@xopcai/xopc 0.0.405 → 0.0.407

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 (232) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/feishu/src/transport/socket-mode/monitor.js +1 -1
  3. package/dist/extensions/feishu/src/transport/webhook/monitor.js +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-wc__VG7A.js → agent-avatar-dicebear-CPNoFyoV.js} +1 -1
  6. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BB0O3b4I.js +1 -0
  7. package/dist/gateway/static/root/assets/agents-Y7XtlqVm.js +77 -0
  8. package/dist/gateway/static/root/assets/{agents-admin-api-D6XzhsQy.js → agents-admin-api-D0UyB0Y_.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-DnQKk3ql.js → app-management-settings-panel-BOAkMTQ7.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-CoL67S5e.js → appearance-settings-BWPt4-vh.js} +1 -1
  11. package/dist/gateway/static/root/assets/apps-page-Ln5N1PK3.js +1 -0
  12. package/dist/gateway/static/root/assets/{archive-plugin-CgKj53U1.js → archive-plugin-CNjE6PYZ.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-Cr_WMoqc.js → automations-page-BsP4j7Nw.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-workspace-lq17XY3n.js +6 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-C_h3FTTz.js → binary-plugins-AFWJskT6.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-lnkSRbxE.js → block-editor-SQ53S4oy.js} +40 -40
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-FsIEAlnO.js → browser-automation-inputs-C2SC9h-c.js} +1 -1
  18. package/dist/gateway/static/root/assets/browser-automations-page-kRoqj1qn.js +3 -0
  19. package/dist/gateway/static/root/assets/browser-settings-page-dZhjL3oj.js +3 -0
  20. package/dist/gateway/static/root/assets/capabilities-CD6PzNK7.js +1 -0
  21. package/dist/gateway/static/root/assets/capabilities-page-Dnp_ilKR.js +2 -0
  22. package/dist/gateway/static/root/assets/capabilities-settings-panel-BA9kBBqE.js +8 -0
  23. package/dist/gateway/static/root/assets/{capability-header-actions-wTmkMFS8.js → capability-header-actions-Cq5XWEDs.js} +1 -1
  24. package/dist/gateway/static/root/assets/channels-BZCzeWtD.js +1 -0
  25. package/dist/gateway/static/root/assets/{chat-terminal-dock-DJjZ0p_B.js → chat-terminal-dock-BC4EyhTx.js} +2 -2
  26. package/dist/gateway/static/root/assets/computer-settings-page-MxcoTOP1.js +1 -0
  27. package/dist/gateway/static/root/assets/{connector-service-page-DavOiSs1.js → connector-service-page-tSQ3a_Ti.js} +1 -1
  28. package/dist/gateway/static/root/assets/connectors-page-h5FTgews.js +1 -0
  29. package/dist/gateway/static/root/assets/{date-picker-cGUcobcp.js → date-picker-CavoWXMc.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dependency-picker-BvEoPDqz.js → dependency-picker-Cl-3upFX.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-DL330r9w.js → desktop-pet-B-RDVNqR.js} +1 -1
  32. package/dist/gateway/static/root/assets/{desktop-pet-settings-BkBrKnpR.js → desktop-pet-settings-rttWyUzY.js} +1 -1
  33. package/dist/gateway/static/root/assets/device-pairing-wizard-6hqiv1ui.js +1 -0
  34. package/dist/gateway/static/root/assets/{directory-picker-path-field-Bq5EumS7.js → directory-picker-path-field-1rEGI8IE.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-debug-page-BcNqrM44.js → extension-debug-page-BaswNoXz.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-page-BIOXclKZ.js → extension-page-uCMJMnc_.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-settings-page-BdLmNW7c.js → extension-settings-page-DiczmHyl.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-config-swr-BvuySoCX.js → gateway-config-swr-CTXr917C.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-realtime-SBtdXzco.js → gateway-realtime-CP6L2jIR.js} +1 -1
  40. package/dist/gateway/static/root/assets/gateway-realtime-store-yXB4a40_.js +1 -0
  41. package/dist/gateway/static/root/assets/gateway-settings-DH5MOwxf.js +1 -0
  42. package/dist/gateway/static/root/assets/{gateway-startup-retry-CEpuztYK.js → gateway-startup-retry-DD2fsxdd.js} +1 -1
  43. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-BJBmXHUI.js → highlighted-body-KQOG7T2V-B62h4sJ4.js} +1 -1
  44. package/dist/gateway/static/root/assets/home-page-BsjMhloP.js +2 -0
  45. package/dist/gateway/static/root/assets/{image-generation-api-vO5_70v-.js → image-generation-api-Di7HnFSL.js} +1 -1
  46. package/dist/gateway/static/root/assets/{imports-page-xvg0vgTo.js → imports-page-DpKfYZMT.js} +1 -1
  47. package/dist/gateway/static/root/assets/index-BUv4J0JN.js +267 -0
  48. package/dist/gateway/static/root/assets/index-Cr4I4q1J.css +1 -0
  49. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D-jHSG1c.js → keyboard-shortcuts-settings-D1Q1kTMI.js} +1 -1
  50. package/dist/gateway/static/root/assets/local-app-workbench-page-CnaLbgJb.js +1 -0
  51. package/dist/gateway/static/root/assets/{local-apps-page-DQOK34TS.js → local-apps-page-CSO0RkyG.js} +1 -1
  52. package/dist/gateway/static/root/assets/{local-session-drafts-DhJjHCfQ.js → local-session-drafts-TqLFKwYo.js} +1 -1
  53. package/dist/gateway/static/root/assets/{locale-store-D5h-Ha6-.js → locale-store-D_migb9R.js} +1 -1
  54. package/dist/gateway/static/root/assets/logs-page-DruO5LTf.js +2 -0
  55. package/dist/gateway/static/root/assets/management-settings-Dw3tQKNe.js +1 -0
  56. package/dist/gateway/static/root/assets/{markdown-view-CthsQiiO.js → markdown-view-vQSMUUY_.js} +1 -1
  57. package/dist/gateway/static/root/assets/{media-plugins-4_OqZkJo.js → media-plugins-CrHXsih_.js} +1 -1
  58. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-CNzdVIcE.js +1 -0
  59. package/dist/gateway/static/root/assets/messages-D__oW2yE.js +3 -0
  60. package/dist/gateway/static/root/assets/note-detail-panel-DCZ6Vgd_.js +5 -0
  61. package/dist/gateway/static/root/assets/note-image-lightbox-BXNZw7lJ.js +1 -0
  62. package/dist/gateway/static/root/assets/notes-page-Bqy9Rh_j.js +8 -0
  63. package/dist/gateway/static/root/assets/{page-context-capture-button-DkFhXsZj.js → page-context-capture-button-DQHbuYER.js} +1 -1
  64. package/dist/gateway/static/root/assets/personal-page-C--WEB5c.js +1 -0
  65. package/dist/gateway/static/root/assets/personal-proactivity-BJcZ3Yhi.js +1 -0
  66. package/dist/gateway/static/root/assets/personal-settings-panel-Cwgc13ls.js +1 -0
  67. package/dist/gateway/static/root/assets/plugin-details-dialog-DxkFHaU-.js +1 -0
  68. package/dist/gateway/static/root/assets/plugin-presentation-CO5BFDGW.js +1 -0
  69. package/dist/gateway/static/root/assets/{preview-open-alternatives-Bz7-AqIY.js → preview-open-alternatives-BW7P2akd.js} +1 -1
  70. package/dist/gateway/static/root/assets/{product-open-page-uAU6q84_.js → product-open-page-BnlpaYs-.js} +1 -1
  71. package/dist/gateway/static/root/assets/product-preview-content-DkXx1Vt8.js +1 -0
  72. package/dist/gateway/static/root/assets/project-detail-page-CtyCpIx8.js +1 -0
  73. package/dist/gateway/static/root/assets/projects-page-CJ0s-bI5.js +1 -0
  74. package/dist/gateway/static/root/assets/{registry-api-Bf0hVPNV.js → registry-api-4NZOh0iz.js} +1 -1
  75. package/dist/gateway/static/root/assets/remote-access-hub-yItNjAR3.js +1 -0
  76. package/dist/gateway/static/root/assets/{runtime-tools-api-ByH1meP7.js → runtime-tools-api-CmEWVrOg.js} +1 -1
  77. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-D2VV6nm2.js → runtime-tools-settings-panel-BGRbt79f.js} +1 -1
  78. package/dist/gateway/static/root/assets/{schema-form-gO0zayZd.js → schema-form-B9VP7ldU.js} +1 -1
  79. package/dist/gateway/static/root/assets/{session-api-fVuszA_P.js → session-api-aQLptIs9.js} +1 -1
  80. package/dist/gateway/static/root/assets/session-manager-D2sLfkw-.js +16 -0
  81. package/dist/gateway/static/root/assets/sessions-page-3O5S9efw.js +1 -0
  82. package/dist/gateway/static/root/assets/settings-advanced-gate-BE-SKsf6.js +1 -0
  83. package/dist/gateway/static/root/assets/{settings-form-section-CihKQYlF.js → settings-form-section-BA2RkU1S.js} +1 -1
  84. package/dist/gateway/static/root/assets/settings-page-BUT0FzfI.js +1 -0
  85. package/dist/gateway/static/root/assets/{setup-status-panel-BWVb5uxa.js → setup-status-panel-1oWs6iPS.js} +1 -1
  86. package/dist/gateway/static/root/assets/{share-preview-page-Dg0mhito.js → share-preview-page-CVNey8Lq.js} +1 -1
  87. package/dist/gateway/static/root/assets/shares-settings-Bb6YoDmU.js +1 -0
  88. package/dist/gateway/static/root/assets/{skill-api-CrNz0Fi0.js → skill-api-BWi0G9Ii.js} +1 -1
  89. package/dist/gateway/static/root/assets/skill-reload-api-DspV2olR.js +1 -0
  90. package/dist/gateway/static/root/assets/skills-page-SbNv1vpY.js +2 -0
  91. package/dist/gateway/static/root/assets/{style-CuYP4CAT.js → style-DlOTU5bN.js} +1 -1
  92. package/dist/gateway/static/root/assets/{system-settings-panel-DGFMkic_.js → system-settings-panel-DbS1qtOh.js} +1 -1
  93. package/dist/gateway/static/root/assets/task-detail-page-uSwizzx8.js +2 -0
  94. package/dist/gateway/static/root/assets/{task-expandable-content-BoGtWYbk.js → task-expandable-content-D0ahXP9o.js} +1 -1
  95. package/dist/gateway/static/root/assets/tracing-settings-page-BMhVvXXd.js +1 -0
  96. package/dist/gateway/static/root/assets/{tunnel-api-CnLkQQGi.js → tunnel-api-CO9rJLFh.js} +1 -1
  97. package/dist/gateway/static/root/assets/{usage-page-BInqKKdE.js → usage-page-DVzIDec4.js} +1 -1
  98. package/dist/gateway/static/root/assets/{use-autosave-0dTfTmCk.js → use-autosave-DqPaXiX2.js} +1 -1
  99. package/dist/gateway/static/root/assets/user-model-page-BYZCHCzG.js +2 -0
  100. package/dist/gateway/static/root/assets/{voice-api-key-field-BpOvEhu7.js → voice-api-key-field-C_iOzfIt.js} +1 -1
  101. package/dist/gateway/static/root/assets/{voice-config-api-CRjdZdJF.js → voice-config-api-4yGMrp7J.js} +1 -1
  102. package/dist/gateway/static/root/assets/{work-discovery-overlay-Br-XaBAW.js → work-discovery-overlay-n59s18s0.js} +1 -1
  103. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-B8E6qBkL.js → workflow-run-setup-panel-Lp6Vumxc.js} +2 -2
  104. package/dist/gateway/static/root/assets/workflows-page-B5BqN1Y1.js +6 -0
  105. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-BARP73BX.js → xopc-cloud-account-card-QSDUy0uF.js} +1 -1
  106. package/dist/gateway/static/root/index.html +16 -15
  107. package/dist/package.js +1 -1
  108. package/dist/packages/gateway-contract/src/capabilities.js +30 -3
  109. package/dist/src/agent/external-tools/cliProvider.js +1 -1
  110. package/dist/src/agent/prompt/conversational-configuration-guide.d.ts +4 -0
  111. package/dist/src/agent/prompt/conversational-configuration-guide.js +25 -0
  112. package/dist/src/agent/prompt/service-prompt-builder.js +6 -1
  113. package/dist/src/agent/prompt/system-prompt.js +2 -2
  114. package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +8 -0
  115. package/dist/src/agent/tool-manuals/xopc-configuration.js +55 -0
  116. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  117. package/dist/src/agent/tool-manuals/xopc-use.js +4 -1
  118. package/dist/src/agent/tools/factory.js +0 -5
  119. package/dist/src/agent/tools/tool-manual-tool.d.ts +1 -0
  120. package/dist/src/agent/tools/tool-manual-tool.js +27 -2
  121. package/dist/src/agent/tools/xopc-use-tool.js +12 -7
  122. package/dist/src/agent-catalog/capabilities.js +27 -1
  123. package/dist/src/agent-config/index.js +2 -2
  124. package/dist/src/agent-config/schema.d.ts +0 -116
  125. package/dist/src/agent-config/schema.js +2 -32
  126. package/dist/src/capabilities/store-connector.d.ts +9 -1
  127. package/dist/src/capabilities/store-connector.js +30 -1
  128. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  129. package/dist/src/config/schema.d.ts +1 -1
  130. package/dist/src/connectors/cli/adapterRegistry.js +1 -8
  131. package/dist/src/connectors/cli/runtime.js +1 -1
  132. package/dist/src/connectors/composio-catalog.d.ts +2 -2
  133. package/dist/src/connectors/composio-catalog.js +3 -8
  134. package/dist/src/connectors/composio-sessions.js +2 -0
  135. package/dist/src/connectors/composio.js +0 -6
  136. package/dist/src/connectors/connection-candidates.js +0 -5
  137. package/dist/src/connectors/connection-capabilities.js +0 -4
  138. package/dist/src/connectors/excluded-connectors.d.ts +4 -0
  139. package/dist/src/connectors/excluded-connectors.js +24 -0
  140. package/dist/src/connectors/install.js +3 -0
  141. package/dist/src/connectors/integration-strategy.js +0 -5
  142. package/dist/src/connectors/providers.d.ts +0 -1
  143. package/dist/src/connectors/providers.js +2 -14
  144. package/dist/src/gateway/hono/routes/personal-agent.js +4 -5
  145. package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
  146. package/dist/src/personal-agent/communication.d.ts +1 -1
  147. package/dist/src/personal-agent/communication.js +1 -1
  148. package/dist/src/personal-agent/default-style.d.ts +2 -0
  149. package/dist/src/personal-agent/default-style.js +11 -0
  150. package/dist/src/personal-agent/persona.d.ts +1 -1
  151. package/dist/src/personal-agent/persona.js +1 -1
  152. package/dist/src/personal-agent/policy.d.ts +1 -1
  153. package/dist/src/personal-agent/policy.js +0 -1
  154. package/dist/src/personal-agent/proactivity/service.js +1 -4
  155. package/dist/src/personal-agent/prompts.d.ts +1 -5
  156. package/dist/src/personal-agent/prompts.js +28 -39
  157. package/dist/src/personal-agent/reply-composer.js +3 -2
  158. package/dist/src/personal-agent/reply-style.d.ts +10 -2
  159. package/dist/src/personal-agent/reply-style.js +61 -3
  160. package/dist/src/personal-agent/repository.d.ts +0 -8
  161. package/dist/src/personal-agent/repository.js +1 -9
  162. package/dist/src/personal-agent/service.d.ts +2 -32
  163. package/dist/src/personal-agent/service.js +11 -17
  164. package/dist/src/platform/contracts.d.ts +3 -3
  165. package/dist/src/storage/sqlite/migrations/259_personal_default_style.sql +10 -0
  166. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  167. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  168. package/dist/src/storage/sqlite/schema.js +1 -1
  169. package/dist/src/tasks/task-main-update-decision-service.js +1 -1
  170. package/package.json +4 -1
  171. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DRgnm9A5.js +0 -1
  172. package/dist/gateway/static/root/assets/agents-sIMLDv80.js +0 -77
  173. package/dist/gateway/static/root/assets/apps-page-CRAr0xnF.js +0 -1
  174. package/dist/gateway/static/root/assets/automations-workspace-BGpO47Sw.js +0 -6
  175. package/dist/gateway/static/root/assets/browser-BLJWD7WI.js +0 -8
  176. package/dist/gateway/static/root/assets/browser-automations-page-Dwhk5TFz.js +0 -3
  177. package/dist/gateway/static/root/assets/browser-settings-page-B1Mfsw2n.js +0 -3
  178. package/dist/gateway/static/root/assets/capabilities-Dl3LttAm.js +0 -1
  179. package/dist/gateway/static/root/assets/capabilities-page-lfNS8DDp.js +0 -2
  180. package/dist/gateway/static/root/assets/capabilities-settings-panel-DLL614DS.js +0 -8
  181. package/dist/gateway/static/root/assets/capability-icon-DVoZxEgW.js +0 -1
  182. package/dist/gateway/static/root/assets/capability-links-DzQWK1Fh.js +0 -1
  183. package/dist/gateway/static/root/assets/channels-W60IrDrt.js +0 -1
  184. package/dist/gateway/static/root/assets/computer-settings-page-BYYgEEdX.js +0 -1
  185. package/dist/gateway/static/root/assets/connectors-page-BUTj6vNY.js +0 -1
  186. package/dist/gateway/static/root/assets/device-pairing-wizard-BYUl_dNS.js +0 -1
  187. package/dist/gateway/static/root/assets/gateway-realtime-store-dKq2fm2X.js +0 -1
  188. package/dist/gateway/static/root/assets/gateway-settings-C1vgqKYa.js +0 -1
  189. package/dist/gateway/static/root/assets/home-page-Cd4MHgKf.js +0 -2
  190. package/dist/gateway/static/root/assets/index-DdJ_djQt.js +0 -260
  191. package/dist/gateway/static/root/assets/index-QegseiyI.css +0 -1
  192. package/dist/gateway/static/root/assets/local-app-workbench-page-ER7_0M_4.js +0 -1
  193. package/dist/gateway/static/root/assets/logs-page-_v_abG4D.js +0 -2
  194. package/dist/gateway/static/root/assets/management-settings-CWojbrEe.js +0 -1
  195. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-BXiiOI72.js +0 -1
  196. package/dist/gateway/static/root/assets/messages-Bwv-AOYl.js +0 -3
  197. package/dist/gateway/static/root/assets/note-detail-panel-tHYUDAgB.js +0 -5
  198. package/dist/gateway/static/root/assets/note-image-lightbox-DwVH-T8-.js +0 -1
  199. package/dist/gateway/static/root/assets/notes-page-BQqxqB3t.js +0 -8
  200. package/dist/gateway/static/root/assets/personal-page-DyKbVh4z.js +0 -1
  201. package/dist/gateway/static/root/assets/plugin-details-dialog-CVbHabgS.js +0 -1
  202. package/dist/gateway/static/root/assets/plugin-presentation-BfVM-8kL.js +0 -1
  203. package/dist/gateway/static/root/assets/product-preview-content-DsPKx_gw.js +0 -1
  204. package/dist/gateway/static/root/assets/project-detail-page-BpUxpCUt.js +0 -1
  205. package/dist/gateway/static/root/assets/projects-page-BWrQ05az.js +0 -1
  206. package/dist/gateway/static/root/assets/remote-access-hub-D4k7snPU.js +0 -1
  207. package/dist/gateway/static/root/assets/session-manager-BMEW_eS_.js +0 -16
  208. package/dist/gateway/static/root/assets/sessions-page-DPrI8ql2.js +0 -1
  209. package/dist/gateway/static/root/assets/settings-advanced-gate-BYXPsUzS.js +0 -1
  210. package/dist/gateway/static/root/assets/settings-page-BYP_I9AF.js +0 -1
  211. package/dist/gateway/static/root/assets/shares-settings-q0E4FYlf.js +0 -1
  212. package/dist/gateway/static/root/assets/skill-reload-api-BNCLOlJs.js +0 -1
  213. package/dist/gateway/static/root/assets/skills-page-CYwH8kim.js +0 -2
  214. package/dist/gateway/static/root/assets/task-detail-page-CTqBd0eY.js +0 -2
  215. package/dist/gateway/static/root/assets/tracing-settings-page-0CvZ40sA.js +0 -1
  216. package/dist/gateway/static/root/assets/user-model-page-3Dr0YRDG.js +0 -2
  217. package/dist/gateway/static/root/assets/workflows-page-CqC45_Fd.js +0 -6
  218. package/dist/src/agent/tools/personal-preference-tool.d.ts +0 -10
  219. package/dist/src/agent/tools/personal-preference-tool.js +0 -55
  220. package/dist/src/connectors/china-catalog.d.ts +0 -2
  221. package/dist/src/connectors/china-catalog.js +0 -873
  222. package/dist/src/connectors/cli/adapters/lark.d.ts +0 -2
  223. package/dist/src/connectors/cli/adapters/lark.js +0 -143
  224. package/dist/src/connectors/cli/adapters/larkShortcuts.d.ts +0 -3
  225. package/dist/src/connectors/cli/adapters/larkShortcuts.js +0 -64
  226. package/dist/src/connectors/cli/adapters/wecom.d.ts +0 -2
  227. package/dist/src/connectors/cli/adapters/wecom.js +0 -97
  228. package/dist/src/connectors/cli/adapters/wps365/bundle.js +0 -575
  229. package/dist/src/connectors/cli/adapters/wps365.d.ts +0 -2
  230. package/dist/src/connectors/cli/adapters/wps365.js +0 -115
  231. package/dist/src/connectors/cli/distributions.d.ts +0 -4
  232. package/dist/src/connectors/cli/distributions.js +0 -69
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-lnkSRbxE.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-DdJ_djQt.js","assets/preload-helper-zJ_50EbN.js","assets/es2015-DBLcMg5B.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-D5h-Ha6-.js","assets/messages-Bwv-AOYl.js","assets/dist-CI_fqRk-.js","assets/floating-ui.dom-B7uQOZZW.js","assets/markdown-view-CthsQiiO.js","assets/dist-BGTk37IG.js","assets/chunk-KS7C4IRE-B2HK1psj.js","assets/createLucideIcon-DPHK1VkS.js","assets/download-Dk-ZjtO6.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/mermaid-render-604gISVe.js","assets/xml-_d7dTN2Q.js","assets/app-link-BV_eGr7l.js","assets/product-delivery-DwmnNJvk.js","assets/schemas-CObaziC7.js","assets/local-apps-yys1VChX.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/markdown-view-Ct4sKkUf.css","assets/vendor-swr-BIWyz7Rc.js","assets/check-DUBLcKHA.js","assets/circle-check-C23XjkUj.js","assets/copy-Dv6d4Dvw.js","assets/ellipsis-0k4rZLoy.js","assets/external-link-DjqjBmc3.js","assets/eye-CABVeTq0.js","assets/folder-open-CyzJ19I9.js","assets/session-manager-BMEW_eS_.js","assets/gateway-realtime-SBtdXzco.js","assets/gateway-realtime-store-dKq2fm2X.js","assets/local-session-drafts-DhJjHCfQ.js","assets/session-api-fVuszA_P.js","assets/gateway-startup-retry-CEpuztYK.js","assets/constants-DeXt1mV-.js","assets/tool-activity-BtJkgjFf.js","assets/registry-api-Bf0hVPNV.js","assets/attachment-utils-core-BIOUBrpT.js","assets/agents-admin-api-D6XzhsQy.js","assets/gateway-config-swr-BvuySoCX.js","assets/capabilities-Dl3LttAm.js","assets/tasks-B4bZpO6O.js","assets/specialists-4bkS5rZ4.js","assets/files-Bw4SBGdM.js","assets/sliding-indicator-hwz0sx3h.js","assets/index-QegseiyI.css","assets/vendor-codemirror-DFxP3B9T.js","assets/with-selector-aYPsXwdl.js","assets/note-image-lightbox-DwVH-T8-.js","assets/block-editor-Cvy3D_4T.css","assets/markdown-editor-BhBJANcx.js","assets/code-editor-CXIH8jQw.js","assets/languages-BFe8nIOO.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-zJ_50EbN.js";import{d as a,f as o,t as s}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as c}from"./check-DUBLcKHA.js";import{t as l}from"./circle-check-C23XjkUj.js";import{t as u}from"./copy-Dv6d4Dvw.js";import{t as d}from"./download-Dk-ZjtO6.js";import{t as f}from"./ellipsis-0k4rZLoy.js";import{t as p}from"./external-link-DjqjBmc3.js";import{t as m}from"./eye-CABVeTq0.js";import{P as h}from"./markdown-view-CthsQiiO.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./messages-Bwv-AOYl.js";import{t as v}from"./cn-0WouolD0.js";import{a as y,c as b,f as x,n as S,p as C,r as w}from"./locale-store-D5h-Ha6-.js";import{a as T,i as E,n as D,o as O,r as k,s as A,t as j}from"./dist-BGTk37IG.js";import{t as M}from"./session-manager-BMEW_eS_.js";import{t as N}from"./copy-to-clipboard-HOJ79TWv.js";import{i as P}from"./vendor-swr-BIWyz7Rc.js";import{$r as F,Af as I,Ao as L,Ar as R,Bc as z,Bs as B,Ds as ee,Ea as te,Es as ne,Fl as re,Fr as ie,Go as ae,Il as V,It as oe,Jl as se,Ju as H,Kc as U,Kl as ce,Mr as le,N as ue,Nl as de,Nr as fe,Or as pe,P as me,Pd as he,Qr as W,Rc as ge,Sa as _e,Sr as G,Ta as ve,Ts as ye,Uu as be,Vc as xe,Wl as Se,Yd as K,Za as Ce,_n as we,_r as Te,a as q,ar as Ee,au as De,c as Oe,cn as J,dr as ke,ds as Ae,du as Y,ei as je,er as Me,eu as Ne,fs as X,gn as Pe,gr as Fe,hr as Ie,ir as Le,jf as Re,jr as ze,kr as Be,ks as Ve,l as He,ln as Ue,mr as We,nr as Ge,o as Ke,on as Z,pf as qe,pr as Je,rd as Ye,rr as Xe,s as Ze,sn as Qe,ti as $e,tr as et,un as tt,ur as nt,va as rt,vn as it,vr as at,wr as ot,ws as st,wu as ct,xr as lt,ya as ut,yd as dt,yn as ft,yr as pt,yu as mt}from"./index-DdJ_djQt.js";import"./note-image-lightbox-DwVH-T8-.js";import{t as ht}from"./page-context-capture-button-DkFhXsZj.js";var Q=e(t(),1),gt=n(),$=r(),_t=6e4,vt=36e5,yt=864e5;function bt(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function xt(e,t,n){let r=t-e;if(r<_t)return n.justNow;if(r<vt){let e=Math.floor(r/_t);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=bt(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(e>=i-yt)return n.yesterday+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(r<7*yt){let e=Math.floor(r/yt);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(n.locale,{month:`short`,day:`numeric`})}function St(e,t,n){let r=bt(t);if(e>=r)return n.today;if(e>=r-yt)return n.yesterday;let i=new Date(e),a=new Date(t);return i.getFullYear()===a.getFullYear()?i.toLocaleDateString(n.locale,{month:`long`,day:`numeric`}):i.toLocaleDateString(n.locale,{year:`numeric`,month:`long`,day:`numeric`})}function Ct(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function wt(e){let t=(0,gt.c)(45),{title:n,description:r,prompt:i,coverage:a,className:s,variant:c}=e,u=c===void 0?`card`:c,d=S(Dt),f=_(d).automations.suggestions,p=_(d).automations,m=o(),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=h):h=t[0];let{data:g}=P(a?`automation-suggestion-coverage`:null,Et,h),y=a?g?.automations.find(e=>Oe(e,a)):void 0,b=y?Ke(y,p):[];if(u===`titleAction`){if(y){let e;t[1]===s?e=t[2]:(e=v(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,s),t[1]=s,t[2]=e);let n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(l,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=n):n=t[3];let r;return t[4]===m?r=t[5]:(r=()=>m(`/automations`),t[4]=m,t[5]=r),(0,$.jsxs)(`section`,{className:e,children:[n,(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:f.coveredTitle}),(0,$.jsx)(U,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:r,children:f.manage})]})}let e;t[6]===s?e=t[7]:(e=v(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,s),t[6]=s,t[7]=e);let a;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Ye,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=a):a=t[8];let o;t[9]!==r||t[10]!==n?(o=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:r,children:n}),t[9]=r,t[10]=n,t[11]=o):o=t[11];let c;t[12]!==m||t[13]!==i?(c=()=>{m(`/automations?${new URLSearchParams({draft:i,autogenerate:`1`}).toString()}`)},t[12]=m,t[13]=i,t[14]=c):c=t[14];let u;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),t[15]=u):u=t[15],(0,$.jsxs)(`section`,{className:e,children:[a,o,(0,$.jsxs)(U,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:c,children:[u,f.setup]})]})}if(y){let e;t[16]===s?e=t[17]:(e=v(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,s),t[16]=s,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=n):n=t[18];let r;t[19]===m?r=t[20]:(r=()=>m(`/automations`),t[19]=m,t[20]=r);let i;return t[21]!==f||t[22]!==r?(i=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsx)(U,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:r,children:f.manage})}),t[21]=f,t[22]=r,t[23]=i):i=t[23],(0,$.jsxs)(`section`,{className:e,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:f.coveredTitle}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:Ze(f.coveredDescription,{name:y.name})})]})]}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:p.explain.whyCovered}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:b.map(Tt)})]}),i]})}let x;t[24]===s?x=t[25]:(x=v(`rounded-lg bg-surface-panel p-3 shadow-surface`,s),t[24]=s,t[25]=x);let C;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(Ye,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=C):C=t[26];let w;t[27]===n?w=t[28]:(w=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n}),t[27]=n,t[28]=w);let T;t[29]===r?T=t[30]:(T=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:r}),t[29]=r,t[30]=T);let E;t[31]!==w||t[32]!==T?(E=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[C,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,T]})]}),t[31]=w,t[32]=T,t[33]=E):E=t[33];let D;t[34]!==m||t[35]!==i?(D=()=>{m(`/automations?${new URLSearchParams({draft:i,autogenerate:`1`}).toString()}`)},t[34]=m,t[35]=i,t[36]=D):D=t[36];let O;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),t[37]=O):O=t[37];let k;t[38]!==f.create||t[39]!==D?(k=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(U,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:D,children:[O,f.create]})}),t[38]=f.create,t[39]=D,t[40]=k):k=t[40];let A;return t[41]!==k||t[42]!==x||t[43]!==E?(A=(0,$.jsxs)(`section`,{className:x,children:[E,k]}),t[41]=k,t[42]=x,t[43]=E,t[44]=A):A=t[44],A}function Tt(e){return(0,$.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function Et(){return He.list()}function Dt(e){return e.language}function Ot(e){let t=(0,gt.c)(93),{detail:n,template:r,onTemplate:i,zh:a,busy:o,processing:s,pageText:c,editing:l,onOrganize:u,onRegenerate:p,onPersonalNotes:m,noteActions:h}=e,[g,_]=(0,Q.useState)(!1),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{_(!1),e()},t[0]=v):v=t[0];let y=v,b=`/api/discussions/${encodeURIComponent(n.discussion.id)}`,x=!!n.discussion.audioAttachmentId&&!n.discussion.audioDeletedAt,S=a?`更多笔记操作`:`More note actions`,C;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(f,{className:`size-5`,"aria-hidden":!0}),t[1]=C):C=t[1];let T;t[2]===S?T=t[3]:(T=(0,$.jsx)(ee,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":S,className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:C})}),t[2]=S,t[3]=T);let E=a?`笔记工具`:`Note tools`,D;t[4]!==m||t[5]!==a?(D=m?(0,$.jsxs)(U,{className:`min-h-11 w-full justify-start`,onClick:()=>y(m),children:[(0,$.jsx)(ce,{className:`size-4`}),a?`添加我的补充`:`Add my notes`]}):null,t[4]=m,t[5]=a,t[6]=D):D=t[6];let O;t[7]!==h||t[8]!==a?(O=h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(U,{className:`min-h-11 w-full justify-start`,disabled:h.busy,onClick:()=>y(h.onAnalyze),children:[(0,$.jsx)(se,{className:`size-4`}),a?`进一步分析`:`Analyze this note`]}),(0,$.jsxs)(U,{className:`min-h-11 w-full justify-start`,disabled:h.busy,onClick:()=>y(h.onChat),children:[(0,$.jsx)(be,{className:`size-4`}),a?`就这篇笔记提问`:`Ask about this note`]})]}):null,t[7]=h,t[8]=a,t[9]=O):O=t[9];let k=a?`整理笔记`:`Organize notes`,A;t[10]===k?A=t[11]:(A=(0,$.jsx)(`p`,{className:`px-2 text-xs text-fg-muted`,children:k}),t[10]=k,t[11]=A);let j=a?`纪要模板`:`Summary template`,M;t[12]===i?M=t[13]:(M=e=>i(e.target.value),t[12]=i,t[13]=M);let N=a?`通用会议`:`General`,P;t[14]===N?P=t[15]:(P=(0,$.jsx)(X,{value:`general`,children:N}),t[14]=N,t[15]=P);let F=a?`项目例会`:`Project`,I;t[16]===F?I=t[17]:(I=(0,$.jsx)(X,{value:`project`,children:F}),t[16]=F,t[17]=I);let L=a?`需求评审`:`Review`,R;t[18]===L?R=t[19]:(R=(0,$.jsx)(X,{value:`review`,children:L}),t[18]=L,t[19]=R);let z=a?`客户访谈`:`Interview`,B;t[20]===z?B=t[21]:(B=(0,$.jsx)(X,{value:`interview`,children:z}),t[20]=z,t[21]=B);let te;t[22]!==j||t[23]!==M||t[24]!==P||t[25]!==I||t[26]!==R||t[27]!==B||t[28]!==r?(te=(0,$.jsxs)(Ae,{value:r,"aria-label":j,onChange:M,children:[P,I,R,B]}),t[22]=j,t[23]=M,t[24]=P,t[25]=I,t[26]=R,t[27]=B,t[28]=r,t[29]=te):te=t[29];let re=o||s||!n.discussion.canonicalTranscript,ie;t[30]===u?ie=t[31]:(ie=()=>y(u),t[30]=u,t[31]=ie);let ae;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(Y,{className:`size-4`}),t[32]=ae):ae=t[32];let V=a?`重新整理纪要`:`Regenerate summary`,oe;t[33]!==re||t[34]!==ie||t[35]!==V?(oe=(0,$.jsxs)(U,{className:`min-h-11 w-full justify-start`,disabled:re,onClick:ie,children:[ae,V]}),t[33]=re,t[34]=ie,t[35]=V,t[36]=oe):oe=t[36];let H;t[37]!==x||t[38]!==o||t[39]!==n.discussion.status||t[40]!==p||t[41]!==s||t[42]!==a?(H=x&&[`completed`,`needs_attention`].includes(n.discussion.status)?(0,$.jsx)(U,{className:`min-h-11 w-full justify-start`,disabled:o||s,onClick:()=>y(p),children:a?`从原音重新生成`:`Regenerate from audio`}):null,t[37]=x,t[38]=o,t[39]=n.discussion.status,t[40]=p,t[41]=s,t[42]=a,t[43]=H):H=t[43];let le;t[44]!==te||t[45]!==oe||t[46]!==H||t[47]!==A?(le=(0,$.jsxs)(`div`,{className:`space-y-2 py-3`,children:[A,te,oe,H]}),t[44]=te,t[45]=oe,t[46]=H,t[47]=A,t[48]=le):le=t[48];let ue=a?`导出与分享`:`Export and share`,de;t[49]===ue?de=t[50]:(de=(0,$.jsx)(`p`,{className:`px-2 text-xs text-fg-muted`,children:ue}),t[49]=ue,t[50]=de);let fe;t[51]!==x||t[52]!==b||t[53]!==a?(fe=x?(0,$.jsxs)(`a`,{className:`flex min-h-11 items-center gap-2 rounded-lg px-2 text-sm hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,href:w(`${b}/audio`),download:!0,children:[(0,$.jsx)(d,{className:`size-4`}),a?`下载录音`:`Download recording`]}):null,t[51]=x,t[52]=b,t[53]=a,t[54]=fe):fe=t[54];let pe;t[55]!==h||t[56]!==a?(pe=h?(0,$.jsx)(U,{className:`min-h-11 w-full justify-start`,disabled:h.busy,onClick:()=>y(h.onShare),children:a?`分享笔记`:`Share note`}):null,t[55]=h,t[56]=a,t[57]=pe):pe=t[57];let me;t[58]===b?me=t[59]:(me=(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`md`,`txt`,`srt`].map(e=>(0,$.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-lg px-3 text-sm text-accent-fg hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,href:w(`${b}/export?format=${e}`),download:!0,children:e.toUpperCase()},e))}),t[58]=b,t[59]=me);let he=n.note.id,W=String(n.note.remoteVersion??1),ge;t[60]!==n.note.id||t[61]!==W?(ge={kind:`note`,id:he,revision:W},t[60]=n.note.id,t[61]=W,t[62]=ge):ge=t[62];let _e;t[63]===c?_e=t[64]:(_e={text:c,draft:!1},t[63]=c,t[64]=_e);let G=a?`带到新对话`:`Use in a new chat`,ve=o||s||l||!c||c.length>16e3,xe;t[65]!==ge||t[66]!==_e||t[67]!==G||t[68]!==ve?(xe=(0,$.jsx)(ht,{resource:ge,selection:_e,label:G,disabled:ve}),t[65]=ge,t[66]=_e,t[67]=G,t[68]=ve,t[69]=xe):xe=t[69];let Se=c.length>16e3?a?`内容较长,请先筛选部分原文。`:`Filter the transcript to share a smaller selection.`:a?`分享当前显示的文字,不包含原音。`:`Shares displayed text, without audio.`,K;t[70]===Se?K=t[71]:(K=(0,$.jsx)(`p`,{className:`px-2 text-xs leading-5 text-fg-muted`,children:Se}),t[70]=Se,t[71]=K);let Ce;t[72]!==de||t[73]!==fe||t[74]!==pe||t[75]!==me||t[76]!==xe||t[77]!==K?(Ce=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle py-3`,children:[de,fe,pe,me,xe,K]}),t[72]=de,t[73]=fe,t[74]=pe,t[75]=me,t[76]=xe,t[77]=K,t[78]=Ce):Ce=t[78];let we;t[79]!==h||t[80]!==a?(we=h?(0,$.jsxs)(`div`,{className:`space-y-1 border-t border-edge-subtle pt-2`,children:[(0,$.jsx)(U,{className:`min-h-11 w-full justify-start`,onClick:()=>y(h.onHistory),children:a?`版本历史`:`Version history`}),(0,$.jsx)(U,{className:`min-h-11 w-full justify-start text-danger`,disabled:h.busy,onClick:()=>y(h.onDelete),children:a?`删除笔记`:`Delete note`})]}):null,t[79]=h,t[80]=a,t[81]=we):we=t[81];let Te;t[82]!==le||t[83]!==Ce||t[84]!==we||t[85]!==E||t[86]!==D||t[87]!==O?(Te=(0,$.jsx)(ye,{children:(0,$.jsxs)(st,{align:`end`,sideOffset:6,collisionPadding:12,"aria-label":E,className:`z-[140] max-h-[min(38rem,var(--radix-popover-content-available-height,85dvh))] w-[min(20rem,calc(100vw-2rem))] overflow-y-auto rounded-2xl border border-edge bg-surface-overlay p-3 text-fg shadow-elevated`,children:[D,O,le,Ce,we]})}),t[82]=le,t[83]=Ce,t[84]=we,t[85]=E,t[86]=D,t[87]=O,t[88]=Te):Te=t[88];let q;return t[89]!==g||t[90]!==T||t[91]!==Te?(q=(0,$.jsxs)(ne,{open:g,onOpenChange:_,children:[T,Te]}),t[89]=g,t[90]=T,t[91]=Te,t[92]=q):q=t[92],q}var kt=e=>`${Math.floor(e/6e4)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`;function At({id:e,query:t,zh:n,refreshKey:r,sourceKey:i,active:a,tab:o,onEvidence:s,onPlay:c}){let[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(!0),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),_=(0,Q.useRef)(0),[v,b]=(0,Q.useState)(),[x,S]=(0,Q.useState)(),[C,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!a||t)return;let e=window.setInterval(()=>D(e=>e+1),3e3);return()=>window.clearInterval(e)},[a,t]),(0,Q.useEffect)(()=>{S(void 0)},[e,t]),(0,Q.useEffect)(()=>{let n=++_.current,r=new AbortController;f(!0),g(!1),m(``);let a=window.setTimeout(()=>{y(w(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}`),{signal:r.signal}).then(e=>{_.current===n&&(u(e),b(i),T(t))}).catch(e=>{_.current===n&&!r.signal.aborted&&m(String(e))}).finally(()=>{_.current===n&&f(!1)})},t?200:0);return()=>{_.current++,r.abort(),window.clearTimeout(a)}},[e,t,r,i,E]);async function O(){if(!l||h)return;let r=_.current;g(!0);try{let n=await y(w(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}&offset=${l.hits.length}&version=${l.version}`));r===_.current&&u({...n,hits:[...l.hits,...n.hits]})}catch(e){r===_.current&&m(n?`内容已变化,请重新搜索。${String(e)}`:`Content changed; search again. ${String(e)}`)}finally{g(!1)}}function k(e){S(e),(!e.provisional||e.kind===`chapter`)&&e.transcriptRevision!==void 0&&e.segments.length&&s({transcriptRevision:e.transcriptRevision,stale:e.stale,audioAvailable:l?.coverage.audioAvailable??!1,timingVerified:e.segments.some(e=>e.playback.length>0),segments:e.segments})}let A=e=>e.kind===`chapter`?n?`章节`:`Chapter`:e.kind===`annotation`?n?`我的标记`:`My mark`:e.kind===`analysis`?n?`分析`:`Analysis`:n?`原文`:`Transcript`,j=e=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded-xl bg-surface-inset p-4`,children:[(0,$.jsxs)(`button`,{className:`text-left text-sm text-accent-fg`,onClick:()=>k(e),children:[e.startedAtMs===void 0?``:`${kt(e.startedAtMs)}${e.endedAtMs===void 0?``:`–${kt(e.endedAtMs)}`} · `,e.title||A(e)]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm`,children:e.kind===`chapter`&&!t&&e.text.length>300?`${e.text.slice(0,300)}…`:e.text}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[A(e),e.provisional?n?` · 阶段性结果`:` · Partial result`:``,e.stale?n?` · 原文已更新,保留旧版依据`:` · Earlier transcript revision`:``,e.kind===`chapter`?` · ${e.highlightCount??0} ${n?`个重点`:`marks`} · ${e.actionCount??0} ${n?`个候选行动`:`candidate actions`}`:``]}),e.kind!==`chapter`||t||x?.id===e.id?e.segments.map(e=>(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[kt(e.startedAtMs),` · `,e.text.length>500?`${e.text.slice(0,500)}…`:e.text]},`${e.sequence}:${e.startedAtMs}`)):null,e.playback.slice(0,3).map((e,t)=>(0,$.jsxs)(U,{onClick:()=>c(e.startedAtMs,e.endedAtMs),children:[n?`回听上下文`:`Play context`,` `,kt(e.startedAtMs),`–`,kt(e.endedAtMs)]},t)),e.segments.length?(0,$.jsx)(U,{onClick:()=>k(e),children:n?`查看对应原文`:`View transcript`}):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`暂无可核实的原文定位`:`No verified transcript reference`})]},e.id);return(0,$.jsxs)(`section`,{"aria-label":n?`长录音回顾`:`Recording review`,className:`flex flex-col gap-3`,children:[p?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p}),(0,$.jsx)(U,{onClick:()=>D(e=>e+1),children:n?`刷新结果`:`Refresh results`})]}):null,d&&(!l||v!==i||C!==t)?(0,$.jsx)(ge,{className:`h-20 w-full`}):null,l&&v===i&&(!t||C===t)?(0,$.jsxs)($.Fragment,{children:[t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`搜索结果 · ${l.total}`:`Search results · ${l.total}`}),(0,$.jsx)(U,{onClick:()=>D(e=>e+1),children:n?`刷新结果`:`Refresh results`}),(0,$.jsx)(`div`,{"aria-label":n?`命中位置`:`Match positions`,className:`relative my-3 h-5 rounded bg-surface-inset`,children:l.hits.filter(e=>e.startedAtMs!==void 0).map(e=>(0,$.jsx)(`button`,{className:`absolute top-0 h-5 w-1.5 rounded bg-accent`,style:{left:`${Math.min(99,100*e.startedAtMs/Math.max(1,l.coverage.durationMs))}%`},"aria-label":`${kt(e.startedAtMs)} ${e.title||A(e)}`,onClick:()=>k(e)},e.id))}),l.total?null:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`未找到关键词;尚未转写的内容无法搜索。`:`No matches. Untranscribed audio is not searchable yet.`}),l.hits.map(j)]}):(0,$.jsxs)($.Fragment,{children:[o===`summary`&&l.chapters.length?(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-inset px-4`,children:[(0,$.jsxs)(`summary`,{className:`min-h-11 cursor-pointer py-3 text-sm font-medium focus-visible:ring-2 focus-visible:ring-accent`,children:[n?`章节目录`:`Chapters`,` · `,l.chapters.length]}),(0,$.jsx)(`div`,{className:`space-y-3 pb-4`,children:l.chapters.map(j)})]}):null,l.hits.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`本轮已完成转写(阶段性)`:`Available transcription from this run`}),l.hits.map(j)]}):null]}),l.hasMore?(0,$.jsx)(U,{disabled:h,onClick:()=>void O(),children:n?`加载更多结果`:`More results`}):null,(0,$.jsxs)(`details`,{className:`rounded-lg text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`min-h-11 cursor-pointer py-3 focus-visible:ring-2 focus-visible:ring-accent`,children:n?`处理范围`:`Processing coverage`}),(0,$.jsxs)(`div`,{role:`status`,className:`space-y-2 pb-3 leading-5`,children:[(0,$.jsxs)(`p`,{children:[n?`原音`:`Audio`,` · `,l.coverage.audioAvailable?n?`已保存,可回听`:`Saved, ready to play`:n?`尚不可用`:`Unavailable`]}),(0,$.jsxs)(`p`,{children:[n?`本轮转写已处理`:`Processed this run`,` `,kt(l.coverage.processedMs),` / `,kt(l.coverage.durationMs),` · `,n?`连续处理至`:`Continuous through`,` `,kt(l.coverage.continuousThroughMs)]}),(0,$.jsxs)(`p`,{children:[n?`分析覆盖`:`Analysis coverage`,` · `,l.coverage.analysisRanges.length?l.coverage.analysisRanges.map(e=>`${kt(e.startedAtMs)}–${kt(e.endedAtMs)}`).join(`、`):n?`暂无本版已完成章节`:`No completed chapters for this revision`,l.coverage.analysisStale?n?`;已发布分析基于旧版原文`:`; published analysis uses an earlier transcript`:``,` · `,l.coverage.complete?n?`本轮处理完成`:`Run complete`:n?`阶段性内容,其余仍待处理`:`Partial content; remaining work pending`]})]})]}),x?.provisional?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`以上是本轮已保存的阶段性原文;正式发布后才能校对和标记具体段落。`:`Saved partial text; segment editing and highlighting become available after publication.`}):null]}):null]})}function jt({recordingId:e,discussionId:t,zh:n,onEvidence:r,onPlay:i}){let{data:a=[],mutate:o}=P(`/api/discussions/${t}/annotations`,e=>y(w(e))),[s,c]=(0,Q.useState)([]),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(``),h=(0,Q.useCallback)(async()=>{c(await J(e))},[e]),g=(0,Q.useCallback)(async()=>{try{await Z(e,t),await h(),await o()}catch(e){await o(),m(e instanceof Error?e.message:String(e))}},[e,t,h,o]);(0,Q.useEffect)(()=>{h().catch(e=>m(String(e))),g();let e=()=>{h().catch(e=>m(String(e)))};window.addEventListener(`discussion-annotations-changed`,e),window.addEventListener(`online`,g);let t=window.setInterval(()=>{navigator.onLine&&g()},15e3);return()=>{window.removeEventListener(`discussion-annotations-changed`,e),window.removeEventListener(`online`,g),window.clearInterval(t)}},[h,g]);let _=new Map(a.map(e=>[e.annotation.id,{...e,localState:`synced`}]));for(let e of s)if(e.state!==`synced`||!_.has(e.annotation.id)){let t=_.get(e.annotation.id);_.set(e.annotation.id,{annotation:e.annotation,state:t?.state??`pending`,playback:t?.playback??[],evidence:t?.evidence,localState:e.state})}let v=async(t,n=s.find(e=>e.annotation.id===t.id)?.nonce??null)=>{try{await tt(e,{...t,updatedAt:Date.now()},n),f(null),m(``),await h(),g()}catch(e){m(e instanceof Error?e.message:String(e))}};return(0,$.jsxs)(`section`,{className:`space-y-4`,"aria-label":n?`我的标记`:`My highlights`,children:[p?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[p,(0,$.jsx)(U,{onClick:()=>void g(),children:n?`重试同步`:`Retry sync`})]}):null,_.size?null:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`录音时标重点,或在原文中标记整段。标记先保存在本机。`:`Highlight while recording or mark a transcript segment. Highlights save locally first.`}),[..._.values()].sort((e,t)=>e.annotation.anchor.capturedAt-t.annotation.anchor.capturedAt).filter(e=>!e.annotation.deleted||e.localState===`conflict`).map(e=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.annotation.kind===`highlight`?n?`重点`:`Highlight`:e.annotation.kind===`question`?n?`问题`:`Question`:n?`我的补充`:`My note`,` · `,new Date(e.annotation.anchor.capturedAt).toLocaleString(),` · `,e.localState===`synced`?n?`已同步`:`Synced`:e.localState===`conflict`?n?`同步冲突,保留了本机修改`:`Conflict; local edits retained`:n?`本机已保存,待同步`:`Saved locally; sync pending`]}),e.evidence?.segments.map(e=>(0,$.jsx)(`blockquote`,{className:`text-sm`,children:e.text},e.sequence)),e.positionMs===void 0?null:(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[n?`标记位置`:`Marked position`,` · `,Math.floor(e.positionMs/6e4),`:`,String(Math.floor(e.positionMs/1e3)%60).padStart(2,`0`)]}),e.annotation.text?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap text-sm`,children:[n?`我的说明:`:`My context: `,e.annotation.text]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(U,{disabled:!e.evidence,onClick:()=>e.evidence&&r(e.evidence),children:n?`查看原文`:`View transcript`}),e.playback.map((e,t)=>(0,$.jsxs)(U,{onClick:()=>i(e),children:[n?`回听`:`Play`,` `,Math.floor(e.startedAtMs/6e4),`:`,String(Math.floor(e.startedAtMs/1e3)%60).padStart(2,`0`)]},t)),(0,$.jsx)(U,{onClick:()=>{u(s.find(t=>t.annotation.id===e.annotation.id)?.nonce??null),f({...e.annotation,revision:a.find(t=>t.annotation.id===e.annotation.id)?.annotation.revision??e.annotation.revision})},children:e.localState===`conflict`?n?`合并修改`:`Merge changes`:n?`添加说明/类型`:`Edit context/type`}),(0,$.jsx)(U,{onClick:()=>void v({...e.annotation,deleted:!0}),children:n?`移除标记`:`Remove`})]}),e.state===`located`&&!e.evidence?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`该位置原文尚未生成,可先回听原音。`:`Transcript for this position is pending; audio is usable.`}):null,e.state===`unavailable`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`该位置原音未保存、已删除或时间尚无法核实;保留原始标记,不自动移动。`:`Audio at this position is missing, deleted or unverified. The original anchor has been retained.`}):e.state===`pending`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`等待原音/原文完成定位`:`Awaiting audio/transcript positioning`}):null,e.localState===`conflict`?(0,$.jsx)(U,{onClick:()=>{let t=s.find(t=>t.annotation.id===e.annotation.id),n=a.find(t=>t.annotation.id===e.annotation.id);t&&n&&Qe(t,n.annotation).then(h)},children:n?`使用服务端版本`:`Use server version`}):null]},e.annotation.id)),d?(0,$.jsxs)(`div`,{role:`dialog`,"aria-label":n?`编辑标记`:`Edit highlight`,className:`rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(Ae,{value:d.kind,"aria-label":n?`标记类型`:`Highlight type`,onChange:e=>f({...d,kind:e.target.value}),children:[(0,$.jsx)(X,{value:`highlight`,children:n?`重点`:`Highlight`}),(0,$.jsx)(X,{value:`question`,children:n?`问题`:`Question`}),(0,$.jsx)(X,{value:`note`,children:n?`补充`:`Context`})]}),(0,$.jsx)(`textarea`,{"aria-label":n?`我的说明`:`My context`,maxLength:4e3,value:d.text,onChange:e=>f({...d,text:e.target.value}),className:`my-2 min-h-24 w-full rounded border border-edge bg-surface-inset p-2`}),(0,$.jsx)(U,{onClick:()=>void v(d,l),children:n?`保存到本机并同步`:`Save locally and sync`}),(0,$.jsx)(U,{onClick:()=>f(null),children:n?`取消`:`Cancel`})]}):null]})}var Mt={tab:`summary`,query:``,page:1,positionMs:0},Nt=C((e,t)=>({notes:{},update:(n,r)=>{let i={...Ft(n,t().notes[n]),...r};e(e=>({notes:{...e.notes,[n]:i}}));try{localStorage.setItem(`discussion-review:${n}`,JSON.stringify(i))}catch{}}})),Pt=new Map;function Ft(e,t){if(t)return t;if(Pt.has(e))return Pt.get(e);let n=Mt;try{let t=JSON.parse(localStorage.getItem(`discussion-review:${e}`)??`null`);t&&[`summary`,`transcript`,`marks`].includes(t.tab)&&typeof t.query==`string`&&Number.isSafeInteger(t.page)&&t.page>0&&t.page<=1e4&&Number.isFinite(t.positionMs)&&t.positionMs>=0&&(n={...Mt,...t})}catch{}return Pt.set(e,n),n}function It(e){let t=(0,gt.c)(51),{initial:n,zh:r,busy:i,onClose:a,onSave:o}=e,[s,c]=(0,Q.useState)(n),l;t[0]!==i||t[1]!==a?(l=e=>{!e&&!i&&a()},t[0]=i,t[1]=a,t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[3]=u):u=t[3];let d=r?`编辑纪要内容`:`Edit meeting content`,f;t[4]===d?f=t[5]:(f=(0,$.jsx)(`header`,{className:`border-b border-edge p-4`,children:(0,$.jsx)(A,{children:d})}),t[4]=d,t[5]=f);let p=r?`人工修改会保留,重新整理不会覆盖。已创建任务保持不变。`:`Your changes survive regeneration. Existing tasks remain unchanged.`,m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[6]=p,t[7]=m);let h=r?`内容`:`Content`,g;t[8]===s?g=t[9]:(g=e=>c({...s,text:e.target.value}),t[8]=s,t[9]=g);let _;t[10]!==s.text||t[11]!==g?(_=(0,$.jsx)(`textarea`,{className:`mt-1 min-h-32 w-full rounded border border-edge bg-transparent p-2`,value:s.text,onChange:g}),t[10]=s.text,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==h||t[14]!==_?(v=(0,$.jsxs)(`label`,{className:`block text-sm`,children:[h,_]}),t[13]=h,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==s||t[17]!==r?(y=s.kind===`actionItems`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm`,children:[r?`负责人原话`:`Owner as stated`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-transparent p-2`,value:s.owner??``,onChange:e=>c({...s,owner:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[r?`期限原话`:`Date as stated`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-transparent p-2`,value:s.dueDate??``,onChange:e=>c({...s,dueDate:e.target.value})})]})]}):null,t[16]=s,t[17]=r,t[18]=y):y=t[18];let b;t[19]!==s||t[20]!==r?(b=s.kind===`summary`?null:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!s.ignored,onChange:e=>c({...s,ignored:e.target.checked})}),r?`忽略此项`:`Ignore this item`]}),t[19]=s,t[20]=r,t[21]=b):b=t[21];let x;t[22]!==v||t[23]!==y||t[24]!==b||t[25]!==m?(x=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[m,v,y,b]}),t[22]=v,t[23]=y,t[24]=b,t[25]=m,t[26]=x):x=t[26];let S=r?`取消`:`Cancel`,C;t[27]!==i||t[28]!==a||t[29]!==S?(C=(0,$.jsx)(U,{disabled:i,onClick:a,children:S}),t[27]=i,t[28]=a,t[29]=S,t[30]=C):C=t[30];let w;t[31]!==i||t[32]!==s.text?(w=i||!s.text.trim(),t[31]=i,t[32]=s.text,t[33]=w):w=t[33];let E;t[34]!==s||t[35]!==o?(E=()=>void o(s),t[34]=s,t[35]=o,t[36]=E):E=t[36];let D=r?`保存修改`:`Save changes`,M;t[37]!==w||t[38]!==E||t[39]!==D?(M=(0,$.jsx)(U,{variant:`primary`,disabled:w,onClick:E,children:D}),t[37]=w,t[38]=E,t[39]=D,t[40]=M):M=t[40];let N;t[41]!==C||t[42]!==M?(N=(0,$.jsxs)(`footer`,{className:`flex justify-end gap-2 border-t border-edge p-3`,children:[C,M]}),t[41]=C,t[42]=M,t[43]=N):N=t[43];let P;t[44]!==x||t[45]!==N||t[46]!==f?(P=(0,$.jsxs)(O,{children:[u,(0,$.jsxs)(k,{"aria-describedby":void 0,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(32rem,90dvh)] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[f,x,N]})]}),t[44]=x,t[45]=N,t[46]=f,t[47]=P):P=t[47];let F;return t[48]!==l||t[49]!==P?(F=(0,$.jsx)(j,{open:!0,onOpenChange:l,children:P}),t[48]=l,t[49]=P,t[50]=F):F=t[50],F}function Lt(e,t,n){if(t===`summary`){let r=e.organization;if(!r)return``;let i=r.organization;if(!i)return``;let a=e=>e.filter(e=>n.showIgnored||!e.ignored);return JSON.stringify({discussionId:e.discussion.id,view:t,revision:r.revision,transcriptRevision:r.transcriptRevision,summary:i.summary,decisions:a(i.decisions),actionItems:a(i.actionItems),risks:a(i.risks),openQuestions:a(i.openQuestions),chapters:i.chapters},null,2)}let r=n.query.toLocaleLowerCase(),i=e.transcript.segments.filter(e=>(e.displayText??e.rawText??``).toLocaleLowerCase().includes(r)||e.speakerLabel?.toLocaleLowerCase().includes(r)).slice(0,n.page*50);return i.length?JSON.stringify({discussionId:e.discussion.id,view:t,revision:e.transcript.revision,scope:`loaded filtered segments only`,segments:i.map(e=>({sequence:e.sequence,startedAtMs:e.startedAtMs,speaker:e.speakerLabel,text:e.displayText??e.rawText??``}))},null,2):``}var Rt=e=>`${String(Math.floor(e/6e4)).padStart(2,`0`)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`;function zt({noteId:e,onPersonalNotes:t,noteActions:n}){let r=a(),i=S(e=>e.language)===`zh`,{data:o,mutate:l,isLoading:u}=P([`note-discussion-document`,e],()=>Pe(e),{refreshInterval:e=>e&&([`recording`,`stopping`,`sealing`,`organizing`].includes(e.discussion.status)||e.recordingJob?.state===`queued`||e.recordingJob?.state===`running`)?3e3:0}),d=o?.discussion.id,f=`/api/discussions/${encodeURIComponent(d??``)}`,{data:p=[],mutate:m}=P(d?`${f}/actions`:null,e=>y(w(e)),{refreshInterval:1e4}),_=Nt(t=>Ft(e,t.notes[e])),v=Nt(e=>e.update),b=_.tab,x=t=>v(e,{tab:t}),C=_.query,E=t=>v(e,{query:t}),[D,M]=(0,Q.useState)(!1),N=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{D&&N.current?.focus()},[D]);let[F,I]=(0,Q.useState)(`general`),[R,z]=(0,Q.useState)(null),[B,ee]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(null),[re,ie]=(0,Q.useState)(!1),[ae,V]=(0,Q.useState)([]),[oe,se]=(0,Q.useState)(null),[H,le]=(0,Q.useState)(!1),ue=_.page,de=t=>v(e,{page:t}),fe=(0,Q.useRef)(null),[pe,me]=(0,Q.useState)([]),he=(0,Q.useRef)(0),W=(0,Q.useRef)(0),_e=(0,Q.useRef)(o?.transcript.revision);_e.current=o?.transcript.revision;let G=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),[,ye]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{l(),m()};return window.addEventListener(`discussion-updated`,e),window.addEventListener(`discussion-segment-updated`,e),()=>{window.removeEventListener(`discussion-updated`,e),window.removeEventListener(`discussion-segment-updated`,e)}},[l,m]),(0,Q.useEffect)(()=>{o?.discussion.template&&I(o.discussion.template)},[o?.discussion.template]);async function be(e){if(!H){le(!0),se(null);try{await e(),await l(),await m()}catch(e){se(e instanceof Error?e.message:String(e))}finally{le(!1)}}}function xe(e,t){G.current&&(fe.current=t??null,G.current.readyState===0?(ve.current=e/1e3,G.current.load()):(G.current.currentTime=e/1e3,G.current.play().catch(()=>void 0)))}function Se(e){let t=e.stale||e.transcriptRevision!==_e.current;z({...e,stale:t}),t||me(e.segments.map(e=>e.sequence))}async function K(e,t,n=!1){if(!o)return;let r=he.current,i=++W.current;await be(async()=>{let a=await y(w(`${f}/evidence?revision=${t??o.organization?.transcriptRevision??o.transcript.revision}&segments=${e.join(`,`)}`));if(!(r!==he.current||i!==W.current)&&(Se(a),n&&a.segments[0]?.playback[0])){let e=a.segments[0].playback[0];xe(e.startedAtMs,e.endedAtMs)}})}async function Ce(e){o&&await be(async()=>{await tt(o.discussion.clientRequestId,Ue({type:`transcript`,capturedAt:Date.now(),transcriptRevision:o.transcript.revision,segmentIds:[e.sequence]})),x(`marks`),Z(o.discussion.clientRequestId,o.discussion.id).catch(e=>se(String(e)))})}(0,Q.useEffect)(()=>(he.current++,z(null),me([]),ee(null),ne(null),V([]),se(null),fe.current=null,()=>{he.current++}),[e]),(0,Q.useEffect)(()=>{let t=o?.discussion.audioSha256??o?.discussion.audioAttachmentId;if(!t)return;let n=Ft(e,Nt.getState().notes[e]);n.source&&n.source!==t?(he.current++,z(null),me([]),G.current?.pause(),v(e,{positionMs:0,source:t}),ve.current=0,fe.current=null):v(e,{source:t})},[e,o?.discussion.audioSha256,o?.discussion.audioAttachmentId,v]),(0,Q.useEffect)(()=>{o?.discussion.audioDeletedAt&&(G.current?.pause(),ve.current=null,fe.current=null,z(e=>e?{...e,audioAvailable:!1,timingVerified:!1,segments:e.segments.map(e=>({...e,playback:[]}))}:null))},[o?.discussion.audioDeletedAt]),(0,Q.useEffect)(()=>{_.tab===`transcript`&&_.anchor!==void 0&&_.anchorRevision===o?.transcript.revision&&window.setTimeout(()=>document.getElementById(`discussion-segment-${_.anchor}`)?.scrollIntoView?.({block:`center`}),0)},[_.tab,_.anchor,_.anchorRevision,o?.transcript.revision]),(0,Q.useEffect)(()=>{me([]),z(e=>e&&e.transcriptRevision!==o?.transcript.revision?{...e,stale:!0}:e)},[o?.transcript.revision]);let Te=(e,t,n)=>t.some(e=>re||!e.ignored)?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`font-semibold text-fg`,children:e}),t.filter(e=>re||!e.ignored).map(e=>(0,$.jsxs)(`div`,{className:`flex items-start gap-3 text-sm`,children:[(0,$.jsxs)(`p`,{className:`flex-1 whitespace-pre-wrap`,children:[e.text,e.supersededBy||e.disputedBy?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:i?`有后续变更`:`Later changes`}):null,e.editedByUser?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:i?e.ignored?`已忽略`:`人工编辑`:e.ignored?`Ignored`:`Edited`}):null]}),(0,$.jsx)(`button`,{className:`text-xs text-fg-muted`,disabled:H,onClick:()=>ne({kind:n,itemId:e.id,text:e.text,ignored:e.ignored}),children:i?`编辑`:`Edit`}),e.evidenceSegmentIds.length?(0,$.jsx)(`button`,{disabled:H,className:`shrink-0 text-accent-fg`,onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:i?`原话`:`Source`}):(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i?`暂无定位`:`No source timing`})]},e.id))]}):null;if(u)return(0,$.jsx)(ge,{className:`h-48 w-full`});if(!o)return null;let{discussion:q,transcript:Ee,organization:Oe}=o,J=Oe?.organization,ke=[`stopping`,`sealing`,`organizing`].includes(q.status),Ae=[`recording`,`completed`,`needs_attention`].includes(q.status),Y=Ee.segments.filter(e=>(e.displayText??e.rawText??``).toLocaleLowerCase().includes(C.toLocaleLowerCase())||e.speakerLabel?.toLocaleLowerCase().includes(C.toLocaleLowerCase())),je=b===`marks`||C.trim()?``:Lt(o,b,{query:C,page:ue,showIgnored:re});return(0,$.jsxs)(`section`,{className:`relative flex h-full min-h-0 w-full flex-col text-fg`,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`f`&&(e.preventDefault(),M(!0))},children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 px-5 pb-3 pt-5 sm:px-7`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-xl font-semibold leading-snug tracking-tight`,children:!o.note.title||/^Discussion · \d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(o.note.title)?i?`语音笔记`:`Voice note`:o.note.title}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[i?`录音`:`Recording`,` · `,Rt(q.durationMs??0)]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":i?`搜索此 Note`:`Search this Note`,"aria-expanded":D||!!C,onClick:()=>{M(e=>!e),D&&E(``)},className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(De,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(Ot,{noteActions:n,detail:o,template:F,onTemplate:I,zh:i,busy:H,processing:ke,pageText:je,editing:!!te||!!B,onPersonalNotes:t,onOrganize:()=>void be(()=>y(w(`${f}/organize`),{method:`POST`,body:JSON.stringify({template:F})})),onRegenerate:()=>void be(()=>we(q.id,`from_audio`))})]}),(0,$.jsx)(L,{as:`nav`,"aria-label":i?`笔记内容`:`Note content`,className:`mx-5 mb-2 flex shrink-0 gap-1 rounded-xl bg-surface-inset p-1 sm:mx-7`,indicatorClassName:`rounded-lg bg-surface-panel shadow-sm`,children:[`summary`,`transcript`,`marks`].map(e=>(0,$.jsx)(`button`,{"aria-pressed":b===e,className:`min-h-11 min-w-0 flex-1 rounded-lg px-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${b===e?`bg-surface-panel font-medium text-fg shadow-sm`:`text-fg-muted hover:text-fg`}`,onClick:()=>x(e),children:e===`summary`?i?`概览`:`Overview`:e===`marks`?i?`标记`:`Highlights`:i?`原文`:`Transcript`},e))}),oe?(0,$.jsxs)(`details`,{role:`alert`,className:`px-4 py-2 text-sm text-danger`,children:[(0,$.jsx)(`summary`,{children:i?`操作未完成,可以稍后重试`:`Action incomplete. Try again later`}),(0,$.jsx)(`p`,{className:`mt-2 break-words text-xs text-fg-muted`,children:oe})]}):null,D||C?(0,$.jsxs)(`label`,{className:`mx-5 mb-2 flex shrink-0 items-center gap-2 rounded-xl bg-surface-inset px-3 sm:mx-7`,children:[(0,$.jsx)(De,{className:`size-4 text-fg-muted`}),(0,$.jsx)(`input`,{ref:N,"aria-label":i?`搜索此 Note`:`Search this Note`,className:`min-h-11 min-w-0 w-full bg-transparent text-sm outline-none`,maxLength:200,placeholder:i?`搜索这篇笔记`:`Search this note`,value:C,onChange:e=>{E(e.target.value),de(1)}}),(0,$.jsx)(`button`,{className:`inline-flex size-11 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":i?`关闭搜索`:`Close search`,onClick:()=>{E(``),M(!1)},children:(0,$.jsx)(g,{className:`size-4`})})]}):null,(0,$.jsxs)(`main`,{className:`flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-5 pb-6 pt-1 sm:px-7`,children:[q.status!==`recording`||o.recordingJob?(0,$.jsx)(it,{context:`note`,input:ft(o),zh:i,busy:H,onRetry:e=>void be(()=>e===`analyze`?y(w(`${f}/organize`),{method:`POST`,body:JSON.stringify({template:F})}):we(q.id,e===`regenerate`?`from_audio`:`resume`))}):null,(0,$.jsx)(`div`,{hidden:!!C.trim(),children:b===`marks`?(0,$.jsx)(jt,{recordingId:q.clientRequestId,discussionId:q.id,zh:i,onEvidence:Se,onPlay:e=>xe(e.startedAtMs,e.endedAtMs)},q.id):b===`summary`?J?(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:i?`摘要`:`Summary`}),(0,$.jsx)(`button`,{className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":i?`编辑概要`:`Edit overview`,title:i?`编辑概要`:`Edit overview`,disabled:H||ke,onClick:()=>ne({kind:`summary`,itemId:`summary`,text:J.summary}),children:(0,$.jsx)(ce,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[15px] leading-7`,children:J.summary}),J.summaryEditedByUser?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`已由你编辑`:`Edited by you`}):null,J.summaryEvidenceSegmentIds?.length?Array.from({length:Math.ceil(J.summaryEvidenceSegmentIds.length/100)},(e,t)=>(0,$.jsxs)(U,{onClick:()=>void K(J.summaryEvidenceSegmentIds.slice(t*100,(t+1)*100)),children:[i?`查看原话`:`View source`,J.summaryEvidenceSegmentIds.length>100?` · ${t+1}`:``]},t)):null,J.keyPointEvidence?.length?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{children:i?`重点结论`:`Key points`}),J.keyPointEvidence.map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2 text-sm`,children:[(0,$.jsx)(`p`,{className:`flex-1`,children:e.text}),(0,$.jsx)(U,{onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:i?`原话`:`Source`})]},e.id))]}):J.keyPoints.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:i?`重点结论`:`Key points`}),(0,$.jsx)(`ul`,{className:`list-disc space-y-2 pl-5 text-[15px] leading-7`,children:J.keyPoints.map((e,t)=>(0,$.jsx)(`li`,{children:e},`${t}:${e}`))})]}):null,[...J.decisions,...J.actionItems,...J.risks,...J.openQuestions].some(e=>e.ignored)?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:re,onChange:e=>ie(e.target.checked)}),i?`显示已忽略项`:`Show ignored items`]}):null,ae.length?(0,$.jsx)(U,{disabled:H,onClick:()=>void be(async()=>{for(let e of ae)await y(w(`${f}/actions/${encodeURIComponent(e)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:Oe.revision})});V([])}),children:i?`加入所选 ${ae.length} 项任务`:`Add ${ae.length} selected tasks`}):null,Te(i?`已决定事项`:`Decisions`,J.decisions,`decisions`),J.actionItems.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:i?`下一步行动`:`Next actions`}),J.actionItems.filter(e=>re||!e.ignored).map(e=>{let t=p.find(t=>t.actionId===e.id);return(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge-subtle p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[!t&&!e.ignored&&(!(e.supersededBy||e.disputedBy)||e.reviewedChangeId===(e.supersededBy??e.disputedBy))?(0,$.jsx)(`input`,{type:`checkbox`,"aria-label":`${i?`选择行动`:`Select action`}: ${e.title}`,className:`ui-checkbox`,checked:ae.includes(e.id),onChange:t=>V(t.target.checked?[...ae,e.id]:ae.filter(t=>t!==e.id))}):null,(0,$.jsxs)(`p`,{className:`flex-1 text-sm font-medium`,children:[e.title,e.supersededBy||e.disputedBy?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:i?`有后续变更,请复核`:`Review later changes`}):null,e.editedByUser?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:i?e.ignored?`已忽略`:`人工编辑`:e.ignored?`Ignored`:`Edited`}):null]}),(0,$.jsx)(`button`,{className:`text-xs text-fg-muted`,disabled:H||ke,onClick:()=>ne({kind:`actionItems`,itemId:e.id,text:e.title,owner:e.owner,dueDate:e.dueDate,ignored:e.ignored}),children:i?`编辑`:`Edit`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[e.owner??(i?`负责人未明确`:`Owner unspecified`),` · `,e.dueDate??(i?`期限未明确`:`Date unspecified`)]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-xs`,children:[e.evidenceSegmentIds.length?(0,$.jsx)(`button`,{disabled:H,className:`text-accent-fg`,onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:i?`查看原话`:`Source`}):null,t?t.deleted?(0,$.jsx)(`span`,{children:i?`关联任务已删除`:`Linked task deleted`}):(0,$.jsx)(s,{className:`text-accent-fg`,to:h(`${r.pathname}${r.search}`,t.taskId),children:t.resolution===`done`?i?`已完成 · 查看任务`:`Done · View task`:i?`查看任务 / 交给助手`:`View task / Delegate`}):e.ignored?null:(0,$.jsx)(U,{disabled:H||!!(e.supersededBy||e.disputedBy)&&e.reviewedChangeId!==(e.supersededBy??e.disputedBy),onClick:()=>void be(()=>y(w(`${f}/actions/${encodeURIComponent(e.id)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:Oe.revision})})),children:i?`加入我的任务`:`Add to my tasks`})]})]},e.id)})]}):null,Te(i?`风险`:`Risks`,J.risks,`risks`),Te(i?`尚未确定`:`Open questions`,J.openQuestions,`openQuestions`),J.changes?.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:i?`前后变更`:`Changes during the meeting`}),J.changes.map(e=>{let t=[...J.decisions,...J.actionItems,...J.risks,...J.openQuestions],n=t.find(t=>t.id===e.fromId),r=t.find(t=>t.id===e.toId);return!n||!r?null:(0,$.jsxs)(`article`,{className:`space-y-2 rounded border border-edge p-3 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.relation===`supersedes`?i?`后续撤销或替代`:`Later superseded`:i?`存在冲突,尚未明确解决`:`Unresolved conflict`}),(0,$.jsx)(`button`,{className:`block text-left text-accent-fg`,onClick:()=>void K(n.evidenceSegmentIds,n.evidenceRevision),children:`title`in n?n.title:n.text}),(0,$.jsx)(`span`,{children:`↓`}),(0,$.jsx)(`button`,{className:`block text-left text-accent-fg`,onClick:()=>void K(r.evidenceSegmentIds,r.evidenceRevision),children:`title`in r?r.title:r.text})]},`${e.fromId}:${e.toId}`)})]}):null]}):(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4 py-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:Ee.text?i?`录音摘录`:`From your recording`:i?`笔记正在整理`:`Preparing your note`}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[15px] leading-7 ${Ee.text?`text-fg`:`text-fg-muted`}`,children:Ee.text?Ee.text.slice(0,400)+(Ee.text.length>400?`…`:``):i?`文字整理完成后,重点和行动会出现在这里。`:`Highlights and actions will appear as processing completes.`}),Ee.text?(0,$.jsx)(U,{className:`min-h-11`,onClick:()=>x(`transcript`),children:i?`查看原文`:`Read transcript`}):null]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[Y.slice(0,ue*50).map(e=>(0,$.jsxs)(`article`,{id:`discussion-segment-${e.sequence}`,className:`rounded-md border p-3 ${pe.includes(e.sequence)||_.anchor===e.sequence&&_.anchorRevision===Ee.revision?`border-accent`:`border-edge-subtle`}`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-3 text-xs text-fg-muted`,children:[(0,$.jsxs)(`button`,{className:`inline-flex items-center gap-1 text-accent-fg`,disabled:!q.audioAttachmentId||!!q.audioDeletedAt,onClick:()=>void K([e.sequence],Ee.revision,!0),children:[(0,$.jsx)(mt,{className:`size-3`}),Rt(e.startedAtMs)]}),e.status===`confirmed`?(0,$.jsx)(`button`,{onClick:()=>void Ce(e),children:i?`标记此段`:`Highlight segment`}):null,(0,$.jsx)(`span`,{children:e.speakerLabel??(i?`未区分说话人`:`Speaker unknown`)}),Ae&&e.status===`confirmed`?(0,$.jsx)(`button`,{className:`ml-auto`,onClick:()=>ee({segment:e,text:e.displayText??e.rawText??``,speaker:e.speakerLabel??``}),children:i?`校对`:`Edit`}):null]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6`,children:e.displayText??e.rawText??(i?`等待转写`:`Awaiting transcription`)})]},e.sequence)),Y.length>ue*50?(0,$.jsx)(U,{onClick:()=>de(ue+1),children:i?`加载更多`:`More`}):null]})}),(0,$.jsx)(`div`,{children:(0,$.jsx)(At,{id:q.id,query:C.trim(),zh:i,sourceKey:`${q.audioSha256}:${q.audioDeletedAt}`,active:ke||q.status===`recording`,tab:b,refreshKey:`${q.updatedAt}:${Ee.revision}:${Oe?.revision}`,onEvidence:Se,onPlay:xe},q.id)})]}),q.audioAttachmentId&&!q.audioDeletedAt?(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,$.jsx)(`audio`,{ref:G,controls:!0,preload:`metadata`,className:`h-10 w-full`,src:w(`${f}/audio`),onTimeUpdate:()=>{let t=(G.current?.currentTime??0)*1e3;ye(t),v(e,{positionMs:t}),fe.current!==null&&t>=fe.current&&(G.current?.pause(),fe.current=null)},onLoadedMetadata:()=>{ve.current!==null&&G.current?(G.current.currentTime=ve.current,ve.current=null,G.current.play().catch(()=>void 0)):G.current&&(G.current.currentTime=_.positionMs/1e3)},onError:()=>se(i?`录音暂不可播放`:`Recording unavailable`)})}):null,R?(0,$.jsxs)(`aside`,{"aria-label":i?`原话证据`:`Source evidence`,className:`absolute inset-y-0 right-0 z-10 flex w-[min(26rem,100%)] flex-col border-l border-edge bg-surface-panel`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge p-4`,children:[(0,$.jsxs)(`h3`,{children:[i?`原话证据`:`Source evidence`,` · v`,R.transcriptRevision]}),(0,$.jsx)(`button`,{"aria-label":i?`关闭`:`Close`,onClick:()=>z(null),children:(0,$.jsx)(g,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`按整段定位,不代表词句级时间。`:`Segment timing; not word-level alignment.`}),R.stale?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`原文已更新,以下保留当时版本的依据。`:`Transcript updated; showing the original evidence revision.`}):null,!R.audioAvailable||!R.timingVerified?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`原文仍可查看;原音不可用或时间定位待核实。`:`Text remains available; audio is missing or timing is unverified.`}):null,R.segments.map(t=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded border border-edge p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[Rt(t.startedAtMs),`–`,Rt(t.endedAtMs),` · `,t.speakerLabel??(i?`说话人未明确`:`Unknown speaker`)]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-7`,children:t.text}),t.playback.map((e,t)=>(0,$.jsxs)(U,{onClick:()=>xe(e.startedAtMs,e.endedAtMs),children:[i?`播放原话`:`Play source`,` `,Rt(e.startedAtMs),`–`,Rt(e.endedAtMs)]},t)),R.stale?null:(0,$.jsx)(U,{onClick:()=>{E(``),de(Math.max(ue,Math.ceil((Ee.segments.findIndex(e=>e.sequence===t.sequence)+1)/50))),x(`transcript`),me([t.sequence]),z(null),v(e,{anchor:t.sequence,anchorRevision:Ee.revision}),window.setTimeout(()=>document.getElementById(`discussion-segment-${t.sequence}`)?.scrollIntoView?.({block:`center`}),0)},children:i?`定位原文`:`Locate transcript`})]},t.sequence))]})]}):null,te&&Oe?(0,$.jsx)(It,{initial:te,zh:i,busy:H,onClose:()=>ne(null),onSave:e=>be(async()=>{await y(w(`${f}/summary`),{method:`PATCH`,body:JSON.stringify({...e,expectedRevision:Oe.revision})}),ne(null)})},`${te.kind}:${te.itemId}:${Oe.revision}`):null,B?(0,$.jsx)(j,{open:!0,onOpenChange:e=>{e||ee(null)},children:(0,$.jsxs)(O,{children:[(0,$.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(k,{"aria-describedby":void 0,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(28rem,90dvh)] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[(0,$.jsxs)(`header`,{className:`flex items-center justify-between border-b border-edge p-4`,children:[(0,$.jsx)(A,{children:i?`校对逐字稿`:`Edit transcript`}),(0,$.jsx)(`button`,{"aria-label":i?`关闭校对`:`Close editor`,onClick:()=>ee(null),children:(0,$.jsx)(g,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[(0,$.jsxs)(`label`,{className:`block text-xs`,children:[i?`本段说话人`:`Speaker for this segment`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-surface-inset p-2 text-sm`,value:B.speaker,onChange:e=>ee({...B,speaker:e.target.value})})]}),B.segment.speakerLabel?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!B.applyToSpeakerGroup,onChange:e=>ee({...B,applyToSpeakerGroup:e.target.checked})}),i?`同时更名所有同标签片段;输入已有标签可合并说话人`:`Rename all segments with this label; use an existing label to merge speakers`]}):null,(0,$.jsx)(`textarea`,{className:`min-h-32 w-full rounded border border-edge bg-surface-inset p-2 text-sm`,value:B.text,onChange:e=>ee({...B,text:e.target.value})})]}),(0,$.jsx)(`footer`,{className:`border-t border-edge p-3`,children:(0,$.jsxs)(U,{variant:`primary`,disabled:H||!B.text.trim(),onClick:()=>void be(async()=>{await y(w(`${f}/segments/${B.segment.sequence}`),{method:`PATCH`,body:JSON.stringify({displayText:B.text,speakerLabel:B.speaker,expectedRevision:B.segment.revision,applyToSpeakerGroup:B.applyToSpeakerGroup,expectedTranscriptRevision:Ee.revision})}),ee(null)}),children:[(0,$.jsx)(c,{className:`size-4`}),i?`保存修订`:`Save revision`]})})]})]})}):null]})}var Bt={edit:ct,ai_edit:se,sync:Y,restore:Re};function Vt(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function Ht({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let a=S(e=>e.language),o=_(a).notes,s={justNow:o.justNow,minutesAgo:o.minutesAgo,today:o.today,yesterday:o.yesterday,daysAgo:o.daysAgo,locale:x(a)},{data:c}=P(e?[`note-history`,e]:null,()=>pt(e)),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),h=(0,Q.useCallback)(async t=>{u(!0),m(null);try{await le(e,t),f(null),i()}catch{m(o.restoreFailed)}finally{u(!1)}},[e,o.restoreSuccess,o.restoreFailed,i]),y=Date.now();return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(dt,{className:`size-4`,"aria-hidden":!0}),o.history]}),(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(g,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[p?(0,$.jsx)(`p`,{className:`border-b border-danger/20 bg-danger-soft px-4 py-2 text-xs text-danger`,role:`alert`,children:p}):null,c?.length?(0,$.jsx)(`ul`,{className:`divide-y divide-edge`,children:c.map(e=>{let r=Bt[e.trigger]??ct,i=t===e.timestamp,a=d===e.timestamp;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:v(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(r,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:Vt(e.trigger,o)}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:xt(e.timestamp,y,s)})]}),e.snippet&&(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,$.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:a?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:o.restoreConfirm}),(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),h(e.timestamp)},disabled:l,className:`shrink-0 rounded-lg bg-accent px-3 py-1 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:opacity-50`,children:l?`...`:o.restore}),(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),f(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),f(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:o.restore})})]},e.timestamp)})}):(0,$.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:o.historyEmpty}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:o.historyEmptyDescription})]})]})]})}function Ut({noteId:e,note:t,catalyzing:n,onCatalyze:r,onClose:i,noteThreads:a,openingChat:s,onOpenChat:c,onOpenNewChat:l}){let u=_(S(e=>e.language)).notes,d=o(),f=t?.aiDeep?.catalysis,p=f?.report??null,[m,h]=(0,Q.useState)(null),[g,y]=(0,Q.useState)(!1),{data:b,mutate:x,isLoading:C}=P(e?[`note-agent-context-status`,e]:null,()=>Fe(e),{revalidateOnFocus:!1}),w=(0,Q.useCallback)(async()=>{if(!g){y(!0),h(null);try{await x(()=>pe(e),{revalidate:!1})}catch(e){h(`${u.contextRebuildFailed}: ${e instanceof Error?e.message:u.quickCaptureFailedHint}`)}finally{y(!1)}}},[g,x,u.contextRebuildFailed,u.quickCaptureFailedHint,e]),T=(0,Q.useCallback)(async t=>{try{await Be(e,t)}catch{}},[e]);return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(se,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:u.catalysisSectionTitle})]}),(0,$.jsx)(`button`,{type:`button`,onClick:i,"aria-label":u.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(I,{className:`size-4 rotate-180`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,$.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:u.catalysisSectionDescription}),b?(0,$.jsxs)(`section`,{className:`mb-4 rounded-xl bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.contextStatusTitle}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:C||g,className:`rounded-md px-1.5 py-0.5 text-[11px] font-medium text-accent transition-colors hover:bg-accent/10 disabled:cursor-not-allowed disabled:opacity-50`,children:g?u.processing:u.contextRebuild}),(0,$.jsx)(`span`,{className:v(`rounded-full px-2 py-0.5 text-[11px] font-medium`,b.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:b.status===`partial`?`bg-amber-500/10 text-amber-600 dark:text-amber-300`:`bg-red-500/10 text-red-600 dark:text-red-300`),children:b.status})]}),(0,$.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:u.contextStatusDetail.replace(`{{attachments}}`,String(b.attachments.length)).replace(`{{tokens}}`,String(b.tokenEstimate??0))}),m?(0,$.jsx)(`p`,{className:`mt-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:m}):null,b.attachments.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:b.attachments.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId))}):null]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:n?u.processing:p?u.recatalyze:u.catalyzeAction}),p?(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.valueHypothesis}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:p.valueHypothesis})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.targetUsers}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:p.targetUsers.slice(0,5).map(e=>(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.keyQuestions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.keyQuestions.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.mvpPathLabel}),(0,$.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.mvpPath.slice(0,3).map((e,t)=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.risks}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.risks.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-fg-muted`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.nextActions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.nextActions.slice(0,4).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,$.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:u.confidenceLabel.replace(`{{percent}}`,String(Math.round(p.confidence*100)))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void T(`helpful`),className:v(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,f?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackHelpfulAria,children:(0,$.jsx)(re,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void T(`not_helpful`),className:v(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,f?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackNotHelpfulAria,children:(0,$.jsx)(V,{className:`size-3.5`,"aria-hidden":!0})})]})]})]}):(0,$.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:u.noCatalysisReportHint}),(0,$.jsxs)(`section`,{className:`mt-6 rounded-xl bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(be,{className:`size-4 text-accent`,"aria-hidden":!0}),u.relatedThreadsTitle]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.relatedThreadsDescription})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:c,disabled:s,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:s?u.openingChat:u.openThread}),(0,$.jsx)(`button`,{type:`button`,onClick:l,disabled:s,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:u.newThread})]})]}),a.length>0?(0,$.jsx)(`div`,{className:`space-y-2`,children:a.slice(0,5).map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||u.noteDiscussionFallback}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:u.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:u.noThreads})]})]})]})}var Wt=[{value:`86400000`,zh:`24 小时`,en:`24 hours`},{value:`604800000`,zh:`7 天`,en:`7 days`},{value:`2592000000`,zh:`30 天`,en:`30 days`}];function Gt({open:e,onOpenChange:t,note:n}){let r=S(e=>e.language)===`zh`,i=r?Yt:Xt,{data:a,mutate:o}=P(e?[`note-shares`,n.id]:null,()=>lt(n.id)),s=P(e?`hosted-share-auth-status`:null,_e),l=s.data===!0,d=P(e&&l?`hosted-publication-capabilities`:null,ut),f=d.data?.publishing.allowed===!0,m=P(e&&l?[`hosted-note-publications`,n.id]:null,()=>at(n.id)),[h,_]=(0,Q.useState)(new Set),[v,y]=(0,Q.useState)(`86400000`),[b,x]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[M,F]=(0,Q.useState)(`hosted`),[I,L]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(null),[ee,ne]=(0,Q.useState)(null),[re,ie]=(0,Q.useState)(!1),[ae,V]=(0,Q.useState)(null),se=(0,Q.useMemo)(()=>{let e=new Set;return n.markdown.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^\s)]+)/gi,(t,r,i)=>{try{decodeURIComponent(r)===n.id&&e.add(decodeURIComponent(i))}catch{}return t}),(n.attachments??[]).filter(t=>e.has(t.id))},[n.attachments,n.id,n.markdown]);(0,Q.useEffect)(()=>{e&&(_(new Set(se.map(e=>e.id))),ne(null),ie(!1),V(null))},[e,se]);let ce=async()=>{L(!0),V(null);try{let e={expectedNoteVersion:n.updatedAt,attachmentIds:[...h],ttlMs:Number(v),maxViews:b.trim()?Number(b):null,description:C.trim()||void 0};M===`hosted`?(ne((await ke(n.id,e)).shareUrl),await m.mutate()):(ne((await Je(n.id,e)).payload.shareUrl),await o())}catch(e){V(e instanceof Error?e.message:String(e))}finally{L(!1)}},le=async(e,t)=>{B(e.id),V(null);try{t===`refresh`?await R(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...h]}):await ve(e.id),await m.mutate()}catch(e){V(e instanceof Error?e.message:String(e))}finally{B(null)}},ue=async(e,t)=>{B(e.id),V(null);try{t===`refresh`?await ze(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...h]}):t===`extend`?await rt(e.id,864e5):await te(e.id),await o()}catch(e){V(e instanceof Error?e.message:String(e))}finally{B(null)}},de=async e=>{V(null);try{if(!await N(e)){ie(!1),V(i.copyFailed);return}ie(!0),window.setTimeout(()=>ie(!1),1500)}catch{ie(!1),V(i.copyFailed)}};return(0,$.jsx)(j,{open:e,onOpenChange:t,children:(0,$.jsxs)(O,{children:[(0,$.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(k,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(A,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,$.jsx)(Ne,{className:`size-4`}),i.title]}),(0,$.jsx)(E,{className:`mt-1 text-xs text-fg-muted`,children:i.description})]}),(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-fg-muted hover:bg-surface-hover`,"aria-label":i.close,children:(0,$.jsx)(g,{className:`size-4`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-inset p-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.title||i.untitled}),(0,$.jsx)(`p`,{className:`mt-2 line-clamp-4 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,children:n.markdown||i.empty}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:i.privateExcluded})]}),se.length>0?(0,$.jsxs)(`section`,{className:`mt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.attachments}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:se.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:h.has(e.id),onChange:()=>_(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),className:`accent-accent`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:Jt(e.size)})]},e.id))})]}):null,(0,$.jsxs)(`section`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.delivery,(0,$.jsxs)(Ae,{value:M,onChange:e=>F(e.target.value),children:[(0,$.jsx)(X,{value:`hosted`,children:i.deliveryHosted}),(0,$.jsx)(X,{value:`local`,children:i.deliveryLocal})]})]}),M===`hosted`&&s.data===!1?(0,$.jsx)(`div`,{className:`sm:col-span-2`,children:(0,$.jsx)(oe,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:()=>void s.mutate(!0,{revalidate:!1})})}):null,M===`hosted`&&l&&d.data&&!f?(0,$.jsx)(`p`,{className:`rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning sm:col-span-2`,children:i.hostedDisabled}):null,(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.expires,(0,$.jsx)(Ae,{value:v,onChange:e=>y(e.target.value),children:Wt.map(e=>(0,$.jsx)(X,{value:e.value,children:r?e.zh:e.en},e.value))})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.maxViews,(0,$.jsx)(`input`,{type:`number`,min:1,max:1e3,value:b,onChange:e=>x(e.target.value),placeholder:i.unlimited,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.publicDescription,(0,$.jsx)(`input`,{value:C,onChange:e=>w(e.target.value),className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]})]}),ee?(0,$.jsx)(`div`,{className:`mt-5 rounded-lg border border-success/25 bg-success-soft p-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`input`,{readOnly:!0,value:ee,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`}),(0,$.jsxs)(U,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void de(ee),children:[re?(0,$.jsx)(c,{className:`size-4`}):(0,$.jsx)(u,{className:`size-4`}),re?i.copied:i.copy]}),(0,$.jsxs)(U,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>window.open(ee,`_blank`,`noopener,noreferrer`),children:[(0,$.jsx)(p,{className:`size-4`}),i.open]})]})}):null,ae?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,children:ae}):null,(a?.items.length??0)>0?(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.activeLinks}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:a.items.map(e=>(0,$.jsx)(qt,{share:e,busy:z===e.id,t:i,onCopy:de,onAction:ue},e.id))})]}):null,(m.data?.length??0)>0?(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.hostedLinks}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:m.data.map(e=>(0,$.jsx)(Kt,{publication:e,stale:e.source?.version!==String(n.updatedAt),busy:z===e.id,publishingAllowed:f,t:i,onCopy:de,onAction:le},e.id))})]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-3`,children:[(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,children:i.close})}),(0,$.jsxs)(U,{type:`button`,onClick:()=>void ce(),disabled:I||M===`hosted`&&(!l||!f),children:[I?(0,$.jsx)(H,{className:`size-4 animate-spin`}):(0,$.jsx)(Ne,{className:`size-4`}),I?i.creating:i.create]})]})]})]})})}function Kt(e){let t=(0,gt.c)(64),{publication:n,stale:r,busy:i,publishingAllowed:a,t:o,onCopy:s,onAction:c}=e,l=n.revoked||n.expired,d=l&&`opacity-60`,f;t[0]===d?f=t[1]:(f=v(`rounded-lg border border-edge-subtle p-3`,d),t[0]=d,t[1]=f);let m=r&&!l?o.stale:l?o.inactive:o.active,h;t[2]===m?h=t[3]:(h=(0,$.jsx)(`span`,{children:m}),t[2]=m,t[3]=h);let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{children:`·`}),t[4]=g):g=t[4];let _=n.maxViews===null?``:` / ${n.maxViews}`,y;t[5]!==n.viewCount||t[6]!==o.views||t[7]!==_?(y=(0,$.jsxs)(`span`,{children:[o.views,` `,n.viewCount,_]}),t[5]=n.viewCount,t[6]=o.views,t[7]=_,t[8]=y):y=t[8];let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`span`,{children:`·`}),t[9]=b):b=t[9];let x;t[10]!==n.revision||t[11]!==o.revision?(x=(0,$.jsxs)(`span`,{children:[o.revision,` `,n.revision]}),t[10]=n.revision,t[11]=o.revision,t[12]=x):x=t[12];let S;t[13]!==h||t[14]!==y||t[15]!==x?(S=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[h,g,y,b,x]}),t[13]=h,t[14]=y,t[15]=x,t[16]=S):S=t[16];let C;t[17]===n.shareUrl?C=t[18]:(C=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[17]=n.shareUrl,t[18]=C);let w;t[19]!==S||t[20]!==C?(w=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[19]=S,t[20]=C,t[21]=w):w=t[21];let T;t[22]===i?T=t[23]:(T=i?(0,$.jsx)(H,{className:`size-4 animate-spin text-fg-muted`}):null,t[22]=i,t[23]=T);let E;t[24]!==w||t[25]!==T?(E=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[w,T]}),t[24]=w,t[25]=T,t[26]=E):E=t[26];let D=!a,O;t[27]!==s||t[28]!==n.shareUrl?(O=()=>void s(n.shareUrl),t[27]=s,t[28]=n.shareUrl,t[29]=O):O=t[29];let k;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(u,{className:`size-3.5`}),t[30]=k):k=t[30];let A;t[31]!==o.copy||t[32]!==D||t[33]!==O?(A=(0,$.jsxs)(U,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:D,onClick:O,children:[k,o.copy]}),t[31]=o.copy,t[32]=D,t[33]=O,t[34]=A):A=t[34];let j=!a,M;t[35]===n.shareUrl?M=t[36]:(M=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=M);let N;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(p,{className:`size-3.5`}),t[37]=N):N=t[37];let P;t[38]!==o.open||t[39]!==j||t[40]!==M?(P=(0,$.jsxs)(U,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:j,onClick:M,children:[N,o.open]}),t[38]=o.open,t[39]=j,t[40]=M,t[41]=P):P=t[41];let F;t[42]!==i||t[43]!==l||t[44]!==c||t[45]!==n||t[46]!==a||t[47]!==r||t[48]!==o.refresh?(F=r&&!l?(0,$.jsxs)(U,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i||!a,onClick:()=>void c(n,`refresh`),children:[(0,$.jsx)(Y,{className:`size-3.5`}),o.refresh]}):null,t[42]=i,t[43]=l,t[44]=c,t[45]=n,t[46]=a,t[47]=r,t[48]=o.refresh,t[49]=F):F=t[49];let I;t[50]!==i||t[51]!==c||t[52]!==n||t[53]!==o.revoke?(I=n.revoked?null:(0,$.jsxs)(U,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i,onClick:()=>void c(n,`revoke`),children:[(0,$.jsx)(de,{className:`size-3.5`}),o.revoke]}),t[50]=i,t[51]=c,t[52]=n,t[53]=o.revoke,t[54]=I):I=t[54];let L;t[55]!==A||t[56]!==P||t[57]!==F||t[58]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[A,P,F,I]}),t[55]=A,t[56]=P,t[57]=F,t[58]=I,t[59]=L):L=t[59];let R;return t[60]!==E||t[61]!==f||t[62]!==L?(R=(0,$.jsxs)(`div`,{className:f,children:[E,L]}),t[60]=E,t[61]=f,t[62]=L,t[63]=R):R=t[63],R}function qt(e){let t=(0,gt.c)(68),{share:n,busy:r,t:i,onCopy:a,onAction:o}=e,s=n.revoked||n.expired,c=s&&`opacity-60`,l;t[0]===c?l=t[1]:(l=v(`rounded-lg border border-edge-subtle p-3`,c),t[0]=c,t[1]=l);let d=n.stale&&!s?i.stale:s?i.inactive:i.active,f;t[2]===d?f=t[3]:(f=(0,$.jsx)(`span`,{children:d}),t[2]=d,t[3]=f);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`span`,{children:`·`}),t[4]=m):m=t[4];let h=n.maxViews===null?``:` / ${n.maxViews}`,g;t[5]!==n.viewCount||t[6]!==i.views||t[7]!==h?(g=(0,$.jsxs)(`span`,{children:[i.views,` `,n.viewCount,h]}),t[5]=n.viewCount,t[6]=i.views,t[7]=h,t[8]=g):g=t[8];let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{children:`·`}),t[9]=_):_=t[9];let y;t[10]===n.expiresAt?y=t[11]:(y=new Date(n.expiresAt).toLocaleDateString(),t[10]=n.expiresAt,t[11]=y);let b;t[12]===y?b=t[13]:(b=(0,$.jsx)(`span`,{children:y}),t[12]=y,t[13]=b);let x;t[14]!==b||t[15]!==f||t[16]!==g?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[f,m,g,_,b]}),t[14]=b,t[15]=f,t[16]=g,t[17]=x):x=t[17];let S;t[18]===n.shareUrl?S=t[19]:(S=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[18]=n.shareUrl,t[19]=S);let C;t[20]!==x||t[21]!==S?(C=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),t[20]=x,t[21]=S,t[22]=C):C=t[22];let w;t[23]===r?w=t[24]:(w=r?(0,$.jsx)(H,{className:`size-4 animate-spin text-fg-muted`}):null,t[23]=r,t[24]=w);let T;t[25]!==C||t[26]!==w?(T=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[C,w]}),t[25]=C,t[26]=w,t[27]=T):T=t[27];let E;t[28]!==a||t[29]!==n.shareUrl?(E=()=>void a(n.shareUrl),t[28]=a,t[29]=n.shareUrl,t[30]=E):E=t[30];let D;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(u,{className:`size-3.5`}),t[31]=D):D=t[31];let O;t[32]!==i.copy||t[33]!==E?(O=(0,$.jsxs)(U,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:E,children:[D,i.copy]}),t[32]=i.copy,t[33]=E,t[34]=O):O=t[34];let k;t[35]===n.shareUrl?k=t[36]:(k=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=k);let A;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(p,{className:`size-3.5`}),t[37]=A):A=t[37];let j;t[38]!==i.open||t[39]!==k?(j=(0,$.jsxs)(U,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:k,children:[A,i.open]}),t[38]=i.open,t[39]=k,t[40]=j):j=t[40];let M;t[41]!==r||t[42]!==s||t[43]!==o||t[44]!==n||t[45]!==i.refresh?(M=n.stale&&!s?(0,$.jsxs)(U,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`refresh`),children:[(0,$.jsx)(Y,{className:`size-3.5`}),i.refresh]}):null,t[41]=r,t[42]=s,t[43]=o,t[44]=n,t[45]=i.refresh,t[46]=M):M=t[46];let N;t[47]!==r||t[48]!==s||t[49]!==o||t[50]!==n||t[51]!==i.extend?(N=s?null:(0,$.jsx)(U,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`extend`),children:i.extend}),t[47]=r,t[48]=s,t[49]=o,t[50]=n,t[51]=i.extend,t[52]=N):N=t[52];let P;t[53]!==r||t[54]!==o||t[55]!==n||t[56]!==i.revoke?(P=n.revoked?null:(0,$.jsxs)(U,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`revoke`),children:[(0,$.jsx)(de,{className:`size-3.5`}),i.revoke]}),t[53]=r,t[54]=o,t[55]=n,t[56]=i.revoke,t[57]=P):P=t[57];let F;t[58]!==O||t[59]!==j||t[60]!==M||t[61]!==N||t[62]!==P?(F=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[O,j,M,N,P]}),t[58]=O,t[59]=j,t[60]=M,t[61]=N,t[62]=P,t[63]=F):F=t[63];let I;return t[64]!==T||t[65]!==l||t[66]!==F?(I=(0,$.jsxs)(`div`,{className:l,children:[T,F]}),t[64]=T,t[65]=l,t[66]=F,t[67]=I):I=t[67],I}function Jt(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var Yt={title:`分享笔记`,description:`创建一个无需登录即可查看的只读快照。`,close:`关闭`,untitled:`无标题笔记`,empty:`空笔记`,privateExcluded:`不会分享标签、AI 元数据、项目、讨论、历史版本或未引用附件。`,attachments:`包含的附件`,expires:`有效期`,maxViews:`最多查看次数`,unlimited:`不限`,publicDescription:`公开说明(可选)`,create:`创建分享链接`,creating:`创建中…`,copy:`复制`,copied:`已复制`,open:`打开`,activeLinks:`这条笔记的分享`,copyFailed:`无法复制到剪贴板,请手动选择链接并复制。`,delivery:`发布方式`,deliveryHosted:`平台托管(外网稳定访问)`,deliveryLocal:`本机直连(需要隧道或公网部署)`,hostedLinks:`平台托管发布`,revision:`版本`,hostedDisabled:`管理员已暂停你的公网分享能力。已有托管链接当前不可访问,但仍可撤销。`,stale:`旧版本`,inactive:`已失效`,active:`有效`,views:`查看`,refresh:`更新快照`,extend:`延长 24 小时`,revoke:`撤销`},Xt={title:`Share Note`,description:`Create a read-only snapshot that opens without sign-in.`,close:`Close`,untitled:`Untitled Note`,empty:`Empty Note`,privateExcluded:`Tags, AI metadata, projects, discussions, history, and unreferenced attachments are excluded.`,attachments:`Included attachments`,expires:`Expires`,maxViews:`Maximum views`,unlimited:`Unlimited`,publicDescription:`Public description (optional)`,create:`Create share link`,creating:`Creating…`,copy:`Copy`,copied:`Copied`,open:`Open`,activeLinks:`Shares for this Note`,copyFailed:`Could not copy to the clipboard. Select the link and copy it manually.`,delivery:`Publishing method`,deliveryHosted:`Hosted platform (stable public access)`,deliveryLocal:`Direct from this device (requires public access)`,hostedLinks:`Hosted publications`,revision:`Revision`,hostedDisabled:`An administrator has paused public sharing for your account. Existing hosted links are unavailable, but can still be revoked.`,stale:`Older version`,inactive:`Inactive`,active:`Active`,views:`Views`,refresh:`Update snapshot`,extend:`Extend 24 hours`,revoke:`Revoke`};function Zt(e){let t=(0,gt.c)(18),{input:n,labels:r,showLabel:i}=e,a=i===void 0?!0:i,o;t[0]===n?o=t[1]:(o=n(),t[0]=n,t[1]=o);let s=o.source.id,c;t[2]===s?c=t[3]:(c=e=>e.source?.type===`note`&&e.source.id===s&&e.status!==`idle`,t[2]=s,t[3]=c);let l=F(c),u;t[4]===s?u=t[5]:(u=e=>e.source?.type===`note`&&e.source.id===s&&e.status===`preparing`,t[4]=s,t[5]=u);let d=F(u),f=F(Qt),p;t[6]!==n||t[7]!==r||t[8]!==d||t[9]!==a?(p=(0,$.jsx)(W,{input:n,labels:r,disabled:d,showLabel:a}),t[6]=n,t[7]=r,t[8]=d,t[9]=a,t[10]=p):p=t[10];let m;t[11]!==l||t[12]!==r||t[13]!==f?(m=l?(0,$.jsx)(`button`,{type:`button`,onClick:f,title:r.stop,"aria-label":r.stop,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(Se,{className:`size-3.5`,"aria-hidden":!0})}):null,t[11]=l,t[12]=r,t[13]=f,t[14]=m):m=t[14];let h;return t[15]!==p||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[p,m]}),t[15]=p,t[16]=m,t[17]=h):h=t[17],h}function Qt(e){return e.stop}function $t(e,t){let n=je(t.replace(/^\s*(`{3,}|~{3,})[^\n]*$/gm,``).replace(/xopc-attachment:\/\/[^\s)]+/g,``).replace(/^(\s*[-*+]\s+)\[[ xX]\]\s*/gm,`$1`)),r=je(e);return!r||n.split(`
3
- `)[0]===r?n:[r,n].filter(Boolean).join(`
4
-
5
- `)}var en=()=>i(()=>import(`./block-editor-lnkSRbxE.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58])),tn=()=>i(()=>import(`./markdown-editor-BhBJANcx.js`),__vite__mapDeps([59,1,55,5,60,61,3])),nn=(0,Q.lazy)(()=>en().then(e=>({default:e.BlockEditor}))),rn=(0,Q.lazy)(()=>tn().then(e=>({default:e.MarkdownEditor})));function an(){let e=(0,gt.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,$.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function on(e){let t=(0,gt.c)(29),{mode:n,onModeChange:r,labels:i}=e,a;t[0]===i.edit?a=t[1]:(a={id:`wysiwyg`,label:i.edit,Icon:he},t[0]=i.edit,t[1]=a);let o;t[2]===i.source?o=t[3]:(o={id:`source`,label:i.source,Icon:K},t[2]=i.source,t[3]=o);let s;t[4]===i.preview?s=t[5]:(s={id:`preview`,label:i.preview,Icon:m},t[4]=i.preview,t[5]=s);let l;t[6]!==a||t[7]!==o||t[8]!==s?(l=[a,o,s],t[6]=a,t[7]=o,t[8]=s,t[9]=l):l=t[9];let u=l,d;t[10]!==n||t[11]!==u?(d=u.find(e=>e.id===n)??u[0],t[10]=n,t[11]=u,t[12]=d):d=t[12];let f=d,p=f.Icon,h=sn,g;t[13]===p?g=t[14]:(g=(0,$.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),t[13]=p,t[14]=g);let _;t[15]===f.label?_=t[16]:(_=(0,$.jsx)(`span`,{children:f.label}),t[15]=f.label,t[16]=_);let v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(qe,{className:`size-3 text-fg-subtle`,"aria-hidden":!0}),t[17]=v):v=t[17];let y;t[18]!==f.label||t[19]!==g||t[20]!==_?(y=(0,$.jsx)(Ee,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":f.label,className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-edge px-2.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[g,_,v]})}),t[18]=f.label,t[19]=g,t[20]=_,t[21]=y):y=t[21];let b;t[22]!==n||t[23]!==u||t[24]!==r?(b=(0,$.jsx)(Ge,{children:(0,$.jsx)(Me,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:u.map(e=>{let{id:t,label:i,Icon:a}=e;return(0,$.jsxs)(et,{onSelect:()=>r(t),onPointerMove:()=>h(t),onFocus:()=>h(t),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(a,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:i}),n===t?(0,$.jsx)(c,{className:`size-4 text-accent`,"aria-hidden":!0}):null]},t)})})}),t[22]=n,t[23]=u,t[24]=r,t[25]=b):b=t[25];let x;return t[26]!==b||t[27]!==y?(x=(0,$.jsxs)(Xe,{modal:!1,children:[y,b]}),t[26]=b,t[27]=y,t[28]=x):x=t[28],x}function sn(e){e===`wysiwyg`&&en(),e===`source`&&tn()}function cn(e){let t=(0,gt.c)(16),{noteId:n,onBack:r,onSaved:i,showBackButton:a,backButtonClassName:o,clearHeaderOnCleanup:s,onOpenSearch:c,autoFocus:l,initialMode:u,onAutoFocusConsumed:d}=e,f=a===void 0?!0:a,p=s===void 0?!0:s,m=l===void 0?!1:l,h=S(ln),g;t[0]===h?g=t[1]:(g=_(h),t[0]=h,t[1]=g);let v=g.notes.lightboxClose,y;t[2]!==m||t[3]!==o||t[4]!==p||t[5]!==u||t[6]!==n||t[7]!==d||t[8]!==r||t[9]!==c||t[10]!==i||t[11]!==f?(y=(0,$.jsx)(un,{noteId:n,onBack:r,onSaved:i,showBackButton:f,backButtonClassName:o,clearHeaderOnCleanup:p,onOpenSearch:c,autoFocus:m,initialMode:u,onAutoFocusConsumed:d}),t[2]=m,t[3]=o,t[4]=p,t[5]=u,t[6]=n,t[7]=d,t[8]=r,t[9]=c,t[10]=i,t[11]=f,t[12]=y):y=t[12];let b;return t[13]!==v||t[14]!==y?(b=(0,$.jsx)(z,{closeLabel:v,children:y}),t[13]=v,t[14]=y,t[15]=b):b=t[15],b}function ln(e){return e.language}function un({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:a=!0,onOpenSearch:s,autoFocus:l=!1,initialMode:u=`wysiwyg`,onAutoFocusConsumed:d}){let p=S(e=>e.language),m=_(p).notes,h=_(p).chat.pageContext,g=_(p).automations.suggestions,{data:y}=P([`note-discussion-document`,e],()=>Pe(e)),[x,C]=(0,Q.useState)(!0),w=o(),T=Ve(e=>e.resolved)===`dark`,{openImage:E}=xe(),[D,O]=(0,Q.useState)(u),[k,A]=(0,Q.useState)(null),[j,N]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(!1),[z,ee]=(0,Q.useState)(``),[te,ne]=(0,Q.useState)(360),[re,V]=(0,Q.useState)(!1),[oe,H]=(0,Q.useState)(!1),[U,ce]=(0,Q.useState)(!1),le=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{le.current+=1},[e]);let[pe,W]=(0,Q.useState)(null),[ge,_e]=(0,Q.useState)(!1),[ve,ye]=(0,Q.useState)(null),[Se,K]=(0,Q.useState)(!1),[we,Oe]=(0,Q.useState)(!1),J=(0,Q.useRef)(!1),ke=(0,Q.useRef)(!1),Ae=(0,Q.useRef)(null),Y=(0,Q.useRef)(null),je=(0,Q.useRef)(null),X=(0,Q.useRef)(null),Fe=(0,Q.useRef)(null),Re=(0,Q.useRef)(null),ze=(0,Q.useRef)(null),Be=(0,Q.useRef)(null),He=(0,Q.useRef)(null),Ue=ae(e=>e.setPageHeader),Ke=ae(e=>e.clearPageHeader),{data:Z,mutate:qe,error:Je}=P(e?[`note-detail`,e]:null,()=>Ie(e)),{data:Ye=[],mutate:Ze}=P(e?[`note-threads`,e]:null,()=>G(e),{revalidateOnFocus:!1}),Qe=j!==null,tt=(0,Q.useCallback)(e=>{W(`${m.refreshFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)},[m.quickCaptureFailedHint,m.refreshFailed]);(0,Q.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&qe().catch(tt)};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[qe,e,tt]),(0,Q.useEffect)(()=>{J.current=!1,ee(``),N(null),A(null),ke.current=!1,He.current=null},[e]),(0,Q.useEffect)(()=>{!Z||J.current||(ee(Z.title??``),J.current=!0)},[Z]),(0,Q.useEffect)(()=>{if(!l||!Z||Qe||He.current===e)return;let t=window.requestAnimationFrame(()=>{Be.current?.focus(),d?.()});return He.current=e,()=>window.cancelAnimationFrame(t)},[l,Qe,Z,e,d]);let rt=Z?new Date(Z.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,it=(0,Q.useMemo)(()=>r?(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":m.back,className:v(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,B,i),children:(0,$.jsx)(I,{className:`size-4`,"aria-hidden":!0})}):null,[i,m.back,t,r]),at=(0,Q.useCallback)(()=>{let t=F.getState();t.source?.type===`note`&&t.source.id===e&&t.stop()},[e]),st=(0,Q.useCallback)(e=>{e!==`preview`&&at(),O(e)},[at]),ct=(0,Q.useCallback)(t=>{at(),ee(t),e&&(X.current=t,Y.current&&clearTimeout(Y.current),Y.current=setTimeout(async()=>{let t=X.current;if(X.current=null,t!==null){R(!0);try{await fe(e,{title:t}),await qe(),n?.()}catch{}finally{R(!1)}}},600))},[at,e,qe,n]),lt=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:v(`flex min-w-0 items-center gap-2`,B),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:z||rt||void 0,children:z||rt}),L?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:m.saving}):null]}),[m.saving,L,rt,z]),ut=(0,Q.useCallback)(async(t=!1)=>{ce(!0),W(null);try{let n=await ot(e,{forceNew:t});await qe(),await Ze(),w(`/chat/${encodeURIComponent(n.conversationId)}`)}catch(e){W(`${m.chatOpenFailedTitle}: ${e instanceof Error?e.message:m.chatOpenFailedMessage}`)}finally{ce(!1)}},[qe,Ze,w,e,m.chatOpenFailedMessage,m.chatOpenFailedTitle]),ft=(0,Q.useCallback)(async()=>{H(!0),W(null);try{await nt(e),await qe()}catch(e){W(`${m.catalysisFailed}: ${e instanceof Error?e.message:m.chatOpenFailedMessage}`)}finally{H(!1)}},[qe,e]),pt=(0,Q.useCallback)(()=>{A(k===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!oe&&ft()},[k,oe,ft,Z?.aiDeep?.catalysis?.report]),mt=(0,Q.useCallback)(()=>{let t=j?j.markdown??``:je.current??Z?.markdown??``,n=j?j.title??``:z,r=$t(n,t);return{source:{type:`note`,id:e,title:n||m.titlePlaceholder},text:r,language:$e(r,p)}},[p,m.titlePlaceholder,Z?.markdown,e,j,z]),ht=(0,Q.useCallback)(async()=>{Ae.current&&clearTimeout(Ae.current),Y.current&&clearTimeout(Y.current),Ae.current=null,Y.current=null;let t=je.current,r=X.current;je.current=null,X.current=null;let i={};if(t!==null&&(i.markdown=t),r!==null&&(i.title=r),Object.keys(i).length===0)return Z??null;R(!0);try{let t=await fe(e,i);return await qe(t,{revalidate:!1}),n?.(),t}catch(e){return je.current===null&&(je.current=t),X.current===null&&(X.current=r),W(`${m.saveFailed}: ${e instanceof Error?e.message:m.saveFailedHint}`),null}finally{R(!1)}},[qe,m.saveFailed,m.saveFailedHint,Z,e,n]),gt=(0,Q.useCallback)(async()=>{if(!Z||U||L)return;ce(!0),W(null);let e=b.getState(),t=++le.current,n=()=>le.current===t&&b.getState().baseUrl===e.baseUrl&&b.getState().conversationId===e.conversationId;try{let t=window.getSelection(),r=t?.anchorNode&&t.focusNode&&Fe.current?.contains(t.anchorNode)&&Fe.current.contains(t.focusNode)?t.toString():``,i=await ht();if(!i||!n())return;if(je.current!==null||X.current!==null)throw Error(h.unavailable);let a=me.capture({title:i.title||i.id,text:i.markdown,resourceRefs:[{kind:`note`,id:i.id,revision:String(i.remoteVersion??1)}],selection:r?{text:r,draft:!1}:void 0}),o=await new M().createSession();if(!n())return;if(je.current!==null||X.current!==null)throw Error(h.unavailable);let s=ue(e.baseUrl,e.conversationId,o.key);if(!me.put(s,a))throw Error(h.unavailable);w(`/chat/${encodeURIComponent(o.key)}`)}catch{n()&&W(h.unavailable)}finally{le.current===t&&ce(!1)}},[Z,U,L,ht,w,h.unavailable]),_t=(0,Q.useCallback)(async()=>{W(null);let e=await ht();e&&(ye(e),_e(!0))},[ht]),vt=(0,Q.useCallback)(async()=>{if(!(we||L)){K(!1),Oe(!0),W(null),at(),Ae.current&&clearTimeout(Ae.current),Y.current&&clearTimeout(Y.current),Ae.current=null,Y.current=null,je.current=null,X.current=null;try{await We(e),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e}})),n?.(),t()}catch(e){W(`${m.deleteFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)}finally{Oe(!1)}}},[we,m.deleteFailed,m.quickCaptureFailedHint,e,t,n,L,at]),yt=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:v(`flex min-w-0 items-center gap-1 sm:gap-2`,B),children:[s?(0,$.jsx)(`button`,{type:`button`,onClick:s,"aria-label":m.searchDialogTitle,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(De,{className:`size-4`,"aria-hidden":!0})}):null,(0,$.jsx)(Zt,{input:mt,showLabel:!1,labels:{read:m.readAloud,preparing:m.readAloudPreparing,pause:m.readAloudPause,resume:m.readAloudResume,retry:m.readAloudRetry,stop:m.readAloudStop}}),(0,$.jsxs)(`button`,{type:`button`,onClick:pt,disabled:oe,"aria-label":m.catalysisSectionTitle,className:v(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50`,k===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,$.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:oe?m.catalyzing:m.catalyzeButton})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ut(!1),"aria-label":m.openChatButton,disabled:U,className:v(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,$.jsx)(be,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:U?m.openingChat:m.openChatButton})]}),(0,$.jsx)(on,{mode:D,onModeChange:st,labels:{edit:m.modeEdit,source:m.modeSource,preview:m.modePreview}}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void gt(),disabled:U||L||!Z||!!j,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge px-2.5 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,$.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),h.capture]}),(0,$.jsxs)(Xe,{modal:!1,children:[(0,$.jsx)(Ee,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":m.noteActions,title:m.noteActions,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(f,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(Ge,{children:(0,$.jsxs)(Me,{align:`end`,sideOffset:6,className:`z-50 min-w-40 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,$.jsxs)(et,{onSelect:()=>void _t(),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(Ne,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),p===`zh`?`分享`:`Share`]}),(0,$.jsxs)(et,{onSelect:()=>A(k===`history`?null:`history`),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(dt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:m.history}),k===`history`?(0,$.jsx)(c,{className:`size-4 text-accent`,"aria-hidden":!0}):null]}),(0,$.jsx)(Le,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsxs)(et,{disabled:we||L,onSelect:()=>K(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none hover:bg-danger-soft focus:bg-danger-soft data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,$.jsx)(de,{className:`size-4`,"aria-hidden":!0}),m.delete]})]})})]})]}),[oe,pt,ut,gt,h.capture,Z,j,D,m.history,m.modeEdit,m.modePreview,m.modeSource,U,k,s,m.searchDialogTitle,m.readAloud,m.readAloudPause,m.readAloudPreparing,m.readAloudResume,m.readAloudRetry,m.readAloudStop,st,mt,_t,we,L,p,m.delete,K]);(0,Q.useLayoutEffect)(()=>(Ue({startExtra:it,main:Z&&!(y&&x)?lt:null,end:Z&&!(y&&x)?yt:null}),()=>{a&&Ke()}),[a,Ke,yt,lt,it,y,x,Z,Ue]);let bt=(0,Q.useCallback)(t=>{e&&(at(),je.current=t,Ae.current&&clearTimeout(Ae.current),Ae.current=setTimeout(async()=>{let t=je.current;if(je.current=null,t!==null){R(!0),W(null);try{await fe(e,{markdown:t}),await qe(),n?.()}catch(e){W(`${m.saveFailed}: ${e instanceof Error?e.message:m.saveFailedHint}`)}finally{R(!1)}}},600))},[at,e,qe,m.saveFailed,m.saveFailedHint,n]),xt=(0,Q.useCallback)(t=>{Te(e,t.timestamp).then(e=>{e&&(at(),N(e))})},[e,at]),St=(0,Q.useCallback)(()=>{at(),A(null),N(null)},[at]),Ct=(0,Q.useCallback)(()=>{at(),A(null),N(null),qe().catch(tt),n?.()},[qe,n,tt,at]);if((0,Q.useEffect)(()=>()=>{Ae.current&&clearTimeout(Ae.current),Y.current&&clearTimeout(Y.current);let t=je.current,n=X.current;je.current=null,X.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&fe(e,r).catch(()=>void 0)},[e]),Z===void 0)return Je?(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,role:`alert`,children:[(0,$.jsx)(`p`,{className:`text-sm text-danger`,children:m.home.loadFailed}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void qe().catch(tt),className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-hover`,children:m.home.retry}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-fg-muted hover:text-fg`,children:m.back})]}):(0,$.jsx)(an,{});if(Z===null)return(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:m.notFoundTitle}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m.notFoundDescription}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:m.back})]});let Tt=Qe?j.title??``:z,Et=Qe?j.markdown??``:je.current??Z.markdown??``,Dt=new Date(Z.createdAt).getTime(),Ot=Number.isFinite(Dt)&&Date.now()-Dt<3600*1e3?(0,$.jsx)(wt,{title:g.noteCreatedTitle,description:g.noteCreatedDescription,prompt:g.noteCreatedPrompt,coverage:{eventType:`note.created`,source:`notes`,eventPayload:{noteId:e}},variant:`titleAction`,className:`ml-3 hidden max-w-[18rem] shrink-0 md:flex`}):null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mx-auto flex min-h-0 min-w-0 w-full max-w-[60rem] flex-1 flex-col`,children:[pe?(0,$.jsx)(`p`,{className:`mb-3 shrink-0 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:pe}):null,(0,$.jsx)(q,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsx)(q,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),y&&!x?(0,$.jsx)(`button`,{className:`mb-2 inline-flex min-h-11 shrink-0 items-center self-start rounded-lg px-2 text-sm text-accent-fg focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>C(!0),children:p===`zh`?`← 返回录音笔记`:`← Back to recording`}):null,(0,$.jsxs)(`div`,{ref:Fe,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel xl:flex-row`,children:[y&&x?(0,$.jsx)(zt,{noteId:e,noteActions:{onAnalyze:pt,onChat:()=>{ut(!1)},onShare:()=>{_t()},onHistory:()=>A(k===`history`?null:`history`),onDelete:()=>K(!0),busy:we||L||oe||U},onPersonalNotes:()=>{C(!1),window.setTimeout(()=>Be.current?.focus(),0)}}):null,(0,$.jsx)(`div`,{className:y&&x?`hidden`:`min-h-0 min-w-0 flex-1`,children:Qe?(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-4 py-4 sm:px-6`,children:[Tt&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Tt}),Et?(0,$.jsx)(ie,{noteId:e,content:Et,className:`opacity-80`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:m.emptyPreview})]}):(0,$.jsxs)($.Fragment,{children:[D===`wysiwyg`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:Be,type:`text`,value:z,onChange:e=>ct(e.target.value),onCompositionStart:()=>{ke.current=!0},onCompositionEnd:()=>{ke.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!ke.current&&!t.isComposing&&(e.preventDefault(),(Fe.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:m.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Ot]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(an,{}),children:(0,$.jsx)(nn,{initialContent:Z.markdown??``,onChange:bt,noteId:e},`wysiwyg-${e}`)})})]}),D===`source`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:Be,type:`text`,value:z,onChange:e=>ct(e.target.value),placeholder:m.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Ot]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(an,{}),children:(0,$.jsx)(rn,{initialContent:Z.markdown??``,onChange:bt,isDark:T},`source-${e}`)})})]}),D===`preview`&&(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-4 py-4 sm:px-6`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&E(t.currentSrc||t.src,t.alt)},children:[z&&!Z.markdown.trimStart().startsWith(`# ${z.trim()}\n`)&&Z.markdown.trim()!==`# ${z.trim()}`&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:z}),Z.markdown?(0,$.jsx)(ie,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:m.emptyPreview})]})]})})]})]}),(0,$.jsx)(`div`,{ref:Re,className:v(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!re&&`transition-[width] duration-300 ease-in-out`),style:{width:k?te:0},children:(0,$.jsxs)(`div`,{ref:ze,className:`flex min-h-0 flex-1 flex-col`,style:{width:te},children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),V(!0);let n=e.clientX,r=te,i=e.pointerId,a=0,o=te,s=te,c=()=>{a=0,s=o,k&&Re.current?.style.setProperty(`width`,`${s}px`),ze.current?.style.setProperty(`width`,`${s}px`)},l=e=>{let t=r-(e.clientX-n);o=Math.max(280,Math.min(600,Math.round(t))),a===0&&(a=window.requestAnimationFrame(c))},u=()=>{a!==0&&(window.cancelAnimationFrame(a),c());try{t.releasePointerCapture(i)}catch{}V(!1),ne(s),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),window.removeEventListener(`pointercancel`,u)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u),window.addEventListener(`pointercancel`,u)},className:v(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,re&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:k===`history`?(0,$.jsx)(Ht,{noteId:e,activeTimestamp:j?.timestamp??null,onSelect:xt,onClose:St,onRestored:Ct}):k===`breakdown`?(0,$.jsx)(Ut,{noteId:e,note:Z??null,catalyzing:oe,onCatalyze:ft,onClose:()=>A(null),noteThreads:Ye,openingChat:U,onOpenChat:()=>ut(!1),onOpenNewChat:()=>ut(!0)}):null})]})})]}),ve?(0,$.jsx)(Gt,{open:ge,onOpenChange:_e,note:ve}):null,(0,$.jsx)(Ce,{open:Se,title:m.deleteConfirmTitle,description:m.deleteConfirmDescription.replace(`{{title}}`,Z.title||m.titlePlaceholder),confirmLabel:m.deleteConfirmLabel,cancelLabel:m.deleteCancelLabel,destructive:!0,onConfirm:()=>void vt(),onCancel:()=>K(!1)})]})}export{xt as i,Ct as n,St as r,cn as t};
@@ -1 +0,0 @@
1
- import"./index-DdJ_djQt.js";
@@ -1,8 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,g as o,m as s}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as c}from"./ellipsis-0k4rZLoy.js";import{z as l}from"./markdown-view-CthsQiiO.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./messages-Bwv-AOYl.js";import{t as p}from"./cn-0WouolD0.js";import{c as m,f as h,n as g}from"./locale-store-D5h-Ha6-.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{$n as v,Af as y,Ao as ee,Bs as b,Cr as te,Df as ne,Du as x,Ef as S,Go as C,Jl as re,Ju as ie,Lr as w,Mf as ae,Mu as T,Nl as E,Nr as D,Od as oe,Pd as O,Pr as k,Rc as A,Ul as se,Za as ce,an as j,ar as le,au as ue,br as de,dn as M,er as fe,fn as N,fo as pe,fr as me,hn as P,in as he,kf as ge,kl as _e,md as ve,mf as F,mn as ye,mr as be,nr as xe,ou as Se,pf as Ce,pn as we,rr as Te,tr as Ee,us as De,wr as I,xf as Oe,zu as ke}from"./index-DdJ_djQt.js";import{i as Ae,t as L}from"./note-detail-panel-tHYUDAgB.js";var R=n(),z=e(t(),1),B=r();function V({projectId:e}){let t=g(e=>e.language)===`zh`,n=a(),r=(0,z.useRef)(null),i=(0,z.useRef)(null),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(null),[u,d]=(0,z.useState)(null);async function f(){let t=i.current;if(!(!t||o!==null)){s(0),l(null);try{let r=await P();if(r.consentAcknowledgedAt==null){d(r.consentPolicyVersion);return}let a=await he(t.file,t.requestId),o=await ye({clientRequestId:t.requestId,contextProjectId:e,source:`web`,consentPolicyVersion:r.consentPolicyVersion});t.discussionId=o.discussion.id,await N({...a,serverDiscussionId:o.discussion.id,projectId:e}),o.discussion.audioAttachmentId||await j(a,o.discussion.id,s),await M(t.requestId),i.current=null,n(`/notes/${encodeURIComponent(o.note.id)}`)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(null)}}}return(0,B.jsxs)(`div`,{className:`inline-flex flex-wrap items-center gap-2 text-xs`,children:[(0,B.jsx)(`input`,{ref:r,hidden:!0,type:`file`,accept:`audio/*,.m4a,.wav,.mp3,.webm,.ogg`,onChange:e=>{let n=e.target.files?.[0];if(e.target.value=``,n){if(!n.size||n.size>1073741824){l(t?`音频须为 1 字节至 1 GiB`:`Audio must be between 1 byte and 1 GiB`);return}i.current={file:n,requestId:crypto.randomUUID()},f()}}}),(0,B.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md p-2 hover:bg-surface-hover`,disabled:o!==null,onClick:()=>c&&i.current?void f():r.current?.click(),children:[(0,B.jsx)(_e,{className:`size-3.5`}),o===null?c&&i.current?t?`重试导入`:`Retry import`:t?`导入录音`:`Import recording`:`${o}%`]}),u===null?null:(0,B.jsxs)(`span`,{children:[t?`请确认你有权上传此录音,并允许配置的语音服务处理。`:`Confirm permission to upload this recording and process it with your configured speech service.`,(0,B.jsx)(`button`,{type:`button`,className:`p-2 text-accent`,onClick:()=>void we(u).then(()=>(d(null),f())).catch(e=>l(String(e))),children:t?`确认导入`:`Confirm import`})]}),c?(0,B.jsx)(`span`,{role:`alert`,className:`text-danger`,children:c}):null]})}async function je(e){e.note??=await me({title:e.title,markdown:e.markdown,projectId:e.projectId,channel:`web`},e.requestId);let t=e.note.id;for(let n=e.attachments.length;n<e.files.length;n++)e.attachments.push(await k(t,e.files[n],`${e.requestId}:file:${n}`));if(e.attachments.length){let n=e.attachments.map(e=>`[${e.fileName.replace(/[\\[\]]/g,`\\$&`).replace(/[\r\n]/g,` `)}](${w(t,e.id)})`);e.note=await D(t,{markdown:`${e.markdown}\n\n## ${e.materialHeading}\n\n${n.join(`
2
-
3
- `)}`})}return{noteId:t,conversationId:(await I(t,{projectId:e.projectId})).conversationId}}function Me(e,t,n){let r=new URLSearchParams({draft:n.replace(`{{id}}`,t),autoSend:`1`});return`/chat/${encodeURIComponent(e)}?${r}`}var H={meeting:S,requirements:O,research:Se,weekly:F};function Ne({projects:e,projectId:t,onProjectChange:n,onCreated:r,labels:i,projectsLoading:o,projectsError:s}){let c=i.home,l=a(),[u,f]=(0,z.useState)(``),[m,h]=(0,z.useState)(null),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)([]),[b,te]=(0,z.useState)(!1),[S,C]=(0,z.useState)(null),[w,ae]=(0,z.useState)(``),T=(0,z.useRef)(null),E=(0,z.useRef)(!1),D=(0,z.useRef)(null),O=(0,z.useRef)(null),k=b||!!T.current,A=m?c.templateOptions[m]:null,se=!!(u.trim()||v.length);async function ce(){if(!(E.current||!se&&!T.current)){E.current=!0,te(!0),C(null),T.current??={requestId:crypto.randomUUID(),title:u.trim().split(`
4
- `)[0]?.slice(0,80)||A?.label||i.titlePlaceholder,markdown:`## ${c.requestHeading}\n\n${A?`${A.prompt}\n`:``}${u.trim()}`,projectId:t||void 0,files:[...v],attachments:[],materialHeading:c.materialsHeading};try{let e=await je(T.current);r(),l(Me(e.conversationId,e.noteId,c.agentPrompt))}catch(e){T.current.note&&r(),C(e instanceof Error?e.message:i.quickCaptureFailedHint)}finally{E.current=!1,te(!1)}}}function j(){T.current=null,C(null),f(``),y([]),h(null),_(!1),O.current?.focus()}return(0,B.jsxs)(`section`,{"aria-label":c.askLabel,children:[(0,B.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ce()},className:`relative rounded-xl border border-edge bg-surface-panel p-4 focus-within:border-accent/60 sm:p-5`,children:[(0,B.jsxs)(`fieldset`,{disabled:k,className:`min-w-0`,children:[(0,B.jsxs)(`label`,{htmlFor:`notes-home-prompt`,className:`flex items-center gap-2 text-xs font-medium text-accent-fg`,children:[(0,B.jsx)(re,{className:`size-4`,"aria-hidden":!0}),c.askLabel]}),(0,B.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:c.agentResultHint}),A?(0,B.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft px-3 py-2 text-xs leading-5 text-accent-fg`,children:[(0,B.jsxs)(`p`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`font-medium`,children:[A.label,` · `]}),A.prompt.split(`
5
-
6
- `)[0]]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>h(null),"aria-label":i.searchClear,className:`shrink-0 rounded p-1 hover:bg-surface-hover`,children:(0,B.jsx)(d,{className:`size-3.5`})})]}):null,(0,B.jsx)(`textarea`,{ref:O,id:`notes-home-prompt`,value:u,onChange:e=>f(e.target.value),placeholder:A?A.prompt.split(`
7
-
8
- `).at(-1):c.askPlaceholder,rows:2,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),ce())},className:`mt-2 min-h-16 w-full resize-y bg-transparent py-2 text-base leading-6 text-fg outline-none placeholder:text-fg-muted sm:text-sm`}),v.length?(0,B.jsx)(`ul`,{className:`mb-3 flex flex-wrap gap-2`,children:v.map((e,t)=>(0,B.jsxs)(`li`,{className:`flex max-w-full items-center gap-2 rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:[(0,B.jsx)(x,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name}),(0,B.jsx)(`button`,{type:`button`,"aria-label":`${c.removeMaterial}: ${e.name}`,onClick:()=>y(e=>e.filter((e,n)=>n!==t)),className:`rounded p-1 hover:bg-surface-hover`,children:(0,B.jsx)(d,{className:`size-3`})})]},`${e.name}-${t}`))}):null,(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:pr-40`,children:[(0,B.jsx)(`div`,{className:`w-44 max-w-full`,children:(0,B.jsx)(De,{value:t,options:e.filter(e=>e.name.toLowerCase().includes(w.toLowerCase())).map(e=>({value:e.id,label:e.name})),selectedLabel:t?e.find(e=>e.id===t)?.name:c.unassigned,placeholder:c.unassigned,emptyLabel:c.unassigned,ariaLabel:c.assignProject,triggerIcon:(0,B.jsx)(oe,{className:`size-4 shrink-0`,"aria-hidden":!0}),triggerClassName:`h-8 border-transparent bg-transparent px-2 text-xs text-fg-muted hover:bg-surface-hover`,onChange:n,disabled:k,loading:o,statusMessage:s?c.projectsLoadFailed:void 0,searchPlaceholder:c.projectSearch,searchValue:w,onSearchChange:ae})}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>D.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover`,children:[(0,B.jsx)(x,{className:`size-4`,"aria-hidden":!0}),c.addMaterials]}),(0,B.jsx)(`input`,{ref:D,type:`file`,multiple:!0,className:`hidden`,"aria-label":c.addMaterials,onChange:e=>{let t=Array.from(e.target.files??[]);y(e=>[...e,...t]),e.target.value=``}})]})]}),(0,B.jsx)(`div`,{className:`mt-2 flex justify-end sm:absolute sm:bottom-5 sm:right-5 sm:mt-0`,children:(0,B.jsxs)(`button`,{type:`submit`,disabled:b||!T.current&&!se,className:`inline-flex h-9 items-center gap-2 rounded-lg bg-accent px-4 text-sm font-medium text-on-accent hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,children:[b?(0,B.jsx)(ie,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,B.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),b?c.creating:S?c.retry:c.agentCreate]})})]}),S?(0,B.jsxs)(`div`,{className:`mt-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-3 text-xs text-danger`,role:`alert`,children:[(0,B.jsx)(`p`,{children:S}),T.current?.note?(0,B.jsx)(`p`,{className:`mt-1`,children:c.partialFailure}):null,(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[T.current?.note?(0,B.jsx)(`button`,{type:`button`,onClick:()=>l(`/notes/${encodeURIComponent(T.current.note.id)}?edit=1`),className:`underline`,children:c.openSavedDraft}):null,(0,B.jsx)(`button`,{type:`button`,onClick:j,className:`underline`,children:c.newRequest})]})]}):null,(0,B.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:(0,B.jsxs)(`button`,{type:`button`,disabled:k,"aria-expanded":g,"aria-controls":`notes-home-templates`,onClick:()=>_(e=>!e),className:`touch-target inline-flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[c.templates,(0,B.jsx)(Ce,{className:p(`size-3.5 transition-transform`,g&&`rotate-180`),"aria-hidden":!0})]})}),(0,B.jsxs)(ee,{id:`notes-home-templates`,hidden:!g,className:p(`mt-1 flex-wrap items-center gap-1 text-xs text-fg-muted`,g?`flex`:`hidden`),role:`group`,"aria-label":c.templates,indicatorClassName:`rounded-md bg-accent-soft`,children:[Object.keys(H).map(e=>{let t=H[e];return(0,B.jsxs)(`button`,{type:`button`,disabled:k,"aria-pressed":m===e,onClick:()=>{h(m===e?null:e),O.current?.focus()},className:p(`inline-flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-surface-hover disabled:opacity-50`,m===e&&`bg-accent-soft text-accent-fg`),children:[(0,B.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),c.templateOptions[e].label]},e)}),(0,B.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted`,onClick:()=>window.dispatchEvent(new CustomEvent(`open-recording-recoveries`)),children:i.discussionCapture.recoveredTitle}),(0,B.jsx)(V,{})]})]})}function Pe(e,t){let n=Number(e.get(`page`)??0),r=Number.isSafeInteger(n)&&n>=0?n:0,i=e.get(`view`);return{projectId:e.get(`projectId`)||void 0,unassigned:e.get(`unassigned`)===`true`||i===`unassigned`||void 0,pinned:i===`favorites`?!0:void 0,agentEdited:i===`agent`||void 0,status:i===`archived`?`archived`:void 0,search:t.trim()||void 0,sortBy:`updatedAt`,sortOrder:`desc`,limit:12,offset:r*12}}function Fe(e){let t=e.snippet?.trim()??``,n=e.title?.trim();return n&&t.startsWith(n)?t.slice(n.length).replace(/^[\s::·—-]+/,``):t}function Ie(e,t,n){return e.kind===`voice`&&/^Discussion · \d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(e.title??``)?n:e.title?.trim()||Fe(e).slice(0,48)||t}var U=`touch-target inline-flex min-h-9 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`;function W(){let e=g(e=>e.language),t=f(e).notes,n=t.home,r=m(e=>e.conversationId),s=C(e=>e.setPageHeader),l=C(e=>e.clearPageHeader),d=a(),{pathname:ne,search:x}=i(),[w,k]=o(),j=w.get(`projectId`)||``,M=w.get(`view`)||`all`,N=w.get(`unassigned`)===`true`||M===`unassigned`,P=w.get(`search`)||``,[he]=pe(P,250),[_e,F]=(0,z.useState)(j),[ye,Se]=(0,z.useState)(``),[we,I]=(0,z.useState)(null),[L,R]=(0,z.useState)(!1),[V,je]=(0,z.useState)(!1),[Me,H]=(0,z.useState)(new Set),[W,G]=(0,z.useState)(null),[K,Le]=(0,z.useState)(null),q=(0,z.useRef)(new Set),J=(0,z.useRef)(null),Re=(0,z.useRef)(!1),ze=(0,z.useRef)(null),Be=Pe(w,he),Y=(Be.offset??0)/12,{data:Ve,error:He,isLoading:Ue,mutate:We}=_(r?[`notes-home`,r,Be]:null,()=>te(Be)),{data:Ge,error:Ke,isLoading:X,mutate:qe}=_(r?[`notes-home-projects`,r]:null,de),Z=Ge?.items??[],Je=Z.filter(e=>e.noteCount>0).slice(0,2),Ye=Z.find(e=>e.id===j)?.name??n.projectNotes,Xe=Ve?.items??[],Q=Ve?.total??0,Ze=Ue||P!==he,Qe=(0,z.useMemo)(()=>({justNow:t.justNow,minutesAgo:t.minutesAgo,today:t.today,yesterday:t.yesterday,daysAgo:t.daysAgo,locale:h(e)}),[e,t.justNow,t.minutesAgo,t.today,t.yesterday,t.daysAgo]),[$e,et]=(0,z.useState)(()=>Date.now());(0,z.useEffect)(()=>{F(j)},[j]),(0,z.useEffect)(()=>{let e=window.setInterval(()=>et(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let $=(0,z.useCallback)(()=>{We().catch(()=>void 0),qe().catch(()=>void 0)},[We,qe]);(0,z.useEffect)(()=>{let e=[`note-updated`,`note-created`,`note-deleted`,`project-updated`,`project-created`,`project-deleted`];return e.forEach(e=>window.addEventListener(e,$)),()=>e.forEach(e=>window.removeEventListener(e,$))},[$]);let tt=(0,z.useCallback)((e,t=!1)=>{let n=`${ne}${x}`,r=new URLSearchParams({returnTo:n});t&&r.set(`edit`,`1`),d(`/notes/${encodeURIComponent(e)}?${r}`)},[ne,x,d]),nt=(0,z.useCallback)(async()=>{if(!(Re.current||!r)){Re.current=!0,R(!0),I(null),J.current??={key:crypto.randomUUID(),projectId:j||void 0};try{let e=await me({markdown:``,kind:`thought`,projectId:J.current.projectId},J.current.key);J.current=null,$(),tt(e.id,!0)}catch(e){I(`${t.createBlankFailed}: ${e instanceof Error?e.message:t.createBlankFailedHint}`)}finally{Re.current=!1,R(!1)}}},[j,t.createBlankFailed,t.createBlankFailedHint,tt,$,r]),rt=(0,z.useCallback)(e=>{k(t=>{let n=new URLSearchParams(t);return e?n.set(`search`,e):n.delete(`search`),n.delete(`page`),n},{replace:!0})},[k]);function it(e,t=`all`){let n=new URLSearchParams;e&&n.set(`projectId`,e),t===`unassigned`?n.set(`unassigned`,`true`):t!==`all`&&n.set(`view`,t),F(e),k(n)}function at(e){k(t=>{let n=new URLSearchParams(t);return N&&n.set(`unassigned`,`true`),e===`all`?n.delete(`view`):n.set(`view`,e),n.delete(`page`),n})}async function ot(e,n){if(!q.current.has(e)){q.current.add(e),H(new Set(q.current)),I(null);try{await D(e,{pinned:n}),$()}catch(e){I(`${t.actionFailed}: ${e instanceof Error?e.message:t.quickCaptureFailedHint}`)}finally{q.current.delete(e),H(new Set(q.current))}}}async function st(){let e=W;if(!(!e||K)){G(null),Le(e.id),I(null);try{await be(e.id),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e.id}})),$()}catch(e){I(`${t.deleteFailed}: ${e instanceof Error?e.message:t.quickCaptureFailedHint}`)}finally{Le(null)}}}if((0,z.useLayoutEffect)(()=>{if(!r){l();return}return s({startExtra:null,main:(0,B.jsx)(`h1`,{className:`truncate text-base font-semibold text-fg`,children:t.title}),end:(0,B.jsx)(`div`,{className:p(`flex min-w-0 items-center gap-2`,b),children:(0,B.jsxs)(`label`,{className:`flex h-9 w-32 min-w-0 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-2 sm:w-48`,children:[(0,B.jsx)(ue,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,B.jsx)(`input`,{ref:ze,type:`search`,value:P,onChange:e=>rt(e.target.value),"aria-label":t.searchDialogTitle,placeholder:t.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`})]})})}),()=>l()},[l,nt,L,n.blankNote,t.searchDialogTitle,t.searchPlaceholder,t.title,P,s,rt,r]),(0,z.useEffect)(()=>{let e=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.isComposing||e.target?.closest(`input, textarea, [contenteditable="true"], [role="dialog"]`)||(e.key.toLowerCase()===`n`&&(e.preventDefault(),nt()),e.key.toLowerCase()===`f`&&(e.preventDefault(),ze.current?.focus()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[nt]),!r)return(0,B.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-sm text-fg-muted`,children:t.needToken});let ct=[{id:`all`,label:n.homeNav,Icon:T},{id:`favorites`,label:n.favorites,Icon:se},{id:`unassigned`,label:n.unassigned,Icon:ve},{id:`archived`,label:t.filterArchived,Icon:ae}],lt=j?`project:${j}`:N?`unassigned`:`all`,ut=!Ze&&!He&&Q===0&&!j&&!N&&!P&&M===`all`;return(0,B.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-panel`,children:[(0,B.jsxs)(`aside`,{className:`hidden w-44 shrink-0 flex-col gap-1 overflow-y-auto px-3 py-6 xl:flex`,"aria-label":n.homeNav,children:[ct.map(({id:e,label:t,Icon:n})=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>it(``,e),"aria-current":!j&&(e===`unassigned`?N:!N&&M===e)?`page`:void 0,className:p(U,`justify-start px-2 text-left text-xs`,!j&&(e===`unassigned`?N:!N&&M===e)&&`bg-surface-hover font-medium text-fg`),children:[(0,B.jsx)(n,{className:`size-4 shrink-0`,"aria-hidden":!0}),t]},e)),(0,B.jsx)(`span`,{className:`mb-1 mt-7 px-2 text-xs text-fg-muted`,children:n.projects}),X?[0,1,2].map(e=>(0,B.jsx)(A,{className:`mb-2 h-8 w-full`},e)):Z.slice(0,8).map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>it(e.id),"aria-current":j===e.id?`page`:void 0,className:p(U,`justify-start px-2 text-left text-xs`,j===e.id&&`bg-surface-hover font-medium text-fg`),children:[(0,B.jsx)(oe,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>d(`/projects`),className:p(U,`mt-2 justify-start px-2 text-xs`),children:[n.allProjects,(0,B.jsx)(ge,{className:`ml-auto size-3`,"aria-hidden":!0})]})]}),(0,B.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,B.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col px-4 pb-4 pt-3 sm:px-6 sm:pb-7 lg:px-8 lg:pb-9 lg:pt-4`,children:[(0,B.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`min-w-0 break-words text-2xl font-semibold tracking-tight text-fg`,children:j?Ye:N?n.unassigned:ut?n.firstNoteTitle:n.continueTitle}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:j?n.projectDescription:ut?n.firstNoteDescription:n.continueDescription})]}),j?(0,B.jsxs)(`button`,{type:`button`,onClick:()=>d(`/projects/${encodeURIComponent(j)}`),className:p(U,`text-xs`),children:[n.openProject,(0,B.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0})]}):null]}),we?(0,B.jsx)(`p`,{className:`mb-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:we}):null,(0,B.jsxs)(`section`,{"aria-label":n.startAction,children:[(0,B.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>void nt(),disabled:L,className:`touch-target flex min-h-20 items-center gap-3 rounded-xl border border-edge bg-surface-panel p-4 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[L?(0,B.jsx)(ie,{className:`size-5 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,B.jsx)(u,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:n.blankNote}),(0,B.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:n.blankActionHint})]})]}),(0,B.jsxs)(`button`,{type:`button`,"aria-label":n.recordAction,onClick:()=>v(j||void 0),className:`touch-target flex min-h-20 items-center gap-3 rounded-xl border border-edge bg-surface-panel p-4 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,B.jsx)(ke,{className:`size-5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:n.recordAction}),(0,B.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:n.recordActionHint})]})]})]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{je(e=>!e),V||window.requestAnimationFrame(()=>document.getElementById(`notes-home-prompt`)?.focus())},"aria-expanded":V,"aria-controls":`notes-home-agent-composer`,title:n.agentActionHint,className:`touch-target mt-2 inline-flex min-h-11 items-center gap-2 rounded-lg px-2 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,B.jsx)(re,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),n.agentAction,(0,B.jsx)(Ce,{className:p(`size-4 transition-transform`,V&&`rotate-180`),"aria-hidden":!0})]}),(0,B.jsx)(`div`,{id:`notes-home-agent-composer`,hidden:!V,className:p(`mt-3`,!V&&`hidden`),children:(0,B.jsx)(Ne,{projects:Z,projectId:_e,onProjectChange:F,onCreated:$,labels:t,projectsLoading:X,projectsError:!!Ke})})]}),Ke?(0,B.jsxs)(`div`,{role:`alert`,className:`mt-4 flex items-center gap-3 text-xs text-danger`,children:[(0,B.jsx)(`span`,{children:n.projectsLoadFailed}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void qe().catch(()=>void 0),className:`underline`,children:n.retry})]}):null,ut?null:(0,B.jsxs)(`section`,{className:`mt-8 pb-6`,"aria-label":n.recentNotes,children:[(0,B.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:M===`favorites`?n.favorites:M===`archived`?t.filterArchived:j?n.projectNotes:n.recentNotes}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-pressed":M===`agent`,onClick:()=>at(M===`agent`?`all`:`agent`),className:p(`touch-target rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,M===`agent`&&`bg-accent-soft text-accent-fg`),children:n.agentEdited}),(0,B.jsx)(`span`,{className:`hidden text-xs text-fg-muted xl:inline`,children:n.sortUpdated}),(0,B.jsx)(`div`,{className:`w-48 max-w-full xl:hidden`,children:(0,B.jsx)(De,{value:lt,allowEmpty:!1,ariaLabel:n.projects,placeholder:n.allNotes,options:[{value:`all`,label:n.allNotes},{value:`unassigned`,label:n.unassigned},...Z.filter(e=>e.name.toLowerCase().includes(ye.toLowerCase())).map(e=>({value:`project:${e.id}`,label:e.name}))],selectedLabel:j?Ye:N?n.unassigned:n.allNotes,triggerClassName:`h-8 bg-surface-panel text-xs`,loading:X,searchPlaceholder:n.projectSearch,searchValue:ye,onSearchChange:Se,onChange:e=>it(e.startsWith(`project:`)?e.slice(8):``,e===`unassigned`?e:`all`)})})]})]}),(0,B.jsxs)(ee,{className:`flex flex-wrap items-center gap-x-5 border-b border-edge xl:hidden`,"aria-label":t.libraryTitle,role:`group`,children:[[{id:`all`,label:t.filterAll},{id:`favorites`,label:n.favorites},{id:`archived`,label:t.filterArchived}].map(({id:e,label:t})=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":M===e||e===`all`&&M===`unassigned`,onClick:()=>at(e),className:p(`touch-target border-b-2 border-transparent py-3 text-xs text-fg-muted hover:text-fg`,(M===e||e===`all`&&M===`unassigned`)&&`border-fg font-medium text-fg`),children:t},e)),(0,B.jsx)(`span`,{className:`ml-auto py-3 text-xs text-fg-muted`,children:n.sortUpdated})]}),He?(0,B.jsxs)(`div`,{className:`py-10 text-center`,role:`alert`,children:[(0,B.jsx)(`p`,{className:`text-sm text-danger`,children:n.loadFailed}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void We().catch(()=>void 0),className:p(U,`mt-2`),children:n.retry})]}):Ze?(0,B.jsx)(`div`,{"aria-busy":`true`,className:`divide-y divide-edge`,children:[0,1,2,3].map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,B.jsx)(A,{className:`h-10 w-8 shrink-0`}),(0,B.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,B.jsx)(A,{className:`h-4 w-2/3`}),(0,B.jsx)(A,{className:`h-3 w-1/2`})]})]},e))}):Xe.length===0?(0,B.jsxs)(`div`,{className:`flex flex-col items-center px-4 py-12 text-center`,children:[(0,B.jsx)(T,{className:`mb-4 size-8 text-fg-muted`,strokeWidth:1.3,"aria-hidden":!0}),(0,B.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:P||M!==`all`&&M!==`unassigned`?n.noMatches:j?n.projectEmpty:n.emptyTitle}),(0,B.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:P||M!==`all`&&M!==`unassigned`?n.noMatchesHint:j?n.projectEmptyHint:n.emptyDescription})]}):(0,B.jsx)(`ul`,{className:`divide-y divide-edge`,children:Xe.map(e=>{let r=e.voiceAttachmentId||e.kind===`voice`?S:e.kind===`bookmark`?Oe:O,i=Ie(e,t.titlePlaceholder,n.voiceNote),a=Fe(e)||(e.coverAttachmentId?t.imageNote:t.noText);return(0,B.jsxs)(`li`,{className:`group flex min-w-0 items-center gap-3 py-4`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>tt(e.id),className:`touch-target flex min-w-0 flex-1 items-center gap-3 rounded-md text-left focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,B.jsx)(`span`,{className:`flex h-10 w-8 shrink-0 items-center justify-center rounded-md border border-edge text-fg-muted`,children:(0,B.jsx)(r,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block truncate text-base font-medium text-fg sm:text-sm group-hover:text-accent-fg`,children:i}),(0,B.jsxs)(`span`,{className:`mt-1 flex min-w-0 items-center gap-1.5 text-xs text-fg-muted`,children:[e.lastEditTrigger===`ai_edit`?(0,B.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-accent-fg`,children:[(0,B.jsx)(re,{className:`size-3`,"aria-hidden":!0}),n.agentEditLabel,(0,B.jsx)(`span`,{"aria-hidden":!0,children:`·`})]}):null,(0,B.jsx)(`span`,{className:`truncate`,children:a})]}),(0,B.jsx)(`time`,{dateTime:new Date(e.updatedAt).toISOString(),className:`mt-1.5 block text-xs text-fg-muted sm:hidden`,children:Ae(e.updatedAt,$e,Qe)})]})]}),(0,B.jsx)(`span`,{className:`hidden max-w-32 truncate text-xs text-fg-muted md:block`,title:e.projects?.map(e=>e.name).join(` · `),children:e.projects?.map(e=>e.name).join(` · `)||n.unassigned}),(0,B.jsx)(`time`,{dateTime:new Date(e.updatedAt).toISOString(),className:`hidden w-24 shrink-0 text-right text-xs text-fg-muted sm:block`,children:Ae(e.updatedAt,$e,Qe)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void ot(e.id,!e.pinned),disabled:Me.has(e.id),"aria-label":`${e.pinned?n.unfavorite:n.favorite}: ${i}`,"aria-pressed":!!e.pinned,className:`touch-target inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-accent`,children:(0,B.jsx)(se,{className:p(`size-4`,e.pinned&&`fill-current text-fg`),"aria-hidden":!0})}),(0,B.jsxs)(Te,{children:[(0,B.jsx)(le,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,disabled:K===e.id,"aria-label":`${t.noteActions}: ${i}`,className:`touch-target inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-accent`,children:K===e.id?(0,B.jsx)(ie,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,B.jsx)(c,{className:`size-4`,"aria-hidden":!0})})}),(0,B.jsx)(xe,{children:(0,B.jsx)(fe,{align:`end`,sideOffset:4,className:`z-50 min-w-36 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:(0,B.jsxs)(Ee,{className:`touch-target flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-danger-soft focus:bg-danger-soft`,onSelect:()=>G(e),children:[(0,B.jsx)(E,{className:`size-4`,"aria-hidden":!0}),t.delete]})})})]})]},e.id)})}),!Ze&&!He&&Q>0?(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 text-xs text-fg-muted`,"aria-live":`polite`,children:[(0,B.jsx)(`span`,{children:t.noteCount.replace(`{{count}}`,String(Q))}),Q>12||Y>0?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":n.previousPage,disabled:Y===0,className:U,onClick:()=>k(e=>{let t=new URLSearchParams(e);return t.set(`page`,String(Y-1)),t}),children:(0,B.jsx)(y,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsxs)(`span`,{children:[Y+1,` / `,Math.max(1,Math.ceil(Q/12))]}),(0,B.jsx)(`button`,{type:`button`,"aria-label":n.nextPage,disabled:(Y+1)*12>=Q,className:U,onClick:()=>k(e=>{let t=new URLSearchParams(e);return t.set(`page`,String(Y+1)),t}),children:(0,B.jsx)(ge,{className:`size-4`,"aria-hidden":!0})})]}):null]}):null]}),!j&&!N&&(X||Je.length>0)?(0,B.jsxs)(`section`,{className:`mt-8`,"aria-label":n.continueProjects,children:[(0,B.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.continueProjects}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>d(`/projects`),className:`text-xs text-fg-muted hover:text-fg`,children:n.allProjects})]}),(0,B.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:X?[0,1].map(e=>(0,B.jsx)(A,{className:`h-28 w-full`},e)):Je.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>it(e.id),className:`min-w-0 rounded-lg border border-edge bg-surface-panel p-3 text-left transition-colors sm:p-4 hover:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,B.jsx)(oe,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]}),e.description?(0,B.jsx)(`p`,{className:`mt-2 hidden line-clamp-1 text-xs text-fg-muted sm:block`,children:e.description}):null,(0,B.jsxs)(`span`,{className:`mt-2 flex flex-wrap items-center justify-between gap-1 text-xs text-fg-muted sm:mt-3`,children:[(0,B.jsx)(`span`,{children:t.noteCount.replace(`{{count}}`,String(e.noteCount))}),(0,B.jsx)(`span`,{children:e.updatedAt?Ae(e.updatedAt,$e,Qe):n.emptyProject})]})]},e.id))})]}):null]})}),(0,B.jsx)(ce,{open:W!==null,title:t.deleteConfirmTitle,description:t.deleteConfirmDescription.replace(`{{title}}`,W?.title||t.titlePlaceholder),confirmLabel:t.deleteConfirmLabel,cancelLabel:t.deleteCancelLabel,destructive:!0,onConfirm:()=>void st(),onCancel:()=>G(null)})]})}function G(){let e=(0,R.c)(12),{noteId:t}=s(),n=a(),[r]=o(),i;e[0]===r?i=e[1]:(i=l(r.get(`returnTo`),`/notes`,[`/chat`,`/personal`,`/projects`,`/notes`,`/tasks`]),e[0]=r,e[1]=i);let c=i,u;e[2]!==n||e[3]!==c?(u=()=>{n(c)},e[2]=n,e[3]=c,e[4]=u):u=e[4];let d=u;if(!t)return null;let f=r.get(`edit`)===`1`?`wysiwyg`:`preview`,p;e[5]===r?p=e[6]:(p=r.get(`edit`),e[5]=r,e[6]=p);let m=p===`1`,h;return e[7]!==d||e[8]!==t||e[9]!==f||e[10]!==m?(h=(0,B.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-6xl flex-1 flex-col`,children:(0,B.jsx)(L,{noteId:t,onBack:d,initialMode:f,autoFocus:m},t)}),e[7]=d,e[8]=t,e[9]=f,e[10]=m,e[11]=h):h=e[11],h}function K(){let e=(0,R.c)(2),{noteId:t}=s(),n;return e[0]===t?n=e[1]:(n=t?(0,B.jsx)(G,{}):(0,B.jsx)(W,{}),e[0]=t,e[1]=n),n}export{K as NotesPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{F as o}from"./markdown-view-CthsQiiO.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./messages-Bwv-AOYl.js";import{a as l,n as u,r as d}from"./locale-store-D5h-Ha6-.js";import{T as f,d as p,ot as m,t as h}from"./session-manager-BMEW_eS_.js";import{Af as g,Ao as _,Cs as v,Cu as y,Ds as b,Es as x,Go as S,Hs as C,J as w,Mi as T,Mo as E,Of as D,Qi as O,Rc as k,Ro as A,Ts as j,Wl as M,Y as N,Zu as P,ac as ee,et as te,kf as ne,kl as re,n as ie,nu as ae,qs as oe,rc as F,us as I,ws as L,xs as se,yu as R}from"./index-DdJ_djQt.js";import{l as z,n as ce,t as le}from"./voice-config-api-CRjdZdJF.js";var B=n(),V=e(t(),1),H=r();function ue(){try{return[`UTC`,...Intl.supportedValuesOf(`timeZone`)]}catch{return[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Seoul`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`Australia/Sydney`,`Pacific/Auckland`]}}var de=ue();function fe({zh:e}){let[t,n]=(0,V.useState)(),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(``),u=s.trim().toLowerCase().replaceAll(`_`,` `),f=[...new Set([...de,t?.timezone].filter(e=>!!e))].sort().filter(e=>e.replaceAll(`_`,` `).toLowerCase().includes(u)).map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.split(`/`)[0]}));(0,V.useEffect)(()=>{let e=!0;return l(d(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(m.parse(t.payload))}).catch(t=>{e&&i(String(t))}),()=>{e=!1}},[]);async function p(e){if(!(!t||a)){o(!0),i(``);try{let r=await l(d(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(m.parse(r.payload))}catch(e){i(String(e));let t=await l(d(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(m.parse(t.payload))}finally{o(!1)}}}return(0,H.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,H.jsx)(k,{className:`h-9 w-full`}):t&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(I,{placeholder:e?`选择主动方式`:`Choose participation`,value:t.mode,disabled:a,allowEmpty:!1,options:[{value:`off`,label:e?`关闭主动联系`:`Off`},{value:`follow_up`,label:e?`仅明确跟进`:`Requested follow-ups`},{value:`balanced`,label:e?`适度主动`:`Thoughtful participation`}],onChange:e=>void p({mode:e})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默开始`:`Quiet from`,(0,H.jsx)(I,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietStart),disabled:a,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void p({quietStart:Number(e)})})]}),(0,H.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默结束`:`Quiet until`,(0,H.jsx)(I,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietEnd),disabled:a,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void p({quietEnd:Number(e)})})]})]}),(0,H.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,H.jsx)(I,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:f,disabled:a,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:s,onSearchChange:c,statusMessage:f.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{c(``),e!==t.timezone&&p({timezone:e})}})]}),(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}var U=[`intro`,`identity`,`voice`,`connections`],pe=[{id:`loopi`,zh:`Loopi`,en:`Loopi`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`},{id:`loopi-care`,zh:`温和`,en:`Gentle`}];function me(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}async function he(e,t){let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await l(d(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),A(e)}function ge({modelsAvailable:e,onCreated:t}){let n=u(e=>e.language)===`zh`,r=u(e=>e.language),[o,s]=(0,V.useState)(`intro`),[f,p]=(0,V.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[m,h]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(null),[C,T]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[A,j]=(0,V.useState)(!0),[M,P]=(0,V.useState)([]),[ie,ae]=(0,V.useState)(null),I=(0,V.useRef)(null),L=(0,V.useRef)(null),[se,B]=(0,V.useState)([]),[ue,de]=(0,V.useState)(!0),[fe,ge]=(0,V.useState)([]),[_e,W]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=!1;return l(d(`/api/personal-agent/onboarding`)).then(t=>{e||(s(t.payload.step),p(t.payload.draft))}).catch(t=>{e||b(t instanceof Error?t.message:String(t))}).finally(()=>{e||h(!0)}),()=>{e=!0}},[]),(0,V.useEffect)(()=>{if(!m)return;let e=window.setTimeout(()=>{l(d(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:o,draft:f})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[f,m,o]),(0,V.useEffect)(()=>{let e=!1;return le().then(t=>{e||(t.tts&&t.enabled?O({provider:t.tts.provider,model:t.tts.model,enabled:!0}):j(!1))}).catch(()=>{e||j(!1)}),()=>{e=!0}},[]),(0,V.useEffect)(()=>{if(!D?.enabled)return;let e=!1;return ce(D.provider,D.model,`realtime`).then(t=>{e||P(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||j(!1)}),()=>{e=!0}},[D]),(0,V.useEffect)(()=>{if(o!==`connections`)return;let e=!1;return de(!0),Promise.allSettled([F({page:1,pageSize:24,verification:`verified`}),ee()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];B(t.value.connectors.filter(t=>t.runtime.type===`composio`&&e.includes(t.runtime.toolkit)).sort((t,n)=>e.indexOf(t.runtime.type===`composio`?t.runtime.toolkit:``)-e.indexOf(n.runtime.type===`composio`?n.runtime.toolkit:``)))}n.status===`fulfilled`&&ge(n.value),de(!1)}}),()=>{e=!0}},[o]),(0,V.useEffect)(()=>()=>{L.current?.abort(),I.current?.close()},[]),(0,V.useEffect)(()=>()=>{C&&URL.revokeObjectURL(C)},[C]);let ve=async(e,t=f)=>{await l(d(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),s(e)},G=async e=>{b(null);let t=U[Math.max(0,Math.min(U.length-1,U.indexOf(o)+e))];try{await ve(t)}catch(e){b(e instanceof Error?e.message:String(e))}},ye=async(n=!1)=>{if(!(!e||_)){v(!0),b(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:f,r=e.voice&&D?.enabled&&M.some(t=>t.id===e.voice)?{provider:D.provider,model:D.model,voice:e.voice}:void 0,i=(await l(d(`/api/personal-agent`),{method:`POST`,body:JSON.stringify({displayName:e.displayName.trim()||`Ada`,appearance:e.appearance,...r?{voicePreference:r}:{}})})).payload,a=!1;if(!n&&x)try{await he(i.agentId,x),i=(await l(d(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:i.revision,displayName:i.displayName,appearance:`custom`,preferences:i.preferences})})).payload}catch{a=!0}t(i,a)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}}},be=(0,V.useCallback)(async e=>{L.current?.abort(),I.current?.close();let t=new AbortController;L.current=t,ae(e),b(null);try{let n=new oe;I.current=n,await n.start();let r=await z(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>ae(null))}catch(e){t.signal.aborted||b(e instanceof Error?e.message:String(e)),ae(null)}},[]);if(!m)return(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,H.jsx)(k,{className:`h-10 w-2/3`}),(0,H.jsx)(k,{className:`h-64 w-full rounded-2xl`}),(0,H.jsx)(k,{className:`h-12 w-full rounded-xl`})]});let K=U.indexOf(o),xe={intro:n?`创建一个和你一起做事的助手`:`Create an assistant to work with you`,identity:n?`先给它一个形象和名字`:`Choose a look and a name`,voice:n?`想让我用什么声音回应?`:`How should your assistant sound?`,connections:n?`要让我了解哪些信息?`:`What information can your assistant use?`}[o];return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,H.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,H.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[K>0?(0,H.jsxs)(`button`,{type:`button`,disabled:_,onClick:()=>void G(-1),className:`-ml-2 inline-flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:[(0,H.jsx)(g,{className:`size-4`}),n?`上一步`:`Back`]}):(0,H.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,H.jsx)(i,{to:`/chat`,className:`-mr-2 inline-flex min-h-10 items-center rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`稍后继续`:`Finish later`})]}),(0,H.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":K+1,"aria-valuemin":1,"aria-valuemax":U.length,children:U.map((e,t)=>(0,H.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=K?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,H.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,H.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,H.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,H.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:C?(0,H.jsx)(`img`,{src:C,alt:``,className:`size-14 rounded-xl object-cover`}):(0,H.jsx)(E,{appearance:f.appearance,className:`size-14`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,H.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:f.displayName||`Ada`})]})]}),(0,H.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${K+1} 步 · 共 ${U.length} 步`:`Step ${K+1} of ${U.length}`}),(0,H.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:xe}),o===`intro`&&(0,H.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,H.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,H.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,H.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),o===`identity`&&(0,H.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,H.jsx)(`input`,{value:f.displayName,maxLength:60,onChange:e=>p(t=>({...t,displayName:e.target.value})),onBlur:()=>p(e=>({...e,displayName:e.displayName.trim()||`Ada`})),className:`mt-2 block w-full rounded-xl border border-edge bg-surface-panel px-4 py-3 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[pe.map(e=>(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":!x&&f.appearance===e.id,onClick:()=>{S(null),T(null),p(t=>({...t,appearance:e.id}))},className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${!x&&f.appearance===e.id?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,H.jsx)(E,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,H.jsxs)(`label`,{className:`flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-within:ring-2 focus-within:ring-accent ${x?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,H.jsx)(re,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,H.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];if(t){if(t.size>512*1024||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){b(n?`请选择不超过 512 KB 的 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image under 512 KB.`);return}S(t),T(URL.createObjectURL(t))}}})]})]}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n?`自定义图片在创建助手时上传;刷新后需要重新选择。`:`Custom images upload when you create the assistant; select again after a refresh.`})]})]}),o===`voice`&&(0,H.jsxs)(`div`,{className:`mt-5`,children:[(0,H.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`用于这个助手的语音通话;文字回答不受影响。试听不会使用麦克风。`:`This affects calls with this assistant. Text stays the same. Preview does not use your microphone.`}),A?(0,H.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(k,{className:`h-20 rounded-xl`}),(0,H.jsx)(k,{className:`h-20 rounded-xl`})]}):D?.enabled&&M.length>0?(0,H.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(`button`,{type:`button`,"aria-pressed":!f.voice,onClick:()=>p(e=>({...e,voice:null})),className:`rounded-xl p-4 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${f.voice?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:n?`使用默认声音`:`Use the default voice`}),M.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${f.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-pressed":f.voice===e.id,onClick:()=>p(t=>({...t,voice:e.id})),children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,H.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void be(e.id),className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`试听${e.name}`:`Preview ${e.name}`,children:(0,H.jsx)(R,{className:`size-4 ${ie===e.id?`text-accent`:``}`})})]},e.id))]}):(0,H.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,H.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,H.jsx)(i,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),o===`connections`&&(0,H.jsxs)(`div`,{className:`mt-5`,children:[(0,H.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`现在连接,或进入对话后再添加。连接不会自动读取历史数据或创建持续关注。`:`Connect now or add sources later. Connecting does not automatically scan history or create ongoing monitoring.`}),ue?(0,H.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,H.jsx)(k,{className:`h-18 rounded-xl`}),(0,H.jsx)(k,{className:`h-18 rounded-xl`})]}):(0,H.jsx)(`div`,{className:`mt-5 space-y-2`,children:se.length?se.map(e=>{let t=me(fe.find(t=>t.connectorId===e.id));return(0,H.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,H.jsx)(te,{connector:e,size:`sm`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,H.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,H.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,H.jsx)(a,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,H.jsx)(`button`,{type:`button`,onClick:()=>W(w(e)),className:`rounded-lg bg-surface-hover px-3 py-2 text-xs text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`连接`:`Connect`})]},e.id)}):(0,H.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:n?`暂无可用的推荐服务;你仍可直接进入对话。`:`No suggested services are available. You can continue to chat.`})})]}),!e&&(0,H.jsxs)(`p`,{className:`mt-5 rounded-xl bg-warning/5 p-4 text-sm text-fg-muted`,children:[n?`开始前需要一个可用模型。`:`A compatible model is required before you start.`,` `,(0,H.jsx)(i,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),y&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:y})]},o)}),(0,H.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,H.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[o===`intro`&&(0,H.jsx)(`button`,{type:`button`,disabled:!e||_,onClick:()=>void ye(!0),className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:n?`用默认设置开始`:`Use defaults`}),o===`voice`&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>{let e={...f,voice:null};p(e),b(null),ve(`connections`,e).catch(e=>b(e instanceof Error?e.message:String(e)))},className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`跳过`:`Skip`}),(0,H.jsxs)(`button`,{type:`button`,disabled:_||o===`connections`&&!e,onClick:()=>o===`connections`?void ye():void G(1),className:`flex min-h-11 items-center gap-2 rounded-xl bg-accent px-5 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:opacity-40`,children:[_?n?`正在创建…`:`Creating…`:o===`connections`?n?`进入对话`:`Start chatting`:n?`继续`:`Continue`,` `,!_&&(0,H.jsx)(ne,{className:`size-4`})]})]})]})}),_e&&(0,H.jsx)(N,{draft:_e,onChange:W,onClose:()=>W(null),t:c(r).connectorsSettings,onInstalled:async()=>{ge(await ee()),W(null)}})]})}function _e({record:e,zh:t,onSelectVoice:n,onGreetingChange:r}){let[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(!0),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(e.voicePreference?.voice??``),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(null),C=(0,V.useRef)(null),w=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await le();if(e||(o(t.openingGreeting===!0),!t.enabled||!t.tts))return;let n={provider:t.tts.provider,model:t.tts.model};f(n);let r=await ce(n.provider,n.model,`realtime`);e||m(r)}catch(t){e||b(t instanceof Error?t.message:String(t))}finally{e||c(!1)}})(),()=>{e=!0}},[]),(0,V.useEffect)(()=>()=>{w.current?.abort(),C.current?.close()},[]);let T=()=>{w.current?.abort(),w.current=null,C.current?.close(),C.current=null,S(null)},E=async e=>{if(x!==null){T();return}T(),b(null);let n=new AbortController;w.current=n,S(e);try{let t=new oe;C.current=t,await t.start();let r=await z(n.signal,e);n.signal.aborted||t.enqueue(r,()=>{w.current===n&&(S(null),w.current=null,C.current=null,t.close())})}catch(e){if(!n.signal.aborted){let n=e?.body?.error?.code;b(t&&n===`unsupported_voice`?`当前音色暂不可用,请刷新语音目录或选择其他音色。`:e instanceof Error?e.message:String(e))}w.current===n&&T()}},D=async e=>{if(_||e===h)return;T();let t=h;g(e),u(``),v(!0),b(null);try{await n(e&&d?{provider:d.provider,model:d.model,voice:e}:null)||g(t)}catch(e){g(t),b(e instanceof Error?e.message:String(e))}finally{v(!1)}},O=p.find(e=>e.id===h),A=t?`默认声音`:`Default voice`,j=O?.name||(h?t?`当前音色不可用`:`Current voice unavailable`:A),N=l.trim().toLocaleLowerCase(),P=p.filter(e=>!N||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(N)).map(e=>({value:e.id,label:e.name}));return(0,H.jsxs)(`section`,{className:`border-t border-edge pt-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:t?`通话声音`:`Call voice`}),s?(0,H.jsx)(`div`,{className:`mt-3`,"aria-busy":`true`,children:(0,H.jsx)(k,{className:`h-10 w-full`})}):d&&p.length?(0,H.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,H.jsx)(I,{value:h,selectedLabel:j,options:P,placeholder:A,emptyLabel:A,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:_,onChange:e=>void D(e),searchPlaceholder:p.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:l,onSearchChange:u,statusMessage:N&&!P.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,H.jsxs)(`button`,{type:`button`,disabled:_||!!(h&&!O),onClick:()=>void E(h),className:`touch-target flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-edge px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,title:x===null?t?`试听${j}`:`Preview ${j}`:t?`停止试听`:`Stop preview`,"aria-label":x===null?t?`试听${j}`:`Preview ${j}`:t?`停止试听`:`Stop preview`,children:[x===null?(0,H.jsx)(R,{className:`size-4`,"aria-hidden":!0}):(0,H.jsx)(M,{className:`size-4 text-accent`,"aria-hidden":!0}),x===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(0,H.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:O?.description||O?.style||(h?t?`选择后自动保存,用于之后的语音通话。`:`Saved automatically for future voice calls.`:t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,H.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,(0,H.jsx)(i,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),r&&a&&(0,H.jsxs)(`label`,{className:`mt-4 flex items-center justify-between gap-3 text-sm text-fg`,children:[t?`连接时打招呼`:`Greet me when connected`,(0,H.jsx)(`input`,{type:`checkbox`,checked:e.voiceCallPreferences?.openingGreetingEnabled??!0,disabled:_,onChange:e=>{let t=e.target.checked;v(!0),r(t).catch(e=>b(String(e))).finally(()=>v(!1))}})]}),y&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:y})]})}var W=new h;function ve({conversationId:e,zh:t,onSaved:n}){let r=f(t=>t.sessions[e]),[i,a]=(0,V.useState)(!0),[o,s]=(0,V.useState)(``);(0,V.useEffect)(()=>{let t=!0;return W.loadSessionAgentConfig(e).then(n=>{t&&p(e,n)}).catch(e=>{t&&s(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let l=!!r?.modelConfigSaving;async function u(t,i){f.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{p(e,await W.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await W.loadSessionAgentConfig(e).catch(()=>null);throw n&&p(e,n),t}finally{f.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型与思考强度`:`Conversation model and thinking`}),i?(0,H.jsx)(k,{className:`h-9 w-full`}):(0,H.jsx)(O,{chat:c(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:l,thinkingDisabled:l,onModelChange:u,onThinkingChange:e=>u(r?.model??``,e)}),o&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:o})]})}var G=5;function ye(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=58)return t;let n=t.replace(/([^)]{1,80})|\([^)]{1,80}\)/g,``).replace(/([A-Za-z0-9])(?=[\u4e00-\u9fff])/g,`$1 `).replace(/\s+/g,` `).trim(),r=n.split(/[。!?;;,]/,1)[0]?.trim()||n;return r.length>58?`${r.slice(0,57).trimEnd()}…`:r}function be(e,t){if(e.phase===`closed`)return{label:t?`已结束`:`Finished`,tone:`bg-fg-subtle`};let n=e.operationalState??e.runStatus;return n===`running`?{label:t?`正在执行`:`Working`,tone:`bg-accent`}:n===`queued`?{label:t?`等待开始`:`Queued`,tone:`bg-fg-subtle`}:n===`failed`?{label:t?`执行失败`:`Failed`,tone:`bg-danger`}:n===`waiting`?{label:t?`等待继续`:`Waiting`,tone:`bg-warning`}:n===`blocked`?{label:t?`已阻塞`:`Blocked`,tone:`bg-warning`}:n===`verifying`?{label:t?`正在验证`:`Verifying`,tone:`bg-accent`}:n===`cancelled`?{label:t?`执行已取消`:`Cancelled`,tone:`bg-fg-subtle`}:e.phase===`review`?{label:t?`等待验收`:`In review`,tone:`bg-warning`}:e.phase===`active`?{label:t?`正在推进`:`In progress`,tone:`bg-accent`}:e.phase===`ready`?{label:t?`准备开始`:`Ready`,tone:`bg-fg-subtle`}:{label:t?`待处理`:`Planned`,tone:`bg-fg-subtle`}}function K(e){let t=(0,B.c)(30),{item:n,zh:r}=e,a;t[0]!==n||t[1]!==r?(a=be(n,r),t[0]=n,t[1]=r,t[2]=a):a=t[2];let s=a,c;t[3]===n.id?c=t[4]:(c=o(`/personal`,n.id),t[3]=n.id,t[4]=c);let l=`mt-2 size-1.5 shrink-0 rounded-full ${s.tone}`,u;t[5]===l?u=t[6]:(u=(0,H.jsx)(`span`,{className:l,"aria-hidden":!0}),t[5]=l,t[6]=u);let d;t[7]===n.title?d=t[8]:(d=ye(n.title),t[7]=n.title,t[8]=d);let f;t[9]===d?f=t[10]:(f=(0,H.jsx)(`span`,{className:`line-clamp-2 break-words text-sm font-medium leading-5 text-fg`,children:d}),t[9]=d,t[10]=f);let p;t[11]===s.label?p=t[12]:(p=(0,H.jsx)(`span`,{children:s.label}),t[11]=s.label,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,H.jsx)(`span`,{className:`text-fg-subtle`,"aria-hidden":!0,children:`·`}),t[13]=m):m=t[13];let h=r?`zh`:`en`,g;t[14]!==n.updatedAt||t[15]!==h?(g=T(n.updatedAt,h),t[14]=n.updatedAt,t[15]=h,t[16]=g):g=t[16];let _;t[17]===g?_=t[18]:(_=(0,H.jsx)(`span`,{children:g}),t[17]=g,t[18]=_);let v;t[19]!==_||t[20]!==p?(v=(0,H.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,_]}),t[19]=_,t[20]=p,t[21]=v):v=t[21];let y;t[22]!==v||t[23]!==f?(y=(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,v]}),t[22]=v,t[23]=f,t[24]=y):y=t[24];let b;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,H.jsx)(D,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0}),t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==c||t[28]!==u?(x=(0,H.jsxs)(i,{to:c,className:`group flex min-w-0 items-start gap-3 rounded-2xl bg-surface-panel px-4 py-4 transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,y,b]}),t[26]=y,t[27]=c,t[28]=u,t[29]=x):x=t[29],x}var xe=[{id:`direct`,warmth:`reserved`,zh:`直接`,en:`Direct`},{id:`natural`,warmth:`balanced`,zh:`自然`,en:`Natural`},{id:`gentle`,warmth:`gentle`,zh:`温和`,en:`Gentle`}],Se=[{id:`loopi`,zh:`Loopi`,en:`Loopi`,color:`bg-slate-100/50 dark:bg-slate-400/10`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`,color:`bg-blue-100/50 dark:bg-blue-400/10`},{id:`loopi-care`,zh:`温和`,en:`Gentle`,color:`bg-violet-100/50 dark:bg-violet-400/10`}];function Ce(e,t){return e.warmth===`reserved`?t?`你可以直接说目标或问题。我会先给结论,需要时再展开。`:`Tell me the goal or question. I’ll lead with the answer and expand when useful.`:e.warmth===`gentle`?t?`想聊一件事,或让我帮你推进工作,都可以从这里开始。我会认真听,也会把下一步说清楚。`:`You can talk something through or ask me to move work forward. I’ll listen carefully and make the next step clear.`:t?`有什么想讨论或推进的事?直接告诉我就好。`:`What would you like to discuss or move forward? Just tell me what is on your mind.`}function we(e){return xe.find(t=>t.warmth===e.warmth)?.id??`natural`}function Te(){let e=C(),t=(0,V.useRef)(e);t.current=e;let n=u(e=>e.language)===`zh`,r=S(e=>e.setPageHeader),i=S(e=>e.clearPageHeader),[a,o]=(0,V.useState)(null),c=(0,V.useRef)(null),f=(0,V.useRef)(Promise.resolve()),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(!0),[w,T]=(0,V.useState)(0),[D,O]=(0,V.useState)(null),[M,N]=(0,V.useState)(!0),[ee,te]=(0,V.useState)(!1),[ne,oe]=(0,V.useState)(`natural`),[F,R]=(0,V.useState)(`loopi`),[z,ce]=(0,V.useState)(!1),le=(0,V.useRef)(null),B=(0,V.useRef)(null),ue=(0,V.useRef)(null),[de,U]=(0,V.useState)(``),[pe,me]=(0,V.useState)(`untangle`),[he,W]=(0,V.useState)(`none`),[ye,be]=(0,V.useState)(`balanced`),[Te,Ee]=(0,V.useState)(`decisions`),[De,Oe]=(0,V.useState)(!1),[ke,q]=(0,V.useState)(!1),[J,Ae]=(0,V.useState)(!1),[Y,je]=(0,V.useState)(null),[Me,Ne]=(0,V.useState)(!1),[X,Pe]=(0,V.useState)(!1),[Fe,Ie]=(0,V.useState)(!1),[Z,Le]=(0,V.useState)(0),Q=(0,V.useRef)(0),Re=(0,V.useCallback)(()=>{Ae(!1),q(!1),Oe(!0)},[]),ze=(0,V.useCallback)(()=>{Ae(!1),q(!1),Oe(e=>!e)},[]),Be=(0,V.useCallback)(async()=>{try{let[e,t]=await Promise.all([l(d(`/api/personal-agent`)),l(d(`/api/personal-agent/models`))]);if(c.current=e.payload,o(e.payload),e.payload?.state===`ready`){let e=await l(d(`/api/personal-agent/onboarding`));N(!e.payload.completed||e.payload.welcomeDone)}window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e.payload})),e.payload&&window.dispatchEvent(new Event(`session-updated`)),m(t.payload),e.payload&&(U(e.payload.displayName),R(e.payload.appearance),oe(we(e.payload.preferences)),me(e.payload.preferences.supportMode??`untangle`),W(e.payload.preferences.humor??`none`),be(e.payload.preferences.detailLevel??`balanced`),Ee(e.payload.preferences.proactivity??`decisions`))}catch(e){O(e instanceof Error?e.message:String(e))}finally{g(!1)}},[]);(0,V.useEffect)(()=>{Be()},[Be]);let $=(0,V.useCallback)(e=>{T(e=>e+1),O(null);let t=f.current.then(async()=>{let t=c.current;if(!t)return!1;let n=e.displayName?.trim()||t.displayName,r=e.appearance??t.appearance,i={...t.preferences,...e.preferences},a=e.voicePreference===void 0?t.voicePreference:e.voicePreference;if(n===t.displayName&&r===t.appearance&&JSON.stringify(i)===JSON.stringify(t.preferences)&&JSON.stringify(a)===JSON.stringify(t.voicePreference)&&(!e.voiceCallPreferences||JSON.stringify(e.voiceCallPreferences)===JSON.stringify(t.voiceCallPreferences)))return!0;try{let s=await l(d(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:t.revision,displayName:n,appearance:r,preferences:i,...e.voicePreference===void 0?{}:{voicePreference:a},...e.voiceCallPreferences?{voiceCallPreferences:e.voiceCallPreferences}:{}})});return c.current=s.payload,o(s.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:s.payload})),!0}catch(e){return O(e instanceof Error?e.message:String(e)),!1}}).finally(()=>T(e=>e-1));return f.current=t,t},[]),Ve=async e=>{if(a){O(null);try{if(e){let t=await l(d(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:a.revision,displayName:a.displayName,appearance:a.appearance,preferences:{...a.preferences,supportMode:e}})});c.current=t.payload,o(t.payload)}await l(d(`/api/personal-agent/onboarding/welcome`),{method:`POST`,body:`{}`}),N(!0)}catch(e){O(e instanceof Error?e.message:String(e))}}},He=(0,V.useCallback)(async()=>{let e=++Q.current;Ae(!0),je(null),Ne(!1),Pe(!1),Ie(!1),Le(0);try{let t=await l(d(`/api/personal-agent/activity?limit=${G}&offset=0`));if(e!==Q.current)return;je(t.payload),Le(t.payload.items.length)}catch{e===Q.current&&Ne(!0)}},[]),Ue=(0,V.useCallback)(async()=>{if(!Y||X||Z>=Y.total)return;let e=Q.current;Pe(!0),Ie(!1);try{let t=await l(d(`/api/personal-agent/activity?limit=${G}&offset=${Z}`));if(e!==Q.current)return;je(e=>e?{total:t.payload.total,items:[...e.items,...t.payload.items.filter(t=>!e.items.some(e=>e.id===t.id))]}:t.payload),Le(e=>e+t.payload.items.length)}catch{e===Q.current&&Ie(!0)}finally{e===Q.current&&Pe(!1)}},[Y,Z,X]);(0,V.useEffect)(()=>{if(!J||!Y||X)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(async()=>{let e=Q.current;try{let t=await l(d(`/api/personal-agent/activity?limit=${Math.max(G,Math.min(100,Z))}&offset=0`));if(e!==Q.current)return;je(t.payload),Le(t.payload.items.length)}catch{}},120)},n=window.setInterval(t,5e3);return window.addEventListener(`task-changed-v2`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.clearTimeout(e),window.clearInterval(n),window.removeEventListener(`task-changed-v2`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[Y,Z,X,J]);let We=async e=>{if(!a||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type)){O(n?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(e.size===0||e.size>512*1024){O(n?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}ce(!0),O(null);try{let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)});await l(d(`/api/agents/${encodeURIComponent(a.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:t.slice(t.indexOf(`,`)+1),mimeType:e.type})}),A(a.agentId),R(`custom`),q(!1),await $({appearance:`custom`})}catch(e){O(e instanceof Error?e.message:String(e))}finally{ce(!1)}};(0,V.useLayoutEffect)(()=>{let o=a?.state===`ready`,c=o?a.appearance:F,l=o?a.displayName:`Ada`;return r({startExtra:null,main:(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[o?(0,H.jsx)(`button`,{ref:ue,type:`button`,onClick:ze,"aria-expanded":De,className:`touch-target -m-1 shrink-0 rounded-full p-1 transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`编辑${l}的资料`:`Edit ${l}'s profile`,title:n?`资料`:`Profile`,children:(0,H.jsx)(`span`,{className:`flex size-8 items-center justify-center`,children:(0,H.jsx)(E,{appearance:c,agentId:a?.agentId,className:`size-8`})})}):(0,H.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center`,children:(0,H.jsx)(E,{appearance:c,agentId:a?.agentId,className:`size-8`})}),(0,H.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-semibold text-fg sm:text-base`,children:l})]}),end:o?(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:e.active,onClick:()=>{a?.state===`ready`&&t.current.open({conversationId:a.conversationId,name:a.displayName,mode:`assistant`})},className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,"aria-label":n?`语音通话`:`Voice call`,title:n?`语音通话`:`Voice call`,children:(0,H.jsx)(y,{className:`size-5`})}),(0,H.jsxs)(x,{open:J,onOpenChange:e=>{e?He():Ae(!1)},children:[(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,"aria-pressed":J,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`正在做的事`:`Activity`,children:(0,H.jsx)(P,{className:`size-5`})})}),(0,H.jsx)(j,{children:(0,H.jsxs)(L,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`派发的任务`:`Delegated tasks`,className:`z-50 flex h-[min(34rem,calc(100dvh-6rem))] w-[min(25rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl focus:outline-none`,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 px-6 pb-3 pt-6`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n?`交给我推进的事`:`Delegated work`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Y?n?`最近更新 · 共 ${Y.total} 项`:`Recently updated · ${Y.total} total`:n?`查看任务进展与结果`:`Follow progress and results`})]}),(0,H.jsx)(v,{className:`touch-target -mr-2 -mt-1 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`关闭活动`:`Close activity`,children:(0,H.jsx)(s,{className:`size-4`})})]}),(0,H.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-5 pt-3`,children:[!Y&&!Me&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(k,{className:`h-18 rounded-2xl`}),(0,H.jsx)(k,{className:`h-18 rounded-2xl`}),(0,H.jsx)(k,{className:`h-18 rounded-2xl`})]}),Me&&(0,H.jsxs)(`div`,{className:`px-5 py-12 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法读取任务`:`Could not load tasks`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void He(),className:`mt-3 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:n?`重试`:`Try again`})]}),Y?.items.length===0&&(0,H.jsxs)(`div`,{className:`px-5 py-16 text-center`,children:[(0,H.jsx)(P,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,H.jsx)(`p`,{className:`mt-4 text-sm font-medium text-fg`,children:n?`还没有派发的任务`:`No delegated work yet`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`你可以在对话里直接告诉我想推进的事。`:`Tell me what you would like to move forward in chat.`})]}),Y&&Y.items.length>0&&(0,H.jsx)(`div`,{className:`space-y-2`,children:Y.items.map(e=>(0,H.jsx)(K,{item:e,zh:n},e.id))}),Y&&Z<Y.total&&(0,H.jsxs)(`div`,{className:`pt-4 text-center`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>void Ue(),disabled:X,className:`min-h-10 rounded-xl bg-surface-panel px-5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,children:X?n?`正在加载…`:`Loading…`:n?`加载更多`:`Load more`}),Fe&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:n?`加载失败,请重试`:`Could not load more. Try again.`})]})]})]})})]}),(0,H.jsx)(`button`,{ref:B,type:`button`,onClick:ze,"aria-expanded":De,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`回应偏好`:`Response preferences`,children:(0,H.jsx)(ae,{className:`size-5`})})]}):null}),()=>i()},[Y,Me,Z,X,Fe,F,i,Ue,He,a,r,J,De,ze,e.active,n]);function Ge(){return a?(0,H.jsxs)(x,{open:De,onOpenChange:e=>{Oe(e),e||q(!1)},children:[(0,H.jsx)(se,{virtualRef:B}),(0,H.jsx)(j,{children:(0,H.jsxs)(L,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`编辑 Personal AI`:`Edit Personal AI`,onInteractOutside:e=>{e.target instanceof Node&&(B.current?.contains(e.target)||ue.current?.contains(e.target))&&e.preventDefault()},className:`z-50 flex h-[min(38rem,calc(100dvh-6rem))] w-[min(28rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl outline-none`,children:[(0,H.jsxs)(`div`,{className:`relative flex shrink-0 flex-col items-center px-5 pt-5 text-center`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:z,onClick:()=>q(e=>!e),"aria-expanded":ke,"aria-controls":`personal-appearance-options`,"aria-label":n?`选择头像`:`Choose avatar`,className:`rounded-full transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,H.jsx)(E,{appearance:F,agentId:a.agentId,className:`size-20`})}),(0,H.jsx)(`input`,{id:`personal-name`,"aria-label":n?`助手名称`:`Assistant name`,value:de,onChange:e=>U(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(U(t),$({displayName:t})):U(c.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=c.current?.displayName??``,U(e.currentTarget.value),e.currentTarget.blur())},maxLength:60,placeholder:`Ada`,className:`mt-3 w-full min-w-0 rounded-lg border border-transparent bg-transparent px-2 py-1 text-center text-lg font-semibold text-fg outline-none transition-colors hover:border-edge focus:border-edge focus:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`}),w>0&&(0,H.jsx)(`span`,{className:`absolute right-4 top-4 text-xs text-fg-muted`,children:n?`正在保存…`:`Saving…`})]}),(0,H.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto overscroll-contain px-5 py-5`,children:[D&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:D}),ke&&(0,H.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`形象`:`Appearance`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[Se.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{R(e.id),q(!1),$({appearance:e.id})},"aria-pressed":F===e.id,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${F===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,H.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${e.color}`,children:(0,H.jsx)(E,{appearance:e.id,className:`size-8`})}),(0,H.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:n?e.zh:e.en})]},e.id)),(0,H.jsx)(`input`,{ref:le,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`sr-only`,"aria-label":n?`上传头像`:`Upload avatar`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&We(t),e.currentTarget.value=``}}),(0,H.jsxs)(`button`,{type:`button`,disabled:z,onClick:()=>le.current?.click(),"aria-pressed":F===`custom`,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${F===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,H.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:F===`custom`?(0,H.jsx)(E,{appearance:`custom`,agentId:a.agentId,className:`size-8`}):(0,H.jsx)(re,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,H.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:z?n?`上传中…`:`Uploading…`:n?`上传`:`Upload`})]})]})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`语气`:`Tone`}),(0,H.jsx)(_,{className:`grid grid-cols-3 gap-2`,role:`group`,"aria-label":n?`语气`:`Tone`,indicatorClassName:`rounded-xl bg-accent/10 ring-1 ring-accent/40`,children:xe.map(e=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>{oe(e.id),$({preferences:{warmth:e.warmth}})},"aria-pressed":ne===e.id,className:`min-h-10 rounded-xl px-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${ne===e.id?`bg-accent/10 font-medium text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:n?e.zh:e.en},e.id))})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`棘手时`:`When things get tricky`}),(0,H.jsx)(_,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":n?`棘手时`:`When things get tricky`,indicatorClassName:`rounded-full bg-accent/10 ring-1 ring-accent/40`,children:[[`listen`,n?`先听`:`Listen`],[`untangle`,n?`理清`:`Untangle`],[`solutions`,n?`给办法`:`Suggest`]].map(([e,t])=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":pe===e,onClick:()=>{me(e),$({preferences:{supportMode:e}})},className:`min-h-9 rounded-full px-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${pe===e?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:t},e))})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`回答长度`:`Length`}),(0,H.jsx)(I,{value:ye??`balanced`,options:[{value:`brief`,label:n?`简短`:`Brief`},{value:`balanced`,label:n?`适中`:`Balanced`},{value:`detailed`,label:n?`详细`:`Detailed`}],placeholder:n?`选择长度`:`Choose length`,allowEmpty:!1,onChange:e=>{let t=e;be(t),$({preferences:{detailLevel:t}})}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`主动更新`:`Updates`}),(0,H.jsx)(I,{value:Te??`decisions`,options:[{value:`decisions`,label:n?`结果与决定`:`Results only`},{value:`important`,label:n?`重要进展`:`Milestones`},{value:`open`,label:n?`多提建议`:`Suggestions`}],placeholder:n?`选择频率`:`Choose frequency`,allowEmpty:!1,onChange:e=>{let t=e;Ee(t),$({preferences:{proactivity:t}})}})]})]}),(0,H.jsxs)(`details`,{className:`text-sm text-fg-muted`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer select-none`,children:n?`更多偏好`:`More preferences`}),(0,H.jsxs)(`div`,{className:`mt-3`,children:[(0,H.jsx)(`p`,{className:`mb-2 font-medium text-fg`,children:n?`轻松程度`:`Humor`}),(0,H.jsx)(I,{value:he??`none`,options:[{value:`none`,label:n?`不加玩笑`:`None`},{value:`occasional`,label:n?`偶尔轻松`:`Sometimes`},{value:`playful`,label:n?`活泼`:`Playful`}],placeholder:n?`选择程度`:`Choose level`,allowEmpty:!1,onChange:e=>{let t=e;W(t),$({preferences:{humor:t}})}})]})]}),(0,H.jsx)(fe,{zh:n}),(0,H.jsx)(_e,{onGreetingChange:e=>$({voiceCallPreferences:{openingGreetingEnabled:e}}),record:a,zh:n,onSelectVoice:e=>$({voicePreference:e})}),(0,H.jsx)(`div`,{className:`border-t border-edge pt-5`,children:(0,H.jsx)(ve,{conversationId:a.conversationId,zh:n,onSaved:async()=>{let e=await l(d(`/api/personal-agent`));e.ok&&e.payload&&(c.current=e.payload,o(e.payload))}})})]})]})})]}):null}return h?(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,H.jsx)(k,{className:`h-20 w-20 rounded-full`}),(0,H.jsx)(k,{className:`h-9 w-72`}),(0,H.jsx)(k,{className:`h-44 w-full rounded-2xl`})]}):a?.state===`ready`?(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[ee&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-center justify-between gap-3 border-b border-warning/30 bg-warning/5 px-5 py-3 text-sm text-fg-muted`,children:[(0,H.jsx)(`span`,{children:n?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{te(!1),Re()},className:`shrink-0 text-accent hover:underline`,children:n?`打开设置`:`Open settings`})]}),(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,H.jsx)(ie,{embedded:!0,personal:!0,personalWelcome:{name:a.displayName,addressAs:a.userCallName??void 0,avatar:(0,H.jsx)(E,{appearance:a.appearance,agentId:a.agentId,className:`size-14`}),opening:Ce(a.preferences,n),showSupportChoice:!M,onChooseSupport:e=>void Ve(e),onSkipSupport:()=>void Ve(),supportChoiceError:D},conversationId:a.conversationId})})}),Ge()]}):(0,H.jsx)(ge,{modelsAvailable:p.length>0,onCreated:(e,t)=>{c.current=e,o(e),U(e.displayName),N(!1),te(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{Te as PersonalPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./x-B_N4OPjy.js";import{a as o,n as s,r as c}from"./locale-store-D5h-Ha6-.js";import{a as l,i as u,n as d,o as ee,r as te,s as ne,t as re}from"./dist-BGTk37IG.js";import{a as ie,i as ae}from"./vendor-swr-BIWyz7Rc.js";import{Au as oe,Kc as f,Rc as p}from"./index-DdJ_djQt.js";import{n as se}from"./capability-links-DzQWK1Fh.js";import{t as ce}from"./capability-icon-DVoZxEgW.js";import{a as le,i as m,n as h,t as g}from"./plugin-presentation-BfVM-8kL.js";var _=n(),v=e(t(),1),y=r();function b(e){let t=(0,_.c)(61),{pluginId:n,initialConnect:r,onClose:b}=e,x=r===void 0?!1:r,S=s(ue).startsWith(`zh`),{mutate:C}=ie(),[w,T]=(0,v.useState)(!1),E=(0,v.useRef)(document.activeElement instanceof HTMLElement?document.activeElement:null),D;t[0]===n?D=t[1]:(D=async()=>{let e=await o(c(`/api/extensions/agent-plugins/${encodeURIComponent(n)}`));if(!e.ok)throw Error(e.error??`Plugin not found`);return e.payload},t[0]=n,t[1]=D);let O;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(O={revalidateOnFocus:!0},t[2]=O):O=t[2];let{data:k,error:A,mutate:j}=ae(`plugin-details:${n}`,D,O),M=k?h(k,S):S?`插件详情`:`Plugin details`,N=k?.localizations?.[S?`zh-CN`:`en`]?.description??k?.description;if(w&&k){let e;t[3]!==j||t[4]!==T?(e=()=>{T(!1),j()},t[3]=j,t[4]=T,t[5]=e):e=t[5];let n;return t[6]!==k||t[7]!==b||t[8]!==e?(n=(0,y.jsx)(m,{extension:k,onUninstalled:b,onClose:e}),t[6]=k,t[7]=b,t[8]=e,t[9]=n):n=t[9],n}let P;t[10]===b?P=t[11]:(P=e=>{e||b()},t[10]=b,t[11]=P);let F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,y.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[12]=F):F=t[12];let I;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>{E.current?.isConnected&&(e.preventDefault(),E.current.focus({preventScroll:!0}))},t[13]=I):I=t[13];let L=k?.branding?.iconUrl,R;t[14]===L?R=t[15]:(R=(0,y.jsx)(ce,{iconUrl:L,fallback:oe}),t[14]=L,t[15]=R);let z;t[16]===M?z=t[17]:(z=(0,y.jsx)(ne,{className:`truncate text-base font-semibold text-fg`,children:M}),t[16]=M,t[17]=z);let B;t[18]===k?B=t[19]:(B=k?(0,y.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[k.version,` · `,k.name]}):null,t[18]=k,t[19]=B);let V;t[20]!==B||t[21]!==z?(V=(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[z,B]}),t[20]=B,t[21]=z,t[22]=V):V=t[22];let H=S?`关闭插件详情`:`Close plugin details`,U;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,y.jsx)(a,{className:`size-5`,"aria-hidden":!0}),t[23]=U):U=t[23];let W;t[24]===H?W=t[25]:(W=(0,y.jsx)(d,{asChild:!0,children:(0,y.jsx)(f,{variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":H,children:U})}),t[24]=H,t[25]=W);let G;t[26]!==V||t[27]!==W||t[28]!==R?(G=(0,y.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-edge px-5 py-4`,children:[R,V,W]}),t[26]=V,t[27]=W,t[28]=R,t[29]=G):G=t[29];let K=S?`查看插件能力、管理账号连接与授权。关闭后返回原来的列表。`:`View plugin capabilities and manage account connections. Close to return to the list.`,q;t[30]===K?q=t[31]:(q=(0,y.jsx)(u,{className:`sr-only`,children:K}),t[30]=K,t[31]=q);let J;t[32]!==k||t[33]!==N||t[34]!==A||t[35]!==x||t[36]!==C||t[37]!==b||t[38]!==n||t[39]!==j||t[40]!==S?(J=(0,y.jsx)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:A?(0,y.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:String(A)}):k?(0,y.jsxs)(y.Fragment,{children:[N?(0,y.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:N}):null,(0,y.jsx)(le,{initialConnect:x,extension:k,zh:S,onChanged:async()=>{await j(),await C(`gateway-extensions-list`)}},n),k.components?.skills.length?(0,y.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,y.jsx)(`h3`,{className:`text-sm font-medium`,children:S?`技能(${k.components.skills.length})`:`Skills (${k.components.skills.length})`}),(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.components.skills.map(e=>(0,y.jsx)(i,{onClick:b,to:`/capabilities/skills?${new URLSearchParams({tab:`installed`,source:`plugin`,q:k.dialect===`portable`?e.name:`${n}.${e.name}`})}`,className:`max-w-full break-words rounded-lg border border-edge px-3 py-2 text-sm text-accent hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:e.name},e.name))})]}):null]}):(0,y.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,y.jsx)(p,{className:`h-14 w-full`}),(0,y.jsx)(p,{className:`h-28 w-full`}),(0,y.jsx)(p,{className:`h-40 w-full`})]})}),t[32]=k,t[33]=N,t[34]=A,t[35]=x,t[36]=C,t[37]=b,t[38]=n,t[39]=j,t[40]=S,t[41]=J):J=t[41];let Y;t[42]!==k||t[43]!==T||t[44]!==S?(Y=k?(0,y.jsx)(f,{variant:`ghost`,onClick:()=>T(!0),children:S?`管理插件`:`Manage plugin`}):(0,y.jsx)(`span`,{}),t[42]=k,t[43]=T,t[44]=S,t[45]=Y):Y=t[45];let X;t[46]!==k||t[47]!==M||t[48]!==S?(X=k&&g(k)?(0,y.jsx)(f,{asChild:!0,children:(0,y.jsx)(i,{to:se(M,S),children:S?`开始使用`:`Start using`})}):(0,y.jsx)(d,{asChild:!0,children:(0,y.jsx)(f,{variant:`secondary`,children:S?`完成`:`Done`})}),t[46]=k,t[47]=M,t[48]=S,t[49]=X):X=t[49];let Z;t[50]!==Y||t[51]!==X?(Z=(0,y.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge px-5 py-4`,children:[Y,X]}),t[50]=Y,t[51]=X,t[52]=Z):Z=t[52];let Q;t[53]!==G||t[54]!==q||t[55]!==J||t[56]!==Z?(Q=(0,y.jsxs)(ee,{children:[F,(0,y.jsxs)(te,{onCloseAutoFocus:I,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] flex h-[min(38rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:[G,q,J,Z]})]}),t[53]=G,t[54]=q,t[55]=J,t[56]=Z,t[57]=Q):Q=t[57];let $;return t[58]!==Q||t[59]!==P?($=(0,y.jsx)(re,{open:!0,onOpenChange:P,children:Q}),t[58]=Q,t[59]=P,t[60]=$):$=t[60],$}function ue(e){return e.language}export{b as PluginDetailsDialog};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,t as o}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as ee}from"./circle-check-C23XjkUj.js";import{t as s}from"./folder-open-CyzJ19I9.js";import{t as c}from"./messages-Bwv-AOYl.js";import{t as l}from"./cn-0WouolD0.js";import{a as u,n as te,r as d}from"./locale-store-D5h-Ha6-.js";import{a as f,i as p,o as m,r as ne,s as re,t as h}from"./dist-BGTk37IG.js";import{a as g}from"./vendor-swr-BIWyz7Rc.js";import{$a as ie,$l as _,Af as v,Au as y,Ju as ae,Kc as b,Rc as oe,Rd as x,kl as S,nf as C,pf as w,uf as T}from"./index-DdJ_djQt.js";import{t as se}from"./capability-links-DzQWK1Fh.js";import{t as E}from"./capability-icon-DVoZxEgW.js";import{t as D}from"./browser-BLJWD7WI.js";var ce=n(),O=e(D(),1),k=e(t(),1),A=r();function j(e){let t=(0,ce.c)(6),{fields:n,values:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Object.entries(n),t[0]=n,t[1]=a);let o;return t[2]!==i||t[3]!==a||t[4]!==r?(o=(0,A.jsx)(A.Fragment,{children:a.map(e=>{let[t,n]=e;return(0,A.jsxs)(`label`,{className:`block space-y-1.5 text-sm`,children:[(0,A.jsxs)(`span`,{children:[n.title,n.required?` *`:``]}),n.type===`boolean`?(0,A.jsx)(`input`,{type:`checkbox`,checked:r[t]===!0,onChange:e=>i({...r,[t]:e.target.checked})}):(0,A.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,type:n.sensitive?`password`:n.type===`number`?`number`:`text`,required:n.required,autoComplete:`off`,value:String(r[t]??``),onChange:e=>i({...r,[t]:n.type===`number`?Number(e.target.value):e.target.value})})]},t)})}),t[2]=i,t[3]=a,t[4]=r,t[5]=o):o=t[5],o}function M(e){let t=(0,ce.c)(62),{account:n,fields:r,zh:i,busy:a,attempt:o,initialMethod:ee,onBack:s,onConnect:c,onSave:l,onRedirect:u,onSkip:te}=e,[d,f]=(0,k.useState)(ee&&n.methods.some(e=>e.id===ee)?ee:n.methods[0]?.id??``),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={},t[0]=p):p=t[0];let[m,ne]=(0,k.useState)(p),[re,h]=(0,k.useState)(``),[g,ie]=(0,k.useState)(),_;t[1]===d?_=t[2]:(_=e=>e.id===d,t[1]=d,t[2]=_);let y=n.methods.find(_),x;t[3]===i?x=t[4]:(x=(e,t)=>i?e:t,t[3]=i,t[4]=x);let S=x,C=o?.challenge?.type===`qr`?o.challenge.url:void 0,w,T;t[5]===C?(w=t[6],T=t[7]):(w=()=>{let e=!1;return ie(void 0),C&&O.toDataURL(C,{width:240,margin:2}).then(t=>{e||ie(t)}).catch(P),()=>{e=!0}},T=[C],t[5]=C,t[6]=w,t[7]=T),(0,k.useEffect)(w,T);let se;t[8]===o?se=t[9]:(se=o&&![`cancelled`,`error`,`connected`].includes(o.state),t[8]=o,t[9]=se);let E=se,D=o?.authorizationUrl??o?.challenge?.url,M=`连接 ${n.title}`,F=`Connect ${n.title}`,I;t[10]!==S||t[11]!==M||t[12]!==F?(I=S(M,F),t[10]=S,t[11]=M,t[12]=F,t[13]=I):I=t[13];let L;t[14]===S?L=t[15]:(L=S(`返回插件详情`,`Back to plugin details`),t[14]=S,t[15]=L);let R;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,A.jsx)(v,{className:`size-4`}),t[16]=R):R=t[16];let z;t[17]!==s||t[18]!==L?(z=(0,A.jsx)(b,{variant:`ghost`,className:`shrink-0`,onClick:s,"aria-label":L,children:R}),t[17]=s,t[18]=L,t[19]=z):z=t[19];let B;t[20]===S?B=t[21]:(B=S(`连接 `,`Connect `),t[20]=S,t[21]=B);let V;t[22]!==n.title||t[23]!==B?(V=(0,A.jsxs)(`h3`,{className:`text-base font-semibold`,children:[B,n.title]}),t[22]=n.title,t[23]=B,t[24]=V):V=t[24];let H;t[25]!==n.description||t[26]!==S?(H=n.description??S(`完成授权后自动检查连接。也可以稍后在详情页继续。`,`The connection is checked after authorization. You can also continue later in plugin details.`),t[25]=n.description,t[26]=S,t[27]=H):H=t[27];let U;t[28]===H?U=t[29]:(U=(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:H}),t[28]=H,t[29]=U);let W;t[30]!==V||t[31]!==U?(W=(0,A.jsxs)(`div`,{children:[V,U]}),t[30]=V,t[31]=U,t[32]=W):W=t[32];let G;t[33]!==z||t[34]!==W?(G=(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[z,W]}),t[33]=z,t[34]=W,t[35]=G):G=t[35];let K;t[36]!==n.methods||t[37]!==E||t[38]!==a||t[39]!==d||t[40]!==S?(K=n.methods.length>1?(0,A.jsx)(`div`,{role:`tablist`,"aria-label":S(`授权方式`,`Authorization methods`),className:`flex flex-wrap gap-2 rounded-lg bg-surface-inset p-1.5`,children:n.methods.map(e=>(0,A.jsx)(`button`,{role:`tab`,type:`button`,"aria-selected":d===e.id,className:`min-h-10 rounded-md px-3 text-sm ${d===e.id?`bg-surface-panel font-medium text-fg`:`text-fg-muted`}`,disabled:a||!!E,onClick:()=>{f(e.id),ne({})},children:e.title},e.id))}):null,t[36]=n.methods,t[37]=E,t[38]=a,t[39]=d,t[40]=S,t[41]=K):K=t[41];let q=y?.instructions?.length||y?.helpUrl?(0,A.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[y.instructions?.length?(0,A.jsx)(`ol`,{className:`list-decimal space-y-2 pl-5`,children:y.instructions.map(N)}):null,y.helpUrl?(0,A.jsx)(`a`,{className:`text-accent underline`,href:y.helpUrl,target:`_blank`,rel:`noopener noreferrer`,children:S(`打开官方配置说明`,`Open setup instructions`)}):null]}):null,J=(y?.type===`form`||y?.fields?.length)&&!E?(0,A.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),l(y.id,m)},children:[(0,A.jsx)(j,{fields:Object.fromEntries((y.fields??[]).filter(e=>r[e]).map(e=>[e,{...r[e],required:!0}])),values:m,onChange:ne}),(0,A.jsxs)(b,{type:`submit`,disabled:a||!y.fields?.every(e=>m[e]!==void 0&&m[e]!==``),children:[a?(0,A.jsx)(ae,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,S(`保存并连接`,`Save and connect`)]})]}):(0,A.jsxs)(`div`,{className:`space-y-4`,children:[E?null:(0,A.jsx)(b,{disabled:a,onClick:()=>c(d),children:S(`连接账号`,`Connect account`)}),E?(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:o.challenge?.message??(o.state===`preparing`?S(`正在准备登录…`,`Preparing sign-in…`):S(`请完成登录,返回后会自动继续。`,`Finish signing in. Installation continues automatically.`))}):null,C&&E?g?(0,A.jsx)(`img`,{src:g,alt:S(`使用 ${n.title} 扫码授权`,`Scan to authorize ${n.title}`),className:`mx-auto size-60 max-w-full rounded-lg`}):(0,A.jsx)(oe,{className:`mx-auto size-60`}):null,D&&E?(0,A.jsx)(`a`,{href:D,target:`_blank`,rel:`noopener noreferrer`,className:`inline-block text-sm text-accent underline`,children:C?S(`也可以打开授权页面`,`Or open the authorization page`):S(`打开登录页面`,`Open sign-in page`)}):null,o?.expiresAt&&E?(0,A.jsxs)(`p`,{className:`text-center text-xs text-fg-muted`,children:[S(`本次授权有效期至 `,`This sign-in expires at `),new Date(o.expiresAt).toLocaleTimeString()]}):null,o?.error?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:o.error}):null,o?.acceptsRedirect&&E?(0,A.jsxs)(`details`,{className:`text-sm`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:S(`登录后没有自动返回?`,`Did sign-in not return automatically?`)}),(0,A.jsxs)(`form`,{className:`mt-3 space-y-3`,onSubmit:e=>{e.preventDefault(),u(re)},children:[(0,A.jsxs)(`label`,{children:[S(`登录回调地址`,`Sign-in callback URL`),(0,A.jsx)(`input`,{value:re,onChange:e=>h(e.target.value),className:`mt-1 w-full rounded-lg border border-edge bg-surface-inset p-2`})]}),(0,A.jsx)(b,{type:`submit`,disabled:a||!re,children:S(`继续登录`,`Continue sign-in`)})]})]}):null]}),Y;t[42]===S?Y=t[43]:(Y=S(`暂时跳过`,`Skip for now`),t[42]=S,t[43]=Y);let X;t[44]!==a||t[45]!==te||t[46]!==Y?(X=(0,A.jsx)(b,{variant:`secondary`,disabled:a,onClick:te,children:Y}),t[44]=a,t[45]=te,t[46]=Y,t[47]=X):X=t[47];let Z;t[48]===S?Z=t[49]:(Z=S(`相关功能暂不可用,可随时在插件详情中授权。`,`Features requiring this account stay unavailable. Connect later in plugin details.`),t[48]=S,t[49]=Z);let le;t[50]===Z?le=t[51]:(le=(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:Z}),t[50]=Z,t[51]=le);let ue;t[52]!==X||t[53]!==le?(ue=(0,A.jsxs)(`div`,{className:`border-t border-edge pt-4`,children:[X,le]}),t[52]=X,t[53]=le,t[54]=ue):ue=t[54];let Q;return t[55]!==I||t[56]!==G||t[57]!==K||t[58]!==q||t[59]!==J||t[60]!==ue?(Q=(0,A.jsxs)(`section`,{className:`space-y-5`,"aria-label":I,children:[G,K,q,J,ue]}),t[55]=I,t[56]=G,t[57]=K,t[58]=q,t[59]=J,t[60]=ue,t[61]=Q):Q=t[61],Q}function N(e,t){return(0,A.jsx)(`li`,{children:e},t)}function P(){}async function F(e,t=`GET`,n){let r=await u(d(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}});if(!r.ok)throw Error(r.error??`Request failed`);return r.payload}function I({extension:e,zh:t,onChanged:n,onStart:r,onInstalled:i,initialConnect:a=!1}){let s=`/api/extensions/agent-plugins/${encodeURIComponent(e.pluginId)}`,[c,l]=(0,k.useState)(),[u,te]=(0,k.useState)({}),[d,f]=(0,k.useState)(!1),[p,m]=(0,k.useState)(``),[ne,re]=(0,k.useState)({}),[h,g]=(0,k.useState)(null),[ie,_]=(0,k.useState)(``),[v,y]=(0,k.useState)(null),[x,S]=(0,k.useState)(!1),w=(0,k.useRef)(new Set),se=(0,k.useRef)(new Set),E=(0,k.useRef)(void 0),D=(0,k.useRef)(null),ce=(0,k.useRef)(new Set),O=(e,n)=>t?e:n,N=e.setup?.authorizations??[],P=new Set(N.flatMap(e=>e.servers)),I=[...N,...(c?.connections??[]).filter(t=>!P.has(t.name)&&(e.components?.mcp.find(e=>e.name===t.name)?.type!==`stdio`||t.state===`token_required`)).map(t=>{let n=t.state===`token_required`||e.components?.mcp.find(e=>e.name===t.name)?.connectionAuth?.mode===`api-key`;return{id:t.name,title:t.name,servers:[t.name],methods:[{id:n?`api-key`:`oauth`,title:n?O(`访问令牌`,`Access token`):O(`浏览器登录`,`Browser sign-in`),type:n?`form`:`oauth`,...n?{fields:[`__apiKey`]}:{server:t.name}}]}})],L=e=>e.servers.every(e=>c?.connections.find(t=>t.name===e)?.state===`connected`)&&(!N.some(t=>t.id===e.id)||c?.authorizations?.find(t=>t.id===e.id)?.state===`connected`),R=(c?.authorizations??[]).flatMap(e=>(e.issues??[]).map(t=>({...t,account:I.find(t=>t.id===e.id)}))),z=I.filter(e=>!L(e)),B=c?.installed||c?.state===`completed`,V=e.setup?.userConfig??{},H=new Set(N.flatMap(e=>e.methods.flatMap(e=>e.fields??[]))),U=Object.fromEntries(Object.entries(V).filter(([e])=>!H.has(e))),W=c?.error===`Connection verification failed. Check the credentials or login status and try again.`?O(`连接验证未通过,请检查凭据或登录状态后重试。`,c.error):c?.error,G=Object.fromEntries(Object.entries(V).filter(([e])=>c?.missingConfig?.includes(e))),K=d||c?.state===`running`,q=I.find(e=>e.id===v);(0,k.useEffect)(()=>{let e=!1;return F(`${s}/setup`).then(t=>{e||l(t)}).catch(t=>{e||(l(null),m(String(t)))}),()=>{e=!0}},[s]),(0,k.useEffect)(()=>{if(c?.state!==`running`)return;let e=!1,t=!1,r=setInterval(()=>{t||(t=!0,F(`${s}/setup`).then(t=>{e||(l(t),t?.state!==`running`&&n())}).catch(t=>{e||m(String(t))}).finally(()=>{t=!1}))},750);return()=>{e=!0,clearInterval(r)}},[s,c?.state]),(0,k.useEffect)(()=>{if(!c||!c.connections.some(e=>[`oauth_required`,`error`].includes(e.state)))return;let e=!1;return F(`${s}/setup/reusable`).then(t=>{e||re(t)}).catch(()=>{e||re({})}),()=>{e=!0}},[s,c?.revision]),(0,k.useEffect)(()=>{if(!ie||c?.state===`completed`)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await F(`${s}/setup/auth/${encodeURIComponent(ie)}`);e||g(t)}catch(t){e||m(String(t))}finally{t=!1}}};n();let r=setInterval(()=>void n(),1500),i=()=>void n();return window.addEventListener(`focus`,i),()=>{e=!0,clearInterval(r),window.removeEventListener(`focus`,i)}},[s,ie,c?.state]),(0,k.useEffect)(()=>{let e=h?.authorizationUrl??(h?.challenge?.type===`url`?h.challenge.url:void 0);if(!h)return;if(h.error||[`cancelled`,`error`,`connected`].includes(h.state)){D.current?.close(),D.current=null;return}if(!e){h.challenge?.type===`qr`&&(D.current?.close(),D.current=null);return}let t=`${h.id}:${e}`;if(ce.current.has(t))return;ce.current.add(t);let n=D.current;D.current=null,n&&!n.closed?n.location.replace(e):window.open(e,`_blank`,`noopener,noreferrer`)},[h]);async function J(e,t={},r=c?.revision){f(!0),m(``);try{let a=await F(`${s}/setup`,`POST`,{action:e,expectedRevision:r,...e===`start`?{}:{idempotencyKey:crypto.randomUUID()},...t}),o=e===`configure`&&N.find(e=>e.id===t.authorization)?.methods.some(e=>e.id===t.method&&e.type===`cli`);return([`reuse`,`start`].includes(e)||e===`configure`&&!o)&&(te({}),S(!1),a=await F(`${s}/setup`,`POST`,{action:`prepare`,expectedRevision:a.revision,idempotencyKey:crypto.randomUUID()})),l(a),await n(),[`complete`,`defer`].includes(e)&&(y(null),g(null),_(``),D.current?.close(),D.current=null,i?.()),a}catch(e){m(e instanceof Error?e.message:String(e));try{l(await F(`${s}/setup`))}catch{}return null}finally{f(!1)}}(0,k.useEffect)(()=>{if(!c||K||p||[`cancelled`,`running`,`failed`].includes(c.state)||c.state===`completed`)return;let e,t=``;if(c.state===`pending`?(e=`prepare`,t=`prepare:${s}:${c.revision}`):h?.state===`connected`&&(e=`prepare`,t=`auth:${s}:${h.id}`),e&&!w.current.has(t)){w.current.add(t),J(e);return}c.resources===`ready`&&!c.missingConfig?.length&&!c.partial&&c.connections.every(e=>e.state===`connected`)&&(c.authorizations??[]).every(e=>e.state===`connected`)&&(t=`complete:${s}:${c.revision}`,w.current.has(t)||(w.current.add(t),J(`complete`)))},[c,h,K,p,s]),(0,k.useEffect)(()=>{K||!c||c.state===`cancelled`||(q&&c.revision!==E.current&&L(q)?(y(null),g(null),_(``)):(!B||a)&&c.resources===`ready`&&(!c.missingConfig?.length||a&&!c.missingConfig.some(e=>e in U))&&!v&&z[0]&&!se.current.has(z[0].id)&&(se.current.add(z[0].id),E.current=c.revision,y(z[0].id)))},[c,K,B,v,a]);function Y(e,t){let n=e.methods.find(e=>e.id===t),r=n?.type===`oauth`||n?.type===`cli`?window.open(`about:blank`,`_blank`):null;r&&(r.opener=null),D.current=r,g(null),J(`authorize`,{server:e.id,...N.some(t=>t.id===e.id)?{method:t}:{}}).then(t=>{t?_(e.id):(r?.close(),D.current=null)})}async function X(t,n,r){if(n===`api-key`&&!N.some(e=>e.id===t.id)){f(!0),m(``);try{let n=e.components?.mcp.find(e=>e.name===t.id);await F(`${s}/mcp/${encodeURIComponent(t.id)}/auth`,`PUT`,{mode:`api-key`,secrets:[{target:n.type===`stdio`?`env`:`headers`,key:n.connectionAuth?.headerName??(n.type===`stdio`?`API_KEY`:`Authorization`),prefix:n.connectionAuth?.prefix??(n.type===`stdio`?``:`Bearer `),value:r.__apiKey}]});let i=await F(`${s}/setup`);l(i),f(!1),await J(`prepare`,{},i.revision);return}catch(e){m(String(e)),f(!1);return}f(!1)}else if(t.methods.find(e=>e.id===n)?.type===`cli`){let e=window.open(`about:blank`,`_blank`);e&&(e.opener=null),D.current=e,g(null);let i=await J(`configure`,{authorization:t.id,method:n,values:r},c?.revision);i&&await J(`authorize`,{server:t.id,method:n},i.revision)?_(t.id):(e?.close(),D.current=null)}else await J(`configure`,{authorization:t.id,method:n,values:r})}if(c===void 0)return(0,A.jsx)(oe,{className:`h-40 w-full`});let Z=()=>{J(`defer`)};return q?(0,A.jsxs)(`div`,{className:`space-y-3`,children:[(0,A.jsx)(M,{initialMethod:c?.authorizations?.find(e=>e.id===q.id)?.method,account:q,fields:{...V,__apiKey:{type:`string`,title:O(`访问令牌`,`Access token`),required:!0,sensitive:!0}},zh:t,busy:K,attempt:h,onBack:()=>y(null),onConnect:e=>Y(q,e),onSave:(e,t)=>void X(q,e,t),onRedirect:e=>{f(!0),F(`${s}/setup/auth/${encodeURIComponent(ie)}/redirect`,`POST`,{url:e}).catch(e=>m(String(e))).finally(()=>f(!1))},onSkip:Z},`${q.id}:${c?.authorizations?.find(e=>e.id===q.id)?.method??``}`),ne[q.id]?.map(e=>(0,A.jsxs)(b,{disabled:K,variant:`secondary`,onClick:()=>void J(`reuse`,{server:q.id,sourceServerId:e.id}),children:[O(`使用已登录账号:`,`Use signed-in account: `),e.name]},e.id)),p||W&&q.servers.some(e=>c?.connections.find(t=>t.name===e)?.state===`error`)?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:p||W}):null]}):(0,A.jsxs)(`section`,{className:`space-y-5`,"aria-label":O(`插件安装与授权`,`Plugin setup`),children:[B?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`font-medium`,children:O(`安装完成`,`Installation complete`)}),(0,A.jsx)(`p`,{role:`status`,className:`mt-1 text-sm text-fg-muted`,children:e.activationEligible===!1?O(`插件已停用。`,`Plugin is disabled.`):c?.partial||z.length||R.length||c?.missingConfig?.length?O(`插件已安装,部分功能仍需要授权。`,`Plugin installed. Some features still need authorization.`):O(`所有 Agent 均可使用。可在 Agent 设置中单独调整。`,`Available to all agents. Customize individual agents in Agent settings.`)})]}):(0,A.jsxs)(`div`,{className:`rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`h3`,{className:`font-medium`,children:O(`安装准备`,`Installation setup`)}),(0,A.jsx)(`ol`,{className:`mt-4 space-y-4 text-sm`,"aria-live":`polite`,children:[{name:O(`准备资源`,`Prepare resources`),done:c?.resources===`ready`,running:K&&c?.resources!==`ready`},{name:O(`授权账号`,`Authorize accounts`),done:c?.resources===`ready`&&!c?.missingConfig?.length&&z.length===0,running:!1},{name:O(`加载可用工具`,`Load available tools`),done:!1,running:K&&c?.resources===`ready`}].map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-3`,children:[e.done?(0,A.jsx)(ee,{className:`size-5 text-accent`,"aria-hidden":!0}):e.running?(0,A.jsx)(ae,{className:`size-5 animate-spin text-accent`,"aria-hidden":!0}):(0,A.jsx)(C,{className:`size-5 text-fg-muted`,"aria-hidden":!0}),e.name]},e.name))}),(0,A.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:O(`安装后所有 Agent 均可使用,可在各自的设置中调整。`,`Available to all agents after installation. Customize individual agents in Agent settings.`)})]}),!c||c.state===`cancelled`?(0,A.jsx)(b,{disabled:d||e.readiness===`blocked`,onClick:()=>void J(`start`),children:O(`继续安装`,`Continue installation`)}):(0,A.jsxs)(A.Fragment,{children:[c.missingConfig?.length||x?(0,A.jsxs)(`form`,{className:`space-y-4 rounded-xl border border-edge p-4`,onSubmit:e=>{e.preventDefault(),J(`configure`,{values:u})},children:[(0,A.jsx)(`h4`,{className:`font-medium`,children:O(`补充配置`,`Required configuration`)}),(0,A.jsx)(j,{fields:x?U:G,values:u,onChange:te}),(0,A.jsx)(b,{type:`submit`,disabled:K||!Object.keys(u).length,children:O(`继续`,`Continue`)})]}):null,B&&(z.length||c.missingConfig?.length)?(0,A.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsx)(T,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium`,children:O(`需要授权`,`Authorization required`)}),(0,A.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:O(`授权后即可使用相关功能。已就绪的功能可继续使用。`,`Connect these accounts to use their features. Ready features remain available.`)})]})]}):null,R.length?(0,A.jsx)(`div`,{className:`space-y-3`,"aria-label":O(`需要补充权限`,`Additional permissions required`),children:R.map(e=>(0,A.jsxs)(`div`,{role:`alert`,className:`space-y-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsx)(`p`,{className:`font-medium`,children:e.title}),(0,A.jsx)(`p`,{className:`text-fg-muted`,children:O(`账号已连接,以下权限尚未就绪;其他已授权功能可继续使用。`,`Account connected. These permissions are not ready; other authorized features remain available.`)}),e.scopes.length?(0,A.jsx)(`p`,{className:`break-all font-mono text-xs`,children:e.scopes.join(`, `)}):null,(0,A.jsx)(`ol`,{className:`list-inside list-decimal space-y-1 text-fg-muted`,children:e.instructions.map(e=>(0,A.jsx)(`li`,{children:e},e))}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.helpUrl?(0,A.jsx)(b,{variant:`secondary`,asChild:!0,children:(0,A.jsx)(`a`,{href:e.helpUrl,target:`_blank`,rel:`noopener noreferrer`,children:O(`前往开通应用权限`,`Open application permissions`)})}):null,e.method&&e.account?(0,A.jsx)(b,{disabled:K,onClick:()=>{E.current=c.revision,y(e.account.id),Y(e.account,e.method)},children:O(`补充授权`,`Grant missing permissions`)}):null,(0,A.jsx)(b,{variant:`secondary`,disabled:K,onClick:()=>void J(`prepare`),children:O(`重新检查权限`,`Check permissions again`)})]})]},`${e.account?.id}:${e.id}`))}):null,I.length?(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(`h4`,{className:`text-sm font-medium`,children:O(`账号与连接`,`Accounts and connections`)}),I.map(e=>(0,A.jsxs)(`div`,{role:`group`,"aria-label":e.title,className:`flex items-center justify-between gap-3 rounded-lg border border-edge p-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:e.title}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:L(e)?O(`已连接`,`Connected`):O(`需要授权`,`Authorization required`)})]}),(0,A.jsx)(b,{variant:L(e)?`secondary`:`primary`,disabled:K||c.resources!==`ready`,onClick:()=>{g(null),_(``),E.current=c.revision,y(e.id)},children:L(e)?O(`重新授权`,`Reconnect`):O(`连接账号`,`Connect account`)})]},e.id))]}):null,!B&&c.resources===`ready`?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(b,{variant:`secondary`,disabled:K,onClick:Z,children:O(`暂时跳过`,`Skip for now`)}),(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:O(`先完成安装,稍后在详情页授权。未授权的功能暂不可用。`,`Finish installation and connect later in plugin details. Unauthenticated features remain unavailable.`)})]}):null,B&&Object.keys(U).length&&!x?(0,A.jsx)(b,{variant:`ghost`,disabled:K,onClick:()=>S(!0),children:O(`修改插件配置`,`Edit plugin configuration`)}):null,B&&!R.length&&N.some(e=>e.methods.some(e=>e.type===`cli`))?(0,A.jsx)(b,{variant:`secondary`,disabled:K,onClick:()=>void J(`prepare`),children:O(`检查连接与权限`,`Check connection and permissions`)}):null,!K&&(p||[`failed`,`interrupted`].includes(c.state)||c.connections.some(e=>e.state===`error`))?(0,A.jsx)(b,{variant:`secondary`,onClick:()=>void J(`prepare`),children:O(`重试检查`,`Retry checks`)}):null,B?null:(0,A.jsx)(b,{variant:`ghost`,disabled:d,onClick:()=>void J(`cancel`),children:O(`取消安装`,`Cancel installation`)}),B&&!z.length&&!c.missingConfig?.length?e.setup?.tasks?.map(t=>(0,A.jsxs)(`div`,{className:`space-y-3 rounded-lg bg-surface-inset p-4 text-sm`,children:[(0,A.jsx)(`p`,{children:t}),(0,A.jsx)(b,{asChild:!0,disabled:!e.active,children:(0,A.jsx)(o,{to:`/chat/new?${new URLSearchParams({draft:t,projectScope:`none`})}`,state:{forceNewChat:!0},onClick:t=>{e.active?r?.():t.preventDefault()},children:O(`开始这个任务`,`Start this task`)})})]},t)):null]}),K?(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:O(`正在准备,可关闭后继续。`,`Preparing. You can close this window and resume.`)}):null,c?.error&&!c.deferred&&!c.missingConfig?.length?(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:W}):null,p?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:p}):null]})}var L=`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg`;function R(e,t){if(e.startsWith(`content.skills:`)){let n=e.slice(15);return t?`提供技能:${n}`:`Add skill: ${n}`}if(e.startsWith(`runtime.mcp.stdio:`)){let n=e.slice(18).split(`:`,1)[0];return t?`在 Gateway 上运行工具服务:${n}`:`Run a tool service on the Gateway: ${n}`}if(e.startsWith(`network.mcp:`)){let n=e.slice(12).split(`:`,1)[0];return t?`连接外部工具服务:${n}`:`Connect to an external tool service: ${n}`}return e.startsWith(`runtime.capability-access:`)?t?`按账号授权启用相关技能和工具`:`Enable skills and tools according to account authorization`:e.startsWith(`runtime.authorization:`)?t?`在本机运行账号登录程序:${e.split(`:`)[1]}`:`Run account sign-in locally: ${e.split(`:`)[1]}`:e.startsWith(`runtime.resource:`)?t?`下载可执行资源:${e.split(`:`)[1]}`:`Download executable resource: ${e.split(`:`)[1]}`:e.startsWith(`network.resource:`)?t?`下载并校验资源:${e.split(`:`)[1]}`:`Download and verify resource: ${e.split(`:`)[1]}`:e}function z(e,t){return t?.publisher?.verification!==`verified`||t.latestVersion.riskTier&&t.latestVersion.riskTier!==`content`?!0:e.addedCapabilities.some(e=>!e.startsWith(`content.skills:`))}async function B(e,t,n){let r=await u(d(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}});if(!r.ok)throw Error(r.error??`Request failed`);return r.payload}function V({extension:e,onClose:t,onUninstalled:n,initialSource:r=``,marketplace:o,autoInstall:u=!1}){let d=te(e=>e.language),v=d.startsWith(`zh`),oe=o?.localizations?.[v?`zh-CN`:`en`],C=oe?.displayName??o?.name,T=oe?.description??o?.description,D=(0,k.useId)(),{mutate:ce}=g(),[O,j]=(0,k.useState)(e),[M,N]=(0,k.useState)(r||e?.installationSource||``),[P,F]=(0,k.useState)(null),[V,H]=(0,k.useState)([]),[U,W]=(0,k.useState)(!1),[G,K]=(0,k.useState)(``),[q,J]=(0,k.useState)(!1),[Y,X]=(0,k.useState)(!1),[Z,le]=(0,k.useState)(!1),[ue,Q]=(0,k.useState)(!1),[de,fe]=(0,k.useState)(!1),[pe,me]=(0,k.useState)(!1),he=a(),ge=i(),[_e,ve]=(0,k.useState)(!1),ye=(0,k.useRef)(!1),be=`/api/extensions/agent-plugins/${encodeURIComponent(O?.pluginId??``)}`,xe=M.trim().startsWith(`store:`),Se=()=>ce(`gateway-extensions-list`);async function $(e){W(!0),K(``);try{await e()}catch(e){K(e instanceof Error?e.message:String(e))}finally{W(!1)}}function Ce(e){N(e),F(null),H([]),K(``)}let we=typeof window<`u`?window.electronAPI?.file:void 0,Te=/^(?:\/|[A-Za-z]:[\\/])/.test(M.trim())?M.trim():void 0;async function Ee(){if(!we?.openDirectory){fe(!0);return}let e=await we.openDirectory(Te?{defaultPath:Te}:void 0);e&&Ce(e)}async function De(){if(!we?.openFile){fe(!0);return}let e=await we.openFile({...Te?{defaultPath:Te}:{},extensions:[`zip`]});e&&Ce(e)}function Oe(e){return[...e.dataTransfer.types].some(e=>e===`Files`||e===`text/plain`||e===`text/uri-list`)}function ke(e){if(!Oe(e))return;e.preventDefault(),Q(!1);let t=Array.from(e.dataTransfer.files);if(t.length){if(t.length>1){K(v?`一次只能选择一个插件目录或 ZIP。`:`Choose one plugin directory or ZIP at a time.`);return}let e=we?.getPathForFile?.(t[0]);e?Ce(e):K(v?`浏览器无法读取本机文件路径,请使用“选择文件或目录”选择安装包。`:`The browser cannot read local file paths. Use Choose file or folder to select the package.`);return}let n=e.dataTransfer.getData(`text/uri-list`)||e.dataTransfer.getData(`text/plain`);n.trim()&&Ce(n.trim().split(/\r?\n/)[0])}async function Ae(e){j(await B(`${be}/activation`,`POST`,{enabled:e})),await Se()}async function je(e){let t=!O,n=await B(t?`/api/extensions/install`:`${be}/update`,`POST`,{source:M,reviewHash:e.reviewHash,...e.layout?{setup:!0}:{}});j(n),await Se(),!e.layout&&t&&!n.activationEligible&&n.readiness!==`blocked`&&n.pluginId&&(n=await B(`/api/extensions/agent-plugins/${encodeURIComponent(n.pluginId)}/activation`,`POST`,{enabled:!0}),j(n),await Se()),F(null),ve(!e.layout&&t&&n.activationEligible===!0)}async function Me(){let e=await B(`/api/extensions/inspect`,`POST`,{source:M});if(z(e,o)){F(e);return}await je(e)}(0,k.useEffect)(()=>{e&&!e.setup&&j(e)},[e]),(0,k.useEffect)(()=>{if(!e?.setup||!e.pluginId)return;let t=!1;return B(`/api/extensions/agent-plugins/${encodeURIComponent(e.pluginId)}`,`GET`).then(e=>{t||j(e)}).catch(()=>{}),()=>{t=!0}},[e?.pluginId]),(0,k.useEffect)(()=>{!u||O||!xe||ye.current||(ye.current=!0,$(Me))},[u,O,xe]);let Ne=u&&!O&&xe&&!ye.current;return(0,A.jsx)(h,{defaultOpen:!0,onOpenChange:e=>!e&&t(),children:(0,A.jsxs)(m,{children:[(0,A.jsx)(f,{className:`fixed inset-0 z-[130] bg-scrim`}),(0,A.jsxs)(ne,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(82vh,42rem)] w-[min(38rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:[(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge p-4`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,A.jsx)(E,{iconUrl:O?.branding?.iconUrl??o?.branding?.iconUrl,fallback:y}),(0,A.jsx)(re,{className:`font-semibold`,children:O?.name??C??(v?`安装插件`:`Install plugin`)})]}),(0,A.jsx)(b,{variant:`ghost`,onClick:t,children:v?`关闭`:`Close`})]}),(0,A.jsx)(p,{className:`sr-only`,children:v?`安装、组件、账号连接和权限`:`Installation, components, connections and permissions`}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[!O&&xe?(0,A.jsxs)(`section`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,A.jsx)(_,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`font-medium text-fg`,children:C??P?.manifest.name??M.slice(6)}),T?(0,A.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:T}):null,(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:o?.publisher?.verification===`verified`?v?`已认证发布者 · 安装后所有 Agent 均可使用`:`Verified publisher · available to all agents after installation`:v?`安装前会检查来源和所需权限`:`Source and required permissions are checked before installation`})]})]}),P?null:(0,A.jsxs)(b,{className:`w-full`,disabled:U||Ne,onClick:()=>void $(Me),children:[U||Ne?(0,A.jsx)(ae,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,U||Ne?v?`正在安全检查并安装…`:`Checking and installing…`:v?`一键安装`:`Install`]})]}):null,O?(0,A.jsxs)(A.Fragment,{children:[_e?(0,A.jsxs)(`div`,{role:`status`,className:`flex items-start gap-3 rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-4`,children:[(0,A.jsx)(ee,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium text-fg`,children:v?`插件已安装并启用`:`Plugin installed and enabled`}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:v?`现在可以直接在对话中使用它。`:`It is ready to use in your conversations.`})]})]}):null,(!O.setup||O.readiness!==`setup_required`)&&!O.activationEligible?(0,A.jsxs)(`div`,{role:`status`,className:`space-y-3 rounded-lg border border-accent/25 bg-accent-soft p-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium text-accent-fg`,children:v?`插件已安装,当前尚未启用`:`Plugin installed. It is not enabled yet.`}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:v?`启用后,Skills 和 MCP 才会加入 Agent 运行时。`:`Enable it to make its skills and MCP servers available to the Agent runtime.`})]}),(0,A.jsx)(b,{disabled:U||O.readiness===`blocked`,onClick:()=>void $(()=>Ae(!0)),children:v?`启用插件`:`Enable plugin`})]}):null,O.setup?(0,A.jsx)(I,{extension:O,zh:v,onStart:t,onInstalled:()=>{t(),he(se(O.pluginId,`installed`,!1,ge.pathname+ge.search))},onChanged:async()=>{j(await B(`${be}`,`GET`)),await Se()}}):null,(0,A.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:v?`插件详情`:`Plugin details`}),(0,A.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,A.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[v?`插件`:`Plugin`,` · `,O.version,` · `,O.readiness&&{ready:v?`已就绪`:`Ready`,setup_required:v?`待连接`:`Setup required`,degraded:v?`部分不可用`:`Partially available`,blocked:v?`已阻止`:`Blocked`}[O.readiness]]}),O.provenance?(0,A.jsxs)(`p`,{className:`break-words text-xs text-fg-muted`,children:[O.provenance.publisherVerification===`verified`?v?`已认证发布者`:`Verified publisher`:v?`社区发布者`:`Community publisher`,` · `,O.provenance.packageName,`@`,O.provenance.version,` · SHA-256 `,O.provenance.sha256.slice(0,12),`…`,O.provenance.riskTier?` · ${O.provenance.riskTier}`:``]}):null,(0,A.jsx)(`p`,{className:`text-sm`,children:O.description}),O.installationSource?(0,A.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[v?`来源:`:`Source: `,O.installationSource,O.resolvedCommit?` · ${O.resolvedCommit.slice(0,12)}`:``]}):null,O.activationEligible?(0,A.jsx)(b,{disabled:U,variant:`secondary`,onClick:()=>void $(()=>Ae(!1)),children:v?`停用`:`Disable`}):null,O.canRollback?(0,A.jsx)(b,{disabled:U,variant:`secondary`,onClick:()=>void $(async()=>{j(await B(`${be}/rollback`,`POST`)),await Se()}),children:v?`回滚上一版本`:`Roll back`}):null]})]}),O.diagnostics?.map((e,t)=>(0,A.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.component,`: `,e.message]},t))]}):null,O?(0,A.jsxs)(b,{variant:`ghost`,className:`px-0`,"aria-expanded":pe,onClick:()=>me(e=>!e),children:[(0,A.jsx)(w,{className:l(`size-4 transition-transform motion-reduce:transition-none`,pe&&`rotate-180`),"aria-hidden":!0}),v?`高级操作`:`Advanced actions`]}):null,!O&&!xe||pe?(0,A.jsxs)(`form`,{className:l(`space-y-3`,O&&`border-t border-edge pt-4`),onSubmit:e=>{e.preventDefault(),$(async()=>{let e=await B(`/api/extensions/inspect`,`POST`,{source:M});e.candidates?(H(e.candidates),F(null)):(H([]),F(e))})},children:[(0,A.jsxs)(`div`,{"data-testid":`plugin-source-dropzone`,className:l(`rounded-xl border border-dashed p-3 transition-colors`,ue?`border-accent bg-accent-soft`:`border-edge bg-surface-inset/40`),onDragEnter:e=>{Oe(e)&&(e.preventDefault(),Q(!0))},onDragOver:e=>{Oe(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Q(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||Q(!1)},onDrop:ke,children:[(0,A.jsxs)(`div`,{className:`mb-2 flex items-start gap-2`,children:[(0,A.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:D,className:`block text-sm font-medium`,children:O?v?`更新包来源`:`Update package source`:v?`安装包来源`:`Package source`}),(0,A.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:v?`输入 github:组织/仓库、Git / ZIP 地址或宿主目录;marketplace 可选择插件。`:`Enter github:owner/repo, a Git / ZIP URL or a Gateway directory. Marketplaces let you choose a plugin.`})]})]}),(0,A.jsx)(`input`,{id:D,className:L,value:M,onChange:e=>Ce(e.target.value),placeholder:v?`/插件目录/或/插件.zip`:`/plugin/folder/or/plugin.zip`,autoComplete:`off`,spellCheck:!1,required:!0}),(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:we?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(b,{type:`button`,variant:`secondary`,disabled:U,onClick:()=>void $(Ee),children:[(0,A.jsx)(s,{className:`size-4`,"aria-hidden":!0}),v?`选择目录`:`Choose directory`]}),(0,A.jsxs)(b,{type:`button`,variant:`secondary`,disabled:U,onClick:()=>void $(De),children:[(0,A.jsx)(x,{className:`size-4`,"aria-hidden":!0}),v?`选择 ZIP`:`Choose ZIP`]})]}):(0,A.jsxs)(b,{type:`button`,variant:`secondary`,disabled:U,onClick:()=>fe(!0),children:[(0,A.jsx)(s,{className:`size-4`,"aria-hidden":!0}),v?`选择文件或目录`:`Choose file or folder`]})})]}),(0,A.jsx)(b,{type:`submit`,variant:`secondary`,disabled:U||!M,children:v?`检查安装包`:`Inspect package`})]}):null,V.length?(0,A.jsx)(`div`,{className:`space-y-2`,"aria-label":v?`选择插件`:`Choose a plugin`,children:V.map(e=>(0,A.jsx)(b,{variant:`secondary`,className:`w-full justify-start`,onClick:()=>{Ce(e.source),$(async()=>F(await B(`/api/extensions/inspect`,`POST`,{source:e.source})))},children:e.name},e.source))}):null,P?(0,A.jsxs)(`div`,{role:`region`,"aria-labelledby":`plugin-authorization-title`,className:`space-y-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(_,{className:`mt-0.5 size-5 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{id:`plugin-authorization-title`,className:`font-medium text-fg`,children:v?`需要你的授权`:`Your authorization is required`}),(0,A.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:v?`此插件需要以下新增能力。确认后自动准备资源,按需登录账号,所有 Agent 均可使用。`:`Review these capabilities. Resources are prepared automatically; sign in if needed. Available to all agents.`})]})]}),(0,A.jsx)(`ul`,{tabIndex:0,"aria-label":v?`插件新增能力`:`Added plugin capabilities`,className:`max-h-[min(28vh,14rem)] space-y-2 overflow-y-auto overscroll-contain rounded-lg border border-edge bg-surface-panel p-3 break-words focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:P.addedCapabilities.map(e=>(0,A.jsxs)(`li`,{className:`flex gap-2`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,children:`•`}),(0,A.jsx)(`span`,{children:R(e,v)})]},e))}),P.capabilities.some(e=>e.startsWith(`runtime.`))?(0,A.jsxs)(`details`,{children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:v?`查看执行内容`:`View execution details`}),(0,A.jsx)(`ul`,{tabIndex:0,"aria-label":v?`插件执行内容`:`Plugin execution details`,className:`mt-2 max-h-40 space-y-2 overflow-y-auto overscroll-contain break-all font-mono text-xs`,children:P.capabilities.filter(e=>e.startsWith(`runtime.`)).map(e=>(0,A.jsx)(`li`,{children:e},e))})]}):null,P.diagnostics.map((e,t)=>(0,A.jsxs)(`p`,{children:[e.component,`: `,e.message]},t))]}):null,O&&pe?(0,A.jsx)(`div`,{className:`border-t border-edge pt-4`,children:Z?(0,A.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,A.jsx)(`p`,{children:v?`卸载保留账号凭据;服务端授权需到相应服务撤销。`:`Credentials are retained. Revoke provider authorization in the service itself.`}),(0,A.jsxs)(`label`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:q,onChange:e=>J(e.target.checked)}),v?`同时删除插件数据`:`Also delete plugin data`]}),(0,A.jsxs)(`label`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:e=>X(e.target.checked)}),v?`同时删除本地凭据`:`Also delete local credentials`]}),(0,A.jsx)(b,{disabled:U,onClick:()=>void $(async()=>{await B(be,`DELETE`,{removeData:q,removeCredentials:Y}),await Se(),(n??t)()}),children:v?`确认卸载`:`Confirm uninstall`})]}):(0,A.jsx)(b,{variant:`ghost`,disabled:U,onClick:()=>le(!0),children:v?`卸载插件`:`Uninstall`})}):null,G?(0,A.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-fg-muted`,children:G}):null]}),P?(0,A.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,A.jsx)(b,{variant:`ghost`,disabled:U,onClick:()=>F(null),children:v?`取消`:`Cancel`}),(0,A.jsxs)(b,{disabled:U||!!O&&P.manifest.name!==O.name,onClick:()=>void $(()=>je(P)),children:[U?(0,A.jsx)(ae,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,v?`授权并安装`:`Authorize and install`]})]}):null]}),we?null:(0,A.jsx)(ie,{open:de,onOpenChange:fe,initialAbsolutePath:Te,onConfirm:async e=>Ce(e),wd:c(d).chat.workingDirectory,selectKind:`file-or-directory`,fileExtensions:[`zip`],title:v?`选择插件安装包`:`Choose plugin package`,description:v?`选择插件目录或 ZIP 文件。`:`Choose a plugin directory or ZIP file.`,confirmLabel:v?`使用此来源`:`Use this source`,nested:!0})]})})}function H(e,t){return e.localizations?.[t?`zh-CN`:`en`]?.displayName??(e.setup?.authorizations?.length===1?e.setup.authorizations[0].title:e.name)}function U(e){return e.authorizationStatus===`required`||!!e.setup?.authorizations?.length&&e.authorizationStatus!==`connected`}function W(e){return e.active&&!U(e)&&(e.authorizationStatus===`connected`||e.authorizationStatus===`not_required`)}export{I as a,V as i,H as n,U as r,W as t};