@xopcai/xopc 0.0.426 → 0.0.427

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 (360) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/src/adapters/security-adapter.js +1 -1
  3. package/dist/extensions/telegram/src/pairing-config-resolver.js +1 -1
  4. package/dist/extensions/telegram/src/plugin.js +2 -2
  5. package/dist/extensions/telegram/xopc.extension.json +1 -1
  6. package/dist/extensions/weixin/src/api/api.js +1 -1
  7. package/dist/extensions/weixin/src/auth/accounts.js +2 -2
  8. package/dist/extensions/weixin/src/auth/pairing.js +1 -1
  9. package/dist/extensions/weixin/src/cdn/upload.js +1 -1
  10. package/dist/extensions/weixin/src/cli/gateway-qr-login.js +1 -1
  11. package/dist/extensions/weixin/src/cli/qr-login.js +1 -1
  12. package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
  13. package/dist/extensions/weixin/src/messaging/inbound.js +2 -2
  14. package/dist/extensions/weixin/src/messaging/process-message.js +3 -3
  15. package/dist/extensions/weixin/src/messaging/send.js +12 -3
  16. package/dist/extensions/weixin/src/monitor/monitor.js +1 -1
  17. package/dist/extensions/weixin/src/outbound-send.js +12 -3
  18. package/dist/extensions/weixin/src/pairing-config-resolver.js +1 -1
  19. package/dist/extensions/weixin/src/plugin.js +1 -1
  20. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D4ClP_DJ.js +1 -0
  21. package/dist/gateway/static/root/assets/agent-plugin-dialog-m1A8wF9p.js +1 -0
  22. package/dist/gateway/static/root/assets/agents-B9slUA_1.js +77 -0
  23. package/dist/gateway/static/root/assets/app-link-DRy3-k7j.js +1 -0
  24. package/dist/gateway/static/root/assets/{app-management-settings-panel-C8yc3yHG.js → app-management-settings-panel-XqoIBF2H.js} +1 -1
  25. package/dist/gateway/static/root/assets/{appearance-settings-BELgtR3O.js → appearance-settings-9ZtqCASo.js} +1 -1
  26. package/dist/gateway/static/root/assets/apps-page-DUeu_7iC.js +1 -0
  27. package/dist/gateway/static/root/assets/attachment-load-DrVGNxJm.js +1 -0
  28. package/dist/gateway/static/root/assets/automation-task-card-Bur78p68.js +3 -0
  29. package/dist/gateway/static/root/assets/{automations-page-CdIPdwF0.js → automations-page-DMIyWsP0.js} +1 -1
  30. package/dist/gateway/static/root/assets/automations-workspace-DEkDjxeU.js +9 -0
  31. package/dist/gateway/static/root/assets/{block-editor-BQtTLe6Q.js → block-editor-CXdlNAmZ.js} +2 -2
  32. package/dist/gateway/static/root/assets/{browser-automation-inputs-DeraGZ1y.js → browser-automation-inputs-Fxo7HbK6.js} +1 -1
  33. package/dist/gateway/static/root/assets/{browser-automations-page-SpPzRNqU.js → browser-automations-page-Dn3LN5wo.js} +2 -2
  34. package/dist/gateway/static/root/assets/browser-settings-page-Cpm9fEPV.js +3 -0
  35. package/dist/gateway/static/root/assets/{button-CnRSIP6m.js → button-Cc4hUNTt.js} +1 -1
  36. package/dist/gateway/static/root/assets/{capabilities-DLMuj21P.js → capabilities-BEvywfF9.js} +1 -1
  37. package/dist/gateway/static/root/assets/capabilities-Bo2qEJhH.js +1 -0
  38. package/dist/gateway/static/root/assets/capabilities-page-BCzsIzvC.js +2 -0
  39. package/dist/gateway/static/root/assets/capabilities-settings-panel-Cr67ziwX.js +8 -0
  40. package/dist/gateway/static/root/assets/{capability-header-actions-CTUCuBlW.js → capability-header-actions-BxMYfQ8y.js} +1 -1
  41. package/dist/gateway/static/root/assets/channels-CA5z5dGY.js +1 -0
  42. package/dist/gateway/static/root/assets/{chat-chart-block-DCzUECct.js → chat-chart-block-B39npsXj.js} +1 -1
  43. package/dist/gateway/static/root/assets/chat-page-D92AWJbh.js +72 -0
  44. package/dist/gateway/static/root/assets/{chat-terminal-dock-Dl-OTkJI.js → chat-terminal-dock-DjFnElAM.js} +2 -2
  45. package/dist/gateway/static/root/assets/composer-payload-handoff-BQXlFKf4.js +1 -0
  46. package/dist/gateway/static/root/assets/{computer-settings-page-B-lGMimW.js → computer-settings-page-MkqyKyf3.js} +1 -1
  47. package/dist/gateway/static/root/assets/confirm-dialog-D7dQJytv.js +1 -0
  48. package/dist/gateway/static/root/assets/connected-providers-grid-BSvKP2u-.js +1 -0
  49. package/dist/gateway/static/root/assets/{connector-service-page-C8InhrMt.js → connector-service-page-DlIl9bLx.js} +1 -1
  50. package/dist/gateway/static/root/assets/connectors-page-Vx8-MY0Y.js +1 -0
  51. package/dist/gateway/static/root/assets/{copy-text-row-CYIv7RfP.js → copy-text-row-CpiRzq4G.js} +1 -1
  52. package/dist/gateway/static/root/assets/{date-picker-kqic8j73.js → date-picker-BIfjfOTM.js} +1 -1
  53. package/dist/gateway/static/root/assets/dependency-picker-XjPB8FJS.js +1 -0
  54. package/dist/gateway/static/root/assets/{desktop-pet-settings-BDS7_tQ_.js → desktop-pet-settings-BDjsFown.js} +1 -1
  55. package/dist/gateway/static/root/assets/device-pairing-wizard-DH_uJ698.js +1 -0
  56. package/dist/gateway/static/root/assets/{directory-picker-path-field-Di0h3ws4.js → directory-picker-path-field-DiZXY7jF.js} +1 -1
  57. package/dist/gateway/static/root/assets/{discussion-annotation-sync-ClKEyXmN.js → discussion-annotation-sync-BXqNuZnx.js} +1 -1
  58. package/dist/gateway/static/root/assets/dist-BGTk37IG.js +1 -0
  59. package/dist/gateway/static/root/assets/dist-BuHnPloF.js +1 -0
  60. package/dist/gateway/static/root/assets/dist-GJ8-1PAx.js +1 -0
  61. package/dist/gateway/static/root/assets/dist-ZrL34Ps4.js +1 -0
  62. package/dist/gateway/static/root/assets/{extension-debug-page-DwB5KMGk.js → extension-debug-page-myQqsol2.js} +1 -1
  63. package/dist/gateway/static/root/assets/{extension-iframe-host-Cqg1K70e.js → extension-iframe-host-DaL-OcTw.js} +1 -1
  64. package/dist/gateway/static/root/assets/{extension-page-DyrQtG82.js → extension-page-DvlGhZLa.js} +1 -1
  65. package/dist/gateway/static/root/assets/{extension-provider-C_uKqJxP.js → extension-provider-fOi6V6Cr.js} +1 -1
  66. package/dist/gateway/static/root/assets/{extension-settings-page-BAMQHzkX.js → extension-settings-page-DOGlQpkx.js} +1 -1
  67. package/dist/gateway/static/root/assets/{gateway-settings-uAboiElC.js → gateway-settings-Di41peSM.js} +1 -1
  68. package/dist/gateway/static/root/assets/home-page-B3sgqrl3.js +2 -0
  69. package/dist/gateway/static/root/assets/{image-generation-api-CQxZSTWA.js → image-generation-api-Ce-IY7Ug.js} +1 -1
  70. package/dist/gateway/static/root/assets/{imports-page-C90644id.js → imports-page-W7_cDbxy.js} +1 -1
  71. package/dist/gateway/static/root/assets/index-D4B6O8B3.js +11 -0
  72. package/dist/gateway/static/root/assets/index-DGWBJDAM.css +1 -0
  73. package/dist/gateway/static/root/assets/install-connector-dialog-DWVl9ekV.js +1 -0
  74. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CbeubKe1.js → keyboard-shortcuts-settings-Doyu0Q9e.js} +1 -1
  75. package/dist/gateway/static/root/assets/link-2-D_ZKYUW7.js +1 -0
  76. package/dist/gateway/static/root/assets/local-app-workbench-page-B3h3P6aI.js +1 -0
  77. package/dist/gateway/static/root/assets/{local-apps-page-C6zFgwkr.js → local-apps-page-D6D2bZGW.js} +1 -1
  78. package/dist/gateway/static/root/assets/{logs-page-CpVCvAWE.js → logs-page-qiXos_12.js} +2 -2
  79. package/dist/gateway/static/root/assets/management-settings-C0WcSdK7.js +1 -0
  80. package/dist/gateway/static/root/assets/{markdown-view-DrVAMlwc.js → markdown-view-Ck5s16p9.js} +2 -2
  81. package/dist/gateway/static/root/assets/mcp-conversation-setup-page-CENs3hGU.js +1 -0
  82. package/dist/gateway/static/root/assets/model-selector-DCBmsHzj.js +1 -0
  83. package/dist/gateway/static/root/assets/note-detail-panel-CnuxqWMd.js +5 -0
  84. package/dist/gateway/static/root/assets/note-image-lightbox-BFKZ7qJr.js +1 -0
  85. package/dist/gateway/static/root/assets/{notes-api-CUlhTRv0.js → notes-api-8kp0X1x6.js} +1 -1
  86. package/dist/gateway/static/root/assets/{notes-page-eoKX85K5.js → notes-page-XMdy-H3H.js} +1 -1
  87. package/dist/gateway/static/root/assets/{oauth-provider-connect-C8BXow79.js → oauth-provider-connect-CfOK8mPM.js} +1 -1
  88. package/dist/gateway/static/root/assets/{page-context-capture-button-CBFK41OS.js → page-context-capture-button-CKlKWSJ7.js} +1 -1
  89. package/dist/gateway/static/root/assets/personal-page-CIMMSI25.js +1 -0
  90. package/dist/gateway/static/root/assets/{personal-settings-panel-DnYapLo7.js → personal-settings-panel-wKdlrfPq.js} +1 -1
  91. package/dist/gateway/static/root/assets/{phone-dependencies-card-DBiKtzwz.js → phone-dependencies-card-CDhk5277.js} +1 -1
  92. package/dist/gateway/static/root/assets/phone-model-connection-DZ-ZunPz.js +1 -0
  93. package/dist/gateway/static/root/assets/{phone-model-picker-BmSxEr7M.js → phone-model-picker-DuZc5jYO.js} +1 -1
  94. package/dist/gateway/static/root/assets/phone-settings-page-0u0GQl_R.js +1 -0
  95. package/dist/gateway/static/root/assets/plugin-details-dialog-Bfc-Wmrd.js +1 -0
  96. package/dist/gateway/static/root/assets/{popover-select-DD8fmrxH.js → popover-select-CEMWIrtY.js} +1 -1
  97. package/dist/gateway/static/root/assets/{preference-select-fields-Cu_ZC9Up.js → preference-select-fields-BKeHZLXZ.js} +1 -1
  98. package/dist/gateway/static/root/assets/{product-automation-feedback-Tn2dUJWM.js → product-automation-feedback-BPur0vyo.js} +2 -2
  99. package/dist/gateway/static/root/assets/{product-open-page-Nf-Oqf1h.js → product-open-page-Bfd7R483.js} +1 -1
  100. package/dist/gateway/static/root/assets/{product-preview-content-D6NwUm3A.js → product-preview-content-Bnq68oVw.js} +1 -1
  101. package/dist/gateway/static/root/assets/{product-preview-modal-BfNcGgXA.js → product-preview-modal-BPmTeweh.js} +2 -2
  102. package/dist/gateway/static/root/assets/project-detail-page-D9nnyvrI.js +7 -0
  103. package/dist/gateway/static/root/assets/{project-understanding-B1BK7Ixi.js → project-understanding-DLvxAoTT.js} +1 -1
  104. package/dist/gateway/static/root/assets/projects-page-BGy1pw9a.js +1 -0
  105. package/dist/gateway/static/root/assets/{recording-upload-RAhaLUcQ.js → recording-upload-CHFJbqW1.js} +1 -1
  106. package/dist/gateway/static/root/assets/{refresh-button-bU_0NarN.js → refresh-button-DiWdGAaX.js} +1 -1
  107. package/dist/gateway/static/root/assets/{remote-access-hub-DWsOWetc.js → remote-access-hub-BVqwnOqO.js} +1 -1
  108. package/dist/gateway/static/root/assets/route-preload-DI43HQV_.js +2 -0
  109. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BGiXeHF5.js → runtime-tools-settings-panel-ccVBG-bZ.js} +1 -1
  110. package/dist/gateway/static/root/assets/{schema-form-BKeP5G7b.js → schema-form-C-jw6Hid.js} +1 -1
  111. package/dist/gateway/static/root/assets/{secret-input-BQvFXqzz.js → secret-input-Dryrns2s.js} +1 -1
  112. package/dist/gateway/static/root/assets/{service-recommendation-list-BEnNx0u7.js → service-recommendation-list-CNghOavt.js} +1 -1
  113. package/dist/gateway/static/root/assets/session-manager-Bnq3qpqy.js +23 -0
  114. package/dist/gateway/static/root/assets/sessions-page-CyBj1Xw2.js +1 -0
  115. package/dist/gateway/static/root/assets/{settings-advanced-section-CURRjsLK.js → settings-advanced-section-DwpPPxT0.js} +1 -1
  116. package/dist/gateway/static/root/assets/{settings-page-GtsbT6as.js → settings-page-Cd8Ermnn.js} +1 -1
  117. package/dist/gateway/static/root/assets/{settings-page-header-DBL0_u0Z.js → settings-page-header-BZl4AMiN.js} +1 -1
  118. package/dist/gateway/static/root/assets/{settings-page-layout-IAvpbz4A.js → settings-page-layout-onhEgq-K.js} +1 -1
  119. package/dist/gateway/static/root/assets/setup-interaction-page-Cvvj6JyV.js +1 -0
  120. package/dist/gateway/static/root/assets/setup-status-panel-D4qgE7QM.js +1 -0
  121. package/dist/gateway/static/root/assets/share-link-dialog-DA0QuFOD.js +1 -0
  122. package/dist/gateway/static/root/assets/{share-preview-page-L9KYu8M7.js → share-preview-page-YDpIY4dC.js} +1 -1
  123. package/dist/gateway/static/root/assets/shares-settings-DUvjOMmA.js +1 -0
  124. package/dist/gateway/static/root/assets/skills-page-ClyNSh-7.js +2 -0
  125. package/dist/gateway/static/root/assets/{system-settings-panel-CsvcFoaJ.js → system-settings-panel-BN6sUX0H.js} +1 -1
  126. package/dist/gateway/static/root/assets/task-detail-page-CS9m7Ipo.js +2 -0
  127. package/dist/gateway/static/root/assets/{task-result-evidence-B8xUiwW3.js → task-result-evidence-DKygspo2.js} +1 -1
  128. package/dist/gateway/static/root/assets/tracing-settings-page-Bs76WeoF.js +1 -0
  129. package/dist/gateway/static/root/assets/{tunnel-api-BB7u79ID.js → tunnel-api-B7nx0NQJ.js} +1 -1
  130. package/dist/gateway/static/root/assets/{usage-page-Cv4Je5XJ.js → usage-page-anU5gslJ.js} +1 -1
  131. package/dist/gateway/static/root/assets/use-composer-attachments-DYY3Yz4a.js +2 -0
  132. package/dist/gateway/static/root/assets/use-file-preview-expanded-CYgWzDnv.js +2 -0
  133. package/dist/gateway/static/root/assets/{use-workspace-tree-BQEiJzK7.js → use-workspace-tree-Dkg9tUr4.js} +1 -1
  134. package/dist/gateway/static/root/assets/user-model-page-DIgPL3tN.js +2 -0
  135. package/dist/gateway/static/root/assets/{voice-api-key-field-DCM69u8Y.js → voice-api-key-field-BUes-Jlp.js} +1 -1
  136. package/dist/gateway/static/root/assets/voice-transcribe-api-Dy4hfftb.js +1 -0
  137. package/dist/gateway/static/root/assets/{work-discovery-overlay-CVe9UmFl.js → work-discovery-overlay-CFF4cRFl.js} +1 -1
  138. package/dist/gateway/static/root/assets/{work-discovery-page-CtqkRMN5.js → work-discovery-page-BnYaVH3V.js} +1 -1
  139. package/dist/gateway/static/root/assets/working-directory-picker-modal-GFwVefVA.js +1 -0
  140. package/dist/gateway/static/root/assets/{workspace-api-tbifz2zY.js → workspace-api-BdB4NEOh.js} +2 -2
  141. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-BubQwQwU.js → workspace-file-preview-dialog-NRL3YRjg.js} +1 -1
  142. package/dist/gateway/static/root/assets/{workspace-open-location-menu-DZk3MBSa.js → workspace-open-location-menu-Dcij7wvJ.js} +1 -1
  143. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-CIavPUr3.js → xopc-cloud-account-card-DC9aG7Pl.js} +1 -1
  144. package/dist/gateway/static/root/index.html +66 -64
  145. package/dist/package.js +1 -1
  146. package/dist/packages/gateway-contract/src/automations.js +7 -0
  147. package/dist/packages/gateway-contract/src/capabilities.js +1 -1
  148. package/dist/src/agent/agent-manager.d.ts +1 -0
  149. package/dist/src/agent/agent-manager.js +1 -0
  150. package/dist/src/agent/child-agent-factory.js +1 -1
  151. package/dist/src/agent/data-acquisition/service.js +1 -1
  152. package/dist/src/agent/embedded/configuration-capability-correction.d.ts +3 -0
  153. package/dist/src/agent/embedded/configuration-capability-correction.js +14 -0
  154. package/dist/src/agent/embedded/run-for-session.js +20 -5
  155. package/dist/src/agent/embedded/run-turn.js +13 -1
  156. package/dist/src/agent/embedded/session-runner.js +6 -3
  157. package/dist/src/agent/image/generation/openai-images-provider.js +1 -1
  158. package/dist/src/agent/image/load-image-media.js +1 -1
  159. package/dist/src/agent/inbound/inbound-loop.js +4 -1
  160. package/dist/src/agent/independent-execution.js +1 -1
  161. package/dist/src/agent/mcp/config.js +1 -1
  162. package/dist/src/agent/mcp/connection-drafts.d.ts +3 -1
  163. package/dist/src/agent/mcp/connection-drafts.js +3 -2
  164. package/dist/src/agent/mcp/connection-setup.js +34 -2
  165. package/dist/src/agent/mcp/conversation-setup.d.ts +163 -0
  166. package/dist/src/agent/mcp/conversation-setup.js +621 -0
  167. package/dist/src/agent/mcp/native-mcp.d.ts +1 -0
  168. package/dist/src/agent/mcp/tool-catalog.d.ts +5 -0
  169. package/dist/src/agent/mcp/tool-catalog.js +19 -2
  170. package/dist/src/agent/mcp/weixin-setup-scope.d.ts +12 -0
  171. package/dist/src/agent/mcp/weixin-setup-scope.js +43 -0
  172. package/dist/src/agent/prompt/conversational-configuration-guide.js +2 -1
  173. package/dist/src/agent/prompt/sections/tooling.js +3 -2
  174. package/dist/src/agent/prompt/service-prompt-builder.js +1 -1
  175. package/dist/src/agent/service/direct-turn-helpers.js +1 -1
  176. package/dist/src/agent/service/process-direct-streaming.js +2 -2
  177. package/dist/src/agent/service.d.ts +2 -0
  178. package/dist/src/agent/service.js +11 -1
  179. package/dist/src/agent/service.types.d.ts +1 -0
  180. package/dist/src/agent/tasks/task-judge-service.js +2 -2
  181. package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +6 -4
  182. package/dist/src/agent/tool-manuals/xopc-configuration.js +92 -8
  183. package/dist/src/agent/tools/automation-tool.d.ts +9 -1
  184. package/dist/src/agent/tools/automation-tool.js +34 -5
  185. package/dist/src/agent/tools/create-share-tool.js +1 -1
  186. package/dist/src/agent/tools/factory.d.ts +3 -0
  187. package/dist/src/agent/tools/factory.js +34 -23
  188. package/dist/src/agent/tools/image-generate-tool.js +3 -3
  189. package/dist/src/agent/tools/index.d.ts +1 -0
  190. package/dist/src/agent/tools/index.js +5 -4
  191. package/dist/src/agent/tools/mcp-setup-tool.d.ts +9 -0
  192. package/dist/src/agent/tools/mcp-setup-tool.js +32 -0
  193. package/dist/src/agent/tools/personal-task-tool.js +2 -2
  194. package/dist/src/agent/tools/publish-artifacts.js +1 -1
  195. package/dist/src/agent/tools/read.js +1 -1
  196. package/dist/src/agent/tools/skill-install-tool.js +56 -1
  197. package/dist/src/agent/tools/skill-manage-tool.d.ts +4 -0
  198. package/dist/src/agent/tools/skill-manage-tool.js +74 -2
  199. package/dist/src/agent/tools/skills-tools.js +1 -1
  200. package/dist/src/agent/tools/task-collaboration-tool.js +1 -1
  201. package/dist/src/agent/tools/tool-manual-tool.d.ts +1 -1
  202. package/dist/src/agent/tools/tool-manual-tool.js +3 -1
  203. package/dist/src/agent/tools/toolExposure.js +2 -0
  204. package/dist/src/agent/tools/write.js +1 -1
  205. package/dist/src/agent/tools/xopc-use-tool.d.ts +4 -2
  206. package/dist/src/agent/tools/xopc-use-tool.js +60 -10
  207. package/dist/src/agent-catalog/service.d.ts +1 -1
  208. package/dist/src/agent-catalog/service.js +2 -1
  209. package/dist/src/automations/capabilities/drafts.js +5 -2
  210. package/dist/src/automations/capabilities/read.js +18 -7
  211. package/dist/src/automations/capabilities/write.d.ts +111 -52
  212. package/dist/src/automations/capabilities/write.js +44 -10
  213. package/dist/src/automations/delivery/delivery-router.d.ts +1 -0
  214. package/dist/src/automations/delivery/delivery-router.js +7 -1
  215. package/dist/src/automations/domain/types.d.ts +8 -0
  216. package/dist/src/automations/domain/validation.d.ts +24 -0
  217. package/dist/src/automations/domain/validation.js +7 -0
  218. package/dist/src/automations/draft/automation-draft-validator.d.ts +6 -0
  219. package/dist/src/automations/index.js +2 -2
  220. package/dist/src/automations/mcp-source.d.ts +60 -0
  221. package/dist/src/automations/mcp-source.js +173 -0
  222. package/dist/src/automations/service/action-executor.js +15 -1
  223. package/dist/src/automations/service/automation-service.d.ts +5 -0
  224. package/dist/src/automations/service/automation-service.js +52 -2
  225. package/dist/src/automations/service/index.js +2 -2
  226. package/dist/src/browser/setup/repository.d.ts +1 -0
  227. package/dist/src/browser/setup/repository.js +7 -1
  228. package/dist/src/browser/setup/service.d.ts +3 -0
  229. package/dist/src/browser/setup/service.js +41 -18
  230. package/dist/src/browser/setup/types.d.ts +1 -0
  231. package/dist/src/channels/attachments/voice-stt-webchat.js +1 -1
  232. package/dist/src/channels/index.js +1 -1
  233. package/dist/src/channels/manager.d.ts +1 -0
  234. package/dist/src/channels/outbound-sender.d.ts +1 -0
  235. package/dist/src/channels/outbound-sender.js +3 -0
  236. package/dist/src/channels/pairing/pairing-service.js +1 -1
  237. package/dist/src/channels/weixin/account-identity.d.ts +2 -0
  238. package/dist/src/channels/weixin/account-identity.js +15 -0
  239. package/dist/src/chat-commands/builtins/config.js +1 -1
  240. package/dist/src/cli/commands/channels.js +2 -2
  241. package/dist/src/cli/commands/doctor/checks/channel-pairing-pending.js +1 -1
  242. package/dist/src/cli/commands/mcp.js +1 -1
  243. package/dist/src/extensions/agent-plugins/credentials.js +1 -1
  244. package/dist/src/extensions/agent-plugins/setup.d.ts +1 -1
  245. package/dist/src/extensions/agent-plugins/setup.js +3 -3
  246. package/dist/src/extensions/api.js +1 -1
  247. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  248. package/dist/src/gateway/agents-admin.js +1 -1
  249. package/dist/src/gateway/device-routes.js +1 -1
  250. package/dist/src/gateway/hono/app.js +1 -1
  251. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  252. package/dist/src/gateway/hono/oauth-async.js +1 -1
  253. package/dist/src/gateway/hono/routes/channels.js +1 -1
  254. package/dist/src/gateway/hono/routes/config.js +1 -1
  255. package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -1
  256. package/dist/src/gateway/hono/routes/mcp.js +39 -2
  257. package/dist/src/gateway/hono/routes/notes.js +2 -2
  258. package/dist/src/gateway/hono/routes/phone-setup.js +33 -9
  259. package/dist/src/gateway/hono/routes/projects.js +1 -1
  260. package/dist/src/gateway/hono/routes/provider-setup.js +1 -1
  261. package/dist/src/gateway/hono/routes/public-gateway.js +22 -0
  262. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  263. package/dist/src/gateway/hono/routes/shares.js +1 -1
  264. package/dist/src/gateway/hono/routes/site-shares.js +1 -1
  265. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  266. package/dist/src/gateway/media-access.js +1 -1
  267. package/dist/src/gateway/service/agent-runner.d.ts +1 -0
  268. package/dist/src/gateway/service/agent-runner.js +3 -1
  269. package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
  270. package/dist/src/gateway/service/config-coordinator.js +2 -1
  271. package/dist/src/gateway/service/run-gateway-agent.js +1 -1
  272. package/dist/src/gateway/service/sessions-api.js +2 -1
  273. package/dist/src/gateway/service.d.ts +5 -1
  274. package/dist/src/gateway/service.js +90 -16
  275. package/dist/src/gateway/session-context-summary.js +1 -1
  276. package/dist/src/gateway/session-reset-service.d.ts +1 -0
  277. package/dist/src/gateway/session-reset-service.js +15 -2
  278. package/dist/src/home-intelligence/host.js +2 -2
  279. package/dist/src/notes/service.js +1 -1
  280. package/dist/src/personal-agent/prompts.js +1 -1
  281. package/dist/src/personal-agent/reply-composer.js +2 -2
  282. package/dist/src/personal-agent/request-service.js +3 -3
  283. package/dist/src/personal-agent/service.js +1 -1
  284. package/dist/src/personal-agent/task-cancel.js +1 -1
  285. package/dist/src/phone/setup/service.d.ts +14 -4
  286. package/dist/src/phone/setup/service.js +106 -28
  287. package/dist/src/projects/index.js +1 -1
  288. package/dist/src/projects/project-service.js +1 -1
  289. package/dist/src/runtime-tools/phone-dependencies.d.ts +2 -0
  290. package/dist/src/runtime-tools/phone-dependencies.js +10 -0
  291. package/dist/src/share/note-share-service.js +1 -1
  292. package/dist/src/share/site-proxy.js +1 -1
  293. package/dist/src/tasks/capabilities/write.js +1 -1
  294. package/dist/src/tasks/index.js +1 -1
  295. package/dist/src/tasks/task-allocation-service.js +3 -3
  296. package/dist/src/tasks/task-application-service.js +2 -2
  297. package/dist/src/tasks/task-context-assembler.js +1 -1
  298. package/dist/src/tasks/task-contract-planner.js +1 -1
  299. package/dist/src/tasks/task-handoff.js +1 -1
  300. package/dist/src/tasks/task-research-result.js +1 -1
  301. package/dist/src/tasks/task-run-coordinator.js +2 -2
  302. package/dist/src/tui/backends/embedded-backend.js +1 -1
  303. package/package.json +3 -1
  304. package/skills/tools/configure-xopc/SKILL.md +10 -3
  305. package/skills/tools/configure-xopc/references/browser/chrome-extension.md +4 -1
  306. package/skills/tools/configure-xopc/references/browser/overview.md +2 -2
  307. package/skills/tools/configure-xopc/references/phone/aliyun.md +3 -2
  308. package/skills/tools/configure-xopc/references/phone/overview.md +2 -2
  309. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Dne9A10p.js +0 -1
  310. package/dist/gateway/static/root/assets/agent-plugin-dialog-BoHL-b1o.js +0 -1
  311. package/dist/gateway/static/root/assets/agents-CIiIlVBp.js +0 -77
  312. package/dist/gateway/static/root/assets/app-link-1j40sJ-z.js +0 -1
  313. package/dist/gateway/static/root/assets/apps-page-vgS1CHDj.js +0 -1
  314. package/dist/gateway/static/root/assets/attachment-load-qjPpQzYY.js +0 -1
  315. package/dist/gateway/static/root/assets/automation-task-card-MnzgyTVA.js +0 -3
  316. package/dist/gateway/static/root/assets/automations-workspace-C3xZLafX.js +0 -9
  317. package/dist/gateway/static/root/assets/browser-settings-page-BD1uF_Nb.js +0 -3
  318. package/dist/gateway/static/root/assets/capabilities-BGE6hiUE.js +0 -1
  319. package/dist/gateway/static/root/assets/capabilities-page-Bda4mSdf.js +0 -2
  320. package/dist/gateway/static/root/assets/capabilities-settings-panel-B2B7no22.js +0 -8
  321. package/dist/gateway/static/root/assets/channels-NtsjZThx.js +0 -1
  322. package/dist/gateway/static/root/assets/chat-page-BnOCCAXG.js +0 -72
  323. package/dist/gateway/static/root/assets/composer-payload-handoff-CQc-VTaL.js +0 -1
  324. package/dist/gateway/static/root/assets/confirm-dialog-XGclfBqe.js +0 -1
  325. package/dist/gateway/static/root/assets/connected-providers-grid-CcXe9kz5.js +0 -1
  326. package/dist/gateway/static/root/assets/connectors-page-Ci0L2How.js +0 -1
  327. package/dist/gateway/static/root/assets/dependency-picker-cbC6-2Ya.js +0 -1
  328. package/dist/gateway/static/root/assets/device-pairing-wizard-_3BJFWVQ.js +0 -1
  329. package/dist/gateway/static/root/assets/dist-CaUuvp8-.js +0 -1
  330. package/dist/gateway/static/root/assets/dist-D3lWNSe7.js +0 -1
  331. package/dist/gateway/static/root/assets/dist-DfWfZ9iu.js +0 -1
  332. package/dist/gateway/static/root/assets/dist-DusecO_p.js +0 -1
  333. package/dist/gateway/static/root/assets/home-page-D6pCBY1V.js +0 -2
  334. package/dist/gateway/static/root/assets/index-Cc41XQid.css +0 -1
  335. package/dist/gateway/static/root/assets/index-CnOYR6jq.js +0 -11
  336. package/dist/gateway/static/root/assets/install-connector-dialog-BuNXON0P.js +0 -1
  337. package/dist/gateway/static/root/assets/local-app-workbench-page-CP-BkbB6.js +0 -1
  338. package/dist/gateway/static/root/assets/management-settings-I-pXv4ML.js +0 -1
  339. package/dist/gateway/static/root/assets/model-selector-CXcxc30J.js +0 -1
  340. package/dist/gateway/static/root/assets/note-detail-panel-CbpLXAVh.js +0 -5
  341. package/dist/gateway/static/root/assets/note-image-lightbox-cLGiF8oU.js +0 -1
  342. package/dist/gateway/static/root/assets/personal-page-CXR1Gy0x.js +0 -1
  343. package/dist/gateway/static/root/assets/phone-settings-page-vg65qilc.js +0 -1
  344. package/dist/gateway/static/root/assets/plugin-details-dialog-B3Hn2cbx.js +0 -1
  345. package/dist/gateway/static/root/assets/project-detail-page-Ch-ZMyTu.js +0 -7
  346. package/dist/gateway/static/root/assets/projects-page-B7cetxao.js +0 -1
  347. package/dist/gateway/static/root/assets/route-preload-Zc5Z3fNv.js +0 -2
  348. package/dist/gateway/static/root/assets/session-manager-ChUtTAoG.js +0 -23
  349. package/dist/gateway/static/root/assets/sessions-page-Bt52kBvJ.js +0 -1
  350. package/dist/gateway/static/root/assets/setup-status-panel-A6uMpGRy.js +0 -1
  351. package/dist/gateway/static/root/assets/share-link-dialog-D1otGSXD.js +0 -1
  352. package/dist/gateway/static/root/assets/shares-settings-Bmfadz8A.js +0 -1
  353. package/dist/gateway/static/root/assets/skills-page-BZklXTX9.js +0 -2
  354. package/dist/gateway/static/root/assets/task-detail-page-SjZGW1Dx.js +0 -2
  355. package/dist/gateway/static/root/assets/tracing-settings-page-MvG4SH64.js +0 -1
  356. package/dist/gateway/static/root/assets/use-composer-attachments-vDdxHtUb.js +0 -2
  357. package/dist/gateway/static/root/assets/use-file-preview-expanded-Ce2mgYme.js +0 -2
  358. package/dist/gateway/static/root/assets/user-model-page-DRSsn4EV.js +0 -2
  359. package/dist/gateway/static/root/assets/voice-transcribe-api-Bbyj0yGR.js +0 -1
  360. package/dist/gateway/static/root/assets/working-directory-picker-modal-CDZ1xh3o.js +0 -1
