@xopcai/xopc 0.0.320 → 0.0.323

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 (323) hide show
  1. package/dist/browser-ext/dist/assets/{auth-DKo-NMUY.js → auth-DocRzRlS.js} +95 -21
  2. package/dist/browser-ext/dist/background.js +1 -1
  3. package/dist/browser-ext/dist/sidepanel.html +1 -1
  4. package/dist/browser-ext/dist/sidepanel.js +18 -2
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/extensions/telegram/xopc.extension.json +1 -1
  7. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BXLU0HJa.js → agent-avatar-dicebear-DFzmThVi.js} +1 -1
  8. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CAFHadiy.js +1 -0
  9. package/dist/gateway/static/root/assets/agent-plugin-dialog-DYFYiuig.js +1 -0
  10. package/dist/gateway/static/root/assets/{agents-hrbGiOHn.js → agents-BqIlB5Co.js} +1 -1
  11. package/dist/gateway/static/root/assets/{app-link-nL8iPwEr.js → app-link-C6gA5Nck.js} +1 -1
  12. package/dist/gateway/static/root/assets/{app-management-settings-panel-C0jEvonH.js → app-management-settings-panel-BgvMRGWe.js} +1 -1
  13. package/dist/gateway/static/root/assets/{appearance-settings-ByVRv2Oe.js → appearance-settings-CliHU03A.js} +1 -1
  14. package/dist/gateway/static/root/assets/apps-page-Drt3Foi9.js +1 -0
  15. package/dist/gateway/static/root/assets/{archive-plugin-CMITc1PQ.js → archive-plugin-DnuPpm0u.js} +1 -1
  16. package/dist/gateway/static/root/assets/{attachment-load-B5Z1PKHm.js → attachment-load-BiwaK0ie.js} +1 -1
  17. package/dist/gateway/static/root/assets/{automations-page-BOcXqVar.js → automations-page-CJSISGQH.js} +1 -1
  18. package/dist/gateway/static/root/assets/automations-workspace-B-Eduqwz.js +7 -0
  19. package/dist/gateway/static/root/assets/{binary-plugins-BkRb9adx.js → binary-plugins-KDjduQZO.js} +1 -1
  20. package/dist/gateway/static/root/assets/{block-editor-DsmDlkC2.js → block-editor-bclvgove.js} +3 -3
  21. package/dist/gateway/static/root/assets/{browser-automation-inputs-BgBH3eFk.js → browser-automation-inputs-CfQ2T9t6.js} +1 -1
  22. package/dist/gateway/static/root/assets/{browser-automations-page-e3KpurLo.js → browser-automations-page-Cxq38Nnp.js} +2 -2
  23. package/dist/gateway/static/root/assets/browser-settings-page-Dwgir6mu.js +3 -0
  24. package/dist/gateway/static/root/assets/capabilities-settings-panel-H5L5vynP.js +8 -0
  25. package/dist/gateway/static/root/assets/capabilities-uFKh3Hd0.js +1 -0
  26. package/dist/gateway/static/root/assets/channels-settings-RFBRYe5S.js +1 -0
  27. package/dist/gateway/static/root/assets/{chat-terminal-dock-DUdkU1C5.js → chat-terminal-dock-DKQC62nQ.js} +2 -2
  28. package/dist/gateway/static/root/assets/{computer-settings-page-C6WR9Syy.js → computer-settings-page-D1whpIqL.js} +1 -1
  29. package/dist/gateway/static/root/assets/{connector-service-page-SVKcySx0.js → connector-service-page-BAuYTgf5.js} +1 -1
  30. package/dist/gateway/static/root/assets/connectors-page-Px-v3Q6Q.js +2 -0
  31. package/dist/gateway/static/root/assets/{date-picker-DBD5yedi.js → date-picker-CfCo3lqh.js} +1 -1
  32. package/dist/gateway/static/root/assets/{dependency-picker-HE41Co5W.js → dependency-picker-DOuVO2M1.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-DH9EU9O3.js → desktop-pet-D9tu6Bhu.js} +1 -1
  34. package/dist/gateway/static/root/assets/{desktop-pet-settings-Br6Z1Vau.js → desktop-pet-settings-CQPXub2f.js} +1 -1
  35. package/dist/gateway/static/root/assets/device-pairing-wizard-DxkOYSut.js +1 -0
  36. package/dist/gateway/static/root/assets/{extension-debug-page-CFjVNb1m.js → extension-debug-page-CtWClPz-.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-page-BQ3ldBhh.js → extension-page-BHh9HLCz.js} +1 -1
  38. package/dist/gateway/static/root/assets/{extension-settings-page-CaXnWbRI.js → extension-settings-page-BdT3v5Uh.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-config-swr-DgFmBSH9.js → gateway-config-swr-1eqyz9vZ.js} +1 -1
  40. package/dist/gateway/static/root/assets/gateway-settings-CZas_Ekx.js +1 -0
  41. package/dist/gateway/static/root/assets/{gateway-startup-retry-C7h3xef0.js → gateway-startup-retry-C4rsW6vJ.js} +1 -1
  42. package/dist/gateway/static/root/assets/home-page-w3_aWeNt.js +1 -0
  43. package/dist/gateway/static/root/assets/{image-generation-api-DJ1xaz2p.js → image-generation-api-B5DXMylk.js} +1 -1
  44. package/dist/gateway/static/root/assets/{imports-page-CaB54QIp.js → imports-page-B1JH0G5j.js} +1 -1
  45. package/dist/gateway/static/root/assets/index--3c0awkr.js +121 -0
  46. package/dist/gateway/static/root/assets/index-CNc4N4TX.css +1 -0
  47. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DnvHvKQJ.js → keyboard-shortcuts-settings-DGrLJ8Yh.js} +1 -1
  48. package/dist/gateway/static/root/assets/local-app-workbench-page-BYKrJpFF.js +1 -0
  49. package/dist/gateway/static/root/assets/local-apps-Bpja8nC6.js +1 -0
  50. package/dist/gateway/static/root/assets/local-apps-page-DqjStqbL.js +1 -0
  51. package/dist/gateway/static/root/assets/{locale-store-C4RjTd0C.js → locale-store-BIkcRr3t.js} +1 -1
  52. package/dist/gateway/static/root/assets/{logs-page-N0q5DxnI.js → logs-page-Dl4kM4Na.js} +2 -2
  53. package/dist/gateway/static/root/assets/management-settings-gCfH4cwH.js +1 -0
  54. package/dist/gateway/static/root/assets/{markdown-view-DkPzc50Z.js → markdown-view-Ck_5MADq.js} +1 -1
  55. package/dist/gateway/static/root/assets/{media-plugins-BzLYE9lj.js → media-plugins-DTsZqgo6.js} +1 -1
  56. package/dist/gateway/static/root/assets/messages-7VAhscYe.js +3 -0
  57. package/dist/gateway/static/root/assets/note-detail-panel-j6sioeL1.js +5 -0
  58. package/dist/gateway/static/root/assets/notes-page-CMvvHv0f.js +8 -0
  59. package/dist/gateway/static/root/assets/{page-context-capture-button-DVnGa7Lu.js → page-context-capture-button-DTI_g4tz.js} +1 -1
  60. package/dist/gateway/static/root/assets/{page-tabs-q6lpN9OD.js → page-tabs-CfW_Q-K5.js} +1 -1
  61. package/dist/gateway/static/root/assets/{preview-open-alternatives-Ck63fJaQ.js → preview-open-alternatives-CuPN-vAn.js} +1 -1
  62. package/dist/gateway/static/root/assets/product-delivery-bv3z8Xkh.js +1 -0
  63. package/dist/gateway/static/root/assets/product-open-page-BHjxRz1E.js +1 -0
  64. package/dist/gateway/static/root/assets/project-detail-page-C9K_e-EV.js +1 -0
  65. package/dist/gateway/static/root/assets/projects-page-Bk-es4i9.js +1 -0
  66. package/dist/gateway/static/root/assets/{registry-api-CRnytFLF.js → registry-api-BAAZUGnU.js} +1 -1
  67. package/dist/gateway/static/root/assets/remote-access-hub-CLGJNA42.js +1 -0
  68. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bu3XyrDI.js → runtime-tools-settings-panel-CHJBJKL1.js} +2 -2
  69. package/dist/gateway/static/root/assets/{scenes-page-B_5HOUzl.js → scenes-page-ClLAD1pz.js} +2 -2
  70. package/dist/gateway/static/root/assets/{schema-form-CbOOKW1B.js → schema-form-FQAit5HL.js} +1 -1
  71. package/dist/gateway/static/root/assets/sessions-page-Xj8MkXN1.js +1 -0
  72. package/dist/gateway/static/root/assets/settings-advanced-gate-DwALV8mi.js +1 -0
  73. package/dist/gateway/static/root/assets/{settings-form-section-D3UN4rb4.js → settings-form-section-BDc6bw1q.js} +1 -1
  74. package/dist/gateway/static/root/assets/{settings-page-BHztZayW.js → settings-page-DnhxBJjV.js} +1 -1
  75. package/dist/gateway/static/root/assets/{settings-page-layout-nskqtzZs.js → settings-page-layout-D3KNSQ5g.js} +1 -1
  76. package/dist/gateway/static/root/assets/{setup-status-panel-BtukdJ-z.js → setup-status-panel-F0rCQ-2a.js} +1 -1
  77. package/dist/gateway/static/root/assets/{share-preview-page-DbYXEqur.js → share-preview-page-DVQCRxwK.js} +1 -1
  78. package/dist/gateway/static/root/assets/shares-settings-C7hf6Cov.js +1 -0
  79. package/dist/gateway/static/root/assets/skill-reload-api-xPrFejRE.js +1 -0
  80. package/dist/gateway/static/root/assets/{skills-page-CK9Jeaur.js → skills-page-RdDYu7Yj.js} +1 -1
  81. package/dist/gateway/static/root/assets/{skills-page.utils-B44aWbyL.js → skills-page.utils-mDwC9UJ-.js} +1 -1
  82. package/dist/gateway/static/root/assets/{system-settings-panel-BwqpUGv_.js → system-settings-panel-Bk7GrMij.js} +1 -1
  83. package/dist/gateway/static/root/assets/task-detail-page-2A966jFY.js +1 -0
  84. package/dist/gateway/static/root/assets/{tunnel-api-BKTZzQIT.js → tunnel-api-D3Aquraj.js} +1 -1
  85. package/dist/gateway/static/root/assets/{use-autosave-BB1JBOCz.js → use-autosave-C1xQ-sHn.js} +1 -1
  86. package/dist/gateway/static/root/assets/user-model-page-CnBxPBVe.js +2 -0
  87. package/dist/gateway/static/root/assets/{voice-api-key-field-C-HsgED9.js → voice-api-key-field-DCNECvcp.js} +1 -1
  88. package/dist/gateway/static/root/assets/{voice-config-api-DvJKYYA0.js → voice-config-api-B-_niUTU.js} +1 -1
  89. package/dist/gateway/static/root/assets/{work-discovery-overlay-K3e5ONUo.js → work-discovery-overlay-BrGx_JS_.js} +1 -1
  90. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-dXRTHBoE.js → workflow-run-setup-panel-CmmC2Pdr.js} +2 -2
  91. package/dist/gateway/static/root/assets/workflows-page-BZVpqw4T.js +6 -0
  92. package/dist/gateway/static/root/index.html +12 -11
  93. package/dist/package.js +1 -1
  94. package/dist/packages/gateway-contract/src/capabilities.js +4 -110
  95. package/dist/packages/gateway-contract/src/chat-previews.js +73 -0
  96. package/dist/packages/gateway-contract/src/index.js +6 -0
  97. package/dist/packages/gateway-contract/src/local-apps.js +215 -0
  98. package/dist/packages/gateway-contract/src/product-delivery.js +62 -17
  99. package/dist/packages/gateway-contract/src/user-turn-document.js +60 -0
  100. package/dist/src/agent/agent-manager.d.ts +1 -0
  101. package/dist/src/agent/agent-manager.js +5 -4
  102. package/dist/src/agent/background-review/run-background-review.js +1 -1
  103. package/dist/src/agent/embedded/model-runtime.js +1 -1
  104. package/dist/src/agent/embedded/run-for-session.js +1 -1
  105. package/dist/src/agent/embedded/transcript-runtime.d.ts +3 -0
  106. package/dist/src/agent/embedded/transcript-runtime.js +6 -0
  107. package/dist/src/agent/external-tools/cliProvider.js +4 -1
  108. package/dist/src/agent/external-tools/composio-provider.js +9 -3
  109. package/dist/src/agent/external-tools/gateway-tools.js +17 -10
  110. package/dist/src/agent/external-tools/mcp-provider.d.ts +3 -1
  111. package/dist/src/agent/external-tools/mcp-provider.js +91 -6
  112. package/dist/src/agent/external-tools/service.d.ts +2 -1
  113. package/dist/src/agent/external-tools/service.js +8 -3
  114. package/dist/src/agent/external-tools/types.d.ts +9 -0
  115. package/dist/src/agent/image/tool-model-config.js +1 -1
  116. package/dist/src/agent/mcp/bundle-mcp-config.js +37 -5
  117. package/dist/src/agent/mcp/bundle-mcp-gateway.d.ts +1 -0
  118. package/dist/src/agent/mcp/bundle-mcp-gateway.js +1 -0
  119. package/dist/src/agent/mcp/bundle-mcp-names.js +2 -1
  120. package/dist/src/agent/mcp/bundle-mcp-runtime.js +33 -1
  121. package/dist/src/agent/mcp/bundle-mcp-types.d.ts +4 -0
  122. package/dist/src/agent/mcp/index.js +1 -1
  123. package/dist/src/agent/mcp/mcp-stdio-transport.d.ts +1 -0
  124. package/dist/src/agent/mcp/mcp-stdio-transport.js +10 -0
  125. package/dist/src/agent/mcp/mcp-transport.js +12 -8
  126. package/dist/src/agent/mcp/oauth/index.js +1 -1
  127. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.d.ts +6 -1
  128. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +70 -14
  129. package/dist/src/agent/mcp/oauth/mcp-oauth-provider.js +1 -1
  130. package/dist/src/agent/mcp/oauth/mcp-oauth-session.d.ts +2 -0
  131. package/dist/src/agent/mcp/oauth/mcp-oauth-session.js +12 -0
  132. package/dist/src/agent/mcp/oauth/mcp-oauth-store.d.ts +3 -0
  133. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +14 -2
  134. package/dist/src/agent/mcp/plugin-http-fetch.d.ts +2 -0
  135. package/dist/src/agent/mcp/plugin-http-fetch.js +56 -0
  136. package/dist/src/agent/service/process-direct-streaming.js +27 -12
  137. package/dist/src/agent/service.js +3 -2
  138. package/dist/src/agent/service.types.d.ts +2 -0
  139. package/dist/src/agent/session/session-inspector.js +1 -1
  140. package/dist/src/agent/skills/hub-lock.js +1 -1
  141. package/dist/src/agent/skills/hub-pull.js +1 -1
  142. package/dist/src/agent/skills/index.js +8 -1
  143. package/dist/src/agent/skills/skill-manager.d.ts +2 -0
  144. package/dist/src/agent/skills/skill-manager.js +8 -0
  145. package/dist/src/agent/skills/skill-sources.js +17 -0
  146. package/dist/src/agent/skills/types.d.ts +3 -1
  147. package/dist/src/agent/source-context/injector.js +10 -5
  148. package/dist/src/agent/source-context/types.d.ts +3 -0
  149. package/dist/src/agent/source-context/types.js +8 -2
  150. package/dist/src/agent/tasks/task-judge-service.js +3 -3
  151. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  152. package/dist/src/agent/tool-manuals/xopc-use.js +12 -2
  153. package/dist/src/agent/tools/automation-tool.js +1 -1
  154. package/dist/src/agent/tools/factory.d.ts +1 -0
  155. package/dist/src/agent/tools/factory.js +2 -1
  156. package/dist/src/agent/tools/search/registry.js +4 -1
  157. package/dist/src/agent/tools/workflow-tool.js +1 -1
  158. package/dist/src/agent/tools/write.js +1 -1
  159. package/dist/src/agent/tools/xopc-use-tool.d.ts +4 -2
  160. package/dist/src/agent/tools/xopc-use-tool.js +120 -12
  161. package/dist/src/ai-assist/text-assist.js +1 -1
  162. package/dist/src/auth/credentials.js +2 -2
  163. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  164. package/dist/src/auth/profiles/store.js +1 -1
  165. package/dist/src/auth/sync-provider-auth.js +2 -2
  166. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  167. package/dist/src/chat-commands/agent-edit.js +1 -1
  168. package/dist/src/chat-previews/index.d.ts +2 -0
  169. package/dist/src/chat-previews/index.js +3 -0
  170. package/dist/src/chat-previews/service.d.ts +27 -0
  171. package/dist/src/chat-previews/service.js +106 -0
  172. package/dist/src/chat-previews/store.d.ts +28 -0
  173. package/dist/src/chat-previews/store.js +77 -0
  174. package/dist/src/cli/commands/agent.js +1 -1
  175. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  176. package/dist/src/cli/commands/doctor/checks/provider-auth.js +3 -3
  177. package/dist/src/cli/commands/extension-agent-plugin.d.ts +8 -0
  178. package/dist/src/cli/commands/extension-agent-plugin.js +82 -0
  179. package/dist/src/cli/commands/extension-marketplace.js +44 -4
  180. package/dist/src/cli/commands/extension.js +35 -3
  181. package/dist/src/cli/commands/models.js +1 -1
  182. package/dist/src/computer/runtime.js +1 -1
  183. package/dist/src/config/index.js +4 -4
  184. package/dist/src/config/loader.js +2 -2
  185. package/dist/src/config/models-json.js +2 -2
  186. package/dist/src/config/schema.js +2 -2
  187. package/dist/src/connectors/account-selection.js +1 -1
  188. package/dist/src/connectors/connection-candidates.d.ts +4 -1
  189. package/dist/src/connectors/connection-candidates.js +8 -2
  190. package/dist/src/connectors/connection-capabilities.d.ts +2 -2
  191. package/dist/src/connectors/connection-capabilities.js +3 -1
  192. package/dist/src/connectors/connection-recovery-service.d.ts +6 -1
  193. package/dist/src/connectors/connection-recovery-service.js +138 -26
  194. package/dist/src/connectors/plugin-mcp-recovery.d.ts +28 -0
  195. package/dist/src/connectors/plugin-mcp-recovery.js +90 -0
  196. package/dist/src/extensions/agent-plugins/auth.d.ts +39 -0
  197. package/dist/src/extensions/agent-plugins/auth.js +156 -0
  198. package/dist/src/extensions/agent-plugins/connection.d.ts +8 -0
  199. package/dist/src/extensions/agent-plugins/connection.js +41 -0
  200. package/dist/src/extensions/agent-plugins/health.d.ts +4 -0
  201. package/dist/src/extensions/agent-plugins/health.js +48 -0
  202. package/dist/src/extensions/agent-plugins/inventory.d.ts +53 -0
  203. package/dist/src/extensions/agent-plugins/inventory.js +34 -0
  204. package/dist/src/extensions/agent-plugins/mcp-adapter.d.ts +3 -0
  205. package/dist/src/extensions/agent-plugins/mcp-adapter.js +47 -0
  206. package/dist/src/extensions/agent-plugins/sources.d.ts +5 -0
  207. package/dist/src/extensions/agent-plugins/sources.js +72 -0
  208. package/dist/src/extensions/agent-plugins/store.d.ts +61 -0
  209. package/dist/src/extensions/agent-plugins/store.js +305 -0
  210. package/dist/src/extensions/agent-plugins/validation.d.ts +59 -0
  211. package/dist/src/extensions/agent-plugins/validation.js +211 -0
  212. package/dist/src/extensions/lockfile.js +1 -1
  213. package/dist/src/extensions/update.js +1 -1
  214. package/dist/src/gateway/agents-admin.js +1 -1
  215. package/dist/src/gateway/chat-stream/mapper.js +10 -3
  216. package/dist/src/gateway/file-path-classifier.js +1 -1
  217. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  218. package/dist/src/gateway/hono/routes/agent-plugins.d.ts +3 -0
  219. package/dist/src/gateway/hono/routes/agent-plugins.js +166 -0
  220. package/dist/src/gateway/hono/routes/agent-stream.js +14 -0
  221. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +4 -2
  222. package/dist/src/gateway/hono/routes/chat-previews.d.ts +3 -0
  223. package/dist/src/gateway/hono/routes/chat-previews.js +41 -0
  224. package/dist/src/gateway/hono/routes/connection-waits.js +4 -2
  225. package/dist/src/gateway/hono/routes/index.js +2 -0
  226. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  227. package/dist/src/gateway/hono/routes/local-apps.js +71 -39
  228. package/dist/src/gateway/hono/routes/mcp.js +48 -21
  229. package/dist/src/gateway/hono/routes/models.js +1 -1
  230. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +4 -0
  231. package/dist/src/gateway/hono/routes/session-input-handler.js +22 -0
  232. package/dist/src/gateway/hono/routes/side-chats.js +11 -0
  233. package/dist/src/gateway/service/agent-runner.js +7 -1
  234. package/dist/src/gateway/service/config-coordinator.js +1 -1
  235. package/dist/src/gateway/service/marketplace-service.d.ts +1 -0
  236. package/dist/src/gateway/service/marketplace-service.js +15 -1
  237. package/dist/src/gateway/service/session-input-coordinator.js +3 -3
  238. package/dist/src/gateway/service.d.ts +5 -1
  239. package/dist/src/gateway/service.js +19 -5
  240. package/dist/src/gateway/side-chat/index.d.ts +3 -1
  241. package/dist/src/gateway/side-chat/index.js +2 -1
  242. package/dist/src/gateway/side-chat/manager.d.ts +16 -0
  243. package/dist/src/gateway/side-chat/manager.js +40 -6
  244. package/dist/src/gateway/side-chat/promotion-service.d.ts +19 -0
  245. package/dist/src/gateway/side-chat/promotion-service.js +111 -0
  246. package/dist/src/gateway/side-chat/run-service.js +1 -0
  247. package/dist/src/gateway/side-chat/types.d.ts +1 -1
  248. package/dist/src/local-apps/artifact-files.d.ts +3 -0
  249. package/dist/src/local-apps/artifact-files.js +45 -0
  250. package/dist/src/local-apps/capabilities/write.js +1 -1
  251. package/dist/src/local-apps/fix-guidance.d.ts +3 -0
  252. package/dist/src/local-apps/fix-guidance.js +75 -0
  253. package/dist/src/local-apps/index.d.ts +2 -1
  254. package/dist/src/local-apps/scaffold.d.ts +5 -0
  255. package/dist/src/local-apps/scaffold.js +18 -5
  256. package/dist/src/local-apps/service.d.ts +18 -3
  257. package/dist/src/local-apps/service.js +106 -64
  258. package/dist/src/local-apps/snapshot-store.d.ts +8 -0
  259. package/dist/src/local-apps/snapshot-store.js +68 -0
  260. package/dist/src/local-apps/types.d.ts +4 -87
  261. package/dist/src/notes/service.js +1 -1
  262. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  263. package/dist/src/providers/index.js +2 -2
  264. package/dist/src/providers/model-catalog-persistence.js +1 -1
  265. package/dist/src/providers/model-registry.js +1 -1
  266. package/dist/src/providers/register-runtime-providers.js +1 -1
  267. package/dist/src/session/client-history.d.ts +3 -1
  268. package/dist/src/session/client-history.js +10 -3
  269. package/dist/src/session/index.d.ts +1 -1
  270. package/dist/src/session/manager.d.ts +4 -0
  271. package/dist/src/session/manager.js +6 -0
  272. package/dist/src/session/session-context-for-llm.d.ts +12 -1
  273. package/dist/src/session/session-context-for-llm.js +16 -2
  274. package/dist/src/session/store.d.ts +14 -0
  275. package/dist/src/session/store.js +17 -0
  276. package/dist/src/session/stored-rows-to-file-entries.js +10 -1
  277. package/dist/src/session/transcript-outline.js +10 -3
  278. package/dist/src/storage/sqlite/connection-wait-repository.js +9 -3
  279. package/dist/src/storage/sqlite/migrations/202_chat_previews.sql +26 -0
  280. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  281. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  282. package/dist/src/storage/sqlite/row-mappers.js +6 -1
  283. package/dist/src/storage/sqlite/schema.js +1 -1
  284. package/dist/src/tui/backends/embedded-backend.js +1 -1
  285. package/dist/src/tui/tui-commands.js +1 -1
  286. package/dist/src/tui/tui-startup-resources.js +1 -1
  287. package/dist/src/tui/tui.js +2 -2
  288. package/dist/src/voice/tts/audio.js +1 -1
  289. package/dist/src/work-discovery/service.js +2 -2
  290. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  291. package/package.json +4 -4
  292. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BGCqlTcR.js +0 -1
  293. package/dist/gateway/static/root/assets/api-DEneywgz.js +0 -1
  294. package/dist/gateway/static/root/assets/apps-page-vC87gAyb.js +0 -1
  295. package/dist/gateway/static/root/assets/automations-workspace-CzYmREol.js +0 -7
  296. package/dist/gateway/static/root/assets/browser-settings-page-BxaSzUIU.js +0 -3
  297. package/dist/gateway/static/root/assets/capabilities-D0S3DuAD.js +0 -1
  298. package/dist/gateway/static/root/assets/capabilities-settings-panel-CFCu-8da.js +0 -8
  299. package/dist/gateway/static/root/assets/channels-settings-CENp82yt.js +0 -1
  300. package/dist/gateway/static/root/assets/connectors-page-g_KTZWCb.js +0 -2
  301. package/dist/gateway/static/root/assets/device-pairing-wizard-DO7jp0ep.js +0 -1
  302. package/dist/gateway/static/root/assets/gateway-settings-BkeSEBxk.js +0 -1
  303. package/dist/gateway/static/root/assets/home-page-KoQXV4hp.js +0 -1
  304. package/dist/gateway/static/root/assets/index-ZxnWUdPv.css +0 -1
  305. package/dist/gateway/static/root/assets/index-u4709aCa.js +0 -89
  306. package/dist/gateway/static/root/assets/local-app-workbench-page-7QX0YFa7.js +0 -2
  307. package/dist/gateway/static/root/assets/local-apps-page-RSAl-NhO.js +0 -1
  308. package/dist/gateway/static/root/assets/management-settings-C_cb0Kue.js +0 -1
  309. package/dist/gateway/static/root/assets/messages-M5xl1fHE.js +0 -3
  310. package/dist/gateway/static/root/assets/note-detail-panel-CVWst-Er.js +0 -5
  311. package/dist/gateway/static/root/assets/notes-page-BFwCgIls.js +0 -8
  312. package/dist/gateway/static/root/assets/product-delivery-chCjIpvu.js +0 -1
  313. package/dist/gateway/static/root/assets/product-open-page-BIGvTs9n.js +0 -1
  314. package/dist/gateway/static/root/assets/project-detail-page-BFEtpkcf.js +0 -1
  315. package/dist/gateway/static/root/assets/projects-page-CHr-P2z4.js +0 -1
  316. package/dist/gateway/static/root/assets/remote-access-hub-PhEyHSOb.js +0 -1
  317. package/dist/gateway/static/root/assets/sessions-page-CmIhlHPS.js +0 -1
  318. package/dist/gateway/static/root/assets/settings-advanced-gate-CCOTu1jb.js +0 -1
  319. package/dist/gateway/static/root/assets/shares-settings-CG1sll8V.js +0 -1
  320. package/dist/gateway/static/root/assets/skill-reload-api-Byq23h9c.js +0 -1
  321. package/dist/gateway/static/root/assets/task-detail-page-D5q-wk_d.js +0 -1
  322. package/dist/gateway/static/root/assets/user-model-page-DE3ZeJL3.js +0 -2
  323. package/dist/gateway/static/root/assets/workflows-page-DGZaETmN.js +0 -6
