@xopcai/xopc 0.0.174 → 0.0.176

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 (242) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-CyEDJeIt.js → activity-store-DsFM1upC.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DF7Bol6I.js → agent-avatar-dicebear-DvdMLOga.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-BVjlpbeZ.js +2 -0
  6. package/dist/gateway/static/root/assets/{api-DYunqroX.js → api-BdPLCCBm.js} +1 -1
  7. package/dist/gateway/static/root/assets/{api-DwyUxpgY.js → api-Bop4IQRW.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-B4xJyvDu.js → app-management-settings-panel-DMLDOHul.js} +1 -1
  9. package/dist/gateway/static/root/assets/appearance-settings-DbI9foFR.js +1 -0
  10. package/dist/gateway/static/root/assets/apps-page-njqxLWYD.js +1 -0
  11. package/dist/gateway/static/root/assets/{archive-plugin-DWhBmmjD.js → archive-plugin-Dfdxuwvb.js} +1 -1
  12. package/dist/gateway/static/root/assets/{attachment-load-BOpZfa_I.js → attachment-load-Dn3RlnYD.js} +2 -2
  13. package/dist/gateway/static/root/assets/{attachment-preview-renderer-DonnL2dL.js → attachment-preview-renderer-Cmo-5BP5.js} +2 -2
  14. package/dist/gateway/static/root/assets/{attachment-process-heavy-RnGYy9bC.js → attachment-process-heavy-B2_kr5EA.js} +3 -3
  15. package/dist/gateway/static/root/assets/{automation-suggestion-card-Byu3I7Rs.js → automation-suggestion-card-Bc0Y7A9u.js} +1 -1
  16. package/dist/gateway/static/root/assets/automations-page-D-eweHZJ.js +6 -0
  17. package/dist/gateway/static/root/assets/{binary-plugins-6AG1qatz.js → binary-plugins-0XtB-xC0.js} +2 -2
  18. package/dist/gateway/static/root/assets/{block-editor-CJhrn98_.js → block-editor-C4fXWbEE.js} +6 -6
  19. package/dist/gateway/static/root/assets/browser-settings-page-lC86-drr.js +8 -0
  20. package/dist/gateway/static/root/assets/{browser-workflow-inputs-CBVb4mt9.js → browser-workflow-inputs-CZmzNymN.js} +1 -1
  21. package/dist/gateway/static/root/assets/{browser-workflows-page-Cq4XUKbu.js → browser-workflows-page-CBYM9HqG.js} +2 -2
  22. package/dist/gateway/static/root/assets/capabilities-settings-panel-6tYNfHqJ.js +7 -0
  23. package/dist/gateway/static/root/assets/{capability-presets-api-hbW4NAKO.js → capability-presets-api-BiJxmmhW.js} +1 -1
  24. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Co-ymbd9.js +1 -0
  25. package/dist/gateway/static/root/assets/{channel-recipient-api-CzMjHb17.js → channel-recipient-api-BKTUZDp-.js} +1 -1
  26. package/dist/gateway/static/root/assets/channels-settings-D46eVjaQ.js +1 -0
  27. package/dist/gateway/static/root/assets/channels-status-swr-BMRAO4zZ.js +1 -0
  28. package/dist/gateway/static/root/assets/{connector-logo-B9Au6gMZ.js → connector-logo-Pr4RIKjj.js} +1 -1
  29. package/dist/gateway/static/root/assets/connectors-page-Dw1eYbRi.js +2 -0
  30. package/dist/gateway/static/root/assets/desktop-pet-B8cZuQUt.js +1 -0
  31. package/dist/gateway/static/root/assets/{desktop-pet-settings-CNff5TFb.js → desktop-pet-settings-CEQacUDF.js} +1 -1
  32. package/dist/gateway/static/root/assets/{directory-picker-path-field-Bf956uo-.js → directory-picker-path-field-DWnxdZtc.js} +1 -1
  33. package/dist/gateway/static/root/assets/{dreaming-settings-CHM8FE1g.js → dreaming-settings-D2e2w2Ho.js} +3 -3
  34. package/dist/gateway/static/root/assets/{extension-debug-page-ZqM_0eUs.js → extension-debug-page-BLjTGbv3.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-D4hvXOMM.js → extension-page-D2_UC6hy.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-GsqxaJjA.js → extension-settings-page-BsH6o_PX.js} +1 -1
  37. package/dist/gateway/static/root/assets/{focus-detail-page-CE6uwrl1.js → focus-detail-page-BBXUtxRB.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-config-api-B4THmgnS.js → gateway-config-api-C-DkC6UJ.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-settings-CPv-MxGE.js → gateway-settings-DEOGiimF.js} +1 -1
  40. package/dist/gateway/static/root/assets/{gateway-startup-retry-MP3K71pP.js → gateway-startup-retry-BlSLh1TF.js} +1 -1
  41. package/dist/gateway/static/root/assets/goal-create-dialog-CSFcRE_N.js +1 -0
  42. package/dist/gateway/static/root/assets/goal-detail-page-VjRArfAJ.js +4 -0
  43. package/dist/gateway/static/root/assets/{goals-config-api-DCcDuIjG.js → goals-config-api-CcdS9qek.js} +1 -1
  44. package/dist/gateway/static/root/assets/goals-page-BAcErdch.js +2 -0
  45. package/dist/gateway/static/root/assets/{goals-settings-o9QMXvNq.js → goals-settings-BY7crl0z.js} +1 -1
  46. package/dist/gateway/static/root/assets/{heartbeat-settings-DixwpXnH.js → heartbeat-settings-DtTkS0gs.js} +1 -1
  47. package/dist/gateway/static/root/assets/{image-generation-api-BOGH9FGi.js → image-generation-api-WGgkbwDZ.js} +1 -1
  48. package/dist/gateway/static/root/assets/index-2UImfRDC.js +212 -0
  49. package/dist/gateway/static/root/assets/index-CS9sVShT.css +1 -0
  50. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D4o4ZPF6.js → keyboard-shortcuts-settings-C5lpWQ3f.js} +1 -1
  51. package/dist/gateway/static/root/assets/local-app-workbench-page-Cl0fcPL4.js +2 -0
  52. package/dist/gateway/static/root/assets/{local-apps-page-GzMmpO7G.js → local-apps-page-b05wWvXG.js} +1 -1
  53. package/dist/gateway/static/root/assets/{locale-store-CAuhEGCn.js → locale-store-sToMfHX_.js} +1 -1
  54. package/dist/gateway/static/root/assets/logs-page-cDE1jLJv.js +7 -0
  55. package/dist/gateway/static/root/assets/{markdown-split-CIX8D1pv.js → markdown-split-0gPVst5y.js} +1 -1
  56. package/dist/gateway/static/root/assets/{media-plugins-Bp3eIA45.js → media-plugins-Rxyq_KTm.js} +1 -1
  57. package/dist/gateway/static/root/assets/messages-CarlxqXV.js +3 -0
  58. package/dist/gateway/static/root/assets/{notes-page-RVFiYAoO.js → notes-page-DRhNDl_Q.js} +1 -1
  59. package/dist/gateway/static/root/assets/notes-workbench-BKNBk0Uf.js +4 -0
  60. package/dist/gateway/static/root/assets/{page-tabs-BGAYH3Ef.js → page-tabs-cOEOQqHh.js} +1 -1
  61. package/dist/gateway/static/root/assets/pdf-D4PI9qAw.js +54 -0
  62. package/dist/gateway/static/root/assets/pdf.worker.min-CHFwMXne.mjs +29 -0
  63. package/dist/gateway/static/root/assets/{preview-open-alternatives-BM6pDkHp.js → preview-open-alternatives-BopOLFvu.js} +1 -1
  64. package/dist/gateway/static/root/assets/{product-open-page-BiMetEmn.js → product-open-page-DWVPmmOq.js} +1 -1
  65. package/dist/gateway/static/root/assets/project-detail-page-BhjEXNQW.js +1 -0
  66. package/dist/gateway/static/root/assets/projects-page-B80e69PH.js +1 -0
  67. package/dist/gateway/static/root/assets/remote-access-hub-CwdVob6H.js +1 -0
  68. package/dist/gateway/static/root/assets/{save-bar-controls-BdjV8MK5.js → save-bar-controls-BfZmKe1t.js} +1 -1
  69. package/dist/gateway/static/root/assets/{schedule-field-ChlqXU46.js → schedule-field-Cpi4jCRV.js} +1 -1
  70. package/dist/gateway/static/root/assets/{schema-form-DDKf5ZSH.js → schema-form-OXFkcZQe.js} +1 -1
  71. package/dist/gateway/static/root/assets/sessions-page-BGt3Asj6.js +1 -0
  72. package/dist/gateway/static/root/assets/settings-advanced-gate-BnTdM9Nn.js +1 -0
  73. package/dist/gateway/static/root/assets/{settings-form-section-CPG0KGVs.js → settings-form-section-BwqkZCHJ.js} +1 -1
  74. package/dist/gateway/static/root/assets/{settings-loading-skeleton-DRSDHucM.js → settings-loading-skeleton-BbqH_S3Y.js} +1 -1
  75. package/dist/gateway/static/root/assets/{settings-page-CeB7_xD0.js → settings-page-BoxC-JSa.js} +1 -1
  76. package/dist/gateway/static/root/assets/{settings-page-layout-BENrkwd0.js → settings-page-layout-Ddu2iGaW.js} +1 -1
  77. package/dist/gateway/static/root/assets/setup-status-panel-z1Lwv0js.js +1 -0
  78. package/dist/gateway/static/root/assets/{share-preview-page-DIzczJkG.js → share-preview-page-CVazOFjy.js} +2 -2
  79. package/dist/gateway/static/root/assets/shares-settings-C4lXuyQj.js +1 -0
  80. package/dist/gateway/static/root/assets/skill-reload-api-DSuIDkeI.js +1 -0
  81. package/dist/gateway/static/root/assets/skills-page-xgZczqVe.js +2 -0
  82. package/dist/gateway/static/root/assets/skills-page.utils-DgyB1tSo.js +1 -0
  83. package/dist/gateway/static/root/assets/{system-settings-panel-Dp4d5Q1B.js → system-settings-panel-BoLSQL65.js} +1 -1
  84. package/dist/gateway/static/root/assets/{theme-store-CbGc1laW.js → theme-store-CBNcGOfj.js} +1 -1
  85. package/dist/gateway/static/root/assets/time-picker-gochWrny.js +1 -0
  86. package/dist/gateway/static/root/assets/{typed-models-lib-DwPk3OPL.js → typed-models-lib-DvRnr7YB.js} +1 -1
  87. package/dist/gateway/static/root/assets/{use-channel-catalog-CXrEu2dw.js → use-channel-catalog-CA9BFVB7.js} +1 -1
  88. package/dist/gateway/static/root/assets/user-context-page-CEfIy4WZ.js +1 -0
  89. package/dist/gateway/static/root/assets/{voice-api-key-field-DFoA79LB.js → voice-api-key-field-v8tgylEZ.js} +1 -1
  90. package/dist/gateway/static/root/assets/work-discovery-page-B-3MClaf.js +1 -0
  91. package/dist/gateway/static/root/assets/work-item-detail-page-CEsFEdax.js +1 -0
  92. package/dist/gateway/static/root/assets/work-page-CT9AHnq6.js +3 -0
  93. package/dist/gateway/static/root/assets/workflow-run-setup-panel-CC3cJn5k.js +3 -0
  94. package/dist/gateway/static/root/assets/workflows-page-C-1-_Zp1.js +11 -0
  95. package/dist/gateway/static/root/index.html +7 -7
  96. package/dist/package.js +1 -1
  97. package/dist/src/agent/agent-manager.js +8 -8
  98. package/dist/src/agent/context/execution-scope.d.ts +26 -0
  99. package/dist/src/agent/context/execution-scope.js +84 -0
  100. package/dist/src/agent/context/project-context.d.ts +3 -1
  101. package/dist/src/agent/context/project-context.js +26 -8
  102. package/dist/src/agent/embedded/model-runtime.d.ts +1 -2
  103. package/dist/src/agent/embedded/model-runtime.js +17 -29
  104. package/dist/src/agent/embedded/session-runner.js +2 -3
  105. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  106. package/dist/src/agent/prompt/service-prompt-builder.js +1 -0
  107. package/dist/src/agent/prompt/system-prompt.js +1 -1
  108. package/dist/src/agent/service/process-direct-streaming.js +7 -4
  109. package/dist/src/agent/service.js +1 -1
  110. package/dist/src/agent/session/session-config-service.d.ts +4 -1
  111. package/dist/src/agent/session/session-config-service.js +5 -3
  112. package/dist/src/agent/session/session-inspector.d.ts +6 -0
  113. package/dist/src/agent/session/session-inspector.js +9 -2
  114. package/dist/src/agent/skills/hub-pull.js +1 -1
  115. package/dist/src/agent/skills/index.d.ts +2 -0
  116. package/dist/src/agent/skills/index.js +14 -5
  117. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
  118. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  119. package/dist/src/agent/skills/test-framework.js +1 -1
  120. package/dist/src/agent/workflow/subagent-runner.js +2 -0
  121. package/dist/src/agent/workflow/types.d.ts +1 -0
  122. package/dist/src/auth/model-credential-store.d.ts +17 -0
  123. package/dist/src/auth/model-credential-store.js +110 -0
  124. package/dist/src/auth/oauth/github-copilot.js +2 -2
  125. package/dist/src/auth/oauth/openai-codex.js +98 -7
  126. package/dist/src/auth/oauth/types.d.ts +4 -1
  127. package/dist/src/auth/oauth/xopc-cloud.js +124 -6
  128. package/dist/src/automations/domain/defaults.d.ts +1 -0
  129. package/dist/src/automations/domain/defaults.js +4 -0
  130. package/dist/src/automations/domain/index.d.ts +1 -0
  131. package/dist/src/automations/domain/index.js +2 -1
  132. package/dist/src/automations/index.js +2 -1
  133. package/dist/src/automations/service/action-executor.js +2 -2
  134. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  135. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  136. package/dist/src/cli/commands/skills.js +1 -1
  137. package/dist/src/cli/commands/update.js +1 -1
  138. package/dist/src/config/agent-profile.js +1 -1
  139. package/dist/src/config/index.js +2 -2
  140. package/dist/src/config/schema.d.ts +21 -0
  141. package/dist/src/config/schema.js +12 -2
  142. package/dist/src/gateway/agents-admin.js +1 -1
  143. package/dist/src/gateway/heartbeat/service.js +1 -1
  144. package/dist/src/gateway/hono/lib/config-payload.d.ts +3 -0
  145. package/dist/src/gateway/hono/lib/config-payload.js +1 -0
  146. package/dist/src/gateway/hono/oauth-async.d.ts +5 -0
  147. package/dist/src/gateway/hono/oauth-async.js +20 -8
  148. package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +1 -1
  149. package/dist/src/gateway/hono/routes/config-patch/gateway.js +9 -0
  150. package/dist/src/gateway/hono/routes/goals.js +13 -0
  151. package/dist/src/gateway/hono/routes/home.d.ts +16 -3
  152. package/dist/src/gateway/hono/routes/home.js +98 -25
  153. package/dist/src/gateway/hono/routes/index.js +2 -0
  154. package/dist/src/gateway/hono/routes/local-apps.js +1 -1
  155. package/dist/src/gateway/hono/routes/project-skills.d.ts +3 -0
  156. package/dist/src/gateway/hono/routes/project-skills.js +119 -0
  157. package/dist/src/gateway/hono/routes/update.js +2 -2
  158. package/dist/src/gateway/index.js +1 -1
  159. package/dist/src/gateway/run-loop.js +1 -1
  160. package/dist/src/gateway/service/sessions-api.d.ts +2 -1
  161. package/dist/src/gateway/service.js +5 -5
  162. package/dist/src/heartbeat/index.js +1 -1
  163. package/dist/src/infra/gateway-processes.js +1 -1
  164. package/dist/src/infra/update-restart.js +1 -1
  165. package/dist/src/infra/update-runner.js +2 -2
  166. package/dist/src/infra/update-startup.js +1 -1
  167. package/dist/src/mcp/channel-bridge.js +1 -1
  168. package/dist/src/projects/index.d.ts +1 -0
  169. package/dist/src/projects/index.js +2 -1
  170. package/dist/src/projects/project-skill-service.d.ts +67 -0
  171. package/dist/src/projects/project-skill-service.js +131 -0
  172. package/dist/src/providers/index.js +4 -2
  173. package/dist/src/providers/provider-auth-service.d.ts +22 -0
  174. package/dist/src/providers/provider-auth-service.js +66 -0
  175. package/dist/src/providers/register-runtime-providers.d.ts +6 -0
  176. package/dist/src/providers/register-runtime-providers.js +55 -0
  177. package/dist/src/providers/xopc-cloud-account-service.d.ts +2 -2
  178. package/dist/src/providers/xopc-cloud-account-service.js +6 -5
  179. package/dist/src/providers/xopc-cloud-config.d.ts +3 -0
  180. package/dist/src/providers/xopc-cloud-config.js +13 -0
  181. package/dist/src/providers/xopc-cloud-model-source.d.ts +2 -2
  182. package/dist/src/providers/xopc-cloud-model-source.js +6 -5
  183. package/dist/src/session/index.d.ts +1 -1
  184. package/dist/src/session/index.js +2 -2
  185. package/dist/src/session/thinking-resolve.d.ts +8 -0
  186. package/dist/src/session/thinking-resolve.js +6 -3
  187. package/dist/src/storage/sqlite/home-attention-repository.d.ts +3 -0
  188. package/dist/src/storage/sqlite/home-attention-repository.js +21 -0
  189. package/dist/src/storage/sqlite/index.d.ts +1 -0
  190. package/dist/src/storage/sqlite/index.js +2 -1
  191. package/dist/src/storage/sqlite/migrations/067_home_attention_acknowledgements.sql +9 -0
  192. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  193. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  194. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  195. package/dist/src/storage/sqlite/schema.js +1 -1
  196. package/dist/src/storage/sqlite/schema.sql +10 -0
  197. package/dist/src/tui/tui-startup-resources.js +1 -1
  198. package/dist/src/tui/tui.js +2 -2
  199. package/dist/src/tui/xopc-tui-keybindings.d.ts +44 -4
  200. package/dist/src/workflows/engine/workflow-engine.d.ts +1 -0
  201. package/dist/src/workflows/engine/workflow-engine.js +2 -0
  202. package/dist/src/workflows/service/workflow-run-service.js +11 -5
  203. package/dist/src/workflows/service/workflow-session-bridge.js +2 -1
  204. package/package.json +5 -5
  205. package/dist/gateway/static/root/assets/agents-BVxEFPQ5.js +0 -2
  206. package/dist/gateway/static/root/assets/appearance-settings-B2PQxRiu.js +0 -1
  207. package/dist/gateway/static/root/assets/apps-page-BtIgd82S.js +0 -1
  208. package/dist/gateway/static/root/assets/automations-page-CG_SCH5b.js +0 -6
  209. package/dist/gateway/static/root/assets/browser-settings-page-CfLqPWZC.js +0 -8
  210. package/dist/gateway/static/root/assets/capabilities-settings-panel-DCJmm6cR.js +0 -7
  211. package/dist/gateway/static/root/assets/capability-presets-settings-panel-CnkAYvWI.js +0 -1
  212. package/dist/gateway/static/root/assets/channels-settings-DtqqFpDn.js +0 -1
  213. package/dist/gateway/static/root/assets/channels-status-swr-C-5yHbc0.js +0 -1
  214. package/dist/gateway/static/root/assets/connectors-page-CaHfs8YF.js +0 -2
  215. package/dist/gateway/static/root/assets/desktop-pet-CvFMKYdb.js +0 -1
  216. package/dist/gateway/static/root/assets/goal-create-dialog-DAeb82xP.js +0 -1
  217. package/dist/gateway/static/root/assets/goal-detail-page-CwLSp01r.js +0 -4
  218. package/dist/gateway/static/root/assets/goals-page-DvJQ6_4M.js +0 -2
  219. package/dist/gateway/static/root/assets/index-CfXiRNN5.css +0 -1
  220. package/dist/gateway/static/root/assets/index-eyttVNS_.js +0 -212
  221. package/dist/gateway/static/root/assets/local-app-workbench-page-CPcfqn_A.js +0 -2
  222. package/dist/gateway/static/root/assets/logs-page-DXABWCZp.js +0 -7
  223. package/dist/gateway/static/root/assets/messages-BiBdO1-O.js +0 -3
  224. package/dist/gateway/static/root/assets/notes-workbench-DgJzZRX3.js +0 -4
  225. package/dist/gateway/static/root/assets/pdf-epILhEOn.js +0 -54
  226. package/dist/gateway/static/root/assets/pdf.worker.min-iDqQPrd3.mjs +0 -31
  227. package/dist/gateway/static/root/assets/project-detail-page-DF7F70Vg.js +0 -1
  228. package/dist/gateway/static/root/assets/projects-page-Cw3jyi5s.js +0 -1
  229. package/dist/gateway/static/root/assets/remote-access-hub-ChAJsaNY.js +0 -1
  230. package/dist/gateway/static/root/assets/sessions-page-BxZIxt7z.js +0 -1
  231. package/dist/gateway/static/root/assets/settings-advanced-gate-DcDLS0xV.js +0 -1
  232. package/dist/gateway/static/root/assets/setup-status-panel-4Xa9NA7v.js +0 -1
  233. package/dist/gateway/static/root/assets/shares-settings-BpN0o5Cf.js +0 -1
  234. package/dist/gateway/static/root/assets/skill-reload-api-DvF2UAaL.js +0 -1
  235. package/dist/gateway/static/root/assets/skills-page-CGKXpNfy.js +0 -2
  236. package/dist/gateway/static/root/assets/time-picker-BhgCeDuO.js +0 -1
  237. package/dist/gateway/static/root/assets/user-context-page-Dy_fKAK_.js +0 -1
  238. package/dist/gateway/static/root/assets/work-discovery-page-BWkjb1NK.js +0 -1
  239. package/dist/gateway/static/root/assets/work-item-detail-page-DLBNFse5.js +0 -1
  240. package/dist/gateway/static/root/assets/work-page-Bn5RXMIE.js +0 -1
  241. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BuniGPO0.js +0 -3
  242. package/dist/gateway/static/root/assets/workflows-page-_vFhRrAl.js +0 -11
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{f as r,l as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./messages-CarlxqXV.js";import{n as ee}from"./locale-store-sToMfHX_.js";import{Ao as te,As as s,At as ne,Do as re,Eo as c,Fl as l,Fo as ie,Io as ae,Lo as u,Mo as d,No as oe,Ns as f,Oo as se,Po as ce,Pt as le,Ro as ue,Wl as de,gu as fe,iu as pe,jl as me,jo as p,js as he,ko as ge,nl as m,ro as h,uc as g,vu as _e,zl as ve}from"./index-2UImfRDC.js";import{l as ye,t as be}from"./api-Bop4IQRW.js";var _=e(t(),1),v=new Set([`completed`,`failed`,`canceled`]);function xe(){return new Promise(e=>window.setTimeout(e,1200))}async function Se(e,t){let n=[],r=t.wait??xe;for(let i=0;i<e.length&&!t.shouldStop?.();i+=1){let a=e[i];if(a)try{await t.grantDirectory(a.rootPath);let o=await t.startRun(a.rootPath);for(t.onRun(o,i,e.length);!v.has(o.status)&&!t.shouldStop?.();)await r(),o=await t.fetchRun(o.id),t.onRun(o,i,e.length);if(n.push(o),o.status===`canceled`||t.shouldStop?.())break}catch(e){if(t.onError?.(e,a,i),t.shouldStop?.())break}}return n}var y=n(),Ce=[`folder_structure`,`recent_progress`,`next_steps`];function b(e){return e instanceof Error?e.message:String(e)}function x(){let e=ee(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,v=i(),[xe]=r(),x=xe.get(`new`)===`1`,[S,C]=(0,_.useState)(`loading`),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(!1),[A,j]=(0,_.useState)(null),[we,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(``),[F,I]=(0,_.useState)(!1),[L,R]=(0,_.useState)(()=>new Set),[z,Te]=(0,_.useState)(!1),[B,Ee]=(0,_.useState)([]),[V,De]=(0,_.useState)(()=>new Set),[Oe,H]=(0,_.useState)([]),[ke,Ae]=(0,_.useState)(!1),[U,W]=(0,_.useState)({current:0,total:0}),G=(0,_.useRef)(!1),K=(0,_.useCallback)(e=>{c.getState().updateDirectoryRun(e),D(e),e.status===`completed`?(R(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),C(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`)):e.status===`failed`||e.status===`canceled`?C(`error`):C(`running`)},[]),je=async()=>{k(!0),j(null);try{let e=await se();if(!e.length){j(t.noCandidates);return}Ee(e),De(new Set([e[0].rootPath])),C(`candidates`)}catch(e){j(b(e))}finally{k(!1)}},Me=e=>{De(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ne=(0,_.useCallback)((e,t,n)=>{c.getState().updateDirectoryRun(e),D(e),W({current:t+1,total:n}),H(n=>{let r=[...n];return r[t]=e,r}),C(`running`)},[]),Pe=(0,_.useCallback)(e=>{H(t=>t.map(t=>t?.id===e.id?e:t))},[]),Fe=async()=>{let e=B.filter(e=>V.has(e.rootPath));if(!e.length)return;k(!0),j(null),H([]),W({current:1,total:e.length}),Ae(!0),G.current=!1;let n=!1;try{let r=await Se(e,{grantDirectory:d,startRun:ae,fetchRun:p,shouldStop:()=>G.current,onRun:(e,t,r)=>{Ne(e,t,r),n||(n=!0,c.getState().scanPersonalContext(e.id))},onError:(n,r,i)=>{W({current:i+1,total:e.length}),j(t.folderAnalysisFailed.replace(`{{folder}}`,r.displayName).replace(`{{error}}`,b(n)))}});if(G.current)return;let i=r.find(e=>e.status===`completed`)??r.at(-1);i?K(i):C(`candidates`)}catch(e){j(b(e)),C(`candidates`)}finally{Ae(!1),k(!1)}},q=le({onPicked:(0,_.useCallback)(async e=>{k(!0),j(null);try{T(await oe(e)),C(`consent`)}catch(e){j(b(e)),C(`intro`)}finally{k(!1)}},[])});(0,_.useEffect)(()=>{let e=!1;return te().then(async({enabled:t,state:n})=>{if(!e){if(!t){v(`/chat`,{replace:!0});return}if(!x&&n.activeRunId)try{let t=await p(n.activeRunId);e||K(t);return}catch{}e||C(`intro`)}}).catch(t=>{e||(j(b(t)),C(`intro`))}),()=>{e=!0}},[K,v,x]),(0,_.useEffect)(()=>{if(!E||S!==`running`||ke)return;let e=!1,t=async()=>{try{let t=await p(E.id);e||K(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===E.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[K,ke,S,E]);let J=async()=>{k(!0);try{await ge()}finally{v(`/chat`,{replace:!0})}},Ie=async()=>{if(w){k(!0),j(null),H([]),W({current:0,total:0});try{await d(w.canonicalRootPath);let e=await ae(w.canonicalRootPath);K(e),c.getState().scanPersonalContext(e.id)}catch(e){j(b(e)),C(`consent`)}finally{k(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;v(`/chat/${encodeURIComponent(e)}${n}`)},Le=e=>{D(e),Te(!1),M(!1),I(!1),R(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),e.status===`completed`?C(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?C(`error`):C(`running`)},Re=async()=>{E&&(G.current=!0,K(await re(E.id)))},X=async(t,n)=>{if(!E)return;await ie(E.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(E.sessionKey,r)},ze=async()=>{if(E){k(!0),j(null);try{let e=E.result?.profileCandidates??[],t=await u((e.length>0?await ue(E.id,e.map(e=>({id:e.id,status:L.has(e.id)?`accepted`:`rejected`}))):E).id,`confirmed`);D(t),Pe(t),C(`recommendation`)}catch(e){j(b(e))}finally{k(!1)}}},Z=async e=>{if(!(!E||!N.trim())){k(!0),j(null);try{let t=await u(E.id,e,N.trim());D(t),Y(t.sessionKey,N.trim())}catch(e){j(b(e)),k(!1)}}},Be=async()=>{if(E){k(!0);try{Y((await u(E.id,`dismissed`)).sessionKey)}catch(e){j(b(e)),k(!1)}}},Ve=async()=>{let e=E?.result?.workThreads?.find(e=>e.horizon===`current`)??E?.result?.workThreads?.[0];if(e){k(!0),j(null);try{let t=await ye(e.id,`accept`);t&&await be(t.id,`progress`,!0),Te(!0)}catch(e){j(b(e))}finally{k(!1)}}},Q=E?.result?.suggestions.find(e=>e.id===E.result?.primarySuggestionId)??E?.result?.suggestions[0],He=E?.result?.suggestions.filter(e=>e.id!==Q?.id)??[],Ue=e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis,We=Oe.filter(e=>e?.status===`completed`),$=We.length>1?(0,y.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,y.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:t.analysisResults}),(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:We.map(e=>{let t=B.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,y.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===E?.id?`bg-accent text-white`:`bg-surface-muted text-fg hover:bg-surface-hover`}`,onClick:()=>Le(e),children:t},e.id)})})]}):null;return(0,y.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,y.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[(0,y.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,y.jsx)(he,{className:`size-11`})}),S===`loading`?(0,y.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,y.jsx)(h,{className:`mx-auto h-8 w-64`}),(0,y.jsx)(h,{className:`mx-auto h-4 w-full max-w-lg`}),(0,y.jsx)(h,{className:`mx-auto size-4/5 max-w-md`}),(0,y.jsx)(h,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,S===`intro`?(0,y.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,y.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,y.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,y.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,y.jsxs)(s,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void je(),disabled:O||q.picking,children:[O?(0,y.jsx)(m,{className:`size-4 animate-spin`}):(0,y.jsx)(g,{className:`size-4`}),t.quickScan]}),(0,y.jsxs)(s,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:q.pick,disabled:O||q.picking,children:[q.picking?(0,y.jsx)(m,{className:`size-4 animate-spin`}):(0,y.jsx)(l,{className:`size-4`}),t.chooseFolderManually]}),(0,y.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`span`,{children:t.quickScanNote})]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null]}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),disabled:O,children:t.skip})]}):null,S===`candidates`?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-candidates-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.candidatesTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.candidatesSubtitle})]}),(0,y.jsx)(`div`,{className:`mt-7 space-y-2`,children:B.map((e,n)=>{let r=V.has(e.rootPath);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":r,className:`flex w-full items-start gap-3 rounded-xl border p-4 text-left transition ${r?`border-accent bg-accent-soft/45`:`border-edge bg-surface-panel hover:border-edge-strong`}`,onClick:()=>Me(e.rootPath),children:[(0,y.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border ${r?`border-accent bg-accent text-white`:`border-edge bg-surface-base text-transparent`}`,children:(0,y.jsx)(a,{className:`size-3.5`})}),(0,y.jsx)(l,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),n===0?(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:t.recommendedCandidate}):null]}),(0,y.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,y.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,y.jsx)(`span`,{children:e.projectKind===`coding`?t.codingProject:e.projectKind===`general`?t.generalProject:t.unknownProject}),e.branch?(0,y.jsx)(`span`,{children:t.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,y.jsx)(`span`,{children:t.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,y.jsxs)(`div`,{className:`mt-5 flex items-start gap-2 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`span`,{children:t.multiFolderPrivacyNote})]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(s,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O||V.size===0,onClick:()=>void Fe(),children:[O?(0,y.jsx)(m,{className:`mr-2 size-4 animate-spin`}):null,t.analyzeSelected.replace(`{{count}}`,String(V.size))]}),(0,y.jsx)(s,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:q.pick,children:t.chooseFolderManually})]}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>C(`intro`),children:t.back})]}):null,S===`consent`&&w?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,y.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,y.jsx)(l,{className:`size-5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:w.displayName}),(0,y.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:w.canonicalRootPath})]}),(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:w.projectKind===`coding`?t.codingProject:w.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,y.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:w.fingerprint.branch?t.branchValue.replace(`{{branch}}`,w.fingerprint.branch):t.noGitBranch})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(w.fingerprint.changedFileCount))})]}),w.fingerprint.recentAreas.length>0?(0,y.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:w.fingerprint.recentAreas.map(e=>(0,y.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,y.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(ve,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:w.remoteModel?t.providerDisclosure.replace(`{{provider}}`,w.provider):t.localDisclosure})]})]})]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(s,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O,onClick:()=>void Ie(),children:[O?(0,y.jsx)(m,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,y.jsx)(s,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:q.pick,children:t.changeFolder})]}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),children:t.skip})]}):null,S===`running`&&E?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle}),U.total>1?(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:t.analyzingFolderProgress.replace(`{{current}}`,String(U.current)).replace(`{{total}}`,String(U.total))}):null]}),(0,y.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:Ce.map((e,n)=>{let r=Math.max(0,Ce.indexOf(E.stage??`folder_structure`)),i=n<r,o=n===r;return(0,y.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,y.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${i?`bg-accent text-white`:o?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:i?(0,y.jsx)(a,{className:`size-4`}):o?(0,y.jsx)(m,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,y.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,y.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,y.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:E.rootPath}),(0,y.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3`,children:[(0,y.jsx)(s,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:()=>v(`/chat`),children:t.continueInBackground}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void Re(),children:t.cancelAnalysis})]})]}):null,S===`recognition`&&E?.result?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,y.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:E.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),$,(0,y.jsxs)(`div`,{className:`mt-7 rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/45 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,y.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:E.result.projectSummary}),(0,y.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:E.result.currentState}),!E.result.lowConfidence&&Q?.evidence.length?(0,y.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:Q.evidence.slice(0,3).map((e,t)=>(0,y.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(me,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`span`,{children:[e.path?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${Q.id}-recognition-${t}`))}):null]}),E.result.workThreads?.length?(0,y.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.workThreadsTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.workThreadsSubtitle}),(0,y.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:E.result.workThreads.map(e=>(0,y.jsxs)(`div`,{className:`py-3 first:pt-0 last:pb-0`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:e.horizon===`current`?t.workThreadCurrent:e.horizon===`ongoing`?t.workThreadOngoing:t.workThreadLongTerm}),(0,y.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title})]}),(0,y.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:e.summary})]},e.id))})]}):null,E.result.profileCandidates?.length?(0,y.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.profileCandidatesTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.profileCandidatesSubtitle}),(0,y.jsx)(`div`,{className:`mt-3 space-y-2`,children:E.result.profileCandidates.map(e=>(0,y.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg px-2 py-2 hover:bg-surface-muted`,children:[(0,y.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 rounded border-edge accent-accent`,checked:L.has(e.id),onChange:()=>R(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,y.jsx)(`span`,{className:`text-sm leading-5 text-fg`,children:e.statement})]},e.id))})]}):null,E.result.lowConfidence?(0,y.jsxs)(`div`,{className:`mt-5`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:E.result.contextQuestion}),(0,y.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,y.jsx)(s,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:O||!N.trim(),onClick:()=>void Z(`different_goal`),children:t.continueWithCorrection})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(s,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O,onClick:()=>void ze(),children:[O?(0,y.jsx)(m,{className:`size-4 animate-spin`}):(0,y.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,y.jsx)(s,{variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:()=>M(e=>!e),children:t.notQuiteRight})]}),we?(0,y.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,y.jsx)(`textarea`,{id:`work-discovery-correction`,value:N,onChange:e=>P(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-2 min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,y.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,y.jsx)(s,{variant:`ghost`,disabled:O||!N.trim(),onClick:()=>void Z(`different_goal`),children:t.differentGoal}),(0,y.jsx)(s,{variant:`primary`,disabled:O||!N.trim(),onClick:()=>void Z(`corrected`),children:t.useCorrection})]})]}):null]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsx)(`button`,{type:`button`,disabled:O,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void Be(),children:t.openConversation})]}):null,S===`recommendation`&&E?.result&&Q?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,y.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),$,(0,y.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,y.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,y.jsx)(fe,{className:`size-5`})}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Q.title}),(0,y.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Q.rationale}),(0,y.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:[(0,y.jsx)(pe,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String(Q.estimatedMinutes))]}),(0,y.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:Ue(Q.risk)})]}),(0,y.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Q.expectedOutcome})]}),(0,y.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,y.jsx)(s,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void X(Q,!1),children:t.startRecommendedAction}),(0,y.jsx)(s,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void X(Q,!0),children:t.explainFirst})]})]})]})}),E.result.workThreads?.length?(0,y.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:(0,y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,y.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:z?(0,y.jsx)(a,{className:`size-4`}):(0,y.jsx)(de,{className:`size-4`})}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:z?t.focusActive:t.focusTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:z?t.focusActiveDescription:t.focusDescription}),z?null:(0,y.jsxs)(s,{className:`mt-3 h-9`,variant:`secondary`,disabled:O,onClick:()=>void Ve(),children:[O?(0,y.jsx)(m,{className:`size-4 animate-spin`}):(0,y.jsx)(de,{className:`size-4`}),t.activateFocus]})]})]})}):null,He.length>0?(0,y.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>I(e=>!e),children:[t.otherDirections,(0,y.jsx)(_e,{className:`size-4 transition-transform ${F?`rotate-180`:``}`})]}),F?(0,y.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:He.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void X(e,!0),children:[(0,y.jsx)(fe,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,y.jsxs)(`span`,{children:[(0,y.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,y.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,y.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,y.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(E.sessionKey),children:t.doSomethingElse}),(0,y.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{M(!0),C(`recognition`)},children:t.correctUnderstanding})]})]}):null,S===`error`&&E?(0,y.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,y.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,y.jsx)(f,{className:`size-5`})}),(0,y.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,y.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:E.errorMessage}),(0,y.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsx)(s,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void ce(E.id).then(K),children:t.retry}),(0,y.jsx)(s,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{D(null),T(null),C(`intro`)},children:t.chooseDifferent})]}),(0,y.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(E.sessionKey),children:t.openConversation})]}):null]}),q.hasNativePicker?null:(0,y.jsx)(ne,{open:q.modalOpen,onOpenChange:q.setModalOpen,initialAbsolutePath:w?.canonicalRootPath,onConfirm:q.confirmPick,wd:n})]})}export{x as WorkDiscoveryPage};
@@ -0,0 +1 @@
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,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-CarlxqXV.js";import{n as ee}from"./locale-store-sToMfHX_.js";import{A as l,As as u,Bc as te,Cc as ne,Fa as re,Gl as ie,Ks as d,Pu as f,Sc as ae,To as p,Xs as m,Yl as oe,Zc as h,a as g,f as se,is as _,jc as ce,jl as le,l as ue,m as de,mu as fe,ns as pe,o as me,p as v,s as he,u as y,vt as b,xu as x,zl as S}from"./index-2UImfRDC.js";var C=n(),w=e(t(),1),T=r();function ge(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function E(e){return e?b(new Date(e)):``}function _e(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function ve(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:e.kind===`note`?`/notes/${encodeURIComponent(e.targetId)}`:`#`}function D(e){let t=(0,C.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,T.jsx)(`dt`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a=r||`-`,o;t[2]===a?o=t[3]:(o=(0,T.jsx)(`dd`,{className:`min-w-0 break-words text-sm text-fg`,children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function ye(e){let t=(0,C.c)(9),{events:n,t:r}=e;if(!n.length){let e;return t[0]===r.detail.noActivity?e=t[1]:(e=(0,T.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-4 py-8 text-center text-sm text-fg-muted shadow-surface`,children:r.detail.noActivity}),t[0]=r.detail.noActivity,t[1]=e),e}let i;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,T.jsx)(`article`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r.eventTypes[e.type]??e.type}),(0,T.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:E(e.createdAt)})]})},e.id),t[5]=r,t[6]=e),i=n.map(e),t[2]=n,t[3]=r,t[4]=i}else i=t[4];let a;return t[7]===i?a=t[8]:(a=(0,T.jsx)(`div`,{className:`grid gap-3`,children:i}),t[7]=i,t[8]=a),a}function O(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function k(e,t,n){let r=t?.projectKind,i=[e.title,e.description,e.nextAction,e.blockedReason,e.status,e.priority,t?.name,t?.description,r].filter(Boolean).join(` `),a=[n.title,n.description,n.metadata.whenToUse,...n.metadata.tags??[]].filter(Boolean).join(` `),o=O(i),s=0;for(let e of O(a))o.has(e)&&(s+=3);let c=a.toLowerCase();return(e.status===`blocked`||e.status===`needs_input`)&&/debug|diagnos|review|audit|fix|检查|排查|修复/.test(c)&&(s+=8),e.status===`in_review`&&/review|audit|check|验收|评审|检查/.test(c)&&(s+=6),e.attachments?.length&&/analy|extract|summar|review|整理|分析|总结/.test(c)&&(s+=5),r===`coding`&&/code|repo|test|pr|review|代码|仓库|测试/.test(c)&&(s+=5),s}function A(e,t,n){return[...n].sort((n,r)=>k(e,t,r)-k(e,t,n)||n.title.localeCompare(r.title))}function j(){let{workItemId:e=``}=i(),t=a(),n=c(ee(e=>e.language)).projectDetailPage.workItems,[r,b]=(0,w.useState)(null),[C,O]=(0,w.useState)(null),[j,M]=(0,w.useState)([]),[N,be]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(!0),[B,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(null),W=(0,w.useRef)(null),G=p(e=>e.setPageHeader),K=p(e=>e.clearPageHeader),q=(0,w.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),J=(0,w.useCallback)(async()=>{if(e){z(!0),U(null);try{let[t,n]=await Promise.all([ue(e),y(e).catch(()=>({events:[]}))]);b(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([re(t.item.projectId).catch(()=>null),l().catch(()=>[])]),a=A(t.item,r,i);O(r),be(a),F(e=>e||a[0]?.id||``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[e]);(0,w.useEffect)(()=>{J()},[J]);let Y=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await se(r.id);b(e.item),t(`/chat/${encodeURIComponent(e.session.key)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),X=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await g(r.id);b(e.item),t(`/goals/${encodeURIComponent(e.goal.id)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),Z=(0,w.useCallback)(async e=>{M((await y(e).catch(()=>({events:[]}))).events)},[]),xe=(0,w.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await v(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});b(e.item),await Z(e.item.id),t(`/workflows?run=${encodeURIComponent(e.runId)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t,Z,P,I]),Se=(0,w.useCallback)(async e=>{if(!(!r||!e.length)){V(!0),U(null);try{let t=await de(r.id,e);b(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),Ce=(0,w.useCallback)(async e=>{if(r){V(!0),U(null);try{let t=await me(r.id,e.id);b(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),we=(0,w.useCallback)(async e=>{if(r){U(null);try{await he(r.id,e)}catch(e){U(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,w.useMemo)(()=>r?N.filter(e=>k(r,C,e)>0).slice(0,3):[],[r,C,N]),$=(0,w.useMemo)(()=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(u,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,T.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),r?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(u,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,T.jsxs)(u,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.createGoal})]})]}):null]}),[B,X,Y,r,J,n.detail.createGoal,n.detail.startChat,n.refreshShort]);return(0,w.useLayoutEffect)(()=>(G({startExtra:(0,T.jsx)(o,{to:q,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":C?.name?n.detail.backToProject.replace(`{{name}}`,C.name):n.detail.backToProjects,children:(0,T.jsx)(f,{className:`size-4`,"aria-hidden":!0})}),main:(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(x,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r?.title??(R?n.detail.loading:n.detail.notFound)})]}),r?(0,T.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[n.statuses[r.status],` · `,n.priorities[r.priority],` · `,C?.name||r.projectId,` · `,n.updated,`: `,E(r.updatedAt)]}):null]}),end:$}),()=>K()),[K,$,r,R,C?.name,q,G,n,C]),R?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,T.jsx)(`div`,{className:`h-8 w-40 animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-5 h-44 animate-pulse rounded-xl bg-surface-hover`})]}):H||!r?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(o,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(f,{className:`size-4`,"aria-hidden":!0}),n.detail.backToProjects]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-lg border border-danger/30 bg-danger-soft px-4 py-3 text-sm text-danger`,children:H||n.detail.notFound})]}):(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface sm:px-5`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(x,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`min-w-0 break-words text-lg font-semibold leading-7 text-fg`,children:r.title})]}),(0,T.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 font-medium`,ge(r.status)),children:n.statuses[r.status]}),(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.priorities[r.priority]}),r.archivedAt?(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.detail.archived}):null]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(u,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,T.jsxs)(u,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,T.jsxs)(`dl`,{className:`mt-5 grid gap-4 border-t border-edge pt-4 sm:grid-cols-2`,children:[(0,T.jsx)(D,{label:n.create.descriptionLabel,value:r.description||n.detail.noDescription}),(0,T.jsx)(D,{label:n.nextAction,value:r.nextAction||n.noNextAction}),(0,T.jsx)(D,{label:n.blockedReason,value:r.blockedReason||n.detail.noBlockedReason}),(0,T.jsx)(D,{label:n.updated,value:E(r.updatedAt)})]})]}),(0,T.jsxs)(`div`,{className:`mt-4 grid min-h-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,T.jsxs)(`section`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,T.jsx)(S,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.activity})]}),(0,T.jsx)(ye,{events:j,t:n})]}),(0,T.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(le,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.detail.workflowTitle})]})}),(0,T.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint}),(0,T.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,T.jsxs)(pe,{className:`h-9 rounded-md border border-edge bg-surface-base px-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:P,disabled:B||N.length===0,onChange:e=>F(e.target.value),children:[N.length===0?(0,T.jsx)(_,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,T.jsx)(_,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n.detail.recommendedWorkflows}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Q.map(e=>(0,T.jsx)(`button`,{type:`button`,className:s(`min-w-0 rounded-md border px-2 py-1 text-left text-xs transition-colors`,P===e.id?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),disabled:B,onClick:()=>F(e.id),children:(0,T.jsx)(`span`,{className:`block max-w-48 truncate`,children:e.title})},e.id))})]}):null,(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowGoal,(0,T.jsx)(`textarea`,{className:`min-h-20 resize-y rounded-md border border-edge bg-surface-base p-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:I,disabled:B,onChange:e=>L(e.target.value)})]}),(0,T.jsxs)(u,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,T.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startWorkflow]}),N.length?null:(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(te,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,T.jsxs)(u,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,T.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),n.attachments.add]}),(0,T.jsx)(`input`,{ref:W,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Se(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-2`,children:r.attachments?.length?r.attachments.map(e=>(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-base p-2 text-sm`,children:[(0,T.jsx)(S,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`div`,{className:`truncate font-medium text-fg`,children:e.fileName}),(0,T.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[e.mimeType,` · `,_e(e.size)]})]}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:n.attachments.download,"aria-label":n.attachments.download,disabled:B,onClick:()=>void we(e),children:(0,T.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0})}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:n.attachments.remove,"aria-label":n.attachments.remove,disabled:B,onClick:()=>void Ce(e),children:(0,T.jsx)(d,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.attachments.empty})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,T.jsxs)(o,{to:ve(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,T.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,T.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[n.linkKinds[e.kind],(0,T.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.detail.noLinks})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.project}),(0,T.jsxs)(o,{to:q,className:`mt-2 inline-flex min-w-0 items-center gap-2 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(fe,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:C?.name||r.projectId})]})]})]})]})]})}export{j as WorkItemDetailPage};
@@ -0,0 +1,3 @@
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,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./circle-alert-BEjgurr2.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-CarlxqXV.js";import{n as u,o as d,r as f,s as p}from"./locale-store-sToMfHX_.js";import{n as m}from"./activity-store-DsFM1upC.js";import{$c as h,As as g,Bo as _,Ci as v,Ei as y,Go as b,Gs as x,Ho as S,Il as C,Kl as w,Ks as T,Nc as E,Ns as D,Nu as O,Si as k,Ti as A,To as j,Uo as M,Va as N,Vo as P,Wl as F,Wo as I,gc as L,gu as R,iu as z,jc as B,mu as ee,nl as V,oc as te,ro as H,tt as ne,vt as U,wi as re,xi as ie,yl as ae,yu as oe,zc as se,zo as ce,zu as le}from"./index-2UImfRDC.js";import{a as ue,d as de,l as fe,n as pe,s as me,t as he}from"./api-Bop4IQRW.js";import{t as ge}from"./copy-VueTIC2x.js";var W=e(t(),1),G=n();function K(e){try{return decodeURIComponent(e).trim()||null}catch{return null}}function q(e){if(!e)return null;let t=e.split(/[?#]/,1)[0],n=/^\/goals\/([^/]+)\/?$/.exec(t);if(n){let e=K(n[1]);return e?{kind:`goal`,id:e}:null}let r=/^\/chat\/([^/]+)\/?$/.exec(t);if(r){let e=K(r[1]);return!e||e===`new`?null:{kind:`session`,id:e}}return null}async function _e(e,t){let n=e.kind===`goal`?`/api/goals/${encodeURIComponent(e.id)}`:`/api/sessions/${encodeURIComponent(e.id)}?limit=1`;try{return(await d(f(n),{signal:t})).status===404?`missing`:`available`}catch(e){if(t?.aborted)throw e;return`available`}}var J=r(),Y=3,ve={info:{Icon:ae,className:`text-accent-fg bg-accent-soft`},success:{Icon:ee,className:`text-success bg-success-soft`},warning:{Icon:x,className:`text-warning bg-warning-soft`},error:{Icon:s,className:`text-danger bg-danger-soft`}};function X(e,t){let n=Math.max(0,Math.round((Date.now()-e)/1e3));if(n<60)return t===`zh`?`刚刚`:`Just now`;let r=Math.round(n/60);if(r<60)return t===`zh`?`${r} 分钟前`:`${r}m ago`;let i=Math.round(r/60);if(i<24)return t===`zh`?`${i} 小时前`:`${i}h ago`;let a=Math.round(i/24);return t===`zh`?`${a} 天前`:`${a}d ago`}function Z(e){let t=(0,G.c)(55),{item:n,targetAvailability:r}=e,i=u(be),o;t[0]===i?o=t[1]:(o=l(i),t[0]=i,t[1]=o);let s=o.projectsPage.workHome,d=m(ye),{Icon:f,className:p}=ve[n.tone],h;t[2]===p?h=t[3]:(h=c(`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg`,p),t[2]=p,t[3]=h);let g;t[4]!==f||t[5]!==n.status?(g=n.status===`running`?(0,J.jsx)(V,{className:`size-3.5 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,J.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[4]=f,t[5]=n.status,t[6]=g):g=t[6];let _;t[7]!==h||t[8]!==g?(_=(0,J.jsx)(`div`,{className:h,children:g}),t[7]=h,t[8]=g,t[9]=_):_=t[9];let v;t[10]===n.title?v=t[11]:(v=(0,J.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-medium leading-5 text-fg`,children:n.title}),t[10]=n.title,t[11]=v);let y;t[12]!==s.activityUnread||t[13]!==n.read?(y=n.read?null:(0,J.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":s.activityUnread}),t[12]=s.activityUnread,t[13]=n.read,t[14]=y):y=t[14];let b;t[15]!==v||t[16]!==y?(b=(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[v,y]}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]===n.message?x=t[19]:(x=n.message?(0,J.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.message}):null,t[18]=n.message,t[19]=x);let S;t[20]===n.source?S=t[21]:(S=n.source?(0,J.jsx)(`span`,{className:`max-w-48 truncate`,children:n.source}):null,t[20]=n.source,t[21]=S);let C;t[22]!==n.updatedAt||t[23]!==i?(C=X(n.updatedAt,i),t[22]=n.updatedAt,t[23]=i,t[24]=C):C=t[24];let w;t[25]===C?w=t[26]:(w=(0,J.jsx)(`span`,{children:C}),t[25]=C,t[26]=w);let T;t[27]===n.occurrences?T=t[28]:(T=n.occurrences>1?(0,J.jsxs)(`span`,{children:[`×`,n.occurrences]}):null,t[27]=n.occurrences,t[28]=T);let E;t[29]!==s.activityCheckingRelated||t[30]!==s.activityRelatedMissing||t[31]!==s.activityViewRelated||t[32]!==n.href||t[33]!==r?(E=n.href&&r===`available`?(0,J.jsxs)(a,{to:n.href,className:`inline-flex items-center gap-0.5 font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[s.activityViewRelated,(0,J.jsx)(R,{className:`size-3`,"aria-hidden":!0})]}):n.href&&r===`checking`?(0,J.jsx)(H,{className:`h-3 w-20 rounded`,"aria-label":s.activityCheckingRelated}):n.href&&r===`missing`?(0,J.jsx)(`span`,{className:`font-medium text-fg-subtle`,role:`status`,children:s.activityRelatedMissing}):null,t[29]=s.activityCheckingRelated,t[30]=s.activityRelatedMissing,t[31]=s.activityViewRelated,t[32]=n.href,t[33]=r,t[34]=E):E=t[34];let O;t[35]!==w||t[36]!==T||t[37]!==E||t[38]!==S?(O=(0,J.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] text-fg-subtle`,children:[S,w,T,E]}),t[35]=w,t[36]=T,t[37]=E,t[38]=S,t[39]=O):O=t[39];let k;t[40]!==O||t[41]!==b||t[42]!==x?(k=(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x,O]}),t[40]=O,t[41]=b,t[42]=x,t[43]=k):k=t[43];let A;t[44]!==n.id||t[45]!==d?(A=()=>d(n.id),t[44]=n.id,t[45]=d,t[46]=A):A=t[46];let j;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,J.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),t[47]=j):j=t[47];let M;t[48]!==s.activityRemove||t[49]!==A?(M=(0,J.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-hover hover:text-fg group-hover:opacity-100 focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":s.activityRemove,onClick:A,children:j}),t[48]=s.activityRemove,t[49]=A,t[50]=M):M=t[50];let N;return t[51]!==k||t[52]!==M||t[53]!==_?(N=(0,J.jsxs)(`article`,{className:`group flex items-start gap-3 border-t border-edge-subtle px-1 py-3 first:border-t-0`,children:[_,k,M]}),t[51]=k,t[52]=M,t[53]=_,t[54]=N):N=t[54],N}function ye(e){return e.remove}function be(e){return e.language}function xe(){let e=(0,G.c)(14),t=l(u(Me)).projectsPage.workHome,n=m(je),r=m(Ae),i=m(ke),[a,s]=(0,W.useState)(!1),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={},e[0]=c):c=e[0];let[d,f]=(0,W.useState)(c),p;e[1]===n?p=e[2]:(p=n.filter(Oe),e[1]=n,e[2]=p);let h=p.length,_;e[3]===n?_=e[4]:(_=n.filter(De),e[3]=n,e[4]=_);let v=_.length,y;e[5]!==a||e[6]!==n?(y=a?n:n.slice(0,Y),e[5]=a,e[6]=n,e[7]=y):y=e[7];let b=y,x;e[8]===n?x=e[9]:(x=[...new Set(n.flatMap(Ee))].sort().join(`
2
+ `),e[8]=n,e[9]=x);let S=x,C,w;e[10]===S?(C=e[11],w=e[12]):(C=()=>{let e=new AbortController,t=new Map((S?S.split(`
3
+ `):[]).flatMap(Te));return f(Object.fromEntries([...t.keys()].map(Q))),Promise.all([...t].map(async t=>{let[n,r]=t,i=await _e(r,e.signal);e.signal.aborted||f(e=>({...e,[n]:i}))})).catch(we),()=>e.abort()},w=[S],e[10]=S,e[11]=C,e[12]=w),(0,W.useEffect)(C,w);let E;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,J.jsx)(le,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),e[13]=E):E=e[13],(0,J.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,"aria-labelledby":`workbench-activity-title`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsx)(`div`,{children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,(0,J.jsx)(`h2`,{id:`workbench-activity-title`,className:`text-sm font-semibold text-fg`,children:t.activityTitle}),h>0?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:[(0,J.jsx)(V,{className:`size-3 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),h,` `,t.running]}):v>0?(0,J.jsxs)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[v,` `,t.activityNew]}):null]})}),a&&n.length>0?(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[v>0?(0,J.jsxs)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:r,children:[(0,J.jsx)(o,{className:`size-3.5`,"aria-hidden":!0}),t.activityMarkRead]}):null,n.some(Ce)?(0,J.jsxs)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-fg-muted`,onClick:i,children:[(0,J.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),t.activityClearFinished]}):null]}):null]}),n.length>0?(0,J.jsxs)(`div`,{className:`mt-3 px-1`,children:[b.map(e=>(0,J.jsx)(Z,{item:e,targetAvailability:e.href&&q(e.href)?d[e.href]??`checking`:`available`},e.id)),n.length>Y?(0,J.jsx)(`div`,{className:`border-t border-edge-subtle py-2 text-center`,children:(0,J.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>s(Se),children:a?t.activityShowLess:t.activityShowAll.replace(`{{count}}`,String(n.length))})}):null]}):(0,J.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-fg-muted`,children:[(0,J.jsx)(z,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`p`,{children:t.activityEmpty})]})]})}function Se(e){return!e}function Ce(e){return e.status===`done`}function we(){}function Q(e){return[e,`checking`]}function Te(e){let t=q(e);return t?[[e,t]]:[]}function Ee(e){return e.href&&q(e.href)?[e.href]:[]}function De(e){return!e.read}function Oe(e){return e.status===`running`}function ke(e){return e.clearFinished}function Ae(e){return e.markAllRead}function je(e){return e.items}function Me(e){return e.language}function Ne(e){let t=(0,G.c)(32),{focus:n,kind:r,language:i,busy:a,onMonitor:o}=e,s;t[0]===i?s=t[1]:(s=ge(i),t[0]=i,t[1]=s);let c=s,l;if(t[2]!==a||t[3]!==c.disabled||t[4]!==c.enableExternal||t[5]!==c.enableProgress||t[6]!==c.enabled||t[7]!==c.external||t[8]!==c.failed||t[9]!==c.lastRun||t[10]!==c.neverRun||t[11]!==c.nextRun||t[12]!==c.progress||t[13]!==c.queued||t[14]!==c.running||t[15]!==n.monitors||t[16]!==n.status||t[17]!==r||t[18]!==o){let e;t[20]===r?e=t[21]:(e=e=>e.kind===r,t[20]=r,t[21]=e);let i=n.monitors.find(e),s=i?.enabled===!0,u=r===`progress`?c.progress:c.external,d=r===`progress`?c.enableProgress:c.enableExternal,f=i?.runState===`running`?c.running:i?.runState===`queued`?c.queued:i?.runState===`failed`?c.failed:s?c.enabled:c.disabled,p=`size-1.5 shrink-0 rounded-full ${s?`bg-success`:`bg-fg-subtle/40`}`,m;t[22]===p?m=t[23]:(m=(0,J.jsx)(`span`,{className:p,"aria-hidden":!0}),t[22]=p,t[23]=m);let h;t[24]!==m||t[25]!==u?(h=(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-xs font-medium text-fg`,children:[m,u]}),t[24]=m,t[25]=u,t[26]=h):h=t[26];let _;t[27]===f?_=t[28]:(_=(0,J.jsx)(`span`,{className:`shrink-0 text-[11px] text-fg-subtle`,children:f}),t[27]=f,t[28]=_);let v;t[29]!==h||t[30]!==_?(v=(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[h,_]}),t[29]=h,t[30]=_,t[31]=v):v=t[31],l=(0,J.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base/70 px-3 py-2.5`,children:[v,s?(0,J.jsxs)(`p`,{className:`mt-1.5 text-[11px] text-fg-subtle`,children:[i?.lastRunAt?`${c.lastRun} ${U(new Date(i.lastRunAt))}`:c.neverRun,i?.nextRunAt?` · ${c.nextRun} ${U(new Date(i.nextRunAt))}`:``]}):(0,J.jsx)(g,{type:`button`,variant:`ghost`,className:`mt-1 h-7 px-0 text-xs text-accent`,disabled:a||n.status!==`active`,onClick:()=>o(r,!0),children:d})]}),t[2]=a,t[3]=c.disabled,t[4]=c.enableExternal,t[5]=c.enableProgress,t[6]=c.enabled,t[7]=c.external,t[8]=c.failed,t[9]=c.lastRun,t[10]=c.neverRun,t[11]=c.nextRun,t[12]=c.progress,t[13]=c.queued,t[14]=c.running,t[15]=n.monitors,t[16]=n.status,t[17]=r,t[18]=o,t[19]=l}else l=t[19];return l}function Pe(e){let t=(0,G.c)(61),{focus:n,language:r,busy:a,onMonitor:o,onStatus:s,onDelete:c}=e,l;t[0]===r?l=t[1]:(l=ge(r),t[0]=r,t[1]=l);let u=l,d=i(),f;t[2]!==n.id||t[3]!==d?(f=()=>d(`/work/focuses/${encodeURIComponent(n.id)}`),t[2]=n.id,t[3]=d,t[4]=f):f=t[4];let p;t[5]===n.title?p=t[6]:(p=(0,J.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[5]=n.title,t[6]=p);let m;t[7]===n.summary?m=t[8]:(m=(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.summary}),t[7]=n.summary,t[8]=m);let h;t[9]!==f||t[10]!==p||t[11]!==m?(h=(0,J.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:f,children:[p,m]}),t[9]=f,t[10]=p,t[11]=m,t[12]=h):h=t[12];let g;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,J.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t[13]=g):g=t[13];let _;t[14]===a?_=t[15]:(_=(0,J.jsx)(y,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":`Actions`,disabled:a,children:g})}),t[14]=a,t[15]=_);let b;t[16]!==n.status||t[17]!==s?(b=()=>s(n.status===`paused`?`active`:`paused`),t[16]=n.status,t[17]=s,t[18]=b):b=t[18];let x;t[19]===n.status?x=t[20]:(x=n.status===`paused`?(0,J.jsx)(E,{className:`size-4`}):(0,J.jsx)(se,{className:`size-4`}),t[19]=n.status,t[20]=x);let S=n.status===`paused`?u.resume:u.pause,C;t[21]!==S||t[22]!==b||t[23]!==x?(C=(0,J.jsxs)(k,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover`,onSelect:b,children:[x,S]}),t[21]=S,t[22]=b,t[23]=x,t[24]=C):C=t[24];let D;t[25]===s?D=t[26]:(D=()=>s(`completed`),t[25]=s,t[26]=D);let O;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,J.jsx)(ee,{className:`size-4`}),t[27]=O):O=t[27];let j;t[28]!==u.complete||t[29]!==D?(j=(0,J.jsxs)(k,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover`,onSelect:D,children:[O,u.complete]}),t[28]=u.complete,t[29]=D,t[30]=j):j=t[30];let M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,J.jsx)(A,{className:`my-1 h-px bg-edge-subtle`}),t[31]=M):M=t[31];let N;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,J.jsx)(T,{className:`size-4`}),t[32]=N):N=t[32];let P;t[33]!==u.remove||t[34]!==c?(P=(0,J.jsxs)(k,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none focus:bg-surface-hover`,onSelect:c,children:[N,u.remove]}),t[33]=u.remove,t[34]=c,t[35]=P):P=t[35];let F;t[36]!==C||t[37]!==j||t[38]!==P?(F=(0,J.jsx)(v,{children:(0,J.jsxs)(ie,{align:`end`,sideOffset:4,className:`z-50 min-w-40 rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,children:[C,j,M,P]})}),t[36]=C,t[37]=j,t[38]=P,t[39]=F):F=t[39];let I;t[40]!==F||t[41]!==_?(I=(0,J.jsxs)(re,{children:[_,F]}),t[40]=F,t[41]=_,t[42]=I):I=t[42];let L;t[43]!==I||t[44]!==h?(L=(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[h,I]}),t[43]=I,t[44]=h,t[45]=L):L=t[45];let R;t[46]!==a||t[47]!==n||t[48]!==r||t[49]!==o?(R=(0,J.jsxs)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[(0,J.jsx)(Ne,{focus:n,kind:`progress`,language:r,busy:a,onMonitor:o}),(0,J.jsx)(Ne,{focus:n,kind:`external_changes`,language:r,busy:a,onMonitor:o})]}),t[46]=a,t[47]=n,t[48]=r,t[49]=o,t[50]=R):R=t[50];let z;t[51]!==n.id||t[52]!==d?(z=()=>d(`/work/focuses/${encodeURIComponent(n.id)}`),t[51]=n.id,t[52]=d,t[53]=z):z=t[53];let B;t[54]!==u.details||t[55]!==z?(B=(0,J.jsxs)(`button`,{type:`button`,className:`mt-3 text-xs font-medium text-accent hover:underline`,onClick:z,children:[u.details,` →`]}),t[54]=u.details,t[55]=z,t[56]=B):B=t[56];let V;return t[57]!==L||t[58]!==R||t[59]!==B?(V=(0,J.jsxs)(`article`,{className:`group rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:border-edge-strong`,children:[L,R,B]}),t[57]=L,t[58]=R,t[59]=B,t[60]=V):V=t[60],V}function Fe(e){return p(f(`/api/home${e?`?locale=${encodeURIComponent(e)}`:``}`))}function Ie(e,t){return p(f(`/api/home/decisions/respond`),{method:`POST`,body:JSON.stringify({...e,decision:t})})}function Le(e){return p(f(`/api/home/attention/acknowledge`),{method:`POST`,body:JSON.stringify(e)})}function Re(e){return p(f(`/api/home/attention/retry`),{method:`POST`,body:JSON.stringify(e)})}function ze(e){return e===`zh`?{newWork:`交给 xopc`,dialogTitle:`现在想完成什么?`,dialogDescription:`发送后会直接进入对话,xopc 会立即开始处理。`,intentLabel:`告诉 xopc 你要做什么`,intentPlaceholder:`例如:整理这周的会议记录,提炼待办并给出下周优先级`,submit:`进入对话`,needsAttention:`需要你处理`,runAttention:`运行异常`,running:`xopc 正在处理`,continue:`继续推进`,recent:`最近对话`,focuses:`持续关注`,projects:`长期项目`,emptyRunning:`当前没有正在处理的对话`,emptyContinue:`还没有需要继续推进的事项`,openChat:`打开对话`}:{newWork:`Ask xopc`,dialogTitle:`What do you want to get done?`,dialogDescription:`You will enter a conversation immediately and xopc will start working.`,intentLabel:`Tell xopc what you need`,intentPlaceholder:`For example: summarize this week’s meeting notes and suggest next week’s priorities`,submit:`Open conversation`,needsAttention:`Needs your attention`,runAttention:`Run issues`,running:`xopc is working`,continue:`Continue`,recent:`Recent conversations`,focuses:`Ongoing focuses`,projects:`Long-term projects`,emptyRunning:`No conversations are running`,emptyContinue:`No ongoing items yet`,openChat:`Open conversation`}}function Be(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Ve(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:U(n)}function $(e){let t=(0,G.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,J.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function He(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,J.jsx)(H,{className:`h-20 rounded-2xl`}),(0,J.jsx)(H,{className:`h-72 rounded-2xl`}),(0,J.jsx)(H,{className:`h-44 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Ue(e){let t=(0,G.c)(19),{item:n,statusLabel:r}=e,i=`/work-items/${encodeURIComponent(n.id)}`,o;t[0]===n.title?o=t[1]:(o=(0,J.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=o);let s;t[2]===n.projectName?s=t[3]:(s=(0,J.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.projectName}),t[2]=n.projectName,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]===r?l=t[8]:(l=(0,J.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:r}),t[7]=r,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==n.blockedReason||t[13]!==n.nextAction?(d=n.blockedReason||n.nextAction?(0,J.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.blockedReason||n.nextAction}):null,t[12]=n.blockedReason,t[13]=n.nextAction,t[14]=d):d=t[14];let f;return t[15]!==i||t[16]!==u||t[17]!==d?(f=(0,J.jsxs)(a,{to:i,className:`group block rounded-lg px-1 py-2.5 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,d]}),t[15]=i,t[16]=u,t[17]=d,t[18]=f):f=t[18],f}function We(e){let t=(0,G.c)(15),{chat:n,statusLabel:r}=e,i=`/chat/${encodeURIComponent(n.key)}`,o;t[0]===n.name?o=t[1]:(o=(0,J.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.name}),t[0]=n.name,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,J.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]===n.updatedAt?l=t[8]:(l=Ve(n.updatedAt,``),t[7]=n.updatedAt,t[8]=l);let u;t[9]===l?u=t[10]:(u=(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:l}),t[9]=l,t[10]=u);let d;return t[11]!==i||t[12]!==c||t[13]!==u?(d=(0,J.jsxs)(a,{to:i,className:`group block rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[c,u]}),t[11]=i,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function Ge(e){let t=(0,G.c)(27),{item:n,kindLabel:r,reasonLabel:i,approveLabel:o,denyLabel:s,busy:c,onRespond:l}=e,u;t[0]===n.title?u=t[1]:(u=(0,J.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=u);let d=n.projectName||r,f;t[2]===d?f=t[3]:(f=(0,J.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:d}),t[2]=d,t[3]=f);let p;t[4]!==u||t[5]!==f?(p=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[u,f]}),t[4]=u,t[5]=f,t[6]=p):p=t[6];let m;t[7]===i?m=t[8]:(m=(0,J.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:i}),t[7]=i,t[8]=m);let h;t[9]!==p||t[10]!==m?(h=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let _;t[12]===n.detail?_=t[13]:(_=n.detail?(0,J.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.detail}):null,t[12]=n.detail,t[13]=_);let v;t[14]!==n.href||t[15]!==h||t[16]!==_?(v=(0,J.jsxs)(a,{to:n.href,className:`group block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[h,_]}),t[14]=n.href,t[15]=h,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==o||t[19]!==c||t[20]!==s||t[21]!==n.response||t[22]!==l?(y=n.response?(0,J.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-warning/20 pt-3`,children:[(0,J.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:c,onClick:()=>l(`deny`),children:s}),(0,J.jsx)(g,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:c,onClick:()=>l(`approve`),children:o})]}):null,t[18]=o,t[19]=c,t[20]=s,t[21]=n.response,t[22]=l,t[23]=y):y=t[23];let b;return t[24]!==v||t[25]!==y?(b=(0,J.jsxs)(`article`,{className:`rounded-xl border border-warning/35 bg-warning-soft/25 p-3.5 transition-colors hover:bg-warning-soft/40`,children:[v,y]}),t[24]=v,t[25]=y,t[26]=b):b=t[26],b}function Ke(e){let t=(0,G.c)(32),{item:n,statusLabel:r,retryLabel:i,viewLabel:o,acknowledgeLabel:s,busy:c,onView:l,onRetry:u,onAcknowledge:d}=e,f;t[0]===n.title?f=t[1]:(f=(0,J.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=f);let p;t[2]===r?p=t[3]:(p=(0,J.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-danger`,children:r}),t[2]=r,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]===n.detail?h=t[8]:(h=(0,J.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[7]=n.detail,t[8]=h);let _;t[9]!==n.href||t[10]!==m||t[11]!==h?(_=(0,J.jsxs)(a,{to:n.href,className:`block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[m,h]}),t[9]=n.href,t[10]=m,t[11]=h,t[12]=_):_=t[12];let v;t[13]!==s||t[14]!==c||t[15]!==d?(v=(0,J.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:c,onClick:d,children:s}),t[13]=s,t[14]=c,t[15]=d,t[16]=v):v=t[16];let y;t[17]!==c||t[18]!==l||t[19]!==o?(y=(0,J.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:c,onClick:l,children:o}),t[17]=c,t[18]=l,t[19]=o,t[20]=y):y=t[20];let b;t[21]!==c||t[22]!==u||t[23]!==i?(b=(0,J.jsx)(g,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:c,onClick:u,children:i}),t[21]=c,t[22]=u,t[23]=i,t[24]=b):b=t[24];let x;t[25]!==v||t[26]!==y||t[27]!==b?(x=(0,J.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2 border-t border-danger/15 pt-3`,children:[v,y,b]}),t[25]=v,t[26]=y,t[27]=b,t[28]=x):x=t[28];let S;return t[29]!==_||t[30]!==x?(S=(0,J.jsxs)(`article`,{className:`rounded-xl border border-danger/25 bg-danger-soft/35 p-3.5`,children:[_,x]}),t[29]=_,t[30]=x,t[31]=S):S=t[31],S}function qe(e){let t=(0,G.c)(19),{project:n,openLabel:r,noDescription:i}=e,o=`/projects/${encodeURIComponent(n.id)}`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,J.jsx)(C,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[0]=s):s=t[0];let c;t[1]===n.name?c=t[2]:(c=(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,(0,J.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.name})]}),t[1]=n.name,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,J.jsx)(O,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-label":r}),t[3]=r,t[4]=l);let u;t[5]!==c||t[6]!==l?(u=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[c,l]}),t[5]=c,t[6]=l,t[7]=u):u=t[7];let d=n.description||n.brief||i,f;t[8]===d?f=t[9]:(f=(0,J.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-5 text-fg-muted`,children:d}),t[8]=d,t[9]=f);let p=n.lastActiveAt??n.updatedAt,m;t[10]===p?m=t[11]:(m=Ve(p,``),t[10]=p,t[11]=m);let h;t[12]===m?h=t[13]:(h=(0,J.jsx)(`p`,{className:`mt-auto pt-3 text-[11px] text-fg-subtle`,children:m}),t[12]=m,t[13]=h);let g;return t[14]!==o||t[15]!==h||t[16]!==u||t[17]!==f?(g=(0,J.jsxs)(a,{to:o,className:`group flex min-h-32 flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,f,h]}),t[14]=o,t[15]=h,t[16]=u,t[17]=f,t[18]=g):g=t[18],g}function Je(){let e=u(e=>e.language),t=l(e),n=t.projectsPage,r=ge(e),o=ze(e),c=i(),d=j(e=>e.setPageHeader),f=j(e=>e.clearPageHeader),[p,m]=(0,W.useState)(null),[v,y]=(0,W.useState)([]),[x,C]=(0,W.useState)([]),[w,T]=(0,W.useState)([]),[E,O]=(0,W.useState)(!0),[k,A]=(0,W.useState)(null),[R,ee]=(0,W.useState)(``),[V,H]=(0,W.useState)(!1),[U,re]=(0,W.useState)(``),[ie,ae]=(0,W.useState)(null),[se,le]=(0,W.useState)(null),[G,K]=(0,W.useState)(null),[q,_e]=(0,W.useState)(null),Y=(0,W.useCallback)(async(t=!1)=>{t&&O(!0),A(null);try{let[t,n,r,i]=await Promise.all([Fe(e),N({limit:100,sortBy:`updatedAt`,sortOrder:`desc`}),me(),ue()]);m(t),y(n.items),C(r),T(i)}catch(e){A(e instanceof Error?e.message:String(e))}finally{O(!1)}},[e]);(0,W.useEffect)(()=>{Y(!0)},[Y]),(0,W.useEffect)(()=>{let e,t=t=>{e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,Y()},t)},n=()=>t(100),r=()=>t(750),i=[`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`,`focus-created`,`focus-updated`,`focus-deleted`,`focus-monitor-updated`,`focus-run-updated`,`focus-insight-updated`,`focus-candidate-updated`],a=[`session-updated`,`session-transcript-updated`];return i.forEach(e=>window.addEventListener(e,n)),a.forEach(e=>window.addEventListener(e,r)),()=>{i.forEach(e=>window.removeEventListener(e,n)),a.forEach(e=>window.removeEventListener(e,r)),e!==void 0&&window.clearTimeout(e)}},[Y]);let ve=(0,W.useMemo)(()=>{let e=R.trim().toLocaleLowerCase(),t=v.filter(e=>e.status!==`archived`);return e?t.filter(t=>[t.name,t.description,t.brief].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e))):t.slice(0,6)},[v,R]),X=(0,W.useMemo)(()=>p?.decisions??[],[p]),Z=(0,W.useMemo)(()=>p?.attention??[],[p]),ye=(0,W.useMemo)(()=>p?.work.current.filter(e=>e.status!==`needs_input`&&e.status!==`in_review`&&e.status!==`blocked`).slice(0,10)??[],[p]),be=(0,W.useCallback)(e=>{e.preventDefault();let t=U.trim();t&&(re(``),H(!1),c({pathname:`/chat/new`,search:`?${new URLSearchParams({draft:t,autoSend:`1`}).toString()}`},{state:{forceNewChat:!0}}))},[c,U]),Se=(0,W.useMemo)(()=>(0,J.jsxs)(g,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>H(!0),children:[(0,J.jsx)(B,{className:`size-4`,"aria-hidden":!0}),o.newWork]}),[o.newWork]),Ce=(0,W.useCallback)(async(e,t)=>{if(e.response){ae(e.id),A(null);try{await Ie(e.response,t),await Y()}catch(e){A(e instanceof Error?e.message:String(e))}finally{ae(null)}}},[Y]),we=(0,W.useCallback)(async(e,t)=>{le(e.id),A(null);try{await t({kind:e.kind,runId:e.runId}),await Y()}catch(e){A(e instanceof Error?e.message:String(e))}finally{le(null)}},[Y]),Q=(0,W.useCallback)(async(e,t,n=r.operationDone)=>{K(e),A(null),_e(null);try{await t();let[e,r]=await Promise.all([me(),ue()]);C(e),T(r),_e(n)}catch(e){A(e instanceof Error?e.message:String(e))}finally{K(null)}},[r.operationDone]);return(0,W.useLayoutEffect)(()=>(d({startExtra:null,main:(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,J.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.workHome.subtitle})]}),end:Se}),()=>f()),[f,Se,d,n.title,n.workHome.subtitle]),(0,J.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-1 flex-col gap-7 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,J.jsx)(ce,{open:V,onOpenChange:H,children:(0,J.jsxs)(I,{children:[(0,J.jsx)(M,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(P,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -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,J.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(b,{className:`text-base font-semibold text-fg`,children:o.dialogTitle}),(0,J.jsx)(S,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:o.dialogDescription})]}),(0,J.jsx)(_,{asChild:!0,children:(0,J.jsx)(g,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:n.cancel,"aria-label":n.cancel,children:(0,J.jsx)(D,{className:`size-4`,"aria-hidden":!0})})})]}),(0,J.jsxs)(`form`,{onSubmit:be,className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,children:[(0,J.jsx)(`label`,{htmlFor:`new-work-outcome`,className:`mb-2 shrink-0 text-sm font-medium text-fg`,children:o.intentLabel}),(0,J.jsx)(`textarea`,{id:`new-work-outcome`,className:`min-h-32 w-full flex-1 resize-none rounded-xl border border-edge bg-surface-base p-3 text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,value:U,onChange:e=>re(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:o.intentPlaceholder,maxLength:12e3,autoFocus:!0}),(0,J.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,J.jsx)(`span`,{children:n.workHome.submitShortcut}),(0,J.jsxs)(`span`,{className:`tabular-nums`,children:[U.length.toLocaleString(),` / `,12e3.toLocaleString()]})]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(_,{asChild:!0,children:(0,J.jsx)(g,{type:`button`,variant:`ghost`,children:n.cancel})}),(0,J.jsxs)(g,{type:`submit`,variant:`primary`,className:`min-w-32`,disabled:!U.trim(),children:[(0,J.jsx)(te,{className:`size-4`,"aria-hidden":!0}),o.submit]})]})]})]})]})}),k?(0,J.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`,children:[(0,J.jsx)(`span`,{children:k}),(0,J.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Y(),children:n.workHome.retry})]}):null,E?(0,J.jsx)(He,{}):p?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`section`,{className:`border-b border-edge-subtle pb-5`,children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.workHome.briefingTitle}),(0,J.jsx)(`h2`,{className:`mt-1 text-xl font-semibold tracking-tight text-fg`,children:p.decisions.length+p.attention.length>0?Be(n.workHome.todaySummary,{attention:p.decisions.length+p.attention.length,moving:p.briefing.progress.movingCount+p.chats.running.length}):Be(n.workHome.todaySummaryClear,{moving:p.briefing.progress.movingCount+p.chats.running.length})}),p.briefing.summary?(0,J.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:p.briefing.summary}):null]}),q?(0,J.jsx)(`div`,{role:`status`,className:`rounded-xl border border-success/25 bg-success-soft px-4 py-3 text-sm text-success`,children:q}):null,p.work.current.length===0&&p.workflowRuns.active.length===0&&p.decisions.length===0&&p.attention.length===0&&p.chats.running.length===0&&p.chats.recent.length===0&&p.upcomingAutomations.length===0&&x.length===0?(0,J.jsxs)(`section`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,J.jsx)(h,{className:`mx-auto size-6 text-accent`,"aria-hidden":!0}),(0,J.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:n.workHome.emptyTitle}),(0,J.jsx)(`p`,{className:`mx-auto mt-1 max-w-lg text-sm leading-6 text-fg-muted`,children:n.workHome.emptyBody}),(0,J.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,J.jsx)(g,{type:`button`,variant:`primary`,onClick:()=>c(`/chat/new`),children:n.workHome.startChat}),(0,J.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>H(!0),children:o.newWork})]})]}):null,(0,J.jsxs)(`div`,{className:`grid items-start gap-6 xl:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[Z.length>0?(0,J.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(s,{className:`size-4 text-danger`,"aria-hidden":!0}),(0,J.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:o.runAttention}),(0,J.jsx)($,{children:Z.length.toLocaleString()})]}),(0,J.jsx)(`div`,{className:`mt-4 space-y-2`,children:Z.map(e=>(0,J.jsx)(Ke,{item:e,statusLabel:e.reason===`run_timeout`?n.workHome.attentionTimeout:n.workHome.attentionFailed,retryLabel:n.workHome.attentionRetry,viewLabel:n.workHome.attentionView,acknowledgeLabel:n.workHome.attentionAcknowledge,busy:se===e.id,onView:()=>c(e.href),onRetry:()=>void we(e,Re),onAcknowledge:()=>void we(e,Le)},e.id))})]}):null,X.length>0?(0,J.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(s,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,J.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:o.needsAttention}),(0,J.jsx)($,{children:X.length.toLocaleString()})]}),(0,J.jsx)(`div`,{className:`mt-4 space-y-2`,children:X.map(e=>(0,J.jsx)(Ge,{item:e,kindLabel:n.workHome.decisionKinds[e.kind],reasonLabel:n.workHome.decisionReasons[e.reason],approveLabel:n.workHome.approve,denyLabel:n.workHome.deny,busy:ie===e.id,onRespond:t=>void Ce(e,t)},e.id))})]}):(0,J.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,J.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-success-soft text-xs text-success`,"aria-hidden":!0,children:`✓`}),n.workHome.nothingNeedsYou]}),(0,J.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(te,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,J.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:o.running}),(0,J.jsx)($,{children:(p.chats.running.length+p.workflowRuns.active.length).toLocaleString()})]}),(0,J.jsxs)(`div`,{className:`mt-4 divide-y divide-edge-subtle px-1`,children:[p.chats.running.map(e=>(0,J.jsx)(`div`,{className:`py-1`,children:(0,J.jsx)(We,{chat:e,statusLabel:n.workHome.running})},e.key)),p.workflowRuns.active.map(e=>(0,J.jsxs)(a,{to:ne(e.id),className:`flex items-center justify-between gap-3 rounded-lg px-2 py-3 text-sm hover:bg-surface-hover/55`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-accent`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.title})]}),(0,J.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.workHome.running})]},e.id)),p.chats.running.length===0&&p.workflowRuns.active.length===0?(0,J.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:o.emptyRunning}):null]})]}),(0,J.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(z,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:o.continue}),(0,J.jsx)($,{children:ye.length.toLocaleString()})]}),(0,J.jsxs)(`div`,{className:`mt-4 divide-y divide-edge-subtle px-1`,children:[ye.map(e=>(0,J.jsx)(`div`,{className:`py-1`,children:(0,J.jsx)(Ue,{item:e,statusLabel:t.projectDetailPage.workItems.statuses[e.status]})},e.id)),ye.length===0?(0,J.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:o.emptyContinue}):null]})]}),p.chats.recent.length>0?(0,J.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,J.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:o.recent})}),(0,J.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:p.chats.recent.slice(0,6).map(e=>(0,J.jsx)(We,{chat:e,statusLabel:o.openChat},e.key))})]}):null]}),(0,J.jsxs)(`aside`,{className:`min-w-0 space-y-4`,"aria-label":n.workHome.nowTitle,children:[(0,J.jsx)(`div`,{className:`px-1`,children:(0,J.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.workHome.nowTitle})}),p.upcomingAutomations.length>0?(0,J.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(oe,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.workHome.scheduled})]}),(0,J.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle`,children:p.upcomingAutomations.slice(0,3).map(e=>(0,J.jsxs)(a,{to:`/automations`,className:`flex items-center justify-between gap-3 rounded-lg px-1 py-3 text-sm hover:bg-surface-hover/55`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.name||e.action}),(0,J.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:Ve(e.nextRunAt,n.never)})]},e.id))})]}):null,(0,J.jsx)(xe,{}),p.briefing.wins.length>0?(0,J.jsxs)(a,{to:p.briefing.wins[0].href,className:`flex items-center justify-between gap-3 rounded-xl px-2 py-2 text-sm text-fg-muted hover:bg-surface-hover/55 hover:text-fg`,children:[(0,J.jsx)(`span`,{children:Be(n.workHome.completedSummary,{count:p.briefing.wins.length})}),(0,J.jsxs)(`span`,{className:`shrink-0 text-xs font-medium text-accent`,children:[n.workHome.viewLatestResult,` →`]})]}):null]})]}),(0,J.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(F,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,J.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:o.focuses}),(0,J.jsx)($,{children:x.length.toLocaleString()})]}),x.length>0?(0,J.jsx)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2`,children:x.slice(0,6).map(t=>(0,J.jsx)(Pe,{focus:t,language:e,busy:G===t.id,onMonitor:(e,n)=>void Q(t.id,async()=>{await he(t.id,e,n)},n?r.monitorStarted:r.monitorStopped),onStatus:e=>void Q(t.id,async()=>{await de(t.id,{status:e})}),onDelete:()=>{window.confirm(r.deleteConfirm)&&Q(t.id,()=>pe(t.id))}},t.id))}):(0,J.jsxs)(`div`,{className:`py-8 text-center`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.empty}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.emptyHint})]})]}),w.length>0?(0,J.jsxs)(`section`,{className:`rounded-2xl border border-dashed border-edge p-5`,children:[(0,J.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r.candidates}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.candidatesHint}),(0,J.jsx)(`div`,{className:`mt-4 space-y-2`,children:w.map(e=>(0,J.jsxs)(`article`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.title}),(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.summary})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,J.jsx)(g,{variant:`ghost`,className:`h-8 text-xs`,disabled:G===e.id,onClick:()=>void Q(e.id,async()=>{await fe(e.id,`dismiss`)}),children:r.dismiss}),(0,J.jsx)(g,{variant:`primary`,className:`h-8 text-xs`,disabled:G===e.id,onClick:()=>void Q(e.id,async()=>{await fe(e.id,`accept`)}),children:r.accept})]})]},e.id))})]}):null]}):null,(0,J.jsxs)(`section`,{className:`border-t border-edge-subtle pt-7`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.projects}),(0,J.jsx)(a,{to:`/projects`,className:`text-xs font-medium text-accent hover:underline`,children:n.management.viewAll})]}),v.filter(e=>e.status!==`archived`).length>6?(0,J.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,J.jsxs)(`label`,{className:`relative block min-w-0`,children:[(0,J.jsx)(L,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`input`,{className:`h-9 w-52 rounded-lg border border-edge bg-surface-panel pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:R,onChange:e=>ee(e.target.value),placeholder:n.searchPlaceholder,"aria-label":n.searchPlaceholder})]})}):null,(0,J.jsx)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:ve.map(e=>(0,J.jsx)(qe,{project:e,openLabel:n.workHome.openSpace,noDescription:n.noDescription},e.id))}),!E&&ve.length===0?(0,J.jsx)(`p`,{className:`py-8 text-center text-sm text-fg-muted`,children:n.workHome.noSpaces}):null]})]})}export{Je as WorkPage};
@@ -0,0 +1,3 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-CarlxqXV.js";import{o,r as s}from"./locale-store-sToMfHX_.js";import{As as c,Bo as l,Bs as u,Cc as d,G as f,Go as p,Ji as m,Ns as h,Uo as g,Vo as _,Wl as v,Wo as y,X as b,Xs as x,cc as S,gl as C,gt as w,ht as T,ic as E,is as D,ns as O,oc as k,ot as A,vu as j,zo as M}from"./index-2UImfRDC.js";var N=e(t(),1),P=n();function F(e){if(!e.trim())return null;try{return JSON.parse(e)}catch{return null}}function I(e){return typeof e.message==`string`&&e.message.trim()?e.message:typeof e.error==`string`&&e.error.trim()?e.error:e.error&&typeof e.error==`object`&&typeof e.error.message==`string`?e.error.message:`AI suggestion failed`}function L(e,t={}){let n=F(e.split(`
2
+ `).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
3
+ `));if(!n)return null;if(n.type===`text_delta`&&typeof n.delta==`string`)return t.onDelta?.(n.delta),null;if(n.type===`thinking_delta`&&typeof n.delta==`string`)return t.onThinkingDelta?.(n.delta),null;if(n.type===`done`&&typeof n.text==`string`)return n.text;if(n.type===`error`)throw Error(I(n));return null}async function R(e,t={}){let n=await o(s(`/api/ai/text-assist`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify(e)});if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message;throw Error(t||`AI suggestion failed (${n.status})`)}if(!n.body){let e=await n.json().catch(()=>null);if(e?.text)return e;throw Error(`AI suggestion stream is empty`)}let r=n.body.getReader(),i=new TextDecoder,a=``,c=``,l=``;for(;;){let{done:e,value:n}=await r.read();if(n){a+=i.decode(n,{stream:!e});let r=a.split(/\r?\n\r?\n/);a=r.pop()??``;for(let e of r){let n=L(e,{onDelta:e=>{c+=e,t.onDelta?.(e)},onThinkingDelta:e=>{l+=e,t.onThinkingDelta?.(e)}});n!==null&&(c=n)}}if(e)break}if(a.trim()){let e=L(a,{onDelta:e=>{c+=e,t.onDelta?.(e)},onThinkingDelta:e=>{l+=e,t.onThinkingDelta?.(e)}});e!==null&&(c=e)}let u=c.trim();if(!u)throw Error(`AI returned an empty suggestion`);return{text:u,thinking:l.trim()||void 0}}function ee(){let[e,t]=(0,N.useState)(``),[n,r]=(0,N.useState)(``),[i,a]=(0,N.useState)(!1),[o,s]=(0,N.useState)(null);return{suggestion:e,thinking:n,loading:i,error:o,generate:(0,N.useCallback)(async e=>{a(!0),s(null),t(``),r(``);try{let n=await R(e,{onDelta:e=>{t(t=>t+e)},onThinkingDelta:e=>{r(t=>t+e)}});return t(n.text),r(n.thinking??``),n.text}catch(e){return s(e instanceof Error?e.message:`AI suggestion failed`),null}finally{a(!1)}},[]),reset:(0,N.useCallback)(()=>{t(``),r(``),s(null),a(!1)},[])}}var z=r(),te=5;function ne(e){return e.startsWith(`zh`)?{title:`AI 优化文案`,buttonTitle:`优化文案`,current:`当前内容`,suggestion:`AI 建议`,editedSuggestion:`审核并编辑建议`,thinking:`模型思考`,thinkingLoading:`思考中`,edit:`编辑`,preview:`预览`,loading:`正在生成建议...`,empty:`暂无内容`,generate:`生成建议`,regenerate:`重新生成`,applyCurrent:`应用当前内容`,replace:`替换`,append:`追加`,cancel:`取消`,close:`关闭`}:{title:`AI text assist`,buttonTitle:`Improve text`,current:`Current`,suggestion:`Suggestion`,editedSuggestion:`Review and edit suggestion`,thinking:`Model thinking`,thinkingLoading:`Thinking`,edit:`Edit`,preview:`Preview`,loading:`Generating suggestion...`,empty:`No content`,generate:`Generate suggestion`,regenerate:`Regenerate`,applyCurrent:`Apply current`,replace:`Replace`,append:`Append`,cancel:`Cancel`,close:`Close`}}function B(e){let t=(0,P.c)(239),{value:n,onApply:r,fieldId:a,fieldLabel:o,scenario:s,format:u,intent:f,locale:b,context:x,disabled:S,className:C,showLabel:w}=e,T=s===void 0?`generic.text`:s,D=u===void 0?`plain`:u,O=f===void 0?`improve`:f,A=w===void 0?!0:w,[F,I]=(0,N.useState)(!1),[L,R]=(0,N.useState)(n),[B,V]=(0,N.useState)(`preview`),[H,U]=(0,N.useState)(``),[W,ae]=(0,N.useState)(`edit`),[G,K]=(0,N.useState)(!0),[oe,se]=(0,N.useState)(!1),[ce,q]=(0,N.useState)(null),le=(0,N.useRef)(null),ue=(0,N.useRef)(!0),{suggestion:de,thinking:J,loading:Y,error:X,generate:fe,reset:pe}=ee(),me;t[0]===b?me=t[1]:(me=ne(b),t[0]=b,t[1]=me);let Z=me,he;t[2]!==Y||t[3]!==J?(he=Y&&J.trim().length>0,t[2]=Y,t[3]=J,t[4]=he):he=t[4];let Q=he,ge,_e;t[5]!==F||t[6]!==n?(ge=()=>{F||R(n)},_e=[F,n],t[5]=F,t[6]=n,t[7]=ge,t[8]=_e):(ge=t[7],_e=t[8]),(0,N.useEffect)(ge,_e);let ve,ye;t[9]===de?(ve=t[10],ye=t[11]):(ye=()=>{U(de)},ve=[de],t[9]=de,t[10]=ve,t[11]=ye),(0,N.useEffect)(ye,ve);let be,xe;t[12]===J?(be=t[13],xe=t[14]):(be=()=>{J.trim()&&K(!0)},xe=[J],t[12]=J,t[13]=be,t[14]=xe),(0,N.useEffect)(be,xe);let Se;t[15]!==Q||t[16]!==G?(Se=()=>{let e=le.current;!e||!Q||!G||ue.current&&(e.scrollTop=e.scrollHeight)},t[15]=Q,t[16]=G,t[17]=Se):Se=t[17];let Ce;t[18]!==Q||t[19]!==J||t[20]!==G?(Ce=[Q,J,G],t[18]=Q,t[19]=J,t[20]=G,t[21]=Ce):Ce=t[21],(0,N.useLayoutEffect)(Se,Ce);let we;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(we=()=>{let e=le.current;e&&(ue.current=e.scrollHeight-e.scrollTop-e.clientHeight<=te)},t[22]=we):we=t[22];let Te=we,Ee;t[23]!==x||t[24]!==a||t[25]!==o||t[26]!==D||t[27]!==fe||t[28]!==O||t[29]!==b||t[30]!==T?(Ee=async e=>{ae(`edit`),K(!0),ue.current=!0,await fe({intent:O,scenario:T,input:e,locale:b,field:{id:a,label:o,format:D},context:x})},t[23]=x,t[24]=a,t[25]=o,t[26]=D,t[27]=fe,t[28]=O,t[29]=b,t[30]=T,t[31]=Ee):Ee=t[31];let De=Ee,Oe;t[32]!==pe||t[33]!==n?(Oe=e=>{se(!!e.currentTarget.closest(`[role="dialog"]`)),q(document.querySelector(`.app-main-surface`)),R(n),V(`preview`),U(``),ae(`edit`),K(!0),pe(),I(!0)},t[32]=pe,t[33]=n,t[34]=Oe):Oe=t[34];let ke=Oe,Ae;t[35]!==L||t[36]!==De?(Ae=async()=>{await De(L)},t[35]=L,t[36]=De,t[37]=Ae):Ae=t[37];let je=Ae,Me;t[38]!==pe||t[39]!==n?(Me=()=>{I(!1),R(n),V(`preview`),U(``),ae(`edit`),K(!0),pe()},t[38]=pe,t[39]=n,t[40]=Me):Me=t[40];let $=Me,Ne;t[41]!==$||t[42]!==L||t[43]!==r?(Ne=()=>{r(L),$()},t[41]=$,t[42]=L,t[43]=r,t[44]=Ne):Ne=t[44];let Pe=Ne,Fe;t[45]!==$||t[46]!==H||t[47]!==r?(Fe=()=>{H.trim()&&(r(H),$())},t[45]=$,t[46]=H,t[47]=r,t[48]=Fe):Fe=t[48];let Ie=Fe,Le;t[49]!==$||t[50]!==L||t[51]!==H||t[52]!==r?(Le=()=>{if(!H.trim())return;let e=L.trimEnd();r(e?`${e}\n\n${H}`:H),$()},t[49]=$,t[50]=L,t[51]=H,t[52]=r,t[53]=Le):Le=t[53];let Re=Le,ze;t[54]!==H||t[55]!==X||t[56]!==Y?(ze=!Y&&!X&&H.trim().length>0,t[54]=H,t[55]=X,t[56]=Y,t[57]=ze):ze=t[57];let Be=ze,Ve=L!==n,He;t[58]!==H||t[59]!==X||t[60]!==J?(He=H.trim().length>0||J.trim().length>0||!!X,t[58]=H,t[59]=X,t[60]=J,t[61]=He):He=t[61];let Ue=He,We=!A&&`size-7 p-0`,Ge;t[62]!==C||t[63]!==We?(Ge=i(`h-7 gap-1 px-2 text-xs`,We,C),t[62]=C,t[63]=We,t[64]=Ge):Ge=t[64];let Ke=S||Y,qe;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,z.jsx)(k,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[65]=qe):qe=t[65];let Je=A?Z.buttonTitle:null,Ye;t[66]!==Z.buttonTitle||t[67]!==ke||t[68]!==Ge||t[69]!==Ke||t[70]!==Je?(Ye=(0,z.jsxs)(c,{type:`button`,variant:`ghost`,className:Ge,title:Z.buttonTitle,"aria-label":Z.buttonTitle,disabled:Ke,onClick:ke,children:[qe,Je]}),t[66]=Z.buttonTitle,t[67]=ke,t[68]=Ge,t[69]=Ke,t[70]=Je,t[71]=Ye):Ye=t[71];let Xe;t[72]===$?Xe=t[73]:(Xe=e=>e?I(!0):$(),t[72]=$,t[73]=Xe);let Ze=ce??void 0,Qe=oe?`bg-transparent`:`bg-scrim`,$e;t[74]===Qe?$e=t[75]:($e=i(`xopc-dialog-overlay absolute inset-0 z-[80]`,Qe),t[74]=Qe,t[75]=$e);let et;t[76]===$e?et=t[77]:(et=(0,z.jsx)(g,{className:$e}),t[76]=$e,t[77]=et);let tt;t[78]===Z.title?tt=t[79]:(tt=(0,z.jsx)(p,{className:`text-base font-semibold text-fg`,children:Z.title}),t[78]=Z.title,t[79]=tt);let nt;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,z.jsx)(h,{className:`size-5`,strokeWidth:1.75}),t[80]=nt):nt=t[80];let rt;t[81]===Z.close?rt=t[82]:(rt=(0,z.jsx)(l,{asChild:!0,children:(0,z.jsx)(c,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":Z.close,children:nt})}),t[81]=Z.close,t[82]=rt);let it;t[83]!==tt||t[84]!==rt?(it=(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[tt,rt]}),t[83]=tt,t[84]=rt,t[85]=it):it=t[85];let at;t[86]===Z.current?at=t[87]:(at=(0,z.jsx)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:Z.current}),t[86]=Z.current,t[87]=at);let ot=B===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,st;t[88]===ot?st=t[89]:(st=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,ot),t[88]=ot,t[89]=st);let ct,lt;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(ct=()=>V(`edit`),lt=(0,z.jsx)(E,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[90]=ct,t[91]=lt):(ct=t[90],lt=t[91]);let ut;t[92]!==Z.edit||t[93]!==st?(ut=(0,z.jsxs)(`button`,{type:`button`,className:st,onClick:ct,children:[lt,Z.edit]}),t[92]=Z.edit,t[93]=st,t[94]=ut):ut=t[94];let dt=B===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,ft;t[95]===dt?ft=t[96]:(ft=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,dt),t[95]=dt,t[96]=ft);let pt,mt;t[97]===Symbol.for(`react.memo_cache_sentinel`)?(pt=()=>V(`preview`),mt=(0,z.jsx)(v,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[97]=pt,t[98]=mt):(pt=t[97],mt=t[98]);let ht;t[99]!==Z.preview||t[100]!==ft?(ht=(0,z.jsxs)(`button`,{type:`button`,className:ft,onClick:pt,children:[mt,Z.preview]}),t[99]=Z.preview,t[100]=ft,t[101]=ht):ht=t[101];let gt;t[102]!==ut||t[103]!==ht?(gt=(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[ut,ht]}),t[102]=ut,t[103]=ht,t[104]=gt):gt=t[104];let _t;t[105]!==at||t[106]!==gt?(_t=(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[at,gt]}),t[105]=at,t[106]=gt,t[107]=_t):_t=t[107];let vt;t[108]!==L||t[109]!==B||t[110]!==D||t[111]!==Z.current||t[112]!==Z.empty?(vt=B===`preview`?(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:D===`markdown`?(0,z.jsx)(m,{content:L||Z.empty,compact:!0,className:`text-sm`}):(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:L||Z.empty})}):(0,z.jsx)(`textarea`,{className:`min-h-0 flex-1 resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25`,value:L,onChange:e=>R(e.currentTarget.value),placeholder:Z.empty,"aria-label":Z.current}),t[108]=L,t[109]=B,t[110]=D,t[111]=Z.current,t[112]=Z.empty,t[113]=vt):vt=t[113];let yt;t[114]!==_t||t[115]!==vt?(yt=(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[_t,vt]}),t[114]=_t,t[115]=vt,t[116]=yt):yt=t[116];let bt;t[117]===Z.editedSuggestion?bt=t[118]:(bt=(0,z.jsx)(`span`,{children:Z.editedSuggestion}),t[117]=Z.editedSuggestion,t[118]=bt);let xt;t[119]!==Z.loading||t[120]!==Y?(xt=Y?(0,z.jsx)(`span`,{className:`ml-2 font-normal`,children:Z.loading}):null,t[119]=Z.loading,t[120]=Y,t[121]=xt):xt=t[121];let St;t[122]!==bt||t[123]!==xt?(St=(0,z.jsxs)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:[bt,xt]}),t[122]=bt,t[123]=xt,t[124]=St):St=t[124];let Ct=W===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,wt;t[125]===Ct?wt=t[126]:(wt=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,Ct),t[125]=Ct,t[126]=wt);let Tt,Et;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(Tt=()=>ae(`edit`),Et=(0,z.jsx)(E,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[127]=Tt,t[128]=Et):(Tt=t[127],Et=t[128]);let Dt;t[129]!==Z.edit||t[130]!==wt?(Dt=(0,z.jsxs)(`button`,{type:`button`,className:wt,onClick:Tt,children:[Et,Z.edit]}),t[129]=Z.edit,t[130]=wt,t[131]=Dt):Dt=t[131];let Ot=W===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,kt;t[132]===Ot?kt=t[133]:(kt=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,Ot),t[132]=Ot,t[133]=kt);let At,jt;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(At=()=>ae(`preview`),jt=(0,z.jsx)(v,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[134]=At,t[135]=jt):(At=t[134],jt=t[135]);let Mt;t[136]!==Z.preview||t[137]!==kt?(Mt=(0,z.jsxs)(`button`,{type:`button`,className:kt,onClick:At,children:[jt,Z.preview]}),t[136]=Z.preview,t[137]=kt,t[138]=Mt):Mt=t[138];let Nt;t[139]!==Dt||t[140]!==Mt?(Nt=(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[Dt,Mt]}),t[139]=Dt,t[140]=Mt,t[141]=Nt):Nt=t[141];let Pt;t[142]!==St||t[143]!==Nt?(Pt=(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[St,Nt]}),t[142]=St,t[143]=Nt,t[144]=Pt):Pt=t[144];let Ft=Q?`opacity-100`:`pointer-events-none opacity-0`,It;t[145]===Ft?It=t[146]:(It=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Ft),t[145]=Ft,t[146]=It);let Lt=!Q,Rt;t[147]===Symbol.for(`react.memo_cache_sentinel`)?(Rt=()=>K(re),t[147]=Rt):Rt=t[147];let zt;t[148]!==Z.thinkingLoading||t[149]!==Y?(zt=Y?(0,z.jsxs)(`span`,{className:`ml-1 font-normal`,children:[`· `,Z.thinkingLoading]}):null,t[148]=Z.thinkingLoading,t[149]=Y,t[150]=zt):zt=t[150];let Bt;t[151]!==Z.thinking||t[152]!==zt?(Bt=(0,z.jsxs)(`span`,{className:`min-w-0 truncate`,children:[Z.thinking,zt]}),t[151]=Z.thinking,t[152]=zt,t[153]=Bt):Bt=t[153];let Vt=G&&`rotate-180`,Ht;t[154]===Vt?Ht=t[155]:(Ht=i(`size-3.5 shrink-0 transition-transform`,Vt),t[154]=Vt,t[155]=Ht);let Ut;t[156]===Ht?Ut=t[157]:(Ut=(0,z.jsx)(j,{className:Ht,strokeWidth:1.75,"aria-hidden":!0}),t[156]=Ht,t[157]=Ut);let Wt;t[158]!==Bt||t[159]!==Ut?(Wt=(0,z.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center justify-between gap-2 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:text-fg`,onClick:Rt,children:[Bt,Ut]}),t[158]=Bt,t[159]=Ut,t[160]=Wt):Wt=t[160];let Gt;t[161]!==J||t[162]!==G?(Gt=G?(0,z.jsx)(`pre`,{ref:le,className:`min-h-0 flex-1 overflow-auto border-t border-edge px-2.5 py-2 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,onScroll:Te,children:J}):null,t[161]=J,t[162]=G,t[163]=Gt):Gt=t[163];let Kt;t[164]!==Wt||t[165]!==Gt?(Kt=(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-lg border border-edge bg-surface-muted/70`,children:[Wt,Gt]}),t[164]=Wt,t[165]=Gt,t[166]=Kt):Kt=t[166];let qt;t[167]!==It||t[168]!==Lt||t[169]!==Kt?(qt=(0,z.jsx)(`div`,{className:It,"aria-hidden":Lt,children:Kt}),t[167]=It,t[168]=Lt,t[169]=Kt,t[170]=qt):qt=t[170];let Jt=Q?`pointer-events-none opacity-0`:`opacity-100`,Yt;t[171]===Jt?Yt=t[172]:(Yt=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Jt),t[171]=Jt,t[172]=Yt);let Xt;t[173]!==H||t[174]!==X||t[175]!==D||t[176]!==Z.empty||t[177]!==Z.loading||t[178]!==Z.suggestion||t[179]!==Y||t[180]!==W?(Xt=X?(0,z.jsx)(`pre`,{className:`h-full min-h-0 overflow-auto whitespace-pre-wrap rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg-muted`,children:X}):W===`preview`?(0,z.jsx)(`div`,{className:`h-full min-h-0 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:Y&&!H.trim()?(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Z.loading}):D===`markdown`?(0,z.jsx)(m,{content:H||Z.empty,compact:!0,className:`text-sm`}):(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:H||Z.empty})}):(0,z.jsx)(`textarea`,{className:`h-full min-h-0 w-full resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25 disabled:text-fg-muted`,value:H,onChange:e=>U(e.currentTarget.value),disabled:Y,placeholder:Y?Z.loading:Z.empty,"aria-label":Z.suggestion}),t[173]=H,t[174]=X,t[175]=D,t[176]=Z.empty,t[177]=Z.loading,t[178]=Z.suggestion,t[179]=Y,t[180]=W,t[181]=Xt):Xt=t[181];let Zt;t[182]!==Yt||t[183]!==Xt?(Zt=(0,z.jsx)(`div`,{className:Yt,children:Xt}),t[182]=Yt,t[183]=Xt,t[184]=Zt):Zt=t[184];let Qt;t[185]!==qt||t[186]!==Zt?(Qt=(0,z.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[qt,Zt]}),t[185]=qt,t[186]=Zt,t[187]=Qt):Qt=t[187];let $t;t[188]!==Pt||t[189]!==Qt?($t=(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[Pt,Qt]}),t[188]=Pt,t[189]=Qt,t[190]=$t):$t=t[190];let en;t[191]!==yt||t[192]!==$t?(en=(0,z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-3 overflow-hidden p-4 md:grid-cols-2`,children:[yt,$t]}),t[191]=yt,t[192]=$t,t[193]=en):en=t[193];let tn;t[194]!==$||t[195]!==Z.cancel?(tn=(0,z.jsx)(c,{type:`button`,variant:`secondary`,onClick:$,children:Z.cancel}),t[194]=$,t[195]=Z.cancel,t[196]=tn):tn=t[196];let nn=!Ve,rn;t[197]!==Pe||t[198]!==Z.applyCurrent||t[199]!==nn?(rn=(0,z.jsx)(c,{type:`button`,variant:`secondary`,disabled:nn,onClick:Pe,children:Z.applyCurrent}),t[197]=Pe,t[198]=Z.applyCurrent,t[199]=nn,t[200]=rn):rn=t[200];let an;t[201]===je?an=t[202]:(an=()=>void je(),t[201]=je,t[202]=an);let on;t[203]===Ue?on=t[204]:(on=Ue?(0,z.jsx)(d,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,z.jsx)(k,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[203]=Ue,t[204]=on);let sn=Ue?Z.regenerate:Z.generate,cn;t[205]!==Y||t[206]!==an||t[207]!==on||t[208]!==sn?(cn=(0,z.jsxs)(c,{type:`button`,variant:`secondary`,disabled:Y,onClick:an,children:[on,sn]}),t[205]=Y,t[206]=an,t[207]=on,t[208]=sn,t[209]=cn):cn=t[209];let ln=!Be,un;t[210]!==Re||t[211]!==Z.append||t[212]!==ln?(un=(0,z.jsx)(c,{type:`button`,variant:`secondary`,disabled:ln,onClick:Re,children:Z.append}),t[210]=Re,t[211]=Z.append,t[212]=ln,t[213]=un):un=t[213];let dn=!Be,fn;t[214]!==Ie||t[215]!==Z.replace||t[216]!==dn?(fn=(0,z.jsx)(c,{type:`button`,variant:`primary`,disabled:dn,onClick:Ie,children:Z.replace}),t[214]=Ie,t[215]=Z.replace,t[216]=dn,t[217]=fn):fn=t[217];let pn;t[218]!==fn||t[219]!==tn||t[220]!==rn||t[221]!==cn||t[222]!==un?(pn=(0,z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[tn,rn,cn,un,fn]}),t[218]=fn,t[219]=tn,t[220]=rn,t[221]=cn,t[222]=un,t[223]=pn):pn=t[223];let mn;t[224]!==pn||t[225]!==it||t[226]!==en?(mn=(0,z.jsx)(`div`,{className:`absolute inset-0 z-[80] flex items-center justify-center p-4 pointer-events-none`,children:(0,z.jsxs)(_,{className:`xopc-dialog-content-pane pointer-events-auto flex h-[min(78vh,38rem)] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,onOpenAutoFocus:ie,children:[it,en,pn]})}),t[224]=pn,t[225]=it,t[226]=en,t[227]=mn):mn=t[227];let hn;t[228]!==mn||t[229]!==Ze||t[230]!==et?(hn=(0,z.jsxs)(y,{container:Ze,children:[et,mn]}),t[228]=mn,t[229]=Ze,t[230]=et,t[231]=hn):hn=t[231];let gn;t[232]!==F||t[233]!==hn||t[234]!==Xe?(gn=(0,z.jsx)(M,{open:F,onOpenChange:Xe,children:hn}),t[232]=F,t[233]=hn,t[234]=Xe,t[235]=gn):gn=t[235];let _n;return t[236]!==gn||t[237]!==Ye?(_n=(0,z.jsxs)(z.Fragment,{children:[Ye,gn]}),t[236]=gn,t[237]=Ye,t[238]=_n):_n=t[238],_n}function re(e){return!e}function ie(e){return e.preventDefault()}function V(e){return!!(e&&e.type===`object`&&e.properties&&!Array.isArray(e.properties))}function H(e){let t=e.properties??{},n=new Set(e.required??[]);return Object.entries(t).map(([e,t])=>({key:e,schema:t,required:n.has(e)}))}function U(e,t){return!V(e)||!e?!0:H(e).every(e=>{if(!e.required)return!0;let n=t[e.key];return n==null?!1:typeof n==`string`?n.trim().length>0:!0})}function W(e,t){if(e)return V(e.inputSchema)?Object.keys(t.schemaInput).length>0?t.schemaInput:void 0:f(t.argValues)}function ae(e,t,n){let r=a(t).workflows;if(!e)return r.noInputSummary;let i=w(e,t);if(V(e.inputSchema)&&Object.keys(n.schemaInput).length>0)return Object.entries(n.schemaInput).map(([e,t])=>`${e}: ${String(t)}`).join(` · `);let o=Object.values(n.argValues).map(e=>e.trim()).filter(Boolean),s=n.goal.trim()||i.description;return s&&o.unshift(s),o.length>0?o.join(` · `):r.noInputSummary}function G(e,t,n=!0){return e?n?V(e.inputSchema)?U(e.inputSchema,t.schemaInput)?{valid:!0}:{valid:!1,reason:`schema-required`}:{valid:(A[e.name]??[]).every(e=>!e.required||!!t.argValues[e.key]?.trim())}:{valid:!1,reason:`raw-json`}:{valid:!1}}function K(e,t){return e[t]??t}function oe(e,t){let n=A[e]??[];if(n.length===0)return{};let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{},i={};for(let e of n){let t=r[e.key];t!=null&&(i[e.key]=String(t))}return i}function se(e){let t=(0,P.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,z.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,z.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function ce(e){let t=(0,P.c)(34),{workflowName:n,language:r,argValues:o,onArgValuesChange:s,goal:c,onGoalChange:l,examplePrompts:u,showGoal:d,inputClassName:f,aiAssist:p}=e,m;t[0]===u?m=t[1]:(m=u===void 0?[]:u,t[0]=u,t[1]=m);let h=m,g=d===void 0?!0:d,_,v,y,b,x,S,C;if(t[2]!==p||t[3]!==o||t[4]!==h||t[5]!==c||t[6]!==f||t[7]!==r||t[8]!==s||t[9]!==l||t[10]!==g||t[11]!==n){y=a(r).workflows;let e=A[n]??[];v=e.length>0;let u=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,f),d;t[19]!==o||t[20]!==s||t[21]!==l?(d=e=>{T(e,l,e=>{s(e(o))})},t[19]=o,t[20]=s,t[21]=l,t[22]=d):d=t[22],_=d,b=`flex flex-col gap-3`,x=e.map(e=>{let t=K(y.args,e.labelKey),a=K(y.args,e.placeholderKey),c=o[e.key]??``;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[t,e.required?` *`:``]}),e.multiline&&p?(0,z.jsx)(B,{value:c,onApply:t=>s({...o,[e.key]:t}),fieldId:`workflow.arg.${e.key}`,fieldLabel:t,scenario:p.argScenario??`workflow.arg`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o,fieldKey:e.key},disabled:p.disabled,showLabel:!1}):null]}),e.multiline?(0,z.jsx)(`textarea`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:i(u,`min-h-20 resize-y`)}):(0,z.jsx)(`input`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:u})]},e.key)}),S=v&&h.length>0?(0,z.jsx)(se,{examples:h,labels:y,onSelect:_}):null,C=g?(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:y.goalLabel}),p?(0,z.jsx)(B,{value:c,onApply:l,fieldId:`workflow.goal`,fieldLabel:y.goalLabel,scenario:p.goalScenario??`cron.workflowGoal`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o},disabled:p.disabled,showLabel:!1}):null]}),(0,z.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:y.goalPlaceholder,className:i(u,`min-h-20 resize-y`)})]}):null,t[2]=p,t[3]=o,t[4]=h,t[5]=c,t[6]=f,t[7]=r,t[8]=s,t[9]=l,t[10]=g,t[11]=n,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C}else _=t[12],v=t[13],y=t[14],b=t[15],x=t[16],S=t[17],C=t[18];let w;t[23]!==_||t[24]!==h||t[25]!==v||t[26]!==y?(w=!v&&h.length>0?(0,z.jsx)(se,{examples:h,labels:y,onSelect:_}):null,t[23]=_,t[24]=h,t[25]=v,t[26]=y,t[27]=w):w=t[27];let E;return t[28]!==b||t[29]!==x||t[30]!==S||t[31]!==C||t[32]!==w?(E=(0,z.jsxs)(`div`,{className:b,children:[x,S,C,w]}),t[28]=b,t[29]=x,t[30]=S,t[31]=C,t[32]=w,t[33]=E):E=t[33],E}var q=`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`;function le({schema:e,value:t,onChange:n,labels:r,aiAssist:a,onValidChange:o}){let s=(0,N.useMemo)(()=>H(e),[e]),[c,l]=(0,N.useState)(!1),[u,d]=(0,N.useState)(()=>JSON.stringify(t,null,2)),[f,p]=(0,N.useState)(null);if(s.length===0)return null;let m=(e,r)=>{let i={...t,[e]:r};(r===``||r===void 0)&&delete i[e],n(i),c&&d(JSON.stringify(i,null,2))},h=e=>{d(e);try{let t=e.trim()?JSON.parse(e):{};if(!t||typeof t!=`object`||Array.isArray(t)){p(r.rawJsonInvalid),o?.(!1);return}p(null),n(t),o?.(!0,t)}catch{p(r.rawJsonInvalid),o?.(!1)}};return(0,z.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel/70 p-4 shadow-surface`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.inputSchemaHeading}),(0,z.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent-fg hover:underline`,onClick:()=>{let e=!c;l(e),e&&(d(JSON.stringify(t,null,2)),p(null),o?.(!0))},children:r.rawJson})]}),c?(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsx)(`textarea`,{value:u,onChange:e=>h(e.target.value),spellCheck:!1,className:i(q,`min-h-40 font-mono text-xs leading-5`)}),f?(0,z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-300`,children:f}):null]}):(0,z.jsx)(`div`,{className:`mt-3 grid gap-3`,children:s.map(e=>(0,z.jsx)(ue,{field:e,value:t[e.key],labels:r,aiAssist:a,allValues:t,onChange:t=>m(e.key,t)},e.key))})]})}function ue(e){let t=(0,P.c)(30),{field:n,value:r,labels:a,aiAssist:o,allValues:s,onChange:c}=e,l=n.schema.title||n.key,u=typeof n.schema.description==`string`?n.schema.description:void 0,d=Array.isArray(n.schema.type)?n.schema.type[0]:n.schema.type,f;t[0]===n.schema.enum?f=t[1]:(f=Array.isArray(n.schema.enum)?n.schema.enum:[],t[0]=n.schema.enum,t[1]=f);let p=f,m=!!o&&!p.length&&(d===`string`||!d),h=String(l),g=n.required?` *`:``,_;t[2]!==h||t[3]!==g?(_=(0,z.jsxs)(`span`,{className:`text-xs font-medium text-fg`,children:[h,g]}),t[2]=h,t[3]=g,t[4]=_):_=t[4];let v;t[5]!==o||t[6]!==s||t[7]!==n.key||t[8]!==n.schema||t[9]!==c||t[10]!==m||t[11]!==l||t[12]!==r?(v=m&&o?(0,z.jsx)(B,{value:typeof r==`string`?r:r==null?``:String(r),onApply:c,fieldId:`workflow.schema.${n.key}`,fieldLabel:String(l),scenario:o.scenario??`workflow.arg`,locale:o.locale,context:{...o.context,fieldKey:n.key,fieldSchema:n.schema,inputValues:s},disabled:o.disabled,showLabel:!1}):null,t[5]=o,t[6]=s,t[7]=n.key,t[8]=n.schema,t[9]=c,t[10]=m,t[11]=l,t[12]=r,t[13]=v):v=t[13];let y;t[14]!==_||t[15]!==v?(y=(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===u?b=t[18]:(b=u?(0,z.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-subtle`,children:u}):null,t[17]=u,t[18]=b);let x;t[19]!==u||t[20]!==p||t[21]!==a||t[22]!==c||t[23]!==d||t[24]!==r?(x=p.length>0?(0,z.jsxs)(O,{value:r==null?``:String(r),onChange:e=>c(e.target.value),className:q,children:[(0,z.jsx)(D,{value:``}),p.map(de)]}):d===`boolean`?(0,z.jsxs)(O,{value:typeof r==`boolean`?String(r):``,onChange:e=>c(e.target.value===``?void 0:e.target.value===`true`),className:q,children:[(0,z.jsx)(D,{value:``}),(0,z.jsx)(D,{value:`true`,children:a.booleanTrue}),(0,z.jsx)(D,{value:`false`,children:a.booleanFalse})]}):d===`number`||d===`integer`?(0,z.jsx)(`input`,{type:`number`,value:typeof r==`number`||typeof r==`string`?String(r):``,onChange:e=>c(e.target.value===``?void 0:Number(e.target.value)),className:q}):(0,z.jsx)(`textarea`,{value:typeof r==`string`?r:r==null?``:String(r),onChange:e=>c(e.target.value),className:i(q,u&&u.length>80?`min-h-20 resize-y`:`min-h-10 resize-y`)}),t[19]=u,t[20]=p,t[21]=a,t[22]=c,t[23]=d,t[24]=r,t[25]=x):x=t[25];let S;return t[26]!==y||t[27]!==b||t[28]!==x?(S=(0,z.jsxs)(`div`,{className:`block`,children:[y,b,x]}),t[26]=y,t[27]=b,t[28]=x,t[29]=S):S=t[29],S}function de(e){return(0,z.jsx)(D,{value:String(e),children:String(e)},String(e))}function J(e){let t=(0,P.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,z.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,z.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function Y(e){let t=(0,P.c)(114),{definition:n,language:r,value:o,onChange:s,aiAssist:c,inputClassName:l,onValidityChange:u}=e,d;t[0]===r?d=t[1]:(d=a(r),t[0]=r,t[1]=d);let f=d.workflows,p;t[2]!==n||t[3]!==r?(p=w(n,r),t[2]=n,t[3]=r,t[4]=p):p=t[4];let m=p,[h,g]=(0,N.useState)(!0),_;t[5]===m.examplePrompts?_=t[6]:(_=m.examplePrompts??[],t[5]=m.examplePrompts,t[6]=_);let v=_,y;t[7]===n.inputSchema?y=t[8]:(y=V(n.inputSchema),t[7]=n.inputSchema,t[8]=y);let b=y,x,S,C,T,E,D,O,k,A,j;if(t[9]!==c||t[10]!==n||t[11]!==v||t[12]!==b||t[13]!==l||t[14]!==f||t[15]!==r||t[16]!==m.description||t[17]!==s||t[18]!==u||t[19]!==h||t[20]!==o){E=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,l),a;t[31]!==n||t[32]!==s||t[33]!==u||t[34]!==h?(a=(e,t)=>{let r=t===void 0?h:t;s(e),u?.(G(n,e,r))},t[31]=n,t[32]=s,t[33]=u,t[34]=h,t[35]=a):a=t[35];let d=a,p;t[36]!==d||t[37]!==o?(p=e=>d({...o,goal:e}),t[36]=d,t[37]=o,t[38]=p):p=t[38];let _=p,y;t[39]!==d||t[40]!==o?(y=e=>d({...o,schemaInput:e}),t[39]=d,t[40]=o,t[41]=y):y=t[41];let w=y,M;t[42]!==d||t[43]!==o?(M=e=>d({...o,argValues:e}),t[42]=d,t[43]=o,t[44]=M):M=t[44];let N=M,P;if(t[45]!==_||t[46]!==w||t[47]!==o.schemaInput?(P=e=>{if(e.field===`goal`){_(e.text);return}w({...o.schemaInput,[e.field]:e.text})},t[45]=_,t[46]=w,t[47]=o.schemaInput,t[48]=P):P=t[48],x=P,!b){let e;t[49]!==c||t[50]!==n.id||t[51]!==n.name||t[52]!==n.title||t[53]!==m.description?(e=c?{disabled:c.disabled,argScenario:c.inputScenario??`workflow.arg`,goalScenario:c.goalScenario??`workflow.goal`,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description}}:void 0,t[49]=c,t[50]=n.id,t[51]=n.name,t[52]=n.title,t[53]=m.description,t[54]=e):e=t[54];let i;t[55]!==n.name||t[56]!==v||t[57]!==l||t[58]!==r||t[59]!==N||t[60]!==_||t[61]!==e||t[62]!==o.argValues||t[63]!==o.goal?(i=(0,z.jsx)(ce,{workflowName:n.name,language:r,argValues:o.argValues,onArgValuesChange:N,goal:o.goal,onGoalChange:_,examplePrompts:v,inputClassName:l,aiAssist:e}),t[55]=n.name,t[56]=v,t[57]=l,t[58]=r,t[59]=N,t[60]=_,t[61]=e,t[62]=o.argValues,t[63]=o.goal,t[64]=i):i=t[64],E=i;break bb0}C=`flex flex-col gap-3`,t[65]!==c||t[66]!==n||t[67]!==f.booleanFalse||t[68]!==f.booleanTrue||t[69]!==f.inputSchemaHeading||t[70]!==f.rawJson||t[71]!==f.rawJsonInvalid||t[72]!==r||t[73]!==m.description||t[74]!==u||t[75]!==w||t[76]!==o?(T=n.inputSchema?(0,z.jsx)(le,{schema:n.inputSchema,value:o.schemaInput,onChange:w,onValidChange:(e,t)=>{g(e),u?.(G(n,t?{...o,schemaInput:t}:o,e))},aiAssist:c?{locale:r,disabled:c.disabled,scenario:c.inputScenario??`workflow.arg`,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description}}:void 0,labels:{inputSchemaHeading:f.inputSchemaHeading,rawJson:f.rawJson,rawJsonInvalid:f.rawJsonInvalid,booleanTrue:f.booleanTrue,booleanFalse:f.booleanFalse}}):null,t[65]=c,t[66]=n,t[67]=f.booleanFalse,t[68]=f.booleanTrue,t[69]=f.inputSchemaHeading,t[70]=f.rawJson,t[71]=f.rawJsonInvalid,t[72]=r,t[73]=m.description,t[74]=u,t[75]=w,t[76]=o,t[77]=T):T=t[77],j=`flex flex-col gap-1`;let F;t[78]===f.goalLabel?F=t[79]:(F=(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:f.goalLabel}),t[78]=f.goalLabel,t[79]=F);let I;t[80]!==c||t[81]!==n.id||t[82]!==n.name||t[83]!==n.title||t[84]!==f.goalLabel||t[85]!==r||t[86]!==m.description||t[87]!==_||t[88]!==o.goal||t[89]!==o.schemaInput?(I=c?(0,z.jsx)(B,{value:o.goal,onApply:_,fieldId:`workflow.goal`,fieldLabel:f.goalLabel,scenario:c.goalScenario??`workflow.goal`,locale:r,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description,workflowInput:o.schemaInput},disabled:c.disabled,showLabel:!1}):null,t[80]=c,t[81]=n.id,t[82]=n.name,t[83]=n.title,t[84]=f.goalLabel,t[85]=r,t[86]=m.description,t[87]=_,t[88]=o.goal,t[89]=o.schemaInput,t[90]=I):I=t[90],t[91]!==F||t[92]!==I?(S=(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[F,I]}),t[91]=F,t[92]=I,t[93]=S):S=t[93],D=o.goal,t[94]===_?O=t[95]:(O=e=>_(e.target.value),t[94]=_,t[95]=O),k=f.goalPlaceholder,A=i(e,`min-h-20 resize-y`)}t[9]=c,t[10]=n,t[11]=v,t[12]=b,t[13]=l,t[14]=f,t[15]=r,t[16]=m.description,t[17]=s,t[18]=u,t[19]=h,t[20]=o,t[21]=x,t[22]=S,t[23]=C,t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=j}else x=t[21],S=t[22],C=t[23],T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29],j=t[30];if(E!==Symbol.for(`react.early_return_sentinel`))return E;let M;t[96]!==D||t[97]!==O||t[98]!==k||t[99]!==A?(M=(0,z.jsx)(`textarea`,{value:D,onChange:O,placeholder:k,className:A}),t[96]=D,t[97]=O,t[98]=k,t[99]=A,t[100]=M):M=t[100];let F;t[101]!==S||t[102]!==M||t[103]!==j?(F=(0,z.jsxs)(`div`,{className:j,children:[S,M]}),t[101]=S,t[102]=M,t[103]=j,t[104]=F):F=t[104];let I;t[105]!==x||t[106]!==v||t[107]!==f?(I=(0,z.jsx)(J,{examples:v,labels:f,onSelect:x}),t[105]=x,t[106]=v,t[107]=f,t[108]=I):I=t[108];let L;return t[109]!==C||t[110]!==T||t[111]!==F||t[112]!==I?(L=(0,z.jsxs)(`div`,{className:C,children:[T,F,I]}),t[109]=C,t[110]=T,t[111]=F,t[112]=I,t[113]=L):L=t[113],L}function X(e,t){let n=e.metadata.estimatedAgents;return n?n.min===n.max?b(t.agentScaleExact,{count:n.min}):b(t.agentScaleRange,{min:n.min,max:n.max}):b(t.agentScaleExact,{count:e.defaults.maxSubagents})}function fe(e){let t=(0,P.c)(41),{definition:n,language:r,value:o,onChange:s,mode:c,badgeLabel:l,aiAssist:d,inputClassName:f,showTimeout:p,defaultAdvancedOpen:m,onValidityChange:h}=e,g=p===void 0?!1:p,_=m===void 0?!1:m,v=a(r).workflows,[y,T]=(0,N.useState)(_),E;t[0]!==n||t[1]!==r?(E=w(n,r),t[0]=n,t[1]=r,t[2]=E):E=t[2];let D=E,O;t[3]!==n.defaults||t[4]!==o.concurrency?(O=o.concurrency.trim()?Number(o.concurrency):n.defaults.concurrency,t[3]=n.defaults,t[4]=o.concurrency,t[5]=O):O=t[5];let k=O,A;t[6]!==n.defaults||t[7]!==o.maxSubagents?(A=o.maxSubagents.trim()?Number(o.maxSubagents):n.defaults.maxSubagents,t[6]=n.defaults,t[7]=o.maxSubagents,t[8]=A):A=t[8];let M=A,F;t[9]!==n||t[10]!==r||t[11]!==o?(F=ae(n,r,o),t[9]=n,t[10]=r,t[11]=o,t[12]=F):F=t[12];let I=F,L=l??v.readyToStart,R;t[13]!==s||t[14]!==o?(R=e=>s({...o,...e}),t[13]=s,t[14]=o,t[15]=R):R=t[15];let ee=R,te=c===`automation`&&`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,ne;t[16]===te?ne=t[17]:(ne=i(`space-y-4`,te),t[16]=te,t[17]=ne);let B=I||D.description,re;t[18]===B?re=t[19]:(re=(0,z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:B}),t[18]=B,t[19]=re);let ie;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,z.jsx)(C,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[20]=ie):ie=t[20];let V;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,z.jsx)(u,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[21]=V):V=t[21];let H;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,z.jsx)(S,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[22]=H):H=t[22];let U;t[23]!==s||t[24]!==o?(U=e=>s({...o,...e}),t[23]=s,t[24]=o,t[25]=U):U=t[25];let W;t[26]===h?W=t[27]:(W=e=>{h?.(e)},t[26]=h,t[27]=W);let G;t[28]!==d||t[29]!==n||t[30]!==f||t[31]!==r||t[32]!==U||t[33]!==W||t[34]!==o?(G=(0,z.jsx)(Y,{definition:n,language:r,value:o,onChange:U,onValidityChange:W,aiAssist:d,inputClassName:f}),t[28]=d,t[29]=n,t[30]=f,t[31]=r,t[32]=U,t[33]=W,t[34]=o,t[35]=G):G=t[35];let K;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>T(pe),t[36]=K):K=t[36];let oe=v.advancedSettings,se=y&&`rotate-180`,ce;t[37]===se?ce=t[38]:(ce=i(`size-4 transition-transform`,se),t[37]=se,t[38]=ce);let q;return t[39]===ce?q=t[40]:(q=(0,z.jsx)(j,{className:ce}),t[39]=ce,t[40]=q),(0,z.jsxs)(`div`,{className:ne,children:[(0,z.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:v.runPlanPreview}),re]}),(0,z.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2 py-1 text-[11px] font-medium text-accent-fg`,children:L})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-2 text-xs text-fg-muted sm:grid-cols-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[ie,(0,z.jsx)(`span`,{children:b(v.phaseCount,{count:n.phases.length})})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[V,(0,z.jsx)(`span`,{children:X(n,v)})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[H,(0,z.jsx)(`span`,{children:b(v.runLimitsSummary,{concurrency:k,max:M})})]})]}),n.phases.length>0?(0,z.jsxs)(`div`,{className:`mt-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:[(0,z.jsx)(x,{className:`size-3.5`,"aria-hidden":!0}),v.startPlanPhases]}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:n.phases.map(me)})]}):null]}),G,(0,z.jsxs)(`div`,{className:`rounded-xl border border-edge`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between px-3 py-2.5 text-left text-sm text-fg`,onClick:K,children:[oe,q]}),y?(0,z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge px-3 pb-3 pt-3 sm:grid-cols-2`,children:[(0,z.jsx)(`input`,{value:o.concurrency,onChange:e=>ee({concurrency:e.target.value}),placeholder:b(v.concurrencyPlaceholder,{default:n.defaults.concurrency}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,z.jsx)(`input`,{value:o.maxSubagents,onChange:e=>ee({maxSubagents:e.target.value}),placeholder:b(v.maxSubagentsPlaceholder,{default:n.defaults.maxSubagents}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),g?(0,z.jsx)(`input`,{value:o.timeoutSeconds??``,onChange:e=>ee({timeoutSeconds:e.target.value}),placeholder:b(v.timeoutSecondsPlaceholder,{default:n.defaults.timeoutSec}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}):null]}):null]})]})}function pe(e){return!e}function me(e,t){return(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t>0?(0,z.jsx)(`span`,{className:`text-fg-subtle`,children:`→`}):null,(0,z.jsx)(`span`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1 text-[11px] text-fg-muted`,children:e.title})]},e.id)}export{B as a,G as i,oe as n,W as r,fe as t};