@@ -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-CiwuuyV8.js";import{a,i as o,n as s,o as c}from"./locale-store-Br7IfbXK.js";import{t as l}from"./createLucideIcon-DPHK1VkS.js";import{n as u,r as d}from"./popover-select-DD8fmrxH.js";import{t as f}from"./circle-check-C23XjkUj.js";import{t as p}from"./external-link-DjqjBmc3.js";import{t as m}from"./secret-input-BQvFXqzz.js";import{t as h}from"./loader-circle-CifKLtgG.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./cn-0WouolD0.js";import{t as v}from"./button-CnRSIP6m.js";import{t as y}from"./skeleton-BI5TyibZ.js";import{a as b,i as ee,n as x,o as te,r as ne,s as S,t as re}from"./dist-DfWfZ9iu.js";import{n as C}from"./interaction-BdhHBbYa.js";import{A as w,N as T,f as E,g as D,h as ie,j as O,k,p as A,w as j,z as M}from"./connectors-api-DEJU8mgn.js";import{s as N}from"./form-field-width-DJw_jULe.js";import{n as P}from"./electron-env-DHOGevH3.js";import{t as F}from"./oauth-provider-connect-C8BXow79.js";var I=l(`package-plus`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`M16 17h6`,key:`1ook5g`}],[`path`,{d:`M19 14v6`,key:`1ckrd5`}],[`path`,{d:`M21 10.535V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.675-.955`,key:`28k6lz`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]);function L(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,...t?{store:t}:{}}}var R=n(),z=e(t(),1),B=r();async function V(e,t){let n=await c(o(e),t);if(!n.ok)throw Error(n.error??`Connection request failed.`);return n.payload}function H({definition:e,instance:t,onClose:n,onChanged:r}){let i=s(e=>e.language)===`zh`,[c,l]=(0,z.useState)(t),[f,p]=(0,z.useState)(),[m,_]=(0,z.useState)(),[x,C]=(0,z.useState)(),[w,E]=(0,z.useState)(),[D,O]=(0,z.useState)(!1),[A,M]=(0,z.useState)(),N=c?.instanceId??e.id,P=(0,z.useCallback)(async()=>{let e=await V(`/api/connectors/${encodeURIComponent(N)}/accounts`);p(e),e.authorization&&_(e.authorization)},[N]);(0,z.useEffect)(()=>{c&&P().catch(e=>M(String(e)))},[c,P]);let F=m&&[`preparing`,`awaiting_user`,`verifying`].includes(m.status);(0,z.useEffect)(()=>{if(!F||!m)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await V(`/api/connectors/authorizations/${m.id}`);if(e)return;_(t.authorization),t.authorization.status===`succeeded`&&(await P(),c&&await r(c))}catch(t){e||M(String(t))}finally{t=!1}}},i=()=>{n()},a=()=>{document.visibilityState===`visible`&&i()};i();let o=setInterval(i,1500);return window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,a),()=>{e=!0,clearInterval(o),window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,a)}},[F,m?.id,c,r,P]);let I=m?.challenge?.type===`qr_code`?m.challenge.artifactId:void 0;(0,z.useEffect)(()=>{if(!I){C(void 0);return}let e=!1,t;return a(o(`/api/connectors/authorizations/${I}/artifact`)).then(async n=>{if(!n.ok)throw Error(`QR code unavailable.`);let r=await n.blob();e||(t=URL.createObjectURL(r),C(t))}).catch(t=>{e||M(String(t))}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},[I]);let L=async t=>{O(!0),M(void 0);try{let n=c??await ie(e.id,{});l(n);let r=await V(`/api/connectors/${encodeURIComponent(n.instanceId)}/authorizations`,{method:`POST`,body:JSON.stringify({accountId:t})});_(r.authorization)}catch(e){M(e instanceof Error?e.message:String(e))}finally{O(!1)}},R=async e=>{O(!0),M(void 0);try{await V(`/api/connectors/${encodeURIComponent(N)}/policy`,{method:`PATCH`,body:JSON.stringify({maxScope:e})}),await P()}catch(e){M(String(e))}finally{O(!1)}},H=async e=>{O(!0),M(void 0);try{await V(`/api/connectors/accounts/${encodeURIComponent(e)}`,{method:`DELETE`}),await P()}catch(e){M(String(e))}finally{O(!1)}},U=async e=>{if(c){O(!0),M(void 0);try{if(e===`remove`)await j(N),await r(c),n();else if(e===`toggle`){let e=await k(N,!c.enabled);l(e),await r(e)}else{let e=await T(N);E(e.ok?i?`验证通过,可用操作:${e.toolCount}`:`Verified: ${e.toolCount} actions`:e.error??e.action??e.status)}}catch(e){M(String(e))}finally{O(!1)}}},W=()=>{c&&r(c),n()};return(0,B.jsx)(re,{open:!0,onOpenChange:e=>{e||W()},children:(0,B.jsxs)(te,{children:[(0,B.jsx)(b,{className:`fixed inset-0 z-50 bg-black/40`}),(0,B.jsxs)(ne,{className:`fixed left-1/2 top-1/2 z-50 flex h-[min(38rem,calc(100dvh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay text-fg`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge p-5`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(S,{className:`font-semibold`,children:e.displayName}),(0,B.jsx)(ee,{className:`mt-1 text-sm text-fg-muted`,children:i?`连接账号并设置允许的操作。`:`Connect an account and choose allowed actions.`})]}),(0,B.jsx)(v,{variant:`ghost`,onClick:W,"aria-label":i?`关闭`:`Close`,children:(0,B.jsx)(g,{className:`size-4`})})]}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:[A?(0,B.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:A}):null,c&&!f?(0,B.jsx)(y,{className:`h-24 w-full`}):null,c?(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(v,{disabled:D||!!F,onClick:()=>void U(`toggle`),children:c.enabled?i?`停用`:`Disable`:i?`启用`:`Enable`}),(0,B.jsx)(v,{disabled:D||!!F||!c.enabled,onClick:()=>void U(`test`),children:i?`检查连接`:`Check connection`}),(0,B.jsx)(v,{variant:`ghost`,disabled:D||!!F,onClick:()=>void U(`remove`),children:i?`移除连接`:`Remove connection`})]}):null,w?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:w}):null,f?.accounts.map(e=>(0,B.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium`,children:e.label??e.id}),(0,B.jsx)(`p`,{className:`break-all text-xs text-fg-muted`,children:String(e.identity.openId??e.identity.botId??e.identity.userId??e.id)}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.enabled&&e.status===`active`?i?`已连接`:`Connected`:i?`已断开`:`Disconnected`}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(v,{variant:`secondary`,disabled:D||!!F||c?.enabled===!1,onClick:()=>void L(e.id),children:i?`重新连接`:`Reconnect`}),(0,B.jsx)(v,{variant:`ghost`,disabled:D||!!F||!e.enabled,onClick:()=>void H(e.id),children:i?`断开本地连接`:`Disconnect locally`})]})]},e.id)),f?.policy?(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`p`,{className:`text-sm`,children:i?`允许的操作`:`Allowed actions`}),(0,B.jsxs)(u,{value:f.policy.maxScope,onChange:e=>void R(e.target.value),disabled:D,children:[(0,B.jsx)(d,{value:`read`,children:i?`仅查看`:`Read only`}),(0,B.jsx)(d,{value:`write`,children:i?`查看并执行操作`:`Read and write`})]}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`写入操作需要确认。断开本地连接不会撤销第三方授权。`:`Writes require confirmation. Local disconnection does not revoke provider authorization.`})]}):null,m?(0,B.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,"aria-live":`polite`,children:[(0,B.jsx)(`p`,{className:`text-sm`,children:m.status===`succeeded`?i?`账号验证成功`:`Account verified`:m.status===`preparing`?i?`正在准备授权…`:`Preparing authorization…`:m.status===`verifying`?i?`授权已完成,正在验证账号…`:`Authorization complete. Verifying account…`:F?i?`请完成当前步骤,返回后会自动检查结果。`:`Complete this step. We will check the result when you return.`:m.error??(i?`授权已结束,请重新连接。`:`Authorization ended. Connect again.`)}),F&&m.challenge&&m.challenge.totalSteps>1?(0,B.jsxs)(`p`,{className:`text-sm font-medium`,children:[i?`第 ${m.challenge.step} / ${m.challenge.totalSteps} 步`:`Step ${m.challenge.step} of ${m.challenge.totalSteps}`,m.challenge.step>1?i?`:上一步已完成,请打开新的授权页面继续。`:`: Previous step complete. Open the new authorization page to continue.`:i?`:完成后还需要继续授权账号。`:`: Account authorization follows this step.`]}):null,F&&m.challenge?.type===`open_url`?(0,B.jsx)(`a`,{href:m.challenge.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-accent underline`,children:i?`打开授权页面`:`Open authorization page`},m.challenge.url):null,F&&I?x?(0,B.jsx)(`img`,{src:x,alt:i?`授权二维码`:`Authorization QR code`,className:`mx-auto size-56 bg-white object-contain`}):(0,B.jsx)(y,{className:`mx-auto size-56`}):null,F?(0,B.jsx)(v,{variant:`secondary`,onClick:()=>{V(`/api/connectors/authorizations/${m.id}/cancel`,{method:`POST`}).then(()=>_({...m,status:`cancelled`,challenge:void 0})).catch(e=>M(String(e)))},children:i?`取消授权`:`Cancel authorization`}):null]}):null]}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge p-4`,children:[(0,B.jsx)(v,{variant:`secondary`,onClick:W,children:i?`关闭`:`Close`}),(0,B.jsxs)(v,{disabled:D||!!F||c?.enabled===!1,onClick:()=>void L(),children:[D?(0,B.jsx)(h,{className:`mr-2 size-4 animate-spin`}):null,i?`连接账号`:`Connect account`]})]})]})]})})}function U(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function W(e,t){return e.runtime.type===`composio`?t.connectorDescriptions[e.runtime.toolkit.toLowerCase()]??e.description:e.description}function G(e){return e instanceof Error?e.message:String(e)}function K(e,t){let n=G(e);return/APIKey_InsufficientPermissions/i.test(n)||/["\\]?code["\\]?\s*:\s*812\b/i.test(n)||/session_management/i.test(n)&&/write access|write permission|at least ["\\]?write/i.test(n)?t.composioSessionWritePermissionRequired:n}var q={sm:{frame:`size-9 rounded-lg`,image:`size-7`,fallback:`size-4`},md:{frame:`size-10 rounded-xl`,image:`size-8`,fallback:`size-5`},lg:{frame:`size-12 rounded-xl`,image:`size-10`,fallback:`size-5`}};function J(e){let t=(0,R.c)(15),{connector:n,size:r,className:i}=e,a=r===void 0?`md`:r,o=n?.branding?.logoUrl,[s,c]=(0,z.useState)(!1),l=q[a],u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{c(!1)},t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=[o],t[1]=o,t[2]=d),(0,z.useEffect)(u,d);let f;t[3]!==i||t[4]!==l.frame?(f=_(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-white`,l.frame,i),t[3]=i,t[4]=l.frame,t[5]=f):f=t[5];let p=n?.displayName,m;t[6]!==l.fallback||t[7]!==l.image||t[8]!==s||t[9]!==o?(m=o&&!s?(0,B.jsx)(`img`,{src:o,alt:``,loading:`lazy`,draggable:!1,className:_(`object-contain`,l.image),onError:()=>c(!0)}):(0,B.jsx)(I,{className:_(`text-fg-muted`,l.fallback),"aria-hidden":!0}),t[6]=l.fallback,t[7]=l.image,t[8]=s,t[9]=o,t[10]=m):m=t[10];let h;return t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,B.jsx)(`span`,{className:f,title:p,children:m}),t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}var Y=_(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,N),ae=_(Y,`min-h-28 font-mono`);function oe(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function se(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function X({draft:e,onChange:t,onClose:n,onInstalled:r,t:a}){let{connector:o}=e,s=W(o,a),c=o.runtime.type===`composio`&&o.runtime.role===`toolkit`,l=o.runtime.type===`composio`&&o.runtime.role===`toolkit`?o.runtime.toolkit:null,k=o.understanding!=null,[j,N]=(0,z.useState)(!c),[L,R]=(0,z.useState)(null),[V,H]=(0,z.useState)(c),[G,q]=(0,z.useState)(null),[X,ce]=(0,z.useState)(null),[Z,le]=(0,z.useState)(!1),[Q,ue]=(0,z.useState)(!1);(0,z.useEffect)(()=>{if(!c)return;let e=!1;return E().then(t=>{e||(R(t),N(t.configured))}).catch(t=>{e||q(t instanceof Error?t.message:String(t))}).finally(()=>{e||H(!1)}),()=>{e=!0}},[o.id,c]),(0,z.useEffect)(()=>{if(!l||!j)return;let e=!1;return le(!0),A(l).then(t=>{e||ce(t)}).catch(t=>{e||q(t instanceof Error?t.message:String(t))}).finally(()=>{e||le(!1)}),()=>{e=!0}},[j,l]);let de=(0,z.useCallback)(async()=>{let n=P(),i=c&&!n?window.open(``,`_blank`):null;i&&(i.opener=null),q(null),t({...e,installing:!0,error:null,result:null,health:null});try{if(c&&!j)throw Error(a.composioSetupSignInRequired);let s=c&&l?X??await A(l):null,u=e.config.authConfigId?.trim();if(s?.requiresCustomAuthConfig&&!u)throw Error(a.composioAuthConfigRequired);if(u){let e=s?.authConfigs.find(e=>e.id===u);if(!e||e.status!==`ENABLED`||!e.isEnabledForToolRouter)throw Error(a.composioAuthConfigUnavailable)}let d={};for(let t of o.setup.config??[]){let n=se(t.type,e.config[t.key]??``);n!==void 0&&(d[t.key]=n)}u&&(d.authConfigId=u);let f=e.store?await D(e.store.packageName,{secrets:e.secrets,config:d},e.store.version,e.store.reviewHash):await ie(o.id,{secrets:e.secrets,config:d,definition:o.source===`registry`?o:void 0}),p=null;try{if(c){let e=await O(o.id);if(!e.authorizationUrl)throw Error(`The connection service did not return an authorization URL.`);if(n){let t=await window.electronAPI?.shell?.openExternalUrl(e.authorizationUrl);if(!t?.ok)throw Error(t?.error??`Could not open the system browser.`)}else i?i.location.href=e.authorizationUrl:window.open(e.authorizationUrl,`_blank`,`noopener,noreferrer`);let t=await M(l,e.connectionId,12e4,e.attemptId);if(i?.close(),k&&Q){if(!t.accountId)throw Error(`Connector account is unavailable.`);await w(t.accountId)}}}catch(n){i?.close(),t({...e,installing:!1,result:null,health:null,error:c?K(n,a):n instanceof Error?n.message:String(n)}),await r(f);return}if(f.materialized.type===`cli`||f.materialized.type===`mcp`)try{p=await T(f.instanceId)}catch{p=null}t({...e,installing:!1,result:f,health:p}),await r(f)}catch(n){i?.close(),t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[k,X,j,l,o,e,c,Q,t,r,a.composioAuthConfigRequired,a.composioAuthConfigUnavailable,a.composioSetupSignInRequired]),fe=X?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[],$=X?.requiresCustomAuthConfig===!0,pe=j&&$&&!e.config.authConfigId?.trim();return(0,B.jsx)(re,{open:!0,onOpenChange:e=>{e||n()},children:(0,B.jsxs)(te,{children:[(0,B.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,B.jsxs)(ne,{className:_(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,c?`max-h-[calc(100dvh-2rem)] w-[min(100%-2rem,32rem)]`:`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,42rem)]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float dark:border-edge`),children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,B.jsx)(J,{connector:o,size:`lg`}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(S,{className:`text-base font-semibold text-fg`,children:U(a.connectDialogTitle,{name:o.displayName})}),(0,B.jsx)(ee,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:s})]})]}),(0,B.jsx)(x,{asChild:!0,children:(0,B.jsxs)(`button`,{type:`button`,className:_(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,C.focusRingPanel),"aria-label":a.modalClose,children:[(0,B.jsx)(g,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,B.jsx)(`div`,{className:_(`min-h-0 overflow-y-auto px-6 py-5`,!c&&`flex-1`),children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[c&&V?(0,B.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,"aria-busy":`true`,"aria-label":a.composioSetupTitle,children:[(0,B.jsx)(y,{className:`h-4 w-40`}),(0,B.jsx)(y,{className:`mt-2 h-3 w-72 max-w-full`}),(0,B.jsx)(y,{className:`mt-3 h-16 w-full rounded-xl`})]}):c&&!j?(0,B.jsxs)(`section`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.composioSetupTitle}),(0,B.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:a.composioSetupHint}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(F,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:!1,onConnected:()=>{E().then(e=>{R(e),N(e.configured)})}})}),(0,B.jsx)(i,{to:`/settings/connector-service`,onClick:n,className:`mt-3 block text-xs text-accent-fg`,children:a.composioSetupByok})]}):null,c&&k?(0,B.jsxs)(`label`,{className:`flex items-start gap-3 rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,B.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-accent`,checked:Q,onChange:e=>ue(e.currentTarget.checked)}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:a.learnAfterConnect}),(0,B.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:a.learnAfterConnectHint})]})]}):null,c&&j&&L?.mode===`managed`?(0,B.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:$?a.composioCloudAuthUnavailable:a.composioSetupManaged}):null,c&&j&&L?.mode===`byok`?(0,B.jsxs)(`details`,{open:$,className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:a.composioAdvancedSettings}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.composioAuthConfigTitle}),(0,B.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:$?a.composioAuthConfigRequiredHint:a.composioAuthConfigManaged})]}),L?.mode===`byok`?(0,B.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:[a.composioAuthConfigManage,(0,B.jsx)(p,{className:`size-3.5`,"aria-hidden":!0})]}):(0,B.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:a.composioSetupManaged})]}),Z?(0,B.jsx)(y,{className:`mt-3 h-10 w-full`}):(0,B.jsxs)(u,{className:_(Y,`mt-3`),value:e.config.authConfigId??``,onChange:n=>t({...e,config:{...e.config,authConfigId:n.currentTarget.value},error:null}),children:[$?null:(0,B.jsx)(d,{value:``,children:a.composioAuthConfigManaged}),$&&!e.config.authConfigId?(0,B.jsx)(d,{value:``,disabled:!0,children:a.composioAuthConfigSelect}):null,fe.map(e=>(0,B.jsxs)(d,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`,` · `,e.id]},e.id))]}),!Z&&$&&fe.length===0?(0,B.jsx)(`p`,{className:`mt-2 text-xs text-amber-700 dark:text-amber-300`,children:a.composioAuthConfigEmpty}):null]}):null,c&&j&&L?.mode===`byok`?(0,B.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:a.composioSessionWritePermissionHint}):null,e.store?(0,B.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailPermissions}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,B.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,B.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,B.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:a.storeLocalExecDenied})]})]}):null,(o.setup.links??[]).length>0?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2 rounded-xl border border-edge bg-surface-base p-3`,children:(o.setup.links??[]).map(e=>{let t=e.external!==!1&&/^https:\/\//i.test(e.href);return(0,B.jsxs)(`a`,{href:t?e.href:`#${e.href}`,target:t?`_blank`:void 0,rel:t?`noopener noreferrer`:void 0,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent-fg hover:underline`,children:[e.label,t?(0,B.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}):null]},`${e.label}:${e.href}`)})}):null,(o.setup.secrets??[]).map(n=>(0,B.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,B.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,B.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,B.jsx)(m,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:a.secretInputLabels,placeholder:n.required?a.requiredPlaceholder:a.optionalPlaceholder})]},n.key)),(o.setup.config??[]).map(n=>(0,B.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,B.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,B.jsx)(`textarea`,{className:ae,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,B.jsx)(`input`,{className:Y,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,B.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,B.jsx)(h,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),a.connectingTitle]}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.connectingHint})]}):null,e.error?(0,B.jsx)(`p`,{className:`min-w-0 max-w-full break-words rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600 [overflow-wrap:anywhere]`,children:e.error}):null,G?(0,B.jsx)(`p`,{className:`min-w-0 max-w-full break-words rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600 [overflow-wrap:anywhere]`,children:G}):null,e.result?(0,B.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsx)(`div`,{children:(0,B.jsx)(`p`,{className:`font-medium text-fg`,children:a.connectedBadge})}),(0,B.jsx)(`span`,{className:_(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?a.healthStatusHealthy:oe(e.health?.status,a)})]}),(0,B.jsx)(`p`,{className:`mt-3`,children:e.health?.ok?a.connectionReady:e.health?a.connectionNeedsSetup:a.installedWithoutHealth}),e.health?.action?(0,B.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})}),(0,B.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,B.jsxs)(v,{variant:`primary`,disabled:!!e.result||e.installing||V||Z||pe||c&&!j,onClick:()=>void de(),children:[e.installing?(0,B.jsx)(h,{className:`size-4 animate-spin`}):e.result?(0,B.jsx)(f,{className:`size-4`}):(0,B.jsx)(I,{className:`size-4`}),e.result?a.connectedBadge:a.connect]})})]})]})})}function ce(e){let t=(0,R.c)(2),n;return t[0]===e?n=t[1]:(n=e.draft.connector.runtime.type===`cli`?(0,B.jsx)(H,{definition:e.draft.connector,onClose:e.onClose,onChanged:e.onInstalled}):(0,B.jsx)(X,{...e}),t[0]=e,t[1]=n),n}export{U as a,I as c,W as i,J as n,H as o,K as r,L as s,ce as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a,u as o}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as s,n as c}from"./locale-store-Br7IfbXK.js";import{t as ee}from"./resource-unavailable-TQcRCpAg.js";import{t as l}from"./arrow-left-D880xG-P.js";import{t as u}from"./check-DUBLcKHA.js";import{t as te}from"./circle-check-C23XjkUj.js";import{t as d}from"./circle-x-DFsCKeya.js";import{t as f}from"./clock-3-DnrAnuyZ.js";import{t as p}from"./external-link-DjqjBmc3.js";import{n as m,r as h,t as ne}from"./power-off-CwwQ7Gp7.js";import{t as g}from"./folder-kanban-CpLlFI1o.js";import{t as re}from"./history-DXH_9jsE.js";import{t as _}from"./loader-circle-CifKLtgG.js";import{t as v}from"./panel-left-C8MqSXRZ.js";import{t as y}from"./power-ZI-pBczI.js";import{t as ie}from"./refresh-cw-BRlGaq2w.js";import{t as ae}from"./rotate-ccw-JM1TBLpp.js";import{t as b}from"./shield-check-BU58siTV.js";import{t as x}from"./sparkles-DHlfQFAF.js";import{t as S}from"./trash-2-DusmjVPV.js";import{t as oe}from"./triangle-alert-2JXFNNKU.js";import{t as se}from"./x-B_N4OPjy.js";import{t as C}from"./button-CnRSIP6m.js";import{t as ce}from"./skeleton-BI5TyibZ.js";import{a as le,i as ue,n as w,o as de,r as fe,s as pe,t as me}from"./dist-DfWfZ9iu.js";import{a as he,i as ge}from"./vendor-swr-CdRzEUwF.js";import{a as _e}from"./local-apps-Ck6kACsY.js";import{u as ve}from"./api-C3Tp9MkF.js";import{t as ye}from"./page-header-store-Du44NIEJ.js";import{a as be,c as xe,d as Se,l as Ce,n as we,r as Te,s as Ee,t as De,u as Oe}from"./api-CRT9ZyH0.js";import{n as ke,r as Ae,t as je}from"./runtime-health-D2TDFLLq.js";import{r as Me}from"./date-formatters-DukWSVwc.js";import{n as Ne,t as Pe}from"./tab-completion-input-CxtEp0aP.js";import{t as Fe}from"./page-context-capture-button-CBFK41OS.js";var T=e(t(),1);function Ie(e){return e.replace(/^(?:例如\s*[::]?|for example\s*[::]?|e\.g\.\s*)/i,``).replace(/…$/,``).trim()}var Le=`build-xopc-local-app`;function E(e){return(e.routing?.agentId??e.agentId??``).trim().toLowerCase()}function Re(e){return e.find(e=>E(e)===`coder`)??null}function ze(e,t){let n=new URLSearchParams({skill:Le}),r=t?.trim();return r&&n.set(`draft`,r),`/chat/${encodeURIComponent(e)}?${n.toString()}`}var Be=n(),D=r();function Ve(e){let t=(0,Be.c)(36),{scenarios:n,results:r,runningTarget:i,zh:a,onRunAll:o,onRunScenario:s,onAskCoder:c}=e;if(!n.length)return null;let ee=a?`产品场景`:`Product scenarios`,l;t[0]===ee?l=t[1]:(l=(0,D.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:ee}),t[0]=ee,t[1]=l);let u=a?`${n.length} 个关键用户路径`:`${n.length} critical user journey${n.length===1?``:`s`}`,p;t[2]===u?p=t[3]:(p=(0,D.jsx)(`p`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:u}),t[2]=u,t[3]=p);let h;t[4]!==l||t[5]!==p?(h=(0,D.jsxs)(`div`,{children:[l,p]}),t[4]=l,t[5]=p,t[6]=h):h=t[6];let ne=i!==null,g;t[7]===i?g=t[8]:(g=i===`all`?(0,D.jsx)(_,{className:`size-3 animate-spin`}):(0,D.jsx)(ie,{className:`size-3`}),t[7]=i,t[8]=g);let re=a?`全部重跑`:`Run all`,v;t[9]!==o||t[10]!==ne||t[11]!==g||t[12]!==re?(v=(0,D.jsxs)(C,{variant:`ghost`,className:`h-7 rounded-lg px-2 text-[11px]`,onClick:o,disabled:ne,children:[g,re]}),t[9]=o,t[10]=ne,t[11]=g,t[12]=re,t[13]=v):v=t[13];let y;t[14]!==h||t[15]!==v?(y=(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[h,v]}),t[14]=h,t[15]=v,t[16]=y):y=t[16];let ae=a?`产品场景验收结果`:`Product scenario acceptance results`,b;if(t[17]!==c||t[18]!==s||t[19]!==r||t[20]!==i||t[21]!==n||t[22]!==a){let e;t[24]!==c||t[25]!==s||t[26]!==r||t[27]!==i||t[28]!==a?(e=e=>{let t=r[e.id],n=i===`all`||i===e.id?`running`:t?.status??`pending`;return(0,D.jsx)(`li`,{className:`py-2.5 first:pt-1`,children:(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:n===`running`?(0,D.jsx)(_,{className:`size-3.5 animate-spin text-accent`}):n===`passed`?(0,D.jsx)(te,{className:`size-3.5 text-success`}):n===`failed`?(0,D.jsx)(d,{className:`size-3.5 text-danger`}):(0,D.jsx)(f,{className:`size-3.5 text-fg-subtle`})}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`truncate text-[11px] font-medium text-fg`,children:e.name}),(0,D.jsx)(`p`,{className:`mt-0.5 text-[10px] text-fg-subtle`,children:a?`${e.stepCount} 个步骤`:`${e.stepCount} step${e.stepCount===1?``:`s`}`})]}),(0,D.jsx)(C,{variant:`ghost`,className:`size-7 shrink-0 rounded-lg p-0`,onClick:()=>s(e.id),disabled:i!==null,"aria-label":a?`重跑${e.name}`:`Rerun ${e.name}`,title:a?`单独重跑`:`Rerun scenario`,children:(0,D.jsx)(ie,{className:`size-3`})})]}),n===`running`?(0,D.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`正在隔离预览中执行…`:`Running in an isolated preview…`}):t?.status===`failed`?(0,D.jsxs)(`div`,{className:`mt-1.5`,children:[(0,D.jsx)(`p`,{className:`text-[11px] leading-4 text-danger`,children:t.message}),(0,D.jsxs)(C,{variant:`ghost`,className:`mt-1 h-7 rounded-lg px-2 text-[11px] text-danger hover:text-danger`,onClick:()=>c(e,t),children:[(0,D.jsx)(m,{className:`size-3`}),a?`让 Coder 修复`:`Ask Coder to fix`]})]}):t?.status===`passed`?(0,D.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`场景已通过`:`Scenario passed`}):(0,D.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`等待运行`:`Waiting to run`})]})]})},e.id)},t[24]=c,t[25]=s,t[26]=r,t[27]=i,t[28]=a,t[29]=e):e=t[29],b=n.map(e),t[17]=c,t[18]=s,t[19]=r,t[20]=i,t[21]=n,t[22]=a,t[23]=b}else b=t[23];let x;t[30]!==ae||t[31]!==b?(x=(0,D.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,"aria-label":ae,children:b}),t[30]=ae,t[31]=b,t[32]=x):x=t[32];let S;return t[33]!==y||t[34]!==x?(S=(0,D.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[y,x]}),t[33]=y,t[34]=x,t[35]=S):S=t[35],S}var He=`allow-scripts allow-forms`;function Ue(e,t){return Me(e,t)}function We(e,t,n){return!!(t&&n&&e.sourceHash===t&&e.status===n.status&&e.interactiveCount===n.interactiveCount&&JSON.stringify(e.checks)===JSON.stringify(n.checks))}function Ge(){let{appId:e}=i(),t=e===`new`,n=c(e=>e.language)===`zh`,r=c(e=>e.language),d=o(),{mutate:f}=he(),Me=ye(e=>e.setPageHeader),Le=ye(e=>e.clearPageHeader),{data:E,isLoading:Be,error:Ge,mutate:Ke}=ge(!t&&e?[`local-app`,e]:null,()=>we(e)),{data:O,isLoading:qe,mutate:Je}=ge(!t&&e?[`local-app-validation`,e]:null,()=>Se(e)),[Ye,Xe]=(0,T.useState)(``),[Ze,Qe]=(0,T.useState)(``),[k,A]=(0,T.useState)(!1),[j,M]=(0,T.useState)(null),[$e,et]=(0,T.useState)(!1),[tt,nt]=(0,T.useState)(!1),[rt,it]=(0,T.useState)(0),[at,ot]=(0,T.useState)(``),[N,st]=(0,T.useState)(!1),[P,ct]=(0,T.useState)(!1),[F,I]=(0,T.useState)(`booting`),[L,lt]=(0,T.useState)(null),[R,ut]=(0,T.useState)(null),[z,dt]=(0,T.useState)({}),[B,ft]=(0,T.useState)(`all`),[V,H]=(0,T.useState)(0),[pt,mt]=(0,T.useState)(0),[ht,U]=(0,T.useState)(null),[W,gt]=(0,T.useState)(null),[_t,vt]=(0,T.useState)([]),[yt,G]=(0,T.useState)(!1),bt=(0,T.useRef)(new Set),K=(0,T.useRef)(null),xt=(0,T.useRef)(null),St=(0,T.useRef)(null),q=(0,T.useRef)(null),J=(0,T.useRef)(``),Y=O?.acceptanceScenarios??[],X=(0,T.useMemo)(()=>{if(!Y.length)return null;let e=Y.map(e=>z[e.id]).filter(e=>!!e);return e.length===Y.length?{status:e.some(e=>e.status===`failed`)?`failed`:`passed`,scenarioCount:Y.length,scenarios:e}:null},[Y,z]),Z=(0,T.useMemo)(()=>{if(!R)return null;if(!O?.acceptanceScenarioCount)return R;if(!X)return null;let e=X.scenarios.find(e=>e.status===`failed`),t={id:`criteria`,status:X.status,message:e?`${e.name}: ${e.message}`:`${X.scenarioCount} product scenario(s) passed`},n=[...R.checks,t];return{status:n.some(e=>e.status===`failed`)?`failed`:`passed`,checks:n,interactiveCount:R.interactiveCount}},[R,X,O?.acceptanceScenarioCount]),Ct=(0,T.useCallback)(async(e,t)=>{let n=Re(await ve(e.projectId));if(!n){let n=new URLSearchParams({projectId:e.projectId,...t?{draft:t}:{}});d(`/chat/new?${n}`,{state:{agentId:`coder`,forceNewChat:!0}});return}bt.current.add(n.key),d(ze(n.key,t))},[d]),wt=(0,T.useCallback)(async(e=!0)=>{if(!E)return null;ct(!0);try{let t=await Se(E.id);return await Je(t,{revalidate:!1}),e&&(q.current=t.sourceHash??null,ft(`all`),H(0),it(e=>e+1)),t}catch(e){return M(e instanceof Error?e.message:String(e)),null}finally{ct(!1)}},[E,Je]);(0,T.useEffect)(()=>{if(!E)return;let e=!1;ve(E.projectId).then(t=>{e||(bt.current=new Set(t.filter(e=>(e.routing?.agentId??e.agentId)?.toLowerCase()===`coder`).map(e=>e.key)))}).catch(()=>{});let t=e=>{let t=e.detail?.key;!t||!bt.current.has(t)||(K.current!==null&&window.clearTimeout(K.current),K.current=window.setTimeout(()=>{K.current=null,wt(!0)},750))};return window.addEventListener(`session-transcript-updated`,t),()=>{e=!0,window.removeEventListener(`session-transcript-updated`,t),K.current!==null&&window.clearTimeout(K.current)}},[E,wt]),(0,T.useEffect)(()=>{vt(E?.acceptanceRuns??[])},[E?.acceptanceRuns]),(0,T.useEffect)(()=>{q.current=null},[E?.id]),(0,T.useEffect)(()=>{!O?.sourceHash||q.current===O.sourceHash||(q.current=O.sourceHash,ft(`all`),H(0),it(e=>e+1))},[E?.id,O?.sourceHash]),(0,T.useLayoutEffect)(()=>{if(!E)return;I(`booting`),lt(null),ut(null),gt(null),G(!1),J.current=``;let e=window.setTimeout(()=>I(e=>e===`failed`?e:`timeout`),7e3),t=xt.current?Ae(xt.current,t=>{let n=_e(t);if(n){if(n.type===`ready`){I(e=>e===`failed`?e:`healthy`);return}if(n.type===`acceptance`){window.clearTimeout(e),ut(n.detail),gt(q.current);return}n.type!==`criteria`&&(window.clearTimeout(e),lt(n.detail),I(`failed`))}}):()=>{};return()=>{window.clearTimeout(e),t()}},[E,rt]),(0,T.useLayoutEffect)(()=>{if(!E||O?.status!==`healthy`||!Y.length){U(null);return}let e=B===`all`?Y[V]:Y.find(e=>e.id===B),t=e?[e]:[];if(!t.length)return;U(B),dt(e=>{if(B===`all`&&V===0)return{};let t={...e};return delete t[B],t});let r=!1,i=e=>{dt(n=>{let r={...n};for(let n of t)r[n.id]={id:n.id,name:n.name,status:`failed`,message:e,failureKind:`runner`};return r}),U(null)},a=window.setTimeout(()=>i(r?n?`场景在 10 秒内未完成。`:`Scenario did not finish within 10 seconds.`:n?`验收执行器未能连接,请重新验收。`:`The acceptance runner did not connect. Run acceptance again.`),1e4),o=St.current?Ae(St.current,e=>{let t=_e(e);t&&(t.type===`ready`?r=!0:t.type===`criteria`?(window.clearTimeout(a),dt(e=>{let n={...e};for(let e of t.detail.scenarios)(n[e.id]?.status!==`failed`||e.status===`failed`)&&(n[e.id]=e);return n}),B===`all`&&V+1<Y.length?(H(e=>e+1),mt(e=>e+1)):U(null)):t.type===`error`&&(window.clearTimeout(a),i(je(t.detail))))}):()=>{};return()=>{window.clearTimeout(a),o()}},[Y,E,pt,B,V,rt,O?.status,n]),(0,T.useEffect)(()=>{if(!E||!Z||!W||W!==O?.sourceHash)return;let e=`${E.id}:${W}:${JSON.stringify(Z)}`;J.current!==e&&(J.current=e,G(!0),Ee(E.id,W,Z).then(t=>{J.current===e&&vt(e=>[t,...e.filter(e=>e.id!==t.id)].toSorted((e,t)=>t.createdAt-e.createdAt).slice(0,20))}).catch(t=>{J.current===e&&(J.current=``,G(!1),M(t instanceof Error?t.message:String(t)))}).finally(()=>{J.current===e&&G(!1)}))},[Z,W,E,O?.sourceHash]);let Q=(0,T.useCallback)(async e=>{if(E){st(!0),M(null);try{await Ct(E,e)}catch(e){M(e instanceof Error?e.message:String(e)),st(!1)}}},[E,Ct]);(0,T.useLayoutEffect)(()=>(Me({startExtra:(0,D.jsx)(a,{to:`/local-apps`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`返回应用工坊`:`Back to App Studio`,children:(0,D.jsx)(l,{className:`size-4`})}),main:(0,D.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:E?.name||(t?n?`创建应用`:`Create app`:n?`应用详情`:`App details`)}),end:E?(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(Fe,{resource:{kind:`local_app`,id:E.id,revision:O?.sourceHash??``},disabled:k||N||P||!O?.sourceHash}),(0,D.jsx)(C,{asChild:!0,variant:`ghost`,className:`h-9`,children:(0,D.jsxs)(a,{to:`/projects/${encodeURIComponent(E.projectId)}`,children:[(0,D.jsx)(g,{className:`size-4`}),n?`项目`:`Project`]})}),(0,D.jsxs)(C,{className:`h-9`,onClick:()=>void Q(),disabled:N,children:[N?(0,D.jsx)(_,{className:`size-4 animate-spin`}):(0,D.jsx)(m,{className:`size-4`}),n?`继续开发`:`Continue building`]})]}):null}),()=>Le()),[E,t,k,N,P,O?.sourceHash,Le,Q,Me,n]);async function Tt(e){e.preventDefault(),A(!0),M(null);try{let e=await De({name:Ye,idea:Ze});await f(`local-apps-list`);let t=n?`请基于 APP_BRIEF.md 完成这个本地应用的首版。先检查现有草稿,再实现最小可用版本并运行校验;完成后告诉我可以如何预览。`:`Build the first usable version of this local app from APP_BRIEF.md. Inspect the existing draft, implement the smallest useful version, run validation, and tell me how to preview it.`;try{await Ct(e,t)}catch{d(`/local-apps/${encodeURIComponent(e.id)}`,{replace:!0})}}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}}async function Et(){if(E){A(!0),M(null);try{let e=await be(E.id);await Ke(e,{revalidate:!1}),await Je(),await Promise.all([f(`local-apps-list`),f(`gateway-extensions-list`)]),et(!1)}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}}}async function Dt(e){A(!0),M(null);try{let t=await e();return await Ke(t,{revalidate:!1}),await Je(),await Promise.all([f(`local-apps-list`),f(`gateway-extensions-list`)]),!0}catch(e){return M(e instanceof Error?e.message:String(e)),!1}finally{A(!1)}}async function Ot(e){E&&await Dt(()=>Ce(E.id,e))}async function kt(e){E&&await Dt(()=>xe(E.id,e))}async function At(){E&&await Dt(()=>Oe(E.id))&&nt(!1)}async function jt(e){if(!(!E||!e.length)){M(null);try{let t=await Te(E.id,{sourceHash:O?.sourceHash,locale:n?`zh`:`en`,diagnostics:e});await Q(t.prompt)}catch(e){M(e instanceof Error?e.message:String(e))}}}function Mt(){jt([...O?.issues.map(e=>({phase:`build`,code:e.code,message:e.message}))??[],...L?[{phase:`runtime`,code:L.kind,message:je(L)}]:[],...Z?.checks.filter(e=>e.status===`failed`&&e.id!==`criteria`).map(e=>({phase:`acceptance`,code:e.id,message:e.message}))??[],...Object.values(z).filter(e=>e.status===`failed`).map(e=>({phase:e.failureKind===`runner`?`runner`:`acceptance`,code:e.id,message:`${e.name}: ${e.message}`})),...F===`timeout`?[{phase:`boot`,code:`boot_timeout`,message:`Preview did not report ready within 7 seconds.`}]:[]])}function Nt(){ft(`all`),H(0),mt(e=>e+1)}function Pt(e){ft(e),H(0),mt(e=>e+1)}function Ft(e,t){jt([{phase:t.failureKind===`runner`?`runner`:`acceptance`,code:e.id,message:`${e.name}: ${t.message}`}])}let It=_t.findIndex(e=>We(e,W,Z)),$=It>=0?_t[It]:null,Lt=It>=0?_t[It+1]??null:_t[0]??null,Rt=ke(Z),zt=Lt?Lt.checks.filter(e=>e.status===`failed`).map(e=>e.message):[],Bt=O?.status===`failed`||F===`failed`||F===`timeout`||Z?.status===`failed`||Object.values(z).some(e=>e.status===`failed`),Vt=zt.filter(e=>!Rt.includes(e)).length;async function Ht(){let e=await wt(!1);if(e?.status===`healthy`&&e.sourceHash!==W){q.current=e.sourceHash??null,H(0),it(e=>e+1);return}e?.status===`healthy`&&F===`healthy`&&Z?.status===`passed`&&$&&$.sourceHash===e.sourceHash&&et(!0)}return t?(0,D.jsx)(`div`,{className:`flex min-h-0 flex-1 bg-surface-panel p-3 sm:p-5 xl:p-6`,children:(0,D.jsxs)(`div`,{className:`grid w-full min-w-0 overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-surface lg:grid-cols-[minmax(280px,0.8fr)_minmax(0,1.5fr)]`,children:[(0,D.jsxs)(`form`,{onSubmit:Tt,className:`flex flex-col border-b border-edge-subtle p-5 lg:border-b-0 lg:border-r`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.14em] text-accent`,children:[(0,D.jsx)(x,{className:`size-4`}),n?`告诉编程智能体你的想法`:`Tell Coder your idea`]}),(0,D.jsx)(`h2`,{className:`mt-4 text-xl font-semibold tracking-tight text-fg`,children:n?`你想创建什么?`:`What do you want to create?`}),(0,D.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n?`我们会创建项目,并在对话中由编程智能体根据你的想法开发应用。`:`We will create a Coder Project and carry the app context and development skill into chat.`}),(0,D.jsxs)(`label`,{className:`mt-6 text-xs font-medium text-fg-muted`,children:[n?`应用名称`:`App name`,(0,D.jsx)(Pe,{value:Ye,onChange:e=>Xe(e.target.value),suggestion:Ie(n?`例如:阅读清单`:`e.g. Reading list`),onAcceptSuggestion:Xe,required:!0,className:`mt-2 w-full rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`例如:阅读清单`:`e.g. Reading list`})]}),(0,D.jsxs)(`label`,{className:`mt-4 text-xs font-medium text-fg-muted`,children:[n?`描述你的想法`:`Describe your idea`,(0,D.jsx)(Ne,{value:Ze,onChange:e=>Qe(e.target.value),suggestion:Ie(n?`我想要一个可以记录待读文章、标记进度并按主题筛选的小工具…`:`I want a small tool that tracks articles, reading progress, and topics…`),onAcceptSuggestion:Qe,required:!0,rows:7,className:`mt-2 w-full resize-none rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm leading-6 text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`我想要一个可以记录待读文章、标记进度并按主题筛选的小工具…`:`I want a small tool that tracks articles, reading progress, and topics…`})]}),j?(0,D.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:j}):null,(0,D.jsxs)(C,{type:`submit`,variant:`primary`,className:`mt-5 h-10`,disabled:k||!Ye.trim()||!Ze.trim(),children:[k?(0,D.jsx)(_,{className:`size-4 animate-spin`}):(0,D.jsx)(m,{className:`size-4`}),n?`开始开发对话`:`Continue with Coder`]})]}),(0,D.jsx)(`div`,{className:`hidden min-h-[620px] place-items-center bg-surface-panel p-8 lg:grid`,children:(0,D.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,D.jsx)(`div`,{className:`mx-auto flex size-16 items-center justify-center rounded-2xl border border-edge bg-surface-base text-accent shadow-surface`,children:(0,D.jsx)(v,{className:`size-7`})}),(0,D.jsx)(`h3`,{className:`mt-5 text-base font-semibold text-fg`,children:n?`创建后,这里就是实时预览`:`Your live preview appears here`}),(0,D.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n?`你可以先体验草稿,再决定是否把它添加到左侧导航。`:`Try the draft first, then decide whether to add it to the sidebar.`})]})})]})}):Be?(0,D.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 bg-surface-panel p-3 lg:grid-cols-[280px_minmax(0,1fr)_260px]`,children:[(0,D.jsx)(ce,{className:`rounded-xl`}),(0,D.jsx)(ce,{className:`rounded-xl`}),(0,D.jsx)(ce,{className:`rounded-xl`})]}):Ge||!E?(0,D.jsx)(ee,{kind:`app`,missing:!Ge||/not found|404/i.test(String(Ge)),backTo:`/local-apps`,retry:()=>void Ke()}):(0,D.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 overflow-hidden bg-surface-panel p-3 lg:grid-cols-[280px_minmax(0,1fr)_300px]`,children:[(0,D.jsxs)(`aside`,{className:`min-h-0 min-w-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.12em] text-accent`,children:[(0,D.jsx)(x,{className:`size-4`}),n?`创作对话`:`Build conversation`]}),(0,D.jsx)(`div`,{className:`mt-4 min-w-0 rounded-xl bg-surface-panel p-3 text-sm leading-6 text-fg [overflow-wrap:anywhere]`,children:E.idea}),(0,D.jsxs)(`div`,{className:`mt-4 rounded-xl bg-accent-soft p-3`,children:[(0,D.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium text-accent-fg`,children:[(0,D.jsx)(te,{className:`size-4`}),n?`草稿已准备好`:`Draft is ready`]}),(0,D.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`继续开发会打开对应项目的对话,编程智能体可以参考当前应用继续修改。`:`Continue in the Project where Coder has the app context and dedicated skill.`})]}),(0,D.jsxs)(`form`,{className:`mt-5`,onSubmit:e=>{e.preventDefault(),Q(at)},children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`local-app-change-request`,children:n?`下一步想改什么?`:`What should change next?`}),(0,D.jsx)(Ne,{id:`local-app-change-request`,value:at,onChange:e=>ot(e.target.value),suggestion:Ie(n?`例如:增加月视图,并支持按标签筛选`:`e.g. Add a monthly view and tag filters`),onAcceptSuggestion:ot,rows:4,className:`mt-2 w-full resize-none rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm leading-6 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`例如:增加月视图,并支持按标签筛选`:`e.g. Add a monthly view and tag filters`}),(0,D.jsxs)(C,{type:`submit`,className:`mt-2 w-full`,disabled:N||!at.trim(),children:[N?(0,D.jsx)(_,{className:`size-4 animate-spin`}):(0,D.jsx)(m,{className:`size-4`}),n?`让 Coder 修改`:`Ask Coder to update`]})]}),(0,D.jsxs)(C,{variant:`ghost`,className:`mt-2 w-full`,onClick:()=>void Q(),disabled:N,children:[(0,D.jsx)(g,{className:`size-4`}),n?`打开已有开发对话`:`Open development chat`]})]}),(0,D.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,D.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between border-b border-edge-subtle px-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`size-2 rounded-full ${O?.status===`failed`||F===`failed`||F===`timeout`||Z?.status===`failed`?`bg-danger`:O?.status===`healthy`&&F===`healthy`&&Z?.status===`passed`&&$?.sourceHash===O.sourceHash&&!yt?`bg-success`:`bg-fg-subtle`}`}),F===`failed`||F===`timeout`?n?`预览运行异常`:`Preview runtime issue`:O?.status===`failed`||Z?.status===`failed`?n?`自动验收未通过`:`Acceptance needs attention`:F===`booting`||!Z?n?`自动验收中`:`Running acceptance`:yt||$?.sourceHash!==O?.sourceHash?n?`正在保存验收快照`:`Saving acceptance snapshot`:n?`草稿已通过验收`:`Draft accepted`]}),(0,D.jsxs)(C,{variant:`ghost`,className:`h-8 px-2`,onClick:()=>void wt(!0),disabled:P,children:[P?(0,D.jsx)(_,{className:`size-3.5 animate-spin`}):(0,D.jsx)(ie,{className:`size-3.5`}),n?`重新验收`:`Run again`]})]}),(0,D.jsx)(`iframe`,{ref:xt,title:`${E.name} preview`,src:s(E.draftPreviewUrl),sandbox:He,className:`min-h-0 w-full flex-1 bg-white`,onError:()=>{lt({kind:`script_error`,message:`Preview document failed to load`}),I(`failed`)}},rt),O?.status===`healthy`&&O.acceptanceScenarioCount>0?(0,D.jsx)(`iframe`,{ref:St,title:`${E.name} acceptance runner`,src:`${s(E.draftPreviewUrl)}?xopcAcceptance=1&xopcScenario=${encodeURIComponent(B===`all`?Y[V]?.id??``:B)}`,sandbox:He,"aria-hidden":`true`,tabIndex:-1,className:`pointer-events-none fixed left-[-200vw] top-0 h-[720px] w-[1024px] opacity-0`},`criteria-${rt}-${pt}-${V}`):null]}),(0,D.jsxs)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n?`发布状态`:`Release status`}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:E.installationState===`not_installed`?n?`尚未安装`:`Not installed`:E.enabled?n?`版本 ${E.activeVersion} 正在使用`:`Version ${E.activeVersion} is active`:n?`已禁用,版本仍保留`:`Disabled, release retained`})]}),(0,D.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full ${E.enabled?`bg-success`:`bg-fg-subtle`}`,"aria-hidden":!0})]}),(0,D.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 text-xs`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`当前草稿`:`Draft`}),(0,D.jsxs)(`dd`,{className:`mt-1 font-medium text-fg`,children:[`v`,E.draftVersion]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`已安装`:`Installed`}),(0,D.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:E.activeVersion?`v${E.activeVersion}`:`—`})]})]}),(0,D.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,D.jsx)(h,{className:`size-4 text-accent`}),n?`草稿检查`:`Draft checks`]}),qe||P?(0,D.jsx)(_,{className:`size-3.5 animate-spin text-fg-muted`}):O?.status===`healthy`?(0,D.jsx)(te,{className:`size-4 text-success`}):(0,D.jsx)(oe,{className:`size-4 text-danger`})]}),O?(0,D.jsxs)(`div`,{className:`mt-2`,children:[(0,D.jsx)(`p`,{className:`text-xs leading-5 ${O.status===`healthy`?`text-fg-muted`:`text-danger`}`,children:O.status===`healthy`?O.hasDraftChanges?n?`${O.changedFileCount} 个文件有改动,可以安装新版本。`:`${O.changedFileCount} changed files are ready for a new release.`:n?`草稿与当前安装版本一致。`:`Draft matches the installed release.`:O.issues[0]?.message}),O.changedFiles.length?(0,D.jsx)(`ul`,{className:`mt-2 space-y-1`,children:O.changedFiles.slice(0,4).map(e=>(0,D.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,D.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,O.changedFileCount>4?(0,D.jsx)(`p`,{className:`mt-1 text-[10px] text-fg-subtle`,children:n?`还有 ${O.changedFileCount-4} 个文件`:`${O.changedFileCount-4} more files`}):null,(0,D.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,D.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,D.jsx)(`span`,{className:`size-2 rounded-full ${F===`healthy`?`bg-success`:F===`booting`?`bg-fg-subtle`:`bg-danger`}`}),n?`预览运行`:`Preview runtime`]}),(0,D.jsx)(`p`,{className:`mt-1 text-xs leading-5 ${F===`failed`||F===`timeout`?`text-danger`:`text-fg-muted`}`,children:L?je(L):F===`healthy`?n?`已成功启动,未发现未捕获异常。`:`Started successfully with no uncaught errors.`:F===`timeout`?n?`7 秒内未完成启动,可能出现白屏或阻塞。`:`Did not finish booting within 7 seconds.`:n?`正在等待应用启动。`:`Waiting for the app to start.`})]}),(0,D.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,D.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,D.jsx)(`span`,{className:`size-2 rounded-full ${Z?.status===`passed`?`bg-success`:Z?.status===`failed`?`bg-danger`:`bg-fg-subtle`}`}),n?`自动验收`:`Automatic acceptance`]}),Z?(0,D.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:Z.checks.map(e=>(0,D.jsxs)(`li`,{className:`flex items-start gap-2 text-[11px] leading-4 ${e.status===`failed`?`text-danger`:`text-fg-muted`}`,children:[(0,D.jsx)(`span`,{className:`mt-1 size-1.5 shrink-0 rounded-full ${e.status===`failed`?`bg-danger`:e.status===`passed`?`bg-success`:`bg-fg-subtle`}`}),(0,D.jsx)(`span`,{children:e.message})]},e.id))}):(0,D.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:O?.acceptanceScenarioCount?n?`正在检查页面基础质量和 ${O.acceptanceScenarioCount} 个产品场景。`:`Checking page quality and ${O.acceptanceScenarioCount} product scenario(s).`:n?`正在检查页面内容和基础交互。`:`Checking rendered content and basic interaction.`}),yt?(0,D.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-[11px] text-fg-muted`,children:[(0,D.jsx)(_,{className:`size-3 animate-spin`}),n?`正在保存当前源码对应的验收快照…`:`Saving the acceptance snapshot for this source…`]}):$?(0,D.jsx)(`p`,{className:`mt-2 text-[11px] leading-4 text-fg-muted`,children:Lt?n?`相比上次:已修复 ${Vt} 项,仍有 ${Rt.length} 项。`:`Since the previous run: ${Vt} fixed, ${Rt.length} remaining.`:n?`首个验收快照已保存。`:`First acceptance snapshot saved.`}):null,(0,D.jsx)(Ve,{scenarios:Y,results:z,runningTarget:ht,zh:n,onRunAll:Nt,onRunScenario:Pt,onAskCoder:Ft})]}),Bt?(0,D.jsxs)(C,{className:`mt-3 w-full`,onClick:Mt,disabled:N,children:[(0,D.jsx)(m,{className:`size-4`}),n?`让 Coder 修复`:`Ask Coder to fix`]}):null]}):(0,D.jsx)(ce,{className:`mt-2 h-12 rounded-lg`})]}),(0,D.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,D.jsx)(b,{className:`size-4 text-accent`}),n?`权限`:`Permissions`]}),(0,D.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(O?.permissions??E.permissions).map(e=>(0,D.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] text-fg-muted`,children:e},e))})]}),(0,D.jsx)(C,{variant:`primary`,className:`mt-5 w-full`,onClick:()=>void Ht(),disabled:k||qe||P||yt||O?.status===`failed`||F!==`healthy`||Z?.status!==`passed`||!$||$.sourceHash!==O?.sourceHash||E.installationState===`installed`&&O?.hasDraftChanges===!1,children:E.installationState===`installed`?n?`安装当前更新`:`Install current update`:n?`添加到左侧导航`:`Add to sidebar`}),E.installationState===`installed`?(0,D.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,D.jsxs)(C,{className:`min-w-0 flex-1`,onClick:()=>void Ot(!E.enabled),disabled:k,children:[E.enabled?(0,D.jsx)(ne,{className:`size-4`}):(0,D.jsx)(y,{className:`size-4`}),E.enabled?n?`禁用`:`Disable`:n?`启用`:`Enable`]}),(0,D.jsx)(C,{variant:`ghost`,className:`text-danger hover:text-danger`,onClick:()=>nt(!0),disabled:k,"aria-label":n?`卸载应用`:`Uninstall app`,children:(0,D.jsx)(S,{className:`size-4`})})]}):null,(0,D.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4`,children:[(0,D.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,D.jsx)(re,{className:`size-4`}),n?`版本历史`:`Release history`]}),E.releases.length?(0,D.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,children:E.releases.map(e=>(0,D.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2.5`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-fg`,children:[`v`,e.version,e.isActive?(0,D.jsx)(`span`,{className:`rounded-full bg-success-soft px-1.5 py-0.5 text-[10px] text-success`,children:n?`当前`:`Active`}):null]}),(0,D.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-fg-subtle`,children:Ue(e.createdAt,r)})]}),e.isActive?null:(0,D.jsxs)(C,{variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:()=>void kt(e.id),disabled:k,children:[(0,D.jsx)(ae,{className:`size-3.5`}),n?`恢复`:`Restore`]})]},e.id))}):(0,D.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n?`安装首个版本后,可以从这里恢复。`:`Install the first version to enable recovery.`})]}),j?(0,D.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-danger`,role:`alert`,children:j}):null]}),(0,D.jsx)(me,{open:$e,onOpenChange:et,children:(0,D.jsxs)(de,{children:[(0,D.jsx)(le,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,D.jsxs)(fe,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex h-[min(560px,calc(100vh-32px))] w-[min(520px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-2xl focus:outline-none`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(pe,{className:`text-base font-semibold text-fg`,children:n?`确认安装到 XOPC`:`Confirm installation`}),(0,D.jsx)(ue,{className:`mt-1 text-sm text-fg-muted`,children:n?`当前草稿会成为左侧导航中的可用版本。`:`The current draft will become the version available in the sidebar.`})]}),(0,D.jsx)(w,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,D.jsx)(se,{className:`size-4`})})]}),(0,D.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,D.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,D.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:E.name}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:E.extensionId})]}),(0,D.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`本次迭代`:`This iteration`}),(0,D.jsxs)(`dl`,{className:`mt-2 grid grid-cols-2 gap-3 text-xs`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`文件变化`:`Changed files`}),(0,D.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:O?.changedFileCount??0})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`自动验收`:`Acceptance`}),(0,D.jsxs)(`dd`,{className:`mt-1 flex items-center gap-1.5 font-medium text-success`,children:[(0,D.jsx)(te,{className:`size-3.5`}),n?`已通过并保存`:`Passed and saved`]})]})]}),O?.changedFiles.length?(0,D.jsx)(`ul`,{className:`mt-3 space-y-1`,children:O.changedFiles.slice(0,5).map(e=>(0,D.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,D.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,(0,D.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`请求权限`:`Requested permissions`}),(0,D.jsx)(`ul`,{className:`mt-2 space-y-2`,children:(O?.permissions??E.permissions).map(e=>(0,D.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,D.jsx)(u,{className:`size-4 text-success`}),e,E.installationState===`installed`&&O?.permissionDelta.added.includes(e)?(0,D.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-[10px] text-warning`,children:n?`新增`:`New`}):null]},e))}),E.installationState===`installed`&&O?.permissionDelta.added.length?(0,D.jsx)(`p`,{className:`mt-4 rounded-xl bg-warning-soft p-3 text-xs leading-5 text-warning`,children:n?`此更新增加了权限,请确认这些能力符合你的修改意图。`:`This update adds permissions. Confirm they match the change you requested.`}):null,(0,D.jsx)(`p`,{className:`mt-5 rounded-xl bg-accent-soft p-3 text-xs leading-5 text-accent-fg`,children:n?`Phase 1 应用只能使用界面主题和本地存储,不能访问网络或运行系统命令。`:`Phase 1 apps can use theme and local storage only. They cannot access the network or run system commands.`})]}),(0,D.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,D.jsx)(w,{asChild:!0,children:(0,D.jsx)(C,{children:n?`取消`:`Cancel`})}),(0,D.jsxs)(C,{variant:`primary`,onClick:()=>void Et(),disabled:k,children:[k?(0,D.jsx)(_,{className:`size-4 animate-spin`}):(0,D.jsx)(p,{className:`size-4`}),n?`确认安装`:`Install`]})]})]})]})}),(0,D.jsx)(me,{open:tt,onOpenChange:nt,children:(0,D.jsxs)(de,{children:[(0,D.jsx)(le,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,D.jsxs)(fe,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex h-[min(420px,calc(100vh-32px))] w-[min(500px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-2xl focus:outline-none`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(pe,{className:`text-base font-semibold text-fg`,children:n?`卸载当前应用?`:`Uninstall this app?`}),(0,D.jsx)(ue,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:n?`应用会从侧栏移除,但项目、源码、版本历史和本地数据都会保留。`:`The app leaves the sidebar, while its Project, source, release history, and local data remain.`})]}),(0,D.jsx)(w,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,D.jsx)(se,{className:`size-4`})})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,D.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:E.name}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`之后可从任意保留版本重新安装。`:`You can reinstall any retained release later.`})]})}),(0,D.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,D.jsx)(w,{asChild:!0,children:(0,D.jsx)(C,{children:n?`取消`:`Cancel`})}),(0,D.jsxs)(C,{variant:`ghost`,className:`text-danger hover:bg-danger-soft hover:text-danger`,onClick:()=>void At(),disabled:k,children:[k?(0,D.jsx)(_,{className:`size-4 animate-spin`}):(0,D.jsx)(S,{className:`size-4`}),n?`卸载但保留项目`:`Uninstall and keep Project`]})]})]})]})})]})}export{Ge as LocalAppWorkbenchPage};
@@ -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{m as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a,i as o,n as s,o as c}from"./locale-store-Br7IfbXK.js";import{t as l}from"./messages-ByFlEbsu.js";import{t as u}from"./activity-YogQEteU.js";import{t as d}from"./chevron-left-DqFhpbvK.js";import{t as f}from"./chevron-right-BweFrslA.js";import{n as p,r as m,t as h}from"./popover-select-DD8fmrxH.js";import{t as g}from"./laptop-CI3hBVrl.js";import{n as _,t as v}from"./shield-off-2jsucUds.js";import{t as y}from"./plus-Q2yW6OE7.js";import{t as b}from"./search-DA7gz22f.js";import{t as x}from"./smartphone-DSSsQFqA.js";import{t as S}from"./x-B_N4OPjy.js";import{t as C}from"./cn-0WouolD0.js";import{t as w}from"./button-CnRSIP6m.js";import{t as T}from"./skeleton-BI5TyibZ.js";import{a as E,n as ee,o as te,r as D,s as ne,t as re}from"./dist-DfWfZ9iu.js";import{i as ie,o as ae}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{i as O,o as k}from"./vendor-swr-CdRzEUwF.js";import{s as A}from"./session-api-Bs3r_d2_.js";import{t as j}from"./page-tabs-oeTY7z3_.js";import{n as M}from"./index.module-Cd9ENXfk.js";import{t as N}from"./confirm-dialog-XGclfBqe.js";import{t as P}from"./refresh-button-bU_0NarN.js";import{n as F}from"./settings-loading-skeleton-BTqvr_Fw.js";import{n as I,t as L}from"./settings-page-header-DBL0_u0Z.js";import{t as oe}from"./settings-page-layout-IAvpbz4A.js";import{t as R}from"./device-pairing-wizard-_3BJFWVQ.js";var z=n(),B=e(t(),1),V=r();async function H(e=`GET`,t,n){let r=await a(o(`/api/endpoint-tools/target-authorizations`+(n?`/`+encodeURIComponent(n):``)),{method:e,...t?{body:JSON.stringify(t)}:{}});if(!r.ok)throw Error(r.status===403?`owner`:`unavailable`);return(await r.json()).payload}function se({devices:e,zh:t}){let n=O(`device-single-call-grants`,()=>H(),{refreshInterval:5e3,shouldRetryOnError:!1}),r=O(n.error?null:`device-grant-conversations`,()=>A({limit:100}),{shouldRetryOnError:!1}),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(`weather`),[f,p]=(0,B.useState)(`approximate`),[m,g]=(0,B.useState)(`restaurant`),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(!1);if(n.error)return null;let x=e.flatMap(e=>e.endpoints.map(t=>({...t,label:e.displayName+` · `+e.platform+` · `+e.id.slice(-8)}))),S=x.find(e=>e.endpointId===c)?.tools.find(e=>e.descriptor.name.endsWith(`.device.get_location`))?.descriptor.name,C=async()=>{if(!(!S||!i||!o)){v(!0),b(!1);try{await H(`POST`,{conversationId:i,requestorPrincipalId:o,targetEndpointId:c,toolName:S,arguments:{purpose:u,precision:f,...u===`nearby`?{category:m}:{}}}),await n.mutate()}catch{b(!0)}finally{v(!1)}}};return(0,V.jsxs)(`section`,{className:`mb-5 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,V.jsx)(`h3`,{className:`font-semibold text-fg`,children:t?`跨设备单次授权`:`Single-call device authorization`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t?`为指定会话和来源设备授权一次定位查询,60 秒后失效。目标设备仍需确认;授权后请在来源设备继续请求。`:`Authorize one location query for a conversation and source device. Expires in 60 seconds; target-device consent is still required. Continue the request from the source device.`}),n.isLoading||r.isLoading?(0,V.jsx)(T,{className:`mt-3 h-28`}):(0,V.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(h,{value:i,onChange:a,placeholder:t?`选择会话`:`Conversation`,ariaLabel:t?`会话`:`Conversation`,options:(r.data?.items??[]).map(e=>({value:e.key,label:e.name||e.key}))}),(0,V.jsx)(h,{value:o,onChange:s,placeholder:t?`消息来源设备`:`Source device`,ariaLabel:t?`消息来源设备`:`Source device`,options:e.filter(e=>e.endpoints.length>0).map(e=>({value:e.id,label:e.displayName+` · `+e.platform+` · `+e.id.slice(-8)}))}),(0,V.jsx)(h,{value:c,onChange:l,placeholder:t?`使用哪台设备的位置`:`Location device`,ariaLabel:t?`目标设备`:`Target device`,options:x.filter(e=>e.tools.some(e=>e.descriptor.name.endsWith(`.device.get_location`))).map(e=>({value:e.endpointId,label:e.label}))}),(0,V.jsx)(h,{placeholder:t?`用途`:`Purpose`,value:u,onChange:e=>d(e),ariaLabel:t?`用途`:`Purpose`,options:[{value:`weather`,label:t?`查询天气`:`Weather`},{value:`nearby`,label:t?`附近地点`:`Nearby places`}],allowEmpty:!1}),(0,V.jsx)(h,{placeholder:t?`精度`:`Precision`,value:f,onChange:e=>p(e),ariaLabel:t?`精度`:`Precision`,options:[{value:`approximate`,label:t?`大致位置`:`Approximate`},{value:`precise`,label:t?`精确位置`:`Precise`}],allowEmpty:!1}),u===`nearby`?(0,V.jsx)(h,{placeholder:t?`地点类型`:`Category`,value:m,onChange:g,ariaLabel:t?`附近地点类型`:`Place category`,options:[`restaurant`,`cafe`,`pharmacy`,`park`].map((e,n)=>({value:e,label:t?[`餐厅`,`咖啡馆`,`药店`,`公园`][n]:e})),allowEmpty:!1}):null,(0,V.jsx)(w,{variant:`primary`,disabled:_||!i||!o||!S,onClick:()=>void C(),children:t?`允许一次`:`Allow once`})]}),y?(0,V.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-fg-muted`,children:t?`授权失败,请检查设备连接后重试。`:`Authorization failed. Check the device connection.`}):null,(0,V.jsx)(`div`,{className:`mt-3 space-y-2`,children:n.data?.map(r=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm text-fg-muted`,children:[(0,V.jsxs)(`span`,{children:[e.find(e=>e.endpoints.some(e=>e.endpointId===r.targetEndpointId))?.displayName??(t?`设备`:`Device`),` · `,r.state===`running`?t?`执行中`:`Running`:t?`等待本次调用`:`Awaiting one call`]}),(0,V.jsx)(w,{disabled:_,onClick:()=>{v(!0),H(`DELETE`,void 0,r.id).then(()=>n.mutate()).catch(()=>b(!0)).finally(()=>v(!1))},children:t?`撤销`:`Revoke`})]},r.id))})]})}var ce=720*60*60*1e3;function le(e){let t=[e.access,e.principal].filter(e=>e!==null);return t.length>0&&t.every(e=>e.revokedAt!==void 0)}function U(e){return le(e)?`revoked`:e.endpoints.length>0?`online`:`offline`}function ue(e){return new Set(e.endpoints.flatMap(e=>e.tools.map(({descriptor:e})=>e.name))).size}function de(e,t=Date.now()){return U(e)===`offline`&&(e.lastSeenAt??e.createdAt)<t-ce}function fe(e,t,n=Date.now()){let r=t.query.trim().toLocaleLowerCase();return e.filter(e=>{let i=U(e),a=t.status===`all`||(t.status===`active`?i!==`revoked`:t.status===`stale`?de(e,n):i===t.status),o=!t.platform||e.platform===t.platform,s=!r||[e.displayName,e.id,e.kind,e.platform].some(e=>e.toLocaleLowerCase().includes(r));return a&&o&&s})}function pe(e){return e.length>8?e.slice(-8):e}function me(e){let t=(0,z.c)(61),{device:n,busy:r,onClose:i,onRevoke:a,onRename:o}=e,c=s(he),u;t[0]===c?u=t[1]:(u=l(c),t[0]=c,t[1]=u);let d=u.endpointToolsSettings,f=c===`zh`?`zh-CN`:`en`,p;t[2]===f?p=t[3]:(p=new Intl.DateTimeFormat(f,{dateStyle:`medium`,timeStyle:`short`}),t[2]=f,t[3]=p);let m=p,h;t[4]===n?h=t[5]:(h=n?U(n):`offline`,t[4]=n,t[5]=h);let g=h,_=n!==null,y;t[6]===i?y=t[7]:(y=e=>!e&&i(),t[6]=i,t[7]=y);let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,V.jsx)(E,{className:C(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ae)}),t[8]=b):b=t[8];let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=C(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,ie),t[9]=x):x=t[9];let T=n?.displayName??d.deviceDetails,O;t[10]===T?O=t[11]:(O=(0,V.jsx)(ne,{className:`truncate text-base font-semibold text-fg`,children:T}),t[10]=T,t[11]=O);let k;t[12]===n?k=t[13]:(k=n?(0,V.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[n.kind,` · `,n.platform,` · `,pe(n.id)]}):null,t[12]=n,t[13]=k);let A;t[14]!==O||t[15]!==k?(A=(0,V.jsxs)(`div`,{className:`min-w-0`,children:[O,k]}),t[14]=O,t[15]=k,t[16]=A):A=t[16];let j;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,V.jsx)(S,{className:`size-5`,"aria-hidden":!0}),t[17]=j):j=t[17];let M;t[18]===d.close?M=t[19]:(M=(0,V.jsx)(ee,{asChild:!0,children:(0,V.jsx)(w,{variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":d.close,children:j})}),t[18]=d.close,t[19]=M);let N;t[20]!==A||t[21]!==M?(N=(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[A,M]}),t[20]=A,t[21]=M,t[22]=N):N=t[22];let P;t[23]!==d.accessActive||t[24]!==d.accessRevoked||t[25]!==d.accessTitle||t[26]!==d.createdAt||t[27]!==d.endpointCount||t[28]!==d.endpointsTitle||t[29]!==d.identityId||t[30]!==d.identityTitle||t[31]!==d.lastSeen||t[32]!==d.never||t[33]!==d.noAccessIdentity||t[34]!==d.noOnlineEndpoints||t[35]!==d.noPermissions||t[36]!==d.permissions||t[37]!==d.status||t[38]!==d.statusLabel||t[39]!==d.toolCount||t[40]!==n||t[41]!==m||t[42]!==c||t[43]!==o||t[44]!==g?(P=n?(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-4`,children:[n.principal&&g!==`revoked`&&o?(0,V.jsx)(ge,{device:n,zh:c===`zh`,onRename:o},`${n.id}:${n.settingsRevision??0}`):null,(0,V.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 rounded-xl bg-surface-hover/40 p-4`,children:[(0,V.jsx)(W,{label:d.statusLabel,value:d.status[g]}),(0,V.jsx)(W,{label:d.lastSeen,value:n.lastSeenAt?m.format(n.lastSeenAt):d.never}),(0,V.jsx)(W,{label:d.endpointCount,value:String(n.endpoints.length)}),(0,V.jsx)(W,{label:d.toolCount,value:String(ue(n))})]}),(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:d.accessTitle}),(0,V.jsx)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-3 text-xs text-fg-muted`,children:n.access?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{children:n.access.revokedAt?d.accessRevoked:d.accessActive}),(0,V.jsx)(`p`,{className:`mt-1`,children:n.access.requestProofVersion===1?c===`zh`?`设备请求签名已启用`:`Device request signing enabled`:c===`zh`?`请求签名未启用,设备不可用`:`Request signing is missing; device unavailable`}),(0,V.jsxs)(`p`,{className:`mt-1 break-words`,children:[d.permissions,`: `,n.access.scopes.join(`, `)||d.noPermissions]})]}):(0,V.jsx)(`p`,{children:d.noAccessIdentity})})]}),n.access&&!n.access.revokedAt&&n.platform!==`chrome`?(0,V.jsx)(_e,{device:n,zh:c===`zh`},n.id):null,(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:d.endpointsTitle}),(0,V.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[n.endpoints.length===0?(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.noOnlineEndpoints}):null,n.endpoints.map(e=>(0,V.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,V.jsx)(`p`,{className:`min-w-0 break-all text-xs font-medium text-fg`,children:e.endpointId}),(0,V.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[d.status[e.availability],` · v`,e.appVersion]})]}),(0,V.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.tools.map(e=>{let{descriptor:t}=e;return(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-hover/50 px-3 py-2`,children:[(0,V.jsx)(`p`,{className:`break-all text-xs font-medium text-fg`,children:t.title}),(0,V.jsxs)(`p`,{className:`mt-0.5 break-words text-xs text-fg-subtle`,children:[t.requiresForeground?c===`zh`?`需要设备在前台 · `:`Requires foreground · `:``,t.confirmation===`always`?c===`zh`?`每次确认`:`Confirm each time`:c===`zh`?`按已授权范围调用`:`Uses the authorized scope`]})]},t.name)})})]},e.connectionId))]})]}),(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:d.identityTitle}),n.principal&&g!==`revoked`&&o?(0,V.jsx)(ge,{device:n,zh:c===`zh`,onRename:o},`${n.id}:${n.settingsRevision??0}`):null,(0,V.jsxs)(`dl`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-3 text-xs`,children:[(0,V.jsx)(W,{label:d.identityId,value:n.id,breakAll:!0}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(W,{label:d.createdAt,value:m.format(n.createdAt)})})]})]})]}):null,t[23]=d.accessActive,t[24]=d.accessRevoked,t[25]=d.accessTitle,t[26]=d.createdAt,t[27]=d.endpointCount,t[28]=d.endpointsTitle,t[29]=d.identityId,t[30]=d.identityTitle,t[31]=d.lastSeen,t[32]=d.never,t[33]=d.noAccessIdentity,t[34]=d.noOnlineEndpoints,t[35]=d.noPermissions,t[36]=d.permissions,t[37]=d.status,t[38]=d.statusLabel,t[39]=d.toolCount,t[40]=n,t[41]=m,t[42]=c,t[43]=o,t[44]=g,t[45]=P):P=t[45];let F;t[46]!==r||t[47]!==d.removeDevice||t[48]!==d.revoking||t[49]!==n||t[50]!==a||t[51]!==g?(F=n&&g!==`revoked`?(0,V.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3`,children:(0,V.jsxs)(w,{variant:`secondary`,className:`w-full text-danger`,disabled:r,onClick:()=>a(n),children:[(0,V.jsx)(v,{className:`size-4`,"aria-hidden":!0}),r?d.revoking:d.removeDevice]})}):null,t[46]=r,t[47]=d.removeDevice,t[48]=d.revoking,t[49]=n,t[50]=a,t[51]=g,t[52]=F):F=t[52];let I;t[53]!==N||t[54]!==P||t[55]!==F?(I=(0,V.jsxs)(te,{children:[b,(0,V.jsxs)(D,{className:x,"aria-describedby":void 0,children:[N,P,F]})]}),t[53]=N,t[54]=P,t[55]=F,t[56]=I):I=t[56];let L;return t[57]!==I||t[58]!==_||t[59]!==y?(L=(0,V.jsx)(re,{open:_,onOpenChange:y,children:I}),t[57]=I,t[58]=_,t[59]=y,t[60]=L):L=t[60],L}function he(e){return e.language}function W(e){let t=(0,z.c)(10),{label:n,value:r,breakAll:i}=e,a=i!==void 0&&i,o;t[0]===n?o=t[1]:(o=(0,V.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=o);let s=a&&`break-all font-mono text-xs`,c;t[2]===s?c=t[3]:(c=C(`mt-1 text-sm text-fg`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,V.jsx)(`dd`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,V.jsxs)(`div`,{className:`min-w-0`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function ge({device:e,zh:t,onRename:n}){let[r,i]=(0,B.useState)(e.displayName),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!1);return(0,V.jsxs)(`form`,{className:`space-y-2`,onSubmit:async t=>{if(t.preventDefault(),!(a||!r.trim())){o(!0),c(!1);try{await n(e,r.trim())}catch{c(!0)}finally{o(!1)}}},children:[(0,V.jsxs)(`label`,{className:`block text-sm text-fg`,children:[t?`设备名称`:`Device name`,(0,V.jsx)(`input`,{value:r,maxLength:80,onChange:e=>i(e.target.value),className:`mt-2 h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-fg`})]}),(0,V.jsx)(w,{type:`submit`,variant:`secondary`,disabled:a||!r.trim()||r.trim()===e.displayName,children:a?t?`保存中…`:`Saving…`:t?`保存名称`:`Save name`}),s?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`保存失败,请刷新设备信息后重试。`:`Unable to save. Refresh device information and retry.`}):null]})}function _e({device:e,zh:t}){let n=e.access?.scopes.includes(`phone.control`)?`control`:e.access?.scopes.includes(`phone.view`)?`view`:`none`,[r,i]=(0,B.useState)(n),[a,s]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1);return(0,B.useEffect)(()=>i(n),[n]),(0,V.jsxs)(`section`,{className:`space-y-2`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t?`云手机访问`:`Cloud phone access`}),(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`移动端配对后默认可查看并接管。可在此关闭,或撤销整个设备的授权。`:`Mobile pairing includes viewing and control by default. Disable it here or revoke the device entirely.`}),(0,V.jsxs)(p,{value:r,disabled:a,onChange:async t=>{let n=t.target.value;s(!0),u(!1);try{await c(o(`/api/phone/device-access/${encodeURIComponent(e.id)}`),{method:`PATCH`,body:JSON.stringify({access:n})}),i(n),await k(o(`/api/endpoint-tools/devices`))}catch{u(!0)}finally{s(!1)}},children:[(0,V.jsx)(m,{value:`none`,children:t?`不允许`:`Not allowed`}),(0,V.jsx)(m,{value:`view`,children:t?`仅查看`:`View only`}),(0,V.jsx)(m,{value:`control`,children:t?`查看并接管`:`View and control`})]}),l?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`授权保存失败,请重试。`:`Unable to save phone access.`}):null]})}function ve(e){let t=(0,z.c)(19),{onPaired:n}=e,[r,a]=i(),o=s(be),c;t[0]===o?c=t[1]:(c=l(o),t[0]=o,t[1]=c);let u=c.endpointToolsSettings.deviceAccess,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={open:!1},t[2]=d):d=t[2];let[f,p]=(0,B.useState)(d),m,h;t[3]!==r||t[4]!==a?(m=()=>{let e=r.get(`startDevicePairing`);e!==`mobile`&&e!==`browser`||(p({open:!0,target:e}),a(ye,{replace:!0}))},h=[r,a],t[3]=r,t[4]=a,t[5]=m,t[6]=h):(m=t[5],h=t[6]),(0,B.useEffect)(m,h);let g,_;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>p({open:!0}),_=(0,V.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t[7]=g,t[8]=_):(g=t[7],_=t[8]);let v;t[9]===u.addDevice?v=t[10]:(v=(0,V.jsxs)(w,{variant:`primary`,onClick:g,children:[_,u.addDevice]}),t[9]=u.addDevice,t[10]=v);let b;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>p(t=>({...t,open:e})),t[11]=b):b=t[11];let x;t[12]!==f.open||t[13]!==f.target||t[14]!==n?(x=(0,V.jsx)(R,{open:f.open,onOpenChange:b,onPaired:n,targetKind:f.target}),t[12]=f.open,t[13]=f.target,t[14]=n,t[15]=x):x=t[15];let S;return t[16]!==v||t[17]!==x?(S=(0,V.jsxs)(V.Fragment,{children:[v,x]}),t[16]=v,t[17]=x,t[18]=S):S=t[18],S}function ye(e){let t=new URLSearchParams(e);return t.delete(`startDevicePairing`),t}function be(e){return e.language}async function G(e){let t=await e.json().catch(()=>null);if(!e.ok||t?.payload===void 0)throw Error(t?.error?.message??`Endpoint management request failed: ${e.status}`);return t.payload}function xe(){return o(`/api/endpoint-tools/devices`)}function Se(e){let t=new URLSearchParams({page:String(e.page),pageSize:String(e.pageSize)});return e.query.trim()&&t.set(`query`,e.query.trim()),e.principalId&&t.set(`principalId`,e.principalId),e.status&&t.set(`status`,e.status),e.effect&&t.set(`effect`,e.effect),o(`/api/endpoint-tools/invocations?${t}`)}async function Ce(){return G(await a(xe()))}async function we(e){let t=Array.from({length:Math.ceil(e.length/100)},(t,n)=>e.slice(n*100,(n+1)*100));await Promise.all(t.map(async e=>{await G(await a(o(`/api/endpoint-tools/devices/revoke`),{method:`POST`,body:JSON.stringify({ids:e})}))}))}async function Te(e){return G(await a(Se(e)))}async function Ee(e,t,n){await G(await a(o(`/api/endpoint-tools/devices/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({nickname:t,expectedRevision:n})}))}var De=5e3,K=20,Oe=20;function ke(e){return e===`online`||e===`succeeded`?`bg-success-soft text-success`:e===`running`?`bg-accent-soft text-accent-fg`:e===`failed`||e===`revoked`?`bg-danger-soft text-danger`:`bg-surface-hover text-fg-muted`}function Ae(e){let t=(0,z.c)(5),{status:n,label:r}=e,i;t[0]===n?i=t[1]:(i=C(`rounded-full px-2 py-0.5 text-xs font-medium`,ke(n)),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,V.jsx)(`span`,{className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function q(){let e=s(e=>e.language),t=l(e).endpointToolsSettings,[n,r]=i(),a=n.get(`view`)===`activity`?`activity`:`devices`,[o,c]=(0,B.useState)(null),[p,m]=(0,B.useState)([]),[y,S]=(0,B.useState)(!1),[T,E]=(0,B.useState)(!1),[ee,te]=(0,B.useState)(``),[D,ne]=(0,B.useState)(`active`),[re,ie]=(0,B.useState)(``),[ae,k]=(0,B.useState)(1),[A,R]=(0,B.useState)(()=>new Set),[z,H]=(0,B.useState)(``),[ce]=M(z,250),[le,he]=(0,B.useState)(``),[W,ge]=(0,B.useState)(``),[_e,ye]=(0,B.useState)(``),[be,G]=(0,B.useState)(1),ke={page:be,pageSize:Oe,query:ce,principalId:le,status:W,effect:_e},q=O(xe(),Ce,{refreshInterval:De}),J=O(a===`activity`?Se(ke):null,()=>Te(ke),{refreshInterval:De,keepPreviousData:!0}),je=(0,B.useMemo)(()=>new Intl.DateTimeFormat(e===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}),[e]);if(q.isLoading&&!q.data)return(0,V.jsx)(I,{children:(0,V.jsx)(F,{sections:2})});let Y=q.data??[],Me=J.data?.items??[],Ne=Y.filter(e=>U(e)===`online`).length,Pe=Y.filter(e=>U(e)!==`revoked`).length,Fe=Y.filter(e=>de(e)).length,Ie=[...new Set(Y.map(e=>e.platform))].toSorted(),X=fe(Y,{query:ee,status:D,platform:re}),Le=Math.max(1,Math.ceil(X.length/K)),Z=Math.min(ae,Le),Re=X.slice((Z-1)*K,Z*K),Q=Re.reduce((e,t)=>(U(t)!==`revoked`&&e.push(t.id),e),[]),ze=Q.length>0&&Q.every(e=>A.has(e)),Be=e=>{r(t=>{let n=new URLSearchParams(t);return e===`devices`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})},Ve=async()=>{await Promise.all([q.mutate(),a===`activity`?J.mutate():Promise.resolve()])},He=async()=>{if(!(p.length===0||y)){S(!0),E(!1);try{await we(p.map(e=>e.id)),m([]),R(new Set),await q.mutate()}catch{E(!0)}finally{S(!1)}}},$=e=>{e(),k(1),R(new Set)};return(0,V.jsxs)(I,{children:[(0,V.jsx)(L,{title:t.title,subtitle:t.subtitle,actions:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(P,{className:`size-9 shrink-0 p-0`,label:t.refresh,onClick:Ve}),(0,V.jsx)(ve,{onPaired:()=>void q.mutate()})]})}),q.error||J.error?(0,V.jsx)(`div`,{className:`rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger`,children:t.loadError}):null,(0,V.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[{label:t.activeDevices,value:Pe,filter:`active`},{label:t.onlineDevices,value:Ne,filter:`online`},{label:t.staleDevices,value:Fe,filter:`stale`}].map(({label:e,value:t,filter:n})=>(0,V.jsxs)(`button`,{type:`button`,className:C(`touch-target rounded-xl px-4 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,D===n?`bg-surface-active`:`bg-surface-hover/20 hover:bg-surface-hover/50`),"aria-pressed":D===n,onClick:()=>{$(()=>ne(n)),Be(`devices`)},children:[(0,V.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e}),(0,V.jsx)(`span`,{className:`mt-1 block text-2xl font-semibold text-fg`,children:t})]},n))}),(0,V.jsx)(j,{items:[{id:`devices`,label:t.devicesTab,icon:_,count:Pe},{id:`activity`,label:t.activityTab,icon:u,count:J.data?.total}],activeTab:a,onChange:Be,ariaLabel:t.viewsAria,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`}),(0,V.jsxs)(oe,{id:`devices`,activeTab:a,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`,title:t.devicesTitle,hint:t.devicesHint,children:[(0,V.jsx)(se,{devices:Y,zh:e===`zh`}),(0,V.jsxs)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-[minmax(0,1fr)_11rem_11rem]`,children:[(0,V.jsxs)(`label`,{className:`relative block`,children:[(0,V.jsx)(`span`,{className:`sr-only`,children:t.searchDevices}),(0,V.jsx)(b,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,V.jsx)(`input`,{type:`search`,"aria-label":t.searchDevices,value:ee,placeholder:t.searchDevices,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset pl-9 pr-3 text-base text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,onChange:e=>$(()=>te(e.target.value))})]}),(0,V.jsx)(h,{value:D,options:[{value:`active`,label:t.filterActive},{value:`online`,label:t.status.online},{value:`offline`,label:t.status.offline},{value:`stale`,label:t.filterStale},{value:`revoked`,label:t.status.revoked},{value:`all`,label:t.filterAll}],placeholder:t.statusLabel,allowEmpty:!1,ariaLabel:t.statusLabel,onChange:e=>$(()=>ne(e))}),(0,V.jsx)(h,{value:re,options:Ie.map(e=>({value:e,label:e})),placeholder:t.allPlatforms,emptyLabel:t.allPlatforms,ariaLabel:t.platformLabel,onChange:e=>$(()=>ie(e))})]}),A.size>0?(0,V.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3 rounded-xl bg-accent-soft px-3 py-2`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-accent-fg`,children:t.selectedCount.replace(`{{count}}`,String(A.size))}),(0,V.jsxs)(w,{variant:`secondary`,className:`text-danger`,onClick:()=>{E(!1),m(Y.filter(e=>A.has(e.id)))},children:[(0,V.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t.removeSelected]})]}):null,Y.length===0?(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noDevices}):X.length===0?(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noMatchingDevices}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`flex min-h-10 items-center gap-3 border-b border-edge-subtle px-1`,children:(0,V.jsxs)(`label`,{className:C(`touch-target flex items-center gap-2 text-xs text-fg-muted`,Q.length>0?`cursor-pointer`:`cursor-not-allowed opacity-50`),children:[(0,V.jsx)(`input`,{type:`checkbox`,"aria-label":t.selectPage,checked:ze,disabled:Q.length===0,className:`size-4 accent-accent`,onChange:e=>{R(t=>{let n=new Set(t);for(let t of Q)e.target.checked?n.add(t):n.delete(t);return n})}}),t.selectPage]})}),(0,V.jsx)(`ul`,{className:`divide-y divide-edge-subtle`,children:Re.map(e=>{let n=U(e),r=e.kind===`mobile`?x:g;return(0,V.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`label`,{className:C(`touch-target flex size-10 shrink-0 items-center justify-center`,n===`revoked`?`cursor-not-allowed opacity-40`:`cursor-pointer`),children:(0,V.jsx)(`input`,{type:`checkbox`,checked:A.has(e.id),disabled:n===`revoked`,"aria-label":t.selectDevice.replace(`{{name}}`,e.displayName),className:`size-4 accent-accent`,onChange:t=>{R(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})}})}),(0,V.jsxs)(`button`,{type:`button`,className:`touch-target flex min-w-0 flex-1 items-center gap-3 py-3 text-left hover:bg-surface-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>c(e),children:[(0,V.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-inset text-fg-muted`,children:(0,V.jsx)(r,{className:`size-4`,"aria-hidden":!0})}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),(0,V.jsx)(Ae,{status:n,label:t.status[n]})]}),(0,V.jsxs)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:[e.platform,` · `,pe(e.id),` · `,t.lastSeen,`: `,e.lastSeenAt?je.format(e.lastSeenAt):t.never]})]}),(0,V.jsx)(`span`,{className:`hidden shrink-0 text-right text-xs text-fg-muted sm:block`,children:t.endpointSummary.replace(`{{endpoints}}`,String(e.endpoints.length)).replace(`{{tools}}`,String(ue(e)))}),(0,V.jsx)(f,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]})]},e.id)})}),(0,V.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-edge-subtle pt-3`,children:[(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.paginationSummary.replace(`{{from}}`,String((Z-1)*K+1)).replace(`{{to}}`,String(Math.min(Z*K,X.length))).replace(`{{total}}`,String(X.length))}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.previousPage,disabled:Z<=1,onClick:()=>k(e=>Math.max(1,e-1)),children:(0,V.jsx)(d,{className:`size-4`,"aria-hidden":!0})}),(0,V.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.nextPage,disabled:Z>=Le,onClick:()=>k(e=>Math.min(Le,e+1)),children:(0,V.jsx)(f,{className:`size-4`,"aria-hidden":!0})})]})]})]})]}),(0,V.jsxs)(oe,{id:`activity`,activeTab:a,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`,title:t.callsTitle,hint:t.callsHint,children:[(0,V.jsxs)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,V.jsxs)(`label`,{className:`relative block sm:col-span-2 lg:col-span-1`,children:[(0,V.jsx)(`span`,{className:`sr-only`,children:t.searchActivity}),(0,V.jsx)(b,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,V.jsx)(`input`,{type:`search`,"aria-label":t.searchActivity,value:z,placeholder:t.searchActivity,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset pl-9 pr-3 text-base text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,onChange:e=>{H(e.target.value),G(1)}})]}),(0,V.jsx)(h,{value:le,options:Y.map(e=>({value:e.id,label:`${e.displayName} · ${pe(e.id)}`})),placeholder:t.allDevices,emptyLabel:t.allDevices,ariaLabel:t.deviceLabel,onChange:e=>{he(e),G(1)}}),(0,V.jsx)(h,{value:W,options:[{value:`running`,label:t.status.running},{value:`succeeded`,label:t.status.succeeded},{value:`failed`,label:t.status.failed}],placeholder:t.allStatuses,emptyLabel:t.allStatuses,ariaLabel:t.statusLabel,onChange:e=>{ge(e),G(1)}}),(0,V.jsx)(h,{value:_e,options:[{value:`read`,label:t.effects.read},{value:`write`,label:t.effects.write},{value:`destructive`,label:t.effects.destructive}],placeholder:t.allEffects,emptyLabel:t.allEffects,ariaLabel:t.effectLabel,onChange:e=>{ye(e),G(1)}})]}),J.isLoading&&!J.data?(0,V.jsx)(F,{sections:1}):null,Me.length===0&&!J.isLoading?(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noMatchingCalls}):null,(0,V.jsx)(`div`,{className:`space-y-2`,children:Me.map(e=>(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`break-all text-sm font-medium text-fg`,children:e.toolName}),(0,V.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[je.format(e.startedAt),` · `,t.effects[e.effect],` · `,e.endpointId]}),e.errorMessage?(0,V.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:e.errorMessage}):null]}),(0,V.jsx)(Ae,{status:e.status,label:t.status[e.status]})]},e.id))}),J.data&&J.data.total>0?(0,V.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-edge-subtle pt-3`,children:[(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.paginationSummary.replace(`{{from}}`,String((J.data.page-1)*J.data.pageSize+1)).replace(`{{to}}`,String(Math.min(J.data.page*J.data.pageSize,J.data.total))).replace(`{{total}}`,String(J.data.total))}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.previousPage,disabled:J.data.page<=1,onClick:()=>G(e=>Math.max(1,e-1)),children:(0,V.jsx)(d,{className:`size-4`,"aria-hidden":!0})}),(0,V.jsx)(w,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.nextPage,disabled:J.data.page>=J.data.totalPages,onClick:()=>G(e=>Math.min(J.data.totalPages,e+1)),children:(0,V.jsx)(f,{className:`size-4`,"aria-hidden":!0})})]})]}):null]}),(0,V.jsx)(me,{device:o,busy:y,onRename:async(e,t)=>{await Ee(e.id,t,e.settingsRevision??0);let n=await q.mutate();c(n?.find(t=>t.id===e.id)??null)},onClose:()=>c(null),onRevoke:e=>{c(null),E(!1),m([e])}}),(0,V.jsx)(N,{open:p.length>0,title:p.length>1?t.removeManyTitle:t.removeTitle,description:`${p.length>1?t.removeManyDescription.replace(`{{count}}`,String(p.length)):t.removeDescription.replace(`{{name}}`,p[0]?.displayName??``)}${T?`\n\n${t.revokeError}`:``}`,confirmLabel:y?t.revoking:t.removeDevice,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void He(),onCancel:()=>{y||m([])}})]})}export{q as EndpointToolsManagementSettings};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,u as ee}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as a}from"./locale-store-Br7IfbXK.js";import{t as te}from"./messages-ByFlEbsu.js";import{t as ne}from"./check-DUBLcKHA.js";import{a as re,c as o,d as s,l as c,o as l,u as ie}from"./popover-select-DD8fmrxH.js";import{t as ae}from"./settings-2-D-csvaET.js";import{t as u}from"./cn-0WouolD0.js";import{c as d,s as f}from"./dist-CaUuvp8-.js";import{i as oe}from"./vendor-swr-CdRzEUwF.js";import{t as se}from"./open-capability-settings-Cvb65hQB.js";import{n as ce}from"./interaction-BdhHBbYa.js";import{n as le,t as ue}from"./registry-api-DFDvOTg4.js";import{i as de,n as fe,r as pe}from"./form-field-width-DJw_jULe.js";var me=n();function p(e,t){return e.displayNames?.[t.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`]||(t.toLowerCase().startsWith(`zh`)&&e.id===`xopc-cloud/auto`&&e.name===`Standard`?`标准`:t.toLowerCase().startsWith(`zh`)&&e.id===`xopc-cloud/advanced`&&e.name===`Advanced`?`高级`:e.name)}var m=e(t(),1);function he(e,t,n){if(t===`computer-use`)return e.filter(e=>!!e.computerUse);let r=e=>e.computerUse?.profile!==void 0&&e.computerUse.dedicated!==!1&&e.computerUse.profile!==`openai-responses-computer-v1`;if(t!==`vision`)return e.filter(e=>!r(e)&&!e.phoneUse||e.id===n);let i=e.filter(e=>e.vision===!0&&!r(e)&&!e.phoneUse);if(!n||i.some(e=>e.id===n))return i;let ee=e.find(e=>e.id===n);if(ee)return[ee,...i];let a=n.indexOf(`/`),te=a>=0?n.slice(0,a):``;return[{id:n,name:(a>=0?n.slice(a+1):n)||n,provider:te||`—`,vision:!1},...i]}var h=r();function g(e){return`${e.id} ${e.name} ${Object.values(e.displayNames??{}).join(` `)} ${e.provider}`.toLowerCase()}var ge=[];function _e(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=g(e);return r.every(e=>t.includes(e))})}function _(e){let t=(0,me.c)(100),{value:n,disabled:r,placeholder:l,searchPlaceholder:g,noMatches:_,models:xe,modelsLoading:Se,modelsError:Ce,capabilitiesFilter:v,outOfFilterNote:we,registryEmptyHint:Te,allowEmpty:Ee,emptyLabel:De,compact:Oe,showProviderInTrigger:ke,contentSide:Ae,contentAlign:je,className:Me,popoverContentClassName:Ne,showProviderSettingsFooter:Pe,settingsFooterLink:Fe,ariaLabel:Ie,onChange:y}=e,Le=Ee!==void 0&&Ee,Re=ke===void 0||ke,ze=Ae===void 0?`bottom`:Ae,Be=je===void 0?`end`:je,Ve=ee(),b=i(),x=a(ye),S;t[0]===x?S=t[1]:(S=te(x),t[0]=x,t[1]=S);let He=S.chat,[Ue,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(``),[We,Ge]=(0,m.useState)(null),Ke=c(),qe=o(We),Je=ie(Ke,qe!==null),E;t[2]!==He||t[3]!==Fe||t[4]!==Pe?(E=Fe??(Pe?{label:He.modelProviderSettingsLink,path:`/settings/capabilities/models`}:void 0),t[2]=He,t[3]=Fe,t[4]=Pe,t[5]=E):E=t[5];let D=E,O;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(O={revalidateOnFocus:!1},t[6]=O):O=t[6];let Ye=oe(xe?null:ue,le,O),k=xe??Ye.data??ge,Xe=xe?!!Se:Ye.isLoading,A=xe?Ce:Ye.error,j;t[7]===n?j=t[8]:(j=n.trim(),t[7]=n,t[8]=j);let M=j,N;t[9]!==v||t[10]!==k||t[11]!==M?(N=he(k,v,M),t[9]=v,t[10]=k,t[11]=M,t[12]=N):N=t[12];let P=N,Ze=v===`computer-use`||P.length>10,Qe=Ze?w:``,$e;t[13]!==P||t[14]!==Qe?($e=_e(P,Qe),t[13]=P,t[14]=Qe,t[15]=$e):$e=t[15];let F=$e,et;t[16]!==k||t[17]!==P||t[18]!==n?(et=k.find(e=>e.id===n)??P.find(e=>e.id===n),t[16]=k,t[17]=P,t[18]=n,t[19]=et):et=t[19];let I=et,tt;t[20]!==x||t[21]!==l||t[22]!==I||t[23]!==Re||t[24]!==n?(tt=I?Re?`${p(I,x)} (${I.provider})`:p(I,x):n||l,t[20]=x,t[21]=l,t[22]=I,t[23]=Re,t[24]=n,t[25]=tt):tt=t[25];let nt=tt,L=!A&&!!v&&P.length===0,rt=d,it=r||Xe,R;t[26]!==x||t[27]!==l||t[28]!==I?(R=I?`${p(I,x)} (${I.provider})`:l,t[26]=x,t[27]=l,t[28]=I,t[29]=R):R=t[29];let at=Oe&&`py-1.5 text-[13px]`,z;t[30]!==Me||t[31]!==at?(z=u(fe,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,ce.transition,`hover:border-edge hover:bg-surface-hover/45`,de,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,at,Me),t[30]=Me,t[31]=at,t[32]=z):z=t[32];let ot=Xe?`…`:nt,B;t[33]===ot?B=t[34]:(B=(0,h.jsx)(`span`,{className:`min-w-0 truncate`,children:ot}),t[33]=ot,t[34]=B);let st;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(st=(0,h.jsx)(s,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[35]=st):st=t[35];let V;t[36]!==Ie||t[37]!==it||t[38]!==R||t[39]!==z||t[40]!==B?(V=(0,h.jsx)(f,{asChild:!0,children:(0,h.jsxs)(`button`,{ref:Ge,type:`button`,"aria-label":Ie,disabled:it,title:R,className:z,children:[B,st]})}),t[36]=Ie,t[37]=it,t[38]=R,t[39]=z,t[40]=B,t[41]=V):V=t[41];let ct=d,lt=qe??void 0,ut=d,dt=u(Je,re,`w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-overlay p-1 shadow-elevated dark:border-edge-subtle`,Ne),H;t[42]!==w||t[43]!==g||t[44]!==Ze?(H=Ze?(0,h.jsx)(`input`,{type:`search`,"aria-label":g,className:u(`mb-1 w-full shrink-0 rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,pe),placeholder:g,value:w,onChange:e=>T(e.target.value)}):null,t[42]=w,t[43]=g,t[44]=Ze,t[45]=H):H=t[45];let U;t[46]!==Le||t[47]!==De||t[48]!==y||t[49]!==l||t[50]!==M?(U=Le?(0,h.jsxs)(`button`,{type:`button`,className:u(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,M===``&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{y(``),C(!1),T(``)},children:[(0,h.jsx)(ne,{className:u(`size-4 shrink-0`,M!==``&&`invisible`),"aria-hidden":!0}),(0,h.jsx)(`span`,{className:`min-w-0 truncate text-fg-muted`,children:De??l})]}):null,t[46]=Le,t[47]=De,t[48]=y,t[49]=l,t[50]=M,t[51]=U):U=t[51];let W;t[52]===A?W=t[53]:(W=A?(0,h.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:A instanceof Error?A.message:`Failed to load models`}):null,t[52]=A,t[53]=W);let G;t[54]!==A||t[55]!==_||t[56]!==Te||t[57]!==L?(G=!A&&L?(0,h.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:Te??_}):null,t[54]=A,t[55]=_,t[56]=Te,t[57]=L,t[58]=G):G=t[58];let K;t[59]!==A||t[60]!==F||t[61]!==_||t[62]!==L?(K=!A&&!L&&F.length===0?(0,h.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:_}):null,t[59]=A,t[60]=F,t[61]=_,t[62]=L,t[63]=K):K=t[63];let ft=v===`vision`?we:void 0,q;t[64]===y?q=t[65]:(q=e=>{y(e),C(!1),T(``)},t[64]=y,t[65]=q);let J;t[66]!==F||t[67]!==_||t[68]!==g||t[69]!==ft||t[70]!==q||t[71]!==n?(J=(0,h.jsx)(be,{models:F,value:n,searchPlaceholder:g,noMatches:_,showSearch:!1,outOfFilterNote:ft,onChange:q}),t[66]=F,t[67]=_,t[68]=g,t[69]=ft,t[70]=q,t[71]=n,t[72]=J):J=t[72];let Y;t[73]!==U||t[74]!==W||t[75]!==G||t[76]!==K||t[77]!==J?(Y=(0,h.jsxs)(`div`,{className:`flex min-h-0 max-h-60 flex-1 flex-col overflow-hidden`,children:[U,W,G,K,J]}),t[73]=U,t[74]=W,t[75]=G,t[76]=K,t[77]=J,t[78]=Y):Y=t[78];let X;t[79]!==D||t[80]!==b||t[81]!==Ve?(X=D?(0,h.jsx)(`div`,{className:`mt-1 shrink-0 border-t border-edge-subtle pt-1`,children:(0,h.jsxs)(`button`,{type:`button`,className:u(`flex w-full items-center gap-2 rounded-md p-2 text-left text-sm font-medium text-accent`,ce.transition,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{D.path===`/settings/capabilities/models`?se(b.pathname.startsWith(`/automations`)?`background`:`chat`,`services`,b.pathname.startsWith(`/automations`)?`automation`:void 0):Ve(D.path,{state:{settingsBackPath:`${b.pathname}${b.search}`}}),C(!1),T(``)},children:[(0,h.jsx)(ae,{className:`size-4 shrink-0 opacity-90`,"aria-hidden":!0}),(0,h.jsx)(`span`,{className:`min-w-0`,children:D.label})]})}):null,t[79]=D,t[80]=b,t[81]=Ve,t[82]=X):X=t[82];let Z;t[83]!==Be||t[84]!==ze||t[85]!==ut.Content||t[86]!==dt||t[87]!==H||t[88]!==Y||t[89]!==X?(Z=(0,h.jsxs)(ut.Content,{className:dt,side:ze,sideOffset:4,align:Be,collisionPadding:8,onOpenAutoFocus:ve,children:[H,Y,X]}),t[83]=Be,t[84]=ze,t[85]=ut.Content,t[86]=dt,t[87]=H,t[88]=Y,t[89]=X,t[90]=Z):Z=t[90];let Q;t[91]!==ct.Portal||t[92]!==lt||t[93]!==Z?(Q=(0,h.jsx)(ct.Portal,{container:lt,children:Z}),t[91]=ct.Portal,t[92]=lt,t[93]=Z,t[94]=Q):Q=t[94];let $;return t[95]!==Ue||t[96]!==rt.Root||t[97]!==V||t[98]!==Q?($=(0,h.jsxs)(rt.Root,{open:Ue,onOpenChange:C,children:[V,Q]}),t[95]=Ue,t[96]=rt.Root,t[97]=V,t[98]=Q,t[99]=$):$=t[99],$}function ve(e){return e.preventDefault()}function ye(e){return e.language}function be({models:e,value:t,onChange:n,searchPlaceholder:r,noMatches:i,disabled:ee,showSearch:te=e.length>10,outOfFilterNote:re,groupByProvider:o=!1}){let s=a(e=>e.language),[c,ie]=(0,m.useState)(``),ae=_e(e,te?c:``),d=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{c||d.current?.scrollIntoView?.({block:`nearest`})},[t,c,ae.some(e=>e.id===t)]);let f=new Map;for(let t of e){let e=o?t.provider:``;f.has(e)||f.set(e,[])}for(let e of ae)f.get(o?e.provider:``).push(e);return(0,h.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[te&&(0,h.jsx)(`input`,{type:`search`,"aria-label":r,placeholder:r,value:c,onChange:e=>ie(e.target.value),className:u(`mx-1 mb-2 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,`focus:outline-none focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:shadow-none focus-visible:border-edge`)}),(0,h.jsxs)(`div`,{"data-select-scroll-region":!0,className:u(l,o&&`scroll-pt-8`),children:[ae.length===0&&(0,h.jsx)(`p`,{className:`px-3 py-4 text-sm text-fg-muted`,children:i}),[...f].filter(([,e])=>e.length>0).map(([r,i])=>(0,h.jsxs)(`div`,{role:o?`group`:void 0,"aria-label":o?r:void 0,className:o?`border-t border-edge-subtle pb-1 first:border-t-0`:void 0,children:[o&&(0,h.jsx)(`p`,{className:`sticky top-0 z-10 bg-surface-overlay px-3 pb-1 pt-3 text-xs font-medium text-fg-muted`,children:r}),i.map(r=>(0,h.jsxs)(`button`,{type:`button`,disabled:ee,title:r.id,ref:r.id===t?d:void 0,"aria-pressed":r.id===t,style:e.length>50?{contentVisibility:`auto`,containIntrinsicSize:`auto 60px`}:void 0,className:u(`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-fg hover:bg-surface-hover disabled:opacity-50`,ce.focusRingPanel,r.id===t&&`bg-surface-hover`),onClick:()=>n(r.id),children:[(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`truncate font-medium`,children:p(r,s)}),(r.phoneUse||r.computerUse?.dedicated||r.reasoning)&&(0,h.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:r.phoneUse?s===`zh`?`手机控制`:`Phone control`:r.computerUse?.dedicated?s===`zh`?`电脑控制`:`Computer control`:s===`zh`?`推理`:`Reasoning`})]}),!o&&(0,h.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:r.provider}),re&&!r.vision&&r.id===t&&(0,h.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:re})]}),(0,h.jsx)(ne,{className:u(`size-4 shrink-0 text-accent-fg`,r.id!==t&&`invisible`),"aria-hidden":!0})]},r.id))]},r))]})]})}export{_ as n,p as r,be as t};
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-BQtTLe6Q.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/locale-store-Br7IfbXK.js","assets/messages-ByFlEbsu.js","assets/unlink-BEuthaaq.js","assets/createLucideIcon-DPHK1VkS.js","assets/check-DUBLcKHA.js","assets/copy-Dv6d4Dvw.js","assets/external-link-DjqjBmc3.js","assets/notes-api-CUlhTRv0.js","assets/markdown-view-DrVAMlwc.js","assets/chunk-KS7C4IRE-CiwuuyV8.js","assets/preload-helper-Czpn1I53.js","assets/download-Dk-ZjtO6.js","assets/file-image-CDUPkZvG.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/dist-DfWfZ9iu.js","assets/dist-CxGUk8J-.js","assets/es2015-DBLcMg5B.js","assets/app-link-1j40sJ-z.js","assets/product-delivery-DRyD9_Xq.js","assets/schemas-CCWMleym.js","assets/local-apps-Ck6kACsY.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/xml-_d7dTN2Q.js","assets/mermaid-render-oOellPHt.js","assets/markdown-view-C-DHb3Io.css","assets/chat-chart-block-DCzUECct.js","assets/skeleton-BI5TyibZ.js","assets/list-todo-CTVRto8O.js","assets/loader-circle-CifKLtgG.js","assets/mic-CuUb7zc-.js","assets/pause-DuPxgSxk.js","assets/pencil-DmIY3Oa-.js","assets/play-kxZvpBg8.js","assets/floating-ui.dom-seOukHzT.js","assets/vendor-swr-CdRzEUwF.js","assets/vendor-codemirror-aCQ0FcJT.js","assets/with-selector-xonYxPoM.js","assets/note-image-lightbox-cLGiF8oU.js","assets/block-editor-Cvy3D_4T.css","assets/markdown-editor-BuuGlcfG.js","assets/languages-zXtNocoy.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{l as a,t as o,u as s}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{f as c,i as l,l as u,n as d,o as f,p}from"./locale-store-Br7IfbXK.js";import{t as m}from"./messages-ByFlEbsu.js";import{E as h,b as g,d as _,h as v,i as y,n as b,o as x,r as S,t as C,w,x as T}from"./discussion-annotation-sync-ClKEyXmN.js";import{t as E}from"./arrow-left-D880xG-P.js";import{a as D,c as O,d as k,i as A,l as j,n as M,o as N,r as P,s as F,t as I,u as L}from"./product-automation-feedback-Tn2dUJWM.js";import{t as ee}from"./check-DUBLcKHA.js";import{t as R}from"./chevron-down-ccbiQQz_.js";import{n as te,r as z}from"./popover-select-DD8fmrxH.js";import{t as ne}from"./circle-check-C23XjkUj.js";import{t as re}from"./code-xml-DJtYhZUF.js";import{t as ie}from"./copy-Dv6d4Dvw.js";import{t as ae}from"./download-Dk-ZjtO6.js";import{t as oe}from"./ellipsis-0k4rZLoy.js";import{t as se}from"./external-link-DjqjBmc3.js";import{t as B}from"./eye-CABVeTq0.js";import{t as ce}from"./file-text-D12HbeVy.js";import{t as le}from"./history-DXH_9jsE.js";import{C as ue,E as V,F as de,O as fe,P as pe,S as me,T as H,_ as U,a as he,c as ge,d as _e,f as ve,h as ye,l as be,m as xe,n as Se,r as W,s as G,u as Ce,w as K,x as we}from"./notes-api-CUlhTRv0.js";import{t as Te}from"./loader-circle-CifKLtgG.js";import{P as Ee}from"./markdown-view-DrVAMlwc.js";import{t as De}from"./message-circle-Badhj-4D.js";import{t as Oe}from"./pencil-DmIY3Oa-.js";import{t as ke}from"./play-kxZvpBg8.js";import{t as q}from"./refresh-cw-BRlGaq2w.js";import{t as Ae}from"./search-DA7gz22f.js";import{t as je}from"./sparkles-DHlfQFAF.js";import{t as Me}from"./square-pen-B8FsvqNu.js";import{t as Ne}from"./square-DMK_fB-3.js";import{t as Pe}from"./trash-2-DusmjVPV.js";import{t as Fe}from"./x-B_N4OPjy.js";import{t as J}from"./cn-0WouolD0.js";import{t as Y}from"./button-CnRSIP6m.js";import{t as Ie}from"./skeleton-BI5TyibZ.js";import{a as Le,i as Re,n as ze,o as X,r as Z,s as Be,t as Ve}from"./dist-DfWfZ9iu.js";import{a as He,i as Ue,o as We,s as Ge}from"./dist-CaUuvp8-.js";import{i as Ke}from"./vendor-swr-CdRzEUwF.js";import{t as qe}from"./session-manager-ChUtTAoG.js";import{t as Je}from"./copy-to-clipboard-HOJ79TWv.js";import{r as Ye}from"./app-chrome-BeB4KgOf.js";import{i as Xe}from"./theme-store-Dlnmgryi.js";import{t as Ze}from"./page-header-store-Du44NIEJ.js";import{t as Qe}from"./sliding-tab-list-DuQyViqe.js";import{t as $e}from"./confirm-dialog-XGclfBqe.js";import{b as et,d as tt,o as nt,s as rt,v as it}from"./shares-api-D8Q-m46d.js";import{l as at,m as ot,o as st,r as ct,t as lt,u as ut}from"./dist-D3lWNSe7.js";import{t as dt}from"./automation-api-hRsGx-qe.js";import{t as ft}from"./oauth-provider-connect-C8BXow79.js";import{n as pt,t as mt}from"./page-context-draft-LF33STHC.js";import"./note-image-lightbox-cLGiF8oU.js";import{t as ht}from"./page-context-capture-button-CBFK41OS.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:o,variant:c}=e,l=c===void 0?`card`:c,u=d(Dt),f=m(u).automations.suggestions,p=m(u).automations,h=s(),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=g):g=t[0];let{data:_}=Ke(a?`automation-suggestion-coverage`:null,Et,g),v=a?_?.automations.find(e=>A(e,a)):void 0,y=v?M(v,p):[];if(l===`titleAction`){if(v){let e;t[1]===o?e=t[2]:(e=J(`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`,o),t[1]=o,t[2]=e);let n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(ne,{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]===h?r=t[5]:(r=()=>h(`/automations`),t[4]=h,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)(Y,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:r,children:f.manage})]})}let e;t[6]===o?e=t[7]:(e=J(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,o),t[6]=o,t[7]=e);let a;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(w,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=a):a=t[8];let s;t[9]!==r||t[10]!==n?(s=(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]=s):s=t[11];let c;t[12]!==h||t[13]!==i?(c=()=>{let e=new URLSearchParams({draft:i,autogenerate:`1`});h(`/automations?${e.toString()}`)},t[12]=h,t[13]=i,t[14]=c):c=t[14];let l;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),t[15]=l):l=t[15],(0,$.jsxs)(`section`,{className:e,children:[a,s,(0,$.jsxs)(Y,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:c,children:[l,f.setup]})]})}if(v){let e;t[16]===o?e=t[17]:(e=J(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,o),t[16]=o,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(ne,{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]===h?r=t[20]:(r=()=>h(`/automations`),t[19]=h,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)(Y,{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:P(f.coveredDescription,{name:v.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:y.map(Tt)})]}),i]})}let b;t[24]===o?b=t[25]:(b=J(`rounded-lg bg-surface-panel p-3 shadow-surface`,o),t[24]=o,t[25]=b);let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(w,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=x):x=t[26];let S;t[27]===n?S=t[28]:(S=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n}),t[27]=n,t[28]=S);let C;t[29]===r?C=t[30]:(C=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:r}),t[29]=r,t[30]=C);let T;t[31]!==S||t[32]!==C?(T=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[x,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]})]}),t[31]=S,t[32]=C,t[33]=T):T=t[33];let E;t[34]!==h||t[35]!==i?(E=()=>{let e=new URLSearchParams({draft:i,autogenerate:`1`});h(`/automations?${e.toString()}`)},t[34]=h,t[35]=i,t[36]=E):E=t[36];let D;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),t[37]=D):D=t[37];let O;t[38]!==f.create||t[39]!==E?(O=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(Y,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:E,children:[D,f.create]})}),t[38]=f.create,t[39]=E,t[40]=O):O=t[40];let k;return t[41]!==O||t[42]!==b||t[43]!==T?(k=(0,$.jsxs)(`section`,{className:b,children:[T,O]}),t[41]=O,t[42]=b,t[43]=T,t[44]=k):k=t[44],k}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 dt.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:u,onOrganize:d,onRegenerate:f,onPersonalNotes:p,noteActions:m}=e,[h,g]=(0,Q.useState)(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{g(!1),e()},t[0]=_):_=t[0];let v=_,y=`/api/discussions/${encodeURIComponent(n.discussion.id)}`,b=!!n.discussion.audioAttachmentId&&!n.discussion.audioDeletedAt,x=a?`更多笔记操作`:`More note actions`,S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(oe,{className:`size-5`,"aria-hidden":!0}),t[1]=S):S=t[1];let C;t[2]===x?C=t[3]:(C=(0,$.jsx)(Ge,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":x,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:S})}),t[2]=x,t[3]=C);let w=a?`笔记工具`:`Note tools`,T;t[4]!==p||t[5]!==a?(T=p?(0,$.jsxs)(Y,{className:`min-h-11 w-full justify-start`,onClick:()=>v(p),children:[(0,$.jsx)(Me,{className:`size-4`}),a?`添加我的补充`:`Add my notes`]}):null,t[4]=p,t[5]=a,t[6]=T):T=t[6];let E;t[7]!==m||t[8]!==a?(E=m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Y,{className:`min-h-11 w-full justify-start`,disabled:m.busy,onClick:()=>v(m.onAnalyze),children:[(0,$.jsx)(je,{className:`size-4`}),a?`进一步分析`:`Analyze this note`]}),(0,$.jsxs)(Y,{className:`min-h-11 w-full justify-start`,disabled:m.busy,onClick:()=>v(m.onChat),children:[(0,$.jsx)(De,{className:`size-4`}),a?`就这篇笔记提问`:`Ask about this note`]})]}):null,t[7]=m,t[8]=a,t[9]=E):E=t[9];let D=a?`整理笔记`:`Organize notes`,O;t[10]===D?O=t[11]:(O=(0,$.jsx)(`p`,{className:`px-2 text-xs text-fg-muted`,children:D}),t[10]=D,t[11]=O);let k=a?`纪要模板`:`Summary template`,A;t[12]===i?A=t[13]:(A=e=>i(e.target.value),t[12]=i,t[13]=A);let j=a?`通用会议`:`General`,M;t[14]===j?M=t[15]:(M=(0,$.jsx)(z,{value:`general`,children:j}),t[14]=j,t[15]=M);let N=a?`项目例会`:`Project`,P;t[16]===N?P=t[17]:(P=(0,$.jsx)(z,{value:`project`,children:N}),t[16]=N,t[17]=P);let F=a?`需求评审`:`Review`,I;t[18]===F?I=t[19]:(I=(0,$.jsx)(z,{value:`review`,children:F}),t[18]=F,t[19]=I);let L=a?`客户访谈`:`Interview`,ee;t[20]===L?ee=t[21]:(ee=(0,$.jsx)(z,{value:`interview`,children:L}),t[20]=L,t[21]=ee);let R;t[22]!==k||t[23]!==A||t[24]!==M||t[25]!==P||t[26]!==I||t[27]!==ee||t[28]!==r?(R=(0,$.jsxs)(te,{value:r,"aria-label":k,onChange:A,children:[M,P,I,ee]}),t[22]=k,t[23]=A,t[24]=M,t[25]=P,t[26]=I,t[27]=ee,t[28]=r,t[29]=R):R=t[29];let ne=o||s||!n.discussion.canonicalTranscript,re;t[30]===d?re=t[31]:(re=()=>v(d),t[30]=d,t[31]=re);let ie;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(q,{className:`size-4`}),t[32]=ie):ie=t[32];let se=a?`重新整理纪要`:`Regenerate summary`,B;t[33]!==ne||t[34]!==re||t[35]!==se?(B=(0,$.jsxs)(Y,{className:`min-h-11 w-full justify-start`,disabled:ne,onClick:re,children:[ie,se]}),t[33]=ne,t[34]=re,t[35]=se,t[36]=B):B=t[36];let ce;t[37]!==b||t[38]!==o||t[39]!==n.discussion.status||t[40]!==f||t[41]!==s||t[42]!==a?(ce=b&&[`completed`,`needs_attention`].includes(n.discussion.status)?(0,$.jsx)(Y,{className:`min-h-11 w-full justify-start`,disabled:o||s,onClick:()=>v(f),children:a?`从原音重新生成`:`Regenerate from audio`}):null,t[37]=b,t[38]=o,t[39]=n.discussion.status,t[40]=f,t[41]=s,t[42]=a,t[43]=ce):ce=t[43];let le;t[44]!==R||t[45]!==B||t[46]!==ce||t[47]!==O?(le=(0,$.jsxs)(`div`,{className:`space-y-2 py-3`,children:[O,R,B,ce]}),t[44]=R,t[45]=B,t[46]=ce,t[47]=O,t[48]=le):le=t[48];let ue=a?`导出与分享`:`Export and share`,V;t[49]===ue?V=t[50]:(V=(0,$.jsx)(`p`,{className:`px-2 text-xs text-fg-muted`,children:ue}),t[49]=ue,t[50]=V);let de;t[51]!==b||t[52]!==y||t[53]!==a?(de=b?(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:l(`${y}/audio`),download:!0,children:[(0,$.jsx)(ae,{className:`size-4`}),a?`下载录音`:`Download recording`]}):null,t[51]=b,t[52]=y,t[53]=a,t[54]=de):de=t[54];let fe;t[55]!==m||t[56]!==a?(fe=m?(0,$.jsx)(Y,{className:`min-h-11 w-full justify-start`,disabled:m.busy,onClick:()=>v(m.onShare),children:a?`分享笔记`:`Share note`}):null,t[55]=m,t[56]=a,t[57]=fe):fe=t[57];let pe;t[58]===y?pe=t[59]:(pe=(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:l(`${y}/export?format=${e}`),download:!0,children:e.toUpperCase()},e))}),t[58]=y,t[59]=pe);let me=n.note.id,H=String(n.note.remoteVersion??1),U;t[60]!==n.note.id||t[61]!==H?(U={kind:`note`,id:me,revision:H},t[60]=n.note.id,t[61]=H,t[62]=U):U=t[62];let he;t[63]===c?he=t[64]:(he={text:c,draft:!1},t[63]=c,t[64]=he);let ge=a?`带到新对话`:`Use in a new chat`,_e=o||s||u||!c||c.length>16e3,ve;t[65]!==U||t[66]!==he||t[67]!==ge||t[68]!==_e?(ve=(0,$.jsx)(ht,{resource:U,selection:he,label:ge,disabled:_e}),t[65]=U,t[66]=he,t[67]=ge,t[68]=_e,t[69]=ve):ve=t[69];let ye=c.length>16e3?a?`内容较长,请先筛选部分原文。`:`Filter the transcript to share a smaller selection.`:a?`分享当前显示的文字,不包含原音。`:`Shares displayed text, without audio.`,be;t[70]===ye?be=t[71]:(be=(0,$.jsx)(`p`,{className:`px-2 text-xs leading-5 text-fg-muted`,children:ye}),t[70]=ye,t[71]=be);let xe;t[72]!==V||t[73]!==de||t[74]!==fe||t[75]!==pe||t[76]!==ve||t[77]!==be?(xe=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle py-3`,children:[V,de,fe,pe,ve,be]}),t[72]=V,t[73]=de,t[74]=fe,t[75]=pe,t[76]=ve,t[77]=be,t[78]=xe):xe=t[78];let Se;t[79]!==m||t[80]!==a?(Se=m?(0,$.jsxs)(`div`,{className:`space-y-1 border-t border-edge-subtle pt-2`,children:[(0,$.jsx)(Y,{className:`min-h-11 w-full justify-start`,onClick:()=>v(m.onHistory),children:a?`版本历史`:`Version history`}),(0,$.jsx)(Y,{className:`min-h-11 w-full justify-start text-danger`,disabled:m.busy,onClick:()=>v(m.onDelete),children:a?`删除笔记`:`Delete note`})]}):null,t[79]=m,t[80]=a,t[81]=Se):Se=t[81];let W;t[82]!==le||t[83]!==xe||t[84]!==Se||t[85]!==w||t[86]!==T||t[87]!==E?(W=(0,$.jsx)(He,{children:(0,$.jsxs)(Ue,{align:`end`,sideOffset:6,collisionPadding:12,"aria-label":w,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:[T,E,le,xe,Se]})}),t[82]=le,t[83]=xe,t[84]=Se,t[85]=w,t[86]=T,t[87]=E,t[88]=W):W=t[88];let G;return t[89]!==h||t[90]!==C||t[91]!==W?(G=(0,$.jsxs)(We,{open:h,onOpenChange:g,children:[C,W]}),t[89]=h,t[90]=C,t[91]=W,t[92]=G):G=t[92],G}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[u,d]=(0,Q.useState)(),[p,m]=(0,Q.useState)(!0),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(0),[b,x]=(0,Q.useState)(),[S,C]=(0,Q.useState)(),[w,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)(()=>{C(void 0)},[e,t]),(0,Q.useEffect)(()=>{let n=++y.current,r=new AbortController;m(!0),v(!1),g(``);let a=window.setTimeout(()=>{f(l(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}`),{signal:r.signal}).then(e=>{y.current===n&&(d(e),x(i),T(t))}).catch(e=>{y.current===n&&!r.signal.aborted&&g(String(e))}).finally(()=>{y.current===n&&m(!1)})},t?200:0);return()=>{y.current++,r.abort(),window.clearTimeout(a)}},[e,t,r,i,E]);async function O(){if(!u||_)return;let r=y.current;v(!0);try{let n=await f(l(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}&offset=${u.hits.length}&version=${u.version}`));r===y.current&&d({...n,hits:[...u.hits,...n.hits]})}catch(e){r===y.current&&g(n?`内容已变化,请重新搜索。${String(e)}`:`Content changed; search again. ${String(e)}`)}finally{v(!1)}}function k(e){C(e),(!e.provisional||e.kind===`chapter`)&&e.transcriptRevision!==void 0&&e.segments.length&&s({transcriptRevision:e.transcriptRevision,stale:e.stale,audioAvailable:u?.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||S?.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)(Y,{onClick:()=>c(e.startedAtMs,e.endedAtMs),children:[n?`回听上下文`:`Play context`,` `,kt(e.startedAtMs),`–`,kt(e.endedAtMs)]},t)),e.segments.length?(0,$.jsx)(Y,{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:[h?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:h}),(0,$.jsx)(Y,{onClick:()=>D(e=>e+1),children:n?`刷新结果`:`Refresh results`})]}):null,p&&(!u||b!==i||w!==t)?(0,$.jsx)(Ie,{className:`h-20 w-full`}):null,u&&b===i&&(!t||w===t)?(0,$.jsxs)($.Fragment,{children:[t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`搜索结果 · ${u.total}`:`Search results · ${u.total}`}),(0,$.jsx)(Y,{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:u.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,u.coverage.durationMs))}%`},"aria-label":`${kt(e.startedAtMs)} ${e.title||A(e)}`,onClick:()=>k(e)},e.id))}),u.total?null:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`未找到关键词;尚未转写的内容无法搜索。`:`No matches. Untranscribed audio is not searchable yet.`}),u.hits.map(j)]}):(0,$.jsxs)($.Fragment,{children:[o===`summary`&&u.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`,` · `,u.chapters.length]}),(0,$.jsx)(`div`,{className:`space-y-3 pb-4`,children:u.chapters.map(j)})]}):null,u.hits.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`本轮已完成转写(阶段性)`:`Available transcription from this run`}),u.hits.map(j)]}):null]}),u.hasMore?(0,$.jsx)(Y,{disabled:_,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`,` · `,u.coverage.audioAvailable?n?`已保存,可回听`:`Saved, ready to play`:n?`尚不可用`:`Unavailable`]}),(0,$.jsxs)(`p`,{children:[n?`本轮转写已处理`:`Processed this run`,` `,kt(u.coverage.processedMs),` / `,kt(u.coverage.durationMs),` · `,n?`连续处理至`:`Continuous through`,` `,kt(u.coverage.continuousThroughMs)]}),(0,$.jsxs)(`p`,{children:[n?`分析覆盖`:`Analysis coverage`,` · `,u.coverage.analysisRanges.length?u.coverage.analysisRanges.map(e=>`${kt(e.startedAtMs)}–${kt(e.endedAtMs)}`).join(`、`):n?`暂无本版已完成章节`:`No completed chapters for this revision`,u.coverage.analysisStale?n?`;已发布分析基于旧版原文`:`; published analysis uses an earlier transcript`:``,` · `,u.coverage.complete?n?`本轮处理完成`:`Run complete`:n?`阶段性内容,其余仍待处理`:`Partial content; remaining work pending`]})]})]}),S?.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}=Ke(`/api/discussions/${t}/annotations`,e=>f(l(e))),[s,c]=(0,Q.useState)([]),[u,d]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``),_=(0,Q.useCallback)(async()=>{c(await S(e))},[e]),v=(0,Q.useCallback)(async()=>{try{await C(e,t),await _(),await o()}catch(e){await o(),g(e instanceof Error?e.message:String(e))}},[e,t,_,o]);(0,Q.useEffect)(()=>{_().catch(e=>g(String(e))),v();let e=()=>{_().catch(e=>g(String(e)))};window.addEventListener(`discussion-annotations-changed`,e),window.addEventListener(`online`,v);let t=window.setInterval(()=>{navigator.onLine&&v()},15e3);return()=>{window.removeEventListener(`discussion-annotations-changed`,e),window.removeEventListener(`online`,v),window.clearInterval(t)}},[_,v]);let y=new Map(a.map(e=>[e.annotation.id,{...e,localState:`synced`}]));for(let e of s)if(e.state!==`synced`||!y.has(e.annotation.id)){let t=y.get(e.annotation.id);y.set(e.annotation.id,{annotation:e.annotation,state:t?.state??`pending`,playback:t?.playback??[],evidence:t?.evidence,localState:e.state})}let w=async(t,n=s.find(e=>e.annotation.id===t.id)?.nonce??null)=>{try{await x(e,{...t,updatedAt:Date.now()},n),m(null),g(``),await _(),v()}catch(e){g(e instanceof Error?e.message:String(e))}};return(0,$.jsxs)(`section`,{className:`space-y-4`,"aria-label":n?`我的标记`:`My highlights`,children:[h?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[h,(0,$.jsx)(Y,{onClick:()=>void v(),children:n?`重试同步`:`Retry sync`})]}):null,y.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.`}),[...y.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)(Y,{disabled:!e.evidence,onClick:()=>e.evidence&&r(e.evidence),children:n?`查看原文`:`View transcript`}),e.playback.map((e,t)=>(0,$.jsxs)(Y,{onClick:()=>i(e),children:[n?`回听`:`Play`,` `,Math.floor(e.startedAtMs/6e4),`:`,String(Math.floor(e.startedAtMs/1e3)%60).padStart(2,`0`)]},t)),(0,$.jsx)(Y,{onClick:()=>{d(s.find(t=>t.annotation.id===e.annotation.id)?.nonce??null),m({...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)(Y,{onClick:()=>void w({...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)(Y,{onClick:()=>{let t=s.find(t=>t.annotation.id===e.annotation.id),n=a.find(t=>t.annotation.id===e.annotation.id);t&&n&&b(t,n.annotation).then(_)},children:n?`使用服务端版本`:`Use server version`}):null]},e.annotation.id)),p?(0,$.jsxs)(`div`,{role:`dialog`,"aria-label":n?`编辑标记`:`Edit highlight`,className:`rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(te,{value:p.kind,"aria-label":n?`标记类型`:`Highlight type`,onChange:e=>m({...p,kind:e.target.value}),children:[(0,$.jsx)(z,{value:`highlight`,children:n?`重点`:`Highlight`}),(0,$.jsx)(z,{value:`question`,children:n?`问题`:`Question`}),(0,$.jsx)(z,{value:`note`,children:n?`补充`:`Context`})]}),(0,$.jsx)(`textarea`,{"aria-label":n?`我的说明`:`My context`,maxLength:4e3,value:p.text,onChange:e=>m({...p,text:e.target.value}),className:`my-2 min-h-24 w-full rounded border border-edge bg-surface-inset p-2`}),(0,$.jsx)(Y,{onClick:()=>void w(p,u),children:n?`保存到本机并同步`:`Save locally and sync`}),(0,$.jsx)(Y,{onClick:()=>m(null),children:n?`取消`:`Cancel`})]}):null]})}var Mt={tab:`summary`,query:``,page:1,positionMs:0},Nt=p((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)(Le,{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)(Be,{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)(Y,{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 T;t[34]!==s||t[35]!==o?(T=()=>void o(s),t[34]=s,t[35]=o,t[36]=T):T=t[36];let E=r?`保存修改`:`Save changes`,D;t[37]!==w||t[38]!==T||t[39]!==E?(D=(0,$.jsx)(Y,{variant:`primary`,disabled:w,onClick:T,children:E}),t[37]=w,t[38]=T,t[39]=E,t[40]=D):D=t[40];let O;t[41]!==C||t[42]!==D?(O=(0,$.jsxs)(`footer`,{className:`flex justify-end gap-2 border-t border-edge p-3`,children:[C,D]}),t[41]=C,t[42]=D,t[43]=O):O=t[43];let k;t[44]!==x||t[45]!==O||t[46]!==f?(k=(0,$.jsxs)(X,{children:[u,(0,$.jsxs)(Z,{"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,O]})]}),t[44]=x,t[45]=O,t[46]=f,t[47]=k):k=t[47];let A;return t[48]!==l||t[49]!==k?(A=(0,$.jsx)(Ve,{open:!0,onOpenChange:l,children:k}),t[48]=l,t[49]=k,t[50]=A):A=t[50],A}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=d(e=>e.language)===`zh`,{data:s,mutate:c,isLoading:u}=Ke([`note-discussion-document`,e],()=>_(e),{refreshInterval:e=>e&&([`recording`,`stopping`,`sealing`,`organizing`].includes(e.discussion.status)||e.recordingJob?.state===`queued`||e.recordingJob?.state===`running`)?3e3:0}),p=s?.discussion.id,m=`/api/discussions/${encodeURIComponent(p??``)}`,{data:h=[],mutate:b}=Ke(p?`${m}/actions`:null,e=>f(l(e)),{refreshInterval:1e4}),S=Nt(t=>Ft(e,t.notes[e])),w=Nt(e=>e.update),E=S.tab,D=t=>w(e,{tab:t}),O=S.query,k=t=>w(e,{query:t}),[A,j]=(0,Q.useState)(!1),M=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{A&&M.current?.focus()},[A]);let[N,P]=(0,Q.useState)(`general`),[F,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(null),[te,z]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(!1),[ie,ae]=(0,Q.useState)([]),[oe,se]=(0,Q.useState)(null),[B,ce]=(0,Q.useState)(!1),le=S.page,ue=t=>w(e,{page:t}),V=(0,Q.useRef)(null),[de,fe]=(0,Q.useState)([]),pe=(0,Q.useRef)(0),me=(0,Q.useRef)(0),H=(0,Q.useRef)(s?.transcript.revision);H.current=s?.transcript.revision;let U=(0,Q.useRef)(null),he=(0,Q.useRef)(null),[,ge]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{c(),b()};return window.addEventListener(`discussion-updated`,e),window.addEventListener(`discussion-segment-updated`,e),()=>{window.removeEventListener(`discussion-updated`,e),window.removeEventListener(`discussion-segment-updated`,e)}},[c,b]),(0,Q.useEffect)(()=>{s?.discussion.template&&P(s.discussion.template)},[s?.discussion.template]);async function _e(e){if(!B){ce(!0),se(null);try{await e(),await c(),await b()}catch(e){se(e instanceof Error?e.message:String(e))}finally{ce(!1)}}}function ve(e,t){U.current&&(V.current=t??null,U.current.readyState===0?(he.current=e/1e3,U.current.load()):(U.current.currentTime=e/1e3,U.current.play().catch(()=>void 0)))}function ye(e){let t=e.stale||e.transcriptRevision!==H.current;I({...e,stale:t}),t||fe(e.segments.map(e=>e.sequence))}async function be(e,t,n=!1){if(!s)return;let r=pe.current,i=++me.current;await _e(async()=>{let a=await f(l(`${m}/evidence?revision=${t??s.organization?.transcriptRevision??s.transcript.revision}&segments=${e.join(`,`)}`));if(!(r!==pe.current||i!==me.current)&&(ye(a),n&&a.segments[0]?.playback[0])){let e=a.segments[0].playback[0];ve(e.startedAtMs,e.endedAtMs)}})}async function xe(e){s&&await _e(async()=>{await x(s.discussion.clientRequestId,y({type:`transcript`,capturedAt:Date.now(),transcriptRevision:s.transcript.revision,segmentIds:[e.sequence]})),D(`marks`),C(s.discussion.clientRequestId,s.discussion.id).catch(e=>se(String(e)))})}(0,Q.useEffect)(()=>(pe.current++,I(null),fe([]),R(null),z(null),ae([]),se(null),V.current=null,()=>{pe.current++}),[e]),(0,Q.useEffect)(()=>{let t=s?.discussion.audioSha256??s?.discussion.audioAttachmentId;if(!t)return;let n=Ft(e,Nt.getState().notes[e]);n.source&&n.source!==t?(pe.current++,I(null),fe([]),U.current?.pause(),w(e,{positionMs:0,source:t}),he.current=0,V.current=null):w(e,{source:t})},[e,s?.discussion.audioSha256,s?.discussion.audioAttachmentId,w]),(0,Q.useEffect)(()=>{s?.discussion.audioDeletedAt&&(U.current?.pause(),he.current=null,V.current=null,I(e=>e?{...e,audioAvailable:!1,timingVerified:!1,segments:e.segments.map(e=>({...e,playback:[]}))}:null))},[s?.discussion.audioDeletedAt]),(0,Q.useEffect)(()=>{S.tab===`transcript`&&S.anchor!==void 0&&S.anchorRevision===s?.transcript.revision&&window.setTimeout(()=>document.getElementById(`discussion-segment-${S.anchor}`)?.scrollIntoView?.({block:`center`}),0)},[S.tab,S.anchor,S.anchorRevision,s?.transcript.revision]),(0,Q.useEffect)(()=>{fe([]),I(e=>e&&e.transcriptRevision!==s?.transcript.revision?{...e,stale:!0}:e)},[s?.transcript.revision]);let Se=(e,t,n)=>t.some(e=>ne||!e.ignored)?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`font-semibold text-fg`,children:e}),t.filter(e=>ne||!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:B,onClick:()=>z({kind:n,itemId:e.id,text:e.text,ignored:e.ignored}),children:i?`编辑`:`Edit`}),e.evidenceSegmentIds.length?(0,$.jsx)(`button`,{disabled:B,className:`shrink-0 text-accent-fg`,onClick:()=>void be(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)(Ie,{className:`h-48 w-full`});if(!s)return null;let{discussion:W,transcript:G,organization:Ce}=s,K=Ce?.organization,we=[`stopping`,`sealing`,`organizing`].includes(W.status),Te=[`recording`,`completed`,`needs_attention`].includes(W.status),De=G.segments.filter(e=>(e.displayText??e.rawText??``).toLocaleLowerCase().includes(O.toLocaleLowerCase())||e.speakerLabel?.toLocaleLowerCase().includes(O.toLocaleLowerCase())),Oe=E===`marks`||O.trim()?``:Lt(s,E,{query:O,page:le,showIgnored:ne});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(),j(!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:!s.note.title||/^Discussion · \d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(s.note.title)?i?`语音笔记`:`Voice note`:s.note.title}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[i?`录音`:`Recording`,` · `,Rt(W.durationMs??0)]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":i?`搜索此 Note`:`Search this Note`,"aria-expanded":A||!!O,onClick:()=>{j(e=>!e),A&&k(``)},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)(Ae,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(Ot,{noteActions:n,detail:s,template:N,onTemplate:P,zh:i,busy:B,processing:we,pageText:Oe,editing:!!te||!!L,onPersonalNotes:t,onOrganize:()=>void _e(()=>f(l(`${m}/organize`),{method:`POST`,body:JSON.stringify({template:N})})),onRegenerate:()=>void _e(()=>v(W.id,`from_audio`))})]}),(0,$.jsx)(Qe,{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":E===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 ${E===e?`bg-surface-panel font-medium text-fg shadow-sm`:`text-fg-muted hover:text-fg`}`,onClick:()=>D(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,A||O?(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)(Ae,{className:`size-4 text-fg-muted`}),(0,$.jsx)(`input`,{ref:M,"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:O,onChange:e=>{k(e.target.value),ue(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:()=>{k(``),j(!1)},children:(0,$.jsx)(Fe,{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:[W.status!==`recording`||s.recordingJob?(0,$.jsx)(g,{context:`note`,input:T(s),zh:i,busy:B,onRetry:e=>void _e(()=>e===`analyze`?f(l(`${m}/organize`),{method:`POST`,body:JSON.stringify({template:N})}):v(W.id,e===`regenerate`?`from_audio`:`resume`))}):null,(0,$.jsx)(`div`,{hidden:!!O.trim(),children:E===`marks`?(0,$.jsx)(jt,{recordingId:W.clientRequestId,discussionId:W.id,zh:i,onEvidence:ye,onPlay:e=>ve(e.startedAtMs,e.endedAtMs)},W.id):E===`summary`?K?(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:B||we,onClick:()=>z({kind:`summary`,itemId:`summary`,text:K.summary}),children:(0,$.jsx)(Me,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[15px] leading-7`,children:K.summary}),K.summaryEditedByUser?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`已由你编辑`:`Edited by you`}):null,K.summaryEvidenceSegmentIds?.length?Array.from({length:Math.ceil(K.summaryEvidenceSegmentIds.length/100)},(e,t)=>(0,$.jsxs)(Y,{onClick:()=>void be(K.summaryEvidenceSegmentIds.slice(t*100,(t+1)*100)),children:[i?`查看原话`:`View source`,K.summaryEvidenceSegmentIds.length>100?` · ${t+1}`:``]},t)):null,K.keyPointEvidence?.length?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{children:i?`重点结论`:`Key points`}),K.keyPointEvidence.map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2 text-sm`,children:[(0,$.jsx)(`p`,{className:`flex-1`,children:e.text}),(0,$.jsx)(Y,{onClick:()=>void be(e.evidenceSegmentIds,e.evidenceRevision),children:i?`原话`:`Source`})]},e.id))]}):K.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:K.keyPoints.map((e,t)=>(0,$.jsx)(`li`,{children:e},`${t}:${e}`))})]}):null,[...K.decisions,...K.actionItems,...K.risks,...K.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:ne,onChange:e=>re(e.target.checked)}),i?`显示已忽略项`:`Show ignored items`]}):null,ie.length?(0,$.jsx)(Y,{disabled:B,onClick:()=>void _e(async()=>{for(let e of ie)await f(l(`${m}/actions/${encodeURIComponent(e)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:Ce.revision})});ae([])}),children:i?`加入所选 ${ie.length} 项任务`:`Add ${ie.length} selected tasks`}):null,Se(i?`已决定事项`:`Decisions`,K.decisions,`decisions`),K.actionItems.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:i?`下一步行动`:`Next actions`}),K.actionItems.filter(e=>ne||!e.ignored).map(e=>{let t=h.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:ie.includes(e.id),onChange:t=>ae(t.target.checked?[...ie,e.id]:ie.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:B||we,onClick:()=>z({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:B,className:`text-accent-fg`,onClick:()=>void be(e.evidenceSegmentIds,e.evidenceRevision),children:i?`查看原话`:`Source`}):null,t?t.deleted?(0,$.jsx)(`span`,{children:i?`关联任务已删除`:`Linked task deleted`}):(0,$.jsx)(o,{className:`text-accent-fg`,to:Ee(`${r.pathname}${r.search}`,t.taskId),children:t.resolution===`done`?i?`已完成 · 查看任务`:`Done · View task`:i?`查看任务 / 交给助手`:`View task / Delegate`}):e.ignored?null:(0,$.jsx)(Y,{disabled:B||!!(e.supersededBy||e.disputedBy)&&e.reviewedChangeId!==(e.supersededBy??e.disputedBy),onClick:()=>void _e(()=>f(l(`${m}/actions/${encodeURIComponent(e.id)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:Ce.revision})})),children:i?`加入我的任务`:`Add to my tasks`})]})]},e.id)})]}):null,Se(i?`风险`:`Risks`,K.risks,`risks`),Se(i?`尚未确定`:`Open questions`,K.openQuestions,`openQuestions`),K.changes?.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:i?`前后变更`:`Changes during the meeting`}),K.changes.map(e=>{let t=[...K.decisions,...K.actionItems,...K.risks,...K.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 be(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 be(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:G.text?i?`录音摘录`:`From your recording`:i?`笔记正在整理`:`Preparing your note`}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[15px] leading-7 ${G.text?`text-fg`:`text-fg-muted`}`,children:G.text?G.text.slice(0,400)+(G.text.length>400?`…`:``):i?`文字整理完成后,重点和行动会出现在这里。`:`Highlights and actions will appear as processing completes.`}),G.text?(0,$.jsx)(Y,{className:`min-h-11`,onClick:()=>D(`transcript`),children:i?`查看原文`:`Read transcript`}):null]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[De.slice(0,le*50).map(e=>(0,$.jsxs)(`article`,{id:`discussion-segment-${e.sequence}`,className:`rounded-md border p-3 ${de.includes(e.sequence)||S.anchor===e.sequence&&S.anchorRevision===G.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:!W.audioAttachmentId||!!W.audioDeletedAt,onClick:()=>void be([e.sequence],G.revision,!0),children:[(0,$.jsx)(ke,{className:`size-3`}),Rt(e.startedAtMs)]}),e.status===`confirmed`?(0,$.jsx)(`button`,{onClick:()=>void xe(e),children:i?`标记此段`:`Highlight segment`}):null,(0,$.jsx)(`span`,{children:e.speakerLabel??(i?`未区分说话人`:`Speaker unknown`)}),Te&&e.status===`confirmed`?(0,$.jsx)(`button`,{className:`ml-auto`,onClick:()=>R({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)),De.length>le*50?(0,$.jsx)(Y,{onClick:()=>ue(le+1),children:i?`加载更多`:`More`}):null]})}),(0,$.jsx)(`div`,{children:(0,$.jsx)(At,{id:W.id,query:O.trim(),zh:i,sourceKey:`${W.audioSha256}:${W.audioDeletedAt}`,active:we||W.status===`recording`,tab:E,refreshKey:`${W.updatedAt}:${G.revision}:${Ce?.revision}`,onEvidence:ye,onPlay:ve},W.id)})]}),W.audioAttachmentId&&!W.audioDeletedAt?(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,$.jsx)(`audio`,{ref:U,controls:!0,preload:`metadata`,className:`h-10 w-full`,src:l(`${m}/audio`),onTimeUpdate:()=>{let t=(U.current?.currentTime??0)*1e3;ge(t),w(e,{positionMs:t}),V.current!==null&&t>=V.current&&(U.current?.pause(),V.current=null)},onLoadedMetadata:()=>{he.current!==null&&U.current?(U.current.currentTime=he.current,he.current=null,U.current.play().catch(()=>void 0)):U.current&&(U.current.currentTime=S.positionMs/1e3)},onError:()=>se(i?`录音暂不可播放`:`Recording unavailable`)})}):null,F?(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-overlay`,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`,F.transcriptRevision]}),(0,$.jsx)(`button`,{"aria-label":i?`关闭`:`Close`,onClick:()=>I(null),children:(0,$.jsx)(Fe,{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.`}),F.stale?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`原文已更新,以下保留当时版本的依据。`:`Transcript updated; showing the original evidence revision.`}):null,!F.audioAvailable||!F.timingVerified?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`原文仍可查看;原音不可用或时间定位待核实。`:`Text remains available; audio is missing or timing is unverified.`}):null,F.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)(Y,{onClick:()=>ve(e.startedAtMs,e.endedAtMs),children:[i?`播放原话`:`Play source`,` `,Rt(e.startedAtMs),`–`,Rt(e.endedAtMs)]},t)),F.stale?null:(0,$.jsx)(Y,{onClick:()=>{k(``),ue(Math.max(le,Math.ceil((G.segments.findIndex(e=>e.sequence===t.sequence)+1)/50))),D(`transcript`),fe([t.sequence]),I(null),w(e,{anchor:t.sequence,anchorRevision:G.revision}),window.setTimeout(()=>document.getElementById(`discussion-segment-${t.sequence}`)?.scrollIntoView?.({block:`center`}),0)},children:i?`定位原文`:`Locate transcript`})]},t.sequence))]})]}):null,te&&Ce?(0,$.jsx)(It,{initial:te,zh:i,busy:B,onClose:()=>z(null),onSave:e=>_e(async()=>{await f(l(`${m}/summary`),{method:`PATCH`,body:JSON.stringify({...e,expectedRevision:Ce.revision})}),z(null)})},`${te.kind}:${te.itemId}:${Ce.revision}`):null,L?(0,$.jsx)(Ve,{open:!0,onOpenChange:e=>{e||R(null)},children:(0,$.jsxs)(X,{children:[(0,$.jsx)(Le,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(Z,{"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)(Be,{children:i?`校对逐字稿`:`Edit transcript`}),(0,$.jsx)(`button`,{"aria-label":i?`关闭校对`:`Close editor`,onClick:()=>R(null),children:(0,$.jsx)(Fe,{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:L.speaker,onChange:e=>R({...L,speaker:e.target.value})})]}),L.segment.speakerLabel?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!L.applyToSpeakerGroup,onChange:e=>R({...L,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:L.text,onChange:e=>R({...L,text:e.target.value})})]}),(0,$.jsx)(`footer`,{className:`border-t border-edge p-3`,children:(0,$.jsxs)(Y,{variant:`primary`,disabled:B||!L.text.trim(),onClick:()=>void _e(async()=>{await f(l(`${m}/segments/${L.segment.sequence}`),{method:`PATCH`,body:JSON.stringify({displayText:L.text,speakerLabel:L.speaker,expectedRevision:L.segment.revision,applyToSpeakerGroup:L.applyToSpeakerGroup,expectedTranscriptRevision:G.revision})}),R(null)}),children:[(0,$.jsx)(ee,{className:`size-4`}),i?`保存修订`:`Save revision`]})})]})]})}):null]})}var Bt={edit:Oe,ai_edit:je,sync:q,restore:h};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=d(e=>e.language),o=m(a).notes,s={justNow:o.justNow,minutesAgo:o.minutesAgo,today:o.today,yesterday:o.yesterday,daysAgo:o.daysAgo,locale:c(a)},{data:l}=Ke(e?[`note-history`,e]:null,()=>ve(e)),[u,f]=(0,Q.useState)(!1),[p,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),v=(0,Q.useCallback)(async t=>{f(!0),_(null);try{await H(e,t),h(null),i()}catch{_(o.restoreFailed)}finally{f(!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)(le,{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)(Fe,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[g?(0,$.jsx)(`p`,{className:`border-b border-danger/20 bg-danger-soft px-4 py-2 text-xs text-danger`,role:`alert`,children:g}):null,l?.length?(0,$.jsx)(`ul`,{className:`divide-y divide-edge`,children:l.map(e=>{let r=Bt[e.trigger]??Oe,i=t===e.timestamp,a=p===e.timestamp;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:J(`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(),v(e.timestamp)},disabled:u,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:u?`...`:o.restore}),(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),h(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(),h(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:o,onOpenChat:c,onOpenNewChat:l}){let u=m(d(e=>e.language)).notes,f=s(),p=t?.aiDeep?.catalysis,h=p?.report??null,[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),{data:b,mutate:x,isLoading:S}=Ke(e?[`note-agent-context-status`,e]:null,()=>be(e),{revalidateOnFocus:!1}),C=(0,Q.useCallback)(async()=>{if(!v){y(!0),_(null);try{await x(()=>we(e),{revalidate:!1})}catch(e){_(`${u.contextRebuildFailed}: ${e instanceof Error?e.message:u.quickCaptureFailedHint}`)}finally{y(!1)}}},[v,x,u.contextRebuildFailed,u.quickCaptureFailedHint,e]),w=(0,Q.useCallback)(async t=>{try{await me(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)(je,{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)(E,{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 C(),disabled:S||v,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:v?u.processing:u.contextRebuild}),(0,$.jsx)(`span`,{className:J(`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))}),g?(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:g}):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:h?u.recatalyze:u.catalyzeAction}),h?(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:h.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:h.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:h.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:h.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:h.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:h.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(h.confidence*100)))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(`helpful`),className:J(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackHelpfulAria,children:(0,$.jsx)(j,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(`not_helpful`),className:J(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackNotHelpfulAria,children:(0,$.jsx)(L,{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)(De,{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:o,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:o?u.openingChat:u.openThread}),(0,$.jsx)(`button`,{type:`button`,onClick:l,disabled:o,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:()=>f(`/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=d(e=>e.language)===`zh`,i=r?Yt:Xt,{data:a,mutate:o}=Ke(e?[`note-shares`,n.id]:null,()=>xe(n.id)),s=Ke(e?`hosted-share-auth-status`:null,tt),c=s.data===!0,l=Ke(e&&c?`hosted-publication-capabilities`:null,rt),u=l.data?.publishing.allowed===!0,f=Ke(e&&c?[`hosted-note-publications`,n.id]:null,()=>_e(n.id)),[p,m]=(0,Q.useState)(new Set),[h,g]=(0,Q.useState)(`86400000`),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(`hosted`),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),P=(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&&(m(new Set(P.map(e=>e.id))),O(null),j(!1),N(null))},[e,P]);let F=async()=>{w(!0),N(null);try{let e={expectedNoteVersion:n.updatedAt,attachmentIds:[...p],ttlMs:Number(h),maxViews:_.trim()?Number(_):null,description:y.trim()||void 0};if(x===`hosted`){let t=await W(n.id,e);O(t.shareUrl),await f.mutate()}else{let t=await he(n.id,e);O(t.payload.shareUrl),await o()}}catch(e){N(e instanceof Error?e.message:String(e))}finally{w(!1)}},I=async(e,t)=>{E(e.id),N(null);try{t===`refresh`?await ue(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...p]}):await it(e.id),await f.mutate()}catch(e){N(e instanceof Error?e.message:String(e))}finally{E(null)}},L=async(e,t)=>{E(e.id),N(null);try{t===`refresh`?await K(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...p]}):t===`extend`?await nt(e.id,864e5):await et(e.id),await o()}catch(e){N(e instanceof Error?e.message:String(e))}finally{E(null)}},R=async e=>{N(null);try{if(!await Je(e)){j(!1),N(i.copyFailed);return}j(!0),window.setTimeout(()=>j(!1),1500)}catch{j(!1),N(i.copyFailed)}};return(0,$.jsx)(Ve,{open:e,onOpenChange:t,children:(0,$.jsxs)(X,{children:[(0,$.jsx)(Le,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(Z,{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)(Be,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,$.jsx)(k,{className:`size-4`}),i.title]}),(0,$.jsx)(Re,{className:`mt-1 text-xs text-fg-muted`,children:i.description})]}),(0,$.jsx)(ze,{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)(Fe,{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})]}),P.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:P.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:p.has(e.id),onChange:()=>m(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)(te,{value:x,onChange:e=>S(e.target.value),children:[(0,$.jsx)(z,{value:`hosted`,children:i.deliveryHosted}),(0,$.jsx)(z,{value:`local`,children:i.deliveryLocal})]})]}),x===`hosted`&&s.data===!1?(0,$.jsx)(`div`,{className:`sm:col-span-2`,children:(0,$.jsx)(ft,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:()=>void s.mutate(!0,{revalidate:!1})})}):null,x===`hosted`&&c&&l.data&&!u?(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)(te,{value:h,onChange:e=>g(e.target.value),children:Wt.map(e=>(0,$.jsx)(z,{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:_,onChange:e=>v(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:y,onChange:e=>b(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`})]})]}),D?(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:D,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`}),(0,$.jsxs)(Y,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void R(D),children:[A?(0,$.jsx)(ee,{className:`size-4`}):(0,$.jsx)(ie,{className:`size-4`}),A?i.copied:i.copy]}),(0,$.jsxs)(Y,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>window.open(D,`_blank`,`noopener,noreferrer`),children:[(0,$.jsx)(se,{className:`size-4`}),i.open]})]})}):null,M?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,children:M}):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:T===e.id,t:i,onCopy:R,onAction:L},e.id))})]}):null,(f.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:f.data.map(e=>(0,$.jsx)(Kt,{publication:e,stale:e.source?.version!==String(n.updatedAt),busy:T===e.id,publishingAllowed:u,t:i,onCopy:R,onAction:I},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)(ze,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,children:i.close})}),(0,$.jsxs)(Y,{type:`button`,onClick:()=>void F(),disabled:C||x===`hosted`&&(!c||!u),children:[C?(0,$.jsx)(Te,{className:`size-4 animate-spin`}):(0,$.jsx)(k,{className:`size-4`}),C?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,u=l&&`opacity-60`,d;t[0]===u?d=t[1]:(d=J(`rounded-lg border border-edge-subtle p-3`,u),t[0]=u,t[1]=d);let f=r&&!l?o.stale:l?o.inactive:o.active,p;t[2]===f?p=t[3]:(p=(0,$.jsx)(`span`,{children:f}),t[2]=f,t[3]=p);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]!==o.views||t[7]!==h?(g=(0,$.jsxs)(`span`,{children:[o.views,` `,n.viewCount,h]}),t[5]=n.viewCount,t[6]=o.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 v;t[10]!==n.revision||t[11]!==o.revision?(v=(0,$.jsxs)(`span`,{children:[o.revision,` `,n.revision]}),t[10]=n.revision,t[11]=o.revision,t[12]=v):v=t[12];let y;t[13]!==p||t[14]!==g||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,g,_,v]}),t[13]=p,t[14]=g,t[15]=v,t[16]=y):y=t[16];let b;t[17]===n.shareUrl?b=t[18]:(b=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[17]=n.shareUrl,t[18]=b);let x;t[19]!==y||t[20]!==b?(x=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[y,b]}),t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;t[22]===i?S=t[23]:(S=i?(0,$.jsx)(Te,{className:`size-4 animate-spin text-fg-muted`}):null,t[22]=i,t[23]=S);let C;t[24]!==x||t[25]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[x,S]}),t[24]=x,t[25]=S,t[26]=C):C=t[26];let w=!a,T;t[27]!==s||t[28]!==n.shareUrl?(T=()=>void s(n.shareUrl),t[27]=s,t[28]=n.shareUrl,t[29]=T):T=t[29];let E;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(ie,{className:`size-3.5`}),t[30]=E):E=t[30];let D;t[31]!==o.copy||t[32]!==w||t[33]!==T?(D=(0,$.jsxs)(Y,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:w,onClick:T,children:[E,o.copy]}),t[31]=o.copy,t[32]=w,t[33]=T,t[34]=D):D=t[34];let O=!a,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)(se,{className:`size-3.5`}),t[37]=A):A=t[37];let j;t[38]!==o.open||t[39]!==O||t[40]!==k?(j=(0,$.jsxs)(Y,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:O,onClick:k,children:[A,o.open]}),t[38]=o.open,t[39]=O,t[40]=k,t[41]=j):j=t[41];let M;t[42]!==i||t[43]!==l||t[44]!==c||t[45]!==n||t[46]!==a||t[47]!==r||t[48]!==o.refresh?(M=r&&!l?(0,$.jsxs)(Y,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i||!a,onClick:()=>void c(n,`refresh`),children:[(0,$.jsx)(q,{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]=M):M=t[49];let N;t[50]!==i||t[51]!==c||t[52]!==n||t[53]!==o.revoke?(N=n.revoked?null:(0,$.jsxs)(Y,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i,onClick:()=>void c(n,`revoke`),children:[(0,$.jsx)(Pe,{className:`size-3.5`}),o.revoke]}),t[50]=i,t[51]=c,t[52]=n,t[53]=o.revoke,t[54]=N):N=t[54];let P;t[55]!==D||t[56]!==j||t[57]!==M||t[58]!==N?(P=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[D,j,M,N]}),t[55]=D,t[56]=j,t[57]=M,t[58]=N,t[59]=P):P=t[59];let F;return t[60]!==C||t[61]!==d||t[62]!==P?(F=(0,$.jsxs)(`div`,{className:d,children:[C,P]}),t[60]=C,t[61]=d,t[62]=P,t[63]=F):F=t[63],F}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=J(`rounded-lg border border-edge-subtle p-3`,c),t[0]=c,t[1]=l);let u=n.stale&&!s?i.stale:s?i.inactive:i.active,d;t[2]===u?d=t[3]:(d=(0,$.jsx)(`span`,{children:u}),t[2]=u,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`span`,{children:`·`}),t[4]=f):f=t[4];let p=n.maxViews===null?``:` / ${n.maxViews}`,m;t[5]!==n.viewCount||t[6]!==i.views||t[7]!==p?(m=(0,$.jsxs)(`span`,{children:[i.views,` `,n.viewCount,p]}),t[5]=n.viewCount,t[6]=i.views,t[7]=p,t[8]=m):m=t[8];let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`span`,{children:`·`}),t[9]=h):h=t[9];let g;t[10]===n.expiresAt?g=t[11]:(g=new Date(n.expiresAt).toLocaleDateString(),t[10]=n.expiresAt,t[11]=g);let _;t[12]===g?_=t[13]:(_=(0,$.jsx)(`span`,{children:g}),t[12]=g,t[13]=_);let v;t[14]!==_||t[15]!==d||t[16]!==m?(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[d,f,m,h,_]}),t[14]=_,t[15]=d,t[16]=m,t[17]=v):v=t[17];let y;t[18]===n.shareUrl?y=t[19]:(y=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[18]=n.shareUrl,t[19]=y);let b;t[20]!==v||t[21]!==y?(b=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[v,y]}),t[20]=v,t[21]=y,t[22]=b):b=t[22];let x;t[23]===r?x=t[24]:(x=r?(0,$.jsx)(Te,{className:`size-4 animate-spin text-fg-muted`}):null,t[23]=r,t[24]=x);let S;t[25]!==b||t[26]!==x?(S=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,x]}),t[25]=b,t[26]=x,t[27]=S):S=t[27];let C;t[28]!==a||t[29]!==n.shareUrl?(C=()=>void a(n.shareUrl),t[28]=a,t[29]=n.shareUrl,t[30]=C):C=t[30];let w;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(ie,{className:`size-3.5`}),t[31]=w):w=t[31];let T;t[32]!==i.copy||t[33]!==C?(T=(0,$.jsxs)(Y,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:C,children:[w,i.copy]}),t[32]=i.copy,t[33]=C,t[34]=T):T=t[34];let E;t[35]===n.shareUrl?E=t[36]:(E=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=E);let D;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(se,{className:`size-3.5`}),t[37]=D):D=t[37];let O;t[38]!==i.open||t[39]!==E?(O=(0,$.jsxs)(Y,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:E,children:[D,i.open]}),t[38]=i.open,t[39]=E,t[40]=O):O=t[40];let k;t[41]!==r||t[42]!==s||t[43]!==o||t[44]!==n||t[45]!==i.refresh?(k=n.stale&&!s?(0,$.jsxs)(Y,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`refresh`),children:[(0,$.jsx)(q,{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]=k):k=t[46];let A;t[47]!==r||t[48]!==s||t[49]!==o||t[50]!==n||t[51]!==i.extend?(A=s?null:(0,$.jsx)(Y,{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]=A):A=t[52];let j;t[53]!==r||t[54]!==o||t[55]!==n||t[56]!==i.revoke?(j=n.revoked?null:(0,$.jsxs)(Y,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`revoke`),children:[(0,$.jsx)(Pe,{className:`size-3.5`}),i.revoke]}),t[53]=r,t[54]=o,t[55]=n,t[56]=i.revoke,t[57]=j):j=t[57];let M;t[58]!==T||t[59]!==O||t[60]!==k||t[61]!==A||t[62]!==j?(M=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[T,O,k,A,j]}),t[58]=T,t[59]=O,t[60]=k,t[61]=A,t[62]=j,t[63]=M):M=t[63];let N;return t[64]!==S||t[65]!==l||t[66]!==M?(N=(0,$.jsxs)(`div`,{className:l,children:[S,M]}),t[64]=S,t[65]=l,t[66]=M,t[67]=N):N=t[67],N}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||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=N(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=N(u),f=N(Qt),p;t[6]!==n||t[7]!==r||t[8]!==d||t[9]!==a?(p=(0,$.jsx)(D,{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)(Ne,{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=F(t.replace(/^\s*(`{3,}|~{3,})[^\n]*$/gm,``).replace(/xopc-attachment:\/\/[^\s)]+/g,``).replace(/^(\s*[-*+]\s+)\[[ xX]\]\s*/gm,`$1`)),r=F(e);return!r||n.split(`
3
- `)[0]===r?n:[r,n].filter(Boolean).join(`
4
-
5
- `)}var en=()=>i(()=>import(`./block-editor-BQtTLe6Q.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])),tn=()=>i(()=>import(`./markdown-editor-BuuGlcfG.js`),__vite__mapDeps([45,1,2,41,46,13])),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:ce},t[0]=i.edit,t[1]=a);let o;t[2]===i.source?o=t[3]:(o={id:`source`,label:i.source,Icon:re},t[2]=i.source,t[3]=o);let s;t[4]===i.preview?s=t[5]:(s={id:`preview`,label:i.preview,Icon:B},t[4]=i.preview,t[5]=s);let c;t[6]!==a||t[7]!==o||t[8]!==s?(c=[a,o,s],t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9];let l=c,u;t[10]!==n||t[11]!==l?(u=l.find(e=>e.id===n)??l[0],t[10]=n,t[11]=l,t[12]=u):u=t[12];let d=u,f=d.Icon,p=sn,m;t[13]===f?m=t[14]:(m=(0,$.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[13]=f,t[14]=m);let h;t[15]===d.label?h=t[16]:(h=(0,$.jsx)(`span`,{children:d.label}),t[15]=d.label,t[16]=h);let g;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(R,{className:`size-3 text-fg-subtle`,"aria-hidden":!0}),t[17]=g):g=t[17];let _;t[18]!==d.label||t[19]!==m||t[20]!==h?(_=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":d.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:[m,h,g]})}),t[18]=d.label,t[19]=m,t[20]=h,t[21]=_):_=t[21];let v;t[22]!==n||t[23]!==l||t[24]!==r?(v=(0,$.jsx)(st,{children:(0,$.jsx)(lt,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:l.map(e=>{let{id:t,label:i,Icon:a}=e;return(0,$.jsxs)(ct,{onSelect:()=>r(t),onPointerMove:()=>p(t),onFocus:()=>p(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)(ee,{className:`size-4 text-accent`,"aria-hidden":!0}):null]},t)})})}),t[22]=n,t[23]=l,t[24]=r,t[25]=v):v=t[25];let y;return t[26]!==v||t[27]!==_?(y=(0,$.jsxs)(at,{modal:!1,children:[_,v]}),t[26]=v,t[27]=_,t[28]=y):y=t[28],y}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:f}=e,p=a===void 0||a,h=s===void 0||s,g=l!==void 0&&l,_=d(ln),v;t[0]===_?v=t[1]:(v=m(_),t[0]=_,t[1]=v);let y=v.notes.lightboxClose,b;t[2]!==g||t[3]!==o||t[4]!==h||t[5]!==u||t[6]!==n||t[7]!==f||t[8]!==r||t[9]!==c||t[10]!==i||t[11]!==p?(b=(0,$.jsx)(un,{noteId:n,onBack:r,onSaved:i,showBackButton:p,backButtonClassName:o,clearHeaderOnCleanup:h,onOpenSearch:c,autoFocus:g,initialMode:u,onAutoFocusConsumed:f}),t[2]=g,t[3]=o,t[4]=h,t[5]=u,t[6]=n,t[7]=f,t[8]=r,t[9]=c,t[10]=i,t[11]=p,t[12]=b):b=t[12];let x;return t[13]!==y||t[14]!==b?(x=(0,$.jsx)(pe,{closeLabel:y,children:b}),t[13]=y,t[14]=b,t[15]=x):x=t[15],x}function ln(e){return e.language}function un({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:a=!0,onOpenSearch:o,autoFocus:c=!1,initialMode:l=`wysiwyg`,onAutoFocusConsumed:f}){let p=d(e=>e.language),h=m(p).notes,g=m(p).chat.pageContext,v=m(p).automations.suggestions,{data:y}=Ke([`note-discussion-document`,e],()=>_(e)),[b,x]=(0,Q.useState)(!0),S=s(),C=Xe(e=>e.resolved)===`dark`,{openImage:w}=de(),[T,D]=(0,Q.useState)(l),[A,j]=(0,Q.useState)(null),[M,P]=(0,Q.useState)(null),[F,L]=(0,Q.useState)(!1),[R,te]=(0,Q.useState)(``),[z,ne]=(0,Q.useState)(360),[re,ie]=(0,Q.useState)(!1),[ae,se]=(0,Q.useState)(!1),[B,ue]=(0,Q.useState)(!1),pe=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{pe.current+=1},[e]);let[me,H]=(0,Q.useState)(null),[he,_e]=(0,Q.useState)(!1),[ve,be]=(0,Q.useState)(null),[xe,W]=(0,Q.useState)(!1),[K,we]=(0,Q.useState)(!1),Te=(0,Q.useRef)(!1),Ee=(0,Q.useRef)(!1),Oe=(0,Q.useRef)(null),ke=(0,Q.useRef)(null),q=(0,Q.useRef)(null),Me=(0,Q.useRef)(null),Ne=(0,Q.useRef)(null),Fe=(0,Q.useRef)(null),Y=(0,Q.useRef)(null),Ie=(0,Q.useRef)(null),Le=(0,Q.useRef)(null),Re=Ze(e=>e.setPageHeader),ze=Ze(e=>e.clearPageHeader),{data:X,mutate:Z,error:Be}=Ke(e?[`note-detail`,e]:null,()=>ge(e)),{data:Ve=[],mutate:He}=Ke(e?[`note-threads`,e]:null,()=>ye(e),{revalidateOnFocus:!1}),Ue=M!==null,We=(0,Q.useCallback)(e=>{H(`${h.refreshFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)},[h.quickCaptureFailedHint,h.refreshFailed]);(0,Q.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&Z().catch(We)};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[Z,e,We]),(0,Q.useEffect)(()=>{Te.current=!1,te(``),P(null),j(null),Ee.current=!1,Le.current=null},[e]),(0,Q.useEffect)(()=>{!X||Te.current||(te(X.title??``),Te.current=!0)},[X]),(0,Q.useEffect)(()=>{if(!c||!X||Ue||Le.current===e)return;let t=window.requestAnimationFrame(()=>{Ie.current?.focus(),f?.()});return Le.current=e,()=>window.cancelAnimationFrame(t)},[c,Ue,X,e,f]);let Ge=X?new Date(X.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,Je=(0,Q.useMemo)(()=>r?(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":h.back,className:J(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,Ye,i),children:(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0})}):null,[i,h.back,t,r]),Qe=(0,Q.useCallback)(()=>{let t=N.getState();t.source?.type===`note`&&t.source.id===e&&t.stop()},[e]),et=(0,Q.useCallback)(e=>{e!==`preview`&&Qe(),D(e)},[Qe]),tt=(0,Q.useCallback)(t=>{Qe(),te(t),e&&(Me.current=t,ke.current&&clearTimeout(ke.current),ke.current=setTimeout(async()=>{let t=Me.current;if(Me.current=null,t!==null){L(!0);try{await V(e,{title:t}),await Z(),n?.()}catch{}finally{L(!1)}}},600))},[Qe,e,Z,n]),nt=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:J(`flex min-w-0 items-center gap-2`,Ye),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:R||Ge||void 0,children:R||Ge}),F?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:h.saving}):null]}),[h.saving,F,Ge,R]),rt=(0,Q.useCallback)(async(t=!1)=>{ue(!0),H(null);try{let n=await U(e,{forceNew:t});await Z(),await He(),S(`/chat/${encodeURIComponent(n.conversationId)}`)}catch(e){H(`${h.chatOpenFailedTitle}: ${e instanceof Error?e.message:h.chatOpenFailedMessage}`)}finally{ue(!1)}},[Z,He,S,e,h.chatOpenFailedMessage,h.chatOpenFailedTitle]),it=(0,Q.useCallback)(async()=>{se(!0),H(null);try{await Se(e),await Z()}catch(e){H(`${h.catalysisFailed}: ${e instanceof Error?e.message:h.chatOpenFailedMessage}`)}finally{se(!1)}},[Z,e]),dt=(0,Q.useCallback)(()=>{j(A===`breakdown`?null:`breakdown`),!X?.aiDeep?.catalysis?.report&&!ae&&it()},[A,ae,it,X?.aiDeep?.catalysis?.report]),ft=(0,Q.useCallback)(()=>{let t=M?M.markdown??``:q.current??X?.markdown??``,n=M?M.title??``:R,r=$t(n,t);return{source:{type:`note`,id:e,title:n||h.titlePlaceholder},text:r,language:O(r,p)}},[p,h.titlePlaceholder,X?.markdown,e,M,R]),ht=(0,Q.useCallback)(async()=>{Oe.current&&clearTimeout(Oe.current),ke.current&&clearTimeout(ke.current),Oe.current=null,ke.current=null;let t=q.current,r=Me.current;q.current=null,Me.current=null;let i={};if(t!==null&&(i.markdown=t),r!==null&&(i.title=r),Object.keys(i).length===0)return X??null;L(!0);try{let t=await V(e,i);return await Z(t,{revalidate:!1}),n?.(),t}catch(e){return q.current===null&&(q.current=t),Me.current===null&&(Me.current=r),H(`${h.saveFailed}: ${e instanceof Error?e.message:h.saveFailedHint}`),null}finally{L(!1)}},[Z,h.saveFailed,h.saveFailedHint,X,e,n]),gt=(0,Q.useCallback)(async()=>{if(!X||B||F)return;ue(!0),H(null);let e=u.getState(),t=++pe.current,n=()=>pe.current===t&&u.getState().baseUrl===e.baseUrl&&u.getState().conversationId===e.conversationId;try{let t=window.getSelection(),r=t?.anchorNode&&t.focusNode&&Ne.current?.contains(t.anchorNode)&&Ne.current.contains(t.focusNode)?t.toString():``,i=await ht();if(!i||!n())return;if(q.current!==null||Me.current!==null)throw Error(g.unavailable);let a=pt.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 qe().createSession();if(!n())return;if(q.current!==null||Me.current!==null)throw Error(g.unavailable);let s=mt(e.baseUrl,e.conversationId,o.key);if(!pt.put(s,a))throw Error(g.unavailable);S(`/chat/${encodeURIComponent(o.key)}`)}catch{n()&&H(g.unavailable)}finally{pe.current===t&&ue(!1)}},[X,B,F,ht,S,g.unavailable]),_t=(0,Q.useCallback)(async()=>{H(null);let e=await ht();e&&(be(e),_e(!0))},[ht]),vt=(0,Q.useCallback)(async()=>{if(!(K||F)){W(!1),we(!0),H(null),Qe(),Oe.current&&clearTimeout(Oe.current),ke.current&&clearTimeout(ke.current),Oe.current=null,ke.current=null,q.current=null,Me.current=null;try{await G(e),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e}})),n?.(),t()}catch(e){H(`${h.deleteFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}finally{we(!1)}}},[K,h.deleteFailed,h.quickCaptureFailedHint,e,t,n,F,Qe]),yt=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:J(`flex min-w-0 items-center gap-1 sm:gap-2`,Ye),children:[o?(0,$.jsx)(`button`,{type:`button`,onClick:o,"aria-label":h.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)(Ae,{className:`size-4`,"aria-hidden":!0})}):null,(0,$.jsx)(Zt,{input:ft,showLabel:!1,labels:{read:h.readAloud,preparing:h.readAloudPreparing,pause:h.readAloudPause,resume:h.readAloudResume,retry:h.readAloudRetry,stop:h.readAloudStop}}),(0,$.jsxs)(`button`,{type:`button`,onClick:dt,disabled:ae,"aria-label":h.catalysisSectionTitle,className:J(`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`,A===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:ae?h.catalyzing:h.catalyzeButton})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>rt(!1),"aria-label":h.openChatButton,disabled:B,className:J(`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)(De,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:B?h.openingChat:h.openChatButton})]}),(0,$.jsx)(on,{mode:T,onModeChange:et,labels:{edit:h.modeEdit,source:h.modeSource,preview:h.modePreview}}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void gt(),disabled:B||F||!X||!!M,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)(ce,{className:`size-3.5`,"aria-hidden":!0}),g.capture]}),(0,$.jsxs)(at,{modal:!1,children:[(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":h.noteActions,title:h.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)(oe,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{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)(ct,{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)(k,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),p===`zh`?`分享`:`Share`]}),(0,$.jsxs)(ct,{onSelect:()=>j(A===`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)(le,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:h.history}),A===`history`?(0,$.jsx)(ee,{className:`size-4 text-accent`,"aria-hidden":!0}):null]}),(0,$.jsx)(ut,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsxs)(ct,{disabled:K||F,onSelect:()=>W(!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)(Pe,{className:`size-4`,"aria-hidden":!0}),h.delete]})]})})]})]}),[ae,dt,rt,gt,g.capture,X,M,T,h.history,h.modeEdit,h.modePreview,h.modeSource,B,A,o,h.searchDialogTitle,h.readAloud,h.readAloudPause,h.readAloudPreparing,h.readAloudResume,h.readAloudRetry,h.readAloudStop,et,ft,_t,K,F,p,h.delete,W]);(0,Q.useLayoutEffect)(()=>(Re({startExtra:Je,main:X&&!(y&&b)?nt:null,end:X&&!(y&&b)?yt:null}),()=>{a&&ze()}),[a,ze,yt,nt,Je,y,b,X,Re]);let bt=(0,Q.useCallback)(t=>{e&&(Qe(),q.current=t,Oe.current&&clearTimeout(Oe.current),Oe.current=setTimeout(async()=>{let t=q.current;if(q.current=null,t!==null){L(!0),H(null);try{await V(e,{markdown:t}),await Z(),n?.()}catch(e){H(`${h.saveFailed}: ${e instanceof Error?e.message:h.saveFailedHint}`)}finally{L(!1)}}},600))},[Qe,e,Z,h.saveFailed,h.saveFailedHint,n]),xt=(0,Q.useCallback)(t=>{Ce(e,t.timestamp).then(e=>{e&&(Qe(),P(e))})},[e,Qe]),St=(0,Q.useCallback)(()=>{Qe(),j(null),P(null)},[Qe]),Ct=(0,Q.useCallback)(()=>{Qe(),j(null),P(null),Z().catch(We),n?.()},[Z,n,We,Qe]);if((0,Q.useEffect)(()=>()=>{Oe.current&&clearTimeout(Oe.current),ke.current&&clearTimeout(ke.current);let t=q.current,n=Me.current;q.current=null,Me.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&V(e,r).catch(()=>void 0)},[e]),X===void 0)return Be?(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:h.home.loadFailed}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Z().catch(We),className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-hover`,children:h.home.retry}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-fg-muted hover:text-fg`,children:h.back})]}):(0,$.jsx)(an,{});if(X===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:h.notFoundTitle}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.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:h.back})]});let Tt=Ue?M.title??``:R,Et=Ue?M.markdown??``:q.current??X.markdown??``,Dt=new Date(X.createdAt).getTime(),Ot=Number.isFinite(Dt)&&Date.now()-Dt<3600*1e3?(0,$.jsx)(wt,{title:v.noteCreatedTitle,description:v.noteCreatedDescription,prompt:v.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:[me?(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:me}):null,(0,$.jsx)(I,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsx)(I,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),y&&!b?(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:()=>x(!0),children:p===`zh`?`← 返回录音笔记`:`← Back to recording`}):null,(0,$.jsxs)(`div`,{ref:Ne,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&&b?(0,$.jsx)(zt,{noteId:e,noteActions:{onAnalyze:dt,onChat:()=>{rt(!1)},onShare:()=>{_t()},onHistory:()=>j(A===`history`?null:`history`),onDelete:()=>W(!0),busy:K||F||ae||B},onPersonalNotes:()=>{x(!1),window.setTimeout(()=>Ie.current?.focus(),0)}}):null,(0,$.jsx)(`div`,{className:y&&b?`hidden`:`min-h-0 min-w-0 flex-1`,children:Ue?(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)(fe,{noteId:e,content:Et,className:`opacity-80`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:h.emptyPreview})]}):(0,$.jsxs)($.Fragment,{children:[T===`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:Ie,type:`text`,value:R,onChange:e=>tt(e.target.value),onCompositionStart:()=>{Ee.current=!0},onCompositionEnd:()=>{Ee.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!Ee.current&&!t.isComposing&&(e.preventDefault(),(Ne.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:h.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:X.markdown??``,onChange:bt,noteId:e},`wysiwyg-${e}`)})})]}),T===`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:Ie,type:`text`,value:R,onChange:e=>tt(e.target.value),placeholder:h.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:X.markdown??``,onChange:bt,isDark:C},`source-${e}`)})})]}),T===`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&&w(t.currentSrc||t.src,t.alt)},children:[R&&!X.markdown.trimStart().startsWith(`# ${R.trim()}\n`)&&X.markdown.trim()!==`# ${R.trim()}`&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:R}),X.markdown?(0,$.jsx)(fe,{noteId:e,content:X.markdown,className:`[&_img]:cursor-zoom-in`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:h.emptyPreview})]})]})})]})]}),(0,$.jsx)(`div`,{ref:Fe,className:J(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!re&&`transition-[width] duration-300 ease-in-out`),style:{width:A?z:0},children:(0,$.jsxs)(`div`,{ref:Y,className:`flex min-h-0 flex-1 flex-col`,style:{width:z},children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),ie(!0);let n=e.clientX,r=z,i=e.pointerId,a=0,o=z,s=z,c=()=>{a=0,s=o,A&&Fe.current?.style.setProperty(`width`,`${s}px`),Y.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{}ie(!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:J(`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:A===`history`?(0,$.jsx)(Ht,{noteId:e,activeTimestamp:M?.timestamp??null,onSelect:xt,onClose:St,onRestored:Ct}):A===`breakdown`?(0,$.jsx)(Ut,{noteId:e,note:X??null,catalyzing:ae,onCatalyze:it,onClose:()=>j(null),noteThreads:Ve,openingChat:B,onOpenChat:()=>rt(!1),onOpenNewChat:()=>rt(!0)}):null})]})})]}),ve?(0,$.jsx)(Gt,{open:he,onOpenChange:_e,note:ve}):null,(0,$.jsx)($e,{open:xe,title:h.deleteConfirmTitle,description:h.deleteConfirmDescription.replace(`{{title}}`,X.title||h.titlePlaceholder),confirmLabel:h.deleteConfirmLabel,cancelLabel:h.deleteCancelLabel,destructive:!0,onConfirm:()=>void vt(),onCancel:()=>W(!1)})]})}export{xt as i,Ct as n,St as r,cn as t};
@@ -1 +0,0 @@
1
- import"./notes-api-CUlhTRv0.js";