@xopcai/xopc 0.0.140 → 0.0.142

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 (250) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DtONoxBN.js → agent-avatar-dicebear-BawPxiu5.js} +1 -1
  4. package/dist/gateway/static/root/assets/agents-CyvCIHnB.js +2 -0
  5. package/dist/gateway/static/root/assets/{app-management-settings-panel-BRBxLECY.js → app-management-settings-panel-81xd1p9R.js} +1 -1
  6. package/dist/gateway/static/root/assets/{appearance-settings-ChvyuSEt.js → appearance-settings-DYeQsYU8.js} +1 -1
  7. package/dist/gateway/static/root/assets/{apps-page-DgHWTnjs.js → apps-page-DK_Vx6nl.js} +1 -1
  8. package/dist/gateway/static/root/assets/{archive-plugin-CdIoagem.js → archive-plugin-D_oa7oti.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-Ch411Kht.js → attachment-load-Cd-bwI2N.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automation-suggestion-card-SVq27yw2.js → automation-suggestion-card-B1LV3YYv.js} +1 -1
  11. package/dist/gateway/static/root/assets/automations-page-fzrovqhv.js +4 -0
  12. package/dist/gateway/static/root/assets/{binary-plugins-D8cV-emn.js → binary-plugins-O8svLKWw.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-CXDkby6y.js → block-editor-Dhj5f4Bx.js} +47 -47
  14. package/dist/gateway/static/root/assets/browser-settings-page-BDn-n-UB.js +8 -0
  15. package/dist/gateway/static/root/assets/{capability-presets-api-DLxI--Ge.js → capability-presets-api-dJy1Eqgx.js} +1 -1
  16. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DKyRbnlH.js → capability-presets-settings-panel-Co5ipo_Q.js} +1 -1
  17. package/dist/gateway/static/root/assets/{channel-recipient-api-DllrPmp-.js → channel-recipient-api-Bfuhp2ty.js} +1 -1
  18. package/dist/gateway/static/root/assets/channels-settings-BWlpaxg9.js +1 -0
  19. package/dist/gateway/static/root/assets/channels-status-swr-D_jkIZLV.js +1 -0
  20. package/dist/gateway/static/root/assets/connectors-page-BcekbW4q.js +2 -0
  21. package/dist/gateway/static/root/assets/{desktop-pet-Bz9ommjr.js → desktop-pet-DFMfIb5F.js} +1 -1
  22. package/dist/gateway/static/root/assets/{desktop-pet-settings-BnLgxgoR.js → desktop-pet-settings-BJCUuL8Y.js} +1 -1
  23. package/dist/gateway/static/root/assets/{directory-picker-path-field-DLsCwFaf.js → directory-picker-path-field-BrYt1gAr.js} +1 -1
  24. package/dist/gateway/static/root/assets/{dreaming-settings-BzkF1-XT.js → dreaming-settings-BN1Z2mIo.js} +3 -3
  25. package/dist/gateway/static/root/assets/{extension-debug-page-CdERvf3L.js → extension-debug-page-Bh630pLD.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-page-D1fz474Z.js → extension-page-B-1KxvVy.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-settings-page-DoQMkNOK.js → extension-settings-page-BF9NACI3.js} +1 -1
  28. package/dist/gateway/static/root/assets/{fetch-BID89uCH.js → fetch-B1WtuprY.js} +1 -1
  29. package/dist/gateway/static/root/assets/{gateway-config-api-Rygo8UAs.js → gateway-config-api-De2N821l.js} +1 -1
  30. package/dist/gateway/static/root/assets/{gateway-settings-kb8KIeQL.js → gateway-settings-DN9sNREz.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-startup-retry-BkrLLlpE.js → gateway-startup-retry-nEujFSDj.js} +1 -1
  32. package/dist/gateway/static/root/assets/goal-create-dialog-BpoQW8cD.js +1 -0
  33. package/dist/gateway/static/root/assets/goal-detail-page-CBRSPd0b.js +4 -0
  34. package/dist/gateway/static/root/assets/{goals-config-api-BuY6-l0a.js → goals-config-api-DUy3eEse.js} +1 -1
  35. package/dist/gateway/static/root/assets/goals-page-BCcBi407.js +2 -0
  36. package/dist/gateway/static/root/assets/{goals-settings-DoH5fZWo.js → goals-settings-pkTXzXkh.js} +1 -1
  37. package/dist/gateway/static/root/assets/{heartbeat-settings-BqDs48B-.js → heartbeat-settings-ezsufgLQ.js} +1 -1
  38. package/dist/gateway/static/root/assets/{index-CrPRlGMg.js → index-DcUaXYeb.js} +65 -65
  39. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CVIwwM15.js +1 -0
  40. package/dist/gateway/static/root/assets/logs-page-DQtTRXtj.js +7 -0
  41. package/dist/gateway/static/root/assets/{markdown-split-CSt32FWE.js → markdown-split-B_6us9j7.js} +1 -1
  42. package/dist/gateway/static/root/assets/{media-plugins-ByItHxBj.js → media-plugins-D_fryIyj.js} +1 -1
  43. package/dist/gateway/static/root/assets/messages-BXNELNBa.js +3 -0
  44. package/dist/gateway/static/root/assets/models-hub-panel-BP2M9n6Q.js +2 -0
  45. package/dist/gateway/static/root/assets/notes-page-CspveYaO.js +1 -0
  46. package/dist/gateway/static/root/assets/notes-workbench-BHwzJ0OC.js +2 -0
  47. package/dist/gateway/static/root/assets/{page-tabs-DOfMaq_L.js → page-tabs-D_8jGlqx.js} +1 -1
  48. package/dist/gateway/static/root/assets/{preview-open-alternatives-BArxASu7.js → preview-open-alternatives-BBLMK8Mp.js} +1 -1
  49. package/dist/gateway/static/root/assets/project-detail-page-Dy3rsobs.js +1 -0
  50. package/dist/gateway/static/root/assets/projects-page-CWKpPE0L.js +1 -0
  51. package/dist/gateway/static/root/assets/remote-access-hub-CqNRyXEo.js +1 -0
  52. package/dist/gateway/static/root/assets/{save-bar-controls-BRxlkhG8.js → save-bar-controls-DVS3FR5r.js} +1 -1
  53. package/dist/gateway/static/root/assets/{schedule-field-BzM1iyOc.js → schedule-field-D6vKd6-T.js} +1 -1
  54. package/dist/gateway/static/root/assets/{schema-form-ChVcm0DX.js → schema-form-BPy4lbIh.js} +1 -1
  55. package/dist/gateway/static/root/assets/sessions-page-MEME7ivF.js +1 -0
  56. package/dist/gateway/static/root/assets/settings-advanced-gate-JVd0qaSF.js +1 -0
  57. package/dist/gateway/static/root/assets/{settings-collapsible-section-BcD9xrvY.js → settings-collapsible-section-WzdikxPt.js} +1 -1
  58. package/dist/gateway/static/root/assets/{settings-form-section-Cu30CXVl.js → settings-form-section-CvfzhBV-.js} +1 -1
  59. package/dist/gateway/static/root/assets/{settings-loading-skeleton-Cfd37IYb.js → settings-loading-skeleton-BxR-Ulhi.js} +1 -1
  60. package/dist/gateway/static/root/assets/{settings-page-EINHyzLo.js → settings-page-DYEbB1EV.js} +1 -1
  61. package/dist/gateway/static/root/assets/{settings-page-layout-C15zixct.js → settings-page-layout-CKefvbYi.js} +1 -1
  62. package/dist/gateway/static/root/assets/{setup-status-panel-Bu7SdpD4.js → setup-status-panel-dWN8BJ3z.js} +1 -1
  63. package/dist/gateway/static/root/assets/{share-preview-page-CjjAFV-v.js → share-preview-page-D8foINzP.js} +1 -1
  64. package/dist/gateway/static/root/assets/shares-settings-Tgbv1s7G.js +1 -0
  65. package/dist/gateway/static/root/assets/skill-reload-api-D_YK0b_Z.js +1 -0
  66. package/dist/gateway/static/root/assets/skills-page-DGytfoZK.js +2 -0
  67. package/dist/gateway/static/root/assets/{system-settings-panel-DlQMtzPf.js → system-settings-panel-BokgAgf7.js} +1 -1
  68. package/dist/gateway/static/root/assets/{typed-models-lib-BS1BwExE.js → typed-models-lib-BwHlNL3L.js} +1 -1
  69. package/dist/gateway/static/root/assets/{use-channel-catalog-EA4hfbsP.js → use-channel-catalog-DR11ap3A.js} +1 -1
  70. package/dist/gateway/static/root/assets/{user-profile-settings-panel-B7RCdmSp.js → user-profile-settings-panel-8YtygcJp.js} +1 -1
  71. package/dist/gateway/static/root/assets/{utils-BrhEgVaa.js → utils-BKUWB-TT.js} +1 -1
  72. package/dist/gateway/static/root/assets/voice-api-key-field-BVH71EFf.js +1 -0
  73. package/dist/gateway/static/root/assets/work-item-detail-page-JeTE7XNM.js +1 -0
  74. package/dist/gateway/static/root/assets/workflow-run-setup-panel-CL_rnAUB.js +3 -0
  75. package/dist/gateway/static/root/assets/{workflow-start-dialog-BZCY7N42.js → workflow-start-dialog-_u8Uc1ze.js} +1 -1
  76. package/dist/gateway/static/root/assets/workflows-page-ixgk_y1l.js +18 -0
  77. package/dist/gateway/static/root/index.html +4 -4
  78. package/dist/package.js +1 -1
  79. package/dist/src/agent/agent-manager.js +13 -21
  80. package/dist/src/agent/agent-manager.js.map +1 -1
  81. package/dist/src/agent/background-review/run-background-review.js +1 -0
  82. package/dist/src/agent/background-review/run-background-review.js.map +1 -1
  83. package/dist/src/agent/embedded/session-runner.js +5 -5
  84. package/dist/src/agent/embedded/session-runner.js.map +1 -1
  85. package/dist/src/agent/embedded/xopc-auth-storage.d.ts +4 -3
  86. package/dist/src/agent/embedded/xopc-auth-storage.js +6 -6
  87. package/dist/src/agent/embedded/xopc-auth-storage.js.map +1 -1
  88. package/dist/src/agent/embedded/xopc-stream-bridge.js +1 -0
  89. package/dist/src/agent/embedded/xopc-stream-bridge.js.map +1 -1
  90. package/dist/src/agent/goals/checklist-judge.js +3 -3
  91. package/dist/src/agent/goals/checklist-judge.js.map +1 -1
  92. package/dist/src/agent/goals/judge.js +2 -2
  93. package/dist/src/agent/goals/judge.js.map +1 -1
  94. package/dist/src/agent/image/understanding/pi-ai-provider.js +2 -2
  95. package/dist/src/agent/image/understanding/pi-ai-provider.js.map +1 -1
  96. package/dist/src/agent/memory/access-policy.d.ts +12 -0
  97. package/dist/src/agent/memory/access-policy.js +44 -0
  98. package/dist/src/agent/memory/access-policy.js.map +1 -0
  99. package/dist/src/agent/memory/builtin-provider.d.ts +4 -1
  100. package/dist/src/agent/memory/builtin-provider.js +51 -16
  101. package/dist/src/agent/memory/builtin-provider.js.map +1 -1
  102. package/dist/src/agent/memory/compaction.js +2 -2
  103. package/dist/src/agent/memory/compaction.js.map +1 -1
  104. package/dist/src/agent/memory/context/planner.d.ts +1 -0
  105. package/dist/src/agent/memory/context/planner.js +9 -5
  106. package/dist/src/agent/memory/context/planner.js.map +1 -1
  107. package/dist/src/agent/memory/create-memory-manager.d.ts +1 -1
  108. package/dist/src/agent/memory/create-memory-manager.js +8 -5
  109. package/dist/src/agent/memory/create-memory-manager.js.map +1 -1
  110. package/dist/src/agent/memory/dreaming/config.d.ts +2 -0
  111. package/dist/src/agent/memory/dreaming/config.js +13 -1
  112. package/dist/src/agent/memory/dreaming/config.js.map +1 -1
  113. package/dist/src/agent/memory/dreaming/deep-promotion.d.ts +2 -0
  114. package/dist/src/agent/memory/dreaming/deep-promotion.js +24 -3
  115. package/dist/src/agent/memory/dreaming/deep-promotion.js.map +1 -1
  116. package/dist/src/agent/memory/dreaming/light-sweep.d.ts +1 -0
  117. package/dist/src/agent/memory/dreaming/light-sweep.js +184 -16
  118. package/dist/src/agent/memory/dreaming/light-sweep.js.map +1 -1
  119. package/dist/src/agent/memory/dreaming/promotion-lifecycle.d.ts +30 -0
  120. package/dist/src/agent/memory/dreaming/promotion-lifecycle.js +85 -0
  121. package/dist/src/agent/memory/dreaming/promotion-lifecycle.js.map +1 -0
  122. package/dist/src/agent/memory/dreaming/rem-patterns.d.ts +4 -0
  123. package/dist/src/agent/memory/dreaming/rem-patterns.js +76 -53
  124. package/dist/src/agent/memory/dreaming/rem-patterns.js.map +1 -1
  125. package/dist/src/agent/memory/dreaming/short-term-store.d.ts +10 -0
  126. package/dist/src/agent/memory/dreaming/short-term-store.js +157 -79
  127. package/dist/src/agent/memory/dreaming/short-term-store.js.map +1 -1
  128. package/dist/src/agent/memory/manager.d.ts +7 -0
  129. package/dist/src/agent/memory/manager.js +31 -6
  130. package/dist/src/agent/memory/manager.js.map +1 -1
  131. package/dist/src/agent/memory/memory-config.d.ts +1 -1
  132. package/dist/src/agent/memory/memory-config.js +3 -3
  133. package/dist/src/agent/memory/memory-config.js.map +1 -1
  134. package/dist/src/agent/memory/sensitivity.d.ts +3 -0
  135. package/dist/src/agent/memory/sensitivity.js +13 -0
  136. package/dist/src/agent/memory/sensitivity.js.map +1 -0
  137. package/dist/src/agent/memory/understanding/service.js +10 -14
  138. package/dist/src/agent/memory/understanding/service.js.map +1 -1
  139. package/dist/src/agent/memory/user-context-coordinator.d.ts +1 -0
  140. package/dist/src/agent/memory/user-context-coordinator.js +2 -0
  141. package/dist/src/agent/memory/user-context-coordinator.js.map +1 -1
  142. package/dist/src/agent/orchestration/agent-orchestrator.js +8 -1
  143. package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
  144. package/dist/src/agent/service/btw-query.d.ts +4 -0
  145. package/dist/src/agent/service/btw-query.js +94 -13
  146. package/dist/src/agent/service/btw-query.js.map +1 -1
  147. package/dist/src/agent/session/session-inspector.js +9 -1
  148. package/dist/src/agent/session/session-inspector.js.map +1 -1
  149. package/dist/src/agent/tools/dreaming-tool.js +3 -12
  150. package/dist/src/agent/tools/dreaming-tool.js.map +1 -1
  151. package/dist/src/agent/tools/factory.js +14 -2
  152. package/dist/src/agent/tools/factory.js.map +1 -1
  153. package/dist/src/agent/tools/memory-tool.d.ts +3 -0
  154. package/dist/src/agent/tools/memory-tool.js +6 -3
  155. package/dist/src/agent/tools/memory-tool.js.map +1 -1
  156. package/dist/src/agent/tools/session-search-tool.js +2 -2
  157. package/dist/src/agent/tools/session-search-tool.js.map +1 -1
  158. package/dist/src/agent/tools/web-extract.js +2 -2
  159. package/dist/src/agent/tools/web-extract.js.map +1 -1
  160. package/dist/src/agent/workspace-runtime/registry.d.ts +6 -6
  161. package/dist/src/agent/workspace-runtime/registry.js +19 -12
  162. package/dist/src/agent/workspace-runtime/registry.js.map +1 -1
  163. package/dist/src/agent-manifest/schema.d.ts +4 -0
  164. package/dist/src/agent-manifest/schema.js +2 -1
  165. package/dist/src/agent-manifest/schema.js.map +1 -1
  166. package/dist/src/agent-runtime/index.js +1 -1
  167. package/dist/src/agent-runtime/runtime-profile.js +1 -1
  168. package/dist/src/ai-assist/text-assist.d.ts +2 -1
  169. package/dist/src/ai-assist/text-assist.js +10 -23
  170. package/dist/src/ai-assist/text-assist.js.map +1 -1
  171. package/dist/src/auth/credentials.js +5 -2
  172. package/dist/src/auth/credentials.js.map +1 -1
  173. package/dist/src/auth/oauth/github-copilot.d.ts +3 -4
  174. package/dist/src/auth/oauth/github-copilot.js +66 -2
  175. package/dist/src/auth/oauth/github-copilot.js.map +1 -0
  176. package/dist/src/auth/oauth/index.js +2 -2
  177. package/dist/src/automations/draft/automation-draft-service.js +3 -3
  178. package/dist/src/automations/draft/automation-draft-service.js.map +1 -1
  179. package/dist/src/chat-commands/builtins/review.js +22 -5
  180. package/dist/src/chat-commands/builtins/review.js.map +1 -1
  181. package/dist/src/chat-commands/types.d.ts +4 -0
  182. package/dist/src/config/schema.d.ts +4 -0
  183. package/dist/src/gateway/hono/lib/config-payload.d.ts +2 -0
  184. package/dist/src/gateway/hono/routes/dreaming.js +28 -21
  185. package/dist/src/gateway/hono/routes/dreaming.js.map +1 -1
  186. package/dist/src/gateway/hono/routes/memory.js +16 -4
  187. package/dist/src/gateway/hono/routes/memory.js.map +1 -1
  188. package/dist/src/gateway/hono/routes/models.js +1 -0
  189. package/dist/src/gateway/hono/routes/models.js.map +1 -1
  190. package/dist/src/gateway/hono/routes/voice.js +2 -2
  191. package/dist/src/gateway/hono/routes/voice.js.map +1 -1
  192. package/dist/src/goals/goal-contract-draft.js +2 -2
  193. package/dist/src/goals/goal-contract-draft.js.map +1 -1
  194. package/dist/src/goals/goal-evidence-review.js +2 -2
  195. package/dist/src/goals/goal-evidence-review.js.map +1 -1
  196. package/dist/src/notes/service.js +2 -2
  197. package/dist/src/notes/service.js.map +1 -1
  198. package/dist/src/providers/constants.d.ts +2 -0
  199. package/dist/src/providers/constants.js +11 -0
  200. package/dist/src/providers/constants.js.map +1 -0
  201. package/dist/src/providers/extension-stream-bridge.js +1 -0
  202. package/dist/src/providers/extension-stream-bridge.js.map +1 -1
  203. package/dist/src/providers/index.d.ts +3 -3
  204. package/dist/src/providers/index.js +5 -4
  205. package/dist/src/providers/index.js.map +1 -1
  206. package/dist/src/providers/model-call.d.ts +17 -0
  207. package/dist/src/providers/model-call.js +60 -0
  208. package/dist/src/providers/model-call.js.map +1 -0
  209. package/dist/src/session/session-title.js +2 -2
  210. package/dist/src/session/session-title.js.map +1 -1
  211. package/dist/src/storage/sqlite/fts.d.ts +6 -0
  212. package/dist/src/storage/sqlite/fts.js +70 -1
  213. package/dist/src/storage/sqlite/fts.js.map +1 -1
  214. package/dist/src/storage/sqlite/memory-index-repository.js +16 -7
  215. package/dist/src/storage/sqlite/memory-index-repository.js.map +1 -1
  216. package/dist/src/storage/sqlite/memory-records-repository.d.ts +18 -0
  217. package/dist/src/storage/sqlite/memory-records-repository.js +55 -8
  218. package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
  219. package/dist/src/voice/tts/summarize.js +2 -2
  220. package/dist/src/voice/tts/summarize.js.map +1 -1
  221. package/dist/src/workflows/draft/workflow-draft-service.js +2 -2
  222. package/dist/src/workflows/draft/workflow-draft-service.js.map +1 -1
  223. package/package.json +5 -5
  224. package/dist/gateway/static/root/assets/agents-Dl9EWnUh.js +0 -2
  225. package/dist/gateway/static/root/assets/automations-page-CFt5Ik4q.js +0 -4
  226. package/dist/gateway/static/root/assets/browser-settings-page-ColJPwer.js +0 -8
  227. package/dist/gateway/static/root/assets/channels-settings-BDLHV3Jx.js +0 -1
  228. package/dist/gateway/static/root/assets/channels-status-swr-EUwWYx8l.js +0 -1
  229. package/dist/gateway/static/root/assets/connectors-page-CA752gY8.js +0 -2
  230. package/dist/gateway/static/root/assets/goal-create-dialog-DVAHnifk.js +0 -1
  231. package/dist/gateway/static/root/assets/goal-detail-page-BuOEQZn_.js +0 -4
  232. package/dist/gateway/static/root/assets/goals-page-WV4cHvD-.js +0 -2
  233. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-D51yogNZ.js +0 -1
  234. package/dist/gateway/static/root/assets/logs-page-CL22jleU.js +0 -7
  235. package/dist/gateway/static/root/assets/messages-DbNQuFdA.js +0 -3
  236. package/dist/gateway/static/root/assets/models-hub-panel-BkV9hDc-.js +0 -2
  237. package/dist/gateway/static/root/assets/notes-page-BK9yydrL.js +0 -1
  238. package/dist/gateway/static/root/assets/notes-workbench-Dd0v-hK2.js +0 -2
  239. package/dist/gateway/static/root/assets/project-detail-page-DSPhB3do.js +0 -1
  240. package/dist/gateway/static/root/assets/projects-page-C-fZk1f7.js +0 -1
  241. package/dist/gateway/static/root/assets/remote-access-hub-BGaVc3t7.js +0 -1
  242. package/dist/gateway/static/root/assets/sessions-page-DbnzgQOP.js +0 -1
  243. package/dist/gateway/static/root/assets/settings-advanced-gate-CuDBoz5k.js +0 -1
  244. package/dist/gateway/static/root/assets/shares-settings-06IYvwDt.js +0 -1
  245. package/dist/gateway/static/root/assets/skill-reload-api-0ODH0DXl.js +0 -1
  246. package/dist/gateway/static/root/assets/skills-page-3W2-wDyO.js +0 -2
  247. package/dist/gateway/static/root/assets/voice-api-key-field-BPn1ZEga.js +0 -1
  248. package/dist/gateway/static/root/assets/work-item-detail-page-BQGTTsz1.js +0 -1
  249. package/dist/gateway/static/root/assets/workflow-run-setup-panel-na-N4jZ6.js +0 -3
  250. package/dist/gateway/static/root/assets/workflows-page-CjeVDs4h.js +0 -18
