@xopcai/xopc 0.0.485 → 0.0.486

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 (167) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/server/chunks.bin +982 -949
  4. package/dist/gateway/server/chunks.json +1 -1
  5. package/dist/gateway/static/root/assets/agent-run-error-parser-DsXmcKt-.js +1 -0
  6. package/dist/gateway/static/root/assets/{api-CGs641OT.js → api-CGrHK9ij.js} +1 -1
  7. package/dist/gateway/static/root/assets/{apps-page-CH9wENBj.js → apps-page-6xeWvMpF.js} +1 -1
  8. package/dist/gateway/static/root/assets/{automations-page-uY_wmZY1.js → automations-page-BLFBqaPX.js} +1 -1
  9. package/dist/gateway/static/root/assets/{automations-workspace-DyQq55Rh.js → automations-workspace-DiO3Iyuj.js} +2 -2
  10. package/dist/gateway/static/root/assets/{capabilities-abgigXV1.js → capabilities-CW-vdkz6.js} +1 -1
  11. package/dist/gateway/static/root/assets/{capabilities-BaKHutgZ.js → capabilities-DZrjA95P.js} +1 -1
  12. package/dist/gateway/static/root/assets/capabilities-page-DQrfkrBA.js +2 -0
  13. package/dist/gateway/static/root/assets/{capabilities-settings-panel-BOwbZn9X.js → capabilities-settings-panel-DIT2dvtc.js} +1 -1
  14. package/dist/gateway/static/root/assets/{channels-DlnXbcOj.js → channels-Dcr5dgqw.js} +1 -1
  15. package/dist/gateway/static/root/assets/{chat-page-3fVhP77N.js → chat-page-DWZCzxY7.js} +31 -31
  16. package/dist/gateway/static/root/assets/{chat-terminal-dock-DE8j-K9d.js → chat-terminal-dock-DCUuwiTt.js} +1 -1
  17. package/dist/gateway/static/root/assets/composer-payload-handoff-a0quQ25p.js +1 -0
  18. package/dist/gateway/static/root/assets/connected-providers-grid-BJKEp0SE.js +1 -0
  19. package/dist/gateway/static/root/assets/{connectors-page-BJm1jjct.js → connectors-page-BteRI1XM.js} +1 -1
  20. package/dist/gateway/static/root/assets/{extension-debug-page-D3X7SlzG.js → extension-debug-page-4jJ1uVQJ.js} +1 -1
  21. package/dist/gateway/static/root/assets/{extension-iframe-host-CIAq7PSn.js → extension-iframe-host-CJV5JETm.js} +1 -1
  22. package/dist/gateway/static/root/assets/{extension-message-router-B2wbucV7.js → extension-message-router-B4I-Y6qs.js} +1 -1
  23. package/dist/gateway/static/root/assets/{extension-page-qwY7r1_p.js → extension-page-lc7a84nG.js} +1 -1
  24. package/dist/gateway/static/root/assets/{extension-provider-DFcRbTHI.js → extension-provider-D8_mIBI0.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-settings-page-Cpnh9lcZ.js → extension-settings-page-Uw2lfWRh.js} +1 -1
  26. package/dist/gateway/static/root/assets/{home-page-BusNFHe-.js → home-page-mSRCU81k.js} +4 -4
  27. package/dist/gateway/static/root/assets/{home-task-actions-C8Fi6GBq.js → home-task-actions-_ZAc57Y7.js} +1 -1
  28. package/dist/gateway/static/root/assets/{index-790PGhZb.js → index-CJAEAcZV.js} +7 -7
  29. package/dist/gateway/static/root/assets/{local-app-workbench-page-B9uSL1Mi.js → local-app-workbench-page-C3Lqi8E1.js} +1 -1
  30. package/dist/gateway/static/root/assets/{note-detail-panel-Bwm_aehq.js → note-detail-panel-uc-5k3a2.js} +3 -3
  31. package/dist/gateway/static/root/assets/{notes-page-DkZWV3Ds.js → notes-page-RPfvHnl6.js} +1 -1
  32. package/dist/gateway/static/root/assets/{page-context-capture-button-BXSBeGms.js → page-context-capture-button-CVHz9b6c.js} +1 -1
  33. package/dist/gateway/static/root/assets/{personal-page-cauym9hr.js → personal-page-Dt1d3tQT.js} +1 -1
  34. package/dist/gateway/static/root/assets/{personal-profile-settings-TcI0Zfwr.js → personal-profile-settings-XiT1MgTK.js} +1 -1
  35. package/dist/gateway/static/root/assets/{personal-settings-panel-BJ46T7ZO.js → personal-settings-panel-bcw04REt.js} +1 -1
  36. package/dist/gateway/static/root/assets/{preview-runtime-C1U57WSM.js → preview-runtime-FtWOW5i4.js} +1 -1
  37. package/dist/gateway/static/root/assets/{product-automation-feedback-GA_YPLkr.js → product-automation-feedback-DdFoCDzG.js} +1 -1
  38. package/dist/gateway/static/root/assets/product-preview-content-B3mzl6-f.js +1 -0
  39. package/dist/gateway/static/root/assets/product-preview-modal-5kTp_7Qk.js +2 -0
  40. package/dist/gateway/static/root/assets/project-detail-page-DGPfKx5M.js +7 -0
  41. package/dist/gateway/static/root/assets/{projects-page-BHQxQGTd.js → projects-page-C-9x23LR.js} +1 -1
  42. package/dist/gateway/static/root/assets/route-preload-CzorjVc9.js +2 -0
  43. package/dist/gateway/static/root/assets/routine-panel-n4IstC8Y.js +2 -0
  44. package/dist/gateway/static/root/assets/session-manager-C2MCS4C5.js +28 -0
  45. package/dist/gateway/static/root/assets/{settings-page-Cd9WZ-Ac.js → settings-page-DsM_f07M.js} +1 -1
  46. package/dist/gateway/static/root/assets/{share-preview-page-Di5_ukH8.js → share-preview-page-C32Mq-BY.js} +1 -1
  47. package/dist/gateway/static/root/assets/{shares-settings-CirGM67m.js → shares-settings-BDGbs8wz.js} +1 -1
  48. package/dist/gateway/static/root/assets/space-page-DwyuUvI3.js +2 -0
  49. package/dist/gateway/static/root/assets/task-copy-CtcqCQ78.js +1 -0
  50. package/dist/gateway/static/root/assets/task-detail-page-DdCpNW8K.js +3 -0
  51. package/dist/gateway/static/root/assets/{task-header-title-qzNctGl5.js → task-header-title-CLt_lmjb.js} +1 -1
  52. package/dist/gateway/static/root/assets/task-result-presentation-CgvcqEMD.js +1 -0
  53. package/dist/gateway/static/root/assets/task-run-issue-notice-8FX876PP.js +1 -0
  54. package/dist/gateway/static/root/assets/tasks-CvOAtEHv.js +1 -0
  55. package/dist/gateway/static/root/assets/turn-outcome-Dtw6OgwL.js +1 -0
  56. package/dist/gateway/static/root/assets/{use-composer-attachments-DJsIzJ1c.js → use-composer-attachments-BEuyorVm.js} +1 -1
  57. package/dist/gateway/static/root/assets/{use-file-preview-expanded-BFF2vXm5.js → use-file-preview-expanded-Cehu0745.js} +1 -1
  58. package/dist/gateway/static/root/assets/use-personal-work-B25WRGHj.js +1 -0
  59. package/dist/gateway/static/root/assets/{use-realtime-voice-9OvLwHzk.js → use-realtime-voice-CV3GIt_T.js} +1 -1
  60. package/dist/gateway/static/root/assets/{use-workspace-tree-LCIT1H-D.js → use-workspace-tree-C0C861cb.js} +1 -1
  61. package/dist/gateway/static/root/assets/{voice-settings-j8o-hGTm.js → voice-settings-JpPo3BvX.js} +1 -1
  62. package/dist/gateway/static/root/assets/workspace-api-CQOuWbVv.js +2 -0
  63. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-DwVWTehC.js → workspace-file-preview-dialog-CmMueTmW.js} +1 -1
  64. package/dist/gateway/static/root/index.html +29 -27
  65. package/dist/package.js +1 -1
  66. package/dist/packages/gateway-contract/src/index.js +3 -1
  67. package/dist/packages/gateway-contract/src/notifications.js +1 -8
  68. package/dist/packages/gateway-contract/src/task-display.js +9 -2
  69. package/dist/packages/gateway-contract/src/task-lifecycle.js +1 -0
  70. package/dist/packages/gateway-contract/src/task-research-result.js +2 -1
  71. package/dist/packages/gateway-contract/src/tasks.js +6 -1
  72. package/dist/packages/gateway-contract/src/user-message-text.js +64 -0
  73. package/dist/src/agent/embedded/run-for-session.js +27 -28
  74. package/dist/src/agent/embedded/session-runner.js +14 -1
  75. package/dist/src/agent/fallback/candidates.d.ts +1 -0
  76. package/dist/src/agent/fallback/candidates.js +1 -1
  77. package/dist/src/agent/image/generation/provider-registry.js +3 -1
  78. package/dist/src/agent/models/manager.d.ts +1 -1
  79. package/dist/src/agent/models/manager.js +2 -1
  80. package/dist/src/agent/models/turn-candidates.d.ts +16 -0
  81. package/dist/src/agent/models/turn-candidates.js +55 -0
  82. package/dist/src/agent/service.d.ts +1 -0
  83. package/dist/src/agent/service.js +12 -0
  84. package/dist/src/agent/skills/installer.js +2 -2
  85. package/dist/src/auth/credentials.js +3 -1
  86. package/dist/src/auth/oauth/index.d.ts +0 -1
  87. package/dist/src/auth/oauth/index.js +1 -4
  88. package/dist/src/auth/oauth/registry.js +0 -4
  89. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  90. package/dist/src/cli/command-manifest.js +1 -1
  91. package/dist/src/cli/commands/auth.js +4 -2
  92. package/dist/src/cli/commands/models.js +12 -10
  93. package/dist/src/config/models-json.js +1 -2
  94. package/dist/src/gateway/agent-reactions/reaction.d.ts +1 -2
  95. package/dist/src/gateway/agent-reactions/reaction.js +10 -21
  96. package/dist/src/gateway/custom-image-providers.js +4 -1
  97. package/dist/src/gateway/hono/oauth.js +3 -0
  98. package/dist/src/gateway/hono/routes/device-push.js +55 -15
  99. package/dist/src/gateway/hono/routes/home.js +1 -1
  100. package/dist/src/gateway/hono/routes/mobile-mcp-setup.js +49 -29
  101. package/dist/src/gateway/hono/routes/notifications.js +12 -1
  102. package/dist/src/gateway/hono/routes/sessions.js +1 -13
  103. package/dist/src/gateway/security/gateway-scopes.js +1 -0
  104. package/dist/src/gateway/service/run-gateway-agent.js +2 -13
  105. package/dist/src/gateway/service.js +84 -64
  106. package/dist/src/home-intelligence/host.js +5 -5
  107. package/dist/src/local-apps/capabilities/projections.d.ts +5 -5
  108. package/dist/src/notifications/device-store.d.ts +3 -0
  109. package/dist/src/notifications/device-store.js +14 -1
  110. package/dist/src/notifications/platform-push.d.ts +17 -0
  111. package/dist/src/notifications/platform-push.js +58 -0
  112. package/dist/src/notifications/service.d.ts +2 -2
  113. package/dist/src/notifications/service.js +26 -12
  114. package/dist/src/notifications/store.d.ts +1 -1
  115. package/dist/src/notifications/store.js +3 -2
  116. package/dist/src/providers/env-keys.js +0 -1
  117. package/dist/src/providers/index.js +1 -7
  118. package/dist/src/providers/model-catalog-sync-service.js +3 -1
  119. package/dist/src/providers/model-registry.js +6 -2
  120. package/dist/src/providers/presentation.js +1 -2
  121. package/dist/src/providers/provider-policy.js +2 -1
  122. package/dist/src/session/client-history.js +3 -3
  123. package/dist/src/session/user-message-display.js +3 -2
  124. package/dist/src/storage/sqlite/agent-reaction-repository.d.ts +2 -4
  125. package/dist/src/storage/sqlite/agent-reaction-repository.js +18 -13
  126. package/dist/src/storage/sqlite/device-access-repository.js +2 -1
  127. package/dist/src/tasks/capabilities/write.d.ts +2 -0
  128. package/dist/src/tasks/home-query-service.js +2 -1
  129. package/dist/src/tasks/task-contract-planner.js +1 -0
  130. package/dist/src/tasks/task-conversation-summary.d.ts +1 -1
  131. package/dist/src/tasks/task-delivery-checks.d.ts +12 -0
  132. package/dist/src/tasks/task-delivery-checks.js +91 -0
  133. package/dist/src/tasks/task-final-reply.d.ts +3 -1
  134. package/dist/src/tasks/task-final-reply.js +17 -4
  135. package/dist/src/tasks/task-model-call.js +4 -2
  136. package/dist/src/tasks/task-origin-repository.d.ts +1 -1
  137. package/dist/src/tasks/task-read-model-projector.js +24 -7
  138. package/dist/src/tasks/task-research-result.js +12 -27
  139. package/dist/src/tasks/task-result-delivery-repository.js +3 -2
  140. package/dist/src/tasks/task-retry-service.js +2 -1
  141. package/dist/src/tasks/task-run-coordinator.js +14 -4
  142. package/dist/src/tasks/task-run-dispatcher.d.ts +1 -0
  143. package/dist/src/tasks/task-run-dispatcher.js +78 -48
  144. package/dist/src/tasks/task-run-repository.js +1 -1
  145. package/package.json +1 -1
  146. package/dist/gateway/static/root/assets/capabilities-page-WCl7Fdce.js +0 -2
  147. package/dist/gateway/static/root/assets/composer-payload-handoff-ClWsunJ2.js +0 -1
  148. package/dist/gateway/static/root/assets/connected-providers-grid-BgW-ioIt.js +0 -1
  149. package/dist/gateway/static/root/assets/product-preview-content-BOq3gtSJ.js +0 -1
  150. package/dist/gateway/static/root/assets/product-preview-modal-DIh_CsXp.js +0 -2
  151. package/dist/gateway/static/root/assets/project-detail-page-D9WKZe3z.js +0 -7
  152. package/dist/gateway/static/root/assets/route-preload-DF8LOfKW.js +0 -2
  153. package/dist/gateway/static/root/assets/routine-panel-Bfbiz0IN.js +0 -2
  154. package/dist/gateway/static/root/assets/session-manager-DUWeBdeG.js +0 -28
  155. package/dist/gateway/static/root/assets/space-page-DlJB7GT1.js +0 -2
  156. package/dist/gateway/static/root/assets/task-detail-page-BFa0Px-B.js +0 -3
  157. package/dist/gateway/static/root/assets/task-run-issue-notice-CGrUMy0s.js +0 -1
  158. package/dist/gateway/static/root/assets/tasks-CwyNaa-j.js +0 -1
  159. package/dist/gateway/static/root/assets/turn-outcome-BSbEJx8h.js +0 -1
  160. package/dist/gateway/static/root/assets/use-personal-work-B1DWeBnm.js +0 -1
  161. package/dist/gateway/static/root/assets/workspace-api-BuNWyNvA.js +0 -2
  162. package/dist/src/auth/oauth/google-antigravity.d.ts +0 -4
  163. package/dist/src/auth/oauth/google-antigravity.js +0 -9
  164. package/dist/src/auth/oauth/google-oauth/google-antigravity.d.ts +0 -25
  165. package/dist/src/auth/oauth/google-oauth/google-antigravity.js +0 -309
  166. package/dist/src/notifications/harmony-push.d.ts +0 -27
  167. package/dist/src/notifications/harmony-push.js +0 -96
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{_ as i,d as a,f as ee,h as o}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{f as s,l as c,n as l}from"./locale-store-CHjsq5NR.js";import{t as u}from"./messages-C7QSnTdg.js";import{t as d}from"./archive-Dz0hferG.js";import{t as f}from"./arrow-left-D880xG-P.js";import{t as p}from"./arrow-right-DSSvoX71.js";import{t as m}from"./arrow-up-D5ZtR1QT.js";import{c as h}from"./product-automation-feedback-GA_YPLkr.js";import{N as g,R as _}from"./recording-upload-plrQDkLa.js";import{t as v}from"./calendar-days-hw_Y-g-s.js";import{t as te}from"./chevron-down-ccbiQQz_.js";import{t as ne}from"./popover-select-hRG1EzAY.js";import{t as re}from"./ellipsis-0k4rZLoy.js";import{t as y}from"./file-text-D12HbeVy.js";import{t as ie}from"./folder-CN-pC3XL.js";import{D as b,E as x,M as S,_ as C,g as w,i as T,p as E,s as D}from"./notes-api-D5SvfybU.js";import{n as O,t as k}from"./star-BuMAkjC9.js";import{t as ae}from"./loader-circle-CifKLtgG.js";import{z as A}from"./markdown-view-ihzUc4ud.js";import{t as oe}from"./mic-CuUb7zc-.js";import{n as se,t as j}from"./scan-search-CSIGkseh.js";import{t as M}from"./paperclip-f1HujQY1.js";import{t as ce}from"./plus-Q2yW6OE7.js";import{t as le}from"./search-DA7gz22f.js";import{t as ue}from"./sparkles-DHlfQFAF.js";import{t as de}from"./trash-2-DusmjVPV.js";import{t as N}from"./x-B_N4OPjy.js";import{t as P}from"./cn-0WouolD0.js";import{t as F}from"./skeleton-DzdOeGYz.js";import{i as fe}from"./vendor-swr-CdRzEUwF.js";import{r as pe}from"./app-chrome-BeB4KgOf.js";import{t as me}from"./page-header-store-NP7MCIaP.js";import{t as he}from"./sliding-tab-list-CmcrqRzN.js";import{t as ge}from"./confirm-dialog-MHCmEEUZ.js";import{n as _e}from"./index.module-Cd9ENXfk.js";import{l as ve,m as ye,o as be,r as xe,t as Se}from"./dist-DaFr5KMw.js";import{a as Ce,i as we,t as I}from"./note-detail-panel-Bwm_aehq.js";var L=e(t(),1),R=n();async function Te(e){e.note??=await T({title:e.title,markdown:e.markdown,projectId:e.projectId,channel:`web`},e.requestId);let t=e.note.id;for(let n=e.attachments.length;n<e.files.length;n++)e.attachments.push(await b(t,e.files[n],`${e.requestId}:file:${n}`));if(e.attachments.length){let n=e.attachments.map(e=>`[${e.fileName.replace(/[\\[\]]/g,`\\$&`).replace(/[\r\n]/g,` `)}](${S(t,e.id)})`);e.note=await x(t,{markdown:`${e.markdown}\n\n## ${e.materialHeading}\n\n${n.join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{_ as i,d as a,f as ee,h as o}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{f as s,l as c,n as l}from"./locale-store-CHjsq5NR.js";import{t as u}from"./messages-C7QSnTdg.js";import{t as d}from"./archive-Dz0hferG.js";import{t as f}from"./arrow-left-D880xG-P.js";import{t as p}from"./arrow-right-DSSvoX71.js";import{t as m}from"./arrow-up-D5ZtR1QT.js";import{c as h}from"./product-automation-feedback-DdFoCDzG.js";import{N as g,R as _}from"./recording-upload-plrQDkLa.js";import{t as v}from"./calendar-days-hw_Y-g-s.js";import{t as te}from"./chevron-down-ccbiQQz_.js";import{t as ne}from"./popover-select-hRG1EzAY.js";import{t as re}from"./ellipsis-0k4rZLoy.js";import{t as y}from"./file-text-D12HbeVy.js";import{t as ie}from"./folder-CN-pC3XL.js";import{D as b,E as x,M as S,_ as C,g as w,i as T,p as E,s as D}from"./notes-api-D5SvfybU.js";import{n as O,t as k}from"./star-BuMAkjC9.js";import{t as ae}from"./loader-circle-CifKLtgG.js";import{z as A}from"./markdown-view-ihzUc4ud.js";import{t as oe}from"./mic-CuUb7zc-.js";import{n as se,t as j}from"./scan-search-CSIGkseh.js";import{t as M}from"./paperclip-f1HujQY1.js";import{t as ce}from"./plus-Q2yW6OE7.js";import{t as le}from"./search-DA7gz22f.js";import{t as ue}from"./sparkles-DHlfQFAF.js";import{t as de}from"./trash-2-DusmjVPV.js";import{t as N}from"./x-B_N4OPjy.js";import{t as P}from"./cn-0WouolD0.js";import{t as F}from"./skeleton-DzdOeGYz.js";import{i as fe}from"./vendor-swr-CdRzEUwF.js";import{r as pe}from"./app-chrome-BeB4KgOf.js";import{t as me}from"./page-header-store-NP7MCIaP.js";import{t as he}from"./sliding-tab-list-CmcrqRzN.js";import{t as ge}from"./confirm-dialog-MHCmEEUZ.js";import{n as _e}from"./index.module-Cd9ENXfk.js";import{l as ve,m as ye,o as be,r as xe,t as Se}from"./dist-DaFr5KMw.js";import{a as Ce,i as we,t as I}from"./note-detail-panel-uc-5k3a2.js";var L=e(t(),1),R=n();async function Te(e){e.note??=await T({title:e.title,markdown:e.markdown,projectId:e.projectId,channel:`web`},e.requestId);let t=e.note.id;for(let n=e.attachments.length;n<e.files.length;n++)e.attachments.push(await b(t,e.files[n],`${e.requestId}:file:${n}`));if(e.attachments.length){let n=e.attachments.map(e=>`[${e.fileName.replace(/[\\[\]]/g,`\\$&`).replace(/[\r\n]/g,` `)}](${S(t,e.id)})`);e.note=await x(t,{markdown:`${e.markdown}\n\n## ${e.materialHeading}\n\n${n.join(`
2
2
 
3
3
  `)}`})}return{noteId:t,conversationId:(await C(t,{projectId:e.projectId})).conversationId}}function z(e,t,n){let r=new URLSearchParams({draft:n.replace(`{{id}}`,t),autoSend:`1`});return`/chat/${encodeURIComponent(e)}?${r}`}var B=r(),V={meeting:h,requirements:y,research:j,weekly:v};function Ee({projects:e,projectId:t,onProjectChange:n,onCreated:r,labels:i,projectsLoading:a,projectsError:o}){let s=i.home,c=ee(),[l,u]=(0,L.useState)(``),[d,f]=(0,L.useState)(null),[p,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)([]),[v,re]=(0,L.useState)(!1),[y,b]=(0,L.useState)(null),[x,S]=(0,L.useState)(``),C=(0,L.useRef)(null),w=(0,L.useRef)(!1),T=(0,L.useRef)(null),E=(0,L.useRef)(null),D=v||!!C.current,O=d?s.templateOptions[d]:null,k=!!(l.trim()||g.length);async function A(){if(!(w.current||!k&&!C.current)){w.current=!0,re(!0),b(null),C.current??={requestId:crypto.randomUUID(),title:l.trim().split(`
4
4
  `)[0]?.slice(0,80)||O?.label||i.titlePlaceholder,markdown:`## ${s.requestHeading}\n\n${O?`${O.prompt}\n`:``}${l.trim()}`,projectId:t||void 0,files:[...g],attachments:[],materialHeading:s.materialsHeading};try{let e=await Te(C.current);r(),c(z(e.conversationId,e.noteId,s.agentPrompt))}catch(e){C.current.note&&r(),b(e instanceof Error?e.message:i.quickCaptureFailedHint)}finally{w.current=!1,re(!1)}}}function oe(){C.current=null,b(null),u(``),_([]),f(null),h(!1),E.current?.focus()}return(0,B.jsxs)(`section`,{"aria-label":s.askLabel,children:[(0,B.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),A()},className:`relative rounded-xl border border-edge bg-surface-panel p-4 focus-within:border-accent/60 sm:p-5`,children:[(0,B.jsxs)(`fieldset`,{disabled:D,className:`min-w-0`,children:[(0,B.jsxs)(`label`,{htmlFor:`notes-home-prompt`,className:`flex items-center gap-2 text-xs font-medium text-accent-fg`,children:[(0,B.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),s.askLabel]}),(0,B.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.agentResultHint}),O?(0,B.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft px-3 py-2 text-xs leading-5 text-accent-fg`,children:[(0,B.jsxs)(`p`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`font-medium`,children:[O.label,` · `]}),O.prompt.split(`
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,f as i}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{l as a,n as o}from"./locale-store-CHjsq5NR.js";import{t as s}from"./messages-C7QSnTdg.js";import{t as c}from"./file-text-D12HbeVy.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./session-manager-DUWeBdeG.js";import{t as d}from"./capabilities-abgigXV1.js";import{r as f}from"./dist-DaFr5KMw.js";import{n as p,t as m}from"./page-context-draft-Bk7jVvAG.js";var h=e(t(),1),g=n();function _({resource:e,selection:t,label:n,disabled:_=!1,presentation:v=`button`}){let y=s(o(e=>e.language)).chat.pageContext,b=i(),x=r().key,[S,C]=(0,h.useState)(!1),[w,T]=(0,h.useState)(!1),E=(0,h.useRef)(!1),D=(0,h.useRef)(0),O=a(e=>e.baseUrl),k=a(e=>e.conversationId);(0,h.useEffect)(()=>(E.current=!1,C(!1),T(!1),()=>{D.current+=1}),[x,e.kind,e.id,e.revision,t?.text,t?.draft,_,O,k]);async function A(){if(_||E.current)return;E.current=!0,C(!0),T(!1);let n=D.current,r=()=>D.current===n&&a.getState().baseUrl===O&&a.getState().conversationId===k;try{let n=p.capture({title:``,text:``,resourceRefs:[e],selection:t}),i=await d(`xopc.context.resolve`,n.envelope);if(!r())return;let a=i.resources[0];if(i.resources.length!==1||JSON.stringify(i.snapshot)!==JSON.stringify(n.envelope)||a.reference.kind!==e.kind||a.reference.id!==e.id||a.reference.revision!==e.revision)throw Error(`Context mismatch`);n.title=a.title,n.preview=a.text,n.truncated=a.truncated;let o=await new u().createSession();if(!r())return;if(!p.put(m(O,k,o.key),n))throw Error(`Context draft limit reached`);b(`/chat/${encodeURIComponent(o.key)}`)}catch{r()&&T(!0)}finally{D.current===n&&(E.current=!1,C(!1))}}let j=(0,g.jsxs)(`button`,{type:`button`,disabled:_||S,onClick:()=>void A(),"aria-busy":S,title:_?y.unavailable:n??y.capture,className:v===`menu`?`flex min-h-11 w-full items-center gap-2 rounded-md px-3 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover disabled:opacity-40`:`inline-flex min-h-9 items-center gap-1.5 rounded-lg border border-edge px-2.5 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[S?(0,g.jsx)(l,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,g.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),n??y.capture]});return(0,g.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[v===`menu`?(0,g.jsx)(f,{asChild:!0,disabled:_||S,onSelect:e=>e.preventDefault(),children:j}):j,w?(0,g.jsx)(`p`,{role:`alert`,className:`max-w-72 text-xs text-danger`,children:y.unavailable}):null]})}export{_ as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,f as i}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{l as a,n as o}from"./locale-store-CHjsq5NR.js";import{t as s}from"./messages-C7QSnTdg.js";import{t as c}from"./file-text-D12HbeVy.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./session-manager-C2MCS4C5.js";import{t as d}from"./capabilities-CW-vdkz6.js";import{r as f}from"./dist-DaFr5KMw.js";import{n as p,t as m}from"./page-context-draft-Bk7jVvAG.js";var h=e(t(),1),g=n();function _({resource:e,selection:t,label:n,disabled:_=!1,presentation:v=`button`}){let y=s(o(e=>e.language)).chat.pageContext,b=i(),x=r().key,[S,C]=(0,h.useState)(!1),[w,T]=(0,h.useState)(!1),E=(0,h.useRef)(!1),D=(0,h.useRef)(0),O=a(e=>e.baseUrl),k=a(e=>e.conversationId);(0,h.useEffect)(()=>(E.current=!1,C(!1),T(!1),()=>{D.current+=1}),[x,e.kind,e.id,e.revision,t?.text,t?.draft,_,O,k]);async function A(){if(_||E.current)return;E.current=!0,C(!0),T(!1);let n=D.current,r=()=>D.current===n&&a.getState().baseUrl===O&&a.getState().conversationId===k;try{let n=p.capture({title:``,text:``,resourceRefs:[e],selection:t}),i=await d(`xopc.context.resolve`,n.envelope);if(!r())return;let a=i.resources[0];if(i.resources.length!==1||JSON.stringify(i.snapshot)!==JSON.stringify(n.envelope)||a.reference.kind!==e.kind||a.reference.id!==e.id||a.reference.revision!==e.revision)throw Error(`Context mismatch`);n.title=a.title,n.preview=a.text,n.truncated=a.truncated;let o=await new u().createSession();if(!r())return;if(!p.put(m(O,k,o.key),n))throw Error(`Context draft limit reached`);b(`/chat/${encodeURIComponent(o.key)}`)}catch{r()&&T(!0)}finally{D.current===n&&(E.current=!1,C(!1))}}let j=(0,g.jsxs)(`button`,{type:`button`,disabled:_||S,onClick:()=>void A(),"aria-busy":S,title:_?y.unavailable:n??y.capture,className:v===`menu`?`flex min-h-11 w-full items-center gap-2 rounded-md px-3 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover disabled:opacity-40`:`inline-flex min-h-9 items-center gap-1.5 rounded-lg border border-edge px-2.5 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[S?(0,g.jsx)(l,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,g.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),n??y.capture]});return(0,g.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[v===`menu`?(0,g.jsx)(f,{asChild:!0,disabled:_||S,onSelect:e=>e.preventDefault(),children:j}):j,w?(0,g.jsx)(`p`,{role:`alert`,className:`max-w-72 text-xs text-danger`,children:y.unavailable}):null]})}export{_ as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,f as i,t as a}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{i as o,n as s,o as c}from"./locale-store-CHjsq5NR.js";import{t as l}from"./messages-C7QSnTdg.js";import{t as u}from"./chat-page-3fVhP77N.js";import{t as d}from"./arrow-left-D880xG-P.js";import{t as f}from"./arrow-right-DSSvoX71.js";import{t as p}from"./check-DUBLcKHA.js";import{n as m,s as ee,t as te}from"./install-connector-dialog-CntHi8Rh.js";import{c as h,o as g,s as _}from"./use-personal-work-B1DWeBnm.js";import{t as ne}from"./play-kxZvpBg8.js";import{t as v}from"./settings-2-D-csvaET.js";import{t as re}from"./upload-rrb46c3c.js";import{t as y}from"./x-B_N4OPjy.js";import{t as b}from"./skeleton-DzdOeGYz.js";import{r as x}from"./right-workspace-store-Cehybf-G.js";import{a as S,i as C,o as w,r as T,t as E}from"./dist-BSVQC3i_.js";import{a as D,r as ie}from"./connectors-api-CRGq-TSw.js";import{u as ae}from"./use-realtime-voice-9OvLwHzk.js";import{n as O}from"./voice-call-context-BM2A4bLz.js";import{t as k}from"./page-header-store-NP7MCIaP.js";import{s as A}from"./agent-avatar-display-D_UDgOr9.js";import{t as j}from"./personal-avatar-1TVnHakL.js";import{d as M,i as N,r as P}from"./voice-config-api-sXEIG6lz.js";import{t as oe}from"./personal-profile-settings-TcI0Zfwr.js";var F=e(t(),1),I=n(),L=[`intro`,`identity`,`voice`,`connections`],se=[{id:`loopi`,zh:`Loopi`,en:`Loopi`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`},{id:`loopi-care`,zh:`温和`,en:`Gentle`}];function ce(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}async function R(e,t){let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await c(o(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),A(e)}function z({modelsAvailable:e,onCreated:t}){let n=s(e=>e.language)===`zh`,r=s(e=>e.language),[i,u]=(0,F.useState)(`intro`),[h,g]=(0,F.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[_,v]=(0,F.useState)(!1),[y,x]=(0,F.useState)(!1),[S,C]=(0,F.useState)(null),[w,T]=(0,F.useState)(null),[E,O]=(0,F.useState)(null),[k,A]=(0,F.useState)(null),[oe,z]=(0,F.useState)(!0),[B,V]=(0,F.useState)([]),[H,U]=(0,F.useState)(null),W=(0,F.useRef)(null),G=(0,F.useRef)(null),[K,le]=(0,F.useState)([]),[q,J]=(0,F.useState)(!0),[Y,X]=(0,F.useState)([]),[Z,Q]=(0,F.useState)(null);(0,F.useEffect)(()=>{let e=!1;return c(o(`/api/personal-agent/onboarding`)).then(t=>{e||(u(t.payload.step),g(t.payload.draft))}).catch(t=>{e||C(t instanceof Error?t.message:String(t))}).finally(()=>{e||v(!0)}),()=>{e=!0}},[]),(0,F.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>{c(o(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:i,draft:h})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[h,_,i]),(0,F.useEffect)(()=>{let e=!1;return P().then(t=>{e||(t.tts&&t.enabled?A({provider:t.tts.provider,model:t.tts.model,enabled:!0}):z(!1))}).catch(()=>{e||z(!1)}),()=>{e=!0}},[]),(0,F.useEffect)(()=>{if(!k?.enabled)return;let e=!1;return N(k.provider,k.model,`realtime`).then(t=>{e||V(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||z(!1)}),()=>{e=!0}},[k]),(0,F.useEffect)(()=>{if(i!==`connections`)return;let e=!1;return J(!0),Promise.allSettled([ie({page:1,pageSize:24,verification:`verified`}),D()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];le(t.value.connectors.filter(t=>t.runtime.type===`composio`&&e.includes(t.runtime.toolkit)).sort((t,n)=>e.indexOf(t.runtime.type===`composio`?t.runtime.toolkit:``)-e.indexOf(n.runtime.type===`composio`?n.runtime.toolkit:``)))}n.status===`fulfilled`&&X(n.value),J(!1)}}),()=>{e=!0}},[i]),(0,F.useEffect)(()=>()=>{G.current?.abort(),W.current?.close()},[]),(0,F.useEffect)(()=>()=>{E&&URL.revokeObjectURL(E)},[E]);let ue=async(e,t=h)=>{await c(o(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),u(e)},de=async e=>{C(null);let t=L[Math.max(0,Math.min(L.length-1,L.indexOf(i)+e))];try{await ue(t)}catch(e){C(e instanceof Error?e.message:String(e))}},fe=async(n=!1)=>{if(!(!e||y)){x(!0),C(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:h,r=e.voice&&k?.enabled&&B.some(t=>t.id===e.voice)?{provider:k.provider,model:k.model,voice:e.voice}:void 0,i=(await c(o(`/api/personal-agent`),{method:`POST`,body:JSON.stringify({displayName:e.displayName.trim()||`Ada`,appearance:e.appearance,...r?{voicePreference:r}:{}})})).payload,a=!1;if(!n&&w)try{await R(i.agentId,w),i=(await c(o(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:i.revision,displayName:i.displayName,appearance:`custom`})})).payload}catch{a=!0}t(i,a)}catch(e){C(e instanceof Error?e.message:String(e))}finally{x(!1)}}},pe=(0,F.useCallback)(async e=>{G.current?.abort(),W.current?.close();let t=new AbortController;G.current=t,U(e),C(null);try{let n=new ae;W.current=n,await n.start();let r=await M(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>U(null))}catch(e){t.signal.aborted||C(e instanceof Error?e.message:String(e)),U(null)}},[]);if(!_)return(0,I.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,I.jsx)(b,{className:`h-10 w-2/3`}),(0,I.jsx)(b,{className:`h-64 w-full rounded-2xl`}),(0,I.jsx)(b,{className:`h-12 w-full rounded-xl`})]});let $=L.indexOf(i),me={intro:n?`创建一个和你一起做事的助手`:`Create an assistant to work with you`,identity:n?`先给它一个形象和名字`:`Choose a look and a name`,voice:n?`想让我用什么声音回应?`:`How should your assistant sound?`,connections:n?`要让我了解哪些信息?`:`What information can your assistant use?`}[i];return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,I.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,I.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[$>0?(0,I.jsxs)(`button`,{type:`button`,disabled:y,onClick:()=>void de(-1),className:`-ml-2 inline-flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:[(0,I.jsx)(d,{className:`size-4`}),n?`上一步`:`Back`]}):(0,I.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,I.jsx)(a,{to:`/chat`,className:`-mr-2 inline-flex min-h-10 items-center rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`稍后继续`:`Finish later`})]}),(0,I.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":$+1,"aria-valuemin":1,"aria-valuemax":L.length,children:L.map((e,t)=>(0,I.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=$?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,I.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,I.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,I.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,I.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:E?(0,I.jsx)(`img`,{src:E,alt:``,className:`size-14 rounded-xl object-cover`}):(0,I.jsx)(j,{appearance:h.appearance,className:`size-14`})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,I.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:h.displayName||`Ada`})]})]}),(0,I.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${$+1} 步 · 共 ${L.length} 步`:`Step ${$+1} of ${L.length}`}),(0,I.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:me}),i===`intro`&&(0,I.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,I.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,I.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,I.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),i===`identity`&&(0,I.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,I.jsx)(`input`,{value:h.displayName,maxLength:60,onChange:e=>g(t=>({...t,displayName:e.target.value})),onBlur:()=>g(e=>({...e,displayName:e.displayName.trim()||`Ada`})),className:`mt-2 block w-full rounded-xl border border-edge bg-surface-panel px-4 py-3 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[se.map(e=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":!w&&h.appearance===e.id,onClick:()=>{T(null),O(null),g(t=>({...t,appearance:e.id}))},className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${!w&&h.appearance===e.id?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,I.jsx)(j,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,I.jsxs)(`label`,{className:`flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-within:ring-2 focus-within:ring-accent ${w?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,I.jsx)(re,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,I.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];if(t){if(t.size>512*1024||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){C(n?`请选择不超过 512 KB 的 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image under 512 KB.`);return}T(t),O(URL.createObjectURL(t))}}})]})]}),(0,I.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n?`自定义图片在创建助手时上传;刷新后需要重新选择。`:`Custom images upload when you create the assistant; select again after a refresh.`})]})]}),i===`voice`&&(0,I.jsxs)(`div`,{className:`mt-5`,children:[(0,I.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`用于这个助手的语音通话;文字回答不受影响。试听不会使用麦克风。`:`This affects calls with this assistant. Text stays the same. Preview does not use your microphone.`}),oe?(0,I.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,I.jsx)(b,{className:`h-20 rounded-xl`}),(0,I.jsx)(b,{className:`h-20 rounded-xl`})]}):k?.enabled&&B.length>0?(0,I.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-pressed":!h.voice,onClick:()=>g(e=>({...e,voice:null})),className:`rounded-xl p-4 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${h.voice?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:n?`使用默认声音`:`Use the default voice`}),B.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${h.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-pressed":h.voice===e.id,onClick:()=>g(t=>({...t,voice:e.id})),children:[(0,I.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,I.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void pe(e.id),className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`试听${e.name}`:`Preview ${e.name}`,children:(0,I.jsx)(ne,{className:`size-4 ${H===e.id?`text-accent`:``}`})})]},e.id))]}):(0,I.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,I.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,I.jsx)(a,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),i===`connections`&&(0,I.jsxs)(`div`,{className:`mt-5`,children:[(0,I.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`现在连接,或进入对话后再添加。连接不会自动读取历史数据或创建持续关注。`:`Connect now or add sources later. Connecting does not automatically scan history or create ongoing monitoring.`}),q?(0,I.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,I.jsx)(b,{className:`h-18 rounded-xl`}),(0,I.jsx)(b,{className:`h-18 rounded-xl`})]}):(0,I.jsx)(`div`,{className:`mt-5 space-y-2`,children:K.length?K.map(e=>{let t=ce(Y.find(t=>t.connectorId===e.id));return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,I.jsx)(m,{connector:e,size:`sm`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,I.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,I.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,I.jsx)(p,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,I.jsx)(`button`,{type:`button`,onClick:()=>Q(ee(e)),className:`rounded-lg bg-surface-hover px-3 py-2 text-xs text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`连接`:`Connect`})]},e.id)}):(0,I.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:n?`暂无可用的推荐服务;你仍可直接进入对话。`:`No suggested services are available. You can continue to chat.`})})]}),!e&&(0,I.jsxs)(`p`,{className:`mt-5 rounded-xl bg-warning/5 p-4 text-sm text-fg-muted`,children:[n?`开始前需要一个可用模型。`:`A compatible model is required before you start.`,` `,(0,I.jsx)(a,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),S&&(0,I.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:S})]},i)}),(0,I.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,I.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,I.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[i===`intro`&&(0,I.jsx)(`button`,{type:`button`,disabled:!e||y,onClick:()=>void fe(!0),className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:n?`用默认设置开始`:`Use defaults`}),i===`voice`&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>{let e={...h,voice:null};g(e),C(null),ue(`connections`,e).catch(e=>C(e instanceof Error?e.message:String(e)))},className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`跳过`:`Skip`}),(0,I.jsxs)(`button`,{type:`button`,disabled:y||i===`connections`&&!e,onClick:()=>i===`connections`?void fe():void de(1),className:`flex min-h-11 items-center gap-2 rounded-xl bg-accent px-5 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:opacity-40`,children:[y?n?`正在创建…`:`Creating…`:i===`connections`?n?`进入对话`:`Start chatting`:n?`继续`:`Continue`,` `,!y&&(0,I.jsx)(f,{className:`size-4`})]})]})]})}),Z&&(0,I.jsx)(te,{draft:Z,onChange:Q,onClose:()=>Q(null),t:l(r).connectorsSettings,onInstalled:async()=>{X(await D()),Q(null)}})]})}function B(){let e=i(),t=r(),n=O(),a=(0,F.useRef)(n);a.current=n;let l=s(e=>e.language)===`zh`,d=k(e=>e.setPageHeader),f=k(e=>e.clearPageHeader),[p,m]=(0,F.useState)(null),[ee,te]=(0,F.useState)([]),[ne,re]=(0,F.useState)(!0),[D,ie]=(0,F.useState)(null),[ae,A]=(0,F.useState)(!1),[M,N]=(0,F.useState)(!1),P=(0,F.useRef)(null),L=(0,F.useRef)(null),[se,ce]=(0,F.useState)(null),R=(0,F.useCallback)(e=>{L.current=e,ce(e?.closest(`[data-app-chat-shell]`)??null)},[]),B=(0,F.useRef)(null),V=(0,F.useRef)(null),H=p?.state===`ready`?p.conversationId:void 0,U=x(e=>{let t=H?e.panes[H]:void 0,n=t?.tabs.find(e=>e.id===t.activeId);return t?.open===!0&&(t.activeId===`personal-tasks`||t.personalDetailsOpen===!0&&(n?.kind===`file`||n?.kind===`browser`))}),{avatarState:W,summary:G,refreshWork:K,refreshPrompt:le}=g(H,l);_(H,K,le);let q=(0,F.useCallback)(()=>e(`/settings/personal`,{state:{settingsBackPath:`${t.pathname}${t.search}${t.hash}`}}),[t.pathname,t.search,t.hash,e]),J=(0,F.useCallback)(e=>{V.current=e,a.current.setMiniAnchor(e)},[]),Y=(0,F.useCallback)(()=>{H&&U&&x.getState().closePersonalTasks(H)},[H,U]),X=(0,F.useCallback)(()=>{a.current.minimize(),N(e=>!e)},[]),Z=(0,F.useCallback)(()=>{H&&(a.current.minimize(),N(!1),U?Y():x.getState().openPersonalTasks(H))},[Y,H,U]);(0,F.useEffect)(()=>{n.expanded&&N(!1)},[n.expanded]),(0,F.useEffect)(()=>{let e=e=>{let t=e.detail;t&&m(t)};return window.addEventListener(`personal-agent-updated`,e),()=>window.removeEventListener(`personal-agent-updated`,e)},[]);let Q=(0,F.useCallback)(async()=>{try{let[e,t]=await Promise.all([c(o(`/api/personal-agent`)),c(o(`/api/personal-agent/models`))]);m(e.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e.payload})),e.payload&&window.dispatchEvent(new Event(`session-updated`)),te(t.payload)}catch(e){ie(e instanceof Error?e.message:String(e))}finally{re(!1)}},[]);return(0,F.useEffect)(()=>{Q()},[Q]),(0,F.useLayoutEffect)(()=>{let e=p?.state===`ready`,t=l?`语音通话`:`Voice call`,r=`touch-target inline-flex min-h-10 shrink-0 items-center justify-center gap-2 rounded-full bg-surface-hover/90 px-3.5 text-sm font-medium text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent aria-expanded:bg-surface-active`,i=()=>{if(N(!1),!e)return;if(a.current.expanded){a.current.minimize();return}let t=L.current;a.current.open({conversationId:p.conversationId,name:p.displayName},t?{anchor:t,avatar:(0,I.jsx)(j,{appearance:p.appearance,agentId:p.agentId,className:`size-full`})}:void 0)},o=e?p.appearance:`loopi`,s=e?p.displayName:`Ada`;return d({startExtra:null,personalChat:e?U?`controls`:`identity`:void 0,main:(0,I.jsxs)(`div`,{className:`flex min-w-0 justify-center`,children:[(0,I.jsx)(`h1`,{className:`sr-only`,children:s}),U?null:e?(0,I.jsxs)(`button`,{ref:B,type:`button`,"data-personal-tasks-trigger":!0,"aria-controls":`app-workspace-panel`,"aria-expanded":U,"aria-describedby":G?`personal-work-status`:void 0,"aria-label":l?`${s} 的任务`:`${s}'s tasks`,title:G||s,onClick:Z,className:`group/identity flex min-w-0 max-w-full flex-col items-center gap-1 rounded-2xl px-1.5 pb-0.5 text-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:gap-1.5`,children:[(0,I.jsx)(`span`,{className:`relative grid size-16 shrink-0 place-items-center rounded-full border border-edge-subtle bg-surface-base transition-colors group-hover/identity:border-edge sm:size-20 @max-[26rem]/personal-chat:size-14`,children:(0,I.jsx)(j,{appearance:o,agentId:p.agentId,activity:W,className:`size-full`})}),(0,I.jsxs)(`span`,{className:`personal-identity-label max-w-full min-w-0 rounded-2xl px-3 py-1`,children:[(0,I.jsx)(`span`,{className:`block truncate text-[0.9375rem] leading-5 font-semibold text-fg sm:text-base`,children:s}),G?(0,I.jsxs)(`span`,{id:`personal-work-status`,role:`status`,className:`flex min-w-0 items-center justify-center gap-1.5 text-xs leading-4 text-fg-muted`,children:[W===`idle`?null:(0,I.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${W===`waiting`?`bg-warning`:`bg-accent`}`,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`truncate`,children:G})]}):null]})]}):(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(j,{appearance:o,className:`size-8`}),(0,I.jsx)(`span`,{className:`text-sm font-semibold`,children:s})]})]}),end:e?(0,I.jsxs)(`div`,{ref:R,className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":n.expanded,onClick:i,className:r,"aria-label":t,title:t,children:[(0,I.jsx)(h,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`hidden @min-[32rem]/personal-header:inline`,children:l?`通话`:`Call`})]}),(0,I.jsxs)(`button`,{ref:P,type:`button`,onClick:X,"aria-haspopup":`dialog`,"aria-expanded":M,className:r,"aria-label":l?`${s} 设置`:`${s} settings`,children:[(0,I.jsx)(v,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`hidden @min-[32rem]/personal-header:inline`,children:l?`设置`:`Settings`})]})]}):null}),()=>f()},[W,f,p,R,d,M,G,U,X,Z,n.expanded,l]),ne?(0,I.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,I.jsx)(b,{className:`h-20 w-20 rounded-full`}),(0,I.jsx)(b,{className:`h-9 w-72`}),(0,I.jsx)(b,{className:`h-44 w-full rounded-2xl`})]}):D&&!p?(0,I.jsxs)(`div`,{role:`alert`,className:`space-y-3 p-6 text-sm text-danger`,children:[(0,I.jsx)(`p`,{children:D}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void Q(),className:`text-accent hover:underline`,children:l?`重试`:`Retry`})]}):p?.state===`ready`?(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[ae&&(0,I.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-center justify-between gap-3 border-b border-warning/30 bg-warning/5 px-5 py-3 text-sm text-fg-muted`,children:[(0,I.jsx)(`span`,{children:l?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>{A(!1),q()},className:`shrink-0 text-accent hover:underline`,children:l?`打开设置`:`Open settings`})]}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(u,{embedded:!0,personal:!0,personalWelcome:{name:p.displayName,addressAs:p.userCallName??void 0,opening:l?`有什么想讨论或推进的事?直接告诉我就好。`:`What would you like to discuss or move forward? Just tell me what is on your mind.`},conversationId:p.conversationId})})}),(0,I.jsxs)(w,{open:M,onOpenChange:N,children:[(0,I.jsx)(E,{virtualRef:L}),(0,I.jsx)(S,{children:(0,I.jsxs)(C,{ref:J,side:`bottom`,align:`end`,sideOffset:12,collisionPadding:12,collisionBoundary:se??void 0,"aria-label":l?`${p.displayName} 快捷设置`:`${p.displayName} quick settings`,onInteractOutside:e=>{e.target instanceof Node&&(P.current?.contains(e.target)||B.current?.contains(e.target)||V.current?.contains(e.target)||e.target instanceof Element&&e.target.closest(`[data-voice-call-mini]`))&&e.preventDefault()},className:`xopc-session-context-popover data-[state=closed]:pointer-events-none z-50 flex h-[min(34rem,calc(100dvh-6rem))] ${n.active?`max-h-[min(var(--radix-popover-content-available-height),calc(100dvh-12rem))]`:`max-h-[var(--radix-popover-content-available-height)]`} min-h-0 w-[min(27rem,calc(100vw-1.5rem))] max-w-[var(--radix-popover-content-available-width)] flex-col overflow-hidden rounded-[1.75rem] border border-edge-subtle bg-surface-overlay shadow-float outline-none`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 px-5 pb-2 pt-4`,children:[(0,I.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:l?`快捷设置`:`Quick settings`}),(0,I.jsx)(T,{className:`touch-target -mr-2 rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":l?`关闭设置`:`Close settings`,children:(0,I.jsx)(y,{className:`size-4`})})]}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 pb-4 pt-2`,children:(0,I.jsx)(oe,{zh:l,onOpenVoiceServices:q})}),(0,I.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,I.jsx)(`button`,{type:`button`,onClick:q,className:`w-full rounded-full bg-surface-hover px-4 py-2.5 text-center text-sm font-medium text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:l?`更多设置`:`More settings`})})]})})]})]}):(0,I.jsx)(z,{modelsAvailable:ee.length>0,onCreated:(e,t)=>{m(e),A(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{B as PersonalPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,f as i,t as a}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{i as o,n as s,o as c}from"./locale-store-CHjsq5NR.js";import{t as l}from"./messages-C7QSnTdg.js";import{t as u}from"./chat-page-DWZCzxY7.js";import{t as d}from"./arrow-left-D880xG-P.js";import{t as f}from"./arrow-right-DSSvoX71.js";import{t as p}from"./check-DUBLcKHA.js";import{n as m,s as ee,t as te}from"./install-connector-dialog-CntHi8Rh.js";import{c as h,o as g,s as _}from"./use-personal-work-B25WRGHj.js";import{t as ne}from"./play-kxZvpBg8.js";import{t as v}from"./settings-2-D-csvaET.js";import{t as re}from"./upload-rrb46c3c.js";import{t as y}from"./x-B_N4OPjy.js";import{t as b}from"./skeleton-DzdOeGYz.js";import{r as x}from"./right-workspace-store-Cehybf-G.js";import{a as S,i as C,o as w,r as T,t as E}from"./dist-BSVQC3i_.js";import{a as D,r as ie}from"./connectors-api-CRGq-TSw.js";import{u as ae}from"./use-realtime-voice-CV3GIt_T.js";import{n as O}from"./voice-call-context-BM2A4bLz.js";import{t as k}from"./page-header-store-NP7MCIaP.js";import{s as A}from"./agent-avatar-display-D_UDgOr9.js";import{t as j}from"./personal-avatar-1TVnHakL.js";import{d as M,i as N,r as P}from"./voice-config-api-sXEIG6lz.js";import{t as oe}from"./personal-profile-settings-XiT1MgTK.js";var F=e(t(),1),I=n(),L=[`intro`,`identity`,`voice`,`connections`],se=[{id:`loopi`,zh:`Loopi`,en:`Loopi`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`},{id:`loopi-care`,zh:`温和`,en:`Gentle`}];function ce(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}async function R(e,t){let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await c(o(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),A(e)}function z({modelsAvailable:e,onCreated:t}){let n=s(e=>e.language)===`zh`,r=s(e=>e.language),[i,u]=(0,F.useState)(`intro`),[h,g]=(0,F.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[_,v]=(0,F.useState)(!1),[y,x]=(0,F.useState)(!1),[S,C]=(0,F.useState)(null),[w,T]=(0,F.useState)(null),[E,O]=(0,F.useState)(null),[k,A]=(0,F.useState)(null),[oe,z]=(0,F.useState)(!0),[B,V]=(0,F.useState)([]),[H,U]=(0,F.useState)(null),W=(0,F.useRef)(null),G=(0,F.useRef)(null),[K,le]=(0,F.useState)([]),[q,J]=(0,F.useState)(!0),[Y,X]=(0,F.useState)([]),[Z,Q]=(0,F.useState)(null);(0,F.useEffect)(()=>{let e=!1;return c(o(`/api/personal-agent/onboarding`)).then(t=>{e||(u(t.payload.step),g(t.payload.draft))}).catch(t=>{e||C(t instanceof Error?t.message:String(t))}).finally(()=>{e||v(!0)}),()=>{e=!0}},[]),(0,F.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>{c(o(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:i,draft:h})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[h,_,i]),(0,F.useEffect)(()=>{let e=!1;return P().then(t=>{e||(t.tts&&t.enabled?A({provider:t.tts.provider,model:t.tts.model,enabled:!0}):z(!1))}).catch(()=>{e||z(!1)}),()=>{e=!0}},[]),(0,F.useEffect)(()=>{if(!k?.enabled)return;let e=!1;return N(k.provider,k.model,`realtime`).then(t=>{e||V(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||z(!1)}),()=>{e=!0}},[k]),(0,F.useEffect)(()=>{if(i!==`connections`)return;let e=!1;return J(!0),Promise.allSettled([ie({page:1,pageSize:24,verification:`verified`}),D()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];le(t.value.connectors.filter(t=>t.runtime.type===`composio`&&e.includes(t.runtime.toolkit)).sort((t,n)=>e.indexOf(t.runtime.type===`composio`?t.runtime.toolkit:``)-e.indexOf(n.runtime.type===`composio`?n.runtime.toolkit:``)))}n.status===`fulfilled`&&X(n.value),J(!1)}}),()=>{e=!0}},[i]),(0,F.useEffect)(()=>()=>{G.current?.abort(),W.current?.close()},[]),(0,F.useEffect)(()=>()=>{E&&URL.revokeObjectURL(E)},[E]);let ue=async(e,t=h)=>{await c(o(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),u(e)},de=async e=>{C(null);let t=L[Math.max(0,Math.min(L.length-1,L.indexOf(i)+e))];try{await ue(t)}catch(e){C(e instanceof Error?e.message:String(e))}},fe=async(n=!1)=>{if(!(!e||y)){x(!0),C(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:h,r=e.voice&&k?.enabled&&B.some(t=>t.id===e.voice)?{provider:k.provider,model:k.model,voice:e.voice}:void 0,i=(await c(o(`/api/personal-agent`),{method:`POST`,body:JSON.stringify({displayName:e.displayName.trim()||`Ada`,appearance:e.appearance,...r?{voicePreference:r}:{}})})).payload,a=!1;if(!n&&w)try{await R(i.agentId,w),i=(await c(o(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:i.revision,displayName:i.displayName,appearance:`custom`})})).payload}catch{a=!0}t(i,a)}catch(e){C(e instanceof Error?e.message:String(e))}finally{x(!1)}}},pe=(0,F.useCallback)(async e=>{G.current?.abort(),W.current?.close();let t=new AbortController;G.current=t,U(e),C(null);try{let n=new ae;W.current=n,await n.start();let r=await M(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>U(null))}catch(e){t.signal.aborted||C(e instanceof Error?e.message:String(e)),U(null)}},[]);if(!_)return(0,I.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,I.jsx)(b,{className:`h-10 w-2/3`}),(0,I.jsx)(b,{className:`h-64 w-full rounded-2xl`}),(0,I.jsx)(b,{className:`h-12 w-full rounded-xl`})]});let $=L.indexOf(i),me={intro:n?`创建一个和你一起做事的助手`:`Create an assistant to work with you`,identity:n?`先给它一个形象和名字`:`Choose a look and a name`,voice:n?`想让我用什么声音回应?`:`How should your assistant sound?`,connections:n?`要让我了解哪些信息?`:`What information can your assistant use?`}[i];return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,I.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,I.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[$>0?(0,I.jsxs)(`button`,{type:`button`,disabled:y,onClick:()=>void de(-1),className:`-ml-2 inline-flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:[(0,I.jsx)(d,{className:`size-4`}),n?`上一步`:`Back`]}):(0,I.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,I.jsx)(a,{to:`/chat`,className:`-mr-2 inline-flex min-h-10 items-center rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`稍后继续`:`Finish later`})]}),(0,I.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":$+1,"aria-valuemin":1,"aria-valuemax":L.length,children:L.map((e,t)=>(0,I.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=$?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,I.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,I.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,I.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,I.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:E?(0,I.jsx)(`img`,{src:E,alt:``,className:`size-14 rounded-xl object-cover`}):(0,I.jsx)(j,{appearance:h.appearance,className:`size-14`})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,I.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:h.displayName||`Ada`})]})]}),(0,I.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${$+1} 步 · 共 ${L.length} 步`:`Step ${$+1} of ${L.length}`}),(0,I.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:me}),i===`intro`&&(0,I.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,I.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,I.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,I.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),i===`identity`&&(0,I.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,I.jsx)(`input`,{value:h.displayName,maxLength:60,onChange:e=>g(t=>({...t,displayName:e.target.value})),onBlur:()=>g(e=>({...e,displayName:e.displayName.trim()||`Ada`})),className:`mt-2 block w-full rounded-xl border border-edge bg-surface-panel px-4 py-3 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[se.map(e=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":!w&&h.appearance===e.id,onClick:()=>{T(null),O(null),g(t=>({...t,appearance:e.id}))},className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${!w&&h.appearance===e.id?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,I.jsx)(j,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,I.jsxs)(`label`,{className:`flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-within:ring-2 focus-within:ring-accent ${w?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,I.jsx)(re,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,I.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];if(t){if(t.size>512*1024||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){C(n?`请选择不超过 512 KB 的 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image under 512 KB.`);return}T(t),O(URL.createObjectURL(t))}}})]})]}),(0,I.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n?`自定义图片在创建助手时上传;刷新后需要重新选择。`:`Custom images upload when you create the assistant; select again after a refresh.`})]})]}),i===`voice`&&(0,I.jsxs)(`div`,{className:`mt-5`,children:[(0,I.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`用于这个助手的语音通话;文字回答不受影响。试听不会使用麦克风。`:`This affects calls with this assistant. Text stays the same. Preview does not use your microphone.`}),oe?(0,I.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,I.jsx)(b,{className:`h-20 rounded-xl`}),(0,I.jsx)(b,{className:`h-20 rounded-xl`})]}):k?.enabled&&B.length>0?(0,I.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-pressed":!h.voice,onClick:()=>g(e=>({...e,voice:null})),className:`rounded-xl p-4 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${h.voice?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:n?`使用默认声音`:`Use the default voice`}),B.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${h.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-pressed":h.voice===e.id,onClick:()=>g(t=>({...t,voice:e.id})),children:[(0,I.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,I.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void pe(e.id),className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`试听${e.name}`:`Preview ${e.name}`,children:(0,I.jsx)(ne,{className:`size-4 ${H===e.id?`text-accent`:``}`})})]},e.id))]}):(0,I.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,I.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,I.jsx)(a,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),i===`connections`&&(0,I.jsxs)(`div`,{className:`mt-5`,children:[(0,I.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`现在连接,或进入对话后再添加。连接不会自动读取历史数据或创建持续关注。`:`Connect now or add sources later. Connecting does not automatically scan history or create ongoing monitoring.`}),q?(0,I.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,I.jsx)(b,{className:`h-18 rounded-xl`}),(0,I.jsx)(b,{className:`h-18 rounded-xl`})]}):(0,I.jsx)(`div`,{className:`mt-5 space-y-2`,children:K.length?K.map(e=>{let t=ce(Y.find(t=>t.connectorId===e.id));return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,I.jsx)(m,{connector:e,size:`sm`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,I.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,I.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,I.jsx)(p,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,I.jsx)(`button`,{type:`button`,onClick:()=>Q(ee(e)),className:`rounded-lg bg-surface-hover px-3 py-2 text-xs text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`连接`:`Connect`})]},e.id)}):(0,I.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:n?`暂无可用的推荐服务;你仍可直接进入对话。`:`No suggested services are available. You can continue to chat.`})})]}),!e&&(0,I.jsxs)(`p`,{className:`mt-5 rounded-xl bg-warning/5 p-4 text-sm text-fg-muted`,children:[n?`开始前需要一个可用模型。`:`A compatible model is required before you start.`,` `,(0,I.jsx)(a,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),S&&(0,I.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:S})]},i)}),(0,I.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,I.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,I.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[i===`intro`&&(0,I.jsx)(`button`,{type:`button`,disabled:!e||y,onClick:()=>void fe(!0),className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:n?`用默认设置开始`:`Use defaults`}),i===`voice`&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>{let e={...h,voice:null};g(e),C(null),ue(`connections`,e).catch(e=>C(e instanceof Error?e.message:String(e)))},className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`跳过`:`Skip`}),(0,I.jsxs)(`button`,{type:`button`,disabled:y||i===`connections`&&!e,onClick:()=>i===`connections`?void fe():void de(1),className:`flex min-h-11 items-center gap-2 rounded-xl bg-accent px-5 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:opacity-40`,children:[y?n?`正在创建…`:`Creating…`:i===`connections`?n?`进入对话`:`Start chatting`:n?`继续`:`Continue`,` `,!y&&(0,I.jsx)(f,{className:`size-4`})]})]})]})}),Z&&(0,I.jsx)(te,{draft:Z,onChange:Q,onClose:()=>Q(null),t:l(r).connectorsSettings,onInstalled:async()=>{X(await D()),Q(null)}})]})}function B(){let e=i(),t=r(),n=O(),a=(0,F.useRef)(n);a.current=n;let l=s(e=>e.language)===`zh`,d=k(e=>e.setPageHeader),f=k(e=>e.clearPageHeader),[p,m]=(0,F.useState)(null),[ee,te]=(0,F.useState)([]),[ne,re]=(0,F.useState)(!0),[D,ie]=(0,F.useState)(null),[ae,A]=(0,F.useState)(!1),[M,N]=(0,F.useState)(!1),P=(0,F.useRef)(null),L=(0,F.useRef)(null),[se,ce]=(0,F.useState)(null),R=(0,F.useCallback)(e=>{L.current=e,ce(e?.closest(`[data-app-chat-shell]`)??null)},[]),B=(0,F.useRef)(null),V=(0,F.useRef)(null),H=p?.state===`ready`?p.conversationId:void 0,U=x(e=>{let t=H?e.panes[H]:void 0,n=t?.tabs.find(e=>e.id===t.activeId);return t?.open===!0&&(t.activeId===`personal-tasks`||t.personalDetailsOpen===!0&&(n?.kind===`file`||n?.kind===`browser`))}),{avatarState:W,summary:G,refreshWork:K,refreshPrompt:le}=g(H,l);_(H,K,le);let q=(0,F.useCallback)(()=>e(`/settings/personal`,{state:{settingsBackPath:`${t.pathname}${t.search}${t.hash}`}}),[t.pathname,t.search,t.hash,e]),J=(0,F.useCallback)(e=>{V.current=e,a.current.setMiniAnchor(e)},[]),Y=(0,F.useCallback)(()=>{H&&U&&x.getState().closePersonalTasks(H)},[H,U]),X=(0,F.useCallback)(()=>{a.current.minimize(),N(e=>!e)},[]),Z=(0,F.useCallback)(()=>{H&&(a.current.minimize(),N(!1),U?Y():x.getState().openPersonalTasks(H))},[Y,H,U]);(0,F.useEffect)(()=>{n.expanded&&N(!1)},[n.expanded]),(0,F.useEffect)(()=>{let e=e=>{let t=e.detail;t&&m(t)};return window.addEventListener(`personal-agent-updated`,e),()=>window.removeEventListener(`personal-agent-updated`,e)},[]);let Q=(0,F.useCallback)(async()=>{try{let[e,t]=await Promise.all([c(o(`/api/personal-agent`)),c(o(`/api/personal-agent/models`))]);m(e.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e.payload})),e.payload&&window.dispatchEvent(new Event(`session-updated`)),te(t.payload)}catch(e){ie(e instanceof Error?e.message:String(e))}finally{re(!1)}},[]);return(0,F.useEffect)(()=>{Q()},[Q]),(0,F.useLayoutEffect)(()=>{let e=p?.state===`ready`,t=l?`语音通话`:`Voice call`,r=`touch-target inline-flex min-h-10 shrink-0 items-center justify-center gap-2 rounded-full bg-surface-hover/90 px-3.5 text-sm font-medium text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent aria-expanded:bg-surface-active`,i=()=>{if(N(!1),!e)return;if(a.current.expanded){a.current.minimize();return}let t=L.current;a.current.open({conversationId:p.conversationId,name:p.displayName},t?{anchor:t,avatar:(0,I.jsx)(j,{appearance:p.appearance,agentId:p.agentId,className:`size-full`})}:void 0)},o=e?p.appearance:`loopi`,s=e?p.displayName:`Ada`;return d({startExtra:null,personalChat:e?U?`controls`:`identity`:void 0,main:(0,I.jsxs)(`div`,{className:`flex min-w-0 justify-center`,children:[(0,I.jsx)(`h1`,{className:`sr-only`,children:s}),U?null:e?(0,I.jsxs)(`button`,{ref:B,type:`button`,"data-personal-tasks-trigger":!0,"aria-controls":`app-workspace-panel`,"aria-expanded":U,"aria-describedby":G?`personal-work-status`:void 0,"aria-label":l?`${s} 的任务`:`${s}'s tasks`,title:G||s,onClick:Z,className:`group/identity flex min-w-0 max-w-full flex-col items-center gap-1 rounded-2xl px-1.5 pb-0.5 text-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:gap-1.5`,children:[(0,I.jsx)(`span`,{className:`relative grid size-16 shrink-0 place-items-center rounded-full border border-edge-subtle bg-surface-base transition-colors group-hover/identity:border-edge sm:size-20 @max-[26rem]/personal-chat:size-14`,children:(0,I.jsx)(j,{appearance:o,agentId:p.agentId,activity:W,className:`size-full`})}),(0,I.jsxs)(`span`,{className:`personal-identity-label max-w-full min-w-0 rounded-2xl px-3 py-1`,children:[(0,I.jsx)(`span`,{className:`block truncate text-[0.9375rem] leading-5 font-semibold text-fg sm:text-base`,children:s}),G?(0,I.jsxs)(`span`,{id:`personal-work-status`,role:`status`,className:`flex min-w-0 items-center justify-center gap-1.5 text-xs leading-4 text-fg-muted`,children:[W===`idle`?null:(0,I.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${W===`waiting`?`bg-warning`:`bg-accent`}`,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`truncate`,children:G})]}):null]})]}):(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(j,{appearance:o,className:`size-8`}),(0,I.jsx)(`span`,{className:`text-sm font-semibold`,children:s})]})]}),end:e?(0,I.jsxs)(`div`,{ref:R,className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":n.expanded,onClick:i,className:r,"aria-label":t,title:t,children:[(0,I.jsx)(h,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`hidden @min-[32rem]/personal-header:inline`,children:l?`通话`:`Call`})]}),(0,I.jsxs)(`button`,{ref:P,type:`button`,onClick:X,"aria-haspopup":`dialog`,"aria-expanded":M,className:r,"aria-label":l?`${s} 设置`:`${s} settings`,children:[(0,I.jsx)(v,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`hidden @min-[32rem]/personal-header:inline`,children:l?`设置`:`Settings`})]})]}):null}),()=>f()},[W,f,p,R,d,M,G,U,X,Z,n.expanded,l]),ne?(0,I.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,I.jsx)(b,{className:`h-20 w-20 rounded-full`}),(0,I.jsx)(b,{className:`h-9 w-72`}),(0,I.jsx)(b,{className:`h-44 w-full rounded-2xl`})]}):D&&!p?(0,I.jsxs)(`div`,{role:`alert`,className:`space-y-3 p-6 text-sm text-danger`,children:[(0,I.jsx)(`p`,{children:D}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void Q(),className:`text-accent hover:underline`,children:l?`重试`:`Retry`})]}):p?.state===`ready`?(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[ae&&(0,I.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-center justify-between gap-3 border-b border-warning/30 bg-warning/5 px-5 py-3 text-sm text-fg-muted`,children:[(0,I.jsx)(`span`,{children:l?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>{A(!1),q()},className:`shrink-0 text-accent hover:underline`,children:l?`打开设置`:`Open settings`})]}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(u,{embedded:!0,personal:!0,personalWelcome:{name:p.displayName,addressAs:p.userCallName??void 0,opening:l?`有什么想讨论或推进的事?直接告诉我就好。`:`What would you like to discuss or move forward? Just tell me what is on your mind.`},conversationId:p.conversationId})})}),(0,I.jsxs)(w,{open:M,onOpenChange:N,children:[(0,I.jsx)(E,{virtualRef:L}),(0,I.jsx)(S,{children:(0,I.jsxs)(C,{ref:J,side:`bottom`,align:`end`,sideOffset:12,collisionPadding:12,collisionBoundary:se??void 0,"aria-label":l?`${p.displayName} 快捷设置`:`${p.displayName} quick settings`,onInteractOutside:e=>{e.target instanceof Node&&(P.current?.contains(e.target)||B.current?.contains(e.target)||V.current?.contains(e.target)||e.target instanceof Element&&e.target.closest(`[data-voice-call-mini]`))&&e.preventDefault()},className:`xopc-session-context-popover data-[state=closed]:pointer-events-none z-50 flex h-[min(34rem,calc(100dvh-6rem))] ${n.active?`max-h-[min(var(--radix-popover-content-available-height),calc(100dvh-12rem))]`:`max-h-[var(--radix-popover-content-available-height)]`} min-h-0 w-[min(27rem,calc(100vw-1.5rem))] max-w-[var(--radix-popover-content-available-width)] flex-col overflow-hidden rounded-[1.75rem] border border-edge-subtle bg-surface-overlay shadow-float outline-none`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 px-5 pb-2 pt-4`,children:[(0,I.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:l?`快捷设置`:`Quick settings`}),(0,I.jsx)(T,{className:`touch-target -mr-2 rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":l?`关闭设置`:`Close settings`,children:(0,I.jsx)(y,{className:`size-4`})})]}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 pb-4 pt-2`,children:(0,I.jsx)(oe,{zh:l,onOpenVoiceServices:q})}),(0,I.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,I.jsx)(`button`,{type:`button`,onClick:q,className:`w-full rounded-full bg-surface-hover px-4 py-2.5 text-center text-sm font-medium text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:l?`更多设置`:`More settings`})})]})})]})]}):(0,I.jsx)(z,{modelsAvailable:ee.length>0,onCreated:(e,t)=>{m(e),A(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{B as PersonalPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{i,o as a}from"./locale-store-CHjsq5NR.js";import{t as o}from"./messages-C7QSnTdg.js";import{n as s,r as c,t as l}from"./popover-select-hRG1EzAY.js";import{t as u}from"./play-kxZvpBg8.js";import{t as d}from"./square-DMK_fB-3.js";import{t as f}from"./upload-rrb46c3c.js";import{t as p}from"./skeleton-DzdOeGYz.js";import{n as m,t as h}from"./voice-CUfqdnlR.js";import{N as g,t as _,v}from"./session-manager-DUWeBdeG.js";import{t as y}from"./composer-model-config-control-C2Bku39S.js";import{i as b}from"./vendor-swr-CdRzEUwF.js";import{t as x}from"./button-C5tRaJxt.js";import{u as S}from"./use-realtime-voice-9OvLwHzk.js";import{s as C}from"./agent-avatar-display-D_UDgOr9.js";import{t as w}from"./personal-avatar-1TVnHakL.js";import{d as T,i as E,n as D,r as O,t as k}from"./voice-config-api-sXEIG6lz.js";var A=e(t(),1),j=n();function M({preferences:e,settings:t,failed:n,disabled:r,zh:i,onChange:a,onOpenServices:o,children:l}){let[u,d]=(0,A.useState)(null),f=(0,A.useRef)(0),g=u??e?.enginePreference??`auto`;async function _(e){if(e===g)return;let t=++f.current;d(e);try{await a({enginePreference:e})}finally{t===f.current&&d(null)}}let v=t?.defaultForNatural?h:t?.legacyModel,y=e?.naturalModel,b=y??v,S=b===h,C=t?.naturalModels??(t?.legacyModel?[{id:t.legacyModel,name:t.legacyModelLabel??t.legacyModel,tools:void 0}]:[]),w=C.find(e=>e.id===b),T=y&&y!==`boson/higgs-realtime`&&!C.some(e=>e.id===y);return(0,j.jsx)(`section`,{className:`space-y-3`,"aria-label":i?`语音通话设置`:`Voice call settings`,children:(0,j.jsxs)(`fieldset`,{disabled:r,className:`space-y-3`,children:[(0,j.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,j.jsx)(`span`,{children:i?`通话引擎`:`Call engine`}),(0,j.jsxs)(s,{side:`top`,"aria-label":i?`通话引擎`:`Call engine`,value:g,onChange:e=>{_(e.target.value)},children:[(0,j.jsx)(c,{value:`auto`,children:i?`自动选择`:`Automatic`}),(0,j.jsx)(c,{value:`natural`,children:i?`实时语音`:`Realtime voice`}),(0,j.jsx)(c,{value:`assistant`,children:i?`助手语音`:`Assistant voice`})]})]}),(0,j.jsx)(`div`,{inert:g===`natural`,"aria-hidden":g===`natural`,className:g===`natural`?`hidden`:``,children:l(g!==`natural`)}),(0,j.jsxs)(`div`,{inert:g===`assistant`,"aria-hidden":g===`assistant`,className:`space-y-3 ${g===`assistant`?`hidden`:``}`,children:[!t&&!n&&(0,j.jsx)(p,{className:`h-10 w-full`}),n&&(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:i?`无法读取自然语音模型。`:`Could not load natural voice models.`}),t&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,j.jsx)(`span`,{className:`block`,children:i?`通话模型`:`Call model`}),(0,j.jsxs)(s,{side:`top`,"aria-label":i?`自然语音模型`:`Natural voice model`,value:y??`inherit`,onChange:e=>a({naturalModel:e.target.value===`inherit`?null:e.target.value}),children:[(0,j.jsxs)(c,{value:`inherit`,children:[i?`跟随系统`:`Follow system`,v?` · ${v===`boson/higgs-realtime`?`Higgs Realtime`:t.legacyModelLabel??v}`:``]}),C.map(e=>(0,j.jsxs)(c,{value:e.id,children:[e.name,e.tools===!1?i?` · 仅对话`:` · Conversation only`:``]},e.id)),(t.credentialSource||y===`boson/higgs-realtime`)&&(0,j.jsx)(c,{value:`boson/higgs-realtime`,children:`Higgs Realtime`}),T&&(0,j.jsxs)(c,{value:y,children:[y,` · `,i?`不可用`:`Unavailable`]})]}),w?.tools===!1&&(0,j.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`此模型仅支持语音交流,不能交办任务。自动选择时会使用具备行动能力的备用引擎。`:`This model supports conversation only. Automatic selection uses the fallback Agent engine to retain actions.`})]}),S&&(0,j.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,j.jsx)(`span`,{className:`block`,children:i?`声音`:`Voice`}),(0,j.jsxs)(s,{side:`top`,"aria-label":i?`自然语音音色`:`Natural voice`,value:e?.higgsVoice??`inherit`,onChange:e=>a({higgsVoice:e.target.value===`inherit`?null:e.target.value}),children:[(0,j.jsxs)(c,{value:`inherit`,children:[i?`跟随系统音色`:`Follow system voice`,` · `,t.voice==="default"?i?`模型默认`:`Model default`:t.voice]}),m.map(e=>(0,j.jsx)(c,{value:e,children:e==="default"?i?`模型默认`:`Model default`:e},e))]})]}),o&&(!b||T||S&&!t.credentialSource)&&(0,j.jsx)(x,{type:`button`,variant:`ghost`,onClick:o,children:i?`设置自然语音服务`:`Set up natural voice`})]})]})]})})}var N=new _;function P({conversationId:e,zh:t,onSaved:n}){let r=g(t=>t.sessions[e]),[i,a]=(0,A.useState)(!0),[s,c]=(0,A.useState)(``);(0,A.useEffect)(()=>{let t=!0;return N.loadSessionAgentConfig(e).then(n=>{t&&v(e,n)}).catch(e=>{t&&c(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let l=!!r?.modelConfigSaving;async function u(t,i){g.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{v(e,await N.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await N.loadSessionAgentConfig(e).catch(()=>null);throw n&&v(e,n),t}finally{g.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,j.jsxs)(`section`,{children:[(0,j.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型`:`Chat model`}),i?(0,j.jsx)(p,{className:`h-9 w-full`}):(0,j.jsx)(y,{chat:o(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:l,thinkingDisabled:l,onModelChange:u,onThinkingChange:e=>u(r?.model??``,e)}),s&&(0,j.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:s})]})}function F({record:e,zh:t,onSelectVoice:n,onGreetingChange:i,onOpenServices:a,active:o=!0}){let[s,c]=(0,A.useState)(!1),[f,m]=(0,A.useState)(!0),[h,g]=(0,A.useState)(``),[_,v]=(0,A.useState)(null),[y,b]=(0,A.useState)([]),[x,C]=(0,A.useState)(e.voicePreference?.voice??``),[w,D]=(0,A.useState)(!1),[k,M]=(0,A.useState)(null),[N,P]=(0,A.useState)(null),[F,I]=(0,A.useState)(null),L=(0,A.useRef)(null),R=(0,A.useRef)(null);(0,A.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await O();if(e||(c(t.openingGreeting===!0),!t.enabled||!t.tts))return;let n={provider:t.tts.provider,model:t.tts.model};v(n);let r=await E(n.provider,n.model,`realtime`);e||b(r)}catch(t){e||P(t instanceof Error?t.message:String(t))}finally{e||m(!1)}})(),()=>{e=!0}},[]),(0,A.useEffect)(()=>()=>{R.current?.abort(),L.current?.close()},[]);let z=(0,A.useCallback)(()=>{R.current?.abort(),R.current=null,L.current?.close(),L.current=null,I(null)},[]);(0,A.useEffect)(()=>{o||z()},[o,z]);let B=async e=>{if(F!==null){z();return}z(),P(null);let n=new AbortController;R.current=n,I(e);try{let t=new S;L.current=t,await t.start();let r=await T(n.signal,e);n.signal.aborted||t.enqueue(r,()=>{R.current===n&&(I(null),R.current=null,L.current=null,t.close())})}catch(e){if(!n.signal.aborted){let n=e?.body?.error?.code;P(t&&n===`unsupported_voice`?`当前音色暂不可用,请刷新语音目录或选择其他音色。`:e instanceof Error?e.message:String(e))}R.current===n&&z()}},V=async e=>{if(w||e===x)return;z();let t=x;C(e),g(``),D(!0),P(null);try{await n(e&&_?{provider:_.provider,model:_.model,voice:e}:null)||C(t)}catch(e){C(t),P(e instanceof Error?e.message:String(e))}finally{D(!1)}},H=y.find(e=>e.id===x),U=t?`默认声音`:`Default voice`,W=H?.name||(x?t?`当前音色不可用`:`Current voice unavailable`:U),G=h.trim().toLocaleLowerCase(),K=y.filter(e=>!G||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(G)).map(e=>({value:e.id,label:e.name}));return(0,j.jsxs)(`section`,{children:[(0,j.jsx)(`h4`,{className:`text-sm text-fg`,children:t?`声音`:`Voice`}),f?(0,j.jsx)(`div`,{className:`mt-1`,"aria-busy":`true`,children:(0,j.jsx)(p,{className:`h-10 w-full`})}):_&&y.length?(0,j.jsxs)(`div`,{className:`mt-1 space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,j.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,j.jsx)(l,{value:x,selectedLabel:W,options:K,side:`top`,placeholder:U,emptyLabel:U,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:w,onChange:e=>void V(e),searchPlaceholder:y.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:h,onSearchChange:g,statusMessage:G&&!K.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,j.jsxs)(`button`,{type:`button`,disabled:w||!!(x&&!H),onClick:()=>void B(x),className:`touch-target flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-edge px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,title:F===null?t?`试听${W}`:`Preview ${W}`:t?`停止试听`:`Stop preview`,"aria-label":F===null?t?`试听${W}`:`Preview ${W}`:t?`停止试听`:`Stop preview`,children:[F===null?(0,j.jsx)(u,{className:`size-4`,"aria-hidden":!0}):(0,j.jsx)(d,{className:`size-4 text-accent`,"aria-hidden":!0}),F===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(H?.description||H?.style||!x)&&(0,j.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:H?.description||H?.style||(t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,j.jsxs)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,a?(0,j.jsx)(`button`,{type:`button`,onClick:a,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`}):(0,j.jsx)(r,{to:`/settings/personal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),i&&s&&(0,j.jsxs)(`label`,{className:`mt-4 flex items-center justify-between gap-3 text-sm text-fg`,children:[t?`接通时问候`:`Greet me when connected`,(0,j.jsx)(`input`,{type:`checkbox`,checked:k??e.voiceCallPreferences?.openingGreetingEnabled??!0,disabled:w||k!==null,onChange:e=>{let t=e.target.checked;M(t),i(t).catch(e=>P(String(e))).finally(()=>M(null))}})]}),N&&(0,j.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:N})]})}var I=[{id:`loopi`,zh:`Loopi`,en:`Loopi`,color:`bg-slate-100/50 dark:bg-slate-400/10`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`,color:`bg-blue-100/50 dark:bg-blue-400/10`},{id:`loopi-care`,zh:`温和`,en:`Gentle`,color:`bg-violet-100/50 dark:bg-violet-400/10`}];function L({zh:e,onOpenVoiceServices:t,showMessageReactions:n=!1}){let[o,s]=(0,A.useState)(null),c=(0,A.useRef)(null),l=(0,A.useRef)(Promise.resolve()),[u,d]=(0,A.useState)(!0),[m,h]=(0,A.useState)(0),[g,_]=(0,A.useState)(null),[v,y]=(0,A.useState)(`loopi`),[x,S]=(0,A.useState)(!1),T=(0,A.useRef)(null),[E,O]=(0,A.useState)(``),[N,L]=(0,A.useState)(!1),R=(0,A.useCallback)(async()=>{_(null);try{let e=await a(i(`/api/personal-agent`)),t=c.current;c.current=e.payload,s(e.payload),e.payload&&(e.payload.displayName!==t?.displayName&&O(e.payload.displayName),e.payload.appearance!==t?.appearance&&y(e.payload.appearance))}catch(e){_(e instanceof Error?e.message:String(e))}finally{d(!1)}},[]);(0,A.useEffect)(()=>{R()},[R]),(0,A.useEffect)(()=>{let e=e=>{let t=e.detail;t&&(t.displayName!==c.current?.displayName&&O(t.displayName),t.appearance!==c.current?.appearance&&y(t.appearance),c.current=t,s(t))};return window.addEventListener(`personal-agent-updated`,e),()=>window.removeEventListener(`personal-agent-updated`,e)},[]),(0,A.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.detail;!t||t.conversationId!==c.current?.conversationId||(l.current=l.current.then(()=>{if(t.enabled!==c.current?.messageReactionsEnabled)return R()}))};return window.addEventListener(`session-agent-reaction-preference`,e),()=>window.removeEventListener(`session-agent-reaction-preference`,e)},[R,n]);let{data:z,error:B}=b(o?.state===`ready`?i(k):null,D),V=(0,A.useCallback)((e,t=!0)=>{t&&h(e=>e+1),_(null);let n=l.current.then(async()=>{let t=c.current;if(!t)return!1;let n=e.displayName?.trim()||t.displayName,r=e.appearance??t.appearance,o=e.voicePreference===void 0?t.voicePreference:e.voicePreference;if(n===t.displayName&&r===t.appearance&&JSON.stringify(o)===JSON.stringify(t.voicePreference)&&(e.messageReactionsEnabled===void 0||e.messageReactionsEnabled===t.messageReactionsEnabled)&&!e.voiceCallPreferences)return!0;try{let l=await a(i(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:t.revision,displayName:n,appearance:r,...e.voicePreference===void 0?{}:{voicePreference:o},...e.messageReactionsEnabled===void 0?{}:{messageReactionsEnabled:e.messageReactionsEnabled},...e.voiceCallPreferences?{voiceCallPreferences:e.voiceCallPreferences}:{}})});return c.current=l.payload,s(l.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:l.payload})),!0}catch(e){return e instanceof Error&&`status`in e&&e.status===409&&await R(),_(e instanceof Error?e.message:String(e)),!1}}).finally(()=>{t&&h(e=>e-1)});return l.current=n,n},[R]),H=async t=>{if(!o||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){_(e?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(t.size===0||t.size>512*1024){_(e?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}S(!0),_(null);try{let e=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await a(i(`/api/agents/${encodeURIComponent(o.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:e.slice(e.indexOf(`,`)+1),mimeType:t.type})}),C(o.agentId),y(`custom`),L(!1),await V({appearance:`custom`})}catch(e){_(e instanceof Error?e.message:String(e))}finally{S(!1)}};if(u)return(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsx)(p,{className:`h-20 w-full`}),(0,j.jsx)(p,{className:`h-48 w-full`})]});if(o?.state!==`ready`)return(0,j.jsxs)(`div`,{className:`space-y-3 text-sm text-fg-muted`,children:[g?(0,j.jsx)(`p`,{role:`alert`,children:g}):null,(0,j.jsx)(r,{to:`/personal`,className:`text-accent hover:underline`,children:e?`前往 Ada 完成设置`:`Finish setting up Ada`}),g?(0,j.jsx)(`button`,{type:`button`,onClick:()=>void R(),className:`ml-3 text-accent hover:underline`,children:e?`重试`:`Retry`}):null]});let U=e?`消息表情`:`Message reactions`,W=o.messageReactionsEnabled===!0;return(0,j.jsxs)(`section`,{className:`space-y-5`,"aria-label":e?`Ada 助手设置`:`Ada assistant settings`,children:[(0,j.jsxs)(`div`,{className:`relative flex flex-col items-center text-center`,children:[(0,j.jsx)(`button`,{type:`button`,disabled:x,onClick:()=>L(e=>!e),"aria-expanded":N,"aria-controls":`personal-appearance-options`,"aria-label":e?`选择头像`:`Choose avatar`,className:`rounded-full transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,j.jsx)(w,{appearance:v,agentId:o.agentId,className:`size-16`})}),(0,j.jsx)(`input`,{id:`personal-name`,"aria-label":e?`助手名称`:`Assistant name`,value:E,onChange:e=>O(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(O(t),V({displayName:t})):O(c.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=c.current?.displayName??``,O(e.currentTarget.value),e.currentTarget.blur())},maxLength:60,placeholder:`Ada`,className:`mt-2 w-full min-w-0 rounded-lg border border-transparent bg-transparent px-2 py-1 text-center text-lg font-semibold text-fg outline-none transition-colors hover:border-edge focus:border-edge focus:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,j.jsxs)(`div`,{className:`space-y-5`,children:[g&&(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:g}),N&&(0,j.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,j.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:e?`形象`:`Appearance`}),(0,j.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[I.map(t=>(0,j.jsxs)(`button`,{type:`button`,onClick:()=>{y(t.id),L(!1),V({appearance:t.id})},"aria-pressed":v===t.id,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${v===t.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,j.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${t.color}`,children:(0,j.jsx)(w,{appearance:t.id,className:`size-8`})}),(0,j.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:e?t.zh:t.en})]},t.id)),(0,j.jsx)(`input`,{ref:T,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`sr-only`,"aria-label":e?`上传头像`:`Upload avatar`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&H(t),e.currentTarget.value=``}}),(0,j.jsxs)(`button`,{type:`button`,disabled:x,onClick:()=>T.current?.click(),"aria-pressed":v===`custom`,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${v===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,j.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:v===`custom`?(0,j.jsx)(w,{appearance:`custom`,agentId:o.agentId,className:`size-8`}):(0,j.jsx)(f,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,j.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:x?e?`上传中…`:`Uploading…`:e?`上传`:`Upload`})]})]})]}),(0,j.jsx)(P,{conversationId:o.conversationId,zh:e,onSaved:async()=>{let e=await a(i(`/api/personal-agent`));e.ok&&e.payload&&(c.current=e.payload,s(e.payload))}}),n&&(0,j.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-4 rounded-xl border border-edge px-4`,children:[(0,j.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:U}),(0,j.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":U,"aria-checked":W,disabled:m>0,onClick:()=>void V({messageReactionsEnabled:!W}),className:`group touch-target flex shrink-0 items-center rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-60`,children:(0,j.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-11 items-center rounded-full bg-fg-muted/30 p-0.5 transition-colors group-aria-checked:bg-accent motion-reduce:transition-none`,children:(0,j.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform group-aria-checked:translate-x-5 motion-reduce:transition-none`})})})]}),(0,j.jsx)(M,{preferences:o.voiceCallPreferences,settings:z,failed:!!B,disabled:m>0,zh:e,onOpenServices:t,onChange:e=>V({voiceCallPreferences:e},e.enginePreference===void 0),children:n=>(0,j.jsx)(F,{active:n,onOpenServices:t,onGreetingChange:e=>V({voiceCallPreferences:{openingGreetingEnabled:e}},!1),record:o,zh:e,onSelectVoice:e=>V({voicePreference:e})})})]})]})}export{L as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{i,o as a}from"./locale-store-CHjsq5NR.js";import{t as o}from"./messages-C7QSnTdg.js";import{n as s,r as c,t as l}from"./popover-select-hRG1EzAY.js";import{t as u}from"./play-kxZvpBg8.js";import{t as d}from"./square-DMK_fB-3.js";import{t as f}from"./upload-rrb46c3c.js";import{t as p}from"./skeleton-DzdOeGYz.js";import{n as m,t as h}from"./voice-CUfqdnlR.js";import{k as g,t as _,v}from"./session-manager-C2MCS4C5.js";import{t as y}from"./composer-model-config-control-C2Bku39S.js";import{i as b}from"./vendor-swr-CdRzEUwF.js";import{t as x}from"./button-C5tRaJxt.js";import{u as S}from"./use-realtime-voice-CV3GIt_T.js";import{s as C}from"./agent-avatar-display-D_UDgOr9.js";import{t as w}from"./personal-avatar-1TVnHakL.js";import{d as T,i as E,n as D,r as O,t as k}from"./voice-config-api-sXEIG6lz.js";var A=e(t(),1),j=n();function M({preferences:e,settings:t,failed:n,disabled:r,zh:i,onChange:a,onOpenServices:o,children:l}){let[u,d]=(0,A.useState)(null),f=(0,A.useRef)(0),g=u??e?.enginePreference??`auto`;async function _(e){if(e===g)return;let t=++f.current;d(e);try{await a({enginePreference:e})}finally{t===f.current&&d(null)}}let v=t?.defaultForNatural?h:t?.legacyModel,y=e?.naturalModel,b=y??v,S=b===h,C=t?.naturalModels??(t?.legacyModel?[{id:t.legacyModel,name:t.legacyModelLabel??t.legacyModel,tools:void 0}]:[]),w=C.find(e=>e.id===b),T=y&&y!==`boson/higgs-realtime`&&!C.some(e=>e.id===y);return(0,j.jsx)(`section`,{className:`space-y-3`,"aria-label":i?`语音通话设置`:`Voice call settings`,children:(0,j.jsxs)(`fieldset`,{disabled:r,className:`space-y-3`,children:[(0,j.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,j.jsx)(`span`,{children:i?`通话引擎`:`Call engine`}),(0,j.jsxs)(s,{side:`top`,"aria-label":i?`通话引擎`:`Call engine`,value:g,onChange:e=>{_(e.target.value)},children:[(0,j.jsx)(c,{value:`auto`,children:i?`自动选择`:`Automatic`}),(0,j.jsx)(c,{value:`natural`,children:i?`实时语音`:`Realtime voice`}),(0,j.jsx)(c,{value:`assistant`,children:i?`助手语音`:`Assistant voice`})]})]}),(0,j.jsx)(`div`,{inert:g===`natural`,"aria-hidden":g===`natural`,className:g===`natural`?`hidden`:``,children:l(g!==`natural`)}),(0,j.jsxs)(`div`,{inert:g===`assistant`,"aria-hidden":g===`assistant`,className:`space-y-3 ${g===`assistant`?`hidden`:``}`,children:[!t&&!n&&(0,j.jsx)(p,{className:`h-10 w-full`}),n&&(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:i?`无法读取自然语音模型。`:`Could not load natural voice models.`}),t&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,j.jsx)(`span`,{className:`block`,children:i?`通话模型`:`Call model`}),(0,j.jsxs)(s,{side:`top`,"aria-label":i?`自然语音模型`:`Natural voice model`,value:y??`inherit`,onChange:e=>a({naturalModel:e.target.value===`inherit`?null:e.target.value}),children:[(0,j.jsxs)(c,{value:`inherit`,children:[i?`跟随系统`:`Follow system`,v?` · ${v===`boson/higgs-realtime`?`Higgs Realtime`:t.legacyModelLabel??v}`:``]}),C.map(e=>(0,j.jsxs)(c,{value:e.id,children:[e.name,e.tools===!1?i?` · 仅对话`:` · Conversation only`:``]},e.id)),(t.credentialSource||y===`boson/higgs-realtime`)&&(0,j.jsx)(c,{value:`boson/higgs-realtime`,children:`Higgs Realtime`}),T&&(0,j.jsxs)(c,{value:y,children:[y,` · `,i?`不可用`:`Unavailable`]})]}),w?.tools===!1&&(0,j.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`此模型仅支持语音交流,不能交办任务。自动选择时会使用具备行动能力的备用引擎。`:`This model supports conversation only. Automatic selection uses the fallback Agent engine to retain actions.`})]}),S&&(0,j.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,j.jsx)(`span`,{className:`block`,children:i?`声音`:`Voice`}),(0,j.jsxs)(s,{side:`top`,"aria-label":i?`自然语音音色`:`Natural voice`,value:e?.higgsVoice??`inherit`,onChange:e=>a({higgsVoice:e.target.value===`inherit`?null:e.target.value}),children:[(0,j.jsxs)(c,{value:`inherit`,children:[i?`跟随系统音色`:`Follow system voice`,` · `,t.voice==="default"?i?`模型默认`:`Model default`:t.voice]}),m.map(e=>(0,j.jsx)(c,{value:e,children:e==="default"?i?`模型默认`:`Model default`:e},e))]})]}),o&&(!b||T||S&&!t.credentialSource)&&(0,j.jsx)(x,{type:`button`,variant:`ghost`,onClick:o,children:i?`设置自然语音服务`:`Set up natural voice`})]})]})]})})}var N=new _;function P({conversationId:e,zh:t,onSaved:n}){let r=g(t=>t.sessions[e]),[i,a]=(0,A.useState)(!0),[s,c]=(0,A.useState)(``);(0,A.useEffect)(()=>{let t=!0;return N.loadSessionAgentConfig(e).then(n=>{t&&v(e,n)}).catch(e=>{t&&c(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let l=!!r?.modelConfigSaving;async function u(t,i){g.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{v(e,await N.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await N.loadSessionAgentConfig(e).catch(()=>null);throw n&&v(e,n),t}finally{g.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,j.jsxs)(`section`,{children:[(0,j.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型`:`Chat model`}),i?(0,j.jsx)(p,{className:`h-9 w-full`}):(0,j.jsx)(y,{chat:o(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:l,thinkingDisabled:l,onModelChange:u,onThinkingChange:e=>u(r?.model??``,e)}),s&&(0,j.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:s})]})}function F({record:e,zh:t,onSelectVoice:n,onGreetingChange:i,onOpenServices:a,active:o=!0}){let[s,c]=(0,A.useState)(!1),[f,m]=(0,A.useState)(!0),[h,g]=(0,A.useState)(``),[_,v]=(0,A.useState)(null),[y,b]=(0,A.useState)([]),[x,C]=(0,A.useState)(e.voicePreference?.voice??``),[w,D]=(0,A.useState)(!1),[k,M]=(0,A.useState)(null),[N,P]=(0,A.useState)(null),[F,I]=(0,A.useState)(null),L=(0,A.useRef)(null),R=(0,A.useRef)(null);(0,A.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await O();if(e||(c(t.openingGreeting===!0),!t.enabled||!t.tts))return;let n={provider:t.tts.provider,model:t.tts.model};v(n);let r=await E(n.provider,n.model,`realtime`);e||b(r)}catch(t){e||P(t instanceof Error?t.message:String(t))}finally{e||m(!1)}})(),()=>{e=!0}},[]),(0,A.useEffect)(()=>()=>{R.current?.abort(),L.current?.close()},[]);let z=(0,A.useCallback)(()=>{R.current?.abort(),R.current=null,L.current?.close(),L.current=null,I(null)},[]);(0,A.useEffect)(()=>{o||z()},[o,z]);let B=async e=>{if(F!==null){z();return}z(),P(null);let n=new AbortController;R.current=n,I(e);try{let t=new S;L.current=t,await t.start();let r=await T(n.signal,e);n.signal.aborted||t.enqueue(r,()=>{R.current===n&&(I(null),R.current=null,L.current=null,t.close())})}catch(e){if(!n.signal.aborted){let n=e?.body?.error?.code;P(t&&n===`unsupported_voice`?`当前音色暂不可用,请刷新语音目录或选择其他音色。`:e instanceof Error?e.message:String(e))}R.current===n&&z()}},V=async e=>{if(w||e===x)return;z();let t=x;C(e),g(``),D(!0),P(null);try{await n(e&&_?{provider:_.provider,model:_.model,voice:e}:null)||C(t)}catch(e){C(t),P(e instanceof Error?e.message:String(e))}finally{D(!1)}},H=y.find(e=>e.id===x),U=t?`默认声音`:`Default voice`,W=H?.name||(x?t?`当前音色不可用`:`Current voice unavailable`:U),G=h.trim().toLocaleLowerCase(),K=y.filter(e=>!G||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(G)).map(e=>({value:e.id,label:e.name}));return(0,j.jsxs)(`section`,{children:[(0,j.jsx)(`h4`,{className:`text-sm text-fg`,children:t?`声音`:`Voice`}),f?(0,j.jsx)(`div`,{className:`mt-1`,"aria-busy":`true`,children:(0,j.jsx)(p,{className:`h-10 w-full`})}):_&&y.length?(0,j.jsxs)(`div`,{className:`mt-1 space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,j.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,j.jsx)(l,{value:x,selectedLabel:W,options:K,side:`top`,placeholder:U,emptyLabel:U,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:w,onChange:e=>void V(e),searchPlaceholder:y.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:h,onSearchChange:g,statusMessage:G&&!K.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,j.jsxs)(`button`,{type:`button`,disabled:w||!!(x&&!H),onClick:()=>void B(x),className:`touch-target flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-edge px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,title:F===null?t?`试听${W}`:`Preview ${W}`:t?`停止试听`:`Stop preview`,"aria-label":F===null?t?`试听${W}`:`Preview ${W}`:t?`停止试听`:`Stop preview`,children:[F===null?(0,j.jsx)(u,{className:`size-4`,"aria-hidden":!0}):(0,j.jsx)(d,{className:`size-4 text-accent`,"aria-hidden":!0}),F===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(H?.description||H?.style||!x)&&(0,j.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:H?.description||H?.style||(t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,j.jsxs)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,a?(0,j.jsx)(`button`,{type:`button`,onClick:a,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`}):(0,j.jsx)(r,{to:`/settings/personal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),i&&s&&(0,j.jsxs)(`label`,{className:`mt-4 flex items-center justify-between gap-3 text-sm text-fg`,children:[t?`接通时问候`:`Greet me when connected`,(0,j.jsx)(`input`,{type:`checkbox`,checked:k??e.voiceCallPreferences?.openingGreetingEnabled??!0,disabled:w||k!==null,onChange:e=>{let t=e.target.checked;M(t),i(t).catch(e=>P(String(e))).finally(()=>M(null))}})]}),N&&(0,j.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:N})]})}var I=[{id:`loopi`,zh:`Loopi`,en:`Loopi`,color:`bg-slate-100/50 dark:bg-slate-400/10`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`,color:`bg-blue-100/50 dark:bg-blue-400/10`},{id:`loopi-care`,zh:`温和`,en:`Gentle`,color:`bg-violet-100/50 dark:bg-violet-400/10`}];function L({zh:e,onOpenVoiceServices:t,showMessageReactions:n=!1}){let[o,s]=(0,A.useState)(null),c=(0,A.useRef)(null),l=(0,A.useRef)(Promise.resolve()),[u,d]=(0,A.useState)(!0),[m,h]=(0,A.useState)(0),[g,_]=(0,A.useState)(null),[v,y]=(0,A.useState)(`loopi`),[x,S]=(0,A.useState)(!1),T=(0,A.useRef)(null),[E,O]=(0,A.useState)(``),[N,L]=(0,A.useState)(!1),R=(0,A.useCallback)(async()=>{_(null);try{let e=await a(i(`/api/personal-agent`)),t=c.current;c.current=e.payload,s(e.payload),e.payload&&(e.payload.displayName!==t?.displayName&&O(e.payload.displayName),e.payload.appearance!==t?.appearance&&y(e.payload.appearance))}catch(e){_(e instanceof Error?e.message:String(e))}finally{d(!1)}},[]);(0,A.useEffect)(()=>{R()},[R]),(0,A.useEffect)(()=>{let e=e=>{let t=e.detail;t&&(t.displayName!==c.current?.displayName&&O(t.displayName),t.appearance!==c.current?.appearance&&y(t.appearance),c.current=t,s(t))};return window.addEventListener(`personal-agent-updated`,e),()=>window.removeEventListener(`personal-agent-updated`,e)},[]),(0,A.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.detail;!t||t.conversationId!==c.current?.conversationId||(l.current=l.current.then(()=>{if(t.enabled!==c.current?.messageReactionsEnabled)return R()}))};return window.addEventListener(`session-agent-reaction-preference`,e),()=>window.removeEventListener(`session-agent-reaction-preference`,e)},[R,n]);let{data:z,error:B}=b(o?.state===`ready`?i(k):null,D),V=(0,A.useCallback)((e,t=!0)=>{t&&h(e=>e+1),_(null);let n=l.current.then(async()=>{let t=c.current;if(!t)return!1;let n=e.displayName?.trim()||t.displayName,r=e.appearance??t.appearance,o=e.voicePreference===void 0?t.voicePreference:e.voicePreference;if(n===t.displayName&&r===t.appearance&&JSON.stringify(o)===JSON.stringify(t.voicePreference)&&(e.messageReactionsEnabled===void 0||e.messageReactionsEnabled===t.messageReactionsEnabled)&&!e.voiceCallPreferences)return!0;try{let l=await a(i(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:t.revision,displayName:n,appearance:r,...e.voicePreference===void 0?{}:{voicePreference:o},...e.messageReactionsEnabled===void 0?{}:{messageReactionsEnabled:e.messageReactionsEnabled},...e.voiceCallPreferences?{voiceCallPreferences:e.voiceCallPreferences}:{}})});return c.current=l.payload,s(l.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:l.payload})),!0}catch(e){return e instanceof Error&&`status`in e&&e.status===409&&await R(),_(e instanceof Error?e.message:String(e)),!1}}).finally(()=>{t&&h(e=>e-1)});return l.current=n,n},[R]),H=async t=>{if(!o||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){_(e?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(t.size===0||t.size>512*1024){_(e?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}S(!0),_(null);try{let e=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await a(i(`/api/agents/${encodeURIComponent(o.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:e.slice(e.indexOf(`,`)+1),mimeType:t.type})}),C(o.agentId),y(`custom`),L(!1),await V({appearance:`custom`})}catch(e){_(e instanceof Error?e.message:String(e))}finally{S(!1)}};if(u)return(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsx)(p,{className:`h-20 w-full`}),(0,j.jsx)(p,{className:`h-48 w-full`})]});if(o?.state!==`ready`)return(0,j.jsxs)(`div`,{className:`space-y-3 text-sm text-fg-muted`,children:[g?(0,j.jsx)(`p`,{role:`alert`,children:g}):null,(0,j.jsx)(r,{to:`/personal`,className:`text-accent hover:underline`,children:e?`前往 Ada 完成设置`:`Finish setting up Ada`}),g?(0,j.jsx)(`button`,{type:`button`,onClick:()=>void R(),className:`ml-3 text-accent hover:underline`,children:e?`重试`:`Retry`}):null]});let U=e?`消息表情`:`Message reactions`,W=o.messageReactionsEnabled===!0;return(0,j.jsxs)(`section`,{className:`space-y-5`,"aria-label":e?`Ada 助手设置`:`Ada assistant settings`,children:[(0,j.jsxs)(`div`,{className:`relative flex flex-col items-center text-center`,children:[(0,j.jsx)(`button`,{type:`button`,disabled:x,onClick:()=>L(e=>!e),"aria-expanded":N,"aria-controls":`personal-appearance-options`,"aria-label":e?`选择头像`:`Choose avatar`,className:`rounded-full transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,j.jsx)(w,{appearance:v,agentId:o.agentId,className:`size-16`})}),(0,j.jsx)(`input`,{id:`personal-name`,"aria-label":e?`助手名称`:`Assistant name`,value:E,onChange:e=>O(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(O(t),V({displayName:t})):O(c.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=c.current?.displayName??``,O(e.currentTarget.value),e.currentTarget.blur())},maxLength:60,placeholder:`Ada`,className:`mt-2 w-full min-w-0 rounded-lg border border-transparent bg-transparent px-2 py-1 text-center text-lg font-semibold text-fg outline-none transition-colors hover:border-edge focus:border-edge focus:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,j.jsxs)(`div`,{className:`space-y-5`,children:[g&&(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:g}),N&&(0,j.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,j.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:e?`形象`:`Appearance`}),(0,j.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[I.map(t=>(0,j.jsxs)(`button`,{type:`button`,onClick:()=>{y(t.id),L(!1),V({appearance:t.id})},"aria-pressed":v===t.id,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${v===t.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,j.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${t.color}`,children:(0,j.jsx)(w,{appearance:t.id,className:`size-8`})}),(0,j.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:e?t.zh:t.en})]},t.id)),(0,j.jsx)(`input`,{ref:T,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`sr-only`,"aria-label":e?`上传头像`:`Upload avatar`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&H(t),e.currentTarget.value=``}}),(0,j.jsxs)(`button`,{type:`button`,disabled:x,onClick:()=>T.current?.click(),"aria-pressed":v===`custom`,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${v===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,j.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:v===`custom`?(0,j.jsx)(w,{appearance:`custom`,agentId:o.agentId,className:`size-8`}):(0,j.jsx)(f,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,j.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:x?e?`上传中…`:`Uploading…`:e?`上传`:`Upload`})]})]})]}),(0,j.jsx)(P,{conversationId:o.conversationId,zh:e,onSaved:async()=>{let e=await a(i(`/api/personal-agent`));e.ok&&e.payload&&(c.current=e.payload,s(e.payload))}}),n&&(0,j.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-4 rounded-xl border border-edge px-4`,children:[(0,j.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:U}),(0,j.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":U,"aria-checked":W,disabled:m>0,onClick:()=>void V({messageReactionsEnabled:!W}),className:`group touch-target flex shrink-0 items-center rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-60`,children:(0,j.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-11 items-center rounded-full bg-fg-muted/30 p-0.5 transition-colors group-aria-checked:bg-accent motion-reduce:transition-none`,children:(0,j.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform group-aria-checked:translate-x-5 motion-reduce:transition-none`})})})]}),(0,j.jsx)(M,{preferences:o.voiceCallPreferences,settings:z,failed:!!B,disabled:m>0,zh:e,onOpenServices:t,onChange:e=>V({voiceCallPreferences:e},e.enginePreference===void 0),children:n=>(0,j.jsx)(F,{active:n,onOpenServices:t,onGreetingChange:e=>V({voiceCallPreferences:{openingGreetingEnabled:e}},!1),record:o,zh:e,onSelectVoice:e=>V({voicePreference:e})})})]})]})}export{L as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,n as a,o}from"./locale-store-CHjsq5NR.js";import{t as s}from"./popover-select-hRG1EzAY.js";import{t as c}from"./skeleton-DzdOeGYz.js";import{St as l}from"./session-manager-DUWeBdeG.js";import{t as u}from"./voice-settings-j8o-hGTm.js";import{t as d}from"./use-personal-profile-D4gLM6Wi.js";import{n as f,t as p}from"./settings-page-header-C21Iw2rD.js";import"./settings-page-layout-BXcLlp6p.js";import{t as m}from"./personal-profile-settings-TcI0Zfwr.js";var h=n(),g=e(t(),1),_=r();function v(){try{return[`UTC`,...Intl.supportedValuesOf(`timeZone`)]}catch{return[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Seoul`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`Australia/Sydney`,`Pacific/Auckland`]}}var y=v();function b({zh:e}){let[t,n]=(0,g.useState)(),[r,a]=(0,g.useState)(``),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(``),m=f.trim().toLowerCase().replaceAll(`_`,` `),h=[...new Set([...y,t?.timezone].filter(e=>!!e))].sort().filter(e=>e.replaceAll(`_`,` `).toLowerCase().includes(m)).map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.split(`/`)[0]}));(0,g.useEffect)(()=>{let e=!0;return o(i(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(l.parse(t.payload))}).catch(t=>{e&&a(String(t))}),()=>{e=!1}},[]);async function v(e){if(!(!t||u)){d(!0),a(``);try{let r=await o(i(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(l.parse(r.payload))}catch(e){a(String(e));let t=await o(i(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(l.parse(t.payload))}finally{d(!1)}}}return(0,_.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,_.jsx)(c,{className:`h-9 w-full`}):t&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(s,{placeholder:e?`选择主动方式`:`Choose participation`,value:t.mode,disabled:u,allowEmpty:!1,options:[{value:`off`,label:e?`关闭主动联系`:`Off`},{value:`follow_up`,label:e?`仅明确跟进`:`Requested follow-ups`},{value:`balanced`,label:e?`适度主动`:`Thoughtful participation`}],onChange:e=>void v({mode:e})}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰开始`:`Quiet from`,(0,_.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietStart),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void v({quietStart:Number(e)})})]}),(0,_.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰结束`:`Quiet until`,(0,_.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietEnd),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void v({quietEnd:Number(e)})})]})]}),(0,_.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,_.jsx)(s,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:h,disabled:u,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:f,onSearchChange:p,statusMessage:h.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{p(``),e!==t.timezone&&v({timezone:e})}})]}),(0,_.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,_.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}function x(){let e=(0,h.c)(22),{displayName:t}=d(),n=a(S)===`zh`,[r,i]=(0,g.useState)(!1),[o,s]=(0,g.useState)(!1),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{i(!0),s(!0)},e[0]=c):c=e[0];let l=c,v;e[1]===t?v=e[2]:(v=(0,_.jsx)(p,{title:t}),e[1]=t,e[2]=v);let y,x;e[3]===n?(y=e[4],x=e[5]):(y=(0,_.jsx)(m,{zh:n,onOpenVoiceServices:l,showMessageReactions:!0}),x=(0,_.jsx)(b,{zh:n}),e[3]=n,e[4]=y,e[5]=x);let C;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{i(e.currentTarget.open),e.currentTarget.open&&s(!0)},e[6]=C):C=e[6];let w=n?`语音服务设置`:`Voice service settings`,T;e[7]===w?T=e[8]:(T=(0,_.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:w}),e[7]=w,e[8]=T);let E;e[9]===o?E=e[10]:(E=o&&(0,_.jsx)(u,{capability:`conversation`}),e[9]=o,e[10]=E);let D;e[11]===E?D=e[12]:(D=(0,_.jsx)(`div`,{className:`mt-4`,children:E}),e[11]=E,e[12]=D);let O;e[13]!==r||e[14]!==T||e[15]!==D?(O=(0,_.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,open:r,onToggle:C,children:[T,D]}),e[13]=r,e[14]=T,e[15]=D,e[16]=O):O=e[16];let k;return e[17]!==v||e[18]!==y||e[19]!==x||e[20]!==O?(k=(0,_.jsxs)(f,{children:[v,y,x,O]}),e[17]=v,e[18]=y,e[19]=x,e[20]=O,e[21]=k):k=e[21],k}function S(e){return e.language}export{x as PersonalSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,n as a,o}from"./locale-store-CHjsq5NR.js";import{t as s}from"./popover-select-hRG1EzAY.js";import{t as c}from"./skeleton-DzdOeGYz.js";import{gt as l}from"./session-manager-C2MCS4C5.js";import{t as u}from"./voice-settings-JpPo3BvX.js";import{t as d}from"./use-personal-profile-D4gLM6Wi.js";import{n as f,t as p}from"./settings-page-header-C21Iw2rD.js";import"./settings-page-layout-BXcLlp6p.js";import{t as m}from"./personal-profile-settings-XiT1MgTK.js";var h=n(),g=e(t(),1),_=r();function v(){try{return[`UTC`,...Intl.supportedValuesOf(`timeZone`)]}catch{return[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Seoul`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`Australia/Sydney`,`Pacific/Auckland`]}}var y=v();function b({zh:e}){let[t,n]=(0,g.useState)(),[r,a]=(0,g.useState)(``),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(``),m=f.trim().toLowerCase().replaceAll(`_`,` `),h=[...new Set([...y,t?.timezone].filter(e=>!!e))].sort().filter(e=>e.replaceAll(`_`,` `).toLowerCase().includes(m)).map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.split(`/`)[0]}));(0,g.useEffect)(()=>{let e=!0;return o(i(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(l.parse(t.payload))}).catch(t=>{e&&a(String(t))}),()=>{e=!1}},[]);async function v(e){if(!(!t||u)){d(!0),a(``);try{let r=await o(i(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(l.parse(r.payload))}catch(e){a(String(e));let t=await o(i(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(l.parse(t.payload))}finally{d(!1)}}}return(0,_.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,_.jsx)(c,{className:`h-9 w-full`}):t&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(s,{placeholder:e?`选择主动方式`:`Choose participation`,value:t.mode,disabled:u,allowEmpty:!1,options:[{value:`off`,label:e?`关闭主动联系`:`Off`},{value:`follow_up`,label:e?`仅明确跟进`:`Requested follow-ups`},{value:`balanced`,label:e?`适度主动`:`Thoughtful participation`}],onChange:e=>void v({mode:e})}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰开始`:`Quiet from`,(0,_.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietStart),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void v({quietStart:Number(e)})})]}),(0,_.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰结束`:`Quiet until`,(0,_.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietEnd),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void v({quietEnd:Number(e)})})]})]}),(0,_.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,_.jsx)(s,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:h,disabled:u,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:f,onSearchChange:p,statusMessage:h.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{p(``),e!==t.timezone&&v({timezone:e})}})]}),(0,_.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,_.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}function x(){let e=(0,h.c)(22),{displayName:t}=d(),n=a(S)===`zh`,[r,i]=(0,g.useState)(!1),[o,s]=(0,g.useState)(!1),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{i(!0),s(!0)},e[0]=c):c=e[0];let l=c,v;e[1]===t?v=e[2]:(v=(0,_.jsx)(p,{title:t}),e[1]=t,e[2]=v);let y,x;e[3]===n?(y=e[4],x=e[5]):(y=(0,_.jsx)(m,{zh:n,onOpenVoiceServices:l,showMessageReactions:!0}),x=(0,_.jsx)(b,{zh:n}),e[3]=n,e[4]=y,e[5]=x);let C;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{i(e.currentTarget.open),e.currentTarget.open&&s(!0)},e[6]=C):C=e[6];let w=n?`语音服务设置`:`Voice service settings`,T;e[7]===w?T=e[8]:(T=(0,_.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:w}),e[7]=w,e[8]=T);let E;e[9]===o?E=e[10]:(E=o&&(0,_.jsx)(u,{capability:`conversation`}),e[9]=o,e[10]=E);let D;e[11]===E?D=e[12]:(D=(0,_.jsx)(`div`,{className:`mt-4`,children:E}),e[11]=E,e[12]=D);let O;e[13]!==r||e[14]!==T||e[15]!==D?(O=(0,_.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,open:r,onToggle:C,children:[T,D]}),e[13]=r,e[14]=T,e[15]=D,e[16]=O):O=e[16];let k;return e[17]!==v||e[18]!==y||e[19]!==x||e[20]!==O?(k=(0,_.jsxs)(f,{children:[v,y,x,O]}),e[17]=v,e[18]=y,e[19]=x,e[20]=O,e[21]=k):k=e[21],k}function S(e){return e.language}export{x as PersonalSettingsPanel};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-DGZZ-M85.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-Czpn1I53.js","assets/pdf-runtime-JnUAvfIa.js","assets/source-workspace-editor-BwYU5OEh.js","assets/vendor-react-BOUWij0V.js","assets/vendor-codemirror-aCQ0FcJT.js","assets/languages-kF11aUYU.js","assets/binary-plugins-D_zw0TgG.js","assets/messages-C7QSnTdg.js","assets/attachment-utils-core-BPYdUI6y.js","assets/preview-open-alternatives-CY_hjK4b.js","assets/download-Dk-ZjtO6.js","assets/createLucideIcon-DPHK1VkS.js","assets/external-link-DjqjBmc3.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/interaction-BdhHBbYa.js","assets/electron-env-DHOGevH3.js","assets/use-blob-object-url-D4BFuzZB.js","assets/media-plugins-C78NkHfB.js","assets/archive-plugin-CQ5UXgZk.js","assets/jszip.min-Dj17eJqX.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{a,i as o,l as s}from"./locale-store-CHjsq5NR.js";import{t as c}from"./messages-C7QSnTdg.js";import{t as l}from"./createLucideIcon-DPHK1VkS.js";import{G as u,t as d}from"./markdown-view-ihzUc4ud.js";import{t as f}from"./plus-Q2yW6OE7.js";import{t as p}from"./rotate-cw-LIg3Am9S.js";import{t as m}from"./search-DA7gz22f.js";import{t as h}from"./cn-0WouolD0.js";import{t as g}from"./skeleton-DzdOeGYz.js";import{r as _}from"./turn-outcome-BSbEJx8h.js";import{a as v,c as y,o as b,r as x,t as S}from"./attachment-utils-core-BPYdUI6y.js";import{n as C}from"./electron-env-DHOGevH3.js";import{t as w}from"./use-async-resource-BHFGZCY2.js";import{a as T,c as E,d as D,m as O,n as k,r as ee,u as A}from"./workspace-api-BuNWyNvA.js";import{t as j}from"./index.module-Cd9ENXfk.js";var M=l(`step-forward`,[[`path`,{d:`M10.029 4.285A2 2 0 0 0 7 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`1ystz2`}],[`path`,{d:`M3 4v16`,key:`1ph11n`}]]),N=l(`step-back`,[[`path`,{d:`M13.971 4.285A2 2 0 0 1 17 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z`,key:`19qhus`}],[`path`,{d:`M21 20V4`,key:`cb8qj8`}]]),P=5*1024*1024,F=32*1024*1024,I=new Set(`.astro,.bat,.c,.cc,.clj,.cljs,.cljc,.cmd,.cpp,.cs,.cts,.cxx,.dart,.edn,.erl,.ex,.exs,.fish,.fs,.fsx,.go,.gql,.graphql,.groovy,.h,.hh,.hpp,.hrl,.hxx,.java,.ts,.tsx,.mts,.js,.jsx,.mjs,.cjs,.css,.scss,.sass,.less,.json,.jsonc,.json5,.yml,.yaml,.xml,.xsd,.xsl,.py,.pyw,.rb,.php,.rs,.kt,.kts,.scala,.swift,.m,.mm,.sh,.bash,.zsh,.ps1,.sql,.lua,.r,.pl,.pm,.sol,.tf,.tfvars,.nix,.proto,.vue,.svelte,.toml,.ini,.cfg,.conf,.properties`.split(`,`)),L=new Set([`.txt`,`.log`,`.lock`,`.csv`,`.tsv`,`.env`,`.gitignore`,`.gitattributes`,`.editorconfig`,`.npmrc`,`.dockerignore`,`.eslintignore`,`.prettierignore`,`.stylelintignore`]),R=new Set([`dockerfile`,`gemfile`,`jenkinsfile`,`makefile`,`procfile`,`rakefile`]),z=new Set([`brewfile`,`changelog`,`codeowners`,`license`,`readme`]),te=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.bmp`,`.ico`,`.svg`,`.svgz`,`.tif`,`.tiff`,`.avif`,`.heic`,`.heif`,`.jxl`]),B=new Set([`.mp3`,`.wav`,`.ogg`,`.oga`,`.aac`,`.m4a`,`.flac`,`.opus`,`.weba`]),V=new Set([`.mp4`,`.webm`,`.mov`,`.m4v`,`.ogv`]),ne=new Set([`.zip`]),H=new Map([[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.md`,`text/markdown`],[`.markdown`,`text/markdown`],[`.html`,`text/html`],[`.htm`,`text/html`],[`.json`,`application/json`],[`.txt`,`text/plain`],[`.csv`,`text/csv`],[`.tsv`,`text/tab-separated-values`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.mp3`,`audio/mpeg`],[`.wav`,`audio/wav`],[`.ogg`,`audio/ogg`],[`.mp4`,`video/mp4`],[`.webm`,`video/webm`],[`.mov`,`video/quicktime`],[`.zip`,`application/zip`]]);function U(e){let t=W(e),n=t.lastIndexOf(`.`);return n<0||n===t.length-1?``:t.slice(n).toLowerCase()}function W(e){let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]||e}function re(e,t){let n=t?.split(`;`)[0]?.trim().toLowerCase();return n&&n!==`application/octet-stream`?n:H.get(U(e))??n??`application/octet-stream`}function ie(e,t){let n=U(e),r=W(e).toLowerCase(),i=re(e,t);return i===`text/markdown`||n===`.md`||n===`.markdown`?`markdown`:i===`text/html`||n===`.html`||n===`.htm`?`html`:i===`application/pdf`||n===`.pdf`?`pdf`:i===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||n===`.docx`?`docx`:i===`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`||i===`application/vnd.ms-excel`||n===`.xlsx`||n===`.xls`?`spreadsheet`:i===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||n===`.pptx`?`pptx`:i.startsWith(`image/`)||te.has(n)?`image`:i.startsWith(`audio/`)||B.has(n)?`audio`:i.startsWith(`video/`)||V.has(n)?`video`:i===`application/zip`||ne.has(n)?`archive`:I.has(n)||R.has(r)||r.startsWith(`dockerfile.`)?`code`:i.startsWith(`text/`)||L.has(n)||z.has(r)||r.startsWith(`.env.`)||i===`application/json`?`text`:`unsupported`}function ae(e){switch(e){case`text`:case`markdown`:case`code`:case`html`:return`text`;case`unsupported`:return`metadata`;default:return`binary`}}async function G(e){let{uri:t,conversationId:n,taskId:r}=e;try{let e=_(t),i=await a(o(e?`/api/files/${encodeURIComponent(e)}/content`:y(t,n,r)));return i.ok?{ok:!0,blob:await i.blob()}:{ok:!1,reason:`http`,status:i.status}}catch(e){return{ok:!1,reason:`network`,message:e instanceof Error?e.message:String(e)}}}async function oe(e){let t=await G(e);return t.ok?{ok:!0,buffer:await t.blob.arrayBuffer()}:t}var K=n(),q=e(t(),1);function J(e){return e.id?String(e.id):`${e.name}:${e.uri??``}`}function se(){return{id:`__empty__`,context:`attachment`,fileName:``,mimeType:`application/octet-stream`,type:`unsupported`,source:{kind:`inline`}}}function Y(e){let t=(0,K.c)(65),{open:n,attachment:r,authToken:i,conversationId:a,language:o}=e,[s,l]=(0,q.useState)(n?r:null),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),m;t[0]!==r||t[1]!==n?(m=n&&r?J(r):null,t[0]=r,t[1]=n,t[2]=m):m=t[2];let h=m,g=(0,q.useRef)(h);h!==g.current&&(g.current=h,l(n&&r?r:null),d(!1),p(!1));let _=s,y;bb0:{if(!_){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=se(),t[3]=e):e=t[3],y=e;break bb0}let e=_.name??`attachment`,n,r;t[4]!==e||t[5]!==_.mimeType?(n=re(e,_.mimeType),r=ie(e,n),t[4]=e,t[5]=_.mimeType,t[6]=n,t[7]=r):(n=t[6],r=t[7]);let i=r,o=_.id?String(_.id):`${e}:${_.uri??``}`,s;t[8]!==a||t[9]!==_.uri?(s=_.uri?{kind:`media-uri`,uri:_.uri,conversationId:a}:{kind:`inline`},t[8]=a,t[9]=_.uri,t[10]=s):s=t[10];let c;t[11]!==e||t[12]!==n||t[13]!==_.size||t[14]!==o||t[15]!==s||t[16]!==i?(c={id:o,context:`attachment`,fileName:e,mimeType:n,size:_.size,type:i,source:s},t[11]=e,t[12]=n,t[13]=_.size,t[14]=o,t[15]=s,t[16]=i,t[17]=c):c=t[17],y=c}let b=y,S;t[18]===_?S=t[19]:(S=_?v(_):void 0,t[18]=_,t[19]=S);let C=S,T=_?.uri,E;t[20]===b.type?E=t[21]:(E=ae(b.type),t[20]=b.type,t[21]=E);let D=E,O=!!(n&&T&&!C&&i&&(D===`binary`||D===`text`)),k;t[22]!==a||t[23]!==o||t[24]!==T||t[25]!==_?.taskId?(k=async()=>{let e=c(o).chat,t=await oe({uri:T,conversationId:a,taskId:_?.taskId});if(!t.ok)throw t.reason===`http`?Error(`${e.attachmentPreviewLoadError} (HTTP ${t.status})`):Error(t.message);return t.buffer},t[22]=a,t[23]=o,t[24]=T,t[25]=_?.taskId,t[26]=k):k=t[26];let ee=_?.taskId,A;t[27]!==i||t[28]!==a||t[29]!==C||t[30]!==o||t[31]!==T||t[32]!==n||t[33]!==D||t[34]!==ee?(A=[n,T,i,o,C,ee,a,D],t[27]=i,t[28]=a,t[29]=C,t[30]=o,t[31]=T,t[32]=n,t[33]=D,t[34]=ee,t[35]=A):A=t[35];let j;t[36]===O?j=t[37]:(j={enabled:O,initial:null,errorData:null},t[36]=O,t[37]=j);let M=w(k,A,j),N;bb1:{if(C)try{let e;t[38]===C?e=t[39]:(e=x(C),t[38]=C,t[39]=e),N=e;break bb1}catch{N=null;break bb1}if(O&&M.loading){N=null;break bb1}N=M.data??null}let P=N,F=D===`binary`?P:null,I=_?.extractedText??``,L;t[40]!==P||t[41]!==I||t[42]!==o||t[43]!==D?(L=D===`text`?I||(P?new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(P)):c(o).chat.attachmentPreviewNoText):null,t[40]=P,t[41]=I,t[42]=o,t[43]=D,t[44]=L):L=t[44];let R=L,z=!!_?.extractedText,te=b.type===`pptx`&&I.length>3e5,B;t[45]!==i||t[46]!==C||t[47]!==o||t[48]!==T||t[49]!==n||t[50]!==D?(B=n&&T&&!C&&!i&&D===`binary`?c(o).chat.attachmentPreviewMissingAuth:null,t[45]=i,t[46]=C,t[47]=o,t[48]=T,t[49]=n,t[50]=D,t[51]=B):B=t[51];let V=B,ne=M.error?M.error instanceof Error?M.error.message:String(M.error):null,H=f?null:V??ne,U=O?M.loading:!1,W;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>p(!0),t[52]=W):W=t[52];let G=I||null,Y;return t[53]!==F||t[54]!==b||t[55]!==P||t[56]!==te||t[57]!==z||t[58]!==H||t[59]!==_||t[60]!==u||t[61]!==U||t[62]!==G||t[63]!==R?(Y={preview:_,descriptor:b,fileType:b.type,fileName:b.fileName,loading:U,loadError:H,clearLoadError:W,textContent:R,binaryBuffer:F,downloadBuffer:P,hasExtractedText:z,extractedText:G,extractedTextTruncated:te,showExtractedText:u,setShowExtractedText:d},t[53]=F,t[54]=b,t[55]=P,t[56]=te,t[57]=z,t[58]=H,t[59]=_,t[60]=u,t[61]=U,t[62]=G,t[63]=R,t[64]=Y):Y=t[64],Y}function ce(e){let t=(0,K.c)(12),{projectId:n,conversationId:r,agentId:i}=e,a;bb0:{let e;t[0]===n?e=t[1]:(e=n?.trim(),t[0]=n,t[1]=e);let o=e;if(o){let e;t[2]===o?e=t[3]:(e={projectId:o},t[2]=o,t[3]=e),a=e;break bb0}let s;t[4]===r?s=t[5]:(s=r?.trim(),t[4]=r,t[5]=s);let c=s;if(c){let e;t[6]===c?e=t[7]:(e={conversationId:c},t[6]=c,t[7]=e),a=e;break bb0}let l;t[8]===i?l=t[9]:(l=i?.trim(),t[8]=i,t[9]=l);let u=l,d;t[10]===u?d=t[11]:(d=u?{agentId:u}:void 0,t[10]=u,t[11]=d),a=d}return a}function le(e){return{descriptor:e,textContent:null,binaryBuffer:null,fileResourceId:null,mtimeMs:null,loadError:null,loading:!1,pptxText:null,pptxTruncated:!1,pptxError:null}}function ue(e,t){switch(t.type){case`clear`:return le(t.descriptor);case`loadStart`:return{...le(t.descriptor),loading:!0};case`loadSuccess`:return{...e,descriptor:t.payload.descriptor,textContent:t.payload.textContent??null,binaryBuffer:t.payload.binaryBuffer??null,fileResourceId:t.payload.fileResourceId??null,mtimeMs:t.payload.mtimeMs??null,loadError:null,loading:!1};case`loadError`:return{...le(t.descriptor),loadError:t.error};case`patchMtime`:return{...e,mtimeMs:t.mtimeMs};case`patchText`:return{...e,textContent:t.text};case`pptxClear`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:null};case`pptxSuccess`:return{...e,pptxText:t.text,pptxTruncated:t.truncated,pptxError:null};case`pptxError`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:t.error}}}function de(e,t){switch(t.type){case`reset`:return{sourceEditMode:!1,saveStatus:`idle`};case`source`:return{...e,sourceEditMode:typeof t.value==`function`?t.value(e.sourceEditMode):t.value};case`saveStatus`:return{...e,saveStatus:t.value}}}function fe({filePath:e,projectId:t,conversationId:n,agentId:r,resolvedFile:a,initialEditMode:o=!1}){let s=ce({projectId:t,conversationId:n,agentId:r}),c=(0,q.useMemo)(()=>{let t=e?W(e):``,i=re(t,b(t)),a=e?ie(t,i):`unsupported`;return{id:e||`__empty__`,context:`workspace`,fileName:t,mimeType:i,type:a,source:{kind:`workspace`,path:e||``,conversationId:n,agentId:r}}},[r,e,n]),[l,u]=(0,q.useReducer)(ue,c,le),[d,f]=(0,q.useReducer)(de,{sourceEditMode:o,saveStatus:`idle`}),[p,m]=(0,q.useState)([]),[h,g]=(0,q.useState)([]),_=(0,q.useRef)(e),v=(0,q.useRef)(void 0),y=(0,q.useRef)(null),x=(0,q.useRef)(null),w=(0,q.useRef)(null),[M,N]=(0,q.useState)(!1),[P,F]=(0,q.useState)(!1),[I,L]=(0,q.useState)(0);_.current!==e&&(_.current=e,f({type:`reset`})),(0,q.useEffect)(()=>{if(!e){u({type:`clear`,descriptor:c});return}let t=!1;u({type:`loadStart`,descriptor:c});let n=ae(c.type),r=e=>{t||u({type:`loadError`,descriptor:c,error:e instanceof Error?e.message:String(e)})};return n===`metadata`?(Promise.all([D(e,s).catch(()=>null),A(e,s).catch(()=>null)]).then(async([n,r])=>{if(!n){t||u({type:`loadSuccess`,payload:{descriptor:c,fileResourceId:r?.fileId??null,mtimeMs:typeof r?.mtimeMs==`number`?r.mtimeMs:null}});return}let i={...c,mimeType:n.mimeType,type:ie(n.name,n.mimeType)};if(ae(i.type)===`text`){let{content:r,mtimeMs:a,revision:o}=await E(e,s);t||(v.current=o,y.current=r,x.current=r,N(!1),F(!1)),t||u({type:`loadSuccess`,payload:{descriptor:i,textContent:r,fileResourceId:n.id,mtimeMs:typeof a==`number`?a:n.modifiedAt}});return}t||u({type:`loadSuccess`,payload:{descriptor:i,fileResourceId:n.id,mtimeMs:n.modifiedAt}})}).catch(r),()=>{t=!0}):(n===`text`?E(e,s,I===0?a:void 0).then(({content:e,mtimeMs:n,revision:r,fileId:i})=>{t||(v.current=r,y.current=e,x.current=e,N(!1),F(!1)),t||u({type:`loadSuccess`,payload:{descriptor:c,textContent:e,fileResourceId:i??null,mtimeMs:typeof n==`number`?n:null}})}).catch(r):Promise.all([T(e,s),A(e,s).catch(()=>null)]).then(async([e,n])=>{let r=await e.arrayBuffer();t||u({type:`loadSuccess`,payload:{descriptor:c,binaryBuffer:r,fileResourceId:n?.fileId??null,mtimeMs:typeof n?.mtimeMs==`number`?n.mtimeMs:null}})}).catch(r),()=>{t=!0})},[c,e,s,I,a]),(0,q.useEffect)(()=>{if(!l.binaryBuffer||l.descriptor.type!==`pptx`){u({type:`pptxClear`});return}let e=!1;return u({type:`pptxClear`}),i(()=>import(`./attachment-process-heavy-DGZZ-M85.js`).then(e=>e.processPptx(l.binaryBuffer,l.descriptor.fileName)),__vite__mapDeps([0,1,2,3])).then(({extractedText:t})=>{if(e)return;let n=t.length>S;u({type:`pptxSuccess`,text:n?t.slice(0,S):t,truncated:n})}).catch(t=>{e||u({type:`pptxError`,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},[l.binaryBuffer,l.descriptor.fileName,l.descriptor.type]);let R=(0,q.useCallback)(async()=>{if(w.current&&!await w.current)return!1;if(!e||y.current===null||y.current===x.current)return!0;let t=(async()=>{f({type:`saveStatus`,value:`saving`});try{for(;y.current!==x.current;){let t=y.current,n=await O(e,t,s,v.current);v.current=n.revision,x.current=t,typeof n.mtimeMs==`number`&&u({type:`patchMtime`,mtimeMs:n.mtimeMs})}return N(!1),f({type:`saveStatus`,value:`saved`}),!0}catch{return f({type:`saveStatus`,value:`error`}),!1}})();w.current=t;try{return await t}finally{w.current===t&&(w.current=null)}},[e,s]),z=j(()=>void R(),500),te=(0,q.useCallback)(e=>{y.current=e,N(e!==x.current),u({type:`patchText`,text:e}),z()},[z]);(0,q.useEffect)(()=>{let e=e=>{y.current!==x.current&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),z.cancel()}},[z]);let B=(0,q.useCallback)(()=>{!M&&!w.current&&L(e=>e+1)},[M]),V=(0,q.useRef)(!1),ne=(0,q.useCallback)(async()=>{if(!(!e||l.loading||w.current||V.current)){V.current=!0;try{let t=await D(e,s);if(!t||!(v.current?t.revision!==v.current:l.mtimeMs!=null&&t.modifiedAt!==l.mtimeMs))return;M||d.sourceEditMode?F(!0):B()}catch{F(!0)}finally{V.current=!1}}},[M,d.sourceEditMode,e,l.loading,l.mtimeMs,s,B]),H=(0,q.useCallback)(async()=>{if(!e)return;let t=W(e);if(l.binaryBuffer){k(t,l.binaryBuffer,l.descriptor.mimeType||`application/octet-stream`);return}if(l.textContent!=null){ee(t,l.textContent);return}let n=await T(e,s);k(t,await n.arrayBuffer(),l.descriptor.mimeType||n.type||`application/octet-stream`)},[e,l.binaryBuffer,l.descriptor.mimeType,l.textContent,s]),U=(0,q.useCallback)(async()=>{if(!e)throw Error(`No workspace file selected`);let t=W(e),n=l.descriptor.mimeType||`application/octet-stream`,r;return r=l.binaryBuffer?new Blob([l.binaryBuffer],{type:n}):l.textContent==null?await T(e,s):new Blob([l.textContent],{type:n}),new File([r],t,{type:l.descriptor.mimeType||r.type||`application/octet-stream`,lastModified:l.mtimeMs??Date.now()})},[e,l.binaryBuffer,l.descriptor.mimeType,l.mtimeMs,l.textContent,s]),G=!l.loading&&!!e,oe=C()&&(!!l.fileResourceId&&!!window.electronAPI?.shell?.openFileResource||l.descriptor.type===`spreadsheet`&&!!l.binaryBuffer&&!!window.electronAPI?.shell?.openTemporaryFile),K=C()&&!!l.fileResourceId&&!!window.electronAPI?.shell?.chooseAppAndOpenFileResource,J=(0,q.useCallback)(async()=>{let e=l.fileResourceId;if(!C()||!e||!window.electronAPI?.shell?.getOpenWithAppsForFileResource){g([]),m([]);return}try{let t=await window.electronAPI.shell.getOpenWithAppsForFileResource(e);g(t.recommended.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl}))),m(t.recent.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl,lastUsedAt:e.lastUsedAt})))}catch{g([]),m([])}},[l.fileResourceId]);(0,q.useEffect)(()=>{J()},[J]);let se=(0,q.useCallback)(async()=>{let e=l.fileResourceId;if(e&&window.electronAPI?.shell?.openFileResource)return window.electronAPI.shell.openFileResource(e);if(l.descriptor.type===`spreadsheet`&&l.binaryBuffer&&window.electronAPI?.shell?.openTemporaryFile)return window.electronAPI.shell.openTemporaryFile({fileName:l.descriptor.fileName,data:new Uint8Array(l.binaryBuffer)})},[l.binaryBuffer,l.descriptor.fileName,l.descriptor.type,l.fileResourceId]),Y=(0,q.useCallback)(async()=>{let e=l.fileResourceId;if(!e||!window.electronAPI?.shell?.chooseAppAndOpenFileResource)return;let t=await window.electronAPI.shell.chooseAppAndOpenFileResource(e);return t.ok&&J(),t},[l.fileResourceId,J]),fe=(0,q.useCallback)(async e=>{let t=l.fileResourceId;if(!t||!e||!window.electronAPI?.shell?.openFileResourceWithApp)return;let n=await window.electronAPI.shell.openFileResourceWithApp(t,e);return n.ok&&J(),n},[l.fileResourceId,J]),X=C()&&!!l.fileResourceId&&!!window.electronAPI?.shell?.showFileResourceInFolder,pe=(0,q.useCallback)(async()=>{let e=l.fileResourceId;if(e&&window.electronAPI?.shell?.showFileResourceInFolder)return window.electronAPI.shell.showFileResourceInFolder(e)},[l.fileResourceId]);return{...l,dirty:M,externalChange:P,flushSource:R,refresh:B,checkForUpdates:ne,extractedText:l.descriptor.type===`pptx`?l.pptxText:null,extractedTextTruncated:l.pptxTruncated,sourceEditMode:d.sourceEditMode,setSourceEditMode:e=>f({type:`source`,value:e}),saveStatus:d.saveStatus,onSourceChange:te,onDownload:H,createAttachmentFile:U,canDownload:G,canOpenWithSystemApp:oe,onOpenWithSystemApp:se,canChooseOpenWithApp:K,onChooseOpenWithApp:Y,recommendedOpenWithApps:h,recentOpenWithApps:p,onOpenWithRecentApp:fe,canRevealInFolder:X,onRevealInFolder:pe}}var X=new Map;function pe(e){return X.get(e)??{zoom:1,rotation:0,page:1,pageCount:null,searchQuery:``,scroll:[]}}function me(e,t){let n={...pe(e),...t};for(X.delete(e),X.set(e,n);X.size>100;)X.delete(X.keys().next().value)}s.subscribe((e,t)=>{(e.baseUrl!==t.baseUrl||e.conversationId!==t.conversationId)&&X.clear()});var he=120*1e3,Z=new Map;function ge(){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function _e(e){for(let[t,n]of Z)n.expiresAt<=e&&Z.delete(t)}function ve(e,t=Date.now()){_e(t);let n=ge();return Z.set(n,{file:e,name:e.name,type:e.type,expiresAt:t+he}),n}function ye(e,t=Date.now()){let n=Z.get(e);return n?n.expiresAt<=t?(Z.delete(e),null):{name:n.name,type:n.type}:null}function be(e,t=Date.now()){let n=Z.get(e);if(!n)return null;if(n.expiresAt<=t)return Z.delete(e),null;if(!n.file)return null;let r=n.file;return n.file=null,r}var xe=`<script>
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{a,i as o,l as s}from"./locale-store-CHjsq5NR.js";import{t as c}from"./messages-C7QSnTdg.js";import{t as l}from"./createLucideIcon-DPHK1VkS.js";import{G as u,t as d}from"./markdown-view-ihzUc4ud.js";import{t as f}from"./plus-Q2yW6OE7.js";import{t as p}from"./rotate-cw-LIg3Am9S.js";import{t as m}from"./search-DA7gz22f.js";import{t as h}from"./cn-0WouolD0.js";import{t as g}from"./skeleton-DzdOeGYz.js";import{r as _}from"./turn-outcome-Dtw6OgwL.js";import{a as v,c as y,o as b,r as x,t as S}from"./attachment-utils-core-BPYdUI6y.js";import{n as C}from"./electron-env-DHOGevH3.js";import{t as w}from"./use-async-resource-BHFGZCY2.js";import{a as T,c as E,d as D,m as O,n as k,r as ee,u as A}from"./workspace-api-CQOuWbVv.js";import{t as j}from"./index.module-Cd9ENXfk.js";var M=l(`step-forward`,[[`path`,{d:`M10.029 4.285A2 2 0 0 0 7 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`1ystz2`}],[`path`,{d:`M3 4v16`,key:`1ph11n`}]]),N=l(`step-back`,[[`path`,{d:`M13.971 4.285A2 2 0 0 1 17 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z`,key:`19qhus`}],[`path`,{d:`M21 20V4`,key:`cb8qj8`}]]),P=5*1024*1024,F=32*1024*1024,I=new Set(`.astro,.bat,.c,.cc,.clj,.cljs,.cljc,.cmd,.cpp,.cs,.cts,.cxx,.dart,.edn,.erl,.ex,.exs,.fish,.fs,.fsx,.go,.gql,.graphql,.groovy,.h,.hh,.hpp,.hrl,.hxx,.java,.ts,.tsx,.mts,.js,.jsx,.mjs,.cjs,.css,.scss,.sass,.less,.json,.jsonc,.json5,.yml,.yaml,.xml,.xsd,.xsl,.py,.pyw,.rb,.php,.rs,.kt,.kts,.scala,.swift,.m,.mm,.sh,.bash,.zsh,.ps1,.sql,.lua,.r,.pl,.pm,.sol,.tf,.tfvars,.nix,.proto,.vue,.svelte,.toml,.ini,.cfg,.conf,.properties`.split(`,`)),L=new Set([`.txt`,`.log`,`.lock`,`.csv`,`.tsv`,`.env`,`.gitignore`,`.gitattributes`,`.editorconfig`,`.npmrc`,`.dockerignore`,`.eslintignore`,`.prettierignore`,`.stylelintignore`]),R=new Set([`dockerfile`,`gemfile`,`jenkinsfile`,`makefile`,`procfile`,`rakefile`]),z=new Set([`brewfile`,`changelog`,`codeowners`,`license`,`readme`]),te=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.bmp`,`.ico`,`.svg`,`.svgz`,`.tif`,`.tiff`,`.avif`,`.heic`,`.heif`,`.jxl`]),B=new Set([`.mp3`,`.wav`,`.ogg`,`.oga`,`.aac`,`.m4a`,`.flac`,`.opus`,`.weba`]),V=new Set([`.mp4`,`.webm`,`.mov`,`.m4v`,`.ogv`]),ne=new Set([`.zip`]),H=new Map([[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.md`,`text/markdown`],[`.markdown`,`text/markdown`],[`.html`,`text/html`],[`.htm`,`text/html`],[`.json`,`application/json`],[`.txt`,`text/plain`],[`.csv`,`text/csv`],[`.tsv`,`text/tab-separated-values`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.mp3`,`audio/mpeg`],[`.wav`,`audio/wav`],[`.ogg`,`audio/ogg`],[`.mp4`,`video/mp4`],[`.webm`,`video/webm`],[`.mov`,`video/quicktime`],[`.zip`,`application/zip`]]);function U(e){let t=W(e),n=t.lastIndexOf(`.`);return n<0||n===t.length-1?``:t.slice(n).toLowerCase()}function W(e){let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]||e}function re(e,t){let n=t?.split(`;`)[0]?.trim().toLowerCase();return n&&n!==`application/octet-stream`?n:H.get(U(e))??n??`application/octet-stream`}function ie(e,t){let n=U(e),r=W(e).toLowerCase(),i=re(e,t);return i===`text/markdown`||n===`.md`||n===`.markdown`?`markdown`:i===`text/html`||n===`.html`||n===`.htm`?`html`:i===`application/pdf`||n===`.pdf`?`pdf`:i===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||n===`.docx`?`docx`:i===`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`||i===`application/vnd.ms-excel`||n===`.xlsx`||n===`.xls`?`spreadsheet`:i===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||n===`.pptx`?`pptx`:i.startsWith(`image/`)||te.has(n)?`image`:i.startsWith(`audio/`)||B.has(n)?`audio`:i.startsWith(`video/`)||V.has(n)?`video`:i===`application/zip`||ne.has(n)?`archive`:I.has(n)||R.has(r)||r.startsWith(`dockerfile.`)?`code`:i.startsWith(`text/`)||L.has(n)||z.has(r)||r.startsWith(`.env.`)||i===`application/json`?`text`:`unsupported`}function ae(e){switch(e){case`text`:case`markdown`:case`code`:case`html`:return`text`;case`unsupported`:return`metadata`;default:return`binary`}}async function G(e){let{uri:t,conversationId:n,taskId:r}=e;try{let e=_(t),i=await a(o(e?`/api/files/${encodeURIComponent(e)}/content`:y(t,n,r)));return i.ok?{ok:!0,blob:await i.blob()}:{ok:!1,reason:`http`,status:i.status}}catch(e){return{ok:!1,reason:`network`,message:e instanceof Error?e.message:String(e)}}}async function oe(e){let t=await G(e);return t.ok?{ok:!0,buffer:await t.blob.arrayBuffer()}:t}var K=n(),q=e(t(),1);function J(e){return e.id?String(e.id):`${e.name}:${e.uri??``}`}function se(){return{id:`__empty__`,context:`attachment`,fileName:``,mimeType:`application/octet-stream`,type:`unsupported`,source:{kind:`inline`}}}function Y(e){let t=(0,K.c)(65),{open:n,attachment:r,authToken:i,conversationId:a,language:o}=e,[s,l]=(0,q.useState)(n?r:null),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),m;t[0]!==r||t[1]!==n?(m=n&&r?J(r):null,t[0]=r,t[1]=n,t[2]=m):m=t[2];let h=m,g=(0,q.useRef)(h);h!==g.current&&(g.current=h,l(n&&r?r:null),d(!1),p(!1));let _=s,y;bb0:{if(!_){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=se(),t[3]=e):e=t[3],y=e;break bb0}let e=_.name??`attachment`,n,r;t[4]!==e||t[5]!==_.mimeType?(n=re(e,_.mimeType),r=ie(e,n),t[4]=e,t[5]=_.mimeType,t[6]=n,t[7]=r):(n=t[6],r=t[7]);let i=r,o=_.id?String(_.id):`${e}:${_.uri??``}`,s;t[8]!==a||t[9]!==_.uri?(s=_.uri?{kind:`media-uri`,uri:_.uri,conversationId:a}:{kind:`inline`},t[8]=a,t[9]=_.uri,t[10]=s):s=t[10];let c;t[11]!==e||t[12]!==n||t[13]!==_.size||t[14]!==o||t[15]!==s||t[16]!==i?(c={id:o,context:`attachment`,fileName:e,mimeType:n,size:_.size,type:i,source:s},t[11]=e,t[12]=n,t[13]=_.size,t[14]=o,t[15]=s,t[16]=i,t[17]=c):c=t[17],y=c}let b=y,S;t[18]===_?S=t[19]:(S=_?v(_):void 0,t[18]=_,t[19]=S);let C=S,T=_?.uri,E;t[20]===b.type?E=t[21]:(E=ae(b.type),t[20]=b.type,t[21]=E);let D=E,O=!!(n&&T&&!C&&i&&(D===`binary`||D===`text`)),k;t[22]!==a||t[23]!==o||t[24]!==T||t[25]!==_?.taskId?(k=async()=>{let e=c(o).chat,t=await oe({uri:T,conversationId:a,taskId:_?.taskId});if(!t.ok)throw t.reason===`http`?Error(`${e.attachmentPreviewLoadError} (HTTP ${t.status})`):Error(t.message);return t.buffer},t[22]=a,t[23]=o,t[24]=T,t[25]=_?.taskId,t[26]=k):k=t[26];let ee=_?.taskId,A;t[27]!==i||t[28]!==a||t[29]!==C||t[30]!==o||t[31]!==T||t[32]!==n||t[33]!==D||t[34]!==ee?(A=[n,T,i,o,C,ee,a,D],t[27]=i,t[28]=a,t[29]=C,t[30]=o,t[31]=T,t[32]=n,t[33]=D,t[34]=ee,t[35]=A):A=t[35];let j;t[36]===O?j=t[37]:(j={enabled:O,initial:null,errorData:null},t[36]=O,t[37]=j);let M=w(k,A,j),N;bb1:{if(C)try{let e;t[38]===C?e=t[39]:(e=x(C),t[38]=C,t[39]=e),N=e;break bb1}catch{N=null;break bb1}if(O&&M.loading){N=null;break bb1}N=M.data??null}let P=N,F=D===`binary`?P:null,I=_?.extractedText??``,L;t[40]!==P||t[41]!==I||t[42]!==o||t[43]!==D?(L=D===`text`?I||(P?new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(P)):c(o).chat.attachmentPreviewNoText):null,t[40]=P,t[41]=I,t[42]=o,t[43]=D,t[44]=L):L=t[44];let R=L,z=!!_?.extractedText,te=b.type===`pptx`&&I.length>3e5,B;t[45]!==i||t[46]!==C||t[47]!==o||t[48]!==T||t[49]!==n||t[50]!==D?(B=n&&T&&!C&&!i&&D===`binary`?c(o).chat.attachmentPreviewMissingAuth:null,t[45]=i,t[46]=C,t[47]=o,t[48]=T,t[49]=n,t[50]=D,t[51]=B):B=t[51];let V=B,ne=M.error?M.error instanceof Error?M.error.message:String(M.error):null,H=f?null:V??ne,U=O?M.loading:!1,W;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>p(!0),t[52]=W):W=t[52];let G=I||null,Y;return t[53]!==F||t[54]!==b||t[55]!==P||t[56]!==te||t[57]!==z||t[58]!==H||t[59]!==_||t[60]!==u||t[61]!==U||t[62]!==G||t[63]!==R?(Y={preview:_,descriptor:b,fileType:b.type,fileName:b.fileName,loading:U,loadError:H,clearLoadError:W,textContent:R,binaryBuffer:F,downloadBuffer:P,hasExtractedText:z,extractedText:G,extractedTextTruncated:te,showExtractedText:u,setShowExtractedText:d},t[53]=F,t[54]=b,t[55]=P,t[56]=te,t[57]=z,t[58]=H,t[59]=_,t[60]=u,t[61]=U,t[62]=G,t[63]=R,t[64]=Y):Y=t[64],Y}function ce(e){let t=(0,K.c)(12),{projectId:n,conversationId:r,agentId:i}=e,a;bb0:{let e;t[0]===n?e=t[1]:(e=n?.trim(),t[0]=n,t[1]=e);let o=e;if(o){let e;t[2]===o?e=t[3]:(e={projectId:o},t[2]=o,t[3]=e),a=e;break bb0}let s;t[4]===r?s=t[5]:(s=r?.trim(),t[4]=r,t[5]=s);let c=s;if(c){let e;t[6]===c?e=t[7]:(e={conversationId:c},t[6]=c,t[7]=e),a=e;break bb0}let l;t[8]===i?l=t[9]:(l=i?.trim(),t[8]=i,t[9]=l);let u=l,d;t[10]===u?d=t[11]:(d=u?{agentId:u}:void 0,t[10]=u,t[11]=d),a=d}return a}function le(e){return{descriptor:e,textContent:null,binaryBuffer:null,fileResourceId:null,mtimeMs:null,loadError:null,loading:!1,pptxText:null,pptxTruncated:!1,pptxError:null}}function ue(e,t){switch(t.type){case`clear`:return le(t.descriptor);case`loadStart`:return{...le(t.descriptor),loading:!0};case`loadSuccess`:return{...e,descriptor:t.payload.descriptor,textContent:t.payload.textContent??null,binaryBuffer:t.payload.binaryBuffer??null,fileResourceId:t.payload.fileResourceId??null,mtimeMs:t.payload.mtimeMs??null,loadError:null,loading:!1};case`loadError`:return{...le(t.descriptor),loadError:t.error};case`patchMtime`:return{...e,mtimeMs:t.mtimeMs};case`patchText`:return{...e,textContent:t.text};case`pptxClear`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:null};case`pptxSuccess`:return{...e,pptxText:t.text,pptxTruncated:t.truncated,pptxError:null};case`pptxError`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:t.error}}}function de(e,t){switch(t.type){case`reset`:return{sourceEditMode:!1,saveStatus:`idle`};case`source`:return{...e,sourceEditMode:typeof t.value==`function`?t.value(e.sourceEditMode):t.value};case`saveStatus`:return{...e,saveStatus:t.value}}}function fe({filePath:e,projectId:t,conversationId:n,agentId:r,resolvedFile:a,initialEditMode:o=!1}){let s=ce({projectId:t,conversationId:n,agentId:r}),c=(0,q.useMemo)(()=>{let t=e?W(e):``,i=re(t,b(t)),a=e?ie(t,i):`unsupported`;return{id:e||`__empty__`,context:`workspace`,fileName:t,mimeType:i,type:a,source:{kind:`workspace`,path:e||``,conversationId:n,agentId:r}}},[r,e,n]),[l,u]=(0,q.useReducer)(ue,c,le),[d,f]=(0,q.useReducer)(de,{sourceEditMode:o,saveStatus:`idle`}),[p,m]=(0,q.useState)([]),[h,g]=(0,q.useState)([]),_=(0,q.useRef)(e),v=(0,q.useRef)(void 0),y=(0,q.useRef)(null),x=(0,q.useRef)(null),w=(0,q.useRef)(null),[M,N]=(0,q.useState)(!1),[P,F]=(0,q.useState)(!1),[I,L]=(0,q.useState)(0);_.current!==e&&(_.current=e,f({type:`reset`})),(0,q.useEffect)(()=>{if(!e){u({type:`clear`,descriptor:c});return}let t=!1;u({type:`loadStart`,descriptor:c});let n=ae(c.type),r=e=>{t||u({type:`loadError`,descriptor:c,error:e instanceof Error?e.message:String(e)})};return n===`metadata`?(Promise.all([D(e,s).catch(()=>null),A(e,s).catch(()=>null)]).then(async([n,r])=>{if(!n){t||u({type:`loadSuccess`,payload:{descriptor:c,fileResourceId:r?.fileId??null,mtimeMs:typeof r?.mtimeMs==`number`?r.mtimeMs:null}});return}let i={...c,mimeType:n.mimeType,type:ie(n.name,n.mimeType)};if(ae(i.type)===`text`){let{content:r,mtimeMs:a,revision:o}=await E(e,s);t||(v.current=o,y.current=r,x.current=r,N(!1),F(!1)),t||u({type:`loadSuccess`,payload:{descriptor:i,textContent:r,fileResourceId:n.id,mtimeMs:typeof a==`number`?a:n.modifiedAt}});return}t||u({type:`loadSuccess`,payload:{descriptor:i,fileResourceId:n.id,mtimeMs:n.modifiedAt}})}).catch(r),()=>{t=!0}):(n===`text`?E(e,s,I===0?a:void 0).then(({content:e,mtimeMs:n,revision:r,fileId:i})=>{t||(v.current=r,y.current=e,x.current=e,N(!1),F(!1)),t||u({type:`loadSuccess`,payload:{descriptor:c,textContent:e,fileResourceId:i??null,mtimeMs:typeof n==`number`?n:null}})}).catch(r):Promise.all([T(e,s),A(e,s).catch(()=>null)]).then(async([e,n])=>{let r=await e.arrayBuffer();t||u({type:`loadSuccess`,payload:{descriptor:c,binaryBuffer:r,fileResourceId:n?.fileId??null,mtimeMs:typeof n?.mtimeMs==`number`?n.mtimeMs:null}})}).catch(r),()=>{t=!0})},[c,e,s,I,a]),(0,q.useEffect)(()=>{if(!l.binaryBuffer||l.descriptor.type!==`pptx`){u({type:`pptxClear`});return}let e=!1;return u({type:`pptxClear`}),i(()=>import(`./attachment-process-heavy-DGZZ-M85.js`).then(e=>e.processPptx(l.binaryBuffer,l.descriptor.fileName)),__vite__mapDeps([0,1,2,3])).then(({extractedText:t})=>{if(e)return;let n=t.length>S;u({type:`pptxSuccess`,text:n?t.slice(0,S):t,truncated:n})}).catch(t=>{e||u({type:`pptxError`,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},[l.binaryBuffer,l.descriptor.fileName,l.descriptor.type]);let R=(0,q.useCallback)(async()=>{if(w.current&&!await w.current)return!1;if(!e||y.current===null||y.current===x.current)return!0;let t=(async()=>{f({type:`saveStatus`,value:`saving`});try{for(;y.current!==x.current;){let t=y.current,n=await O(e,t,s,v.current);v.current=n.revision,x.current=t,typeof n.mtimeMs==`number`&&u({type:`patchMtime`,mtimeMs:n.mtimeMs})}return N(!1),f({type:`saveStatus`,value:`saved`}),!0}catch{return f({type:`saveStatus`,value:`error`}),!1}})();w.current=t;try{return await t}finally{w.current===t&&(w.current=null)}},[e,s]),z=j(()=>void R(),500),te=(0,q.useCallback)(e=>{y.current=e,N(e!==x.current),u({type:`patchText`,text:e}),z()},[z]);(0,q.useEffect)(()=>{let e=e=>{y.current!==x.current&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),z.cancel()}},[z]);let B=(0,q.useCallback)(()=>{!M&&!w.current&&L(e=>e+1)},[M]),V=(0,q.useRef)(!1),ne=(0,q.useCallback)(async()=>{if(!(!e||l.loading||w.current||V.current)){V.current=!0;try{let t=await D(e,s);if(!t||!(v.current?t.revision!==v.current:l.mtimeMs!=null&&t.modifiedAt!==l.mtimeMs))return;M||d.sourceEditMode?F(!0):B()}catch{F(!0)}finally{V.current=!1}}},[M,d.sourceEditMode,e,l.loading,l.mtimeMs,s,B]),H=(0,q.useCallback)(async()=>{if(!e)return;let t=W(e);if(l.binaryBuffer){k(t,l.binaryBuffer,l.descriptor.mimeType||`application/octet-stream`);return}if(l.textContent!=null){ee(t,l.textContent);return}let n=await T(e,s);k(t,await n.arrayBuffer(),l.descriptor.mimeType||n.type||`application/octet-stream`)},[e,l.binaryBuffer,l.descriptor.mimeType,l.textContent,s]),U=(0,q.useCallback)(async()=>{if(!e)throw Error(`No workspace file selected`);let t=W(e),n=l.descriptor.mimeType||`application/octet-stream`,r;return r=l.binaryBuffer?new Blob([l.binaryBuffer],{type:n}):l.textContent==null?await T(e,s):new Blob([l.textContent],{type:n}),new File([r],t,{type:l.descriptor.mimeType||r.type||`application/octet-stream`,lastModified:l.mtimeMs??Date.now()})},[e,l.binaryBuffer,l.descriptor.mimeType,l.mtimeMs,l.textContent,s]),G=!l.loading&&!!e,oe=C()&&(!!l.fileResourceId&&!!window.electronAPI?.shell?.openFileResource||l.descriptor.type===`spreadsheet`&&!!l.binaryBuffer&&!!window.electronAPI?.shell?.openTemporaryFile),K=C()&&!!l.fileResourceId&&!!window.electronAPI?.shell?.chooseAppAndOpenFileResource,J=(0,q.useCallback)(async()=>{let e=l.fileResourceId;if(!C()||!e||!window.electronAPI?.shell?.getOpenWithAppsForFileResource){g([]),m([]);return}try{let t=await window.electronAPI.shell.getOpenWithAppsForFileResource(e);g(t.recommended.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl}))),m(t.recent.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl,lastUsedAt:e.lastUsedAt})))}catch{g([]),m([])}},[l.fileResourceId]);(0,q.useEffect)(()=>{J()},[J]);let se=(0,q.useCallback)(async()=>{let e=l.fileResourceId;if(e&&window.electronAPI?.shell?.openFileResource)return window.electronAPI.shell.openFileResource(e);if(l.descriptor.type===`spreadsheet`&&l.binaryBuffer&&window.electronAPI?.shell?.openTemporaryFile)return window.electronAPI.shell.openTemporaryFile({fileName:l.descriptor.fileName,data:new Uint8Array(l.binaryBuffer)})},[l.binaryBuffer,l.descriptor.fileName,l.descriptor.type,l.fileResourceId]),Y=(0,q.useCallback)(async()=>{let e=l.fileResourceId;if(!e||!window.electronAPI?.shell?.chooseAppAndOpenFileResource)return;let t=await window.electronAPI.shell.chooseAppAndOpenFileResource(e);return t.ok&&J(),t},[l.fileResourceId,J]),fe=(0,q.useCallback)(async e=>{let t=l.fileResourceId;if(!t||!e||!window.electronAPI?.shell?.openFileResourceWithApp)return;let n=await window.electronAPI.shell.openFileResourceWithApp(t,e);return n.ok&&J(),n},[l.fileResourceId,J]),X=C()&&!!l.fileResourceId&&!!window.electronAPI?.shell?.showFileResourceInFolder,pe=(0,q.useCallback)(async()=>{let e=l.fileResourceId;if(e&&window.electronAPI?.shell?.showFileResourceInFolder)return window.electronAPI.shell.showFileResourceInFolder(e)},[l.fileResourceId]);return{...l,dirty:M,externalChange:P,flushSource:R,refresh:B,checkForUpdates:ne,extractedText:l.descriptor.type===`pptx`?l.pptxText:null,extractedTextTruncated:l.pptxTruncated,sourceEditMode:d.sourceEditMode,setSourceEditMode:e=>f({type:`source`,value:e}),saveStatus:d.saveStatus,onSourceChange:te,onDownload:H,createAttachmentFile:U,canDownload:G,canOpenWithSystemApp:oe,onOpenWithSystemApp:se,canChooseOpenWithApp:K,onChooseOpenWithApp:Y,recommendedOpenWithApps:h,recentOpenWithApps:p,onOpenWithRecentApp:fe,canRevealInFolder:X,onRevealInFolder:pe}}var X=new Map;function pe(e){return X.get(e)??{zoom:1,rotation:0,page:1,pageCount:null,searchQuery:``,scroll:[]}}function me(e,t){let n={...pe(e),...t};for(X.delete(e),X.set(e,n);X.size>100;)X.delete(X.keys().next().value)}s.subscribe((e,t)=>{(e.baseUrl!==t.baseUrl||e.conversationId!==t.conversationId)&&X.clear()});var he=120*1e3,Z=new Map;function ge(){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function _e(e){for(let[t,n]of Z)n.expiresAt<=e&&Z.delete(t)}function ve(e,t=Date.now()){_e(t);let n=ge();return Z.set(n,{file:e,name:e.name,type:e.type,expiresAt:t+he}),n}function ye(e,t=Date.now()){let n=Z.get(e);return n?n.expiresAt<=t?(Z.delete(e),null):{name:n.name,type:n.type}:null}function be(e,t=Date.now()){let n=Z.get(e);if(!n)return null;if(n.expiresAt<=t)return Z.delete(e),null;if(!n.file)return null;let r=n.file;return n.file=null,r}var xe=`<script>
3
3
  window.addEventListener('click', (event) => {
4
4
  if (event.defaultPrevented || event.button !== 0 ||
5
5
  event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{n as a}from"./locale-store-CHjsq5NR.js";import{t as o}from"./messages-C7QSnTdg.js";import{t as s}from"./createLucideIcon-DPHK1VkS.js";import{t as c}from"./activity-YogQEteU.js";import{t as l}from"./bot-DjLkhyZL.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./circle-pause-CN9jYH2s.js";import{t as f}from"./clock-3-DnrAnuyZ.js";import{t as p}from"./external-link-DjqjBmc3.js";import{t as m}from"./loader-circle-CifKLtgG.js";import{t as h}from"./message-square-fVE7Ghj1.js";import{t as g}from"./pause-DuPxgSxk.js";import{t as _}from"./play-kxZvpBg8.js";import{t as v}from"./rotate-ccw-JM1TBLpp.js";import{t as y}from"./rotate-cw-LIg3Am9S.js";import{t as b}from"./sparkles-DHlfQFAF.js";import{t as x}from"./triangle-alert-2JXFNNKU.js";import{t as S}from"./volume-2-BSJhAY97.js";import{t as C}from"./zap-dximCGjy.js";import{t as w}from"./cn-0WouolD0.js";import{a as T}from"./session-manager-DUWeBdeG.js";import{i as E}from"./vendor-swr-CdRzEUwF.js";import{t as D}from"./button-C5tRaJxt.js";import{t as O}from"./automation-api-D-gn6x5E.js";var k=s(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),A=s(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),j=s(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),M=n(),N=e(t(),1),P=r(),F=(0,N.forwardRef)(function(e,t){let n=(0,M.c)(36),r,i,a,o,s,c,l;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7]):({input:a,labels:o,className:i,showLabel:s,disabled:c,hideNativeTitle:l,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c,n[7]=l);let u=s!==void 0&&s,d=c!==void 0&&c,f=l!==void 0&&l,p;n[8]===a?p=n[9]:(p=typeof a==`function`?a():a,n[8]=a,n[9]=p);let h=p,y=T(I),b=T(L),x=T(R),C=y?.type===h.source.type&&y.id===h.source.id,E=C?b:`idle`,D=E===`preparing`?o.preparing:E===`playing`?o.pause:E===`paused`?o.resume:E===`error`?o.retry:o.read,O;n[10]!==a||n[11]!==x?(O=()=>x(typeof a==`function`?a():a),n[10]=a,n[11]=x,n[12]=O):O=n[12];let k;n[13]!==d||n[14]!==h.text?(k=d||!h.text.trim(),n[13]=d,n[14]=h.text,n[15]=k):k=n[15];let A=f?void 0:D,j=C&&(E===`playing`||E===`paused`),N=u?`min-h-11 gap-1.5 px-2.5 text-sm font-medium sm:min-h-8 sm:text-xs`:`size-11 sm:size-9`,F=C&&`bg-surface-active text-accent`,z;n[16]!==i||n[17]!==F||n[18]!==N?(z=w(`inline-flex shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors transition-transform duration-150 ease-out`,`hover:bg-surface-hover hover:text-fg active:scale-95 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,N,F,i),n[16]=i,n[17]=F,n[18]=N,n[19]=z):z=n[19];let B;n[20]===E?B=n[21]:(B=E===`preparing`?(0,P.jsx)(m,{className:`size-4 animate-spin`,"aria-hidden":!0}):E===`playing`?(0,P.jsx)(g,{className:`size-4`,"aria-hidden":!0}):E===`paused`?(0,P.jsx)(_,{className:`size-4`,"aria-hidden":!0}):E===`error`?(0,P.jsx)(v,{className:`size-4`,"aria-hidden":!0}):(0,P.jsx)(S,{className:`size-4`,"aria-hidden":!0}),n[20]=E,n[21]=B);let V;n[22]!==D||n[23]!==u?(V=u?(0,P.jsx)(`span`,{children:D}):null,n[22]=D,n[23]=u,n[24]=V):V=n[24];let H;return n[25]!==r||n[26]!==D||n[27]!==t||n[28]!==z||n[29]!==B||n[30]!==V||n[31]!==O||n[32]!==k||n[33]!==A||n[34]!==j?(H=(0,P.jsxs)(`button`,{...r,ref:t,type:`button`,onClick:O,disabled:k,title:A,"aria-label":D,"aria-pressed":j,className:z,children:[B,V]}),n[25]=r,n[26]=D,n[27]=t,n[28]=z,n[29]=B,n[30]=V,n[31]=O,n[32]=k,n[33]=A,n[34]=j,n[35]=H):H=n[35],H});function I(e){return e.source}function L(e){return e.status}function R(e){return e.requestStart}function z(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),e)}function B(e,t){if(!e.enabled||e.trigger.kind!==`event`||e.trigger.eventType!==t.eventType||e.trigger.source&&e.trigger.source!==t.source)return!1;let n=e.trigger.payloadMatch;if(!n)return!0;let r=t.eventPayload??{};return Object.entries(n).every(([e,t])=>Object.is(r[e],t))}function V(e,t){let n=e.trigger,r=t.explain;return n.kind===`event`?[U(n.eventType,n.source,t),W(n.payloadMatch,t),K(e.safety,t),G(e.action,t)]:[r.triggerMatched,G(e.action,t)]}function H(e,t,n){let r=e.triggerSnapshot,i=J(t),a=n.explain;return r.kind===`event`?[i?U(i.type,i.source,n):U(r.eventType,r.source,n),W(r.payloadMatch,n),K(q(t),n),G(e.actionSnapshot,n)]:r.kind===`manual`?[a.manual,G(e.actionSnapshot,n)]:r.kind===`webhook`?[a.webhook,G(e.actionSnapshot,n)]:[a.schedule,G(e.actionSnapshot,n)]}function U(e,t,n){let r=n.explain;return t?z(r.eventFrom,{eventType:e,source:t}):z(r.event,{eventType:e})}function W(e,t){if(!e||Object.keys(e).length===0)return t.explain.noPayloadFilter;let n=Object.entries(e).slice(0,3).map(([e,t])=>`${e}=${String(t)}`).join(`, `);return z(t.explain.payloadMatched,{pairs:n})}function G(e,t){return e.kind===`task_command`?`Starts task ${e.taskId}.`:e.kind===`system`?`Runs system capability ${e.capability}.`:t.explain.actionAgent}function K(e,t){let n=e?.mode??`auto_apply`;return z(t.explain.safetyMode,{mode:t.safety[n]})}function q(e){if(!e.data||typeof e.data!=`object`||Array.isArray(e.data))return;let t=e.data.safety;if(!t||typeof t!=`object`||Array.isArray(t))return;let n=t.mode;return n===`suggest_only`||n===`ask_before_apply`||n===`auto_apply`?{mode:n}:void 0}function J(e){if(!e.data||typeof e.data!=`object`||Array.isArray(e.data))return null;let t=e.data.event;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;return typeof n.type!=`string`||!n.type.trim()?null:{type:n.type,source:typeof n.source==`string`?n.source:void 0}}function Y(e){return e===`succeeded`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:e===`cancelled`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300`}function X(e,t){return new Date(e).toLocaleString(t,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Z(e){return e.some(e=>[`queued`,`running`,`cancelling`].includes(e.run.status))}function Q(e){return e===`failed`||e===`timeout`||e===`cancelled`}function ee(e){let t=new Map;for(let{run:n}of e){let e=t.get(n.automationId),r=!e||n.createdAtMs>e.latest.createdAtMs?n:e.latest;t.set(n.automationId,{latest:r,hadAttention:!!e?.hadAttention||Q(n.status)})}let n={total:t.size,succeeded:0,active:0,attention:0,recovered:0};for(let{latest:e,hadAttention:r}of t.values())e.status===`succeeded`&&(n.succeeded+=1),e.status===`succeeded`&&r&&(n.recovered+=1),(e.status===`queued`||e.status===`running`||e.status===`cancelling`)&&(n.active+=1),Q(e.status)&&(n.attention+=1,n.latestAttentionRun??=e);return n}function te(e){let t=new Map;for(let{run:n}of e){let e=t.get(n.automationId);(!e||n.createdAtMs>e.createdAtMs)&&t.set(n.automationId,n)}return t}function $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),e)}function ne(e){let t=(0,M.c)(47),{health:n,labels:r,primaryRepairBusy:i,onPrimaryRepair:a}=e,o=n.attention>0,s=n.active>0,c=n.recovered>0,l;t[0]!==s||t[1]!==c||t[2]!==n.active||t[3]!==n.attention||t[4]!==n.latestAttentionRun?.automationName||t[5]!==n.recovered||t[6]!==n.succeeded||t[7]!==n.total||t[8]!==r.feedback.summaryHealthy||t[9]!==r.feedback.summaryNeedsAttention||t[10]!==r.feedback.summaryRecovered||t[11]!==r.feedback.summaryRunning||t[12]!==r.feedback.thisAutomation||t[13]!==o?(l=o?$(r.feedback.summaryNeedsAttention,{total:n.total,attention:n.attention,name:n.latestAttentionRun?.automationName??r.feedback.thisAutomation}):s?$(r.feedback.summaryRunning,{total:n.total,active:n.active}):c?$(r.feedback.summaryRecovered,{total:n.total,recovered:n.recovered,succeeded:n.succeeded}):$(r.feedback.summaryHealthy,{total:n.total,succeeded:n.succeeded}),t[0]=s,t[1]=c,t[2]=n.active,t[3]=n.attention,t[4]=n.latestAttentionRun?.automationName,t[5]=n.recovered,t[6]=n.succeeded,t[7]=n.total,t[8]=r.feedback.summaryHealthy,t[9]=r.feedback.summaryNeedsAttention,t[10]=r.feedback.summaryRecovered,t[11]=r.feedback.summaryRunning,t[12]=r.feedback.thisAutomation,t[13]=o,t[14]=l):l=t[14];let d=l,p=o?`text-amber-800 dark:text-amber-200`:`text-fg-muted`,m;t[15]===p?m=t[16]:(m=w(`break-words text-xs leading-5`,p),t[15]=p,t[16]=m);let h;t[17]!==d||t[18]!==m?(h=(0,P.jsx)(`p`,{className:m,children:d}),t[17]=d,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==n.succeeded||t[21]!==r.feedback.succeededCount?(g=n.succeeded?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,P.jsx)(u,{className:`size-3`,"aria-hidden":!0}),$(r.feedback.succeededCount,{count:n.succeeded})]}):null,t[20]=n.succeeded,t[21]=r.feedback.succeededCount,t[22]=g):g=t[22];let _;t[23]!==n.active||t[24]!==r.feedback.activeCount?(_=n.active?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-blue-500/25 bg-blue-500/10 px-2 py-0.5 text-xs text-blue-700 dark:text-blue-300`,children:[(0,P.jsx)(f,{className:`size-3`,"aria-hidden":!0}),$(r.feedback.activeCount,{count:n.active})]}):null,t[23]=n.active,t[24]=r.feedback.activeCount,t[25]=_):_=t[25];let v;t[26]!==n.attention||t[27]!==r.feedback.attentionCount?(v=n.attention?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-amber-500/25 bg-amber-500/10 px-2 py-0.5 text-xs text-amber-700 dark:text-amber-300`,children:[(0,P.jsx)(x,{className:`size-3`,"aria-hidden":!0}),$(r.feedback.attentionCount,{count:n.attention})]}):null,t[26]=n.attention,t[27]=r.feedback.attentionCount,t[28]=v):v=t[28];let y;t[29]!==n.recovered||t[30]!==r.feedback.recoveredCount?(y=n.recovered?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,P.jsx)(u,{className:`size-3`,"aria-hidden":!0}),$(r.feedback.recoveredCount,{count:n.recovered})]}):null,t[29]=n.recovered,t[30]=r.feedback.recoveredCount,t[31]=y):y=t[31];let S;t[32]!==g||t[33]!==_||t[34]!==v||t[35]!==y?(S=(0,P.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:[g,_,v,y]}),t[32]=g,t[33]=_,t[34]=v,t[35]=y,t[36]=S):S=t[36];let C;t[37]!==r.feedback.primaryRepair||t[38]!==r.feedback.primaryRepairing||t[39]!==o||t[40]!==a||t[41]!==i?(C=o&&a?(0,P.jsx)(`div`,{className:`mt-2`,children:(0,P.jsxs)(D,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:i,onClick:a,children:[(0,P.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),i?r.feedback.primaryRepairing:r.feedback.primaryRepair]})}):null,t[37]=r.feedback.primaryRepair,t[38]=r.feedback.primaryRepairing,t[39]=o,t[40]=a,t[41]=i,t[42]=C):C=t[42];let T;return t[43]!==C||t[44]!==h||t[45]!==S?(T=(0,P.jsxs)(`div`,{className:`mb-3 border-l-2 border-accent/50 pl-3`,children:[h,S,C]}),t[43]=C,t[44]=h,t[45]=S,t[46]=T):T=t[46],T}function re({eventType:e,source:t,payloadKey:n,payloadValue:r,limit:s=3,className:f,onSaveInsight:m,isInsightSaved:g}){let _=a(e=>e.language),v=o(_).automations,x=_===`zh`?`zh-CN`:`en-US`,S=[`product-automation-feedback`,e,t??``,n??``,r??``,s],[T,k]=(0,N.useState)(null),[A,j]=(0,N.useState)(null),{data:M,mutate:F}=E(e&&(!n||r!==void 0)?S:null,()=>O.productEventRuns({eventType:e,source:t,payloadKey:n,payloadValue:r,limit:s}),{revalidateOnFocus:!1,refreshInterval:e=>e?.items&&Z(e.items)?3e3:15e3}),[I,L]=(0,N.useState)({}),[R,z]=(0,N.useState)({}),B=M?.items??[],V=ee(B),U=te(B);if(!B.length)return null;let W=async(e,t)=>{k(e),j(null);try{await t(),await F()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(null)}},G=async e=>{k(`${e.id}:repair`),j(null);try{let t=await O.repairDraft(e.id,{language:_});L(n=>({...n,[e.id]:t.repair})),z(t=>({...t,[e.id]:!1}))}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(null)}},K=async(e,t,n=!1)=>{k(n?`${e.id}:applyAndRerun`:`${e.id}:applyRepair`),j(null);try{await O.update(e.automationId,t.patch),n&&await O.rerun(e.id),await F(),L(t=>{let n={...t};return delete n[e.id],n}),z(t=>{let n={...t};return delete n[e.id],n})}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(null)}},q=V.latestAttentionRun&&!I[V.latestAttentionRun.id]?V.latestAttentionRun:void 0,J=q?T===`${q.id}:repair`:!1;return(0,P.jsxs)(`section`,{className:w(`rounded-lg border border-edge bg-surface-panel p-3`,f),children:[(0,P.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,P.jsxs)(`h3`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,P.jsx)(C,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,P.jsx)(`span`,{className:`truncate`,children:v.feedback.title})]}),(0,P.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:B.length})]}),(0,P.jsx)(ne,{health:V,labels:v,primaryRepairBusy:J,onPrimaryRepair:q?()=>void G(q):void 0}),A?(0,P.jsxs)(`p`,{className:`mb-2 rounded-md border border-danger/25 bg-danger-soft px-2.5 py-2 text-xs text-danger`,role:`alert`,children:[v.feedback.actionFailed,`: `,A]}):null,(0,P.jsx)(`ul`,{className:`grid gap-2`,children:B.map(({run:e,triggerEvent:t})=>{let n=U.get(e.automationId),r=n?.id===e.id,a=Q(e.status)&&!r,o=a&&n?.status===`succeeded`,s=I[e.id],f=R[e.id]??!1,_=T===`${e.id}:repair`,S=T===`${e.id}:applyRepair`,C=T===`${e.id}:applyAndRerun`,E=H(e,t,v),k=g?.(e)??!1,A=e.status===`succeeded`&&!!e.summary&&!!m&&!k,j=T===`${e.id}:saveInsight`;return(0,P.jsxs)(`li`,{className:`rounded-md border border-edge/70 bg-surface-inset/35 px-2.5 py-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,P.jsx)(l,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,P.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.automationName})]}),(0,P.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-xs text-fg-muted`,children:e.error||e.summary||t.message})]}),(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,P.jsx)(`span`,{className:w(`rounded-full border px-2 py-0.5 text-xs`,Y(e.status)),children:v.status[e.status]}),a?(0,P.jsx)(`span`,{className:`rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:o?v.feedback.recovered:v.feedback.historical}):null]})]}),(0,P.jsx)(`div`,{className:`mt-2 flex items-center justify-between gap-2 text-xs text-fg-muted`,children:(0,P.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,P.jsx)(c,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,P.jsx)(`span`,{className:`truncate`,children:X(t.createdAtMs,x)})]})}),(0,P.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/60 bg-surface-base/45 px-2.5 py-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:v.explain.whyRan}),(0,P.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:E.map(e=>(0,P.jsx)(`span`,{className:`rounded-full border border-edge/70 bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e))})]}),s?(0,P.jsxs)(`div`,{className:`mt-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-semibold text-amber-800 dark:text-amber-200`,children:[(0,P.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),v.repair.title]}),(0,P.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg`,children:s.explanation}),s.expectedEffect?(0,P.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:s.expectedEffect}):null,s.risks.length?(0,P.jsx)(`ul`,{className:`mt-2 list-disc space-y-1 pl-4 text-xs text-fg-muted`,children:s.risks.slice(0,3).map(e=>(0,P.jsx)(`li`,{children:e},e))}):null,s.requiresApproval?(0,P.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-fg`,children:[(0,P.jsx)(`input`,{className:`mt-0.5`,type:`checkbox`,checked:f,onChange:t=>{z(n=>({...n,[e.id]:t.target.checked}))}}),(0,P.jsx)(`span`,{children:v.repair.approval})]}):null,(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1.5`,children:[(0,P.jsx)(D,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,onClick:()=>{L(t=>{let n={...t};return delete n[e.id],n})},children:v.draft.discard}),(0,P.jsx)(D,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:s.requiresApproval&&!f||T!==null,onClick:()=>void K(e,s),children:S?v.feedback.working:v.repair.apply}),(0,P.jsxs)(D,{variant:`primary`,className:`h-7 rounded-md px-2 text-xs`,disabled:s.requiresApproval&&!f||T!==null,onClick:()=>void K(e,s,!0),children:[(0,P.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),C?v.feedback.working:v.feedback.applyAndRerun]})]})]}):null,(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[k?(0,P.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1 rounded-md border border-emerald-500/25 bg-emerald-500/10 px-2 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,P.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),v.feedback.savedInsight]}):null,A?(0,P.jsxs)(D,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:T!==null,onClick:()=>void W(`${e.id}:saveInsight`,()=>Promise.resolve(m(e))),children:[(0,P.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),j?v.feedback.savingInsight:v.feedback.saveInsight]}):null,e.conversationId?(0,P.jsx)(D,{asChild:!0,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,children:(0,P.jsxs)(i,{to:`/chat/${encodeURIComponent(e.conversationId)}`,children:[(0,P.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),v.feedback.chat]})}):null,null,r&&Q(e.status)&&!s?(0,P.jsxs)(D,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:T!==null,onClick:()=>void G(e),children:[(0,P.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),_?v.repair.generating:v.repair.suggest]}):null,(0,P.jsxs)(D,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:T!==null,onClick:()=>void W(`${e.id}:rerun`,()=>O.rerun(e.id)),children:[(0,P.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),T===`${e.id}:rerun`?v.feedback.working:v.feedback.rerun]}),(0,P.jsxs)(D,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:T!==null,onClick:()=>void W(`${e.id}:pause`,()=>O.pause(e.automationId)),children:[(0,P.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),T===`${e.id}:pause`?v.feedback.working:v.feedback.pause]}),(0,P.jsx)(D,{asChild:!0,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,children:(0,P.jsxs)(i,{to:`/automations?run=${encodeURIComponent(e.id)}`,children:[(0,P.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),v.feedback.open]})})]})]},e.id)})})]})}export{F as a,k as c,B as i,V as n,j as o,z as r,A as s,re as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{n as a}from"./locale-store-CHjsq5NR.js";import{t as o}from"./messages-C7QSnTdg.js";import{t as s}from"./createLucideIcon-DPHK1VkS.js";import{t as c}from"./activity-YogQEteU.js";import{t as l}from"./bot-DjLkhyZL.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./circle-pause-CN9jYH2s.js";import{t as f}from"./clock-3-DnrAnuyZ.js";import{t as p}from"./external-link-DjqjBmc3.js";import{t as m}from"./loader-circle-CifKLtgG.js";import{t as h}from"./message-square-fVE7Ghj1.js";import{t as g}from"./pause-DuPxgSxk.js";import{t as _}from"./play-kxZvpBg8.js";import{t as v}from"./rotate-ccw-JM1TBLpp.js";import{t as y}from"./rotate-cw-LIg3Am9S.js";import{t as b}from"./sparkles-DHlfQFAF.js";import{t as x}from"./triangle-alert-2JXFNNKU.js";import{t as S}from"./volume-2-BSJhAY97.js";import{t as C}from"./zap-dximCGjy.js";import{t as w}from"./cn-0WouolD0.js";import{a as T}from"./session-manager-C2MCS4C5.js";import{i as E}from"./vendor-swr-CdRzEUwF.js";import{t as D}from"./button-C5tRaJxt.js";import{t as O}from"./automation-api-D-gn6x5E.js";var k=s(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),A=s(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),j=s(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),M=n(),N=e(t(),1),P=r(),F=(0,N.forwardRef)(function(e,t){let n=(0,M.c)(36),r,i,a,o,s,c,l;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7]):({input:a,labels:o,className:i,showLabel:s,disabled:c,hideNativeTitle:l,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c,n[7]=l);let u=s!==void 0&&s,d=c!==void 0&&c,f=l!==void 0&&l,p;n[8]===a?p=n[9]:(p=typeof a==`function`?a():a,n[8]=a,n[9]=p);let h=p,y=T(I),b=T(L),x=T(R),C=y?.type===h.source.type&&y.id===h.source.id,E=C?b:`idle`,D=E===`preparing`?o.preparing:E===`playing`?o.pause:E===`paused`?o.resume:E===`error`?o.retry:o.read,O;n[10]!==a||n[11]!==x?(O=()=>x(typeof a==`function`?a():a),n[10]=a,n[11]=x,n[12]=O):O=n[12];let k;n[13]!==d||n[14]!==h.text?(k=d||!h.text.trim(),n[13]=d,n[14]=h.text,n[15]=k):k=n[15];let A=f?void 0:D,j=C&&(E===`playing`||E===`paused`),N=u?`min-h-11 gap-1.5 px-2.5 text-sm font-medium sm:min-h-8 sm:text-xs`:`size-11 sm:size-9`,F=C&&`bg-surface-active text-accent`,z;n[16]!==i||n[17]!==F||n[18]!==N?(z=w(`inline-flex shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors transition-transform duration-150 ease-out`,`hover:bg-surface-hover hover:text-fg active:scale-95 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,N,F,i),n[16]=i,n[17]=F,n[18]=N,n[19]=z):z=n[19];let B;n[20]===E?B=n[21]:(B=E===`preparing`?(0,P.jsx)(m,{className:`size-4 animate-spin`,"aria-hidden":!0}):E===`playing`?(0,P.jsx)(g,{className:`size-4`,"aria-hidden":!0}):E===`paused`?(0,P.jsx)(_,{className:`size-4`,"aria-hidden":!0}):E===`error`?(0,P.jsx)(v,{className:`size-4`,"aria-hidden":!0}):(0,P.jsx)(S,{className:`size-4`,"aria-hidden":!0}),n[20]=E,n[21]=B);let V;n[22]!==D||n[23]!==u?(V=u?(0,P.jsx)(`span`,{children:D}):null,n[22]=D,n[23]=u,n[24]=V):V=n[24];let H;return n[25]!==r||n[26]!==D||n[27]!==t||n[28]!==z||n[29]!==B||n[30]!==V||n[31]!==O||n[32]!==k||n[33]!==A||n[34]!==j?(H=(0,P.jsxs)(`button`,{...r,ref:t,type:`button`,onClick:O,disabled:k,title:A,"aria-label":D,"aria-pressed":j,className:z,children:[B,V]}),n[25]=r,n[26]=D,n[27]=t,n[28]=z,n[29]=B,n[30]=V,n[31]=O,n[32]=k,n[33]=A,n[34]=j,n[35]=H):H=n[35],H});function I(e){return e.source}function L(e){return e.status}function R(e){return e.requestStart}function z(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),e)}function B(e,t){if(!e.enabled||e.trigger.kind!==`event`||e.trigger.eventType!==t.eventType||e.trigger.source&&e.trigger.source!==t.source)return!1;let n=e.trigger.payloadMatch;if(!n)return!0;let r=t.eventPayload??{};return Object.entries(n).every(([e,t])=>Object.is(r[e],t))}function V(e,t){let n=e.trigger,r=t.explain;return n.kind===`event`?[U(n.eventType,n.source,t),W(n.payloadMatch,t),K(e.safety,t),G(e.action,t)]:[r.triggerMatched,G(e.action,t)]}function H(e,t,n){let r=e.triggerSnapshot,i=J(t),a=n.explain;return r.kind===`event`?[i?U(i.type,i.source,n):U(r.eventType,r.source,n),W(r.payloadMatch,n),K(q(t),n),G(e.actionSnapshot,n)]:r.kind===`manual`?[a.manual,G(e.actionSnapshot,n)]:r.kind===`webhook`?[a.webhook,G(e.actionSnapshot,n)]:[a.schedule,G(e.actionSnapshot,n)]}function U(e,t,n){let r=n.explain;return t?z(r.eventFrom,{eventType:e,source:t}):z(r.event,{eventType:e})}function W(e,t){if(!e||Object.keys(e).length===0)return t.explain.noPayloadFilter;let n=Object.entries(e).slice(0,3).map(([e,t])=>`${e}=${String(t)}`).join(`, `);return z(t.explain.payloadMatched,{pairs:n})}function G(e,t){return e.kind===`task_command`?`Starts task ${e.taskId}.`:e.kind===`system`?`Runs system capability ${e.capability}.`:t.explain.actionAgent}function K(e,t){let n=e?.mode??`auto_apply`;return z(t.explain.safetyMode,{mode:t.safety[n]})}function q(e){if(!e.data||typeof e.data!=`object`||Array.isArray(e.data))return;let t=e.data.safety;if(!t||typeof t!=`object`||Array.isArray(t))return;let n=t.mode;return n===`suggest_only`||n===`ask_before_apply`||n===`auto_apply`?{mode:n}:void 0}function J(e){if(!e.data||typeof e.data!=`object`||Array.isArray(e.data))return null;let t=e.data.event;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;return typeof n.type!=`string`||!n.type.trim()?null:{type:n.type,source:typeof n.source==`string`?n.source:void 0}}function Y(e){return e===`succeeded`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:e===`cancelled`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300`}function X(e,t){return new Date(e).toLocaleString(t,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Z(e){return e.some(e=>[`queued`,`running`,`cancelling`].includes(e.run.status))}function Q(e){return e===`failed`||e===`timeout`||e===`cancelled`}function ee(e){let t=new Map;for(let{run:n}of e){let e=t.get(n.automationId),r=!e||n.createdAtMs>e.latest.createdAtMs?n:e.latest;t.set(n.automationId,{latest:r,hadAttention:!!e?.hadAttention||Q(n.status)})}let n={total:t.size,succeeded:0,active:0,attention:0,recovered:0};for(let{latest:e,hadAttention:r}of t.values())e.status===`succeeded`&&(n.succeeded+=1),e.status===`succeeded`&&r&&(n.recovered+=1),(e.status===`queued`||e.status===`running`||e.status===`cancelling`)&&(n.active+=1),Q(e.status)&&(n.attention+=1,n.latestAttentionRun??=e);return n}function te(e){let t=new Map;for(let{run:n}of e){let e=t.get(n.automationId);(!e||n.createdAtMs>e.createdAtMs)&&t.set(n.automationId,n)}return t}function $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),e)}function ne(e){let t=(0,M.c)(47),{health:n,labels:r,primaryRepairBusy:i,onPrimaryRepair:a}=e,o=n.attention>0,s=n.active>0,c=n.recovered>0,l;t[0]!==s||t[1]!==c||t[2]!==n.active||t[3]!==n.attention||t[4]!==n.latestAttentionRun?.automationName||t[5]!==n.recovered||t[6]!==n.succeeded||t[7]!==n.total||t[8]!==r.feedback.summaryHealthy||t[9]!==r.feedback.summaryNeedsAttention||t[10]!==r.feedback.summaryRecovered||t[11]!==r.feedback.summaryRunning||t[12]!==r.feedback.thisAutomation||t[13]!==o?(l=o?$(r.feedback.summaryNeedsAttention,{total:n.total,attention:n.attention,name:n.latestAttentionRun?.automationName??r.feedback.thisAutomation}):s?$(r.feedback.summaryRunning,{total:n.total,active:n.active}):c?$(r.feedback.summaryRecovered,{total:n.total,recovered:n.recovered,succeeded:n.succeeded}):$(r.feedback.summaryHealthy,{total:n.total,succeeded:n.succeeded}),t[0]=s,t[1]=c,t[2]=n.active,t[3]=n.attention,t[4]=n.latestAttentionRun?.automationName,t[5]=n.recovered,t[6]=n.succeeded,t[7]=n.total,t[8]=r.feedback.summaryHealthy,t[9]=r.feedback.summaryNeedsAttention,t[10]=r.feedback.summaryRecovered,t[11]=r.feedback.summaryRunning,t[12]=r.feedback.thisAutomation,t[13]=o,t[14]=l):l=t[14];let d=l,p=o?`text-amber-800 dark:text-amber-200`:`text-fg-muted`,m;t[15]===p?m=t[16]:(m=w(`break-words text-xs leading-5`,p),t[15]=p,t[16]=m);let h;t[17]!==d||t[18]!==m?(h=(0,P.jsx)(`p`,{className:m,children:d}),t[17]=d,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==n.succeeded||t[21]!==r.feedback.succeededCount?(g=n.succeeded?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,P.jsx)(u,{className:`size-3`,"aria-hidden":!0}),$(r.feedback.succeededCount,{count:n.succeeded})]}):null,t[20]=n.succeeded,t[21]=r.feedback.succeededCount,t[22]=g):g=t[22];let _;t[23]!==n.active||t[24]!==r.feedback.activeCount?(_=n.active?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-blue-500/25 bg-blue-500/10 px-2 py-0.5 text-xs text-blue-700 dark:text-blue-300`,children:[(0,P.jsx)(f,{className:`size-3`,"aria-hidden":!0}),$(r.feedback.activeCount,{count:n.active})]}):null,t[23]=n.active,t[24]=r.feedback.activeCount,t[25]=_):_=t[25];let v;t[26]!==n.attention||t[27]!==r.feedback.attentionCount?(v=n.attention?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-amber-500/25 bg-amber-500/10 px-2 py-0.5 text-xs text-amber-700 dark:text-amber-300`,children:[(0,P.jsx)(x,{className:`size-3`,"aria-hidden":!0}),$(r.feedback.attentionCount,{count:n.attention})]}):null,t[26]=n.attention,t[27]=r.feedback.attentionCount,t[28]=v):v=t[28];let y;t[29]!==n.recovered||t[30]!==r.feedback.recoveredCount?(y=n.recovered?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,P.jsx)(u,{className:`size-3`,"aria-hidden":!0}),$(r.feedback.recoveredCount,{count:n.recovered})]}):null,t[29]=n.recovered,t[30]=r.feedback.recoveredCount,t[31]=y):y=t[31];let S;t[32]!==g||t[33]!==_||t[34]!==v||t[35]!==y?(S=(0,P.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:[g,_,v,y]}),t[32]=g,t[33]=_,t[34]=v,t[35]=y,t[36]=S):S=t[36];let C;t[37]!==r.feedback.primaryRepair||t[38]!==r.feedback.primaryRepairing||t[39]!==o||t[40]!==a||t[41]!==i?(C=o&&a?(0,P.jsx)(`div`,{className:`mt-2`,children:(0,P.jsxs)(D,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:i,onClick:a,children:[(0,P.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),i?r.feedback.primaryRepairing:r.feedback.primaryRepair]})}):null,t[37]=r.feedback.primaryRepair,t[38]=r.feedback.primaryRepairing,t[39]=o,t[40]=a,t[41]=i,t[42]=C):C=t[42];let T;return t[43]!==C||t[44]!==h||t[45]!==S?(T=(0,P.jsxs)(`div`,{className:`mb-3 border-l-2 border-accent/50 pl-3`,children:[h,S,C]}),t[43]=C,t[44]=h,t[45]=S,t[46]=T):T=t[46],T}function re({eventType:e,source:t,payloadKey:n,payloadValue:r,limit:s=3,className:f,onSaveInsight:m,isInsightSaved:g}){let _=a(e=>e.language),v=o(_).automations,x=_===`zh`?`zh-CN`:`en-US`,S=[`product-automation-feedback`,e,t??``,n??``,r??``,s],[T,k]=(0,N.useState)(null),[A,j]=(0,N.useState)(null),{data:M,mutate:F}=E(e&&(!n||r!==void 0)?S:null,()=>O.productEventRuns({eventType:e,source:t,payloadKey:n,payloadValue:r,limit:s}),{revalidateOnFocus:!1,refreshInterval:e=>e?.items&&Z(e.items)?3e3:15e3}),[I,L]=(0,N.useState)({}),[R,z]=(0,N.useState)({}),B=M?.items??[],V=ee(B),U=te(B);if(!B.length)return null;let W=async(e,t)=>{k(e),j(null);try{await t(),await F()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(null)}},G=async e=>{k(`${e.id}:repair`),j(null);try{let t=await O.repairDraft(e.id,{language:_});L(n=>({...n,[e.id]:t.repair})),z(t=>({...t,[e.id]:!1}))}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(null)}},K=async(e,t,n=!1)=>{k(n?`${e.id}:applyAndRerun`:`${e.id}:applyRepair`),j(null);try{await O.update(e.automationId,t.patch),n&&await O.rerun(e.id),await F(),L(t=>{let n={...t};return delete n[e.id],n}),z(t=>{let n={...t};return delete n[e.id],n})}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(null)}},q=V.latestAttentionRun&&!I[V.latestAttentionRun.id]?V.latestAttentionRun:void 0,J=q?T===`${q.id}:repair`:!1;return(0,P.jsxs)(`section`,{className:w(`rounded-lg border border-edge bg-surface-panel p-3`,f),children:[(0,P.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,P.jsxs)(`h3`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,P.jsx)(C,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,P.jsx)(`span`,{className:`truncate`,children:v.feedback.title})]}),(0,P.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:B.length})]}),(0,P.jsx)(ne,{health:V,labels:v,primaryRepairBusy:J,onPrimaryRepair:q?()=>void G(q):void 0}),A?(0,P.jsxs)(`p`,{className:`mb-2 rounded-md border border-danger/25 bg-danger-soft px-2.5 py-2 text-xs text-danger`,role:`alert`,children:[v.feedback.actionFailed,`: `,A]}):null,(0,P.jsx)(`ul`,{className:`grid gap-2`,children:B.map(({run:e,triggerEvent:t})=>{let n=U.get(e.automationId),r=n?.id===e.id,a=Q(e.status)&&!r,o=a&&n?.status===`succeeded`,s=I[e.id],f=R[e.id]??!1,_=T===`${e.id}:repair`,S=T===`${e.id}:applyRepair`,C=T===`${e.id}:applyAndRerun`,E=H(e,t,v),k=g?.(e)??!1,A=e.status===`succeeded`&&!!e.summary&&!!m&&!k,j=T===`${e.id}:saveInsight`;return(0,P.jsxs)(`li`,{className:`rounded-md border border-edge/70 bg-surface-inset/35 px-2.5 py-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,P.jsx)(l,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,P.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.automationName})]}),(0,P.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-xs text-fg-muted`,children:e.error||e.summary||t.message})]}),(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,P.jsx)(`span`,{className:w(`rounded-full border px-2 py-0.5 text-xs`,Y(e.status)),children:v.status[e.status]}),a?(0,P.jsx)(`span`,{className:`rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:o?v.feedback.recovered:v.feedback.historical}):null]})]}),(0,P.jsx)(`div`,{className:`mt-2 flex items-center justify-between gap-2 text-xs text-fg-muted`,children:(0,P.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,P.jsx)(c,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,P.jsx)(`span`,{className:`truncate`,children:X(t.createdAtMs,x)})]})}),(0,P.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/60 bg-surface-base/45 px-2.5 py-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:v.explain.whyRan}),(0,P.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:E.map(e=>(0,P.jsx)(`span`,{className:`rounded-full border border-edge/70 bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e))})]}),s?(0,P.jsxs)(`div`,{className:`mt-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-semibold text-amber-800 dark:text-amber-200`,children:[(0,P.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),v.repair.title]}),(0,P.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg`,children:s.explanation}),s.expectedEffect?(0,P.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:s.expectedEffect}):null,s.risks.length?(0,P.jsx)(`ul`,{className:`mt-2 list-disc space-y-1 pl-4 text-xs text-fg-muted`,children:s.risks.slice(0,3).map(e=>(0,P.jsx)(`li`,{children:e},e))}):null,s.requiresApproval?(0,P.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-fg`,children:[(0,P.jsx)(`input`,{className:`mt-0.5`,type:`checkbox`,checked:f,onChange:t=>{z(n=>({...n,[e.id]:t.target.checked}))}}),(0,P.jsx)(`span`,{children:v.repair.approval})]}):null,(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1.5`,children:[(0,P.jsx)(D,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,onClick:()=>{L(t=>{let n={...t};return delete n[e.id],n})},children:v.draft.discard}),(0,P.jsx)(D,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:s.requiresApproval&&!f||T!==null,onClick:()=>void K(e,s),children:S?v.feedback.working:v.repair.apply}),(0,P.jsxs)(D,{variant:`primary`,className:`h-7 rounded-md px-2 text-xs`,disabled:s.requiresApproval&&!f||T!==null,onClick:()=>void K(e,s,!0),children:[(0,P.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),C?v.feedback.working:v.feedback.applyAndRerun]})]})]}):null,(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[k?(0,P.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1 rounded-md border border-emerald-500/25 bg-emerald-500/10 px-2 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,P.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),v.feedback.savedInsight]}):null,A?(0,P.jsxs)(D,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:T!==null,onClick:()=>void W(`${e.id}:saveInsight`,()=>Promise.resolve(m(e))),children:[(0,P.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),j?v.feedback.savingInsight:v.feedback.saveInsight]}):null,e.conversationId?(0,P.jsx)(D,{asChild:!0,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,children:(0,P.jsxs)(i,{to:`/chat/${encodeURIComponent(e.conversationId)}`,children:[(0,P.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),v.feedback.chat]})}):null,null,r&&Q(e.status)&&!s?(0,P.jsxs)(D,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:T!==null,onClick:()=>void G(e),children:[(0,P.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),_?v.repair.generating:v.repair.suggest]}):null,(0,P.jsxs)(D,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:T!==null,onClick:()=>void W(`${e.id}:rerun`,()=>O.rerun(e.id)),children:[(0,P.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),T===`${e.id}:rerun`?v.feedback.working:v.feedback.rerun]}),(0,P.jsxs)(D,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:T!==null,onClick:()=>void W(`${e.id}:pause`,()=>O.pause(e.automationId)),children:[(0,P.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),T===`${e.id}:pause`?v.feedback.working:v.feedback.pause]}),(0,P.jsx)(D,{asChild:!0,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,children:(0,P.jsxs)(i,{to:`/automations?run=${encodeURIComponent(e.id)}`,children:[(0,P.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),v.feedback.open]})})]})]},e.id)})})]})}export{F as a,k as c,B as i,V as n,j as o,z as r,A as s,re as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{d as n,t as r}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{i,l as a,n as o}from"./locale-store-CHjsq5NR.js";import{t as s}from"./messages-C7QSnTdg.js";import{i as c,u as l}from"./automation-display-DaVDNZz8.js";import{F as u,V as d,t as f}from"./markdown-view-ihzUc4ud.js";import{t as p}from"./skeleton-DzdOeGYz.js";import{p as m}from"./tasks-CvOAtEHv.js";import{a as h,c as g}from"./api-CGrHK9ij.js";import{i as _}from"./vendor-swr-CdRzEUwF.js";import{t as v}from"./button-C5tRaJxt.js";import{t as y}from"./task-copy-CtcqCQ78.js";import{t as b}from"./automation-api-D-gn6x5E.js";import{n as x}from"./automation-task-card-C453Q-Wa.js";import{i as S,n as C}from"./api-B3T06TLl.js";import{n as w}from"./product-preview-modal-5kTp_7Qk.js";import{t as T}from"./open-route-MyZ2sB9C.js";import{i as E,r as D}from"./automation-result-state-B7hq0XOL.js";import{t as O}from"./project-overview-model-DrLXaO-t.js";import{n as k}from"./task-result-presentation-CgvcqEMD.js";var A=e(),j=t(),M=new Set([`queued`,`running`,`cancelling`]);function N(e){let t=(0,A.c)(60),{automationId:n,runId:r}=e,i=o(I),a=i===`zh`,c,l;t[0]!==n||t[1]!==r?(c=[`automation-run-preview`,n,r],l=async()=>{let[e,t]=await Promise.all([b.get(n),r?b.getRun(r).then(F):Promise.resolve(void 0)]);if(t&&t.automationId!==n)throw Error(`Run does not belong to this task`);return{task:e.automation,run:t}},t[0]=n,t[1]=r,t[2]=c,t[3]=l):(c=t[2],l=t[3]);let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u={shouldRetryOnError:!1,refreshInterval:P},t[4]=u):u=t[4];let{data:d,error:m,mutate:h}=_(c,l,u);if(m){let e=a?`暂时无法读取这次运行,请重试。`:`Could not load this run. Try again.`,n;t[5]===e?n=t[6]:(n=(0,j.jsx)(`p`,{children:e}),t[5]=e,t[6]=n);let r;t[7]===h?r=t[8]:(r=()=>void h(),t[7]=h,t[8]=r);let i=a?`重试`:`Retry`,o;t[9]!==r||t[10]!==i?(o=(0,j.jsx)(v,{variant:`secondary`,onClick:r,children:i}),t[9]=r,t[10]=i,t[11]=o):o=t[11];let s;return t[12]!==n||t[13]!==o?(s=(0,j.jsxs)(`div`,{role:`alert`,className:`space-y-3 text-sm text-fg-muted`,children:[n,o]}),t[12]=n,t[13]=o,t[14]=s):s=t[14],s}if(!d){let e;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,j.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,j.jsx)(p,{className:`h-6 w-2/3`}),(0,j.jsx)(p,{className:`h-4 w-1/3`}),(0,j.jsx)(p,{className:`h-32`})]}),t[15]=e):e=t[15],e}let g=d.run;if(!g){let e;t[16]===d.task.name?e=t[17]:(e=(0,j.jsx)(`h2`,{className:`text-lg font-medium text-fg`,children:d.task.name}),t[16]=d.task.name,t[17]=e);let n=a?`这条旧链接没有关联具体执行,请从任务的运行记录查看。`:`This older link does not identify an execution. Choose one from the task history.`,r;t[18]===n?r=t[19]:(r=(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n}),t[18]=n,t[19]=r);let i;return t[20]!==e||t[21]!==r?(i=(0,j.jsxs)(`div`,{className:`space-y-3`,children:[e,r]}),t[20]=e,t[21]=r,t[22]=i):i=t[22],i}let y;t[23]===d.task.name?y=t[24]:(y=(0,j.jsx)(`h2`,{className:`text-lg font-medium text-fg`,children:d.task.name}),t[23]=d.task.name,t[24]=y);let S;t[25]===i?S=t[26]:(S=s(i),t[25]=i,t[26]=S);let C=S.automations.status[g.status],w;t[27]!==g.createdAtMs||t[28]!==a?(w=new Date(g.createdAtMs).toLocaleString(a?`zh-CN`:`en-US`),t[27]=g.createdAtMs,t[28]=a,t[29]=w):w=t[29];let T;t[30]!==C||t[31]!==w?(T=(0,j.jsxs)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:[C,` · `,w]}),t[30]=C,t[31]=w,t[32]=T):T=t[32];let O;t[33]!==y||t[34]!==T?(O=(0,j.jsxs)(`div`,{className:`space-y-2`,children:[y,T]}),t[33]=y,t[34]=T,t[35]=O):O=t[35];let k;t[36]!==g.status||t[37]!==a?(k=g.status===`queued`?(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a?`任务正在排队,开始后会自动更新。`:`Queued. This view updates when execution starts.`}):g.status===`running`?(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a?`正在执行,结果会自动显示在这里。`:`Running. The result will appear here automatically.`}):null,t[36]=g.status,t[37]=a,t[38]=k):k=t[38];let N;t[39]===g.summary?N=t[40]:(N=g.summary?(0,j.jsx)(f,{content:g.summary}):null,t[39]=g.summary,t[40]=N);let L;t[41]!==i||t[42]!==g?(L=g.error?(0,j.jsx)(`p`,{className:`text-sm leading-6 text-danger`,children:D(g,i)}):null,t[41]=i,t[42]=g,t[43]=L):L=t[43];let R;t[44]!==n||t[45]!==i||t[46]!==g.id||t[47]!==g.status?(R=g.status===`failed`||g.status===`timeout`?(0,j.jsx)(x,{automationId:n,runId:g.id,language:i,variant:`secondary`}):null,t[44]=n,t[45]=i,t[46]=g.id,t[47]=g.status,t[48]=R):R=t[48];let z;t[49]!==i||t[50]!==g.id||t[51]!==g.status?(z=M.has(g.status)?null:(0,j.jsx)(E,{runId:g.id,language:i}),t[49]=i,t[50]=g.id,t[51]=g.status,t[52]=z):z=t[52];let ee;return t[53]!==k||t[54]!==N||t[55]!==L||t[56]!==R||t[57]!==z||t[58]!==O?(ee=(0,j.jsxs)(`div`,{className:`space-y-5`,children:[O,k,N,L,R,z]}),t[53]=k,t[54]=N,t[55]=L,t[56]=R,t[57]=z,t[58]=O,t[59]=ee):ee=t[59],ee}function P(e){return e&&(e.task.state.runningRunId||e.run&&M.has(e.run.status))?3e3:0}function F(e){return e.run}function I(e){return e.language}var L=`rounded text-sm text-accent-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent`,R=e=>e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`);function z(e){let t=(0,A.c)(84),{project:i,target:c}=e,l=o(B),h=a(oe),v=n(),b=l===`zh`,x;t[0]===l?x=t[1]:(x=s(l),t[0]=l,t[1]=x);let S=x.projectDetailPage,C;t[2]!==c.id||t[3]!==h?(C=[`chat-project-operating-view`,c.id,h],t[2]=c.id,t[3]=h,t[4]=C):C=t[4];let w;t[5]===c.id?w=t[6]:(w=()=>g(c.id),t[5]=c.id,t[6]=w);let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T={shouldRetryOnError:!1},t[7]=T):T=t[7];let{data:E,error:D,isLoading:M,mutate:N}=_(C,w,T),P=`${v.pathname}${v.search}`,F=`/projects/${encodeURIComponent(c.id)}`,I;t[8]!==P||t[9]!==F||t[10]!==c.ownerAgentId?(I=e=>{let t=new URLSearchParams;return c.ownerAgentId&&t.set(`agentId`,c.ownerAgentId),d(`${F}/${e}${t.size?`?${t}`:``}`,P)},t[8]=P,t[9]=F,t[10]=c.ownerAgentId,t[11]=I):I=t[11];let z=I,V;t[12]===P?V=t[13]:(V=e=>u(P,e),t[12]=P,t[13]=V);let H=V,U,W,G,K,q,J,Y;if(t[14]!==D||t[15]!==M||t[16]!==l||t[17]!==N||t[18]!==S||t[19]!==i||t[20]!==z||t[21]!==H||t[22]!==E||t[23]!==b){let e=E?.tasks??[],n={moving:0,ready:0,waiting:0,needsUser:0,done:0};for(let t of e)t.phase===`closed`?t.resolution===`done`&&(n.done+=1):R(t)?n.needsUser+=1:[`queued`,`running`,`verifying`].includes(t.operationalState)?n.moving+=1:[`waiting`,`blocked`].includes(t.operationalState)?n.waiting+=1:n.ready+=1;let a={moving:b?`进行中`:`In progress`,ready:b?`待处理`:`To do`,waiting:b?`等待中`:`Waiting`,needsUser:b?`等你处理`:`Needs you`,done:b?`已完成`:`Completed`},o=new Set(e.filter(ae).map(ie)),s=(E?.blockers??[]).filter(e=>o.has(e.taskId)).sort(re),c=s.filter((e,t)=>s.findIndex(t=>t.taskId===e.taskId)===t).slice(0,2),u=O(e,e.length).sort(ne).slice(0,3),d=[...(i.recentUpdates??[]).map((e,t)=>({id:`update:${e.id??t}`,source:`project`,summary:e.summary,at:e.createdAt,title:b?`项目进展`:`Project update`,href:z(`progress`)})),...(E?.recentResults??[]).map(e=>{let{taskId:t,taskTitle:n,receipt:r}=e;return{id:`receipt:${r.runId}`,source:`task:${t}`,summary:r.status===`failed`?k(r.summary,l):r.summary,at:r.finalizedAt,title:`${n} · ${y(l).resultStatuses[m(r)]}`,href:H(t)}})].filter(te).sort(ee),h=d.filter((e,t)=>d.findIndex(t=>t.source===e.source&&t.summary.trim()===e.summary.trim())===t).slice(0,3),g;t[31]===b?g=t[32]:(g=e=>e===void 0||!Number.isFinite(new Date(e).getTime())?null:new Intl.DateTimeFormat(b?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e)),t[31]=b,t[32]=g);let _=g,v=i.lastActiveAt||i.updatedAt,x;t[33]!==_||t[34]!==v?(x=_(v),t[33]=_,t[34]=v,t[35]=x):x=t[35];let C=x,w=i.outcome||i.description||i.brief,T=b?`项目健康度尚未评估`:`Project health not assessed`,A=b?`进展正常`:`On track`,P=b?`存在风险`:`At risk`,F=b?`偏离计划`:`Off track`,I;t[36]!==T||t[37]!==A||t[38]!==P||t[39]!==F?(I={unknown:T,on_track:A,at_risk:P,off_track:F},t[36]=T,t[37]=A,t[38]=P,t[39]=F,t[40]=I):I=t[40];let oe=I;U=`space-y-5`;let B;t[41]===i.name?B=t[42]:(B=(0,j.jsx)(`h2`,{className:`min-w-0 break-words text-xl font-semibold text-fg`,children:i.name}),t[41]=i.name,t[42]=B);let V=S.statuses[i.status],X;t[43]===V?X=t[44]:(X=(0,j.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-inset px-2 py-1 text-xs text-fg-muted`,children:V}),t[43]=V,t[44]=X);let Z;t[45]!==B||t[46]!==X?(Z=(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[B,X]}),t[45]=B,t[46]=X,t[47]=Z):Z=t[47];let Q;t[48]!==w||t[49]!==b?(Q=w?(0,j.jsx)(`div`,{className:`line-clamp-3 text-sm text-fg-muted`,children:(0,j.jsx)(f,{content:w,mermaidActions:!1})}):(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:b?`尚未填写项目目标。`:`No project goal recorded yet.`}),t[48]=w,t[49]=b,t[50]=Q):Q=t[50];let se=oe[i.health],ce=C?` · ${b?`最近活动`:`Last activity`} ${C}`:``,$;t[51]!==se||t[52]!==ce?($=(0,j.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[se,ce]}),t[51]=se,t[52]=ce,t[53]=$):$=t[53],t[54]!==Z||t[55]!==Q||t[56]!==$?(W=(0,j.jsxs)(`div`,{className:`space-y-2`,children:[Z,Q,$]}),t[54]=Z,t[55]=Q,t[56]=$,t[57]=W):W=t[57];let le=b?`当前概况`:`Overview`,ue=b?`当前概况`:`Overview`,de;t[58]===ue?de=t[59]:(de=(0,j.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:ue}),t[58]=ue,t[59]=de);let fe=M?(0,j.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-3`,children:[(0,j.jsx)(p,{className:`h-4 w-3/4`}),(0,j.jsx)(p,{className:`h-14 w-full`})]}):D||!E?(0,j.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-2 text-sm text-fg-muted`,children:[(0,j.jsx)(`span`,{children:b?`任务概况暂时无法读取。`:`Task overview is temporarily unavailable.`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>void N(),className:L,children:b?`重试`:`Retry`})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.length===0?b?`尚未关联任务,可在项目中添加下一步工作。`:`No tasks linked yet. Add the next piece of work in the project.`:b?`${n.moving} 项任务正在推进,${n.needsUser} 项等你处理,${n.waiting} 项等待中。`:`${n.moving} in progress, ${n.needsUser} need your input, ${n.waiting} waiting.`}),E.digest.recommendedAction&&(0,j.jsxs)(`p`,{className:`break-words text-sm leading-6 text-fg-muted`,children:[b?`建议下一步:`:`Suggested next step: `,E.digest.recommendedAction]}),(0,j.jsx)(`dl`,{className:`grid grid-cols-3 gap-3 border-t border-edge pt-3 sm:grid-cols-5`,children:Object.keys(a).map(e=>(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`dt`,{className:`text-xs text-fg-muted`,children:a[e]}),(0,j.jsx)(`dd`,{className:`mt-1 text-xl font-semibold tabular-nums text-fg`,children:n[e]})]},e))})]});t[60]!==le||t[61]!==de||t[62]!==fe?(G=(0,j.jsxs)(`section`,{"aria-label":le,className:`space-y-3 rounded-xl border border-edge bg-surface-inset/50 p-4`,children:[de,fe]}),t[60]=le,t[61]=de,t[62]=fe,t[63]=G):G=t[63],K=E&&(0,j.jsxs)(`div`,{className:`grid gap-6 sm:grid-cols-2`,children:[(0,j.jsxs)(`section`,{className:`min-w-0 space-y-3`,children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:b?`优先关注`:`Needs attention`}),c.length?(0,j.jsx)(`ul`,{className:`divide-y divide-edge`,children:c.map(e=>(0,j.jsx)(`li`,{className:`py-3 first:pt-0`,children:(0,j.jsxs)(r,{to:H(e.taskId),className:`block rounded-lg focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,j.jsx)(`p`,{className:`break-words text-sm font-medium text-fg`,children:e.title}),(0,j.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-sm leading-6 text-fg-muted`,children:e.detail}),(0,j.jsx)(`span`,{className:`mt-2 inline-block ${L}`,children:b?`查看关联任务 →`:`View task →`})]})},e.taskId))}):(0,j.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:b?`暂无已记录的阻塞或待处理提醒。`:`No recorded blockers or attention items.`})]}),(0,j.jsxs)(`section`,{className:`min-w-0 space-y-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:b?`当前任务`:`Current tasks`}),(0,j.jsx)(r,{to:z(`tasks`),className:L,children:b?`查看全部`:`View all`})]}),u.length?(0,j.jsx)(`ul`,{className:`divide-y divide-edge`,children:u.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsxs)(r,{to:H(e.id),className:`block rounded-lg py-3 hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,j.jsx)(`p`,{className:`break-words text-sm font-medium text-fg`,children:e.title}),(0,j.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[S.board.phases[e.phase],e.operationalState===`idle`?``:` · ${S.board.operationalStates[e.operationalState]}`]})]})},e.id))}):(0,j.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:b?`暂无可推进的任务,等待中的任务可在全部任务中查看。`:`No actionable tasks. View all tasks to see any waiting work.`})]})]}),q=`space-y-3 border-t border-edge pt-5`;let pe=b?`最近进展`:`Recent progress`,me;t[64]===pe?me=t[65]:(me=(0,j.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:pe}),t[64]=pe,t[65]=me);let he;t[66]===z?he=t[67]:(he=z(`progress`),t[66]=z,t[67]=he);let ge=b?`查看记录`:`View history`,_e;t[68]!==he||t[69]!==ge?(_e=(0,j.jsx)(r,{to:he,className:L,children:ge}),t[68]=he,t[69]=ge,t[70]=_e):_e=t[70],t[71]!==me||t[72]!==_e?(J=(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[me,_e]}),t[71]=me,t[72]=_e,t[73]=J):J=t[73],Y=h.length?(0,j.jsx)(`ul`,{className:`divide-y divide-edge-subtle`,children:h.map(e=>(0,j.jsxs)(`li`,{className:`space-y-2 py-3 first:pt-0`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,j.jsxs)(`p`,{className:`min-w-0 break-words text-xs text-fg-muted`,children:[e.title,_(e.at)?` · ${_(e.at)}`:``]}),(0,j.jsx)(r,{to:e.href,className:L,children:b?`查看来源`:`View source`})]}),(0,j.jsx)(`div`,{className:`line-clamp-3 break-words text-sm text-fg`,children:(0,j.jsx)(f,{content:e.summary,mermaidActions:!1})})]},e.id))}):(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:b?`暂无项目进展或执行结果。`:`No project updates or execution results yet.`}),t[14]=D,t[15]=M,t[16]=l,t[17]=N,t[18]=S,t[19]=i,t[20]=z,t[21]=H,t[22]=E,t[23]=b,t[24]=U,t[25]=W,t[26]=G,t[27]=K,t[28]=q,t[29]=J,t[30]=Y}else U=t[24],W=t[25],G=t[26],K=t[27],q=t[28],J=t[29],Y=t[30];let X;t[74]!==q||t[75]!==J||t[76]!==Y?(X=(0,j.jsxs)(`section`,{className:q,children:[J,Y]}),t[74]=q,t[75]=J,t[76]=Y,t[77]=X):X=t[77];let Z;return t[78]!==U||t[79]!==W||t[80]!==G||t[81]!==K||t[82]!==X?(Z=(0,j.jsxs)(`div`,{className:U,children:[W,G,K,X]}),t[78]=U,t[79]=W,t[80]=G,t[81]=K,t[82]=X,t[83]=Z):Z=t[83],Z}function ee(e,t){return(t.at||0)-(e.at||0)}function te(e){return e.summary?.trim()}function ne(e,t){return Number([`queued`,`running`,`verifying`].includes(t.operationalState))-Number([`queued`,`running`,`verifying`].includes(e.operationalState))}function re(e,t){return Number([`input_required`,`approval_required`].includes(t.kind))-Number([`input_required`,`approval_required`].includes(e.kind))}function ie(e){return e.id}function ae(e){return e.phase!==`closed`}function oe(e){return e.conversationId}function B(e){return e.language}async function V(e){switch(e.kind){case`project`:return{kind:e.kind,value:await h(e.id)};case`automation`:{let[t,n]=await Promise.all([b.list(),b.runs(5,e.id)]);return{kind:e.kind,value:t.automations.find(t=>t.id===e.id),runs:n.runs}}case`local_app`:{let t=await C(e.id),n=e.sourceHash?await S(e.id,e.sourceHash):void 0;return{kind:e.kind,value:t,previewUrl:n?.previewUrl||t.draftPreviewUrl}}}}var H={pending:[`等待中`,`Pending`],planned:[`计划中`,`Planned`],active:[`进行中`,`Active`],paused:[`已暂停`,`Paused`],completed:[`已完成`,`Completed`],cancelled:[`已取消`,`Cancelled`],archived:[`已归档`,`Archived`],queued:[`排队中`,`Queued`],running:[`运行中`,`Running`],succeeded:[`成功`,`Succeeded`],failed:[`失败`,`Failed`],timeout:[`超时`,`Timed out`],cancelling:[`取消中`,`Cancelling`],unknown:[`尚未评估`,`Not assessed`],on_track:[`进展正常`,`On track`],at_risk:[`存在风险`,`At risk`],off_track:[`偏离计划`,`Off track`]};function U(e){let t=(0,A.c)(5),{target:n}=e;if(n.kind===`automation`&&n.view===`run`){let e;return t[0]!==n.id||t[1]!==n.runId?(e=(0,j.jsx)(N,{automationId:n.id,runId:n.runId}),t[0]=n.id,t[1]=n.runId,t[2]=e):e=t[2],e}let r;return t[3]===n?r=t[4]:(r=(0,j.jsx)(W,{target:n}),t[3]=n,t[4]=r),r}function W(e){let t=(0,A.c)(56),{target:n}=e,u=a(J),d=o(q),f=d===`zh`,p=s(d),m;t[0]===f?m=t[1]:(m=e=>H[e]?.[+!f]||e,t[0]=f,t[1]=m);let h=m,g;t[2]!==n.href||t[3]!==u?(g=[`chat-product-preview`,n.href,u],t[2]=n.href,t[3]=u,t[4]=g):g=t[4];let v;t[5]===n?v=t[6]:(v=()=>V(n),t[5]=n,t[6]=v);let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y={shouldRetryOnError:!1,refreshInterval:K},t[7]=y):y=t[7];let{data:b,error:x,isLoading:S}=_(g,v,y);if(S){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,j.jsx)(w,{}),t[8]=e):e=t[8],e}if(x){let e=f?`无法加载内容,它可能已删除或暂时不可用。`:`Unable to load this content. It may have been deleted or be temporarily unavailable.`,n;return t[9]===e?n=t[10]:(n=(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:e}),t[9]=e,t[10]=n),n}if(!b?.value){let e=f?`内容不存在或已删除。`:`This content is unavailable or has been deleted.`,n;return t[11]===e?n=t[12]:(n=(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n),n}let C=G;if(b.kind===`project`){let e;return t[13]!==b.value||t[14]!==n?(e=(0,j.jsx)(z,{project:b.value,target:n}),t[13]=b.value,t[14]=n,t[15]=e):e=t[15],e}if(b.kind===`automation`){let e=b.value,n=e.action.kind===`agent`?e.action.instruction:void 0,r;t[16]===e.name?r=t[17]:(r=(0,j.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:e.name}),t[16]=e.name,t[17]=r);let i;t[18]!==e.description||t[19]!==C?(i=C(e.description),t[18]=e.description,t[19]=C,t[20]=i):i=t[20];let a;t[21]!==n||t[22]!==C?(a=C(n),t[21]=n,t[22]=C,t[23]=a):a=t[23];let o;t[24]!==e.state.nextRunAtMs||t[25]!==f?(o=e.state.nextRunAtMs&&(0,j.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[f?`下次运行`:`Next run`,` · `,new Date(e.state.nextRunAtMs).toLocaleString(f?`zh-CN`:`en-US`)]}),t[24]=e.state.nextRunAtMs,t[25]=f,t[26]=o):o=t[26];let s;t[27]===e.state.lastError?s=t[28]:(s=e.state.lastError&&(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e.state.lastError}),t[27]=e.state.lastError,t[28]=s);let u=f?`最近运行`:`Recent runs`,m;t[29]===u?m=t[30]:(m=(0,j.jsx)(`h3`,{className:`font-medium text-fg`,children:u}),t[29]=u,t[30]=m);let g;t[31]!==b.runs||t[32]!==C||t[33]!==h||t[34]!==f?(g=b.runs.length?b.runs.map(e=>(0,j.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,j.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[h(e.status),` · `,new Date(e.createdAtMs).toLocaleString(f?`zh-CN`:`en-US`)]}),C(e.summary),e.error&&(0,j.jsx)(`p`,{className:`text-sm text-danger`,children:e.error})]},e.id)):(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f?`暂无运行记录。`:`No runs yet.`}),t[31]=b.runs,t[32]=C,t[33]=h,t[34]=f,t[35]=g):g=t[35];let _;return t[36]!==m||t[37]!==g?(_=(0,j.jsxs)(`section`,{className:`space-y-3`,children:[m,g]}),t[36]=m,t[37]=g,t[38]=_):_=t[38],(0,j.jsxs)(`div`,{className:`space-y-6`,children:[(0,j.jsxs)(`div`,{className:`space-y-3`,children:[r,(0,j.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[l(e)?f?`已完成`:`Completed`:e.enabled?f?`已启用`:`Enabled`:f?`已暂停`:`Paused`,` · `,c(e.trigger,p.automations,p.cron,d)]}),i,a,o,s]}),_]})}let E=b.value,D;t[39]===E.name?D=t[40]:(D=(0,j.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:E.name}),t[39]=E.name,t[40]=D);let O=E.description||E.idea,k;t[41]!==C||t[42]!==O?(k=C(O),t[41]=C,t[42]=O,t[43]=k):k=t[43];let M;t[44]!==E.name||t[45]!==b.previewUrl||t[46]!==f?(M=b.previewUrl&&(0,j.jsx)(`iframe`,{title:f?`${E.name} 交互预览`:`${E.name} interactive preview`,src:i(b.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-[min(30rem,55dvh)] w-full rounded-lg border border-edge bg-white`}),t[44]=E.name,t[45]=b.previewUrl,t[46]=f,t[47]=M):M=t[47];let N;t[48]!==E||t[49]!==f?(N=E.installationState===`installed`&&E.enabled&&E.status===`installed`&&(0,j.jsx)(r,{to:T(E),className:`inline-flex rounded-lg bg-accent px-3 py-2 text-sm text-white focus-visible:ring-2 focus-visible:ring-accent`,children:f?`使用应用`:`Use app`}),t[48]=E,t[49]=f,t[50]=N):N=t[50];let P;return t[51]!==D||t[52]!==k||t[53]!==M||t[54]!==N?(P=(0,j.jsxs)(`div`,{className:`space-y-5`,children:[D,k,M,N]}),t[51]=D,t[52]=k,t[53]=M,t[54]=N,t[55]=P):P=t[55],P}function G(e){return e?.trim()?(0,j.jsx)(f,{content:e,mermaidActions:!1}):null}function K(e){return e?.kind===`automation`&&e.value?.state.runningRunId?3e3:0}function q(e){return e.language}function J(e){return e.conversationId}export{U as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/product-preview-content-B3mzl6-f.js","assets/vendor-react-BOUWij0V.js","assets/rolldown-runtime-aKtaBQYM.js","assets/chunk-KS7C4IRE-DIIvxCDx.js","assets/preload-helper-Czpn1I53.js","assets/locale-store-CHjsq5NR.js","assets/messages-C7QSnTdg.js","assets/automation-display-DaVDNZz8.js","assets/createLucideIcon-DPHK1VkS.js","assets/markdown-view-ihzUc4ud.js","assets/marked.esm-8VXEA2AD.js","assets/dist-DlirbHVs.js","assets/es2015-CFqg57eW.js","assets/dist-CDSvxjOh.js","assets/download-Dk-ZjtO6.js","assets/file-image-CDUPkZvG.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/app-link-Ji4uewEG.js","assets/product-delivery-4gEqUIsK.js","assets/schemas-CCWMleym.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/xml-_d7dTN2Q.js","assets/mermaid-render-oOellPHt.js","assets/markdown-view-Czi3_WHu.css","assets/skeleton-DzdOeGYz.js","assets/tasks-CvOAtEHv.js","assets/turn-outcome-Dtw6OgwL.js","assets/specialists-xbB3xL9e.js","assets/api-CGrHK9ij.js","assets/files-GdwDamkp.js","assets/vendor-swr-CdRzEUwF.js","assets/button-C5tRaJxt.js","assets/task-copy-CtcqCQ78.js","assets/automation-api-D-gn6x5E.js","assets/automation-task-card-C453Q-Wa.js","assets/chevron-down-ccbiQQz_.js","assets/chevron-right-BweFrslA.js","assets/popover-select-hRG1EzAY.js","assets/check-DUBLcKHA.js","assets/dist-BSVQC3i_.js","assets/dist-DSRLZhL9.js","assets/floating-ui.dom-CiMnRY5O.js","assets/floating-ui.react-dom-Gx6CM22l.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/message-circle-Badhj-4D.js","assets/pencil-DmIY3Oa-.js","assets/chat-agents-api-CyvBfBbp.js","assets/gateway-config-swr-BD-ams0X.js","assets/agent-avatar-display-D_UDgOr9.js","assets/loopi-CNtmi9FU.js","assets/loopi-C09I2mNj.css","assets/agent-display-names-Bje7vfSn.js","assets/model-selector-QFZY5XNN.js","assets/settings-2-D-csvaET.js","assets/registry-api-CDpUAb2R.js","assets/gateway-startup-retry-DgmvR-hb.js","assets/open-capability-settings-DQsmJxI7.js","assets/interaction-BdhHBbYa.js","assets/form-field-width-DJw_jULe.js","assets/model-sort-_Tz8s_4N.js","assets/date-picker-DwITf4I2.js","assets/calendar-days-hw_Y-g-s.js","assets/chevron-left-DqFhpbvK.js","assets/time-picker-otHjbob1.js","assets/clock-3-DnrAnuyZ.js","assets/api-B3T06TLl.js","assets/open-route-MyZ2sB9C.js","assets/automation-result-state-B7hq0XOL.js","assets/project-overview-model-DrLXaO-t.js","assets/task-result-presentation-CgvcqEMD.js","assets/agent-run-error-parser-DsXmcKt-.js","assets/capability-presentation-DlJQUUlM.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{t as a}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{n as o}from"./locale-store-CHjsq5NR.js";import{a as s,i as c,n as l,o as u,r as d,s as f,t as p}from"./dist-DlirbHVs.js";import{t as m}from"./external-link-DjqjBmc3.js";import{V as h}from"./markdown-view-ihzUc4ud.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./skeleton-DzdOeGYz.js";import{i as v}from"./vendor-swr-CdRzEUwF.js";import{t as y}from"./button-C5tRaJxt.js";import{t as b}from"./automation-api-D-gn6x5E.js";import{r as x}from"./automation-task-card-C453Q-Wa.js";var S=n(),C=e(t(),1),w=r(),T=(0,C.lazy)(()=>i(()=>import(`./product-preview-content-B3mzl6-f.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74]))),E={project:[`项目预览`,`Project preview`],automation:[`自动化详情`,`Automation details`],local_app:[`应用预览`,`App preview`]};function D(){let e=(0,S.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,w.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,w.jsx)(_,{className:`h-7 w-2/3`}),(0,w.jsx)(_,{className:`h-4 w-full`}),(0,w.jsx)(_,{className:`h-4 w-4/5`}),(0,w.jsx)(_,{className:`h-32 w-full`})]}),e[0]=t):t=e[0],t}function O(e){let t=(0,S.c)(8),{target:n,backgroundPath:r,onClose:i}=e;if(n.kind===`automation`&&n.view!==`run`){let e;return t[0]!==r||t[1]!==i||t[2]!==n?(e=(0,w.jsx)(k,{target:n,backgroundPath:r,onClose:i}),t[0]=r,t[1]=i,t[2]=n,t[3]=e):e=t[3],e}let a;return t[4]!==r||t[5]!==i||t[6]!==n?(a=(0,w.jsx)(j,{target:n,backgroundPath:r,onClose:i}),t[4]=r,t[5]=i,t[6]=n,t[7]=a):a=t[7],a}function k(e){let t=(0,S.c)(34),{target:n,backgroundPath:r,onClose:i}=e,a=o(A),l,m;t[0]===n.id?(l=t[1],m=t[2]):(l=[`automation-card`,n.id],m=()=>b.get(n.id),t[0]=n.id,t[1]=l,t[2]=m);let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1,shouldRetryOnError:!1},t[3]=h):h=t[3];let{data:g,error:_,mutate:C}=v(l,m,h);if(g?.automation){if(g.automation.action.kind===`agent`&&!g.automation.management){let e;return t[4]!==g.automation||t[5]!==a||t[6]!==i?(e=(0,w.jsx)(x,{automation:g.automation,language:a,onClose:i}),t[4]=g.automation,t[5]=a,t[6]=i,t[7]=e):e=t[7],e}let e;return t[8]!==r||t[9]!==i||t[10]!==n?(e=(0,w.jsx)(j,{target:n,backgroundPath:r,onClose:i}),t[8]=r,t[9]=i,t[10]=n,t[11]=e):e=t[11],e}let T=a===`zh`,E;t[12]===i?E=t[13]:(E=e=>{e||i()},t[12]=i,t[13]=E);let O;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,w.jsx)(s,{className:`fixed inset-0 z-65 bg-scrim`}),t[14]=O):O=t[14];let k=T?`定时任务详情`:`Scheduled task details`,M;t[15]===k?M=t[16]:(M=(0,w.jsx)(f,{className:`mb-5 font-medium`,children:k}),t[15]=k,t[16]=M);let N=T?`查看和编辑定时任务。`:`View and edit the scheduled task.`,P;t[17]===N?P=t[18]:(P=(0,w.jsx)(c,{className:`sr-only`,children:N}),t[17]=N,t[18]=P);let F;t[19]!==_||t[20]!==C||t[21]!==T?(F=_?(0,w.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[(0,w.jsx)(`p`,{children:T?`任务已不存在或暂时无法读取。`:`This task is unavailable.`}),(0,w.jsx)(y,{variant:`secondary`,onClick:()=>void C(),children:T?`重试`:`Retry`})]}):(0,w.jsx)(D,{}),t[19]=_,t[20]=C,t[21]=T,t[22]=F):F=t[22];let I=T?`关闭`:`Close`,L;t[23]!==i||t[24]!==I?(L=(0,w.jsx)(y,{className:`mt-auto self-end`,variant:`ghost`,onClick:i,children:I}),t[23]=i,t[24]=I,t[25]=L):L=t[25];let R;t[26]!==F||t[27]!==L||t[28]!==M||t[29]!==P?(R=(0,w.jsxs)(u,{children:[O,(0,w.jsxs)(d,{className:`fixed left-1/2 top-1/2 z-70 flex h-[min(600px,calc(100dvh-2rem))] w-[min(680px,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay p-5`,children:[M,P,F,L]})]}),t[26]=F,t[27]=L,t[28]=M,t[29]=P,t[30]=R):R=t[30];let z;return t[31]!==R||t[32]!==E?(z=(0,w.jsx)(p,{open:!0,onOpenChange:E,children:R}),t[31]=R,t[32]=E,t[33]=z):z=t[33],z}function A(e){return e.language}function j(e){let t=(0,S.c)(34),{target:n,backgroundPath:r,onClose:i}=e,_=o(M)===`zh`,v=n.kind===`project`?`w-[min(55rem,calc(100vw-2rem))]`:`w-[min(52rem,calc(100vw-2rem))]`,y=n.kind===`automation`&&n.view===`run`?_?`运行情况`:`Run progress`:E[n.kind][+!_],b;t[0]===i?b=t[1]:(b=e=>{e||i()},t[0]=i,t[1]=b);let x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,w.jsx)(s,{className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`}),t[2]=x):x=t[2];let O=`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(48rem,calc(100dvh-2rem))] ${v} -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,k;t[3]===y?k=t[4]:(k=(0,w.jsx)(f,{className:`min-w-0 flex-1 truncate font-medium text-fg`,children:y}),t[3]=y,t[4]=k);let A=_?`查看关联内容,或打开独立页面。`:`Preview related content or open its full page.`,j;t[5]===A?j=t[6]:(j=(0,w.jsx)(c,{className:`sr-only`,children:A}),t[5]=A,t[6]=j);let N;t[7]!==r||t[8]!==n.href||t[9]!==n.view||t[10]!==_?(N=n.view!==`run`&&(0,w.jsxs)(a,{to:h(n.href,r),className:`flex shrink-0 items-center gap-1.5 rounded-lg px-2 py-1.5 text-sm text-accent hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,w.jsx)(m,{className:`size-4`,"aria-hidden":!0}),_?`打开独立页面`:`Open full page`]}),t[7]=r,t[8]=n.href,t[9]=n.view,t[10]=_,t[11]=N):N=t[11];let P=_?`关闭预览`:`Close preview`,F=_?`关闭预览`:`Close preview`,I;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,w.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[12]=I):I=t[12];let L;t[13]!==P||t[14]!==F?(L=(0,w.jsx)(l,{title:P,"aria-label":F,className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:I}),t[13]=P,t[14]=F,t[15]=L):L=t[15];let R;t[16]!==L||t[17]!==k||t[18]!==j||t[19]!==N?(R=(0,w.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-edge bg-surface-panel px-5 py-3.5`,children:[k,j,N,L]}),t[16]=L,t[17]=k,t[18]=j,t[19]=N,t[20]=R):R=t[20];let z=`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5 ${n.kind===`project`?`sm:p-6`:`sm:p-8`}`,B;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,w.jsx)(D,{}),t[21]=B):B=t[21];let V;t[22]===n?V=t[23]:(V=(0,w.jsx)(C.Suspense,{fallback:B,children:(0,w.jsx)(T,{target:n},n.href)}),t[22]=n,t[23]=V);let H;t[24]!==z||t[25]!==V?(H=(0,w.jsx)(`div`,{className:z,children:V}),t[24]=z,t[25]=V,t[26]=H):H=t[26];let U;t[27]!==R||t[28]!==H||t[29]!==O?(U=(0,w.jsxs)(u,{children:[x,(0,w.jsxs)(d,{className:O,children:[R,H]})]}),t[27]=R,t[28]=H,t[29]=O,t[30]=U):U=t[30];let W;return t[31]!==b||t[32]!==U?(W=(0,w.jsx)(p,{open:!0,onOpenChange:b,children:U}),t[31]=b,t[32]=U,t[33]=W):W=t[33],W}function M(e){return e.language}export{D as n,O as t};