@xopcai/xopc 0.0.459 → 0.0.462

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 (266) hide show
  1. package/dist/browser-ext/dist/assets/{pcm-capture-worklet-CGN9Mlhg.js → pcm-capture-worklet-Df5TcFw4.js} +4 -2
  2. package/dist/browser-ext/dist/sidepanel.js +3 -2
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{agents-CGUdvmIT.js → agents-DC0lHtl5.js} +3 -3
  6. package/dist/gateway/static/root/assets/{apps-page-M2XD1Pzu.js → apps-page-QLOYw2QR.js} +1 -1
  7. package/dist/gateway/static/root/assets/{automation-task-card-CiJmJ7_h.js → automation-task-card-CJbIHRxN.js} +1 -1
  8. package/dist/gateway/static/root/assets/{automations-page-CVjgENMO.js → automations-page-DpKnqajR.js} +1 -1
  9. package/dist/gateway/static/root/assets/{automations-workspace-CGPWyL0P.js → automations-workspace-BXT_EDON.js} +2 -2
  10. package/dist/gateway/static/root/assets/{block-editor-CmnkluMF.js → block-editor-DrZyRQQ0.js} +5 -5
  11. package/dist/gateway/static/root/assets/{capabilities-DDqDvCBs.js → capabilities-Dr-vvMez.js} +1 -1
  12. package/dist/gateway/static/root/assets/capabilities-hSb-qEgL.js +1 -0
  13. package/dist/gateway/static/root/assets/capabilities-page-CnU0htlO.js +2 -0
  14. package/dist/gateway/static/root/assets/{capabilities-settings-panel-CvF8VRTv.js → capabilities-settings-panel-B08mjrGB.js} +1 -1
  15. package/dist/gateway/static/root/assets/{channels-BDVQ6Z7A.js → channels-B--IHNs4.js} +1 -1
  16. package/dist/gateway/static/root/assets/{chat-chart-block-stPJEZ90.js → chat-chart-block-ClCZyIi0.js} +1 -1
  17. package/dist/gateway/static/root/assets/chat-page-U2a7d6wP.js +71 -0
  18. package/dist/gateway/static/root/assets/{chat-terminal-dock-B4uA_W6R.js → chat-terminal-dock-eneTvxV3.js} +1 -1
  19. package/dist/gateway/static/root/assets/{connectors-page-DyzDVVfz.js → connectors-page-Bs29RvXz.js} +1 -1
  20. package/dist/gateway/static/root/assets/constants-Bg1wM2nv.js +1 -0
  21. package/dist/gateway/static/root/assets/diagnostics-Bo0Z42P_.js +1 -0
  22. package/dist/gateway/static/root/assets/{extension-debug-page-BPwRrP3L.js → extension-debug-page-Bn_5xu_M.js} +1 -1
  23. package/dist/gateway/static/root/assets/{extension-iframe-host-DIH4TcdH.js → extension-iframe-host-Vs6USa0c.js} +1 -1
  24. package/dist/gateway/static/root/assets/{extension-message-router-C9JDpo_7.js → extension-message-router-GIekDj_w.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-page-CLDoL5N8.js → extension-page-C_3bIjSB.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-provider-BPIoHw4r.js → extension-provider-D-LolObs.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-settings-page-BO_UKeG8.js → extension-settings-page-BV51dk16.js} +1 -1
  28. package/dist/gateway/static/root/assets/home-page-DefKShSW.js +8 -0
  29. package/dist/gateway/static/root/assets/index-CChzK_5b.css +1 -0
  30. package/dist/gateway/static/root/assets/index-CEBDMkde.js +11 -0
  31. package/dist/gateway/static/root/assets/{local-app-workbench-page-D8oqDDAn.js → local-app-workbench-page-CfnixDO3.js} +1 -1
  32. package/dist/gateway/static/root/assets/{markdown-view-BlxIaCCQ.js → markdown-view-CNJaAdNN.js} +39 -39
  33. package/dist/gateway/static/root/assets/note-detail-panel-D_l5jkV9.js +7 -0
  34. package/dist/gateway/static/root/assets/note-image-lightbox-D6mvMSKr.js +1 -0
  35. package/dist/gateway/static/root/assets/{notes-api-CdXA-g9r.js → notes-api-BOIM9Q_D.js} +1 -1
  36. package/dist/gateway/static/root/assets/notes-page-R4uJroeD.js +8 -0
  37. package/dist/gateway/static/root/assets/{page-context-capture-button-Dibmspef.js → page-context-capture-button-B_Vdo2Ai.js} +1 -1
  38. package/dist/gateway/static/root/assets/pcm-capture-worklet-CpXsv44v.js +1 -0
  39. package/dist/gateway/static/root/assets/personal-page-BsONyPfQ.js +1 -0
  40. package/dist/gateway/static/root/assets/personal-profile-settings-C4CxmQLQ.js +1 -0
  41. package/dist/gateway/static/root/assets/{personal-settings-panel-BppxtWBl.js → personal-settings-panel-CnxI2TL0.js} +1 -1
  42. package/dist/gateway/static/root/assets/{product-automation-feedback-D51I7Lg3.js → product-automation-feedback-CGso8wGv.js} +1 -1
  43. package/dist/gateway/static/root/assets/{product-preview-content-WkF2j_c-.js → product-preview-content-Dgtb4LF7.js} +1 -1
  44. package/dist/gateway/static/root/assets/product-preview-modal-C35EWUps.js +2 -0
  45. package/dist/gateway/static/root/assets/project-detail-page-xNSy6SAv.js +7 -0
  46. package/dist/gateway/static/root/assets/recording-upload-CFX7CANT.js +1 -0
  47. package/dist/gateway/static/root/assets/route-preload-Dwb_N8L-.js +2 -0
  48. package/dist/gateway/static/root/assets/routine-panel-KH1VaEdC.js +2 -0
  49. package/dist/gateway/static/root/assets/session-manager-63NaXb1s.js +25 -0
  50. package/dist/gateway/static/root/assets/{settings-page-D2qkIrUg.js → settings-page-8MiJzbbl.js} +1 -1
  51. package/dist/gateway/static/root/assets/{share-preview-page-fV5USZb1.js → share-preview-page-Cqy-7-rd.js} +1 -1
  52. package/dist/gateway/static/root/assets/{shares-settings-sl40lqND.js → shares-settings-BDr50uTV.js} +1 -1
  53. package/dist/gateway/static/root/assets/{skills-page-FTd0Z7Ey.js → skills-page-DReUQ4Ug.js} +1 -1
  54. package/dist/gateway/static/root/assets/star-CnYNmpLd.js +1 -0
  55. package/dist/gateway/static/root/assets/task-detail-page-DxKXoBbE.js +3 -0
  56. package/dist/gateway/static/root/assets/{task-result-evidence-CSJeB9AH.js → task-result-evidence-CW_tN93T.js} +1 -1
  57. package/dist/gateway/static/root/assets/{use-composer-attachments-CO7XLI4x.js → use-composer-attachments-Xn6eUus2.js} +1 -1
  58. package/dist/gateway/static/root/assets/{use-file-preview-expanded-BXXeXnT0.js → use-file-preview-expanded-D0IBFhM9.js} +1 -1
  59. package/dist/gateway/static/root/assets/use-realtime-voice-B5IsKrRW.js +1 -0
  60. package/dist/gateway/static/root/assets/{use-workspace-tree-D27u-eoX.js → use-workspace-tree-7X2ydgS8.js} +1 -1
  61. package/dist/gateway/static/root/assets/{voice-settings-BiqJ0tlf.js → voice-settings-57pwZeKD.js} +1 -1
  62. package/dist/gateway/static/root/assets/workspace-api-Dd_UDfeo.js +2 -0
  63. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-NffP-UXC.js → workspace-file-preview-dialog-Clj9hMj5.js} +1 -1
  64. package/dist/gateway/static/root/assets/{workspace-preview-store-Do31QQH5.js → workspace-preview-store-imhtuEIP.js} +1 -1
  65. package/dist/gateway/static/root/index.html +27 -26
  66. package/dist/package.js +1 -1
  67. package/dist/packages/gateway-contract/src/follow-ups.js +97 -0
  68. package/dist/packages/gateway-contract/src/home.js +1 -0
  69. package/dist/packages/gateway-contract/src/index.js +4 -0
  70. package/dist/packages/gateway-contract/src/observation-starters.js +95 -0
  71. package/dist/packages/gateway-contract/src/observation.js +7 -0
  72. package/dist/packages/gateway-contract/src/task-research-result.js +3 -0
  73. package/dist/src/agent/agent-manager.d.ts +1 -1
  74. package/dist/src/agent/background-review/prompts.d.ts +1 -0
  75. package/dist/src/agent/background-review/prompts.js +7 -1
  76. package/dist/src/agent/background-review/run-background-review.js +85 -7
  77. package/dist/src/agent/coding/run-verification.d.ts +14 -7
  78. package/dist/src/agent/coding/run-verification.js +28 -6
  79. package/dist/src/agent/context/coordinator.js +1 -1
  80. package/dist/src/agent/context/deep-recall.js +1 -1
  81. package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -0
  82. package/dist/src/agent/embedded/execution-tool-policy.js +4 -2
  83. package/dist/src/agent/embedded/run-for-session.d.ts +2 -0
  84. package/dist/src/agent/embedded/run-for-session.js +9 -0
  85. package/dist/src/agent/embedded/run-turn.js +63 -14
  86. package/dist/src/agent/embedded/types.d.ts +2 -0
  87. package/dist/src/agent/inbound/turn-dispatcher.d.ts +1 -0
  88. package/dist/src/agent/inbound/turn-dispatcher.js +1 -0
  89. package/dist/src/agent/service/direct-turn-helpers.d.ts +1 -0
  90. package/dist/src/agent/service/direct-turn-helpers.js +17 -2
  91. package/dist/src/agent/service/process-direct-streaming.d.ts +1 -0
  92. package/dist/src/agent/service/process-direct-streaming.js +1 -0
  93. package/dist/src/agent/service.d.ts +1 -1
  94. package/dist/src/agent/tasks/task-judge-service.js +1 -0
  95. package/dist/src/agent/tool-manuals/browser.d.ts +1 -1
  96. package/dist/src/agent/tool-manuals/browser.js +3 -1
  97. package/dist/src/agent/tools/factory.d.ts +1 -1
  98. package/dist/src/agent/tools/factory.js +1 -1
  99. package/dist/src/agent/tools/personal-request-tool.js +36 -4
  100. package/dist/src/agent/tools/personal-task-tool.d.ts +7 -1
  101. package/dist/src/agent/tools/personal-task-tool.js +68 -3
  102. package/dist/src/agent/tools/session-search-tool.js +1 -1
  103. package/dist/src/agent/tools/task-collaboration-tool.d.ts +1 -1
  104. package/dist/src/agent/tools/task-collaboration-tool.js +54 -3
  105. package/dist/src/agent/tools/task-result-tool.js +31 -0
  106. package/dist/src/agent/tools/xopc-use-tool.js +50 -19
  107. package/dist/src/automations/capabilities/write.d.ts +2 -2
  108. package/dist/src/automations/domain/validation.d.ts +4 -4
  109. package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -1
  110. package/dist/src/browser/drivers/browser-driver.d.ts +1 -0
  111. package/dist/src/browser/drivers/create-driver.js +2 -11
  112. package/dist/src/browser/drivers/playwright-driver.d.ts +5 -2
  113. package/dist/src/browser/drivers/playwright-driver.js +83 -38
  114. package/dist/src/browser/runtime/browser-runtime.d.ts +5 -0
  115. package/dist/src/browser/runtime/browser-runtime.js +71 -9
  116. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  117. package/dist/src/computer/diagnostics.d.ts +4 -4
  118. package/dist/src/computer/errors.d.ts +4 -4
  119. package/dist/src/computer/evaluation.d.ts +3 -3
  120. package/dist/src/computer/flows.d.ts +1 -1
  121. package/dist/src/computer/runtime.d.ts +3 -3
  122. package/dist/src/config/schema.d.ts +6 -2
  123. package/dist/src/config/schema.js +3 -0
  124. package/dist/src/connectors/connected-source-understanding.js +11 -3
  125. package/dist/src/connectors/learning-coordinator.js +45 -11
  126. package/dist/src/discussions/recording.js +13 -6
  127. package/dist/src/endpoint-tools/device-host.d.ts +2 -2
  128. package/dist/src/gateway/hono/lib/config-payload.d.ts +4 -0
  129. package/dist/src/gateway/hono/routes/home.js +52 -1
  130. package/dist/src/gateway/hono/routes/projects.js +1 -1
  131. package/dist/src/gateway/hono/routes/session-command-handler.js +15 -1
  132. package/dist/src/gateway/hono/routes/user-model.js +1 -1
  133. package/dist/src/gateway/service/agent-runner.d.ts +2 -8
  134. package/dist/src/gateway/service/agent-runner.js +1 -0
  135. package/dist/src/gateway/service/config-coordinator.d.ts +5 -1
  136. package/dist/src/gateway/service/run-gateway-agent.d.ts +13 -8
  137. package/dist/src/gateway/service/run-gateway-agent.js +5 -2
  138. package/dist/src/gateway/service/session-input-coordinator.d.ts +4 -0
  139. package/dist/src/gateway/service/session-input-coordinator.js +6 -1
  140. package/dist/src/gateway/service.d.ts +1 -0
  141. package/dist/src/gateway/service.js +8 -1
  142. package/dist/src/home-intelligence/follow-ups.d.ts +36 -0
  143. package/dist/src/home-intelligence/follow-ups.js +496 -0
  144. package/dist/src/home-intelligence/host.d.ts +80 -4
  145. package/dist/src/home-intelligence/host.js +122 -2
  146. package/dist/src/home-intelligence/observation-starters.d.ts +3 -0
  147. package/dist/src/home-intelligence/observation-starters.js +27 -0
  148. package/dist/src/home-intelligence/observation.d.ts +1 -1
  149. package/dist/src/home-intelligence/observation.js +16 -4
  150. package/dist/src/local-apps/automation-proposals.d.ts +4 -4
  151. package/dist/src/local-apps/capabilities/projections.d.ts +38 -38
  152. package/dist/src/memory-learning/choice-observations.d.ts +9 -0
  153. package/dist/src/memory-learning/choice-observations.js +155 -0
  154. package/dist/src/memory-learning/evidence-repair.d.ts +12 -0
  155. package/dist/src/memory-learning/evidence-repair.js +31 -0
  156. package/dist/src/memory-learning/repository.d.ts +1 -0
  157. package/dist/src/memory-learning/repository.js +43 -5
  158. package/dist/src/memory-learning/source-learning.js +52 -7
  159. package/dist/src/memory-learning/task-receipts.js +19 -10
  160. package/dist/src/memory-learning/transcript-source.js +7 -0
  161. package/dist/src/memory-learning/work-candidate.d.ts +14 -0
  162. package/dist/src/memory-learning/work-candidate.js +17 -2
  163. package/dist/src/memory-learning/work-capture.d.ts +1 -0
  164. package/dist/src/memory-learning/work-capture.js +28 -10
  165. package/dist/src/memory-learning/work-review.d.ts +46 -0
  166. package/dist/src/memory-learning/work-review.js +209 -0
  167. package/dist/src/notes/agent-context.js +1 -1
  168. package/dist/src/personal-agent/communication.d.ts +1 -1
  169. package/dist/src/personal-agent/communication.js +1 -1
  170. package/dist/src/personal-agent/default-style.d.ts +1 -1
  171. package/dist/src/personal-agent/default-style.js +1 -1
  172. package/dist/src/personal-agent/proactivity/repository.d.ts +1 -1
  173. package/dist/src/personal-agent/prompts.js +4 -4
  174. package/dist/src/personal-agent/reply-composer.d.ts +1 -1
  175. package/dist/src/personal-agent/reply-composer.js +52 -34
  176. package/dist/src/personal-agent/reply-style.d.ts +2 -2
  177. package/dist/src/personal-agent/reply-style.js +3 -2
  178. package/dist/src/personal-agent/request-repository.d.ts +3 -0
  179. package/dist/src/personal-agent/request-service.d.ts +2 -0
  180. package/dist/src/personal-agent/request-service.js +8 -2
  181. package/dist/src/phone/contracts.d.ts +1 -1
  182. package/dist/src/projects/capabilities/write.js +1 -1
  183. package/dist/src/projects/index.js +1 -1
  184. package/dist/src/projects/project-service.js +1 -1
  185. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  186. package/dist/src/storage/sqlite/schema.js +7 -7
  187. package/dist/src/storage/sqlite/schema.sql +22 -0
  188. package/dist/src/storage/sqlite/upgrades/274_home_followups.sql +21 -0
  189. package/dist/src/tasks/capabilities/management.d.ts +3 -3
  190. package/dist/src/tasks/capabilities/relations.d.ts +3 -3
  191. package/dist/src/tasks/capabilities/write.d.ts +4 -4
  192. package/dist/src/tasks/capabilities/write.js +2 -0
  193. package/dist/src/tasks/home-query-service.js +4 -2
  194. package/dist/src/tasks/task-allocation-service.js +10 -2
  195. package/dist/src/tasks/task-application-service.d.ts +4 -0
  196. package/dist/src/tasks/task-application-service.js +6 -1
  197. package/dist/src/tasks/task-context-assembler.js +7 -2
  198. package/dist/src/tasks/task-contract-planner.js +3 -3
  199. package/dist/src/tasks/task-conversation-summary.d.ts +64 -0
  200. package/dist/src/tasks/task-conversation-summary.js +105 -0
  201. package/dist/src/tasks/task-delay-notice.d.ts +4 -0
  202. package/dist/src/tasks/task-delay-notice.js +113 -0
  203. package/dist/src/tasks/task-deletion-service.js +6 -1
  204. package/dist/src/tasks/task-handoff.d.ts +21 -0
  205. package/dist/src/tasks/task-handoff.js +77 -1
  206. package/dist/src/tasks/task-json-acceptance.d.ts +22 -0
  207. package/dist/src/tasks/task-json-acceptance.js +96 -0
  208. package/dist/src/tasks/task-main-update-decision-service.js +17 -21
  209. package/dist/src/tasks/task-main-update-delivery.js +34 -7
  210. package/dist/src/tasks/task-notification-preference.d.ts +16 -0
  211. package/dist/src/tasks/task-notification-preference.js +42 -0
  212. package/dist/src/tasks/task-origin-repository.d.ts +1 -0
  213. package/dist/src/tasks/task-origin-repository.js +3 -0
  214. package/dist/src/tasks/task-read-model-projector.js +1 -1
  215. package/dist/src/tasks/task-repository.js +1 -0
  216. package/dist/src/tasks/task-research-repair.d.ts +19 -1
  217. package/dist/src/tasks/task-research-repair.js +14 -4
  218. package/dist/src/tasks/task-research-result.d.ts +12 -0
  219. package/dist/src/tasks/task-research-result.js +5 -0
  220. package/dist/src/tasks/task-result-delivery-repository.d.ts +4 -1
  221. package/dist/src/tasks/task-result-delivery-repository.js +8 -5
  222. package/dist/src/tasks/task-result-delivery-service.js +9 -1
  223. package/dist/src/tasks/task-run-coordinator.js +45 -10
  224. package/dist/src/usage/cloud-wire.d.ts +1 -0
  225. package/dist/src/user-context/config.d.ts +8 -0
  226. package/dist/src/user-context/config.js +10 -0
  227. package/dist/src/user-model/capture/evidence-policy.d.ts +2 -0
  228. package/dist/src/user-model/capture/evidence-policy.js +8 -1
  229. package/dist/src/user-model/capture/executor.js +16 -4
  230. package/dist/src/user-model/capture/semantic.d.ts +4 -0
  231. package/dist/src/user-model/capture/semantic.js +3 -0
  232. package/dist/src/user-model/index.js +1 -1
  233. package/dist/src/user-model/observation-repository.d.ts +6 -0
  234. package/dist/src/user-model/observation-repository.js +12 -0
  235. package/dist/src/user-model/repository.js +10 -1
  236. package/dist/src/voice/realtime/agentEngine.js +29 -7
  237. package/dist/src/voice/realtime/pcmPlaybackEcho.d.ts +10 -0
  238. package/dist/src/voice/realtime/pcmPlaybackEcho.js +56 -0
  239. package/dist/src/voice/realtime/playback-echo.d.ts +3 -0
  240. package/dist/src/voice/realtime/playback-echo.js +35 -5
  241. package/dist/src/voice/realtime/runtime.js +6 -1
  242. package/dist/src/voice/realtime/turnPolicy.js +1 -1
  243. package/package.json +15 -9
  244. package/dist/gateway/static/root/assets/capabilities-DB713nRi.js +0 -1
  245. package/dist/gateway/static/root/assets/capabilities-page-D2hq4cgE.js +0 -2
  246. package/dist/gateway/static/root/assets/chat-page-BhPw56Vc.js +0 -71
  247. package/dist/gateway/static/root/assets/constants-DpkUgykJ.js +0 -1
  248. package/dist/gateway/static/root/assets/discussion-annotation-sync-fwPPMPv9.js +0 -1
  249. package/dist/gateway/static/root/assets/home-page-BPPe4JXB.js +0 -7
  250. package/dist/gateway/static/root/assets/index-D0_qnBzh.css +0 -1
  251. package/dist/gateway/static/root/assets/index-Hv71yddc.js +0 -11
  252. package/dist/gateway/static/root/assets/note-detail-panel-DLPwJGh0.js +0 -7
  253. package/dist/gateway/static/root/assets/note-image-lightbox-CqK_uJ6Y.js +0 -1
  254. package/dist/gateway/static/root/assets/notes-page-DpfN5bZZ.js +0 -8
  255. package/dist/gateway/static/root/assets/pcm-capture-worklet-uW_SEACy.js +0 -1
  256. package/dist/gateway/static/root/assets/personal-page-BBGjwkAC.js +0 -1
  257. package/dist/gateway/static/root/assets/personal-profile-settings-HMQY9lz9.js +0 -1
  258. package/dist/gateway/static/root/assets/product-preview-modal-DMHOKocl.js +0 -2
  259. package/dist/gateway/static/root/assets/project-detail-page-Dj_PuT7k.js +0 -7
  260. package/dist/gateway/static/root/assets/recording-upload-CyZSl2DJ.js +0 -1
  261. package/dist/gateway/static/root/assets/route-preload-gas8e1we.js +0 -2
  262. package/dist/gateway/static/root/assets/routine-panel-CXs4PjW0.js +0 -2
  263. package/dist/gateway/static/root/assets/session-manager-D2LaQymu.js +0 -25
  264. package/dist/gateway/static/root/assets/task-detail-page-_5TEldtl.js +0 -3
  265. package/dist/gateway/static/root/assets/use-realtime-voice-C7iWQuUv.js +0 -1
  266. package/dist/gateway/static/root/assets/workspace-api-LghfbP5g.js +0 -2
