@xopcai/xopc 0.0.433 → 0.0.435

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 (362) hide show
  1. package/README.md +5 -5
  2. package/README.zh-CN.md +5 -5
  3. package/dist/browser-ext/dist/sidepanel.js +11 -0
  4. package/dist/browser-ext/manifest.json +1 -1
  5. package/dist/extensions/telegram/xopc.extension.json +1 -1
  6. package/dist/gateway/static/root/assets/{activity-store-BpYGrRXw.js → activity-store-Cwn_CNwl.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DTgOSv6G.js → agent-avatar-dicebear-Cd23LnJJ.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agent-avatar-display-BUH7ljEo.js → agent-avatar-display-ByzM7u9S.js} +2 -2
  9. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-B_FAikHA.js → agent-defaults-settings-panel-B0i37diS.js} +1 -1
  10. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DPabZaSE.js → agent-plugin-dialog-XN-tZ-Ox.js} +1 -1
  11. package/dist/gateway/static/root/assets/{agents-BAPYP1Ka.js → agents-ZDA1OaLv.js} +3 -3
  12. package/dist/gateway/static/root/assets/{agents-admin-api-CXCAHNPj.js → agents-admin-api-B5lKH_ps.js} +1 -1
  13. package/dist/gateway/static/root/assets/{api-oIK4hYkJ.js → api-B9fZL-V8.js} +1 -1
  14. package/dist/gateway/static/root/assets/{api-DMbimMEi.js → api-Djju8qIR.js} +1 -1
  15. package/dist/gateway/static/root/assets/{app-management-settings-panel-BZ3Fy8ZR.js → app-management-settings-panel-IlyzDPJu.js} +1 -1
  16. package/dist/gateway/static/root/assets/{appearance-settings-DsRTj1by.js → appearance-settings-BxdFGob3.js} +1 -1
  17. package/dist/gateway/static/root/assets/apps-page-CxEKiOTA.js +1 -0
  18. package/dist/gateway/static/root/assets/{archive-plugin-Bg1VTieK.js → archive-plugin-4gEvotPr.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automation-api-CLPsgcQN.js → automation-api-4fVKv9PJ.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automation-result-state-CKVnR4KG.js → automation-result-state-m7PeK2kl.js} +1 -1
  21. package/dist/gateway/static/root/assets/automation-run-list-CJOdy_R2.js +1 -0
  22. package/dist/gateway/static/root/assets/{automation-task-card-D27Mw66U.js → automation-task-card-DZWhCWJa.js} +3 -3
  23. package/dist/gateway/static/root/assets/{automations-page-DGNTJ8lN.js → automations-page-BjbM15eY.js} +1 -1
  24. package/dist/gateway/static/root/assets/automations-workspace-CqurzLYX.js +9 -0
  25. package/dist/gateway/static/root/assets/{binary-plugins-CuwSdCG5.js → binary-plugins-69WyJLNW.js} +1 -1
  26. package/dist/gateway/static/root/assets/{block-editor-Dtl2BG3t.js → block-editor-DUONDIZR.js} +1 -1
  27. package/dist/gateway/static/root/assets/{browser-automation-inputs-uGK086ag.js → browser-automation-inputs-DL4YPCuN.js} +1 -1
  28. package/dist/gateway/static/root/assets/{browser-automations-page-Da_edNNS.js → browser-automations-page-1Aq6XmRs.js} +1 -1
  29. package/dist/gateway/static/root/assets/{browser-control-api-k3OOX3bS.js → browser-control-api-yjru8E7R.js} +1 -1
  30. package/dist/gateway/static/root/assets/{browser-settings-page-C1bSw-Jq.js → browser-settings-page-CvwpT8Um.js} +1 -1
  31. package/dist/gateway/static/root/assets/{capabilities-DlHPLld_.js → capabilities-C7lnwKKm.js} +1 -1
  32. package/dist/gateway/static/root/assets/{capabilities-CoeuLRt6.js → capabilities-DaeQXJT4.js} +1 -1
  33. package/dist/gateway/static/root/assets/capabilities-page-B5avAOUM.js +2 -0
  34. package/dist/gateway/static/root/assets/{capabilities-settings-panel-CtY-bGIi.js → capabilities-settings-panel-_9yCS78i.js} +1 -1
  35. package/dist/gateway/static/root/assets/capability-links-DeO34GIF.js +1 -0
  36. package/dist/gateway/static/root/assets/{channels-Cn1MWBL_.js → channels-CoQb4HOF.js} +1 -1
  37. package/dist/gateway/static/root/assets/{chat-agents-api-BB0biwc7.js → chat-agents-api-BUi_7GRo.js} +1 -1
  38. package/dist/gateway/static/root/assets/{chat-chart-block-QSvjx4w6.js → chat-chart-block-CcVcKsDZ.js} +1 -1
  39. package/dist/gateway/static/root/assets/chat-page--wcFhTjW.js +72 -0
  40. package/dist/gateway/static/root/assets/{chat-terminal-dock-Cd51G9eG.js → chat-terminal-dock-BMXJpPuH.js} +1 -1
  41. package/dist/gateway/static/root/assets/{command-palette-api-CEG10uE-.js → command-palette-api-luUjQPsh.js} +1 -1
  42. package/dist/gateway/static/root/assets/{composer-payload-handoff-Bogdq9Hy.js → composer-payload-handoff-B5XNxNCb.js} +1 -1
  43. package/dist/gateway/static/root/assets/computer-settings-page-CWtdyEJH.js +1 -0
  44. package/dist/gateway/static/root/assets/connected-providers-grid-2idMtk65.js +1 -0
  45. package/dist/gateway/static/root/assets/connection-usage-Cm_McddI.js +1 -0
  46. package/dist/gateway/static/root/assets/connection-usage-guide-Ddh0bfkj.js +1 -0
  47. package/dist/gateway/static/root/assets/{connector-service-page-k2rjyjrp.js → connector-service-page-C3msXaBk.js} +1 -1
  48. package/dist/gateway/static/root/assets/{connectors-api-DtvB9Cjm.js → connectors-api-NcWECWKg.js} +1 -1
  49. package/dist/gateway/static/root/assets/connectors-page-Crb6DILX.js +1 -0
  50. package/dist/gateway/static/root/assets/{date-picker-CAankdQw.js → date-picker-Cfjq1hD_.js} +1 -1
  51. package/dist/gateway/static/root/assets/{desktop-pet-DjM73fir.js → desktop-pet-ChFn9v-3.js} +1 -1
  52. package/dist/gateway/static/root/assets/{desktop-pet-settings-Rmh-GxHl.js → desktop-pet-settings-DvnVIv25.js} +1 -1
  53. package/dist/gateway/static/root/assets/{dev-view-store-BgW2Riyk.js → dev-view-store-DQJ61P5L.js} +1 -1
  54. package/dist/gateway/static/root/assets/{device-pairing-wizard-UdzSpNa5.js → device-pairing-wizard-KxaIL-OX.js} +1 -1
  55. package/dist/gateway/static/root/assets/{directory-picker-path-field-Rkw3f7lG.js → directory-picker-path-field-Drv864uE.js} +1 -1
  56. package/dist/gateway/static/root/assets/{discussion-annotation-sync-Dudoj_Fz.js → discussion-annotation-sync-DfBRkWtw.js} +1 -1
  57. package/dist/gateway/static/root/assets/{extension-debug-page-DxIGAO23.js → extension-debug-page-DAlBIt_R.js} +1 -1
  58. package/dist/gateway/static/root/assets/{extension-iframe-host-63KpX6IP.js → extension-iframe-host-Bds-5kY_.js} +1 -1
  59. package/dist/gateway/static/root/assets/{extension-marketplace-api-yXNUkQDA.js → extension-marketplace-api-CZg8nBwW.js} +1 -1
  60. package/dist/gateway/static/root/assets/{extension-page-C811A_Ww.js → extension-page-ZTw-oucT.js} +1 -1
  61. package/dist/gateway/static/root/assets/{extension-provider-C4jLFIgh.js → extension-provider-NKWfjpdP.js} +1 -1
  62. package/dist/gateway/static/root/assets/{extension-settings-page-WJSw5MT0.js → extension-settings-page-CT7PPt_q.js} +1 -1
  63. package/dist/gateway/static/root/assets/{file-preview-surface-zE9AcaHM.js → file-preview-surface-BcLeaSNe.js} +1 -1
  64. package/dist/gateway/static/root/assets/{gateway-config-swr-D6cc6W6E.js → gateway-config-swr-Cq-ByXL4.js} +1 -1
  65. package/dist/gateway/static/root/assets/{gateway-realtime-BSRNLciy.js → gateway-realtime-DwMd2PCt.js} +1 -1
  66. package/dist/gateway/static/root/assets/gateway-realtime-store-CHrf6-nR.js +1 -0
  67. package/dist/gateway/static/root/assets/{gateway-restart-Unun5hRL.js → gateway-restart-DdiVzbkL.js} +1 -1
  68. package/dist/gateway/static/root/assets/{gateway-settings-DP-DV-e5.js → gateway-settings-1QUdNwrZ.js} +1 -1
  69. package/dist/gateway/static/root/assets/{gateway-startup-retry-C8g666Ja.js → gateway-startup-retry-PMJi5mX4.js} +1 -1
  70. package/dist/gateway/static/root/assets/{global-defaults-api-BObi-1ww.js → global-defaults-api-DgzZh3wX.js} +1 -1
  71. package/dist/gateway/static/root/assets/{home-page-CIcs7Mzy.js → home-page-Chn7YTiD.js} +2 -2
  72. package/dist/gateway/static/root/assets/{image-generation-api-C2SqYNyD.js → image-generation-api-CjVpsckq.js} +1 -1
  73. package/dist/gateway/static/root/assets/{imports-page-C8ezUkOJ.js → imports-page-CJCvZFaQ.js} +1 -1
  74. package/dist/gateway/static/root/assets/index-8xLWo0Tt.js +11 -0
  75. package/dist/gateway/static/root/assets/index-iukJWzxG.css +1 -0
  76. package/dist/gateway/static/root/assets/install-connector-dialog-Bo06Ry3H.js +1 -0
  77. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BRaY4-wA.js → keyboard-shortcuts-settings-BylFJeGu.js} +1 -1
  78. package/dist/gateway/static/root/assets/{local-app-workbench-page-BZtVcjF3.js → local-app-workbench-page-B3MSSFsr.js} +1 -1
  79. package/dist/gateway/static/root/assets/{local-apps-page-MqP4EnJm.js → local-apps-page-BeV86rMJ.js} +1 -1
  80. package/dist/gateway/static/root/assets/{local-session-drafts-DTq9776a.js → local-session-drafts-jgw8UGsO.js} +2 -2
  81. package/dist/gateway/static/root/assets/{locale-store-B6OrWgY1.js → locale-store-CAZaC05J.js} +1 -1
  82. package/dist/gateway/static/root/assets/{logs-page-hkHBjblX.js → logs-page-BMmSsUP5.js} +1 -1
  83. package/dist/gateway/static/root/assets/{management-settings-DoX4eTM3.js → management-settings-Bu7T8ewk.js} +1 -1
  84. package/dist/gateway/static/root/assets/{markdown-view-DrhYZSmg.js → markdown-view-BatP4qeK.js} +1 -1
  85. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-BEp5E6TD.js → mcp-conversation-setup-page-rROtr0UN.js} +1 -1
  86. package/dist/gateway/static/root/assets/{media-plugins-D987i9Gc.js → media-plugins-88OV72YE.js} +1 -1
  87. package/dist/gateway/static/root/assets/messages-C7fckbyG.js +3 -0
  88. package/dist/gateway/static/root/assets/{model-selector-DXm4NS1_.js → model-selector-raBRBkN_.js} +1 -1
  89. package/dist/gateway/static/root/assets/{models-hub-cache-BLcha5rx.js → models-hub-cache-CzC9y3D0.js} +1 -1
  90. package/dist/gateway/static/root/assets/{note-detail-panel-Cl851ivY.js → note-detail-panel-BvA8Vkbm.js} +3 -3
  91. package/dist/gateway/static/root/assets/note-image-lightbox-D6kUDDd5.js +1 -0
  92. package/dist/gateway/static/root/assets/{notes-api-Ddsf7FVg.js → notes-api-zXpV6UXu.js} +1 -1
  93. package/dist/gateway/static/root/assets/{notes-page-DSwA1MU1.js → notes-page-CjYH9Kle.js} +1 -1
  94. package/dist/gateway/static/root/assets/{oauth-api-CMmu4DzH.js → oauth-api-DmxSaxM1.js} +1 -1
  95. package/dist/gateway/static/root/assets/{oauth-provider-connect-BkhnftBq.js → oauth-provider-connect-D4Gfs-Ba.js} +1 -1
  96. package/dist/gateway/static/root/assets/{page-context-capture-button-urhQBRaN.js → page-context-capture-button-Mig3d0UX.js} +1 -1
  97. package/dist/gateway/static/root/assets/{page-context-draft-BuNUerth.js → page-context-draft-C4IIZaKd.js} +1 -1
  98. package/dist/gateway/static/root/assets/page-header-store-D7G5utVi.js +1 -0
  99. package/dist/gateway/static/root/assets/{personal-avatar-B49ueeZO.js → personal-avatar-DLa-CpaK.js} +1 -1
  100. package/dist/gateway/static/root/assets/{personal-page-f05ceuFn.js → personal-page-BhuT79Wd.js} +1 -1
  101. package/dist/gateway/static/root/assets/{personal-settings-panel-DLQxzPYr.js → personal-settings-panel-XSUkgcr2.js} +1 -1
  102. package/dist/gateway/static/root/assets/phone-dependencies-card-DYwnuVh3.js +1 -0
  103. package/dist/gateway/static/root/assets/phone-model-connection-2F32QTHA.js +1 -0
  104. package/dist/gateway/static/root/assets/phone-model-picker-DCVzIr0s.js +1 -0
  105. package/dist/gateway/static/root/assets/phone-settings-page-DJttE4id.js +1 -0
  106. package/dist/gateway/static/root/assets/{phone-workspace-store-DbqktZbO.js → phone-workspace-store-Dxp-KhFP.js} +1 -1
  107. package/dist/gateway/static/root/assets/plugin-details-dialog-tyjAjFjA.js +1 -0
  108. package/dist/gateway/static/root/assets/{preference-select-fields-BZWqG7pu.js → preference-select-fields-BVP3MhGK.js} +1 -1
  109. package/dist/gateway/static/root/assets/{product-automation-feedback-DDQUsag7.js → product-automation-feedback-DbJvv92z.js} +1 -1
  110. package/dist/gateway/static/root/assets/{product-open-page-BkRP_HmA.js → product-open-page-RImqlhCD.js} +1 -1
  111. package/dist/gateway/static/root/assets/{product-preview-content-o2Y3VNE7.js → product-preview-content-DxSqrKsg.js} +1 -1
  112. package/dist/gateway/static/root/assets/{product-preview-modal-7Ohx-7OR.js → product-preview-modal-Cw8Q8Uom.js} +2 -2
  113. package/dist/gateway/static/root/assets/{project-detail-page-B2RsSHya.js → project-detail-page-CuugOYfe.js} +1 -1
  114. package/dist/gateway/static/root/assets/{project-understanding-BIMouiYX.js → project-understanding-BMKcoUW5.js} +1 -1
  115. package/dist/gateway/static/root/assets/{projects-page-C9R5u3tF.js → projects-page-CFsABLvs.js} +1 -1
  116. package/dist/gateway/static/root/assets/{providers-api-BOCkRZ7X.js → providers-api-CAeXbJNF.js} +1 -1
  117. package/dist/gateway/static/root/assets/{recording-upload-C6muEHEO.js → recording-upload-CfpllTe5.js} +1 -1
  118. package/dist/gateway/static/root/assets/{registry-api-Bl2guMRg.js → registry-api-fLOqFyrz.js} +1 -1
  119. package/dist/gateway/static/root/assets/{remote-access-hub-BceSMbCs.js → remote-access-hub-BvKOxy0L.js} +1 -1
  120. package/dist/gateway/static/root/assets/{resource-unavailable-CUNbPkdj.js → resource-unavailable-D15jzjV_.js} +1 -1
  121. package/dist/gateway/static/root/assets/route-preload-BQapekpy.js +2 -0
  122. package/dist/gateway/static/root/assets/{runtime-tools-api-LopLjgvu.js → runtime-tools-api-D0Nrvuqv.js} +1 -1
  123. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-9HIPerDP.js → runtime-tools-settings-panel-CA27XgL2.js} +1 -1
  124. package/dist/gateway/static/root/assets/{service-recommendation-list-CoMI6MB1.js → service-recommendation-list-B0RoYLVT.js} +1 -1
  125. package/dist/gateway/static/root/assets/session-api-CHRP5Lwf.js +1 -0
  126. package/dist/gateway/static/root/assets/session-channel-icon-D1ktvt1P.js +1 -0
  127. package/dist/gateway/static/root/assets/session-identity-label-BP7OIYth.js +1 -0
  128. package/dist/gateway/static/root/assets/session-manager-DRRWwKE4.js +25 -0
  129. package/dist/gateway/static/root/assets/{sessions-page-BT0GdXdS.js → sessions-page-uJHS3-6F.js} +1 -1
  130. package/dist/gateway/static/root/assets/settings-advanced-gate-CZ4J3Kuy.js +1 -0
  131. package/dist/gateway/static/root/assets/{settings-advanced-section-CEorDLUp.js → settings-advanced-section-D-llwfSj.js} +1 -1
  132. package/dist/gateway/static/root/assets/{settings-mode-store-C2LZqBES.js → settings-mode-store-BspMKc9N.js} +1 -1
  133. package/dist/gateway/static/root/assets/{settings-page-C_Np_6qZ.js → settings-page-CedwaHM0.js} +1 -1
  134. package/dist/gateway/static/root/assets/{settings-page-header-BAN34UQi.js → settings-page-header-LuOJvqNa.js} +1 -1
  135. package/dist/gateway/static/root/assets/{settings-page-layout-B5TVFBV2.js → settings-page-layout-CduQ8w4a.js} +1 -1
  136. package/dist/gateway/static/root/assets/{setup-interaction-page-BYvTJW3_.js → setup-interaction-page-ujpPGl84.js} +1 -1
  137. package/dist/gateway/static/root/assets/{setup-status-panel-UY2dH-sK.js → setup-status-panel-BN2aCJUN.js} +1 -1
  138. package/dist/gateway/static/root/assets/{share-link-dialog-BMcXyzr2.js → share-link-dialog-CTATUaa4.js} +1 -1
  139. package/dist/gateway/static/root/assets/{share-preview-page-UQ6eUM2_.js → share-preview-page-Dq0J3VgS.js} +1 -1
  140. package/dist/gateway/static/root/assets/{shares-api-DOeDN6Tm.js → shares-api-zegE8pSE.js} +1 -1
  141. package/dist/gateway/static/root/assets/{shares-settings-W8XhuAoL.js → shares-settings-DXpvsRXq.js} +1 -1
  142. package/dist/gateway/static/root/assets/{skill-api-Do_c0d9n.js → skill-api-DCL1EN7f.js} +1 -1
  143. package/dist/gateway/static/root/assets/{skill-list-api-DpHaXI2l.js → skill-list-api-Bv0mmHbu.js} +1 -1
  144. package/dist/gateway/static/root/assets/{skill-reload-api-DDRd9IJ2.js → skill-reload-api-DPZbadiO.js} +1 -1
  145. package/dist/gateway/static/root/assets/{skills-page-CaeJVKhO.js → skills-page-DMC7Gaku.js} +1 -1
  146. package/dist/gateway/static/root/assets/{system-settings-panel-DYWlWPJL.js → system-settings-panel-BYFUhlqG.js} +1 -1
  147. package/dist/gateway/static/root/assets/{task-detail-page-De0qD7xw.js → task-detail-page-_Og3plZL.js} +3 -3
  148. package/dist/gateway/static/root/assets/{task-result-evidence-CICR5K1t.js → task-result-evidence-Bxm8-H0B.js} +1 -1
  149. package/dist/gateway/static/root/assets/{terminal-panel-store-BbWUcQe7.js → terminal-panel-store-Djf9l2qZ.js} +1 -1
  150. package/dist/gateway/static/root/assets/{theme-store-TkG5mo0p.js → theme-store-8GFVtotZ.js} +1 -1
  151. package/dist/gateway/static/root/assets/{tracing-settings-page-CYXEy4EG.js → tracing-settings-page-oWW3SBZ4.js} +1 -1
  152. package/dist/gateway/static/root/assets/{tunnel-api-DquDm6U2.js → tunnel-api-D-mEsSGF.js} +1 -1
  153. package/dist/gateway/static/root/assets/{understanding-activity-store-Ot3wZ3oQ.js → understanding-activity-store-CvDjsd0I.js} +1 -1
  154. package/dist/gateway/static/root/assets/{understanding-refresh-store-C5KYFMaC.js → understanding-refresh-store-DzOZJm7A.js} +1 -1
  155. package/dist/gateway/static/root/assets/{usage-page-1xFO4smo.js → usage-page-z-o6Uuev.js} +1 -1
  156. package/dist/gateway/static/root/assets/{use-autosave-HL8XRNR8.js → use-autosave-BVYS8UoK.js} +1 -1
  157. package/dist/gateway/static/root/assets/{use-composer-attachments-XRlQBdNF.js → use-composer-attachments-lecOV2q5.js} +1 -1
  158. package/dist/gateway/static/root/assets/{use-file-preview-expanded-CW956CXS.js → use-file-preview-expanded-nd_CuFsd.js} +2 -2
  159. package/dist/gateway/static/root/assets/{use-personal-profile-202s6tJt.js → use-personal-profile-CQi2ZCxV.js} +1 -1
  160. package/dist/gateway/static/root/assets/{use-workspace-tree-CjydkmH1.js → use-workspace-tree-BiaddkzX.js} +1 -1
  161. package/dist/gateway/static/root/assets/{user-model-page-OGPXx3pe.js → user-model-page-Bks1n0Nj.js} +1 -1
  162. package/dist/gateway/static/root/assets/{voice-api-key-field-CxFu4MEA.js → voice-api-key-field-BbW8NFeZ.js} +1 -1
  163. package/dist/gateway/static/root/assets/{voice-config-api-MHe5Pn-A.js → voice-config-api-jSMzZWWy.js} +1 -1
  164. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-B9xc1oK8.js → voice-input-shortcut-events-_SgYmx7X.js} +1 -1
  165. package/dist/gateway/static/root/assets/{voice-transcribe-api-CVEcB6Pe.js → voice-transcribe-api-BJCfiRFU.js} +1 -1
  166. package/dist/gateway/static/root/assets/{work-discovery-overlay-C-JoAg2D.js → work-discovery-overlay-DSTSNyU7.js} +1 -1
  167. package/dist/gateway/static/root/assets/{work-discovery-page-B5Kx29Ru.js → work-discovery-page-Dd_QJJvb.js} +1 -1
  168. package/dist/gateway/static/root/assets/{working-directory-picker-modal-DGp9cNzH.js → working-directory-picker-modal-q39BUcJ6.js} +1 -1
  169. package/dist/gateway/static/root/assets/{workspace-api-HBXn8pL9.js → workspace-api-Di2OmCvz.js} +2 -2
  170. package/dist/gateway/static/root/assets/workspace-editor-agent-store-B2r9wlix.js +1 -0
  171. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-3cpwSG2w.js → workspace-file-preview-dialog-BUGNT765.js} +1 -1
  172. package/dist/gateway/static/root/assets/{workspace-open-location-menu-D0VOFvuP.js → workspace-open-location-menu-bMSvmQW7.js} +1 -1
  173. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-BkdW2p3v.js → xopc-cloud-account-card-Bbe19Del.js} +1 -1
  174. package/dist/gateway/static/root/index.html +87 -85
  175. package/dist/package.js +1 -1
  176. package/dist/packages/computer-control-contract/src/index.js +33 -3
  177. package/dist/packages/gateway-contract/src/session-identity.js +2 -1
  178. package/dist/packages/gateway-contract/src/session-input-command.js +19 -2
  179. package/dist/packages/gateway-contract/src/specialists.js +1 -0
  180. package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -1
  181. package/dist/src/agent/embedded/execution-tool-policy.js +2 -2
  182. package/dist/src/agent/embedded/run-for-session.js +23 -8
  183. package/dist/src/agent/embedded/run-turn.js +30 -7
  184. package/dist/src/agent/embedded/runs.d.ts +2 -2
  185. package/dist/src/agent/embedded/runs.js +4 -4
  186. package/dist/src/agent/embedded/session-runner.js +26 -11
  187. package/dist/src/agent/embedded/tool-search-extension.d.ts +8 -2
  188. package/dist/src/agent/embedded/tool-search-extension.js +122 -30
  189. package/dist/src/agent/external-tools/cliProvider.d.ts +10 -9
  190. package/dist/src/agent/external-tools/cliProvider.js +24 -4
  191. package/dist/src/agent/external-tools/composio-provider.d.ts +3 -3
  192. package/dist/src/agent/external-tools/composio-provider.js +6 -3
  193. package/dist/src/agent/external-tools/discovery.d.ts +47 -0
  194. package/dist/src/agent/external-tools/discovery.js +56 -0
  195. package/dist/src/agent/external-tools/gateway-tools.js +26 -46
  196. package/dist/src/agent/external-tools/index.d.ts +1 -0
  197. package/dist/src/agent/external-tools/index.js +7 -0
  198. package/dist/src/agent/external-tools/personal-request-scope.d.ts +7 -0
  199. package/dist/src/agent/external-tools/personal-request-scope.js +83 -0
  200. package/dist/src/agent/external-tools/read-policy.js +5 -4
  201. package/dist/src/agent/external-tools/service.d.ts +2 -0
  202. package/dist/src/agent/external-tools/service.js +22 -3
  203. package/dist/src/agent/external-tools/tool-registry.d.ts +6 -0
  204. package/dist/src/agent/external-tools/types.d.ts +7 -2
  205. package/dist/src/agent/inbound/turn-dispatcher.d.ts +1 -1
  206. package/dist/src/agent/inbound/turn-dispatcher.js +3 -2
  207. package/dist/src/agent/orchestration/llm-turn-retry.d.ts +1 -1
  208. package/dist/src/agent/orchestration/llm-turn-retry.js +13 -8
  209. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.d.ts +1 -0
  210. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +3 -1
  211. package/dist/src/agent/prompt/sections/tooling.js +1 -1
  212. package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
  213. package/dist/src/agent/tool-manuals/computer.js +6 -4
  214. package/dist/src/agent/tool-manuals/phone.d.ts +1 -1
  215. package/dist/src/agent/tool-manuals/phone.js +4 -4
  216. package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +1 -1
  217. package/dist/src/agent/tool-manuals/xopc-configuration.js +4 -2
  218. package/dist/src/agent/tools/computer-use-tool.js +7 -6
  219. package/dist/src/agent/tools/delegation-policy.js +1 -0
  220. package/dist/src/agent/tools/factory.js +4 -2
  221. package/dist/src/agent/tools/phone-use-tool.js +2 -2
  222. package/dist/src/agent/tools/web.js +22 -3
  223. package/dist/src/agent-matching/service.js +2 -2
  224. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  225. package/dist/src/computer/batch.d.ts +108 -0
  226. package/dist/src/computer/batch.js +125 -0
  227. package/dist/src/computer/broker.d.ts +30 -2
  228. package/dist/src/computer/broker.js +109 -17
  229. package/dist/src/computer/diagnostics.d.ts +5 -1
  230. package/dist/src/computer/diagnostics.js +22 -3
  231. package/dist/src/computer/errors.d.ts +15 -0
  232. package/dist/src/computer/errors.js +59 -3
  233. package/dist/src/computer/model-adapter.d.ts +58 -0
  234. package/dist/src/computer/model-adapter.js +112 -66
  235. package/dist/src/computer/native-errors.d.ts +2 -0
  236. package/dist/src/computer/native-errors.js +13 -0
  237. package/dist/src/computer/program-runtime.d.ts +1 -1
  238. package/dist/src/computer/program-runtime.js +1 -0
  239. package/dist/src/computer/runtime.d.ts +11 -0
  240. package/dist/src/computer/runtime.js +102 -34
  241. package/dist/src/computer/semantic-actions.js +4 -0
  242. package/dist/src/config/schema.d.ts +6 -0
  243. package/dist/src/extensions/agent-plugins/formats.js +2 -1
  244. package/dist/src/extensions/agent-plugins/inventory.d.ts +2 -0
  245. package/dist/src/extensions/agent-plugins/inventory.js +4 -1
  246. package/dist/src/extensions/agent-plugins/validation.d.ts +1 -0
  247. package/dist/src/extensions/agent-plugins/validation.js +2 -1
  248. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  249. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  250. package/dist/src/gateway/hono/routes/phone-dependencies.js +26 -5
  251. package/dist/src/gateway/hono/routes/phone-setup.js +42 -16
  252. package/dist/src/gateway/hono/routes/phone.js +22 -7
  253. package/dist/src/gateway/hono/routes/session-command-handler.js +9 -0
  254. package/dist/src/gateway/hono/routes/session-input-control.d.ts +3 -0
  255. package/dist/src/gateway/hono/routes/session-input-control.js +37 -0
  256. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +12 -0
  257. package/dist/src/gateway/hono/routes/session-input-handler.js +22 -0
  258. package/dist/src/gateway/hono/routes/sessions.js +4 -0
  259. package/dist/src/gateway/service/agent-runner.js +5 -4
  260. package/dist/src/gateway/service/config-coordinator.d.ts +6 -0
  261. package/dist/src/gateway/service/session-input-coordinator.d.ts +6 -3
  262. package/dist/src/gateway/service/session-input-coordinator.js +47 -6
  263. package/dist/src/gateway/service.d.ts +1 -0
  264. package/dist/src/gateway/service.js +8 -5
  265. package/dist/src/home-intelligence/host.js +2 -2
  266. package/dist/src/personal-agent/capability-service.js +1 -1
  267. package/dist/src/personal-agent/request-access.d.ts +2 -0
  268. package/dist/src/personal-agent/request-access.js +22 -2
  269. package/dist/src/personal-agent/request-service.js +2 -2
  270. package/dist/src/personal-agent/specialist-capabilities.d.ts +2 -0
  271. package/dist/src/personal-agent/specialist-capabilities.js +9 -3
  272. package/dist/src/phone/adb-driver.d.ts +3 -0
  273. package/dist/src/phone/adb-driver.js +29 -0
  274. package/dist/src/phone/contracts.d.ts +14 -2
  275. package/dist/src/phone/contracts.js +8 -1
  276. package/dist/src/phone/gui-protocol.js +1 -1
  277. package/dist/src/phone/hdc-driver.d.ts +30 -0
  278. package/dist/src/phone/hdc-driver.js +331 -0
  279. package/dist/src/phone/hdc-video-bridge.d.ts +2 -0
  280. package/dist/src/phone/hdc-video-bridge.js +91 -0
  281. package/dist/src/phone/hdc-video-tools.d.ts +15 -0
  282. package/dist/src/phone/hdc-video-tools.js +123 -0
  283. package/dist/src/phone/hdc-video.d.ts +69 -0
  284. package/dist/src/phone/hdc-video.js +350 -0
  285. package/dist/src/phone/interactive-session.js +1 -1
  286. package/dist/src/phone/live-provider.d.ts +6 -0
  287. package/dist/src/phone/live-provider.js +1 -0
  288. package/dist/src/phone/model-adapter.d.ts +3 -0
  289. package/dist/src/phone/model-adapter.js +5 -3
  290. package/dist/src/phone/repository.js +2 -1
  291. package/dist/src/phone/runtime.d.ts +10 -4
  292. package/dist/src/phone/runtime.js +151 -85
  293. package/dist/src/phone/setup/service.d.ts +8 -6
  294. package/dist/src/phone/setup/service.js +33 -16
  295. package/dist/src/platform/client.d.ts +1 -1
  296. package/dist/src/platform/contracts.d.ts +1 -1
  297. package/dist/src/process/phone-process.d.ts +1 -1
  298. package/dist/src/process/phone-process.js +2 -2
  299. package/dist/src/runtime-tools/downloader.d.ts +1 -0
  300. package/dist/src/runtime-tools/downloader.js +8 -4
  301. package/dist/src/runtime-tools/harmony-dependencies.d.ts +24 -0
  302. package/dist/src/runtime-tools/harmony-dependencies.js +272 -0
  303. package/dist/src/runtime-tools/harmony-dependency-catalog.d.ts +4 -0
  304. package/dist/src/runtime-tools/harmony-dependency-catalog.js +54 -0
  305. package/dist/src/runtime-tools/harmony-paths.d.ts +9 -0
  306. package/dist/src/runtime-tools/harmony-paths.js +15 -0
  307. package/dist/src/runtime-tools/hdc-dependency-catalog.d.ts +8 -0
  308. package/dist/src/runtime-tools/hdc-dependency-catalog.js +83 -0
  309. package/dist/src/runtime-tools/hdc-files.d.ts +14 -0
  310. package/dist/src/runtime-tools/hdc-files.js +87 -0
  311. package/dist/src/runtime-tools/phone-dependencies.d.ts +6 -1
  312. package/dist/src/runtime-tools/phone-dependencies.js +20 -2
  313. package/dist/src/runtime-tools/phone-dependency-catalog.d.ts +10 -1
  314. package/dist/src/runtime-tools/phone-dependency-catalog.js +2 -0
  315. package/dist/src/runtime-tools/types.d.ts +1 -1
  316. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  317. package/dist/src/storage/sqlite/schema.js +7 -7
  318. package/dist/src/storage/sqlite/schema.sql +16 -0
  319. package/dist/src/storage/sqlite/session-creation-repository.js +3 -0
  320. package/dist/src/storage/sqlite/session-input-control-repository.d.ts +12 -0
  321. package/dist/src/storage/sqlite/session-input-control-repository.js +83 -0
  322. package/dist/src/storage/sqlite/session-input-repository.d.ts +2 -0
  323. package/dist/src/storage/sqlite/session-input-repository.js +17 -5
  324. package/dist/src/storage/sqlite/session-repository.js +1 -0
  325. package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +2 -0
  326. package/dist/src/storage/sqlite/session-turn-replace-repository.js +14 -2
  327. package/dist/src/storage/sqlite/upgrades/262_session_input_control.sql +15 -0
  328. package/package.json +2 -2
  329. package/skills/tools/configure-xopc/SKILL.md +2 -2
  330. package/skills/tools/configure-xopc/references/phone/acceptance.md +3 -2
  331. package/skills/tools/configure-xopc/references/phone/dependencies.md +18 -2
  332. package/skills/tools/configure-xopc/references/phone/harmonyos.md +16 -0
  333. package/skills/tools/configure-xopc/references/phone/overview.md +2 -2
  334. package/skills/tools/configure-xopc/references/scene-index.md +2 -2
  335. package/dist/gateway/static/root/assets/apps-page-D-n71lO1.js +0 -1
  336. package/dist/gateway/static/root/assets/automations-workspace-DWDWy-SG.js +0 -9
  337. package/dist/gateway/static/root/assets/capabilities-page-IcwojmJK.js +0 -2
  338. package/dist/gateway/static/root/assets/capability-links-DzQWK1Fh.js +0 -1
  339. package/dist/gateway/static/root/assets/chat-page-CwP4OMdW.js +0 -72
  340. package/dist/gateway/static/root/assets/computer-settings-page-DyAlOzqY.js +0 -1
  341. package/dist/gateway/static/root/assets/connected-providers-grid-D0lXg22c.js +0 -1
  342. package/dist/gateway/static/root/assets/connectors-page-DI_Q0CKz.js +0 -1
  343. package/dist/gateway/static/root/assets/gateway-realtime-store-BFeFfApQ.js +0 -1
  344. package/dist/gateway/static/root/assets/index-Cz-VjTNd.css +0 -1
  345. package/dist/gateway/static/root/assets/index-D1_PUrJf.js +0 -11
  346. package/dist/gateway/static/root/assets/install-connector-dialog-Cn4nRSyt.js +0 -1
  347. package/dist/gateway/static/root/assets/list-tree-B0OMswgM.js +0 -1
  348. package/dist/gateway/static/root/assets/messages-jwdBhfL9.js +0 -3
  349. package/dist/gateway/static/root/assets/note-image-lightbox-DGYRJS03.js +0 -1
  350. package/dist/gateway/static/root/assets/page-header-store-CEn_kPsn.js +0 -1
  351. package/dist/gateway/static/root/assets/phone-dependencies-card-DjmC1Z5j.js +0 -1
  352. package/dist/gateway/static/root/assets/phone-model-connection-BRjHSgYn.js +0 -1
  353. package/dist/gateway/static/root/assets/phone-model-picker-DgIiWLhR.js +0 -1
  354. package/dist/gateway/static/root/assets/phone-settings-page-DCZGCL_z.js +0 -1
  355. package/dist/gateway/static/root/assets/plugin-details-dialog-D4tGKip4.js +0 -1
  356. package/dist/gateway/static/root/assets/route-preload-C1BKDjnu.js +0 -2
  357. package/dist/gateway/static/root/assets/session-api-Bfmlmn9F.js +0 -1
  358. package/dist/gateway/static/root/assets/session-channel-icon-SsY70Z6t.js +0 -1
  359. package/dist/gateway/static/root/assets/session-identity-label-B7sgG1PE.js +0 -1
  360. package/dist/gateway/static/root/assets/session-manager-X4UHOjjO.js +0 -25
  361. package/dist/gateway/static/root/assets/settings-advanced-gate-Dk9c-Z5e.js +0 -1
  362. package/dist/gateway/static/root/assets/workspace-editor-agent-store-msZa42fU.js +0 -1
