@xopcai/xopc 0.0.247 → 0.0.249

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 (509) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/src/update-offset-store.js +17 -54
  3. package/dist/extensions/telegram/xopc.extension.json +1 -1
  4. package/dist/extensions/weixin/src/auth/accounts.js +3 -5
  5. package/dist/extensions/weixin/src/monitor/monitor.js +3 -5
  6. package/dist/extensions/weixin/src/storage/sync-buf.d.ts +3 -6
  7. package/dist/extensions/weixin/src/storage/sync-buf.js +9 -22
  8. package/dist/gateway/static/root/assets/{activity-store-BlxqErph.js → activity-store-B759R_qf.js} +1 -1
  9. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DmaFeojS.js → agent-avatar-dicebear-BUu7EnwM.js} +1 -1
  10. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C1rXNUAG.js +1 -0
  11. package/dist/gateway/static/root/assets/agents-DK9HjHO0.js +1 -0
  12. package/dist/gateway/static/root/assets/{api-BbXzyQMj.js → api-Cg0v7Lpn.js} +1 -1
  13. package/dist/gateway/static/root/assets/app-management-settings-panel-C9DkCW_d.js +1 -0
  14. package/dist/gateway/static/root/assets/appearance-settings-CFggS95Y.js +1 -0
  15. package/dist/gateway/static/root/assets/apps-page-jOvT-fzU.js +1 -0
  16. package/dist/gateway/static/root/assets/{archive-plugin-DD2SweEH.js → archive-plugin-BQrilVVv.js} +1 -1
  17. package/dist/gateway/static/root/assets/{attachment-load-BG82bNBQ.js → attachment-load-BG0BliqV.js} +1 -1
  18. package/dist/gateway/static/root/assets/{automations-page-CqBZ89He.js → automations-page-Bo4RiTkh.js} +1 -1
  19. package/dist/gateway/static/root/assets/automations-workspace-BKjKTlW8.js +6 -0
  20. package/dist/gateway/static/root/assets/{binary-plugins-B6LKm5Zv.js → binary-plugins-BCnyNU0C.js} +1 -1
  21. package/dist/gateway/static/root/assets/{block-editor-BJKvGVXd.js → block-editor-Db8DlVvg.js} +50 -50
  22. package/dist/gateway/static/root/assets/browser-settings-page-Dzq18pO1.js +8 -0
  23. package/dist/gateway/static/root/assets/{browser-workflow-inputs-BAAc151l.js → browser-workflow-inputs-C71vfl0b.js} +1 -1
  24. package/dist/gateway/static/root/assets/{browser-workflows-page-DoE4Uuns.js → browser-workflows-page-vvmSYKsO.js} +2 -2
  25. package/dist/gateway/static/root/assets/capabilities-settings-panel-DW4SBQf4.js +7 -0
  26. package/dist/gateway/static/root/assets/channels-settings-57OGuewD.js +1 -0
  27. package/dist/gateway/static/root/assets/{channels-status-swr-CCBCtLDg.js → channels-status-swr-CKyV3jY5.js} +1 -1
  28. package/dist/gateway/static/root/assets/{chat-terminal-dock-BsRWnz7M.js → chat-terminal-dock-B1Xd6OFB.js} +2 -2
  29. package/dist/gateway/static/root/assets/connectors-page-CT_I3kbR.js +2 -0
  30. package/dist/gateway/static/root/assets/{cron-expression-DdCgsH2c.js → cron-expression-D-F9vjtE.js} +1 -1
  31. package/dist/gateway/static/root/assets/{date-picker-dt37Lt8e.js → date-picker-B2OoYvic.js} +1 -1
  32. package/dist/gateway/static/root/assets/dependency-picker-BiGx9Sbj.js +1 -0
  33. package/dist/gateway/static/root/assets/{desktop-pet-Nw_Pgkk3.js → desktop-pet-BNMRqipe.js} +1 -1
  34. package/dist/gateway/static/root/assets/desktop-pet-settings-DeYbIV7A.js +1 -0
  35. package/dist/gateway/static/root/assets/{extension-debug-page-BHSst0WN.js → extension-debug-page-COyn05ub.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-page-DXbL4cQZ.js → extension-page-oH43chS2.js} +1 -1
  37. package/dist/gateway/static/root/assets/extension-settings-page-BMO59994.js +1 -0
  38. package/dist/gateway/static/root/assets/gateway-config-api-cimpViGk.js +1 -0
  39. package/dist/gateway/static/root/assets/{gateway-config-swr-826dipyU.js → gateway-config-swr-BGdHwT4e.js} +1 -1
  40. package/dist/gateway/static/root/assets/gateway-settings-BHJtnSic.js +1 -0
  41. package/dist/gateway/static/root/assets/{gateway-startup-retry-DyvcAIMm.js → gateway-startup-retry-CuaM3b4c.js} +1 -1
  42. package/dist/gateway/static/root/assets/heartbeat-settings-DNhrZHqx.js +1 -0
  43. package/dist/gateway/static/root/assets/home-page-BiHwiBnQ.js +1 -0
  44. package/dist/gateway/static/root/assets/{image-generation-api-D7cyfks6.js → image-generation-api-D7duj7Uj.js} +1 -1
  45. package/dist/gateway/static/root/assets/index-DGeGmj4k.css +2 -0
  46. package/dist/gateway/static/root/assets/index-aBs0EfQB.js +72 -0
  47. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-EY4cu-6W.js → keyboard-shortcuts-settings-D8Zw_lYd.js} +1 -1
  48. package/dist/gateway/static/root/assets/local-app-workbench-page-eBFVWmtH.js +2 -0
  49. package/dist/gateway/static/root/assets/{local-apps-page-Dh7OxX0S.js → local-apps-page-CvPDPRwb.js} +1 -1
  50. package/dist/gateway/static/root/assets/{locale-store-CBoCuIMx.js → locale-store-zEL8bkwx.js} +1 -1
  51. package/dist/gateway/static/root/assets/logs-page-ClvcWlL6.js +2 -0
  52. package/dist/gateway/static/root/assets/{management-settings-ZjiL3A-S.js → management-settings-D8moh99U.js} +1 -1
  53. package/dist/gateway/static/root/assets/{markdown-split-B4BxkTpU.js → markdown-split-D7V3j0vE.js} +1 -1
  54. package/dist/gateway/static/root/assets/{markdown-view-BXsHghJd.js → markdown-view-DGRN-8wP.js} +1 -1
  55. package/dist/gateway/static/root/assets/{media-plugins-D15XBiEo.js → media-plugins-BLaE5b1Y.js} +1 -1
  56. package/dist/gateway/static/root/assets/messages-W5P19VTF.js +11 -0
  57. package/dist/gateway/static/root/assets/mobile-pairing-wizard-DiVDuCxl.js +1 -0
  58. package/dist/gateway/static/root/assets/note-detail-panel-CEEvR-fV.js +5 -0
  59. package/dist/gateway/static/root/assets/notes-page-BLqgXNCx.js +8 -0
  60. package/dist/gateway/static/root/assets/page-tabs-BFMGjA60.js +1 -0
  61. package/dist/gateway/static/root/assets/preview-open-alternatives-DNEWZN7H.js +1 -0
  62. package/dist/gateway/static/root/assets/{product-open-page-CAJeUXeU.js → product-open-page-Co5u7asH.js} +1 -1
  63. package/dist/gateway/static/root/assets/project-detail-page-CIiFJ5tk.js +1 -0
  64. package/dist/gateway/static/root/assets/projects-page-B3UF-Pfm.js +1 -0
  65. package/dist/gateway/static/root/assets/{registry-api-BhGKnvLP.js → registry-api-Cg92zSod.js} +1 -1
  66. package/dist/gateway/static/root/assets/remote-access-hub-BUtpkJPG.js +1 -0
  67. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BhKcyEId.js → runtime-tools-settings-panel-C0ByNmlV.js} +2 -2
  68. package/dist/gateway/static/root/assets/{schema-form-L0s7RWCi.js → schema-form-Dq_VQpuY.js} +1 -1
  69. package/dist/gateway/static/root/assets/sessions-page-UgJmG-V4.js +1 -0
  70. package/dist/gateway/static/root/assets/settings-advanced-gate-DDCzpdkl.js +1 -0
  71. package/dist/gateway/static/root/assets/settings-form-section-CZu6FX4k.js +1 -0
  72. package/dist/gateway/static/root/assets/{settings-page-CTKoztlF.js → settings-page-S8ekeUZd.js} +1 -1
  73. package/dist/gateway/static/root/assets/setup-status-panel-BdVmwXMv.js +1 -0
  74. package/dist/gateway/static/root/assets/{share-preview-page-CiiLLz5A.js → share-preview-page-D2fEidbn.js} +1 -1
  75. package/dist/gateway/static/root/assets/shares-settings-BdsqnCYj.js +1 -0
  76. package/dist/gateway/static/root/assets/skill-reload-api-ghzAQKna.js +1 -0
  77. package/dist/gateway/static/root/assets/skills-page-AYiPlgZE.js +2 -0
  78. package/dist/gateway/static/root/assets/{skills-page.utils-CwRekJSJ.js → skills-page.utils-DGzl-ib-.js} +1 -1
  79. package/dist/gateway/static/root/assets/system-settings-panel-5Xd5mIiR.js +1 -0
  80. package/dist/gateway/static/root/assets/task-detail-page-BQAUaCDD.js +1 -0
  81. package/dist/gateway/static/root/assets/{theme-store-hybK3oC9.js → theme-store-ZVClZKQ0.js} +1 -1
  82. package/dist/gateway/static/root/assets/tunnel-api-CdZN1Jin.js +1 -0
  83. package/dist/gateway/static/root/assets/{use-autosave-DX5YZ3Nn.js → use-autosave-czRI0NBc.js} +1 -1
  84. package/dist/gateway/static/root/assets/user-model-page-W3GTm6nA.js +2 -0
  85. package/dist/gateway/static/root/assets/{voice-api-key-field-ocnZbAyi.js → voice-api-key-field-8YEvA3cU.js} +1 -1
  86. package/dist/gateway/static/root/assets/{voice-config-api-CBbiF1T3.js → voice-config-api-CopF64lY.js} +1 -1
  87. package/dist/gateway/static/root/assets/work-discovery-overlay-keLtqYYJ.js +1 -0
  88. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DaErGvxO.js → workflow-run-setup-panel-Dy5WgYMO.js} +2 -2
  89. package/dist/gateway/static/root/assets/workflows-page-BbAV3h7n.js +5 -0
  90. package/dist/gateway/static/root/index.html +10 -26
  91. package/dist/package.js +1 -1
  92. package/dist/src/agent/agent-instance-gateway.d.ts +2 -2
  93. package/dist/src/agent/agent-manager.d.ts +4 -4
  94. package/dist/src/agent/agent-manager.js +31 -15
  95. package/dist/src/agent/background-review/coordinator.d.ts +2 -4
  96. package/dist/src/agent/background-review/coordinator.js +5 -30
  97. package/dist/src/agent/background-review/prompts.d.ts +4 -2
  98. package/dist/src/agent/background-review/prompts.js +24 -19
  99. package/dist/src/agent/background-review/run-background-review.d.ts +6 -7
  100. package/dist/src/agent/background-review/run-background-review.js +47 -41
  101. package/dist/src/agent/background-review/settings.d.ts +0 -1
  102. package/dist/src/agent/background-review/settings.js +6 -7
  103. package/dist/src/agent/commands/command-registry.d.ts +1 -0
  104. package/dist/src/agent/commands/command-registry.js +12 -22
  105. package/dist/src/agent/context/audit.d.ts +36 -0
  106. package/dist/src/agent/context/audit.js +97 -0
  107. package/dist/src/agent/context/coordinator.d.ts +26 -0
  108. package/dist/src/agent/context/coordinator.js +72 -0
  109. package/dist/src/agent/context/execution-context.d.ts +54 -0
  110. package/dist/src/agent/context/execution-context.js +147 -0
  111. package/dist/src/agent/context/execution-scope.js +1 -1
  112. package/dist/src/agent/context/prepend.d.ts +2 -0
  113. package/dist/src/agent/context/prepend.js +28 -0
  114. package/dist/src/agent/context/project-context.d.ts +3 -3
  115. package/dist/src/agent/context/project-context.js +26 -23
  116. package/dist/src/agent/embedded/index.js +1 -1
  117. package/dist/src/agent/embedded/run-for-session.js +1 -0
  118. package/dist/src/agent/embedded/run-turn.js +22 -2
  119. package/dist/src/agent/embedded/types.d.ts +1 -25
  120. package/dist/src/agent/external-tools/composio-provider.js +87 -92
  121. package/dist/src/agent/external-tools/gateway-tools.d.ts +4 -1
  122. package/dist/src/agent/external-tools/gateway-tools.js +153 -41
  123. package/dist/src/agent/external-tools/index.js +1 -1
  124. package/dist/src/agent/external-tools/search-error.d.ts +12 -0
  125. package/dist/src/agent/external-tools/search-error.js +29 -0
  126. package/dist/src/agent/external-tools/service.d.ts +4 -0
  127. package/dist/src/agent/external-tools/service.js +22 -2
  128. package/dist/src/agent/ipc/inbox.d.ts +8 -31
  129. package/dist/src/agent/ipc/inbox.js +64 -133
  130. package/dist/src/agent/memory/compaction-policy.js +1 -1
  131. package/dist/src/agent/memory/compaction-promotion.js +45 -77
  132. package/dist/src/agent/memory/create-memory-manager.js +1 -3
  133. package/dist/src/agent/memory/index.d.ts +0 -5
  134. package/dist/src/agent/memory/index.js +2 -5
  135. package/dist/src/agent/memory/manager.d.ts +0 -16
  136. package/dist/src/agent/memory/manager.js +11 -40
  137. package/dist/src/agent/memory/memory-config.js +1 -1
  138. package/dist/src/agent/memory/runtime.d.ts +2 -2
  139. package/dist/src/agent/memory/runtime.js +9 -19
  140. package/dist/src/agent/memory/types.d.ts +1 -1
  141. package/dist/src/agent/orchestration/agent-orchestrator.js +13 -21
  142. package/dist/src/agent/prompt/sections/memory-skills.js +25 -36
  143. package/dist/src/agent/prompt/sections/tooling.js +10 -4
  144. package/dist/src/agent/prompt/service-prompt-builder.js +4 -3
  145. package/dist/src/agent/service/direct-turn-helpers.js +6 -23
  146. package/dist/src/agent/service/process-direct-one-shot.js +15 -10
  147. package/dist/src/agent/service/process-direct-streaming.js +5 -3
  148. package/dist/src/agent/service.js +4 -3
  149. package/dist/src/agent/tasks/task-judge-service.js +1 -1
  150. package/dist/src/agent/tools/clarify-tool.d.ts +1 -0
  151. package/dist/src/agent/tools/delegate-tool.js +5 -2
  152. package/dist/src/agent/tools/factory.js +36 -19
  153. package/dist/src/agent/tools/index.d.ts +3 -2
  154. package/dist/src/agent/tools/index.js +4 -3
  155. package/dist/src/agent/tools/knowledge-memory-tool.d.ts +9 -0
  156. package/dist/src/agent/tools/knowledge-memory-tool.js +129 -0
  157. package/dist/src/agent/tools/{dreaming-tool.d.ts → memory-maintenance-tool.d.ts} +2 -2
  158. package/dist/src/agent/tools/memory-maintenance-tool.js +31 -0
  159. package/dist/src/agent/tools/user-context-tool.d.ts +8 -0
  160. package/dist/src/agent/tools/user-context-tool.js +81 -0
  161. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  162. package/dist/src/agent/workflow/catalog.d.ts +1 -8
  163. package/dist/src/agent/workflow/catalog.js +44 -102
  164. package/dist/src/agent/workflow/index.d.ts +1 -1
  165. package/dist/src/agent/workflow/index.js +2 -2
  166. package/dist/src/automations/domain/types.d.ts +1 -0
  167. package/dist/src/automations/service/action-executor.js +2 -2
  168. package/dist/src/automations/service/automation-service.js +2 -2
  169. package/dist/src/channels/manager.d.ts +1 -1
  170. package/dist/src/channels/manager.js +2 -2
  171. package/dist/src/channels/outbound/persist-store.d.ts +2 -8
  172. package/dist/src/channels/outbound/persist-store.js +11 -38
  173. package/dist/src/channels/outbound-sender.d.ts +1 -1
  174. package/dist/src/channels/outbound-sender.js +2 -2
  175. package/dist/src/chat-commands/builtins/understanding.js +24 -6
  176. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  177. package/dist/src/config/schema.d.ts +68 -75
  178. package/dist/src/config/schema.js +31 -20
  179. package/dist/src/config/web-patch.d.ts +1 -1
  180. package/dist/src/connectors/composio-managed-client.js +6 -2
  181. package/dist/src/connectors/composio-triggers.d.ts +2 -2
  182. package/dist/src/connectors/composio-triggers.js +8 -15
  183. package/dist/src/connectors/connected-source-understanding.d.ts +1 -3
  184. package/dist/src/connectors/connected-source-understanding.js +86 -99
  185. package/dist/src/connectors/connection-candidates.d.ts +11 -0
  186. package/dist/src/connectors/connection-candidates.js +58 -0
  187. package/dist/src/connectors/connection-capabilities.d.ts +4 -0
  188. package/dist/src/connectors/connection-capabilities.js +37 -0
  189. package/dist/src/connectors/connection-recovery-service.d.ts +42 -0
  190. package/dist/src/connectors/connection-recovery-service.js +396 -0
  191. package/dist/src/connectors/learning-coordinator.d.ts +0 -2
  192. package/dist/src/connectors/learning-coordinator.js +6 -7
  193. package/dist/src/connectors/principal.d.ts +5 -0
  194. package/dist/src/connectors/principal.js +18 -0
  195. package/dist/src/gateway/agent-builtin-tools.d.ts +28 -10
  196. package/dist/src/gateway/agent-builtin-tools.js +30 -9
  197. package/dist/src/gateway/automation-agent-session.js +3 -0
  198. package/dist/src/gateway/chat-stream/mapper.js +1 -28
  199. package/dist/src/gateway/chat-stream/protocol.d.ts +2 -24
  200. package/dist/src/gateway/clarify-bridge.d.ts +4 -0
  201. package/dist/src/gateway/clarify-bridge.js +9 -4
  202. package/dist/src/gateway/heartbeat/service.js +1 -1
  203. package/dist/src/gateway/hono/lib/config-payload.d.ts +52 -30
  204. package/dist/src/gateway/hono/lib/config-payload.js +4 -4
  205. package/dist/src/gateway/hono/lib/extension-store.js +8 -25
  206. package/dist/src/gateway/hono/middleware/auth.js +1 -2
  207. package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +1 -1
  208. package/dist/src/gateway/hono/routes/config-patch/misc.js +72 -28
  209. package/dist/src/gateway/hono/routes/connection-waits.d.ts +3 -0
  210. package/dist/src/gateway/hono/routes/connection-waits.js +58 -0
  211. package/dist/src/gateway/hono/routes/connectors.js +4 -12
  212. package/dist/src/gateway/hono/routes/context-sources.d.ts +4 -0
  213. package/dist/src/gateway/hono/routes/context-sources.js +159 -0
  214. package/dist/src/gateway/hono/routes/index.js +4 -2
  215. package/dist/src/gateway/hono/routes/lazy-bundles.js +9 -4
  216. package/dist/src/gateway/hono/routes/notes.js +22 -7
  217. package/dist/src/gateway/hono/routes/projects.js +37 -45
  218. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +15 -1
  219. package/dist/src/gateway/hono/routes/side-chats.js +13 -2
  220. package/dist/src/gateway/hono/routes/tasks.js +2 -2
  221. package/dist/src/gateway/hono/routes/user-model.d.ts +3 -0
  222. package/dist/src/gateway/hono/routes/user-model.js +480 -0
  223. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  224. package/dist/src/gateway/memory-maintenance-automation-reconciler.d.ts +11 -0
  225. package/dist/src/gateway/memory-maintenance-automation-reconciler.js +72 -0
  226. package/dist/src/gateway/service/agent-runner.d.ts +9 -1
  227. package/dist/src/gateway/service/agent-runner.js +25 -1
  228. package/dist/src/gateway/service/config-coordinator.d.ts +2 -2
  229. package/dist/src/gateway/service/config-coordinator.js +4 -4
  230. package/dist/src/gateway/service/run-gateway-agent.d.ts +1 -0
  231. package/dist/src/gateway/service/run-gateway-agent.js +18 -14
  232. package/dist/src/gateway/service/session-input-coordinator.d.ts +3 -0
  233. package/dist/src/gateway/service/session-input-coordinator.js +12 -2
  234. package/dist/src/gateway/service.d.ts +3 -1
  235. package/dist/src/gateway/service.js +49 -19
  236. package/dist/src/gateway/side-chat/manager.d.ts +16 -3
  237. package/dist/src/gateway/side-chat/manager.js +117 -28
  238. package/dist/src/gateway/side-chat/run-service.d.ts +2 -0
  239. package/dist/src/gateway/side-chat/run-service.js +28 -5
  240. package/dist/src/gateway/side-chat/types.d.ts +9 -1
  241. package/dist/src/heartbeat/index.js +1 -1
  242. package/dist/src/knowledge/connected-knowledge-pipeline.d.ts +0 -2
  243. package/dist/src/knowledge/connected-knowledge-pipeline.js +46 -217
  244. package/dist/src/knowledge-memory/domain.d.ts +35 -0
  245. package/dist/src/knowledge-memory/index.d.ts +2 -0
  246. package/dist/src/knowledge-memory/index.js +2 -0
  247. package/dist/src/knowledge-memory/repository.d.ts +45 -0
  248. package/dist/src/knowledge-memory/repository.js +154 -0
  249. package/dist/src/memory-maintenance/index.d.ts +2 -0
  250. package/dist/src/memory-maintenance/index.js +3 -0
  251. package/dist/src/memory-maintenance/schedule.d.ts +13 -0
  252. package/dist/src/memory-maintenance/schedule.js +51 -0
  253. package/dist/src/memory-maintenance/service.d.ts +28 -0
  254. package/dist/src/memory-maintenance/service.js +216 -0
  255. package/dist/src/notes/index.d.ts +1 -1
  256. package/dist/src/notes/index.js +2 -2
  257. package/dist/src/notes/paths.d.ts +0 -3
  258. package/dist/src/notes/paths.js +1 -10
  259. package/dist/src/notes/service.d.ts +1 -1
  260. package/dist/src/notes/service.js +7 -4
  261. package/dist/src/notes/store.d.ts +0 -2
  262. package/dist/src/notes/store.js +33 -80
  263. package/dist/src/notes/types.d.ts +16 -0
  264. package/dist/src/proactive/execution/context.d.ts +2 -2
  265. package/dist/src/proactive/execution/context.js +16 -11
  266. package/dist/src/proactive/index.d.ts +1 -1
  267. package/dist/src/proactive/index.js +2 -2
  268. package/dist/src/projects/index.d.ts +1 -1
  269. package/dist/src/projects/index.js +2 -2
  270. package/dist/src/projects/knowledge-bind.d.ts +1 -0
  271. package/dist/src/projects/knowledge-bind.js +15 -0
  272. package/dist/src/projects/project-loop.d.ts +3 -3
  273. package/dist/src/projects/project-loop.js +4 -4
  274. package/dist/src/projects/project-store.js +2 -1
  275. package/dist/src/realtime/runtime.js +1 -0
  276. package/dist/src/runtime-tools/manager.js +1 -1
  277. package/dist/src/share/hosted-session-share.d.ts +1 -4
  278. package/dist/src/share/hosted-session-share.js +14 -47
  279. package/dist/src/share/share-auto.d.ts +1 -1
  280. package/dist/src/share/share-auto.js +2 -2
  281. package/dist/src/share/share-store.d.ts +2 -7
  282. package/dist/src/share/share-store.js +153 -195
  283. package/dist/src/share/share-types.d.ts +0 -4
  284. package/dist/src/share/site-share-store.d.ts +3 -8
  285. package/dist/src/share/site-share-store.js +94 -153
  286. package/dist/src/share/site-share-types.d.ts +0 -4
  287. package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +17 -0
  288. package/dist/src/storage/sqlite/collaboration-rule-repository.js +54 -0
  289. package/dist/src/storage/sqlite/connection-wait-repository.d.ts +30 -0
  290. package/dist/src/storage/sqlite/connection-wait-repository.js +338 -0
  291. package/dist/src/storage/sqlite/connection.d.ts +1 -2
  292. package/dist/src/storage/sqlite/connection.js +50 -47
  293. package/dist/src/storage/sqlite/connector-account-repository.js +1 -1
  294. package/dist/src/storage/sqlite/context-evidence-repository.d.ts +24 -0
  295. package/dist/src/storage/sqlite/context-evidence-repository.js +52 -0
  296. package/dist/src/storage/sqlite/durable-queue.d.ts +16 -0
  297. package/dist/src/storage/sqlite/durable-queue.js +52 -0
  298. package/dist/src/storage/sqlite/durable-state.d.ts +16 -0
  299. package/dist/src/storage/sqlite/durable-state.js +43 -0
  300. package/dist/src/storage/sqlite/index.d.ts +3 -5
  301. package/dist/src/storage/sqlite/index.js +4 -6
  302. package/dist/src/storage/sqlite/knowledge-repository.d.ts +0 -19
  303. package/dist/src/storage/sqlite/knowledge-repository.js +1 -90
  304. package/dist/src/storage/sqlite/migrations/146_understanding_focus_exclusions.sql +9 -0
  305. package/dist/src/storage/sqlite/migrations/147_durable_application_state.sql +39 -0
  306. package/dist/src/storage/sqlite/migrations/148_user_model_foundation.sql +554 -0
  307. package/dist/src/storage/sqlite/migrations/149_separate_source_index_from_memory.sql +18 -0
  308. package/dist/src/storage/sqlite/migrations/150_session_connection_waits.sql +47 -0
  309. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  310. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  311. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  312. package/dist/src/storage/sqlite/notes-repository.d.ts +2 -1
  313. package/dist/src/storage/sqlite/notes-repository.js +37 -3
  314. package/dist/src/storage/sqlite/schema.js +1 -1
  315. package/dist/src/storage/sqlite/session-input-repository.d.ts +14 -2
  316. package/dist/src/storage/sqlite/session-input-repository.js +16 -13
  317. package/dist/src/storage/sqlite/session-repository.js +4 -1
  318. package/dist/src/storage/sqlite/transcript-repository.js +1 -1
  319. package/dist/src/tasks/index.js +2 -2
  320. package/dist/src/tasks/project-operating-view-service.js +1 -1
  321. package/dist/src/tasks/task-application-service.js +6 -1
  322. package/dist/src/tasks/task-context-assembler.js +1 -1
  323. package/dist/src/tasks/task-context-repository.d.ts +0 -1
  324. package/dist/src/tasks/task-context-repository.js +1 -1
  325. package/dist/src/tasks/task-deletion-service.js +1 -1
  326. package/dist/src/tasks/task-handoff-service.js +1 -1
  327. package/dist/src/tasks/task-read-model-projector.js +1 -1
  328. package/dist/src/tasks/task-run-coordinator.js +1 -1
  329. package/dist/src/tasks/task-run-dispatcher.js +1 -1
  330. package/dist/src/tasks/task-run-repository.js +1 -0
  331. package/dist/src/tasks/task-signal-service.js +1 -1
  332. package/dist/src/tui/tool-summary.js +2 -1
  333. package/dist/src/tui/tui-scoped-models.js +9 -6
  334. package/dist/src/user-context/changes.d.ts +1 -1
  335. package/dist/src/user-context/config.d.ts +135 -153
  336. package/dist/src/user-context/config.js +94 -99
  337. package/dist/src/user-context/relationship-continuity.d.ts +2 -2
  338. package/dist/src/user-context/relationship-continuity.js +34 -24
  339. package/dist/src/user-context/sources/activity-clustering.d.ts +9 -3
  340. package/dist/src/user-context/sources/index.js +2 -2
  341. package/dist/src/user-context/sources/repository.d.ts +1 -21
  342. package/dist/src/user-context/sources/repository.js +1 -183
  343. package/dist/src/user-context/sources/types.d.ts +0 -23
  344. package/dist/src/user-model/capture/executor.d.ts +40 -0
  345. package/dist/src/user-model/capture/executor.js +134 -0
  346. package/dist/src/user-model/capture/index.d.ts +2 -0
  347. package/dist/src/user-model/capture/index.js +3 -0
  348. package/dist/src/user-model/capture/semantic.d.ts +21 -0
  349. package/dist/src/user-model/capture/semantic.js +197 -0
  350. package/dist/src/user-model/domain.d.ts +93 -0
  351. package/dist/src/user-model/domain.js +33 -0
  352. package/dist/src/user-model/goals.d.ts +58 -0
  353. package/dist/src/user-model/goals.js +89 -0
  354. package/dist/src/user-model/importance.d.ts +11 -0
  355. package/dist/src/user-model/importance.js +17 -0
  356. package/dist/src/user-model/index.d.ts +5 -0
  357. package/dist/src/user-model/index.js +6 -0
  358. package/dist/src/user-model/repository.d.ts +23 -0
  359. package/dist/src/user-model/repository.js +268 -0
  360. package/dist/src/user-model/temporal.d.ts +10 -0
  361. package/dist/src/user-model/temporal.js +44 -0
  362. package/dist/src/voice/realtime/agentEngine.js +63 -18
  363. package/dist/src/voice/realtime/conversationTurn.d.ts +20 -0
  364. package/dist/src/voice/realtime/conversationTurn.js +83 -0
  365. package/dist/src/voice/realtime/memory-context.d.ts +7 -2
  366. package/dist/src/voice/realtime/memory-context.js +39 -51
  367. package/dist/src/voice/realtime/omniEngine.js +72 -18
  368. package/dist/src/work-discovery/service.d.ts +3 -14
  369. package/dist/src/work-discovery/service.js +138 -99
  370. package/dist/src/work-discovery/types.d.ts +3 -3
  371. package/dist/src/workflows/authoring/workflow-draft-store.d.ts +1 -5
  372. package/dist/src/workflows/authoring/workflow-draft-store.js +23 -43
  373. package/dist/src/workflows/index.js +2 -2
  374. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  375. package/dist/src/workflows/service/workflow-session-bridge.js +12 -20
  376. package/dist/src/workflows/store/event-store.d.ts +1 -2
  377. package/dist/src/workflows/store/event-store.js +19 -64
  378. package/dist/src/workflows/store/paths.d.ts +0 -2
  379. package/dist/src/workflows/store/paths.js +1 -7
  380. package/dist/src/workflows/store/run-store.d.ts +0 -1
  381. package/dist/src/workflows/store/run-store.js +1 -24
  382. package/package.json +3 -3
  383. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-eG49pM-z.js +0 -1
  384. package/dist/gateway/static/root/assets/agents-CZwf1mgZ.js +0 -1
  385. package/dist/gateway/static/root/assets/app-management-settings-panel-BODskFTb.js +0 -1
  386. package/dist/gateway/static/root/assets/appearance-settings-DeaVvaYZ.js +0 -1
  387. package/dist/gateway/static/root/assets/apps-page-BZG3BK7f.js +0 -1
  388. package/dist/gateway/static/root/assets/automations-workspace-CB7Yl2_B.js +0 -6
  389. package/dist/gateway/static/root/assets/browser-settings-page-Bu42Ljfw.js +0 -8
  390. package/dist/gateway/static/root/assets/capabilities-settings-panel-Cg7zCxEH.js +0 -7
  391. package/dist/gateway/static/root/assets/channels-settings-EDTZ8P3y.js +0 -1
  392. package/dist/gateway/static/root/assets/cloud-C4-yfnnk.js +0 -1
  393. package/dist/gateway/static/root/assets/connectors-page-kh7PEkSS.js +0 -2
  394. package/dist/gateway/static/root/assets/dependency-picker-oi7cdv2C.js +0 -1
  395. package/dist/gateway/static/root/assets/desktop-pet-settings-D9OO-exo.js +0 -1
  396. package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +0 -1
  397. package/dist/gateway/static/root/assets/extension-settings-page-FTD7nE8v.js +0 -1
  398. package/dist/gateway/static/root/assets/eye-CABVeTq0.js +0 -1
  399. package/dist/gateway/static/root/assets/eye-off-DEAzt3g1.js +0 -1
  400. package/dist/gateway/static/root/assets/folder-open-CyzJ19I9.js +0 -1
  401. package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +0 -1
  402. package/dist/gateway/static/root/assets/gateway-config-api-c-8ENciH.js +0 -1
  403. package/dist/gateway/static/root/assets/gateway-settings-BxvyTRl0.js +0 -1
  404. package/dist/gateway/static/root/assets/heartbeat-settings-C1S2Ccui.js +0 -1
  405. package/dist/gateway/static/root/assets/home-page-Bqx-SMWV.js +0 -1
  406. package/dist/gateway/static/root/assets/index-Cif1_3Jx.js +0 -71
  407. package/dist/gateway/static/root/assets/index-Dbh5SXyV.css +0 -2
  408. package/dist/gateway/static/root/assets/interaction-BmQogeqz.js +0 -1
  409. package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +0 -1
  410. package/dist/gateway/static/root/assets/link-2-D_ZKYUW7.js +0 -1
  411. package/dist/gateway/static/root/assets/local-app-workbench-page-sDdw7Y3Q.js +0 -2
  412. package/dist/gateway/static/root/assets/logs-page-DUsxXdDp.js +0 -2
  413. package/dist/gateway/static/root/assets/message-square-plus-XP0tGdlV.js +0 -1
  414. package/dist/gateway/static/root/assets/messages-BbdwoxVo.js +0 -3
  415. package/dist/gateway/static/root/assets/minimize-2-DtOGrlpo.js +0 -1
  416. package/dist/gateway/static/root/assets/mobile-pairing-wizard-Dv87XewB.js +0 -1
  417. package/dist/gateway/static/root/assets/models-hub-cache-88f4fzYS.js +0 -1
  418. package/dist/gateway/static/root/assets/notes-page-DOe0lOcQ.js +0 -1
  419. package/dist/gateway/static/root/assets/notes-workbench-Cy0oYbWP.js +0 -4
  420. package/dist/gateway/static/root/assets/oauth-api-BjSUDIgq.js +0 -1
  421. package/dist/gateway/static/root/assets/oauth-authorization-window-Cdolr2wE.js +0 -1
  422. package/dist/gateway/static/root/assets/page-tabs-BaEQMYm_.js +0 -1
  423. package/dist/gateway/static/root/assets/pencil-DmIY3Oa-.js +0 -1
  424. package/dist/gateway/static/root/assets/preview-open-alternatives-CsNVTKC0.js +0 -1
  425. package/dist/gateway/static/root/assets/project-detail-page-fgD1xc4O.js +0 -1
  426. package/dist/gateway/static/root/assets/projects-page-CiTiEcOc.js +0 -1
  427. package/dist/gateway/static/root/assets/remote-access-hub-Dc0GrNSp.js +0 -1
  428. package/dist/gateway/static/root/assets/rotate-cw-LIg3Am9S.js +0 -1
  429. package/dist/gateway/static/root/assets/search-DA7gz22f.js +0 -1
  430. package/dist/gateway/static/root/assets/sessions-page-BPOW3yaM.js +0 -1
  431. package/dist/gateway/static/root/assets/settings-advanced-gate-Bz4s9BBY.js +0 -1
  432. package/dist/gateway/static/root/assets/settings-form-section-DjWzRk4z.js +0 -1
  433. package/dist/gateway/static/root/assets/setup-status-panel-rllj-j7k.js +0 -1
  434. package/dist/gateway/static/root/assets/shares-settings-DMj7onCX.js +0 -1
  435. package/dist/gateway/static/root/assets/skill-reload-api-DRB366nS.js +0 -1
  436. package/dist/gateway/static/root/assets/skills-page-cBT9jCof.js +0 -2
  437. package/dist/gateway/static/root/assets/system-settings-panel-Byrk4DQy.js +0 -1
  438. package/dist/gateway/static/root/assets/task-detail-page-CheX3zmK.js +0 -1
  439. package/dist/gateway/static/root/assets/tunnel-api-jKzujxFU.js +0 -1
  440. package/dist/gateway/static/root/assets/user-context-page-CWy3Pqtk.js +0 -1
  441. package/dist/gateway/static/root/assets/work-discovery-overlay-DE4_YpDn.js +0 -1
  442. package/dist/gateway/static/root/assets/workflows-page-y4O9-BTf.js +0 -5
  443. package/dist/src/agent/memory/builtin-provider.d.ts +0 -37
  444. package/dist/src/agent/memory/builtin-provider.js +0 -225
  445. package/dist/src/agent/memory/context/types.d.ts +0 -40
  446. package/dist/src/agent/memory/understanding/quality.d.ts +0 -8
  447. package/dist/src/agent/memory/understanding/quality.js +0 -18
  448. package/dist/src/agent/memory/understanding/service.d.ts +0 -19
  449. package/dist/src/agent/memory/understanding/service.js +0 -209
  450. package/dist/src/agent/memory/understanding/types.d.ts +0 -34
  451. package/dist/src/agent/memory/understanding/types.js +0 -1
  452. package/dist/src/agent/memory/user-context-coordinator.d.ts +0 -23
  453. package/dist/src/agent/memory/user-context-coordinator.js +0 -113
  454. package/dist/src/agent/tools/dreaming-tool.js +0 -37
  455. package/dist/src/agent/tools/memory-tool.d.ts +0 -9
  456. package/dist/src/agent/tools/memory-tool.js +0 -119
  457. package/dist/src/gateway/dreaming-automation-reconciler.d.ts +0 -11
  458. package/dist/src/gateway/dreaming-automation-reconciler.js +0 -63
  459. package/dist/src/gateway/hono/routes/understanding-sources.d.ts +0 -21
  460. package/dist/src/gateway/hono/routes/understanding-sources.js +0 -387
  461. package/dist/src/gateway/hono/routes/you.d.ts +0 -3
  462. package/dist/src/gateway/hono/routes/you.js +0 -443
  463. package/dist/src/projects/memory-bind.d.ts +0 -1
  464. package/dist/src/projects/memory-bind.js +0 -14
  465. package/dist/src/storage/sqlite/context-consolidation-repository.d.ts +0 -37
  466. package/dist/src/storage/sqlite/context-consolidation-repository.js +0 -64
  467. package/dist/src/storage/sqlite/memory-records-repository.d.ts +0 -217
  468. package/dist/src/storage/sqlite/memory-records-repository.js +0 -715
  469. package/dist/src/storage/sqlite/remote-context-repository.d.ts +0 -3
  470. package/dist/src/storage/sqlite/remote-context-repository.js +0 -40
  471. package/dist/src/storage/sqlite/user-context-quality-repository.d.ts +0 -49
  472. package/dist/src/storage/sqlite/user-context-quality-repository.js +0 -118
  473. package/dist/src/storage/sqlite/user-context-repository.d.ts +0 -85
  474. package/dist/src/storage/sqlite/user-context-repository.js +0 -535
  475. package/dist/src/user-context/automatic-context.d.ts +0 -17
  476. package/dist/src/user-context/automatic-context.js +0 -85
  477. package/dist/src/user-context/consolidation.d.ts +0 -27
  478. package/dist/src/user-context/consolidation.js +0 -187
  479. package/dist/src/user-context/context-objects.d.ts +0 -17
  480. package/dist/src/user-context/context-objects.js +0 -99
  481. package/dist/src/user-context/evaluation/harness.d.ts +0 -13
  482. package/dist/src/user-context/evaluation/harness.js +0 -31
  483. package/dist/src/user-context/extraction/executor.d.ts +0 -22
  484. package/dist/src/user-context/extraction/executor.js +0 -142
  485. package/dist/src/user-context/extraction/repair.d.ts +0 -19
  486. package/dist/src/user-context/extraction/repair.js +0 -71
  487. package/dist/src/user-context/extraction/semantic.d.ts +0 -18
  488. package/dist/src/user-context/extraction/semantic.js +0 -148
  489. package/dist/src/user-context/focus-lifecycle.d.ts +0 -2
  490. package/dist/src/user-context/focus-lifecycle.js +0 -26
  491. package/dist/src/user-context/manual-understanding.d.ts +0 -12
  492. package/dist/src/user-context/manual-understanding.js +0 -37
  493. package/dist/src/user-context/planner.d.ts +0 -17
  494. package/dist/src/user-context/planner.js +0 -465
  495. package/dist/src/user-context/relationships/indexer.d.ts +0 -13
  496. package/dist/src/user-context/relationships/indexer.js +0 -185
  497. package/dist/src/user-context/relationships/service.d.ts +0 -22
  498. package/dist/src/user-context/relationships/service.js +0 -50
  499. package/dist/src/user-context/retriever.d.ts +0 -15
  500. package/dist/src/user-context/retriever.js +0 -124
  501. package/dist/src/user-context/scope.d.ts +0 -7
  502. package/dist/src/user-context/scope.js +0 -9
  503. package/dist/src/user-context/selection-policy.d.ts +0 -20
  504. package/dist/src/user-context/selection-policy.js +0 -33
  505. package/dist/src/user-context/understanding.d.ts +0 -15
  506. package/dist/src/user-context/understanding.js +0 -24
  507. package/dist/src/user-context/understandingQuality.d.ts +0 -5
  508. package/dist/src/user-context/understandingQuality.js +0 -48
  509. /package/dist/src/{agent/memory/context/types.js → knowledge-memory/domain.js} +0 -0
