@xopcai/xopc 0.0.455 → 0.0.457

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 (309) hide show
  1. package/dist/browser-ext/dist/sidepanel.js +5 -1
  2. package/dist/browser-ext/manifest.json +1 -1
  3. package/dist/extensions/telegram/xopc.extension.json +1 -1
  4. package/dist/gateway/static/root/assets/{activity-store-DYwR1u3f.js → activity-store-CQHh48Zf.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CsRBprL-.js → agent-avatar-dicebear-CAz-Ke6Q.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agent-avatar-display-DqFYHXCS.js → agent-avatar-display-loBdGw_i.js} +2 -2
  7. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-DOAJrMLe.js → agent-defaults-settings-panel-By2Q-6JS.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agent-plugin-dialog-vqlN3ORH.js → agent-plugin-dialog-CikzCYAG.js} +1 -1
  9. package/dist/gateway/static/root/assets/{agents-BgHlOVRV.js → agents-CGUdvmIT.js} +3 -3
  10. package/dist/gateway/static/root/assets/{agents-admin-api-CKscfdvA.js → agents-admin-api-D0N09mqJ.js} +1 -1
  11. package/dist/gateway/static/root/assets/{api-CHM2c_Ah.js → api-B1J5ajiP.js} +1 -1
  12. package/dist/gateway/static/root/assets/{api-DPNeNCmR.js → api-B4FJ51EC.js} +1 -1
  13. package/dist/gateway/static/root/assets/{app-management-settings-panel-Bhz6bj1C.js → app-management-settings-panel-BHlUDZOG.js} +1 -1
  14. package/dist/gateway/static/root/assets/{appearance-settings-BX32aogA.js → appearance-settings-Du5JLyV1.js} +1 -1
  15. package/dist/gateway/static/root/assets/{apps-page-0Yo3jBsQ.js → apps-page-M2XD1Pzu.js} +1 -1
  16. package/dist/gateway/static/root/assets/{archive-plugin-Bha8obMe.js → archive-plugin-BAvglLfu.js} +1 -1
  17. package/dist/gateway/static/root/assets/{automation-api-mn8ihWJ_.js → automation-api-DxBmyzp0.js} +1 -1
  18. package/dist/gateway/static/root/assets/{automation-result-state-COzakzak.js → automation-result-state-CAsqgMNR.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automation-run-list-BhtaMpTb.js → automation-run-list-BmYeWB_N.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automation-task-card-BY_k6iWp.js → automation-task-card-BjqxvYqc.js} +1 -1
  21. package/dist/gateway/static/root/assets/{automations-page-Dt_Z1UTT.js → automations-page-BSnPWyYd.js} +1 -1
  22. package/dist/gateway/static/root/assets/automations-workspace-DIaCdxtX.js +9 -0
  23. package/dist/gateway/static/root/assets/{binary-plugins-DUbrJFLU.js → binary-plugins-D2bFqG6K.js} +1 -1
  24. package/dist/gateway/static/root/assets/{block-editor-DW--pXAc.js → block-editor-CmnkluMF.js} +1 -1
  25. package/dist/gateway/static/root/assets/{browser-settings-page-CDh6nxs9.js → browser-settings-page-CGcgZOWh.js} +1 -1
  26. package/dist/gateway/static/root/assets/capabilities-DB713nRi.js +1 -0
  27. package/dist/gateway/static/root/assets/{capabilities-DKbXv8Ck.js → capabilities-DDqDvCBs.js} +1 -1
  28. package/dist/gateway/static/root/assets/{capabilities-page-D1wQ2sPI.js → capabilities-page-dXDa0i5o.js} +2 -2
  29. package/dist/gateway/static/root/assets/{capabilities-settings-panel-BW5jQz5R.js → capabilities-settings-panel-CvF8VRTv.js} +1 -1
  30. package/dist/gateway/static/root/assets/{channels-BzZp42yO.js → channels-BDVQ6Z7A.js} +1 -1
  31. package/dist/gateway/static/root/assets/{chat-agents-api-UOdNWZ0_.js → chat-agents-api-CjlzCSmC.js} +1 -1
  32. package/dist/gateway/static/root/assets/{chat-chart-block-NSy-B0NS.js → chat-chart-block-stPJEZ90.js} +1 -1
  33. package/dist/gateway/static/root/assets/chat-page-Bx_A__qB.js +71 -0
  34. package/dist/gateway/static/root/assets/{chat-terminal-dock-CAaHWS7F.js → chat-terminal-dock-B4uA_W6R.js} +1 -1
  35. package/dist/gateway/static/root/assets/{command-palette-api-Dkn9bbYd.js → command-palette-api-CP0F6sIm.js} +1 -1
  36. package/dist/gateway/static/root/assets/{composer-model-config-control-BrK8-SNz.js → composer-model-config-control-DAagrRx_.js} +1 -1
  37. package/dist/gateway/static/root/assets/{composer-notifications-B-kL3qAA.js → composer-notifications-CqV6Xj-H.js} +1 -1
  38. package/dist/gateway/static/root/assets/composer-payload-handoff-Dc43dgSg.js +1 -0
  39. package/dist/gateway/static/root/assets/{computer-settings-page-C9KdEecx.js → computer-settings-page-f-vcEpeF.js} +1 -1
  40. package/dist/gateway/static/root/assets/{connected-providers-grid-D_8v6Qex.js → connected-providers-grid-CZ-FXxaW.js} +1 -1
  41. package/dist/gateway/static/root/assets/{connection-usage-guide-CiVpcbds.js → connection-usage-guide-Cibh2lrV.js} +1 -1
  42. package/dist/gateway/static/root/assets/{connector-service-page-B919cKSm.js → connector-service-page-Btz68iy8.js} +1 -1
  43. package/dist/gateway/static/root/assets/{connectors-api-CgsSm-Av.js → connectors-api-CTuVWwBf.js} +1 -1
  44. package/dist/gateway/static/root/assets/{connectors-page-CEpfDCLA.js → connectors-page-BwJHhyRb.js} +1 -1
  45. package/dist/gateway/static/root/assets/{date-picker-dx284jQI.js → date-picker-XnE3iFhG.js} +1 -1
  46. package/dist/gateway/static/root/assets/{date-time-picker-Dj-bhLNP.js → date-time-picker-VGKm0HVn.js} +1 -1
  47. package/dist/gateway/static/root/assets/{desktop-pet-DlTuGzZ2.js → desktop-pet-CBm3DySQ.js} +1 -1
  48. package/dist/gateway/static/root/assets/{desktop-pet-narrative-cBFIPXzR.js → desktop-pet-narrative-JqMsz4rn.js} +1 -1
  49. package/dist/gateway/static/root/assets/{desktop-pet-settings-CsmrvoxU.js → desktop-pet-settings-6O77QXGo.js} +1 -1
  50. package/dist/gateway/static/root/assets/{dev-view-store-BOxbj1ie.js → dev-view-store-B8fGILny.js} +1 -1
  51. package/dist/gateway/static/root/assets/{device-pairing-wizard-CAqFIFRC.js → device-pairing-wizard-qtUvtdDT.js} +1 -1
  52. package/dist/gateway/static/root/assets/{directory-picker-path-field-BxEw5OrT.js → directory-picker-path-field-ByDqf5fE.js} +1 -1
  53. package/dist/gateway/static/root/assets/{discussion-annotation-sync-CyntTwIa.js → discussion-annotation-sync-fwPPMPv9.js} +1 -1
  54. package/dist/gateway/static/root/assets/{extension-authoritative-grants-C0ReZguU.js → extension-authoritative-grants-BfL8dMBf.js} +1 -1
  55. package/dist/gateway/static/root/assets/{extension-debug-page-Cd3HMUbi.js → extension-debug-page-BPwRrP3L.js} +1 -1
  56. package/dist/gateway/static/root/assets/{extension-iframe-host-DiIqM2JO.js → extension-iframe-host-DIH4TcdH.js} +1 -1
  57. package/dist/gateway/static/root/assets/{extension-marketplace-api-CK5CMKTs.js → extension-marketplace-api-BIzkukYp.js} +1 -1
  58. package/dist/gateway/static/root/assets/{extension-message-router-Dn8JzOdR.js → extension-message-router-C9JDpo_7.js} +1 -1
  59. package/dist/gateway/static/root/assets/{extension-page-CLZtAtqm.js → extension-page-CLDoL5N8.js} +1 -1
  60. package/dist/gateway/static/root/assets/{extension-provider-CbVokTvd.js → extension-provider-BPIoHw4r.js} +1 -1
  61. package/dist/gateway/static/root/assets/{extension-settings-page-BM79cwUy.js → extension-settings-page-BO_UKeG8.js} +1 -1
  62. package/dist/gateway/static/root/assets/file-preview-surface-i5UOFnQF.js +1 -0
  63. package/dist/gateway/static/root/assets/{gateway-config-swr-OGhON-s6.js → gateway-config-swr-1Rk0LeEM.js} +1 -1
  64. package/dist/gateway/static/root/assets/{gateway-realtime-B9u4uSXW.js → gateway-realtime-DIs1pjkQ.js} +1 -1
  65. package/dist/gateway/static/root/assets/gateway-realtime-store-sx7B8kdC.js +1 -0
  66. package/dist/gateway/static/root/assets/{gateway-restart-DKAweWmg.js → gateway-restart-DTmlcJps.js} +1 -1
  67. package/dist/gateway/static/root/assets/{gateway-settings-Dc7qUbG-.js → gateway-settings-ClcCloqQ.js} +1 -1
  68. package/dist/gateway/static/root/assets/{gateway-startup-retry-BaaoKBoB.js → gateway-startup-retry-D6WPS0RW.js} +1 -1
  69. package/dist/gateway/static/root/assets/{global-defaults-api-BIr3ApRj.js → global-defaults-api-BpDMnJe7.js} +1 -1
  70. package/dist/gateway/static/root/assets/home-page-D1sTZYAY.js +3 -0
  71. package/dist/gateway/static/root/assets/{image-generation-api-C7D2IetZ.js → image-generation-api-sbtx4NiC.js} +1 -1
  72. package/dist/gateway/static/root/assets/{imports-page-BjEdZJxZ.js → imports-page-CBlaxUhl.js} +1 -1
  73. package/dist/gateway/static/root/assets/index-CHAVhyVb.js +11 -0
  74. package/dist/gateway/static/root/assets/index-CQABygtM.css +1 -0
  75. package/dist/gateway/static/root/assets/{install-connector-dialog-BsiyYQhx.js → install-connector-dialog-DxSv1wS2.js} +1 -1
  76. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CIthQ1lp.js → keyboard-shortcuts-settings-CnAV96nr.js} +1 -1
  77. package/dist/gateway/static/root/assets/{local-app-workbench-page-CSCIHvZV.js → local-app-workbench-page-D8oqDDAn.js} +1 -1
  78. package/dist/gateway/static/root/assets/{local-apps-page-EntiM0tz.js → local-apps-page-BI3Be5qo.js} +1 -1
  79. package/dist/gateway/static/root/assets/{local-session-drafts-XurtjR58.js → local-session-drafts-BIBHRkpM.js} +2 -2
  80. package/dist/gateway/static/root/assets/{locale-store-cg9cm2EL.js → locale-store-Dy1EByeG.js} +1 -1
  81. package/dist/gateway/static/root/assets/{logs-page-rmS9VSem.js → logs-page-CMW34T31.js} +1 -1
  82. package/dist/gateway/static/root/assets/{management-api-B6jVuJ6W.js → management-api-B5w5DdXH.js} +1 -1
  83. package/dist/gateway/static/root/assets/{management-settings-DdI9gs51.js → management-settings-DfcMIqbQ.js} +1 -1
  84. package/dist/gateway/static/root/assets/{markdown-view-D1zBWkfB.js → markdown-view-BlxIaCCQ.js} +1 -1
  85. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-Bn49Ph1n.js → mcp-conversation-setup-page-CsTSmjmX.js} +1 -1
  86. package/dist/gateway/static/root/assets/{media-plugins-Cd6hAGDp.js → media-plugins-DGhWjPIU.js} +1 -1
  87. package/dist/gateway/static/root/assets/messages-BAnhwALN.js +3 -0
  88. package/dist/gateway/static/root/assets/{model-selector-CL6WT-jw.js → model-selector-C-CqPBao.js} +1 -1
  89. package/dist/gateway/static/root/assets/{models-hub-cache-s0FMNhq9.js → models-hub-cache-Bgh3Gfgl.js} +1 -1
  90. package/dist/gateway/static/root/assets/{note-detail-panel-anM38aV6.js → note-detail-panel-B1cq9sU2.js} +3 -3
  91. package/dist/gateway/static/root/assets/note-image-lightbox-CqK_uJ6Y.js +1 -0
  92. package/dist/gateway/static/root/assets/{notes-api-CR75RHd0.js → notes-api-CdXA-g9r.js} +1 -1
  93. package/dist/gateway/static/root/assets/{notes-page-BsZmT7Zw.js → notes-page-Do0l5Ddr.js} +1 -1
  94. package/dist/gateway/static/root/assets/{oauth-api-CvPnQTlH.js → oauth-api-B560CHeD.js} +1 -1
  95. package/dist/gateway/static/root/assets/{oauth-provider-connect-Dk1NeeqD.js → oauth-provider-connect-D63M8Iv7.js} +1 -1
  96. package/dist/gateway/static/root/assets/{page-context-capture-button-BPtX67hZ.js → page-context-capture-button-Dibmspef.js} +1 -1
  97. package/dist/gateway/static/root/assets/{page-context-draft-Ckb8baxj.js → page-context-draft-Cr5GqS2D.js} +1 -1
  98. package/dist/gateway/static/root/assets/page-header-store-Bm8oxpFR.js +1 -0
  99. package/dist/gateway/static/root/assets/{personal-avatar-CZSnrSfc.js → personal-avatar-BMRVyTrE.js} +1 -1
  100. package/dist/gateway/static/root/assets/{personal-page-BSCNuRMT.js → personal-page-DrYh0NPE.js} +1 -1
  101. package/dist/gateway/static/root/assets/{personal-profile-settings-DJRDcK2c.js → personal-profile-settings-HMQY9lz9.js} +1 -1
  102. package/dist/gateway/static/root/assets/{personal-settings-panel-C6p25Noq.js → personal-settings-panel-BppxtWBl.js} +1 -1
  103. package/dist/gateway/static/root/assets/{phone-dependencies-card-DKkFFpqi.js → phone-dependencies-card-flTci8mm.js} +1 -1
  104. package/dist/gateway/static/root/assets/{phone-model-connection-CRRHq4PQ.js → phone-model-connection-Vi_Swyv6.js} +1 -1
  105. package/dist/gateway/static/root/assets/{phone-model-picker-CN_I0-46.js → phone-model-picker-BOv3mb_F.js} +1 -1
  106. package/dist/gateway/static/root/assets/{phone-settings-page-CkdSOA7D.js → phone-settings-page-vD0bTcHj.js} +1 -1
  107. package/dist/gateway/static/root/assets/{phone-workspace-store-CC61pIuJ.js → phone-workspace-store-Ltrevdsx.js} +1 -1
  108. package/dist/gateway/static/root/assets/{plugin-details-dialog-Bqz4jT53.js → plugin-details-dialog-nSDw8sfo.js} +1 -1
  109. package/dist/gateway/static/root/assets/{preference-select-fields-DHeNbAvn.js → preference-select-fields-D1pZekPs.js} +1 -1
  110. package/dist/gateway/static/root/assets/{product-automation-feedback-BN2HTA9T.js → product-automation-feedback-D51I7Lg3.js} +1 -1
  111. package/dist/gateway/static/root/assets/{product-open-page-B-j4gpLD.js → product-open-page-BO8lUvw3.js} +1 -1
  112. package/dist/gateway/static/root/assets/{product-preview-content-EqrTk7kU.js → product-preview-content-CUaHxyiE.js} +1 -1
  113. package/dist/gateway/static/root/assets/{product-preview-modal-aurFBFq4.js → product-preview-modal-BUeyRD5W.js} +2 -2
  114. package/dist/gateway/static/root/assets/{project-detail-page-ibZZ_w51.js → project-detail-page-D3k1NzXQ.js} +2 -2
  115. package/dist/gateway/static/root/assets/{project-understanding-HNK9lFVy.js → project-understanding-Cg8WbBNB.js} +1 -1
  116. package/dist/gateway/static/root/assets/{projects-page-CugSyKl5.js → projects-page-C6Pt6OdT.js} +1 -1
  117. package/dist/gateway/static/root/assets/{providers-api-DUntOOqr.js → providers-api-Nytkkop9.js} +1 -1
  118. package/dist/gateway/static/root/assets/{recording-upload-DIwP541B.js → recording-upload-CyZSl2DJ.js} +1 -1
  119. package/dist/gateway/static/root/assets/{registry-api-BTd_OgbD.js → registry-api-DuDIthjL.js} +1 -1
  120. package/dist/gateway/static/root/assets/{remote-access-hub-f5mIfsBF.js → remote-access-hub-DePwafOK.js} +1 -1
  121. package/dist/gateway/static/root/assets/{resource-unavailable-DtQ2rfu_.js → resource-unavailable-BRKhKJA0.js} +1 -1
  122. package/dist/gateway/static/root/assets/right-workspace-store-HPw7Gw0n.js +1 -0
  123. package/dist/gateway/static/root/assets/route-preload-CTuS4GFj.js +2 -0
  124. package/dist/gateway/static/root/assets/routine-panel-9UC3NU5V.js +2 -0
  125. package/dist/gateway/static/root/assets/{runtime-tools-api-C1iI8EPo.js → runtime-tools-api-Dd8a07eo.js} +1 -1
  126. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-0tdI1z0g.js → runtime-tools-settings-panel-CvHQoqHu.js} +1 -1
  127. package/dist/gateway/static/root/assets/{service-recommendation-list-DSIe-NRe.js → service-recommendation-list-8mVIWB38.js} +1 -1
  128. package/dist/gateway/static/root/assets/{session-api-CQlEq0MB.js → session-api-BFiIYodK.js} +1 -1
  129. package/dist/gateway/static/root/assets/{session-manager-C7RfUfqI.js → session-manager-D2LaQymu.js} +2 -2
  130. package/dist/gateway/static/root/assets/{sessions-page-DdS8U0RV.js → sessions-page-DQEq_VJS.js} +1 -1
  131. package/dist/gateway/static/root/assets/settings-advanced-gate-Cvx7DnU8.js +1 -0
  132. package/dist/gateway/static/root/assets/{settings-advanced-section-C6dPu5i1.js → settings-advanced-section-B-H1gYOs.js} +1 -1
  133. package/dist/gateway/static/root/assets/{settings-mode-store-BSiiowQa.js → settings-mode-store-YH60sibB.js} +1 -1
  134. package/dist/gateway/static/root/assets/{settings-page-DAc5n-mM.js → settings-page-CGiZCF8z.js} +1 -1
  135. package/dist/gateway/static/root/assets/{settings-page-header-BSMu5Zq3.js → settings-page-header-DEZZ8D0S.js} +1 -1
  136. package/dist/gateway/static/root/assets/{settings-page-layout-B_vMffB1.js → settings-page-layout-De2j64Lo.js} +1 -1
  137. package/dist/gateway/static/root/assets/{setup-interaction-page-DKXfFdNt.js → setup-interaction-page-Dh6BPwv0.js} +1 -1
  138. package/dist/gateway/static/root/assets/{setup-status-panel-BbAZ9w77.js → setup-status-panel-DGAAczL-.js} +1 -1
  139. package/dist/gateway/static/root/assets/{share-link-dialog-ztX1WPXG.js → share-link-dialog-C1t_HB6f.js} +1 -1
  140. package/dist/gateway/static/root/assets/{share-preview-page-Ds2Ydfg6.js → share-preview-page-fV5USZb1.js} +1 -1
  141. package/dist/gateway/static/root/assets/{shares-api-CSZqeNL4.js → shares-api-Dm07CnXw.js} +1 -1
  142. package/dist/gateway/static/root/assets/{shares-settings-CX3TNAmI.js → shares-settings-sl40lqND.js} +1 -1
  143. package/dist/gateway/static/root/assets/{skill-api-CGzAQ-MX.js → skill-api-BV8oFqeE.js} +1 -1
  144. package/dist/gateway/static/root/assets/{skill-list-api-DfUsku-x.js → skill-list-api-1o_YRCu9.js} +1 -1
  145. package/dist/gateway/static/root/assets/{skill-reload-api-Y9qSMnBd.js → skill-reload-api-fGsO9Y86.js} +1 -1
  146. package/dist/gateway/static/root/assets/{skills-page-DnMN50Ot.js → skills-page-FTd0Z7Ey.js} +1 -1
  147. package/dist/gateway/static/root/assets/{system-settings-panel-DWNkQmme.js → system-settings-panel-CUI6QHEP.js} +1 -1
  148. package/dist/gateway/static/root/assets/{task-detail-page-BJok6V1K.js → task-detail-page-CWwwumsy.js} +3 -3
  149. package/dist/gateway/static/root/assets/task-result-evidence-CSJeB9AH.js +1 -0
  150. package/dist/gateway/static/root/assets/{terminal-panel-store-D8eZPvql.js → terminal-panel-store-Du53Upr2.js} +1 -1
  151. package/dist/gateway/static/root/assets/{theme-store-GZQ3pTgy.js → theme-store-BaWep_o7.js} +1 -1
  152. package/dist/gateway/static/root/assets/tool-friendly-title-CP35P4VA.js +2 -0
  153. package/dist/gateway/static/root/assets/{tracing-settings-page-DM3-7Hlw.js → tracing-settings-page-CnciBMVH.js} +1 -1
  154. package/dist/gateway/static/root/assets/{tunnel-api-DOGAIXRR.js → tunnel-api-Iz7JCBt3.js} +1 -1
  155. package/dist/gateway/static/root/assets/{understanding-activity-store-CuPfe0eQ.js → understanding-activity-store-BFc8PamJ.js} +1 -1
  156. package/dist/gateway/static/root/assets/understanding-refresh-store-CdEfR40A.js +1 -0
  157. package/dist/gateway/static/root/assets/{usage-page-BA9Yrvqu.js → usage-page-DL2fmeOh.js} +1 -1
  158. package/dist/gateway/static/root/assets/{use-autosave-CO0IPCVg.js → use-autosave-N_SjHXTw.js} +1 -1
  159. package/dist/gateway/static/root/assets/use-composer-attachments-CO7XLI4x.js +2 -0
  160. package/dist/gateway/static/root/assets/{use-file-preview-expanded-dhNMHf5b.js → use-file-preview-expanded-BXXeXnT0.js} +3 -3
  161. package/dist/gateway/static/root/assets/{use-personal-profile-CVqDWBDS.js → use-personal-profile-C1vqD9yV.js} +1 -1
  162. package/dist/gateway/static/root/assets/{use-realtime-voice-DDVVlX1R.js → use-realtime-voice-C7iWQuUv.js} +1 -1
  163. package/dist/gateway/static/root/assets/{use-workspace-tree-CZej8mhf.js → use-workspace-tree-D27u-eoX.js} +1 -1
  164. package/dist/gateway/static/root/assets/user-model-page-D2FHjLi7.js +2 -0
  165. package/dist/gateway/static/root/assets/{voice-api-key-field-DpwUDAvu.js → voice-api-key-field-B_GApUQP.js} +1 -1
  166. package/dist/gateway/static/root/assets/{voice-config-api-GIuXoHXw.js → voice-config-api-DhJ3l8fk.js} +1 -1
  167. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-Cc30ZcFy.js → voice-input-shortcut-events-CEeFBhp3.js} +1 -1
  168. package/dist/gateway/static/root/assets/{voice-settings-DA3m5MT0.js → voice-settings-BiqJ0tlf.js} +1 -1
  169. package/dist/gateway/static/root/assets/{work-discovery-overlay-yGUkk1NV.js → work-discovery-overlay-BNZK4hQ4.js} +1 -1
  170. package/dist/gateway/static/root/assets/{work-discovery-page-RN6iuY-0.js → work-discovery-page-KwSPhukU.js} +1 -1
  171. package/dist/gateway/static/root/assets/{working-directory-picker-modal-CeXl9w6z.js → working-directory-picker-modal-BGZduAXV.js} +1 -1
  172. package/dist/gateway/static/root/assets/{workspace-api-B1Uirhxf.js → workspace-api-LghfbP5g.js} +2 -2
  173. package/dist/gateway/static/root/assets/workspace-editor-agent-store-DVPJcbuE.js +1 -0
  174. package/dist/gateway/static/root/assets/workspace-file-preview-dialog-NffP-UXC.js +1 -0
  175. package/dist/gateway/static/root/assets/{workspace-open-location-menu-DWGNOIE2.js → workspace-open-location-menu-CvZxU9de.js} +1 -1
  176. package/dist/gateway/static/root/assets/workspace-preview-store-Do31QQH5.js +1 -0
  177. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-x-XT4bKF.js → xopc-cloud-account-card-Q_jezTUy.js} +1 -1
  178. package/dist/gateway/static/root/index.html +92 -90
  179. package/dist/package.js +1 -1
  180. package/dist/packages/gateway-contract/src/automations.js +6 -0
  181. package/dist/packages/gateway-contract/src/capabilities.js +1 -1
  182. package/dist/packages/gateway-contract/src/home.js +3 -0
  183. package/dist/packages/gateway-contract/src/index.js +3 -1
  184. package/dist/packages/gateway-contract/src/observation.js +177 -0
  185. package/dist/packages/gateway-contract/src/session-input-command.js +5 -1
  186. package/dist/src/agent/agent-manager.js +6 -1
  187. package/dist/src/agent/background-review/prompts.d.ts +1 -1
  188. package/dist/src/agent/background-review/prompts.js +8 -1
  189. package/dist/src/agent/background-review/run-background-review.js +47 -3
  190. package/dist/src/agent/client-error-format.js +1 -1
  191. package/dist/src/agent/context/audit.js +18 -0
  192. package/dist/src/agent/context/coordinator.d.ts +4 -0
  193. package/dist/src/agent/context/coordinator.js +33 -7
  194. package/dist/src/agent/context/deep-recall.d.ts +33 -0
  195. package/dist/src/agent/context/deep-recall.js +190 -0
  196. package/dist/src/agent/context/execution-context.js +29 -5
  197. package/dist/src/agent/context/execution-context.types.d.ts +2 -0
  198. package/dist/src/agent/context/memory-claim-grounding.d.ts +2 -0
  199. package/dist/src/agent/context/memory-claim-grounding.js +20 -0
  200. package/dist/src/agent/context/recall-grounding.d.ts +3 -0
  201. package/dist/src/agent/context/recall-grounding.js +31 -0
  202. package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -0
  203. package/dist/src/agent/embedded/execution-tool-policy.js +31 -5
  204. package/dist/src/agent/embedded/run-for-session.js +16 -8
  205. package/dist/src/agent/embedded/run-turn.js +111 -29
  206. package/dist/src/agent/embedded/types.d.ts +2 -0
  207. package/dist/src/agent/fallback/reason.js +1 -1
  208. package/dist/src/agent/memory/context-recovery.d.ts +1 -1
  209. package/dist/src/agent/memory/index.js +1 -1
  210. package/dist/src/agent/orchestration/llm-turn-retry.d.ts +5 -0
  211. package/dist/src/agent/orchestration/llm-turn-retry.js +17 -6
  212. package/dist/src/agent/service/process-direct-streaming.js +1 -1
  213. package/dist/src/agent/service.d.ts +1 -0
  214. package/dist/src/agent/service.js +5 -2
  215. package/dist/src/agent/tools/factory.js +22 -0
  216. package/dist/src/agent/tools/knowledge-memory-tool.js +7 -1
  217. package/dist/src/agent/tools/personal-memory-tool.d.ts +11 -0
  218. package/dist/src/agent/tools/personal-memory-tool.js +387 -0
  219. package/dist/src/agent/tools/session-search-tool.d.ts +2 -0
  220. package/dist/src/agent/tools/session-search-tool.js +21 -7
  221. package/dist/src/agent/tools/user-context-tool.js +11 -1
  222. package/dist/src/automations/capabilities/write.d.ts +10 -0
  223. package/dist/src/automations/domain/types.d.ts +14 -0
  224. package/dist/src/automations/domain/validation.d.ts +20 -0
  225. package/dist/src/automations/domain/validation.js +6 -0
  226. package/dist/src/automations/draft/automation-draft-validator.d.ts +5 -0
  227. package/dist/src/automations/draft/automation-draft-validator.js +1 -0
  228. package/dist/src/automations/index.js +2 -2
  229. package/dist/src/automations/service/action-executor.d.ts +2 -0
  230. package/dist/src/automations/service/action-executor.js +18 -2
  231. package/dist/src/automations/service/index.js +2 -2
  232. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  233. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  234. package/dist/src/config/schema.d.ts +6 -0
  235. package/dist/src/config/schema.js +6 -0
  236. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  237. package/dist/src/gateway/hono/lib/config-payload.d.ts +6 -0
  238. package/dist/src/gateway/hono/routes/home.js +100 -2
  239. package/dist/src/gateway/hono/routes/user-model.js +47 -7
  240. package/dist/src/gateway/security/gateway-scopes.js +1 -0
  241. package/dist/src/gateway/service/config-coordinator.d.ts +6 -0
  242. package/dist/src/gateway/service.js +17 -0
  243. package/dist/src/home-intelligence/application-service.d.ts +1 -0
  244. package/dist/src/home-intelligence/application-service.js +1 -1
  245. package/dist/src/home-intelligence/generator.js +4 -0
  246. package/dist/src/home-intelligence/host.d.ts +157 -1
  247. package/dist/src/home-intelligence/host.js +196 -12
  248. package/dist/src/home-intelligence/observation.d.ts +41 -0
  249. package/dist/src/home-intelligence/observation.js +297 -0
  250. package/dist/src/home-intelligence/repository.d.ts +1 -1
  251. package/dist/src/home-intelligence/routines.d.ts +36 -0
  252. package/dist/src/home-intelligence/routines.js +444 -0
  253. package/dist/src/home-intelligence/snapshot.d.ts +14 -0
  254. package/dist/src/knowledge-memory/index.js +2 -2
  255. package/dist/src/knowledge-memory/repository.d.ts +6 -0
  256. package/dist/src/knowledge-memory/repository.js +49 -1
  257. package/dist/src/knowledge-memory/usage-policy.js +7 -7
  258. package/dist/src/local-apps/automation-proposals.d.ts +20 -0
  259. package/dist/src/memory-learning/work-capture.js +3 -1
  260. package/dist/src/personal-agent/policy.d.ts +1 -1
  261. package/dist/src/personal-agent/policy.js +2 -1
  262. package/dist/src/personal-agent/proactivity/repository.d.ts +1 -1
  263. package/dist/src/personal-agent/prompts.js +7 -1
  264. package/dist/src/providers/model-response.js +1 -1
  265. package/dist/src/realtime/compact-run-event.js +9 -0
  266. package/dist/src/session/history-recall-policy.d.ts +6 -0
  267. package/dist/src/session/history-recall-policy.js +48 -0
  268. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  269. package/dist/src/storage/sqlite/schema.js +7 -7
  270. package/dist/src/storage/sqlite/schema.sql +71 -0
  271. package/dist/src/storage/sqlite/session-input-control-repository.js +2 -0
  272. package/dist/src/storage/sqlite/upgrades/272_home_observation.sql +41 -0
  273. package/dist/src/storage/sqlite/upgrades/273_observation_routines.sql +30 -0
  274. package/dist/src/tasks/home-query-service.js +1 -0
  275. package/dist/src/user-context/config.d.ts +12 -0
  276. package/dist/src/user-context/config.js +14 -1
  277. package/dist/src/user-context/memory-version.d.ts +2 -0
  278. package/dist/src/user-context/memory-version.js +12 -0
  279. package/dist/src/user-model/capture/evidence-policy.d.ts +45 -0
  280. package/dist/src/user-model/capture/evidence-policy.js +143 -0
  281. package/dist/src/user-model/capture/executor.d.ts +1 -0
  282. package/dist/src/user-model/capture/executor.js +68 -8
  283. package/dist/src/user-model/capture/semantic.d.ts +16 -0
  284. package/dist/src/user-model/capture/semantic.js +66 -12
  285. package/dist/src/user-model/repository.js +11 -0
  286. package/dist/src/user-model/usage-policy.js +5 -5
  287. package/dist/src/work-discovery/service.js +1 -1
  288. package/package.json +1 -1
  289. package/dist/gateway/static/root/assets/automations-workspace-BhHgruhH.js +0 -9
  290. package/dist/gateway/static/root/assets/capabilities-kG175Q-7.js +0 -1
  291. package/dist/gateway/static/root/assets/chat-page-dY6aCCRx.js +0 -71
  292. package/dist/gateway/static/root/assets/composer-payload-handoff-DBE1mvOS.js +0 -1
  293. package/dist/gateway/static/root/assets/file-preview-surface-z7_HV0WN.js +0 -1
  294. package/dist/gateway/static/root/assets/gateway-realtime-store-xB7Bq4Zs.js +0 -1
  295. package/dist/gateway/static/root/assets/home-page-i_PIrDCU.js +0 -3
  296. package/dist/gateway/static/root/assets/index-Bj5exyow.css +0 -1
  297. package/dist/gateway/static/root/assets/index-CZI3VGGW.js +0 -11
  298. package/dist/gateway/static/root/assets/messages-eQ2CYlpG.js +0 -3
  299. package/dist/gateway/static/root/assets/note-image-lightbox-DfK2KSgu.js +0 -1
  300. package/dist/gateway/static/root/assets/page-header-store-DU4NnGap.js +0 -1
  301. package/dist/gateway/static/root/assets/route-preload-anuckzRl.js +0 -2
  302. package/dist/gateway/static/root/assets/settings-advanced-gate-DnfH22f_.js +0 -1
  303. package/dist/gateway/static/root/assets/task-input-card-lCMSy6YY.js +0 -1
  304. package/dist/gateway/static/root/assets/tool-friendly-title-DC8_9-Lo.js +0 -2
  305. package/dist/gateway/static/root/assets/understanding-refresh-store-Ihz2p9Vg.js +0 -1
  306. package/dist/gateway/static/root/assets/use-composer-attachments-CLIrD0mm.js +0 -2
  307. package/dist/gateway/static/root/assets/user-model-page-1eYattnk.js +0 -2
  308. package/dist/gateway/static/root/assets/workspace-editor-agent-store-Nos5ebMv.js +0 -1
  309. package/dist/gateway/static/root/assets/workspace-file-preview-dialog-D0h2yJ3v.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,m as a,t as o}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as s,n as c,o as l}from"./locale-store-Dy1EByeG.js";import{a as u,c as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-CY7CS_D3.js";import{n as v,t as y}from"./earth-C9Z4bTTG.js";import{t as b}from"./bot-DjLkhyZL.js";import{C as x,S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,l as M,m as ee,n as N,o as te,p as P,r as F,s as I,t as L,v as R,w as z,x as B,y as ne}from"./understanding-refresh-store-CdEfR40A.js";import{t as re}from"./briefcase-business-BsoCaI_t.js";import{t as ie}from"./calendar-days-hw_Y-g-s.js";import{t as ae}from"./check-DUBLcKHA.js";import{t as oe}from"./chevron-down-ccbiQQz_.js";import{t as V}from"./chevron-right-BweFrslA.js";import{n as H,r as U,t as W}from"./popover-select-CLsphyzA.js";import{t as se}from"./circle-alert-BEjgurr2.js";import{t as G}from"./circle-check-C23XjkUj.js";import{t as ce}from"./clock-3-DnrAnuyZ.js";import{t as le}from"./database-CjjeZfRG.js";import{t as ue}from"./download-Dk-ZjtO6.js";import{t as de}from"./ellipsis-0k4rZLoy.js";import{m as K,p as q,t as J}from"./understanding-activity-store-BFc8PamJ.js";import{t as fe}from"./folder-open-CyzJ19I9.js";import{t as pe}from"./git-branch-Dh9uxTot.js";import{t as me}from"./list-todo-CTVRto8O.js";import{t as he}from"./loader-circle-CifKLtgG.js";import{t as ge}from"./lock-keyhole-DEK5kH0u.js";import{t as _e}from"./message-circle-Badhj-4D.js";import{t as ve}from"./pencil-DmIY3Oa-.js";import{t as ye}from"./plus-Q2yW6OE7.js";import{t as be}from"./refresh-cw-BRlGaq2w.js";import{t as xe}from"./search-DA7gz22f.js";import{t as Se}from"./shield-check-BU58siTV.js";import{t as Ce}from"./sliders-horizontal-DqsYor6I.js";import{t as we}from"./sparkles-DHlfQFAF.js";import{t as Te}from"./sticky-note-fzP7NAJq.js";import{t as Ee}from"./trash-2-DusmjVPV.js";import{t as De}from"./upload-rrb46c3c.js";import{t as Oe}from"./user-round-C9jxPhMR.js";import{t as ke}from"./x-B_N4OPjy.js";import{t as Ae}from"./cn-0WouolD0.js";import{t as je}from"./skeleton-DzdOeGYz.js";import{i as Me}from"./vendor-swr-CdRzEUwF.js";import{t as Y}from"./button-Cc4hUNTt.js";import{r as Ne}from"./app-chrome-BeB4KgOf.js";import{t as Pe}from"./page-tabs-oeTY7z3_.js";import{t as Fe}from"./page-header-store-Bm8oxpFR.js";import{t as Ie}from"./loopi-CNtmi9FU.js";import{t as Le}from"./sliding-tab-list-CmcrqRzN.js";import{l as Re,m as ze,o as Be,r as Ve,t as He}from"./dist-ZrL34Ps4.js";import{t as Ue}from"./date-picker-XnE3iFhG.js";var X=e(t(),1),Z=n(),Q=r();function We(e){let t=(0,Z.c)(15),{sourceId:n,disabled:r}=e,i=r!==void 0&&r,a=c(qe)===`zh`,{sources:o,starting:s,start:l}=L(),u;t[0]!==n||t[1]!==o?(u=n?o.filter(e=>e.grantId===n):o,t[0]=n,t[1]=o,t[2]=u):u=t[2];let d=u,f;t[3]===d?f=t[4]:(f=d.some(Ke),t[3]=d,t[4]=f);let p=f,m=n&&d.some(Ge),h=p?a?`更新中`:`Updating`:m?a?`重试`:`Retry`:n?a?`更新理解`:`Update understanding`:a?`更新全部`:`Update all`,g=i||s||p,_;t[5]!==n||t[6]!==l?(_=()=>void l(n),t[5]=n,t[6]=l,t[7]=_):_=t[7];let v;t[8]===p?v=t[9]:(v=p?(0,Q.jsx)(he,{className:`size-3.5 animate-spin motion-reduce:animate-none`}):(0,Q.jsx)(be,{className:`size-3.5`}),t[8]=p,t[9]=v);let y;return t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==v?(y=(0,Q.jsxs)(Y,{variant:`ghost`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs`,disabled:g,onClick:_,children:[v,h]}),t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y):y=t[14],y}function Ge(e){return e.status===`failed`||e.status===`partial`||e.status===`canceled`}function Ke(e){return e.status===`queued`||e.status===`running`}function qe(e){return e.language}function Je(e){let t=(0,Z.c)(22),{sourceId:n,lastCollectedAt:r}=e,i=c(Ye),a=i===`zh`,o;t[0]===n?o=t[1]:(o=e=>e.sources.find(e=>e.grantId===n),t[0]=n,t[1]=o);let s=L(o);if(!s){let e;t[2]!==i||t[3]!==r||t[4]!==a?(e=r?`${a?`上次更新:`:`Last updated: `}${new Date(r).toLocaleString(i)}`:a?`尚未分析`:`Not analyzed yet`,t[2]=i,t[3]=r,t[4]=a,t[5]=e):e=t[5];let n;return t[6]===e?n=t[7]:(n=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e}),t[6]=e,t[7]=n),n}let l;t[8]===a?l=t[9]:(l=a?{queued:`等待更新`,waiting_desktop:`等待桌面端读取资料`,reading:`正在读取资料`,analyzing:`正在更新理解`}:{queued:`Queued`,waiting_desktop:`Waiting for desktop collection`,reading:`Reading source`,analyzing:`Updating understanding`},t[8]=a,t[9]=l);let u=l,d=s.status===`running`||s.status===`queued`,f=s.status===`failed`||s.status===`partial`||s.status===`canceled`,p=s.metadata.added,m=d?u[s.metadata.phase??`queued`]??u.queued:f?a?`更新未完成,可重试`:`Update incomplete; retry available`:p===0?a?`更新完成,暂无新增理解`:`Updated; no new understanding`:p===void 0?a?`更新完成`:`Updated`:a?`更新完成,新增 ${p} 条`:`Updated; ${p} added`,h;t[10]===m?h=t[11]:(h=(0,Q.jsx)(`p`,{children:m}),t[10]=m,t[11]=h);let g;t[12]!==i||t[13]!==s.completedAt?(g=s.completedAt?(0,Q.jsx)(`p`,{children:new Date(s.completedAt).toLocaleString(i)}):null,t[12]=i,t[13]=s.completedAt,t[14]=g):g=t[14];let _;t[15]!==f||t[16]!==s.errorMessage?(_=f&&s.errorMessage?(0,Q.jsx)(`p`,{className:`text-danger`,children:s.errorMessage}):null,t[15]=f,t[16]=s.errorMessage,t[17]=_):_=t[17];let v;return t[18]!==h||t[19]!==g||t[20]!==_?(v=(0,Q.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,"aria-live":`polite`,children:[h,g,_]}),t[18]=h,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function Ye(e){return e.language}function Xe(e){let t=(0,Z.c)(87),{language:n,busy:r,statement:i,scope:a,onEdit:o,onDelete:s,onScopeChange:c}=e,[l,d]=(0,X.useState)(!1),[v,x]=(0,X.useState)(!1),S=n===`zh`,{data:C,isLoading:w,error:T}=Me(v?`memory-scope-options`:null,Ze),E;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E={type:`global`},t[0]=E):E=t[0];let D=S?`所有协作`:`All work`,O=S?`任何助手和对话都可按需使用`:`Available when relevant across all work`,k;t[1]!==D||t[2]!==O?(k={value:E,icon:y,title:D,detail:O},t[1]=D,t[2]=O,t[3]=k):k=t[3];let A;if(t[4]!==a||t[5]!==C?.agents||t[6]!==C?.projects||t[7]!==k||t[8]!==S){let e;t[10]===S?e=t[11]:(e=e=>({value:{type:`agent`,id:e.id},icon:b,title:S?`仅助手:${e.name||e.id}`:`Assistant: ${e.name||e.id}`,detail:S?`不会分享给其他助手`:`Not shared with other assistants`}),t[10]=S,t[11]=e);let n;if(t[12]===S?n=t[13]:(n=e=>({value:{type:`project`,id:e.id},icon:y,title:S?`仅项目:${e.name}`:`Project: ${e.name}`,detail:S?`仅在此项目中按需使用`:`Available only in this project`}),t[12]=S,t[13]=n),A=[k,...(C?.agents??[]).map(e),...(C?.projects??[]).map(n)],a&&!A.some(e=>e.value.type===a.type&&e.value.id===a.id)){let e=S?`保留现有范围`:`Keep existing scope`,n;t[14]===S?n=t[15]:(n=S?{global:`所有协作`,agent:`指定助手`,workspace:`指定工作区`,project:`指定项目`,session:`指定会话`}:{global:`All work`,agent:`Assigned assistant`,workspace:`Assigned workspace`,project:`Assigned project`,session:`Assigned conversation`},t[14]=S,t[15]=n);let r=n[a.type],i;t[16]!==a||t[17]!==e||t[18]!==r?(i={value:a,icon:b,title:e,detail:r},t[16]=a,t[17]=e,t[18]=r,t[19]=i):i=t[19],A.push(i)}t[4]=a,t[5]=C?.agents,t[6]=C?.projects,t[7]=k,t[8]=S,t[9]=A}else A=t[9];let j=S?`修改或删除这条内容`:`Edit or delete this item`,M;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(de,{className:`size-4`,"aria-hidden":`true`}),t[20]=M):M=t[20];let ee;t[21]!==r||t[22]!==j?(ee=(0,Q.jsx)(ze,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-11 shrink-0 p-0`,disabled:r,"aria-label":j,children:M})}),t[21]=r,t[22]=j,t[23]=ee):ee=t[23];let N;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(ve,{className:`size-4`,"aria-hidden":`true`}),t[24]=N):N=t[24];let te=S?`修改`:`Edit`,P;t[25]!==r||t[26]!==o||t[27]!==te?(P=(0,Q.jsxs)(Ve,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:o,children:[N,te]}),t[25]=r,t[26]=o,t[27]=te,t[28]=P):P=t[28];let F;t[29]!==r||t[30]!==c||t[31]!==a||t[32]!==S?(F=a&&c?(0,Q.jsxs)(Ve,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:()=>x(!0),children:[(0,Q.jsx)(Ce,{className:`size-4`,"aria-hidden":`true`}),S?`作用范围`:`Where it applies`]}):null,t[29]=r,t[30]=c,t[31]=a,t[32]=S,t[33]=F):F=t[33];let I,L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>d(!0),L=(0,Q.jsx)(Ee,{className:`size-4`,"aria-hidden":`true`}),t[34]=I,t[35]=L):(I=t[34],L=t[35]);let R=S?`删除`:`Delete`,z;t[36]!==r||t[37]!==R?(z=(0,Q.jsxs)(Ve,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:I,children:[L,R]}),t[36]=r,t[37]=R,t[38]=z):z=t[38];let B;t[39]!==P||t[40]!==F||t[41]!==z?(B=(0,Q.jsx)(Be,{children:(0,Q.jsxs)(He,{align:`end`,sideOffset:4,className:`z-[100] min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[P,F,z]})}),t[39]=P,t[40]=F,t[41]=z,t[42]=B):B=t[42];let ne;t[43]!==B||t[44]!==ee?(ne=(0,Q.jsxs)(Re,{modal:!1,children:[ee,B]}),t[43]=B,t[44]=ee,t[45]=ne):ne=t[45];let re;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(u,{className:`fixed inset-0 z-[110] bg-scrim`}),t[46]=re):re=t[46];let ie=S?`删除这条内容?`:`Delete this item?`,ae;t[47]===ie?ae=t[48]:(ae=(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:ie}),t[47]=ie,t[48]=ae);let oe=S?`删除后将不再使用这条记忆,原始对话和文件会保留。`:`This memory will no longer be used. Original conversations and files are kept.`,V;t[49]===oe?V=t[50]:(V=(0,Q.jsx)(f,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:oe}),t[49]=oe,t[50]=V);let H;t[51]!==ae||t[52]!==V?(H=(0,Q.jsxs)(`header`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[ae,V]}),t[51]=ae,t[52]=V,t[53]=H):H=t[53];let U;t[54]===i?U=t[55]:(U=(0,Q.jsx)(`p`,{className:`min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap break-words px-5 py-4 text-sm leading-6 text-fg`,children:i}),t[54]=i,t[55]=U);let W=S?`取消`:`Cancel`,se;t[56]===W?se=t[57]:(se=(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,children:W})}),t[56]=W,t[57]=se);let G;t[58]===s?G=t[59]:(G=()=>{d(!1),s()},t[58]=s,t[59]=G);let ce=S?`删除`:`Delete`,le;t[60]!==r||t[61]!==G||t[62]!==ce?(le=(0,Q.jsx)(Y,{disabled:r,onClick:G,children:ce}),t[60]=r,t[61]=G,t[62]=ce,t[63]=le):le=t[63];let ue;t[64]!==se||t[65]!==le?(ue=(0,Q.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3`,children:[se,le]}),t[64]=se,t[65]=le,t[66]=ue):ue=t[66];let K;t[67]!==H||t[68]!==U||t[69]!==ue?(K=(0,Q.jsxs)(m,{children:[re,(0,Q.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-[120] flex h-[min(22rem,calc(100dvh-2rem))] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover`,children:[H,U,ue]})]}),t[67]=H,t[68]=U,t[69]=ue,t[70]=K):K=t[70];let q;t[71]!==l||t[72]!==ne||t[73]!==K?(q=(0,Q.jsxs)(_,{open:l,onOpenChange:d,children:[ne,K]}),t[71]=l,t[72]=ne,t[73]=K,t[74]=q):q=t[74];let J;t[75]!==r||t[76]!==A||t[77]!==c||t[78]!==a||t[79]!==T||t[80]!==w||t[81]!==v||t[82]!==S?(J=a&&c?(0,Q.jsx)(_,{open:v,onOpenChange:x,children:(0,Q.jsxs)(m,{children:[(0,Q.jsx)(u,{className:`fixed inset-0 z-[110] bg-scrim`}),(0,Q.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-[120] flex h-[min(25rem,calc(100dvh-2rem))] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover`,children:[(0,Q.jsxs)(`header`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:S?`这条记忆在哪里生效?`:`Where should this memory apply?`}),(0,Q.jsx)(f,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:S?`选择明确的助手或项目。工作区和会话范围也可在对应聊天中设置。`:`Choose an assistant or project. Workspace and conversation scopes can also be set in the corresponding chat.`})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-4`,children:[w?(0,Q.jsx)(je,{className:`h-20 w-full rounded-xl`}):null,T?(0,Q.jsx)(`p`,{role:`status`,className:`px-4 py-2 text-sm text-fg-muted`,children:S?`无法载入范围,请重试;现有范围未改变。`:`Could not load scopes. Your existing scope is unchanged.`}):null,A.map(e=>{let{value:t,icon:n,title:i,detail:o}=e,s=a.type===t.type&&(a.id??``)===(t.id??``);return(0,Q.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full items-center gap-3 rounded-xl px-4 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${s?`bg-surface-active`:`hover:bg-surface-hover`}`,disabled:r,onClick:()=>{x(!1),c(t)},children:[(0,Q.jsx)(n,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:i}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:o})]}),s?(0,Q.jsx)(`span`,{className:`text-xs font-medium text-accent-fg`,children:S?`当前`:`Current`}):null]},`${t.type}:${t.id??``}`)})]}),(0,Q.jsx)(`footer`,{className:`flex shrink-0 justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,children:S?`取消`:`Cancel`})})})]})]})}):null,t[75]=r,t[76]=A,t[77]=c,t[78]=a,t[79]=T,t[80]=w,t[81]=v,t[82]=S,t[83]=J):J=t[83];let fe;return t[84]!==q||t[85]!==J?(fe=(0,Q.jsxs)(Q.Fragment,{children:[q,J]}),t[84]=q,t[85]=J,t[86]=fe):fe=t[86],fe}async function Ze(){let[e,t]=await Promise.all([l(s(`/api/agents`)),l(s(`/api/projects`))]);return{agents:e.payload?.agents??[],projects:t.items??[]}}function Qe(e,t){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`}).format(e):null}function $e(e,t,n=new Date){let r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(r);i.setDate(r.getDate()-1);let a=new Map;for(let n of[...e].sort((e,t)=>t.recordedAt-e.recordedAt)){let e=n.recordedAt>=r.getTime()?t===`zh`?`今天`:`Today`:n.recordedAt>=i.getTime()?t===`zh`?`昨天`:`Yesterday`:Qe(n.recordedAt,t)??(t===`zh`?`更早`:`Earlier`),o=a.get(e)??[];o.push(n),a.set(e,o)}return[...a].map(([e,t])=>({label:e,items:t}))}function et(e,t){return(t===`zh`?{user_explicit:`你告诉我的`,user_observed:`从协作中观察到`,system_inferred:`xopc 的推测`,external_untrusted:`来自连接的信息`}:{user_explicit:`You told me`,user_observed:`Observed while working together`,system_inferred:`Inferred by xopc`,external_untrusted:`From connected information`})[e.authority]}function tt(e,t){if(e.validTo){let n=Qe(e.validTo,t);return t===`zh`?`适用至 ${n}`:`Applies until ${n}`}return(t===`zh`?{stable:`相对稳定`,slow:`会随时间复核`,dynamic:`近期状态`,event:`特定阶段`}:{stable:`Relatively stable`,slow:`Reviewed over time`,dynamic:`Current context`,event:`Specific period`})[e.volatility]}function nt(e,t){return e.authority===`user_explicit`?null:e.confidence>=.85?t===`zh`?`把握较高`:`High confidence`:e.confidence>=.65?t===`zh`?`把握中等`:`Medium confidence`:t===`zh`?`证据较少`:`Limited evidence`}function rt(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function it(e){let t=(0,Z.c)(25),{item:n,language:r,busy:i,editing:a,draft:o,onDraftChange:s,onEdit:c,onCancel:l,onDelete:u,onCorrect:d,onScopeChange:f}=e,p=(0,X.useId)(),[m,h]=(0,X.useState)(!1),g=r===`zh`,_;t[0]!==n||t[1]!==r?(_=nt(n,r),t[0]=n,t[1]=r,t[2]=_):_=t[2];let v=_,y;t[3]===n.sources?y=t[4]:(y=new Set(n.sources?.map(ot).filter(Boolean)),t[3]=n.sources,t[4]=y);let b;t[5]===y?b=t[6]:(b=[...y],t[5]=y,t[6]=b);let x=b,S=g?`修改`:`Edit`,C;return t[7]!==i||t[8]!==v||t[9]!==o||t[10]!==S||t[11]!==a||t[12]!==m||t[13]!==p||t[14]!==n||t[15]!==r||t[16]!==l||t[17]!==d||t[18]!==u||t[19]!==s||t[20]!==c||t[21]!==f||t[22]!==x||t[23]!==g?(C=(0,Q.jsx)(`article`,{className:`border-t border-edge-subtle px-4 py-3 first:border-t-0 sm:px-5 [content-visibility:auto] [contain-intrinsic-size:auto_100px]`,children:a?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:p,children:g?`修改这条理解`:`Edit this understanding`}),(0,Q.jsx)(`textarea`,{id:p,value:o,disabled:i,onChange:e=>s(e.target.value),className:`mt-2 min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-base leading-7 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(Y,{variant:`ghost`,disabled:i,onClick:l,children:g?`取消`:`Cancel`}),(0,Q.jsx)(Y,{variant:`primary`,disabled:!o.trim()||i,onClick:d,children:i?g?`保存中…`:`Saving…`:g?`保存修改`:`Save changes`})]})]}):(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-2 sm:flex sm:gap-4`,children:[(0,Q.jsxs)(`div`,{className:`contents min-w-0 flex-1 pt-1.5 sm:block`,children:[(0,Q.jsx)(`p`,{className:`col-span-2 whitespace-pre-wrap break-words text-base leading-7 text-fg`,children:!m&&n.statement.length>240?`${n.statement.slice(0,240)}…`:n.statement}),n.statement.length>240?(0,Q.jsx)(`button`,{type:`button`,"aria-expanded":m,onClick:()=>h(!m),className:`col-span-2 mt-1 min-h-11 rounded-md text-left text-sm text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:m?g?`收起全文`:`Show less`:g?`展开全文`:`Read more`}):null,(0,Q.jsxs)(`div`,{className:`col-start-1 mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs leading-5 text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:et(n,r)}),n.usable===!1?(0,Q.jsx)(`span`,{children:g?`暂不使用`:`Not in use`}):null,n.validTo?(0,Q.jsx)(`span`,{children:tt(n,r)}):null,n.authority!==`user_explicit`&&n.confidence<.65?(0,Q.jsx)(`span`,{children:v}):null,(0,Q.jsxs)(`details`,{className:`open:basis-full`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-11 w-fit cursor-pointer items-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:g?`查看来源`:`Sources`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:g?`来源与使用方式`:`Sources & use`})]}),(0,Q.jsxs)(`div`,{className:`my-2 space-y-1 border-l-2 border-edge pl-3 text-sm leading-6`,children:[(0,Q.jsx)(`p`,{children:n.usable===!1?g?`目前不会用于回答。`:`Currently not used in responses.`:g?`回答相关问题时,xopc 会参考这条信息。`:`xopc can refer to this when answering related questions.`}),(0,Q.jsxs)(`p`,{children:[g?`适用范围:`:`Applies to: `,rt(n.scope,r)]}),n.validTo?(0,Q.jsx)(`p`,{children:tt(n,r)}):null,v?(0,Q.jsxs)(`p`,{children:[g?`确定程度:`:`Confidence: `,v]}):null,(0,Q.jsxs)(`p`,{children:[g?`最近记录:`:`Last noted: `,Qe(n.observedAt,r)]}),x.length?x.map(at):(0,Q.jsx)(`p`,{children:g?`暂无更详细的来源记录`:`No further source details available`})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,Q.jsx)(Y,{variant:`ghost`,className:`min-h-11 min-w-11 px-2`,disabled:i,onClick:c,children:S}),(0,Q.jsx)(Xe,{language:r,busy:i,statement:n.statement,scope:n.scope,onEdit:c,onDelete:u,onScopeChange:f})]})]})}),t[7]=i,t[8]=v,t[9]=o,t[10]=S,t[11]=a,t[12]=m,t[13]=p,t[14]=n,t[15]=r,t[16]=l,t[17]=d,t[18]=u,t[19]=s,t[20]=c,t[21]=f,t[22]=x,t[23]=g,t[24]=C):C=t[24],C}function at(e){return(0,Q.jsx)(`p`,{className:`break-words`,children:e},e)}function ot(e){return e.label}var st={zh:{eyebrow:`全局用户理解`,title:`xopc 如何形成对你的理解`,subtitle:`这里汇总跨项目、跨对话形成的认识,并说明它们来自哪些渠道。项目事实不会混入你的个人画像。`,channels:`理解渠道`,channelHint:`查看来源及其最近更新。`,noChannels:`尚未通过任何渠道形成可展示的全局理解。`,activeCount:`{{count}} 条已在使用`,pendingCount:`{{count}} 条暂不使用`,noUnderstanding:`暂无来自此渠道的全局理解`,pending:`最近更新`,pendingHint:`自动整理并按需使用,你可以随时修改或删除。`,nothingPending:`尚未形成全局理解。`,showAll:`查看全部 {{count}} 条`,showLess:`收起`,done:`完成`,updating:`正在从已授权渠道更新理解;你可以先查看已有内容。`,sourceKinds:{user:`你明确告诉我的`,conversation:`对话与协作`,connector:`连接的服务`,work_folder:`工作目录`,local_source:`本机来源`,inference:`综合整理`}},en:{eyebrow:`Global user understanding`,title:`How xopc forms its understanding of you`,subtitle:`This brings together understanding formed across projects and conversations, with the channel behind each item. Project facts stay out of your personal portrait.`,channels:`Understanding channels`,channelHint:`View sources and their latest updates.`,noChannels:`No channel has formed displayable global understanding yet.`,activeCount:`{{count}} in use`,pendingCount:`{{count}} not in use`,noUnderstanding:`No usable global understanding has formed from this channel yet`,pending:`Recent updates`,pendingHint:`Organized automatically and used when relevant. Edit or delete anytime.`,nothingPending:`No understanding has formed yet.`,showAll:`View all {{count}}`,showLess:`Show less`,done:`Done`,updating:`Updating from authorized channels. You can review existing understanding now.`,sourceKinds:{user:`You told me`,conversation:`Conversations and work`,connector:`Connected services`,work_folder:`Work folders`,local_source:`On-device sources`,inference:`Synthesized understanding`}}},ct={"local-recent-files":{en:`Recent files`,zh:`最近文件`},"chromium-bookmarks":{en:`Recent bookmarks`,zh:`最近书签`},"apple-notes":{en:`Apple Notes`,zh:`Apple 备忘录`},"apple-mail":{en:`Apple Mail`,zh:`Apple 邮件`},"apple-calendar":{en:`Apple Calendar`,zh:`Apple 日历`},"apple-reminders":{en:`Apple Reminders`,zh:`Apple 提醒事项`},"windows-recent-documents":{en:`Recent documents`,zh:`最近文档`},"linux-recent-documents":{en:`Recent documents`,zh:`最近文档`}},lt={user:Oe,conversation:_e,connector:le,work_folder:fe,local_source:K,inference:le},ut={files:fe,recent_documents:K,calendar:ie,tasks:me,notes:Te,mail:q,messages:_e,code_activity:pe};function $(e){let t=e.authority===`user_explicit`?`user`:e.authority===`user_observed`?`conversation`:e.authority===`external_untrusted`?`connector`:`inference`;return{id:t,kind:t,observedAt:e.observedAt}}function dt(e,t){return e.kind===`local_source`&&e.label?ct[e.label]?.[t]??e.label:e.kind===`work_folder`&&e.label?t===`zh`?`工作目录 · ${e.label}`:`Work folder · ${e.label}`:e.label?e.label:st[t].sourceKinds[e.kind]}function ft(e){return`${e.kind}:${e.adapterId}:${e.displayName}`}function pt(e){let t=(0,Z.c)(91),{assertions:n,configuredSources:r,activityRunning:i,language:a,busy:o,error:s,onReviewAssertion:c,onCompleted:l}=e,u=st[a],[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(``),_;t[0]===n?_=t[1]:(_=n.filter(bt),t[0]=n,t[1]=_);let v=_,y;t[2]===v?y=t[3]:(y=[...v].sort(yt),t[2]=v,t[3]=y);let b=y,x;if(t[4]!==r||t[5]!==v||t[6]!==a){let e=new Map;for(let t of r){let n=t.kind===`local_source`?ct[t.adapterId]?.[a]??t.displayName:t.displayName,r=ft(t);e.set(r,{key:r,grantId:t.id,kind:t.kind,category:t.category,label:t.kind===`work_folder`?a===`zh`?`工作目录 · ${n}`:`Work folder · ${n}`:n,assertions:[],lastObservedAt:t.lastCollectedAt})}for(let t of v)for(let n of t.sources?.length?t.sources:[$(t)]){let r=dt(n,a),i=[...e.values()].find(e=>e.kind===n.kind&&e.label===r),o=i?.key??`${n.kind}:${r}`,s=i??e.get(o)??{key:o,kind:n.kind,category:n.category,label:r,assertions:[],lastObservedAt:n.observedAt};s.assertions.some(e=>e.id===t.id)||s.assertions.push(t),s.lastObservedAt=Math.max(s.lastObservedAt??0,n.observedAt),e.set(o,s)}x=[...e.values()].sort(vt),t[4]=r,t[5]=v,t[6]=a,t[7]=x}else x=t[7];let S=x,C;t[8]===c?C=t[9]:(C=async(e,t,n)=>{await c(e,t,n)&&m(null)},t[8]=c,t[9]=C);let w=C,T,E,D,O,k,A,j,M,ee;if(t[10]!==i||t[11]!==o||t[12]!==h||t[13]!==p||t[14]!==a||t[15]!==b||t[16]!==w||t[17]!==d||t[18]!==u.eyebrow||t[19]!==u.nothingPending||t[20]!==u.pending||t[21]!==u.pendingHint||t[22]!==u.showAll||t[23]!==u.showLess||t[24]!==u.subtitle||t[25]!==u.title||t[26]!==u.updating){let e=d?b:b.slice(0,5);T=`mx-auto w-full max-w-[42rem] pb-2`,E=`polite`;let n;t[36]===u.eyebrow?n=t[37]:(n=(0,Q.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-accent-fg`,children:u.eyebrow}),t[36]=u.eyebrow,t[37]=n);let r;t[38]===u.title?r=t[39]:(r=(0,Q.jsx)(`h2`,{className:`mt-3 text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:u.title}),t[38]=u.title,t[39]=r);let s;t[40]===u.subtitle?s=t[41]:(s=(0,Q.jsx)(`p`,{className:`mx-auto mt-3 max-w-[38rem] text-sm leading-6 text-fg-muted`,children:u.subtitle}),t[40]=u.subtitle,t[41]=s),t[42]!==n||t[43]!==r||t[44]!==s?(D=(0,Q.jsxs)(`div`,{className:`text-center`,children:[n,r,s]}),t[42]=n,t[43]=r,t[44]=s,t[45]=D):D=t[45],t[46]!==i||t[47]!==u.updating?(O=i?(0,Q.jsxs)(`div`,{className:`mt-6 flex items-center gap-3 rounded-xl border border-accent/20 bg-accent-soft/55 px-4 py-3 text-sm text-accent-fg`,children:[(0,Q.jsx)(he,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`}),(0,Q.jsx)(`p`,{children:u.updating})]}):null,t[46]=i,t[47]=u.updating,t[48]=O):O=t[48],k=`mt-8`,A=`understanding-updates-title`;let c=b.length?` · ${b.length}`:``;t[49]!==u.pending||t[50]!==c?(j=(0,Q.jsxs)(`h3`,{id:`understanding-updates-title`,className:`text-sm font-semibold text-fg`,children:[u.pending,c]}),t[49]=u.pending,t[50]=c,t[51]=j):j=t[51],t[52]===u.pendingHint?M=t[53]:(M=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.pendingHint}),t[52]=u.pendingHint,t[53]=M),ee=b.length?(0,Q.jsxs)(`div`,{className:`mt-3`,children:[$e(e,a).map(e=>{let{label:t,items:n}=e;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`border-b border-edge-subtle px-4 pb-2 pt-3 text-xs font-medium text-fg-muted`,children:t}),(0,Q.jsx)(`div`,{children:n.map(e=>(0,Q.jsx)(it,{item:e,language:a,busy:o,editing:p===e.id,draft:h,onDraftChange:g,onEdit:()=>{m(e.id),g(e.statement)},onCancel:()=>m(null),onCorrect:()=>void w(e,`edited`,h.trim()),onDelete:()=>void w(e,`deleted`)},e.id))})]},t)}),b.length>5?(0,Q.jsxs)(`button`,{type:`button`,className:`mx-auto flex items-center gap-1.5 px-3 py-2 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>f(_t),children:[d?u.showLess:u.showAll.replace(`{{count}}`,String(b.length)),(0,Q.jsx)(oe,{className:Ae(`size-3.5 transition-transform`,d&&`rotate-180`)})]}):null]}):(0,Q.jsxs)(`div`,{className:`mt-3 flex items-start gap-3 rounded-xl border border-edge bg-surface-base/55 p-4`,children:[(0,Q.jsx)(G,{className:`mt-0.5 size-5 shrink-0 text-success`}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:u.nothingPending})]}),t[10]=i,t[11]=o,t[12]=h,t[13]=p,t[14]=a,t[15]=b,t[16]=w,t[17]=d,t[18]=u.eyebrow,t[19]=u.nothingPending,t[20]=u.pending,t[21]=u.pendingHint,t[22]=u.showAll,t[23]=u.showLess,t[24]=u.subtitle,t[25]=u.title,t[26]=u.updating,t[27]=T,t[28]=E,t[29]=D,t[30]=O,t[31]=k,t[32]=A,t[33]=j,t[34]=M,t[35]=ee}else T=t[27],E=t[28],D=t[29],O=t[30],k=t[31],A=t[32],j=t[33],M=t[34],ee=t[35];let N;t[54]!==k||t[55]!==A||t[56]!==j||t[57]!==M||t[58]!==ee?(N=(0,Q.jsxs)(`section`,{className:k,"aria-labelledby":A,children:[j,M,ee]}),t[54]=k,t[55]=A,t[56]=j,t[57]=M,t[58]=ee,t[59]=N):N=t[59];let te;t[60]!==S.length||t[61]!==u.channels?(te=(0,Q.jsxs)(`summary`,{className:`w-fit cursor-pointer rounded-md py-2 text-sm font-medium text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u.channels,` · `,S.length]}),t[60]=S.length,t[61]=u.channels,t[62]=te):te=t[62];let P;t[63]===u.channelHint?P=t[64]:(P=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.channelHint}),t[63]=u.channelHint,t[64]=P);let F;t[65]!==S||t[66]!==u.activeCount||t[67]!==u.noChannels||t[68]!==u.noUnderstanding||t[69]!==u.pendingCount?(F=S.length?(0,Q.jsx)(`div`,{className:`mt-3 space-y-3`,children:S.map(e=>{let t=e.category?ut[e.category]??lt[e.kind]:lt[e.kind],n=e.assertions.filter(gt).length,r=e.assertions.filter(ht).length;return(0,Q.jsxs)(`article`,{className:`rounded-xl border border-edge bg-surface-base/55 px-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-surface-hover text-fg-muted`,children:(0,Q.jsx)(t,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),e.grantId?(0,Q.jsx)(Je,{sourceId:e.grantId,lastCollectedAt:e.lastObservedAt}):null,e.assertions.length?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[n?u.activeCount.replace(`{{count}}`,String(n)):``,r?u.pendingCount.replace(`{{count}}`,String(r)):``].filter(Boolean).join(` · `)}):(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.noUnderstanding})]}),e.grantId?(0,Q.jsx)(We,{sourceId:e.grantId}):null]}),e.assertions.length?(0,Q.jsx)(`ul`,{className:`ml-12 mt-3 space-y-2 border-t border-edge-subtle pt-3 text-xs leading-5 text-fg-muted`,children:e.assertions.slice(0,5).map(mt)}):null]},e.key)})}):(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl border border-edge bg-surface-base/55 p-4 text-sm text-fg-muted`,children:u.noChannels}),t[65]=S,t[66]=u.activeCount,t[67]=u.noChannels,t[68]=u.noUnderstanding,t[69]=u.pendingCount,t[70]=F):F=t[70];let I;t[71]!==te||t[72]!==P||t[73]!==F?(I=(0,Q.jsxs)(`details`,{className:`mt-6 border-t border-edge pt-4`,children:[te,P,F]}),t[71]=te,t[72]=P,t[73]=F,t[74]=I):I=t[74];let L;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(ae,{className:`size-4`}),t[75]=L):L=t[75];let R;t[76]!==o||t[77]!==l||t[78]!==u.done?(R=(0,Q.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,Q.jsxs)(Y,{variant:`primary`,disabled:o,onClick:l,children:[L,u.done]})}),t[76]=o,t[77]=l,t[78]=u.done,t[79]=R):R=t[79];let z;t[80]===s?z=t[81]:(z=s?(0,Q.jsx)(`p`,{className:`mt-5 text-sm text-danger`,role:`alert`,children:s}):null,t[80]=s,t[81]=z);let B;return t[82]!==T||t[83]!==E||t[84]!==D||t[85]!==O||t[86]!==N||t[87]!==I||t[88]!==R||t[89]!==z?(B=(0,Q.jsxs)(`section`,{className:T,"aria-live":E,children:[D,O,N,I,R,z]}),t[82]=T,t[83]=E,t[84]=D,t[85]=O,t[86]=N,t[87]=I,t[88]=R,t[89]=z,t[90]=B):B=t[90],B}function mt(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent/60`}),(0,Q.jsx)(`span`,{children:e.statement})]},e.id)}function ht(e){return!e.usable}function gt(e){return e.usable}function _t(e){return!e}function vt(e,t){return t.assertions.length-e.assertions.length||(t.lastObservedAt??0)-(e.lastObservedAt??0)}function yt(e,t){return t.recordedAt-e.recordedAt}function bt(e){return e.scope.type===`global`&&e.status!==`archived`&&e.status!==`rejected`}function xt(){let{pathname:e,search:t}=i(),n=c(e=>e.language),r=J(),[a,o]=(0,X.useState)(!1),[s,l]=(0,X.useState)(null),v=e===`/user-model`,{data:y,mutate:b}=Me(v?`/api/user-model`:null,M),x=L(e=>e.error),S=L(e=>e.sources.some(e=>e.status===`running`||e.status===`queued`)),C=n===`zh`;if((0,X.useEffect)(()=>{v&&new URLSearchParams(t).get(`workDiscovery`)===`review`&&J.getState().setDrawerOpen(!0)},[v,t]),(0,X.useEffect)(()=>{v&&r.status!==`running`&&b()},[b,v,r.directoryRun?.id,r.status]),!v)return null;let T=r.status===`running`||S,E=async(e,t,n)=>{o(!0),l(null);try{return t===`edited`&&n?await N(e.id,n):t===`deleted`&&await w(e.id),await b(),!0}catch(e){return l(e instanceof Error?e.message:String(e)),!1}finally{o(!1)}},D=e=>{if(!e&&y&&r.status!==`running`){r.finish();return}r.setDrawerOpen(e)};return(0,Q.jsxs)(_,{open:r.drawerOpen,onOpenChange:D,children:[(0,Q.jsx)(d,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:Ae(`relative size-8 rounded-xl p-0`,Ne),title:C?`查看 xopc 对你的理解`:`Review what xopc understands`,"aria-label":C?`查看 xopc 对你的理解`:`Review what xopc understands`,children:T?(0,Q.jsx)(he,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,Q.jsx)(we,{className:`size-4 text-accent-fg`})})}),(0,Q.jsxs)(m,{children:[(0,Q.jsx)(u,{className:`fixed inset-0 z-[60] bg-scrim backdrop-blur-sm data-[state=closed]:animate-out data-[state=open]:animate-in motion-reduce:backdrop-blur-none`}),(0,Q.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] flex items-center justify-center p-3 sm:p-6`,children:(0,Q.jsxs)(h,{className:`xopc-understanding-center pointer-events-auto flex h-[min(42rem,calc(100dvh-1.5rem))] w-[min(44rem,calc(100vw-1.5rem))] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float outline-none sm:h-[min(42rem,calc(100dvh-3rem))] sm:w-[min(44rem,calc(100vw-3rem))]`,children:[(0,Q.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center justify-between border-b border-edge-subtle px-5 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(g,{className:`text-sm font-semibold text-fg`,children:T?C?`正在更新用户理解`:`Updating user understanding`:C?`用户理解`:`User understanding`}),(0,Q.jsx)(f,{className:`mt-0.5 text-xs text-fg-muted`,children:T?C?`关闭窗口也会在后台继续`:`You can close this window; work continues in the background`:C?`自动更新,可随时修改或删除`:`Updated automatically. Edit or delete anytime`})]}),(0,Q.jsx)(We,{disabled:!y?.sources?.length}),(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-8 rounded-xl p-0`,"aria-label":C?`关闭`:`Close`,children:(0,Q.jsx)(ke,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-7 sm:px-9 sm:py-9`,children:y?(0,Q.jsx)(pt,{assertions:y.assertions,configuredSources:y.sources??[],activityRunning:T,language:n,busy:a,error:s??x??null,onReviewAssertion:E,onCompleted:()=>{D(!1)}}):(0,Q.jsxs)(`section`,{className:`space-y-4`,"aria-label":C?`正在加载用户理解`:`Loading user understanding`,children:[(0,Q.jsx)(je,{className:`h-8 w-2/3`}),(0,Q.jsx)(je,{className:`h-32 w-full`}),(0,Q.jsx)(je,{className:`h-32 w-full`})]})})]})})]})]})}function St(e){let t=(0,Z.c)(34),{language:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={refreshInterval:15e3},t[0]=r):r=t[0];let{data:i,error:a,isLoading:o}=Me(`memory-learning-status`,Nt,r);if(o){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(je,{className:`h-14 w-full rounded-xl`}),t[1]=e):e=t[1],e}if(a||!i?.jobs||!i?.coverage)return null;let s;t[2]===i.jobs?s=t[3]:(s=i.jobs.filter(Mt).reduce(jt,0),t[2]=i.jobs,t[3]=s);let c=s,l;t[4]===i.coverage?l=t[5]:(l=i.coverage.filter(At).reduce(kt,0),t[4]=i.coverage,t[5]=l);let u=l,d;t[6]===i.coverage?d=t[7]:(d=i.coverage.filter(Ot).reduce(Dt,0),t[6]=i.coverage,t[7]=d);let f=d,p;t[8]===i.jobs?p=t[9]:(p=i.jobs.filter(Et).reduce(Tt,0),t[8]=i.jobs,t[9]=p);let m=p,h;t[10]===i.jobs?h=t[11]:(h=i.jobs.filter(wt).reduce(Ct,0),t[10]=i.jobs,t[11]=h);let g=h,_=n===`zh`?`资料 ${f} 条 · 已生效记忆 ${u} 条`:`${f} sources · ${u} active memories`,v;t[12]!==n||t[13]!==c?(v=c>0?(0,Q.jsx)(`span`,{className:`ml-2`,children:n===`zh`?`${c} 项处理中`:`${c} processing`}):null,t[12]=n,t[13]=c,t[14]=v):v=t[14];let y=n===`zh`?`计数说明`:`About these counts`,b;t[15]===y?b=t[16]:(b=(0,Q.jsx)(`summary`,{className:`w-fit cursor-pointer rounded focus-visible:outline-accent`,children:y}),t[15]=y,t[16]=b);let x=n===`zh`?`仅统计已启用且有依据的工作记忆;管理列表包含其他状态。“关于你”单独计数。`:`Work memories must be active and supported. Management lists include other states. About you is counted separately.`,S;t[17]===x?S=t[18]:(S=(0,Q.jsx)(`p`,{className:`mt-1 leading-5`,children:x}),t[17]=x,t[18]=S);let C;t[19]!==b||t[20]!==S?(C=(0,Q.jsxs)(`details`,{className:`mt-1 text-xs`,children:[b,S]}),t[19]=b,t[20]=S,t[21]=C):C=t[21];let w;t[22]!==m||t[23]!==n?(w=m>0?(0,Q.jsx)(`span`,{className:`ml-2`,children:n===`zh`?`${m} 项处理失败`:`${m} failed jobs`}):null,t[22]=m,t[23]=n,t[24]=w):w=t[24];let T;t[25]!==n||t[26]!==g?(T=g>0?(0,Q.jsx)(`span`,{className:`ml-2`,children:n===`zh`?`${g} 项等待配置本地模型`:`${g} jobs require a local model`}):null,t[25]=n,t[26]=g,t[27]=T):T=t[27];let E;return t[28]!==C||t[29]!==w||t[30]!==T||t[31]!==_||t[32]!==v?(E=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base px-4 py-3 text-sm text-fg-muted`,role:`status`,children:[_,v,C,w,T]}),t[28]=C,t[29]=w,t[30]=T,t[31]=_,t[32]=v,t[33]=E):E=t[33],E}function Ct(e,t){return e+t.count}function wt(e){return e.errorCode===`local_model_required`}function Tt(e,t){return e+t.count}function Et(e){return e.state===`failed`}function Dt(e,t){return e+t.count}function Ot(e){return e.recordClass===`source_index`}function kt(e,t){return e+t.count}function At(e){return e.recordClass===`memory`&&e.status===`active`&&e.verification===`supported`}function jt(e,t){return e+t.count}function Mt(e){return[`queued`,`running`,`retry_wait`].includes(e.state)}function Nt(){return l(s(`/api/memory-learning/status`))}function Pt(e){let t=(0,Z.c)(12),{id:n,language:r}=e,i;t[0]===n?i=t[1]:(i=()=>l(s(`/api/knowledge-memory/${encodeURIComponent(n)}/evidence`)),t[0]=n,t[1]=i);let{data:a,error:o,isLoading:c}=Me(`knowledge-evidence:${n}`,i);if(c){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(je,{className:`mt-3 h-10 w-full rounded-lg`}),t[2]=e):e=t[2],e}if(o){let e=r===`zh`?`此条证据目前不可用于回答,请检查来源授权、有效期和读取范围。`:`Evidence is currently unavailable. Check source authorization, validity and read scope.`,n;return t[3]===e?n=t[4]:(n=(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:e}),t[3]=e,t[4]=n),n}if(!Array.isArray(a?.evidence)||!a.evidence.length)return null;let u;if(t[5]!==a.evidence||t[6]!==r){let e;t[8]===r?e=t[9]:(e=(e,t)=>(0,Q.jsxs)(`p`,{children:[r===`zh`?`证据`:`Evidence`,` · `,e.sourceType===`conversation`?r===`zh`?`对话`:`Conversation`:e.sourceType===`runtime`?r===`zh`?`执行记录`:`Execution receipt`:r===`zh`?`授权资料`:`Authorized source`,` · `,new Date(e.observedAt).toLocaleDateString(r),e.excerpt?(0,Q.jsx)(`span`,{className:`mt-1 block whitespace-pre-wrap break-words`,children:e.excerpt}):null]},t),t[8]=r,t[9]=e),u=a.evidence.map(e),t[5]=a.evidence,t[6]=r,t[7]=u}else u=t[7];let d;return t[10]===u?d=t[11]:(d=(0,Q.jsx)(`div`,{className:`mt-3 space-y-2 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:u}),t[10]=u,t[11]=d),d}function Ft(e){let t=e.get(`tab`);return t===`understanding`&&e.get(`section`)===`work`?`work`:t===`understanding`||t===`work`||t===`privacy`?t:`overview`}var It={en:{pageTitle:`About you`,overview:`Overview`,understanding:`What xopc knows`,privacy:`Data & privacy`,knowledge:`Work memory`,editProfile:`Edit basics`,callName:`What should xopc call you?`,callNamePlaceholder:`For example: Alex, Joyce, or Dr. Chen`,role:`Your role`,rolePlaceholder:`For example: founder, designer, or engineer`,pronouns:`Pronouns (optional)`,pronounsPlaceholder:`For example: she/her, he/him, they/them`,timezone:`Timezone`,timezoneSearch:`Search timezones…`,timezoneNoMatch:`No matching timezone`,locale:`Language / locale`,useDeviceTimezone:`Use this device`,notProvided:`Not provided`,editProfileHint:`These are facts you provide directly. They remain separate from xopc’s observations and inferences.`,saveProfile:`Save`,saving:`Saving…`,explicit:`You told me`,explicitHint:`Facts and preferences you stated directly`,learned:`Learned together`,learnedHint:`Patterns formed from our work`,allUnderstanding:`All understanding`,understandingFilterHint:`Filter this view by how each item was formed.`,importantNow:`What matters now`,prioritySourceGoal:`From a goal you confirmed`,prioritySourceWork:`From your current work`,editPriority:`Edit focus`,addPriority:`Set current focus`,priorityTitle:`Current focus`,priorityTitlePlaceholder:`What matters most right now?`,priorityOutcome:`What a good outcome looks like`,priorityOutcomePlaceholder:`Describe the result you want…`,priorityUntil:`Focus through`,savePriority:`Save focus`,endPriority:`End focus`,endingPriority:`Ending…`,priorityHint:`This is used to keep xopc aligned with what deserves attention now.`,otherGoals:`Other active outcomes`,howWeWork:`How we work together`,noRules:`No collaboration preferences yet.`,seeAll:`See all`,workMemory:`What I remember from the work`,items:`items`,refresh:`Refresh`,refreshing:`Refreshing…`,refreshComplete:`Refreshed`,refreshFailed:`Refresh failed`,aboutYouTitle:`What xopc remembers about you`,aboutYouHint:`Review your background, preferences, and habits. Edit anything that no longer fits.`,identity:`Who you are`,preferences:`Preferences and working rhythm`,relationships:`People and relationships`,currentState:`Current context`,insights:`My current read`,emptyGroup:`No usable personal understanding yet. Ongoing preferences will build through collaboration; project facts and progress are in Work memory.`,correct:`Correct`,save:`Save correction`,cancel:`Cancel`,correctionPlaceholder:`Write the accurate version…`,searchPlaceholder:`Search work memory…`,allMemory:`All work memory`,memoryFilterHint:`Filter by memory type`,memoryLibraryHint:`Only distilled facts, decisions, lessons, commitments, and open questions appear here. Source records stay with their connector.`,noKnowledge:`No work memory has formed yet.`,noKnowledgeMatch:`No work memory matches this search.`,showMore:`Show more`,expand:`Show details`,collapse:`Hide details`,disable:`Disable`,disabled:`Not in use`,enable:`Enable`,loadFailed:`Could not load your understanding.`,tryAgain:`Try again`,actionFailed:`The change could not be saved. Please try again.`},zh:{pageTitle:`关于你`,overview:`总览`,understanding:`对我的了解`,privacy:`数据与隐私`,knowledge:`工作记忆`,editProfile:`编辑基本信息`,callName:`希望 xopc 如何称呼你?`,callNamePlaceholder:`例如:Mic、Joyce、张老师`,role:`你的角色`,rolePlaceholder:`例如:创业者、产品设计师、工程师`,pronouns:`代词(可选)`,pronounsPlaceholder:`例如:she/her、he/him、they/them`,timezone:`时区`,timezoneSearch:`搜索时区…`,timezoneNoMatch:`没有匹配的时区`,locale:`语言 / 地区`,useDeviceTimezone:`使用本机时区`,notProvided:`未填写`,editProfileHint:`这些是由你直接提供的事实,与 xopc 的观察和推断分开维护。`,saveProfile:`保存`,saving:`正在保存…`,explicit:`你告诉我的`,explicitHint:`你明确表达的事实与偏好`,learned:`协作中学到的`,learnedHint:`从实际协作中形成的认识`,allUnderstanding:`全部来源`,understandingFilterHint:`按内容来源筛选这份理解。`,importantNow:`你最近在关注什么`,prioritySourceGoal:`来自你确认的当前目标`,prioritySourceWork:`来自当前工作上下文`,editPriority:`编辑`,addPriority:`设置当前关注`,priorityTitle:`当前关注`,priorityTitlePlaceholder:`现在最重要的是什么?`,priorityOutcome:`期待结果`,priorityOutcomePlaceholder:`描述你希望达成的结果…`,priorityUntil:`关注至`,savePriority:`保存关注`,endPriority:`结束关注`,endingPriority:`正在结束…`,priorityHint:`这项内容会帮助 xopc 在协作中优先关注当前最重要的事情。`,otherGoals:`其他进行中的目标`,howWeWork:`我们怎样协作`,noRules:`还没有形成协作偏好。`,seeAll:`查看全部`,workMemory:`我在工作中记住的`,items:`条`,refresh:`刷新`,refreshing:`正在刷新…`,refreshComplete:`已刷新`,refreshFailed:`刷新失败`,aboutYouTitle:`xopc 记住的你`,aboutYouHint:`在这里查看你的背景、偏好和习惯。有不准确或已经变化的内容,可以直接修改。`,identity:`你的背景与能力`,preferences:`偏好与习惯`,relationships:`重要的人与关系`,currentState:`最近的状态`,insights:`其他观察`,emptyGroup:`还没有记住关于你的信息。你可以在聊天中告诉 xopc 你的背景或偏好,例如「回答时先给结论」。`,correct:`修正`,save:`保存修正`,cancel:`取消`,correctionPlaceholder:`写下更准确的说法…`,searchPlaceholder:`搜索工作记忆…`,allMemory:`全部工作记忆`,memoryFilterHint:`按记忆类型筛选`,memoryLibraryHint:`这里只显示提炼后的事实、决定、经验、承诺和待解问题;邮件、日历与文档原文保留在对应来源中。`,noKnowledge:`还没有形成工作记忆。`,noKnowledgeMatch:`没有符合搜索条件的工作记忆。`,showMore:`显示更多`,expand:`查看详情`,collapse:`收起详情`,disable:`停用`,disabled:`已停用`,enable:`启用`,loadFailed:`无法载入对你的理解。`,tryAgain:`重试`,actionFailed:`修改没有保存,请重试。`}},Lt=new Set([`identity.call_name`,`identity.role`,`identity.pronouns`,`preference.timezone`,`preference.locale`]),Rt=[`work_thread`,`project_fact`,`workspace_fact`,`decision`,`task_lesson`,`commitment`,`open_question`,`episode`,`note`],zt=`UTC.Africa/Cairo.Africa/Johannesburg.America/Chicago.America/Denver.America/Los_Angeles.America/Mexico_City.America/New_York.America/Sao_Paulo.America/Toronto.America/Vancouver.Asia/Bangkok.Asia/Dubai.Asia/Hong_Kong.Asia/Jakarta.Asia/Kolkata.Asia/Seoul.Asia/Shanghai.Asia/Singapore.Asia/Taipei.Asia/Tokyo.Australia/Melbourne.Australia/Perth.Australia/Sydney.Europe/Amsterdam.Europe/Berlin.Europe/London.Europe/Madrid.Europe/Paris.Europe/Rome.Pacific/Auckland.Pacific/Honolulu`.split(`.`);function Bt(){try{let e=Intl.supportedValuesOf(`timeZone`);return[...new Set([`UTC`,...e])]}catch{return[...zt]}}var Vt=Bt();function Ht(e){return e.map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.includes(`/`)?e.split(`/`)[0]:`UTC`}))}function Ut(e,t,n=!1){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,...n?{timeStyle:`short`}:{}}).format(e):null}function Wt(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Gt(e){return{callName:Wt(e.profile.callName)??``,role:Wt(e.profile.role)??``,pronouns:Wt(e.profile.pronouns)??``,timezone:Wt(e.profile.timezone)??``,locale:Wt(e.profile.locale)??``}}function Kt(e,t){return{"zh-CN":{en:`Simplified Chinese`,zh:`简体中文`},"zh-TW":{en:`Traditional Chinese`,zh:`繁体中文`},"en-US":{en:`English (US)`,zh:`英语(美国)`},"en-GB":{en:`English (UK)`,zh:`英语(英国)`},"ja-JP":{en:`Japanese`,zh:`日语`}}[e]?.[t]??e}function qt(e,t){let n=Ut(e,t);return t===`zh`?`当前安排至 ${n}`:`Current plan through ${n}`}function Jt(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Yt(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r,23,59,59,999).getTime()}function Xt(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function Zt(e,t){return(t===`zh`?{work_thread:`工作主线`,project_fact:`项目事实`,workspace_fact:`工作区事实`,decision:`已经决定`,task_lesson:`工作经验`,commitment:`承诺与约定`,open_question:`待解问题`,episode:`重要经历`,note:`其他记录`}:{work_thread:`Work threads`,project_fact:`Project facts`,workspace_fact:`Workspace facts`,decision:`Decisions`,task_lesson:`Lessons`,commitment:`Commitments`,open_question:`Open questions`,episode:`Episodes`,note:`Notes`})[e]}function Qt(e,t,n){if(e)return e.targetType===`goal`?t.find(t=>t.id===e.targetId)?.title:/^[0-9a-f]{8}-[0-9a-f-]{20,}$/i.test(e.targetId)?(n===`zh`?{project:`当前项目`,task:`当前任务`,assertion:`一项待处理的理解`,topic:`当前主题`}:{project:`Current project`,task:`Current task`,assertion:`An understanding to address`,topic:`Current topic`})[e.targetType]:e.targetId}function $t(e){let t=(0,Z.c)(16),{title:n,hint:r,action:i,children:a,className:o}=e,s=o===void 0?``:o,c;t[0]===n?c=t[1]:(c=(0,Q.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n}),t[0]=n,t[1]=c);let l;t[2]===r?l=t[3]:(l=r?(0,Q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:r}):null,t[2]=r,t[3]=l);let u;t[4]!==c||t[5]!==l?(u=(0,Q.jsxs)(`div`,{children:[c,l]}),t[4]=c,t[5]=l,t[6]=u):u=t[6];let d;t[7]!==i||t[8]!==u?(d=(0,Q.jsxs)(`header`,{className:`flex items-end justify-between gap-4 px-1 pb-3`,children:[u,i]}),t[7]=i,t[8]=u,t[9]=d):d=t[9];let f;t[10]===a?f=t[11]:(f=(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-2xl bg-surface-panel`,children:a}),t[10]=a,t[11]=f);let p;return t[12]!==s||t[13]!==d||t[14]!==f?(p=(0,Q.jsxs)(`section`,{className:s,children:[d,f]}),t[12]=s,t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function en(e){let t=(0,Z.c)(7),{icon:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`span`,{className:`text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Q.jsx)(`p`,{children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-5 text-sm text-fg-muted`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function tn({open:e,profile:t,language:n,saving:r,onOpenChange:i,onSave:a}){let o=It[n],[s,c]=(0,X.useState)(t),[l,d]=(0,X.useState)(``);(0,X.useEffect)(()=>{e&&(c(t),d(``))},[e,t]);let v=e=>{e.preventDefault(),a({callName:s.callName.trim(),role:s.role.trim(),pronouns:s.pronouns.trim(),timezone:s.timezone.trim(),locale:s.locale.trim()})},y=(e,t,n)=>(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Q.jsx)(`input`,{value:s[e],onChange:t=>c(n=>({...n,[e]:t.target.value})),placeholder:n,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),b=[`zh-CN`,`zh-TW`,`en-US`,`en-GB`,`ja-JP`];s.locale&&!b.includes(s.locale)&&b.push(s.locale);let x=I(),S=(0,X.useMemo)(()=>[...new Set([...Vt,x,s.timezone].filter(Boolean))].sort(),[x,s.timezone]),C=l.trim().toLocaleLowerCase(),w=(0,X.useMemo)(()=>Ht(S.filter(e=>!C||e.toLocaleLowerCase().includes(C)||e.replaceAll(`_`,` `).toLocaleLowerCase().includes(C))),[S,C]);return(0,Q.jsx)(_,{open:e,onOpenChange:i,children:(0,Q.jsxs)(m,{children:[(0,Q.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsx)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] h-[min(40rem,calc(100vh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:(0,Q.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col overflow-hidden [border-radius:inherit]`,onSubmit:v,children:[(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:o.editProfile}),(0,Q.jsx)(f,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.editProfileHint})]}),(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o.cancel,children:(0,Q.jsx)(ke,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5 sm:p-6`,children:(0,Q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[y(`callName`,o.callName,o.callNamePlaceholder),y(`role`,o.role,o.rolePlaceholder),y(`pronouns`,o.pronouns,o.pronounsPlaceholder),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:o.locale}),(0,Q.jsxs)(H,{value:s.locale,onChange:e=>c(t=>({...t,locale:e.target.value})),children:[(0,Q.jsx)(U,{value:``,children:o.notProvided}),b.map(e=>(0,Q.jsx)(U,{value:e,children:Kt(e,n)},e))]})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:col-span-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:o.timezone}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(W,{value:s.timezone,options:w,placeholder:I(),emptyLabel:o.notProvided,ariaLabel:o.timezone,selectedLabel:s.timezone||o.notProvided,searchPlaceholder:o.timezoneSearch,searchValue:l,onSearchChange:d,statusMessage:w.length?void 0:o.timezoneNoMatch,triggerClassName:`min-w-0 flex-1 rounded-xl bg-surface-base`,onChange:e=>{c(t=>({...t,timezone:e})),d(``)}}),(0,Q.jsx)(Y,{className:`shrink-0 whitespace-nowrap`,onClick:()=>c(e=>({...e,timezone:x})),children:o.useDeviceTimezone})]})]})]})}),(0,Q.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{disabled:r,children:o.cancel})}),(0,Q.jsxs)(Y,{type:`submit`,variant:`primary`,disabled:r,children:[r?(0,Q.jsx)(he,{className:`size-4 animate-spin`}):null,r?o.saving:o.saveProfile]})]})]})})]})})}function nn(e){let t=(0,Z.c)(94),{open:n,priority:r,title:i,outcome:a,language:o,saving:s,onOpenChange:c,onSave:l,onEnd:d}=e,v=It[o],[y,b]=(0,X.useState)(i),[x,S]=(0,X.useState)(a??``),C=r?.validTo??Date.now()+6048e5,w;t[0]===C?w=t[1]:(w=Jt(C),t[0]=C,t[1]=w);let T=w,[E,D]=(0,X.useState)(T),O,k;t[2]!==T||t[3]!==n||t[4]!==a||t[5]!==i?(O=()=>{n&&(b(i),S(a??``),D(T))},k=[T,n,a,i],t[2]=T,t[3]=n,t[4]=a,t[5]=i,t[6]=O,t[7]=k):(O=t[6],k=t[7]),(0,X.useEffect)(O,k);let A;t[8]!==x||t[9]!==y||t[10]!==E||t[11]!==l||t[12]!==r?.targetType?(A=e=>{e.preventDefault(),l({title:y.trim(),...r?.targetType===`goal`?{desiredOutcome:x.trim()}:{},validTo:Yt(E)})},t[8]=x,t[9]=y,t[10]=E,t[11]=l,t[12]=r?.targetType,t[13]=A):A=t[13];let j=A,M;t[14]!==x||t[15]!==y||t[16]!==E||t[17]!==r?.targetType?(M=y.trim()&&E&&(r?.targetType!==`goal`||x.trim()),t[14]=x,t[15]=y,t[16]=E,t[17]=r?.targetType,t[18]=M):M=t[18];let ee=!!M,N;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[19]=N):N=t[19];let te=r?v.editPriority:v.addPriority,P;t[20]===te?P=t[21]:(P=(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:te}),t[20]=te,t[21]=P);let F;t[22]===v.priorityHint?F=t[23]:(F=(0,Q.jsx)(f,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:v.priorityHint}),t[22]=v.priorityHint,t[23]=F);let I;t[24]!==F||t[25]!==P?(I=(0,Q.jsxs)(`div`,{children:[P,F]}),t[24]=F,t[25]=P,t[26]=I):I=t[26];let L;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(ke,{className:`size-4`}),t[27]=L):L=t[27];let R;t[28]===v.cancel?R=t[29]:(R=(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":v.cancel,children:L})}),t[28]=v.cancel,t[29]=R);let z;t[30]!==I||t[31]!==R?(z=(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[I,R]}),t[30]=I,t[31]=R,t[32]=z):z=t[32];let B;t[33]===v.priorityTitle?B=t[34]:(B=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:v.priorityTitle}),t[33]=v.priorityTitle,t[34]=B);let ne;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>b(e.target.value),t[35]=ne):ne=t[35];let re;t[36]!==y||t[37]!==v.priorityTitlePlaceholder?(re=(0,Q.jsx)(`input`,{autoFocus:!0,value:y,onChange:ne,placeholder:v.priorityTitlePlaceholder,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[36]=y,t[37]=v.priorityTitlePlaceholder,t[38]=re):re=t[38];let ie;t[39]!==B||t[40]!==re?(ie=(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[B,re]}),t[39]=B,t[40]=re,t[41]=ie):ie=t[41];let ae;t[42]!==x||t[43]!==r?.targetType||t[44]!==v.priorityOutcome||t[45]!==v.priorityOutcomePlaceholder?(ae=r?.targetType===`goal`?(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:v.priorityOutcome}),(0,Q.jsx)(`textarea`,{value:x,onChange:e=>S(e.target.value),placeholder:v.priorityOutcomePlaceholder,className:`min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}):null,t[42]=x,t[43]=r?.targetType,t[44]=v.priorityOutcome,t[45]=v.priorityOutcomePlaceholder,t[46]=ae):ae=t[46];let oe;t[47]===v.priorityUntil?oe=t[48]:(oe=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:v.priorityUntil}),t[47]=v.priorityUntil,t[48]=oe);let V;t[49]===r?.validFrom?V=t[50]:(V=r?.validFrom??Date.now(),t[49]=r?.validFrom,t[50]=V);let H;t[51]===V?H=t[52]:(H=Jt(V),t[51]=V,t[52]=H);let U;t[53]!==E||t[54]!==v.priorityUntil||t[55]!==H?(U=(0,Q.jsx)(Ue,{min:H,value:E,onChange:D,ariaLabel:v.priorityUntil,className:`rounded-xl border border-edge bg-surface-base hover:border-edge-strong hover:bg-surface-base`}),t[53]=E,t[54]=v.priorityUntil,t[55]=H,t[56]=U):U=t[56];let W;t[57]!==oe||t[58]!==U?(W=(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[oe,U]}),t[57]=oe,t[58]=U,t[59]=W):W=t[59];let se;t[60]!==ie||t[61]!==ae||t[62]!==W?(se=(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5 sm:p-6`,children:[ie,ae,W]}),t[60]=ie,t[61]=ae,t[62]=W,t[63]=se):se=t[63];let G;t[64]!==d||t[65]!==r||t[66]!==s||t[67]!==v.endPriority||t[68]!==v.endingPriority?(G=r&&d?(0,Q.jsxs)(Y,{variant:`ghost`,className:`text-danger hover:text-danger`,disabled:s,onClick:d,children:[s?(0,Q.jsx)(he,{className:`size-4 animate-spin`}):null,s?v.endingPriority:v.endPriority]}):(0,Q.jsx)(`span`,{}),t[64]=d,t[65]=r,t[66]=s,t[67]=v.endPriority,t[68]=v.endingPriority,t[69]=G):G=t[69];let ce;t[70]!==s||t[71]!==v.cancel?(ce=(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{disabled:s,children:v.cancel})}),t[70]=s,t[71]=v.cancel,t[72]=ce):ce=t[72];let le=!ee||s,ue;t[73]===s?ue=t[74]:(ue=s?(0,Q.jsx)(he,{className:`size-4 animate-spin`}):null,t[73]=s,t[74]=ue);let de;t[75]!==v.savePriority||t[76]!==le||t[77]!==ue?(de=(0,Q.jsxs)(Y,{type:`submit`,variant:`primary`,disabled:le,children:[ue,v.savePriority]}),t[75]=v.savePriority,t[76]=le,t[77]=ue,t[78]=de):de=t[78];let K;t[79]!==ce||t[80]!==de?(K=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[ce,de]}),t[79]=ce,t[80]=de,t[81]=K):K=t[81];let q;t[82]!==G||t[83]!==K?(q=(0,Q.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[G,K]}),t[82]=G,t[83]=K,t[84]=q):q=t[84];let J;t[85]!==j||t[86]!==z||t[87]!==se||t[88]!==q?(J=(0,Q.jsxs)(m,{children:[N,(0,Q.jsx)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] h-[min(34rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:(0,Q.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col overflow-hidden [border-radius:inherit]`,onSubmit:j,children:[z,se,q]})})]}),t[85]=j,t[86]=z,t[87]=se,t[88]=q,t[89]=J):J=t[89];let fe;return t[90]!==c||t[91]!==n||t[92]!==J?(fe=(0,Q.jsx)(_,{open:n,onOpenChange:c,children:J}),t[90]=c,t[91]=n,t[92]=J,t[93]=fe):fe=t[93],fe}function rn(e){let t=(0,Z.c)(16),{rule:n,language:r,busy:i,onToggle:a}=e,o=It[r],s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),t[0]=s):s=t[0];let c;t[1]===n.statement?c=t[2]:(c=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-sm leading-6 text-fg`,children:n.statement}),t[1]=n.statement,t[2]=c);let l;t[3]!==n.status||t[4]!==o.disabled?(l=n.status===`disabled`?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.disabled}):null,t[3]=n.status,t[4]=o.disabled,t[5]=l):l=t[5];let u=n.status===`active`?o.disable:o.enable,d;t[6]!==i||t[7]!==a||t[8]!==u?(d=(0,Q.jsx)(Y,{variant:`ghost`,className:`h-8`,disabled:i,onClick:a,children:u}),t[6]=i,t[7]=a,t[8]=u,t[9]=d):d=t[9];let f;t[10]!==l||t[11]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==c||t[14]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-t border-edge-subtle px-5 py-3 first:border-t-0`,children:[s,c,f]}),t[13]=c,t[14]=f,t[15]=p):p=t[15],p}function an(e){let t=(0,Z.c)(15),{suggestion:n,language:r,busy:i,onConfirm:a}=e,o=r===`zh`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(we,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),t[0]=s):s=t[0];let c;t[1]===n.statement?c=t[2]:(c=(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),t[1]=n.statement,t[2]=c);let l=o?`根据你已确认的模式生成;确认前不会生效`:`Suggested from a pattern you confirmed; inactive until you approve`,u;t[3]===l?u=t[4]:(u=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:l}),t[3]=l,t[4]=u);let d;t[5]!==c||t[6]!==u?(d=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[c,u]}),t[5]=c,t[6]=u,t[7]=d):d=t[7];let f=i?o?`启用中…`:`Enabling…`:o?`确认启用`:`Approve`,p;t[8]!==i||t[9]!==a||t[10]!==f?(p=(0,Q.jsx)(Y,{variant:`secondary`,className:`h-8 shrink-0`,disabled:i,onClick:a,children:f}),t[8]=i,t[9]=a,t[10]=f,t[11]=p):p=t[11];let m;return t[12]!==d||t[13]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-t border-edge-subtle px-5 py-3 first:border-t-0`,children:[s,d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14],m}function on(e){let t=(0,Z.c)(27),{item:n,language:r,busy:i,expanded:a,onToggle:o,editing:s,draft:c,onDraftChange:l,onEdit:u,onCancel:d,onReview:f,onDelete:p,onScopeChange:m}=e,h=It[r],g=n.updatedAt??n.createdAt,_;t[0]!==r||t[1]!==g?(_=Ut(g,r),t[0]=r,t[1]=g,t[2]=_):_=t[2];let y=_,b;t[3]!==n.claimMode||t[4]!==n.content?(b=n.content.length>96||n.content.includes(`
2
+ `)||!!n.claimMode,t[3]=n.claimMode,t[4]=n.content,t[5]=b):b=t[5];let x=b,S;return t[6]!==i||t[7]!==x||t[8]!==y||t[9]!==c||t[10]!==s||t[11]!==a||t[12]!==n.claimMode||t[13]!==n.content||t[14]!==n.id||t[15]!==n.scope||t[16]!==n.verification||t[17]!==r||t[18]!==d||t[19]!==p||t[20]!==l||t[21]!==u||t[22]!==f||t[23]!==m||t[24]!==o||t[25]!==h?(S=(0,Q.jsx)(`article`,{className:`group border-t border-edge-subtle px-5 py-4 first:border-t-0 sm:px-6`,children:s?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`textarea`,{"aria-label":h.correctionPlaceholder,disabled:i,value:c,onChange:e=>l(e.target.value),className:`min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none transition focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(Y,{variant:`ghost`,className:`h-8`,onClick:d,children:h.cancel}),(0,Q.jsx)(Y,{variant:`primary`,className:`h-8`,disabled:!c.trim()||i,onClick:()=>f(`edit_and_approve`,c.trim()),children:h.save})]})]}):(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(v,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-base leading-7 text-fg ${a?``:`line-clamp-2`}`,children:n.content}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`span`,{children:Xt(n.scope,r)}),n.claimMode===`reported`?(0,Q.jsx)(`span`,{children:r===`zh`?`来源报告`:`Source report`}):null,n.verification===`tentative`?(0,Q.jsx)(`span`,{children:r===`zh`?`证据待补充`:`Evidence pending`}):null,y?(0,Q.jsx)(`span`,{children:y}):null]}),a?(0,Q.jsx)(Pt,{id:n.id,language:r}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[x?(0,Q.jsx)(Y,{variant:`ghost`,className:`size-11 p-0`,"aria-expanded":a,"aria-label":a?h.collapse:h.expand,onClick:o,children:(0,Q.jsx)(oe,{className:`size-3.5 transition-transform ${a?`rotate-180`:``}`})}):null,(0,Q.jsx)(Xe,{language:r,busy:i,statement:n.content,scope:n.scope,onScopeChange:m,onEdit:u,onDelete:p})]})]})}),t[6]=i,t[7]=x,t[8]=y,t[9]=c,t[10]=s,t[11]=a,t[12]=n.claimMode,t[13]=n.content,t[14]=n.id,t[15]=n.scope,t[16]=n.verification,t[17]=r,t[18]=d,t[19]=p,t[20]=l,t[21]=u,t[22]=f,t[23]=m,t[24]=o,t[25]=h,t[26]=S):S=t[26],S}function sn(){let e=c(e=>e.language),t=It[e],n=Fe(e=>e.setPageHeader),r=Fe(e=>e.clearPageHeader),[i,s]=a(),{data:l,error:u,isLoading:d,isValidating:f,mutate:p}=Me(`/api/user-model`,M),m=Ft(i),[h,g]=(0,X.useState)(),[_,v]=(0,X.useState)(),[y,b]=(0,X.useState)(``),[I,L]=(0,X.useState)(),[oe,W]=(0,X.useState)(``),[G,de]=(0,X.useState)(``),[K,q]=(0,X.useState)(24),[J,fe]=(0,X.useState)(),[pe,me]=(0,X.useState)(!1),[_e,Ce]=(0,X.useState)(!1),Te=i.get(`source`),Ee=Te===`explicit`||Te===`learned`?Te:`all`,Ae=i.get(`search`)??``,Ne=i.get(`category`)??`all`,[Re,ze]=(0,X.useState)(`all`),[Be,Ve]=(0,X.useState)(`idle`),He=(0,X.useRef)(void 0),Ue=e=>{if(e===m)return;let t=document.getElementById(`app-main-content`);typeof t?.scrollTo==`function`&&t.scrollTo({top:0,behavior:`auto`}),s(t=>{let n=new URLSearchParams(t);return n.delete(`section`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n})},Z=(e,t,n=!1)=>{s(n=>{let r=new URLSearchParams(n);return!t||t===`all`?r.delete(e):r.set(e,t),r},{replace:n})},We=(0,X.useCallback)(async()=>{if(!(Be===`refreshing`||f)){He.current&&window.clearTimeout(He.current),Ve(`refreshing`),v(void 0),b(t.refreshing);try{await p(),Ve(`success`),b(t.refreshComplete)}catch{Ve(`error`),b(``),v(t.refreshFailed)}finally{He.current=window.setTimeout(()=>Ve(`idle`),1600)}}},[f,p,Be,t]);(0,X.useEffect)(()=>()=>{He.current&&window.clearTimeout(He.current)},[]);let Ge=f||Be===`refreshing`,Ke=Ge?t.refreshing:Be===`success`?t.refreshComplete:Be===`error`?t.refreshFailed:t.refresh;(0,X.useEffect)(()=>(n({startExtra:null,main:(0,Q.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:t.pageTitle}),end:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(xt,{}),(0,Q.jsx)(Y,{variant:`secondary`,className:`size-9 p-0 ${Be===`success`?`text-success`:Be===`error`?`text-danger`:``}`,disabled:Ge,"aria-label":Ke,title:Ke,onClick:()=>void We(),children:Ge?(0,Q.jsx)(he,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":`true`}):Be===`success`?(0,Q.jsx)(ae,{className:`size-4`,"aria-hidden":`true`}):Be===`error`?(0,Q.jsx)(se,{className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(be,{className:`size-4`,"aria-hidden":`true`})})]})}),r),[r,Ge,Be,Ke,We,n,t]);let qe=async(n,r)=>{g(n),v(void 0),b(``);try{await r(),await p(),b(e===`zh`?`已更新`:`Updated`)}catch{v(t.actionFailed)}finally{g(void 0)}},Je=e=>{qe(e.id,async()=>{await N(e.id,oe.trim()),L(void 0),W(``)})},Ye=async e=>{g(`profile`),v(void 0),b(``);try{await R(e),await p(),me(!1)}catch{v(t.actionFailed)}finally{g(void 0)}},Xe=async(n,r)=>{g(`priority:${n.id}`),v(void 0),b(``);try{await C(n.id,r),await p(),Ce(!1),b(e===`zh`?`当前关注已更新`:`Current focus updated`)}catch{v(t.actionFailed)}finally{g(void 0)}},Ze=async n=>{g(`priority:create`),v(void 0),b(``);try{await F(n),await p(),Ce(!1),b(e===`zh`?`当前关注已设置`:`Current focus set`)}catch{v(t.actionFailed)}finally{g(void 0)}},Qe=async n=>{g(`priority:${n.id}`),v(void 0),b(``);try{await C(n.id,{status:`completed`}),await p(),Ce(!1),b(e===`zh`?`当前关注已结束`:`Current focus ended`)}catch{v(t.actionFailed)}finally{g(void 0)}};if(d)return(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-7xl space-y-5 px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`,children:[(0,Q.jsx)(je,{className:`h-10 w-72 rounded-xl`}),(0,Q.jsx)(je,{className:`h-72 rounded-xl`}),(0,Q.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-2`,children:[(0,Q.jsx)(je,{className:`h-80 rounded-xl`}),(0,Q.jsx)(je,{className:`h-80 rounded-xl`})]})]});if(u||!l)return(0,Q.jsxs)(`div`,{className:`mx-auto flex min-h-72 max-w-xl flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,Q.jsx)(z,{className:`size-6 text-fg-subtle`}),(0,Q.jsx)(`p`,{className:`text-sm text-danger`,children:t.loadFailed}),(0,Q.jsx)(Y,{onClick:()=>void p(),children:t.tryAgain})]});let $e=l.assertions.filter(e=>e.usable&&!Lt.has(e.predicate)).sort((e,t)=>{let n=e.declaredImportance??e.inferredImportance;return(t.declaredImportance??t.inferredImportance)-n||t.recordedAt-e.recordedAt}),et=l.assertions.filter(e=>[`candidate`,`needs_review`,`conflicted`].includes(e.status)).sort((e,t)=>t.recordedAt-e.recordedAt),tt=Gt(l),nt=tt.callName||(e===`zh`?`你`:`You`),rt=[{key:`identity`,title:t.identity,icon:Oe,kinds:[`identity`,`capability`]},{key:`preferences`,title:t.preferences,icon:x,kinds:[`preference`,`value`,`routine`]},{key:`relationships`,title:t.relationships,icon:S,kinds:[`relationship`]},{key:`current`,title:t.currentState,icon:ce,kinds:[`current_state`]},{key:`insights`,title:t.insights,icon:we,kinds:[`derived_insight`]}],at=rt.find(e=>e.key===Ne),ot=$e.filter(e=>(!at||at.kinds.includes(e.kind))&&(!Ae.trim()||e.statement.toLocaleLowerCase().includes(Ae.trim().toLocaleLowerCase()))),st=ot.filter(e=>e.authority===`user_explicit`).length,ct=ot.length-st,lt=ot.filter(e=>Ee===`explicit`?e.authority===`user_explicit`:Ee!==`learned`||e.authority!==`user_explicit`),ut=l.priorities.filter(e=>e.status===`active`&&e.validTo>Date.now()),$=ut.find(e=>e.rank===`primary`)??ut[0],dt=Qt($,l.goals,e),ft=$?.targetType===`goal`?l.goals.find(e=>e.id===$.targetId):void 0,pt=l.goals.filter(e=>e.status===`active`||e.status===`paused`).filter(e=>$?.targetType!==`goal`||e.id!==$.targetId),mt=l.rules.filter(e=>e.status!==`archived`),ht=l.ruleSuggestions??[],gt=l.knowledge.filter(e=>e.status!==`archived`&&e.status!==`rejected`),_t=G.trim().toLocaleLowerCase(),vt=gt.filter(e=>Re===`all`||e.kind===Re),yt=vt.filter(t=>!_t||t.content.toLocaleLowerCase().includes(_t)||Zt(t.kind,e).toLocaleLowerCase().includes(_t)),bt=rt.map(e=>({...e,items:lt.filter(t=>e.kinds.includes(t.kind))})).filter(e=>e.items.length>0),Ct=rt.map(e=>({...e,items:$e.filter(t=>e.kinds.includes(t.kind))})).filter(e=>e.items.length>0),wt=Rt.map(e=>({kind:e,count:gt.filter(t=>t.kind===e).length})).filter(e=>e.count>0),Tt=wt.slice(0,4),Et=Tt.length===1?`grid-cols-1`:`sm:grid-cols-2`,Dt=yt.slice(0,K),Ot=Rt.map(e=>({kind:e,items:Dt.filter(t=>t.kind===e),totalCount:yt.filter(t=>t.kind===e).length})).filter(e=>e.items.length>0),kt=[{id:`all`,label:t.allUnderstanding,count:ot.length},{id:`explicit`,label:t.explicit,count:st},{id:`learned`,label:t.learned,count:ct}],At=(e=`all`)=>{s(t=>{let n=new URLSearchParams(t);return n.set(`tab`,`understanding`),n.delete(`section`),n.delete(`source`),n.delete(`search`),e===`all`?n.delete(`category`):n.set(`category`,e),n})},jt=e=>{ze(e),de(``),q(24),Ue(`work`)},Mt=t=>(0,Q.jsx)(it,{item:t,language:e,busy:!!h,editing:I===t.id,draft:I===t.id?oe:``,onDraftChange:W,onEdit:()=>{L(t.id),W(t.statement)},onCancel:()=>{L(void 0),W(``)},onDelete:()=>void qe(t.id,()=>w(t.id)),onCorrect:()=>Je(t),onScopeChange:e=>void qe(t.id,()=>O(t.id,e,t.version))},t.id);return(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl space-y-6 px-4 pb-4 pt-3 sm:space-y-8 sm:px-6 sm:pb-7 lg:px-8 lg:pb-10 lg:pt-4`,children:[(0,Q.jsx)(`div`,{className:`hidden px-1 sm:block`,children:(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:e===`zh`?`让 xopc 按你的习惯与你协作。记错了,随时改。`:`Help xopc work your way. You can correct what it remembers at any time.`})}),(0,Q.jsx)(Pe,{items:[{id:`overview`,label:t.overview,icon:we},{id:`understanding`,label:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`记住的你`:`Memories`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.understanding})]}),icon:Oe,count:$e.length},{id:`work`,label:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`工作记忆`:`Work`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.knowledge})]}),title:t.knowledge,icon:re,count:gt.length},{id:`privacy`,label:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`隐私`:`Privacy`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.privacy})]}),icon:Se}],activeTab:m,onChange:Ue,ariaLabel:t.pageTitle,tabIdPrefix:`understanding-tab`,panelIdPrefix:`understanding-panel`,className:`w-full max-w-full gap-1 rounded-full bg-surface-panel p-1 shadow-surface sm:w-fit`,buttonClassName:`min-h-11 min-w-0 flex-1 justify-center whitespace-nowrap rounded-full px-2 py-2 sm:min-h-9 sm:flex-none sm:px-3.5 [&_svg]:hidden sm:[&_svg]:block`,countClassName:`hidden sm:inline-flex`,selectedClassName:`bg-surface-active text-fg`,unselectedClassName:`text-fg-muted hover:bg-surface-hover hover:text-fg`}),(0,Q.jsx)(`p`,{role:`status`,className:`sr-only`,children:y}),_?(0,Q.jsxs)(`div`,{role:`alert`,className:`flex items-center justify-between gap-3 rounded-xl border border-danger bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,Q.jsx)(`span`,{children:_}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(void 0),"aria-label":t.cancel,children:(0,Q.jsx)(ke,{className:`size-4`})})]}):null,m===`overview`?(0,Q.jsxs)(`div`,{id:`understanding-panel-overview`,role:`tabpanel`,"aria-labelledby":`understanding-tab-overview`,className:`grid grid-cols-1 items-start gap-6 sm:gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(20rem,24rem)]`,children:[(0,Q.jsx)(`section`,{"data-testid":`overview-hero`,className:`min-w-0 lg:col-start-1 lg:row-start-1`,children:(0,Q.jsxs)(`div`,{className:`min-w-0 px-1 sm:py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 sm:flex-wrap sm:gap-5`,children:[(0,Q.jsx)(Ie,{className:`size-16 sm:size-20`,mood:_?`care`:Ge||h?`work`:`listen`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`truncate text-xl font-semibold tracking-tight text-fg sm:text-3xl`,children:nt}),(0,Q.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg-muted`,children:tt.role||(e===`zh`?`从你的背景和偏好开始了解你`:`Your background and preferences, in one place`)})]}),(0,Q.jsxs)(Y,{variant:`ghost`,className:`size-11 shrink-0 px-0 sm:h-9 sm:w-auto sm:px-3`,onClick:()=>me(!0),children:[(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:t.editProfile})]})]}),(0,Q.jsx)(`dl`,{className:`mt-6 hidden gap-x-8 gap-y-5 sm:grid sm:grid-cols-3`,children:[{icon:B,label:t.locale,value:tt.locale?Kt(tt.locale,e):``},{icon:T,label:t.timezone,value:tt.timezone},{icon:Oe,label:t.pronouns,value:tt.pronouns}].filter(({value:e})=>e).map(({icon:e,label:t,value:n})=>(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`dt`,{className:`flex items-center gap-1.5 text-xs text-fg-subtle`,children:[(0,Q.jsx)(e,{className:`size-3.5`,"aria-hidden":`true`}),t]}),(0,Q.jsx)(`dd`,{className:`mt-1.5 truncate text-sm font-medium text-fg`,children:n})]},t))})]})}),et.length?(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-2xl bg-accent-soft/70 shadow-surface lg:col-span-2`,"aria-label":e===`zh`?`需要你确认`:`Needs your review`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-4 sm:px-6`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-panel text-accent-fg`,children:(0,Q.jsx)(we,{className:`size-4`,"aria-hidden":`true`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e===`zh`?`这条理解准确吗?`:`Needs your review`}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e===`zh`?`xopc 还不确定,想请你确认。`:`xopc is unsure and would like your confirmation.`})]})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 text-xs font-medium tabular-nums text-accent-fg`,children:et.length})]}),(0,Q.jsxs)(`div`,{className:`border-t border-accent/10 bg-surface-panel px-5 py-4 sm:flex sm:items-center sm:gap-4 sm:px-6`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-sm leading-6 text-fg`,children:et[0].statement}),(0,Q.jsxs)(`div`,{className:`mt-3 flex shrink-0 gap-2 sm:mt-0`,children:[(0,Q.jsx)(Y,{variant:`ghost`,className:`min-h-11 flex-1 sm:flex-none`,disabled:h===et[0].id,onClick:()=>void qe(et[0].id,()=>P(et[0].id,`rejected`)),children:e===`zh`?`不是`:`No`}),(0,Q.jsx)(Y,{variant:`primary`,className:`min-h-11 flex-1 sm:flex-none`,disabled:h===et[0].id,onClick:()=>void qe(et[0].id,()=>P(et[0].id,`active`)),children:e===`zh`?`是的`:`That’s right`})]})]})]}):null,(0,Q.jsxs)(`section`,{"aria-label":t.aboutYouTitle,className:`space-y-3 sm:space-y-4 lg:col-span-2`,children:[(0,Q.jsxs)(`header`,{className:`flex items-start justify-between gap-3 px-1`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e===`zh`?t.aboutYouTitle:`What xopc knows about me`}),(0,Q.jsxs)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`记错了,随时改。`:`You can correct anything.`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:e===`zh`?`这些内容会帮助 xopc 更好地回应你。推测会单独标注。`:`These details help shape xopc’s responses. Inferences are labeled.`})]})]}),(0,Q.jsx)(Y,{variant:`ghost`,className:`min-h-11 shrink-0`,onClick:()=>At(),children:t.seeAll})]}),Ct.length?(0,Q.jsx)(`div`,{className:`grid items-start gap-5 lg:grid-cols-2`,children:Ct.map(({key:t,title:n,icon:r,items:i})=>(0,Q.jsxs)(`section`,{className:`min-w-0 overflow-hidden rounded-2xl bg-surface-panel`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center justify-between gap-3 px-5 pb-2 pt-4`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,Q.jsx)(r,{className:`size-4`,"aria-hidden":`true`}),n]}),(0,Q.jsxs)(Y,{variant:`ghost`,className:`min-h-11 shrink-0 px-2 text-fg-muted`,"aria-label":`${n}: ${i.length}`,onClick:()=>At(t),children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`${i.length} 条`:i.length}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:e===`zh`?`查看全部 ${i.length} 条`:`View all ${i.length}`}),(0,Q.jsx)(V,{className:`size-4`,"aria-hidden":`true`})]})]}),i.slice(0,2).map(Mt)]},t))}):(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel px-5 py-6`,children:[(0,Q.jsx)(`p`,{className:`max-w-xl text-sm leading-7 text-fg-muted`,children:t.emptyGroup}),(0,Q.jsx)(Y,{variant:`secondary`,className:`mt-4`,onClick:()=>me(!0),children:t.editProfile})]})]}),(0,Q.jsxs)(`aside`,{"data-testid":`priority-panel`,className:`flex min-h-0 flex-col rounded-[1.4rem] bg-surface-panel p-5 shadow-surface sm:p-6 lg:col-start-2 lg:row-start-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:t.importantNow}),$?(0,Q.jsxs)(`p`,{className:`mt-1.5 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Q.jsx)(re,{className:`size-3.5`,"aria-hidden":`true`}),$.targetType===`goal`?t.prioritySourceGoal:t.prioritySourceWork]}):null]}),$&&dt?(0,Q.jsxs)(Y,{variant:`ghost`,className:`h-8 shrink-0 px-2.5`,onClick:()=>Ce(!0),children:[(0,Q.jsx)(ve,{className:`size-3.5`,"aria-hidden":`true`}),t.editPriority]}):null]}),dt?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`mt-3 text-lg font-semibold leading-7 tracking-tight text-fg`,children:dt}),ft?.desiredOutcome?(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:ft.desiredOutcome}):null,$?(0,Q.jsxs)(`p`,{className:`mt-auto flex items-center gap-1.5 pt-4 text-xs text-fg-subtle`,children:[(0,Q.jsx)(ie,{className:`size-3.5`,"aria-hidden":`true`}),qt($.validTo,e)]}):null]}):(0,Q.jsxs)(`div`,{className:`mt-2 space-y-4 text-sm leading-6 text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:e===`zh`?`告诉 xopc 当前最重要的事,让协作更贴近你的目标。`:`Tell xopc what matters most so it can keep your goals in mind.`}),(0,Q.jsxs)(Y,{variant:`primary`,onClick:()=>Ce(!0),children:[(0,Q.jsx)(ye,{className:`size-4`,"aria-hidden":`true`}),t.addPriority]})]}),pt.length?(0,Q.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.otherGoals}),(0,Q.jsx)(`div`,{className:`mt-2 space-y-2`,children:pt.slice(0,3).map(e=>(0,Q.jsx)(`p`,{className:`text-sm text-fg`,children:e.title},e.id))})]}):null]}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-6 sm:gap-8 lg:col-span-2 lg:grid-cols-2`,children:[(0,Q.jsx)($t,{title:t.howWeWork,className:`min-w-0`,children:mt.length||ht.length?(0,Q.jsxs)(Q.Fragment,{children:[mt.slice(0,3).map(t=>(0,Q.jsx)(rn,{rule:t,language:e,busy:h===t.id,onToggle:()=>void qe(t.id,()=>A(t.id,t.status===`active`?`disabled`:`active`))},t.id)),ht.slice(0,2).map(t=>(0,Q.jsx)(an,{suggestion:t,language:e,busy:h===t.id,onConfirm:()=>void qe(t.id,()=>j(t))},t.id))]}):(0,Q.jsx)(en,{icon:(0,Q.jsx)(S,{className:`size-5`}),children:t.noRules})}),(0,Q.jsx)($t,{title:t.workMemory,className:`min-w-0`,action:(0,Q.jsx)(Y,{variant:`ghost`,className:`h-8 shrink-0`,onClick:()=>jt(`all`),children:t.seeAll}),children:wt.length?(0,Q.jsx)(`div`,{"data-testid":`memory-summary-grid`,className:`grid gap-3 bg-surface-base ${Et}`,children:Tt.map(({kind:n,count:r})=>(0,Q.jsxs)(`button`,{type:`button`,className:`group flex min-h-28 cursor-pointer items-start justify-between rounded-2xl bg-surface-panel px-5 py-5 text-left transition-colors hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>jt(n),"aria-label":`${Zt(n,e)}: ${r}`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`block text-xs font-medium text-fg-muted`,children:[Zt(n,e),` · `,r,` `,t.items]}),(0,Q.jsx)(`span`,{className:`mt-2 block line-clamp-3 break-words text-sm leading-6 text-fg`,children:gt.find(e=>e.kind===n)?.content})]}),(0,Q.jsx)(V,{className:`mt-1 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted motion-reduce:transform-none`,"aria-hidden":`true`})]},n))}):(0,Q.jsx)(en,{icon:(0,Q.jsx)(le,{className:`size-5`}),children:t.noKnowledge})})]})]}):null,m===`understanding`?(0,Q.jsxs)(`div`,{id:`understanding-panel-understanding`,role:`tabpanel`,"aria-labelledby":`understanding-tab-understanding`,className:`mx-auto max-w-3xl space-y-7`,children:[(0,Q.jsxs)(`div`,{className:`px-1 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(z,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:t.aboutYouTitle}),(0,Q.jsxs)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`你的偏好与背景,都可以在这里修改。`:`Review and edit your preferences here.`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.aboutYouHint})]})]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 grid grid-cols-[minmax(0,1fr)_7rem] gap-2 sm:flex sm:gap-3`,children:[(0,Q.jsxs)(`label`,{className:`relative block min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:e===`zh`?`搜索关于你的信息`:`Search what xopc knows`}),(0,Q.jsx)(xe,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":`true`}),(0,Q.jsx)(`input`,{type:`search`,value:Ae,onChange:e=>Z(`search`,e.target.value,!0),placeholder:e===`zh`?`搜索记忆`:`Search memories`,className:`min-h-11 w-full rounded-xl border border-edge bg-surface-panel pl-10 pr-3 text-base text-fg placeholder:text-fg-muted sm:text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,Q.jsxs)(H,{"aria-label":e===`zh`?`内容分类`:`Category`,value:rt.some(e=>e.key===Ne)?Ne:`all`,onChange:e=>Z(`category`,e.target.value),triggerClassName:`min-h-11 w-full text-base sm:w-48 sm:text-sm`,children:[(0,Q.jsx)(U,{value:`all`,children:e===`zh`?`全部`:`All`}),rt.map(t=>(0,Q.jsx)(U,{value:t.key,children:e===`zh`?{identity:`背景`,preferences:`偏好`,relationships:`关系`,current:`近况`,insights:`观察`}[t.key]:{identity:`Profile`,preferences:`Habits`,relationships:`People`,current:`Now`,insights:`Notes`}[t.key]},t.key))]})]}),(0,Q.jsx)(Le,{className:`mt-3 flex flex-wrap gap-2`,role:`group`,"aria-label":t.understandingFilterHint,indicatorClassName:`rounded-full bg-surface-active`,children:kt.map(t=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":Ee===t.id,className:`touch-target inline-flex min-h-11 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${Ee===t.id?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>Z(`source`,t.id),children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?{all:`全部`,explicit:`你说过的`,learned:`协作中发现`}[t.id]:{all:`All`,explicit:`You said`,learned:`Observed`}[t.id]}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.label}),(0,Q.jsx)(`span`,{className:`hidden tabular-nums text-fg-muted sm:inline`,children:t.count})]},t.id))})]}),bt.length?bt.map(({key:e,title:t,icon:n,items:r})=>(0,Q.jsx)($t,{title:t,action:(0,Q.jsx)(n,{className:`size-4 text-fg-subtle`,"aria-hidden":`true`}),children:(0,Q.jsx)(`div`,{children:r.map(Mt)})},e)):(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel`,children:[(0,Q.jsx)(en,{icon:(0,Q.jsx)(z,{className:`size-5`}),children:$e.length?e===`zh`?`没有找到符合条件的内容,试试其他关键词或清除筛选。`:`No matching details. Try another search or clear the filters.`:t.emptyGroup}),$e.length?(0,Q.jsx)(Y,{variant:`ghost`,className:`mb-4 ml-4`,onClick:()=>At(),children:e===`zh`?`清除筛选`:`Clear filters`}):null]})]}):null,m===`work`?(0,Q.jsxs)(`div`,{id:`understanding-panel-work`,role:`tabpanel`,"aria-labelledby":`understanding-tab-work`,className:`space-y-8`,children:[(0,Q.jsx)(St,{language:e}),(0,Q.jsxs)(`div`,{className:`px-1 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:Re===`all`?t.allMemory:Zt(Re,e)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:[vt.length,` `,t.items,` · `,e===`zh`?`当前筛选的工作资料记录数,包含未启用或待核验项;不同于顶部已启用且有依据的记忆数。`:`Work records matching this filter, including inactive or unverified items; separate from active, supported memories above.`,` · `,t.memoryLibraryHint]})]}),(0,Q.jsxs)(`label`,{className:`relative block sm:w-80`,children:[(0,Q.jsx)(xe,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:t.searchPlaceholder}),(0,Q.jsx)(`input`,{type:`search`,value:G,onChange:e=>{de(e.target.value),q(24)},placeholder:t.searchPlaceholder,className:`h-10 w-full rounded-xl border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]})]}),(0,Q.jsxs)(Le,{className:`mt-4 flex flex-wrap gap-2`,role:`group`,"aria-label":t.memoryFilterHint,indicatorClassName:`rounded-full bg-surface-active`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":Re===`all`,className:`touch-target inline-flex min-h-9 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${Re===`all`?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>ze(`all`),children:[t.allMemory,(0,Q.jsx)(`span`,{className:`tabular-nums text-fg-subtle`,children:gt.length})]}),wt.map(({kind:t,count:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":Re===t,className:`touch-target inline-flex min-h-9 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${Re===t?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>ze(t),children:[Zt(t,e),(0,Q.jsx)(`span`,{className:`tabular-nums text-fg-subtle`,children:n})]},t))]})]}),yt.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`space-y-8`,children:Ot.map(({kind:t,items:n,totalCount:r})=>(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-2xl bg-surface-panel`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center justify-between px-5 pb-1 pt-4 sm:px-6`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Zt(t,e)}),(0,Q.jsx)(`span`,{className:`text-xs tabular-nums text-fg-subtle`,children:r})]}),(0,Q.jsx)(`div`,{children:n.map(t=>(0,Q.jsx)(on,{item:t,language:e,busy:!!h,expanded:J===t.id,onToggle:()=>fe(e=>e===t.id?void 0:t.id),editing:I===`knowledge:${t.id}`,draft:oe,onDraftChange:W,onEdit:()=>{L(`knowledge:${t.id}`),W(t.content)},onCancel:()=>{L(void 0),W(``)},onDelete:()=>void qe(t.id,()=>te(t.id)),onScopeChange:e=>void qe(t.id,()=>ee(t,e)),onReview:(e,n)=>void qe(t.id,async()=>{await D(t,e,n),L(void 0),W(``)})},t.id))})]},t))}),yt.length>K?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(Y,{onClick:()=>q(e=>e+24),children:t.showMore})}):null]}):(0,Q.jsx)(`div`,{className:`rounded-2xl bg-surface-panel`,children:(0,Q.jsx)(en,{icon:(0,Q.jsx)(xe,{className:`size-5`}),children:G.trim()?t.noKnowledgeMatch:t.noKnowledge})})]}):null,m===`privacy`?(0,Q.jsxs)(`div`,{id:`understanding-panel-privacy`,role:`tabpanel`,"aria-labelledby":`understanding-tab-privacy`,className:`space-y-8`,children:[(0,Q.jsx)(`div`,{className:`px-1 pt-1`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Se,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:e===`zh`?`你的信息,由你掌控`:`Your information, under your control`}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:e===`zh`?`决定 xopc 可以记住什么、从哪里了解你,以及如何迁移你的数据。`:`Decide what xopc can remember, where it learns from, and how your data moves.`})]})]})}),(0,Q.jsx)($t,{title:e===`zh`?`记忆与使用`:`Memory & use`,children:(0,Q.jsxs)(`div`,{className:`divide-y divide-edge-subtle`,children:[[{key:`memory`,icon:z,title:e===`zh`?`长期记忆`:`Long-term memory`,detail:e===`zh`?`记住长期有用的信息,减少重复说明。`:`Remember useful information so you do not have to repeat yourself.`,enabled:l.settings.memoryEnabled},{key:`references`,icon:we,title:e===`zh`?`回答中的记忆引用`:`Memory references in answers`,detail:e===`zh`?`当个人信息影响回答时,显示本次参考内容。`:`Show what personal context was referenced when it shapes an answer.`,enabled:l.settings.showMemoryReferences}].map(({key:e,icon:t,title:n,detail:r,enabled:i})=>(0,Q.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":i,disabled:!!h,className:`flex min-h-20 w-full items-center gap-4 px-5 py-4 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent disabled:opacity-60 sm:px-6`,onClick:()=>void qe(`setting:${e}`,()=>k(e===`memory`?{memoryEnabled:!i}:{showMemoryReferences:!i})),children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(t,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:r})]}),(0,Q.jsx)(`span`,{className:`relative h-6 w-11 shrink-0 rounded-full transition-colors ${i?`bg-accent`:`bg-surface-active`}`,"aria-hidden":`true`,children:(0,Q.jsx)(`span`,{className:`absolute top-0.5 size-5 rounded-full bg-white shadow-sm transition-transform ${i?`translate-x-5`:`translate-x-0.5`}`})})]},e)),(0,Q.jsxs)(`div`,{className:`flex min-h-20 items-center gap-4 px-5 py-4 sm:px-6`,children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(ge,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e===`zh`?`敏感信息`:`Sensitive information`}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e===`zh`?`控制健康、财务等信息是否可以保存。`:`Control whether health, financial, and similar information can be saved.`})]}),(0,Q.jsxs)(H,{"aria-label":e===`zh`?`敏感信息策略`:`Sensitive information policy`,value:l.settings.sensitiveWritePolicy,disabled:!!h,onChange:e=>void qe(`setting:sensitive`,()=>k({sensitiveWritePolicy:e.target.value})),children:[(0,Q.jsx)(U,{value:`confirm`,children:e===`zh`?`先询问`:`Ask first`}),(0,Q.jsx)(U,{value:`deny`,children:e===`zh`?`不保存`:`Never save`}),(0,Q.jsx)(U,{value:`allow`,children:e===`zh`?`允许`:`Allow`})]})]})]})}),(0,Q.jsx)($t,{title:e===`zh`?`数据管理`:`Data management`,children:(0,Q.jsxs)(`div`,{className:`divide-y divide-edge-subtle`,children:[(0,Q.jsxs)(o,{to:`/settings/imports`,className:`flex min-h-20 items-center gap-4 px-5 py-4 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent sm:px-6`,children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(De,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e===`zh`?`从其他 AI 导入`:`Import from another AI`}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e===`zh`?`导入前预览新增、重复和冲突内容。`:`Preview new, duplicate, and conflicting items before import.`})]}),(0,Q.jsx)(V,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":`true`})]}),(0,Q.jsxs)(`button`,{type:`button`,disabled:!!h,className:`flex min-h-20 w-full items-center gap-4 px-5 py-4 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent disabled:opacity-60 sm:px-6`,onClick:()=>void qe(`export`,E),children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(ue,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e===`zh`?`下载我的记忆`:`Download my memory`}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e===`zh`?`导出为可阅读、可迁移的数据包。`:`Export a readable, portable archive.`})]}),(0,Q.jsx)(V,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":`true`})]})]})}),(0,Q.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel px-5 py-5 sm:px-6`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e===`zh`?`纠正与忘记`:`Correct and forget`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e===`zh`?`在“记忆”中打开任意一条内容的菜单,即可修改、调整作用范围或彻底删除。`:`Open any item in Memory to edit it, change where it applies, or delete it permanently.`}),(0,Q.jsx)(Y,{variant:`ghost`,className:`mt-3`,onClick:()=>{Ue(`understanding`)},children:e===`zh`?`管理记忆`:`Manage memory`})]})]}):null,(0,Q.jsx)(tn,{open:pe,profile:tt,language:e,saving:h===`profile`,onOpenChange:me,onSave:e=>void Ye(e)}),(0,Q.jsx)(nn,{open:_e,priority:$,title:dt??``,outcome:ft?.desiredOutcome,language:e,saving:h===($?`priority:${$.id}`:`priority:create`),onOpenChange:Ce,onSave:e=>$?void Xe($,e):void Ze(e),onEnd:$?()=>void Qe($):void 0})]})}export{sn as UserModelPage};
@@ -1 +1 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./secret-input-DsjfQmDn.js";import{t as i}from"./cn-0WouolD0.js";import{m as a}from"./voice-config-api-GIuXoHXw.js";var o=t();e();var s=n();function c(e){let t=(0,o.c)(15),{kind:n,providerId:c,fieldId:u,value:d,onChange:f,labels:p,placeholder:m,className:h}=e,g=m===void 0?`sk-...`:m,_;t[0]!==n||t[1]!==c?(_=()=>a({kind:n,provider:c}).then(l),t[0]=n,t[1]=c,t[2]=_):_=t[2];let v=_,y;t[3]===h?y=t[4]:(y=i(`flex min-w-0 flex-col gap-1.5`,h),t[3]=h,t[4]=y);let b;t[5]!==u||t[6]!==p||t[7]!==f||t[8]!==g||t[9]!==v||t[10]!==d?(b=(0,s.jsx)(r,{id:u,value:d,onChange:f,placeholder:g,labels:p,reveal:v,loadFailedLabel:p.loadFailed,maskedHelp:p.maskedHelp,notInConfigFile:p.notInConfigFile,inputClassName:`text-xs`}),t[5]=u,t[6]=p,t[7]=f,t[8]=g,t[9]=v,t[10]=d,t[11]=b):b=t[11];let x;return t[12]!==y||t[13]!==b?(x=(0,s.jsx)(`div`,{className:y,children:b}),t[12]=y,t[13]=b,t[14]=x):x=t[14],x}function l(e){return e.apiKey??null}export{c as t};
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./secret-input-DsjfQmDn.js";import{t as i}from"./cn-0WouolD0.js";import{m as a}from"./voice-config-api-DhJ3l8fk.js";var o=t();e();var s=n();function c(e){let t=(0,o.c)(15),{kind:n,providerId:c,fieldId:u,value:d,onChange:f,labels:p,placeholder:m,className:h}=e,g=m===void 0?`sk-...`:m,_;t[0]!==n||t[1]!==c?(_=()=>a({kind:n,provider:c}).then(l),t[0]=n,t[1]=c,t[2]=_):_=t[2];let v=_,y;t[3]===h?y=t[4]:(y=i(`flex min-w-0 flex-col gap-1.5`,h),t[3]=h,t[4]=y);let b;t[5]!==u||t[6]!==p||t[7]!==f||t[8]!==g||t[9]!==v||t[10]!==d?(b=(0,s.jsx)(r,{id:u,value:d,onChange:f,placeholder:g,labels:p,reveal:v,loadFailedLabel:p.loadFailed,maskedHelp:p.maskedHelp,notInConfigFile:p.notInConfigFile,inputClassName:`text-xs`}),t[5]=u,t[6]=p,t[7]=f,t[8]=g,t[9]=v,t[10]=d,t[11]=b):b=t[11];let x;return t[12]!==y||t[13]!==b?(x=(0,s.jsx)(`div`,{className:y,children:b}),t[12]=y,t[13]=b,t[14]=x):x=t[14],x}function l(e){return e.apiKey??null}export{c as t};
@@ -1 +1 @@
1
- import{i as e,o as t}from"./locale-store-cg9cm2EL.js";import{i as n}from"./voice-CDlC6XMH.js";import{n as r}from"./gateway-config-swr-OGhON-s6.js";var i=`/api/voice/boson`;async function a(){return(await t(e(i))).payload}async function o(){return(await t(e(`${i}/reveal-api-key`),{method:`POST`})).payload.apiKey}async function s(n){return(await t(e(i),{method:`PUT`,body:JSON.stringify(n)})).payload}async function c(){return(await t(e(`/api/voice/realtime/status`))).payload}async function l(n,r){let i=await t(e(`/api/voice/realtime/preview`),{method:`POST`,signal:n,body:JSON.stringify(r?{voice:r}:{})});if(i.payload.sampleRate!==24e3)throw Error(`Unsupported preview sample rate`);return Uint8Array.from(atob(i.payload.audio),e=>e.charCodeAt(0)).buffer}async function u(n,r,i){let a=new URLSearchParams({provider:n,model:r});return i&&a.set(`purpose`,i),(await t(e(`/api/voice/tts-voices?${a.toString()}`))).payload?.voices??[]}function d(){return{enabled:!1,provider:`openai`,providers:{alibaba:{model:`qwen-audio-3.1-asr-flash`},openai:{model:`gpt-4o-mini-transcribe`}},fallback:{enabled:!1,order:[]}}}function f(){return{enabled:!0,provider:`xopc-cloud`,trigger:`off`,maxTextLength:512,timeoutMs:6e4,providers:{alibaba:{model:`qwen3-tts-flash`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`}}}}function p(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function m(e){return typeof e==`string`&&e.trim().length>0?e.trim():`openai`}function h(e){let t=d();if(!p(e))return t;let n=m(e.provider),r=t.fallback??{enabled:!1,order:[]};if(p(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):r.order;r={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:r.enabled,order:t.length?t:r.order}}let i={...t.providers??{},...p(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,p(t)?{...t}:{}])):{}};return{enabled:!!e.enabled,provider:n,providers:i,fallback:r}}function g(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-cloud`}function _(e){let t=f();if(!p(e))return t;let n=g(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`off`,i={...t.providers??{},...p(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,p(t)?{...t}:{}])):{}};return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,providers:i}}function v(e){return{...e}}function y(e){return{...e}}function b(e){let t=p(e)?e:{},r=p(t.voice)?t.voice:{},i=p(r.input)?r.input:{},a=p(i.refinement)?i.refinement:{},o=p(r.realtime)?r.realtime:{},s=p(o.assistant)?o.assistant:{},c=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`].find(e=>e===s.thinkingLevel),l=p(o.boson)?n.safeParse(o.boson.voice):void 0,u=a.mode===`punctuation`||a.mode===`light`||a.mode===`custom`?a.mode:`off`;return{stt:h(t.stt),tts:_(t.tts),voice:{languageMode:r.languageMode===`manual`?`manual`:`auto`,language:r.language===`zh`?`zh`:`en`,input:{refinement:{mode:u,...typeof a.model==`string`&&a.model.trim()?{model:a.model.trim()}:{},...typeof a.customInstruction==`string`?{customInstruction:a.customInstruction}:{}}},realtime:{enabled:o.enabled===!0,defaultEngine:o.defaultEngine===`omni`?`omni`:o.defaultEngine===`agent`?`agent`:`auto`,silenceDurationMs:typeof o.silenceDurationMs==`number`?o.silenceDurationMs:1200,idleTimeoutMs:typeof o.idleTimeoutMs==`number`?o.idleTimeoutMs:6e4,maxDictationMs:typeof o.maxDictationMs==`number`?o.maxDictationMs:6e5,maxConversationMs:typeof o.maxConversationMs==`number`?o.maxConversationMs:36e5,bargeIn:o.bargeIn!==!1,...p(o.assistant)?{assistant:{...typeof s.model==`string`?{model:s.model}:{},...typeof s.historyTokens==`number`&&Number.isFinite(s.historyTokens)?{historyTokens:s.historyTokens}:{},...c?{thinkingLevel:c}:{}}}:{},...l?.success&&p(o.boson)?{boson:{defaultForNatural:o.boson.defaultForNatural===!0,voice:l.data}}:{},...p(o.stt)&&(o.stt.provider===`xopc-cloud`||o.stt.provider===`alibaba`)&&typeof o.stt.model==`string`?{stt:{provider:o.stt.provider,model:o.stt.model}}:{},...p(o.tts)&&(o.tts.provider===`alibaba`||o.tts.provider===`xopc-cloud`)?{tts:{provider:o.tts.provider,...typeof o.tts.model==`string`?{model:o.tts.model}:{},...typeof o.tts.voice==`string`?{voice:o.tts.voice}:{}}}:{},...p(o.omni)?{omni:{...o.omni}}:{}}}}}async function x(){return b((await t(e(`/api/config`))).payload?.config??{})}function S(e){return!p(e)||!p(e.voiceSettingsRevisions)?{}:Object.fromEntries(Object.entries(e.voiceSettingsRevisions).filter(([e,t])=>[`transcription`,`speech`,`conversation`].includes(e)&&typeof t==`string`&&/^[a-f0-9]{64}$/.test(t)))}async function C(n,i,a){let o=await t(e(`/api/config`),{method:`PATCH`,body:JSON.stringify({...a?{expectedVoiceRevision:{capability:i,revision:a}}:{},...i===`transcription`?{stt:v(n.stt)}:{},...i===`speech`?{tts:y(n.tts)}:{},...i===`conversation`?{voice:{realtime:n.voice.realtime}}:i===`transcription`?{voice:{language:n.voice.language,languageMode:n.voice.languageMode,input:n.voice.input}}:{}})});return i===`transcription`&&n.voice.languageMode===`auto`&&await t(e(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:n.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),r(),S(o?.payload?.config)}async function w(){let n=await t(e(`/api/voice/models`));if(!n.payload?.models)throw Error(`Missing voice models payload`);return n.payload.models}async function T(){let n=await t(e(`/api/voice/providers`));if(!n.payload?.providers)throw Error(`Missing voice providers payload`);return n.payload}async function E(){let n=await t(e(`/api/voice/stt-providers`));if(!n.payload?.providers)throw Error(`Missing STT providers payload`);return n.payload}async function D(n,r){let i=await t(e(`/api/voice/tts-test`),{method:`POST`,signal:r,body:JSON.stringify(n)});if(i.ok===!1){let e=typeof i.error==`string`?i.error:i.error?.message;throw Error(e||`TTS test failed`)}if(!i.payload||typeof i.payload.audio!=`string`||!i.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return i.payload}async function O(n){let r=await t(e(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(n)});if(!r.payload)throw Error(`Missing reveal payload`);return r.payload}export{w as a,E as c,l as d,S as f,D as g,s as h,u as i,b as l,O as m,a as n,T as o,o as p,c as r,x as s,i as t,C as u};
1
+ import{i as e,o as t}from"./locale-store-Dy1EByeG.js";import{i as n}from"./voice-CDlC6XMH.js";import{n as r}from"./gateway-config-swr-1Rk0LeEM.js";var i=`/api/voice/boson`;async function a(){return(await t(e(i))).payload}async function o(){return(await t(e(`${i}/reveal-api-key`),{method:`POST`})).payload.apiKey}async function s(n){return(await t(e(i),{method:`PUT`,body:JSON.stringify(n)})).payload}async function c(){return(await t(e(`/api/voice/realtime/status`))).payload}async function l(n,r){let i=await t(e(`/api/voice/realtime/preview`),{method:`POST`,signal:n,body:JSON.stringify(r?{voice:r}:{})});if(i.payload.sampleRate!==24e3)throw Error(`Unsupported preview sample rate`);return Uint8Array.from(atob(i.payload.audio),e=>e.charCodeAt(0)).buffer}async function u(n,r,i){let a=new URLSearchParams({provider:n,model:r});return i&&a.set(`purpose`,i),(await t(e(`/api/voice/tts-voices?${a.toString()}`))).payload?.voices??[]}function d(){return{enabled:!1,provider:`openai`,providers:{alibaba:{model:`qwen-audio-3.1-asr-flash`},openai:{model:`gpt-4o-mini-transcribe`}},fallback:{enabled:!1,order:[]}}}function f(){return{enabled:!0,provider:`xopc-cloud`,trigger:`off`,maxTextLength:512,timeoutMs:6e4,providers:{alibaba:{model:`qwen3-tts-flash`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`}}}}function p(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function m(e){return typeof e==`string`&&e.trim().length>0?e.trim():`openai`}function h(e){let t=d();if(!p(e))return t;let n=m(e.provider),r=t.fallback??{enabled:!1,order:[]};if(p(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):r.order;r={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:r.enabled,order:t.length?t:r.order}}let i={...t.providers??{},...p(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,p(t)?{...t}:{}])):{}};return{enabled:!!e.enabled,provider:n,providers:i,fallback:r}}function g(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-cloud`}function _(e){let t=f();if(!p(e))return t;let n=g(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`off`,i={...t.providers??{},...p(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,p(t)?{...t}:{}])):{}};return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,providers:i}}function v(e){return{...e}}function y(e){return{...e}}function b(e){let t=p(e)?e:{},r=p(t.voice)?t.voice:{},i=p(r.input)?r.input:{},a=p(i.refinement)?i.refinement:{},o=p(r.realtime)?r.realtime:{},s=p(o.assistant)?o.assistant:{},c=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`].find(e=>e===s.thinkingLevel),l=p(o.boson)?n.safeParse(o.boson.voice):void 0,u=a.mode===`punctuation`||a.mode===`light`||a.mode===`custom`?a.mode:`off`;return{stt:h(t.stt),tts:_(t.tts),voice:{languageMode:r.languageMode===`manual`?`manual`:`auto`,language:r.language===`zh`?`zh`:`en`,input:{refinement:{mode:u,...typeof a.model==`string`&&a.model.trim()?{model:a.model.trim()}:{},...typeof a.customInstruction==`string`?{customInstruction:a.customInstruction}:{}}},realtime:{enabled:o.enabled===!0,defaultEngine:o.defaultEngine===`omni`?`omni`:o.defaultEngine===`agent`?`agent`:`auto`,silenceDurationMs:typeof o.silenceDurationMs==`number`?o.silenceDurationMs:1200,idleTimeoutMs:typeof o.idleTimeoutMs==`number`?o.idleTimeoutMs:6e4,maxDictationMs:typeof o.maxDictationMs==`number`?o.maxDictationMs:6e5,maxConversationMs:typeof o.maxConversationMs==`number`?o.maxConversationMs:36e5,bargeIn:o.bargeIn!==!1,...p(o.assistant)?{assistant:{...typeof s.model==`string`?{model:s.model}:{},...typeof s.historyTokens==`number`&&Number.isFinite(s.historyTokens)?{historyTokens:s.historyTokens}:{},...c?{thinkingLevel:c}:{}}}:{},...l?.success&&p(o.boson)?{boson:{defaultForNatural:o.boson.defaultForNatural===!0,voice:l.data}}:{},...p(o.stt)&&(o.stt.provider===`xopc-cloud`||o.stt.provider===`alibaba`)&&typeof o.stt.model==`string`?{stt:{provider:o.stt.provider,model:o.stt.model}}:{},...p(o.tts)&&(o.tts.provider===`alibaba`||o.tts.provider===`xopc-cloud`)?{tts:{provider:o.tts.provider,...typeof o.tts.model==`string`?{model:o.tts.model}:{},...typeof o.tts.voice==`string`?{voice:o.tts.voice}:{}}}:{},...p(o.omni)?{omni:{...o.omni}}:{}}}}}async function x(){return b((await t(e(`/api/config`))).payload?.config??{})}function S(e){return!p(e)||!p(e.voiceSettingsRevisions)?{}:Object.fromEntries(Object.entries(e.voiceSettingsRevisions).filter(([e,t])=>[`transcription`,`speech`,`conversation`].includes(e)&&typeof t==`string`&&/^[a-f0-9]{64}$/.test(t)))}async function C(n,i,a){let o=await t(e(`/api/config`),{method:`PATCH`,body:JSON.stringify({...a?{expectedVoiceRevision:{capability:i,revision:a}}:{},...i===`transcription`?{stt:v(n.stt)}:{},...i===`speech`?{tts:y(n.tts)}:{},...i===`conversation`?{voice:{realtime:n.voice.realtime}}:i===`transcription`?{voice:{language:n.voice.language,languageMode:n.voice.languageMode,input:n.voice.input}}:{}})});return i===`transcription`&&n.voice.languageMode===`auto`&&await t(e(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:n.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),r(),S(o?.payload?.config)}async function w(){let n=await t(e(`/api/voice/models`));if(!n.payload?.models)throw Error(`Missing voice models payload`);return n.payload.models}async function T(){let n=await t(e(`/api/voice/providers`));if(!n.payload?.providers)throw Error(`Missing voice providers payload`);return n.payload}async function E(){let n=await t(e(`/api/voice/stt-providers`));if(!n.payload?.providers)throw Error(`Missing STT providers payload`);return n.payload}async function D(n,r){let i=await t(e(`/api/voice/tts-test`),{method:`POST`,signal:r,body:JSON.stringify(n)});if(i.ok===!1){let e=typeof i.error==`string`?i.error:i.error?.message;throw Error(e||`TTS test failed`)}if(!i.payload||typeof i.payload.audio!=`string`||!i.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return i.payload}async function O(n){let r=await t(e(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(n)});if(!r.payload)throw Error(`Missing reveal payload`);return r.payload}export{w as a,E as c,l as d,S as f,D as g,s as h,u as i,b as l,O as m,a as n,T as o,o as p,c as r,x as s,i as t,C as u};
@@ -1 +1 @@
1
- import{p as e}from"./locale-store-cg9cm2EL.js";import{t}from"./middleware-Pd0e8Igk.js";function n(){return typeof navigator>`u`?!1:navigator.platform?.includes(`Mac`)??navigator.userAgent.includes(`Mac`)}function r(e,t=n()){return a(e).split(`+`).map(e=>e===`control`?`Ctrl`:e===`meta`?t?`⌘`:`Win`:e===`alt`?t?`Option`:`Alt`:e===`shift`?`Shift`:e===`space`?`Space`:e.length===1?e.toUpperCase():e)}function i(e=n()){return e?`meta+.`:`control+.`}function a(e){return e.split(`+`).map(l).filter(Boolean).join(`+`)}function o(e){if(e.key===`Escape`||[`Meta`,`Control`,`Alt`,`Shift`].includes(e.key))return null;let t=e.key===` `?`space`:l(e.key);return t?[...[e.metaKey?`meta`:``,e.ctrlKey?`control`:``,e.altKey?`alt`:``,e.shiftKey?`shift`:``].filter(Boolean),t].join(`+`):null}var s=e(t(e=>({shortcut:i(),setShortcut:t=>e({shortcut:a(t)||i()})}),{name:`xopc-quick-capture-shortcut`,version:2})),c={cmd:`meta`,command:`meta`,ctrl:`control`,ctl:`control`,opt:`alt`,option:`alt`};function l(e){let t=e.toLowerCase().trim();return c[t]??t}function u(e,t){let n=a(t).split(`+`),r=new Set(n.filter(e=>[`meta`,`control`,`alt`,`shift`].includes(e))),i=n.find(e=>!r.has(e));return!i||r.has(`meta`)!==e.metaKey||r.has(`control`)!==e.ctrlKey||r.has(`alt`)!==e.altKey||r.has(`shift`)!==e.shiftKey?!1:e.key.toLowerCase()===i||e.code.toLowerCase()===i}function d(e=n()){return e?`meta+shift+m`:`control+shift+m`}var f=e(t(e=>({shortcut:d(),setShortcut:t=>e({shortcut:a(t)||d()})}),{name:`xopc-voice-input-shortcut`,version:1})),p=`xopc-voice-input-toggle`,m=`xopc-voice-input-cancel`,h=`app-shortcut-recording`,g=!1;function _(e,t){let n=new CustomEvent(e,{cancelable:!0,detail:{target:t}});return window.dispatchEvent(n),n.defaultPrevented}function v(){g=!0}function y(){g=!1}function b(){return g?(g=!1,!0):!1}export{_ as a,d as c,n as d,u as f,s as h,y as i,f as l,o as m,m as n,v as o,r as p,p as r,b as s,h as t,i as u};
1
+ import{p as e}from"./locale-store-Dy1EByeG.js";import{t}from"./middleware-Pd0e8Igk.js";function n(){return typeof navigator>`u`?!1:navigator.platform?.includes(`Mac`)??navigator.userAgent.includes(`Mac`)}function r(e,t=n()){return a(e).split(`+`).map(e=>e===`control`?`Ctrl`:e===`meta`?t?`⌘`:`Win`:e===`alt`?t?`Option`:`Alt`:e===`shift`?`Shift`:e===`space`?`Space`:e.length===1?e.toUpperCase():e)}function i(e=n()){return e?`meta+.`:`control+.`}function a(e){return e.split(`+`).map(l).filter(Boolean).join(`+`)}function o(e){if(e.key===`Escape`||[`Meta`,`Control`,`Alt`,`Shift`].includes(e.key))return null;let t=e.key===` `?`space`:l(e.key);return t?[...[e.metaKey?`meta`:``,e.ctrlKey?`control`:``,e.altKey?`alt`:``,e.shiftKey?`shift`:``].filter(Boolean),t].join(`+`):null}var s=e(t(e=>({shortcut:i(),setShortcut:t=>e({shortcut:a(t)||i()})}),{name:`xopc-quick-capture-shortcut`,version:2})),c={cmd:`meta`,command:`meta`,ctrl:`control`,ctl:`control`,opt:`alt`,option:`alt`};function l(e){let t=e.toLowerCase().trim();return c[t]??t}function u(e,t){let n=a(t).split(`+`),r=new Set(n.filter(e=>[`meta`,`control`,`alt`,`shift`].includes(e))),i=n.find(e=>!r.has(e));return!i||r.has(`meta`)!==e.metaKey||r.has(`control`)!==e.ctrlKey||r.has(`alt`)!==e.altKey||r.has(`shift`)!==e.shiftKey?!1:e.key.toLowerCase()===i||e.code.toLowerCase()===i}function d(e=n()){return e?`meta+shift+m`:`control+shift+m`}var f=e(t(e=>({shortcut:d(),setShortcut:t=>e({shortcut:a(t)||d()})}),{name:`xopc-voice-input-shortcut`,version:1})),p=`xopc-voice-input-toggle`,m=`xopc-voice-input-cancel`,h=`app-shortcut-recording`,g=!1;function _(e,t){let n=new CustomEvent(e,{cancelable:!0,detail:{target:t}});return window.dispatchEvent(n),n.defaultPrevented}function v(){g=!0}function y(){g=!1}function b(){return g?(g=!1,!0):!1}export{_ as a,d as c,n as d,u as f,s as h,y as i,f as l,o as m,m as n,v as o,r as p,p as r,b as s,h as t,i as u};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as o,l as s,n as c,o as l}from"./locale-store-cg9cm2EL.js";import{t as u}from"./messages-eQ2CYlpG.js";import{n as d,r as f}from"./popover-select-CLsphyzA.js";import{t as p}from"./secret-input-DsjfQmDn.js";import{t as m}from"./loader-circle-CifKLtgG.js";import{t as h}from"./mic-CuUb7zc-.js";import{t as g}from"./play-kxZvpBg8.js";import{t as _}from"./square-DMK_fB-3.js";import{t as v}from"./volume-2-BSJhAY97.js";import{t as y}from"./cn-0WouolD0.js";import{t as b}from"./skeleton-DzdOeGYz.js";import{a as x,c as S,i as C,m as w,n as T,p as E,u as D}from"./schemas-CCWMleym.js";import{n as O}from"./voice-CDlC6XMH.js";import{i as k}from"./vendor-swr-CdRzEUwF.js";import{n as A,r as j}from"./gateway-config-swr-OGhON-s6.js";import{t as M}from"./button-Cc4hUNTt.js";import{t as N}from"./open-capability-settings-DQsmJxI7.js";import{a as P,d as F,f as I,i as L,o as R,p as z,t as B,u as V}from"./use-realtime-voice-DDVVlX1R.js";import{t as H}from"./voice-call-context-BM2A4bLz.js";import{a as U,o as ee,s as te}from"./form-field-width-DJw_jULe.js";import{t as ne}from"./secret-input-labels-B5Jl5HqK.js";import{n as W}from"./model-sort-_Tz8s_4N.js";import{r as G}from"./model-selector-CL6WT-jw.js";import{t as K}from"./settings-loading-skeleton-CAoOV17i.js";import{a as re,i as q}from"./capability-navigation-QtHJxxW2.js";import{t as J}from"./number-input-El7Szeln.js";import{n as ie,t as ae}from"./use-autosave-CO0IPCVg.js";import{a as oe,c as se,d as ce,f as le,g as ue,h as de,i as fe,l as pe,n as me,o as he,p as Y,r as ge,t as _e,u as ve}from"./voice-config-api-GIuXoHXw.js";import{t as ye}from"./voice-api-key-field-DpwUDAvu.js";var be=E({"zh-CN":w().min(1).optional(),en:w().min(1).optional()}),xe=T([`transcription`,`transcription.stream`,`speech`,`speech.stream`,`conversation`]),Se=E({protocolVersion:S(1),serviceVersion:D().int().positive(),modes:C(xe),transport:S(`websocket-pcm`),inputFormat:E({encoding:S(`pcm_s16le`),sampleRate:S(16e3),channels:S(1)}),outputFormat:E({encoding:S(`pcm_s16le`),sampleRate:S(24e3),channels:S(1)}),turnDetection:C(S(`server_vad`)),bargeIn:x(),tools:x(),resumable:S(!1),voices:C(E({id:w().min(1),name:w(),displayNames:be.optional(),languages:C(w()),gender:T([`female`,`male`]).optional(),style:w().optional(),description:w().optional(),modes:C(xe).optional()})),defaultVoice:w().min(1).optional(),limits:E({maxFrameBytes:D().int().positive().max(65536),maxSessionSeconds:D().int().positive()})});function Ce(e,t){return e.modes===void 0||e.modes.includes(t)}var we=E({mode:xe,model:w().min(1).max(200),voice:w().min(1).max(200).optional()}),Te=E({revision:w().min(1),catalogVersion:w().nullable(),selections:C(we),models:C(E({id:w(),name:w(),displayNames:be.optional(),voice:Se}))}),X=n(),Z=e(t(),1),Q=r();function Ee({disabled:e=!1,modes:t,onPendingChange:n}){let r=c(e=>e.language),i=r===`zh`,[a,s]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>(n?.(a),()=>n?.(!1)),[a,n]);let[u,p]=(0,Z.useState)(``),{data:m,mutate:h,error:g}=k(o(`/api/voice/catalog`),async e=>{let t=await l(e);return Te.parse(t.payload)}),_=i?{transcription:`录音转文字`,"transcription.stream":`实时听写 / 语音助手输入`,speech:`消息朗读`,"speech.stream":`语音助手输出`,conversation:`自然语音对话`}:{transcription:`Recorded transcription`,"transcription.stream":`Live dictation / assistant input`,speech:`Message readout`,"speech.stream":`Assistant speech`,conversation:`Natural conversation`},v=async e=>{if(m){s(!0),p(``);try{let t=await l(o(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:m.revision,selection:e})}:{}});await h(Te.parse(t.payload),!1),await A()}catch(e){p(e instanceof Error?e.message:String(e)),await h()}finally{s(!1)}}};return(0,Q.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h3`,{className:`font-medium`,children:i?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,Q.jsx)(M,{variant:`secondary`,disabled:a||e||!m,onClick:()=>void v(),children:i?`刷新目录`:`Refresh catalog`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`修改在下次调用生效。各设备共用此 Gateway 的配置。`:`Changes apply to the next call and are shared across devices.`}),u||g?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:u||String(g)}):null,m?(0,Q.jsx)(Q.Fragment,{children:t.map(t=>{let n=m.selections.find(e=>e.mode===t),o=m.models.filter(e=>e.voice.modes.includes(t)).sort(W),s=o.find(e=>e.id===n?.model),c=s?.voice.voices.filter(e=>Ce(e,t))??[],l=n?.voice??c.find(e=>e.id===s?.voice.defaultVoice)?.id??c[0]?.id??``;return(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,Q.jsx)(`span`,{children:_[t]}),(0,Q.jsxs)(d,{className:`w-full`,value:n?.model??``,disabled:a||e||!o.length,onChange:e=>void v({mode:t,model:e.target.value}),children:[(0,Q.jsx)(f,{value:``,disabled:!0,children:i?`选择模型`:`Choose model`}),n&&!s?(0,Q.jsxs)(f,{value:n.model,disabled:!0,children:[n.model,` · `,i?`不可用`:`Unavailable`]}):null,o.map(e=>(0,Q.jsx)(f,{value:e.id,children:G(e,r)},e.id))]}),o.length?null:(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i?`暂无可用模型`:`No available model`})]}),s&&c.length>0?(0,Q.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,Q.jsx)(`span`,{children:i?`音色`:`Voice`}),(0,Q.jsxs)(d,{className:`w-full`,value:l,disabled:a||e,onChange:e=>void v({mode:t,model:s.id,voice:e.target.value}),children:[n?.voice&&!c.some(e=>e.id===n.voice)?(0,Q.jsxs)(f,{value:n.voice,disabled:!0,children:[n.voice,` · `,i?`当前场景不可用`:`Unavailable for this mode`]}):null,c.map(e=>(0,Q.jsxs)(f,{value:e.id,children:[G(e,r),e.gender?` · ${i?e.gender===`female`?`女声`:`男声`:e.gender}`:``,e.style?` · ${e.style}`:``]},e.id))]}),c.find(e=>e.id===l)?.description?(0,Q.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:c.find(e=>e.id===l)?.description}):null]}):null]},t)})}):(0,Q.jsx)(b,{className:`h-48 w-full`})]})}function De({v:e}){let t=I(e=>e.microphoneId),n=I(e=>e.setMicrophoneId),[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{l.current=!0;let e=()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{l.current&&i(e.filter(e=>e.kind===`audioinput`))}).catch(()=>{})};return e(),navigator.mediaDevices?.addEventListener(`devicechange`,e),()=>{l.current=!1,navigator.mediaDevices?.removeEventListener(`devicechange`,e)}},[]);let u=async()=>{c(!0),o(``);try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop());let e=await navigator.mediaDevices.enumerateDevices();l.current&&i(e.filter(e=>e.kind===`audioinput`))}catch(e){l.current&&o(e instanceof Error?e.message:String(e))}finally{l.current&&c(!1)}};return(0,Q.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,Q.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,Q.jsx)(`span`,{children:e.experience.microphone}),(0,Q.jsxs)(d,{value:t,onChange:e=>n(e.target.value),children:[(0,Q.jsx)(f,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,Q.jsx)(f,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,Q.jsx)(f,{value:t.deviceId,children:t.label||`${e.experience.microphone} ${n+1}`},t.deviceId))]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.experience.deviceHint}),(0,Q.jsx)(M,{variant:`secondary`,disabled:s,onClick:()=>void u(),children:e.experience.refreshDevices}),a?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}var Oe=(0,Z.createContext)(null);function ke(e){let t=(0,X.c)(18),n,r;t[0]===e?(n=t[1],r=t[2]):({to:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let[o]=i(),s=(0,Z.useContext)(Oe),c,l;t[3]===r?(c=t[4],l=t[5]):(c=new URLSearchParams(r.split(`?`)[1]??``),l=q(c.get(`configure`)),t[3]=r,t[4]=c,t[5]=l);let u=l,d;t[6]!==s||t[7]!==n||t[8]!==c||t[9]!==u?(d=e=>{n.onClick?.(e),!e.defaultPrevented&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&e.button===0&&s&&u&&c.get(`tab`)===`services`&&(e.preventDefault(),s(u))},t[6]=s,t[7]=n,t[8]=c,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==o||t[12]!==r?(f=re(r,o),t[11]=o,t[12]=r,t[13]=f):f=t[13];let p;return t[14]!==n||t[15]!==d||t[16]!==f?(p=(0,Q.jsx)(a,{...n,onClick:d,to:f}),t[14]=n,t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function Ae(e){let t=(0,X.c)(19),{zh:n}=e,{data:r,error:i,mutate:a}=k(`voice-dictation-route`,je),o,s;t[0]===a?(o=t[1],s=t[2]):(o=()=>{let e=()=>{a()};return window.addEventListener(`voice-config-changed`,e),window.addEventListener(`config-reload`,e),()=>{window.removeEventListener(`voice-config-changed`,e),window.removeEventListener(`config-reload`,e)}},s=[a],t[0]=a,t[1]=o,t[2]=s),(0,Z.useEffect)(o,s);let c=n?`同时用于聊天听写`:`Also used for chat dictation`,l;t[3]===c?l=t[4]:(l=(0,Q.jsx)(`h2`,{className:`font-medium text-fg`,children:c}),t[3]=c,t[4]=l);let u=n?`默认与录音识别共用模型。已有的独立听写设置会保留。`:`Dictation shares this recognition model. Existing separate dictation settings are preserved.`,d;t[5]===u?d=t[6]:(d=(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:u}),t[5]=u,t[6]=d);let f;t[7]!==r||t[8]!==i||t[9]!==n?(f=!r&&!i?(0,Q.jsx)(b,{className:`h-5 w-64 max-w-full`}):(0,Q.jsx)(`p`,{role:i?`alert`:`status`,className:`text-fg-muted`,children:i?n?`暂时无法读取听写状态。`:`Dictation status could not be loaded.`:r?.mode===`recorded`?n?`当前使用 ${r.provider},点击完成后转为文字。`:`Using ${r.provider}. Choose Finish to transcribe.`:r?.mode===`streaming`?n?`当前使用流式识别${r.provider?` · ${r.provider}`:``}。`:`Using streaming recognition${r.provider?` · ${r.provider}`:``}.`:n?`听写未就绪,请检查识别模型或已有的流式配置。`:`Check the recognition model or existing streaming configuration.`}),t[7]=r,t[8]=i,t[9]=n,t[10]=f):f=t[10];let p;t[11]!==r?.mode||t[12]!==n?(p=r?.mode===`recorded`?null:(0,Q.jsx)(ke,{className:`inline-block text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=transcription`,children:n?`管理识别服务`:`Manage recognition services`}),t[11]=r?.mode,t[12]=n,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==d||t[16]!==f||t[17]!==p?(m=(0,Q.jsxs)(`section`,{className:`space-y-2 rounded-xl border border-edge p-4 text-sm`,children:[l,d,f,p]}),t[14]=l,t[15]=d,t[16]=f,t[17]=p,t[18]=m):m=t[18],m}function je(){return L(AbortSignal.timeout(15e3))}function Me({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Z.useContext)(H)?.active??!1,[s,c]=(0,Z.useState)(`idle`),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``),p=(0,Z.useRef)(`idle`),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!1),b=e=>{p.current=e,c(e)},x=()=>{v.current?.(),v.current=null};(0,Z.useEffect)(()=>()=>v.current?.(),[]);async function S(e){x(),i?.({input:!1,output:!1}),y.current=!1,u(``),f(``),b(e?`connecting`:`playing`);let t=new AbortController,r,o,s,c,l=()=>{o?.cancel(),r?.getTracks().forEach(e=>e.stop()),s?.stop(`surface_closed`)},d=window.setTimeout(()=>m(a.timeout),6e4);v.current=()=>{t.abort(),window.clearTimeout(d),l(),c?.close()};function m(e){t.signal.aborted||(b(`error`),f(e),x())}async function h(){b(`playing`),l();try{let e=await ce(t.signal);if(t.signal.aborted)return;c?.enqueue(e,()=>{t.signal.aborted||(window.clearTimeout(d),b(`confirm`))})}catch(e){m(e instanceof Error?e.message:a.testFailed)}}try{if(n&&(c=new V,await c.start(),t.signal.throwIfAborted()),!e){await h();return}let d=window.electronAPI?.system;if(d){let e=await d.requestMicrophone();if(t.signal.throwIfAborted(),e.status===`denied`)throw Error(a.microphoneDenied)}if(r=await navigator.mediaDevices.getUserMedia({audio:z()}),t.signal.aborted){l();return}if(s=await F.connect({purpose:`dictation`,signal:t.signal,onEvent:e=>{t.signal.aborted||(e.type===`session.error`&&m(a.testFailed),p.current===`listening`&&(e.type===`input.transcript.delta`&&u(e.payload.text),e.type===`input.transcript.final`&&e.payload.text.trim()&&(u(e.payload.text.trim()),y.current=!0,n?h():(b(`passed`),i?.({input:!0,output:!1}),x()))))},onClose:()=>{(p.current===`listening`||p.current===`connecting`)&&m(a.testFailed)}}),t.signal.aborted){l();return}let f;if(o=await P.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new R(o.sampleRate,s.session.inputFormat.sampleRate),b(`listening`)}catch(e){if(t.signal.aborted){l();return}m(e instanceof Error?e.message:a.testFailed)}}let C=s===`connecting`||s===`listening`||s===`playing`;return(0,Q.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(M,{type:`button`,variant:`primary`,disabled:o||r||!t||C,onClick:()=>void S(!0),children:[C?(0,Q.jsx)(m,{className:`size-4 animate-spin`}):(0,Q.jsx)(h,{className:`size-4`}),n?a.test:a.testInput]}),(0,Q.jsxs)(M,{type:`button`,variant:`secondary`,disabled:o||r||!n||C,onClick:()=>void S(!1),children:[(0,Q.jsx)(g,{className:`size-4`}),e.tts.test.play]}),C?(0,Q.jsxs)(M,{type:`button`,variant:`ghost`,onClick:()=>{x(),b(`idle`)},children:[(0,Q.jsx)(_,{className:`size-4`}),e.tts.test.stop]}):null]}),(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`space-y-2 text-xs text-fg-muted`,children:[s===`idle`?(0,Q.jsx)(`p`,{children:o?e.experience.endCallBeforeTest:r?a.saveBeforeTest:a.microphoneHint}):null,s===`connecting`?(0,Q.jsx)(`p`,{children:a.connecting}):null,s===`listening`?(0,Q.jsx)(`p`,{children:a.speakNow}):null,l?(0,Q.jsx)(`p`,{className:`rounded-lg bg-surface-base p-3 text-sm text-fg`,children:l}):null,s===`playing`?(0,Q.jsx)(`p`,{children:a.playing}):null,s===`confirm`?(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{children:a.heardQuestion}),(0,Q.jsx)(M,{type:`button`,variant:`secondary`,onClick:()=>{x(),i?.({input:y.current,output:!0}),b(`passed`)},children:a.heard}),(0,Q.jsx)(M,{type:`button`,variant:`ghost`,onClick:()=>{x(),b(`error`),f(a.notHeard)},children:a.notHeardButton})]}):null,s===`passed`?(0,Q.jsx)(`p`,{children:y.current?n?a.passed:a.inputPassed:a.outputPassed}):null,s===`error`?(0,Q.jsx)(`p`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:d}):null]})]})}function Ne(e){let t=(0,X.c)(78),{section:n,v:r,form:i,pending:a,onChange:s}=e,l=c(Re),u=r.setup,p;t[0]===i?p=t[1]:(p=JSON.stringify(i),t[0]=i,t[1]=p);let m=p,h;t[2]===m?h=t[3]:(h={signature:m,input:!1,output:!1},t[2]=m,t[3]=h);let[g,_]=(0,Z.useState)(h);g.signature!==m&&_({signature:m,input:!1,output:!1});let v;t[4]!==a||t[5]!==m?(v=a?null:[`voice-realtime-status`,m],t[4]=a,t[5]=m,t[6]=v):v=t[6];let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y={revalidateOnFocus:!0},t[7]=y):y=t[7];let{data:x,error:S,isLoading:C}=k(v,ge,y),w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=o(`/api/voice/catalog`),t[8]=w):w=t[8];let{data:T}=k(w,Le),E=i.voice.realtime,D=E.tts,O=D?.provider??x?.tts?.provider,A=x?.tts?.model,j;t[9]!==A||t[10]!==O?(j=O&&A?[`realtime-voices`,O,A]:null,t[9]=A,t[10]=O,t[11]=j):j=t[11];let M;t[12]!==A||t[13]!==O?(M=()=>fe(O,A,`realtime`),t[12]=A,t[13]=O,t[14]=M):M=t[14];let N;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(N={revalidateOnFocus:!1},t[15]=N):N=t[15];let{data:P}=k(j,M,N),F;t[16]===P?F=t[17]:(F=P===void 0?[]:P,t[16]=P,t[17]=F);let I=F,L=I,R;t[18]===I?R=t[19]:(R=I.filter(Ie),t[18]=I,t[19]=R);let z=R,B=E.defaultEngine===`omni`,V=B?E.omni?.voice??``:D?.voice??``,H;t[20]!==T?.models||t[21]!==B||t[22]!==z||t[23]!==E.omni||t[24]!==L?(H=B&&E.omni?.provider===`qwen-token-plan-cn`?[{id:E.omni.voice,name:E.omni.voice}]:B?E.omni?.provider===`xopc-cloud`?T?.models.find(e=>e.id===E.omni?.model)?.voice.voices.filter(Fe)??[]:z.length?z:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(Pe):L,t[20]=T?.models,t[21]=B,t[22]=z,t[23]=E.omni,t[24]=L,t[25]=H):H=t[25];let U=H,te=!!(x?.enabled&&x.stt),ne=!!(x?.enabled&&x.tts),W;t[26]!==i||t[27]!==s||t[28]!==E?(W=e=>s({...i,voice:{...i.voice,realtime:{...E,...e}}}),t[26]=i,t[27]=s,t[28]=E,t[29]=W):W=t[29];let K=W,re;t[30]!==a||t[31]!==E.enabled||t[32]!==u.disabled||t[33]!==u.needsSetup||t[34]!==u.pending||t[35]!==u.unverified||t[36]!==u.verified||t[37]!==m||t[38]!==g.signature?(re=(e,t)=>E.enabled?a?u.pending:e?t&&g.signature===m?u.verified:u.unverified:u.needsSetup:u.disabled,t[30]=a,t[31]=E.enabled,t[32]=u.disabled,t[33]=u.needsSetup,t[34]=u.pending,t[35]=u.unverified,t[36]=u.verified,t[37]=m,t[38]=g.signature,t[39]=re):re=t[39];let q=re,J;t[40]!==V||t[41]!==l||t[42]!==B||t[43]!==O||t[44]!==E.bargeIn||t[45]!==E.defaultEngine||t[46]!==E.enabled||t[47]!==E.omni||t[48]!==E.tts||t[49]!==u.bargeIn||t[50]!==u.defaultVoice||t[51]!==u.enable||t[52]!==u.voice||t[53]!==n||t[54]!==D||t[55]!==x?.tts||t[56]!==K||t[57]!==r.experience||t[58]!==r.realtime||t[59]!==U?(J=n===`listening`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`span`,{children:u.enable}),(0,Q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":E.enabled,className:`ui-checkbox`,checked:E.enabled,onChange:e=>K({enabled:e.target.checked})})]}),(0,Q.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,Q.jsx)(`span`,{children:r.experience.defaultMode}),(0,Q.jsxs)(d,{value:E.defaultEngine,className:ee,onChange:e=>K({defaultEngine:e.target.value}),children:[(0,Q.jsx)(f,{value:`auto`,children:l===`zh`?`自动选择`:`Automatic`}),(0,Q.jsx)(f,{value:`agent`,children:r.experience.assistant}),(0,Q.jsx)(f,{value:`omni`,children:r.experience.natural})]})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[E.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsx)(`label`,{htmlFor:`realtime-voice`,className:`text-sm font-medium text-fg`,children:u.voice}),(0,Q.jsxs)(d,{id:`realtime-voice`,className:`${ee} w-full sm:w-56`,value:V,disabled:B?!E.omni:!D&&!x?.tts,onChange:e=>{if(B&&E.omni){K({omni:{...E.omni,voice:e.target.value}});return}if(O===`alibaba`||O===`xopc-cloud`){let t={...E.tts,provider:O};e.target.value?t.voice=e.target.value:delete t.voice,K({tts:t})}},children:[B?null:(0,Q.jsx)(f,{value:``,children:u.defaultVoice}),V&&!U.some(e=>e.id===V)?(0,Q.jsx)(f,{value:V,children:V}):null,U.map(e=>(0,Q.jsxs)(f,{value:e.id,children:[G(e,l),`gender`in e&&e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,`style`in e&&e.style?` · ${e.style}`:``]},e.id))]}),(()=>{let e=U.find(e=>e.id===V);return e&&`description`in e&&typeof e.description==`string`?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.description}):null})()]}),(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,Q.jsxs)(`span`,{children:[u.bargeIn,(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:r.realtime.bargeInDescription})]}),(0,Q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":E.bargeIn,checked:E.bargeIn,className:`size-4 accent-accent`,onChange:e=>K({bargeIn:e.target.checked})})]})]}):null,t[40]=V,t[41]=l,t[42]=B,t[43]=O,t[44]=E.bargeIn,t[45]=E.defaultEngine,t[46]=E.enabled,t[47]=E.omni,t[48]=E.tts,t[49]=u.bargeIn,t[50]=u.defaultVoice,t[51]=u.enable,t[52]=u.voice,t[53]=n,t[54]=D,t[55]=x?.tts,t[56]=K,t[57]=r.experience,t[58]=r.realtime,t[59]=U,t[60]=J):J=t[60];let ie;t[61]!==te||t[62]!==ne||t[63]!==S||t[64]!==C||t[65]!==a||t[66]!==n||t[67]!==m||t[68]!==x||t[69]!==q||t[70]!==r||t[71]!==g.input||t[72]!==g.output?(ie=n===`diagnostics`?(0,Q.jsxs)(Q.Fragment,{children:[C?(0,Q.jsx)(b,{className:`h-16 w-full`}):(0,Q.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,Q.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,q(te,g.input)]}),(0,Q.jsxs)(`p`,{children:[r.experience.agentReady,` · `,q(te&&ne,g.input&&g.output)]}),(0,Q.jsxs)(`p`,{children:[r.experience.omniReady,` · `,q(!!(x?.enabled&&x.omni),!1)]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,Q.jsx)(Me,{v:r,canListen:te,canSpeak:ne,disabled:a||C||!!S,onVerified:e=>_({signature:m,...e})},`${m}:${JSON.stringify(x)}`)]}):null,t[61]=te,t[62]=ne,t[63]=S,t[64]=C,t[65]=a,t[66]=n,t[67]=m,t[68]=x,t[69]=q,t[70]=r,t[71]=g.input,t[72]=g.output,t[73]=ie):ie=t[73];let ae;return t[74]!==u.service||t[75]!==J||t[76]!==ie?(ae=(0,Q.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":u.service,children:[J,ie]}),t[74]=u.service,t[75]=J,t[76]=ie,t[77]=ae):ae=t[77],ae}function Pe(e){return{id:e,name:e}}function Fe(e){return Ce(e,`conversation`)}function Ie(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function Le(e){return Te.parse((await l(e)).payload)}function Re(e){return e.language}function ze(e){let t=(0,X.c)(19),{value:n,onChange:r}=e,i=c(Be)===`zh`,a=i?`通话指令`:`Conversation instructions`,o;t[0]===a?o=t[1]:(o=(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:a}),t[0]=a,t[1]=o);let s=i?`通话会接续当前会话。可在这里调整语气与回答方式。`:`Calls continue the current conversation. Adjust tone and response style here.`,l;t[2]===s?l=t[3]:(l=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s}),t[2]=s,t[3]=l);let u=i?`通话指令`:`Conversation instructions`,d;t[4]===u?d=t[5]:(d=(0,Q.jsx)(`span`,{children:u}),t[4]=u,t[5]=d);let f;t[6]!==r||t[7]!==n?(f=e=>r({...n,instructions:e.target.value}),t[6]=r,t[7]=n,t[8]=f):f=t[8];let p;t[9]!==f||t[10]!==n.instructions?(p=(0,Q.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,rows:3,maxLength:8e3,value:n.instructions,onChange:f}),t[9]=f,t[10]=n.instructions,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==p?(m=(0,Q.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==o||t[16]!==l||t[17]!==m?(h=(0,Q.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[o,l,m]}),t[15]=o,t[16]=l,t[17]=m,t[18]=h):h=t[18],h}function Be(e){return e.language}function Ve({disabled:e=!1}){let t=c(e=>e.language),n=t===`zh`,{data:r,error:i,mutate:s}=k(o(_e),me),[l,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(0),_=(0,Z.useId)();(0,Z.useLayoutEffect)(()=>{g(e=>e+1)},[]);let[v,y]=(0,Z.useState)(),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(!1),D=B({disabled:e||x,chat:u(t).chat,onTranscript:()=>{},onTestAudioPlayed:()=>E(!0)}),j=D.phase!==`idle`&&D.phase!==`error`,P=v??r?.voice??`default`,F=r?.credentialSource===`global`;async function I(){try{return await Y()}catch(e){throw e instanceof Error&&`status`in e&&e.status===404?Error(n?`当前 Gateway 版本不支持查看密钥。请更新并重启 Gateway。`:`Update and restart the Gateway to view or copy the saved key.`):e}}async function L(e){if(!(x||j)){S(!0),w(``);try{await s(await de(e),{revalidate:!1}),`apiKey`in e&&(m(``),g(e=>e+1),E(!1),D.cancelVoiceInput()),await A()}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}}}return(0,Q.jsxs)(`section`,{className:`@container space-y-3 rounded-xl border border-edge bg-surface-panel p-4`,"aria-label":`Boson AI`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Boson AI · Higgs Realtime`}),!r&&!i?(0,Q.jsx)(b,{className:`h-24 w-full`}):null,i?(0,Q.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[n?`无法读取 Boson 设置。`:`Could not load Boson settings.`,(0,Q.jsx)(M,{variant:`ghost`,onClick:()=>void s(),children:n?`重试`:`Retry`})]}):null,r&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`fieldset`,{disabled:e||x||j,className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`label`,{htmlFor:_,className:`text-sm font-medium text-fg`,children:`Boson API Key`}),(0,Q.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:r.credentialSource===`env`?n?`已从环境读取 BOSON_API_KEY`:`Using BOSON_API_KEY from the environment`:r.credentialSource?n?`已保存 API Key`:`API key saved`:n?`尚未连接`:`Connection needed`})]}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-2 @min-[32rem]:grid-cols-[minmax(0,1fr)_auto]`,children:[(0,Q.jsx)(p,{id:_,value:l||(F?`••••••••••••`:``),onChange:e=>m(e.replace(/^•+/u,``)),autoComplete:`new-password`,inputClassName:`min-h-11`,labels:{show:n?`显示密钥`:`Show key`,hide:n?`隐藏密钥`:`Hide key`,copy:n?`复制密钥`:`Copy key`,copied:n?`已复制`:`Copied`},reveal:F?I:void 0,allowUnrevealedCopy:!0,loadFailedLabel:n?`无法查看已保存的密钥。`:`Could not load the saved key.`,notInConfigFile:n?`当前没有已保存的密钥。`:`There is no saved key.`},`${F}:${h}`),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(M,{className:`min-h-11`,variant:`secondary`,type:`button`,disabled:!l.trim(),onClick:()=>void L({apiKey:l}),children:x?n?`正在保存…`:`Saving…`:n?`保存密钥`:`Save key`}),F&&(0,Q.jsx)(M,{className:`min-h-11`,type:`button`,variant:`ghost`,onClick:()=>void L({apiKey:null}),children:n?`移除已保存密钥`:`Remove saved key`})]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,Q.jsx)(`span`,{children:n?`Higgs 默认音色`:`Default Higgs voice`}),(0,Q.jsx)(d,{"aria-label":n?`Higgs 默认音色`:`Default Higgs voice`,value:P,onChange:e=>{y(e.target.value),E(!1),D.cancelVoiceInput()},children:O.map(e=>(0,Q.jsx)(f,{value:e,children:e==="default"?n?`模型默认`:`Model default`:e},e))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(M,{type:`button`,variant:`secondary`,disabled:P===r.voice||!r.credentialSource,onClick:()=>void L({voice:P}),children:n?`保存音色`:`Save voice`}),(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:r.defaultForNatural?n?`当前全局自然语音模型`:`Current global natural voice model`:n?`在上方选择全局自然语音模型`:`Choose the global natural voice model above`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`测试时请说一句中文,听到回复后可以插话。音频由 Boson 处理,测试内容仅在当前面板显示,可能产生用量。`:`Say a sentence and try interrupting the reply. Boson processes the audio. Test content stays in this panel and may incur usage.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[j?(0,Q.jsx)(M,{type:`button`,variant:`secondary`,onClick:D.cancelVoiceInput,children:n?`结束测试`:`End test`}):(0,Q.jsx)(M,{type:`button`,variant:`secondary`,disabled:e||x||!r.credentialSource,onClick:()=>{D.cancelVoiceInput(),E(!1),w(``),D.startHiggsTest(P)},children:n?`测试通话`:`Test call`}),r.credentialSource&&!e&&!x&&!j&&(0,Q.jsx)(a,{className:`px-2 text-sm text-accent-fg hover:underline`,to:`/personal`,onClick:N,children:n?`打开 Ada`:`Open Ada`})]}),j&&(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:D.phase===`recording`?D.responsePhase===`speaking`?n?`正在播放,可以插话`:`Playing reply. You can interrupt.`:n?`麦克风已开启,请说话`:`Microphone on. Say something.`:n?`正在连接测试通话…`:`Connecting test call…`}),T&&(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-success`,children:n?`测试通过,已播放回复`:`Test passed. Reply played.`}),D.finalTranscript&&(0,Q.jsxs)(`p`,{className:`text-sm text-fg`,children:[n?`转写 · `:`Transcript · `,D.finalTranscript]}),D.responseText&&(0,Q.jsxs)(`p`,{className:`text-sm text-fg`,children:[n?`回复 · `:`Reply · `,D.responseText]})]})]}),(C||D.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:C||D.error})]})}var He=U;function Ue(){return y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,te,`dark:border-edge`)}function $(){return y(ee,U)}function We(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ge(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}function Ke(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function qe(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`minimax`:return`MiniMax`;default:return e}}function Je(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;default:return t.tts.providerHints.generic}}function Ye(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Xe(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type!==`boolean`&&``:t.defaultValue}function Ze(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Qe(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`saved`:{let n=structuredClone(t.value);return{form:e.form!==null&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function $e(e){let t=(0,X.c)(10),[n,r]=(0,Z.useState)(0),i;t[0]!==e.capability||t[1]!==e.disabled?(i=e.capability===`conversation`&&(0,Q.jsx)(Ve,{disabled:e.disabled}),t[0]=e.capability,t[1]=e.disabled,t[2]=i):i=t[2];let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>r(et),t[3]=a):a=t[3];let o;t[4]!==n||t[5]!==e?(o=(0,Q.jsx)(tt,{...e,onReload:a},n),t[4]=n,t[5]=e,t[6]=o):o=t[6];let s;return t[7]!==i||t[8]!==o?(s=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[i,o]}),t[7]=i,t[8]=o,t[9]=s):s=t[9],s}function et(e){return e+1}function tt({capability:e,onPendingChange:t,disabled:n=!1,onReload:r}){let i=c(e=>e.language),a=u(i).voiceSettings,l=I(e=>e.captions),p=I(e=>e.setCaptions),m=!!s(e=>e.conversationId),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useReducer)(Qe,{form:null,baseline:null}),y=_.form,b=_.baseline,[x,S]=(0,Z.useState)(null),C=(0,Z.useRef)(!1),w=(0,Z.useRef)({}),T=(0,Z.useRef)(y);T.current=y;let E=(0,Z.useRef)({parsed:null,models:void 0}),{data:D,error:O,isLoading:A,mutate:N}=j(m),{data:P,error:F,isLoading:L,mutate:R}=k(m?o(`/api/voice/models`):null,oe,{revalidateOnFocus:!1}),{data:z,error:B,isLoading:V}=k(m?o(`/api/voice/providers`):null,he,{revalidateOnFocus:!1}),{data:H,error:U,isLoading:ee}=k(m?o(`/api/voice/stt-providers`):null,se,{revalidateOnFocus:!1}),te=(0,Z.useMemo)(()=>z?.providers??[],[z]),ne=(0,Z.useMemo)(()=>H?.providers??[],[H]),W=(0,Z.useMemo)(()=>D?.payload?.config===void 0?null:pe(D.payload.config),[D]),G=(0,Z.useMemo)(()=>!y||!b?!1:JSON.stringify(y)!==JSON.stringify(b),[y,b]);m?W!==null&&P!==void 0&&!C.current&&(E.current.parsed!==W||E.current.models!==P)&&(E.current={parsed:W,models:P},w.current=le(D?.payload?.config),v({type:`sync`,value:W}),S(P)):(E.current.parsed!==null||E.current.models!==void 0)&&(E.current={parsed:null,models:void 0},v({type:`reset`}),S(null),C.current=!1);let re=!!(m&&(W===null||P===void 0||z===void 0||H===void 0)&&(A||L||V||ee)),q=O instanceof Error?O.message:O?String(O):F instanceof Error?F.message:F?String(F):B instanceof Error?B.message:B?String(B):U instanceof Error?U.message:U?String(U):null,J=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e},...e.provider&&e.provider!==`xopc-cloud`?{voice:{...t.voice,realtime:{...t.voice.realtime,stt:void 0}}}:{}}:null})},[]),ce=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ue=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),de=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>t?{...t,voice:{...t.voice,languageMode:e,...e===`auto`?{language:i}:{}}}:null})},[i]),fe=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),me=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),Y=ae({value:y,dirty:G,onSave:(0,Z.useCallback)(async t=>{try{let n=await ve(t,e,w.current[e]);w.current={...w.current,...n},v({type:`saved`,value:t}),C.current=!!(T.current&&JSON.stringify(T.current)!==JSON.stringify(t))}catch(e){throw Error(e instanceof Error?e.message:a.saveError)}},[a.saveError,e])});(0,Z.useEffect)(()=>{t?.(G||Y.status===`saving`||h)},[G,Y.status,h,t]),(0,Z.useEffect)(()=>()=>t?.(!1),[t]);let ge=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:()=>e})},[]);if(!m)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.needToken})});if(re)return(0,Q.jsx)(K,{rows:4});if(!y||x===null)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:q??a.loadError}),(0,Q.jsx)(M,{type:`button`,variant:`secondary`,onClick:()=>{N(),R()},children:a.retry})]});let _e=y.stt,ye=y.tts,be=y.voice.input.refinement,xe=Ye(a);return(0,Q.jsxs)(`fieldset`,{disabled:n||h,className:`flex min-w-0 flex-col gap-4`,onBlurCapture:Y.error?void 0:Y.onBlurCapture,children:[(0,Q.jsx)(ie,{status:Y.status,error:Y.error}),Y.error?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(M,{variant:`secondary`,onClick:Y.retry,children:i===`zh`?`重试保存`:`Retry saving`}),(0,Q.jsx)(M,{variant:`ghost`,onClick:()=>{N().then(()=>r()).catch(()=>{})},children:i===`zh`?`重新加载(放弃未保存更改)`:`Reload and discard unsaved changes`})]}):null,e===`transcription`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ae,{zh:i===`zh`}),(0,Q.jsx)(it,{managedModel:!0,v:a,apiKeyLabels:xe,stt:_e,models:x,sttProviders:ne,updateStt:J,updateSttFallback:ce}),(0,Q.jsx)(rt,{v:a,voice:y.voice,updateLanguageMode:de}),(0,Q.jsxs)(`details`,{"data-voice-section":`input-processing`,className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[a.experience.inputProcessing,` · `,be.mode===`off`?a.stt.refinementOff:be.mode===`punctuation`?a.stt.refinementPunctuation:be.mode===`light`?a.stt.refinementLight:a.setup.advanced]}),(0,Q.jsxs)(`label`,{className:`mt-4 block space-y-2 text-sm`,children:[(0,Q.jsx)(`span`,{children:a.stt.refinement}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.stt.refinementDesc}),(0,Q.jsxs)(d,{className:$(),value:be.mode,onChange:e=>ue({mode:e.target.value}),children:[(0,Q.jsx)(f,{value:`off`,children:a.stt.refinementOff}),(0,Q.jsx)(f,{value:`punctuation`,children:a.stt.refinementPunctuation}),(0,Q.jsx)(f,{value:`light`,children:a.stt.refinementLight}),be.mode===`custom`?(0,Q.jsx)(f,{value:`custom`,children:a.setup.advanced}):null]})]})]}),_e.provider===`xopc-cloud`?(0,Q.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`实时听写`:`Live dictation`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(Ee,{modes:[`transcription.stream`],disabled:G||Y.status===`saving`,onPendingChange:g})})]}):null]}):e===`speech`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ot,{managedModel:!0,v:a,apiKeyLabels:xe,tts:ye,models:x,ttsProviders:te,updateTts:me}),(0,Q.jsx)(nt,{v:a,tts:ye,updateTts:me})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ne,{section:`listening`,v:a,form:y,pending:G||Y.status===`saving`||!!Y.error,onChange:ge}),y.voice.realtime.defaultEngine===`omni`&&y.voice.realtime.omni?(0,Q.jsx)(ze,{value:y.voice.realtime.omni,onChange:e=>fe({omni:e})}):null,(0,Q.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:a.experience.pace}),(0,Q.jsxs)(d,{className:$(),value:String(y.voice.realtime.silenceDurationMs),onChange:e=>fe({silenceDurationMs:Number(e.target.value)}),children:[(0,Q.jsx)(f,{value:`800`,children:a.experience.fast}),(0,Q.jsx)(f,{value:`1200`,children:a.experience.standard}),(0,Q.jsx)(f,{value:`2000`,children:a.experience.relaxed}),[800,1200,2e3].includes(y.voice.realtime.silenceDurationMs)?null:(0,Q.jsxs)(f,{value:String(y.voice.realtime.silenceDurationMs),children:[y.voice.realtime.silenceDurationMs,` ms`]})]})]})}),(0,Q.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[a.experience.captions,(0,Q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":l,className:`ui-checkbox`,checked:l,onChange:e=>p(e.target.checked)})]}),y.voice.realtime.defaultEngine===`agent`&&_e.provider===`xopc-cloud`?(0,Q.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`语音助手输出`:`Assistant speech output`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(Ee,{modes:[`speech.stream`],disabled:G||Y.status===`saving`,onPendingChange:g})})]}):null,(0,Q.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`麦克风、扬声器与诊断`:`Microphone, speakers and diagnostics`}),(0,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,Q.jsx)(De,{v:a}),(0,Q.jsx)(Ne,{section:`diagnostics`,v:a,form:y,pending:G||Y.status===`saving`||!!Y.error,onChange:ge})]})]})]})]})}function nt(e){let t=(0,X.c)(29),{v:n,tts:r,updateTts:i}=e,a;t[0]===n.setup.readout?a=t[1]:(a=(0,Q.jsx)(`span`,{className:`font-medium`,children:n.setup.readout}),t[0]=n.setup.readout,t[1]=a);let o=n.setup.readout,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=$(),t[2]=s):s=t[2];let c=r.enabled?r.trigger:`off`,l;t[3]===i?l=t[4]:(l=e=>i({enabled:e.target.value!==`off`,trigger:e.target.value}),t[3]=i,t[4]=l);let u;t[5]===n.tts.triggerOff?u=t[6]:(u=(0,Q.jsx)(f,{value:`off`,children:n.tts.triggerOff}),t[5]=n.tts.triggerOff,t[6]=u);let p;t[7]===n.tts.triggerInbound?p=t[8]:(p=(0,Q.jsx)(f,{value:`inbound`,children:n.tts.triggerInbound}),t[7]=n.tts.triggerInbound,t[8]=p);let m;t[9]===n.tts.triggerAlways?m=t[10]:(m=(0,Q.jsx)(f,{value:`always`,children:n.tts.triggerAlways}),t[9]=n.tts.triggerAlways,t[10]=m);let h;t[11]===n.tts.triggerTagged?h=t[12]:(h=(0,Q.jsx)(f,{value:`tagged`,children:n.tts.triggerTagged}),t[11]=n.tts.triggerTagged,t[12]=h);let g;t[13]!==c||t[14]!==l||t[15]!==u||t[16]!==p||t[17]!==m||t[18]!==h||t[19]!==n.setup.readout?(g=(0,Q.jsxs)(d,{"aria-label":o,className:s,value:c,onChange:l,children:[u,p,m,h]}),t[13]=c,t[14]=l,t[15]=u,t[16]=p,t[17]=m,t[18]=h,t[19]=n.setup.readout,t[20]=g):g=t[20];let _;t[21]!==a||t[22]!==g?(_=(0,Q.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[a,g]}),t[21]=a,t[22]=g,t[23]=_):_=t[23];let v;t[24]===n.setup.readoutHint?v=t[25]:(v=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.readoutHint}),t[24]=n.setup.readoutHint,t[25]=v);let y;return t[26]!==_||t[27]!==v?(y=(0,Q.jsxs)(`section`,{className:`space-y-2 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,children:[_,v]}),t[26]=_,t[27]=v,t[28]=y):y=t[28],y}function rt(e){let t=(0,X.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,Q.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=$(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let p;t[10]===n.language.auto?p=t[11]:(p=(0,Q.jsx)(f,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=p);let m;t[12]===n.language.manual?m=t[13]:(m=(0,Q.jsx)(f,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=m);let h;t[14]!==u||t[15]!==p||t[16]!==m||t[17]!==r.languageMode?(h=(0,Q.jsxs)(d,{className:l,value:r.languageMode,onChange:u,children:[p,m]}),t[14]=u,t[15]=p,t[16]=m,t[17]=r.languageMode,t[18]=h):h=t[18];let g;return t[19]!==c||t[20]!==h?(g=(0,Q.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,h]})}),t[19]=c,t[20]=h,t[21]=g):g=t[21],g}function it(e){let t=(0,X.c)(65),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c,managedModel:l}=e,u=l!==void 0&&l,p;if(t[0]!==o){let e=new Set;p=[];for(let t of o)e.has(t.id)||(e.add(t.id),p.push(t));t[0]=o,t[1]=p}else p=t[1];let m=p,g,_,v,b;if(t[2]!==a||t[3]!==m||t[4]!==i.provider||t[5]!==i.providers){g=m.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],v=e,_=a?.stt?.[i.provider]?.length?a.stt[i.provider]:g?.models??[],b=g?.fields.find(at),t[2]=a,t[3]=m,t[4]=i.provider,t[5]=i.providers,t[6]=g,t[7]=_,t[8]=v,t[9]=b}else g=t[6],_=t[7],v=t[8],b=t[9];let x=b,S=typeof v.model==`string`?v.model:void 0,C=S??(typeof x?.defaultValue==`string`?x.defaultValue:_[0]?.id),w;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(w=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=s,t[16]=w):w=t[16];let T=w,E,D;t[17]!==S||t[18]!==C||t[19]!==u||t[20]!==x||t[21]!==T?(E=()=>{!u&&x&&C&&S!==C&&T({model:C})},D=[u,S,C,x,T],t[17]=S,t[18]=C,t[19]=u,t[20]=x,t[21]=T,t[22]=E,t[23]=D):(E=t[22],D=t[23]),(0,Z.useEffect)(E,D);let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Q.jsx)(h,{"aria-hidden":`true`,className:`size-4 text-accent`,strokeWidth:1.75}),t[24]=O):O=t[24];let k;t[25]===n.stt.title?k=t[26]:(k=(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[O,n.stt.title]}),t[25]=n.stt.title,t[26]=k);let A;t[27]===n.stt.enable?A=t[28]:(A=(0,Q.jsx)(`span`,{children:n.stt.enable}),t[27]=n.stt.enable,t[28]=A);let j;t[29]===s?j=t[30]:(j=e=>s({enabled:e.target.checked}),t[29]=s,t[30]=j);let M;t[31]!==i.enabled||t[32]!==j?(M=(0,Q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i.enabled,className:`ui-checkbox`,checked:i.enabled,onChange:j}),t[31]=i.enabled,t[32]=j,t[33]=M):M=t[33];let N;t[34]!==M||t[35]!==A?(N=(0,Q.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-xs text-fg-muted`,children:[A,M]}),t[34]=M,t[35]=A,t[36]=N):N=t[36];let P;t[37]!==N||t[38]!==k?(P=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[k,N]}),t[37]=N,t[38]=k,t[39]=P):P=t[39];let F;t[40]===n.stt.description?F=t[41]:(F=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[40]=n.stt.description,t[41]=F);let I;t[42]!==P||t[43]!==F?(I=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[P,F]}),t[42]=P,t[43]=F,t[44]=I):I=t[44];let L;t[45]!==g?.fields||t[46]!==r||t[47]!==C||t[48]!==u||t[49]!==_||t[50]!==m||t[51]!==v||t[52]!==i.enabled||t[53]!==i.fallback?.enabled||t[54]!==i.provider||t[55]!==T||t[56]!==s||t[57]!==c||t[58]!==n?(L=i.enabled?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[u?null:(0,Q.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,He),children:[(0,Q.jsx)(mt,{children:n.stt.provider}),(0,Q.jsx)(d,{"aria-label":n.stt.provider,className:$(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:m.map(e=>(0,Q.jsxs)(f,{value:e.id,children:[Ke(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Q.jsx)(st,{managedModel:u,kind:`stt`,providerId:i.provider,fields:g?.fields??[],providerSlice:v,models:_,currentModel:C,apiKeyLabels:r,onPatch:T})]}),i.provider===`alibaba`?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.keyHint}):null,(0,Q.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>c({enabled:e.target.checked})})]})]})]}):null,t[45]=g?.fields,t[46]=r,t[47]=C,t[48]=u,t[49]=_,t[50]=m,t[51]=v,t[52]=i.enabled,t[53]=i.fallback?.enabled,t[54]=i.provider,t[55]=T,t[56]=s,t[57]=c,t[58]=n,t[59]=L):L=t[59];let R;t[60]===L?R=t[61]:(R=(0,Q.jsx)(`div`,{className:`space-y-4`,children:L}),t[60]=L,t[61]=R);let z;return t[62]!==I||t[63]!==R?(z=(0,Q.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[I,R]}),t[62]=I,t[63]=R,t[64]=z):z=t[64],z}function at(e){return e.key===`model`}function ot({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,managedModel:o=!1}){let[s,c]=(0,Z.useState)(e.tts.test.sampleText),[l,u]=(0,Z.useState)({status:`idle`}),p=(0,Z.useRef)(null),h=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x=(0,Z.useCallback)(()=>{b.current?.abort(),b.current=null,p.current?.pause(),p.current=null,h.current&&=(URL.revokeObjectURL(h.current),null)},[]),S=(0,Z.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),C=S.find(e=>e.id===n.provider),w=n.providers?.[n.provider]??{},T=r?.tts?.[n.provider]?.length?r.tts[n.provider]:C?.models??[],E=C?.fields.find(e=>e.key===`model`),D=C?.fields.find(e=>e.key===`voice`),O=typeof w.model==`string`?w.model:void 0,A=O??(typeof E?.defaultValue==`string`?E.defaultValue:T[0]?.id),j=T.find(e=>e.id===A),N=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:C?.voices??[],{data:P=[]}=k(A?`voice:tts:${n.provider}:${A}`:null,()=>fe(n.provider,A??``),{revalidateOnFocus:!1}),F=P.length>0?P:N,I=typeof w.voice==`string`?w.voice:void 0,L=I??F.find(e=>e.id===j?.tts?.defaultVoice)?.id??(typeof D?.defaultValue==`string`?D.defaultValue:F[0]?.id),R=(C?.fields??[]).filter(e=>(e.key!==`speed`||j?.tts?.speed!==!1)&&(e.key!==`instructions`||j?.tts?.instructions!==!1)),z=(0,Z.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Z.useEffect)(()=>{if(o)return;let e={};E&&A&&O!==A&&(e.model=A),D&&L&&I!==L&&(e.voice=L),Object.keys(e).length>0&&z(e)},[o,O,I,A,L,E,z,D]),(0,Z.useEffect)(()=>()=>x(),[x]);let B=(0,Z.useCallback)(e=>{a({provider:e}),u({status:`idle`})},[a]),V=(0,Z.useCallback)(async()=>{let t=s.trim();if(!t){u({status:`error`,message:e.tts.test.emptyText});return}x();let r=new AbortController;b.current=r,u({status:`loading`});try{let i=await ue({text:t,provider:n.provider,providerConfig:w,...A?{model:A}:{},...L?{voice:L}:{}},r.signal);if(r.signal.aborted)return;let a=Ge(i.audio,i.mimeType);h.current=a;let o=new Audio(a);p.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,We(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>u({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>u({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),u({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;x(),u({status:`error`,message:e instanceof Error?e.message:String(e)})}},[A,L,w,x,s,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,Q.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[(0,Q.jsxs)(`div`,{className:`mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(v,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:o?null:(0,Q.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,He),children:[(0,Q.jsx)(mt,{children:e.tts.provider}),(0,Q.jsx)(d,{"aria-label":e.tts.provider,className:$(),value:n.provider,onChange:e=>B(e.target.value),children:S.map(t=>(0,Q.jsx)(f,{value:t.id,children:qe(t.id,e)},t.id))}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[C?.configured?e.tts.configured:C?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${C.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,C?.description??Je(n.provider,e)]})]})}),(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,Q.jsx)(st,{managedModel:o,kind:`tts`,providerId:n.provider,fields:R,providerSlice:w,models:T,voices:F,currentModel:A,currentVoice:L,apiKeyLabels:t,onPatch:z,resetVoiceOnModelChange:!0})}),(0,Q.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e.tts.test.title}),(0,Q.jsxs)(`div`,{className:`mt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsxs)(M,{type:`button`,variant:`primary`,onClick:()=>void V(),disabled:l.status===`loading`,className:`h-9`,children:[l.status===`loading`?(0,Q.jsx)(m,{className:`size-4 animate-spin`}):(0,Q.jsx)(g,{className:`size-4`}),l.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Q.jsxs)(M,{type:`button`,variant:`secondary`,onClick:()=>{x(),u(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:l.status!==`playing`,className:`h-9`,children:[(0,Q.jsx)(_,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Q.jsxs)(`details`,{className:`mt-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:e.setup.sampleText}),(0,Q.jsx)(`textarea`,{className:y(Ue(),`mt-3 min-h-20 resize-y`),value:s,onChange:e=>c(e.target.value),maxLength:1e3})]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,Q.jsxs)(`span`,{className:`text-fg-subtle`,children:[s.length,`/1000`]}),l.status===`playing`||l.status===`done`?(0,Q.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[l.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,l.summary]}):null,l.status===`error`?(0,Q.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:l.message}):null]})]})]})]})})]})}function st(e){let t=(0,X.c)(48),{kind:n,providerId:r,fields:i,providerSlice:a,models:o,voices:s,currentModel:l,currentVoice:p,apiKeyLabels:m,onPatch:h,resetVoiceOnModelChange:g,managedModel:_}=e,v;t[0]===s?v=t[1]:(v=s===void 0?[]:s,t[0]=s,t[1]=v);let b=v,x=g!==void 0&&g,S=_!==void 0&&_,C=c(dt),w;t[2]===C?w=t[3]:(w=u(C),t[2]=C,t[3]=w);let T=w.voiceSettings,E=S,D=ut,O=lt,k,A,j;if(t[4]!==m||t[5]!==l||t[6]!==p||t[7]!==i||t[8]!==n||t[9]!==C||t[10]!==S||t[11]!==o||t[12]!==h||t[13]!==r||t[14]!==a||t[15]!==x||t[16]!==E||t[17]!==T||t[18]!==b){let e;t[22]===E?e=t[23]:(e=e=>!E||e.key!==`model`&&!O(e),t[22]=E,t[23]=e);let s=i.filter(e),c;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>!D(e),t[24]=c):c=t[24];let u=s.filter(c),g;t[25]!==m||t[26]!==l||t[27]!==p||t[28]!==n||t[29]!==C||t[30]!==S||t[31]!==o||t[32]!==h||t[33]!==r||t[34]!==a||t[35]!==x||t[36]!==T||t[37]!==b?(g=e=>e.map(e=>S&&e.key===`model`?null:e.key===`apiKey`?(0,Q.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,He),children:[(0,Q.jsx)(mt,{htmlFor:`voice-${n}-${r}-api-key`,children:T.stt.apiKey}),(0,Q.jsx)(ye,{kind:n,providerId:r,fieldId:`voice-${n}-${r}-api-key`,value:typeof a.apiKey==`string`?a.apiKey:``,onChange:e=>h({apiKey:e}),labels:m,placeholder:e.placeholder}),e.description?(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.description}):null]},e.key):e.key===`model`&&o.length>0?(0,Q.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,He),children:[(0,Q.jsx)(mt,{htmlFor:`voice-${n}-${r}-model`,children:T.stt.model}),(0,Q.jsx)(d,{id:`voice-${n}-${r}-model`,className:$(),value:l??``,onChange:e=>h({model:e.target.value,...x?{voice:void 0}:{}}),children:[...o].sort(W).map(ct)})]},e.key):e.key===`voice`&&b.length>0?(0,Q.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,He),children:[(0,Q.jsx)(mt,{htmlFor:`voice-${n}-${r}-voice`,children:T.tts.voice}),(0,Q.jsxs)(d,{id:`voice-${n}-${r}-voice`,className:$(),value:p??``,onChange:e=>h({voice:e.target.value}),children:[p&&!b.some(e=>e.id===p)?(0,Q.jsxs)(f,{value:p,children:[p,` · unavailable`]}):null,b.map(e=>(0,Q.jsxs)(f,{value:e.id,children:[G(e,C),e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,e.style?` · ${e.style}`:``]},e.id))]}),b.find(e=>e.id===p)?.description?(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:b.find(e=>e.id===p)?.description}):null]},e.key):(0,Q.jsx)(ft,{fieldId:`voice-${n}-${r}-${e.key}`,field:e,value:Xe(a,e),onChange:t=>h({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:He},e.key)),t[25]=m,t[26]=l,t[27]=p,t[28]=n,t[29]=C,t[30]=S,t[31]=o,t[32]=h,t[33]=r,t[34]=a,t[35]=x,t[36]=T,t[37]=b,t[38]=g):g=t[38];let _=g;t[39]!==i||t[40]!==n||t[41]!==C||t[42]!==E?(k=E&&i.some(O)?(0,Q.jsx)(ke,{className:`text-sm text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=${n===`stt`?`transcription`:`speech`}`,children:C===`zh`?`管理服务连接`:`Manage service connection`}):null,t[39]=i,t[40]=n,t[41]=C,t[42]=E,t[43]=k):k=t[43],A=_(s.filter(D)),j=u.length?(0,Q.jsxs)(`details`,{className:`rounded-lg border border-edge p-3 sm:col-span-2`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:T.experience.providerOptions}),(0,Q.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:_(u)})]}):null,t[4]=m,t[5]=l,t[6]=p,t[7]=i,t[8]=n,t[9]=C,t[10]=S,t[11]=o,t[12]=h,t[13]=r,t[14]=a,t[15]=x,t[16]=E,t[17]=T,t[18]=b,t[19]=k,t[20]=A,t[21]=j}else k=t[19],A=t[20],j=t[21];let M;return t[44]!==k||t[45]!==A||t[46]!==j?(M=(0,Q.jsxs)(Q.Fragment,{children:[k,A,j]}),t[44]=k,t[45]=A,t[46]=j,t[47]=M):M=t[47],M}function ct(e){return(0,Q.jsx)(f,{value:e.id,children:e.name},e.id)}function lt(e){return e.secret||e.type===`password`||[`apiKey`,`baseUrl`,`region`,`groupId`].includes(e.key)}function ut(e){return e.required||[`apiKey`,`model`,`voice`].includes(e.key)}function dt(e){return e.language}function ft(e){let t=(0,X.c)(37),{fieldId:n,field:r,value:i,onChange:a,className:o}=e,s=n??`voice-schema-field-${r.key}`,c=r.description;if(r.type===`boolean`){let e;t[0]===o?e=t[1]:(e=y(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let n;t[2]===r.label?n=t[3]:(n=(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r.label}),t[2]=r.label,t[3]=n);let s;t[4]===c?s=t[5]:(s=c?(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=s);let l;t[6]!==n||t[7]!==s?(l=(0,Q.jsxs)(`span`,{children:[n,s]}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let u=!!i,d;t[9]!==r||t[10]!==a?(d=e=>a(Ze(r,e.target.checked)),t[9]=r,t[10]=a,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,Q.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let l=typeof i==`boolean`?``:String(i),u;t[19]===o?u=t[20]:(u=y(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let f;t[21]!==r.label||t[22]!==s?(f=(0,Q.jsx)(mt,{htmlFor:s,children:r.label}),t[21]=r.label,t[22]=s,t[23]=f):f=t[23];let m;t[24]!==o||t[25]!==r||t[26]!==l||t[27]!==s||t[28]!==a?(m=r.type===`select`?(0,Q.jsx)(d,{id:s,className:$(),value:l,required:r.required,onChange:e=>a(Ze(r,e.target.value)),children:(r.options??[]).map(pt)}):r.type===`textarea`?(0,Q.jsx)(`textarea`,{id:s,className:y(Ue(),`min-h-24 resize-y`),value:l,required:r.required,placeholder:r.placeholder,onChange:e=>a(Ze(r,e.target.value))}):r.type===`password`?(0,Q.jsx)(p,{id:s,className:o,value:l,onChange:e=>a(Ze(r,e)),placeholder:r.placeholder,labels:ne}):r.type===`number`?(0,Q.jsx)(J,{id:s,className:Ue(),autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,allowEmpty:!r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(Ze(r,e.target.value))}):(0,Q.jsx)(`input`,{id:s,className:Ue(),type:`text`,autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(Ze(r,e.target.value))}),t[24]=o,t[25]=r,t[26]=l,t[27]=s,t[28]=a,t[29]=m):m=t[29];let h;t[30]===c?h=t[31]:(h=c?(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[30]=c,t[31]=h);let g;return t[32]!==u||t[33]!==f||t[34]!==m||t[35]!==h?(g=(0,Q.jsxs)(`div`,{className:u,children:[f,m,h]}),t[32]=u,t[33]=f,t[34]=m,t[35]=h,t[36]=g):g=t[36],g}function pt(e){return(0,Q.jsx)(f,{value:e.id,children:e.name},e.id)}function mt(e){let t=(0,X.c)(3),{children:n,htmlFor:r}=e,i;return t[0]!==n||t[1]!==r?(i=r?(0,Q.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:n}):(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}export{Oe as n,$e as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as o,l as s,n as c,o as l}from"./locale-store-Dy1EByeG.js";import{t as u}from"./messages-BAnhwALN.js";import{n as d,r as f}from"./popover-select-CLsphyzA.js";import{t as p}from"./secret-input-DsjfQmDn.js";import{t as m}from"./loader-circle-CifKLtgG.js";import{t as h}from"./mic-CuUb7zc-.js";import{t as g}from"./play-kxZvpBg8.js";import{t as _}from"./square-DMK_fB-3.js";import{t as v}from"./volume-2-BSJhAY97.js";import{t as y}from"./cn-0WouolD0.js";import{t as b}from"./skeleton-DzdOeGYz.js";import{a as x,c as S,i as C,m as w,n as T,p as E,u as D}from"./schemas-CCWMleym.js";import{n as O}from"./voice-CDlC6XMH.js";import{i as k}from"./vendor-swr-CdRzEUwF.js";import{n as A,r as j}from"./gateway-config-swr-1Rk0LeEM.js";import{t as M}from"./button-Cc4hUNTt.js";import{t as N}from"./open-capability-settings-DQsmJxI7.js";import{a as P,d as F,f as I,i as L,o as R,p as z,t as B,u as V}from"./use-realtime-voice-C7iWQuUv.js";import{t as H}from"./voice-call-context-BM2A4bLz.js";import{a as U,o as ee,s as te}from"./form-field-width-DJw_jULe.js";import{t as ne}from"./secret-input-labels-B5Jl5HqK.js";import{n as W}from"./model-sort-_Tz8s_4N.js";import{r as G}from"./model-selector-C-CqPBao.js";import{t as K}from"./settings-loading-skeleton-CAoOV17i.js";import{a as re,i as q}from"./capability-navigation-QtHJxxW2.js";import{t as J}from"./number-input-El7Szeln.js";import{n as ie,t as ae}from"./use-autosave-N_SjHXTw.js";import{a as oe,c as se,d as ce,f as le,g as ue,h as de,i as fe,l as pe,n as me,o as he,p as Y,r as ge,t as _e,u as ve}from"./voice-config-api-DhJ3l8fk.js";import{t as ye}from"./voice-api-key-field-B_GApUQP.js";var be=E({"zh-CN":w().min(1).optional(),en:w().min(1).optional()}),xe=T([`transcription`,`transcription.stream`,`speech`,`speech.stream`,`conversation`]),Se=E({protocolVersion:S(1),serviceVersion:D().int().positive(),modes:C(xe),transport:S(`websocket-pcm`),inputFormat:E({encoding:S(`pcm_s16le`),sampleRate:S(16e3),channels:S(1)}),outputFormat:E({encoding:S(`pcm_s16le`),sampleRate:S(24e3),channels:S(1)}),turnDetection:C(S(`server_vad`)),bargeIn:x(),tools:x(),resumable:S(!1),voices:C(E({id:w().min(1),name:w(),displayNames:be.optional(),languages:C(w()),gender:T([`female`,`male`]).optional(),style:w().optional(),description:w().optional(),modes:C(xe).optional()})),defaultVoice:w().min(1).optional(),limits:E({maxFrameBytes:D().int().positive().max(65536),maxSessionSeconds:D().int().positive()})});function Ce(e,t){return e.modes===void 0||e.modes.includes(t)}var we=E({mode:xe,model:w().min(1).max(200),voice:w().min(1).max(200).optional()}),Te=E({revision:w().min(1),catalogVersion:w().nullable(),selections:C(we),models:C(E({id:w(),name:w(),displayNames:be.optional(),voice:Se}))}),X=n(),Z=e(t(),1),Q=r();function Ee({disabled:e=!1,modes:t,onPendingChange:n}){let r=c(e=>e.language),i=r===`zh`,[a,s]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>(n?.(a),()=>n?.(!1)),[a,n]);let[u,p]=(0,Z.useState)(``),{data:m,mutate:h,error:g}=k(o(`/api/voice/catalog`),async e=>{let t=await l(e);return Te.parse(t.payload)}),_=i?{transcription:`录音转文字`,"transcription.stream":`实时听写 / 语音助手输入`,speech:`消息朗读`,"speech.stream":`语音助手输出`,conversation:`自然语音对话`}:{transcription:`Recorded transcription`,"transcription.stream":`Live dictation / assistant input`,speech:`Message readout`,"speech.stream":`Assistant speech`,conversation:`Natural conversation`},v=async e=>{if(m){s(!0),p(``);try{let t=await l(o(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:m.revision,selection:e})}:{}});await h(Te.parse(t.payload),!1),await A()}catch(e){p(e instanceof Error?e.message:String(e)),await h()}finally{s(!1)}}};return(0,Q.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h3`,{className:`font-medium`,children:i?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,Q.jsx)(M,{variant:`secondary`,disabled:a||e||!m,onClick:()=>void v(),children:i?`刷新目录`:`Refresh catalog`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`修改在下次调用生效。各设备共用此 Gateway 的配置。`:`Changes apply to the next call and are shared across devices.`}),u||g?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:u||String(g)}):null,m?(0,Q.jsx)(Q.Fragment,{children:t.map(t=>{let n=m.selections.find(e=>e.mode===t),o=m.models.filter(e=>e.voice.modes.includes(t)).sort(W),s=o.find(e=>e.id===n?.model),c=s?.voice.voices.filter(e=>Ce(e,t))??[],l=n?.voice??c.find(e=>e.id===s?.voice.defaultVoice)?.id??c[0]?.id??``;return(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,Q.jsx)(`span`,{children:_[t]}),(0,Q.jsxs)(d,{className:`w-full`,value:n?.model??``,disabled:a||e||!o.length,onChange:e=>void v({mode:t,model:e.target.value}),children:[(0,Q.jsx)(f,{value:``,disabled:!0,children:i?`选择模型`:`Choose model`}),n&&!s?(0,Q.jsxs)(f,{value:n.model,disabled:!0,children:[n.model,` · `,i?`不可用`:`Unavailable`]}):null,o.map(e=>(0,Q.jsx)(f,{value:e.id,children:G(e,r)},e.id))]}),o.length?null:(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i?`暂无可用模型`:`No available model`})]}),s&&c.length>0?(0,Q.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,Q.jsx)(`span`,{children:i?`音色`:`Voice`}),(0,Q.jsxs)(d,{className:`w-full`,value:l,disabled:a||e,onChange:e=>void v({mode:t,model:s.id,voice:e.target.value}),children:[n?.voice&&!c.some(e=>e.id===n.voice)?(0,Q.jsxs)(f,{value:n.voice,disabled:!0,children:[n.voice,` · `,i?`当前场景不可用`:`Unavailable for this mode`]}):null,c.map(e=>(0,Q.jsxs)(f,{value:e.id,children:[G(e,r),e.gender?` · ${i?e.gender===`female`?`女声`:`男声`:e.gender}`:``,e.style?` · ${e.style}`:``]},e.id))]}),c.find(e=>e.id===l)?.description?(0,Q.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:c.find(e=>e.id===l)?.description}):null]}):null]},t)})}):(0,Q.jsx)(b,{className:`h-48 w-full`})]})}function De({v:e}){let t=I(e=>e.microphoneId),n=I(e=>e.setMicrophoneId),[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{l.current=!0;let e=()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{l.current&&i(e.filter(e=>e.kind===`audioinput`))}).catch(()=>{})};return e(),navigator.mediaDevices?.addEventListener(`devicechange`,e),()=>{l.current=!1,navigator.mediaDevices?.removeEventListener(`devicechange`,e)}},[]);let u=async()=>{c(!0),o(``);try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop());let e=await navigator.mediaDevices.enumerateDevices();l.current&&i(e.filter(e=>e.kind===`audioinput`))}catch(e){l.current&&o(e instanceof Error?e.message:String(e))}finally{l.current&&c(!1)}};return(0,Q.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,Q.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,Q.jsx)(`span`,{children:e.experience.microphone}),(0,Q.jsxs)(d,{value:t,onChange:e=>n(e.target.value),children:[(0,Q.jsx)(f,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,Q.jsx)(f,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,Q.jsx)(f,{value:t.deviceId,children:t.label||`${e.experience.microphone} ${n+1}`},t.deviceId))]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.experience.deviceHint}),(0,Q.jsx)(M,{variant:`secondary`,disabled:s,onClick:()=>void u(),children:e.experience.refreshDevices}),a?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}var Oe=(0,Z.createContext)(null);function ke(e){let t=(0,X.c)(18),n,r;t[0]===e?(n=t[1],r=t[2]):({to:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let[o]=i(),s=(0,Z.useContext)(Oe),c,l;t[3]===r?(c=t[4],l=t[5]):(c=new URLSearchParams(r.split(`?`)[1]??``),l=q(c.get(`configure`)),t[3]=r,t[4]=c,t[5]=l);let u=l,d;t[6]!==s||t[7]!==n||t[8]!==c||t[9]!==u?(d=e=>{n.onClick?.(e),!e.defaultPrevented&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&e.button===0&&s&&u&&c.get(`tab`)===`services`&&(e.preventDefault(),s(u))},t[6]=s,t[7]=n,t[8]=c,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==o||t[12]!==r?(f=re(r,o),t[11]=o,t[12]=r,t[13]=f):f=t[13];let p;return t[14]!==n||t[15]!==d||t[16]!==f?(p=(0,Q.jsx)(a,{...n,onClick:d,to:f}),t[14]=n,t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function Ae(e){let t=(0,X.c)(19),{zh:n}=e,{data:r,error:i,mutate:a}=k(`voice-dictation-route`,je),o,s;t[0]===a?(o=t[1],s=t[2]):(o=()=>{let e=()=>{a()};return window.addEventListener(`voice-config-changed`,e),window.addEventListener(`config-reload`,e),()=>{window.removeEventListener(`voice-config-changed`,e),window.removeEventListener(`config-reload`,e)}},s=[a],t[0]=a,t[1]=o,t[2]=s),(0,Z.useEffect)(o,s);let c=n?`同时用于聊天听写`:`Also used for chat dictation`,l;t[3]===c?l=t[4]:(l=(0,Q.jsx)(`h2`,{className:`font-medium text-fg`,children:c}),t[3]=c,t[4]=l);let u=n?`默认与录音识别共用模型。已有的独立听写设置会保留。`:`Dictation shares this recognition model. Existing separate dictation settings are preserved.`,d;t[5]===u?d=t[6]:(d=(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:u}),t[5]=u,t[6]=d);let f;t[7]!==r||t[8]!==i||t[9]!==n?(f=!r&&!i?(0,Q.jsx)(b,{className:`h-5 w-64 max-w-full`}):(0,Q.jsx)(`p`,{role:i?`alert`:`status`,className:`text-fg-muted`,children:i?n?`暂时无法读取听写状态。`:`Dictation status could not be loaded.`:r?.mode===`recorded`?n?`当前使用 ${r.provider},点击完成后转为文字。`:`Using ${r.provider}. Choose Finish to transcribe.`:r?.mode===`streaming`?n?`当前使用流式识别${r.provider?` · ${r.provider}`:``}。`:`Using streaming recognition${r.provider?` · ${r.provider}`:``}.`:n?`听写未就绪,请检查识别模型或已有的流式配置。`:`Check the recognition model or existing streaming configuration.`}),t[7]=r,t[8]=i,t[9]=n,t[10]=f):f=t[10];let p;t[11]!==r?.mode||t[12]!==n?(p=r?.mode===`recorded`?null:(0,Q.jsx)(ke,{className:`inline-block text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=transcription`,children:n?`管理识别服务`:`Manage recognition services`}),t[11]=r?.mode,t[12]=n,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==d||t[16]!==f||t[17]!==p?(m=(0,Q.jsxs)(`section`,{className:`space-y-2 rounded-xl border border-edge p-4 text-sm`,children:[l,d,f,p]}),t[14]=l,t[15]=d,t[16]=f,t[17]=p,t[18]=m):m=t[18],m}function je(){return L(AbortSignal.timeout(15e3))}function Me({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Z.useContext)(H)?.active??!1,[s,c]=(0,Z.useState)(`idle`),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``),p=(0,Z.useRef)(`idle`),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!1),b=e=>{p.current=e,c(e)},x=()=>{v.current?.(),v.current=null};(0,Z.useEffect)(()=>()=>v.current?.(),[]);async function S(e){x(),i?.({input:!1,output:!1}),y.current=!1,u(``),f(``),b(e?`connecting`:`playing`);let t=new AbortController,r,o,s,c,l=()=>{o?.cancel(),r?.getTracks().forEach(e=>e.stop()),s?.stop(`surface_closed`)},d=window.setTimeout(()=>m(a.timeout),6e4);v.current=()=>{t.abort(),window.clearTimeout(d),l(),c?.close()};function m(e){t.signal.aborted||(b(`error`),f(e),x())}async function h(){b(`playing`),l();try{let e=await ce(t.signal);if(t.signal.aborted)return;c?.enqueue(e,()=>{t.signal.aborted||(window.clearTimeout(d),b(`confirm`))})}catch(e){m(e instanceof Error?e.message:a.testFailed)}}try{if(n&&(c=new V,await c.start(),t.signal.throwIfAborted()),!e){await h();return}let d=window.electronAPI?.system;if(d){let e=await d.requestMicrophone();if(t.signal.throwIfAborted(),e.status===`denied`)throw Error(a.microphoneDenied)}if(r=await navigator.mediaDevices.getUserMedia({audio:z()}),t.signal.aborted){l();return}if(s=await F.connect({purpose:`dictation`,signal:t.signal,onEvent:e=>{t.signal.aborted||(e.type===`session.error`&&m(a.testFailed),p.current===`listening`&&(e.type===`input.transcript.delta`&&u(e.payload.text),e.type===`input.transcript.final`&&e.payload.text.trim()&&(u(e.payload.text.trim()),y.current=!0,n?h():(b(`passed`),i?.({input:!0,output:!1}),x()))))},onClose:()=>{(p.current===`listening`||p.current===`connecting`)&&m(a.testFailed)}}),t.signal.aborted){l();return}let f;if(o=await P.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new R(o.sampleRate,s.session.inputFormat.sampleRate),b(`listening`)}catch(e){if(t.signal.aborted){l();return}m(e instanceof Error?e.message:a.testFailed)}}let C=s===`connecting`||s===`listening`||s===`playing`;return(0,Q.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(M,{type:`button`,variant:`primary`,disabled:o||r||!t||C,onClick:()=>void S(!0),children:[C?(0,Q.jsx)(m,{className:`size-4 animate-spin`}):(0,Q.jsx)(h,{className:`size-4`}),n?a.test:a.testInput]}),(0,Q.jsxs)(M,{type:`button`,variant:`secondary`,disabled:o||r||!n||C,onClick:()=>void S(!1),children:[(0,Q.jsx)(g,{className:`size-4`}),e.tts.test.play]}),C?(0,Q.jsxs)(M,{type:`button`,variant:`ghost`,onClick:()=>{x(),b(`idle`)},children:[(0,Q.jsx)(_,{className:`size-4`}),e.tts.test.stop]}):null]}),(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`space-y-2 text-xs text-fg-muted`,children:[s===`idle`?(0,Q.jsx)(`p`,{children:o?e.experience.endCallBeforeTest:r?a.saveBeforeTest:a.microphoneHint}):null,s===`connecting`?(0,Q.jsx)(`p`,{children:a.connecting}):null,s===`listening`?(0,Q.jsx)(`p`,{children:a.speakNow}):null,l?(0,Q.jsx)(`p`,{className:`rounded-lg bg-surface-base p-3 text-sm text-fg`,children:l}):null,s===`playing`?(0,Q.jsx)(`p`,{children:a.playing}):null,s===`confirm`?(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{children:a.heardQuestion}),(0,Q.jsx)(M,{type:`button`,variant:`secondary`,onClick:()=>{x(),i?.({input:y.current,output:!0}),b(`passed`)},children:a.heard}),(0,Q.jsx)(M,{type:`button`,variant:`ghost`,onClick:()=>{x(),b(`error`),f(a.notHeard)},children:a.notHeardButton})]}):null,s===`passed`?(0,Q.jsx)(`p`,{children:y.current?n?a.passed:a.inputPassed:a.outputPassed}):null,s===`error`?(0,Q.jsx)(`p`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:d}):null]})]})}function Ne(e){let t=(0,X.c)(78),{section:n,v:r,form:i,pending:a,onChange:s}=e,l=c(Re),u=r.setup,p;t[0]===i?p=t[1]:(p=JSON.stringify(i),t[0]=i,t[1]=p);let m=p,h;t[2]===m?h=t[3]:(h={signature:m,input:!1,output:!1},t[2]=m,t[3]=h);let[g,_]=(0,Z.useState)(h);g.signature!==m&&_({signature:m,input:!1,output:!1});let v;t[4]!==a||t[5]!==m?(v=a?null:[`voice-realtime-status`,m],t[4]=a,t[5]=m,t[6]=v):v=t[6];let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y={revalidateOnFocus:!0},t[7]=y):y=t[7];let{data:x,error:S,isLoading:C}=k(v,ge,y),w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=o(`/api/voice/catalog`),t[8]=w):w=t[8];let{data:T}=k(w,Le),E=i.voice.realtime,D=E.tts,O=D?.provider??x?.tts?.provider,A=x?.tts?.model,j;t[9]!==A||t[10]!==O?(j=O&&A?[`realtime-voices`,O,A]:null,t[9]=A,t[10]=O,t[11]=j):j=t[11];let M;t[12]!==A||t[13]!==O?(M=()=>fe(O,A,`realtime`),t[12]=A,t[13]=O,t[14]=M):M=t[14];let N;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(N={revalidateOnFocus:!1},t[15]=N):N=t[15];let{data:P}=k(j,M,N),F;t[16]===P?F=t[17]:(F=P===void 0?[]:P,t[16]=P,t[17]=F);let I=F,L=I,R;t[18]===I?R=t[19]:(R=I.filter(Ie),t[18]=I,t[19]=R);let z=R,B=E.defaultEngine===`omni`,V=B?E.omni?.voice??``:D?.voice??``,H;t[20]!==T?.models||t[21]!==B||t[22]!==z||t[23]!==E.omni||t[24]!==L?(H=B&&E.omni?.provider===`qwen-token-plan-cn`?[{id:E.omni.voice,name:E.omni.voice}]:B?E.omni?.provider===`xopc-cloud`?T?.models.find(e=>e.id===E.omni?.model)?.voice.voices.filter(Fe)??[]:z.length?z:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(Pe):L,t[20]=T?.models,t[21]=B,t[22]=z,t[23]=E.omni,t[24]=L,t[25]=H):H=t[25];let U=H,te=!!(x?.enabled&&x.stt),ne=!!(x?.enabled&&x.tts),W;t[26]!==i||t[27]!==s||t[28]!==E?(W=e=>s({...i,voice:{...i.voice,realtime:{...E,...e}}}),t[26]=i,t[27]=s,t[28]=E,t[29]=W):W=t[29];let K=W,re;t[30]!==a||t[31]!==E.enabled||t[32]!==u.disabled||t[33]!==u.needsSetup||t[34]!==u.pending||t[35]!==u.unverified||t[36]!==u.verified||t[37]!==m||t[38]!==g.signature?(re=(e,t)=>E.enabled?a?u.pending:e?t&&g.signature===m?u.verified:u.unverified:u.needsSetup:u.disabled,t[30]=a,t[31]=E.enabled,t[32]=u.disabled,t[33]=u.needsSetup,t[34]=u.pending,t[35]=u.unverified,t[36]=u.verified,t[37]=m,t[38]=g.signature,t[39]=re):re=t[39];let q=re,J;t[40]!==V||t[41]!==l||t[42]!==B||t[43]!==O||t[44]!==E.bargeIn||t[45]!==E.defaultEngine||t[46]!==E.enabled||t[47]!==E.omni||t[48]!==E.tts||t[49]!==u.bargeIn||t[50]!==u.defaultVoice||t[51]!==u.enable||t[52]!==u.voice||t[53]!==n||t[54]!==D||t[55]!==x?.tts||t[56]!==K||t[57]!==r.experience||t[58]!==r.realtime||t[59]!==U?(J=n===`listening`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`span`,{children:u.enable}),(0,Q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":E.enabled,className:`ui-checkbox`,checked:E.enabled,onChange:e=>K({enabled:e.target.checked})})]}),(0,Q.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,Q.jsx)(`span`,{children:r.experience.defaultMode}),(0,Q.jsxs)(d,{value:E.defaultEngine,className:ee,onChange:e=>K({defaultEngine:e.target.value}),children:[(0,Q.jsx)(f,{value:`auto`,children:l===`zh`?`自动选择`:`Automatic`}),(0,Q.jsx)(f,{value:`agent`,children:r.experience.assistant}),(0,Q.jsx)(f,{value:`omni`,children:r.experience.natural})]})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[E.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsx)(`label`,{htmlFor:`realtime-voice`,className:`text-sm font-medium text-fg`,children:u.voice}),(0,Q.jsxs)(d,{id:`realtime-voice`,className:`${ee} w-full sm:w-56`,value:V,disabled:B?!E.omni:!D&&!x?.tts,onChange:e=>{if(B&&E.omni){K({omni:{...E.omni,voice:e.target.value}});return}if(O===`alibaba`||O===`xopc-cloud`){let t={...E.tts,provider:O};e.target.value?t.voice=e.target.value:delete t.voice,K({tts:t})}},children:[B?null:(0,Q.jsx)(f,{value:``,children:u.defaultVoice}),V&&!U.some(e=>e.id===V)?(0,Q.jsx)(f,{value:V,children:V}):null,U.map(e=>(0,Q.jsxs)(f,{value:e.id,children:[G(e,l),`gender`in e&&e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,`style`in e&&e.style?` · ${e.style}`:``]},e.id))]}),(()=>{let e=U.find(e=>e.id===V);return e&&`description`in e&&typeof e.description==`string`?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.description}):null})()]}),(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,Q.jsxs)(`span`,{children:[u.bargeIn,(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:r.realtime.bargeInDescription})]}),(0,Q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":E.bargeIn,checked:E.bargeIn,className:`size-4 accent-accent`,onChange:e=>K({bargeIn:e.target.checked})})]})]}):null,t[40]=V,t[41]=l,t[42]=B,t[43]=O,t[44]=E.bargeIn,t[45]=E.defaultEngine,t[46]=E.enabled,t[47]=E.omni,t[48]=E.tts,t[49]=u.bargeIn,t[50]=u.defaultVoice,t[51]=u.enable,t[52]=u.voice,t[53]=n,t[54]=D,t[55]=x?.tts,t[56]=K,t[57]=r.experience,t[58]=r.realtime,t[59]=U,t[60]=J):J=t[60];let ie;t[61]!==te||t[62]!==ne||t[63]!==S||t[64]!==C||t[65]!==a||t[66]!==n||t[67]!==m||t[68]!==x||t[69]!==q||t[70]!==r||t[71]!==g.input||t[72]!==g.output?(ie=n===`diagnostics`?(0,Q.jsxs)(Q.Fragment,{children:[C?(0,Q.jsx)(b,{className:`h-16 w-full`}):(0,Q.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,Q.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,q(te,g.input)]}),(0,Q.jsxs)(`p`,{children:[r.experience.agentReady,` · `,q(te&&ne,g.input&&g.output)]}),(0,Q.jsxs)(`p`,{children:[r.experience.omniReady,` · `,q(!!(x?.enabled&&x.omni),!1)]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,Q.jsx)(Me,{v:r,canListen:te,canSpeak:ne,disabled:a||C||!!S,onVerified:e=>_({signature:m,...e})},`${m}:${JSON.stringify(x)}`)]}):null,t[61]=te,t[62]=ne,t[63]=S,t[64]=C,t[65]=a,t[66]=n,t[67]=m,t[68]=x,t[69]=q,t[70]=r,t[71]=g.input,t[72]=g.output,t[73]=ie):ie=t[73];let ae;return t[74]!==u.service||t[75]!==J||t[76]!==ie?(ae=(0,Q.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":u.service,children:[J,ie]}),t[74]=u.service,t[75]=J,t[76]=ie,t[77]=ae):ae=t[77],ae}function Pe(e){return{id:e,name:e}}function Fe(e){return Ce(e,`conversation`)}function Ie(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function Le(e){return Te.parse((await l(e)).payload)}function Re(e){return e.language}function ze(e){let t=(0,X.c)(19),{value:n,onChange:r}=e,i=c(Be)===`zh`,a=i?`通话指令`:`Conversation instructions`,o;t[0]===a?o=t[1]:(o=(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:a}),t[0]=a,t[1]=o);let s=i?`通话会接续当前会话。可在这里调整语气与回答方式。`:`Calls continue the current conversation. Adjust tone and response style here.`,l;t[2]===s?l=t[3]:(l=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s}),t[2]=s,t[3]=l);let u=i?`通话指令`:`Conversation instructions`,d;t[4]===u?d=t[5]:(d=(0,Q.jsx)(`span`,{children:u}),t[4]=u,t[5]=d);let f;t[6]!==r||t[7]!==n?(f=e=>r({...n,instructions:e.target.value}),t[6]=r,t[7]=n,t[8]=f):f=t[8];let p;t[9]!==f||t[10]!==n.instructions?(p=(0,Q.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,rows:3,maxLength:8e3,value:n.instructions,onChange:f}),t[9]=f,t[10]=n.instructions,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==p?(m=(0,Q.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==o||t[16]!==l||t[17]!==m?(h=(0,Q.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[o,l,m]}),t[15]=o,t[16]=l,t[17]=m,t[18]=h):h=t[18],h}function Be(e){return e.language}function Ve({disabled:e=!1}){let t=c(e=>e.language),n=t===`zh`,{data:r,error:i,mutate:s}=k(o(_e),me),[l,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(0),_=(0,Z.useId)();(0,Z.useLayoutEffect)(()=>{g(e=>e+1)},[]);let[v,y]=(0,Z.useState)(),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(!1),D=B({disabled:e||x,chat:u(t).chat,onTranscript:()=>{},onTestAudioPlayed:()=>E(!0)}),j=D.phase!==`idle`&&D.phase!==`error`,P=v??r?.voice??`default`,F=r?.credentialSource===`global`;async function I(){try{return await Y()}catch(e){throw e instanceof Error&&`status`in e&&e.status===404?Error(n?`当前 Gateway 版本不支持查看密钥。请更新并重启 Gateway。`:`Update and restart the Gateway to view or copy the saved key.`):e}}async function L(e){if(!(x||j)){S(!0),w(``);try{await s(await de(e),{revalidate:!1}),`apiKey`in e&&(m(``),g(e=>e+1),E(!1),D.cancelVoiceInput()),await A()}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}}}return(0,Q.jsxs)(`section`,{className:`@container space-y-3 rounded-xl border border-edge bg-surface-panel p-4`,"aria-label":`Boson AI`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Boson AI · Higgs Realtime`}),!r&&!i?(0,Q.jsx)(b,{className:`h-24 w-full`}):null,i?(0,Q.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[n?`无法读取 Boson 设置。`:`Could not load Boson settings.`,(0,Q.jsx)(M,{variant:`ghost`,onClick:()=>void s(),children:n?`重试`:`Retry`})]}):null,r&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`fieldset`,{disabled:e||x||j,className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`label`,{htmlFor:_,className:`text-sm font-medium text-fg`,children:`Boson API Key`}),(0,Q.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:r.credentialSource===`env`?n?`已从环境读取 BOSON_API_KEY`:`Using BOSON_API_KEY from the environment`:r.credentialSource?n?`已保存 API Key`:`API key saved`:n?`尚未连接`:`Connection needed`})]}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-2 @min-[32rem]:grid-cols-[minmax(0,1fr)_auto]`,children:[(0,Q.jsx)(p,{id:_,value:l||(F?`••••••••••••`:``),onChange:e=>m(e.replace(/^•+/u,``)),autoComplete:`new-password`,inputClassName:`min-h-11`,labels:{show:n?`显示密钥`:`Show key`,hide:n?`隐藏密钥`:`Hide key`,copy:n?`复制密钥`:`Copy key`,copied:n?`已复制`:`Copied`},reveal:F?I:void 0,allowUnrevealedCopy:!0,loadFailedLabel:n?`无法查看已保存的密钥。`:`Could not load the saved key.`,notInConfigFile:n?`当前没有已保存的密钥。`:`There is no saved key.`},`${F}:${h}`),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(M,{className:`min-h-11`,variant:`secondary`,type:`button`,disabled:!l.trim(),onClick:()=>void L({apiKey:l}),children:x?n?`正在保存…`:`Saving…`:n?`保存密钥`:`Save key`}),F&&(0,Q.jsx)(M,{className:`min-h-11`,type:`button`,variant:`ghost`,onClick:()=>void L({apiKey:null}),children:n?`移除已保存密钥`:`Remove saved key`})]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,Q.jsx)(`span`,{children:n?`Higgs 默认音色`:`Default Higgs voice`}),(0,Q.jsx)(d,{"aria-label":n?`Higgs 默认音色`:`Default Higgs voice`,value:P,onChange:e=>{y(e.target.value),E(!1),D.cancelVoiceInput()},children:O.map(e=>(0,Q.jsx)(f,{value:e,children:e==="default"?n?`模型默认`:`Model default`:e},e))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(M,{type:`button`,variant:`secondary`,disabled:P===r.voice||!r.credentialSource,onClick:()=>void L({voice:P}),children:n?`保存音色`:`Save voice`}),(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:r.defaultForNatural?n?`当前全局自然语音模型`:`Current global natural voice model`:n?`在上方选择全局自然语音模型`:`Choose the global natural voice model above`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`测试时请说一句中文,听到回复后可以插话。音频由 Boson 处理,测试内容仅在当前面板显示,可能产生用量。`:`Say a sentence and try interrupting the reply. Boson processes the audio. Test content stays in this panel and may incur usage.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[j?(0,Q.jsx)(M,{type:`button`,variant:`secondary`,onClick:D.cancelVoiceInput,children:n?`结束测试`:`End test`}):(0,Q.jsx)(M,{type:`button`,variant:`secondary`,disabled:e||x||!r.credentialSource,onClick:()=>{D.cancelVoiceInput(),E(!1),w(``),D.startHiggsTest(P)},children:n?`测试通话`:`Test call`}),r.credentialSource&&!e&&!x&&!j&&(0,Q.jsx)(a,{className:`px-2 text-sm text-accent-fg hover:underline`,to:`/personal`,onClick:N,children:n?`打开 Ada`:`Open Ada`})]}),j&&(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:D.phase===`recording`?D.responsePhase===`speaking`?n?`正在播放,可以插话`:`Playing reply. You can interrupt.`:n?`麦克风已开启,请说话`:`Microphone on. Say something.`:n?`正在连接测试通话…`:`Connecting test call…`}),T&&(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-success`,children:n?`测试通过,已播放回复`:`Test passed. Reply played.`}),D.finalTranscript&&(0,Q.jsxs)(`p`,{className:`text-sm text-fg`,children:[n?`转写 · `:`Transcript · `,D.finalTranscript]}),D.responseText&&(0,Q.jsxs)(`p`,{className:`text-sm text-fg`,children:[n?`回复 · `:`Reply · `,D.responseText]})]})]}),(C||D.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:C||D.error})]})}var He=U;function Ue(){return y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,te,`dark:border-edge`)}function $(){return y(ee,U)}function We(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ge(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}function Ke(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function qe(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`minimax`:return`MiniMax`;default:return e}}function Je(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;default:return t.tts.providerHints.generic}}function Ye(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Xe(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type!==`boolean`&&``:t.defaultValue}function Ze(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Qe(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`saved`:{let n=structuredClone(t.value);return{form:e.form!==null&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function $e(e){let t=(0,X.c)(10),[n,r]=(0,Z.useState)(0),i;t[0]!==e.capability||t[1]!==e.disabled?(i=e.capability===`conversation`&&(0,Q.jsx)(Ve,{disabled:e.disabled}),t[0]=e.capability,t[1]=e.disabled,t[2]=i):i=t[2];let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>r(et),t[3]=a):a=t[3];let o;t[4]!==n||t[5]!==e?(o=(0,Q.jsx)(tt,{...e,onReload:a},n),t[4]=n,t[5]=e,t[6]=o):o=t[6];let s;return t[7]!==i||t[8]!==o?(s=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[i,o]}),t[7]=i,t[8]=o,t[9]=s):s=t[9],s}function et(e){return e+1}function tt({capability:e,onPendingChange:t,disabled:n=!1,onReload:r}){let i=c(e=>e.language),a=u(i).voiceSettings,l=I(e=>e.captions),p=I(e=>e.setCaptions),m=!!s(e=>e.conversationId),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useReducer)(Qe,{form:null,baseline:null}),y=_.form,b=_.baseline,[x,S]=(0,Z.useState)(null),C=(0,Z.useRef)(!1),w=(0,Z.useRef)({}),T=(0,Z.useRef)(y);T.current=y;let E=(0,Z.useRef)({parsed:null,models:void 0}),{data:D,error:O,isLoading:A,mutate:N}=j(m),{data:P,error:F,isLoading:L,mutate:R}=k(m?o(`/api/voice/models`):null,oe,{revalidateOnFocus:!1}),{data:z,error:B,isLoading:V}=k(m?o(`/api/voice/providers`):null,he,{revalidateOnFocus:!1}),{data:H,error:U,isLoading:ee}=k(m?o(`/api/voice/stt-providers`):null,se,{revalidateOnFocus:!1}),te=(0,Z.useMemo)(()=>z?.providers??[],[z]),ne=(0,Z.useMemo)(()=>H?.providers??[],[H]),W=(0,Z.useMemo)(()=>D?.payload?.config===void 0?null:pe(D.payload.config),[D]),G=(0,Z.useMemo)(()=>!y||!b?!1:JSON.stringify(y)!==JSON.stringify(b),[y,b]);m?W!==null&&P!==void 0&&!C.current&&(E.current.parsed!==W||E.current.models!==P)&&(E.current={parsed:W,models:P},w.current=le(D?.payload?.config),v({type:`sync`,value:W}),S(P)):(E.current.parsed!==null||E.current.models!==void 0)&&(E.current={parsed:null,models:void 0},v({type:`reset`}),S(null),C.current=!1);let re=!!(m&&(W===null||P===void 0||z===void 0||H===void 0)&&(A||L||V||ee)),q=O instanceof Error?O.message:O?String(O):F instanceof Error?F.message:F?String(F):B instanceof Error?B.message:B?String(B):U instanceof Error?U.message:U?String(U):null,J=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e},...e.provider&&e.provider!==`xopc-cloud`?{voice:{...t.voice,realtime:{...t.voice.realtime,stt:void 0}}}:{}}:null})},[]),ce=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ue=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),de=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>t?{...t,voice:{...t.voice,languageMode:e,...e===`auto`?{language:i}:{}}}:null})},[i]),fe=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),me=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),Y=ae({value:y,dirty:G,onSave:(0,Z.useCallback)(async t=>{try{let n=await ve(t,e,w.current[e]);w.current={...w.current,...n},v({type:`saved`,value:t}),C.current=!!(T.current&&JSON.stringify(T.current)!==JSON.stringify(t))}catch(e){throw Error(e instanceof Error?e.message:a.saveError)}},[a.saveError,e])});(0,Z.useEffect)(()=>{t?.(G||Y.status===`saving`||h)},[G,Y.status,h,t]),(0,Z.useEffect)(()=>()=>t?.(!1),[t]);let ge=(0,Z.useCallback)(e=>{C.current=!0,v({type:`update`,updater:()=>e})},[]);if(!m)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.needToken})});if(re)return(0,Q.jsx)(K,{rows:4});if(!y||x===null)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:q??a.loadError}),(0,Q.jsx)(M,{type:`button`,variant:`secondary`,onClick:()=>{N(),R()},children:a.retry})]});let _e=y.stt,ye=y.tts,be=y.voice.input.refinement,xe=Ye(a);return(0,Q.jsxs)(`fieldset`,{disabled:n||h,className:`flex min-w-0 flex-col gap-4`,onBlurCapture:Y.error?void 0:Y.onBlurCapture,children:[(0,Q.jsx)(ie,{status:Y.status,error:Y.error}),Y.error?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(M,{variant:`secondary`,onClick:Y.retry,children:i===`zh`?`重试保存`:`Retry saving`}),(0,Q.jsx)(M,{variant:`ghost`,onClick:()=>{N().then(()=>r()).catch(()=>{})},children:i===`zh`?`重新加载(放弃未保存更改)`:`Reload and discard unsaved changes`})]}):null,e===`transcription`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ae,{zh:i===`zh`}),(0,Q.jsx)(it,{managedModel:!0,v:a,apiKeyLabels:xe,stt:_e,models:x,sttProviders:ne,updateStt:J,updateSttFallback:ce}),(0,Q.jsx)(rt,{v:a,voice:y.voice,updateLanguageMode:de}),(0,Q.jsxs)(`details`,{"data-voice-section":`input-processing`,className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[a.experience.inputProcessing,` · `,be.mode===`off`?a.stt.refinementOff:be.mode===`punctuation`?a.stt.refinementPunctuation:be.mode===`light`?a.stt.refinementLight:a.setup.advanced]}),(0,Q.jsxs)(`label`,{className:`mt-4 block space-y-2 text-sm`,children:[(0,Q.jsx)(`span`,{children:a.stt.refinement}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.stt.refinementDesc}),(0,Q.jsxs)(d,{className:$(),value:be.mode,onChange:e=>ue({mode:e.target.value}),children:[(0,Q.jsx)(f,{value:`off`,children:a.stt.refinementOff}),(0,Q.jsx)(f,{value:`punctuation`,children:a.stt.refinementPunctuation}),(0,Q.jsx)(f,{value:`light`,children:a.stt.refinementLight}),be.mode===`custom`?(0,Q.jsx)(f,{value:`custom`,children:a.setup.advanced}):null]})]})]}),_e.provider===`xopc-cloud`?(0,Q.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`实时听写`:`Live dictation`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(Ee,{modes:[`transcription.stream`],disabled:G||Y.status===`saving`,onPendingChange:g})})]}):null]}):e===`speech`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ot,{managedModel:!0,v:a,apiKeyLabels:xe,tts:ye,models:x,ttsProviders:te,updateTts:me}),(0,Q.jsx)(nt,{v:a,tts:ye,updateTts:me})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ne,{section:`listening`,v:a,form:y,pending:G||Y.status===`saving`||!!Y.error,onChange:ge}),y.voice.realtime.defaultEngine===`omni`&&y.voice.realtime.omni?(0,Q.jsx)(ze,{value:y.voice.realtime.omni,onChange:e=>fe({omni:e})}):null,(0,Q.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:a.experience.pace}),(0,Q.jsxs)(d,{className:$(),value:String(y.voice.realtime.silenceDurationMs),onChange:e=>fe({silenceDurationMs:Number(e.target.value)}),children:[(0,Q.jsx)(f,{value:`800`,children:a.experience.fast}),(0,Q.jsx)(f,{value:`1200`,children:a.experience.standard}),(0,Q.jsx)(f,{value:`2000`,children:a.experience.relaxed}),[800,1200,2e3].includes(y.voice.realtime.silenceDurationMs)?null:(0,Q.jsxs)(f,{value:String(y.voice.realtime.silenceDurationMs),children:[y.voice.realtime.silenceDurationMs,` ms`]})]})]})}),(0,Q.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[a.experience.captions,(0,Q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":l,className:`ui-checkbox`,checked:l,onChange:e=>p(e.target.checked)})]}),y.voice.realtime.defaultEngine===`agent`&&_e.provider===`xopc-cloud`?(0,Q.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`语音助手输出`:`Assistant speech output`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(Ee,{modes:[`speech.stream`],disabled:G||Y.status===`saving`,onPendingChange:g})})]}):null,(0,Q.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`麦克风、扬声器与诊断`:`Microphone, speakers and diagnostics`}),(0,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,Q.jsx)(De,{v:a}),(0,Q.jsx)(Ne,{section:`diagnostics`,v:a,form:y,pending:G||Y.status===`saving`||!!Y.error,onChange:ge})]})]})]})]})}function nt(e){let t=(0,X.c)(29),{v:n,tts:r,updateTts:i}=e,a;t[0]===n.setup.readout?a=t[1]:(a=(0,Q.jsx)(`span`,{className:`font-medium`,children:n.setup.readout}),t[0]=n.setup.readout,t[1]=a);let o=n.setup.readout,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=$(),t[2]=s):s=t[2];let c=r.enabled?r.trigger:`off`,l;t[3]===i?l=t[4]:(l=e=>i({enabled:e.target.value!==`off`,trigger:e.target.value}),t[3]=i,t[4]=l);let u;t[5]===n.tts.triggerOff?u=t[6]:(u=(0,Q.jsx)(f,{value:`off`,children:n.tts.triggerOff}),t[5]=n.tts.triggerOff,t[6]=u);let p;t[7]===n.tts.triggerInbound?p=t[8]:(p=(0,Q.jsx)(f,{value:`inbound`,children:n.tts.triggerInbound}),t[7]=n.tts.triggerInbound,t[8]=p);let m;t[9]===n.tts.triggerAlways?m=t[10]:(m=(0,Q.jsx)(f,{value:`always`,children:n.tts.triggerAlways}),t[9]=n.tts.triggerAlways,t[10]=m);let h;t[11]===n.tts.triggerTagged?h=t[12]:(h=(0,Q.jsx)(f,{value:`tagged`,children:n.tts.triggerTagged}),t[11]=n.tts.triggerTagged,t[12]=h);let g;t[13]!==c||t[14]!==l||t[15]!==u||t[16]!==p||t[17]!==m||t[18]!==h||t[19]!==n.setup.readout?(g=(0,Q.jsxs)(d,{"aria-label":o,className:s,value:c,onChange:l,children:[u,p,m,h]}),t[13]=c,t[14]=l,t[15]=u,t[16]=p,t[17]=m,t[18]=h,t[19]=n.setup.readout,t[20]=g):g=t[20];let _;t[21]!==a||t[22]!==g?(_=(0,Q.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[a,g]}),t[21]=a,t[22]=g,t[23]=_):_=t[23];let v;t[24]===n.setup.readoutHint?v=t[25]:(v=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.readoutHint}),t[24]=n.setup.readoutHint,t[25]=v);let y;return t[26]!==_||t[27]!==v?(y=(0,Q.jsxs)(`section`,{className:`space-y-2 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,children:[_,v]}),t[26]=_,t[27]=v,t[28]=y):y=t[28],y}function rt(e){let t=(0,X.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,Q.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=$(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let p;t[10]===n.language.auto?p=t[11]:(p=(0,Q.jsx)(f,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=p);let m;t[12]===n.language.manual?m=t[13]:(m=(0,Q.jsx)(f,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=m);let h;t[14]!==u||t[15]!==p||t[16]!==m||t[17]!==r.languageMode?(h=(0,Q.jsxs)(d,{className:l,value:r.languageMode,onChange:u,children:[p,m]}),t[14]=u,t[15]=p,t[16]=m,t[17]=r.languageMode,t[18]=h):h=t[18];let g;return t[19]!==c||t[20]!==h?(g=(0,Q.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,h]})}),t[19]=c,t[20]=h,t[21]=g):g=t[21],g}function it(e){let t=(0,X.c)(65),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c,managedModel:l}=e,u=l!==void 0&&l,p;if(t[0]!==o){let e=new Set;p=[];for(let t of o)e.has(t.id)||(e.add(t.id),p.push(t));t[0]=o,t[1]=p}else p=t[1];let m=p,g,_,v,b;if(t[2]!==a||t[3]!==m||t[4]!==i.provider||t[5]!==i.providers){g=m.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],v=e,_=a?.stt?.[i.provider]?.length?a.stt[i.provider]:g?.models??[],b=g?.fields.find(at),t[2]=a,t[3]=m,t[4]=i.provider,t[5]=i.providers,t[6]=g,t[7]=_,t[8]=v,t[9]=b}else g=t[6],_=t[7],v=t[8],b=t[9];let x=b,S=typeof v.model==`string`?v.model:void 0,C=S??(typeof x?.defaultValue==`string`?x.defaultValue:_[0]?.id),w;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(w=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=s,t[16]=w):w=t[16];let T=w,E,D;t[17]!==S||t[18]!==C||t[19]!==u||t[20]!==x||t[21]!==T?(E=()=>{!u&&x&&C&&S!==C&&T({model:C})},D=[u,S,C,x,T],t[17]=S,t[18]=C,t[19]=u,t[20]=x,t[21]=T,t[22]=E,t[23]=D):(E=t[22],D=t[23]),(0,Z.useEffect)(E,D);let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Q.jsx)(h,{"aria-hidden":`true`,className:`size-4 text-accent`,strokeWidth:1.75}),t[24]=O):O=t[24];let k;t[25]===n.stt.title?k=t[26]:(k=(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[O,n.stt.title]}),t[25]=n.stt.title,t[26]=k);let A;t[27]===n.stt.enable?A=t[28]:(A=(0,Q.jsx)(`span`,{children:n.stt.enable}),t[27]=n.stt.enable,t[28]=A);let j;t[29]===s?j=t[30]:(j=e=>s({enabled:e.target.checked}),t[29]=s,t[30]=j);let M;t[31]!==i.enabled||t[32]!==j?(M=(0,Q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i.enabled,className:`ui-checkbox`,checked:i.enabled,onChange:j}),t[31]=i.enabled,t[32]=j,t[33]=M):M=t[33];let N;t[34]!==M||t[35]!==A?(N=(0,Q.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-xs text-fg-muted`,children:[A,M]}),t[34]=M,t[35]=A,t[36]=N):N=t[36];let P;t[37]!==N||t[38]!==k?(P=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[k,N]}),t[37]=N,t[38]=k,t[39]=P):P=t[39];let F;t[40]===n.stt.description?F=t[41]:(F=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[40]=n.stt.description,t[41]=F);let I;t[42]!==P||t[43]!==F?(I=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[P,F]}),t[42]=P,t[43]=F,t[44]=I):I=t[44];let L;t[45]!==g?.fields||t[46]!==r||t[47]!==C||t[48]!==u||t[49]!==_||t[50]!==m||t[51]!==v||t[52]!==i.enabled||t[53]!==i.fallback?.enabled||t[54]!==i.provider||t[55]!==T||t[56]!==s||t[57]!==c||t[58]!==n?(L=i.enabled?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[u?null:(0,Q.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,He),children:[(0,Q.jsx)(mt,{children:n.stt.provider}),(0,Q.jsx)(d,{"aria-label":n.stt.provider,className:$(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:m.map(e=>(0,Q.jsxs)(f,{value:e.id,children:[Ke(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Q.jsx)(st,{managedModel:u,kind:`stt`,providerId:i.provider,fields:g?.fields??[],providerSlice:v,models:_,currentModel:C,apiKeyLabels:r,onPatch:T})]}),i.provider===`alibaba`?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.keyHint}):null,(0,Q.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>c({enabled:e.target.checked})})]})]})]}):null,t[45]=g?.fields,t[46]=r,t[47]=C,t[48]=u,t[49]=_,t[50]=m,t[51]=v,t[52]=i.enabled,t[53]=i.fallback?.enabled,t[54]=i.provider,t[55]=T,t[56]=s,t[57]=c,t[58]=n,t[59]=L):L=t[59];let R;t[60]===L?R=t[61]:(R=(0,Q.jsx)(`div`,{className:`space-y-4`,children:L}),t[60]=L,t[61]=R);let z;return t[62]!==I||t[63]!==R?(z=(0,Q.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[I,R]}),t[62]=I,t[63]=R,t[64]=z):z=t[64],z}function at(e){return e.key===`model`}function ot({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,managedModel:o=!1}){let[s,c]=(0,Z.useState)(e.tts.test.sampleText),[l,u]=(0,Z.useState)({status:`idle`}),p=(0,Z.useRef)(null),h=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x=(0,Z.useCallback)(()=>{b.current?.abort(),b.current=null,p.current?.pause(),p.current=null,h.current&&=(URL.revokeObjectURL(h.current),null)},[]),S=(0,Z.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),C=S.find(e=>e.id===n.provider),w=n.providers?.[n.provider]??{},T=r?.tts?.[n.provider]?.length?r.tts[n.provider]:C?.models??[],E=C?.fields.find(e=>e.key===`model`),D=C?.fields.find(e=>e.key===`voice`),O=typeof w.model==`string`?w.model:void 0,A=O??(typeof E?.defaultValue==`string`?E.defaultValue:T[0]?.id),j=T.find(e=>e.id===A),N=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:C?.voices??[],{data:P=[]}=k(A?`voice:tts:${n.provider}:${A}`:null,()=>fe(n.provider,A??``),{revalidateOnFocus:!1}),F=P.length>0?P:N,I=typeof w.voice==`string`?w.voice:void 0,L=I??F.find(e=>e.id===j?.tts?.defaultVoice)?.id??(typeof D?.defaultValue==`string`?D.defaultValue:F[0]?.id),R=(C?.fields??[]).filter(e=>(e.key!==`speed`||j?.tts?.speed!==!1)&&(e.key!==`instructions`||j?.tts?.instructions!==!1)),z=(0,Z.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Z.useEffect)(()=>{if(o)return;let e={};E&&A&&O!==A&&(e.model=A),D&&L&&I!==L&&(e.voice=L),Object.keys(e).length>0&&z(e)},[o,O,I,A,L,E,z,D]),(0,Z.useEffect)(()=>()=>x(),[x]);let B=(0,Z.useCallback)(e=>{a({provider:e}),u({status:`idle`})},[a]),V=(0,Z.useCallback)(async()=>{let t=s.trim();if(!t){u({status:`error`,message:e.tts.test.emptyText});return}x();let r=new AbortController;b.current=r,u({status:`loading`});try{let i=await ue({text:t,provider:n.provider,providerConfig:w,...A?{model:A}:{},...L?{voice:L}:{}},r.signal);if(r.signal.aborted)return;let a=Ge(i.audio,i.mimeType);h.current=a;let o=new Audio(a);p.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,We(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>u({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>u({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),u({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;x(),u({status:`error`,message:e instanceof Error?e.message:String(e)})}},[A,L,w,x,s,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,Q.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[(0,Q.jsxs)(`div`,{className:`mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(v,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:o?null:(0,Q.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,He),children:[(0,Q.jsx)(mt,{children:e.tts.provider}),(0,Q.jsx)(d,{"aria-label":e.tts.provider,className:$(),value:n.provider,onChange:e=>B(e.target.value),children:S.map(t=>(0,Q.jsx)(f,{value:t.id,children:qe(t.id,e)},t.id))}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[C?.configured?e.tts.configured:C?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${C.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,C?.description??Je(n.provider,e)]})]})}),(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,Q.jsx)(st,{managedModel:o,kind:`tts`,providerId:n.provider,fields:R,providerSlice:w,models:T,voices:F,currentModel:A,currentVoice:L,apiKeyLabels:t,onPatch:z,resetVoiceOnModelChange:!0})}),(0,Q.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e.tts.test.title}),(0,Q.jsxs)(`div`,{className:`mt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsxs)(M,{type:`button`,variant:`primary`,onClick:()=>void V(),disabled:l.status===`loading`,className:`h-9`,children:[l.status===`loading`?(0,Q.jsx)(m,{className:`size-4 animate-spin`}):(0,Q.jsx)(g,{className:`size-4`}),l.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Q.jsxs)(M,{type:`button`,variant:`secondary`,onClick:()=>{x(),u(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:l.status!==`playing`,className:`h-9`,children:[(0,Q.jsx)(_,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Q.jsxs)(`details`,{className:`mt-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:e.setup.sampleText}),(0,Q.jsx)(`textarea`,{className:y(Ue(),`mt-3 min-h-20 resize-y`),value:s,onChange:e=>c(e.target.value),maxLength:1e3})]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,Q.jsxs)(`span`,{className:`text-fg-subtle`,children:[s.length,`/1000`]}),l.status===`playing`||l.status===`done`?(0,Q.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[l.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,l.summary]}):null,l.status===`error`?(0,Q.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:l.message}):null]})]})]})]})})]})}function st(e){let t=(0,X.c)(48),{kind:n,providerId:r,fields:i,providerSlice:a,models:o,voices:s,currentModel:l,currentVoice:p,apiKeyLabels:m,onPatch:h,resetVoiceOnModelChange:g,managedModel:_}=e,v;t[0]===s?v=t[1]:(v=s===void 0?[]:s,t[0]=s,t[1]=v);let b=v,x=g!==void 0&&g,S=_!==void 0&&_,C=c(dt),w;t[2]===C?w=t[3]:(w=u(C),t[2]=C,t[3]=w);let T=w.voiceSettings,E=S,D=ut,O=lt,k,A,j;if(t[4]!==m||t[5]!==l||t[6]!==p||t[7]!==i||t[8]!==n||t[9]!==C||t[10]!==S||t[11]!==o||t[12]!==h||t[13]!==r||t[14]!==a||t[15]!==x||t[16]!==E||t[17]!==T||t[18]!==b){let e;t[22]===E?e=t[23]:(e=e=>!E||e.key!==`model`&&!O(e),t[22]=E,t[23]=e);let s=i.filter(e),c;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>!D(e),t[24]=c):c=t[24];let u=s.filter(c),g;t[25]!==m||t[26]!==l||t[27]!==p||t[28]!==n||t[29]!==C||t[30]!==S||t[31]!==o||t[32]!==h||t[33]!==r||t[34]!==a||t[35]!==x||t[36]!==T||t[37]!==b?(g=e=>e.map(e=>S&&e.key===`model`?null:e.key===`apiKey`?(0,Q.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,He),children:[(0,Q.jsx)(mt,{htmlFor:`voice-${n}-${r}-api-key`,children:T.stt.apiKey}),(0,Q.jsx)(ye,{kind:n,providerId:r,fieldId:`voice-${n}-${r}-api-key`,value:typeof a.apiKey==`string`?a.apiKey:``,onChange:e=>h({apiKey:e}),labels:m,placeholder:e.placeholder}),e.description?(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.description}):null]},e.key):e.key===`model`&&o.length>0?(0,Q.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,He),children:[(0,Q.jsx)(mt,{htmlFor:`voice-${n}-${r}-model`,children:T.stt.model}),(0,Q.jsx)(d,{id:`voice-${n}-${r}-model`,className:$(),value:l??``,onChange:e=>h({model:e.target.value,...x?{voice:void 0}:{}}),children:[...o].sort(W).map(ct)})]},e.key):e.key===`voice`&&b.length>0?(0,Q.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,He),children:[(0,Q.jsx)(mt,{htmlFor:`voice-${n}-${r}-voice`,children:T.tts.voice}),(0,Q.jsxs)(d,{id:`voice-${n}-${r}-voice`,className:$(),value:p??``,onChange:e=>h({voice:e.target.value}),children:[p&&!b.some(e=>e.id===p)?(0,Q.jsxs)(f,{value:p,children:[p,` · unavailable`]}):null,b.map(e=>(0,Q.jsxs)(f,{value:e.id,children:[G(e,C),e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,e.style?` · ${e.style}`:``]},e.id))]}),b.find(e=>e.id===p)?.description?(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:b.find(e=>e.id===p)?.description}):null]},e.key):(0,Q.jsx)(ft,{fieldId:`voice-${n}-${r}-${e.key}`,field:e,value:Xe(a,e),onChange:t=>h({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:He},e.key)),t[25]=m,t[26]=l,t[27]=p,t[28]=n,t[29]=C,t[30]=S,t[31]=o,t[32]=h,t[33]=r,t[34]=a,t[35]=x,t[36]=T,t[37]=b,t[38]=g):g=t[38];let _=g;t[39]!==i||t[40]!==n||t[41]!==C||t[42]!==E?(k=E&&i.some(O)?(0,Q.jsx)(ke,{className:`text-sm text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=${n===`stt`?`transcription`:`speech`}`,children:C===`zh`?`管理服务连接`:`Manage service connection`}):null,t[39]=i,t[40]=n,t[41]=C,t[42]=E,t[43]=k):k=t[43],A=_(s.filter(D)),j=u.length?(0,Q.jsxs)(`details`,{className:`rounded-lg border border-edge p-3 sm:col-span-2`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:T.experience.providerOptions}),(0,Q.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:_(u)})]}):null,t[4]=m,t[5]=l,t[6]=p,t[7]=i,t[8]=n,t[9]=C,t[10]=S,t[11]=o,t[12]=h,t[13]=r,t[14]=a,t[15]=x,t[16]=E,t[17]=T,t[18]=b,t[19]=k,t[20]=A,t[21]=j}else k=t[19],A=t[20],j=t[21];let M;return t[44]!==k||t[45]!==A||t[46]!==j?(M=(0,Q.jsxs)(Q.Fragment,{children:[k,A,j]}),t[44]=k,t[45]=A,t[46]=j,t[47]=M):M=t[47],M}function ct(e){return(0,Q.jsx)(f,{value:e.id,children:e.name},e.id)}function lt(e){return e.secret||e.type===`password`||[`apiKey`,`baseUrl`,`region`,`groupId`].includes(e.key)}function ut(e){return e.required||[`apiKey`,`model`,`voice`].includes(e.key)}function dt(e){return e.language}function ft(e){let t=(0,X.c)(37),{fieldId:n,field:r,value:i,onChange:a,className:o}=e,s=n??`voice-schema-field-${r.key}`,c=r.description;if(r.type===`boolean`){let e;t[0]===o?e=t[1]:(e=y(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let n;t[2]===r.label?n=t[3]:(n=(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r.label}),t[2]=r.label,t[3]=n);let s;t[4]===c?s=t[5]:(s=c?(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=s);let l;t[6]!==n||t[7]!==s?(l=(0,Q.jsxs)(`span`,{children:[n,s]}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let u=!!i,d;t[9]!==r||t[10]!==a?(d=e=>a(Ze(r,e.target.checked)),t[9]=r,t[10]=a,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,Q.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let l=typeof i==`boolean`?``:String(i),u;t[19]===o?u=t[20]:(u=y(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let f;t[21]!==r.label||t[22]!==s?(f=(0,Q.jsx)(mt,{htmlFor:s,children:r.label}),t[21]=r.label,t[22]=s,t[23]=f):f=t[23];let m;t[24]!==o||t[25]!==r||t[26]!==l||t[27]!==s||t[28]!==a?(m=r.type===`select`?(0,Q.jsx)(d,{id:s,className:$(),value:l,required:r.required,onChange:e=>a(Ze(r,e.target.value)),children:(r.options??[]).map(pt)}):r.type===`textarea`?(0,Q.jsx)(`textarea`,{id:s,className:y(Ue(),`min-h-24 resize-y`),value:l,required:r.required,placeholder:r.placeholder,onChange:e=>a(Ze(r,e.target.value))}):r.type===`password`?(0,Q.jsx)(p,{id:s,className:o,value:l,onChange:e=>a(Ze(r,e)),placeholder:r.placeholder,labels:ne}):r.type===`number`?(0,Q.jsx)(J,{id:s,className:Ue(),autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,allowEmpty:!r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(Ze(r,e.target.value))}):(0,Q.jsx)(`input`,{id:s,className:Ue(),type:`text`,autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(Ze(r,e.target.value))}),t[24]=o,t[25]=r,t[26]=l,t[27]=s,t[28]=a,t[29]=m):m=t[29];let h;t[30]===c?h=t[31]:(h=c?(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[30]=c,t[31]=h);let g;return t[32]!==u||t[33]!==f||t[34]!==m||t[35]!==h?(g=(0,Q.jsxs)(`div`,{className:u,children:[f,m,h]}),t[32]=u,t[33]=f,t[34]=m,t[35]=h,t[36]=g):g=t[36],g}function pt(e){return(0,Q.jsx)(f,{value:e.id,children:e.name},e.id)}function mt(e){let t=(0,X.c)(3),{children:n,htmlFor:r}=e,i;return t[0]!==n||t[1]!==r?(i=r?(0,Q.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:n}):(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}export{Oe as n,$e as t};