@@ -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-CiwuuyV8.js";import{n as o}from"./locale-store-B6OrWgY1.js";import{t as s}from"./messages-jwdBhfL9.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist-BGTk37IG.js";import{t as g}from"./secret-input-Dryrns2s.js";import{t as _}from"./settings-uiTATseT.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./skeleton-BI5TyibZ.js";import{i as b}from"./vendor-swr-CdRzEUwF.js";import{t as x}from"./button-Cc4hUNTt.js";import{C as S,D as C,f as w,t as T}from"./connectors-api-DtvB9Cjm.js";import{t as E}from"./confirm-dialog-D7dQJytv.js";import{t as D}from"./oauth-provider-connect-BkhnftBq.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=o(N),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,c;e[2]===r.title?c=e[3]:(c=(0,j.jsx)(a,{to:`/capabilities/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=c);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]!==c||e[9]!==u?(p=(0,j.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[c,u,d,f]}),e[8]=c,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=o(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,g=a!==void 0&&a,y=o(L),b;t[2]===y?b=t[3]:(b=s(y),t[2]=y,t[3]=b);let S=b.connectorsSettings,C=y===`zh`,w;t[4]!==g||t[5]!==C?(w=g?null:(0,j.jsx)(l,{asChild:!0,children:(0,j.jsxs)(x,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":C?`应用连接服务`:`Connection service`,children:[(0,j.jsx)(_,{className:`size-4`,"aria-hidden":!0}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:C?`应用连接服务`:`Connection service`})]})}),t[4]=g,t[5]=C,t[6]=w):w=t[6];let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,j.jsx)(c,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[7]=T):T=t[7];let E=C?`应用连接服务`:`App connection service`,D;t[8]===E?D=t[9]:(D=(0,j.jsx)(m,{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)(u,{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)(v,{className:`size-5`,"aria-hidden":!0}),t[13]=M):M=t[13];let N;t[14]===S.modalClose?N=t[15]:(N=(0,j.jsx)(d,{asChild:!0,children:(0,j.jsx)(x,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":S.modalClose,children:M})}),t[14]=S.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)(f,{children:[T,(0,j.jsxs)(p,{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)(h,{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=o(e=>e.language),t=s(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=b(`connector-service`,w),[c,l]=(0,A.useState)(``),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(),[m,h]=(0,A.useState)();async function _(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)(y,{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)(D,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,j.jsx)(x,{variant:`secondary`,disabled:u||r.mode===`managed`&&r.configured,onClick:()=>void _(()=>C({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)(g,{value:c,onChange:l,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,j.jsx)(x,{disabled:u||!c.trim(),onClick:()=>void _(()=>T(c)),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)(x,{variant:`ghost`,disabled:u||!c.trim()||e.credentialSource===`environment`,onClick:()=>void _(()=>T(c,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,j.jsx)(x,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>void _(()=>C({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,j.jsx)(x,{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)(E,{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&&_(()=>S(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-CiwuuyV8.js";import{n as o}from"./locale-store-CAZaC05J.js";import{t as s}from"./messages-C7fckbyG.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist-BGTk37IG.js";import{t as g}from"./secret-input-Dryrns2s.js";import{t as _}from"./settings-uiTATseT.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./skeleton-BI5TyibZ.js";import{i as b}from"./vendor-swr-CdRzEUwF.js";import{t as x}from"./button-Cc4hUNTt.js";import{C as S,D as C,f as w,t as T}from"./connectors-api-NcWECWKg.js";import{t as E}from"./confirm-dialog-D7dQJytv.js";import{t as D}from"./oauth-provider-connect-D4Gfs-Ba.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=o(N),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,c;e[2]===r.title?c=e[3]:(c=(0,j.jsx)(a,{to:`/capabilities/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=c);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]!==c||e[9]!==u?(p=(0,j.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[c,u,d,f]}),e[8]=c,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=o(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,g=a!==void 0&&a,y=o(L),b;t[2]===y?b=t[3]:(b=s(y),t[2]=y,t[3]=b);let S=b.connectorsSettings,C=y===`zh`,w;t[4]!==g||t[5]!==C?(w=g?null:(0,j.jsx)(l,{asChild:!0,children:(0,j.jsxs)(x,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":C?`应用连接服务`:`Connection service`,children:[(0,j.jsx)(_,{className:`size-4`,"aria-hidden":!0}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:C?`应用连接服务`:`Connection service`})]})}),t[4]=g,t[5]=C,t[6]=w):w=t[6];let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,j.jsx)(c,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[7]=T):T=t[7];let E=C?`应用连接服务`:`App connection service`,D;t[8]===E?D=t[9]:(D=(0,j.jsx)(m,{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)(u,{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)(v,{className:`size-5`,"aria-hidden":!0}),t[13]=M):M=t[13];let N;t[14]===S.modalClose?N=t[15]:(N=(0,j.jsx)(d,{asChild:!0,children:(0,j.jsx)(x,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":S.modalClose,children:M})}),t[14]=S.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)(f,{children:[T,(0,j.jsxs)(p,{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)(h,{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=o(e=>e.language),t=s(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=b(`connector-service`,w),[c,l]=(0,A.useState)(``),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(),[m,h]=(0,A.useState)();async function _(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)(y,{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)(D,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,j.jsx)(x,{variant:`secondary`,disabled:u||r.mode===`managed`&&r.configured,onClick:()=>void _(()=>C({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)(g,{value:c,onChange:l,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,j.jsx)(x,{disabled:u||!c.trim(),onClick:()=>void _(()=>T(c)),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)(x,{variant:`ghost`,disabled:u||!c.trim()||e.credentialSource===`environment`,onClick:()=>void _(()=>T(c,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,j.jsx)(x,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>void _(()=>C({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,j.jsx)(x,{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)(E,{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&&_(()=>S(e))}})]})}export{O as n,I as t};
@@ -1 +1 @@
1
- import{i as e,o as t}from"./locale-store-B6OrWgY1.js";import{n}from"./gateway-config-swr-D6cc6W6E.js";function r(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function i(){return r(await t(e(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function a(n){let i=new URLSearchParams;return n?.q?.trim()&&i.set(`q`,n.q.trim()),n?.page&&i.set(`page`,String(n.page)),n?.pageSize&&i.set(`pageSize`,String(n.pageSize)),n?.refresh&&i.set(`refresh`,`1`),n?.verification&&i.set(`verification`,n.verification),r(await t(e(`/api/connectors/composio/catalog${i.size?`?${i.toString()}`:``}`)),`Could not load Composio catalog.`)}async function o(n){let i=new URLSearchParams;return n?.q?.trim()&&i.set(`q`,n.q.trim()),n?.page&&i.set(`page`,String(n.page)),n?.pageSize&&i.set(`pageSize`,String(n.pageSize)),n?.category?.trim()&&i.set(`category`,n.category.trim()),n?.sort&&i.set(`sort`,n.sort),r(await t(e(`/api/capabilities/connectors${i.size?`?${i.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function s(n,i){return r(await t(e(`/api/capabilities/connectors/${encodeURIComponent(n)}/install-plan`),{method:`POST`,body:JSON.stringify({version:i})}),`Could not prepare connector installation.`).plan}async function c(i,a,o,s){let c=await t(e(`/api/capabilities/connectors/${encodeURIComponent(i)}/install`),{method:`POST`,body:JSON.stringify({...a,version:o,reviewHash:s})});return n(),r(c,`Could not install Store connector.`).instance}async function l(){return r(await t(e(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function u(n,i){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/auth/start`),{method:`POST`,body:JSON.stringify({accountId:i})}),`Could not start connector authorization.`).authorization}async function d(){return r(await t(e(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function f(n,i){r(await t(e(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:n,replaceBackendId:i})}),`Could not enable the connection service.`)}async function p(n){await t(e(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify(n)})}async function m(n){await t(e(`/api/connectors/composio/backends/${encodeURIComponent(n)}`),{method:`DELETE`})}async function h(n){await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}`),{method:`DELETE`})}async function g(i,a){let o=await t(e(`/api/connectors/${encodeURIComponent(i)}/install`),{method:`POST`,body:JSON.stringify(a)});return n(),r(o,`Could not install connector.`).instance}async function _(n,i){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/config`),{method:`POST`,body:JSON.stringify(i)}),`Could not update connector config.`).instance}async function v(r){await t(e(`/api/connectors/${encodeURIComponent(r)}`),{method:`DELETE`}),n()}async function y(n){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/test`),{method:`POST`}),`Connector test failed.`)}async function b(){return r(await t(e(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function x(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/auth-configs`)),`Could not load Composio auth configs.`).auth}async function S(e,t,n=12e4,r){let i=Date.now()+n,a=1500;for(;Date.now()<i;){if(r){let e=await C(r);if(e.status===`failed`)throw Error(`Authorization failed or a different account was authorized. The original account was not changed.`);if(e.status===`expired`)throw Error(`Authorization expired. Start a new connection.`);if(e.status!==`succeeded`){await new Promise(e=>window.setTimeout(e,a)),a=Math.min(5e3,a*1.5);continue}}let n=(await b().catch(()=>[])).find(n=>n.toolkit.toLowerCase()===e.toLowerCase()&&n.status===`active`&&(!t||n.providerConnectionId===t));if(n)return n;await new Promise(e=>window.setTimeout(e,2e3))}throw Error(`Connection authorization timed out.`)}async function C(n){return r(await t(e(`/api/connectors/composio/authorizations/${encodeURIComponent(n)}`)),`Could not check authorization.`).attempt}async function w(n,i){return r(await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update Composio connection.`).connection}async function T(n,r){await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}`),{method:`PATCH`,body:JSON.stringify(r)})}async function E(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/health`)),`Could not check Composio connector health.`).health}async function D(n){await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}/refresh`),{method:`POST`})}async function O(n){await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}`),{method:`DELETE`})}async function k(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/scope`)),`Could not load Composio scope.`).scope}async function A(i,a){let o=await t(e(`/api/connectors/composio/${encodeURIComponent(i)}/scope`),{method:`POST`,body:JSON.stringify({scope:a})});return n(),r(o,`Could not update Composio scope.`).scope}async function j(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/policy`)),`Could not load Composio policy.`)}async function M(n,i){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/policy`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update Composio policy.`).policy}async function N(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/tools`)),`Could not load Composio tools.`).tools}async function P(n=50){return r(await t(e(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(n))}`)),`Could not load Composio trigger events.`).events}async function F(n){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/learning`),{method:`POST`}),`Could not start learning from this connection.`).job}async function I(){return r(await t(e(`/api/connectors/learning`)),`Could not load connector learning jobs.`).jobs}async function L(n){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/sync-policy`)),`Could not load connector sync policy.`).policy}async function R(n,i){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/sync-policy`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update connector sync policy.`).policy}async function z(n){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/source-sync`),{method:`POST`}),`Could not sync connector source.`)}async function B(n=`pending`){return r(await t(e(`/api/connectors/approvals?status=${encodeURIComponent(n)}`)),`Could not load connector approvals.`).approvals}async function V(n,i){return r(await t(e(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:n,decision:i})}),`Could not update connector approval.`).approval}async function H(i,a){let o=await t(e(`/api/connectors/${encodeURIComponent(i)}/${a?`enable`:`disable`}`),{method:`POST`});return n(),r(o,`Could not update connector state.`).instance}export{F as A,m as C,p as D,O as E,w as F,M as I,_ as L,z as M,y as N,A as O,T as P,R,D as S,V as T,b as _,l as a,B as b,C as c,k as d,d as f,c as g,g as h,i,u as j,H as k,E as l,L as m,h as n,o,x as p,a as r,s,f as t,j as u,N as v,v as w,I as x,P as y,S as z};
1
+ import{i as e,o as t}from"./locale-store-CAZaC05J.js";import{n}from"./gateway-config-swr-Cq-ByXL4.js";function r(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function i(){return r(await t(e(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function a(n){let i=new URLSearchParams;return n?.q?.trim()&&i.set(`q`,n.q.trim()),n?.page&&i.set(`page`,String(n.page)),n?.pageSize&&i.set(`pageSize`,String(n.pageSize)),n?.refresh&&i.set(`refresh`,`1`),n?.verification&&i.set(`verification`,n.verification),r(await t(e(`/api/connectors/composio/catalog${i.size?`?${i.toString()}`:``}`)),`Could not load Composio catalog.`)}async function o(n){let i=new URLSearchParams;return n?.q?.trim()&&i.set(`q`,n.q.trim()),n?.page&&i.set(`page`,String(n.page)),n?.pageSize&&i.set(`pageSize`,String(n.pageSize)),n?.category?.trim()&&i.set(`category`,n.category.trim()),n?.sort&&i.set(`sort`,n.sort),r(await t(e(`/api/capabilities/connectors${i.size?`?${i.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function s(n,i){return r(await t(e(`/api/capabilities/connectors/${encodeURIComponent(n)}/install-plan`),{method:`POST`,body:JSON.stringify({version:i})}),`Could not prepare connector installation.`).plan}async function c(i,a,o,s){let c=await t(e(`/api/capabilities/connectors/${encodeURIComponent(i)}/install`),{method:`POST`,body:JSON.stringify({...a,version:o,reviewHash:s})});return n(),r(c,`Could not install Store connector.`).instance}async function l(){return r(await t(e(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function u(n,i){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/auth/start`),{method:`POST`,body:JSON.stringify({accountId:i})}),`Could not start connector authorization.`).authorization}async function d(){return r(await t(e(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function f(n,i){r(await t(e(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:n,replaceBackendId:i})}),`Could not enable the connection service.`)}async function p(n){await t(e(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify(n)})}async function m(n){await t(e(`/api/connectors/composio/backends/${encodeURIComponent(n)}`),{method:`DELETE`})}async function h(n){await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}`),{method:`DELETE`})}async function g(i,a){let o=await t(e(`/api/connectors/${encodeURIComponent(i)}/install`),{method:`POST`,body:JSON.stringify(a)});return n(),r(o,`Could not install connector.`).instance}async function _(n,i){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/config`),{method:`POST`,body:JSON.stringify(i)}),`Could not update connector config.`).instance}async function v(r){await t(e(`/api/connectors/${encodeURIComponent(r)}`),{method:`DELETE`}),n()}async function y(n){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/test`),{method:`POST`}),`Connector test failed.`)}async function b(){return r(await t(e(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function x(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/auth-configs`)),`Could not load Composio auth configs.`).auth}async function S(e,t,n=12e4,r){let i=Date.now()+n,a=1500;for(;Date.now()<i;){if(r){let e=await C(r);if(e.status===`failed`)throw Error(`Authorization failed or a different account was authorized. The original account was not changed.`);if(e.status===`expired`)throw Error(`Authorization expired. Start a new connection.`);if(e.status!==`succeeded`){await new Promise(e=>window.setTimeout(e,a)),a=Math.min(5e3,a*1.5);continue}}let n=(await b().catch(()=>[])).find(n=>n.toolkit.toLowerCase()===e.toLowerCase()&&n.status===`active`&&(!t||n.providerConnectionId===t));if(n)return n;await new Promise(e=>window.setTimeout(e,2e3))}throw Error(`Connection authorization timed out.`)}async function C(n){return r(await t(e(`/api/connectors/composio/authorizations/${encodeURIComponent(n)}`)),`Could not check authorization.`).attempt}async function w(n,i){return r(await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update Composio connection.`).connection}async function T(n,r){await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}`),{method:`PATCH`,body:JSON.stringify(r)})}async function E(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/health`)),`Could not check Composio connector health.`).health}async function D(n){await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}/refresh`),{method:`POST`})}async function O(n){await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}`),{method:`DELETE`})}async function k(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/scope`)),`Could not load Composio scope.`).scope}async function A(i,a){let o=await t(e(`/api/connectors/composio/${encodeURIComponent(i)}/scope`),{method:`POST`,body:JSON.stringify({scope:a})});return n(),r(o,`Could not update Composio scope.`).scope}async function j(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/policy`)),`Could not load Composio policy.`)}async function M(n,i){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/policy`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update Composio policy.`).policy}async function N(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/tools`)),`Could not load Composio tools.`).tools}async function P(n=50){return r(await t(e(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(n))}`)),`Could not load Composio trigger events.`).events}async function F(n){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/learning`),{method:`POST`}),`Could not start learning from this connection.`).job}async function I(){return r(await t(e(`/api/connectors/learning`)),`Could not load connector learning jobs.`).jobs}async function L(n){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/sync-policy`)),`Could not load connector sync policy.`).policy}async function R(n,i){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/sync-policy`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update connector sync policy.`).policy}async function z(n){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/source-sync`),{method:`POST`}),`Could not sync connector source.`)}async function B(n=`pending`){return r(await t(e(`/api/connectors/approvals?status=${encodeURIComponent(n)}`)),`Could not load connector approvals.`).approvals}async function V(n,i){return r(await t(e(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:n,decision:i})}),`Could not update connector approval.`).approval}async function H(i,a){let o=await t(e(`/api/connectors/${encodeURIComponent(i)}/${a?`enable`:`disable`}`),{method:`POST`});return n(),r(o,`Could not update connector state.`).instance}export{F as A,m as C,p as D,O as E,w as F,M as I,_ as L,z as M,y as N,A as O,T as P,R,D as S,V as T,b as _,l as a,B as b,C as c,k as d,d as f,c as g,g as h,i,u as j,H as k,E as l,L as m,h as n,o,x as p,a as r,s,f as t,j as u,N as v,v as w,I as x,P as y,S as z};
@@ -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{m as i,u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{l as o,n as s}from"./locale-store-CAZaC05J.js";import{t as c}from"./messages-C7fckbyG.js";import{a as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist-BGTk37IG.js";import{i as g,n as _,r as v,t as y}from"./service-recommendation-list-B0RoYLVT.js";import{t as b}from"./chevron-down-ccbiQQz_.js";import{t as x}from"./chevron-right-BweFrslA.js";import{n as S,r as C,t as w}from"./popover-select-CEMWIrtY.js";import{t as T}from"./circle-alert-BEjgurr2.js";import{t as E}from"./circle-check-C23XjkUj.js";import{t as D}from"./circle-pause-CN9jYH2s.js";import{a as O,i as k,n as A,r as j,t as M}from"./connector-filters-Cfcx9EA2.js";import{t as N}from"./clock-3-DnrAnuyZ.js";import{t as P}from"./database-CjjeZfRG.js";import{t as F}from"./ellipsis-0k4rZLoy.js";import{t as I}from"./external-link-DjqjBmc3.js";import{n as L}from"./secret-input-Dryrns2s.js";import{t as R}from"./eye-CABVeTq0.js";import{t as ee}from"./key-round-DWbpyU2U.js";import{t as z}from"./loader-circle-CifKLtgG.js";import{a as B,c as V,i as H,n as te,o as U,r as ne,s as re,t as ie}from"./install-connector-dialog-Bo06Ry3H.js";import{t as W}from"./plug-DKYPEgkR.js";import{t as G}from"./plus-Q2yW6OE7.js";import{t as K}from"./refresh-cw-BRlGaq2w.js";import{t as ae}from"./save-DRDABU--.js";import{t as oe}from"./server-BlHCBjiE.js";import{t as se}from"./settings-uiTATseT.js";import{t as q}from"./store-SzD1Jvgm.js";import{t as ce}from"./terminal-oKqqZdiG.js";import{t as le}from"./trash-2-DusmjVPV.js";import{t as J}from"./wrench-DFb4r8bH.js";import{t as ue}from"./x-B_N4OPjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as de}from"./skeleton-BI5TyibZ.js";import{r as fe}from"./extension-provider-NKWfjpdP.js";import{i as pe}from"./vendor-swr-CdRzEUwF.js";import{r as me}from"./gateway-config-swr-Cq-ByXL4.js";import{t as X}from"./button-Cc4hUNTt.js";import{n as he}from"./copy-to-clipboard-HOJ79TWv.js";import{n as Z}from"./interaction-BdhHBbYa.js";import{A as ge,E as _e,F as ve,I as ye,L as be,M as xe,N as Se,O as Ce,P as we,R as Te,S as Ee,_ as De,a as Oe,c as ke,d as Ae,i as je,j as Me,l as Ne,m as Pe,n as Fe,o as Ie,p as Le,r as Re,s as ze,u as Be,v as Ve,w as He,x as Ue,y as We,z as Ge}from"./connectors-api-NcWECWKg.js";import{s as Ke}from"./form-field-width-DJw_jULe.js";import{n as qe}from"./electron-env-DHOGevH3.js";import{t as Je}from"./page-tabs-oeTY7z3_.js";import{t as Ye}from"./page-header-store-D7G5utVi.js";import{t as Xe}from"./sliding-tab-list-DuQyViqe.js";import{t as Ze}from"./confirm-dialog-D7dQJytv.js";import{l as Qe,m as $e,o as et,r as tt,t as nt}from"./dist-ZrL34Ps4.js";import{C as rt,S as it,_ as at,a as ot,b as st,c as ct,d as lt,f as ut,g as dt,h as ft,i as pt,l as mt,m as ht,n as gt,o as _t,p as vt,r as yt,s as bt,t as xt,u as St,v as Ct,w as wt,x as Tt,y as Et}from"./connection-usage-guide-Ddh0bfkj.js";import{t as Dt}from"./capability-links-DeO34GIF.js";import{t as Ot}from"./capability-icon-DVoZxEgW.js";import{n as kt,t as At}from"./capability-header-actions-BxMYfQ8y.js";import{t as jt}from"./connector-service-page-C3msXaBk.js";import{t as Mt}from"./number-input-El7Szeln.js";var Q=e(t(),1),Nt=n(),$=r();function Pt(e){let t=(0,Nt.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,u,d,f;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(Ft),p=e.slice(0,2),m=Math.max(0,e.length-p.length),h=o.connect,g;t[11]!==n||t[12]!==o?(g=H(n,o),t[11]=n,t[12]=o,t[13]=g):g=t[13];let _=g,v=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,y;t[14]!==h||t[15]!==n||t[16]!==i?(y=e=>(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:Y(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(V,{className:`size-4`}),h]}),t[14]=h,t[15]=n,t[16]=i,t[17]=y):y=t[17],s=y,f=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let b;t[18]===n?b=t[19]:(b=(0,$.jsx)(te,{connector:n}),t[18]=n,t[19]=b);let x;t[20]!==n||t[21]!==a?(x=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]=x):x=t[22];let S;t[23]===v?S=t[24]:(S=v?(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:v}):null,t[23]=v,t[24]=S);let C;t[25]!==S||t[26]!==x?(C=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),t[25]=S,t[26]=x,t[27]=C):C=t[27];let w;t[28]!==C||t[29]!==b?(w=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,C]}),t[28]=C,t[29]=b,t[30]=w):w=t[30];let T;t[31]!==r||t[32]!==s?(T=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=T):T=t[33];let D;t[34]!==r||t[35]!==o.connectedBadge?(D=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)(E,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=D):D=t[36];let O;t[37]!==T||t[38]!==D?(O=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[T,D]}),t[37]=T,t[38]=D,t[39]=O):O=t[39],t[40]!==w||t[41]!==O?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[w,O]}),t[40]=w,t[41]=O,t[42]=l):l=t[42],t[43]===_?u=t[44]:(u=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:_,children:_}),t[43]=_,t[44]=u),d=p.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),m>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,m]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p;t[45]!==c||t[46]!==l||t[47]!==u||t[48]!==d?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u,d]}),t[45]=c,t[46]=l,t[47]=u,t[48]=d,t[49]=p):p=t[49];let m;t[50]!==r||t[51]!==s?(m=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=m):m=t[52];let h;return t[53]!==f||t[54]!==p||t[55]!==m?(h=(0,$.jsxs)(`div`,{className:f,children:[p,m]}),t[53]=f,t[54]=p,t[55]=m,t[56]=h):h=t[56],h}function Ft(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var It=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function Lt(e,t){return t.some(t=>t.connectorId===e.id)}var Rt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function zt(){let e=(0,Nt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:Y(`size-10 shrink-0 rounded-xl`,Rt)}),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:Y(`h-4 min-w-0 flex-1`,Rt)}),(0,$.jsx)(`div`,{className:Y(`h-8 w-[4.5rem] shrink-0 rounded-lg`,Rt)})]}),(0,$.jsx)(`div`,{className:Y(`h-3 w-full`,Rt)}),(0,$.jsx)(`div`,{className:Y(`h-3 w-[88%]`,Rt)})]})]})}),e[1]=n):n=e[1],n}function Bt(){let e=(0,Nt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(de,{className:`size-9 shrink-0 rounded-lg`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4`,"aria-hidden":!0,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(de,{className:`h-4 w-28 max-w-full`}),(0,$.jsx)(de,{className:`h-3 w-20 max-w-full`})]})]}),(0,$.jsx)(de,{className:`mt-2 h-3 w-48 max-w-full`}),(0,$.jsx)(de,{className:`ml-auto mt-auto h-3 w-16`})]}),e[1]=n):n=e[1],n}var Vt=[`understand`,`act`,`reach`];function Ht(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 Ut(e){return Ht(e)[0]??`act`}function Wt(e,t){let n=t?Ut(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 Kt(e,t){if(e.runtime.type===`mcp`)return B(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 B(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function qt(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Jt(e){let t=(0,Nt.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:o}=e,s;t[0]!==n||t[1]!==o?(s=H(n,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,g,_,v,y,b,x,S,C,w,T,D,O,k,A,j,M;if(t[3]!==n||t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==o){let e=Ht(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(Zt),...(n.setup.config??[]).filter(Xt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let s=a,N=n.capabilities.filter(Yt);v=h,S=!0,t[27]===i?C=t[28]:(C=e=>{e||i()},t[27]=i,t[28]=C),_=f,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=x):x=t[29],g=p,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(y=Y(`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]=y):y=t[30];let P;t[31]===n?P=t[32]:(P=(0,$.jsx)(te,{connector:n,size:`lg`}),t[31]=n,t[32]=P);let F;t[33]===n.displayName?F=t[34]:(F=(0,$.jsx)(m,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=F);let I;t[35]!==r||t[36]!==o.connectedBadge?(I=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)(E,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[35]=r,t[36]=o.connectedBadge,t[37]=I):I=t[37];let L;t[38]!==F||t[39]!==I?(L=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[F,I]}),t[38]=F,t[39]=I,t[40]=L):L=t[40];let R;t[41]===c?R=t[42]:(R=(0,$.jsx)(u,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:c}),t[41]=c,t[42]=R);let z;t[43]!==L||t[44]!==R?(z=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[L,R]}),t[43]=L,t[44]=R,t[45]=z):z=t[45];let V;t[46]!==P||t[47]!==z?(V=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[P,z]}),t[46]=P,t[47]=z,t[48]=V):V=t[48];let H;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(H=Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Z.focusRingPanel),t[49]=H):H=t[49];let U;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(ue,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=U):U=t[50];let ne;t[51]===o.modalClose?ne=t[52]:(ne=(0,$.jsx)(d,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:H,"aria-label":o.modalClose,children:U})}),t[51]=o.modalClose,t[52]=ne),t[53]!==V||t[54]!==ne?(b=(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:[V,ne]}),t[53]=V,t[54]=ne,t[55]=b):b=t[55],A=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,j=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.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:o.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.connectorBenefitHints[e]})]},e))})]}):null;let re;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(ee,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=re):re=t[56];let ie;t[57]===o.detailPermissions?ie=t[58]:(ie=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.detailPermissions}),t[57]=o.detailPermissions,t[58]=ie);let W;t[59]!==n||t[60]!==o?(W=qt(n,o),t[59]=n,t[60]=o,t[61]=W):W=t[61];let G;t[62]===W?G=t[63]:(G=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:W}),t[62]=W,t[63]=G);let K;t[64]!==ie||t[65]!==G?(K=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[re,(0,$.jsxs)(`div`,{children:[ie,G]})]}),t[64]=ie,t[65]=G,t[66]=K):K=t[66];let ae;t[67]===o.connectorSetupTitle?ae=t[68]:(ae=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorSetupTitle}),t[67]=o.connectorSetupTitle,t[68]=ae);let se;t[69]!==s.length||t[70]!==o.connectorRequiredInputsCount||t[71]!==o.connectorSetupNone?(se=s.length?B(o.connectorRequiredInputsCount,{count:String(s.length)}):o.connectorSetupNone,t[69]=s.length,t[70]=o.connectorRequiredInputsCount,t[71]=o.connectorSetupNone,t[72]=se):se=t[72];let q;t[73]===se?q=t[74]:(q=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:se}),t[73]=se,t[74]=q);let ce;t[75]!==ae||t[76]!==q?(ce=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[ae,q]}),t[75]=ae,t[76]=q,t[77]=ce):ce=t[77],t[78]!==K||t[79]!==ce?(M=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[K,ce]}),t[78]=K,t[79]=ce,t[80]=M):M=t[80],O=`rounded-xl border border-edge bg-surface-base`,t[81]===o.connectorTechnicalDetails?k=t[82]:(k=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:o.connectorTechnicalDetails}),t[81]=o.connectorTechnicalDetails,t[82]=k),w=`space-y-5 border-t border-edge-subtle px-4 py-4`;let le;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),t[83]=le):le=t[83];let J;t[84]===o.connectorRuntimeTitle?J=t[85]:(J=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[le,o.connectorRuntimeTitle]}),t[84]=o.connectorRuntimeTitle,t[85]=J);let de;t[86]!==n||t[87]!==o?(de=Kt(n,o),t[86]=n,t[87]=o,t[88]=de):de=t[88];let fe;t[89]===de?fe=t[90]:(fe=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:de}),t[89]=de,t[90]=fe),t[91]!==J||t[92]!==fe?(T=(0,$.jsxs)(`div`,{children:[J,fe]}),t[91]=J,t[92]=fe,t[93]=T):T=t[93],D=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,o)},e))}):null,t[3]=n,t[4]=c,t[5]=r,t[6]=i,t[7]=o,t[8]=g,t[9]=_,t[10]=v,t[11]=y,t[12]=b,t[13]=x,t[14]=S,t[15]=C,t[16]=w,t[17]=T,t[18]=D,t[19]=O,t[20]=k,t[21]=A,t[22]=j,t[23]=M}else g=t[8],_=t[9],v=t[10],y=t[11],b=t[12],x=t[13],S=t[14],C=t[15],w=t[16],T=t[17],D=t[18],O=t[19],k=t[20],A=t[21],j=t[22],M=t[23];let N;t[94]!==w||t[95]!==T||t[96]!==D?(N=(0,$.jsxs)(`div`,{className:w,children:[T,D]}),t[94]=w,t[95]=T,t[96]=D,t[97]=N):N=t[97];let P;t[98]!==N||t[99]!==O||t[100]!==k?(P=(0,$.jsxs)(`details`,{className:O,children:[k,N]}),t[98]=N,t[99]=O,t[100]=k,t[101]=P):P=t[101];let F;t[102]!==P||t[103]!==A||t[104]!==j||t[105]!==M?(F=(0,$.jsxs)(`div`,{className:A,children:[j,M,P]}),t[102]=P,t[103]=A,t[104]=j,t[105]=M,t[106]=F):F=t[106];let I;t[107]===o.modalClose?I=t[108]:(I=(0,$.jsx)(d,{asChild:!0,children:(0,$.jsx)(X,{variant:`secondary`,children:o.modalClose})}),t[107]=o.modalClose,t[108]=I);let L;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==o.connect?(L=r?null:(0,$.jsxs)(X,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(V,{className:`size-4`}),o.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=o.connect,t[114]=L):L=t[114];let R;t[115]!==I||t[116]!==L?(R=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[I,L]}),t[115]=I,t[116]=L,t[117]=R):R=t[117];let z;t[118]!==g||t[119]!==y||t[120]!==b||t[121]!==F||t[122]!==R?(z=(0,$.jsxs)(g,{className:y,children:[b,F,R]}),t[118]=g,t[119]=y,t[120]=b,t[121]=F,t[122]=R,t[123]=z):z=t[123];let U;t[124]!==_||t[125]!==x||t[126]!==z?(U=(0,$.jsxs)(_,{children:[x,z]}),t[124]=_,t[125]=x,t[126]=z,t[127]=U):U=t[127];let ne;return t[128]!==v||t[129]!==S||t[130]!==C||t[131]!==U?(ne=(0,$.jsx)(v,{open:S,onOpenChange:C,children:U}),t[128]=v,t[129]=S,t[130]=C,t[131]=U,t[132]=ne):ne=t[132],ne}function Yt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function Xt(e){return e.required}function Zt(e){return e.required}var Qt=(0,Q.memo)(function(e){let t=(0,Nt.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:s,browseLabel:c,customLabel:l,serviceLabel:u,moreActionsLabel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`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`,Z.transition),t[0]=m):m=t[0];let h=m,g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(G,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=g):g=t[1];let _;t[2]===s?_=t[3]:(_=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s}),t[2]=s,t[3]=_);let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(b,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=v):v=t[4];let y;t[5]!==s||t[6]!==_?(y=(0,$.jsx)($e,{asChild:!0,children:(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":s,children:[g,_,v]})}),t[5]=s,t[6]=_,t[7]=y):y=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(q,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=x):x=t[8];let S;t[9]!==c||t[10]!==a?(S=(0,$.jsxs)(tt,{className:h,onSelect:a,children:[x,c]}),t[9]=c,t[10]=a,t[11]=S):S=t[11];let C;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(J,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=C):C=t[12];let w;t[13]!==l||t[14]!==o?(w=(0,$.jsxs)(tt,{className:h,onSelect:o,children:[C,l]}),t[13]=l,t[14]=o,t[15]=w):w=t[15];let T;t[16]!==S||t[17]!==w?(T=(0,$.jsx)(et,{children:(0,$.jsxs)(nt,{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:[S,w]})}),t[16]=S,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==y?(E=(0,$.jsxs)(Qe,{children:[y,T]}),t[19]=T,t[20]=y,t[21]=E):E=t[21];let D;t[22]===f?D=t[23]:(D=(0,$.jsx)(jt,{open:f,onOpenChange:p,hideTrigger:!0}),t[22]=f,t[23]=D);let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(F,{className:`size-4`,"aria-hidden":!0}),t[24]=O):O=t[24];let k;t[25]===d?k=t[26]:(k=(0,$.jsx)($e,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":d,title:d,children:O})}),t[25]=d,t[26]=k);let A;t[27]!==n||t[28]!==i||t[29]!==r?(A=n?(0,$.jsxs)(tt,{className:h,disabled:r,onSelect:n,children:[r?(0,$.jsx)(z,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(K,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=A):A=t[30];let j,M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>p(!0),M=(0,$.jsx)(se,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=j,t[32]=M):(j=t[31],M=t[32]);let N;t[33]===u?N=t[34]:(N=(0,$.jsxs)(tt,{className:h,onSelect:j,children:[M,u]}),t[33]=u,t[34]=N);let P;t[35]!==A||t[36]!==N?(P=(0,$.jsx)(et,{children:(0,$.jsxs)(nt,{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:[A,N]})}),t[35]=A,t[36]=N,t[37]=P):P=t[37];let I;t[38]!==k||t[39]!==P?(I=(0,$.jsxs)(Qe,{children:[k,P]}),t[38]=k,t[39]=P,t[40]=I):I=t[40];let L;return t[41]!==E||t[42]!==D||t[43]!==I?(L=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[E,D,I]}),t[41]=E,t[42]=D,t[43]=I,t[44]=L):L=t[44],L});function $t(e){let t=(0,Nt.c)(114),{serverId:n,displayName:r,returnFocusTo:i,draftId:a,t:o,onClose:s,onConfigure:c}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[0]=g):g=t[0];let[_,v]=(0,Q.useState)(g),[y,b]=(0,Q.useState)(!0),[x,S]=(0,Q.useState)(``),[C,w]=(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 b(!0),S(``),v([]),(a?St(a,e.signal):lt(n,e.signal)).then(e=>{t&&v(e)}).catch(e=>{let n=e?.status;t&&S(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&b(!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,L,R,ee,z,B,V,H;if(t[14]!==r||t[15]!==a||t[16]!==x||t[17]!==y||t[18]!==s||t[19]!==c||t[20]!==C||t[21]!==i||t[22]!==n||t[23]!==o.exposureLabels||t[24]!==o.setupConfigure||t[25]!==o.toolDetails||t[26]!==o.toolsClearSearch||t[27]!==o.toolsDialogSearchEmpty||t[28]!==o.toolsDialogSearchPlaceholder||t[29]!==o.toolsDialogSubtitle||t[30]!==o.toolsDialogTitle||t[31]!==o.toolsEmpty||t[32]!==o.toolsLoading||t[33]!==o.toolsRetryHint||t[34]!==o.toolsSearchSummary||t[35]!==o.toolsTitle||t[36]!==_){let e=C.trim().toLowerCase(),d;if(t[51]!==n){let e;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[53]=e):e=t[53],d=n.replace(e,`_`),t[51]=n,t[52]=d}else d=t[52];let g=`mcp__${d}__`,v=_.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));M=h,I=!0,t[54]===s?L=t[55]:(L=e=>{e||s()},t[54]=s,t[55]=L),j=f,t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(l,{className:`fixed inset-0 z-[60] bg-scrim`}),t[56]=F):F=t[56],A=p,t[57]===i?H=t[58]:(H=e=>{(D.current||i)&&e.preventDefault(),!D.current&&i?.isConnected&&i.focus()},t[57]=i,t[58]=H),N=`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 b;t[59]===o.toolsDialogTitle?b=t[60]:(b=(0,$.jsx)(m,{className:`font-semibold`,children:o.toolsDialogTitle}),t[59]=o.toolsDialogTitle,t[60]=b);let S;t[61]!==r||t[62]!==x||t[63]!==y||t[64]!==n||t[65]!==o.toolsDialogSubtitle||t[66]!==_.length?(S=y||x?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(_.length)),t[61]=r,t[62]=x,t[63]=y,t[64]=n,t[65]=o.toolsDialogSubtitle,t[66]=_.length,t[67]=S):S=t[67];let T;t[68]===S?T=t[69]:(T=(0,$.jsx)(u,{className:`mt-1 break-words text-sm text-fg-muted`,children:S}),t[68]=S,t[69]=T);let E;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>w(e.target.value),t[70]=E):E=t[70];let O;t[71]!==C||t[72]!==o.toolsDialogSearchPlaceholder?(O=(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:C,onChange:E,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[71]=C,t[72]=o.toolsDialogSearchPlaceholder,t[73]=O):O=t[73];let k=e&&!y&&!x?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(v.length)).replace(`{{count}}`,String(_.length))}):null;t[74]!==b||t[75]!==T||t[76]!==O||t[77]!==k?(P=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[b,T,O,k]}),t[74]=b,t[75]=T,t[76]=O,t[77]=k,t[78]=P):P=t[78],R=`min-h-0 flex-1 overflow-y-auto p-5`,ee=y,t[79]!==o.toolsTitle||t[80]!==_.length?(z=o.toolsTitle.replace(`{{count}}`,String(_.length)),t[79]=o.toolsTitle,t[80]=_.length,t[81]=z):z=t[81],B=!y&&!x&&_.length&&!e?(0,$.jsx)(`div`,{className:`mb-5`,children:(0,$.jsx)(xt,{target:{kind:`mcp`,id:n,name:r||n},tools:_,preview:!!a,onStart:s})}):null,V=y?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(tn)}):x?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:x}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(X,{variant:`secondary`,onClick:()=>{D.current=!0,c()},children:o.setupConfigure}):null]}):v.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:v.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(g)?e.name.slice(g.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:_.length?o.toolsDialogSearchEmpty:o.toolsEmpty}),e?(0,$.jsx)(X,{variant:`secondary`,onClick:()=>w(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=a,t[16]=x,t[17]=y,t[18]=s,t[19]=c,t[20]=C,t[21]=i,t[22]=n,t[23]=o.exposureLabels,t[24]=o.setupConfigure,t[25]=o.toolDetails,t[26]=o.toolsClearSearch,t[27]=o.toolsDialogSearchEmpty,t[28]=o.toolsDialogSearchPlaceholder,t[29]=o.toolsDialogSubtitle,t[30]=o.toolsDialogTitle,t[31]=o.toolsEmpty,t[32]=o.toolsLoading,t[33]=o.toolsRetryHint,t[34]=o.toolsSearchSummary,t[35]=o.toolsTitle,t[36]=_,t[37]=A,t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=F,t[43]=I,t[44]=L,t[45]=R,t[46]=ee,t[47]=z,t[48]=B,t[49]=V,t[50]=H}else A=t[37],j=t[38],M=t[39],N=t[40],P=t[41],F=t[42],I=t[43],L=t[44],R=t[45],ee=t[46],z=t[47],B=t[48],V=t[49],H=t[50];let te;t[82]!==R||t[83]!==ee||t[84]!==z||t[85]!==B||t[86]!==V?(te=(0,$.jsxs)(`div`,{className:R,"aria-busy":ee,"aria-label":z,children:[B,V]}),t[82]=R,t[83]=ee,t[84]=z,t[85]=B,t[86]=V,t[87]=te):te=t[87];let U;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>E(en),t[88]=U):U=t[88];let ne;t[89]!==y||t[90]!==o.refreshTools?(ne=(0,$.jsx)(X,{variant:`secondary`,disabled:y,onClick:U,children:o.refreshTools}),t[89]=y,t[90]=o.refreshTools,t[91]=ne):ne=t[91];let re;t[92]!==s||t[93]!==o.toolsDialogClose?(re=(0,$.jsx)(d,{asChild:!0,children:(0,$.jsx)(X,{onClick:s,children:o.toolsDialogClose})}),t[92]=s,t[93]=o.toolsDialogClose,t[94]=re):re=t[94];let ie;t[95]!==ne||t[96]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[ne,re]}),t[95]=ne,t[96]=re,t[97]=ie):ie=t[97];let W;t[98]!==A||t[99]!==N||t[100]!==P||t[101]!==te||t[102]!==ie||t[103]!==H?(W=(0,$.jsxs)(A,{onCloseAutoFocus:H,className:N,children:[P,te,ie]}),t[98]=A,t[99]=N,t[100]=P,t[101]=te,t[102]=ie,t[103]=H,t[104]=W):W=t[104];let G;t[105]!==j||t[106]!==F||t[107]!==W?(G=(0,$.jsxs)(j,{children:[F,W]}),t[105]=j,t[106]=F,t[107]=W,t[108]=G):G=t[108];let K;return t[109]!==M||t[110]!==I||t[111]!==L||t[112]!==G?(K=(0,$.jsx)(M,{open:I,onOpenChange:L,children:G}),t[109]=M,t[110]=I,t[111]=L,t[112]=G,t[113]=K):K=t[113],K}function en(e){return e+1}function tn(e){return(0,$.jsx)(de,{className:`h-24 w-full`},e)}function nn(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 rn({row:e,lastCheck:t,t:n,cs:r,onEdit:i,onRemove:a}){let o=s(e=>e.language),[c,l]=(0,Q.useState)(!1),u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),h=e.displayName||e.id,g=nn(e),_=e.extra.enabled===!1,v=_?D:t?E:N,y=e.transport===`stdio`?ce:oe,b=_?n.setupDisabled:t?r.customCheckSucceeded:r.customUnchecked,x=t?new Intl.DateTimeFormat(o,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.checkedAt)):null;return(0,$.jsxs)(`li`,{className:`flex min-h-[8.75rem] min-w-0 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`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`div`,{title:n.transportLabels[e.transport],className:`flex size-9 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-inset text-fg-muted`,children:(0,$.jsx)(y,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,$.jsx)(`h3`,{className:`min-w-0 max-w-full text-sm font-semibold text-fg`,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,title:h,className:`block max-w-full truncate rounded text-left hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:h})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:[(0,$.jsxs)(`span`,{title:x?r.customLastChecked.replace(`{{time}}`,x):void 0,"aria-label":x?`${b} · ${r.customLastChecked.replace(`{{time}}`,x)}`:b,className:Y(`inline-flex shrink-0 items-center gap-1`,!_&&t?`text-emerald-700 dark:text-emerald-300`:`text-fg-muted`),children:[(0,$.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),b]}),t?(0,$.jsx)(`span`,{className:`text-fg-muted`,children:r.customToolCount.replace(`{{count}}`,String(t.toolCount))}):null]})]})})]}),(0,$.jsx)(`p`,{title:g,className:`mt-2 truncate font-mono text-xs leading-5 text-fg-muted`,children:g})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-auto text-[11px] text-fg-subtle`,children:n.transportLabels[e.transport]}),(0,$.jsx)(X,{variant:`ghost`,className:`h-8 px-2 py-1 text-xs`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(X,{ref:u,variant:`secondary`,className:`h-8 px-2 py-1 text-xs shadow-none sm:shadow-none`,disabled:_,onClick:()=>l(!0),children:o===`zh`?`用法与工具`:`Usage & tools`}),(0,$.jsxs)(Qe,{children:[(0,$.jsx)($e,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,className:`size-8 p-0`,"aria-label":r.customManage.replace(`{{name}}`,h),title:r.customManage.replace(`{{name}}`,h),children:(0,$.jsx)(F,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(et,{children:(0,$.jsx)(nt,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:(0,$.jsxs)(tt,{onSelect:()=>f(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none data-[highlighted]:bg-surface-hover`,children:[(0,$.jsx)(le,{className:`size-4`,"aria-hidden":!0}),n.removeServer]})})})]})]}),p?(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:p}):null,c?(0,$.jsx)($t,{serverId:e.id,displayName:e.displayName,returnFocusTo:u.current,t:n,onClose:()=>l(!1),onConfigure:()=>{l(!1),i()}}):null,(0,$.jsx)(Ze,{open:d,title:r.removeConfirmTitle.replace(`{{name}}`,h),description:r.removeConfirmDescription,confirmLabel:n.removeServer,cancelLabel:r.modalCancel,destructive:!0,onCancel:()=>f(!1),onConfirm:()=>{f(!1),m(``),a().catch(()=>m(n.setupRemoveFailed))}})]})}function an(e){let t=(0,Nt.c)(30),{servers:n,lastChecks:r,t:i,cs:a,onAdd:o,onEdit:s,onRemove:c}=e,l;t[0]===a.customIntegrationsTitle?l=t[1]:(l=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.customIntegrationsTitle}),t[0]=a.customIntegrationsTitle,t[1]=l);let u;t[2]===n.length?u=t[3]:(u=(0,$.jsx)(`span`,{className:`rounded-md bg-surface-inset px-1.5 py-0.5 text-xs tabular-nums text-fg-muted`,children:n.length}),t[2]=n.length,t[3]=u);let d;t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l,u]}),t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]===a.customIntegrationsHint?f=t[8]:(f=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.customIntegrationsHint}),t[7]=a.customIntegrationsHint,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(G,{className:`size-3.5`,"aria-hidden":!0}),t[12]=m):m=t[12];let h;t[13]!==a.customAdd||t[14]!==o?(h=(0,$.jsxs)(X,{variant:`secondary`,className:`shrink-0 text-xs shadow-none sm:shadow-none`,onClick:o,children:[m,a.customAdd]}),t[13]=a.customAdd,t[14]=o,t[15]=h):h=t[15];let g;t[16]!==p||t[17]!==h?(g=(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[p,h]}),t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==a||t[20]!==r||t[21]!==s||t[22]!==c||t[23]!==n||t[24]!==i?(_=n.length?(0,$.jsx)(`ul`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>(0,$.jsx)(rn,{row:e,lastCheck:r[e.id],t:i,cs:a,onEdit:()=>s(e),onRemove:()=>c(e)},e.clientKey))}):(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge px-5 py-8 text-center text-sm text-fg-muted`,children:a.customEmpty}),t[19]=a,t[20]=r,t[21]=s,t[22]=c,t[23]=n,t[24]=i,t[25]=_):_=t[25];let v;return t[26]!==a.customIntegrationsTitle||t[27]!==g||t[28]!==_?(v=(0,$.jsxs)(`section`,{"aria-label":a.customIntegrationsTitle,children:[g,_]}),t[26]=a.customIntegrationsTitle,t[27]=g,t[28]=_,t[29]=v):v=t[29],v}function on(e){return e.format===`agent-plugin`&&!!e.pluginId&&(!!e.setup?.authorizations?.length||e.authorizationStatus===`required`||!!e.components?.mcp.some(e=>e.type!==`stdio`))}function sn(e){let t=(0,Nt.c)(54),{extension:n,language:r,onOpen:i}=e,a;t[0]===r?a=t[1]:(a=r.startsWith(`zh`),t[0]=r,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(e,t)=>o?e:t,t[2]=o,t[3]=s);let c=s,l=n.installationState===`preparing`,u=n.activationEligible===!1,d=n.authorizationStatus===`required`,f;t[4]!==u||t[5]!==n.readiness||t[6]!==d||t[7]!==l||t[8]!==c?(f=l?c(`准备未完成`,`Setup incomplete`):u?c(`已停用`,`Disabled`):d?c(`需要授权`,`Authorization required`):n.readiness===`blocked`||n.readiness===`degraded`?c(`需要处理`,`Needs attention`):c(`已连接`,`Connected`),t[4]=u,t[5]=n.readiness,t[6]=d,t[7]=l,t[8]=c,t[9]=f):f=t[9];let p=f,m;t[10]!==u||t[11]!==d||t[12]!==l||t[13]!==c?(m=l?c(`继续安装`,`Continue setup`):!u&&d?c(`去授权`,`Connect account`):c(`查看详情`,`View details`),t[10]=u,t[11]=d,t[12]=l,t[13]=c,t[14]=m):m=t[14];let h=m,g;t[15]===n.setup?.authorizations?g=t[16]:(g=n.setup?.authorizations??[],t[15]=n.setup?.authorizations,t[16]=g);let _=g,v=_.length===1?_[0].title:n.name,y=l||!u&&(d||n.readiness===`blocked`||n.readiness===`degraded`),b=l?N:u?D:y?T:E,S=y&&`border-amber-500/25`,C;t[17]===S?C=t[18]:(C=Y(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,S),t[17]=S,t[18]=C);let w=n.branding?.iconUrl,O;t[19]===w?O=t[20]:(O=(0,$.jsx)(Ot,{iconUrl:w,fallback:W,className:`size-9`}),t[19]=w,t[20]=O);let k;t[21]===v?k=t[22]:(k=(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-fg`,title:v,children:v}),t[21]=v,t[22]=k);let A=y?`text-amber-700 dark:text-amber-300`:u?`text-fg-muted`:`text-emerald-700 dark:text-emerald-300`,j;t[23]===A?j=t[24]:(j=Y(`mt-1 inline-flex items-center gap-1 text-[11px]`,A),t[23]=A,t[24]=j);let M;t[25]===b?M=t[26]:(M=(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),t[25]=b,t[26]=M);let P;t[27]!==p||t[28]!==j||t[29]!==M?(P=(0,$.jsxs)(`span`,{className:j,children:[M,p]}),t[27]=p,t[28]=j,t[29]=M,t[30]=P):P=t[30];let F;t[31]!==k||t[32]!==P?(F=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[k,P]}),t[31]=k,t[32]=P,t[33]=F):F=t[33];let I;t[34]!==F||t[35]!==O?(I=(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-3`,children:[O,F]}),t[34]=F,t[35]=O,t[36]=I):I=t[36];let L=n.name,R;t[37]===c?R=t[38]:(R=c(`由插件提供`,`Provided by plugin`),t[37]=c,t[38]=R);let ee;t[39]!==n.name||t[40]!==R?(ee=(0,$.jsxs)(`span`,{className:`mt-2 block w-full truncate text-xs leading-5 text-fg-muted`,title:L,children:[R,` · `,n.name]}),t[39]=n.name,t[40]=R,t[41]=ee):ee=t[41];let z=y?`text-accent-fg`:`text-fg-muted`,B;t[42]===z?B=t[43]:(B=Y(`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs`,z),t[42]=z,t[43]=B);let V;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(x,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[44]=V):V=t[44];let H;t[45]!==h||t[46]!==B?(H=(0,$.jsxs)(`span`,{className:B,children:[h,V]}),t[45]=h,t[46]=B,t[47]=H):H=t[47];let te;return t[48]!==i||t[49]!==I||t[50]!==ee||t[51]!==H||t[52]!==C?(te=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:C,children:[I,ee,H]}),t[48]=i,t[49]=I,t[50]=ee,t[51]=H,t[52]=C,t[53]=te):te=t[53],te}function cn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function ln(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?cn(t)-cn(e):e.isCurrentAuthorization?-1:1}function un(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(ln);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>ln(e.primary,t.primary))}var dn=Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ke);function fn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function pn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function mn(e,t,n){return e.status===`connected`?B(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 hn(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 gn(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 _n({instance:e,t,onChanged:n}){let r=fn(e),i=s(e=>e.language)===`zh`,[a,o]=(0,Q.useState)([]),[c,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)([]),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)([]),[w,D]=(0,Q.useState)({}),[O,k]=(0,Q.useState)(`read`),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(null),[R,V]=(0,Q.useState)(null),[H,te]=(0,Q.useState)(!1),[U,re]=(0,Q.useState)(!1),[ie,W]=(0,Q.useState)(!1),G=(0,Q.useRef)(0),ae=(0,Q.useRef)(0),oe=(0,Q.useMemo)(()=>un(a),[a]),se=(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]),q=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;j(!0),N(null);let t=++G.current;try{let e=(await Promise.allSettled([se(De()).then(e=>{t===G.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),te(!0))}),se(Ae(r)).then(e=>{t===G.current&&k(e)}),se(Be(r)).then(e=>{t===G.current&&(p(e.policy),h(e.agents))})])).find(e=>e.status===`rejected`);t===G.current&&e?.status===`rejected`&&N(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===G.current&&j(!1)}},[e.materialized,r,se]);(0,Q.useEffect)(()=>(q(),()=>{G.current++}),[q]);let ce=(0,Q.useCallback)(async()=>{if(!r)return;let e=++ae.current;W(!0),F(!1);let t=t=>n=>{e===ae.current&&t(n)},n=await Promise.allSettled([se(Ve(r)).then(t(l)),se(We(20)).then(t(e=>d(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),se(Le(r)).then(t(y)),se(Ne(r)).then(t(_))]);e===ae.current&&(F(n.some(e=>e.status===`rejected`)),W(!1))},[r,se]);(0,Q.useEffect)(()=>(U&&ce(),()=>{ae.current++}),[U,ce]),(0,Q.useEffect)(()=>{let e=!1,t=un(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return se(Ue()).then(t=>{e||x(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await se(Pe(e.accountId))])).then(t=>{e||D(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,se]);let J=(0,Q.useCallback)(async i=>{if(!r)return;let a=qe()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),j(!0),N(null);try{if(!qe()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await Me(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(qe()){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 Ge(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?.(),q()])}catch(e){N(ne(e,t))}finally{a?.close(),j(!1)}},[e.connectorId,q,n,t,r]),ue=(0,Q.useCallback)(async t=>{j(!0),N(null);try{await be(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),q()])}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[e.config,e.instanceId,q,n]),fe=async e=>{let t=qe()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),N(null);try{let n=await ke(e.id);if(n.authorizationUrl)if(qe())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await q()}catch(e){t?.close(),N(e instanceof Error?e.message:String(e))}},pe=(0,Q.useCallback)(async e=>{if(r){k(e),N(null);try{await Ce(r,e)}catch(e){N(e instanceof Error?e.message:String(e)),await q()}}},[q,r]),me=(0,Q.useCallback)(async e=>{if(r){N(null);try{p(await ye(r,e))}catch(e){N(e instanceof Error?e.message:String(e))}}},[r]),he=(0,Q.useCallback)(e=>{if(!f)return;let t=f.allowedAgentIds.includes(e);if(t&&f.allowedAgentIds.length===1)return;let n=t?f.allowedAgentIds.filter(t=>t!==e):[...f.allowedAgentIds,e];me({allowedAgentIds:n})},[me,f]),Z=(0,Q.useCallback)(async e=>{j(!0),N(null);try{await e(),await q()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[q]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let xe=oe.filter(e=>e.primary.status===`active`).length,Se=xe>0?t.composioAddAccount:t.composioConnectAccount,Oe=H&&xe>0,je=v?.requiresCustomAuthConfig===!0,Ie=v?.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:Y(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Oe?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Oe?(0,$.jsx)(E,{className:`size-3.5`}):(0,$.jsx)(T,{className:`size-3.5`}),Oe?t.connectionReady:H||M?t.connectionNeedsSetup:t.connectionChecking]}),H&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:B(t.composioAccountCount,{count:String(oe.length)})})]}),(0,$.jsxs)(X,{variant:`primary`,className:`shrink-0`,disabled:A,onClick:()=>void J(),children:[A?(0,$.jsx)(z,{className:`size-4 animate-spin`}):(0,$.jsx)(ee,{className:`size-4`}),Se]})]}),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)(X,{variant:`secondary`,disabled:A,onClick:()=>void q(),children:t.composioRetry})]}):null,g&&!Oe?(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:mn(g,xe,t)}),g.recovery===`none`?null:(0,$.jsx)(X,{variant:`secondary`,disabled:A,onClick:()=>void(g.recovery===`retry`?q():J()),children:g.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,je&&Ie.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:O===`read`?t.composioAccessReadHint:O===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(S,{value:O,onChange:e=>void pe(e.currentTarget.value),children:[(0,$.jsx)(C,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(C,{value:`write`,children:t.composioAccessReadWrite}),O===`admin`?(0,$.jsx)(C,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(S,{value:f.confirmationPolicy,onChange:e=>void me({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(C,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(C,{value:`always`,children:t.composioConfirmAlways}),f.confirmationPolicy===`never`?(0,$.jsx)(C,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children: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:Y(`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 me({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),m.map(e=>(0,$.jsx)(`button`,{type:`button`,className:Y(`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:()=>he(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:A,onChange:e=>void me({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),f.selectedAccountIds!==null&&oe.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:f.selectedAccountIds.includes(e.accountId),onChange:t=>void me({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}),H&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:B(t.composioAccountCount,{count:String(oe.length)})})]}),(0,$.jsxs)(X,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:A,onClick:()=>void q(),children:[(0,$.jsx)(K,{className:Y(`size-3.5`,A&&`animate-spin`)}),t.refresh]})]}),oe.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:oe.map(e=>{let r=e.primary,a=b.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:Y(`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`:hn(r.status,t)}),a?(0,$.jsx)(`p`,{className:Y(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:B(t.connectorLearningStatus,{status:gn(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)(X,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void fe(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(X,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:A,onClick:()=>V(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(X,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:A,onClick:()=>void J(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(X,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:A,onClick:()=>void Z(()=>we(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(X,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:A,onClick:()=>void Z(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await ge(r.accountId),await n?.()}),children:[(0,$.jsx)(K,{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:A,checked:r.allowedAgentIds==null,onChange:e=>void Z(()=>we(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&m.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;Z(()=>we(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:A,onChange:e=>void Z(()=>Te(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(S,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:A,onChange:e=>void Z(()=>Te(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(C,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(C,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(C,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(C,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:Y(dn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&Z(()=>ve(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)(X,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:A,onClick:()=>L(e.id),children:(0,$.jsx)(le,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(X,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:A,onClick:()=>void Z(()=>Ee(r.id)),children:(0,$.jsx)(K,{className:`size-4`})})})]})]})]},e.key)})}):A&&!H?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(de,{className:`h-16 w-full`}),(0,$.jsx)(de,{className:`h-16 w-full`})]}):H?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>re(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[ie?(0,$.jsx)(de,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,P?(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)(X,{variant:`ghost`,disabled:ie,onClick:()=>void ce(),children:t.composioRetry})]}):null,v?.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:je?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(S,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:A,onChange:e=>void ue(e.currentTarget.value),children:[je?null:(0,$.jsx)(C,{value:``,children:t.composioAuthConfigManaged}),je&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(C,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,Ie.map(e=>(0,$.jsxs)(C,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children: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:[pn(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)(Ze,{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;V(null),e&&Z(()=>Fe(e))},onCancel:()=>V(null)}),(0,$.jsx)(Ze,{open:I!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=I;L(null),e&&Z(()=>_e(e))},onCancel:()=>L(null)})]})}var vn=Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ke);function yn(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 bn(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 xn({instance:e,definition:t,onClose:n,onChanged:r,t:i}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(()=>yn(t,e)),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),A=t?.setup.config??[],j=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&A.length>0&&(t?.setup.secrets??[]).length===0,M=e.materialized.type===`mcp`,N=e.materialized.type===`composio`,F=e.materialized.type===`memorySource`,I=t?H(t,i):null,L=(0,Q.useCallback)(async()=>{D(!0),T(null);try{let t=await Se(e.instanceId);k(t),t.ok||T(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{D(!1)}},[e.instanceId,r,i.healthStatusLabels]),R=(0,Q.useCallback)(async()=>{o(!0),T(null);try{await He(e.instanceId),await r(),n()}catch(e){T(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),ee=(0,Q.useCallback)(async()=>{if(!(!t||!j)){_(!0),T(null);try{let n={};for(let e of t.setup.config??[]){let t=bn(e.type,S[e.key]??``);t!==void 0&&(n[e.key]=t)}await be(e.instanceId,{config:n}),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{_(!1)}}},[S,t,e.instanceId,r,j]),V=(0,Q.useCallback)(async()=>{y(!0),x(null),T(null);try{let t=await xe(e.connectorId);x(t.recordIds.length),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.connectorId,r]);return(0,$.jsxs)(h,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(f,{children:[(0,$.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(p,{className:Y(`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`,N?`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)(te,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(m,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(u,{className:`mt-1 text-sm text-fg-muted`,children:I??(e.materialized.type===`mcp`?B(i.mcpServerRuntime,{serverId:e.materialized.serverId}):B(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(d,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Z.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(ue,{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:[w?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:w}):null,e.enabled&&(O?O.ok:e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`)?(0,$.jsx)(`div`,{className:`mb-5`,children:(0,$.jsx)(xt,{target:{kind:`connector`,id:e.connectorId,name:e.displayName},serverId:e.materialized.type===`mcp`?e.materialized.serverId:void 0,onStart:n})}):null,M?(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:O?.ok?B(i.toolsAvailable,{count:String(O.toolCount)}):O?i.healthStatusLabels[O.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(X,{variant:`secondary`,"aria-busy":E,disabled:E||!e.enabled,onClick:()=>void L(),children:[E?(0,$.jsx)(z,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(K,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),j?A.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:vn,value:S[e.key]??``,placeholder:e.placeholder,onChange:t=>C(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,N?(0,$.jsx)(_n,{instance:e,t:i,onChanged:r}):null,F?(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}),I?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:I}):null,b===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:B(i.connectedSourceSynced,{count:String(b)})})]}),(0,$.jsxs)(X,{disabled:v,onClick:()=>void V(),children:[v?(0,$.jsx)(z,{className:`size-4 animate-spin`}):(0,$.jsx)(P,{className:`size-4`}),i.composioSyncNow]})]}),j?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:A.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:vn,value:S[e.key]??``,placeholder:e.placeholder,onChange:t=>C(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!M&&!N&&!F?(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)(X,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(z,{className:`size-4 animate-spin`}):(0,$.jsx)(le,{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)(X,{variant:`secondary`,onClick:n,children:i.modalClose}),(M||F)&&j?(0,$.jsxs)(X,{variant:`primary`,disabled:g,onClick:()=>void ee(),children:[g?(0,$.jsx)(z,{className:`size-4 animate-spin`}):(0,$.jsx)(ae,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(Ze,{open:s,title:B(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),R()},onCancel:()=>{a||c(!1)}})]})}function Sn(e){let t=(0,Nt.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(U,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(xn,{...e}),t[0]=e,t[1]=n),n}function Cn(e){let t=(0,Nt.c)(59),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i!==void 0&&i,c;t[0]!==r||t[1]!==n?(c=Wt(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c.state,u;t[3]!==r||t[4]!==o?(u=r?H(r,o):null,t[3]=r,t[4]=o,t[5]=u):u=t[5];let d=u,f,p,m,h,g,_,v,y,b;if(t[6]!==l||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){f=l===`ready`?{label:o.connectionReady,Icon:E,className:`text-emerald-700 dark:text-emerald-300`}:l===`needs_setup`?{label:o.connectionNeedsSetup,Icon:T,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:N,className:`text-fg-muted`},b=`button`;let e=l===`needs_setup`&&`border-amber-500/25`,i=s&&`bg-accent-soft`;t[23]!==e||t[24]!==i?(p=Y(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left hover:bg-surface-hover/45`,Z.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e,i),t[23]=e,t[24]=i,t[25]=p):p=t[25],t[26]!==n||t[27]!==a?(m=()=>a(n),t[26]=n,t[27]=a,t[28]=m):m=t[28],v=`flex w-full min-w-0 items-start gap-3`,t[29]===r?y=t[30]:(y=(0,$.jsx)(te,{connector:r,size:`sm`}),t[29]=r,t[30]=y),g=`min-w-0 flex-1`,t[31]===n.displayName?_=t[32]:(_=(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:n.displayName,children:n.displayName}),t[31]=n.displayName,t[32]=_),h=Y(`mt-1 inline-flex items-center gap-1 text-[11px]`,f.className),t[6]=l,t[7]=r,t[8]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.connectionReady,t[14]=f,t[15]=p,t[16]=m,t[17]=h,t[18]=g,t[19]=_,t[20]=v,t[21]=y,t[22]=b}else f=t[14],p=t[15],m=t[16],h=t[17],g=t[18],_=t[19],v=t[20],y=t[21],b=t[22];let S;t[33]===f.Icon?S=t[34]:(S=(0,$.jsx)(f.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[33]=f.Icon,t[34]=S);let C;t[35]!==f.label||t[36]!==S||t[37]!==h?(C=(0,$.jsxs)(`span`,{className:h,children:[S,f.label]}),t[35]=f.label,t[36]=S,t[37]=h,t[38]=C):C=t[38];let w;t[39]!==C||t[40]!==g||t[41]!==_?(w=(0,$.jsxs)(`div`,{className:g,children:[_,C]}),t[39]=C,t[40]=g,t[41]=_,t[42]=w):w=t[42];let D;t[43]!==w||t[44]!==v||t[45]!==y?(D=(0,$.jsxs)(`div`,{className:v,children:[y,w]}),t[43]=w,t[44]=v,t[45]=y,t[46]=D):D=t[46];let O;t[47]===d?O=t[48]:(O=d?(0,$.jsx)(`p`,{className:`mt-2 w-full line-clamp-2 text-xs leading-5 text-fg-muted`,title:d,children:d}):null,t[47]=d,t[48]=O);let k;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(x,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[49]=k):k=t[49];let A;t[50]===o.installedDetails?A=t[51]:(A=(0,$.jsxs)(`span`,{className:`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs text-fg-muted`,children:[o.installedDetails,k]}),t[50]=o.installedDetails,t[51]=A);let j;return t[52]!==p||t[53]!==m||t[54]!==D||t[55]!==O||t[56]!==A||t[57]!==b?(j=(0,$.jsxs)(`button`,{type:b,className:p,onClick:m,children:[D,O,A]}),t[52]=p,t[53]=m,t[54]=D,t[55]=O,t[56]=A,t[57]=b,t[58]=j):j=t[58],j}function wn(e,t){return ct()}function Tn(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:[Tt()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function En(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,Tt(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Tt(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Dn(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 On(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ke)}function kn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d,referenceLabel:f=`Existing credential reference`,showValueLabel:p=`Show value`,hideValueLabel:m=`Hide value`,allowPaste:h=!0}){let[g,_]=(0,Q.useState)(new Set),[v,y]=(0,Q.useState)(!1),b=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},x=()=>{d([...u,Tt()])},S=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Tt()])},C=async()=>{try{let e=await he();if(!e){y(!0);return}let t=rt(e);if(!t?.length){y(!0);return}d(t)}catch{y(!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]}),h?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void C(),children:[(0,$.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.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:Y(On(),`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=>b(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:Y(On(),`min-w-0 font-mono text-xs`),type:g.has(e.clientKey)?`text`:`password`,autoComplete:`off`,"aria-label":`${l} ${t+1}`,readOnly:!!e.reference,value:e.reference?f:e.value,placeholder:e.reference?f:l,onChange:e=>b(t,{value:e.target.value})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":g.has(e.clientKey)?m:p,onClick:()=>_(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:g.has(e.clientKey)?(0,$.jsx)(L,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(R,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>S(t),"aria-label":r,children:(0,$.jsx)(le,{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:f}):null]},e.clientKey))}),(0,$.jsx)(Ze,{open:v,title:o,description:a,confirmLabel:s,onConfirm:()=>y(!1),onCancel:()=>y(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`self-start text-sm text-accent hover:underline`,Z.press),onClick:x,children:[`+ `,n]})]})}var An=Y(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,Ke);function jn(e){let t=(0,Nt.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o!==void 0&&o,[c,l]=(0,Q.useState)(!1),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(An,`mt-1.5`),t[0]=u):u=t[0];let d=c?`text`:`password`,f;t[1]===r?f=t[2]:(f=e=>r(e.target.value),t[1]=r,t[2]=f);let p;t[3]!==s||t[4]!==d||t[5]!==f||t[6]!==n?(p=(0,$.jsx)(`input`,{className:u,type:d,value:n,required:s,autoComplete:`off`,onChange:f}),t[3]=s,t[4]=d,t[5]=f,t[6]=n,t[7]=p):p=t[7];let m;t[8]!==i||t[9]!==p?(m=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i,p]}),t[8]=i,t[9]=p,t[10]=m):m=t[10];let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>l(Mn),t[11]=h):h=t[11];let g;t[12]===c?g=t[13]:(g=c?(0,$.jsx)(L,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(R,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=g);let _=c?a.setupHideValue:a.setupShowValue,v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:h,children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==m?(y=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[m,v]}),t[17]=v,t[18]=m,t[19]=y):y=t[19],y}function Mn(e){return!e}function Nn(e){let t=(0,Nt.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a!==void 0&&a,c=o!==void 0&&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)(kn,{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 Pn(e){let t=(0,Nt.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=Y(An,`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)(C,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=f);let p;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(p=a||n.mode===`existing`?(0,$.jsx)(C,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=p):p=t[9];let m;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==u||t[13]!==f||t[14]!==p?(m=(0,$.jsxs)(S,{"aria-label":s,className:c,value:l,onChange:u,children:[f,p]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=u,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]!==i.setupAuthLabel||t[17]!==m?(h=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,m]}),t[16]=i.setupAuthLabel,t[17]=m,t[18]=h):h=t[18];let g;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(g=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]=g):g=t[21];let _;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(_=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]=_):_=t[24];let v;t[25]!==n.mode||t[26]!==i.setupExistingHint?(v=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]=v):v=t[27];let y;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(y=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jn,{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]=y):y=t[32];let b;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(b=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:Y(An,`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)(jn,{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]=b):b=t[38];let x;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(x=n.mode===`headers`?(0,$.jsx)(Nn,{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]=x):x=t[43];let w;return t[44]!==h||t[45]!==g||t[46]!==_||t[47]!==v||t[48]!==y||t[49]!==b||t[50]!==x?(w=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g,_,v,y,b,x]}),t[44]=h,t[45]=g,t[46]=_,t[47]=v,t[48]=y,t[49]=b,t[50]=x,t[51]=w):w=t[51],w}function Fn(e){let t=(0,Nt.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 In({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>wt(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=ht(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)(X,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(Fn,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:An,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:An,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(le,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(X,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(G,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(Nn,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(it(e)??{})})}})]})}function Ln(e){let t=(0,Nt.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&&o,u=s!==void 0&&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)(Fn,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:An,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(In,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(Fn,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:An,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(Fn,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:An,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)(Fn,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:An,readOnly:u,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(Fn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:An,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&l?(0,$.jsx)(Fn,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:An,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(Fn,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(S,{"aria-label":r.exposureLabel,className:An,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(C,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(Fn,{label:r.requestTimeoutLabel,children:(0,$.jsx)(Mt,{allowEmpty:!0,type:`number`,min:1,className:An,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 Rn(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 zn(e,t){return JSON.stringify({id:e.id,config:gt(En(e,t))})}function Bn(e,t){try{return zn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Vn(e){let{t,cs:n}=e,r=s(e=>e.language),i=(0,Q.useId)(),[a,o]=(0,Q.useState)(e.initialRow),[c,d]=(0,Q.useState)(()=>Tn(e.initialRow)),[g,_]=(0,Q.useState)(`idle`),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(),[k,A]=(0,Q.useState)(),[j,M]=(0,Q.useState)(),[N,P]=(0,Q.useState)(!1),[F,L]=(0,Q.useState)(!1),[R,ee]=(0,Q.useState)(``),[B,V]=(0,Q.useState)(``),[H,te]=(0,Q.useState)([]),[U,ne]=(0,Q.useState)(`0`),[re,ie]=(0,Q.useState)(0),[W,G]=(0,Q.useState)(``),[K,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),q=e.mode===`edit`,[ce,le]=(0,Q.useState)(``),J=(0,Q.useRef)(void 0),[de]=(0,Q.useState)(()=>Bn(e.initialRow,Tn(e.initialRow))),fe=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),pe=(0,Q.useRef)(void 0),me=(0,Q.useRef)(void 0),he=(0,Q.useRef)(void 0),Z=(0,Q.useRef)(null),ge=(0,Q.useRef)(``),_e=(0,Q.useRef)(!0),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),be=(0,Q.useRef)(null),xe=(0,Q.useRef)(null),Se=(0,Q.useRef)(e.onSaved);Se.current=e.onSaved;let Ce=j?.state===`starting`||j?.state===`authorizing`,we=g!==`idle`||Ce,Te=de!==Bn(a,c),Ee=a.extra.enabled===!1,De=!w&&!b&&(Te||!!R.trim());(0,Q.useEffect)(()=>(_e.current=!0,()=>{_e.current=!1,pe.current?.abort(),Z.current?.close(),J.current&&_t(J.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!De)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[De]),(0,Q.useEffect)(()=>{if(!D)return;let e=be.current?.querySelector(`[data-field="${D.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`,i),D.focus!==!1&&(n??xe.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[D,i]),(0,Q.useEffect)(()=>{if(!j||!Ce)return;let e=new AbortController;me.current=e;let n;async function r(){try{let n=await at(J.current,e.signal);if(e.signal.aborted||(M(n),n.authorizationUrl&&ge.current!==n.authorizationUrl&&(ge.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&y(t.oauthOpenFailed):Z.current&&!Z.current.closed&&Z.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){he.current=void 0,Z.current?.close(),A({state:`connected`,toolCount:n.toolCount}),y(``);return}if(n.state===`error`||n.state===`cancelled`){he.current=void 0,Z.current?.close(),y(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&P(!0);return}}catch{if(e.signal.aborted)return;Oe(),Z.current?.close(),y(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[j?.id,Ce,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function Oe(){pe.current?.abort(),me.current?.abort(),J.current&&_t(J.current).catch(()=>{}),J.current=void 0,le(``),ae(!1),A(void 0),M(void 0),y(``),O(void 0)}function ke(e){o(t=>({...t,...e})),Oe()}function Ae(e){d(t=>({...t,...e})),Oe()}function je(){g===`saving`||Ce||(g===`checking`&&(Oe(),_(`idle`)),De?se(!0):e.onClose())}function Me(){try{te(ft(R)),ne(`0`),V(``)}catch{V(t.setupImportError),te([])}}function Ne(){let t=H[Number(U)];if(!t)return;let n={...t,id:fe.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...fe.current?{enabled:a.extra.enabled}:{}}};o(n),d(Tn(n)),Oe(),ie(e=>e+1),L(!1),ee(``),te([])}function Pe(e){function n(e,t){return O({field:e,message:t}),!1}if(e.transport!==`stdio`){try{e.url=ut(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(c.mode===`bearer`&&!c.token.trim().replace(/^Bearer\s*/i,``)||c.mode===`apiKey`&&(!c.apiKey.trim()||!c.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(Dn(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(c.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(c.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{gt(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 Fe(){y(``),_(`checking`),ge.current=``,window.electronAPI?.shell?.openExternalUrl||(Z.current=window.open(`about:blank`,`_blank`),Z.current&&(Z.current.opener=null));try{let e=await Ct(J.current);if(!_e.current){Z.current?.close(),J.current&&_t(J.current).catch(()=>{});return}he.current=e.id,M(e)}catch{Z.current?.close(),_e.current&&y(t.setupAuthFailed)}finally{_e.current&&_(`idle`)}}async function Ie(){let r=En(a,c);if(!Pe(r))return;let i=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==fe.current),s=new Set([...e.managedServerIds,...i.map(e=>e.id)]);if(r.id=fe.current||r.id.trim()||st(r,s),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...s].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){O({field:`advanced`,message:n.duplicateServerId});return}Oe(),_(`checking`);let l=new AbortController;pe.current=l;try{let n=await ot(r,fe.current||void 0,e.initialRow.extra,l.signal);if(!_e.current||l.signal.aborted){_t(n.id).catch(()=>{});return}J.current=n.id,o(r),le(Bn(r,c));let i=await dt(n.id,l.signal);if(!_e.current||l.signal.aborted)return;A(i),i.state===`error`&&y(Rn(i,t))}catch(e){_e.current&&!l.signal.aborted&&y(e.status===409?t.setupConflict:Rn(e,t))}finally{_e.current&&pe.current===l&&_(`idle`)}}async function Le(e=!1){if(!(!J.current||k?.state!==`connected`||ce!==Bn(a,c))){_(`saving`),y(``);try{let t=await pt(J.current,e);J.current=void 0,await Se.current().catch(()=>{}),t?.reloadRequired?x(!0):(e&&o(e=>({...e,extra:{...e.extra,enabled:!0}})),T(!0))}catch(e){let n=e.status;n===404||n===409?(Oe(),y(t.setupConflict)):y(t.setupSaveFailed)}finally{_e.current&&_(`idle`)}}}async function Re(){me.current?.abort();let e=J.current;he.current=void 0,M(void 0),Z.current?.close(),y(t.setupCancelled),_(`checking`);try{e&&await yt(e)}catch{_e.current&&(Oe(),y(t.setupCancelled))}finally{_e.current&&_(`idle`)}}async function ze(){j?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(j.authorizationUrl)).ok||y(t.oauthOpenFailed):window.open(j.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Be(){if(j)try{await Et(J.current,W),G(``),y(``)}catch{y(t.setupRedirectInvalid)}}let Ve=!!J.current&&ce===Bn(a,c)&&(c.mode===`oauth`||c.mode===`auto`&&k?.state===`oauth_required`)&&k?.state!==`connected`,He=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(a.url.trim()),Ue=H[Number(U)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(h,{open:e.open,onOpenChange:e=>{e||je()},children:(0,$.jsxs)(f,{children:[(0,$.jsx)(l,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(p,{ref:ve,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(),ve.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)(m,{className:`font-semibold`,children:w?a.displayName||a.id:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(u,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:g===`saving`||Ce,onClick:je,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(ue,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[w?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),Ee?t.setupDisabled:r===`zh`?`连接已保存,可以开始使用`:`Connection saved and ready to use`]}),Ee?null:(0,$.jsx)(xt,{target:{kind:`mcp`,id:a.id,name:a.displayName||a.id},serverId:a.id,onStart:e.onClose})]}):F?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(X,{variant:`ghost`,onClick:()=>L(!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:Y(An,`mt-1.5 min-h-40 font-mono text-xs`),value:R,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{ee(e.target.value),te([]),V(``)}})]}),(0,$.jsx)(X,{variant:`secondary`,disabled:!R.trim(),onClick:Me,children:t.setupImportPreview}),B?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:B}):null,Ue?(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)(S,{"aria-label":t.setupImportChoose,className:Y(An,`mt-1.5`),value:U,onChange:e=>ne(e.target.value),children:H.map((e,t)=>(0,$.jsx)(C,{value:String(t),children:e.displayName||e.id||nn(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[Ue.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,nn(Ue)]})]}):null]}):(0,$.jsxs)(`form`,{ref:be,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&a.url.trim())try{ut(a.url)}catch{O({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Ie()},children:[(0,$.jsxs)(`fieldset`,{disabled:we||b,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(Xe,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`sse`,`stdio`].map(e=>(0,$.jsx)(X,{type:`button`,variant:a.transport===e?`secondary`:`ghost`,"aria-pressed":a.transport===e,onClick:()=>ke({transport:e}),children:e===`stdio`?t.setupUseCommand:e===`sse`?r===`zh`?`旧版 SSE`:`Legacy SSE`:t.setupUseUrl},e))}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>L(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Ln,{row:a,t,variant:`basic`,onUpdate:ke},`${a.transport}-${re}`)}),a.transport===`stdio`?null:(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(Pn,{allowExisting:!!a.extra.auth||a.headers.some(e=>!!e.reference),draft:c,onChange:Ae,t})}),D?(0,$.jsx)(`p`,{id:i,ref:xe,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:D.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:N,onToggle:e=>P(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)(Ln,{row:a,t,variant:`advanced`,idReadOnly:q,showOAuth:c.mode===`oauth`,onUpdate:ke}),a.transport!==`stdio`&&c.mode!==`headers`&&c.mode!==`existing`?(0,$.jsx)(Nn,{additional:!0,headers:c.additionalHeaders,onChange:e=>Ae({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:a.transport===`stdio`?t.setupCommandHostHint:He?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),b?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!w&&!F&&!b?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[g===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(z,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),g===`saving`?t.setupSaving:t.setupChecking]}),g===`idle`&&q&&!Te&&!k&&!v&&!Ce?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:Ee?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,k?.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)(E,{className:`size-4 shrink-0`,"aria-hidden":!0}),k.toolCount?t.setupConnected.replace(`{{count}}`,String(k.toolCount)):t.setupZeroTools]}),(0,$.jsx)(xt,{preview:!0,target:{kind:`mcp`,id:a.id,name:a.displayName||a.id},serverId:a.id,draftId:J.current}),(0,$.jsx)(X,{ref:ye,variant:`secondary`,onClick:()=>ae(!0),children:t.viewTools})]}):null,k?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,k?.state===`auth_unknown`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:r===`zh`?`认证方式尚未确定。请核实服务接入说明,选择 Token 或已确认支持的 OAuth。`:`Authentication is undetermined. Check the integration guide and select a Token or verified OAuth method.`}):null,k?.state===`oauth_required`&&!Ce?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,Ce?(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)(z,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[j?.authorizationUrl?(0,$.jsxs)(X,{variant:`secondary`,onClick:()=>void ze(),children:[(0,$.jsx)(I,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(X,{variant:`ghost`,onClick:()=>void Re(),children:t.setupCancelAuth})]}),j?.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:An,value:W,onChange:e=>G(e.target.value)})]}),(0,$.jsx)(X,{className:`mt-2`,disabled:!W.trim(),onClick:()=>void Be(),children:t.setupContinue})]}):null]}):null,v?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:v}),v!==t.setupSaveFailed&&g!==`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)(X,{variant:`secondary`,disabled:g===`saving`||Ce,onClick:je,children:w||q||b?t.setupClose:n.modalCancel}),w||b?null:F?(0,$.jsx)(X,{variant:`primary`,disabled:!Ue,onClick:Ne,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{variant:k?.state===`connected`?`secondary`:`primary`,disabled:we,onClick:()=>Ve?void Fe():void Ie(),children:Ve?t.setupSignIn:t.setupTestConnection}),k?.state===`connected`&&ce===Bn(a,c)?(0,$.jsxs)($.Fragment,{children:[Ee?(0,$.jsx)(X,{variant:`secondary`,disabled:we,onClick:()=>void Le(!0),children:t.setupEnableSave}):null,(0,$.jsx)(X,{variant:`primary`,disabled:we,"aria-busy":we,onClick:()=>void Le(),children:q?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(Ze,{open:oe,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>se(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),K?(0,$.jsx)($t,{draftId:J.current,serverId:a.id,displayName:a.displayName,returnFocusTo:ye.current,t,onClose:()=>ae(!1)}):null]})}var Hn=`recommended`,Un=`builtin`,Wn=`composio`,Gn=`xopc-store`;function Kn(e,t=`en`){return e==="default"&&t.startsWith(`zh`)?Hn:Un}function qn(e,t){let n=e.connectorManifest;if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n;if(r.contractVersion!==1||r.id!==e.name)return null;let i=r.runtime,a=r.auth;if(!i||typeof i!=`object`||Array.isArray(i)||!a||typeof a!=`object`||Array.isArray(a))return null;let o=i,s=a;if(o.type!==`mcp`||typeof o.serverId!=`string`)return null;let c=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(r.category??``))?r.category:`custom`,l=s.mode===`oauth`?{mode:`oauth`,...typeof s.clientId==`string`?{clientId:s.clientId}:{}}:s.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`},u=e.localizations?.[t===`zh`?`zh-CN`:`en`];return{id:e.name,version:e.latestVersion??`store`,displayName:u?.displayName??(typeof r.displayName==`string`?r.displayName:e.name),description:u?.description??(typeof r.description==`string`?r.description:e.description),category:c,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(r.capabilities)?r.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(r.tags)?r.tags.filter(e=>typeof e==`string`):[`store`],auth:l,setup:r.setup&&typeof r.setup==`object`&&!Array.isArray(r.setup)?r.setup:{},runtime:{type:`mcp`,serverId:o.serverId}}}function Jn(e){return g(e.map(e=>({connector:e,service:{id:e.id,source:e.source===`builtin`?`builtin-connector`:e.source===`store`?`store-connector`:`registry-connector`}})),`en`).map(e=>e.connector)}function Yn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function Xn({embedded:e=!1,onHeaderActionChange:t}){let n=fe().filter(on),r=s(e=>e.language),l=c(r),u=l.connectorsSettings,d=l.mcpSettings,f=o(e=>e.conversationId),p=!!f,m=a(),[h,g]=i(),b=h.get(`understanding`)===`1`,x=Yn(h.get(`returnTo`)),S=!!h.get(`returnTo`)&&!b,C=h.get(`tab`),[T,E]=(0,Q.useState)(!b&&C===`connected`?`connected`:`discover`),{data:D}=pe(p&&T===`discover`&&!b?[`service-recommendations`,r]:null,()=>_(r),{revalidateOnFocus:!1}),O=(0,Q.useMemo)(()=>new Set(D?.items.filter(e=>e.service?.source===`store-plugin`).map(e=>v(e.id))??[]),[D]),N=(0,Q.useRef)(!1),[P,F]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[I,L]=(0,Q.useState)(!1),[R,ee]=(0,Q.useState)(!1),[B,V]=(0,Q.useState)(1),[H,te]=(0,Q.useState)(void 0),[U,ne]=(0,Q.useState)(``),[W,G]=(0,Q.useState)(b||S?h.get(`connector`)??``:``),[K,ae]=(0,Q.useState)(Kn(b?`understanding`:`default`,r)),[oe,se]=(0,Q.useState)(`name`),[q,ce]=(0,Q.useState)(b?`understand`:`all`),[le,J]=(0,Q.useState)(null),[ue,de]=(0,Q.useState)(null),[he,Z]=(0,Q.useState)(null),[ge,_e]=(0,Q.useState)(null),[ve,ye]=(0,Q.useState)(null),[be,xe]=(0,Q.useState)(null),{data:Se,mutate:Ce}=me(p),we=Se?.payload?.config,Te=(0,Q.useMemo)(()=>we===void 0?null:vt(we),[we]),Ee=Te?.servers??[],De=P.instances.length+Ee.length+n.length,[ke,Ae]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(Ae({}),!p||!we)return;let e=new AbortController;return mt(e.signal).then(t=>{e.signal.aborted||Ae(t)}).catch(()=>{}),()=>e.abort()},[p,we]);let Me=(0,Q.useCallback)(async()=>{if(!f){F({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}F(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([je(),Oe()]);F(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){F({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[f]);(0,Q.useEffect)(()=>{Me()},[Me]),(0,Q.useEffect)(()=>{N.current||P.loading||p&&!Te||(E(b?`discover`:De>0?`connected`:`discover`),N.current=!0)},[p,De,Te,b,P.loading]),(0,Q.useEffect)(()=>{ae(e=>e===`builtin`||e===`recommended`?Kn(b?`understanding`:`default`,r):e)},[r,b]);let Ne=(0,Q.useCallback)(e=>{N.current=!0,E(e)},[]),Pe=(0,Q.useMemo)(()=>[{id:Wn,displayName:u.composioSourceName},{id:Gn,displayName:u.storeSourceName}],[u.composioSourceName,u.storeSourceName]),Fe=(0,Q.useCallback)(async e=>{if(!p||K===`builtin`||K===`recommended`){F(e=>({...e,registryCatalog:[]})),V(1),te(void 0);return}let t=W.trim(),n=Math.max(e?.page??1,1),i=e?.append??!1,a=K===`all`?Pe:Pe.filter(e=>e.id===K);if(a.length!==0){L(!0),i?F(e=>({...e,error:null})):(V(1),te(void 0),F(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(a.map(async e=>{if(e.id===`composio`){let e=await Re({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let i=await Ie({q:t||void 0,page:n,pageSize:24,sort:oe===`source`?`newest`:`downloads`});return{connectors:i.items.flatMap(e=>{let t=qn(e,r);return t?[t]:[]}),totalPages:i.meta.totalPages}})),o=Jn(e.flatMap(e=>e.connectors)),s=Math.max(1,...e.map(e=>e.totalPages??1));V(n),te(s),F(e=>({...e,registryCatalog:i?Jn([...e.registryCatalog,...o]):o}))}catch(e){F(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{L(!1)}}},[oe,W,K,p,Pe,r]);(0,Q.useEffect)(()=>{if(T!==`discover`||P.loading)return;if(K===`builtin`||K===`recommended`){F(e=>({...e,registryCatalog:[]})),V(1),te(void 0);return}let e=window.setTimeout(()=>{Fe()},W.trim()?350:0);return()=>window.clearTimeout(e)},[W,K,Fe,P.loading,T]);let Le=(0,Q.useMemo)(()=>new Set(P.instances.map(e=>e.connectorId)),[P.instances]),Be=(0,Q.useMemo)(()=>new Map([...P.catalog,...P.registryCatalog].map(e=>[e.id,e])),[P.catalog,P.registryCatalog]);(0,Q.useEffect)(()=>{if(P.loading)return;let e=h.get(`connector`),t=h.get(`instance`);if(!e&&!t)return;let n=P.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)N.current=!0,ne(``),Z(n.instanceId),_e(n),E(`connected`);else if(e){let t=Be.get(e);if(!t)return;N.current=!0,ae(Kn(b?`understanding`:`default`,r)),G(``),de(t),E(`discover`)}let i=new URLSearchParams(h);i.delete(`connector`),i.delete(`instance`),i.set(`tab`,n?`connected`:`discover`),g(i,{replace:!0})},[Be,b,r,h,g,P.instances,P.loading]);let Ve=(0,Q.useCallback)(async e=>{ee(!0),F(e=>({...e,error:null}));try{let t=await ze(e);J(re(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){F(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{ee(!1)}},[]);(0,Q.useEffect)(()=>{let e=h.get(`storeConnector`);if(!p||!e)return;let t=new URLSearchParams(h);t.delete(`storeConnector`),g(t,{replace:!0}),Ve(e)},[p,h,g,Ve]);let He=(0,Q.useMemo)(()=>new Set(P.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[P.instances]),Ue=(0,Q.useCallback)(async e=>{let t=await bt(e);await Ce(),await Me(),t.reloadRequired&&F(e=>({...e,error:d.setupReloadRequired}))},[Me,Ce,d.setupReloadRequired]),We=(0,Q.useCallback)(()=>{xe({mode:`add`,row:wn(Ee,He)})},[Ee,He]),Ge=Ye(e=>e.setPageHeader),Ke=Ye(e=>e.clearPageHeader),qe=(0,Q.useMemo)(()=>({searchLabel:T===`connected`?u.connectedSearchPlaceholder:u.discoverSearchPlaceholder,search:(0,$.jsx)(kt,{value:T===`connected`?U:W,onChange:T===`connected`?ne:G,placeholder:T===`connected`?u.connectedSearchPlaceholder:u.discoverSearchPlaceholder}),secondary:(0,$.jsx)(Qt,{onRefresh:T===`connected`&&p?Me:void 0,refreshing:P.loading,refreshLabel:u.refreshConnections,onBrowseCatalog:()=>Ne(`discover`),onAddCustomServer:We,addLabel:u.addConnection,browseLabel:u.addFromCatalog,customLabel:u.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:l.capabilitiesHub.moreActions})}),[U,u,W,p,r,Me,l.capabilitiesHub.moreActions,We,Ne,P.loading,T]);(0,Q.useLayoutEffect)(()=>e?(t?.(qe),()=>t?.(null)):(Ge({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:u.title})}),end:(0,$.jsx)(At,{contribution:qe})}),()=>Ke()),[Ke,u.title,e,qe,t,Ge]);let Ze=(0,Q.useMemo)(()=>P.instances.map(e=>({instance:e,value:Wt(e,Be.get(e.connectorId))})),[Be,P.instances]),Qe=(0,Q.useMemo)(()=>new Map(Ze.map(({instance:e,value:t})=>[e.instanceId,t])),[Ze]),$e=(0,Q.useMemo)(()=>P.instances.filter(e=>j(e,U)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Qe.get(e.instanceId)?.state??`checking`,i=Qe.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[U,Qe,P.instances]),et=(0,Q.useMemo)(()=>$e.filter(e=>Qe.get(e.instanceId)?.state===`needs_setup`),[Qe,$e]),tt=(0,Q.useMemo)(()=>$e.filter(e=>Qe.get(e.instanceId)?.state!==`needs_setup`),[Qe,$e]),nt=(0,Q.useMemo)(()=>Ee.filter(e=>M(e,U)),[U,Ee]),rt=(0,Q.useMemo)(()=>{let e=U.trim().toLowerCase();return n.filter(t=>[t.name,t.description,...(t.setup?.authorizations??[]).map(e=>e.title),...(t.components?.mcp??[]).map(e=>e.name)].filter(Boolean).join(` `).toLowerCase().includes(e))},[U,n]),it=$e.length+nt.length+rt.length,at=(0,Q.useMemo)(()=>P.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&k(e)),[P.catalog]),ot=(0,Q.useMemo)(()=>K===`recommended`?[]:K===`builtin`?at:K===`all`?Jn([...at,...P.registryCatalog]):P.registryCatalog,[at,K,P.registryCatalog]),st=(0,Q.useMemo)(()=>{let e=b?ot.filter(e=>e.understanding?.mode===`activity`):Jn(ot).filter(e=>!O.has(v(e.id)));return A(q===`all`?e:e.filter(e=>Ht(e).includes(q)),W,oe)},[oe,W,ot,b,q,O]),ct=(0,Q.useMemo)(()=>Vt.filter(e=>ot.some(t=>Ht(t).includes(e))),[ot]);(0,Q.useEffect)(()=>{q!==`all`&&!ct.includes(q)&&ce(`all`)},[ct,q]);let lt=T===`discover`&&K!==`builtin`&&!!(H&&B<H),ut=(0,Q.useMemo)(()=>P.instances.find(e=>e.instanceId===he)??ge,[he,ge,P.instances]),dt=(0,Q.useMemo)(()=>[{value:Hn,label:r===`zh`?`推荐服务`:`Recommended services`},{value:`all`,label:u.discoverSourceAll},{value:Un,label:u.discoverSourceBuiltin},...Pe.map(e=>({value:e.id,label:e.displayName}))],[u.discoverSourceAll,u.discoverSourceBuiltin,Pe,r]),ft=[{id:`connected`,label:u.tabConnected,count:De},{id:`discover`,label:u.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:Y(`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:[p?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:u.tokenHint}),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:u.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.understandingSetupHint})]}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>m(x),children:u.understandingSetupDone})]}):null,S?(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:u.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.recoverySetupHint})]}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>m(x),children:u.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)(Je,{items:ft,activeTab:T,onChange:Ne,ariaLabel:u.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),P.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:P.error}):null,T===`connected`&&p?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:P.loading?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":u.loading,children:It.slice(0,3).map(e=>(0,$.jsx)(Bt,{},e))}):De===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.connectionsEmpty}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Ne(`discover`),children:u.addFromCatalog})]}):it===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:u.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[et.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:u.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:et.length})]}),(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:et.map(e=>(0,$.jsx)(Cn,{instance:e,definition:Be.get(e.connectorId),highlighted:e.instanceId===ve,onOpenDetails:e=>{ye(null),Z(e.instanceId),_e(e)},t:u},e.instanceId))})]}):null,tt.length||rt.length?(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[tt.map(e=>(0,$.jsx)(Cn,{instance:e,definition:Be.get(e.connectorId),highlighted:e.instanceId===ve,onOpenDetails:e=>{ye(null),Z(e.instanceId),_e(e)},t:u},e.instanceId)),rt.map(e=>(0,$.jsx)(sn,{extension:e,language:r,onOpen:()=>m(Dt(e.pluginId,`connections`,e.authorizationStatus===`required`))},e.id))]})}):null,nt.length||!U.trim()?(0,$.jsx)(an,{servers:nt,lastChecks:ke,t:d,cs:u,onAdd:We,onEdit:e=>xe({mode:`edit`,row:structuredClone(e)}),onRemove:Ue}):null]})}):null,T===`discover`&&p?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[b?null:(0,$.jsx)(Xe,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":u.taskFilterAria,indicatorClassName:`rounded-lg bg-surface-active`,children:[`all`,...ct].map(e=>(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,q===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":q===e,onClick:()=>ce(e),children:e===`all`?u.taskAll:u.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:Y(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,b?`grid-cols-1`:`grid-cols-2`),children:[b?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(w,{value:K,options:dt,placeholder:u.discoverSourceAll,allowEmpty:!1,ariaLabel:u.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ae})}),K===`recommended`?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(w,{value:oe,options:[{value:`name`,label:u.sortName},{value:`source`,label:u.sortSource}],placeholder:u.sortName,allowEmpty:!1,ariaLabel:u.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>se(e)})})]})]}),K===`recommended`?(0,$.jsx)(y,{layout:`cards`,initialCount:6,query:W,onChanged:async()=>{await Me(),await Ce()}}):(P.loading||I)&&st.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":u.loading,children:It.map(e=>(0,$.jsx)(zt,{},e))}):st.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:u.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[I?(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":u.loading,children:(0,$.jsx)(z,{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:st.map(e=>(0,$.jsx)(Pt,{connector:e,installed:Le.has(e.id)||Lt(e,P.instances),onInstall:e=>{if(e.source===`store`){Ve(e.id);return}J(re(e))},onOpenDetails:e.source===`store`?void 0:de,t:u},e.id))}),lt?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:I||R,onClick:()=>void Fe({page:B+1,append:!0}),children:[I?(0,$.jsx)(z,{className:`size-4 animate-spin`}):null,u.loadMore]})}):null]})]}):null]}),le?(0,$.jsx)(ie,{draft:le,onChange:J,onClose:()=>J(null),t:u,onInstalled:async e=>{await Me(),await Ce(),ye(e.instanceId),Ne(`connected`)}}):null,ue?(0,$.jsx)(Jt,{connector:ue,installed:Le.has(ue.id)||Lt(ue,P.instances),onClose:()=>de(null),onInstall:e=>J(re(e)),t:u}):null,ut?(0,$.jsx)(Sn,{instance:ut,definition:Be.get(ut.connectorId),onClose:()=>{Z(null),_e(null)},onChanged:Me,t:u,mcp:d}):null,be?(0,$.jsx)(Vn,{open:!0,mode:be.mode,initialRow:be.row,lastCheck:be.mode===`edit`?ke[be.row.id]:void 0,existingCustomServers:Ee,config:we,managedServerIds:He,t:d,cs:u,onClose:()=>xe(null),onSaved:async()=>{await Ce(),await Me(),Ne(`connected`)}},`${be.mode}-${be.row.clientKey}`):null]})})}export{Xn as ConnectorsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{n as i}from"./locale-store-B6OrWgY1.js";import{t as a}from"./calendar-days-hw_Y-g-s.js";import{t as ee}from"./chevron-left-DqFhpbvK.js";import{t as te}from"./chevron-right-BweFrslA.js";import{c as ne,l as re,u as ie}from"./popover-select-CEMWIrtY.js";import{t as ae}from"./cn-0WouolD0.js";import{c as oe,n as se,s as ce}from"./dist-GJ8-1PAx.js";var o=e(t(),1),le=n();function s(e){return String(e).padStart(2,`0`)}function ue(e){return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())}`}function de(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 fe(e,t){let n=de(e);return n?t===`zh`?`${n.getFullYear()}/${s(n.getMonth()+1)}/${s(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var c=r();function pe(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 l(e){let t=(0,le.c)(106),{value:n,onChange:r,disabled:s,className:l,ariaLabel:ve,placeholder:ye,min:u,max:d}=e,f=i(_e),p=f===`zh`?`zh-CN`:`en`,be;t[0]===n?be=t[1]:(be=de(n),t[0]=n,t[1]=be);let m=be,[h,xe]=(0,o.useState)(!1),[Se,Ce]=(0,o.useState)(null),g;t[2]===m?g=t[3]:(g=()=>m??new Date,t[2]=m,t[3]=g);let[_,we]=(0,o.useState)(g),Te=ne(Se),Ee=ie(re(),Te!==null),v=+(f===`zh`),y,b;t[4]!==h||t[5]!==n?(y=()=>{if(!h)return;let e=de(n);e&&we(e)},b=[h,n],t[4]=h,t[5]=n,t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,o.useEffect)(y,b);let x;t[8]!==_||t[9]!==v?(x=pe(_,v),t[8]=_,t[9]=v,t[10]=x):x=t[10];let De=x,S;if(t[11]!==p||t[12]!==v){let e=new Date(2026,7,23,12);S=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+v+n),new Intl.DateTimeFormat(p,{weekday:`narrow`}).format(r)}),t[11]=p,t[12]=v,t[13]=S}else S=t[13];let Oe=S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=ue(new Date),t[14]=C):C=t[14];let w=C,T;t[15]===m?T=t[16]:(T=m?ue(m):``,t[15]=m,t[16]=T);let E=T,D;t[17]!==p||t[18]!==_?(D=new Intl.DateTimeFormat(p,{year:`numeric`,month:`long`}).format(_),t[17]=p,t[18]=_,t[19]=D):D=t[19];let ke=D,O;t[20]===r?O=t[21]:(O=e=>{r(e),xe(!1)},t[20]=r,t[21]=O);let k=O,Ae=oe,je=s&&`cursor-not-allowed opacity-50`,A;t[22]!==l||t[23]!==je?(A=ae(`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`,je,l),t[22]=l,t[23]=je,t[24]=A):A=t[24];let Me=!n&&`text-fg-subtle`,j;t[25]===Me?j=t[26]:(j=ae(`min-w-0 truncate tabular-nums`,Me),t[25]=Me,t[26]=j);let M;t[27]!==f||t[28]!==ye||t[29]!==n?(M=fe(n,f)||ye||(f===`zh`?`选择日期`:`Select date`),t[27]=f,t[28]=ye,t[29]=n,t[30]=M):M=t[30];let N;t[31]!==j||t[32]!==M?(N=(0,c.jsx)(`span`,{className:j,children:M}),t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,c.jsx)(a,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=P):P=t[34];let F;t[35]!==ve||t[36]!==s||t[37]!==A||t[38]!==N?(F=(0,c.jsx)(ce,{asChild:!0,children:(0,c.jsxs)(`button`,{ref:Ce,type:`button`,disabled:s,"aria-label":ve,className:A,children:[N,P]})}),t[35]=ve,t[36]=s,t[37]=A,t[38]=N,t[39]=F):F=t[39];let Ne=oe,Pe=Te??void 0,Fe=oe,Ie=Te??void 0,Le=ae(Ee,`max-h-[var(--radix-popover-content-available-height)] w-[19rem] overflow-y-auto rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Re=f===`zh`?`上个月`:`Previous month`,I,L;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>we(ge),L=(0,c.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[40]=I,t[41]=L):(I=t[40],L=t[41]);let R;t[42]===Re?R=t[43]:(R=(0,c.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":Re,onClick:I,children:L}),t[42]=Re,t[43]=R);let z;t[44]===ke?z=t[45]:(z=(0,c.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ke}),t[44]=ke,t[45]=z);let ze=f===`zh`?`下个月`:`Next month`,B,V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>we(he),V=(0,c.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[46]=B,t[47]=V):(B=t[46],V=t[47]);let H;t[48]===ze?H=t[49]:(H=(0,c.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":ze,onClick:B,children:V}),t[48]=ze,t[49]=H);let U;t[50]!==R||t[51]!==z||t[52]!==H?(U=(0,c.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[R,z,H]}),t[50]=R,t[51]=z,t[52]=H,t[53]=U):U=t[53];let W;t[54]===Oe?W=t[55]:(W=(0,c.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:Oe.map(me)}),t[54]=Oe,t[55]=W);let G;if(t[56]!==De||t[57]!==p||t[58]!==d||t[59]!==u||t[60]!==k||t[61]!==E||t[62]!==_){let e;t[64]!==p||t[65]!==d||t[66]!==u||t[67]!==k||t[68]!==E||t[69]!==_?(e=e=>{let t=ue(e),n=t===E,r=t===w,i=e.getMonth()!==_.getMonth(),a=!!(u&&t<u||d&&t>d);return(0,c.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":a,disabled:a,"aria-label":new Intl.DateTimeFormat(p,{dateStyle:`full`}).format(e),className:ae(`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`,i&&`text-fg-disabled`,a&&`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:()=>k(t),children:e.getDate()},t)},t[64]=p,t[65]=d,t[66]=u,t[67]=k,t[68]=E,t[69]=_,t[70]=e):e=t[70],G=De.map(e),t[56]=De,t[57]=p,t[58]=d,t[59]=u,t[60]=k,t[61]=E,t[62]=_,t[63]=G}else G=t[63];let K;t[71]===G?K=t[72]:(K=(0,c.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:G}),t[71]=G,t[72]=K);let Be=!n,q;t[73]===k?q=t[74]:(q=()=>k(``),t[73]=k,t[74]=q);let Ve=f===`zh`?`清除`:`Clear`,J;t[75]!==Be||t[76]!==q||t[77]!==Ve?(J=(0,c.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:q,children:Ve}),t[75]=Be,t[76]=q,t[77]=Ve,t[78]=J):J=t[78];let He=!!(u&&w<u||d&&w>d),Y;t[79]===k?Y=t[80]:(Y=()=>k(w),t[79]=k,t[80]=Y);let Ue=f===`zh`?`今天`:`Today`,X;t[81]!==He||t[82]!==Y||t[83]!==Ue?(X=(0,c.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:Y,children:Ue}),t[81]=He,t[82]=Y,t[83]=Ue,t[84]=X):X=t[84];let Z;t[85]!==J||t[86]!==X?(Z=(0,c.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[J,X]}),t[85]=J,t[86]=X,t[87]=Z):Z=t[87];let We;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,c.jsx)(se,{className:`fill-surface-overlay`}),t[88]=We):We=t[88];let Q;t[89]!==Fe.Content||t[90]!==Ie||t[91]!==Le||t[92]!==U||t[93]!==W||t[94]!==K||t[95]!==Z?(Q=(0,c.jsxs)(Fe.Content,{align:`start`,sideOffset:6,collisionPadding:12,collisionBoundary:Ie,className:Le,children:[U,W,K,Z,We]}),t[89]=Fe.Content,t[90]=Ie,t[91]=Le,t[92]=U,t[93]=W,t[94]=K,t[95]=Z,t[96]=Q):Q=t[96];let $;t[97]!==Ne.Portal||t[98]!==Pe||t[99]!==Q?($=(0,c.jsx)(Ne.Portal,{container:Pe,children:Q}),t[97]=Ne.Portal,t[98]=Pe,t[99]=Q,t[100]=$):$=t[100];let Ge;return t[101]!==h||t[102]!==Ae.Root||t[103]!==F||t[104]!==$?(Ge=(0,c.jsxs)(Ae.Root,{open:h,onOpenChange:xe,children:[F,$]}),t[101]=h,t[102]=Ae.Root,t[103]=F,t[104]=$,t[105]=Ge):Ge=t[105],Ge}function me(e,t){return(0,c.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function he(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function ge(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function _e(e){return e.language}export{l 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{n as i}from"./locale-store-CAZaC05J.js";import{t as a}from"./calendar-days-hw_Y-g-s.js";import{t as ee}from"./chevron-left-DqFhpbvK.js";import{t as te}from"./chevron-right-BweFrslA.js";import{c as ne,l as re,u as ie}from"./popover-select-CEMWIrtY.js";import{t as ae}from"./cn-0WouolD0.js";import{c as oe,n as se,s as ce}from"./dist-GJ8-1PAx.js";var o=e(t(),1),le=n();function s(e){return String(e).padStart(2,`0`)}function ue(e){return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())}`}function de(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 fe(e,t){let n=de(e);return n?t===`zh`?`${n.getFullYear()}/${s(n.getMonth()+1)}/${s(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var c=r();function pe(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 l(e){let t=(0,le.c)(106),{value:n,onChange:r,disabled:s,className:l,ariaLabel:ve,placeholder:ye,min:u,max:d}=e,f=i(_e),p=f===`zh`?`zh-CN`:`en`,be;t[0]===n?be=t[1]:(be=de(n),t[0]=n,t[1]=be);let m=be,[h,xe]=(0,o.useState)(!1),[Se,Ce]=(0,o.useState)(null),g;t[2]===m?g=t[3]:(g=()=>m??new Date,t[2]=m,t[3]=g);let[_,we]=(0,o.useState)(g),Te=ne(Se),Ee=ie(re(),Te!==null),v=+(f===`zh`),y,b;t[4]!==h||t[5]!==n?(y=()=>{if(!h)return;let e=de(n);e&&we(e)},b=[h,n],t[4]=h,t[5]=n,t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,o.useEffect)(y,b);let x;t[8]!==_||t[9]!==v?(x=pe(_,v),t[8]=_,t[9]=v,t[10]=x):x=t[10];let De=x,S;if(t[11]!==p||t[12]!==v){let e=new Date(2026,7,23,12);S=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+v+n),new Intl.DateTimeFormat(p,{weekday:`narrow`}).format(r)}),t[11]=p,t[12]=v,t[13]=S}else S=t[13];let Oe=S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=ue(new Date),t[14]=C):C=t[14];let w=C,T;t[15]===m?T=t[16]:(T=m?ue(m):``,t[15]=m,t[16]=T);let E=T,D;t[17]!==p||t[18]!==_?(D=new Intl.DateTimeFormat(p,{year:`numeric`,month:`long`}).format(_),t[17]=p,t[18]=_,t[19]=D):D=t[19];let ke=D,O;t[20]===r?O=t[21]:(O=e=>{r(e),xe(!1)},t[20]=r,t[21]=O);let k=O,Ae=oe,je=s&&`cursor-not-allowed opacity-50`,A;t[22]!==l||t[23]!==je?(A=ae(`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`,je,l),t[22]=l,t[23]=je,t[24]=A):A=t[24];let Me=!n&&`text-fg-subtle`,j;t[25]===Me?j=t[26]:(j=ae(`min-w-0 truncate tabular-nums`,Me),t[25]=Me,t[26]=j);let M;t[27]!==f||t[28]!==ye||t[29]!==n?(M=fe(n,f)||ye||(f===`zh`?`选择日期`:`Select date`),t[27]=f,t[28]=ye,t[29]=n,t[30]=M):M=t[30];let N;t[31]!==j||t[32]!==M?(N=(0,c.jsx)(`span`,{className:j,children:M}),t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,c.jsx)(a,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=P):P=t[34];let F;t[35]!==ve||t[36]!==s||t[37]!==A||t[38]!==N?(F=(0,c.jsx)(ce,{asChild:!0,children:(0,c.jsxs)(`button`,{ref:Ce,type:`button`,disabled:s,"aria-label":ve,className:A,children:[N,P]})}),t[35]=ve,t[36]=s,t[37]=A,t[38]=N,t[39]=F):F=t[39];let Ne=oe,Pe=Te??void 0,Fe=oe,Ie=Te??void 0,Le=ae(Ee,`max-h-[var(--radix-popover-content-available-height)] w-[19rem] overflow-y-auto rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Re=f===`zh`?`上个月`:`Previous month`,I,L;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>we(ge),L=(0,c.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[40]=I,t[41]=L):(I=t[40],L=t[41]);let R;t[42]===Re?R=t[43]:(R=(0,c.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":Re,onClick:I,children:L}),t[42]=Re,t[43]=R);let z;t[44]===ke?z=t[45]:(z=(0,c.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ke}),t[44]=ke,t[45]=z);let ze=f===`zh`?`下个月`:`Next month`,B,V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>we(he),V=(0,c.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[46]=B,t[47]=V):(B=t[46],V=t[47]);let H;t[48]===ze?H=t[49]:(H=(0,c.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":ze,onClick:B,children:V}),t[48]=ze,t[49]=H);let U;t[50]!==R||t[51]!==z||t[52]!==H?(U=(0,c.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[R,z,H]}),t[50]=R,t[51]=z,t[52]=H,t[53]=U):U=t[53];let W;t[54]===Oe?W=t[55]:(W=(0,c.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:Oe.map(me)}),t[54]=Oe,t[55]=W);let G;if(t[56]!==De||t[57]!==p||t[58]!==d||t[59]!==u||t[60]!==k||t[61]!==E||t[62]!==_){let e;t[64]!==p||t[65]!==d||t[66]!==u||t[67]!==k||t[68]!==E||t[69]!==_?(e=e=>{let t=ue(e),n=t===E,r=t===w,i=e.getMonth()!==_.getMonth(),a=!!(u&&t<u||d&&t>d);return(0,c.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":a,disabled:a,"aria-label":new Intl.DateTimeFormat(p,{dateStyle:`full`}).format(e),className:ae(`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`,i&&`text-fg-disabled`,a&&`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:()=>k(t),children:e.getDate()},t)},t[64]=p,t[65]=d,t[66]=u,t[67]=k,t[68]=E,t[69]=_,t[70]=e):e=t[70],G=De.map(e),t[56]=De,t[57]=p,t[58]=d,t[59]=u,t[60]=k,t[61]=E,t[62]=_,t[63]=G}else G=t[63];let K;t[71]===G?K=t[72]:(K=(0,c.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:G}),t[71]=G,t[72]=K);let Be=!n,q;t[73]===k?q=t[74]:(q=()=>k(``),t[73]=k,t[74]=q);let Ve=f===`zh`?`清除`:`Clear`,J;t[75]!==Be||t[76]!==q||t[77]!==Ve?(J=(0,c.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:q,children:Ve}),t[75]=Be,t[76]=q,t[77]=Ve,t[78]=J):J=t[78];let He=!!(u&&w<u||d&&w>d),Y;t[79]===k?Y=t[80]:(Y=()=>k(w),t[79]=k,t[80]=Y);let Ue=f===`zh`?`今天`:`Today`,X;t[81]!==He||t[82]!==Y||t[83]!==Ue?(X=(0,c.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:Y,children:Ue}),t[81]=He,t[82]=Y,t[83]=Ue,t[84]=X):X=t[84];let Z;t[85]!==J||t[86]!==X?(Z=(0,c.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[J,X]}),t[85]=J,t[86]=X,t[87]=Z):Z=t[87];let We;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,c.jsx)(se,{className:`fill-surface-overlay`}),t[88]=We):We=t[88];let Q;t[89]!==Fe.Content||t[90]!==Ie||t[91]!==Le||t[92]!==U||t[93]!==W||t[94]!==K||t[95]!==Z?(Q=(0,c.jsxs)(Fe.Content,{align:`start`,sideOffset:6,collisionPadding:12,collisionBoundary:Ie,className:Le,children:[U,W,K,Z,We]}),t[89]=Fe.Content,t[90]=Ie,t[91]=Le,t[92]=U,t[93]=W,t[94]=K,t[95]=Z,t[96]=Q):Q=t[96];let $;t[97]!==Ne.Portal||t[98]!==Pe||t[99]!==Q?($=(0,c.jsx)(Ne.Portal,{container:Pe,children:Q}),t[97]=Ne.Portal,t[98]=Pe,t[99]=Q,t[100]=$):$=t[100];let Ge;return t[101]!==h||t[102]!==Ae.Root||t[103]!==F||t[104]!==$?(Ge=(0,c.jsxs)(Ae.Root,{open:h,onOpenChange:xe,children:[F,$]}),t[101]=h,t[102]=Ae.Root,t[103]=F,t[104]=$,t[105]=Ge):Ge=t[105],Ge}function me(e,t){return(0,c.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function he(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function ge(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function _e(e){return e.language}export{l 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{n as i}from"./locale-store-B6OrWgY1.js";import{t as a}from"./messages-jwdBhfL9.js";import{t as o}from"./resource-unavailable-CUNbPkdj.js";import{t as s}from"./chevron-down-ccbiQQz_.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./desktop-pet-narrative-ChwjpnsG.js";import{t as u}from"./desktop-pet-sprite-D5YYq2zC.js";var d=e(t(),1),f=n(),p=9e4,m=3e4,h=20*6e4,g=45e3,_=45*6e4,v=58;function y(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=p}function b(e,t){return e.state===`running`&&t-e.timestamp>=m}function x(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 S(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>v?`${n.slice(0,v-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function C(e,t,n){if(b(e,t))return n.stale;if(y(e,t))return n.longRunning}function w(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function ee(e){let t=e.now-e.lastActivityAt,n=t>=h?(t-h)%_: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<=g&&e.now>=e.dismissedUntil}function T(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:b(e,n)||t===`playful`||t===`companion`&&y(e,n)?`notice`:`ambient`}function E(e,t,n,r){let i=T(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var D=8e3;function O(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+D:void 0}}function k(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]=O(t,e))}return n}function A(e,t){return t?.runId===e.runId&&t.state===e.state}function j(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 M(e){return e?`/chat/${e.conversationId}`:void 0}var N=r();function P(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??l(e.phase):`idle`}function F(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 I(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return F(r?.success,t);if(t.state===`waiting`)return F(r?.waiting,t);if(t.state===`error`)return F(r?.error,t)}function L(e,t,n){return e?n?`${e} · ${t}`:e:t}function R(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 z(){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 B(){let e=a(i(e=>e.language)).desktopPet,[t,n]=(0,d.useState)(z),[r,o]=(0,d.useState)({}),[l,f]=(0,d.useState)({}),[p,m]=(0,d.useState)(Date.now()),[h,g]=(0,d.useState)(()=>Date.now()),[v,y]=(0,d.useState)(0),[b,T]=(0,d.useState)(null),D=(0,d.useRef)(null),O=(0,d.useRef)(!1),B=(0,d.useRef)(null),V=(0,d.useRef)(null),H=(0,d.useRef)(null),U=(0,d.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),W=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),G=(0,d.useMemo)(()=>j(Object.values(r),p),[r,p]),K=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>!A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),q=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),J=K[0]??G[0],te=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,ne=b??(J?P(J):te),Y=e.personaPhrases[U?.persona?.tone??`calm`],X=ee({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:K.length,activeCount:G.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,d.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),o(t=>k(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>o(t=>(g(Date.now()),k(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,d.useEffect)(()=>{if(!t.relationshipMoment)return;T(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>T(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,d.useLayoutEffect)(()=>{let e=B.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[V.current,H.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*W),s=o+(V.current?8+V.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),V.current&&r.observe(V.current),H.current&&r.observe(H.current),n(),()=>r.disconnect()},[X,K.length,t.prefs.collapsed,W]);let Z=(e=J)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.conversationId,e.runId),o(t=>{let{[e.conversationId]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(M(e))},re=async()=>{if(Object.keys(l).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,d.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,d.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,T(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,d.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&&(T(`released`),window.setTimeout(()=>T(null),700),O.current=!0,window.setTimeout(()=>{O.current=!1},0))},[]);(0,d.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=()=>{O.current||Z()};if(!U)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*W)}px`,"--desktop-pet-menu-size":`${Math.round(28*W)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*W)}px`},$=t.prefs.collapsed?K.length:q;return(0,N.jsxs)(`div`,{ref:B,className:`desktop-pet-window`,"data-reduced-motion":t.prefs.reducedMotion,style:se,children:[!t.prefs.collapsed&&K.length>0?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue`,children:K.map(t=>{let n=C(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=S(t,e.tipCompleteSummary),i=w(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),a=r??n??i??t.action,o=L(I(U,t,Y),a,!!(r||n||i)),s=R(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:t.sessionLabel}),(0,N.jsxs)(`span`,{children:[o,r||n?``:x(t,p,e.tipTargetSuffix)]})]}),s?(0,N.jsx)(`span`,{className:`desktop-pet-session-cta`,children:s}):null]}),(0,N.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,N.jsx)(c,{size:12})})]},t.conversationId)})}):null,X?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:e.idleTipTitle}),(0,N.jsx)(`span`,{children:F(U.persona?.phrases?.greeting??Y.greeting,{conversationId:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+_),children:(0,N.jsx)(c,{size:12})})]})}):null,(0,N.jsxs)(`div`,{ref:H,className:`desktop-pet-stage`,children:[(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,N.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,N.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!J&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&T(`greet`)},onPointerLeave:()=>{D.current||T(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Q,title:e.openApp,children:(0,N.jsx)(u,{animationKey:J?.runId,pet:U,action:ne,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*W)},U.id)})]})]})}function V(){let e=(0,f.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=window.electronAPI?.pet?(0,N.jsx)(B,{}):(0,N.jsx)(o,{kind:`desktop`,backTo:`/`}),e[0]=t):t=e[0],t}export{V 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{n as i}from"./locale-store-CAZaC05J.js";import{t as a}from"./messages-C7fckbyG.js";import{t as o}from"./resource-unavailable-D15jzjV_.js";import{t as s}from"./chevron-down-ccbiQQz_.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./desktop-pet-narrative-ChwjpnsG.js";import{t as u}from"./desktop-pet-sprite-D5YYq2zC.js";var d=e(t(),1),f=n(),p=9e4,m=3e4,h=20*6e4,g=45e3,_=45*6e4,v=58;function y(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=p}function b(e,t){return e.state===`running`&&t-e.timestamp>=m}function x(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 S(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>v?`${n.slice(0,v-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function C(e,t,n){if(b(e,t))return n.stale;if(y(e,t))return n.longRunning}function w(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function ee(e){let t=e.now-e.lastActivityAt,n=t>=h?(t-h)%_: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<=g&&e.now>=e.dismissedUntil}function T(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:b(e,n)||t===`playful`||t===`companion`&&y(e,n)?`notice`:`ambient`}function E(e,t,n,r){let i=T(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var D=8e3;function O(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+D:void 0}}function k(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]=O(t,e))}return n}function A(e,t){return t?.runId===e.runId&&t.state===e.state}function j(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 M(e){return e?`/chat/${e.conversationId}`:void 0}var N=r();function P(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??l(e.phase):`idle`}function F(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 I(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return F(r?.success,t);if(t.state===`waiting`)return F(r?.waiting,t);if(t.state===`error`)return F(r?.error,t)}function L(e,t,n){return e?n?`${e} · ${t}`:e:t}function R(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 z(){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 B(){let e=a(i(e=>e.language)).desktopPet,[t,n]=(0,d.useState)(z),[r,o]=(0,d.useState)({}),[l,f]=(0,d.useState)({}),[p,m]=(0,d.useState)(Date.now()),[h,g]=(0,d.useState)(()=>Date.now()),[v,y]=(0,d.useState)(0),[b,T]=(0,d.useState)(null),D=(0,d.useRef)(null),O=(0,d.useRef)(!1),B=(0,d.useRef)(null),V=(0,d.useRef)(null),H=(0,d.useRef)(null),U=(0,d.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),W=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),G=(0,d.useMemo)(()=>j(Object.values(r),p),[r,p]),K=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>!A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),q=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),J=K[0]??G[0],te=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,ne=b??(J?P(J):te),Y=e.personaPhrases[U?.persona?.tone??`calm`],X=ee({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:K.length,activeCount:G.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,d.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),o(t=>k(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>o(t=>(g(Date.now()),k(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,d.useEffect)(()=>{if(!t.relationshipMoment)return;T(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>T(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,d.useLayoutEffect)(()=>{let e=B.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[V.current,H.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*W),s=o+(V.current?8+V.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),V.current&&r.observe(V.current),H.current&&r.observe(H.current),n(),()=>r.disconnect()},[X,K.length,t.prefs.collapsed,W]);let Z=(e=J)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.conversationId,e.runId),o(t=>{let{[e.conversationId]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(M(e))},re=async()=>{if(Object.keys(l).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,d.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,d.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,T(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,d.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&&(T(`released`),window.setTimeout(()=>T(null),700),O.current=!0,window.setTimeout(()=>{O.current=!1},0))},[]);(0,d.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=()=>{O.current||Z()};if(!U)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*W)}px`,"--desktop-pet-menu-size":`${Math.round(28*W)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*W)}px`},$=t.prefs.collapsed?K.length:q;return(0,N.jsxs)(`div`,{ref:B,className:`desktop-pet-window`,"data-reduced-motion":t.prefs.reducedMotion,style:se,children:[!t.prefs.collapsed&&K.length>0?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue`,children:K.map(t=>{let n=C(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=S(t,e.tipCompleteSummary),i=w(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),a=r??n??i??t.action,o=L(I(U,t,Y),a,!!(r||n||i)),s=R(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:t.sessionLabel}),(0,N.jsxs)(`span`,{children:[o,r||n?``:x(t,p,e.tipTargetSuffix)]})]}),s?(0,N.jsx)(`span`,{className:`desktop-pet-session-cta`,children:s}):null]}),(0,N.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,N.jsx)(c,{size:12})})]},t.conversationId)})}):null,X?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:e.idleTipTitle}),(0,N.jsx)(`span`,{children:F(U.persona?.phrases?.greeting??Y.greeting,{conversationId:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+_),children:(0,N.jsx)(c,{size:12})})]})}):null,(0,N.jsxs)(`div`,{ref:H,className:`desktop-pet-stage`,children:[(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,N.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,N.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!J&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&T(`greet`)},onPointerLeave:()=>{D.current||T(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Q,title:e.openApp,children:(0,N.jsx)(u,{animationKey:J?.runId,pet:U,action:ne,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*W)},U.id)})]})]})}function V(){let e=(0,f.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=window.electronAPI?.pet?(0,N.jsx)(B,{}):(0,N.jsx)(o,{kind:`desktop`,backTo:`/`}),e[0]=t):t=e[0],t}export{V 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{u as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as a}from"./locale-store-B6OrWgY1.js";import{t as o}from"./messages-jwdBhfL9.js";import{t as s}from"./resource-unavailable-CUNbPkdj.js";import{t as c}from"./chevron-down-ccbiQQz_.js";import{n as l,r as u}from"./popover-select-CEMWIrtY.js";import{t as d}from"./circle-alert-BEjgurr2.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./message-square-plus-XP0tGdlV.js";import{n as m,t as h}from"./wand-sparkles-CkSL-3Fy.js";import{t as g}from"./rotate-ccw-JM1TBLpp.js";import{t as _}from"./cn-0WouolD0.js";import{t as v}from"./skeleton-BI5TyibZ.js";import{n as y}from"./interaction-BdhHBbYa.js";import{n as b}from"./electron-env-DHOGevH3.js";import{t as x}from"./refresh-button-DiWdGAaX.js";import{t as S}from"./desktop-pet-sprite-D5YYq2zC.js";import{n as C,t as w}from"./settings-page-header-BAN34UQi.js";import"./settings-page-layout-B5TVFBV2.js";var T=n(),E=e(t(),1),D=r();function O(e){let t=(0,T.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,D.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,D.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,D.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,D.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,D.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 k(){let e=o(a(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,E.useState)(null),[T,k]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),M=typeof window<`u`?window.electronAPI?.pet:void 0,N=(0,E.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),P=(0,E.useCallback)(async()=>{if(M){k(!0);try{r(await M.getState())}finally{k(!1)}}},[M]);if((0,E.useEffect)(()=>{if(M)return P(),M.onStateChanged(r)},[M,P]),!b()||!M)return(0,D.jsx)(s,{kind:`desktop`,backTo:`/settings/overview`});if(!n)return(0,D.jsxs)(C,{gap:`gap-4`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle}),(0,D.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-24 rounded-xl`}),(0,D.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(v,{className:`h-16 rounded-xl`},t))})]})})]});let F=async e=>{k(!0);try{r(await M.setPrefs(e))}finally{k(!1)}},I=async e=>{e?(await M.show(),r(await M.getState())):r(await M.setPrefs({enabled:!1}))},L=e=>{F({selectedPetId:e})},R=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},z=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},B=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=R(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},V=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),H=()=>{z(e.createChatDraft)},U=t=>{let n=V(e.optimizeChatDraft,{id:t.id,name:R(t).name,description:R(t).description,sourcePrompt:B(t)});z(n)},W=t=>{let n=V(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails});z(n)},G=A??n.prefs.sizePercent,K=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),q=async(e=G)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));j(null),t!==n.prefs.sizePercent&&await F({sizePercent:t})};return(0,D.jsxs)(C,{gap:`gap-5`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle,actions:(0,D.jsx)(x,{className:`size-9 shrink-0 p-0`,disabled:T,label:e.refresh,onClick:P})}),(0,D.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-6`,children:[(0,D.jsx)(`div`,{className:`grid h-40 w-40 shrink-0 place-items-center self-center rounded-xl bg-surface-hover/35`,children:N?(0,D.jsx)(S,{pet:N,action:`idle`,displayHeight:Math.round(104*G/100),reducedMotion:n.prefs.reducedMotion}):null}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-2`,children:[(0,D.jsx)(`h2`,{className:`break-words text-xl font-semibold text-fg`,children:N?R(N).name:e.title}),(0,D.jsx)(O,{title:e.enable,checked:n.prefs.enabled,disabled:T,onChange:e=>void I(e)})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondSummary.replace(`{days}`,String(K)).replace(`{tasks}`,String(n.relationship.completedTaskCount))}),n.pets.length>1?(0,D.jsx)(`div`,{className:`mt-4 max-w-56`,children:(0,D.jsx)(l,{"aria-label":e.petList,value:N?.id??``,onChange:e=>L(e.target.value),disabled:T,children:n.pets.map(e=>(0,D.jsx)(u,{value:e.id,children:R(e).name},e.id))})}):null,N&&!N.builtin?(0,D.jsxs)(`button`,{type:`button`,onClick:()=>U(N),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,D.jsx)(m,{className:`size-3.5`}),e.optimizeInChat]}):null]})]}),(0,D.jsx)(`div`,{className:`border-t border-edge px-5 py-2`,children:(0,D.jsxs)(`button`,{type:`button`,onClick:H,className:_(`inline-flex min-h-10 items-center gap-2 text-xs font-medium text-fg-muted hover:text-accent-fg`,y.press),children:[(0,D.jsx)(h,{className:`size-4`}),e.createTitle]})})]}),n.petIssues.length>0?(0,D.jsxs)(`section`,{className:`rounded-xl border border-danger/20 bg-danger/5 p-4`,children:[(0,D.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,D.jsx)(d,{className:`size-4`}),e.invalidPets]}),(0,D.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.petIssues.map(t=>(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,D.jsx)(`p`,{className:`break-words`,children:t.reason}),(0,D.jsxs)(`details`,{className:`mt-1`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer`,children:e.issueDetails}),(0,D.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:t.dir}),t.details?.length?(0,D.jsx)(`p`,{className:`mt-1 break-words`,children:t.details.join(`; `)}):null]})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>W(t),className:`inline-flex min-h-9 shrink-0 items-center gap-1.5 text-xs font-medium text-danger`,children:[(0,D.jsx)(p,{className:`size-3.5`}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null,(0,D.jsxs)(`section`,{"aria-label":e.displayGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.displayGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.showOnStartup,checked:n.prefs.showOnStartup,disabled:T,onChange:e=>void F({showOnStartup:e})}),(0,D.jsx)(O,{title:e.alwaysOnTop,checked:n.prefs.alwaysOnTop,disabled:T,onChange:e=>void F({alwaysOnTop:e})}),(0,D.jsx)(O,{title:e.bubbles,checked:n.prefs.bubbleEnabled,disabled:T,onChange:e=>void F({bubbleEnabled:e})}),(0,D.jsxs)(`div`,{className:`py-3`,children:[(0,D.jsxs)(`label`,{htmlFor:`desktop-pet-size`,className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[e.size,(0,D.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[G,`%`]})]}),(0,D.jsx)(`input`,{id:`desktop-pet-size`,type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:G,disabled:T,onChange:e=>j(Number(e.target.value)),onBlur:()=>void q(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&q()},onPointerUp:()=>void q()})]})]})]}),(0,D.jsxs)(`section`,{"aria-label":e.interactionGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.interactionGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.proactiveTips,checked:n.prefs.proactiveTipsEnabled,disabled:T,onChange:e=>void F({proactiveTipsEnabled:e})}),(0,D.jsx)(O,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:T,onChange:e=>void F({interactionEnabled:e})}),(0,D.jsx)(O,{title:e.reducedMotion,checked:n.prefs.reducedMotion,disabled:T,onChange:e=>void F({reducedMotion:e})}),(0,D.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-3 py-3`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,D.jsxs)(l,{"aria-label":e.behaviorMode,className:`w-36`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,disabled:T,onChange:e=>void F({behaviorMode:e.target.value}),children:[(0,D.jsx)(u,{value:`focus`,children:e.behaviorFocus}),(0,D.jsx)(u,{value:`companion`,children:e.behaviorCompanion}),(0,D.jsx)(u,{value:`playful`,children:e.behaviorPlayful})]})]})]})]}),(0,D.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-panel`,children:[(0,D.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,D.jsx)(c,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`})]}),(0,D.jsxs)(`div`,{className:`space-y-3 border-t border-edge px-4 pb-4`,children:[(0,D.jsx)(O,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:T,onChange:e=>void F({clickThroughWhenIdle:e})}),(0,D.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,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.customPets}),(0,D.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void M.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,D.jsx)(f,{className:`size-3.5`}),e.openFolder]})]}),(0,D.jsxs)(`button`,{type:`button`,className:_(`inline-flex min-h-10 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg disabled:opacity-50`,y.press),disabled:T,onClick:()=>void M.resetPosition().then(r),children:[(0,D.jsx)(g,{className:`size-3.5`}),e.resetPosition]})]})]})]})}export{k 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{u as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as a}from"./locale-store-CAZaC05J.js";import{t as o}from"./messages-C7fckbyG.js";import{t as s}from"./resource-unavailable-D15jzjV_.js";import{t as c}from"./chevron-down-ccbiQQz_.js";import{n as l,r as u}from"./popover-select-CEMWIrtY.js";import{t as d}from"./circle-alert-BEjgurr2.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./message-square-plus-XP0tGdlV.js";import{n as m,t as h}from"./wand-sparkles-CkSL-3Fy.js";import{t as g}from"./rotate-ccw-JM1TBLpp.js";import{t as _}from"./cn-0WouolD0.js";import{t as v}from"./skeleton-BI5TyibZ.js";import{n as y}from"./interaction-BdhHBbYa.js";import{n as b}from"./electron-env-DHOGevH3.js";import{t as x}from"./refresh-button-DiWdGAaX.js";import{t as S}from"./desktop-pet-sprite-D5YYq2zC.js";import{n as C,t as w}from"./settings-page-header-LuOJvqNa.js";import"./settings-page-layout-CduQ8w4a.js";var T=n(),E=e(t(),1),D=r();function O(e){let t=(0,T.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,D.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,D.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,D.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,D.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,D.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 k(){let e=o(a(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,E.useState)(null),[T,k]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),M=typeof window<`u`?window.electronAPI?.pet:void 0,N=(0,E.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),P=(0,E.useCallback)(async()=>{if(M){k(!0);try{r(await M.getState())}finally{k(!1)}}},[M]);if((0,E.useEffect)(()=>{if(M)return P(),M.onStateChanged(r)},[M,P]),!b()||!M)return(0,D.jsx)(s,{kind:`desktop`,backTo:`/settings/overview`});if(!n)return(0,D.jsxs)(C,{gap:`gap-4`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle}),(0,D.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-24 rounded-xl`}),(0,D.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(v,{className:`h-16 rounded-xl`},t))})]})})]});let F=async e=>{k(!0);try{r(await M.setPrefs(e))}finally{k(!1)}},I=async e=>{e?(await M.show(),r(await M.getState())):r(await M.setPrefs({enabled:!1}))},L=e=>{F({selectedPetId:e})},R=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},z=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},B=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=R(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},V=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),H=()=>{z(e.createChatDraft)},U=t=>{let n=V(e.optimizeChatDraft,{id:t.id,name:R(t).name,description:R(t).description,sourcePrompt:B(t)});z(n)},W=t=>{let n=V(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails});z(n)},G=A??n.prefs.sizePercent,K=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),q=async(e=G)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));j(null),t!==n.prefs.sizePercent&&await F({sizePercent:t})};return(0,D.jsxs)(C,{gap:`gap-5`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle,actions:(0,D.jsx)(x,{className:`size-9 shrink-0 p-0`,disabled:T,label:e.refresh,onClick:P})}),(0,D.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-6`,children:[(0,D.jsx)(`div`,{className:`grid h-40 w-40 shrink-0 place-items-center self-center rounded-xl bg-surface-hover/35`,children:N?(0,D.jsx)(S,{pet:N,action:`idle`,displayHeight:Math.round(104*G/100),reducedMotion:n.prefs.reducedMotion}):null}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-2`,children:[(0,D.jsx)(`h2`,{className:`break-words text-xl font-semibold text-fg`,children:N?R(N).name:e.title}),(0,D.jsx)(O,{title:e.enable,checked:n.prefs.enabled,disabled:T,onChange:e=>void I(e)})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondSummary.replace(`{days}`,String(K)).replace(`{tasks}`,String(n.relationship.completedTaskCount))}),n.pets.length>1?(0,D.jsx)(`div`,{className:`mt-4 max-w-56`,children:(0,D.jsx)(l,{"aria-label":e.petList,value:N?.id??``,onChange:e=>L(e.target.value),disabled:T,children:n.pets.map(e=>(0,D.jsx)(u,{value:e.id,children:R(e).name},e.id))})}):null,N&&!N.builtin?(0,D.jsxs)(`button`,{type:`button`,onClick:()=>U(N),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,D.jsx)(m,{className:`size-3.5`}),e.optimizeInChat]}):null]})]}),(0,D.jsx)(`div`,{className:`border-t border-edge px-5 py-2`,children:(0,D.jsxs)(`button`,{type:`button`,onClick:H,className:_(`inline-flex min-h-10 items-center gap-2 text-xs font-medium text-fg-muted hover:text-accent-fg`,y.press),children:[(0,D.jsx)(h,{className:`size-4`}),e.createTitle]})})]}),n.petIssues.length>0?(0,D.jsxs)(`section`,{className:`rounded-xl border border-danger/20 bg-danger/5 p-4`,children:[(0,D.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,D.jsx)(d,{className:`size-4`}),e.invalidPets]}),(0,D.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.petIssues.map(t=>(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,D.jsx)(`p`,{className:`break-words`,children:t.reason}),(0,D.jsxs)(`details`,{className:`mt-1`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer`,children:e.issueDetails}),(0,D.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:t.dir}),t.details?.length?(0,D.jsx)(`p`,{className:`mt-1 break-words`,children:t.details.join(`; `)}):null]})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>W(t),className:`inline-flex min-h-9 shrink-0 items-center gap-1.5 text-xs font-medium text-danger`,children:[(0,D.jsx)(p,{className:`size-3.5`}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null,(0,D.jsxs)(`section`,{"aria-label":e.displayGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.displayGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.showOnStartup,checked:n.prefs.showOnStartup,disabled:T,onChange:e=>void F({showOnStartup:e})}),(0,D.jsx)(O,{title:e.alwaysOnTop,checked:n.prefs.alwaysOnTop,disabled:T,onChange:e=>void F({alwaysOnTop:e})}),(0,D.jsx)(O,{title:e.bubbles,checked:n.prefs.bubbleEnabled,disabled:T,onChange:e=>void F({bubbleEnabled:e})}),(0,D.jsxs)(`div`,{className:`py-3`,children:[(0,D.jsxs)(`label`,{htmlFor:`desktop-pet-size`,className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[e.size,(0,D.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[G,`%`]})]}),(0,D.jsx)(`input`,{id:`desktop-pet-size`,type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:G,disabled:T,onChange:e=>j(Number(e.target.value)),onBlur:()=>void q(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&q()},onPointerUp:()=>void q()})]})]})]}),(0,D.jsxs)(`section`,{"aria-label":e.interactionGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.interactionGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.proactiveTips,checked:n.prefs.proactiveTipsEnabled,disabled:T,onChange:e=>void F({proactiveTipsEnabled:e})}),(0,D.jsx)(O,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:T,onChange:e=>void F({interactionEnabled:e})}),(0,D.jsx)(O,{title:e.reducedMotion,checked:n.prefs.reducedMotion,disabled:T,onChange:e=>void F({reducedMotion:e})}),(0,D.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-3 py-3`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,D.jsxs)(l,{"aria-label":e.behaviorMode,className:`w-36`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,disabled:T,onChange:e=>void F({behaviorMode:e.target.value}),children:[(0,D.jsx)(u,{value:`focus`,children:e.behaviorFocus}),(0,D.jsx)(u,{value:`companion`,children:e.behaviorCompanion}),(0,D.jsx)(u,{value:`playful`,children:e.behaviorPlayful})]})]})]})]}),(0,D.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-panel`,children:[(0,D.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,D.jsx)(c,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`})]}),(0,D.jsxs)(`div`,{className:`space-y-3 border-t border-edge px-4 pb-4`,children:[(0,D.jsx)(O,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:T,onChange:e=>void F({clickThroughWhenIdle:e})}),(0,D.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,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.customPets}),(0,D.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void M.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,D.jsx)(f,{className:`size-3.5`}),e.openFolder]})]}),(0,D.jsxs)(`button`,{type:`button`,className:_(`inline-flex min-h-10 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg disabled:opacity-50`,y.press),disabled:T,onClick:()=>void M.resetPosition().then(r),children:[(0,D.jsx)(g,{className:`size-3.5`}),e.resetPosition]})]})]})]})}export{k as DesktopPetSettings};
@@ -1 +1 @@
1
- import{p as e}from"./locale-store-B6OrWgY1.js";import{t}from"./middleware-Pd0e8Igk.js";var n=e(t(e=>({showRawToolData:!1,setShowRawToolData:t=>e({showRawToolData:t})}),{name:`xopc-web-dev-view`}));export{n as t};
1
+ import{p as e}from"./locale-store-CAZaC05J.js";import{t}from"./middleware-Pd0e8Igk.js";var n=e(t(e=>({showRawToolData:!1,setShowRawToolData:t=>e({showRawToolData:t})}),{name:`xopc-web-dev-view`}));export{n as t};