botmux 3.16.0 → 3.17.0

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 (619) hide show
  1. package/dist/.runtime-build-id +1 -1
  2. package/dist/adapters/backend/riff-backend.d.ts +84 -1
  3. package/dist/adapters/backend/riff-backend.d.ts.map +1 -1
  4. package/dist/adapters/backend/riff-backend.js +202 -19
  5. package/dist/adapters/backend/riff-backend.js.map +1 -1
  6. package/dist/adapters/backend/sandbox.d.ts +8 -0
  7. package/dist/adapters/backend/sandbox.d.ts.map +1 -1
  8. package/dist/adapters/backend/sandbox.js +15 -0
  9. package/dist/adapters/backend/sandbox.js.map +1 -1
  10. package/dist/adapters/backend/tmux-backend.d.ts +61 -7
  11. package/dist/adapters/backend/tmux-backend.d.ts.map +1 -1
  12. package/dist/adapters/backend/tmux-backend.js +80 -9
  13. package/dist/adapters/backend/tmux-backend.js.map +1 -1
  14. package/dist/adapters/backend/tmux-pipe-backend.d.ts +62 -4
  15. package/dist/adapters/backend/tmux-pipe-backend.d.ts.map +1 -1
  16. package/dist/adapters/backend/tmux-pipe-backend.js +240 -27
  17. package/dist/adapters/backend/tmux-pipe-backend.js.map +1 -1
  18. package/dist/adapters/cli/claude-code.d.ts.map +1 -1
  19. package/dist/adapters/cli/claude-code.js +4 -2
  20. package/dist/adapters/cli/claude-code.js.map +1 -1
  21. package/dist/adapters/cli/coco.d.ts.map +1 -1
  22. package/dist/adapters/cli/coco.js +27 -0
  23. package/dist/adapters/cli/coco.js.map +1 -1
  24. package/dist/adapters/cli/codex-app.d.ts.map +1 -1
  25. package/dist/adapters/cli/codex-app.js +28 -0
  26. package/dist/adapters/cli/codex-app.js.map +1 -1
  27. package/dist/adapters/cli/codex.d.ts.map +1 -1
  28. package/dist/adapters/cli/codex.js +51 -23
  29. package/dist/adapters/cli/codex.js.map +1 -1
  30. package/dist/adapters/cli/dsh-tui.d.ts +24 -0
  31. package/dist/adapters/cli/dsh-tui.d.ts.map +1 -0
  32. package/dist/adapters/cli/dsh-tui.js +99 -0
  33. package/dist/adapters/cli/dsh-tui.js.map +1 -0
  34. package/dist/adapters/cli/dsh.d.ts.map +1 -1
  35. package/dist/adapters/cli/dsh.js +15 -9
  36. package/dist/adapters/cli/dsh.js.map +1 -1
  37. package/dist/adapters/cli/fs-policy.d.ts +98 -1
  38. package/dist/adapters/cli/fs-policy.d.ts.map +1 -1
  39. package/dist/adapters/cli/fs-policy.js +182 -7
  40. package/dist/adapters/cli/fs-policy.js.map +1 -1
  41. package/dist/adapters/cli/grok.js +16 -18
  42. package/dist/adapters/cli/grok.js.map +1 -1
  43. package/dist/adapters/cli/model-catalog-json.d.ts +17 -0
  44. package/dist/adapters/cli/model-catalog-json.d.ts.map +1 -0
  45. package/dist/adapters/cli/model-catalog-json.js +43 -0
  46. package/dist/adapters/cli/model-catalog-json.js.map +1 -0
  47. package/dist/adapters/cli/oh-my-pi.d.ts +2 -0
  48. package/dist/adapters/cli/oh-my-pi.d.ts.map +1 -1
  49. package/dist/adapters/cli/oh-my-pi.js +45 -13
  50. package/dist/adapters/cli/oh-my-pi.js.map +1 -1
  51. package/dist/adapters/cli/opencode.js +1 -1
  52. package/dist/adapters/cli/opencode.js.map +1 -1
  53. package/dist/adapters/cli/registry.d.ts +2 -1
  54. package/dist/adapters/cli/registry.d.ts.map +1 -1
  55. package/dist/adapters/cli/registry.js +6 -1
  56. package/dist/adapters/cli/registry.js.map +1 -1
  57. package/dist/adapters/cli/relay.d.ts.map +1 -1
  58. package/dist/adapters/cli/relay.js +7 -0
  59. package/dist/adapters/cli/relay.js.map +1 -1
  60. package/dist/adapters/cli/seed.d.ts.map +1 -1
  61. package/dist/adapters/cli/seed.js +6 -0
  62. package/dist/adapters/cli/seed.js.map +1 -1
  63. package/dist/adapters/cli/shared-hints.d.ts.map +1 -1
  64. package/dist/adapters/cli/shared-hints.js +20 -14
  65. package/dist/adapters/cli/shared-hints.js.map +1 -1
  66. package/dist/adapters/cli/traex.d.ts +4 -0
  67. package/dist/adapters/cli/traex.d.ts.map +1 -1
  68. package/dist/adapters/cli/traex.js +153 -0
  69. package/dist/adapters/cli/traex.js.map +1 -1
  70. package/dist/adapters/cli/types.d.ts +42 -1
  71. package/dist/adapters/cli/types.d.ts.map +1 -1
  72. package/dist/autostart.d.ts +6 -0
  73. package/dist/autostart.d.ts.map +1 -1
  74. package/dist/autostart.js +21 -1
  75. package/dist/autostart.js.map +1 -1
  76. package/dist/bot-registry.d.ts +27 -0
  77. package/dist/bot-registry.d.ts.map +1 -1
  78. package/dist/bot-registry.js +62 -2
  79. package/dist/bot-registry.js.map +1 -1
  80. package/dist/cli/vc-agent.d.ts.map +1 -1
  81. package/dist/cli/vc-agent.js +21 -3
  82. package/dist/cli/vc-agent.js.map +1 -1
  83. package/dist/cli.d.ts.map +1 -1
  84. package/dist/cli.js +92 -1
  85. package/dist/cli.js.map +1 -1
  86. package/dist/codex-app-runner.js +28 -0
  87. package/dist/codex-app-runner.js.map +1 -1
  88. package/dist/core/bot-steer-directive.d.ts +25 -0
  89. package/dist/core/bot-steer-directive.d.ts.map +1 -0
  90. package/dist/core/bot-steer-directive.js +47 -0
  91. package/dist/core/bot-steer-directive.js.map +1 -0
  92. package/dist/core/command-handler.d.ts.map +1 -1
  93. package/dist/core/command-handler.js +102 -18
  94. package/dist/core/command-handler.js.map +1 -1
  95. package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
  96. package/dist/core/dashboard-ipc-server.js +53 -13
  97. package/dist/core/dashboard-ipc-server.js.map +1 -1
  98. package/dist/core/dashboard-rows.d.ts +3 -0
  99. package/dist/core/dashboard-rows.d.ts.map +1 -1
  100. package/dist/core/dashboard-rows.js +26 -5
  101. package/dist/core/dashboard-rows.js.map +1 -1
  102. package/dist/core/dashboard-url.d.ts +10 -1
  103. package/dist/core/dashboard-url.d.ts.map +1 -1
  104. package/dist/core/dashboard-url.js +12 -2
  105. package/dist/core/dashboard-url.js.map +1 -1
  106. package/dist/core/dispatch.d.ts.map +1 -1
  107. package/dist/core/dispatch.js +5 -4
  108. package/dist/core/dispatch.js.map +1 -1
  109. package/dist/core/existing-app-server.d.ts +22 -0
  110. package/dist/core/existing-app-server.d.ts.map +1 -0
  111. package/dist/core/existing-app-server.js +85 -0
  112. package/dist/core/existing-app-server.js.map +1 -0
  113. package/dist/core/native-topic-id.d.ts +9 -0
  114. package/dist/core/native-topic-id.d.ts.map +1 -0
  115. package/dist/core/native-topic-id.js +14 -0
  116. package/dist/core/native-topic-id.js.map +1 -0
  117. package/dist/core/per-bot-env.d.ts.map +1 -1
  118. package/dist/core/per-bot-env.js +10 -0
  119. package/dist/core/per-bot-env.js.map +1 -1
  120. package/dist/core/plugins/mcp/gateway.d.ts +27 -3
  121. package/dist/core/plugins/mcp/gateway.d.ts.map +1 -1
  122. package/dist/core/plugins/mcp/gateway.js +272 -26
  123. package/dist/core/plugins/mcp/gateway.js.map +1 -1
  124. package/dist/core/plugins/mcp/host.d.ts +18 -0
  125. package/dist/core/plugins/mcp/host.d.ts.map +1 -1
  126. package/dist/core/plugins/mcp/host.js +80 -16
  127. package/dist/core/plugins/mcp/host.js.map +1 -1
  128. package/dist/core/plugins/mcp/launch-record.d.ts +14 -0
  129. package/dist/core/plugins/mcp/launch-record.d.ts.map +1 -0
  130. package/dist/core/plugins/mcp/launch-record.js +63 -0
  131. package/dist/core/plugins/mcp/launch-record.js.map +1 -0
  132. package/dist/core/session-activity.d.ts +11 -0
  133. package/dist/core/session-activity.d.ts.map +1 -1
  134. package/dist/core/session-activity.js +23 -0
  135. package/dist/core/session-activity.js.map +1 -1
  136. package/dist/core/session-group-birth.d.ts.map +1 -1
  137. package/dist/core/session-group-birth.js +23 -8
  138. package/dist/core/session-group-birth.js.map +1 -1
  139. package/dist/core/session-manager.d.ts +1 -4
  140. package/dist/core/session-manager.d.ts.map +1 -1
  141. package/dist/core/session-manager.js +16 -20
  142. package/dist/core/session-manager.js.map +1 -1
  143. package/dist/core/shared-adopt.d.ts +20 -0
  144. package/dist/core/shared-adopt.d.ts.map +1 -0
  145. package/dist/core/shared-adopt.js +26 -0
  146. package/dist/core/shared-adopt.js.map +1 -0
  147. package/dist/core/skills/customize-command.d.ts +7 -0
  148. package/dist/core/skills/customize-command.d.ts.map +1 -0
  149. package/dist/core/skills/customize-command.js +303 -0
  150. package/dist/core/skills/customize-command.js.map +1 -0
  151. package/dist/core/terminal-write-auth.d.ts +15 -0
  152. package/dist/core/terminal-write-auth.d.ts.map +1 -1
  153. package/dist/core/terminal-write-auth.js +15 -0
  154. package/dist/core/terminal-write-auth.js.map +1 -1
  155. package/dist/core/terminal-write-frame.d.ts +30 -0
  156. package/dist/core/terminal-write-frame.d.ts.map +1 -0
  157. package/dist/core/terminal-write-frame.js +44 -0
  158. package/dist/core/terminal-write-frame.js.map +1 -0
  159. package/dist/core/types.d.ts +14 -4
  160. package/dist/core/types.d.ts.map +1 -1
  161. package/dist/core/types.js +6 -8
  162. package/dist/core/types.js.map +1 -1
  163. package/dist/core/worker-pool.d.ts +31 -6
  164. package/dist/core/worker-pool.d.ts.map +1 -1
  165. package/dist/core/worker-pool.js +444 -102
  166. package/dist/core/worker-pool.js.map +1 -1
  167. package/dist/core/worker-startup-retry.d.ts +52 -0
  168. package/dist/core/worker-startup-retry.d.ts.map +1 -0
  169. package/dist/core/worker-startup-retry.js +68 -0
  170. package/dist/core/worker-startup-retry.js.map +1 -0
  171. package/dist/daemon.d.ts +9 -8
  172. package/dist/daemon.d.ts.map +1 -1
  173. package/dist/daemon.js +467 -171
  174. package/dist/daemon.js.map +1 -1
  175. package/dist/dashboard/autostart-api.d.ts +26 -0
  176. package/dist/dashboard/autostart-api.d.ts.map +1 -0
  177. package/dist/dashboard/autostart-api.js +88 -0
  178. package/dist/dashboard/autostart-api.js.map +1 -0
  179. package/dist/dashboard/bot-payload.d.ts +5 -0
  180. package/dist/dashboard/bot-payload.d.ts.map +1 -1
  181. package/dist/dashboard/bot-payload.js +2 -0
  182. package/dist/dashboard/bot-payload.js.map +1 -1
  183. package/dist/dashboard/control-csrf.d.ts +29 -1
  184. package/dist/dashboard/control-csrf.d.ts.map +1 -1
  185. package/dist/dashboard/control-csrf.js +49 -10
  186. package/dist/dashboard/control-csrf.js.map +1 -1
  187. package/dist/dashboard/customization-api.d.ts +23 -0
  188. package/dist/dashboard/customization-api.d.ts.map +1 -0
  189. package/dist/dashboard/customization-api.js +198 -0
  190. package/dist/dashboard/customization-api.js.map +1 -0
  191. package/dist/dashboard/debug-terminal.d.ts +13 -1
  192. package/dist/dashboard/debug-terminal.d.ts.map +1 -1
  193. package/dist/dashboard/debug-terminal.js +18 -4
  194. package/dist/dashboard/debug-terminal.js.map +1 -1
  195. package/dist/dashboard/settings-write-applier.d.ts +0 -23
  196. package/dist/dashboard/settings-write-applier.d.ts.map +1 -1
  197. package/dist/dashboard/settings-write-applier.js +7 -28
  198. package/dist/dashboard/settings-write-applier.js.map +1 -1
  199. package/dist/dashboard/terminal-control-route.d.ts +32 -0
  200. package/dist/dashboard/terminal-control-route.d.ts.map +1 -0
  201. package/dist/dashboard/terminal-control-route.js +70 -0
  202. package/dist/dashboard/terminal-control-route.js.map +1 -0
  203. package/dist/dashboard/terminal-control.d.ts +64 -13
  204. package/dist/dashboard/terminal-control.d.ts.map +1 -1
  205. package/dist/dashboard/terminal-control.js +77 -14
  206. package/dist/dashboard/terminal-control.js.map +1 -1
  207. package/dist/dashboard/terminal-front-proxy.d.ts.map +1 -1
  208. package/dist/dashboard/terminal-front-proxy.js +41 -9
  209. package/dist/dashboard/terminal-front-proxy.js.map +1 -1
  210. package/dist/dashboard/vc-consumer-profiles-api.d.ts +69 -18
  211. package/dist/dashboard/vc-consumer-profiles-api.d.ts.map +1 -1
  212. package/dist/dashboard/vc-consumer-profiles-api.js +149 -29
  213. package/dist/dashboard/vc-consumer-profiles-api.js.map +1 -1
  214. package/dist/dashboard/web/agent-workbench-api.d.ts +34 -2
  215. package/dist/dashboard/web/agent-workbench-api.d.ts.map +1 -1
  216. package/dist/dashboard/web/agent-workbench-api.js +39 -4
  217. package/dist/dashboard/web/agent-workbench-api.js.map +1 -1
  218. package/dist/dashboard/web/agent-workbench-appearance.d.ts +6 -3
  219. package/dist/dashboard/web/agent-workbench-appearance.d.ts.map +1 -1
  220. package/dist/dashboard/web/agent-workbench-appearance.js +7 -4
  221. package/dist/dashboard/web/agent-workbench-appearance.js.map +1 -1
  222. package/dist/dashboard/web/agent-workbench-model.d.ts +2 -0
  223. package/dist/dashboard/web/agent-workbench-model.d.ts.map +1 -1
  224. package/dist/dashboard/web/agent-workbench-model.js.map +1 -1
  225. package/dist/dashboard/web/agent-workbench-page.js +2 -2
  226. package/dist/dashboard/web/agent-workbench-page.js.map +1 -1
  227. package/dist/dashboard/web/agent-workbench-panes.d.ts +59 -4
  228. package/dist/dashboard/web/agent-workbench-panes.d.ts.map +1 -1
  229. package/dist/dashboard/web/agent-workbench-panes.js +493 -85
  230. package/dist/dashboard/web/agent-workbench-panes.js.map +1 -1
  231. package/dist/dashboard/web/agent-workbench-session-list.d.ts +11 -7
  232. package/dist/dashboard/web/agent-workbench-session-list.d.ts.map +1 -1
  233. package/dist/dashboard/web/agent-workbench-session-list.js +24 -31
  234. package/dist/dashboard/web/agent-workbench-session-list.js.map +1 -1
  235. package/dist/dashboard/web/agent-workbench-terminal-control.d.ts +198 -0
  236. package/dist/dashboard/web/agent-workbench-terminal-control.d.ts.map +1 -0
  237. package/dist/dashboard/web/agent-workbench-terminal-control.js +292 -0
  238. package/dist/dashboard/web/agent-workbench-terminal-control.js.map +1 -0
  239. package/dist/dashboard/web/agent-workbench-view.d.ts +3 -2
  240. package/dist/dashboard/web/agent-workbench-view.d.ts.map +1 -1
  241. package/dist/dashboard/web/agent-workbench-view.js +69 -50
  242. package/dist/dashboard/web/agent-workbench-view.js.map +1 -1
  243. package/dist/dashboard/web/app.d.ts.map +1 -1
  244. package/dist/dashboard/web/app.js +58 -7
  245. package/dist/dashboard/web/app.js.map +1 -1
  246. package/dist/dashboard/web/bot-defaults-page.d.ts +24 -0
  247. package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
  248. package/dist/dashboard/web/bot-defaults-page.js +191 -16
  249. package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
  250. package/dist/dashboard/web/bot-defaults.d.ts +17 -0
  251. package/dist/dashboard/web/bot-defaults.d.ts.map +1 -1
  252. package/dist/dashboard/web/bot-defaults.js +51 -2
  253. package/dist/dashboard/web/bot-defaults.js.map +1 -1
  254. package/dist/dashboard/web/bot-onboarding.d.ts.map +1 -1
  255. package/dist/dashboard/web/bot-onboarding.js +32 -8
  256. package/dist/dashboard/web/bot-onboarding.js.map +1 -1
  257. package/dist/dashboard/web/confirm-modal.d.ts +35 -0
  258. package/dist/dashboard/web/confirm-modal.d.ts.map +1 -0
  259. package/dist/dashboard/web/confirm-modal.js +111 -0
  260. package/dist/dashboard/web/confirm-modal.js.map +1 -0
  261. package/dist/dashboard/web/connectors-page.d.ts.map +1 -1
  262. package/dist/dashboard/web/connectors-page.js +2 -1
  263. package/dist/dashboard/web/connectors-page.js.map +1 -1
  264. package/dist/dashboard/web/customization-page.d.ts +3 -0
  265. package/dist/dashboard/web/customization-page.d.ts.map +1 -0
  266. package/dist/dashboard/web/customization-page.js +315 -0
  267. package/dist/dashboard/web/customization-page.js.map +1 -0
  268. package/dist/dashboard/web/dashboard-routes.d.ts.map +1 -1
  269. package/dist/dashboard/web/dashboard-routes.js +1 -0
  270. package/dist/dashboard/web/dashboard-routes.js.map +1 -1
  271. package/dist/dashboard/web/groups-page.d.ts.map +1 -1
  272. package/dist/dashboard/web/groups-page.js +11 -9
  273. package/dist/dashboard/web/groups-page.js.map +1 -1
  274. package/dist/dashboard/web/i18n.d.ts.map +1 -1
  275. package/dist/dashboard/web/i18n.js +226 -42
  276. package/dist/dashboard/web/i18n.js.map +1 -1
  277. package/dist/dashboard/web/monitor-room.d.ts.map +1 -1
  278. package/dist/dashboard/web/monitor-room.js +3 -2
  279. package/dist/dashboard/web/monitor-room.js.map +1 -1
  280. package/dist/dashboard/web/overview-page.d.ts.map +1 -1
  281. package/dist/dashboard/web/overview-page.js +98 -63
  282. package/dist/dashboard/web/overview-page.js.map +1 -1
  283. package/dist/dashboard/web/roles-page.d.ts.map +1 -1
  284. package/dist/dashboard/web/roles-page.js +4 -3
  285. package/dist/dashboard/web/roles-page.js.map +1 -1
  286. package/dist/dashboard/web/schedules-page.d.ts.map +1 -1
  287. package/dist/dashboard/web/schedules-page.js +165 -18
  288. package/dist/dashboard/web/schedules-page.js.map +1 -1
  289. package/dist/dashboard/web/sessions-kanban.d.ts +2 -0
  290. package/dist/dashboard/web/sessions-kanban.d.ts.map +1 -1
  291. package/dist/dashboard/web/sessions-kanban.js +142 -24
  292. package/dist/dashboard/web/sessions-kanban.js.map +1 -1
  293. package/dist/dashboard/web/sessions-page.d.ts.map +1 -1
  294. package/dist/dashboard/web/sessions-page.js +177 -94
  295. package/dist/dashboard/web/sessions-page.js.map +1 -1
  296. package/dist/dashboard/web/sessions.d.ts.map +1 -1
  297. package/dist/dashboard/web/sessions.js +5 -4
  298. package/dist/dashboard/web/sessions.js.map +1 -1
  299. package/dist/dashboard/web/settings-page.d.ts +0 -8
  300. package/dist/dashboard/web/settings-page.d.ts.map +1 -1
  301. package/dist/dashboard/web/settings-page.js +185 -65
  302. package/dist/dashboard/web/settings-page.js.map +1 -1
  303. package/dist/dashboard/web/skills/skill-library-tab.d.ts +2 -0
  304. package/dist/dashboard/web/skills/skill-library-tab.d.ts.map +1 -1
  305. package/dist/dashboard/web/skills/skill-library-tab.js +15 -1
  306. package/dist/dashboard/web/skills/skill-library-tab.js.map +1 -1
  307. package/dist/dashboard/web/skills-page.d.ts.map +1 -1
  308. package/dist/dashboard/web/skills-page.js +5 -4
  309. package/dist/dashboard/web/skills-page.js.map +1 -1
  310. package/dist/dashboard/web/store.d.ts +5 -0
  311. package/dist/dashboard/web/store.d.ts.map +1 -1
  312. package/dist/dashboard/web/store.js +4 -0
  313. package/dist/dashboard/web/store.js.map +1 -1
  314. package/dist/dashboard/web/team-federation-page.d.ts.map +1 -1
  315. package/dist/dashboard/web/team-federation-page.js +3 -2
  316. package/dist/dashboard/web/team-federation-page.js.map +1 -1
  317. package/dist/dashboard/web/toast.d.ts +15 -0
  318. package/dist/dashboard/web/toast.d.ts.map +1 -0
  319. package/dist/dashboard/web/toast.js +70 -0
  320. package/dist/dashboard/web/toast.js.map +1 -0
  321. package/dist/dashboard/web/v3-components.d.ts.map +1 -1
  322. package/dist/dashboard/web/v3-components.js +2 -1
  323. package/dist/dashboard/web/v3-components.js.map +1 -1
  324. package/dist/dashboard/web/vc-consumer-profiles-section.d.ts +10 -12
  325. package/dist/dashboard/web/vc-consumer-profiles-section.d.ts.map +1 -1
  326. package/dist/dashboard/web/vc-consumer-profiles-section.js +219 -200
  327. package/dist/dashboard/web/vc-consumer-profiles-section.js.map +1 -1
  328. package/dist/dashboard/web/whiteboards-page.d.ts.map +1 -1
  329. package/dist/dashboard/web/whiteboards-page.js +2 -1
  330. package/dist/dashboard/web/whiteboards-page.js.map +1 -1
  331. package/dist/dashboard-web/app.js +1 -1
  332. package/dist/dashboard-web/chunks/agent-workbench-dock-page-LZSUOCEQ.js +1 -0
  333. package/dist/dashboard-web/chunks/agent-workbench-page-YONDRJU7.js +1 -0
  334. package/dist/dashboard-web/chunks/bot-defaults-page-X7LV6373.js +1 -0
  335. package/dist/dashboard-web/chunks/chunk-2PVRDXEL.js +1 -0
  336. package/dist/dashboard-web/chunks/chunk-53JUKBU2.js +10 -0
  337. package/dist/dashboard-web/chunks/{chunk-5CJMHTT4.js → chunk-5QX4OYOR.js} +1 -1
  338. package/dist/dashboard-web/chunks/{chunk-NACP7BMR.js → chunk-5VRVJFQR.js} +1 -1
  339. package/dist/dashboard-web/chunks/{chunk-FDZ7WOBW.js → chunk-6ROOZWYV.js} +1 -1
  340. package/dist/dashboard-web/chunks/{chunk-F6KNPF4R.js → chunk-CK22743G.js} +15 -19
  341. package/dist/dashboard-web/chunks/chunk-CVNIMUPY.js +25 -0
  342. package/dist/dashboard-web/chunks/chunk-GJC2TMWS.js +2 -0
  343. package/dist/dashboard-web/chunks/chunk-OT6L6G7R.js +1 -0
  344. package/dist/dashboard-web/chunks/chunk-QITAMHW6.js +1 -0
  345. package/dist/dashboard-web/chunks/chunk-RHVFZC5Z.js +1 -0
  346. package/dist/dashboard-web/chunks/chunk-SOBMN2VY.js +1 -0
  347. package/dist/dashboard-web/chunks/chunk-SZOB6VK2.js +1 -0
  348. package/dist/dashboard-web/chunks/chunk-XVIXNQGC.js +44 -0
  349. package/dist/dashboard-web/chunks/chunk-YUJF34ME.js +1 -0
  350. package/dist/dashboard-web/chunks/connectors-page-LB2HEJ7F.js +1 -0
  351. package/dist/dashboard-web/chunks/customization-page-4GXBYLG6.js +105 -0
  352. package/dist/dashboard-web/chunks/feedback-page-IZQ7VLDG.js +1 -0
  353. package/dist/dashboard-web/chunks/groups-page-4WCP5OEV.js +8 -0
  354. package/dist/dashboard-web/chunks/{insights-page-HJFDYR5N.js → insights-page-TXQHIPQL.js} +1 -1
  355. package/dist/dashboard-web/chunks/{monitor-room-V7PCP47V.js → monitor-room-VBRVWXCM.js} +8 -8
  356. package/dist/dashboard-web/chunks/monitoring-page-QDDZWERE.js +2 -0
  357. package/dist/dashboard-web/chunks/office-page-PENFNYPG.js +1 -0
  358. package/dist/dashboard-web/chunks/overview-page-BZQDP6MP.js +1 -0
  359. package/dist/dashboard-web/chunks/plugin-page-JX4GSWZS.js +1 -0
  360. package/dist/dashboard-web/chunks/roles-page-VPNINZNK.js +1 -0
  361. package/dist/dashboard-web/chunks/schedules-page-BITO6HEA.js +1 -0
  362. package/dist/dashboard-web/chunks/sessions-page-ZKCOVTD2.js +8 -0
  363. package/dist/dashboard-web/chunks/settings-page-UT6JDTS6.js +2 -0
  364. package/dist/dashboard-web/chunks/skills-page-GULXVAJY.js +4 -0
  365. package/dist/dashboard-web/chunks/team-federation-page-CUUJWGEG.js +1 -0
  366. package/dist/dashboard-web/chunks/v3-page-5WVJ5AUR.js +94 -0
  367. package/dist/dashboard-web/chunks/whiteboards-page-FZ2CME4H.js +1 -0
  368. package/dist/dashboard-web/design-tokens.css +236 -0
  369. package/dist/dashboard-web/index.html +1 -0
  370. package/dist/dashboard-web/style.css +1930 -114
  371. package/dist/dashboard.js +360 -279
  372. package/dist/dashboard.js.map +1 -1
  373. package/dist/desktop/renderer/app.js +6 -0
  374. package/dist/desktop/renderer/app.js.map +1 -1
  375. package/dist/dsh-runner.js +139 -17
  376. package/dist/dsh-runner.js.map +1 -1
  377. package/dist/global-config.d.ts +33 -2
  378. package/dist/global-config.d.ts.map +1 -1
  379. package/dist/global-config.js +62 -0
  380. package/dist/global-config.js.map +1 -1
  381. package/dist/i18n/en.d.ts.map +1 -1
  382. package/dist/i18n/en.js +13 -4
  383. package/dist/i18n/en.js.map +1 -1
  384. package/dist/i18n/index.d.ts +27 -3
  385. package/dist/i18n/index.d.ts.map +1 -1
  386. package/dist/i18n/index.js +33 -4
  387. package/dist/i18n/index.js.map +1 -1
  388. package/dist/i18n/zh.d.ts.map +1 -1
  389. package/dist/i18n/zh.js +13 -4
  390. package/dist/i18n/zh.js.map +1 -1
  391. package/dist/im/lark/card-builder.d.ts +2 -0
  392. package/dist/im/lark/card-builder.d.ts.map +1 -1
  393. package/dist/im/lark/card-builder.js +7 -4
  394. package/dist/im/lark/card-builder.js.map +1 -1
  395. package/dist/im/lark/card-handler.d.ts.map +1 -1
  396. package/dist/im/lark/card-handler.js +135 -20
  397. package/dist/im/lark/card-handler.js.map +1 -1
  398. package/dist/im/lark/event-dispatcher.d.ts +38 -3
  399. package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
  400. package/dist/im/lark/event-dispatcher.js +163 -13
  401. package/dist/im/lark/event-dispatcher.js.map +1 -1
  402. package/dist/im/lark/v3-blocked-card-handler.d.ts.map +1 -1
  403. package/dist/im/lark/v3-blocked-card-handler.js +2 -1
  404. package/dist/im/lark/v3-blocked-card-handler.js.map +1 -1
  405. package/dist/im/lark/v3-blocked-card.d.ts +1 -1
  406. package/dist/im/lark/v3-blocked-card.d.ts.map +1 -1
  407. package/dist/im/lark/v3-blocked-card.js +14 -0
  408. package/dist/im/lark/v3-blocked-card.js.map +1 -1
  409. package/dist/index-core-only.js +2 -0
  410. package/dist/index-core-only.js.map +1 -1
  411. package/dist/index-daemon.js +3 -0
  412. package/dist/index-daemon.js.map +1 -1
  413. package/dist/platform/binding.d.ts +37 -0
  414. package/dist/platform/binding.d.ts.map +1 -1
  415. package/dist/platform/binding.js +15 -0
  416. package/dist/platform/binding.js.map +1 -1
  417. package/dist/services/bridge-turn-journal.d.ts +63 -0
  418. package/dist/services/bridge-turn-journal.d.ts.map +1 -0
  419. package/dist/services/bridge-turn-journal.js +149 -0
  420. package/dist/services/bridge-turn-journal.js.map +1 -0
  421. package/dist/services/bridge-turn-queue.d.ts +8 -1
  422. package/dist/services/bridge-turn-queue.d.ts.map +1 -1
  423. package/dist/services/bridge-turn-queue.js +2 -1
  424. package/dist/services/bridge-turn-queue.js.map +1 -1
  425. package/dist/services/codex-app-runner-protocol.d.ts +5 -0
  426. package/dist/services/codex-app-runner-protocol.d.ts.map +1 -1
  427. package/dist/services/codex-app-runner-protocol.js +5 -0
  428. package/dist/services/codex-app-runner-protocol.js.map +1 -1
  429. package/dist/services/customization-store.d.ts +93 -0
  430. package/dist/services/customization-store.d.ts.map +1 -0
  431. package/dist/services/customization-store.js +542 -0
  432. package/dist/services/customization-store.js.map +1 -0
  433. package/dist/services/file-bridge-path.d.ts.map +1 -1
  434. package/dist/services/file-bridge-path.js +3 -0
  435. package/dist/services/file-bridge-path.js.map +1 -1
  436. package/dist/services/grok-transcript.d.ts.map +1 -1
  437. package/dist/services/grok-transcript.js +44 -9
  438. package/dist/services/grok-transcript.js.map +1 -1
  439. package/dist/services/local-cli-opener.d.ts.map +1 -1
  440. package/dist/services/local-cli-opener.js +12 -3
  441. package/dist/services/local-cli-opener.js.map +1 -1
  442. package/dist/services/model-catalog.d.ts +54 -0
  443. package/dist/services/model-catalog.d.ts.map +1 -0
  444. package/dist/services/model-catalog.js +147 -0
  445. package/dist/services/model-catalog.js.map +1 -0
  446. package/dist/services/omp-transcript.d.ts +27 -0
  447. package/dist/services/omp-transcript.d.ts.map +1 -0
  448. package/dist/services/omp-transcript.js +214 -0
  449. package/dist/services/omp-transcript.js.map +1 -0
  450. package/dist/services/platform-team-store.d.ts +16 -8
  451. package/dist/services/platform-team-store.d.ts.map +1 -1
  452. package/dist/services/platform-team-store.js +17 -10
  453. package/dist/services/platform-team-store.js.map +1 -1
  454. package/dist/services/project-scanner.d.ts.map +1 -1
  455. package/dist/services/project-scanner.js +13 -8
  456. package/dist/services/project-scanner.js.map +1 -1
  457. package/dist/services/resumable-session-discovery.d.ts.map +1 -1
  458. package/dist/services/resumable-session-discovery.js +117 -35
  459. package/dist/services/resumable-session-discovery.js.map +1 -1
  460. package/dist/services/structured-bridge-clis.d.ts +5 -3
  461. package/dist/services/structured-bridge-clis.d.ts.map +1 -1
  462. package/dist/services/structured-bridge-clis.js +5 -1
  463. package/dist/services/structured-bridge-clis.js.map +1 -1
  464. package/dist/services/vc-meeting-action-gate.d.ts.map +1 -1
  465. package/dist/services/vc-meeting-action-gate.js +15 -4
  466. package/dist/services/vc-meeting-action-gate.js.map +1 -1
  467. package/dist/services/vc-meeting-consumer-profile-bootstrap.d.ts +46 -66
  468. package/dist/services/vc-meeting-consumer-profile-bootstrap.d.ts.map +1 -1
  469. package/dist/services/vc-meeting-consumer-profile-bootstrap.js +33 -292
  470. package/dist/services/vc-meeting-consumer-profile-bootstrap.js.map +1 -1
  471. package/dist/services/vc-meeting-consumer-profile-templates.js +3 -3
  472. package/dist/services/vc-meeting-consumer-profile-templates.js.map +1 -1
  473. package/dist/services/vc-meeting-delivery-store.d.ts +18 -0
  474. package/dist/services/vc-meeting-delivery-store.d.ts.map +1 -1
  475. package/dist/services/vc-meeting-delivery-store.js +55 -0
  476. package/dist/services/vc-meeting-delivery-store.js.map +1 -1
  477. package/dist/services/vc-meeting-send-policy.d.ts +21 -1
  478. package/dist/services/vc-meeting-send-policy.d.ts.map +1 -1
  479. package/dist/services/vc-meeting-send-policy.js +30 -2
  480. package/dist/services/vc-meeting-send-policy.js.map +1 -1
  481. package/dist/services/vc-meeting-shared-consumer-catalog-store.d.ts +78 -0
  482. package/dist/services/vc-meeting-shared-consumer-catalog-store.d.ts.map +1 -0
  483. package/dist/services/vc-meeting-shared-consumer-catalog-store.js +227 -0
  484. package/dist/services/vc-meeting-shared-consumer-catalog-store.js.map +1 -0
  485. package/dist/services/vc-meeting-shared-consumer-catalog.d.ts +53 -0
  486. package/dist/services/vc-meeting-shared-consumer-catalog.d.ts.map +1 -0
  487. package/dist/services/vc-meeting-shared-consumer-catalog.js +161 -0
  488. package/dist/services/vc-meeting-shared-consumer-catalog.js.map +1 -0
  489. package/dist/setup/bot-config-editor.d.ts.map +1 -1
  490. package/dist/setup/bot-config-editor.js +1 -0
  491. package/dist/setup/bot-config-editor.js.map +1 -1
  492. package/dist/setup/open-platform-automation.d.ts +20 -0
  493. package/dist/setup/open-platform-automation.d.ts.map +1 -1
  494. package/dist/setup/open-platform-automation.js +27 -0
  495. package/dist/setup/open-platform-automation.js.map +1 -1
  496. package/dist/skills/customization-bundle.d.ts +83 -0
  497. package/dist/skills/customization-bundle.d.ts.map +1 -0
  498. package/dist/skills/customization-bundle.js +214 -0
  499. package/dist/skills/customization-bundle.js.map +1 -0
  500. package/dist/skills/definitions.d.ts.map +1 -1
  501. package/dist/skills/definitions.js +10 -3
  502. package/dist/skills/definitions.js.map +1 -1
  503. package/dist/skills/effective-builtins.d.ts +38 -0
  504. package/dist/skills/effective-builtins.d.ts.map +1 -0
  505. package/dist/skills/effective-builtins.js +96 -0
  506. package/dist/skills/effective-builtins.js.map +1 -0
  507. package/dist/skills/injection-mode.d.ts +4 -1
  508. package/dist/skills/injection-mode.d.ts.map +1 -1
  509. package/dist/skills/injection-mode.js +11 -3
  510. package/dist/skills/injection-mode.js.map +1 -1
  511. package/dist/skills/installer.d.ts.map +1 -1
  512. package/dist/skills/installer.js +24 -1
  513. package/dist/skills/installer.js.map +1 -1
  514. package/dist/skills/prompt-fragments.d.ts +58 -0
  515. package/dist/skills/prompt-fragments.d.ts.map +1 -0
  516. package/dist/skills/prompt-fragments.js +88 -0
  517. package/dist/skills/prompt-fragments.js.map +1 -0
  518. package/dist/types.d.ts +51 -0
  519. package/dist/types.d.ts.map +1 -1
  520. package/dist/utils/cli-usage-limit.d.ts +50 -0
  521. package/dist/utils/cli-usage-limit.d.ts.map +1 -1
  522. package/dist/utils/cli-usage-limit.js +43 -0
  523. package/dist/utils/cli-usage-limit.js.map +1 -1
  524. package/dist/utils/idle-detector.d.ts +12 -0
  525. package/dist/utils/idle-detector.d.ts.map +1 -1
  526. package/dist/utils/idle-detector.js +88 -2
  527. package/dist/utils/idle-detector.js.map +1 -1
  528. package/dist/utils/stuck-detector.d.ts +5 -0
  529. package/dist/utils/stuck-detector.d.ts.map +1 -1
  530. package/dist/utils/stuck-detector.js +41 -0
  531. package/dist/utils/stuck-detector.js.map +1 -1
  532. package/dist/utils/usage-limit-tracker.d.ts +46 -0
  533. package/dist/utils/usage-limit-tracker.d.ts.map +1 -0
  534. package/dist/utils/usage-limit-tracker.js +91 -0
  535. package/dist/utils/usage-limit-tracker.js.map +1 -0
  536. package/dist/utils/user-token.js +1 -1
  537. package/dist/utils/user-token.js.map +1 -1
  538. package/dist/worker.js +812 -125
  539. package/dist/worker.js.map +1 -1
  540. package/dist/workflows/definition.d.ts +14 -14
  541. package/dist/workflows/events/payloads.d.ts +12 -12
  542. package/dist/workflows/events/schema.d.ts +164 -164
  543. package/dist/workflows/migration/v2-to-v3.js +1 -1
  544. package/dist/workflows/migration/v2-to-v3.js.map +1 -1
  545. package/dist/workflows/v3/architect.d.ts.map +1 -1
  546. package/dist/workflows/v3/architect.js +11 -5
  547. package/dist/workflows/v3/architect.js.map +1 -1
  548. package/dist/workflows/v3/artifact-contract-declarations.d.ts +22 -0
  549. package/dist/workflows/v3/artifact-contract-declarations.d.ts.map +1 -0
  550. package/dist/workflows/v3/artifact-contract-declarations.js +95 -0
  551. package/dist/workflows/v3/artifact-contract-declarations.js.map +1 -0
  552. package/dist/workflows/v3/contract.d.ts +1 -0
  553. package/dist/workflows/v3/contract.d.ts.map +1 -1
  554. package/dist/workflows/v3/contract.js.map +1 -1
  555. package/dist/workflows/v3/daemon-run.d.ts +2 -2
  556. package/dist/workflows/v3/daemon-run.d.ts.map +1 -1
  557. package/dist/workflows/v3/daemon-run.js +4 -0
  558. package/dist/workflows/v3/daemon-run.js.map +1 -1
  559. package/dist/workflows/v3/dag.d.ts +7 -0
  560. package/dist/workflows/v3/dag.d.ts.map +1 -1
  561. package/dist/workflows/v3/dag.js +69 -8
  562. package/dist/workflows/v3/dag.js.map +1 -1
  563. package/dist/workflows/v3/ephemeral-pool.js +1 -1
  564. package/dist/workflows/v3/ephemeral-pool.js.map +1 -1
  565. package/dist/workflows/v3/event-contract.d.ts +3 -1
  566. package/dist/workflows/v3/event-contract.d.ts.map +1 -1
  567. package/dist/workflows/v3/host.d.ts.map +1 -1
  568. package/dist/workflows/v3/host.js +5 -1
  569. package/dist/workflows/v3/host.js.map +1 -1
  570. package/dist/workflows/v3/journal.d.ts +1 -1
  571. package/dist/workflows/v3/journal.d.ts.map +1 -1
  572. package/dist/workflows/v3/journal.js.map +1 -1
  573. package/dist/workflows/v3/library-materialize.d.ts.map +1 -1
  574. package/dist/workflows/v3/library-materialize.js +9 -1
  575. package/dist/workflows/v3/library-materialize.js.map +1 -1
  576. package/dist/workflows/v3/library-schema.d.ts +3 -1
  577. package/dist/workflows/v3/library-schema.d.ts.map +1 -1
  578. package/dist/workflows/v3/library-schema.js +20 -4
  579. package/dist/workflows/v3/library-schema.js.map +1 -1
  580. package/dist/workflows/v3/library-store.d.ts.map +1 -1
  581. package/dist/workflows/v3/library-store.js +15 -3
  582. package/dist/workflows/v3/library-store.js.map +1 -1
  583. package/dist/workflows/v3/run-envelope.d.ts +16 -16
  584. package/dist/workflows/v3/shared-node-runtime.d.ts +2 -1
  585. package/dist/workflows/v3/shared-node-runtime.d.ts.map +1 -1
  586. package/dist/workflows/v3/shared-node-runtime.js +48 -7
  587. package/dist/workflows/v3/shared-node-runtime.js.map +1 -1
  588. package/package.json +2 -1
  589. package/dist/dashboard-web/chunks/agent-workbench-dock-page-IKAC5CFL.js +0 -1
  590. package/dist/dashboard-web/chunks/agent-workbench-page-M53UN5EB.js +0 -1
  591. package/dist/dashboard-web/chunks/bot-defaults-page-YKE5SDZF.js +0 -10
  592. package/dist/dashboard-web/chunks/chunk-22WIADUT.js +0 -2
  593. package/dist/dashboard-web/chunks/chunk-24ONYQMR.js +0 -1
  594. package/dist/dashboard-web/chunks/chunk-2W6SCN3M.js +0 -1
  595. package/dist/dashboard-web/chunks/chunk-4XNJX6B3.js +0 -1
  596. package/dist/dashboard-web/chunks/chunk-5THX4DI2.js +0 -66
  597. package/dist/dashboard-web/chunks/chunk-7SZRL6FY.js +0 -1
  598. package/dist/dashboard-web/chunks/chunk-AGCPF6MT.js +0 -1
  599. package/dist/dashboard-web/chunks/chunk-FXW3V4JR.js +0 -1
  600. package/dist/dashboard-web/chunks/chunk-SYC6D5XU.js +0 -1
  601. package/dist/dashboard-web/chunks/connectors-page-VOISXXII.js +0 -1
  602. package/dist/dashboard-web/chunks/feedback-page-RN6HRZMS.js +0 -1
  603. package/dist/dashboard-web/chunks/groups-page-UQT6DCB7.js +0 -8
  604. package/dist/dashboard-web/chunks/monitoring-page-NKEKVQAP.js +0 -2
  605. package/dist/dashboard-web/chunks/office-page-GVJF73XW.js +0 -1
  606. package/dist/dashboard-web/chunks/overview-page-KHLV6VTI.js +0 -1
  607. package/dist/dashboard-web/chunks/plugin-page-J3OF5IY4.js +0 -1
  608. package/dist/dashboard-web/chunks/roles-page-WQIRSOLZ.js +0 -1
  609. package/dist/dashboard-web/chunks/schedules-page-J2DEY2X6.js +0 -1
  610. package/dist/dashboard-web/chunks/sessions-page-7BQFEA5P.js +0 -8
  611. package/dist/dashboard-web/chunks/settings-page-BJEIOFJH.js +0 -2
  612. package/dist/dashboard-web/chunks/skills-page-HGIFR3IU.js +0 -4
  613. package/dist/dashboard-web/chunks/team-federation-page-MR5ZPL4B.js +0 -1
  614. package/dist/dashboard-web/chunks/v3-page-GBR5JWPE.js +0 -94
  615. package/dist/dashboard-web/chunks/whiteboards-page-QAZM4BN3.js +0 -1
  616. package/dist/services/vc-meeting-consumer-profile-store.d.ts +0 -39
  617. package/dist/services/vc-meeting-consumer-profile-store.d.ts.map +0 -1
  618. package/dist/services/vc-meeting-consumer-profile-store.js +0 -191
  619. package/dist/services/vc-meeting-consumer-profile-store.js.map +0 -1
