@xopcai/xopc 0.0.331 → 0.0.333

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 (388) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B0BtF24E.js → agent-avatar-dicebear-DiI2O7lC.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CVp3J969.js +1 -0
  5. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DbvLXQO2.js → agent-plugin-dialog-CacyndrS.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-DXYZSuUV.js +70 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-fwzTRJfP.js → app-management-settings-panel-BcszTlqr.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-v_GGe8UZ.js → appearance-settings-B1XPe8qz.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-C9ZMEuuA.js → apps-page-ZqANbUZv.js} +1 -1
  10. package/dist/gateway/static/root/assets/{archive-plugin-B6EgADeH.js → archive-plugin-MjUsJcNb.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-B4H_IFeX.js → attachment-load-DHa-BI9a.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-UlVCvg4r.js → automations-page-Dsjivdxs.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-workspace-B37vs5tk.js +7 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-BxTSx30f.js → binary-plugins-DQYcuBHP.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-CVzdrpjl.js → block-editor-Bx0uXbJP.js} +3 -3
  16. package/dist/gateway/static/root/assets/{browser-automation-inputs-C5s1yHOu.js → browser-automation-inputs-1ZIPGDeq.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-automations-page-CBVD8k6O.js → browser-automations-page-CCjYipHc.js} +2 -2
  18. package/dist/gateway/static/root/assets/browser-settings-page-CSv4rvmx.js +3 -0
  19. package/dist/gateway/static/root/assets/capabilities-BnO9LV7U.js +1 -0
  20. package/dist/gateway/static/root/assets/{capabilities-page-BAT7Vvb8.js → capabilities-page-BfvDvIY1.js} +2 -2
  21. package/dist/gateway/static/root/assets/capabilities-settings-panel-CoW7-ESq.js +8 -0
  22. package/dist/gateway/static/root/assets/{capability-header-actions-EETjXmkG.js → capability-header-actions-D_hbWRRF.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-BhMaRh1x.js +1 -0
  24. package/dist/gateway/static/root/assets/{chat-terminal-dock-DCqm9j9W.js → chat-terminal-dock-Fnum_IEm.js} +1 -1
  25. package/dist/gateway/static/root/assets/{computer-settings-page-CxFWdovV.js → computer-settings-page-DI1zfCTA.js} +1 -1
  26. package/dist/gateway/static/root/assets/{connector-service-page-wxsEhmlU.js → connector-service-page-CiGDAubm.js} +1 -1
  27. package/dist/gateway/static/root/assets/connectors-page-Ono0Pha1.js +2 -0
  28. package/dist/gateway/static/root/assets/{date-picker-h_OS6uBR.js → date-picker-D-JhzZyW.js} +1 -1
  29. package/dist/gateway/static/root/assets/{dependency-picker-DNgSSH3z.js → dependency-picker-DpD3xaEB.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-CflvPnB-.js → desktop-pet-CCoDxKqh.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-settings-CXy0X5Js.js → desktop-pet-settings-GxndKfCx.js} +1 -1
  32. package/dist/gateway/static/root/assets/{device-pairing-wizard-BDMiJcsK.js → device-pairing-wizard-B71w3ptm.js} +1 -1
  33. package/dist/gateway/static/root/assets/{directory-picker-path-field-BqkOh13m.js → directory-picker-path-field-CUzjJvjs.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-debug-page-VT4s-9pK.js → extension-debug-page-BtDY8ntX.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-CBSeGhGA.js → extension-page-D9_XF-XC.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-DRB6uOo8.js → extension-settings-page-CjhUFAaC.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-swr-cR-tz7-Q.js → gateway-config-swr-CgIjCxM8.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-settings-lF-FpnZy.js → gateway-settings-BWaCnwT1.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-startup-retry-6jLRcQsu.js → gateway-startup-retry-i-1lTrwY.js} +1 -1
  40. package/dist/gateway/static/root/assets/home-page-BTjGLngn.js +1 -0
  41. package/dist/gateway/static/root/assets/{image-generation-api-CSSkwsyC.js → image-generation-api-gilc-u7M.js} +1 -1
  42. package/dist/gateway/static/root/assets/{imports-page-DGkOijwE.js → imports-page-BEtq5BRU.js} +1 -1
  43. package/dist/gateway/static/root/assets/index-DHL16aYZ.js +121 -0
  44. package/dist/gateway/static/root/assets/index-N1e6PDwx.css +1 -0
  45. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-iU6c2zg1.js → keyboard-shortcuts-settings-JUYY_18v.js} +1 -1
  46. package/dist/gateway/static/root/assets/local-app-workbench-page-uI7mtoVz.js +1 -0
  47. package/dist/gateway/static/root/assets/{local-apps-page-C0BWC8D2.js → local-apps-page-BlYESNqz.js} +1 -1
  48. package/dist/gateway/static/root/assets/{locale-store-wNXWkWu5.js → locale-store-BY30D6tg.js} +1 -1
  49. package/dist/gateway/static/root/assets/{logs-page-Dpoi-r-_.js → logs-page-BbLQreeN.js} +2 -2
  50. package/dist/gateway/static/root/assets/management-settings-c4krhYU7.js +1 -0
  51. package/dist/gateway/static/root/assets/{markdown-view-DlT9KqwF.js → markdown-view-BEeXMfDw.js} +1 -1
  52. package/dist/gateway/static/root/assets/{media-plugins-C8E_F2F_.js → media-plugins-DEFN1I73.js} +1 -1
  53. package/dist/gateway/static/root/assets/messages-_6IXbP2u.js +3 -0
  54. package/dist/gateway/static/root/assets/note-detail-panel--09xGxyE.js +5 -0
  55. package/dist/gateway/static/root/assets/notes-page-DsxcVBXF.js +8 -0
  56. package/dist/gateway/static/root/assets/{page-context-capture-button-qqWG_gs_.js → page-context-capture-button-D43aVpCj.js} +1 -1
  57. package/dist/gateway/static/root/assets/{page-tabs-b3lheKy4.js → page-tabs-BhYBCqls.js} +1 -1
  58. package/dist/gateway/static/root/assets/{preview-open-alternatives-0Q4rTfGX.js → preview-open-alternatives-CP8agNlc.js} +1 -1
  59. package/dist/gateway/static/root/assets/{product-open-page-jnJZCrKQ.js → product-open-page-CU7fRhfT.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-U-EdDfAW.js +1 -0
  61. package/dist/gateway/static/root/assets/{projects-page-r96k_2wB.js → projects-page-DUOKZLt7.js} +1 -1
  62. package/dist/gateway/static/root/assets/{registry-api-BIpltJ47.js → registry-api-BvVx0G1o.js} +1 -1
  63. package/dist/gateway/static/root/assets/{remote-access-hub-B1d8pB_y.js → remote-access-hub-fVPQe5YS.js} +1 -1
  64. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Do_iF13W.js → runtime-tools-settings-panel-Czvzsuj_.js} +2 -2
  65. package/dist/gateway/static/root/assets/scenes-page-C0-WHOY3.js +2 -0
  66. package/dist/gateway/static/root/assets/{schema-form-Cfft26Je.js → schema-form-B9Ni5O93.js} +1 -1
  67. package/dist/gateway/static/root/assets/sessions-page-DdXvW09N.js +1 -0
  68. package/dist/gateway/static/root/assets/settings-advanced-gate-BtF83fBY.js +1 -0
  69. package/dist/gateway/static/root/assets/{settings-form-section-iI0MTyuU.js → settings-form-section-jquf1P7n.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-C2Ka9oJm.js → settings-page-DPomsvba.js} +1 -1
  71. package/dist/gateway/static/root/assets/{setup-status-panel-nnmS_p5h.js → setup-status-panel-BvVlqpHf.js} +1 -1
  72. package/dist/gateway/static/root/assets/{share-preview-page-D0Knvtlp.js → share-preview-page-b9DI0N1J.js} +1 -1
  73. package/dist/gateway/static/root/assets/shares-settings-R_qwc4DN.js +1 -0
  74. package/dist/gateway/static/root/assets/{skill-api-BuZKcy9b.js → skill-api-Bu7-3w-L.js} +1 -1
  75. package/dist/gateway/static/root/assets/skill-reload-api-CNJAQ_e-.js +1 -0
  76. package/dist/gateway/static/root/assets/{skills-page-DcxWxIrR.js → skills-page-D7XPEQu_.js} +1 -1
  77. package/dist/gateway/static/root/assets/{system-settings-panel-CMG0ZAsd.js → system-settings-panel-BwFR0Uci.js} +1 -1
  78. package/dist/gateway/static/root/assets/task-detail-page-PFjGW2g1.js +1 -0
  79. package/dist/gateway/static/root/assets/{tunnel-api-DGYA6GyO.js → tunnel-api-PfucxMP3.js} +1 -1
  80. package/dist/gateway/static/root/assets/usage-page-t_zdQHcy.js +1 -0
  81. package/dist/gateway/static/root/assets/{use-autosave-CDemMoSX.js → use-autosave-DLyy2wHz.js} +1 -1
  82. package/dist/gateway/static/root/assets/user-model-page-OyfPVfB9.js +2 -0
  83. package/dist/gateway/static/root/assets/{voice-api-key-field-CXArY4t5.js → voice-api-key-field-CQDY5EBK.js} +1 -1
  84. package/dist/gateway/static/root/assets/{voice-config-api-ujEySjyc.js → voice-config-api-Bwy3Al3J.js} +1 -1
  85. package/dist/gateway/static/root/assets/{work-discovery-overlay-Dk5KsKOm.js → work-discovery-overlay-CJzqJ47I.js} +1 -1
  86. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DNpdaI-2.js → workflow-run-setup-panel-sCOk-esV.js} +2 -2
  87. package/dist/gateway/static/root/assets/workflows-page-DYBGjN7C.js +6 -0
  88. package/dist/gateway/static/root/index.html +9 -9
  89. package/dist/package.js +1 -1
  90. package/dist/packages/gateway-contract/src/automations.js +59 -14
  91. package/dist/packages/gateway-contract/src/capabilities.js +106 -8
  92. package/dist/packages/gateway-contract/src/index.js +2 -0
  93. package/dist/packages/gateway-contract/src/scenes.js +7 -6
  94. package/dist/packages/gateway-contract/src/sessions.js +2 -1
  95. package/dist/packages/gateway-contract/src/usage.js +6 -0
  96. package/dist/src/agent/agent-manager.js +13 -7
  97. package/dist/src/agent/background-review/run-background-review.js +7 -2
  98. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
  99. package/dist/src/agent/embedded/run-turn.js +7 -1
  100. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  101. package/dist/src/agent/external-tools/gateway-tools.d.ts +2 -1
  102. package/dist/src/agent/external-tools/gateway-tools.js +44 -11
  103. package/dist/src/agent/external-tools/index.js +1 -1
  104. package/dist/src/agent/image/tool-model-config.js +1 -1
  105. package/dist/src/agent/image/understanding/pi-ai-provider.js +1 -1
  106. package/dist/src/agent/memory/compaction.js +4 -0
  107. package/dist/src/agent/orchestration/agent-orchestrator.js +0 -21
  108. package/dist/src/agent/service/btw-query.js +8 -2
  109. package/dist/src/agent/service.js +3 -3
  110. package/dist/src/agent/skills/filesystem-watcher.js +1 -1
  111. package/dist/src/agent/skills/hub-pull.js +2 -2
  112. package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +1 -1
  113. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
  114. package/dist/src/agent/tasks/task-judge-service.js +4 -0
  115. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  116. package/dist/src/agent/tool-manuals/xopc-use.js +5 -4
  117. package/dist/src/agent/tools/automation-tool.d.ts +4 -1
  118. package/dist/src/agent/tools/automation-tool.js +42 -4
  119. package/dist/src/agent/tools/session-search-tool.js +1 -1
  120. package/dist/src/agent/tools/web-extract.js +1 -1
  121. package/dist/src/agent/tools/xopc-use-tool.js +50 -9
  122. package/dist/src/agent-catalog/capabilities.js +2 -2
  123. package/dist/src/ai-assist/text-assist.js +5 -1
  124. package/dist/src/auth/credentials.js +1 -1
  125. package/dist/src/auth/oauth-provider-lock.js +1 -1
  126. package/dist/src/auth/sync-provider-auth.js +1 -1
  127. package/dist/src/automations/api/routes.js +65 -0
  128. package/dist/src/automations/capabilities/drafts.js +1 -1
  129. package/dist/src/automations/capabilities/read.js +24 -0
  130. package/dist/src/automations/capabilities/write.d.ts +69 -14
  131. package/dist/src/automations/capabilities/write.js +78 -5
  132. package/dist/src/automations/delivery/delivery-router.d.ts +50 -0
  133. package/dist/src/automations/delivery/delivery-router.js +318 -0
  134. package/dist/src/automations/delivery/index.d.ts +1 -0
  135. package/dist/src/automations/delivery/index.js +2 -0
  136. package/dist/src/automations/domain/defaults.d.ts +0 -1
  137. package/dist/src/automations/domain/defaults.js +2 -2
  138. package/dist/src/automations/domain/index.js +2 -2
  139. package/dist/src/automations/domain/types.d.ts +180 -7
  140. package/dist/src/automations/domain/validation.d.ts +172 -22
  141. package/dist/src/automations/domain/validation.js +82 -13
  142. package/dist/src/automations/draft/automation-draft-prompt.js +3 -4
  143. package/dist/src/automations/draft/automation-draft-service.js +6 -0
  144. package/dist/src/automations/draft/automation-draft-validator.d.ts +31 -3
  145. package/dist/src/automations/draft/automation-draft-validator.js +5 -4
  146. package/dist/src/automations/events/event-catalog.d.ts +14 -0
  147. package/dist/src/automations/events/event-catalog.js +117 -0
  148. package/dist/src/automations/events/event-dispatcher.d.ts +27 -0
  149. package/dist/src/automations/events/event-dispatcher.js +140 -0
  150. package/dist/src/automations/events/event-repository.d.ts +59 -0
  151. package/dist/src/automations/events/event-repository.js +361 -0
  152. package/dist/src/automations/events/index.d.ts +3 -0
  153. package/dist/src/automations/events/index.js +4 -0
  154. package/dist/src/automations/index.d.ts +3 -1
  155. package/dist/src/automations/index.js +9 -3
  156. package/dist/src/automations/service/action-executor.d.ts +20 -1
  157. package/dist/src/automations/service/action-executor.js +80 -24
  158. package/dist/src/automations/service/automation-service.d.ts +21 -4
  159. package/dist/src/automations/service/automation-service.js +150 -100
  160. package/dist/src/automations/storage/automation-repository.js +7 -7
  161. package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
  162. package/dist/src/automations/storage/automation-run-repository.js +26 -1
  163. package/dist/src/automations/storage/index.js +2 -2
  164. package/dist/src/automations/webhook-secrets.d.ts +1 -0
  165. package/dist/src/automations/webhook-secrets.js +16 -0
  166. package/dist/src/bootstrap/application-state.js +1 -1
  167. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  168. package/dist/src/capabilities/runtime/product.js +1 -1
  169. package/dist/src/capabilities/store-connector.d.ts +17 -1
  170. package/dist/src/capabilities/store-connector.js +69 -3
  171. package/dist/src/chat-commands/agent-edit.js +1 -1
  172. package/dist/src/chat-commands/builtins/config.js +1 -1
  173. package/dist/src/cli/commands/agent.js +1 -1
  174. package/dist/src/cli/commands/agents.js +1 -1
  175. package/dist/src/cli/commands/connectors.js +4 -3
  176. package/dist/src/cli/commands/doctor/checks/automation-integrity.d.ts +2 -0
  177. package/dist/src/cli/commands/doctor/checks/automation-integrity.js +55 -0
  178. package/dist/src/cli/commands/doctor/checks/database-relations.d.ts +2 -0
  179. package/dist/src/cli/commands/doctor/checks/database-relations.js +81 -0
  180. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  181. package/dist/src/cli/commands/doctor/flow.js +5 -1
  182. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  183. package/dist/src/cli/commands/models.js +1 -1
  184. package/dist/src/cli/commands/onboard/model.js +2 -2
  185. package/dist/src/cli/commands/skills.js +1 -1
  186. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  187. package/dist/src/config/index.js +4 -4
  188. package/dist/src/config/loader.js +2 -2
  189. package/dist/src/config/models-json.js +1 -1
  190. package/dist/src/config/schema.d.ts +4 -0
  191. package/dist/src/config/schema.js +5 -1
  192. package/dist/src/connectors/approval-resume.js +1 -1
  193. package/dist/src/connectors/cli/store.js +1 -1
  194. package/dist/src/connectors/composio-backends.js +14 -4
  195. package/dist/src/connectors/composio-managed-events.d.ts +5 -2
  196. package/dist/src/connectors/composio-managed-events.js +4 -1
  197. package/dist/src/connectors/connection-recovery-service.d.ts +2 -1
  198. package/dist/src/connectors/connection-recovery-service.js +89 -4
  199. package/dist/src/discussions/analyzer.js +4 -4
  200. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  201. package/dist/src/extensions/update.js +1 -1
  202. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  203. package/dist/src/gateway/agents-admin.js +2 -2
  204. package/dist/src/gateway/file-path-classifier.js +1 -1
  205. package/dist/src/gateway/home-intelligence-automation-reconciler.d.ts +3 -0
  206. package/dist/src/gateway/home-intelligence-automation-reconciler.js +52 -0
  207. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  208. package/dist/src/gateway/hono/routes/capabilities.js +1 -1
  209. package/dist/src/gateway/hono/routes/config-patch/misc.js +18 -4
  210. package/dist/src/gateway/hono/routes/connection-waits.js +3 -2
  211. package/dist/src/gateway/hono/routes/home.js +0 -1
  212. package/dist/src/gateway/hono/routes/lazy-bundles.js +14 -1
  213. package/dist/src/gateway/hono/routes/notes.js +2 -2
  214. package/dist/src/gateway/hono/routes/projects.js +2 -2
  215. package/dist/src/gateway/hono/routes/public-gateway.js +93 -3
  216. package/dist/src/gateway/hono/routes/scenes.js +57 -41
  217. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  218. package/dist/src/gateway/hono/routes/sessions.js +15 -0
  219. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  220. package/dist/src/gateway/hono/routes/update.js +6 -1
  221. package/dist/src/gateway/hono/routes/usage.d.ts +3 -0
  222. package/dist/src/gateway/hono/routes/usage.js +61 -0
  223. package/dist/src/gateway/hono/routes/voice.js +1 -1
  224. package/dist/src/gateway/image-generation-setup.js +2 -2
  225. package/dist/src/gateway/lock.js +1 -1
  226. package/dist/src/gateway/memory-maintenance-automation-reconciler.js +21 -15
  227. package/dist/src/gateway/scenes/host.js +27 -14
  228. package/dist/src/gateway/scenes/slackThreadSource.d.ts +2 -2
  229. package/dist/src/gateway/security/gateway-scopes.js +1 -0
  230. package/dist/src/gateway/service/active-execution.d.ts +19 -0
  231. package/dist/src/gateway/service/active-execution.js +16 -0
  232. package/dist/src/gateway/service/agent-runner.d.ts +4 -0
  233. package/dist/src/gateway/service/agent-runner.js +19 -1
  234. package/dist/src/gateway/service/marketplace-service.js +2 -2
  235. package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
  236. package/dist/src/gateway/service/run-gateway-agent.js +9 -1
  237. package/dist/src/gateway/service/sessions-api.d.ts +13 -0
  238. package/dist/src/gateway/service/sessions-api.js +23 -0
  239. package/dist/src/gateway/service.d.ts +7 -3
  240. package/dist/src/gateway/service.js +108 -89
  241. package/dist/src/gateway/side-chat/run-service.js +10 -7
  242. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  243. package/dist/src/home-intelligence/generator.js +4 -1
  244. package/dist/src/home-intelligence/host.d.ts +1 -1
  245. package/dist/src/home-intelligence/host.js +2 -10
  246. package/dist/src/home-intelligence/notification.js +1 -1
  247. package/dist/src/home-intelligence/repository.d.ts +1 -1
  248. package/dist/src/infra/domain-outbox-dispatcher.d.ts +0 -3
  249. package/dist/src/infra/domain-outbox-dispatcher.js +15 -7
  250. package/dist/src/infra/update-check.d.ts +8 -4
  251. package/dist/src/infra/update-check.js +43 -41
  252. package/dist/src/infra/update-startup.d.ts +7 -1
  253. package/dist/src/infra/update-startup.js +15 -6
  254. package/dist/src/local-apps/service.js +2 -2
  255. package/dist/src/memory-maintenance/index.js +2 -2
  256. package/dist/src/memory-maintenance/schedule.d.ts +0 -3
  257. package/dist/src/memory-maintenance/schedule.js +1 -8
  258. package/dist/src/notes/service.js +2 -3
  259. package/dist/src/projects/project-service.js +1 -2
  260. package/dist/src/projects/project-skill-service.js +2 -2
  261. package/dist/src/providers/model-call.d.ts +3 -2
  262. package/dist/src/providers/model-call.js +30 -5
  263. package/dist/src/providers/model-catalog-persistence.js +1 -1
  264. package/dist/src/scenes/activationAdapter.d.ts +19 -0
  265. package/dist/src/scenes/activationAdapter.js +1 -0
  266. package/dist/src/scenes/agentExecutor.js +3 -10
  267. package/dist/src/scenes/contracts.d.ts +3 -9
  268. package/dist/src/scenes/contracts.js +1 -0
  269. package/dist/src/scenes/execution.d.ts +9 -3
  270. package/dist/src/scenes/execution.js +12 -11
  271. package/dist/src/scenes/httpServices.d.ts +5 -2
  272. package/dist/src/scenes/mailContext.d.ts +4 -0
  273. package/dist/src/scenes/mailContext.js +9 -0
  274. package/dist/src/scenes/maintenance.js +1 -5
  275. package/dist/src/scenes/metrics.d.ts +0 -6
  276. package/dist/src/scenes/metrics.js +0 -11
  277. package/dist/src/scenes/registry.d.ts +11 -0
  278. package/dist/src/scenes/registry.js +28 -0
  279. package/dist/src/scenes/repository.d.ts +6 -3
  280. package/dist/src/scenes/repository.js +43 -5
  281. package/dist/src/scenes/service.d.ts +2 -1
  282. package/dist/src/scenes/service.js +9 -7
  283. package/dist/src/scenes/taskFollowUp/contracts.d.ts +37 -7
  284. package/dist/src/scenes/taskFollowUp/contracts.js +36 -17
  285. package/dist/src/scenes/taskFollowUp/service.d.ts +35 -7
  286. package/dist/src/scenes/taskFollowUp/service.js +86 -28
  287. package/dist/src/scenes/templates.d.ts +2 -2
  288. package/dist/src/scenes/userNotes.d.ts +3 -0
  289. package/dist/src/scenes/userNotes.js +6 -0
  290. package/dist/src/session/client-history.d.ts +3 -0
  291. package/dist/src/session/client-history.js +10 -5
  292. package/dist/src/session/manager.d.ts +1 -0
  293. package/dist/src/session/resolve-session.js +4 -3
  294. package/dist/src/session/session-title.js +1 -1
  295. package/dist/src/session/store.d.ts +1 -0
  296. package/dist/src/session/store.js +3 -2
  297. package/dist/src/storage/sqlite/ai-usage-repository.d.ts +137 -0
  298. package/dist/src/storage/sqlite/ai-usage-repository.js +175 -0
  299. package/dist/src/storage/sqlite/connector-account-repository.js +7 -5
  300. package/dist/src/storage/sqlite/connector-repository.js +36 -34
  301. package/dist/src/storage/sqlite/index.d.ts +2 -2
  302. package/dist/src/storage/sqlite/index.js +3 -3
  303. package/dist/src/storage/sqlite/migrations/208_automation_management.sql +2 -0
  304. package/dist/src/storage/sqlite/migrations/209_automation_event_hub.sql +48 -0
  305. package/dist/src/storage/sqlite/migrations/210_remove_legacy_automation_timeout.sql +14 -0
  306. package/dist/src/storage/sqlite/migrations/211_automation_result_deliveries.sql +16 -0
  307. package/dist/src/storage/sqlite/migrations/212_automation_delivery_policy.sql +30 -0
  308. package/dist/src/storage/sqlite/migrations/213_automation_reliability_contract.sql +188 -0
  309. package/dist/src/storage/sqlite/migrations/214_ai_usage_ledger.sql +41 -0
  310. package/dist/src/storage/sqlite/migrations/215_scene_execution_adapters.sql +6 -0
  311. package/dist/src/storage/sqlite/migrations/216_remove_scene_model_usage.sql +1 -0
  312. package/dist/src/storage/sqlite/migrations/217_remove_legacy_memory_tables.sql +4 -0
  313. package/dist/src/storage/sqlite/migrations/218_core_relation_indexes.sql +26 -0
  314. package/dist/src/storage/sqlite/migrations/219_json_contracts.sql +123 -0
  315. package/dist/src/storage/sqlite/migrations/220_normalize_timestamps.sql +339 -0
  316. package/dist/src/storage/sqlite/migrations/221_ai_usage_retention_index.sql +2 -0
  317. package/dist/src/storage/sqlite/migrations/222_session_config_authority.sql +13 -0
  318. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  319. package/dist/src/storage/sqlite/migrations/runner.js +4 -4
  320. package/dist/src/storage/sqlite/row-mappers.d.ts +3 -7
  321. package/dist/src/storage/sqlite/row-mappers.js +6 -6
  322. package/dist/src/storage/sqlite/scenes-schema.d.ts +1 -1
  323. package/dist/src/storage/sqlite/scenes-schema.js +0 -1
  324. package/dist/src/storage/sqlite/schema.js +1 -1
  325. package/dist/src/storage/sqlite/schema.sql +0 -52
  326. package/dist/src/storage/sqlite/schemas/scenes.sql +0 -7
  327. package/dist/src/storage/sqlite/session-input-repository.d.ts +8 -0
  328. package/dist/src/storage/sqlite/session-input-repository.js +18 -1
  329. package/dist/src/storage/sqlite/session-read-repository.d.ts +1 -1
  330. package/dist/src/storage/sqlite/session-read-repository.js +0 -1
  331. package/dist/src/storage/sqlite/session-repository.d.ts +0 -4
  332. package/dist/src/storage/sqlite/session-repository.js +8 -18
  333. package/dist/src/storage/sqlite/timestamps.d.ts +4 -0
  334. package/dist/src/storage/sqlite/timestamps.js +20 -0
  335. package/dist/src/storage/sqlite/transcript-repository.d.ts +1 -0
  336. package/dist/src/storage/sqlite/transcript-repository.js +23 -15
  337. package/dist/src/storage/sqlite/user-trust-repository.js +4 -2
  338. package/dist/src/tasks/capabilities/read.js +2 -2
  339. package/dist/src/tasks/capabilities/write.d.ts +1 -1
  340. package/dist/src/tasks/home-query-service.js +4 -3
  341. package/dist/src/tasks/task-contract-planner.js +1 -1
  342. package/dist/src/tui/backends/embedded-backend.js +2 -2
  343. package/dist/src/tui/tui-commands.js +1 -1
  344. package/dist/src/tui/tui-startup-resources.js +1 -1
  345. package/dist/src/tui/tui.js +1 -1
  346. package/dist/src/usage/cost.d.ts +4 -0
  347. package/dist/src/usage/cost.js +28 -0
  348. package/dist/src/usage/recorder.d.ts +13 -0
  349. package/dist/src/usage/recorder.js +117 -0
  350. package/dist/src/usage/scenario-registry.d.ts +8 -0
  351. package/dist/src/usage/scenario-registry.js +117 -0
  352. package/dist/src/usage/types.d.ts +55 -0
  353. package/dist/src/usage/types.js +1 -0
  354. package/dist/src/user-context/config.d.ts +9 -0
  355. package/dist/src/user-context/config.js +13 -4
  356. package/dist/src/voice/realtime/persona-context.js +1 -1
  357. package/dist/src/voice/tts/summarize.js +1 -1
  358. package/dist/src/work-discovery/analyzer.js +2 -2
  359. package/dist/src/work-discovery/investigator.js +1 -1
  360. package/dist/src/workflows/service/workflow-run-service.js +15 -2
  361. package/package.json +6 -6
  362. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DgP5DEJF.js +0 -1
  363. package/dist/gateway/static/root/assets/agents-Bh4XNLyk.js +0 -70
  364. package/dist/gateway/static/root/assets/automations-workspace-C7VS-yb7.js +0 -7
  365. package/dist/gateway/static/root/assets/browser-settings-page-CC43CC43.js +0 -3
  366. package/dist/gateway/static/root/assets/capabilities-sAZT4brT.js +0 -1
  367. package/dist/gateway/static/root/assets/capabilities-settings-panel-DPETQOfF.js +0 -8
  368. package/dist/gateway/static/root/assets/channels-CwA619os.js +0 -1
  369. package/dist/gateway/static/root/assets/connectors-page-l7goF6QS.js +0 -2
  370. package/dist/gateway/static/root/assets/home-page-DSaXXoLm.js +0 -1
  371. package/dist/gateway/static/root/assets/index-BEw0xrde.css +0 -1
  372. package/dist/gateway/static/root/assets/index-D99vN3es.js +0 -121
  373. package/dist/gateway/static/root/assets/local-app-workbench-page-rH33N8I9.js +0 -1
  374. package/dist/gateway/static/root/assets/management-settings-RFDLaquR.js +0 -1
  375. package/dist/gateway/static/root/assets/messages-fmf0dnr4.js +0 -3
  376. package/dist/gateway/static/root/assets/note-detail-panel-DI7CIjmM.js +0 -5
  377. package/dist/gateway/static/root/assets/notes-page-BkqnU-Jh.js +0 -8
  378. package/dist/gateway/static/root/assets/project-detail-page-BvvcTH2F.js +0 -1
  379. package/dist/gateway/static/root/assets/scenes-page-DK316w9a.js +0 -2
  380. package/dist/gateway/static/root/assets/sessions-page-EIk8iJTK.js +0 -1
  381. package/dist/gateway/static/root/assets/settings-advanced-gate-DcOsdz78.js +0 -1
  382. package/dist/gateway/static/root/assets/shares-settings-BcaxGQLC.js +0 -1
  383. package/dist/gateway/static/root/assets/skill-reload-api-Cb_CUL-U.js +0 -1
  384. package/dist/gateway/static/root/assets/task-detail-page-Cvr1qUTW.js +0 -1
  385. package/dist/gateway/static/root/assets/user-model-page-VXfz3rE7.js +0 -2
  386. package/dist/gateway/static/root/assets/workflows-page-DDNDLdId.js +0 -6
  387. package/dist/src/automations/product-events.d.ts +0 -5
  388. package/dist/src/automations/product-events.js +0 -19
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a,m as o,t as s}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as c}from"./check-DUBLcKHA.js";import{n as l,r as u,t as d}from"./popover-select-DcsFzD_i.js";import{t as f}from"./circle-check-C23XjkUj.js";import{t as p}from"./copy-Dv6d4Dvw.js";import{t as m}from"./download-Dk-ZjtO6.js";import{t as h}from"./external-link-DjqjBmc3.js";import{f as g,m as _,t as v}from"./markdown-view-DlT9KqwF.js";import{t as y}from"./loader-circle-CifKLtgG.js";import{t as b}from"./message-square-plus-XP0tGdlV.js";import{t as x}from"./plus-Q2yW6OE7.js";import{t as S}from"./search-DA7gz22f.js";import{t as C}from"./x-B_N4OPjy.js";import{t as w}from"./messages-fmf0dnr4.js";import{t as T}from"./cn-JdwAhgNB.js";import{a as E,c as D,f as O,n as k,r as A}from"./locale-store-wNXWkWu5.js";import{a as j,i as M,n as N,o as P,r as F,s as I,t as L}from"./dist-BGTk37IG.js";import{i as R,t as z}from"./tasks-CDR_RVbQ.js";import{t as B}from"./copy-to-clipboard-HOJ79TWv.js";import{i as V}from"./vendor-swr-BIWyz7Rc.js";import{t as H}from"./button-CS04eWY9.js";import{a as U,i as ee,n as W,o as G,r as te}from"./dist-3h6cXXhT.js";import{t as ne}from"./skeleton-BwbyijEw.js";import{Bi as re,Br as K,Bu as q,Ca as ie,Cc as J,Cd as ae,Cl as oe,Cu as se,Da as ce,Dc as le,Du as ue,Ea as Y,Ei as de,El as fe,Eu as pe,Gc as me,Gn as he,Ha as ge,Hn as _e,Ho as ve,Ia as ye,Jc as be,Ji as xe,Kn as Se,Li as Ce,Ll as we,Ma as Te,Mc as Ee,Oa as De,Ol as Oe,On as ke,Pc as Ae,Pu as je,Qc as Me,Qn as Ne,Rc as Pe,Sa as Fe,Sd as Ie,Sl as Le,Su as Re,Ta as ze,Td as Be,Tl as Ve,Ui as He,Un as Ue,Va as We,Vn as Ge,Vr as Ke,Wc as qe,Wl as Je,Wn as Ye,Wu as Xe,Xi as Ze,Xn as Qe,Yu as $e,Zc as et,Zl as tt,Zt as nt,_a as rt,_o as it,_r as at,ac as ot,ad as st,al as ct,as as lt,ba as ut,bc as dt,bl as ft,br as pt,bu as mt,cd as ht,cl as gt,co as _t,dl as vt,do as yt,dr as bt,ed as xt,fo as St,fu as Ct,ga as wt,gi as Tt,go as Et,ho as Dt,ic as Ot,id as kt,io as At,lo as jt,lr as Mt,md as Nt,mo as Pt,mu as Ft,no as It,nu as Lt,od as Rt,oo as zt,po as Bt,ps as Vt,pu as Ht,qn as Ut,rd as Wt,rl as Gt,ro as Kt,sc as qt,so as Jt,sr as Yt,tu as Xt,uc as Zt,ul as Qt,uo as $t,ur as en,uu as tn,vo as nn,wa as rn,wn as an,xa as on,ya as sn,yc as cn,yd as ln,yo as un,za as dn}from"./index-D99vN3es.js";import{t as fn}from"./page-tabs-b3lheKy4.js";import{n as pn,t as mn}from"./use-autosave-CDemMoSX.js";import{t as hn}from"./page-context-capture-button-qqWG_gs_.js";import{t as gn}from"./directory-picker-path-field-BqkOh13m.js";import{d as _n,h as vn,o as yn}from"./skill-api-BuZKcy9b.js";import{t as bn}from"./date-picker-h_OS6uBR.js";import{t as xn}from"./automations-workspace-C7VS-yb7.js";import{i as Sn,n as Cn,r as wn,t as Tn}from"./note-detail-panel-DI7CIjmM.js";import{t as En}from"./dependency-picker-DNgSSH3z.js";import{c as Dn,l as On,n as kn,o as An,r as jn,t as X}from"./style-TIDOdKy0.js";var Mn=n(),Z=e(t(),1),Q=r();function Nn(e){let t=(0,Mn.c)(15),{noteId:n,attachmentId:r,className:i}=e,[a,o]=(0,Z.useState)(!1),s;t[0]!==r||t[1]!==n?(s=Ke(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s;if(a){let e;t[3]===i?e=t[4]:(e=T(`flex size-12 shrink-0 items-center justify-center rounded-lg border border-edge-subtle bg-surface-hover text-fg-muted`,i),t[3]=i,t[4]=e);let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(Ct,{className:`size-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,Q.jsx)(`div`,{className:e,"aria-hidden":!0,children:n}),t[6]=e,t[7]=r),r}let l;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>o(!0),t[8]=l):l=t[8];let u;t[9]===i?u=t[10]:(u=T(`size-12 shrink-0 rounded-lg border border-edge-subtle bg-surface-hover object-cover`,i),t[9]=i,t[10]=u);let d;return t[11]!==n||t[12]!==c||t[13]!==u?(d=(0,Q.jsx)(pt,{src:c,expectedNoteId:n,alt:``,loading:`lazy`,draggable:!1,onLoadFailed:l,className:u}),t[11]=n,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function Pn(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,`0`)}`}function Fn(e){let t=(0,Mn.c)(38),{noteId:n,attachmentId:r,durationSec:i,className:a}=e,{playing:o,loading:s,currentTime:c,duration:l,noteId:u,attachmentId:d}=K(),f=K(Ln),p=u===n&&d===r,m=p&&o,h=p&&s,g=p?c:0,_=p&&l>0?l:i??0,v=_>0?Math.min(g/_*100,100):0,b;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==f?(b=e=>{e.stopPropagation(),f(n,r,i)},t[0]=r,t[1]=i,t[2]=n,t[3]=f,t[4]=b):b=t[4];let x=b,S;t[5]!==r||t[6]!==i||t[7]!==n||t[8]!==f?(S=e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),f(n,r,i))},t[5]=r,t[6]=i,t[7]=n,t[8]=f,t[9]=S):S=t[9];let C=S,w;t[10]===a?w=t[11]:(w=T(`flex items-center gap-2`,a),t[10]=a,t[11]=w);let E=m?`bg-accent text-on-accent`:`bg-accent/10 text-accent hover:bg-accent/20`,D;t[12]===E?D=t[13]:(D=T(`flex size-7 shrink-0 items-center justify-center rounded-full transition-colors`,E),t[12]=E,t[13]=D);let O=m?`Pause`:`Play`,k;t[14]!==h||t[15]!==m?(k=h?(0,Q.jsx)(y,{className:`size-3.5 animate-spin`}):m?(0,Q.jsx)(Ve,{className:`size-3.5`}):(0,Q.jsx)(ft,{className:`size-3.5 ml-0.5`}),t[14]=h,t[15]=m,t[16]=k):k=t[16];let A;t[17]!==x||t[18]!==C||t[19]!==D||t[20]!==O||t[21]!==k?(A=(0,Q.jsx)(`button`,{type:`button`,onClick:x,onKeyDown:C,className:D,"aria-label":O,children:k}),t[17]=x,t[18]=C,t[19]=D,t[20]=O,t[21]=k,t[22]=A):A=t[22];let j=`${v}%`,M;t[23]===j?M=t[24]:(M=(0,Q.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:j}})}),t[23]=j,t[24]=M);let N;t[25]!==_||t[26]!==p||t[27]!==g?(N=Pn(p&&g>0?g:_),t[25]=_,t[26]=p,t[27]=g,t[28]=N):N=t[28];let P;t[29]===N?P=t[30]:(P=(0,Q.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:N}),t[29]=N,t[30]=P);let F;t[31]!==M||t[32]!==P?(F=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[M,P]}),t[31]=M,t[32]=P,t[33]=F):F=t[33];let I;return t[34]!==F||t[35]!==w||t[36]!==A?(I=(0,Q.jsxs)(`div`,{className:w,onClick:In,children:[A,F]}),t[34]=F,t[35]=w,t[36]=A,t[37]=I):I=t[37],I}function In(e){return e.stopPropagation()}function Ln(e){return e.toggle}function $(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function Rn(e){let t=(0,Mn.c)(88),{note:n,selected:r,onPress:i,onPin:a,onArchive:o,onDelete:s,labels:c,timeLabels:l}=e,u=r===void 0?!1:r,d;t[0]!==c||t[1]!==n?(d=$(n,c),t[0]=c,t[1]=n,t[2]=d):d=t[2];let f=d,p=!n.snippet?.trim(),[m]=(0,Z.useState)(Gn),h;t[3]!==n.createdAt||t[4]!==m||t[5]!==l?(h=Sn(n.createdAt,m,l),t[3]=n.createdAt,t[4]=m,t[5]=l,t[6]=h):h=t[6];let g=h,_,v;t[7]!==n.id||t[8]!==i?(_=()=>i(n.id),v=e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),i(n.id))},t[7]=n.id,t[8]=i,t[9]=_,t[10]=v):(_=t[9],v=t[10]);let y=u?`bg-surface-active hover:bg-surface-active`:`bg-transparent hover:bg-surface-panel/70`,b;t[11]===y?b=t[12]:(b=T(`group relative flex cursor-pointer flex-col gap-2 overflow-hidden rounded-lg px-3 py-2.5`,`transition-colors duration-150 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-rail`,y),t[11]=y,t[12]=b);let x=u?`true`:void 0,S;t[13]===u?S=t[14]:(S=u?(0,Q.jsx)(`span`,{className:`pointer-events-none absolute inset-y-2 left-0 w-0.5 rounded-r-pill bg-accent`,"aria-hidden":!0}):null,t[13]=u,t[14]=S);let C;t[15]!==n.coverAttachmentId||t[16]!==n.id||t[17]!==n.kind||t[18]!==n.voiceAttachmentId||t[19]!==n.voiceDurationSec?(C=n.coverAttachmentId?(0,Q.jsx)(Nn,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,Q.jsx)(Fn,{noteId:n.id,attachmentId:n.voiceAttachmentId,durationSec:n.voiceDurationSec,className:`mt-0.5 w-28 shrink-0`}):null,t[15]=n.coverAttachmentId,t[16]=n.id,t[17]=n.kind,t[18]=n.voiceAttachmentId,t[19]=n.voiceDurationSec,t[20]=C):C=t[20];let w;t[21]===n.title?w=t[22]:(w=n.title&&(0,Q.jsx)(`h3`,{className:`mb-0.5 truncate text-sm font-semibold text-fg`,children:n.title}),t[21]=n.title,t[22]=w);let E=n.title?`text-fg-muted`:p?`italic text-fg-muted`:`text-fg`,D;t[23]===E?D=t[24]:(D=T(`truncate text-sm leading-5`,E),t[23]=E,t[24]=D);let O;t[25]!==f||t[26]!==D?(O=(0,Q.jsx)(`p`,{className:D,children:f}),t[25]=f,t[26]=D,t[27]=O):O=t[27];let k;t[28]!==w||t[29]!==O?(k=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,O]}),t[28]=w,t[29]=O,t[30]=k):k=t[30];let A;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(je,{className:`size-4`}),t[31]=A):A=t[31];let j;t[32]===c.actions?j=t[33]:(j=(0,Q.jsx)(Ut,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:Wn,className:`shrink-0 rounded-md p-1 text-fg-muted opacity-100 transition-opacity hover:bg-surface-panel focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:opacity-0 lg:group-hover:opacity-100 lg:focus-visible:opacity-100`,"aria-label":c.actions,title:c.actions,children:A})}),t[32]=c.actions,t[33]=j);let M;t[34]!==n.id||t[35]!==n.pinned||t[36]!==a?(M=()=>{a(n.id,!n.pinned).catch(Hn)},t[34]=n.id,t[35]=n.pinned,t[36]=a,t[37]=M):M=t[37];let N;t[38]===n.pinned?N=t[39]:(N=n.pinned?(0,Q.jsx)(Le,{className:`size-4`}):(0,Q.jsx)(oe,{className:`size-4`}),t[38]=n.pinned,t[39]=N);let P=n.pinned?c.unpin:c.pin,F;t[40]!==M||t[41]!==N||t[42]!==P?(F=(0,Q.jsxs)(Ue,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:M,children:[N,P]}),t[40]=M,t[41]=N,t[42]=P,t[43]=F):F=t[43];let I;t[44]!==n.id||t[45]!==o?(I=()=>{o(n.id).catch(Vn)},t[44]=n.id,t[45]=o,t[46]=I):I=t[46];let L;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(Be,{className:`size-4`}),t[47]=L):L=t[47];let R;t[48]!==c.archive||t[49]!==I?(R=(0,Q.jsxs)(Ue,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:I,children:[L,c.archive]}),t[48]=c.archive,t[49]=I,t[50]=R):R=t[50];let z;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Q.jsx)(Se,{className:`my-1 h-px bg-edge-subtle`}),t[51]=z):z=t[51];let B;t[52]!==n.id||t[53]!==s?(B=()=>{s(n.id).catch(Bn)},t[52]=n.id,t[53]=s,t[54]=B):B=t[54];let V;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Q.jsx)(Pe,{className:`size-4`}),t[55]=V):V=t[55];let H;t[56]!==c.delete||t[57]!==B?(H=(0,Q.jsxs)(Ue,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-red-500 outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:B,children:[V,c.delete]}),t[56]=c.delete,t[57]=B,t[58]=H):H=t[58];let U;t[59]!==F||t[60]!==R||t[61]!==H?(U=(0,Q.jsx)(Ye,{children:(0,Q.jsxs)(_e,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:Un,children:[F,R,z,H]})}),t[59]=F,t[60]=R,t[61]=H,t[62]=U):U=t[62];let ee;t[63]!==j||t[64]!==U?(ee=(0,Q.jsxs)(he,{children:[j,U]}),t[63]=j,t[64]=U,t[65]=ee):ee=t[65];let W;t[66]!==C||t[67]!==k||t[68]!==ee?(W=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[C,k,ee]}),t[66]=C,t[67]=k,t[68]=ee,t[69]=W):W=t[69];let G;t[70]===n.pinned?G=t[71]:(G=n.pinned&&(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-xs font-medium text-accent`,children:(0,Q.jsx)(oe,{className:`size-3`})}),t[70]=n.pinned,t[71]=G);let te;t[72]===n.tags?te=t[73]:(te=n.tags?.slice(0,2).map(zn),t[72]=n.tags,t[73]=te);let ne;t[74]===g?ne=t[75]:(ne=(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:g}),t[74]=g,t[75]=ne);let re;t[76]!==G||t[77]!==te||t[78]!==ne?(re=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[G,te,ne]}),t[76]=G,t[77]=te,t[78]=ne,t[79]=re):re=t[79];let K;return t[80]!==W||t[81]!==re||t[82]!==_||t[83]!==v||t[84]!==b||t[85]!==x||t[86]!==S?(K=(0,Q.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:_,onKeyDown:v,className:b,"aria-current":x,children:[S,W,re]}),t[80]=W,t[81]=re,t[82]=_,t[83]=v,t[84]=b,t[85]=x,t[86]=S,t[87]=K):K=t[87],K}function zn(e){return(0,Q.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e)}function Bn(){}function Vn(){}function Hn(){}function Un(e){return e.stopPropagation()}function Wn(e){return e.stopPropagation()}function Gn(){return Date.now()}var Kn=3e4;function qn(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function Jn({placeholder:e,submitLabel:t,actionsLabel:n,imageLabel:r,voiceLabel:i,stopRecordingLabel:a,onCapture:o,onImagePick:s,onVoiceCapture:c,onVoiceError:l,recordingLabel:u,imageDisabled:d=!1,voiceDisabled:f=!1,onDiscussionCapture:p,discussionCaptureLabel:m}){let[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(0),[w,E]=(0,Z.useState)(!1),D=(0,Z.useRef)(null),O=(0,Z.useRef)(null),k=(0,Z.useRef)(null),A=(0,Z.useRef)([]),j=(0,Z.useRef)(0),M=(0,Z.useRef)(null),N=(0,Z.useRef)(null),P=(0,Z.useCallback)(()=>{M.current&&=(clearInterval(M.current),null),N.current&&=(clearTimeout(N.current),null),k.current?.getTracks().forEach(e=>e.stop()),k.current=null,O.current=null,A.current=[],b(!1),C(0)},[]);(0,Z.useEffect)(()=>()=>P(),[P]);let F=(0,Z.useCallback)(async()=>{let e=O.current;if(!e||e.state!==`recording`)return;E(!0),await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()});let t=Math.max(1,Math.round((Date.now()-j.current)/1e3)),n=e.mimeType||qn()||`audio/webm`,r=new Blob(A.current,{type:n});if(P(),r.size>0&&c){let e=n.includes(`mp4`)?`m4a`:n.includes(`ogg`)?`ogg`:`webm`,i=new File([r],`voice-${Date.now()}.${e}`,{type:n});try{await c(i,t)}finally{E(!1)}return}E(!1)},[P,c]),I=(0,Z.useCallback)(async()=>{if(!(!c||w||y)){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){l?.();return}try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});k.current=e;let t=qn(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);O.current=n,A.current=[],j.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&A.current.push(e.data)},n.start(),b(!0),C(0),M.current=setInterval(()=>{C(Math.round((Date.now()-j.current)/1e3))},250),N.current=setTimeout(()=>{F()},Kn)}catch{P(),l?.()}}},[P,c,l,y,F,w]),L=(0,Z.useCallback)(async()=>{let e=h.trim();if(!(!e||_)){v(!0),g(``);try{await o(e)}catch{g(e)}finally{v(!1),D.current?.focus()}}},[h,_,o]),R=(0,Z.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),L())},[L]),z=_||w,B=!!(s||c||p);return(0,Q.jsxs)(`div`,{className:T(`flex items-center gap-1.5 rounded-2xl border border-edge bg-surface-panel p-2 shadow-float dark:shadow-elevated`,`focus-within:border-accent focus-within:ring-1 focus-within:ring-accent`,y&&`border-danger ring-1 ring-danger/40`),"aria-busy":z,children:[y?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void F(),disabled:w,className:`shrink-0 rounded-lg bg-danger-soft p-2 text-danger transition-colors hover:bg-danger-soft disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":a,title:a,"aria-pressed":`true`,children:(0,Q.jsx)(be,{className:`size-4 fill-current`,"aria-hidden":!0})}):B?(0,Q.jsxs)(he,{children:[(0,Q.jsx)(Ut,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,disabled:z,className:`shrink-0 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":n,title:n,children:(0,Q.jsx)(x,{className:`size-4`,"aria-hidden":!0})})}),(0,Q.jsx)(Ye,{children:(0,Q.jsxs)(_e,{side:`top`,align:`start`,sideOffset:8,className:`z-50 min-w-44 rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,children:[s?(0,Q.jsxs)(Ue,{disabled:d,onSelect:s,className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,Q.jsx)(tn,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),r]}):null,c?(0,Q.jsxs)(Ue,{disabled:f,onSelect:()=>void I(),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,Q.jsx)(we,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,p?(0,Q.jsxs)(Ue,{onSelect:p,className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,Q.jsx)(ln,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),m]}):null]})})]}):null,y?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:u.replace(`{{seconds}}`,String(S))}):(0,Q.jsx)(`textarea`,{ref:D,value:h,onChange:e=>g(e.target.value),onKeyDown:R,placeholder:e,"aria-label":e,rows:1,disabled:z,className:`max-h-28 min-h-8 flex-1 resize-none overflow-y-auto bg-transparent py-1.5 text-sm leading-5 text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:{fieldSizing:`content`}}),(0,Q.jsx)(`button`,{type:`button`,disabled:!h.trim()||z||y,onClick:()=>void L(),"aria-label":t,title:t,className:T(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,h.trim()&&!z&&!y?`bg-accent text-on-accent hover:bg-accent-hover`:`text-fg-disabled`),children:(0,Q.jsx)(gt,{className:`size-4`,"aria-hidden":!0})})]})}var Yn={statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1},Xn=240,Zn=320,Qn=520,$n=560;function er(e){if(globalThis.localStorage===void 0)return Zn;try{let t=globalThis.localStorage.getItem(e);if(!t)return Zn;let n=Number(t);return Number.isFinite(n)?n:Zn}catch{return Zn}}function tr(e,t){if(globalThis.localStorage!==void 0)try{globalThis.localStorage.setItem(e,String(Math.round(t)))}catch{}}var nr={thought:me,todo:et,voice:we,media:tn,bookmark:Nt,mixed:me,task:et};function rr(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function ir(e,t){return e.statusFilter===t.patch.statusFilter&&e.kindFilter===t.patch.kindFilter&&e.pinnedOnly===t.patch.pinnedOnly}function ar(e,t){return`${e.replace(/\/$/,``)}/${encodeURIComponent(t)}`}function or({selectedNoteId:e,basePath:t,managePageHeader:n=!1,showLibrary:r=!0,allowMediaCapture:a=!0,projectId:o,listTitle:s,listDescription:c,emptyText:d,emptyDescription:f,listWidthStorageKey:p=`xopc.notes.listWidth`}){let m=k(e=>e.language),h=w(m).notes,g=!!D(e=>e.conversationId),[_,v]=(0,Z.useReducer)(Te,Yn),[y,b]=(0,Z.useState)(!1),[E,A]=(0,Z.useState)(``),[R,z]=(0,Z.useState)(0),[B,H]=(0,Z.useState)(()=>er(p)),[U,ee]=(0,Z.useState)(!1),[W,G]=(0,Z.useState)(!1),[te,ne]=(0,Z.useState)(!1),[re,K]=(0,Z.useState)(null),[q,ie]=(0,Z.useState)(null),J=(0,Z.useRef)(null),ae=(0,Z.useRef)(null),[oe]=(0,Z.useState)(()=>Date.now()),se=i(),ce=(0,Z.useCallback)(e=>{let t=J.current?.clientWidth??window.innerWidth,n=Math.max(Xn,t-$n);return Math.max(Xn,Math.min(Math.min(Qn,n),e))},[]),le=(0,Z.useCallback)(e=>{let t=ce(e);H(t),tr(p,t)},[ce,p]);(0,Z.useLayoutEffect)(()=>{H(e=>ce(e))},[ce]);let{data:ue,mutate:Y,isLoading:de}=V((0,Z.useMemo)(()=>g?[`notes-list`,o,_.statusFilter,_.kindFilter,_.pinnedOnly]:null,[g,o,_.statusFilter,_.kindFilter,_.pinnedOnly]),()=>Yt({status:_.statusFilter===`all`?void 0:_.statusFilter,kind:_.kindFilter===`all`?void 0:_.kindFilter,projectId:o,pinned:_.pinnedOnly?!0:void 0,limit:100,sortBy:`createdAt`,sortOrder:`desc`}),{keepPreviousData:!0}),fe=de&&!ue,pe=ue?.items??[],he=ue?.total??0,ge=E.trim(),{data:_e,isLoading:ye}=V(g&&y&&ge?[`notes-search`,o,ge]:null,()=>Yt({search:ge,projectId:o,limit:30,sortBy:`updatedAt`,sortOrder:`desc`})),be=_e?.items??[],xe=e?pe.some(t=>t.id===e):!0;(0,Z.useEffect)(()=>{z(0)},[ge]),(0,Z.useEffect)(()=>{R>=be.length&&z(Math.max(0,be.length-1))},[R,be.length]),(0,Z.useEffect)(()=>{let e=()=>{Y().catch(e=>{K(`${h.refreshFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)})};return window.addEventListener(`note-updated`,e),()=>window.removeEventListener(`note-updated`,e)},[Y,h.quickCaptureFailedHint,h.refreshFailed]);let Se=ve(e=>e.setPageHeader),Ce=ve(e=>e.clearPageHeader),we=h.noteCount.replace(`{{count}}`,String(he)),Ee=!r&&he===0&&c?c:we,De=h.searchDialogTitle,ke=h.searchClose,Ae=h.searchClear,je=(0,Z.useMemo)(()=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),className:T(`inline-flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,lt),"aria-label":De,children:[(0,Q.jsx)(S,{className:`size-4`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:De})]}),[De]);(0,Z.useLayoutEffect)(()=>{if(n)return g?(Se({startExtra:null,main:(0,Q.jsxs)(`div`,{className:T(`flex min-w-0 items-center gap-2`,lt),children:[(0,Q.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:s??h.title}),we?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:we}):null]}),end:je}),()=>Ce()):(Ce(),()=>Ce())},[Ce,g,je,s,n,h.title,we,e,Se]);let Me=(0,Z.useMemo)(()=>({justNow:h.justNow,minutesAgo:h.minutesAgo,today:h.today,yesterday:h.yesterday,daysAgo:h.daysAgo,locale:O(m)}),[m,h.justNow,h.minutesAgo,h.today,h.yesterday,h.daysAgo]),Pe=(0,Z.useMemo)(()=>[{id:`recent`,label:h.viewRecent,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1}},{id:`inbox`,label:h.filterInbox,patch:{statusFilter:`inbox`,kindFilter:`all`,pinnedOnly:!1}},{id:`pinned`,label:h.pinned,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!0}},{id:`tasks`,label:h.viewTasks,patch:{statusFilter:`all`,kindFilter:`todo`,pinnedOnly:!1}},{id:`voice`,label:h.kindVoice,patch:{statusFilter:`all`,kindFilter:`voice`,pinnedOnly:!1}},{id:`media`,label:h.kindMedia,patch:{statusFilter:`all`,kindFilter:`media`,pinnedOnly:!1}},{id:`bookmarks`,label:h.kindBookmark,patch:{statusFilter:`all`,kindFilter:`bookmark`,pinnedOnly:!1}},{id:`processed`,label:h.filterProcessed,patch:{statusFilter:`processed`,kindFilter:`all`,pinnedOnly:!1}},{id:`archive`,label:h.filterArchived,patch:{statusFilter:`archived`,kindFilter:`all`,pinnedOnly:!1}}],[h.filterArchived,h.filterInbox,h.filterProcessed,h.kindBookmark,h.kindMedia,h.kindVoice,h.pinned,h.viewRecent,h.viewTasks]),Fe=Pe.find(e=>ir(_,e))??Pe[0],Ie=s??Fe.label,Le=(0,Z.useCallback)(async e=>{K(null);try{let n=o?await Qe({markdown:e,kind:`thought`,projectId:o,channel:`web`}):await Mt(e,`web`);await Y(),se(ar(t,n.id))}catch(e){throw K(`${h.quickCaptureFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`),e}},[t,Y,h.quickCaptureFailed,h.quickCaptureFailedHint,se,o]),Re=(0,Z.useCallback)(async()=>{if(!te){ne(!0),K(null);try{let e=await Qe({markdown:``,kind:`thought`,projectId:o,channel:`web`});v({type:`patch`,patch:Yn}),await Y(),ie(e.id),se(ar(t,e.id))}catch(e){K(`${h.createBlankFailed}: ${e instanceof Error?e.message:h.createBlankFailedHint}`)}finally{ne(!1)}}},[t,te,Y,h.createBlankFailed,h.createBlankFailedHint,se,o]),ze=(0,Z.useCallback)(()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async()=>{let t=e.files?.[0];if(t)try{K(null),await en(t,`web`),await Y()}catch(e){K(`${h.imageUploadFailed}: ${e instanceof Error?e.message:h.imageUploadFailedHint}`)}},e.click()},[Y,h.imageUploadFailed,h.imageUploadFailedHint]),Be=(0,Z.useCallback)(async(e,t)=>{try{K(null),await bt(e,t,`web`),await Y()}catch(e){K(`${h.voiceUploadFailed}: ${e instanceof Error?e.message:h.voiceUploadFailedHint}`)}},[Y,h.voiceUploadFailed,h.voiceUploadFailedHint]),Ve=(0,Z.useCallback)(()=>{K(`${h.voiceCaptureFailed}: ${h.voiceCaptureFailedHint}`)},[h.voiceCaptureFailed,h.voiceCaptureFailedHint]),He=(0,Z.useCallback)(async(e,t)=>{K(null);try{await at(e,{pinned:t}),await Y()}catch(e){K(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[Y,h.actionFailed,h.quickCaptureFailedHint]),Ue=(0,Z.useCallback)(async e=>{K(null);try{await at(e,{status:`archived`}),await Y()}catch(e){K(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[Y,h.actionFailed,h.quickCaptureFailedHint]),We=(0,Z.useCallback)(async e=>{K(null);try{await Ne(e),await Y()}catch(e){K(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[Y,h.actionFailed,h.quickCaptureFailedHint]),Ke=(0,Z.useCallback)(e=>{se(ar(t,e))},[t,se]),qe=(0,Z.useCallback)(e=>{se(ar(t,e)),b(!1)},[t,se]),Je=(0,Z.useCallback)(e=>{if(be.length){if(e.key===`ArrowDown`)e.preventDefault(),z(e=>Math.min(be.length-1,e+1));else if(e.key===`ArrowUp`)e.preventDefault(),z(e=>Math.max(0,e-1));else if(e.key===`Enter`){e.preventDefault();let t=be[R]??be[0];t&&qe(t.id)}}},[R,qe,be]),Ye=(0,Z.useCallback)(e=>{e.preventDefault();let t=e.currentTarget,n=ae.current;t.setPointerCapture(e.pointerId),ee(!0);let r=J.current?.clientWidth??window.innerWidth,i=Math.max(Xn,r-$n),a=Math.min(Qn,i),o=e=>Math.max(Xn,Math.min(a,e)),s=e.clientX,c=o(B),l=e.pointerId,u=0,d=c,f=c;n&&(n.style.transition=`none`,n.style.width=`${c}px`);let m=()=>{u=0,f=d,n&&(n.style.width=`${f}px`)},h=e=>{d=o(c+e.clientX-s),u===0&&(u=window.requestAnimationFrame(m))},g=()=>{u!==0&&(window.cancelAnimationFrame(u),m());try{t.releasePointerCapture(l)}catch{}ee(!1),J.current?.style.setProperty(`--notes-list-width`,`${f}px`),n&&(n.style.removeProperty(`transition`),n.style.removeProperty(`width`)),H(f),tr(p,f),window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),window.removeEventListener(`pointercancel`,g)};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,g),window.addEventListener(`pointercancel`,g)},[p,B]);(0,Z.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.repeat||e.key.toLowerCase()!==`n`||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||(e.preventDefault(),Re())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Re]);let Xe=(0,Z.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),le(B-16)):e.key===`ArrowRight`?(e.preventDefault(),le(B+16)):e.key===`Home`?(e.preventDefault(),le(Xn)):e.key===`End`&&(e.preventDefault(),le(Qn))},[le,B]);return g?(0,Q.jsxs)(`div`,{ref:J,className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-base`,style:{"--notes-list-width":`${B}px`},children:[(0,Q.jsxs)(`section`,{ref:ae,className:T(`relative flex min-h-0 w-full shrink-0 flex-col overflow-hidden bg-surface-rail`,!U&&`lg:transition-[width] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,W?`lg:w-0 lg:min-w-0 lg:max-w-0 lg:pointer-events-none`:`lg:w-[var(--notes-list-width)]`,e&&`hidden lg:flex`),"aria-hidden":W?!0:void 0,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle p-3`,children:[re?(0,Q.jsx)(`p`,{className:`mb-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:re}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,Q.jsx)(l,{value:Fe.id,onChange:e=>{let t=Pe.find(t=>t.id===e.target.value);t&&v({type:`patch`,patch:t.patch})},className:`-ml-1 h-7 w-full max-w-44 rounded-lg border border-transparent bg-transparent px-2 text-sm font-semibold text-fg transition-colors hover:border-edge hover:bg-surface-base focus:border-accent focus:bg-surface-base focus:outline-none focus:ring-1 focus:ring-accent`,"aria-label":h.libraryTitle,children:Pe.map(e=>(0,Q.jsx)(u,{value:e.id,children:e.label},e.id))}):(0,Q.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:Ie}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:Ee})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>G(!0),className:`hidden size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":h.collapseNotesList,title:h.collapseNotesList,children:(0,Q.jsx)(Oe,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,onClick:Re,disabled:te,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":h.createBlankNote,title:h.createBlankShortcut,children:(0,Q.jsx)(x,{className:`size-4`,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>b(!0),className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":h.searchDialogTitle,title:h.searchDialogTitle,children:(0,Q.jsx)(S,{className:`size-4`,"aria-hidden":!0})})]})]})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 py-3 [scrollbar-gutter:stable]`,children:fe?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3,4].map(e=>(0,Q.jsx)(`div`,{className:`h-20 animate-pulse rounded-lg bg-surface-hover`},e))}):pe.length===0?(0,Q.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-2 px-6 py-10 text-center`,children:[(0,Q.jsx)(`span`,{className:`mb-1 inline-flex size-12 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-fg-muted`,children:(0,Q.jsx)(me,{className:`size-6`,"aria-hidden":!0})}),(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:e&&!xe?h.noteOutsideCurrentView:d??h.noNotes}),e&&!xe?null:(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:f??h.noNotesDescription})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e&&!xe?(0,Q.jsx)(`div`,{className:`mb-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-xs leading-5 text-fg-muted`,children:h.noteOutsideCurrentView}):null,pe.map((t,n)=>{let r=n>0?Cn(pe[n-1].createdAt):null;return(0,Q.jsxs)(`div`,{children:[Cn(t.createdAt)!==r&&(0,Q.jsx)(`div`,{className:T(`px-3 pb-1.5 pt-2 text-xs font-medium text-fg-muted`,n===0&&`pt-0`),children:wn(t.createdAt,oe,Me)}),(0,Q.jsx)(Rn,{note:t,selected:t.id===e,onPress:Ke,onPin:He,onArchive:Ue,onDelete:We,timeLabels:Me,labels:{pin:h.pin,unpin:h.unpin,archive:h.archive,delete:h.delete,actions:h.noteActions,imageNote:h.imageNote,noText:h.noText}})]},t.id)})]})}),(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,Q.jsx)(Jn,{placeholder:h.quickCapturePlaceholder,submitLabel:h.quickCaptureSubmit,actionsLabel:h.quickCaptureActions,imageLabel:h.quickCaptureImage,voiceLabel:h.quickCaptureVoice,stopRecordingLabel:h.stopRecording,onCapture:Le,onImagePick:a?ze:void 0,onVoiceCapture:a?Be:void 0,onVoiceError:Ve,recordingLabel:h.recording,discussionCaptureLabel:h.discussionCapture.title,onDiscussionCapture:()=>Ge(o)})})]}),(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":h.resizeNotesList,"aria-valuemin":Xn,"aria-valuemax":Qn,"aria-valuenow":Math.round(B),tabIndex:0,onPointerDown:Ye,onDoubleClick:()=>le(Zn),onKeyDown:Xe,title:h.resizeNotesList,className:T(`group relative z-10 hidden shrink-0 cursor-col-resize touch-none select-none items-center justify-center bg-transparent hover:bg-surface-hover/60 lg:flex`,`lg:transition-[width,opacity] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,W?`lg:w-0 lg:opacity-0 lg:pointer-events-none`:`lg:w-2 lg:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-0`),children:(0,Q.jsx)(`span`,{"aria-hidden":!0,className:T(`h-full w-px bg-transparent transition-[background-color,transform] duration-150`,`group-hover:bg-accent/70 group-focus-visible:bg-accent`,U&&`bg-accent scale-x-[2]`)})}),(0,Q.jsxs)(`section`,{className:T(`relative min-w-0 flex-1 bg-surface-base`,!e&&`hidden lg:flex`),children:[W?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>G(!1),className:`absolute left-3 top-3 z-10 hidden size-8 items-center justify-center rounded-lg border border-edge bg-surface-base text-fg-muted shadow-surface transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":h.expandNotesList,title:h.expandNotesList,children:(0,Q.jsx)(Oe,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,e?(0,Q.jsx)(Tn,{noteId:e,onBack:()=>se(t),onSaved:()=>{Y().catch(e=>{K(`${h.refreshFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)})},backButtonClassName:`lg:hidden`,clearHeaderOnCleanup:!1,onOpenSearch:()=>b(!0),autoFocus:e===q,onAutoFocusConsumed:()=>ie(null)}):(0,Q.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 items-center justify-center px-8 text-center`,children:(0,Q.jsxs)(`div`,{className:`max-w-sm`,children:[(0,Q.jsx)(me,{className:`mx-auto size-9 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-fg`,children:h.emptyEditorTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:h.emptyEditorDescription}),(0,Q.jsxs)(`button`,{type:`button`,onClick:Re,disabled:te,className:`mt-5 inline-flex items-center gap-2 rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,Q.jsx)(x,{className:`size-4`,"aria-hidden":!0}),te?h.creatingBlankNote:h.createBlankNote]})]})})]}),(0,Q.jsx)(L,{open:y,onOpenChange:b,children:(0,Q.jsxs)(P,{children:[(0,Q.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(F,{className:`xopc-dialog-content fixed left-1/2 top-24 z-[90] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Q.jsx)(I,{className:`text-sm font-semibold text-fg`,children:De}),(0,Q.jsx)(M,{className:`sr-only`,children:h.searchPlaceholder}),(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":ke,children:(0,Q.jsx)(C,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Q.jsxs)(`div`,{className:`p-4`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(S,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:E,onChange:e=>A(e.target.value),onKeyDown:Je,placeholder:h.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-10 text-sm text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`}),E?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(``),className:`absolute right-2 top-1/2 inline-flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":Ae,children:(0,Q.jsx)(C,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,Q.jsx)(`div`,{className:`mt-4 max-h-[min(28rem,calc(100vh-14rem))] overflow-y-auto [scrollbar-gutter:stable]`,children:ge?ye&&!_e?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-surface-hover`},e))}):be.length===0?(0,Q.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Q.jsx)(me,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:h.searchNoResults}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:h.searchNoResultsDescription})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`p`,{className:`px-2 pb-1 text-xs text-fg-muted`,children:h.searchResultsCount.replace(`{{count}}`,String(_e?.total??be.length))}),be.map((e,t)=>{let n=nr[e.kind]||me,r=rr(e,{imageNote:h.imageNote,noText:h.noText});return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>qe(e.id),onMouseEnter:()=>z(t),className:T(`flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors`,t===R?`bg-surface-active`:`hover:bg-surface-hover`),children:[(0,Q.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title||r}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Sn(e.updatedAt,oe,Me)})]}),e.title?(0,Q.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:r}):null,e.tags?.length?(0,Q.jsx)(`span`,{className:`mt-1 flex min-w-0 flex-wrap gap-1`,children:e.tags.slice(0,3).map(e=>(0,Q.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e))}):null]})]},e.id)})]}):(0,Q.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Q.jsx)(S,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:h.searchEmptyTitle}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:h.searchEmptyDescription})]})})]})]})]})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,Q.jsx)(me,{className:`size-10 text-fg-muted`}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.needToken})]})}function sr(e){return E(A(`/api/projects/${encodeURIComponent(e)}/skills`))}function cr(e,t){return E(A(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`))}function lr(e,t){return E(A(`/api/projects/${encodeURIComponent(e)}/workspace-trust`),{method:`PATCH`,body:JSON.stringify({trusted:t})})}function ur(e,t){let n=new FormData;return n.set(`file`,t),E(A(`/api/projects/${encodeURIComponent(e)}/skills/upload`),{method:`POST`,body:n})}function dr(e,t,n={}){return E(A(`/api/projects/${encodeURIComponent(e)}/skills/marketplace/install`),{method:`POST`,body:JSON.stringify({name:t,...n})})}function fr(e,t){return E(A(`/api/projects/${encodeURIComponent(e)}/skills/source/install`),{method:`POST`,body:JSON.stringify({source:t})})}function pr(e,t){return E(A(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),{method:`DELETE`})}function mr({projectId:e,copy:t}){let n=k(e=>e.language),[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)([]),[l,u]=(0,Z.useState)([]),[f,p]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!0),[w,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(null),[A,M]=(0,Z.useState)(``),[R,z]=(0,Z.useState)(null),[B,V]=(0,Z.useState)(null),[W,K]=(0,Z.useState)(``),[q,ie]=(0,Z.useState)(1),[J,ae]=(0,Z.useState)(null),[oe,se]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(``),[ue,Y]=(0,Z.useState)(``),de=(0,Z.useRef)(null),fe=(0,Z.useCallback)(async()=>{b(!0),M(``);try{let t=await sr(e);i(t.items),o(t.inheritedItems),c(t.sources)}catch(e){M(e instanceof Error?e.message:String(e))}finally{b(!1)}},[e]);(0,Z.useEffect)(()=>{fe()},[fe]),(0,Z.useEffect)(()=>{let t=!1;return St(e).then(e=>{t||u(e)}).catch(()=>{t||u([])}),()=>{t=!0}},[e]),(0,Z.useEffect)(()=>{if(!f){g(null);return}let e=l.find(e=>e.key===f),t=!1;return g(null),M(``),v(!0),re(e?.agentId??e?.routing?.agentId,f,!0).then(e=>{t||g(e)}).catch(e=>{t||M(e instanceof Error?e.message:String(e))}).finally(()=>{t||v(!1)}),()=>{t=!0}},[f,l]),(0,Z.useEffect)(()=>{if(R!==`marketplace`)return;let e=new AbortController,t=window.setTimeout(()=>{se(!0),le(``),yn({q:W,page:q,pageSize:8,sort:`downloads`,signal:e.signal}).then(ae).catch(t=>{e.signal.aborted||le(t instanceof Error?t.message:String(t))}).finally(()=>{e.signal.aborted||se(!1)})},250);return()=>{window.clearTimeout(t),e.abort()}},[R,q,W]);async function pe(e,t){E(!0),O(t??null),M(``);try{await e(),z(null),Y(``),await fe()}catch(e){M(e instanceof Error?e.message:String(e))}finally{E(!1),O(null)}}async function me(t){M(``);try{V((await cr(e,t)).skill)}catch(e){M(e instanceof Error?e.message:String(e))}}async function he(n){if(n.removable&&window.confirm(t.removeConfirm.replace(`{{name}}`,n.name))){E(!0);try{await pr(e,n.directoryId),await fe()}catch(e){M(e instanceof Error?e.message:String(e))}finally{E(!1)}}}async function ge(){E(!0),M(``);try{await lr(e,!0),await fe()}catch(e){M(e instanceof Error?e.message:String(e))}finally{E(!1)}}let _e=s.find(e=>e.origin===`agents-workspace`),ve=new Map(h?.skills.map(e=>[e.name,e]));return(0,Q.jsxs)(`section`,{id:`project-panel-skills`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-skills`,className:`grid content-start gap-4`,children:[(0,Q.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.description})]}),(0,Q.jsxs)(U,{children:[(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(H,{type:`button`,children:[(0,Q.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t.add,(0,Q.jsx)(Rt,{className:`size-3.5`,"aria-hidden":!0})]})}),(0,Q.jsx)(ee,{children:(0,Q.jsxs)(te,{align:`end`,sideOffset:8,className:`z-50 w-72 rounded-lg border border-edge bg-surface-panel p-1.5 shadow-xl`,children:[(0,Q.jsx)(vr,{icon:qe,title:t.marketplace,hint:t.marketplaceHint,onClick:()=>z(`marketplace`)}),(0,Q.jsx)(vr,{icon:mt,title:t.source,hint:t.sourceHint,onClick:()=>z(`source`)}),(0,Q.jsx)(vr,{icon:Ae,title:t.upload,hint:t.uploadHint,onClick:()=>de.current?.click()})]})})]}),(0,Q.jsx)(`input`,{ref:de,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:t=>{let n=t.target.files?.[0];n&&pe(()=>ur(e,n)),t.target.value=``}})]})}),A?(0,Q.jsx)(`p`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:A}):null,_e?.state===`untrusted`?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Je,{className:`mt-0.5 size-4 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.trustTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustHint})]})]}),(0,Q.jsxs)(H,{type:`button`,variant:`secondary`,disabled:w,onClick:()=>void ge(),children:[(0,Q.jsx)(Gt,{className:`size-4`,"aria-hidden":!0}),w?t.trusting:t.trustAction]})]}):null,l.length?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.sessionViewLabel}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:_?t.sessionLoading:f?h?.agentId:t.sessionViewAll})]}),(0,Q.jsx)(d,{value:f,options:l.map(e=>({value:e.key,label:e.name?.trim()||`${t.sessionFallback} · ${e.key.slice(-12)}`})),placeholder:t.sessionViewAll,emptyLabel:t.sessionViewAll,triggerClassName:`w-[min(24rem,calc(100vw-3rem))]`,onChange:p})]}):null,y?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[0,1,2].map(e=>(0,Q.jsx)(ne,{className:`h-36 rounded-lg`},e))}):r.length?(0,Q.jsx)(hr,{title:t.localTitle,items:r,copy:t,busy:w,availabilityByName:ve,onPreview:me,onRemove:he}):(0,Q.jsxs)(`div`,{className:`rounded-lg border border-dashed border-edge bg-surface-panel px-6 py-12 text-center`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.empty}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.emptyHint})]}),!y&&a.length?(0,Q.jsx)(hr,{title:t.inheritedTitle,hint:t.inheritedHint,items:a,copy:t,busy:w,availabilityByName:ve,onPreview:me,onRemove:he}):null,(0,Q.jsx)(L,{open:R!==null,onOpenChange:e=>{e||z(null)},children:(0,Q.jsxs)(P,{children:[(0,Q.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(F,{className:T(`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-xl`,R===`marketplace`?`h-[min(46rem,calc(100vh-2rem))] w-[min(58rem,calc(100vw-2rem))]`:`h-[min(22rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))]`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(I,{className:`text-base font-semibold text-fg`,children:R===`marketplace`?t.marketplace:t.source}),(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,Q.jsx)(C,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:R===`marketplace`?(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.marketplace}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.marketplaceHint}),(0,Q.jsxs)(`div`,{className:`relative mt-3`,children:[(0,Q.jsx)(S,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{className:`h-10 w-full rounded-md border border-edge bg-surface-base pl-9 pr-3 text-sm outline-none focus:border-accent`,value:W,onChange:e=>{K(e.target.value),ie(1)},placeholder:t.marketplacePlaceholder,autoFocus:!0})]}),ce?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-300`,children:ce}):null,oe&&!J?(0,Q.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,Q.jsx)(ne,{className:`h-32 rounded-lg`},e))}):J?.items.length?(0,Q.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:J.items.map(i=>{let a=He(i,n),o=i.providerId??J.provider,s=vn(i,o),c=r.some(e=>e.origin===`xopc-workspace`&&(e.directoryId===i.id||e.directoryId===s||e.name===i.name)),l=D===s;return(0,Q.jsxs)(`article`,{className:`group flex min-h-32 gap-3 rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsx)(_n,{name:i.name,className:`size-10`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`h4`,{className:`truncate text-sm font-semibold text-fg`,children:a.displayName}),(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:a.description||`—`}),(0,Q.jsxs)(`div`,{className:`mt-auto flex items-end justify-between gap-2 pt-2`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-fg-subtle`,children:[(0,Q.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t.marketplaceDownloads,` `,i.downloads]}),(0,Q.jsx)(H,{type:`button`,className:`h-8 px-2.5 text-xs`,variant:c?`secondary`:`primary`,disabled:w||c,onClick:()=>void pe(()=>dr(e,s,{provider:o}),s),children:c?t.marketplaceInstalled:l?t.installing:t.install})]})]})]},`${o??`default`}:${i.id}`)})}):oe?null:(0,Q.jsx)(`p`,{className:`mt-6 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}),J&&J.meta.totalPages>1?(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t.marketplacePage.replace(`{{page}}`,String(J.meta.page)).replace(`{{total}}`,String(J.meta.totalPages))}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:oe||q<=1,onClick:()=>ie(e=>Math.max(1,e-1)),children:[(0,Q.jsx)(st,{className:`size-4`}),t.marketplacePrevious]}),(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:oe||q>=J.meta.totalPages,onClick:()=>ie(e=>e+1),children:[t.marketplaceNext,(0,Q.jsx)(kt,{className:`size-4`})]})]})]}):null]}):(0,Q.jsxs)(`section`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:t.sourceHint}),(0,Q.jsx)(`input`,{className:`mt-4 h-10 w-full rounded-md border border-edge bg-surface-base px-3 text-sm outline-none focus:border-accent`,value:ue,onChange:e=>Y(e.target.value),placeholder:t.sourcePlaceholder,autoFocus:!0}),(0,Q.jsxs)(`div`,{className:`mt-auto flex justify-end gap-2 border-t border-edge pt-4`,children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(H,{type:`button`,variant:`secondary`,children:t.close})}),(0,Q.jsx)(H,{type:`button`,disabled:w||!ue.trim(),onClick:()=>void pe(()=>fr(e,ue.trim())),children:w?t.installing:t.install})]})]})})]})]})}),(0,Q.jsx)(L,{open:!!B,onOpenChange:e=>{e||V(null)},children:(0,Q.jsxs)(P,{children:[(0,Q.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(F,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex h-[min(42rem,calc(100vh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-xl`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(I,{className:`text-base font-semibold text-fg`,children:B?.name}),(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,Q.jsx)(C,{className:`size-4`})})})]}),(0,Q.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-5 text-sm leading-6 text-fg-muted`,children:B?.bodyMarkdown})]})]})})]})}function hr(e){let t=(0,Mn.c)(25),{title:n,hint:r,items:i,copy:a,busy:o,availabilityByName:s,onPreview:c,onRemove:l}=e,u;t[0]===n?u=t[1]:(u=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[0]=n,t[1]=u);let d;t[2]===r?d=t[3]:(d=r?(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r}):null,t[2]=r,t[3]=d);let f;t[4]!==u||t[5]!==d?(f=(0,Q.jsxs)(`div`,{children:[u,d]}),t[4]=u,t[5]=d,t[6]=f):f=t[6];let p;if(t[7]!==s||t[8]!==o||t[9]!==a||t[10]!==i||t[11]!==c||t[12]!==l){let e;t[14]!==s||t[15]!==o||t[16]!==a||t[17]!==c||t[18]!==l?(e=e=>{let t=e.effective?s.get(e.name):void 0;return(0,Q.jsxs)(`article`,{className:T(`flex min-h-36 flex-col rounded-lg border border-edge bg-surface-panel p-4`,!e.effective&&`opacity-70`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Be,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,Q.jsx)(`h4`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:e.name})]}),(0,Q.jsx)(`p`,{className:`mt-2 line-clamp-2 flex-1 text-sm leading-5 text-fg-muted`,children:e.description||e.directoryId}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:gr(a,e.origin)}),e.writable?null:(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:a.sourceReadOnly}),e.effective?null:(0,Q.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-2 py-0.5 text-amber-800 dark:text-amber-200`,children:a.shadowed}),t?(0,Q.jsx)(`span`,{className:T(`rounded-md px-2 py-0.5`,t.availableForCurrentAgent?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:_r(a,t)}):null]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>void c(e.key),children:[(0,Q.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),a.view]}),e.removable?(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-red-600`,disabled:o,onClick:()=>void l(e),children:[(0,Q.jsx)(Pe,{className:`size-3.5`,"aria-hidden":!0}),a.remove]}):null]})]},e.key)},t[14]=s,t[15]=o,t[16]=a,t[17]=c,t[18]=l,t[19]=e):e=t[19],p=i.map(e),t[7]=s,t[8]=o,t[9]=a,t[10]=i,t[11]=c,t[12]=l,t[13]=p}else p=t[13];let m;t[20]===p?m=t[21]:(m=(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:p}),t[20]=p,t[21]=m);let g;return t[22]!==f||t[23]!==m?(g=(0,Q.jsxs)(`section`,{className:`grid gap-3`,children:[f,m]}),t[22]=f,t[23]=m,t[24]=g):g=t[24],g}function gr(e,t){switch(t){case`xopc-workspace`:return e.xopcSource;case`agents-workspace`:return e.agentsSource;case`xopc-global`:case`custom-global`:return e.globalXopcSource;case`agents-global`:return e.globalAgentsSource;case`bundled`:return e.bundledSource;case`extra`:return e.extraSource}}function _r(e,t){if(t.availableForCurrentAgent)return e.sessionAvailable;switch(t.unavailableReason){case`agent-denied`:return e.sessionUnavailableAgent;case`disabled`:return e.sessionUnavailableDisabled;case`requirements-unmet`:return e.sessionUnavailableRequirements;case`model-invocation-disabled`:return e.sessionUnavailableModel;case`tool-gated`:return e.sessionUnavailableTools;default:return e.sessionUnavailableAgent}}function vr(e){let t=(0,Mn.c)(13),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,Q.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==a||t[10]!==o||t[11]!==l?(u=(0,Q.jsx)(W,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 rounded-md px-3 py-2.5 text-left hover:bg-surface-hover`,onClick:a,children:[o,l]})}),t[9]=a,t[10]=o,t[11]=l,t[12]=u):u=t[12],u}function yr(e){return{name:e.name,description:e.description??``,status:e.status,defaultAgentId:e.defaultAgentId??``,executionMode:e.executionMode,workspaceRoot:e.workspaceRoot??``,brief:e.brief??``,instructions:e.instructions??``}}function br(e,t,n){let r=yr(t),i=yr(n),a=Object.keys(r).filter(t=>e[t]===r[t]);return{...e,...Object.fromEntries(a.map(e=>[e,i[e]]))}}var xr={active:0,review:1,ready:2,backlog:3,closed:4},Sr={blocked:0,waiting:1,verifying:2,running:3,queued:4,idle:5},Cr={critical:0,high:1,normal:2,low:3};function wr(e,t=4){return e.filter(e=>e.phase!==`closed`&&!(e.operationalState===`waiting`&&e.attention.length===0)).sort((e,t)=>{let n=Number(t.attention.length>0)-Number(e.attention.length>0);if(n!==0)return n;let r=Sr[e.operationalState]-Sr[t.operationalState];if(r!==0)return r;let i=xr[e.phase]-xr[t.phase];if(i!==0)return i;let a=Cr[e.priority]-Cr[t.priority];return a===0?t.updatedAt-e.updatedAt:a}).slice(0,t)}var Tr=[`backlog`,`ready`,`active`,`review`,`closed`];function Er(e){return{backlog:e.filter(e=>e.phase===`backlog`),ready:e.filter(e=>e.phase===`ready`),active:e.filter(e=>e.phase===`active`),review:e.filter(e=>e.phase===`review`),closed:e.filter(e=>e.phase===`closed`)}}function Dr(e,t){if(e.phase!==t){if(e.phase===`closed`&&t!==`closed`&&e.allowedCommands.includes(`reopen`))return`reopen_${t}`;if(t===`closed`&&e.phase===`review`&&e.allowedCommands.includes(`close`))return`complete`;if(t!==`closed`&&e.allowedCommands.includes(`move`))return`move_${t}`}}function Or(e){if(e.allowedCommands.includes(`resolve_wait`))return`resume`;if(e.allowedCommands.includes(`mark_ready`))return`ready`;if(e.allowedCommands.includes(`start`))return`run`;if(e.allowedCommands.includes(`request_review`))return`review`;if(e.phase===`review`&&e.allowedCommands.includes(`close`))return`complete`;if(e.allowedCommands.includes(`reopen`))return`reopen`;if(e.allowedCommands.includes(`add_wait`))return`pause`}function kr(e){let t=new Map,n=new Map;for(let r of e)t.set(r.dependencyTaskId,[...t.get(r.dependencyTaskId)??[],r.dependentTaskId]),n.set(r.dependentTaskId,[...n.get(r.dependentTaskId)??[],r.dependencyTaskId]);return{outgoing:t,incoming:n}}function Ar(e,t){let n=new Set(e.map(e=>e.id)),{outgoing:r,incoming:i}=kr(t.filter(e=>n.has(e.dependencyTaskId)&&n.has(e.dependentTaskId))),a=new Map(e.map(e=>[e.id,i.get(e.id)?.length??0])),o=new Map(e.map(e=>[e.id,0])),s=e.filter(e=>a.get(e.id)===0).sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>e.id);for(let e=0;e<s.length;e+=1){let t=s[e];for(let e of r.get(t)??[]){o.set(e,Math.max(o.get(e)??0,(o.get(t)??0)+1));let n=(a.get(e)??1)-1;a.set(e,n),n===0&&s.push(e)}}let c=new Map;for(let t of e){let e=o.get(t.id)??0;c.set(e,[...c.get(e)??[],t.id])}let l=new Map;for(let[e,t]of c)t.forEach((t,n)=>l.set(t,{x:e*300,y:n*136}));return l}function jr(e,t){let{incoming:n}=kr(t),r=new Set(e.filter(e=>e.operationalState===`blocked`).map(e=>e.id)),i=[...r];for(let e=0;e<i.length;e+=1)for(let t of n.get(i[e])??[])r.has(t)||(r.add(t),i.push(t));return r}function Mr(e,t){let{incoming:n,outgoing:r}=kr(t),i=new Set([e]);for(let t of[n,r]){let n=[e],r=new Set(n);for(let e=0;e<n.length;e+=1)for(let a of t.get(n[e])??[])r.has(a)||(r.add(a),i.add(a),n.push(a))}return i}var Nr={backlog:`border-edge`,ready:`border-edge`,active:`border-accent ring-2 ring-accent/15`,review:`border-amber-400/80`,closed:`border-emerald-400/60`};function Pr(e){let t=(0,Mn.c)(25),{data:n,selected:r}=e,i=n.task,a=i.operationalState===`waiting`||i.operationalState===`blocked`,o=Nr[i.phase],s=r&&`ring-2 ring-accent/30`,c=n.dimmed&&`opacity-30`,l;t[0]!==o||t[1]!==s||t[2]!==c?(l=T(`group w-56 rounded-xl border bg-surface-panel p-3 shadow-surface transition-opacity`,o,s,c),t[0]=o,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(jn,{type:`target`,position:On.Left,className:`!size-3 !border-2 !border-surface-panel !bg-accent opacity-60 transition-opacity group-hover:opacity-100`}),t[4]=u):u=t[4];let d;t[5]===i.title?d=t[6]:(d=(0,Q.jsx)(`strong`,{className:`line-clamp-2 min-w-0 text-sm font-medium leading-5 text-fg`,children:i.title}),t[5]=i.title,t[6]=d);let f;t[7]===a?f=t[8]:(f=a?(0,Q.jsx)(Ht,{className:`mt-0.5 size-3.5 shrink-0 text-violet-600 dark:text-violet-300`,"aria-hidden":!0}):null,t[7]=a,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===n.phaseLabel?m=t[13]:(m=(0,Q.jsx)(`span`,{children:n.phaseLabel}),t[12]=n.phaseLabel,t[13]=m);let h;t[14]!==a||t[15]!==i.blockedBy?(h=a&&i.blockedBy.length>0?(0,Q.jsx)(`span`,{children:i.blockedBy.length}):null,t[14]=a,t[15]=i.blockedBy,t[16]=h):h=t[16];let g;t[17]!==h||t[18]!==m?(g=(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 text-[11px] text-fg-subtle`,children:[m,h]}),t[17]=h,t[18]=m,t[19]=g):g=t[19];let _;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(jn,{type:`source`,position:On.Right,className:`!size-3 !border-2 !border-surface-panel !bg-accent opacity-60 transition-opacity group-hover:opacity-100`}),t[20]=_):_=t[20];let v;return t[21]!==g||t[22]!==l||t[23]!==p?(v=(0,Q.jsxs)(`div`,{className:l,children:[u,p,g,_]}),t[21]=g,t[22]=l,t[23]=p,t[24]=v):v=t[24],v}var Fr={taskNode:Pr};function Ir(e){let t=(0,Mn.c)(90),{tasks:n,dependencyEdges:r,returnTo:i,copy:a,onDependenciesChange:o}=e,[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(),[m,g]=(0,Z.useState)(),_=(0,Z.useRef)(null),v;t[0]!==r||t[1]!==n?(v=jr(n,r),t[0]=r,t[1]=n,t[2]=v):v=t[2];let y=v,b;t[3]!==y||t[4]!==u||t[5]!==c||t[6]!==n?(b=u?n.filter(e=>y.has(e.id)):c?n:n.filter(Wr),t[3]=y,t[4]=u,t[5]=c,t[6]=n,t[7]=b):b=t[7];let x=b,S;t[8]===x?S=t[9]:(S=new Set(x.map(Ur)),t[8]=x,t[9]=S);let C=S,w;if(t[10]!==r||t[11]!==C){let e;t[13]===C?e=t[14]:(e=e=>C.has(e.dependencyTaskId)&&C.has(e.dependentTaskId),t[13]=C,t[14]=e),w=r.filter(e),t[10]=r,t[11]=C,t[12]=w}else w=t[12];let E=w,D;t[15]!==E||t[16]!==x?(D=Ar(x,E),t[15]=E,t[16]=x,t[17]=D):D=t[17];let O=D,k;t[18]!==f||t[19]!==E?(k=f?Mr(f,E):void 0,t[18]=f,t[19]=E,t[20]=k):k=t[20];let A=k,j;t[21]===f?j=t[22]:(j=e=>e.id===f,t[21]=f,t[22]=j);let M=x.find(j),N;t[23]===x?N=t[24]:(N=new Map(x.map(Hr)),t[23]=x,t[24]=N);let P=N,F;if(t[25]!==a.phases||t[26]!==O||t[27]!==A||t[28]!==x){let e;t[30]!==a.phases||t[31]!==O||t[32]!==A?(e=e=>({id:e.id,type:`taskNode`,position:O.get(e.id)??{x:0,y:0},data:{task:e,phaseLabel:a.phases[e.phase],dimmed:!!(A&&!A.has(e.id))}}),t[30]=a.phases,t[31]=O,t[32]=A,t[33]=e):e=t[33],F=x.map(e),t[25]=a.phases,t[26]=O,t[27]=A,t[28]=x,t[29]=F}else F=t[29];let I=F,L;if(t[34]!==A||t[35]!==P||t[36]!==E){let e;t[38]!==A||t[39]!==P?(e=e=>{let t=P.get(e.dependencyTaskId),n=t?.phase===`closed`&&t.resolution===`done`,r=!!(A&&(!A.has(e.dependencyTaskId)||!A.has(e.dependentTaskId)));return{id:`${e.dependencyTaskId}:${e.dependentTaskId}`,source:e.dependencyTaskId,target:e.dependentTaskId,markerEnd:{type:Dn.ArrowClosed},style:{stroke:n?`var(--color-edge-strong)`:`var(--color-accent)`,strokeWidth:n?1.25:1.75,opacity:r?.18:1,strokeDasharray:n?`5 5`:void 0}}},t[38]=A,t[39]=P,t[40]=e):e=t[40],L=E.map(e),t[34]=A,t[35]=P,t[36]=E,t[37]=L}else L=t[37];let R=L,z,B;t[41]!==f||t[42]!==C?(z=()=>{f&&!C.has(f)&&p(void 0)},B=[f,C],t[41]=f,t[42]=C,t[43]=z,t[44]=B):(z=t[43],B=t[44]),(0,Z.useEffect)(z,B);let V,U;t[45]!==R||t[46]!==m?(V=()=>{m&&!R.some(e=>e.id===m)&&g(void 0)},U=[R,m],t[45]=R,t[46]=m,t[47]=V,t[48]=U):(V=t[47],U=t[48]),(0,Z.useEffect)(V,U);let ee;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ee=()=>{let e=window.requestAnimationFrame(()=>{_.current?.fitView({padding:.2,minZoom:.35,maxZoom:1,duration:250})});return()=>window.cancelAnimationFrame(e)},t[49]=ee):ee=t[49];let W;t[50]!==u||t[51]!==c||t[52]!==x.length?(W=[u,c,x.length],t[50]=u,t[51]=c,t[52]=x.length,t[53]=W):W=t[53],(0,Z.useEffect)(ee,W);let G;t[54]===f?G=t[55]:(G=()=>{f&&_.current?.fitView({nodes:[{id:f}],padding:1.5,minZoom:.7,maxZoom:1,duration:250})},t[54]=f,t[55]=G);let te=G,ne;t[56]!==r||t[57]!==o?(ne=e=>{if(!e.source||!e.target||e.source===e.target)return;let t=r.filter(t=>t.dependentTaskId===e.target).map(Vr);t.includes(e.source)||o(e.target,[...t,e.source])},t[56]=r,t[57]=o,t[58]=ne):ne=t[58];let re=ne,K;t[59]!==r||t[60]!==o||t[61]!==m?(K=()=>{if(!m)return;let e=r.find(e=>`${e.dependencyTaskId}:${e.dependentTaskId}`===m);e&&(g(void 0),o(e.dependentTaskId,r.filter(t=>t.dependentTaskId===e.dependentTaskId&&t.dependencyTaskId!==e.dependencyTaskId).map(Br)))},t[59]=r,t[60]=o,t[61]=m,t[62]=K):K=t[62];let q=K,ie;t[63]===a.connectHint?ie=t[64]:(ie=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.connectHint}),t[63]=a.connectHint,t[64]=ie);let ae=u?`secondary`:`ghost`,oe;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>d(zr),t[65]=oe):oe=t[65];let se=u?a.allTasks:a.blockedChains,ce;t[66]!==u||t[67]!==ae||t[68]!==se?(ce=(0,Q.jsx)(H,{type:`button`,variant:ae,className:`h-8 rounded-lg px-2.5 text-xs`,"aria-pressed":u,onClick:oe,children:se}),t[66]=u,t[67]=ae,t[68]=se,t[69]=ce):ce=t[69];let le;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>l(Rr),t[70]=le):le=t[70];let ue=c?a.hideCompleted:a.showCompleted,Y;t[71]!==u||t[72]!==c||t[73]!==ue?(Y=(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,"aria-pressed":c,onClick:le,disabled:u,children:ue}),t[71]=u,t[72]=c,t[73]=ue,t[74]=Y):Y=t[74];let de=M?(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:te,children:[(0,Q.jsx)(pe,{className:`size-3.5`,"aria-hidden":!0}),a.locateTask]}):null,fe;t[75]!==a.removeDependency||t[76]!==q||t[77]!==m?(fe=m?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs text-danger`,onClick:q,children:a.removeDependency}):null,t[75]=a.removeDependency,t[76]=q,t[77]=m,t[78]=fe):fe=t[78];let me;t[79]!==ce||t[80]!==Y||t[81]!==de||t[82]!==fe?(me=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[ce,Y,de,fe]}),t[79]=ce,t[80]=Y,t[81]=de,t[82]=fe,t[83]=me):me=t[83];let he;t[84]!==ie||t[85]!==me?(he=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-edge bg-surface-panel px-3 py-2.5`,children:[ie,me]}),t[84]=ie,t[85]=me,t[86]=he):he=t[86];let ge=x.length>0?(0,Q.jsxs)(`div`,{className:T(`grid h-[min(42rem,calc(100vh-14rem))] min-h-[28rem]`,M&&`lg:grid-cols-[minmax(0,1fr)_18rem]`),children:[(0,Q.jsxs)(An,{nodes:I,edges:R,nodeTypes:Fr,nodesDraggable:!1,nodesConnectable:!0,elementsSelectable:!0,onNodeClick:(e,t)=>p(t.id),onEdgeClick:(e,t)=>g(t.id),onConnect:re,onPaneClick:()=>{p(void 0),g(void 0)},onInit:e=>{_.current=e},fitView:!0,minZoom:.25,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:{hideAttribution:!0},children:[(0,Q.jsx)(X,{color:`var(--color-edge)`,gap:22,size:1}),(0,Q.jsx)(kn,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`})]}),M?(0,Q.jsxs)(`aside`,{className:`overflow-y-auto border-t border-edge bg-surface-panel p-4 lg:border-l lg:border-t-0`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-accent-fg`,children:a.phases[M.phase]}),(0,Q.jsx)(`h3`,{className:`mt-2 text-sm font-semibold leading-6 text-fg`,children:M.title}),M.operationalState===`blocked`&&M.blockedBy.length>0?(0,Q.jsxs)(`div`,{className:`mt-4 rounded-lg bg-violet-500/8 p-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-violet-700 dark:text-violet-300`,children:a.blockedBy.replace(`{{count}}`,String(M.blockedBy.length))}),(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:M.blockedBy.map(Lr)})]}):null,(0,Q.jsxs)(s,{to:J(i,M.id),className:`mt-4 inline-flex items-center gap-1.5 text-xs font-medium text-accent-fg hover:underline`,children:[(0,Q.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),a.openTask]})]}):null]}):(0,Q.jsx)(`div`,{className:`flex min-h-72 items-center justify-center px-6 text-center text-sm text-fg-muted`,children:a.empty}),_e;return t[87]!==he||t[88]!==ge?(_e=(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base/40`,children:[he,ge]}),t[87]=he,t[88]=ge,t[89]=_e):_e=t[89],_e}function Lr(e){return(0,Q.jsx)(`li`,{children:e.title},e.id)}function Rr(e){return!e}function zr(e){return!e}function Br(e){return e.dependencyTaskId}function Vr(e){return e.dependencyTaskId}function Hr(e){return[e.id,e]}function Ur(e){return e.id}function Wr(e){return e.phase!==`closed`}function Gr(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}var Kr={backlog:xt,ready:xt,active:tt,review:Ee,closed:f},qr={backlog:`bg-surface-hover text-fg-muted`,ready:`bg-surface-panel text-fg-muted`,active:`bg-accent-soft text-accent-fg`,review:`bg-amber-500/10 text-amber-700 dark:text-amber-300`,closed:`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`};function Jr(e){return e===`running`||e===`queued`?`border-accent/20 bg-accent-soft text-accent-fg`:e===`verifying`?`border-emerald-500/20 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`waiting`?`border-amber-500/20 bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`blocked`?`border-violet-500/20 bg-violet-500/10 text-violet-700 dark:text-violet-300`:`border-edge-subtle bg-surface-hover text-fg-muted`}function Yr(e){return e===`passed`?`border-emerald-500/20 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`?`border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge-subtle bg-surface-hover text-fg-muted`}function Xr(e){let t=(0,Mn.c)(83),{task:n,returnTo:r,copy:i,busy:a,onAction:o,onDragStart:c,onDropBefore:l}=e,u,d,p,m,h,g,_,v,y,b,x,S,C,w,E,D;t[0]!==c||t[1]!==l||t[2]!==r||t[3]!==n?(h=Or(n),g=h!==`review`&&n.allowedCommands.includes(`request_review`)?`review`:void 0,p=n.phase===`closed`,m=!!(n.dueAt&&n.dueAt<Date.now()&&!p),d=p?f:$e,v=n.priority!==`normal`,_=v||n.operationalState!==`idle`||!!n.latestVerification||n.acceptanceCriteriaCount>0||!!n.dueAt||!!n.nextCheckAt,x=!0,t[20]!==c||t[21]!==n.id?(S=e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,n.id),c(n.id)},t[20]=c,t[21]=n.id,t[22]=S):S=t[22],t[23]===c?C=t[24]:(C=()=>c(``),t[23]=c,t[24]=C),w=Qr,t[25]!==l||t[26]!==n.id?(E=e=>{e.preventDefault(),e.stopPropagation(),l(n.id)},t[25]=l,t[26]=n.id,t[27]=E):E=t[27],D=`group relative min-h-max min-w-0 shrink-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface transition-[border-color,box-shadow] hover:border-edge focus-within:border-accent/40`,u=s,t[28]!==r||t[29]!==n.id?(y=J(r,n.id),t[28]=r,t[29]=n.id,t[30]=y):y=t[30],b=T(`block min-w-0 p-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,g?`pr-19`:h&&`pr-11`),t[0]=c,t[1]=l,t[2]=r,t[3]=n,t[4]=u,t[5]=d,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_,t[11]=v,t[12]=y,t[13]=b,t[14]=x,t[15]=S,t[16]=C,t[17]=w,t[18]=E,t[19]=D):(u=t[4],d=t[5],p=t[6],m=t[7],h=t[8],g=t[9],_=t[10],v=t[11],y=t[12],b=t[13],x=t[14],S=t[15],C=t[16],w=t[17],E=t[18],D=t[19]);let O=p?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`,k;t[31]===O?k=t[32]:(k=T(`mt-0.5 size-4 shrink-0`,O),t[31]=O,t[32]=k);let A;t[33]!==d||t[34]!==k?(A=(0,Q.jsx)(d,{className:k,"aria-hidden":!0}),t[33]=d,t[34]=k,t[35]=A):A=t[35];let j=p?`text-fg-subtle`:`text-fg`,M;t[36]===j?M=t[37]:(M=T(`min-w-0 break-words text-sm font-semibold leading-5`,j),t[36]=j,t[37]=M);let N;t[38]!==M||t[39]!==n.title?(N=(0,Q.jsx)(`h3`,{className:M,children:n.title}),t[38]=M,t[39]=n.title,t[40]=N):N=t[40];let P;t[41]!==A||t[42]!==N?(P=(0,Q.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[A,N]}),t[41]=A,t[42]=N,t[43]=P):P=t[43];let F;t[44]!==i||t[45]!==n.attention||t[46]!==n.blockedBy||t[47]!==n.operationalState?(F=n.operationalState===`blocked`&&n.blockedBy.length>0?(0,Q.jsxs)(`div`,{className:`ml-6.5 mt-2.5 rounded-lg bg-violet-500/8 px-2.5 py-2 text-xs text-violet-700 dark:text-violet-300`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium`,children:[(0,Q.jsx)(Ht,{className:`size-3.5`,"aria-hidden":!0}),i.blockedBy.replace(`{{count}}`,String(n.blockedBy.length))]}),(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 leading-5 text-fg-muted`,children:n.blockedBy.map(Zr).join(`、`)})]}):n.attention[0]?(0,Q.jsxs)(`p`,{className:`ml-6.5 mt-2.5 flex items-start gap-1.5 text-xs leading-5 text-fg-muted`,children:[(0,Q.jsx)(Wt,{className:`mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`line-clamp-2`,children:n.attention[0].summary})]}):null,t[44]=i,t[45]=n.attention,t[46]=n.blockedBy,t[47]=n.operationalState,t[48]=F):F=t[48];let I;t[49]!==i||t[50]!==m||t[51]!==_||t[52]!==v||t[53]!==n.acceptanceCriteriaCount||t[54]!==n.dueAt||t[55]!==n.latestVerification||t[56]!==n.nextCheckAt||t[57]!==n.operationalState||t[58]!==n.priority?(I=_?(0,Q.jsxs)(`div`,{className:`ml-6.5 mt-2.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[v?(0,Q.jsx)(`span`,{className:T(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,n.priority===`critical`?`border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300`:n.priority===`high`?`border-amber-500/20 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-edge-subtle bg-surface-hover text-fg-muted`),children:i.priorityOptions[n.priority]}):null,n.operationalState===`idle`?null:(0,Q.jsx)(`span`,{className:T(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,Jr(n.operationalState)),children:i.operationalStates[n.operationalState]}),n.latestVerification?(0,Q.jsx)(`span`,{className:T(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,Yr(n.latestVerification)),children:i.verification[n.latestVerification]}):null,n.acceptanceCriteriaCount>0?(0,Q.jsxs)(`span`,{className:`inline-flex min-h-6 items-center gap-1 rounded-md border border-edge-subtle bg-surface-hover px-2 text-fg-muted`,children:[(0,Q.jsx)(tt,{className:`size-3`,"aria-hidden":!0}),i.acceptanceCriteria.replace(`{{count}}`,String(n.acceptanceCriteriaCount))]}):null,n.dueAt?(0,Q.jsxs)(`span`,{className:T(`inline-flex min-h-6 items-center gap-1 rounded-md border px-2`,m?`border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge-subtle bg-surface-hover text-fg-muted`),children:[(0,Q.jsx)(ht,{className:`size-3`,"aria-hidden":!0}),Tt(new Date(n.dueAt))]}):null,n.nextCheckAt?(0,Q.jsxs)(`span`,{className:`inline-flex min-h-6 items-center gap-1 rounded-md border border-accent/20 bg-accent-soft px-2 text-accent-fg`,children:[(0,Q.jsx)(ht,{className:`size-3`,"aria-hidden":!0}),Tt(new Date(n.nextCheckAt))]}):null]}):null,t[49]=i,t[50]=m,t[51]=_,t[52]=v,t[53]=n.acceptanceCriteriaCount,t[54]=n.dueAt,t[55]=n.latestVerification,t[56]=n.nextCheckAt,t[57]=n.operationalState,t[58]=n.priority,t[59]=I):I=t[59];let L;t[60]!==u||t[61]!==y||t[62]!==P||t[63]!==F||t[64]!==I||t[65]!==b?(L=(0,Q.jsxs)(u,{to:y,className:b,children:[P,F,I]}),t[60]=u,t[61]=y,t[62]=P,t[63]=F,t[64]=I,t[65]=b,t[66]=L):L=t[66];let R;t[67]!==a||t[68]!==i||t[69]!==o||t[70]!==h||t[71]!==g||t[72]!==n?(R=h?(0,Q.jsxs)(`div`,{className:`absolute right-2.5 top-2.5 z-10 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100`,children:[g?(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,g),className:`inline-flex size-7 items-center justify-center rounded-md bg-surface-hover text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait disabled:opacity-50`,"aria-label":i.actions[g],title:i.actions[g],children:(0,Q.jsx)(Ee,{className:`size-3.5`,"aria-hidden":!0})}):null,(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,h),className:`inline-flex size-7 items-center justify-center rounded-md bg-accent-soft text-accent-fg hover:bg-accent-soft/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait disabled:opacity-50`,"aria-label":i.actions[h],title:i.actions[h],children:(0,Q.jsx)(Ie,{className:`size-3.5`,"aria-hidden":!0})})]}):null,t[67]=a,t[68]=i,t[69]=o,t[70]=h,t[71]=g,t[72]=n,t[73]=R):R=t[73];let z;return t[74]!==L||t[75]!==R||t[76]!==x||t[77]!==S||t[78]!==C||t[79]!==w||t[80]!==E||t[81]!==D?(z=(0,Q.jsxs)(`article`,{draggable:x,onDragStart:S,onDragEnd:C,onDragOver:w,onDrop:E,className:D,children:[L,R]}),t[74]=L,t[75]=R,t[76]=x,t[77]=S,t[78]=C,t[79]=w,t[80]=E,t[81]=D,t[82]=z):z=t[82],z}function Zr(e){return e.title}function Qr(e){e.preventDefault(),e.stopPropagation()}function $r({tasks:e,dependencyEdges:t,returnTo:n,copy:r,onAction:i,onReorder:a,onUndoMove:o,onDependenciesChange:s,onCreate:c,actionBusyId:d,ref:f}){let p=(0,Z.useRef)(null),m=(0,Z.useRef)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(`board`),[C,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(()=>crypto.randomUUID()),[A,R]=(0,Z.useState)(``),[z,B]=(0,Z.useState)(`normal`),[V,U]=(0,Z.useState)(``),[ee,W]=(0,Z.useState)([]),[G,te]=(0,Z.useState)(!1),[ne,re]=(0,Z.useState)(null),K=k(e=>e.language),q=de({chat:w(K).chat}),ie=Er(e),J=e.filter(e=>e.phase!==`closed`),ae=(e,t)=>void i(e,t),oe=async(t,n)=>{let r=e.find(e=>e.id===h);if(g(null),!r||r.id===n)return;let o=ie[r.phase],s=o.findIndex(e=>e.id===r.id),c=s>=0?o[s+1]?.id??null:null;if(r.phase===t&&c===n)return;let l=Dr(r,t);r.phase!==t&&!l||l&&!await i(r,l)||await a(r.id,n)&&b({taskId:r.id,phase:r.phase,beforeTaskId:c})},se=async e=>{e.preventDefault();let t=A.trim();if(!(!t||G)){te(!0),re(null);try{let e=V?new Date(`${V}T23:59:59.999`).getTime():void 0;await c({requestId:D,objective:t,priority:z,dependsOnTaskIds:ee,attachments:q.wireAttachmentsPayload(),...e===void 0?{}:{dueAt:e}}),R(``),B(`normal`),U(``),W([]),q.clearAttachments(),O(crypto.randomUUID()),E(!1)}catch(e){re(e instanceof Error?e.message:r.createFailed)}finally{te(!1)}}},ce=()=>{O(crypto.randomUUID()),R(``),B(`normal`),U(``),W([]),q.clearAttachments(),re(null),E(!0)};(0,Z.useImperativeHandle)(f,()=>({openCreate:ce})),(0,Z.useEffect)(()=>{if(!y)return;let e=window.setTimeout(()=>b(null),6e3);return()=>window.clearTimeout(e)},[y]);let le=(0,Z.useCallback)(e=>{let t=m.current;!t||t.pointerId!==e.pointerId||(m.current=null,v(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),ue=(0,Z.useCallback)(e=>{if(e.button!==0||Gr(e.target))return;let t=p.current;t&&(m.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},[]),Y=(0,Z.useCallback)(e=>{let t=m.current,n=p.current;if(!t||!n||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX;!t.active&&Math.abs(r)<5||(t.active||(t.active=!0,v(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},[]);return(0,Q.jsxs)(`section`,{id:`project-panel-board`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-board`,className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex shrink-0 flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r.description})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,Q.jsxs)(`div`,{className:`flex rounded-lg border border-edge bg-surface-panel p-0.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":x===`board`,onClick:()=>S(`board`),className:T(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,x===`board`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,Q.jsx)(Xt,{className:`size-3.5`,"aria-hidden":!0}),r.views.board]}),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":x===`graph`,onClick:()=>S(`graph`),className:T(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,x===`graph`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,Q.jsx)(mt,{className:`size-3.5`,"aria-hidden":!0}),r.views.graph]})]})})]}),x===`board`?(0,Q.jsx)(`div`,{ref:p,className:T(`min-h-0 w-full min-w-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-x-contain pb-2 [scrollbar-width:thin]`,_?`cursor-grabbing select-none`:`cursor-grab`),onPointerDown:ue,onPointerMove:Y,onPointerUp:le,onPointerCancel:le,onLostPointerCapture:e=>{m.current?.pointerId===e.pointerId&&(m.current=null,v(!1))},children:(0,Q.jsx)(`div`,{className:`grid h-full min-h-0 min-w-[103rem] grid-cols-5 gap-3`,children:Tr.map(t=>{let i=Kr[t],a=ie[t];return(0,Q.jsxs)(`section`,{onDragOver:n=>{let r=e.find(e=>e.id===h);r&&(r.phase===t||Dr(r,t))&&n.preventDefault()},onDrop:e=>{e.preventDefault(),oe(t,null)},className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-inset/70 p-2.5`,children:[(0,Q.jsxs)(`header`,{className:`mb-2.5 flex shrink-0 items-center gap-2 px-0.5`,children:[(0,Q.jsxs)(`div`,{className:T(`flex items-center gap-1.5 rounded-md px-2 py-1`,qr[t]),children:[(0,Q.jsx)(i,{className:`size-3.5`,"aria-hidden":!0}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.phases[t]})]}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.length})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-y-contain pr-1 [scrollbar-gutter:stable] [scrollbar-width:thin]`,children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,Q.jsx)(Xr,{task:e,returnTo:n,copy:r,busy:d===e.id,onAction:ae,onDragStart:g,onDropBefore:e=>void oe(t,e)},e.id))})})]},t)})})}):(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(Ir,{tasks:e,dependencyEdges:t,returnTo:n,copy:{...r.graph,phases:r.phases},onDependenciesChange:s})}),(0,Q.jsx)(L,{open:C,onOpenChange:e=>{G||E(e)},children:(0,Q.jsxs)(P,{children:[(0,Q.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(F,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(40rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(I,{className:`text-base font-semibold text-fg`,children:r.createTitle}),(0,Q.jsx)(M,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r.createDescription})]}),(0,Q.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>void se(e),children:[(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsx)(`label`,{htmlFor:`project-task-objective`,className:`font-medium text-fg-muted`,children:r.objective}),(0,Q.jsxs)(`div`,{className:T(`overflow-hidden rounded-lg border border-edge bg-surface-base transition-colors focus-within:border-accent`,q.isDragging&&`border-accent bg-accent-soft/30`),onDragOver:e=>{e.preventDefault(),G||q.setIsDragging(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||q.setIsDragging(!1)},onDrop:e=>{e.preventDefault(),q.setIsDragging(!1),G||q.processFiles(Array.from(e.dataTransfer.files))},children:[(0,Q.jsx)(`textarea`,{id:`project-task-objective`,autoFocus:!0,className:`min-h-28 w-full resize-y bg-transparent px-3 py-3 text-sm leading-6 text-fg outline-none placeholder:text-fg-subtle`,value:A,onChange:e=>{R(e.target.value),re(null)},placeholder:r.objectivePlaceholder,maxLength:12e3,disabled:G}),(0,Q.jsx)(Ce,{attachments:q.attachments,topPadded:!1,onRemove:e=>{G||q.removeAttachment(e)}}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t border-edge-subtle px-2.5 py-2`,children:[(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:G,onClick:()=>q.fileInputRef.current?.click(),children:[(0,Q.jsx)(fe,{className:`size-3.5`,"aria-hidden":!0}),r.addFiles]}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:r.attachmentsDescription}),(0,Q.jsx)(`input`,{ref:q.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{q.processFiles(Array.from(e.target.files??[])),e.currentTarget.value=``}})]})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:r.priority}),(0,Q.jsx)(l,{value:z,onChange:e=>B(e.target.value),disabled:G,children:[`low`,`normal`,`high`,`critical`].map(e=>(0,Q.jsx)(u,{value:e,children:r.priorityOptions[e]},e))})]}),(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[r.dueDate,` `,(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:r.optional})]}),(0,Q.jsx)(bn,{className:`min-h-10 bg-surface-base`,value:V,onChange:U,disabled:G,ariaLabel:r.dueDate})]})]}),(0,Q.jsxs)(`fieldset`,{className:`grid gap-2`,children:[(0,Q.jsxs)(`legend`,{className:`text-sm font-medium text-fg-muted`,children:[r.dependencies,` `,(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:r.optional})]}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:r.dependenciesDescription}),(0,Q.jsx)(En,{candidates:J,selectedIds:ee,disabled:G,onChange:W,labels:{link:r.linkDependencies,linked:r.linkedDependencies,searchPlaceholder:r.dependencySearchPlaceholder,noMatches:r.noDependencyMatches,noCandidates:r.noDependencyCandidates,remove:r.removeDependency}})]}),ne?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ne}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:G,children:r.cancel})}),(0,Q.jsx)(H,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:G||!A.trim(),children:G?r.creating:K===`zh`?`保存待安排任务`:`Save for later`})]})]})]})]})}),y?(0,Q.jsxs)(`div`,{role:`status`,className:`fixed bottom-5 left-1/2 z-50 flex -translate-x-1/2 items-center gap-4 rounded-lg border border-edge bg-surface-panel px-4 py-3 text-sm text-fg shadow-float`,children:[(0,Q.jsx)(`span`,{children:r.moved}),(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:()=>{let e=y;b(null),o(e.taskId,e.phase,e.beforeTaskId).then(t=>{t||b(e)})},children:r.undo})]}):null]})}var ei=new Set([{id:`overview`,icon:Lt},{id:`tasks`,icon:q},{id:`automations`,icon:le},{id:`files`,icon:Re},{id:`notes`,icon:ue},{id:`skills`,icon:Me},{id:`sessions`,icon:b},{id:`progress`,icon:Ft},{id:`settings`,icon:ct}].map(e=>e.id)),ti=`xopc.projectFiles.panelWidthPx`,ni=320,ri=220,ii=560;function ai(e,t){return e.name!==t.name||e.description!==(t.description??``)||e.status!==t.status||e.defaultAgentId!==(t.defaultAgentId??``)||e.executionMode!==t.executionMode||e.brief!==(t.brief??``)||e.instructions!==(t.instructions??``)}function oi(e){return Math.min(ii,Math.max(ri,Math.round(e)))}function si(){try{let e=window.localStorage.getItem(ti);if(e==null)return ni;let t=Number.parseInt(e,10);return Number.isFinite(t)?oi(t):ni}catch{return ni}}function ci(e){try{window.localStorage.setItem(ti,String(oi(e)))}catch{}}function li(e){return!!(e&&ei.has(e))}function ui(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function di(e,t=``){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?String(e):Tt(n)}function fi(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`paused`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`archived`?`bg-surface-inset text-fg-subtle`:`bg-surface-hover text-fg-muted`}function pi(e){let t=(0,Mn.c)(8),{label:n,hint:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,Q.jsx)(`span`,{className:`text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function mi(e=!1){return T(`w-full rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,e?`min-h-24 py-2 leading-5`:`min-h-10`)}function hi(e){let t=(0,Mn.c)(10),{label:n,value:r,mono:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=o);let s=a&&`font-mono text-xs`,c;t[2]===s?c=t[3]:(c=T(`mt-1 min-w-0 truncate text-sm text-fg`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,Q.jsx)(`div`,{className:c,title:r,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-md bg-surface-base px-3 py-2`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function gi(e){return[e.name,e.slug,e.workspaceRoot,e.description,e.brief].filter(Boolean).join(` `).toLowerCase()}function _i(e){let t=e.lastActiveAt??e.updatedAt??e.createdAt,n=t?new Date(t).getTime():0;return Number.isFinite(n)?n:0}function vi(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function yi(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function bi(e){let t=e.actor;return t.name?t.name:t.agentId?t.agentId:t.id?t.id:t.conversationId?t.conversationId:t.kind}function xi(e){return e.primaryObject.title?.trim()||e.primaryObject.id}function Si(e){let t=e.source;return t.toolCallId?`${t.kind} · ${t.toolCallId}`:t.runId?`${t.kind} · ${t.runId}`:t.requestId?`${t.kind} · ${t.requestId}`:t.kind}function Ci(e){let t=e.sourceChannel?.trim();return t?wi(t):``}function wi(e){let t=e.trim().toLowerCase();return t?t===`tui`?`TUI`:t===`acp`?`ACP`:t===`webchat`?`Webchat`:t:``}function Ti(e){let t=e.payload.changes;if(Array.isArray(t)&&t.length)return t.filter(e=>typeof e==`string`).join(`, `);let n=e.payload.contentPreview;if(typeof n==`string`&&n.trim())return n.trim();let r=e.payload.title??e.payload.name;return typeof r==`string`&&r.trim()?r.trim():``}function Ei(e){return e.map(e=>({fileId:e.fileId,name:e.name,path:e.path,isDirectory:e.type===`directory`,children:e.type===`directory`?[]:void 0}))}function Di(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:Di(e.children,t,n)}:e)}function Oi({currentProject:e,pm:t,projectsText:n,wd:r}){let a=i(),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)([e]),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`new`),[C,w]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(!1),[A,R]=(0,Z.useState)(!0),[z,B]=(0,Z.useState)(null),[V,W]=(0,Z.useState)(null),ne=(0,Z.useCallback)(async()=>{m(!0),g(null);try{let t=await Bt({limit:100});u(n=>{let r=new Map;r.set(e.id,e);for(let e of n)r.set(e.id,e);for(let e of t.items)r.set(e.id,e);return Array.from(r.values())})}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e]);(0,Z.useEffect)(()=>{u(t=>[e,...t.filter(t=>t.id!==e.id)])},[e]),(0,Z.useEffect)(()=>{o&&ne()},[ne,o]);let re=(0,Z.useMemo)(()=>{let t=d.trim().toLowerCase().split(/\s+/).filter(Boolean);return l.filter(t=>t.id!==e.id).filter(e=>{if(t.length===0)return!0;let n=gi(e);return t.every(e=>n.includes(e))}).sort((e,t)=>_i(t)-_i(e))},[e.id,l,d]),K=e=>t.statuses[e.status]??e.status,q=e=>e.description||e.brief||t.common.defaultWorkspace,ie=e=>{b(e),w(``),D(``),B(null),v(!0),s(!1)},J=(0,Z.useCallback)(async(e={})=>{let t=E.trim(),n=C.trim()||(y===`directory`?vi(t):``);if(n){k(!0),B(null),W(null);try{let r=await Kt({autoUnderstand:A,name:n,...t?{workspaceRoot:t}:{},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});v(!1),w(``),D(``),R(!0),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:r.id}})),u(e=>[r,...e.filter(e=>e.id!==r.id)]),a(`/projects/${encodeURIComponent(r.id)}`)}catch(e){let t=yi(e);t?(W(t),v(!1)):B(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[y,C,a,E,A]),ae=(0,Z.useCallback)(e=>{e.preventDefault(),J()},[J]),oe=(0,Z.useCallback)(()=>{J({createWorkspaceRoot:!0})},[J]),ce=(0,Z.useCallback)(()=>{W(null),v(!0)},[]),le=e=>{D(e),y===`directory`&&!C.trim()&&w(vi(e))},ue=(e,t)=>(0,Q.jsxs)(`button`,{type:`button`,className:T(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-2 rounded-md p-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,t&&`bg-accent-soft/55 hover:bg-accent-soft/70`),onClick:()=>{s(!1),t||a(`/projects/${encodeURIComponent(e.id)}`)},children:[(0,Q.jsx)(c,{className:T(`size-4 text-accent-fg`,!t&&`invisible`),"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,Q.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:q(e)})]}),(0,Q.jsx)(`span`,{className:T(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,fi(e.status)),children:K(e)})]},e.id);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(U,{open:o,onOpenChange:s,children:[(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`group flex max-w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":t.projectSwitcher.switchProject,title:t.projectSwitcher.switchProject,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:e.name}),(0,Q.jsx)(`span`,{className:T(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,fi(e.status)),children:K(e)})]}),(0,Q.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:q(e)})]}),(0,Q.jsx)(Rt,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]})}),(0,Q.jsx)(ee,{children:(0,Q.jsxs)(te,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-[min(26rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover outline-none`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(`label`,{className:`relative block`,children:[(0,Q.jsx)(S,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,className:`h-9 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:d,onChange:e=>f(e.target.value),placeholder:t.projectSwitcher.searchPlaceholder,"aria-label":t.projectSwitcher.searchPlaceholder})]}),(0,Q.jsxs)(`div`,{className:`mt-1 max-h-[min(54vh,24rem)] overflow-y-auto pr-0.5 [scrollbar-gutter:stable]`,children:[(0,Q.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.current}),ue(e,!0),(0,Q.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.recent}),h?(0,Q.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:h}):null,p&&re.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.loading}):null,!p&&re.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.noMatches}):null,re.map(e=>ue(e,!1))]}),(0,Q.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>ie(`new`),children:[(0,Q.jsx)(x,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.newProject})]}),(0,Q.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>ie(`directory`),children:[(0,Q.jsx)(Re,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.openDirectory})]}),(0,Q.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>{s(!1),a(`/projects`)},children:[(0,Q.jsx)(ct,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.manageProjects})]})]})]})})]}),(0,Q.jsx)(L,{open:_,onOpenChange:e=>!O&&v(e),children:(0,Q.jsxs)(P,{children:[(0,Q.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(F,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(32rem,calc(100vh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(I,{className:`text-base font-semibold text-fg`,children:y===`directory`?t.projectSwitcher.createFromDirectoryTitle:n.createTitle}),(0,Q.jsx)(M,{className:`mt-1 text-sm text-fg-muted`,children:y===`directory`?t.projectSwitcher.createFromDirectoryDescription:n.createDescription})]}),(0,Q.jsxs)(`form`,{onSubmit:ae,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[z?(0,Q.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:z}):null,(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,Q.jsx)(`input`,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:C,onChange:e=>w(e.target.value),placeholder:`xopc`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,Q.jsx)(gn,{value:E,onChange:le,disabled:O,wd:r,placeholder:n.workspacePlaceholder,inputClassName:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]}),(0,Q.jsx)(We,{checked:A,onChange:R,disabled:O})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:O,children:n.cancel})}),(0,Q.jsxs)(H,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:O||!(C.trim()||y===`directory`&&vi(E)),children:[(0,Q.jsx)(x,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})}),(0,Q.jsx)(L,{open:!!V,onOpenChange:e=>{e||W(null)},children:(0,Q.jsxs)(P,{children:[(0,Q.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(F,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[110] flex w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(I,{className:`text-base font-semibold text-fg`,children:n.workspaceMissingTitle}),(0,Q.jsx)(M,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:V?ui(n.workspaceMissingDescription,{workspace:V}):null})]}),V?(0,Q.jsx)(`div`,{className:`px-5 py-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-inset px-3 py-2 text-sm text-fg-muted`,children:[(0,Q.jsx)(Re,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:V})]})}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:ce,disabled:O,children:n.workspaceMissingBack}),(0,Q.jsxs)(H,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:oe,disabled:O,children:[(0,Q.jsx)(se,{className:`size-4`,"aria-hidden":!0}),n.workspaceMissingCreate]})]})]})]})})]})}function ki(){let{projectId:e=``,tabId:t,noteId:n}=o(),r=i(),[c]=a(),d=k(e=>e.language),f=w(d),m=f.chat.workingDirectory,h=f.projectDetailPage,y=f.projectsPage,E=ve(e=>e.setPageHeader),D=ve(e=>e.clearPageHeader),[O,A]=(0,Z.useState)(null),V=(0,Z.useRef)(O);(0,Z.useLayoutEffect)(()=>{V.current=O},[O]);let[U,ee]=(0,Z.useState)(null),[W,G]=(0,Z.useState)([]),[te,re]=(0,Z.useState)(``),[K,de]=(0,Z.useState)([]),[fe,pe]=(0,Z.useState)(0),[me,he]=(0,Z.useState)(!1),[_e,be]=(0,Z.useState)(!1),[Se,Ce]=(0,Z.useState)(!1),[we,Te]=(0,Z.useState)([]),[Ee,Oe]=(0,Z.useState)(null),Ae=(0,Z.useRef)(new Set),[je,Ne]=(0,Z.useState)(null),[Ie,Ve]=(0,Z.useState)(null),[He,Ue]=(0,Z.useState)(null),[We,Ge]=(0,Z.useState)(si),[Ke,qe]=(0,Z.useState)(!1),[Je,Ye]=(0,Z.useState)(!1),[Qe,$e]=(0,Z.useState)(``),[et,tt]=(0,Z.useState)([]),[at,st]=(0,Z.useState)(!1),[lt,ft]=(0,Z.useState)(null),[pt,ht]=(0,Z.useState)(!1),[gt,bt]=(0,Z.useState)(null),[xt,Ct]=(0,Z.useState)([]),[Tt,kt]=(0,Z.useState)(``),[Mt,Nt]=(0,Z.useState)(!0),[Rt,Bt]=(0,Z.useState)(!1),[Ht,Ut]=(0,Z.useState)(!1),[Gt,Kt]=(0,Z.useState)(null),[Yt,Xt]=(0,Z.useState)(!1),[en,tn]=(0,Z.useState)(`fixed`),[ln,_n]=(0,Z.useState)(``),[vn,yn]=(0,Z.useState)(null),[bn,Sn]=(0,Z.useState)(!1),[Cn,wn]=(0,Z.useState)(!1),[Tn,En]=(0,Z.useState)(!1),[Dn,On]=(0,Z.useState)(null),kn=(0,Z.useRef)(null),An=(0,Z.useRef)(!1),[jn,X]=(0,Z.useState)(null),[Mn,Nn]=(0,Z.useState)({title:``,reason:``}),[Pn,Fn]=(0,Z.useState)({name:``,description:``,status:`active`,defaultAgentId:``,executionMode:`local_checkout`,workspaceRoot:``,brief:``,instructions:``}),In=(0,Z.useRef)(Pn),Ln=`overview`,$=n?`notes`:li(t)?t:Ln,Rn=(0,Z.useMemo)(()=>g(c.get(`returnTo`),`/projects`,[`/chat`]),[c]),zn=(0,Z.useCallback)(t=>{if(!e)return`/projects`;let n=`/projects/${encodeURIComponent(e)}/${t}`;return Rn===`/projects`?n:_(n,Rn)},[Rn,e]),Bn=(0,Z.useCallback)(t=>{e&&r(zn(t))},[r,e,zn]),Vn=(0,Z.useCallback)(()=>{if($===`tasks`&&kn.current){kn.current.openCreate();return}An.current=!0,Bn(`tasks`)},[Bn,$]);(0,Z.useEffect)(()=>{$!==`tasks`||!An.current||(An.current=!1,kn.current?.openCreate())},[$]);let Hn=(0,Z.useCallback)(t=>{e&&r(zn(t),{replace:!0})},[r,e,zn]),Un=(0,Z.useCallback)(e=>t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||Hn(e)},[Hn]),Wn=(0,Z.useCallback)(e=>e.startsWith(`/chat/`)?`sessions`:e.startsWith(`/notes`)?`notes`:$,[$]);(0,Z.useEffect)(()=>{!e||!t||li(t)||r(zn(Ln),{replace:!0})},[Ln,r,e,zn,t]),(0,Z.useEffect)(()=>{if(!e)return;let t=!1;return Nt(!0),X(null),Promise.all([Jt(e),$t(e),St(e),an().catch(()=>null),yt(e).catch(()=>null)]).then(([e,n,r,i,a])=>{if(t)return;A(e),ee(n),G(r),Oe(a),Ct(i?.agents??[]),kt(e.defaultAgentId??``);let o=yr(e);In.current=o,Fn(o)}).catch(e=>{t||(Oe(null),X(e instanceof Error?e.message:String(e)))}).finally(()=>{t||Nt(!1)}),()=>{t=!0}},[e]);let Gn=(0,Z.useCallback)(async()=>{e&&ee(await $t(e))},[e]);(0,Z.useEffect)(()=>{if(Mt)return;let t=!0,n=0,r=r=>{let i=r.detail?.id;if(!e||i&&i!==e)return;let a=++n;Promise.all([Jt(e),$t(e)]).then(([e,r])=>{if(!t||n!==a)return;let i=V.current;if(!(i?.id===e.id&&i.version>e.version)){if(i?.id===e.id){let t=br(In.current,i,e);In.current=t,Fn(t)}V.current=e,A(e),ee(r)}}).catch(e=>{!t||n!==a||e instanceof Error&&`status`in e&&e.status===404&&(A(null),ee(null),X(e.message))})};return window.addEventListener(`project-resource-changed`,r),r(new Event(`project-resource-changed`)),()=>{t=!1,window.removeEventListener(`project-resource-changed`,r)}},[e,Mt]),(0,Z.useEffect)(()=>{let t,n=n=>{let r=z.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void Gn(),120))},r=n=>{let r=R.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void Gn(),120))};return window.addEventListener(`task-changed-v2`,n),window.addEventListener(`task-deleted-v1`,r),()=>{window.clearTimeout(t),window.removeEventListener(`task-changed-v2`,n),window.removeEventListener(`task-deleted-v1`,r)}},[e,Gn]);let Kn=(0,Z.useCallback)(async(e,t)=>{On(e.id),X(null);try{let n=await Zt(e.id),r=t.startsWith(`move_`)?{type:`move`,phase:t.slice(5)}:t.startsWith(`reopen_`)?{type:`reopen`,phase:t.slice(7)}:t===`ready`?{type:`mark_ready`}:t===`run`?{type:`start`,executor:{kind:`agent`,agentId:n.task.delegateAgentId??(await qt(e.id)).agentId}}:t===`pause`?{type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}:t===`review`?{type:`request_review`}:t===`complete`?{type:`close`,resolution:`done`}:t===`reopen`?{type:`reopen`,phase:`ready`}:{type:`resolve_wait`,waitId:n.waits[0]?.id??``};if(r.type===`resolve_wait`&&!r.waitId)throw Error(`No active wait to resolve`);return await Ot(e.id,r,n.task.version),await Gn(),!0}catch(e){return await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed),!1}finally{On(null)}},[U,h.board.actionFailed,Gn]),qn=(0,Z.useCallback)(async t=>{e&&(X(null),await ot({idempotencyKey:t.requestId,title:t.objective,projectId:e,priority:t.priority,dueAt:t.dueAt,locale:d,contract:{objective:t.objective,expectedOutputs:[],acceptanceCriteria:[],constraints:[],approvalRequired:[],assumptions:[],risks:[],acceptancePolicy:`manual`,outputDestinations:[]},dependencies:t.dependsOnTaskIds,context:t.attachments.map((e,t)=>({targetKind:`file`,targetId:e.uri??e.name??`attachment-${t+1}`,role:`input`,title:e.name,pinned:!0,retrievalPolicy:{},metadata:{mimeType:e.mimeType,size:e.size,data:e.data}})),authorityGrants:[],activation:{mode:`capture`,phase:`backlog`}}),await Gn())},[d,e,Gn]),Jn=(0,Z.useCallback)(async(e,t)=>{On(e),X(null);try{return await cn(e,t,(await Zt(e)).task.version),await Gn(),!0}catch(e){return await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed),!1}finally{On(null)}},[h.board.actionFailed,Gn]),Yn=(0,Z.useCallback)(async(e,t,n)=>{On(e),X(null);try{let r=await Zt(e);return r.task.phase!==t&&(r=await Ot(e,r.task.phase===`closed`?{type:`reopen`,phase:t===`closed`?`ready`:t}:t===`closed`?{type:`close`,resolution:`done`}:{type:`move`,phase:t},r.task.version)),await cn(e,n,r.task.version),await Gn(),!0}catch(e){return await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed),!1}finally{On(null)}},[h.board.actionFailed,Gn]),Xn=(0,Z.useCallback)(async(e,t)=>{On(e),X(null);try{await dt(e,t,(await Zt(e)).task.version),await Gn()}catch(e){await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed)}finally{On(null)}},[h.board.actionFailed,Gn]),Zn=(0,Z.useCallback)(async()=>{if(O){he(!0),X(null);try{let e=await _t(O.id,{includeRelated:_e,limit:100});de(e.items),pe(e.total)}catch(e){X(e instanceof Error?e.message:String(e))}finally{he(!1)}}},[O,_e]);(0,Z.useEffect)(()=>{$===`progress`&&Zn()},[Zn,$]);let Qn=(0,Z.useCallback)(async()=>{if(!O?.effectiveWorkspaceRoot?.trim()){Te([]),Ae.current.clear(),bt(null);return}ht(!0),bt(null),Ae.current.clear();try{Te(Ei((await jt(O.id,``)).entries)),Ae.current.add(``)}catch(e){Te([]),Ae.current.clear(),bt(e instanceof Error?e.message:String(e))}finally{ht(!1)}},[O]),$n=(0,Z.useCallback)(async e=>{if(!(!O?.effectiveWorkspaceRoot?.trim()||Ae.current.has(e))){Ae.current.add(e),bt(null);try{let t=await jt(O.id,e);Te(n=>Di(n,e,Ei(t.entries)))}catch(t){Ae.current.delete(e),bt(t instanceof Error?t.message:String(t))}}},[O]),er=(0,Z.useCallback)(async e=>{if(!O?.effectiveWorkspaceRoot?.trim())return;let t=Ei((await jt(O.id,e)).entries);Te(e?n=>Di(n,e,t):t),Ae.current.add(e)},[O]);(0,Z.useEffect)(()=>{$===`files`&&Qn()},[Qn,$]);let tr=Qe.trim();(0,Z.useEffect)(()=>{if($!==`files`||!O||!Je||!tr){tt([]),st(!1),ft(null);return}let e=!1;st(!0),ft(null),tt([]);let t=window.setTimeout(()=>{it(O.id,tr,50).then(t=>{e||tt(t)}).catch(t=>{e||ft(t instanceof Error?t.message:String(t))}).finally(()=>{e||st(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[tr,O,Je,$]);let nr=(0,Z.useCallback)(async()=>{if(!O)return;let[e,t]=await Promise.all([Jt(O.id),$t(O.id)]);ee(t),A(e)},[O]),rr=(0,Z.useCallback)(async e=>{if(e.preventDefault(),!(!O||!Mn.title.trim())){wn(!0),X(null);try{await At(O.id,{title:Mn.title.trim(),reason:Mn.reason.trim()||void 0}),Nn({title:``,reason:``}),En(!1),await nr()}catch(e){X(e instanceof Error?e.message:String(e))}finally{wn(!1)}}},[Mn.reason,Mn.title,O,nr]),ir=(0,Z.useMemo)(()=>(0,Q.jsx)(s,{to:Rn,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":Rn===`/projects`?h.backToProjects:f.sidebar.back,children:(0,Q.jsx)(ae,{className:`size-4`,"aria-hidden":!0})}),[Rn,f.sidebar.back,h.backToProjects]),ar=(0,Z.useMemo)(()=>O?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(hn,{resource:{kind:`project`,id:O.id,revision:String(O.version)},disabled:Rt||ai(Pn,O)}),(0,Q.jsx)(H,{asChild:!0,variant:`secondary`,className:`h-9 rounded-lg`,children:(0,Q.jsxs)(s,{to:`/workflows?tab=library&projectId=${encodeURIComponent(O.id)}`,children:[(0,Q.jsx)(mt,{className:`size-4`,"aria-hidden":!0}),h.common.runWorkflow]})}),(0,Q.jsxs)(H,{variant:`secondary`,className:`h-9 rounded-lg`,onClick:Vn,children:[(0,Q.jsx)(x,{className:`size-4`,"aria-hidden":!0}),h.board.create]}),(0,Q.jsx)(H,{asChild:!0,variant:`primary`,className:`h-9 rounded-lg`,children:(0,Q.jsxs)(s,{to:dn(O.id),state:{forceNewChat:!0,agentId:O.defaultAgentId},onClick:Un(`sessions`),children:[(0,Q.jsx)(b,{className:`size-4`,"aria-hidden":!0}),h.common.newChat]})})]}):null,[Vn,Un,h.board.create,h.common.newChat,h.common.runWorkflow,O,Rt,Pn]);(0,Z.useLayoutEffect)(()=>(E({startExtra:ir,main:O?(0,Q.jsx)(Oi,{currentProject:O,pm:h,projectsText:y,wd:m}):(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:h.fallbackTitle}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:h.fallbackContext})]}),end:ar}),()=>D()),[D,ar,ir,h,O,y,E,m]);function sr(e){A(t=>t?{...t,...e}:null),kt(e.defaultAgentId??``),yt(e.id).then(Oe).catch(()=>Oe(null)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}async function cr(e=In.current){if(!(!O||!ai(e,O))){X(null),Kt(null);try{let t=await un(O.id,{name:e.name.trim(),status:e.status,description:e.description,defaultAgentId:e.defaultAgentId,executionMode:e.executionMode,brief:e.brief,instructions:e.instructions},O.version);sr(t);let n=In.current,r={...n,name:n.name===e.name?t.name:n.name,description:n.description===e.description?t.description??``:n.description,status:n.status===e.status?t.status:n.status,defaultAgentId:n.defaultAgentId===e.defaultAgentId?t.defaultAgentId??``:n.defaultAgentId,executionMode:n.executionMode===e.executionMode?t.executionMode:n.executionMode,brief:n.brief===e.brief?t.brief??``:n.brief,instructions:n.instructions===e.instructions?t.instructions??``:n.instructions};In.current=r,Fn(r)}catch(e){let t=yi(e);throw t?Kt(t):X(e instanceof Error?e.message:String(e)),e}}}function lr(e){e.preventDefault(),kr.flush()}function ur(e,t=!1){let n={...In.current,...e};In.current=n,Fn(n),t&&kr.saveNow(n)}let dr=(0,Z.useCallback)(()=>{if(!O)return;let e=O.workspaceRoot?.trim()??``;tn(e?`fixed`:`follow`),_n(e||O.effectiveWorkspaceRoot||``),Xt(!0)},[O]);async function fr(e={}){if(!O)return;let t=en===`fixed`?ln.trim():``;if(!(en===`fixed`&&!t)){Bt(!0),X(null),Kt(null);try{let n=await un(O.id,{workspaceRoot:t,...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}},O.version);sr(n),ur({workspaceRoot:n.workspaceRoot??``}),Xt(!1),Kt(null)}catch(e){let t=yi(e);t?(Kt(t),Xt(!1)):X(e instanceof Error?e.message:String(e))}finally{Bt(!1)}}}async function pr(){if(!(!O||vn)){yn(`pin`),X(null);try{sr(O.pinnedAt?await nn(O.id,O.version):await Pt(O.id,O.version))}catch(e){X(e instanceof Error?e.message:String(e))}finally{yn(null)}}}async function hr(){if(!(!O||vn)){yn(`archive`),X(null);try{let e=O.status===`archived`?await Dt(O.id,O.version):await It(O.id,O.version);sr(e),ur({status:e.status})}catch(e){X(e instanceof Error?e.message:String(e))}finally{yn(null)}}}async function gr(){if(O){Sn(!0),X(null);try{await zt(O.id,O.version),Ut(!1),r(`/projects`)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Sn(!1)}}}async function _r(){if(!(!O||Se)){Ce(!0),X(null);try{await Et(O.id)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Ce(!1)}}}let vr=(0,Z.useCallback)(e=>{Ne(e)},[]),xr=(0,Z.useCallback)((e,t)=>{t||Ne(e)},[]),Sr=(0,Z.useCallback)(async(e,t,n)=>{let r=O?.id;if(r)switch(e){case`preview`:t.isDirectory||Ne(t.path);break;case`download`:if(t.isDirectory)return;try{let e=rt(t.path);if(sn(wt(e))!==`text`){let n=await ie(t.path,{projectId:r}),i=ye(e)??`application/octet-stream`;on(e,await n.arrayBuffer(),i)}else{let{content:n}=await rn(t.path,{projectId:r});Fe(e,n)}}catch(e){Vt(`warning`,e instanceof Error?e.message:String(e),void 0,{duration:4e3})}break;case`copyPath`:try{await B(t.path)&&Vt(`success`,f.workspace.pathCopied,void 0,{duration:2500})}catch{Vt(`warning`,f.clipboard.copyFailed,void 0,{duration:4e3})}break;case`openDefault`:await Ze(()=>window.electronAPI?.shell?.openFileResource?.(t.fileId),f.workspace.openFileFailed);break;case`openWith`:await Ze(()=>window.electronAPI?.shell?.chooseAppAndOpenFileResource?.(t.fileId),f.workspace.openFileFailed);break;case`openWithApp`:if(!n)return;await Ze(()=>window.electronAPI?.shell?.openFileResourceWithApp?.(t.fileId,n),f.workspace.openFileFailed);break;case`revealInFolder`:await Ze(()=>window.electronAPI?.shell?.showFileResourceInFolder?.(t.fileId),f.workspace.revealFileFailed);break;case`trash`:Ve(t);break;case`delete`:t.isDirectory||Ue(t);break;default:break}},[f.clipboard.copyFailed,f.workspace.openFileFailed,f.workspace.pathCopied,f.workspace.revealFileFailed,O?.id]),Cr=(0,Z.useCallback)(async()=>{let e=Ie;if(!e)return;let t=await window.electronAPI?.shell?.trashFileResource?.(e.fileId);if(!t?.ok){Vt(`warning`,t?.error??f.workspace.trashFailed,void 0,{duration:4e3});return}je===e.path&&Ne(null),Ve(null),await Qn(),Vt(`success`,f.workspace.trashSuccess,void 0,{duration:2500})},[f.workspace.trashFailed,f.workspace.trashSuccess,Ie,je,Qn]),Tr=(0,Z.useCallback)(async(e,t)=>{let n=O?.id;if(n)try{await Promise.all(e.map(e=>ze(e,t,{projectId:n}))),await er(t).catch(()=>void 0),Vt(`success`,f.workspace.uploadSuccess.replace(`{{count}}`,String(e.length)),void 0,{duration:2500})}catch(e){await er(t).catch(()=>void 0),Vt(`warning`,`${f.workspace.uploadFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[f.workspace.uploadFailed,f.workspace.uploadSuccess,O?.id,er]),Er=(0,Z.useCallback)(async()=>{let e=He;if(e)try{await ut(e.fileId),je===e.path&&Ne(null),Ue(null);let t=e.path.lastIndexOf(`/`);await er(t<0?``:e.path.slice(0,t)).catch(()=>void 0),Vt(`success`,f.workspace.deleteSuccess,void 0,{duration:2500})}catch(e){Vt(`warning`,`${f.workspace.deleteFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[f.workspace.deleteFailed,f.workspace.deleteSuccess,He,je,er]),Dr=(0,Z.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`[data-project-files-grid]`);if(!n)return;t.setPointerCapture(e.pointerId),qe(!0);let r=e.clientX,i=We,a=e.pointerId,o=0,s=i,c=i,l=()=>{o=0,c=s,n.style.setProperty(`--project-files-panel-width`,`${c}px`)},u=e=>{s=oi(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(l))},d=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}qe(!1),Ge(c),ci(c),window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},[We]);(0,Z.useEffect)(()=>{$!==`files`&&Ne(null)},[e,$]);let Or=!!(O&&ai(Pn,O)),kr=mn({value:O?Pn:null,dirty:Or,onSave:cr,validate:e=>e.name.trim()?null:h.settings.nameRequired});if(Mt)return(0,Q.jsx)(`main`,{className:`w-full flex-1 p-3 text-sm text-fg-muted sm:px-5 sm:py-4 xl:px-6`,children:h.loading});if(!O)return(0,Q.jsxs)(`main`,{className:`w-full flex-1 p-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,Q.jsxs)(s,{to:Rn,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,Q.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),Rn===`/projects`?h.backToProjects:f.sidebar.back]}),(0,Q.jsx)(`p`,{className:`mt-6 rounded-lg bg-surface-panel p-4 shadow-surface text-sm text-fg-muted`,children:jn||h.notFound})]});let Ar=W.slice(0,3),jr=U?.blockers??[],Mr=wr(U?.tasks??[]),Nr=U?.tasks.filter(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.operationalState)).length??0,Pr=e=>h.statuses[e]??e,Fr=e=>ui(h.common.messages,{count:e}),Ir=te.trim().toLowerCase(),Lr=Ir?W.filter(e=>{let t=di(e.updatedAt),n=e.routing?.agentId||e.agentId||h.common.agent,r=e.name?.trim()||h.sessions.fallbackTitle,i=Fr(e.messageCount??0),a=Ci(e);return[r,e.key,n,a,t,i].filter(Boolean).join(` `).toLowerCase().includes(Ir)}):W,Rr=W.length>0&&Lr.length===0,zr=xt.find(e=>e.id===O.defaultAgentId)?.name||O.defaultAgentId||h.settings.globalDefaultAgent,Br=xt.find(e=>e.id===Pn.defaultAgentId),Vr=O.workspaceRoot?.trim()||``,Hr=O.status===`archived`,Ur=!!O.pinnedAt,Wr=!Vr,Gr=Vr||Br?.workspace||O.effectiveWorkspaceRoot||h.common.defaultWorkspace,Kr=en===`fixed`?ln.trim()||h.settings.workspacePlaceholder:Br?.workspace||O.effectiveWorkspaceRoot||h.common.defaultWorkspace,qr=(en===`fixed`?ln.trim():``)!==Vr&&(en===`follow`||!!ln.trim()),Jr=[{id:`overview`,icon:Lt,label:h.tabs.overview},{id:`tasks`,icon:q,label:h.tabs.tasks},{id:`automations`,icon:le,label:h.tabs.automations},{id:`files`,icon:Re,label:h.tabs.files},{id:`notes`,icon:ue,label:h.tabs.notes},{id:`skills`,icon:Me,label:h.tabs.skills},{id:`sessions`,icon:b,label:h.tabs.sessions},{id:`progress`,icon:Ft,label:h.tabs.progress}];async function Yr(){if(!Gr)return;let e=await B(Gr);Vt(e?`success`:`warning`,e?f.workspace.pathCopied:f.clipboard.copyFailed,void 0,{duration:e?2500:4e3})}function Xr(){Kt(null),Xt(!0)}return(0,Q.jsxs)(`main`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden p-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3`,children:[(0,Q.jsx)(fn,{items:Jr,activeTab:$,onChange:Bn,ariaLabel:h.navAria,tabIdPrefix:`project-primary-tab`,className:`min-w-0 flex-1`}),(0,Q.jsxs)(H,{id:`project-primary-tab-settings`,type:`button`,variant:$===`settings`?`secondary`:`ghost`,className:`h-9 shrink-0 rounded-lg px-3`,"aria-current":$===`settings`?`page`:void 0,onClick:()=>Bn(`settings`),children:[(0,Q.jsx)(ct,{className:`size-4`,"aria-hidden":!0}),h.tabs.settings,Or?(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-label":h.settings.unsavedChanges}):null]})]}),jn?(0,Q.jsx)(`p`,{className:`mt-3 shrink-0 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:jn}):null,(0,Q.jsxs)(`div`,{className:T(`mt-3 min-h-0 flex-1`,$===`overview`?`overflow-y-auto pr-1 [scrollbar-gutter:stable] xl:overflow-hidden xl:pr-0`:$===`tasks`?`overflow-hidden`:`overflow-y-auto pr-1 [scrollbar-gutter:stable]`),children:[$===`overview`?(0,Q.jsxs)(`section`,{id:`project-panel-overview`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-overview`,className:`grid min-h-full gap-4 xl:h-full xl:min-h-0 xl:grid-cols-[minmax(0,1fr)_20rem] xl:overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,Q.jsx)(ge,{projectId:O.id},O.id),(0,Q.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface`,children:[(0,Q.jsx)(`div`,{className:`p-5`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.directionTitle}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:ui(h.overview.activitySummary,{moving:Nr,attention:jr.length})})]}),(0,Q.jsx)(`p`,{className:`mt-2 max-w-3xl text-base font-medium leading-7 text-fg`,children:O.outcome||O.description||O.brief||h.overview.directionFallback}),U?.digest.recommendedAction?(0,Q.jsx)(`p`,{className:`mt-3 max-w-3xl rounded-lg bg-surface-hover px-3 py-2.5 text-sm font-medium leading-6 text-fg`,children:ui(h.overview.recommendedNext,{action:U.digest.recommendedAction})}):null]}),(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 rounded-lg px-2 text-xs`,onClick:()=>void _r(),disabled:Se,children:[(0,Q.jsx)(Qt,{className:`size-3.5`,"aria-hidden":!0}),Se?h.overview.savingDigest:h.overview.saveDigest]})]})}),(0,Q.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-5 py-3.5`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.nextActions}),(0,Q.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-fg-muted transition-colors hover:text-fg`,onClick:()=>Bn(`tasks`),children:h.common.viewAll})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle border-t border-edge-subtle`,children:Mr.length?Mr.map(e=>(0,Q.jsxs)(s,{to:J(zn(`overview`),e.id),className:`block px-5 py-3 transition-colors hover:bg-surface-hover`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,Q.jsxs)(`span`,{className:T(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,e.attention.length?`bg-warning/10 text-warning`:`bg-surface-hover text-fg-muted`),children:[h.board.phases[e.phase],e.operationalState===`idle`?``:` · ${h.board.operationalStates[e.operationalState]}`]})]}),e.attention[0]?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.attention[0].summary}):null]},e.id)):(0,Q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:h.overview.noNextActions})})]})]}),U?.recentResults.length?(0,Q.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.recentResults})}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:U.recentResults.slice(0,3).map(({taskId:e,taskTitle:t,receipt:n})=>(0,Q.jsxs)(s,{to:J(zn(`overview`),e),className:`block px-5 py-3 transition-colors hover:bg-surface-hover`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),(0,Q.jsxs)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:[h.overview.resultStatuses[n.status],` · `,h.board.verification[n.verification.status]]})]}),(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-3 text-sm leading-5 text-fg-muted`,children:(0,Q.jsx)(v,{content:n.summary,compact:!0})})]},n.runId))})]}):null,O.milestones.length||O.recentUpdates.length?(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-4 md:grid-cols-2`,children:[O.milestones.length?(0,Q.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.milestones})}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:O.milestones.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-5 py-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:h.statuses[e.status]})]},e.id))})]}):null,O.recentUpdates.length?(0,Q.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.projectUpdates})}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:O.recentUpdates.slice(0,3).map(e=>(0,Q.jsxs)(`div`,{className:`px-5 py-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm leading-5 text-fg`,children:e.summary}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:h.overview.healthLabels[e.health]})]},e.id))})]}):null]}):null]}),(0,Q.jsxs)(`aside`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-surface-panel p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.attention}),(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 rounded-lg px-2 text-xs`,"aria-expanded":Tn,onClick:()=>En(e=>!e),children:[(0,Q.jsx)(x,{className:T(`size-3.5 transition-transform`,Tn&&`rotate-45`),"aria-hidden":!0}),h.overview.addBlocker]})]}),jr.length?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-3`,children:jr.map(e=>{let t=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(Wt,{className:`size-4 text-amber-600 dark:text-amber-300`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title})]}),(0,Q.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:[h.overview.attentionKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:e.status?` · ${Pr(e.status)}`:``]})]});return e.href?(0,Q.jsx)(s,{to:e.href,onClick:Un(Wn(e.href)),className:`min-w-0 rounded-md bg-surface-base p-3 hover:bg-surface-hover`,children:t},e.id):(0,Q.jsx)(`div`,{className:`min-w-0 rounded-md bg-surface-base p-3`,children:t},e.id)})}):(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:h.overview.noBlockedTasks}),Tn?(0,Q.jsxs)(`form`,{onSubmit:rr,className:`mt-4 flex gap-2 border-t border-edge-subtle pt-4`,children:[(0,Q.jsx)(`input`,{className:`min-h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:Mn.title,onChange:e=>Nn(t=>({...t,title:e.target.value})),placeholder:h.overview.blockerTitlePlaceholder}),(0,Q.jsx)(H,{type:`submit`,variant:`secondary`,className:`shrink-0 rounded-lg px-3`,disabled:Cn||!Mn.title.trim(),"aria-label":Cn?h.overview.addingBlocker:h.overview.addBlocker,title:Cn?h.overview.addingBlocker:h.overview.addBlocker,children:(0,Q.jsx)(x,{className:`size-4`,"aria-hidden":!0})})]}):null]}),(0,Q.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(Xe,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:h.overview.recentSessions})]}),(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>Bn(`sessions`),children:h.common.viewAll})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Ar.length?Ar.map(e=>(0,Q.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Un(`sessions`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:di(e.updatedAt)})]}),(e.routing?.agentId||e.agentId)&&(e.routing?.agentId||e.agentId)!==O.defaultAgentId?(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.routing?.agentId||e.agentId}):null]},e.key)):(0,Q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:h.overview.noSessions})})]})]})]}):null,$===`tasks`?(0,Q.jsx)($r,{ref:kn,tasks:U?.tasks??[],dependencyEdges:U?.dependencyEdges??[],returnTo:zn(`tasks`),copy:h.board,onAction:Kn,onReorder:Jn,onUndoMove:Yn,onDependenciesChange:Xn,onCreate:qn,actionBusyId:Dn}):null,$===`automations`?(0,Q.jsx)(`section`,{id:`project-panel-automations`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-automations`,className:`grid min-h-full content-start gap-4`,children:(0,Q.jsx)(xn,{projectId:O.id,embedded:!0,title:h.automations.title,subtitle:h.automations.hint})}):null,$===`notes`?(0,Q.jsx)(`section`,{id:`project-panel-notes`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-notes`,className:`flex h-full min-h-[28rem] overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,Q.jsx)(or,{selectedNoteId:n,basePath:`/projects/${encodeURIComponent(O.id)}/notes`,showLibrary:!1,allowMediaCapture:!1,projectId:O.id,listTitle:h.notes.title,listDescription:h.notes.hint,emptyText:h.notes.emptyTitle,emptyDescription:h.notes.emptyDescription,listWidthStorageKey:`xopc.projectNotes.listWidth.${O.id}`})}):null,$===`skills`?(0,Q.jsx)(mr,{projectId:O.id,copy:h.skills}):null,$===`files`?(0,Q.jsx)(`section`,{id:`project-panel-files`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-files`,className:`flex h-full min-h-[28rem] flex-col`,children:(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl bg-surface-panel`,children:O.effectiveWorkspaceRoot?(0,Q.jsxs)(`div`,{"data-project-files-grid":!0,className:T(`grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[var(--project-files-panel-width)_8px_minmax(0,1fr)]`,Ke&&`cursor-col-resize select-none`),style:{"--project-files-panel-width":`${We}px`},children:[(0,Q.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-b border-edge bg-surface-panel lg:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-1 bg-surface-hover/30 px-3 text-sm`,children:[Ee?(0,Q.jsx)(xe,{resourceId:Ee.fileId,displayName:Ee.name}):null,(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,className:T(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,Je&&`bg-surface-hover text-fg`),onClick:()=>Ye(!0),"aria-label":h.files.search,title:h.files.search,"aria-pressed":Je,children:(0,Q.jsx)(S,{className:`size-3.5`,"aria-hidden":!0})}),(0,Q.jsx)(ce,{className:`size-7 shrink-0 rounded-md p-0`,loading:pt,label:f.cron.refresh,onClick:()=>void Qn()})]})]}),Je?(0,Q.jsx)(`div`,{className:`shrink-0 bg-surface-hover/20 px-3 py-2`,children:(0,Q.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md bg-surface-base px-2 focus-within:ring-2 focus-within:ring-accent/30`,children:[(0,Q.jsx)(S,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`text`,role:`searchbox`,value:Qe,onChange:e=>$e(e.target.value),placeholder:h.files.searchPlaceholder,"aria-label":h.files.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none placeholder:text-fg-subtle`}),(0,Q.jsx)(`button`,{type:`button`,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":h.files.clearSearch,title:h.files.clearSearch,onClick:()=>{$e(``),Ye(!1)},children:(0,Q.jsx)(C,{className:`size-3.5`,"aria-hidden":!0})})]})}):null,gt?(0,Q.jsx)(`div`,{className:`bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:gt}):null,tr?(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:at?(0,Q.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,Q.jsx)(ne,{className:`h-11 w-full`}),(0,Q.jsx)(ne,{className:`h-11 w-full`}),(0,Q.jsx)(ne,{className:`h-11 w-full`})]}):lt?(0,Q.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[f.workspace.loadError,`: `,lt]}):et.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:h.files.noSearchResults}):et.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:T(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,je===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>Ne(e.path),title:e.path,children:[(0,Q.jsx)(ue,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,Q.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):pt&&we.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:h.files.loading}):(0,Q.jsx)(Y,{tree:we,selectedPath:je,onSelectFile:vr,onSelectEntry:xr,onExpandDir:e=>void $n(e),onAction:Sr,onUploadFiles:(e,t)=>void Tr(e,t),uploadDropHint:f.workspace.dropToUpload,actionLabels:{preview:f.workspace.preview,download:f.workspace.download,copyPath:f.workspace.copyPath,openDefault:f.workspace.openSystemApp,openDirectory:f.workspace.openInFileManager,openWith:f.workspace.openWith,revealInFolder:f.workspace.revealInFolder,trash:f.workspace.moveToTrash,delete:f.workspace.deleteFile,recommendedApps:f.workspace.recommendedApps,desktopUpdateRequired:f.workspace.desktopUpdateRequired},emptyHint:h.files.emptyDirectory})]}),(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":h.files.resizeHandle,className:T(`group hidden cursor-col-resize touch-none items-stretch justify-center bg-transparent transition-colors hover:bg-surface-hover/60 lg:flex`,Ke&&`bg-surface-hover/70`),onPointerDown:Dr,children:(0,Q.jsx)(`div`,{className:T(`my-3 w-px rounded-full bg-transparent transition-colors`,`group-hover:bg-edge-strong/55`,Ke&&`bg-accent/60`)})}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden bg-surface-base`,children:je?(0,Q.jsx)(nt,{filePath:je,projectId:O.id,agentId:O.defaultAgentId||Tt||void 0,onClose:()=>Ne(null)}):(0,Q.jsx)(`div`,{className:`flex h-full min-h-[18rem] items-center justify-center px-6 text-center`,children:(0,Q.jsxs)(`div`,{className:`max-w-sm`,children:[(0,Q.jsx)(Re,{className:`mx-auto size-8 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:h.files.previewEmptyTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.files.previewEmptyDescription})]})})})]}):(0,Q.jsxs)(`div`,{className:`grid gap-3 px-4 py-8 text-sm text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:h.files.needWorkspace}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(H,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>Bn(`settings`),children:h.files.openSettings})})]})})}):null,$===`sessions`?(0,Q.jsxs)(`section`,{id:`project-panel-sessions`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-sessions`,className:`grid min-h-full content-start gap-3`,children:[W.length?(0,Q.jsxs)(`label`,{className:`relative flex min-h-9 w-full max-w-lg cursor-text items-center rounded-lg bg-surface-panel py-1.5 pl-9 pr-9 shadow-surface`,children:[(0,Q.jsx)(S,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:te,onChange:e=>re(e.currentTarget.value),placeholder:h.sessions.searchPlaceholder,"aria-label":h.sessions.searchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),te?(0,Q.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":h.sessions.clearSearch,onClick:()=>re(``),children:(0,Q.jsx)(C,{className:`size-3.5`,"aria-hidden":!0})}):null]}):null,Lr.length?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Lr.map(e=>{let t=di(e.updatedAt),n=e.routing?.agentId||e.agentId||h.common.agent,r=Ci(e),i=e.name?.trim()||h.sessions.fallbackTitle,a=Fr(e.messageCount??0);return(0,Q.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Un(`sessions`),className:`group flex min-h-[8.75rem] min-w-0 flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-base text-fg-muted`,children:(0,Q.jsx)(b,{className:`size-4`,"aria-hidden":!0})}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:i}),r?(0,Q.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-2 py-0.5 text-[11px] font-medium leading-5 text-fg-muted`,children:r}):null]})})]}),(0,Q.jsxs)(`div`,{className:`mt-auto grid gap-2 pt-4 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[h.sessions.agent,`: `,n]}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:a})]}),t?(0,Q.jsxs)(`span`,{className:`truncate rounded-md bg-surface-base px-2 py-1`,children:[h.sessions.updated,`: `,t]}):null]})]},e.key)})}):Rr?(0,Q.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:h.sessions.noMatches})}):(0,Q.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:h.sessions.emptyTitle}),(0,Q.jsx)(`p`,{className:`mx-auto mt-1 max-w-md text-sm leading-6 text-fg-muted`,children:h.sessions.emptyDescription})]})})]}):null,$===`progress`?(0,Q.jsxs)(`section`,{id:`project-panel-progress`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-progress`,className:`grid min-h-full content-start gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.progress.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ui(h.progress.count,{count:fe})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`label`,{className:`inline-flex min-h-9 items-center gap-2 rounded-lg bg-surface-panel px-3 text-sm text-fg-muted shadow-surface`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:_e,onChange:e=>be(e.currentTarget.checked),className:`size-4 rounded border-edge text-accent focus:ring-accent/30`}),h.progress.includeRelated]}),(0,Q.jsxs)(H,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3`,onClick:()=>void Zn(),disabled:me,children:[(0,Q.jsx)(vt,{className:T(`size-4`,me&&`animate-spin`),"aria-hidden":!0}),h.common.refresh]})]})]}),(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:me&&K.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:h.progress.loading}):K.length?(0,Q.jsx)(`div`,{className:`divide-y divide-edge`,children:K.map(e=>{let t=h.progress.types[e.type]??e.type,n=h.progress.objectKinds[e.primaryObject.kind]??e.primaryObject.kind,r=Ti(e),i=e.relatedProjects.length>0&&!e.scopes.some(e=>e.scopeKind===`project`&&e.scopeId===O.id);return(0,Q.jsxs)(`article`,{className:`grid gap-2 px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),i?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-xs font-medium text-fg-muted`,children:h.progress.related}):null]}),(0,Q.jsxs)(`p`,{className:`mt-1 min-w-0 truncate text-sm text-fg-muted`,children:[n,`: `,xi(e)]})]}),(0,Q.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,dateTime:new Date(e.createdAt).toISOString(),children:di(e.createdAt)})]}),r?(0,Q.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:r}):null,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[h.progress.actor,`: `,bi(e)]}),(0,Q.jsxs)(`span`,{className:`max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[h.progress.source,`: `,Si(e)]})]})]},e.id)})}):(0,Q.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:h.progress.empty})})]}):null,$===`settings`?(0,Q.jsxs)(`form`,{id:`project-panel-settings`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-settings`,onSubmit:lr,onBlurCapture:kr.onBlurCapture,className:`grid min-h-full content-start gap-4 pb-1`,children:[(0,Q.jsxs)(`section`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.summaryTitle}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:h.settings.summaryHint})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-2`,children:[(0,Q.jsx)(`span`,{className:T(`rounded-full px-2 py-0.5 text-xs font-medium`,fi(Pn.status)),children:h.settings.statuses[Pn.status]}),(0,Q.jsx)(pn,{status:kr.status,error:kr.error})]})]}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.detailsTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.settings.detailsHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Q.jsx)(pi,{label:h.settings.name,children:(0,Q.jsx)(`input`,{className:mi(),value:Pn.name,onChange:e=>ur({name:e.target.value})})}),(0,Q.jsx)(pi,{label:h.settings.defaultAgent,children:(0,Q.jsxs)(l,{className:mi(),value:Pn.defaultAgentId,onChange:e=>ur({defaultAgentId:e.target.value},!0),children:[(0,Q.jsx)(u,{value:``,children:h.settings.globalDefaultAgent}),xt.map(e=>(0,Q.jsx)(u,{value:e.id,children:ke(e,f.agentsSettings)},e.id))]})}),(0,Q.jsx)(pi,{label:h.settings.status,children:Hr?(0,Q.jsx)(`div`,{className:`grid min-h-10 content-center rounded-md border border-edge bg-surface-inset px-3 text-sm text-fg-muted`,children:h.settings.statuses.archived}):(0,Q.jsxs)(l,{className:mi(),value:Pn.status===`archived`?`active`:Pn.status,onChange:e=>ur({status:e.target.value},!0),children:[(0,Q.jsx)(u,{value:`active`,children:h.settings.statuses.active}),(0,Q.jsx)(u,{value:`paused`,children:h.settings.statuses.paused})]})}),(0,Q.jsx)(pi,{label:h.settings.executionMode,hint:h.settings.executionModeHint,children:(0,Q.jsxs)(l,{className:mi(),value:Pn.executionMode,onChange:e=>ur({executionMode:e.target.value},!0),children:[(0,Q.jsx)(u,{value:`managed_worktree`,children:h.settings.executionModeWorktree}),(0,Q.jsx)(u,{value:`local_checkout`,children:h.settings.executionModeLocal})]})}),(0,Q.jsx)(pi,{label:h.settings.description,hint:h.settings.descriptionHint,children:(0,Q.jsx)(`textarea`,{className:mi(!0),value:Pn.description,onChange:e=>ur({description:e.target.value})})})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.projectGuidanceTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.settings.projectGuidanceHint})]}),(0,Q.jsx)(pi,{label:h.settings.brief,hint:h.settings.briefHint,children:(0,Q.jsx)(`textarea`,{className:mi(!0),value:Pn.brief,onChange:e=>ur({brief:e.target.value})})}),(0,Q.jsx)(pi,{label:h.settings.instructions,hint:h.settings.instructionsHint,children:(0,Q.jsx)(`textarea`,{className:mi(!0),value:Pn.instructions,onChange:e=>ur({instructions:e.target.value})})})]})]}),(0,Q.jsxs)(`aside`,{className:`grid gap-4 xl:sticky xl:top-0`,children:[(0,Q.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.workspaceRoot}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:h.settings.workspaceIndependentHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Q.jsx)(`span`,{className:`w-fit rounded-md bg-surface-inset px-2 py-0.5 text-xs font-medium text-fg-muted`,children:Wr?h.settings.workspaceModeFollow:h.settings.workspaceModeFixed}),(0,Q.jsx)(`div`,{className:`break-all font-mono text-xs leading-5 text-fg`,title:Gr,children:Gr}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:()=>void Yr(),children:[(0,Q.jsx)(p,{className:`size-4`,"aria-hidden":!0}),h.settings.copyWorkspacePath]}),Ee?(0,Q.jsx)(xe,{resourceId:Ee.fileId,displayName:Ee.name}):null,(0,Q.jsxs)(H,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:dr,children:[(0,Q.jsx)(se,{className:`size-4`,"aria-hidden":!0}),h.settings.migrateWorkspace]})]})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.currentProjectTitle}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(hi,{label:h.settings.defaultAgent,value:zr}),(0,Q.jsx)(hi,{label:h.settings.pinState,value:Ur?h.settings.pinned:h.settings.notPinned}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Q.jsx)(hi,{label:h.settings.createdAt,value:di(O.createdAt)||h.common.never}),(0,Q.jsx)(hi,{label:h.settings.updatedAt,value:di(O.updatedAt)||h.common.never})]})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.managementTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:h.settings.managementHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:Ur?h.settings.pinnedTitle:h.settings.pinTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:h.settings.pinHint})]}),(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`w-fit rounded-lg`,disabled:vn===`pin`,onClick:()=>void pr(),children:[Ur?(0,Q.jsx)(Le,{className:`size-4`,"aria-hidden":!0}):(0,Q.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),Ur?h.settings.unpinProject:h.settings.pinProject]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:Hr?h.settings.restoreTitle:h.settings.archiveTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:Hr?h.settings.restoreHint:h.settings.archiveHint})]}),(0,Q.jsxs)(H,{type:`button`,variant:Hr?`primary`:`ghost`,className:`w-fit rounded-lg`,disabled:vn===`archive`,onClick:()=>void hr(),children:[Hr?(0,Q.jsx)(vt,{className:`size-4`,"aria-hidden":!0}):(0,Q.jsx)(Be,{className:`size-4`,"aria-hidden":!0}),Hr?h.settings.restoreProject:h.settings.archiveProject]})]})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-3 rounded-lg border border-red-500/20 bg-red-500/5 p-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-red-700 dark:text-red-300`,children:h.settings.dangerTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-red-700/80 dark:text-red-200/80`,children:h.settings.dangerHint})]}),(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`w-fit text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>Ut(!0),children:[(0,Q.jsx)(Pe,{className:`size-4`,"aria-hidden":!0}),h.settings.deleteConfirmAction]})]})]})]})]}):null]}),(0,Q.jsx)(L,{open:Ht,onOpenChange:e=>{bn||Ut(e)},children:(0,Q.jsxs)(P,{children:[(0,Q.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(F,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-5 shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-red-500/10 text-red-600 dark:text-red-400`,children:(0,Q.jsx)(Wt,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(I,{className:`text-base font-semibold text-fg`,children:h.settings.deleteConfirmTitle}),(0,Q.jsx)(M,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:O?ui(h.settings.deleteConfirm,{name:O.name}):h.settings.deleteConfirmFallback})]})]}),(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:bn,children:h.common.cancel})}),(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,className:`rounded-lg text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,disabled:bn||!O,onClick:()=>void gr(),children:[(0,Q.jsx)(Pe,{className:`size-4`,"aria-hidden":!0}),h.settings.deleteConfirmAction]})]})]})]})}),(0,Q.jsx)(De,{open:!!Ie,title:f.workspace.trashConfirmTitle,description:f.workspace.trashConfirmDescription.replace(`{{name}}`,Ie?.name??``),confirmLabel:f.workspace.moveToTrash,cancelLabel:f.workspace.cancel,destructive:!0,onConfirm:()=>void Cr(),onCancel:()=>Ve(null)}),(0,Q.jsx)(De,{open:!!He,title:f.workspace.deleteConfirmTitle,description:f.workspace.deleteConfirmDescription.replace(`{{name}}`,He?.name??``),confirmLabel:f.workspace.deleteFile,cancelLabel:f.workspace.cancel,destructive:!0,onConfirm:()=>void Er(),onCancel:()=>Ue(null)}),(0,Q.jsx)(L,{open:Yt,onOpenChange:e=>{Rt||Xt(e)},children:(0,Q.jsxs)(P,{children:[(0,Q.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(F,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(I,{className:`text-base font-semibold text-fg`,children:h.settings.workspaceMigrationTitle}),(0,Q.jsx)(M,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.settings.workspaceMigrationDescription})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:h.settings.workspaceMode}),(0,Q.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:T(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,en===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Q.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:en===`fixed`,onChange:()=>tn(`fixed`),disabled:Rt}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:h.settings.workspaceModeFixed}),(0,Q.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:h.settings.workspaceMigrationFixedHint})]})]}),(0,Q.jsxs)(`label`,{className:T(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,en===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Q.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:en===`follow`,onChange:()=>tn(`follow`),disabled:Rt}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:h.settings.workspaceModeFollow}),(0,Q.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:h.settings.workspaceHint})]})]})]})]}),en===`fixed`?(0,Q.jsx)(gn,{value:ln,onChange:_n,disabled:Rt,wd:m,placeholder:h.settings.workspacePlaceholder,inputClassName:mi(),autoFocus:!0}):null,(0,Q.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm leading-6 text-amber-800 dark:text-amber-200`,children:h.settings.workspaceMigrationImpact}),(0,Q.jsx)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-subtle`,children:ui(h.settings.workspaceCurrent,{workspace:Kr})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Rt,children:h.common.cancel})}),(0,Q.jsxs)(H,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:Rt||!qr,onClick:()=>void fr(),children:[(0,Q.jsx)(se,{className:`size-4`,"aria-hidden":!0}),h.settings.workspaceMigrationConfirm]})]})]})]})}),(0,Q.jsx)(L,{open:!!Gt,onOpenChange:e=>{e||Kt(null)},children:(0,Q.jsxs)(P,{children:[(0,Q.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(F,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(I,{className:`text-base font-semibold text-fg`,children:h.settings.workspaceMissingTitle}),(0,Q.jsx)(M,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:Gt?ui(h.settings.workspaceMissingDescription,{workspace:Gt}):null})]}),Gt?(0,Q.jsx)(`div`,{className:`px-5 py-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-inset px-3 py-2 text-sm text-fg-muted`,children:[(0,Q.jsx)(Re,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:Gt})]})}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(H,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:Xr,disabled:Rt,children:h.settings.workspaceMissingBack}),(0,Q.jsxs)(H,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:()=>void fr({createWorkspaceRoot:!0}),disabled:Rt,children:[(0,Q.jsx)(se,{className:`size-4`,"aria-hidden":!0}),h.settings.workspaceMissingCreate]})]})]})]})})]})}export{ki as ProjectDetailPage};
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{c as a,d as o,f as s,g as c,l,m as u,t as d,u as f}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as p,r as m,t as h}from"./popover-select-DcsFzD_i.js";import{t as g}from"./x-B_N4OPjy.js";import{a as _,c as v,n as y,r as b}from"./locale-store-wNXWkWu5.js";import{a as x,i as S,n as C,o as w,r as T,s as E,t as D}from"./dist-BGTk37IG.js";import{a as O,i as k,n as A}from"./vendor-swr-BIWyz7Rc.js";import{t as j}from"./button-CS04eWY9.js";import{t as M}from"./skeleton-BwbyijEw.js";import{$u as N,Cd as P,Ho as F,Oa as I,Qc as ee,Qt as te,Ro as L,fl as R,lu as z,ol as B,po as ne,rn as re,sd as ie}from"./index-D99vN3es.js";import{t as ae}from"./page-context-capture-button-qqWG_gs_.js";var V=e(t(),1),H=r(),U=e=>_(b(`/api/scenes${e}`)),W=(e,t,n,r)=>_(b(`/api/scenes${e}`),{method:t,body:n===void 0?void 0:JSON.stringify(n),headers:{"Idempotency-Key":r??crypto.randomUUID()}});function G(e,t){let n=e?.status;return n===401?t?`登录已失效,请重新登录后查看智能关注。`:`Your session expired. Sign in again to view monitors.`:n===503?t?`智能关注服务暂不可用,请检查服务状态后重试。`:`The monitor service is unavailable. Check the Gateway and retry.`:n===409?t?`内容已被更新,请刷新后重新确认。`:`This content changed. Refresh and review it before trying again.`:(e?.body?.missing)?.some(e=>e.startsWith(`model_`))?t?`请先在模型设置中选择可用模型并配置凭据,然后重试。`:`Choose an available model and configure its credentials in model settings, then retry.`:n===422?t?`设置或授权不完整,请检查数据来源和范围。`:`Setup or permission is incomplete. Check the source and scope.`:n===404?t?`找不到这项关注或结果,请返回智能关注列表。`:`Monitor or result not found. Return to the monitors list.`:t?`操作未完成,请检查连接后重试。你的输入仍保留在当前页面。`:`Could not finish. Check your connection and retry. Your input is still on this page.`}var K=i();function oe(e){let t=(0,H.c)(49),{activationId:n,zh:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:15e3},t[0]=i):i=t[0];let a=k(`/diagnostics`,U,i),o,s,c,l,u,f,p,m,h,g,_;if(t[1]!==n||t[2]!==a.data||t[3]!==r){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a.data?.activations.find(e=>e.id===n);if(!e){c=null;break bb0}let i;t[15]===r?i=t[16]:(i=e=>e==null?r?`未设置`:`Not scheduled`:new Date(e).toLocaleString(r?`zh-CN`:`en`),t[15]=r,t[16]=i);let v=i,y;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(y={needs_permission:[`邮件授权已失效,请重新连接账号。`,`Mail permission expired. Reconnect the account.`],source_rate_limited:[`邮件服务暂时限流,将自动重试。`,`Mail service rate limited. A retry is scheduled.`],source_timeout:[`读取邮件超时,将自动重试。`,`Mail read timed out. A retry is scheduled.`],unchanged_result:[`资料未变化,已保留原成果和反馈。`,`Context unchanged. The existing result and feedback were preserved.`],source_not_ready:[`来源暂不可用,请检查连接授权;稍后会重试。`,`Source unavailable. Check connection access; a retry is scheduled.`],daily_budget:[`已达每日模型调用上限,将在预算恢复后继续。`,`Daily model limit reached. Checks resume after the budget resets.`],execution_failed:[`检查失败,请检查模型凭据和服务连接,再点“现在检查”。`,`Check failed. Verify model credentials and connectivity, then check again.`],invalid_model_result:[`模型返回的格式不符合这项关注的要求,结果未发布;请重试或更换模型。`,`The model returned an unsupported result for this monitor. Nothing was published; retry or choose another model.`],empty_input:[`请先填写安排和约束。`,`Provide arrangements and constraints first.`],source_changed:[`来源已变化,旧草稿未发布;可重新检查。`,`Source changed. The stale draft was withheld; check again.`],execution_aborted:[`检查已中断,可在服务恢复后重新检查。`,`Check interrupted. Retry after the service resumes.`]},t[17]=y):y=t[17];let b=y,x=[e.next_schedule_at,e.next_deadline_check_at,e.retry_at].filter(se),S=e.source_reason??e.last_reason;l=`space-y-2 rounded-xl border border-edge p-4 text-sm text-fg-muted`,u=(0,K.jsxs)(`p`,{children:[r?`最近发起检查`:`Last check started`,`: `,e.last_check_at==null?r?`尚未检查`:`Not checked yet`:v(e.last_check_at)]});let C=r?`下次定时检查`:`Next scheduled check`,w=e.status!==`active`||a.data?.checksPaused?r?`当前不会自动检查`:`Automatic checks inactive`:x.length?`${Math.min(...x)<=Date.now()?r?`等待执行,原定 `:`Pending, scheduled for `:``}${v(Math.min(...x))}`:r?`暂无待执行检查`:`No check scheduled`;t[18]!==C||t[19]!==w?(f=(0,K.jsxs)(`p`,{children:[C,`: `,w]}),t[18]=C,t[19]=w,t[20]=f):f=t[20],p=e.deadline_at!=null&&(0,K.jsxs)(`p`,{children:[r?`邮件跟进截止时间`:`Mail follow-up deadline`,`: `,v(e.deadline_at)]}),m=e.source_reason&&e.source_attempt_at!=null&&(0,K.jsxs)(`p`,{children:[r?`最近尝试读取邮件`:`Last mail read attempt`,`: `,v(e.source_attempt_at),` · `,r?`连续失败`:`Consecutive failures`,`: `,e.source_failures]}),h=e.source_reason&&(0,K.jsx)(d,{to:`/capabilities/connectors`,className:`inline-block text-accent underline`,children:r?`检查连接授权`:`Check connection access`}),g=e.source_success_at!=null&&(0,K.jsxs)(`p`,{children:[r?`最近成功读取邮件`:`Last successful mail read`,`: `,v(e.source_success_at)]}),_=S&&b[S]&&(0,K.jsx)(`p`,{role:`status`,children:b[S][+!r]});let T=r?`当前关注使用的模型`:`Current monitor model`,E=a.data.currentModel??(r?`配置不可用`:`Configuration unavailable`);t[21]!==T||t[22]!==E?(o=(0,K.jsxs)(`p`,{children:[T,`: `,E]}),t[21]=T,t[22]=E,t[23]=o):o=t[23],s=e.source_reason&&e.status===`active`&&!a.data?.checksPaused&&e.source_retry_at!=null&&(0,K.jsxs)(`p`,{children:[r?`来源重试时间`:`Source retry`,`: `,v(e.source_retry_at)]})}t[1]=n,t[2]=a.data,t[3]=r,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let v=r?`所有智能关注待检查`:`Pending checks across monitors`,y;t[24]!==a.data.pendingChecks||t[25]!==v?(y=(0,K.jsxs)(`p`,{children:[v,`: `,a.data.pendingChecks]}),t[24]=a.data.pendingChecks,t[25]=v,t[26]=y):y=t[26];let b=r?`最近 7 天所有智能关注的模型用量`:`Model usage across monitors in the last 7 days`,x=a.data.lastSevenDays.modelCalls,S=r?`次调用`:`calls`,C=a.data.lastSevenDays.tokens,w=r?`估算费用`:`estimated cost`,T;t[27]===a.data.lastSevenDays.estimatedCost?T=t[28]:(T=a.data.lastSevenDays.estimatedCost.toFixed(4),t[27]=a.data.lastSevenDays.estimatedCost,t[28]=T);let E;t[29]!==a.data.lastSevenDays.modelCalls||t[30]!==a.data.lastSevenDays.tokens||t[31]!==b||t[32]!==S||t[33]!==w||t[34]!==T?(E=(0,K.jsxs)(`p`,{children:[b,`: `,x,` `,S,` · `,C,` tokens · `,w,` $`,T]}),t[29]=a.data.lastSevenDays.modelCalls,t[30]=a.data.lastSevenDays.tokens,t[31]=b,t[32]=S,t[33]=w,t[34]=T,t[35]=E):E=t[35];let D;return t[36]!==o||t[37]!==s||t[38]!==y||t[39]!==l||t[40]!==E||t[41]!==u||t[42]!==f||t[43]!==p||t[44]!==m||t[45]!==h||t[46]!==g||t[47]!==_?(D=(0,K.jsxs)(`section`,{className:l,children:[u,f,p,m,h,g,_,o,s,y,E]}),t[36]=o,t[37]=s,t[38]=y,t[39]=l,t[40]=E,t[41]=u,t[42]=f,t[43]=p,t[44]=m,t[45]=h,t[46]=g,t[47]=_,t[48]=D):D=t[48],D}function se(e){return e!=null}function q(e){let t=(0,H.c)(13),{dirty:n,zh:r}=e,i;t[0]===n?i=t[1]:(i=e=>{n&&(e.preventDefault(),e.returnValue=``)},t[0]=n,t[1]=i),a(i);let o=l(n),s=o.state===`blocked`,c=r?`放弃未保存的更改?`:`Discard unsaved changes?`,u=r?`当前内容尚未保存,现在离开将丢失这些更改。`:`Your changes have not been saved. Leaving now will discard them.`,d=r?`放弃并离开`:`Discard and leave`,f=r?`继续编辑`:`Keep editing`,p,m;t[2]===o?(p=t[3],m=t[4]):(p=()=>{o.state===`blocked`&&o.proceed()},m=()=>{o.state===`blocked`&&o.reset()},t[2]=o,t[3]=p,t[4]=m);let h;return t[5]!==s||t[6]!==c||t[7]!==u||t[8]!==d||t[9]!==f||t[10]!==p||t[11]!==m?(h=(0,K.jsx)(I,{open:s,title:c,description:u,confirmLabel:d,cancelLabel:f,destructive:!0,overlayClassName:`z-[100]`,contentClassName:`z-[101]`,onConfirm:p,onCancel:m}),t[5]=s,t[6]=c,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h):h=t[12],h}function ce({zh:e}){let[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(),[s,c]=(0,V.useState)(!1);async function l(){n(!0),o(void 0),c(!1);try{if(await Notification.requestPermission()!==`granted`){c(!0);return}let{publicKey:t}=await W(`/browser/prepare`,`POST`);await navigator.serviceWorker.register(`/notification-sw.js`);let n=await navigator.serviceWorker.ready,r=Uint8Array.from(atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0)),a=await n.pushManager.getSubscription(),o=a?.options.applicationServerKey;a&&(!o||!new Uint8Array(o).every((e,t)=>e===r[t])||o.byteLength!==r.byteLength)&&(await a.unsubscribe(),a=null),a??=await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:r}),await W(`/browser/subscriptions`,`POST`,{...a.toJSON(),expirationTime:a.expirationTime,language:e?`zh`:`en`}),i(!0)}catch(e){o(e)}finally{n(!1)}}let u=te()&&`PushManager`in window;return(0,K.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-3`,children:[(0,K.jsx)(j,{disabled:t||!u,onClick:()=>void l(),children:r?e?`刷新此浏览器提醒订阅`:`Refresh this browser subscription`:e?`开启页面关闭后的浏览器提醒`:`Enable reminders when this page is closed`}),r&&(0,K.jsx)(`p`,{role:`status`,children:e?`此浏览器已订阅。服务需持续运行;送达取决于浏览器和系统权限。`:`Subscribed. The Gateway must remain running; delivery depends on browser and system permissions.`}),(!u||s)&&(0,K.jsx)(`p`,{className:`text-fg-muted`,children:e?`当前环境或通知权限不支持后台提醒。成果仍会保留在智能关注收件箱;可在支持推送的 HTTPS 浏览器中开启。`:`Background reminders are unavailable here. Results remain in your monitor inbox. Use a push-capable HTTPS browser and allow notifications.`}),a!=null&&(0,K.jsx)(`p`,{role:`alert`,className:`text-danger`,children:G(a,e)})]})}function le(e){let t=(0,H.c)(23),{zh:n,open:r,onOpenChange:i,onCloseAutoFocus:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,K.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[0]=o):o=t[0];let s;t[1]===a?s=t[2]:(s=e=>{e.preventDefault(),a()},t[1]=a,t[2]=s);let c=n?`检查与提醒设置`:`Checks and reminders`,l;t[3]===c?l=t[4]:(l=(0,K.jsx)(E,{className:`text-base font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u=n?`适用于所有智能关注,设置更改后自动保存。`:`Applies to all monitors. Changes are saved automatically.`,d;t[5]===u?d=t[6]:(d=(0,K.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:u}),t[5]=u,t[6]=d);let f;t[7]!==l||t[8]!==d?(f=(0,K.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-4 sm:px-6`,children:[l,d]}),t[7]=l,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n?p=t[11]:(p=(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 sm:p-6`,children:(0,K.jsx)(ue,{zh:n})}),t[10]=n,t[11]=p);let m=n?`关闭`:`Close`,h;t[12]===m?h=t[13]:(h=(0,K.jsx)(`div`,{className:`flex shrink-0 justify-end border-t border-edge p-4 sm:px-6`,children:(0,K.jsx)(C,{asChild:!0,children:(0,K.jsx)(j,{type:`button`,variant:`secondary`,children:m})})}),t[12]=m,t[13]=h);let g;t[14]!==h||t[15]!==s||t[16]!==f||t[17]!==p?(g=(0,K.jsxs)(w,{children:[o,(0,K.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(40rem,calc(100dvh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,onCloseAutoFocus:s,children:[f,p,h]})]}),t[14]=h,t[15]=s,t[16]=f,t[17]=p,t[18]=g):g=t[18];let _;return t[19]!==i||t[20]!==r||t[21]!==g?(_=(0,K.jsx)(D,{open:r,onOpenChange:i,children:g}),t[19]=i,t[20]=r,t[21]=g,t[22]=_):_=t[22],_}function ue({zh:e}){let t=k(`/preferences`,U),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)();async function o(e,i=t.data?.revision){if(!t.data||n||i===void 0)return!1;r(!0),a(void 0);try{let n=await W(`/preferences`,`PATCH`,{...e,expectedRevision:i});return await t.mutate(n,!1),!0}catch(e){return a(e),await t.mutate(),!1}finally{r(!1)}}if(!t.data)return t.error?(0,K.jsx)(`p`,{role:`alert`,children:G(t.error,e)}):(0,K.jsx)(M,{className:`h-32 w-full`});let s=t.data,c=`w-24 rounded-md border border-edge bg-surface-panel px-2 py-1 text-fg`;return(0,K.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,K.jsx)(`p`,{className:`text-fg-muted`,children:e?`设备休眠或服务关闭时不会检查;服务恢复后继续。草稿不会自动发送。`:`Checks require the device and Gateway to stay running. Drafts are never sent automatically.`}),[[`checksPaused`,e?`暂停所有检查`:`Pause all checks`],[`notificationsMuted`,e?`静音提醒(继续检查并保留成果)`:`Mute reminders (continue checks and keep results)`],[`suppressWhileViewing`,e?`查看成果时不重复提醒`:`Avoid reminders while viewing a result`],[`digestEnabled`,e?`汇总为每日摘要`:`Use a daily digest`]].map(([e,t])=>(0,K.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:s[e],disabled:n,onChange:t=>void o({[e]:t.target.checked})}),t]},e)),(0,K.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[e?`时区`:`Timezone`,(0,K.jsx)(de,{value:s.timezone,revision:s.revision,disabled:n,className:`${c} w-48`,zh:e,onSave:(e,t)=>o({timezone:String(e)},t)})]}),[[`quietStartHour`,e?`免打扰开始(小时)`:`Quiet hours start`,23],[`quietEndHour`,e?`免打扰结束(小时)`:`Quiet hours end`,23],[`dailyNotificationLimit`,e?`每日提醒上限`:`Daily reminder limit`,30],...s.digestEnabled?[[`digestHour`,e?`摘要时间(小时)`:`Digest hour`,23],[`digestMinute`,e?`摘要时间(分钟)`:`Digest minute`,59]]:[]].map(([t,r,i])=>(0,K.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[r,(0,K.jsx)(de,{value:s[t],revision:s.revision,max:i,disabled:n,className:c,zh:e,onSave:(e,n)=>o({[t]:Number(e)},n)})]},t)),(0,K.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,disabled:n,checked:s.preferredChannel===`browser`,onChange:e=>void o({preferredChannel:e.target.checked?`browser`:`in_app`})}),e?`允许浏览器后台提醒`:`Allow background browser reminders`]}),(0,K.jsx)(ce,{zh:e}),i!=null&&(0,K.jsx)(`p`,{role:`alert`,className:`text-danger`,children:G(i,e)}),s.checksPausedUntil&&(0,K.jsx)(j,{disabled:n,onClick:()=>void o({checksPausedUntil:null}),children:e?`取消定时暂停`:`Clear timed pause`})]})}function de(e){let t=(0,H.c)(26),{value:n,revision:r,max:i,disabled:a,className:o,zh:s,onSave:c}=e,[l,u]=(0,V.useState)(null),d;t[0]!==l||t[1]!==i||t[2]!==c||t[3]!==n?(d=async()=>{if(!l||l.value===String(n))return;let e=i===void 0?l.value:Number(l.value);!l.value||typeof e==`number`&&(!Number.isInteger(e)||e<0||e>i)||await c(e,l.revision)&&u(null)},t[0]=l,t[1]=i,t[2]=c,t[3]=n,t[4]=d):d=t[4];let f=d,p=i===void 0?`text`:`number`,m=i===void 0?void 0:0,h=l?.value??n,g;t[5]===r?g=t[6]:(g=e=>u(t=>({value:e.target.value,revision:t?.revision??r})),t[5]=r,t[6]=g);let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{e.key===`Escape`&&u(null)},t[7]=_):_=t[7];let v;t[8]===f?v=t[9]:(v=e=>{e.relatedTarget instanceof HTMLElement&&e.relatedTarget.hasAttribute(`data-discard-preference`)||f()},t[8]=f,t[9]=v);let y;t[10]!==o||t[11]!==a||t[12]!==i||t[13]!==p||t[14]!==m||t[15]!==h||t[16]!==g||t[17]!==v?(y=(0,K.jsx)(`input`,{type:p,min:m,max:i,value:h,disabled:a,className:o,onChange:g,onKeyDown:_,onBlur:v}),t[10]=o,t[11]=a,t[12]=i,t[13]=p,t[14]=m,t[15]=h,t[16]=g,t[17]=v,t[18]=y):y=t[18];let b;t[19]!==a||t[20]!==l||t[21]!==s?(b=l&&(0,K.jsx)(j,{"data-discard-preference":!0,type:`button`,variant:`ghost`,disabled:a,onPointerDown:fe,onClick:()=>u(null),children:s?`放弃修改`:`Discard edits`}),t[19]=a,t[20]=l,t[21]=s,t[22]=b):b=t[22];let x;return t[23]!==y||t[24]!==b?(x=(0,K.jsxs)(K.Fragment,{children:[y,b]}),t[23]=y,t[24]=b,t[25]=x):x=t[25],x}function fe(e){return e.preventDefault()}function J({item:e,zh:t,onChange:n}){let r=(0,V.useRef)(null);(0,V.useEffect)(()=>{let t=crypto.randomUUID(),n=!1,i=()=>{W(`/presence`,`POST`,{clientId:t,surface:`web`,presentationId:e.id,visible:n&&document.visibilityState===`visible`&&document.hasFocus()}).catch(()=>void 0)},a=new IntersectionObserver(([e])=>{n=e.isIntersecting,i()},{threshold:.5});r.current&&a.observe(r.current);let o=setInterval(i,2e4);return document.addEventListener(`visibilitychange`,i),window.addEventListener(`focus`,i),window.addEventListener(`blur`,i),()=>{a.disconnect(),clearInterval(o),document.removeEventListener(`visibilitychange`,i),window.removeEventListener(`focus`,i),window.removeEventListener(`blur`,i),n=!1,i()}},[e.id]);let[i,a]=(0,V.useState)(!1),o=`/presentations/${encodeURIComponent(e.id)}`,s=k(e.readOnly?null:`${o}/feedback`,U),{mutate:c}=O(),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(),p=async e=>{if(s.data){u(!0),f(void 0);try{let t=s.data.feedback?.note??``,n=await W(`${o}/feedback`,`POST`,{expectedRevision:s.data.feedback?.revision??0,rating:e});await s.mutate({feedback:{rating:e,note:t,revision:n.revision}},{revalidate:!1}),c(`/metrics`)}catch(e){f(e),s.mutate()}finally{u(!1)}}},m=async()=>{u(!0),f(void 0);try{await W(o,`PATCH`,{read:e.status!==`read`}),n()}catch(e){f(e)}finally{u(!1)}};return(0,K.jsxs)(`article`,{ref:r,className:`space-y-3 rounded-xl border border-edge bg-surface-panel p-4 sm:p-6`,children:[e.createdAt!=null&&(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[t?`生成于`:`Generated`,` `,new Date(e.createdAt).toLocaleString(t?`zh-CN`:`en`)]}),e.sourceHealth?.reason&&(0,K.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t?`邮件来源暂不可用,这份成果尚未核实最新邮件,请检查连接授权后重试。`:`Mail is unavailable. This result has not been checked against the latest messages. Check connection access and retry.`}),(0,K.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-fg`,children:e.content.summary}),(0,K.jsx)(j,{variant:`ghost`,onClick:()=>{navigator.clipboard.writeText(e.content.summary).then(()=>a(!0)).catch(f)},children:i?t?`已复制`:`Copied`:t?`复制成果`:`Copy result`}),(0,K.jsx)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:e.sources?.length?e.sources.map(e=>(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`a`,{className:`text-accent underline`,href:e.href,target:e.kind===`mail`?`_blank`:void 0,rel:`noreferrer`,children:e.kind===`notes`?t?`查看关注资料`:`View monitor notes`:e.title||(t?`查看原邮件`:`View original email`)}),e.sender&&` · ${e.sender}`]},e.href)):(0,K.jsx)(`p`,{children:t?`来源详情暂不可用`:`Source details unavailable`})}),e.readOnly?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`这份成果已结束、过期或延后,仅供查阅。`:`This result is resolved, expired or snoozed, and is available for reference.`}):(0,K.jsxs)(K.Fragment,{children:[s.error?(0,K.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[G(s.error,t),(0,K.jsx)(j,{onClick:()=>void s.mutate(),children:t?`重新加载`:`Reload`})]}):s.data?(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`useful`,`not_useful`].map(e=>(0,K.jsx)(j,{disabled:l,"aria-pressed":s.data?.feedback?.rating===e,onClick:()=>void p(e),children:e===`useful`?t?`对我有帮助`:`Helpful`:t?`没有帮助`:`Not helpful`},e))}):(0,K.jsx)(M,{className:`h-11 w-48`}),(0,K.jsx)(j,{disabled:l,variant:`ghost`,onClick:()=>void m(),children:e.status===`read`?t?`标为未读`:`Mark unread`:t?`标为已读`:`Mark read`})]}),!!d&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:G(d,t)})]})}var pe=`min-h-11 w-full rounded-md border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`;function me({activation:e,zh:t,onDirty:n,onChanged:r}){let i=`/activations/${e.id}/schedules`,a=k(i,U),o=k(`/templates/${e.templateKey}/versions/${e.templateVersion}`,U),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(),d=()=>{a.mutate(),o.mutate()};if(a.error||o.error)return(0,K.jsxs)(`div`,{role:`alert`,children:[(0,K.jsx)(`p`,{children:G(a.error??o.error,t)}),(0,K.jsx)(j,{onClick:d,children:t?`重新加载`:`Reload`})]});if(!a.data||!o.data)return(0,K.jsx)(M,{className:`h-32 w-full`});let f=o.data.template.triggers.find(e=>e.type===`schedule`);if(!f)return null;let p=a.data.schedules.find(e=>e.triggerKey===f.id);return(0,K.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4 sm:p-6`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`检查时间`:`Review schedule`}),p?(0,K.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.status===`active`?t?`下次检查:`:`Next check: `:t?`当前不会定时检查。已保存时间:`:`Not scheduling while inactive. Saved time: `,new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`,timeZone:p.schedule.timeZone}).format(p.nextDueAt),` · `,p.schedule.timeZone]}):(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`尚未设置定时检查。只有你点“现在检查”才会执行周期复盘。`:`No recurring schedule yet. Use Check now for a manual review.`}),!!l&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:G(l,t)}),s?(0,K.jsx)(he,{initial:s.cursor,zh:t,onCancel:()=>{c(null),n(!1)},onSave:async e=>{u(void 0);try{await W(`${i}/${encodeURIComponent(f.id)}`,`PATCH`,{expectedRevision:s.cursor?.revision??0,schedule:e}),c(null),n(!1),await a.mutate(),r?.()}catch(e){throw u(e),e}}}):(0,K.jsx)(j,{disabled:e.status!==`active`,onClick:()=>{u(void 0),c({cursor:p}),n(!0)},children:p?t?`修改时间`:`Edit schedule`:t?`设置时间`:`Set schedule`}),(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?`没有值得关注的新变化时保持安静。暂停关注会停止定时检查。`:`Stays quiet when there is no useful change. Pause the monitor to stop scheduled checks.`})]})}function he({initial:e,zh:t,onSave:n,onCancel:r}){let[i,a]=(0,V.useState)(e?.schedule.weekdays??[0]),[o,s]=(0,V.useState)(`${String(e?.schedule.hour??18).padStart(2,`0`)}:${String(e?.schedule.minute??0).padStart(2,`0`)}`),[c,l]=(0,V.useState)(e?.schedule.timeZone??Intl.DateTimeFormat().resolvedOptions().timeZone),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(!1),m=async e=>{e.preventDefault();try{new Intl.DateTimeFormat(`en`,{timeZone:c})}catch{p(!0);return}if(!i.length||!/^\d{2}:\d{2}$/.test(o)){p(!0);return}p(!1),d(!0);try{let[e,t]=o.split(`:`).map(Number);await n({weekdays:i,hour:e,minute:t,timeZone:c})}catch{}finally{d(!1)}};return(0,K.jsx)(`form`,{onSubmit:e=>void m(e),children:(0,K.jsxs)(`fieldset`,{disabled:u,className:`space-y-4`,children:[(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{className:`mb-2 text-sm font-medium text-fg`,children:t?`每周检查日`:`Days of the week`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(t?[`周日`,`周一`,`周二`,`周三`,`周四`,`周五`,`周六`]:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`]).map((e,t)=>(0,K.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 rounded-md border border-edge px-3 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.includes(t),onChange:e=>a(n=>e.target.checked?[...n,t].sort():n.filter(e=>e!==t))}),e]},t))})]}),(0,K.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`当地时间`:`Local time`,(0,K.jsx)(`input`,{type:`time`,required:!0,value:o,onChange:e=>s(e.target.value),className:pe})]}),(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`时区(例如 Asia/Shanghai)`:`Time zone (for example Asia/Shanghai)`,(0,K.jsx)(`input`,{required:!0,maxLength:100,value:c,onChange:e=>l(e.target.value),className:pe,spellCheck:!1})]})]}),f&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`请选择至少一天,并填写有效时间和时区。`:`Choose at least one day and enter a valid time and time zone.`}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(j,{type:`submit`,disabled:u,children:u?t?`正在保存…`:`Saving…`:t?`保存时间`:`Save schedule`}),(0,K.jsx)(j,{type:`button`,onClick:r,children:t?`取消`:`Cancel`})]})]})})}function ge({value:e,disabled:t,zh:n,onChange:r}){let i=k(`/sources/mail/accounts`,U),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)([]),[f,p]=(0,V.useState)(!1),[m,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(),y=a||i.data?.accounts[0]?.id||``;async function b(){p(!0),v(void 0),u([]),g(!0),r({id:``,accountId:``,subject:``,sender:``});try{u((await W(`/sources/mail/search`,`POST`,{accountId:y,query:s})).sources)}catch(e){v(e)}finally{p(!1)}}if(i.error)return(0,K.jsxs)(`div`,{role:`alert`,className:`space-y-2 text-sm text-danger`,children:[(0,K.jsx)(`p`,{children:G(i.error,n)}),(0,K.jsx)(j,{onClick:()=>void i.mutate(),children:n?`重新加载`:`Reload`})]});if(!i.data)return(0,K.jsx)(M,{className:`h-24 w-full`});let x=e=>`${e.subject||(n?`无主题邮件`:`Untitled mail`)} · ${e.sender||e.accountId}`;return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`搜索会读取所选 Gmail 账号的匹配邮件;开启后只持续跟进选定线程,不发送邮件,也不需要开启后台学习。`:`Search reads matching mail in your selected Gmail account. The monitor follows only the selected thread, never sends mail, and requires no background learning.`}),(0,K.jsx)(h,{value:y,disabled:t||f,ariaLabel:n?`邮箱账号`:`Mail account`,placeholder:n?`选择账号`:`Choose account`,allowEmpty:!1,options:i.data.accounts.map(e=>({value:e.id,label:e.label})),onChange:e=>{o(e),u([]),r({id:``,accountId:``,subject:``,sender:``})}}),(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[n?`主题、发件人或 Gmail 搜索条件`:`Subject, sender, or Gmail query`,(0,K.jsx)(`input`,{value:s,maxLength:500,disabled:t||f,onChange:e=>c(e.target.value),className:`rounded-md border border-edge bg-surface-panel px-3 py-2`,placeholder:n?`例如 from:alice@example.com`:`e.g. from:alice@example.com`})]}),(0,K.jsx)(j,{type:`button`,disabled:t||f||!y||!s.trim(),onClick:()=>void b(),children:f?n?`正在搜索…`:`Searching…`:n?`搜索邮件`:`Search mail`}),(0,K.jsx)(h,{value:e,disabled:t||f,ariaLabel:n?`要跟进的邮件`:`Mail to follow`,placeholder:n?`选择邮件线程`:`Choose a thread`,allowEmpty:!1,options:l.map(e=>({value:e.id,label:x(e)})),onChange:e=>{let t=l.find(t=>t.id===e);t&&r(t)}}),!i.data.accounts.length&&(0,K.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[n?`请连接 Gmail,并允许读取及后台检查;要求每次确认或仅限指定 Agent 的账号暂不支持。`:`Connect Gmail and allow background reads. Accounts requiring confirmation for every read or restricted to specific agents are not supported yet.`,` `,(0,K.jsx)(d,{className:`text-accent underline`,to:`/capabilities/connectors`,children:n?`管理连接`:`Manage connections`})]}),m&&!f&&!_&&!l.length&&(0,K.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:n?`没有找到匹配线程,请调整搜索条件。`:`No matching threads. Try a different query.`}),_!=null&&(0,K.jsx)(`p`,{role:`alert`,className:`text-danger`,children:G(_,n)})]})}function _e({activation:e,zh:t,onDirty:n,onChanged:r}){let i=`/activations/${e.id}/work-items`,a=k(i,U),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(),[u,d]=(0,V.useState)(!1),f=()=>{s(null),n(!1),a.mutate(),r()};if(a.error)return(0,K.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[G(a.error,t),(0,K.jsx)(j,{onClick:()=>void a.mutate(),children:t?`重新加载`:`Reload`})]});if(!a.data)return(0,K.jsx)(M,{className:`h-32 w-full`});let p=a.data.workItems[0],m=async e=>{if(p){d(!0),l(void 0);try{await W(`/work-items/${p.id}`,`PATCH`,{expectedRevision:p.revision,status:e}),f()}catch(e){l(e)}finally{d(!1)}}};return(0,K.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4 sm:p-6`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`这封邮件的跟进时间`:`Follow-up deadline`}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p?`${p.status===`watching`?t?`留意回复,到时检查`:`Watching replies; check at deadline`:p.status===`paused`?t?`已暂停跟进`:`Follow-up paused`:t?`已结束跟进`:`Follow-up ended`} · ${new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}).format(p.dueAt)}`:t?`设置一个时间;此前有新回复时会重新判断是否还需要跟进。`:`Choose a deadline. New replies before then trigger a review of whether follow-up is still needed.`}),!!c&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:G(c,t)}),o?(0,K.jsx)(ve,{initial:o.item?.dueAt,zh:t,onCancel:()=>{s(null),n(!1)},onSave:async t=>{l(void 0);try{o.item?await W(`/work-items/${o.item.id}`,`PATCH`,{expectedRevision:o.item.revision,dueAt:t,status:`watching`}):e.scope.kind===`objects`&&await W(i,`POST`,{subjectId:e.scope.ids[0],accountId:e.permissions.accountIds[0],dueAt:t}),f()}catch(e){throw l(e),e}}}):(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[p?.status!==`completed`&&(0,K.jsx)(j,{disabled:u||e.status!==`active`,onClick:()=>{s({item:p}),n(!0),l(void 0)},children:p?t?`重新设置跟进时间`:`Reschedule follow-up`:t?`设置跟进时间`:`Set deadline`}),p?.status===`watching`&&(0,K.jsx)(j,{disabled:u,onClick:()=>void m(`paused`),children:t?`暂停这次跟进`:`Pause follow-up`}),p&&p.status!==`completed`&&(0,K.jsx)(j,{disabled:u,onClick:()=>void m(`completed`),children:t?`结束这次跟进`:`End follow-up`})]}),(0,K.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?`结束跟进只停止检查,不表示邮件已发送或事情已经解决。`:`Ending stops checks; it does not mean a message was sent or the matter resolved.`})]})}function ve({initial:e,zh:t,onSave:n,onCancel:r}){let[i,a]=(0,V.useState)(()=>{if(!e)return``;let t=new Date(e);return new Date(e-t.getTimezoneOffset()*6e4).toISOString().slice(0,16)}),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(!1),u=async e=>{e.preventDefault();let t=new Date(i).getTime();if(!Number.isFinite(t)||t<=Date.now()){l(!0);return}l(!1),s(!0);try{await n(t)}catch{}finally{s(!1)}};return(0,K.jsx)(`form`,{onSubmit:e=>void u(e),children:(0,K.jsxs)(`fieldset`,{disabled:o,className:`space-y-3`,children:[(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`跟进时间(当前设备时区)`:`Deadline (device time zone)`,(0,K.jsx)(`input`,{required:!0,type:`datetime-local`,value:i,onChange:e=>a(e.target.value),className:`min-h-11 w-full min-w-0 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),c&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`请选择未来的有效时间。`:`Choose a valid future time.`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(j,{type:`submit`,disabled:o,children:o?t?`正在保存…`:`Saving…`:t?`保存跟进时间`:`Save deadline`}),(0,K.jsx)(j,{type:`button`,onClick:r,children:t?`取消`:`Cancel`})]})]})})}var ye=e(n(),1),Y=`min-h-11 w-full rounded-md border border-edge bg-surface-panel px-3 py-2 text-base text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,X=`min-w-0 space-y-4 rounded-xl border border-edge bg-surface-panel p-4`;function be(e,t,n){return e===`none`?[]:[`workspace.read`,...t?[`workspace.write`]:[],...e===`worktree`&&n.trim()?[`verification.run`]:[]]}function xe(){let e=y(e=>e.language)===`zh`,t=(t,n)=>e?t:n,n=s(),r=k(`/source-providers`,U),[i,a]=(0,V.useState)(``),o=i||r.data?.providers[0]?.id||``,c=k(o?`/source-providers/${encodeURIComponent(o)}/accounts`:null,U),l=k(`follow-up-projects`,()=>ne({limit:100})),[u,f]=(0,V.useState)(``),[h,g]=(0,V.useState)(``),[_,v]=(0,V.useState)(``),[b,x]=(0,V.useState)(``),[S,C]=(0,V.useState)(``),[w,T]=(0,V.useState)(`none`),[E,D]=(0,V.useState)(!1),[O,A]=(0,V.useState)(``),[N,P]=(0,V.useState)(!1),[F,I]=(0,V.useState)(``),[ee,te]=(0,V.useState)(!1),L=(0,V.useRef)(null),R=l.data?.items.filter(e=>e.workspaceRoot)??[],z=u||(c.data?.accounts.length===1?c.data.accounts[0].id:``),B=h||(R.length===1?R[0].id:``);async function re(r){if(r.preventDefault(),!N){P(!0),I(``);try{let{source:e}=await W(`/source-providers/${encodeURIComponent(o)}/resolve-link`,`POST`,{accountId:z,url:_}),r={source:e,sourceUrl:_,goal:b,instruction:S,resource:w,...w===`worktree`?{projectId:B}:{},capabilities:be(w,E,O),...w===`worktree`&&O.trim()?{verificationCommand:O.trim()}:{}},i=await W(`/task-follow-ups/preflight`,`POST`,r);if(!i.ready){let e={verification_backend:t(`可选验证需要配置隔离后端;也可清空验证命令,先生成修改。`,`Optional verification needs an isolation backend. Clear the command to proceed without running tests.`),verification_backend_unavailable:t(`验证后端不可用;检查配置或清空验证命令。`,`Verification backend unavailable. Check settings or clear the command.`),clean_base_checkout:t(`项目基础工作区有未提交改动,请先整理。`,`The project base checkout has uncommitted changes.`),source_read_permission:t(`来源读取权限不足,请检查连接。`,`Source read permission is missing. Check the connection.`),model_credentials:t(`请配置模型凭据。`,`Configure model credentials.`),model_configuration:t(`请选择可用模型。`,`Choose an available model.`)};I(i.missing.map(t=>e[t]??t).join(` `));return}let a=await W(`/task-follow-ups`,`POST`,r);(0,ye.flushSync)(()=>te(!0)),n(`/scenes/${a.activation.id}`,{replace:!0})}catch(t){I(G(t,e))}finally{P(!1),setTimeout(()=>L.current?.focus(),0)}}}return r.error||c.error||l.error?(0,K.jsx)(`p`,{role:`alert`,children:G(r.error??c.error??l.error,e)}):!r.data||!l.data||o&&!c.data?(0,K.jsxs)(`div`,{"aria-busy":`true`,children:[(0,K.jsx)(M,{className:`h-12`}),(0,K.jsx)(M,{className:`mt-4 h-32`})]}):(0,K.jsxs)(`form`,{className:`space-y-5`,onSubmit:re,children:[(0,K.jsx)(q,{dirty:!ee&&!!(_||b||S),zh:e}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:t(`持续推进一件事`,`Keep work moving`)}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`选定来源,告诉 AI 要完成什么。后续变化自动进入同一任务;仅在需要判断或遇到阻塞时提醒你。`,`Choose a source and describe the outcome. Updates stay with one task; attention is requested for decisions or blockers.`)}),(0,K.jsxs)(`fieldset`,{disabled:N,className:`space-y-5`,children:[(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[t(`来源`,`Source`),(0,K.jsx)(p,{"aria-label":t(`来源`,`Source`),value:o,onChange:e=>{a(e.target.value),f(``)},required:!0,children:r.data.providers.map(e=>(0,K.jsx)(m,{value:e.id,children:e.label},e.id))})]}),!c.data?.accounts.length&&(0,K.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`请先连接可读取的账号。`,`Connect an account with read access first.`),` `,(0,K.jsx)(d,{className:`text-accent-fg`,to:`/capabilities/connectors`,children:t(`连接`,`Connections`)})]}),(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[t(`账号`,`Account`),(0,K.jsxs)(p,{"aria-label":t(`账号`,`Account`),value:z,onChange:e=>f(e.target.value),required:!0,children:[(0,K.jsx)(m,{value:``,children:t(`选择账号`,`Choose an account`)}),c.data?.accounts.map(e=>(0,K.jsx)(m,{value:e.id,children:e.label},e.id))]})]}),(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[t(`来源链接`,`Source link`),(0,K.jsx)(`input`,{className:Y,type:`url`,required:!0,maxLength:2e3,value:_,onChange:e=>v(e.target.value)})]}),(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[t(`你希望完成什么?`,`What should be accomplished?`),(0,K.jsx)(`textarea`,{className:Y,required:!0,maxLength:6e3,rows:3,value:b,onChange:e=>x(e.target.value)})]}),(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[t(`处理指令(可选)`,`Instructions (optional)`),(0,K.jsx)(`textarea`,{className:Y,rows:3,maxLength:12e3,value:S,onChange:e=>C(e.target.value),placeholder:t(`例如:持续更新决策记录;有冲突时向我确认。`,`For example: keep a decision log updated; ask me about conflicts.`)})]}),(0,K.jsxs)(`section`,{className:X,children:[(0,K.jsx)(`h3`,{className:`font-medium text-fg`,children:t(`资源与权限`,`Resources and permissions`)}),(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[t(`工作资源`,`Workspace resource`),(0,K.jsxs)(p,{"aria-label":t(`工作资源`,`Workspace resource`),value:w,onChange:e=>{T(e.target.value),A(``),D(!1)},children:[(0,K.jsx)(m,{value:`none`,children:t(`无文件资源 · 分析与建议`,`No files · analysis and recommendations`)}),(0,K.jsx)(m,{value:`artifacts`,children:t(`任务产物目录 · 文档等文件`,`Task artifact folder · documents and files`)}),(0,K.jsx)(m,{value:`worktree`,children:t(`Git worktree · 项目修改`,`Git worktree · project changes`)})]})]}),w===`worktree`&&(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[t(`项目`,`Project`),(0,K.jsxs)(p,{"aria-label":t(`项目`,`Project`),required:!0,value:B,onChange:e=>g(e.target.value),children:[(0,K.jsx)(m,{value:``,children:t(`选择本地 Git 项目`,`Choose a local Git project`)}),R.map(e=>(0,K.jsx)(m,{value:e.id,children:e.name},e.id))]})]}),w!==`none`&&(0,K.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm text-fg`,children:[(0,K.jsx)(`input`,{className:`ui-checkbox`,type:`checkbox`,checked:E,onChange:e=>D(e.target.checked)}),t(`允许创建和修改此任务工作区内的文件`,`Allow creating and editing files in this task workspace`)]}),w===`worktree`&&(0,K.jsxs)(`details`,{className:`space-y-3`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg`,children:t(`可选:授权运行验证命令`,`Optional: authorize a verification command`)}),(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[t(`固定验证命令(留空则不执行命令)`,`Fixed verification command (blank means no commands)`),(0,K.jsx)(`input`,{className:Y,maxLength:2e3,value:O,onChange:e=>A(e.target.value),placeholder:`pnpm test`})]}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`仅此可选工具需要已配置的隔离后端。留空也能修改文件,但结果会标记未验证。不会自动改为宿主机执行。`,`Only this optional tool needs a configured isolation backend. File edits work without it and remain unverified. No automatic host execution.`)}),(0,K.jsx)(d,{to:`/settings/agent-defaults`,className:`text-sm text-accent-fg`,children:t(`查看执行设置`,`Execution settings`)})]}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`不会提交、推送、部署或对外发消息。约每分钟检查一次,Gateway 需要保持在线。`,`No commits, pushes, deployment or outgoing messages. Checks about once a minute while the Gateway is online.`)})]}),F&&(0,K.jsx)(`p`,{ref:L,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:F}),(0,K.jsx)(j,{variant:`primary`,type:`submit`,disabled:N||!z||w===`worktree`&&!B,children:N?t(`正在检查并开启…`,`Checking and starting…`):t(`确认范围并开始跟进`,`Confirm scope and start following`)})]})]})}function Se({id:e}){let[t,n]=(0,V.useState)(!1),r=y(e=>e.language)===`zh`,i=(e,t)=>r?e:t,a=`/task-follow-ups/${encodeURIComponent(e)}`,o=k(a,U,{refreshInterval:5e3}),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(``);async function f(e){c(!0),u(``);try{await W(a,`PATCH`,{expectedRevision:o.data.activation.revision,status:e}),await o.mutate()}catch(e){u(G(e,r))}finally{c(!1)}}if(o.error)return(0,K.jsx)(`p`,{role:`alert`,children:G(o.error,r)});if(!o.data)return(0,K.jsx)(`div`,{"aria-busy":`true`,children:(0,K.jsx)(M,{className:`h-48`})});let p=o.data,m=p.processedRevision>0&&p.processedRevision===p.observedRevision;return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:p.activation.goal}),(0,K.jsx)(ae,{resource:{kind:`scene`,id:p.activation.id,revision:String(p.activation.revision)},disabled:s||t}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,role:`status`,children:p.activation.status===`archived`?i(`已停止跟进,任务与产物已保留`,`Stopped following; task and artifacts retained`):p.lastError||p.activation.status===`needs_setup`||p.receipt?.needsUser?i(`需要你处理`,`Needs your attention`):p.activation.status===`paused`?i(`已暂停`,`Paused`):p.run?.status===`running`?i(`正在处理`,`Working`):m?i(`已处理当前来源版本,继续观察变化`,`Current source revision processed; watching for updates`):i(`正在跟进`,`Following updates`)}),(0,K.jsxs)(`section`,{className:X,children:[(0,K.jsx)(`h3`,{className:`font-medium text-fg`,children:i(`来源 → 任务 → 产物`,`Source → task → artifacts`)}),(0,K.jsx)(`p`,{className:`break-words text-sm text-fg-muted`,children:p.input.source.provider}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,K.jsx)(d,{className:`text-sm text-accent-fg`,to:`/tasks/${p.task.id}`,children:i(`打开关联任务`,`Open linked task`)}),p.input.sourceUrl&&(0,K.jsx)(`a`,{className:`text-sm text-accent-fg`,href:p.input.sourceUrl,target:`_blank`,rel:`noopener noreferrer`,children:i(`打开原讨论`,`Open source`)})]}),(0,K.jsxs)(`dl`,{className:`grid grid-cols-1 gap-3 text-sm sm:grid-cols-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-fg-muted`,children:i(`已观察版本`,`Observed revision`)}),(0,K.jsx)(`dd`,{children:p.observedRevision})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-fg-muted`,children:i(`已交付版本`,`Delivered revision`)}),(0,K.jsx)(`dd`,{children:p.deliveredRevision})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-fg-muted`,children:i(`已处理版本`,`Processed revision`)}),(0,K.jsx)(`dd`,{children:p.processedRevision||`—`})]})]}),(p.environment||p.artifactPath)&&(0,K.jsxs)(`div`,{className:`space-y-2 break-all text-sm text-fg-muted`,children:[p.environment?.branchRef&&(0,K.jsxs)(`p`,{children:[i(`任务分支:`,`Task branch: `),p.environment.branchRef]}),(0,K.jsxs)(`p`,{children:[i(`产物位置:`,`Artifact location: `),p.environment?.rootPath??p.artifactPath]})]}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i(`已处理不代表通过验收。验证状态以工具证据为准。`,`Processed does not mean accepted. Verification status comes from tool evidence.`)})]}),p.lastError&&(0,K.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:p.lastError}),p.receipt&&(0,K.jsxs)(`section`,{className:X,children:[(0,K.jsx)(`h3`,{className:`font-medium text-fg`,children:i(`最近结果`,`Latest result`)}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p.receipt.verification.status===`passed`?i(`已授权命令通过;仍需审阅业务结果`,`Approved command passed; review the outcome`):i(`未验证:没有当前版本的通过证据`,`Unverified: no passing evidence for the current revision`)}),(0,K.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-fg`,children:p.receipt.summary}),p.receipt.remainingWork.map((e,t)=>(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e},t)),(0,K.jsxs)(`details`,{children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg`,children:i(`产物与验证证据`,`Artifacts and verification evidence`)}),[...p.receipt.changes,...p.receipt.evidence].map((e,t)=>(0,K.jsxs)(`pre`,{className:`mt-3 max-h-64 overflow-y-auto whitespace-pre-wrap break-words text-xs text-fg-muted`,children:[e.title,`
2
- `,e.summary]},t))]})]}),p.input.resource===`worktree`&&p.input.projectId&&(0,K.jsx)(we,{projectId:p.input.projectId,taskId:p.task.id}),p.activation.status===`paused`&&(0,K.jsx)(Ce,{item:p,onSaved:()=>o.mutate(),onDirty:n},p.activation.id),l&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:l}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:p.activation.status!==`archived`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(j,{variant:`secondary`,disabled:s,onClick:()=>void f(p.activation.status===`active`?`paused`:`active`),children:s?i(`处理中…`,`Working…`):p.activation.status===`active`?i(`暂停跟进与执行`,`Pause observation and execution`):i(`确认后恢复`,`Resume after review`)}),(0,K.jsx)(j,{variant:`ghost`,disabled:s,onClick:()=>void f(`archived`),children:i(`停止跟进(保留产物)`,`Stop following (keep artifacts)`)})]})})]})}function Ce({item:e,onSaved:t,onDirty:n}){let r=y(e=>e.language)===`zh`,i=(e,t)=>r?e:t,[a,o]=(0,V.useState)(null),s=a??{base:e,instruction:e.input.instruction,writable:e.input.capabilities.includes(`workspace.write`),command:e.input.verificationCommand??``},{instruction:c,writable:l,command:u}=s,d=e=>o(t=>({...t??s,...e})),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(``),g=c!==e.input.instruction||l!==e.input.capabilities.includes(`workspace.write`)||u!==(e.input.verificationCommand??``);(0,V.useEffect)(()=>(n(g||f),()=>n(!1)),[g,f,n]);async function _(n){n.preventDefault(),p(!0),h(``);try{let n=s.base;await W(`/task-follow-ups/${e.activation.id}`,`PATCH`,{expectedRevision:n.activation.revision,configuration:{...n.input,instruction:c,capabilities:be(n.input.resource,l,u),verificationCommand:u.trim()||void 0}}),await t(),o(null)}catch(e){h(G(e,r))}finally{p(!1)}}return(0,K.jsxs)(`details`,{className:X,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg`,children:i(`调整指令与授权`,`Edit instructions and permissions`)}),(0,K.jsx)(q,{dirty:g,zh:r}),(0,K.jsxs)(`form`,{className:`space-y-3`,onSubmit:_,children:[(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i(`处理指令`,`Instructions`),(0,K.jsx)(`textarea`,{disabled:f,className:Y,rows:4,maxLength:12e3,value:c,onChange:e=>d({instruction:e.target.value})})]}),s.base.input.resource!==`none`&&(0,K.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm text-fg`,children:[(0,K.jsx)(`input`,{disabled:f,type:`checkbox`,className:`ui-checkbox`,checked:l,onChange:e=>d({writable:e.target.checked})}),i(`允许修改任务工作区文件`,`Allow task workspace file edits`)]}),s.base.input.resource===`worktree`&&(0,K.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i(`验证命令(可选;留空不执行)`,`Verification command (optional; blank disables execution)`),(0,K.jsx)(`input`,{disabled:f,className:Y,maxLength:2e3,value:u,onChange:e=>d({command:e.target.value})})]}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i(`保存后仍保持暂停。确认授权范围后再恢复。`,`Saving keeps the monitor paused. Review permissions before resuming.`)}),m&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:m}),(0,K.jsx)(j,{type:`submit`,disabled:f||!g,children:f?i(`正在保存…`,`Saving…`):i(`保存指令与授权`,`Save instructions and permissions`)}),a&&(0,K.jsx)(j,{type:`button`,variant:`ghost`,disabled:f,onClick:()=>{o(null),h(``)},children:i(`放弃修改`,`Discard edits`)})]})]})}function we({projectId:e,taskId:t}){let n=y(e=>e.language)===`zh`,[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(``),f=k(r?`/task-follow-ups/projects/${encodeURIComponent(e)}/branches`:null,U),h=f.data?.branches.find(e=>e.ref===a);async function g(){if(h){c(!0),u(``);try{await W(`/task-follow-ups/branch-links`,`POST`,{projectId:e,taskId:t,branchRef:h.ref,expectedSha:h.sha}),await f.mutate()}catch(e){u(G(e,n))}finally{c(!1)}}}return(0,K.jsxs)(`details`,{className:X,open:r,onToggle:e=>i(e.currentTarget.open),children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg`,children:n?`已有分支与需求关联`:`Existing branches and requirements`}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`只读盘点。确认关联仅记录归属,不接管该分支,也不修改、重命名或清理代码。`:`Read-only inventory. Confirming records ownership only: no takeover, edits, renaming or cleanup.`}),f.error?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:G(f.error,n)}):f.data?(0,K.jsxs)(K.Fragment,{children:[f.data.checkoutDirty&&(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`基础工作区存在未提交改动,已保留。`:`The base checkout has uncommitted changes; they are preserved.`}),(0,K.jsxs)(p,{"aria-label":n?`选择已有分支`:`Choose an existing branch`,value:a,onChange:e=>o(e.target.value),children:[(0,K.jsx)(m,{value:``,children:n?`选择分支查看归属`:`Choose a branch to inspect`}),f.data.branches.map(e=>(0,K.jsx)(m,{value:e.ref,children:e.ref.replace(`refs/heads/`,``)},e.ref))]}),h&&(0,K.jsxs)(`div`,{className:`space-y-3 break-all text-sm text-fg`,children:[(0,K.jsx)(`p`,{children:h.subject}),(0,K.jsx)(`p`,{className:`text-fg-muted`,children:h.sha}),h.worktree&&(0,K.jsx)(`p`,{className:`text-fg-muted`,children:h.worktree}),h.taskId?(0,K.jsx)(d,{className:`text-accent-fg`,to:h.activationId?`/scenes/${h.activationId}`:`/tasks/${h.taskId}`,children:n?`查看对应事项`:`Open associated work`}):(0,K.jsx)(j,{variant:`secondary`,disabled:s,onClick:()=>void g(),children:s?n?`关联中…`:`Linking…`:n?`确认关联到当前任务`:`Confirm association with this task`}),h.changedSinceConfirmation&&(0,K.jsx)(`p`,{className:`text-fg-muted`,children:n?`该分支在确认关联后已有新提交。`:`This branch has new commits since confirmation.`})]})]}):(0,K.jsx)(M,{className:`h-24`}),l&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:l})]})}function Te(){let{mutate:e}=O();(0,V.useEffect)(()=>{let t=0,n,r,i=()=>{r===void 0&&(r=setTimeout(()=>{r=void 0,e(()=>!0)},50))},a=re(e=>{e.kind===`scene`&&i()}),o=async()=>{let o=++t;n?.(),n=void 0;try{let{capabilities:s}=await _(b(`/api/capabilities/operations`));if(o!==t)return;if(!s.some(e=>e.id===`xopc.scenes.list`)){r!==void 0&&clearTimeout(r),r=void 0,e(()=>!0,void 0,{revalidate:!0});return}n=L(`resources:scenes`,{onEvent:e=>{e.event===`resource.changed`&&a(e.topic,e.data)},onGap:i},0),i()}catch{}},s=()=>{o()};return window.addEventListener(`gateway-realtime-connected`,s),o(),()=>{t++,n?.(),r!==void 0&&clearTimeout(r),window.removeEventListener(`gateway-realtime-connected`,s)}},[e])}var Ee=`min-h-11 w-full rounded-md border border-edge bg-surface-panel px-3 py-2 text-base text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,Z=`min-w-0 rounded-xl border border-edge bg-surface-panel p-4 sm:p-6`,De=`grid gap-2 text-sm font-medium text-fg`;function Oe(e,t){return{needs_setup:[`待完成设置`,`Finish setup`],active:[`已开启`,`Active`],paused:[`已暂停`,`Paused`],completed:[`已完成`,`Completed`],archived:[`已归档`,`Archived`],running:[`正在检查`,`Checking`],succeeded:[`已准备成果`,`Result ready`],skipped:[`无需新行动`,`No new action`],retry_wait:[`等待来源或预算`,`Waiting for source or budget`],failed:[`检查失败`,`Check failed`],cancelled:[`已取消`,`Cancelled`]}[e]?.[+!t]??e}function Q(){let e=(0,H.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,K.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,K.jsx)(M,{className:`h-8 w-48`}),(0,K.jsx)(M,{className:`h-40 w-full`}),(0,K.jsx)(M,{className:`h-32 w-full`})]}),e[0]=t):t=e[0],t}function $(e){let t=(0,H.c)(24),{error:n,retry:r}=e,i=y(ke)===`zh`;if(n?.status===503){let e=i?`智能关注尚未开放`:`Monitors are not available yet`,r;t[0]===e?r=t[1]:(r=(0,K.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:e}),t[0]=e,t[1]=r);let a;t[2]!==n||t[3]!==i?(a=G(n,i),t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===a?o=t[6]:(o=(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}),t[5]=a,t[6]=o);let s=i?`返回对话`:`Back to chat`,c;t[7]===s?c=t[8]:(c=(0,K.jsx)(j,{asChild:!0,children:(0,K.jsx)(d,{to:`/chat`,children:s})}),t[7]=s,t[8]=c);let l;return t[9]!==r||t[10]!==o||t[11]!==c?(l=(0,K.jsxs)(`section`,{className:`${Z} space-y-3`,children:[r,o,c]}),t[9]=r,t[10]=o,t[11]=c,t[12]=l):l=t[12],l}let a;t[13]!==n||t[14]!==i?(a=G(n,i),t[13]=n,t[14]=i,t[15]=a):a=t[15];let o;t[16]===a?o=t[17]:(o=(0,K.jsx)(`p`,{className:`text-sm text-danger`,children:a}),t[16]=a,t[17]=o);let s;t[18]!==r||t[19]!==i?(s=r&&(0,K.jsxs)(j,{onClick:r,children:[(0,K.jsx)(R,{size:16,"aria-hidden":`true`}),i?`重新加载`:`Reload`]}),t[18]=r,t[19]=i,t[20]=s):s=t[20];let c;return t[21]!==o||t[22]!==s?(c=(0,K.jsxs)(`div`,{role:`alert`,className:`space-y-3 rounded-xl border border-edge p-4`,children:[o,s]}),t[21]=o,t[22]=s,t[23]=c):c=t[23],c}function ke(e){return e.language}function Ae(){let e=(0,H.c)(5),t=v(Ne);if(v(Me)){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,K.jsx)($,{error:{status:401}}),e[0]=t):t=e[0],t}let n=t??`anonymous`,r,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r={provider:je},i=(0,K.jsx)(Pe,{}),e[1]=r,e[2]=i):(r=e[1],i=e[2]);let a;return e[3]===n?a=e[4]:(a=(0,K.jsx)(A,{value:r,children:i},n),e[3]=n,e[4]=a),a}function je(){return new Map}function Me(e){return e.tokenExpired}function Ne(e){return e.conversationId}function Pe(){let e=(0,H.c)(20);Te();let{activationId:t,templateKey:n}=u(),r=o(`/scenes/inbox`),i=y(Le)===`zh`,[a,s]=(0,V.useState)(!1),l=(0,V.useRef)(null),p=f(),[m]=c(),h=t&&p.state?.fromSceneInbox===!0?`/scenes/inbox${typeof p.state.inboxSearch==`string`?p.state.inboxSearch:``}`:void 0,g=F(Ie),_=F(Fe),v,b;e[0]!==_||e[1]!==g||e[2]!==i?(v=()=>{let e=i?`把需要持续留意的事交给 AI,把时间留给自己。`:`Let AI look after recurring needs, leaving more time for you.`,t=i?`查看全部成果`:`View all results`,n=i?`检查与提醒设置`:`Checks and reminders`;return g({startExtra:null,main:(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:i?`智能关注`:`Monitors`}),(0,K.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,title:e,children:e})]}),end:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(j,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,K.jsxs)(d,{"data-scene-inbox":!0,to:`/scenes/inbox`,"aria-label":t,title:t,children:[(0,K.jsx)(z,{className:`size-4`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}),(0,K.jsx)(j,{ref:l,type:`button`,variant:`ghost`,className:`size-9 p-0`,"aria-label":n,title:n,"aria-haspopup":`dialog`,onClick:()=>s(!0),children:(0,K.jsx)(B,{className:`size-4`,"aria-hidden":`true`})})]})}),()=>_()},b=[_,g,i],e[0]=_,e[1]=g,e[2]=i,e[3]=v,e[4]=b):(v=e[3],b=e[4]),(0,V.useLayoutEffect)(v,b);let x;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,K.jsx)(`main`,{className:`h-full overflow-y-auto bg-surface-panel`,children:(0,K.jsx)(`div`,{className:`mx-auto w-full max-w-7xl space-y-6 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:(0,K.jsx)(ze,{})})}),e[5]=x):x=e[5];let S;e[6]!==t||e[7]!==r||e[8]!==h||e[9]!==m||e[10]!==n||e[11]!==i?(S=(t||n||r)&&(0,K.jsx)(Re,{titleText:r?m.has(`digest`)?i?`摘要中的成果`:`Results in this digest`:i?`关注成果`:`Monitor results`:t?i?`关注详情`:`Monitor details`:i?`了解并开启`:`Explore and start`,closeLabel:r?i?`关闭关注成果`:`Close monitor results`:t?i?`关闭关注详情`:`Close monitor details`:i?`关闭关注设置`:`Close monitor setup`,backTo:h,backLabel:i?`返回成果`:`Back to results`,restoreSelector:r?`[data-scene-inbox]`:t?`[data-scene-id="${CSS.escape(t)}"]`:`[data-scene-template="${CSS.escape(n)}"]`,children:r?(0,K.jsx)(He,{}):t?(0,K.jsx)(Ke,{id:t}):(0,K.jsx)(We,{templateKey:n})},t??n??`inbox`),e[6]=t,e[7]=r,e[8]=h,e[9]=m,e[10]=n,e[11]=i,e[12]=S):S=e[12];let C;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>l.current?.focus(),e[13]=C):C=e[13];let w;e[14]!==a||e[15]!==i?(w=(0,K.jsx)(le,{zh:i,open:a,onOpenChange:s,onCloseAutoFocus:C}),e[14]=a,e[15]=i,e[16]=w):w=e[16];let T;return e[17]!==S||e[18]!==w?(T=(0,K.jsxs)(K.Fragment,{children:[x,S,w]}),e[17]=S,e[18]=w,e[19]=T):T=e[19],T}function Fe(e){return e.clearPageHeader}function Ie(e){return e.setPageHeader}function Le(e){return e.language}function Re(e){let t=(0,H.c)(29),{titleText:n,closeLabel:r,restoreSelector:i,backTo:a,backLabel:o,children:c}=e,l=s(),u=(0,V.useRef)(null),f;t[0]===l?f=t[1]:(f=()=>l(`/scenes`,{replace:!0}),t[0]=l,t[1]=f);let p=f,m;t[2]===p?m=t[3]:(m=e=>{e||p()},t[2]=p,t[3]=m);let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,K.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[4]=h):h=t[4];let _;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{e.preventDefault(),u.current?.focus()},t[5]=_):_=t[5];let v;t[6]===i?v=t[7]:(v=e=>{e.preventDefault(),document.querySelector(i)?.focus()},t[6]=i,t[7]=v);let y;t[8]!==o||t[9]!==a?(y=a&&(0,K.jsx)(j,{asChild:!0,variant:`ghost`,className:`size-9 shrink-0 p-0`,children:(0,K.jsx)(d,{to:a,replace:!0,"aria-label":o,title:o,children:(0,K.jsx)(P,{size:18,"aria-hidden":`true`})})}),t[8]=o,t[9]=a,t[10]=y):y=t[10];let b;t[11]===n?b=t[12]:(b=(0,K.jsx)(E,{ref:u,tabIndex:-1,className:`min-w-0 flex-1 text-base font-semibold text-fg outline-none`,children:n}),t[11]=n,t[12]=b);let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,K.jsx)(g,{size:18,"aria-hidden":`true`}),t[13]=S):S=t[13];let O;t[14]===r?O=t[15]:(O=(0,K.jsx)(C,{asChild:!0,children:(0,K.jsx)(j,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":r,title:r,children:S})}),t[14]=r,t[15]=O);let k;t[16]!==y||t[17]!==b||t[18]!==O?(k=(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3 sm:px-6`,children:[y,b,O]}),t[16]=y,t[17]=b,t[18]=O,t[19]=k):k=t[19];let A;t[20]===c?A=t[21]:(A=(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 sm:p-6`,children:(0,K.jsx)(`div`,{className:`space-y-6`,children:c})}),t[20]=c,t[21]=A);let M;t[22]!==k||t[23]!==A||t[24]!==v?(M=(0,K.jsxs)(w,{children:[h,(0,K.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(52rem,calc(100dvh-2rem))] w-[min(52rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,"aria-describedby":void 0,onOpenAutoFocus:_,onCloseAutoFocus:v,children:[k,A]})]}),t[22]=k,t[23]=A,t[24]=v,t[25]=M):M=t[25];let N;return t[26]!==M||t[27]!==m?(N=(0,K.jsx)(D,{open:!0,onOpenChange:m,children:M}),t[26]=M,t[27]=m,t[28]=N):N=t[28],N}function ze(){let e=(0,H.c)(48),{activationId:t}=u(),n=y(Be)===`zh`,[r,i]=c(),a;e[0]===r?a=e[1]:(a=r.get(`after`)??``,e[0]=r,e[1]=a);let o=a,s=k(`/templates`,U),l=k(`/activations?limit=20&afterId=${encodeURIComponent(o)}`,U),f=l.mutate,p,m;if(e[2]!==t||e[3]!==f?(p=()=>{t||f()},m=[t,f],e[2]=t,e[3]=f,e[4]=p,e[5]=m):(p=e[4],m=e[5]),(0,V.useEffect)(p,m),s.error||l.error){let t=s.error??l.error,n;e[6]!==l||e[7]!==s?(n=()=>{s.mutate(),l.mutate()},e[6]=l,e[7]=s,e[8]=n):n=e[8];let r;return e[9]!==t||e[10]!==n?(r=(0,K.jsx)($,{error:t,retry:n}),e[9]=t,e[10]=n,e[11]=r):r=e[11],r}if(!s.data||!l.data){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,K.jsx)(Q,{}),e[12]=t):t=e[12],t}let h=n?`你想先轻松一点的事`:`Where could you use a little help?`,g;e[13]===h?g=e[14]:(g=(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:h}),e[13]=h,e[14]=g);let _;if(e[15]!==s.data.templates||e[16]!==n){let t;e[18]===n?t=e[19]:(t=e=>(0,K.jsxs)(`article`,{className:`${Z} space-y-3`,children:[(0,K.jsx)(ee,{className:`text-fg-muted`,size:20,"aria-hidden":`true`}),(0,K.jsx)(`h3`,{className:`text-balance font-medium text-fg`,children:e.title}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.description}),(0,K.jsx)(j,{asChild:!0,children:(0,K.jsx)(d,{"data-scene-template":e.key,to:`/scenes/new/${encodeURIComponent(e.key)}?version=${encodeURIComponent(e.version)}`,children:n?`了解并开启`:`Explore and start`})})]},`${e.key}:${e.version}`),e[18]=n,e[19]=t),_=s.data.templates.map(t),e[15]=s.data.templates,e[16]=n,e[17]=_}else _=e[17];let v;e[20]===_?v=e[21]:(v=(0,K.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:_}),e[20]=_,e[21]=v);let b;e[22]!==g||e[23]!==v?(b=(0,K.jsxs)(`section`,{className:`space-y-3`,children:[g,v]}),e[22]=g,e[23]=v,e[24]=b):b=e[24];let x=n?`我的关注`:`My monitors`,S;e[25]===x?S=e[26]:(S=(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:x}),e[25]=x,e[26]=S);let C;e[27]!==l.data.activations||e[28]!==n?(C=l.data.activations.length?l.data.activations.map(e=>(0,K.jsxs)(d,{to:`/scenes/${e.id}`,"data-scene-id":e.id,className:`${Z} block space-y-2 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,K.jsx)(`p`,{className:`break-words font-medium text-fg`,children:e.goal}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Oe(e.status===`active`&&e.setupMissing?.length?`needs_setup`:e.status,n)})]},e.id)):(0,K.jsxs)(`div`,{className:`${Z} space-y-2`,children:[(0,K.jsx)(ie,{"aria-hidden":`true`,className:`text-fg-muted`}),(0,K.jsx)(`p`,{className:`text-fg`,children:n?`还没有开启智能关注`:`No monitors yet`}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`从上面选择一件你希望 AI 帮忙照看的事。`:`Choose something above that you would like AI to monitor.`})]}),e[27]=l.data.activations,e[28]=n,e[29]=C):C=e[29];let w;e[30]!==o||e[31]!==i||e[32]!==n?(w=o&&(0,K.jsx)(j,{onClick:()=>i({}),children:n?`返回第一页`:`First page`}),e[30]=o,e[31]=i,e[32]=n,e[33]=w):w=e[33];let T;e[34]!==l.data.nextCursor||e[35]!==i||e[36]!==n?(T=l.data.nextCursor&&(0,K.jsx)(j,{onClick:()=>i({after:l.data.nextCursor}),children:n?`下一页`:`Next page`}),e[34]=l.data.nextCursor,e[35]=i,e[36]=n,e[37]=T):T=e[37];let E;e[38]!==w||e[39]!==T?(E=(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[w,T]}),e[38]=w,e[39]=T,e[40]=E):E=e[40];let D;e[41]!==C||e[42]!==E||e[43]!==S?(D=(0,K.jsxs)(`section`,{className:`space-y-3`,children:[S,C,E]}),e[41]=C,e[42]=E,e[43]=S,e[44]=D):D=e[44];let O;return e[45]!==D||e[46]!==b?(O=(0,K.jsxs)(K.Fragment,{children:[b,D]}),e[45]=D,e[46]=b,e[47]=O):O=e[47],O}function Be(e){return e.language}function Ve(e){let t=(0,H.c)(20),{zh:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={refreshInterval:15e3,shouldRetryOnError:!1},t[0]=r):r=t[0];let i=k(`/metrics`,U,r),a;t[1]===n?a=t[2]:(a=n?[`有帮助的成果`,`没有帮助的成果`,`带来帮助的关注`]:[`Helpful results`,`Unhelpful results`,`Monitors that helped`],t[1]=n,t[2]=a);let o=a,s,c,l,u;if(t[3]!==o||t[4]!==i||t[5]!==n){let e=i.data?[i.data.usefulOutcomes,i.data.unhelpfulOutcomes,i.data.scenesWithUsefulOutcomes]:[],r=new Intl.NumberFormat(n?`zh-CN`:`en`);s=`${Z} space-y-3`,c=n?`反馈概览`:`Feedback overview`;let a=n?`最近 7 天的反馈`:`Feedback in the last 7 days`;t[10]===a?l=t[11]:(l=(0,K.jsx)(`h2`,{className:`text-balance text-base font-semibold text-fg`,children:a}),t[10]=a,t[11]=l),u=i.error?(0,K.jsxs)(`div`,{role:`alert`,className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法加载统计,仍可查看和评价成果。`:`Stats are unavailable. You can still view and rate results.`}),(0,K.jsx)(j,{disabled:i.isValidating,onClick:()=>void i.mutate(),children:n?`重新加载统计`:`Reload stats`})]}):(0,K.jsx)(`dl`,{className:`grid gap-4 sm:grid-cols-3`,"aria-busy":!i.data,children:o.map((t,n)=>(0,K.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,K.jsx)(`dt`,{className:`text-sm text-fg-muted`,children:t}),(0,K.jsx)(`dd`,{className:`text-xl font-semibold tabular-nums text-fg`,children:i.data?r.format(e[n]):(0,K.jsx)(M,{className:`h-7 w-12`})})]},t))}),t[3]=o,t[4]=i,t[5]=n,t[6]=s,t[7]=c,t[8]=l,t[9]=u}else s=t[6],c=t[7],l=t[8],u=t[9];let d=n?`按你这段时间的明确反馈统计,每份成果取最新评价。已读和检查成功不计入,也不代表已采纳或节省时间。`:`Counts your explicit feedback during this period, using the latest rating per result. Reads and successful checks do not count. This does not measure adoption or time saved.`,f;t[12]===d?f=t[13]:(f=(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d}),t[12]=d,t[13]=f);let p;return t[14]!==s||t[15]!==c||t[16]!==l||t[17]!==u||t[18]!==f?(p=(0,K.jsxs)(`section`,{className:s,"aria-label":c,children:[l,u,f]}),t[14]=s,t[15]=c,t[16]=l,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function He(){let e=(0,H.c)(42),t=y(Ue)===`zh`,[n,r]=c(),i;e[0]===n?i=e[1]:(i=n.get(`after`)??``,e[0]=n,e[1]=i);let a=i,o;e[2]===n?o=e[3]:(o=n.get(`digest`),e[2]=n,e[3]=o);let s=o,l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:15e3},e[4]=l):l=e[4];let u=k(`${s?`/digests/${encodeURIComponent(s)}`:`/outcomes`}?limit=20&afterId=${encodeURIComponent(a)}`,U,l);if(u.error){let t;e[5]===u?t=e[6]:(t=()=>void u.mutate(),e[5]=u,e[6]=t);let n;return e[7]!==u.error||e[8]!==t?(n=(0,K.jsx)($,{error:u.error,retry:t}),e[7]=u.error,e[8]=t,e[9]=n):n=e[9],n}if(!u.data){let t;return e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,K.jsx)(Q,{}),e[10]=t):t=e[10],t}let f=t?`集中查看各项智能关注准备的成果,告诉 AI 哪些对你有帮助。`:`Review results across your monitors and tell AI what helps.`,p;e[11]===f?p=e[12]:(p=(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f}),e[11]=f,e[12]=p);let m;e[13]===t?m=e[14]:(m=(0,K.jsx)(Ve,{zh:t}),e[13]=t,e[14]=m);let h=t?`成果列表`:`Results list`,g;e[15]!==s||e[16]!==n||e[17]!==u||e[18]!==t?(g=u.data.outcomes.length?u.data.outcomes.map(e=>(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(J,{item:e,zh:t,onChange:()=>void u.mutate()}),(0,K.jsx)(j,{asChild:!0,variant:`ghost`,children:(0,K.jsx)(d,{state:{fromSceneInbox:!0,inboxSearch:`?${n.toString()}`},to:`/scenes/${encodeURIComponent(e.activationId)}`,children:t?`查看所属关注`:`View monitor`})})]},e.id)):(0,K.jsxs)(`div`,{className:`${Z} space-y-3`,children:[(0,K.jsx)(z,{size:32,"aria-hidden":`true`,className:`text-fg-muted`}),(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`这里还没有成果`:`No results here yet`}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s?t?`这份摘要中的成果目前不可查看,可能已被撤回。`:`Results in this digest are currently unavailable and may have been withdrawn.`:t?`回到智能关注,提供资料并检查一次;有新成果时会出现在这里。`:`Open a monitor, provide context and run a check. New results will appear here.`})]}),e[15]=s,e[16]=n,e[17]=u,e[18]=t,e[19]=g):g=e[19];let _;e[20]!==h||e[21]!==g?(_=(0,K.jsx)(`section`,{className:`space-y-4`,"aria-label":h,children:g}),e[20]=h,e[21]=g,e[22]=_):_=e[22];let v=t?`成果分页`:`Results pages`,b;e[23]!==a||e[24]!==s||e[25]!==r||e[26]!==t?(b=a&&(0,K.jsx)(j,{onClick:()=>r(s?{digest:s}:{}),children:t?`返回第一页`:`First page`}),e[23]=a,e[24]=s,e[25]=r,e[26]=t,e[27]=b):b=e[27];let x;e[28]!==s||e[29]!==u.data.nextCursor||e[30]!==r||e[31]!==t?(x=u.data.nextCursor&&(0,K.jsx)(j,{onClick:()=>r({...s?{digest:s}:{},after:u.data.nextCursor}),children:t?`下一页`:`Next page`}),e[28]=s,e[29]=u.data.nextCursor,e[30]=r,e[31]=t,e[32]=x):x=e[32];let S;e[33]!==b||e[34]!==x||e[35]!==v?(S=(0,K.jsxs)(`nav`,{className:`flex flex-wrap gap-3`,"aria-label":v,children:[b,x]}),e[33]=b,e[34]=x,e[35]=v,e[36]=S):S=e[36];let C;return e[37]!==S||e[38]!==p||e[39]!==m||e[40]!==_?(C=(0,K.jsxs)(K.Fragment,{children:[p,m,_,S]}),e[37]=S,e[38]=p,e[39]=m,e[40]=_,e[41]=C):C=e[41],C}function Ue(e){return e.language}function We(e){let t=(0,H.c)(2),{templateKey:n}=e,r;return t[0]===n?r=t[1]:(r=n===`task-follow-up`?(0,K.jsx)(xe,{}):(0,K.jsx)(Ge,{templateKey:n}),t[0]=n,t[1]=r),r}function Ge({templateKey:e}){let t=y(e=>e.language)===`zh`,[n]=c(),r=s(),i=n.get(`version`)??`1.0.0`,a=k(`/templates/${encodeURIComponent(e)}/versions/${encodeURIComponent(i)}`,U),[o,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(``),[f,p]=(0,V.useState)(``),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(!1),[v,b]=(0,V.useState)(),[x,S]=(0,V.useState)(!1),C=(0,V.useRef)({content:``,id:``}),w=(0,V.useRef)(``),T=!!(o||f||m)&&!x;if((0,V.useEffect)(()=>{x&&r(w.current,{replace:!0})},[x,r]),a.error)return(0,K.jsx)($,{error:a.error,retry:()=>void a.mutate()});if(!a.data)return(0,K.jsx)(Q,{});let E=a.data.template,D=E.contextProviders.includes(`mail`),O=async t=>{t.preventDefault(),_(!0),b(void 0);let n={templateKey:e,templateVersion:i,goal:o,scope:D?{kind:`objects`,ids:[f.trim()]}:{kind:`personal`},permissions:{accountIds:D?[u.trim()]:[],contextProviders:E.contextProviders,effectHandlers:[]}},r=JSON.stringify(n);C.current.content!==r&&(C.current={content:r,id:crypto.randomUUID()});try{w.current=`/scenes/${(await W(`/activations`,`POST`,n,C.current.id)).activation.id}`,S(!0)}catch(e){b(e)}finally{_(!1)}};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{dirty:T,zh:t}),(0,K.jsxs)(`header`,{children:[(0,K.jsx)(`h1`,{className:`text-wrap text-xl font-semibold text-fg`,children:E.title}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:E.description})]}),(0,K.jsx)(`form`,{onSubmit:e=>void O(e),className:`${Z} space-y-5`,children:(0,K.jsxs)(`fieldset`,{disabled:g||x,className:`space-y-5`,children:[(0,K.jsxs)(`label`,{className:De,children:[t?`希望它持续帮你做好什么?`:`What should it keep helping you with?`,(0,K.jsx)(`textarea`,{required:!0,maxLength:4e3,rows:3,value:o,onChange:e=>l(e.target.value),className:Ee,autoComplete:`off`})]}),D&&(0,K.jsx)(ge,{value:f,disabled:g||x,zh:t,onChange:e=>{d(e.accountId),p(e.id),h(!1)}}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只准备草稿和建议,不发送消息、不执行外部写操作。下一步需补齐资料和检查时间;完成后才会自动检查。`:`Prepares drafts and suggestions only. No messages or external writes. Next, complete the context and timing settings for automatic checks.`}),(0,K.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm text-fg`,children:[(0,K.jsx)(`input`,{required:!0,type:`checkbox`,className:`ui-checkbox`,checked:m,onChange:e=>h(e.target.checked)}),t?`确认以上范围,允许读取我提供的资料。`:`I confirm this scope and allow reading the information I provide.`]}),!!v&&(0,K.jsx)($,{error:v}),(0,K.jsx)(j,{type:`submit`,variant:`primary`,disabled:g||x||D&&!f,children:g?t?`正在开启…`:`Starting…`:t?`继续设置`:`Continue setup`})]})})]})}function Ke(e){let t=(0,H.c)(6),{id:n}=e,r=k(`/activations/${encodeURIComponent(n)}`,U);if(r.error){let e;return t[0]===r.error?e=t[1]:(e=(0,K.jsx)($,{error:r.error}),t[0]=r.error,t[1]=e),e}if(!r.data){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Q,{}),t[2]=e):e=t[2],e}let i;return t[3]!==r.data.activation.templateKey||t[4]!==n?(i=r.data.activation.templateKey===`task-follow-up`?(0,K.jsx)(Se,{id:n}):(0,K.jsx)(qe,{id:n}),t[3]=r.data.activation.templateKey,t[4]=n,t[5]=i):i=t[5],i}function qe({id:e}){let t=y(e=>e.language)===`zh`,[n]=c(),r=n.get(`result`),i=`/activations/${encodeURIComponent(e)}`,[a,o]=(0,V.useState)(``),[s,l]=(0,V.useState)(``),u=k(i,U,{refreshInterval:15e3}),d=k(`${i}/runs?limit=20&afterId=${encodeURIComponent(a)}`,U,{refreshInterval:5e3}),f=k(`/outcomes?limit=20&activationId=${encodeURIComponent(e)}&afterId=${encodeURIComponent(s)}`,U,{refreshInterval:5e3}),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(),[_,v]=(0,V.useState)(!1),b=(0,V.useRef)(null),[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(!1),[T,E]=(0,V.useState)(!1),D=x||C||T,O=async e=>{if(u.data){m(!0),g(void 0),v(!1);try{e?(b.current??=crypto.randomUUID(),await W(`${i}/checks`,`POST`,void 0,b.current),b.current=null,v(!0),o(``),l(``)):await W(i,`PATCH`,{expectedRevision:u.data.activation.revision,status:u.data.activation.status===`active`?`paused`:`active`}),await Promise.all([u.mutate(),d.mutate(),f.mutate()])}catch(e){g(e)}finally{m(!1)}}};if(u.error)return(0,K.jsx)($,{error:u.error,retry:()=>void u.mutate()});if(!u.data)return(0,K.jsx)(Q,{});let A=u.data.activation;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{dirty:D,zh:t}),(0,K.jsxs)(`header`,{className:`space-y-3`,children:[(0,K.jsx)(`h1`,{className:`break-words text-wrap text-xl font-semibold text-fg`,children:A.goal}),(0,K.jsx)(ae,{resource:{kind:`scene`,id:A.id,revision:String(A.revision)},disabled:D||p}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Oe(A.status===`active`&&A.setupMissing?.length?`needs_setup`:A.status,t)}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只准备建议和成果,不自动发送或写入外部系统。`:`Prepares suggestions and results. Does not send or write to external systems.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,K.jsx)(j,{variant:`primary`,disabled:p||A.status!==`active`,onClick:()=>void O(!0),children:p?t?`处理中…`:`Working…`:t?`现在检查`:`Check now`}),[`active`,`paused`,`needs_setup`].includes(A.status)&&(0,K.jsxs)(j,{disabled:p,onClick:()=>void O(!1),children:[(0,K.jsx)(N,{size:16,"aria-hidden":`true`}),A.status===`active`?t?`暂停关注`:`Pause monitor`:t?`检查设置并恢复`:`Review setup and resume`]})]}),[`active`,`paused`].includes(A.status)&&(0,K.jsx)(j,{disabled:p,variant:`ghost`,onClick:()=>{m(!0),W(i,`PATCH`,{expectedRevision:A.revision,status:`completed`}).then(()=>Promise.all([u.mutate(),f.mutate(),d.mutate()])).catch(g).finally(()=>m(!1))},children:t?`结束关注(保留成果)`:`End monitor (keep results)`}),_&&(0,K.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t?`检查已排队;没有新变化时不会生成新卡片。`:`Check queued. No new card is created when nothing has changed.`})]}),h&&(0,K.jsx)($,{error:h,retry:()=>{u.mutate(),g(void 0)}}),A.status===`active`&&!!A.setupMissing?.length&&(0,K.jsxs)(`section`,{role:`status`,className:Z,children:[(0,K.jsx)(`h2`,{className:`font-medium text-fg`,children:t?`完成以下设置后,这项关注才会自动检查`:`Complete setup for automatic checks`}),(0,K.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-sm text-fg-muted`,children:A.setupMissing.map(e=>(0,K.jsx)(`li`,{children:{notes:t?`填写安排和约束`:`Provide arrangements and constraints`,schedule:t?`设置周期检查时间`:`Set a recurring review time`,deadline:t?`设置邮件跟进截止时间`:`Set a mail follow-up deadline`}[e]},e))})]}),(0,K.jsx)(oe,{activationId:e,zh:t}),[`active`,`paused`,`needs_setup`].includes(A.status)&&(0,K.jsx)(Je,{activation:A,zh:t,onDirty:E,onSaved:()=>{u.mutate(),f.mutate(),d.mutate()}},A.id),A.permissions.contextProviders.includes(`user_notes`)&&(0,K.jsx)(Xe,{path:i,zh:t,onDirty:S,onSaved:()=>{u.mutate(),f.mutate(),d.mutate()}}),A.templateKey===`mail-follow-up`?(0,K.jsx)(_e,{activation:A,zh:t,onDirty:w,onChanged:()=>{u.mutate(),f.mutate(),d.mutate()}}):(0,K.jsx)(me,{activation:A,zh:t,onDirty:w,onChanged:()=>void u.mutate()}),r&&(0,K.jsx)(Ye,{activationId:e,presentationId:r,zh:t}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`最近成果`:`Recent results`}),f.error?(0,K.jsx)($,{error:f.error,retry:()=>void f.mutate()}):f.data?f.data.outcomes.filter(t=>t.activationId===e).length===0?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`还没有新成果。提供资料后,可以先检查一次。`:`No new results yet. Provide context and try a check.`}):f.data.outcomes.map(e=>(0,K.jsx)(J,{item:e,zh:t,onChange:()=>void f.mutate()},e.id)):(0,K.jsx)(Q,{}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[s&&(0,K.jsx)(j,{onClick:()=>l(``),children:t?`最近成果`:`Latest results`}),f.data?.nextCursor&&(0,K.jsx)(j,{onClick:()=>l(f.data.nextCursor),children:t?`更早成果`:`Earlier results`})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`检查记录`:`Check history`}),d.error?(0,K.jsx)($,{error:d.error,retry:()=>void d.mutate()}):d.data?d.data.runs.length===0?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`尚未执行检查。`:`No checks yet.`}):(0,K.jsx)(`ul`,{className:`divide-y divide-edge`,children:d.data.runs.map(e=>(0,K.jsxs)(`li`,{className:`flex flex-wrap justify-between gap-2 py-3 text-sm`,children:[(0,K.jsxs)(`span`,{className:`text-fg`,children:[Oe(e.status,t),e.reason===`empty_input`?t?`:请先提供资料`:`: provide context first`:``]}),(0,K.jsx)(`time`,{className:`text-fg-muted`,dateTime:new Date(e.createdAt).toISOString(),children:new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}).format(e.createdAt)})]},e.id))}):(0,K.jsx)(Q,{}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[a&&(0,K.jsx)(j,{onClick:()=>o(``),children:t?`最近检查`:`Latest checks`}),d.data?.nextCursor&&(0,K.jsx)(j,{onClick:()=>o(d.data.nextCursor),children:t?`更早检查`:`Earlier checks`})]})]})]})}function Je(e){let t=(0,H.c)(45),{activation:n,zh:r,onDirty:i,onSaved:a}=e,[o,s]=(0,V.useState)(null),c=o?.goal??n.goal,[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(),p,m;t[0]!==n.goal||t[1]!==c||t[2]!==i?(p=()=>(i(c!==n.goal),()=>i(!1)),m=[c,n.goal,i],t[0]=n.goal,t[1]=c,t[2]=i,t[3]=p,t[4]=m):(p=t[3],m=t[4]),(0,V.useEffect)(p,m);let h=r?`修改目标`:`Edit goal`,g;t[5]===h?g=t[6]:(g=(0,K.jsx)(`summary`,{className:`cursor-pointer`,children:h}),t[5]=h,t[6]=g);let _=r?`保存后暂停检查并撤回旧建议。确认设置后恢复;邮件跟进时间需另行恢复。`:`Saving pauses checks and withdraws previous suggestions. Review settings before resuming, including mail deadlines.`,v;t[7]===_?v=t[8]:(v=(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_}),t[7]=_,t[8]=v);let y=r?`新目标`:`New goal`,b;t[9]===n?b=t[10]:(b=e=>s(t=>({base:t?.base??n,goal:e.target.value})),t[9]=n,t[10]=b);let x;t[11]!==l||t[12]!==c||t[13]!==b?(x=(0,K.jsx)(`textarea`,{disabled:l,value:c,maxLength:4e3,onChange:b,className:Ee}),t[11]=l,t[12]=c,t[13]=b,t[14]=x):x=t[14];let S;t[15]!==y||t[16]!==x?(S=(0,K.jsxs)(`label`,{className:De,children:[y,x]}),t[15]=y,t[16]=x,t[17]=S):S=t[17];let C;t[18]!==n.goal||t[19]!==l||t[20]!==c?(C=l||!c.trim()||c===n.goal,t[18]=n.goal,t[19]=l,t[20]=c,t[21]=C):C=t[21];let w;t[22]!==n||t[23]!==o?.base||t[24]!==c||t[25]!==a?(w=()=>{u(!0),f(void 0);let e=o?.base??n;W(`/activations/${n.id}`,`PATCH`,{expectedRevision:e.revision,goal:c,scope:e.scope,permissions:e.permissions}).then(()=>{s(null),a()}).catch(f).finally(()=>u(!1))},t[22]=n,t[23]=o?.base,t[24]=c,t[25]=a,t[26]=w):w=t[26];let T=r?`保存目标`:`Save goal`,E;t[27]!==C||t[28]!==w||t[29]!==T?(E=(0,K.jsx)(j,{disabled:C,onClick:w,children:T}),t[27]=C,t[28]=w,t[29]=T,t[30]=E):E=t[30];let D;t[31]!==l||t[32]!==o||t[33]!==r?(D=o&&(0,K.jsx)(j,{type:`button`,variant:`ghost`,disabled:l,onClick:()=>{s(null),f(void 0)},children:r?`放弃修改`:`Discard edits`}),t[31]=l,t[32]=o,t[33]=r,t[34]=D):D=t[34];let O;t[35]!==d||t[36]!==r?(O=d!=null&&(0,K.jsx)(`p`,{role:`alert`,className:`text-danger`,children:G(d,r)}),t[35]=d,t[36]=r,t[37]=O):O=t[37];let k;return t[38]!==S||t[39]!==E||t[40]!==D||t[41]!==O||t[42]!==g||t[43]!==v?(k=(0,K.jsxs)(`details`,{className:`${Z} space-y-3`,children:[g,v,S,E,D,O]}),t[38]=S,t[39]=E,t[40]=D,t[41]=O,t[42]=g,t[43]=v,t[44]=k):k=t[44],k}function Ye(e){let t=(0,H.c)(15),{activationId:n,presentationId:r,zh:i}=e,a=k(`/presentations/${encodeURIComponent(r)}`,U);if(a.error){let e;return t[0]===a.error?e=t[1]:(e=(0,K.jsx)($,{error:a.error}),t[0]=a.error,t[1]=e),e}if(!a.data){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Q,{}),t[2]=e):e=t[2],e}if(a.data.outcome.activationId!==n){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)($,{error:{status:404}}),t[3]=e):e=t[3],e}let o=i?`通知中的成果`:`Result from notification`,s;t[4]===o?s=t[5]:(s=(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:o}),t[4]=o,t[5]=s);let c;t[6]===a?c=t[7]:(c=()=>void a.mutate(),t[6]=a,t[7]=c);let l;t[8]!==a.data.outcome||t[9]!==c||t[10]!==i?(l=(0,K.jsx)(J,{item:a.data.outcome,zh:i,onChange:c},a.data.outcome.id),t[8]=a.data.outcome,t[9]=c,t[10]=i,t[11]=l):l=t[11];let u;return t[12]!==s||t[13]!==l?(u=(0,K.jsxs)(`section`,{className:`space-y-3`,children:[s,l]}),t[12]=s,t[13]=l,t[14]=u):u=t[14],u}function Xe({path:e,zh:t,onSaved:n,onDirty:r}){let i=k(`${e}/notes`,U,{revalidateOnFocus:!1}),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(),d=a!==null&&a.content!==i.data?.notes.content;if((0,V.useEffect)(()=>(r(d),()=>r(!1)),[d,r]),i.error)return(0,K.jsx)($,{error:i.error,retry:()=>void i.mutate()});if(!i.data)return(0,K.jsx)(Q,{});let f=async t=>{t.preventDefault(),c(!0),u(void 0);try{let{content:t,revision:r,validUntil:s}=a??i.data.notes,c=await W(`${e}/notes`,`PATCH`,{expectedRevision:r,content:t,validUntil:s});await i.mutate({notes:{content:t.trim(),revision:c.revision,validUntil:s}},{revalidate:!1}),o(null),n()}catch(e){u(e)}finally{c(!1)}};return(0,K.jsxs)(`form`,{onSubmit:e=>void f(e),className:`${Z} space-y-3`,children:[(0,K.jsxs)(`label`,{className:De,children:[t?`你愿意提供的安排和约束`:`Arrangements and constraints you choose to share`,(0,K.jsx)(`textarea`,{disabled:s,rows:5,maxLength:32e3,className:Ee,value:a?.content??i.data.notes.content,onChange:e=>o(t=>({...t??i.data.notes,content:e.target.value})),autoComplete:`off`})]}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只用于这项关注,不会因此访问其他家庭成员的数据。修改资料会撤回旧计划。`:`Used only by this monitor. Does not grant access to other family members. Editing withdraws the previous plan.`}),!!l&&(0,K.jsx)($,{error:l}),(0,K.jsx)(j,{type:`submit`,disabled:s||!d,children:s?t?`正在保存…`:`Saving…`:t?`保存资料`:`Save context`}),d&&(0,K.jsx)(j,{type:`button`,disabled:s,variant:`ghost`,onClick:()=>{o(null),u(void 0),i.mutate()},children:t?`放弃修改并重新加载`:`Discard edits and reload`})]})}export{Ae as ScenesPage};