@@ -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{f as i,m as a,t as o,u as s}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as c,l,n as u,o as d}from"./locale-store-Dy1EByeG.js";import{t as f}from"./messages-BAnhwALN.js";import{a as p,i as m,n as h,o as g,r as _,s as v,t as y}from"./dist-CY7CS_D3.js";import{C as b,U as x,V as S,nt as C,t as w}from"./chat-page-U2a7d6wP.js";import{t as T}from"./arrow-left-D880xG-P.js";import{f as E,i as D,u as O}from"./automation-display-DaVDNZz8.js";import{t as k}from"./check-DUBLcKHA.js";import{t as A}from"./chevron-right-BweFrslA.js";import{n as j,r as M}from"./popover-select-CLsphyzA.js";import{t as N}from"./circle-BoO4YvTx.js";import{t as P}from"./ellipsis-0k4rZLoy.js";import{t as F}from"./external-link-DjqjBmc3.js";import{t as I}from"./folder-kanban-CpLlFI1o.js";import{t as L}from"./folder-open-CyzJ19I9.js";import{B as R,H as z,I as ee,P as B}from"./markdown-view-CNJaAdNN.js";import{t as te}from"./message-square-fVE7Ghj1.js";import{t as ne}from"./pause-DuPxgSxk.js";import{t as re}from"./play-kxZvpBg8.js";import{t as ie}from"./x-B_N4OPjy.js";import{t as V}from"./cn-0WouolD0.js";import{t as ae}from"./skeleton-DzdOeGYz.js";import{c as oe}from"./api-B4FJ51EC.js";import{mt as se,pt as ce}from"./session-manager-63NaXb1s.js";import{i as le}from"./vendor-swr-CdRzEUwF.js";import{C as H,D as ue,T as de,_ as fe,a as pe,f as me,i as he,l as ge,n as _e,r as ve,t as ye,u as be,x as xe}from"./workspace-preview-store-imhtuEIP.js";import{t as Se}from"./chat-agents-api-CjlzCSmC.js";import{t as U}from"./button-Cc4hUNTt.js";import{n as Ce}from"./right-workspace-store-HPw7Gw0n.js";import{s as we}from"./composer-payload-handoff-Dc43dgSg.js";import{t as Te}from"./page-header-store-Bm8oxpFR.js";import{t as Ee}from"./agent-avatar-display-loBdGw_i.js";import{t as De}from"./automation-api-DxBmyzp0.js";import{t as Oe}from"./sliding-tab-list-CmcrqRzN.js";import{t as ke}from"./confirm-dialog-DrA5mTQp.js";import{l as Ae,m as je,o as Me,r as Ne,t as Pe,u as Fe}from"./dist-ZrL34Ps4.js";import{a as W,c as Ie,d as Le,l as Re,u as ze}from"./automation-task-card-CJbIHRxN.js";import{t as Be}from"./date-picker-XnE3iFhG.js";import{t as Ve}from"./time-picker-C1PXAXZF.js";import{n as He}from"./date-formatters-DukWSVwc.js";import{t as Ue}from"./date-time-picker-VGKm0HVn.js";import{n as We,r as G,t as Ge}from"./task-result-evidence-CW_tN93T.js";import{t as Ke}from"./page-context-capture-button-B_Vdo2Ai.js";import{t as qe}from"./dependency-picker-XjPB8FJS.js";var K=e(t(),1),q=n(),J=r();function Je(e,t,n){let r=new URLSearchParams(e),i=r.getAll(`taskPanel`).filter(e=>e!==t&&e!==`${t}:closed`);r.delete(`taskPanel`);for(let e of i)r.append(`taskPanel`,e);return r.append(`taskPanel`,n?t:`${t}:closed`),r}function Ye(e){let t=(0,q.c)(32),n,r,i,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],o=t[4],s=t[5],c=t[6],l=t[7]):({panelId:r,title:l,defaultOpen:s,children:n,summaryClassName:o,chevron:c,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=s,t[6]=c,t[7]=l);let u=s!==void 0&&s,d=c!==void 0&&c,[f,p]=a(),m;if(t[8]!==u||t[9]!==r||t[10]!==f){let e=f.getAll(`taskPanel`);m=e.includes(r)||u&&!e.includes(`${r}:closed`),t[8]=u,t[9]=r,t[10]=f,t[11]=m}else m=t[11];let h=m,g=o??`cursor-pointer py-2 text-xs text-fg-muted hover:text-fg`,_=d&&`flex list-none items-center justify-between gap-3 [&::-webkit-details-marker]:hidden`,v;t[12]!==g||t[13]!==_?(v=V(g,_),t[12]=g,t[13]=_,t[14]=v):v=t[14];let y;t[15]!==h||t[16]!==r||t[17]!==p?(y=e=>{e.preventDefault(),p(e=>Je(e,r,!h),{preventScrollReset:!0})},t[15]=h,t[16]=r,t[17]=p,t[18]=y):y=t[18];let b;t[19]!==d||t[20]!==h||t[21]!==l?(b=d?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1`,children:l}),(0,J.jsx)(A,{"aria-hidden":!0,className:V(`size-4 shrink-0 text-fg-subtle motion-safe:transition-transform motion-safe:duration-150`,h&&`rotate-90`)})]}):l,t[19]=d,t[20]=h,t[21]=l,t[22]=b):b=t[22];let x;t[23]!==v||t[24]!==y||t[25]!==b?(x=(0,J.jsx)(`summary`,{className:v,onClick:y,children:b}),t[23]=v,t[24]=y,t[25]=b,t[26]=x):x=t[26];let S;return t[27]!==n||t[28]!==h||t[29]!==i||t[30]!==x?(S=(0,J.jsxs)(`details`,{...i,open:h,children:[x,n]}),t[27]=n,t[28]=h,t[29]=i,t[30]=x,t[31]=S):S=t[31],S}function Xe(e){let t=e;for(;t&&!/(auto|scroll)/.test(getComputedStyle(t).overflowY);)t=t.parentElement;return t}function Ze(e,t){let n=e?.closest(`.task-detail-scroll`),r=Array.from(n?.querySelectorAll(`[data-task-section]`)??[]).find(e=>e.dataset.taskSection===t);if(!r||!n)return;r instanceof HTMLDetailsElement&&(r.open=!0);let i=Xe(n),a=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;if(!i){r.scrollIntoView({block:`start`,behavior:a?`instant`:`smooth`});return}let o=(e?.parentElement?.getBoundingClientRect().height??0)+16,s=Math.max(0,Math.min(i.scrollHeight-i.clientHeight,i.scrollTop+r.getBoundingClientRect().top-i.getBoundingClientRect().top-i.clientTop-o));i.scrollTo({top:s,behavior:a?`instant`:`smooth`});let c=i;return{cancel:()=>c.scrollTo({top:c.scrollTop,behavior:`instant`}),isComplete:()=>Math.abs(c.scrollTop-s)<1}}function Qe(e){let t=(0,q.c)(28),{language:n,hasSchedule:r}=e,[i,o]=a(),s;t[0]===i?s=t[1]:(s=i.get(`taskSection`),t[0]=i,t[1]=s);let c=s,l=(0,K.useRef)(null),u=(0,K.useRef)(null),d=(0,K.useRef)(null),f=(0,K.useRef)(void 0),p=(0,K.useRef)(o),m=(0,K.useRef)(c),h,g;t[2]!==c||t[3]!==o?(h=()=>{p.current=o,m.current=c},g=[o,c],t[2]=c,t[3]=o,t[4]=h,t[5]=g):(h=t[4],g=t[5]),(0,K.useEffect)(h,g);let _=(0,K.useRef)(void 0),v=(0,K.useRef)(!1),y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{let e=d.current;d.current=null,_.current=void 0,!(!e||!v.current)&&(v.current=!1,p.current(t=>{let n=Je(t,e,!0);return n.set(`taskSection`,e),n},{preventScrollReset:!0}))},t[6]=y):y=t[6];let b=y,x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x=(e,t)=>{let n=t!==void 0&&t;clearTimeout(f.current),d.current=e,v.current=n,f.current=setTimeout(b,800),_.current=Ze(l.current,e)},t[7]=x):x=t[7];let S=x,[C,w]=(0,K.useState)(c??`results`),T;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],t[8]=T):T=t[8];let[E,D]=(0,K.useState)(T),O;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>{let e=l.current,t=e?.closest(`.task-detail-scroll`),n=e?.parentElement;if(!t||!n)return;let r=Array.from(t.querySelectorAll(`[data-task-section]`));D(r.map($e));let i=0,a=()=>{if(d.current)return;let e=Xe(t),i=n.getBoundingClientRect().bottom+24,a=r[0];for(let e of r)e.getBoundingClientRect().top<=i&&(a=e);if(e&&e.scrollHeight>e.clientHeight&&e.scrollTop+e.clientHeight>=e.scrollHeight-2&&(a=r.at(-1)),!a)return;let o=a.dataset.taskSection;w(o),m.current!==o&&(u.current=o,clearTimeout(f.current),f.current=setTimeout(()=>{p.current(e=>{let t=new URLSearchParams(e);return t.set(`taskSection`,o),t},{replace:!0,preventScrollReset:!0})},160))},o=e=>{if(!(!(e.target instanceof Element)||!e.target.contains(t))){if(d.current){clearTimeout(f.current),f.current=setTimeout(b,160);return}clearTimeout(f.current),i||=requestAnimationFrame(()=>{i=0,a()})}},s=n=>{!(n.target instanceof Node)||!t.contains(n.target)||e.contains(n.target)||n instanceof KeyboardEvent&&![`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `].includes(n.key)||(_.current?.cancel(),_.current=void 0,d.current=null,v.current=!1,clearTimeout(f.current))},c=e=>{e.target instanceof Element&&e.target.contains(t)&&d.current&&(!_.current||_.current.isComplete())&&(clearTimeout(f.current),b())},h=()=>{let e=n.getBoundingClientRect().height;for(let t of r)t.style.scrollMarginTop=`${e+16}px`};h();let g=typeof ResizeObserver>`u`?null:new ResizeObserver(h);return g?.observe(n),window.addEventListener(`resize`,h),document.addEventListener(`scroll`,o,!0),document.addEventListener(`scrollend`,c,!0),document.addEventListener(`wheel`,s,{capture:!0,passive:!0}),document.addEventListener(`touchstart`,s,{capture:!0,passive:!0}),document.addEventListener(`pointerdown`,s,{capture:!0,passive:!0}),document.addEventListener(`keydown`,s,!0),()=>{cancelAnimationFrame(i),g?.disconnect(),window.removeEventListener(`resize`,h),document.removeEventListener(`scroll`,o,!0),document.removeEventListener(`scrollend`,c,!0),document.removeEventListener(`wheel`,s,!0),document.removeEventListener(`touchstart`,s,!0),document.removeEventListener(`pointerdown`,s,!0),document.removeEventListener(`keydown`,s,!0)}},t[9]=O):O=t[9];let k;t[10]!==r||t[11]!==n?(k=[n,r,b],t[10]=r,t[11]=n,t[12]=k):k=t[12],(0,K.useEffect)(O,k);let A,j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>()=>{clearTimeout(f.current),_.current?.cancel()},A=[],t[13]=A,t[14]=j):(A=t[13],j=t[14]),(0,K.useEffect)(j,A);let M,N;t[15]===c?(M=t[16],N=t[17]):(M=()=>{!c||u.current===c||(u.current=c,w(c),S(c))},N=[c,S],t[15]=c,t[16]=M,t[17]=N),(0,K.useEffect)(M,N);let P;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{let e=l.current,t=e?.querySelector(`[aria-current="location"]`);if(!e||!t)return;let n=t.offsetLeft<e.scrollLeft?t.offsetLeft:t.offsetLeft+t.offsetWidth>e.scrollLeft+e.clientWidth?t.offsetLeft+t.offsetWidth-e.clientWidth:e.scrollLeft;n!==e.scrollLeft&&e.scrollTo({left:n,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`})},t[18]=P):P=t[18];let F;t[19]!==C||t[20]!==E?(F=[C,E],t[19]=C,t[20]=E,t[21]=F):F=t[21],(0,K.useEffect)(P,F);let I=n===`zh`?`任务详情分区`:`Task detail sections`,L;t[22]!==C||t[23]!==E?(L=E.map(e=>(0,J.jsx)(`button`,{type:`button`,"aria-current":C===e.id?`location`:void 0,"aria-pressed":C===e.id,"data-sliding-active":C===e.id,className:V(`relative z-10 min-h-9 min-w-max flex-1 touch-manipulation rounded-lg px-3 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,C===e.id?`text-fg`:`text-fg-muted hover:text-fg`),onClick:()=>{u.current=e.id,w(e.id),S(e.id,!0)},children:e.label},e.id)),t[22]=C,t[23]=E,t[24]=L):L=t[24];let R;return t[25]!==I||t[26]!==L?(R=(0,J.jsx)(Oe,{scrollFocusedItemIntoView:!1,as:`nav`,ref:l,"aria-label":I,className:`flex w-full gap-0.5 overflow-x-auto rounded-xl bg-surface-inset p-1`,indicatorClassName:`rounded-lg bg-surface-panel ring-1 ring-edge-subtle duration-300 [transition-timing-function:cubic-bezier(0.22,1,0.36,1)]`,children:L}),t[25]=I,t[26]=L,t[27]=R):R=t[27],R}function $e(e){return{id:e.dataset.taskSection,label:e.dataset.taskSectionLabel}}var et=`Default criteria were not expanded into concrete acceptance items; broad completion cannot certify item coverage.`;function tt(e){let t=(0,q.c)(64),{criterion:n,index:r,language:i,closed:a,pending:o,onReview:s,projectId:c,conversationId:l}=e,u=i===`zh`,d=(0,K.useId)(),f=n.status===`passed`,p=n.evidence.length>0||n.method||n.review||n.note,m=n.verificationStatus===`passed`?u?`通过`:`Passed`:n.verificationStatus===`failed`?u?`未通过`:`Failed`:u?`未核验`:`Unverified`,h=n.review?.status===`passed`?u?`已验收`:`Accepted`:n.review?.status===`failed`?u?`未通过`:`Failed`:u?`已撤销验收`:`Acceptance cleared`,g=!a&&!o&&`cursor-pointer`,_;t[0]===g?_=t[1]:(_=V(`relative grid size-11 shrink-0 place-items-center rounded-full`,g),t[0]=g,t[1]=_);let v=o||void 0,y;t[2]!==r||t[3]!==s||t[4]!==o?(y=e=>{o||s(r,e.target.checked?`passed`:`unverified`)},t[2]=r,t[3]=s,t[4]=o,t[5]=y):y=t[5];let b;t[6]!==f||t[7]!==a||t[8]!==v||t[9]!==y||t[10]!==d?(b=(0,J.jsx)(`input`,{type:`checkbox`,"aria-labelledby":d,className:`peer sr-only`,checked:f,disabled:a,"aria-disabled":v,onChange:y}),t[6]=f,t[7]=a,t[8]=v,t[9]=y,t[10]=d,t[11]=b):b=t[11];let x=f?`border-edge bg-surface-inset text-fg`:`border-fg-subtle/70`,S=!a&&!o&&`hover:bg-surface-hover`,C;t[12]!==x||t[13]!==S?(C=V(`grid size-5 place-items-center rounded-full border motion-safe:transition-colors motion-safe:duration-150 peer-focus-visible:ring-2 peer-focus-visible:ring-accent peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-surface-panel`,x,S),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w;t[15]===f?w=t[16]:(w=f?(0,J.jsx)(k,{className:`size-3.5`,strokeWidth:2.8}):null,t[15]=f,t[16]=w);let T;t[17]!==C||t[18]!==w?(T=(0,J.jsx)(`span`,{"aria-hidden":!0,className:C,children:w}),t[17]=C,t[18]=w,t[19]=T):T=t[19];let E;t[20]!==T||t[21]!==_||t[22]!==b?(E=(0,J.jsxs)(`label`,{className:_,children:[b,T]}),t[20]=T,t[21]=_,t[22]=b,t[23]=E):E=t[23];let D=`criterion:${r}:evidence`,O;t[24]!==n.text||t[25]!==d?(O=(0,J.jsx)(`span`,{id:d,className:`block whitespace-pre-wrap break-words text-sm leading-5 text-fg [overflow-wrap:anywhere]`,children:n.text}),t[24]=n.text,t[25]=d,t[26]=O):O=t[26];let A=u?`验收依据`:`Acceptance evidence`,j;t[27]===A?j=t[28]:(j=(0,J.jsx)(`p`,{className:`font-medium text-fg`,children:A}),t[27]=A,t[28]=j);let M;t[29]!==n.method||t[30]!==m||t[31]!==u?(M=n.method?(0,J.jsxs)(`p`,{children:[u?`自动核验`:`Automatic verification`,` · `,m,n.method===`model_reviewed`?u?` · 模型审阅`:` · Model review`:``]}):null,t[29]=n.method,t[30]=m,t[31]=u,t[32]=M):M=t[32];let N;t[33]!==n.review||t[34]!==i||t[35]!==h||t[36]!==u?(N=n.review?(0,J.jsxs)(`p`,{children:[u?`人工验收`:`User review`,` · `,h,` · `,He(n.review.reviewedAt,i)]}):null,t[33]=n.review,t[34]=i,t[35]=h,t[36]=u,t[37]=N):N=t[37];let P;t[38]!==n.note||t[39]!==r||t[40]!==i?(P=n.note&&n.note!==et?(0,J.jsx)(G,{content:n.note,contentKey:`criterion:${r}:note`,language:i,markdown:!1}):null,t[38]=n.note,t[39]=r,t[40]=i,t[41]=P):P=t[41];let F;t[42]!==l||t[43]!==n.evidence||t[44]!==i||t[45]!==c?(F=(0,J.jsx)(Ge,{evidence:n.evidence,projectId:c,conversationId:l,language:i}),t[42]=l,t[43]=n.evidence,t[44]=i,t[45]=c,t[46]=F):F=t[46];let I;t[47]!==p||t[48]!==u?(I=p?null:(0,J.jsx)(`p`,{children:u?`暂无验收依据`:`No evidence yet`}),t[47]=p,t[48]=u,t[49]=I):I=t[49];let L;t[50]!==j||t[51]!==M||t[52]!==N||t[53]!==P||t[54]!==F||t[55]!==I?(L=(0,J.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg bg-surface-inset px-3 py-2.5 text-xs leading-5 text-fg-muted`,children:[j,M,N,P,F,I]}),t[50]=j,t[51]=M,t[52]=N,t[53]=P,t[54]=F,t[55]=I,t[56]=L):L=t[56];let R;t[57]!==D||t[58]!==O||t[59]!==L?(R=(0,J.jsx)(Ye,{panelId:D,chevron:!0,className:`min-w-0 flex-1`,summaryClassName:`-ms-1 min-h-11 cursor-pointer rounded-lg py-3 pe-2 ps-1 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,title:O,children:L}),t[57]=D,t[58]=O,t[59]=L,t[60]=R):R=t[60];let z;return t[61]!==E||t[62]!==R?(z=(0,J.jsxs)(`li`,{className:`relative flex min-w-0 items-start px-2 before:absolute before:end-0 before:start-13 before:top-0 before:border-t before:border-edge-subtle first:before:hidden sm:px-3`,children:[E,R]}),t[61]=E,t[62]=R,t[63]=z):z=t[63],z}function nt(e){let t=(0,q.c)(39),{criteria:n,language:r,closed:i,pending:a,blockedReason:o,error:s,onReview:c,projectId:l,conversationId:u}=e,d=r===`zh`,f;t[0]===n?f=t[1]:(f=n.some(it),t[0]=n,t[1]=f);let p=f,m;t[2]!==p||t[3]!==d?(m=p?(0,J.jsx)(Ye,{panelId:`acceptance:diagnostic`,title:d?`自动核验未完成:验收标准过于宽泛`:`Automatic verification incomplete: criteria are too broad`,className:`mx-4 mb-2 text-xs leading-5 text-fg-muted`,children:(0,J.jsx)(`p`,{className:`mt-2 break-words`,children:et})}):null,t[2]=p,t[3]=d,t[4]=m):m=t[4];let h=a||void 0,g;if(t[5]!==i||t[6]!==u||t[7]!==n||t[8]!==r||t[9]!==c||t[10]!==a||t[11]!==l){let e;t[13]!==i||t[14]!==u||t[15]!==r||t[16]!==c||t[17]!==a||t[18]!==l?(e=(e,t)=>(0,J.jsx)(tt,{criterion:e,index:t,language:r,closed:i,pending:a,onReview:c,projectId:l,conversationId:u},`${t}:${e.text}`),t[13]=i,t[14]=u,t[15]=r,t[16]=c,t[17]=a,t[18]=l,t[19]=e):e=t[19],g=n.map(e),t[5]=i,t[6]=u,t[7]=n,t[8]=r,t[9]=c,t[10]=a,t[11]=l,t[12]=g}else g=t[12];let _;t[20]!==h||t[21]!==g?(_=(0,J.jsx)(`ul`,{"aria-busy":h,className:`border-t border-edge-subtle`,children:g}),t[20]=h,t[21]=g,t[22]=_):_=t[22];let v;t[23]!==n.length||t[24]!==d?(v=n.length===0?(0,J.jsx)(`p`,{className:`px-4 py-4 text-sm text-fg-muted`,children:d?`尚未定义验收标准`:`No acceptance criteria defined`}):null,t[23]=n.length,t[24]=d,t[25]=v):v=t[25];let y;t[26]===s?y=t[27]:(y=s?(0,J.jsx)(`p`,{role:`alert`,className:`mx-4 my-2 text-sm text-danger`,children:s}):null,t[26]=s,t[27]=y);let b;t[28]!==o||t[29]!==i||t[30]!==n||t[31]!==d?(b=!i&&n.length>0&&(o||n.some(rt))?(0,J.jsx)(`p`,{className:`border-t border-edge-subtle px-4 py-2.5 text-xs text-fg-muted`,children:o??(d?`勾选全部验收项后,任务自动完成。`:`Checking all criteria completes the task.`)}):null,t[28]=o,t[29]=i,t[30]=n,t[31]=d,t[32]=b):b=t[32];let x;return t[33]!==m||t[34]!==_||t[35]!==v||t[36]!==y||t[37]!==b?(x=(0,J.jsxs)(J.Fragment,{children:[m,_,v,y,b]}),t[33]=m,t[34]=_,t[35]=v,t[36]=y,t[37]=b,t[38]=x):x=t[38],x}function rt(e){return e.status!==`passed`}function it(e){return e.note===et}function at(e){let t=(0,q.c)(22),{detail:n,language:r}=e,i=r===`zh`,a;if(t[0]!==n||t[1]!==r||t[2]!==i){let e=_e(n),s;if(t[4]!==n.runs||t[5]!==n.task){let e;t[7]===n.task?e=t[8]:(e=e=>e.contractVersion===n.task.latestContractVersion,t[7]=n.task,t[8]=e),s=new Set(n.runs.filter(e).map(dt)),t[4]=n.runs,t[5]=n.task,t[6]=s}else s=t[6];let c=s,l;if(t[9]!==n.context||t[10]!==n.receipts||t[11]!==c){l=n.context.filter(ut).map(lt);let e=new Set(l.map(ct).filter(Boolean)),r;t[13]===c?r=t[14]:(r=e=>c.has(e.runId),t[13]=c,t[14]=r);for(let t of n.receipts.filter(r))for(let n of t.evidence.filter(st))n.uri&&e.has(n.uri)||(n.uri&&e.add(n.uri),l.push(n));t[9]=n.context,t[10]=n.receipts,t[11]=c,t[12]=l}else l=t[12];let u=e?.summary.trim(),d=u&&u.length<=160&&!u.includes(`
2
+ `)&&!/\b(?:Claim|Criterion|Research claim)\b|c-ac\d|Default criteria were not/i.test(u)?u:void 0,f=i?`交付结果`:`Deliverables`,p;t[15]===f?p=t[16]:(p=(0,J.jsx)(`h2`,{id:`task-results-heading`,className:`text-sm font-semibold text-fg`,children:f}),t[15]=f,t[16]=p);let m;t[17]!==n||t[18]!==l||t[19]!==r||t[20]!==i?(m=l.length>0?(0,J.jsx)(Ge,{evidence:l,language:r,projectId:n.task.projectId,conversationId:n.conversation.activeConversationId??void 0,compact:!0}):(0,J.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:i?`尚无可查看的交付物`:`No deliverables available yet`}),t[17]=n,t[18]=l,t[19]=r,t[20]=i,t[21]=m):m=t[21],a=(0,J.jsxs)(`section`,{"aria-label":i?`交付结果`:`Deliverables`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[p,d?(0,J.jsx)(`p`,{className:`mt-2 break-words text-sm leading-6 text-fg-muted [overflow-wrap:anywhere]`,children:d}):null,e&&e.completionVerdict!==`achieved`?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:i?`本次执行尚未报告目标全部达成。`:`This run has not reported the full goal achieved.`}):null,m,e?null:(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:i?`尚无本版任务的执行结果`:`No run result for this task version`}),e&&(e.needsUser||e.remainingWork.length>0||e.nextAction||e.failure)?(0,J.jsxs)(`div`,{className:`mt-4 space-y-2 border-t border-edge-subtle pt-3`,"aria-label":i?`执行待办`:`Run follow-up`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:e.needsUser?i?`需要你决定`:`Your decision needed`:i?`待处理事项`:`Remaining work`}),e.remainingWork.length>0?(0,J.jsx)(`ul`,{className:`space-y-2 text-sm leading-6 text-fg`,children:[...new Set(e.remainingWork)].map(ot)}):null,e.nextAction?(0,J.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-6 text-fg [overflow-wrap:anywhere]`,children:e.nextAction}):null,e.failure?(0,J.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-6 text-danger [overflow-wrap:anywhere]`,children:e.failure.recoveryAction}):null,e.needsUser?(0,J.jsx)(o,{className:`inline-flex min-h-9 items-center rounded-sm text-xs font-medium text-accent-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/40`,to:B(n.task.id),children:i?`查看并决定`:`Review and decide`}):null]}):null]}),t[0]=n,t[1]=r,t[2]=i,t[3]=a}else a=t[3];return a}function ot(e){return(0,J.jsx)(`li`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e},e)}function st(e){return e.kind===`artifact`}function ct(e){return e.uri}function lt(e){return{kind:[`file`,`url`].includes(e.targetKind)?`artifact`:`source`,title:e.title??e.targetId,summary:``,...[`file`,`url`].includes(e.targetKind)?{uri:e.targetId}:{},provenance:`user`,strength:`observed`,observedAt:0}}function ut(e){return e.role===`deliverable`}function dt(e){return e.id}function ft(e){let t=(0,q.c)(13),{detail:n,language:r}=e,i=r===`zh`,a=we(r),o;t[0]===n?o=t[1]:(o=_e(n),t[0]=n,t[1]=o);let s=o,c;t[2]===s?.runId?c=t[3]:(c=e=>e.runId!==s?.runId,t[2]=s?.runId,t[3]=c);let l=n.receipts.filter(c),[u,d]=(0,K.useState)(`idle`),f;t[4]===s?f=t[5]:(f=async function(e){if(s){d(`pending`);try{await H(s.runId,e),d(`saved`)}catch{d(`failed`)}}},t[4]=s,t[5]=f);let p=f,m;t[6]!==n||t[7]!==r?(m=(0,J.jsx)(x,{detail:n,language:r}),t[6]=n,t[7]=r,t[8]=m):m=t[8];let h=s?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:a.latestResult}),(0,J.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[a.receiptStatuses[s.status],` · `,a.verificationStatuses[s.verification.status]]})]}),(0,J.jsx)(G,{content:s.summary,contentKey:`${n.task.id}:result:${s.runId}`,language:r}),s.evidence.length>0?(0,J.jsxs)(`details`,{children:[(0,J.jsxs)(`summary`,{className:`cursor-pointer py-2 text-xs text-fg-muted`,children:[i?`验证依据与执行产物`:`Evidence and artifacts`,` · `,s.evidence.length]}),(0,J.jsx)(Ge,{evidence:s.evidence,projectId:n.task.projectId,conversationId:n.conversation.activeConversationId??void 0,language:r})]}):null,(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-edge-subtle pt-3`,children:[(0,J.jsx)(U,{variant:`ghost`,className:`min-h-9 px-2 text-xs`,disabled:u===`pending`,onClick:()=>void p(`helpful`),children:a.doneWell}),(0,J.jsx)(U,{variant:`ghost`,className:`min-h-9 px-2 text-xs`,disabled:u===`pending`,onClick:()=>void p(`not_helpful`),children:a.needsFix}),u===`saved`?(0,J.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:i?`反馈已记录`:`Feedback saved`}):null,u===`failed`?(0,J.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:a.actionFailed}):null]})]}):null,g=l.length>0?(0,J.jsxs)(`details`,{className:`border-t border-edge-subtle pt-3`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer py-2 text-xs text-fg-muted`,children:a.executionHistory.replace(`{{count}}`,String(l.length))}),(0,J.jsx)(`div`,{className:`mt-3 space-y-4`,children:l.map(e=>(0,J.jsxs)(`article`,{className:`space-y-2 rounded-lg bg-surface-hover p-3`,children:[(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.receiptStatuses[e.status]}),(0,J.jsx)(G,{content:e.summary,contentKey:`${n.task.id}:result:${e.runId}`,language:r})]},e.runId))})]}):null,_;return t[9]!==m||t[10]!==h||t[11]!==g?(_=(0,J.jsxs)(`div`,{className:`space-y-4`,children:[m,h,g]}),t[9]=m,t[10]=h,t[11]=g,t[12]=_):_=t[12],_}function pt(e){let t=(0,q.c)(33),{changes:n,language:r}=e,i=r===`zh`,a;t[0]===i?a=t[1]:(a=i?{backlog:`待办池`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已关闭`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Closed`},t[0]=i,t[1]=a);let o=a,s;t[2]===i?s=t[3]:(s=i?{board:`看板`,mobile:`移动端`,api:`手动操作`,runtime:`自动流转`,undo:`撤销`}:{board:`Board`,mobile:`Mobile`,api:`Manual update`,runtime:`Automatic`,undo:`Undo`},t[2]=i,t[3]=s);let c=s,l;t[4]===i?l=t[5]:(l=i?{done:`完成`,cancelled:`取消`,duplicate:`重复`,wont_do:`不做`}:{done:`Done`,cancelled:`Cancelled`,duplicate:`Duplicate`,wont_do:`Won’t do`},t[4]=i,t[5]=l);let u=l,d;t[6]===i?d=t[7]:(d=i?{user:`用户`,agent:`Agent`,system:`系统`,integration:`外部服务`}:{user:`User`,agent:`Agent`,system:`System`,integration:`Integration`},t[6]=i,t[7]=d);let f=d,p=i?`变更记录`:`Change log`,m;t[8]!==n.length||t[9]!==p?(m=(0,J.jsxs)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:[p,` (`,n.length,`)`]}),t[8]=n.length,t[9]=p,t[10]=m):m=t[10];let h;if(t[11]!==f||t[12]!==n||t[13]!==r||t[14]!==o||t[15]!==u||t[16]!==c){let e;t[18]!==f||t[19]!==r||t[20]!==o||t[21]!==u||t[22]!==c?(e=e=>(0,J.jsxs)(`li`,{className:`text-sm text-fg`,children:[(0,J.jsxs)(`div`,{children:[o[e.fromPhase],e.fromResolution?` · ${u[e.fromResolution]}`:``,` → `,o[e.toPhase],e.toResolution?` · ${u[e.toResolution]}`:``]}),(0,J.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[f[e.actor.kind],e.actor.id?` (${e.actor.id})`:``,` · `,c[e.source],` · `,(0,J.jsx)(`time`,{dateTime:new Date(e.createdAt).toISOString(),children:He(e.createdAt,r)})]})]},e.id),t[18]=f,t[19]=r,t[20]=o,t[21]=u,t[22]=c,t[23]=e):e=t[23],h=[...n].reverse().map(e),t[11]=f,t[12]=n,t[13]=r,t[14]=o,t[15]=u,t[16]=c,t[17]=h}else h=t[17];let g;t[24]===h?g=t[25]:(g=(0,J.jsx)(`ol`,{className:`mt-3 max-h-80 space-y-3 overflow-y-auto`,children:h}),t[24]=h,t[25]=g);let _;t[26]!==n.length||t[27]!==i?(_=n.length?null:(0,J.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:i?`暂无阶段变更记录`:`No phase changes yet`}),t[26]=n.length,t[27]=i,t[28]=_):_=t[28];let v;return t[29]!==m||t[30]!==g||t[31]!==_?(v=(0,J.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[m,g,_]}),t[29]=m,t[30]=g,t[31]=_,t[32]=v):v=t[32],v}function mt({schedules:e,language:t,onEdit:n,onUpdated:r}){let i=t===`zh`,a=f(t),[s,c]=(0,K.useState)(null),l=(0,K.useRef)(!1),[u,d]=(0,K.useState)(null),p=e=>new Date(e).toLocaleString(i?`zh-CN`:`en-US`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,timeZoneName:`short`});async function m(e){if(!l.current){l.current=!0,c(e.id),d(null);try{r((await De.update(e.id,{enabled:!1,expectedRevision:e.updatedAtMs})).automation)}catch(e){d(e instanceof Error?e.message:a.automations.feedback.actionFailed)}finally{l.current=!1,c(null)}}}return(0,J.jsxs)(`section`,{"aria-label":i?`执行时间`:`Execution schedule`,className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i?`执行时间`:`Execution schedule`}),(0,J.jsx)(`div`,{className:`mt-3 space-y-4`,children:e.map(e=>{let r=e.trigger.kind===`schedule`?e.trigger.schedule:null,c=O(e),l=!e.management||e.management.editable.includes(`trigger`),u=!e.management||e.management.editable.includes(`enabled`);return(0,J.jsxs)(`article`,{className:`space-y-2 text-sm text-fg`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,J.jsx)(`span`,{className:`text-xs text-fg-muted`,children:c?i?`已执行`:`Completed`:e.enabled?i?`已启用`:`Enabled`:i?`已取消定时执行`:`Scheduling disabled`})]}),(0,J.jsx)(`p`,{children:r?.kind===`once`?`${i?`单次执行:`:`Run once: `}${p(Date.parse(r.at))}`:D(e.trigger,a.automations,a.cron,t)}),r?.kind===`cron`?(0,J.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[i?`执行时区:`:`Schedule timezone: `,r.tz||(i?`服务所在电脑时区`:`Server timezone`)]}):null,(0,J.jsxs)(`p`,{className:`text-fg-muted`,children:[i?`下次执行:`:`Next run: `,c?i?`已执行,无后续计划`:`Completed; no upcoming run`:e.enabled?e.state.nextRunAtMs===void 0?i?`暂无后续执行`:`No upcoming run`:p(e.state.nextRunAtMs):i?`已取消,不再自动执行`:`Disabled; no automatic runs`]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l?(0,J.jsx)(U,{variant:`secondary`,disabled:s!==null,onClick:()=>n(e),children:i?`修改时间`:`Edit schedule`}):null,e.enabled&&u?(0,J.jsx)(U,{variant:`ghost`,disabled:s!==null,onClick:()=>void m(e),children:s===e.id?i?`正在取消…`:`Cancelling…`:i?`取消定时执行`:`Cancel schedule`}):null,(0,J.jsx)(U,{asChild:!0,variant:`ghost`,children:(0,J.jsx)(o,{to:`/automations?automation=${encodeURIComponent(e.id)}`,children:i?`查看自动化`:`View automation`})})]})]},e.id)})}),u?(0,J.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:u}):null]})}var ht=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-2 focus-visible:outline-accent`;function gt({taskId:e,taskTitle:t,projectId:n,executorAgentId:r,language:i,onClose:a,onCreated:s,automation:c}){let l=i===`zh`,u=f(i).automations,[d,b]=(0,K.useState)(()=>c?ze(c):{...Le,name:t,projectId:n??``,actionMode:`task_command`,taskId:e,agentId:r??``,triggerMode:`once`,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}),[x,S]=(0,K.useState)(null),[C,w]=(0,K.useState)(!1),T=(0,K.useRef)(!1),[E,D]=(0,K.useState)(null),O=e=>b(t=>({...t,...e}));async function k(e){if(e.preventDefault(),!(T.current||x)&&(D(null),!(!d.name.trim()||!c&&!r))){if(d.triggerMode===`once`&&(!Number.isFinite(new Date(d.onceAt).getTime())||new Date(d.onceAt).getTime()<=Date.now())){D(u.experience.futureTime);return}T.current=!0,w(!0);try{let e=c?Ie(c,d).trigger:Re(d).trigger,{automation:t}=c?await De.update(c.id,{trigger:e,...c.management?{}:{name:d.name.trim(),delivery:{...c.delivery,notificationPolicy:d.notificationPolicy}},...!c.management||c.management.editable.includes(`enabled`)?{enabled:!0}:{},expectedRevision:c.updatedAtMs}):await De.create({...Re(d),enabled:!0});S(t),s(t)}catch(e){D(e instanceof Error?e.message:u.feedback.actionFailed)}finally{T.current=!1,w(!1)}}}return(0,J.jsx)(y,{open:!0,onOpenChange:e=>{!e&&!T.current&&a()},children:(0,J.jsxs)(g,{children:[(0,J.jsx)(p,{className:`fixed inset-0 z-[110] bg-black/45`}),(0,J.jsxs)(_,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[111] flex h-[min(38rem,calc(100dvh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,J.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge-subtle px-5 py-4`,children:[(0,J.jsx)(v,{className:`text-base font-semibold text-fg`,children:c?l?`修改执行时间`:`Edit execution schedule`:l?`设置执行时间`:`Set execution time`}),(0,J.jsx)(h,{asChild:!0,children:(0,J.jsx)(U,{variant:`ghost`,className:`size-9 p-0`,disabled:C,"aria-label":l?`关闭`:`Close`,children:(0,J.jsx)(ie,{className:`size-4`})})})]}),(0,J.jsx)(m,{className:`sr-only`,children:l?`为当前任务创建定时或周期自动化。`:`Create a scheduled or recurring automation for this task.`}),x?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-5`,children:[(0,J.jsx)(`p`,{role:`status`,className:`text-sm font-medium text-fg`,children:c?l?`执行时间已更新`:`Schedule updated`:l?`执行时间已设置`:`Schedule created`}),(0,J.jsx)(`p`,{className:`break-words text-sm text-fg-muted`,children:x.name}),(0,J.jsx)(U,{asChild:!0,variant:`primary`,children:(0,J.jsx)(o,{to:`/automations?automation=${encodeURIComponent(x.id)}`,children:l?`查看自动化`:`View automation`})})]}),(0,J.jsx)(`footer`,{className:`shrink-0 border-t border-edge-subtle p-4`,children:(0,J.jsx)(U,{onClick:a,children:l?`完成`:`Done`})})]}):(0,J.jsxs)(`form`,{onSubmit:e=>void k(e),className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-5`,children:[(0,J.jsxs)(`p`,{className:`break-words text-sm text-fg-muted`,children:[l?`执行任务:`:`Task: `,t]}),(0,J.jsxs)(`fieldset`,{disabled:C,className:`space-y-4`,children:[(0,J.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[u.form.name,(0,J.jsx)(`input`,{required:!0,readOnly:!!c?.management,className:ht,value:d.name,onChange:e=>O({name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[u.form.trigger,(0,J.jsxs)(j,{value:d.triggerMode,onChange:e=>O({triggerMode:e.target.value}),children:[c?.trigger.kind===`schedule`&&c.trigger.schedule.kind===`interval`?(0,J.jsx)(M,{value:`interval`,children:l?`固定间隔`:`Fixed interval`}):null,c?.trigger.kind===`schedule`&&c.trigger.schedule.kind===`cron`?(0,J.jsx)(M,{value:`cron`,children:l?`自定义规则`:`Custom schedule`}):null,(0,J.jsx)(M,{value:`once`,children:u.trigger.once}),(0,J.jsx)(M,{value:`daily`,children:u.trigger.daily}),(0,J.jsx)(M,{value:`weekly`,children:u.trigger.weekly})]})]}),d.triggerMode===`once`?(0,J.jsx)(Ue,{label:u.form.onceAt,disabled:C,value:d.onceAt,defaultTime:d.time,onChange:e=>O({onceAt:e})}):[`daily`,`weekly`].includes(d.triggerMode)?(0,J.jsxs)(`div`,{className:`grid gap-2 text-sm text-fg`,children:[(0,J.jsx)(`span`,{children:u.form.time}),(0,J.jsx)(Ve,{disabled:C,value:d.time,onChange:e=>O({time:e}),ariaLabel:u.form.time})]}):null,d.triggerMode===`weekly`?(0,J.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[u.form.day,(0,J.jsx)(j,{value:d.weekday,onChange:e=>O({weekday:e.target.value}),children:[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`].map((e,t)=>(0,J.jsx)(M,{value:String(t),children:u.weekdays[e]},e))})]}):null,d.triggerMode===`cron`?(0,J.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[l?`定时规则`:`Cron expression`,(0,J.jsx)(`input`,{required:!0,className:ht,value:d.cronExpr,onChange:e=>O({cronExpr:e.target.value})})]}):null,d.triggerMode===`interval`?(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,J.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[l?`执行间隔`:`Interval`,(0,J.jsx)(`input`,{required:!0,type:`number`,min:`1`,className:ht,value:d.intervalValue,onChange:e=>O({intervalValue:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[l?`单位`:`Unit`,(0,J.jsxs)(j,{value:d.intervalUnit,onChange:e=>O({intervalUnit:e.target.value}),children:[(0,J.jsx)(M,{value:`minute`,children:l?`分钟`:`Minutes`}),(0,J.jsx)(M,{value:`hour`,children:l?`小时`:`Hours`}),(0,J.jsx)(M,{value:`day`,children:l?`天`:`Days`}),(0,J.jsx)(M,{value:`week`,children:l?`周`:`Weeks`})]})]})]}):null,(0,J.jsx)(W,{form:d,onChange:O,language:i}),(0,J.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[u.draft.notifications,(0,J.jsxs)(j,{disabled:!!c?.management,value:d.notificationPolicy,onChange:e=>O({notificationPolicy:e.target.value}),children:[(0,J.jsx)(M,{value:`attention`,children:u.draft.notifyAttention}),(0,J.jsx)(M,{value:`all`,children:u.draft.notifyAll}),(0,J.jsx)(M,{value:`none`,children:u.draft.notifyNone})]})]})]}),!c&&!r?(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:l?`请先为任务指定执行 Agent。`:`Assign an executor agent to the task first.`}):null,E?(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:E}):null]}),(0,J.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,J.jsx)(U,{type:`button`,variant:`ghost`,disabled:C,onClick:a,children:l?`取消`:`Cancel`}),(0,J.jsx)(U,{type:`submit`,variant:`primary`,disabled:C||!c&&!r||!d.name.trim()||d.triggerMode===`once`&&!d.onceAt,children:C?l?`正在保存…`:`Saving…`:c?c.enabled?l?`保存修改`:`Save changes`:l?`保存并启用`:`Save and enable`:l?`创建自动化`:`Create automation`})]})]})]})]})})}function _t(e){let t=(0,q.c)(36),{detail:n,language:r,onUpdated:i}=e,a=r===`zh`,s;t[0]===n.waits?s=t[1]:(s=n.waits.find(xt),t[0]=n.waits,t[1]=s);let c=s,l,u,d,f,p,m,h;if(t[2]!==n||t[3]!==r||t[4]!==i||t[5]!==c||t[6]!==a){l=n.allowedCommands.includes(`resolve_wait`)&&!c?n.waits.filter(bt):[];let e=l.length>0||n.attention.some(yt),s;t[14]===n?s=t[15]:(s=_e(n),t[14]=n,t[15]=s);let g=s,_=n.runs.some(vt);d=c?.reason??n.waits[0]?.reason??(n.task.phase===`closed`?a?`任务已关闭,可查看交付物与执行结果。`:`The task is closed. Review its deliverables and results.`:n.task.phase===`review`?a?`请检查交付物并勾选通过的验收项。`:`Review the deliverables and check the criteria that pass.`:_?a?`Agent 正在执行任务,无需你操作。`:`The agent is working. No action is needed from you.`:g?.summary??(a?`任务尚未开始,可开始执行或设置执行时间。`:`Start the task or set an execution time.`)),u=n.attention.length>0?(0,J.jsx)(`ul`,{className:`mt-3 space-y-3`,children:n.attention.map((e,t)=>{let i=l.some(t=>e.kind===`input_required`&&t.kind===`user_input`||e.kind===`approval_required`&&t.kind===`approval`);return(0,J.jsxs)(`li`,{className:`text-sm leading-6 text-fg-muted`,children:[(0,J.jsx)(G,{content:e.summary,contentKey:`${n.task.id}:attention:${e.kind}:${t}`,language:r,markdown:!1,previewHeight:72}),!i&&(e.kind===`input_required`||e.kind===`approval_required`)?(0,J.jsx)(o,{className:`mt-2 inline-flex min-h-11 items-center rounded-lg bg-accent-soft px-3 font-medium text-accent-fg`,to:B(n.task.id),children:a?e.kind===`approval_required`?`查看并决定`:`补充信息`:e.kind===`approval_required`?`Review decision`:`Provide information`}):null]},`${e.kind}-${t}`)})}):null,f=a?`当前需要处理`:`Current action`,p=`rounded-xl border border-edge bg-surface-panel p-4`;let v=e?a?`需要你处理`:`Your action needed`:a?`当前进展`:`Current progress`,y=l.length>1?` · ${l.length}`:``;t[16]!==v||t[17]!==y?(m=(0,J.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[v,y]}),t[16]=v,t[17]=y,t[18]=m):m=t[18];let b;t[19]!==n||t[20]!==i||t[21]!==a?(b=e=>(0,J.jsx)(We,{wait:e,detail:n,zh:a,onUpdated:i},e.id),t[19]=n,t[20]=i,t[21]=a,t[22]=b):b=t[22],h=l.map(b),t[2]=n,t[3]=r,t[4]=i,t[5]=c,t[6]=a,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h}else l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13];let g;t[23]!==l.length||t[24]!==u||t[25]!==n.task||t[26]!==r||t[27]!==d||t[28]!==a?(g=l.length>0?u?(0,J.jsxs)(`details`,{className:`mt-3`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:a?`等待详情`:`Waiting details`}),u]}):null:u??(0,J.jsx)(G,{content:d,contentKey:`${n.task.id}:current-progress`,language:r,previewHeight:72,className:`mt-2 text-sm leading-6 text-fg-muted`,children:(0,J.jsx)(S,{content:se(d),compact:!0})}),t[23]=l.length,t[24]=u,t[25]=n.task,t[26]=r,t[27]=d,t[28]=a,t[29]=g):g=t[29];let _;return t[30]!==f||t[31]!==p||t[32]!==m||t[33]!==h||t[34]!==g?(_=(0,J.jsxs)(`section`,{"aria-label":f,className:p,children:[m,h,g]}),t[30]=f,t[31]=p,t[32]=m,t[33]=h,t[34]=g,t[35]=_):_=t[35],_}function vt(e){return!e.parentRunId&&[`queued`,`running`,`waiting`,`verifying`].includes(e.status)}function yt(e){return e.kind===`input_required`||e.kind===`approval_required`}function bt(e){return(e.kind===`user_input`||e.kind===`approval`&&typeof e.condition.capability==`string`)&&e.condition.type!==`connection`}function xt(e){return e.kind===`paused`}function St(e){let t=(0,q.c)(16),{label:n,title:r,compact:i}=e,a=i&&!!r,o=a&&`-translate-y-2 opacity-0`,s;t[0]===o?s=t[1]:(s=V(`truncate [grid-area:1/1] motion-safe:transition-[opacity,translate] motion-safe:duration-200 motion-safe:ease-out`,o),t[0]=o,t[1]=s);let c;t[2]!==n||t[3]!==a||t[4]!==s?(c=(0,J.jsx)(`span`,{"aria-hidden":a,className:s,children:n}),t[2]=n,t[3]=a,t[4]=s,t[5]=c):c=t[5];let l=!a,u=!a&&`translate-y-2 opacity-0`,d;t[6]===u?d=t[7]:(d=V(`truncate [grid-area:1/1] motion-safe:transition-[opacity,translate] motion-safe:duration-200 motion-safe:ease-out`,u),t[6]=u,t[7]=d);let f;t[8]!==l||t[9]!==d||t[10]!==r?(f=(0,J.jsx)(`span`,{"aria-hidden":l,className:d,children:r}),t[8]=l,t[9]=d,t[10]=r,t[11]=f):f=t[11];let p;return t[12]!==a||t[13]!==c||t[14]!==f?(p=(0,J.jsxs)(`span`,{className:`grid min-w-0 overflow-hidden leading-6`,"data-task-header-compact":a,children:[c,f]}),t[12]=a,t[13]=c,t[14]=f,t[15]=p):p=t[15],p}function Ct(e){let t=(0,q.c)(17),{children:n,contentKey:r,language:i,className:o}=e,s=(0,K.useId)(),c=K.Children.toArray(n),[l,u]=a(),d;t[0]!==r||t[1]!==l?(d=l.getAll(`taskExpanded`).includes(r),t[0]=r,t[1]=l,t[2]=d):d=t[2];let f=d,p=f?c:c.slice(0,3),m;t[3]!==s||t[4]!==p?(m=(0,J.jsx)(`ul`,{id:s,className:`space-y-1.5`,children:p}),t[3]=s,t[4]=p,t[5]=m):m=t[5];let h;t[6]!==r||t[7]!==f||t[8]!==s||t[9]!==c.length||t[10]!==i||t[11]!==u?(h=c.length>3?(0,J.jsx)(`button`,{type:`button`,"aria-expanded":f,"aria-controls":s,className:`mt-2 min-h-9 rounded-sm text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:()=>u(e=>{let t=new URLSearchParams(e),n=t.getAll(`taskExpanded`).filter(e=>e!==r);return t.delete(`taskExpanded`),n.forEach(e=>t.append(`taskExpanded`,e)),f||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:i===`zh`?f?`收起`:`查看全部(${c.length})`:f?`Show less`:`Show all (${c.length})`}):null,t[6]=r,t[7]=f,t[8]=s,t[9]=c.length,t[10]=i,t[11]=u,t[12]=h):h=t[12];let g;return t[13]!==o||t[14]!==m||t[15]!==h?(g=(0,J.jsxs)(`div`,{className:o,children:[m,h]}),t[13]=o,t[14]=m,t[15]=h,t[16]=g):g=t[16],g}function wt({taskId:e}){let t=l(e=>e.conversationId),n=u(e=>e.language),[r,i]=(0,K.useState)(``),[a,o]=(0,K.useState)(null),[s,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)([]),[_,v]=(0,K.useState)(null),y=c(`/api/tasks/${encodeURIComponent(e)}/collaboration`),{data:b,error:x,mutate:S}=le([`task-collaboration`,e,t],()=>d(`${y}?recent=1`),{revalidateOnFocus:!0}),C=[...new Map([...h,...b?.items??[]].map(e=>[e.id,e])).values()].sort((e,t)=>e.sequence-t.sequence),w=async()=>{let e=C[0];if(!(!e||p)){m(!0);try{let t=await d(`${y}?recent=1&beforeSequence=${e.sequence}`);g(e=>[...t.items,...e])}catch(e){v(e instanceof Error?e.message:String(e))}finally{m(!1)}}};(0,K.useEffect)(()=>{let t=t=>{let n=t.detail;(!n?.taskId||n.taskId===e)&&S()};return window.addEventListener(`task-collaboration-entry-added`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.removeEventListener(`task-collaboration-entry-added`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[S,e]);let T=async()=>{if(!(!r.trim()||s)){f(!0),v(null);try{await d(y,{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({kind:a?`answer`:`instruction`,body:r.trim(),...a?{causationId:a}:{}})}),i(``),o(null),await S()}catch(e){v(e instanceof Error?e.message:String(e))}finally{f(!1)}}};return(0,J.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n===`zh`?`任务留言`:`Task updates`}),(0,J.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto`,children:[!b&&!x?(0,J.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-2`,children:[(0,J.jsx)(ae,{className:`h-14 w-full`}),(0,J.jsx)(ae,{className:`h-14 w-4/5`})]}):null,x?(0,J.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:n===`zh`?`暂时无法读取留言`:`Updates unavailable`}):null,C[0]&&C[0].sequence>1?(0,J.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void w(),className:`text-xs text-accent hover:underline disabled:opacity-50`,children:n===`zh`?`查看更早留言`:`Earlier updates`}):null,C.map(t=>(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 text-sm`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,J.jsx)(`span`,{children:t.authorKind===`worker_agent`?n===`zh`?`执行 Agent`:`Worker`:t.authorKind===`main_agent`?n===`zh`?`主 Agent`:`Main Agent`:t.authorKind===`system`?n===`zh`?`系统`:`System`:n===`zh`?`用户`:`You`}),(0,J.jsxs)(`span`,{children:[`· `,t.kind]}),t.deliveryStatus?(0,J.jsxs)(`span`,{children:[`· `,t.deliveryStatus]}):null]}),(0,J.jsx)(`div`,{className:`mt-1 min-w-0 text-fg`,"data-task-collaboration-body":!0,children:(0,J.jsx)(G,{content:t.body,contentKey:`${e}:update:${t.id}`,language:n,breaks:!0,previewHeight:120})}),t.kind===`question`&&t.authorKind===`worker_agent`?(0,J.jsx)(`button`,{type:`button`,className:`mt-2 text-xs text-accent hover:underline`,onClick:()=>o(t.id),children:n===`zh`?`回复问题`:`Reply`}):null]},t.id)),b&&!C.length?(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n===`zh`?`暂无进展留言`:`No updates yet`}):null]}),a?(0,J.jsxs)(`p`,{className:`mt-3 text-xs text-accent`,children:[n===`zh`?`正在回复执行 Agent 的问题`:`Replying to the worker`,(0,J.jsx)(`button`,{type:`button`,className:`ml-2 underline`,onClick:()=>o(null),children:n===`zh`?`取消`:`Cancel`})]}):null,(0,J.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),rows:2,"aria-label":n===`zh`?`任务留言`:`Task message`,placeholder:n===`zh`?`给执行 Agent 留言`:`Message the worker`,className:`mt-3 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),_?(0,J.jsx)(`p`,{role:`alert`,className:`mt-1 text-xs text-danger`,children:_}):null,(0,J.jsx)(`button`,{type:`button`,disabled:!r.trim()||s,onClick:()=>void T(),className:`mt-2 rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white disabled:opacity-50`,children:s?n===`zh`?`发送中`:`Sending`:n===`zh`?`发送`:`Send`})]})}function Tt(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function Et(e,t){let n={...e.task};t.title!==void 0&&(n.title=t.title),t.priority!==void 0&&(n.priority=t.priority);for(let e of[`body`,`projectId`,`milestoneId`,`parentTaskId`,`dueAt`,`ownerId`]){let r=t[e];r!==void 0&&(r===null?delete n[e]:Object.assign(n,{[e]:r}))}return n.version+=1,n.updatedAt=Date.now(),{...e,task:n}}function Dt(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已关闭`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Closed`})[e]}function Ot(){let e=(0,q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,J.jsx)(ae,{className:`h-32 rounded-2xl`}),(0,J.jsx)(ae,{className:`h-52 rounded-2xl`}),(0,J.jsx)(ae,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function kt(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function At(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var jt=[`backlog`,`ready`,`active`,`review`,`closed`],Mt=[`low`,`normal`,`high`,`critical`],Nt=(0,K.memo)(function(e){let t=(0,q.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:c,onChange:l}=e,u;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(u=e=>e!==n&&!i&&!(e===`closed`?a:n===`closed`&&o),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=u):u=t[4];let d=u,f;t[5]===c?f=t[6]:(f=(0,J.jsx)(`span`,{children:c}),t[5]=c,t[6]=f);let p;t[7]===l?p=t[8]:(p=e=>l(e.target.value),t[7]=l,t[8]=p);let m;t[9]!==s||t[10]!==d?(m=jt.map(e=>(0,J.jsx)(M,{value:e,disabled:d(e),children:Dt(e,s)},e)),t[9]=s,t[10]=d,t[11]=m):m=t[11];let h;t[12]!==r||t[13]!==p||t[14]!==m||t[15]!==n?(h=(0,J.jsx)(j,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:p,children:m}),t[12]=r,t[13]=p,t[14]=m,t[15]=n,t[16]=h):h=t[16];let g;return t[17]!==f||t[18]!==h?(g=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[f,h]}),t[17]=f,t[18]=h,t[19]=g):g=t[19],g}),Pt=(0,K.memo)(function(e){let t=(0,q.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,J.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=e=>o(e.target.value),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=Mt.map(e=>(0,J.jsx)(M,{value:e,children:a[e]},e)),t[4]=a,t[5]=l);let u;t[6]!==r||t[7]!==c||t[8]!==l||t[9]!==n?(u=(0,J.jsx)(j,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:c,children:l}),t[6]=r,t[7]=c,t[8]=l,t[9]=n,t[10]=u):u=t[10];let d;return t[11]!==s||t[12]!==u?(d=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,u]}),t[11]=s,t[12]=u,t[13]=d):d=t[13],d}),Ft=(0,K.memo)(function(e){let t=(0,q.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,J.jsx)(`span`,{children:i}),t[0]=i,t[1]=o);let s;t[2]!==r||t[3]!==i||t[4]!==a||t[5]!==n?(s=(0,J.jsx)(Be,{disabled:r,value:n,onChange:a,ariaLabel:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}),It=(0,K.memo)(function(e){let t=(0,q.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,c;t[0]===i?c=t[1]:(c=(0,J.jsx)(`span`,{children:i}),t[0]=i,t[1]=c);let l;t[2]===s?l=t[3]:(l=e=>s(e.target.value),t[2]=s,t[3]=l);let u;t[4]===a?u=t[5]:(u=(0,J.jsx)(M,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=u);let d;t[6]===o?d=t[7]:(d=o.map(Zt),t[6]=o,t[7]=d);let f;t[8]!==r||t[9]!==l||t[10]!==u||t[11]!==d||t[12]!==n?(f=(0,J.jsxs)(j,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:l,children:[u,d]}),t[8]=r,t[9]=l,t[10]=u,t[11]=d,t[12]=n,t[13]=f):f=t[13];let p;return t[14]!==c||t[15]!==f?(p=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[c,f]}),t[14]=c,t[15]=f,t[16]=p):p=t[16],p}),Lt=(0,K.memo)(function(e){let t=(0,q.c)(9),{candidates:n,selected:r,disabled:i,labels:a,getTaskHref:o,onChange:s}=e,c;t[0]===r?c=t[1]:(c=r.map(Qt),t[0]=r,t[1]=c);let l;return t[2]!==n||t[3]!==i||t[4]!==o||t[5]!==a||t[6]!==s||t[7]!==c?(l=(0,J.jsx)(qe,{borderless:!0,candidates:n,selectedIds:c,disabled:i,getTaskHref:o,onChange:s,labels:a}),t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=c,t[8]=l):l=t[8],l},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&e.getTaskHref===t.getTaskHref&&e.onChange===t.onChange&&e.candidates.length===t.candidates.length&&e.candidates.every((e,n)=>e.id===t.candidates[n]?.id&&e.title===t.candidates[n]?.title)&&e.selected.length===t.selected.length&&e.selected.every((e,n)=>e.id===t.selected[n]?.id&&e.title===t.selected[n]?.title)),Rt=`xopc.taskDetail.chatPanelPercent`,zt=42;function Bt(e,t){let n=Math.max(30,352/Math.max(t,1)*100),r=Math.min(60,(t-480)/Math.max(t,1)*100);return r<n?zt:Math.min(r,Math.max(n,e))}function Vt(){try{let e=Number(window.localStorage.getItem(Rt));return Number.isFinite(e)&&e>=30&&e<=60?e:zt}catch{return zt}}function Ht(e){let t=(0,q.c)(13),{items:n,empty:r,contentKey:i}=e,a=u(Wt);if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,J.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let o;t[2]===n?o=t[3]:(o=n.join(`
3
+ `),t[2]=n,t[3]=o);let s;t[4]===n?s=t[5]:(s=n.map(Ut),t[4]=n,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,J.jsx)(`ul`,{className:`space-y-2`,children:s}),t[6]=s,t[7]=c);let l;return t[8]!==i||t[9]!==a||t[10]!==o||t[11]!==c?(l=(0,J.jsx)(G,{content:o,contentKey:i,language:a,previewHeight:144,children:c}),t[8]=i,t[9]=a,t[10]=o,t[11]=c,t[12]=l):l=t[12],l}function Ut(e){return(0,J.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,J.jsx)(N,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,J.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e})]},e)}function Wt(e){return e.language}function Y({taskId:e,presentation:t,backgroundPath:n,onDeleted:r,onHeaderChange:i}){let[c,d]=a(),f=s(),p=u(e=>e.language),m=l(e=>e.conversationId),h=(0,K.useMemo)(()=>we(p),[p]),g=Te(e=>e.setPageHeader),_=Te(e=>e.clearPageHeader),v=Ce(e=>e.panes),y=b(e=>e.openForSession),{data:x,error:S,mutate:D,lastChange:O,conversationLoading:k,conversationError:A}=C(e),{data:j,error:M,mutate:N}=le(e?[`task-detail-automations`,m]:null,()=>De.list(),{refreshInterval:3e4}),[ie,H]=(0,K.useState)(null),[ye,Oe]=(0,K.useState)(null),[W,Ie]=(0,K.useState)(()=>new Set),[Le,Re]=(0,K.useState)([]),[ze,Be]=(0,K.useState)(null),[Ve,Ue]=(0,K.useState)([]),[We,Ge]=(0,K.useState)(!1),[qe,q]=(0,K.useState)(``),[Ze,$e]=(0,K.useState)(!1),[et,tt]=(0,K.useState)(``),[rt,it]=(0,K.useState)(Vt),[ot,st]=(0,K.useState)(!1),ct=(0,K.useRef)(null),lt=(0,K.useRef)(null),ut=(0,K.useRef)(null),dt=(0,K.useRef)(null),[ht,vt]=(0,K.useState)(!1),yt=(0,K.useRef)(!1),bt=(0,K.useRef)(!1),xt=(0,K.useRef)(``),Dt=(0,K.useRef)(null),jt=(0,K.useRef)(null),Mt=(0,K.useRef)(null),Ut=(0,K.useRef)(x),[Wt,Y]=(0,K.useState)(null),[Gt,Kt]=(0,K.useState)(null),[qt,Jt]=(0,K.useState)(!1),[Yt,Xt]=(0,K.useState)(!1),[Zt,Qt]=(0,K.useState)(null),$t=(0,K.useRef)(null),en=(0,K.useMemo)(()=>({link:h.linkDependencies,linked:h.linkedDependencies,searchPlaceholder:h.dependencySearchPlaceholder,noMatches:h.noDependencyMatches,noCandidates:h.noDependencyCandidates,remove:h.removeDependency}),[h.dependencySearchPlaceholder,h.linkDependencies,h.linkedDependencies,h.noDependencyCandidates,h.noDependencyMatches,h.removeDependency]),tn=x?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,nn=(0,K.useMemo)(()=>R(c.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[c]),rn=(0,K.useCallback)(e=>t===`modal`&&n?ee(n,e):z(`/tasks/${encodeURIComponent(e)}`,nn),[n,t,nn]);Ut.current=x;let X=(0,K.useCallback)((e,t)=>{Ie(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,K.useEffect)(()=>{H(null),Oe(null),Y(null),Ge(!1),Dt.current=null,$e(!1),Kt(null),Jt(!1),Xt(!1),Qt(null)},[e]),(0,K.useEffect)(()=>{let e=!0;return Se().then(t=>{e&&Ue(t.items)}).catch(()=>void 0),()=>{e=!1}},[m]),(0,K.useEffect)(()=>{if(!O||O.source===`user`)return;Kt(O);let e=window.setTimeout(()=>Kt(null),3500);return()=>window.clearTimeout(e)},[O]),(0,K.useEffect)(()=>{let t=x?.task.projectId,n=x?.dependencies??[];if(!t){Mt.current=null,Be(null),Re(n);return}Mt.current!==t&&(Mt.current=t,Be(null));let r=!0;return oe(t).then(t=>{if(!r)return;Be(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});Re([...i.values()])}).catch(()=>{r&&Re(n)}),()=>{r=!1}},[tn,x?.task.projectId,e]);let Z=(0,K.useCallback)(async(t,n=`command`)=>{let r=Ut.current;if(r){X(n,!0),H(null),t.type===`close`&&t.resolution===`done`&&Oe(null);try{await D(await be(e,t,r.task.version),{revalidate:!1})}catch{H(h.actionFailed),t.type===`close`&&t.resolution===`done`&&Oe(h.actionFailed)}finally{X(n,!1)}}},[h.actionFailed,D,X,e]),an=(0,K.useCallback)(async(t,n)=>{let r=Ut.current;if(!r)return!1;n&&X(n,!0),H(null);try{let n=de(e,t,r.task.version);return await D(n,{optimisticData:Et(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return H(h.actionFailed),!1}finally{n&&X(n,!1)}},[h.actionFailed,D,X,e]),on=()=>{x&&(Dt.current={value:x.task.title,version:x.task.version},Y(null),q(x.task.title),Ge(!0))},sn=()=>{yt.current=!0,q(Ut.current?.task.title??``),Dt.current=null,Y(null),Ge(!1),queueMicrotask(()=>{yt.current=!1})},cn=async(e=!1)=>{if(yt.current){yt.current=!1;return}let t=Ut.current;if(!t||W.has(`title`))return;let n=qe.trim();if(!n){sn();return}let r=Dt.current;if(!e&&Tt(r,t.task.version,t.task.title,n)){Y(`title`);return}if(n===t.task.title){sn();return}await an({title:n},`title`)&&(Dt.current=null,Y(null),Ge(!1))},ln=async()=>{if(!x)return;if(bt.current){bt.current=!1;return}let e=et.trim(),t=jt.current;if(Tt(t,x.task.version,x.task.body??``,e)){Y(`description`);return}if(et===xt.current||e===(x.task.body??``).trim()){$e(!1);return}await an({body:ce(x.task.body??``,e)||null})&&(Y(null),$e(!1))},un=(0,K.useCallback)(async e=>{let t=Ut.current;!t||e===t.task.phase||await Z({type:`move`,phase:e},`phase`)},[Z]),dn=(0,K.useCallback)(e=>{an({priority:e},`priority`)},[an]),fn=(0,K.useCallback)(e=>{an({dueAt:At(e)},`dueAt`)},[an]),pn=(0,K.useCallback)(e=>{it(e);try{window.localStorage.setItem(Rt,String(e))}catch{}},[]),mn=(0,K.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=ut.current?.clientWidth??0,n=e.key===`Home`?zt:rt+(e.key===`ArrowLeft`?2:-2);pn(Bt(n,t))},[rt,pn]),hn=(0,K.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=ut.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),st(!0);let i=rt,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=Bt((n.right-e.clientX)/n.width*100,n.width),a===0&&(a=window.requestAnimationFrame(o))},c=()=>{a!==0&&(window.cancelAnimationFrame(a),o());try{n.releasePointerCapture(r)}catch{}st(!1),pn(i),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[rt,pn]),gn=(0,K.useCallback)(async t=>{let n=Ut.current;if(n){X(`dependencies`,!0),H(null);try{await D(await ue(e,t,n.task.version),{revalidate:!1})}catch{H(h.dependencyUpdateFailed)}finally{X(`dependencies`,!1)}}},[h.dependencyUpdateFailed,D,X,e]),_n=(0,K.useCallback)(async t=>{let n=Ut.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){X(`delegateAgentId`,!0),H(null);try{await D(await fe(e,t,n.task.version),{revalidate:!1})}catch{H(h.actionFailed)}finally{X(`delegateAgentId`,!1)}}},[h.actionFailed,D,X,e]),vn=(0,K.useCallback)(async()=>{X(`delete`,!0),H(null);try{await me(e),r?r():f(nn,{replace:!0})}catch(e){H(e instanceof Error?e.message:h.actionFailed)}finally{X(`delete`,!1)}},[h.actionFailed,f,r,nn,X,e]),yn=(0,K.useCallback)(async(t,n)=>{let r=Ut.current;if(!r)return!1;X(`acceptance`,!0),Oe(null),H(null);try{return await D(await xe(e,t,n,r.task.version,r.task.latestContractVersion),{revalidate:!1}),!0}catch{return Oe(h.actionFailed),H(h.actionFailed),D().catch(()=>void 0),!1}finally{X(`acceptance`,!1)}},[h.actionFailed,D,X,e]),bn=x?.task.title,xn=bn!==void 0;if((0,K.useLayoutEffect)(()=>{let e=dt.current,t=e?.parentElement;if(!xn||!e||!t||typeof IntersectionObserver>`u`)return;let n=new IntersectionObserver(([e])=>{let n=Xe(t),r=n?n.getBoundingClientRect().top+n.clientTop:0;vt(!e.isIntersecting&&e.boundingClientRect.bottom<=r)});return n.observe(e),()=>n.disconnect()},[xn,e]),(0,K.useLayoutEffect)(()=>{i?.({taskId:e,title:bn,compact:ht})},[ht,i,e,bn]),(0,K.useLayoutEffect)(()=>{if(t!==`modal`)return g({startExtra:(0,J.jsx)(o,{to:nn,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":h.backToWork,children:(0,J.jsx)(T,{className:`size-4`})}),main:xn?(0,J.jsx)(`div`,{className:`min-w-0 text-sm font-semibold text-fg`,children:(0,J.jsx)(St,{label:ze?`${ze} / ${h.taskLabel}`:h.taskLabel,title:bn,compact:ht})}):null,end:null}),_},[_,ht,h.backToWork,h.taskLabel,xn,t,ze,nn,g,bn]),S&&!x)return(0,J.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:h.taskNotFound});if(!x)return(0,J.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,J.jsx)(Ot,{})});let Sn=x.waits[0],Cn=x.runs.find(e=>!e.parentRunId&&[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),wn=pe(x),Tn=wn.length>0&&wn.every(e=>e.status===`passed`),En=x.waits.find(e=>e.kind===`paused`),Dn=_e(x),On=ve(x),kn=h.detailStatuses[On],An=se(x.task.body?.trim()||x.task.contract?.objective.trim()||``),jn=x.allowedCommands.includes(`mark_ready`),Mn=x.allowedCommands.includes(`start`),Nn=x.allowedCommands.includes(`add_wait`),Pn=!Sn&&!Cn&&Tn&&x.task.phase===`review`&&x.allowedCommands.includes(`close`),Fn=x.allowedCommands.includes(`reopen`),Q=x.conversation.activeConversationId,In=x.conversation.currentExecutorAgentId??x.task.delegateAgentId??x.task.ownerId,Ln=Ve.find(e=>e.id===In),Rn=!!(Q&&v[Q]?.open),zn=x.context.filter(e=>e.role!==`deliverable`),Bn=j?.automations.filter(t=>t.action.kind===`task_command`&&t.action.taskId===e)??[],$=Bn.filter(e=>e.trigger.kind===`schedule`&&e.action.kind===`task_command`&&e.action.command.type===`start`),Vn=$.filter(e=>e.enabled&&e.state.nextRunAtMs!==void 0).map(e=>e.state.nextRunAtMs).sort((e,t)=>e-t)[0],Hn=e=>{N(t=>({automations:[e,...(t?.automations??[]).filter(t=>t.id!==e.id)]}),{revalidate:!1})},Un=e=>{Qt(e),Xt(!0)},Wn=()=>{j&&($.length===1?Un($[0]):$.length>1?($t.current&&($t.current.open=!0),d(e=>Je(e,`schedule`,!0),{preventScrollReset:!0}),$t.current?.scrollIntoView({block:`start`,behavior:`smooth`}),$t.current?.focus({preventScroll:!0})):(Qt(null),Xt(!0)))},Gn=x.sessions.filter((e,t,n)=>n.findIndex(t=>t.conversationId===e.conversationId)===t),Kn=x.task.contract?.expectedOutputs??[],qn=x.task.contract?.constraints??[],Jn=x.task.contract?.approvalRequired??[],Yn=x.task.contract?.assumptions??[],Xn=x.task.contract?.risks??[],Zn=qn.length>0||Jn.length>0||Yn.length>0||Xn.length>0,Qn=(...e)=>!!Gt?.changedFields.some(t=>e.includes(t)),$n=x.allowedCommands.includes(`move`),er=W.has(`command`),tr=W.has(`delete`),nr=Cn!==void 0,rr=()=>{let e=ct.current;e&&(e.open=!0,d(e=>Je(e,`acceptance`,!0),{preventScrollReset:!0}),e.scrollIntoView({block:`start`,behavior:`smooth`}),e.focus({preventScroll:!0}))},ir=(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[jn&&!Mn&&!Sn&&x.task.phase!==`review`?(0,J.jsxs)(U,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:er,onClick:()=>void Z({type:`mark_ready`}),children:[(0,J.jsx)(re,{className:`size-4`}),h.scheduleTask]}):null,En&&x.allowedCommands.includes(`resolve_wait`)?(0,J.jsxs)(U,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:er,onClick:()=>void Z({type:`resolve_wait`,waitId:En.id}),children:[(0,J.jsx)(re,{className:`size-4`}),h.resumeTask]}):null,!Sn&&Mn&&x.task.phase!==`review`&&In?(0,J.jsxs)(U,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:er,onClick:()=>void Z({type:`start`,executor:{kind:`agent`,agentId:In}}),children:[(0,J.jsx)(re,{className:`size-4`}),h.runTask]}):null,Fn?(0,J.jsxs)(U,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`ghost`,disabled:er,onClick:()=>void Z({type:`reopen`,phase:`ready`}),children:[(0,J.jsx)(re,{className:`size-4`}),h.reopenTask]}):null,x.task.phase!==`review`&&!En&&Nn?(0,J.jsxs)(U,{variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,disabled:er,onClick:()=>void Z({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,J.jsx)(ne,{className:`size-4`}),h.pauseTask]}):null,x.task.phase===`closed`?(0,J.jsx)(U,{variant:`primary`,className:`min-h-9 px-3 py-1.5 text-xs`,onClick:()=>{lt.current?.scrollIntoView({block:`start`,behavior:`smooth`}),lt.current?.focus({preventScroll:!0})},children:p===`zh`?`查看结果`:`View results`}):null,!Sn&&!Cn&&x.task.phase!==`closed`&&x.task.phase!==`review`?(0,J.jsxs)(U,{variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,disabled:!j,onClick:Wn,children:[(0,J.jsx)(E,{className:`size-4`}),$.length>0?p===`zh`?`管理执行时间`:`Manage schedule`:p===`zh`?`设置执行时间`:`Set execution time`]}):null,x.task.phase===`review`?(0,J.jsx)(U,{variant:`primary`,className:`min-h-9 px-3 py-1.5 text-xs`,onClick:rr,children:p===`zh`?`去验收`:`Review results`}):null,(0,J.jsxs)(Ae,{children:[(0,J.jsx)(je,{asChild:!0,children:(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:er||tr,"aria-label":h.moreActions,children:(0,J.jsx)(P,{className:`size-4`,"aria-hidden":!0})})}),(0,J.jsx)(Me,{children:(0,J.jsxs)(Pe,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[x.task.phase===`review`&&!En&&Nn?(0,J.jsx)(Ne,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover`,onSelect:()=>void Z({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:h.pauseTask}):null,x.task.phase===`review`&&!Sn&&!Cn?(0,J.jsx)(Ne,{disabled:!j,className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:opacity-50`,onSelect:Wn,children:$.length>0?p===`zh`?`管理执行时间`:`Manage schedule`:p===`zh`?`设置执行时间`:`Set execution time`}):null,x.task.phase===`review`&&!Sn&&Mn&&In?(0,J.jsx)(Ne,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover`,onSelect:()=>void Z({type:`start`,executor:{kind:`agent`,agentId:In}}),children:h.runTask}):null,jn&&(Mn||Sn||x.task.phase===`review`)?(0,J.jsx)(Ne,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover`,onSelect:()=>void Z({type:`mark_ready`}),children:h.scheduleTask}):null,Cn?(0,J.jsx)(Ne,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{X(`command`,!0),H(null),D(ge(e,Cn.id,Cn.version),{revalidate:!1}).catch(()=>H(h.actionFailed)).finally(()=>X(`command`,!1))},children:h.cancelActiveRun}):null,Cn?(0,J.jsx)(Fe,{className:`my-1 h-px bg-edge`}):null,x.task.phase===`closed`?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ne,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void Z({type:`close`,resolution:`cancelled`}),children:h.cancelTask}),(0,J.jsx)(Fe,{className:`my-1 h-px bg-edge`})]}),(0,J.jsx)(Ne,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{if(nr){H(h.deleteActiveTaskBlocked);return}Jt(!0)},children:h.deleteTask})]})})]})]});return(0,J.jsxs)(`div`,{ref:ut,className:`flex h-full min-h-0 flex-col overflow-hidden ${ot?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${rt}%`},children:[(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`task-detail-scroll flex min-w-0 shrink-0 flex-col bg-surface-panel lg:min-h-0 lg:flex-1 lg:shrink lg:overflow-y-auto lg:overscroll-contain`,children:[(0,J.jsxs)(`header`,{ref:dt,className:V(`shrink-0 px-4 py-5 sm:px-6 sm:py-6`,Qn(`title`)&&`task-detail-live-update`),children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-6 gap-y-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[ze?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,J.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),ze]}):null,ze?(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`/`}):null,(0,J.jsx)(`span`,{children:h.taskLabel}),Gt?(0,J.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:Gt.source===`agent`?p===`zh`?`Agent 刚刚更新`:`Updated by Agent`:p===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),We?(0,J.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,"aria-label":p===`zh`?`任务标题`:`Task title`,rows:2,value:qe,onFocus:e=>{Dt.current?.value===qe&&(e.currentTarget.setSelectionRange(0,0),e.currentTarget.scrollTop=0)},onChange:e=>q(e.target.value),onBlur:()=>void cn(),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),sn()):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.blur()))},className:`mt-2 block max-h-56 min-h-14 w-full max-w-3xl resize-none overflow-y-auto bg-transparent p-0 text-xl font-semibold leading-7 tracking-tight text-fg sm:text-2xl outline-none [field-sizing:content]`}):(0,J.jsx)(G,{content:x.task.title,contentKey:`${e}:title`,language:p,previewHeight:56,className:`mt-2 max-w-3xl`,children:(0,J.jsx)(`h1`,{className:`break-words text-xl font-semibold leading-7 tracking-tight text-fg sm:text-2xl`,children:(0,J.jsx)(`button`,{type:`button`,className:`max-w-full whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-sm text-left outline-none hover:bg-surface-hover/60 focus-visible:ring-2 focus-visible:ring-accent/40`,title:x.task.title,onClick:on,children:x.task.title})})}),Wt===`title`?(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,J.jsx)(`span`,{children:p===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,J.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:sn,children:p===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,J.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,disabled:W.has(`title`),onClick:()=>void cn(!0),children:p===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),(0,J.jsx)(`span`,{className:V(`shrink-0 rounded-full px-2.5 py-1 text-xs font-medium`,he(On)),children:kn})]}),(0,J.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,J.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[In?(0,J.jsx)(Ee,{agentId:In,avatar:Ln?.avatar,size:20,className:`shrink-0`}):null,(0,J.jsxs)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,children:[h.executorLabel,` · `,Ln?.name??In??h.unassigned]})]}),(0,J.jsx)(`span`,{className:`text-fg-subtle`,children:h.updatedAt.replace(`{{date}}`,He(x.task.updatedAt,p))})]})]}),(0,J.jsxs)(`div`,{className:`sticky top-0 z-10 flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-edge-subtle bg-surface-panel px-4 py-2 sm:px-5`,"aria-label":p===`zh`?`任务操作`:`Task actions`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:kn}),ir,ie?(0,J.jsx)(`p`,{role:`alert`,className:`basis-full text-sm text-danger`,children:ie}):null,(0,J.jsx)(Qe,{language:p,hasSchedule:$.length>0},e)]}),(0,J.jsxs)(`section`,{className:`min-w-0 space-y-4 p-4 sm:p-5`,children:[x.task.phase===`review`?null:(0,J.jsx)(_t,{detail:x,language:p,onUpdated:e=>{D(e,{revalidate:!1})}}),(0,J.jsxs)(`section`,{"data-task-section":`results`,"data-task-section-label":p===`zh`?`交付结果`:`Results`,ref:lt,tabIndex:-1,"aria-labelledby":`task-results-heading`,className:`scroll-mt-24 space-y-4`,children:[(0,J.jsx)(at,{detail:x,language:p}),x.task.phase===`review`&&(x.waits.length>0||x.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`))?(0,J.jsx)(_t,{detail:x,language:p,onUpdated:e=>{D(e,{revalidate:!1})}}):null,(0,J.jsx)(Ye,{panelId:`acceptance`,chevron:!0,"data-task-section":`acceptance`,"data-task-section-label":p===`zh`?`验收`:`Acceptance`,defaultOpen:!0,ref:ct,tabIndex:-1,"aria-label":h.successDefinition,className:`scroll-mt-24 overflow-hidden rounded-2xl border border-edge-subtle bg-surface-panel`,summaryClassName:`min-h-12 cursor-pointer px-4 py-2 text-sm font-semibold text-fg outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,title:(0,J.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[p===`zh`?`验收`:`Acceptance`,(0,J.jsxs)(`span`,{"aria-live":`polite`,className:`rounded-full bg-surface-inset px-2 py-0.5 text-xs font-medium tabular-nums text-fg-muted`,children:[wn.filter(e=>e.status===`passed`).length,`/`,wn.length]})]}),children:(0,J.jsx)(nt,{criteria:wn,language:p,closed:x.task.phase===`closed`,pending:W.has(`acceptance`),error:ye,blockedReason:Sn?p===`zh`?`请先处理待办事项`:`Resolve the pending request first`:Cn?p===`zh`?`请等待当前执行结束`:`Wait for the current run to finish`:void 0,onReview:yn,projectId:x.task.projectId,conversationId:Q??void 0},`${e}:${x.task.latestContractVersion}`)})]}),(0,J.jsx)(Ye,{panelId:`report`,chevron:!0,defaultOpen:!0,"data-task-section":`report`,"data-task-section-label":p===`zh`?`执行报告`:`Report`,className:`rounded-2xl border border-edge-subtle bg-surface-panel p-4`,summaryClassName:`cursor-pointer rounded-sm text-sm font-medium text-fg`,title:p===`zh`?`完整执行报告`:`Full execution report`,children:(0,J.jsx)(ft,{detail:x,language:p},Dn?.runId??e)}),!j&&!M?(0,J.jsx)(ae,{className:`h-9 rounded-lg`}):null,M?(0,J.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-2 text-sm text-danger`,children:[(0,J.jsx)(`span`,{children:p===`zh`?`无法读取执行计划,请重试后再设置时间。`:`Could not load schedules. Retry before setting a time.`}),(0,J.jsx)(U,{variant:`ghost`,onClick:()=>void N(),children:p===`zh`?`重试`:`Retry`})]}):null,$.length>0?(0,J.jsx)(Ye,{panelId:`schedule`,chevron:!0,defaultOpen:!0,"data-task-section":`schedule`,"data-task-section-label":p===`zh`?`执行时间`:`Schedule`,ref:$t,tabIndex:-1,className:`scroll-mt-24 rounded-2xl border border-edge-subtle bg-surface-panel p-4`,summaryClassName:`cursor-pointer rounded-sm text-sm text-fg-muted`,title:(0,J.jsxs)(J.Fragment,{children:[p===`zh`?`执行时间`:`Execution schedule`,` · `,$.length,Vn===void 0?``:` · ${p===`zh`?`下次执行:`:`Next run: `}${He(Vn,p)}`]}),children:(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(mt,{schedules:$,language:p,onEdit:Un,onUpdated:Hn})})}):null,(0,J.jsx)(Ye,{panelId:`goal`,chevron:!0,defaultOpen:!0,"data-task-section":`goal`,"data-task-section-label":p===`zh`?`目标说明`:`Goal`,className:`rounded-2xl border border-edge-subtle bg-surface-panel p-4`,summaryClassName:`cursor-pointer rounded-sm text-sm font-medium text-fg`,title:p===`zh`?`任务目标与说明`:`Task goal and description`,children:(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel divide-y divide-edge-subtle`,children:[(0,J.jsxs)(`div`,{className:`border-b border-edge-subtle p-5`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p===`zh`?`任务目标`:`Task goal`}),(0,J.jsx)(G,{content:x.task.contract?.objective||x.task.title,contentKey:`${e}:goal`,language:p,markdown:!1,previewHeight:72,className:`mt-3 text-sm leading-6 text-fg`}),(0,J.jsxs)(U,{variant:`ghost`,className:`mt-2 min-h-9 px-2 text-xs`,onClick:rr,children:[h.successDefinition,` · `,wn.length]})]}),Kn.length>0?(0,J.jsxs)(`div`,{className:`p-5`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:h.expectedOutputs}),(0,J.jsx)(`div`,{className:`mt-2`,children:(0,J.jsx)(Ht,{contentKey:`${e}:expectedOutputs`,items:Kn,empty:h.noDefinition})})]}):null,(0,J.jsxs)(`details`,{className:V(`p-5`,Qn(`body`)&&`task-detail-live-update`),children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:h.taskDescription}),Ze?(0,J.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:et,onChange:e=>tt(e.target.value),onBlur:()=>void ln(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),bt.current=!0,tt(se(x.task.body??x.task.contract?.objective??``)),$e(!1),queueMicrotask(()=>{bt.current=!1}))},className:`mt-3 w-full resize-y rounded-lg bg-surface-hover px-3 py-2 text-sm leading-6 text-fg outline-none ring-2 ring-accent/20 focus:ring-accent/50`}):(0,J.jsxs)(`div`,{className:`mt-2`,children:[An&&An!==x.task.title?(0,J.jsx)(G,{content:An,contentKey:`${e}:description`,language:p}):(0,J.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:h.noTaskDescription}),(0,J.jsx)(`button`,{type:`button`,className:`mt-2 rounded-md px-2 py-1 text-xs text-accent hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=se(x.task.body??x.task.contract?.objective??``);xt.current=e,jt.current={value:x.task.body??``,version:x.task.version},Y(null),tt(e),$e(!0)},children:p===`zh`?`编辑说明`:`Edit description`})]}),Wt===`description`?(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,J.jsx)(`span`,{children:p===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,J.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{tt(se(x.task.body??``)),Y(null),$e(!1)},children:p===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,J.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void an({body:ce(x.task.body??``,et.trim())||null}).then(e=>{e&&(Y(null),$e(!1))}),children:p===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),Zn?(0,J.jsxs)(`section`,{className:V(`p-5`,Qn(`contract`)&&`task-detail-live-update`),children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.taskDefinition}),(0,J.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:p===`zh`?`执行边界及补充背景`:`Execution boundaries and supporting context`}),qn.length>0?(0,J.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:h.constraints}),(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(Ht,{contentKey:`${e}:constraints`,items:qn,empty:h.noDefinition})})]}):null,Jn.length>0?(0,J.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:h.approvalRequired}),(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(Ht,{contentKey:`${e}:approvalRequired`,items:Jn,empty:h.noDefinition})})]}):null,Yn.length>0?(0,J.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:h.contextAssumptions}),(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(Ht,{contentKey:`${e}:assumptions`,items:Yn,empty:h.noDefinition})})]}):null,Xn.length>0?(0,J.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:h.contextRisks}),(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(Ht,{contentKey:`${e}:risks`,items:Xn,empty:h.noDefinition})})]}):null]}):null]})})}),(0,J.jsxs)(Ye,{panelId:`management`,chevron:!0,defaultOpen:!0,"data-task-section":`management`,"data-task-section-label":p===`zh`?`任务管理`:`Management`,"aria-label":p===`zh`?`任务管理`:`Task management`,className:`rounded-2xl border border-edge-subtle bg-surface-panel p-4`,summaryClassName:`cursor-pointer rounded-sm text-sm font-medium text-fg`,title:p===`zh`?`任务管理`:`Task management`,children:[(0,J.jsxs)(`aside`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,J.jsxs)(`section`,{className:V(`p-5`,Qn(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.taskProperties}),(0,J.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,J.jsx)(Nt,{value:x.task.phase,disabled:W.has(`phase`),canMove:$n,canApprove:Pn,canReopen:Fn,language:p,label:h.taskPhase,onChange:un}),(0,J.jsx)(Pt,{value:x.task.priority,disabled:W.has(`priority`),label:h.priority,labels:h.priorityLabels,onChange:dn}),(0,J.jsx)(Ft,{value:kt(x.task.dueAt),disabled:W.has(`dueAt`),label:h.dueDate,onChange:fn}),(0,J.jsx)(It,{value:x.conversation.currentExecutorAgentId??``,disabled:W.has(`delegateAgentId`),label:h.executorLabel,unassignedLabel:h.unassigned,agents:Ve,onChange:_n})]})]}),(0,J.jsxs)(`details`,{className:V(`p-5`,Qn(`dependencies`)&&`task-detail-live-update`),children:[(0,J.jsxs)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:[h.taskRelations,` · `,x.dependencies.length,` / `,x.dependents.length]}),(0,J.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:h.dependencies}),(0,J.jsx)(Lt,{candidates:Le,selected:x.dependencies,disabled:W.has(`dependencies`),labels:en,getTaskHref:rn,onChange:gn})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:h.dependents}),x.dependents.length>0?(0,J.jsx)(`div`,{className:`space-y-1.5`,children:x.dependents.map(t=>(0,J.jsx)(G,{content:t.title,contentKey:`${e}:dependent:${t.id}`,language:p,previewHeight:72,className:`rounded-lg bg-surface-hover p-2.5`,children:(0,J.jsx)(o,{to:rn(t.id),className:`block break-words [overflow-wrap:anywhere] text-sm text-fg-muted transition-colors hover:text-fg`,children:t.title})},t.id))}):(0,J.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:h.noDependents})]})]})]})]}),x.task.phase===`closed`?null:(0,J.jsxs)(U,{variant:`ghost`,className:`my-3`,disabled:!j,onClick:Wn,children:[(0,J.jsx)(E,{className:`size-4`}),$.length>0?p===`zh`?`管理执行时间`:`Manage schedule`:h.scheduleRecurringTask]}),(0,J.jsxs)(`details`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5 shadow-surface`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:p===`zh`?`关联内容`:`Related work`}),Gn.length>0||x.runs.length>0||Bn.length>0||x.dependencies.length>0||x.dependents.length>0?(0,J.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[Gn.length>0?(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:p===`zh`?`对话 · ${Gn.length}`:`Conversations · ${Gn.length}`}),(0,J.jsx)(Ct,{contentKey:`${e}:sessions`,language:p,className:`mt-2`,children:Gn.map(t=>(0,J.jsx)(`li`,{children:(0,J.jsx)(o,{className:`block break-words [overflow-wrap:anywhere] text-sm text-accent hover:underline`,to:t.conversationId===Q?B(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===Q?p===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?p===`zh`?`关联讨论`:`Linked discussion`:p===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})]}):null,Bn.length>0?(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:p===`zh`?`自动化 · ${Bn.length}`:`Automations · ${Bn.length}`}),(0,J.jsx)(Ct,{contentKey:`${e}:automations`,language:p,className:`mt-2`,children:Bn.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(o,{className:`block break-words [overflow-wrap:anywhere] text-sm text-accent hover:underline`,to:`/automations?automation=${encodeURIComponent(e.id)}`,children:e.name})},e.id))})]}):null,x.dependencies.length>0||x.dependents.length>0?(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:h.taskRelations}),(0,J.jsx)(`p`,{className:`mt-2 text-sm text-fg`,children:p===`zh`?`${x.dependencies.length} 个前置任务 · ${x.dependents.length} 个后续任务`:`${x.dependencies.length} prerequisites · ${x.dependents.length} dependents`})]}):null]}):(0,J.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:p===`zh`?`还没有关联内容`:`No related work yet`}),(0,J.jsx)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:(0,J.jsx)(Ke,{resource:{kind:`task`,id:x.task.id,revision:String(x.task.version)},disabled:We||Ze||W.size>0})})]}),zn.length>0?(0,J.jsxs)(`section`,{className:V(`p-5`,Qn(`context`)&&`task-detail-live-update`),children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.contextUsed}),(0,J.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:zn.map(e=>(0,J.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,J.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[h.contextRoleLabels[e.role],` · `,h.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,J.jsx)(`a`,{className:`mt-1 block break-all text-sm text-accent hover:underline`,href:e.targetId,target:`_blank`,rel:`noreferrer`,children:e.title??e.targetId}):(0,J.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,J.jsx)(Ye,{panelId:`activity`,chevron:!0,defaultOpen:!0,"data-task-section":`activity`,"data-task-section-label":p===`zh`?`活动留言`:`Activity`,className:`rounded-2xl border border-edge-subtle bg-surface-panel p-4`,summaryClassName:`cursor-pointer rounded-sm text-sm font-semibold text-fg`,title:p===`zh`?`活动记录与留言`:`Activity and updates`,children:(0,J.jsxs)(`div`,{className:`mt-3 space-y-4`,children:[(0,J.jsx)(wt,{taskId:e},e),(0,J.jsx)(pt,{changes:x.phaseChanges,language:p})]})})]})]}),(0,J.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":p===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(rt),tabIndex:0,onPointerDown:hn,onKeyDown:mn,onDoubleClick:()=>pn(zt),className:`hidden w-2 shrink-0 cursor-col-resize touch-none bg-surface-panel outline-none focus-visible:bg-accent-soft lg:block`}),(0,J.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 shrink-0 flex-col bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)]`,children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-medium text-fg-muted`,children:p===`zh`?`执行对话`:`Execution chat`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Gn.length>1?(0,J.jsxs)(Ae,{children:[(0,J.jsx)(je,{asChild:!0,children:(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,children:p===`zh`?`${Gn.length} 段对话`:`${Gn.length} conversations`})}),(0,J.jsx)(Me,{children:(0,J.jsx)(Pe,{align:`end`,sideOffset:6,className:`z-[100] min-w-52 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:Gn.map(t=>(0,J.jsx)(Ne,{asChild:!0,children:(0,J.jsx)(o,{className:`block rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,to:t.conversationId===Q?B(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===Q?p===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?p===`zh`?`关联讨论`:`Linked discussion`:p===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})})]}):null,Q?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:V(`size-8 p-0`,Rn&&`bg-surface-hover text-fg`),"aria-label":p===`zh`?`项目文件`:`Project files`,"aria-pressed":Rn,onClick:()=>{Ce.getState().openFiles(Q),y(Q)},children:(0,J.jsx)(L,{className:`size-4`,"aria-hidden":!0})}),(0,J.jsx)(U,{asChild:!0,variant:`ghost`,className:`size-8 p-0`,children:(0,J.jsx)(o,{to:B(e),"aria-label":p===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,J.jsx)(F,{className:`size-4`,"aria-hidden":!0})})})]}):null]})]}),Q?(0,J.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,J.jsx)(w,{embedded:!0,conversationId:Q,taskId:e})}):k?(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,J.jsxs)(`div`,{className:`max-w-xs`,children:[(0,J.jsx)(te,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,J.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:p===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):A?(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,J.jsxs)(`div`,{className:`max-w-xs`,children:[(0,J.jsx)(te,{className:`mx-auto size-8 text-danger`}),(0,J.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:p===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,J.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:A instanceof Error?A.message:String(A)})]})}):(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,J.jsxs)(`div`,{className:`max-w-xs`,children:[(0,J.jsx)(te,{className:`mx-auto size-8 text-fg-subtle`}),(0,J.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:p===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,J.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:p===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]})]}),Yt?(0,J.jsx)(gt,{automation:Zt??void 0,taskId:e,taskTitle:x.task.title,projectId:x.task.projectId,executorAgentId:In,language:p,onClose:()=>Xt(!1),onCreated:Hn},`${e}:${Zt?.id??`new`}`):null,(0,J.jsx)(ke,{open:qt,title:h.deleteTaskTitle,description:h.deleteTaskDescription.replace(`{{title}}`,x.task.title),confirmLabel:h.confirmDeleteTask,cancelLabel:h.keepTask,destructive:!0,onConfirm:()=>{Jt(!1),vn()},onCancel:()=>Jt(!1)})]})}function Gt(){let e=(0,q.c)(2),{taskId:t}=i(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,J.jsx)(Y,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function Kt(e){let t=(0,q.c)(43),{taskId:n,backgroundPath:r,workspacePanelWidth:i,onClose:a}=e,o=i===void 0?0:i,s=u(Xt),c=ye(Yt),l=o>0,[d,f]=(0,K.useState)(),p=d?.taskId===n?d:void 0,b;t[0]!==a||t[1]!==c?(b=e=>{e||(c(null),a())},t[0]=a,t[1]=c,t[2]=b):b=t[2];let x=s===`zh`?`关闭任务详情`:`Close task details`,S;t[3]!==a||t[4]!==c?(S=()=>{c(null),a()},t[3]=a,t[4]=c,t[5]=S):S=t[5];let C;t[6]!==x||t[7]!==S?(C=(0,J.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45`,"aria-label":x,onClick:S}),t[6]=x,t[7]=S,t[8]=C):C=t[8];let w=l?`true`:`false`,T=`${o/2}px`,E=`${o}px`,D;t[9]!==T||t[10]!==E?(D={"--task-detail-workspace-offset":T,"--task-detail-workspace-width":E},t[9]=T,t[10]=E,t[11]=D):D=t[11];let O=D,k=s===`zh`?`任务详情`:`Task details`,A=p?.title,j=p?.compact??!1,M;t[12]!==k||t[13]!==A||t[14]!==j?(M=(0,J.jsx)(v,{className:`min-w-0 flex-1 font-medium text-fg`,children:(0,J.jsx)(St,{label:k,title:A,compact:j})}),t[12]=k,t[13]=A,t[14]=j,t[15]=M):M=t[15];let N=s===`zh`?`查看并操作任务详情`:`View and manage task details`,P;t[16]===N?P=t[17]:(P=(0,J.jsx)(m,{className:`sr-only`,children:N}),t[16]=N,t[17]=P);let F=s===`zh`?`关闭任务详情`:`Close task details`,I;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,J.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),t[18]=I):I=t[18];let L;t[19]===F?L=t[20]:(L=(0,J.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,J.jsx)(h,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":F,children:I})}),t[19]=F,t[20]=L);let R;t[21]!==M||t[22]!==P||t[23]!==L?(R=(0,J.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[M,P,L]}),t[21]=M,t[22]=P,t[23]=L,t[24]=R):R=t[24];let z;t[25]!==a||t[26]!==c?(z=()=>{c(null),a()},t[25]=a,t[26]=c,t[27]=z):z=t[27];let ee;t[28]!==r||t[29]!==z||t[30]!==n?(ee=(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,J.jsx)(Y,{taskId:n,presentation:`modal`,backgroundPath:r,onHeaderChange:f,onDeleted:z},n)}),t[28]=r,t[29]=z,t[30]=n,t[31]=ee):ee=t[31];let B;t[32]!==O||t[33]!==R||t[34]!==ee||t[35]!==w?(B=(0,J.jsxs)(_,{className:`xopc-dialog-content task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,"data-workspace-panel-open":w,style:O,onEscapeKeyDown:Jt,onInteractOutside:qt,children:[R,ee]}),t[32]=O,t[33]=R,t[34]=ee,t[35]=w,t[36]=B):B=t[36];let te;t[37]!==B||t[38]!==C?(te=(0,J.jsxs)(g,{children:[C,B]}),t[37]=B,t[38]=C,t[39]=te):te=t[39];let ne;return t[40]!==b||t[41]!==te?(ne=(0,J.jsx)(y,{modal:!1,open:!0,onOpenChange:b,children:te}),t[40]=b,t[41]=te,t[42]=ne):ne=t[42],ne}function qt(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Jt(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function Yt(e){return e.setPath}function Xt(e){return e.language}function Zt(e){return(0,J.jsx)(M,{value:e.id,children:e.name||e.id},e.id)}function Qt(e){return e.id}export{Kt as TaskDetailModal,Gt as TaskDetailPage};
@@ -1 +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{m as i,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as o}from"./external-link-DjqjBmc3.js";import{t as s}from"./file-text-D12HbeVy.js";import{t as c}from"./markdown-view-BlxIaCCQ.js";import{t as l}from"./cn-0WouolD0.js";import{ft as u}from"./session-manager-D2LaQymu.js";import{t as d,u as f}from"./workspace-preview-store-Do31QQH5.js";import{t as p}from"./button-Cc4hUNTt.js";import{t as m}from"./activity-store-CQHh48Zf.js";import{m as h,o as g}from"./shares-api-Dm07CnXw.js";var _=n(),v=e(t(),1),y=r();function b(e){let t=(0,_.c)(38),{content:n,contentKey:r,language:a,markdown:o,breaks:s,previewHeight:d,className:f,children:p}=e,m=o===void 0||o,h=s!==void 0&&s,g=d===void 0?240:d,b;t[0]===n?b=t[1]:(b=u(n),t[0]=n,t[1]=b),n=b;let x=(0,v.useId)(),S=(0,v.useRef)(null),[C,w]=(0,v.useState)(!1),[T,E]=i(),D;t[2]!==r||t[3]!==T?(D=T.getAll(`taskExpanded`).includes(r),t[2]=r,t[3]=T,t[4]=D):D=t[4];let O=D,k;t[5]===g?k=t[6]:(k=()=>{let e=S.current;if(!e)return;let t=()=>w(e.scrollHeight>g);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[5]=g,t[6]=k);let A;t[7]!==n||t[8]!==g?(A=[n,g],t[7]=n,t[8]=g,t[9]=A):A=t[9],(0,v.useLayoutEffect)(k,A);let j=C&&!O,M;t[10]===f?M=t[11]:(M=l(`min-w-0`,f),t[10]=f,t[11]=M);let N;t[12]!==j||t[13]!==g?(N=j?{maxHeight:g,overflow:`hidden`,maskImage:`linear-gradient(to bottom, black calc(100% - ${Math.min(24,g/3)}px), transparent)`}:void 0,t[12]=j,t[13]=g,t[14]=N):N=t[14];let P;t[15]!==h||t[16]!==p||t[17]!==n||t[18]!==m?(P=p??(m?(0,y.jsx)(c,{content:n,compact:!0,breaks:h,className:`text-sm leading-6 text-fg`}):(0,y.jsx)(`p`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n})),t[15]=h,t[16]=p,t[17]=n,t[18]=m,t[19]=P):P=t[19];let F;t[20]!==j||t[21]!==P?(F=(0,y.jsx)(`div`,{ref:S,inert:j,children:P}),t[20]=j,t[21]=P,t[22]=F):F=t[22];let I;t[23]!==x||t[24]!==F||t[25]!==N?(I=(0,y.jsx)(`div`,{id:x,style:N,children:F}),t[23]=x,t[24]=F,t[25]=N,t[26]=I):I=t[26];let L;t[27]!==r||t[28]!==O||t[29]!==x||t[30]!==a||t[31]!==C||t[32]!==E?(L=C?(0,y.jsx)(`button`,{type:`button`,"aria-expanded":O,"aria-controls":x,className:`mt-2 min-h-9 rounded-sm text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:()=>E(e=>{let t=new URLSearchParams(e),n=t.getAll(`taskExpanded`).filter(e=>e!==r);t.delete(`taskExpanded`);for(let e of n)t.append(`taskExpanded`,e);return O||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:a===`zh`?O?`收起`:`查看更多`:O?`Show less`:`Show more`}):null,t[27]=r,t[28]=O,t[29]=x,t[30]=a,t[31]=C,t[32]=E,t[33]=L):L=t[33];let R;return t[34]!==I||t[35]!==L||t[36]!==M?(R=(0,y.jsxs)(`div`,{className:M,children:[I,L]}),t[34]=I,t[35]=L,t[36]=M,t[37]=R):R=t[37],R}function x({wait:e,detail:t,zh:n,onUpdated:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),h=(0,v.useRef)(null),g=e.kind===`approval`,_=Array.isArray(e.condition.choices)?e.condition.choices.filter(e=>typeof e==`string`):[];async function b(a){if(!g&&!i.trim()||g&&!a||o)return;let c=JSON.stringify([t.task.version,i.trim(),a]);h.current?.signature!==c&&(h.current={signature:c,key:crypto.randomUUID()}),s(!0),l(``);try{let o=await f(t.task.id,{type:`resolve_wait`,waitId:e.id,resolution:g?{kind:`task_approval`,decision:a}:{kind:`user_answer`,answer:i.trim()}},t.task.version,h.current.key);d(!0),r(o),m({tone:`success`,title:g?n?`决定已保存`:`Decision saved`:n?`补充信息已保存`:`Answer saved`,message:o.waits.length?n?`仍有其他等待条件,任务尚未恢复执行。`:`Other waiting conditions remain.`:n?`等待已解除,请在任务状态中查看后续执行进展。`:`The wait is resolved. Follow progress in the task status.`,source:n?`任务`:`Task`})}catch{l(n?`提交未确认,内容已保留。可重试;若问题已变化,请刷新。`:`Submission not confirmed. Your answer is saved here; retry or refresh if the question changed.`)}finally{s(!1)}}return(0,y.jsxs)(`form`,{className:`mt-3 space-y-3 rounded-lg border border-edge p-3`,onSubmit:e=>{e.preventDefault(),b()},children:[g?(0,y.jsxs)(`div`,{className:`text-sm text-fg`,children:[(0,y.jsx)(`p`,{children:e.reason}),(0,y.jsxs)(`p`,{className:`mt-2`,children:[n?`授权范围:`:`Permission: `,String(e.condition.capability)]}),(0,y.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,y.jsx)(p,{type:`button`,variant:`primary`,disabled:o||u,onClick:()=>void b(`approve`),children:n?`批准`:`Approve`}),(0,y.jsx)(p,{type:`button`,disabled:o||u,onClick:()=>void b(`deny`),children:n?`拒绝并暂停`:`Deny and pause`})]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`label`,{className:`block text-sm text-fg`,children:[typeof e.condition.question==`string`?e.condition.question:e.reason,(0,y.jsx)(`textarea`,{className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel p-3`,rows:3,maxLength:12e3,value:i,disabled:o||u,onChange:e=>a(e.target.value)})]}),_.length>0&&(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_.map(e=>(0,y.jsx)(p,{type:`button`,disabled:o||u,variant:`secondary`,"aria-pressed":i===e,onClick:()=>a(e),children:e},e))}),(0,y.jsx)(p,{type:`submit`,variant:`primary`,disabled:o||u||!i.trim(),children:o?n?`正在提交`:`Submitting`:n?`提交补充信息`:`Submit answer`})]}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`保存到任务上下文;其他等待条件满足后继续执行。`:`Saved to task context. Work continues once all waiting conditions are met.`}),c&&(0,y.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c})]})}function S(e,t){let n;try{n=new URL(e)}catch{return}return t.find(e=>[e.shareUrl,e.lanUrl].some(e=>{if(!e)return!1;try{let t=new URL(e);return t.origin===n.origin&&t.pathname.replace(/\/$/,``)===n.pathname.replace(/\/$/,``)}catch{return!1}}))}function C({uri:e,zh:t}){let[n,r]=(0,v.useState)(),[i,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``);async function m(){o(!0),u(``);try{let n=S(e,(await h()).payload.shares);r(n),c(!0),n?n.kind!==`file`&&n.kind!==`directory`?u(t?`这是文档快照,请从原笔记或对话的分享面板重新发布。`:`This is a document snapshot. Republish it from the original note or conversation.`):n.revoked?u(t?`分享已被撤销,不能自动恢复。请从原任务重新生成并分享。`:`This share was revoked. Generate and share a new artifact from the task.`):n.maxViews!==null&&n.downloadCount>=n.maxViews?u(t?`已达到访问次数上限,请在分享设置中调整后重试。`:`The access limit was reached. Adjust it in share settings.`):n.expired||(f(n.shareUrl),u(t?`链接仍在有效期内;若打不开,请检查网关连接。`:`The link has not expired. If it cannot open, check gateway connectivity.`)):u(t?`未找到本机管理的分享记录。外部链接或已清理的记录无法在这里续期,请从原任务重新生成产物。`:`No locally managed share matches this link. Regenerate the artifact from its task.`)}catch{u(t?`检查失败,请重试。`:`Check failed. Please retry.`)}finally{o(!1)}}async function _(){if(!(!n||i)){o(!0),u(``);try{let e=await g(n.id,864e5);f(e.payload.shareUrl),r({...n,expired:!1,expiresAt:e.payload.expiresAt}),u(t?`已续期 24 小时,访问范围与次数限制保持不变。`:`Renewed for 24 hours. Access scope and view limits are unchanged.`)}catch(e){u(`${t?`恢复失败:`:`Recovery failed: `}${e instanceof Error?e.message:String(e)}`)}finally{o(!1)}}}return(0,y.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t?`链接打不开?`:`Trouble opening the link?`}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(p,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void m(),children:t?`检查链接状态`:`Check link`}),s&&n?.expired&&(n.kind===`file`||n.kind===`directory`)&&!n.revoked&&(n.maxViews===null||n.downloadCount<n.maxViews)&&(0,y.jsx)(p,{type:`button`,disabled:i,onClick:()=>void _(),children:t?`恢复链接 · 续期 24 小时`:`Restore link for 24 hours`}),l&&(0,y.jsx)(`p`,{role:`status`,className:`break-words leading-5`,children:l}),d&&(0,y.jsx)(`a`,{className:`block py-2 text-accent`,href:d,target:`_blank`,rel:`noopener noreferrer`,children:t?`打开产物`:`Open artifact`}),s&&(0,y.jsx)(a,{className:`block py-2 text-accent`,to:`/settings/shares`,children:t?`管理分享记录`:`Manage shares`})]})]})}function w(e){let t=(0,_.c)(18),{evidence:n,projectId:r,conversationId:i,language:a,onOpenFile:c,compact:l}=e,u=l!==void 0&&l,f=d(T);if(!n.length)return null;let p=a===`zh`?`交付物与验证依据`:`Deliverables and evidence`,m;if(t[0]!==u||t[1]!==i||t[2]!==n||t[3]!==a||t[4]!==c||t[5]!==r||t[6]!==f){let e;t[8]!==u||t[9]!==i||t[10]!==a||t[11]!==c||t[12]!==r||t[13]!==f?(e=(e,t)=>{let n=e.uri?.trim(),l=n&&/^https?:\/\//i.test(n),d=n&&!l&&e.kind===`artifact`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!n.startsWith(`//`),p=e.title||(a===`zh`?`查看产物`:`Open artifact`);return(0,y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge-subtle p-3`,children:[(0,y.jsx)(b,{content:p,contentKey:`${i??r}:evidence-title:${t}:${e.title}`,language:a,previewHeight:60,children:l?(0,y.jsxs)(`a`,{className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:[(0,y.jsx)(o,{className:`size-4 shrink-0`}),(0,y.jsx)(`span`,{className:`min-w-0 break-words`,children:p})]}):d&&(r||i)?(0,y.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,onClick:()=>c?c(n):f(n,null,r,i),children:[(0,y.jsx)(s,{className:`size-4 shrink-0`}),p]}):(0,y.jsx)(`p`,{className:`break-words [overflow-wrap:anywhere] text-sm font-medium text-fg`,children:p})}),l&&e.kind===`artifact`&&(0,y.jsx)(C,{uri:n,zh:a===`zh`},n),u&&!l&&!(d&&(r||i))?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a===`zh`?`位置待确认`:`Location needs confirmation`}):null,!u&&e.summary?(0,y.jsx)(b,{content:e.summary,contentKey:`${i??r}:evidence:${t}:${e.title}`,language:a,markdown:!1,previewHeight:80,className:`mt-1 text-xs leading-5 text-fg-muted`}):null,u?null:(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.provenance===`judge`?e.strength===`verified`?a===`zh`?`模型审阅通过`:`Model reviewed`:a===`zh`?`模型未确认,待核验`:`Not confirmed by review`:e.strength===`verified`?a===`zh`?`已验证`:`Verified`:a===`zh`?`已记录,待验证`:`Observed, not verified`})]},`${e.title}-${t}`)},t[8]=u,t[9]=i,t[10]=a,t[11]=c,t[12]=r,t[13]=f,t[14]=e):e=t[14],m=n.map(e),t[0]=u,t[1]=i,t[2]=n,t[3]=a,t[4]=c,t[5]=r,t[6]=f,t[7]=m}else m=t[7];let h;return t[15]!==p||t[16]!==m?(h=(0,y.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,"aria-label":p,children:m}),t[15]=p,t[16]=m,t[17]=h):h=t[17],h}function T(e){return e.setPath}export{x as n,b as r,w as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as o}from"./external-link-DjqjBmc3.js";import{t as s}from"./file-text-D12HbeVy.js";import{t as c}from"./markdown-view-CNJaAdNN.js";import{t as l}from"./cn-0WouolD0.js";import{mt as u}from"./session-manager-63NaXb1s.js";import{t as d,u as f}from"./workspace-preview-store-imhtuEIP.js";import{t as p}from"./button-Cc4hUNTt.js";import{t as m}from"./activity-store-CQHh48Zf.js";import{m as h,o as g}from"./shares-api-Dm07CnXw.js";var _=n(),v=e(t(),1),y=r();function b(e){let t=(0,_.c)(38),{content:n,contentKey:r,language:a,markdown:o,breaks:s,previewHeight:d,className:f,children:p}=e,m=o===void 0||o,h=s!==void 0&&s,g=d===void 0?240:d,b;t[0]===n?b=t[1]:(b=u(n),t[0]=n,t[1]=b),n=b;let x=(0,v.useId)(),S=(0,v.useRef)(null),[C,w]=(0,v.useState)(!1),[T,E]=i(),D;t[2]!==r||t[3]!==T?(D=T.getAll(`taskExpanded`).includes(r),t[2]=r,t[3]=T,t[4]=D):D=t[4];let O=D,k;t[5]===g?k=t[6]:(k=()=>{let e=S.current;if(!e)return;let t=()=>w(e.scrollHeight>g);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[5]=g,t[6]=k);let A;t[7]!==n||t[8]!==g?(A=[n,g],t[7]=n,t[8]=g,t[9]=A):A=t[9],(0,v.useLayoutEffect)(k,A);let j=C&&!O,M;t[10]===f?M=t[11]:(M=l(`min-w-0`,f),t[10]=f,t[11]=M);let N;t[12]!==j||t[13]!==g?(N=j?{maxHeight:g,overflow:`hidden`,maskImage:`linear-gradient(to bottom, black calc(100% - ${Math.min(24,g/3)}px), transparent)`}:void 0,t[12]=j,t[13]=g,t[14]=N):N=t[14];let P;t[15]!==h||t[16]!==p||t[17]!==n||t[18]!==m?(P=p??(m?(0,y.jsx)(c,{content:n,compact:!0,breaks:h,className:`text-sm leading-6 text-fg`}):(0,y.jsx)(`p`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n})),t[15]=h,t[16]=p,t[17]=n,t[18]=m,t[19]=P):P=t[19];let F;t[20]!==j||t[21]!==P?(F=(0,y.jsx)(`div`,{ref:S,inert:j,children:P}),t[20]=j,t[21]=P,t[22]=F):F=t[22];let I;t[23]!==x||t[24]!==F||t[25]!==N?(I=(0,y.jsx)(`div`,{id:x,style:N,children:F}),t[23]=x,t[24]=F,t[25]=N,t[26]=I):I=t[26];let L;t[27]!==r||t[28]!==O||t[29]!==x||t[30]!==a||t[31]!==C||t[32]!==E?(L=C?(0,y.jsx)(`button`,{type:`button`,"aria-expanded":O,"aria-controls":x,className:`mt-2 min-h-9 rounded-sm text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:()=>E(e=>{let t=new URLSearchParams(e),n=t.getAll(`taskExpanded`).filter(e=>e!==r);t.delete(`taskExpanded`);for(let e of n)t.append(`taskExpanded`,e);return O||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:a===`zh`?O?`收起`:`查看更多`:O?`Show less`:`Show more`}):null,t[27]=r,t[28]=O,t[29]=x,t[30]=a,t[31]=C,t[32]=E,t[33]=L):L=t[33];let R;return t[34]!==I||t[35]!==L||t[36]!==M?(R=(0,y.jsxs)(`div`,{className:M,children:[I,L]}),t[34]=I,t[35]=L,t[36]=M,t[37]=R):R=t[37],R}function x({wait:e,detail:t,zh:n,onUpdated:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),h=(0,v.useRef)(null),g=e.kind===`approval`,_=Array.isArray(e.condition.choices)?e.condition.choices.filter(e=>typeof e==`string`):[];async function b(a){if(!g&&!i.trim()||g&&!a||o)return;let c=JSON.stringify([t.task.version,i.trim(),a]);h.current?.signature!==c&&(h.current={signature:c,key:crypto.randomUUID()}),s(!0),l(``);try{let o=await f(t.task.id,{type:`resolve_wait`,waitId:e.id,resolution:g?{kind:`task_approval`,decision:a}:{kind:`user_answer`,answer:i.trim()}},t.task.version,h.current.key);d(!0),r(o),m({tone:`success`,title:g?n?`决定已保存`:`Decision saved`:n?`补充信息已保存`:`Answer saved`,message:o.waits.length?n?`仍有其他等待条件,任务尚未恢复执行。`:`Other waiting conditions remain.`:n?`等待已解除,请在任务状态中查看后续执行进展。`:`The wait is resolved. Follow progress in the task status.`,source:n?`任务`:`Task`})}catch{l(n?`提交未确认,内容已保留。可重试;若问题已变化,请刷新。`:`Submission not confirmed. Your answer is saved here; retry or refresh if the question changed.`)}finally{s(!1)}}return(0,y.jsxs)(`form`,{className:`mt-3 space-y-3 rounded-lg border border-edge p-3`,onSubmit:e=>{e.preventDefault(),b()},children:[g?(0,y.jsxs)(`div`,{className:`text-sm text-fg`,children:[(0,y.jsx)(`p`,{children:e.reason}),(0,y.jsxs)(`p`,{className:`mt-2`,children:[n?`授权范围:`:`Permission: `,String(e.condition.capability)]}),(0,y.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,y.jsx)(p,{type:`button`,variant:`primary`,disabled:o||u,onClick:()=>void b(`approve`),children:n?`批准`:`Approve`}),(0,y.jsx)(p,{type:`button`,disabled:o||u,onClick:()=>void b(`deny`),children:n?`拒绝并暂停`:`Deny and pause`})]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`label`,{className:`block text-sm text-fg`,children:[typeof e.condition.question==`string`?e.condition.question:e.reason,(0,y.jsx)(`textarea`,{className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel p-3`,rows:3,maxLength:12e3,value:i,disabled:o||u,onChange:e=>a(e.target.value)})]}),_.length>0&&(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_.map(e=>(0,y.jsx)(p,{type:`button`,disabled:o||u,variant:`secondary`,"aria-pressed":i===e,onClick:()=>a(e),children:e},e))}),(0,y.jsx)(p,{type:`submit`,variant:`primary`,disabled:o||u||!i.trim(),children:o?n?`正在提交`:`Submitting`:n?`提交补充信息`:`Submit answer`})]}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`保存到任务上下文;其他等待条件满足后继续执行。`:`Saved to task context. Work continues once all waiting conditions are met.`}),c&&(0,y.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c})]})}function S(e,t){let n;try{n=new URL(e)}catch{return}return t.find(e=>[e.shareUrl,e.lanUrl].some(e=>{if(!e)return!1;try{let t=new URL(e);return t.origin===n.origin&&t.pathname.replace(/\/$/,``)===n.pathname.replace(/\/$/,``)}catch{return!1}}))}function C({uri:e,zh:t}){let[n,r]=(0,v.useState)(),[i,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``);async function m(){o(!0),u(``);try{let n=S(e,(await h()).payload.shares);r(n),c(!0),n?n.kind!==`file`&&n.kind!==`directory`?u(t?`这是文档快照,请从原笔记或对话的分享面板重新发布。`:`This is a document snapshot. Republish it from the original note or conversation.`):n.revoked?u(t?`分享已被撤销,不能自动恢复。请从原任务重新生成并分享。`:`This share was revoked. Generate and share a new artifact from the task.`):n.maxViews!==null&&n.downloadCount>=n.maxViews?u(t?`已达到访问次数上限,请在分享设置中调整后重试。`:`The access limit was reached. Adjust it in share settings.`):n.expired||(f(n.shareUrl),u(t?`链接仍在有效期内;若打不开,请检查网关连接。`:`The link has not expired. If it cannot open, check gateway connectivity.`)):u(t?`未找到本机管理的分享记录。外部链接或已清理的记录无法在这里续期,请从原任务重新生成产物。`:`No locally managed share matches this link. Regenerate the artifact from its task.`)}catch{u(t?`检查失败,请重试。`:`Check failed. Please retry.`)}finally{o(!1)}}async function _(){if(!(!n||i)){o(!0),u(``);try{let e=await g(n.id,864e5);f(e.payload.shareUrl),r({...n,expired:!1,expiresAt:e.payload.expiresAt}),u(t?`已续期 24 小时,访问范围与次数限制保持不变。`:`Renewed for 24 hours. Access scope and view limits are unchanged.`)}catch(e){u(`${t?`恢复失败:`:`Recovery failed: `}${e instanceof Error?e.message:String(e)}`)}finally{o(!1)}}}return(0,y.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t?`链接打不开?`:`Trouble opening the link?`}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(p,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void m(),children:t?`检查链接状态`:`Check link`}),s&&n?.expired&&(n.kind===`file`||n.kind===`directory`)&&!n.revoked&&(n.maxViews===null||n.downloadCount<n.maxViews)&&(0,y.jsx)(p,{type:`button`,disabled:i,onClick:()=>void _(),children:t?`恢复链接 · 续期 24 小时`:`Restore link for 24 hours`}),l&&(0,y.jsx)(`p`,{role:`status`,className:`break-words leading-5`,children:l}),d&&(0,y.jsx)(`a`,{className:`block py-2 text-accent`,href:d,target:`_blank`,rel:`noopener noreferrer`,children:t?`打开产物`:`Open artifact`}),s&&(0,y.jsx)(a,{className:`block py-2 text-accent`,to:`/settings/shares`,children:t?`管理分享记录`:`Manage shares`})]})]})}function w(e){let t=(0,_.c)(18),{evidence:n,projectId:r,conversationId:i,language:a,onOpenFile:c,compact:l}=e,u=l!==void 0&&l,f=d(T);if(!n.length)return null;let p=a===`zh`?`交付物与验证依据`:`Deliverables and evidence`,m;if(t[0]!==u||t[1]!==i||t[2]!==n||t[3]!==a||t[4]!==c||t[5]!==r||t[6]!==f){let e;t[8]!==u||t[9]!==i||t[10]!==a||t[11]!==c||t[12]!==r||t[13]!==f?(e=(e,t)=>{let n=e.uri?.trim(),l=n&&/^https?:\/\//i.test(n),d=n&&!l&&e.kind===`artifact`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!n.startsWith(`//`),p=e.title||(a===`zh`?`查看产物`:`Open artifact`);return(0,y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge-subtle p-3`,children:[(0,y.jsx)(b,{content:p,contentKey:`${i??r}:evidence-title:${t}:${e.title}`,language:a,previewHeight:60,children:l?(0,y.jsxs)(`a`,{className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:[(0,y.jsx)(o,{className:`size-4 shrink-0`}),(0,y.jsx)(`span`,{className:`min-w-0 break-words`,children:p})]}):d&&(r||i)?(0,y.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,onClick:()=>c?c(n):f(n,null,r,i),children:[(0,y.jsx)(s,{className:`size-4 shrink-0`}),p]}):(0,y.jsx)(`p`,{className:`break-words [overflow-wrap:anywhere] text-sm font-medium text-fg`,children:p})}),l&&e.kind===`artifact`&&(0,y.jsx)(C,{uri:n,zh:a===`zh`},n),u&&!l&&!(d&&(r||i))?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a===`zh`?`位置待确认`:`Location needs confirmation`}):null,!u&&e.summary?(0,y.jsx)(b,{content:e.summary,contentKey:`${i??r}:evidence:${t}:${e.title}`,language:a,markdown:!1,previewHeight:80,className:`mt-1 text-xs leading-5 text-fg-muted`}):null,u?null:(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.provenance===`judge`?e.strength===`verified`?a===`zh`?`模型审阅通过`:`Model reviewed`:a===`zh`?`模型未确认,待核验`:`Not confirmed by review`:e.strength===`verified`?a===`zh`?`已验证`:`Verified`:a===`zh`?`已记录,待验证`:`Observed, not verified`})]},`${e.title}-${t}`)},t[8]=u,t[9]=i,t[10]=a,t[11]=c,t[12]=r,t[13]=f,t[14]=e):e=t[14],m=n.map(e),t[0]=u,t[1]=i,t[2]=n,t[3]=a,t[4]=c,t[5]=r,t[6]=f,t[7]=m}else m=t[7];let h;return t[15]!==p||t[16]!==m?(h=(0,y.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,"aria-label":p,children:m}),t[15]=p,t[16]=m,t[17]=h):h=t[17],h}function T(e){return e.setPath}export{x as n,b as r,w as t};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-load-DrVGNxJm.js","assets/rolldown-runtime-aKtaBQYM.js","assets/attachment-utils-core-BIOUBrpT.js"])))=>i.map(i=>d[i]);
2
- 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"./preload-helper-Czpn1I53.js";import{n as a}from"./locale-store-Dy1EByeG.js";import{t as o}from"./messages-BAnhwALN.js";import{o as s,r as c,s as l,t as u}from"./dist-CY7CS_D3.js";import{t as d}from"./chevron-left-DqFhpbvK.js";import{t as f}from"./chevron-right-BweFrslA.js";import{n as p,t as m}from"./file-BqMS_3DT.js";import{a as h,b as g,l as _,n as v,t as y}from"./use-file-preview-expanded-BXXeXnT0.js";import{t as b}from"./mic-CuUb7zc-.js";import{n as x}from"./share-link-dialog-C1t_HB6f.js";import{t as S}from"./cn-0WouolD0.js";import{r as C,t as w}from"./constants-DpkUgykJ.js";import{r as T}from"./attachment-utils-core-BIOUBrpT.js";import{n as E}from"./right-workspace-store-HPw7Gw0n.js";import{n as D}from"./interaction-BdhHBbYa.js";import{t as O}from"./composer-notifications-CqV6Xj-H.js";import{n as k}from"./electron-env-DHOGevH3.js";import{i as A}from"./skill-wire-pattern-BPpeIcCi.js";import{a as j,n as ee,t as M}from"./file-preview-surface-i5UOFnQF.js";function N(e,t){let n=e.trim(),r=t.trim();return n&&A(n)?`/skill:${n}${r?` ${r}`:` `}`:r||null}function P(e,t,n){let r=e.trim(),i=t?.trim()??``;if(!r&&!i)return null;let a=new URLSearchParams;return r&&a.set(`draft`,r),a.set(`autoSend`,`1`),i&&a.set(`attachmentsHandoff`,i),n?.projectScope===`none`&&a.set(`projectScope`,`none`),`/chat/new?${a.toString()}`}function F(e){let t=e.startsWith(`?`)?e.slice(1):e;if(!t)return``;let n=new URLSearchParams(t),r=new URLSearchParams,i=n.get(`skill`),a=n.get(`slash`),o=n.get(`draft`),s=n.get(`autoSend`),c=n.get(`attachmentHandoff`),l=n.get(`attachmentsHandoff`),u=n.get(`agentSetup`);i&&r.set(`skill`,i),a&&r.set(`slash`,a),o&&r.set(`draft`,o),s===`1`&&r.set(`autoSend`,`1`),c&&r.set(`attachmentHandoff`,c),l&&r.set(`attachmentsHandoff`,l),n.get(`setup`)===`automation`&&r.set(`setup`,`automation`),u===`1`&&r.set(`agentSetup`,`1`),n.get(`scene`)===`find-skills`&&r.set(`scene`,`find-skills`);let d=r.toString();return d?`?${d}`:``}function I(e){let t=e.startsWith(`?`)?e.slice(1):e,n=new URLSearchParams(t),r=n.get(`projectId`)?.trim();return r?{kind:`project`,projectId:r}:n.get(`projectScope`)===`none`?{kind:`none`}:{kind:`remember-last`}}function L(e){let t=e?.trim();return t?`/chat/new?projectId=${encodeURIComponent(t)}`:`/chat/new?projectScope=none`}var R=n(),z=e(t(),1),B=r();function V(e){let t=(0,R.c)(6),n=g(),r,i;if(t[0]!==n||t[1]!==e?(r=()=>{!n||e.embedded||!e.open||!e.attachment||(E.getState().openFile({attachment:e.attachment,images:e.images,conversationId:e.conversationId||void 0,resultRevision:e.resultRevision},n),e.onClose())},i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),(0,z.useEffect)(r,i),n&&!e.embedded)return null;let a;return t[4]===e?a=t[5]:(a=(0,B.jsx)(H,{...e}),t[4]=e,t[5]=a),a}function H({open:e,embedded:t=!1,tabId:n,attachment:r,images:i=[],resultRevision:p,onAttachmentChange:m,authToken:h,conversationId:g,layerClassName:b=`z-[115]`,onClose:w}){let T=a(e=>e.language),E=o(T).chat,A=_({open:e,attachment:r,authToken:h,conversationId:g,language:T}),N=j(),{expanded:P,setExpanded:F}=y(e,N.dialogOpen),[I,L]=(0,z.useState)(!1),{preview:R,fileType:V,hasExtractedText:H}=A,U=r?i.findIndex(e=>e===r||e.id&&e.id===r.id||e.uri&&e.uri===r.uri||!e.id&&!e.uri&&e.name===r.name&&!!e.data&&e.data===r.data):-1,W=V===`image`&&i.length>1&&U>=0&&!!m,G=e=>{if(!W||N.dialogOpen)return;let t=U+(e===`previous`?-1:1);t>=0&&t<i.length&&m?.(i[t])},K=V!==`image`&&V!==`text`&&V!==`pptx`&&H,q=R?.uri?C(R.uri):null,J=!!(q||R?.uri?.startsWith(`media://`)&&(g||R.taskId)),Y=()=>{!R?.uri||!J||N.createShareLink(q?{fileId:q,fileName:R.name}:{uri:R.uri,conversationId:g??void 0,taskId:R.taskId,fileName:R.name})},X=!!(R&&!A.loading&&!A.loadError),Z=()=>{F(!1),w()},te=()=>{if(!R||!A.downloadBuffer)return;let e=new Blob([A.downloadBuffer],{type:A.descriptor.mimeType}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=R.name??`download`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},ne=!!A.downloadBuffer,re=k()&&V===`spreadsheet`&&/\.xlsx?$/i.test(A.fileName)&&!!A.downloadBuffer&&!!window.electronAPI?.shell?.openTemporaryFile,ie=async()=>{let e=A.downloadBuffer,t=window.electronAPI?.shell?.openTemporaryFile;if(!(!e||!t||I)){L(!0);try{(await t({fileName:A.fileName,data:new Uint8Array(e)})).ok||O(`warning`,E.attachmentPreviewOpenLocalFailed)}catch{O(`warning`,E.attachmentPreviewOpenLocalFailed)}finally{L(!1)}}},ae={onDownload:te,canDownload:ne},Q=S(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,D.focusRingBase),$=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(v,{header:{expanded:P,onToggleExpanded:X?()=>F(e=>!e):void 0,hideClose:t,hideExpand:!!n,onClose:Z,share:J?{onClick:Y,loading:N.loading}:void 0,openWithSystemApp:re?{onClick:()=>void ie(),loading:I}:void 0,textView:K?{active:A.showExtractedText,onChange:e=>{A.setShowExtractedText(e),A.clearLoadError()}}:void 0},chat:A.downloadBuffer?{conversationId:g,createFile:async()=>new File([A.downloadBuffer],A.fileName,{type:A.descriptor.mimeType})}:void 0,onImageSwipe:W?G:void 0,language:T,descriptor:n?{...A.descriptor,id:n}:A.descriptor,loading:A.loading,loadError:A.loadError,textContent:A.textContent,binaryBuffer:A.binaryBuffer,showExtractedText:A.showExtractedText,extractedText:A.extractedText,extractedTextTruncated:A.extractedTextTruncated,actions:ae}),p?(0,B.jsxs)(`p`,{className:`shrink-0 border-t border-edge px-4 py-2 text-xs text-fg-muted`,"data-result-revision":!0,children:[T===`zh`?`成果版本`:`Result version`,` `,p]}):null,W?(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-center gap-4 border-t border-edge bg-surface-panel px-3 py-2`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":E.attachmentPreviewPreviousImage,disabled:U===0,onClick:()=>G(`previous`),className:S(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,D.focusRingBase),children:(0,B.jsx)(d,{size:20,"aria-hidden":`true`})}),(0,B.jsxs)(`span`,{role:`status`,className:`min-w-16 text-center text-sm tabular-nums text-fg-muted`,children:[U+1,` / `,i.length]}),(0,B.jsx)(`button`,{type:`button`,"aria-label":E.attachmentPreviewNextImage,disabled:U===i.length-1,onClick:()=>G(`next`),className:S(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,D.focusRingBase),children:(0,B.jsx)(f,{size:20,"aria-hidden":`true`})})]}):null]});return t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(M,{expanded:P,children:$}),(0,B.jsx)(x,{open:N.dialogOpen,onOpenChange:N.handleOpenChange,loading:N.loading,error:N.error,result:N.result,pendingParams:N.pendingParams,onConfirm:e=>void N.confirmShareLink(e)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(u,{open:e,onOpenChange:e=>!e&&Z(),children:(0,B.jsx)(s,{children:(0,B.jsxs)(c,{"aria-describedby":void 0,onKeyDown:e=>{!W||N.dialogOpen||e.altKey||e.ctrlKey||e.metaKey||e.target.closest(`input, textarea, select, [contenteditable="true"]`)||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),G(e.key===`ArrowLeft`?`previous`:`next`))},className:S(`xopc-dialog-content-fullscreen fixed inset-0 flex h-[100dvh] w-full flex-row overflow-hidden`,ee(),b,`border-0 bg-transparent p-0 shadow-none outline-none`),children:[(0,B.jsx)(l,{className:`sr-only`,children:R?.name??``}),(0,B.jsx)(`button`,{type:`button`,className:Q,onClick:Z,"aria-label":E.attachmentPreviewClose}),(0,B.jsx)(`div`,{className:S(`flex h-full min-h-0 shrink-0 flex-col overflow-hidden`,P?`w-full`:`w-[min(100%,var(--max-width-app-main))]`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),children:$}),(0,B.jsx)(`button`,{type:`button`,className:Q,onClick:Z,"aria-label":E.attachmentPreviewClose})]})})}),(0,B.jsx)(x,{open:N.dialogOpen,onOpenChange:N.handleOpenChange,loading:N.loading,error:N.error,result:N.result,pendingParams:N.pendingParams,onConfirm:e=>void N.confirmShareLink(e)})]})}function U(e){let t=(0,R.c)(23),{attachments:n,conversationId:r,topPadded:i,onRemove:s,className:c}=e,l=a(W),u;t[0]===l?u=t[1]:(u=o(l),t[0]=l,t[1]=u);let d=u.chat,[f,h]=(0,z.useState)(null);if(n.length===0)return null;let g=i?`pt-2`:`pt-3`,_;t[2]!==c||t[3]!==g?(_=S(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,g,c),t[2]=c,t[3]=g,t[4]=_):_=t[4];let v;if(t[5]!==n||t[6]!==d||t[7]!==s){let e;t[9]!==d||t[10]!==s?(e=(e,t)=>{let n=e.type===`pasted_text`?d.pastedText:e.name;return(0,B.jsxs)(`div`,{className:`flex max-w-[200px] items-center rounded-lg bg-surface-hover text-xs dark:bg-surface-hover/80`,children:[(0,B.jsxs)(`button`,{type:`button`,className:S(`flex min-w-0 flex-1 items-center gap-1.5 rounded-l-lg py-1 pl-2 pr-1 text-left hover:bg-surface-active`,D.transition,D.press,D.focusRingPanel),onClick:()=>h(e),"aria-label":`${d.attachmentPreviewOpen}: ${n}`,title:`${d.attachmentPreviewOpen}: ${n}`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,B.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 shrink-0 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,B.jsx)(b,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.type===`pasted_text`?(0,B.jsx)(p,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,B.jsx)(m,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(0,B.jsx)(`span`,{className:`shrink-0 text-fg-disabled`,children:T(e.size)})]}),(0,B.jsx)(`button`,{type:`button`,className:S(`flex min-h-8 min-w-8 items-center justify-center rounded-r-lg text-fg-muted hover:bg-surface-active hover:text-fg`,D.transition,D.press,D.focusRingPanel),onClick:()=>s(t),"aria-label":`${d.attachmentPreviewRemove}: ${n}`,title:`${d.attachmentPreviewRemove}: ${n}`,children:(0,B.jsx)(`span`,{"aria-hidden":!0,children:`×`})})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`)},t[9]=d,t[10]=s,t[11]=e):e=t[11],v=n.map(e),t[5]=n,t[6]=d,t[7]=s,t[8]=v}else v=t[8];let y;t[12]!==_||t[13]!==v?(y=(0,B.jsx)(`div`,{className:_,children:v}),t[12]=_,t[13]=v,t[14]=y):y=t[14];let x=f!==null,C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>h(null),t[15]=C):C=t[15];let w;t[16]!==r||t[17]!==f||t[18]!==x?(w=(0,B.jsx)(V,{open:x,attachment:f,conversationId:r,onClose:C}),t[16]=r,t[17]=f,t[18]=x,t[19]=w):w=t[19];let E;return t[20]!==y||t[21]!==w?(E=(0,B.jsxs)(B.Fragment,{children:[y,w]}),t[20]=y,t[21]=w,t[22]=E):E=t[22],E}function W(e){return e.language}function G(e){let{chat:t,initialAttachments:n=[],onAttachmentsChange:r}=e,[a,o]=(0,z.useState)(n),[s,c]=(0,z.useState)(!1),l=(0,z.useRef)(null),u=(0,z.useRef)(a),d=(0,z.useRef)(r);u.current=a,d.current=r;let f=(0,z.useCallback)(e=>{let t=typeof e==`function`?e(u.current):e;u.current=t,o(t),d.current?.(t)},[]),p=(0,z.useCallback)(()=>{f([])},[]),m=(0,z.useCallback)(e=>{f(t=>t.filter((t,n)=>n!==e))},[]),g=(0,z.useCallback)(()=>u.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]),_=(0,z.useCallback)(async(e,n)=>{if(e.length===0)return;let r=10-u.current.length;if(r<=0){O(`warning`,t.maxAttachmentsReached,{max:10});return}let a=e.slice(0,r);e.length>a.length&&O(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-a.length});let{loadAttachment:o}=await i(async()=>{let{loadAttachment:e}=await import(`./attachment-load-DrVGNxJm.js`).then(e=>e.t);return{loadAttachment:e}},__vite__mapDeps([0,1,2])),s=(await Promise.all(a.map(async e=>{if(e.size>33554432)return O(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:T(w)}),null;try{return await o(e,e.name)}catch{return O(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null).map(e=>n?{...e,type:n}:e);f(e=>[...e,...s])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]),v=(0,z.useCallback)(e=>_(e),[_]);return(0,z.useEffect)(()=>{if(e.conversationId)return h(e.conversationId,async e=>{let t=u.current.length;return await _([e]),u.current.length>t})},[_,e.conversationId]),{attachments:a,setAttachments:f,attachmentsRef:u,isDragging:s,setIsDragging:c,fileInputRef:l,processFiles:v,processPastedText:(0,z.useCallback)(e=>_([new File([e.text],e.name,{type:e.mimeType})],`pasted_text`),[_]),removeAttachment:m,clearAttachments:p,wireAttachmentsPayload:g}}export{P as a,F as c,N as i,U as n,L as o,V as r,I as s,G as t};
2
+ 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"./preload-helper-Czpn1I53.js";import{n as a}from"./locale-store-Dy1EByeG.js";import{t as o}from"./messages-BAnhwALN.js";import{o as s,r as c,s as l,t as u}from"./dist-CY7CS_D3.js";import{t as d}from"./chevron-left-DqFhpbvK.js";import{t as f}from"./chevron-right-BweFrslA.js";import{n as p,t as m}from"./file-BqMS_3DT.js";import{a as h,b as g,l as _,n as v,t as y}from"./use-file-preview-expanded-D0IBFhM9.js";import{t as b}from"./mic-CuUb7zc-.js";import{n as x}from"./share-link-dialog-C1t_HB6f.js";import{t as S}from"./cn-0WouolD0.js";import{r as C,t as w}from"./constants-Bg1wM2nv.js";import{r as T}from"./attachment-utils-core-BIOUBrpT.js";import{n as E}from"./right-workspace-store-HPw7Gw0n.js";import{n as D}from"./interaction-BdhHBbYa.js";import{t as O}from"./composer-notifications-CqV6Xj-H.js";import{n as k}from"./electron-env-DHOGevH3.js";import{i as A}from"./skill-wire-pattern-BPpeIcCi.js";import{a as j,n as ee,t as M}from"./file-preview-surface-i5UOFnQF.js";function N(e,t){let n=e.trim(),r=t.trim();return n&&A(n)?`/skill:${n}${r?` ${r}`:` `}`:r||null}function P(e,t,n){let r=e.trim(),i=t?.trim()??``;if(!r&&!i)return null;let a=new URLSearchParams;return r&&a.set(`draft`,r),a.set(`autoSend`,`1`),i&&a.set(`attachmentsHandoff`,i),n?.projectScope===`none`&&a.set(`projectScope`,`none`),`/chat/new?${a.toString()}`}function F(e){let t=e.startsWith(`?`)?e.slice(1):e;if(!t)return``;let n=new URLSearchParams(t),r=new URLSearchParams,i=n.get(`skill`),a=n.get(`slash`),o=n.get(`draft`),s=n.get(`autoSend`),c=n.get(`attachmentHandoff`),l=n.get(`attachmentsHandoff`),u=n.get(`agentSetup`);i&&r.set(`skill`,i),a&&r.set(`slash`,a),o&&r.set(`draft`,o),s===`1`&&r.set(`autoSend`,`1`),c&&r.set(`attachmentHandoff`,c),l&&r.set(`attachmentsHandoff`,l),n.get(`setup`)===`automation`&&r.set(`setup`,`automation`),u===`1`&&r.set(`agentSetup`,`1`),n.get(`scene`)===`find-skills`&&r.set(`scene`,`find-skills`);let d=r.toString();return d?`?${d}`:``}function I(e){let t=e.startsWith(`?`)?e.slice(1):e,n=new URLSearchParams(t),r=n.get(`projectId`)?.trim();return r?{kind:`project`,projectId:r}:n.get(`projectScope`)===`none`?{kind:`none`}:{kind:`remember-last`}}function L(e){let t=e?.trim();return t?`/chat/new?projectId=${encodeURIComponent(t)}`:`/chat/new?projectScope=none`}var R=n(),z=e(t(),1),B=r();function V(e){let t=(0,R.c)(6),n=g(),r,i;if(t[0]!==n||t[1]!==e?(r=()=>{!n||e.embedded||!e.open||!e.attachment||(E.getState().openFile({attachment:e.attachment,images:e.images,conversationId:e.conversationId||void 0,resultRevision:e.resultRevision},n),e.onClose())},i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),(0,z.useEffect)(r,i),n&&!e.embedded)return null;let a;return t[4]===e?a=t[5]:(a=(0,B.jsx)(H,{...e}),t[4]=e,t[5]=a),a}function H({open:e,embedded:t=!1,tabId:n,attachment:r,images:i=[],resultRevision:p,onAttachmentChange:m,authToken:h,conversationId:g,layerClassName:b=`z-[115]`,onClose:w}){let T=a(e=>e.language),E=o(T).chat,A=_({open:e,attachment:r,authToken:h,conversationId:g,language:T}),N=j(),{expanded:P,setExpanded:F}=y(e,N.dialogOpen),[I,L]=(0,z.useState)(!1),{preview:R,fileType:V,hasExtractedText:H}=A,U=r?i.findIndex(e=>e===r||e.id&&e.id===r.id||e.uri&&e.uri===r.uri||!e.id&&!e.uri&&e.name===r.name&&!!e.data&&e.data===r.data):-1,W=V===`image`&&i.length>1&&U>=0&&!!m,G=e=>{if(!W||N.dialogOpen)return;let t=U+(e===`previous`?-1:1);t>=0&&t<i.length&&m?.(i[t])},K=V!==`image`&&V!==`text`&&V!==`pptx`&&H,q=R?.uri?C(R.uri):null,J=!!(q||R?.uri?.startsWith(`media://`)&&(g||R.taskId)),Y=()=>{!R?.uri||!J||N.createShareLink(q?{fileId:q,fileName:R.name}:{uri:R.uri,conversationId:g??void 0,taskId:R.taskId,fileName:R.name})},X=!!(R&&!A.loading&&!A.loadError),Z=()=>{F(!1),w()},te=()=>{if(!R||!A.downloadBuffer)return;let e=new Blob([A.downloadBuffer],{type:A.descriptor.mimeType}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=R.name??`download`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},ne=!!A.downloadBuffer,re=k()&&V===`spreadsheet`&&/\.xlsx?$/i.test(A.fileName)&&!!A.downloadBuffer&&!!window.electronAPI?.shell?.openTemporaryFile,ie=async()=>{let e=A.downloadBuffer,t=window.electronAPI?.shell?.openTemporaryFile;if(!(!e||!t||I)){L(!0);try{(await t({fileName:A.fileName,data:new Uint8Array(e)})).ok||O(`warning`,E.attachmentPreviewOpenLocalFailed)}catch{O(`warning`,E.attachmentPreviewOpenLocalFailed)}finally{L(!1)}}},ae={onDownload:te,canDownload:ne},Q=S(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,D.focusRingBase),$=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(v,{header:{expanded:P,onToggleExpanded:X?()=>F(e=>!e):void 0,hideClose:t,hideExpand:!!n,onClose:Z,share:J?{onClick:Y,loading:N.loading}:void 0,openWithSystemApp:re?{onClick:()=>void ie(),loading:I}:void 0,textView:K?{active:A.showExtractedText,onChange:e=>{A.setShowExtractedText(e),A.clearLoadError()}}:void 0},chat:A.downloadBuffer?{conversationId:g,createFile:async()=>new File([A.downloadBuffer],A.fileName,{type:A.descriptor.mimeType})}:void 0,onImageSwipe:W?G:void 0,language:T,descriptor:n?{...A.descriptor,id:n}:A.descriptor,loading:A.loading,loadError:A.loadError,textContent:A.textContent,binaryBuffer:A.binaryBuffer,showExtractedText:A.showExtractedText,extractedText:A.extractedText,extractedTextTruncated:A.extractedTextTruncated,actions:ae}),p?(0,B.jsxs)(`p`,{className:`shrink-0 border-t border-edge px-4 py-2 text-xs text-fg-muted`,"data-result-revision":!0,children:[T===`zh`?`成果版本`:`Result version`,` `,p]}):null,W?(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-center gap-4 border-t border-edge bg-surface-panel px-3 py-2`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":E.attachmentPreviewPreviousImage,disabled:U===0,onClick:()=>G(`previous`),className:S(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,D.focusRingBase),children:(0,B.jsx)(d,{size:20,"aria-hidden":`true`})}),(0,B.jsxs)(`span`,{role:`status`,className:`min-w-16 text-center text-sm tabular-nums text-fg-muted`,children:[U+1,` / `,i.length]}),(0,B.jsx)(`button`,{type:`button`,"aria-label":E.attachmentPreviewNextImage,disabled:U===i.length-1,onClick:()=>G(`next`),className:S(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,D.focusRingBase),children:(0,B.jsx)(f,{size:20,"aria-hidden":`true`})})]}):null]});return t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(M,{expanded:P,children:$}),(0,B.jsx)(x,{open:N.dialogOpen,onOpenChange:N.handleOpenChange,loading:N.loading,error:N.error,result:N.result,pendingParams:N.pendingParams,onConfirm:e=>void N.confirmShareLink(e)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(u,{open:e,onOpenChange:e=>!e&&Z(),children:(0,B.jsx)(s,{children:(0,B.jsxs)(c,{"aria-describedby":void 0,onKeyDown:e=>{!W||N.dialogOpen||e.altKey||e.ctrlKey||e.metaKey||e.target.closest(`input, textarea, select, [contenteditable="true"]`)||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),G(e.key===`ArrowLeft`?`previous`:`next`))},className:S(`xopc-dialog-content-fullscreen fixed inset-0 flex h-[100dvh] w-full flex-row overflow-hidden`,ee(),b,`border-0 bg-transparent p-0 shadow-none outline-none`),children:[(0,B.jsx)(l,{className:`sr-only`,children:R?.name??``}),(0,B.jsx)(`button`,{type:`button`,className:Q,onClick:Z,"aria-label":E.attachmentPreviewClose}),(0,B.jsx)(`div`,{className:S(`flex h-full min-h-0 shrink-0 flex-col overflow-hidden`,P?`w-full`:`w-[min(100%,var(--max-width-app-main))]`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),children:$}),(0,B.jsx)(`button`,{type:`button`,className:Q,onClick:Z,"aria-label":E.attachmentPreviewClose})]})})}),(0,B.jsx)(x,{open:N.dialogOpen,onOpenChange:N.handleOpenChange,loading:N.loading,error:N.error,result:N.result,pendingParams:N.pendingParams,onConfirm:e=>void N.confirmShareLink(e)})]})}function U(e){let t=(0,R.c)(23),{attachments:n,conversationId:r,topPadded:i,onRemove:s,className:c}=e,l=a(W),u;t[0]===l?u=t[1]:(u=o(l),t[0]=l,t[1]=u);let d=u.chat,[f,h]=(0,z.useState)(null);if(n.length===0)return null;let g=i?`pt-2`:`pt-3`,_;t[2]!==c||t[3]!==g?(_=S(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,g,c),t[2]=c,t[3]=g,t[4]=_):_=t[4];let v;if(t[5]!==n||t[6]!==d||t[7]!==s){let e;t[9]!==d||t[10]!==s?(e=(e,t)=>{let n=e.type===`pasted_text`?d.pastedText:e.name;return(0,B.jsxs)(`div`,{className:`flex max-w-[200px] items-center rounded-lg bg-surface-hover text-xs dark:bg-surface-hover/80`,children:[(0,B.jsxs)(`button`,{type:`button`,className:S(`flex min-w-0 flex-1 items-center gap-1.5 rounded-l-lg py-1 pl-2 pr-1 text-left hover:bg-surface-active`,D.transition,D.press,D.focusRingPanel),onClick:()=>h(e),"aria-label":`${d.attachmentPreviewOpen}: ${n}`,title:`${d.attachmentPreviewOpen}: ${n}`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,B.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 shrink-0 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,B.jsx)(b,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.type===`pasted_text`?(0,B.jsx)(p,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,B.jsx)(m,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(0,B.jsx)(`span`,{className:`shrink-0 text-fg-disabled`,children:T(e.size)})]}),(0,B.jsx)(`button`,{type:`button`,className:S(`flex min-h-8 min-w-8 items-center justify-center rounded-r-lg text-fg-muted hover:bg-surface-active hover:text-fg`,D.transition,D.press,D.focusRingPanel),onClick:()=>s(t),"aria-label":`${d.attachmentPreviewRemove}: ${n}`,title:`${d.attachmentPreviewRemove}: ${n}`,children:(0,B.jsx)(`span`,{"aria-hidden":!0,children:`×`})})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`)},t[9]=d,t[10]=s,t[11]=e):e=t[11],v=n.map(e),t[5]=n,t[6]=d,t[7]=s,t[8]=v}else v=t[8];let y;t[12]!==_||t[13]!==v?(y=(0,B.jsx)(`div`,{className:_,children:v}),t[12]=_,t[13]=v,t[14]=y):y=t[14];let x=f!==null,C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>h(null),t[15]=C):C=t[15];let w;t[16]!==r||t[17]!==f||t[18]!==x?(w=(0,B.jsx)(V,{open:x,attachment:f,conversationId:r,onClose:C}),t[16]=r,t[17]=f,t[18]=x,t[19]=w):w=t[19];let E;return t[20]!==y||t[21]!==w?(E=(0,B.jsxs)(B.Fragment,{children:[y,w]}),t[20]=y,t[21]=w,t[22]=E):E=t[22],E}function W(e){return e.language}function G(e){let{chat:t,initialAttachments:n=[],onAttachmentsChange:r}=e,[a,o]=(0,z.useState)(n),[s,c]=(0,z.useState)(!1),l=(0,z.useRef)(null),u=(0,z.useRef)(a),d=(0,z.useRef)(r);u.current=a,d.current=r;let f=(0,z.useCallback)(e=>{let t=typeof e==`function`?e(u.current):e;u.current=t,o(t),d.current?.(t)},[]),p=(0,z.useCallback)(()=>{f([])},[]),m=(0,z.useCallback)(e=>{f(t=>t.filter((t,n)=>n!==e))},[]),g=(0,z.useCallback)(()=>u.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]),_=(0,z.useCallback)(async(e,n)=>{if(e.length===0)return;let r=10-u.current.length;if(r<=0){O(`warning`,t.maxAttachmentsReached,{max:10});return}let a=e.slice(0,r);e.length>a.length&&O(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-a.length});let{loadAttachment:o}=await i(async()=>{let{loadAttachment:e}=await import(`./attachment-load-DrVGNxJm.js`).then(e=>e.t);return{loadAttachment:e}},__vite__mapDeps([0,1,2])),s=(await Promise.all(a.map(async e=>{if(e.size>33554432)return O(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:T(w)}),null;try{return await o(e,e.name)}catch{return O(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null).map(e=>n?{...e,type:n}:e);f(e=>[...e,...s])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]),v=(0,z.useCallback)(e=>_(e),[_]);return(0,z.useEffect)(()=>{if(e.conversationId)return h(e.conversationId,async e=>{let t=u.current.length;return await _([e]),u.current.length>t})},[_,e.conversationId]),{attachments:a,setAttachments:f,attachmentsRef:u,isDragging:s,setIsDragging:c,fileInputRef:l,processFiles:v,processPastedText:(0,z.useCallback)(e=>_([new File([e.text],e.name,{type:e.mimeType})],`pasted_text`),[_]),removeAttachment:m,clearAttachments:p,wireAttachmentsPayload:g}}export{P as a,F as c,N as i,U as n,L as o,V as r,I as s,G as t};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-DGZZ-M85.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-Czpn1I53.js","assets/pdf-runtime-JnUAvfIa.js","assets/source-workspace-editor-BwYU5OEh.js","assets/vendor-react-BOUWij0V.js","assets/vendor-codemirror-aCQ0FcJT.js","assets/languages-kF11aUYU.js","assets/binary-plugins-D2bFqG6K.js","assets/messages-BAnhwALN.js","assets/attachment-utils-core-BIOUBrpT.js","assets/preview-open-alternatives-CY_hjK4b.js","assets/download-Dk-ZjtO6.js","assets/createLucideIcon-DPHK1VkS.js","assets/external-link-DjqjBmc3.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/interaction-BdhHBbYa.js","assets/electron-env-DHOGevH3.js","assets/use-blob-object-url-D4BFuzZB.js","assets/media-plugins-DGhWjPIU.js","assets/archive-plugin-BAvglLfu.js","assets/jszip.min-Dj17eJqX.js"])))=>i.map(i=>d[i]);
2
- 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"./preload-helper-Czpn1I53.js";import{u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as o,i as s,l as c,n as l}from"./locale-store-Dy1EByeG.js";import{t as u}from"./messages-BAnhwALN.js";import{t as d}from"./createLucideIcon-DPHK1VkS.js";import{t as f}from"./app-window-DXFNqt_0.js";import{t as p}from"./check-DUBLcKHA.js";import{t as m}from"./chevron-down-ccbiQQz_.js";import{t as h}from"./copy-Dv6d4Dvw.js";import{t as g}from"./download-Dk-ZjtO6.js";import{t as _}from"./ellipsis-0k4rZLoy.js";import{t as v}from"./external-link-DjqjBmc3.js";import{t as y}from"./eye-CABVeTq0.js";import{t as b}from"./folder-open-CyzJ19I9.js";import{t as x}from"./link-2-D_ZKYUW7.js";import{t as S}from"./loader-circle-CifKLtgG.js";import{G as C,K as w,t as T}from"./markdown-view-BlxIaCCQ.js";import{t as E}from"./message-square-plus-XP0tGdlV.js";import{t as ee}from"./minimize-2-DtOGrlpo.js";import{t as D}from"./paperclip-f1HujQY1.js";import{t as te}from"./pencil-DmIY3Oa-.js";import{t as O}from"./plus-Q2yW6OE7.js";import{t as k}from"./refresh-cw-BRlGaq2w.js";import{t as A}from"./rotate-cw-LIg3Am9S.js";import{t as ne}from"./save-DRDABU--.js";import{t as j}from"./search-DA7gz22f.js";import{t as re}from"./x-B_N4OPjy.js";import{t as M}from"./cn-0WouolD0.js";import{t as N}from"./skeleton-DzdOeGYz.js";import{r as P,t as F}from"./constants-DpkUgykJ.js";import{a as ie}from"./session-api-BFiIYodK.js";import{a as ae,i as oe,n as se,r as I,s as L,t as R}from"./attachment-utils-core-BIOUBrpT.js";import{n as ce}from"./interaction-BdhHBbYa.js";import{t as z}from"./composer-notifications-CqV6Xj-H.js";import{r as le}from"./app-chrome-BeB4KgOf.js";import{n as ue}from"./electron-env-DHOGevH3.js";import{t as de}from"./use-async-resource-BHFGZCY2.js";import{t as fe}from"./sliding-tab-list-CmcrqRzN.js";import{a as pe,c as me,d as he,m as B,n as ge,r as V,u as H}from"./workspace-api-LghfbP5g.js";import{t as _e}from"./index.module-Cd9ENXfk.js";import{a as ve,l as ye,m as be,n as xe,o as Se,r as U,t as Ce,u as we}from"./dist-ZrL34Ps4.js";var Te=d(`folders`,[[`path`,{d:`M20 5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5a1.5 1.5 0 0 1 1.2.6l.6.8a1.5 1.5 0 0 0 1.2.6z`,key:`a4852j`}],[`path`,{d:`M3 8.268a2 2 0 0 0-1 1.738V19a2 2 0 0 0 2 2h11a2 2 0 0 0 1.732-1`,key:`yxbcw3`}]]),Ee=d(`step-forward`,[[`path`,{d:`M10.029 4.285A2 2 0 0 0 7 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`1ystz2`}],[`path`,{d:`M3 4v16`,key:`1ph11n`}]]),De=d(`step-back`,[[`path`,{d:`M13.971 4.285A2 2 0 0 1 17 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z`,key:`19qhus`}],[`path`,{d:`M21 20V4`,key:`cb8qj8`}]]),Oe=d(`text-wrap`,[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]]),W=n(),G=e(t(),1),ke=(0,G.createContext)(null);function Ae(){return(0,G.useContext)(ke)}var K=(0,G.createContext)([]),je=(0,G.createContext)(null),Me=5*1024*1024,Ne=32*1024*1024,Pe=new Set(`.astro,.bat,.c,.cc,.clj,.cljs,.cljc,.cmd,.cpp,.cs,.cts,.cxx,.dart,.edn,.erl,.ex,.exs,.fish,.fs,.fsx,.go,.gql,.graphql,.groovy,.h,.hh,.hpp,.hrl,.hxx,.java,.ts,.tsx,.mts,.js,.jsx,.mjs,.cjs,.css,.scss,.sass,.less,.json,.jsonc,.json5,.yml,.yaml,.xml,.xsd,.xsl,.py,.pyw,.rb,.php,.rs,.kt,.kts,.scala,.swift,.m,.mm,.sh,.bash,.zsh,.ps1,.sql,.lua,.r,.pl,.pm,.sol,.tf,.tfvars,.nix,.proto,.vue,.svelte,.toml,.ini,.cfg,.conf,.properties`.split(`,`)),Fe=new Set([`.txt`,`.log`,`.lock`,`.csv`,`.tsv`,`.env`,`.gitignore`,`.gitattributes`,`.editorconfig`,`.npmrc`,`.dockerignore`,`.eslintignore`,`.prettierignore`,`.stylelintignore`]),Ie=new Set([`dockerfile`,`gemfile`,`jenkinsfile`,`makefile`,`procfile`,`rakefile`]),Le=new Set([`brewfile`,`changelog`,`codeowners`,`license`,`readme`]),Re=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.bmp`,`.ico`,`.svg`,`.svgz`,`.tif`,`.tiff`,`.avif`,`.heic`,`.heif`,`.jxl`]),ze=new Set([`.mp3`,`.wav`,`.ogg`,`.oga`,`.aac`,`.m4a`,`.flac`,`.opus`,`.weba`]),Be=new Set([`.mp4`,`.webm`,`.mov`,`.m4v`,`.ogv`]),Ve=new Set([`.zip`]),He=new Map([[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.md`,`text/markdown`],[`.markdown`,`text/markdown`],[`.html`,`text/html`],[`.htm`,`text/html`],[`.json`,`application/json`],[`.txt`,`text/plain`],[`.csv`,`text/csv`],[`.tsv`,`text/tab-separated-values`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.mp3`,`audio/mpeg`],[`.wav`,`audio/wav`],[`.ogg`,`audio/ogg`],[`.mp4`,`video/mp4`],[`.webm`,`video/webm`],[`.mov`,`video/quicktime`],[`.zip`,`application/zip`]]);function q(e){let t=J(e),n=t.lastIndexOf(`.`);return n<0||n===t.length-1?``:t.slice(n).toLowerCase()}function J(e){let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]||e}function Y(e,t){let n=t?.split(`;`)[0]?.trim().toLowerCase();return n&&n!==`application/octet-stream`?n:He.get(q(e))??n??`application/octet-stream`}function X(e,t){let n=q(e),r=J(e).toLowerCase(),i=Y(e,t);return i===`text/markdown`||n===`.md`||n===`.markdown`?`markdown`:i===`text/html`||n===`.html`||n===`.htm`?`html`:i===`application/pdf`||n===`.pdf`?`pdf`:i===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||n===`.docx`?`docx`:i===`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`||i===`application/vnd.ms-excel`||n===`.xlsx`||n===`.xls`?`spreadsheet`:i===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||n===`.pptx`?`pptx`:i.startsWith(`image/`)||Re.has(n)?`image`:i.startsWith(`audio/`)||ze.has(n)?`audio`:i.startsWith(`video/`)||Be.has(n)?`video`:i===`application/zip`||Ve.has(n)?`archive`:Pe.has(n)||Ie.has(r)||r.startsWith(`dockerfile.`)?`code`:i.startsWith(`text/`)||Fe.has(n)||Le.has(r)||r.startsWith(`.env.`)||i===`application/json`?`text`:`unsupported`}function Ue(e){switch(e){case`text`:case`markdown`:case`code`:case`html`:return`text`;case`unsupported`:return`metadata`;default:return`binary`}}async function We(e){let{uri:t,conversationId:n,taskId:r}=e;try{let e=P(t),i=await o(s(e?`/api/files/${encodeURIComponent(e)}/content`:L(t,n,r)));return i.ok?{ok:!0,blob:await i.blob()}:{ok:!1,reason:`http`,status:i.status}}catch(e){return{ok:!1,reason:`network`,message:e instanceof Error?e.message:String(e)}}}async function Ge(e){let t=await We(e);return t.ok?{ok:!0,buffer:await t.blob.arrayBuffer()}:t}function Ke(e){return e.id?String(e.id):`${e.name}:${e.uri??``}`}function qe(){return{id:`__empty__`,context:`attachment`,fileName:``,mimeType:`application/octet-stream`,type:`unsupported`,source:{kind:`inline`}}}function Je(e){let t=(0,W.c)(65),{open:n,attachment:r,authToken:i,conversationId:a,language:o}=e,[s,c]=(0,G.useState)(n?r:null),[l,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),m;t[0]!==r||t[1]!==n?(m=n&&r?Ke(r):null,t[0]=r,t[1]=n,t[2]=m):m=t[2];let h=m,g=(0,G.useRef)(h);h!==g.current&&(g.current=h,c(n&&r?r:null),d(!1),p(!1));let _=s,v;bb0:{if(!_){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=qe(),t[3]=e):e=t[3],v=e;break bb0}let e=_.name??`attachment`,n,r;t[4]!==e||t[5]!==_.mimeType?(n=Y(e,_.mimeType),r=X(e,n),t[4]=e,t[5]=_.mimeType,t[6]=n,t[7]=r):(n=t[6],r=t[7]);let i=r,o=_.id?String(_.id):`${e}:${_.uri??``}`,s;t[8]!==a||t[9]!==_.uri?(s=_.uri?{kind:`media-uri`,uri:_.uri,conversationId:a}:{kind:`inline`},t[8]=a,t[9]=_.uri,t[10]=s):s=t[10];let c;t[11]!==e||t[12]!==n||t[13]!==_.size||t[14]!==o||t[15]!==s||t[16]!==i?(c={id:o,context:`attachment`,fileName:e,mimeType:n,size:_.size,type:i,source:s},t[11]=e,t[12]=n,t[13]=_.size,t[14]=o,t[15]=s,t[16]=i,t[17]=c):c=t[17],v=c}let y=v,b;t[18]===_?b=t[19]:(b=_?oe(_):void 0,t[18]=_,t[19]=b);let x=b,S=_?.uri,C;t[20]===y.type?C=t[21]:(C=Ue(y.type),t[20]=y.type,t[21]=C);let w=C,T=!!(n&&S&&!x&&i&&(w===`binary`||w===`text`)),E;t[22]!==a||t[23]!==o||t[24]!==S||t[25]!==_?.taskId?(E=async()=>{let e=u(o).chat,t=await Ge({uri:S,conversationId:a,taskId:_?.taskId});if(!t.ok)throw t.reason===`http`?Error(`${e.attachmentPreviewLoadError} (HTTP ${t.status})`):Error(t.message);return t.buffer},t[22]=a,t[23]=o,t[24]=S,t[25]=_?.taskId,t[26]=E):E=t[26];let ee=_?.taskId,D;t[27]!==i||t[28]!==a||t[29]!==x||t[30]!==o||t[31]!==S||t[32]!==n||t[33]!==w||t[34]!==ee?(D=[n,S,i,o,x,ee,a,w],t[27]=i,t[28]=a,t[29]=x,t[30]=o,t[31]=S,t[32]=n,t[33]=w,t[34]=ee,t[35]=D):D=t[35];let te;t[36]===T?te=t[37]:(te={enabled:T,initial:null,errorData:null},t[36]=T,t[37]=te);let O=de(E,D,te),k;bb1:{if(x)try{let e;t[38]===x?e=t[39]:(e=se(x),t[38]=x,t[39]=e),k=e;break bb1}catch{k=null;break bb1}if(T&&O.loading){k=null;break bb1}k=O.data??null}let A=k,ne=w===`binary`?A:null,j=_?.extractedText??``,re;t[40]!==A||t[41]!==j||t[42]!==o||t[43]!==w?(re=w===`text`?j||(A?new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(A)):u(o).chat.attachmentPreviewNoText):null,t[40]=A,t[41]=j,t[42]=o,t[43]=w,t[44]=re):re=t[44];let M=re,N=!!_?.extractedText,P=y.type===`pptx`&&j.length>3e5,F;t[45]!==i||t[46]!==x||t[47]!==o||t[48]!==S||t[49]!==n||t[50]!==w?(F=n&&S&&!x&&!i&&w===`binary`?u(o).chat.attachmentPreviewMissingAuth:null,t[45]=i,t[46]=x,t[47]=o,t[48]=S,t[49]=n,t[50]=w,t[51]=F):F=t[51];let ie=F,ae=O.error?O.error instanceof Error?O.error.message:String(O.error):null,I=f?null:ie??ae,L=T?O.loading:!1,R;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>p(!0),t[52]=R):R=t[52];let ce=j||null,z;return t[53]!==ne||t[54]!==y||t[55]!==A||t[56]!==P||t[57]!==N||t[58]!==I||t[59]!==_||t[60]!==l||t[61]!==L||t[62]!==ce||t[63]!==M?(z={preview:_,descriptor:y,fileType:y.type,fileName:y.fileName,loading:L,loadError:I,clearLoadError:R,textContent:M,binaryBuffer:ne,downloadBuffer:A,hasExtractedText:N,extractedText:ce,extractedTextTruncated:P,showExtractedText:l,setShowExtractedText:d},t[53]=ne,t[54]=y,t[55]=A,t[56]=P,t[57]=N,t[58]=I,t[59]=_,t[60]=l,t[61]=L,t[62]=ce,t[63]=M,t[64]=z):z=t[64],z}function Ye(e){let t=(0,W.c)(12),{projectId:n,conversationId:r,agentId:i}=e,a;bb0:{let e;t[0]===n?e=t[1]:(e=n?.trim(),t[0]=n,t[1]=e);let o=e;if(o){let e;t[2]===o?e=t[3]:(e={projectId:o},t[2]=o,t[3]=e),a=e;break bb0}let s;t[4]===r?s=t[5]:(s=r?.trim(),t[4]=r,t[5]=s);let c=s;if(c){let e;t[6]===c?e=t[7]:(e={conversationId:c},t[6]=c,t[7]=e),a=e;break bb0}let l;t[8]===i?l=t[9]:(l=i?.trim(),t[8]=i,t[9]=l);let u=l,d;t[10]===u?d=t[11]:(d=u?{agentId:u}:void 0,t[10]=u,t[11]=d),a=d}return a}function Xe(e){return{descriptor:e,textContent:null,binaryBuffer:null,fileResourceId:null,mtimeMs:null,loadError:null,loading:!1,pptxText:null,pptxTruncated:!1,pptxError:null}}function Ze(e,t){switch(t.type){case`clear`:return Xe(t.descriptor);case`loadStart`:return{...Xe(t.descriptor),loading:!0};case`loadSuccess`:return{...e,descriptor:t.payload.descriptor,textContent:t.payload.textContent??null,binaryBuffer:t.payload.binaryBuffer??null,fileResourceId:t.payload.fileResourceId??null,mtimeMs:t.payload.mtimeMs??null,loadError:null,loading:!1};case`loadError`:return{...Xe(t.descriptor),loadError:t.error};case`patchMtime`:return{...e,mtimeMs:t.mtimeMs};case`patchText`:return{...e,textContent:t.text};case`pptxClear`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:null};case`pptxSuccess`:return{...e,pptxText:t.text,pptxTruncated:t.truncated,pptxError:null};case`pptxError`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:t.error}}}function Qe(e,t){switch(t.type){case`reset`:return{sourceEditMode:!1,saveStatus:`idle`};case`source`:return{...e,sourceEditMode:typeof t.value==`function`?t.value(e.sourceEditMode):t.value};case`saveStatus`:return{...e,saveStatus:t.value}}}function $e({filePath:e,projectId:t,conversationId:n,agentId:r,initialEditMode:a=!1}){let o=Ye({projectId:t,conversationId:n,agentId:r}),s=(0,G.useMemo)(()=>{let t=e?J(e):``,i=Y(t,ae(t)),a=e?X(t,i):`unsupported`;return{id:e||`__empty__`,context:`workspace`,fileName:t,mimeType:i,type:a,source:{kind:`workspace`,path:e||``,conversationId:n,agentId:r}}},[r,e,n]),[c,l]=(0,G.useReducer)(Ze,s,Xe),[u,d]=(0,G.useReducer)(Qe,{sourceEditMode:a,saveStatus:`idle`}),[f,p]=(0,G.useState)([]),[m,h]=(0,G.useState)([]),g=(0,G.useRef)(e),_=(0,G.useRef)(void 0),v=(0,G.useRef)(null),y=(0,G.useRef)(null),b=(0,G.useRef)(null),[x,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(0);g.current!==e&&(g.current=e,d({type:`reset`})),(0,G.useEffect)(()=>{if(!e){l({type:`clear`,descriptor:s});return}let t=!1;l({type:`loadStart`,descriptor:s});let n=Ue(s.type),r=e=>{t||l({type:`loadError`,descriptor:s,error:e instanceof Error?e.message:String(e)})};return n===`metadata`?(Promise.all([he(e,o).catch(()=>null),H(e,o).catch(()=>null)]).then(async([n,r])=>{if(!n){t||l({type:`loadSuccess`,payload:{descriptor:s,fileResourceId:r?.fileId??null,mtimeMs:typeof r?.mtimeMs==`number`?r.mtimeMs:null}});return}let i={...s,mimeType:n.mimeType,type:X(n.name,n.mimeType)};if(Ue(i.type)===`text`){let{content:r,mtimeMs:a,revision:s}=await me(e,o);t||(_.current=s,v.current=r,y.current=r,S(!1),w(!1)),t||l({type:`loadSuccess`,payload:{descriptor:i,textContent:r,fileResourceId:n.id,mtimeMs:typeof a==`number`?a:n.modifiedAt}});return}t||l({type:`loadSuccess`,payload:{descriptor:i,fileResourceId:n.id,mtimeMs:n.modifiedAt}})}).catch(r),()=>{t=!0}):(n===`text`?Promise.all([me(e,o),H(e,o).catch(()=>null)]).then(([{content:e,mtimeMs:n,revision:r},i])=>{t||(_.current=r,v.current=e,y.current=e,S(!1),w(!1)),t||l({type:`loadSuccess`,payload:{descriptor:s,textContent:e,fileResourceId:i?.fileId??null,mtimeMs:typeof n==`number`?n:null}})}).catch(r):Promise.all([pe(e,o),H(e,o).catch(()=>null)]).then(async([e,n])=>{let r=await e.arrayBuffer();t||l({type:`loadSuccess`,payload:{descriptor:s,binaryBuffer:r,fileResourceId:n?.fileId??null,mtimeMs:typeof n?.mtimeMs==`number`?n.mtimeMs:null}})}).catch(r),()=>{t=!0})},[s,e,o,T]),(0,G.useEffect)(()=>{if(!c.binaryBuffer||c.descriptor.type!==`pptx`){l({type:`pptxClear`});return}let e=!1;return l({type:`pptxClear`}),i(()=>import(`./attachment-process-heavy-DGZZ-M85.js`).then(e=>e.processPptx(c.binaryBuffer,c.descriptor.fileName)),__vite__mapDeps([0,1,2,3])).then(({extractedText:t})=>{if(e)return;let n=t.length>R;l({type:`pptxSuccess`,text:n?t.slice(0,R):t,truncated:n})}).catch(t=>{e||l({type:`pptxError`,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},[c.binaryBuffer,c.descriptor.fileName,c.descriptor.type]);let ee=(0,G.useCallback)(async()=>{if(b.current&&!await b.current)return!1;if(!e||v.current===null||v.current===y.current)return!0;let t=(async()=>{d({type:`saveStatus`,value:`saving`});try{for(;v.current!==y.current;){let t=v.current,n=await B(e,t,o,_.current);_.current=n.revision,y.current=t,typeof n.mtimeMs==`number`&&l({type:`patchMtime`,mtimeMs:n.mtimeMs})}return S(!1),d({type:`saveStatus`,value:`saved`}),!0}catch{return d({type:`saveStatus`,value:`error`}),!1}})();b.current=t;try{return await t}finally{b.current===t&&(b.current=null)}},[e,o]),D=_e(()=>void ee(),500),te=(0,G.useCallback)(e=>{v.current=e,S(e!==y.current),l({type:`patchText`,text:e}),D()},[D]);(0,G.useEffect)(()=>{let e=e=>{v.current!==y.current&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),D.cancel()}},[D]);let O=(0,G.useCallback)(()=>{!x&&!b.current&&E(e=>e+1)},[x]),k=(0,G.useRef)(!1),A=(0,G.useCallback)(async()=>{if(!(!e||c.loading||b.current||k.current)){k.current=!0;try{let t=await he(e,o);if(!t||!(_.current?t.revision!==_.current:c.mtimeMs!=null&&t.modifiedAt!==c.mtimeMs))return;x||u.sourceEditMode?w(!0):O()}catch{w(!0)}finally{k.current=!1}}},[x,u.sourceEditMode,e,c.loading,c.mtimeMs,o,O]),ne=(0,G.useCallback)(async()=>{if(!e)return;let t=J(e);if(c.binaryBuffer){ge(t,c.binaryBuffer,c.descriptor.mimeType||`application/octet-stream`);return}if(c.textContent!=null){V(t,c.textContent);return}let n=await pe(e,o);ge(t,await n.arrayBuffer(),c.descriptor.mimeType||n.type||`application/octet-stream`)},[e,c.binaryBuffer,c.descriptor.mimeType,c.textContent,o]),j=(0,G.useCallback)(async()=>{if(!e)throw Error(`No workspace file selected`);let t=J(e),n=c.descriptor.mimeType||`application/octet-stream`,r;return r=c.binaryBuffer?new Blob([c.binaryBuffer],{type:n}):c.textContent==null?await pe(e,o):new Blob([c.textContent],{type:n}),new File([r],t,{type:c.descriptor.mimeType||r.type||`application/octet-stream`,lastModified:c.mtimeMs??Date.now()})},[e,c.binaryBuffer,c.descriptor.mimeType,c.mtimeMs,c.textContent,o]),re=!c.loading&&!!e,M=ue()&&(!!c.fileResourceId&&!!window.electronAPI?.shell?.openFileResource||c.descriptor.type===`spreadsheet`&&!!c.binaryBuffer&&!!window.electronAPI?.shell?.openTemporaryFile),N=ue()&&!!c.fileResourceId&&!!window.electronAPI?.shell?.chooseAppAndOpenFileResource,P=(0,G.useCallback)(async()=>{let e=c.fileResourceId;if(!ue()||!e||!window.electronAPI?.shell?.getOpenWithAppsForFileResource){h([]),p([]);return}try{let t=await window.electronAPI.shell.getOpenWithAppsForFileResource(e);h(t.recommended.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl}))),p(t.recent.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl,lastUsedAt:e.lastUsedAt})))}catch{h([]),p([])}},[c.fileResourceId]);(0,G.useEffect)(()=>{P()},[P]);let F=(0,G.useCallback)(async()=>{let e=c.fileResourceId;if(e&&window.electronAPI?.shell?.openFileResource)return window.electronAPI.shell.openFileResource(e);if(c.descriptor.type===`spreadsheet`&&c.binaryBuffer&&window.electronAPI?.shell?.openTemporaryFile)return window.electronAPI.shell.openTemporaryFile({fileName:c.descriptor.fileName,data:new Uint8Array(c.binaryBuffer)})},[c.binaryBuffer,c.descriptor.fileName,c.descriptor.type,c.fileResourceId]),ie=(0,G.useCallback)(async()=>{let e=c.fileResourceId;if(!e||!window.electronAPI?.shell?.chooseAppAndOpenFileResource)return;let t=await window.electronAPI.shell.chooseAppAndOpenFileResource(e);return t.ok&&P(),t},[c.fileResourceId,P]),oe=(0,G.useCallback)(async e=>{let t=c.fileResourceId;if(!t||!e||!window.electronAPI?.shell?.openFileResourceWithApp)return;let n=await window.electronAPI.shell.openFileResourceWithApp(t,e);return n.ok&&P(),n},[c.fileResourceId,P]),se=ue()&&!!c.fileResourceId&&!!window.electronAPI?.shell?.showFileResourceInFolder,I=(0,G.useCallback)(async()=>{let e=c.fileResourceId;if(e&&window.electronAPI?.shell?.showFileResourceInFolder)return window.electronAPI.shell.showFileResourceInFolder(e)},[c.fileResourceId]);return{...c,dirty:x,externalChange:C,flushSource:ee,refresh:O,checkForUpdates:A,extractedText:c.descriptor.type===`pptx`?c.pptxText:null,extractedTextTruncated:c.pptxTruncated,sourceEditMode:u.sourceEditMode,setSourceEditMode:e=>d({type:`source`,value:e}),saveStatus:u.saveStatus,onSourceChange:te,onDownload:ne,createAttachmentFile:j,canDownload:re,canOpenWithSystemApp:M,onOpenWithSystemApp:F,canChooseOpenWithApp:N,onChooseOpenWithApp:ie,recommendedOpenWithApps:m,recentOpenWithApps:f,onOpenWithRecentApp:oe,canRevealInFolder:se,onRevealInFolder:I}}var et=new Map;function tt(e){return et.get(e)??{zoom:1,rotation:0,page:1,pageCount:null,searchQuery:``,scroll:[]}}function nt(e,t){let n={...tt(e),...t};for(et.delete(e),et.set(e,n);et.size>100;)et.delete(et.keys().next().value)}c.subscribe((e,t)=>{(e.baseUrl!==t.baseUrl||e.conversationId!==t.conversationId)&&et.clear()});var rt=new Map;function it(e,t){return rt.set(e,t),()=>{rt.get(e)===t&&rt.delete(e)}}async function at(e,t){return await rt.get(e)?.(t)??!1}var ot=120*1e3,st=new Map;function ct(){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function lt(e){for(let[t,n]of st)n.expiresAt<=e&&st.delete(t)}function ut(e,t=Date.now()){lt(t);let n=ct();return st.set(n,{file:e,name:e.name,type:e.type,expiresAt:t+ot}),n}function dt(e,t=Date.now()){let n=st.get(e);return n?n.expiresAt<=t?(st.delete(e),null):{name:n.name,type:n.type}:null}function ft(e,t=Date.now()){let n=st.get(e);if(!n)return null;if(n.expiresAt<=t)return st.delete(e),null;if(!n.file)return null;let r=n.file;return n.file=null,r}var Z=r();function pt(e){let t=(0,W.c)(3),{app:n}=e,[r,i]=(0,G.useState)(),a;return t[0]!==n||t[1]!==r?(a=n?.iconDataUrl&&n.iconDataUrl!==r?(0,Z.jsx)(`img`,{src:n.iconDataUrl,alt:``,width:20,height:20,className:`size-5 shrink-0 object-contain`,onError:()=>i(n.iconDataUrl)}):(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=r,t[2]=a):a=t[2],a}function mt({variant:e=`split`,onAction:t,systemApp:n,chooseApp:r,recommendedApps:i,recentApps:a,onOpenWithApp:o}){let s=l(e=>e.language),c=u(s).workspace,[d,h]=(0,G.useState)(),[g,_]=(0,G.useState)(!1),y=[...i,...a],b=o&&d!==null?y.find(e=>e.path===d?.path)??d??y[0]:void 0,x=!!(g||n?.loading||r?.loading),C=x||!!n?.disabled,w=b?s===`zh`?`用 ${b.name} 打开`:`Open with ${b.name}`:c.openSystemApp,T=`flex min-h-9 cursor-default items-center gap-2.5 rounded-md px-2.5 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-40`,E=`my-1 h-px bg-edge-subtle`;if(!n&&!r&&(!o||!y.length))return null;if(e===`menu`){let e=e=>t?t(e):e(),s=`flex min-h-9 w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-sm text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-40`;return(0,Z.jsxs)(Z.Fragment,{children:[n?(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C,onClick:()=>e(n.onClick),children:[(0,Z.jsx)(v,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c.openSystemApp})]}):null,o?[{label:c.recommendedApps,apps:i},{label:c.recentApps,apps:a.filter(e=>!i.some(t=>t.path===e.path))}].map(t=>t.apps.length?(0,Z.jsxs)(`div`,{role:`group`,"aria-label":t.label,children:[(0,Z.jsx)(`div`,{className:`px-2.5 pb-1 pt-1.5 text-xs font-medium text-fg-muted`,children:t.label}),t.apps.map(t=>(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C,onClick:()=>e(()=>o(t.path)),children:[(0,Z.jsx)(pt,{app:t}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.name})]},t.path))]},t.label):null):null,r?(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C||r.disabled,onClick:()=>e(()=>{r.onClick()}),children:[(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:c.chooseApp})]}):null,(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`})]})}return(0,Z.jsxs)(`div`,{className:`inline-flex h-9 shrink-0 items-stretch rounded-full border border-edge-subtle bg-surface-panel`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":w,title:w,disabled:C||!b&&!n,onClick:()=>b?o?.(b.path):n?.onClick(),className:M(`inline-flex min-w-0 items-center gap-2 rounded-l-full pl-3 pr-2 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-40`,ce.focusRingPanel),children:[x?(0,Z.jsx)(S,{className:`size-5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(pt,{app:b}),(0,Z.jsx)(`span`,{children:s===`zh`?`打开`:`Open`})]}),(0,Z.jsxs)(ye,{modal:!1,children:[(0,Z.jsx)(be,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":c.chooseApp,title:c.chooseApp,disabled:C,className:M(`inline-flex w-8 shrink-0 items-center justify-center rounded-r-full text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,ce.focusRingPanel),children:(0,Z.jsx)(m,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,Z.jsx)(Se,{children:(0,Z.jsxs)(Ce,{align:`end`,sideOffset:6,collisionPadding:8,"aria-label":c.chooseApp,onEscapeKeyDown:e=>e.stopPropagation(),className:`z-[150] max-h-[var(--radix-dropdown-menu-content-available-height)] w-64 max-w-[calc(100vw-1rem)] overflow-y-auto overscroll-contain rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover outline-none`,children:[n?(0,Z.jsxs)(U,{className:T,disabled:n.disabled||x,onSelect:()=>{h(null),n.onClick()},children:[(0,Z.jsx)(v,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c.openSystemApp}),b?null:(0,Z.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,o?[{label:c.recommendedApps,apps:i},{label:c.recentApps,apps:a.filter(e=>!i.some(t=>t.path===e.path))}].map(e=>e.apps.length?(0,Z.jsxs)(xe,{children:[(0,Z.jsx)(we,{className:E}),(0,Z.jsx)(ve,{className:`px-2.5 pb-1 pt-1.5 text-xs font-medium text-fg-muted`,children:e.label}),e.apps.map(e=>(0,Z.jsxs)(U,{className:T,disabled:x,title:e.name,onSelect:()=>{h(e),o(e.path)},children:[(0,Z.jsx)(pt,{app:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.path===b?.path?(0,Z.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]},e.path))]},e.label):null):null,r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(we,{className:E}),(0,Z.jsxs)(U,{className:T,disabled:r.disabled||x,onSelect:async()=>{_(!0);try{let e=await r.onClick();e&&h(e)}finally{_(!1)}},children:[(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:c.chooseApp})]})]}):null]})})]})]})}var ht=`<script>
2
+ 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"./preload-helper-Czpn1I53.js";import{u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as o,i as s,l as c,n as l}from"./locale-store-Dy1EByeG.js";import{t as u}from"./messages-BAnhwALN.js";import{t as d}from"./createLucideIcon-DPHK1VkS.js";import{t as f}from"./app-window-DXFNqt_0.js";import{t as p}from"./check-DUBLcKHA.js";import{t as m}from"./chevron-down-ccbiQQz_.js";import{t as h}from"./copy-Dv6d4Dvw.js";import{t as g}from"./download-Dk-ZjtO6.js";import{t as _}from"./ellipsis-0k4rZLoy.js";import{t as v}from"./external-link-DjqjBmc3.js";import{t as y}from"./eye-CABVeTq0.js";import{t as b}from"./folder-open-CyzJ19I9.js";import{t as x}from"./link-2-D_ZKYUW7.js";import{t as S}from"./loader-circle-CifKLtgG.js";import{K as C,q as w,t as T}from"./markdown-view-CNJaAdNN.js";import{t as E}from"./message-square-plus-XP0tGdlV.js";import{t as ee}from"./minimize-2-DtOGrlpo.js";import{t as D}from"./paperclip-f1HujQY1.js";import{t as te}from"./pencil-DmIY3Oa-.js";import{t as O}from"./plus-Q2yW6OE7.js";import{t as k}from"./refresh-cw-BRlGaq2w.js";import{t as A}from"./rotate-cw-LIg3Am9S.js";import{t as ne}from"./save-DRDABU--.js";import{t as j}from"./search-DA7gz22f.js";import{t as re}from"./x-B_N4OPjy.js";import{t as M}from"./cn-0WouolD0.js";import{t as N}from"./skeleton-DzdOeGYz.js";import{r as P,t as F}from"./constants-Bg1wM2nv.js";import{a as ie}from"./session-api-BFiIYodK.js";import{a as ae,i as oe,n as se,r as I,s as L,t as R}from"./attachment-utils-core-BIOUBrpT.js";import{n as ce}from"./interaction-BdhHBbYa.js";import{t as z}from"./composer-notifications-CqV6Xj-H.js";import{r as le}from"./app-chrome-BeB4KgOf.js";import{n as ue}from"./electron-env-DHOGevH3.js";import{t as de}from"./use-async-resource-BHFGZCY2.js";import{t as fe}from"./sliding-tab-list-CmcrqRzN.js";import{a as pe,c as me,d as he,m as B,n as ge,r as V,u as H}from"./workspace-api-Dd_UDfeo.js";import{t as _e}from"./index.module-Cd9ENXfk.js";import{a as ve,l as ye,m as be,n as xe,o as Se,r as U,t as Ce,u as we}from"./dist-ZrL34Ps4.js";var Te=d(`folders`,[[`path`,{d:`M20 5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5a1.5 1.5 0 0 1 1.2.6l.6.8a1.5 1.5 0 0 0 1.2.6z`,key:`a4852j`}],[`path`,{d:`M3 8.268a2 2 0 0 0-1 1.738V19a2 2 0 0 0 2 2h11a2 2 0 0 0 1.732-1`,key:`yxbcw3`}]]),Ee=d(`step-forward`,[[`path`,{d:`M10.029 4.285A2 2 0 0 0 7 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`1ystz2`}],[`path`,{d:`M3 4v16`,key:`1ph11n`}]]),De=d(`step-back`,[[`path`,{d:`M13.971 4.285A2 2 0 0 1 17 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z`,key:`19qhus`}],[`path`,{d:`M21 20V4`,key:`cb8qj8`}]]),Oe=d(`text-wrap`,[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]]),W=n(),G=e(t(),1),ke=(0,G.createContext)(null);function Ae(){return(0,G.useContext)(ke)}var K=(0,G.createContext)([]),je=(0,G.createContext)(null),Me=5*1024*1024,Ne=32*1024*1024,Pe=new Set(`.astro,.bat,.c,.cc,.clj,.cljs,.cljc,.cmd,.cpp,.cs,.cts,.cxx,.dart,.edn,.erl,.ex,.exs,.fish,.fs,.fsx,.go,.gql,.graphql,.groovy,.h,.hh,.hpp,.hrl,.hxx,.java,.ts,.tsx,.mts,.js,.jsx,.mjs,.cjs,.css,.scss,.sass,.less,.json,.jsonc,.json5,.yml,.yaml,.xml,.xsd,.xsl,.py,.pyw,.rb,.php,.rs,.kt,.kts,.scala,.swift,.m,.mm,.sh,.bash,.zsh,.ps1,.sql,.lua,.r,.pl,.pm,.sol,.tf,.tfvars,.nix,.proto,.vue,.svelte,.toml,.ini,.cfg,.conf,.properties`.split(`,`)),Fe=new Set([`.txt`,`.log`,`.lock`,`.csv`,`.tsv`,`.env`,`.gitignore`,`.gitattributes`,`.editorconfig`,`.npmrc`,`.dockerignore`,`.eslintignore`,`.prettierignore`,`.stylelintignore`]),Ie=new Set([`dockerfile`,`gemfile`,`jenkinsfile`,`makefile`,`procfile`,`rakefile`]),Le=new Set([`brewfile`,`changelog`,`codeowners`,`license`,`readme`]),Re=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.bmp`,`.ico`,`.svg`,`.svgz`,`.tif`,`.tiff`,`.avif`,`.heic`,`.heif`,`.jxl`]),ze=new Set([`.mp3`,`.wav`,`.ogg`,`.oga`,`.aac`,`.m4a`,`.flac`,`.opus`,`.weba`]),Be=new Set([`.mp4`,`.webm`,`.mov`,`.m4v`,`.ogv`]),Ve=new Set([`.zip`]),He=new Map([[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.md`,`text/markdown`],[`.markdown`,`text/markdown`],[`.html`,`text/html`],[`.htm`,`text/html`],[`.json`,`application/json`],[`.txt`,`text/plain`],[`.csv`,`text/csv`],[`.tsv`,`text/tab-separated-values`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.mp3`,`audio/mpeg`],[`.wav`,`audio/wav`],[`.ogg`,`audio/ogg`],[`.mp4`,`video/mp4`],[`.webm`,`video/webm`],[`.mov`,`video/quicktime`],[`.zip`,`application/zip`]]);function q(e){let t=J(e),n=t.lastIndexOf(`.`);return n<0||n===t.length-1?``:t.slice(n).toLowerCase()}function J(e){let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]||e}function Y(e,t){let n=t?.split(`;`)[0]?.trim().toLowerCase();return n&&n!==`application/octet-stream`?n:He.get(q(e))??n??`application/octet-stream`}function X(e,t){let n=q(e),r=J(e).toLowerCase(),i=Y(e,t);return i===`text/markdown`||n===`.md`||n===`.markdown`?`markdown`:i===`text/html`||n===`.html`||n===`.htm`?`html`:i===`application/pdf`||n===`.pdf`?`pdf`:i===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||n===`.docx`?`docx`:i===`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`||i===`application/vnd.ms-excel`||n===`.xlsx`||n===`.xls`?`spreadsheet`:i===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||n===`.pptx`?`pptx`:i.startsWith(`image/`)||Re.has(n)?`image`:i.startsWith(`audio/`)||ze.has(n)?`audio`:i.startsWith(`video/`)||Be.has(n)?`video`:i===`application/zip`||Ve.has(n)?`archive`:Pe.has(n)||Ie.has(r)||r.startsWith(`dockerfile.`)?`code`:i.startsWith(`text/`)||Fe.has(n)||Le.has(r)||r.startsWith(`.env.`)||i===`application/json`?`text`:`unsupported`}function Ue(e){switch(e){case`text`:case`markdown`:case`code`:case`html`:return`text`;case`unsupported`:return`metadata`;default:return`binary`}}async function We(e){let{uri:t,conversationId:n,taskId:r}=e;try{let e=P(t),i=await o(s(e?`/api/files/${encodeURIComponent(e)}/content`:L(t,n,r)));return i.ok?{ok:!0,blob:await i.blob()}:{ok:!1,reason:`http`,status:i.status}}catch(e){return{ok:!1,reason:`network`,message:e instanceof Error?e.message:String(e)}}}async function Ge(e){let t=await We(e);return t.ok?{ok:!0,buffer:await t.blob.arrayBuffer()}:t}function Ke(e){return e.id?String(e.id):`${e.name}:${e.uri??``}`}function qe(){return{id:`__empty__`,context:`attachment`,fileName:``,mimeType:`application/octet-stream`,type:`unsupported`,source:{kind:`inline`}}}function Je(e){let t=(0,W.c)(65),{open:n,attachment:r,authToken:i,conversationId:a,language:o}=e,[s,c]=(0,G.useState)(n?r:null),[l,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),m;t[0]!==r||t[1]!==n?(m=n&&r?Ke(r):null,t[0]=r,t[1]=n,t[2]=m):m=t[2];let h=m,g=(0,G.useRef)(h);h!==g.current&&(g.current=h,c(n&&r?r:null),d(!1),p(!1));let _=s,v;bb0:{if(!_){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=qe(),t[3]=e):e=t[3],v=e;break bb0}let e=_.name??`attachment`,n,r;t[4]!==e||t[5]!==_.mimeType?(n=Y(e,_.mimeType),r=X(e,n),t[4]=e,t[5]=_.mimeType,t[6]=n,t[7]=r):(n=t[6],r=t[7]);let i=r,o=_.id?String(_.id):`${e}:${_.uri??``}`,s;t[8]!==a||t[9]!==_.uri?(s=_.uri?{kind:`media-uri`,uri:_.uri,conversationId:a}:{kind:`inline`},t[8]=a,t[9]=_.uri,t[10]=s):s=t[10];let c;t[11]!==e||t[12]!==n||t[13]!==_.size||t[14]!==o||t[15]!==s||t[16]!==i?(c={id:o,context:`attachment`,fileName:e,mimeType:n,size:_.size,type:i,source:s},t[11]=e,t[12]=n,t[13]=_.size,t[14]=o,t[15]=s,t[16]=i,t[17]=c):c=t[17],v=c}let y=v,b;t[18]===_?b=t[19]:(b=_?oe(_):void 0,t[18]=_,t[19]=b);let x=b,S=_?.uri,C;t[20]===y.type?C=t[21]:(C=Ue(y.type),t[20]=y.type,t[21]=C);let w=C,T=!!(n&&S&&!x&&i&&(w===`binary`||w===`text`)),E;t[22]!==a||t[23]!==o||t[24]!==S||t[25]!==_?.taskId?(E=async()=>{let e=u(o).chat,t=await Ge({uri:S,conversationId:a,taskId:_?.taskId});if(!t.ok)throw t.reason===`http`?Error(`${e.attachmentPreviewLoadError} (HTTP ${t.status})`):Error(t.message);return t.buffer},t[22]=a,t[23]=o,t[24]=S,t[25]=_?.taskId,t[26]=E):E=t[26];let ee=_?.taskId,D;t[27]!==i||t[28]!==a||t[29]!==x||t[30]!==o||t[31]!==S||t[32]!==n||t[33]!==w||t[34]!==ee?(D=[n,S,i,o,x,ee,a,w],t[27]=i,t[28]=a,t[29]=x,t[30]=o,t[31]=S,t[32]=n,t[33]=w,t[34]=ee,t[35]=D):D=t[35];let te;t[36]===T?te=t[37]:(te={enabled:T,initial:null,errorData:null},t[36]=T,t[37]=te);let O=de(E,D,te),k;bb1:{if(x)try{let e;t[38]===x?e=t[39]:(e=se(x),t[38]=x,t[39]=e),k=e;break bb1}catch{k=null;break bb1}if(T&&O.loading){k=null;break bb1}k=O.data??null}let A=k,ne=w===`binary`?A:null,j=_?.extractedText??``,re;t[40]!==A||t[41]!==j||t[42]!==o||t[43]!==w?(re=w===`text`?j||(A?new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(A)):u(o).chat.attachmentPreviewNoText):null,t[40]=A,t[41]=j,t[42]=o,t[43]=w,t[44]=re):re=t[44];let M=re,N=!!_?.extractedText,P=y.type===`pptx`&&j.length>3e5,F;t[45]!==i||t[46]!==x||t[47]!==o||t[48]!==S||t[49]!==n||t[50]!==w?(F=n&&S&&!x&&!i&&w===`binary`?u(o).chat.attachmentPreviewMissingAuth:null,t[45]=i,t[46]=x,t[47]=o,t[48]=S,t[49]=n,t[50]=w,t[51]=F):F=t[51];let ie=F,ae=O.error?O.error instanceof Error?O.error.message:String(O.error):null,I=f?null:ie??ae,L=T?O.loading:!1,R;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>p(!0),t[52]=R):R=t[52];let ce=j||null,z;return t[53]!==ne||t[54]!==y||t[55]!==A||t[56]!==P||t[57]!==N||t[58]!==I||t[59]!==_||t[60]!==l||t[61]!==L||t[62]!==ce||t[63]!==M?(z={preview:_,descriptor:y,fileType:y.type,fileName:y.fileName,loading:L,loadError:I,clearLoadError:R,textContent:M,binaryBuffer:ne,downloadBuffer:A,hasExtractedText:N,extractedText:ce,extractedTextTruncated:P,showExtractedText:l,setShowExtractedText:d},t[53]=ne,t[54]=y,t[55]=A,t[56]=P,t[57]=N,t[58]=I,t[59]=_,t[60]=l,t[61]=L,t[62]=ce,t[63]=M,t[64]=z):z=t[64],z}function Ye(e){let t=(0,W.c)(12),{projectId:n,conversationId:r,agentId:i}=e,a;bb0:{let e;t[0]===n?e=t[1]:(e=n?.trim(),t[0]=n,t[1]=e);let o=e;if(o){let e;t[2]===o?e=t[3]:(e={projectId:o},t[2]=o,t[3]=e),a=e;break bb0}let s;t[4]===r?s=t[5]:(s=r?.trim(),t[4]=r,t[5]=s);let c=s;if(c){let e;t[6]===c?e=t[7]:(e={conversationId:c},t[6]=c,t[7]=e),a=e;break bb0}let l;t[8]===i?l=t[9]:(l=i?.trim(),t[8]=i,t[9]=l);let u=l,d;t[10]===u?d=t[11]:(d=u?{agentId:u}:void 0,t[10]=u,t[11]=d),a=d}return a}function Xe(e){return{descriptor:e,textContent:null,binaryBuffer:null,fileResourceId:null,mtimeMs:null,loadError:null,loading:!1,pptxText:null,pptxTruncated:!1,pptxError:null}}function Ze(e,t){switch(t.type){case`clear`:return Xe(t.descriptor);case`loadStart`:return{...Xe(t.descriptor),loading:!0};case`loadSuccess`:return{...e,descriptor:t.payload.descriptor,textContent:t.payload.textContent??null,binaryBuffer:t.payload.binaryBuffer??null,fileResourceId:t.payload.fileResourceId??null,mtimeMs:t.payload.mtimeMs??null,loadError:null,loading:!1};case`loadError`:return{...Xe(t.descriptor),loadError:t.error};case`patchMtime`:return{...e,mtimeMs:t.mtimeMs};case`patchText`:return{...e,textContent:t.text};case`pptxClear`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:null};case`pptxSuccess`:return{...e,pptxText:t.text,pptxTruncated:t.truncated,pptxError:null};case`pptxError`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:t.error}}}function Qe(e,t){switch(t.type){case`reset`:return{sourceEditMode:!1,saveStatus:`idle`};case`source`:return{...e,sourceEditMode:typeof t.value==`function`?t.value(e.sourceEditMode):t.value};case`saveStatus`:return{...e,saveStatus:t.value}}}function $e({filePath:e,projectId:t,conversationId:n,agentId:r,initialEditMode:a=!1}){let o=Ye({projectId:t,conversationId:n,agentId:r}),s=(0,G.useMemo)(()=>{let t=e?J(e):``,i=Y(t,ae(t)),a=e?X(t,i):`unsupported`;return{id:e||`__empty__`,context:`workspace`,fileName:t,mimeType:i,type:a,source:{kind:`workspace`,path:e||``,conversationId:n,agentId:r}}},[r,e,n]),[c,l]=(0,G.useReducer)(Ze,s,Xe),[u,d]=(0,G.useReducer)(Qe,{sourceEditMode:a,saveStatus:`idle`}),[f,p]=(0,G.useState)([]),[m,h]=(0,G.useState)([]),g=(0,G.useRef)(e),_=(0,G.useRef)(void 0),v=(0,G.useRef)(null),y=(0,G.useRef)(null),b=(0,G.useRef)(null),[x,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(0);g.current!==e&&(g.current=e,d({type:`reset`})),(0,G.useEffect)(()=>{if(!e){l({type:`clear`,descriptor:s});return}let t=!1;l({type:`loadStart`,descriptor:s});let n=Ue(s.type),r=e=>{t||l({type:`loadError`,descriptor:s,error:e instanceof Error?e.message:String(e)})};return n===`metadata`?(Promise.all([he(e,o).catch(()=>null),H(e,o).catch(()=>null)]).then(async([n,r])=>{if(!n){t||l({type:`loadSuccess`,payload:{descriptor:s,fileResourceId:r?.fileId??null,mtimeMs:typeof r?.mtimeMs==`number`?r.mtimeMs:null}});return}let i={...s,mimeType:n.mimeType,type:X(n.name,n.mimeType)};if(Ue(i.type)===`text`){let{content:r,mtimeMs:a,revision:s}=await me(e,o);t||(_.current=s,v.current=r,y.current=r,S(!1),w(!1)),t||l({type:`loadSuccess`,payload:{descriptor:i,textContent:r,fileResourceId:n.id,mtimeMs:typeof a==`number`?a:n.modifiedAt}});return}t||l({type:`loadSuccess`,payload:{descriptor:i,fileResourceId:n.id,mtimeMs:n.modifiedAt}})}).catch(r),()=>{t=!0}):(n===`text`?Promise.all([me(e,o),H(e,o).catch(()=>null)]).then(([{content:e,mtimeMs:n,revision:r},i])=>{t||(_.current=r,v.current=e,y.current=e,S(!1),w(!1)),t||l({type:`loadSuccess`,payload:{descriptor:s,textContent:e,fileResourceId:i?.fileId??null,mtimeMs:typeof n==`number`?n:null}})}).catch(r):Promise.all([pe(e,o),H(e,o).catch(()=>null)]).then(async([e,n])=>{let r=await e.arrayBuffer();t||l({type:`loadSuccess`,payload:{descriptor:s,binaryBuffer:r,fileResourceId:n?.fileId??null,mtimeMs:typeof n?.mtimeMs==`number`?n.mtimeMs:null}})}).catch(r),()=>{t=!0})},[s,e,o,T]),(0,G.useEffect)(()=>{if(!c.binaryBuffer||c.descriptor.type!==`pptx`){l({type:`pptxClear`});return}let e=!1;return l({type:`pptxClear`}),i(()=>import(`./attachment-process-heavy-DGZZ-M85.js`).then(e=>e.processPptx(c.binaryBuffer,c.descriptor.fileName)),__vite__mapDeps([0,1,2,3])).then(({extractedText:t})=>{if(e)return;let n=t.length>R;l({type:`pptxSuccess`,text:n?t.slice(0,R):t,truncated:n})}).catch(t=>{e||l({type:`pptxError`,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},[c.binaryBuffer,c.descriptor.fileName,c.descriptor.type]);let ee=(0,G.useCallback)(async()=>{if(b.current&&!await b.current)return!1;if(!e||v.current===null||v.current===y.current)return!0;let t=(async()=>{d({type:`saveStatus`,value:`saving`});try{for(;v.current!==y.current;){let t=v.current,n=await B(e,t,o,_.current);_.current=n.revision,y.current=t,typeof n.mtimeMs==`number`&&l({type:`patchMtime`,mtimeMs:n.mtimeMs})}return S(!1),d({type:`saveStatus`,value:`saved`}),!0}catch{return d({type:`saveStatus`,value:`error`}),!1}})();b.current=t;try{return await t}finally{b.current===t&&(b.current=null)}},[e,o]),D=_e(()=>void ee(),500),te=(0,G.useCallback)(e=>{v.current=e,S(e!==y.current),l({type:`patchText`,text:e}),D()},[D]);(0,G.useEffect)(()=>{let e=e=>{v.current!==y.current&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),D.cancel()}},[D]);let O=(0,G.useCallback)(()=>{!x&&!b.current&&E(e=>e+1)},[x]),k=(0,G.useRef)(!1),A=(0,G.useCallback)(async()=>{if(!(!e||c.loading||b.current||k.current)){k.current=!0;try{let t=await he(e,o);if(!t||!(_.current?t.revision!==_.current:c.mtimeMs!=null&&t.modifiedAt!==c.mtimeMs))return;x||u.sourceEditMode?w(!0):O()}catch{w(!0)}finally{k.current=!1}}},[x,u.sourceEditMode,e,c.loading,c.mtimeMs,o,O]),ne=(0,G.useCallback)(async()=>{if(!e)return;let t=J(e);if(c.binaryBuffer){ge(t,c.binaryBuffer,c.descriptor.mimeType||`application/octet-stream`);return}if(c.textContent!=null){V(t,c.textContent);return}let n=await pe(e,o);ge(t,await n.arrayBuffer(),c.descriptor.mimeType||n.type||`application/octet-stream`)},[e,c.binaryBuffer,c.descriptor.mimeType,c.textContent,o]),j=(0,G.useCallback)(async()=>{if(!e)throw Error(`No workspace file selected`);let t=J(e),n=c.descriptor.mimeType||`application/octet-stream`,r;return r=c.binaryBuffer?new Blob([c.binaryBuffer],{type:n}):c.textContent==null?await pe(e,o):new Blob([c.textContent],{type:n}),new File([r],t,{type:c.descriptor.mimeType||r.type||`application/octet-stream`,lastModified:c.mtimeMs??Date.now()})},[e,c.binaryBuffer,c.descriptor.mimeType,c.mtimeMs,c.textContent,o]),re=!c.loading&&!!e,M=ue()&&(!!c.fileResourceId&&!!window.electronAPI?.shell?.openFileResource||c.descriptor.type===`spreadsheet`&&!!c.binaryBuffer&&!!window.electronAPI?.shell?.openTemporaryFile),N=ue()&&!!c.fileResourceId&&!!window.electronAPI?.shell?.chooseAppAndOpenFileResource,P=(0,G.useCallback)(async()=>{let e=c.fileResourceId;if(!ue()||!e||!window.electronAPI?.shell?.getOpenWithAppsForFileResource){h([]),p([]);return}try{let t=await window.electronAPI.shell.getOpenWithAppsForFileResource(e);h(t.recommended.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl}))),p(t.recent.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl,lastUsedAt:e.lastUsedAt})))}catch{h([]),p([])}},[c.fileResourceId]);(0,G.useEffect)(()=>{P()},[P]);let F=(0,G.useCallback)(async()=>{let e=c.fileResourceId;if(e&&window.electronAPI?.shell?.openFileResource)return window.electronAPI.shell.openFileResource(e);if(c.descriptor.type===`spreadsheet`&&c.binaryBuffer&&window.electronAPI?.shell?.openTemporaryFile)return window.electronAPI.shell.openTemporaryFile({fileName:c.descriptor.fileName,data:new Uint8Array(c.binaryBuffer)})},[c.binaryBuffer,c.descriptor.fileName,c.descriptor.type,c.fileResourceId]),ie=(0,G.useCallback)(async()=>{let e=c.fileResourceId;if(!e||!window.electronAPI?.shell?.chooseAppAndOpenFileResource)return;let t=await window.electronAPI.shell.chooseAppAndOpenFileResource(e);return t.ok&&P(),t},[c.fileResourceId,P]),oe=(0,G.useCallback)(async e=>{let t=c.fileResourceId;if(!t||!e||!window.electronAPI?.shell?.openFileResourceWithApp)return;let n=await window.electronAPI.shell.openFileResourceWithApp(t,e);return n.ok&&P(),n},[c.fileResourceId,P]),se=ue()&&!!c.fileResourceId&&!!window.electronAPI?.shell?.showFileResourceInFolder,I=(0,G.useCallback)(async()=>{let e=c.fileResourceId;if(e&&window.electronAPI?.shell?.showFileResourceInFolder)return window.electronAPI.shell.showFileResourceInFolder(e)},[c.fileResourceId]);return{...c,dirty:x,externalChange:C,flushSource:ee,refresh:O,checkForUpdates:A,extractedText:c.descriptor.type===`pptx`?c.pptxText:null,extractedTextTruncated:c.pptxTruncated,sourceEditMode:u.sourceEditMode,setSourceEditMode:e=>d({type:`source`,value:e}),saveStatus:u.saveStatus,onSourceChange:te,onDownload:ne,createAttachmentFile:j,canDownload:re,canOpenWithSystemApp:M,onOpenWithSystemApp:F,canChooseOpenWithApp:N,onChooseOpenWithApp:ie,recommendedOpenWithApps:m,recentOpenWithApps:f,onOpenWithRecentApp:oe,canRevealInFolder:se,onRevealInFolder:I}}var et=new Map;function tt(e){return et.get(e)??{zoom:1,rotation:0,page:1,pageCount:null,searchQuery:``,scroll:[]}}function nt(e,t){let n={...tt(e),...t};for(et.delete(e),et.set(e,n);et.size>100;)et.delete(et.keys().next().value)}c.subscribe((e,t)=>{(e.baseUrl!==t.baseUrl||e.conversationId!==t.conversationId)&&et.clear()});var rt=new Map;function it(e,t){return rt.set(e,t),()=>{rt.get(e)===t&&rt.delete(e)}}async function at(e,t){return await rt.get(e)?.(t)??!1}var ot=120*1e3,st=new Map;function ct(){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function lt(e){for(let[t,n]of st)n.expiresAt<=e&&st.delete(t)}function ut(e,t=Date.now()){lt(t);let n=ct();return st.set(n,{file:e,name:e.name,type:e.type,expiresAt:t+ot}),n}function dt(e,t=Date.now()){let n=st.get(e);return n?n.expiresAt<=t?(st.delete(e),null):{name:n.name,type:n.type}:null}function ft(e,t=Date.now()){let n=st.get(e);if(!n)return null;if(n.expiresAt<=t)return st.delete(e),null;if(!n.file)return null;let r=n.file;return n.file=null,r}var Z=r();function pt(e){let t=(0,W.c)(3),{app:n}=e,[r,i]=(0,G.useState)(),a;return t[0]!==n||t[1]!==r?(a=n?.iconDataUrl&&n.iconDataUrl!==r?(0,Z.jsx)(`img`,{src:n.iconDataUrl,alt:``,width:20,height:20,className:`size-5 shrink-0 object-contain`,onError:()=>i(n.iconDataUrl)}):(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=r,t[2]=a):a=t[2],a}function mt({variant:e=`split`,onAction:t,systemApp:n,chooseApp:r,recommendedApps:i,recentApps:a,onOpenWithApp:o}){let s=l(e=>e.language),c=u(s).workspace,[d,h]=(0,G.useState)(),[g,_]=(0,G.useState)(!1),y=[...i,...a],b=o&&d!==null?y.find(e=>e.path===d?.path)??d??y[0]:void 0,x=!!(g||n?.loading||r?.loading),C=x||!!n?.disabled,w=b?s===`zh`?`用 ${b.name} 打开`:`Open with ${b.name}`:c.openSystemApp,T=`flex min-h-9 cursor-default items-center gap-2.5 rounded-md px-2.5 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-40`,E=`my-1 h-px bg-edge-subtle`;if(!n&&!r&&(!o||!y.length))return null;if(e===`menu`){let e=e=>t?t(e):e(),s=`flex min-h-9 w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-sm text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-40`;return(0,Z.jsxs)(Z.Fragment,{children:[n?(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C,onClick:()=>e(n.onClick),children:[(0,Z.jsx)(v,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c.openSystemApp})]}):null,o?[{label:c.recommendedApps,apps:i},{label:c.recentApps,apps:a.filter(e=>!i.some(t=>t.path===e.path))}].map(t=>t.apps.length?(0,Z.jsxs)(`div`,{role:`group`,"aria-label":t.label,children:[(0,Z.jsx)(`div`,{className:`px-2.5 pb-1 pt-1.5 text-xs font-medium text-fg-muted`,children:t.label}),t.apps.map(t=>(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C,onClick:()=>e(()=>o(t.path)),children:[(0,Z.jsx)(pt,{app:t}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.name})]},t.path))]},t.label):null):null,r?(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C||r.disabled,onClick:()=>e(()=>{r.onClick()}),children:[(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:c.chooseApp})]}):null,(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`})]})}return(0,Z.jsxs)(`div`,{className:`inline-flex h-9 shrink-0 items-stretch rounded-full border border-edge-subtle bg-surface-panel`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":w,title:w,disabled:C||!b&&!n,onClick:()=>b?o?.(b.path):n?.onClick(),className:M(`inline-flex min-w-0 items-center gap-2 rounded-l-full pl-3 pr-2 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-40`,ce.focusRingPanel),children:[x?(0,Z.jsx)(S,{className:`size-5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(pt,{app:b}),(0,Z.jsx)(`span`,{children:s===`zh`?`打开`:`Open`})]}),(0,Z.jsxs)(ye,{modal:!1,children:[(0,Z.jsx)(be,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":c.chooseApp,title:c.chooseApp,disabled:C,className:M(`inline-flex w-8 shrink-0 items-center justify-center rounded-r-full text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,ce.focusRingPanel),children:(0,Z.jsx)(m,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,Z.jsx)(Se,{children:(0,Z.jsxs)(Ce,{align:`end`,sideOffset:6,collisionPadding:8,"aria-label":c.chooseApp,onEscapeKeyDown:e=>e.stopPropagation(),className:`z-[150] max-h-[var(--radix-dropdown-menu-content-available-height)] w-64 max-w-[calc(100vw-1rem)] overflow-y-auto overscroll-contain rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover outline-none`,children:[n?(0,Z.jsxs)(U,{className:T,disabled:n.disabled||x,onSelect:()=>{h(null),n.onClick()},children:[(0,Z.jsx)(v,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c.openSystemApp}),b?null:(0,Z.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,o?[{label:c.recommendedApps,apps:i},{label:c.recentApps,apps:a.filter(e=>!i.some(t=>t.path===e.path))}].map(e=>e.apps.length?(0,Z.jsxs)(xe,{children:[(0,Z.jsx)(we,{className:E}),(0,Z.jsx)(ve,{className:`px-2.5 pb-1 pt-1.5 text-xs font-medium text-fg-muted`,children:e.label}),e.apps.map(e=>(0,Z.jsxs)(U,{className:T,disabled:x,title:e.name,onSelect:()=>{h(e),o(e.path)},children:[(0,Z.jsx)(pt,{app:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.path===b?.path?(0,Z.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]},e.path))]},e.label):null):null,r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(we,{className:E}),(0,Z.jsxs)(U,{className:T,disabled:r.disabled||x,onSelect:async()=>{_(!0);try{let e=await r.onClick();e&&h(e)}finally{_(!1)}},children:[(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:c.chooseApp})]})]}):null]})})]})]})}var ht=`<script>
3
3
  window.addEventListener('click', (event) => {
4
4
  if (event.defaultPrevented || event.button !== 0 ||
5
5
  event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,p as i,r as a}from"./locale-store-Dy1EByeG.js";import{a as o,r as s}from"./voice-CDlC6XMH.js";import{t as c}from"./session-manager-63NaXb1s.js";import{t as l}from"./middleware-Pd0e8Igk.js";import{t as u}from"./composer-notifications-CqV6Xj-H.js";var d=e(t(),1),ee=i()(l(e=>({captions:!0,microphoneId:``,setCaptions:t=>e({captions:t}),setMicrophoneId:t=>e({microphoneId:t})}),{name:`xopc-voice-preferences`}));function te(){let e=ee.getState().microphoneId;return{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,...e?{deviceId:{exact:e}}:{}}}function ne(e,t,n,r){return new Promise((i,a)=>{let o=!1,s=(e,n)=>{o||(o=!0,clearTimeout(l),t.removeEventListener(`abort`,c),e===void 0?i(n):a(e))},c=()=>s(t.reason??new DOMException(`Cancelled`,`AbortError`)),l=setTimeout(()=>s(new DOMException(`Voice startup timed out`,`TimeoutError`)),n);e.then(e=>{o?r?.(e):s(void 0,e)},e=>s(e)),t.addEventListener(`abort`,c,{once:!0}),t.aborted&&c()})}function re(e,t,n,r){let i=e.get(t);if(i&&(n<i.revision||i.final&&!r||n===i.revision&&(i.final||!r)))return!1;if(!e.has(t)&&e.size>=256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return e.set(t,{revision:n,final:r}),!0}var f=32,p=1481592883,ie=3,ae=1,oe=2,m=1,h=64*1024,g=new TextEncoder,_=new TextDecoder(`utf-8`,{fatal:!0});function se(e){let t=g.encode(e.id);if(!t.length||t.length>160||!Number.isInteger(e.connectionEpoch)||e.connectionEpoch<1||e.connectionEpoch>4294967295||!Number.isInteger(e.seq)||e.seq<1||e.seq>4294967295||!Number.isFinite(e.timestampMs)||e.timestampMs<0||e.durationMs!==20||e.flags<0||e.flags>3||!e.audio.length||e.audio.length%2||f+t.length+e.audio.length>h)throw Error(`Invalid voice media frame`);let n=new Uint8Array(f+t.length+e.audio.length),r=new DataView(n.buffer);return r.setUint32(0,p),r.setUint8(4,ie),r.setUint8(5,e.kind),r.setUint8(6,m),r.setUint8(7,e.flags),r.setUint32(8,e.connectionEpoch),r.setUint32(12,e.seq),r.setFloat64(16,e.timestampMs),r.setUint16(24,e.durationMs),r.setUint16(26,t.length),r.setUint32(28,e.audio.length),n.set(t,f),n.set(e.audio,f+t.length),n}function ce(e,t){if(e.length<=f||e.length>h)throw Error(`Invalid voice media frame`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint8(5),i=n.getUint32(8),a=n.getUint32(12),o=n.getFloat64(16),s=n.getUint16(24),c=n.getUint16(26),l=n.getUint32(28),u=f+c,d=n.getUint8(7);if(n.getUint32(0)!==p||n.getUint8(4)!==ie||r!==t||n.getUint8(6)!==m||d>3||!i||!a||!Number.isFinite(o)||o<0||s!==20||!c||c>160||!l||l%2||u+l!==e.length)throw Error(`Invalid voice media header`);return{kind:r,connectionEpoch:i,id:_.decode(e.subarray(f,u)),seq:a,timestampMs:o,durationMs:s,flags:d,audio:e.slice(u)}}function le(e){let t=ce(e,oe);return{connectionEpoch:t.connectionEpoch,responseId:t.id,seq:t.seq,mediaTimestampMs:t.timestampMs,durationMs:t.durationMs,audio:t.audio}}function ue(e){return se({kind:ae,connectionEpoch:e.connectionEpoch,id:e.utteranceId,seq:e.audioSeq,timestampMs:e.capturedAtMonotonicMs,durationMs:e.durationMs,flags:!!e.start|(e.end?2:0),audio:e.audio})}var de=class{session;eventSeq=0;audioSeq=0;ready=!1;closed=!1;cancelled=new Set;constructor(e){this.session=e}event(e){if(this.closed)throw Error(`Voice session closed`);if(e.sessionId!==this.session.sessionId||e.seq!==this.eventSeq+1)throw Error(`Invalid voice event sequence`);if(this.eventSeq=e.seq,e.type===`session.ready`){if(this.ready||e.payload.connectionEpoch!==this.session.connectionEpoch||e.payload.purpose!==this.session.purpose||e.payload.inputMode!==this.session.inputMode||e.payload.inputFormat.sampleRate!==this.session.inputFormat.sampleRate||e.payload.mode!==this.session.mode||e.payload.route.engine!==this.session.route.engine)throw Error(`Voice session mismatch`);this.ready=!0}e.type===`response.cancelled`&&this.cancel(e.payload.responseId),e.type===`session.closed`&&(this.ready=!1,this.closed=!0)}audio(e){if(!this.ready||e.connectionEpoch!==this.session.connectionEpoch||e.seq!==this.audioSeq+1)throw Error(`Invalid voice audio sequence`);return this.audioSeq=e.seq,!this.cancelled.has(e.responseId)}cancel(e){if(!this.cancelled.has(e)){if(this.cancelled.size>=1e4)throw Error(`Voice response limit exceeded`);this.cancelled.add(e)}}};function v(e,t){return{protocolVersion:3,messageId:crypto.randomUUID(),type:e,sentAt:Date.now(),payload:t}}function y(e){let t=new URL(n(e));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}var fe=class e{socket;session;timingMetrics;receive;heartbeatId;inputRemainder=new Uint8Array;utteranceId=crypto.randomUUID();inputSeq=0;constructor(e,t,n=[]){this.socket=e,this.session=t,this.timingMetrics=n,this.receive=new de(t)}static async preflight(e){return e.purpose===`conversation`&&e.conversationId&&await new c().materialize(e.conversationId,`voice`),(await r(n(`/api/voice/realtime/preflight`),{method:`POST`,signal:e.signal,body:JSON.stringify({purpose:e.purpose,mode:e.mode,naturalBackend:e.naturalBackend,testHiggsVoice:e.testHiggsVoice,conversationId:e.conversationId,supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})})).timingMetrics??[]}static async connect(t){t.signal?.throwIfAborted();let i=await r(n(`/api/voice/realtime/sessions`),{method:`POST`,signal:t.signal,body:JSON.stringify({purpose:t.purpose,...t.language?{language:t.language}:{},...t.purpose===`conversation`&&t.mode!==`natural`&&t.logicalCallId?{openingGreeting:{logicalCallId:t.logicalCallId,initiation:t.recovery?`recovery`:`user`,supportsOutputReady:!0}}:{},...t.mode?{mode:t.mode}:{},...t.naturalBackend?{naturalBackend:t.naturalBackend}:{},...t.testHiggsVoice?{testHiggsVoice:t.testHiggsVoice}:{},...t.conversationId?{conversationId:t.conversationId}:{},supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})}),a=s.parse(i.payload);t.signal?.throwIfAborted();let c=new WebSocket(y(a.websocketPath));c.binaryType=`arraybuffer`;let l=new e(c,a,t.timingMetrics);return await new Promise((e,n)=>{let r=!1,i,s=e=>{r||(r=!0,i!==void 0&&window.clearTimeout(i),c.close(),n(e))};i=window.setTimeout(()=>s(Error(`Realtime voice connection timed out`)),15e3);let u=()=>{r?c.close():s(Error(`Realtime voice connection cancelled`))};if(t.signal?.addEventListener(`abort`,u,{once:!0}),c.addEventListener(`close`,()=>t.signal?.removeEventListener(`abort`,u),{once:!0}),t.signal?.aborted){u();return}c.onerror=()=>s(Error(`Realtime voice connection failed`)),c.onclose=e=>{r?t.onClose?.(e.reason):s(Error(e.reason||`Realtime voice connection closed`))},c.onopen=()=>{c.send(JSON.stringify(v(`session.start`,{sessionId:a.sessionId,ticket:a.ticket})))},c.onmessage=n=>{if(typeof n.data!=`string`){try{let e=le(new Uint8Array(n.data));l.receive.audio(e)&&t.onAudio?.(e.audio.slice().buffer,e.responseId)}catch{c.close(4400,`Invalid voice audio frame`)}return}try{let c=o(JSON.parse(n.data));if(l.receive.event(c),t.onEvent(c),c.type===`session.ready`&&!r){if(c.payload.connectionEpoch!==a.connectionEpoch||c.payload.mode!==a.mode)throw Error(`Voice session mismatch`);r=!0,window.clearTimeout(i),l.startHeartbeat(c.payload.heartbeatIntervalMs),e()}else c.type===`session.error`&&!c.payload.recoverable&&s(Error(c.payload.message))}catch(e){r?c.close(4400,`Invalid voice protocol frame`):s(e instanceof Error?e:Error(String(e)))}}}),l}outputReady(){this.session.openingGreeting?.accepted&&this.sendControl(`session.output_ready`,{connectionEpoch:this.session.connectionEpoch})}sendAudio(e){if(!e.byteLength||this.socket.readyState!==WebSocket.OPEN)return;let t=new Uint8Array(e),n=new Uint8Array(this.inputRemainder.byteLength+t.byteLength);n.set(this.inputRemainder),n.set(t,this.inputRemainder.byteLength);let r=0;for(;r+640<=n.byteLength;){let e=ue({connectionEpoch:this.session.connectionEpoch,utteranceId:this.utteranceId,audioSeq:++this.inputSeq,capturedAtMonotonicMs:performance.now(),durationMs:20,...this.inputSeq===1?{start:!0}:{},audio:n.slice(r,r+640)});this.socket.send(e.buffer),r+=640}this.inputRemainder=n.slice(r)}reportMetric(e,t,n){t===`speech_end_to_audio_scheduled`&&!this.timingMetrics.includes(t)||this.sendControl(`session.metric`,{responseId:e,metric:t,durationMs:Math.min(6e5,Math.max(0,n))})}setInputMuted(e){this.sendControl(`input.mute`,{muted:e}),this.inputRemainder=new Uint8Array,e||(this.utteranceId=crypto.randomUUID(),this.inputSeq=0)}commit(){this.sendControl(`input.commit`,{})}cancelResponse(e){this.sendControl(`response.stop_playback`,{responseId:e})}cancelTask(e){this.sendControl(`task.cancel`,{taskId:e})}acknowledgeAudio(e,t){this.sendControl(`response.audio.played`,{responseId:e,playedDurationMs:Math.floor(t/48)})}stop(e=`user_finished`){this.stopHeartbeat(),this.socket.readyState===WebSocket.OPEN?this.sendControl(`session.stop`,{reason:e}):this.socket.close()}sendControl(e,t){this.socket.readyState===WebSocket.OPEN&&(e===`response.stop_playback`&&`responseId`in t&&this.receive.cancel(t.responseId),this.socket.send(JSON.stringify(v(e,t))))}startHeartbeat(e){this.stopHeartbeat(),this.heartbeatId=window.setInterval(()=>this.sendControl(`session.ping`,{}),e),this.socket.addEventListener(`close`,()=>this.stopHeartbeat(),{once:!0})}stopHeartbeat(){this.heartbeatId!==void 0&&(window.clearInterval(this.heartbeatId),this.heartbeatId=void 0)}},b=1.7,pe=class{context=new AudioContext({sampleRate:24e3,latencyHint:`interactive`});output=this.context.createGain();ringbackOutput=this.context.createGain();limiter=this.context.createDynamicsCompressor();sources=new Set;ringbackSources=new Map;ringbackDelay=null;ringbackInterval=null;ringbackActive=!1;nextStartTime=0;hasStartedAudio=!1;confirmedSpeech=!1;tentativeDuckTimer;constructor(){this.output.gain.value=b,this.limiter.threshold.value=-6,this.limiter.knee.value=6,this.limiter.ratio.value=12,this.limiter.attack.value=.003,this.limiter.release.value=.12,this.output.connect(this.limiter),this.limiter.connect(this.context.destination),this.ringbackOutput.gain.value=0,this.ringbackOutput.connect(this.context.destination)}async start(){await this.context.resume()}get hasPendingAudio(){return this.sources.size>0}startRingback(){this.stopRingback(),this.context.state!==`closed`&&(this.ringbackActive=!0,this.ringbackDelay=setTimeout(()=>{this.ringbackDelay=null,!(!this.ringbackActive||this.context.state!==`running`)&&(this.ringbackOutput.gain.cancelScheduledValues(this.context.currentTime),this.ringbackOutput.gain.setValueAtTime(.14,this.context.currentTime),this.playRingbackPulse(),this.ringbackInterval=setInterval(()=>this.playRingbackPulse(),3e3))},500))}playRingbackPulse(){if(!this.ringbackActive||this.context.state!==`running`)return;let e=this.context.currentTime;for(let[t,n]of[392,494].entries()){let r=e+t*.4,i=this.context.createOscillator(),a=this.context.createGain();i.type=`sine`,i.frequency.value=n,a.gain.setValueAtTime(0,r),a.gain.linearRampToValueAtTime(.5,r+.04),a.gain.setValueAtTime(.5,r+.18),a.gain.linearRampToValueAtTime(0,r+.28),i.connect(a),a.connect(this.ringbackOutput),this.ringbackSources.set(i,a),i.onended=()=>{this.ringbackSources.delete(i),i.disconnect(),a.disconnect()},i.start(r),i.stop(r+.29)}}stopRingback(){if(this.ringbackActive=!1,this.ringbackDelay!==null&&clearTimeout(this.ringbackDelay),this.ringbackInterval!==null&&clearInterval(this.ringbackInterval),this.ringbackDelay=null,this.ringbackInterval=null,this.context.state!==`closed`){this.ringbackOutput.gain.cancelScheduledValues(this.context.currentTime),this.ringbackOutput.gain.setTargetAtTime(0,this.context.currentTime,.025);for(let[e,t]of this.ringbackSources){t.gain.cancelScheduledValues(this.context.currentTime),t.gain.setTargetAtTime(0,this.context.currentTime,.02);try{e.stop(this.context.currentTime+.12)}catch{}}}}enqueue(e,t,n=24e3){if(e.byteLength<2||this.context.state===`closed`)return;let r=new DataView(e),i=new Float32Array(Math.floor(e.byteLength/2));for(let e=0;e<i.length;e+=1)i[e]=r.getInt16(e*2,!0)/32768;let a=this.context.createBuffer(1,i.length,n);a.copyToChannel(i,0);let o=this.context.createBufferSource();o.buffer=a,o.connect(this.output);let s=this.hasStartedAudio?.015:.02,c=Math.max(this.context.currentTime+s,this.nextStartTime);return o.start(c),this.hasStartedAudio=!0,this.nextStartTime=c+a.duration,this.sources.add(o),o.onended=()=>{this.sources.delete(o)&&(o.disconnect(),t())},Math.max(0,c-this.context.currentTime)*1e3}duck(e){clearTimeout(this.tentativeDuckTimer),this.tentativeDuckTimer=void 0,this.confirmedSpeech=e,this.setOutputGain(e?.15:1)}duckForVoiceOnset(){this.confirmedSpeech||this.tentativeDuckTimer!==void 0||!this.hasPendingAudio||(this.setOutputGain(.55),this.tentativeDuckTimer=setTimeout(()=>{this.tentativeDuckTimer=void 0,this.setOutputGain(1)},280))}setOutputGain(e){this.context.state!==`closed`&&(this.output.gain.cancelScheduledValues(this.context.currentTime),this.output.gain.setTargetAtTime(b*e,this.context.currentTime,.015))}clear(){for(let e of this.sources){e.onended=null;try{e.stop()}catch{}e.disconnect()}this.sources.clear(),this.nextStartTime=this.context.currentTime,this.hasStartedAudio=!1,this.duck(!1)}async close(){this.stopRingback(),this.clear(),this.output.disconnect(),this.ringbackOutput.disconnect(),this.limiter.disconnect(),this.context.state!==`closed`&&await this.context.close();for(let[e,t]of this.ringbackSources)e.onended=null,e.disconnect(),t.disconnect();this.ringbackSources.clear()}},x=`/assets/pcm-capture-worklet-CpXsv44v.js`,S=16e3;function C(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];return Math.min(1,Math.sqrt(t/e.length))}function w(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function me(e,t,n=S){if(t===n)return e;let r=Math.max(1,Math.round(e.length*n/t)),i=new Float32Array(r),a=t/n;for(let t=0;t<r;t+=1){let n=t*a,r=Math.min(e.length-1,Math.floor(n)),o=Math.min(e.length-1,r+1),s=n-r;i[t]=e[r]*(1-s)+e[o]*s}return i}function he(e,t=S){let n=new ArrayBuffer(44+e.length*2),r=new DataView(n),i=(e,t)=>{for(let n=0;n<t.length;n+=1)r.setUint8(e+n,t.charCodeAt(n))};i(0,`RIFF`),r.setUint32(4,36+e.length*2,!0),i(8,`WAVE`),i(12,`fmt `),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,`data`),r.setUint32(40,e.length*2,!0);for(let t=0;t<e.length;t+=1){let n=Math.max(-1,Math.min(1,e[t]));r.setInt16(44+t*2,n<0?n*32768:n*32767,!0)}return n}function T(e){let t=new ArrayBuffer(e.length*2),n=new DataView(t);for(let t=0;t<e.length;t+=1){let r=Math.max(-1,Math.min(1,e[t]));n.setInt16(t*2,r<0?r*32768:r*32767,!0)}return t}var ge=class{sourceRate;targetRate;pending=new Float32Array;position=0;constructor(e,t=S){if(this.sourceRate=e,this.targetRate=t,e<=0||t<=0)throw Error(`PCM sample rates must be positive`)}push(e){if(e.length===0)return new ArrayBuffer(0);let t=new Float32Array(this.pending.length+e.length);t.set(this.pending),t.set(e,this.pending.length);let n=this.sourceRate/this.targetRate,r=[];for(;this.position+1<t.length;){let e=Math.floor(this.position),i=this.position-e;r.push(t[e]*(1-i)+t[e+1]*i),this.position+=n}let i=Math.min(t.length-1,Math.floor(this.position));return this.pending=t.slice(i),this.position-=i,T(Float32Array.from(r))}flush(){if(this.pending.length===0)return new ArrayBuffer(0);let e=this.pending[Math.min(this.pending.length-1,Math.floor(this.position))];return this.pending=new Float32Array,this.position=0,T(Float32Array.of(e))}},_e=`xopc-pcm-capture`,E=1e3,D=1e4,ve=class e{context;source;node;mutedOutput;options;sampleRate;paused=!1;accepting=!0;processorFailed=!1;stopPromise;flushResolve;constructor(e,t,n,r,i){this.context=e,this.source=t,this.node=n,this.mutedOutput=r,this.options=i,this.sampleRate=e.sampleRate,this.node.port.onmessage=e=>{if(e.data.type===`flushed`){this.flushResolve?.();return}if(!this.accepting||this.paused)return;let t=new Float32Array(e.data.buffer);if(this.options.onSamples(t),this.options.onAudioLevel){let e=C(t);this.options.onAudioLevel({level:e,speaking:e>=(this.options.speechThreshold??.015)})}},this.node.onprocessorerror=()=>{this.processorFailed=!0,this.flushResolve?.()}}static async start(t,n){if(typeof AudioWorkletNode>`u`)throw Error(`PCM audio recording is not supported in this browser`);let r=new AudioContext,i,a,o=new Promise((e,t)=>{a=setTimeout(()=>{t(new DOMException(`PCM audio capture startup timed out`,`TimeoutError`))},D)});try{await Promise.race([r.audioWorklet.addModule(x),o]);let a=r.createMediaStreamSource(t),s=n.frameDurationMs===void 0?void 0:Math.round(r.sampleRate*n.frameDurationMs/1e3),c=new AudioWorkletNode(r,_e,{processorOptions:{frameSamples:s}}),l=r.createGain();return l.gain.value=0,i=new e(r,a,c,l,n),a.connect(c),c.connect(l),l.connect(r.destination),await Promise.race([r.resume(),o]),i}catch(e){throw i?i.cancel():r.close().catch(()=>void 0),e}finally{clearTimeout(a)}}pause(){this.paused=!0}resume(){this.paused=!1}stop(){return this.stopPromise??=this.finish(),this.stopPromise}cancel(){this.accepting&&(this.accepting=!1,this.flushResolve?.(),this.flushResolve=void 0,this.disconnect(),this.context.close().catch(()=>void 0))}async finish(){this.accepting&&(this.processorFailed||await this.flushWorklet(),this.flushResolve=void 0,this.accepting&&(this.accepting=!1,this.disconnect(),await this.context.close().catch(()=>void 0)))}flushWorklet(){return new Promise(e=>{let t=!1,n=()=>{t||(t=!0,globalThis.clearTimeout(r),e())},r=globalThis.setTimeout(n,E);this.flushResolve=n;try{this.node.port.postMessage(`flush`)}catch{n()}})}disconnect(){this.node.port.onmessage=null,this.node.onprocessorerror=null,this.source.disconnect(),this.node.disconnect(),this.mutedOutput.disconnect()}},ye=class e{capture;chunks;stopped=!1;constructor(e,t){this.capture=e,this.chunks=t}static async start(t,n={}){let r=[],i=await ve.start(t,{...n,onSamples:e=>r.push(e)});return new e(i,r)}async stop(){if(this.stopped)return new Blob([],{type:`audio/wav`});this.stopped=!0,await this.capture.stop();let e=me(w(this.chunks),this.capture.sampleRate);return new Blob([he(e)],{type:`audio/wav`})}cancel(){this.stopped||(this.stopped=!0,this.capture.cancel(),this.chunks.length=0)}};function O(e){return e.includes(`ogg`)?`ogg`:e.includes(`mp4`)||e.includes(`m4a`)?`m4a`:e.includes(`mpeg`)||e.includes(`mp3`)?`mp3`:e.includes(`wav`)?`wav`:`webm`}async function k(e,t,i,a){let o=e.type||t||`audio/webm`,s=e.type?e:new Blob([e],{type:o}),c=new FormData;c.append(`audio`,s,`recording.${O(o)}`),a&&c.append(`expectedProvider`,a);let l=await r(n(`/api/voice/transcriptions`),{method:`POST`,body:c,...i?{signal:i}:{}});if(!l.payload)throw Error(`Missing transcription payload`);return l.payload}async function be(e){let t=await r(n(`/api/status`),{signal:e});if(!t.voice?.dictation)throw Error(`Missing dictation status`);return t.voice.dictation}function A(){}typeof window<`u`&&(window.addEventListener(`voice-config-changed`,A),window.addEventListener(`config-reload`,A));var j=null;function xe(e){return j&&j!==e?!1:(j=e,!0)}function M(e){j===e&&(j=null)}function Se(e){if(!(e instanceof Error))return!1;let t=e.body,n=typeof t?.error==`object`?t.error.code:void 0;return n===`VOICE_DISABLED`||n===`PROVIDER_UNAVAILABLE`}function Ce(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function we(e){return e===`requesting`||e===`connecting`||e===`starting`}async function Te(){if(!navigator.permissions?.query)return null;try{return(await navigator.permissions.query({name:`microphone`})).state}catch{return null}}function Ee(e){return e instanceof DOMException||e instanceof Error?e.name:``}function De(e,t){if(e===`permission`)return`permission`;if(e===`recorder`)return`recorder`;if(e===`session`)return`session`;let n=Ee(t);return n===`NotAllowedError`||n===`SecurityError`?`permission`:`device`}function Oe(e){let{disabled:t,chat:i,onTranscript:o}=e,[s,c]=(0,d.useState)(`idle`),[l,ee]=(0,d.useState)(!1),f=(0,d.useRef)(null),p=(0,d.useRef)(null),ie=(0,d.useRef)(void 0),[ae,oe]=(0,d.useState)(0),[m,h]=(0,d.useState)(0),[g,_]=(0,d.useState)(``),[se,ce]=(0,d.useState)(``),[le,ue]=(0,d.useState)(``),[de,v]=(0,d.useState)([]),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(`idle`),[C,w]=(0,d.useState)(null),[me,he]=(0,d.useState)(!1),T=(0,d.useRef)(!1),[_e,E]=(0,d.useState)(null),[D,O]=(0,d.useState)(null),[A,j]=(0,d.useState)(!1),[Oe,ke]=(0,d.useState)(null),N=(0,d.useRef)(void 0),P=(0,d.useRef)(null),[Ae,je]=(0,d.useState)(`dictation`),Me=(0,d.useRef)(Symbol(`voice-capture`)),F=(0,d.useRef)(`idle`),I=(0,d.useRef)(0),L=(0,d.useRef)(null),Ne=(0,d.useRef)(null),R=(0,d.useRef)(null),Pe=(0,d.useRef)(void 0),Fe=(0,d.useRef)(void 0),Ie=(0,d.useRef)(void 0),z=(0,d.useRef)(null),Le=(0,d.useRef)(null),Re=(0,d.useRef)(null),B=(0,d.useRef)(new Map),V=(0,d.useRef)(!1),ze=(0,d.useRef)(()=>{}),Be=(0,d.useRef)(new Map),H=(0,d.useRef)(null),U=(0,d.useRef)(new Set),[Ve,He]=(0,d.useState)([]),Ue=(0,d.useRef)(!1),W=(0,d.useRef)(null),We=(0,d.useRef)(!1),G=(0,d.useRef)(new Set),Ge=(0,d.useRef)(0),Ke=(0,d.useRef)(6e5),qe=(0,d.useRef)(null),K=(0,d.useRef)(null),Je=(0,d.useRef)(o);Je.current=o;let Ye=(0,d.useRef)(e.onTestAudioPlayed);Ye.current=e.onTestAudioPlayed;let q=(0,d.useCallback)(e=>{F.current=e,c(e)},[]),J=(0,d.useCallback)(()=>{qe.current!=null&&(clearInterval(qe.current),qe.current=null)},[]),Y=(0,d.useCallback)(()=>{Le.current?.getTracks().forEach(e=>e.stop()),Le.current=null},[]),X=(0,d.useCallback)(()=>{M(Me.current),I.current+=1,P.current?.abort(),P.current=null,J(),K.current!==null&&clearTimeout(K.current),K.current=null,z.current?.stopRingback(),Y(),f.current?.cancel(),f.current=null,p.current=null,ie.current=void 0,ee(!1),L.current?.cancel(),L.current=null,Ne.current=null,R.current=null;let e=z.current;z.current=null,e?.close(),Re.current=null,oe(0),h(0),_(``),ce(``),ue(``),S(`idle`),w(null),v([]),b(null),W.current=null,G.current.clear(),T.current=!1,he(!1),j(!1),Be.current.clear(),B.current.clear(),V.current=!1,H.current=null,U.current.clear(),He([])},[Y,J]),Z=(0,d.useCallback)(()=>{X(),q(`idle`)},[X,q]),Xe=(0,d.useCallback)(()=>{R.current?.stop(`user_finished`),Z(),E(null),O(null),ke(null)},[Z]),Q=(0,d.useCallback)(async e=>{if(V.current)return;V.current=!0;let t=I.current,a=e??[...B.current.values()].join(` `).trim();if(Y(),J(),L.current?.cancel(),L.current=null,q(`transcribing`),!a){u(`warning`,i.voiceTranscribeEmpty),Z();return}let o=a;try{let e=await r(n(`/api/voice/transcriptions/refine`),{method:`POST`,body:JSON.stringify({text:a}),signal:AbortSignal.any([P.current.signal,AbortSignal.timeout(15e3)])});e.payload.text.trim()&&(o=e.payload.text)}catch{if(t!==I.current)return;u(`warning`,i.voiceRefinementFailed)}t===I.current&&(Je.current(o),Z())},[Z,i.voiceRefinementFailed,i.voiceTranscribeEmpty,Y,J,q]),Ze=(0,d.useCallback)(async()=>{if(V.current)return;V.current=!0;let e=I.current;J(),q(`transcribing`);try{let t=f.current;if(!p.current&&t){let n=await t.stop();if(e!==I.current)return;p.current=n}if(f.current=null,Y(),e!==I.current)return;let n=p.current;if(!n)throw Error(i.voiceTranscribeEmpty);let r=await k(n,n.type,AbortSignal.any([P.current.signal,AbortSignal.timeout(9e4)]),ie.current);if(e!==I.current)return;V.current=!1,await Q(r.text.trim())}catch(t){if(e!==I.current)return;Y(),V.current=!1,E(t instanceof Error?t.message:i.voiceTranscribeFailed),O(`session`),q(`error`)}},[Q,i.voiceTranscribeEmpty,i.voiceTranscribeFailed,Y,J,q]),Qe=(0,d.useCallback)(e=>{ke(e);let t=F.current;if(!(t===`idle`||t===`error`||V.current)){if(!N.current){if(t===`transcribing`&&e===`input_committed`){Q();return}J(),Y(),L.current?.cancel(),L.current=null,R.current=null,E(i.voiceTranscribeFailed),q(`error`);return}Z()}},[Q,Z,i.voiceTranscribeFailed,Y,J,q]),$e=(0,d.useCallback)(()=>{J(),qe.current=setInterval(()=>{let e=Re.current;if(e===null)return;let t=performance.now()-e;if(oe(Math.max(0,t/1e3)),t>=Ke.current&&F.current===`recording`){if(!N.current){ze.current();return}ke(`session_limit`),R.current?.stop(`user_finished`),Z()}},200)},[Z,J]),$=(0,d.useCallback)(async(e,n,r,o,s=!1,c)=>{if(t||F.current!==`idle`||e===`conversation`&&!r&&!c)return;if(!xe(Me.current)){E(i.callCaptureBusy),e===`dictation`&&u(`error`,i.callCaptureBusy);return}N.current=r;let l=new AbortController;P.current=l,E(null),O(null),ke(null);let d=++I.current,p=()=>d===I.current;je(e),w(e===`conversation`?`preparing`:null),(!s||!Pe.current)&&(Pe.current=crypto.randomUUID()),Fe.current=n,Ie.current=o,ue(``),q(`connecting`);let ae=performance.now(),m=(e,t,n)=>ne(e,l.signal,t,n),g=`permission`;try{if(e===`conversation`){g=`recorder`;let e=new pe;if(z.current=e,await m(e.start(),1e4),!p()){e.close();return}}g=`session`;let t=e===`dictation`?await m(be(l.signal),2e4):null;if(!p())return;if(t?.mode===`unavailable`){let e=Error(i.voiceSttNotConfigured);throw Object.assign(e,{body:{error:{code:`PROVIDER_UNAVAILABLE`}}}),e}let d=t?.mode===`recorded`,ne=e===`conversation`?{mode:n,...o?{naturalBackend:o}:{},...c?{testHiggsVoice:c}:{},conversationId:r}:{},ae=d?[]:await m(fe.preflight({purpose:e,...ne,signal:l.signal}),2e4),se=!1;if(!p())return;g=`permission`;let le=window.electronAPI?.system,de=await m(Te(),5e3);if(!p()||!we(F.current))return;if(le&&de!==`granted`){q(`requesting`);let e=await m(le.requestMicrophone(),6e4);if(!p())return;let t=window.electronAPI?.platform===`darwin`&&e.status!==`granted`;if(e.status===`denied`||t)throw Error(`Microphone permission denied`)}else!le&&de!==`granted`&&q(`requesting`);if(!p()||!we(F.current))return;q(`starting`),window.dispatchEvent(new Event(`xopc-voice-recording-start`)),g=`media`;let y=await m(navigator.mediaDevices.getUserMedia({audio:te()}),15e3,e=>e.getTracks().forEach(e=>e.stop()));if(!p()||!we(F.current)){y.getTracks().forEach(e=>e.stop());return}if(Le.current=y,d){g=`recorder`;let e=await m(ye.start(y,{onAudioLevel:({level:e})=>{p()&&h(Math.min(1,e*8))}}),15e3,e=>e.cancel());if(!p()){e.cancel();return}f.current=e,ie.current=t.provider,ee(!0),Ke.current=6e5,Re.current=performance.now(),oe(0),q(`recording`),$e();return}e===`conversation`&&(w(`dialing`),z.current?.startRingback(),K.current=setTimeout(()=>{p()&&(z.current?.stopRingback(),w(`slow`),K.current=null)},12e3)),g=`session`,q(`connecting`),B.current.clear();let x=await m(fe.connect({timingMetrics:ae,logicalCallId:Pe.current,recovery:s,language:a(),purpose:e,signal:l.signal,...ne,onEvent:t=>{if(p()&&!((t.type===`input.transcript.delta`||t.type===`input.transcript.final`)&&!re(Be.current,t.payload.utteranceId,t.payload.revision,t.type===`input.transcript.final`))){if(t.type===`input.transcript.delta`&&_(t.payload.text),t.type===`input.transcript.final`){let n=t.payload.text.trim();_(``),ce(n),n&&e===`dictation`&&(B.current.set(t.payload.utteranceId,n),[...B.current.values()].join(` `).length>=2e4&&F.current===`recording`&&ze.current(),ce([...B.current.values()].join(` `)))}if(t.type===`input.speech_started`&&!T.current&&R.current?.session.bargeIn&&H.current&&We.current&&(G.current.size<32&&G.current.add(t.payload.utteranceId),z.current?.duck(!0)),t.type===`input.speech_stopped`&&(W.current=performance.now(),G.current.delete(t.payload.utteranceId)&&G.current.size===0&&z.current?.duck(!1)),t.type===`response.created`){if(H.current){H.current!==t.payload.responseId&&R.current?.cancelResponse(t.payload.responseId);return}H.current=t.payload.responseId,G.current.clear(),z.current?.duck(!1),Ue.current=!1,We.current=!1,Ge.current=0,ue(``),U.current.size||(v([]),b(null)),S(`thinking`)}if(t.type===`task.created`&&(U.current.add(t.payload.taskId),He([...U.current])),t.type===`task.activity`&&U.current.has(t.payload.taskId)){let e={toolCallId:t.payload.toolCallId,toolName:t.payload.toolName,status:t.payload.status};v(t=>[...t.filter(t=>t.toolCallId!==e.toolCallId),e].slice(-8))}if(t.type===`task.done`&&(U.current.delete(t.payload.taskId),He([...U.current]),U.current.size||v([])),t.type===`response.clarification`&&b(t.payload),t.type===`response.text.delta`&&H.current===t.payload.responseId&&(S(`speaking`),ue(e=>e+t.payload.delta)),t.type===`response.audio.started`&&H.current===t.payload.responseId&&S(`speaking`),t.type===`response.done`&&H.current===t.payload.responseId&&(Ue.current=!0,z.current?.hasPendingAudio||(H.current=null,S(`idle`))),t.type===`response.cancelled`&&H.current===t.payload.responseId&&(G.current.clear(),H.current=null,S(`idle`),z.current?.clear()),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`RESPONSE_FAILED`&&u(`warning`,i.voiceResponseFailed),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`INPUT_DROPPED`&&u(`warning`,i.voiceInputDropped),t.type===`session.error`&&!t.payload.recoverable){let n=t.payload.code===`PROVIDER_UNAVAILABLE`,r=t.payload.code===`CONTEXT_CHANGED`?i.voiceContextChanged:n?i.voiceSttNotConfigured:t.payload.message;E(r),O(`session`),j(n),e===`dictation`&&u(`error`,r,void 0,n?{href:`/settings/capabilities/models?configure=transcription`}:void 0),R.current?.stop(`surface_closed`),e===`conversation`?X():(J(),Y(),L.current?.cancel(),L.current=null,R.current=null),q(`error`)}}},onAudio:(e,t)=>{if(!p())return;let n=H.current;if(!n||t!==n)return;let r=!We.current,i=W.current;r&&(We.current=!0,W.current!==null&&R.current?.reportMetric(n,`speech_end_to_audio_received`,performance.now()-W.current),W.current=null);let a=z.current?.enqueue(e,()=>{H.current===n&&(Ge.current+=e.byteLength,R.current?.acknowledgeAudio(n,Ge.current),c&&!se&&new Int16Array(e).some(e=>Math.abs(e)>96)&&(se=!0,Ye.current?.()),Ue.current&&!z.current?.hasPendingAudio&&(H.current=null,S(`idle`)))});r&&i!==null&&a!==void 0&&R.current?.reportMetric(n,`speech_end_to_audio_scheduled`,performance.now()-i+a)},onClose:e=>{p()&&Qe(e)}}),2e4,e=>e.stop(`surface_closed`));if(!p()){x.stop(`surface_closed`);return}z.current?.stopRingback(),K.current!==null&&clearTimeout(K.current),K.current=null,R.current=x,Ke.current=x.session.limits.maxSessionMs,g=`recorder`,q(`starting`);let C,me=[],he=e===`conversation`&&y.getAudioTracks()[0]?.getSettings?.().echoCancellation===!0,_e=.005,D=0,k=0,A=!1,xe=0,M=await m(ve.start(y,{frameDurationMs:20,onSamples:e=>{if(!p()||T.current)return;if(!C){me.push(e);return}let t=(Ne.current??C).push(e);t&&x.sendAudio(t)},onAudioLevel:({level:e})=>{if(p()){if(T.current){D=k=0,A=!1;return}if(xe++%2==0&&h(Math.min(1,e*8)),!(!he||!x.session.bargeIn)){if(!H.current||!We.current||!z.current?.hasPendingAudio){e<.02&&(_e+=(e-_e)*.05),D=k=0,A=!1;return}e>=Math.max(.022,_e*3)?(k=0,!A&&++D>=3&&(A=!0,z.current.duckForVoiceOnset())):(D=0,++k>=6&&(A=!1))}}}}),15e3,e=>e.cancel());if(!p()||!we(F.current)){M.cancel(),x.stop(`surface_closed`),y.getTracks().forEach(e=>e.stop());return}if(L.current=M,e===`conversation`&&(await m(z.current.start(),1e4),!p()))return;x.outputReady(),C=new ge(M.sampleRate,x.session.inputFormat.sampleRate),Ne.current=C;for(let e of me)x.sendAudio(C.push(e));Re.current=performance.now(),oe(0),q(`recording`),w(null),$e()}catch(t){if(!p())return;let n=De(g,t);console.error(`[chat:voice] realtime capture start failed`,{stage:g,durationMs:Math.round(performance.now()-ae),kind:n,errorName:Ee(t),errorMessage:t instanceof Error?t.message:String(t)}),R.current?.stop(`surface_closed`),X(),q(n===`session`?`error`:`idle`);let r=n===`session`&&Se(t),a=Ee(t)===`TimeoutError`?g===`session`?i.voiceConnectionTimeout:i.voiceMicrophoneTimeout:n===`permission`?i.voiceMicDenied:n===`device`?i.voiceMicUnavailable:n===`recorder`?i.voiceRecorderFailed:r?i.voiceSttNotConfigured:t instanceof Error?t.message:i.voiceSttNotConfigured;E(a),O(n),j(r),e===`dictation`&&u(`error`,a,void 0,r?{href:`/settings/capabilities/models?configure=transcription`}:void 0)}},[t,Qe,i,X,$e,Y,J,q]),et=(0,d.useCallback)(()=>{if(N.current)return;if(f.current||p.current){Ze();return}if(F.current===`error`&&B.current.size){Q();return}if(F.current!==`recording`)return;q(`transcribing`),J(),Y();let e=L.current,t=I.current;L.current=null,e?.stop().then(()=>{if(t!==I.current)return;let e=Ne.current?.flush();e&&R.current?.sendAudio(e),R.current?.commit()}).catch(()=>{t===I.current&&(u(`error`,i.voiceTranscribeFailed),R.current?.stop(`surface_closed`),X(),q(`error`))})},[Q,Ze,i.voiceTranscribeFailed,X,Y,J,q]);ze.current=et,(0,d.useEffect)(()=>()=>{M(Me.current),I.current+=1,P.current?.abort(),f.current?.cancel(),p.current=null,L.current?.cancel(),R.current?.stop(`surface_closed`),z.current?.close(),K.current!==null&&clearTimeout(K.current),Y(),J()},[Y,J]);let tt=(0,d.useCallback)(()=>{if(F.current===`error`){if(p.current){Ze();return}X(),q(`idle`),$(Ae,Fe.current,N.current,Ie.current,!0)}},[$,Ze,Ae,X,q]),nt=(0,d.useCallback)(()=>$(`dictation`),[$]),rt=(0,d.useCallback)((e,t,n)=>$(`conversation`,t,e,n),[$]),it=(0,d.useCallback)(e=>$(`conversation`,`natural`,void 0,void 0,!1,e),[$]),at=(0,d.useCallback)(()=>{let e=performance.now(),t=H.current;z.current?.clear(),G.current.clear(),H.current=null,S(`idle`),t&&(R.current?.reportMetric(t,`local_stop`,performance.now()-e),R.current?.cancelResponse(t))},[]),ot=(0,d.useCallback)(()=>{let e=!T.current;T.current=e,e&&(G.current.clear(),z.current?.duck(!1)),Le.current?.getAudioTracks().forEach(t=>{t.enabled=!e});let t=L.current,n=R.current;t&&n&&(Ne.current=new ge(t.sampleRate,n.session.inputFormat.sampleRate)),n?.setInputMuted(e),_(``),h(0),z.current?.duck(!1),he(e)},[]);return{phase:s,voiceActive:s!==`idle`,recordedDictation:l,elapsedLabel:Ce(ae),audioLevel:m,partialTranscript:g,finalTranscript:se,responseText:le,activeTaskIds:Ve,cancelTask:e=>{U.current.has(e)&&R.current?.cancelTask(e)},activities:de,clarification:y,dismissClarification:e=>b(t=>t?.requestId===e?null:t),responsePhase:x,callConnectionStage:C,muted:me,error:_e,failureKind:D,settingsRequired:A,endedReason:Oe,mode:Ae,startVoiceInput:nt,startVoiceConversation:rt,startHiggsTest:it,interruptResponse:at,toggleMute:ot,cancelVoiceInput:Xe,confirmVoiceInput:et,retryVoiceInput:tt}}export{ve as a,he as c,fe as d,ee as f,be as i,me as l,xe as n,ge as o,te as p,M as r,C as s,Oe as t,pe as u};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,s as i}from"./workspace-api-LghfbP5g.js";var a=e(t(),1);function o(e){return e.map(e=>({fileId:e.id,name:e.name,path:e.path,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function s(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:s(e.children,t,n)}:e)}function c(e,t,c){let[l,u]=(0,a.useState)([]),[d,f]=(0,a.useState)(null),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(null),_=(0,a.useRef)(new Set),v=e.trim(),y=t?.trim()??``,b=c?.trim()??``,x=b?``:y,S=!b&&!y?v:``,C=(0,a.useMemo)(()=>{if(b)return{projectId:b};if(x)return{conversationId:x};if(S)return{agentId:S}},[b,x,S]);return{tree:l,rootResource:d,loading:p,error:h,loadRoot:(0,a.useCallback)(async()=>{m(!0),g(null),_.current.clear();try{let[e,t]=await Promise.all([n(``,C),r(C)]);u(o(e.entries)),f(o([t])[0]??null),_.current.add(``)}catch(e){f(null),g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[C]),loadChildren:(0,a.useCallback)(async e=>{if(!_.current.has(e)){_.current.add(e);try{let t=o(await i(e,C));u(n=>s(n,e,t))}catch{_.current.delete(e)}}},[C]),refreshDirectory:(0,a.useCallback)(async e=>{let t=o(await i(e,C));u(e?n=>s(n,e,t):t),_.current.add(e)},[C]),reset:(0,a.useCallback)(()=>{u([]),f(null),g(null),_.current.clear()},[])}}export{c as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,s as i}from"./workspace-api-Dd_UDfeo.js";var a=e(t(),1);function o(e){return e.map(e=>({fileId:e.id,name:e.name,path:e.path,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function s(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:s(e.children,t,n)}:e)}function c(e,t,c){let[l,u]=(0,a.useState)([]),[d,f]=(0,a.useState)(null),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(null),_=(0,a.useRef)(new Set),v=e.trim(),y=t?.trim()??``,b=c?.trim()??``,x=b?``:y,S=!b&&!y?v:``,C=(0,a.useMemo)(()=>{if(b)return{projectId:b};if(x)return{conversationId:x};if(S)return{agentId:S}},[b,x,S]);return{tree:l,rootResource:d,loading:p,error:h,loadRoot:(0,a.useCallback)(async()=>{m(!0),g(null),_.current.clear();try{let[e,t]=await Promise.all([n(``,C),r(C)]);u(o(e.entries)),f(o([t])[0]??null),_.current.add(``)}catch(e){f(null),g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[C]),loadChildren:(0,a.useCallback)(async e=>{if(!_.current.has(e)){_.current.add(e);try{let t=o(await i(e,C));u(n=>s(n,e,t))}catch{_.current.delete(e)}}},[C]),refreshDirectory:(0,a.useCallback)(async e=>{let t=o(await i(e,C));u(e?n=>s(n,e,t):t),_.current.add(e)},[C]),reset:(0,a.useCallback)(()=>{u([]),f(null),g(null),_.current.clear()},[])}}export{c as t};