@@ -1,2 +0,0 @@
1
- import{a as Ie}from"./chunk-G5ZS2YUS.js";import{a as _,c as ue,j as Me,l as w,q as M}from"./chunk-5CJMHTT4.js";import{c as xe,d as S}from"./chunk-FXW3V4JR.js";import{a as ve}from"./chunk-24ONYQMR.js";import{w as be}from"./chunk-F6KNPF4R.js";import{a as Oe}from"./chunk-SYC6D5XU.js";import{a as we,d as ce}from"./chunk-5THX4DI2.js";import{c as ee}from"./chunk-7SZRL6FY.js";var p=ee(we(),1);var N=ee(we(),1);var a=ee(ce(),1),He=["transcript_received","chat_received","participant_joined","participant_left","magic_share_started","magic_share_ended"],he=8e3,_e=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,$e="\u6301\u7EED\u6574\u7406\u4F1A\u8BAE\u7EAA\u8981\uFF0C\u91CD\u70B9\u8BB0\u5F55\u5DF2\u786E\u8BA4\u7684\u51B3\u7B56\u3001\u5F85\u529E\u4E8B\u9879\uFF08\u542B\u8D1F\u8D23\u4EBA\u548C\u622A\u6B62\u65F6\u95F4\uFF09\u4EE5\u53CA\u672A\u89E3\u51B3\u98CE\u9669\uFF1B\u5B57\u5E55\u4FEE\u8BA2\u65F6\u66F4\u65B0\u5DF2\u6709\u6761\u76EE\uFF0C\u4E0D\u91CD\u590D\u8BB0\u5F55\u540C\u4E00\u4E8B\u9879\u3002\u4EC5\u5728\u51FA\u73B0\u65B0\u7684\u5173\u952E\u51B3\u7B56\u3001\u660E\u786E\u5F85\u529E\u6216\u98CE\u9669\uFF0C\u6216\u88AB\u7528\u6237\u70B9\u540D\u65F6\uFF0C\u624D\u5728\u76D1\u542C\u7FA4\u8F93\u51FA\u7B80\u6D01\u589E\u91CF\uFF1B\u65E0\u5B9E\u8D28\u589E\u91CF\u65F6\u4FDD\u6301\u9759\u9ED8\uFF0C\u4E0D\u53D1\u9001\u786E\u8BA4\u6216\u5FC3\u8DF3\u3002\u9700\u8981\u5411\u4F1A\u8BAE\u5185\u53D1\u9001\u6587\u5B57\u6216\u8BED\u97F3\u65F6\uFF0C\u5FC5\u987B\u901A\u8FC7 botmux \u53D7\u7BA1 request-output/action gate \u63D0\u4EA4\uFF0C\u4E0D\u5F97\u7ED5\u8FC7\u6743\u9650\u3001\u6240\u6709\u6743\u4E0E\u5BA1\u6838\u7B56\u7565\u3002",Re=0;function Ne(){return Re+=1,`p${Re}`}function De(e){return{...e,listenerPlacement:e.listenerPlacement??"auto",uiKey:Ne(),isNew:!1}}function Ve(e){let{uiKey:t,isNew:i,...r}=e;return r}function ye(e){return e.workingDirReady&&e.reliableTurnTerminal&&e.managedSideEffectEligible}function Be(e){return e.find(ye)?.appId??""}function z(e){return(0,a.jsxs)("span",{className:"vc-profile-field-head",children:[e.title,(0,a.jsx)(Me,{label:e.title,children:(0,a.jsx)("span",{className:"vc-profile-help",children:e.help})})]})}function Le(e){let t=S(),i=(0,N.useRef)(null);return(0,N.useEffect)(()=>{let r=i.current;if(!(!r||r.open))try{r.showModal()}catch{r.setAttribute("open","")}},[]),(0,a.jsxs)("dialog",{ref:i,className:["vc-profile-dialog",e.className].filter(Boolean).join(" "),onClose:e.onClose,onCancel:r=>{r.preventDefault(),e.onClose()},children:[(0,a.jsxs)("header",{className:"vc-profile-dialog-head",children:[(0,a.jsxs)("div",{children:[e.eyebrow?(0,a.jsx)("span",{children:e.eyebrow}):null,(0,a.jsx)("h3",{children:e.title})]}),(0,a.jsx)("button",{type:"button",className:"vc-profile-dialog-close","aria-label":t("settings.vcProfiles.close"),onClick:e.onClose})]}),(0,a.jsx)("div",{className:"vc-profile-dialog-body",children:e.children})]})}function Ue(e){let t=S();return e.enabled?e.canWrite?(0,a.jsx)(Fe,{canWrite:e.canWrite,listenerBotAppId:e.listenerBotAppId,listenerBotOptions:e.listenerBotOptions}):(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.needAuth")}):null}function Fe(e){let t=S(),i=xe(),r=(0,N.useRef)(!1),g=e.listenerBotOptions,[f,v]=(0,N.useState)(e.listenerBotAppId??g[0]?.larkAppId??""),[u,y]=(0,N.useState)(null),[T,h]=(0,N.useState)(null),[b,k]=(0,N.useState)(!1),[$,V]=(0,N.useState)(!1),[D,W]=(0,N.useState)(!1),[c,m]=(0,N.useState)(!1),[A,I]=(0,N.useState)({}),[te,q]=(0,N.useState)(!1),[ae,B]=(0,N.useState)(null),[le,Z]=(0,N.useState)(null);(0,N.useEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]);let J=(0,N.useRef)(0);(0,N.useEffect)(()=>{e.listenerBotAppId&&e.listenerBotAppId!==f&&!$&&v(e.listenerBotAppId)},[$,e.listenerBotAppId,f]);let K=(0,N.useCallback)(async s=>{let l=++J.current;if(y(null),V(!1),m(!1),I({}),B(null),Z(null),!s){h(null);return}k(!0);try{let o=await fetch(`/api/vc-meeting/consumer-profiles?listenerBotAppId=${encodeURIComponent(s)}`),d=await o.json().catch(()=>({}));if(!r.current||J.current!==l)return;!o.ok||d?.ok!==!0?(y(null),h(typeof d?.error=="string"?d.error:`HTTP ${o.status}`)):(y({forBot:s,revision:d.revision,catalogState:d.catalogState==="explicit_empty"||d.catalogState==="legacy_or_partial"||d.catalogState==="profiles"?d.catalogState:"uninitialized",defaultMode:d.defaultMode==="agents"?"agents":"listenOnly",defaultConsumerIds:Array.isArray(d.defaultConsumerIds)?d.defaultConsumerIds:[],profiles:(Array.isArray(d.profiles)?d.profiles:[]).map(De),agentOptions:Array.isArray(d.agentOptions)?d.agentOptions:[],templateCatalog:d.templateCatalog?.schemaVersion===1&&Array.isArray(d.templateCatalog.templates)?d.templateCatalog:{schemaVersion:1,templates:[]},...d.migrationOffer==="enable_seeded_minutes_default"?{migrationOffer:d.migrationOffer}:{}}),h(null),V(!1))}catch(o){if(!r.current||J.current!==l)return;y(null),h(o instanceof Error?o.message:String(o))}finally{r.current&&J.current===l&&k(!1)}},[]);(0,N.useEffect)(()=>{K(f)},[K,f]);let R=(0,N.useCallback)(s=>{y(l=>l&&s(l)),V(!0),q(!1)},[]),se=(0,N.useCallback)((s,l)=>{R(o=>({...o,profiles:o.profiles.map(d=>d.uiKey===s?{...d,...l}:d)}))},[R]),ge=(0,N.useCallback)(async()=>{if(!u||D||b||!u.forBot||u.forBot!==f)return;let s={};if(u.profiles.forEach((l,o)=>{_e.test(l.id)||(s[`profiles[${o}].id`]=t("settings.vcProfiles.idInvalid")),(l.instructions??"").length>he&&(s[`profiles[${o}].instructions`]=t("settings.vcProfiles.instructionsTooLong"))}),Object.keys(s).length>0){I(s);return}W(!0),m(!1),I({});try{let l=await fetch("/api/vc-meeting/consumer-profiles",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({listenerBotAppId:u.forBot,expectedRevision:u.revision,defaultMode:u.defaultMode,defaultConsumerIds:u.defaultConsumerIds,profiles:u.profiles.map(Ve)})}),o=await l.json().catch(()=>({}));if(!r.current||u.forBot!==f)return;if(l.status===409){m(!0);return}if(l.status===422){let d={};for(let C of Array.isArray(o?.fieldErrors)?o.fieldErrors:[])typeof C?.path=="string"&&typeof C?.message=="string"&&(d[C.path]=C.message);I(Object.keys(d).length>0?d:{profiles:t("settings.vcProfiles.validationFailed")});return}if(!l.ok||o?.ok!==!0){I({profiles:typeof o?.error=="string"?o.error:`HTTP ${l.status}`});return}y({forBot:u.forBot,revision:o.revision,catalogState:o.catalogState==="explicit_empty"||o.catalogState==="legacy_or_partial"||o.catalogState==="profiles"?o.catalogState:"uninitialized",defaultMode:o.defaultMode==="agents"?"agents":"listenOnly",defaultConsumerIds:Array.isArray(o.defaultConsumerIds)?o.defaultConsumerIds:[],profiles:(Array.isArray(o.profiles)?o.profiles:[]).map(De),agentOptions:Array.isArray(o.agentOptions)?o.agentOptions:[],templateCatalog:o.templateCatalog?.schemaVersion===1&&Array.isArray(o.templateCatalog.templates)?o.templateCatalog:{schemaVersion:1,templates:[]},...o.migrationOffer==="enable_seeded_minutes_default"?{migrationOffer:o.migrationOffer}:{}}),V(!1),q(!0)}catch(l){if(!r.current)return;I({profiles:l instanceof Error?l.message:String(l)})}finally{r.current&&W(!1)}},[u,D,f,t]),X=(0,N.useMemo)(()=>g.map(s=>({value:s.larkAppId,label:s.botName||s.larkAppId})),[g]),fe=X.find(s=>s.value===f)?.label??f,L=(0,N.useMemo)(()=>u?u.agentOptions.map(s=>{let l=[s.online?void 0:t("settings.vcProfiles.agentOffline"),s.workingDirReady?void 0:t("settings.vcProfiles.agentNoWorkingDir"),s.reliableTurnTerminal?void 0:t("settings.vcProfiles.agentNoReliableTerminal"),s.managedSideEffectEligible?void 0:t("settings.vcProfiles.agentNoManagedIsolation"),s.managedSideEffectEligible&&!s.sandboxIsolated?t("settings.vcProfiles.agentUnsandboxedRisk"):void 0].filter(Boolean),o=!ye(s);return{value:s.appId,disabled:o,label:(0,a.jsxs)("span",{className:"vc-agent-option",children:[(0,a.jsxs)("span",{className:"vc-agent-option-name",children:[s.label,s.cliId?(0,a.jsx)("em",{className:"vc-agent-option-cli",children:s.cliId}):null]}),l.length>0?(0,a.jsxs)("span",{className:"vc-agent-option-warn",children:["\u26A0 ",l.join(" \xB7 ")]}):null]})}}):[],[u,t]),pe=s=>{let l=u?.agentOptions.find(d=>d.appId===s);return l?!l.online||!l.workingDirReady||!l.reliableTurnTerminal||!l.managedSideEffectEligible||!l.sandboxIsolated?`\u26A0 ${l.label}`:l.label:s},x=(0,N.useCallback)(s=>{let o=["observe_only","meeting_text","meeting_voice","meeting_text_voice"].map(d=>({value:d,label:t(`settings.vcProfiles.preset.${d}`)}));return(!s.isNew||s.permissionPreset==="custom")&&o.push({value:"custom",label:t("settings.vcProfiles.preset.custom")}),o},[t]),oe=(0,N.useCallback)(()=>{let s=Ne();R(l=>({...l,profiles:[...l.profiles,{uiKey:s,isNew:!0,id:"",agentAppId:Be(l.agentOptions),responseMode:"silent",listenerPlacement:"auto",permissionPreset:"observe_only"}]})),B(s)},[R]),re=(0,N.useCallback)(s=>{let l=Ne();R(o=>{let d=new Set(o.profiles.map(P=>P.id)),C=s.suggestedProfileId;for(let P=2;d.has(C);P+=1)C=`${s.suggestedProfileId.slice(0,60)}-${P}`;return{...o,profiles:[...o.profiles,{uiKey:l,isNew:!0,id:C,label:s.profileLabel[i],agentAppId:Be(o.agentOptions),instructions:s.instructions[i],activityTypes:[...s.activityTypes],responseMode:s.responseMode,listenerPlacement:s.listenerPlacement,permissionPreset:s.permissionPreset}]}}),Z(null),B(l)},[i,R]),G=(0,N.useCallback)(s=>{R(l=>({...l,profiles:l.profiles.filter(o=>o.uiKey!==s),defaultConsumerIds:l.defaultConsumerIds.filter(o=>l.profiles.some(d=>d.uiKey!==s&&d.id===o))})),B(l=>l===s?null:l)},[R]);if(g.length===0)return null;let F=s=>A[s],Q=!e.canWrite||D||b,Y=u?.agentOptions.some(ye)??!1,ne=u?.profiles.findIndex(s=>s.uiKey===ae)??-1,H=ne>=0?u?.profiles[ne]??null:null,ie=u?.templateCatalog.templates.find(s=>s.templateId===le)??null,Se=(s,l)=>{s.id&&R(o=>{let d=l?[...new Set([...o.defaultConsumerIds,s.id])]:o.defaultConsumerIds.filter(C=>C!==s.id);return{...o,defaultMode:d.length>0?"agents":"listenOnly",defaultConsumerIds:d}})};return(0,a.jsxs)("div",{className:"vc-profiles-section",children:[(0,a.jsxs)("div",{className:"settings-field-row",children:[(0,a.jsx)(w,{help:t("settings.vcProfiles.help"),children:t("settings.vcProfiles.title")}),e.listenerBotAppId===null&&X.length>1?(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.listenerOwner")}),(0,a.jsx)(M,{className:"settings-field-menu",ariaLabel:t("settings.vcProfiles.listenerOwner"),disabled:b||D,value:f,label:_(X,f),options:X,onChange:s=>{s!==f&&($&&!window.confirm(t("settings.vcProfiles.discardConfirm"))||v(s))}})]}):(0,a.jsx)("span",{className:"vc-profile-config-target",children:t("settings.vcProfiles.configuringBot",{bot:fe})})]}),(0,a.jsx)("p",{className:"hint vc-profiles-freeze",children:t("settings.vcProfiles.freezeNotice")}),b?(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.loading")}):null,T?(0,a.jsx)("p",{className:"hint-warn",children:T==="bot_not_in_config"?t("settings.vcProfiles.botNotInConfig"):`${t("settings.vcProfiles.loadFailed")}: ${T}`}):null,c?(0,a.jsxs)("p",{className:"hint-warn",children:[t("settings.vcProfiles.conflict")," ",(0,a.jsx)("button",{type:"button",className:"vc-profiles-link",onClick:()=>{K(f)},children:t("settings.vcProfiles.reload")})]}):null,F("profiles")?(0,a.jsx)("p",{className:"hint-warn",children:F("profiles")}):null,u?(0,a.jsxs)(a.Fragment,{children:[u.migrationOffer==="enable_seeded_minutes_default"?(0,a.jsxs)("p",{className:"hint-warn vc-profile-migration-offer",children:[t("settings.vcProfiles.migrationOffer")," ",(0,a.jsx)("button",{type:"button",className:"vc-profiles-link",disabled:Q||$,onClick:()=>R(s=>({...s,defaultMode:"agents",defaultConsumerIds:["minutes"],profiles:s.profiles.map(l=>l.id==="minutes"?{...l,instructions:$e,responseMode:"listener_thread",permissionPreset:"meeting_text_voice"}:l),migrationOffer:void 0})),children:t("settings.vcProfiles.migrationEnable")})]}):null,u.catalogState==="uninitialized"&&u.profiles.length===0&&!Y?(0,a.jsx)("p",{className:"hint-warn",children:t("settings.vcProfiles.noEligibleDefaultAgent")}):null,u.catalogState==="legacy_or_partial"?(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.legacyCatalog")}):null,(0,a.jsxs)("section",{className:"vc-profile-library-section",children:[(0,a.jsxs)("div",{className:"vc-profile-list-heading",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.list.title")}),(0,a.jsx)("p",{children:t("settings.vcProfiles.list.help")})]}),e.canWrite?(0,a.jsx)("button",{type:"button",className:"vc-profiles-link vc-profile-add",disabled:D||b||!Y,title:Y?void 0:t("settings.vcProfiles.noEligibleDefaultAgent"),onClick:oe,children:t("settings.vcProfiles.add")}):null]}),u.profiles.length>0?(0,a.jsx)("div",{className:"vc-profile-card-grid",children:u.profiles.map(s=>{let l=u.agentOptions.find(d=>d.appId===s.agentAppId),o=u.defaultMode==="agents"&&u.defaultConsumerIds.includes(s.id);return(0,a.jsxs)("article",{className:"vc-profile-summary-card",role:"button",tabIndex:0,onClick:()=>B(s.uiKey),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),B(s.uiKey))},children:[(0,a.jsxs)("div",{className:"vc-profile-summary-top",children:[(0,a.jsx)("span",{className:"vc-profile-summary-icon","aria-hidden":"true",children:(s.label||s.id||"?").slice(0,1)}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:s.label||s.id||t("settings.vcProfiles.untitled")}),(0,a.jsx)("code",{children:s.id||t("settings.vcProfiles.newBadge")})]}),s.isNew?(0,a.jsx)("em",{children:t("settings.vcProfiles.newBadge")}):null]}),(0,a.jsx)("p",{children:(s.instructions??"").trim()||t("settings.vcProfiles.noInstructions")}),(0,a.jsxs)("div",{className:"vc-profile-summary-meta",children:[(0,a.jsx)("span",{children:l?.label??s.agentAppId}),(0,a.jsx)("span",{children:s.responseMode==="listener_thread"?t("settings.vcProfiles.responseListener"):t("settings.vcProfiles.responseSilent")})]}),(0,a.jsxs)("label",{className:"vc-profile-default-toggle",onClick:d=>d.stopPropagation(),children:[(0,a.jsx)("input",{type:"checkbox",checked:o,disabled:Q||!s.id,onChange:d=>Se(s,d.currentTarget.checked)}),(0,a.jsx)("span",{children:t("settings.vcProfiles.setDefault")})]})]},s.uiKey)})}):(0,a.jsx)("p",{className:"vc-profile-empty",children:t("settings.vcProfiles.list.empty")})]}),u.templateCatalog.templates.length>0?(0,a.jsxs)("section",{className:"vc-profile-template-catalog",children:[(0,a.jsxs)("div",{className:"vc-profile-template-heading",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.templates.title")}),(0,a.jsx)("p",{children:t("settings.vcProfiles.templates.help")})]}),(0,a.jsx)("span",{children:t("settings.vcProfiles.templates.builtinBadge")})]}),(0,a.jsx)("div",{className:"vc-profile-template-grid",children:u.templateCatalog.templates.map(s=>(0,a.jsxs)("button",{type:"button",className:"vc-profile-template-card",onClick:()=>Z(s.templateId),children:[(0,a.jsx)("span",{"aria-hidden":"true",children:"\u2726"}),(0,a.jsx)("strong",{children:s.title[i]}),(0,a.jsx)("p",{children:s.description[i]}),(0,a.jsxs)("em",{children:[t("settings.vcProfiles.viewDetails")," \u2192"]})]},`${s.templateId}@${s.version}`))})]}):null,(0,a.jsxs)("div",{className:"settings-field-row vc-profile-default-mode-row",children:[(0,a.jsx)(w,{help:t("settings.vcProfiles.defaultModeHelp"),children:t("settings.vcProfiles.defaultMode")}),(0,a.jsx)(M,{className:"settings-field-menu",ariaLabel:t("settings.vcProfiles.defaultMode"),disabled:Q,value:u.defaultMode,label:u.defaultMode==="agents"?t("settings.vcProfiles.defaultModeAgents"):t("settings.vcProfiles.defaultModeListenOnly"),options:[{value:"listenOnly",label:t("settings.vcProfiles.defaultModeListenOnly")},{value:"agents",label:t("settings.vcProfiles.defaultModeAgents")}],onChange:s=>R(l=>({...l,defaultMode:s==="agents"?"agents":"listenOnly"}))})]}),F("defaultConsumerIds")?(0,a.jsx)("em",{className:"vc-profile-err",children:F("defaultConsumerIds")}):null,F("defaultMode")?(0,a.jsx)("em",{className:"vc-profile-err",children:F("defaultMode")}):null,e.canWrite?(0,a.jsxs)("div",{className:"vc-profiles-actions",children:[(0,a.jsx)("button",{type:"button",className:"vc-profiles-save",disabled:!$||D||c,onClick:()=>{ge()},children:t(D?"settings.vcProfiles.saving":"settings.vcProfiles.save")}),te?(0,a.jsx)("span",{className:"vc-profile-hint",children:t("settings.vcProfiles.saved")}):null,$&&!D?(0,a.jsx)("span",{className:"vc-profile-hint",children:t("settings.vcProfiles.unsaved")}):null]}):null,H?(0,a.jsx)(We,{profile:H,index:ne,frozen:Q,canWrite:e.canWrite,agentOptions:L,agentLabel:pe(H.agentAppId),presetOptions:x(H),error:F,onClose:()=>B(null),onUpdate:s=>se(H.uiKey,s),onIdChange:s=>{let l=H.id;R(o=>({...o,profiles:o.profiles.map(d=>d.uiKey===H.uiKey?{...d,id:s}:d),defaultConsumerIds:o.defaultConsumerIds.map(d=>d===l&&l?s:d).filter(Boolean)}))},onRemove:()=>G(H.uiKey)}):null,ie?(0,a.jsx)(Ze,{template:ie,locale:i,disabled:Q||!Y,onClose:()=>Z(null),onUse:()=>re(ie)}):null]}):null]})}function We(e){let t=S(),{profile:i,index:r}=e;return(0,a.jsxs)(Le,{className:"vc-profile-editor-dialog",eyebrow:t("settings.vcProfiles.list.title"),title:i.label||i.id||t("settings.vcProfiles.untitled"),onClose:e.onClose,children:[(0,a.jsxs)("div",{className:"vc-profile-grid",children:[(0,a.jsxs)("label",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(z,{title:t("settings.vcProfiles.fieldId"),help:t("settings.vcProfiles.idHelp")})}),(0,a.jsx)("input",{type:"text",value:i.id,disabled:e.frozen||!i.isNew,placeholder:"minutes",onChange:g=>e.onIdChange(g.currentTarget.value)}),e.error(`profiles[${r}].id`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${r}].id`)}):null]}),(0,a.jsxs)("label",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(z,{title:t("settings.vcProfiles.fieldLabel"),help:t("settings.vcProfiles.labelHelp")})}),(0,a.jsx)("input",{type:"text",value:i.label??"",disabled:e.frozen,onChange:g=>e.onUpdate({label:g.currentTarget.value||void 0})}),e.error(`profiles[${r}].label`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${r}].label`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(z,{title:t("settings.vcProfiles.fieldAgent"),help:t("settings.vcProfiles.agentHelp")})}),(0,a.jsx)(M,{className:"vc-profile-agent-menu",ariaLabel:t("settings.vcProfiles.fieldAgent"),disabled:e.frozen,value:i.agentAppId,label:e.agentLabel,options:e.agentOptions,onChange:g=>e.onUpdate({agentAppId:g})}),e.error(`profiles[${r}].agentAppId`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${r}].agentAppId`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(z,{title:t("settings.vcProfiles.fieldResponseMode"),help:t("settings.vcProfiles.responseModeHelp")})}),(0,a.jsx)(M,{ariaLabel:t("settings.vcProfiles.fieldResponseMode"),disabled:e.frozen,value:i.responseMode,label:i.responseMode==="listener_thread"?t("settings.vcProfiles.responseListener"):t("settings.vcProfiles.responseSilent"),options:[{value:"silent",label:t("settings.vcProfiles.responseSilent")},{value:"listener_thread",label:t("settings.vcProfiles.responseListener")}],onChange:g=>e.onUpdate({responseMode:g})}),e.error(`profiles[${r}].responseMode`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${r}].responseMode`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(z,{title:t("settings.vcProfiles.fieldListenerPlacement"),help:t("settings.vcProfiles.listenerPlacementHelp")})}),(0,a.jsx)(M,{ariaLabel:t("settings.vcProfiles.fieldListenerPlacement"),disabled:e.frozen||i.responseMode==="silent",value:i.listenerPlacement??"auto",label:t(`settings.vcProfiles.listenerPlacement.${i.listenerPlacement??"auto"}`),options:["auto","chat","topic"].map(g=>({value:g,label:t(`settings.vcProfiles.listenerPlacement.${g}`)})),onChange:g=>e.onUpdate({listenerPlacement:g})}),e.error(`profiles[${r}].listenerPlacement`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${r}].listenerPlacement`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(z,{title:t("settings.vcProfiles.fieldPreset"),help:t("settings.vcProfiles.presetHelp")})}),(0,a.jsx)(M,{ariaLabel:t("settings.vcProfiles.fieldPreset"),disabled:e.frozen,value:i.permissionPreset,label:_(e.presetOptions,i.permissionPreset),options:e.presetOptions,onChange:g=>e.onUpdate({permissionPreset:g})}),e.error(`profiles[${r}].permissionPreset`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${r}].permissionPreset`)}):null]})]}),(0,a.jsxs)("label",{className:"vc-profile-field vc-profile-instructions",children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(z,{title:t("settings.vcProfiles.fieldInstructions"),help:t("settings.vcProfiles.instructionsHelp")}),(0,a.jsxs)("em",{className:"vc-profile-count",children:[(i.instructions??"").length,"/",he]})]}),(0,a.jsx)("textarea",{rows:7,maxLength:he,value:i.instructions??"",disabled:e.frozen,placeholder:t("settings.vcProfiles.instructionsPlaceholder"),onChange:g=>e.onUpdate({instructions:g.currentTarget.value||void 0})}),e.error(`profiles[${r}].instructions`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${r}].instructions`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(z,{title:t("settings.vcProfiles.fieldActivityTypes"),help:t("settings.vcProfiles.activityHelp")})}),(0,a.jsx)("div",{className:"vc-profile-activity",children:He.map(g=>{let f=i.activityTypes?.includes(g)??!1;return(0,a.jsxs)("label",{className:"vc-profile-check",children:[(0,a.jsx)("input",{type:"checkbox",checked:f,disabled:e.frozen,onChange:v=>{let u=new Set(i.activityTypes??[]);v.currentTarget.checked?u.add(g):u.delete(g),e.onUpdate({activityTypes:u.size>0?[...u]:void 0})}}),t(`settings.vcProfiles.activity.${g}`)]},g)})}),(0,a.jsx)("em",{className:"vc-profile-hint",children:t("settings.vcProfiles.activityAllHint")}),e.error(`profiles[${r}].activityTypes`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${r}].activityTypes`)}):null]}),e.canWrite?(0,a.jsxs)("footer",{className:"vc-profile-dialog-actions",children:[(0,a.jsx)("button",{type:"button",className:"vc-profiles-link vc-profile-remove",disabled:e.frozen,onClick:e.onRemove,children:t("settings.vcProfiles.remove")}),(0,a.jsx)("button",{type:"button",className:"vc-profile-dialog-done",onClick:e.onClose,children:t("settings.vcProfiles.done")})]}):null]})}function Ze(e){let t=S(),i=e.template;return(0,a.jsxs)(Le,{className:"vc-profile-template-dialog",eyebrow:t("settings.vcProfiles.templates.title"),title:i.title[e.locale],onClose:e.onClose,children:[(0,a.jsx)("p",{className:"vc-profile-template-description",children:i.description[e.locale]}),(0,a.jsxs)("div",{className:"vc-profile-template-facts",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.fieldResponseMode")}),(0,a.jsx)("strong",{children:t(i.responseMode==="listener_thread"?"settings.vcProfiles.responseListener":"settings.vcProfiles.responseSilent")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.fieldListenerPlacement")}),(0,a.jsx)("strong",{children:t(`settings.vcProfiles.listenerPlacement.${i.listenerPlacement}`)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.fieldPreset")}),(0,a.jsx)("strong",{children:t(`settings.vcProfiles.preset.${i.permissionPreset}`)})]})]}),(0,a.jsxs)("section",{className:"vc-profile-template-prompt",children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.fieldInstructions")}),(0,a.jsx)("p",{children:i.instructions[e.locale]})]}),(0,a.jsxs)("section",{className:"vc-profile-template-events",children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.fieldActivityTypes")}),(0,a.jsx)("div",{children:i.activityTypes.map(r=>(0,a.jsx)("span",{children:t(`settings.vcProfiles.activity.${r}`)},r))})]}),(0,a.jsxs)("footer",{className:"vc-profile-dialog-actions",children:[(0,a.jsx)("button",{type:"button",className:"vc-profile-dialog-secondary",onClick:e.onClose,children:t("settings.vcProfiles.close")}),(0,a.jsx)("button",{type:"button",className:"vc-profile-template-use",disabled:e.disabled,onClick:e.onUse,children:t("settings.vcProfiles.templates.use")})]})]})}var n=ee(ce(),1),Pe=["Asia/Shanghai","Asia/Hong_Kong","Asia/Tokyo","Asia/Singapore","Asia/Kolkata","UTC","Europe/London","Europe/Paris","Europe/Moscow","America/Los_Angeles","America/New_York","America/Sao_Paulo","Australia/Sydney"];function Ke(e,t){if(!e||typeof e!="object")return null;if(e.failed){let i=e.failed.step==="install"?t("settings.herdrTraexInstallStepInstall"):t("settings.herdrTraexInstallStepAction");return{text:`${t("settings.herdrTraexInstallFailed")}\uFF08${i}\uFF09: ${e.failed.reason??""}`,cls:"hint-warn-inline"}}if(e.skippedReason==="plugin_unsupported"){let i=typeof e.herdrVersion=="string"&&e.herdrVersion?` (${e.herdrVersion})`:"";return{text:`${t("settings.herdrTraexUnsupported")}${i}`,cls:"hint-warn-inline"}}return e.installed||e.actionInvoked?{text:t("settings.herdrTraexInstalled"),cls:"hint-ok"}:e.alreadyInstalled?{text:t("settings.herdrTraexAlreadyInstalled"),cls:"hint-ok"}:null}function ke(e){return{groupNamePrefix:typeof e?.groupNamePrefix=="string"?e.groupNamePrefix:"",publicReadOnly:e?.publicReadOnly===!0,openTerminalInFeishu:e?.openTerminalInFeishu===!0,enableLocalCliOpen:e?.enableLocalCliOpen===!0,localCliOpenMode:e?.localCliOpenMode==="resume"?"resume":"attach",chatBotDiscovery:e?.chatBotDiscovery!==!1,herdrTraexPlugin:{enabled:e?.herdrTraexPlugin?.enabled===!0,source:typeof e?.herdrTraexPlugin?.source=="string"?e.herdrTraexPlugin.source:"",ref:typeof e?.herdrTraexPlugin?.ref=="string"?e.herdrTraexPlugin.ref:"",recommendedSource:typeof e?.herdrTraexPlugin?.recommendedSource=="string"?e.herdrTraexPlugin.recommendedSource:"",recommendedRef:typeof e?.herdrTraexPlugin?.recommendedRef=="string"?e.herdrTraexPlugin.recommendedRef:""},codexRpcInput:e?.codexRpcInput===!0,bypassCodexHookTrust:e?.bypassCodexHookTrust!==!1,codexNotifier:{enabled:e?.codexNotifier?.enabled===!0,targetBotAppId:typeof e?.codexNotifier?.targetBotAppId=="string"?e.codexNotifier.targetBotAppId:null,notifyWhen:e?.codexNotifier?.notifyWhen==="always"?"always":"locked_only",platformSupported:e?.codexNotifier?.platformSupported===!0,hookInstalled:e?.codexNotifier?.hookInstalled===!0,botOptions:Array.isArray(e?.codexNotifier?.botOptions)?e.codexNotifier.botOptions:[],targetDaemonOnline:e?.codexNotifier?.targetDaemonOnline===!0,pendingCount:Number.isSafeInteger(e?.codexNotifier?.pendingCount)?Math.max(0,e.codexNotifier.pendingCount):0,workerOnline:e?.codexNotifier?.workerOnline===!0,lastError:e?.codexNotifier?.lastError&&typeof e.codexNotifier.lastError.message=="string"?e.codexNotifier.lastError:null},hostOverloadAlert:{enabled:e?.hostOverloadAlert?.enabled===!0,targetBotAppId:typeof e?.hostOverloadAlert?.targetBotAppId=="string"?e.hostOverloadAlert.targetBotAppId:null,enterLoadRatio:typeof e?.hostOverloadAlert?.enterLoadRatio=="number"?e.hostOverloadAlert.enterLoadRatio:1.5,enterMemUsedFrac:typeof e?.hostOverloadAlert?.enterMemUsedFrac=="number"?e.hostOverloadAlert.enterMemUsedFrac:.92,botOptions:Array.isArray(e?.hostOverloadAlert?.botOptions)?e.hostOverloadAlert.botOptions:[],targetDaemonOnline:e?.hostOverloadAlert?.targetDaemonOnline===!0},noVisibleOutputHint:e?.noVisibleOutputHint===!0,vcMeetingAgent:{enabled:e?.vcMeetingAgent?.enabled!==!1,listenerBotAppId:typeof e?.vcMeetingAgent?.listenerBotAppId=="string"?e.vcMeetingAgent.listenerBotAppId:null,listenerBotOptions:Array.isArray(e?.vcMeetingAgent?.listenerBotOptions)?e.vcMeetingAgent.listenerBotOptions:[],larkCliVersion:e?.vcMeetingAgent?.larkCliVersion===void 0?void 0:e.vcMeetingAgent.larkCliVersion??null,larkCliMeetsRequirement:e?.vcMeetingAgent?.larkCliMeetsRequirement===!0,larkCliMinVersion:typeof e?.vcMeetingAgent?.larkCliMinVersion=="string"?e.vcMeetingAgent.larkCliMinVersion:void 0},repoPickerMode:e?.repoPickerMode==="repos"?"repos":"all",maintenance:e?.maintenance&&typeof e.maintenance=="object"?e.maintenance:{},localDevInstall:e?.localDevInstall===!0,autoUpdateSupported:e?.autoUpdateSupported!==!1,whiteboard:{enabled:e?.whiteboard?.enabled===!0},workflow:{enabled:e?.workflow?.enabled!==!1},remoteAccess:e?.remoteAccess===!0,scheduleTimeZone:typeof e?.scheduleTimeZone=="string"?e.scheduleTimeZone:"",hostTimeZone:typeof e?.hostTimeZone=="string"&&e.hostTimeZone?e.hostTimeZone:"UTC",effectiveScheduleTimeZone:typeof e?.effectiveScheduleTimeZone=="string"&&e.effectiveScheduleTimeZone?e.effectiveScheduleTimeZone:typeof e?.scheduleTimeZone=="string"&&e.scheduleTimeZone?e.scheduleTimeZone:typeof e?.hostTimeZone=="string"&&e.hostTimeZone?e.hostTimeZone:"UTC"}}function je(e,t){let i=e?.[t]??{};return{enabled:i.enabled===!0,time:typeof i.time=="string"?i.time:"04:00"}}function Ee(e,t){return t(e==="npm-global"?"update.kindNpm":e==="pnpm-global"?"update.kindPnpm":e==="yarn-global"?"update.kindYarn":e==="bun-global"?"update.kindBun":e==="source-checkout"?"update.kindSource":"update.kindUnknown")}function ze(){let e=S(),t=(0,p.useRef)(!1),i=(0,p.useRef)(new Set),[r,g]=(0,p.useState)(null),[f,v]=(0,p.useState)(!1),[u,y]=(0,p.useState)(null),[T,h]=(0,p.useState)(!0),[b,k]=(0,p.useState)(!1),[$,V]=(0,p.useState)(null),[D,W]=(0,p.useState)(null),[c,m]=(0,p.useState)(null),[A,I]=(0,p.useState)(null),[te,q]=(0,p.useState)(null),[ae,B]=(0,p.useState)(null),[le,Z]=(0,p.useState)(!1),[J,K]=(0,p.useState)(!0),[R,se]=(0,p.useState)(!1),[ge,X]=(0,p.useState)(""),[fe,L]=(0,p.useState)(!1),[pe,x]=(0,p.useState)(null),oe=(0,p.useCallback)(()=>{for(let l of i.current)window.clearTimeout(l);i.current.clear()},[]),re=(0,p.useCallback)((l,o)=>{let d=window.setTimeout(()=>{i.current.delete(d),l()},o);return i.current.add(d),d},[]),G=(0,p.useCallback)(async()=>{try{let l=await fetch("/api/update/status"),o=await l.json().catch(()=>({}));if(!t.current)return;if(!l.ok){I(null),q(o?.error??`HTTP ${l.status}`);return}I(o),q(null)}catch(l){if(!t.current)return;I(null),q(l instanceof Error?l.message:String(l))}},[]),F=(0,p.useCallback)(async()=>{try{let l=await fetch("/api/settings"),o=await l.json().catch(()=>({}));if(!t.current)return;if(!l.ok){g(null),y(o?.error??`HTTP ${l.status}`),v(!0);return}g(ke(o.settings)),h(o.authed===!0),k(o.bound===!0),y(null),v(!0)}catch(l){if(!t.current)return;g(null),y(l instanceof Error?l.message:String(l)),v(!0)}},[]);(0,p.useEffect)(()=>(t.current=!0,F(),()=>{t.current=!1,oe()}),[oe,F]),(0,p.useEffect)(()=>{f&&(L(!1),x(null),Z(!1),T&&G())},[T,G,f]);async function Q(l,o,d){if(!r)return;let C=r;g(d(r)),V(l),W({text:e("settings.saving")});try{let P=await fetch("/api/settings",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(o)}),U=await P.json().catch(()=>({}));if(!t.current)return;if(!P.ok||U.ok===!1)throw typeof U?.feishuLoginQr=="string"&&U.feishuLoginQr&&m(U.feishuLoginQr),new Error(U?.error??`HTTP ${P.status}`);m(null);let j=ke(U.settings);g(j),be.publicReadOnly=j.publicReadOnly,ve.setScheduleTimeZone(j.effectiveScheduleTimeZone);let de=Ke(U.herdrTraexInstall,e);W(de??{text:e("settings.saved"),cls:"hint-ok"})}catch(P){if(!t.current)return;let U=!1;try{let de=await fetch("/api/settings"),Te=await de.json().catch(()=>({}));if(t.current&&de.ok&&Te?.settings){let me=ke(Te.settings);g(me),be.publicReadOnly=me.publicReadOnly,ve.setScheduleTimeZone(me.effectiveScheduleTimeZone),U=!0}}catch{}if(!t.current)return;U||g(C);let j=P instanceof Error?P.message:String(P);W({text:U?`${e("settings.saveReconciled")}: ${j}`:`${e("settings.saveFailed")}: ${j}`,cls:"hint-warn-inline"})}finally{t.current&&V(null)}}async function Y(){B(null),K(!0),se(!1);try{let l=await fetch("/api/update/changelog"),o=await l.json().catch(()=>({}));if(!t.current)return;X(typeof o?.releasesUrl=="string"?o.releasesUrl:""),l.ok?(B(Array.isArray(o.releases)?o.releases:[]),K(o.ok!==!1),se(o.rateLimited===!0)):(B([]),K(!1))}catch{if(!t.current)return;B([]),K(!1)}}function ne(){let l=Date.now(),o=async()=>{if(t.current){if(Date.now()-l>9e4){L(!1),x({text:e("update.restartSlow"),cls:"hint-warn-inline"});return}try{let d=await fetch("/__health",{cache:"no-store"});if(!t.current)return;if(d.ok){location.reload();return}}catch{}t.current&&re(()=>{o()},2e3)}};re(()=>{o()},3e3)}async function H(l){L(!0),x({text:e("update.restarting")});try{let o=await fetch("/api/update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(l?{update:l}:{})}),d=await o.json().catch(()=>({}));if(!o.ok||d.ok===!1){if(d.error==="update_target_unavailable"||d.error==="update_target_drifted"){if(!t.current)return;L(!1),x({text:e(`update.${d.error}`,{dir:String(d.dir??"")}),cls:"hint-warn-inline"}),G();return}throw new Error(String(d.detail??d.error??`HTTP ${o.status}`))}if(!t.current)return}catch(o){if(!t.current)return;L(!1),x({text:e("update.restartFailed",{detail:o instanceof Error?o.message:String(o)}),cls:"hint-warn-inline"});return}ne()}async function ie(){let l=A;if(!l)return;if(!l.node.ok){window.alert(e("update.nodeTooOldAlert",{version:l.node.version,required:l.node.required}));return}let o=l.localDevInstall===!0;if(o){if(!l.localDevUpdatable){window.alert(e("update.localDev"));return}}else if(!l.updateSupported||!l.updateCommand){window.alert(e("update.unsupportedInstall"));return}if(l.installs.multiple){let C=l.installs.entries.map(P=>`\u2022 ${P.binPath} (${Ee(P.kind,e)})`).join(`
2
- `);if(!window.confirm(e("update.confirmMultiInstall",{paths:C})))return}let d=o?e("update.confirmUpdateLocalDev"):l.latest?e("update.confirmUpdate",{version:`v${l.latest}`,command:l.updateCommand}):e("update.confirmUpdateNoVer",{command:l.updateCommand});if(window.confirm(d)){L(!0),x({text:o?e("update.updatingLocalDev"):e("update.updating",{command:l.updateCommand})});try{let C=await fetch("/api/update/run",{method:"POST"}),P=await C.json().catch(()=>({}));if(!t.current)return;if(!C.ok||P.ok===!1){if(P?.error==="dirty_worktree"){L(!1),x({text:e("update.dirtyWorktree",{detail:String(P.detail??"")}),cls:"hint-warn-inline"});return}let j=P?.detail??P?.error??`HTTP ${C.status}`;L(!1),x({text:e("update.updateFailed",{detail:j}),cls:"hint-warn-inline"});return}Ie(P)?(L(!1),x({text:P.changed?e("update.updatedChanged",{old:`v${P.oldVersion}`,new:`v${P.newVersion}`}):e("update.builtNeedsRestart"),cls:"hint-ok"}),window.confirm(e("update.confirmRestart"))?await H({oldVersion:P.oldVersion,newVersion:P.newVersion}):t.current&&x({text:e("update.noRestartHint"),cls:"hint-ok"})):(L(!1),x({text:e("update.alreadyLatestRun",{version:`v${P.newVersion}`}),cls:"hint-ok"}),await G())}catch(C){if(!t.current)return;L(!1),x({text:e("update.updateFailed",{detail:C instanceof Error?C.message:String(C)}),cls:"hint-warn-inline"})}}}let s=r?(0,n.jsx)(qe,{settings:r,canWrite:T,bound:b,savingKey:$,message:D,updateBlock:(0,n.jsx)(nt,{canWrite:T,status:A,statusError:te,changelog:ae,changelogOpen:le,changelogOk:J,changelogRateLimited:R,releasesUrl:ge,busy:fe,message:pe,onCheck:()=>{I(null),B(null),Z(!1),x(null),q(null),G()},onToggleChangelog:()=>{let l=!le;Z(l),l&&ae===null&&Y()},onUpdate:()=>{ie()},onRestart:()=>{window.confirm(e("update.confirmPlainRestart"))&&H(null)}}),feishuLoginQr:c,onCloseFeishuLoginQr:()=>m(null),onSave:Q}):u?(0,n.jsxs)("p",{className:"hint-warn",children:[e("settings.loadFailed"),": ",u]}):(0,n.jsx)(ue,{label:e("settings.loading")});return(0,n.jsxs)("section",{className:"page settings-page",children:[(0,n.jsx)("div",{className:"page-heading",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"eyebrow",children:e("nav.settings")}),(0,n.jsx)("h1",{children:e("settings.title")})]})}),s]})}function qe(e){let t=S(),{settings:i,canWrite:r,bound:g,savingKey:f}=e,v=!r,u=je(i.maintenance,"autoUpdate"),y=!r||i.localDevInstall||!i.autoUpdateSupported,T=!r||i.maintenance.autoUpdate?.enabled!==!0,h=(c,m)=>{e.onSave(c,{[c]:m},A=>({...A,[c]:m}))},b=c=>e.onSave("herdrTraexPlugin",{herdrTraexPlugin:c},m=>({...m,herdrTraexPlugin:{...m.herdrTraexPlugin,...c}})),k=c=>e.onSave("codexNotifier",{codexNotifier:c},m=>({...m,codexNotifier:{...m.codexNotifier,...c}})),$=c=>e.onSave("hostOverloadAlert",{hostOverloadAlert:c},m=>({...m,hostOverloadAlert:{...m.hostOverloadAlert,...c}})),V=(0,p.useMemo)(()=>[{value:"all",label:t("settings.repoPickerModeAll")},{value:"repos",label:t("settings.repoPickerModeRepos")}],[t]),D=(0,p.useMemo)(()=>[{value:"attach",label:t("settings.localCliOpenModeAttach")},{value:"resume",label:t("settings.localCliOpenModeResume")}],[t]),W=(0,p.useMemo)(()=>[{value:"",label:t("settings.vcMeetingListenerBotAuto")},...i.vcMeetingAgent.listenerBotOptions.map(c=>{let m=c.botName||c.larkAppId,A=c.cliId?` \xB7 ${c.cliId}`:"",I=[c.vcMeetingAgentEnabled===!0?void 0:t("settings.vcMeetingListenerBotDisabled"),c.hasLarkCliProfile===!0?void 0:t("settings.vcMeetingListenerBotNoProfile")].filter(Boolean),te=I.length>0?` \xB7 ${I.join(" \xB7 ")}`:"";return{value:c.larkAppId,label:`${m}${A}${te}`}})],[i.vcMeetingAgent.listenerBotOptions,t]);return(0,n.jsxs)("div",{className:"settings-layout",children:[r?null:(0,n.jsx)("article",{className:"bd-card settings-card settings-alert-card",children:(0,n.jsx)("p",{className:"hint-warn",children:t("settings.readOnlyVisitor")})}),(0,n.jsx)(Ce,{title:t("settings.moduleGeneral"),description:t("settings.moduleGeneralHelp"),children:(0,n.jsxs)(Ae,{className:"settings-group-main",children:[(0,n.jsxs)(E,{title:t("settings.sectionAccess"),children:[(0,n.jsx)(O,{title:t("settings.publicReadOnly"),help:t("settings.publicReadOnlyHelp"),checked:i.publicReadOnly,disabled:v||f==="publicReadOnly",onChange:c=>h("publicReadOnly",c)}),g?(0,n.jsx)(O,{title:t("settings.remoteAccess"),help:t("settings.remoteAccessHelp"),checked:i.remoteAccess,disabled:v||f==="remoteAccess",onChange:c=>h("remoteAccess",c)}):null]}),(0,n.jsxs)(E,{title:t("settings.sectionCards"),children:[(0,n.jsx)(O,{title:t("settings.openTerminalInFeishu"),help:t("settings.openTerminalInFeishuHelp"),checked:i.openTerminalInFeishu,disabled:v||f==="openTerminalInFeishu",onChange:c=>h("openTerminalInFeishu",c)}),(0,n.jsx)(O,{title:t("settings.enableLocalCliOpen"),help:t("settings.enableLocalCliOpenHelp"),checked:i.enableLocalCliOpen,disabled:v||f==="enableLocalCliOpen",onChange:c=>h("enableLocalCliOpen",c)}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(w,{help:t("settings.localCliOpenModeHelp"),children:t("settings.localCliOpenMode")}),(0,n.jsx)(M,{className:"settings-field-menu",ariaLabel:t("settings.localCliOpenMode"),disabled:v||!i.enableLocalCliOpen||f==="localCliOpenMode",value:i.localCliOpenMode,label:_(D,i.localCliOpenMode),options:D,onChange:c=>{e.onSave("localCliOpenMode",{localCliOpenMode:c},m=>({...m,localCliOpenMode:c}))}})]})]}),(0,n.jsx)(E,{title:t("settings.sectionGroupCreation"),children:(0,n.jsx)(et,{value:i.groupNamePrefix,disabled:v||f==="groupNamePrefix",onSave:c=>e.onSave("groupNamePrefix",{groupNamePrefix:c},m=>({...m,groupNamePrefix:c}))})}),(0,n.jsxs)(E,{title:t("settings.sectionExperimental"),children:[(0,n.jsx)(O,{title:t("settings.chatBotDiscovery"),help:t("settings.chatBotDiscoveryHelp"),checked:i.chatBotDiscovery,disabled:v||f==="chatBotDiscovery",onChange:c=>h("chatBotDiscovery",c)}),(0,n.jsx)(O,{title:t("settings.herdrTraexPlugin"),help:t("settings.herdrTraexPluginHelp"),checked:i.herdrTraexPlugin.enabled,disabled:v||f==="herdrTraexPlugin",onChange:c=>b({enabled:c})}),i.herdrTraexPlugin.enabled?(0,n.jsx)(tt,{value:i.herdrTraexPlugin,disabled:v||f==="herdrTraexPlugin",onSave:c=>b(c)}):null,(0,n.jsx)(O,{title:t("settings.codexRpcInput"),help:t("settings.codexRpcInputHelp"),checked:i.codexRpcInput,disabled:v||f==="codexRpcInput",onChange:c=>h("codexRpcInput",c)}),(0,n.jsx)(O,{title:t("settings.bypassCodexHookTrust"),help:t("settings.bypassCodexHookTrustHelp"),checked:i.bypassCodexHookTrust,disabled:v||f==="bypassCodexHookTrust",onChange:c=>h("bypassCodexHookTrust",c)}),(0,n.jsx)(Qe,{value:i.codexNotifier,disabled:v,saving:f==="codexNotifier",onSave:k}),(0,n.jsx)(O,{title:t("settings.noVisibleOutputHint"),help:t("settings.noVisibleOutputHintHelp"),checked:i.noVisibleOutputHint,disabled:v||f==="noVisibleOutputHint",onChange:c=>h("noVisibleOutputHint",c)})]}),(0,n.jsx)(E,{title:t("settings.sectionHostOverloadAlert"),children:(0,n.jsx)(Je,{value:i.hostOverloadAlert,disabled:v,saving:f==="hostOverloadAlert",onSave:$})}),(0,n.jsx)(E,{title:t("settings.sectionWhiteboard"),children:(0,n.jsx)(O,{title:t("settings.whiteboardEnable"),help:t("settings.whiteboardEnableHelp"),checked:i.whiteboard.enabled,disabled:v||f==="whiteboard",onChange:c=>{e.onSave("whiteboard",{whiteboard:{enabled:c}},m=>({...m,whiteboard:{enabled:c}}))}})}),(0,n.jsx)(E,{title:t("settings.sectionWorkflow"),children:(0,n.jsx)(O,{title:t("settings.workflowEnable"),help:t("settings.workflowEnableHelp"),checked:i.workflow.enabled,disabled:v||f==="workflow",onChange:c=>{e.onSave("workflow",{workflow:{enabled:c}},m=>({...m,workflow:{enabled:c}}))}})}),(0,n.jsx)(E,{title:t("settings.sectionRepoPicker"),children:(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(w,{help:t("settings.repoPickerModeHelp"),children:t("settings.repoPickerMode")}),(0,n.jsx)(M,{className:"settings-field-menu",ariaLabel:t("settings.repoPickerMode"),disabled:v||f==="repoPickerMode",value:i.repoPickerMode,label:_(V,i.repoPickerMode),options:V,onChange:c=>{e.onSave("repoPickerMode",{repoPickerMode:c},m=>({...m,repoPickerMode:c}))}})]})}),(0,n.jsx)(E,{title:t("settings.sectionSchedule"),children:(0,n.jsx)(Xe,{value:i.scheduleTimeZone,host:i.hostTimeZone,effective:i.effectiveScheduleTimeZone,disabled:v||f==="scheduleTimeZone",onSave:c=>{e.onSave("scheduleTimeZone",{scheduleTimeZone:c},m=>({...m,scheduleTimeZone:c??""}))}})})]})}),(0,n.jsx)(Ce,{className:"settings-module-meeting",title:t("settings.moduleMeeting"),description:t("settings.moduleMeetingHelp"),children:(0,n.jsx)(Ae,{className:"settings-group-meeting",children:(0,n.jsxs)(E,{className:"settings-vc-block",title:t("settings.sectionVcMeetingAgent"),children:[(0,n.jsx)(O,{title:t("settings.vcMeetingAgent"),help:t("settings.vcMeetingAgentHelp"),checked:i.vcMeetingAgent.enabled,disabled:v||f==="vcMeetingAgent",onChange:c=>{e.onSave("vcMeetingAgent",{vcMeetingAgent:{enabled:c}},m=>({...m,vcMeetingAgent:{...m.vcMeetingAgent,enabled:c}}))}}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(w,{help:t("settings.vcMeetingListenerBotHelp"),children:t("settings.vcMeetingListenerBot")}),(0,n.jsx)(M,{className:"settings-field-menu",ariaLabel:t("settings.vcMeetingListenerBot"),disabled:v||f==="vcMeetingAgent",value:i.vcMeetingAgent.listenerBotAppId??"",label:_(W,i.vcMeetingAgent.listenerBotAppId??""),options:W,onChange:c=>{let m=c||null;e.onSave("vcMeetingAgent",{vcMeetingAgent:{listenerBotAppId:m}},A=>({...A,vcMeetingAgent:{...A.vcMeetingAgent,listenerBotAppId:m}}))}})]}),(0,n.jsx)(Ge,{settings:i.vcMeetingAgent}),(0,n.jsx)(Ue,{enabled:i.vcMeetingAgent.enabled,canWrite:r,listenerBotAppId:i.vcMeetingAgent.listenerBotAppId,listenerBotOptions:i.vcMeetingAgent.listenerBotOptions}),e.feishuLoginQr?(0,n.jsxs)("div",{className:"settings-feishu-login",children:[(0,n.jsx)("button",{type:"button",className:"settings-feishu-login-close","aria-label":t("settings.feishuLoginClose"),title:t("settings.feishuLoginClose"),onClick:e.onCloseFeishuLoginQr}),(0,n.jsx)("p",{children:t("settings.feishuLoginRequired")}),(0,n.jsx)("img",{src:e.feishuLoginQr,alt:t("settings.feishuLoginQrAlt")})]}):null]})})}),(0,n.jsx)(Ce,{title:t("settings.moduleSystem"),description:t("settings.moduleSystemHelp"),children:(0,n.jsxs)(Ae,{className:"settings-group-ops",children:[(0,n.jsx)(E,{title:t("settings.sectionMaintenance"),titleExtra:i.localDevInstall?(0,n.jsx)("span",{className:"settings-title-note",children:t("settings.autoUpdateLocalDev")}):i.autoUpdateSupported?null:(0,n.jsx)("span",{className:"settings-title-note",children:t("settings.autoUpdateUnsupportedInstall")}),children:(0,n.jsxs)("div",{className:"settings-maintenance-grid",children:[(0,n.jsxs)("div",{className:"settings-maintenance-update",children:[(0,n.jsx)(O,{title:t("settings.autoUpdate"),help:t("settings.autoUpdateHelp"),checked:u.enabled,disabled:y||f==="autoUpdate",onChange:c=>{let m={enabled:c,time:u.time};e.onSave("autoUpdate",{maintenance:{autoUpdate:m}},A=>({...A,maintenance:{...A.maintenance,autoUpdate:m}}))}}),(0,n.jsx)("div",{className:"maint-time",children:(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:t("settings.maintenanceTime")}),(0,n.jsx)("input",{type:"time",value:u.time,disabled:y||f==="autoUpdate",onChange:c=>{let m={enabled:u.enabled,time:c.currentTarget.value||"04:00"};e.onSave("autoUpdate",{maintenance:{autoUpdate:m}},A=>({...A,maintenance:{...A.maintenance,autoUpdate:m}}))}})]})})]}),(0,n.jsx)("div",{className:"settings-maintenance-restart",children:(0,n.jsx)(O,{title:t("settings.autoRestart"),help:t("settings.autoRestartHelp"),checked:i.maintenance.autoRestart?.enabled===!0,disabled:T||f==="autoRestart",onChange:c=>{let m={enabled:c};e.onSave("autoRestart",{maintenance:{autoRestart:m}},A=>({...A,maintenance:{...A.maintenance,autoRestart:m}}))}})})]})}),e.updateBlock]})}),(0,n.jsx)("div",{className:"settings-status-row",children:(0,n.jsx)("span",{className:`oncall-status ${e.message?.cls??""}`,"data-settings-status":!0,children:e.message?.text??""})})]})}function Ce(e){let t=["settings-module",e.className].filter(Boolean).join(" ");return(0,n.jsxs)("section",{className:t,children:[(0,n.jsxs)("header",{className:"settings-module-heading",children:[(0,n.jsx)("h2",{children:e.title}),(0,n.jsx)("p",{children:e.description})]}),e.children]})}function Ge(e){let t=S(),i=e.settings.larkCliVersion,r=typeof i=="string"&&e.settings.larkCliMeetsRequirement===!0,g=r?t("settings.larkCliReady",{version:i}):typeof i=="string"?t("settings.larkCliOutdated",{version:i,minimum:e.settings.larkCliMinVersion??"-"}):t("settings.larkCliMissing");return(0,n.jsxs)("div",{className:`settings-lark-cli-status ${r?"is-ready":"is-warning"}`,children:[(0,n.jsx)("span",{"aria-hidden":"true"}),(0,n.jsx)("strong",{children:g}),r?null:(0,n.jsx)("code",{children:"npm i -g @larksuite/cli@latest"})]})}function Ae(e){let t=["settings-group",e.className].filter(Boolean).join(" ");return(0,n.jsx)("section",{className:t,children:(0,n.jsx)("article",{className:"bd-card settings-group-card",children:e.children})})}function E(e){let t=["settings-block",e.className].filter(Boolean).join(" ");return(0,n.jsx)("section",{className:t,children:(0,n.jsxs)("article",{className:"bd-card settings-card",children:[(0,n.jsxs)("div",{className:"settings-block-title-row",children:[(0,n.jsx)("h2",{className:"bd-section-title",children:e.title}),e.titleExtra?(0,n.jsx)("div",{className:"settings-block-title-extra",children:e.titleExtra}):null]}),e.children]})})}function Qe(e){let t=S(),[i,r]=(0,p.useState)(!1),g=(0,p.useRef)(!1),f=(0,p.useMemo)(()=>[{value:"",label:t("settings.codexNotifierTargetPlaceholder")},...e.value.botOptions.map(k=>({value:k.larkAppId,label:[k.botName||k.larkAppId,k.cliId].filter(Boolean).join(" \xB7 ")}))],[e.value.botOptions,t]),v=(0,p.useMemo)(()=>[{value:"locked_only",label:t("settings.codexNotifierLockedOnly")},{value:"always",label:t("settings.codexNotifierAlways")}],[t]),u=e.value.botOptions.find(k=>k.larkAppId===e.value.targetBotAppId),y=!e.value.targetBotAppId||u?.recipientConfigured!==!0||u?.recipientVerified!==!0||!e.value.targetDaemonOnline||!e.value.platformSupported&&e.value.notifyWhen==="locked_only",T=e.value.enabled||i,h=e.disabled||e.saving;(0,p.useEffect)(()=>{if(!i||e.value.enabled||y){g.current=!1;return}h||g.current||(g.current=!0,e.onSave({enabled:!0}))},[h,y,i,e.onSave,e.value.enabled]),(0,p.useEffect)(()=>{e.value.enabled&&i&&r(!1)},[i,e.value.enabled]);let b=k=>{if(!k){g.current=!1,r(!1),e.value.enabled&&e.onSave({enabled:!1});return}if(y){r(!0);return}e.onSave({enabled:!0})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(O,{title:t("settings.codexNotifier"),help:t("settings.codexNotifierHelp"),checked:e.value.enabled||i,disabled:h,onChange:b}),T?(0,n.jsxs)("div",{className:"settings-codex-notifier-details",children:[e.value.enabled?null:(0,n.jsx)("p",{className:"settings-subfield-hint",children:t("settings.codexNotifierEnablePending")}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(w,{help:t("settings.codexNotifierTargetHelp"),children:t("settings.codexNotifierTarget")}),(0,n.jsx)(M,{className:"settings-field-menu",ariaLabel:t("settings.codexNotifierTarget"),disabled:h,searchable:!0,value:e.value.targetBotAppId??"",label:_(f,e.value.targetBotAppId??""),options:f,onChange:k=>{e.onSave({targetBotAppId:k||null})}})]}),u?.recipientHint?(0,n.jsx)("p",{className:"settings-subfield-hint",children:t("settings.codexNotifierRecipient",{recipient:u.recipientHint})}):null,(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(w,{help:t("settings.codexNotifierNotifyWhenHelp"),children:t("settings.codexNotifierNotifyWhen")}),(0,n.jsx)(M,{className:"settings-field-menu",ariaLabel:t("settings.codexNotifierNotifyWhen"),disabled:h,value:e.value.notifyWhen,label:_(v,e.value.notifyWhen),options:v,onChange:k=>{e.onSave({notifyWhen:k})}})]}),e.value.targetBotAppId?u?.recipientConfigured!==!0?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierRecipientMissing")}):e.value.targetDaemonOnline?u?.recipientVerified!==!0?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierRecipientUnverified")}):!e.value.platformSupported&&e.value.notifyWhen==="locked_only"?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierUnsupported")}):e.value.enabled?e.value.hookInstalled?e.value.workerOnline?e.value.lastError?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierLastError",{error:e.value.lastError.message})}):e.value.pendingCount>0?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierPending",{count:e.value.pendingCount})}):null:(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierWorkerPending")}):(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierHookPending")}):null:(0,n.jsx)("p",{className:"hint-warn-inline",children:t(e.value.enabled?"settings.codexNotifierDaemonOffline":"settings.codexNotifierTargetOffline")}):(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierTargetRequired")})]}):null]})}function Je(e){let t=S(),i=e.disabled||e.saving,r=(0,p.useMemo)(()=>[{value:"",label:t("settings.hostOverloadAlertTargetPlaceholder")},...e.value.botOptions.map(b=>({value:b.larkAppId,label:[b.botName||b.larkAppId,b.cliId].filter(Boolean).join(" \xB7 ")}))],[e.value.botOptions,t]),g=e.value.botOptions.find(b=>b.larkAppId===e.value.targetBotAppId),[f,v]=(0,p.useState)(String(e.value.enterLoadRatio)),[u,y]=(0,p.useState)(String(Math.round(e.value.enterMemUsedFrac*100)));(0,p.useEffect)(()=>{v(String(e.value.enterLoadRatio))},[e.value.enterLoadRatio]),(0,p.useEffect)(()=>{y(String(Math.round(e.value.enterMemUsedFrac*100)))},[e.value.enterMemUsedFrac]);let T=()=>{let b=Number(f);Number.isFinite(b)&&b>0&&b!==e.value.enterLoadRatio?e.onSave({enterLoadRatio:b}):v(String(e.value.enterLoadRatio))},h=()=>{let b=Number(u),k=b/100;Number.isFinite(b)&&b>0&&b<=100&&k!==e.value.enterMemUsedFrac?e.onSave({enterMemUsedFrac:k}):y(String(Math.round(e.value.enterMemUsedFrac*100)))};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(O,{title:t("settings.hostOverloadAlert"),help:t("settings.hostOverloadAlertHelp"),checked:e.value.enabled,disabled:i||!e.value.enabled&&!e.value.targetBotAppId,onChange:b=>{e.onSave({enabled:b})}}),(0,n.jsxs)("div",{className:"settings-codex-notifier-details",children:[(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(w,{help:t("settings.hostOverloadAlertTargetHelp"),children:t("settings.hostOverloadAlertTarget")}),(0,n.jsx)(M,{className:"settings-field-menu",ariaLabel:t("settings.hostOverloadAlertTarget"),disabled:i,searchable:!0,value:e.value.targetBotAppId??"",label:_(r,e.value.targetBotAppId??""),options:r,onChange:b=>{e.onSave({targetBotAppId:b||null})}})]}),g?.recipientHint?(0,n.jsx)("p",{className:"settings-subfield-hint",children:t("settings.hostOverloadAlertRecipient",{recipient:g.recipientHint})}):null,(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(w,{help:t("settings.hostOverloadAlertEnterLoadHelp"),children:t("settings.hostOverloadAlertEnterLoad")}),(0,n.jsx)("input",{type:"number",min:.1,step:.1,className:"settings-text-input",value:f,disabled:i,onChange:b=>v(b.currentTarget.value),onBlur:T,onKeyDown:b=>{b.key==="Enter"&&T()}})]}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(w,{help:t("settings.hostOverloadAlertEnterMemHelp"),children:t("settings.hostOverloadAlertEnterMem")}),(0,n.jsx)("input",{type:"number",min:1,max:100,step:1,className:"settings-text-input",value:u,disabled:i,onChange:b=>y(b.currentTarget.value),onBlur:h,onKeyDown:b=>{b.key==="Enter"&&h()}})]}),e.value.targetBotAppId?g?.recipientConfigured!==!0?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.hostOverloadAlertRecipientMissing")}):e.value.targetDaemonOnline?g?.recipientVerified!==!0?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.hostOverloadAlertRecipientUnverified")}):null:(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.hostOverloadAlertTargetOffline")}):(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.hostOverloadAlertTargetRequired")})]})]})}function Xe(e){let t=S(),i=e.value.trim(),r=e.effective||e.value.trim()||e.host,g=(0,p.useMemo)(()=>{let f=i&&!Pe.includes(i)?[i,...Pe]:Pe;return[{value:"",label:t("settings.scheduleTimeZoneHost",{host:e.host})},...f.map(v=>({value:v,label:v}))]},[e.host,t,i]);return(0,n.jsxs)("div",{className:"settings-field-row settings-timezone-row",children:[(0,n.jsx)(w,{help:t("settings.scheduleTimeZoneHelp",{host:e.host,effective:r}),children:t("settings.scheduleTimeZone")}),(0,n.jsx)(M,{className:"settings-field-menu settings-timezone-menu",ariaLabel:t("settings.scheduleTimeZone"),value:i,label:_(g,i),options:g,disabled:e.disabled,onChange:f=>e.onSave(f===""?null:f)})]})}function O(e){return(0,n.jsxs)("label",{className:"toggle-row",children:[(0,n.jsx)("input",{type:"checkbox",checked:e.checked,disabled:e.disabled,onChange:t=>e.onChange(t.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch","aria-hidden":"true"}),(0,n.jsx)("span",{className:"toggle-tx",children:(0,n.jsx)("strong",{children:(0,n.jsx)(w,{className:"settings-toggle-title",help:e.help,children:e.title})})})]})}var Ye=32;function et(e){let t=S(),[i,r]=(0,p.useState)(e.value);(0,p.useEffect)(()=>r(e.value),[e.value]);let g=i.trim().length>0,f=i===""||g,v=i!==e.value,u=()=>{e.disabled||!v||!f||e.onSave(i)};return(0,n.jsxs)("div",{className:"settings-subfield settings-group-prefix-editor",children:[(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(w,{help:t("settings.groupNamePrefixHelp"),children:t("settings.groupNamePrefix")}),(0,n.jsx)("input",{className:"settings-text-input",type:"text",value:i,maxLength:Ye,placeholder:t("settings.groupNamePrefixPlaceholder"),disabled:e.disabled,onChange:y=>r(y.currentTarget.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),u())}})]}),(0,n.jsx)("p",{className:"settings-subfield-hint","data-group-name-prefix-preview":!0,children:g?t("settings.groupNamePrefixPreview",{name:`${i}${t("settings.groupNamePrefixPreviewName")}`}):t("settings.groupNamePrefixDisabled")}),(0,n.jsx)("div",{className:"actions",children:(0,n.jsx)("button",{type:"button",className:"page-primary-action",disabled:e.disabled||!v||!f,onClick:u,children:t("settings.groupNamePrefixSave")})})]})}function tt(e){let t=S(),[i,r]=(0,p.useState)(e.value.source),[g,f]=(0,p.useState)(e.value.ref);(0,p.useEffect)(()=>{r(e.value.source),f(e.value.ref)},[e.value.source,e.value.ref]);let v=i.trim(),u=g.trim(),y=v!==e.value.source.trim()||u!==e.value.ref.trim(),T=()=>{e.disabled||!y||e.onSave({source:v,ref:u})};return(0,n.jsxs)("div",{className:"settings-subfield",children:[(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(w,{help:t("settings.herdrTraexPluginSourceHelp"),children:t("settings.herdrTraexPluginSource")}),(0,n.jsx)("input",{className:"settings-text-input",type:"text",value:i,placeholder:t("settings.herdrTraexPluginSourcePlaceholder"),disabled:e.disabled,onChange:h=>r(h.currentTarget.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),T())}})]}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(w,{help:t("settings.herdrTraexPluginRefHelp"),children:t("settings.herdrTraexPluginRef")}),(0,n.jsx)("input",{className:"settings-text-input",type:"text",value:g,placeholder:t("settings.herdrTraexPluginRefPlaceholder"),disabled:e.disabled,onChange:h=>f(h.currentTarget.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),T())}})]}),v?null:(0,n.jsx)("p",{className:"hint-warn-inline settings-subfield-hint",children:t("settings.herdrTraexPluginSourceRequired")}),e.value.recommendedSource&&(v!==e.value.recommendedSource||u!==e.value.recommendedRef)?(0,n.jsxs)("p",{className:"settings-subfield-hint",children:[t("settings.herdrTraexPluginRecommended")," ",(0,n.jsxs)("button",{type:"button",className:"settings-inline-link",disabled:e.disabled,onClick:()=>{r(e.value.recommendedSource),f(e.value.recommendedRef)},children:[e.value.recommendedSource,e.value.recommendedRef?` @ ${e.value.recommendedRef}`:""]})]}):null,(0,n.jsx)("div",{className:"actions",children:(0,n.jsx)("button",{type:"button",className:"page-primary-action",disabled:e.disabled||!y,onClick:T,children:t("settings.herdrTraexPluginSave")})})]})}function nt(e){let t=S(),i;if(!e.canWrite)i=(0,n.jsx)("p",{className:"hint-warn",children:t("update.loginRequired")});else if(e.statusError)i=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"hint-warn",children:[t("update.checkFailed"),": ",e.statusError]}),(0,n.jsx)("div",{className:"update-actions",children:(0,n.jsx)("button",{type:"button","data-up":"check",onClick:e.onCheck,children:t("update.btnCheck")})})]});else if(!e.status)i=(0,n.jsx)(ue,{label:t("update.loading"),compact:!0});else{let r=e.status,g=e.busy||(r.localDevInstall?!r.localDevUpdatable:!r.updateSupported),f=r.localDevInstall?t("update.btnUpdateLocalDev"):t("update.btnUpdate");i=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"update-version",children:[(0,n.jsxs)("span",{children:[t("update.current"),": ",(0,n.jsxs)("strong",{children:["v",r.current]})]})," ",(0,n.jsx)(at,{status:r})]}),r.node.ok?null:(0,n.jsx)("p",{className:"hint-warn",children:t("update.nodeWarn",{version:r.node.version,required:r.node.required})}),!r.localDevInstall&&!r.updateSupported?(0,n.jsx)("p",{className:"hint-warn",children:t("update.unsupportedInstall")}):null,r.localDevInstall?(0,n.jsx)("p",{className:"hint",children:r.localDevUpdatable?t("update.localDevUpdatable"):t("update.localDev")}):null,r.installs.multiple?(0,n.jsx)(lt,{entries:r.installs.entries}):null,(0,n.jsxs)("div",{className:"update-actions",children:[(0,n.jsx)("button",{type:"button","data-up":"check",disabled:e.busy,onClick:e.onCheck,children:t("update.btnCheck")}),(0,n.jsx)("button",{type:"button","data-up":"changelog",disabled:e.busy,onClick:e.onToggleChangelog,children:e.changelogOpen?t("update.btnChangelogHide"):t("update.btnChangelog")}),(0,n.jsx)("button",{type:"button",className:"page-primary-action","data-up":"update",disabled:g,onClick:e.onUpdate,children:f}),(0,n.jsx)("button",{type:"button","data-up":"restart",disabled:e.busy,onClick:e.onRestart,children:t("update.btnRestart")})]}),r.cliUpdates?.length?(0,n.jsx)(it,{entries:r.cliUpdates}):null,e.changelogOpen?(0,n.jsx)(st,{changelog:e.changelog,ok:e.changelogOk,rateLimited:e.changelogRateLimited,releasesUrl:e.releasesUrl}):null,e.message?(0,n.jsx)("p",{className:`oncall-status ${e.message.cls??""}`,children:e.message.text}):null]})}return(0,n.jsx)(E,{className:"settings-update-block",title:t("update.section"),titleExtra:e.status?.localDevInstall?(0,n.jsx)("span",{className:"settings-title-note",children:e.status.localDevUpdatable?t("update.localDevNote"):t("update.localDev")}):e.status&&!e.status.updateSupported?(0,n.jsx)("span",{className:"settings-title-note",children:t("update.unsupportedInstall")}):null,children:i})}function it(e){let t=S();return(0,n.jsxs)("div",{className:"cli-runtime-updates",children:[(0,n.jsx)("strong",{children:t("update.runtimeTitle")}),(0,n.jsx)("ul",{children:e.entries.map(i=>(0,n.jsxs)("li",{className:i.updateAvailable?"is-behind":"",children:[(0,n.jsxs)("div",{className:"cli-runtime-update-head",children:[(0,n.jsx)("span",{children:i.displayName}),i.updateAvailable&&i.latest?(0,n.jsx)("span",{className:"update-badge update-badge-new",children:t("update.runtimeAvailable",{current:i.current??"?",latest:i.latest})}):i.managed?i.latest?(0,n.jsx)("span",{className:"update-badge update-badge-ok",children:t("update.upToDate")}):(0,n.jsx)("span",{className:"hint-warn-inline",children:t("update.checkUnavailable")}):(0,n.jsx)("span",{className:"hint-warn-inline",children:t("update.runtimeUnmanaged")})]}),(0,n.jsx)("code",{children:i.binPath}),i.updateAvailable&&i.updateCommand?(0,n.jsxs)("small",{children:[t("update.runtimeCommand"),": ",(0,n.jsx)("code",{children:i.updateCommand})]}):null]},`${i.runtimeId}:${i.binPath}`))}),(0,n.jsx)("p",{className:"settings-help",children:t("update.runtimeHelp")})]})}function at(e){let t=S(),i=e.status;return i.latest?i.behind?(0,n.jsx)("span",{className:"update-badge update-badge-new",children:t("update.newAvailable",{version:`v${i.latest}`})}):(0,n.jsx)("span",{className:"update-badge update-badge-ok",children:t("update.upToDate")}):(0,n.jsx)("span",{className:"hint-warn-inline",children:t("update.checkUnavailable")})}function lt(e){let t=S();return(0,n.jsxs)("div",{className:"hint-warn",children:[(0,n.jsx)("p",{children:t("update.multiInstallWarn")}),(0,n.jsx)("ul",{className:"update-install-list",children:e.entries.map(i=>(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:i.binPath})," \u2192 ",Ee(i.kind,t)," ",(0,n.jsx)("small",{children:i.root})]},`${i.binPath}:${i.root}`))})]})}function st(e){let t=S();if(e.changelog===null)return(0,n.jsx)(ue,{label:t("update.changelogLoading"),compact:!0});if(!e.ok){let i=e.rateLimited?t("update.changelogRateLimited"):t("update.changelogFailed");return(0,n.jsxs)("p",{className:"hint-warn-inline",children:[i,e.releasesUrl?(0,n.jsxs)(n.Fragment,{children:[" ",(0,n.jsx)("a",{href:e.releasesUrl,target:"_blank",rel:"noopener",children:t("update.changelogViewOnGitHub")})]}):null]})}return e.changelog.length===0?(0,n.jsx)("p",{className:"empty",children:t("update.changelogEmpty")}):(0,n.jsx)("div",{className:"update-changelog",children:e.changelog.map(i=>{let r=i.name&&i.name!==`v${i.version}`?i.name:"",g=i.publishedAt?new Date(i.publishedAt).toLocaleDateString():"";return(0,n.jsxs)("details",{className:"update-release",open:!0,children:[(0,n.jsxs)("summary",{children:[(0,n.jsxs)("strong",{children:["v",i.version]})," ",r," ",(0,n.jsx)("small",{children:g})," ",(0,n.jsx)("a",{href:i.url,target:"_blank",rel:"noopener",children:"\u2197"})]}),(0,n.jsx)("pre",{className:"update-release-body",children:i.body||""})]},i.version)})})}function bt(e){return Oe(e,(0,n.jsx)(ze,{}))}export{Qe as CodexNotifierSettingsEditor,et as GroupNamePrefixRow,Je as HostOverloadAlertSettingsEditor,Xe as TimeZoneRow,bt as renderSettingsPage};
@@ -1,4 +0,0 @@
1
- import{b as Ye,c as vl,d as ue,h as bl,l as hl}from"./chunk-5CJMHTT4.js";import{d as Z}from"./chunk-FXW3V4JR.js";import"./chunk-24ONYQMR.js";import{C as Ve}from"./chunk-F6KNPF4R.js";import{a as fl}from"./chunk-SYC6D5XU.js";import{a as Ae,b as ds,d as de}from"./chunk-5THX4DI2.js";import{c as ee}from"./chunk-7SZRL6FY.js";var c=ee(Ae(),1),Bl=ee(ds(),1);var J=ee(Ae(),1);var k=ee(de(),1);function us(e){return(e.missingSkills?.length??0)>0?"missing":(e.references?.length??0)===0?"unassigned":"complete"}function yl(e){let l=Z(),n=e.packs??[],m=e.skills??[],[f,p]=(0,J.useState)(!1),[g,S]=(0,J.useState)(null),[o,D]=(0,J.useState)(null),[B,v]=(0,J.useState)(null),[C,w]=(0,J.useState)(!1),h=()=>{S(null),p(!0)},x=y=>{S(y),p(!0)},[E,T]=(0,J.useState)(()=>new Set),{focusPackId:L,focusPackIds:A,onFocusConsumed:$}=e;(0,J.useEffect)(()=>{if(!(!L&&(A?.length??0)===0)){if(L){let y=n.find(b=>b.id===L);y&&(S(y),p(!0)),T(new Set([L]))}else A&&T(new Set(A));$?.()}},[L,A]);let H=()=>{p(!1),S(null),D({text:l("skills.saved"),ok:!0}),e.onRefresh()},K=async y=>{try{let b=await fetch(`/api/skill-packs/${encodeURIComponent(y.id)}`,{method:"DELETE"}),I=await b.json().catch(()=>({}));if(b.ok){D({text:l("skills.packDeleted",{name:y.name}),ok:!0}),e.onRefresh();return}if(b.status===409&&I?.error==="SKILL_PACK_IN_USE"){let d=Array.isArray(I?.references)?I.references:y.references??[];v({pack:y,references:d});return}throw new Error(I?.error??`HTTP ${b.status}`)}catch(b){D({text:`${l("skills.failed")}: ${b?.message??b}`,ok:!1})}},F=async()=>{if(B){w(!0);try{let y=await fetch(`/api/skill-packs/${encodeURIComponent(B.pack.id)}?force=1`,{method:"DELETE"}),b=await y.json().catch(()=>({}));if(!y.ok)throw new Error(b?.error??`HTTP ${y.status}`);D({text:l("skills.packDeleted",{name:B.pack.name}),ok:!0}),v(null),e.onRefresh()}catch(y){D({text:`${l("skills.failed")}: ${y?.message??y}`,ok:!1})}finally{w(!1)}}};return(0,k.jsxs)("section",{className:"skills-config-block",children:[(0,k.jsx)(ue,{title:l("skills.packs"),count:e.packsKnown===!1?"\u2014":l("skills.packCount",{count:n.length}),hint:l("skills.packsHelp")}),o&&(0,k.jsx)("p",{className:`hint-${o.ok?"ok":"warn"}`,children:o.text}),(0,k.jsx)("div",{className:"bd-card skills-config-card",children:e.packsKnown===!1&&n.length===0?(0,k.jsxs)("div",{className:"skills-empty-state","data-packs-unknown":!0,children:[(0,k.jsx)("p",{className:"hint-warn",children:l("skills.packsUnknown")}),(0,k.jsx)("button",{className:"bd-button",onClick:()=>e.onRefresh(),children:l("skills.refresh")})]}):n.length===0?(0,k.jsxs)("div",{className:"skills-empty-state",children:[(0,k.jsx)("p",{children:l("skills.packsEmpty")}),(0,k.jsx)("button",{className:"bd-button primary",onClick:h,children:l("skills.packCreate")})]}):(0,k.jsxs)("div",{className:"skills-pack-grid",children:[(0,k.jsxs)("button",{className:"skills-pack-create-tile",onClick:h,children:[(0,k.jsx)("span",{className:"skills-pack-create-plus",children:"+"}),(0,k.jsx)("span",{children:l("skills.packCreate")})]}),n.map(y=>{let b=us(y);return(0,k.jsxs)("div",{className:`skills-pack-card${E.has(y.id)?" skills-pack-card-focus":""}`,children:[(0,k.jsxs)("div",{className:"skills-pack-card-head",children:[(0,k.jsxs)("div",{className:"skills-pack-title",children:[(0,k.jsx)("strong",{children:y.name}),(0,k.jsx)("code",{className:"skills-pack-id",children:y.id})]}),(0,k.jsx)("span",{className:`skills-pack-health skills-pack-health-${b}`,children:b==="complete"?"\u2713":b==="missing"?"!":"\u25CB"})]}),y.description&&(0,k.jsx)("p",{className:"skills-pack-desc",children:y.description}),(0,k.jsxs)("div",{className:"skills-pack-meta",children:[(0,k.jsx)("span",{className:"skills-pack-meta-item",children:l("skills.skillCount",{count:y.include.length})}),(0,k.jsx)("span",{className:"skills-pack-meta-item",children:l("skills.packRefCount",{count:y.references?.length??0})})]}),y.tags&&y.tags.length>0&&(0,k.jsx)("div",{className:"skills-pack-tags",children:y.tags.map(I=>(0,k.jsx)("span",{className:"skills-pack-tag",children:I},I))}),(y.references?.length??0)>0&&(0,k.jsx)("div",{className:"skills-pack-refs",children:y.references.map(I=>(0,k.jsx)("button",{type:"button",className:"skills-pack-ref-chip","data-action":"open-pack-bot",disabled:!e.onOpenBot,onClick:()=>e.onOpenBot?.(I.larkAppId),children:I.botName},I.larkAppId))}),(y.missingSkills?.length??0)>0&&(0,k.jsxs)("div",{className:"skills-pack-missing",children:[l("skills.packMissing"),":"," ",y.missingSkills.map(I=>(0,k.jsx)("button",{type:"button",className:"skills-missing-skill-chip","data-action":"install-missing-skill",title:l("skills.installMissingHint",{skill:I}),disabled:!e.onInstallMissingSkill,onClick:()=>e.onInstallMissingSkill?.(I),children:I},I))]}),(0,k.jsxs)("div",{className:"skills-pack-actions",children:[(0,k.jsx)("button",{className:"bd-button small",onClick:()=>x(y),children:l("skills.packEdit")}),(0,k.jsx)("button",{className:"bd-button small danger",onClick:()=>{K(y)},children:l("skills.remove")})]})]},y.id)})]})}),f&&(0,k.jsx)(ks,{pack:g,skills:m,onClose:()=>{p(!1),S(null)},onSaved:H}),B&&(0,k.jsx)("dialog",{className:"bd-dialog skills-pack-delete-confirm",open:!0,onClose:()=>!C&&v(null),children:(0,k.jsxs)("form",{method:"dialog",onSubmit:y=>{y.preventDefault(),F()},children:[(0,k.jsx)("h3",{children:l("skills.packDeleteConfirmTitle")}),(0,k.jsx)("p",{children:l("skills.packDeleteConfirmBody",{name:B.pack.name})}),B.references.length>0&&(0,k.jsxs)("div",{className:"skills-pack-delete-refs",children:[(0,k.jsx)("p",{children:(0,k.jsxs)("strong",{children:[l("skills.packDeleteAffectedBots"),":"]})}),(0,k.jsx)("ul",{children:B.references.map(y=>(0,k.jsx)("li",{children:y.botName},y.larkAppId))})]}),(0,k.jsx)("p",{className:"hint-warn",children:l("skills.packDeleteForceWarning")}),(0,k.jsxs)("div",{className:"skills-dialog-actions",children:[(0,k.jsx)("button",{type:"button",className:"bd-button",onClick:()=>v(null),disabled:C,children:l("skills.cancel")}),(0,k.jsx)("button",{type:"submit",className:"bd-button danger",disabled:C,children:l(C?"skills.removing":"skills.removeAnyway")})]})]})})]})}function ks(e){let l=Z(),n=e.skills??[],[m,f]=(0,J.useState)(e.pack?.id??""),[p,g]=(0,J.useState)(e.pack?.name??""),[S,o]=(0,J.useState)(e.pack?.description??""),[D,B]=(0,J.useState)((e.pack?.tags??[]).join(", ")),[v,C]=(0,J.useState)(()=>new Set(e.pack?.include.map(d=>d.replace("skill:",""))??[])),[w,h]=(0,J.useState)(!1),[x,E]=(0,J.useState)(null),[T,L]=(0,J.useState)(""),A=(0,J.useRef)(null),$=(0,J.useMemo)(()=>new Set(n.map(d=>d.name)),[n]),H=(0,J.useMemo)(()=>[...v].filter(d=>!$.has(d)).sort(),[$,v]);(0,J.useEffect)(()=>{let d=A.current;d&&!d.open&&d.showModal()},[]);let K=(0,J.useMemo)(()=>{let d=T.trim().toLowerCase();return d?n.filter(U=>`${U.name} ${U.description??""}`.toLowerCase().includes(d)):n},[n,T]),F=K.length>0&&K.every(d=>v.has(d.name)),y=d=>{C(U=>{let G=new Set(U);return G.has(d)?G.delete(d):G.add(d),G})},b=()=>{C(d=>{let U=new Set(d);if(F)for(let G of K)U.delete(G.name);else for(let G of K)U.add(G.name);return U})},I=async()=>{h(!0),E(null);try{let d={id:m,name:p,description:S||void 0,tags:D.split(",").map(r=>r.trim()).filter(Boolean),include:[...v].map(r=>`skill:${r}`),...e.pack?{expectedRevision:e.pack.revision}:{}},U=e.pack?`/api/skill-packs/${encodeURIComponent(e.pack.id)}`:"/api/skill-packs",G=await fetch(U,{method:e.pack?"PUT":"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d)}),te=await G.json().catch(()=>({}));if(!G.ok)throw new Error(te?.error??te?.reason??`HTTP ${G.status}`);e.onSaved()}catch(d){E(d?.message??String(d))}finally{h(!1)}};return(0,k.jsx)("dialog",{className:"bd-dialog skills-pack-editor",ref:A,onClose:e.onClose,children:(0,k.jsxs)("form",{method:"dialog",onSubmit:d=>{d.preventDefault(),I()},children:[(0,k.jsx)("h3",{children:e.pack?l("skills.packEdit"):l("skills.packCreate")}),x&&(0,k.jsx)("p",{className:"hint-warn",children:x}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packId")}),(0,k.jsx)("input",{value:m,onChange:d=>f(d.target.value),disabled:!!e.pack,placeholder:l("skills.packIdPlaceholder")})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packName")}),(0,k.jsx)("input",{value:p,onChange:d=>g(d.target.value)})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packDescription")}),(0,k.jsx)("textarea",{value:S,onChange:d=>o(d.target.value),rows:2})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packTags")}),(0,k.jsx)("input",{value:D,onChange:d=>B(d.target.value),placeholder:l("skills.packTagsPlaceholder")})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsxs)("div",{className:"skills-pack-include-head",children:[(0,k.jsxs)("label",{children:[l("skills.packInclude")," (",v.size,"/",n.length+H.length,")"]}),(0,k.jsx)("input",{className:"skills-pack-skill-search",type:"text",placeholder:l("skills.searchPlaceholder"),value:T,onChange:d=>L(d.target.value)})]}),K.length>0&&(0,k.jsxs)("label",{className:"skills-pack-select-all",children:[(0,k.jsx)("input",{type:"checkbox",checked:F,onChange:b}),l(F?"skills.deselectAll":"skills.selectAll")]}),H.length>0&&(0,k.jsxs)("div",{className:"skills-pack-missing-editor",children:[(0,k.jsx)("small",{className:"muted",children:l("skills.packMissing")}),H.map(d=>(0,k.jsxs)("label",{className:"skills-pack-skill-item skills-pack-skill-missing","data-missing-skill":d,children:[(0,k.jsx)("input",{type:"checkbox",checked:!0,onChange:()=>y(d)}),(0,k.jsx)("span",{className:"skills-pack-skill-name",children:d}),(0,k.jsx)("small",{className:"skills-pack-skill-desc",children:l("skills.packMissing")})]},d))]}),(0,k.jsxs)("div",{className:"skills-pack-skill-list",children:[K.map(d=>(0,k.jsxs)("label",{className:"skills-pack-skill-item",children:[(0,k.jsx)("input",{type:"checkbox",checked:v.has(d.name),onChange:()=>y(d.name)}),(0,k.jsx)("span",{className:"skills-pack-skill-name",children:d.name}),d.description&&(0,k.jsx)("small",{className:"skills-pack-skill-desc",children:d.description})]},d.name)),K.length===0&&(0,k.jsx)("p",{className:"muted",children:l("skills.noResults")})]})]}),(0,k.jsxs)("div",{className:"skills-dialog-actions",children:[(0,k.jsx)("button",{type:"button",className:"bd-button",onClick:e.onClose,children:l("skills.cancel")}),(0,k.jsx)("button",{type:"submit",className:"bd-button primary",disabled:w||v.size===0||!p.trim(),children:l(w?"skills.saving":"skills.saveSelection")})]})]})})}var oe=ee(Ae(),1);var Nl=new Set(["-y","--yes","-g","--global"]);function ms(e){let l=[],n="",m,f=!1;for(let p=0;p<e.length;p++){let g=e[p];if(m){if(g===m){m=void 0;continue}if(g==="\\"&&m==='"'){if(p+1>=e.length)return null;n+=e[++p];continue}n+=g;continue}if(/\s/.test(g)){f&&(l.push(n),n="",f=!1);continue}if(g==="'"||g==='"'){m=g,f=!0;continue}if(g==="\\"){if(p+1>=e.length)return null;n+=e[++p],f=!0;continue}n+=g,f=!0}return m?null:(f&&l.push(n),l)}function Sl(e){for(let l of e)if(!Nl.has(l))return l.startsWith("-")?null:l||null;return null}function wl(e){let l=ms(e);if(!l)return null;let n=l.findIndex(g=>g==="skills"||g==="add-skill"||g.startsWith("skills@"));if(n<0)return null;let m=l[n],f=l.slice(n+1);if(m==="add-skill")return Sl(f);let p=0;for(;Nl.has(f[p]);)p++;return f[p]!=="add"?null:Sl(f.slice(p+1))}var q=ee(de(),1);function Il(e){let[l,n]=(0,oe.useState)(null),m=(0,oe.useRef)(null),{navIntent:f,onNavIntentConsumed:p}=e;(0,oe.useEffect)(()=>{if(f){if(f.openInstallWizard){let S=m.current;S?.scrollIntoView?.({behavior:"smooth",block:"start"}),S?.querySelector('input[data-install="source"]')?.focus()}p?.()}},[f,p]);let g=S=>{!S||S.length===0||S.length>1&&n(S)};return(0,q.jsxs)("div",{className:"skills-page-stack",children:[(0,q.jsx)("div",{className:"skills-install-anchor",ref:m,children:(0,q.jsx)(e.InstallPanel,{installSource:e.installSource,installPath:e.installPath,installRef:e.installRef,installFullDepth:e.installFullDepth,installTargetSkill:e.installTargetSkill??null,installStatus:e.installStatus,installBusy:e.installBusy,installDiscovering:e.installDiscovering,installSelectionOpen:e.installSelectionOpen,installCandidates:e.installCandidates,selectedInstallSkills:e.selectedInstallSkills,onInstallSourceChange:e.onInstallSourceChange,onInstallPathChange:e.onInstallPathChange,onInstallRefChange:e.onInstallRefChange,onInstallFullDepthChange:e.onInstallFullDepthChange,onClearInstallTarget:e.onClearInstallTarget,onToggleInstallSkill:e.onToggleInstallSkill,onSelectAllInstallSkills:e.onSelectAllInstallSkills,onConfirmInstallSelection:()=>{e.onConfirmInstallSelection().then(g)},onCloseInstallSelection:e.onCloseInstallSelection,onInstall:()=>{e.onInstall().then(g)},onOpenNativeDiscovery:e.onOpenNativeDiscovery})}),l&&(0,q.jsx)(gs,{skillNames:l,onClose:()=>n(null),onCreate:async S=>{await e.onCreatePack(S),n(null)}}),(0,q.jsx)(e.InstalledLibrary,{skills:e.skills,busySkill:e.skillBusy,removingNames:e.removingNames,status:e.installedStatus,onUpdate:e.onUpdateSkill,onRequestRemove:e.onRequestRemove,externalQuery:e.navIntent?.librarySearch??null,externalFilterNames:e.navIntent?.libraryFilterSkills??null,packsKnown:e.packsKnown,onInstallMissing:e.onInstallMissing,graph:e.graph,packNames:e.packNames,onShowSkillPacks:e.onShowSkillPacks,onShowSkillBots:e.onShowSkillBots}),(0,q.jsx)(e.RemoveDialog,{names:e.removalDialogOpen?e.pendingRemoval:null,references:e.removalReferences,busy:e.removingNames.size>0,error:e.removalError,onCancel:e.onCancelRemoval,onConfirm:e.onConfirmRemoval})]})}function gs(e){let l=Z(),[n,m]=(0,oe.useState)(""),[f,p]=(0,oe.useState)(""),[g,S]=(0,oe.useState)(!1),[o,D]=(0,oe.useState)(null),B=(0,oe.useRef)(null);(0,oe.useEffect)(()=>{let C=B.current;if(C&&!C.open)try{C.showModal()}catch{}},[]);let v=async()=>{if(!(!n.trim()||!f.trim())){S(!0),D(null);try{await e.onCreate({id:n.trim(),name:f.trim(),skillNames:e.skillNames})}catch(C){D(C?.message??String(C))}finally{S(!1)}}};return(0,q.jsx)("dialog",{className:"bd-dialog skills-post-install-pack",ref:B,onClose:()=>!g&&e.onClose(),children:(0,q.jsxs)("form",{method:"dialog",onSubmit:C=>{C.preventDefault(),v()},children:[(0,q.jsx)("h3",{children:l("skills.postInstallPackTitle")}),(0,q.jsx)("p",{children:l("skills.postInstallPackHelp",{count:e.skillNames.length})}),(0,q.jsxs)("div",{className:"skills-control-block",children:[(0,q.jsx)("label",{children:l("skills.packId")}),(0,q.jsx)("input",{autoFocus:!0,required:!0,value:n,onChange:C=>m(C.target.value)})]}),(0,q.jsxs)("div",{className:"skills-control-block",children:[(0,q.jsx)("label",{children:l("skills.packName")}),(0,q.jsx)("input",{required:!0,value:f,onChange:C=>p(C.target.value)})]}),(0,q.jsxs)("div",{className:"skills-resolved-preview",children:[(0,q.jsx)("strong",{children:l("skills.postInstallPackSkills")}),(0,q.jsx)("ul",{children:e.skillNames.map(C=>(0,q.jsx)("li",{children:(0,q.jsx)("code",{children:C})},C))})]}),o&&(0,q.jsx)("p",{className:"hint-warn",children:o}),(0,q.jsxs)("div",{className:"skills-dialog-actions",children:[(0,q.jsx)("button",{type:"button",className:"bd-button",disabled:g,onClick:e.onClose,children:l("skills.postInstallPackSkip")}),(0,q.jsx)("button",{type:"submit",className:"bd-button primary",disabled:g||!n.trim()||!f.trim(),children:l(g?"skills.saving":"skills.postInstallPackCreate")})]})]})})}function el(e){let l=e.trim(),n=l.toLowerCase();if(!l)return"unknown";if(/^agentbuddy:/i.test(l)||/(?:^|\s)(?:npx\s+)?agentbuddy(?:@[\w.-]+)?\s+(?:skill|plugin)\s/i.test(l))return"agentbuddy";let m=wl(l);return m?el(m):n.startsWith("github:")?"github":n.startsWith("git+")||n.startsWith("git@")||n.startsWith("git://")?"git":n.includes("github.com")?"github":n.startsWith("http://")||n.startsWith("https://")||n.endsWith(".git")?"git":/^[/~.]/.test(l)?"local":/^[A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9._-]+(?:\/[\w./-]+)?$/.test(l)?"github":l.includes("://")?"unknown":"local"}var Q=ee(Ae(),1);function ps(e,l){let n=String(e??"").replace(/\\/g,"/");return n.includes("/.codex/skills/")?l("skills.sourceCodex"):n.includes("/.claude/skills/")?l("skills.sourceClaude"):n.includes("/.trae/skills/")?l("skills.sourceTrae"):n.includes("/.cursor/skills/")?l("skills.sourceCursor"):n.includes("/.gemini/skills/")?l("skills.sourceGemini"):n.includes("/.config/opencode/skills/")?l("skills.sourceOpenCode"):null}function ll(e,l){let n=e.source??{};return n.type==="github"?`github:${n.owner}/${n.repo}/${n.path??""}`:n.type==="git"?`${n.url??"git"}#${n.path??""}`:n.type==="local-link"?ps(n.path,l)??l("skills.sourceLocalLink"):n.type==="local-copy"?l("skills.sourceBotmuxCopy"):String(n.type??"unknown")}function ke(e){return(e?.include??[]).filter(l=>l.startsWith("skill:")).map(l=>l.slice(6))}function be(e){return(e?.include??[]).filter(l=>l.startsWith("pack:")).map(l=>l.slice(5))}function Cl(e,l,n){let m=(e?.include??[]).filter(g=>!g.startsWith("skill:")&&!g.startsWith("pack:")),f=[...new Set(l.map(g=>g.trim()).filter(Boolean))].map(g=>`skill:${g}`),p=[...new Set(n.map(g=>g.trim()).filter(Boolean))].map(g=>`pack:${g}`);return[...f,...p,...m]}function Pl(e){return(e?.include?.length??0)>0}function Be(e){return`${e.cliId}
2
- ${e.rootDir}`}function Ge(e,l,n,m){let f=m?.packsKnown!==!1,p=new Set(e.map(v=>v.name)),g=new Map,S=v=>{let C=g.get(v);return C||(C={name:v,installed:p.has(v),packIds:[],directBotIds:[],viaPackBotIds:[]},g.set(v,C)),C};for(let v of p)S(v);let o=new Map,D=new Map;for(let v of l){D.set(v.id,v);let C=[],w=[];for(let h of v.include){if(!h.startsWith("skill:"))continue;let x=h.slice(6),E=S(x);E.packIds.includes(v.id)||E.packIds.push(v.id),(p.has(x)?C:w).push(x)}o.set(v.id,{id:v.id,resolved:C,missing:w,botIds:[]})}let B=new Map;for(let v of n){let C=v.skills?.include??[],w=new Map,h=new Set,x=[],E=!1;for(let L of C)if(L.startsWith("skill:")){let A=L.slice(6),$=S(A);$.directBotIds.includes(v.larkAppId)||$.directBotIds.push(v.larkAppId),p.has(A)?w.set(A,"direct"):h.add(A)}else if(L.startsWith("pack:")){let A=L.slice(5),$=D.get(A);if(!$){f?x.push(A):E=!0;continue}let H=o.get(A);H.botIds.includes(v.larkAppId)||H.botIds.push(v.larkAppId);for(let K of $.include){if(!K.startsWith("skill:"))continue;let F=K.slice(6),y=S(F);y.viaPackBotIds.includes(v.larkAppId)||y.viaPackBotIds.push(v.larkAppId),p.has(F)?w.has(F)||w.set(F,`pack:${A}`):h.add(F)}}let T=x.length>0?"pack_missing":h.size>0?"missing":E?"unknown":C.length===0?"default":"ok";B.set(v.larkAppId,{larkAppId:v.larkAppId,resolved:[...w.entries()].map(([L,A])=>({name:L,source:A})),missingSkills:[...h],missingPacks:x,finalCount:w.size,health:T})}return{skills:g,packs:o,bots:B}}function Rl(e){return[...e.skills.values()].filter(l=>!l.installed).map(l=>l.name).sort()}function sl(e,l){if(l){let n=e.some(m=>m.name===l);return{selected:n?new Set([l]):new Set,targetMissing:!n}}return{selected:new Set(e.map(n=>n.name)),targetMissing:!1}}var u=ee(de(),1);function Dl(e){let l=Z(),[n,m]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[g,S]=(0,Q.useState)(!1),[o,D]=(0,Q.useState)(null),[B,v]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(""),[h,x]=(0,Q.useState)(null),[E,T]=(0,Q.useState)(()=>new Set),[L,A]=(0,Q.useState)(null),{focusBotIds:$,focusSkill:H,onFocusConsumed:K}=e;(0,Q.useEffect)(()=>{($?.length??0)===0&&!H||($&&$.length>0&&T(new Set($)),H&&(A(H),w(H)),K?.())},[$,H]),(0,Q.useEffect)(()=>{if(!B)return;let r=setTimeout(()=>v(null),1600);return()=>clearTimeout(r)},[B]);let F=(0,Q.useMemo)(()=>Ge(e.skills,e.packs,e.bots,{packsKnown:e.packsKnown!==!1}),[e.skills,e.packs,e.bots,e.packsKnown]),y=(0,Q.useMemo)(()=>{let r=new Set;for(let a of e.skills)for(let M of a.tags??[])r.add(M);return[...r].sort()},[e.skills]),b=(0,Q.useMemo)(()=>{let r=C.trim().toLowerCase();return e.skills.filter(a=>h&&!(a.tags??[]).includes(h)?!1:r?`${a.name} ${a.description??""}`.toLowerCase().includes(r):!0)},[e.skills,C,h]),I=async r=>{if(!o||o.sourceBotId)return;p(null),D(null);let a=ke(r.skills),M=be(r.skills);if(o.type==="skill"){if(a.includes(o.id)){v({botId:r.larkAppId,itemLabel:o.id});return}e.onMutate?await e.onMutate(r.larkAppId,`skill:${o.id}`,!0):await e.onSave(r.larkAppId,[...a,o.id],M)}else{if(M.includes(o.id)){v({botId:r.larkAppId,itemLabel:e.packs.find(P=>P.id===o.id)?.name??o.id});return}e.onMutate?await e.onMutate(r.larkAppId,`pack:${o.id}`,!0):await e.onSave(r.larkAppId,a,[...M,o.id])}},d=async()=>{let r=o;if(!r?.sourceBotId)return;S(!1),p(null),D(null);let a=e.bots.find(_=>_.larkAppId===r.sourceBotId);if(!a)return;let M=ke(a.skills),P=be(a.skills);if(r.type==="skill"){if(!M.includes(r.id))return;e.onMutate?await e.onMutate(a.larkAppId,`skill:${r.id}`,!1):await e.onSave(a.larkAppId,M.filter(_=>_!==r.id),P)}else{if(!P.includes(r.id))return;e.onMutate?await e.onMutate(a.larkAppId,`pack:${r.id}`,!1):await e.onSave(a.larkAppId,M,P.filter(_=>_!==r.id))}},U=()=>{D(null),p(null),S(!1)},G=(r,a,M)=>{r.dataTransfer.effectAllowed=M,r.dataTransfer.setData("text/plain",a.id),v(null),D(a)},te=o?.sourceBotId?e.bots.find(r=>r.larkAppId===o.sourceBotId):null;return(0,u.jsxs)("section",{className:"skills-config-block",children:[(0,u.jsx)(ue,{title:l("skills.bots"),count:l("skills.botCount",{count:e.bots.length}),hint:l("skills.botsHelp")}),(0,u.jsxs)("div",{className:"skills-bot-assign-layout",children:[(0,u.jsxs)("div",{className:"skills-bot-palette",children:[(0,u.jsxs)("div",{className:"skills-bot-palette-hint",children:[(0,u.jsx)("span",{className:"skills-drag-icon",children:"\u2927"}),(0,u.jsx)("span",{children:l("skills.dragHint")})]}),o?.sourceBotId?(0,u.jsxs)("div",{className:`skills-unassign-dropzone${g?" is-active":""}`,"data-action":"unassign-dropzone","data-drag-over":g||void 0,role:"status","aria-live":"polite",onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move",S(!0)},onDragLeave:r=>{r.currentTarget.contains(r.relatedTarget)||S(!1)},onDrop:r=>{r.preventDefault(),d().catch(()=>{})},children:[(0,u.jsx)("span",{className:"skills-unassign-icon","aria-hidden":"true",children:"\u21A9"}),(0,u.jsxs)("span",{children:[(0,u.jsx)("strong",{children:l("skills.unassignDropTitle")}),(0,u.jsx)("small",{children:l("skills.unassignDropHint",{bot:te?.botName??o.sourceBotId})})]})]}):null,e.packs.length>0&&(0,u.jsxs)("div",{className:"skills-bot-palette-group",children:[(0,u.jsx)("span",{className:"skills-bot-palette-label",children:l("skills.packChips")}),(0,u.jsx)("div",{className:"skills-bot-palette-items",children:e.packs.map(r=>(0,u.jsx)("span",{className:"skills-draggable-chip skills-pack-chip",draggable:!0,"data-palette-drag-type":"pack","data-palette-drag-id":r.id,onDragStart:a=>G(a,{type:"pack",id:r.id},"copy"),onDragEnd:U,title:`${r.name} (${l("skills.skillCount",{count:r.include.length})})`,children:r.name},r.id))})]}),(0,u.jsxs)("div",{className:"skills-bot-palette-group",children:[(0,u.jsx)("span",{className:"skills-bot-palette-label",children:l("skills.individualSkills")}),(0,u.jsx)("input",{className:"skills-bot-palette-search",type:"text",placeholder:l("skills.searchPlaceholder"),value:C,onChange:r=>w(r.target.value)}),y.length>0&&(0,u.jsxs)("div",{className:"skills-bot-palette-tags",children:[(0,u.jsx)("button",{className:`skills-tag-filter${h===null?" active":""}`,onClick:()=>x(null),children:l("skills.all")}),y.map(r=>(0,u.jsx)("button",{className:`skills-tag-filter${h===r?" active":""}`,onClick:()=>x(h===r?null:r),children:r},r))]}),(0,u.jsxs)("div",{className:"skills-bot-palette-items",children:[b.map(r=>(0,u.jsx)("span",{className:"skills-draggable-chip skills-skill-chip",draggable:!0,"data-palette-drag-type":"skill","data-palette-drag-id":r.name,onDragStart:a=>G(a,{type:"skill",id:r.name},"copy"),onDragEnd:U,title:r.description??r.name,children:r.name},r.name)),b.length===0&&(0,u.jsx)("span",{className:"muted",children:l("skills.noResults")})]})]})]}),(0,u.jsx)("article",{className:"bd-card skills-config-card skills-bot-table-wrap",children:(0,u.jsx)("div",{className:"skills-bot-table",children:(0,u.jsxs)("table",{children:[(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{children:l("skills.bot")}),(0,u.jsx)("th",{children:l("skills.packChips")}),(0,u.jsx)("th",{children:l("skills.individualSkills")}),(0,u.jsx)("th",{children:l("skills.finalCount")}),(0,u.jsx)("th",{children:l("skills.health")}),(0,u.jsx)("th",{})]})}),(0,u.jsx)("tbody",{children:e.bots.map(r=>{let a=ke(r.skills),M=be(r.skills),P=F.bots.get(r.larkAppId),_=P?.finalCount??0,V=fs(P,l),he=f===r.larkAppId,fe=E.has(r.larkAppId)||L!=null&&(P?.resolved.some(W=>W.name===L)??!1),ye=B?.botId===r.larkAppId?B:null,le=e.statuses[r.larkAppId]??null,se=e.busyBotIds?.has(r.larkAppId)===!0;return(0,u.jsxs)("tr",{className:`skills-bot-row${he?" drag-over":""}${fe?" skills-bot-row-focus":""}${se?" is-busy":""}`,"aria-busy":se,onDragOver:W=>{se||!o||o.sourceBotId||(W.preventDefault(),W.dataTransfer.dropEffect="copy",p(r.larkAppId))},onDragLeave:W=>{W.currentTarget.contains(W.relatedTarget)||p(Y=>Y===r.larkAppId?null:Y)},onDrop:W=>{se||!o||o.sourceBotId||(W.preventDefault(),I(r).catch(()=>{}))},children:[(0,u.jsx)("td",{children:r.botName??r.larkAppId}),(0,u.jsx)("td",{children:(0,u.jsx)("div",{className:"skills-pack-chips",children:M.length===0?(0,u.jsx)("span",{className:"muted",children:"\u2014"}):M.map(W=>{let Y=e.packs.find(Se=>Se.id===W),we=!Y&&e.packsKnown===!1,xe=!Y&&!we;return(0,u.jsx)("span",{className:`skills-assigned-draggable${o?.sourceBotId===r.larkAppId&&o.type==="pack"&&o.id===W?" is-dragging":""}`,draggable:!se,"data-assigned-drag-type":"pack","data-assigned-drag-id":W,"data-assigned-bot":r.larkAppId,title:l("skills.dragToRemove"),onDragStart:Se=>{se||G(Se,{type:"pack",id:W,sourceBotId:r.larkAppId},"move")},onDragEnd:U,children:(0,u.jsx)("button",{type:"button",className:`skills-pack-chip${xe?" skills-chip-missing":""}${we?" skills-chip-unknown":""}`,"data-action":"open-bot-pack",title:we?l("skills.healthUnknown"):void 0,disabled:!Y||!e.onOpenPack,onClick:()=>e.onOpenPack?.(W),children:Y?.name??W})},W)})})}),(0,u.jsx)("td",{children:a.length===0?(0,u.jsx)("span",{className:"muted",children:"\u2014"}):(0,u.jsxs)("span",{className:"skills-skill-chips",children:[a.slice(0,3).map(W=>(0,u.jsx)("span",{className:`skills-assigned-draggable${o?.sourceBotId===r.larkAppId&&o.type==="skill"&&o.id===W?" is-dragging":""}`,draggable:!se,"data-assigned-drag-type":"skill","data-assigned-drag-id":W,"data-assigned-bot":r.larkAppId,title:l("skills.dragToRemove"),onDragStart:Y=>{se||G(Y,{type:"skill",id:W,sourceBotId:r.larkAppId},"move")},onDragEnd:U,children:(0,u.jsx)("button",{type:"button",className:"skills-skill-chip","data-action":"open-bot-skill",disabled:!e.onOpenSkill,onClick:()=>e.onOpenSkill?.(W),children:W})},W)),a.length>3&&(0,u.jsxs)("span",{className:"muted",children:["+",a.length-3]})]})}),(0,u.jsx)("td",{children:P?.health==="unknown"?(0,u.jsx)("span",{className:"muted",title:l("skills.healthUnknown"),children:"\u2014"}):_}),(0,u.jsx)("td",{children:(0,u.jsx)("span",{className:`skills-health skills-health-${V.level}`,children:V.label})}),(0,u.jsx)("td",{children:(0,u.jsxs)("div",{className:"skills-bot-row-actions",children:[ye?(0,u.jsx)("span",{className:"skills-duplicate-feedback",role:"status","aria-live":"polite",children:l("skills.alreadyAssigned",{item:ye.itemLabel})}):null,le?(0,u.jsx)("span",{className:`oncall-status ${le.ok?"hint-ok":"hint-warn-inline"}`,role:"status","aria-live":"polite",children:le.text}):se?(0,u.jsx)("span",{className:"oncall-status",role:"status","aria-live":"polite",children:l("skills.saving")}):null,(0,u.jsx)("button",{className:"bd-button",disabled:se,onClick:()=>m(r),children:l("skills.select")})]})})]},r.larkAppId)})})]})})})]}),n&&(0,u.jsx)(vs,{bot:n,skills:e.skills,packs:e.packs,status:e.statuses[n.larkAppId]??null,onClose:()=>m(null),onSave:(r,a)=>e.onSave(n.larkAppId,r,a)})]})}function fs(e,l){switch(e?.health){case"pack_missing":return{level:"error",label:l("skills.healthPackMissing")};case"missing":return{level:"warn",label:l("skills.healthMissing",{count:e.missingSkills.length})};case"unknown":return{level:"unknown",label:l("skills.healthUnknown")};case"default":case void 0:return{level:"ok",label:l("skills.healthDefault")};default:return{level:"ok",label:l("skills.healthOk")}}}function vs(e){let l=Z(),n=(0,Q.useMemo)(()=>ke(e.bot.skills),[e.bot.skills]),m=(0,Q.useMemo)(()=>be(e.bot.skills),[e.bot.skills]),[f,p]=(0,Q.useState)(()=>new Set(n)),[g,S]=(0,Q.useState)(()=>new Set(m)),[o,D]=(0,Q.useState)(!1),B=h=>{p(x=>{let E=new Set(x);return E.has(h)?E.delete(h):E.add(h),E})},v=h=>{S(x=>{let E=new Set(x);return E.has(h)?E.delete(h):E.add(h),E})},C=(0,Q.useMemo)(()=>{let h=new Map;for(let x of f)h.set(x,"direct");for(let x of g){let E=e.packs.find(T=>T.id===x);if(E)for(let T of E.include){let L=T.replace("skill:","");h.has(L)||h.set(L,`pack:${E.name}`)}}return[...h.entries()].map(([x,E])=>({name:x,source:E}))},[f,g,e.packs]),w=async()=>{D(!0);try{await e.onSave([...f],[...g]),e.onClose()}finally{D(!1)}};return(0,u.jsx)("dialog",{className:"bd-dialog skills-bot-editor",open:!0,onClose:e.onClose,children:(0,u.jsxs)("form",{method:"dialog","data-action":"save-bot-assignment",onSubmit:h=>{h.preventDefault(),w().catch(()=>{})},children:[(0,u.jsxs)("h3",{children:[l("skills.botEdit"),": ",e.bot.botName??e.bot.larkAppId]}),e.status&&(0,u.jsx)("p",{className:`hint-${e.status.ok?"ok":"warn"}`,children:e.status.text}),(0,u.jsxs)("div",{className:"skills-control-block",children:[(0,u.jsx)("label",{children:l("skills.packChips")}),(0,u.jsxs)("div",{className:"skills-pack-skill-list",children:[e.packs.map(h=>(0,u.jsxs)("label",{className:"skills-pack-skill-item",children:[(0,u.jsx)("input",{type:"checkbox",checked:g.has(h.id),onChange:()=>v(h.id)}),(0,u.jsx)("span",{children:h.name}),(0,u.jsx)("small",{children:l("skills.skillCount",{count:h.include.length})})]},h.id)),e.packs.length===0&&(0,u.jsx)("small",{className:"muted",children:l("skills.packsEmpty")})]})]}),(0,u.jsxs)("div",{className:"skills-control-block",children:[(0,u.jsxs)("label",{children:[l("skills.individualSkills")," (",l("skills.advanced"),")"]}),(0,u.jsx)("div",{className:"skills-pack-skill-list",children:e.skills.map(h=>(0,u.jsxs)("label",{className:"skills-pack-skill-item",children:[(0,u.jsx)("input",{type:"checkbox",checked:f.has(h.name),onChange:()=>B(h.name)}),(0,u.jsx)("span",{children:h.name})]},h.name))})]}),(0,u.jsxs)("div",{className:"skills-control-block",children:[(0,u.jsxs)("label",{children:[l("skills.resolvedPreview")," (",C.length,")"]}),(0,u.jsx)("div",{className:"skills-resolved-preview",children:C.map(({name:h,source:x})=>(0,u.jsxs)("div",{className:"skills-resolved-item",children:[(0,u.jsx)("span",{children:h}),(0,u.jsx)("small",{className:"muted",children:x})]},h))})]}),(0,u.jsxs)("div",{className:"skills-dialog-actions",children:[(0,u.jsx)("button",{type:"button",className:"bd-button",onClick:e.onClose,children:l("skills.cancel")}),(0,u.jsx)("button",{type:"submit",className:"bd-button primary",disabled:o,children:l(o?"skills.saving":"skills.saveSelection")})]})]})})}var O=ee(de(),1);function Tl(e){let l=Z(),{SkillSegmented:n}=e;return(0,O.jsxs)("div",{className:"skills-page-stack",children:[(0,O.jsxs)("section",{className:"skills-config-block",children:[(0,O.jsx)(ue,{title:l("skills.globalDefaults")}),(0,O.jsxs)("article",{className:"bd-card skills-defaults-panel skills-config-card",children:[(0,O.jsxs)("div",{className:"skills-control-block",children:[(0,O.jsx)("span",{className:"skills-control-label",children:l("skills.globalProject")}),(0,O.jsx)(n,{value:e.trustProjectSkills,disabled:e.globalBusy==="project",options:[{value:"off",label:l("skills.globalProjectOff"),help:l("skills.globalProjectOffHelp")},{value:"all",label:l("skills.globalProjectAll"),help:l("skills.globalProjectAllHelp")}],onChange:m=>e.onUpdateProject(m)})]}),(0,O.jsxs)("div",{className:"skills-control-block",children:[(0,O.jsxs)("span",{className:"skills-control-label",children:[l("skills.globalDelivery"),(0,O.jsx)("small",{className:"skills-scope-note",children:l("skills.scopeGlobal")})]}),(0,O.jsx)(n,{value:e.delivery,disabled:e.globalBusy==="delivery",options:[{value:"auto",label:l("skills.deliveryAuto"),help:l("skills.deliveryAutoHelp")},{value:"prompt",label:l("skills.deliveryPrompt"),help:l("skills.deliveryPromptHelp")},{value:"native",label:l("skills.deliveryNative"),help:l("skills.deliveryNativeHelp")}],onChange:m=>e.onUpdateDelivery(m)})]})]})]}),(0,O.jsxs)("section",{className:"skills-config-block",children:[(0,O.jsx)(ue,{title:l("skills.botInjection"),hint:l("skills.botInjectionHelp")}),(0,O.jsxs)("article",{className:"bd-card skills-config-card",children:[(0,O.jsx)("p",{className:"skills-injection-note",children:l("skills.botInjectionNote")}),(0,O.jsx)("div",{className:"skills-bot-injection-table",children:(0,O.jsxs)("table",{children:[(0,O.jsx)("thead",{children:(0,O.jsxs)("tr",{children:[(0,O.jsx)("th",{children:l("skills.bot")}),(0,O.jsx)("th",{children:l("skills.cli")}),(0,O.jsx)("th",{children:l("skills.injection")}),(0,O.jsx)("th",{children:l("skills.status")})]})}),(0,O.jsx)("tbody",{children:e.bots.map(m=>(0,O.jsxs)("tr",{children:[(0,O.jsx)("td",{children:m.botName??m.larkAppId}),(0,O.jsx)("td",{children:(0,O.jsx)("code",{children:m.cliId??""})}),(0,O.jsx)("td",{children:(0,O.jsx)(n,{value:m.skillInjection??m.skillInjectionDefault??"prompt",options:[{value:"global",label:l("skills.injectionGlobal"),help:l("skills.injectionGlobalHelp")},{value:"prompt",label:l("skills.injectionPrompt"),help:l("skills.injectionPromptHelp")},{value:"off",label:l("skills.injectionOff"),help:l("skills.injectionOffHelp")}],onChange:f=>e.onUpdateBotInjection(m.larkAppId,f)})}),(0,O.jsx)("td",{children:e.botStatuses[m.larkAppId]?(0,O.jsx)("span",{className:`hint-${e.botStatuses[m.larkAppId].ok?"ok":"warn"}`,children:e.botStatuses[m.larkAppId].text}):null})]},m.larkAppId))})]})})]})]})]})}var X=ee(Ae(),1);function Al(e){let l=(0,X.useRef)(!0),[n,m]=(0,X.useState)([]),[f,p]=(0,X.useState)([]),[g,S]=(0,X.useState)([]),[o,D]=(0,X.useState)([]),[B,v]=(0,X.useState)("off"),[C,w]=(0,X.useState)("auto"),[h,x]=(0,X.useState)(!0),[E,T]=(0,X.useState)(null),[L,A]=(0,X.useState)(null),[$,H]=(0,X.useState)(!1),K=(0,X.useRef)(e.apiUnavailableText);K.current=e.apiUnavailableText;let F=(0,X.useCallback)(async()=>{x(!0);try{let[y,b,I]=await Promise.all([fetch("/api/skills"),fetch("/api/bots"),fetch("/api/skill-packs").catch(()=>null)]),d=await y.json().catch(()=>({})),U=await b.json().catch(()=>({})),G=I?await I.json().catch(()=>({})):{};if(!y.ok){let te=d?.error??`skills HTTP ${y.status}`;throw new Error(te==="not_found_yet"||te==="not_found"?K.current:te)}if(!b.ok)throw new Error(U?.error??`bots HTTP ${b.status}`);if(!l.current)return;m(Array.isArray(d.skills)?d.skills:[]),p(Array.isArray(d.nativeSkillGroups)?d.nativeSkillGroups:[]),S(Array.isArray(U.bots)?U.bots:[]),I?.ok&&Array.isArray(G.packs)?(D(G.packs),A(null),H(!0)):I?.status===404?(D([]),A(null),H(!0)):A(I?G?.error??`HTTP ${I.status}`:"network_error"),v(d.trustProjectSkills==="all"?"all":"off"),w(d.delivery==="prompt"||d.delivery==="native"?d.delivery:"auto"),T(null)}catch(y){l.current&&T(y?.message??String(y))}finally{l.current&&x(!1)}},[]);return(0,X.useEffect)(()=>(l.current=!0,F(),()=>{l.current=!1}),[F]),{skills:n,nativeSkillGroups:f,bots:g,packs:o,trustProjectSkills:B,delivery:C,loading:h,loadError:E,packsError:L,packsKnown:$,refresh:F,setSkills:m,setBots:S,setTrustProjectSkills:v,setDelivery:w}}var s=ee(de(),1),bs=2;function hs(e){return e>=1600?4:e<=620?1:e<=980?2:3}async function re(e,l){let n=await fetch(e,{...l,headers:{"content-type":"application/json",...l.headers??{}}}),m=await n.json().catch(()=>({}));if(!n.ok||m.ok===!1){let f=new Error(m?.error??`HTTP ${n.status}`);throw f.status=n.status,f.body=m,f}return m}function tl(e){return`oncall-status${e?` ${e.ok?"hint-ok":"hint-warn-inline"}`:""}`}function ys(e){let l=e.options.find(n=>n.value===e.value);return(0,s.jsxs)("div",{className:"skills-segmented-control",children:[(0,s.jsx)("div",{className:"segmented skills-segmented",role:"group",children:e.options.map(n=>(0,s.jsx)("button",{type:"button",className:e.value===n.value?"active":"","aria-pressed":e.value===n.value?"true":"false",title:typeof n.help=="string"?n.help:void 0,disabled:e.disabled,onClick:()=>e.onChange(n.value),children:n.label},n.value))}),l?.help?(0,s.jsx)("span",{className:"skills-setting-hint",children:l.help}):null]})}function Ss(e){let l=Z(),n=(0,c.useRef)(null),m=(0,c.useRef)(null),f=(0,c.useId)(),p=`${f}-input`,g=`${f}-title`,[S,o]=(0,c.useState)(!1),D=e.installCandidates??[],B=e.selectedInstallSkills??new Set,v=D.length>0&&D.every(T=>B.has(T.name)),C=e.installBusy||e.installDiscovering,w=el(e.installSource),h=l(w==="github"?"skills.sourceDetectedGithub":w==="git"?"skills.sourceDetectedGit":w==="agentbuddy"?"skills.sourceDetectedAgentbuddy":w==="local"?"skills.sourceDetectedLocal":"skills.sourceDetectedUnknown"),x=l(w==="agentbuddy"?"skills.sourcePreflightAgentbuddy":w==="github"||w==="git"?"skills.sourcePreflightGit":w==="local"?"skills.sourcePreflightLocal":"skills.sourcePreflightUnknown"),E=l(w==="agentbuddy"?"skills.installDiagnosticAgentbuddy":w==="github"||w==="git"?"skills.installDiagnosticGit":w==="local"?"skills.installDiagnosticLocal":"skills.installDiagnosticUnknown");return(0,c.useEffect)(()=>{let T=n.current;if(T)if(e.installSelectionOpen&&!T.open)try{T.showModal()}catch{}else!e.installSelectionOpen&&T.open&&T.close()},[e.installSelectionOpen,D.length]),(0,c.useEffect)(()=>{if(!S||typeof document>"u")return;let T=A=>{m.current?.contains(A.target)||o(!1)},L=A=>{A.key==="Escape"&&o(!1)};return document.addEventListener("pointerdown",T),document.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",T),document.removeEventListener("keydown",L)}},[S]),(0,s.jsxs)("article",{className:"bd-card skills-install-panel",children:[e.showTitle===!1?null:(0,s.jsx)("div",{className:"skills-install-title",children:(0,s.jsx)("h3",{className:"bd-section-title",children:(0,s.jsx)(hl,{help:l("skills.installInfo"),helpLabel:l("skills.installInfoLabel"),children:l("skills.install")})})}),e.installTargetSkill?(0,s.jsxs)("div",{className:"skills-inline-target","data-install-target":e.installTargetSkill,children:[(0,s.jsx)("span",{children:l("skills.installTargetHint",{skill:e.installTargetSkill})}),(0,s.jsx)("button",{type:"button","data-action":"clear-install-target",onClick:()=>e.onClearInstallTarget?.(),children:l("skills.clearInstallTarget")})]}):null,(0,s.jsxs)("div",{className:"skills-install-grid",children:[(0,s.jsxs)("div",{className:"skills-source-label",children:[(0,s.jsxs)("div",{className:"skills-source-heading",ref:m,onKeyDown:T=>{T.key==="Escape"&&o(!1)},children:[(0,s.jsx)("label",{htmlFor:p,children:l("skills.source")}),(0,s.jsx)("button",{type:"button",className:"skills-source-help-trigger","data-action":"toggle-source-help","aria-label":l("skills.sourceHelpOpen"),"aria-expanded":S,"aria-controls":f,"aria-haspopup":"dialog",onClick:()=>o(T=>!T),children:"?"}),S?(0,s.jsxs)("aside",{className:"skills-source-help-popover",id:f,role:"dialog","aria-labelledby":g,"data-source-help-popover":!0,children:[(0,s.jsxs)("div",{className:"skills-source-help-head",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{id:g,children:l("skills.sourceHelpTitle")}),(0,s.jsx)("span",{children:l("skills.sourceHelpIntro")})]}),(0,s.jsx)("button",{type:"button",className:"skills-source-help-close","data-action":"close-source-help","aria-label":l("skills.sourceHelpClose"),onClick:()=>o(!1),children:"\xD7"})]}),(0,s.jsxs)("div",{className:"skills-source-help-list",children:[(0,s.jsxs)("section",{children:[(0,s.jsx)("strong",{children:l("skills.sourceHelpRemoteLabel")}),(0,s.jsx)("span",{children:l("skills.sourceHelpRemote")}),(0,s.jsx)("code",{children:l("skills.sourceHelpRemoteExample")})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)("strong",{children:l("skills.sourceHelpLocalLabel")}),(0,s.jsx)("span",{children:l("skills.sourceHelpLocal")}),(0,s.jsx)("code",{children:l("skills.sourceHelpLocalExample")})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)("strong",{children:l("skills.sourceHelpAgentbuddyLabel")}),(0,s.jsx)("span",{children:l("skills.sourceHelpAgentbuddy")}),(0,s.jsx)("code",{children:l("skills.sourceHelpAgentbuddyExample")})]})]})]}):null]}),(0,s.jsx)("div",{className:"skills-source-control",children:(0,s.jsx)("input",{id:p,type:"text","data-install":"source","aria-label":l("skills.source"),placeholder:l("skills.sourcePlaceholder"),value:e.installSource,onChange:T=>e.onInstallSourceChange(T.currentTarget.value)})}),e.installSource.trim()?(0,s.jsxs)("div",{className:`skills-source-feedback is-${w}`,"data-source-hint":w,children:[(0,s.jsx)("strong",{children:h}),(0,s.jsx)("span",{children:x})]}):null]}),(0,s.jsxs)("details",{className:"skills-install-advanced","data-install-advanced":!0,children:[(0,s.jsx)("summary",{children:l("skills.advancedOptions")}),(0,s.jsxs)("div",{className:"skills-install-advanced-body",children:[(0,s.jsxs)("label",{className:"skills-install-field",children:[(0,s.jsx)("span",{children:l("skills.path")}),(0,s.jsx)("input",{type:"text","data-install":"path",placeholder:l("skills.pathPlaceholder"),value:e.installPath,onChange:T=>e.onInstallPathChange(T.currentTarget.value)}),(0,s.jsx)("small",{children:l("skills.pathHelpInline")})]}),(0,s.jsxs)("label",{className:"skills-install-field",children:[(0,s.jsx)("span",{children:l("skills.ref")}),(0,s.jsx)("input",{type:"text","data-install":"ref",placeholder:l("skills.refPlaceholder"),value:e.installRef,onChange:T=>e.onInstallRefChange(T.currentTarget.value)}),(0,s.jsx)("small",{children:l("skills.refHelpInline")})]}),(0,s.jsxs)("label",{className:"skills-scan-toggle",children:[(0,s.jsx)("input",{type:"checkbox","data-install":"full-depth",checked:e.installFullDepth,disabled:C,onChange:T=>e.onInstallFullDepthChange(T.currentTarget.checked)}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:l("skills.deepScan")}),(0,s.jsx)("small",{children:l("skills.deepScanHelp")}),(0,s.jsx)("small",{className:"muted",children:l("skills.autoDeepScanHint")})]})]})]})]}),(0,s.jsxs)("div",{className:"skills-install-actions",children:[(0,s.jsx)("button",{type:"button",className:"skills-local-discovery-link","data-action":"open-native-skill-discovery",title:l("skills.localDiscoverHelp"),onClick:()=>e.onOpenNativeDiscovery(),children:l("skills.localDiscover")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"install",disabled:C||!e.installSource.trim(),onClick:()=>e.onInstall(),children:e.installDiscovering?l("skills.scanning"):e.installBusy?l("skills.jobRunning"):l("skills.installSubmit")})]})]}),e.installStatus?(0,s.jsx)("div",{className:"actions skills-install-status-row",children:(0,s.jsx)("span",{className:tl(e.installStatus),"data-skills-status":!0,children:e.installStatus.text})}):null,e.installStatus&&!e.installStatus.ok?(0,s.jsxs)("div",{className:"skills-install-diagnostic","data-install-diagnostic":w,role:"alert",children:[(0,s.jsx)("strong",{children:l("skills.installDiagnosticTitle")}),(0,s.jsx)("span",{children:E})]}):null,(0,s.jsx)("dialog",{className:"skills-discovery-dialog skills-install-selection-dialog","data-install-selection-dialog":!0,ref:n,onClose:()=>e.onCloseInstallSelection?.(),children:(0,s.jsxs)("article",{children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:l("skills.installSelectionTitle")}),(0,s.jsx)("p",{children:l("skills.installSelectionHelp",{count:D.length})})]}),(0,s.jsx)("div",{className:"skills-discovery-body skills-install-selection-body",children:(0,s.jsxs)("div",{className:"skills-candidate-list","data-install-candidates":!0,children:[(0,s.jsxs)("div",{className:"skills-candidate-list-head",children:[(0,s.jsx)("span",{children:l("skills.scanFound",{count:D.length})}),e.onSelectAllInstallSkills?(0,s.jsx)("button",{type:"button","data-action":"toggle-all-source-skills",disabled:e.installBusy,onClick:()=>e.onSelectAllInstallSkills?.(!v),children:l(v?"skills.discoverClearSelection":"skills.discoverSelectAll")}):null]}),D.map(T=>(0,s.jsxs)("label",{className:"skills-candidate-row",children:[(0,s.jsx)("input",{type:"checkbox",checked:B.has(T.name),disabled:e.installBusy,onChange:()=>e.onToggleInstallSkill?.(T.name)}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:T.name}),(0,s.jsxs)("small",{children:[T.path,T.description?` \xB7 ${T.description}`:""]})]})]},`${T.name}:${T.path}`))]})}),(0,s.jsxs)("footer",{className:"actions",children:[(0,s.jsx)("button",{type:"button","data-action":"close-install-selection",disabled:e.installBusy,onClick:()=>e.onCloseInstallSelection?.(),children:l("skills.installSelectionCancel")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"confirm-install-selection",disabled:e.installBusy||B.size===0,onClick:()=>e.onConfirmInstallSelection?.(),children:e.installBusy?l("skills.jobRunning"):l("skills.installSelected")})]})]})})]})}function Ns(e){let l=Z(),n=(0,c.useRef)(null),m=(0,c.useRef)(new Set(e.skills.map(a=>a.name))),f=(0,c.useRef)(""),p=(0,c.useRef)(!1),g=(0,c.useRef)(null),[S,o]=(0,c.useState)(""),[D,B]=(0,c.useState)(!1),[v,C]=(0,c.useState)(()=>new Set),[w,h]=(0,c.useState)(null),[x,E]=(0,c.useState)(0),[T,L]=(0,c.useState)(()=>typeof window>"u"?1200:window.innerWidth),A=S.trim().toLocaleLowerCase();f.current=S,p.current=D;let $=(0,c.useMemo)(()=>{let a=w?e.skills.filter(M=>w.has(M.name)):e.skills;return A?a.filter(M=>[M.name,M.displayName,M.description,...M.tags??[],ll(M,l)].filter(Boolean).join(`
3
- `).toLocaleLowerCase().includes(A)):a},[w,A,e.skills,l]),H=(0,c.useMemo)(()=>{if(!w)return[];let a=new Set(e.skills.map(M=>M.name));return[...w].filter(M=>!a.has(M)).sort()},[w,e.skills]),K=hs(T)*bs,F=Math.max(1,Math.ceil($.length/K)),y=$.slice(x*K,x*K+K),b=(0,c.useMemo)(()=>new Set($.map(a=>a.name)),[$]),I=$.filter(a=>v.has(a.name)).length,d=Math.max(0,v.size-I),U=$.length>0&&I===$.length;(0,c.useEffect)(()=>{if(typeof window>"u")return;let a=()=>L(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),(0,c.useEffect)(()=>{e.externalQuery!=null&&e.externalQuery!==""&&o(e.externalQuery)},[e.externalQuery]),(0,c.useEffect)(()=>{e.externalFilterNames&&e.externalFilterNames.length>0&&h(new Set(e.externalFilterNames))},[e.externalFilterNames]),(0,c.useEffect)(()=>E(0),[A,K,w]),(0,c.useEffect)(()=>{E(a=>Math.min(Math.max(0,a),F-1))},[F]),(0,c.useEffect)(()=>{let a=new Set(e.skills.map(P=>P.name)),M=[...m.current].some(P=>!a.has(P));C(P=>{let _=new Set([...P].filter(V=>a.has(V)));return _.size===P.size?P:_}),M&&(B(!1),C(new Set)),m.current=a},[e.skills]),(0,c.useEffect)(()=>{n.current&&(n.current.indeterminate=I>0&&!U)},[U,I]),(0,c.useEffect)(()=>{if(typeof document>"u")return;let a=P=>{if(P.key!=="Escape"||!p.current)return;let _=f.current;g.current=_,P.preventDefault(),P.stopPropagation(),B(!1),C(new Set),window.setTimeout(()=>{o(V=>V||_),g.current=null},50)},M=P=>{if(P.key!=="Escape"||g.current===null)return;let _=g.current;g.current=null,P.preventDefault(),P.stopPropagation(),o(_)};return document.addEventListener("keydown",a,!0),document.addEventListener("keyup",M,!0),()=>{document.removeEventListener("keydown",a,!0),document.removeEventListener("keyup",M,!0)}},[]);function G(a){C(M=>{let P=new Set(M);return P.has(a)?P.delete(a):P.add(a),P})}function te(){C(a=>{let M=new Set(a);if(U)for(let P of b)M.delete(P);else for(let P of b)M.add(P);return M})}function r(a=!1){let M=S;B(!1),C(new Set),a&&typeof window<"u"&&window.setTimeout(()=>o(M),0)}return(0,s.jsxs)("section",{className:"skills-installed-block",children:[(0,s.jsx)(ue,{title:l("skills.installed"),count:l("skills.installedCount",{count:e.skills.length}),hint:l("skills.installedHelp"),children:(0,s.jsx)("div",{className:"skills-installed-header-actions",children:D?(0,s.jsx)("button",{type:"button","data-action":"cancel-installed-selection",onClick:()=>r(),children:l("skills.cancel")}):(0,s.jsx)("button",{type:"button","data-action":"select-installed-skills",disabled:e.skills.length===0,onClick:()=>B(!0),children:l("skills.select")})})}),(0,s.jsxs)("section",{className:"bd-card skills-installed-panel",children:[(0,s.jsxs)("div",{className:"skills-library-toolbar",children:[(0,s.jsxs)("label",{className:"skills-installed-search",children:[(0,s.jsx)("span",{className:"sr-only",children:l("skills.searchLabel")}),(0,s.jsx)("input",{type:"text",role:"searchbox",inputMode:"search","data-action":"search-installed-skills",placeholder:l("skills.searchPlaceholder"),value:S,onChange:a=>o(a.currentTarget.value),onKeyDown:a=>{a.key!=="Escape"||!D||(a.preventDefault(),a.stopPropagation(),r(!0))}}),S?(0,s.jsx)("button",{type:"button","data-action":"clear-installed-search","aria-label":l("skills.clearSearch"),onClick:()=>o(""),children:"\xD7"}):null]}),D?(0,s.jsxs)("label",{className:"skills-select-all-results",children:[(0,s.jsx)("input",{ref:n,type:"checkbox",checked:U,disabled:$.length===0||e.removingNames.size>0,onChange:te}),(0,s.jsx)("span",{children:A?l("skills.selectSearchResults",{count:$.length}):l("skills.selectAllSkills",{count:$.length})})]}):null,w?(0,s.jsxs)("button",{type:"button",className:"skills-library-filter-chip","data-action":"clear-library-filter",title:[...w].join(", "),"aria-label":l("skills.clearFilter"),onClick:()=>h(null),children:[l("skills.libraryFilterActive",{count:w.size})," \xD7"]}):null,A?(0,s.jsx)("span",{className:"skills-filter-count",children:l("skills.resultCount",{count:$.length})}):null,F>1?(0,s.jsxs)("div",{className:"skills-pager",children:[(0,s.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"-1","aria-label":l("skills.prevPage"),title:l("skills.prevPage"),disabled:x===0,onClick:()=>E(a=>Math.max(0,a-1)),children:"\u2039"}),(0,s.jsx)("span",{children:l("skills.pageStatus",{page:x+1,pages:F})}),(0,s.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"1","aria-label":l("skills.nextPage"),title:l("skills.nextPage"),disabled:x>=F-1,onClick:()=>E(a=>Math.min(F-1,a+1)),children:"\u203A"})]}):null]}),(0,s.jsx)("div",{className:"skills-installed-live",role:"status","aria-live":"polite",children:e.status?(0,s.jsx)("span",{className:tl(e.status),children:e.status.text}):null}),H.length>0&&(0,s.jsxs)("div",{className:"skills-missing-list","data-missing-skills":!0,children:[(0,s.jsx)("strong",{children:l("skills.missingFilteredTitle")}),H.map(a=>(0,s.jsxs)("div",{className:"skills-missing-row","data-missing-skill":a,children:[(0,s.jsx)("span",{className:"skills-missing-row-name",children:a}),(0,s.jsx)("small",{className:"muted",children:l("skills.dangling")}),(0,s.jsx)("button",{type:"button","data-action":"install-dangling-skill",disabled:!e.onInstallMissing,onClick:()=>e.onInstallMissing?.(a),children:l("skills.installNow")})]},a))]}),e.skills.length===0?(0,s.jsxs)("div",{className:"skills-library-empty",children:[(0,s.jsx)("strong",{children:l("skills.emptyTitle")}),(0,s.jsx)("p",{children:l("skills.emptyHelp")})]}):$.length===0&&H.length>0?null:$.length===0?(0,s.jsxs)("div",{className:"skills-library-empty","data-empty":"search",children:[(0,s.jsx)("strong",{children:l("skills.noResultsTitle",{query:S.trim()})}),(0,s.jsx)("p",{children:l("skills.noResultsHelp")}),(0,s.jsx)("button",{type:"button","data-action":"clear-installed-search-empty",onClick:()=>o(""),children:l("skills.clearSearch")})]}):(0,s.jsx)("div",{className:"skills-list",children:y.map(a=>{let M=v.has(a.name),P=e.removingNames.has(a.name);return(0,s.jsxs)("article",{className:`skills-row skills-installed-card${D?" is-selectable":""}${M?" is-selected":""}${P?" is-removing":""}`,"data-skill":a.name,"data-selection-mode":D?"true":void 0,"aria-busy":P||void 0,onClick:D?()=>G(a.name):void 0,children:[(0,s.jsxs)("div",{className:"skills-row-body",children:[(0,s.jsxs)("div",{className:"skills-row-title",children:[D?(0,s.jsx)("input",{type:"checkbox","aria-label":l("skills.selectNamed",{skill:a.displayName??a.name}),checked:M,disabled:P,onClick:_=>_.stopPropagation(),onChange:()=>G(a.name)}):null,(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:a.displayName??a.name}),a.displayName&&a.displayName!==a.name?(0,s.jsx)("small",{className:"skills-canonical-name",children:a.name}):null]})]}),a.description?(0,s.jsx)("p",{children:a.description}):null,(0,s.jsx)("small",{className:"skills-source-badge",children:ll(a,l)}),e.graph?(()=>{let _=e.graph.skills.get(a.name),V=e.packsKnown===!1,he=_?.packIds.length??0,fe=_?new Set([..._.directBotIds,..._.viaPackBotIds]).size:0,ye=V?l("skills.healthUnknown"):(_?.packIds??[]).map(le=>e.packNames?.find(se=>se.id===le)?.name??le).join(", ");return(0,s.jsxs)("span",{className:"skills-usage-chips",children:[(0,s.jsx)("button",{type:"button",className:"skills-usage-chip","data-action":"show-skill-packs",disabled:V||he===0||!e.onShowSkillPacks,title:ye||void 0,onClick:le=>{le.stopPropagation(),e.onShowSkillPacks?.(a.name)},children:V?l("skills.usedInPacksUnknown"):l("skills.usedInPacks",{count:he})}),(0,s.jsx)("button",{type:"button",className:"skills-usage-chip","data-action":"show-skill-bots",disabled:fe===0||!e.onShowSkillBots,onClick:le=>{le.stopPropagation(),e.onShowSkillBots?.(a.name)},children:l("skills.usedByBots",{count:fe})})]})})():null,P?(0,s.jsx)("span",{className:"skills-removing-label",children:l("skills.removing")}):null]}),D?null:(0,s.jsxs)("div",{className:"skills-card-actions",children:[(0,s.jsx)("button",{type:"button","data-action":"update-skill",disabled:e.busySkill===`${a.name}:update`||P,onClick:()=>e.onUpdate(a.name),children:l("skills.update")}),(0,s.jsx)("button",{type:"button","data-action":"remove-skill",disabled:P,onClick:()=>e.onRequestRemove([a.name]),children:l("skills.remove")})]})]},a.name)})})]}),D?(0,s.jsxs)("div",{className:"skills-bulk-action-bar",role:"toolbar","aria-label":l("skills.bulkActions"),children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:l("skills.selectedCount",{count:v.size})}),d>0?(0,s.jsx)("small",{children:l("skills.selectedHidden",{count:d})}):null]}),(0,s.jsx)("button",{type:"button",className:"danger","data-action":"remove-selected-skills",disabled:v.size===0||e.removingNames.size>0,onClick:()=>e.onRequestRemove([...v]),children:l("skills.removeSelected",{count:v.size})})]}):null]})}function ws(e){let l=Z(),n=(0,c.useRef)(null),m=e.names??[],f=e.references.length>0,p=m.slice(0,3),g=new Set(e.references.flatMap(o=>o.bots)).size,S=new Set(e.references.flatMap(o=>o.packs)).size;return(0,c.useEffect)(()=>{let o=n.current;if(o)if(e.names&&!o.open)try{o.showModal()}catch{}else!e.names&&o.open&&o.close()},[e.names]),(0,s.jsx)("dialog",{className:"skills-remove-dialog","data-remove-skills-dialog":!0,ref:n,onCancel:o=>{o.preventDefault(),e.busy||e.onCancel()},onClick:o=>{o.target===o.currentTarget&&!e.busy&&e.onCancel()},children:(0,s.jsxs)("article",{children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:f?m.length===1?l("skills.removeInUseOneTitle",{skill:m[0]}):l("skills.removeInUseManyTitle",{count:m.length}):m.length===1?l("skills.removeOneTitle",{skill:m[0]}):l("skills.removeManyTitle",{count:m.length})}),(0,s.jsx)("p",{children:f?m.length===1?S>0?l("skills.removeInUseOneHelpWithPacks",{botCount:g,packCount:S}):l("skills.removeInUseOneHelp",{count:g}):S>0?l("skills.removeInUseManyHelpWithPacks",{botCount:g,packCount:S}):l("skills.removeInUseManyHelp",{count:g}):m.length===1?l("skills.removeOnePermanentHelp"):l("skills.removePermanentHelp")})]}),(0,s.jsxs)("div",{className:"skills-remove-dialog-body",children:[m.length>1?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("ul",{children:p.map(o=>(0,s.jsx)("li",{children:o},o))}),m.length>p.length?(0,s.jsx)("p",{children:l("skills.removeMore",{count:m.length-p.length})}):null]}):null,e.references.length>0?(0,s.jsxs)("div",{className:"skills-remove-reference-warning",role:"alert",children:[(0,s.jsx)("strong",{children:l("skills.removeReferencesDetail")}),(0,s.jsx)("ul",{children:e.references.map(o=>(0,s.jsxs)("li",{children:[(0,s.jsx)("strong",{children:o.name}),(0,s.jsxs)("span",{children:[o.bots.join(", "),o.bots.length>0&&o.packs.length>0?" \xB7 ":"",o.packs.length>0?`${l("skills.packChips")}: ${o.packs.join(", ")}`:""]})]},o.name))})]}):null,e.error?(0,s.jsx)("p",{className:"hint-warn",role:"alert",children:e.error}):null]}),(0,s.jsxs)("footer",{className:"actions",children:[(0,s.jsx)("button",{type:"button",autoFocus:!0,disabled:e.busy,onClick:e.onCancel,children:l("skills.cancel")}),(0,s.jsx)("button",{type:"button",className:"danger",disabled:e.busy,onClick:()=>e.onConfirm(f),children:e.busy?l("skills.removing"):f?l("skills.removeAnyway"):m.length===1?l("skills.removeOneConfirm"):l("skills.removeSelected",{count:m.length})})]})]})})}function Is(){let e=Z(),l=(0,c.useRef)(!0),n=(0,c.useRef)(new Set),m=(0,c.useRef)(null),{skills:f,nativeSkillGroups:p,bots:g,packs:S,trustProjectSkills:o,delivery:D,loading:B,loadError:v,packsError:C,packsKnown:w,refresh:h,setSkills:x,setBots:E,setTrustProjectSkills:T,setDelivery:L}=Al({apiUnavailableText:e("skills.apiUnavailable")}),[A,$]=(0,c.useState)("library"),[H,K]=(0,c.useState)(null),[F,y]=(0,c.useState)(null),b=(0,c.useCallback)(t=>{K(t),y(t.installTargetSkill??null),$(t.tab)},[]),I=(0,c.useCallback)(()=>K(null),[]),[d,U]=(0,c.useState)(""),[G,te]=(0,c.useState)(""),[r,a]=(0,c.useState)(""),[M,P]=(0,c.useState)(null),[_,V]=(0,c.useState)(!1),[he,fe]=(0,c.useState)(!1),[ye,le]=(0,c.useState)(!1),[se,W]=(0,c.useState)([]),[Y,we]=(0,c.useState)(!1),[xe,Se]=(0,c.useState)(!1),[ze,Me]=(0,c.useState)(()=>new Set),[Ke,Ie]=(0,c.useState)(!1),[xl,nl]=(0,c.useState)(!1),[_e,Ml]=(0,c.useState)(null),[We,qe]=(0,c.useState)(()=>new Set),[El,Ee]=(0,c.useState)(null),[$l,al]=(0,c.useState)(null),[Ll,il]=(0,c.useState)(()=>new Set),[ol,Ne]=(0,c.useState)({}),[Je,Ce]=(0,c.useState)(null),[rl,Qe]=(0,c.useState)(null),[Hl,Pe]=(0,c.useState)(!1),[Ol,$e]=(0,c.useState)([]),[jl,Le]=(0,c.useState)(null),[He,cl]=(0,c.useState)(()=>new Set),Re=(0,c.useRef)(g),Oe=(0,c.useRef)(new Map);(0,c.useEffect)(()=>{Re.current=g},[g]);let je=(0,c.useMemo)(()=>new Set(f.map(t=>t.name)),[f]),ve=(0,c.useMemo)(()=>p.length===0?void 0:(_e?p.find(i=>Be(i)===_e):void 0)??p.find(i=>i.skills.length>0)??p[0],[_e,p]),Xe=ve?Be(ve):"",De=(0,c.useMemo)(()=>ve?ve.skills.filter(t=>!je.has(t.name)).map(t=>t.rootDir??t.source?.root??"").filter(Boolean):[],[ve,je]),dl=De.length>0&&De.every(t=>We.has(t)),ul=(0,c.useCallback)(()=>{for(let t of n.current)window.clearTimeout(t);n.current.clear()},[]),Fl=(0,c.useCallback)(t=>new Promise(i=>{let N=window.setTimeout(()=>{n.current.delete(N),i()},t);n.current.add(N)}),[]);(0,c.useEffect)(()=>(l.current=!0,()=>{l.current=!1,ul()}),[ul]),(0,c.useEffect)(()=>{qe(t=>{let i=new Set,N=new Set(f.map(R=>R.name));for(let R of p)for(let z of R.skills){let j=z.rootDir??z.source?.root??"";j&&!N.has(z.name)&&t.has(j)&&i.add(j)}return i.size===t.size?t:i})},[f,p]),(0,c.useEffect)(()=>{if(!Je||He.size>0)return;let t=window.setTimeout(()=>{l.current&&Ce(null)},6e3);return()=>window.clearTimeout(t)},[Je,He]),(0,c.useEffect)(()=>{let t=m.current;if(t)if(Ke&&!t.open)try{t.showModal()}catch{}else!Ke&&t.open&&t.close()},[Ke,Xe]);async function kl(t,i,N=!0){let R=t;for(i({text:e("skills.jobRunning"),ok:!0});;){if(!l.current)return null;if(R.status==="succeeded")return i({text:e("skills.saved"),ok:!0}),N&&await h(),R;if(R.status==="failed")throw new Error(R.error??"job_failed");if(await Fl(800),!l.current)return null;let z=await re(`/api/skills/jobs/${encodeURIComponent(R.id)}`,{method:"GET"});if(!l.current)return null;R=z.job}}function Ul(t){return g.filter(i=>ke(i.skills).includes(t)).map(i=>i.botName??i.larkAppId)}function Te(){W([]),Me(new Set),le(!1),Se(!1)}function ml(){return{source:d.trim(),path:G.trim()||void 0,ref:r.trim()||void 0,...Y?{fullDepth:!0}:{}}}function Gl(t,i=Y||xe){let N=t??[...ze];return{...ml(),skillNames:N.length>0?N:void 0,...i?{fullDepth:!0}:{}}}async function zl(){fe(!0),P({text:e("skills.scanning"),ok:!0});try{let t=await re("/api/skills/discover",{method:"POST",body:JSON.stringify(ml())});if(!l.current)return{skills:[],directInstall:!1,fullDepth:Y};let i=t.discovery?.directInstall===!0,N=Array.isArray(t.discovery?.skills)?t.discovery.skills:[],R=t.discovery?.deepScanned===!0;return Se(R),W(N),Me(sl(N,F).selected),{skills:N,directInstall:i,fullDepth:Y||R}}finally{l.current&&fe(!1)}}function me(t){let i=t||"";return i.startsWith("skill_git_command_failed")&&/authentication failed|could not read username|repository not found|unauthor|\b401\b|\b403\b/i.test(i)?e("skills.gitNeedsAuth"):i.startsWith("agentbuddy_not_found")?e("skills.agentbuddyNotFound"):i.startsWith("agentbuddy_login_required")?e("skills.agentbuddyNeedsLogin"):i.startsWith("agentbuddy_command_failed")?/login|credential|unauthor|not logged|401|403/i.test(i)?e("skills.agentbuddyNeedsLogin"):e("skills.agentbuddyCommandFailed"):i.startsWith("agentbuddy_clear_telemetry_failed")||i.startsWith("agentbuddy_telemetry_not_stripped")?e("skills.agentbuddyTelemetryFailed"):i.startsWith("agentbuddy_no_skill_produced")?e("skills.agentbuddyNoSkill"):i.startsWith("invalid_agentbuddy")?e("skills.agentbuddyInvalid"):i}async function Ze(t,i=Y||xe){V(!0);try{let N=await re("/api/skills/install",{method:"POST",body:JSON.stringify(Gl(t,i))});if(!l.current)return null;let R=await kl(N.job,P);if(!l.current||!R)return null;let z=(R.skills??(R.skill?[R.skill]:[])).map(j=>j.name).filter(Boolean);return Te(),y(null),[...new Set(z.length>0?z:t??[])]}catch(N){return l.current&&P({text:`${e("skills.failed")}: ${me(N?.message??String(N))}`,ok:!1}),null}finally{l.current&&V(!1)}}function Kl(t){Me(i=>{let N=new Set(i);return N.has(t)?N.delete(t):N.add(t),N})}function _l(t){Me(t?new Set(se.map(i=>i.name)):new Set)}async function Wl(){if(!d.trim())return P({text:e("skills.sourceRequired"),ok:!1}),null;try{le(!1);let{skills:t,directInstall:i,fullDepth:N}=await zl();if(!l.current)return null;if(i)return await Ze(void 0,N);if(t.length===0)return P({text:e("skills.scanEmpty"),ok:!1}),null;let{targetMissing:R}=sl(t,F);return t.length===1&&!R?await Ze([t[0].name],N):(P(R?{text:e("skills.installTargetNotFound",{skill:F}),ok:!1}:{text:e("skills.scanFound",{count:t.length}),ok:!0}),le(!0),null)}catch(t){return l.current&&P({text:`${e("skills.failed")}: ${me(t?.message??String(t))}`,ok:!1}),null}}async function ql(){let t=[...ze];return t.length===0?(P({text:e("skills.discoverNothingSelected"),ok:!1}),null):await Ze(t)}async function Jl(t){await re("/api/skill-packs",{method:"POST",body:JSON.stringify({id:t.id,name:t.name,include:t.skillNames.map(i=>`skill:${i}`)})}),l.current&&(await h(),l.current&&$("packs"))}async function Ql(){let t=[...We].filter(Boolean);if(t.length===0){P({text:e("skills.discoverNothingSelected"),ok:!1});return}nl(!0);try{if(P({text:e("skills.discoverRegisteringBatch",{total:t.length}),ok:!0}),await re("/api/skills/install-local-links",{method:"POST",body:JSON.stringify({sources:t})}),!l.current)return;Ie(!1),await h(),l.current&&P({text:e("skills.saved"),ok:!0})}catch(i){l.current&&P({text:`${e("skills.failed")}: ${me(i?.message??String(i))}`,ok:!1})}finally{l.current&&nl(!1)}}async function Xl(t){if(o!==t){Ee("project");try{let i=await re("/api/skills/global",{method:"PUT",body:JSON.stringify({trustProjectSkills:t})});if(!l.current)return;T(i.trustProjectSkills==="all"?"all":t)}catch(i){l.current&&window.alert(`${e("skills.failed")}: ${me(i?.message??String(i))}`)}finally{l.current&&Ee(null)}}}async function Zl(t){if(D!==t){Ee("delivery");try{let i=await re("/api/skills/global",{method:"PUT",body:JSON.stringify({delivery:t})});if(!l.current)return;L(i.delivery==="prompt"||i.delivery==="native"?i.delivery:t)}catch(i){l.current&&window.alert(`${e("skills.failed")}: ${me(i?.message??String(i))}`)}finally{l.current&&Ee(null)}}}async function Vl(t){al(`${t}:update`);try{let i=await re(`/api/skills/${encodeURIComponent(t)}/update`,{method:"POST",body:"{}"});if(!l.current)return;await kl(i.job,P)}catch(i){l.current&&window.alert(`${e("skills.failed")}: ${me(i?.message??String(i))}`)}finally{l.current&&al(null)}}function Yl(t){let i=[...new Set(t.filter(N=>je.has(N)))];i.length!==0&&(Qe(i),Pe(!0),$e([]),Le(null))}function es(){He.size>0||(Pe(!1),Qe(null),$e([]),Le(null))}async function ls(t){let i=rl??[];if(i.length!==0){cl(new Set(i)),Pe(!1),Le(null),Ce({text:e("skills.removingCount",{count:i.length}),ok:!0});try{let N=await re("/api/skills/remove",{method:"POST",body:JSON.stringify({names:i,force:t})});if(!l.current)return;let R=Array.isArray(N.removed)?N.removed.filter(j=>typeof j=="string"):i,z=new Set(R);x(j=>j.filter(ne=>!z.has(ne.name))),Ce({text:R.length===1?e("skills.removedOne",{skill:R[0]}):e("skills.removedMany",{count:R.length}),ok:!0}),Qe(null),$e([])}catch(N){if(!l.current)return;if(N?.status===409&&N?.body?.error==="skills_in_use"){let z=Array.isArray(N.body.affectedSkills)?N.body.affectedSkills.map(j=>{let ne=typeof j?.name=="string"?j.name:"",ie=Array.isArray(j?.affectedBots)?j.affectedBots.map(ae=>ae?.botName||ae?.larkAppId||"").filter(Boolean):Ul(ne),ce=Array.isArray(j?.affectedPacks)?j.affectedPacks.filter(ae=>typeof ae=="string"):[];return ne?{name:ne,bots:ie,packs:ce}:null}).filter(j=>j!==null):[];$e(z),Pe(!0),Ce(null);return}let R=e("skills.removeFailed",{detail:me(N?.message??String(N))});Le(R),Pe(!0),Ce({text:R,ok:!1})}finally{l.current&&cl(new Set)}}}function gl(t,i){let N=Oe.current.get(t)??Promise.resolve();il(z=>new Set(z).add(t));let R=N.catch(()=>{}).then(i);return Oe.current.set(t,R),R.finally(()=>{Oe.current.get(t)===R&&(Oe.current.delete(t),l.current&&il(z=>{let j=new Set(z);return j.delete(t),j}))})}async function pl(t,i,N){Ne(R=>({...R,[t]:null}));try{let R=Re.current.find(ie=>ie.larkAppId===t),z=Cl(R?.skills,i,N),j=await re(`/api/bots/${encodeURIComponent(t)}/skills`,{method:"PUT",body:JSON.stringify({action:"set",policy:z.length>0?{include:z}:null})});if(!l.current)return;let ne=ie=>ie.map(ce=>ce.larkAppId===t?{...ce,skills:j.skills??null}:ce);Re.current=ne(Re.current),E(ne),Ne(ie=>({...ie,[t]:{text:e("skills.policySaved"),ok:!0}}))}catch(R){throw l.current&&Ne(z=>({...z,[t]:{text:`${e("skills.failed")}: ${me(R?.message??String(R))}`,ok:!1}})),R}}function ss(t,i,N){return gl(t,()=>pl(t,i,N))}function ts(t,i,N){return gl(t,async()=>{let R=Re.current.find(ae=>ae.larkAppId===t),z=ke(R?.skills),j=be(R?.skills),[ne,ie]=i.split(":",2),ce=ae=>N?[...new Set([...ae,ie])]:ae.filter(cs=>cs!==ie);await pl(t,ne==="skill"?ce(z):z,ne==="pack"?ce(j):j)})}async function ns(t,i){Ne(N=>({...N,[t]:null}));try{if(await re(`/api/bots/${encodeURIComponent(t)}/skill-injection`,{method:"PUT",body:JSON.stringify({skillInjection:i})}),!l.current)return;E(N=>N.map(R=>R.larkAppId===t?{...R,skillInjection:i}:R)),Ne(N=>({...N,[t]:{text:e("skills.saved"),ok:!0}}))}catch(N){l.current&&Ne(R=>({...R,[t]:{text:`${e("skills.failed")}: ${N?.message??N}`,ok:!1}}))}}let as=g.filter(t=>Pl(t.skills)).length,is=g.reduce((t,i)=>t+(i.skills?.include?.length??0),0),ge=(0,c.useMemo)(()=>Ge(f,S,g,{packsKnown:w}),[f,S,g,w]),pe=(0,c.useMemo)(()=>Rl(ge),[ge]),Fe=(0,c.useMemo)(()=>[...ge.packs.values()].filter(t=>t.botIds.length===0).map(t=>t.id),[ge]),Ue=(0,c.useMemo)(()=>[...ge.bots.values()].filter(t=>t.health==="missing"||t.health==="pack_missing").map(t=>t.larkAppId),[ge]),os=(0,s.jsxs)("div",{className:"page-heading-actions skills-heading-actions",children:[(0,s.jsxs)("div",{className:"skills-metric-strip",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricInstalled")}),(0,s.jsx)("strong",{children:f.length})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricPacks")}),(0,s.jsx)("strong",{children:w?S.length:"\u2014"})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricBots")}),(0,s.jsxs)("strong",{children:[as,"/",g.length]})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricAttached")}),(0,s.jsx)("strong",{children:is})]})]}),(0,s.jsxs)("div",{className:"skills-issue-strip",role:"group","aria-label":e("skills.issuesLabel"),children:[pe.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-warn","data-action":"issue-dangling-skills",title:pe.join(", "),onClick:()=>b(pe.length===1?{tab:"library",librarySearch:pe[0],openInstallWizard:!0,installTargetSkill:pe[0]}:{tab:"library",libraryFilterSkills:pe}),children:e("skills.issueDangling",{count:pe.length})}),Fe.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-info","data-action":"issue-unassigned-packs",onClick:()=>b({tab:"packs",focusPackIds:Fe}),children:e("skills.issueUnassignedPacks",{count:Fe.length})}),Ue.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-warn","data-action":"issue-bots-missing",onClick:()=>b({tab:"bots",focusBotIds:Ue}),children:e("skills.issueBotsMissing",{count:Ue.length})}),!B&&w&&pe.length===0&&Fe.length===0&&Ue.length===0&&(0,s.jsx)("span",{className:"skills-issue-badge skills-issue-ok","data-skills-healthy":!0,children:e("skills.issueNone")})]}),(0,s.jsx)(bl,{id:"skills-refresh",label:e("skills.refresh"),busy:B,disabled:B,onClick:()=>{h()}})]}),rs=(0,s.jsx)("div",{className:"skills-page-stack",children:B?(0,s.jsx)(vl,{label:e("common.loading")}):v?(0,s.jsx)("p",{className:"hint-warn",children:v}):(0,s.jsxs)(s.Fragment,{children:[C&&(0,s.jsx)("p",{className:"hint-warn","data-packs-error":!0,role:"alert",children:e(w?"skills.packsLoadError":"skills.packsLoadErrorFirst",{error:C})}),(0,s.jsxs)("div",{className:"skills-tabs",role:"tablist",children:[(0,s.jsx)("button",{role:"tab","aria-selected":A==="library",className:A==="library"?"active":"",onClick:()=>$("library"),children:e("skills.tabLibrary")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="packs",className:A==="packs"?"active":"",onClick:()=>$("packs"),children:e("skills.tabPacks")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="bots",className:A==="bots"?"active":"",onClick:()=>$("bots"),children:e("skills.tabBots")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="delivery",className:A==="delivery"?"active":"",onClick:()=>$("delivery"),children:e("skills.tabDelivery")})]}),A==="packs"&&(0,s.jsx)(yl,{skills:f,packs:S,packsKnown:w,onRefresh:()=>{h()},focusPackId:H?.tab==="packs"?H.focusPackId??null:null,focusPackIds:H?.tab==="packs"?H.focusPackIds??null:null,onFocusConsumed:I,onOpenBot:t=>b({tab:"bots",focusBotIds:[t]}),onInstallMissingSkill:t=>b({tab:"library",librarySearch:t,openInstallWizard:!0,installTargetSkill:t})}),A==="library"&&(0,s.jsx)(Il,{skills:f,nativeSkillGroups:p,installSource:d,installPath:G,installRef:r,installFullDepth:Y,installStatus:M,installBusy:_,installDiscovering:he,installSelectionOpen:ye,installCandidates:se,selectedInstallSkills:ze,onInstallSourceChange:t=>{U(t),Te()},onInstallPathChange:t=>{te(t),Te()},onInstallRefChange:t=>{a(t),Te()},onInstallFullDepthChange:t=>{we(t),Te()},onToggleInstallSkill:Kl,onSelectAllInstallSkills:_l,onConfirmInstallSelection:ql,onCloseInstallSelection:()=>le(!1),onInstall:Wl,onOpenNativeDiscovery:()=>Ie(!0),onCreatePack:Jl,InstallPanel:Ss,InstalledLibrary:Ns,RemoveDialog:ws,removingNames:He,removalDialogOpen:Hl,pendingRemoval:rl,removalReferences:Ol,removalError:jl,skillBusy:$l,installedStatus:Je,onUpdateSkill:t=>{Vl(t)},onRequestRemove:Yl,onCancelRemoval:es,onConfirmRemoval:t=>{ls(t)},navIntent:H?.tab==="library"?H:null,onNavIntentConsumed:I,installTargetSkill:F,onClearInstallTarget:()=>y(null),packsKnown:w,onInstallMissing:t=>b({tab:"library",openInstallWizard:!0,installTargetSkill:t}),graph:ge,packNames:S.map(t=>({id:t.id,name:t.name})),onShowSkillPacks:t=>{let i=ge.skills.get(t)?.packIds??[];b(i.length===1?{tab:"packs",focusPackId:i[0]}:{tab:"packs",focusPackIds:i})},onShowSkillBots:t=>b({tab:"bots",focusSkill:t})}),A==="bots"&&(0,s.jsx)(Dl,{bots:g,skills:f,statuses:ol,onSave:ss,onMutate:ts,busyBotIds:Ll,packs:S,packsKnown:w,focusBotIds:H?.tab==="bots"?H.focusBotIds??null:null,focusSkill:H?.tab==="bots"?H.focusSkill??null:null,onFocusConsumed:I,onOpenPack:t=>b({tab:"packs",focusPackId:t}),onOpenSkill:t=>b({tab:"library",librarySearch:t})}),A==="delivery"&&(0,s.jsx)(Tl,{trustProjectSkills:o,delivery:D,globalBusy:El,onUpdateProject:t=>{Xl(t)},onUpdateDelivery:t=>{Zl(t)},bots:g,onUpdateBotInjection:ns,botStatuses:ol,SkillSegmented:ys}),(0,s.jsx)("dialog",{className:"skills-discovery-dialog",id:"skills-discovery-dialog",ref:m,onClose:()=>Ie(!1),onClick:t=>{t.target===t.currentTarget&&Ie(!1)},children:(0,s.jsxs)("article",{children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:e("skills.discoverTitle")}),(0,s.jsx)("p",{children:e("skills.discoverHelp")}),(0,s.jsx)("button",{type:"button",className:"skills-discovery-close","data-action":"close-discovery","aria-label":e("skills.discoverClose"),title:e("skills.discoverClose"),onClick:()=>Ie(!1)})]}),(0,s.jsx)("div",{className:"skills-discovery-body",children:ve?(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"skills-discovery-layout",children:[(0,s.jsx)("div",{className:"skills-discovery-tabs",role:"tablist","aria-label":e("skills.discoverTitle"),children:p.map(t=>{let i=Be(t),N=i===Xe;return(0,s.jsxs)("button",{type:"button",role:"tab","data-discovery-tab":i,className:N?"selected":"","aria-selected":N?"true":"false",onClick:()=>Ml(i),children:[(0,s.jsx)("strong",{children:t.label??t.cliId}),(0,s.jsx)("small",{children:e("skills.skillCount",{count:t.skills.length})})]},i)})}),(0,s.jsxs)("div",{className:"skills-discovery-main",children:[(0,s.jsx)("div",{className:"skills-discovery-path",children:(0,s.jsx)("code",{children:ve.rootDir})}),p.map(t=>{let i=Be(t);return(0,s.jsx)("section",{className:"skills-discovery-group","data-discovery-panel":i,hidden:!(i===Xe),children:t.skills.length===0?(0,s.jsx)("p",{className:"empty",children:e("skills.discoverGroupEmpty")}):(0,s.jsx)("div",{className:"skills-discovery-list",children:t.skills.map(R=>{let z=je.has(R.name),j=R.rootDir??R.source?.root??"";return(0,s.jsxs)("label",{className:`skills-discovery-row${z?" installed":""}`,children:[(0,s.jsx)("input",{type:"checkbox","data-discovered-skill":!0,value:j,disabled:z,checked:!z&&We.has(j),onChange:ne=>{let ie=ne.currentTarget.checked;qe(ce=>{let ae=new Set(ce);return ie?ae.add(j):ae.delete(j),ae})}}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:R.name}),R.description?(0,s.jsx)("small",{children:R.description}):null]}),z?(0,s.jsx)("em",{children:e("skills.discoverRegistered")}):null]},`${R.name}:${j}`)})})},i)})]})]})}):(0,s.jsx)("p",{className:"empty",children:e("skills.discoverEmpty")})}),(0,s.jsxs)("footer",{className:"actions",children:[(0,s.jsx)("button",{type:"button","data-action":"toggle-discovered-skills",disabled:De.length===0,onClick:()=>{qe(t=>{let i=new Set(t);return dl?De.forEach(N=>i.delete(N)):De.forEach(N=>i.add(N)),i})},children:e(dl?"skills.discoverClearSelection":"skills.discoverSelectAll")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"register-discovered-skills",disabled:xl,onClick:()=>{Ql()},children:e("skills.discoverRegister")})]})]})})]})});return(0,s.jsxs)("section",{className:"page skills-page",children:[(0,s.jsxs)("div",{className:"page-heading",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"eyebrow",children:e("nav.skills")}),(0,s.jsx)("h1",{children:e("skills.title")})]}),os]}),(0,s.jsx)("div",{id:"skills-body",children:rs})]})}function Cs(e,l){return e.size===l.length&&l.every(n=>e.has(n))}function Ps(e){let l=Z(),n=(0,c.useRef)(null),m=(0,c.useRef)(null),f=(0,c.useRef)(null),[p,g]=(0,c.useState)(!1),[S,o]=(0,c.useState)(""),[D,B]=(0,c.useState)(()=>new Set(e.names)),[v,C]=(0,c.useState)(null),w=e.names.join(`
4
- `),h=S.trim().toLocaleLowerCase(),x=(0,c.useMemo)(()=>{let b=new Map(e.skills.map(I=>[I.name,I]));for(let I of e.names)b.has(I)||b.set(I,{name:I});return[...b.values()].sort((I,d)=>I.name.localeCompare(d.name))},[e.names,e.skills]),E=(0,c.useMemo)(()=>h?x.filter(b=>`${b.name} ${b.description||""}`.toLocaleLowerCase().includes(h)):x,[h,x]),T=!Cs(D,e.names),L=(0,c.useCallback)(()=>{let b=m.current;if(!b||typeof window>"u")return;let I=b.getBoundingClientRect(),d=12,U=7,G=Math.min(370,Math.max(260,window.innerWidth-d*2)),te=Math.min(Math.max(d,I.left),Math.max(d,window.innerWidth-G-d)),r=Math.max(0,I.top-U-d),a=Math.max(0,window.innerHeight-I.bottom-U-d),M=r>a,P=M?r:a,_=118+Math.min(x.length,5)*42,V=Math.max(180,Math.min(_,P));C({left:te,top:M?Math.max(d,I.top-U-V):I.bottom+U,width:G,height:V})},[x.length]);(0,c.useEffect)(()=>{p||B(new Set(e.names))},[w,p]),(0,c.useEffect)(()=>{if(!p||typeof document>"u")return;let b=I=>{n.current?.contains(I.target)||f.current?.contains(I.target)||(g(!1),o(""),B(new Set(e.names)))};return document.addEventListener("pointerdown",b),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),L(),()=>{document.removeEventListener("pointerdown",b),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[w,p,L]);function A(){B(new Set(e.names)),o(""),L(),g(!0)}function $(){B(new Set(e.names)),o(""),g(!1)}function H(b){B(I=>{let d=new Set(I);return d.has(b)?d.delete(b):d.add(b),d})}async function K(){let b=[...D].sort((I,d)=>I.localeCompare(d));try{await e.onSave(b),o(""),g(!1)}catch{}}let F=e.names.length===0?l("skills.pickerPlaceholder"):e.names.length===1?e.names[0]:l("skills.pickerSelectedCount",{count:e.names.length}),y=p?(0,s.jsxs)("div",{ref:f,className:"skills-multi-picker-popover",style:v?{left:v.left,top:v.top,width:v.width,height:v.height}:void 0,children:[(0,s.jsxs)("div",{className:"skills-multi-picker-head",children:[(0,s.jsxs)("label",{className:"skills-multi-picker-search",children:[(0,s.jsx)("span",{className:"skills-multi-picker-search-icon","aria-hidden":"true"}),(0,s.jsx)("input",{type:"search","data-action":"search-skills",autoFocus:!0,autoComplete:"off",value:S,placeholder:l("skills.pickerSearchPlaceholder"),onChange:b=>o(b.currentTarget.value),onKeyDown:b=>{b.key==="Escape"&&(b.preventDefault(),$())}})]}),(0,s.jsxs)("div",{className:"skills-multi-picker-meta",children:[(0,s.jsx)("span",{children:l("skills.pickerSelectionMeta",{selected:D.size,total:x.length})}),D.size>0?(0,s.jsx)("button",{type:"button",className:"skills-multi-picker-clear","data-action":"clear-skill-selection",onClick:()=>B(new Set),children:l("skills.pickerClear")}):null]})]}),(0,s.jsxs)("div",{className:"skills-multi-picker-options",role:"listbox","aria-label":l("skills.priority"),"aria-multiselectable":"true",children:[E.map(b=>{let I=D.has(b.name),d=!e.installedNames.has(b.name);return(0,s.jsxs)("button",{type:"button",className:`skills-multi-picker-option${I?" selected":""}${d?" dangling":""}`,role:"option","aria-selected":I,"data-skill-name":b.name,onClick:()=>H(b.name),children:[(0,s.jsx)("span",{className:"skills-multi-picker-check","aria-hidden":"true"}),(0,s.jsxs)("span",{className:"skills-multi-picker-option-copy",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("b",{children:b.name}),d?(0,s.jsx)("em",{children:l("skills.dangling")}):null]}),b.description?(0,s.jsx)("small",{children:b.description}):null]})]},b.name)}),E.length===0?(0,s.jsx)("p",{className:"skills-multi-picker-empty",children:l("skills.pickerNoResults")}):null]}),(0,s.jsxs)("footer",{className:"skills-multi-picker-actions",children:[(0,s.jsx)("button",{type:"button",className:"ghost","data-action":"cancel-skill-selection",disabled:e.busy,onClick:$,children:l("skills.cancel")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"save-skill-selection",disabled:!T||e.busy,onClick:()=>{K()},children:e.busy?l("skills.saving"):l("skills.saveSelection")})]})]}):null;return(0,s.jsxs)("div",{ref:n,className:`skills-multi-picker${p?" open":""}`,"data-skill-picker":e.botId,children:[(0,s.jsxs)("button",{ref:m,type:"button",className:"skills-multi-picker-trigger","data-action":"open-skill-picker","aria-haspopup":"listbox","aria-expanded":p,disabled:e.busy,onClick:()=>p?$():A(),children:[(0,s.jsxs)("span",{className:"skills-multi-picker-trigger-copy",children:[(0,s.jsx)("b",{children:F}),(0,s.jsx)("small",{children:l("skills.pickerTriggerHint")})]}),(0,s.jsx)("span",{className:"skills-multi-picker-chevron","aria-hidden":"true"})]}),y&&typeof document<"u"?(0,Bl.createPortal)(y,document.body):y]})}function Ys(e){let l=Z(),{bot:n,installedNames:m,skills:f,status:p,busyKey:g,onSave:S}=e,o=n.botName??n.larkAppId,D=ke(n.skills);return n.error?(0,s.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":n.larkAppId,children:[(0,s.jsxs)("header",{children:[(0,s.jsx)(Ye,{html:Ve({name:o,larkAppId:n.larkAppId,size:"sm"})}),(0,s.jsx)("strong",{children:o})]}),(0,s.jsx)("p",{className:"hint-warn-inline",children:n.error})]}):(0,s.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":n.larkAppId,children:[(0,s.jsxs)("header",{className:"skills-bot-head",children:[(0,s.jsx)(Ye,{html:Ve({name:o,larkAppId:n.larkAppId,size:"sm",dot:"ok"})}),(0,s.jsxs)("div",{className:"skills-bot-title-line",children:[(0,s.jsx)("strong",{children:o}),(0,s.jsx)("span",{className:"skills-count-pill",children:l("skills.skillCount",{count:D.length})})]})]}),(0,s.jsxs)("section",{className:"skills-policy-panel",children:[(0,s.jsx)("div",{className:"skills-priority-head",children:(0,s.jsx)("h3",{className:"skills-priority-title",children:l("skills.priority")})}),(0,s.jsx)(Ps,{botId:n.larkAppId,names:D,installedNames:m,skills:f,busy:g===`${n.larkAppId}:set`,onSave:B=>S(n.larkAppId,B)})]}),(0,s.jsx)("span",{className:tl(p),"data-bot-status":!0,children:p?.text??""})]})}function et(e){return fl(e,(0,s.jsx)(Is,{}))}export{Ys as BotPolicyCard,Ns as InstalledSkillsLibrary,ws as RemoveSkillsDialog,Ps as SkillMultiPicker,ys as SkillSegmented,Ss as SkillsInstallPanel,Is as SkillsPage,et as renderSkillsPage};
@@ -1 +0,0 @@
1
- import{a as E,b as J,c as S,d as V}from"./chunk-EVK77ASG.js";import{a as se,d as q,g as ie,q as re}from"./chunk-5CJMHTT4.js";import{d as F}from"./chunk-FXW3V4JR.js";import"./chunk-24ONYQMR.js";import"./chunk-F6KNPF4R.js";import{a as K}from"./chunk-SYC6D5XU.js";import{a as z,d as oe}from"./chunk-5THX4DI2.js";import{c as L}from"./chunk-7SZRL6FY.js";var l=L(z(),1);async function W(){return E("/api/team/hosted")}async function le(){return E("/api/team/remote-roster")}async function de(t,a){return V("/api/team/local-bots/"+encodeURIComponent(t)+"/capability",{capability:a})}async function me(t){return E("/api/team/local-bots/"+encodeURIComponent(t)+"/role")}async function ce(t){return S("/api/team/identity/auto-bind",t?{unionId:t}:void 0)}async function ue(t,a){return J("DELETE",`/api/team/hosted/${encodeURIComponent(t)}/members/${encodeURIComponent(a)}`)}async function pe(t,a,n){return S("/api/team/federated-group",{name:a,larkAppIds:n,teamId:t})}async function ge(t,a,n,o){return S("/api/team/remote-group",{hubUrl:t,teamId:a,name:n,larkAppIds:o})}async function ye(t){return S("/api/team/hosted",{name:t})}async function be(t){return J("DELETE","/api/team/hosted/"+encodeURIComponent(t))}async function fe(t,a){return V(`/api/team/hosted/${encodeURIComponent(t)}/feedback`,{feedback:a})}async function ke(t){return S("/api/team/local-invite",{teamId:t})}async function he(t,a){return S("/api/team/join-remote",{hubUrl:t,inviteCode:a})}function G(t,a){let n=a.query.trim().toLowerCase();return!(n&&!((t.name||"")+" "+(t.cliId||"")+" "+(t.capability||"")).toLowerCase().includes(n)||a.cliId&&t.cliId!==a.cliId||a.hasCapability&&!t.capability||a.hasRole&&!t.hasTeamRole)}function ve(t){return Array.from(new Set(t.flatMap(a=>a.bots.map(n=>n.cliId)).filter(Boolean))).sort()}function Te(t,a){return(t.teams||[]).map(n=>({kind:"local",key:`local:${n.teamId}`,teamId:n.teamId,label:n.isDefault?a("team.myHostedTeam"):n.name,sub:"",ok:!0,deployments:n.deployments||[],bots:n.bots||[]}))}function Ne(t,a){return(t.memberships||[]).map(o=>{let d=o.roster?.deployments||[],r=d.find(T=>T.local),p=r?.name?a("team.remoteTeamLabel",{name:r.name}):o.teamName||o.teamId;return{kind:"remote",key:`${o.hubUrl}::${o.teamId}`,teamId:o.teamId,label:p,sub:o.hubUrl,ok:!!o.ok,error:o.error,hubUrl:o.hubUrl,deployments:d,bots:o.roster?.bots||[]}})}function Q(t,a,n){return t.map(o=>({...o,bots:o.bots.map(d=>d.larkAppId===a?{...d,capability:n.trim()||null}:d)}))}var e=L(oe(),1),Se=L(z(),1);function we(){let t=(0,l.useRef)(!0);return(0,l.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Ce(t){let a=F(),n=t.active==="home",o=t.active==="manage";return(0,e.jsxs)("nav",{className:"team-subnav insight-tabs",role:"tablist","aria-label":a("team.eyebrow"),children:[(0,e.jsx)("a",{href:"#/team",className:`itab${n?" on":""}`,role:"tab","aria-selected":n,children:a("team.navHome")}),(0,e.jsx)("a",{href:"#/team/manage",className:`itab${o?" on":""}`,role:"tab","aria-selected":o,children:a("team.navManage")})]})}function X(t,a){return t.get(a)??new Set}function Le(){let t=F(),a=we(),[n,o]=(0,l.useState)([]),[d,r]=(0,l.useState)([]),[p,T]=(0,l.useState)(""),[k,y]=(0,l.useState)(t("team.unbound")),[u,R]=(0,l.useState)({query:"",cliId:"",hasCapability:!1,hasRole:!1}),[B,x]=(0,l.useState)(()=>new Map),[D,M]=(0,l.useState)(()=>new Map),[O,I]=(0,l.useState)(()=>new Set),[P,H]=(0,l.useState)(()=>new Set),[U,w]=(0,l.useState)({kind:"hidden"}),[j,c]=(0,l.useState)(()=>new Map),[g,N]=(0,l.useState)(null),b=(0,l.useMemo)(()=>[...n,...d],[n,d]),Z=(0,l.useMemo)(()=>ve(b),[b]),ee=(0,l.useMemo)(()=>[{value:"",label:t("team.allCli")},...Z.map(s=>({value:s,label:s}))],[Z,t]),A=(0,l.useCallback)(async()=>{let s=await W();if(!a.current)return;let i=s.body;if(!i?.ok){o([]);return}T(i.deployment?.deploymentId??""),y(i.deployment?.ownerName||(i.deployment?.ownerUnionId?t("team.bound"):t("team.unbound"))),o(Te(i,t))},[a,t]),te=(0,l.useCallback)(async()=>{let s=await le();a.current&&r(Ne(s.body,t))},[a,t]);(0,l.useEffect)(()=>{x(new Map),M(new Map),I(new Set),H(new Set),A(),te()},[A,te]),(0,l.useEffect)(()=>{y(s=>s==="\u672A\u7ED1\u5B9A"||s==="Unbound"?t("team.unbound"):s)},[t]),(0,l.useEffect)(()=>{let s=new Map;for(let i of b)s.set(i.key,new Set(i.bots.filter(m=>G(m,u)).map(m=>m.larkAppId)));x(i=>{let m=!1,f=new Map;for(let[h,v]of i){let C=s.get(h),_=new Set([...v].filter(Ae=>C?.has(Ae)));_.size!==v.size&&(m=!0),_.size&&f.set(h,_)}return m?f:i})},[u,b]);let ae=(0,l.useMemo)(()=>{if(!b.length)return"";let s=new Set,i=new Set;for(let h of b)h.bots.filter(C=>G(C,u)).forEach(C=>s.add(C.larkAppId)),h.bots.forEach(C=>i.add(C.larkAppId));let m=b.length>1?t("team.acrossTeams",{n:b.length}):"";return`\xB7 ${s.size===i.size?`${i.size}`:`${s.size} / ${i.size}`} ${t("team.botsWord")}${m}`},[u,b,t]);function $(s,i){c(m=>{let f=new Map(m);return f.set(s,i),f})}function xe(s,i,m){x(f=>{let h=new Map(f),v=new Set(h.get(s)??[]);return m?v.add(i):v.delete(i),v.size?h.set(s,v):h.delete(s),h})}function Me(s,i){M(m=>{let f=new Map(m);return i?f.set(s,i):f.delete(s),f})}async function Pe(s,i){await de(s,i),a.current&&(o(m=>Q(m,s,i)),r(m=>Q(m,s,i)))}async function Be(s,i){let m=await me(s);a.current&&N({app:s,name:i,content:m.body?.role||""})}async function De(s,i,m){confirm(t("team.removeMemberConfirm",{name:m}))&&(await ue(s,i),a.current&&A())}async function He(s){let i=[...X(B,s.key)];if(!i.length){$(s.key,{kind:"err",key:"team.errPickBot"});return}let m=(D.get(s.key)||"").trim()||t("team.defaultGroupName");$(s.key,{kind:"muted",key:"team.creatingGroup"});let f=s.kind==="local"?await pe(s.teamId,m,i):await ge(s.hubUrl,s.teamId,m,i);a.current&&($(s.key,{kind:"group-result",body:f.body,status:f.status}),f.body?.ok&&(x(h=>{let v=new Map(h);return v.delete(s.key),v}),M(h=>{let v=new Map(h);return v.delete(s.key),v}),s.kind==="local"&&A()))}async function ne(s){w({kind:"loading",key:s?"team.binding":"team.identifying"});let i=await ce(s);if(!a.current)return;let m=i.body;if(m?.ok&&m.owner){w({kind:"ok",name:m.owner.name||m.owner.unionId||""}),A();return}if(m?.ok&&m.needChoice&&Array.isArray(m.candidates)){w({kind:"choice",candidates:m.candidates});return}if(m?.error==="no_candidates"){w({kind:"err",key:"team.noCandidates"});return}w({kind:"bind-fail",error:String(m?.error||"unknown")})}return(0,e.jsxs)("section",{className:"page team-page team-home-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("team.eyebrow")}),(0,e.jsx)("h1",{children:t("team.homeTitle")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(Ce,{active:"home"})})]}),(0,e.jsxs)("section",{className:"overview-block team-identity-section",children:[(0,e.jsx)(q,{title:t("team.localDeployTitle"),hint:t("team.bindHint")}),(0,e.jsx)("div",{className:"card team-card team-identity-card",children:(0,e.jsxs)("p",{className:"team-identity-row",children:[(0,e.jsx)("span",{className:"team-identity-label",children:t("team.myIdentity")}),(0,e.jsx)("b",{id:"tf-owner",children:k}),(0,e.jsx)("button",{type:"button",id:"tf-autobind",className:"page-primary-action",onClick:()=>{ne()},children:t("team.bindBtn")}),(0,e.jsx)("span",{id:"tf-bind-out",className:"team-bind-status",hidden:U.kind==="hidden",children:(0,e.jsx)(Oe,{state:U,tr:t,onPick:s=>{ne(s)}})})]})})]}),(0,e.jsxs)("section",{className:"overview-block team-roster-section",children:[(0,e.jsx)(q,{title:t("team.myTeams"),count:ae?ae.replace(/^·\s*/,""):void 0,hint:t("team.teamsHint")}),(0,e.jsxs)("div",{className:"card team-card team-roster-card",children:[(0,e.jsxs)("form",{className:"team-filters dashboard-toolbar",onSubmit:s=>s.preventDefault(),children:[(0,e.jsx)("input",{id:"tf-search",type:"search",placeholder:t("team.searchPh"),value:u.query,onChange:s=>R(i=>({...i,query:s.target.value}))}),(0,e.jsx)(re,{id:"tf-cli",className:"team-cli-menu",ariaLabel:t("team.allCli"),value:u.cliId,label:se(ee,u.cliId),options:ee,onChange:s=>R(i=>({...i,cliId:s}))}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-fcap",checked:u.hasCapability,onChange:s=>R(i=>({...i,hasCapability:s.target.checked}))}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("team.hasCap")})]}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-frole",checked:u.hasRole,onChange:s=>R(i=>({...i,hasRole:s.target.checked}))}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("team.hasRole")})]})]}),(0,e.jsx)("div",{id:"tf-teams",children:(0,e.jsx)(Ue,{teams:b,filters:u,pickedByTeam:B,gnameByTeam:D,expandedTeams:O,expandedDeps:P,groupOutputs:j,myDeploymentId:p,tr:t,onToggleTeam:s=>I(i=>Re(i,s)),onToggleDep:s=>H(i=>Re(i,s)),onPick:xe,onGroupNameChange:Me,onCapabilityChange:(s,i)=>{Pe(s,i)},onOpenRole:(s,i)=>{Be(s,i)},onRemoveMember:(s,i,m)=>{De(s,i,m)},onPullGroup:s=>{He(s)}})})]})]}),(0,e.jsx)(_e,{state:g,tr:t,onClose:()=>N(null)})]})}function Re(t,a){let n=new Set(t);return n.has(a)?n.delete(a):n.add(a),n}function Oe(t){let{state:a,tr:n}=t;return a.kind==="hidden"?null:a.kind==="loading"?(0,e.jsx)("span",{className:"team-bind-loading",children:n(a.key)}):a.kind==="ok"?(0,e.jsx)("span",{className:"ok",children:n("team.bound2",{name:a.name})}):a.kind==="choice"?(0,e.jsxs)(e.Fragment,{children:[n("team.multiCandidate"),(0,e.jsx)("br",{}),a.candidates.map(o=>(0,e.jsx)("button",{type:"button",className:"tf-pickowner ghost","data-union":o.unionId,style:{margin:"2px"},onClick:()=>t.onPick(o.unionId),children:o.name||o.unionId},o.unionId))]}):a.kind==="err"?(0,e.jsx)("span",{className:"err",children:n(a.key)}):(0,e.jsx)("span",{className:"err",children:n("team.bindFail",{error:a.error})})}function Ue(t){let{tr:a}=t;return t.teams.length?(0,e.jsx)(e.Fragment,{children:t.teams.map(n=>{let o=n.bots.filter(p=>G(p,t.filters)),d=!t.expandedTeams.has(n.key),r=n.kind==="remote"?n.ok?(0,e.jsx)("span",{className:"team-status-pill ok",children:a("team.connected")}):(0,e.jsx)("span",{className:"team-status-pill err",children:a("team.connectFail",{error:n.error||""})}):(0,e.jsx)("span",{className:"team-status-pill muted",children:a("team.iHost")});return(0,e.jsxs)("article",{className:"card team-list-card",children:[(0,e.jsxs)("button",{type:"button",className:"tf-team-h","data-tk":n.key,"aria-expanded":!d,onClick:()=>t.onToggleTeam(n.key),children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:d?"\u203A":"\u2304"}),(0,e.jsx)("b",{children:n.label}),n.sub?(0,e.jsx)("span",{className:"muted",children:n.sub}):null,r,(0,e.jsx)("span",{className:"team-meta-pill",children:a("team.teamMeta",{deps:n.deployments.length,bots:n.bots.length})})]}),d?null:n.kind==="remote"&&!n.ok?(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:a("team.rosterFail")}):(0,e.jsx)(je,{...t,team:n,filtered:o})]},n.key)})}):(0,e.jsx)("p",{className:"muted",children:a("team.noTeams")})}function je(t){let{team:a,tr:n}=t,o=[...a.deployments].sort((r,p)=>r.local===p.local?0:r.local?-1:1),d=o.some(r=>t.filtered.some(p=>p.deployment.id===r.id));return(0,e.jsxs)(e.Fragment,{children:[o.map(r=>(0,Se.createElement)(Fe,{...t,deployment:r,key:r.id})),d?null:(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:n("team.noMatch")}),(0,e.jsxs)("div",{className:"team-pull-row",children:[(0,e.jsxs)("label",{className:"team-pill-field team-group-name-field",children:[(0,e.jsx)("span",{children:n("team.gnameLabel")}),(0,e.jsx)("input",{className:"tf-gname","data-tk":a.key,value:t.gnameByTeam.get(a.key)||"",placeholder:n("team.gnamePlaceholder"),onChange:r=>t.onGroupNameChange(a.key,r.target.value)})]}),(0,e.jsx)("button",{className:"tf-grp page-primary-action","data-tk":a.key,onClick:()=>t.onPullGroup(a),children:n("team.pullGroupBtn")}),(0,e.jsx)("span",{className:"muted team-pull-hint",children:n("team.pullGroupHint")}),(0,e.jsx)("span",{className:"tf-gout","data-tk":a.key,children:(0,e.jsx)(Ge,{output:t.groupOutputs.get(a.key),tr:n})})]})]})}function Fe(t){let{team:a,deployment:n,tr:o}=t,d=t.filtered.filter(u=>u.deployment.id===n.id);if(!d.length)return null;let r=n.id===t.myDeploymentId,p=r?o("team.tagLocal"):n.stale?o("team.tagRemoteStale"):o("team.tagRemote"),T=`${a.key}::${n.id}`,k=t.expandedDeps.has(T),y=d.filter(u=>X(t.pickedByTeam,a.key).has(u.larkAppId)).length;return(0,e.jsxs)("section",{className:"team-deployment-block",children:[(0,e.jsxs)("div",{className:"tf-dep-h","data-dk":T,"aria-expanded":k,role:"button",tabIndex:0,onClick:()=>t.onToggleDep(T),onKeyDown:u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),t.onToggleDep(T))},children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:k?"\u2304":"\u203A"}),(0,e.jsx)("b",{children:n.name}),(0,e.jsxs)("span",{className:"muted",children:[o("team.depTag",{tag:p})," \xB7 ",o("team.depCount",{count:d.length}),y?o("team.depSelected",{n:y}):""]}),a.kind==="local"&&!r?(0,e.jsx)("button",{type:"button",className:"tf-rmmember ghost","data-team":a.teamId,"data-dep":n.id,"data-name":n.name,onClick:u=>{u.stopPropagation(),t.onRemoveMember(a.teamId,n.id,n.name)},children:o("team.removeMember")}):null]}),k?(0,e.jsx)("div",{className:"team-roster-list",children:d.map(u=>(0,e.jsx)(Ee,{bot:u,mine:r,picked:X(t.pickedByTeam,a.key).has(u.larkAppId),teamKey:a.key,tr:o,onPick:t.onPick,onCapabilityChange:t.onCapabilityChange,onOpenRole:t.onOpenRole},u.larkAppId))}):null]})}function Ee(t){let{bot:a,tr:n}=t,o=a.deployment.stale?{opacity:.55}:void 0,d=()=>t.onPick(t.teamKey,a.larkAppId,!t.picked);return(0,e.jsxs)("article",{className:`team-bot-row${t.picked?" selected":""}`,style:o,role:"checkbox","aria-checked":t.picked,tabIndex:0,onClick:r=>{Ie(r.target)||d()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||Ie(r.target)||(r.preventDefault(),d())},children:[(0,e.jsxs)("label",{className:`team-check-pill${t.picked?" selected":""}`,onClick:r=>r.stopPropagation(),children:[(0,e.jsx)("input",{type:"checkbox",className:"tf-pick","data-tk":t.teamKey,"data-app":a.larkAppId,checked:t.picked,onChange:r=>t.onPick(t.teamKey,a.larkAppId,r.target.checked)}),(0,e.jsx)("span",{className:"team-check-dot","aria-hidden":"true"})]}),(0,e.jsxs)("div",{className:"team-bot-main",children:[(0,e.jsx)("strong",{children:a.name}),(0,e.jsx)("span",{children:a.larkAppId})]}),(0,e.jsx)("span",{className:"team-meta-pill",children:a.cliId}),(0,e.jsx)("div",{className:"team-capability-cell",children:t.mine?(0,e.jsxs)("label",{className:"team-pill-field team-cap-field",children:[(0,e.jsx)("span",{children:n("team.capLabel")}),(0,e.jsx)("input",{className:"tf-cap","data-app":a.larkAppId,defaultValue:a.capability||"",placeholder:n("team.capPh"),onBlur:r=>{let p=r.target.value;p!==(a.capability||"")&&t.onCapabilityChange(a.larkAppId,p)},onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),r.currentTarget.blur())}})]}):a.capability||null}),(0,e.jsx)("div",{className:"team-role-cell",children:a.hasTeamRole?t.mine?(0,e.jsx)("button",{className:"tf-role","data-app":a.larkAppId,"data-name":a.name,onClick:()=>t.onOpenRole(a.larkAppId,a.name),children:n("team.viewRole")}):n("team.hasRoleShort"):(0,e.jsx)("span",{className:"muted",children:"\u2014"})})]})}function Ie(t){return t instanceof HTMLElement?!!t.closest('button, input, textarea, select, a, label, [contenteditable="true"]'):!1}function Ge(t){let{output:a,tr:n}=t;return a?a.kind==="muted"?(0,e.jsx)("span",{className:"muted",children:n(a.key)}):a.kind==="err"?(0,e.jsx)("span",{className:"err",children:n(a.key)}):(0,e.jsx)($e,{body:a.body,status:a.status,tr:n}):null}function $e(t){let{body:a,status:n,tr:o}=t;if(a?.ok&&a.chatId){let p=a.shareLink||"https://applink.feishu.cn/client/chat/open?openChatId="+encodeURIComponent(a.chatId);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"ok",children:o("team.groupCreated")}),a.delegatedTo?o("team.delegatedBy",{name:String(a.delegatedTo)}):""," \xB7 ",(0,e.jsx)("a",{href:p,target:"_blank",rel:"noreferrer",children:o("team.openInLark")}),(a.invalidBotIds||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.invalidBots",{ids:(a.invalidBotIds||[]).join(", ")})]}):null,(a.invalidOwnerUnionIds||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.invalidOwners",{n:(a.invalidOwnerUnionIds||[]).length})]}):null,a.missingOperatorIdentity?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.missingIdentity")]}):null,(a.skippedNoOwner||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.skippedNoOwner",{n:(a.skippedNoOwner||[]).length})]}):null]})}let d=a?.error||n,r=d==="no_local_online_bot"?o("team.errNoLocalBot"):d==="all_bots_skipped_no_owner"?o("team.errAllSkipped"):d==="no_creator_available"?o("team.errNoCreator"):d==="delegation_timeout"?o("team.errDelegationTimeout"):o("team.errGroupCreate",{error:String(d)});return(0,e.jsx)("span",{className:"err",children:r})}function _e(t){let{state:a,tr:n}=t;return(0,e.jsx)("div",{id:"tf-modal",className:"team-role-modal","data-app":a?.app,hidden:!a,children:(0,e.jsxs)("div",{className:"team-role-dialog",children:[(0,e.jsx)("h2",{id:"tf-modal-title",children:a?n("team.roleModalTitleName",{name:a.name}):n("team.roleModalTitle")}),(0,e.jsx)("p",{className:"muted",style:{fontSize:"13px"},children:n("team.roleModalHint")}),(0,e.jsx)("textarea",{id:"tf-modal-text",readOnly:!0,value:a?.content??""}),(0,e.jsx)("div",{className:"team-role-actions",children:(0,e.jsx)("button",{type:"button",id:"tf-modal-cancel",onClick:t.onClose,children:n("team.close")})})]})})}function ze(){let t=F(),a=we(),[n,o]=(0,l.useState)([]),[d,r]=(0,l.useState)(""),[p,T]=(0,l.useState)(""),[k,y]=(0,l.useState)({kind:"none"}),[u,R]=(0,l.useState)(()=>new Map),[B,x]=(0,l.useState)(""),[D,M]=(0,l.useState)(""),[O,I]=(0,l.useState)({kind:"none"}),P=(0,l.useCallback)(async()=>{let c=await W();if(!a.current)return;let g=c.body;r(N=>g?.suggestedHubUrl||N),o(g?.teams||[])},[a]);(0,l.useEffect)(()=>{P()},[P]);async function H(){let c=p.trim();if(!c){y({kind:"err",key:"team.errName"});return}y({kind:"muted",key:"team.creating"});let g=await ye(c);a.current&&(g.body?.ok?(y({kind:"ok",key:"team.created"}),T(""),P()):y({kind:"create-fail",error:String(g.body?.error||g.status)}))}async function U(c){R(N=>{let b=new Map(N);return b.set(c,{kind:"muted",key:"team.generating"}),b});let g=await ke(c);a.current&&R(N=>{let b=new Map(N);return b.set(c,g.body?.code?{kind:"invite",code:g.body.code}:{kind:"err",key:"team.genFail"}),b})}async function w(c,g){confirm(t("team.delConfirm",{name:g}))&&(await be(c),a.current&&P())}async function j(){let c=B.trim(),g=D.trim();if(I({kind:"muted",key:"team.joining"}),!c||!g){I({kind:"err",key:"team.errHubCode"});return}let N=await he(c,g);a.current&&(N.body?.ok?(I({kind:"joined",name:String(N.body.teamName||"")}),M("")):I({kind:"join-fail",error:N.body?.error||N.status}))}return(0,e.jsxs)("section",{className:"page team-page team-manage-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("team.eyebrow")}),(0,e.jsx)("h1",{children:t("team.manageTitle")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(Ce,{active:"manage"})})]}),(0,e.jsxs)("div",{className:"card team-card",children:[(0,e.jsx)("div",{className:"team-card-head",children:(0,e.jsx)("h2",{children:t("team.hostedTitle")})}),(0,e.jsxs)("form",{className:"team-inline-form dashboard-toolbar",onSubmit:c=>{c.preventDefault(),H()},children:[(0,e.jsx)("input",{id:"tm-newname",type:"text",placeholder:t("team.newTeamPh"),value:p,onChange:c=>T(c.target.value)}),(0,e.jsx)(ie,{id:"tm-create",className:"page-primary-action",onClick:()=>{H()},children:t("team.createTeamBtn")}),(0,e.jsx)("span",{className:"toolbar-status tm-cout",children:(0,e.jsx)(Y,{status:k,tr:t})})]}),(0,e.jsx)("div",{id:"tm-list",children:(0,e.jsx)(Ke,{teams:n,suggestedHubUrl:d,inviteStatuses:u,tr:t,onInvite:c=>{U(c)},onDelete:(c,g)=>{w(c,g)}})})]}),(0,e.jsxs)("div",{className:"card team-card",children:[(0,e.jsx)("div",{className:"team-card-head",children:(0,e.jsx)("h2",{children:t("team.joinTitle")})}),(0,e.jsxs)("form",{className:"team-inline-form dashboard-toolbar team-join-form",onSubmit:c=>{c.preventDefault(),j()},children:[(0,e.jsx)("input",{id:"tm-hub",type:"text",placeholder:t("team.hubPh"),value:B,onChange:c=>x(c.target.value)}),(0,e.jsx)("input",{id:"tm-code",type:"text",placeholder:t("team.codePh"),value:D,onChange:c=>M(c.target.value)}),(0,e.jsx)("button",{type:"button",id:"tm-join",className:"page-primary-action",onClick:()=>{j()},children:t("team.joinBtn")})]}),(0,e.jsx)("div",{id:"tm-join-out",className:"team-inline-output",hidden:O.kind==="none",children:(0,e.jsx)(Y,{status:O,tr:t})})]})]})}function Ke(t){let{teams:a,tr:n}=t;return a.length?(0,e.jsx)(e.Fragment,{children:a.map(o=>{let d=(o.deployments||[]).filter(p=>!p.local).length,r=t.inviteStatuses.get(o.teamId)??{kind:"none"};return(0,e.jsxs)("div",{className:"card team-list-card team-manage-card",children:[(0,e.jsxs)("div",{className:"team-manage-head",children:[(0,e.jsx)("b",{children:o.name}),o.isDefault?(0,e.jsx)("span",{className:"team-status-pill muted",children:n("team.default")}):null,(0,e.jsxs)("span",{className:"team-meta-pill",children:[n("team.manageMetaDeps",{count:(o.deployments||[]).length}),d?n("team.manageMetaRemote",{r:d}):""," \xB7 ",n("team.manageMetaBots",{count:(o.bots||[]).length})]}),(0,e.jsxs)("span",{className:"team-manage-actions",children:[(0,e.jsx)("button",{className:"tm-invite ghost","data-team":o.teamId,onClick:()=>t.onInvite(o.teamId),children:n("team.genInvite")}),o.isDefault?null:(0,e.jsx)("button",{className:"tm-del ghost","data-team":o.teamId,"data-name":o.name,onClick:()=>t.onDelete(o.teamId,o.name),children:n("team.delBtn")})]})]}),(0,e.jsx)("div",{className:"tm-inv-out team-inline-output","data-team":o.teamId,hidden:r.kind==="none",children:(0,e.jsx)(Y,{status:r,tr:n,suggestedHubUrl:t.suggestedHubUrl})}),(0,e.jsx)(qe,{teamId:o.teamId,initial:o.feedback??null})]},o.teamId)})}):(0,e.jsx)("p",{className:"muted",children:n("team.noTeamsShort")})}function qe(t){let[a,n]=(0,l.useState)(JSON.stringify(t.initial??{enabled:!1},null,2)),[o,d]=(0,l.useState)(""),[r,p]=(0,l.useState)(!1);async function T(){p(!0),d("");try{let k=JSON.parse(a),y=await fe(t.teamId,k);if(y.status<200||y.status>=300||y.body.ok===!1)throw new Error(String(y.body?.error??y.status));n(JSON.stringify(y.body.feedback??null,null,2)),d("\u2713 \u5DF2\u4FDD\u5B58")}catch(k){d(`\u2717 ${k instanceof Error?k.message:String(k)}`)}finally{p(!1)}}return(0,e.jsxs)("div",{className:"team-feedback-editor",children:[(0,e.jsxs)("label",{children:[(0,e.jsx)("span",{children:"\u56E2\u961F\u53CD\u9988\u7B56\u7565"}),(0,e.jsx)("textarea",{rows:6,value:a,disabled:r,onChange:k=>n(k.target.value)})]}),(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",disabled:r,onClick:()=>{T()},children:"\u4FDD\u5B58\u53CD\u9988\u7B56\u7565"}),(0,e.jsx)("span",{children:o})]})]})}function Y(t){let{status:a,tr:n}=t;if(a.kind==="none")return null;if(a.kind==="muted")return(0,e.jsx)("span",{className:"muted",children:n(a.key)});if(a.kind==="ok")return(0,e.jsx)("span",{className:"ok",children:n(a.key)});if(a.kind==="err")return(0,e.jsx)("span",{className:"err",children:n(a.key)});if(a.kind==="create-fail")return(0,e.jsx)("span",{className:"err",children:n("team.createFail",{error:a.error})});if(a.kind==="invite")return(0,e.jsxs)(e.Fragment,{children:[n("team.inviteResultLede"),(0,e.jsx)("br",{}),n("team.inviteHub"),(0,e.jsx)("code",{children:t.suggestedHubUrl||""}),(0,e.jsx)("br",{}),n("team.inviteCode"),(0,e.jsx)("code",{className:"team-invite-code",children:a.code})]});if(a.kind==="joined")return(0,e.jsx)("span",{className:"ok",children:n("team.joined",{name:a.name})});let o=a.error,d=o==="cannot_join_self"?n("team.joinErrSelf"):o==="deployment_already_joined"?n("team.joinErrAlready"):o==="hub_unreachable"?n("team.joinErrUnreachable"):o==="hub_timeout"?n("team.joinErrTimeout"):n("team.joinErrGeneric",{error:String(o)});return(0,e.jsx)("span",{className:"err",children:d})}function Ze(t){return K(t,(0,e.jsx)(Le,{}))}function et(t){return K(t,(0,e.jsx)(ze,{}))}export{Ze as renderTeamFederationPage,et as renderTeamManagePage};