@@ -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{d as i,l as a,p as o,t as s}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist-CpzYSoz7.js";import{t as g}from"./check-DUBLcKHA.js";import{c as _,l as v,n as y,o as b,r as x,s as S,t as C,u as w}from"./popover-select-C-Hj-nXR.js";import{t as T}from"./circle-check-C23XjkUj.js";import{t as E}from"./copy-Dv6d4Dvw.js";import{t as D}from"./download-Dk-ZjtO6.js";import{t as O}from"./external-link-DjqjBmc3.js";import{d as k,p as A}from"./markdown-view-BXsHghJd.js";import{t as j}from"./message-square-plus-XP0tGdlV.js";import{t as M}from"./plus-Q2yW6OE7.js";import{t as N}from"./search-DA7gz22f.js";import{t as P}from"./x-B_N4OPjy.js";import{t as F}from"./copy-to-clipboard-HOJ79TWv.js";import{t as I}from"./messages-BbdwoxVo.js";import{a as L,n as R,r as z}from"./locale-store-CBoCuIMx.js";import{t as B}from"./cn-JdwAhgNB.js";import{t as V}from"./button-CtTvuElV.js";import{n as H}from"./interaction-BmQogeqz.js";import{t as U}from"./skeleton-BwbyijEw.js";import{$l as W,$r as G,$s as ee,Ai as te,B as ne,Bl as K,Bs as re,Ci as ie,Dc as ae,Di as q,Ei as oe,Es as se,Fl as ce,Go as le,Gs as ue,Il as de,Jc as fe,Jr as pe,Js as me,Ko as he,Ll as ge,Mi as _e,Ms as ve,N as ye,Nl as be,Nr as xe,Oi as Se,Pc as Ce,Pi as we,Qr as Te,Qs as Ee,Rc as De,Ri as Oe,Si as ke,Ti as Ae,Vi as je,Wi as Me,Wt as Ne,Xr as Pe,Yc as Fe,Yo as Ie,Ys as Le,Yt as Re,Zo as ze,Zr as Be,_l as Ve,as as He,bi as Ue,bl as We,cl as Ge,cs as Ke,dc as qe,ds as Je,ei as Ye,eu as Xe,fs as Ze,gi as Qe,gr as $e,hi as et,il as tt,ji as nt,jl as rt,jr as it,ki as at,lo as ot,mc as st,mi as ct,ni as lt,nu as ut,oa as dt,ol as ft,os as pt,qr as mt,qt as ht,ri as gt,rl as _t,sl as vt,ti as yt,tl as bt,uc as xt,us as St,vi as Ct,wi as wt,wl as Tt,wt as Et,xi as Dt,xs as Ot,yi as kt,ys as At,zc as jt,zi as Mt}from"./index-Cif1_3Jx.js";import{t as Nt}from"./notes-workbench-Cy0oYbWP.js";import{n as Pt,t as Ft}from"./use-autosave-DX5YZ3Nn.js";import{t as It}from"./page-tabs-BaEQMYm_.js";import{t as Lt}from"./date-picker-dt37Lt8e.js";import{c as Rt,l as zt,n as Bt,o as Vt,r as Ht,t as Ut}from"./style-TIDOdKy0.js";import{t as Wt}from"./automations-workspace-CB7Yl2_B.js";import{i as Gt,p as Kt,s as qt}from"./skills-page.utils-CwRekJSJ.js";import{t as Jt}from"./dependency-picker-oi7cdv2C.js";var J=e(t(),1),Yt=n(),Y=r();function Xt(e){let t=(0,Yt.c)(27),{value:n,onPick:r,disabled:i,placeholder:a,title:o,className:s,maxWidthClass:c,compact:l,"aria-label":u}=e,d=c===void 0?`max-w-[min(12rem,40vw)]`:c,f=l===void 0?!1:l,p,m;t[0]!==a||t[1]!==n?(m=n.trim(),p=m?Mt(m):a??``,t[0]=a,t[1]=n,t[2]=p,t[3]=m):(p=t[2],m=t[3]);let h=p,g=o??(m||void 0),_=u??o??h,v=f?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,y=!f&&d,b=i&&`cursor-not-allowed opacity-60`,x;t[4]!==s||t[5]!==v||t[6]!==y||t[7]!==b?(x=B(v,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,H.transition,H.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,y,b,s),t[4]=s,t[5]=v,t[6]=y,t[7]=b,t[8]=x):x=t[8];let S;t[9]!==i||t[10]!==r?(S=e=>{e.stopPropagation(),i||r()},t[9]=i,t[10]=r,t[11]=S):S=t[11];let C=f?`size-4`:`size-3.5`,w;t[12]===C?w=t[13]:(w=B(`shrink-0 text-fg-muted`,C),t[12]=C,t[13]=w);let T;t[14]===w?T=t[15]:(T=(0,Y.jsx)(ft,{className:w,"aria-hidden":!0}),t[14]=w,t[15]=T);let E;t[16]!==f||t[17]!==h?(E=f?null:(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:h}),t[16]=f,t[17]=h,t[18]=E):E=t[18];let D;return t[19]!==i||t[20]!==S||t[21]!==T||t[22]!==E||t[23]!==g||t[24]!==_||t[25]!==x?(D=(0,Y.jsxs)(`button`,{type:`button`,disabled:i,title:g,"aria-label":_,className:x,onClick:S,children:[T,E]}),t[19]=i,t[20]=S,t[21]=T,t[22]=E,t[23]=g,t[24]=_,t[25]=x,t[26]=D):D=t[26],D}function Zt(e){let t=(0,Yt.c)(38),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,inputClassName:s,autoFocus:c,trailing:l}=e,u;t[0]!==r||t[1]!==n?(u={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=u):u=t[2];let d=Oe(u),f;t[3]===n?f=t[4]:(f=n.trim(),t[3]=n,t[4]=f);let p=f,m=p?`${p}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`,h;t[5]===s?h=t[6]:(h=B(`min-w-0 flex-1`,s),t[5]=s,t[6]=h);let g=i||d.picking,_;t[7]===r?_=t[8]:(_=e=>void r(e.target.value),t[7]=r,t[8]=_);let v=o??a.pathInputPlaceholder,y;t[9]!==c||t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==n?(y=(0,Y.jsx)(`input`,{type:`text`,className:h,value:n,disabled:g,onChange:_,placeholder:v,autoFocus:c,autoComplete:`off`,spellCheck:!1}),t[9]=c,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=n,t[15]=y):y=t[15];let b=i||d.picking,x;t[16]!==m||t[17]!==d.pick||t[18]!==b||t[19]!==n||t[20]!==a.selectWorkingDirectory?(x=(0,Y.jsx)(Xt,{compact:!0,value:n,onPick:d.pick,disabled:b,title:m,"aria-label":a.selectWorkingDirectory}),t[16]=m,t[17]=d.pick,t[18]=b,t[19]=n,t[20]=a.selectWorkingDirectory,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==l?(S=(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[x,l]}),t[22]=x,t[23]=l,t[24]=S):S=t[24];let C;t[25]!==S||t[26]!==y?(C=(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[y,S]}),t[25]=S,t[26]=y,t[27]=C):C=t[27];let w;t[28]!==d.confirmPick||t[29]!==d.hasNativePicker||t[30]!==d.modalOpen||t[31]!==d.setModalOpen||t[32]!==p||t[33]!==a?(w=d.hasNativePicker?null:(0,Y.jsx)(we,{open:d.modalOpen,onOpenChange:d.setModalOpen,initialAbsolutePath:p||void 0,onConfirm:d.confirmPick,wd:a}),t[28]=d.confirmPick,t[29]=d.hasNativePicker,t[30]=d.modalOpen,t[31]=d.setModalOpen,t[32]=p,t[33]=a,t[34]=w):w=t[34];let T;return t[35]!==C||t[36]!==w?(T=(0,Y.jsxs)(Y.Fragment,{children:[C,w]}),t[35]=C,t[36]=w,t[37]=T):T=t[37],T}function Qt(e){return L(z(`/api/projects/${encodeURIComponent(e)}/skills`))}function $t(e,t){return L(z(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`))}function en(e,t){return L(z(`/api/projects/${encodeURIComponent(e)}/workspace-trust`),{method:`PATCH`,body:JSON.stringify({trusted:t})})}function tn(e,t){let n=new FormData;return n.set(`file`,t),L(z(`/api/projects/${encodeURIComponent(e)}/skills/upload`),{method:`POST`,body:n})}function nn(e,t,n={}){return L(z(`/api/projects/${encodeURIComponent(e)}/skills/marketplace/install`),{method:`POST`,body:JSON.stringify({name:t,...n})})}function rn(e,t){return L(z(`/api/projects/${encodeURIComponent(e)}/skills/source/install`),{method:`POST`,body:JSON.stringify({source:t})})}function an(e,t){return L(z(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),{method:`DELETE`})}function on({projectId:e,copy:t}){let[n,r]=(0,J.useState)([]),[i,a]=(0,J.useState)([]),[o,s]=(0,J.useState)([]),[l,u]=(0,J.useState)([]),[g,y]=(0,J.useState)([]),[b,x]=(0,J.useState)(``),[T,E]=(0,J.useState)(null),[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(!0),[F,I]=(0,J.useState)(!1),[L,R]=(0,J.useState)(null),[z,H]=(0,J.useState)(``),[W,G]=(0,J.useState)(null),[ee,te]=(0,J.useState)(null),[ne,K]=(0,J.useState)(``),[re,ie]=(0,J.useState)(1),[q,oe]=(0,J.useState)(null),[se,le]=(0,J.useState)(!1),[fe,pe]=(0,J.useState)(``),[me,he]=(0,J.useState)(``),_e=(0,J.useRef)(null),ye=(0,J.useCallback)(async()=>{j(!0),H(``);try{let t=await Qt(e);r(t.items),a(t.inheritedItems),s(t.sources),u(t.diagnostics)}catch(e){H(e instanceof Error?e.message:String(e))}finally{j(!1)}},[e]);(0,J.useEffect)(()=>{ye()},[ye]),(0,J.useEffect)(()=>{let t=!1;return wt(e).then(e=>{t||y(e)}).catch(()=>{t||y([])}),()=>{t=!0}},[e]),(0,J.useEffect)(()=>{if(!b){E(null);return}let e=g.find(e=>e.key===b),t=!1;return E(null),H(``),k(!0),Re(e?.agentId??e?.routing?.agentId,b,!0).then(e=>{t||E(e)}).catch(e=>{t||H(e instanceof Error?e.message:String(e))}).finally(()=>{t||k(!1)}),()=>{t=!0}},[b,g]),(0,J.useEffect)(()=>{if(W!==`marketplace`)return;let e=new AbortController,t=window.setTimeout(()=>{le(!0),pe(``),Kt({q:ne,page:re,pageSize:8,sort:`downloads`,signal:e.signal}).then(oe).catch(t=>{e.signal.aborted||pe(t instanceof Error?t.message:String(t))}).finally(()=>{e.signal.aborted||le(!1)})},250);return()=>{window.clearTimeout(t),e.abort()}},[W,re,ne]);async function be(e,t){I(!0),R(t??null),H(``);try{await e(),G(null),he(``),await ye()}catch(e){H(e instanceof Error?e.message:String(e))}finally{I(!1),R(null)}}async function xe(t){H(``);try{te((await $t(e,t)).skill)}catch(e){H(e instanceof Error?e.message:String(e))}}async function Se(n){if(n.removable&&window.confirm(t.removeConfirm.replace(`{{name}}`,n.name))){I(!0);try{await an(e,n.directoryId),await ye()}catch(e){H(e instanceof Error?e.message:String(e))}finally{I(!1)}}}async function Ce(){I(!0),H(``);try{await en(e,!0),await ye()}catch(e){H(e instanceof Error?e.message:String(e))}finally{I(!1)}}let we=o.find(e=>e.origin===`agents-workspace`),Te=new Map(T?.skills.map(e=>[e.name,e]));return(0,Y.jsxs)(`section`,{id:`project-panel-skills`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-skills`,className:`grid content-start gap-4`,children:[(0,Y.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.description})]}),(0,Y.jsxs)(v,{children:[(0,Y.jsx)(w,{asChild:!0,children:(0,Y.jsxs)(V,{type:`button`,children:[(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":!0}),t.add,(0,Y.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0})]})}),(0,Y.jsx)(_,{children:(0,Y.jsxs)(S,{align:`end`,sideOffset:8,className:`z-50 w-72 rounded-lg border border-edge bg-surface-panel p-1.5 shadow-xl`,children:[(0,Y.jsx)(un,{icon:ve,title:t.marketplace,hint:t.marketplaceHint,onClick:()=>G(`marketplace`)}),(0,Y.jsx)(un,{icon:bt,title:t.source,hint:t.sourceHint,onClick:()=>G(`source`)}),(0,Y.jsx)(un,{icon:Ot,title:t.upload,hint:t.uploadHint,onClick:()=>_e.current?.click()})]})})]}),(0,Y.jsx)(`input`,{ref:_e,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:t=>{let n=t.target.files?.[0];n&&be(()=>tn(e,n)),t.target.value=``}})]}),o.length?(0,Y.jsx)(`div`,{className:`mt-3 grid gap-2 rounded-md border border-edge-subtle bg-surface-base p-3`,children:o.map(e=>(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-fg`,children:e.origin===`xopc-workspace`?t.xopcSource:t.agentsSource}),e.writable?null:(0,Y.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-fg-muted`,children:t.sourceReadOnly}),(0,Y.jsx)(`span`,{className:`text-fg-subtle`,children:dn(t,e.state)}),(0,Y.jsxs)(`span`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.path,`: `,e.rootDir]})]},e.origin))}):null]}),z?(0,Y.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:z}):null,we?.state===`untrusted`?(0,Y.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,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Y.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.trustTitle}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustHint})]})]}),(0,Y.jsxs)(V,{type:`button`,variant:`secondary`,disabled:F,onClick:()=>void Ce(),children:[(0,Y.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),F?t.trusting:t.trustAction]})]}):null,l.some(e=>e.type!==`skipped`)?(0,Y.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-4 py-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.diagnosticsTitle}),(0,Y.jsx)(`ul`,{className:`mt-2 grid gap-1 text-xs leading-5 text-fg-muted`,children:l.filter(e=>e.type!==`skipped`).map((e,t)=>(0,Y.jsx)(`li`,{children:e.message},`${e.type}:${e.path??``}:${t}`))})]}):null,g.length?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.sessionViewLabel}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:O?t.sessionLoading:b?T?.agentId:t.sessionViewAll})]}),(0,Y.jsx)(C,{value:b,options:g.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:x})]}):null,A?(0,Y.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[0,1,2].map(e=>(0,Y.jsx)(U,{className:`h-36 rounded-lg`},e))}):n.length?(0,Y.jsx)(sn,{title:t.localTitle,items:n,copy:t,busy:F,availabilityByName:Te,onPreview:xe,onRemove:Se}):(0,Y.jsxs)(`div`,{className:`rounded-lg border border-dashed border-edge bg-surface-panel px-6 py-12 text-center`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.empty}),(0,Y.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.emptyHint})]}),!A&&i.length?(0,Y.jsx)(sn,{title:t.inheritedTitle,hint:t.inheritedHint,items:i,copy:t,busy:F,availabilityByName:Te,onPreview:xe,onRemove:Se}):null,(0,Y.jsx)(h,{open:W!==null,onOpenChange:e=>{e||G(null)},children:(0,Y.jsxs)(f,{children:[(0,Y.jsx)(c,{className:`fixed inset-0 z-50 bg-black/45`}),(0,Y.jsxs)(p,{className:B(`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-panel shadow-xl`,W===`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,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Y.jsx)(m,{className:`text-base font-semibold text-fg`,children:W===`marketplace`?t.marketplace:t.source}),(0,Y.jsx)(d,{asChild:!0,children:(0,Y.jsx)(V,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,Y.jsx)(P,{className:`size-4`})})})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:W===`marketplace`?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.marketplace}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.marketplaceHint}),(0,Y.jsxs)(`div`,{className:`relative mt-3`,children:[(0,Y.jsx)(N,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,Y.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:ne,onChange:e=>{K(e.target.value),ie(1)},placeholder:t.marketplacePlaceholder,autoFocus:!0})]}),fe?(0,Y.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-300`,children:fe}):null,se&&!q?(0,Y.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,Y.jsx)(U,{className:`h-32 rounded-lg`},e))}):q?.items.length?(0,Y.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:q.items.map(r=>{let i=r.providerId??q.provider,a=Gt(r,i),o=n.some(e=>e.origin===`xopc-workspace`&&(e.directoryId===r.id||e.directoryId===a||e.name===r.name)),s=L===a;return(0,Y.jsxs)(`article`,{className:`group flex min-h-32 gap-3 rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Y.jsx)(qt,{name:r.name,className:`size-10`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`h4`,{className:`truncate text-sm font-semibold text-fg`,children:r.name}),(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:r.description||`—`}),(0,Y.jsxs)(`div`,{className:`mt-auto flex items-end justify-between gap-2 pt-2`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-fg-subtle`,children:[(0,Y.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),t.marketplaceDownloads,` `,r.downloads]}),(0,Y.jsx)(V,{type:`button`,className:`h-8 px-2.5 text-xs`,variant:o?`secondary`:`primary`,disabled:F||o,onClick:()=>void be(()=>nn(e,a,{provider:i}),a),children:o?t.marketplaceInstalled:s?t.installing:t.install})]})]})]},`${i??`default`}:${r.id}`)})}):se?null:(0,Y.jsx)(`p`,{className:`mt-6 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}),q&&q.meta.totalPages>1?(0,Y.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t.marketplacePage.replace(`{{page}}`,String(q.meta.page)).replace(`{{total}}`,String(q.meta.totalPages))}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:se||re<=1,onClick:()=>ie(e=>Math.max(1,e-1)),children:[(0,Y.jsx)(de,{className:`size-4`}),t.marketplacePrevious]}),(0,Y.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:se||re>=q.meta.totalPages,onClick:()=>ie(e=>e+1),children:[t.marketplaceNext,(0,Y.jsx)(ce,{className:`size-4`})]})]})]}):null]}):(0,Y.jsxs)(`section`,{className:`flex h-full flex-col`,children:[(0,Y.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:t.sourceHint}),(0,Y.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:me,onChange:e=>he(e.target.value),placeholder:t.sourcePlaceholder,autoFocus:!0}),(0,Y.jsxs)(`div`,{className:`mt-auto flex justify-end gap-2 border-t border-edge pt-4`,children:[(0,Y.jsx)(d,{asChild:!0,children:(0,Y.jsx)(V,{type:`button`,variant:`secondary`,children:t.close})}),(0,Y.jsx)(V,{type:`button`,disabled:F||!me.trim(),onClick:()=>void be(()=>rn(e,me.trim())),children:F?t.installing:t.install})]})]})})]})]})}),(0,Y.jsx)(h,{open:!!ee,onOpenChange:e=>{e||te(null)},children:(0,Y.jsxs)(f,{children:[(0,Y.jsx)(c,{className:`fixed inset-0 z-50 bg-black/45`}),(0,Y.jsxs)(p,{className:`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-panel shadow-xl`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Y.jsx)(m,{className:`text-base font-semibold text-fg`,children:ee?.name}),(0,Y.jsx)(d,{asChild:!0,children:(0,Y.jsx)(V,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,Y.jsx)(P,{className:`size-4`})})})]}),(0,Y.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-5 text-sm leading-6 text-fg-muted`,children:ee?.bodyMarkdown})]})]})})]})}function sn(e){let t=(0,Yt.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,Y.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,Y.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,Y.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,Y.jsxs)(`article`,{className:B(`flex min-h-36 flex-col rounded-lg border border-edge bg-surface-panel p-4`,!e.effective&&`opacity-70`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(ut,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,Y.jsx)(`h4`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:e.name})]}),(0,Y.jsx)(`p`,{className:`mt-2 line-clamp-2 flex-1 text-sm leading-5 text-fg-muted`,children:e.description||e.directoryId}),(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[(0,Y.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:cn(a,e.origin)}),e.writable?null:(0,Y.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:a.sourceReadOnly}),e.effective?null:(0,Y.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,Y.jsx)(`span`,{className:B(`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:ln(a,t)}):null]}),(0,Y.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>void c(e.key),children:[(0,Y.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),a.view]}),e.removable?(0,Y.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-red-600`,disabled:o,onClick:()=>void l(e),children:[(0,Y.jsx)(se,{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,Y.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:p}),t[20]=p,t[21]=m);let h;return t[22]!==f||t[23]!==m?(h=(0,Y.jsxs)(`section`,{className:`grid gap-3`,children:[f,m]}),t[22]=f,t[23]=m,t[24]=h):h=t[24],h}function cn(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 ln(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 un(e){let t=(0,Yt.c)(13),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,Y.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,Y.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,Y.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,Y.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,Y.jsx)(b,{asChild:!0,children:(0,Y.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 dn(e,t){switch(t){case`active`:return e.sourceStateActive;case`missing`:return e.sourceStateMissing;case`disabled`:return e.sourceStateDisabled;case`untrusted`:return e.sourceStateUntrusted;case`invalid`:return e.sourceStateInvalid}}var fn=[`backlog`,`ready`,`active`,`review`,`closed`];function pn(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 mn(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 hn(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 gn(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 _n(e,t){let n=new Set(e.map(e=>e.id)),{outgoing:r,incoming:i}=gn(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 vn(e,t){let{incoming:n}=gn(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 yn(e,t){let{incoming:n,outgoing:r}=gn(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 bn={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 xn(e){let t=(0,Yt.c)(25),{data:n,selected:r}=e,i=n.task,a=i.operationalState===`waiting`||i.operationalState===`blocked`,o=bn[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=B(`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,Y.jsx)(Ht,{type:`target`,position:zt.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,Y.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,Y.jsx)(fe,{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,Y.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,Y.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,Y.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,Y.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,Y.jsx)(Ht,{type:`source`,position:zt.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,Y.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 Sn={taskNode:xn};function Cn(e){let t=(0,Yt.c)(90),{tasks:n,dependencyEdges:r,returnTo:i,copy:a,onDependenciesChange:o}=e,[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(),[m,h]=(0,J.useState)(),g=(0,J.useRef)(null),_;t[0]!==r||t[1]!==n?(_=vn(n,r),t[0]=r,t[1]=n,t[2]=_):_=t[2];let v=_,y;t[3]!==v||t[4]!==u||t[5]!==c||t[6]!==n?(y=u?n.filter(e=>v.has(e.id)):c?n:n.filter(kn),t[3]=v,t[4]=u,t[5]=c,t[6]=n,t[7]=y):y=t[7];let b=y,x;t[8]===b?x=t[9]:(x=new Set(b.map(Z)),t[8]=b,t[9]=x);let S=x,C;if(t[10]!==r||t[11]!==S){let e;t[13]===S?e=t[14]:(e=e=>S.has(e.dependencyTaskId)&&S.has(e.dependentTaskId),t[13]=S,t[14]=e),C=r.filter(e),t[10]=r,t[11]=S,t[12]=C}else C=t[12];let w=C,T;t[15]!==w||t[16]!==b?(T=_n(b,w),t[15]=w,t[16]=b,t[17]=T):T=t[17];let E=T,D;t[18]!==f||t[19]!==w?(D=f?yn(f,w):void 0,t[18]=f,t[19]=w,t[20]=D):D=t[20];let k=D,A;t[21]===f?A=t[22]:(A=e=>e.id===f,t[21]=f,t[22]=A);let j=b.find(A),M;t[23]===b?M=t[24]:(M=new Map(b.map(On)),t[23]=b,t[24]=M);let N=M,P;if(t[25]!==a.phases||t[26]!==E||t[27]!==k||t[28]!==b){let e;t[30]!==a.phases||t[31]!==E||t[32]!==k?(e=e=>({id:e.id,type:`taskNode`,position:E.get(e.id)??{x:0,y:0},data:{task:e,phaseLabel:a.phases[e.phase],dimmed:!!(k&&!k.has(e.id))}}),t[30]=a.phases,t[31]=E,t[32]=k,t[33]=e):e=t[33],P=b.map(e),t[25]=a.phases,t[26]=E,t[27]=k,t[28]=b,t[29]=P}else P=t[29];let F=P,I;if(t[34]!==k||t[35]!==N||t[36]!==w){let e;t[38]!==k||t[39]!==N?(e=e=>{let t=N.get(e.dependencyTaskId),n=t?.phase===`closed`&&t.resolution===`done`,r=!!(k&&(!k.has(e.dependencyTaskId)||!k.has(e.dependentTaskId)));return{id:`${e.dependencyTaskId}:${e.dependentTaskId}`,source:e.dependencyTaskId,target:e.dependentTaskId,markerEnd:{type:Rt.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]=k,t[39]=N,t[40]=e):e=t[40],I=w.map(e),t[34]=k,t[35]=N,t[36]=w,t[37]=I}else I=t[37];let L=I,R,z;t[41]!==f||t[42]!==S?(R=()=>{f&&!S.has(f)&&p(void 0)},z=[f,S],t[41]=f,t[42]=S,t[43]=R,t[44]=z):(R=t[43],z=t[44]),(0,J.useEffect)(R,z);let H,U;t[45]!==L||t[46]!==m?(H=()=>{m&&!L.some(e=>e.id===m)&&h(void 0)},U=[L,m],t[45]=L,t[46]=m,t[47]=H,t[48]=U):(H=t[47],U=t[48]),(0,J.useEffect)(H,U);let W;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{let e=window.requestAnimationFrame(()=>{g.current?.fitView({padding:.2,minZoom:.35,maxZoom:1,duration:250})});return()=>window.cancelAnimationFrame(e)},t[49]=W):W=t[49];let G;t[50]!==u||t[51]!==c||t[52]!==b.length?(G=[u,c,b.length],t[50]=u,t[51]=c,t[52]=b.length,t[53]=G):G=t[53],(0,J.useEffect)(W,G);let ee;t[54]===f?ee=t[55]:(ee=()=>{f&&g.current?.fitView({nodes:[{id:f}],padding:1.5,minZoom:.7,maxZoom:1,duration:250})},t[54]=f,t[55]=ee);let te=ee,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(Dn);t.includes(e.source)||o(e.target,[...t,e.source])},t[56]=r,t[57]=o,t[58]=ne):ne=t[58];let K=ne,re;t[59]!==r||t[60]!==o||t[61]!==m?(re=()=>{if(!m)return;let e=r.find(e=>`${e.dependencyTaskId}:${e.dependentTaskId}`===m);e&&(h(void 0),o(e.dependentTaskId,r.filter(t=>t.dependentTaskId===e.dependentTaskId&&t.dependencyTaskId!==e.dependencyTaskId).map(X)))},t[59]=r,t[60]=o,t[61]=m,t[62]=re):re=t[62];let ie=re,ae;t[63]===a.connectHint?ae=t[64]:(ae=(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.connectHint}),t[63]=a.connectHint,t[64]=ae);let q=u?`secondary`:`ghost`,oe;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>d(En),t[65]=oe):oe=t[65];let se=u?a.allTasks:a.blockedChains,ce;t[66]!==u||t[67]!==q||t[68]!==se?(ce=(0,Y.jsx)(V,{type:`button`,variant:q,className:`h-8 rounded-lg px-2.5 text-xs`,"aria-pressed":u,onClick:oe,children:se}),t[66]=u,t[67]=q,t[68]=se,t[69]=ce):ce=t[69];let le;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>l(Tn),t[70]=le):le=t[70];let ue=c?a.hideCompleted:a.showCompleted,de;t[71]!==u||t[72]!==c||t[73]!==ue?(de=(0,Y.jsx)(V,{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]=de):de=t[74];let fe=j?(0,Y.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:te,children:[(0,Y.jsx)(vt,{className:`size-3.5`,"aria-hidden":!0}),a.locateTask]}):null,pe;t[75]!==a.removeDependency||t[76]!==ie||t[77]!==m?(pe=m?(0,Y.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs text-danger`,onClick:ie,children:a.removeDependency}):null,t[75]=a.removeDependency,t[76]=ie,t[77]=m,t[78]=pe):pe=t[78];let me;t[79]!==ce||t[80]!==de||t[81]!==fe||t[82]!==pe?(me=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[ce,de,fe,pe]}),t[79]=ce,t[80]=de,t[81]=fe,t[82]=pe,t[83]=me):me=t[83];let he;t[84]!==ae||t[85]!==me?(he=(0,Y.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:[ae,me]}),t[84]=ae,t[85]=me,t[86]=he):he=t[86];let ge=b.length>0?(0,Y.jsxs)(`div`,{className:B(`grid h-[min(42rem,calc(100vh-14rem))] min-h-[28rem]`,j&&`lg:grid-cols-[minmax(0,1fr)_18rem]`),children:[(0,Y.jsxs)(Vt,{nodes:F,edges:L,nodeTypes:Sn,nodesDraggable:!1,nodesConnectable:!0,elementsSelectable:!0,onNodeClick:(e,t)=>p(t.id),onEdgeClick:(e,t)=>h(t.id),onConnect:K,onPaneClick:()=>{p(void 0),h(void 0)},onInit:e=>{g.current=e},fitView:!0,minZoom:.25,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:{hideAttribution:!0},children:[(0,Y.jsx)(Ut,{color:`var(--color-edge)`,gap:22,size:1}),(0,Y.jsx)(Bt,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`})]}),j?(0,Y.jsxs)(`aside`,{className:`overflow-y-auto border-t border-edge bg-surface-panel p-4 lg:border-l lg:border-t-0`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-accent-fg`,children:a.phases[j.phase]}),(0,Y.jsx)(`h3`,{className:`mt-2 text-sm font-semibold leading-6 text-fg`,children:j.title}),j.operationalState===`blocked`&&j.blockedBy.length>0?(0,Y.jsxs)(`div`,{className:`mt-4 rounded-lg bg-violet-500/8 p-3`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-violet-700 dark:text-violet-300`,children:a.blockedBy.replace(`{{count}}`,String(j.blockedBy.length))}),(0,Y.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:j.blockedBy.map(wn)})]}):null,(0,Y.jsxs)(s,{to:Ke(i,j.id),className:`mt-4 inline-flex items-center gap-1.5 text-xs font-medium text-accent-fg hover:underline`,children:[(0,Y.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),a.openTask]})]}):null]}):(0,Y.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,Y.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 wn(e){return(0,Y.jsx)(`li`,{children:e.title},e.id)}function Tn(e){return!e}function En(e){return!e}function X(e){return e.dependencyTaskId}function Dn(e){return e.dependencyTaskId}function On(e){return[e.id,e]}function Z(e){return e.id}function kn(e){return e.phase!==`closed`}function An({policy:e,copy:t,onSave:n}){let[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(e.mode),[s,g]=(0,J.useState)(Math.round(e.confidenceThreshold*100)),[_,v]=(0,J.useState)(!!e.quietHours),[b,S]=(0,J.useState)(e.quietHours?.startHour??22),[C,w]=(0,J.useState)(e.quietHours?.endHour??8),[T,E]=(0,J.useState)(e.quietHours?.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone),[D,O]=(0,J.useState)(e.allowedActions.includes(`create_project_task`)),[k,A]=(0,J.useState)(!1),[j,M]=(0,J.useState)();(0,J.useEffect)(()=>{o(e.mode),g(Math.round(e.confidenceThreshold*100)),v(!!e.quietHours),S(e.quietHours?.startHour??22),w(e.quietHours?.endHour??8),E(e.quietHours?.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone),O(e.allowedActions.includes(`create_project_task`))},[e]);let N=async()=>{A(!0),M(void 0);try{await n({mode:a,confidenceThreshold:s/100,quietHours:_?{startHour:b,endHour:C,timezone:T}:null,allowedActions:D?[`create_project_task`]:[]}),i(!1)}catch(e){M(e instanceof Error?e.message:t.saveFailed)}finally{A(!1)}};return(0,Y.jsxs)(h,{open:r,onOpenChange:e=>{k||i(e)},children:[(0,Y.jsx)(l,{asChild:!0,children:(0,Y.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-9 gap-2 px-2.5 text-xs`,children:[(0,Y.jsx)(Le,{className:`size-3.5`,"aria-hidden":!0}),t.modes[e.mode]]})}),(0,Y.jsxs)(f,{children:[(0,Y.jsx)(c,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Y.jsxs)(p,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(36rem,calc(100vh-2rem))] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(m,{className:`text-base font-semibold text-fg`,children:t.title}),(0,Y.jsx)(u,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.description})]}),(0,Y.jsx)(d,{asChild:!0,children:(0,Y.jsx)(V,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:k,children:(0,Y.jsx)(P,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[(0,Y.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-fg-muted`,children:t.mode}),(0,Y.jsx)(y,{value:a,onChange:e=>o(e.target.value),children:Object.entries(t.modes).map(([e,t])=>(0,Y.jsx)(x,{value:e,children:t},e))})]}),(0,Y.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[t.confidence,` · `,s,`%`]}),(0,Y.jsx)(`input`,{type:`range`,min:`50`,max:`100`,step:`5`,value:s,onChange:e=>g(Number(e.target.value)),className:`accent-accent`})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border border-edge p-3`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),t.quietHours]}),_?(0,Y.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,Y.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietStart,(0,Y.jsx)(`input`,{type:`number`,min:`0`,max:`23`,value:b,onChange:e=>S(Number(e.target.value)),className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-fg`})]}),(0,Y.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietEnd,(0,Y.jsx)(`input`,{type:`number`,min:`0`,max:`23`,value:C,onChange:e=>w(Number(e.target.value)),className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-fg`})]}),(0,Y.jsxs)(`label`,{className:`col-span-2 grid gap-1 text-xs text-fg-muted`,children:[t.timezone,(0,Y.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-fg`})]})]}):null]}),(0,Y.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge p-3`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:D,onChange:e=>O(e.target.checked)}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:t.allowTaskCreation}),(0,Y.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.allowTaskCreationDescription})]})]})]}),(0,Y.jsxs)(`div`,{className:`shrink-0 border-t border-edge px-5 py-3`,children:[j?(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:j}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(d,{asChild:!0,children:(0,Y.jsx)(V,{type:`button`,variant:`ghost`,disabled:k,children:t.cancel})}),(0,Y.jsx)(V,{type:`button`,variant:`primary`,disabled:k||!T.trim()||b<0||b>23||C<0||C>23,onClick:()=>void N(),children:k?t.saving:t.save})]})]})]})]})]})}function jn(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}var Q={backlog:rt,ready:rt,active:Ce,review:At,closed:T},Mn={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 Nn(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 Pn(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 Fn(e){let t=(0,Yt.c)(83),{task:n,returnTo:r,copy:i,busy:a,onAction:o,onDragStart:c,onDropBefore:l}=e,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,E;t[0]!==c||t[1]!==l||t[2]!==r||t[3]!==n?(m=hn(n),h=m!==`review`&&n.allowedCommands.includes(`request_review`)?`review`:void 0,f=n.phase===`closed`,p=!!(n.dueAt&&n.dueAt<Date.now()&&!f),d=f?T:Tt,_=n.priority!==`normal`,g=_||n.operationalState!==`idle`||!!n.latestVerification||n.acceptanceCriteriaCount>0||!!n.dueAt||!!n.nextCheckAt,b=!0,t[20]!==c||t[21]!==n.id?(x=e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,n.id),c(n.id)},t[20]=c,t[21]=n.id,t[22]=x):x=t[22],t[23]===c?S=t[24]:(S=()=>c(``),t[23]=c,t[24]=S),C=Ln,t[25]!==l||t[26]!==n.id?(w=e=>{e.preventDefault(),e.stopPropagation(),l(n.id)},t[25]=l,t[26]=n.id,t[27]=w):w=t[27],E=`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?(v=Ke(r,n.id),t[28]=r,t[29]=n.id,t[30]=v):v=t[30],y=B(`block min-w-0 p-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,h?`pr-19`:m&&`pr-11`),t[0]=c,t[1]=l,t[2]=r,t[3]=n,t[4]=u,t[5]=d,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y,t[14]=b,t[15]=x,t[16]=S,t[17]=C,t[18]=w,t[19]=E):(u=t[4],d=t[5],f=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]);let D=f?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`,O;t[31]===D?O=t[32]:(O=B(`mt-0.5 size-4 shrink-0`,D),t[31]=D,t[32]=O);let k;t[33]!==d||t[34]!==O?(k=(0,Y.jsx)(d,{className:O,"aria-hidden":!0}),t[33]=d,t[34]=O,t[35]=k):k=t[35];let A=f?`text-fg-subtle`:`text-fg`,j;t[36]===A?j=t[37]:(j=B(`min-w-0 break-words text-sm font-semibold leading-5`,A),t[36]=A,t[37]=j);let M;t[38]!==j||t[39]!==n.title?(M=(0,Y.jsx)(`h3`,{className:j,children:n.title}),t[38]=j,t[39]=n.title,t[40]=M):M=t[40];let N;t[41]!==k||t[42]!==M?(N=(0,Y.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[k,M]}),t[41]=k,t[42]=M,t[43]=N):N=t[43];let P;t[44]!==i||t[45]!==n.attention||t[46]!==n.blockedBy||t[47]!==n.operationalState?(P=n.operationalState===`blocked`&&n.blockedBy.length>0?(0,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium`,children:[(0,Y.jsx)(fe,{className:`size-3.5`,"aria-hidden":!0}),i.blockedBy.replace(`{{count}}`,String(n.blockedBy.length))]}),(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 leading-5 text-fg-muted`,children:n.blockedBy.map(In).join(`、`)})]}):n.attention[0]?(0,Y.jsxs)(`p`,{className:`ml-6.5 mt-2.5 flex items-start gap-1.5 text-xs leading-5 text-fg-muted`,children:[(0,Y.jsx)(be,{className:`mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,Y.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]=P):P=t[48];let F;t[49]!==i||t[50]!==p||t[51]!==g||t[52]!==_||t[53]!==n.acceptanceCriteriaCount||t[54]!==n.dueAt||t[55]!==n.latestVerification||t[56]!==n.nextCheckAt||t[57]!==n.operationalState||t[58]!==n.priority?(F=g?(0,Y.jsxs)(`div`,{className:`ml-6.5 mt-2.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[_?(0,Y.jsx)(`span`,{className:B(`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,Y.jsx)(`span`,{className:B(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,Nn(n.operationalState)),children:i.operationalStates[n.operationalState]}),n.latestVerification?(0,Y.jsx)(`span`,{className:B(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,Pn(n.latestVerification)),children:i.verification[n.latestVerification]}):null,n.acceptanceCriteriaCount>0?(0,Y.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,Y.jsx)(Ce,{className:`size-3`,"aria-hidden":!0}),i.acceptanceCriteria.replace(`{{count}}`,String(n.acceptanceCriteriaCount))]}):null,n.dueAt?(0,Y.jsxs)(`span`,{className:B(`inline-flex min-h-6 items-center gap-1 rounded-md border px-2`,p?`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,Y.jsx)(K,{className:`size-3`,"aria-hidden":!0}),$e(new Date(n.dueAt))]}):null,n.nextCheckAt?(0,Y.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,Y.jsx)(K,{className:`size-3`,"aria-hidden":!0}),$e(new Date(n.nextCheckAt))]}):null]}):null,t[49]=i,t[50]=p,t[51]=g,t[52]=_,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]=F):F=t[59];let I;t[60]!==u||t[61]!==v||t[62]!==N||t[63]!==P||t[64]!==F||t[65]!==y?(I=(0,Y.jsxs)(u,{to:v,className:y,children:[N,P,F]}),t[60]=u,t[61]=v,t[62]=N,t[63]=P,t[64]=F,t[65]=y,t[66]=I):I=t[66];let L;t[67]!==a||t[68]!==i||t[69]!==o||t[70]!==m||t[71]!==h||t[72]!==n?(L=m?(0,Y.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:[h?(0,Y.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,h),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[h],title:i.actions[h],children:(0,Y.jsx)(At,{className:`size-3.5`,"aria-hidden":!0})}):null,(0,Y.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,m),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[m],title:i.actions[m],children:(0,Y.jsx)(W,{className:`size-3.5`,"aria-hidden":!0})})]}):null,t[67]=a,t[68]=i,t[69]=o,t[70]=m,t[71]=h,t[72]=n,t[73]=L):L=t[73];let R;return t[74]!==I||t[75]!==L||t[76]!==b||t[77]!==x||t[78]!==S||t[79]!==C||t[80]!==w||t[81]!==E?(R=(0,Y.jsxs)(`article`,{draggable:b,onDragStart:x,onDragEnd:S,onDragOver:C,onDrop:w,className:E,children:[I,L]}),t[74]=I,t[75]=L,t[76]=b,t[77]=x,t[78]=S,t[79]=C,t[80]=w,t[81]=E,t[82]=R):R=t[82],R}function In(e){return e.title}function Ln(e){e.preventDefault(),e.stopPropagation()}function Rn({tasks:e,dependencyEdges:t,monitoring:n,returnTo:r,copy:i,onAction:a,onReorder:o,onUndoMove:s,onDependenciesChange:l,onMonitoringChange:g,onCreate:_,actionBusyId:v,ref:b}){let S=(0,J.useRef)(null),C=(0,J.useRef)(null),[w,T]=(0,J.useState)(null),[E,D]=(0,J.useState)(!1),[O,k]=(0,J.useState)(null),[A,j]=(0,J.useState)(`board`),[M,N]=(0,J.useState)(!1),[P,F]=(0,J.useState)(()=>crypto.randomUUID()),[L,z]=(0,J.useState)(``),[H,U]=(0,J.useState)(`normal`),[W,G]=(0,J.useState)(``),[ee,te]=(0,J.useState)([]),[K,re]=(0,J.useState)(!1),[ie,ae]=(0,J.useState)(null),q=ye({chat:I(R(e=>e.language)).chat}),oe=pn(e),se=e.filter(e=>e.phase!==`closed`),ce=(e,t)=>void a(e,t),le=async(t,n)=>{let r=e.find(e=>e.id===w);if(T(null),!r||r.id===n)return;let i=oe[r.phase],s=i.findIndex(e=>e.id===r.id),c=s>=0?i[s+1]?.id??null:null;if(r.phase===t&&c===n)return;let l=mn(r,t);r.phase!==t&&!l||l&&!await a(r,l)||await o(r.id,n)&&k({taskId:r.id,phase:r.phase,beforeTaskId:c})},ue=async e=>{e.preventDefault();let t=L.trim();if(!(!t||K)){re(!0),ae(null);try{let e=W?new Date(`${W}T23:59:59.999`).getTime():void 0;await _({requestId:P,objective:t,priority:H,dependsOnTaskIds:ee,attachments:q.wireAttachmentsPayload(),...e===void 0?{}:{dueAt:e}}),z(``),U(`normal`),G(``),te([]),q.clearAttachments(),F(crypto.randomUUID()),N(!1)}catch(e){ae(e instanceof Error?e.message:i.createFailed)}finally{re(!1)}}},de=()=>{F(crypto.randomUUID()),z(``),U(`normal`),G(``),te([]),q.clearAttachments(),ae(null),N(!0)};(0,J.useImperativeHandle)(b,()=>({openCreate:de})),(0,J.useEffect)(()=>{if(!O)return;let e=window.setTimeout(()=>k(null),6e3);return()=>window.clearTimeout(e)},[O]);let fe=(0,J.useCallback)(e=>{let t=C.current;!t||t.pointerId!==e.pointerId||(C.current=null,D(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),pe=(0,J.useCallback)(e=>{if(e.button!==0||jn(e.target))return;let t=S.current;t&&(C.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},[]),me=(0,J.useCallback)(e=>{let t=C.current,n=S.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,D(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},[]);return(0,Y.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,Y.jsxs)(`div`,{className:`mb-4 flex shrink-0 flex-wrap items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:i.title}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.description})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Y.jsx)(An,{policy:n,copy:i.monitoring,onSave:g}),(0,Y.jsxs)(`div`,{className:`flex rounded-lg border border-edge bg-surface-panel p-0.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":A===`board`,onClick:()=>j(`board`),className:B(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,A===`board`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,Y.jsx)(De,{className:`size-3.5`,"aria-hidden":!0}),i.views.board]}),(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":A===`graph`,onClick:()=>j(`graph`),className:B(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,A===`graph`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,Y.jsx)(bt,{className:`size-3.5`,"aria-hidden":!0}),i.views.graph]})]})]})]}),A===`board`?(0,Y.jsx)(`div`,{ref:S,className:B(`min-h-0 w-full min-w-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-x-contain pb-2 [scrollbar-width:thin]`,E?`cursor-grabbing select-none`:`cursor-grab`),onPointerDown:pe,onPointerMove:me,onPointerUp:fe,onPointerCancel:fe,onLostPointerCapture:e=>{C.current?.pointerId===e.pointerId&&(C.current=null,D(!1))},children:(0,Y.jsx)(`div`,{className:`grid h-full min-h-0 min-w-[103rem] grid-cols-5 gap-3`,children:fn.map(t=>{let n=Q[t],a=oe[t];return(0,Y.jsxs)(`section`,{onDragOver:n=>{let r=e.find(e=>e.id===w);r&&(r.phase===t||mn(r,t))&&n.preventDefault()},onDrop:e=>{e.preventDefault(),le(t,null)},className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-muted/70 p-2.5`,children:[(0,Y.jsxs)(`header`,{className:`mb-2.5 flex shrink-0 items-center gap-2 px-0.5`,children:[(0,Y.jsxs)(`div`,{className:B(`flex items-center gap-1.5 rounded-md px-2 py-1`,Mn[t]),children:[(0,Y.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:i.phases[t]})]}),(0,Y.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.length})]}),(0,Y.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,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,Y.jsx)(Fn,{task:e,returnTo:r,copy:i,busy:v===e.id,onAction:ce,onDragStart:T,onDropBefore:e=>void le(t,e)},e.id))})})]},t)})})}):(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Y.jsx)(Cn,{tasks:e,dependencyEdges:t,returnTo:r,copy:{...i.graph,phases:i.phases},onDependenciesChange:l})}),(0,Y.jsx)(h,{open:M,onOpenChange:e=>{K||N(e)},children:(0,Y.jsxs)(f,{children:[(0,Y.jsx)(c,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Y.jsxs)(p,{className:`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-panel shadow-float focus:outline-none`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Y.jsx)(m,{className:`text-base font-semibold text-fg`,children:i.createTitle}),(0,Y.jsx)(u,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.createDescription})]}),(0,Y.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>void ue(e),children:[(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,Y.jsx)(`label`,{htmlFor:`project-task-objective`,className:`font-medium text-fg-muted`,children:i.objective}),(0,Y.jsxs)(`div`,{className:B(`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(),K||q.setIsDragging(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||q.setIsDragging(!1)},onDrop:e=>{e.preventDefault(),q.setIsDragging(!1),K||q.processFiles(Array.from(e.dataTransfer.files))},children:[(0,Y.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:L,onChange:e=>{z(e.target.value),ae(null)},placeholder:i.objectivePlaceholder,maxLength:12e3,disabled:K}),(0,Y.jsx)(ne,{attachments:q.attachments,topPadded:!1,onRemove:e=>{K||q.removeAttachment(e)}}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t border-edge-subtle px-2.5 py-2`,children:[(0,Y.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:K,onClick:()=>q.fileInputRef.current?.click(),children:[(0,Y.jsx)(st,{className:`size-3.5`,"aria-hidden":!0}),i.addFiles]}),(0,Y.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:i.attachmentsDescription}),(0,Y.jsx)(`input`,{ref:q.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{q.processFiles(Array.from(e.target.files??[])),e.currentTarget.value=``}})]})]})]}),(0,Y.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-fg-muted`,children:i.priority}),(0,Y.jsx)(y,{value:H,onChange:e=>U(e.target.value),disabled:K,children:[`low`,`normal`,`high`,`critical`].map(e=>(0,Y.jsx)(x,{value:e,children:i.priorityOptions[e]},e))})]}),(0,Y.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[i.dueDate,` `,(0,Y.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:i.optional})]}),(0,Y.jsx)(Lt,{className:`min-h-10 bg-surface-base`,value:W,onChange:G,disabled:K,ariaLabel:i.dueDate})]})]}),(0,Y.jsxs)(`fieldset`,{className:`grid gap-2`,children:[(0,Y.jsxs)(`legend`,{className:`text-sm font-medium text-fg-muted`,children:[i.dependencies,` `,(0,Y.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:i.optional})]}),(0,Y.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:i.dependenciesDescription}),(0,Y.jsx)(Jt,{candidates:se,selectedIds:ee,disabled:K,onChange:te,labels:{link:i.linkDependencies,linked:i.linkedDependencies,searchPlaceholder:i.dependencySearchPlaceholder,noMatches:i.noDependencyMatches,noCandidates:i.noDependencyCandidates,remove:i.removeDependency}})]}),ie?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ie}):null]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Y.jsx)(d,{asChild:!0,children:(0,Y.jsx)(V,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:K,children:i.cancel})}),(0,Y.jsx)(V,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:K||!L.trim(),children:K?i.creating:i.create})]})]})]})]})}),O?(0,Y.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,Y.jsx)(`span`,{children:i.moved}),(0,Y.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:()=>{let e=O;k(null),s(e.taskId,e.phase,e.beforeTaskId).then(t=>{t||k(e)})},children:i.undo})]}):null]})}var zn=new Set([{id:`overview`,icon:jt},{id:`tasks`,icon:Ve},{id:`automations`,icon:Ze},{id:`files`,icon:_t},{id:`notes`,icon:Ge},{id:`skills`,icon:re},{id:`sessions`,icon:j},{id:`progress`,icon:Fe},{id:`settings`,icon:me}].map(e=>e.id)),$=`xopc.projectFiles.panelWidthPx`,Bn=320,Vn=220,Hn=560;function Un(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 Wn(e){return Math.min(Hn,Math.max(Vn,Math.round(e)))}function Gn(){try{let e=window.localStorage.getItem($);if(e==null)return Bn;let t=Number.parseInt(e,10);return Number.isFinite(t)?Wn(t):Bn}catch{return Bn}}function Kn(e){try{window.localStorage.setItem($,String(Wn(e)))}catch{}}function qn(e){return!!(e&&zn.has(e))}function Jn(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Yn(e,t=``){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?String(e):$e(n)}function Xn(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-muted text-fg-subtle`:`bg-surface-hover text-fg-muted`}function Zn(e){let t=(0,Yt.c)(8),{label:n,hint:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Y.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,Y.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,Y.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 Qn(e=!1){return B(`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 $n(e){let t=(0,Yt.c)(10),{label:n,value:r,mono:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,Y.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=B(`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,Y.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,Y.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 er(e){return[e.name,e.slug,e.workspaceRoot,e.description,e.brief].filter(Boolean).join(` `).toLowerCase()}function tr(e){let t=e.lastActiveAt??e.updatedAt??e.createdAt,n=t?new Date(t).getTime():0;return Number.isFinite(n)?n:0}function nr(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function rr(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function ir(e){let t=e.actor;return t.name?t.name:t.agentId?t.agentId:t.id?t.id:t.sessionKey?t.sessionKey:t.kind}function ar(e){return e.primaryObject.title?.trim()||e.primaryObject.id}function or(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 sr(e){let t=e.sourceChannel?.trim();if(t)return cr(t);let n=e.key.split(`:`).filter(Boolean),r=(n[0]?.toLowerCase()===`agent`?n.slice(2).join(`:`):e.key).split(`:`)[0]?.split(/[-_]/)[0]?.trim();return cr(r||``)}function cr(e){let t=e.trim().toLowerCase();return t?t===`tui`?`TUI`:t===`acp`?`ACP`:t===`webchat`?`Webchat`:t:``}function lr(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 ur(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 dr(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:dr(e.children,t,n)}:e)}function fr({currentProject:e,pm:t,projectsText:n,wd:r}){let i=a(),[o,s]=(0,J.useState)(!1),[l,y]=(0,J.useState)([e]),[b,x]=(0,J.useState)(``),[C,T]=(0,J.useState)(!1),[E,D]=(0,J.useState)(null),[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(`new`),[P,F]=(0,J.useState)(``),[I,L]=(0,J.useState)(``),[R,z]=(0,J.useState)(!1),[H,U]=(0,J.useState)(null),[W,G]=(0,J.useState)(null),ee=(0,J.useCallback)(async()=>{T(!0),D(null);try{let t=await Ae({limit:100});y(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){D(e instanceof Error?e.message:String(e))}finally{T(!1)}},[e]);(0,J.useEffect)(()=>{y(t=>[e,...t.filter(t=>t.id!==e.id)])},[e]),(0,J.useEffect)(()=>{o&&ee()},[ee,o]);let te=(0,J.useMemo)(()=>{let t=b.trim().toLowerCase().split(/\s+/).filter(Boolean);return l.filter(t=>t.id!==e.id).filter(e=>{if(t.length===0)return!0;let n=er(e);return t.every(e=>n.includes(e))}).sort((e,t)=>tr(t)-tr(e))},[e.id,l,b]),ne=e=>t.statuses[e.status]??e.status,K=e=>e.workspaceRoot||e.effectiveWorkspaceRoot||e.description||e.brief||t.common.defaultWorkspace,re=e=>{j(e),F(``),L(``),U(null),k(!0),s(!1)},ie=(0,J.useCallback)(async(e={})=>{let t=I.trim(),n=P.trim()||(A===`directory`?nr(t):``);if(n){z(!0),U(null),G(null);try{let r=await et({name:n,...t?{workspaceRoot:t}:{},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});k(!1),F(``),L(``),y(e=>[r,...e.filter(e=>e.id!==r.id)]),i(`/projects/${encodeURIComponent(r.id)}`)}catch(e){let t=rr(e);t?(G(t),k(!1)):U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[A,P,i,I]),ae=(0,J.useCallback)(e=>{e.preventDefault(),ie()},[ie]),q=(0,J.useCallback)(()=>{ie({createWorkspaceRoot:!0})},[ie]),oe=(0,J.useCallback)(()=>{G(null),k(!0)},[]),se=e=>{L(e),A===`directory`&&!P.trim()&&F(nr(e))},ce=(e,t)=>(0,Y.jsxs)(`button`,{type:`button`,className:B(`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||i(`/projects/${encodeURIComponent(e.id)}`)},children:[(0,Y.jsx)(g,{className:B(`size-4 text-accent-fg`,!t&&`invisible`),"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,Y.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:K(e)})]}),(0,Y.jsx)(`span`,{className:B(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,Xn(e.status)),children:ne(e)})]},e.id);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(v,{open:o,onOpenChange:s,children:[(0,Y.jsx)(w,{asChild:!0,children:(0,Y.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,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:e.name}),(0,Y.jsx)(`span`,{className:B(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,Xn(e.status)),children:ne(e)})]}),(0,Y.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:K(e)})]}),(0,Y.jsx)(ge,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]})}),(0,Y.jsx)(_,{children:(0,Y.jsxs)(S,{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,Y.jsxs)(`label`,{className:`relative block`,children:[(0,Y.jsx)(N,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,Y.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:b,onChange:e=>x(e.target.value),placeholder:t.projectSwitcher.searchPlaceholder,"aria-label":t.projectSwitcher.searchPlaceholder})]}),(0,Y.jsxs)(`div`,{className:`mt-1 max-h-[min(54vh,24rem)] overflow-y-auto pr-0.5 [scrollbar-gutter:stable]`,children:[(0,Y.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.current}),ce(e,!0),(0,Y.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.recent}),E?(0,Y.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:E}):null,C&&te.length===0?(0,Y.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.loading}):null,!C&&te.length===0?(0,Y.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.noMatches}):null,te.map(e=>ce(e,!1))]}),(0,Y.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:[(0,Y.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:()=>re(`new`),children:[(0,Y.jsx)(M,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.newProject})]}),(0,Y.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:()=>re(`directory`),children:[(0,Y.jsx)(_t,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.openDirectory})]}),(0,Y.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),i(`/projects`)},children:[(0,Y.jsx)(me,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.manageProjects})]})]})]})})]}),(0,Y.jsx)(h,{open:O,onOpenChange:e=>!R&&k(e),children:(0,Y.jsxs)(f,{children:[(0,Y.jsx)(c,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Y.jsxs)(p,{className:`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-panel shadow-float focus:outline-none`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Y.jsx)(m,{className:`text-base font-semibold text-fg`,children:A===`directory`?t.projectSwitcher.createFromDirectoryTitle:n.createTitle}),(0,Y.jsx)(u,{className:`mt-1 text-sm text-fg-muted`,children:A===`directory`?t.projectSwitcher.createFromDirectoryDescription:n.createDescription})]}),(0,Y.jsxs)(`form`,{onSubmit:ae,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[H?(0,Y.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:H}):null,(0,Y.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,Y.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:P,onChange:e=>F(e.target.value),placeholder:`xopc`})]}),(0,Y.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,Y.jsx)(Zt,{value:I,onChange:se,disabled:R,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,Y.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Y.jsx)(d,{asChild:!0,children:(0,Y.jsx)(V,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:R,children:n.cancel})}),(0,Y.jsxs)(V,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:R||!(P.trim()||A===`directory`&&nr(I)),children:[(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})}),(0,Y.jsx)(h,{open:!!W,onOpenChange:e=>{e||G(null)},children:(0,Y.jsxs)(f,{children:[(0,Y.jsx)(c,{className:`fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,Y.jsxs)(p,{className:`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-panel shadow-float focus:outline-none`,children:[(0,Y.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,Y.jsx)(m,{className:`text-base font-semibold text-fg`,children:n.workspaceMissingTitle}),(0,Y.jsx)(u,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:W?Jn(n.workspaceMissingDescription,{workspace:W}):null})]}),W?(0,Y.jsx)(`div`,{className:`px-5 py-4`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,Y.jsx)(_t,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:W})]})}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Y.jsx)(V,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:oe,disabled:R,children:n.workspaceMissingBack}),(0,Y.jsxs)(V,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:q,disabled:R,children:[(0,Y.jsx)(tt,{className:`size-4`,"aria-hidden":!0}),n.workspaceMissingCreate]})]})]})]})})]})}function pr(){let{projectId:e=``,tabId:t,noteId:n}=i(),r=a(),[l]=o(),g=R(e=>e.language),_=I(g),v=_.chat.workingDirectory,b=_.projectDetailPage,S=_.projectsPage,C=dt(e=>e.setPageHeader),w=dt(e=>e.clearPageHeader),[T,D]=(0,J.useState)(null),[O,L]=(0,J.useState)(null),[z,H]=(0,J.useState)([]),[W,ne]=(0,J.useState)(``),[K,ae]=(0,J.useState)([]),[ce,ue]=(0,J.useState)(0),[de,fe]=(0,J.useState)(!1),[ge,ve]=(0,J.useState)(!1),[ye,Ce]=(0,J.useState)(!1),[we,De]=(0,J.useState)([]),[Oe,Ae]=(0,J.useState)(null),Le=(0,J.useRef)(new Set),[Re,$e]=(0,J.useState)(null),[et,rt]=(0,J.useState)(null),[st,ft]=(0,J.useState)(Gn),[vt,Tt]=(0,J.useState)(!1),[Ot,At]=(0,J.useState)(!1),[Mt,Lt]=(0,J.useState)(``),[Rt,zt]=(0,J.useState)([]),[Bt,Vt]=(0,J.useState)(!1),[Ht,Ut]=(0,J.useState)(null),[Gt,Kt]=(0,J.useState)(!1),[qt,Jt]=(0,J.useState)(null),[Yt,Xt]=(0,J.useState)([]),[Qt,$t]=(0,J.useState)(``),[en,tn]=(0,J.useState)(!0),[nn,rn]=(0,J.useState)(!1),[an,sn]=(0,J.useState)(!1),[cn,ln]=(0,J.useState)(null),[un,dn]=(0,J.useState)(!1),[fn,pn]=(0,J.useState)(`fixed`),[mn,hn]=(0,J.useState)(``),[gn,_n]=(0,J.useState)(null),[vn,yn]=(0,J.useState)(!1),[bn,xn]=(0,J.useState)(!1),[Sn,Cn]=(0,J.useState)(null),wn=(0,J.useRef)(null),Tn=(0,J.useRef)(!1),[En,X]=(0,J.useState)(null),[Dn,On]=(0,J.useState)({title:``,reason:``}),[Z,kn]=(0,J.useState)({name:``,description:``,status:`active`,defaultAgentId:``,executionMode:`local_checkout`,workspaceRoot:``,brief:``,instructions:``}),An=(0,J.useRef)(Z),jn=`overview`,Q=n?`notes`:qn(t)?t:jn,Mn=(0,J.useMemo)(()=>k(l.get(`returnTo`),`/projects`,[`/chat`]),[l]),Nn=(0,J.useCallback)(t=>{if(!e)return`/projects`;let n=`/projects/${encodeURIComponent(e)}/${t}`;return Mn===`/projects`?n:A(n,Mn)},[Mn,e]),Pn=(0,J.useCallback)(t=>{e&&r(Nn(t))},[r,e,Nn]),Fn=(0,J.useCallback)(()=>{if(Q===`tasks`&&wn.current){wn.current.openCreate();return}Tn.current=!0,Pn(`tasks`)},[Pn,Q]);(0,J.useEffect)(()=>{Q!==`tasks`||!Tn.current||(Tn.current=!1,wn.current?.openCreate())},[Q]);let In=(0,J.useCallback)(t=>{e&&r(Nn(t),{replace:!0})},[r,e,Nn]),Ln=(0,J.useCallback)(e=>t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||In(e)},[In]),zn=(0,J.useCallback)(e=>e.startsWith(`/chat/`)?`sessions`:e.startsWith(`/notes`)?`notes`:Q,[Q]);(0,J.useEffect)(()=>{!e||!t||qn(t)||r(Nn(jn),{replace:!0})},[jn,r,e,Nn,t]),(0,J.useEffect)(()=>{if(!e)return;let t=!1;return tn(!0),X(null),Promise.all([kt(e),ke(e),wt(e),ht().catch(()=>null),ie(e).catch(()=>null)]).then(([e,n,r,i,a])=>{if(t)return;D(e),L(n),H(r),Ae(a),Xt(i?.agents??[]),$t(e.defaultAgentId??``);let o={name:e.name,description:e.description??``,status:e.status,defaultAgentId:e.defaultAgentId??``,executionMode:e.executionMode,workspaceRoot:e.workspaceRoot??``,brief:e.brief??``,instructions:e.instructions??``};An.current=o,kn(o)}).catch(e=>{t||(Ae(null),X(e instanceof Error?e.message:String(e)))}).finally(()=>{t||tn(!1)}),()=>{t=!0}},[e]);let $=(0,J.useCallback)(async()=>{e&&L(await ke(e))},[e]);(0,J.useEffect)(()=>{let t,n=n=>{let r=St.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void $(),120))},r=n=>{let r=Je.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void $(),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,$]);let Bn=(0,J.useCallback)(async(e,t)=>{Cn(e.id),X(null);try{let n=await ze(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 Ie(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 le(e.id,r,n.task.version),await $(),!0}catch(e){return await $().catch(()=>void 0),X(e instanceof Error?e.message:b.board.actionFailed),!1}finally{Cn(null)}},[O,b.board.actionFailed,$]),Vn=(0,J.useCallback)(async t=>{e&&(X(null),await he({idempotencyKey:t.requestId,title:t.objective,projectId:e,priority:t.priority,dueAt:t.dueAt,locale:g,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 $())},[g,e,$]),Hn=(0,J.useCallback)(async(e,t)=>{Cn(e),X(null);try{return await He(e,t,(await ze(e)).task.version),await $(),!0}catch(e){return await $().catch(()=>void 0),X(e instanceof Error?e.message:b.board.actionFailed),!1}finally{Cn(null)}},[b.board.actionFailed,$]),er=(0,J.useCallback)(async(e,t,n)=>{Cn(e),X(null);try{let r=await ze(e);return r.task.phase!==t&&(r=await le(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 He(e,n,r.task.version),await $(),!0}catch(e){return await $().catch(()=>void 0),X(e instanceof Error?e.message:b.board.actionFailed),!1}finally{Cn(null)}},[b.board.actionFailed,$]),tr=(0,J.useCallback)(async(e,t)=>{Cn(e),X(null);try{await pt(e,t,(await ze(e)).task.version),await $()}catch(e){await $().catch(()=>void 0),X(e instanceof Error?e.message:b.board.actionFailed)}finally{Cn(null)}},[b.board.actionFailed,$]),nr=(0,J.useCallback)(async t=>{if(e){X(null);try{await _e(e,t),await $()}catch(e){throw X(e instanceof Error?e.message:b.board.actionFailed),e}}},[b.board.actionFailed,e,$]),cr=(0,J.useCallback)(async()=>{if(T){fe(!0),X(null);try{let e=await Ue(T.id,{includeRelated:ge,limit:100});ae(e.items),ue(e.total)}catch(e){X(e instanceof Error?e.message:String(e))}finally{fe(!1)}}},[T,ge]);(0,J.useEffect)(()=>{Q===`progress`&&cr()},[cr,Q]);let pr=(0,J.useCallback)(async()=>{if(!T?.effectiveWorkspaceRoot?.trim()){De([]),Le.current.clear(),Jt(null);return}Kt(!0),Jt(null),Le.current.clear();try{De(ur((await Dt(T.id,``)).entries)),Le.current.add(``)}catch(e){De([]),Le.current.clear(),Jt(e instanceof Error?e.message:String(e))}finally{Kt(!1)}},[T]),mr=(0,J.useCallback)(async e=>{if(!(!T?.effectiveWorkspaceRoot?.trim()||Le.current.has(e))){Le.current.add(e),Jt(null);try{let t=await Dt(T.id,e);De(n=>dr(n,e,ur(t.entries)))}catch(t){Le.current.delete(e),Jt(t instanceof Error?t.message:String(t))}}},[T]);(0,J.useEffect)(()=>{Q===`files`&&pr()},[pr,Q]);let hr=Mt.trim();(0,J.useEffect)(()=>{if(Q!==`files`||!T||!Ot||!hr){zt([]),Vt(!1),Ut(null);return}let e=!1;Vt(!0),Ut(null),zt([]);let t=window.setTimeout(()=>{at(T.id,hr,50).then(t=>{e||zt(t)}).catch(t=>{e||Ut(t instanceof Error?t.message:String(t))}).finally(()=>{e||Vt(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[hr,T,Ot,Q]);let gr=(0,J.useCallback)(async()=>{if(!T)return;let[e,t]=await Promise.all([kt(T.id),ke(T.id)]);L(t),D(e)},[T]),_r=(0,J.useCallback)(async e=>{if(e.preventDefault(),!(!T||!Dn.title.trim())){xn(!0),X(null);try{await Qe(T.id,{title:Dn.title.trim(),reason:Dn.reason.trim()||void 0}),On({title:``,reason:``}),await gr()}catch(e){X(e instanceof Error?e.message:String(e))}finally{xn(!1)}}},[Dn.reason,Dn.title,T,gr]),vr=(0,J.useMemo)(()=>(0,Y.jsx)(s,{to:Mn,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":Mn===`/projects`?b.backToProjects:_.sidebar.back,children:(0,Y.jsx)(Xe,{className:`size-4`,"aria-hidden":!0})}),[Mn,_.sidebar.back,b.backToProjects]),yr=(0,J.useMemo)(()=>T?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(V,{asChild:!0,variant:`secondary`,className:`h-9 rounded-lg`,children:(0,Y.jsxs)(s,{to:`/workflows?tab=library&projectId=${encodeURIComponent(T.id)}`,children:[(0,Y.jsx)(bt,{className:`size-4`,"aria-hidden":!0}),b.common.runWorkflow]})}),(0,Y.jsxs)(V,{variant:`secondary`,className:`h-9 rounded-lg`,onClick:Fn,children:[(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":!0}),b.board.create]}),(0,Y.jsx)(V,{asChild:!0,variant:`primary`,className:`h-9 rounded-lg`,children:(0,Y.jsxs)(s,{to:Me(T.id),state:{forceNewChat:!0,agentId:T.defaultAgentId},onClick:Ln(`sessions`),children:[(0,Y.jsx)(j,{className:`size-4`,"aria-hidden":!0}),b.common.newChat]})})]}):null,[Fn,Ln,b.board.create,b.common.newChat,b.common.runWorkflow,T]);(0,J.useLayoutEffect)(()=>(C({startExtra:vr,main:T?(0,Y.jsx)(fr,{currentProject:T,pm:b,projectsText:S,wd:v}):(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:b.fallbackTitle}),(0,Y.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:b.fallbackContext})]}),end:yr}),()=>w()),[w,yr,vr,b,T,S,C,v]);function br(e){D(t=>t?{...t,...e}:null),$t(e.defaultAgentId??``),ie(e.id).then(Ae).catch(()=>Ae(null)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}async function xr(e=An.current){if(!(!T||!Un(e,T))){X(null),ln(null);try{let t=await nt(T.id,{name:e.name.trim(),status:e.status,description:e.description,defaultAgentId:e.defaultAgentId,executionMode:e.executionMode,brief:e.brief,instructions:e.instructions});br(t);let n=An.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};An.current=r,kn(r)}catch(e){let t=rr(e);throw t?ln(t):X(e instanceof Error?e.message:String(e)),e}}}function Sr(e){e.preventDefault(),Ir.flush()}function Cr(e,t=!1){let n={...An.current,...e};An.current=n,kn(n),t&&Ir.saveNow(n)}let wr=(0,J.useCallback)(()=>{if(!T)return;let e=T.workspaceRoot?.trim()??``;pn(e?`fixed`:`follow`),hn(e||T.effectiveWorkspaceRoot||``),dn(!0)},[T]);async function Tr(e={}){if(!T)return;let t=fn===`fixed`?mn.trim():``;if(!(fn===`fixed`&&!t)){rn(!0),X(null),ln(null);try{let n=await nt(T.id,{workspaceRoot:t,...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});br(n),Cr({workspaceRoot:n.workspaceRoot??``}),dn(!1),ln(null)}catch(e){let t=rr(e);t?(ln(t),dn(!1)):X(e instanceof Error?e.message:String(e))}finally{rn(!1)}}}async function Er(){if(!(!T||gn)){_n(`pin`),X(null);try{br(T.pinnedAt?await te(T.id):await oe(T.id))}catch(e){X(e instanceof Error?e.message:String(e))}finally{_n(null)}}}async function Dr(){if(!(!T||gn)){_n(`archive`),X(null);try{let e=T.status===`archived`?await q(T.id):await ct(T.id);br(e),Cr({status:e.status})}catch(e){X(e instanceof Error?e.message:String(e))}finally{_n(null)}}}async function Or(){if(T){yn(!0),X(null);try{await Ct(T.id),sn(!1),r(`/projects`)}catch(e){X(e instanceof Error?e.message:String(e))}finally{yn(!1)}}}async function kr(){if(!(!T||ye)){Ce(!0),X(null);try{await Se(T.id)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Ce(!1)}}}let Ar=(0,J.useCallback)(e=>{$e(e)},[]),jr=(0,J.useCallback)((e,t)=>{t||$e(e)},[]),Mr=(0,J.useCallback)(async(e,t,n)=>{let r=T?.id;if(r)switch(e){case`preview`:t.isDirectory||$e(t.path);break;case`download`:if(t.isDirectory)return;try{let e=pe(t.path);if(Pe(mt(e))!==`text`){let n=await G(t.path,{projectId:r}),i=je(e)??`application/octet-stream`;Be(e,await n.arrayBuffer(),i)}else{let{content:n}=await Ye(t.path,{projectId:r});Te(e,n)}}catch(e){ot(`warning`,e instanceof Error?e.message:String(e),void 0,{duration:4e3})}break;case`copyPath`:try{await F(t.path)&&ot(`success`,_.workspace.pathCopied,void 0,{duration:2500})}catch{ot(`warning`,_.clipboard.copyFailed,void 0,{duration:4e3})}break;case`openDefault`:await xe(()=>window.electronAPI?.shell?.openFileResource?.(t.fileId),_.workspace.openFileFailed);break;case`openWith`:await xe(()=>window.electronAPI?.shell?.chooseAppAndOpenFileResource?.(t.fileId),_.workspace.openFileFailed);break;case`openWithApp`:if(!n)return;await xe(()=>window.electronAPI?.shell?.openFileResourceWithApp?.(t.fileId,n),_.workspace.openFileFailed);break;case`revealInFolder`:await xe(()=>window.electronAPI?.shell?.showFileResourceInFolder?.(t.fileId),_.workspace.revealFileFailed);break;case`trash`:rt(t);break;default:break}},[_.clipboard.copyFailed,_.workspace.openFileFailed,_.workspace.pathCopied,_.workspace.revealFileFailed,T?.id]),Nr=(0,J.useCallback)(async()=>{let e=et;if(!e)return;let t=await window.electronAPI?.shell?.trashFileResource?.(e.fileId);if(!t?.ok){ot(`warning`,t?.error??_.workspace.trashFailed,void 0,{duration:4e3});return}Re===e.path&&$e(null),rt(null),await pr(),ot(`success`,_.workspace.trashSuccess,void 0,{duration:2500})},[_.workspace.trashFailed,_.workspace.trashSuccess,et,Re,pr]),Pr=(0,J.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),Tt(!0);let r=e.clientX,i=st,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=Wn(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(l))},d=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}Tt(!1),ft(c),Kn(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)},[st]);(0,J.useEffect)(()=>{Q!==`files`&&$e(null)},[e,Q]);let Fr=!!(T&&Un(Z,T)),Ir=Ft({value:T?Z:null,dirty:Fr,onSave:xr,validate:e=>e.name.trim()?null:b.settings.nameRequired});if(en)return(0,Y.jsx)(`main`,{className:`w-full flex-1 p-3 text-sm text-fg-muted sm:px-5 sm:py-4 xl:px-6`,children:b.loading});if(!T)return(0,Y.jsxs)(`main`,{className:`w-full flex-1 p-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,Y.jsxs)(s,{to:Mn,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,Y.jsx)(Xe,{className:`size-4`,"aria-hidden":!0}),Mn===`/projects`?b.backToProjects:_.sidebar.back]}),(0,Y.jsx)(`p`,{className:`mt-6 rounded-lg bg-surface-panel p-4 shadow-surface text-sm text-fg-muted`,children:En||b.notFound})]});let Lr=z.slice(0,6),Rr=O?.blockers??[],zr=O?.tasks.filter(e=>e.phase!==`closed`)??[],Br=e=>b.statuses[e]??e,Vr=e=>Jn(b.common.messages,{count:e}),Hr=W.trim().toLowerCase(),Ur=Hr?z.filter(e=>{let t=Yn(e.updatedAt),n=e.routing?.agentId||e.agentId||b.common.agent,r=e.name?.trim()||b.sessions.fallbackTitle,i=Vr(e.messageCount??0),a=sr(e);return[r,e.key,n,a,t,i].filter(Boolean).join(` `).toLowerCase().includes(Hr)}):z,Wr=z.length>0&&Ur.length===0,Gr=Yt.find(e=>e.id===T.defaultAgentId)?.name||T.defaultAgentId||b.settings.globalDefaultAgent,Kr=Yt.find(e=>e.id===Z.defaultAgentId),qr=T.workspaceRoot?.trim()||``,Jr=T.status===`archived`,Yr=!!T.pinnedAt,Xr=!qr,Zr=qr||Kr?.workspace||T.effectiveWorkspaceRoot||b.common.defaultWorkspace,Qr=fn===`fixed`?mn.trim()||b.settings.workspacePlaceholder:Kr?.workspace||T.effectiveWorkspaceRoot||b.common.defaultWorkspace,$r=(fn===`fixed`?mn.trim():``)!==qr&&(fn===`follow`||!!mn.trim()),ei=[{id:`overview`,icon:jt,label:b.tabs.overview},{id:`tasks`,icon:Ve,label:b.tabs.tasks},{id:`automations`,icon:Ze,label:b.tabs.automations},{id:`files`,icon:_t,label:b.tabs.files},{id:`notes`,icon:Ge,label:b.tabs.notes},{id:`skills`,icon:re,label:b.tabs.skills},{id:`sessions`,icon:j,label:b.tabs.sessions},{id:`progress`,icon:Fe,label:b.tabs.progress}];async function ti(){if(!Zr)return;let e=await F(Zr);ot(e?`success`:`warning`,e?_.workspace.pathCopied:_.clipboard.copyFailed,void 0,{duration:e?2500:4e3})}function ni(){ln(null),dn(!0)}return(0,Y.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,Y.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3`,children:[(0,Y.jsx)(It,{items:ei,activeTab:Q,onChange:Pn,ariaLabel:b.navAria,tabIdPrefix:`project-primary-tab`,className:`min-w-0 flex-1`}),(0,Y.jsxs)(V,{id:`project-primary-tab-settings`,type:`button`,variant:Q===`settings`?`secondary`:`ghost`,className:`h-9 shrink-0 rounded-lg px-3`,"aria-current":Q===`settings`?`page`:void 0,onClick:()=>Pn(`settings`),children:[(0,Y.jsx)(me,{className:`size-4`,"aria-hidden":!0}),b.tabs.settings,Fr?(0,Y.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-label":b.settings.unsavedChanges}):null]})]}),En?(0,Y.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:En}):null,(0,Y.jsxs)(`div`,{className:B(`mt-3 min-h-0 flex-1`,Q===`overview`?`overflow-y-auto pr-1 [scrollbar-gutter:stable] xl:overflow-hidden xl:pr-0`:Q===`tasks`?`overflow-hidden`:`overflow-y-auto pr-1 [scrollbar-gutter:stable]`),children:[Q===`overview`?(0,Y.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,Y.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,Y.jsx)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.overview.directionTitle}),(0,Y.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:T.outcome||O?.digest.summary||T.description||T.brief||b.overview.directionFallback}),O?.digest.recommendedAction?(0,Y.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm font-medium leading-6 text-fg`,children:Jn(b.overview.recommendedNext,{action:O.digest.recommendedAction})}):null]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:(0,Y.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>void kr(),disabled:ye,children:[(0,Y.jsx)(Ee,{className:`size-4`,"aria-hidden":!0}),ye?b.overview.savingDigest:b.overview.saveDigest]})})]})}),(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel shadow-surface`,children:[(0,Y.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.overview.nextActions})}),(0,Y.jsx)(`div`,{className:`divide-y divide-edge`,children:zr.length?zr.map(e=>(0,Y.jsxs)(s,{to:Ke(Nn(`overview`),e.id),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,Y.jsxs)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:[e.phase,` · `,e.operationalState]})]}),e.attention[0]?(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.attention[0].summary}):null]},e.id)):(0,Y.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:b.overview.noNextActions})})]}),O?.recentResults.length?(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel shadow-surface`,children:[(0,Y.jsx)(`div`,{className:`border-b border-edge px-4 py-3`,children:(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.overview.recentResults})}),(0,Y.jsx)(`div`,{className:`divide-y divide-edge`,children:O.recentResults.slice(0,5).map(({taskId:e,taskTitle:t,receipt:n})=>(0,Y.jsxs)(s,{to:Ke(Nn(`overview`),e),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),(0,Y.jsxs)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:[n.status,` · `,n.verification.status]})]}),(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:n.summary})]},n.runId))})]}):null,(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 md:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{className:`rounded-lg bg-surface-panel shadow-surface`,children:[(0,Y.jsx)(`div`,{className:`border-b border-edge px-4 py-3`,children:(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.overview.milestones})}),(0,Y.jsx)(`div`,{className:`divide-y divide-edge`,children:T.milestones.length?T.milestones.map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.status})]},e.id)):(0,Y.jsx)(`p`,{className:`px-4 py-5 text-sm text-fg-muted`,children:b.overview.noMilestones})})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg bg-surface-panel shadow-surface`,children:[(0,Y.jsx)(`div`,{className:`border-b border-edge px-4 py-3`,children:(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.overview.projectUpdates})}),(0,Y.jsx)(`div`,{className:`divide-y divide-edge`,children:T.recentUpdates.length?T.recentUpdates.slice(0,3).map(e=>(0,Y.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm leading-5 text-fg`,children:e.summary}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.health})]},e.id)):(0,Y.jsx)(`p`,{className:`px-4 py-5 text-sm text-fg-muted`,children:b.overview.noProjectUpdates})})]})]})]}),(0,Y.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,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.overview.attention}),Rr.length?(0,Y.jsx)(`div`,{className:`mt-3 grid gap-3`,children:Rr.map(e=>{let t=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(be,{className:`size-4 text-amber-600 dark:text-amber-300`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title})]}),(0,Y.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:[b.overview.attentionKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:e.status?` · ${Br(e.status)}`:``]})]});return e.href?(0,Y.jsx)(s,{to:e.href,onClick:Ln(zn(e.href)),className:`min-w-0 rounded-md bg-surface-base p-3 hover:bg-surface-hover`,children:t},e.id):(0,Y.jsx)(`div`,{className:`min-w-0 rounded-md bg-surface-base p-3`,children:t},e.id)})}):(0,Y.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:b.overview.noBlockedTasks}),(0,Y.jsxs)(`form`,{onSubmit:_r,className:`mt-4 flex gap-2 border-t border-edge pt-4`,children:[(0,Y.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:Dn.title,onChange:e=>On(t=>({...t,title:e.target.value})),placeholder:b.overview.blockerTitlePlaceholder}),(0,Y.jsx)(V,{type:`submit`,variant:`secondary`,className:`shrink-0 rounded-lg px-3`,disabled:bn||!Dn.title.trim(),"aria-label":bn?b.overview.addingBlocker:b.overview.addBlocker,title:bn?b.overview.addingBlocker:b.overview.addBlocker,children:(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel shadow-surface`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(We,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Y.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:b.overview.recentSessions})]}),(0,Y.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>Pn(`sessions`),children:b.common.viewAll})]}),(0,Y.jsx)(`div`,{className:`divide-y divide-edge`,children:Lr.length?Lr.map(e=>(0,Y.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Ln(`sessions`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:Yn(e.updatedAt)})]}),(0,Y.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.agentId||b.common.agent})]},e.key)):(0,Y.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:b.overview.noSessions})})]})]})]}):null,Q===`tasks`?(0,Y.jsx)(Rn,{ref:wn,tasks:O?.tasks??[],dependencyEdges:O?.dependencyEdges??[],monitoring:O?.monitoring??{projectId:e??``,mode:`observe`,allowedActions:[],confidenceThreshold:.75,scenarios:[],configured:!1},returnTo:Nn(`tasks`),copy:b.board,onAction:Bn,onReorder:Hn,onUndoMove:er,onDependenciesChange:tr,onMonitoringChange:nr,onCreate:Vn,actionBusyId:Sn}):null,Q===`automations`?(0,Y.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,Y.jsx)(Wt,{projectId:T.id,embedded:!0,title:b.automations.title,subtitle:b.automations.hint})}):null,Q===`notes`?(0,Y.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,Y.jsx)(Nt,{selectedNoteId:n,basePath:`/projects/${encodeURIComponent(T.id)}/notes`,showLibrary:!1,allowMediaCapture:!1,projectId:T.id,listTitle:b.notes.title,listDescription:b.notes.hint,emptyText:b.notes.emptyTitle,emptyDescription:b.notes.emptyDescription,listWidthStorageKey:`xopc.projectNotes.listWidth.${T.id}`})}):null,Q===`skills`?(0,Y.jsx)(on,{projectId:T.id,copy:b.skills}):null,Q===`files`?(0,Y.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,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:T.effectiveWorkspaceRoot?(0,Y.jsxs)(`div`,{"data-project-files-grid":!0,className:B(`grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[var(--project-files-panel-width)_6px_minmax(0,1fr)]`,vt&&`cursor-col-resize select-none`),style:{"--project-files-panel-width":`${st}px`},children:[(0,Y.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-b border-edge lg:border-b-0 lg:border-r`,children:[(0,Y.jsxs)(`div`,{className:`flex h-11 items-center gap-1 border-b border-edge bg-surface-muted/50 px-3 text-sm`,children:[Oe?(0,Y.jsx)(it,{resourceId:Oe.fileId,displayName:Oe.name}):null,(0,Y.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,Y.jsx)(`button`,{type:`button`,className:B(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,Ot&&`bg-surface-hover text-fg`),onClick:()=>At(!0),"aria-label":b.files.search,title:b.files.search,"aria-pressed":Ot,children:(0,Y.jsx)(N,{className:`size-3.5`,"aria-hidden":!0})}),(0,Y.jsx)(lt,{className:`size-7 shrink-0 rounded-md p-0`,loading:Gt,label:_.cron.refresh,onClick:()=>void pr()})]})]}),Ot?(0,Y.jsx)(`div`,{className:`shrink-0 border-b border-edge bg-surface-muted/40 px-3 py-2`,children:(0,Y.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,Y.jsx)(N,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Y.jsx)(`input`,{type:`text`,role:`searchbox`,value:Mt,onChange:e=>Lt(e.target.value),placeholder:b.files.searchPlaceholder,"aria-label":b.files.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none placeholder:text-fg-subtle`}),(0,Y.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":b.files.clearSearch,title:b.files.clearSearch,onClick:()=>{Lt(``),At(!1)},children:(0,Y.jsx)(P,{className:`size-3.5`,"aria-hidden":!0})})]})}):null,qt?(0,Y.jsx)(`div`,{className:`border-b border-edge bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:qt}):null,hr?(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:Bt?(0,Y.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,Y.jsx)(U,{className:`h-11 w-full`}),(0,Y.jsx)(U,{className:`h-11 w-full`}),(0,Y.jsx)(U,{className:`h-11 w-full`})]}):Ht?(0,Y.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[_.workspace.loadError,`: `,Ht]}):Rt.length===0?(0,Y.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:b.files.noSearchResults}):Rt.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:B(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,Re===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>$e(e.path),title:e.path,children:[(0,Y.jsx)(Ge,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,Y.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):Gt&&we.length===0?(0,Y.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:b.files.loading}):(0,Y.jsx)(yt,{tree:we,selectedPath:Re,onSelectFile:Ar,onSelectEntry:jr,onExpandDir:e=>void mr(e),onAction:Mr,actionLabels:{preview:_.workspace.preview,download:_.workspace.download,copyPath:_.workspace.copyPath,openDefault:_.workspace.openSystemApp,openDirectory:_.workspace.openInFileManager,openWith:_.workspace.openWith,revealInFolder:_.workspace.revealInFolder,trash:_.workspace.moveToTrash,recommendedApps:_.workspace.recommendedApps,desktopUpdateRequired:_.workspace.desktopUpdateRequired},emptyHint:b.files.emptyDirectory})]}),(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":b.files.resizeHandle,className:B(`hidden cursor-col-resize touch-none items-stretch justify-center bg-surface-panel transition-colors hover:bg-surface-hover lg:flex`,vt&&`bg-surface-hover`),onPointerDown:Pr,children:(0,Y.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70`})}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden bg-surface-base`,children:Re?(0,Y.jsx)(Et,{filePath:Re,projectId:T.id,agentId:T.defaultAgentId||Qt||void 0,onClose:()=>$e(null)}):(0,Y.jsx)(`div`,{className:`flex h-full min-h-[18rem] items-center justify-center px-6 text-center`,children:(0,Y.jsxs)(`div`,{className:`max-w-sm`,children:[(0,Y.jsx)(_t,{className:`mx-auto size-8 text-fg-subtle`,"aria-hidden":!0}),(0,Y.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:b.files.previewEmptyTitle}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:b.files.previewEmptyDescription})]})})})]}):(0,Y.jsxs)(`div`,{className:`grid gap-3 px-4 py-8 text-sm text-fg-muted`,children:[(0,Y.jsx)(`p`,{children:b.files.needWorkspace}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(V,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>Pn(`settings`),children:b.files.openSettings})})]})})}):null,Q===`sessions`?(0,Y.jsxs)(`section`,{id:`project-panel-sessions`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-sessions`,className:`grid min-h-full content-start gap-3`,children:[z.length?(0,Y.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,Y.jsx)(N,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,"aria-hidden":!0}),(0,Y.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:W,onChange:e=>ne(e.currentTarget.value),placeholder:b.sessions.searchPlaceholder,"aria-label":b.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`}),W?(0,Y.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":b.sessions.clearSearch,onClick:()=>ne(``),children:(0,Y.jsx)(P,{className:`size-3.5`,"aria-hidden":!0})}):null]}):null,Ur.length?(0,Y.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Ur.map(e=>{let t=Yn(e.updatedAt),n=e.routing?.agentId||e.agentId||b.common.agent,r=sr(e),i=e.name?.trim()||b.sessions.fallbackTitle,a=Vr(e.messageCount??0);return(0,Y.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Ln(`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,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Y.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,Y.jsx)(j,{className:`size-4`,"aria-hidden":!0})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:i}),r?(0,Y.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,Y.jsxs)(`div`,{className:`mt-auto grid gap-2 pt-4 text-xs text-fg-muted`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[b.sessions.agent,`: `,n]}),(0,Y.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:a})]}),t?(0,Y.jsxs)(`span`,{className:`truncate rounded-md bg-surface-base px-2 py-1`,children:[b.sessions.updated,`: `,t]}):null]})]},e.key)})}):Wr?(0,Y.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:b.sessions.noMatches})}):(0,Y.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:b.sessions.emptyTitle}),(0,Y.jsx)(`p`,{className:`mx-auto mt-1 max-w-md text-sm leading-6 text-fg-muted`,children:b.sessions.emptyDescription})]})})]}):null,Q===`progress`?(0,Y.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,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.progress.title}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Jn(b.progress.count,{count:ce})})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.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,Y.jsx)(`input`,{type:`checkbox`,checked:ge,onChange:e=>ve(e.currentTarget.checked),className:`size-4 rounded border-edge text-accent focus:ring-accent/30`}),b.progress.includeRelated]}),(0,Y.jsxs)(V,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3`,onClick:()=>void cr(),disabled:de,children:[(0,Y.jsx)(ee,{className:B(`size-4`,de&&`animate-spin`),"aria-hidden":!0}),b.common.refresh]})]})]}),(0,Y.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:de&&K.length===0?(0,Y.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:b.progress.loading}):K.length?(0,Y.jsx)(`div`,{className:`divide-y divide-edge`,children:K.map(e=>{let t=b.progress.types[e.type]??e.type,n=b.progress.objectKinds[e.primaryObject.kind]??e.primaryObject.kind,r=lr(e),i=e.relatedProjects.length>0&&!e.scopes.some(e=>e.scopeKind===`project`&&e.scopeId===T.id);return(0,Y.jsxs)(`article`,{className:`grid gap-2 px-4 py-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),i?(0,Y.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:b.progress.related}):null]}),(0,Y.jsxs)(`p`,{className:`mt-1 min-w-0 truncate text-sm text-fg-muted`,children:[n,`: `,ar(e)]})]}),(0,Y.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,dateTime:new Date(e.createdAt).toISOString(),children:Yn(e.createdAt)})]}),r?(0,Y.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:r}):null,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,Y.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[b.progress.actor,`: `,ir(e)]}),(0,Y.jsxs)(`span`,{className:`max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[b.progress.source,`: `,or(e)]})]})]},e.id)})}):(0,Y.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:b.progress.empty})})]}):null,Q===`settings`?(0,Y.jsxs)(`form`,{id:`project-panel-settings`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-settings`,onSubmit:Sr,onBlurCapture:Ir.onBlurCapture,className:`grid min-h-full content-start gap-4 pb-1`,children:[(0,Y.jsxs)(`section`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.settings.summaryTitle}),(0,Y.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:b.settings.summaryHint})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-2`,children:[(0,Y.jsx)(`span`,{className:B(`rounded-full px-2 py-0.5 text-xs font-medium`,Xn(Z.status)),children:b.settings.statuses[Z.status]}),(0,Y.jsx)(Pt,{status:Ir.status,error:Ir.error})]})]}),(0,Y.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Y.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.settings.detailsTitle}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:b.settings.detailsHint})]}),(0,Y.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Y.jsx)(Zn,{label:b.settings.name,children:(0,Y.jsx)(`input`,{className:Qn(),value:Z.name,onChange:e=>Cr({name:e.target.value})})}),(0,Y.jsx)(Zn,{label:b.settings.defaultAgent,children:(0,Y.jsxs)(y,{className:Qn(),value:Z.defaultAgentId,onChange:e=>Cr({defaultAgentId:e.target.value},!0),children:[(0,Y.jsx)(x,{value:``,children:b.settings.globalDefaultAgent}),Yt.map(e=>(0,Y.jsx)(x,{value:e.id,children:Ne(e,_.agentsSettings)},e.id))]})}),(0,Y.jsx)(Zn,{label:b.settings.status,children:Jr?(0,Y.jsx)(`div`,{className:`grid min-h-10 content-center rounded-md border border-edge bg-surface-muted px-3 text-sm text-fg-muted`,children:b.settings.statuses.archived}):(0,Y.jsxs)(y,{className:Qn(),value:Z.status===`archived`?`active`:Z.status,onChange:e=>Cr({status:e.target.value},!0),children:[(0,Y.jsx)(x,{value:`active`,children:b.settings.statuses.active}),(0,Y.jsx)(x,{value:`paused`,children:b.settings.statuses.paused})]})}),(0,Y.jsx)(Zn,{label:b.settings.executionMode,hint:b.settings.executionModeHint,children:(0,Y.jsxs)(y,{className:Qn(),value:Z.executionMode,onChange:e=>Cr({executionMode:e.target.value},!0),children:[(0,Y.jsx)(x,{value:`managed_worktree`,children:b.settings.executionModeWorktree}),(0,Y.jsx)(x,{value:`local_checkout`,children:b.settings.executionModeLocal})]})}),(0,Y.jsx)(Zn,{label:b.settings.description,hint:b.settings.descriptionHint,children:(0,Y.jsx)(`textarea`,{className:Qn(!0),value:Z.description,onChange:e=>Cr({description:e.target.value})})})]})]}),(0,Y.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.settings.projectGuidanceTitle}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:b.settings.projectGuidanceHint})]}),(0,Y.jsx)(Zn,{label:b.settings.brief,hint:b.settings.briefHint,children:(0,Y.jsx)(`textarea`,{className:Qn(!0),value:Z.brief,onChange:e=>Cr({brief:e.target.value})})}),(0,Y.jsx)(Zn,{label:b.settings.instructions,hint:b.settings.instructionsHint,children:(0,Y.jsx)(`textarea`,{className:Qn(!0),value:Z.instructions,onChange:e=>Cr({instructions:e.target.value})})})]})]}),(0,Y.jsxs)(`aside`,{className:`grid gap-4 xl:sticky xl:top-0`,children:[(0,Y.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.settings.workspaceRoot}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:b.settings.workspaceIndependentHint})]}),(0,Y.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Y.jsx)(`span`,{className:`w-fit rounded-md bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:Xr?b.settings.workspaceModeFollow:b.settings.workspaceModeFixed}),(0,Y.jsx)(`div`,{className:`break-all font-mono text-xs leading-5 text-fg`,title:Zr,children:Zr}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsxs)(V,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:()=>void ti(),children:[(0,Y.jsx)(E,{className:`size-4`,"aria-hidden":!0}),b.settings.copyWorkspacePath]}),Oe?(0,Y.jsx)(it,{resourceId:Oe.fileId,displayName:Oe.name}):null,(0,Y.jsxs)(V,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:wr,children:[(0,Y.jsx)(tt,{className:`size-4`,"aria-hidden":!0}),b.settings.migrateWorkspace]})]})]})]}),(0,Y.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.settings.currentProjectTitle}),(0,Y.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Y.jsx)($n,{label:b.settings.defaultAgent,value:Gr}),(0,Y.jsx)($n,{label:b.settings.pinState,value:Yr?b.settings.pinned:b.settings.notPinned}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Y.jsx)($n,{label:b.settings.createdAt,value:Yn(T.createdAt)||b.common.never}),(0,Y.jsx)($n,{label:b.settings.updatedAt,value:Yn(T.updatedAt)||b.common.never})]})]})]}),(0,Y.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:b.settings.managementTitle}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:b.settings.managementHint})]}),(0,Y.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:Yr?b.settings.pinnedTitle:b.settings.pinTitle}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:b.settings.pinHint})]}),(0,Y.jsxs)(V,{type:`button`,variant:`ghost`,className:`w-fit rounded-lg`,disabled:gn===`pin`,onClick:()=>void Er(),children:[Yr?(0,Y.jsx)(xt,{className:`size-4`,"aria-hidden":!0}):(0,Y.jsx)(qe,{className:`size-4`,"aria-hidden":!0}),Yr?b.settings.unpinProject:b.settings.pinProject]})]}),(0,Y.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:Jr?b.settings.restoreTitle:b.settings.archiveTitle}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:Jr?b.settings.restoreHint:b.settings.archiveHint})]}),(0,Y.jsxs)(V,{type:`button`,variant:Jr?`primary`:`ghost`,className:`w-fit rounded-lg`,disabled:gn===`archive`,onClick:()=>void Dr(),children:[Jr?(0,Y.jsx)(ee,{className:`size-4`,"aria-hidden":!0}):(0,Y.jsx)(ut,{className:`size-4`,"aria-hidden":!0}),Jr?b.settings.restoreProject:b.settings.archiveProject]})]})]})]}),(0,Y.jsxs)(`section`,{className:`grid gap-3 rounded-lg border border-red-500/20 bg-red-500/5 p-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-red-700 dark:text-red-300`,children:b.settings.dangerTitle}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-red-700/80 dark:text-red-200/80`,children:b.settings.dangerHint})]}),(0,Y.jsxs)(V,{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:()=>sn(!0),children:[(0,Y.jsx)(se,{className:`size-4`,"aria-hidden":!0}),b.settings.deleteConfirmAction]})]})]})]})]}):null]}),(0,Y.jsx)(h,{open:an,onOpenChange:e=>{vn||sn(e)},children:(0,Y.jsxs)(f,{children:[(0,Y.jsx)(c,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Y.jsxs)(p,{className:`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-panel p-5 shadow-float focus:outline-none`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.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,Y.jsx)(be,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(m,{className:`text-base font-semibold text-fg`,children:b.settings.deleteConfirmTitle}),(0,Y.jsx)(u,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:T?Jn(b.settings.deleteConfirm,{name:T.name}):b.settings.deleteConfirmFallback})]})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Y.jsx)(d,{asChild:!0,children:(0,Y.jsx)(V,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:vn,children:b.common.cancel})}),(0,Y.jsxs)(V,{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:vn||!T,onClick:()=>void Or(),children:[(0,Y.jsx)(se,{className:`size-4`,"aria-hidden":!0}),b.settings.deleteConfirmAction]})]})]})]})}),(0,Y.jsx)(gt,{open:!!et,title:_.workspace.trashConfirmTitle,description:_.workspace.trashConfirmDescription.replace(`{{name}}`,et?.name??``),confirmLabel:_.workspace.moveToTrash,cancelLabel:_.workspace.cancel,destructive:!0,onConfirm:()=>void Nr(),onCancel:()=>rt(null)}),(0,Y.jsx)(h,{open:un,onOpenChange:e=>{nn||dn(e)},children:(0,Y.jsxs)(f,{children:[(0,Y.jsx)(c,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Y.jsxs)(p,{className:`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-panel shadow-float focus:outline-none`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Y.jsx)(m,{className:`text-base font-semibold text-fg`,children:b.settings.workspaceMigrationTitle}),(0,Y.jsx)(u,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:b.settings.workspaceMigrationDescription})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-fg-muted`,children:b.settings.workspaceMode}),(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:B(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,fn===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Y.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:fn===`fixed`,onChange:()=>pn(`fixed`),disabled:nn}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:b.settings.workspaceModeFixed}),(0,Y.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:b.settings.workspaceMigrationFixedHint})]})]}),(0,Y.jsxs)(`label`,{className:B(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,fn===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Y.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:fn===`follow`,onChange:()=>pn(`follow`),disabled:nn}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:b.settings.workspaceModeFollow}),(0,Y.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:b.settings.workspaceHint})]})]})]})]}),fn===`fixed`?(0,Y.jsx)(Zt,{value:mn,onChange:hn,disabled:nn,wd:v,placeholder:b.settings.workspacePlaceholder,inputClassName:Qn(),autoFocus:!0}):null,(0,Y.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:b.settings.workspaceMigrationImpact}),(0,Y.jsx)(`div`,{className:`rounded-lg bg-surface-muted px-3 py-2 text-xs leading-5 text-fg-subtle`,children:Jn(b.settings.workspaceCurrent,{workspace:Qr})})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Y.jsx)(d,{asChild:!0,children:(0,Y.jsx)(V,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:nn,children:b.common.cancel})}),(0,Y.jsxs)(V,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:nn||!$r,onClick:()=>void Tr(),children:[(0,Y.jsx)(tt,{className:`size-4`,"aria-hidden":!0}),b.settings.workspaceMigrationConfirm]})]})]})]})}),(0,Y.jsx)(h,{open:!!cn,onOpenChange:e=>{e||ln(null)},children:(0,Y.jsxs)(f,{children:[(0,Y.jsx)(c,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Y.jsxs)(p,{className:`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-panel shadow-float focus:outline-none`,children:[(0,Y.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,Y.jsx)(m,{className:`text-base font-semibold text-fg`,children:b.settings.workspaceMissingTitle}),(0,Y.jsx)(u,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:cn?Jn(b.settings.workspaceMissingDescription,{workspace:cn}):null})]}),cn?(0,Y.jsx)(`div`,{className:`px-5 py-4`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,Y.jsx)(_t,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:cn})]})}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Y.jsx)(V,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:ni,disabled:nn,children:b.settings.workspaceMissingBack}),(0,Y.jsxs)(V,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:()=>void Tr({createWorkspaceRoot:!0}),disabled:nn,children:[(0,Y.jsx)(tt,{className:`size-4`,"aria-hidden":!0}),b.settings.workspaceMissingCreate]})]})]})]})})]})}export{pr as ProjectDetailPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./dist-CpzYSoz7.js";import{n as f,r as p}from"./popover-select-C-Hj-nXR.js";import{t as m}from"./folder-open-CyzJ19I9.js";import{t as h}from"./loader-circle-CifKLtgG.js";import{t as g}from"./plus-Q2yW6OE7.js";import{t as _}from"./search-DA7gz22f.js";import{t as v}from"./x-B_N4OPjy.js";import{t as ee}from"./messages-BbdwoxVo.js";import{n as te}from"./locale-store-CBoCuIMx.js";import{t as y}from"./cn-JdwAhgNB.js";import{t as b}from"./button-CtTvuElV.js";import{t as x}from"./skeleton-BwbyijEw.js";import{$l as S,$s as C,Ai as w,Di as T,Ei as E,Pi as D,Ri as O,Ti as k,al as A,dc as j,hi as M,hr as N,mi as ne,nu as P,oa as re,uc as F}from"./index-Cif1_3Jx.js";var I=n(),L=e(t(),1),R=r();function z(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:N(n)}function ie(e){return[...e].sort((e,t)=>{let n=Number(!!t.pinnedAt)-Number(!!e.pinnedAt);return n===0?new Date(t.lastActiveAt??t.updatedAt).getTime()-new Date(e.lastActiveAt??e.updatedAt).getTime():n})}function ae(){let e=(0,I.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,R.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,"aria-busy":!0,children:Array.from({length:6},B)}),e[0]=t):t=e[0],t}function B(e,t){return(0,R.jsx)(x,{className:`h-40 rounded-xl`},t)}function oe(e){let t=(0,I.c)(59),{project:n,busy:r,onTogglePin:a,onToggleArchive:o}=e,s=te(V),c,l,u,d,f,p,m,h;if(t[0]!==s||t[1]!==n.brief||t[2]!==n.description||t[3]!==n.id||t[4]!==n.lastActiveAt||t[5]!==n.name||t[6]!==n.status||t[7]!==n.updatedAt||t[8]!==n.workspaceRoot){let e=ee(s).projectsPage;c=e.management,m=`flex h-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4`;let r;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,R.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent`,children:(0,R.jsx)(A,{className:`size-4`,"aria-hidden":!0})}),t[17]=r):r=t[17];let a;t[18]===n.name?a=t[19]:(a=(0,R.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[18]=n.name,t[19]=a);let o=(0,R.jsxs)(`div`,{className:`min-w-0`,children:[a,(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:e.statuses[n.status]})]}),g;t[20]===o?g=t[21]:(g=(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[r,o]}),t[20]=o,t[21]=g);let _;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,R.jsx)(S,{className:`mt-2 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[22]=_):_=t[22];let v;t[23]===g?v=t[24]:(v=(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[g,_]}),t[23]=g,t[24]=v),h=(0,R.jsxs)(i,{to:`/projects/${encodeURIComponent(n.id)}`,className:`group flex min-w-0 flex-1 flex-col rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[v,(0,R.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-10 text-xs leading-5 text-fg-muted`,children:n.description||n.brief||e.noDescription})]}),p=`mt-3 flex shrink-0 items-end justify-between gap-3 border-t border-edge-subtle pt-3`,d=`min-w-0 text-[11px] text-fg-subtle`,f=(0,R.jsx)(`p`,{className:`truncate`,children:n.workspaceRoot||e.agentDefault}),l=`mt-1`,u=z(n.lastActiveAt??n.updatedAt,e.never),t[0]=s,t[1]=n.brief,t[2]=n.description,t[3]=n.id,t[4]=n.lastActiveAt,t[5]=n.name,t[6]=n.status,t[7]=n.updatedAt,t[8]=n.workspaceRoot,t[9]=c,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h}else c=t[9],l=t[10],u=t[11],d=t[12],f=t[13],p=t[14],m=t[15],h=t[16];let g;t[25]!==l||t[26]!==u?(g=(0,R.jsx)(`p`,{className:l,children:u}),t[25]=l,t[26]=u,t[27]=g):g=t[27];let _;t[28]!==d||t[29]!==f||t[30]!==g?(_=(0,R.jsxs)(`div`,{className:d,children:[f,g]}),t[28]=d,t[29]=f,t[30]=g,t[31]=_):_=t[31];let v=n.pinnedAt?c.unpin:c.pin,y=n.pinnedAt?c.unpin:c.pin,x;t[32]===n.pinnedAt?x=t[33]:(x=n.pinnedAt?(0,R.jsx)(F,{className:`size-4`,"aria-hidden":!0}):(0,R.jsx)(j,{className:`size-4`,"aria-hidden":!0}),t[32]=n.pinnedAt,t[33]=x);let w;t[34]!==r||t[35]!==a||t[36]!==v||t[37]!==y||t[38]!==x?(w=(0,R.jsx)(b,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:a,"aria-label":v,title:y,children:x}),t[34]=r,t[35]=a,t[36]=v,t[37]=y,t[38]=x,t[39]=w):w=t[39];let T=n.status===`archived`?c.restore:c.archive,E=n.status===`archived`?c.restore:c.archive,D;t[40]===n.status?D=t[41]:(D=n.status===`archived`?(0,R.jsx)(C,{className:`size-4`,"aria-hidden":!0}):(0,R.jsx)(P,{className:`size-4`,"aria-hidden":!0}),t[40]=n.status,t[41]=D);let O;t[42]!==r||t[43]!==o||t[44]!==T||t[45]!==E||t[46]!==D?(O=(0,R.jsx)(b,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:o,"aria-label":T,title:E,children:D}),t[42]=r,t[43]=o,t[44]=T,t[45]=E,t[46]=D,t[47]=O):O=t[47];let k;t[48]!==w||t[49]!==O?(k=(0,R.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[w,O]}),t[48]=w,t[49]=O,t[50]=k):k=t[50];let M;t[51]!==k||t[52]!==p||t[53]!==_?(M=(0,R.jsxs)(`div`,{className:p,children:[_,k]}),t[51]=k,t[52]=p,t[53]=_,t[54]=M):M=t[54];let N;return t[55]!==M||t[56]!==m||t[57]!==h?(N=(0,R.jsxs)(`article`,{className:m,children:[h,M]}),t[55]=M,t[56]=m,t[57]=h,t[58]=N):N=t[58],N}function V(e){return e.language}function H(){let e=ee(te(e=>e.language)),t=e.projectsPage,n=t.management,r=e.chat.workingDirectory,i=re(e=>e.setPageHeader),x=re(e=>e.clearPageHeader),[S,C]=(0,L.useState)([]),[j,N]=(0,L.useState)(!0),[P,F]=(0,L.useState)(null),[I,z]=(0,L.useState)(``),[B,V]=(0,L.useState)(!1),[H,se]=(0,L.useState)(`active`),[ce,U]=(0,L.useState)(null),[le,W]=(0,L.useState)(!1),[G,K]=(0,L.useState)(null),[q,ue]=(0,L.useState)(!1),[J,de]=(0,L.useState)(``),[Y,fe]=(0,L.useState)(``),[X,pe]=(0,L.useState)(``),Z=O({initialPath:X,onPicked:pe}),Q=(0,L.useCallback)(async()=>{N(!0),F(null);try{C(ie((await k({limit:100,sortBy:`updatedAt`,sortOrder:`desc`})).items))}catch(e){F(e instanceof Error?e.message:String(e))}finally{N(!1)}},[]);(0,L.useEffect)(()=>{Q()},[Q]);let $=(0,L.useMemo)(()=>{let e=I.trim().toLocaleLowerCase();return S.filter(e=>H===`all`||e.status===H).filter(t=>!e||[t.name,t.description,t.brief,t.workspaceRoot].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e)))},[H,S,I]),me=(0,L.useMemo)(()=>(0,R.jsxs)(b,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>W(!0),children:[(0,R.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t.create]}),[t.create]);(0,L.useLayoutEffect)(()=>(i({startExtra:null,main:(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,R.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:me}),()=>x()),[x,me,n.subtitle,n.title,i]);let he=(0,L.useCallback)(async e=>{e.preventDefault();let t=J.trim(),n=X.trim();if(!(!t||!n||q)){ue(!0),K(null);try{let e=await M({name:t,...Y.trim()?{description:Y.trim()}:{},workspaceRoot:n});C(t=>[e,...t.filter(t=>t.id!==e.id)]),de(``),fe(``),pe(``),W(!1),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){K(e instanceof Error?e.message:String(e))}finally{ue(!1)}}},[q,Y,J,X]),ge=(0,L.useCallback)(async(e,t)=>{U(e.id),F(null);try{let n;n=t===`pin`?e.pinnedAt?await w(e.id):await E(e.id):e.status===`archived`?await T(e.id):await ne(e.id),C(e=>e.map(e=>e.id===n.id?n:e)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){F(e instanceof Error?e.message:String(e))}finally{U(null)}},[]),_e=[{id:`active`,label:t.statuses.active},{id:`paused`,label:t.statuses.paused},{id:`archived`,label:t.statuses.archived},{id:`all`,label:t.all}],ve=_e.find(e=>e.id===H)?.label??t.all,ye=n.resultCount.replace(`{{status}}`,ve).replace(`{{count}}`,String($.length));return(0,R.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,R.jsx)(d,{open:le,onOpenChange:e=>{W(e),e||K(null)},children:(0,R.jsxs)(c,{children:[(0,R.jsx)(a,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,R.jsxs)(l,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,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-panel shadow-float focus:outline-none`,children:[(0,R.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,R.jsx)(u,{className:`text-base font-semibold text-fg`,children:t.createTitle}),(0,R.jsx)(o,{className:`mt-1 text-sm text-fg-muted`,children:t.createDescription})]}),(0,R.jsxs)(`form`,{onSubmit:he,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.projectName,(0,R.jsx)(`input`,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 font-normal outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:J,onChange:e=>de(e.target.value),maxLength:160})]}),(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[n.descriptionLabel,(0,R.jsx)(`textarea`,{className:`min-h-28 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 font-normal leading-6 outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:Y,onChange:e=>fe(e.target.value),maxLength:2e3,placeholder:n.descriptionPlaceholder})]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,R.jsx)(`span`,{className:`font-medium text-fg`,children:t.workspaceRoot}),(0,R.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent/20 disabled:cursor-not-allowed disabled:opacity-60`,onClick:Z.pick,disabled:q||Z.picking,children:[Z.picking?(0,R.jsx)(h,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,R.jsx)(m,{className:`size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:X?r.chooseFolder:r.selectWorkingDirectory}),(0,R.jsx)(`span`,{className:y(`mt-0.5 block truncate font-mono text-xs font-normal`,X?`text-fg-muted`:`text-fg-subtle`),title:X||void 0,children:X||t.workspaceSelectionPlaceholder})]})]}),(0,R.jsx)(`p`,{className:`text-xs font-normal text-fg-subtle`,children:t.workspaceSelectionHint})]}),G?(0,R.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:G}):null]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,R.jsx)(s,{asChild:!0,children:(0,R.jsx)(b,{type:`button`,variant:`ghost`,children:t.cancel})}),(0,R.jsx)(b,{type:`submit`,variant:`primary`,disabled:q||!J.trim()||!X.trim(),children:q?t.home.creating:t.create})]})]})]})]})}),Z.hasNativePicker?null:(0,R.jsx)(D,{open:Z.modalOpen,onOpenChange:Z.setModalOpen,initialAbsolutePath:X||void 0,onConfirm:Z.confirmPick,wd:r}),(0,R.jsxs)(`section`,{className:`flex min-h-10 flex-wrap items-center justify-between gap-3`,"aria-label":n.filterLabel,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,"aria-live":`polite`,children:ye}),(0,R.jsxs)(`div`,{className:y(`ml-auto flex min-w-0 items-center justify-end gap-2`,B&&`w-full sm:w-auto`),children:[B?(0,R.jsxs)(`div`,{className:`relative min-w-0 flex-1 sm:w-64 sm:flex-none`,children:[(0,R.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,R.jsx)(`input`,{autoFocus:!0,className:`h-9 w-full rounded-lg border border-edge bg-surface-panel pl-9 pr-9 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:I,onChange:e=>z(e.target.value),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder}),(0,R.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg`,onClick:()=>{z(``),V(!1)},"aria-label":n.clearSearch,title:n.clearSearch,children:(0,R.jsx)(v,{className:`size-3.5`,"aria-hidden":!0})})]}):(0,R.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,onClick:()=>V(!0),"aria-label":t.searchPlaceholder,title:t.searchPlaceholder,children:(0,R.jsx)(_,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsx)(f,{className:`w-28 sm:w-32`,triggerClassName:`h-9 border-edge bg-surface-panel px-2.5 text-xs font-medium`,contentClassName:`min-w-36`,align:`end`,value:H,"aria-label":n.filterLabel,onChange:e=>se(e.target.value),children:_e.map(e=>(0,R.jsx)(p,{value:e.id,children:e.label},e.id))})]})]}),P?(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,role:`alert`,children:[(0,R.jsx)(`span`,{children:P}),(0,R.jsx)(b,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Q(),children:t.home.retry})]}):null,j?(0,R.jsx)(ae,{}):$.length?(0,R.jsx)(`section`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:$.map(e=>(0,R.jsx)(oe,{project:e,busy:ce===e.id,onTogglePin:()=>void ge(e,`pin`),onToggleArchive:()=>void ge(e,`archive`)},e.id))}):(0,R.jsxs)(`section`,{className:`rounded-xl border border-dashed border-edge p-10 text-center`,children:[(0,R.jsx)(A,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,R.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:n.emptyTitle}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint})]})]})}export{H as ProjectsPage};
@@ -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{l as i,p as a,t as o}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as s,i as c,o as l,r as u,s as d,t as f}from"./dist-CpzYSoz7.js";import{t as p}from"./check-DUBLcKHA.js";import{t as m}from"./copy-Dv6d4Dvw.js";import{t as h}from"./external-link-DjqjBmc3.js";import{t as g}from"./globe-DSSGFWFn.js";import{t as _}from"./loader-circle-CifKLtgG.js";import{t as v}from"./copy-to-clipboard-HOJ79TWv.js";import{t as y}from"./messages-BbdwoxVo.js";import{n as b,s as x}from"./locale-store-CBoCuIMx.js";import{t as S}from"./cn-JdwAhgNB.js";import{i as C}from"./vendor-swr-BIWyz7Rc.js";import{t as w}from"./button-CtTvuElV.js";import{n as T,r as E}from"./gateway-config-swr-826dipyU.js";import{i as D,o as O}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as k,n as A,r as j}from"./oauth-api-BjSUDIgq.js";import{$l as M,Fl as N,Hr as P,Li as F,Ll as I,Ts as L,Us as R,Vc as z,Vs as B,Xs as V,ac as H,eo as ee,ht as te,ks as U,ri as ne,vc as W,wl as re}from"./index-Cif1_3Jx.js";import{n as G,r as K,t as q}from"./settings-page-layout-BRQNel6r.js";import{a as ie,c as ae,d as J,g as oe,i as se,l as ce,n as Y,o as le,r as ue,s as de,t as fe,u as pe}from"./tunnel-api-jKzujxFU.js";import{n as X,r as me,t as he}from"./settings-form-section-DjWzRk4z.js";import{n as ge,r as _e,t as ve}from"./oauth-authorization-window-Cdolr2wE.js";import{t as ye}from"./page-tabs-BaEQMYm_.js";import{t as be}from"./settings-advanced-gate-Bz4s9BBY.js";var Z=e(t(),1),Q=n(),$=r();function xe(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function Se(e){let t=(0,Q.c)(5),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=S(`rounded-full px-2 py-0.5 text-[11px] font-medium`,xe(r)),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`span`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Ce(e){let t=(0,Q.c)(31),{onOpenTab:n}=e,r=b(Te),i;t[0]===r?i=t[1]:(i=y(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!x(we),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={refreshInterval:3e4},t[2]=s):s=t[2];let{data:c}=C(o?`exposure-status`:null,pe,s),l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:15e3},t[3]=l):l=t[3];let{data:u}=C(o?`tunnel-status`:null,fe,l),d=E(o);if(!o)return null;let f=c?.tailscale.active===!0,p=u?.state,m=u?.enabled&&p===`connected`,h=u?.enabled&&(p===`connecting`||p===`reconnecting`||!!u?.startProgress||!!u?.frpcDownload),_=d.data?.payload?.config,v=!!(_&&typeof _==`object`&&!Array.isArray(_)&&_.gateway?.publicUrl),w=f?`active`:`off`,T=f?a.statusActive:a.statusOff,D;t[4]!==a.tailscaleCardTitle||t[5]!==w||t[6]!==T?(D={tab:`tailscale`,icon:g,title:a.tailscaleCardTitle,kind:w,statusLabel:T},t[4]=a.tailscaleCardTitle,t[5]=w,t[6]=T,t[7]=D):D=t[7];let O=m?`active`:h?`connecting`:`off`,k=m?a.statusActive:h?a.statusConnecting:a.statusOff,A;t[8]!==a.publicCardTitle||t[9]!==O||t[10]!==k?(A={tab:`public`,icon:W,title:a.publicCardTitle,kind:O,statusLabel:k},t[8]=a.publicCardTitle,t[9]=O,t[10]=k,t[11]=A):A=t[11];let j=v?`active`:`off`,M=v?a.statusActive:a.statusOff,N;t[12]!==a.reverseProxyCardTitle||t[13]!==j||t[14]!==M?(N={tab:`reverse-proxy`,icon:R,title:a.reverseProxyCardTitle,kind:j,statusLabel:M},t[12]=a.reverseProxyCardTitle,t[13]=j,t[14]=M,t[15]=N):N=t[15];let P;t[16]!==a.sshCardStatus||t[17]!==a.sshCardTitle?(P={tab:`ssh`,icon:U,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[16]=a.sshCardStatus,t[17]=a.sshCardTitle,t[18]=P):P=t[18];let F;t[19]!==a.lanCardStatus||t[20]!==a.lanCardTitle?(F={tab:`lan`,icon:V,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[19]=a.lanCardStatus,t[20]=a.lanCardTitle,t[21]=F):F=t[21];let I;t[22]!==N||t[23]!==P||t[24]!==F||t[25]!==D||t[26]!==A?(I=[D,A,N,P,F],t[22]=N,t[23]=P,t[24]=F,t[25]=D,t[26]=A,t[27]=I):I=t[27];let L=I,z;return t[28]!==L||t[29]!==n?(z=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:L.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:S(`flex items-start gap-3 rounded-xl bg-surface-base px-3 py-2.5 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(Se,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[28]=L,t[29]=n,t[30]=z):z=t[30],z}function we(e){return e.token}function Te(e){return e.language}function Ee(e){let t=(0,Q.c)(26),{title:n,description:r,recommended:i,icon:a,onOpen:o,openLabel:s,recommendedLabel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=S(`group flex w-full flex-col rounded-2xl bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=l):l=t[0];let u;t[1]===a?u=t[2]:(u=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=u);let d;t[3]===n?d=t[4]:(d=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=d);let f;t[5]!==i||t[6]!==c?(f=i&&c?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:c}):null,t[5]=i,t[6]=c,t[7]=f):f=t[7];let p;t[8]!==d||t[9]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=m);let h;t[13]!==p||t[14]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[p,m]}),t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=g):g=t[16];let _;t[17]!==u||t[18]!==h?(_=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[u,h,g]}),t[17]=u,t[18]=h,t[19]=_):_=t[19];let v;t[20]===s?v=t[21]:(v=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:s}),t[20]=s,t[21]=v);let y;return t[22]!==o||t[23]!==v||t[24]!==_?(y=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:l,children:[_,v]}),t[22]=o,t[23]=v,t[24]=_,t[25]=y):y=t[25],y}function De(e){let t=(0,Q.c)(83),{onOpenTab:n}=e,r=b(Ae),i;t[0]===r?i=t[1]:(i=y(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!x(ke),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:l}=C(s?`exposure-status`:null,pe,c),u;t[3]===l?.conflicts?u=t[4]:(u=l?.conflicts??[],t[3]=l?.conflicts,t[4]=u);let d=u;if(!s){let e;return t[5]===o.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.needToken}),t[5]=o.needToken,t[6]=e),e}let f;t[7]===n?f=t[8]:(f=(0,$.jsx)(Ce,{onOpenTab:n}),t[7]=n,t[8]=f);let p;t[9]!==d||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(p=d.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:o.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:o.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:d.map(Oe)})]}):null,t[9]=d,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=p):p=t[12];let m;t[13]===o.pickMethod?m=t[14]:(m=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=m);let h;t[15]===n?h=t[16]:(h=()=>n(`tailscale`),t[15]=n,t[16]=h);let _;t[17]!==o.configure||t[18]!==o.recommended||t[19]!==o.tailscaleCardDesc||t[20]!==o.tailscaleCardTitle||t[21]!==h?(_=(0,$.jsx)(Ee,{icon:g,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,openLabel:o.configure,onOpen:h}),t[17]=o.configure,t[18]=o.recommended,t[19]=o.tailscaleCardDesc,t[20]=o.tailscaleCardTitle,t[21]=h,t[22]=_):_=t[22];let v;t[23]===n?v=t[24]:(v=()=>n(`public`),t[23]=n,t[24]=v);let S;t[25]!==o.configure||t[26]!==o.publicCardDesc||t[27]!==o.publicCardTitle||t[28]!==v?(S=(0,$.jsx)(Ee,{icon:W,title:o.publicCardTitle,description:o.publicCardDesc,openLabel:o.configure,onOpen:v}),t[25]=o.configure,t[26]=o.publicCardDesc,t[27]=o.publicCardTitle,t[28]=v,t[29]=S):S=t[29];let w;t[30]===n?w=t[31]:(w=()=>n(`reverse-proxy`),t[30]=n,t[31]=w);let T;t[32]!==o.configure||t[33]!==o.reverseProxyCardDesc||t[34]!==o.reverseProxyCardTitle||t[35]!==w?(T=(0,$.jsx)(Ee,{icon:R,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,openLabel:o.configure,onOpen:w}),t[32]=o.configure,t[33]=o.reverseProxyCardDesc,t[34]=o.reverseProxyCardTitle,t[35]=w,t[36]=T):T=t[36];let E;t[37]===n?E=t[38]:(E=()=>n(`ssh`),t[37]=n,t[38]=E);let D;t[39]!==o.configure||t[40]!==o.sshCardDesc||t[41]!==o.sshCardTitle||t[42]!==E?(D=(0,$.jsx)(Ee,{icon:U,title:o.sshCardTitle,description:o.sshCardDesc,openLabel:o.configure,onOpen:E}),t[39]=o.configure,t[40]=o.sshCardDesc,t[41]=o.sshCardTitle,t[42]=E,t[43]=D):D=t[43];let O;t[44]===n?O=t[45]:(O=()=>n(`lan`),t[44]=n,t[45]=O);let k;t[46]!==o.configure||t[47]!==o.lanCardDesc||t[48]!==o.lanCardTitle||t[49]!==O?(k=(0,$.jsx)(Ee,{icon:V,title:o.lanCardTitle,description:o.lanCardDesc,openLabel:o.configure,onOpen:O}),t[46]=o.configure,t[47]=o.lanCardDesc,t[48]=o.lanCardTitle,t[49]=O,t[50]=k):k=t[50];let A;t[51]!==S||t[52]!==T||t[53]!==D||t[54]!==k||t[55]!==_?(A=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[_,S,T,D,k]}),t[51]=S,t[52]=T,t[53]=D,t[54]=k,t[55]=_,t[56]=A):A=t[56];let j;t[57]!==A||t[58]!==m?(j=(0,$.jsxs)(`div`,{children:[m,A]}),t[57]=A,t[58]=m,t[59]=j):j=t[59];let M;t[60]===o.oneAtATimeHint?M=t[61]:(M=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[60]=o.oneAtATimeHint,t[61]=M);let N;t[62]===a.advanced.proxyTitle?N=t[63]:(N=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[62]=a.advanced.proxyTitle,t[63]=N);let P;t[64]===a.advanced.proxyBody?P=t[65]:(P=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[64]=a.advanced.proxyBody,t[65]=P);let F;t[66]!==r||t[67]!==a.advanced.proxyDocs?(F=(0,$.jsx)(J,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=a.advanced.proxyDocs,t[68]=F):F=t[68];let I;t[69]!==N||t[70]!==P||t[71]!==F?(I=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-4 py-3`,children:[N,P,F]}),t[69]=N,t[70]=P,t[71]=F,t[72]=I):I=t[72];let L;t[73]!==o.docsLink||t[74]!==r?(L=(0,$.jsx)(J,{language:r,label:o.docsLink}),t[73]=o.docsLink,t[74]=r,t[75]=L):L=t[75];let z;return t[76]!==j||t[77]!==M||t[78]!==I||t[79]!==L||t[80]!==f||t[81]!==p?(z=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[f,p,j,M,I,L]}),t[76]=j,t[77]=M,t[78]=I,t[79]=L,t[80]=f,t[81]=p,t[82]=z):z=t[82],z}function Oe(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function ke(e){return e.token}function Ae(e){return e.language}function je(){let e=(0,Q.c)(16),t=b(Me),n;e[0]===t?n=e[1]:(n=y(t),e[0]=t,e[1]=n);let r=n.remoteAccess.lan,i;e[2]!==r.subtitle||e[3]!==r.title?(i=(0,$.jsx)(X,{icon:V,title:r.title,subtitle:r.subtitle}),e[2]=r.subtitle,e[3]=r.title,e[4]=i):i=e[4];let a;e[5]===r.body?a=e[6]:(a=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.body}),e[5]=r.body,e[6]=a);let s;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),e[7]=s):s=e[7];let c;e[8]===r.link?c=e[9]:(c=(0,$.jsxs)(o,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[r.link,s]}),e[8]=r.link,e[9]=c);let l;e[10]!==a||e[11]!==c?(l=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[a,c]}),e[10]=a,e[11]=c,e[12]=l):l=e[12];let u;return e[13]!==i||e[14]!==l?(u=(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,$.jsxs)(he,{children:[i,l]})}),e[13]=i,e[14]=l,e[15]=u):u=e[15],u}function Me(e){return e.language}function Ne(e){let t=(0,Q.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=b(Pe),a;t[0]===i?a=t[1]:(a=y(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,c]=(0,Z.useState)(!1),l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=async()=>{await v(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=l):l=t[2];let u=l,d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=d):d=t[3];let f,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>void u(),p=(0,$.jsx)(m,{className:`mr-1 size-4`}),t[4]=f,t[5]=p):(f=t[4],p=t[5]);let h=s?o.copied:o.copy,g;t[6]===h?g=t[7]:(g=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(w,{type:`button`,variant:`ghost`,onClick:f,children:[p,h]})}),t[6]=h,t[7]=g);let _;t[8]!==r||t[9]!==o.hint?(_=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:o.hint}):null,t[8]=r,t[9]=o.hint,t[10]=_):_=t[10];let x;t[11]!==g||t[12]!==_?(x=(0,$.jsxs)($.Fragment,{children:[d,g,_]}),t[11]=g,t[12]=_,t[13]=x):x=t[13];let S=x;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(X,{icon:U,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===S?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:S}),t[17]=S,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(he,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let C;t[22]!==o.subtitle||t[23]!==o.title?(C=(0,$.jsx)(X,{icon:U,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=C):C=t[24];let T;t[25]===S?T=t[26]:(T=(0,$.jsx)(`div`,{className:`mt-4`,children:S}),t[25]=S,t[26]=T);let E;return t[27]!==C||t[28]!==T?(E=(0,$.jsxs)(he,{children:[C,T]}),t[27]=C,t[28]=T,t[29]=E):E=t[29],E}function Pe(e){return e.language}function Fe(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ne,{embedded:!0}),e[0]=t):t=e[0],t}var Ie=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Le(e){return e&&Ie.includes(e)?e:`guide`}function Re(e){let t=(0,Q.c)(26),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:s,defaultOpen:c,advancedOnly:l}=e,u=l===void 0?!1:l,[d,f]=(0,Z.useState)(c??!1),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>f(e.currentTarget.open),t[0]=p):p=t[0];let m;t[1]===s?m=t[2]:(m=S(`group rounded-2xl bg-surface-base open:pb-1`,s),t[1]=s,t[2]=m);let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(I,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[3]=h):h=t[3];let g;t[4]===i?g=t[5]:(g=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[4]=i,t[5]=g);let _;t[6]===n?_=t[7]:(_=(0,$.jsx)(`span`,{className:`group-open:hidden`,children:n}),t[6]=n,t[7]=_);let v;t[8]===r?v=t[9]:(v=(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:r}),t[8]=r,t[9]=v);let y;t[10]!==g||t[11]!==_||t[12]!==v?(y=(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-2xl px-4 py-3.5 text-sm font-medium text-fg transition-colors hover:text-fg group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:[h,g,_,v]}),t[10]=g,t[11]=_,t[12]=v,t[13]=y):y=t[13];let b;t[14]===a?b=t[15]:(b=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[14]=a,t[15]=b);let x;t[16]!==o||t[17]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[b,o]}),t[16]=o,t[17]=b,t[18]=x):x=t[18];let C;t[19]!==d||t[20]!==x||t[21]!==m||t[22]!==y?(C=(0,$.jsxs)(`details`,{open:d,onToggle:p,className:m,children:[y,x]}),t[19]=d,t[20]=x,t[21]=m,t[22]=y,t[23]=C):C=t[23];let w=C;if(u){let e;return t[24]===w?e=t[25]:(e=(0,$.jsx)(be,{children:w}),t[24]=w,t[25]=e),e}return w}function ze(e){let t=(0,Q.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:p,cancelLabel:m,onConfirm:h,onCancel:g}=e,[_,v]=(0,Z.useState)(!1),y;t[0]===g?y=t[1]:(y=e=>{e||(v(!1),g())},t[0]=g,t[1]=y);let b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(s,{className:S(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,O)}),t[2]=b):b=t[2];let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=S(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,D),t[3]=x):x=t[3];let C;t[4]===r?C=t[5]:(C=(0,$.jsx)(d,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=C);let T;t[6]===i?T=t[7]:(T=(0,$.jsx)(c,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=T);let E;t[8]===a?E=t[9]:(E=a.map(Be),t[8]=a,t[9]=E);let k;t[10]===E?k=t[11]:(k=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:E}),t[10]=E,t[11]=k);let A;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>v(e.target.checked),t[12]=A):A=t[12];let j;t[13]===_?j=t[14]:(j=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:_,onChange:A}),t[13]=_,t[14]=j);let M;t[15]===o?M=t[16]:(M=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=M);let N;t[17]!==M||t[18]!==j?(N=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[j,M]}),t[17]=M,t[18]=j,t[19]=N):N=t[19];let P;t[20]!==m||t[21]!==g?(P=(0,$.jsx)(w,{type:`button`,variant:`secondary`,onClick:g,children:m}),t[20]=m,t[21]=g,t[22]=P):P=t[22];let F=!_,I;t[23]!==p||t[24]!==h||t[25]!==F?(I=(0,$.jsx)(w,{type:`button`,disabled:F,onClick:h,children:p}),t[23]=p,t[24]=h,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==P||t[28]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[27]=P,t[28]=I,t[29]=L):L=t[29];let R;t[30]!==N||t[31]!==L||t[32]!==C||t[33]!==T||t[34]!==k?(R=(0,$.jsxs)(l,{children:[b,(0,$.jsxs)(u,{className:x,onOpenAutoFocus:Ve,children:[C,T,k,N,L]})]}),t[30]=N,t[31]=L,t[32]=C,t[33]=T,t[34]=k,t[35]=R):R=t[35];let z;return t[36]!==n||t[37]!==y||t[38]!==R?(z=(0,$.jsx)(f,{open:n,onOpenChange:y,children:R}),t[36]=n,t[37]=y,t[38]=R,t[39]=z):z=t[39],z}function Be(e){return(0,$.jsx)(`li`,{children:e},e)}function Ve(e){return e.preventDefault()}function He(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Ue=[`preparing_frpc`,`registering`,`starting_frpc`];function We(e){return e?e===`reconnecting_frpc`?Ue.indexOf(`starting_frpc`):Ue.indexOf(e):-1}function Ge(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Ue.indexOf(e),i=We(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Ke(e,t,n){let r=n.startProgress;return Ge(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function qe(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Je(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Ye(e){let t=(0,Q.c)(31),{status:n,t:r}=e,[,i]=(0,Z.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(Xe),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let o=n.startProgress?.startedAt,s;if(t[3]!==n.state||t[4]!==o?(s=[n.state,o],t[3]=n.state,t[4]=o,t[5]=s):s=t[5],(0,Z.useEffect)(a,s),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let c,l,u,d,f;if(t[6]!==n||t[7]!==r){let e=Je(n.startProgress?.startedAt);c=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,l=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`;let i;t[13]===r.startProgressTitle?i=t[14]:(i=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=i);let a;t[15]===r.startProgressHint?a=t[16]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=a),t[17]!==i||t[18]!==a?(u=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=u):u=t[19];let o=Ue.map(e=>{let t=Ge(e,n),i=Ke(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(p,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(_,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(re,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:S(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:qe(r,e)}),i?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:i}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:S(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[He(n.frpcDownload.bytesReceived),` /`,` `,He(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===o?d=t[21]:(d=(0,$.jsx)(`ol`,{className:`space-y-2`,children:o}),t[20]=o,t[21]=d),f=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f}else c=t[8],l=t[9],u=t[10],d=t[11],f=t[12];let m;t[22]!==c||t[23]!==r.publicUrlPendingNotice?(m=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=c,t[23]=r.publicUrlPendingNotice,t[24]=m):m=t[24];let h;return t[25]!==l||t[26]!==u||t[27]!==d||t[28]!==f||t[29]!==m?(h=(0,$.jsxs)(`div`,{className:l,children:[u,d,f,m]}),t[25]=l,t[26]=u,t[27]=d,t[28]=f,t[29]=m,t[30]=h):h=t[30],h}function Xe(e){return e+1}function Ze(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function Qe(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function $e(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function et(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function tt(e){let t=(0,Q.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:l,startDisabled:u,startDisabledReason:d,stepLabel:f,onStart:p,onStop:m}=e,h=u===void 0?!1:u,v,y,b,x,C,T,E;t[0]!==r||t[1]!==o?(E=Qe(r),v=r.enabled||o,y=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(T=S(me(),`space-y-4`),t[9]=T):T=t[9],C=`flex flex-wrap items-start justify-between gap-3`,x=`flex items-center gap-2`,b=S(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,$e(E)),t[0]=r,t[1]=o,t[2]=v,t[3]=y,t[4]=b,t[5]=x,t[6]=C,t[7]=T,t[8]=E):(v=t[2],y=t[3],b=t[4],x=t[5],C=t[6],T=t[7],E=t[8]);let D=E===`connected`&&`bg-emerald-500`,O=E===`progress`&&`bg-amber-500 animate-pulse`,k=E===`error`&&`bg-red-500`,A=E===`off`&&`bg-fg-subtle`,j;t[10]!==D||t[11]!==O||t[12]!==k||t[13]!==A?(j=S(`size-1.5 rounded-full`,D,O,k,A),t[10]=D,t[11]=O,t[12]=k,t[13]=A,t[14]=j):j=t[14];let M;t[15]===j?M=t[16]:(M=(0,$.jsx)(`span`,{className:j,"aria-hidden":!0}),t[15]=j,t[16]=M);let N;t[17]!==i||t[18]!==r||t[19]!==n?(N=i&&!r.enabled?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-3 w-16 animate-pulse rounded-full bg-surface-hover/70 motion-reduce:animate-none`}):Ze(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=N):N=t[20];let F;t[21]!==M||t[22]!==N||t[23]!==b?(F=(0,$.jsxs)(`span`,{className:b,children:[M,N]}),t[21]=M,t[22]=N,t[23]=b,t[24]=F):F=t[24];let I;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(I=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,et(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=I):I=t[28];let R;t[29]!==F||t[30]!==I||t[31]!==x?(R=(0,$.jsxs)(`div`,{className:x,children:[F,I]}),t[29]=F,t[30]=I,t[31]=x,t[32]=R):R=t[32];let z;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(g,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=z):z=t[33];let B;t[34]!==R||t[35]!==C?(B=(0,$.jsxs)(`div`,{className:C,children:[R,z]}),t[34]=R,t[35]=C,t[36]=B):B=t[36];let V;t[37]===a?V=t[38]:(V=a?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a instanceof Error?a.message:String(a)}):null,t[37]=a,t[38]=V);let ee;t[39]!==c||t[40]!==n.consentExpiredBanner?(ee=c?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=c,t[40]=n.consentExpiredBanner,t[41]=ee):ee=t[41];let te;t[42]!==v||t[43]!==l||t[44]!==p||t[45]!==m||t[46]!==y||t[47]!==r||t[48]!==h||t[49]!==d||t[50]!==o||t[51]!==f||t[52]!==s||t[53]!==n?(te=v?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,$.jsx)(P,{label:n.publicUrlLabel,text:r.publicUrl,labels:l})}):null,y?(0,$.jsx)(Ye,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:s,onClick:m,children:[s?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(w,{type:`button`,disabled:o,onClick:p,children:[o?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(H,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[f?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:f}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(L,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),h&&d?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:d}):null,(0,$.jsxs)(w,{type:`button`,disabled:o||h,onClick:p,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(H,{className:`size-4`}),n.start]})]}),t[42]=v,t[43]=l,t[44]=p,t[45]=m,t[46]=y,t[47]=r,t[48]=h,t[49]=d,t[50]=o,t[51]=f,t[52]=s,t[53]=n,t[54]=te):te=t[54];let U;return t[55]!==B||t[56]!==V||t[57]!==ee||t[58]!==te||t[59]!==T?(U=(0,$.jsxs)(`section`,{className:T,children:[B,V,ee,te]}),t[55]=B,t[56]=V,t[57]=ee,t[58]=te,t[59]=T,t[60]=U):U=t[60],U}var nt=`https://console.xopc.ai/access/client`,rt={reconfiguring:!1};function it(e){let t=(0,Q.c)(89),{t:n,brokerSecretReady:r,brokerSecretConfiguredInConfig:i,brokerSecretMaskedValue:a,brokerSecretDraft:o,savingBrokerSecret:s,authorizingBrokerSecret:c,brokerSecretAuthorizationUrl:l,brokerSecretNotice:u,copyFailedLabel:d,onDraftChange:f,onSave:m,onAuthorize:g,onClear:v,sectionRef:y}=e,b=(0,Z.useId)(),x=r,C=!x,[T,E]=(0,Z.useReducer)(F,rt),{reconfiguring:D}=T,O;t[0]!==i||t[1]!==o||t[2]!==D?(O=i&&!D&&!o.trim(),t[0]=i,t[1]=o,t[2]=D,t[3]=O):O=t[3];let k=O,A;t[4]!==n.copied||t[5]!==n.copyKey||t[6]!==n.hideKey||t[7]!==n.showKey?(A={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[4]=n.copied,t[5]=n.copyKey,t[6]=n.hideKey,t[7]=n.showKey,t[8]=A):A=t[8];let j=A,M;t[9]===o?M=t[10]:(M=o.trim().length>0&&!te(o.trim()),t[9]=o,t[10]=M);let N=M,P;t[11]===f?P=t[12]:(P=()=>{E({type:`patch`,patch:{reconfiguring:!1}}),f(``)},t[11]=f,t[12]=P);let I=P,L=C&&`ring-1 ring-amber-500/30`,R;t[13]===L?R=t[14]:(R=S(L),t[13]=L,t[14]=R);let B=x?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:C?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,V;t[15]===B?V=t[16]:(V=S(`flex size-9 shrink-0 items-center justify-center rounded-lg`,B),t[15]=B,t[16]=V);let H;t[17]===x?H=t[18]:(H=x?(0,$.jsx)(p,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(z,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=x,t[18]=H);let U;t[19]!==V||t[20]!==H?(U=(0,$.jsx)(`span`,{className:V,children:H}),t[19]=V,t[20]=H,t[21]=U):U=t[21];let ne=x?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,W;t[22]===ne?W=t[23]:(W=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:ne}),t[22]=ne,t[23]=W);let re=x?n.brokerSecretReadyHint:n.brokerSecretHint,G;t[24]===re?G=t[25]:(G=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:re}),t[24]=re,t[25]=G);let K;t[26]!==C||t[27]!==n.brokerSecretMissingHint?(K=C?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[26]=C,t[27]=n.brokerSecretMissingHint,t[28]=K):K=t[28];let q;t[29]!==W||t[30]!==G||t[31]!==K?(q=(0,$.jsxs)(`div`,{children:[W,G,K]}),t[29]=W,t[30]=G,t[31]=K,t[32]=q):q=t[32];let ie;t[33]!==c||t[34]!==C||t[35]!==g||t[36]!==D||t[37]!==s||t[38]!==n.brokerSecretAuthorize||t[39]!==n.brokerSecretAuthorizing||t[40]!==n.brokerSecretConsoleLink?(ie=C||D?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(w,{type:`button`,disabled:s||c,onClick:g,children:[c?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,c?n.brokerSecretAuthorizing:n.brokerSecretAuthorize]}),(0,$.jsxs)(`a`,{href:nt,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,(0,$.jsx)(h,{className:`size-3`,"aria-hidden":!0})]})]}):null,t[33]=c,t[34]=C,t[35]=g,t[36]=D,t[37]=s,t[38]=n.brokerSecretAuthorize,t[39]=n.brokerSecretAuthorizing,t[40]=n.brokerSecretConsoleLink,t[41]=ie):ie=t[41];let ae;t[42]!==c||t[43]!==l||t[44]!==n.brokerSecretOpenAuthorization?(ae=c&&l?(0,$.jsxs)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[n.brokerSecretOpenAuthorization,(0,$.jsx)(h,{className:`size-3`,"aria-hidden":!0})]}):null,t[42]=c,t[43]=l,t[44]=n.brokerSecretOpenAuthorization,t[45]=ae):ae=t[45];let J;t[46]!==i||t[47]!==o||t[48]!==a||t[49]!==N||t[50]!==I||t[51]!==d||t[52]!==b||t[53]!==C||t[54]!==v||t[55]!==f||t[56]!==m||t[57]!==D||t[58]!==s||t[59]!==j||t[60]!==k||t[61]!==n.brokerSecretCancelReconfigure||t[62]!==n.brokerSecretClear||t[63]!==n.brokerSecretMaskedHelp||t[64]!==n.brokerSecretNotInConfigFile||t[65]!==n.brokerSecretPlaceholder||t[66]!==n.brokerSecretReconfigure||t[67]!==n.brokerSecretRevealFailed||t[68]!==n.brokerSecretSave||t[69]!==n.brokerSecretSaveAndContinue||t[70]!==n.brokerSecretTitle?(J=k?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(ee,{id:b,value:a,labels:j,reveal:at,loadFailedLabel:d||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(w,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>{E({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(w,{type:`button`,variant:`ghost`,disabled:s,onClick:v,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(ee,{id:b,value:o,onChange:f,placeholder:n.brokerSecretPlaceholder,labels:j,disabled:s}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(w,{type:`button`,disabled:s||!N,onClick:m,children:[s?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,C?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),i?(0,$.jsx)(w,{type:`button`,variant:`ghost`,disabled:s,onClick:v,children:n.brokerSecretClear}):null,D?(0,$.jsx)(w,{type:`button`,variant:`ghost`,disabled:s,onClick:I,children:n.brokerSecretCancelReconfigure}):null]})]}),t[46]=i,t[47]=o,t[48]=a,t[49]=N,t[50]=I,t[51]=d,t[52]=b,t[53]=C,t[54]=v,t[55]=f,t[56]=m,t[57]=D,t[58]=s,t[59]=j,t[60]=k,t[61]=n.brokerSecretCancelReconfigure,t[62]=n.brokerSecretClear,t[63]=n.brokerSecretMaskedHelp,t[64]=n.brokerSecretNotInConfigFile,t[65]=n.brokerSecretPlaceholder,t[66]=n.brokerSecretReconfigure,t[67]=n.brokerSecretRevealFailed,t[68]=n.brokerSecretSave,t[69]=n.brokerSecretSaveAndContinue,t[70]=n.brokerSecretTitle,t[71]=J):J=t[71];let oe;t[72]===u?oe=t[73]:(oe=u?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:u}):null,t[72]=u,t[73]=oe);let se;t[74]!==q||t[75]!==ie||t[76]!==ae||t[77]!==J||t[78]!==oe?(se=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[q,ie,ae,J,oe]}),t[74]=q,t[75]=ie,t[76]=ae,t[77]=J,t[78]=oe,t[79]=se):se=t[79];let ce;t[80]!==U||t[81]!==se?(ce=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[U,se]}),t[80]=U,t[81]=se,t[82]=ce):ce=t[82];let Y;t[83]!==ce||t[84]!==R?(Y=(0,$.jsx)(he,{className:R,children:ce}),t[83]=ce,t[84]=R,t[85]=Y):Y=t[85];let le;return t[86]!==y||t[87]!==Y?(le=(0,$.jsx)(`div`,{ref:y,id:`tunnel-broker-secret-setup`,children:Y}),t[86]=y,t[87]=Y,t[88]=le):le=t[88],le}function at(){return ie().then(ot)}function ot(e){return e.registrationSecret??null}var st={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null};function ct({embedded:e=!1}){let t=b(e=>e.language),n=y(t).tunnelSettings,r=!!x(e=>e.token),[i,a]=(0,Z.useReducer)(F,st),{actionError:o,starting:s,stopping:c,savingAutoStart:l,consentOpen:u,autoStartConfirmOpen:d,releaseConfirmOpen:f,releasing:p,brokerSecretDraft:m,savingBrokerSecret:h,authorizingBrokerSecret:v,brokerSecretAuthorizationUrl:D,brokerSecretNotice:O}=i,M=(0,Z.useRef)(null),{data:N}=E(r),{data:P,error:I,isLoading:L,mutate:R}=C(r?`tunnel-status`:null,fe,{refreshInterval:e=>s?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),z=(0,Z.useMemo)(()=>{let e=N?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return P?.config?.autoStart===!0},[N,P?.config?.autoStart]),B=(0,Z.useMemo)(()=>{let e=N?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[N]),V=te(B),H=P?.registrationSecret?.configured??V;(0,Z.useEffect)(()=>{let e=()=>{R()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[R]);let ee=(0,Z.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),U=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{starting:!0}});try{await le(),await R(),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{starting:!1}})}},[R]),W=(0,Z.useCallback)(()=>{if(!H){a({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),M.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(P?.consentRequired){a({type:`patch`,patch:{consentOpen:!0}});return}U()},[H,P?.consentRequired,U,n.brokerSecretRequiredBeforeStart]),re=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{consentOpen:!1}}),a({type:`patch`,patch:{actionError:null}});try{await se(),await Promise.all([R(),U()])}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[R,U]),G=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{stopping:!0}});try{await de(),await R(),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{stopping:!1}})}},[R]),K=(0,Z.useCallback)(async e=>{a({type:`patch`,patch:{savingAutoStart:!0}}),a({type:`patch`,patch:{actionError:null}});try{await Y({autoStart:e}),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingAutoStart:!1}})}},[]),q=(0,Z.useCallback)(()=>{if(z){K(!1);return}if(P?.consentRequired){a({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!P?.canAutoStart){a({type:`patch`,patch:{actionError:n.autoStartHint}});return}a({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[K,P?.canAutoStart,P?.consentRequired,n,z]),ie=(0,Z.useCallback)(async()=>{let e=m.trim();if(e){a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await Y({registrationSecret:e}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),T(),await R(),a({type:`patch`,patch:{actionError:null}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[m,R,n.brokerSecretSaved]),ae=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await Y({registrationSecret:null}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),T(),await R()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}},[R,n.brokerSecretCleared]),oe=(0,Z.useCallback)(async()=>{let e=_e(),t=null,r=null;a({type:`patch`,patch:{authorizingBrokerSecret:!0,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null,actionError:null}});try{for(t=(await k(`xopc-tunnel`)).sessionId;;){await new Promise(e=>window.setTimeout(e,1e3));let i=await j(t);if(i.authUrl&&i.authUrl!==r&&(r=i.authUrl,a({type:`patch`,patch:{brokerSecretAuthorizationUrl:i.authUrl}}),await ge(i.authUrl,e)),i.status===`failed`||i.status===`cancelled`)throw Error(i.error??i.message??`OAuth authorization failed`);if(i.status===`completed`){await ue(),await Promise.all([R(),T()]),a({type:`patch`,patch:{brokerSecretNotice:n.brokerSecretSaved,brokerSecretDraft:``}});return}}}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{ve(e),t&&A(t).catch(()=>void 0),a({type:`patch`,patch:{authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null}})}},[R,n.brokerSecretSaved]),ce=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await de({release:!0}),await R(),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{releasing:!1}})}},[R]),pe=(0,Z.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:y(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!r)return(0,$.jsx)(`div`,{className:e?void 0:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let X=P??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:z,brokerUrl:`https://frp.xopc.ai/api`}},me=P?.consentRequired&&(X.enabled||z||P?.consent?.acceptedAt),ye=(0,$.jsx)(it,{t:n,brokerSecretReady:H,brokerSecretConfiguredInConfig:V,brokerSecretMaskedValue:V?B:``,brokerSecretDraft:m,savingBrokerSecret:h,authorizingBrokerSecret:v,brokerSecretAuthorizationUrl:D,brokerSecretNotice:O,copyFailedLabel:y(t).clipboard.copyFailed,onDraftChange:e=>a({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void ie(),onAuthorize:()=>void oe(),onClear:()=>void ae(),sectionRef:M}),be=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ze,{open:u,title:n.consentTitle,intro:n.consentIntro,bullets:ee,checkboxLabel:n.consentCheckbox,confirmLabel:me?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void re(),onCancel:()=>a({type:`patch`,patch:{consentOpen:!1}})},u?`consent-open`:`consent-closed`),(0,$.jsx)(ne,{open:d,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{a({type:`patch`,patch:{autoStartConfirmOpen:!1}}),K(!0)},onCancel:()=>a({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(ne,{open:f,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void ce(),onCancel:()=>a({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(tt,{t:n,status:X,isLoading:L,statusErr:I,starting:s,stopping:c,showConsentExpired:!!me,copyLabels:pe,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:W,onStop:()=>void G()}),(0,$.jsxs)(Re,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:S(`flex items-center gap-3 text-sm text-fg`,!z&&!P?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:z,disabled:l||!z&&!P?.canAutoStart,onChange:q}),n.autoStart]}),!P?.canAutoStart&&!z?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,X.subdomain||X.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:p||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[p?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(Re,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(J,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),be]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(tt,{t:n,status:X,isLoading:L,statusErr:I,starting:s,stopping:c,showConsentExpired:!!me,copyLabels:pe,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,onStart:W,onStop:()=>void G()}),X.subdomain||X.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:p||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[p?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,n.release]})}):null,X.subdomain||X.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(he,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:S(`flex items-center gap-3 text-sm text-fg`,!z&&!P?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:z,disabled:l||!z&&!P?.canAutoStart,onChange:q}),n.autoStart]}),!P?.canAutoStart&&!z?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-subtle shadow-surface`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(J,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),be]})}function lt(e,t){return e.tabs[t]}function ut(e,t){return e.tabIntro[t]}function dt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function ft(e){let t=(0,Q.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(De,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ce,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ct,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ae,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fe,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(je,{}),t[6]=e):e=t[6],e}}}function pt(){let e=(0,Q.c)(3),t=i(),n=b(ht),r=y(n).remoteAccess,o=!!x(mt),[s,c]=a(),l=Le(s.get(`tab`)),u=s.get(`intent`)===`mobile-pairing`,d;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:2e3},e[0]=d):d=e[0];let f=C(u?`mobile-pairing-readiness`:null,oe,d),p;e[1]===c?p=e[2]:(p=e=>{c(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[1]=c,e[2]=p);let m=p,h=ut(r,l),g=Ie.map(e=>({id:e,label:lt(r,e)}));return(0,$.jsxs)(K,{children:[(0,$.jsx)(G,{title:r.pageTitle,subtitle:r.pageSubtitle,meta:(0,$.jsx)(J,{language:n,label:r.docsLink,section:dt(l),className:`mt-1`})}),o?(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(B,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.mobilePairingFlow.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:f.data?.ready?r.mobilePairingFlow.ready:r.mobilePairingFlow.hint})]})]}),(0,$.jsxs)(w,{variant:`primary`,disabled:!f.data?.ready,onClick:()=>t(`/settings/devices?startMobilePairing=1`),children:[f.data?.ready?r.mobilePairingFlow.continue:r.mobilePairingFlow.waiting,(0,$.jsx)(M,{className:`size-4`,"aria-hidden":!0})]})]}):null,(0,$.jsx)(ye,{items:g,activeTab:l,onChange:m,ariaLabel:r.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(q,{id:l,activeTab:l,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:lt(r,l),hint:l===`public`?void 0:h,children:(0,$.jsx)(ft,{tab:l,onOpenTab:m})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.guide.needToken})]})}function mt(e){return e.token}function ht(e){return e.language}export{pt as RemoteAccessHub};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-DPHK1VkS.js";var t=e(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]);export{t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-DPHK1VkS.js";var t=e(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]);export{t};
@@ -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{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{a,n as o,o as s,r as c,s as l,t as u}from"./dist-CpzYSoz7.js";import{n as d,r as f}from"./popover-select-C-Hj-nXR.js";import{t as p}from"./download-Dk-ZjtO6.js";import{t as m}from"./folder-open-CyzJ19I9.js";import{t as h}from"./minimize-2-DtOGrlpo.js";import{t as g}from"./plus-Q2yW6OE7.js";import{t as _}from"./search-DA7gz22f.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./messages-BbdwoxVo.js";import{a as b,n as x,r as S,s as C}from"./locale-store-CBoCuIMx.js";import{t as w}from"./cn-JdwAhgNB.js";import{i as T}from"./vendor-swr-BIWyz7Rc.js";import{t as E}from"./button-CtTvuElV.js";import{n as D,t as O}from"./interaction-BmQogeqz.js";import{n as k,r as A}from"./gateway-config-swr-826dipyU.js";import{s as j}from"./form-field-width-DJw_jULe.js";import{t as M}from"./skeleton-BwbyijEw.js";import{i as N,o as P}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as F,t as I}from"./registry-api-BhGKnvLP.js";import{Bc as L,Es as R,Fi as z,Gi as B,Ii as V,Js as H,Lc as U,Li as W,P as ee,Rc as G,Sc as te,St as ne,ai as re,ci as ie,dc as ae,fi as oe,fs as K,ii as se,li as q,ml as J,nu as ce,oi as le,pi as ue,ru as de,si as fe,uc as pe,ui as me,wl as he,xt as ge,z as Y}from"./index-Cif1_3Jx.js";import{n as _e,t as ve}from"./settings-form-section-DjWzRk4z.js";import{n as ye,t as be}from"./use-autosave-DX5YZ3Nn.js";import{t as xe}from"./page-tabs-BaEQMYm_.js";import{t as Se}from"./settings-advanced-gate-Bz4s9BBY.js";var X=e(t(),1),Ce=n(),Z=r();function we(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function Te(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ee(e){let t=(0,Ce.c)(105),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:s,onAction:c}=e,l;t[0]!==i.unnamedSession||t[1]!==n.name?(l=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=l):l=t[2];let u=l,d;t[3]===n.name?d=t[4]:(d=n.name?.trim(),t[3]=n.name,t[4]=d);let f=!!d,m=n.status===`archived`,h=n.status===`pinned`,g=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,_;t[5]===g?_=t[6]:(_=w(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,g),t[5]=g,t[6]=_);let v;t[7]===s?v=t[8]:(v=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},t[7]=s,t[8]=v);let y=r===`list`&&`sm:py-3`,b;t[9]===y?b=t[10]:(b=w(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,y),t[9]=y,t[10]=b);let x;t[11]===n.sourceChannel?x=t[12]:(x=(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=x);let S;t[13]===h?S=t[14]:(S=h?(0,Z.jsx)(ae,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=h,t[14]=S);let C;t[15]===n.updatedAt?C=t[16]:(C=we(n.updatedAt),t[15]=n.updatedAt,t[16]=C);let T;t[17]===C?T=t[18]:(T=(0,Z.jsx)(`span`,{children:C}),t[17]=C,t[18]=T);let E;t[19]!==T||t[20]!==S?(E=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[S,T]}),t[19]=T,t[20]=S,t[21]=E):E=t[21];let D;t[22]!==E||t[23]!==b||t[24]!==x?(D=(0,Z.jsxs)(`div`,{className:b,children:[x,E]}),t[22]=E,t[23]=b,t[24]=x,t[25]=D):D=t[25];let k=r===`list`&&`sm:py-3`,A;t[26]===k?A=t[27]:(A=w(`min-w-0 flex-1 px-3 py-2`,k),t[26]=k,t[27]=A);let j=r===`list`&&`sm:items-start`,M;t[28]===j?M=t[29]:(M=w(`flex gap-3`,j),t[28]=j,t[29]=M);let N;t[30]!==o||t[31]!==a?(N=(0,Z.jsx)(ee,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=o,t[31]=a,t[32]=N):N=t[32];let P;t[33]===u?P=t[34]:(P=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:u,children:u}),t[33]=u,t[34]=P);let F;t[35]!==n.key||t[36]!==f?(F=f?(0,Z.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[35]=n.key,t[36]=f,t[37]=F):F=t[37];let I;t[38]!==P||t[39]!==F?(I=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[P,F]}),t[38]=P,t[39]=F,t[40]=I):I=t[40];let L;t[41]!==M||t[42]!==N||t[43]!==I?(L=(0,Z.jsxs)(`div`,{className:M,children:[N,I]}),t[41]=M,t[42]=N,t[43]=I,t[44]=L):L=t[44];let z;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(te,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=z):z=t[45];let B;t[46]===n.messageCount?B=t[47]:(B=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[z,n.messageCount]}),t[46]=n.messageCount,t[47]=B);let V;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(K,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=V):V=t[48];let H;t[49]===n.estimatedTokens?H=t[50]:(H=Te(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=H);let U;t[51]===H?U=t[52]:(U=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[V,H]}),t[51]=H,t[52]=U);let W;t[53]!==B||t[54]!==U?(W=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[B,U]}),t[53]=B,t[54]=U,t[55]=W):W=t[55];let G;t[56]===n.tags?G=t[57]:(G=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(ke),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=G);let ne;t[58]!==A||t[59]!==L||t[60]!==W||t[61]!==G?(ne=(0,Z.jsxs)(`div`,{className:A,children:[L,W,G]}),t[58]=A,t[59]=L,t[60]=W,t[61]=G,t[62]=ne):ne=t[62];let re;t[63]===c?re=t[64]:(re=()=>c(`continue`),t[63]=c,t[64]=re);let ie;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsx)(te,{className:`size-4`,strokeWidth:1.75}),t[65]=ie):ie=t[65];let oe;t[66]!==i.continueChat||t[67]!==re?(oe=(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.continueChat,"aria-label":i.continueChat,onClick:re,children:ie}),t[66]=i.continueChat,t[67]=re,t[68]=oe):oe=t[68];let se;t[69]!==m||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==c?(se=m?(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>c(`unarchive`),children:(0,Z.jsx)(de,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.archive,"aria-label":i.archive,onClick:()=>c(`archive`),children:(0,Z.jsx)(ce,{className:`size-4`,strokeWidth:1.75})}),t[69]=m,t[70]=i.archive,t[71]=i.unarchive,t[72]=c,t[73]=se):se=t[73];let q;t[74]!==h||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==c?(q=h?(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.unpin,"aria-label":i.unpin,onClick:()=>c(`unpin`),children:(0,Z.jsx)(pe,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.pin,"aria-label":i.pin,onClick:()=>c(`pin`),children:(0,Z.jsx)(ae,{className:`size-4`,strokeWidth:1.75})}),t[74]=h,t[75]=i.pin,t[76]=i.unpin,t[77]=c,t[78]=q):q=t[78];let J;t[79]===c?J=t[80]:(J=()=>c(`export`),t[79]=c,t[80]=J);let le;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Z.jsx)(p,{className:`size-4`,strokeWidth:1.75}),t[81]=le):le=t[81];let ue;t[82]!==i.export||t[83]!==J?(ue=(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.export,"aria-label":i.export,onClick:J,children:le}),t[82]=i.export,t[83]=J,t[84]=ue):ue=t[84];let fe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(fe=w(O,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=fe):fe=t[85];let me;t[86]===c?me=t[87]:(me=()=>c(`delete`),t[86]=c,t[87]=me);let he;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Z.jsx)(R,{className:`size-4`,strokeWidth:1.75}),t[88]=he):he=t[88];let ge;t[89]!==i.delete||t[90]!==me?(ge=(0,Z.jsx)(`button`,{type:`button`,className:fe,title:i.delete,"aria-label":i.delete,onClick:me,children:he}),t[89]=i.delete,t[90]=me,t[91]=ge):ge=t[91];let Y;t[92]!==oe||t[93]!==se||t[94]!==q||t[95]!==ue||t[96]!==ge?(Y=(0,Z.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:Oe,onKeyDown:De,children:[oe,se,q,ue,ge]}),t[92]=oe,t[93]=se,t[94]=q,t[95]=ue,t[96]=ge,t[97]=Y):Y=t[97];let _e;return t[98]!==s||t[99]!==D||t[100]!==ne||t[101]!==_||t[102]!==Y||t[103]!==v?(_e=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:_,onClick:s,onKeyDown:v,children:[D,ne,Y]}),t[98]=s,t[99]=D,t[100]=ne,t[101]=_,t[102]=Y,t[103]=v,t[104]=_e):_e=t[104],_e}function De(e){return e.stopPropagation()}function Oe(e){return e.stopPropagation()}function ke(e){return(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Ae(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function je(e,t){return t.find(t=>t.id===e)?.avatar}var Me={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:2e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pe(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Fe(e){let t=Ne(e)?e:{},n=Ne(t.userContext)?t.userContext:{},r=Ne(n.memory)?n.memory:{},i=Ne(r.retention)?r.retention:{},a=Ne(i.compaction)?i.compaction:{},o=Me,s=typeof a.model==`string`&&a.model.trim()?a.model.trim():void 0,c=Array.isArray(a.postCompactionSections)&&a.postCompactionSections.length<=12&&a.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(a.postCompactionSections.map(e=>e.trim()))]:[...o.postCompactionSections];return{enabled:typeof a.enabled==`boolean`?a.enabled:o.enabled,triggerThreshold:Pe(a.triggerThreshold,o.triggerThreshold,.1,.98),reserveTokens:Q(a.reserveTokens,o.reserveTokens,1024),minMessagesBeforeCompact:Q(a.minMessagesBeforeCompact,o.minMessagesBeforeCompact,2),keepRecentTokens:Q(a.keepRecentTokens,o.keepRecentTokens,1e3),recentTurnsPreserve:Q(a.recentTurnsPreserve,o.recentTurnsPreserve,1,12),summaryMaxTokens:Q(a.summaryMaxTokens,o.summaryMaxTokens,256),summaryChunkTokens:Q(a.summaryChunkTokens,o.summaryChunkTokens,1e3),summaryTimeoutMs:Q(a.summaryTimeoutMs,o.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(a.summaryRetries,o.summaryRetries,0,5),qualityGuard:typeof a.qualityGuard==`boolean`?a.qualityGuard:o.qualityGuard,gapAudit:typeof a.gapAudit==`boolean`?a.gapAudit:o.gapAudit,...s?{model:s}:{},minToolResultKeepChars:Q(a.minToolResultKeepChars,o.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(a.maxActiveTranscriptBytes,o.maxActiveTranscriptBytes,64e3),postCompactionSections:c}}function Ie(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Le(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{memory:{retention:{compaction:t}}}}}async function Re(e){await b(S(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await k()}var ze=128e3,Be={balanced:Me,preserve:{...Me,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Me,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ve=z();function He(){return w(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,j,`dark:border-edge`)}function Ue(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function We(e){let t=Ue(e);for(let[e,n]of Object.entries(Be))if(t===Ue(n))return e;return`custom`}function Ge(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Ce.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=He(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ke(e){let t=(0,Ce.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=w(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n?d=t[9]:(d=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=d);let f;t[10]===r?f=t[11]:(f=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`span`,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==u||t[17]!==p?(m=(0,Z.jsxs)(`label`,{className:c,children:[u,p]}),t[15]=c,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}function qe({hasToken:e}){let t=y(x(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=A(e),{data:i=[],isLoading:a}=T(e?I:null,F,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[s,c]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[l,u]=(0,X.useState)(``),d=(0,X.useRef)(!1),f=(0,X.useRef)(s.form);f.current=s.form;let p=(0,X.useRef)(null);V({enabled:e,parsed:o,dirty:d.current,trackedParsedRef:p,dispatch:c,onResetDirty:()=>{d.current=!1}});let m=s.form,_=s.baseline,b=!!(m&&_&&JSON.stringify(m)!==JSON.stringify(_)),S=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),C=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),O=be({value:m,dirty:b,onSave:(0,X.useCallback)(async e=>{try{await Re(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ie(e);return n?t.invalidValue.replace(`{{field}}`,C(n)):null}});if(!e||!m)return r?(0,Z.jsx)(ve,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(M,{className:`h-5 w-48`}),(0,Z.jsx)(M,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(M,{className:`h-36 w-full rounded-xl`})]})}):null;let k=We(m),j=Math.max(0,ze-m.reserveTokens),N=Math.min(Math.floor(ze*m.triggerThreshold),j),P=Math.min(100,N/ze*100),L=Math.min(100,j/ze*100),R=m.model?i.find(e=>e.id===m.model):void 0,z=R?.contextWindow&&m.summaryChunkTokens+m.summaryMaxTokens+4096>R.contextWindow,B=m.keepRecentTokens+m.reserveTokens>N,H=Math.round(m.summaryTimeoutMs*(m.summaryRetries+1)/1e3),U=e=>{let t=Be[e];S({...t,...m.model?{model:m.model}:{model:void 0},postCompactionSections:m.postCompactionSections})},W={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},ee=()=>{let e=l.trim();!e||m.postCompactionSections.includes(e)||m.postCompactionSections.length>=12||(S({postCompactionSections:[...m.postCompactionSections,e]}),u(``))};return(0,Z.jsxs)(ve,{onBlurCapture:O.onBlurCapture,children:[(0,Z.jsx)(_e,{icon:h,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(ye,{status:O.status,error:O.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:m.enabled,onChange:e=>S({enabled:e.target.checked})}),m.enabled?t.enabled:t.disabled]})]})}),O.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:O.error}):null,m.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!m.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),k===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":k===e,className:w(`rounded-xl border px-3 py-3 text-left`,D.transition,D.focusRingPanel,k===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>U(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:W[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:W[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-hover/35 p-4 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(N)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${P}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(j)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${L}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((m.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>S({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(m.reserveTokens)),value:m.reserveTokens,min:1024,step:1024,onChange:e=>S({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:m.recentTurnsPreserve,min:1,max:12,onChange:e=>S({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(m.keepRecentTokens)),value:m.keepRecentTokens,min:1e3,step:1e3,onChange:e=>S({keepRecentTokens:Math.floor(e)})})]}),B?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(Y,{value:m.model??``,disabled:!m.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>S({model:e})}),m.model?(0,Z.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>S({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:m.qualityGuard,onChange:e=>S({qualityGuard:e})}),(0,Z.jsx)(Ke,{label:t.gapAudit,hint:t.gapAuditHint,checked:m.gapAudit,onChange:e=>S({gapAudit:e})})]}),m.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(Se,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 border-t border-edge pt-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:m.minMessagesBeforeCompact,min:2,onChange:e=>S({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((m.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>S({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:m.summaryMaxTokens,min:256,step:256,onChange:e=>S({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:m.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>S({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(H)),value:m.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>S({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:m.summaryRetries,min:0,max:5,onChange:e=>S({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:m.minToolResultKeepChars,min:200,step:100,onChange:e=>S({minToolResultKeepChars:Math.floor(e)})})]}),z?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`border-t border-edge pt-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),m.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:m.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:w(`text-fg-muted hover:text-fg`,D.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>S({postCompactionSections:m.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(v,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:He(),value:l,maxLength:120,disabled:m.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ee())}}),(0,Z.jsxs)(E,{type:`button`,variant:`secondary`,disabled:!l.trim()||m.postCompactionSections.length>=12,onClick:ee,children:[(0,Z.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ye(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function Xe(e){let t=Je(e)?e:{},n=Je(t.session)?t.session:{},r=Je(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:Ye(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Ze(e){await b(S(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),k()}function Qe(){return w(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,j,`dark:border-edge`)}var $e=z();function et({hasToken:e}){let t=y(x(e=>e.language)).sessions.config,{data:n,isLoading:r}=A(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[a,o]=(0,X.useReducer)($e,{form:null,baseline:null}),s=a.form,c=a.baseline,l=(0,X.useRef)(!1),u=(0,X.useRef)(s);u.current=s;let p=(0,X.useRef)(null);V({enabled:e,parsed:i,dirty:l.current,trackedParsedRef:p,dispatch:o,onResetDirty:()=>{l.current=!1}});let m=!!(s&&c&&JSON.stringify(s)!==JSON.stringify(c)),h=(0,X.useCallback)(e=>{l.current=!0,o({type:`patch`,patch:e})},[]),g=be({value:s,dirty:m,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),o({type:`saved`,value:e}),l.current=!!(u.current&&JSON.stringify(u.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!s?r?(0,Z.jsx)(ve,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(M,{className:`h-5 w-40`}),(0,Z.jsx)(M,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(ve,{onBlurCapture:g.onBlurCapture,children:[(0,Z.jsx)(_e,{icon:J,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(ye,{status:g.status,error:g.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(d,{className:Qe(),value:s.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Z.jsx)(f,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(f,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(f,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(f,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:Qe(),value:s.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:Qe(),value:s.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function tt(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function nt(e){let t=(0,Ce.c)(60),{open:n,loading:r,session:i,sessionAgentId:d,sessionAgentAvatar:f,labels:p,onClose:m,onArchive:h,onUnarchive:g,onPin:_,onUnpin:y,onExport:b,onDelete:x}=e,S=i?.status===`archived`,C=i?.status===`pinned`,T;t[0]===m?T=t[1]:(T=e=>!e&&m(),t[0]=m,t[1]=T);let D;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(a,{className:w(`xopc-dialog-overlay fixed inset-0 bg-scrim`,P)}),t[2]=D):D=t[2];let O;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(O=w(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,N,`dark:border-edge`),t[3]=O):O=t[3];let k;t[4]!==i||t[5]!==f||t[6]!==d?(k=i&&d?(0,Z.jsx)(ee,{agentId:d,avatar:f,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=f,t[6]=d,t[7]=k):k=t[7];let A;t[8]!==p.unnamedSession||t[9]!==i?.name?(A=i?.name?.trim()||p.unnamedSession,t[8]=p.unnamedSession,t[9]=i?.name,t[10]=A):A=t[10];let j;t[11]===A?j=t[12]:(j=(0,Z.jsx)(l,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:A}),t[11]=A,t[12]=j);let M;t[13]!==k||t[14]!==j?(M=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[k,j]}),t[13]=k,t[14]=j,t[15]=M):M=t[15];let F;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75}),t[16]=F):F=t[16];let I;t[17]===p.close?I=t[18]:(I=(0,Z.jsx)(o,{asChild:!0,children:(0,Z.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":p.close,children:F})}),t[17]=p.close,t[18]=I);let L;t[19]!==M||t[20]!==I?(L=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[M,I]}),t[19]=M,t[20]=I,t[21]=L):L=t[21];let R;t[22]!==p.detailLoading||t[23]!==p.detailMessages||t[24]!==r||t[25]!==i?(R=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=p.detailLoading,t[23]=p.detailMessages,t[24]=r,t[25]=i,t[26]=R):R=t[26];let z;t[27]===R?z=t[28]:(z=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:R}),t[27]=R,t[28]=z);let B;t[29]!==p.detailExport||t[30]!==b?(B=(0,Z.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:b,children:p.detailExport}),t[29]=p.detailExport,t[30]=b,t[31]=B):B=t[31];let V;t[32]!==S||t[33]!==p.archive||t[34]!==p.unarchive||t[35]!==h||t[36]!==g?(V=S?(0,Z.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:p.unarchive}):(0,Z.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:p.archive}),t[32]=S,t[33]=p.archive,t[34]=p.unarchive,t[35]=h,t[36]=g,t[37]=V):V=t[37];let H;t[38]!==C||t[39]!==p.pin||t[40]!==p.unpin||t[41]!==_||t[42]!==y?(H=C?(0,Z.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:y,children:p.unpin}):(0,Z.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:_,children:p.pin}),t[38]=C,t[39]=p.pin,t[40]=p.unpin,t[41]=_,t[42]=y,t[43]=H):H=t[43];let U;t[44]!==p.delete||t[45]!==x?(U=(0,Z.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:x,children:p.delete}),t[44]=p.delete,t[45]=x,t[46]=U):U=t[46];let W;t[47]!==B||t[48]!==V||t[49]!==H||t[50]!==U?(W=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[B,V,H,U]})}),t[47]=B,t[48]=V,t[49]=H,t[50]=U,t[51]=W):W=t[51];let G;t[52]!==L||t[53]!==z||t[54]!==W?(G=(0,Z.jsxs)(s,{children:[D,(0,Z.jsxs)(c,{className:O,"aria-describedby":void 0,children:[L,z,W]})]}),t[52]=L,t[53]=z,t[54]=W,t[55]=G):G=t[55];let te;return t[56]!==n||t[57]!==T||t[58]!==G?(te=(0,Z.jsx)(u,{open:n,onOpenChange:T,children:G}),t[56]=n,t[57]=T,t[58]=G,t[59]=te):te=t[59],te}function rt(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:tt(e.content)})]},`${e.timestamp??``}-${e.role}-${tt(e.content).slice(0,24)}`)}var it=20;function at(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ot=new Set([`all`,`active`,`pinned`,`archived`]),st=new Set([`grid`,`list`]),ct=[`sessions`,`settings`];function lt(e){return e&&ct.includes(e)?e:`sessions`}function ut(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function dt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function ft(e){let t=(0,Ce.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=ct.map(e=>({id:e,label:ut(n,e),icon:e===`sessions`?L:H})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(xe,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function pt(e){let t=(0,Ce.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ut(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:dt(n,r)})]}),(0,Z.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function mt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ot.has(t)?t:`all`,viewMode:st.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function ht(){let e=y(x(e=>e.language)),t=e.sessions,n=C(e=>e.token),r=!!n,{data:o,mutate:d}=T(r?[`gateway-chat-agents`,n]:null,B,{revalidateOnFocus:!1}),f=o?.defaultId??`main`,p=o?.items??[],[h,g]=i(),v=lt(h.get(`tab`)),b=(0,X.useCallback)(e=>{let t=new URLSearchParams(h);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),g(t,{replace:!0})},[h,g]),[S,O]=(0,X.useReducer)(W,h,mt),{searchInput:k,debouncedSearch:A,statusFilter:j,viewMode:M,channelFilter:F,sessions:I,loading:R,error:z,hasMore:V,stats:H,detailOpen:ee,detailLoading:te,detailSession:K,confirmOpen:J,confirmKey:de}=S;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=k.trim();A!==e&&O({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[k,A]);let pe=h.toString(),Y=(0,X.useRef)(pe);if(Y.current!==pe){Y.current=pe;let e=h.get(`q`)??``,t=h.get(`status`),n=h.get(`view`),r=(h.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();O({type:`patch`,patch:{...k===e?{}:{searchInput:e},...A===o?{}:{debouncedSearch:o},...j===i?{}:{statusFilter:i},...M===a?{}:{viewMode:a},...F===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(h),t=A.trim();t?e.set(`q`,t):e.delete(`q`),j===`all`?e.delete(`status`):e.set(`status`,j),M===`grid`?e.delete(`view`):e.set(`view`,M),F?e.set(`channel`,F):e.delete(`channel`),e.toString()!==h.toString()&&g(e,{replace:!0})},[A,h,g,j,M,F]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=!1;return(async()=>{O({type:`patch`,patch:{loading:!0,error:null}});try{let t=await q({limit:it,offset:0,...A?{search:A}:{},...j===`all`?{}:{status:j},...F?{channel:F}:{}});if(e)return;O({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||O({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||O({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,v,A,j,F,t.loadError]),(0,X.useEffect)(()=>{!r||v!==`sessions`||ie().then(e=>O({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,v]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=()=>void d();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,v,d]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||O({type:`patch`,patch:{sessions:I.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:K&&K.key===t.key?{...K,name:t.name}:K}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,v,I,K]);let _e=(0,X.useCallback)(async()=>{if(!(!r||R||!V)){O({type:`patch`,patch:{loading:!0,error:null}});try{let e=await q({limit:it,offset:I.length,...A?{search:A}:{},...j===`all`?{}:{status:j},...F?{channel:F}:{}});O({type:`patch`,patch:{sessions:[...I,...e.items],hasMore:e.hasMore}})}catch(e){O({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{O({type:`patch`,patch:{loading:!1}})}}},[r,R,V,I.length,A,j,F,t.loadError]),ve=(0,X.useCallback)((e,t)=>{O({type:`patch`,patch:{sessions:I.map(n=>n.key===e?{...n,status:t}:n),detailSession:K&&K.key===e?{...K,status:t}:K}})},[I,K]),ye=(0,X.useCallback)(async e=>{O({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{O({type:`patch`,patch:{detailSession:await fe(e)}})}catch{O({type:`patch`,patch:{detailOpen:!1}})}finally{O({type:`patch`,patch:{detailLoading:!1}})}},[]),be=e=>{ye(e)},xe=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){O({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await se(e),ve(e,`archived`);break;case`unarchive`:await oe(e),ve(e,`active`);break;case`pin`:await me(e),ve(e,`pinned`);break;case`unpin`:await ue(e),ve(e,`active`);break;case`export`:{let t=await le(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}ie().then(e=>O({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Se=async e=>{try{await re(e),O({type:`patch`,patch:{sessions:I.filter(t=>t.key!==e),detailSession:K?.key===e?null:K,...K?.key===e?{detailOpen:!1}:{}}}),ie().then(e=>O({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},we={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Te=[{key:`all`,label:t.filterAll,icon:L},{key:`active`,label:t.filterActive,icon:he},{key:`pinned`,label:t.filterPinned,icon:ae},{key:`archived`,label:t.filterArchived,icon:ce}],De=(()=>{let e=Object.entries(H?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Z.jsx)(ft,{s:t,activeTab:v,onChange:b}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:v,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(qe,{hasToken:r}),(0,Z.jsx)(et,{hasToken:r})]})}),(0,Z.jsxs)(pt,{s:t,id:`sessions`,activeTab:v,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Te.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":j===e,onClick:()=>O({type:`patch`,patch:{statusFilter:e}}),className:w(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,D.transition,D.focusRingPanel,j===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(_,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:k,onChange:e=>O({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":A||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!F,onClick:()=>O({type:`patch`,patch:{channelFilter:``}}),className:w(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,D.transition,D.focusRingPanel,F?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),De.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":F===e,onClick:()=>O({type:`patch`,patch:{channelFilter:e}}),className:w(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,D.transition,D.focusRingPanel,F===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,H?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:H.byChannel[e]})]},e))]}),H?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[H.totalSessions,t.totalSessions],[H.activeSessions,t.activeSessions],[H.pinnedSessions,t.pinnedSessions],[H.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,z?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:z}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:at(t.sessionCount,{count:I.length})}),(0,Z.jsxs)(`div`,{className:ne,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(E,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":M===`grid`,onClick:()=>O({type:`patch`,patch:{viewMode:`grid`}}),className:w(ge,`size-7 p-0`,M===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(G,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(E,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":M===`list`,onClick:()=>O({type:`patch`,patch:{viewMode:`list`}}),className:w(ge,`size-9 p-0`,M===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`list`&&`text-accent-fg`),children:(0,Z.jsx)(U,{className:`size-3.5`,strokeWidth:1.5})})]})]}),R&&I.length===0?(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):I.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Z.jsx)(m,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(E,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:w(`grid min-w-0 gap-3`,M===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":A||void 0,children:I.map(e=>{let t=Ae(e,f);return(0,Z.jsx)(Ee,{session:e,variant:M,labels:Ce,sessionAgentId:t,sessionAgentAvatar:je(t,p),onOpen:()=>be(e.key),onAction:t=>void xe(e.key,t)},e.key)})}),V?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(E,{type:`button`,variant:`secondary`,disabled:R,onClick:()=>void _e(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:ee,loading:te,session:K,sessionAgentId:K?Ae(K,f):void 0,sessionAgentAvatar:K?je(Ae(K,f),p):void 0,labels:we,onClose:()=>{O({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>K&&void xe(K.key,`archive`),onUnarchive:()=>K&&void xe(K.key,`unarchive`),onPin:()=>K&&void xe(K.key,`pin`),onUnpin:()=>K&&void xe(K.key,`unpin`),onExport:()=>K&&void xe(K.key,`export`),onDelete:()=>K&&O({type:`patch`,patch:{confirmKey:K.key,confirmOpen:!0}})}),(0,Z.jsx)(u,{open:J,onOpenChange:e=>O({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(s,{children:[(0,Z.jsx)(a,{className:w(`xopc-dialog-overlay fixed inset-0 bg-scrim`,P)}),(0,Z.jsxs)(c,{className:w(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,N),children:[(0,Z.jsx)(l,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:de?at(t.deleteSessionMessage,{name:I.find(e=>e.key===de)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>O({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(E,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{de&&Se(de),O({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{ht as SessionsPage};
@@ -1 +0,0 @@
1
- import{$t as e}from"./index-Cif1_3Jx.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};