@xopcai/xopc 0.0.393 → 0.0.395

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 (152) 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-1AF2KGju.js → agent-avatar-dicebear-BRtkz-ZU.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Dqg2NOn-.js +1 -0
  5. package/dist/gateway/static/root/assets/{agent-plugin-dialog-cjJXJj_3.js → agent-plugin-dialog-CKK95Jmr.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-0zgLsfVA.js +77 -0
  7. package/dist/gateway/static/root/assets/{agents-admin-api-B5aykqg_.js → agents-admin-api-BjGOUrAf.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-B_MFhXXU.js → app-management-settings-panel-BZS8FvoL.js} +1 -1
  9. package/dist/gateway/static/root/assets/{appearance-settings-TYGidVnd.js → appearance-settings-RxXMAxiB.js} +1 -1
  10. package/dist/gateway/static/root/assets/apps-page-mGU9WLjP.js +1 -0
  11. package/dist/gateway/static/root/assets/{archive-plugin-BrFfEp0u.js → archive-plugin-DEnHq3OR.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-B7OofUPF.js → automations-page-BwkugzB8.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-workspace-K8aDhoYt.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-BfAWnYG8.js → binary-plugins-NWeXhh1k.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-_Y-QwZ-3.js → block-editor-D_bKN3BN.js} +3 -3
  16. package/dist/gateway/static/root/assets/{browser-automation-inputs-DH9QHI9m.js → browser-automation-inputs-vtPkXfJ8.js} +1 -1
  17. package/dist/gateway/static/root/assets/browser-automations-page-DBPbwOG8.js +3 -0
  18. package/dist/gateway/static/root/assets/browser-settings-page-VBZDYoXD.js +3 -0
  19. package/dist/gateway/static/root/assets/{capabilities-pt2M56-E.js → capabilities-CTfLd_UE.js} +1 -1
  20. package/dist/gateway/static/root/assets/capabilities-page-CQsGp9Sx.js +2 -0
  21. package/dist/gateway/static/root/assets/capabilities-settings-panel-C_OMsW_8.js +8 -0
  22. package/dist/gateway/static/root/assets/{capability-header-actions-CFVx3iaZ.js → capability-header-actions-CMJXWq8a.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-C_TVCc1N.js +1 -0
  24. package/dist/gateway/static/root/assets/{chat-terminal-dock-D3GuiG3N.js → chat-terminal-dock-9YRAokOl.js} +16 -16
  25. package/dist/gateway/static/root/assets/computer-settings-page-BPYAZ4ks.js +1 -0
  26. package/dist/gateway/static/root/assets/{connector-service-page-CDyCHkpK.js → connector-service-page-B81cEAEX.js} +1 -1
  27. package/dist/gateway/static/root/assets/connectors-page-C0NvAP2V.js +1 -0
  28. package/dist/gateway/static/root/assets/date-picker-BvKP4P3n.js +1 -0
  29. package/dist/gateway/static/root/assets/{dependency-picker-BVJh9sYc.js → dependency-picker-TvrNaf8y.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-Q52A8vjp.js → desktop-pet-De-_QNSD.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-settings-CZr1CXxu.js → desktop-pet-settings-CRSRTIwT.js} +1 -1
  32. package/dist/gateway/static/root/assets/{device-pairing-wizard-D_WWTsze.js → device-pairing-wizard-DnyJ8Bja.js} +1 -1
  33. package/dist/gateway/static/root/assets/{directory-picker-path-field-C6cUgrvg.js → directory-picker-path-field-DOPXwYNR.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-debug-page-DyyfC4gA.js → extension-debug-page-DzXvpUwj.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-Dho9o3ZZ.js → extension-page-C0S1zNeP.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-CdnIGyCH.js → extension-settings-page-C3Z7bFjy.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-swr-BEePO3Wl.js → gateway-config-swr-Di9g6pE8.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-realtime-Dng_VOvI.js → gateway-realtime-2-o7qk92.js} +1 -1
  39. package/dist/gateway/static/root/assets/gateway-realtime-store-DQ6-whg-.js +1 -0
  40. package/dist/gateway/static/root/assets/gateway-settings-Btc2wTQe.js +1 -0
  41. package/dist/gateway/static/root/assets/{gateway-startup-retry-CDCiy7Cd.js → gateway-startup-retry-BCUswcVy.js} +1 -1
  42. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-BNpj_mIM.js → highlighted-body-KQOG7T2V-BFYBbh1P.js} +1 -1
  43. package/dist/gateway/static/root/assets/home-page-C5sLR47Q.js +2 -0
  44. package/dist/gateway/static/root/assets/{image-generation-api-DwkO2y46.js → image-generation-api-Vqcyqnzb.js} +1 -1
  45. package/dist/gateway/static/root/assets/{imports-page-BrYvomnU.js → imports-page-BJGHrzhX.js} +1 -1
  46. package/dist/gateway/static/root/assets/index-BNRLzxpH.js +260 -0
  47. package/dist/gateway/static/root/assets/index-zIgp-ZTu.css +1 -0
  48. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BveDYfYk.js → keyboard-shortcuts-settings-BQkQoPmm.js} +1 -1
  49. package/dist/gateway/static/root/assets/local-app-workbench-page-DbxLz9Ms.js +1 -0
  50. package/dist/gateway/static/root/assets/{local-apps-page-B1a69mlV.js → local-apps-page-CaatwSrK.js} +1 -1
  51. package/dist/gateway/static/root/assets/{local-session-drafts-CYEDUPH7.js → local-session-drafts-BjwlkAKA.js} +1 -1
  52. package/dist/gateway/static/root/assets/{locale-store-CE7L6MlS.js → locale-store-Djl2FW6_.js} +1 -1
  53. package/dist/gateway/static/root/assets/logs-page-3Wo4Lmts.js +2 -0
  54. package/dist/gateway/static/root/assets/management-settings-BHlbM8IM.js +1 -0
  55. package/dist/gateway/static/root/assets/{markdown-view-PrKvVpRh.js → markdown-view-DyO7Q0Ms.js} +1 -1
  56. package/dist/gateway/static/root/assets/{media-plugins-CR1fp6IL.js → media-plugins-Cq1uLrd8.js} +1 -1
  57. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-XhlIBp5t.js +1 -0
  58. package/dist/gateway/static/root/assets/{messages-CaeL_miw.js → messages-DPxcWxfD.js} +2 -2
  59. package/dist/gateway/static/root/assets/note-detail-panel-MjKND8HC.js +5 -0
  60. package/dist/gateway/static/root/assets/notes-page-Cv040hVD.js +8 -0
  61. package/dist/gateway/static/root/assets/{page-context-capture-button-Cn_WK68Y.js → page-context-capture-button-Cp71nTq2.js} +1 -1
  62. package/dist/gateway/static/root/assets/personal-page-CyEUWV2n.js +1 -0
  63. package/dist/gateway/static/root/assets/{preview-open-alternatives-3NbiWGRG.js → preview-open-alternatives-gzCecXc4.js} +1 -1
  64. package/dist/gateway/static/root/assets/{product-open-page-KKE5-V8k.js → product-open-page-CWFT7VuQ.js} +1 -1
  65. package/dist/gateway/static/root/assets/product-preview-content-Dh111Kca.js +1 -0
  66. package/dist/gateway/static/root/assets/project-detail-page-CyhyZiTi.js +1 -0
  67. package/dist/gateway/static/root/assets/projects-page-QUdyJino.js +1 -0
  68. package/dist/gateway/static/root/assets/{registry-api-BO2Ck3aA.js → registry-api-BwR2CiR5.js} +1 -1
  69. package/dist/gateway/static/root/assets/remote-access-hub-Cd8P0Dxs.js +1 -0
  70. package/dist/gateway/static/root/assets/{runtime-tools-api-B1sb8nlw.js → runtime-tools-api-C_VOMhLI.js} +1 -1
  71. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-W0X_Fy7b.js → runtime-tools-settings-panel-bTjVfYm5.js} +1 -1
  72. package/dist/gateway/static/root/assets/{schema-form-DNM2Zdyr.js → schema-form-BGOzfVyj.js} +1 -1
  73. package/dist/gateway/static/root/assets/{session-api-CaAUJvu1.js → session-api-DbNNQps9.js} +1 -1
  74. package/dist/gateway/static/root/assets/{session-manager-DoFTlgNz.js → session-manager-DfVviLTK.js} +1 -1
  75. package/dist/gateway/static/root/assets/sessions-page-BGMemJF6.js +1 -0
  76. package/dist/gateway/static/root/assets/settings-advanced-gate-BiySFw1N.js +1 -0
  77. package/dist/gateway/static/root/assets/{settings-form-section-DCSHPFAN.js → settings-form-section-Bqm1IKvR.js} +1 -1
  78. package/dist/gateway/static/root/assets/{settings-page-B18UbbaJ.js → settings-page-CniJVL-o.js} +1 -1
  79. package/dist/gateway/static/root/assets/setup-status-panel-JPs4-QRw.js +1 -0
  80. package/dist/gateway/static/root/assets/{share-preview-page-BLnS3hoH.js → share-preview-page-BnDGFgBR.js} +1 -1
  81. package/dist/gateway/static/root/assets/shares-settings-Cgp5BuLt.js +1 -0
  82. package/dist/gateway/static/root/assets/{skill-api-CcYGkRPL.js → skill-api-CFdrz6tl.js} +1 -1
  83. package/dist/gateway/static/root/assets/skill-reload-api-Cy5jVfms.js +1 -0
  84. package/dist/gateway/static/root/assets/skills-page-CxaA3P5E.js +2 -0
  85. package/dist/gateway/static/root/assets/sliding-indicator-hwz0sx3h.js +1 -0
  86. package/dist/gateway/static/root/assets/{style-BQqU-1pP.js → style-C_MAnir7.js} +1 -1
  87. package/dist/gateway/static/root/assets/{system-settings-panel-C974myUM.js → system-settings-panel-BjnIlilP.js} +1 -1
  88. package/dist/gateway/static/root/assets/task-detail-page-Bg79rPnF.js +2 -0
  89. package/dist/gateway/static/root/assets/{task-expandable-content-DTEVoNrM.js → task-expandable-content-D3i_51Oc.js} +1 -1
  90. package/dist/gateway/static/root/assets/tracing-settings-page-BCI0tUbe.js +1 -0
  91. package/dist/gateway/static/root/assets/{tunnel-api-DWyI3uA3.js → tunnel-api-0knnta9z.js} +1 -1
  92. package/dist/gateway/static/root/assets/usage-page-D5aT1eie.js +1 -0
  93. package/dist/gateway/static/root/assets/{use-autosave-CY0YuljR.js → use-autosave-Ds_mbAfe.js} +1 -1
  94. package/dist/gateway/static/root/assets/user-model-page-D7L0-pDt.js +2 -0
  95. package/dist/gateway/static/root/assets/{voice-api-key-field-BNG4ixJE.js → voice-api-key-field-CPoGdarN.js} +1 -1
  96. package/dist/gateway/static/root/assets/{voice-config-api-D0Wscn9W.js → voice-config-api-Ceo_hqZC.js} +1 -1
  97. package/dist/gateway/static/root/assets/{work-discovery-overlay-CohIoAre.js → work-discovery-overlay-CWNguy2Z.js} +1 -1
  98. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BcDMFfkT.js +3 -0
  99. package/dist/gateway/static/root/assets/workflows-page-BwZB-s4N.js +6 -0
  100. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-C_COnY_B.js → xopc-cloud-account-card-DlKr98VO.js} +1 -1
  101. package/dist/gateway/static/root/index.html +16 -15
  102. package/dist/package.js +1 -1
  103. package/dist/src/agent/coding/run-verification.js +4 -4
  104. package/dist/src/agent/embedded/agent-profile-context.js +10 -4
  105. package/dist/src/agent/tools/exec-command.d.ts +2 -0
  106. package/dist/src/agent/tools/exec-command.js +45 -1
  107. package/dist/src/config/models-json.d.ts +16 -16
  108. package/dist/src/providers/cloud-thinking.d.ts +3 -0
  109. package/dist/src/providers/cloud-thinking.js +13 -0
  110. package/dist/src/providers/model-registry.js +3 -0
  111. package/dist/src/providers/register-runtime-providers.js +3 -0
  112. package/package.json +4 -4
  113. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CPJr7NRR.js +0 -1
  114. package/dist/gateway/static/root/assets/agents-DW3TlnIg.js +0 -77
  115. package/dist/gateway/static/root/assets/apps-page-DOkyvOF0.js +0 -1
  116. package/dist/gateway/static/root/assets/automations-workspace-DIod-bfm.js +0 -6
  117. package/dist/gateway/static/root/assets/browser-automations-page-B_SnD9B0.js +0 -3
  118. package/dist/gateway/static/root/assets/browser-settings-page-BPlqYpMM.js +0 -3
  119. package/dist/gateway/static/root/assets/capabilities-page-BtzZvMIK.js +0 -2
  120. package/dist/gateway/static/root/assets/capabilities-settings-panel-WzoG3oBb.js +0 -8
  121. package/dist/gateway/static/root/assets/channels-BXA55GY2.js +0 -1
  122. package/dist/gateway/static/root/assets/computer-settings-page-CIbHDlp8.js +0 -1
  123. package/dist/gateway/static/root/assets/connectors-page-DA2b6cJu.js +0 -1
  124. package/dist/gateway/static/root/assets/date-picker-C424c_g9.js +0 -1
  125. package/dist/gateway/static/root/assets/gateway-realtime-store-DtlBf7oH.js +0 -1
  126. package/dist/gateway/static/root/assets/gateway-settings-D0KSQRNZ.js +0 -1
  127. package/dist/gateway/static/root/assets/home-page-CH_A0W29.js +0 -2
  128. package/dist/gateway/static/root/assets/index-CKdOZoVu.js +0 -260
  129. package/dist/gateway/static/root/assets/index-Rxjt-jc3.css +0 -1
  130. package/dist/gateway/static/root/assets/local-app-workbench-page-CcIi1BhT.js +0 -1
  131. package/dist/gateway/static/root/assets/logs-page-Us1jv3C4.js +0 -2
  132. package/dist/gateway/static/root/assets/management-settings-C9RAM7-s.js +0 -1
  133. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-DQdcaMiu.js +0 -1
  134. package/dist/gateway/static/root/assets/note-detail-panel-Q4yRx9iZ.js +0 -5
  135. package/dist/gateway/static/root/assets/notes-page-C9qu16IN.js +0 -8
  136. package/dist/gateway/static/root/assets/personal-page-DrP6hEcg.js +0 -1
  137. package/dist/gateway/static/root/assets/product-preview-content-BM0oqNxi.js +0 -1
  138. package/dist/gateway/static/root/assets/project-detail-page-CPZrwf8n.js +0 -1
  139. package/dist/gateway/static/root/assets/projects-page-Besfx_07.js +0 -1
  140. package/dist/gateway/static/root/assets/remote-access-hub-CTDghL5L.js +0 -1
  141. package/dist/gateway/static/root/assets/sessions-page-Dxtablvd.js +0 -1
  142. package/dist/gateway/static/root/assets/settings-advanced-gate-C7zklouD.js +0 -1
  143. package/dist/gateway/static/root/assets/setup-status-panel-JoSfluza.js +0 -1
  144. package/dist/gateway/static/root/assets/shares-settings-DcIuPJK3.js +0 -1
  145. package/dist/gateway/static/root/assets/skill-reload-api-PnUZjoPK.js +0 -1
  146. package/dist/gateway/static/root/assets/skills-page-D3JAw62U.js +0 -2
  147. package/dist/gateway/static/root/assets/task-detail-page-CiljFekC.js +0 -2
  148. package/dist/gateway/static/root/assets/tracing-settings-page-DEE75MUn.js +0 -1
  149. package/dist/gateway/static/root/assets/usage-page-DJYvbxk7.js +0 -1
  150. package/dist/gateway/static/root/assets/user-model-page-eHZJD6Fw.js +0 -2
  151. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BXI8eyYh.js +0 -3
  152. package/dist/gateway/static/root/assets/workflows-page-CVti0u-l.js +0 -6
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./plus-Q2yW6OE7.js";import{t as s}from"./messages-DPxcWxfD.js";import{a as c,n as l,r as u}from"./locale-store-Djl2FW6_.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{r as f}from"./gateway-config-swr-Di9g6pE8.js";import{n as p,t as m}from"./registry-api-BwR2CiR5.js";import{$i as h,Fn as g,In as _,Mu as v,Rc as y,Vl as b,Wc as x,Xl as S,as as C,ju as w,xd as ee}from"./index-BNRLzxpH.js";import{n as T,r as E}from"./settings-page-layout-Dx5S-Msc.js";var D=n(),O=e(t(),1),k=r();function te({zh:e}){let t=s(e?`zh`:`en`).computerSettings,n=d(`settings-agent-defaults`,g),r=d(m,p),a=n.data?.defaults.models.computerUse?.primary??``,[o,c]=(0,O.useState)(a),[l,u]=(0,O.useState)(!1),[f,v]=(0,O.useState)(``),[b,S]=(0,O.useState)(!1);(0,O.useEffect)(()=>{c(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{u(!0),v(``),S(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await g(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await _({...e.defaults,models:r});await n.mutate(i,!1),S(!0)}catch(e){v(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,k.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,k.jsx)(y,{className:`h-52 w-full rounded-xl`}):n.error?(0,k.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,k.jsx)(x,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,k.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 sm:p-5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1`,children:r.isLoading?(0,k.jsx)(y,{className:`h-11 w-full rounded-lg`}):(0,k.jsx)(h,{value:o,onChange:e=>{c(e),S(!1)},disabled:l,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`})}),(0,k.jsx)(x,{variant:`primary`,disabled:l||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel})]}),(0,k.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,k.jsx)(`span`,{children:t.modelDataUse}),(0,k.jsx)(x,{asChild:!0,variant:`ghost`,className:`h-auto p-0 text-xs`,children:(0,k.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),b&&(0,k.jsx)(`span`,{role:`status`,children:t.modelSaved})]}),!C&&!r.isLoading&&!r.error&&(0,k.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,k.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:[String(r.error),(0,k.jsx)(x,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),f&&(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:f})]})]})}function A(e){let t=(0,D.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,k.jsx)(`div`,{className:`flex size-6 shrink-0 items-center justify-center text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,k.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,k.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,k.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,k.jsxs)(`div`,{className:`flex min-h-16 flex-wrap items-center gap-3 px-4 py-3 sm:flex-nowrap sm:px-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function j(){let e=(0,D.c)(2),t=l(M)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,k.jsx)(N,{zh:t}),e[0]=t,e[1]=n),n}function M(e){return e.language}function N({zh:e}){let t=s(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:l}=f(!0),d=n?.payload?.config,[p,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(``),[_,D]=(0,O.useState)(!1),[j,M]=(0,O.useState)(null),[N,P]=(0,O.useState)(!1),[F,I]=(0,O.useState)(null),[ne,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(!1),[re,H]=(0,O.useState)(!1),U=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,W=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,O.useEffect)(()=>{if(!U)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await U.status();e||(M(t),P(!1))}catch{e||(M(null),P(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[U]),(0,O.useEffect)(()=>{if(!U?.access)return;let e=!1;return U.access().then(t=>{e||(I(t),L(!1))}).catch(()=>{e||L(!0)}),()=>{e=!0}},[U]);let G=async e=>{m(!0),g(``);try{await e()}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}},ie=e=>G(async()=>{C()&&(await c(u(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r())}),ae=async()=>{g(``),D(!1);try{await U?.stop(),D(!0),U&&M(await U.status())}catch(e){g(e instanceof Error?e.message:String(e))}},K=j?.session?.status??`idle`,q=t.states[K]??K,J=C()&&d?.computer?.enabled===!0,oe=j?.controlPaused?t.pausedNotice:J?j?.connected?`${t.connected} · ${q}`:j?t.disconnected:t.checking:t.disabled,Y=!U||N||j?.reenrollmentRequired===!0||!!(j?.error||j?.session?.errorCode)||j!=null&&(!j.permissions.accessibility||j.permissions.screenRecording!==`granted`),X=j?.permissions.accessibility===!0&&j.permissions.screenRecording===`granted`&&!j.reenrollmentRequired,Z=F?.apps.filter(e=>F.authorizedAppIds.includes(e.appId))??[],Q=F?.apps.filter(e=>!F.authorizedAppIds.includes(e.appId)&&`${e.name} ${e.appId}`.toLocaleLowerCase().includes(R.toLocaleLowerCase()))??[],$=(0,k.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),U?N?(0,k.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):j?X&&!re?(0,k.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,k.jsx)(A,{icon:(0,k.jsx)(S,{className:`size-5`}),title:t.systemPermissions,description:t.granted,children:(0,k.jsx)(x,{onClick:()=>H(!0),children:t.viewDetails})})}):(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(v,{className:`size-5`}),title:t.device,description:(0,k.jsxs)(`span`,{"aria-live":`polite`,children:[j.connected?t.connected:t.disconnected,` · `,q]}),children:j.reenrollmentRequired&&(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{M(await U.reenroll())})},children:t.reenroll})}),W&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(A,{icon:(0,k.jsx)(S,{className:`size-5`}),title:t.accessibility,children:[(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.accessibility?t.granted:t.notGranted}),!j.permissions.accessibility&&(0,k.jsx)(x,{disabled:p,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{G(()=>W.requestAccessibility())},children:t.openSettings})]}),(0,k.jsxs)(A,{icon:(0,k.jsx)(v,{className:`size-5`}),title:t.screen,children:[(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.screenRecording===`granted`?t.granted:t.notGranted}),j.permissions.screenRecording!==`granted`&&(0,k.jsx)(x,{disabled:p,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{G(()=>W.requestScreen())},children:t.openSettings})]})]}),X&&(0,k.jsx)(`div`,{className:`flex justify-end px-4 py-2 sm:px-5`,children:(0,k.jsx)(x,{variant:`ghost`,onClick:()=>H(!1),children:t.hideDetails})})]}):(0,k.jsx)(`div`,{"aria-label":t.checking,children:(0,k.jsx)(y,{className:`h-20 w-full rounded-xl`})}):(0,k.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(j?.error||j?.session?.errorCode)&&(0,k.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:j.error||j.session?.errorCode})]});return(0,k.jsxs)(E,{gap:`gap-7`,children:[(0,k.jsx)(T,{title:t.title,subtitle:t.subtitle,meta:(0,k.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview}),actions:U&&(0,k.jsxs)(x,{onClick:()=>{ae()},children:[(0,k.jsx)(b,{className:`size-3.5`}),t.stop]})}),h&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:h}),_&&(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),(0,k.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!d&&!l?(0,k.jsx)(y,{className:`h-32 w-full rounded-xl`}):l?(0,k.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(l),` `,(0,k.jsx)(x,{onClick:()=>{G(()=>r())},children:t.retry})]}):(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(w,{className:`size-5`}),title:t.desktop,description:(0,k.jsx)(`span`,{"aria-live":`polite`,children:oe}),children:(0,k.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":J,disabled:p||!C(),onClick:()=>{ie(d?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,k.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${J?`bg-accent`:`bg-fg-muted/30`}`,children:(0,k.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${J?`translate-x-5`:`translate-x-0`}`})})})}),j?.controlPaused&&(0,k.jsx)(`div`,{className:`flex justify-end border-t border-edge-subtle px-4 py-3 sm:px-5`,children:(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{U&&M(await U.resume()),D(!1)})},children:t.resume})})]})]}),Y&&$,U?.access&&(0,k.jsxs)(`section`,{"aria-labelledby":`computer-app-access-title`,className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsx)(`h2`,{id:`computer-app-access-title`,className:`text-sm font-semibold text-fg`,children:t.appAccess}),!F?.allowAllApps&&(0,k.jsxs)(x,{disabled:p,"aria-expanded":B,"aria-controls":B?`computer-app-picker`:void 0,onClick:()=>{V(e=>!e),z(``)},children:[B?(0,k.jsx)(a,{className:`size-4`,"aria-hidden":!0}):(0,k.jsx)(o,{className:`size-4`,"aria-hidden":!0}),B?t.doneAdding:t.addApp]})]}),F?(0,k.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(w,{className:`size-5`}),title:t.anyApp,description:t.anyAppDescription,children:(0,k.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.anyApp,"aria-checked":F.allowAllApps===!0,disabled:p,onClick:()=>{G(async()=>{I(await U.setAllAppAccess(!F.allowAllApps)),V(!1)})},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,k.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${F.allowAllApps?`bg-accent`:`bg-fg-muted/30`}`,children:(0,k.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${F.allowAllApps?`translate-x-5`:`translate-x-0`}`})})})}),!F.allowAllApps&&(0,k.jsx)(`div`,{className:`border-t border-edge-subtle`,children:Z.length?Z.map(e=>(0,k.jsxs)(`div`,{className:`flex min-h-16 items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3 last:border-b-0 sm:px-5`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,k.jsx)(x,{disabled:p,variant:`ghost`,onClick:()=>{G(async()=>{let t=await U.setAppAccess(e.appId,!1);I(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.revokeApp})]},e.appId)):(0,k.jsx)(`p`,{className:`px-5 py-6 text-center text-sm text-fg-muted`,children:t.noAuthorizedApps})})]}):ne?(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.appListError}):(0,k.jsx)(y,{className:`h-20 w-full rounded-xl`}),B&&!F?.allowAllApps&&(0,k.jsxs)(`div`,{id:`computer-app-picker`,className:`space-y-3 rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`input`,{"aria-label":t.searchApps,value:R,onChange:e=>z(e.target.value),placeholder:t.searchApps,className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{I(await U.access()),L(!1)})},children:t.refreshApps})]}),F&&(0,k.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-xl border border-edge`,children:Q.length?Q.map(e=>(0,k.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3 border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,k.jsx)(x,{disabled:p,variant:`secondary`,onClick:()=>{G(async()=>{let t=await U.setAppAccess(e.appId,!0);I(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.authorizeApp})]},e.appId)):(0,k.jsx)(`p`,{className:`px-3 py-5 text-center text-sm text-fg-muted`,children:F.appsBusy?t.appsBusy:F.appsUnavailable?t.appListError:t.noMatchingApps})})]})]}),(0,k.jsx)(te,{zh:e}),!Y&&$,(0,k.jsxs)(`section`,{"aria-labelledby":`computer-browser-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-browser-title`,className:`text-sm font-semibold text-fg`,children:t.otherControl}),(0,k.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,k.jsx)(A,{icon:(0,k.jsx)(ee,{className:`size-5`}),title:t.browser,description:d?d.browser?.enabled?t.browserEnabled:t.browserDisabled:t.checking,children:(0,k.jsx)(x,{asChild:!0,children:(0,k.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})})]}),(0,k.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.previewFootnote})]})}export{j as ComputerSettingsPage,N as ComputerSettingsPanel};
@@ -1 +1 @@
1
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as o}from"./x-B_N4OPjy.js";import{t as s}from"./messages-CaeL_miw.js";import{n as c}from"./locale-store-CE7L6MlS.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BGTk37IG.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{$s as v,Hc as y,Ic as b,It as x,Xa as S,Xl as C,js as w,uc as T,vc as E,xc as D}from"./index-CKdOZoVu.js";var O=t({ConnectorServiceDialog:()=>I,ConnectorServicePage:()=>M}),k=r(),A=e(n(),1),j=i();function M(){let e=(0,k.c)(11),t=c(N),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,o;e[2]===r.title?o=e[3]:(o=(0,j.jsx)(a,{to:`/capabilities/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=o);let l=i?`应用连接服务`:`App connection service`,u;e[4]===l?u=e[5]:(u=(0,j.jsx)(`h1`,{className:`text-xl font-semibold`,children:l}),e[4]=l,e[5]=u);let d,f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:(0,j.jsx)(P,{})}),f=(0,j.jsx)(R,{}),e[6]=d,e[7]=f):(d=e[6],f=e[7]);let p;return e[8]!==o||e[9]!==u?(p=(0,j.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[o,u,d,f]}),e[8]=o,e[9]=u,e[10]=p):p=e[10],p}function N(e){return e.language}function P(){let e=(0,k.c)(2),t=c(F)===`zh`?`此设置决定新账号通过哪个服务连接。已有账号继续使用其原来的连接服务。`:`Choose the service for new accounts. Existing accounts keep their original service.`,n;return e[0]===t?n=e[1]:(n=(0,j.jsx)(j.Fragment,{children:t}),e[0]=t,e[1]=n),n}function F(e){return e.language}function I(e){let t=(0,k.c)(27),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{open:r,onOpenChange:i,hideTrigger:a}=n,_=a===void 0?!1:a,v=c(L),b;t[2]===v?b=t[3]:(b=s(v),t[2]=v,t[3]=b);let x=b.connectorsSettings,S=v===`zh`,w;t[4]!==_||t[5]!==S?(w=_?null:(0,j.jsx)(u,{asChild:!0,children:(0,j.jsxs)(y,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":S?`应用连接服务`:`Connection service`,children:[(0,j.jsx)(C,{className:`size-4`,"aria-hidden":!0}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:S?`应用连接服务`:`Connection service`})]})}),t[4]=_,t[5]=S,t[6]=w):w=t[6];let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,j.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[7]=T):T=t[7];let E=S?`应用连接服务`:`App connection service`,D;t[8]===E?D=t[9]:(D=(0,j.jsx)(h,{className:`text-base font-semibold text-fg`,children:E}),t[8]=E,t[9]=D);let O;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,j.jsx)(d,{className:`mt-1 text-sm text-fg-muted`,children:(0,j.jsx)(P,{})}),t[10]=O):O=t[10];let A;t[11]===D?A=t[12]:(A=(0,j.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[11]=D,t[12]=A);let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,j.jsx)(o,{className:`size-5`,"aria-hidden":!0}),t[13]=M):M=t[13];let N;t[14]===x.modalClose?N=t[15]:(N=(0,j.jsx)(f,{asChild:!0,children:(0,j.jsx)(y,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":x.modalClose,children:M})}),t[14]=x.modalClose,t[15]=N);let F;t[16]!==N||t[17]!==A?(F=(0,j.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[A,N]}),t[16]=N,t[17]=A,t[18]=F):F=t[18];let I;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,j.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,j.jsx)(R,{})}),t[19]=I):I=t[19];let z;t[20]===F?z=t[21]:(z=(0,j.jsxs)(p,{children:[T,(0,j.jsxs)(m,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100dvh-2rem,42rem)] w-[min(100%-2rem,42rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-float`,children:[F,I]})]}),t[20]=F,t[21]=z);let B;return t[22]!==i||t[23]!==r||t[24]!==z||t[25]!==w?(B=(0,j.jsxs)(g,{open:r,onOpenChange:i,children:[w,z]}),t[22]=i,t[23]=r,t[24]=z,t[25]=w,t[26]=B):B=t[26],B}function L(e){return e.language}function R(){let e=c(e=>e.language),t=s(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=_(`connector-service`,T),[o,l]=(0,A.useState)(``),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(),[m,h]=(0,A.useState)();async function g(e){d(!0),p(void 0);try{await e(),l(``),await a()}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,j.jsx)(b,{className:`h-40 w-full`}):null,r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,j.jsx)(`h2`,{className:`font-medium`,children:`XOPC Cloud`}),(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioSetupHint}),(0,j.jsx)(x,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,j.jsx)(y,{variant:`secondary`,disabled:u||r.mode===`managed`&&r.configured,onClick:()=>void g(()=>D({mode:`managed`})),children:r.mode===`managed`?n?`当前服务`:`Current service`:n?`使用 XOPC Cloud`:`Use XOPC Cloud`})]}),(0,j.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,j.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:t.composioSetupByok}),(0,j.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,j.jsxs)(`ol`,{className:`list-inside list-decimal text-sm text-fg-muted`,children:[(0,j.jsx)(`li`,{children:t.composioSetupStepProject}),(0,j.jsx)(`li`,{children:t.composioSetupStepKey}),(0,j.jsx)(`li`,{children:t.composioSetupStepPaste})]}),(0,j.jsx)(`a`,{href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent-fg`,children:t.composioSetupOpenDashboard}),(0,j.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,j.jsx)(`span`,{children:`Composio API key`}),(0,j.jsx)(w,{value:o,onChange:l,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,j.jsx)(y,{disabled:u||!o.trim(),onClick:()=>void g(()=>v(o)),children:n?`验证并使用新项目`:`Verify and use new project`}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n?`验证只检查连接服务和现有账号访问,不执行写入。工具权限在实际使用时检查。环境变量密钥需在运行环境中修改。`:`Verification checks service and existing account access without writes. Tool permissions are checked on use. Environment keys must be updated in the gateway environment.`}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSessionWritePermissionHint}),r.backends?.filter(e=>e.mode===`byok`).map(e=>(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-sm`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`p`,{children:e.label}),(0,j.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.credentialSource===`environment`?n?`环境变量`:`Environment`:n?`本地保存`:`Stored locally`,e.verifiedAt&&` · ${new Date(e.verifiedAt).toLocaleString()}`]})]}),(0,j.jsx)(y,{variant:`ghost`,disabled:u||!o.trim()||e.credentialSource===`environment`,onClick:()=>void g(()=>v(o,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,j.jsx)(y,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>void g(()=>D({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,j.jsx)(y,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>h(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,f||i?(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f??String(i)}):null,(0,j.jsx)(S,{open:!!m,title:n?`移除连接服务`:`Remove connection service`,description:n?`移除此服务及其本地保存的密钥,不修改环境变量。需要先切换服务并断开该项目的账号,已有数据不会删除。`:`Remove this service and its saved key, without changing environment variables. Switch services and disconnect this project’s accounts first. Existing data is retained.`,confirmLabel:n?`移除`:`Remove`,cancelLabel:t.modalCancel,destructive:!0,onCancel:()=>h(void 0),onConfirm:()=>{let e=m;h(void 0),e&&g(()=>E(e))}})]})}export{O as n,I as t};
1
+ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as o}from"./x-B_N4OPjy.js";import{t as s}from"./messages-DPxcWxfD.js";import{n as c}from"./locale-store-Djl2FW6_.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BGTk37IG.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{Cc as v,It as y,Ns as b,Ql as x,Rc as S,Wc as C,Za as w,bc as T,fc as E,tc as D}from"./index-BNRLzxpH.js";var O=t({ConnectorServiceDialog:()=>I,ConnectorServicePage:()=>M}),k=r(),A=e(n(),1),j=i();function M(){let e=(0,k.c)(11),t=c(N),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,o;e[2]===r.title?o=e[3]:(o=(0,j.jsx)(a,{to:`/capabilities/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=o);let l=i?`应用连接服务`:`App connection service`,u;e[4]===l?u=e[5]:(u=(0,j.jsx)(`h1`,{className:`text-xl font-semibold`,children:l}),e[4]=l,e[5]=u);let d,f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:(0,j.jsx)(P,{})}),f=(0,j.jsx)(R,{}),e[6]=d,e[7]=f):(d=e[6],f=e[7]);let p;return e[8]!==o||e[9]!==u?(p=(0,j.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[o,u,d,f]}),e[8]=o,e[9]=u,e[10]=p):p=e[10],p}function N(e){return e.language}function P(){let e=(0,k.c)(2),t=c(F)===`zh`?`此设置决定新账号通过哪个服务连接。已有账号继续使用其原来的连接服务。`:`Choose the service for new accounts. Existing accounts keep their original service.`,n;return e[0]===t?n=e[1]:(n=(0,j.jsx)(j.Fragment,{children:t}),e[0]=t,e[1]=n),n}function F(e){return e.language}function I(e){let t=(0,k.c)(27),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{open:r,onOpenChange:i,hideTrigger:a}=n,_=a===void 0?!1:a,v=c(L),y;t[2]===v?y=t[3]:(y=s(v),t[2]=v,t[3]=y);let b=y.connectorsSettings,S=v===`zh`,w;t[4]!==_||t[5]!==S?(w=_?null:(0,j.jsx)(u,{asChild:!0,children:(0,j.jsxs)(C,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":S?`应用连接服务`:`Connection service`,children:[(0,j.jsx)(x,{className:`size-4`,"aria-hidden":!0}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:S?`应用连接服务`:`Connection service`})]})}),t[4]=_,t[5]=S,t[6]=w):w=t[6];let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,j.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[7]=T):T=t[7];let E=S?`应用连接服务`:`App connection service`,D;t[8]===E?D=t[9]:(D=(0,j.jsx)(h,{className:`text-base font-semibold text-fg`,children:E}),t[8]=E,t[9]=D);let O;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,j.jsx)(d,{className:`mt-1 text-sm text-fg-muted`,children:(0,j.jsx)(P,{})}),t[10]=O):O=t[10];let A;t[11]===D?A=t[12]:(A=(0,j.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[11]=D,t[12]=A);let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,j.jsx)(o,{className:`size-5`,"aria-hidden":!0}),t[13]=M):M=t[13];let N;t[14]===b.modalClose?N=t[15]:(N=(0,j.jsx)(f,{asChild:!0,children:(0,j.jsx)(C,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":b.modalClose,children:M})}),t[14]=b.modalClose,t[15]=N);let F;t[16]!==N||t[17]!==A?(F=(0,j.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[A,N]}),t[16]=N,t[17]=A,t[18]=F):F=t[18];let I;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,j.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,j.jsx)(R,{})}),t[19]=I):I=t[19];let z;t[20]===F?z=t[21]:(z=(0,j.jsxs)(p,{children:[T,(0,j.jsxs)(m,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100dvh-2rem,42rem)] w-[min(100%-2rem,42rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-float`,children:[F,I]})]}),t[20]=F,t[21]=z);let B;return t[22]!==i||t[23]!==r||t[24]!==z||t[25]!==w?(B=(0,j.jsxs)(g,{open:r,onOpenChange:i,children:[w,z]}),t[22]=i,t[23]=r,t[24]=z,t[25]=w,t[26]=B):B=t[26],B}function L(e){return e.language}function R(){let e=c(e=>e.language),t=s(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=_(`connector-service`,E),[o,l]=(0,A.useState)(``),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(),[m,h]=(0,A.useState)();async function g(e){d(!0),p(void 0);try{await e(),l(``),await a()}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,j.jsx)(S,{className:`h-40 w-full`}):null,r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,j.jsx)(`h2`,{className:`font-medium`,children:`XOPC Cloud`}),(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioSetupHint}),(0,j.jsx)(y,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,j.jsx)(C,{variant:`secondary`,disabled:u||r.mode===`managed`&&r.configured,onClick:()=>void g(()=>v({mode:`managed`})),children:r.mode===`managed`?n?`当前服务`:`Current service`:n?`使用 XOPC Cloud`:`Use XOPC Cloud`})]}),(0,j.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,j.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:t.composioSetupByok}),(0,j.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,j.jsxs)(`ol`,{className:`list-inside list-decimal text-sm text-fg-muted`,children:[(0,j.jsx)(`li`,{children:t.composioSetupStepProject}),(0,j.jsx)(`li`,{children:t.composioSetupStepKey}),(0,j.jsx)(`li`,{children:t.composioSetupStepPaste})]}),(0,j.jsx)(`a`,{href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent-fg`,children:t.composioSetupOpenDashboard}),(0,j.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,j.jsx)(`span`,{children:`Composio API key`}),(0,j.jsx)(b,{value:o,onChange:l,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,j.jsx)(C,{disabled:u||!o.trim(),onClick:()=>void g(()=>D(o)),children:n?`验证并使用新项目`:`Verify and use new project`}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n?`验证只检查连接服务和现有账号访问,不执行写入。工具权限在实际使用时检查。环境变量密钥需在运行环境中修改。`:`Verification checks service and existing account access without writes. Tool permissions are checked on use. Environment keys must be updated in the gateway environment.`}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSessionWritePermissionHint}),r.backends?.filter(e=>e.mode===`byok`).map(e=>(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-sm`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`p`,{children:e.label}),(0,j.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.credentialSource===`environment`?n?`环境变量`:`Environment`:n?`本地保存`:`Stored locally`,e.verifiedAt&&` · ${new Date(e.verifiedAt).toLocaleString()}`]})]}),(0,j.jsx)(C,{variant:`ghost`,disabled:u||!o.trim()||e.credentialSource===`environment`,onClick:()=>void g(()=>D(o,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,j.jsx)(C,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>void g(()=>v({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,j.jsx)(C,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>h(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,f||i?(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f??String(i)}):null,(0,j.jsx)(w,{open:!!m,title:n?`移除连接服务`:`Remove connection service`,description:n?`移除此服务及其本地保存的密钥,不修改环境变量。需要先切换服务并断开该项目的账号,已有数据不会删除。`:`Remove this service and its saved key, without changing environment variables. Switch services and disconnect this project’s accounts first. Existing data is retained.`,confirmLabel:n?`移除`:`Remove`,cancelLabel:t.modalCancel,destructive:!0,onCancel:()=>h(void 0),onConfirm:()=>{let e=m;h(void 0),e&&g(()=>T(e))}})]})}export{O as n,I as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./ellipsis-0k4rZLoy.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./eye-CABVeTq0.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./messages-DPxcWxfD.js";import{t as p}from"./cn-0WouolD0.js";import{a as m,c as h,n as g,r as _}from"./locale-store-Djl2FW6_.js";import{a as v,i as y,n as b,o as x,r as S,s as C,t as w}from"./dist-BGTk37IG.js";import{n as T}from"./copy-to-clipboard-HOJ79TWv.js";import{n as E,r as D}from"./gateway-config-swr-Di9g6pE8.js";import{$ as O,Ac as k,Al as A,Ao as j,Dc as M,Du as N,Ec as P,Fd as F,Go as I,Ic as ee,J as L,Jd as R,Jn as z,Ll as B,Mc as V,Nc as H,Oc as U,Pc as W,Q as G,Ql as te,Rc as K,Rd as ne,Rs as q,Sc as re,Tc as ie,Wc as J,Wu as ae,X as oe,Xd as Y,Xn as se,Y as ce,Yn as le,Z as X,Za as ue,Zn as de,_c as fe,ac as pe,ar as me,cc as he,dc as ge,ds as _e,er as ve,et as ye,eu as be,fs as Z,gc as xe,hc as Se,ic as Ce,is as we,iu as Te,jc as Ee,kc as De,lc as Oe,lf as ke,mc as Ae,nc as je,nr as Me,oc as Ne,of as Pe,os as Fe,pc as Ie,rc as Le,rr as Re,sc as ze,sd as Be,sf as Ve,su as He,tr as Ue,uc as We,us as Ge,vc as Ke,wc as qe,xc as Je,yc as Ye,yl as Xe,zo as Ze}from"./index-BNRLzxpH.js";import{n as Qe,t as $e}from"./capability-header-actions-CMJXWq8a.js";import{t as et}from"./connector-service-page-B81cEAEX.js";import{n as tt}from"./agent-plugin-dialog-CKK95Jmr.js";import{t as nt}from"./number-input-DDeqHK-G.js";var Q=e(t(),1),rt=n(),$=r();function it(e){let t=(0,rt.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:s}=e,c,l,u,d,f,m;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==s){let e=n.capabilities.filter(at),h=e.slice(0,2),g=Math.max(0,e.length-h.length),_=s.connect,v;t[11]!==n||t[12]!==s?(v=X(n,s),t[11]=n,t[12]=s,t[13]=v):v=t[13];let y=v,b=n.verificationLevel===`verified`?s.connectorVerified:n.verificationLevel===`beta`?s.connectorBeta:n.verificationLevel===`experimental`?s.connectorExperimental:null,x;t[14]!==_||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:p(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(N,{className:`size-4`}),_]}),t[14]=_,t[15]=n,t[16]=i,t[17]=x):x=t[17],c=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`,l=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(ye,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=C):C=t[22];let w;t[23]===b?w=t[24]:(w=b?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:b}):null,t[23]=b,t[24]=w);let T;t[25]!==w||t[26]!==C?(T=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[25]=w,t[26]=C,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==S?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,T]}),t[28]=T,t[29]=S,t[30]=E):E=t[30];let D;t[31]!==r||t[32]!==c?(D=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:c()}),t[31]=r,t[32]=c,t[33]=D):D=t[33];let O;t[34]!==r||t[35]!==s.connectedBadge?(O=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(o,{className:`size-3`,"aria-hidden":!0}),s.connectedBadge]}):null,t[34]=r,t[35]=s.connectedBadge,t[36]=O):O=t[36];let k;t[37]!==D||t[38]!==O?(k=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[D,O]}),t[37]=D,t[38]=O,t[39]=k):k=t[39],t[40]!==E||t[41]!==k?(u=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,k]}),t[40]=E,t[41]=k,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:s.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]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=m}else c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],m=t[10];let h;t[45]!==l||t[46]!==u||t[47]!==d||t[48]!==f?(h=(0,$.jsxs)(`div`,{className:l,children:[u,d,f]}),t[45]=l,t[46]=u,t[47]=d,t[48]=f,t[49]=h):h=t[49];let g;t[50]!==r||t[51]!==c?(g=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:c(`w-full`)}),t[50]=r,t[51]=c,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 at(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ot=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function st(e,t){return t.some(t=>t.connectorId===e.id)}var ct=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function lt(){let e=(0,rt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:p(`size-10 shrink-0 rounded-xl`,ct)}),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`,ct)}),(0,$.jsx)(`div`,{className:p(`h-8 w-[4.5rem] shrink-0 rounded-lg`,ct)})]}),(0,$.jsx)(`div`,{className:p(`h-3 w-full`,ct)}),(0,$.jsx)(`div`,{className:p(`h-3 w-[88%]`,ct)})]})]})}),e[1]=n):n=e[1],n}var ut=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function dt(){let e=(0,rt.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:p(`size-10 shrink-0 rounded-xl`,ut)}),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`,ut)}),(0,$.jsx)(`div`,{className:p(`h-3 w-72 max-w-full`,ut)})]}),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`,ut)}),(0,$.jsx)(`div`,{className:p(`h-9 w-20 rounded-lg`,ut)})]})]})]}),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`,ut)}),(0,$.jsx)(`div`,{className:p(`h-8 w-24 rounded-md`,ut)}),(0,$.jsx)(`div`,{className:p(`h-8 w-28 rounded-md`,ut)})]}),(0,$.jsx)(`div`,{className:p(`mt-3 h-20 rounded-xl`,ut)})]}),e[3]=i):i=e[3],i}var ft=[`understand`,`act`,`reach`];function pt(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 mt(e){return pt(e)[0]??`act`}function ht(e,t){let n=t?mt(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 gt(e,t){return t.connectorCapabilityLabels[e]??e}function _t(e,t){if(e.runtime.type===`mcp`)return G(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return G(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function vt(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function yt(e){let t=(0,rt.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:s}=e,c;t[0]!==n||t[1]!==s?(c=X(n,s),t[0]=n,t[1]=s,t[2]=c):c=t[2];let l=c,u,f,m,h,g,_,T,E,D,O,k,A,j,M,P,F;if(t[3]!==n||t[4]!==l||t[5]!==r||t[6]!==i||t[7]!==s){let e=pt(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(St),...(n.setup.config??[]).filter(xt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let c=a,N=n.capabilities.filter(bt);m=w,T=!0,t[27]===i?E=t[28]:(E=e=>{e||i()},t[27]=i,t[28]=E),f=x,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=_):_=t[29],u=S,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(h=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`),t[30]=h):h=t[30];let I;t[31]===n?I=t[32]:(I=(0,$.jsx)(ye,{connector:n,size:`lg`}),t[31]=n,t[32]=I);let L;t[33]===n.displayName?L=t[34]:(L=(0,$.jsx)(C,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=L);let R;t[35]!==r||t[36]!==s.connectedBadge?(R=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(o,{className:`size-3`,"aria-hidden":!0}),s.connectedBadge]}):null,t[35]=r,t[36]=s.connectedBadge,t[37]=R):R=t[37];let z;t[38]!==L||t[39]!==R?(z=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[L,R]}),t[38]=L,t[39]=R,t[40]=z):z=t[40];let B;t[41]===l?B=t[42]:(B=(0,$.jsx)(y,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:l}),t[41]=l,t[42]=B);let V;t[43]!==z||t[44]!==B?(V=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[z,B]}),t[43]=z,t[44]=B,t[45]=V):V=t[45];let H;t[46]!==I||t[47]!==V?(H=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[I,V]}),t[46]=I,t[47]=V,t[48]=H):H=t[48];let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=p(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ee.focusRingPanel),t[49]=U):U=t[49];let W;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(d,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=W):W=t[50];let te;t[51]===s.modalClose?te=t[52]:(te=(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:U,"aria-label":s.modalClose,children:W})}),t[51]=s.modalClose,t[52]=te),t[53]!==H||t[54]!==te?(g=(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:[H,te]}),t[53]=H,t[54]=te,t[55]=g):g=t[55],M=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,P=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.connectorBenefitHints[e]})]},e))})]}):null;let K;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(Be,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=K):K=t[56];let ne;t[57]===s.detailPermissions?ne=t[58]:(ne=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.detailPermissions}),t[57]=s.detailPermissions,t[58]=ne);let q;t[59]!==n||t[60]!==s?(q=vt(n,s),t[59]=n,t[60]=s,t[61]=q):q=t[61];let re;t[62]===q?re=t[63]:(re=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:q}),t[62]=q,t[63]=re);let ie;t[64]!==ne||t[65]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[K,(0,$.jsxs)(`div`,{children:[ne,re]})]}),t[64]=ne,t[65]=re,t[66]=ie):ie=t[66];let J;t[67]===s.connectorSetupTitle?J=t[68]:(J=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.connectorSetupTitle}),t[67]=s.connectorSetupTitle,t[68]=J);let ae;t[69]!==c.length||t[70]!==s.connectorRequiredInputsCount||t[71]!==s.connectorSetupNone?(ae=c.length?G(s.connectorRequiredInputsCount,{count:String(c.length)}):s.connectorSetupNone,t[69]=c.length,t[70]=s.connectorRequiredInputsCount,t[71]=s.connectorSetupNone,t[72]=ae):ae=t[72];let oe;t[73]===ae?oe=t[74]:(oe=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:ae}),t[73]=ae,t[74]=oe);let Y;t[75]!==J||t[76]!==oe?(Y=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[J,oe]}),t[75]=J,t[76]=oe,t[77]=Y):Y=t[77],t[78]!==ie||t[79]!==Y?(F=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[ie,Y]}),t[78]=ie,t[79]=Y,t[80]=F):F=t[80],A=`rounded-xl border border-edge bg-surface-base`,t[81]===s.connectorTechnicalDetails?j=t[82]:(j=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:s.connectorTechnicalDetails}),t[81]=s.connectorTechnicalDetails,t[82]=j),D=`space-y-5 border-t border-edge-subtle px-4 py-4`;let se;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(be,{className:`size-3.5`,"aria-hidden":!0}),t[83]=se):se=t[83];let ce;t[84]===s.connectorRuntimeTitle?ce=t[85]:(ce=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[se,s.connectorRuntimeTitle]}),t[84]=s.connectorRuntimeTitle,t[85]=ce);let le;t[86]!==n||t[87]!==s?(le=_t(n,s),t[86]=n,t[87]=s,t[88]=le):le=t[88];let X;t[89]===le?X=t[90]:(X=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:le}),t[89]=le,t[90]=X),t[91]!==ce||t[92]!==X?(O=(0,$.jsxs)(`div`,{children:[ce,X]}),t[91]=ce,t[92]=X,t[93]=O):O=t[93],k=N.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:N.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:gt(e,s)},e))}):null,t[3]=n,t[4]=l,t[5]=r,t[6]=i,t[7]=s,t[8]=u,t[9]=f,t[10]=m,t[11]=h,t[12]=g,t[13]=_,t[14]=T,t[15]=E,t[16]=D,t[17]=O,t[18]=k,t[19]=A,t[20]=j,t[21]=M,t[22]=P,t[23]=F}else u=t[8],f=t[9],m=t[10],h=t[11],g=t[12],_=t[13],T=t[14],E=t[15],D=t[16],O=t[17],k=t[18],A=t[19],j=t[20],M=t[21],P=t[22],F=t[23];let I;t[94]!==D||t[95]!==O||t[96]!==k?(I=(0,$.jsxs)(`div`,{className:D,children:[O,k]}),t[94]=D,t[95]=O,t[96]=k,t[97]=I):I=t[97];let L;t[98]!==I||t[99]!==A||t[100]!==j?(L=(0,$.jsxs)(`details`,{className:A,children:[j,I]}),t[98]=I,t[99]=A,t[100]=j,t[101]=L):L=t[101];let R;t[102]!==L||t[103]!==M||t[104]!==P||t[105]!==F?(R=(0,$.jsxs)(`div`,{className:M,children:[P,F,L]}),t[102]=L,t[103]=M,t[104]=P,t[105]=F,t[106]=R):R=t[106];let z;t[107]===s.modalClose?z=t[108]:(z=(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(J,{variant:`secondary`,children:s.modalClose})}),t[107]=s.modalClose,t[108]=z);let B;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==s.connect?(B=r?null:(0,$.jsxs)(J,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(N,{className:`size-4`}),s.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=s.connect,t[114]=B):B=t[114];let V;t[115]!==z||t[116]!==B?(V=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[z,B]}),t[115]=z,t[116]=B,t[117]=V):V=t[117];let H;t[118]!==u||t[119]!==h||t[120]!==g||t[121]!==R||t[122]!==V?(H=(0,$.jsxs)(u,{className:h,children:[g,R,V]}),t[118]=u,t[119]=h,t[120]=g,t[121]=R,t[122]=V,t[123]=H):H=t[123];let U;t[124]!==f||t[125]!==_||t[126]!==H?(U=(0,$.jsxs)(f,{children:[_,H]}),t[124]=f,t[125]=_,t[126]=H,t[127]=U):U=t[127];let W;return t[128]!==m||t[129]!==T||t[130]!==E||t[131]!==U?(W=(0,$.jsx)(m,{open:T,onOpenChange:E,children:U}),t[128]=m,t[129]=T,t[130]=E,t[131]=U,t[132]=W):W=t[132],W}function bt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function xt(e){return e.required}function St(e){return e.required}var Ct=(0,Q.memo)(function(e){let t=(0,rt.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:c,browseLabel:l,customLabel:d,serviceLabel:f,moreActionsLabel:m}=e,[h,g]=(0,Q.useState)(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=p(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,ee.transition),t[0]=_):_=t[0];let v=_,y;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(u,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=y):y=t[1];let b;t[2]===c?b=t[3]:(b=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:c}),t[2]=c,t[3]=b);let x;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(ke,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=x):x=t[4];let S;t[5]!==c||t[6]!==b?(S=(0,$.jsx)(me,{asChild:!0,children:(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":c,children:[y,b,x]})}),t[5]=c,t[6]=b,t[7]=S):S=t[7];let C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(B,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=C):C=t[8];let w;t[9]!==l||t[10]!==a?(w=(0,$.jsxs)(Ue,{className:v,onSelect:a,children:[C,l]}),t[9]=l,t[10]=a,t[11]=w):w=t[11];let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Xe,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=T):T=t[12];let E;t[13]!==d||t[14]!==o?(E=(0,$.jsxs)(Ue,{className:v,onSelect:o,children:[T,d]}),t[13]=d,t[14]=o,t[15]=E):E=t[15];let D;t[16]!==w||t[17]!==E?(D=(0,$.jsx)(Me,{children:(0,$.jsxs)(ve,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[w,E]})}),t[16]=w,t[17]=E,t[18]=D):D=t[18];let O;t[19]!==D||t[20]!==S?(O=(0,$.jsxs)(Re,{children:[S,D]}),t[19]=D,t[20]=S,t[21]=O):O=t[21];let k;t[22]===h?k=t[23]:(k=(0,$.jsx)(et,{open:h,onOpenChange:g,hideTrigger:!0}),t[22]=h,t[23]=k);let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[24]=A):A=t[24];let j;t[25]===m?j=t[26]:(j=(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":m,title:m,children:A})}),t[25]=m,t[26]=j);let M;t[27]!==n||t[28]!==i||t[29]!==r?(M=n?(0,$.jsxs)(Ue,{className:v,disabled:r,onSelect:n,children:[r?(0,$.jsx)(ae,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(He,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=M):M=t[30];let N,P;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>g(!0),P=(0,$.jsx)(te,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=N,t[32]=P):(N=t[31],P=t[32]);let F;t[33]===f?F=t[34]:(F=(0,$.jsxs)(Ue,{className:v,onSelect:N,children:[P,f]}),t[33]=f,t[34]=F);let I;t[35]!==M||t[36]!==F?(I=(0,$.jsx)(Me,{children:(0,$.jsxs)(ve,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[M,F]})}),t[35]=M,t[36]=F,t[37]=I):I=t[37];let L;t[38]!==j||t[39]!==I?(L=(0,$.jsxs)(Re,{children:[j,I]}),t[38]=j,t[39]=I,t[40]=L):L=t[40];let R;return t[41]!==O||t[42]!==k||t[43]!==L?(R=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[O,k,L]}),t[41]=O,t[42]=k,t[43]=L,t[44]=R):R=t[44],R});function wt(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var Tt=/^([^:=]+)[:=](.*)$/;function Et(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Ot(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Tt.exec(t);r&&n.push(wt(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function Dt(e){let t=Object.create(null);for(let n of e){let e=n.key.trim();e&&(t[e]=n.reference??n.value)}return Object.keys(t).length>0?t:void 0}function Ot(e){if(!e||typeof e!=`object`)return[wt()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...wt(e),reference:t}:wt(e,t==null?``:String(t)));return t.length>0?t:[wt()]}function kt(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 At(e){let t=e.trim();if(!t)return;if(t.startsWith(`[`)){let e=JSON.parse(t);if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`Command arguments must be a JSON array of strings.`);return e}let n=[],r=``,i=``,a=!1;for(let e=0;e<t.length;e++){let o=t[e];o===`\\`&&t[e+1]&&i!==`'`&&/[\s"'\\]/.test(t[e+1])?(r+=t[++e],a=!0):i?o===i?i=``:r+=o:o===`"`||o===`'`?(i=o,a=!0):/\s/.test(o)?a&&=(n.push(r),r=``,!1):(r+=o,a=!0)}if(i)throw Error(`Command arguments contain an unclosed quote.`);return a&&n.push(r),n}function jt(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 Mt(e){let t={...e.extra,exposure:e.exposure};if(e.displayName?.trim()?t.displayName=e.displayName.trim():delete t.displayName,delete t.command,delete t.args,delete t.env,delete t.cwd,delete t.url,delete t.headers,delete t.type,e.transport===`stdio`){t.type=`stdio`,t.command=e.command.trim();let n=At(e.argsText);if(n&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envEntries){let n=new Set;for(let t of e.envEntries)if(!(!t.key.trim()&&!t.value&&!t.reference)){if(!t.key.trim()||n.has(t.key.trim()))throw Error(`Environment variable names must be non-empty and unique.`);n.add(t.key.trim())}let r=Dt(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=jt(e.envJson));delete t.oauth,delete t.auth}else{t.type=`http`,t.url=e.url.trim();let n=Dt(e.headers);n&&(t.headers=n);let r={...t.oauth??{}};e.oauthClientId.trim()?r.clientId=e.oauthClientId.trim():delete r.clientId,Object.keys(r).length?t.oauth=r:delete t.oauth}return e.timeout===void 0?delete t.timeout:t.timeout=e.timeout,t}function Nt(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?`streamable-http`:`stdio`,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?JSON.stringify(t.args):``,envJson:t.env?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:``,url:typeof t.url==`string`?t.url:``,headers:Ot(t.headers),oauthClientId:typeof n?.clientId==`string`?n.clientId:``,timeout:typeof t.timeout==`number`?t.timeout:void 0,exposure:t.exposure??`codemode`,extra:t}}function Pt(e,t){let n=`mcp`;try{n=e.transport===`streamable-http`?new URL(e.url).hostname:e.command.split(/[\\/]/).pop()||n}catch{}let r=n.replace(/[^a-zA-Z0-9_-]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`,i=new Set([...t].map(e=>e.replace(/-/g,`_`))),a=r;for(let e=2;i.has(a.replace(/-/g,`_`));e++)a=`${r}_${e}`;return a}function Ft(e){let t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:/i.test(t)&&!/^[^/]+:\d+(?:[/?#]|$)/.test(t)?t:`${/^(localhost|127\.0\.0\.1)(:|\/|$)/i.test(t)?`http`:`https`}://${t}`);if(![`http:`,`https:`].includes(n.protocol)||n.username||n.password)throw Error(`Use an HTTP or HTTPS MCP address without embedded credentials.`);return n.href}function It(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Expected a JSON object.`);let n=t.mcpServers??t.mcp?.servers??t.servers;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Expected a server configuration object.`);let r=n?Object.entries(n):[[``,t]];if(!r.length)throw Error(`No MCP servers found.`);return r.map(([e,t])=>{if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid MCP server configuration.`);let n=t;if(typeof n.url!=`string`&&typeof n.command!=`string`)throw Error(`The configuration needs an MCP URL or command.`);if(n.args!==void 0&&(!Array.isArray(n.args)||n.args.some(e=>typeof e!=`string`)))throw Error(`Command arguments must be strings.`);let r=Nt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Ft(r.url),r})}function Lt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Rt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!kt(e)).map(([e,t])=>Nt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function zt(e){return Mt(e)}async function Bt(e,t){return(await m(_(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Vt(e,t,n,r){return(await m(_(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:Mt(e)})})).payload}async function Ht(e,t){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Ut(e){await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Wt(e,t=!1){let n=await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return E(),n.payload}async function Gt(e){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function Kt(e,t){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function qt(e){await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function Jt(e,t){await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function Yt(e,t){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function Xt(e){let t=await m(_(`/api/mcp/servers`),{signal:e});return Object.fromEntries(t.payload.servers.filter(e=>e.lastCheck&&Number.isFinite(Date.parse(e.lastCheck.checkedAt))).map(e=>[e.id,e.lastCheck]))}async function Zt(e){let t=await m(_(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return E(),t.payload}function Qt(e){let t=(0,rt.c)(111),{serverId:n,displayName:r,returnFocusTo:i,draftId:a,t:o,onClose:s,onConfigure:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(!1),O;t[1]!==a||t[2]!==n||t[3]!==o.setupAccessDenied||t[4]!==o.setupConflict||t[5]!==o.setupGatewayUnauthorized||t[6]!==o.setupRateLimited||t[7]!==o.toolsLoadFailed?(O=()=>{let e=new AbortController,t=!0;return p(!0),h(``),d([]),(a?Yt(a,e.signal):Bt(n,e.signal)).then(e=>{t&&d(e)}).catch(e=>{let n=e?.status;t&&h(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&p(!1)}),()=>{t=!1,e.abort()}},t[1]=a,t[2]=n,t[3]=o.setupAccessDenied,t[4]=o.setupConflict,t[5]=o.setupGatewayUnauthorized,t[6]=o.setupRateLimited,t[7]=o.toolsLoadFailed,t[8]=O):O=t[8];let k;t[9]!==a||t[10]!==T||t[11]!==n||t[12]!==o?(k=[n,a,T,o],t[9]=a,t[10]=T,t[11]=n,t[12]=o,t[13]=k):k=t[13],(0,Q.useEffect)(O,k);let A,j,M,N,P,F,I,ee,L,R,z,B,V;if(t[14]!==r||t[15]!==m||t[16]!==f||t[17]!==s||t[18]!==c||t[19]!==g||t[20]!==i||t[21]!==n||t[22]!==o.exposureLabels||t[23]!==o.setupConfigure||t[24]!==o.toolDetails||t[25]!==o.toolsClearSearch||t[26]!==o.toolsDialogSearchEmpty||t[27]!==o.toolsDialogSearchPlaceholder||t[28]!==o.toolsDialogSubtitle||t[29]!==o.toolsDialogTitle||t[30]!==o.toolsEmpty||t[31]!==o.toolsLoading||t[32]!==o.toolsRetryHint||t[33]!==o.toolsSearchSummary||t[34]!==o.toolsTitle||t[35]!==u){let e=g.trim().toLowerCase(),a;if(t[49]!==n){let e;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[51]=e):e=t[51],a=n.replace(e,`_`),t[49]=n,t[50]=a}else a=t[50];let l=`mcp__${a}__`,d=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));M=w,F=!0,t[52]===s?I=t[53]:(I=e=>{e||s()},t[52]=s,t[53]=I),j=x,t[54]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(v,{className:`fixed inset-0 z-[60] bg-scrim`}),t[54]=P):P=t[54],A=S,t[55]===i?B=t[56]:(B=e=>{(D.current||i)&&e.preventDefault(),!D.current&&i?.isConnected&&i.focus()},t[55]=i,t[56]=B),V=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`;let p;t[57]===o.toolsDialogTitle?p=t[58]:(p=(0,$.jsx)(C,{className:`font-semibold`,children:o.toolsDialogTitle}),t[57]=o.toolsDialogTitle,t[58]=p);let h;t[59]!==r||t[60]!==m||t[61]!==f||t[62]!==n||t[63]!==o.toolsDialogSubtitle||t[64]!==u.length?(h=f||m?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[59]=r,t[60]=m,t[61]=f,t[62]=n,t[63]=o.toolsDialogSubtitle,t[64]=u.length,t[65]=h):h=t[65];let b;t[66]===h?b=t[67]:(b=(0,$.jsx)(y,{className:`mt-1 break-words text-sm text-fg-muted`,children:h}),t[66]=h,t[67]=b);let T;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>_(e.target.value),t[68]=T):T=t[68];let E;t[69]!==g||t[70]!==o.toolsDialogSearchPlaceholder?(E=(0,$.jsx)(`input`,{className:`mt-4 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:g,onChange:T,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[69]=g,t[70]=o.toolsDialogSearchPlaceholder,t[71]=E):E=t[71];let O=e&&!f&&!m?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(d.length)).replace(`{{count}}`,String(u.length))}):null;t[72]!==p||t[73]!==b||t[74]!==E||t[75]!==O?(N=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[p,b,E,O]}),t[72]=p,t[73]=b,t[74]=E,t[75]=O,t[76]=N):N=t[76],ee=`min-h-0 flex-1 overflow-y-auto p-5`,L=f,t[77]!==o.toolsTitle||t[78]!==u.length?(R=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[77]=o.toolsTitle,t[78]=u.length,t[79]=R):R=t[79],z=f?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(en)}):m?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:m}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(J,{variant:`secondary`,onClick:()=>{D.current=!0,c()},children:o.setupConfigure}):null]}):d.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:d.map(e=>(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`h3`,{className:`break-all font-mono text-sm font-semibold text-fg`,children:e.name.startsWith(l)?e.name.slice(l.length):e.name}),e.exposure&&Object.hasOwn(o.exposureLabels,e.exposure)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.exposureLabels[e.exposure]}):null,e.description?(0,$.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:e.description}):null,(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:o.toolDetails}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:e.name}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel p-3 text-xs text-fg`,children:JSON.stringify(e.inputSchema,null,2)})]})]},e.name))}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.length?o.toolsDialogSearchEmpty:o.toolsEmpty}),e?(0,$.jsx)(J,{variant:`secondary`,onClick:()=>_(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=m,t[16]=f,t[17]=s,t[18]=c,t[19]=g,t[20]=i,t[21]=n,t[22]=o.exposureLabels,t[23]=o.setupConfigure,t[24]=o.toolDetails,t[25]=o.toolsClearSearch,t[26]=o.toolsDialogSearchEmpty,t[27]=o.toolsDialogSearchPlaceholder,t[28]=o.toolsDialogSubtitle,t[29]=o.toolsDialogTitle,t[30]=o.toolsEmpty,t[31]=o.toolsLoading,t[32]=o.toolsRetryHint,t[33]=o.toolsSearchSummary,t[34]=o.toolsTitle,t[35]=u,t[36]=A,t[37]=j,t[38]=M,t[39]=N,t[40]=P,t[41]=F,t[42]=I,t[43]=ee,t[44]=L,t[45]=R,t[46]=z,t[47]=B,t[48]=V}else A=t[36],j=t[37],M=t[38],N=t[39],P=t[40],F=t[41],I=t[42],ee=t[43],L=t[44],R=t[45],z=t[46],B=t[47],V=t[48];let H;t[80]!==ee||t[81]!==L||t[82]!==R||t[83]!==z?(H=(0,$.jsx)(`div`,{className:ee,"aria-busy":L,"aria-label":R,children:z}),t[80]=ee,t[81]=L,t[82]=R,t[83]=z,t[84]=H):H=t[84];let U;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>E($t),t[85]=U):U=t[85];let W;t[86]!==f||t[87]!==o.refreshTools?(W=(0,$.jsx)(J,{variant:`secondary`,disabled:f,onClick:U,children:o.refreshTools}),t[86]=f,t[87]=o.refreshTools,t[88]=W):W=t[88];let G;t[89]!==s||t[90]!==o.toolsDialogClose?(G=(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(J,{onClick:s,children:o.toolsDialogClose})}),t[89]=s,t[90]=o.toolsDialogClose,t[91]=G):G=t[91];let te;t[92]!==W||t[93]!==G?(te=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[W,G]}),t[92]=W,t[93]=G,t[94]=te):te=t[94];let K;t[95]!==A||t[96]!==N||t[97]!==H||t[98]!==te||t[99]!==B||t[100]!==V?(K=(0,$.jsxs)(A,{onCloseAutoFocus:B,className:V,children:[N,H,te]}),t[95]=A,t[96]=N,t[97]=H,t[98]=te,t[99]=B,t[100]=V,t[101]=K):K=t[101];let ne;t[102]!==j||t[103]!==P||t[104]!==K?(ne=(0,$.jsxs)(j,{children:[P,K]}),t[102]=j,t[103]=P,t[104]=K,t[105]=ne):ne=t[105];let q;return t[106]!==M||t[107]!==F||t[108]!==I||t[109]!==ne?(q=(0,$.jsx)(M,{open:F,onOpenChange:I,children:ne}),t[106]=M,t[107]=F,t[108]=I,t[109]=ne,t[110]=q):q=t[110],q}function $t(e){return e+1}function en(e){return(0,$.jsx)(K,{className:`h-24 w-full`},e)}function tn(e){if(e.transport===`stdio`)return e.command.trim();try{let t=new URL(e.url);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.url.trim().split(/[?#]/,1)[0].replace(/\/\/[^/]*@/,`//`)}}function nn({row:e,lastCheck:t,t:n,cs:r,onEdit:i,onRemove:a}){let[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``);return(0,$.jsxs)(`div`,{className:`px-4 py-3.5`,children:[(0,$.jsxs)(`button`,{className:`block w-full text-left`,onClick:i,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.displayName||e.id}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:tn(e)})]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:e.extra.enabled===!1?n.setupDisabled:t?n.setupLastCheck.replace(`{{count}}`,String(t.toolCount)):n.setupUnverified}),t?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`time`,{dateTime:t.checkedAt,children:new Intl.DateTimeFormat(void 0,{dateStyle:`short`,timeStyle:`short`}).format(new Date(t.checkedAt))})}):null,d?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:d}):null,(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(J,{ref:c,variant:`secondary`,disabled:e.extra.enabled===!1,onClick:()=>s(!0),children:n.viewTools}),(0,$.jsx)(J,{variant:`ghost`,onClick:()=>u(!0),children:n.removeServer})]}),o?(0,$.jsx)(Qt,{serverId:e.id,displayName:e.displayName,returnFocusTo:c.current,t:n,onClose:()=>s(!1),onConfigure:()=>{s(!1),i()}}):null,(0,$.jsx)(ue,{open:l,title:r.removeConfirmTitle.replace(`{{name}}`,e.displayName||e.id),description:r.removeConfirmDescription,confirmLabel:n.removeServer,cancelLabel:r.modalCancel,destructive:!0,onCancel:()=>u(!1),onConfirm:()=>{u(!1),f(``),a().catch(()=>f(n.setupRemoveFailed))}})]})}function rn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function an(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?rn(t)-rn(e):e.isCurrentAuthorization?-1:1}function on(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(an);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>an(e.primary,t.primary))}var sn=p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q);function cn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function ln(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function un(e,t,n){return e.status===`connected`?G(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 dn(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 fn(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 pn({instance:e,t,onChanged:n}){let r=cn(e),i=g(e=>e.language)===`zh`,[a,s]=(0,Q.useState)([]),[c,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)([]),[f,m]=(0,Q.useState)(null),[h,_]=(0,Q.useState)([]),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)([]),[w,T]=(0,Q.useState)({}),[E,D]=(0,Q.useState)(`read`),[O,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(!1),[ee,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(null),[B,U]=(0,Q.useState)(!1),[te,ne]=(0,Q.useState)(!1),[q,Y]=(0,Q.useState)(!1),se=(0,Q.useRef)(0),ce=(0,Q.useRef)(0),le=(0,Q.useMemo)(()=>on(a),[a]),X=(0,Q.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),de=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;j(!0),N(null);let t=++se.current;try{let e=(await Promise.allSettled([X(Se()).then(e=>{t===se.current&&(s(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),U(!0))}),X(ge(r)).then(e=>{t===se.current&&D(e)}),X(We(r)).then(e=>{t===se.current&&(m(e.policy),_(e.agents))})])).find(e=>e.status===`rejected`);t===se.current&&e?.status===`rejected`&&N(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===se.current&&j(!1)}},[e.materialized,r,X]);(0,Q.useEffect)(()=>(de(),()=>{se.current++}),[de]);let pe=(0,Q.useCallback)(async()=>{if(!r)return;let e=++ce.current;Y(!0),I(!1);let t=t=>n=>{e===ce.current&&t(n)},n=await Promise.allSettled([X(xe(r)).then(t(l)),X(fe(20)).then(t(e=>d(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),X(Ie(r)).then(t(x)),X(Oe(r)).then(t(y))]);e===ce.current&&(I(n.some(e=>e.status===`rejected`)),Y(!1))},[r,X]);(0,Q.useEffect)(()=>(te&&pe(),()=>{ce.current++}),[te,pe]),(0,Q.useEffect)(()=>{let e=!1,t=on(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return X(Ke()).then(t=>{e||C(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await X(Ae(e.accountId))])).then(t=>{e||T(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,X]);let me=(0,Q.useCallback)(async i=>{if(!r)return;let a=Fe()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),j(!0),N(null);try{if(!Fe()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await P(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(Fe()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else a.location.href=t.authorizationUrl;let o=await W(r,t.connectionId,12e4,t.attemptId);if(i&&o.accountId!==i)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),de()])}catch(e){N(oe(e,t))}finally{a?.close(),j(!1)}},[e.connectorId,de,n,t,r]),ve=(0,Q.useCallback)(async t=>{j(!0),N(null);try{await V(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),de()])}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[e.config,e.instanceId,de,n]),ye=async e=>{let t=Fe()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),N(null);try{let n=await he(e.id);if(n.authorizationUrl)if(Fe())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 de()}catch(e){t?.close(),N(e instanceof Error?e.message:String(e))}},be=(0,Q.useCallback)(async e=>{if(r){D(e),N(null);try{await qe(r,e)}catch(e){N(e instanceof Error?e.message:String(e)),await de()}}},[de,r]),Ce=(0,Q.useCallback)(async e=>{if(r){N(null);try{m(await Ee(r,e))}catch(e){N(e instanceof Error?e.message:String(e))}}},[r]),we=(0,Q.useCallback)(e=>{if(!f)return;let t=f.allowedAgentIds.includes(e);t&&f.allowedAgentIds.length===1||Ce({allowedAgentIds:t?f.allowedAgentIds.filter(t=>t!==e):[...f.allowedAgentIds,e]})},[Ce,f]),Te=(0,Q.useCallback)(async e=>{j(!0),N(null);try{await e(),await de()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[de]);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 ke=le.filter(e=>e.primary.status===`active`).length,Me=ke>0?t.composioAddAccount:t.composioConnectAccount,Ne=B&&ke>0,Le=b?.requiresCustomAuthConfig===!0,Re=b?.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`,Ne?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Ne?(0,$.jsx)(o,{className:`size-3.5`}):(0,$.jsx)(Pe,{className:`size-3.5`}),Ne?t.connectionReady:B||M?t.connectionNeedsSetup:t.connectionChecking]}),B&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:G(t.composioAccountCount,{count:String(le.length)})})]}),(0,$.jsxs)(J,{variant:`primary`,className:`shrink-0`,disabled:O,onClick:()=>void me(),children:[O?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):(0,$.jsx)(Be,{className:`size-4`}),Me]})]}),M?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:M}),(0,$.jsx)(J,{variant:`secondary`,disabled:O,onClick:()=>void de(),children:t.composioRetry})]}):null,v&&!Ne?(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:un(v,ke,t)}),v.recovery===`none`?null:(0,$.jsx)(J,{variant:`secondary`,disabled:O,onClick:()=>void(v.recovery===`retry`?de():me()),children:v.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,Le&&Re.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,f?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:E===`read`?t.composioAccessReadHint:E===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(_e,{value:E,onChange:e=>void be(e.currentTarget.value),children:[(0,$.jsx)(Z,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(Z,{value:`write`,children:t.composioAccessReadWrite}),E===`admin`?(0,$.jsx)(Z,{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)(_e,{value:f.confirmationPolicy,onChange:e=>void Ce({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(Z,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(Z,{value:`always`,children:t.composioConfirmAlways}),f.confirmationPolicy===`never`?(0,$.jsx)(Z,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:f.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void Ce({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),h.map(e=>(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>we(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:f.selectedAccountIds===null,disabled:O,onChange:e=>void Ce({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),f.selectedAccountIds!==null&&le.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:O,checked:f.selectedAccountIds.includes(e.accountId),onChange:t=>void Ce({selectedAccountIds:t.currentTarget.checked?[...f.selectedAccountIds,e.accountId]:f.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),f.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),B&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:G(t.composioAccountCount,{count:String(le.length)})})]}),(0,$.jsxs)(J,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:O,onClick:()=>void de(),children:[(0,$.jsx)(He,{className:p(`size-3.5`,O&&`animate-spin`)}),t.refresh]})]}),le.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:le.map(e=>{let r=e.primary,a=S.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?w[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`:dn(r.status,t)}),a?(0,$.jsx)(`p`,{className:p(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:G(t.connectorLearningStatus,{status:fn(a,o,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(J,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void ye(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(J,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:O,onClick:()=>z(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(J,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:O,onClick:()=>void me(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(J,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:O,onClick:()=>void Te(()=>De(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(J,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:O,onClick:()=>void Te(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await ie(r.accountId),await n?.()}),children:[(0,$.jsx)(He,{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:O,checked:r.allowedAgentIds==null,onChange:e=>void Te(()=>De(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&h.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:O,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;Te(()=>De(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&o?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:O,onChange:e=>void Te(()=>H(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(_e,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:O,onChange:e=>void Te(()=>H(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(Z,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(Z,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(Z,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(Z,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:p(sn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&Te(()=>k(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)(J,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:O,onClick:()=>L(e.id),children:(0,$.jsx)(A,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(J,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:O,onClick:()=>void Te(()=>Ye(r.id)),children:(0,$.jsx)(He,{className:`size-4`})})})]})]})]},e.key)})}):O&&!B?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(K,{className:`h-16 w-full`}),(0,$.jsx)(K,{className:`h-16 w-full`})]}):B?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>ne(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:[q?(0,$.jsx)(K,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,F?(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)(J,{variant:`ghost`,disabled:q,onClick:()=>void pe(),children:t.composioRetry})]}):null,b?.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:Le?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)(_e,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:O,onChange:e=>void ve(e.currentTarget.value),children:[Le?null:(0,$.jsx)(Z,{value:``,children:t.composioAuthConfigManaged}),Le&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(Z,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,Re.map(e=>(0,$.jsxs)(Z,{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:c.length?c.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:[ln(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:u.length?u.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(ue,{open:R!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=R;z(null),e&&Te(()=>je(e))},onCancel:()=>z(null)}),(0,$.jsx)(ue,{open:ee!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=ee;L(null),e&&Te(()=>re(e))},onCancel:()=>L(null)})]})}var mn=p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q);function hn(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 gn(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 _n({instance:e,definition:t,onClose:n,onChanged:r,t:i}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,T]=(0,Q.useState)(()=>hn(t,e)),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),[j,N]=(0,Q.useState)(null),P=t?.setup.config??[],F=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&P.length>0&&(t?.setup.secrets??[]).length===0,I=e.materialized.type===`mcp`,L=e.materialized.type===`composio`,R=e.materialized.type===`memorySource`,z=t?X(t,i):null,B=(0,Q.useCallback)(async()=>{k(!0),D(null);try{let t=await U(e.instanceId);N(t),t.ok||D(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(!1)}},[e.instanceId,r,i.healthStatusLabels]),H=(0,Q.useCallback)(async()=>{o(!0),D(null);try{await Je(e.instanceId),await r(),n()}catch(e){D(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),W=(0,Q.useCallback)(async()=>{if(!(!t||!F)){u(!0),D(null);try{let n={};for(let e of t.setup.config??[]){let t=gn(e.type,_[e.key]??``);t!==void 0&&(n[e.key]=t)}await V(e.instanceId,{config:n}),await r()}catch(e){D(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[_,t,e.instanceId,r,F]),te=(0,Q.useCallback)(async()=>{m(!0),g(null),D(null);try{g((await M(e.connectorId)).recordIds.length),await r()}catch(e){D(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.connectorId,r]);return(0,$.jsxs)(w,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(x,{children:[(0,$.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(S,{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`,L?`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)(ye,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(C,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(y,{className:`mt-1 text-sm text-fg-muted`,children:z??(e.materialized.type===`mcp`?G(i.mcpServerRuntime,{serverId:e.materialized.serverId}):G(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(b,{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`,ee.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(d,{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:[E?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:E}):null,I?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,role:`status`,children:j?.ok?G(i.toolsAvailable,{count:String(j.toolCount)}):j?i.healthStatusLabels[j.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(J,{variant:`secondary`,"aria-busy":O,disabled:O||!e.enabled,onClick:()=>void B(),children:[O?(0,$.jsx)(ae,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(He,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),F?P.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:mn,value:_[e.key]??``,placeholder:e.placeholder,onChange:t=>T(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,L?(0,$.jsx)(pn,{instance:e,t:i,onChanged:r}):null,R?(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}),z?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:z}):null,h===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:G(i.connectedSourceSynced,{count:String(h)})})]}),(0,$.jsxs)(J,{disabled:f,onClick:()=>void te(),children:[f?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):(0,$.jsx)(ne,{className:`size-4`}),i.composioSyncNow]})]}),F?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:P.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:mn,value:_[e.key]??``,placeholder:e.placeholder,onChange:t=>T(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!I&&!L&&!R?(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)(J,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):(0,$.jsx)(A,{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)(J,{variant:`secondary`,onClick:n,children:i.modalClose}),(I||R)&&F?(0,$.jsxs)(J,{variant:`primary`,disabled:l,onClick:()=>void W(),children:[l?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):(0,$.jsx)(Te,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(ue,{open:s,title:G(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),H()},onCancel:()=>{a||c(!1)}})]})}function vn(e){let t=(0,rt.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(O,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(_n,{...e}),t[0]=e,t[1]=n),n}function yn(e){let t=(0,rt.c)(55),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:s}=e,c=i===void 0?!1:i,l;t[0]!==r||t[1]!==n?(l=ht(n,r),t[0]=r,t[1]=n,t[2]=l):l=t[2];let u=l.state,d;t[3]!==r||t[4]!==s?(d=r?X(r,s):null,t[3]=r,t[4]=s,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]!==c||t[9]!==n||t[10]!==a||t[11]!==s.connectionChecking||t[12]!==s.connectionNeedsSetup||t[13]!==s.connectionReady){m=u===`ready`?{label:s.connectionReady,Icon:o,className:`text-emerald-700 dark:text-emerald-300`}:u===`needs_setup`?{label:s.connectionNeedsSetup,Icon:Pe,className:`text-amber-700 dark:text-amber-300`}:{label:s.connectionChecking,Icon:R,className:`text-fg-muted`},x=`button`;let e=c&&`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)]`,ee.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)(ye,{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]=c,t[9]=n,t[10]=a,t[11]=s.connectionChecking,t[12]=s.connectionNeedsSetup,t[13]=s.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)(Ve,{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 bn(e,t){return Lt()}function xn(e){let t=e.headers.filter(e=>e.key.trim()),n=t.find(e=>e.key.toLowerCase()===`authorization`&&!e.reference&&/^Bearer\s/i.test(e.value)),r=e.extra.auth||t.some(e=>e.reference)||e.extra.oauth&&t.some(e=>e.key.toLowerCase()===`authorization`)?`existing`:e.extra.oauth?`oauth`:n?`bearer`:t.length?`headers`:`auto`;return{mode:r,token:n?.value.replace(/^Bearer\s+/i,``)??``,apiKey:``,headerName:``,customHeaders:t.length?t:[wt()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function Sn(e,t){if(e.transport===`stdio`||t.mode===`existing`)return{...e,extra:{...e.extra}};let n={...e.extra};delete n.auth,t.mode!==`oauth`&&delete n.oauth;let r=t.mode===`headers`?t.customHeaders:t.additionalHeaders;if(t.mode===`bearer`){let e=t.token.trim().replace(/^Bearer\s+/i,``);r=[...r,wt(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,wt(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Cn(e){let t=new Set;return e.findIndex(e=>{let n=e.key.trim();if(!n&&!e.value&&!e.reference)return!1;if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(n)||/[\r\n]/.test(e.value))return!0;let r=n.toLowerCase();return t.has(r)?!0:(t.add(r),!1)})}function wn(){return p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q)}function Tn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:u,headers:d,onChange:f,referenceLabel:m=`Existing credential reference`,showValueLabel:h=`Show value`,hideValueLabel:g=`Hide value`,allowPaste:_=!0}){let[v,y]=(0,Q.useState)(new Set),[b,x]=(0,Q.useState)(!1),S=(e,t)=>{f(d.map((n,r)=>r===e?{...n,...t}:n))},C=()=>{f([...d,wt()])},w=e=>{let t=d.filter((t,n)=>n!==e);f(t.length>0?t:[wt()])},E=async()=>{try{let e=await T();if(!e){x(!0);return}let t=Et(e);if(!t?.length){x(!0);return}f(t)}catch{x(!0)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),_?(0,$.jsxs)(J,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void E(),children:[(0,$.jsx)(Y,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto]`,children:[(0,$.jsx)(`input`,{className:p(wn(),`col-span-3 min-w-0 font-mono text-xs sm:col-span-1`),"aria-label":`${c} ${t+1}`,value:e.key,placeholder:c,onChange:e=>S(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:p(wn(),`min-w-0 font-mono text-xs`),type:v.has(e.clientKey)?`text`:`password`,autoComplete:`off`,"aria-label":`${u} ${t+1}`,readOnly:!!e.reference,value:e.reference?m:e.value,placeholder:e.reference?m:u,onChange:e=>S(t,{value:e.target.value})}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":v.has(e.clientKey)?g:h,onClick:()=>y(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:v.has(e.clientKey)?(0,$.jsx)(F,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(l,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:d.length<=1&&!e.key&&!e.value,onClick:()=>w(t),"aria-label":r,children:(0,$.jsx)(A,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})}),e.reference?(0,$.jsx)(`p`,{className:`col-span-3 break-words text-xs text-fg-muted sm:col-span-4`,children:m}):null]},e.clientKey))}),(0,$.jsx)(ue,{open:b,title:o,description:a,confirmLabel:s,onConfirm:()=>x(!1),onCancel:()=>x(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:p(`self-start text-sm text-accent hover:underline`,ee.press),onClick:C,children:[`+ `,n]})]})}var En=p(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,q);function Dn(e){let t=(0,rt.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o===void 0?!1:o,[c,u]=(0,Q.useState)(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=p(En,`mt-1.5`),t[0]=d):d=t[0];let f=c?`text`:`password`,m;t[1]===r?m=t[2]:(m=e=>r(e.target.value),t[1]=r,t[2]=m);let h;t[3]!==s||t[4]!==f||t[5]!==m||t[6]!==n?(h=(0,$.jsx)(`input`,{className:d,type:f,value:n,required:s,autoComplete:`off`,onChange:m}),t[3]=s,t[4]=f,t[5]=m,t[6]=n,t[7]=h):h=t[7];let g;t[8]!==i||t[9]!==h?(g=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i,h]}),t[8]=i,t[9]=h,t[10]=g):g=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>u(On),t[11]=_):_=t[11];let v;t[12]===c?v=t[13]:(v=c?(0,$.jsx)(F,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(l,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=v);let y=c?a.setupHideValue:a.setupShowValue,b;t[14]!==v||t[15]!==y?(b=(0,$.jsxs)(J,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:_,children:[v,y]}),t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;return t[17]!==b||t[18]!==g?(x=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[g,b]}),t[17]=b,t[18]=g,t[19]=x):x=t[19],x}function On(e){return!e}function kn(e){let t=(0,rt.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l=c?i.envLabel:s?i.setupAdditionalHeaders:i.headersLabel,u=c?i.setupAddEnv:i.addHeader,d=c?i.setupRemoveEnv:i.removeHeader,f=c?i.setupEnvName:i.headerKeyPlaceholder,p=c?i.setupEnvValue:i.headerValuePlaceholder,m=!c,h;return t[0]!==n||t[1]!==r||t[2]!==i.optionalSuffix||t[3]!==i.pasteHeaders||t[4]!==i.pasteHeadersDismiss||t[5]!==i.pasteHeadersFailed||t[6]!==i.pasteHeadersFailedTitle||t[7]!==i.setupHideValue||t[8]!==i.setupReference||t[9]!==i.setupShowValue||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(h=(0,$.jsx)(Tn,{label:l,optionalLabel:i.optionalSuffix,addLabel:u,removeHeaderAria:d,pasteLabel:i.pasteHeaders,pasteFailed:i.pasteHeadersFailed,pasteFailedTitle:i.pasteHeadersFailedTitle,dismissLabel:i.pasteHeadersDismiss,keyPlaceholder:f,valuePlaceholder:p,headers:n,onChange:r,referenceLabel:i.setupReference,showValueLabel:i.setupShowValue,hideValueLabel:i.setupHideValue,allowPaste:m}),t[0]=n,t[1]=r,t[2]=i.optionalSuffix,t[3]=i.pasteHeaders,t[4]=i.pasteHeadersDismiss,t[5]=i.pasteHeadersFailed,t[6]=i.pasteHeadersFailedTitle,t[7]=i.setupHideValue,t[8]=i.setupReference,t[9]=i.setupShowValue,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function An(e){let t=(0,rt.c)(52),{draft:n,onChange:r,t:i,allowExisting:a}=e,o=i.setupAuthLabel,s=i.setupAuthLabel,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=p(En,`mt-1.5`),t[0]=c):c=t[0];let l=n.mode,u;t[1]===r?u=t[2]:(u=e=>r({mode:e.target.value}),t[1]=r,t[2]=u);let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=[`auto`,`oauth`,`bearer`,`apiKey`,`headers`,`none`],t[3]=d):d=t[3];let f;t[4]===i.setupAuthModes?f=t[5]:(f=d.map(e=>(0,$.jsx)(Z,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=f);let m;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(m=a||n.mode===`existing`?(0,$.jsx)(Z,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=m):m=t[9];let h;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==u||t[13]!==f||t[14]!==m?(h=(0,$.jsxs)(_e,{"aria-label":s,className:c,value:l,onChange:u,children:[f,m]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=u,t[13]=f,t[14]=m,t[15]=h):h=t[15];let g;t[16]!==i.setupAuthLabel||t[17]!==h?(g=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,h]}),t[16]=i.setupAuthLabel,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(_=n.mode===`auto`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthAutoHint}):null,t[19]=n.mode,t[20]=i.setupAuthAutoHint,t[21]=_):_=t[21];let v;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(v=n.mode===`oauth`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthOAuthHint}):null,t[22]=n.mode,t[23]=i.setupAuthOAuthHint,t[24]=v):v=t[24];let y;t[25]!==n.mode||t[26]!==i.setupExistingHint?(y=n.mode===`existing`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupExistingHint}):null,t[25]=n.mode,t[26]=i.setupExistingHint,t[27]=y):y=t[27];let b;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(b=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dn,{value:n.token,onChange:e=>r({token:e}),label:i.setupTokenLabel,t:i,required:!0}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupTokenHint})]}):null,t[28]=n.mode,t[29]=n.token,t[30]=r,t[31]=i,t[32]=b):b=t[32];let x;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(x=n.mode===`apiKey`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.setupApiKeyHeader,(0,$.jsx)(`input`,{className:p(En,`mt-1.5`),placeholder:`x-api-key`,value:n.headerName,required:!0,onChange:e=>r({headerName:e.target.value})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupApiKeyHint}),(0,$.jsx)(Dn,{value:n.apiKey,onChange:e=>r({apiKey:e}),label:`API Key`,t:i,required:!0})]}):null,t[33]=n.apiKey,t[34]=n.headerName,t[35]=n.mode,t[36]=r,t[37]=i,t[38]=x):x=t[38];let S;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(S=n.mode===`headers`?(0,$.jsx)(kn,{headers:n.customHeaders,onChange:e=>r({customHeaders:e}),t:i}):null,t[39]=n.customHeaders,t[40]=n.mode,t[41]=r,t[42]=i,t[43]=S):S=t[43];let C;return t[44]!==g||t[45]!==_||t[46]!==v||t[47]!==y||t[48]!==b||t[49]!==x||t[50]!==S?(C=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[g,_,v,y,b,x,S]}),t[44]=g,t[45]=_,t[46]=v,t[47]=y,t[48]=b,t[49]=x,t[50]=S,t[51]=C):C=t[51],C}function jn(e){let t=(0,rt.c)(8),{label:n,children:r,hint:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{children:n}),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=i?(0,$.jsx)(`span`,{className:`block text-xs font-normal text-fg-muted`,children:i}):null,t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-fg`,children:[a,r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Mn({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>Ot(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=At(e.argsText)??[]}catch{}let c=e=>n({argsText:JSON.stringify(e)});return(0,$.jsxs)(`div`,{"data-field":`commandOptions`,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.argsLabel}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(jn,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:En,value:e.argsText,onChange:e=>n({argsText:e.target.value})})}):s.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{className:En,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(J,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(u,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(kn,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(Dt(e)??{})})}})]})}function Nn(e){let t=(0,rt.c)(15),{row:n,t:r,onUpdate:i,variant:a,showOAuth:o,idReadOnly:s}=e,c=a===void 0?`all`:a,l=o===void 0?!1:o,u=s===void 0?!1:s,d=c!==`advanced`,f=c!==`basic`,p;t[0]!==d||t[1]!==i||t[2]!==n||t[3]!==r?(p=d?(0,$.jsxs)($.Fragment,{children:[n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jn,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:En,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(Mn,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(jn,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:En,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(jn,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:En,value:n.displayName??``,placeholder:r.setupNamePlaceholder,onChange:e=>i({displayName:e.target.value})})})]}):null,t[0]=d,t[1]=i,t[2]=n,t[3]=r,t[4]=p):p=t[4];let m;t[5]!==f||t[6]!==u||t[7]!==i||t[8]!==n||t[9]!==l||t[10]!==r?(m=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jn,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:En,readOnly:u,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(jn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:En,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&l?(0,$.jsx)(jn,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:En,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(jn,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(_e,{"aria-label":r.exposureLabel,className:En,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(Z,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(jn,{label:r.requestTimeoutLabel,children:(0,$.jsx)(nt,{allowEmpty:!0,type:`number`,min:1,className:En,value:n.timeout??``,placeholder:r.setupDefaultTimeout,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})})]}):null,t[5]=f,t[6]=u,t[7]=i,t[8]=n,t[9]=l,t[10]=r,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==m?(h=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p,m]}),t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function Pn(e,t){let n=e;if(n?.status===429)return t.setupRateLimited;if(n?.status===401)return t.setupGatewayUnauthorized;if(n?.status===404||n?.status===409)return t.setupConflict;if(n?.status&&n.status>=500)return t.setupGatewayCheckFailed;let r={command_missing:t.setupCommandMissing,connection_refused:t.setupConnectionRefused,host_not_found:t.setupHostNotFound,timeout:t.setupTimedOut,access_denied:t.setupAccessDenied,network:t.setupServiceNetworkFailed,tls:t.setupTlsFailed,invalid_response:t.setupInvalidResponse,not_found:t.setupEndpointNotFound,rate_limited:t.setupServiceRateLimited,configuration:t.setupInvalidConfig};if(n?.errorCode&&Object.hasOwn(r,n.errorCode))return r[n.errorCode];let i=e instanceof Error?e.message:typeof e==`string`?e:n?.error??``;return/ENOENT|command not found|executable.{0,30}not found/i.test(i)?t.setupCommandMissing:/ECONNREFUSED|connection refused/i.test(i)?t.setupConnectionRefused:/ENOTFOUND|EAI_AGAIN|could not resolve/i.test(i)?t.setupHostNotFound:/timeout|timed out/i.test(i)?t.setupTimedOut:/fetch failed|failed to fetch|network error|NetworkError/i.test(i)?n?.error===void 0?t.setupGatewayNetworkFailed:t.setupServiceNetworkFailed:/\b(?:401|403)\b|unauthorized|forbidden|permission denied/i.test(i)?t.setupAccessDenied:t.setupCheckFailed}function Fn(e,t){return JSON.stringify({id:e.id,config:zt(Sn(e,t))})}function In(e,t){try{return Fn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Ln(e){let{t,cs:n}=e,r=(0,Q.useId)(),[i,a]=(0,Q.useState)(e.initialRow),[s,l]=(0,Q.useState)(()=>xn(e.initialRow)),[u,f]=(0,Q.useState)(`idle`),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[b,T]=(0,Q.useState)(),[E,D]=(0,Q.useState)(),[O,k]=(0,Q.useState)(),[A,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(``),[ee,L]=(0,Q.useState)(``),[R,z]=(0,Q.useState)([]),[B,V]=(0,Q.useState)(`0`),[H,U]=(0,Q.useState)(0),[W,G]=(0,Q.useState)(``),[te,K]=(0,Q.useState)(!1),[ne,q]=(0,Q.useState)(!1),re=e.mode===`edit`,[ie,oe]=(0,Q.useState)(``),Y=(0,Q.useRef)(void 0),[se]=(0,Q.useState)(()=>In(e.initialRow,xn(e.initialRow))),ce=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),le=(0,Q.useRef)(void 0),X=(0,Q.useRef)(void 0),de=(0,Q.useRef)(void 0),fe=(0,Q.useRef)(null),pe=(0,Q.useRef)(``),me=(0,Q.useRef)(!0),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),be=(0,Q.useRef)(e.onSaved);be.current=e.onSaved;let xe=O?.state===`starting`||O?.state===`authorizing`,Se=u!==`idle`||xe,Ce=se!==In(i,s),we=i.extra.enabled===!1,Te=!g&&(Ce||!!F.trim());(0,Q.useEffect)(()=>(me.current=!0,()=>{me.current=!1,le.current?.abort(),fe.current?.close(),Y.current&&Ut(Y.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!Te)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[Te]),(0,Q.useEffect)(()=>{if(!b)return;let e=ve.current?.querySelector(`[data-field="${b.field}"]`),t=e?.closest(`details`);t&&(t.open=!0);let n=e?.querySelector(`input,button,textarea`)??e;return n?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-describedby`,r),b.focus!==!1&&(n??ye.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[b,r]),(0,Q.useEffect)(()=>{if(!O||!xe)return;let e=new AbortController;X.current=e;let n;async function r(){try{let n=await Kt(Y.current,e.signal);if(e.signal.aborted||(k(n),n.authorizationUrl&&pe.current!==n.authorizationUrl&&(pe.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&h(t.oauthOpenFailed):fe.current&&!fe.current.closed&&fe.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){de.current=void 0,fe.current?.close(),D({state:`connected`,toolCount:n.toolCount}),h(``);return}if(n.state===`error`||n.state===`cancelled`){de.current=void 0,fe.current?.close(),h(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&M(!0);return}}catch{if(e.signal.aborted)return;Ee(),fe.current?.close(),h(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[O?.id,xe,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function Ee(){le.current?.abort(),X.current?.abort(),Y.current&&Ut(Y.current).catch(()=>{}),Y.current=void 0,oe(``),K(!1),D(void 0),k(void 0),h(``),T(void 0)}function De(e){a(t=>({...t,...e})),Ee()}function Oe(e){l(t=>({...t,...e})),Ee()}function ke(){u===`saving`||xe||(u===`checking`&&(Ee(),f(`idle`)),Te?q(!0):e.onClose())}function Ae(){try{z(It(F)),V(`0`),L(``)}catch{L(t.setupImportError),z([])}}function je(){let t=R[Number(B)];if(!t)return;let n={...t,id:ce.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...ce.current?{enabled:i.extra.enabled}:{}}};a(n),l(xn(n)),Ee(),U(e=>e+1),P(!1),I(``),z([])}function Me(e){function n(e,t){return T({field:e,message:t}),!1}if(e.transport===`streamable-http`){try{e.url=Ft(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(s.mode===`bearer`&&!s.token.trim().replace(/^Bearer\s*/i,``)||s.mode===`apiKey`&&(!s.apiKey.trim()||!s.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(Cn(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(s.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(s.mode===`headers`&&!e.headers.some(e=>e.key.trim()&&(e.value.trim()||e.reference)))return n(`auth`,t.setupCredentialRequired)}else if(!e.command.trim())return n(`command`,t.setupCommandRequired);if(e.timeout!==void 0&&(!Number.isFinite(e.timeout)||e.timeout<=0))return n(`advanced`,t.setupInvalidConfig);try{zt(e)}catch(r){return n(e.transport===`stdio`?`commandOptions`:`advanced`,r instanceof Error&&r.message.startsWith(`Environment`)?t.setupEnvInvalid:t.setupInvalidConfig)}return!0}async function Ne(){h(``),f(`checking`),pe.current=``,window.electronAPI?.shell?.openExternalUrl||(fe.current=window.open(`about:blank`,`_blank`),fe.current&&(fe.current.opener=null));try{let e=await Gt(Y.current);if(!me.current){fe.current?.close(),Y.current&&Ut(Y.current).catch(()=>{});return}de.current=e.id,k(e)}catch{fe.current?.close(),me.current&&h(t.setupAuthFailed)}finally{me.current&&f(`idle`)}}async function Pe(){let r=Sn(i,s);if(!Me(r))return;let o=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==ce.current),c=new Set([...e.managedServerIds,...o.map(e=>e.id)]);if(r.id=ce.current||r.id.trim()||Pt(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){T({field:`advanced`,message:n.duplicateServerId});return}Ee(),f(`checking`);let l=new AbortController;le.current=l;try{let n=await Vt(r,ce.current||void 0,e.initialRow.extra,l.signal);if(!me.current||l.signal.aborted){Ut(n.id).catch(()=>{});return}Y.current=n.id,a(r),oe(In(r,s));let i=await Ht(n.id,l.signal);if(!me.current||l.signal.aborted)return;D(i),i.state===`error`&&h(Pn(i,t))}catch(e){me.current&&!l.signal.aborted&&h(e.status===409?t.setupConflict:Pn(e,t))}finally{me.current&&le.current===l&&f(`idle`)}}async function Fe(n=!1){if(!(!Y.current||E?.state!==`connected`||ie!==In(i,s))){f(`saving`),h(``);try{let t=await Wt(Y.current,n);Y.current=void 0,await be.current().catch(()=>{}),t?.reloadRequired?_(!0):e.onClose()}catch(e){let n=e.status;n===404||n===409?(Ee(),h(t.setupConflict)):h(t.setupSaveFailed)}finally{me.current&&f(`idle`)}}}async function Ie(){X.current?.abort();let e=Y.current;de.current=void 0,k(void 0),fe.current?.close(),h(t.setupCancelled),f(`checking`);try{e&&await qt(e)}catch{me.current&&(Ee(),h(t.setupCancelled))}finally{me.current&&f(`idle`)}}async function Le(){O?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(O.authorizationUrl)).ok||h(t.oauthOpenFailed):window.open(O.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Re(){if(O)try{await Jt(Y.current,W),G(``),h(``)}catch{h(t.setupRedirectInvalid)}}let ze=!!Y.current&&ie===In(i,s)&&(s.mode===`oauth`||s.mode===`auto`&&E?.state===`oauth_required`)&&E?.state!==`connected`,Be=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(i.url.trim()),Ve=R[Number(B)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(w,{open:e.open,onOpenChange:e=>{e||ke()},children:(0,$.jsxs)(x,{children:[(0,$.jsx)(v,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(S,{ref:he,tabIndex:-1,className:`fixed left-1/2 top-1/2 z-[60] flex h-[min(44rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,onOpenAutoFocus:e=>{e.preventDefault(),he.current?.focus()},children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge p-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(C,{className:`font-semibold`,children:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(y,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:u===`saving`||xe,onClick:ke,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(d,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[N?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:()=>P(!1),children:t.setupImportBack}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportEmpty}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[t.setupImport,(0,$.jsx)(`textarea`,{className:p(En,`mt-1.5 min-h-40 font-mono text-xs`),value:F,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{I(e.target.value),z([]),L(``)}})]}),(0,$.jsx)(J,{variant:`secondary`,disabled:!F.trim(),onClick:Ae,children:t.setupImportPreview}),ee?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:ee}):null,Ve?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportScope}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium`,children:[t.setupImportChoose,(0,$.jsx)(_e,{"aria-label":t.setupImportChoose,className:p(En,`mt-1.5`),value:B,onChange:e=>V(e.target.value),children:R.map((e,t)=>(0,$.jsx)(Z,{value:String(t),children:e.displayName||e.id||tn(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[Ve.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,tn(Ve)]})]}):null]}):(0,$.jsxs)(`form`,{ref:ve,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&i.url.trim())try{Ft(i.url)}catch{T({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Pe()},children:[(0,$.jsxs)(`fieldset`,{disabled:Se||g,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(j,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`stdio`].map(e=>(0,$.jsx)(J,{type:`button`,variant:i.transport===e?`secondary`:`ghost`,"aria-pressed":i.transport===e,onClick:()=>De({transport:e}),children:e===`stdio`?t.setupUseCommand:t.setupUseUrl},e))}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,onClick:()=>P(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Nn,{row:i,t,variant:`basic`,onUpdate:De},`${i.transport}-${H}`)}),i.transport===`streamable-http`?(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(An,{allowExisting:!!i.extra.auth||i.headers.some(e=>!!e.reference),draft:s,onChange:Oe,t})}):null,b?(0,$.jsx)(`p`,{id:r,ref:ye,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:b.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:A,onToggle:e=>M(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Nn,{row:i,t,variant:`advanced`,idReadOnly:re,showOAuth:s.mode===`oauth`,onUpdate:De}),i.transport===`streamable-http`&&s.mode!==`headers`&&s.mode!==`existing`?(0,$.jsx)(kn,{additional:!0,headers:s.additionalHeaders,onChange:e=>Oe({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i.transport===`stdio`?t.setupCommandHostHint:Be?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),g?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!N&&!g?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[u===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(ae,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),u===`saving`?t.setupSaving:t.setupChecking]}),u===`idle`&&re&&!Ce&&!E&&!m&&!xe?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:we?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,E?.state===`connected`?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(o,{className:`size-4 shrink-0`,"aria-hidden":!0}),E.toolCount?t.setupConnected.replace(`{{count}}`,String(E.toolCount)):t.setupZeroTools]}),(0,$.jsx)(J,{ref:ge,variant:`secondary`,onClick:()=>K(!0),children:t.viewTools})]}):null,E?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,E?.state===`oauth_required`&&!xe?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,xe?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(ae,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[O?.authorizationUrl?(0,$.jsxs)(J,{variant:`secondary`,onClick:()=>void Le(),children:[(0,$.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(J,{variant:`ghost`,onClick:()=>void Ie(),children:t.setupCancelAuth})]}),O?.acceptsRedirect?(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:t.setupRemoteFallback}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.setupRedirectHint}),(0,$.jsxs)(`label`,{className:`mt-2 block text-sm`,children:[t.setupRedirectLabel,(0,$.jsx)(`input`,{className:En,value:W,onChange:e=>G(e.target.value)})]}),(0,$.jsx)(J,{className:`mt-2`,disabled:!W.trim(),onClick:()=>void Re(),children:t.setupContinue})]}):null]}):null,m?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:m}),m!==t.setupSaveFailed&&u!==`saving`?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:t.setupTestFailure}):null]}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(J,{variant:`secondary`,disabled:u===`saving`||xe,onClick:ke,children:re||g?t.setupClose:n.modalCancel}),g?null:N?(0,$.jsx)(J,{variant:`primary`,disabled:!Ve,onClick:je,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{variant:E?.state===`connected`?`secondary`:`primary`,disabled:Se,onClick:()=>ze?void Ne():void Pe(),children:ze?t.setupSignIn:t.setupTestConnection}),E?.state===`connected`&&ie===In(i,s)?(0,$.jsxs)($.Fragment,{children:[we?(0,$.jsx)(J,{variant:`secondary`,disabled:Se,onClick:()=>void Fe(!0),children:t.setupEnableSave}):null,(0,$.jsx)(J,{variant:`primary`,disabled:Se,"aria-busy":Se,onClick:()=>void Fe(),children:re?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(ue,{open:ne,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>q(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),te?(0,$.jsx)(Qt,{draftId:Y.current,serverId:i.id,displayName:i.displayName,returnFocusTo:ge.current,t,onClose:()=>K(!1)}):null]})}var Rn=`builtin`,zn=`composio`,Bn=`xopc-store`;function Vn(e){return Rn}function Hn(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`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},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 Un(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Wn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function Gn({embedded:e=!1,onHeaderActionChange:t}){let n=Ze().filter(e=>e.format===`agent-plugin`),r=g(e=>e.language),o=f(r),s=o.connectorsSettings,c=o.mcpSettings,l=h(e=>e.conversationId),u=!!l,d=i(),[m,_]=a(),v=m.get(`understanding`)===`1`,y=Wn(m.get(`returnTo`)),b=!!m.get(`returnTo`)&&!v,x=m.get(`tab`),[S,C]=(0,Q.useState)(!v&&x===`connected`?`connected`:`discover`),w=(0,Q.useRef)(!1),[T,E]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[O,k]=(0,Q.useState)(!1),[A,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(1),[F,ee]=(0,Q.useState)(void 0),[R,B]=(0,Q.useState)(``),[V,H]=(0,Q.useState)(v||b?m.get(`connector`)??``:``),[U,W]=(0,Q.useState)(Vn(v?`understanding`:`default`)),[G,te]=(0,Q.useState)(`name`),[K,ne]=(0,Q.useState)(v?`understand`:`all`),[q,re]=(0,Q.useState)(null),[ie,oe]=(0,Q.useState)(null),[Y,X]=(0,Q.useState)(null),[ue,fe]=(0,Q.useState)(null),[me,he]=(0,Q.useState)(null),[ge,_e]=(0,Q.useState)(null),{data:ve,mutate:ye}=D(u),be=ve?.payload?.config,Z=(0,Q.useMemo)(()=>be===void 0?null:Rt(be),[be]),xe=Z?.servers??[],Se=T.instances.length+xe.length+n.reduce((e,t)=>e+(t.components?.mcp.length??0),0),[Te,Ee]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(Ee({}),!u||!be)return;let e=new AbortController;return Xt(e.signal).then(t=>{e.signal.aborted||Ee(t)}).catch(()=>{}),()=>e.abort()},[u,be]);let De=(0,Q.useCallback)(async()=>{if(!l){E({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}E(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Ce(),pe()]);E(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){E({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[l]);(0,Q.useEffect)(()=>{De()},[De]),(0,Q.useEffect)(()=>{w.current||T.loading||u&&!Z||(C(v?`discover`:Se>0?`connected`:`discover`),w.current=!0)},[u,Se,Z,v,T.loading]);let Oe=(0,Q.useCallback)(e=>{w.current=!0,C(e)},[]),ke=(0,Q.useMemo)(()=>[{id:zn,displayName:s.composioSourceName},{id:Bn,displayName:s.storeSourceName}],[s.composioSourceName,s.storeSourceName]),Ae=(0,Q.useCallback)(async e=>{if(!u||U===`builtin`){E(e=>({...e,registryCatalog:[]})),P(1),ee(void 0);return}let t=V.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=U===`all`?ke:ke.filter(e=>e.id===U);if(i.length!==0){k(!0),r?E(e=>({...e,error:null})):(P(1),ee(void 0),E(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await Le({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Ne({q:t||void 0,page:n,pageSize:24,sort:G===`source`?`newest`:`downloads`});return{connectors:r.items.flatMap(e=>{let t=Hn(e);return t?[t]:[]}),totalPages:r.meta.totalPages}})),a=Un(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));P(n),ee(o),E(e=>({...e,registryCatalog:r?Un([...e.registryCatalog,...a]):a}))}catch(e){E(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{k(!1)}}},[G,V,U,u,ke]);(0,Q.useEffect)(()=>{if(S!==`discover`||T.loading)return;if(U===`builtin`){E(e=>({...e,registryCatalog:[]})),P(1),ee(void 0);return}let e=window.setTimeout(()=>{Ae()},V.trim()?350:0);return()=>window.clearTimeout(e)},[V,U,Ae,T.loading,S]);let je=(0,Q.useMemo)(()=>new Set(T.instances.map(e=>e.connectorId)),[T.instances]),Me=(0,Q.useMemo)(()=>new Map([...T.catalog,...T.registryCatalog].map(e=>[e.id,e])),[T.catalog,T.registryCatalog]);(0,Q.useEffect)(()=>{if(T.loading)return;let e=m.get(`connector`),t=m.get(`instance`);if(!e&&!t)return;let n=T.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)w.current=!0,B(``),X(n.instanceId),fe(n),C(`connected`);else if(e){let t=Me.get(e);if(!t)return;w.current=!0,W(Vn(v?`understanding`:`default`)),H(``),oe(t),C(`discover`)}let r=new URLSearchParams(m);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),_(r,{replace:!0})},[Me,v,m,_,T.instances,T.loading]);let Pe=(0,Q.useCallback)(async e=>{M(!0),E(e=>({...e,error:null}));try{let t=await ze(e);re(L(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){E(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{M(!1)}},[]),Fe=(0,Q.useMemo)(()=>new Set(T.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[T.instances]),Ie=(0,Q.useCallback)(async e=>{let t=await Zt(e);await ye(),await De(),t.reloadRequired&&E(e=>({...e,error:c.setupReloadRequired}))},[De,ye,c.setupReloadRequired]),Re=(0,Q.useCallback)(()=>{_e({mode:`add`,row:bn(xe,Fe)})},[xe,Fe]),Be=I(e=>e.setPageHeader),Ve=I(e=>e.clearPageHeader),He=(0,Q.useMemo)(()=>({searchLabel:S===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder,search:(0,$.jsx)(Qe,{value:S===`connected`?R:V,onChange:S===`connected`?B:H,placeholder:S===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder}),secondary:(0,$.jsx)(Ct,{onRefresh:S===`connected`&&u?De:void 0,refreshing:T.loading,refreshLabel:s.refreshConnections,onBrowseCatalog:()=>Oe(`discover`),onAddCustomServer:Re,addLabel:s.addConnection,browseLabel:s.addFromCatalog,customLabel:s.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[R,s,V,u,r,De,o.capabilitiesHub.moreActions,Re,Oe,T.loading,S]);(0,Q.useLayoutEffect)(()=>e?(t?.(He),()=>t?.(null)):(Be({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:s.title})}),end:(0,$.jsx)($e,{contribution:He})}),()=>Ve()),[Ve,s.title,e,He,t,Be]);let Ue=(0,Q.useMemo)(()=>T.instances.map(e=>({instance:e,value:ht(e,Me.get(e.connectorId))})),[Me,T.instances]),We=(0,Q.useMemo)(()=>new Map(Ue.map(({instance:e,value:t})=>[e.instanceId,t])),[Ue]),Ke=(0,Q.useMemo)(()=>T.instances.filter(e=>se(e,R)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=We.get(e.instanceId)?.state??`checking`,i=We.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[R,We,T.instances]),qe=(0,Q.useMemo)(()=>Ke.filter(e=>We.get(e.instanceId)?.state===`needs_setup`),[We,Ke]),Je=(0,Q.useMemo)(()=>Ke.filter(e=>We.get(e.instanceId)?.state!==`needs_setup`),[We,Ke]),Ye=(0,Q.useMemo)(()=>xe.filter(e=>z(e,R)),[R,xe]),Xe=(0,Q.useMemo)(()=>{let e=R.trim().toLowerCase();return n.flatMap(t=>(t.components?.mcp??[]).filter(n=>`${t.name} ${n.name}`.toLowerCase().includes(e)).map(e=>({extension:t,server:e})))},[R,n]),et=Ke.length+Ye.length+Xe.length,nt=(0,Q.useMemo)(()=>T.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&de(e)),[T.catalog]),rt=(0,Q.useMemo)(()=>U===`builtin`?nt:U===`all`?Un([...nt,...T.registryCatalog]):T.registryCatalog,[nt,U,T.registryCatalog]),at=(0,Q.useMemo)(()=>{let e=v?rt.filter(e=>e.understanding?.mode===`activity`):rt;return le(K===`all`?e:e.filter(e=>pt(e).includes(K)),V,G)},[G,V,rt,v,K]),ct=(0,Q.useMemo)(()=>ft.filter(e=>rt.some(t=>pt(t).includes(e))),[rt]);(0,Q.useEffect)(()=>{K!==`all`&&!ct.includes(K)&&ne(`all`)},[ct,K]);let ut=S===`discover`&&U!==`builtin`&&!!(F&&N<F),mt=(0,Q.useMemo)(()=>T.instances.find(e=>e.instanceId===Y)??ue,[Y,ue,T.instances]),gt=(0,Q.useMemo)(()=>[{value:`all`,label:s.discoverSourceAll},{value:Rn,label:s.discoverSourceBuiltin},...ke.map(e=>({value:e.id,label:e.displayName}))],[s.discoverSourceAll,s.discoverSourceBuiltin,ke]),_t=[{id:`connected`,label:s.tabConnected,count:Se},{id:`discover`,label:s.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:p(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[u?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:s.tokenHint}),v?(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:s.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.understandingSetupHint})]}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>d(y),children:s.understandingSetupDone})]}):null,b?(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:s.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.recoverySetupHint})]}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>d(y),children:s.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(we,{items:_t,activeTab:S,onChange:Oe,ariaLabel:s.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),T.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:T.error}):null,S===`connected`&&u?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:T.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":s.loading,children:ot.slice(0,3).map(e=>(0,$.jsx)(dt,{},e))}):Se===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.connectionsEmpty}),(0,$.jsx)(J,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Oe(`discover`),children:s.addFromCatalog})]}):et===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[qe.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:s.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:qe.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-amber-500/25 bg-amber-500/5`,children:qe.map(e=>(0,$.jsx)(yn,{instance:e,definition:Me.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{he(null),X(e.instanceId),fe(e)},t:s},e.instanceId))})]}):null,Je.length?(0,$.jsx)(`section`,{children:(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:Je.map(e=>(0,$.jsx)(yn,{instance:e,definition:Me.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{he(null),X(e.instanceId),fe(e)},t:s},e.instanceId))})}):null,Xe.map(({extension:e,server:t})=>(0,$.jsx)(tt,{pluginId:e.pluginId,server:t,enabled:e.active},t.id)),Ye.length||!R.trim()?(0,$.jsxs)(`section`,{"aria-label":s.customIntegrationsTitle,className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`h2`,{className:`inline text-sm font-medium text-fg`,children:s.customIntegrationsTitle}),(0,$.jsx)(`span`,{className:`ml-2 text-xs tabular-nums text-fg-subtle`,children:Ye.length}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:s.customIntegrationsHint})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 px-4 py-3`,children:(0,$.jsx)(J,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:Re,children:s.addCustomServerAdvanced})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Ye.map(e=>(0,$.jsx)(nn,{row:e,lastCheck:Te[e.id],t:c,cs:s,onEdit:()=>_e({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Ie(e)},e.clientKey))})]})]}):null]})}):null,S===`discover`&&u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[v?null:(0,$.jsx)(j,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":s.taskFilterAria,indicatorClassName:`rounded-lg bg-surface-active`,children:[`all`,...ct].map(e=>(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,K===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":K===e,onClick:()=>ne(e),children:e===`all`?s.taskAll:s.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:p(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,v?`grid-cols-1`:`grid-cols-2`),children:[v?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(Ge,{value:U,options:gt,placeholder:s.discoverSourceAll,allowEmpty:!1,ariaLabel:s.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:W})}),(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(Ge,{value:G,options:[{value:`name`,label:s.sortName},{value:`source`,label:s.sortSource}],placeholder:s.sortName,allowEmpty:!1,ariaLabel:s.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>te(e)})})]})]}),(T.loading||O)&&at.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:ot.map(e=>(0,$.jsx)(lt,{},e))}):at.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[O?(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":s.loading,children:(0,$.jsx)(ae,{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:at.map(e=>(0,$.jsx)(it,{connector:e,installed:je.has(e.id)||st(e,T.instances),onInstall:e=>{if(e.source===`store`){Pe(e.id);return}re(L(e))},onOpenDetails:e.source===`store`?void 0:oe,t:s},e.id))}),ut?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(J,{type:`button`,variant:`secondary`,disabled:O||A,onClick:()=>void Ae({page:N+1,append:!0}),children:[O?(0,$.jsx)(ae,{className:`size-4 animate-spin`}):null,s.loadMore]})}):null]})]}):null]}),q?(0,$.jsx)(ce,{draft:q,onChange:re,onClose:()=>re(null),t:s,onInstalled:async e=>{await De(),await ye(),he(e.instanceId),Oe(`connected`)}}):null,ie?(0,$.jsx)(yt,{connector:ie,installed:je.has(ie.id)||st(ie,T.instances),onClose:()=>oe(null),onInstall:e=>re(L(e)),t:s}):null,mt?(0,$.jsx)(vn,{instance:mt,definition:Me.get(mt.connectorId),onClose:()=>{X(null),fe(null)},onChanged:De,t:s,mcp:c}):null,ge?(0,$.jsx)(Ln,{open:!0,mode:ge.mode,initialRow:ge.row,lastCheck:ge.mode===`edit`?Te[ge.row.id]:void 0,existingCustomServers:xe,config:be,managedServerIds:Fe,t:c,cs:s,onClose:()=>_e(null),onSaved:async()=>{await ye(),await De(),Oe(`connected`)}},`${ge.mode}-${ge.row.clientKey}`):null]})})}export{Gn as ConnectorsPage};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-0WouolD0.js";import{n as a}from"./locale-store-Djl2FW6_.js";import{Ds as o,Os as ee,Ss as te,_s as ne,cf as re,gs as ie,hs as ae,sf as oe,uf as se}from"./index-BNRLzxpH.js";var s=e(t(),1),ce=n();function c(e){return String(e).padStart(2,`0`)}function le(e){return`${e.getFullYear()}-${c(e.getMonth()+1)}-${c(e.getDate())}`}function ue(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i,12);return a.getFullYear()===n&&a.getMonth()===r&&a.getDate()===i?a:null}function de(e,t){let n=ue(e);return n?t===`zh`?`${n.getFullYear()}/${c(n.getMonth()+1)}/${c(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var l=r();function fe(e,t){let n=new Date(e.getFullYear(),e.getMonth(),1,12),r=(n.getDay()-t+7)%7;return Array.from({length:42},(e,t)=>new Date(n.getFullYear(),n.getMonth(),1-r+t,12))}function u(e){let t=(0,ce.c)(105),{value:n,onChange:r,disabled:c,className:u,ariaLabel:_e,placeholder:ve,min:d,max:f}=e,p=a(ge),m=p===`zh`?`zh-CN`:`en`,ye;t[0]===n?ye=t[1]:(ye=ue(n),t[0]=n,t[1]=ye);let h=ye,[g,be]=(0,s.useState)(!1),[xe,Se]=(0,s.useState)(null),_;t[2]===h?_=t[3]:(_=()=>h??new Date,t[2]=h,t[3]=_);let[v,Ce]=(0,s.useState)(_),we=ae(xe),Te=ne(ie(),we!==null),y=+(p===`zh`),b,x;t[4]!==g||t[5]!==n?(b=()=>{if(!g)return;let e=ue(n);e&&Ce(e)},x=[g,n],t[4]=g,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),(0,s.useEffect)(b,x);let S;t[8]!==v||t[9]!==y?(S=fe(v,y),t[8]=v,t[9]=y,t[10]=S):S=t[10];let Ee=S,C;if(t[11]!==m||t[12]!==y){let e=new Date(2026,7,23,12);C=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+y+n),new Intl.DateTimeFormat(m,{weekday:`narrow`}).format(r)}),t[11]=m,t[12]=y,t[13]=C}else C=t[13];let De=C,w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=le(new Date),t[14]=w):w=t[14];let T=w,E;t[15]===h?E=t[16]:(E=h?le(h):``,t[15]=h,t[16]=E);let D=E,O;t[17]!==m||t[18]!==v?(O=new Intl.DateTimeFormat(m,{year:`numeric`,month:`long`}).format(v),t[17]=m,t[18]=v,t[19]=O):O=t[19];let Oe=O,k;t[20]===r?k=t[21]:(k=e=>{r(e),be(!1)},t[20]=r,t[21]=k);let A=k,ke=ee,Ae=c&&`cursor-not-allowed opacity-50`,j;t[22]!==u||t[23]!==Ae?(j=i(`flex h-10 w-full min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-hover px-3 text-left text-sm text-fg outline-none transition-colors`,`hover:bg-surface-active focus-visible:ring-2 focus-visible:ring-accent/40`,Ae,u),t[22]=u,t[23]=Ae,t[24]=j):j=t[24];let je=!n&&`text-fg-subtle`,M;t[25]===je?M=t[26]:(M=i(`min-w-0 truncate tabular-nums`,je),t[25]=je,t[26]=M);let N;t[27]!==p||t[28]!==ve||t[29]!==n?(N=de(n,p)||ve||(p===`zh`?`选择日期`:`Select date`),t[27]=p,t[28]=ve,t[29]=n,t[30]=N):N=t[30];let P;t[31]!==M||t[32]!==N?(P=(0,l.jsx)(`span`,{className:M,children:N}),t[31]=M,t[32]=N,t[33]=P):P=t[33];let F;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,l.jsx)(se,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=F):F=t[34];let I;t[35]!==_e||t[36]!==c||t[37]!==j||t[38]!==P?(I=(0,l.jsx)(o,{asChild:!0,children:(0,l.jsxs)(`button`,{ref:Se,type:`button`,disabled:c,"aria-label":_e,className:j,children:[P,F]})}),t[35]=_e,t[36]=c,t[37]=j,t[38]=P,t[39]=I):I=t[39];let Me=ee,Ne=we??void 0,Pe=ee,Fe=i(Te,`w-[19rem] rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Ie=p===`zh`?`上个月`:`Previous month`,L,R;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>Ce(he),R=(0,l.jsx)(re,{className:`size-4`,"aria-hidden":!0}),t[40]=L,t[41]=R):(L=t[40],R=t[41]);let z;t[42]===Ie?z=t[43]:(z=(0,l.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Ie,onClick:L,children:R}),t[42]=Ie,t[43]=z);let B;t[44]===Oe?B=t[45]:(B=(0,l.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:Oe}),t[44]=Oe,t[45]=B);let Le=p===`zh`?`下个月`:`Next month`,Re,ze;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Re=()=>Ce(me),ze=(0,l.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t[46]=Re,t[47]=ze):(Re=t[46],ze=t[47]);let V;t[48]===Le?V=t[49]:(V=(0,l.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Le,onClick:Re,children:ze}),t[48]=Le,t[49]=V);let H;t[50]!==z||t[51]!==B||t[52]!==V?(H=(0,l.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[z,B,V]}),t[50]=z,t[51]=B,t[52]=V,t[53]=H):H=t[53];let U;t[54]===De?U=t[55]:(U=(0,l.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:De.map(pe)}),t[54]=De,t[55]=U);let W;if(t[56]!==Ee||t[57]!==m||t[58]!==f||t[59]!==d||t[60]!==A||t[61]!==D||t[62]!==v){let e;t[64]!==m||t[65]!==f||t[66]!==d||t[67]!==A||t[68]!==D||t[69]!==v?(e=e=>{let t=le(e),n=t===D,r=t===T,a=e.getMonth()!==v.getMonth(),o=!!(d&&t<d||f&&t>f);return(0,l.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":o,disabled:o,"aria-label":new Intl.DateTimeFormat(m,{dateStyle:`full`}).format(e),className:i(`mx-auto flex size-9 items-center justify-center rounded-xl text-sm tabular-nums text-fg transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a&&`text-fg-disabled`,o&&`cursor-not-allowed opacity-35 hover:bg-transparent`,r&&!n&&`bg-accent-soft font-semibold text-accent-fg`,n&&`bg-accent font-semibold text-on-accent hover:bg-accent-hover`),onClick:()=>A(t),children:e.getDate()},t)},t[64]=m,t[65]=f,t[66]=d,t[67]=A,t[68]=D,t[69]=v,t[70]=e):e=t[70],W=Ee.map(e),t[56]=Ee,t[57]=m,t[58]=f,t[59]=d,t[60]=A,t[61]=D,t[62]=v,t[63]=W}else W=t[63];let G;t[71]===W?G=t[72]:(G=(0,l.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:W}),t[71]=W,t[72]=G);let Be=!n,K;t[73]===A?K=t[74]:(K=()=>A(``),t[73]=A,t[74]=K);let Ve=p===`zh`?`清除`:`Clear`,q;t[75]!==Be||t[76]!==K||t[77]!==Ve?(q=(0,l.jsx)(`button`,{type:`button`,disabled:Be,className:`rounded-lg px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,onClick:K,children:Ve}),t[75]=Be,t[76]=K,t[77]=Ve,t[78]=q):q=t[78];let He=!!(d&&T<d||f&&T>f),J;t[79]===A?J=t[80]:(J=()=>A(T),t[79]=A,t[80]=J);let Ue=p===`zh`?`今天`:`Today`,Y;t[81]!==He||t[82]!==J||t[83]!==Ue?(Y=(0,l.jsx)(`button`,{type:`button`,disabled:He,className:`rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80 disabled:pointer-events-none disabled:opacity-35`,onClick:J,children:Ue}),t[81]=He,t[82]=J,t[83]=Ue,t[84]=Y):Y=t[84];let X;t[85]!==q||t[86]!==Y?(X=(0,l.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[q,Y]}),t[85]=q,t[86]=Y,t[87]=X):X=t[87];let We;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,l.jsx)(te,{className:`fill-surface-overlay`}),t[88]=We):We=t[88];let Z;t[89]!==Pe.Content||t[90]!==Fe||t[91]!==H||t[92]!==U||t[93]!==G||t[94]!==X?(Z=(0,l.jsxs)(Pe.Content,{align:`start`,sideOffset:6,collisionPadding:12,className:Fe,children:[H,U,G,X,We]}),t[89]=Pe.Content,t[90]=Fe,t[91]=H,t[92]=U,t[93]=G,t[94]=X,t[95]=Z):Z=t[95];let Q;t[96]!==Me.Portal||t[97]!==Ne||t[98]!==Z?(Q=(0,l.jsx)(Me.Portal,{container:Ne,children:Z}),t[96]=Me.Portal,t[97]=Ne,t[98]=Z,t[99]=Q):Q=t[99];let $;return t[100]!==g||t[101]!==ke.Root||t[102]!==I||t[103]!==Q?($=(0,l.jsxs)(ke.Root,{open:g,onOpenChange:be,children:[I,Q]}),t[100]=g,t[101]=ke.Root,t[102]=I,t[103]=Q,t[104]=$):$=t[104],$}function pe(e,t){return(0,l.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function me(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function he(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function ge(e){return e.language}export{u as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./x-B_N4OPjy.js";import{t as s}from"./cn-0WouolD0.js";import{Fa as c,Hc as l,Ma as u,Na as d,Pa as f,Xu as p,eu as m,ja as h,sf as g}from"./index-CKdOZoVu.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w===void 0?!1:w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(f,{children:[(0,y.jsx)(c,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere] rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere]`,children:t.title})}),(0,y.jsx)(u,{children:(0,y.jsx)(h,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(o,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(l,{type:`button`,variant:`secondary`,className:s(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(p,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(g,{className:s(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:s(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(m,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:s(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:s(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:s(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words [overflow-wrap:anywhere]`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(d,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./x-B_N4OPjy.js";import{t as s}from"./cn-0WouolD0.js";import{Fa as c,Ia as l,Ma as u,Na as d,Pa as f,Qu as p,Wc as m,lf as h,nu as g}from"./index-BNRLzxpH.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w===void 0?!1:w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(c,{children:[(0,y.jsx)(l,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere] rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere]`,children:t.title})}),(0,y.jsx)(d,{children:(0,y.jsx)(u,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(o,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(m,{type:`button`,variant:`secondary`,className:s(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(p,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(h,{className:s(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:s(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(g,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:s(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:s(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:s(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words [overflow-wrap:anywhere]`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(f,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./x-B_N4OPjy.js";import{t as a}from"./messages-CaeL_miw.js";import{n as o}from"./locale-store-CE7L6MlS.js";import{sf as s,t as c}from"./index-CKdOZoVu.js";import{t as l}from"./desktop-pet-sprite-Bd-aOI7N.js";var u=e(t(),1),d=n(),f=9e4,p=3e4,m=20*6e4,h=45e3,g=45*6e4,_=58;function v(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=f}function y(e,t){return e.state===`running`&&t-e.timestamp>=p}function b(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function ee(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>_?`${n.slice(0,_-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function x(e,t,n){if(y(e,t))return n.stale;if(v(e,t))return n.longRunning}function S(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function C(e){let t=e.now-e.lastActivityAt,n=t>=m?(t-m)%g:1/0;return e.bubbleEnabled&&e.behaviorMode!==`focus`&&e.proactiveTipsEnabled&&(!e.remindersPausedUntil||e.now>=e.remindersPausedUntil)&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=h&&e.now>=e.dismissedUntil}function w(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:y(e,n)||t===`playful`||t===`companion`&&v(e,n)?`notice`:`ambient`}function T(e,t,n,r){let i=w(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var E=8e3;function D(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+E:void 0}}function O(e,t){let n={...e};for(let e of t){let t=n[e.conversationId];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.conversationId]=D(t,e))}return n}function k(e,t){return t?.runId===e.runId&&t.state===e.state}function te(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function ne(e){return e?`/chat/${e.conversationId}`:void 0}var A=r();function j(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??c(e.phase):`idle`}function M(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.conversationId}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function N(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return M(r?.success,t);if(t.state===`waiting`)return M(r?.waiting,t);if(t.state===`error`)return M(r?.error,t)}function P(e,t,n){return e?n?`${e} · ${t}`:e:t}function F(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function I(){let e=Date.now();return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`loopi`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,behaviorMode:`companion`,proactiveTipsEnabled:!0,interactionEnabled:!0,reducedMotion:!1,sizePercent:100,collapsed:!1},relationship:{firstMetAt:e,lastSeenAt:e,completedTaskCount:0,unlockedReactions:[],recentCompletedRunIds:[]},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function L(){let e=a(o(e=>e.language)).desktopPet,[t,n]=(0,u.useState)(I),[r,c]=(0,u.useState)({}),[d,f]=(0,u.useState)({}),[p,m]=(0,u.useState)(Date.now()),[h,_]=(0,u.useState)(()=>Date.now()),[v,y]=(0,u.useState)(0),[w,E]=(0,u.useState)(null),D=(0,u.useRef)(null),L=(0,u.useRef)(!1),R=(0,u.useRef)(null),z=(0,u.useRef)(null),B=(0,u.useRef)(null),V=(0,u.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),H=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),U=(0,u.useMemo)(()=>te(Object.values(r),p),[r,p]),W=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?U.filter(e=>!k(e,d[e.conversationId])&&T(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[U,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),G=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?U.filter(e=>k(e,d[e.conversationId])&&T(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[U,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),K=W[0]??U[0],q=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,J=w??(K?j(K):q),Y=e.personaPhrases[V?.persona?.tone??`calm`],X=C({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:W.length,activeCount:U.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,u.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),c(t=>O(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>c(t=>(_(Date.now()),O(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,u.useEffect)(()=>{if(!t.relationshipMoment)return;E(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>E(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,u.useLayoutEffect)(()=>{let e=R.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[z.current,B.current].filter(e=>e!==null).map(e=>({left:e.offsetLeft,top:e.offsetTop,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}));if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom)),o=Math.round(132*H),s=o+(z.current?8+z.current.offsetHeight:0);t.setContentSize({width:Math.ceil(Math.max(i-n,o)),height:Math.ceil(Math.max(a-r,s))})},r=new ResizeObserver(n);return r.observe(e),z.current&&r.observe(z.current),B.current&&r.observe(B.current),n(),()=>r.disconnect()},[X,W.length,t.prefs.collapsed,H]);let Z=(e=K)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.conversationId,e.runId),c(t=>{let{[e.conversationId]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(ne(e))},re=async()=>{if(Object.keys(d).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,u.useCallback)(e=>{e.button===0&&(D.current={pointerId:e.pointerId,x:e.screenX,y:e.screenY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ae=(0,u.useCallback)(e=>{let t=D.current;!t||t.pointerId!==e.pointerId||(t.moved||Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4)&&(t.moved=!0,E(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,u.useCallback)(e=>{let t=D.current;if(!t||e&&t.pointerId!==e.pointerId)return;D.current=null;let n=e?.type===`pointerup`&&Number.isFinite(e.screenX)&&Number.isFinite(e.screenY),r=t.moved||n&&Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4;r&&n&&window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}),window.electronAPI?.pet?.endDrag(),r&&(E(`released`),window.setTimeout(()=>E(null),700),L.current=!0,window.setTimeout(()=>{L.current=!1},0))},[]);(0,u.useEffect)(()=>{let e=e=>Q(e),t=()=>Q();return window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,t),()=>{window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,t)}},[Q]);let oe=()=>{L.current||Z()};if(!V)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*H)}px`,"--desktop-pet-menu-size":`${Math.round(28*H)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*H)}px`},$=t.prefs.collapsed?W.length:G;return(0,A.jsxs)(`div`,{ref:R,className:`desktop-pet-window`,"data-reduced-motion":t.prefs.reducedMotion,style:se,children:[!t.prefs.collapsed&&W.length>0?(0,A.jsx)(`div`,{ref:z,className:`desktop-pet-bubble desktop-pet-queue`,children:W.map(t=>{let n=x(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=ee(t,e.tipCompleteSummary),a=S(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),o=r??n??a??t.action,s=P(N(V,t,Y),o,!!(r||n||a)),c=F(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,A.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,A.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,A.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,A.jsx)(`strong`,{children:t.sessionLabel}),(0,A.jsxs)(`span`,{children:[s,r||n?``:b(t,p,e.tipTargetSuffix)]})]}),c?(0,A.jsx)(`span`,{className:`desktop-pet-session-cta`,children:c}):null]}),(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.conversationId,t.runId),f(e=>({...e,[t.conversationId]:{runId:t.runId,state:t.state}}))},children:(0,A.jsx)(i,{size:12})})]},t.conversationId)})}):null,X?(0,A.jsx)(`div`,{ref:z,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,A.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,A.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,A.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,A.jsx)(`strong`,{children:e.idleTipTitle}),(0,A.jsx)(`span`,{children:M(V.persona?.phrases?.greeting??Y.greeting,{conversationId:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+g),children:(0,A.jsx)(i,{size:12})})]})}):null,(0,A.jsxs)(`div`,{ref:B,className:`desktop-pet-stage`,children:[(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,A.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,A.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!K&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&E(`greet`)},onPointerLeave:()=>{D.current||E(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Q,title:e.openApp,children:(0,A.jsx)(l,{animationKey:K?.runId,pet:V,action:J,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*H)},V.id)})]})]})}function R(){let e=(0,d.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,A.jsx)(L,{}),e[0]=t):t=e[0],t}export{R as DesktopPetPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./x-B_N4OPjy.js";import{t as a}from"./messages-DPxcWxfD.js";import{n as o}from"./locale-store-Djl2FW6_.js";import{lf as s,t as c}from"./index-BNRLzxpH.js";import{t as l}from"./desktop-pet-sprite-Bd-aOI7N.js";var u=e(t(),1),d=n(),f=9e4,p=3e4,m=20*6e4,h=45e3,g=45*6e4,_=58;function v(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=f}function y(e,t){return e.state===`running`&&t-e.timestamp>=p}function b(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function ee(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>_?`${n.slice(0,_-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function x(e,t,n){if(y(e,t))return n.stale;if(v(e,t))return n.longRunning}function S(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function C(e){let t=e.now-e.lastActivityAt,n=t>=m?(t-m)%g:1/0;return e.bubbleEnabled&&e.behaviorMode!==`focus`&&e.proactiveTipsEnabled&&(!e.remindersPausedUntil||e.now>=e.remindersPausedUntil)&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=h&&e.now>=e.dismissedUntil}function w(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:y(e,n)||t===`playful`||t===`companion`&&v(e,n)?`notice`:`ambient`}function T(e,t,n,r){let i=w(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var E=8e3;function D(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+E:void 0}}function O(e,t){let n={...e};for(let e of t){let t=n[e.conversationId];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.conversationId]=D(t,e))}return n}function k(e,t){return t?.runId===e.runId&&t.state===e.state}function te(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function ne(e){return e?`/chat/${e.conversationId}`:void 0}var A=r();function j(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??c(e.phase):`idle`}function M(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.conversationId}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function N(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return M(r?.success,t);if(t.state===`waiting`)return M(r?.waiting,t);if(t.state===`error`)return M(r?.error,t)}function P(e,t,n){return e?n?`${e} · ${t}`:e:t}function F(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function I(){let e=Date.now();return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`loopi`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,behaviorMode:`companion`,proactiveTipsEnabled:!0,interactionEnabled:!0,reducedMotion:!1,sizePercent:100,collapsed:!1},relationship:{firstMetAt:e,lastSeenAt:e,completedTaskCount:0,unlockedReactions:[],recentCompletedRunIds:[]},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function L(){let e=a(o(e=>e.language)).desktopPet,[t,n]=(0,u.useState)(I),[r,c]=(0,u.useState)({}),[d,f]=(0,u.useState)({}),[p,m]=(0,u.useState)(Date.now()),[h,_]=(0,u.useState)(()=>Date.now()),[v,y]=(0,u.useState)(0),[w,E]=(0,u.useState)(null),D=(0,u.useRef)(null),L=(0,u.useRef)(!1),R=(0,u.useRef)(null),z=(0,u.useRef)(null),B=(0,u.useRef)(null),V=(0,u.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),H=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),U=(0,u.useMemo)(()=>te(Object.values(r),p),[r,p]),W=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?U.filter(e=>!k(e,d[e.conversationId])&&T(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[U,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),G=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?U.filter(e=>k(e,d[e.conversationId])&&T(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[U,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),K=W[0]??U[0],q=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,J=w??(K?j(K):q),Y=e.personaPhrases[V?.persona?.tone??`calm`],X=C({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:W.length,activeCount:U.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,u.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),c(t=>O(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>c(t=>(_(Date.now()),O(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,u.useEffect)(()=>{if(!t.relationshipMoment)return;E(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>E(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,u.useLayoutEffect)(()=>{let e=R.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[z.current,B.current].filter(e=>e!==null).map(e=>({left:e.offsetLeft,top:e.offsetTop,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}));if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom)),o=Math.round(132*H),s=o+(z.current?8+z.current.offsetHeight:0);t.setContentSize({width:Math.ceil(Math.max(i-n,o)),height:Math.ceil(Math.max(a-r,s))})},r=new ResizeObserver(n);return r.observe(e),z.current&&r.observe(z.current),B.current&&r.observe(B.current),n(),()=>r.disconnect()},[X,W.length,t.prefs.collapsed,H]);let Z=(e=K)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.conversationId,e.runId),c(t=>{let{[e.conversationId]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(ne(e))},re=async()=>{if(Object.keys(d).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,u.useCallback)(e=>{e.button===0&&(D.current={pointerId:e.pointerId,x:e.screenX,y:e.screenY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ae=(0,u.useCallback)(e=>{let t=D.current;!t||t.pointerId!==e.pointerId||(t.moved||Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4)&&(t.moved=!0,E(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,u.useCallback)(e=>{let t=D.current;if(!t||e&&t.pointerId!==e.pointerId)return;D.current=null;let n=e?.type===`pointerup`&&Number.isFinite(e.screenX)&&Number.isFinite(e.screenY),r=t.moved||n&&Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4;r&&n&&window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}),window.electronAPI?.pet?.endDrag(),r&&(E(`released`),window.setTimeout(()=>E(null),700),L.current=!0,window.setTimeout(()=>{L.current=!1},0))},[]);(0,u.useEffect)(()=>{let e=e=>Q(e),t=()=>Q();return window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,t),()=>{window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,t)}},[Q]);let oe=()=>{L.current||Z()};if(!V)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*H)}px`,"--desktop-pet-menu-size":`${Math.round(28*H)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*H)}px`},$=t.prefs.collapsed?W.length:G;return(0,A.jsxs)(`div`,{ref:R,className:`desktop-pet-window`,"data-reduced-motion":t.prefs.reducedMotion,style:se,children:[!t.prefs.collapsed&&W.length>0?(0,A.jsx)(`div`,{ref:z,className:`desktop-pet-bubble desktop-pet-queue`,children:W.map(t=>{let n=x(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=ee(t,e.tipCompleteSummary),a=S(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),o=r??n??a??t.action,s=P(N(V,t,Y),o,!!(r||n||a)),c=F(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,A.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,A.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,A.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,A.jsx)(`strong`,{children:t.sessionLabel}),(0,A.jsxs)(`span`,{children:[s,r||n?``:b(t,p,e.tipTargetSuffix)]})]}),c?(0,A.jsx)(`span`,{className:`desktop-pet-session-cta`,children:c}):null]}),(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.conversationId,t.runId),f(e=>({...e,[t.conversationId]:{runId:t.runId,state:t.state}}))},children:(0,A.jsx)(i,{size:12})})]},t.conversationId)})}):null,X?(0,A.jsx)(`div`,{ref:z,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,A.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,A.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,A.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,A.jsx)(`strong`,{children:e.idleTipTitle}),(0,A.jsx)(`span`,{children:M(V.persona?.phrases?.greeting??Y.greeting,{conversationId:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+g),children:(0,A.jsx)(i,{size:12})})]})}):null,(0,A.jsxs)(`div`,{ref:B,className:`desktop-pet-stage`,children:[(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,A.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,A.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!K&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&E(`greet`)},onPointerLeave:()=>{D.current||E(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Q,title:e.openApp,children:(0,A.jsx)(l,{animationKey:K?.runId,pet:V,action:J,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*H)},V.id)})]})]})}function R(){let e=(0,d.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,A.jsx)(L,{}),e[0]=t):t=e[0],t}export{R as DesktopPetPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./external-link-DjqjBmc3.js";import{t as o}from"./messages-CaeL_miw.js";import{t as s}from"./cn-0WouolD0.js";import{n as c}from"./locale-store-CE7L6MlS.js";import{Fu as l,Ic as u,Pc as d,Ya as f,if as p,is as m,iu as h,ls as g,sf as _,us as v,vl as y,yu as b}from"./index-CKdOZoVu.js";import{t as x}from"./desktop-pet-sprite-Bd-aOI7N.js";import{n as S,r as C}from"./settings-page-layout-Dx5S-Msc.js";var w=n(),T=e(t(),1),E=r();function D(e){let t=(0,w.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,E.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,E.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,E.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,E.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,E.jsxs)(`label`,{className:`flex min-h-12 cursor-pointer items-center justify-between gap-3 py-3`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function O(){let e=o(c(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,T.useState)(null),[w,O]=(0,T.useState)(!1),[k,A]=(0,T.useState)(null),j=typeof window<`u`?window.electronAPI?.pet:void 0,M=(0,T.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),N=(0,T.useCallback)(async()=>{if(j){O(!0);try{r(await j.getState())}finally{O(!1)}}},[j]);if((0,T.useEffect)(()=>{if(j)return N(),j.onStateChanged(r)},[j,N]),!m()||!j)return null;if(!n)return(0,E.jsxs)(C,{gap:`gap-4`,children:[(0,E.jsx)(S,{title:e.title,subtitle:e.subtitle}),(0,E.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,E.jsxs)(`div`,{className:`space-y-3`,children:[(0,E.jsx)(u,{className:`h-14 rounded-xl`}),(0,E.jsx)(u,{className:`h-14 rounded-xl`}),(0,E.jsx)(u,{className:`h-24 rounded-xl`}),(0,E.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,E.jsx)(u,{className:`h-16 rounded-xl`},t))})]})})]});let P=async e=>{O(!0);try{r(await j.setPrefs(e))}finally{O(!1)}},F=async e=>{e?(await j.show(),r(await j.getState())):r(await j.setPrefs({enabled:!1}))},I=e=>{P({selectedPetId:e})},L=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},R=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},z=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=L(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},B=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),V=()=>{R(e.createChatDraft)},H=t=>{R(B(e.optimizeChatDraft,{id:t.id,name:L(t).name,description:L(t).description,sourcePrompt:z(t)}))},U=t=>{R(B(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},W=k??n.prefs.sizePercent,G=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),K=async(e=W)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));A(null),t!==n.prefs.sizePercent&&await P({sizePercent:t})};return(0,E.jsxs)(C,{gap:`gap-5`,children:[(0,E.jsx)(S,{title:e.title,subtitle:e.subtitle,actions:(0,E.jsx)(f,{className:`size-9 shrink-0 p-0`,disabled:w,label:e.refresh,onClick:N})}),(0,E.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-6`,children:[(0,E.jsx)(`div`,{className:`grid h-40 w-40 shrink-0 place-items-center self-center rounded-xl bg-surface-hover/35`,children:M?(0,E.jsx)(x,{pet:M,action:`idle`,displayHeight:Math.round(104*W/100),reducedMotion:n.prefs.reducedMotion}):null}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-2`,children:[(0,E.jsx)(`h2`,{className:`break-words text-xl font-semibold text-fg`,children:M?L(M).name:e.title}),(0,E.jsx)(D,{title:e.enable,checked:n.prefs.enabled,disabled:w,onChange:e=>void F(e)})]}),(0,E.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondSummary.replace(`{days}`,String(G)).replace(`{tasks}`,String(n.relationship.completedTaskCount))}),n.pets.length>1?(0,E.jsx)(`div`,{className:`mt-4 max-w-56`,children:(0,E.jsx)(g,{"aria-label":e.petList,value:M?.id??``,onChange:e=>I(e.target.value),disabled:w,children:n.pets.map(e=>(0,E.jsx)(v,{value:e.id,children:L(e).name},e.id))})}):null,M&&!M.builtin?(0,E.jsxs)(`button`,{type:`button`,onClick:()=>H(M),className:`mt-3 inline-flex min-h-9 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,E.jsx)(b,{className:`size-3.5`}),e.optimizeInChat]}):null]})]}),(0,E.jsx)(`div`,{className:`border-t border-edge px-5 py-2`,children:(0,E.jsxs)(`button`,{type:`button`,onClick:V,className:s(`inline-flex min-h-10 items-center gap-2 text-xs font-medium text-fg-muted hover:text-accent-fg`,d.press),children:[(0,E.jsx)(y,{className:`size-4`}),e.createTitle]})})]}),n.petIssues.length>0?(0,E.jsxs)(`section`,{className:`rounded-xl border border-danger/20 bg-danger/5 p-4`,children:[(0,E.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,E.jsx)(p,{className:`size-4`}),e.invalidPets]}),(0,E.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.petIssues.map(t=>(0,E.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,E.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,E.jsx)(`p`,{className:`break-words`,children:t.reason}),(0,E.jsxs)(`details`,{className:`mt-1`,children:[(0,E.jsx)(`summary`,{className:`cursor-pointer`,children:e.issueDetails}),(0,E.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:t.dir}),t.details?.length?(0,E.jsx)(`p`,{className:`mt-1 break-words`,children:t.details.join(`; `)}):null]})]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>U(t),className:`inline-flex min-h-9 shrink-0 items-center gap-1.5 text-xs font-medium text-danger`,children:[(0,E.jsx)(l,{className:`size-3.5`}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null,(0,E.jsxs)(`section`,{"aria-label":e.displayGroup,children:[(0,E.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.displayGroup}),(0,E.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,E.jsx)(D,{title:e.showOnStartup,checked:n.prefs.showOnStartup,disabled:w,onChange:e=>void P({showOnStartup:e})}),(0,E.jsx)(D,{title:e.alwaysOnTop,checked:n.prefs.alwaysOnTop,disabled:w,onChange:e=>void P({alwaysOnTop:e})}),(0,E.jsx)(D,{title:e.bubbles,checked:n.prefs.bubbleEnabled,disabled:w,onChange:e=>void P({bubbleEnabled:e})}),(0,E.jsxs)(`div`,{className:`py-3`,children:[(0,E.jsxs)(`label`,{htmlFor:`desktop-pet-size`,className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[e.size,(0,E.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[W,`%`]})]}),(0,E.jsx)(`input`,{id:`desktop-pet-size`,type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:W,disabled:w,onChange:e=>A(Number(e.target.value)),onBlur:()=>void K(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&K()},onPointerUp:()=>void K()})]})]})]}),(0,E.jsxs)(`section`,{"aria-label":e.interactionGroup,children:[(0,E.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.interactionGroup}),(0,E.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,E.jsx)(D,{title:e.proactiveTips,checked:n.prefs.proactiveTipsEnabled,disabled:w,onChange:e=>void P({proactiveTipsEnabled:e})}),(0,E.jsx)(D,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:w,onChange:e=>void P({interactionEnabled:e})}),(0,E.jsx)(D,{title:e.reducedMotion,checked:n.prefs.reducedMotion,disabled:w,onChange:e=>void P({reducedMotion:e})}),(0,E.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-3 py-3`,children:[(0,E.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,E.jsxs)(g,{"aria-label":e.behaviorMode,className:`w-36`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,disabled:w,onChange:e=>void P({behaviorMode:e.target.value}),children:[(0,E.jsx)(v,{value:`focus`,children:e.behaviorFocus}),(0,E.jsx)(v,{value:`companion`,children:e.behaviorCompanion}),(0,E.jsx)(v,{value:`playful`,children:e.behaviorPlayful})]})]})]})]}),(0,E.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-panel`,children:[(0,E.jsxs)(`summary`,{className:`flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 px-4 text-sm font-medium text-fg [&::-webkit-details-marker]:hidden`,children:[e.advanced,(0,E.jsx)(_,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`})]}),(0,E.jsxs)(`div`,{className:`space-y-3 border-t border-edge px-4 pb-4`,children:[(0,E.jsx)(D,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:w,onChange:e=>void P({clickThroughWhenIdle:e})}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge pt-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.customPets}),(0,E.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void j.openCustomPetsDir(),className:`inline-flex min-h-10 shrink-0 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,E.jsx)(a,{className:`size-3.5`}),e.openFolder]})]}),(0,E.jsxs)(`button`,{type:`button`,className:s(`inline-flex min-h-10 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg disabled:opacity-50`,d.press),disabled:w,onClick:()=>void j.resetPosition().then(r),children:[(0,E.jsx)(h,{className:`size-3.5`}),e.resetPosition]})]})]})]})}export{O as DesktopPetSettings};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./external-link-DjqjBmc3.js";import{t as o}from"./messages-DPxcWxfD.js";import{t as s}from"./cn-0WouolD0.js";import{n as c}from"./locale-store-Djl2FW6_.js";import{Ic as l,Lu as u,Rc as d,Xa as f,bl as p,ds as m,fs as h,lf as g,of as _,os as v,ou as y,xu as b}from"./index-BNRLzxpH.js";import{t as x}from"./desktop-pet-sprite-Bd-aOI7N.js";import{n as S,r as C}from"./settings-page-layout-Dx5S-Msc.js";var w=n(),T=e(t(),1),E=r();function D(e){let t=(0,w.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,E.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,E.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,E.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,E.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,E.jsxs)(`label`,{className:`flex min-h-12 cursor-pointer items-center justify-between gap-3 py-3`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function O(){let e=o(c(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,T.useState)(null),[w,O]=(0,T.useState)(!1),[k,A]=(0,T.useState)(null),j=typeof window<`u`?window.electronAPI?.pet:void 0,M=(0,T.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),N=(0,T.useCallback)(async()=>{if(j){O(!0);try{r(await j.getState())}finally{O(!1)}}},[j]);if((0,T.useEffect)(()=>{if(j)return N(),j.onStateChanged(r)},[j,N]),!v()||!j)return null;if(!n)return(0,E.jsxs)(C,{gap:`gap-4`,children:[(0,E.jsx)(S,{title:e.title,subtitle:e.subtitle}),(0,E.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,E.jsxs)(`div`,{className:`space-y-3`,children:[(0,E.jsx)(d,{className:`h-14 rounded-xl`}),(0,E.jsx)(d,{className:`h-14 rounded-xl`}),(0,E.jsx)(d,{className:`h-24 rounded-xl`}),(0,E.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,E.jsx)(d,{className:`h-16 rounded-xl`},t))})]})})]});let P=async e=>{O(!0);try{r(await j.setPrefs(e))}finally{O(!1)}},F=async e=>{e?(await j.show(),r(await j.getState())):r(await j.setPrefs({enabled:!1}))},I=e=>{P({selectedPetId:e})},L=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},R=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},z=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=L(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},B=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),V=()=>{R(e.createChatDraft)},H=t=>{R(B(e.optimizeChatDraft,{id:t.id,name:L(t).name,description:L(t).description,sourcePrompt:z(t)}))},U=t=>{R(B(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},W=k??n.prefs.sizePercent,G=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),K=async(e=W)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));A(null),t!==n.prefs.sizePercent&&await P({sizePercent:t})};return(0,E.jsxs)(C,{gap:`gap-5`,children:[(0,E.jsx)(S,{title:e.title,subtitle:e.subtitle,actions:(0,E.jsx)(f,{className:`size-9 shrink-0 p-0`,disabled:w,label:e.refresh,onClick:N})}),(0,E.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-6`,children:[(0,E.jsx)(`div`,{className:`grid h-40 w-40 shrink-0 place-items-center self-center rounded-xl bg-surface-hover/35`,children:M?(0,E.jsx)(x,{pet:M,action:`idle`,displayHeight:Math.round(104*W/100),reducedMotion:n.prefs.reducedMotion}):null}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-2`,children:[(0,E.jsx)(`h2`,{className:`break-words text-xl font-semibold text-fg`,children:M?L(M).name:e.title}),(0,E.jsx)(D,{title:e.enable,checked:n.prefs.enabled,disabled:w,onChange:e=>void F(e)})]}),(0,E.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondSummary.replace(`{days}`,String(G)).replace(`{tasks}`,String(n.relationship.completedTaskCount))}),n.pets.length>1?(0,E.jsx)(`div`,{className:`mt-4 max-w-56`,children:(0,E.jsx)(m,{"aria-label":e.petList,value:M?.id??``,onChange:e=>I(e.target.value),disabled:w,children:n.pets.map(e=>(0,E.jsx)(h,{value:e.id,children:L(e).name},e.id))})}):null,M&&!M.builtin?(0,E.jsxs)(`button`,{type:`button`,onClick:()=>H(M),className:`mt-3 inline-flex min-h-9 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,E.jsx)(b,{className:`size-3.5`}),e.optimizeInChat]}):null]})]}),(0,E.jsx)(`div`,{className:`border-t border-edge px-5 py-2`,children:(0,E.jsxs)(`button`,{type:`button`,onClick:V,className:s(`inline-flex min-h-10 items-center gap-2 text-xs font-medium text-fg-muted hover:text-accent-fg`,l.press),children:[(0,E.jsx)(p,{className:`size-4`}),e.createTitle]})})]}),n.petIssues.length>0?(0,E.jsxs)(`section`,{className:`rounded-xl border border-danger/20 bg-danger/5 p-4`,children:[(0,E.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,E.jsx)(_,{className:`size-4`}),e.invalidPets]}),(0,E.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.petIssues.map(t=>(0,E.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,E.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,E.jsx)(`p`,{className:`break-words`,children:t.reason}),(0,E.jsxs)(`details`,{className:`mt-1`,children:[(0,E.jsx)(`summary`,{className:`cursor-pointer`,children:e.issueDetails}),(0,E.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:t.dir}),t.details?.length?(0,E.jsx)(`p`,{className:`mt-1 break-words`,children:t.details.join(`; `)}):null]})]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>U(t),className:`inline-flex min-h-9 shrink-0 items-center gap-1.5 text-xs font-medium text-danger`,children:[(0,E.jsx)(u,{className:`size-3.5`}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null,(0,E.jsxs)(`section`,{"aria-label":e.displayGroup,children:[(0,E.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.displayGroup}),(0,E.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,E.jsx)(D,{title:e.showOnStartup,checked:n.prefs.showOnStartup,disabled:w,onChange:e=>void P({showOnStartup:e})}),(0,E.jsx)(D,{title:e.alwaysOnTop,checked:n.prefs.alwaysOnTop,disabled:w,onChange:e=>void P({alwaysOnTop:e})}),(0,E.jsx)(D,{title:e.bubbles,checked:n.prefs.bubbleEnabled,disabled:w,onChange:e=>void P({bubbleEnabled:e})}),(0,E.jsxs)(`div`,{className:`py-3`,children:[(0,E.jsxs)(`label`,{htmlFor:`desktop-pet-size`,className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[e.size,(0,E.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[W,`%`]})]}),(0,E.jsx)(`input`,{id:`desktop-pet-size`,type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:W,disabled:w,onChange:e=>A(Number(e.target.value)),onBlur:()=>void K(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&K()},onPointerUp:()=>void K()})]})]})]}),(0,E.jsxs)(`section`,{"aria-label":e.interactionGroup,children:[(0,E.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.interactionGroup}),(0,E.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,E.jsx)(D,{title:e.proactiveTips,checked:n.prefs.proactiveTipsEnabled,disabled:w,onChange:e=>void P({proactiveTipsEnabled:e})}),(0,E.jsx)(D,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:w,onChange:e=>void P({interactionEnabled:e})}),(0,E.jsx)(D,{title:e.reducedMotion,checked:n.prefs.reducedMotion,disabled:w,onChange:e=>void P({reducedMotion:e})}),(0,E.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-3 py-3`,children:[(0,E.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,E.jsxs)(m,{"aria-label":e.behaviorMode,className:`w-36`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,disabled:w,onChange:e=>void P({behaviorMode:e.target.value}),children:[(0,E.jsx)(h,{value:`focus`,children:e.behaviorFocus}),(0,E.jsx)(h,{value:`companion`,children:e.behaviorCompanion}),(0,E.jsx)(h,{value:`playful`,children:e.behaviorPlayful})]})]})]})]}),(0,E.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-panel`,children:[(0,E.jsxs)(`summary`,{className:`flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 px-4 text-sm font-medium text-fg [&::-webkit-details-marker]:hidden`,children:[e.advanced,(0,E.jsx)(g,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`})]}),(0,E.jsxs)(`div`,{className:`space-y-3 border-t border-edge px-4 pb-4`,children:[(0,E.jsx)(D,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:w,onChange:e=>void P({clickThroughWhenIdle:e})}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge pt-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.customPets}),(0,E.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void j.openCustomPetsDir(),className:`inline-flex min-h-10 shrink-0 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,E.jsx)(a,{className:`size-3.5`}),e.openFolder]})]}),(0,E.jsxs)(`button`,{type:`button`,className:s(`inline-flex min-h-10 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg disabled:opacity-50`,l.press),disabled:w,onClick:()=>void j.resetPosition().then(r),children:[(0,E.jsx)(y,{className:`size-3.5`}),e.resetPosition]})]})]})]})}export{O as DesktopPetSettings};