@@ -1,8 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DbNQuFdA.js";import{a as o,n as s,o as c,t as l}from"./fetch-BID89uCH.js";import{n as u}from"./locale-store-Ba72bFmP.js";import{r as d}from"./toast-z0toXu32.js";import{$c as f,Ac as p,Bo as m,Dt as h,Eo as g,Es as _,Et as v,Fc as y,Kc as b,Ks as x,Nc as S,Ro as C,Rs as w,T,Ts as E,Tt as D,Vc as O,Xc as k,Ya as A,Zo as j,_c as M,_s as N,as as P,ga as F,go as I,ha as L,ho as R,is as z,jo as ee,kl as B,mr as V,nl as H,ns as te,po as U,qc as W,ro as G,to as ne,ws as K,xs as re}from"./index-CrPRlGMg.js";import{n as ie,r as ae,t as oe}from"./settings-page-layout-C15zixct.js";import{n as se}from"./settings-loading-skeleton-Cfd37IYb.js";import{t as ce}from"./settings-advanced-gate-CuDBoz5k.js";import{n as le,t as q}from"./settings-form-section-Cu30CXVl.js";import{t as ue}from"./page-tabs-DOfMaq_L.js";import{c as de,r as fe,s as J}from"./typed-models-lib-BS1BwExE.js";import{i as pe,l as me,s as he,u as ge}from"./gateway-config-api-Rygo8UAs.js";var Y=e(t(),1),X=n(),Z=r();function Q(e){let t=(0,X.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function _e(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function ve(e){let t=(0,X.c)(28),{value:n,onChange:r,onOpenConfig:a,options:o,m:s}=e,c;if(t[0]!==s.browserGoToConfigure||t[1]!==s.browserPickerSubtitle||t[2]!==s.browserPickerTitle||t[3]!==r||t[4]!==a||t[5]!==o||t[6]!==n){let e=o.find(e=>e.value===n)??o[0],l;t[8]===s.browserPickerTitle?l=t[9]:(l=(0,Z.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:s.browserPickerTitle}),t[8]=s.browserPickerTitle,t[9]=l);let u;t[10]===s.browserPickerSubtitle?u=t[11]:(u=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:s.browserPickerSubtitle}),t[10]=s.browserPickerSubtitle,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=i(de(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=t[15];let p;t[16]===r?p=t[17]:(p=e=>r(e.target.value),t[16]=r,t[17]=p);let m=s.browserPickerTitle,h;t[18]===o?h=t[19]:(h=o.map(ye),t[18]=o,t[19]=h);let g;t[20]!==s.browserPickerTitle||t[21]!==p||t[22]!==h||t[23]!==n?(g=(0,Z.jsx)(ne,{id:`browser-backend-select`,className:f,value:n,onChange:p,"aria-label":m,children:h}),t[20]=s.browserPickerTitle,t[21]=p,t[22]=h,t[23]=n,t[24]=g):g=t[24];let _=a?(0,Z.jsxs)(`button`,{type:`button`,className:i(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>a(n),"aria-label":`${e?.name??n} — ${s.browserGoToConfigure}`,children:[(0,Z.jsx)(`span`,{children:s.browserGoToConfigure}),(0,Z.jsx)(H,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,v;t[25]!==_||t[26]!==g?(v=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[g,_]}),t[25]=_,t[26]=g,t[27]=v):v=t[27],c=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,v,e?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,Z.jsx)(`span`,{className:i(`inline-block size-1.5 rounded-full`,_e(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=s.browserGoToConfigure,t[1]=s.browserPickerSubtitle,t[2]=s.browserPickerTitle,t[3]=r,t[4]=a,t[5]=o,t[6]=n,t[7]=c}else c=t[7];return c}function ye(e){return(0,Z.jsx)(G,{value:e.value,children:e.name},e.value)}function be(e){return`browser-focus-${e}`}function xe(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function Se(e){let t=(0,X.c)(89),{a:n,form:r,update:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=be(`runtime`),t[0]=a):a=t[0];let o;t[1]===n.browserBehaviorShow?o=t[2]:(o=(0,Z.jsx)(le,{icon:te,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=o);let s;t[3]===i?s=t[4]:(s=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=s);let c;t[5]!==r.browserHeadless||t[6]!==s?(c=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:s}),t[5]=r.browserHeadless,t[6]=s,t[7]=c):c=t[7];let l;t[8]===n.browserHeadlessOn?l=t[9]:(l=(0,Z.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=l);let u;t[10]!==c||t[11]!==l?(u=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==u?(d=(0,Z.jsx)(Q,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:u}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=u,t[16]=d):d=t[16];let f=n.label.browserDialogPolicy,p=n.desc.browserDialogPolicy,m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=de(),t[17]=m):m=t[17];let h;t[18]===i?h=t[19]:(h=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=h);let g;t[20]===n.browserDialogPolicyMustRespond?g=t[21]:(g=(0,Z.jsx)(G,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=g);let _;t[22]===n.browserDialogPolicyAutoDismiss?_=t[23]:(_=(0,Z.jsx)(G,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=_);let v;t[24]===n.browserDialogPolicyAutoAccept?v=t[25]:(v=(0,Z.jsx)(G,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=v);let y;t[26]!==r.browserDialogPolicy||t[27]!==h||t[28]!==g||t[29]!==_||t[30]!==v?(y=(0,Z.jsxs)(ne,{className:m,value:r.browserDialogPolicy,onChange:h,children:[g,_,v]}),t[26]=r.browserDialogPolicy,t[27]=h,t[28]=g,t[29]=_,t[30]=v,t[31]=y):y=t[31];let b;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==y?(b=(0,Z.jsx)(Q,{label:f,description:p,children:y}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=y,t[35]=b):b=t[35];let x=n.label.browserDialogTimeout,S=n.desc.browserDialogTimeout,C;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(C=J(),t[36]=C):C=t[36];let w=r.browserDialogTimeout??``,T;t[37]===i?T=t[38]:(T=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[37]=i,t[38]=T);let E;t[39]!==w||t[40]!==T?(E=(0,Z.jsx)(`input`,{type:`number`,className:C,min:1,value:w,placeholder:`300`,onChange:T}),t[39]=w,t[40]=T,t[41]=E):E=t[41];let D;t[42]!==n.desc.browserDialogTimeout||t[43]!==n.label.browserDialogTimeout||t[44]!==E?(D=(0,Z.jsx)(Q,{label:x,description:S,children:E}),t[42]=n.desc.browserDialogTimeout,t[43]=n.label.browserDialogTimeout,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==b||t[47]!==D||t[48]!==d?(O=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[d,b,D]}),t[46]=b,t[47]=D,t[48]=d,t[49]=O):O=t[49];let k;t[50]!==o||t[51]!==O?(k=(0,Z.jsx)(`div`,{id:a,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{children:[o,O]})}),t[50]=o,t[51]=O,t[52]=k):k=t[52];let A;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(A=be(`security`),t[53]=A):A=t[53];let j;t[54]===n.browserSecurityShow?j=t[55]:(j=(0,Z.jsx)(le,{icon:P,title:n.browserSecurityShow}),t[54]=n.browserSecurityShow,t[55]=j);let M;t[56]===i?M=t[57]:(M=e=>i({browserAllowPrivateUrls:e.target.checked}),t[56]=i,t[57]=M);let N;t[58]!==r.browserAllowPrivateUrls||t[59]!==M?(N=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:M}),t[58]=r.browserAllowPrivateUrls,t[59]=M,t[60]=N):N=t[60];let F;t[61]===n.browserAllowPrivateOn?F=t[62]:(F=(0,Z.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[61]=n.browserAllowPrivateOn,t[62]=F);let I;t[63]!==N||t[64]!==F?(I=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[N,F]}),t[63]=N,t[64]=F,t[65]=I):I=t[65];let L;t[66]!==n.desc.browserAllowPrivateUrls||t[67]!==n.label.browserAllowPrivateUrls||t[68]!==I?(L=(0,Z.jsx)(Q,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:I}),t[66]=n.desc.browserAllowPrivateUrls,t[67]=n.label.browserAllowPrivateUrls,t[68]=I,t[69]=L):L=t[69];let R=n.label.browserCommandTimeout,z=n.desc.browserCommandTimeout,ee;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ee=J(),t[70]=ee):ee=t[70];let B=r.browserCommandTimeout??``,V;t[71]===i?V=t[72]:(V=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=V);let H;t[73]!==B||t[74]!==V?(H=(0,Z.jsx)(`input`,{type:`number`,className:ee,min:5,value:B,placeholder:`30`,onChange:V}),t[73]=B,t[74]=V,t[75]=H):H=t[75];let U;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==H?(U=(0,Z.jsx)(Q,{label:R,description:z,children:H}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=H,t[79]=U):U=t[79];let W;t[80]!==L||t[81]!==U?(W=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[L,U]}),t[80]=L,t[81]=U,t[82]=W):W=t[82];let K;t[83]!==j||t[84]!==W?(K=(0,Z.jsx)(`div`,{id:A,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{className:`border border-amber-500/20`,children:[j,W]})}),t[83]=j,t[84]=W,t[85]=K):K=t[85];let re;return t[86]!==k||t[87]!==K?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[k,K]}),t[86]=k,t[87]=K,t[88]=re):re=t[88],re}function Ce(e){let t=(0,X.c)(9),{language:n,label:r,className:a}=e,o;t[0]===n?o=t[1]:(o=A(n),t[0]=n,t[1]=o);let s;t[2]===a?s=t[3]:(s=i(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a),t[2]=a,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(p,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=c):c=t[4];let l;return t[5]!==r||t[6]!==o||t[7]!==s?(l=(0,Z.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,c]}),t[5]=r,t[6]=o,t[7]=s,t[8]=l):l=t[8],l}function we(e){let t=(0,X.c)(27),{title:n,description:r,recommended:a,recommendedLabel:o,icon:s,onSelect:c,selectLabel:l}=e,u=`${n} — ${l}`,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(`group flex w-full flex-col rounded-xl bg-surface-panel/80 px-3 py-3 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=d):d=t[0];let f;t[1]===s?f=t[2]:(f=(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=s,t[2]=f);let p;t[3]===n?p=t[4]:(p=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==a||t[6]!==o?(m=a&&o?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:o}):null,t[5]=a,t[6]=o,t[7]=m):m=t[7];let h;t[8]!==p||t[9]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p,m]}),t[8]=p,t[9]=m,t[10]=h):h=t[10];let g;t[11]===r?g=t[12]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(H,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]!==f||t[18]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[f,_,v]}),t[17]=f,t[18]=_,t[19]=y):y=t[19];let b;t[20]===l?b=t[21]:(b=(0,Z.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:l}),t[20]=l,t[21]=b);let x;return t[22]!==c||t[23]!==u||t[24]!==y||t[25]!==b?(x=(0,Z.jsxs)(`button`,{type:`button`,onClick:c,"aria-label":u,className:d,children:[y,b]}),t[22]=c,t[23]=u,t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function Te(e){let t=(0,X.c)(25),{m:n,onStart:r}=e,i=V(Ee),a;t[0]!==n.browserBackendCloakBrowser||t[1]!==n.browserModeCloakTagline||t[2]!==n.browserSetupCloudDesc||t[3]!==n.browserSetupCloudTitle||t[4]!==n.browserSetupExtDesc||t[5]!==n.browserSetupExtTitle||t[6]!==n.browserSetupLocalDesc||t[7]!==n.browserSetupLocalTitle||t[8]!==i?(a=[{id:`extension`,icon:re,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:z,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:w,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:O,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>me(e.id,i)),t[0]=n.browserBackendCloakBrowser,t[1]=n.browserModeCloakTagline,t[2]=n.browserSetupCloudDesc,t[3]=n.browserSetupCloudTitle,t[4]=n.browserSetupExtDesc,t[5]=n.browserSetupExtTitle,t[6]=n.browserSetupLocalDesc,t[7]=n.browserSetupLocalTitle,t[8]=i,t[9]=a):a=t[9];let o=a,s;t[10]===n.browserSetupTitle?s=t[11]:(s=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[10]=n.browserSetupTitle,t[11]=s);let c;t[12]===n.browserSetupSubtitle?c=t[13]:(c=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[12]=n.browserSetupSubtitle,t[13]=c);let l;t[14]!==s||t[15]!==c?(l=(0,Z.jsxs)(`div`,{children:[s,c]}),t[14]=s,t[15]=c,t[16]=l):l=t[16];let u;t[17]!==n.browserSetupRecommended||t[18]!==n.browserSetupSelect||t[19]!==o||t[20]!==r?(u=(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>(0,Z.jsx)(we,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[17]=n.browserSetupRecommended,t[18]=n.browserSetupSelect,t[19]=o,t[20]=r,t[21]=u):u=t[21];let d;return t[22]!==l||t[23]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-base px-4 py-4`,children:[l,u]}),t[22]=l,t[23]=u,t[24]=d):d=t[24],d}function Ee(e){return e.mode}function De(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function Oe(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function ke(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function Ae(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var je=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Me=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Ne={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Pe(e){let t=(e??``).trim();return t===`behavior`?`overview`:je.includes(t)?t:`overview`}function Fe(e){return Me.includes(e)}function Ie(e){let t=(0,X.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Le,{kind:a,detail:o,m:u})}):(0,Z.jsx)(`span`,{}),s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,Z.jsx)(Le,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Le(e){let t=(0,X.c)(27),{kind:n,detail:r,m:a}=e,o,s,c,l;if(t[0]!==n||t[1]!==a.browserStatusChecking||t[2]!==a.browserStatusError||t[3]!==a.browserStatusNotInstalled||t[4]!==a.browserStatusReady||t[5]!==a.browserStatusUnknown){let{icon:e,color:r,label:u}={ready:{icon:f,color:`text-green-600 dark:text-green-400`,label:a.browserStatusReady},not_installed:{icon:m,color:`text-amber-600 dark:text-amber-400`,label:a.browserStatusNotInstalled},checking:{icon:x,color:`text-fg-muted`,label:a.browserStatusChecking},unknown:{icon:k,color:`text-fg-muted`,label:a.browserStatusUnknown},error:{icon:W,color:`text-red-600 dark:text-red-400`,label:a.browserStatusError}}[n];o=e,s=u,l=`inline-flex min-w-0 flex-col items-start gap-1`,c=i(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=a.browserStatusChecking,t[2]=a.browserStatusError,t[3]=a.browserStatusNotInstalled,t[4]=a.browserStatusReady,t[5]=a.browserStatusUnknown,t[6]=o,t[7]=s,t[8]=c,t[9]=l}else o=t[6],s=t[7],c=t[8],l=t[9];let u=n===`checking`&&`animate-spin`,d;t[10]===u?d=t[11]:(d=i(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let p;t[12]!==o||t[13]!==d?(p=(0,Z.jsx)(o,{className:d}),t[12]=o,t[13]=d,t[14]=p):p=t[14];let h;t[15]===s?h=t[16]:(h=(0,Z.jsx)(`span`,{children:s}),t[15]=s,t[16]=h);let g;t[17]!==c||t[18]!==p||t[19]!==h?(g=(0,Z.jsxs)(`span`,{className:c,children:[p,h]}),t[17]=c,t[18]=p,t[19]=h,t[20]=g):g=t[20];let _;t[21]===r?_=t[22]:(_=r?(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=_);let v;return t[23]!==l||t[24]!==g||t[25]!==_?(v=(0,Z.jsxs)(`span`,{className:l,children:[g,_]}),t[23]=l,t[24]=g,t[25]=_,t[26]=v):v=t[26],v}function Re(e){let t=(0,X.c)(5),{kind:n,message:r}=e,a=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,o;t[0]===a?o=t[1]:(o=i(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,a),t[0]=a,t[1]=o);let s;return t[2]!==r||t[3]!==o?(s=(0,Z.jsx)(`div`,{className:o,children:r}),t[2]=r,t[3]=o,t[4]=s):s=t[4],s}var ze={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function Be({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,Y.useReducer)(h,ze),{instances:u,launchStatus:d,launchMessage:f,testStatus:p,testMessage:m,executablePath:g}=c,_=(0,Y.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,Y.useEffect)(()=>{_();let e=setInterval(()=>void _(),8e3);return()=>clearInterval(e)},[_]);let v=(0,Y.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(g.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await _()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[g,r,d,e.browserCdpLaunchedAtPort,n,_]),y=(0,Y.useCallback)(async e=>{await i(e),await _()},[_,i]),b=(0,Y.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Ie,{icon:E,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:d===`pending`,onClick:()=>void v(),children:[d===`pending`?(0,Z.jsx)(x,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(E,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[f?(0,Z.jsx)(Re,{kind:d===`error`?`error`:`success`,message:f}):null,(0,Z.jsx)(Q,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:g,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:u.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,Z.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void y(t.port),children:[(0,Z.jsx)(j,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Ie,{icon:ee,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||p===`pending`,onClick:()=>void b(),children:[p===`pending`?(0,Z.jsx)(x,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(K,{className:`size-3.5`}),p===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),m?(0,Z.jsx)(Re,{kind:p===`error`?`error`:`success`,message:m}):null]})]})}function Ve(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function He(e){let t=(0,X.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=Ve(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,Z.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,Z.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,Z.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted shadow-surface`,children:r.lines.map(Ue)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-surface-base px-3 py-2.5 shadow-surface`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function Ue(e){return(0,Z.jsx)(`div`,{className:`truncate`,children:e},e)}var We={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function Ge({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:a,launchCloak:o,form:s,onChange:c,embedded:l=!1}){let[u,d]=(0,Y.useReducer)(h,We),{confirmOpen:p,installStatus:m,installMessage:g,openStatus:_,openMessage:v,runtime:y}=u,{progress:b,running:C,cancelling:w,run:D,reset:O,cancel:k}=i,A=t.kind===`ok`?t.data:null,j=A?.installed===!0,M=m===`installing`||C,P=(0,Y.useCallback)(async()=>{if(j)try{d({type:`patch`,patch:{runtime:await a()}})}catch{}},[a,j]);(0,Y.useEffect)(()=>{if(!j){d({type:`patch`,patch:{runtime:null}});return}P();let e=setInterval(()=>void P(),8e3);return()=>clearInterval(e)},[j,P]);let F=(0,Y.useCallback)(async()=>{d({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),O();let t=await D({body:{cacheDir:s.cacheDir.trim()||void 0,binaryPath:s.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){d({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){d({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),O();return}d({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),d({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:s.cacheDir,binaryPath:s.binaryPath}),await P()},[r,s.binaryPath,s.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,P,O,D]),I=(0,Y.useCallback)(async()=>{if(_!==`pending`){d({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await o();d({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){d({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[o,e.browserCloakOpenLaunched,e.browserCloakOpenReused,_]),L=t.kind===`loading`?`checking`:t.kind===`error`?`error`:j?`ready`:`not_installed`,R=j&&A?.version?`v${A.version} (${A.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ie,{icon:z,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:L,statusDetail:R,m:e,embedded:l,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[j?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:_===`pending`,onClick:()=>void I(),children:[_===`pending`?(0,Z.jsx)(x,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(E,{className:`size-3.5`}),_===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:M,onClick:()=>d({type:`patch`,patch:{confirmOpen:!0}}),children:[M?(0,Z.jsx)(x,{className:`size-3.5 animate-spin`}):j?(0,Z.jsx)(N,{className:`size-3.5`}):m===`installed`?(0,Z.jsx)(f,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(S,{className:`size-3.5`}),M?e.browserCloakInstalling:j?e.browserReinstall:e.browserCloakDownload]})]}),children:[C?(0,Z.jsx)(He,{m:e,progress:b,cancelling:w,onCancel:()=>void k()}):null,g?(0,Z.jsx)(Re,{kind:m===`failed`?`error`:`success`,message:g}):null,v?(0,Z.jsx)(Re,{kind:_===`error`?`error`:`success`,message:v}):null,j&&y?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:y.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(y.port)):e.browserCloakRuntimeOff})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:y.userDataDir})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),y.temporaryProfile?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.keepOpen,onChange:e=>c({keepOpen:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.temporaryProfile,onChange:e=>c({temporaryProfile:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.humanize,onChange:e=>c({humanize:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,Z.jsxs)(ne,{className:de(),value:s.humanPreset,onChange:e=>c({humanPreset:e.target.value}),children:[(0,Z.jsx)(G,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(G,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(q,{className:`mt-4`,children:[(0,Z.jsx)(le,{icon:z,title:e.browserCloakAdvancedShow}),(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsxs)(Q,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>c({cacheDir:e.target.value}),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,Z.jsxs)(Q,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>c({binaryPath:e.target.value}),autoComplete:`off`}),s.binaryPath.trim()?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,Z.jsx)(Q,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.timezone,placeholder:`America/New_York`,onChange:e=>c({timezone:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.locale,placeholder:`en-US`,onChange:e=>c({locale:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>c({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.fingerprintPlatform,placeholder:`macos`,onChange:e=>c({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Z.jsx)(Q,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,Z.jsx)(`textarea`,{className:Ke(),value:s.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>c({extraArgs:e.target.value})})})})]})]}),(0,Z.jsx)(T,{open:p,title:e.browserConfirmDownloadTitle,description:qe(e,A),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void F(),onCancel:()=>d({type:`patch`,patch:{confirmOpen:!1}})})]})}function Ke(){return`${J()} min-h-[4.5rem] resize-y font-mono text-xs`}function qe(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
2
- `)}function Je({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[o,s]=(0,Y.useState)(`idle`),[c,l]=(0,Y.useState)(null),d=t.provider===`local`?`browserbase`:t.provider,f=a(u(e=>e.language)).providersSettings,p=U({show:f.show,hide:f.hide,copy:f.copy,copied:f.copied}),m=(0,Y.useCallback)(()=>pe().then(e=>e.apiKey??null),[]),h=(0,Y.useCallback)(async()=>{s(`pending`),l(null);try{let n=await r(d,t.apiKey);n.reachable?(s(`ok`),l(e.browserCloudTestOk)):(s(`error`),l(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){s(`error`),l(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,d,r]);return(0,Z.jsxs)(Ie,{icon:O,title:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,m:e,embedded:i,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:o===`pending`,onClick:()=>void h(),children:[o===`pending`?(0,Z.jsx)(x,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(K,{className:`size-3.5`}),e.browserCloudTestConnection]}),children:[(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,children:(0,Z.jsxs)(ne,{className:de(),value:d,onChange:e=>n({provider:e.target.value}),children:[(0,Z.jsx)(G,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,Z.jsx)(G,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,Z.jsx)(R,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:d===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:p,reveal:m,loadFailedLabel:`Failed to load key`})}),d===`browserbase`?(0,Z.jsx)(Q,{label:e.label.browserCloudProjectId,description:e.desc.browserCloudProjectId,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.projectId,placeholder:`BROWSERBASE_PROJECT_ID`,onChange:e=>n({projectId:e.target.value}),autoComplete:`off`})}):null,(0,Z.jsx)(Q,{label:e.label.browserCloudRegion,description:e.desc.browserCloudRegion,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.region,placeholder:`us-west-2`,onChange:e=>n({region:e.target.value}),autoComplete:`off`})})]}),c?(0,Z.jsx)(Re,{kind:o===`error`?`error`:`success`,message:c}):null]})}function Ye(e){let t=(0,X.c)(48),{m:n,installed:r,extensionDir:a,connected:o,busy:s,onOpenChrome:c,onCopyPath:l,onRevealFolder:u,pathBusy:d,folderBusy:p}=e,m;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(m={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=m):m=t[2];let h=!!a&&o,g;t[3]!==s||t[4]!==a||t[5]!==p||t[6]!==n.browserExtensionCopyPath||t[7]!==n.browserExtensionInstallStep2FolderLabel||t[8]!==n.browserExtensionInstalling||t[9]!==n.browserExtensionOpenChrome||t[10]!==n.browserExtensionRevealFolder||t[11]!==l||t[12]!==c||t[13]!==u||t[14]!==d?(g=a?(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-raised px-2.5 py-2 shadow-surface`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.browserExtensionInstallStep2FolderLabel}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-fg`,children:a}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:c,children:n.browserExtensionOpenChrome}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:l,title:a,children:d?n.browserExtensionInstalling:n.browserExtensionCopyPath}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:u,title:a,children:p?n.browserExtensionInstalling:n.browserExtensionRevealFolder})]})]}):null,t[3]=s,t[4]=a,t[5]=p,t[6]=n.browserExtensionCopyPath,t[7]=n.browserExtensionInstallStep2FolderLabel,t[8]=n.browserExtensionInstalling,t[9]=n.browserExtensionOpenChrome,t[10]=n.browserExtensionRevealFolder,t[11]=l,t[12]=c,t[13]=u,t[14]=d,t[15]=g):g=t[15];let _;t[16]!==n.browserExtensionInstallStep2||t[17]!==h||t[18]!==g?(_={id:`load`,label:n.browserExtensionInstallStep2,done:h,detail:g},t[16]=n.browserExtensionInstallStep2,t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==o||t[21]!==n.browserExtensionInstallStep3?(v={id:`connect`,label:n.browserExtensionInstallStep3,done:o},t[20]=o,t[21]=n.browserExtensionInstallStep3,t[22]=v):v=t[22];let y;t[23]!==m||t[24]!==_||t[25]!==v?(y=[m,_,v],t[23]=m,t[24]=_,t[25]=v,t[26]=y):y=t[26];let x=y,S;t[27]===x?S=t[28]:(S=x.filter(Xe),t[27]=x,t[28]=S);let C=S.length,w=n.browserExtensionInstallGuideTitle,T;t[29]===n.browserExtensionInstallGuideTitle?T=t[30]:(T=(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=T);let E;t[31]!==C||t[32]!==n.browserExtensionChecklistProgress||t[33]!==x.length?(E=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(C)).replace(`{{total}}`,String(x.length)),t[31]=C,t[32]=n.browserExtensionChecklistProgress,t[33]=x.length,t[34]=E):E=t[34];let D;t[35]===E?D=t[36]:(D=(0,Z.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:E}),t[35]=E,t[36]=D);let O;t[37]!==D||t[38]!==T?(O=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[T,D]}),t[37]=D,t[38]=T,t[39]=O):O=t[39];let k;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==x?(k=(0,Z.jsx)(`ol`,{className:`flex flex-col gap-3`,children:x.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:e.done?(0,Z.jsx)(f,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,Z.jsx)(b,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:i(`text-[11px] leading-relaxed`,e.done?`text-fg-muted line-through decoration-fg-subtle/60`:`text-fg`),children:[(0,Z.jsxs)(`span`,{className:`sr-only`,children:[e.done?n.browserExtensionChecklistDone:n.browserExtensionChecklistPending,` `]}),t+1,`. `,e.label]}),e.detail]})]},e.id))}),t[40]=n.browserExtensionChecklistDone,t[41]=n.browserExtensionChecklistPending,t[42]=x,t[43]=k):k=t[43];let A;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==O||t[46]!==k?(A=(0,Z.jsxs)(`div`,{"aria-label":w,className:`rounded-xl bg-surface-base px-3 py-3`,children:[O,k]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=O,t[46]=k,t[47]=A):A=t[47],A}function Xe(e){return e.done}var Ze=19820,Qe=3e4;function $e({m:e,probe:t,artifacts:n,onChange:r,startBridge:i,stopBridge:a,disconnectExtension:o,installArtifacts:s,refetchArtifacts:c,openExtensionChrome:l,revealExtensionFolder:u,form:f,embedded:p=!1}){let[m,h]=(0,Y.useState)(null),[g,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),w=f.port??Ze,T=f.host||`127.0.0.1`,D=`ws://${T}:${w}/browser-ext`,O=t.kind===`ok`&&t.data.running,k=t.kind===`ok`&&t.data.connected,A=t.kind===`ok`&&t.data.bridgeHeld===!0,M=t.kind===`ok`&&t.data.portConflict===!0,N=O||A,P=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,F=P?.installed===!0,L=P?.extensionDir,R=P?.needsChromeReload===!0,z=t.kind===`ok`?k?{icon:_,color:`text-green-500`,label:e.browserExtensionConnected}:O?{icon:K,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:C,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:C,color:`text-fg-muted`,label:`…`},ee=z.icon,B=(0,Y.useCallback)(async()=>{if(!m){h(`start`),v(null);try{await i({host:T,port:w})}catch(e){v(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,T,w,i]),V=(0,Y.useCallback)(async()=>{if(!m){h(`stop`),v(null);try{await a()}catch(e){v(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,a]),H=(0,Y.useCallback)(async()=>{if(!m){h(`disconnect`),v(null);try{await o()}catch(e){v(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,o]),te=(0,Y.useCallback)(async()=>{if(!m){h(`install`),v(null),b(null);try{let t=await s({force:F});t?.extensionDir?b(`${e.browserExtensionInstalled}: ${t.extensionDir}`):b(e.browserExtensionInstalled),await c()}catch(e){v(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,s,F,e.browserExtensionInstalled,c]),U=(0,Y.useCallback)(async()=>{if(!m){h(`open`),v(null);try{await l()}catch(e){v(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,l]),W=(0,Y.useCallback)(async()=>{if(!(!L||m)){h(`path`),v(null),b(null);try{await I(L)?d({type:`success`,title:e.browserExtensionPathCopied}):b(e.browserExtensionPathCopyFailed)}catch(e){v(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,L,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),G=(0,Y.useCallback)(async()=>{if(!(!L||m)){h(`folder`),v(null),b(null);try{await u(),d({type:`success`,title:e.browserExtensionFolderOpened})}catch(e){v(e instanceof Error?e.message:String(e))}finally{h(null)}}},[m,L,e.browserExtensionFolderOpened,u]),ne=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void te(),children:[m===`install`?(0,Z.jsx)(x,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(S,{className:`size-3.5`}),m===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),N?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void V(),children:[m===`stop`?(0,Z.jsx)(x,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(j,{className:`size-3.5`}),e.browserExtensionStopBridge]}):(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void B(),children:[m===`start`?(0,Z.jsx)(x,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(E,{className:`size-3.5`}),m===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),k?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void H(),children:[m===`disconnect`?(0,Z.jsx)(x,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(C,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,Z.jsx)(Ie,{icon:re,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:p,primaryAction:ne,advancedTitle:e.browserAdvancedShow,advanced:(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserExtensionPort,description:e.desc.browserExtensionPort,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1024,max:65535,value:f.port??``,placeholder:String(Ze),onChange:e=>{let t=e.target.value;r({port:t===``?void 0:Number.parseInt(t,10)})}})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionHost,description:e.desc.browserExtensionHost,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:f.host,placeholder:`127.0.0.1`,onChange:e=>r({host:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionConnectionTimeout,description:e.desc.browserExtensionConnectionTimeout,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1,step:1,value:f.connectionTimeoutMs==null?``:Math.round(f.connectionTimeoutMs/1e3),placeholder:String(Qe/1e3),onChange:e=>{let t=e.target.value;r({connectionTimeoutMs:t===``?void 0:Math.max(1,Number.parseInt(t,10))*1e3})}})})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:D}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${z.color}`,children:[(0,Z.jsx)(ee,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:z.label})]})]}),(0,Z.jsx)(Ye,{m:e,installed:F,extensionDir:L,connected:k,busy:m!==null,pathBusy:m===`path`,folderBusy:m===`folder`,onOpenChrome:()=>void U(),onCopyPath:()=>void W(),onRevealFolder:()=>void G()}),R?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionNeedsChromeReload}):null,M?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionPortConflict.replace(`{{port}}`,String(w))}):null,y?(0,Z.jsx)(Re,{kind:`success`,message:y}):null,g?(0,Z.jsx)(Re,{kind:`error`,message:g}):null]})})}function et(e){let t=(0,X.c)(41),{m:n,doctor:r,refetch:i,applyDoctor:a,installStream:o,embedded:s}=e,c=s===void 0?!1:s,[l,u]=(0,Y.useState)(`idle`),[d,p]=(0,Y.useState)(null),{progress:m,running:h,cancelling:g,run:_,reset:v,cancel:y}=o,b;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==v||t[5]!==_?(b=async()=>{u(`installing`),p(null),v();let e=await _({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){u(`installing`);return}if(e.error===`cancelled`){u(`idle`),p(null),v();return}u(`failed`),p(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),u(`installed`),p(e.payload?.executablePath?`${n.browserPlaywrightInstalled}: ${e.payload.executablePath}`:n.browserPlaywrightInstalled),await i()},t[0]=a,t[1]=n.browserPlaywrightInstallFailed,t[2]=n.browserPlaywrightInstalled,t[3]=i,t[4]=v,t[5]=_,t[6]=b):b=t[6];let C=b,T=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,E=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,D=r.kind===`ok`&&r.data.installed,O=l===`installing`||h,k;t[7]===C?k=t[8]:(k=()=>void C(),t[7]=C,t[8]=k);let A;t[9]!==D||t[10]!==O||t[11]!==l?(A=O?(0,Z.jsx)(x,{className:`size-3.5 animate-spin`}):D?(0,Z.jsx)(N,{className:`size-3.5`}):l===`installed`?(0,Z.jsx)(f,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(S,{className:`size-3.5`}),t[9]=D,t[10]=O,t[11]=l,t[12]=A):A=t[12];let j=O?n.browserPlaywrightInstalling:D?n.browserReinstall:n.browserPlaywrightInstall,M;t[13]!==O||t[14]!==k||t[15]!==A||t[16]!==j?(M=(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:O,onClick:k,children:[A,j]}),t[13]=O,t[14]=k,t[15]=A,t[16]=j,t[17]=M):M=t[17];let P;t[18]===n.browserPlaywrightManualInstall?P=t[19]:(P=(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=P);let F;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(`code`,{className:`mt-2 block w-fit rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg`,children:`node node_modules/playwright-core/cli.js install chromium`}),t[20]=F):F=t[20];let I;t[21]===P?I=t[22]:(I=(0,Z.jsxs)(`div`,{className:`text-xs`,children:[P,F]}),t[21]=P,t[22]=I);let L;t[23]!==y||t[24]!==g||t[25]!==n||t[26]!==m||t[27]!==h?(L=h?(0,Z.jsx)(He,{m:n,progress:m,showLogs:!0,cancelling:g,onCancel:()=>void y()}):null,t[23]=y,t[24]=g,t[25]=n,t[26]=m,t[27]=h,t[28]=L):L=t[28];let R;t[29]!==d||t[30]!==l?(R=d?(0,Z.jsx)(Re,{kind:l===`failed`?`error`:`success`,message:d}):null,t[29]=d,t[30]=l,t[31]=R):R=t[31];let z;return t[32]!==c||t[33]!==n||t[34]!==E||t[35]!==T||t[36]!==L||t[37]!==R||t[38]!==M||t[39]!==I?(z=(0,Z.jsxs)(Ie,{icon:w,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:T,statusDetail:E,m:n,embedded:c,primaryAction:M,children:[I,L,R]}),t[32]=c,t[33]=n,t[34]=E,t[35]=T,t[36]=L,t[37]=R,t[38]=M,t[39]=I,t[40]=z):z=t[40],z}async function tt(e){let t=await l(e),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1){let e=typeof n.error==`string`?n.error:n.error?.message;throw Error(e||`Request failed: ${t.status}`)}if(n.payload===void 0)throw Error(`Empty payload`);return n.payload}async function $(e,t){let n=await l(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1){let e=typeof r.error==`string`?r.error:r.error?.message;throw Error(e||`Request failed: ${n.status}`)}if(r.payload===void 0)throw Error(`Empty payload`);return r.payload}var nt={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function rt(e,t){switch(t.type){case`playwright`:return{...e,playwright:t.state};case`cloak`:return{...e,cloak:t.state};case`extension`:return{...e,extension:t.state};case`extension-artifacts`:return{...e,extensionArtifacts:t.state};case`playwright-idle`:return{...e,playwright:{kind:`idle`}};case`cloak-idle`:return{...e,cloak:{kind:`idle`}};case`extension-idle`:return{...e,extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};case`extension-start-probe`:return{...e,extension:e.extension.kind===`ok`?e.extension:{kind:`loading`}};case`extension-artifacts-start-probe`:return{...e,extensionArtifacts:e.extensionArtifacts.kind===`ok`?e.extensionArtifacts:{kind:`loading`}}}}function it(e){let[t,n]=(0,Y.useReducer)(rt,nt),{playwright:r,cloak:i,extension:a,extensionArtifacts:o}=t,s=(0,Y.useCallback)(async()=>{n({type:`playwright`,state:{kind:`loading`}});try{n({type:`playwright`,state:{kind:`ok`,data:await tt(c(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),u=(0,Y.useCallback)(async t=>{n({type:`cloak`,state:{kind:`loading`}});let r=(t?.cacheDir??e.cacheDir??``).trim(),i=(t?.binaryPath??e.binaryPath??``).trim(),a=new URLSearchParams;r&&a.set(`cacheDir`,r),i&&a.set(`binaryPath`,i);try{let e=await tt(c(`/api/browser/cloakbrowser/doctor${a.size?`?${a}`:``}`));return n({type:`cloak`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`cloak`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[e.binaryPath,e.cacheDir]),d=(0,Y.useCallback)(e=>{n({type:`playwright`,state:{kind:`ok`,data:e}})},[]),f=(0,Y.useCallback)(e=>{n({type:`cloak`,state:{kind:`ok`,data:e}})},[]),p=(0,Y.useCallback)(async()=>tt(c(`/api/browser/cloakbrowser/status`)),[]),m=(0,Y.useCallback)(async()=>$(c(`/api/browser/cloakbrowser/launch`),{}),[]),h=e.browserEnabled===!0&&e.probeExtension===!0,g=e.browserEnabled===!0&&e.probeLocal===!0,_=e.browserEnabled===!0&&e.probeCloak===!0,{extensionHost:v,extensionPort:y}=e,b=(0,Y.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});v&&e.set(`host`,v),y!==void 0&&e.set(`port`,String(y)),n({type:`extension-start-probe`});try{let t=await l(c(`/api/browser/extension-status?${e}`),{signal:AbortSignal.timeout(3e3)}),r=await t.json().catch(()=>({}));if(!t.ok){n({type:`extension`,state:{kind:`error`,message:`HTTP ${t.status}`}});return}n({type:`extension`,state:{kind:`ok`,data:{running:r.running===!0,connected:r.connected===!0,backend:r.backend,artifacts:r.artifacts,bridgeHeld:r.bridgeHeld===!0,refCount:typeof r.refCount==`number`?r.refCount:void 0,manualBridge:r.manualBridge===!0,portConflict:r.portConflict===!0}}})}catch(e){n({type:`extension`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[v,y]),x=(0,Y.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await tt(c(`/api/browser/extension/doctor`));return n({type:`extension-artifacts`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`extension-artifacts`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[]),S=(0,Y.useCallback)(async e=>{let t=(await $(c(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await b(),t},[b]),C=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/open`),{action:`folder`})},[]);(0,Y.useEffect)(()=>{if(!g){n({type:`playwright-idle`});return}s()},[g,s]),(0,Y.useEffect)(()=>{if(!_){n({type:`cloak-idle`});return}u()},[_,u]);let T=(0,Y.useRef)(h);T.current!==h&&(T.current=h,h||n({type:`extension-idle`})),(0,Y.useEffect)(()=>{if(!h)return;b(),x();let e=setInterval(()=>void b(),5e3);return()=>clearInterval(e)},[h,b,x]);let E=(0,Y.useCallback)(async e=>{await $(c(`/api/browser/extension/start`),{host:e?.host??v,port:e?.port??y}),await b()},[v,y,b]),D=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/stop`),{}),await b()},[b]),O=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/disconnect`),{}),await b()},[b]),k=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!h||e.activeBackend!==`extension`){k.current=null;return}if(a.kind!==`ok`||a.data.running||a.data.bridgeHeld)return;let t=`${v}:${y??19820}`;k.current!==t&&(k.current=t,E({host:v,port:y}).catch(()=>{k.current=null}))},[h,a,v,y,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:o,refetchPlaywright:s,applyPlaywrightDoctor:d,refetchCloak:u,applyCloakDoctor:f,fetchCloakRuntimeStatus:p,launchCloak:m,refetchExtension:b,refetchExtensionArtifacts:x,installExtensionArtifacts:S,openExtensionChrome:C,revealExtensionFolder:w,pingCdp:(0,Y.useCallback)(async e=>$(c(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,Y.useCallback)(async(e,t)=>$(c(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,Y.useCallback)(async e=>$(c(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,Y.useCallback)(async e=>{await $(c(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,Y.useCallback)(async()=>(await tt(c(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var at=`
3
-
4
- `,ot=/\r\n/g,st={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},ct={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},lt=8;function ut(){return{phase:null,message:null,percent:null,lines:[]}}function dt(e,t){let n={phase:t.phase,message:t.message??t.line??e.message,percent:t.percent??e.percent,lines:e.lines};if(t.line){let r=[...e.lines,t.line];n.lines=r.length>lt?r.slice(-8):r}return n}async function ft(e,t,n){let r=e.getReader(),i=new TextDecoder,a=``,o=null,s=e=>{let n=``,r=``;for(let t of e.split(`
5
- `)){let e=t.replace(/\r$/,``);e.startsWith(`event:`)?n=e.slice(6).trim():e.startsWith(`data:`)&&(r+=e.slice(5).trimStart())}if(r){if(n===`progress`){try{let e=JSON.parse(r);e&&typeof e==`object`&&typeof e.phase==`string`&&t(e)}catch{}return}if(n===`result`)try{let e=JSON.parse(r);o=e.ok?{ok:!0,payload:e.payload}:{ok:!1,error:String(e.error??`unknown`),message:typeof e.message==`string`?e.message:void 0,status:e.error===`busy`?409:e.error===`cancelled`?499:500}}catch{o={ok:!1,error:`parse`,status:0}}}};try{let e=async()=>{if(o!==null)return o;if(n?.aborted)return await r.cancel().catch(()=>{}),{ok:!1,error:`cancelled`,status:499};let{done:t,value:c}=await r.read();if(t)return o??{ok:!1,error:`no-result`,status:0};a+=i.decode(c,{stream:!0}),a=a.replace(ot,`
6
- `);let l=a.split(at);a=l.pop()??``;for(let e of l)e.length&&s(e);return e()},t=await e();if(t)return t}catch(e){if(n?.aborted||e instanceof DOMException&&e.name===`AbortError`)return{ok:!1,error:`cancelled`,status:499};throw e}finally{r.releaseLock()}return o||(n?.aborted?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`no-result`,status:0})}function pt(e){let[t,n]=(0,Y.useState)(ut),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),s=(0,Y.useRef)(!1),u=(0,Y.useRef)(null),d=(0,Y.useCallback)(()=>{s.current||n(ut())},[]),f=(0,Y.useCallback)(async()=>{if(s.current){o(!0);try{await l(c(ct[e]),{method:`POST`}).catch(()=>{}),u.current?.abort()}finally{o(!1)}}},[e]);return{progress:t,running:r,cancelling:a,run:(0,Y.useCallback)(async t=>{if(s.current)return{ok:!1,error:`busy`,status:409,errorMessage:`An install for this browser type is already in progress.`};let r=new AbortController;u.current=r,s.current=!0,i(!0),n(ut());try{let i=await l(c(st[e]),{method:`POST`,headers:{Accept:`text/event-stream`,...t.body===void 0?{}:{"Content-Type":`application/json`}},body:t.body===void 0?void 0:JSON.stringify(t.body),signal:r.signal});if(!i.ok||!i.body){let e=await i.text().catch(()=>``),t=`HTTP ${i.status}`;try{let n=JSON.parse(e);typeof n.message==`string`?t=n.message:typeof n.error==`string`&&(t=n.error)}catch{e&&(t=e.slice(0,500))}return{ok:!1,error:i.status===409?`busy`:`http`,status:i.status,errorMessage:t}}let a=await ft(i.body,e=>{n(t=>dt(t,e))},r.signal);return a.ok?a:a.error===`cancelled`?{...a,errorMessage:void 0}:{...a,errorMessage:a.message??(a.error===`busy`?`An install for this browser type is already in progress.`:t.fallbackError)}}catch(e){return r.signal.aborted||e instanceof DOMException&&e.name===`AbortError`?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`network`,errorMessage:e instanceof Error?e.message:t.fallbackError}}finally{u.current===r&&(u.current=null),s.current=!1,i(!1),o(!1)}},[e]),reset:d,cancel:f}}function mt(e){let t=(0,X.c)(150),{a:n,form:r,update:a,activeTab:o,setActiveTab:s}=e,c=u(gt),l=V(ht),d=pt(`playwright`),f=pt(`cloakbrowser`),p=r.browserEnabled&&(o===`overview`||o===`extension`),m=r.browserEnabled&&(o===`overview`||o===`local`),h=r.browserEnabled&&(o===`overview`||o===`cloakbrowser`),g;t[0]!==r.browserBackend||t[1]!==r.browserCloakBinaryPath||t[2]!==r.browserCloakCacheDir||t[3]!==r.browserEnabled||t[4]!==r.browserExtensionHost||t[5]!==r.browserExtensionPort||t[6]!==h||t[7]!==p||t[8]!==m?(g={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:p,probeLocal:m,probeCloak:h,extensionHost:r.browserExtensionHost,extensionPort:r.browserExtensionPort},t[0]=r.browserBackend,t[1]=r.browserCloakBinaryPath,t[2]=r.browserCloakCacheDir,t[3]=r.browserEnabled,t[4]=r.browserExtensionHost,t[5]=r.browserExtensionPort,t[6]=h,t[7]=p,t[8]=m,t[9]=g):g=t[9];let _=it(g),v;t[10]===_.playwright?v=t[11]:(v=De(_.playwright),t[10]=_.playwright,t[11]=v);let y=v,b;t[12]===_.cloak?b=t[13]:(b=De(_.cloak),t[12]=_.cloak,t[13]=b);let x=b,S;t[14]===_.extension?S=t[15]:(S=ke(_.extension),t[14]=_.extension,t[15]=S);let C=S,T;t[16]!==n||t[17]!==_.extension?(T=Ae(_.extension,n),t[16]=n,t[17]=_.extension,t[18]=T):T=t[18];let E=T,D;t[19]!==n||t[20]!==x||t[21]!==C||t[22]!==E||t[23]!==y||t[24]!==l?(D=[{value:`extension`,icon:re,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:C,statusLabel:E},{value:`local`,icon:w,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:y,statusLabel:Oe(y,n)},{value:`cloakbrowser`,icon:z,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:x,statusLabel:Oe(x,n)},{value:`cdp`,icon:ee,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:O,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>me(e.value,l)),t[19]=n,t[20]=x,t[21]=C,t[22]=E,t[23]=y,t[24]=l,t[25]=D):D=t[25];let k=D,A;t[26]!==s||t[27]!==a?(A=e=>{a({browserEnabled:!0,browserBackend:e}),s(e)},t[26]=s,t[27]=a,t[28]=A):A=t[28];let j=A,N=!r.browserEnabled&&`pointer-events-none opacity-40`,P;t[29]===N?P=t[30]:(P=i(`flex flex-col gap-5 transition-opacity`,N),t[29]=N,t[30]=P);let F=!r.browserEnabled,I;t[31]!==n||t[32]!==o||t[33]!==_.disconnectExtension||t[34]!==_.extension||t[35]!==_.extensionArtifacts||t[36]!==_.installExtensionArtifacts||t[37]!==_.openExtensionChrome||t[38]!==_.refetchExtensionArtifacts||t[39]!==_.revealExtensionFolder||t[40]!==_.startExtensionBridge||t[41]!==_.stopExtensionBridge||t[42]!==r.browserExtensionConnectionTimeout||t[43]!==r.browserExtensionHost||t[44]!==r.browserExtensionPort||t[45]!==a?(I=o===`extension`?(0,Z.jsx)(q,{children:(0,Z.jsx)($e,{embedded:!0,m:n,probe:_.extension,artifacts:_.extensionArtifacts,form:{port:r.browserExtensionPort,host:r.browserExtensionHost,connectionTimeoutMs:r.browserExtensionConnectionTimeout},onChange:e=>a({...e.port===void 0?{}:{browserExtensionPort:e.port},...e.host===void 0?{}:{browserExtensionHost:e.host},...e.connectionTimeoutMs===void 0?{}:{browserExtensionConnectionTimeout:e.connectionTimeoutMs}}),startBridge:_.startExtensionBridge,stopBridge:_.stopExtensionBridge,disconnectExtension:_.disconnectExtension,installArtifacts:_.installExtensionArtifacts,refetchArtifacts:_.refetchExtensionArtifacts,openExtensionChrome:_.openExtensionChrome,revealExtensionFolder:_.revealExtensionFolder})}):null,t[31]=n,t[32]=o,t[33]=_.disconnectExtension,t[34]=_.extension,t[35]=_.extensionArtifacts,t[36]=_.installExtensionArtifacts,t[37]=_.openExtensionChrome,t[38]=_.refetchExtensionArtifacts,t[39]=_.revealExtensionFolder,t[40]=_.startExtensionBridge,t[41]=_.stopExtensionBridge,t[42]=r.browserExtensionConnectionTimeout,t[43]=r.browserExtensionHost,t[44]=r.browserExtensionPort,t[45]=a,t[46]=I):I=t[46];let L;t[47]!==n||t[48]!==o||t[49]!==_.applyPlaywrightDoctor||t[50]!==_.playwright||t[51]!==_.refetchPlaywright||t[52]!==d?(L=o===`local`?(0,Z.jsx)(q,{children:(0,Z.jsx)(et,{embedded:!0,m:n,doctor:_.playwright,refetch:_.refetchPlaywright,applyDoctor:_.applyPlaywrightDoctor,installStream:d})}):null,t[47]=n,t[48]=o,t[49]=_.applyPlaywrightDoctor,t[50]=_.playwright,t[51]=_.refetchPlaywright,t[52]=d,t[53]=L):L=t[53];let R;t[54]!==n||t[55]!==o||t[56]!==f||t[57]!==_.applyCloakDoctor||t[58]!==_.cloak||t[59]!==_.fetchCloakRuntimeStatus||t[60]!==_.launchCloak||t[61]!==_.refetchCloak||t[62]!==r.browserCloakBinaryPath||t[63]!==r.browserCloakCacheDir||t[64]!==r.browserCloakExtraArgs||t[65]!==r.browserCloakFingerprintPlatform||t[66]!==r.browserCloakKeepOpen||t[67]!==r.browserCloakLocale||t[68]!==r.browserCloakTemporaryProfile||t[69]!==r.browserCloakTimezone||t[70]!==r.browserCloakWebrtcIp||t[71]!==r.browserHumanPreset||t[72]!==r.browserHumanize||t[73]!==a?(R=o===`cloakbrowser`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Ge,{embedded:!0,m:n,doctor:_.cloak,refetch:_.refetchCloak,applyDoctor:_.applyCloakDoctor,installStream:f,fetchRuntimeStatus:_.fetchCloakRuntimeStatus,launchCloak:_.launchCloak,form:{cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,keepOpen:r.browserCloakKeepOpen,temporaryProfile:r.browserCloakTemporaryProfile,humanize:r.browserHumanize,humanPreset:r.browserHumanPreset,timezone:r.browserCloakTimezone,locale:r.browserCloakLocale,webrtcIp:r.browserCloakWebrtcIp,fingerprintPlatform:r.browserCloakFingerprintPlatform,extraArgs:r.browserCloakExtraArgs},onChange:e=>a({...e.cacheDir===void 0?{}:{browserCloakCacheDir:e.cacheDir},...e.binaryPath===void 0?{}:{browserCloakBinaryPath:e.binaryPath},...e.keepOpen===void 0?{}:{browserCloakKeepOpen:e.keepOpen},...e.temporaryProfile===void 0?{}:{browserCloakTemporaryProfile:e.temporaryProfile},...e.humanize===void 0?{}:{browserHumanize:e.humanize},...e.humanPreset===void 0?{}:{browserHumanPreset:e.humanPreset},...e.timezone===void 0?{}:{browserCloakTimezone:e.timezone},...e.locale===void 0?{}:{browserCloakLocale:e.locale},...e.webrtcIp===void 0?{}:{browserCloakWebrtcIp:e.webrtcIp},...e.fingerprintPlatform===void 0?{}:{browserCloakFingerprintPlatform:e.fingerprintPlatform},...e.extraArgs===void 0?{}:{browserCloakExtraArgs:e.extraArgs}})})}):null,t[54]=n,t[55]=o,t[56]=f,t[57]=_.applyCloakDoctor,t[58]=_.cloak,t[59]=_.fetchCloakRuntimeStatus,t[60]=_.launchCloak,t[61]=_.refetchCloak,t[62]=r.browserCloakBinaryPath,t[63]=r.browserCloakCacheDir,t[64]=r.browserCloakExtraArgs,t[65]=r.browserCloakFingerprintPlatform,t[66]=r.browserCloakKeepOpen,t[67]=r.browserCloakLocale,t[68]=r.browserCloakTemporaryProfile,t[69]=r.browserCloakTimezone,t[70]=r.browserCloakWebrtcIp,t[71]=r.browserHumanPreset,t[72]=r.browserHumanize,t[73]=a,t[74]=R):R=t[74];let B;t[75]!==n||t[76]!==o||t[77]!==_.launchCdp||t[78]!==_.listCdpInstances||t[79]!==_.pingCdp||t[80]!==_.stopCdp||t[81]!==r.browserCdpUrl||t[82]!==a?(B=o===`cdp`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Be,{embedded:!0,m:n,cdpUrl:r.browserCdpUrl,onCdpUrlChange:e=>a({browserCdpUrl:e}),launch:_.launchCdp,stop:_.stopCdp,listInstances:_.listCdpInstances,ping:_.pingCdp})}):null,t[75]=n,t[76]=o,t[77]=_.launchCdp,t[78]=_.listCdpInstances,t[79]=_.pingCdp,t[80]=_.stopCdp,t[81]=r.browserCdpUrl,t[82]=a,t[83]=B):B=t[83];let H;t[84]!==n||t[85]!==o||t[86]!==_.testCloud||t[87]!==r.browserCloudApiKey||t[88]!==r.browserCloudProjectId||t[89]!==r.browserCloudProvider||t[90]!==r.browserCloudRegion||t[91]!==a?(H=o===`cloud`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Je,{embedded:!0,m:n,form:{provider:r.browserCloudProvider,apiKey:r.browserCloudApiKey,projectId:r.browserCloudProjectId,region:r.browserCloudRegion},onChange:e=>a({...e.provider===void 0?{}:{browserCloudProvider:e.provider},...e.apiKey===void 0?{}:{browserCloudApiKey:e.apiKey},...e.projectId===void 0?{}:{browserCloudProjectId:e.projectId},...e.region===void 0?{}:{browserCloudRegion:e.region}}),testCloud:_.testCloud})}):null,t[84]=n,t[85]=o,t[86]=_.testCloud,t[87]=r.browserCloudApiKey,t[88]=r.browserCloudProjectId,t[89]=r.browserCloudProvider,t[90]=r.browserCloudRegion,t[91]=a,t[92]=H):H=t[92];let te;t[93]!==I||t[94]!==L||t[95]!==R||t[96]!==B||t[97]!==H||t[98]!==P||t[99]!==F?(te=(0,Z.jsxs)(`div`,{className:P,"aria-hidden":F,children:[I,L,R,B,H]}),t[93]=I,t[94]=L,t[95]=R,t[96]=B,t[97]=H,t[98]=P,t[99]=F,t[100]=te):te=t[100];let U=te;if(o===`overview`){let e;t[101]!==n||t[102]!==r.browserEnabled||t[103]!==j?(e=r.browserEnabled?null:(0,Z.jsx)(Te,{m:n,onStart:j}),t[101]=n,t[102]=r.browserEnabled,t[103]=j,t[104]=e):e=t[104];let o;t[105]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,"aria-hidden":!0,children:(0,Z.jsx)(M,{className:`size-4`,strokeWidth:1.75})}),t[105]=o):o=t[105];let l;t[106]===a?l=t[107]:(l=e=>a({browserEnabled:e.target.checked}),t[106]=a,t[107]=l);let u;t[108]!==r.browserEnabled||t[109]!==l?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserEnabled,onChange:l}),t[108]=r.browserEnabled,t[109]=l,t[110]=u):u=t[110];let d;t[111]===n.browserEnabledOn?d=t[112]:(d=(0,Z.jsx)(`span`,{children:n.browserEnabledOn}),t[111]=n.browserEnabledOn,t[112]=d);let f;t[113]!==u||t[114]!==d?(f=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[u,d]}),t[113]=u,t[114]=d,t[115]=f):f=t[115];let p;t[116]!==n.desc.browserEnabled||t[117]!==n.label.browserEnabled||t[118]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[o,(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Q,{label:n.label.browserEnabled,description:n.desc.browserEnabled,children:f})})]}),t[116]=n.desc.browserEnabled,t[117]=n.label.browserEnabled,t[118]=f,t[119]=p):p=t[119];let m;t[120]!==n.browserDocsLink||t[121]!==c?(m=(0,Z.jsx)(Ce,{language:c,label:n.browserDocsLink,className:`shrink-0 pt-1`}),t[120]=n.browserDocsLink,t[121]=c,t[122]=m):m=t[122];let h;t[123]!==p||t[124]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[123]=p,t[124]=m,t[125]=h):h=t[125];let g;t[126]!==n||t[127]!==r.browserBackend||t[128]!==r.browserEnabled||t[129]!==k||t[130]!==s||t[131]!==a?(g=r.browserEnabled?(0,Z.jsx)(`div`,{id:be(`connection`),className:i(`scroll-mt-24 transition-opacity`,!r.browserEnabled&&`pointer-events-none opacity-40`),children:(0,Z.jsx)(ve,{m:n,value:r.browserBackend,onChange:e=>a({browserBackend:e}),onOpenConfig:s,options:k})}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.browserDisabledHint}),t[126]=n,t[127]=r.browserBackend,t[128]=r.browserEnabled,t[129]=k,t[130]=s,t[131]=a,t[132]=g):g=t[132];let _;t[133]!==h||t[134]!==g?(_=(0,Z.jsx)(q,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,g]})}),t[133]=h,t[134]=g,t[135]=_):_=t[135];let v=!r.browserEnabled&&`pointer-events-none opacity-40`,y;t[136]===v?y=t[137]:(y=i(`transition-opacity`,v),t[136]=v,t[137]=y);let b=!r.browserEnabled,x;t[138]!==n||t[139]!==r||t[140]!==a?(x=(0,Z.jsx)(Se,{a:n,form:r,update:a}),t[138]=n,t[139]=r,t[140]=a,t[141]=x):x=t[141];let S;t[142]!==y||t[143]!==b||t[144]!==x?(S=(0,Z.jsx)(ce,{children:(0,Z.jsx)(`div`,{className:y,"aria-hidden":b,children:x})}),t[142]=y,t[143]=b,t[144]=x,t[145]=S):S=t[145];let C;return t[146]!==e||t[147]!==_||t[148]!==S?(C=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e,_,S]}),t[146]=e,t[147]=_,t[148]=S,t[149]=C):C=t[149],C}return Fe(o)?U:null}function ht(e){return e.mode}function gt(e){return e.language}function _t(e){let t=(0,X.c)(54),{sectionId:n,intro:r,vm:i,children:o,tabbed:s}=e,c=s===void 0?!1:s,l=u(vt),d;t[0]===l?d=t[1]:(d=a(l),t[0]=l,t[1]=d);let f=d,p=f.agentSettings,m=f.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(y,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===m?n=t[4]:(n=(0,Z.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:m}),t[3]=m,t[4]=n);let r;t[5]===p.needToken?r=t[6]:(r=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:p.needToken}),t[5]=p.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,Z.jsx)(oe,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,Z.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(i.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(oe,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Z.jsx)(se,{sections:1})}),t[10]=e):e=t[10],e}if(!i.form){let e=i.error??i.fetchError??p.loadError,n;t[11]===e?n=t[12]:(n=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let r;t[13]===i?r=t[14]:(r=()=>void i.mutate(),t[13]=i,t[14]=r);let a;t[15]!==f.logs.refresh||t[16]!==r?(a=(0,Z.jsx)(g,{type:`button`,variant:`secondary`,onClick:r,children:f.logs.refresh}),t[15]=f.logs.refresh,t[16]=r,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,Z.jsxs)(oe,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let h=c?void 0:r,_;t[21]===p.sectionDesc?_=t[22]:(_=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:p.sectionDesc}),t[21]=p.sectionDesc,t[22]=_);let v;t[23]!==p.saved||t[24]!==i.dirty||t[25]!==i.saveOk?(v=i.saveOk&&!i.dirty?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,role:`status`,children:p.saved}):null,t[23]=p.saved,t[24]=i.dirty,t[25]=i.saveOk,t[26]=v):v=t[26];let b=!i.dirty||i.saving,x;t[27]!==p.discard||t[28]!==b||t[29]!==i.discard?(x=(0,Z.jsx)(g,{type:`button`,variant:`secondary`,disabled:b,onClick:i.discard,children:p.discard}),t[27]=p.discard,t[28]=b,t[29]=i.discard,t[30]=x):x=t[30];let S=!i.dirty||i.saving,C;t[31]===i?C=t[32]:(C=()=>void i.save(),t[31]=i,t[32]=C);let w=i.saving?p.saving:p.save,T;t[33]!==S||t[34]!==C||t[35]!==w?(T=(0,Z.jsx)(g,{type:`button`,variant:`primary`,disabled:S,onClick:C,children:w}),t[33]=S,t[34]=C,t[35]=w,t[36]=T):T=t[36];let E;t[37]!==T||t[38]!==v||t[39]!==x?(E=(0,Z.jsxs)(Z.Fragment,{children:[v,x,T]}),t[37]=T,t[38]=v,t[39]=x,t[40]=E):E=t[40];let D;t[41]!==m||t[42]!==E||t[43]!==h||t[44]!==_?(D=(0,Z.jsx)(ie,{title:m,subtitle:h,meta:_,actions:E}),t[41]=m,t[42]=E,t[43]=h,t[44]=_,t[45]=D):D=t[45];let O;t[46]===i.error?O=t[47]:(O=i.error?(0,Z.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:i.error}):null,t[46]=i.error,t[47]=O);let k;t[48]===o?k=t[49]:(k=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:o}),t[48]=o,t[49]=k);let A;return t[50]!==D||t[51]!==O||t[52]!==k?(A=(0,Z.jsxs)(oe,{gap:`gap-6`,children:[D,O,k]}),t[50]=D,t[51]=O,t[52]=k,t[53]=A):A=t[53],A}function vt(e){return e.language}var yt={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},bt={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},xt={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},St={summaryModel:``},Ct={model:``,maxLength:void 0};function wt(e){if(!e)return``;if(typeof e==`string`)return e;if(typeof e==`object`&&!Array.isArray(e)){let t=e.primary;return typeof t==`string`?t:``}return``}function Tt(e){if(typeof e!=`object`||!e||!(`fallbacks`in e))return[];let t=e.fallbacks;return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function Et(e){return e===!0||e===`true`||e===1}function Dt(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!0,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`extension`,browserCloudProvider:`local`,browserCloudApiKey:``,browserCloudProjectId:``,browserCloudRegion:``,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserExtensionConnectionTimeout:void 0,browserCloakKeepOpen:!0,browserCloakTemporaryProfile:!1,browserCloakCacheDir:``,browserCloakBinaryPath:``,browserCloakTimezone:``,browserCloakLocale:``,browserCloakWebrtcIp:``,browserCloakFingerprintPlatform:``,browserCloakExtraArgs:``,browserHumanize:!0,browserHumanPreset:`careful`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=Et(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=Et(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.backend,l=c===`local`||c===`cdp`||c===`cloud`||c===`extension`||c===`cloakbrowser`?c:`extension`,u=n.cloudProvider,d=u===`browserbase`||u===`browser-use`?u:`local`,f=typeof n.cloud==`object`&&n.cloud&&!Array.isArray(n.cloud)?n.cloud:{},p=typeof f.apiKey==`string`?f.apiKey:``,m=typeof f.projectId==`string`?f.projectId:``,h=typeof f.region==`string`?f.region:``,g=typeof n.cdpUrl==`string`?n.cdpUrl:``,_=typeof n.extension==`object`&&n.extension&&!Array.isArray(n.extension)?n.extension:{},v=typeof _.port==`number`&&Number.isFinite(_.port)&&_.port>=1024&&_.port<=65535?Math.floor(_.port):void 0,y=typeof _.host==`string`&&_.host?_.host:`127.0.0.1`,b=typeof _.connectionTimeout==`number`&&Number.isFinite(_.connectionTimeout)&&_.connectionTimeout>=1e3?Math.floor(_.connectionTimeout):void 0,x=typeof n.cloakbrowser==`object`&&n.cloakbrowser&&!Array.isArray(n.cloakbrowser)?n.cloakbrowser:{},S=n.humanPreset==="default"?`default`:`careful`,C=n.dialogPolicy,w=C===`must_respond`||C===`auto_accept`?C:`auto_dismiss`,T=typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserBackend:l,browserCloudProvider:d,browserCloudApiKey:p,browserCloudProjectId:m,browserCloudRegion:h,browserCdpUrl:g,browserExtensionPort:v,browserExtensionHost:y,browserExtensionConnectionTimeout:b,browserCloakKeepOpen:x.keepOpen!==!1,browserCloakTemporaryProfile:x.temporaryProfile===!0,browserCloakCacheDir:typeof x.cacheDir==`string`?x.cacheDir:``,browserCloakBinaryPath:typeof x.binaryPath==`string`?x.binaryPath:``,browserCloakTimezone:typeof x.timezone==`string`?x.timezone:``,browserCloakLocale:typeof x.locale==`string`?x.locale:``,browserCloakWebrtcIp:typeof x.webrtcIp==`string`?x.webrtcIp:``,browserCloakFingerprintPlatform:typeof x.fingerprintPlatform==`string`?x.fingerprintPlatform:``,browserCloakExtraArgs:Array.isArray(x.extraArgs)?x.extraArgs.filter(e=>typeof e==`string`&&e.trim().length>0).join(`
7
- `):``,browserHumanize:n.humanize!==!1,browserHumanPreset:S,browserDialogPolicy:w,browserDialogTimeout:T}}function Ot(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...yt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:yt.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):yt.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:yt.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):yt.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):yt.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:yt.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):yt.retentionWindow}}function kt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...bt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:bt.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):bt.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:bt.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:bt.tailKeepRatio}}function At(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...xt};let t=e,n=t.provider,r=n===`none`||n===`stub`?n:``,i=t.injectionFrequency,a=i===`every-turn`||i===`first-turn`?i:``;return{enabled:typeof t.enabled==`boolean`?t.enabled:xt.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:xt.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:xt.userProfileEnabled,provider:r,injectionFrequency:a,memoryCharLimit:typeof t.memoryCharLimit==`number`&&t.memoryCharLimit>0?Math.floor(t.memoryCharLimit):void 0,userCharLimit:typeof t.userCharLimit==`number`&&t.userCharLimit>0?Math.floor(t.userCharLimit):void 0,contextCadence:typeof t.contextCadence==`number`&&t.contextCadence>=1?Math.floor(t.contextCadence):void 0,dialecticCadence:typeof t.dialecticCadence==`number`&&t.dialecticCadence>=1?Math.floor(t.dialecticCadence):void 0}}function jt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...St};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function Mt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Ct};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function Nt(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return{enabled:t};let n=e;return{enabled:typeof n.enabled==`boolean`?n.enabled:t}}function Pt(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Ft(e){if(e==null)return``;if(typeof e==`string`){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e))return JSON.stringify(e,null,2)}catch{return t}return``}if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function It(e){let t=e.imageGenerationModelTimeoutMs;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return Math.floor(t);let n=e.imageGenerationModel;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.timeoutMs;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e)}return null}function Lt(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function Rt(e){let t={},n=t.models&&typeof t.models==`object`&&!Array.isArray(t.models)?t.models:{},r=n.chat,i=t.modelFallbacks,a=Array.isArray(i)&&i.every(e=>typeof e==`string`)?i:Tt(r),o=t.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:Tt(t.imageModel),c=t.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:Tt(t.imageGenerationModel),u=Dt((e&&typeof e==`object`&&!Array.isArray(e)?e:{}).browser),d=typeof t.maxTaskDurationMs==`number`&&Number.isFinite(t.maxTaskDurationMs)?t.maxTaskDurationMs:void 0,f=d===void 0?void 0:Math.round(d/6e4);return{model:wt(r),modelFallbacks:a,imageModel:wt(t.imageModel),imageModelFallbacks:s,imageGenerationModel:wt(t.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:It(t),imageGenerationModelAutoProviderFallback:Lt(t),mediaMaxMb:typeof t.mediaMaxMb==`number`&&!Number.isNaN(t.mediaMaxMb)?t.mediaMaxMb:void 0,maxTokens:typeof t.maxTokens==`number`?t.maxTokens:8192,temperature:typeof t.temperature==`number`?t.temperature:.7,maxToolIterations:typeof t.maxToolIterations==`number`?t.maxToolIterations:20,maxTaskDurationMinutes:f,maxRequestsPerTurn:typeof t.maxRequestsPerTurn==`number`?t.maxRequestsPerTurn:50,maxToolFailuresPerTurn:typeof t.maxToolFailuresPerTurn==`number`?t.maxToolFailuresPerTurn:3,workspace:typeof t.workspace==`string`?t.workspace:`~/.xopc/workspace`,...u,thinkingDefault:typeof t.thinkingDefault==`string`?t.thinkingDefault:`medium`,reasoningDefault:typeof t.reasoningDefault==`string`?t.reasoningDefault:`stream`,verboseDefault:typeof t.verboseDefault==`string`?t.verboseDefault:`full`,compaction:Ot(t.compaction),pruning:kt(t.pruning),memory:At(t.memory),sessionSearch:jt(t.sessionSearch),webExtract:Mt(t.webExtract),delegate:Nt(t.delegate,!1),executeCode:Nt(t.executeCode,!1),systemPromptOverride:typeof t.systemPromptOverride==`string`?t.systemPromptOverride:``,skillsAllowlist:Pt(t.skills),toolsDisable:(()=>{let e=t.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let n=e.disable;return Pt(n)})(),typedModels:fe(n),paramsJson:Ft(t.params)}}function zt(e){return{enabled:e.browserEnabled,headless:e.browserHeadless,allowPrivateUrls:e.browserAllowPrivateUrls,...e.browserCommandTimeout===void 0?{}:{commandTimeout:e.browserCommandTimeout},backend:e.browserBackend,...e.browserCloudProvider===`local`?{}:{cloudProvider:e.browserCloudProvider},...e.browserBackend===`cloud`?{cloud:{...e.browserCloudApiKey.trim()?{apiKey:e.browserCloudApiKey.trim()}:{},...e.browserCloudProjectId.trim()?{projectId:e.browserCloudProjectId.trim()}:{},...e.browserCloudRegion.trim()?{region:e.browserCloudRegion.trim()}:{}}}:{},...e.browserCdpUrl.trim()?{cdpUrl:e.browserCdpUrl.trim()}:{},...e.browserBackend===`extension`?{extension:{...e.browserExtensionPort===void 0?{}:{port:e.browserExtensionPort},...e.browserExtensionHost.trim()?{host:e.browserExtensionHost.trim()}:{},...e.browserExtensionConnectionTimeout===void 0?{}:{connectionTimeout:e.browserExtensionConnectionTimeout}}}:{},...e.browserBackend===`cloakbrowser`?{cloakbrowser:{keepOpen:e.browserCloakKeepOpen,temporaryProfile:e.browserCloakTemporaryProfile,...e.browserCloakCacheDir.trim()?{cacheDir:e.browserCloakCacheDir.trim()}:{},...e.browserCloakBinaryPath.trim()?{binaryPath:e.browserCloakBinaryPath.trim()}:{},...e.browserCloakTimezone.trim()?{timezone:e.browserCloakTimezone.trim()}:{},...e.browserCloakLocale.trim()?{locale:e.browserCloakLocale.trim()}:{},...e.browserCloakWebrtcIp.trim()?{webrtcIp:e.browserCloakWebrtcIp.trim()}:{},...e.browserCloakFingerprintPlatform.trim()?{fingerprintPlatform:e.browserCloakFingerprintPlatform.trim()}:{},...(()=>{let t=e.browserCloakExtraArgs.split(`
8
- `).map(e=>e.trim()).filter(Boolean);return t.length>0?{extraArgs:t}:{}})()},humanize:e.browserHumanize,humanPreset:e.browserHumanPreset}:{},...e.browserDialogPolicy===`auto_dismiss`?{}:{dialogPolicy:e.browserDialogPolicy},...e.browserDialogTimeout===void 0?{}:{dialogTimeoutSeconds:e.browserDialogTimeout}}}async function Bt(e){await s(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:zt(e)})}),L()}var Vt=D();function Ht(e,t={}){let n=!!o(e=>e.token),[r,i]=(0,Y.useReducer)(Vt,{form:null,baseline:null}),a=r.form,s=r.baseline,[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),m=(0,Y.useRef)(!1),h=(0,Y.useRef)(null),{data:g,error:_,isLoading:y,mutate:b}=F(n);v({enabled:n,parsed:(0,Y.useMemo)(()=>g?.payload?.config===void 0?null:Rt(g.payload.config),[g]),dirty:m.current,trackedParsedRef:h,dispatch:i,onResetDirty:()=>{m.current=!1}});let x=!!(n&&y&&g===void 0&&!_),S=_ instanceof Error?_.message:_?String(_):null,C=(0,Y.useMemo)(()=>!a||!s?!1:JSON.stringify(a)!==JSON.stringify(s),[a,s]);return{hasToken:n,loading:x,fetchError:S,form:a,update:(0,Y.useCallback)(e=>{m.current=!0,p(!1),i({type:`patch`,patch:e})},[]),dirty:C,saving:c,saveOk:f,error:u,setError:d,save:(0,Y.useCallback)(async()=>{if(!a||c)return!1;l(!0),d(null),p(!1);try{return await Bt(a),m.current=!1,i({type:`saved`,value:a}),p(!0),b(),!0}catch(t){return d(t instanceof Error?t.message:e.saveError),!1}finally{l(!1)}},[e.saveError,a,b,c]),discard:(0,Y.useCallback)(()=>{m.current=!1,i({type:`discard`}),p(!1),d(null)},[]),mutate:b}}function Ut(e,t){return e.browserTabs[t]}function Wt(){let e=(0,X.c)(43),t=u(Kt),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.agentSettings,o=r.chat,s=V(Gt),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={saveScope:`browser`},e[2]=c):c=e[2];let l=Ht(i,c),[d,f]=B(),p;e[3]===s?p=e[4]:(p=ge(je,s),e[3]=s,e[4]=p);let m=p,h;e[5]===d?h=e[6]:(h=xe(d.get(`focus`)),e[5]=d,e[6]=h);let g=h,_;e[7]!==g||e[8]!==d?(_=g?Ne[g]??Pe(d.get(`tab`)):Pe(d.get(`tab`)),e[7]=g,e[8]=d,e[9]=_):_=e[9];let v=_,y;bb0:{if(!l.form){y=null;break bb0}let t;e[10]!==i||e[11]!==o||e[12]!==l.form||e[13]!==l.update?(t={form:l.form,update:l.update,a:i,chat:o},e[10]=i,e[11]=o,e[12]=l.form,e[13]=l.update,e[14]=t):t=e[14],y=t}let b=y,x;e[15]===f?x=e[16]:(x=e=>{f(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[15]=f,e[16]=x);let S=x;he(v,S);let C,w;e[17]!==g||e[18]!==d||e[19]!==f?(C=()=>{if(!g)return;let e=Ne[g]??Pe(d.get(`tab`));f(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0});let t=g===`runtime`||g===`security`?be(g):null;if(!t)return;let n=window.setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:`smooth`,block:`start`})},80);return()=>window.clearTimeout(n)},w=[g,d,f],e[17]=g,e[18]=d,e[19]=f,e[20]=C,e[21]=w):(C=e[20],w=e[21]),(0,Y.useEffect)(C,w);let T;if(e[22]!==i||e[23]!==m){let t;e[25]===i?t=e[26]:(t=e=>({id:e,label:Ut(i,e)}),e[25]=i,e[26]=t),T=m.map(t),e[22]=i,e[23]=m,e[24]=T}else T=e[24];let E=T,D;e[27]!==v||e[28]!==i.browserTabsAria||e[29]!==S||e[30]!==E?(D=(0,Z.jsx)(ue,{items:E,activeTab:v,onChange:S,ariaLabel:i.browserTabsAria,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`}),e[27]=v,e[28]=i.browserTabsAria,e[29]=S,e[30]=E,e[31]=D):D=e[31];let O;e[32]!==v||e[33]!==b||e[34]!==S?(O=b?(0,Z.jsx)(mt,{...b,activeTab:v,setActiveTab:S}):null,e[32]=v,e[33]=b,e[34]=S,e[35]=O):O=e[35];let k;e[36]!==v||e[37]!==O?(k=(0,Z.jsx)(ae,{id:v,activeTab:v,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:O}),e[36]=v,e[37]=O,e[38]=k):k=e[38];let A;return e[39]!==D||e[40]!==k||e[41]!==l?(A=(0,Z.jsxs)(_t,{sectionId:`agent-browser`,intro:``,vm:l,tabbed:!0,children:[D,k]}),e[39]=D,e[40]=k,e[41]=l,e[42]=A):A=e[42],A}function Gt(e){return e.mode}function Kt(e){return e.language}export{Wt as AgentBrowserSettingsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DbNQuFdA.js";import{a as o,n as s,o as c,t as l}from"./fetch-BID89uCH.js";import{n as u}from"./locale-store-Ba72bFmP.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$c as f,Ac as p,Ba as m,Bo as h,Dl as g,Eo as _,Ga as v,Ha as y,Ka as b,Ks as x,Ol as S,Ua as C,Va as w,Wa as T,Yn as E,Yo as D,_a as O,_r as k,ao as A,at as j,bs as M,eo as N,gr as P,hs as F,io as I,ko as L,oo as R,pa as z,qa as B,ss as ee,tl as te,va as ne,vr as re,yi as ie,yo as ae}from"./index-CrPRlGMg.js";import{n as oe,t as se}from"./settings-page-layout-C15zixct.js";import{n as ce}from"./settings-loading-skeleton-Cfd37IYb.js";import{t as le}from"./schema-form-ChVcm0DX.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-EUwWYx8l.js";import{t as pe}from"./use-channel-catalog-EA4hfbsP.js";var V=n(),me=e(ue(),1),H=e(t(),1),U=r();function he(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}async function ge(e){let t=await l(c(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function _e({entry:e,locale:t,messages:n,onChanged:r,compact:a=!1}){let o=(0,H.useMemo)(()=>he(e),[e]),s=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,H.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await ge({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=K(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,H.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||ge({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=o?.[1].label??(e.configured?n.reconnect:n.connect),m=e.actions?.[`doctor.run`]?.label??n.diagnose,h=G(c.payload),g=K(c.payload,e.id),v=g?c.generatedQr:q(c.payload),y=o?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),b=c.payload?.type===`form`?c.payload:null,S=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:a?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:i(`flex flex-wrap items-start gap-3`,a?`justify-end`:`justify-between`),children:[a?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,U.jsxs)(_,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(o[0]),children:[c.busy?(0,U.jsx)(x,{className:`size-4 animate-spin`}):(0,U.jsx)(M,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(_,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,U.jsx)(D,{className:`size-4`}),m]}):null]})]}),h?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:h}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,y?(0,U.jsxs)(`div`,{className:i(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base px-3 py-3 shadow-surface`,a?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:v?(0,U.jsx)(`img`,{src:v,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(O,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:i(`min-w-0 max-w-sm text-sm text-fg-muted`,a&&`w-full sm:w-auto`),children:[v?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(O,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(O,{className:`h-4 w-36 max-w-full`})]}),g?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(p,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(f,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:b.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,U.jsx)(_,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(b.submitAction,c.formDraft),children:n.saveSetup})]}):null,S?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:S.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var ve=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ye(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function be(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:ve,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function xe(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Se(e,t,n){let r=xe(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Ce(e,t=!1){return e===`drawer`?i(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,A):i(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,A,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function we(e){let t=(0,V.c)(33),{presentation:n,open:r,onOpenChange:a,title:o,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:h}=e,g=p===void 0?!1:p,x=n===`drawer`,[S,E]=(0,H.useState)(null),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,U.jsx)(C,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,R)}),t[0]=D):D=t[0];let O;t[1]!==n||t[2]!==g?(O=Ce(n,g),t[1]=n,t[2]=g,t[3]=O):O=t[3];let k;t[4]===c?k=t[5]:(k=c?(0,U.jsx)(b,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=k);let A;t[6]===l?A=t[7]:(A=l?(0,U.jsx)(y,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=A);let j;t[8]!==u||t[9]!==s||t[10]!==h||t[11]!==x||t[12]!==o?(j=x?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[o?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:o}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(m,{asChild:!0,children:(0,U.jsx)(_,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(L,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(m,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:i(ae,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(L,{className:`size-4`})})}),h]}),t[8]=u,t[9]=s,t[10]=h,t[11]=x,t[12]=o,t[13]=j):j=t[13];let M=x?`px-4 py-4`:`p-6`,N;t[14]===M?N=t[15]:(N=i(`min-h-0 flex-1 overflow-y-auto`,M),t[14]=M,t[15]=N);let P;t[16]!==d||t[17]!==N?(P=(0,U.jsx)(`div`,{className:N,children:d}),t[16]=d,t[17]=N,t[18]=P):P=t[18];let F;t[19]!==f||t[20]!==S||t[21]!==k||t[22]!==A||t[23]!==j||t[24]!==P?(F=(0,U.jsxs)(I,{layer:`modal`,portalContainer:S,children:[k,A,j,P,f]}),t[19]=f,t[20]=S,t[21]=k,t[22]=A,t[23]=j,t[24]=P,t[25]=F):F=t[25];let z;t[26]!==F||t[27]!==O?(z=(0,U.jsxs)(T,{children:[D,(0,U.jsx)(w,{ref:E,className:O,onOpenAutoFocus:Te,children:F})]}),t[26]=F,t[27]=O,t[28]=z):z=t[28];let B;return t[29]!==a||t[30]!==r||t[31]!==z?(B=(0,U.jsx)(v,{open:r,onOpenChange:a,children:z}),t[29]=a,t[30]=r,t[31]=z,t[32]=B):B=t[32],B}function Te(e){return e.preventDefault()}var Ee=(0,H.memo)(function(e){let t=(0,V.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(ie,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function De(e){let t=(0,V.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(_,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(_,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,v;t[13]!==m||t[14]!==h||t[15]!==g?(v=(0,U.jsx)(_,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==p||t[19]!==v?(y=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,v]}),t[17]=d,t[18]=p,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,y]}),t[21]=y,t[22]=u,t[23]=b):b=t[23],b}var Oe=`channels-status`;function ke(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Ae(e){let t=t=>e(t.detail);return window.addEventListener(Oe,t),()=>window.removeEventListener(Oe,t)}function je(e,t){let n=(0,V.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Ae(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,H.useEffect)(i,a)}function Me(e){return e?c(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Ne(e){return(await s(c(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Pe=[`enabled`];async function Fe(){let e=await s(c(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Ie(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Le(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Re(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function ze(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Be(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ve(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Pe.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Pe.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function He(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ue(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ue(n)&&delete t[e];return Object.keys(t).length===0}function We(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ue(n),n}function Ge(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Ke(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function qe(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Je(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ye(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(Qe(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Je(e,Ke(t,e),n);i&&r.push(i)}let a=qe(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Q(e,t){let n=Y(e),r=he(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Xe(e,t){let n=he(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function Ze(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function Qe(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function $e({entry:e}){let t=o(e=>e.token),[n,r]=(0,H.useState)(!1),i=(0,H.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(c(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Ie(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(ne,{sourceChannel:e.id,className:`size-7`})})}function et(e){let t=(0,V.c)(16),{checked:n,disabled:r,onToggle:a,label:o}=e,s;t[0]===a?s=t[1]:(s=e=>{e.stopPropagation(),a()},t[0]=a,t[1]=s);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=i(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=i(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==o||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":o,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=o,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function tt(e){let t=(0,V.c)(71),{entry:n,config:r,runtime:a,busy:o,restarting:s,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,v,y,b,S;if(t[2]!==o||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==a||t[10]!==p.enabled||t[11]!==p.ready){let e=Ye(n,r,c),s=Ze(n,c);m=!p.enabled&&p.ready?u:a===`stopped`?d:l,b=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,U.jsx)($e,{entry:n}),t[19]=n,t[20]=f);let _;t[21]===n.label?_=t[22]:(_=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=_);let x;t[23]===a?x=t[24]:(x=i(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Be(a)),t[23]=a,t[24]=x);let C;t[25]!==c||t[26]!==a?(C=Re(a,c),t[25]=c,t[26]=a,t[27]=C):C=t[27];let w;t[28]!==x||t[29]!==C?(w=(0,U.jsx)(`span`,{className:x,children:C}),t[28]=x,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==_?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[_,w]}),t[31]=w,t[32]=_,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==o||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(et,{checked:D,disabled:o,label:O,onToggle:u}),t[40]=o,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(S=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=S):S=t[47],h=`button`,g=l,v=`mt-5 min-h-[6.25rem] text-left`,y=p.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(rt)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Xe(n,c)}),s.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:s.map(nt)}):null]}),t[2]=o,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=a,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=v,t[16]=y,t[17]=b,t[18]=S}else m=t[12],h=t[13],g=t[14],v=t[15],y=t[16],b=t[17],S=t[18];let C;t[48]!==h||t[49]!==g||t[50]!==v||t[51]!==y?(C=(0,U.jsx)(`button`,{type:h,onClick:g,className:v,children:y}),t[48]=h,t[49]=g,t[50]=v,t[51]=y,t[52]=C):C=t[52];let w=o||s,T;t[53]!==o||t[54]!==s?(T=o||s?(0,U.jsx)(x,{className:`size-4 animate-spin`}):null,t[53]=o,t[54]=s,t[55]=T):T=t[55];let E;t[56]!==c||t[57]!==n||t[58]!==s||t[59]!==a?(E=s?c.restartingChannel:a===`stopped`?c.restartChannel:Q(n,c),t[56]=c,t[57]=n,t[58]=s,t[59]=a,t[60]=E):E=t[60];let D;t[61]!==m||t[62]!==T||t[63]!==E||t[64]!==w?(D=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(_,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:w,children:[T,E]})}),t[61]=m,t[62]=T,t[63]=E,t[64]=w,t[65]=D):D=t[65];let O;return t[66]!==D||t[67]!==b||t[68]!==S||t[69]!==C?(O=(0,U.jsxs)(`article`,{className:b,children:[S,C,D]}),t[66]=D,t[67]=b,t[68]=S,t[69]=C,t[70]=O):O=t[70],O}function nt(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function rt(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function it(e){let t=(0,V.c)(51),{runtime:n,restarting:r,checking:a,showConnectionOptions:o,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,p=n===`running`?f:n===`stopped`||n===`needs_setup`?te:x,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,v=n===`disabled`&&`text-fg-muted`,y=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,b;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==v||t[4]!==y?(b=i(`mt-0.5 size-5 shrink-0`,m,h,g,v,y),t[0]=m,t[1]=h,t[2]=g,t[3]=v,t[4]=y,t[5]=b):b=t[5];let S;t[6]!==p||t[7]!==b?(S=(0,U.jsx)(p,{className:b}),t[6]=p,t[7]=b,t[8]=S):S=t[8];let C;t[9]===c.connectionStatus?C=t[10]:(C=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=C);let w;t[11]!==c||t[12]!==n?(w=ze(n,c),t[11]=c,t[12]=n,t[13]=w):w=t[13];let T;t[14]===w?T=t[15]:(T=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:w}),t[14]=w,t[15]=T);let E;t[16]!==T||t[17]!==C?(E=(0,U.jsxs)(`div`,{children:[C,T]}),t[16]=T,t[17]=C,t[18]=E):E=t[18];let D;t[19]!==E||t[20]!==S?(D=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,E]}),t[19]=E,t[20]=S,t[21]=D):D=t[21];let O=a||r,k;t[22]===a?k=t[23]:(k=a?(0,U.jsx)(x,{className:`size-4 animate-spin`}):null,t[22]=a,t[23]=k);let A=a?c.checkingConnection:c.checkConnection,j;t[24]!==u||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,U.jsxs)(_,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:u,children:[k,A]}),t[24]=u,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==a||t[32]!==l||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,U.jsxs)(_,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||a,onClick:l,children:[r?(0,U.jsx)(x,{className:`size-4 animate-spin`}):(0,U.jsx)(F,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=a,t[32]=l,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==a||t[40]!==d||t[41]!==r||t[42]!==o?(N=s?(0,U.jsx)(_,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:a||r,onClick:d,children:o?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=a,t[40]=d,t[41]=r,t[42]=o,t[43]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let I;return t[48]!==D||t[49]!==P?(I=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[D,P]})}),t[48]=D,t[49]=P,t[50]=I):I=t[50],I}function at(e){let t=(0,V.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(h,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:Qe(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let g;t[26]!==m||t[27]!==l||t[28]!==u?(g=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=g):g=t[29];let _;return t[30]!==g||t[31]!==d?(_=(0,U.jsx)(`section`,{className:d,children:g}),t[30]=g,t[31]=d,t[32]=_):_=t[32],_}function ot(){let e=u(e=>e.language),t=a(e),n=o(e=>!!e.token),r=g(),{channelId:s}=S(),f=re(s),m=pe(n,e),h=m.entries,{data:_,mutate:v,isValidating:y}=d(n?fe():null,de,{revalidateOnFocus:!0}),{data:b,mutate:x}=d(n?`channels-config-map`:null,Fe,{revalidateOnFocus:!1}),C=b?.channels??{},w=b?.bindings??[],{data:T}=d(n?`channel-routing-agents`:null,z,{revalidateOnFocus:!1}),D=B(e=>e.setPageHeader),O=B(e=>e.clearPageHeader),A=(0,H.useMemo)(()=>h.find(e=>e.id===f),[f,h]),M=A?Le(A):null,{data:F,mutate:I}=d(n&&M?Me(M):null,()=>Ne(M)),[L,R]=(0,H.useState)(null),[te,ne]=(0,H.useState)(!1),[ie,ae]=(0,H.useState)(null),[ue,V]=(0,H.useState)(null),[me,ge]=(0,H.useState)(!1),[W,G]=(0,H.useState)(null),[K,q]=(0,H.useState)(null),ve=L??F??{},J=t.channelsSettings,xe=(0,H.useMemo)(()=>A?.configSchema??{type:`object`,properties:{}},[A?.configSchema]),Ce=(0,H.useMemo)(()=>We(xe,Pe),[xe]),Te=(0,H.useMemo)(()=>Ve(A),[A]),Oe=(0,H.useMemo)(()=>He(Ce,Te),[Te,Ce]),Ae=(0,H.useMemo)(()=>We(Ce,Te),[Te,Ce]),Ie=(0,H.useMemo)(()=>Ge(Oe),[Oe]),ze=A?K??ye(w,A.id):``,X=(0,H.useMemo)(()=>(T?.items??[]).map(e=>{let n=E(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[T?.items,t.agentsSettings]),Z=T?.items.find(e=>e.id===T.defaultId),Ue=Z?E(Z,t.agentsSettings):T?.defaultId??``,Ke=(0,H.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),qe=(0,H.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Je=_!==void 0,Ye=(0,H.useCallback)(e=>Se(e,qe.get(e.id),Je),[qe,Je]),Q=(0,H.useCallback)(async()=>{await Promise.all([m.mutate(),v()])},[m,v]);je((0,H.useCallback)(e=>{let t=ke(e);t&&v(t,!1)},[v]),n);let Xe=(0,H.useMemo)(()=>n?(0,U.jsx)(Ee,{ch:J,refreshing:m.isValidating||y,saveOk:!1,onRefresh:()=>void Q()}):null,[m.isValidating,J,n,y,Q]);(0,H.useLayoutEffect)(()=>(D({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>O()),[O,Xe,t.settingsSections.channels,D]);let Ze=(0,H.useCallback)(e=>{r(k(e)),R(null),q(null),G(null)},[r]),Qe=(0,H.useCallback)(()=>{r(P),R(null),q(null),G(null)},[r]),nt=(0,H.useCallback)(async e=>{V(e.id),G(null);try{let t=await l(c(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{V(null)}},[Q]);(0,H.useEffect)(()=>{q(null),ge(!1)},[A?.id]);let rt=(0,H.useCallback)(async()=>{if(!A||!L&&K===null)return!1;let e=Le(A);ne(!0),G(null);try{let t=await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({...L?{channels:{[e]:L}}:{},...K===null?{}:{bindings:be(w,A.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return L&&await I(L,!1),await x(),await m.mutate(),R(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[A,K,w,m,L,x,I]),ot=(0,H.useCallback)(async e=>{let t=Y(e),n=Le(e),r=A?.id===e.id?L:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ae(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await m.mutate(),await x(),await v(),A?.id===e.id&&(await I(),R(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(null)}},[A?.id,m,L,x,I,v,Ze]),$=A?.ui?.modal,st=$?.placement!==`replace-config`,ct=A?Ye(A):`checking`,lt=A?!Y(A).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[m.isLoading?(0,U.jsx)(ce,{sections:2}):m.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(m.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:h.map(e=>(0,U.jsx)(tt,{entry:e,config:C[Le(e)]?.config,runtime:Ye(e),busy:ie===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void ot(e),onRestart:()=>void nt(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(we,{presentation:`modal`,open:!!A,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:A?.label??J.selectChannel,srDescription:A?.description,wide:!0,footer:A?(0,U.jsx)(De,{ch:J,dirty:!!L||K!==null,saving:te,onCancel:Qe,onDiscard:()=>{R(null),q(null)},onSave:rt}):null,children:A?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)($e,{entry:A}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:A.label}),(0,U.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Be(ct)),children:Re(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(A).ready&&he(A)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,A.label):A.description}),A.docsPath?(0,U.jsxs)(`a`,{href:A.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(p,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(A).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(et,{checked:Y(A).enabled,disabled:ie===A.id,label:J.toggleChannel.replace(`{{channel}}`,A.label),onToggle:()=>void ot(A)})]})]})}),(0,U.jsx)(it,{runtime:ct,restarting:ue===A.id,checking:y,showConnectionOptions:me,canManageConnection:Y(A).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void nt(A),onCheck:()=>void Q(),onManageConnection:()=>ge(e=>!e)}),(0,U.jsx)(at,{entry:A,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(_e,{entry:A,locale:e,messages:J,compact:!0,onChanged:async()=>{await I(),await Q(),await x()}},A.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(j,{extensionId:A.extensionId,extensionName:A.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:A.id,entry:A,config:ve}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(j,{extensionId:A.extensionId,extensionName:A.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:A.id,entry:A,config:ve}}):null,st&&Ie?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:Oe,values:ve,onChange:e=>R(e),disabled:te,labels:Ke})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(ee,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(N,{value:ze,options:X,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,Ue||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:te||!T,onChange:e=>q(e)})]})]}),st&&Ge(Ae)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(ee,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Ae,values:ve,onChange:e=>R(e),disabled:te,labels:Ke})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{ot as ChannelsSettingsPanel};
@@ -1 +0,0 @@
1
- import{o as e}from"./fetch-BID89uCH.js";import{n as t}from"./channel-recipient-api-DllrPmp-.js";function n(){return e(`/api/channels/status`)}var r=t;export{r as n,n as t};
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DbNQuFdA.js";import{a as o,n as s,o as c}from"./fetch-BID89uCH.js";import{n as l}from"./locale-store-Ba72bFmP.js";import{r as u}from"./toast-z0toXu32.js";import{$c as d,$r as f,Ao as p,Ba as m,Cs as h,Ec as g,Eo as _,Es as v,Fr as y,Fs as b,Ga as x,Ha as S,Ir as C,Ka as w,Ks as T,Lr as E,Pc as D,Pr as O,To as k,Ua as A,Va as j,Vo as M,Wa as N,Wc as P,_o as F,ac as I,ao as L,bc as ee,bo as R,cs as z,ei as B,ga as te,ha as V,ho as ne,il as re,is as ie,kl as ae,ko as oe,ni as se,oo as ce,ps as le,qa as ue,ri as de,ro as fe,ti as pe,to as me,us as he,ws as ge,yi as _e,zr as ve}from"./index-CrPRlGMg.js";import{n as ye,t as be}from"./settings-form-section-Cu30CXVl.js";import{t as xe}from"./page-tabs-DOfMaq_L.js";var H=e(t(),1),U=n(),W=r(),G=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,Se=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function Ce(e,t){return t.some(t=>t.connectorId===e.id)}function K(e,t){return t[e]??e}function q(e,t){return t.connectorCategoryTemplate.replace(`{{category}}`,K(e,t.connectorCategoryLabels))}function we(){let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 min-w-0 flex-1`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-[4.5rem] shrink-0 rounded-lg`,G)})]}),(0,W.jsx)(`div`,{className:i(`h-3 w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-[88%]`,G)})]})})}),e[0]=t):t=e[0],t}function Te(){let e=(0,U.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 w-48 max-w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-72 max-w-full`,G)})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[t,(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)}),(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)})]})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,W.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[n,(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-8 w-20 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-24 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-28 rounded-md`,G)})]}),(0,W.jsx)(`div`,{className:i(`mt-3 h-20 rounded-xl`,G)})]}),e[2]=r):r=e[2],r}function Ee(e){let t=(0,U.c)(69),{connector:n,installed:r,onInstall:a,onOpenDetails:o,t:s}=e,c;t[0]!==n.category||t[1]!==s?(c=q(n.category,s),t[0]=n.category,t[1]=s,t[2]=c):c=t[2];let l=c,u,f,p,m,h,g,v,y,x,S;if(t[3]!==l||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o||t[8]!==s.install||t[9]!==s.installedBadge){let e=n.capabilities.slice(0,4),c=Math.max(0,n.capabilities.length-e.length),C;t[20]!==n||t[21]!==a||t[22]!==s.install?(C=e=>(0,W.jsxs)(_,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),a(n)},children:[(0,W.jsx)(b,{className:`size-4`}),s.install]}),t[20]=n,t[21]=a,t[22]=s.install,t[23]=C):C=t[23],u=C;let w;t[24]!==n||t[25]!==o?(w=e=>{!o||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o(n))},t[24]=n,t[25]=o,t[26]=w):w=t[26];let T=w,E=o?`cursor-pointer`:null;t[27]===E?v=t[28]:(v=i(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,E),t[27]=E,t[28]=v),y=o?`button`:void 0,x=o?0:void 0,t[29]!==n||t[30]!==o?(S=()=>o?.(n),t[29]=n,t[30]=o,t[31]=S):S=t[31],f=T,p=`flex min-w-0 flex-1 flex-col`;let D;t[32]===n.displayName?D=t[33]:(D=(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[32]=n.displayName,t[33]=D);let O;t[34]===l?O=t[35]:(O=(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:l}),t[34]=l,t[35]=O);let k;t[36]!==D||t[37]!==O?(k=(0,W.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[D,O]})}),t[36]=D,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==r||t[40]!==u?(A=r?null:(0,W.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:u()}),t[39]=r,t[40]=u,t[41]=A):A=t[41];let j;t[42]!==r||t[43]!==s.installedBadge?(j=r?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,W.jsx)(d,{className:`size-3`,"aria-hidden":!0}),s.installedBadge]}):null,t[42]=r,t[43]=s.installedBadge,t[44]=j):j=t[44];let M;t[45]!==A||t[46]!==j?(M=(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[A,j]}),t[45]=A,t[46]=j,t[47]=M):M=t[47],t[48]!==k||t[49]!==M?(m=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[k,M]}),t[48]=k,t[49]=M,t[50]=m):m=t[50],t[51]===n.description?h=t[52]:(h=(0,W.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[51]=n.description,t[52]=h),g=e.length>0?(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(J),c>0?(0,W.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,c]}):null]}):null,t[3]=l,t[4]=n,t[5]=r,t[6]=a,t[7]=o,t[8]=s.install,t[9]=s.installedBadge,t[10]=u,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=v,t[17]=y,t[18]=x,t[19]=S}else u=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],v=t[16],y=t[17],x=t[18],S=t[19];let C;t[53]!==p||t[54]!==m||t[55]!==h||t[56]!==g?(C=(0,W.jsxs)(`div`,{className:p,children:[m,h,g]}),t[53]=p,t[54]=m,t[55]=h,t[56]=g,t[57]=C):C=t[57];let w;t[58]!==r||t[59]!==u?(w=r?null:(0,W.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:u(`w-full`)}),t[58]=r,t[59]=u,t[60]=w):w=t[60];let T;return t[61]!==f||t[62]!==C||t[63]!==w||t[64]!==v||t[65]!==y||t[66]!==x||t[67]!==S?(T=(0,W.jsxs)(`div`,{className:v,role:y,tabIndex:x,onClick:S,onKeyDown:f,children:[C,w]}),t[61]=f,t[62]=C,t[63]=w,t[64]=v,t[65]=y,t[66]=x,t[67]=S,t[68]=T):T=t[68],T}function J(e){return(0,W.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Y(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function De(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Oe(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),Y(await s(c(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function ke(e,t){return Y(await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function Ae(e,t,n){let r=await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return V(),Y(r,`Could not install Store connector.`).instance}async function je(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function Me(){return Y(await s(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var Ne=new Map,Pe=300*1e3;async function Fe(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),l=Math.max(n?.pageSize??24,1),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${l}`,d=Date.now(),f=Ne.get(u);if(f&&f.expiresAt>d)return f.promise;let p=new URLSearchParams;r&&p.set(`q`,r),i!==`all`&&p.set(`source`,i),a&&p.set(`browse`,`1`),p.set(`page`,String(o)),p.set(`pageSize`,String(l));let m=s(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Y(e,`Could not search connector registries.`),n=Math.max(0,...(t.results??[]).map(e=>e.totalPages??0))||void 0;return{connectors:t.connectors,totalPages:n}});Ne.set(u,{expiresAt:d+Pe,promise:m});try{return await m}catch(e){throw Ne.delete(u),e}}async function Ie(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Le(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Re(e,t){let n=await s(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return V(),Y(n,`Could not install connector.`).instance}async function ze(e,t={}){return Y(await s(c(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Be(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function Ve(e){await s(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),V()}async function He(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function Ue(){return Y(await s(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function We(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function Ge(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function Ke(e,t){let n=await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return V(),Y(n,`Could not update Composio scope.`).scope}async function qe(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function Je(e=50){return Y(await s(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function X(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function Ye(e,t){return t.connectorCapabilityLabels[e]??e}function Xe(e,t){if(e.runtime.type===`mcp`)return X(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.id??e.runtime.channelId??e.runtime.toolkit??e.runtime.toolsetId??e.runtime.sourceKind??e.runtime.type;return X(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n})}function Ze(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Qe(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function $e(e){let t=(0,U.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,W.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(et),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,W.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,W.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function et(e){return(0,W.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,W.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function tt({connector:e,installed:t,onClose:n,onInstall:r,t:a}){let[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(null),[u,f]=(0,H.useState)(null),h=Qe(e),g=e.capabilities.slice(0,8),y=Math.max(0,e.capabilities.length-g.length),C=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:a.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:a.connectorSetupConfig}))],E=async()=>{s(!0),f(null);try{l(await ze(e))}catch(e){l(null),f(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,W.jsx)(x,{open:!0,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(N,{children:[(0,W.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(j,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.source}),(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.kind}),t?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,W.jsx)(d,{className:`size-3`,"aria-hidden":!0}),a.installedBadge]}):null]}),(0,W.jsx)(w,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,W.jsx)(S,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]}),(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,R.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(oe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),a.detailTools]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?X(a.connectorPreviewToolsCount,{count:c.toolCount}):a.connectorPreviewUnknown})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),a.connectorRequiredInputs]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:X(a.connectorRequiredInputsCount,{count:h})})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorCapabilitiesTitle}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[g.map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:Ye(e,a)},e)),y>0?(0,W.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,y]}):null]}),(0,W.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.connectorCapabilitiesHint})]}),u?(0,W.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorPreviewTitle}),(0,W.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?a.healthStatusHealthy:a.healthStatusLabels[c.status]??c.status})]}),(0,W.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.toolsMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.resourcesMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.promptsMetric})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)($e,{title:a.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,W.jsx)($e,{title:a.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,W.jsx)($e,{title:a.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??X(a.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,W.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,W.jsxs)(`aside`,{className:`space-y-3`,children:[(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(I,{className:`size-4 text-accent`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(D,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorSetupTitle]}),C.length>0?(0,W.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:C.map(e=>(0,W.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,W.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,W.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:a.connectorSetupRequired}):null]}),e.description?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:a.connectorSetupNone})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(z,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorRuntimeTitle]}),(0,W.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:Xe(e,a)})]})]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(_,{variant:`secondary`,children:a.modalClose})}),(0,W.jsxs)(_,{variant:`secondary`,disabled:o,onClick:()=>void E(),children:[o?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(p,{className:`size-4`}),a.connectorPreviewButton]}),t?(0,W.jsxs)(_,{variant:`secondary`,disabled:!0,children:[(0,W.jsx)(v,{className:`size-4`}),a.installedBadge]}):(0,W.jsxs)(_,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,W.jsx)(b,{className:`size-4`}),a.install]})]})]})]})})}var nt=(0,H.memo)(function(e){let t=(0,U.c)(19),{loading:n,searchQuery:r,setSearchQuery:i,onReloadClick:a,onAddCustomServer:o,searchPlaceholder:s,addLabel:c,reloadLabel:l}=e,u;t[0]!==n||t[1]!==a||t[2]!==l?(u=(0,W.jsx)(_e,{className:`size-9 shrink-0 p-0`,loading:n,label:l,title:l,onClick:a}),t[0]=n,t[1]=a,t[2]=l,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,W.jsx)(he,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i(e.currentTarget.value),t[5]=i,t[6]=f);let p;t[7]!==s||t[8]!==r||t[9]!==f?(p=(0,W.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,W.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:r,onChange:f,placeholder:s,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[7]=s,t[8]=r,t[9]=f,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,W.jsx)(h,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=m):m=t[11];let g;t[12]!==c||t[13]!==o?(g=(0,W.jsxs)(_,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[m,c]}),t[12]=c,t[13]=o,t[14]=g):g=t[14];let v;return t[15]!==u||t[16]!==p||t[17]!==g?(v=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,p,g]}),t[15]=u,t[16]=p,t[17]=g,t[18]=v):v=t[18],v}),rt=/^([^:=]+)[:=](.*)$/;function it(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=rt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function at(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function ot(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function st(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function ct(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||st(t)&&(r[e]=t);return r}function lt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function ut(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function dt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=lt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=ut(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=at(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function ft(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:ot(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function pt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function mt(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=t&&typeof t==`object`?t:{},r=n.servers,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.entries(r).flatMap(([e,t])=>!t||typeof t!=`object`||Array.isArray(t)||st(t)?[]:[ft(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function ht(e){return dt(e)}async function gt(e,t={}){let n={};for(let r of e.servers){let e=r.id.trim();if(e){if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=dt(r)}}let r={servers:{...t,...n}};e.sessionIdleTtlMinutes!=null&&Number.isFinite(e.sessionIdleTtlMinutes)&&(r.sessionIdleTtlMs=e.sessionIdleTtlMinutes===0?0:Math.round(e.sessionIdleTtlMinutes*6e4)),await s(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),V()}function _t(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function vt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function yt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function bt(e,t){let n=await s(c(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=_t(n.payload.tools),i=vt(n.payload.resources),a=yt(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function xt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function St(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>600))return n*1e3}function Ct(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function Z(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function wt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),p=Ct(e),m=(0,H.useCallback)(async()=>{o(!0),f(null);try{let t=await bt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,H.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,W.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),p?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:Z(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(_,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),t.testConnection]}),(0,W.jsxs)(_,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(M,{className:`size-4`}),t.removeServer]})]})]})]})}function Tt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Et(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Tt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
- `).toLowerCase().includes(r)}function Dt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Ot(e){let t=(0,U.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:a,searchEmptyLabel:o}=e,[s,c]=(0,H.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>Et(e,s,r),t[4]=s,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=s,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===s?d=t[8]:(d=s.trim(),t[7]=s,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,W.jsx)(he,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,k),h=e=>c(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==s||t[13]!==a?(g=(0,W.jsxs)(`div`,{className:`relative`,children:[p,(0,W.jsx)(`input`,{type:`search`,value:s,placeholder:a,"aria-label":a,className:m,onChange:h})]}),t[12]=s,t[13]=a,t[14]=g):g=t[14];let _;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(_=f?(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,W.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==u||t[23]!==o||t[24]!==r?(y=(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Dt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,W.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=o,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function kt(e){let t=(0,U.c)(38),{open:n,onOpenChange:r,serverId:a,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:h}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,W.jsx)(A,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ce)}),t[0]=g):g=t[0];let v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=i(`fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,L,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=v):v=t[1];let y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,W.jsx)(p,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=y):y=t[2];let b;t[3]===o?b=t[4]:(b=(0,W.jsxs)(w,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[y,o]}),t[3]=o,t[4]=b);let C;t[5]!==a||t[6]!==s||t[7]!==f.length?(C=s.replace(`{{serverId}}`,a).replace(`{{count}}`,String(f.length)),t[5]=a,t[6]=s,t[7]=f.length,t[8]=C):C=t[8];let T;t[9]===C?T=t[10]:(T=(0,W.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[9]=C,t[10]=T);let E;t[11]!==b||t[12]!==T?(E=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[b,T]}),t[11]=b,t[12]=T,t[13]=E):E=t[13];let D;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,W.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t[14]=D):D=t[14];let O;t[15]===d?O=t[16]:(O=(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:D})}),t[15]=d,t[16]=O);let k;t[17]!==E||t[18]!==O?(k=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[E,O]}),t[17]=E,t[18]=O,t[19]=k):k=t[19];let M;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==a||t[25]!==h||t[26]!==f?(M=f.length>0?(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,W.jsx)(Ot,{tools:f,stripPrefix:h,searchPlaceholder:c,searchEmptyLabel:l},`${a}-${n?`open`:`closed`}`)}):(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=a,t[25]=h,t[26]=f,t[27]=M):M=t[27];let P;t[28]===d?P=t[29]:(P=(0,W.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(_,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=P);let F;t[30]!==k||t[31]!==M||t[32]!==P?(F=(0,W.jsxs)(N,{children:[g,(0,W.jsxs)(j,{className:v,children:[k,M,P]})]}),t[30]=k,t[31]=M,t[32]=P,t[33]=F):F=t[33];let I;return t[34]!==r||t[35]!==n||t[36]!==F?(I=(0,W.jsx)(x,{open:n,onOpenChange:r,children:F}),t[34]=r,t[35]=n,t[36]=F,t[37]=I):I=t[37],I}var At=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k);function jt(e){return e.materialized.type===`composio`?e.connectorId.replace(/^composio-/,``):null}function Mt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function Nt({instance:e,t}){let n=jt(e),[r,a]=(0,H.useState)([]),[o,s]=(0,H.useState)([]),[c,l]=(0,H.useState)([]),[u,d]=(0,H.useState)(`read`),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(null),g=(0,H.useCallback)(async()=>{if(!(!n||n===`api-key`)){p(!0),h(null);try{let[e,t,r,i]=await Promise.all([Ue().catch(()=>[]),qe(n).catch(()=>[]),Je(20).catch(()=>[]),Ge(n).catch(()=>`read`)]);a(e.filter(e=>e.toolkit.toLowerCase()===n.toLowerCase())),s(t),l(r.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===n.toLowerCase())),d(i)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]);(0,H.useEffect)(()=>{g()},[g]);let v=(0,H.useCallback)(async()=>{if(n){p(!0),h(null);try{let e=await We(n);window.open(e.connectUrl,`_blank`,`noopener,noreferrer`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]),y=(0,H.useCallback)(async e=>{if(n){d(e);try{await Ke(n,e),await g()}catch(e){h(e instanceof Error?e.message:String(e))}}},[g,n]);return n?n===`api-key`?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,W.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:Z(t.composioToolkitTitle,{toolkit:n})}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsxs)(me,{className:i(At,`h-9 w-28 py-1`),value:u,onChange:e=>void y(e.currentTarget.value),children:[(0,W.jsx)(fe,{value:`read`,children:t.composioScopeRead}),(0,W.jsx)(fe,{value:`write`,children:t.composioScopeWrite}),(0,W.jsx)(fe,{value:`admin`,children:t.composioScopeAdmin})]}),(0,W.jsxs)(_,{variant:`secondary`,disabled:f,onClick:()=>void v(),children:[f?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(I,{className:`size-4`}),t.connectOAuth]}),(0,W.jsx)(_,{variant:`ghost`,disabled:f,onClick:()=>void g(),children:t.refresh})]})]}),m?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,(0,W.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),r.length?r.map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.id}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.status})]},e.id)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),o.length?o.slice(0,8).map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[Mt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),c.length?c.slice(0,5).map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]}):null}var Pt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k);function Ft(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function It(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function Lt(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function Rt(e){let t=(0,U.c)(12),{title:n,description:r,meta:a}=e,o;t[0]===r?o=t[1]:(o=r?(0,W.jsx)(pe,{delayDuration:300,skipDelayDuration:100,children:(0,W.jsxs)(se,{children:[(0,W.jsx)(de,{asChild:!0,children:(0,W.jsx)(`p`,{tabIndex:0,title:r,className:i(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,W.jsx)(B,{children:(0,W.jsx)(f,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,W.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=o);let s=o,c;t[2]===n?c=t[3]:(c=(0,W.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=c);let l;t[4]===a?l=t[5]:(l=a?(0,W.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:a}):null,t[4]=a,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==u?(d=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,s]}),t[9]=s,t[10]=u,t[11]=d):d=t[11],d}function zt({instance:e,definition:t,onClose:n,onChanged:r,t:a,mcp:o}){let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[h,y]=(0,H.useState)(null),[b,C]=(0,H.useState)(`health`),[E,O]=(0,H.useState)(!1),[k,P]=(0,H.useState)(()=>It(t,e)),[F,L]=(0,H.useState)(null),ee=t?.setup.config??[],z=e.materialized.type===`mcp`&&ee.length>0&&(t?.setup.secrets??[]).length===0,B=h?h.toolCount:e.usage.lastToolCount,te=(0,H.useMemo)(()=>{let t=[[`health`,ie,a.detailHealth],[`tools`,p,`${a.detailTools} ${h?h.toolCount:e.usage.lastToolCount??``}`],[`resources`,D,`${a.detailResources} ${h?h.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,g,`${a.detailPrompts} ${h?h.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,I,a.detailPermissions]];return z?[...t,[`config`,D,a.tabConfig]]:t},[h,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,z,a]),V=(0,H.useCallback)(async()=>{c(!0),L(null);try{let t=await He(e.instanceId);y(t),t.toolCount>0&&C(`tools`),r()}catch(e){L(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),ne=(0,H.useCallback)(async()=>{u(!0),L(null);try{await Ve(e.instanceId),await r(),n()}catch(e){L(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),re=(0,H.useCallback)(async()=>{if(!(!t||!z)){f(!0),L(null);try{let n={};for(let e of t.setup.config??[]){let t=Lt(e.type,k[e.key]??``);t!==void 0&&(n[e.key]=t)}await Be(e.instanceId,{config:n}),await r(),C(`health`)}catch(e){L(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[k,t,e.instanceId,r,z]);return(0,W.jsxs)(x,{open:!0,onOpenChange:e=>{e||n()},children:[(0,W.jsxs)(N,{children:[(0,W.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(j,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(w,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,W.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:e.materialized.type===`mcp`?Z(a.mcpServerRuntime,{serverId:e.materialized.serverId}):Z(a.runtimeLabel,{runtime:e.materialized.type})})]}),(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,R.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(oe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[F?(0,W.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:F}):null,(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:te.map(([e,t,n])=>(0,W.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,b===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>C(e),children:[(0,W.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,W.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[b===`health`?(0,W.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,W.jsxs)(`p`,{children:[a.statusLabel,` `,(0,W.jsx)(`span`,{className:h?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:Ft(h?.status??e.usage.lastHealthStatus,a)})]}),(0,W.jsxs)(`p`,{children:[a.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():a.never]}),h?.action?(0,W.jsx)(`p`,{children:h.action}):null]}):null,b===`tools`?h?.tools.length?(0,W.jsxs)(`div`,{className:`grid gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Z(a.toolsAvailable,{count:String(h.tools.length)})}),(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>O(!0),children:o.viewAllTools})]}),(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.tools.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`p`,{className:`text-fg-muted`,children:B?Z(a.toolsLastCheckSummary,{count:String(B)}):a.toolsRunTestHint}),(0,W.jsxs)(_,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void V(),children:[s?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),a.test]})]}):null,b===`resources`?h?.resources.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.resources.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,W.jsx)(`p`,{className:`text-fg-muted`,children:a.resourcesRunTestHint}):null,b===`prompts`?h?.prompts.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.prompts.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.title??e.name,description:e.description,meta:e.argumentCount?Z(a.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,W.jsx)(`p`,{className:`text-fg-muted`,children:a.promptsRunTestHint}):null,b===`permissions`?(0,W.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,W.jsx)(`p`,{children:Z(a.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,W.jsx)(`p`,{children:e.materialized.type===`mcp`?Z(a.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):Z(a.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,W.jsx)(`p`,{children:e.materialized.type===`mcp`?a.mcpPolicyHint:a.connectorPolicyHint})]}):null,b===`config`&&z?(0,W.jsx)(`div`,{className:`grid gap-3`,children:ee.map(e=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,W.jsx)(`input`,{className:Pt,value:k[e.key]??``,placeholder:e.placeholder,onChange:t=>P(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,W.jsx)(Nt,{instance:e,t:a}):null]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsx)(_,{variant:`secondary`,onClick:n,children:a.modalClose}),b===`config`&&z?(0,W.jsxs)(_,{variant:`primary`,disabled:d,onClick:()=>void re(),children:[d?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(le,{className:`size-4`}),a.modalSave]}):null,e.materialized.type===`mcp`?(0,W.jsxs)(_,{variant:`secondary`,disabled:s,onClick:()=>void V(),children:[s?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),a.test]}):null,(0,W.jsxs)(_,{variant:`ghost`,disabled:l,onClick:()=>void ne(),children:[l?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(M,{className:`size-4`}),a.remove]})]})]})]}),e.materialized.type===`mcp`?(0,W.jsx)(kt,{open:E,onOpenChange:O,serverId:e.materialized.serverId,title:Z(a.installedToolsDialogTitle,{name:e.displayName}),subtitle:a.installedToolsDialogSubtitle,searchPlaceholder:o.toolsDialogSearchPlaceholder,searchEmptyLabel:o.toolsDialogSearchEmpty,emptyLabel:a.toolsRunTestHint,closeLabel:o.toolsDialogClose,tools:h?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}function Bt({instance:e,definition:t,onOpenDetails:n,onChanged:r,t:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),f=(0,H.useCallback)(async()=>{o(!0),u(null);try{await He(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.instanceId,r]),p=(0,H.useCallback)(async()=>{c(!0),u(null);try{await Ve(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e)),c(!1)}},[e.instanceId,r]),m=e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:i.healthNotTested,h=e.usage.lastToolCount??0,g=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`);return(0,W.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:()=>n(e),children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,W.jsx)(d,{className:`size-3`,"aria-hidden":!0}),i.installedBadge]}),g?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:i.tabConfig}):null]}),(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all text-sm leading-5 text-fg-muted`,children:e.materialized.type===`mcp`?Z(i.mcpServerRuntime,{serverId:e.materialized.serverId}):Z(i.runtimeLabel,{runtime:e.materialized.type})}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,W.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[i.statusLabel,` `,m]}),(0,W.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:Z(i.toolsAvailable,{count:String(h)})})]}),l?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:l}):null]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:i.connectorDetails}),(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[e.materialized.type===`mcp`?(0,W.jsxs)(_,{variant:`secondary`,disabled:a,onClick:()=>void f(),children:[a?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),i.test]}):null,(0,W.jsxs)(_,{variant:`ghost`,disabled:s,onClick:()=>void p(),children:[s?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(M,{className:`size-4`}),i.remove]})]})]})]})}var Vt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k),Ht=i(Vt,`min-h-28 font-mono`);function Ut(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function Wt(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function Gt(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,oauth:{flow:null,connected:e.auth.mode!==`oauth`},...t?{store:t}:{}}}function Kt(e){let t=(0,U.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,W.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(qt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,W.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,W.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function qt(e){return(0,W.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,W.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,W.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Jt({draft:e,onChange:t,onClose:n,onInstalled:r,t:a}){let{connector:o}=e,s=e.result?`complete`:e.installing?`health`:`configure`,c=[{id:`configure`,label:a.installStepConfigure},{id:`health`,label:a.installStepHealth},{id:`complete`,label:a.installStepComplete}],l=(0,H.useCallback)(async()=>{t({...e,installing:!0,error:null});try{let n=await Ie(o.id);window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),t({...e,installing:!1,error:null,oauth:{flow:n,connected:!1}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o.id,e,t]),u=(0,H.useCallback)(async()=>{if(e.oauth.flow){t({...e,installing:!0,error:null});try{await Le(o.id,e.oauth.flow.deviceCode),t({...e,installing:!1,error:null,oauth:{...e.oauth,connected:!0}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}}},[o.id,e,t]),f=(0,H.useCallback)(async()=>{t({...e,installing:!0,error:null,result:null,health:null});try{if(o.auth.mode===`oauth`&&!e.oauth.connected)throw Error(a.oauthRequiredBeforeInstall);let n={};for(let t of o.setup.config??[]){let r=Wt(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let i=e.store?await Ae(e.store.packageName,{secrets:e.secrets,config:n},e.store.version):await Re(o.id,{secrets:e.secrets,config:n,definition:o.source===`registry`?o:void 0}),s=null;try{s=await He(i.instanceId)}catch{s=null}t({...e,installing:!1,result:i,health:s}),await r()}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o,e,t,r,a.oauthRequiredBeforeInstall]);return(0,W.jsx)(x,{open:!0,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(N,{children:[(0,W.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(j,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex max-h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(w,{className:`text-base font-semibold text-fg`,children:Z(a.installDialogTitle,{name:o.displayName})}),(0,W.jsx)(S,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o.description})]}),(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,R.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(oe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,W.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":a.installProgressAria,children:c.map((e,t)=>{let n=c.findIndex(e=>e.id===s);return(0,W.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,W.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.auth.mode===`oauth`?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:a.oauthTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.oauthHint}),e.oauth.flow?(0,W.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface-base p-3 text-sm text-fg-muted`,children:[(0,W.jsx)(`p`,{children:Z(a.oauthOpenCodePrefix,{url:e.oauth.flow.verificationUri})}),(0,W.jsx)(`p`,{className:`mt-2 font-mono text-lg font-semibold tracking-widest text-fg`,children:e.oauth.flow.userCode})]}):null,e.oauth.connected?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700`,children:a.oauthConnected}):null,(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,W.jsxs)(_,{variant:`secondary`,disabled:e.installing,onClick:()=>void l(),children:[e.installing&&!e.oauth.flow?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),a.oauthConnectButton]}),(0,W.jsxs)(_,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void u(),children:[e.installing&&e.oauth.flow?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(d,{className:`size-4`}),a.oauthAuthorizedButton]})]})]}):null,e.store?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailPermissions}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,W.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:a.storeLocalExecDenied})]})]}):null,(o.setup.secrets??[]).map(n=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,W.jsx)(ne,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:a.secretInputLabels,placeholder:n.required?a.requiredPlaceholder:a.optionalPlaceholder})]},n.key)),(o.setup.config??[]).map(n=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,W.jsx)(`textarea`,{className:Ht,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,W.jsx)(`input`,{className:Vt,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,W.jsx)(T,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),a.installingTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.installingHint})]}):null,e.error?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,e.result?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:Z(a.installedAs,{target:e.result.materialized.type===`mcp`?e.result.materialized.serverId:e.result.instanceId})}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:Z(a.runtimeLabel,{runtime:e.result.materialized.type.toUpperCase()})})]}),(0,W.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?a.healthStatusHealthy:Ut(e.health?.status,a)})]}),e.health?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,W.jsx)(`div`,{children:a.toolsMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,W.jsx)(`div`,{children:a.resourcesMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,W.jsx)(`div`,{children:a.promptsMetric})]})]}),(0,W.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,W.jsx)(Kt,{title:a.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,W.jsx)(Kt,{title:a.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,W.jsx)(Kt,{title:a.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??Z(a.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,W.jsx)(`p`,{className:`mt-3`,children:a.installedWithoutHealth}),e.health?.action?(0,W.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,W.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,W.jsxs)(_,{variant:`primary`,disabled:!!e.result||e.installing||o.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void f(),children:[e.installing?(0,W.jsx)(T,{className:`size-4 animate-spin`}):e.result?(0,W.jsx)(d,{className:`size-4`}):(0,W.jsx)(b,{className:`size-4`}),e.result?a.installedBadge:a.install]})})]})]})})}function Yt(e,t){let n=e.length+1,r=`server-${n}`,i=new Set([...e.map(e=>e.id.trim()),...t]);for(;i.has(r);)n+=1,r=`server-${n}`;return pt(r)}function Xt(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function Zt(e,t,n){return e.filter(e=>Xt(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Qt(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function $t(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function en(e,t,n){let r=e.key.trim();if(r)return`key:${r}`;let i=e.value.trim();return i?`value:${i}`:`empty:${n.slice(0,t).filter(e=>!e.key.trim()&&!e.value.trim()).length}`}function tn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k)}function nn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:a,pasteFailed:o,keyPlaceholder:s,valuePlaceholder:c,headers:l,onChange:u}){let d=(e,t)=>{u(l.map((n,r)=>r===e?{...n,...t}:n))},f=()=>{u([...l,{key:``,value:``}])},p=e=>{let t=l.filter((t,n)=>n!==e);u(t.length>0?t:[{key:``,value:``}])},m=async()=>{try{let e=await F();if(!e){window.alert(o);return}let t=it(e);if(!t?.length){window.alert(o);return}u(t)}catch{window.alert(o)}};return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,W.jsx)(`span`,{children:e}),t?(0,W.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,W.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void m(),children:[(0,W.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),a]})]}),(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:i(tn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:s,onChange:e=>d(t,{key:e.target.value})}),(0,W.jsx)(`input`,{className:i(tn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:c,onChange:e=>d(t,{value:e.target.value})}),(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:l.length<=1&&!e.key&&!e.value,onClick:()=>p(t),"aria-label":r,children:(0,W.jsx)(M,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},en(e,t,l)))}),(0,W.jsxs)(`button`,{type:`button`,className:i(`self-start text-sm text-accent hover:underline`,R.press),onClick:f,children:[`+ `,n]})]})}var rn=[`stdio`,`sse`,`streamable-http`];function Q(e){let t=(0,U.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,W.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,W.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,W.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function $(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k)}function an(e){let t=(0,U.c)(29),{row:n,t:r,onUpdate:a,idConflictMessage:o,variant:s}=e,c=s===void 0?`all`:s,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==o||t[1]!==a||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Q,{label:r.transportLabel,required:!0,children:(0,W.jsx)(me,{className:$(),value:n.transport,onChange:e=>a({transport:e.target.value}),children:rn.map(e=>(0,W.jsx)(fe,{value:e,children:r.transportLabels[e]},e))})}),(0,W.jsxs)(Q,{label:r.serverIdLabel,required:!0,children:[(0,W.jsx)(`input`,{className:$(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>a({id:e.target.value})}),o?(0,W.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:o}):null]})]}):null,t[0]=o,t[1]=a,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==a||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,W.jsxs)(W.Fragment,{children:[l?(0,W.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,W.jsx)(Q,{label:r.commandLabel,required:!0,children:(0,W.jsx)(`input`,{className:$(),value:n.command,onChange:e=>a({command:e.target.value})})})}):null,u?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Q,{label:r.argsLabel,description:r.argsHint,children:(0,W.jsx)(`input`,{className:$(),value:n.argsText,onChange:e=>a({argsText:e.target.value})})}),(0,W.jsx)(Q,{label:r.cwdLabel,children:(0,W.jsx)(`input`,{className:$(),value:n.cwd,onChange:e=>a({cwd:e.target.value})})}),(0,W.jsx)(Q,{label:r.envLabel,description:r.envHint,children:(0,W.jsx)(`textarea`,{className:i($(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>a({envJson:e.target.value})})})]}):null]}):(0,W.jsxs)(W.Fragment,{children:[l?(0,W.jsx)(`div`,{className:`md:col-span-2`,children:(0,W.jsx)(Q,{label:r.urlLabel,required:!0,children:(0,W.jsx)(`input`,{className:i($(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>a({url:e.target.value})})})}):null,u?(0,W.jsx)(nn,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>a({headers:e})}):null]}),t[7]=a,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==a||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,W.jsx)(Q,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,W.jsx)(`input`,{type:`number`,min:1,max:600,className:$(),value:xt(n),placeholder:r.timeoutPlaceholder,onChange:e=>a({connectionTimeoutMs:St(e.target.value)})})}):null,t[20]=a,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;return t[25]!==d||t[26]!==f||t[27]!==p?(m=(0,W.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m):m=t[28],m}function on(e,t){if(e.shortName)return e.shortName;let n=`${t.trim()}__`;return n&&e.name.startsWith(n)?e.name.slice(n.length):e.name}function sn(e){let t=(0,U.c)(13),{tool:n,serverId:r}=e,a;t[0]!==r||t[1]!==n?(a=on(n,r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s=n.name===o?o:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==o||t[6]!==s?(u=(0,W.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:s,children:o}),t[5]=o,t[6]=s,t[7]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,W.jsx)(pe,{delayDuration:300,skipDelayDuration:100,children:(0,W.jsxs)(se,{children:[(0,W.jsx)(de,{asChild:!0,children:(0,W.jsx)(`p`,{tabIndex:0,title:l,className:i(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:l})}),(0,W.jsx)(B,{children:(0,W.jsx)(f,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,W.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let p;return t[10]!==u||t[11]!==d?(p=(0,W.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=p):p=t[12],p}function cn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:a,config:o,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:f}){let[h,g]=(0,H.useState)(n),[y,b]=(0,H.useState)(!1),[C,E]=(0,H.useState)(!1),[D,O]=(0,H.useState)(null),[k,M]=(0,H.useState)(!1),[P,F]=(0,H.useState)({status:`idle`}),[I,L]=(0,H.useState)(null),ee=n.id.trim(),B=h.id.trim()!==ee&&s.has(h.id.trim())||s.has(h.id.trim())&&t===`add`?c.reservedServerId:void 0,te=h.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===h.id.trim())?l.duplicateServerId:void 0,V=h.id.trim().length>0&&!B&&!te&&(h.transport===`stdio`?h.command.trim().length>0:h.url.trim().length>0),ne=Ct(h),ie=(0,H.useCallback)(async()=>{if(h.id.trim()){E(!0),O(null),F({status:`loading`});try{F({status:`ok`,tools:(await bt(h.id.trim(),ht(h))).tools})}catch(e){F({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{E(!1)}}},[h]),ae=(0,H.useCallback)(async()=>{if(!(!V||y)){b(!0),O(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(h),await gt({sessionIdleTtlMinutes:a,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},ct(o)),await f(),u()}catch(e){O(e instanceof Error?e.message:String(e))}finally{b(!1)}}},[V,o,r,n.clientKey,t,u,f,ee,h,y,a]);return e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(x,{open:e,onOpenChange:e=>{e||u()},children:(0,W.jsxs)(N,{children:[(0,W.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(j,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(w,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,W.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,R.focusRingPanel),"aria-label":l.modalClose,children:[(0,W.jsx)(oe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(z,{className:`size-4 text-accent`,"aria-hidden":!0}),h.id.trim()||c.cardUntitled]}),(0,W.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:ne||(h.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[h.transport]})]})}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,W.jsx)(an,{row:h,t:c,variant:`basic`,onUpdate:e=>{g(t=>({...t,...e})),O(null)},idConflictMessage:B??te})]}),P.status===`ok`?(0,W.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,W.jsx)(p,{className:`size-4 text-accent`,"aria-hidden":!0}),P.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(P.tools.length))]}),P.tools.length>0?(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>L(P.tools),children:c.viewAllTools}):null]}),P.tools.length>0?(0,W.jsx)(`div`,{className:`mt-3 grid gap-2`,children:P.tools.slice(0,6).map((e,t)=>(0,W.jsx)(sn,{tool:e,serverId:h.id},e.name||`tool-${t}`))}):null]}):null,P.status===`error`?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:P.message}):null,D?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D}):null,(0,W.jsxs)(`details`,{open:k,onToggle:e=>M(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(re,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,W.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,W.jsx)(`div`,{className:`border-t border-edge px-4 py-4`,children:(0,W.jsx)(an,{row:h,t:c,variant:`advanced`,onUpdate:e=>{g(t=>({...t,...e})),O(null)}})})]})]})}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsxs)(_,{variant:`secondary`,disabled:!h.id.trim()||C,onClick:()=>void ie(),children:[C?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),c.testConnection]}),(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(_,{variant:`secondary`,children:l.modalCancel})}),(0,W.jsxs)(_,{variant:`primary`,disabled:!V||y,onClick:()=>void ae(),children:[y?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(d,{className:`size-4`}),y?c.saving:l.modalSave]})]})]})]})}),I?(0,W.jsx)(kt,{open:!0,onOpenChange:e=>{e||L(null)},serverId:h.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:I,stripPrefix:`${h.id.trim()}__`}):null]}):null}var ln=`mprov`,un=`xopc-store`,dn=un,fn=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k);function pn(e){let t=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(e.category??``)?e.category:`custom`;return{id:e.name,version:e.latestVersion??`store`,displayName:e.name,description:e.description,category:t,kind:`mcp`,source:`store`,capabilities:[`tools`,`runtime.mcp.streamableHttp`],tags:[`store`],auth:{mode:`none`},setup:{},runtime:{type:`mcp`,serverId:`store-${e.name}`.slice(0,64)}}}function mn(){let e=a(l(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=o(e=>e.token),s=!!r,[c,d]=ae(),f=c.get(ln)?.trim()||dn,[p,m]=(0,H.useState)(`marketplace`),[h,g]=(0,H.useState)({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!0,error:null}),[v,b]=(0,H.useState)(!1),[x,S]=(0,H.useState)(!1),[w,D]=(0,H.useState)(1),[k,A]=(0,H.useState)(void 0),[j,M]=(0,H.useState)(``),[N,P]=(0,H.useState)(f),[F,I]=(0,H.useState)(`name`),[L,z]=(0,H.useState)(null),[B,V]=(0,H.useState)(null),[ne,ie]=(0,H.useState)(null),[oe,se]=(0,H.useState)(null),[ce,le]=(0,H.useState)(null),[de,fe]=(0,H.useState)(void 0),[pe,me]=(0,H.useState)(!1),[he,_e]=(0,H.useState)(!1),{data:U,mutate:G}=te(s),K=U?.payload?.config,q=(0,H.useMemo)(()=>K===void 0?null:mt(K),[K]),J=q?.servers??[];(0,H.useEffect)(()=>{q&&fe(q.sessionIdleTtlMinutes)},[q]);let Y=(0,H.useCallback)(async()=>{if(!r){g({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:null});return}g(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([De(),Me(),je()]);g(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,registries:n,loading:!1,error:null}))}catch(e){g({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,H.useEffect)(()=>{Y()},[Y]);let Ae=c.toString(),Ne=(0,H.useRef)(Ae);(0,H.useEffect)(()=>{Ne.current!==Ae&&(Ne.current=Ae,P(c.get(ln)?.trim()||dn))},[c,Ae]);let Pe=(0,H.useMemo)(()=>[{id:un,displayName:t.storeSourceName},...h.registries],[t.storeSourceName,h.registries]);(0,H.useEffect)(()=>{if(Pe.length===0||Pe.some(e=>e.id===N))return;let e=Pe.some(e=>e.id===dn)?dn:Pe[0]?.id;e&&P(e)},[Pe,N]),(0,H.useEffect)(()=>{if(!N||N===c.get(ln))return;let e=new URLSearchParams(c);e.set(ln,N),Ne.current=e.toString(),d(e,{replace:!0})},[N,c,d]);let Ie=(0,H.useCallback)(async e=>{let t=j.trim(),n=e?.browse??!1,r=Math.max(e?.page??1,1),i=e?.append??!1;if(!(!s||N!==un&&!t&&!n)){b(!0),i?g(e=>({...e,error:null})):(D(1),A(void 0),g(e=>({...e,registryCatalog:[],error:null})));try{let e=N===un?await Oe({q:t||void 0,page:r,pageSize:24,sort:F===`source`?`newest`:`downloads`}).then(e=>({connectors:e.items.map(pn),totalPages:e.meta.totalPages})):await Fe(t,N,{browse:n,page:r});D(r),A(e.totalPages),g(t=>({...t,registryCatalog:i?[...t.registryCatalog,...e.connectors].filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t):e.connectors}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{b(!1)}}},[F,s,j,N]);(0,H.useEffect)(()=>{if(p!==`marketplace`)return;let e=window.setTimeout(()=>{j.trim()?Ie():N&&Ie({browse:!0})},j.trim()?350:0);return()=>window.clearTimeout(e)},[N,j,Ie,h.loading,p]);let Le=(0,H.useMemo)(()=>new Set(h.instances.map(e=>e.connectorId)),[h.instances]),Re=(0,H.useMemo)(()=>new Map([...h.catalog,...h.registryCatalog].map(e=>[e.id,e])),[h.catalog,h.registryCatalog]),ze=(0,H.useCallback)(async e=>{S(!0),g(e=>({...e,error:null}));try{let n=await ke(e);if(n.requiresOAuth&&n.definition.id!==`github`)throw Error(t.storeOAuthUnsupported);z(Gt(n.definition,{packageName:n.packageName,version:n.version,permissions:n.permissions}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{S(!1)}},[t.storeOAuthUnsupported]),Be=(0,H.useMemo)(()=>new Set(h.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[h.instances]),Ve=(0,H.useCallback)(async e=>{if(!q||K===void 0)return;let t=J.filter(t=>t.clientKey!==e.clientKey);await gt({sessionIdleTtlMinutes:q.sessionIdleTtlMinutes,servers:t},ct(K)),await G(),await Y()},[K,J,Y,q,G]),He=(0,H.useCallback)(()=>{le({mode:`add`,row:Yt(J,Be)})},[J,Be]),Ue=(0,H.useCallback)(async()=>{if(!(!q||K===void 0||pe)){me(!0),_e(!1);try{await gt({sessionIdleTtlMinutes:de,servers:J},ct(K)),await G(),_e(!0),u({type:`success`,title:n.saved})}finally{me(!1)}}},[K,J,q,G,de,pe]),We=ue(e=>e.setPageHeader),Ge=ue(e=>e.clearPageHeader),Ke=(0,H.useMemo)(()=>(0,W.jsx)(nt,{loading:h.loading||v||x,searchQuery:j,setSearchQuery:M,onReloadClick:Y,onAddCustomServer:He,searchPlaceholder:p===`marketplace`?t.marketplaceSearchPlaceholder:p===`builtin`?t.builtinSearchPlaceholder:p===`user`?t.userSearchPlaceholder:t.configSearchPlaceholder,addLabel:t.addCustomServer,reloadLabel:t.reload}),[t,Y,He,v,j,h.loading,x,p]);(0,H.useLayoutEffect)(()=>(We({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ke}),()=>Ge()),[Ge,t.title,Ke,We]);let qe=h.instances.length+J.length,Je=(0,H.useMemo)(()=>Zt(h.catalog.filter(e=>e.source===`builtin`),j,F),[F,j,h.catalog]),X=(0,H.useMemo)(()=>Zt(h.registryCatalog,j,F),[F,j,h.registryCatalog]),Ye=p===`marketplace`&&!!(k&&w<k),Xe=(0,H.useMemo)(()=>h.instances.filter(e=>Qt(e,j)),[j,h.instances]),Ze=(0,H.useMemo)(()=>J.filter(e=>$t(e,j)),[J,j]),Qe=(0,H.useMemo)(()=>h.instances.find(e=>e.instanceId===ne)??oe,[ne,oe,h.instances]),$e=Xe.length+Ze.length,et=[{id:`marketplace`,label:t.tabMarketplace},{id:`builtin`,label:t.tabBuiltin,count:Je.length},{id:`user`,label:t.tabUser,count:qe},{id:`config`,label:t.tabConfig}];return(0,W.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,W.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[s?null:(0,W.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,W.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,W.jsx)(xe,{items:et,activeTab:p,onChange:m,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`}),(0,W.jsxs)(`div`,{className:`flex min-h-9 min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[p===`marketplace`?(0,W.jsx)(`div`,{className:`inline-flex h-9 max-w-full shrink-0 overflow-x-auto rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,role:`group`,"aria-label":t.registrySourceAria,children:Pe.map(e=>(0,W.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,R.focusRingPanel,N===e.id?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":N===e.id,onClick:()=>P(e.id),children:e.displayName},e.id))}):null,p!==`user`&&p!==`config`?(0,W.jsxs)(E,{children:[(0,W.jsx)(ve,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,R.transition,R.focusRingPanel),children:[(0,W.jsx)(ee,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:F===`name`?t.sortName:t.sortSource}),(0,W.jsx)(re,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,W.jsx)(C,{children:(0,W.jsxs)(O,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,W.jsx)(y,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>I(`name`),children:t.sortName}),(0,W.jsx)(y,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>I(`source`),children:t.sortSource})]})})]}):null]})]}),h.error?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h.error}):null,p===`user`&&s?(0,W.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.installedTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.installedHint})]}),h.loading?(0,W.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.slice(0,3).map(e=>(0,W.jsx)(Te,{},e))}):qe===0||$e===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:qe===0?t.installedEmpty:t.userEmpty}):(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[Xe.map(e=>(0,W.jsx)(Bt,{instance:e,definition:Re.get(e.connectorId),onOpenDetails:e=>{ie(e.instanceId),se(e)},onChanged:Y,t},e.instanceId)),Ze.map(e=>(0,W.jsx)(wt,{row:e,t:n,cs:t,onEdit:()=>le({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Ve(e)},e.clientKey))]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,p===`config`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,W.jsxs)(be,{children:[(0,W.jsx)(ye,{icon:ge,title:n.globalTitle,subtitle:n.globalHint}),(0,W.jsx)(`div`,{className:`max-w-xl`,children:(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.idleTtlLabel}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`number`,min:0,className:i(fn,`w-40 flex-none`),value:de??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();fe(t===``?void 0:Number.parseInt(t,10)),_e(!1)}}),(0,W.jsxs)(_,{variant:`secondary`,disabled:pe,onClick:()=>void Ue(),children:[pe?(0,W.jsx)(T,{className:`size-4 animate-spin`}):null,n.save]})]}),(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]})})]})}):null,p===`marketplace`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:v&&X.length===0?(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.map(e=>(0,W.jsx)(we,{},e))}):j.trim()&&X.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}):!j.trim()&&X.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceStartHint}):(0,W.jsxs)(`div`,{className:`relative`,children:[v?(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,W.jsx)(T,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:X.map(e=>(0,W.jsx)(Ee,{connector:e,installed:Le.has(e.id)||Ce(e,h.instances),onInstall:e=>{if(e.source===`store`){ze(e.id);return}z(Gt(e))},onOpenDetails:e.source===`store`?void 0:V,t},e.id))}),Ye?(0,W.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,W.jsxs)(_,{type:`button`,variant:`secondary`,disabled:v||x,onClick:()=>void Ie({browse:!j.trim(),page:w+1,append:!0}),children:[v?(0,W.jsx)(T,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})}):null,p===`builtin`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:h.loading?(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.map(e=>(0,W.jsx)(we,{},e))}):Je.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.builtinEmpty}):(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Je.map(e=>(0,W.jsx)(Ee,{connector:e,installed:Le.has(e.id)||Ce(e,h.instances),onInstall:e=>z(Gt(e)),onOpenDetails:V,t},e.id))})}):null]}),L?(0,W.jsx)(Jt,{draft:L,onChange:z,onClose:()=>z(null),t,onInstalled:async()=>{await Y(),await G(),m(`user`)}}):null,B?(0,W.jsx)(tt,{connector:B,installed:Le.has(B.id)||Ce(B,h.instances),onClose:()=>V(null),onInstall:e=>z(Gt(e)),t}):null,Qe?(0,W.jsx)(zt,{instance:Qe,definition:Re.get(Qe.connectorId),onClose:()=>{ie(null),se(null)},onChanged:Y,t,mcp:n}):null,ce?(0,W.jsx)(cn,{open:!0,mode:ce.mode,initialRow:ce.row,existingCustomServers:J,sessionIdleTtlMinutes:de,config:K,managedServerIds:Be,t:n,cs:t,onClose:()=>le(null),onSaved:async()=>{await G(),await Y(),m(`user`)}},`${ce.mode}-${ce.row.clientKey}`):null]})})}export{mn as ConnectorsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-BQ_8x0bT.js";import{t as i}from"./messages-DbNQuFdA.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{Cs as o,Eo as s,Ga as c,Ha as l,Jn as u,Ka as d,Ms as f,Ua as ee,Va as p,Vo as m,Wa as h,Yn as g,ct as _,es as v,il as y,jt as b,ko as x,no as S,ro as C,ss as w,to as T}from"./index-CrPRlGMg.js";var E=e(t(),1),D=n();function O(){return{title:``,objective:``,description:``,attachments:[],checklist:[``],scopeBoundary:``,evidencePlan:[``],priority:`normal`,deadlineMode:`none`,deadline:``,maxTurns:`10`,agentId:``,judgeModelRef:``}}function k(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function A(e){let t=e=>String(e).padStart(2,`0`);return[e.getFullYear(),`-`,t(e.getMonth()+1),`-`,t(e.getDate()),`T`,t(e.getHours()),`:`,t(e.getMinutes())].join(``)}function j(e){let t=new Date;return t.setDate(t.getDate()+e),t.setHours(23,59,0,0),A(t)}function M(){let e=new Date,t=e.getDay(),n=t<=5?5-t:7-t+5;return e.setDate(e.getDate()+n),e.setHours(23,59,0,0),A(e)}function N(e){if(e===`today`)return j(0);if(e===`tomorrow`)return j(1);if(e===`friday`)return M();if(e===`custom`){let e=new Date;return e.setHours(e.getHours()+1,0,0,0),A(e)}return``}function P(e){let t=new Set,n=[];for(let r of e){let e=r.trim();!e||t.has(e.toLowerCase())||(t.add(e.toLowerCase()),n.push(e))}return n}function F({open:e,t,chat:n,busy:A,options:j,onClose:M,onCreate:F,onDraftContract:I}){let L=i(a(e=>e.language)).agentsSettings,[R,z]=(0,E.useState)(()=>O()),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(null),[K,q]=(0,E.useState)(!1),J=_({chat:n});(0,E.useEffect)(()=>{e||(z(O()),V(!1),U(!1),G(null),q(!1),J.clearAttachments())},[J.clearAttachments,e]),(0,E.useEffect)(()=>{!e||!j.defaultAgentId||z(e=>e.agentId?e:{...e,agentId:j.defaultAgentId})},[e,j.defaultAgentId]);let Y=e=>z(t=>({...t,...e})),X=j.agents.length?j.agents:[{id:j.defaultAgentId||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],Z=X.find(e=>e.id===R.agentId)??X.find(e=>e.id===j.defaultAgentId)??X[0],Q=Z?u(Z,L):``,te=R.agentId||Z?.id||`main`,$=[...Z?.typedModels.effective??[]].sort((e,t)=>e.id===`judge`?-1:t.id===`judge`?1:e.id.localeCompare(t.id)),ne=j.models.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t),re=e=>{Y({deadlineMode:e,deadline:N(e)})},ie=(e,t)=>{z(n=>({...n,checklist:n.checklist.map((n,r)=>r===e?t:n)}))},ae=e=>{z(t=>({...t,checklist:t.checklist.filter((t,n)=>n!==e)}))},oe=(e,t)=>{z(n=>({...n,evidencePlan:n.evidencePlan.map((n,r)=>r===e?t:n)}))},se=e=>{z(t=>({...t,evidencePlan:t.evidencePlan.filter((t,n)=>n!==e)}))},ce=async()=>{G(null),q(!0);try{Y(I?await I({...R,attachments:J.wireAttachmentsPayload()}):{objective:R.objective||R.title,scopeBoundary:R.scopeBoundary,evidencePlan:P(R.evidencePlan).length?R.evidencePlan:[...t.createDialog.defaultEvidencePlan],checklist:R.checklist}),V(!0)}catch(e){G(e instanceof Error?e.message:t.createDialog.draftFailed)}finally{q(!1)}},le=async()=>{if(G(null),!R.title.trim()){G(t.createDialog.titleRequired);return}try{await F({...R,attachments:J.wireAttachmentsPayload(),checklist:P(R.checklist)}),M()}catch(e){G(e instanceof Error?e.message:t.errors.create)}};return(0,D.jsx)(c,{open:e,onOpenChange:e=>!e&&M(),children:(0,D.jsxs)(h,{children:[(0,D.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,D.jsxs)(p,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(92vh,46rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,D.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(d,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.createDialog.title}),(0,D.jsx)(l,{className:`mt-1 truncate text-sm text-fg-muted`,children:t.createDialog.description})]}),(0,D.jsx)(s,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":t.closeDetails,onClick:M,children:(0,D.jsx)(x,{className:`size-5`,"aria-hidden":!0})})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,D.jsxs)(`div`,{className:`grid gap-4`,children:[(0,D.jsx)(`section`,{className:`rounded-lg border border-accent/25 bg-accent-soft/50 px-3 py-3`,children:(0,D.jsxs)(`div`,{className:`flex flex-col gap-3 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:t.createDialog.simpleStartTitle}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.simpleStartHint})]}),(0,D.jsxs)(s,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 rounded-lg text-xs`,onClick:()=>void ce(),disabled:K||!R.title.trim()&&!R.description.trim(),children:[(0,D.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),K?t.createDialog.drafting:t.createDialog.aiDraft]})]})}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalTitle}),(0,D.jsx)(`input`,{value:R.title,onChange:e=>Y({title:e.target.value}),placeholder:t.newGoalPlaceholder,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,autoFocus:!0})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalDescription}),(0,D.jsxs)(s,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>J.fileInputRef.current?.click(),children:[(0,D.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addAttachment]})]}),(0,D.jsx)(`textarea`,{value:R.description,onChange:e=>Y({description:e.target.value}),placeholder:t.createDialog.descriptionPlaceholder,rows:4,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,D.jsx)(`input`,{ref:J.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,J.processFiles(t)}}),(0,D.jsx)(b,{attachments:J.attachments,topPadded:!1,onRemove:J.removeAttachment})]}),(0,D.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>V(e=>!e),children:[(0,D.jsxs)(`span`,{className:`min-w-0`,children:[(0,D.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:t.createDialog.completionPlan}),(0,D.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.createDialog.completionPlanHint})]}),(0,D.jsx)(y,{className:r(`size-4 shrink-0 text-fg-muted transition-transform`,B&&`rotate-180`),"aria-hidden":!0})]}),B?(0,D.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[(0,D.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.criteriaTitle}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.criteriaHint}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:j.checklistDecomposePolicy===`supplement_existing`?t.createDialog.checklistPolicySupplementExisting:t.createDialog.checklistPolicyEmptyOnly})]}),(0,D.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[R.checklist.map((e,n)=>(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`input`,{value:e,onChange:e=>ie(n,e.target.value),placeholder:k(t.createDialog.criteriaPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,D.jsx)(s,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeCriteria,onClick:()=>ae(n),children:(0,D.jsx)(m,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,D.jsxs)(s,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>Y({checklist:[...R.checklist,``]}),children:[(0,D.jsx)(o,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addCriteria]})]})]}),(0,D.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,D.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.contractTitle}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.contractHint}),(0,D.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.objective}),(0,D.jsx)(`textarea`,{value:R.objective,onChange:e=>Y({objective:e.target.value}),placeholder:t.createDialog.objectivePlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.scopeBoundary}),(0,D.jsx)(`textarea`,{value:R.scopeBoundary,onChange:e=>Y({scopeBoundary:e.target.value}),placeholder:t.createDialog.scopeBoundaryPlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`div`,{className:`mt-3 grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.evidencePlan}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.createDialog.evidencePlanHint}),R.evidencePlan.map((e,n)=>(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`input`,{value:e,onChange:e=>oe(n,e.target.value),placeholder:k(t.createDialog.evidencePlanPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,D.jsx)(s,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeEvidence,onClick:()=>se(n),children:(0,D.jsx)(m,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,D.jsxs)(s,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>Y({evidencePlan:[...R.evidencePlan,``]}),children:[(0,D.jsx)(o,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addEvidence]})]})]})]}):null]}),(0,D.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>U(e=>!e),children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,D.jsx)(w,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t.createDialog.advanced]}),(0,D.jsx)(y,{className:r(`size-4 text-fg-muted transition-transform`,H&&`rotate-180`),"aria-hidden":!0})]}),H?(0,D.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 sm:grid-cols-2`,children:[(0,D.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.agentId}),(0,D.jsx)(T,{value:te,onChange:e=>Y({agentId:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:X.map(e=>(0,D.jsx)(C,{value:e.id,children:g(e,L)+(e.isDefault?` · ${t.createDialog.defaultAgent}`:` · ${e.id}`)},e.id))}),Q?(0,D.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:Q}):Z?.model?.primary?(0,D.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:k(t.createDialog.agentPrimaryModel,{model:Z.model.primary})}):null]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.priority}),(0,D.jsxs)(T,{value:R.priority,onChange:e=>Y({priority:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,D.jsx)(C,{value:`normal`,children:t.priorities.normal}),(0,D.jsx)(C,{value:`high`,children:t.priorities.high}),(0,D.jsx)(C,{value:`low`,children:t.priorities.low})]})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadline}),(0,D.jsxs)(T,{value:R.deadlineMode,onChange:e=>re(e.target.value),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,D.jsx)(C,{value:`none`,children:t.createDialog.deadlineNone}),(0,D.jsx)(C,{value:`today`,children:t.createDialog.deadlineToday}),(0,D.jsx)(C,{value:`tomorrow`,children:t.createDialog.deadlineTomorrow}),(0,D.jsx)(C,{value:`friday`,children:t.createDialog.deadlineFriday}),(0,D.jsx)(C,{value:`custom`,children:t.createDialog.deadlineCustom})]})]}),R.deadlineMode===`none`?null:(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadlineAt}),(0,D.jsx)(`input`,{type:`datetime-local`,value:R.deadline,onChange:e=>Y({deadline:e.target.value,deadlineMode:`custom`}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.maxTurns}),(0,D.jsx)(`input`,{type:`number`,min:1,max:500,value:R.maxTurns,onChange:e=>Y({maxTurns:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.judgeModel}),(0,D.jsxs)(T,{value:R.judgeModelRef,onChange:e=>Y({judgeModelRef:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,D.jsx)(C,{value:``,children:t.createDialog.judgeModelPlaceholder}),$.length?(0,D.jsx)(S,{label:t.createDialog.agentModelRoles,children:$.map(e=>(0,D.jsxs)(C,{value:e.model,children:[e.id===`judge`?t.createDialog.judgeRole:e.id,` · `,e.model]},`${e.id}:${e.model}`))}):null,(0,D.jsx)(S,{label:t.createDialog.configuredModels,children:ne.map(e=>(0,D.jsxs)(C,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]})]})]}):null]}),W?(0,D.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:W}):null]})}),(0,D.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,D.jsx)(s,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:M,children:t.createDialog.cancel}),(0,D.jsxs)(s,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:A||!R.title.trim(),onClick:()=>void le(),children:[(0,D.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t.createDialog.create]})]})]})]})})}export{P as n,F as t};