@@ -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{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-B-GDnZO9.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./plus-Q2yW6OE7.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./cn-JdwAhgNB.js";import{a as d,c as f,n as p,r as m}from"./locale-store-C4RjTd0C.js";import{t as h}from"./messages-M5xl1fHE.js";import{a as g,n as _,o as v,r as y,s as ee,t as te}from"./dist-BGTk37IG.js";import{i as ne}from"./vendor-swr-BIWyz7Rc.js";import{t as b}from"./button-CS04eWY9.js";import{n as x,r as S}from"./gateway-config-swr-DgFmBSH9.js";import{t as C}from"./skeleton-BwbyijEw.js";import{i as re,o as w}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as T,t as E}from"./registry-api-CRnytFLF.js";import{$c as D,Aa as O,Ca as k,Da as A,Ea as j,Il as M,Kt as N,Ll as P,Ma as F,Na as I,Ns as L,Oa as R,Pc as z,Ps as B,Pu as V,R as ie,Rc as H,Ro as U,Sa as W,Ta as ae,_l as oe,da as se,dd as ce,el as le,gi as G,hl as ue,ka as de,la as K,nc as fe,ou as pe,pc as me,qt as he,ua as ge,ud as _e,wa as ve,xu as q,ya as ye,zl as be}from"./index-u4709aCa.js";import{n as xe,r as Se}from"./settings-page-layout-nskqtzZs.js";import{n as Ce,t as J}from"./settings-form-section-D3UN4rb4.js";import{t as Y}from"./page-tabs-q6lpN9OD.js";import{n as we,t as Te}from"./use-autosave-BB1JBOCz.js";import{t as Ee}from"./settings-advanced-gate-CCOTu1jb.js";var X=e(t(),1),De=n(),Z=r();function Oe(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function ke(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ae(e){let t=(0,De.c)(113),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,d;t[0]!==i.unnamedSession||t[1]!==n.name?(d=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=d):d=t[2];let f=d,m=p(Pe),g;t[3]!==m||t[4]!==n?(g=k(n,h(m).sidebar.sessionFilters),t[3]=m,t[4]=n,t[5]=g):g=t[5];let _=g,v;t[6]===n.name?v=t[7]:(v=n.name?.trim(),t[6]=n.name,t[7]=v);let y=!!v,ee=n.status===`archived`,te=n.status===`pinned`,ne=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,b;t[8]===ne?b=t[9]:(b=u(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,ne),t[8]=ne,t[9]=b);let x;t[10]===c?x=t[11]:(x=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[10]=c,t[11]=x);let S=r===`list`&&`sm:py-3`,C;t[12]===S?C=t[13]:(C=u(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,S),t[12]=S,t[13]=C);let re;t[14]===n?re=t[15]:(re=(0,Z.jsx)(W,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[14]=n,t[15]=re);let w;t[16]===_?w=t[17]:(w=(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:_}),t[16]=_,t[17]=w);let T;t[18]!==w||t[19]!==re?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[re,w]}),t[18]=w,t[19]=re,t[20]=T):T=t[20];let E;t[21]===te?E=t[22]:(E=te?(0,Z.jsx)(le,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[21]=te,t[22]=E);let O;t[23]===n.updatedAt?O=t[24]:(O=Oe(n.updatedAt),t[23]=n.updatedAt,t[24]=O);let A;t[25]===O?A=t[26]:(A=(0,Z.jsx)(`span`,{children:O}),t[25]=O,t[26]=A);let j;t[27]!==E||t[28]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[E,A]}),t[27]=E,t[28]=A,t[29]=j):j=t[29];let M;t[30]!==T||t[31]!==j||t[32]!==C?(M=(0,Z.jsxs)(`div`,{className:C,children:[T,j]}),t[30]=T,t[31]=j,t[32]=C,t[33]=M):M=t[33];let N=r===`list`&&`sm:py-3`,P;t[34]===N?P=t[35]:(P=u(`min-w-0 flex-1 px-3 py-2`,N),t[34]=N,t[35]=P);let F=r===`list`&&`sm:items-start`,I;t[36]===F?I=t[37]:(I=u(`flex gap-3`,F),t[36]=F,t[37]=I);let R;t[38]!==o||t[39]!==a?(R=(0,Z.jsx)(ie,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[38]=o,t[39]=a,t[40]=R):R=t[40];let z;t[41]===f?z=t[42]:(z=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[41]=f,t[42]=z);let B;t[43]!==n.key||t[44]!==y?(B=y?(0,Z.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[43]=n.key,t[44]=y,t[45]=B):B=t[45];let V;t[46]!==z||t[47]!==B?(V=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[z,B]}),t[46]=z,t[47]=B,t[48]=V):V=t[48];let H;t[49]!==I||t[50]!==R||t[51]!==V?(H=(0,Z.jsxs)(`div`,{className:I,children:[R,V]}),t[49]=I,t[50]=R,t[51]=V,t[52]=H):H=t[52];let U;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(oe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[53]=U):U=t[53];let ae;t[54]===n.messageCount?ae=t[55]:(ae=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[U,n.messageCount]}),t[54]=n.messageCount,t[55]=ae);let se;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Z.jsx)(fe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[56]=se):se=t[56];let G;t[57]===n.estimatedTokens?G=t[58]:(G=ke(n.estimatedTokens),t[57]=n.estimatedTokens,t[58]=G);let ue;t[59]===G?ue=t[60]:(ue=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[se,G]}),t[59]=G,t[60]=ue);let de;t[61]!==ae||t[62]!==ue?(de=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[ae,ue]}),t[61]=ae,t[62]=ue,t[63]=de):de=t[63];let K;t[64]===n.tags?K=t[65]:(K=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Ne),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[64]=n.tags,t[65]=K);let pe;t[66]!==P||t[67]!==H||t[68]!==de||t[69]!==K?(pe=(0,Z.jsxs)(`div`,{className:P,children:[H,de,K]}),t[66]=P,t[67]=H,t[68]=de,t[69]=K,t[70]=pe):pe=t[70];let he;t[71]===l?he=t[72]:(he=()=>l(`continue`),t[71]=l,t[72]=he);let ge;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(oe,{className:`size-4`,strokeWidth:1.75}),t[73]=ge):ge=t[73];let ve;t[74]!==i.continueChat||t[75]!==he?(ve=(0,Z.jsx)(`button`,{type:`button`,className:L,title:i.continueChat,"aria-label":i.continueChat,onClick:he,children:ge}),t[74]=i.continueChat,t[75]=he,t[76]=ve):ve=t[76];let q;t[77]!==ee||t[78]!==i.archive||t[79]!==i.unarchive||t[80]!==l?(q=ee?(0,Z.jsx)(`button`,{type:`button`,className:L,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(ce,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:L,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(_e,{className:`size-4`,strokeWidth:1.75})}),t[77]=ee,t[78]=i.archive,t[79]=i.unarchive,t[80]=l,t[81]=q):q=t[81];let ye;t[82]!==te||t[83]!==i.pin||t[84]!==i.unpin||t[85]!==l?(ye=te?(0,Z.jsx)(`button`,{type:`button`,className:L,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(D,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:L,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(le,{className:`size-4`,strokeWidth:1.75})}),t[82]=te,t[83]=i.pin,t[84]=i.unpin,t[85]=l,t[86]=ye):ye=t[86];let be;t[87]===l?be=t[88]:(be=()=>l(`export`),t[87]=l,t[88]=be);let xe;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[89]=xe):xe=t[89];let Se;t[90]!==i.export||t[91]!==be?(Se=(0,Z.jsx)(`button`,{type:`button`,className:L,title:i.export,"aria-label":i.export,onClick:be,children:xe}),t[90]=i.export,t[91]=be,t[92]=Se):Se=t[92];let Ce;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=u(L,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[93]=Ce):Ce=t[93];let J;t[94]===l?J=t[95]:(J=()=>l(`delete`),t[94]=l,t[95]=J);let Y;t[96]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Z.jsx)(me,{className:`size-4`,strokeWidth:1.75}),t[96]=Y):Y=t[96];let we;t[97]!==i.delete||t[98]!==J?(we=(0,Z.jsx)(`button`,{type:`button`,className:Ce,title:i.delete,"aria-label":i.delete,onClick:J,children:Y}),t[97]=i.delete,t[98]=J,t[99]=we):we=t[99];let Te;t[100]!==ve||t[101]!==q||t[102]!==ye||t[103]!==Se||t[104]!==we?(Te=(0,Z.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Me,onKeyDown:je,children:[ve,q,ye,Se,we]}),t[100]=ve,t[101]=q,t[102]=ye,t[103]=Se,t[104]=we,t[105]=Te):Te=t[105];let Ee;return t[106]!==c||t[107]!==M||t[108]!==pe||t[109]!==Te||t[110]!==b||t[111]!==x?(Ee=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:b,onClick:c,onKeyDown:x,children:[M,pe,Te]}),t[106]=c,t[107]=M,t[108]=pe,t[109]=Te,t[110]=b,t[111]=x,t[112]=Ee):Ee=t[112],Ee}function je(e){return e.stopPropagation()}function Me(e){return e.stopPropagation()}function Ne(e){return(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Pe(e){return e.language}function Fe(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Ie(e,t){return t.find(t=>t.id===e)?.avatar}var Le={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ze(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Be(e){let t=Re(e)?e:{},n=Re(t.userContext)?t.userContext:{},r=Re(n.contextPlanning)?n.contextPlanning:{},i=Re(r.compaction)?r.compaction:{},a=Le,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:ze(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function Ve(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function He(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function Ue(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify(He(e))}),await x()}var We=128e3,Ge={balanced:Le,preserve:{...Le,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Le,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ke=K();function qe(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,U,`dark:border-edge`)}function Je(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function Ye(e){let t=Je(e);for(let[e,n]of Object.entries(Ge))if(t===Je(n))return e;return`custom`}function Xe(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,De.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=qe(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ze(e){let t=(0,De.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=u(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=d):d=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:c,children:[d,m]}),t[15]=c,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function Qe({hasToken:e}){let t=h(p(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=S(e),{data:i=[],isLoading:a}=ne(e?E:null,T,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Be(n.payload.config),[n]),[s,d]=(0,X.useReducer)(Ke,{form:null,baseline:null}),[f,m]=(0,X.useState)(``),g=(0,X.useRef)(!1),_=(0,X.useRef)(s.form);_.current=s.form;let v=(0,X.useRef)(null);ge({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:v,dispatch:d,onResetDirty:()=>{g.current=!1}});let y=s.form,ee=s.baseline,te=!!(y&&ee&&JSON.stringify(y)!==JSON.stringify(ee)),x=(0,X.useCallback)(e=>{g.current=!0,d({type:`patch`,patch:e})},[]),re=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),w=Te({value:y,dirty:te,onSave:(0,X.useCallback)(async e=>{try{await Ue(e),d({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ve(e);return n?t.invalidValue.replace(`{{field}}`,re(n)):null}});if(!e||!y)return r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(C,{className:`h-5 w-48`}),(0,Z.jsx)(C,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(C,{className:`h-36 w-full rounded-xl`})]})}):null;let D=Ye(y),O=Math.max(0,We-y.reserveTokens),k=Math.min(Math.floor(We*y.triggerThreshold),O),A=Math.min(100,k/We*100),j=Math.min(100,O/We*100),M=y.model?i.find(e=>e.id===y.model):void 0,N=M?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>M.contextWindow,P=y.keepRecentTokens+y.reserveTokens>k,F=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),I=e=>{let t=Ge[e];x({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.postCompactionSections})},L={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},R=()=>{let e=f.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(x({postCompactionSections:[...y.postCompactionSections,e]}),m(``))};return(0,Z.jsxs)(J,{onBlurCapture:w.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:ue,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(we,{status:w.status,error:w.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:y.enabled,onChange:e=>x({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),w.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:w.error}):null,y.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!y.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),D===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":D===e,className:u(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,B.transition,B.focusRingPanel,D===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>I(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:L[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:L[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Xe(k)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${A}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Xe(O)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${j}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((y.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>x({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Xe(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>x({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:y.recentTurnsPreserve,min:1,max:12,onChange:e=>x({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Xe(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>x({keepRecentTokens:Math.floor(e)})})]}),P?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(G,{value:y.model??``,disabled:!y.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>x({model:e})}),y.model?(0,Z.jsx)(b,{type:`button`,variant:`secondary`,onClick:()=>x({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ze,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:y.qualityGuard,onChange:e=>x({qualityGuard:e})}),(0,Z.jsx)(Ze,{label:t.gapAudit,hint:t.gapAuditHint,checked:y.gapAudit,onChange:e=>x({gapAudit:e})})]}),y.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(Ee,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:y.minMessagesBeforeCompact,min:2,onChange:e=>x({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((y.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>x({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:y.summaryMaxTokens,min:256,step:256,onChange:e=>x({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:y.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>x({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(F)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>x({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:y.summaryRetries,min:0,max:5,onChange:e=>x({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:y.minToolResultKeepChars,min:200,step:100,onChange:e=>x({minToolResultKeepChars:Math.floor(e)})})]}),N?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),y.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:y.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:u(`text-fg-muted hover:text-fg`,B.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>x({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(l,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:qe(),value:f,maxLength:120,disabled:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),R())}}),(0,Z.jsxs)(b,{type:`button`,variant:`secondary`,disabled:!f.trim()||y.postCompactionSections.length>=12,onClick:R,children:[(0,Z.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function $e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function et(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function tt(e){let t=$e(e)?e:{},n=$e(t.session)?t.session:{},r=$e(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:et(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function nt(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),x()}function rt(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,U,`dark:border-edge`)}var it=K();function at({hasToken:e}){let t=h(p(e=>e.language)).sessions.config,{data:n,isLoading:r}=S(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:tt(n.payload.config),[n]),[s,c]=(0,X.useReducer)(it,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,X.useRef)(!1),f=(0,X.useRef)(l);f.current=l;let m=(0,X.useRef)(null);ge({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:m,dispatch:c,onResetDirty:()=>{d.current=!1}});let g=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),_=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),v=Te({value:l,dirty:g,onSave:(0,X.useCallback)(async e=>{try{await nt(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(C,{className:`h-5 w-40`}),(0,Z.jsx)(C,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(J,{onBlurCapture:v.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:q,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(we,{status:v.status,error:v.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(a,{className:rt(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Z.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:rt(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:rt(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function ot(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function st(e){let t=(0,De.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:d,onUnarchive:f,onPin:p,onUnpin:m,onExport:h,onDelete:ne}=e,x=i?.status===`archived`,S=i?.status===`pinned`,C;t[0]===c?C=t[1]:(C=e=>!e&&c(),t[0]=c,t[1]=C);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(g,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,w)}),t[2]=T):T=t[2];let E;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(E=u(`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`,re,`dark:border-edge`),t[3]=E):E=t[3];let D;t[4]!==i||t[5]!==o||t[6]!==a?(D=i&&a?(0,Z.jsx)(ie,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=D):D=t[7];let O;t[8]!==s.unnamedSession||t[9]!==i?.name?(O=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=O):O=t[10];let k;t[11]===O?k=t[12]:(k=(0,Z.jsx)(ee,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:O}),t[11]=O,t[12]=k);let A;t[13]!==D||t[14]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[D,k]}),t[13]=D,t[14]=k,t[15]=A):A=t[15];let j;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(l,{className:`size-5`,strokeWidth:1.75}),t[16]=j):j=t[16];let M;t[17]===s.close?M=t[18]:(M=(0,Z.jsx)(_,{asChild:!0,children:(0,Z.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:j})}),t[17]=s.close,t[18]=M);let N;t[19]!==A||t[20]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[A,M]}),t[19]=A,t[20]=M,t[21]=N):N=t[21];let P;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(P=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(ct)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=P):P=t[26];let F;t[27]===P?F=t[28]:(F=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:P}),t[27]=P,t[28]=F);let I;t[29]!==s.detailExport||t[30]!==h?(I=(0,Z.jsx)(b,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:s.detailExport}),t[29]=s.detailExport,t[30]=h,t[31]=I):I=t[31];let L;t[32]!==x||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==d||t[36]!==f?(L=x?(0,Z.jsx)(b,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.unarchive}):(0,Z.jsx)(b,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.archive}),t[32]=x,t[33]=s.archive,t[34]=s.unarchive,t[35]=d,t[36]=f,t[37]=L):L=t[37];let R;t[38]!==S||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==p||t[42]!==m?(R=S?(0,Z.jsx)(b,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.unpin}):(0,Z.jsx)(b,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.pin}),t[38]=S,t[39]=s.pin,t[40]=s.unpin,t[41]=p,t[42]=m,t[43]=R):R=t[43];let z;t[44]!==s.delete||t[45]!==ne?(z=(0,Z.jsx)(b,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:ne,children:s.delete}),t[44]=s.delete,t[45]=ne,t[46]=z):z=t[46];let B;t[47]!==I||t[48]!==L||t[49]!==R||t[50]!==z?(B=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I,L,R,z]})}),t[47]=I,t[48]=L,t[49]=R,t[50]=z,t[51]=B):B=t[51];let V;t[52]!==N||t[53]!==F||t[54]!==B?(V=(0,Z.jsxs)(v,{children:[T,(0,Z.jsxs)(y,{className:E,"aria-describedby":void 0,children:[N,F,B]})]}),t[52]=N,t[53]=F,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==n||t[57]!==C||t[58]!==V?(H=(0,Z.jsx)(te,{open:n,onOpenChange:C,children:V}),t[56]=n,t[57]=C,t[58]=V,t[59]=H):H=t[59],H}function ct(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ot(e.content)})]},`${e.timestamp??``}-${e.role}-${ot(e.content).slice(0,24)}`)}var lt=20;function ut(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var dt=new Set([`all`,`active`,`pinned`,`archived`]),ft=new Set([`grid`,`list`]),pt=[`sessions`,`settings`];function mt(e){return e&&pt.includes(e)?e:`sessions`}function ht(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function gt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function _t(e){let t=(0,De.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=pt.map(e=>({id:e,label:ht(n,e),icon:e===`sessions`?be:z})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(Y,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function vt(e){let t=(0,De.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ht(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:gt(n,r)})]}),(0,Z.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function yt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:dt.has(t)?t:`all`,viewMode:ft.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function bt(){let e=h(p(e=>e.language)),t=e.sessions,n=f(e=>e.conversationId),r=!!n,{data:a,mutate:o}=ne(r?[`gateway-chat-agents`,n]:null,ye,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,c=a?.items??[],[l,d]=i(),m=mt(l.get(`tab`)),_=(0,X.useCallback)(e=>{let t=new URLSearchParams(l);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),d(t,{replace:!0})},[l,d]),[x,S]=(0,X.useReducer)(se,l,yt),{searchInput:C,debouncedSearch:T,statusFilter:E,viewMode:D,channelFilter:k,sessions:L,loading:z,error:ie,hasMore:U,stats:W,detailOpen:oe,detailLoading:ce,detailSession:G,confirmOpen:ue,confirmKey:K}=x;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=C.trim();T!==e&&S({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[C,T]);let fe=l.toString(),me=(0,X.useRef)(fe);if(me.current!==fe){me.current=fe;let e=l.get(`q`)??``,t=l.get(`status`),n=l.get(`view`),r=(l.get(`channel`)??``).trim(),i=dt.has(t)?t:`all`,a=ft.has(n)?n:`grid`,o=e.trim();S({type:`patch`,patch:{...C===e?{}:{searchInput:e},...T===o?{}:{debouncedSearch:o},...E===i?{}:{statusFilter:i},...D===a?{}:{viewMode:a},...k===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(l),t=T.trim();t?e.set(`q`,t):e.delete(`q`),E===`all`?e.delete(`status`):e.set(`status`,E),D===`grid`?e.delete(`view`):e.set(`view`,D),k?e.set(`channel`,k):e.delete(`channel`),e.toString()!==l.toString()&&d(e,{replace:!0})},[T,l,d,E,D,k]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=!1;return(async()=>{S({type:`patch`,patch:{loading:!0,error:null}});try{let t=await de({limit:lt,offset:0,...T?{search:T}:{},...E===`all`?{}:{status:E},...k?{channel:k}:{}});if(e)return;S({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||S({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||S({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,m,T,E,k,t.loadError]),(0,X.useEffect)(()=>{!r||m!==`sessions`||R().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,m]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,m,o]),(0,X.useEffect)(()=>{if(!r||m!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||S({type:`patch`,patch:{sessions:L.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:G&&G.key===t.key?{...G,name:t.name}:G}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,m,L,G]);let ge=(0,X.useCallback)(async()=>{if(!(!r||z||!U)){S({type:`patch`,patch:{loading:!0,error:null}});try{let e=await de({limit:lt,offset:L.length,...T?{search:T}:{},...E===`all`?{}:{status:E},...k?{channel:k}:{}});S({type:`patch`,patch:{sessions:[...L,...e.items],hasMore:e.hasMore}})}catch(e){S({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{S({type:`patch`,patch:{loading:!1}})}}},[r,z,U,L.length,T,E,k,t.loadError]),q=(0,X.useCallback)((e,t)=>{S({type:`patch`,patch:{sessions:L.map(n=>n.key===e?{...n,status:t}:n),detailSession:G&&G.key===e?{...G,status:t}:G}})},[L,G]),Ce=(0,X.useCallback)(async e=>{S({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{S({type:`patch`,patch:{detailSession:await A(e)}})}catch{S({type:`patch`,patch:{detailOpen:!1}})}finally{S({type:`patch`,patch:{detailLoading:!1}})}},[]),J=e=>{Ce(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){S({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await ve(e),q(e,`archived`);break;case`unarchive`:await F(e),q(e,`active`);break;case`pin`:await O(e),q(e,`pinned`);break;case`unpin`:await I(e),q(e,`active`);break;case`export`:{let t=await j(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}R().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we=async e=>{try{await ae(e),S({type:`patch`,patch:{sessions:L.filter(t=>t.key!==e),detailSession:G?.key===e?null:G,...G?.key===e?{detailOpen:!1}:{}}}),R().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},Ee={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},De=[{key:`all`,label:t.filterAll,icon:be},{key:`active`,label:t.filterActive,icon:V},{key:`pinned`,label:t.filterPinned,icon:le},{key:`archived`,label:t.filterArchived,icon:_e}],Oe=(()=>{let e=Object.entries(W?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(Se,{gap:`gap-6`,children:[(0,Z.jsx)(xe,{title:t.title}),(0,Z.jsx)(_t,{s:t,activeTab:m,onChange:_}),(0,Z.jsx)(vt,{s:t,id:`settings`,activeTab:m,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Qe,{hasToken:r}),(0,Z.jsx)(at,{hasToken:r})]})}),(0,Z.jsxs)(vt,{s:t,id:`sessions`,activeTab:m,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:De.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":E===e,onClick:()=>S({type:`patch`,patch:{statusFilter:e}}),className:u(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,B.transition,B.focusRingPanel,E===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(H,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:C,onChange:e=>S({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":T||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!k,onClick:()=>S({type:`patch`,patch:{channelFilter:``}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,B.transition,B.focusRingPanel,k?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),Oe.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":k===e,onClick:()=>S({type:`patch`,patch:{channelFilter:e}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,B.transition,B.focusRingPanel,k===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,W?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:W.byChannel[e]})]},e))]}),W?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[W.totalSessions,t.totalSessions],[W.activeSessions,t.activeSessions],[W.pinnedSessions,t.pinnedSessions],[W.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,ie?(0,Z.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:ie}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ut(t.sessionCount,{count:L.length})}),(0,Z.jsxs)(`div`,{className:he,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(b,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":D===`grid`,onClick:()=>S({type:`patch`,patch:{viewMode:`grid`}}),className:u(N,`size-7 p-0`,D===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,D===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(P,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(b,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":D===`list`,onClick:()=>S({type:`patch`,patch:{viewMode:`list`}}),className:u(N,`size-9 p-0`,D===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,D===`list`&&`text-accent-fg`),children:(0,Z.jsx)(M,{className:`size-3.5`,strokeWidth:1.5})})]})]}),z&&L.length===0?(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):L.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Z.jsx)(pe,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(b,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:u(`grid min-w-0 gap-3`,D===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":T||void 0,children:L.map(e=>{let t=Fe(e,s);return(0,Z.jsx)(Ae,{session:e,variant:D,labels:Te,sessionAgentId:t,sessionAgentAvatar:Ie(t,c),onOpen:()=>J(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),U?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(b,{type:`button`,variant:`secondary`,disabled:z,onClick:()=>void ge(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(st,{open:oe,loading:ce,session:G,sessionAgentId:G?Fe(G,s):void 0,sessionAgentAvatar:G?Ie(Fe(G,s),c):void 0,labels:Ee,onClose:()=>{S({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>G&&void Y(G.key,`archive`),onUnarchive:()=>G&&void Y(G.key,`unarchive`),onPin:()=>G&&void Y(G.key,`pin`),onUnpin:()=>G&&void Y(G.key,`unpin`),onExport:()=>G&&void Y(G.key,`export`),onDelete:()=>G&&S({type:`patch`,patch:{confirmKey:G.key,confirmOpen:!0}})}),(0,Z.jsx)(te,{open:ue,onOpenChange:e=>S({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(v,{children:[(0,Z.jsx)(g,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,w)}),(0,Z.jsxs)(y,{className:u(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,re),children:[(0,Z.jsx)(ee,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:K?ut(t.deleteSessionMessage,{name:L.find(e=>e.key===K)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(b,{type:`button`,variant:`secondary`,onClick:()=>S({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(b,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{K&&we(K),S({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{bt as SessionsPage};
@@ -1 +0,0 @@
1
- import{Tn as e}from"./index-u4709aCa.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./check-DUBLcKHA.js";import{n as o,r as s}from"./popover-select-B-GDnZO9.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./plus-Q2yW6OE7.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{a as f,c as p,n as m,r as h}from"./locale-store-C4RjTd0C.js";import{t as g}from"./messages-M5xl1fHE.js";import{a as _,n as v,o as y,r as b,s as x,t as S}from"./dist-BGTk37IG.js";import{t as C}from"./copy-to-clipboard-HOJ79TWv.js";import{i as ee}from"./vendor-swr-BIWyz7Rc.js";import{t as w}from"./button-CS04eWY9.js";import{n as T,r as E}from"./gateway-config-swr-DgFmBSH9.js";import{t as D}from"./skeleton-BwbyijEw.js";import{Ai as O,At as te,Bi as k,Cn as A,Ei as j,Fi as M,Gi as N,Gu as P,Hi as F,Ii as ne,Mi as I,Ni as L,Oi as R,Ou as z,Ri as re,Ro as B,Tl as V,Uc as ie,Ui as H,Vi as U,Wi as W,Xl as ae,_l as oe,aa as se,bc as ce,bn as le,da as ue,du as de,ji as fe,ku as pe,ou as me,pc as he,sa as G,zi as ge}from"./index-u4709aCa.js";import{n as _e,r as ve,t as ye}from"./settings-page-layout-nskqtzZs.js";import{t as K}from"./settings-form-section-D3UN4rb4.js";import{t as be}from"./page-tabs-q6lpN9OD.js";import{t as q}from"./settings-loading-skeleton-CAmWMaOT.js";var J=e(t(),1),xe=n(),Y={enabled:!0,defaultTtlHours:24,maxTtlDays:30,maxActiveShares:500,maxFileSizeMb:500,directoryMaxFolderSizeMb:2048,directoryMaxFileCount:1e4,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`],noteEnabled:!0,noteMaxTotalSizeMb:250,noteMaxAttachmentCount:50,siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function Se(){return structuredClone(Y)}var X=36e5,Z=864e5,Q=1048576;function Ce(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function we(e,t=32){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function Te(e){let t=Ce(e)?e:{},n=Ce(t.gateway)?t.gateway:{},r=Ce(n.share)?n.share:{},i=Ce(r.directory)?r.directory:{},a=Ce(r.note)?r.note:{},o=Ce(n.siteShare)?n.siteShare:{},s=Ce(o.static)?o.static:{},c=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):Y.defaultTtlHours*X,l=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):Y.maxTtlDays*Z,u=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):Y.maxFileSizeMb*Q,d=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):Y.directoryMaxFolderSizeMb*Q,f=typeof o.defaultTtlMs==`number`&&Number.isFinite(o.defaultTtlMs)?Math.floor(o.defaultTtlMs):Y.siteDefaultTtlHours*X,p=typeof o.maxTtlMs==`number`&&Number.isFinite(o.maxTtlMs)?Math.floor(o.maxTtlMs):Y.siteMaxTtlDays*Z,m=typeof s.maxRootDirSize==`number`&&Number.isFinite(s.maxRootDirSize)?Math.floor(s.maxRootDirSize):Y.siteMaxRootDirSizeMb*Q,h=typeof a.maxTotalSize==`number`&&Number.isFinite(a.maxTotalSize)?Math.floor(a.maxTotalSize):Y.noteMaxTotalSizeMb*Q;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(c/X)),maxTtlDays:Math.max(1,Math.round(l/Z)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):Y.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(u/Q)),directoryMaxFolderSizeMb:Math.max(1,Math.round(d/Q)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):Y.directoryMaxFileCount,inlinePreviewMimes:we(r.inlinePreviewMimes,32).length?we(r.inlinePreviewMimes,32):[...Y.inlinePreviewMimes],noteEnabled:a.enabled!==!1,noteMaxTotalSizeMb:Math.max(1,Math.round(h/Q)),noteMaxAttachmentCount:typeof a.maxAttachmentCount==`number`&&Number.isFinite(a.maxAttachmentCount)?Math.max(0,Math.min(500,Math.floor(a.maxAttachmentCount))):Y.noteMaxAttachmentCount,siteEnabled:o.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(f/X)),siteMaxTtlDays:Math.max(1,Math.round(p/Z)),maxActiveSites:typeof o.maxActiveSites==`number`&&Number.isFinite(o.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(o.maxActiveSites))):Y.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(m/Q)),siteMaxFileCount:typeof s.maxFileCount==`number`&&Number.isFinite(s.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(s.maxFileCount))):Y.siteMaxFileCount}}function Ee(e){let t=e.defaultTtlHours*X,n=e.maxTtlDays*Z,r=e.siteDefaultTtlHours*X,i=e.siteMaxTtlDays*Z;return t<6e4||t>6048e5?`Default share TTL must be between 1 minute and 7 days.`:n<6e4||n>2592e6?`Maximum share TTL must be between 1 minute and 30 days.`:t>n?`Default TTL cannot exceed maximum TTL.`:e.maxActiveShares<1||e.maxActiveShares>1e4?`Maximum active shares must be between 1 and 10,000.`:e.maxActiveSites<1||e.maxActiveSites>1e3?`Maximum active site shares must be between 1 and 1,000.`:e.maxFileSizeMb<1||e.maxFileSizeMb>10240?`Maximum file size must be between 1 MB and 10 GB.`:e.directoryMaxFolderSizeMb<1||e.directoryMaxFolderSizeMb>10240?`Maximum folder size must be between 1 MB and 10 GB.`:e.directoryMaxFileCount<1||e.directoryMaxFileCount>1e5?`Maximum directory file count must be between 1 and 100,000.`:e.noteMaxTotalSizeMb<1||e.noteMaxTotalSizeMb>2048?`Maximum Note snapshot size must be between 1 MB and 2 GB.`:e.noteMaxAttachmentCount<0||e.noteMaxAttachmentCount>500?`Maximum Note attachment count must be between 0 and 500.`:r<6e4||r>6048e5?`Default site share TTL must be between 1 minute and 7 days.`:i<6e4||i>2592e6?`Maximum site share TTL must be between 1 minute and 30 days.`:r>i?`Default site TTL cannot exceed maximum site TTL.`:e.siteMaxRootDirSizeMb<1||e.siteMaxRootDirSizeMb>10240?`Maximum static site size must be between 1 MB and 10 GB.`:e.siteMaxFileCount<1||e.siteMaxFileCount>1e5?`Maximum static site file count must be between 1 and 100,000.`:null}async function De(e){let t=Ee(e);if(t)throw Error(t);await f(h(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*X,maxTtlMs:e.maxTtlDays*Z,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Q,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Q,maxFileCount:e.directoryMaxFileCount},note:{enabled:e.noteEnabled,maxTotalSize:e.noteMaxTotalSizeMb*Q,maxAttachmentCount:e.noteMaxAttachmentCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*X,maxTtlMs:e.siteMaxTtlDays*Z,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Q,maxFileCount:e.siteMaxFileCount}}}})}),T()}var $=r();function Oe(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,B,`dark:border-edge`)}function ke({hasToken:e}){let t=g(m(e=>e.language)).sharesSettings,{data:n,isLoading:r}=E(e),i=(0,J.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(Te(n.payload.config)),[n]),a=(0,J.useRef)(!1),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(!1),h=o??i,_=i,v=(0,J.useMemo)(()=>!h||!_?!1:JSON.stringify(h)!==JSON.stringify(_),[h,_]),y=(0,J.useCallback)(e=>{a.current=!0,s(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),b=(0,J.useCallback)(async()=>{if(!(!h||c)){l(!0),d(null),p(!1);try{await De(h),a.current=!1,s(null),p(!0),window.setTimeout(()=>p(!1),2500)}catch(e){d(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[h,c,t.policySaveError]),x=(0,J.useCallback)(()=>{a.current=!1,s(null),d(null),p(!1)},[]);return!e||!h?r?(0,$.jsx)(K,{children:(0,$.jsx)(q,{rows:2})}):null:(0,$.jsxs)(K,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[f?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,$.jsx)(w,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>y(Se()),children:t.policyUseRecommended}),(0,$.jsx)(w,{type:`button`,variant:`secondary`,disabled:!v||c,onClick:x,children:t.policyDiscard}),(0,$.jsx)(w,{type:`button`,variant:`primary`,disabled:!v||c,onClick:()=>void b(),children:c?t.policySaving:t.policySave})]})]}),v?(0,$.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,u?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,$.jsx)(Ae,{t,form:h,onChange:y})]})}function Ae(e){let t=(0,xe.c)(189),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyFileSection}),t[0]=n.policyFileSection,t[1]=a);let o;t[2]===n.policyFileSectionHint?o=t[3]:(o=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyFileSectionHint}),t[2]=n.policyFileSectionHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,$.jsxs)(`div`,{className:`mb-4`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.policyEnabled||t[13]!==l?(u=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.policyEnabled]}),t[12]=n.policyEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({defaultTtlHours:e}),t[15]=i,t[16]=f);let p;t[17]!==r.defaultTtlHours||t[18]!==n.policyDefaultTtlHint||t[19]!==n.policyDefaultTtlHours||t[20]!==d||t[21]!==f?(p=(0,$.jsx)(je,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:d,onChange:f}),t[17]=r.defaultTtlHours,t[18]=n.policyDefaultTtlHint,t[19]=n.policyDefaultTtlHours,t[20]=d,t[21]=f,t[22]=p):p=t[22];let m=!r.enabled,h;t[23]===i?h=t[24]:(h=e=>i({maxTtlDays:e}),t[23]=i,t[24]=h);let g;t[25]!==r.maxTtlDays||t[26]!==n.policyMaxTtlDays||t[27]!==n.policyMaxTtlHint||t[28]!==m||t[29]!==h?(g=(0,$.jsx)(je,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:m,onChange:h}),t[25]=r.maxTtlDays,t[26]=n.policyMaxTtlDays,t[27]=n.policyMaxTtlHint,t[28]=m,t[29]=h,t[30]=g):g=t[30];let _=!r.enabled,v;t[31]===i?v=t[32]:(v=e=>i({maxActiveShares:e}),t[31]=i,t[32]=v);let y;t[33]!==r.maxActiveShares||t[34]!==n.policyMaxActiveShares||t[35]!==n.policyMaxActiveSharesHint||t[36]!==_||t[37]!==v?(y=(0,$.jsx)(je,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:_,onChange:v}),t[33]=r.maxActiveShares,t[34]=n.policyMaxActiveShares,t[35]=n.policyMaxActiveSharesHint,t[36]=_,t[37]=v,t[38]=y):y=t[38];let b=!r.enabled,x;t[39]===i?x=t[40]:(x=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=x);let S;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==b||t[45]!==x?(S=(0,$.jsx)(je,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:b,onChange:x}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=b,t[45]=x,t[46]=S):S=t[46];let C=!r.enabled,ee;t[47]===i?ee=t[48]:(ee=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=ee);let w;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==C||t[53]!==ee?(w=(0,$.jsx)(je,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:C,onChange:ee}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=C,t[53]=ee,t[54]=w):w=t[54];let T=!r.enabled,E;t[55]===i?E=t[56]:(E=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=E);let D;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==T||t[61]!==E?(D=(0,$.jsx)(je,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:T,onChange:E}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=T,t[61]=E,t[62]=D):D=t[62];let O;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==w||t[67]!==D||t[68]!==p?(O=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,w,D]}),t[63]=g,t[64]=y,t[65]=S,t[66]=w,t[67]=D,t[68]=p,t[69]=O):O=t[69];let te=!r.enabled,k;t[70]===i?k=t[71]:(k=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=k);let A;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==te||t[75]!==k?(A=(0,$.jsx)(Me,{t:n,values:r.inlinePreviewMimes,disabled:te,onChange:k}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=te,t[75]=k,t[76]=A):A=t[76];let j;t[77]!==O||t[78]!==A||t[79]!==s||t[80]!==u?(j=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[s,u,O,A]}),t[77]=O,t[78]=A,t[79]=s,t[80]=u,t[81]=j):j=t[81];let M;t[82]===n.policyNoteSection?M=t[83]:(M=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyNoteSection}),t[82]=n.policyNoteSection,t[83]=M);let N;t[84]===n.policyNoteSectionHint?N=t[85]:(N=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyNoteSectionHint}),t[84]=n.policyNoteSectionHint,t[85]=N);let P;t[86]!==M||t[87]!==N?(P=(0,$.jsxs)(`div`,{className:`mb-4`,children:[M,N]}),t[86]=M,t[87]=N,t[88]=P):P=t[88];let F;t[89]===i?F=t[90]:(F=e=>i({noteEnabled:e.target.checked}),t[89]=i,t[90]=F);let ne;t[91]!==r.noteEnabled||t[92]!==F?(ne=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.noteEnabled,onChange:F}),t[91]=r.noteEnabled,t[92]=F,t[93]=ne):ne=t[93];let I;t[94]!==n.policyNoteEnabled||t[95]!==ne?(I=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ne,n.policyNoteEnabled]}),t[94]=n.policyNoteEnabled,t[95]=ne,t[96]=I):I=t[96];let L=!r.enabled||!r.noteEnabled,R;t[97]===i?R=t[98]:(R=e=>i({noteMaxTotalSizeMb:e}),t[97]=i,t[98]=R);let z;t[99]!==r.noteMaxTotalSizeMb||t[100]!==n.policyNoteMaxTotalSizeHint||t[101]!==n.policyNoteMaxTotalSizeMb||t[102]!==L||t[103]!==R?(z=(0,$.jsx)(je,{id:`share-note-max-size-mb`,label:n.policyNoteMaxTotalSizeMb,hint:n.policyNoteMaxTotalSizeHint,value:r.noteMaxTotalSizeMb,min:1,max:2048,disabled:L,onChange:R}),t[99]=r.noteMaxTotalSizeMb,t[100]=n.policyNoteMaxTotalSizeHint,t[101]=n.policyNoteMaxTotalSizeMb,t[102]=L,t[103]=R,t[104]=z):z=t[104];let re=!r.enabled||!r.noteEnabled,B;t[105]===i?B=t[106]:(B=e=>i({noteMaxAttachmentCount:e}),t[105]=i,t[106]=B);let V;t[107]!==r.noteMaxAttachmentCount||t[108]!==n.policyNoteMaxAttachmentCount||t[109]!==n.policyNoteMaxAttachmentCountHint||t[110]!==re||t[111]!==B?(V=(0,$.jsx)(je,{id:`share-note-max-attachments`,label:n.policyNoteMaxAttachmentCount,hint:n.policyNoteMaxAttachmentCountHint,value:r.noteMaxAttachmentCount,min:0,max:500,disabled:re,onChange:B}),t[107]=r.noteMaxAttachmentCount,t[108]=n.policyNoteMaxAttachmentCount,t[109]=n.policyNoteMaxAttachmentCountHint,t[110]=re,t[111]=B,t[112]=V):V=t[112];let ie;t[113]!==z||t[114]!==V?(ie=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[z,V]}),t[113]=z,t[114]=V,t[115]=ie):ie=t[115];let H;t[116]!==P||t[117]!==I||t[118]!==ie?(H=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[P,I,ie]}),t[116]=P,t[117]=I,t[118]=ie,t[119]=H):H=t[119];let U;t[120]===n.policySiteSection?U=t[121]:(U=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[120]=n.policySiteSection,t[121]=U);let W;t[122]===n.policySiteSectionHint?W=t[123]:(W=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[122]=n.policySiteSectionHint,t[123]=W);let ae;t[124]!==U||t[125]!==W?(ae=(0,$.jsxs)(`div`,{className:`mb-4`,children:[U,W]}),t[124]=U,t[125]=W,t[126]=ae):ae=t[126];let oe;t[127]===i?oe=t[128]:(oe=e=>i({siteEnabled:e.target.checked}),t[127]=i,t[128]=oe);let se;t[129]!==r.siteEnabled||t[130]!==oe?(se=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:oe}),t[129]=r.siteEnabled,t[130]=oe,t[131]=se):se=t[131];let ce;t[132]!==n.policySiteEnabled||t[133]!==se?(ce=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[se,n.policySiteEnabled]}),t[132]=n.policySiteEnabled,t[133]=se,t[134]=ce):ce=t[134];let le=!r.siteEnabled,ue;t[135]===i?ue=t[136]:(ue=e=>i({siteDefaultTtlHours:e}),t[135]=i,t[136]=ue);let de;t[137]!==r.siteDefaultTtlHours||t[138]!==n.policySiteDefaultTtlHint||t[139]!==n.policySiteDefaultTtlHours||t[140]!==le||t[141]!==ue?(de=(0,$.jsx)(je,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:le,onChange:ue}),t[137]=r.siteDefaultTtlHours,t[138]=n.policySiteDefaultTtlHint,t[139]=n.policySiteDefaultTtlHours,t[140]=le,t[141]=ue,t[142]=de):de=t[142];let fe=!r.siteEnabled,pe;t[143]===i?pe=t[144]:(pe=e=>i({siteMaxTtlDays:e}),t[143]=i,t[144]=pe);let me;t[145]!==r.siteMaxTtlDays||t[146]!==n.policySiteMaxTtlDays||t[147]!==n.policySiteMaxTtlHint||t[148]!==fe||t[149]!==pe?(me=(0,$.jsx)(je,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:fe,onChange:pe}),t[145]=r.siteMaxTtlDays,t[146]=n.policySiteMaxTtlDays,t[147]=n.policySiteMaxTtlHint,t[148]=fe,t[149]=pe,t[150]=me):me=t[150];let he=!r.siteEnabled,G;t[151]===i?G=t[152]:(G=e=>i({maxActiveSites:e}),t[151]=i,t[152]=G);let ge;t[153]!==r.maxActiveSites||t[154]!==n.policyMaxActiveSites||t[155]!==n.policyMaxActiveSitesHint||t[156]!==he||t[157]!==G?(ge=(0,$.jsx)(je,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:he,onChange:G}),t[153]=r.maxActiveSites,t[154]=n.policyMaxActiveSites,t[155]=n.policyMaxActiveSitesHint,t[156]=he,t[157]=G,t[158]=ge):ge=t[158];let _e=!r.siteEnabled,ve;t[159]===i?ve=t[160]:(ve=e=>i({siteMaxRootDirSizeMb:e}),t[159]=i,t[160]=ve);let ye;t[161]!==r.siteMaxRootDirSizeMb||t[162]!==n.policySiteMaxRootDirSizeHint||t[163]!==n.policySiteMaxRootDirSizeMb||t[164]!==_e||t[165]!==ve?(ye=(0,$.jsx)(je,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:_e,onChange:ve}),t[161]=r.siteMaxRootDirSizeMb,t[162]=n.policySiteMaxRootDirSizeHint,t[163]=n.policySiteMaxRootDirSizeMb,t[164]=_e,t[165]=ve,t[166]=ye):ye=t[166];let K=!r.siteEnabled,be;t[167]===i?be=t[168]:(be=e=>i({siteMaxFileCount:e}),t[167]=i,t[168]=be);let q;t[169]!==r.siteMaxFileCount||t[170]!==n.policySiteMaxFileCount||t[171]!==n.policySiteMaxFileCountHint||t[172]!==K||t[173]!==be?(q=(0,$.jsx)(je,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:K,onChange:be}),t[169]=r.siteMaxFileCount,t[170]=n.policySiteMaxFileCount,t[171]=n.policySiteMaxFileCountHint,t[172]=K,t[173]=be,t[174]=q):q=t[174];let J;t[175]!==de||t[176]!==me||t[177]!==ge||t[178]!==ye||t[179]!==q?(J=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[de,me,ge,ye,q]}),t[175]=de,t[176]=me,t[177]=ge,t[178]=ye,t[179]=q,t[180]=J):J=t[180];let Y;t[181]!==ae||t[182]!==ce||t[183]!==J?(Y=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[ae,ce,J]}),t[181]=ae,t[182]=ce,t[183]=J,t[184]=Y):Y=t[184];let Se;return t[185]!==j||t[186]!==H||t[187]!==Y?(Se=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[j,H,Y]}),t[185]=j,t[186]=H,t[187]=Y,t[188]=Se):Se=t[188],Se}function je(e){let t=(0,xe.c)(21),{id:n,label:r,hint:i,value:a,min:o,max:s,disabled:c,onChange:l}=e,u;t[0]!==n||t[1]!==r?(u=(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=u):u=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=d(Oe(),`max-w-xs font-mono text-xs`),t[3]=f):f=t[3];let p;t[4]!==s||t[5]!==o||t[6]!==l?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==p||t[13]!==a?(m=(0,$.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:f,value:a,onChange:p}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=p,t[13]=a,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==u||t[18]!==m||t[19]!==h?(g=(0,$.jsxs)(`div`,{children:[u,m,h]}),t[17]=u,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function Me(e){let t=(0,xe.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,o;t[0]!==a||t[1]!==r?(o=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===n.policyInlinePreviewMimes?c=t[4]:(c=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=c);let l;t[5]===n.policyInlinePreviewMimesHint?l=t[6]:(l=(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=l);let u;t[7]!==i||t[8]!==a||t[9]!==r?(u=r.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,i?null:(0,$.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>a(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=a,t[9]=r,t[10]=u):u=t[10];let f;t[11]===u?f=t[12]:(f=(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=f);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=d(Oe(),`font-mono text-xs`),t[13]=p):p=t[13];let m=i||r.length>=32,h;t[14]===s?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==m||t[18]!==h?(g=(0,$.jsx)(`input`,{className:p,placeholder:n.policyMimePlaceholder,disabled:m,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==c||t[21]!==l||t[22]!==f||t[23]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[c,l,f,g]}),t[20]=c,t[21]=l,t[22]=f,t[23]=g,t[24]=_):_=t[24],_}function Ne(e){let t=(0,xe.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:c,conversationId:l,agentId:f}=e,h=c===void 0?`any`:c,C=g(m(Ie)),T=C.workspace,E=C.sharesSettings,D=j(Fe),{data:O}=ee(p(Pe)?`picker-agents-list`:null,le),te;bb0:{let e;t[0]===f?e=t[1]:(e=f?.trim(),t[0]=f,t[1]=e);let n=e;if(n){te=n;break bb0}let r;t[2]===D?r=t[3]:(r=D.trim(),t[2]=D,t[3]=r);let i=r;if(i){te=i;break bb0}if(O?.defaultId){te=O.defaultId;break bb0}if(O?.agents?.[0]?.id){te=O.agents[0].id;break bb0}te=``}let k=te,[M,N]=(0,J.useState)(k),P,F;t[4]===k?(P=t[5],F=t[6]):(P=()=>{N(k)},F=[k],t[4]=k,t[5]=P,t[6]=F),(0,J.useEffect)(P,F);let{tree:ne,loading:I,error:L,loadRoot:z,loadChildren:re,reset:B}=R(M,l??null),H;t[7]===a?H=t[8]:(H=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=H);let[U,W]=(0,J.useState)(H),ae;t[9]!==a||t[10]!==z||t[11]!==n||t[12]!==B||t[13]!==W?(ae=()=>{if(!n){B(),W(a?{path:a,isDirectory:!1}:null);return}z()},t[9]=a,t[10]=z,t[11]=n,t[12]=B,t[13]=W,t[14]=ae):ae=t[14];let oe;t[15]!==l||t[16]!==a||t[17]!==z||t[18]!==n||t[19]!==M||t[20]!==B?(oe=[n,M,l,z,B,a],t[15]=l,t[16]=a,t[17]=z,t[18]=n,t[19]=M,t[20]=B,t[21]=oe):oe=t[21],(0,J.useEffect)(ae,oe);let ce;t[22]===re?ce=t[23]:(ce=e=>{re(e)},t[22]=re,t[23]=ce);let ue=ce,de=U!==null&&(h===`any`||h===`file`&&!U.isDirectory||h===`directory`&&U.isDirectory),fe;bb1:{if(!U){fe=E.pickerHintNone;break bb1}if(h===`file`&&U.isDirectory){fe=E.pickerHintNeedsFile;break bb1}if(h===`directory`&&!U.isDirectory){fe=E.pickerHintNeedsDirectory;break bb1}fe=`${U.isDirectory?`📁`:`📄`} ${U.path}`}let pe=fe,he=O?.agents??[],G;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(_,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=G):G=t[24];let ge;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ge=d(`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`flex h-[min(28rem,calc(100vh-3rem))] flex-col overflow-hidden rounded-lg border border-edge bg-surface-overlay shadow-popover outline-none`),t[25]=ge):ge=t[25];let _e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(me,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=_e):_e=t[26];let ve=C.cron.refresh,ye=C.cron.refresh,K;t[27]===z?K=t[28]:(K=()=>void z(),t[27]=z,t[28]=K);let be=I&&`animate-spin`,q;t[29]===be?q=t[30]:(q=d(`size-4`,be),t[29]=be,t[30]=q);let Y;t[31]===q?Y=t[32]:(Y=(0,$.jsx)(ie,{className:q,"aria-hidden":!0}),t[31]=q,t[32]=Y);let Se;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(u,{className:`size-4`}),t[33]=Se):Se=t[33];let X;t[34]!==L||t[35]!==T.loadError?(X=L?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[T.loadError,`: `,L]}):null,t[34]=L,t[35]=T.loadError,t[36]=X):X=t[36];let Z;t[37]!==ue||t[38]!==I||t[39]!==U?.path||t[40]!==W||t[41]!==T.emptyDir||t[42]!==T.title||t[43]!==ne?(Z=I&&ne.length===0?(0,$.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(V,{className:`size-4 animate-spin`}),T.title,`…`]}):(0,$.jsx)(se,{tree:ne,selectedPath:U?.path??null,onSelectFile:e=>W({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>W({path:e,isDirectory:t}),onExpandDir:ue,onAction:void 0,emptyHint:T.emptyDir}),t[37]=ue,t[38]=I,t[39]=U?.path,t[40]=W,t[41]=T.emptyDir,t[42]=T.title,t[43]=ne,t[44]=Z):Z=t[44];let Q;t[45]!==X||t[46]!==Z?(Q=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[X,Z]}),t[45]=X,t[46]=Z,t[47]=Q):Q=t[47];let Ce;t[48]===pe?Ce=t[49]:(Ce=(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:pe}),t[48]=pe,t[49]=Ce);let we;t[50]===r?we=t[51]:(we=()=>r(!1),t[50]=r,t[51]=we);let Te;t[52]!==E.cancel||t[53]!==we?(Te=(0,$.jsx)(w,{type:`button`,variant:`ghost`,onClick:we,children:E.cancel}),t[52]=E.cancel,t[53]=we,t[54]=Te):Te=t[54];let Ee=!de,De;t[55]!==i||t[56]!==r||t[57]!==M||t[58]!==U?(De=()=>{U&&(i({...U,agentId:M}),r(!1))},t[55]=i,t[56]=r,t[57]=M,t[58]=U,t[59]=De):De=t[59];let Oe;t[60]!==E.pickerConfirm||t[61]!==Ee||t[62]!==De?(Oe=(0,$.jsx)(w,{type:`button`,disabled:Ee,onClick:De,children:E.pickerConfirm}),t[60]=E.pickerConfirm,t[61]=Ee,t[62]=De,t[63]=Oe):Oe=t[63];let ke;t[64]!==Te||t[65]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Te,Oe]}),t[64]=Te,t[65]=Oe,t[66]=ke):ke=t[66];let Ae;return t[67]!==Ce||t[68]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ce,ke]}),t[67]=Ce,t[68]=ke,t[69]=Ae):Ae=t[69],(0,$.jsx)(S,{open:n,onOpenChange:r,children:(0,$.jsxs)(y,{children:[G,(0,$.jsxs)(b,{className:ge,children:[(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[_e,(0,$.jsx)(x,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:E.pickerTitle}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:ve,"aria-label":ye,disabled:I,onClick:K,children:Y}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":T.close,children:Se})})]}),he.length>0?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,$.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:E.pickerAgentLabel}),(0,$.jsx)(o,{id:`picker-agent-select`,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:M,onChange:e=>{N(e.target.value),W(null)},children:he.map(e=>(0,$.jsxs)(s,{value:e.id,children:[A(e,C.agentsSettings),e.id===O?.defaultId?` ★`:``]},e.id))})]}):null,Q,Ae]})]})})}function Pe(e){return e.conversationId}function Fe(e){return e.agentId}function Ie(e){return e.language}var Le=[`shares`,`policy`];function Re(e){let t=(e??``).trim();return Le.includes(t)?t:`shares`}function ze(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Be(e,t){let n=new Date(e).getTime()-Date.now(),r=Math.abs(n),i=n<0;if(r<6e4)return t===`zh`?`刚刚`:`just now`;let a=Math.floor(r/6e4);if(a<60){let e=t===`zh`?`${a} 分钟`:`${a}m`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let o=Math.floor(a/60);if(o<24){let e=t===`zh`?`${o} 小时`:`${o}h`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let s=Math.floor(o/24),c=t===`zh`?`${s} 天`:`${s}d`;return i?t===`zh`?`${c}前`:`${c} ago`:c}var Ve=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`},{value:2592e6,key:`30d`}];function He(){let e=(0,xe.c)(23),t=m(We),n=g(t).sharesSettings,r=!!p(Ue),[a,o]=i(),s;e[0]===a?s=e[1]:(s=Re(a.get(`tab`)),e[0]=a,e[1]=s);let c=s,l;e[2]===o?l=e[3]:(l=e=>{o(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=o,e[3]=l);let u=l;if(!r)return(0,$.jsx)(ve,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let d={shares:n.tabShares,policy:n.tabPolicy},f=Le.map(e=>({id:e,label:d[e]})),h;e[4]===n.title?h=e[5]:(h=(0,$.jsx)(_e,{title:n.title}),e[4]=n.title,e[5]=h);let _;e[6]!==c||e[7]!==u||e[8]!==n.tabsAria||e[9]!==f?(_=(0,$.jsx)(be,{items:f,activeTab:c,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[6]=c,e[7]=u,e[8]=n.tabsAria,e[9]=f,e[10]=_):_=e[10];let v;e[11]!==c||e[12]!==r||e[13]!==t||e[14]!==n?(v=c===`shares`?(0,$.jsx)(Ge,{t:n,language:t}):(0,$.jsx)(ke,{hasToken:r}),e[11]=c,e[12]=r,e[13]=t,e[14]=n,e[15]=v):v=e[15];let y;e[16]!==c||e[17]!==v?(y=(0,$.jsx)(ye,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:v}),e[16]=c,e[17]=v,e[18]=y):y=e[18];let b;return e[19]!==h||e[20]!==_||e[21]!==y?(b=(0,$.jsxs)(ve,{children:[h,_,y]}),e[19]=h,e[20]=_,e[21]=y,e[22]=b):b=e[22],b}function Ue(e){return e.conversationId}function We(e){return e.language}function Ge(e){let t=(0,xe.c)(79),{t:n,language:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:3e4},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,mutate:c}=ee(`shares-list`,re,i),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:3e4},t[1]=l):l=t[1];let u=ee(`hosted-publications-list`,ne,l),f;t[2]===a?.payload?.shares?f=t[3]:(f=a?.payload?.shares??[],t[2]=a?.payload?.shares,t[3]=f);let p=f,[m,h]=(0,J.useState)(!1),g;bb0:{if(m){g=p;break bb0}let e;t[4]===p?e=t[5]:(e=p.filter(Xe),t[4]=p,t[5]=e),g=e}let _=g,v;t[6]===p?v=t[7]:(v=p.filter(Ye),t[6]=p,t[7]=v);let y=v.length,b;t[8]===p?b=t[9]:(b=p.filter(Je),t[8]=p,t[9]=b);let x=b.length,S;t[10]===c?S=t[11]:(S=()=>void c(),t[10]=c,t[11]=S);let C;t[12]!==n||t[13]!==S?(C=(0,$.jsx)(nt,{t:n,onCreated:S}),t[12]=n,t[13]=S,t[14]=C):C=t[14];let T=u.data?.connected===!0,E=u.data?.publishingAllowed===!0,D;t[15]===u?D=t[16]:(D=()=>void u.mutate(),t[15]=u,t[16]=D);let O;t[17]!==r||t[18]!==E||t[19]!==D||t[20]!==T?(O=(0,$.jsx)(Ze,{language:r,connected:T,publishingAllowed:E,onCreated:D}),t[17]=r,t[18]=E,t[19]=D,t[20]=T,t[21]=O):O=t[21];let te=m?n.allSharesTitle:n.listTitle,k;t[22]===y?k=t[23]:(k=y>0&&(0,$.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,y,`)`]}),t[22]=y,t[23]=k);let A;t[24]!==te||t[25]!==k?(A=(0,$.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[te,k]}),t[24]=te,t[25]=k,t[26]=A):A=t[26];let j;t[27]===c?j=t[28]:(j=()=>void c(),t[27]=c,t[28]=j);let M=s&&`animate-spin`,N;t[29]===M?N=t[30]:(N=d(`size-3.5`,M),t[29]=M,t[30]=N);let P;t[31]===N?P=t[32]:(P=(0,$.jsx)(ie,{className:N}),t[31]=N,t[32]=P);let F;t[33]!==s||t[34]!==j||t[35]!==P?(F=(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:j,disabled:s,children:P}),t[33]=s,t[34]=j,t[35]=P,t[36]=F):F=t[36];let I;t[37]!==x||t[38]!==m||t[39]!==n.hideExpired||t[40]!==n.showExpired?(I=x>0&&(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>h(qe),children:m?n.hideExpired:n.showExpired}),t[37]=x,t[38]=m,t[39]=n.hideExpired,t[40]=n.showExpired,t[41]=I):I=t[41];let L;t[42]!==F||t[43]!==I?(L=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[F,I]}),t[42]=F,t[43]=I,t[44]=L):L=t[44];let R;t[45]!==A||t[46]!==L?(R=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[A,L]}),t[45]=A,t[46]=L,t[47]=R):R=t[47];let z;t[48]!==a||t[49]!==o||t[50]!==_||t[51]!==s||t[52]!==r||t[53]!==c||t[54]!==n?(z=s&&!a?(0,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Ke)}):o?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{children:n.error}),(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):_.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:_.map(e=>(0,$.jsx)(it,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[48]=a,t[49]=o,t[50]=_,t[51]=s,t[52]=r,t[53]=c,t[54]=n,t[55]=z):z=t[55];let B;t[56]!==x||t[57]!==c||t[58]!==m||t[59]!==n?(B=x>0&&m&&(0,$.jsx)(at,{t:n,onCleaned:()=>void c()}),t[56]=x,t[57]=c,t[58]=m,t[59]=n,t[60]=B):B=t[60];let V;t[61]!==R||t[62]!==z||t[63]!==B?(V=(0,$.jsxs)(K,{children:[R,z,B]}),t[61]=R,t[62]=z,t[63]=B,t[64]=V):V=t[64];let H;t[65]===u?H=t[66]:(H=()=>void u.mutate(),t[65]=u,t[66]=H);let U;t[67]!==u.data||t[68]!==u.error||t[69]!==u.isLoading||t[70]!==r||t[71]!==n||t[72]!==H?(U=(0,$.jsx)(Qe,{data:u.data,error:u.error,isLoading:u.isLoading,language:r,t:n,onChanged:H}),t[67]=u.data,t[68]=u.error,t[69]=u.isLoading,t[70]=r,t[71]=n,t[72]=H,t[73]=U):U=t[73];let W;return t[74]!==O||t[75]!==V||t[76]!==U||t[77]!==C?(W=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[C,O,V,U]}),t[74]=O,t[75]=V,t[76]=U,t[77]=C,t[78]=W):W=t[78],W}function Ke(e,t){return(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(D,{className:`h-4 w-2/3`}),(0,$.jsx)(D,{className:`mt-2 h-3 w-1/2`})]}),(0,$.jsx)(D,{className:`h-7 w-20 rounded-md`})]})},t)}function qe(e){return!e}function Je(e){return e.expired||e.revoked}function Ye(e){return!e.expired&&!e.revoked}function Xe(e){return!e.expired&&!e.revoked}function Ze({language:e,connected:t,publishingAllowed:n,onCreated:r}){let i=e===`zh`,[a,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(6048e5),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(null),[ee,T]=(0,J.useState)(null),E=async()=>{if(a.trim()){b(!0),T(null);try{S(await fe({path:a.trim(),title:h.trim()||void 0,ttlMs:_,spaFallback:!0,...l?{agentId:l}:{}})),r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{b(!1)}}};return(0,$.jsxs)(K,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(z,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i?`发布静态网站`:`Publish static website`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i?`把工作区内的 HTML 文件,或包含 index.html 的网站目录,发布到隔离的托管域名。`:`Publish an HTML file or a website directory containing index.html to the isolated hosted origin.`}),t&&!n?(0,$.jsx)(`p`,{className:`mt-3 rounded-md bg-warning-soft px-3 py-2 text-xs text-warning`,children:i?`管理员已暂停你的公网分享能力。已有远端链接当前不可访问;你仍可在下方撤销它们。`:`An administrator has paused public sharing for your account. Existing hosted links are unavailable, but you can still revoke them below.`}):null,(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-[1fr_12rem]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{value:a,onChange:e=>{c(e.target.value),f(!1),S(null)},placeholder:i?`选择 HTML 文件或网站目录`:`Select an HTML file or website directory`,className:`h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`}),(0,$.jsxs)(w,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>m(!0),children:[a&&!d?(0,$.jsx)(de,{className:`size-4`}):(0,$.jsx)(me,{className:`size-4`}),a?i?`更换`:`Change`:i?`选择`:`Browse`]})]}),(0,$.jsxs)(o,{value:String(_),onChange:e=>v(Number(e.target.value)),children:[(0,$.jsx)(s,{value:`86400000`,children:i?`24 小时`:`24 hours`}),(0,$.jsx)(s,{value:`604800000`,children:i?`7 天`:`7 days`}),(0,$.jsx)(s,{value:`2592000000`,children:i?`30 天`:`30 days`})]}),(0,$.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:i?`网站标题(可选)`:`Site title (optional)`,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent sm:col-span-2`})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,$.jsxs)(w,{type:`button`,onClick:()=>void E(),disabled:!a.trim()||y||!t||!n,children:[y?(0,$.jsx)(V,{className:`size-4 animate-spin`}):(0,$.jsx)(z,{className:`size-4`}),y?i?`发布中…`:`Publishing…`:i?`发布网站`:`Publish site`]}),x?(0,$.jsxs)(`button`,{type:`button`,className:`min-w-0 truncate text-xs text-accent hover:underline`,onClick:()=>void C(x.shareUrl),children:[x.shareUrl,` · `,x.fileCount,` `,i?`个文件`:`files`,` · `,ze(x.totalBytes)]}):null]}),ee?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-danger`,children:ee}):null]})]}),(0,$.jsx)(Ne,{open:p,onOpenChange:m,initialPath:a||void 0,agentId:l||void 0,selectKind:`any`,onConfirm:e=>{c(e.path),u(e.agentId),f(e.isDirectory),S(null),T(null)}})]})}function Qe(e){let t=(0,xe.c)(18),{data:n,error:r,isLoading:i,language:a,t:o,onChanged:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(z,{className:`size-4 text-accent`,"aria-hidden":!0}),t[0]=c):c=t[0];let l;t[1]===o.hostedTitle?l=t[2]:(l=(0,$.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[c,o.hostedTitle]}),t[1]=o.hostedTitle,t[2]=l);let u;t[3]===o.hostedHint?u=t[4]:(u=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.hostedHint}),t[3]=o.hostedHint,t[4]=u);let d;t[5]!==l||t[6]!==u?(d=(0,$.jsx)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:(0,$.jsxs)(`div`,{children:[l,u]})}),t[5]=l,t[6]=u,t[7]=d):d=t[7];let f;t[8]!==n||t[9]!==r||t[10]!==i||t[11]!==a||t[12]!==s||t[13]!==o?(f=i&&!n?(0,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:2}).map($e)}):r?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o.error}):n?.connected?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[n.publishingAllowed?null:(0,$.jsx)(`p`,{className:`rounded-md bg-warning-soft px-3 py-2 text-xs text-warning`,children:a===`zh`?`管理员已暂停公网分享。已有托管链接当前不可访问,也不能更新;撤销操作仍然可用。`:`An administrator has paused public sharing. Existing hosted links are unavailable and cannot be updated; revocation remains available.`}),n.publications.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedEmpty}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:n.publications.map(e=>(0,$.jsx)(et,{publication:e,language:a,t:o,publishingAllowed:n.publishingAllowed,onChanged:s},e.id))})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedDisconnected}),(0,$.jsx)(te,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:s})]}),t[8]=n,t[9]=r,t[10]=i,t[11]=a,t[12]=s,t[13]=o,t[14]=f):f=t[14];let p;return t[15]!==d||t[16]!==f?(p=(0,$.jsxs)(K,{children:[d,f]}),t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function $e(e,t){return(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:[(0,$.jsx)(D,{className:`h-4 w-2/3`}),(0,$.jsx)(D,{className:`mt-2 h-3 w-1/2`})]},t)}function et({publication:e,language:t,t:n,publishingAllowed:r,onChanged:i}){let[o,s]=(0,J.useState)(!1),[l,u]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(!1),v=Date.now()>=new Date(e.expiresAt).getTime(),y=e.status===`active`&&!v,b=e.status===`revoked`?n.statusRevoked:v?n.statusExpired:e.status===`staging`?t===`zh`?`准备中`:`Staging`:n.statusActive,x=e.kind===`note_document`?ce:e.kind===`static_site`?z:oe,S=e.kind===`note_document`?t===`zh`?`笔记文档`:`Note document`:e.kind===`static_site`?t===`zh`?`静态网站`:`Static website`:t===`zh`?`会话快照`:`Conversation snapshot`,ee=(0,J.useCallback)(async()=>{e.shareUrl&&await C(e.shareUrl)&&(p(!0),window.setTimeout(()=>p(!1),2e3))},[e.shareUrl]),T=(0,J.useCallback)(async()=>{s(!1),u(!0);try{await k(e.id),i()}catch{}finally{u(!1)}},[e.id,i]),E=(0,J.useCallback)(async()=>{if(!(!e.revision||e.revision<=1)){h(!0);try{let t=(await M(e.id)).find(t=>t.revision<e.revision);if(!t)return;await F(e.id,e.revision,t.revision),i()}catch{}finally{h(!1)}}},[e.id,e.revision,i]),D=(0,J.useCallback)(async()=>{_(!0);try{await ge(e.id),i()}catch{}finally{_(!1)}},[e.id,i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(x,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:d(`text-xs font-medium`,y?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`),children:b})]}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[S,` · `,n.hostedRevision,` `,e.revision??`—`,` · `,e.managedFromThisDevice?n.hostedThisDevice:n.hostedOtherDevice]}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsxs)(`span`,{children:[t===`zh`?`浏览`:`Views`,`: `,e.viewCount,e.maxViews===null?``:` / ${e.maxViews}`]}),(0,$.jsx)(`span`,{children:v?n.statusExpired:Be(e.expiresAt,t)}),e.description?(0,$.jsx)(`span`,{className:`italic`,children:e.description}):null]})]}),y?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.shareUrl?(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:!r,title:n.copyUrl,onClick:()=>void ee(),children:f?(0,$.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(c,{className:`size-3.5`})}):null,(e.revision??0)>1?(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:m||!r,onClick:()=>void E(),title:t===`zh`?`回滚上一版本`:`Roll back one revision`,children:m?(0,$.jsx)(V,{className:`size-3.5 animate-spin`}):(0,$.jsx)(ae,{className:`size-3.5`})}):null,e.kind===`static_site`&&e.managedFromThisDevice?(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:g||!r,onClick:()=>void D(),title:t===`zh`?`发布工作区中的最新版本`:`Publish latest workspace version`,children:(0,$.jsx)(ie,{className:d(`size-3.5`,g&&`animate-spin`)})}):null,(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,disabled:l,onClick:()=>s(!0),children:l?(0,$.jsx)(V,{className:`size-3.5 animate-spin`}):(0,$.jsx)(he,{className:`size-3.5`})})]}):null]})}),(0,$.jsx)(G,{open:o,title:n.revokeConfirmTitle,description:n.revokeConfirmBody,confirmLabel:n.revokeConfirmLabel,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void T(),onCancel:()=>s(!1)})]})}var tt={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function nt({t:e,onCreated:t}){let[n,r]=(0,J.useReducer)(ue,tt),{expanded:i,path:a,isDirectory:c,agentId:u,ttlMs:f,maxViews:p,description:m,directoryMode:h,creating:g,result:_,errorMsg:v,resultDialogOpen:y,pickerOpen:b}=n,x=(0,J.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await I({path:a.trim(),ttlMs:f,maxViews:p,description:m.trim()||void 0,...u?{agentId:u}:{},...c?{kind:`directory`,directoryMode:h}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[a,c,u,f,p,m,h,t]),S=(0,J.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,$.jsxs)(K,{children:[(0,$.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:d(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,a?`text-fg`:`text-fg-subtle`),children:a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:c?`📁`:`📄`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,$.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,$.jsxs)(w,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,$.jsx)(de,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),c?(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,$.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:h,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,$.jsx)(s,{value:`browse`,children:e.directoryModeBrowse}),(0,$.jsx)(s,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,$.jsx)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:f,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Ve.map(t=>(0,$.jsx)(s,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,$.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:p??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,$.jsx)(s,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,$.jsx)(s,{value:`1`,children:`1`}),(0,$.jsx)(s,{value:`5`,children:`5`}),(0,$.jsx)(s,{value:`10`,children:`10`}),(0,$.jsx)(s,{value:`50`,children:`50`}),(0,$.jsx)(s,{value:`100`,children:`100`})]})]})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,$.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:m,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,$.jsxs)(w,{type:`button`,disabled:g||!a.trim(),onClick:()=>void x(),children:[g?(0,$.jsx)(V,{className:`size-4 animate-spin`}):(0,$.jsx)(l,{className:`size-4`}),g?e.creating:e.createButton]}),(0,$.jsx)(w,{type:`button`,variant:`ghost`,onClick:()=>{S(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),v&&(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v})]}),(0,$.jsx)(W,{open:y,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:_}),(0,$.jsx)(Ne,{open:b,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:a||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,$.jsxs)(w,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,$.jsx)(l,{className:`size-4`}),e.createTitle]})}var rt={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function it({share:e,t,language:n,onRevoked:r,onExtended:i}){let[o,s]=(0,J.useReducer)(ue,rt),{revokeOpen:l,revoking:u,linksOpen:f,urlCopied:p,copyFailed:m,extending:h}=o,g=!e.expired&&!e.revoked,_=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,v=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,y=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await U(e.id),r()}catch{}finally{s({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),b=(0,J.useCallback)(async()=>{if(s({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await C(e.shareUrl)){s({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{copyFailed:!1}}),2500);return}s({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),x=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{extending:!0}});try{await L(e.id,864e5),i()}catch{}finally{s({type:`patch`,patch:{extending:!1}})}},[e.id,i]),S=`share-links-${e.id}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:d(`flex min-w-0 flex-1 items-start gap-3 rounded-md text-left`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),"aria-expanded":f,"aria-controls":S,onClick:()=>s({type:`patch`,patch:{linksOpen:!f}}),children:[(0,$.jsx)(P,{className:d(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,f?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),e.kind===`note`?(0,$.jsx)(ce,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):e.kind===`session`?(0,$.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(de,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:d(`text-xs font-medium`,v),children:_})]}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.kind===`note`?n===`zh`?`笔记快照 · 版本 ${e.snapshotRevision??1}`:`Note snapshot · revision ${e.snapshotRevision??1}`:e.kind===`session`?n===`zh`?`会话快照 · ${e.messageCount??0} 条消息 · 版本 ${e.snapshotRevision??1}`:`Conversation snapshot · ${e.messageCount??0} messages · revision ${e.snapshotRevision??1}`:e.workspaceRelativePath}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:ze(e.fileSize)}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(pe,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:Be(e.expiresAt,n)]}),(0,$.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,$.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:g&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void b(),children:p?(0,$.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(c,{className:`size-3.5`})}),(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void x(),disabled:h,title:t.extend,children:h?(0,$.jsx)(V,{className:`size-3.5 animate-spin`}):(0,$.jsx)(pe,{className:`size-3.5`})}),(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>s({type:`patch`,patch:{revokeOpen:!0}}),disabled:u,children:u?(0,$.jsx)(V,{className:`size-3.5 animate-spin`}):(0,$.jsx)(he,{className:`size-3.5`})})]})})]}),g&&f?(0,$.jsxs)(`div`,{id:S,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,$.jsx)(N,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),m?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(H,{reachability:e.reachability})})]}):null]}),(0,$.jsx)(G,{open:l,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void y(),onCancel:()=>s({type:`patch`,patch:{revokeOpen:!1}})})]})}function at({t:e,onCleaned:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),o=(0,J.useCallback)(async()=>{r(!1),a(!0);try{await O(),t()}catch{}finally{a(!1)}},[t]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,$.jsx)(V,{className:`size-3.5 animate-spin`}):(0,$.jsx)(he,{className:`size-3.5`}),e.cleanExpired]})}),(0,$.jsx)(G,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{He as SharesSettingsPanel};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,r as n}from"./locale-store-C4RjTd0C.js";import{xi as r}from"./index-u4709aCa.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{f as a,g as o,m as s,t as c}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as l,r as u}from"./popover-select-B-GDnZO9.js";import{t as d}from"./circle-check-C23XjkUj.js";import{f,m as p,t as m}from"./markdown-view-DkPzc50Z.js";import{t as h}from"./x-B_N4OPjy.js";import{t as g}from"./cn-JdwAhgNB.js";import{c as _,n as ee}from"./locale-store-C4RjTd0C.js";import{i as te,n as ne,o as re,r as ie,s as ae,t as oe}from"./dist-BGTk37IG.js";import{u as se}from"./tasks-CDR_RVbQ.js";import{t as v}from"./button-CS04eWY9.js";import{t as y}from"./skeleton-BwbyijEw.js";import{$s as b,Bs as x,Co as ce,Fn as le,Fs as ue,Fu as de,In as fe,Js as pe,Jt as S,Ln as me,Ls as C,Ni as w,Pn as T,Pu as E,Qs as he,R as ge,Ri as D,Rn as O,Rs as k,Ti as A,Ua as _e,Ws as j,Xs as M,Yo as N,Yr as P,Zc as F,_l as I,_u as ve,cd as ye,du as be,ec as xe,mr as Se,n as Ce,ou as we,qs as Te,rl as Ee,sa as De,su as Oe,vu as ke,wi as Ae,ya as je,zn as Me}from"./index-u4709aCa.js";import{t as Ne}from"./page-context-capture-button-DVnGa7Lu.js";import{t as L}from"./date-picker-DBD5yedi.js";import{t as R}from"./dependency-picker-HE41Co5W.js";var z=r(),B=e(t(),1),V=i();function Pe({wait:e,detail:t,zh:n,onUpdated:r}){let[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(!1),f=(0,B.useRef)(null),p=e.kind===`approval`,m=Array.isArray(e.condition.choices)?e.condition.choices.filter(e=>typeof e==`string`):[];async function h(a){if(!p&&!i.trim()||p&&!a||o)return;let c=JSON.stringify([t.task.version,i.trim(),a]);f.current?.signature!==c&&(f.current={signature:c,key:crypto.randomUUID()}),s(!0),l(``);try{let o=await k(t.task.id,{type:`resolve_wait`,waitId:e.id,resolution:p?{kind:`task_approval`,decision:a}:{kind:`user_answer`,answer:i.trim()}},t.task.version,f.current.key);d(!0),r(o),N({tone:`success`,title:p?n?`决定已保存`:`Decision saved`:n?`补充信息已保存`:`Answer saved`,message:o.waits.length?n?`仍有其他等待条件,任务尚未恢复执行。`:`Other waiting conditions remain.`:n?`等待已解除,请在任务状态中查看后续执行进展。`:`The wait is resolved. Follow progress in the task status.`,source:n?`任务`:`Task`})}catch{l(n?`提交未确认,内容已保留。可重试;若问题已变化,请刷新。`:`Submission not confirmed. Your answer is saved here; retry or refresh if the question changed.`)}finally{s(!1)}}return(0,V.jsxs)(`form`,{className:`mt-3 space-y-3 rounded-lg border border-edge p-3`,onSubmit:e=>{e.preventDefault(),h()},children:[p?(0,V.jsxs)(`div`,{className:`text-sm text-fg`,children:[(0,V.jsx)(`p`,{children:e.reason}),(0,V.jsxs)(`p`,{className:`mt-2`,children:[n?`授权范围:`:`Permission: `,String(e.condition.capability)]}),(0,V.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,V.jsx)(v,{type:`button`,variant:`primary`,disabled:o||u,onClick:()=>void h(`approve`),children:n?`批准`:`Approve`}),(0,V.jsx)(v,{type:`button`,disabled:o||u,onClick:()=>void h(`deny`),children:n?`拒绝并暂停`:`Deny and pause`})]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`label`,{className:`block text-sm text-fg`,children:[typeof e.condition.question==`string`?e.condition.question:e.reason,(0,V.jsx)(`textarea`,{className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel p-3`,rows:3,maxLength:12e3,value:i,disabled:o||u,onChange:e=>a(e.target.value)})]}),m.length>0&&(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:m.map(e=>(0,V.jsx)(v,{type:`button`,disabled:o||u,variant:`secondary`,"aria-pressed":i===e,onClick:()=>a(e),children:e},e))}),(0,V.jsx)(v,{type:`submit`,variant:`primary`,disabled:o||u||!i.trim(),children:o?n?`正在提交`:`Submitting`:n?`提交补充信息`:`Submit answer`})]}),(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`保存到任务上下文;其他等待条件满足后继续执行。`:`Saved to task context. Work continues once all waiting conditions are met.`}),c&&(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c})]})}var Fe=e(n(),1);function Ie(e,t){let n;try{n=new URL(e)}catch{return}return t.find(e=>[e.shareUrl,e.lanUrl].some(e=>{if(!e)return!1;try{let t=new URL(e);return t.origin===n.origin&&t.pathname.replace(/\/$/,``)===n.pathname.replace(/\/$/,``)}catch{return!1}}))}function Le({uri:e,zh:t}){let[n,r]=(0,B.useState)(),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(!1),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(``);async function p(){a(!0),u(``);try{let n=Ie(e,(await D()).payload.shares);r(n),s(!0),n?n.kind!==`file`&&n.kind!==`directory`?u(t?`这是文档快照,请从原笔记或对话的分享面板重新发布。`:`This is a document snapshot. Republish it from the original note or conversation.`):n.revoked?u(t?`分享已被撤销,不能自动恢复。请从原任务重新生成并分享。`:`This share was revoked. Generate and share a new artifact from the task.`):n.maxViews!==null&&n.downloadCount>=n.maxViews?u(t?`已达到访问次数上限,请在分享设置中调整后重试。`:`The access limit was reached. Adjust it in share settings.`):n.expired||(f(n.shareUrl),u(t?`链接仍在有效期内;若打不开,请检查网关连接。`:`The link has not expired. If it cannot open, check gateway connectivity.`)):u(t?`未找到本机管理的分享记录。外部链接或已清理的记录无法在这里续期,请从原任务重新生成产物。`:`No locally managed share matches this link. Regenerate the artifact from its task.`)}catch{u(t?`检查失败,请重试。`:`Check failed. Please retry.`)}finally{a(!1)}}async function m(){if(!(!n||i)){a(!0),u(``);try{let e=await w(n.id,864e5);f(e.payload.shareUrl),r({...n,expired:!1,expiresAt:e.payload.expiresAt}),u(t?`已续期 24 小时,访问范围与次数限制保持不变。`:`Renewed for 24 hours. Access scope and view limits are unchanged.`)}catch(e){u(`${t?`恢复失败:`:`Recovery failed: `}${e instanceof Error?e.message:String(e)}`)}finally{a(!1)}}}return(0,V.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t?`链接打不开?`:`Trouble opening the link?`}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(v,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void p(),children:t?`检查链接状态`:`Check link`}),o&&n?.expired&&(n.kind===`file`||n.kind===`directory`)&&!n.revoked&&(n.maxViews===null||n.downloadCount<n.maxViews)&&(0,V.jsx)(v,{type:`button`,disabled:i,onClick:()=>void m(),children:t?`恢复链接 · 续期 24 小时`:`Restore link for 24 hours`}),l&&(0,V.jsx)(`p`,{role:`status`,className:`break-words leading-5`,children:l}),d&&(0,V.jsx)(`a`,{className:`block py-2 text-accent`,href:d,target:`_blank`,rel:`noopener noreferrer`,children:t?`打开产物`:`Open artifact`}),o&&(0,V.jsx)(c,{className:`block py-2 text-accent`,to:`/settings/shares`,children:t?`管理分享记录`:`Manage shares`})]})]})}function Re(e){let t=(0,z.c)(14),{evidence:n,projectId:r,conversationId:i,language:a}=e,o=Ae(ze);if(!n.length)return null;let s=a===`zh`?`交付物与验证依据`:`Deliverables and evidence`,c;if(t[0]!==i||t[1]!==n||t[2]!==a||t[3]!==r||t[4]!==o){let e;t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o?(e=(e,t)=>{let n=e.uri?.trim(),s=n&&/^https?:\/\//i.test(n),c=n&&!s&&e.kind===`artifact`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!n.startsWith(`//`),l=e.title||(a===`zh`?`查看产物`:`Open artifact`);return(0,V.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge-subtle p-3`,children:[s?(0,V.jsxs)(`a`,{className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:[(0,V.jsx)(ve,{className:`size-4 shrink-0`}),l]}):c&&(r||i)?(0,V.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline`,onClick:()=>o(n,null,r,i),children:[(0,V.jsx)(be,{className:`size-4 shrink-0`}),l]}):(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:l}),s&&e.kind===`artifact`&&(0,V.jsx)(Le,{uri:n,zh:a===`zh`},n),e.summary?(0,V.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:e.summary}):null,(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.strength===`verified`?a===`zh`?`已验证`:`Verified`:a===`zh`?`已记录,待验证`:`Observed, not verified`})]},`${e.title}-${t}`)},t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=e):e=t[10],c=n.map(e),t[0]=i,t[1]=n,t[2]=a,t[3]=r,t[4]=o,t[5]=c}else c=t[5];let l;return t[11]!==s||t[12]!==c?(l=(0,V.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,"aria-label":s,children:c}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function ze(e){return e.setPath}function Be(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function Ve(e,t){let n={...e.task};t.title!==void 0&&(n.title=t.title),t.priority!==void 0&&(n.priority=t.priority);for(let e of[`body`,`projectId`,`milestoneId`,`parentTaskId`,`dueAt`,`ownerId`]){let r=t[e];r!==void 0&&(r===null?delete n[e]:Object.assign(n,{[e]:r}))}return n.version+=1,n.updatedAt=Date.now(),{...e,task:n}}function He(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Ue(){let e=(0,z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,V.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,V.jsx)(y,{className:`h-32 rounded-2xl`}),(0,V.jsx)(y,{className:`h-52 rounded-2xl`}),(0,V.jsx)(y,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function We(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Ge(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var Ke=[`backlog`,`ready`,`active`,`review`,`closed`],qe=[`low`,`normal`,`high`,`critical`],Je=(0,B.memo)(function(e){let t=(0,z.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:c,onChange:d}=e,f;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(f=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=f):f=t[4];let p=f,m;t[5]===c?m=t[6]:(m=(0,V.jsx)(`span`,{children:c}),t[5]=c,t[6]=m);let h;t[7]===d?h=t[8]:(h=e=>d(e.target.value),t[7]=d,t[8]=h);let g;t[9]!==s||t[10]!==p?(g=Ke.map(e=>(0,V.jsx)(u,{value:e,disabled:p(e),children:He(e,s)},e)),t[9]=s,t[10]=p,t[11]=g):g=t[11];let _;t[12]!==r||t[13]!==h||t[14]!==g||t[15]!==n?(_=(0,V.jsx)(l,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:h,children:g}),t[12]=r,t[13]=h,t[14]=g,t[15]=n,t[16]=_):_=t[16];let ee;return t[17]!==m||t[18]!==_?(ee=(0,V.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[m,_]}),t[17]=m,t[18]=_,t[19]=ee):ee=t[19],ee}),Ye=(0,B.memo)(function(e){let t=(0,z.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,V.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=e=>o(e.target.value),t[2]=o,t[3]=c);let d;t[4]===a?d=t[5]:(d=qe.map(e=>(0,V.jsx)(u,{value:e,children:a[e]},e)),t[4]=a,t[5]=d);let f;t[6]!==r||t[7]!==c||t[8]!==d||t[9]!==n?(f=(0,V.jsx)(l,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:c,children:d}),t[6]=r,t[7]=c,t[8]=d,t[9]=n,t[10]=f):f=t[10];let p;return t[11]!==s||t[12]!==f?(p=(0,V.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,f]}),t[11]=s,t[12]=f,t[13]=p):p=t[13],p}),Xe=(0,B.memo)(function(e){let t=(0,z.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,V.jsx)(`span`,{children:i}),t[0]=i,t[1]=o);let s;t[2]!==r||t[3]!==i||t[4]!==a||t[5]!==n?(s=(0,V.jsx)(L,{disabled:r,value:n,onChange:a,ariaLabel:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,V.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}),Ze=(0,B.memo)(function(e){let t=(0,z.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,c;t[0]===i?c=t[1]:(c=(0,V.jsx)(`span`,{children:i}),t[0]=i,t[1]=c);let d;t[2]===s?d=t[3]:(d=e=>s(e.target.value),t[2]=s,t[3]=d);let f;t[4]===a?f=t[5]:(f=(0,V.jsx)(u,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=f);let p;t[6]===o?p=t[7]:(p=o.map(ht),t[6]=o,t[7]=p);let m;t[8]!==r||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==n?(m=(0,V.jsxs)(l,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:d,children:[f,p]}),t[8]=r,t[9]=d,t[10]=f,t[11]=p,t[12]=n,t[13]=m):m=t[13];let h;return t[14]!==c||t[15]!==m?(h=(0,V.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[c,m]}),t[14]=c,t[15]=m,t[16]=h):h=t[16],h}),Qe=(0,B.memo)(function(e){let t=(0,z.c)(9),{candidates:n,selected:r,disabled:i,labels:a,getTaskHref:o,onChange:s}=e,c;t[0]===r?c=t[1]:(c=r.map(gt),t[0]=r,t[1]=c);let l;return t[2]!==n||t[3]!==i||t[4]!==o||t[5]!==a||t[6]!==s||t[7]!==c?(l=(0,V.jsx)(R,{borderless:!0,candidates:n,selectedIds:c,disabled:i,getTaskHref:o,onChange:s,labels:a}),t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=c,t[8]=l):l=t[8],l},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&e.getTaskHref===t.getTaskHref&&e.onChange===t.onChange&&e.candidates.length===t.candidates.length&&e.candidates.every((e,n)=>e.id===t.candidates[n]?.id&&e.title===t.candidates[n]?.title)&&e.selected.length===t.selected.length&&e.selected.every((e,n)=>e.id===t.selected[n]?.id&&e.title===t.selected[n]?.title)),$e=`xopc.taskDetail.chatPanelPercent`,et=42;function tt(e,t){let n=Math.max(30,352/Math.max(t,1)*100),r=Math.min(60,(t-480)/Math.max(t,1)*100);return r<n?et:Math.min(r,Math.max(n,e))}function nt(){try{let e=Number(window.localStorage.getItem($e));return Number.isFinite(e)&&e>=30&&e<=60?e:et}catch{return et}}function rt(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.waits.some(e=>e.kind===`paused`)?`paused`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`ready`:e.operationalState}function it(e){return e===`needsUser`||e===`blocked`?`bg-warning/10 text-warning`:e===`completed`?`bg-success-soft text-success`:e===`running`||e===`verifying`||e===`review`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-muted`}function H(e){let t=(0,z.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,V.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let a;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>{let t=i?.get(e)??`unverified`;return(0,V.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,V.jsx)(t===`passed`?d:t===`failed`?de:E,{className:t===`passed`?`mt-1 size-4 shrink-0 text-success`:t===`failed`?`mt-1 size-4 shrink-0 text-danger`:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,V.jsx)(`span`,{children:e})]},e)},t[5]=i,t[6]=e),a=n.map(e),t[2]=n,t[3]=i,t[4]=a}else a=t[4];let o;return t[7]===a?o=t[8]:(o=(0,V.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function at({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[i]=o(),s=a(),l=ee(e=>e.language),u=_(e=>e.conversationId),h=(0,B.useMemo)(()=>xe(l),[l]),te=ce(e=>e.setPageHeader),ne=ce(e=>e.clearPageHeader),re=A(e=>e.open),ie=A(e=>e.conversationIdOverride),ae=A(e=>e.openForSession),oe=Se(e=>e.setOpen),{data:y,error:de,mutate:S,lastChange:w,conversationLoading:E,conversationError:D}=ue(e),[N,be]=(0,B.useState)(null),[Ae,L]=(0,B.useState)(null),[R,z]=(0,B.useState)(()=>new Set),[Ie,Le]=(0,B.useState)([]),[ze,He]=(0,B.useState)(null),[Ke,qe]=(0,B.useState)([]),[at,U]=(0,B.useState)(!1),[ot,st]=(0,B.useState)(``),[ct,W]=(0,B.useState)(!1),[lt,ut]=(0,B.useState)(``),[G,dt]=(0,B.useState)(nt),[ft,pt]=(0,B.useState)(!1),mt=(0,B.useRef)(null),ht=(0,B.useRef)(!1),gt=(0,B.useRef)(!1),_t=(0,B.useRef)(``),vt=(0,B.useRef)(null),yt=(0,B.useRef)(null),bt=(0,B.useRef)(null),xt=(0,B.useRef)(y),[St,K]=(0,B.useState)(null),[Ct,wt]=(0,B.useState)(null),[Tt,Et]=(0,B.useState)(!1),Dt=(0,B.useMemo)(()=>({link:h.linkDependencies,linked:h.linkedDependencies,searchPlaceholder:h.dependencySearchPlaceholder,noMatches:h.noDependencyMatches,noCandidates:h.noDependencyCandidates,remove:h.removeDependency}),[h.dependencySearchPlaceholder,h.linkDependencies,h.linkedDependencies,h.noDependencyCandidates,h.noDependencyMatches,h.removeDependency]),Ot=y?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,kt=(0,B.useMemo)(()=>f(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]),At=(0,B.useCallback)(e=>t===`modal`&&n?b(n,e):p(`/tasks/${encodeURIComponent(e)}`,kt),[n,t,kt]);xt.current=y;let q=(0,B.useCallback)((e,t)=>{z(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,B.useEffect)(()=>{L(null),K(null),U(!1),W(!1),wt(null),Et(!1)},[e]),(0,B.useEffect)(()=>{let e=!0;return je().then(t=>{e&&qe(t.items)}).catch(()=>void 0),()=>{e=!1}},[u]),(0,B.useEffect)(()=>{if(!w||w.source===`user`)return;wt(w);let e=window.setTimeout(()=>wt(null),3500);return()=>window.clearTimeout(e)},[w]),(0,B.useEffect)(()=>{let t=y?.task.projectId,n=y?.dependencies??[];if(!t){bt.current=null,He(null),Le(n);return}bt.current!==t&&(bt.current=t,He(null));let r=!0;return _e(t).then(t=>{if(!r)return;He(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});Le([...i.values()])}).catch(()=>{r&&Le(n)}),()=>{r=!1}},[Ot,y?.task.projectId,e]);let J=(0,B.useCallback)(async(t,n=`command`)=>{let r=xt.current;if(r){q(n,!0),L(null);try{await S(await k(e,t,r.task.version),{revalidate:!1})}catch{L(h.actionFailed)}finally{q(n,!1)}}},[h.actionFailed,S,q,e]),Y=(0,B.useCallback)(async(t,n)=>{let r=xt.current;if(!r)return!1;n&&q(n,!0),L(null);try{return await S(pe(e,t,r.task.version),{optimisticData:Ve(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return L(h.actionFailed),!1}finally{n&&q(n,!1)}},[h.actionFailed,S,q,e]),jt=async()=>{if(!y)return;if(ht.current){ht.current=!1;return}let e=ot.trim(),t=vt.current;if(Be(t,y.task.version,y.task.title,e)){K(`title`);return}if(!e||e===y.task.title){st(y.task.title),U(!1);return}await Y({title:e})&&(K(null),U(!1))},Mt=async()=>{if(!y)return;if(gt.current){gt.current=!1;return}let e=lt.trim(),t=yt.current;if(Be(t,y.task.version,y.task.body??``,e)){K(`description`);return}if(lt===_t.current||e===(y.task.body??``).trim()){W(!1);return}await Y({body:e||null})&&(K(null),W(!1))},Nt=(0,B.useCallback)(async e=>{let t=xt.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await J({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await J({type:`close`,resolution:`done`},`phase`);return}await J({type:`move`,phase:e},`phase`)}},[J]),Pt=(0,B.useCallback)(e=>{Y({priority:e},`priority`)},[Y]),Ft=(0,B.useCallback)(e=>{Y({dueAt:Ge(e)},`dueAt`)},[Y]),It=(0,B.useCallback)(e=>{dt(e);try{window.localStorage.setItem($e,String(e))}catch{}},[]),Lt=(0,B.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=mt.current?.clientWidth??0;It(tt(e.key===`Home`?et:G+(e.key===`ArrowLeft`?2:-2),t))},[G,It]),Rt=(0,B.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=mt.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),pt(!0);let i=G,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=tt((n.right-e.clientX)/n.width*100,n.width),a===0&&(a=window.requestAnimationFrame(o))},c=()=>{a!==0&&(window.cancelAnimationFrame(a),o());try{n.releasePointerCapture(r)}catch{}pt(!1),It(i),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[G,It]),zt=(0,B.useCallback)(async t=>{let n=xt.current;if(n){q(`dependencies`,!0),L(null);try{await S(await M(e,t,n.task.version),{revalidate:!1})}catch{L(h.dependencyUpdateFailed)}finally{q(`dependencies`,!1)}}},[h.dependencyUpdateFailed,S,q,e]),Bt=(0,B.useCallback)(async t=>{let n=xt.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){q(`delegateAgentId`,!0),L(null);try{await S(await j(e,t,n.task.version),{revalidate:!1})}catch{L(h.actionFailed)}finally{q(`delegateAgentId`,!1)}}},[h.actionFailed,S,q,e]),Vt=(0,B.useCallback)(async()=>{q(`delete`,!0),L(null);try{await x(e),r?r():s(kt,{replace:!0})}catch(e){L(e instanceof Error?e.message:h.actionFailed)}finally{q(`delete`,!1)}},[h.actionFailed,s,r,kt,q,e]);if((0,B.useLayoutEffect)(()=>{if(t!==`modal`)return te({startExtra:(0,V.jsx)(c,{to:kt,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":h.backToWork,children:(0,V.jsx)(ye,{className:`size-4`})}),main:y?(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:ze?`${ze} / ${h.taskLabel}`:h.taskLabel}),(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:h.detailStatuses[rt(y)]})]}):null,end:(0,V.jsx)(`div`,{ref:be,className:`flex min-w-0 items-center justify-end`})}),ne},[ne,h.backToWork,h.detailStatuses,h.taskLabel,y,t,ze,kt,te]),de&&!y)return(0,V.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:h.taskNotFound});if(!y)return(0,V.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,V.jsx)(Ue,{})});let Ht=y.waits[0],Ut=y.waits.find(e=>e.kind===`paused`),X=y.receipts[0],Wt=rt(y),Gt=h.detailStatuses[Wt],Kt=y.task.body?.trim()||y.task.contract?.objective.trim(),qt=y.runs.find(e=>e.id===X?.runId)?.contractVersion===y.task.latestContractVersion?X:void 0,Jt=se(qt),Yt=new Map(qt?.verification.checks.map(e=>[e.criterion,e.status===`passed`&&!Jt.has(e.criterion)?`unverified`:e.status])),Xt=y.allowedCommands.includes(`mark_ready`),Zt=y.allowedCommands.includes(`start`),Qt=y.allowedCommands.includes(`add_wait`),$t=!Ht&&y.task.phase===`review`&&y.allowedCommands.includes(`close`),en=y.allowedCommands.includes(`reopen`),Z=y.conversation.activeConversationId,tn=y.conversation.currentExecutorAgentId??y.task.delegateAgentId??y.task.ownerId,nn=Ke.find(e=>e.id===tn),rn=!!(Z&&re&&ie===Z),an=y.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),on=y.task.contract?.acceptanceCriteria??[],sn=on.filter(e=>Yt.get(e)===`passed`).length,cn=y.task.contract?.expectedOutputs??[],ln=y.task.contract?.constraints??[],un=y.task.contract?.approvalRequired??[],dn=y.task.contract?.assumptions??[],fn=y.task.contract?.risks??[],Q=(...e)=>!!Ct?.changedFields.some(t=>e.includes(t)),pn=y.allowedCommands.includes(`move`),$=R.has(`command`),mn=R.has(`delete`),hn=y.runs.find(e=>!e.parentRunId&&[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),gn=hn!==void 0,_n=(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Xt?(0,V.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`mark_ready`}),children:[(0,V.jsx)(F,{className:`size-4`}),h.scheduleTask]}):null,Ut&&y.allowedCommands.includes(`resolve_wait`)?(0,V.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`resolve_wait`,waitId:Ut.id}),children:[(0,V.jsx)(F,{className:`size-4`}),h.resumeTask]}):null,!Ht&&Zt&&tn?(0,V.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`start`,executor:{kind:`agent`,agentId:tn}}),children:[(0,V.jsx)(F,{className:`size-4`}),h.runTask]}):null,$t?(0,V.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`close`,resolution:`done`}),children:[(0,V.jsx)(d,{className:`size-4`}),h.approveTask]}):null,en?(0,V.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`reopen`,phase:`ready`}),children:[(0,V.jsx)(F,{className:`size-4`}),h.reopenTask]}):null,!Ut&&Qt?(0,V.jsxs)(v,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:$,onClick:()=>void J({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,V.jsx)(Ee,{className:`size-4`}),h.pauseTask]}):null,(0,V.jsxs)(me,{children:[(0,V.jsx)(Me,{asChild:!0,children:(0,V.jsx)(v,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$||mn,"aria-label":h.moreActions,children:(0,V.jsx)(ke,{className:`size-4`,"aria-hidden":!0})})}),(0,V.jsx)(fe,{children:(0,V.jsxs)(T,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[hn?(0,V.jsx)(le,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{q(`command`,!0),L(null),S(C(e,hn.id,hn.version),{revalidate:!1}).catch(()=>L(h.actionFailed)).finally(()=>q(`command`,!1))},children:h.cancelActiveRun}):null,hn?(0,V.jsx)(O,{className:`my-1 h-px bg-edge`}):null,y.task.phase===`closed`?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(le,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void J({type:`close`,resolution:`cancelled`}),children:h.cancelTask}),(0,V.jsx)(O,{className:`my-1 h-px bg-edge`})]}),(0,V.jsx)(le,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{if(gn){L(h.deleteActiveTaskBlocked);return}Et(!0)},children:h.deleteTask})]})})]})]}),vn=(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,V.jsx)(Ne,{resource:{kind:`task`,id:y.task.id,revision:String(y.task.version)},disabled:at||ct||R.size>0}),_n,Z&&t!==`modal`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(v,{type:`button`,variant:`ghost`,className:g(`h-8 shrink-0 px-2 text-xs`,rn&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":rn,onClick:()=>{oe(Z,!1),ae(Z)},children:[(0,V.jsx)(we,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,V.jsx)(v,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,V.jsxs)(c,{to:he(e),children:[(0,V.jsx)(ve,{className:`size-3.5`}),l===`zh`?`全屏`:`Full screen`]})})]}):null]});return(0,V.jsxs)(`div`,{ref:mt,className:`${t===`modal`?`flex h-full min-h-0 flex-col lg:flex-row`:`flex min-h-[calc(100dvh-8rem)] flex-col overflow-hidden lg:flex-row`} ${ft?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${G}%`},children:[t===`page`&&N?(0,Fe.createPortal)(vn,N):null,(0,V.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,V.jsxs)(`header`,{className:g(`px-4 pb-5`,Q(`title`)&&`task-detail-live-update`),children:[(0,V.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[ze?(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(Oe,{className:`size-3.5`,"aria-hidden":!0}),ze]}):null,(0,V.jsx)(`span`,{children:`/`}),(0,V.jsx)(`span`,{children:h.taskLabel}),(0,V.jsx)(`span`,{className:g(`rounded-full px-2 py-0.5 text-[11px] font-medium`,it(Wt)),children:Gt}),(0,V.jsx)(`span`,{className:`text-fg-subtle`,children:h.updatedAt.replace(`{{date}}`,P(y.task.updatedAt,l))}),Ct?(0,V.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:Ct.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),at?(0,V.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:ot,onChange:e=>st(e.target.value),onBlur:()=>void jt(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ht.current=!0,st(y.task.title),U(!1),queueMicrotask(()=>{ht.current=!1}))},className:`mt-3 w-full max-w-3xl rounded-lg bg-surface-hover px-3 py-2 text-2xl font-semibold leading-8 text-fg outline-none ring-2 ring-accent/30 focus:ring-accent/60`}):(0,V.jsx)(`button`,{type:`button`,className:`mt-3 block max-w-3xl rounded-lg text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{vt.current={value:y.task.title,version:y.task.version},K(null),st(y.task.title),U(!0)},children:(0,V.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:y.task.title})}),St===`title`?(0,V.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,V.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{st(y.task.title),K(null),U(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({title:ot.trim()}).then(e=>{e&&(K(null),U(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),Ae?(0,V.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:Ae}):null]}),y.attention.length>0?(0,V.jsxs)(`section`,{className:g(`mb-4 rounded-xl border border-warning/20 bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:an?h.needsAttention:h.waitingStatus}),(0,V.jsx)(`ul`,{className:`mt-2 space-y-1.5 text-sm leading-6 text-fg-muted`,children:y.attention.map((t,n)=>(0,V.jsxs)(`li`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1`,children:t.summary}),t.kind===`input_required`||t.kind===`approval_required`?(0,V.jsx)(c,{className:`inline-flex min-h-11 items-center rounded-lg bg-surface-panel px-3 text-sm font-medium text-accent`,to:he(e),children:l===`zh`?t.kind===`approval_required`?`查看并决定`:`补充信息`:t.kind===`approval_required`?`Review decision`:`Provide information`}):null]},`${t.kind}-${n}`))})]}):null,y.task.phase!==`closed`&&!Ut&&y.waits.filter(e=>(e.kind===`user_input`||e.kind===`approval`&&typeof e.condition.capability==`string`)&&e.condition.type!==`connection`).map(e=>(0,V.jsx)(Pe,{wait:e,detail:y,zh:l===`zh`,onUpdated:e=>{S(e,{revalidate:!1})}},e.id)),(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsxs)(`main`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,V.jsxs)(`section`,{className:g(`p-5`,Q(`body`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.taskDescription}),ct?(0,V.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:lt,onChange:e=>ut(e.target.value),onBlur:()=>void Mt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),gt.current=!0,ut(y.task.body??y.task.contract?.objective??``),W(!1),queueMicrotask(()=>{gt.current=!1}))},className:`mt-3 w-full resize-y rounded-lg bg-surface-hover px-3 py-2 text-sm leading-6 text-fg outline-none ring-2 ring-accent/20 focus:ring-accent/50`}):(0,V.jsx)(`button`,{type:`button`,className:`-mx-1 mt-2 block w-[calc(100%+0.5rem)] rounded-lg px-1 py-1 text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=y.task.body??y.task.contract?.objective??``;_t.current=e,yt.current={value:y.task.body??``,version:y.task.version},K(null),ut(e),W(!0)},children:(0,V.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:Kt&&Kt!==y.task.title?Kt:h.noTaskDescription})}),St===`description`?(0,V.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,V.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{ut(y.task.body??``),K(null),W(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,V.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({body:lt.trim()||null}).then(e=>{e&&(K(null),W(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),(0,V.jsxs)(`section`,{className:g(`p-5`,Q(`contract`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.taskDefinition}),(0,V.jsxs)(`div`,{className:`mt-5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:h.successDefinition}),on.length>0?(0,V.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:h.criteriaProgress.replace(`{{verified}}`,String(sn)).replace(`{{total}}`,String(on.length))}):null]}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(H,{items:on,empty:h.noDefinition,verificationByCriterion:Yt})})]}),cn.length>0?(0,V.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-5`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:h.expectedOutputs}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(H,{items:cn,empty:h.noDefinition})})]}):null,ln.length>0?(0,V.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:h.constraints}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(H,{items:ln,empty:h.noDefinition})})]}):null,un.length>0?(0,V.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:h.approvalRequired}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(H,{items:un,empty:h.noDefinition})})]}):null,dn.length>0?(0,V.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:h.contextAssumptions}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(H,{items:dn,empty:h.noDefinition})})]}):null,fn.length>0?(0,V.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:h.contextRisks}),(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(H,{items:fn,empty:h.noDefinition})})]}):null]}),X?(0,V.jsxs)(`section`,{className:g(`p-5`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.latestResult}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l===`zh`?X.completionVerdict===`achieved`?`本次执行报告目标已达成,请结合下方验证依据验收。`:`这是阶段性结果,尚不能代表任务全部完成。`:X.completionVerdict===`achieved`?`The run reports the goal achieved. Review the evidence below.`:`This is a partial result; the task is not yet fully complete.`}),(0,V.jsx)(m,{content:X.summary,compact:!0,className:`mt-2 text-sm leading-6 text-fg`})]}),(0,V.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[h.receiptStatuses[X.status],` · `,h.verificationStatuses[X.verification.status]]})]}),X.remainingWork.length>0?(0,V.jsxs)(`div`,{className:`mt-4`,children:[(0,V.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:h.remainingWork}),(0,V.jsx)(`div`,{className:`mt-2`,children:(0,V.jsx)(H,{items:X.remainingWork,empty:h.noRemainingWork})})]}):null,X.nextAction?(0,V.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:h.nextAction}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:X.nextAction})]}):null,(0,V.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(v,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void Te(X.runId,`helpful`),children:h.doneWell}),(0,V.jsx)(v,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void Te(X.runId,`not_helpful`),children:h.needsFix})]}),(0,V.jsx)(Re,{evidence:X.evidence,projectId:y.task.projectId,conversationId:Z??void 0,language:l}),y.receipts.length>1?(0,V.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:h.executionHistory.replace(`{{count}}`,String(y.receipts.length-1))}),(0,V.jsx)(`div`,{className:`mt-3 space-y-3`,children:y.receipts.slice(1).map(e=>(0,V.jsx)(`article`,{className:`rounded-lg bg-surface-hover p-3`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,V.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:h.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,y.context.length>0?(0,V.jsxs)(`section`,{className:g(`p-5`,Q(`context`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.contextUsed}),(0,V.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:y.context.map(e=>(0,V.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,V.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[h.contextRoleLabels[e.role],` · `,h.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,V.jsx)(`a`,{className:`mt-1 block break-all text-sm text-accent hover:underline`,href:e.targetId,target:`_blank`,rel:`noreferrer`,children:e.title??e.targetId}):(0,V.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,V.jsxs)(`aside`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,V.jsxs)(`section`,{className:g(`p-5`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.taskProperties}),(0,V.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(Je,{value:y.task.phase,disabled:R.has(`phase`),canMove:pn,canApprove:$t,canReopen:en,language:l,label:h.taskPhase,onChange:Nt}),(0,V.jsx)(Ye,{value:y.task.priority,disabled:R.has(`priority`),label:h.priority,labels:h.priorityLabels,onChange:Pt}),(0,V.jsx)(Xe,{value:We(y.task.dueAt),disabled:R.has(`dueAt`),label:h.dueDate,onChange:Ft}),(0,V.jsx)(Ze,{value:y.conversation.currentExecutorAgentId??``,disabled:R.has(`delegateAgentId`),label:h.executorLabel,unassignedLabel:h.unassigned,agents:Ke,onChange:Bt})]})]}),(0,V.jsxs)(`section`,{className:g(`p-5`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,V.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.taskRelations}),(0,V.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:h.dependencies}),(0,V.jsx)(Qe,{candidates:Ie,selected:y.dependencies,disabled:R.has(`dependencies`),labels:Dt,getTaskHref:At,onChange:zt})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:h.dependents}),y.dependents.length>0?(0,V.jsx)(`div`,{className:`space-y-1.5`,children:y.dependents.map(e=>(0,V.jsx)(c,{to:At(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-fg-muted transition-colors hover:text-fg`,children:e.title},e.id))}):(0,V.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:h.noDependents})]})]})]})]})]})]}),(0,V.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":l===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(G),tabIndex:0,onPointerDown:Rt,onKeyDown:Lt,onDoubleClick:()=>It(et),className:`group hidden w-2 shrink-0 cursor-col-resize touch-none items-stretch justify-center bg-surface-panel outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover lg:flex ${ft?`bg-surface-hover`:``}`,children:(0,V.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,V.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 flex-col bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:shrink-0`,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-inset px-4 py-3.5`,children:[(0,V.jsx)(`div`,{className:`min-w-0`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[tn?(0,V.jsx)(ge,{agentId:tn,avatar:nn?.avatar,size:28,className:`shrink-0`}):null,(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:l===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,V.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[nn?.name??tn??h.unassigned,` · `,Gt]})]})]})}),t===`modal`?vn:null]}),Z?(0,V.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,V.jsx)(Ce,{embedded:!0,conversationId:Z,taskId:e})}):E?(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,V.jsxs)(`div`,{className:`max-w-xs`,children:[(0,V.jsx)(I,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,V.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):D?(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,V.jsxs)(`div`,{className:`max-w-xs`,children:[(0,V.jsx)(I,{className:`mx-auto size-8 text-danger`}),(0,V.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,V.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:D instanceof Error?D.message:String(D)})]})}):(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,V.jsxs)(`div`,{className:`max-w-xs`,children:[(0,V.jsx)(I,{className:`mx-auto size-8 text-fg-subtle`}),(0,V.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,V.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:l===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]}),(0,V.jsx)(De,{open:Tt,title:h.deleteTaskTitle,description:h.deleteTaskDescription.replace(`{{title}}`,y.task.title),confirmLabel:h.confirmDeleteTask,cancelLabel:h.keepTask,destructive:!0,onConfirm:()=>{Et(!1),Vt()},onCancel:()=>Et(!1)})]})}function U(){let e=(0,z.c)(2),{taskId:t}=s(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,V.jsx)(at,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function ot(e){let t=(0,z.c)(58),{taskId:n,backgroundPath:r,onClose:i}=e,a=ee(mt),{data:o}=ue(n),s=o?.conversation.activeConversationId??null,l=A(pt),u=A(ft),d=A(dt),f=A(G),p=Se(ut),m=Ae(lt),_=Ae(W),se=l?u:0,v;t[0]!==i||t[1]!==_?(v=e=>{e||(_(null),i())},t[0]=i,t[1]=_,t[2]=v):v=t[2];let y=a===`zh`?`关闭任务详情`:`Close task details`,b;t[3]!==i||t[4]!==_?(b=()=>{_(null),i()},t[3]=i,t[4]=_,t[5]=b):b=t[5];let x;t[6]!==y||t[7]!==b?(x=(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":y,onClick:b}),t[6]=y,t[7]=b,t[8]=x):x=t[8];let ce=l?`true`:`false`,le=`${se/2}px`,de=`${se}px`,fe;t[9]!==le||t[10]!==de?(fe={"--task-detail-workspace-offset":le,"--task-detail-workspace-width":de},t[9]=le,t[10]=de,t[11]=fe):fe=t[11];let pe=fe,me=a===`zh`?`任务详情`:`Task details`,C;t[12]===me?C=t[13]:(C=(0,V.jsx)(ae,{className:`font-medium text-fg`,children:me}),t[12]=me,t[13]=C);let w=a===`zh`?`查看并操作任务详情`:`View and manage task details`,T;t[14]===w?T=t[15]:(T=(0,V.jsx)(te,{className:`sr-only`,children:w}),t[14]=w,t[15]=T);let E;t[16]!==s||t[17]!==a||t[18]!==f||t[19]!==p||t[20]!==n||t[21]!==d||t[22]!==l?(E=s?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:g(`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,l&&d===s&&`bg-surface-hover text-fg`),"aria-label":a===`zh`?`项目文件`:`Project files`,title:a===`zh`?`项目文件`:`Project files`,"aria-pressed":l&&d===s,onClick:()=>{p(s,!1),f(s)},children:(0,V.jsx)(we,{className:`size-4`,"aria-hidden":!0})}),(0,V.jsx)(c,{to:he(n),className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a===`zh`?`全屏打开对话`:`Open chat full screen`,title:a===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,V.jsx)(ve,{className:`size-4`,"aria-hidden":!0})})]}):null,t[16]=s,t[17]=a,t[18]=f,t[19]=p,t[20]=n,t[21]=d,t[22]=l,t[23]=E):E=t[23];let ge=a===`zh`?`关闭任务详情`:`Close task details`,D;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,V.jsx)(h,{className:`size-4`,"aria-hidden":!0}),t[24]=D):D=t[24];let O;t[25]===ge?O=t[26]:(O=(0,V.jsx)(ne,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":ge,children:D}),t[25]=ge,t[26]=O);let k;t[27]!==E||t[28]!==O?(k=(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[E,O]}),t[27]=E,t[28]=O,t[29]=k):k=t[29];let _e;t[30]!==C||t[31]!==T||t[32]!==k?(_e=(0,V.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[C,T,k]}),t[30]=C,t[31]=T,t[32]=k,t[33]=_e):_e=t[33];let j;t[34]!==i||t[35]!==_?(j=()=>{_(null),i()},t[34]=i,t[35]=_,t[36]=j):j=t[36];let M;t[37]!==r||t[38]!==j||t[39]!==n?(M=(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,V.jsx)(at,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:j})}),t[37]=r,t[38]=j,t[39]=n,t[40]=M):M=t[40];let N;t[41]!==_e||t[42]!==M||t[43]!==ce||t[44]!==pe?(N=(0,V.jsxs)(ie,{className:`xopc-dialog-content task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,"data-workspace-panel-open":ce,style:pe,onEscapeKeyDown:ct,onInteractOutside:st,children:[_e,M]}),t[41]=_e,t[42]=M,t[43]=ce,t[44]=pe,t[45]=N):N=t[45];let P;t[46]!==m||t[47]!==d||t[48]!==l||t[49]!==u?(P=m?(0,V.jsx)(`div`,{className:`fixed inset-y-0 left-0 z-[100] flex min-h-0 min-w-0 overflow-hidden bg-surface-panel transition-[right] duration-200 ease-out motion-reduce:transition-none`,style:{right:l?u:0},children:(0,V.jsx)(S,{allowOutsideChat:!0,conversationId:d??void 0})}):null,t[46]=m,t[47]=d,t[48]=l,t[49]=u,t[50]=P):P=t[50];let F;t[51]!==N||t[52]!==P||t[53]!==x?(F=(0,V.jsxs)(re,{children:[x,N,P]}),t[51]=N,t[52]=P,t[53]=x,t[54]=F):F=t[54];let I;return t[55]!==v||t[56]!==F?(I=(0,V.jsx)(oe,{modal:!1,open:!0,onOpenChange:v,children:F}),t[55]=v,t[56]=F,t[57]=I):I=t[57],I}function st(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function ct(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function W(e){return e.setPath}function lt(e){return e.path}function ut(e){return e.setOpen}function G(e){return e.openForSession}function dt(e){return e.conversationIdOverride}function ft(e){return e.widthPx}function pt(e){return e.open}function mt(e){return e.language}function ht(e){return(0,V.jsx)(u,{value:e.id,children:e.name||e.id},e.id)}function gt(e){return e.id}export{ot as TaskDetailModal,U as TaskDetailPage};
@@ -1,2 +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{g as i,u as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./check-DUBLcKHA.js";import{n as s,r as c,t as l}from"./popover-select-B-GDnZO9.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./plus-Q2yW6OE7.js";import{t as f}from"./x-B_N4OPjy.js";import{t as p}from"./cn-JdwAhgNB.js";import{n as m}from"./locale-store-C4RjTd0C.js";import{a as h,c as g,i as _,n as v,o as y,r as b,s as ee,t as x}from"./dist-BGTk37IG.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{t as C}from"./button-CS04eWY9.js";import{t as w}from"./skeleton-BwbyijEw.js";import{Au as T,Bo as E,Co as D,Dc as O,Fn as k,Gu as A,Hu as j,In as M,J as N,Ju as P,Ku as F,Ln as I,Ol as L,Pn as R,Rc as z,Sl as B,Tl as V,Uc as H,Uu as U,Vl as W,Yu as G,at as K,bc as q,bl as te,cc as ne,ct as re,dt as ie,eu as ae,ft as oe,it as se,lt as ce,nu as le,ot as ue,ou as de,pc as J,pt as fe,pu as Y,rt as pe,sc as me,st as he,td as ge,tl as _e,ut as ve,vu as ye,wu as be,xl as xe,xu as Se,zn as Ce}from"./index-u4709aCa.js";import{t as we}from"./page-tabs-q6lpN9OD.js";import{t as Te}from"./date-picker-DBD5yedi.js";var X=e(t(),1),Z=n(),Q=r();function Ee(e){let t=(0,Z.c)(15),{sourceId:n,disabled:r}=e,i=r===void 0?!1:r,a=m(ke)===`zh`,{sources:o,starting:s,start:c}=N(),l;t[0]!==n||t[1]!==o?(l=n?o.filter(e=>e.grantId===n):o,t[0]=n,t[1]=o,t[2]=l):l=t[2];let u=l,d;t[3]===u?d=t[4]:(d=u.some(Oe),t[3]=u,t[4]=d);let f=d,p=n&&u.some(De),h=f?a?`更新中`:`Updating`:p?a?`重试`:`Retry`:n?a?`更新理解`:`Update understanding`:a?`更新全部`:`Update all`,g=i||s||f,_;t[5]!==n||t[6]!==c?(_=()=>void c(n),t[5]=n,t[6]=c,t[7]=_):_=t[7];let v;t[8]===f?v=t[9]:(v=f?(0,Q.jsx)(V,{className:`size-3.5 animate-spin motion-reduce:animate-none`}):(0,Q.jsx)(H,{className:`size-3.5`}),t[8]=f,t[9]=v);let y;return t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==v?(y=(0,Q.jsxs)(C,{variant:`ghost`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs`,disabled:g,onClick:_,children:[v,h]}),t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y):y=t[14],y}function De(e){return e.status===`failed`||e.status===`partial`||e.status===`canceled`}function Oe(e){return e.status===`queued`||e.status===`running`}function ke(e){return e.language}function Ae(e){let t=(0,Z.c)(22),{sourceId:n,lastCollectedAt:r}=e,i=m(je),a=i===`zh`,o;t[0]===n?o=t[1]:(o=e=>e.sources.find(e=>e.grantId===n),t[0]=n,t[1]=o);let s=N(o);if(!s){let e;t[2]!==i||t[3]!==r||t[4]!==a?(e=r?`${a?`上次更新:`:`Last updated: `}${new Date(r).toLocaleString(i)}`:a?`尚未分析`:`Not analyzed yet`,t[2]=i,t[3]=r,t[4]=a,t[5]=e):e=t[5];let n;return t[6]===e?n=t[7]:(n=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e}),t[6]=e,t[7]=n),n}let c;t[8]===a?c=t[9]:(c=a?{queued:`等待更新`,waiting_desktop:`等待桌面端读取资料`,reading:`正在读取资料`,analyzing:`正在更新理解`}:{queued:`Queued`,waiting_desktop:`Waiting for desktop collection`,reading:`Reading source`,analyzing:`Updating understanding`},t[8]=a,t[9]=c);let l=c,u=s.status===`running`||s.status===`queued`,d=s.status===`failed`||s.status===`partial`||s.status===`canceled`,f=s.metadata.added,p=u?l[s.metadata.phase??`queued`]??l.queued:d?a?`更新未完成,可重试`:`Update incomplete; retry available`:f===0?a?`更新完成,暂无新增理解`:`Updated; no new understanding`:f===void 0?a?`更新完成`:`Updated`:a?`更新完成,新增 ${f} 条`:`Updated; ${f} added`,h;t[10]===p?h=t[11]:(h=(0,Q.jsx)(`p`,{children:p}),t[10]=p,t[11]=h);let g;t[12]!==i||t[13]!==s.completedAt?(g=s.completedAt?(0,Q.jsx)(`p`,{children:new Date(s.completedAt).toLocaleString(i)}):null,t[12]=i,t[13]=s.completedAt,t[14]=g):g=t[14];let _;t[15]!==d||t[16]!==s.errorMessage?(_=d&&s.errorMessage?(0,Q.jsx)(`p`,{className:`text-danger`,children:s.errorMessage}):null,t[15]=d,t[16]=s.errorMessage,t[17]=_):_=t[17];let v;return t[18]!==h||t[19]!==g||t[20]!==_?(v=(0,Q.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,"aria-live":`polite`,children:[h,g,_]}),t[18]=h,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function je(e){return e.language}function Me(e){let t=(0,Z.c)(49),{language:n,busy:r,statement:i,onEdit:a,onDelete:o}=e,[s,c]=(0,X.useState)(!1),l=n===`zh`,u=l?`修改或删除这条内容`:`Edit or delete this item`,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(ye,{className:`size-4`,"aria-hidden":`true`}),t[0]=d):d=t[0];let f;t[1]!==r||t[2]!==u?(f=(0,Q.jsx)(Ce,{asChild:!0,children:(0,Q.jsx)(C,{variant:`ghost`,className:`size-11 shrink-0 p-0`,disabled:r,"aria-label":u,children:d})}),t[1]=r,t[2]=u,t[3]=f):f=t[3];let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(_e,{className:`size-4`,"aria-hidden":`true`}),t[4]=p):p=t[4];let m=l?`修改`:`Edit`,g;t[5]!==r||t[6]!==a||t[7]!==m?(g=(0,Q.jsxs)(k,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:a,children:[p,m]}),t[5]=r,t[6]=a,t[7]=m,t[8]=g):g=t[8];let S,w;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>c(!0),w=(0,Q.jsx)(J,{className:`size-4`,"aria-hidden":`true`}),t[9]=S,t[10]=w):(S=t[9],w=t[10]);let T=l?`删除`:`Delete`,E;t[11]!==r||t[12]!==T?(E=(0,Q.jsxs)(k,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:S,children:[w,T]}),t[11]=r,t[12]=T,t[13]=E):E=t[13];let D;t[14]!==E||t[15]!==g?(D=(0,Q.jsx)(M,{children:(0,Q.jsxs)(R,{align:`end`,sideOffset:4,className:`z-[100] min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[g,E]})}),t[14]=E,t[15]=g,t[16]=D):D=t[16];let O;t[17]!==D||t[18]!==f?(O=(0,Q.jsxs)(I,{modal:!1,children:[f,D]}),t[17]=D,t[18]=f,t[19]=O):O=t[19];let A;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(h,{className:`fixed inset-0 z-[110] bg-scrim`}),t[20]=A):A=t[20];let j=l?`删除这条内容?`:`Delete this item?`,N;t[21]===j?N=t[22]:(N=(0,Q.jsx)(ee,{className:`font-semibold text-fg`,children:j}),t[21]=j,t[22]=N);let P=l?`删除后将不再使用这条记忆,原始对话和文件会保留。`:`This memory will no longer be used. Original conversations and files are kept.`,F;t[23]===P?F=t[24]:(F=(0,Q.jsx)(_,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:P}),t[23]=P,t[24]=F);let L;t[25]!==N||t[26]!==F?(L=(0,Q.jsxs)(`header`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[N,F]}),t[25]=N,t[26]=F,t[27]=L):L=t[27];let z;t[28]===i?z=t[29]:(z=(0,Q.jsx)(`p`,{className:`min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap break-words px-5 py-4 text-sm leading-6 text-fg`,children:i}),t[28]=i,t[29]=z);let B=l?`取消`:`Cancel`,V;t[30]===B?V=t[31]:(V=(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsx)(C,{variant:`ghost`,children:B})}),t[30]=B,t[31]=V);let H;t[32]===o?H=t[33]:(H=()=>{c(!1),o()},t[32]=o,t[33]=H);let U=l?`删除`:`Delete`,W;t[34]!==r||t[35]!==H||t[36]!==U?(W=(0,Q.jsx)(C,{disabled:r,onClick:H,children:U}),t[34]=r,t[35]=H,t[36]=U,t[37]=W):W=t[37];let G;t[38]!==V||t[39]!==W?(G=(0,Q.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3`,children:[V,W]}),t[38]=V,t[39]=W,t[40]=G):G=t[40];let K;t[41]!==L||t[42]!==z||t[43]!==G?(K=(0,Q.jsxs)(y,{children:[A,(0,Q.jsxs)(b,{className:`fixed left-1/2 top-1/2 z-[120] flex h-[min(22rem,calc(100dvh-2rem))] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover`,children:[L,z,G]})]}),t[41]=L,t[42]=z,t[43]=G,t[44]=K):K=t[44];let q;return t[45]!==s||t[46]!==O||t[47]!==K?(q=(0,Q.jsxs)(x,{open:s,onOpenChange:c,children:[O,K]}),t[45]=s,t[46]=O,t[47]=K,t[48]=q):q=t[48],q}function Ne(e,t){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`}).format(e):null}function Pe(e,t,n=new Date){let r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(r);i.setDate(r.getDate()-1);let a=new Map;for(let n of[...e].sort((e,t)=>t.recordedAt-e.recordedAt)){let e=n.recordedAt>=r.getTime()?t===`zh`?`今天`:`Today`:n.recordedAt>=i.getTime()?t===`zh`?`昨天`:`Yesterday`:Ne(n.recordedAt,t)??(t===`zh`?`更早`:`Earlier`),o=a.get(e)??[];o.push(n),a.set(e,o)}return[...a].map(([e,t])=>({label:e,items:t}))}function Fe(e,t){return(t===`zh`?{user_explicit:`你告诉我的`,user_observed:`从协作中观察到`,system_inferred:`我形成的判断`,external_untrusted:`来自连接的信息`}:{user_explicit:`You told me`,user_observed:`Observed while working together`,system_inferred:`My current read`,external_untrusted:`From connected information`})[e.authority]}function Ie(e,t){if(e.validTo){let n=Ne(e.validTo,t);return t===`zh`?`适用至 ${n}`:`Applies until ${n}`}return(t===`zh`?{stable:`相对稳定`,slow:`会随时间复核`,dynamic:`近期状态`,event:`特定阶段`}:{stable:`Relatively stable`,slow:`Reviewed over time`,dynamic:`Current context`,event:`Specific period`})[e.volatility]}function Le(e,t){return e.authority===`user_explicit`?null:e.confidence>=.85?t===`zh`?`把握较高`:`High confidence`:e.confidence>=.65?t===`zh`?`把握中等`:`Medium confidence`:t===`zh`?`证据较少`:`Limited evidence`}function Re(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function ze(e){let t=(0,Z.c)(23),{item:n,language:r,busy:i,editing:a,draft:o,onDraftChange:s,onEdit:c,onCancel:l,onDelete:u,onCorrect:d}=e,f=(0,X.useId)(),p=r===`zh`,m;t[0]!==n||t[1]!==r?(m=Le(n,r),t[0]=n,t[1]=r,t[2]=m):m=t[2];let h=m,g;t[3]===n.sources?g=t[4]:(g=new Set(n.sources?.map(Ve).filter(Boolean)),t[3]=n.sources,t[4]=g);let _;t[5]===g?_=t[6]:(_=[...g],t[5]=g,t[6]=_);let v=_,y=p?`修改`:`Edit`,b;return t[7]!==i||t[8]!==h||t[9]!==o||t[10]!==y||t[11]!==a||t[12]!==f||t[13]!==n||t[14]!==r||t[15]!==l||t[16]!==d||t[17]!==u||t[18]!==s||t[19]!==c||t[20]!==v||t[21]!==p?(b=(0,Q.jsx)(`article`,{className:`border-t border-edge-subtle px-4 py-3 first:border-t-0 sm:px-5 [content-visibility:auto] [contain-intrinsic-size:auto_100px]`,children:a?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:f,children:p?`修改这条理解`:`Edit this understanding`}),(0,Q.jsx)(`textarea`,{id:f,value:o,disabled:i,onChange:e=>s(e.target.value),className:`mt-2 min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-base leading-7 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,disabled:i,onClick:l,children:p?`取消`:`Cancel`}),(0,Q.jsx)(C,{variant:`primary`,disabled:!o.trim()||i,onClick:d,children:i?p?`保存中…`:`Saving…`:p?`保存修改`:`Save changes`})]})]}):(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 pt-1.5`,children:[(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-base leading-7 text-fg`,children:n.statement}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs leading-5 text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:Fe(n,r)}),n.usable===!1?(0,Q.jsx)(`span`,{children:p?`暂不使用`:`Not in use`}):null,n.validTo?(0,Q.jsx)(`span`,{children:Ie(n,r)}):null,n.authority!==`user_explicit`&&n.confidence<.65?(0,Q.jsx)(`span`,{children:h}):null,(0,Q.jsxs)(`details`,{className:`open:basis-full`,children:[(0,Q.jsx)(`summary`,{className:`w-fit cursor-pointer rounded-md py-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:p?`查看依据`:`View sources`}),(0,Q.jsxs)(`div`,{className:`my-2 space-y-1 border-l-2 border-edge pl-3 text-sm leading-6`,children:[(0,Q.jsx)(`p`,{children:n.usable?p?`按需用于当前协作`:`Used when relevant`:p?`暂不使用,后台继续复核`:`Not in use; reviewed automatically`}),(0,Q.jsxs)(`p`,{children:[Ie(n,r),` · `,Re(n.scope,r),h?` · ${h}`:``]}),(0,Q.jsxs)(`p`,{children:[p?`最近观察:`:`Last observed: `,Ne(n.observedAt,r)]}),v.length?v.map(Be):(0,Q.jsx)(`p`,{children:p?`暂无更详细的来源记录`:`No further source details available`}),(0,Q.jsx)(C,{variant:`ghost`,className:`-ml-2 px-2`,disabled:i,onClick:c,children:y})]})]})]})]}),(0,Q.jsx)(Me,{language:r,busy:i,statement:n.statement,onEdit:c,onDelete:u})]})}),t[7]=i,t[8]=h,t[9]=o,t[10]=y,t[11]=a,t[12]=f,t[13]=n,t[14]=r,t[15]=l,t[16]=d,t[17]=u,t[18]=s,t[19]=c,t[20]=v,t[21]=p,t[22]=b):b=t[22],b}function Be(e){return(0,Q.jsx)(`p`,{className:`break-words`,children:e},e)}function Ve(e){return e.label}var He={zh:{eyebrow:`全局用户理解`,title:`xopc 如何形成对你的理解`,subtitle:`这里汇总跨项目、跨对话形成的认识,并说明它们来自哪些渠道。项目事实不会混入你的个人画像。`,channels:`理解渠道`,channelHint:`查看来源及其最近更新。`,noChannels:`尚未通过任何渠道形成可展示的全局理解。`,activeCount:`{{count}} 条已在使用`,pendingCount:`{{count}} 条暂不使用`,noUnderstanding:`暂无来自此渠道的全局理解`,pending:`最近更新`,pendingHint:`自动整理并按需使用,你可以随时修改或删除。`,nothingPending:`尚未形成全局理解。`,showAll:`查看全部 {{count}} 条`,showLess:`收起`,done:`完成`,updating:`正在从已授权渠道更新理解;你可以先查看已有内容。`,sourceKinds:{user:`你明确告诉我的`,conversation:`对话与协作`,connector:`连接的服务`,work_folder:`工作目录`,local_source:`本机来源`,inference:`综合整理`}},en:{eyebrow:`Global user understanding`,title:`How xopc forms its understanding of you`,subtitle:`This brings together understanding formed across projects and conversations, with the channel behind each item. Project facts stay out of your personal portrait.`,channels:`Understanding channels`,channelHint:`View sources and their latest updates.`,noChannels:`No channel has formed displayable global understanding yet.`,activeCount:`{{count}} in use`,pendingCount:`{{count}} not in use`,noUnderstanding:`No usable global understanding has formed from this channel yet`,pending:`Recent updates`,pendingHint:`Organized automatically and used when relevant. Edit or delete anytime.`,nothingPending:`No understanding has formed yet.`,showAll:`View all {{count}}`,showLess:`Show less`,done:`Done`,updating:`Updating from authorized channels. You can review existing understanding now.`,sourceKinds:{user:`You told me`,conversation:`Conversations and work`,connector:`Connected services`,work_folder:`Work folders`,local_source:`On-device sources`,inference:`Synthesized understanding`}}},Ue={"local-recent-files":{en:`Recent files`,zh:`最近文件`},"chromium-bookmarks":{en:`Recent bookmarks`,zh:`最近书签`},"apple-notes":{en:`Apple Notes`,zh:`Apple 备忘录`},"apple-mail":{en:`Apple Mail`,zh:`Apple 邮件`},"apple-calendar":{en:`Apple Calendar`,zh:`Apple 日历`},"apple-reminders":{en:`Apple Reminders`,zh:`Apple 提醒事项`},"windows-recent-documents":{en:`Recent documents`,zh:`最近文档`},"linux-recent-documents":{en:`Recent documents`,zh:`最近文档`}},We={user:me,conversation:te,connector:Se,work_folder:de,local_source:Y,inference:Se},Ge={files:de,recent_documents:Y,calendar:F,tasks:L,notes:q,mail:B,messages:te,code_activity:le};function Ke(e){let t=e.authority===`user_explicit`?`user`:e.authority===`user_observed`?`conversation`:e.authority===`external_untrusted`?`connector`:`inference`;return{id:t,kind:t,observedAt:e.observedAt}}function qe(e,t){return e.kind===`local_source`&&e.label?Ue[e.label]?.[t]??e.label:e.kind===`work_folder`&&e.label?t===`zh`?`工作目录 · ${e.label}`:`Work folder · ${e.label}`:e.label?e.label:He[t].sourceKinds[e.kind]}function $(e){return`${e.kind}:${e.adapterId}:${e.displayName}`}function Je(e){let t=(0,Z.c)(91),{assertions:n,configuredSources:r,activityRunning:i,language:a,busy:s,error:c,onReviewAssertion:l,onCompleted:d}=e,f=He[a],[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(``),b;t[0]===n?b=t[1]:(b=n.filter(tt),t[0]=n,t[1]=b);let ee=b,x;t[2]===ee?x=t[3]:(x=[...ee].sort(et),t[2]=ee,t[3]=x);let S=x,w;if(t[4]!==r||t[5]!==ee||t[6]!==a){let e=new Map;for(let t of r){let n=t.kind===`local_source`?Ue[t.adapterId]?.[a]??t.displayName:t.displayName,r=$(t);e.set(r,{key:r,grantId:t.id,kind:t.kind,category:t.category,label:t.kind===`work_folder`?a===`zh`?`工作目录 · ${n}`:`Work folder · ${n}`:n,assertions:[],lastObservedAt:t.lastCollectedAt})}for(let t of ee)for(let n of t.sources?.length?t.sources:[Ke(t)]){let r=qe(n,a),i=[...e.values()].find(e=>e.kind===n.kind&&e.label===r),o=i?.key??`${n.kind}:${r}`,s=i??e.get(o)??{key:o,kind:n.kind,category:n.category,label:r,assertions:[],lastObservedAt:n.observedAt};s.assertions.some(e=>e.id===t.id)||s.assertions.push(t),s.lastObservedAt=Math.max(s.lastObservedAt??0,n.observedAt),e.set(o,s)}w=[...e.values()].sort($e),t[4]=r,t[5]=ee,t[6]=a,t[7]=w}else w=t[7];let T=w,E;t[8]===l?E=t[9]:(E=async(e,t,n)=>{await l(e,t,n)&&_(null)},t[8]=l,t[9]=E);let D=E,O,k,j,M,N,P,F,I,L;if(t[10]!==i||t[11]!==s||t[12]!==v||t[13]!==g||t[14]!==a||t[15]!==S||t[16]!==D||t[17]!==m||t[18]!==f.eyebrow||t[19]!==f.nothingPending||t[20]!==f.pending||t[21]!==f.pendingHint||t[22]!==f.showAll||t[23]!==f.showLess||t[24]!==f.subtitle||t[25]!==f.title||t[26]!==f.updating){let e=m?S:S.slice(0,5);O=`mx-auto w-full max-w-[42rem] pb-2`,k=`polite`;let n;t[36]===f.eyebrow?n=t[37]:(n=(0,Q.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-accent-fg`,children:f.eyebrow}),t[36]=f.eyebrow,t[37]=n);let r;t[38]===f.title?r=t[39]:(r=(0,Q.jsx)(`h2`,{className:`mt-3 text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:f.title}),t[38]=f.title,t[39]=r);let o;t[40]===f.subtitle?o=t[41]:(o=(0,Q.jsx)(`p`,{className:`mx-auto mt-3 max-w-[38rem] text-sm leading-6 text-fg-muted`,children:f.subtitle}),t[40]=f.subtitle,t[41]=o),t[42]!==n||t[43]!==r||t[44]!==o?(j=(0,Q.jsxs)(`div`,{className:`text-center`,children:[n,r,o]}),t[42]=n,t[43]=r,t[44]=o,t[45]=j):j=t[45],t[46]!==i||t[47]!==f.updating?(M=i?(0,Q.jsxs)(`div`,{className:`mt-6 flex items-center gap-3 rounded-xl border border-accent/20 bg-accent-soft/55 px-4 py-3 text-sm text-accent-fg`,children:[(0,Q.jsx)(V,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`}),(0,Q.jsx)(`p`,{children:f.updating})]}):null,t[46]=i,t[47]=f.updating,t[48]=M):M=t[48],N=`mt-8`,P=`understanding-updates-title`;let c=S.length?` · ${S.length}`:``;t[49]!==f.pending||t[50]!==c?(F=(0,Q.jsxs)(`h3`,{id:`understanding-updates-title`,className:`text-sm font-semibold text-fg`,children:[f.pending,c]}),t[49]=f.pending,t[50]=c,t[51]=F):F=t[51],t[52]===f.pendingHint?I=t[53]:(I=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:f.pendingHint}),t[52]=f.pendingHint,t[53]=I),L=S.length?(0,Q.jsxs)(`div`,{className:`mt-3`,children:[Pe(e,a).map(e=>{let{label:t,items:n}=e;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`border-b border-edge-subtle px-4 pb-2 pt-3 text-xs font-medium text-fg-muted`,children:t}),(0,Q.jsx)(`div`,{children:n.map(e=>(0,Q.jsx)(ze,{item:e,language:a,busy:s,editing:g===e.id,draft:v,onDraftChange:y,onEdit:()=>{_(e.id),y(e.statement)},onCancel:()=>_(null),onCorrect:()=>void D(e,`edited`,v.trim()),onDelete:()=>void D(e,`deleted`)},e.id))})]},t)}),S.length>5?(0,Q.jsxs)(`button`,{type:`button`,className:`mx-auto flex items-center gap-1.5 px-3 py-2 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>h(Qe),children:[m?f.showLess:f.showAll.replace(`{{count}}`,String(S.length)),(0,Q.jsx)(A,{className:p(`size-3.5 transition-transform`,m&&`rotate-180`)})]}):null]}):(0,Q.jsxs)(`div`,{className:`mt-3 flex items-start gap-3 rounded-xl border border-edge bg-surface-base/55 p-4`,children:[(0,Q.jsx)(u,{className:`mt-0.5 size-5 shrink-0 text-success`}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:f.nothingPending})]}),t[10]=i,t[11]=s,t[12]=v,t[13]=g,t[14]=a,t[15]=S,t[16]=D,t[17]=m,t[18]=f.eyebrow,t[19]=f.nothingPending,t[20]=f.pending,t[21]=f.pendingHint,t[22]=f.showAll,t[23]=f.showLess,t[24]=f.subtitle,t[25]=f.title,t[26]=f.updating,t[27]=O,t[28]=k,t[29]=j,t[30]=M,t[31]=N,t[32]=P,t[33]=F,t[34]=I,t[35]=L}else O=t[27],k=t[28],j=t[29],M=t[30],N=t[31],P=t[32],F=t[33],I=t[34],L=t[35];let R;t[54]!==N||t[55]!==P||t[56]!==F||t[57]!==I||t[58]!==L?(R=(0,Q.jsxs)(`section`,{className:N,"aria-labelledby":P,children:[F,I,L]}),t[54]=N,t[55]=P,t[56]=F,t[57]=I,t[58]=L,t[59]=R):R=t[59];let z;t[60]!==T.length||t[61]!==f.channels?(z=(0,Q.jsxs)(`summary`,{className:`w-fit cursor-pointer rounded-md py-2 text-sm font-medium text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[f.channels,` · `,T.length]}),t[60]=T.length,t[61]=f.channels,t[62]=z):z=t[62];let B;t[63]===f.channelHint?B=t[64]:(B=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:f.channelHint}),t[63]=f.channelHint,t[64]=B);let H;t[65]!==T||t[66]!==f.activeCount||t[67]!==f.noChannels||t[68]!==f.noUnderstanding||t[69]!==f.pendingCount?(H=T.length?(0,Q.jsx)(`div`,{className:`mt-3 space-y-3`,children:T.map(e=>{let t=e.category?Ge[e.category]??We[e.kind]:We[e.kind],n=e.assertions.filter(Ze).length,r=e.assertions.filter(Xe).length;return(0,Q.jsxs)(`article`,{className:`rounded-xl border border-edge bg-surface-base/55 px-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-surface-hover text-fg-muted`,children:(0,Q.jsx)(t,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),e.grantId?(0,Q.jsx)(Ae,{sourceId:e.grantId,lastCollectedAt:e.lastObservedAt}):null,e.assertions.length?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[n?f.activeCount.replace(`{{count}}`,String(n)):``,r?f.pendingCount.replace(`{{count}}`,String(r)):``].filter(Boolean).join(` · `)}):(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:f.noUnderstanding})]}),e.grantId?(0,Q.jsx)(Ee,{sourceId:e.grantId}):null]}),e.assertions.length?(0,Q.jsx)(`ul`,{className:`ml-12 mt-3 space-y-2 border-t border-edge-subtle pt-3 text-xs leading-5 text-fg-muted`,children:e.assertions.slice(0,5).map(Ye)}):null]},e.key)})}):(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl border border-edge bg-surface-base/55 p-4 text-sm text-fg-muted`,children:f.noChannels}),t[65]=T,t[66]=f.activeCount,t[67]=f.noChannels,t[68]=f.noUnderstanding,t[69]=f.pendingCount,t[70]=H):H=t[70];let U;t[71]!==z||t[72]!==B||t[73]!==H?(U=(0,Q.jsxs)(`details`,{className:`mt-6 border-t border-edge pt-4`,children:[z,B,H]}),t[71]=z,t[72]=B,t[73]=H,t[74]=U):U=t[74];let W;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Q.jsx)(o,{className:`size-4`}),t[75]=W):W=t[75];let G;t[76]!==s||t[77]!==d||t[78]!==f.done?(G=(0,Q.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,Q.jsxs)(C,{variant:`primary`,disabled:s,onClick:d,children:[W,f.done]})}),t[76]=s,t[77]=d,t[78]=f.done,t[79]=G):G=t[79];let K;t[80]===c?K=t[81]:(K=c?(0,Q.jsx)(`p`,{className:`mt-5 text-sm text-danger`,role:`alert`,children:c}):null,t[80]=c,t[81]=K);let q;return t[82]!==O||t[83]!==k||t[84]!==j||t[85]!==M||t[86]!==R||t[87]!==U||t[88]!==G||t[89]!==K?(q=(0,Q.jsxs)(`section`,{className:O,"aria-live":k,children:[j,M,R,U,G,K]}),t[82]=O,t[83]=k,t[84]=j,t[85]=M,t[86]=R,t[87]=U,t[88]=G,t[89]=K,t[90]=q):q=t[90],q}function Ye(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent/60`}),(0,Q.jsx)(`span`,{children:e.statement})]},e.id)}function Xe(e){return!e.usable}function Ze(e){return e.usable}function Qe(e){return!e}function $e(e,t){return t.assertions.length-e.assertions.length||(t.lastObservedAt??0)-(e.lastObservedAt??0)}function et(e,t){return t.recordedAt-e.recordedAt}function tt(e){return e.scope.type===`global`&&e.status!==`archived`&&e.status!==`rejected`}function nt(){let{pathname:e,search:t}=a(),n=m(e=>e.language),r=pe(),[i,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(null),l=e===`/user-model`,{data:u,mutate:d}=S(l?`/api/user-model`:null,ce),T=N(e=>e.error),D=N(e=>e.sources.some(e=>e.status===`running`||e.status===`queued`)),k=n===`zh`;if((0,X.useEffect)(()=>{l&&new URLSearchParams(t).get(`workDiscovery`)===`review`&&pe.getState().setDrawerOpen(!0)},[l,t]),(0,X.useEffect)(()=>{l&&r.status!==`running`&&d()},[d,l,r.directoryRun?.id,r.status]),!l)return null;let A=r.status===`running`||D,j=async(e,t,n)=>{o(!0),c(null);try{return t===`edited`&&n?await se(e.id,n):t===`deleted`&&await ue(e.id),await d(),!0}catch(e){return c(e instanceof Error?e.message:String(e)),!1}finally{o(!1)}},M=e=>{if(!e&&u&&r.status!==`running`){r.finish();return}r.setDrawerOpen(e)};return(0,Q.jsxs)(x,{open:r.drawerOpen,onOpenChange:M,children:[(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsx)(C,{type:`button`,variant:`ghost`,className:p(`relative size-8 rounded-xl p-0`,E),title:k?`查看 xopc 对你的理解`:`Review what xopc understands`,"aria-label":k?`查看 xopc 对你的理解`:`Review what xopc understands`,children:A?(0,Q.jsx)(V,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,Q.jsx)(O,{className:`size-4 text-accent-fg`})})}),(0,Q.jsxs)(y,{children:[(0,Q.jsx)(h,{className:`fixed inset-0 z-[60] bg-scrim backdrop-blur-sm data-[state=closed]:animate-out data-[state=open]:animate-in motion-reduce:backdrop-blur-none`}),(0,Q.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] flex items-center justify-center p-3 sm:p-6`,children:(0,Q.jsxs)(b,{className:`xopc-understanding-center pointer-events-auto flex h-[min(42rem,calc(100dvh-1.5rem))] w-[min(44rem,calc(100vw-1.5rem))] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float outline-none sm:h-[min(42rem,calc(100dvh-3rem))] sm:w-[min(44rem,calc(100vw-3rem))]`,children:[(0,Q.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center justify-between border-b border-edge-subtle px-5 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(ee,{className:`text-sm font-semibold text-fg`,children:A?k?`正在更新用户理解`:`Updating user understanding`:k?`用户理解`:`User understanding`}),(0,Q.jsx)(_,{className:`mt-0.5 text-xs text-fg-muted`,children:A?k?`关闭窗口也会在后台继续`:`You can close this window; work continues in the background`:k?`自动更新,可随时修改或删除`:`Updated automatically. Edit or delete anytime`})]}),(0,Q.jsx)(Ee,{disabled:!u?.sources?.length}),(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsx)(C,{variant:`ghost`,className:`size-8 rounded-xl p-0`,"aria-label":k?`关闭`:`Close`,children:(0,Q.jsx)(f,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-7 sm:px-9 sm:py-9`,children:u?(0,Q.jsx)(Je,{assertions:u.assertions,configuredSources:u.sources??[],activityRunning:A,language:n,busy:i,error:s??T??null,onReviewAssertion:j,onCompleted:()=>{M(!1)}}):(0,Q.jsxs)(`section`,{className:`space-y-4`,"aria-label":k?`正在加载用户理解`:`Loading user understanding`,children:[(0,Q.jsx)(w,{className:`h-8 w-2/3`}),(0,Q.jsx)(w,{className:`h-32 w-full`}),(0,Q.jsx)(w,{className:`h-32 w-full`})]})})]})})]})]})}function rt(e){let t=e.get(`tab`);return t===`understanding`||t===`knowledge`?t:`overview`}var it={en:{pageTitle:`You`,pageSubtitle:`A living portrait shaped by you and xopc.`,overview:`Your portrait`,understanding:`Shared understanding`,knowledge:`Work memory`,portraitEyebrow:`YOU × XOPC`,portraitIntro:`Your explicit profile stays clear and editable. xopc builds a separate shared understanding through conversations and work.`,editProfile:`Edit basics`,callName:`What should xopc call you?`,callNamePlaceholder:`For example: Alex, Joyce, or Dr. Chen`,role:`Your role`,rolePlaceholder:`For example: founder, designer, or engineer`,pronouns:`Pronouns (optional)`,pronounsPlaceholder:`For example: she/her, he/him, they/them`,timezone:`Timezone`,timezoneSearch:`Search timezones…`,timezoneNoMatch:`No matching timezone`,locale:`Language / locale`,useDeviceTimezone:`Use this device`,notProvided:`Not provided`,editProfileHint:`These are facts you provide directly. They remain separate from xopc’s observations and inferences.`,saveProfile:`Save`,saving:`Saving…`,explicit:`You told me`,explicitHint:`Facts and preferences you stated directly`,learned:`Learned together`,learnedHint:`Patterns formed from our work`,pending:`Not in use`,pendingHint:`Reviewed automatically as evidence changes`,allUnderstanding:`All understanding`,understandingFilterHint:`Filter this view by how each item was formed or whether it is currently in use.`,importantNow:`What matters now`,prioritySourceGoal:`From a goal you confirmed`,prioritySourceWork:`From your current work`,editPriority:`Edit focus`,addPriority:`Set current focus`,priorityTitle:`Current focus`,priorityTitlePlaceholder:`What matters most right now?`,priorityOutcome:`What a good outcome looks like`,priorityOutcomePlaceholder:`Describe the result you want…`,priorityUntil:`Focus through`,savePriority:`Save focus`,endPriority:`End focus`,endingPriority:`Ending…`,priorityHint:`This is used to keep xopc aligned with what deserves attention now.`,noPriority:`No current priority has been set.`,otherGoals:`Other active outcomes`,howWeWork:`How we work together`,howWeWorkHint:`Your standing instructions for how I should communicate and act.`,noRules:`No collaboration preferences yet.`,recent:`Recently formed understanding`,recentHint:`Recent understanding from our work. You can edit any item.`,seeAll:`See all`,workMemory:`What I remember from the work`,workMemoryHint:`Project facts, decisions, lessons, and open questions stay separate from facts about you.`,items:`items`,maintenanceReady:`Memory upkeep is enabled and waiting for its first run.`,maintenanceComplete:`Memory was last organized`,maintenanceFailed:`The latest memory upkeep needs attention`,refresh:`Refresh`,refreshing:`Refreshing…`,refreshComplete:`Refreshed`,refreshFailed:`Refresh failed`,aboutYouTitle:`A view you can correct`,aboutYouHint:`This is working context, not a fixed profile. Every item can be corrected or retired.`,identity:`Who you are`,preferences:`Preferences and working rhythm`,relationships:`People and relationships`,currentState:`Current context`,insights:`My current read`,emptyGroup:`No understanding has formed here yet.`,correct:`Correct`,save:`Save correction`,cancel:`Cancel`,correctionPlaceholder:`Write the accurate version…`,searchPlaceholder:`Search work memory…`,allMemory:`All work memory`,memoryFilterHint:`Filter by memory type`,memoryLibraryHint:`Only distilled facts, decisions, lessons, commitments, and open questions appear here. Source records stay with their connector.`,noKnowledge:`No work memory has formed yet.`,noKnowledgeMatch:`No work memory matches this search.`,showMore:`Show more`,expand:`Show details`,collapse:`Hide details`,disable:`Disable`,disabled:`Not in use`,enable:`Enable`,loadFailed:`Could not load your understanding.`,tryAgain:`Try again`,actionFailed:`The change could not be saved. Please try again.`},zh:{pageTitle:`你`,pageSubtitle:`一份由你和 xopc 共同塑造、持续生长的画像。`,overview:`你的画像`,understanding:`共同理解`,knowledge:`工作记忆`,portraitEyebrow:`YOU × XOPC`,portraitIntro:`你明确提供的基本信息会被清晰呈现并由你直接编辑;xopc 在对话与共事中形成的理解则单独维护。`,editProfile:`编辑基本信息`,callName:`希望 xopc 如何称呼你?`,callNamePlaceholder:`例如:Mic、Joyce、张老师`,role:`你的角色`,rolePlaceholder:`例如:创业者、产品设计师、工程师`,pronouns:`代词(可选)`,pronounsPlaceholder:`例如:she/her、he/him、they/them`,timezone:`时区`,timezoneSearch:`搜索时区…`,timezoneNoMatch:`没有匹配的时区`,locale:`语言 / 地区`,useDeviceTimezone:`使用本机时区`,notProvided:`未填写`,editProfileHint:`这些是由你直接提供的事实,与 xopc 的观察和推断分开维护。`,saveProfile:`保存`,saving:`正在保存…`,explicit:`你告诉我的`,explicitHint:`你明确表达的事实与偏好`,learned:`协作中学到的`,learnedHint:`从实际协作中形成的认识`,pending:`暂不使用`,pendingHint:`随新证据自动复核`,allUnderstanding:`全部理解`,understandingFilterHint:`按内容来源和当前是否使用筛选这份理解。`,importantNow:`此刻重要`,prioritySourceGoal:`来自你确认的当前目标`,prioritySourceWork:`来自当前工作上下文`,editPriority:`编辑`,addPriority:`设置当前关注`,priorityTitle:`当前关注`,priorityTitlePlaceholder:`现在最重要的是什么?`,priorityOutcome:`期待结果`,priorityOutcomePlaceholder:`描述你希望达成的结果…`,priorityUntil:`关注至`,savePriority:`保存关注`,endPriority:`结束关注`,endingPriority:`正在结束…`,priorityHint:`这项内容会帮助 xopc 在协作中优先关注当前最重要的事情。`,noPriority:`还没有设置当前优先事项。`,otherGoals:`其他进行中的目标`,howWeWork:`我们怎样协作`,howWeWorkHint:`你对沟通方式和执行行为的长期约定。`,noRules:`还没有形成协作偏好。`,recent:`最近形成的理解`,recentHint:`最近在协作中形成的认识,你可以随时修改。`,seeAll:`查看全部`,workMemory:`我在工作中记住的`,workMemoryHint:`项目事实、决定、经验和待解问题,与“关于你”的理解分别管理。`,items:`条`,maintenanceReady:`记忆整理已经启用,正在等待首次运行。`,maintenanceComplete:`最近一次记忆整理于`,maintenanceFailed:`最近一次记忆整理需要处理`,refresh:`刷新`,refreshing:`正在刷新…`,refreshComplete:`已刷新`,refreshFailed:`刷新失败`,aboutYouTitle:`一份可以共同修正的理解`,aboutYouHint:`它是协作中的工作认知,不是给你定型的档案。每一条都能修正或停止使用。`,identity:`关于你是谁`,preferences:`偏好与工作节奏`,relationships:`重要的人与关系`,currentState:`当前状态`,insights:`我形成的判断`,emptyGroup:`这里还没有形成理解。`,correct:`修正`,save:`保存修正`,cancel:`取消`,correctionPlaceholder:`写下更准确的说法…`,searchPlaceholder:`搜索工作记忆…`,allMemory:`全部工作记忆`,memoryFilterHint:`按记忆类型筛选`,memoryLibraryHint:`这里只显示提炼后的事实、决定、经验、承诺和待解问题;邮件、日历与文档原文保留在对应来源中。`,noKnowledge:`还没有形成工作记忆。`,noKnowledgeMatch:`没有符合搜索条件的工作记忆。`,showMore:`显示更多`,expand:`查看详情`,collapse:`收起详情`,disable:`停用`,disabled:`已停用`,enable:`启用`,loadFailed:`无法载入对你的理解。`,tryAgain:`重试`,actionFailed:`修改没有保存,请重试。`}},at=new Set([`identity.call_name`,`identity.role`,`identity.pronouns`,`preference.timezone`,`preference.locale`]),ot=[`work_thread`,`project_fact`,`workspace_fact`,`decision`,`task_lesson`,`commitment`,`open_question`,`episode`,`note`],st=`UTC.Africa/Cairo.Africa/Johannesburg.America/Chicago.America/Denver.America/Los_Angeles.America/Mexico_City.America/New_York.America/Sao_Paulo.America/Toronto.America/Vancouver.Asia/Bangkok.Asia/Dubai.Asia/Hong_Kong.Asia/Jakarta.Asia/Kolkata.Asia/Seoul.Asia/Shanghai.Asia/Singapore.Asia/Taipei.Asia/Tokyo.Australia/Melbourne.Australia/Perth.Australia/Sydney.Europe/Amsterdam.Europe/Berlin.Europe/London.Europe/Madrid.Europe/Paris.Europe/Rome.Pacific/Auckland.Pacific/Honolulu`.split(`.`);function ct(){try{let e=Intl.supportedValuesOf(`timeZone`);return[...new Set([`UTC`,...e])]}catch{return[...st]}}var lt=ct();function ut(e){return e.map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.includes(`/`)?e.split(`/`)[0]:`UTC`}))}function dt(e,t,n=!1){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,...n?{timeStyle:`short`}:{}}).format(e):null}function ft(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function pt(e){return{callName:ft(e.profile.callName)??``,role:ft(e.profile.role)??``,pronouns:ft(e.profile.pronouns)??``,timezone:ft(e.profile.timezone)??``,locale:ft(e.profile.locale)??``}}function mt(e,t){return{"zh-CN":{en:`Simplified Chinese`,zh:`简体中文`},"zh-TW":{en:`Traditional Chinese`,zh:`繁体中文`},"en-US":{en:`English (US)`,zh:`英语(美国)`},"en-GB":{en:`English (UK)`,zh:`英语(英国)`},"ja-JP":{en:`Japanese`,zh:`日语`}}[e]?.[t]??e}function ht(e){return Array.from(e.trim()).slice(0,2).join(``).toLocaleUpperCase()}function gt(e,t){let n=dt(e,t);return t===`zh`?`当前安排至 ${n}`:`Current plan through ${n}`}function _t(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function vt(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r,23,59,59,999).getTime()}function yt(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function bt(e,t){return(t===`zh`?{work_thread:`工作主线`,project_fact:`项目事实`,workspace_fact:`工作区事实`,decision:`已经决定`,task_lesson:`工作经验`,commitment:`承诺与约定`,open_question:`待解问题`,episode:`重要经历`,note:`其他记录`}:{work_thread:`Work threads`,project_fact:`Project facts`,workspace_fact:`Workspace facts`,decision:`Decisions`,task_lesson:`Lessons`,commitment:`Commitments`,open_question:`Open questions`,episode:`Episodes`,note:`Notes`})[e]}function xt(e,t,n){if(e)return e.targetType===`goal`?t.find(t=>t.id===e.targetId)?.title:/^[0-9a-f]{8}-[0-9a-f-]{20,}$/i.test(e.targetId)?(n===`zh`?{project:`当前项目`,task:`当前任务`,assertion:`一项待处理的理解`,topic:`当前主题`}:{project:`Current project`,task:`Current task`,assertion:`An understanding to address`,topic:`Current topic`})[e.targetType]:e.targetId}function St(e){let t=(0,Z.c)(16),{title:n,hint:r,action:i,children:a,className:o}=e,s=o===void 0?``:o,c;t[0]===n?c=t[1]:(c=(0,Q.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n}),t[0]=n,t[1]=c);let l;t[2]===r?l=t[3]:(l=r?(0,Q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:r}):null,t[2]=r,t[3]=l);let u;t[4]!==c||t[5]!==l?(u=(0,Q.jsxs)(`div`,{children:[c,l]}),t[4]=c,t[5]=l,t[6]=u):u=t[6];let d;t[7]!==i||t[8]!==u?(d=(0,Q.jsxs)(`header`,{className:`flex items-end justify-between gap-4 px-1 pb-3`,children:[u,i]}),t[7]=i,t[8]=u,t[9]=d):d=t[9];let f;t[10]===a?f=t[11]:(f=(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-2xl bg-surface-panel`,children:a}),t[10]=a,t[11]=f);let p;return t[12]!==s||t[13]!==d||t[14]!==f?(p=(0,Q.jsxs)(`section`,{className:s,children:[d,f]}),t[12]=s,t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function Ct(e){let t=(0,Z.c)(7),{icon:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`span`,{className:`text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Q.jsx)(`p`,{children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-5 text-sm text-fg-muted`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function wt({open:e,profile:t,language:n,saving:r,onOpenChange:i,onSave:a}){let o=it[n],[u,d]=(0,X.useState)(t),[p,m]=(0,X.useState)(``);(0,X.useEffect)(()=>{e&&(d(t),m(``))},[e,t]);let g=e=>{e.preventDefault(),a({callName:u.callName.trim(),role:u.role.trim(),pronouns:u.pronouns.trim(),timezone:u.timezone.trim(),locale:u.locale.trim()})},S=(e,t,n)=>(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Q.jsx)(`input`,{value:u[e],onChange:t=>d(n=>({...n,[e]:t.target.value})),placeholder:n,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),w=[`zh-CN`,`zh-TW`,`en-US`,`en-GB`,`ja-JP`];u.locale&&!w.includes(u.locale)&&w.push(u.locale);let T=re(),E=(0,X.useMemo)(()=>[...new Set([...lt,T,u.timezone].filter(Boolean))].sort(),[T,u.timezone]),D=p.trim().toLocaleLowerCase(),O=(0,X.useMemo)(()=>ut(E.filter(e=>!D||e.toLocaleLowerCase().includes(D)||e.replaceAll(`_`,` `).toLocaleLowerCase().includes(D))),[E,D]);return(0,Q.jsx)(x,{open:e,onOpenChange:i,children:(0,Q.jsxs)(y,{children:[(0,Q.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsx)(b,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] h-[min(40rem,calc(100vh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:(0,Q.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col overflow-hidden [border-radius:inherit]`,onSubmit:g,children:[(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(ee,{className:`font-semibold text-fg`,children:o.editProfile}),(0,Q.jsx)(_,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.editProfileHint})]}),(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsx)(C,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o.cancel,children:(0,Q.jsx)(f,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5 sm:p-6`,children:(0,Q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[S(`callName`,o.callName,o.callNamePlaceholder),S(`role`,o.role,o.rolePlaceholder),S(`pronouns`,o.pronouns,o.pronounsPlaceholder),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:o.locale}),(0,Q.jsxs)(s,{value:u.locale,onChange:e=>d(t=>({...t,locale:e.target.value})),children:[(0,Q.jsx)(c,{value:``,children:o.notProvided}),w.map(e=>(0,Q.jsx)(c,{value:e,children:mt(e,n)},e))]})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:col-span-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:o.timezone}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(l,{value:u.timezone,options:O,placeholder:re(),emptyLabel:o.notProvided,ariaLabel:o.timezone,selectedLabel:u.timezone||o.notProvided,searchPlaceholder:o.timezoneSearch,searchValue:p,onSearchChange:m,statusMessage:O.length?void 0:o.timezoneNoMatch,triggerClassName:`min-w-0 flex-1 rounded-xl bg-surface-base`,onChange:e=>{d(t=>({...t,timezone:e})),m(``)}}),(0,Q.jsx)(C,{className:`shrink-0 whitespace-nowrap`,onClick:()=>d(e=>({...e,timezone:T})),children:o.useDeviceTimezone})]})]})]})}),(0,Q.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsx)(C,{disabled:r,children:o.cancel})}),(0,Q.jsxs)(C,{type:`submit`,variant:`primary`,disabled:r,children:[r?(0,Q.jsx)(V,{className:`size-4 animate-spin`}):null,r?o.saving:o.saveProfile]})]})]})})]})})}function Tt(e){let t=(0,Z.c)(94),{open:n,priority:r,title:i,outcome:a,language:o,saving:s,onOpenChange:c,onSave:l,onEnd:u}=e,d=it[o],[p,m]=(0,X.useState)(i),[g,S]=(0,X.useState)(a??``),w=r?.validTo??Date.now()+6048e5,T;t[0]===w?T=t[1]:(T=_t(w),t[0]=w,t[1]=T);let E=T,[D,O]=(0,X.useState)(E),k,A;t[2]!==E||t[3]!==n||t[4]!==a||t[5]!==i?(k=()=>{n&&(m(i),S(a??``),O(E))},A=[E,n,a,i],t[2]=E,t[3]=n,t[4]=a,t[5]=i,t[6]=k,t[7]=A):(k=t[6],A=t[7]),(0,X.useEffect)(k,A);let j;t[8]!==g||t[9]!==p||t[10]!==D||t[11]!==l||t[12]!==r?.targetType?(j=e=>{e.preventDefault(),l({title:p.trim(),...r?.targetType===`goal`?{desiredOutcome:g.trim()}:{},validTo:vt(D)})},t[8]=g,t[9]=p,t[10]=D,t[11]=l,t[12]=r?.targetType,t[13]=j):j=t[13];let M=j,N;t[14]!==g||t[15]!==p||t[16]!==D||t[17]!==r?.targetType?(N=p.trim()&&D&&(r?.targetType!==`goal`||g.trim()),t[14]=g,t[15]=p,t[16]=D,t[17]=r?.targetType,t[18]=N):N=t[18];let P=!!N,F;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Q.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[19]=F):F=t[19];let I=r?d.editPriority:d.addPriority,L;t[20]===I?L=t[21]:(L=(0,Q.jsx)(ee,{className:`font-semibold text-fg`,children:I}),t[20]=I,t[21]=L);let R;t[22]===d.priorityHint?R=t[23]:(R=(0,Q.jsx)(_,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:d.priorityHint}),t[22]=d.priorityHint,t[23]=R);let z;t[24]!==R||t[25]!==L?(z=(0,Q.jsxs)(`div`,{children:[L,R]}),t[24]=R,t[25]=L,t[26]=z):z=t[26];let B;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(f,{className:`size-4`}),t[27]=B):B=t[27];let H;t[28]===d.cancel?H=t[29]:(H=(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsx)(C,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":d.cancel,children:B})}),t[28]=d.cancel,t[29]=H);let U;t[30]!==z||t[31]!==H?(U=(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[z,H]}),t[30]=z,t[31]=H,t[32]=U):U=t[32];let W;t[33]===d.priorityTitle?W=t[34]:(W=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:d.priorityTitle}),t[33]=d.priorityTitle,t[34]=W);let G;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>m(e.target.value),t[35]=G):G=t[35];let K;t[36]!==p||t[37]!==d.priorityTitlePlaceholder?(K=(0,Q.jsx)(`input`,{autoFocus:!0,value:p,onChange:G,placeholder:d.priorityTitlePlaceholder,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[36]=p,t[37]=d.priorityTitlePlaceholder,t[38]=K):K=t[38];let q;t[39]!==W||t[40]!==K?(q=(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[W,K]}),t[39]=W,t[40]=K,t[41]=q):q=t[41];let te;t[42]!==g||t[43]!==r?.targetType||t[44]!==d.priorityOutcome||t[45]!==d.priorityOutcomePlaceholder?(te=r?.targetType===`goal`?(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:d.priorityOutcome}),(0,Q.jsx)(`textarea`,{value:g,onChange:e=>S(e.target.value),placeholder:d.priorityOutcomePlaceholder,className:`min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}):null,t[42]=g,t[43]=r?.targetType,t[44]=d.priorityOutcome,t[45]=d.priorityOutcomePlaceholder,t[46]=te):te=t[46];let ne;t[47]===d.priorityUntil?ne=t[48]:(ne=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:d.priorityUntil}),t[47]=d.priorityUntil,t[48]=ne);let re;t[49]===r?.validFrom?re=t[50]:(re=r?.validFrom??Date.now(),t[49]=r?.validFrom,t[50]=re);let ie;t[51]===re?ie=t[52]:(ie=_t(re),t[51]=re,t[52]=ie);let ae;t[53]!==D||t[54]!==d.priorityUntil||t[55]!==ie?(ae=(0,Q.jsx)(Te,{min:ie,value:D,onChange:O,ariaLabel:d.priorityUntil,className:`rounded-xl border border-edge bg-surface-base hover:border-edge-strong hover:bg-surface-base`}),t[53]=D,t[54]=d.priorityUntil,t[55]=ie,t[56]=ae):ae=t[56];let oe;t[57]!==ne||t[58]!==ae?(oe=(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[ne,ae]}),t[57]=ne,t[58]=ae,t[59]=oe):oe=t[59];let se;t[60]!==q||t[61]!==te||t[62]!==oe?(se=(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5 sm:p-6`,children:[q,te,oe]}),t[60]=q,t[61]=te,t[62]=oe,t[63]=se):se=t[63];let ce;t[64]!==u||t[65]!==r||t[66]!==s||t[67]!==d.endPriority||t[68]!==d.endingPriority?(ce=r&&u?(0,Q.jsxs)(C,{variant:`ghost`,className:`text-danger hover:text-danger`,disabled:s,onClick:u,children:[s?(0,Q.jsx)(V,{className:`size-4 animate-spin`}):null,s?d.endingPriority:d.endPriority]}):(0,Q.jsx)(`span`,{}),t[64]=u,t[65]=r,t[66]=s,t[67]=d.endPriority,t[68]=d.endingPriority,t[69]=ce):ce=t[69];let le;t[70]!==s||t[71]!==d.cancel?(le=(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsx)(C,{disabled:s,children:d.cancel})}),t[70]=s,t[71]=d.cancel,t[72]=le):le=t[72];let ue=!P||s,de;t[73]===s?de=t[74]:(de=s?(0,Q.jsx)(V,{className:`size-4 animate-spin`}):null,t[73]=s,t[74]=de);let J;t[75]!==d.savePriority||t[76]!==ue||t[77]!==de?(J=(0,Q.jsxs)(C,{type:`submit`,variant:`primary`,disabled:ue,children:[de,d.savePriority]}),t[75]=d.savePriority,t[76]=ue,t[77]=de,t[78]=J):J=t[78];let fe;t[79]!==le||t[80]!==J?(fe=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[le,J]}),t[79]=le,t[80]=J,t[81]=fe):fe=t[81];let Y;t[82]!==ce||t[83]!==fe?(Y=(0,Q.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[ce,fe]}),t[82]=ce,t[83]=fe,t[84]=Y):Y=t[84];let pe;t[85]!==M||t[86]!==U||t[87]!==se||t[88]!==Y?(pe=(0,Q.jsxs)(y,{children:[F,(0,Q.jsx)(b,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] h-[min(34rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:(0,Q.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col overflow-hidden [border-radius:inherit]`,onSubmit:M,children:[U,se,Y]})})]}),t[85]=M,t[86]=U,t[87]=se,t[88]=Y,t[89]=pe):pe=t[89];let me;return t[90]!==c||t[91]!==n||t[92]!==pe?(me=(0,Q.jsx)(x,{open:n,onOpenChange:c,children:pe}),t[90]=c,t[91]=n,t[92]=pe,t[93]=me):me=t[93],me}function Et(e){let t=(0,Z.c)(16),{rule:n,language:r,busy:i,onToggle:a}=e,o=it[r],s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),t[0]=s):s=t[0];let c;t[1]===n.statement?c=t[2]:(c=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-sm leading-6 text-fg`,children:n.statement}),t[1]=n.statement,t[2]=c);let l;t[3]!==n.status||t[4]!==o.disabled?(l=n.status===`disabled`?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.disabled}):null,t[3]=n.status,t[4]=o.disabled,t[5]=l):l=t[5];let u=n.status===`active`?o.disable:o.enable,d;t[6]!==i||t[7]!==a||t[8]!==u?(d=(0,Q.jsx)(C,{variant:`ghost`,className:`h-8`,disabled:i,onClick:a,children:u}),t[6]=i,t[7]=a,t[8]=u,t[9]=d):d=t[9];let f;t[10]!==l||t[11]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==c||t[14]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-t border-edge-subtle px-5 py-3 first:border-t-0`,children:[s,c,f]}),t[13]=c,t[14]=f,t[15]=p):p=t[15],p}function Dt(e){let t=(0,Z.c)(22),{item:n,language:r,busy:i,expanded:a,onToggle:o,editing:s,draft:c,onDraftChange:l,onEdit:u,onCancel:d,onReview:f,onDelete:p}=e,m=it[r],h=n.updatedAt??n.createdAt,g;t[0]!==r||t[1]!==h?(g=dt(h,r),t[0]=r,t[1]=h,t[2]=g):g=t[2];let _=g,v;t[3]===n.content?v=t[4]:(v=n.content.length>96||n.content.includes(`
2
- `),t[3]=n.content,t[4]=v);let y=v,b;return t[5]!==i||t[6]!==y||t[7]!==_||t[8]!==c||t[9]!==s||t[10]!==a||t[11]!==n.content||t[12]!==n.scope||t[13]!==r||t[14]!==d||t[15]!==p||t[16]!==l||t[17]!==u||t[18]!==f||t[19]!==o||t[20]!==m?(b=(0,Q.jsx)(`article`,{className:`group border-t border-edge-subtle px-5 py-4 first:border-t-0 sm:px-6`,children:s?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`textarea`,{"aria-label":m.correctionPlaceholder,disabled:i,value:c,onChange:e=>l(e.target.value),className:`min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none transition focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{variant:`ghost`,className:`h-8`,onClick:d,children:m.cancel}),(0,Q.jsx)(C,{variant:`primary`,className:`h-8`,disabled:!c.trim()||i,onClick:()=>f(`edit_and_approve`,c.trim()),children:m.save})]})]}):(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(ge,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-base leading-7 text-fg ${a?``:`line-clamp-2`}`,children:n.content}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`span`,{children:yt(n.scope,r)}),_?(0,Q.jsx)(`span`,{children:_}):null]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[y?(0,Q.jsx)(C,{variant:`ghost`,className:`size-11 p-0`,"aria-expanded":a,"aria-label":a?m.collapse:m.expand,onClick:o,children:(0,Q.jsx)(A,{className:`size-3.5 transition-transform ${a?`rotate-180`:``}`})}):null,(0,Q.jsx)(Me,{language:r,busy:i,statement:n.content,onEdit:u,onDelete:p})]})]})}),t[5]=i,t[6]=y,t[7]=_,t[8]=c,t[9]=s,t[10]=a,t[11]=n.content,t[12]=n.scope,t[13]=r,t[14]=d,t[15]=p,t[16]=l,t[17]=u,t[18]=f,t[19]=o,t[20]=m,t[21]=b):b=t[21],b}function Ot(){let e=m(e=>e.language),t=it[e],n=D(e=>e.setPageHeader),r=D(e=>e.clearPageHeader),[a,s]=i(),{data:c,error:l,isLoading:u,isValidating:p,mutate:h}=S(`/api/user-model`,ce),g=rt(a),[_,v]=(0,X.useState)(),[y,b]=(0,X.useState)(),[ee,x]=(0,X.useState)(``),[E,k]=(0,X.useState)(),[A,M]=(0,X.useState)(``),[N,I]=(0,X.useState)(``),[L,R]=(0,X.useState)(24),[B,q]=(0,X.useState)(),[re,le]=(0,X.useState)(!1),[de,J]=(0,X.useState)(!1),[Y,pe]=(0,X.useState)(`all`),[ye,Ce]=(0,X.useState)(`all`),[Te,Z]=(0,X.useState)(`idle`),Ee=(0,X.useRef)(void 0),De=e=>{e!==g&&s(t=>{let n=new URLSearchParams(t);return e===`overview`?n.delete(`tab`):n.set(`tab`,e),n})},Oe=(0,X.useCallback)(async()=>{if(!(Te===`refreshing`||p)){Ee.current&&window.clearTimeout(Ee.current),Z(`refreshing`),b(void 0),x(t.refreshing);try{await h(),Z(`success`),x(t.refreshComplete)}catch{Z(`error`),x(``),b(t.refreshFailed)}finally{Ee.current=window.setTimeout(()=>Z(`idle`),1600)}}},[p,h,Te,t]);(0,X.useEffect)(()=>()=>{Ee.current&&window.clearTimeout(Ee.current)},[]);let ke=p||Te===`refreshing`,Ae=ke?t.refreshing:Te===`success`?t.refreshComplete:Te===`error`?t.refreshFailed:t.refresh;(0,X.useEffect)(()=>(n({startExtra:null,main:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:t.pageTitle}),(0,Q.jsx)(`p`,{className:`hidden text-xs text-fg-muted sm:block`,children:t.pageSubtitle})]}),end:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(nt,{}),(0,Q.jsx)(C,{variant:`secondary`,className:`size-9 p-0 ${Te===`success`?`text-success`:Te===`error`?`text-danger`:``}`,disabled:ke,"aria-label":Ae,title:Ae,onClick:()=>void Oe(),children:ke?(0,Q.jsx)(V,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":`true`}):Te===`success`?(0,Q.jsx)(o,{className:`size-4`,"aria-hidden":`true`}):Te===`error`?(0,Q.jsx)(j,{className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(H,{className:`size-4`,"aria-hidden":`true`})})]})}),r),[r,ke,Te,Ae,Oe,n,t]);let je=async(n,r)=>{v(n),b(void 0),x(``);try{await r(),await h(),x(e===`zh`?`已更新`:`Updated`)}catch{b(t.actionFailed)}finally{v(void 0)}},Me=e=>{je(e.id,async()=>{await se(e.id,A.trim()),k(void 0),M(``)})},Ne=async e=>{v(`profile`),b(void 0),x(``);try{await fe(e),await h(),le(!1)}catch{b(t.actionFailed)}finally{v(void 0)}},Fe=async(n,r)=>{v(`priority:${n.id}`),b(void 0),x(``);try{await oe(n.id,r),await h(),J(!1),x(e===`zh`?`当前关注已更新`:`Current focus updated`)}catch{b(t.actionFailed)}finally{v(void 0)}},Ie=async n=>{v(`priority:create`),b(void 0),x(``);try{await K(n),await h(),J(!1),x(e===`zh`?`当前关注已设置`:`Current focus set`)}catch{b(t.actionFailed)}finally{v(void 0)}},Le=async n=>{v(`priority:${n.id}`),b(void 0),x(``);try{await oe(n.id,{status:`completed`}),await h(),J(!1),x(e===`zh`?`当前关注已结束`:`Current focus ended`)}catch{b(t.actionFailed)}finally{v(void 0)}};if(u)return(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-7xl space-y-5 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,Q.jsx)(w,{className:`h-10 w-72 rounded-xl`}),(0,Q.jsx)(w,{className:`h-72 rounded-xl`}),(0,Q.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-2`,children:[(0,Q.jsx)(w,{className:`h-80 rounded-xl`}),(0,Q.jsx)(w,{className:`h-80 rounded-xl`})]})]});if(l||!c)return(0,Q.jsxs)(`div`,{className:`mx-auto flex min-h-72 max-w-xl flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,Q.jsx)(G,{className:`size-6 text-fg-subtle`}),(0,Q.jsx)(`p`,{className:`text-sm text-danger`,children:t.loadFailed}),(0,Q.jsx)(C,{onClick:()=>void h(),children:t.tryAgain})]});let Re=[...c.assertions].sort((e,t)=>{let n=e.declaredImportance??e.inferredImportance;return(t.declaredImportance??t.inferredImportance)-n||t.recordedAt-e.recordedAt}).filter(e=>e.scope.type===`global`&&!at.has(e.predicate)),Be=pt(c),Ve=Be.callName||(e===`zh`?`你`:`You`),He=Re.filter(e=>!e.usable),Ue=Re.filter(e=>e.usable),We=Ue.filter(e=>e.authority===`user_explicit`).length,Ge=Ue.length-We,Ke=Re.filter(e=>Y===`explicit`?e.usable&&e.authority===`user_explicit`:Y===`learned`?e.usable&&e.authority!==`user_explicit`:Y===`pending`?!e.usable:!0),qe=c.priorities.filter(e=>e.status===`active`&&e.validTo>Date.now()),$=qe.find(e=>e.rank===`primary`)??qe[0],Je=xt($,c.goals,e),Ye=$?.targetType===`goal`?c.goals.find(e=>e.id===$.targetId):void 0,Xe=c.goals.filter(e=>e.status===`active`||e.status===`paused`).filter(e=>$?.targetType!==`goal`||e.id!==$.targetId),Ze=c.rules.filter(e=>e.status!==`archived`),Qe=[...Re].sort((e,t)=>t.recordedAt-e.recordedAt),$e=c.knowledge.filter(e=>e.status!==`archived`&&e.status!==`rejected`),et=N.trim().toLocaleLowerCase(),tt=$e.filter(e=>ye===`all`||e.kind===ye),st=tt.filter(t=>!et||t.content.toLocaleLowerCase().includes(et)||bt(t.kind,e).toLocaleLowerCase().includes(et)),ct=[{key:`identity`,title:t.identity,icon:me,items:Ke.filter(e=>e.kind===`identity`)},{key:`preferences`,title:t.preferences,icon:be,items:Ke.filter(e=>[`preference`,`value`,`routine`,`capability`].includes(e.kind))},{key:`relationships`,title:t.relationships,icon:ae,items:Ke.filter(e=>e.kind===`relationship`)},{key:`current`,title:t.currentState,icon:T,items:Ke.filter(e=>e.kind===`current_state`)},{key:`insights`,title:t.insights,icon:O,items:Ke.filter(e=>e.kind===`derived_insight`)}].filter(e=>e.items.length>0),lt=ot.map(e=>({kind:e,count:$e.filter(t=>t.kind===e).length})).filter(e=>e.count>0),ut=lt.slice(0,4),ft=ut.length===1?`grid-cols-1`:ut.length===2?`sm:grid-cols-2`:ut.length===3?`sm:grid-cols-3`:`sm:grid-cols-2 lg:grid-cols-4`,_t=st.slice(0,L),vt=ot.map(e=>({kind:e,items:_t.filter(t=>t.kind===e),totalCount:st.filter(t=>t.kind===e).length})).filter(e=>e.items.length>0),yt=[{id:`all`,label:t.allUnderstanding,count:Re.length},{id:`explicit`,label:t.explicit,count:We},{id:`learned`,label:t.learned,count:Ge},{id:`pending`,label:t.pending,count:He.length}],Ot=e=>{pe(e),De(`understanding`)},kt=e=>{Ce(e),I(``),R(24),De(`knowledge`)},At=t=>(0,Q.jsx)(ze,{item:t,language:e,busy:!!_,editing:E===t.id,draft:E===t.id?A:``,onDraftChange:M,onEdit:()=>{k(t.id),M(t.statement)},onCancel:()=>{k(void 0),M(``)},onDelete:()=>void je(t.id,()=>ue(t.id)),onCorrect:()=>Me(t)},t.id),jt=c.maintenance.lastRun?dt(c.maintenance.lastRun.finishedAt??c.maintenance.lastRun.startedAt,e,!0):null,Mt=c.maintenance.lastRun?c.maintenance.lastRun.status===`completed`?`${t.maintenanceComplete} ${jt}`:t.maintenanceFailed:t.maintenanceReady;return(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl space-y-8 px-4 py-7 sm:px-6 lg:px-8 lg:py-10`,children:[(0,Q.jsx)(we,{items:[{id:`overview`,label:t.overview,icon:O},{id:`understanding`,label:t.understanding,icon:me,count:Re.length},{id:`knowledge`,label:t.knowledge,icon:ge,count:$e.length}],activeTab:g,onChange:De,ariaLabel:t.pageTitle,tabIdPrefix:`understanding-tab`,panelIdPrefix:`understanding-panel`,className:`w-fit max-w-full gap-1 rounded-full bg-surface-panel p-1 shadow-surface`,buttonClassName:`rounded-full px-3.5 py-2`,selectedClassName:`bg-surface-active text-fg`,unselectedClassName:`text-fg-muted hover:bg-surface-hover hover:text-fg`}),(0,Q.jsx)(`p`,{role:`status`,className:`sr-only`,children:ee}),y?(0,Q.jsxs)(`div`,{role:`alert`,className:`flex items-center justify-between gap-3 rounded-xl border border-danger bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,Q.jsx)(`span`,{children:y}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>b(void 0),"aria-label":t.cancel,children:(0,Q.jsx)(f,{className:`size-4`})})]}):null,g===`overview`?(0,Q.jsxs)(`div`,{id:`understanding-panel-overview`,role:`tabpanel`,"aria-labelledby":`understanding-tab-overview`,className:`space-y-10`,children:[(0,Q.jsxs)(`section`,{"data-testid":`overview-hero`,className:`grid gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(20rem,24rem)] lg:gap-12`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 px-1 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold tracking-[0.16em] text-accent-fg`,children:[(0,Q.jsx)(O,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:t.portraitEyebrow})]}),(0,Q.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-5`,children:[(0,Q.jsx)(`div`,{className:`flex size-20 shrink-0 items-center justify-center rounded-[1.4rem] bg-surface-active text-xl font-semibold text-fg`,children:ht(Ve)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`truncate text-3xl font-semibold tracking-tight text-fg`,children:Ve}),(0,Q.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg-muted`,children:Be.role||t.notProvided})]}),(0,Q.jsxs)(C,{variant:`ghost`,className:`shrink-0`,onClick:()=>le(!0),children:[(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":`true`}),t.editProfile]})]}),(0,Q.jsx)(`p`,{className:`mt-5 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.portraitIntro}),(0,Q.jsx)(`dl`,{className:`mt-7 grid gap-x-8 gap-y-5 sm:grid-cols-3`,children:[{icon:W,label:t.locale,value:Be.locale?mt(Be.locale,e):t.notProvided},{icon:xe,label:t.timezone,value:Be.timezone||t.notProvided},{icon:me,label:t.pronouns,value:Be.pronouns||t.notProvided}].map(({icon:e,label:t,value:n})=>(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`dt`,{className:`flex items-center gap-1.5 text-xs text-fg-subtle`,children:[(0,Q.jsx)(e,{className:`size-3.5`,"aria-hidden":`true`}),t]}),(0,Q.jsx)(`dd`,{className:`mt-1.5 truncate text-sm font-medium text-fg`,children:n})]},t))})]}),(0,Q.jsxs)(`aside`,{"data-testid":`priority-panel`,className:`flex min-h-64 flex-col rounded-[1.4rem] bg-surface-panel p-6 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs font-semibold tracking-wide text-fg-subtle`,children:t.importantNow}),$?(0,Q.jsxs)(`p`,{className:`mt-1.5 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Q.jsx)(P,{className:`size-3.5`,"aria-hidden":`true`}),$.targetType===`goal`?t.prioritySourceGoal:t.prioritySourceWork]}):null]}),$&&Je?(0,Q.jsxs)(C,{variant:`ghost`,className:`h-8 shrink-0 px-2.5`,onClick:()=>J(!0),children:[(0,Q.jsx)(_e,{className:`size-3.5`,"aria-hidden":`true`}),t.editPriority]}):null]}),Je?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`mt-3 text-lg font-semibold leading-7 tracking-tight text-fg`,children:Je}),Ye?.desiredOutcome?(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Ye.desiredOutcome}):null,$?(0,Q.jsxs)(`p`,{className:`mt-auto flex items-center gap-1.5 pt-4 text-xs text-fg-subtle`,children:[(0,Q.jsx)(F,{className:`size-3.5`,"aria-hidden":`true`}),gt($.validTo,e)]}):null]}):(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 py-6 text-center text-sm text-fg-muted`,children:[(0,Q.jsx)(P,{className:`size-5 text-fg-subtle`}),(0,Q.jsx)(`span`,{children:t.noPriority}),(0,Q.jsxs)(C,{variant:`primary`,className:`mt-2`,onClick:()=>J(!0),children:[(0,Q.jsx)(d,{className:`size-4`,"aria-hidden":`true`}),t.addPriority]})]}),Xe.length?(0,Q.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.otherGoals}),(0,Q.jsx)(`div`,{className:`mt-2 space-y-2`,children:Xe.slice(0,3).map(e=>(0,Q.jsx)(`p`,{className:`text-sm text-fg`,children:e.title},e.id))})]}):null]})]}),(0,Q.jsx)(`section`,{"aria-label":t.understanding,className:`grid gap-2 sm:grid-cols-3`,children:[{icon:te,label:t.explicit,hint:t.explicitHint,count:We},{icon:G,label:t.learned,hint:t.learnedHint,count:Ge},{icon:o,label:t.pending,hint:t.pendingHint,count:He.length}].map(({icon:e,label:t,hint:n,count:r},i)=>(0,Q.jsxs)(`button`,{type:`button`,className:`group flex min-h-24 w-full cursor-pointer items-start gap-3 rounded-2xl px-4 py-4 text-left transition-colors hover:bg-surface-panel focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:px-5`,onClick:()=>Ot(i===0?`explicit`:i===1?`learned`:`pending`),"aria-label":`${t}: ${r}`,children:[(0,Q.jsx)(e,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`p`,{className:`text-sm font-medium text-fg`,children:[(0,Q.jsx)(`span`,{className:`mr-1.5 text-lg tabular-nums`,children:r}),t]}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:n})]}),(0,Q.jsx)(U,{className:`mt-1 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted motion-reduce:transform-none`,"aria-hidden":`true`})]},t))}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-10 lg:grid-cols-2 lg:gap-8`,children:[(0,Q.jsx)(St,{title:t.recent,hint:t.recentHint,action:(0,Q.jsx)(C,{variant:`ghost`,className:`h-8 shrink-0`,onClick:()=>De(`understanding`),children:t.seeAll}),children:Qe.length?(0,Q.jsx)(`div`,{children:Pe(Qe.slice(0,3),e).map(({label:e,items:t})=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`px-5 pb-1 pt-4 text-xs font-medium text-fg-muted`,children:e}),(0,Q.jsx)(`div`,{children:t.map(At)})]},e))}):(0,Q.jsx)(Ct,{icon:(0,Q.jsx)(G,{className:`size-5`}),children:t.emptyGroup})}),(0,Q.jsx)(St,{title:t.howWeWork,hint:t.howWeWorkHint,children:Ze.length?Ze.slice(0,3).map(t=>(0,Q.jsx)(Et,{rule:t,language:e,busy:_===t.id,onToggle:()=>void je(t.id,()=>ie(t.id,t.status===`active`?`disabled`:`active`))},t.id)):(0,Q.jsx)(Ct,{icon:(0,Q.jsx)(ae,{className:`size-5`}),children:t.noRules})})]}),(0,Q.jsx)(St,{title:t.workMemory,hint:t.workMemoryHint,action:(0,Q.jsx)(C,{variant:`ghost`,className:`h-8 shrink-0`,onClick:()=>De(`knowledge`),children:t.seeAll}),children:lt.length?(0,Q.jsx)(`div`,{"data-testid":`memory-summary-grid`,className:`grid gap-3 bg-surface-base ${ft}`,children:ut.map(({kind:t,count:n})=>(0,Q.jsxs)(`button`,{type:`button`,className:`group flex min-h-28 cursor-pointer items-start justify-between rounded-2xl bg-surface-panel px-5 py-5 text-left transition-colors hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>kt(t),"aria-label":`${bt(t,e)}: ${n}`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-2xl font-semibold tabular-nums text-fg`,children:n}),(0,Q.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:bt(t,e)})]}),(0,Q.jsx)(U,{className:`mt-1 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted motion-reduce:transform-none`,"aria-hidden":`true`})]},t))}):(0,Q.jsx)(Ct,{icon:(0,Q.jsx)(Se,{className:`size-5`}),children:t.noKnowledge})}),(0,Q.jsx)(`footer`,{className:`flex items-center gap-4 px-1 pb-2 text-xs text-fg-subtle`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Q.jsx)(H,{className:`size-3.5`,"aria-hidden":`true`}),Mt]})})]}):null,g===`understanding`?(0,Q.jsxs)(`div`,{id:`understanding-panel-understanding`,role:`tabpanel`,"aria-labelledby":`understanding-tab-understanding`,className:`space-y-10`,children:[(0,Q.jsxs)(`div`,{className:`px-1 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(G,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:t.aboutYouTitle}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:t.aboutYouHint})]})]}),(0,Q.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,role:`group`,"aria-label":t.understandingFilterHint,children:yt.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":Y===e.id,className:`touch-target inline-flex min-h-9 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${Y===e.id?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>pe(e.id),children:[e.label,(0,Q.jsx)(`span`,{className:`tabular-nums text-fg-subtle`,children:e.count})]},e.id))})]}),ct.length?ct.map(({key:e,title:t,icon:n,items:r})=>(0,Q.jsx)(St,{title:t,action:(0,Q.jsx)(n,{className:`size-4 text-fg-subtle`,"aria-hidden":`true`}),children:(0,Q.jsx)(`div`,{children:r.map(At)})},e)):(0,Q.jsx)(`div`,{className:`rounded-2xl bg-surface-panel`,children:(0,Q.jsx)(Ct,{icon:(0,Q.jsx)(G,{className:`size-5`}),children:t.emptyGroup})})]}):null,g===`knowledge`?(0,Q.jsxs)(`div`,{id:`understanding-panel-knowledge`,role:`tabpanel`,"aria-labelledby":`understanding-tab-knowledge`,className:`space-y-8`,children:[(0,Q.jsxs)(`div`,{className:`px-1 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:ye===`all`?t.allMemory:bt(ye,e)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:[tt.length,` `,t.items,` · `,t.memoryLibraryHint]})]}),(0,Q.jsxs)(`label`,{className:`relative block sm:w-80`,children:[(0,Q.jsx)(z,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:t.searchPlaceholder}),(0,Q.jsx)(`input`,{type:`search`,value:N,onChange:e=>{I(e.target.value),R(24)},placeholder:t.searchPlaceholder,className:`h-10 w-full rounded-xl border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,role:`group`,"aria-label":t.memoryFilterHint,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":ye===`all`,className:`touch-target inline-flex min-h-9 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${ye===`all`?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>Ce(`all`),children:[t.allMemory,(0,Q.jsx)(`span`,{className:`tabular-nums text-fg-subtle`,children:$e.length})]}),lt.map(({kind:t,count:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":ye===t,className:`touch-target inline-flex min-h-9 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${ye===t?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>Ce(t),children:[bt(t,e),(0,Q.jsx)(`span`,{className:`tabular-nums text-fg-subtle`,children:n})]},t))]})]}),st.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`space-y-8`,children:vt.map(({kind:t,items:n,totalCount:r})=>(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-2xl bg-surface-panel`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center justify-between px-5 pb-1 pt-4 sm:px-6`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:bt(t,e)}),(0,Q.jsx)(`span`,{className:`text-xs tabular-nums text-fg-subtle`,children:r})]}),(0,Q.jsx)(`div`,{children:n.map(t=>(0,Q.jsx)(Dt,{item:t,language:e,busy:!!_,expanded:B===t.id,onToggle:()=>q(e=>e===t.id?void 0:t.id),editing:E===`knowledge:${t.id}`,draft:A,onDraftChange:M,onEdit:()=>{k(`knowledge:${t.id}`),M(t.content)},onCancel:()=>{k(void 0),M(``)},onDelete:()=>void je(t.id,()=>he(t.id)),onReview:(e,n)=>void je(t.id,async()=>{await ve(t,e,n),k(void 0),M(``)})},t.id))})]},t))}),st.length>L?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(C,{onClick:()=>R(e=>e+24),children:t.showMore})}):null]}):(0,Q.jsx)(`div`,{className:`rounded-2xl bg-surface-panel`,children:(0,Q.jsx)(Ct,{icon:(0,Q.jsx)(z,{className:`size-5`}),children:N.trim()?t.noKnowledgeMatch:t.noKnowledge})})]}):null,(0,Q.jsx)(wt,{open:re,profile:Be,language:e,saving:_===`profile`,onOpenChange:le,onSave:e=>void Ne(e)}),(0,Q.jsx)(Tt,{open:de,priority:$,title:Je??``,outcome:Ye?.desiredOutcome,language:e,saving:_===($?`priority:${$.id}`:`priority:create`),onOpenChange:J,onSave:e=>$?void Fe($,e):void Ie(e),onEnd:$?()=>void Le($):void 0})]})}export{Ot as UserModelPage};