@xopcai/xopc 0.0.121 → 0.0.123

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 (309) hide show
  1. package/README.md +23 -3
  2. package/README.zh-CN.md +23 -3
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-4AW4JgSU.js → agent-avatar-dicebear-Bicr3ZBg.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-CxDSFHGx.js +2 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-CE6GkGU2.js → app-management-settings-panel-CbEy9sR1.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-BmaUjghw.js → appearance-settings-CTHja6n9.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-CyZdgqvm.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-CX4_KWut.js → archive-plugin-Bpy64GjU.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-jf-PIIUU.js → attachment-load-DMkp4xSb.js} +1 -1
  12. package/dist/gateway/static/root/assets/automation-suggestion-card-KnYaP7NT.js +1 -0
  13. package/dist/gateway/static/root/assets/automations-page-8VLKM4au.js +1 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-DG9XQikd.js → binary-plugins-DA9C5mCw.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-Up_VIxLJ.js → block-editor-CiSXk_YC.js} +6 -6
  16. package/dist/gateway/static/root/assets/browser-settings-page-5tPg0DcP.js +8 -0
  17. package/dist/gateway/static/root/assets/{capability-presets-api-CGM4OyMw.js → capability-presets-api-CEJ44WCU.js} +1 -1
  18. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-CzWt0LBb.js → capability-presets-settings-panel-BJW3aVST.js} +1 -1
  19. package/dist/gateway/static/root/assets/{channel-recipient-api-BEByL4_o.js → channel-recipient-api-CDhrhfhN.js} +1 -1
  20. package/dist/gateway/static/root/assets/channels-settings-CorUCTrs.js +1 -0
  21. package/dist/gateway/static/root/assets/connectors-page-VKstC3sP.js +2 -0
  22. package/dist/gateway/static/root/assets/directory-picker-path-field-7jKfbH0J.js +1 -0
  23. package/dist/gateway/static/root/assets/dreaming-settings-m1-wmz4o.js +1 -0
  24. package/dist/gateway/static/root/assets/{extension-debug-page-DZxa_j7-.js → extension-debug-page-C9qQQrBS.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-page-CseziW53.js → extension-page-DcBBMEGl.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-settings-page-B_9J-xyo.js → extension-settings-page-BQ-jMMP9.js} +1 -1
  27. package/dist/gateway/static/root/assets/{fetch-Cs4ck8zA.js → fetch-Dtpbbe0s.js} +1 -1
  28. package/dist/gateway/static/root/assets/{gateway-config-api-Dl223a7r.js → gateway-config-api-BN6pyX2c.js} +1 -1
  29. package/dist/gateway/static/root/assets/gateway-settings-hQtgVmSR.js +1 -0
  30. package/dist/gateway/static/root/assets/{gateway-startup-retry-IvePwjFE.js → gateway-startup-retry-BIET2x3y.js} +1 -1
  31. package/dist/gateway/static/root/assets/goal-create-dialog-BuIMDx6C.js +1 -0
  32. package/dist/gateway/static/root/assets/goal-detail-page-FEypCq74.js +1 -0
  33. package/dist/gateway/static/root/assets/{goals-config-api-CUCP6yCl.js → goals-config-api-CQm2r1Ty.js} +1 -1
  34. package/dist/gateway/static/root/assets/goals-page-C4-2_MLG.js +2 -0
  35. package/dist/gateway/static/root/assets/{goals-settings-Dj87qPxv.js → goals-settings-DDrdRMxB.js} +1 -1
  36. package/dist/gateway/static/root/assets/heartbeat-settings-BJVok3Sl.js +1 -0
  37. package/dist/gateway/static/root/assets/index-CBDr5xjB.css +1 -0
  38. package/dist/gateway/static/root/assets/index-T0SaNd5a.js +191 -0
  39. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DJgYw0nB.js → keyboard-shortcuts-settings-C2TuQppb.js} +1 -1
  40. package/dist/gateway/static/root/assets/logs-page-DwkwPgid.js +2 -0
  41. package/dist/gateway/static/root/assets/{markdown-split-gnQ_EiGo.js → markdown-split-DhONQ81k.js} +1 -1
  42. package/dist/gateway/static/root/assets/{media-plugins-CQV-mgJn.js → media-plugins-DS44pJzr.js} +1 -1
  43. package/dist/gateway/static/root/assets/messages-avfvyZuQ.js +3 -0
  44. package/dist/gateway/static/root/assets/models-hub-panel-huNY4A1G.js +2 -0
  45. package/dist/gateway/static/root/assets/notes-page-DdfGuEZ1.js +1 -0
  46. package/dist/gateway/static/root/assets/notes-workbench-B0bT9Hqa.js +2 -0
  47. package/dist/gateway/static/root/assets/{preview-open-alternatives-BPMXC-2u.js → preview-open-alternatives-Dej6zHnr.js} +1 -1
  48. package/dist/gateway/static/root/assets/project-detail-page-CjxhPorG.js +1 -0
  49. package/dist/gateway/static/root/assets/projects-page-C4Z5OJMF.js +1 -0
  50. package/dist/gateway/static/root/assets/remote-access-hub-CVCOPUVd.js +1 -0
  51. package/dist/gateway/static/root/assets/{save-bar-controls-BEHqwZjz.js → save-bar-controls-Zu1FzH6z.js} +1 -1
  52. package/dist/gateway/static/root/assets/{schedule-field-CMY25m97.js → schedule-field-BW78mKc0.js} +1 -1
  53. package/dist/gateway/static/root/assets/{schema-form-CxjxsFfg.js → schema-form-Cc-IOydE.js} +1 -1
  54. package/dist/gateway/static/root/assets/segmented-styles-BL8oLBEp.js +1 -0
  55. package/dist/gateway/static/root/assets/sessions-page-B4qExXHC.js +1 -0
  56. package/dist/gateway/static/root/assets/settings-advanced-gate-Ce8yLTBi.js +1 -0
  57. package/dist/gateway/static/root/assets/{settings-collapsible-section-s-kiLAxP.js → settings-collapsible-section-DIpIYht_.js} +1 -1
  58. package/dist/gateway/static/root/assets/{settings-form-section-CIxIEYxU.js → settings-form-section-BFxBNxOG.js} +1 -1
  59. package/dist/gateway/static/root/assets/settings-page-C4fivemT.js +1 -0
  60. package/dist/gateway/static/root/assets/settings-page-layout-CLx4o2PN.js +1 -0
  61. package/dist/gateway/static/root/assets/setup-status-panel-Kyc4eUf0.js +1 -0
  62. package/dist/gateway/static/root/assets/share-preview-page-ZswWCrDu.js +2 -0
  63. package/dist/gateway/static/root/assets/shares-settings-Bu76CMiC.js +1 -0
  64. package/dist/gateway/static/root/assets/skill-reload-api-D-CFg86j.js +1 -0
  65. package/dist/gateway/static/root/assets/skills-page-CUU4f6Ss.js +2 -0
  66. package/dist/gateway/static/root/assets/{system-settings-panel-Czjf0kLJ.js → system-settings-panel-3ZNcGRhS.js} +1 -1
  67. package/dist/gateway/static/root/assets/{typed-models-lib-Cmt8SYdI.js → typed-models-lib-bpzZjiVF.js} +1 -1
  68. package/dist/gateway/static/root/assets/{use-channel-catalog-DyM-ckEQ.js → use-channel-catalog-BCjZLZ3O.js} +1 -1
  69. package/dist/gateway/static/root/assets/{user-profile-settings-panel-BygLv8vm.js → user-profile-settings-panel-CIXafITi.js} +1 -1
  70. package/dist/gateway/static/root/assets/{utils-CloW8coB.js → utils-DXMtz5j_.js} +1 -1
  71. package/dist/gateway/static/root/assets/voice-api-key-field-C1MrQD8R.js +1 -0
  72. package/dist/gateway/static/root/assets/workflow-run-setup-panel-DqizIcY5.js +3 -0
  73. package/dist/gateway/static/root/assets/workflow-start-dialog-B4sZpTDQ.js +1 -0
  74. package/dist/gateway/static/root/assets/workflows-page-B3sVNPFk.js +18 -0
  75. package/dist/gateway/static/root/index.html +5 -5
  76. package/dist/package.js +1 -1
  77. package/dist/src/agent/agent-manager.d.ts +2 -0
  78. package/dist/src/agent/agent-manager.js +47 -7
  79. package/dist/src/agent/agent-manager.js.map +1 -1
  80. package/dist/src/agent/context/project-context.d.ts +19 -0
  81. package/dist/src/agent/context/project-context.js +90 -0
  82. package/dist/src/agent/context/project-context.js.map +1 -0
  83. package/dist/src/agent/goals/goal-locale.js +2 -2
  84. package/dist/src/agent/memory/types.d.ts +1 -0
  85. package/dist/src/agent/prompt/service-prompt-builder.d.ts +1 -0
  86. package/dist/src/agent/prompt/service-prompt-builder.js +2 -0
  87. package/dist/src/agent/prompt/service-prompt-builder.js.map +1 -1
  88. package/dist/src/agent/prompt/system-prompt-params.d.ts +2 -0
  89. package/dist/src/agent/prompt/system-prompt-params.js +1 -0
  90. package/dist/src/agent/prompt/system-prompt-params.js.map +1 -1
  91. package/dist/src/agent/prompt/system-prompt.d.ts +1 -0
  92. package/dist/src/agent/prompt/system-prompt.js +2 -1
  93. package/dist/src/agent/prompt/system-prompt.js.map +1 -1
  94. package/dist/src/agent/service.js +4 -3
  95. package/dist/src/agent/service.js.map +1 -1
  96. package/dist/src/agent/session/session-config-service.js +6 -1
  97. package/dist/src/agent/session/session-config-service.js.map +1 -1
  98. package/dist/src/agent/session/session-hydrator.js +7 -3
  99. package/dist/src/agent/session/session-hydrator.js.map +1 -1
  100. package/dist/src/agent/session/session-inspector.js +9 -5
  101. package/dist/src/agent/session/session-inspector.js.map +1 -1
  102. package/dist/src/agent/starter-agents.js +5 -34
  103. package/dist/src/agent/starter-agents.js.map +1 -1
  104. package/dist/src/agent/tools/factory.js +1 -1
  105. package/dist/src/agent/tools/factory.js.map +1 -1
  106. package/dist/src/agent/tools/goal-tool.d.ts +5 -1
  107. package/dist/src/agent/tools/goal-tool.js +8 -2
  108. package/dist/src/agent/tools/goal-tool.js.map +1 -1
  109. package/dist/src/agent/tools/index.d.ts +1 -1
  110. package/dist/src/agent/workflow/index.js +2 -2
  111. package/dist/src/agent/workflow/runtime.js +1 -1
  112. package/dist/src/automations/api/routes.js +13 -2
  113. package/dist/src/automations/api/routes.js.map +1 -1
  114. package/dist/src/automations/domain/types.d.ts +2 -0
  115. package/dist/src/automations/domain/validation.d.ts +3 -0
  116. package/dist/src/automations/domain/validation.js +1 -0
  117. package/dist/src/automations/domain/validation.js.map +1 -1
  118. package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -0
  119. package/dist/src/automations/service/action-executor.js +3 -1
  120. package/dist/src/automations/service/action-executor.js.map +1 -1
  121. package/dist/src/automations/service/automation-service.d.ts +4 -1
  122. package/dist/src/automations/service/automation-service.js +2 -2
  123. package/dist/src/automations/service/automation-service.js.map +1 -1
  124. package/dist/src/automations/storage/automation-repository.d.ts +3 -1
  125. package/dist/src/automations/storage/automation-repository.js +7 -5
  126. package/dist/src/automations/storage/automation-repository.js.map +1 -1
  127. package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
  128. package/dist/src/automations/storage/automation-run-repository.js +12 -1
  129. package/dist/src/automations/storage/automation-run-repository.js.map +1 -1
  130. package/dist/src/chat-commands/builtins/goal.js +4 -1
  131. package/dist/src/chat-commands/builtins/goal.js.map +1 -1
  132. package/dist/src/chat-commands/context.js +2 -1
  133. package/dist/src/chat-commands/context.js.map +1 -1
  134. package/dist/src/cli/command-loaders.js +1 -0
  135. package/dist/src/cli/command-loaders.js.map +1 -1
  136. package/dist/src/cli/command-manifest.js +4 -0
  137. package/dist/src/cli/command-manifest.js.map +1 -1
  138. package/dist/src/cli/commands/agent.js +2 -2
  139. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  140. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  141. package/dist/src/cli/commands/goal.js +27 -4
  142. package/dist/src/cli/commands/goal.js.map +1 -1
  143. package/dist/src/cli/commands/models.js +1 -1
  144. package/dist/src/cli/commands/onboard.js +1 -1
  145. package/dist/src/cli/commands/profile.js +1 -1
  146. package/dist/src/cli/commands/project.d.ts +4 -0
  147. package/dist/src/cli/commands/project.js +239 -0
  148. package/dist/src/cli/commands/project.js.map +1 -0
  149. package/dist/src/cli/commands/tunnel.js +1 -1
  150. package/dist/src/cli/commands/update.js +1 -1
  151. package/dist/src/cli/extension-cli-register.js +1 -1
  152. package/dist/src/config/index.js +1 -1
  153. package/dist/src/gateway/hono/routes/goals.js +51 -4
  154. package/dist/src/gateway/hono/routes/goals.js.map +1 -1
  155. package/dist/src/gateway/hono/routes/index.js +2 -0
  156. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  157. package/dist/src/gateway/hono/routes/memory.js +5 -1
  158. package/dist/src/gateway/hono/routes/memory.js.map +1 -1
  159. package/dist/src/gateway/hono/routes/notes.js +5 -0
  160. package/dist/src/gateway/hono/routes/notes.js.map +1 -1
  161. package/dist/src/gateway/hono/routes/projects.d.ts +3 -0
  162. package/dist/src/gateway/hono/routes/projects.js +662 -0
  163. package/dist/src/gateway/hono/routes/projects.js.map +1 -0
  164. package/dist/src/gateway/hono/routes/sessions.js +47 -7
  165. package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
  166. package/dist/src/gateway/hono/routes/workflows.js +27 -4
  167. package/dist/src/gateway/hono/routes/workflows.js.map +1 -1
  168. package/dist/src/gateway/run-loop.js +1 -1
  169. package/dist/src/gateway/service.d.ts +3 -0
  170. package/dist/src/gateway/service.js +10 -3
  171. package/dist/src/gateway/service.js.map +1 -1
  172. package/dist/src/goals/goal-service.d.ts +1 -1
  173. package/dist/src/goals/goal-service.js +2 -1
  174. package/dist/src/goals/goal-service.js.map +1 -1
  175. package/dist/src/goals/goal-store.d.ts +1 -1
  176. package/dist/src/goals/goal-store.js +12 -6
  177. package/dist/src/goals/goal-store.js.map +1 -1
  178. package/dist/src/goals/goal-workflow-judge.js +1 -1
  179. package/dist/src/goals/types.d.ts +3 -0
  180. package/dist/src/i18n/goals-bundle.js +1 -1
  181. package/dist/src/i18n/index.js +1 -1
  182. package/dist/src/i18n/share-tool-bundle.js +2 -2
  183. package/dist/src/notes/agent-context.js +2 -2
  184. package/dist/src/projects/automation-bind.d.ts +1 -0
  185. package/dist/src/projects/automation-bind.js +16 -0
  186. package/dist/src/projects/automation-bind.js.map +1 -0
  187. package/dist/src/projects/goal-bind.d.ts +4 -0
  188. package/dist/src/projects/goal-bind.js +40 -0
  189. package/dist/src/projects/goal-bind.js.map +1 -0
  190. package/dist/src/projects/index.d.ts +12 -0
  191. package/dist/src/projects/index.js +12 -0
  192. package/dist/src/projects/memory-bind.d.ts +1 -0
  193. package/dist/src/projects/memory-bind.js +16 -0
  194. package/dist/src/projects/memory-bind.js.map +1 -0
  195. package/dist/src/projects/project-agent.d.ts +10 -0
  196. package/dist/src/projects/project-agent.js +27 -0
  197. package/dist/src/projects/project-agent.js.map +1 -0
  198. package/dist/src/projects/project-loop.d.ts +58 -0
  199. package/dist/src/projects/project-loop.js +118 -0
  200. package/dist/src/projects/project-loop.js.map +1 -0
  201. package/dist/src/projects/project-service.d.ts +40 -0
  202. package/dist/src/projects/project-service.js +187 -0
  203. package/dist/src/projects/project-service.js.map +1 -0
  204. package/dist/src/projects/project-store.d.ts +31 -0
  205. package/dist/src/projects/project-store.js +193 -0
  206. package/dist/src/projects/project-store.js.map +1 -0
  207. package/dist/src/projects/session-bind.d.ts +5 -0
  208. package/dist/src/projects/session-bind.js +46 -0
  209. package/dist/src/projects/session-bind.js.map +1 -0
  210. package/dist/src/projects/types.d.ts +62 -0
  211. package/dist/src/projects/types.js +1 -0
  212. package/dist/src/projects/workflow-bind.d.ts +1 -0
  213. package/dist/src/projects/workflow-bind.js +16 -0
  214. package/dist/src/projects/workflow-bind.js.map +1 -0
  215. package/dist/src/projects/workspace-project.d.ts +22 -0
  216. package/dist/src/projects/workspace-project.js +143 -0
  217. package/dist/src/projects/workspace-project.js.map +1 -0
  218. package/dist/src/projects/workspace.d.ts +5 -0
  219. package/dist/src/projects/workspace.js +25 -0
  220. package/dist/src/projects/workspace.js.map +1 -0
  221. package/dist/src/session/index.d.ts +1 -1
  222. package/dist/src/session/index.js +3 -3
  223. package/dist/src/session/session-workspace.d.ts +4 -2
  224. package/dist/src/session/session-workspace.js +10 -3
  225. package/dist/src/session/session-workspace.js.map +1 -1
  226. package/dist/src/session/types.d.ts +3 -0
  227. package/dist/src/session/types.js.map +1 -1
  228. package/dist/src/storage/sqlite/memory-records-repository.d.ts +3 -0
  229. package/dist/src/storage/sqlite/memory-records-repository.js +16 -5
  230. package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
  231. package/dist/src/storage/sqlite/migrations/019_projects.sql +40 -0
  232. package/dist/src/storage/sqlite/migrations/020_project_default_agent.sql +1 -0
  233. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  234. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  235. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  236. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  237. package/dist/src/storage/sqlite/notes-repository.js +20 -4
  238. package/dist/src/storage/sqlite/notes-repository.js.map +1 -1
  239. package/dist/src/storage/sqlite/row-mappers.d.ts +2 -0
  240. package/dist/src/storage/sqlite/row-mappers.js +2 -0
  241. package/dist/src/storage/sqlite/row-mappers.js.map +1 -1
  242. package/dist/src/storage/sqlite/schema.js +1 -1
  243. package/dist/src/storage/sqlite/session-repository.js +10 -5
  244. package/dist/src/storage/sqlite/session-repository.js.map +1 -1
  245. package/dist/src/storage/sqlite/transcript-repository.js +8 -0
  246. package/dist/src/storage/sqlite/transcript-repository.js.map +1 -1
  247. package/dist/src/tui/backends/embedded-backend.d.ts +7 -1
  248. package/dist/src/tui/backends/embedded-backend.js +41 -2
  249. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  250. package/dist/src/tui/backends/gateway-sse-backend.d.ts +7 -1
  251. package/dist/src/tui/backends/gateway-sse-backend.js +22 -0
  252. package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
  253. package/dist/src/tui/tui-backend.d.ts +16 -0
  254. package/dist/src/tui/tui-commands.js +145 -0
  255. package/dist/src/tui/tui-commands.js.map +1 -1
  256. package/dist/src/tui/tui.js +21 -0
  257. package/dist/src/tui/tui.js.map +1 -1
  258. package/dist/src/workflows/domain/run.d.ts +1 -0
  259. package/dist/src/workflows/domain/run.js.map +1 -1
  260. package/dist/src/workflows/index.js +1 -1
  261. package/dist/src/workflows/service/workflow-run-service.d.ts +1 -0
  262. package/dist/src/workflows/service/workflow-run-service.js +18 -4
  263. package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
  264. package/dist/src/workflows/service/workflow-run-service.types.d.ts +2 -0
  265. package/dist/src/workflows/service/workflow-session-bridge.d.ts +1 -0
  266. package/dist/src/workflows/service/workflow-session-bridge.js +3 -0
  267. package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
  268. package/dist/src/workflows/store/run-index-store.d.ts +1 -0
  269. package/dist/src/workflows/store/run-index-store.js +13 -3
  270. package/dist/src/workflows/store/run-index-store.js.map +1 -1
  271. package/dist/src/workflows/store/run-store.d.ts +3 -1
  272. package/dist/src/workflows/store/run-store.js +5 -2
  273. package/dist/src/workflows/store/run-store.js.map +1 -1
  274. package/package.json +10 -1
  275. package/dist/gateway/static/root/assets/agents-2SVUUPlp.js +0 -2
  276. package/dist/gateway/static/root/assets/apps-page-BWeQ1I49.js +0 -1
  277. package/dist/gateway/static/root/assets/automation-suggestion-card-BHk5rtJz.js +0 -1
  278. package/dist/gateway/static/root/assets/automations-page-QHotl53D.js +0 -1
  279. package/dist/gateway/static/root/assets/browser-settings-page-Cmwi6IIQ.js +0 -8
  280. package/dist/gateway/static/root/assets/channels-settings-BOMCUe2J.js +0 -1
  281. package/dist/gateway/static/root/assets/connectors-page-C-Dexk_F.js +0 -2
  282. package/dist/gateway/static/root/assets/dreaming-settings-WPEj8pir.js +0 -1
  283. package/dist/gateway/static/root/assets/gateway-settings-DdzbtW9R.js +0 -1
  284. package/dist/gateway/static/root/assets/goal-detail-page-Dxldogms.js +0 -1
  285. package/dist/gateway/static/root/assets/goals-page-DU5Nd6Xp.js +0 -2
  286. package/dist/gateway/static/root/assets/heartbeat-settings-Cgm5JmwH.js +0 -1
  287. package/dist/gateway/static/root/assets/index-BU1pvxmS.js +0 -191
  288. package/dist/gateway/static/root/assets/index-l54WfSqe.css +0 -1
  289. package/dist/gateway/static/root/assets/logs-page-C10aS4XO.js +0 -2
  290. package/dist/gateway/static/root/assets/messages-C6Kc4Jhf.js +0 -3
  291. package/dist/gateway/static/root/assets/models-hub-panel-B35CAfg6.js +0 -2
  292. package/dist/gateway/static/root/assets/note-detail-page-Brlwse8x.js +0 -2
  293. package/dist/gateway/static/root/assets/note-image-lightbox-BthwKjLA.js +0 -1
  294. package/dist/gateway/static/root/assets/note-time-hm6JO_Wi.js +0 -1
  295. package/dist/gateway/static/root/assets/notes-page-CoAwRc7L.js +0 -1
  296. package/dist/gateway/static/root/assets/remote-access-hub-B36RQ05h.js +0 -1
  297. package/dist/gateway/static/root/assets/sessions-page-73THChnj.js +0 -1
  298. package/dist/gateway/static/root/assets/settings-advanced-gate-CR9VsY-R.js +0 -1
  299. package/dist/gateway/static/root/assets/settings-page-BJ1AhfKI.js +0 -1
  300. package/dist/gateway/static/root/assets/settings-page-layout--6qT7ZJa.js +0 -1
  301. package/dist/gateway/static/root/assets/setup-status-panel-C1TtS1vJ.js +0 -1
  302. package/dist/gateway/static/root/assets/share-preview-page-BZADSbS1.js +0 -2
  303. package/dist/gateway/static/root/assets/shares-settings-gqC8Rmhy.js +0 -1
  304. package/dist/gateway/static/root/assets/skill-reload-api-C9P-WYvS.js +0 -1
  305. package/dist/gateway/static/root/assets/skills-page-CEpSvOhF.js +0 -2
  306. package/dist/gateway/static/root/assets/voice-api-key-field-BsoqJba6.js +0 -1
  307. package/dist/gateway/static/root/assets/voice-player-store-DduWlJYV.js +0 -1
  308. package/dist/gateway/static/root/assets/workflow-run-setup-panel-CcQeX6l5.js +0 -3
  309. package/dist/gateway/static/root/assets/workflows-page-CeA8A9Ef.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-C6Kc4Jhf.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-Cs4ck8zA.js";import{r as d}from"./toast-z0toXu32.js";import{Ba as f,Co as p,Ds as m,Fo as h,Gs as g,Hs as _,Jn as v,Js as y,Ma as b,Ns as x,Oa as S,Qi as C,Ra as w,Rs as T,Ss as E,To as D,Ts as O,Uo as k,Za as A,_a as j,ao as M,bo as N,ct as P,f as F,fs as I,gi as L,go as ee,ha as R,hi as z,ia as B,io as V,no as H,oa as U,ot as W,st as G,va as te,wo as K,yc as ne,zs as re}from"./index-BU1pvxmS.js";import{t as ie}from"./settings-advanced-gate-CR9VsY-R.js";import{n as ae,t as q}from"./settings-form-section-CIxIEYxU.js";import{i as oe,n as se,r as ce,t as le}from"./settings-page-layout--6qT7ZJa.js";import{c as ue,r as de,s as J}from"./typed-models-lib-Cmt8SYdI.js";import{i as fe,l as pe,s as me,u as he}from"./gateway-config-api-Dl223a7r.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 ge(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 _e(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(ue(),`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(ve),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)(B,{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)(y,{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 border border-edge-subtle bg-surface-panel px-3 py-2.5`,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`,ge(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 ve(e){return(0,Z.jsx)(U,{value:e.value,children:e.name},e.value)}function ye(e){return`browser-focus-${e}`}function be(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 xe(e){let t=(0,X.c)(89),{a:n,form:r,update:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=ye(`runtime`),t[0]=a):a=t[0];let o;t[1]===n.browserBehaviorShow?o=t[2]:(o=(0,Z.jsx)(ae,{icon:H,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=ue(),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)(U,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=g);let _;t[22]===n.browserDialogPolicyAutoDismiss?_=t[23]:(_=(0,Z.jsx)(U,{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)(U,{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)(B,{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=ye(`security`),t[53]=A):A=t[53];let j;t[54]===n.browserSecurityShow?j=t[55]:(j=(0,Z.jsx)(ae,{icon:M,title:n.browserSecurityShow}),t[54]=n.browserSecurityShow,t[55]=j);let N;t[56]===i?N=t[57]:(N=e=>i({browserAllowPrivateUrls:e.target.checked}),t[56]=i,t[57]=N);let P;t[58]!==r.browserAllowPrivateUrls||t[59]!==N?(P=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:N}),t[58]=r.browserAllowPrivateUrls,t[59]=N,t[60]=P):P=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]!==P||t[64]!==F?(I=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[P,F]}),t[63]=P,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 ee=n.label.browserCommandTimeout,R=n.desc.browserCommandTimeout,z;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(z=J(),t[70]=z):z=t[70];let V=r.browserCommandTimeout??``,W;t[71]===i?W=t[72]:(W=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=W);let G;t[73]!==V||t[74]!==W?(G=(0,Z.jsx)(`input`,{type:`number`,className:z,min:5,value:V,placeholder:`30`,onChange:W}),t[73]=V,t[74]=W,t[75]=G):G=t[75];let te;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==G?(te=(0,Z.jsx)(Q,{label:ee,description:R,children:G}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=G,t[79]=te):te=t[79];let K;t[80]!==L||t[81]!==te?(K=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[L,te]}),t[80]=L,t[81]=te,t[82]=K):K=t[82];let ne;t[83]!==j||t[84]!==K?(ne=(0,Z.jsx)(`div`,{id:A,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{className:`border border-amber-500/20`,children:[j,K]})}),t[83]=j,t[84]=K,t[85]=ne):ne=t[85];let re;return t[86]!==k||t[87]!==ne?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[k,ne]}),t[86]=k,t[87]=ne,t[88]=re):re=t[88],re}function Se(e){let t=(0,X.c)(9),{language:n,label:r,className:a}=e,o;t[0]===n?o=t[1]:(o=C(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)(E,{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 Ce(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 border border-edge bg-surface-panel px-3 py-3 text-left transition-colors`,`hover:border-edge-strong 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)(y,{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 b;t[17]!==f||t[18]!==_?(b=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[f,_,v]}),t[17]=f,t[18]=_,t[19]=b):b=t[19];let x;t[20]===l?x=t[21]:(x=(0,Z.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:l}),t[20]=l,t[21]=x);let S;return t[22]!==c||t[23]!==u||t[24]!==b||t[25]!==x?(S=(0,Z.jsxs)(`button`,{type:`button`,onClick:c,"aria-label":u,className:d,children:[b,x]}),t[22]=c,t[23]=u,t[24]=b,t[25]=x,t[26]=S):S=t[26],S}function we(e){let t=(0,X.c)(25),{m:n,onStart:r}=e,i=v(Te),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:N,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:V,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:h,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:x,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>pe(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)(Ce,{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 border border-edge-subtle bg-surface-base px-4 py-4`,children:[l,u]}),t[22]=l,t[23]=u,t[24]=d):d=t[24],d}function Te(e){return e.mode}function Ee(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 De(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Oe(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function ke(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 Ae=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],je=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Me={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Ne(e){let t=(e??``).trim();return t===`behavior`?`overview`:Ae.includes(t)?t:`overview`}function Pe(e){return je.includes(e)}function Fe(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)(Ie,{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)(Ie,{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 border border-edge bg-surface-panel p-4`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Ie(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:g,color:`text-green-600 dark:text-green-400`,label:a.browserStatusReady},not_installed:{icon:f,color:`text-amber-600 dark:text-amber-400`,label:a.browserStatusNotInstalled},checking:{icon:k,color:`text-fg-muted`,label:a.browserStatusChecking},unknown:{icon:_,color:`text-fg-muted`,label:a.browserStatusUnknown},error:{icon:re,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 m;t[15]===s?m=t[16]:(m=(0,Z.jsx)(`span`,{children:s}),t[15]=s,t[16]=m);let h;t[17]!==c||t[18]!==p||t[19]!==m?(h=(0,Z.jsxs)(`span`,{className:c,children:[p,m]}),t[17]=c,t[18]=p,t[19]=m,t[20]=h):h=t[20];let v;t[21]===r?v=t[22]:(v=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]=v);let y;return t[23]!==l||t[24]!==h||t[25]!==v?(y=(0,Z.jsxs)(`span`,{className:l,children:[h,v]}),t[23]=l,t[24]=h,t[25]=v,t[26]=y):y=t[26],y}function Le(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 Re={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function ze({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,Y.useReducer)(P,Re),{instances:u,launchStatus:d,launchMessage:f,testStatus:m,testMessage:h,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]),x=(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)(Fe,{icon:K,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)(k,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(K,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[f?(0,Z.jsx)(Le,{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 border border-edge bg-surface-base p-3 text-xs`,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)(A,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Fe,{icon:b,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()||m===`pending`,onClick:()=>void x(),children:[m===`pending`?(0,Z.jsx)(k,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(p,{className:`size-3.5`}),m===`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}),h?(0,Z.jsx)(Le,{kind:m===`error`?`error`:`success`,message:h}):null]})]})}function Be(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 Ve(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=Be(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 border border-edge bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted`,children:r.lines.map(He)}):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 border border-edge bg-surface-base px-3 py-2.5`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function He(e){return(0,Z.jsx)(`div`,{className:`truncate`,children:e},e)}var Ue={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function We({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)(P,Ue),{confirmOpen:f,installStatus:p,installMessage:m,openStatus:h,openMessage:_,runtime:v}=u,{progress:y,running:b,cancelling:x,run:S,reset:C,cancel:w}=i,T=t.kind===`ok`?t.data:null,E=T?.installed===!0,D=p===`installing`||b,A=(0,Y.useCallback)(async()=>{if(E)try{d({type:`patch`,patch:{runtime:await a()}})}catch{}},[a,E]);(0,Y.useEffect)(()=>{if(!E){d({type:`patch`,patch:{runtime:null}});return}A();let e=setInterval(()=>void A(),8e3);return()=>clearInterval(e)},[E,A]);let j=(0,Y.useCallback)(async()=>{d({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),C();let t=await S({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}}),C();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 A()},[r,s.binaryPath,s.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,A,C,S]),M=(0,Y.useCallback)(async()=>{if(h!==`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,h]),N=t.kind===`loading`?`checking`:t.kind===`error`?`error`:E?`ready`:`not_installed`,I=E&&T?.version?`v${T.version} (${T.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fe,{icon:V,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:N,statusDetail:I,m:e,embedded:l,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E?(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:h===`pending`,onClick:()=>void M(),children:[h===`pending`?(0,Z.jsx)(k,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(K,{className:`size-3.5`}),h===`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:D,onClick:()=>d({type:`patch`,patch:{confirmOpen:!0}}),children:[D?(0,Z.jsx)(k,{className:`size-3.5 animate-spin`}):E?(0,Z.jsx)(ee,{className:`size-3.5`}):p===`installed`?(0,Z.jsx)(g,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(O,{className:`size-3.5`}),D?e.browserCloakInstalling:E?e.browserReinstall:e.browserCloakDownload]})]}),children:[b?(0,Z.jsx)(Ve,{m:e,progress:y,cancelling:x,onCancel:()=>void w()}):null,m?(0,Z.jsx)(Le,{kind:p===`failed`?`error`:`success`,message:m}):null,_?(0,Z.jsx)(Le,{kind:h===`error`?`error`:`success`,message:_}):null,E&&v?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge bg-surface-base p-3 text-xs`,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:v.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(v.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:v.userDataDir})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),v.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)(B,{className:ue(),value:s.humanPreset,onChange:e=>c({humanPreset:e.target.value}),children:[(0,Z.jsx)(U,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(U,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(q,{className:`mt-4 border border-edge-subtle`,children:[(0,Z.jsx)(ae,{icon:V,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:Ge(),value:s.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>c({extraArgs:e.target.value})})})})]})]}),(0,Z.jsx)(F,{open:f,title:e.browserConfirmDownloadTitle,description:Ke(e,T),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void j(),onCancel:()=>d({type:`patch`,patch:{confirmOpen:!1}})})]})}function Ge(){return`${J()} min-h-[4.5rem] resize-y font-mono text-xs`}function Ke(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 qe({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[s,c]=(0,Y.useState)(`idle`),[l,u]=(0,Y.useState)(null),d=t.provider===`local`?`browserbase`:t.provider,f=a(o(e=>e.language)).providersSettings,m=R({show:f.show,hide:f.hide,copy:f.copy,copied:f.copied}),h=(0,Y.useCallback)(()=>fe().then(e=>e.apiKey??null),[]),g=(0,Y.useCallback)(async()=>{c(`pending`),u(null);try{let n=await r(d,t.apiKey);n.reachable?(c(`ok`),u(e.browserCloudTestOk)):(c(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){c(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,d,r]);return(0,Z.jsxs)(Fe,{icon:x,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:s===`pending`,onClick:()=>void g(),children:[s===`pending`?(0,Z.jsx)(k,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(p,{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)(B,{className:ue(),value:d,onChange:e=>n({provider:e.target.value}),children:[(0,Z.jsx)(U,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,Z.jsx)(U,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,Z.jsx)(j,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:d===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:m,reveal:h,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`})})]}),l?(0,Z.jsx)(Le,{kind:s===`error`?`error`:`success`,message:l}):null]})}function Je(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:f}=e,p;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(p={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=p):p=t[2];let m=!!a&&o,h;t[3]!==s||t[4]!==a||t[5]!==f||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?(h=a?(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge bg-surface-raised px-2.5 py-2`,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:f?n.browserExtensionInstalling:n.browserExtensionRevealFolder})]})]}):null,t[3]=s,t[4]=a,t[5]=f,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]=h):h=t[15];let _;t[16]!==n.browserExtensionInstallStep2||t[17]!==m||t[18]!==h?(_={id:`load`,label:n.browserExtensionInstallStep2,done:m,detail:h},t[16]=n.browserExtensionInstallStep2,t[17]=m,t[18]=h,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]!==p||t[24]!==_||t[25]!==v?(y=[p,_,v],t[23]=p,t[24]=_,t[25]=v,t[26]=y):y=t[26];let b=y,x;t[27]===b?x=t[28]:(x=b.filter(Ye),t[27]=b,t[28]=x);let S=x.length,C=n.browserExtensionInstallGuideTitle,w;t[29]===n.browserExtensionInstallGuideTitle?w=t[30]:(w=(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=w);let E;t[31]!==S||t[32]!==n.browserExtensionChecklistProgress||t[33]!==b.length?(E=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(S)).replace(`{{total}}`,String(b.length)),t[31]=S,t[32]=n.browserExtensionChecklistProgress,t[33]=b.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]!==w?(O=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[w,D]}),t[37]=D,t[38]=w,t[39]=O):O=t[39];let k;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==b?(k=(0,Z.jsx)(`ol`,{className:`flex flex-col gap-3`,children:b.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)(g,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,Z.jsx)(T,{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]=b,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":C,className:`rounded-xl border border-edge 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 Ye(e){return e.done}var Xe=19820,Ze=3e4;function Qe({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:m=!1}){let[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),x=f.port??Xe,S=f.host||`127.0.0.1`,C=`ws://${S}:${x}/browser-ext`,T=t.kind===`ok`&&t.data.running,E=t.kind===`ok`&&t.data.connected,j=t.kind===`ok`&&t.data.bridgeHeld===!0,M=t.kind===`ok`&&t.data.portConflict===!0,P=T||j,F=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,I=F?.installed===!0,L=F?.extensionDir,ee=F?.needsChromeReload===!0,R=t.kind===`ok`?E?{icon:D,color:`text-green-500`,label:e.browserExtensionConnected}:T?{icon:p,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:w,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:w,color:`text-fg-muted`,label:`…`},z=R.icon,B=(0,Y.useCallback)(async()=>{if(!h){g(`start`),v(null);try{await i({host:S,port:x})}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,S,x,i]),V=(0,Y.useCallback)(async()=>{if(!h){g(`stop`),v(null);try{await a()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,a]),H=(0,Y.useCallback)(async()=>{if(!h){g(`disconnect`),v(null);try{await o()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,o]),U=(0,Y.useCallback)(async()=>{if(!h){g(`install`),v(null),b(null);try{let t=await s({force:I});t?.extensionDir?b(`${e.browserExtensionInstalled}: ${t.extensionDir}`):b(e.browserExtensionInstalled),await c()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,s,I,e.browserExtensionInstalled,c]),W=(0,Y.useCallback)(async()=>{if(!h){g(`open`),v(null);try{await l()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,l]),G=(0,Y.useCallback)(async()=>{if(!(!L||h)){g(`path`),v(null),b(null);try{await te(L)?d({type:`success`,title:e.browserExtensionPathCopied}):b(e.browserExtensionPathCopyFailed)}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(null)}}},[h,L,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),ne=(0,Y.useCallback)(async()=>{if(!(!L||h)){g(`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{g(null)}}},[h,L,e.browserExtensionFolderOpened,u]),re=(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:h!==null,onClick:()=>void U(),children:[h===`install`?(0,Z.jsx)(k,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(O,{className:`size-3.5`}),h===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),P?(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:h!==null,onClick:()=>void V(),children:[h===`stop`?(0,Z.jsx)(k,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(A,{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:h!==null,onClick:()=>void B(),children:[h===`start`?(0,Z.jsx)(k,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(K,{className:`size-3.5`}),h===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),E?(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:h!==null,onClick:()=>void H(),children:[h===`disconnect`?(0,Z.jsx)(k,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(w,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,Z.jsx)(Fe,{icon:N,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:m,primaryAction:re,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(Xe),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(Ze/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 border border-edge bg-surface-base px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:C}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${R.color}`,children:[(0,Z.jsx)(z,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:R.label})]})]}),(0,Z.jsx)(Je,{m:e,installed:I,extensionDir:L,connected:E,busy:h!==null,pathBusy:h===`path`,folderBusy:h===`folder`,onOpenChrome:()=>void W(),onCopyPath:()=>void G(),onRevealFolder:()=>void ne()}),ee?(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(x))}):null,y?(0,Z.jsx)(Le,{kind:`success`,message:y}):null,_?(0,Z.jsx)(Le,{kind:`error`,message:_}):null]})})}function $e(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,f]=(0,Y.useState)(null),{progress:p,running:m,cancelling:_,run:v,reset:y,cancel:b}=o,x;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==y||t[5]!==v?(x=async()=>{u(`installing`),f(null),y();let e=await v({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){u(`installing`);return}if(e.error===`cancelled`){u(`idle`),f(null),y();return}u(`failed`),f(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),u(`installed`),f(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]=y,t[5]=v,t[6]=x):x=t[6];let S=x,C=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,w=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,T=r.kind===`ok`&&r.data.installed,E=l===`installing`||m,D;t[7]===S?D=t[8]:(D=()=>void S(),t[7]=S,t[8]=D);let A;t[9]!==T||t[10]!==E||t[11]!==l?(A=E?(0,Z.jsx)(k,{className:`size-3.5 animate-spin`}):T?(0,Z.jsx)(ee,{className:`size-3.5`}):l===`installed`?(0,Z.jsx)(g,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(O,{className:`size-3.5`}),t[9]=T,t[10]=E,t[11]=l,t[12]=A):A=t[12];let j=E?n.browserPlaywrightInstalling:T?n.browserReinstall:n.browserPlaywrightInstall,M;t[13]!==E||t[14]!==D||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:E,onClick:D,children:[A,j]}),t[13]=E,t[14]=D,t[15]=A,t[16]=j,t[17]=M):M=t[17];let N;t[18]===n.browserPlaywrightManualInstall?N=t[19]:(N=(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=N);let P;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(P=(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]=P):P=t[20];let F;t[21]===N?F=t[22]:(F=(0,Z.jsxs)(`div`,{className:`text-xs`,children:[N,P]}),t[21]=N,t[22]=F);let I;t[23]!==b||t[24]!==_||t[25]!==n||t[26]!==p||t[27]!==m?(I=m?(0,Z.jsx)(Ve,{m:n,progress:p,showLogs:!0,cancelling:_,onCancel:()=>void b()}):null,t[23]=b,t[24]=_,t[25]=n,t[26]=p,t[27]=m,t[28]=I):I=t[28];let L;t[29]!==d||t[30]!==l?(L=d?(0,Z.jsx)(Le,{kind:l===`failed`?`error`:`success`,message:d}):null,t[29]=d,t[30]=l,t[31]=L):L=t[31];let R;return t[32]!==c||t[33]!==n||t[34]!==w||t[35]!==C||t[36]!==I||t[37]!==L||t[38]!==M||t[39]!==F?(R=(0,Z.jsxs)(Fe,{icon:h,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:C,statusDetail:w,m:n,embedded:c,primaryAction:M,children:[F,I,L]}),t[32]=c,t[33]=n,t[34]=w,t[35]=C,t[36]=I,t[37]=L,t[38]=M,t[39]=F,t[40]=R):R=t[40],R}async function et(e){let t=await u(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 u(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 tt={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function nt(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 rt(e){let[t,n]=(0,Y.useReducer)(nt,tt),{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 et(c(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),l=(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 et(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()=>et(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 u(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 et(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}l()},[_,l]);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:l,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 et(c(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var it=`
3
-
4
- `,at=/\r\n/g,ot={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},st={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},ct=8;function lt(){return{phase:null,message:null,percent:null,lines:[]}}function ut(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>ct?r.slice(-8):r}return n}async function dt(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(at,`
6
- `);let l=a.split(it);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 ft(e){let[t,n]=(0,Y.useState)(lt),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),s=(0,Y.useRef)(!1),l=(0,Y.useRef)(null),d=(0,Y.useCallback)(()=>{s.current||n(lt())},[]),f=(0,Y.useCallback)(async()=>{if(s.current){o(!0);try{await u(c(st[e]),{method:`POST`}).catch(()=>{}),l.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;l.current=r,s.current=!0,i(!0),n(lt());try{let i=await u(c(ot[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 dt(i.body,e=>{n(t=>ut(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{l.current===r&&(l.current=null),s.current=!1,i(!1),o(!1)}},[e]),reset:d,cancel:f}}function pt(e){let t=(0,X.c)(150),{a:n,form:r,update:a,activeTab:s,setActiveTab:c}=e,l=o(ht),u=v(mt),d=ft(`playwright`),f=ft(`cloakbrowser`),p=r.browserEnabled&&(s===`overview`||s===`extension`),m=r.browserEnabled&&(s===`overview`||s===`local`),g=r.browserEnabled&&(s===`overview`||s===`cloakbrowser`),_;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]!==g||t[7]!==p||t[8]!==m?(_={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:p,probeLocal:m,probeCloak:g,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]=g,t[7]=p,t[8]=m,t[9]=_):_=t[9];let y=rt(_),S;t[10]===y.playwright?S=t[11]:(S=Ee(y.playwright),t[10]=y.playwright,t[11]=S);let C=S,w;t[12]===y.cloak?w=t[13]:(w=Ee(y.cloak),t[12]=y.cloak,t[13]=w);let T=w,E;t[14]===y.extension?E=t[15]:(E=Oe(y.extension),t[14]=y.extension,t[15]=E);let D=E,O;t[16]!==n||t[17]!==y.extension?(O=ke(y.extension,n),t[16]=n,t[17]=y.extension,t[18]=O):O=t[18];let k=O,A;t[19]!==n||t[20]!==T||t[21]!==D||t[22]!==k||t[23]!==C||t[24]!==u?(A=[{value:`extension`,icon:N,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:D,statusLabel:k},{value:`local`,icon:h,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:C,statusLabel:De(C,n)},{value:`cloakbrowser`,icon:V,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:T,statusLabel:De(T,n)},{value:`cdp`,icon:b,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:x,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>pe(e.value,u)),t[19]=n,t[20]=T,t[21]=D,t[22]=k,t[23]=C,t[24]=u,t[25]=A):A=t[25];let j=A,M;t[26]!==c||t[27]!==a?(M=e=>{a({browserEnabled:!0,browserBackend:e}),c(e)},t[26]=c,t[27]=a,t[28]=M):M=t[28];let P=M,F=!r.browserEnabled&&`pointer-events-none opacity-40`,L;t[29]===F?L=t[30]:(L=i(`flex flex-col gap-5 transition-opacity`,F),t[29]=F,t[30]=L);let ee=!r.browserEnabled,R;t[31]!==n||t[32]!==s||t[33]!==y.disconnectExtension||t[34]!==y.extension||t[35]!==y.extensionArtifacts||t[36]!==y.installExtensionArtifacts||t[37]!==y.openExtensionChrome||t[38]!==y.refetchExtensionArtifacts||t[39]!==y.revealExtensionFolder||t[40]!==y.startExtensionBridge||t[41]!==y.stopExtensionBridge||t[42]!==r.browserExtensionConnectionTimeout||t[43]!==r.browserExtensionHost||t[44]!==r.browserExtensionPort||t[45]!==a?(R=s===`extension`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Qe,{embedded:!0,m:n,probe:y.extension,artifacts:y.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:y.startExtensionBridge,stopBridge:y.stopExtensionBridge,disconnectExtension:y.disconnectExtension,installArtifacts:y.installExtensionArtifacts,refetchArtifacts:y.refetchExtensionArtifacts,openExtensionChrome:y.openExtensionChrome,revealExtensionFolder:y.revealExtensionFolder})}):null,t[31]=n,t[32]=s,t[33]=y.disconnectExtension,t[34]=y.extension,t[35]=y.extensionArtifacts,t[36]=y.installExtensionArtifacts,t[37]=y.openExtensionChrome,t[38]=y.refetchExtensionArtifacts,t[39]=y.revealExtensionFolder,t[40]=y.startExtensionBridge,t[41]=y.stopExtensionBridge,t[42]=r.browserExtensionConnectionTimeout,t[43]=r.browserExtensionHost,t[44]=r.browserExtensionPort,t[45]=a,t[46]=R):R=t[46];let z;t[47]!==n||t[48]!==s||t[49]!==y.applyPlaywrightDoctor||t[50]!==y.playwright||t[51]!==y.refetchPlaywright||t[52]!==d?(z=s===`local`?(0,Z.jsx)(q,{children:(0,Z.jsx)($e,{embedded:!0,m:n,doctor:y.playwright,refetch:y.refetchPlaywright,applyDoctor:y.applyPlaywrightDoctor,installStream:d})}):null,t[47]=n,t[48]=s,t[49]=y.applyPlaywrightDoctor,t[50]=y.playwright,t[51]=y.refetchPlaywright,t[52]=d,t[53]=z):z=t[53];let B;t[54]!==n||t[55]!==s||t[56]!==f||t[57]!==y.applyCloakDoctor||t[58]!==y.cloak||t[59]!==y.fetchCloakRuntimeStatus||t[60]!==y.launchCloak||t[61]!==y.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?(B=s===`cloakbrowser`?(0,Z.jsx)(q,{children:(0,Z.jsx)(We,{embedded:!0,m:n,doctor:y.cloak,refetch:y.refetchCloak,applyDoctor:y.applyCloakDoctor,installStream:f,fetchRuntimeStatus:y.fetchCloakRuntimeStatus,launchCloak:y.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]=s,t[56]=f,t[57]=y.applyCloakDoctor,t[58]=y.cloak,t[59]=y.fetchCloakRuntimeStatus,t[60]=y.launchCloak,t[61]=y.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]=B):B=t[74];let H;t[75]!==n||t[76]!==s||t[77]!==y.launchCdp||t[78]!==y.listCdpInstances||t[79]!==y.pingCdp||t[80]!==y.stopCdp||t[81]!==r.browserCdpUrl||t[82]!==a?(H=s===`cdp`?(0,Z.jsx)(q,{children:(0,Z.jsx)(ze,{embedded:!0,m:n,cdpUrl:r.browserCdpUrl,onCdpUrlChange:e=>a({browserCdpUrl:e}),launch:y.launchCdp,stop:y.stopCdp,listInstances:y.listCdpInstances,ping:y.pingCdp})}):null,t[75]=n,t[76]=s,t[77]=y.launchCdp,t[78]=y.listCdpInstances,t[79]=y.pingCdp,t[80]=y.stopCdp,t[81]=r.browserCdpUrl,t[82]=a,t[83]=H):H=t[83];let U;t[84]!==n||t[85]!==s||t[86]!==y.testCloud||t[87]!==r.browserCloudApiKey||t[88]!==r.browserCloudProjectId||t[89]!==r.browserCloudProvider||t[90]!==r.browserCloudRegion||t[91]!==a?(U=s===`cloud`?(0,Z.jsx)(q,{children:(0,Z.jsx)(qe,{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:y.testCloud})}):null,t[84]=n,t[85]=s,t[86]=y.testCloud,t[87]=r.browserCloudApiKey,t[88]=r.browserCloudProjectId,t[89]=r.browserCloudProvider,t[90]=r.browserCloudRegion,t[91]=a,t[92]=U):U=t[92];let W;t[93]!==R||t[94]!==z||t[95]!==B||t[96]!==H||t[97]!==U||t[98]!==L||t[99]!==ee?(W=(0,Z.jsxs)(`div`,{className:L,"aria-hidden":ee,children:[R,z,B,H,U]}),t[93]=R,t[94]=z,t[95]=B,t[96]=H,t[97]=U,t[98]=L,t[99]=ee,t[100]=W):W=t[100];let G=W;if(s===`overview`){let e;t[101]!==n||t[102]!==r.browserEnabled||t[103]!==P?(e=r.browserEnabled?null:(0,Z.jsx)(we,{m:n,onStart:P}),t[101]=n,t[102]=r.browserEnabled,t[103]=P,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)(I,{className:`size-4`,strokeWidth:1.75})}),t[105]=o):o=t[105];let s;t[106]===a?s=t[107]:(s=e=>a({browserEnabled:e.target.checked}),t[106]=a,t[107]=s);let u;t[108]!==r.browserEnabled||t[109]!==s?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserEnabled,onChange:s}),t[108]=r.browserEnabled,t[109]=s,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]!==l?(m=(0,Z.jsx)(Se,{language:l,label:n.browserDocsLink,className:`shrink-0 pt-1`}),t[120]=n.browserDocsLink,t[121]=l,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]!==j||t[130]!==c||t[131]!==a?(g=r.browserEnabled?(0,Z.jsx)(`div`,{id:ye(`connection`),className:i(`scroll-mt-24 transition-opacity`,!r.browserEnabled&&`pointer-events-none opacity-40`),children:(0,Z.jsx)(_e,{m:n,value:r.browserBackend,onChange:e=>a({browserBackend:e}),onOpenConfig:c,options:j})}):(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]=j,t[130]=c,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)(xe,{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)(ie,{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 Pe(s)?G:null}function mt(e){return e.mode}function ht(e){return e.language}function gt(e){let t=(0,X.c)(57),{sectionId:n,intro:r,vm:i,children:s,tabbed:c}=e,l=c===void 0?!1:c,u=o(_t),d;t[0]===u?d=t[1]:(d=a(u),t[0]=u,t[1]=d);let f=d,p=f.agentSettings,h=f.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(m,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===h?n=t[4]:(n=(0,Z.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:h}),t[3]=h,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)(le,{gap:`gap-3`,padding:`px-4 py-10`,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,n;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),n=(0,Z.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),t[10]=e,t[11]=n):(e=t[10],n=t[11]);let r;return t[12]===f.logs.loading?r=t[13]:(r=(0,Z.jsxs)(le,{gap:`gap-0`,padding:`px-4 py-8`,children:[e,n,(0,Z.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:f.logs.loading})]}),t[12]=f.logs.loading,t[13]=r),r}if(!i.form){let e=i.error??i.fetchError??p.loadError,n;t[14]===e?n=t[15]:(n=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[14]=e,t[15]=n);let r;t[16]===i?r=t[17]:(r=()=>void i.mutate(),t[16]=i,t[17]=r);let a;t[18]!==f.logs.refresh||t[19]!==r?(a=(0,Z.jsx)(S,{type:`button`,variant:`secondary`,onClick:r,children:f.logs.refresh}),t[18]=f.logs.refresh,t[19]=r,t[20]=a):a=t[20];let o;return t[21]!==n||t[22]!==a?(o=(0,Z.jsxs)(le,{gap:`gap-3`,padding:`px-4 py-10`,children:[n,a]}),t[21]=n,t[22]=a,t[23]=o):o=t[23],o}let g=l?void 0:r,_;t[24]===p.sectionDesc?_=t[25]:(_=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:p.sectionDesc}),t[24]=p.sectionDesc,t[25]=_);let v;t[26]!==p.saved||t[27]!==i.dirty||t[28]!==i.saveOk?(v=i.saveOk&&!i.dirty?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,role:`status`,children:p.saved}):null,t[26]=p.saved,t[27]=i.dirty,t[28]=i.saveOk,t[29]=v):v=t[29];let y=!i.dirty||i.saving,b;t[30]!==p.discard||t[31]!==y||t[32]!==i.discard?(b=(0,Z.jsx)(S,{type:`button`,variant:`secondary`,disabled:y,onClick:i.discard,children:p.discard}),t[30]=p.discard,t[31]=y,t[32]=i.discard,t[33]=b):b=t[33];let x=!i.dirty||i.saving,C;t[34]===i?C=t[35]:(C=()=>void i.save(),t[34]=i,t[35]=C);let w=i.saving?p.saving:p.save,T;t[36]!==x||t[37]!==C||t[38]!==w?(T=(0,Z.jsx)(S,{type:`button`,variant:`primary`,disabled:x,onClick:C,children:w}),t[36]=x,t[37]=C,t[38]=w,t[39]=T):T=t[39];let E;t[40]!==T||t[41]!==v||t[42]!==b?(E=(0,Z.jsxs)(Z.Fragment,{children:[v,b,T]}),t[40]=T,t[41]=v,t[42]=b,t[43]=E):E=t[43];let D;t[44]!==h||t[45]!==E||t[46]!==g||t[47]!==_?(D=(0,Z.jsx)(se,{title:h,subtitle:g,meta:_,actions:E}),t[44]=h,t[45]=E,t[46]=g,t[47]=_,t[48]=D):D=t[48];let O;t[49]===i.error?O=t[50]:(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[49]=i.error,t[50]=O);let k;t[51]===s?k=t[52]:(k=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:s}),t[51]=s,t[52]=k);let A;return t[53]!==D||t[54]!==O||t[55]!==k?(A=(0,Z.jsxs)(le,{gap:`gap-6`,children:[D,O,k]}),t[53]=D,t[54]=O,t[55]=k,t[56]=A):A=t[56],A}function _t(e){return e.language}var vt={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},yt={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},bt={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},xt={summaryModel:``},St={enabled:!1,memoryNudgeInterval:10,skillNudgeInterval:10,maxToolRounds:8,maxHistoryMessages:80,maxDurationMs:12e4},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{...vt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:vt.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):vt.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:vt.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):vt.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):vt.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:vt.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):vt.retentionWindow}}function kt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...yt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:yt.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):yt.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:yt.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:yt.tailKeepRatio}}function At(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...bt};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:bt.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:bt.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:bt.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{...xt};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function Mt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...St};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:St.enabled,memoryNudgeInterval:typeof t.memoryNudgeInterval==`number`&&t.memoryNudgeInterval>=0?Math.floor(t.memoryNudgeInterval):St.memoryNudgeInterval,skillNudgeInterval:typeof t.skillNudgeInterval==`number`&&t.skillNudgeInterval>=0?Math.floor(t.skillNudgeInterval):St.skillNudgeInterval,maxToolRounds:typeof t.maxToolRounds==`number`&&t.maxToolRounds>=1&&t.maxToolRounds<=32?Math.floor(t.maxToolRounds):St.maxToolRounds,maxHistoryMessages:typeof t.maxHistoryMessages==`number`&&t.maxHistoryMessages>=10&&t.maxHistoryMessages<=200?Math.floor(t.maxHistoryMessages):St.maxHistoryMessages,maxDurationMs:typeof t.maxDurationMs==`number`&&t.maxDurationMs>=3e4&&t.maxDurationMs<=6e5?Math.floor(t.maxDurationMs):St.maxDurationMs}}function Nt(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 Pt(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 Ft(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function It(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 Lt(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 Rt(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function zt(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:Lt(t),imageGenerationModelAutoProviderFallback:Rt(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),backgroundReview:Mt(t.backgroundReview),webExtract:Nt(t.webExtract),delegate:Pt(t.delegate,!1),executeCode:Pt(t.executeCode,!1),systemPromptOverride:typeof t.systemPromptOverride==`string`?t.systemPromptOverride:``,skillsAllowlist:Ft(t.skills),toolsDisable:(()=>{let e=t.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let n=e.disable;return Ft(n)})(),typedModels:de(n),paramsJson:It(t.params)}}function Bt(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 Vt(e){await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:Bt(e)})}),z()}var Ht=W();function Ut(e,t={}){let n=!!s(e=>e.token),[r,i]=(0,Y.useReducer)(Ht,{form:null,baseline:null}),a=r.form,o=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:v,mutate:y}=L(n);G({enabled:n,parsed:(0,Y.useMemo)(()=>g?.payload?.config===void 0?null:zt(g.payload.config),[g]),dirty:m.current,trackedParsedRef:h,dispatch:i,onResetDirty:()=>{m.current=!1}});let b=!!(n&&v&&g===void 0&&!_),x=_ instanceof Error?_.message:_?String(_):null,S=(0,Y.useMemo)(()=>!a||!o?!1:JSON.stringify(a)!==JSON.stringify(o),[a,o]);return{hasToken:n,loading:b,fetchError:x,form:a,update:(0,Y.useCallback)(e=>{m.current=!0,p(!1),i({type:`patch`,patch:e})},[]),dirty:S,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 Vt(a),m.current=!1,i({type:`saved`,value:a}),p(!0),y(),!0}catch(t){return d(t instanceof Error?t.message:e.saveError),!1}finally{l(!1)}},[e.saveError,a,y,c]),discard:(0,Y.useCallback)(()=>{m.current=!1,i({type:`discard`}),p(!1),d(null)},[]),mutate:y}}function Wt(e,t){return e.browserTabs[t]}function Gt(){let e=(0,X.c)(43),t=o(qt),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.agentSettings,s=r.chat,c=v(Kt),l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l={saveScope:`browser`},e[2]=l):l=e[2];let u=Ut(i,l),[d,f]=ne(),p;e[3]===c?p=e[4]:(p=he(Ae,c),e[3]=c,e[4]=p);let m=p,h;e[5]===d?h=e[6]:(h=be(d.get(`focus`)),e[5]=d,e[6]=h);let g=h,_;e[7]!==g||e[8]!==d?(_=g?Me[g]??Ne(d.get(`tab`)):Ne(d.get(`tab`)),e[7]=g,e[8]=d,e[9]=_):_=e[9];let y=_,b;bb0:{if(!u.form){b=null;break bb0}let t;e[10]!==i||e[11]!==s||e[12]!==u.form||e[13]!==u.update?(t={form:u.form,update:u.update,a:i,chat:s},e[10]=i,e[11]=s,e[12]=u.form,e[13]=u.update,e[14]=t):t=e[14],b=t}let x=b,S;e[15]===f?S=e[16]:(S=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]=S);let C=S;me(y,C);let w,T;e[17]!==g||e[18]!==d||e[19]!==f?(w=()=>{if(!g)return;let e=Me[g]??Ne(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`?ye(g):null;if(!t)return;let n=window.setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:`smooth`,block:`start`})},80);return()=>window.clearTimeout(n)},T=[g,d,f],e[17]=g,e[18]=d,e[19]=f,e[20]=w,e[21]=T):(w=e[20],T=e[21]),(0,Y.useEffect)(w,T);let E;if(e[22]!==i||e[23]!==m){let t;e[25]===i?t=e[26]:(t=e=>({id:e,label:Wt(i,e)}),e[25]=i,e[26]=t),E=m.map(t),e[22]=i,e[23]=m,e[24]=E}else E=e[24];let D=E,O;e[27]!==y||e[28]!==i.browserTabsAria||e[29]!==C||e[30]!==D?(O=(0,Z.jsx)(oe,{items:D,activeTab:y,onChange:C,ariaLabel:i.browserTabsAria,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`}),e[27]=y,e[28]=i.browserTabsAria,e[29]=C,e[30]=D,e[31]=O):O=e[31];let k;e[32]!==y||e[33]!==x||e[34]!==C?(k=x?(0,Z.jsx)(pt,{...x,activeTab:y,setActiveTab:C}):null,e[32]=y,e[33]=x,e[34]=C,e[35]=k):k=e[35];let A;e[36]!==y||e[37]!==k?(A=(0,Z.jsx)(ce,{id:y,activeTab:y,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:k}),e[36]=y,e[37]=k,e[38]=A):A=e[38];let j;return e[39]!==O||e[40]!==A||e[41]!==u?(j=(0,Z.jsxs)(gt,{sectionId:`agent-browser`,intro:``,vm:u,tabbed:!0,children:[O,A]}),e[39]=O,e[40]=A,e[41]=u,e[42]=j):j=e[42],j}function Kt(e){return e.mode}function qt(e){return e.language}export{Gt 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-C6Kc4Jhf.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-Cs4ck8zA.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Aa as f,Ba as p,Gi as m,Gs as h,Hi as g,Ji as _,Ki as v,Oa as y,Qn as b,Ss as x,Ui as S,Uo as C,V as w,Vr as T,Wi as E,Xn as D,Ya as O,Yi as k,Zn as A,_c as j,ca as M,qi as ee,sa as N,so as P,vc as F,xa as te,xi as I,yo as L}from"./index-BU1pvxmS.js";import{t as ne}from"./schema-form-CxjxsFfg.js";import{t as R}from"./browser-BLJWD7WI.js";import{n as re,t as ie}from"./settings-page-layout--6qT7ZJa.js";import{t as ae}from"./use-channel-catalog-DyM-ckEQ.js";var z=n(),oe=e(R(),1),B=e(t(),1),V=r();function H(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 U(e){let t=await u(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 se(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ce({entry:e,locale:t,messages:n,onChanged:r,autoStartPrimary:a=!1,compact:o=!1}){let s=(0,B.useMemo)(()=>H(e),[e]),c=(0,B.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[l,u]=(0,B.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,B.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,B.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await U({channelId:e.id,actionId:n,locale:t,input:i});u(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){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,B.useEffect)(()=>{!a||!s||s[1].result!==`qr`||l.payload||l.busy||l.error||d(s[0])},[a,s,d,l.busy,l.error,l.payload]),(0,B.useEffect)(()=>{let t=K(l.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),oe.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,l.payload]),(0,B.useEffect)(()=>{let n=l.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||U({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(u(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||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,l.poll]);let f=s?.[1].label??(e.configured?n.reconnect:n.connect),p=e.actions?.[`doctor.run`]?.label??n.diagnose,m=G(l.payload),g=K(l.payload,e.id),_=g?l.generatedQr:se(l.payload),v=s?.[1].result===`qr`&&(a||l.busy||l.payload?.type===`qr`||l.payload?.type===`poll`),b=l.busy||!!(g&&!_),S=l.payload?.type===`form`?l.payload:null,w=l.payload?.type===`diagnostics`?l.payload.checks:null;return(0,V.jsxs)(`div`,{className:o?`space-y-3`:`rounded-lg border border-edge-subtle bg-surface-panel p-4`,children:[(0,V.jsxs)(`div`,{className:i(`flex flex-wrap items-start gap-3`,o?`justify-end`:`justify-between`),children:[o?null:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s?(0,V.jsxs)(y,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(s[0]),children:[l.busy?(0,V.jsx)(C,{className:`size-4 animate-spin`}):(0,V.jsx)(L,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,V.jsxs)(y,{type:`button`,variant:`secondary`,disabled:l.busy,onClick:()=>void d(`doctor.run`),children:[(0,V.jsx)(O,{className:`size-4`}),p]}):null]})]}),m?(0,V.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,l.error?(0,V.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:l.error}):null,v?(0,V.jsxs)(`div`,{className:i(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg border border-edge-subtle bg-surface-base px-3 py-3`,o?`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,V.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,V.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,V.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base text-fg-muted`,children:(0,V.jsx)(C,{className:i(`size-6`,b&&`animate-spin`)})})}),(0,V.jsxs)(`div`,{className:i(`min-w-0 max-w-sm text-sm text-fg-muted`,o&&`w-full sm:w-auto`),children:[(0,V.jsx)(`p`,{className:`line-clamp-3`,children:_?n.waitingConfirmation:n.loading}),g?(0,V.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,V.jsx)(x,{className:`size-3.5`})]}):null]})]}):null,l.payload?.type===`poll`&&l.payload.phase===`done`?(0,V.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-sm`,children:[(0,V.jsx)(h,{className:l.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,V.jsx)(`span`,{className:l.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:l.payload.message??(l.payload.ok?n.complete:n.failed)})]}):null,S?(0,V.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,V.jsx)(ne,{schema:S.schema,values:l.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:l.busy,labels:c}),(0,V.jsx)(y,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(S.submitAction,l.formDraft),children:n.saveSetup})]}):null,w?(0,V.jsx)(`div`,{className:`mt-4 space-y-2`,children:w.map((e,t)=>(0,V.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base px-3 py-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,V.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,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}function le(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`,N):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)]`,N,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function ue(e){let t=(0,z.c)(30),{presentation:n,open:r,onOpenChange:a,title:o,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:p,wide:h,headerExtra:b}=e,x=h===void 0?!1:h,C=n===`drawer`,w;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,V.jsx)(m,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),t[0]=w):w=t[0];let T;t[1]!==n||t[2]!==x?(T=le(n,x),t[1]=n,t[2]=x,t[3]=T):T=t[3];let D;t[4]===c?D=t[5]:(D=c?(0,V.jsx)(_,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=D);let O;t[6]===l?O=t[7]:(O=l?(0,V.jsx)(E,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=O);let k;t[8]!==u||t[9]!==s||t[10]!==b||t[11]!==C||t[12]!==o?(k=C?(0,V.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[o?(0,V.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:o}):null,s?(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,V.jsx)(g,{asChild:!0,children:(0,V.jsx)(y,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,V.jsx)(f,{className:`size-5`,strokeWidth:1.75})})})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(g,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:i(te,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,V.jsx)(f,{className:`size-4`})})}),b]}),t[8]=u,t[9]=s,t[10]=b,t[11]=C,t[12]=o,t[13]=k):k=t[13];let A=C?`px-4 py-4`:`p-6`,j;t[14]===A?j=t[15]:(j=i(`min-h-0 flex-1 overflow-y-auto`,A),t[14]=A,t[15]=j);let N;t[16]!==d||t[17]!==j?(N=(0,V.jsx)(`div`,{className:j,children:d}),t[16]=d,t[17]=j,t[18]=N):N=t[18];let P;t[19]!==p||t[20]!==T||t[21]!==D||t[22]!==O||t[23]!==k||t[24]!==N?(P=(0,V.jsxs)(v,{children:[w,(0,V.jsxs)(S,{className:T,onOpenAutoFocus:de,children:[D,O,k,N,p]})]}),t[19]=p,t[20]=T,t[21]=D,t[22]=O,t[23]=k,t[24]=N,t[25]=P):P=t[25];let F;return t[26]!==a||t[27]!==r||t[28]!==P?(F=(0,V.jsx)(ee,{open:r,onOpenChange:a,children:P}),t[26]=a,t[27]=r,t[28]=P,t[29]=F):F=t[29],F}function de(e){return e.preventDefault()}var fe=(0,B.memo)(function(e){let t=(0,z.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,V.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,V.jsx)(T,{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,V.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 pe(e){let t=(0,z.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,V.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,V.jsx)(y,{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,V.jsx)(y,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,V.jsx)(y,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let b;return t[21]!==v||t[22]!==u?(b=(0,V.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=b):b=t[23],b}function me(e){return e?c(`/api/channels/${encodeURIComponent(e)}/config`):null}async function he(e){return(await l(c(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var ge=[`enabled`];async function _e(){return(await l(c(`/api/config`))).payload?.config?.channels??{}}function q(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function J(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 ve(e,t){let n=Y(e);return n.state===`needs_setup`?t.hubStatusNeedsSetup:n.state===`error`?t.hubStatusError:n.enabled&&n.ready&&e.runtime===`loaded`?t.hubStatusRunning:n.enabled&&n.ready?t.hubStatusEnabled:n.ready?t.hubStatusConfigured:t.hubStatusNotConfigured}function ye(e){let t=Y(e);return t.state===`needs_setup`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:t.state===`error`?`bg-red-500/10 text-red-700 dark:text-red-300`:t.enabled&&t.ready&&e.runtime===`loaded`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:t.enabled||t.ready?`bg-accent-soft text-accent`:`bg-surface-hover text-fg-muted`}function be(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=>!ge.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!ge.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 xe(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 Q(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Q(n)&&delete t[e];return Object.keys(t).length===0}function Se(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 Q(n),n}function Ce(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function $(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function we(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Te(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 Ee(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(Ae(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Te(e,$(t,e),n);i&&r.push(i)}let a=we(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function De(e,t){let n=Y(e),r=H(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 Oe(e,t){let n=H(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function ke(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 Ae(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 je({entry:e}){let t=s(e=>e.token),[n,r]=(0,B.useState)(!1),i=(0,B.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(c(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${q(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,V.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,V.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,V.jsx)(I,{sourceChannel:e.id,className:`size-7`})})}function Me(e){let t=(0,z.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,V.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,V.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 Ne(e){let t=(0,z.c)(70),{entry:n,config:r,busy:a,ch:o,onOpen:s,onToggle:c}=e,l;t[0]===n?l=t[1]:(l=Y(n),t[0]=n,t[1]=l);let u=l,d,f,p,m,h,g,_;if(t[2]!==a||t[3]!==o||t[4]!==r||t[5]!==n||t[6]!==s||t[7]!==c||t[8]!==u.enabled||t[9]!==u.ready){let e=Ee(n,r,o),l=ke(n,o);d=!u.enabled&&u.ready,g=`flex min-h-[15.5rem] flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-surface transition-colors hover:border-edge`;let v;t[17]===n?v=t[18]:(v=(0,V.jsx)(je,{entry:n}),t[17]=n,t[18]=v);let y;t[19]===n.label?y=t[20]:(y=(0,V.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[19]=n.label,t[20]=y);let b;t[21]===n?b=t[22]:(b=i(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,ye(n)),t[21]=n,t[22]=b);let x;t[23]!==o||t[24]!==n?(x=ve(n,o),t[23]=o,t[24]=n,t[25]=x):x=t[25];let S;t[26]!==b||t[27]!==x?(S=(0,V.jsx)(`span`,{className:b,children:x}),t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;t[29]!==S||t[30]!==y?(C=(0,V.jsxs)(`div`,{className:`min-w-0`,children:[y,S]}),t[29]=S,t[30]=y,t[31]=C):C=t[31];let w;t[32]!==C||t[33]!==v?(w=(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[v,C]}),t[32]=C,t[33]=v,t[34]=w):w=t[34];let T=u.enabled,E;t[35]!==o.toggleChannel||t[36]!==n.label?(E=o.toggleChannel.replace(`{{channel}}`,n.label),t[35]=o.toggleChannel,t[36]=n.label,t[37]=E):E=t[37];let D;t[38]!==a||t[39]!==c||t[40]!==u.enabled||t[41]!==E?(D=(0,V.jsx)(Me,{checked:T,disabled:a,label:E,onToggle:c}),t[38]=a,t[39]=c,t[40]=u.enabled,t[41]=E,t[42]=D):D=t[42],t[43]!==w||t[44]!==D?(_=(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[w,D]}),t[43]=w,t[44]=D,t[45]=_):_=t[45],f=`button`,p=s,m=`mt-5 min-h-[6.25rem] text-left`,h=u.ready?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,V.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(Fe)}):null]}):(0,V.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base px-3 py-3`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.cardSetupTitle}),(0,V.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Oe(n,o)}),l.length>0?(0,V.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:l.map(Pe)}):null]}),t[2]=a,t[3]=o,t[4]=r,t[5]=n,t[6]=s,t[7]=c,t[8]=u.enabled,t[9]=u.ready,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_}else d=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],_=t[16];let v;t[46]!==o.cardAdapterLabel||t[47]!==n.description||t[48]!==u.ready?(v=!u.ready&&n.description?(0,V.jsxs)(`p`,{className:`mt-3 truncate text-xs text-fg-subtle`,title:n.description,children:[o.cardAdapterLabel,`: `,n.description]}):null,t[46]=o.cardAdapterLabel,t[47]=n.description,t[48]=u.ready,t[49]=v):v=t[49];let b;t[50]!==f||t[51]!==p||t[52]!==m||t[53]!==h||t[54]!==v?(b=(0,V.jsxs)(`button`,{type:f,onClick:p,className:m,children:[h,v]}),t[50]=f,t[51]=p,t[52]=m,t[53]=h,t[54]=v,t[55]=b):b=t[55];let x=d?c:s,S;t[56]===a?S=t[57]:(S=a?(0,V.jsx)(C,{className:`size-4 animate-spin`}):null,t[56]=a,t[57]=S);let w;t[58]!==o||t[59]!==n?(w=De(n,o),t[58]=o,t[59]=n,t[60]=w):w=t[60];let T;t[61]!==x||t[62]!==S||t[63]!==w?(T=(0,V.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,V.jsxs)(y,{type:`button`,variant:`primary`,className:`w-full rounded-2xl py-2.5`,onClick:x,children:[S,w]})}),t[61]=x,t[62]=S,t[63]=w,t[64]=T):T=t[64];let E;return t[65]!==T||t[66]!==g||t[67]!==_||t[68]!==b?(E=(0,V.jsxs)(`article`,{className:g,children:[_,b,T]}),t[65]=T,t[66]=g,t[67]=_,t[68]=b,t[69]=E):E=t[69],E}function Pe(e){return(0,V.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function Fe(e){return(0,V.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function Ie(e){let t=(0,z.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,V.jsx)(p,{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,V.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let m=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===m?c=t[15]:(c=(0,V.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:m}),t[14]=m,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let h;t[16]===r?h=t[17]:(h=e=>(0,V.jsx)(`li`,{children:Ae(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=h),a=e.issues.map(h)}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 m;t[18]!==i||t[19]!==a?(m=(0,V.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=m):m=t[20];let h;t[21]!==m||t[22]!==o||t[23]!==s||t[24]!==c?(h=(0,V.jsxs)(`div`,{className:o,children:[s,c,m]}),t[21]=m,t[22]=o,t[23]=s,t[24]=c,t[25]=h):h=t[25];let g;t[26]!==h||t[27]!==l||t[28]!==u?(g=(0,V.jsxs)(`div`,{className:l,children:[u,h]}),t[26]=h,t[27]=l,t[28]=u,t[29]=g):g=t[29];let _;return t[30]!==g||t[31]!==d?(_=(0,V.jsx)(`section`,{className:d,children:g}),t[30]=g,t[31]=d,t[32]=_):_=t[32],_}function Le(){let e=o(e=>e.language),t=a(e),n=s(e=>!!e.token),r=j(),{channelId:l}=F(),f=b(l),p=ae(n,e),m=p.entries,{data:h={},mutate:g}=d(n?`channels-config-map`:null,_e,{revalidateOnFocus:!1}),_=k(e=>e.setPageHeader),v=k(e=>e.clearPageHeader),y=(0,B.useMemo)(()=>m.find(e=>e.id===f),[f,m]),S=y?J(y):null,{data:C,mutate:T}=d(n&&S?me(S):null,()=>he(S)),[E,O]=(0,B.useState)(null),[M,ee]=(0,B.useState)(!1),[N,te]=(0,B.useState)(null),[I,L]=(0,B.useState)(null),R=E??C??{},z=t.channelsSettings,oe=(0,B.useMemo)(()=>y?.configSchema??{type:`object`,properties:{}},[y?.configSchema]),U=(0,B.useMemo)(()=>Se(oe,ge),[oe]),W=(0,B.useMemo)(()=>be(y),[y]),G=(0,B.useMemo)(()=>xe(U,W),[W,U]),K=(0,B.useMemo)(()=>Se(U,W),[W,U]),se=(0,B.useMemo)(()=>Ce(G),[G]),le=(0,B.useMemo)(()=>({defaultBooleanLabel:z.schemaBooleanDefault,unsupportedArrayType:z.schemaUnsupportedArrayType,arrayAddPlaceholder:z.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>z.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[z]),de=(0,B.useMemo)(()=>n?(0,V.jsx)(fe,{ch:z,refreshing:p.isValidating,saveOk:!1,onRefresh:()=>void p.mutate()}):null,[p,z,n]);(0,B.useLayoutEffect)(()=>(_({startExtra:null,main:(0,V.jsx)(`div`,{className:`min-w-0`,children:(0,V.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:de}),()=>v()),[v,de,t.settingsSections.channels,_]);let q=(0,B.useCallback)(e=>{r(A(e)),O(null),L(null)},[r]),X=(0,B.useCallback)(()=>{r(D),O(null),L(null)},[r]),Z=(0,B.useCallback)(async()=>{if(!y||!E)return!1;let e=J(y);ee(!0),L(null);try{let t=await u(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[e]:E}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return await T(E,!1),await g(),await p.mutate(),O(null),!0}catch(e){return L(e instanceof Error?e.message:String(e)),!1}finally{ee(!1)}},[y,p,E,g,T]),Q=(0,B.useCallback)(async e=>{let t=Y(e),n=J(e),r=y?.id===e.id?E:null;if(!t.enabled&&!t.ready&&!r){q(e.id);return}te(e.id),L(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await u(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 p.mutate(),await g(),y?.id===e.id&&(await T(),O(null))}catch(e){L(e instanceof Error?e.message:String(e))}finally{te(null)}},[y?.id,p,E,g,T,q]),$=y?.ui?.modal,we=$?.placement!==`replace-config`;return n?(0,V.jsxs)(ie,{gap:`gap-4`,children:[p.isLoading?(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:z.loadingChannels}):p.error?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(p.error)}):(0,V.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:m.map(e=>(0,V.jsx)(Ne,{entry:e,config:h[J(e)]?.config,busy:N===e.id,ch:z,onOpen:()=>q(e.id),onToggle:()=>void Q(e)},e.id))}),I?(0,V.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:I}):null,(0,V.jsx)(ue,{presentation:`modal`,open:!!y,onOpenChange:e=>{e||X()},closeAriaLabel:z.close,srTitle:y?.label??z.selectChannel,srDescription:y?.description,wide:!0,footer:y?(0,V.jsx)(pe,{ch:z,dirty:!!E,saving:M,onCancel:X,onDiscard:()=>O(null),onSave:Z}):null,children:y?(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,V.jsx)(je,{entry:y}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,V.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:y.label}),(0,V.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,ye(y)),children:ve(y,z)})]}),(0,V.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,V.jsx)(`span`,{className:`min-w-0 truncate`,children:H(y)?.[1].result===`qr`?z.scanLoginHint.replace(`{{channel}}`,y.label):y.description}),y.docsPath?(0,V.jsxs)(`a`,{href:y.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[z.docs,(0,V.jsx)(x,{className:`size-3.5`})]}):null]})]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,V.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:z.enabledLabel}),(0,V.jsx)(Me,{checked:Y(y).enabled,disabled:N===y.id,label:z.toggleChannel.replace(`{{channel}}`,y.label),onToggle:()=>void Q(y)})]})]})}),(0,V.jsx)(Ie,{entry:y,ch:z}),$?.entrypoint&&$.placement===`before-config`?(0,V.jsx)(w,{extensionId:y.extensionId,extensionName:y.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:y.id,entry:y,config:R}}):null,$?.placement===`replace-config`?null:(0,V.jsx)(ce,{entry:y,locale:e,messages:z,autoStartPrimary:!0,compact:!0,onChanged:async()=>{await T(),await p.mutate(),await g()}},y.id),$?.entrypoint&&$.placement!==`before-config`?(0,V.jsx)(w,{extensionId:y.extensionId,extensionName:y.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:y.id,entry:y,config:R}}):null,we&&se?(0,V.jsxs)(`section`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:z.basicConfiguration}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:z.basicConfigurationHint})]}),(0,V.jsx)(ne,{schema:G,values:R,onChange:e=>O(e),disabled:M,labels:le})]}):null,we&&Ce(K)?(0,V.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,V.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,V.jsx)(P,{className:`size-4 text-fg-muted`}),z.advancedConfiguration]}),(0,V.jsx)(`div`,{className:`border-t border-edge-subtle p-4`,children:(0,V.jsx)(ne,{schema:K,values:R,onChange:e=>O(e),disabled:M,labels:le})})]}):null,I?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:I}):null]}):null})]}):(0,V.jsxs)(ie,{gap:`gap-3`,padding:`px-4 py-8`,children:[(0,V.jsx)(re,{title:t.settingsSections.channels}),(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:z.tokenRequired})]})}export{Le as ChannelsSettingsPanel};
@@ -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-C6Kc4Jhf.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-Cs4ck8zA.js";import{r as u}from"./toast-z0toXu32.js";import{Aa as d,Co as f,Da as p,Es as m,Gi as h,Gs as g,Hi as _,Is as v,Ji as y,Ki as b,Mo as x,Oa as S,Oo as C,Sa as w,So as T,To as E,Ui as D,Uo as O,Va as k,Vr as A,Wi as j,Xs as M,Yi as N,_a as P,ca as ee,gi as F,hi as I,hs as te,ia as L,io as ne,ja as R,oa as z,qi as B,sa as re,ts as ie,uo as ae,vs as oe,ya as V,yc as se}from"./index-BU1pvxmS.js";import{n as ce,t as le}from"./settings-form-section-CIxIEYxU.js";import{i as ue,n as de,o as fe,r as pe,t as me}from"./dist-wO9a2_ID.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`,he=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function ge(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 _e(){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 border border-edge-subtle bg-surface-base p-4 dark:border-edge-subtle`,"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 ve(){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 border border-edge 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 ye(e){let t=(0,U.c)(52),{connector:n,installed:r,onInstall:a,t:o}=e,s;t[0]!==n.category||t[1]!==o?(s=q(n.category,o),t[0]=n.category,t[1]=o,t[2]=s):s=t[2];let c=s,l,u,d,f,p,m;if(t[3]!==c||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o.install||t[8]!==o.installedBadge){let e=n.capabilities.slice(0,4),s=Math.max(0,n.capabilities.length-e.length),h;t[15]!==n||t[16]!==a||t[17]!==o.install?(h=e=>(0,W.jsxs)(S,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>a(n),children:[(0,W.jsx)(x,{className:`size-4`}),o.install]}),t[15]=n,t[16]=a,t[17]=o.install,t[18]=h):h=t[18],l=h,m=`group flex min-h-[9.5rem] flex-col rounded-lg border border-edge bg-surface-panel p-4 shadow-surface transition-colors hover:border-accent/50 focus-within:border-accent/50`,u=`flex min-w-0 flex-1 flex-col`;let _;t[19]===n.displayName?_=t[20]:(_=(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[19]=n.displayName,t[20]=_);let v;t[21]===c?v=t[22]:(v=(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:c}),t[21]=c,t[22]=v);let y;t[23]!==_||t[24]!==v?(y=(0,W.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[_,v]})}),t[23]=_,t[24]=v,t[25]=y):y=t[25];let b;t[26]!==r||t[27]!==l?(b=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:l()}),t[26]=r,t[27]=l,t[28]=b):b=t[28];let C;t[29]!==r||t[30]!==o.installedBadge?(C=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)(g,{className:`size-3`,"aria-hidden":!0}),o.installedBadge]}):null,t[29]=r,t[30]=o.installedBadge,t[31]=C):C=t[31];let w;t[32]!==b||t[33]!==C?(w=(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[b,C]}),t[32]=b,t[33]=C,t[34]=w):w=t[34],t[35]!==y||t[36]!==w?(d=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[y,w]}),t[35]=y,t[36]=w,t[37]=d):d=t[37],t[38]===n.description?f=t[39]:(f=(0,W.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[38]=n.description,t[39]=f),p=e.length>0?(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(be),s>0?(0,W.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,s]}):null]}):null,t[3]=c,t[4]=n,t[5]=r,t[6]=a,t[7]=o.install,t[8]=o.installedBadge,t[9]=l,t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m}else l=t[9],u=t[10],d=t[11],f=t[12],p=t[13],m=t[14];let h;t[40]!==u||t[41]!==d||t[42]!==f||t[43]!==p?(h=(0,W.jsxs)(`div`,{className:u,children:[d,f,p]}),t[40]=u,t[41]=d,t[42]=f,t[43]=p,t[44]=h):h=t[44];let _;t[45]!==r||t[46]!==l?(_=r?null:(0,W.jsx)(`div`,{className:`mt-4 flex items-center justify-end border-t border-edge pt-3 sm:hidden`,children:l(`w-full`)}),t[45]=r,t[46]=l,t[47]=_):_=t[47];let v;return t[48]!==m||t[49]!==h||t[50]!==_?(v=(0,W.jsxs)(`div`,{className:m,children:[h,_]}),t[48]=m,t[49]=h,t[50]=_,t[51]=v):v=t[51],v}function be(e){return(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}var xe=(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)(A,{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)(ae,{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-base 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)(T,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=m):m=t[11];let h;t[12]!==c||t[13]!==o?(h=(0,W.jsxs)(S,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[m,c]}),t[12]=c,t[13]=o,t[14]=h):h=t[14];let g;return t[15]!==u||t[16]!==p||t[17]!==h?(g=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,p,h]}),t[15]=u,t[16]=p,t[17]=h,t[18]=g):g=t[18],g}),Se=/^([^:=]+)[:=](.*)$/;function J(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=Se.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function Y(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 Ce(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 we(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 Te(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)||we(t)&&(r[e]=t);return r}function Ee(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function De(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 Oe(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=Ee(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=De(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=Y(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function ke(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:Ce(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function Ae(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function je(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)||we(t)?[]:[ke(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 Me(e){return Oe(e)}async function Ne(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]=Oe(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 l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),I()}function Pe(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 Fe(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 Ie(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 Le(e,t){let n=await l(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=Pe(n.payload.tools),i=Fe(n.payload.resources),a=Ie(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 Re(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function ze(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 Be(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 X(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function Ve({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=Be(e),m=(0,H.useCallback)(async()=>{o(!0),f(null);try{let t=await Le(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:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,W.jsx)(`span`,{className:`rounded-full border border-edge 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-1 truncate font-mono text-xs text-fg-subtle`,title:p,children:p}):null]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(S,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(E,{className:`size-4`}),t.testConnection]}),(0,W.jsxs)(S,{variant:`secondary`,onClick:r,children:[(0,W.jsx)(C,{className:`size-4`}),n.editCustomServer]}),(0,W.jsxs)(S,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(k,{className:`size-4`}),t.removeServer]})]})]}),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:X(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]})}function Z(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function He(){return Z(await l(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Ue(){return Z(await l(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function We(){return Z(await l(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var Ge=new Map,Ke=300*1e3;async function qe(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),s=Math.max(n?.pageSize??24,1),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${s}`,d=Date.now(),f=Ge.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(s));let m=l(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Z(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}});Ge.set(u,{expiresAt:d+Ke,promise:m});try{return await m}catch(e){throw Ge.delete(u),e}}async function Je(e){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Ye(e,t){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Xe(e,t){let n=await l(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return I(),Z(n,`Could not install connector.`).instance}async function Ze(e){await l(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),I()}async function Qe(e){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function $e(){return Z(await l(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function et(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function tt(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function nt(e,t){let n=await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return I(),Z(n,`Could not update Composio scope.`).scope}async function rt(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function it(e=50){return Z(await l(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function at(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function ot(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||at(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
- `).toLowerCase().includes(r)}function st(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function ct(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=>ot(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,m;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,W.jsx)(ae,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=m):m=t[9];let h,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=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`,p),g=e=>c(e.target.value),t[10]=h,t[11]=g):(h=t[10],g=t[11]);let _;t[12]!==s||t[13]!==a?(_=(0,W.jsxs)(`div`,{className:`relative`,children:[m,(0,W.jsx)(`input`,{type:`search`,value:s,placeholder:a,"aria-label":a,className:h,onChange:g})]}),t[12]=s,t[13]=a,t[14]=_):_=t[14];let v;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(v=f?(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=v):v=t[18];let y;t[19]!==_||t[20]!==v?(y=(0,W.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[_,v]}),t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;t[22]!==u||t[23]!==o||t[24]!==r?(b=(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||st(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,W.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=o,t[24]=r,t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==b?(x=(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[y,b]}),t[26]=y,t[27]=b,t[28]=x):x=t[28],x}function lt(e){let t=(0,U.c)(38),{open:n,onOpenChange:r,serverId:a,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:f,tools:p,stripPrefix:m}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,W.jsx)(h,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),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`,re,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=v):v=t[1];let x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,W.jsx)(R,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=x):x=t[2];let C;t[3]===o?C=t[4]:(C=(0,W.jsxs)(y,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[x,o]}),t[3]=o,t[4]=C);let w;t[5]!==a||t[6]!==s||t[7]!==p.length?(w=s.replace(`{{serverId}}`,a).replace(`{{count}}`,String(p.length)),t[5]=a,t[6]=s,t[7]=p.length,t[8]=w):w=t[8];let T;t[9]===w?T=t[10]:(T=(0,W.jsx)(j,{className:`mt-1 text-sm text-fg-muted`,children:w}),t[9]=w,t[10]=T);let E;t[11]!==C||t[12]!==T?(E=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[C,T]}),t[11]=C,t[12]=T,t[13]=E):E=t[13];let O;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,W.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[14]=O):O=t[14];let k;t[15]===f?k=t[16]:(k=(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(S,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":f,children:O})}),t[15]=f,t[16]=k);let A;t[17]!==E||t[18]!==k?(A=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[E,k]}),t[17]=E,t[18]=k,t[19]=A):A=t[19];let M;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==a||t[25]!==m||t[26]!==p?(M=p.length>0?(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,W.jsx)(ct,{tools:p,stripPrefix:m,searchPlaceholder:c,searchEmptyLabel:l},`${a}-${n?`open`:`closed`}`)}):(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=a,t[25]=m,t[26]=p,t[27]=M):M=t[27];let N;t[28]===f?N=t[29]:(N=(0,W.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(S,{type:`button`,variant:`secondary`,children:f})})}),t[28]=f,t[29]=N);let P;t[30]!==A||t[31]!==M||t[32]!==N?(P=(0,W.jsxs)(b,{children:[g,(0,W.jsxs)(D,{className:v,children:[A,M,N]})]}),t[30]=A,t[31]=M,t[32]=N,t[33]=P):P=t[33];let F;return t[34]!==r||t[35]!==n||t[36]!==P?(F=(0,W.jsx)(B,{open:n,onOpenChange:r,children:P}),t[34]=r,t[35]=n,t[36]=P,t[37]=F):F=t[37],F}var ut=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,p);function dt(e){return e.materialized.type===`composio`?e.connectorId.replace(/^composio-/,``):null}function ft(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function pt({instance:e,t}){let n=dt(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([$e().catch(()=>[]),rt(n).catch(()=>[]),it(20).catch(()=>[]),tt(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 _=(0,H.useCallback)(async()=>{if(n){p(!0),h(null);try{let e=await et(n);window.open(e.connectUrl,`_blank`,`noopener,noreferrer`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]),v=(0,H.useCallback)(async e=>{if(n){d(e);try{await nt(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:X(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)(L,{className:i(ut,`h-9 w-28 py-1`),value:u,onChange:e=>void v(e.currentTarget.value),children:[(0,W.jsx)(z,{value:`read`,children:t.composioScopeRead}),(0,W.jsx)(z,{value:`write`,children:t.composioScopeWrite}),(0,W.jsx)(z,{value:`admin`,children:t.composioScopeAdmin})]}),(0,W.jsxs)(S,{variant:`secondary`,disabled:f,onClick:()=>void _(),children:[f?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(ie,{className:`size-4`}),t.connectOAuth]}),(0,W.jsx)(S,{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:[ft(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}function mt(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function ht({instance:e,onChanged:t,t:n,mcp:r}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(`health`),[p,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(null),v=(0,H.useCallback)(async()=>{o(!0),_(null);try{let n=await Qe(e.instanceId);u(n),n.toolCount>0&&f(`tools`),await t()}catch(e){_(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.instanceId,t]),y=(0,H.useCallback)(async()=>{c(!0),_(null);try{await Ze(e.instanceId),await t()}catch(e){_(e instanceof Error?e.message:String(e)),c(!1)}},[e.instanceId,t]),b=l?l.toolCount:e.usage.lastToolCount;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.displayName}),(0,W.jsx)(`span`,{className:`rounded-full border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.catalogBadge})]}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.materialized.type===`mcp`?X(n.mcpServerRuntime,{serverId:e.materialized.serverId}):X(n.runtimeLabel,{runtime:e.materialized.type})})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[e.materialized.type===`mcp`?(0,W.jsxs)(S,{variant:`secondary`,disabled:a,onClick:()=>void v(),children:[a?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(E,{className:`size-4`}),n.test]}):null,(0,W.jsxs)(S,{variant:`ghost`,disabled:s,onClick:()=>void y(),children:[s?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(k,{className:`size-4`}),n.remove]})]})]}),g?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:g}):null,(0,W.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[[`health`,ne,n.detailHealth],[`tools`,R,`${n.detailTools} ${l?l.toolCount:e.usage.lastToolCount??``}`],[`resources`,m,`${n.detailResources} ${l?l.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,oe,`${n.detailPrompts} ${l?l.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,ie,n.detailPermissions]].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`,d===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>f(e),children:[(0,W.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,W.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[d===`health`?(0,W.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,W.jsxs)(`p`,{children:[n.statusLabel,` `,(0,W.jsx)(`span`,{className:l?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:mt(l?.status??e.usage.lastHealthStatus,n)})]}),(0,W.jsxs)(`p`,{children:[n.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():n.never]}),l?.action?(0,W.jsx)(`p`,{children:l.action}):null]}):null,d===`tools`?l?.tools.length?(0,W.jsxs)(`div`,{className:`grid gap-2`,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:X(n.toolsAvailable,{count:String(l.tools.length)})}),(0,W.jsx)(S,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>h(!0),children:r.viewAllTools})]}),l.tools.slice(0,8).map(e=>(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.shortName??e.name}),e.description?(0,W.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.description}):null]},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?X(n.toolsLastCheckSummary,{count:String(b)}):n.toolsRunTestHint}),(0,W.jsxs)(S,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void v(),children:[a?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(E,{className:`size-4`}),n.test]})]}):null,d===`resources`?l?.resources.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:l.resources.slice(0,8).map(e=>(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.title??e.name}),(0,W.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.uri})]},e.uri))}):(0,W.jsx)(`p`,{className:`text-fg-muted`,children:n.resourcesRunTestHint}):null,d===`prompts`?l?.prompts.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:l.prompts.slice(0,8).map(e=>(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.title??e.name}),e.description?(0,W.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.description}):null]},e.name))}):(0,W.jsx)(`p`,{className:`text-fg-muted`,children:n.promptsRunTestHint}):null,d===`permissions`?(0,W.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,W.jsx)(`p`,{children:X(n.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,W.jsx)(`p`,{children:e.materialized.type===`mcp`?X(n.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):X(n.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,W.jsx)(`p`,{children:e.materialized.type===`mcp`?n.mcpPolicyHint:n.connectorPolicyHint})]}):null]}),e.materialized.type===`composio`?(0,W.jsx)(pt,{instance:e,t:n}):null]}),e.materialized.type===`mcp`?(0,W.jsx)(lt,{open:p,onOpenChange:h,serverId:e.materialized.serverId,title:X(n.installedToolsDialogTitle,{name:e.displayName}),subtitle:n.installedToolsDialogSubtitle,searchPlaceholder:r.toolsDialogSearchPlaceholder,searchEmptyLabel:r.toolsDialogSearchEmpty,emptyLabel:n.toolsRunTestHint,closeLabel:r.toolsDialogClose,tools:l?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var gt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,p),_t=i(gt,`min-h-28 font-mono`);function vt(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function yt(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 bt(e){let t={};for(let n of e.setup.secrets??[])t[n.key]=``;let n={};for(let t of e.setup.config??[])n[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:t,config:n,installing:!1,error:null,result:null,health:null,oauth:{flow:null,connected:e.auth.mode!==`oauth`}}}function xt({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 Je(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 Ye(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=yt(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let i=await Xe(o.id,{secrets:e.secrets,config:n,definition:o.source===`registry`?o:void 0}),s=null;try{s=await Qe(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)(B,{open:!0,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(b,{children:[(0,W.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(D,{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)(y,{className:`text-base font-semibold text-fg`,children:X(a.installDialogTitle,{name:o.displayName})}),(0,W.jsx)(j,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o.description})]}),(0,W.jsx)(_,{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`,w.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(d,{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:X(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)(S,{variant:`secondary`,disabled:e.installing,onClick:()=>void l(),children:[e.installing&&!e.oauth.flow?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(E,{className:`size-4`}),a.oauthConnectButton]}),(0,W.jsxs)(S,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void u(),children:[e.installing&&e.oauth.flow?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),a.oauthAuthorizedButton]})]})]}):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)(P,{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:_t,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:gt,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)(O,{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:X(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:X(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:vt(e.health?.status,a)})]}),e.health?(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.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)(S,{variant:`primary`,disabled:!!e.result||e.installing||o.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void f(),children:[e.installing?(0,W.jsx)(O,{className:`size-4 animate-spin`}):e.result?(0,W.jsx)(g,{className:`size-4`}):(0,W.jsx)(x,{className:`size-4`}),e.result?a.installedBadge:a.install]})})]})]})})}function St(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 Ae(r)}function Ct(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 wt(e,t,n){return e.filter(e=>Ct(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Tt(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 Et(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 Dt(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 Ot(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,p)}function kt({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 V();if(!e){window.alert(o);return}let t=J(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)(S,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void m(),children:[(0,W.jsx)(v,{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(Ot(),`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(Ot(),`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)(S,{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)(k,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Dt(e,t,l)))}),(0,W.jsxs)(`button`,{type:`button`,className:i(`self-start text-sm text-accent hover:underline`,w.press),onClick:f,children:[`+ `,n]})]})}var At=[`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`,p)}function jt(e){let t=(0,U.c)(67),{row:n,t:r,onUpdate:a,idConflictMessage:o}=e,s=r.transportLabel,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=$(),t[0]=c):c=t[0];let l=n.transport,u;t[1]===a?u=t[2]:(u=e=>a({transport:e.target.value}),t[1]=a,t[2]=u);let d;t[3]===r.transportLabels?d=t[4]:(d=At.map(e=>(0,W.jsx)(z,{value:e,children:r.transportLabels[e]},e)),t[3]=r.transportLabels,t[4]=d);let f;t[5]!==n.transport||t[6]!==u||t[7]!==d?(f=(0,W.jsx)(L,{className:c,value:l,onChange:u,children:d}),t[5]=n.transport,t[6]=u,t[7]=d,t[8]=f):f=t[8];let p;t[9]!==r.transportLabel||t[10]!==f?(p=(0,W.jsx)(Q,{label:s,required:!0,children:f}),t[9]=r.transportLabel,t[10]=f,t[11]=p):p=t[11];let m=r.serverIdLabel,h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=$(),t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=e=>a({id:e.target.value}),t[13]=a,t[14]=g);let _;t[15]!==n.id||t[16]!==r.serverIdPlaceholder||t[17]!==g?(_=(0,W.jsx)(`input`,{className:h,value:n.id,placeholder:r.serverIdPlaceholder,onChange:g}),t[15]=n.id,t[16]=r.serverIdPlaceholder,t[17]=g,t[18]=_):_=t[18];let v;t[19]===o?v=t[20]:(v=o?(0,W.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:o}):null,t[19]=o,t[20]=v);let y;t[21]!==r.serverIdLabel||t[22]!==_||t[23]!==v?(y=(0,W.jsxs)(Q,{label:m,required:!0,children:[_,v]}),t[21]=r.serverIdLabel,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==a||t[26]!==n.argsText||t[27]!==n.command||t[28]!==n.cwd||t[29]!==n.envJson||t[30]!==n.headers||t[31]!==n.transport||t[32]!==n.url||t[33]!==r.addHeader||t[34]!==r.argsHint||t[35]!==r.argsLabel||t[36]!==r.commandLabel||t[37]!==r.cwdLabel||t[38]!==r.envHint||t[39]!==r.envLabel||t[40]!==r.headerKeyPlaceholder||t[41]!==r.headerValuePlaceholder||t[42]!==r.headersLabel||t[43]!==r.optionalSuffix||t[44]!==r.pasteHeaders||t[45]!==r.pasteHeadersFailed||t[46]!==r.removeHeader||t[47]!==r.urlLabel?(b=n.transport===`stdio`?(0,W.jsxs)(W.Fragment,{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})})}),(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})})})]}):(0,W.jsxs)(W.Fragment,{children:[(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})})})}),(0,W.jsx)(kt,{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})})]}),t[25]=a,t[26]=n.argsText,t[27]=n.command,t[28]=n.cwd,t[29]=n.envJson,t[30]=n.headers,t[31]=n.transport,t[32]=n.url,t[33]=r.addHeader,t[34]=r.argsHint,t[35]=r.argsLabel,t[36]=r.commandLabel,t[37]=r.cwdLabel,t[38]=r.envHint,t[39]=r.envLabel,t[40]=r.headerKeyPlaceholder,t[41]=r.headerValuePlaceholder,t[42]=r.headersLabel,t[43]=r.optionalSuffix,t[44]=r.pasteHeaders,t[45]=r.pasteHeadersFailed,t[46]=r.removeHeader,t[47]=r.urlLabel,t[48]=b):b=t[48];let x=r.timeoutLabel,S=r.timeoutHint,C;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(C=$(),t[49]=C):C=t[49];let w;t[50]===n?w=t[51]:(w=Re(n),t[50]=n,t[51]=w);let T;t[52]===a?T=t[53]:(T=e=>a({connectionTimeoutMs:ze(e.target.value)}),t[52]=a,t[53]=T);let E;t[54]!==r.timeoutPlaceholder||t[55]!==w||t[56]!==T?(E=(0,W.jsx)(`input`,{type:`number`,min:1,max:600,className:C,value:w,placeholder:r.timeoutPlaceholder,onChange:T}),t[54]=r.timeoutPlaceholder,t[55]=w,t[56]=T,t[57]=E):E=t[57];let D;t[58]!==r.timeoutHint||t[59]!==r.timeoutLabel||t[60]!==E?(D=(0,W.jsx)(Q,{label:x,description:S,children:E}),t[58]=r.timeoutHint,t[59]=r.timeoutLabel,t[60]=E,t[61]=D):D=t[61];let O;return t[62]!==y||t[63]!==b||t[64]!==D||t[65]!==p?(O=(0,W.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[p,y,b,D]}),t[62]=y,t[63]=b,t[64]=D,t[65]=p,t[66]=O):O=t[66],O}function Mt({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:a,config:o,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:f}){let[p,m]=(0,H.useState)(n),[v,x]=(0,H.useState)(!1),[C,T]=(0,H.useState)(!1),[k,A]=(0,H.useState)(null),[M,N]=(0,H.useState)({status:`idle`}),[P,ee]=(0,H.useState)(null),F=n.id.trim(),I=p.id.trim()!==F&&s.has(p.id.trim())||s.has(p.id.trim())&&t===`add`?c.reservedServerId:void 0,te=p.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===p.id.trim())?l.duplicateServerId:void 0,L=p.id.trim().length>0&&!I&&!te&&(p.transport===`stdio`?p.command.trim().length>0:p.url.trim().length>0),ne=(0,H.useCallback)(async()=>{if(p.id.trim()){T(!0),A(null),N({status:`loading`});try{N({status:`ok`,tools:(await Le(p.id.trim(),Me(p))).tools})}catch(e){N({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{T(!1)}}},[p]),z=(0,H.useCallback)(async()=>{if(!(!L||v)){x(!0),A(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(p),await Ne({sessionIdleTtlMinutes:a,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Te(o)),await f(),u()}catch(e){A(e instanceof Error?e.message:String(e))}finally{x(!1)}}},[L,o,r,n.clientKey,t,u,f,F,p,v,a]);return e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(B,{open:e,onOpenChange:e=>{e||u()},children:(0,W.jsxs)(b,{children:[(0,W.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(D,{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)(y,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,W.jsx)(j,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,W.jsx)(_,{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`,w.focusRingPanel),"aria-label":l.modalClose,children:[(0,W.jsx)(d,{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-4`,children:[(0,W.jsx)(jt,{row:p,t:c,onUpdate:e=>{m(t=>({...t,...e})),A(null)},idConflictMessage:I??te}),M.status===`ok`?(0,W.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base px-3 py-2.5`,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)(R,{className:`size-4 text-accent`,"aria-hidden":!0}),M.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(M.tools.length))]}),M.tools.length>0?(0,W.jsx)(S,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>ee(M.tools),children:c.viewAllTools}):null]})}):null,M.status===`error`?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:M.message}):null,k?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:k}):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)(S,{variant:`secondary`,disabled:!p.id.trim()||C,onClick:()=>void ne(),children:[C?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(E,{className:`size-4`}),c.testConnection]}),(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(S,{variant:`secondary`,children:l.modalCancel})}),(0,W.jsxs)(S,{variant:`primary`,disabled:!L||v,onClick:()=>void z(),children:[v?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),v?c.saving:l.modalSave]})]})]})]})}),P?(0,W.jsx)(lt,{open:!0,onOpenChange:e=>{e||ee(null)},serverId:p.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:P,stripPrefix:`${p.id.trim()}__`}):null]}):null}var Nt=`mprov`,Pt=`smithery`,Ft=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,p);function It(){let e=a(o(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=s(e=>e.token),c=!!r,[l,d]=se(),p=l.get(Nt)?.trim()||Pt,[m,h]=(0,H.useState)(`marketplace`),[g,_]=(0,H.useState)({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!0,error:null}),[v,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)(1),[C,T]=(0,H.useState)(void 0),[E,D]=(0,H.useState)(``),[k,A]=(0,H.useState)(p),[j,P]=(0,H.useState)(`name`),[ee,I]=(0,H.useState)(null),[L,ne]=(0,H.useState)(null),[R,z]=(0,H.useState)(void 0),[B,re]=(0,H.useState)(!1),[ie,ae]=(0,H.useState)(!1),{data:oe,mutate:V}=F(c),U=oe?.payload?.config,G=(0,H.useMemo)(()=>U===void 0?null:je(U),[U]),K=G?.servers??[];(0,H.useEffect)(()=>{G&&z(G.sessionIdleTtlMinutes)},[G]);let q=(0,H.useCallback)(async()=>{if(!r){_({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:null});return}_(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([He(),We(),Ue()]);_(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,registries:n,loading:!1,error:null}))}catch(e){_({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,H.useEffect)(()=>{q()},[q]);let be=l.toString(),Se=(0,H.useRef)(be);(0,H.useEffect)(()=>{Se.current!==be&&(Se.current=be,A(l.get(Nt)?.trim()||Pt))},[l,be]);let J=(0,H.useMemo)(()=>g.registries.map(e=>e.id),[g.registries]);(0,H.useEffect)(()=>{if(J.length===0||J.includes(k))return;let e=J.includes(Pt)?Pt:J[0];e&&A(e)},[k,J]),(0,H.useEffect)(()=>{if(!k||k===l.get(Nt))return;let e=new URLSearchParams(l);e.set(Nt,k),Se.current=e.toString(),d(e,{replace:!0})},[k,l,d]);let Y=(0,H.useCallback)(async e=>{let t=E.trim(),n=e?.browse??!1,r=Math.max(e?.page??1,1),i=e?.append??!1;if(!(!c||!t&&!n)){y(!0),i?_(e=>({...e,error:null})):(x(1),T(void 0),_(e=>({...e,registryCatalog:[],error:null})));try{let e=await qe(t,k,{browse:n,page:r});x(r),T(e.totalPages),_(t=>({...t,registryCatalog:i?[...t.registryCatalog,...e.connectors].filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t):e.connectors}))}catch(e){_(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{y(!1)}}},[c,E,k]);(0,H.useEffect)(()=>{if(m!==`marketplace`)return;let e=window.setTimeout(()=>{E.trim()?Y():k&&Y({browse:!0})},E.trim()?350:0);return()=>window.clearTimeout(e)},[k,E,Y,g.loading,m]);let Ce=(0,H.useMemo)(()=>new Set(g.instances.map(e=>e.connectorId)),[g.instances]),we=(0,H.useMemo)(()=>new Set(g.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[g.instances]),Ee=(0,H.useCallback)(async e=>{if(!G||U===void 0)return;let t=K.filter(t=>t.clientKey!==e.clientKey);await Ne({sessionIdleTtlMinutes:G.sessionIdleTtlMinutes,servers:t},Te(U)),await V(),await q()},[U,K,q,G,V]),De=(0,H.useCallback)(()=>{ne({mode:`add`,row:St(K,we)})},[K,we]),Oe=(0,H.useCallback)(async()=>{if(!(!G||U===void 0||B)){re(!0),ae(!1);try{await Ne({sessionIdleTtlMinutes:R,servers:K},Te(U)),await V(),ae(!0),u({type:`success`,title:n.saved})}finally{re(!1)}}},[U,K,G,V,R,B]),ke=N(e=>e.setPageHeader),Ae=N(e=>e.clearPageHeader),Me=(0,H.useMemo)(()=>(0,W.jsx)(xe,{loading:g.loading||v,searchQuery:E,setSearchQuery:D,onReloadClick:q,onAddCustomServer:De,searchPlaceholder:m===`marketplace`?t.marketplaceSearchPlaceholder:m===`builtin`?t.builtinSearchPlaceholder:m===`user`?t.userSearchPlaceholder:t.configSearchPlaceholder,addLabel:t.addCustomServer,reloadLabel:t.reload}),[t,q,De,v,E,g.loading,m]);(0,H.useLayoutEffect)(()=>(ke({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:Me}),()=>Ae()),[Ae,t.title,Me,ke]);let Pe=g.instances.length+K.length,Fe=(0,H.useMemo)(()=>wt(g.catalog.filter(e=>e.source===`builtin`),E,j),[j,E,g.catalog]),Ie=(0,H.useMemo)(()=>wt(g.registryCatalog,E,j),[j,E,g.registryCatalog]),Le=m===`marketplace`&&!!(C&&b<C),Re=(0,H.useMemo)(()=>g.instances.filter(e=>Tt(e,E)),[E,g.instances]),ze=(0,H.useMemo)(()=>K.filter(e=>Et(e,E)),[K,E]),Be=Re.length+ze.length;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:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6 sm:px-8`,children:[c?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)(`div`,{className:`flex flex-wrap gap-x-1 gap-y-1`,role:`tablist`,"aria-label":t.navAria,children:[`marketplace`,`builtin`,`user`,`config`].map(e=>(0,W.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":m===e,className:i(`relative max-w-full rounded-md px-3 py-2 text-left text-sm font-medium transition-colors sm:text-center`,m===e?`text-fg after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`:`text-fg-muted hover:text-fg`),onClick:()=>h(e),children:[e===`marketplace`?t.tabMarketplace:e===`builtin`?t.tabBuiltin:e===`user`?t.tabUser:t.tabConfig,e===`builtin`?(0,W.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,Fe.length,`)`]}):null,e===`user`?(0,W.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,Pe,`)`]}):null]},e))}),(0,W.jsxs)(`div`,{className:`flex min-h-9 min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[m===`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:g.registries.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`,w.focusRingPanel,k===e.id?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":k===e.id,onClick:()=>A(e.id),children:e.displayName},e.id))}):null,m!==`user`&&m!==`config`?(0,W.jsxs)(ue,{children:[(0,W.jsx)(fe,{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`,w.transition,w.focusRingPanel),children:[(0,W.jsx)(te,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:j===`name`?t.sortName:t.sortSource}),(0,W.jsx)(M,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,W.jsx)(pe,{children:(0,W.jsxs)(me,{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)(de,{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:()=>P(`name`),children:t.sortName}),(0,W.jsx)(de,{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:()=>P(`source`),children:t.sortSource})]})})]}):null]})]}),g.error?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:g.error}):null,m===`user`&&c?(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})]}),g.loading?(0,W.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:he.slice(0,3).map(e=>(0,W.jsx)(ve,{},e))}):Pe===0||Be===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:Pe===0?t.installedEmpty:t.userEmpty}):(0,W.jsxs)(`div`,{className:`grid gap-3`,children:[Re.map(e=>(0,W.jsx)(ht,{instance:e,onChanged:q,t,mcp:n},e.instanceId)),ze.map(e=>(0,W.jsx)(Ve,{row:e,t:n,cs:t,onEdit:()=>ne({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Ee(e)},e.clientKey))]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,m===`config`&&c?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,W.jsxs)(le,{children:[(0,W.jsx)(ce,{icon:f,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(Ft,`w-40 flex-none`),value:R??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();z(t===``?void 0:Number.parseInt(t,10)),ae(!1)}}),(0,W.jsxs)(S,{variant:`secondary`,disabled:B,onClick:()=>void Oe(),children:[B?(0,W.jsx)(O,{className:`size-4 animate-spin`}):null,n.save]})]}),(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]})})]})}):null,m===`marketplace`&&c?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:v&&Ie.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:he.map(e=>(0,W.jsx)(_e,{},e))}):E.trim()&&Ie.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}):!E.trim()&&Ie.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)(O,{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:Ie.map(e=>(0,W.jsx)(ye,{connector:e,installed:Ce.has(e.id)||ge(e,g.instances),onInstall:e=>I(bt(e)),t},e.id))}),Le?(0,W.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,W.jsxs)(S,{type:`button`,variant:`secondary`,disabled:v,onClick:()=>void Y({browse:!E.trim(),page:b+1,append:!0}),children:[v?(0,W.jsx)(O,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})}):null,m===`builtin`&&c?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:g.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:he.map(e=>(0,W.jsx)(_e,{},e))}):Fe.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:Fe.map(e=>(0,W.jsx)(ye,{connector:e,installed:Ce.has(e.id)||ge(e,g.instances),onInstall:e=>I(bt(e)),t},e.id))})}):null]}),ee?(0,W.jsx)(xt,{draft:ee,onChange:I,onClose:()=>I(null),t,onInstalled:async()=>{await q(),await V(),h(`user`)}}):null,L?(0,W.jsx)(Mt,{open:!0,mode:L.mode,initialRow:L.row,existingCustomServers:K,sessionIdleTtlMinutes:R,config:U,managedServerIds:we,t:n,cs:t,onClose:()=>ne(null),onSaved:async()=>{await V(),await q(),h(`user`)}},`${L.mode}-${L.row.clientKey}`):null]})})}export{It as ConnectorsPage};
@@ -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-C6Kc4Jhf.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-Cs4ck8zA.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ho as d,Ka as f,Oa as p,Po as m,Uo as h,Va as g,ct as _,eo as v,fo as y,go as b,hi as x,ja as S,pc as C,rs as w,so as T,wa as E,wo as D,yc as O}from"./index-BU1pvxmS.js";import{n as k,t as A}from"./settings-form-section-CIxIEYxU.js";import{i as j,n as M,r as N,t as ee}from"./settings-page-layout--6qT7ZJa.js";import{n as P,t as F}from"./schedule-field-CMY25m97.js";import{t as I}from"./format-cron-label-arqgGlVV.js";var L=e(t(),1),R=n();function z(){return c(`/api/dreaming`)}async function te(){let e=await l(z());if(!e.payload)throw Error(`Missing payload`);return e.payload}async function ne(e){await l(c(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e})})}async function re(e=`deep`){let t=await l(c(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e})});if(t.ok===!1||!t.payload)throw Error(`Failed to run dreaming phase`);let n=t.payload.phase;return{phase:n===`light`||n===`deep`||n===`rem`?n:e,result:t.payload.result}}async function ie(e){let t=await l(c(`/api/dreaming/preview${typeof e==`number`&&Number.isFinite(e)?`?limit=${encodeURIComponent(String(e))}`:``}`));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ae(e=50){return(await l(c(`/api/dreaming/events${`?limit=${encodeURIComponent(String(e))}`}`))).payload?.events??[]}function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var V={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},H={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},U={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},W={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:V,deep:H,rem:U};function G(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function K(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function q(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function oe(e){let t=B(e)?e:{},n=B(t.memory)?t.memory:{},r=B(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||B(t.phases)?t:{},a=B(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=B(a.phases)?a.phases:{},s=B(o.light)?o.light:{},c=B(o.deep)?o.deep:{},l=B(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():W.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:G(typeof c.minScore==`number`?c.minScore:Number(c.minScore),W.minScore),minRecallCount:Math.max(1,K(c.minRecallCount,W.minRecallCount)),limit:K(c.limit,W.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():V.cron,lookbackDays:Math.max(1,K(s.lookbackDays,V.lookbackDays)),limit:K(s.limit,V.limit),dedupeSimilarity:G(q(s.dedupeSimilarity,V.dedupeSimilarity),V.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():H.cron,minScore:G(q(c.minScore,H.minScore),H.minScore),minRecallCount:Math.max(1,K(c.minRecallCount,H.minRecallCount)),limit:K(c.limit,H.limit),recencyHalfLifeDays:Math.max(1,q(c.recencyHalfLifeDays,H.recencyHalfLifeDays)),maxAgeDays:Math.max(1,q(c.maxAgeDays,H.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():U.cron,lookbackDays:Math.max(1,K(l.lookbackDays,U.lookbackDays)),limit:K(l.limit,U.limit),minPatternStrength:G(q(l.minPatternStrength,U.minPatternStrength),U.minPatternStrength)}}}async function se(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await l(c(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({memory:{...n??{},mode:t.enabled?`confirmWrite`:typeof n?.mode==`string`?n.mode:`off`,sources:Array.isArray(n?.sources)?n.sources:[`session`,`curated`,`workspace`],writePolicy:B(n?.writePolicy)?n.writePolicy:{curated:`confirm`,workspace:`confirm`},dreaming:{enabled:!!t.enabled,...r?{frequency:r}:{},...i?{timezone:i}:{},phases:{light:{enabled:!!t.light.enabled,...t.light.cron.trim()?{cron:t.light.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.light.lookbackDays)),limit:Math.max(0,Math.floor(t.light.limit)),dedupeSimilarity:G(t.light.dedupeSimilarity,V.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:G(t.deep.minScore,H.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),limit:Math.max(0,Math.floor(t.deep.limit)),recencyHalfLifeDays:Math.max(1,t.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,t.deep.maxAgeDays)},rem:{enabled:!!t.rem.enabled,...t.rem.cron.trim()?{cron:t.rem.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.rem.lookbackDays)),limit:Math.max(0,Math.floor(t.rem.limit)),minPatternStrength:G(t.rem.minPatternStrength,U.minPatternStrength)}}}}})}),x()}var ce=`p-4 sm:px-5`,le=`mb-3`,J=`rounded-xl border border-edge-subtle bg-surface-panel/30 p-3 sm:p-4`,Y=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,E);function ue(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function X(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function de(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Z=r(),fe=`text-xs font-medium text-fg-muted`,pe=`text-sm font-medium text-fg`;function Q(e){let t=(0,R.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:fe,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,R.c)(11),{label:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`min-w-0`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:fe,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(pe,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function me(e){let t=(0,R.c)(5),{label:n,className:r}=e,a;t[0]===r?a=t[1]:(a=i(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,Z.jsx)(`h3`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function he(e){let t=(0,R.c)(39),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,showEnabledControl:d,actions:f,status:p,enabledLabel:m,onLabel:h,offLabel:g,cronLabel:_,children:v}=e,y=d===void 0?!0:d,b;t[0]===n?b=t[1]:(b=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=b);let x;t[2]===r?x=t[3]:(x=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=x);let S;t[4]!==p||t[5]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x,p]}),t[4]=p,t[5]=x,t[6]=S):S=t[6];let C;t[7]===i?C=t[8]:(C=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[7]=i,t[8]=C);let w;t[9]!==S||t[10]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[9]=S,t[10]=C,t[11]=w):w=t[11];let T;t[12]!==b||t[13]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[b,w]}),t[12]=b,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==f||t[16]!==u||t[17]!==a||t[18]!==m||t[19]!==g||t[20]!==o||t[21]!==h||t[22]!==y?(E=f||y?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[f,y?(0,Z.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:e=>o(e.target.checked)}),(0,Z.jsx)(`span`,{children:m??(a?h:g)})]}):null]}):null,t[15]=f,t[16]=u,t[17]=a,t[18]=m,t[19]=g,t[20]=o,t[21]=h,t[22]=y,t[23]=E):E=t[23];let D;t[24]!==T||t[25]!==E?(D=(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 border-b border-edge-subtle/80 pb-2.5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==_||t[29]!==u||t[30]!==c||t[31]!==l?(O=(0,Z.jsx)(F,{kind:`cron`,className:`mb-2.5`,label:_,value:s,onChange:c,labels:l,disabled:u}),t[27]=s,t[28]=_,t[29]=u,t[30]=c,t[31]=l,t[32]=O):O=t[32];let k;t[33]===v?k=t[34]:(k=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:v}),t[33]=v,t[34]=k);let A;return t[35]!==O||t[36]!==k||t[37]!==D?(A=(0,Z.jsxs)(`div`,{className:J,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function ge(e){let t=(0,R.c)(23),{icon:n,label:r,enabled:a,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(J,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=a?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=i(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=a?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,Z.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,Z.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,Z.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function _e(e){let t=(0,R.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(me,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,Z.jsxs)(`details`,{className:`group rounded-lg border border-edge-subtle`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto border-t border-edge-subtle p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`border-t border-edge-subtle/80 pt-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function ve(e){let t=(0,R.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,Z.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=X(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,Z.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,Z.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,Z.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,Z.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,Z.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,Z.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,Z.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,Z.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function ye(e){let t=(0,R.c)(56),{t:n,schedulePickerLabels:r,hasToken:a,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,setRunPhase:d,runBusy:p,setCfgForm:h,doRunNow:g}=e,_;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==g||t[4]!==a||t[5]!==p||t[6]!==u||t[7]!==d||t[8]!==n?(_=(e,t)=>o?.enabled?(0,Z.jsx)(Se,{t:n,busy:p&&u===e,disabled:!a||l||p||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{d(e),g(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=g,t[4]=a,t[5]=p,t[6]=u,t[7]=d,t[8]=n,t[9]=_):_=t[9];let y=_,b;t[10]!==s||t[11]!==o||t[12]!==n.phasePendingSave||t[13]!==n.phaseWillDisable||t[14]!==n.phaseWillEnable?(b=e=>{if(!o||!s)return null;let t=o[e],r=s[e];return JSON.stringify(t)===JSON.stringify(r)?null:t.enabled===r.enabled?n.phasePendingSave:t.enabled?n.phaseWillEnable:n.phaseWillDisable},t[10]=s,t[11]=o,t[12]=n.phasePendingSave,t[13]=n.phaseWillDisable,t[14]=n.phaseWillEnable,t[15]=b):b=t[15];let x=b,S;return t[16]!==c||t[17]!==o||t[18]!==l||t[19]!==a||t[20]!==x||t[21]!==y||t[22]!==r||t[23]!==h||t[24]!==n.configDeepHalfLife||t[25]!==n.configDeepLimit||t[26]!==n.configDeepMaxAge||t[27]!==n.configDeepMinRecallCount||t[28]!==n.configDeepMinScore||t[29]!==n.configFrequency||t[30]!==n.configLightDedupe||t[31]!==n.configLightLimit||t[32]!==n.configLightLookbackDays||t[33]!==n.configLoading||t[34]!==n.configPhaseCron||t[35]!==n.configPhaseDeep||t[36]!==n.configPhaseDeepHint||t[37]!==n.configPhaseLight||t[38]!==n.configPhaseLightHint||t[39]!==n.configPhaseRem||t[40]!==n.configPhaseRemHint||t[41]!==n.configRemLimit||t[42]!==n.configRemLookbackDays||t[43]!==n.configRemMinStrength||t[44]!==n.configTimezone||t[45]!==n.masterHint||t[46]!==n.masterOff||t[47]!==n.masterOn||t[48]!==n.masterTitle||t[49]!==n.off||t[50]!==n.on||t[51]!==n.phasesTitle||t[52]!==n.scheduleTitle||t[53]!==n.unsavedConfigHint||t[54]!==n.unsavedConfigTitle?(S=(0,Z.jsx)(A,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:i(J,`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.masterTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.masterHint})]}),(0,Z.jsxs)(`label`,{className:i(`inline-flex w-fit cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,o.enabled?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o.enabled,disabled:!a||l,onChange:e=>h(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:i(`text-xs font-semibold`,o.enabled?`text-emerald-600 dark:text-emerald-400`:``),children:o.enabled?n.masterOn:n.masterOff})]})]}),c?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:[(0,Z.jsx)(w,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-semibold`,children:n.unsavedConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 leading-snug text-amber-800/90 dark:text-amber-100/80`,children:n.unsavedConfigHint})]})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(be,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:J,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-9`,children:(0,Z.jsx)(F,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>h(t=>t&&{...t,frequency:e}),labels:r,disabled:!a||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:Y,value:o.timezone,disabled:!a||l,onChange:e=>h(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(be,{title:n.phasesTitle}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(f,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>h(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>h(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:y(`light`,o.light.enabled),status:x(`light`)?(0,Z.jsx)(xe,{label:x(`light`)??``}):null,enabledLabel:x(`light`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configLightLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Y,value:o.light.lookbackDays,disabled:!a||l,onChange:e=>h(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:Y,value:o.light.limit,disabled:!a||l,onChange:e=>h(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightDedupe,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:Y,value:o.light.dedupeSimilarity,disabled:!a||l,onChange:e=>h(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(m,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>h(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>h(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:y(`deep`,o.deep.enabled),status:x(`deep`)?(0,Z.jsx)(xe,{label:x(`deep`)??``}):null,enabledLabel:x(`deep`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configDeepMinScore,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:Y,value:o.deep.minScore,disabled:!a||l,onChange:e=>h(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Y,value:o.deep.minRecallCount,disabled:!a||l,onChange:e=>h(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:Y,value:o.deep.limit,disabled:!a||l,onChange:e=>h(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepHalfLife,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Y,value:o.deep.recencyHalfLifeDays,disabled:!a||l,onChange:e=>h(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMaxAge,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Y,value:o.deep.maxAgeDays,disabled:!a||l,onChange:e=>h(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(v,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>h(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>h(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:y(`rem`,o.rem.enabled),status:x(`rem`)?(0,Z.jsx)(xe,{label:x(`rem`)??``}):null,enabledLabel:x(`rem`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configRemLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:Y,value:o.rem.lookbackDays,disabled:!a||l,onChange:e=>h(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:Y,value:o.rem.limit,disabled:!a||l,onChange:e=>h(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemMinStrength,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:Y,value:o.rem.minPatternStrength,disabled:!a||l,onChange:e=>h(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading})}),t[16]=c,t[17]=o,t[18]=l,t[19]=a,t[20]=x,t[21]=y,t[22]=r,t[23]=h,t[24]=n.configDeepHalfLife,t[25]=n.configDeepLimit,t[26]=n.configDeepMaxAge,t[27]=n.configDeepMinRecallCount,t[28]=n.configDeepMinScore,t[29]=n.configFrequency,t[30]=n.configLightDedupe,t[31]=n.configLightLimit,t[32]=n.configLightLookbackDays,t[33]=n.configLoading,t[34]=n.configPhaseCron,t[35]=n.configPhaseDeep,t[36]=n.configPhaseDeepHint,t[37]=n.configPhaseLight,t[38]=n.configPhaseLightHint,t[39]=n.configPhaseRem,t[40]=n.configPhaseRemHint,t[41]=n.configRemLimit,t[42]=n.configRemLookbackDays,t[43]=n.configRemMinStrength,t[44]=n.configTimezone,t[45]=n.masterHint,t[46]=n.masterOff,t[47]=n.masterOn,t[48]=n.masterTitle,t[49]=n.off,t[50]=n.on,t[51]=n.phasesTitle,t[52]=n.scheduleTitle,t[53]=n.unsavedConfigHint,t[54]=n.unsavedConfigTitle,t[55]=S):S=t[55],S}function be(e){let t=(0,R.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`px-0.5 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function xe(e){let t=(0,R.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex shrink-0 rounded-md border border-amber-500/25 bg-amber-500/10 px-1.5 py-0.5 text-[0.65rem] font-semibold text-amber-800 dark:text-amber-200`,children:n}),t[0]=n,t[1]=r),r}function Se(e){let t=(0,R.c)(8),{t:n,busy:r,disabled:i,title:a,onClick:o}=e,s;t[0]===r?s=t[1]:(s=r?(0,Z.jsx)(h,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),t[0]=r,t[1]=s);let c;return t[2]!==i||t[3]!==o||t[4]!==n.runNow||t[5]!==s||t[6]!==a?(c=(0,Z.jsxs)(p,{type:`button`,variant:`secondary`,className:`h-7 gap-1.5 rounded-lg px-2 text-xs`,disabled:i,title:a,onClick:o,children:[s,n.runNow]}),t[2]=i,t[3]=o,t[4]=n.runNow,t[5]=s,t[6]=a,t[7]=c):c=t[7],c}function Ce(e){let t=(0,R.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(h,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(p,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,Z.jsx)(k,{className:le,icon:C,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(we)}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=f):f=t[16];let m;return t[17]!==d||t[18]!==f?(m=(0,Z.jsxs)(A,{className:ce,children:[d,f]}),t[17]=d,t[18]=f,t[19]=m):m=t[19],m}function we(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-xs`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:i(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:X(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:ue(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function Te(e){let t=(0,R.c)(23),{t:n,hasToken:r,cfgForm:i,cfgSaving:a,cfgDirty:o,saveConfig:s,doRefresh:c}=e,l=!r||!i||a||!o,u;t[0]===s?u=t[1]:(u=()=>void s(),t[0]=s,t[1]=u);let d;t[2]===a?d=t[3]:(d=a?(0,Z.jsx)(h,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=a,t[3]=d);let f;t[4]!==n.saveConfig||t[5]!==l||t[6]!==u||t[7]!==d?(f=(0,Z.jsxs)(p,{type:`button`,variant:`primary`,disabled:l,onClick:u,children:[d,n.saveConfig]}),t[4]=n.saveConfig,t[5]=l,t[6]=u,t[7]=d,t[8]=f):f=t[8];let m=!r,g;t[9]===c?g=t[10]:(g=()=>void c(),t[9]=c,t[10]=g);let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(b,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=_):_=t[11];let v;t[12]!==n.refresh||t[13]!==m||t[14]!==g?(v=(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:m,title:n.refresh,"aria-label":n.refresh,onClick:g,children:_}),t[12]=n.refresh,t[13]=m,t[14]=g,t[15]=v):v=t[15];let y;t[16]!==f||t[17]!==v?(y=(0,Z.jsxs)(Z.Fragment,{children:[f,v]}),t[16]=f,t[17]=v,t[18]=y):y=t[18];let x;return t[19]!==n.subtitle||t[20]!==n.title||t[21]!==y?(x=(0,Z.jsx)(M,{title:n.title,subtitle:n.subtitle,actions:y}),t[19]=n.subtitle,t[20]=n.title,t[21]=y,t[22]=x):x=t[22],x}function Ee(e){let t=(0,R.c)(30),{t:n,disabled:r,actionBusy:a,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-2xl`,ce),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(k,{className:le,icon:S,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===a?u=t[8]:(u=a===`reset_store`?(0,Z.jsx)(h,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(g,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=a,t[8]=u);let f;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(f=(0,Z.jsxs)(p,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=f):f=t[13];let m;t[14]!==o||t[15]!==n.confirmClearLock?(m=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=m):m=t[16];let _;t[17]===a?_=t[18]:(_=a===`clear_lock`?(0,Z.jsx)(h,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(d,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=a,t[18]=_);let v;t[19]!==r||t[20]!==n.clearLock||t[21]!==m||t[22]!==_?(v=(0,Z.jsxs)(p,{variant:`secondary`,disabled:r,onClick:m,children:[_,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=m,t[22]=_,t[23]=v):v=t[23];let y;t[24]!==f||t[25]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[f,v]}),t[24]=f,t[25]=v,t[26]=y):y=t[26];let b;return t[27]!==c||t[28]!==y?(b=(0,Z.jsxs)(A,{className:s,children:[c,y]}),t[27]=c,t[28]=y,t[29]=b):b=t[29],b}function De(e){let t=(0,R.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(h,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(p,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,Z.jsx)(k,{className:le,icon:y,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/60 px-2.5 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Z.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,Z.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,Z.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,Z.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let m;return t[18]!==d||t[19]!==f?(m=(0,Z.jsxs)(A,{className:ce,children:[d,f]}),t[18]=d,t[19]=f,t[20]=m):m=t[20],m}function Oe(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var ke={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},Ae={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function je(e,t){return e.startsWith(`zh`)?Ae[t]:ke[t]}function Me(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&P.has(r)){let e=Oe(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return je(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return je(t,`minute`).format(a);let o=Math.round(a/60);return je(t,`hour`).format(o)}function Ne(e){let t=(0,R.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?I(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Me(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function Pe(e){let t=(0,R.c)(100),{t:n,data:r,isLoading:a,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?de(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`min-w-0`,ce),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a?(0,Z.jsx)(h,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=a,t[5]=d);let p;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(p=(0,Z.jsx)(k,{className:le,icon:C,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:d}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=d,t[9]=p):p=t[9];let g;t[10]===n.subsectionSchedule?g=t[11]:(g=(0,Z.jsx)(me,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=g);let _=r?r.config.enabled?n.on:n.off:`—`,y;t[12]!==n.enabled||t[13]!==_?(y=(0,Z.jsx)($,{label:n.enabled,children:_}),t[12]=n.enabled,t[13]=_,t[14]=y):y=t[14];let b=l?.className,x=l?l.text:`—`,S;t[15]!==b||t[16]!==x?(S=(0,Z.jsx)(`span`,{className:b,children:x}),t[15]=b,t[16]=x,t[17]=S):S=t[17];let w;t[18]!==n.lock||t[19]!==S?(w=(0,Z.jsx)($,{label:n.lock,children:S}),t[18]=n.lock,t[19]=S,t[20]=w):w=t[20];let T=r&&r.config.timezone||`—`,E;t[21]!==n.timezone||t[22]!==T?(E=(0,Z.jsx)($,{label:n.timezone,children:T}),t[21]=n.timezone,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==r||t[25]!==o||t[26]!==s?(D=r?(0,Z.jsx)(Ne,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=D):D=t[27];let O;t[28]===r?O=t[29]:(O=r?.config.frequency?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=O);let j;t[30]!==n.schedule||t[31]!==D||t[32]!==O?(j=(0,Z.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[D,O]}),t[30]=n.schedule,t[31]=D,t[32]=O,t[33]=j):j=t[33];let M;t[34]!==w||t[35]!==E||t[36]!==j||t[37]!==y?(M=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[y,w,E,j]}),t[34]=w,t[35]=E,t[36]=j,t[37]=y,t[38]=M):M=t[38];let N;t[39]!==M||t[40]!==g?(N=(0,Z.jsxs)(`div`,{className:J,children:[g,M]}),t[39]=M,t[40]=g,t[41]=N):N=t[41];let ee;t[42]===n.subsectionStore?ee=t[43]:(ee=(0,Z.jsx)(me,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=ee);let P=r?String(r.store.entryCount):`—`,F;t[44]!==n.storeEntries||t[45]!==P?(F=(0,Z.jsx)($,{label:n.storeEntries,children:P}),t[44]=n.storeEntries,t[45]=P,t[46]=F):F=t[46];let L=r?String(r.store.promotedCount):`—`,z;t[47]!==n.storePromoted||t[48]!==L?(z=(0,Z.jsx)($,{label:n.storePromoted,children:L}),t[47]=n.storePromoted,t[48]=L,t[49]=z):z=t[49];let te;t[50]===r?te=t[51]:(te=r?ue(r.store.updatedAt):`—`,t[50]=r,t[51]=te);let ne;t[52]!==n.storeUpdatedAt||t[53]!==te?(ne=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:te}),t[52]=n.storeUpdatedAt,t[53]=te,t[54]=ne):ne=t[54];let re;t[55]===r?re=t[56]:(re=r?ue(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=re);let ie;t[57]!==n.storeLastPromotedAt||t[58]!==re?(ie=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:re}),t[57]=n.storeLastPromotedAt,t[58]=re,t[59]=ie):ie=t[59];let ae;t[60]!==F||t[61]!==z||t[62]!==ne||t[63]!==ie?(ae=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[F,z,ne,ie]}),t[60]=F,t[61]=z,t[62]=ne,t[63]=ie,t[64]=ae):ae=t[64];let B;t[65]!==ee||t[66]!==ae?(B=(0,Z.jsxs)(`div`,{className:J,children:[ee,ae]}),t[65]=ee,t[66]=ae,t[67]=B):B=t[67];let V;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(V=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(me,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(ge,{icon:(0,Z.jsx)(f,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:I(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,Z.jsx)(ge,{icon:(0,Z.jsx)(m,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:I(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls≥${r.config.phases.deep.minRecallCount}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(ge,{icon:(0,Z.jsx)(v,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:I(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=V):V=t[72];let H;t[73]===n.subsectionLastRun?H=t[74]:(H=(0,Z.jsx)(me,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=H);let U;t[75]===n.lastRunBlockHint?U=t[76]:(U=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=U);let W;t[77]!==r||t[78]!==n?(W=r?.lastRun?.exists?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,Z.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge-subtle/80 bg-surface-panel/50 p-2.5`,children:(0,Z.jsx)(ve,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg border border-edge-subtle`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto border-t border-edge-subtle p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=W):W=t[79];let G;t[80]!==H||t[81]!==U||t[82]!==W?(G=(0,Z.jsxs)(`div`,{className:J,children:[H,U,W]}),t[80]=H,t[81]=U,t[82]=W,t[83]=G):G=t[83];let K=r?.lightLastRun,q;t[84]!==n||t[85]!==K?(q=(0,Z.jsx)(_e,{label:n.subsectionLightLastRun,lastRun:K,t:n}),t[84]=n,t[85]=K,t[86]=q):q=t[86];let oe=r?.remLastRun,se;t[87]!==n||t[88]!==oe?(se=(0,Z.jsx)(_e,{label:n.subsectionRemLastRun,lastRun:oe,t:n}),t[87]=n,t[88]=oe,t[89]=se):se=t[89];let Y;t[90]!==N||t[91]!==B||t[92]!==V||t[93]!==G||t[94]!==q||t[95]!==se?(Y=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[N,B,V,G,q,se]}),t[90]=N,t[91]=B,t[92]=V,t[93]=G,t[94]=q,t[95]=se,t[96]=Y):Y=t[96];let X;return t[97]!==Y||t[98]!==p?(X=(0,Z.jsxs)(A,{className:u,children:[p,Y]}),t[97]=Y,t[98]=p,t[99]=X):X=t[99],X}var Fe=[`config`,`runtime`,`insights`,`maintenance`],Ie={config:T,runtime:C,insights:y,maintenance:S};function Le(e){return e&&Fe.includes(e)?e:`config`}function Re(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function ze(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Be(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var Ve={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null};function He(){let e=o(e=>e.language),t=a(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,c=e===`zh`?`zh-CN`:`en-US`,l=!!s(e=>e.token),[d,f]=O(),p=Le(d.get(`tab`)),m=(0,L.useCallback)(e=>{f(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[f]),[h,g]=(0,L.useReducer)(_,Ve),{actionBusy:v,actionError:y,runBusy:b,runError:x,runPhase:S,cfgSaving:C,cfgError:w,previewLoading:T,previewError:E,previewItems:D,eventsLoading:k,eventsError:A,events:j}=h,[M,N]=(0,L.useReducer)(Be,{form:null,baseline:null}),P=M.form,F=M.baseline,I=(0,L.useRef)(!1),{data:R,error:B,isLoading:V,mutate:H}=u(l?z():null,te,{revalidateOnFocus:!1}),U=(0,L.useMemo)(()=>{let e=[];return B&&e.push(B instanceof Error?B.message:String(B)),y&&e.push(y),x&&e.push(x),E&&e.push(E),A&&e.push(A),w&&e.push(w),e},[B,y,x,E,A,w]),W=(0,L.useCallback)(async()=>{g({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await H()},[H]),G=(0,L.useCallback)(async()=>{g({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{g({type:`patch`,patch:{previewItems:(await ie(20)).items??[]}})}catch(e){g({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{previewLoading:!1}})}},[]),K=(0,L.useCallback)(async()=>{g({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{g({type:`patch`,patch:{events:await ae(50)}})}catch(e){g({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{eventsLoading:!1}})}},[]),q=(0,L.useCallback)(async(e=`deep`)=>{g({type:`patch`,patch:{runBusy:!0,runOk:!1,runError:null}});try{await re(e),g({type:`patch`,patch:{runOk:!0}}),await H()}catch(e){g({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{runBusy:!1}})}},[H]),ce=(0,L.useCallback)(async e=>{g({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await ne(e),g({type:`patch`,patch:{actionOk:!0}}),await H()}catch(e){g({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{actionBusy:null}})}},[H]),le=!l||V||!!v,J=(0,L.useMemo)(()=>{let e=R?.config;return oe(e??{})},[R]),Y=R?.agentId??`main`,ue=R?.memory;(0,L.useEffect)(()=>{if(!l){N({type:`reset`}),I.current=!1;return}I.current||N({type:`sync`,value:J})},[J,l]);let X=(0,L.useMemo)(()=>!P||!F?!1:JSON.stringify(P)!==JSON.stringify(F),[P,F]);return(0,Z.jsxs)(ee,{children:[(0,Z.jsx)(Te,{t:n,hasToken:l,cfgForm:P,cfgSaving:C,cfgDirty:X,saveConfig:(0,L.useCallback)(async()=>{if(P){g({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await se(Y,P,ue),N({type:`saved`,value:P}),I.current=!1,g({type:`patch`,patch:{cfgOk:!0}}),await H()}catch(e){g({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{cfgSaving:!1}})}}},[Y,ue,P,H]),doRefresh:W}),U.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-amber-500/20 bg-amber-500/5 px-4 py-3`,role:`alert`,children:U.map(e=>(0,Z.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,(0,Z.jsx)(Ue,{t:n,activeTab:p,onChange:m}),(0,Z.jsx)(We,{t:n,id:`config`,activeTab:p,children:(0,Z.jsx)(ye,{t:n,schedulePickerLabels:r,hasToken:l,cfgForm:P,cfgBaseline:F,cfgDirty:X,cfgSaving:C,runPhase:S,setRunPhase:e=>g({type:`patch`,patch:{runPhase:e}}),runBusy:b,setCfgForm:e=>{I.current=!0;let t=typeof e==`function`?e(P):e;t&&N({type:`set`,value:t})},doRunNow:q})}),(0,Z.jsx)(We,{t:n,id:`runtime`,activeTab:p,children:(0,Z.jsx)(Pe,{t:n,data:R,isLoading:V,localeTag:c,scheduleBadgeLabels:i})}),(0,Z.jsx)(We,{t:n,id:`insights`,activeTab:p,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(De,{t:n,hasToken:l,previewLoading:T,previewItems:D,loadPreview:G}),(0,Z.jsx)(Ce,{t:n,hasToken:l,eventsLoading:k,events:j,loadEvents:K})]})}),(0,Z.jsx)(We,{t:n,id:`maintenance`,activeTab:p,children:(0,Z.jsx)(Ee,{t:n,disabled:le,actionBusy:v,doAction:ce})})]})}function Ue(e){let t=(0,R.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Fe.map(e=>({id:e,label:Re(n,e),icon:Ie[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(j,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function We(e){let t=(0,R.c)(13),{t:n,id:r,activeTab:i,children:a}=e,o=r!==`config`,s;t[0]!==r||t[1]!==n?(s=Re(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n?(c=ze(n,r),t[3]=r,t[4]=n,t[5]=c):c=t[5];let l;return t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,Z.jsx)(N,{id:r,activeTab:i,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`,title:s,hint:c,showHeading:o,children:a}),t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}export{He as DreamingSettingsPanel};