@xopcai/xopc 0.0.465 → 0.0.466

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 (298) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/dingtalk/src/index.d.ts +8 -0
  3. package/dist/extensions/dingtalk/src/index.js +159 -0
  4. package/dist/extensions/dingtalk/xopc.extension.json +131 -0
  5. package/dist/extensions/discord/src/gateway.d.ts +13 -0
  6. package/dist/extensions/discord/src/gateway.js +186 -0
  7. package/dist/extensions/discord/src/index.d.ts +8 -0
  8. package/dist/extensions/discord/src/index.js +184 -0
  9. package/dist/extensions/discord/xopc.extension.json +113 -0
  10. package/dist/extensions/feishu/src/adapters/gateway-setup.js +33 -26
  11. package/dist/extensions/slack/src/index.d.ts +8 -0
  12. package/dist/extensions/slack/src/index.js +169 -0
  13. package/dist/extensions/slack/src/manifest.d.ts +33 -0
  14. package/dist/extensions/slack/src/manifest.js +32 -0
  15. package/dist/extensions/slack/xopc.extension.json +124 -0
  16. package/dist/extensions/telegram/src/adapters/gateway-setup.js +4 -1
  17. package/dist/extensions/telegram/xopc.extension.json +1 -1
  18. package/dist/extensions/wecom/src/index.d.ts +8 -0
  19. package/dist/extensions/wecom/src/index.js +188 -0
  20. package/dist/extensions/wecom/xopc.extension.json +131 -0
  21. package/dist/gateway/static/root/assets/{activity-store-B9heFbtJ.js → activity-store-CdEua6PR.js} +1 -1
  22. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-nzhB7Xjk.js → agent-avatar-dicebear-l8GQ4I9J.js} +1 -1
  23. package/dist/gateway/static/root/assets/{agent-avatar-display-DBzgoHMD.js → agent-avatar-display-BO1bqKlR.js} +2 -2
  24. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BJrNV93g.js → agent-defaults-settings-panel-Dj_H2kDD.js} +1 -1
  25. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DLbTHALG.js → agent-plugin-dialog-BQA2brAU.js} +1 -1
  26. package/dist/gateway/static/root/assets/agents-C5C5l13A.js +77 -0
  27. package/dist/gateway/static/root/assets/{agents-admin-api-CqQbYIiY.js → agents-admin-api-DZ1lLnrj.js} +1 -1
  28. package/dist/gateway/static/root/assets/api-CG-SjNfw.js +1 -0
  29. package/dist/gateway/static/root/assets/{api-BGodd--L.js → api-DDWYNF7I.js} +1 -1
  30. package/dist/gateway/static/root/assets/{api-8tNOT72p.js → api-DVXcGKP-.js} +1 -1
  31. package/dist/gateway/static/root/assets/{app-link-DImAfVs5.js → app-link-BkEO3eBe.js} +1 -1
  32. package/dist/gateway/static/root/assets/{app-management-settings-panel-Q7apF7KE.js → app-management-settings-panel-B5-7E03Z.js} +1 -1
  33. package/dist/gateway/static/root/assets/{appearance-settings-ClVZeUmo.js → appearance-settings-E_BcjEDM.js} +1 -1
  34. package/dist/gateway/static/root/assets/{apps-page-BsJJwpKj.js → apps-page-BjB_mjXu.js} +1 -1
  35. package/dist/gateway/static/root/assets/{archive-plugin-Bl_M0WJp.js → archive-plugin-MvSiDvxK.js} +1 -1
  36. package/dist/gateway/static/root/assets/{automation-api-BOnIc_vw.js → automation-api-24NjW7qG.js} +1 -1
  37. package/dist/gateway/static/root/assets/{automation-result-state-BwDSJs05.js → automation-result-state-C94Q3OEL.js} +1 -1
  38. package/dist/gateway/static/root/assets/{automation-run-list-CqlIq4BG.js → automation-run-list-BShRirWV.js} +1 -1
  39. package/dist/gateway/static/root/assets/automation-task-card-Bgq5Plux.js +2 -0
  40. package/dist/gateway/static/root/assets/{automations-page-Bimqx5Pc.js → automations-page-_apIsCPT.js} +1 -1
  41. package/dist/gateway/static/root/assets/automations-workspace-WmcQUi9O.js +9 -0
  42. package/dist/gateway/static/root/assets/{binary-plugins-DDNKe1Io.js → binary-plugins-C7i5pqkO.js} +1 -1
  43. package/dist/gateway/static/root/assets/{block-editor-BQ3amsRP.js → block-editor-DAWXPErA.js} +1 -1
  44. package/dist/gateway/static/root/assets/{browser-settings-page-CHf1_RVl.js → browser-settings-page-DI2PYAPC.js} +1 -1
  45. package/dist/gateway/static/root/assets/{capabilities-C5oWMC-Z.js → capabilities-CFWTer_v.js} +1 -1
  46. package/dist/gateway/static/root/assets/{capabilities-Cj8vl1ZY.js → capabilities-Dyw8xW90.js} +1 -1
  47. package/dist/gateway/static/root/assets/capabilities-page-C2RB9fzC.js +2 -0
  48. package/dist/gateway/static/root/assets/capabilities-settings-panel-DuQGhgAl.js +8 -0
  49. package/dist/gateway/static/root/assets/{capability-navigation-QtHJxxW2.js → capability-navigation-CZbCI5C2.js} +1 -1
  50. package/dist/gateway/static/root/assets/channels-DiDfjON8.js +1 -0
  51. package/dist/gateway/static/root/assets/{chat-agents-api-C3JChTsh.js → chat-agents-api-BksS0CNy.js} +1 -1
  52. package/dist/gateway/static/root/assets/{chat-chart-block-DrtmYOIo.js → chat-chart-block-aZIklMNN.js} +1 -1
  53. package/dist/gateway/static/root/assets/chat-page-BMZwIVXH.js +71 -0
  54. package/dist/gateway/static/root/assets/{chat-terminal-dock-B0D220I-.js → chat-terminal-dock-B4HoRIzf.js} +1 -1
  55. package/dist/gateway/static/root/assets/{command-palette-api-CkJ6_Yf3.js → command-palette-api-VhBEUFmw.js} +1 -1
  56. package/dist/gateway/static/root/assets/{composer-handoff-params-GKGdXjMZ.js → composer-handoff-params-DBpzHuNo.js} +1 -1
  57. package/dist/gateway/static/root/assets/{composer-model-config-control-DQCOWHzJ.js → composer-model-config-control-BhRAbdPW.js} +1 -1
  58. package/dist/gateway/static/root/assets/{composer-notifications-D__OU_xx.js → composer-notifications-nT-U6jcc.js} +1 -1
  59. package/dist/gateway/static/root/assets/{composer-payload-handoff-BBTbJ1bO.js → composer-payload-handoff-xEFHDnLo.js} +1 -1
  60. package/dist/gateway/static/root/assets/{computer-settings-page-DGRUCkOt.js → computer-settings-page-DXlH96m6.js} +1 -1
  61. package/dist/gateway/static/root/assets/{connected-providers-grid-BoDipD2g.js → connected-providers-grid-D8vBFsbY.js} +1 -1
  62. package/dist/gateway/static/root/assets/{connection-usage-guide-B1VUqibv.js → connection-usage-guide-C8jPm7QO.js} +1 -1
  63. package/dist/gateway/static/root/assets/{connector-service-page-bwQ1PekA.js → connector-service-page-B42yWHxS.js} +1 -1
  64. package/dist/gateway/static/root/assets/{connectors-api-BvYGL65q.js → connectors-api-so2a7xrD.js} +1 -1
  65. package/dist/gateway/static/root/assets/{connectors-page-BX6Jt6w5.js → connectors-page-yhOZIiUZ.js} +1 -1
  66. package/dist/gateway/static/root/assets/{date-picker-ClRDaNBJ.js → date-picker-UEh3JM7r.js} +1 -1
  67. package/dist/gateway/static/root/assets/{date-time-picker-CA6H47M6.js → date-time-picker-Dci0LfAU.js} +1 -1
  68. package/dist/gateway/static/root/assets/{desktop-pet-Bi8Hgf-x.js → desktop-pet-BAU_GuBe.js} +1 -1
  69. package/dist/gateway/static/root/assets/{desktop-pet-settings-CQ6qE8lf.js → desktop-pet-settings-CYE2eTTf.js} +1 -1
  70. package/dist/gateway/static/root/assets/{dev-view-store-UCqQeWa2.js → dev-view-store-C7v4CIlF.js} +1 -1
  71. package/dist/gateway/static/root/assets/{device-pairing-wizard-gC-XZxt2.js → device-pairing-wizard-7NDkYmiZ.js} +1 -1
  72. package/dist/gateway/static/root/assets/{directory-picker-path-field-Y8snl5Xl.js → directory-picker-path-field-DmRZY8kg.js} +1 -1
  73. package/dist/gateway/static/root/assets/{extension-authoritative-grants-D2abOXTl.js → extension-authoritative-grants-DIeg1mg8.js} +1 -1
  74. package/dist/gateway/static/root/assets/{extension-debug-page-OOlRCInL.js → extension-debug-page-D8TAJgZ_.js} +1 -1
  75. package/dist/gateway/static/root/assets/{extension-iframe-host-D_WXBf6a.js → extension-iframe-host-CjfRKtQ4.js} +1 -1
  76. package/dist/gateway/static/root/assets/{extension-marketplace-api-Bmtm6-L1.js → extension-marketplace-api-V1oFBxVi.js} +1 -1
  77. package/dist/gateway/static/root/assets/{extension-message-router-xqjjSxcp.js → extension-message-router-DZahH1Hd.js} +1 -1
  78. package/dist/gateway/static/root/assets/{extension-page-bpQnyNz-.js → extension-page-DMuHBIHa.js} +1 -1
  79. package/dist/gateway/static/root/assets/{extension-provider-l7SvHEK1.js → extension-provider-lqJ1zIkA.js} +1 -1
  80. package/dist/gateway/static/root/assets/{extension-settings-page-BvUtZGLT.js → extension-settings-page-D5IfKVff.js} +1 -1
  81. package/dist/gateway/static/root/assets/{file-preview-surface-B-r2ZnCV.js → file-preview-surface-B7B9qXm9.js} +1 -1
  82. package/dist/gateway/static/root/assets/{gateway-config-swr-DOwezeL2.js → gateway-config-swr-Dk3FtNv1.js} +1 -1
  83. package/dist/gateway/static/root/assets/{gateway-realtime-Br7dErHY.js → gateway-realtime-DMvo4pAc.js} +1 -1
  84. package/dist/gateway/static/root/assets/gateway-realtime-store-CJf-qaHZ.js +1 -0
  85. package/dist/gateway/static/root/assets/{gateway-restart-B3Xro3qd.js → gateway-restart-C2h5R1eP.js} +1 -1
  86. package/dist/gateway/static/root/assets/{gateway-settings-DCnP-HPj.js → gateway-settings-DGPaikv5.js} +1 -1
  87. package/dist/gateway/static/root/assets/{gateway-startup-retry-vteSIhYI.js → gateway-startup-retry-yZn7ShiP.js} +1 -1
  88. package/dist/gateway/static/root/assets/{global-defaults-api-Bpje9rVk.js → global-defaults-api-gsAa0Kj9.js} +1 -1
  89. package/dist/gateway/static/root/assets/{home-page-CNEgNWEQ.js → home-page-Dgopm60U.js} +3 -3
  90. package/dist/gateway/static/root/assets/{image-generation-api-BvpAa3Lj.js → image-generation-api-DPn1SBMH.js} +1 -1
  91. package/dist/gateway/static/root/assets/{imports-page-Dx5T5pqw.js → imports-page-Cc48Uq20.js} +1 -1
  92. package/dist/gateway/static/root/assets/index-BE3XMuQI.js +11 -0
  93. package/dist/gateway/static/root/assets/index-CY5vdQcc.css +1 -0
  94. package/dist/gateway/static/root/assets/{install-connector-dialog-Cb4ufypG.js → install-connector-dialog-QkJMw_uW.js} +1 -1
  95. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BEuXrnv0.js → keyboard-shortcuts-settings-BZXqXuI4.js} +1 -1
  96. package/dist/gateway/static/root/assets/{local-app-workbench-page-CPFIbEbv.js → local-app-workbench-page-wekatwet.js} +1 -1
  97. package/dist/gateway/static/root/assets/{local-apps-page-DxHcRSxc.js → local-apps-page-D-bRvlZY.js} +1 -1
  98. package/dist/gateway/static/root/assets/{local-session-drafts-Cmc-GCVa.js → local-session-drafts-CZ19DRRK.js} +1 -1
  99. package/dist/gateway/static/root/assets/{locale-store-tI9VX7dp.js → locale-store-DIBIYLnI.js} +1 -1
  100. package/dist/gateway/static/root/assets/{logs-page-BcibwftP.js → logs-page-CukseY3k.js} +1 -1
  101. package/dist/gateway/static/root/assets/{management-api-C9tFjLcE.js → management-api-EG5duPec.js} +1 -1
  102. package/dist/gateway/static/root/assets/{management-settings-DbnAlXoB.js → management-settings-B7RWHrwo.js} +1 -1
  103. package/dist/gateway/static/root/assets/{markdown-view-CSpQhSka.js → markdown-view-C30KvTaE.js} +1 -1
  104. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-DedbjJbF.js → mcp-conversation-setup-page-BZ1PDTYY.js} +1 -1
  105. package/dist/gateway/static/root/assets/{media-plugins-BYnP_orq.js → media-plugins-DlMEwcS8.js} +1 -1
  106. package/dist/gateway/static/root/assets/messages-BDBGlBKh.js +3 -0
  107. package/dist/gateway/static/root/assets/{model-selector-B4oTiJI6.js → model-selector-COGICRIG.js} +1 -1
  108. package/dist/gateway/static/root/assets/{models-hub-cache-DpEClnsE.js → models-hub-cache-aRYHi2dh.js} +1 -1
  109. package/dist/gateway/static/root/assets/new-chat-navigation-DXYDldT_.js +1 -0
  110. package/dist/gateway/static/root/assets/{note-detail-panel-D8asMfBm.js → note-detail-panel-yAPC_cZU.js} +3 -3
  111. package/dist/gateway/static/root/assets/note-image-lightbox-CxXu_Tkh.js +1 -0
  112. package/dist/gateway/static/root/assets/{notes-api-pVC1amyp.js → notes-api-BXevQivV.js} +1 -1
  113. package/dist/gateway/static/root/assets/{notes-page-CG1_6PLz.js → notes-page-CUMhjKKd.js} +1 -1
  114. package/dist/gateway/static/root/assets/{oauth-api-BsVPwufr.js → oauth-api-enDU_32p.js} +1 -1
  115. package/dist/gateway/static/root/assets/{oauth-provider-connect-Bu20kmPq.js → oauth-provider-connect-C2pfvPOI.js} +1 -1
  116. package/dist/gateway/static/root/assets/{page-context-capture-button-CDsnNXjS.js → page-context-capture-button-BaSooYGv.js} +1 -1
  117. package/dist/gateway/static/root/assets/{page-context-draft-D6tu8c_9.js → page-context-draft-4-3RtO0q.js} +1 -1
  118. package/dist/gateway/static/root/assets/page-header-store-C2ydtnXa.js +1 -0
  119. package/dist/gateway/static/root/assets/{personal-avatar-BboNc6e2.js → personal-avatar-BPQpvC34.js} +1 -1
  120. package/dist/gateway/static/root/assets/personal-page-POCG1_kK.js +1 -0
  121. package/dist/gateway/static/root/assets/{personal-profile-settings-Cd4QyseL.js → personal-profile-settings-DwMdjQ6H.js} +1 -1
  122. package/dist/gateway/static/root/assets/{personal-settings-panel-CtBY_Uk1.js → personal-settings-panel-DiNpP_g3.js} +1 -1
  123. package/dist/gateway/static/root/assets/{phone-dependencies-card-BgH1LluB.js → phone-dependencies-card-DUT-qRLZ.js} +1 -1
  124. package/dist/gateway/static/root/assets/{phone-model-connection-DkdKU5Kv.js → phone-model-connection-pvOciDNo.js} +1 -1
  125. package/dist/gateway/static/root/assets/{phone-model-picker-0g1z4RPL.js → phone-model-picker-CD97E6C5.js} +1 -1
  126. package/dist/gateway/static/root/assets/{phone-settings-page-DlIUajBY.js → phone-settings-page-BUZ1dh7s.js} +1 -1
  127. package/dist/gateway/static/root/assets/{phone-workspace-store-DW2sZtkh.js → phone-workspace-store-BwilERgv.js} +1 -1
  128. package/dist/gateway/static/root/assets/{plugin-details-dialog-9KUkZk_t.js → plugin-details-dialog-C_uOVmJv.js} +1 -1
  129. package/dist/gateway/static/root/assets/{preference-select-fields-DH5QZhIc.js → preference-select-fields-BSUgcO7-.js} +1 -1
  130. package/dist/gateway/static/root/assets/{product-automation-feedback-a1thJ0M9.js → product-automation-feedback-BlwtlUY7.js} +1 -1
  131. package/dist/gateway/static/root/assets/product-delivery-CnvCn9L-.js +1 -0
  132. package/dist/gateway/static/root/assets/{product-open-page-DCzQh7tr.js → product-open-page-Dy6D5exJ.js} +1 -1
  133. package/dist/gateway/static/root/assets/{product-preview-content-C5TLcagj.js → product-preview-content-DEUPAilo.js} +1 -1
  134. package/dist/gateway/static/root/assets/product-preview-modal-C4TV9RUd.js +2 -0
  135. package/dist/gateway/static/root/assets/project-detail-page-BjOzJyw1.js +7 -0
  136. package/dist/gateway/static/root/assets/{project-understanding-CoPBvlqf.js → project-understanding-lOJ5Tz2V.js} +1 -1
  137. package/dist/gateway/static/root/assets/{projects-page-k1v8Fry8.js → projects-page-B3aGdPHy.js} +1 -1
  138. package/dist/gateway/static/root/assets/{providers-api-BSJZyO8n.js → providers-api-C26HgxZY.js} +1 -1
  139. package/dist/gateway/static/root/assets/{recording-upload-CExCePtr.js → recording-upload-BJkXktA-.js} +1 -1
  140. package/dist/gateway/static/root/assets/{registry-api-CqcJj60w.js → registry-api-pQ0eInzG.js} +1 -1
  141. package/dist/gateway/static/root/assets/{remote-access-hub-BLFkNl1y.js → remote-access-hub-CjWrYzjf.js} +1 -1
  142. package/dist/gateway/static/root/assets/{resource-unavailable-B_BXTQa7.js → resource-unavailable-Y9WRHOnz.js} +1 -1
  143. package/dist/gateway/static/root/assets/{right-workspace-store-OceFhUjM.js → right-workspace-store-DHHyicqQ.js} +1 -1
  144. package/dist/gateway/static/root/assets/route-preload-DjYsRhY1.js +2 -0
  145. package/dist/gateway/static/root/assets/{routine-panel-BsE9o9uu.js → routine-panel-DSNsdpy8.js} +2 -2
  146. package/dist/gateway/static/root/assets/{runtime-tools-api-aAZChVm4.js → runtime-tools-api-BoJQ3u5o.js} +1 -1
  147. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bn9HTrK5.js → runtime-tools-settings-panel-DB7cfLrX.js} +1 -1
  148. package/dist/gateway/static/root/assets/schema-form-DXHzZPMr.js +1 -0
  149. package/dist/gateway/static/root/assets/send-1f1Ntw6E.js +1 -0
  150. package/dist/gateway/static/root/assets/{service-recommendation-list-BNIVRGDf.js → service-recommendation-list-_rFmwIwY.js} +1 -1
  151. package/dist/gateway/static/root/assets/{session-api-DdW7Wix2.js → session-api-a6wb0_Gf.js} +1 -1
  152. package/dist/gateway/static/root/assets/{session-channel-icon-DUJbB-Km.js → session-channel-icon-COynhpeK.js} +1 -1
  153. package/dist/gateway/static/root/assets/{session-identity-label-DjhlQ6LU.js → session-identity-label-DCIZvqbN.js} +1 -1
  154. package/dist/gateway/static/root/assets/session-manager-D5g6LOU-.js +25 -0
  155. package/dist/gateway/static/root/assets/{sessions-page-CfhKeUkZ.js → sessions-page-dEupc-3A.js} +1 -1
  156. package/dist/gateway/static/root/assets/settings-advanced-gate-DjyibJZ1.js +1 -0
  157. package/dist/gateway/static/root/assets/{settings-advanced-section-BOoJfJuB.js → settings-advanced-section-CnGJr2xp.js} +1 -1
  158. package/dist/gateway/static/root/assets/{settings-mode-store-BMh_BQ9a.js → settings-mode-store-DWRhupcY.js} +1 -1
  159. package/dist/gateway/static/root/assets/{settings-page-header-Bfu4cuQd.js → settings-page-header-wL2jvs-y.js} +1 -1
  160. package/dist/gateway/static/root/assets/{settings-page-layout-BnZa1qHH.js → settings-page-layout-BkUQVmyY.js} +1 -1
  161. package/dist/gateway/static/root/assets/{settings-page-M6XwzIyu.js → settings-page-u-U9D9qT.js} +1 -1
  162. package/dist/gateway/static/root/assets/{setup-interaction-page-CVlrVNrm.js → setup-interaction-page-D238tuw-.js} +1 -1
  163. package/dist/gateway/static/root/assets/{setup-status-panel-FFyDODEx.js → setup-status-panel-DXvYjIu3.js} +1 -1
  164. package/dist/gateway/static/root/assets/{share-link-dialog-Cv-eDEw_.js → share-link-dialog-DFDJyl3N.js} +1 -1
  165. package/dist/gateway/static/root/assets/{share-preview-page-BctH6eFs.js → share-preview-page-BYPdlPIb.js} +1 -1
  166. package/dist/gateway/static/root/assets/{shares-api-cLTEcQLE.js → shares-api-CfFiW03g.js} +1 -1
  167. package/dist/gateway/static/root/assets/{shares-settings-DcetAN8K.js → shares-settings-B85XIDFv.js} +1 -1
  168. package/dist/gateway/static/root/assets/{skill-api-CgEZJoy9.js → skill-api-CWRhFSkA.js} +1 -1
  169. package/dist/gateway/static/root/assets/{skill-list-api-BWVr2PL5.js → skill-list-api-CmPp2czp.js} +1 -1
  170. package/dist/gateway/static/root/assets/{skill-reload-api-BLhHNvaK.js → skill-reload-api-BGsSq3dj.js} +1 -1
  171. package/dist/gateway/static/root/assets/{skills-page-DIjcAvA0.js → skills-page-DqD0FPeH.js} +1 -1
  172. package/dist/gateway/static/root/assets/{system-settings-panel-C7LAPaN_.js → system-settings-panel-aw9C86I8.js} +1 -1
  173. package/dist/gateway/static/root/assets/task-detail-page-BPHt6S1V.js +3 -0
  174. package/dist/gateway/static/root/assets/{task-result-evidence-BsBn3n_l.js → task-result-evidence-C-zIBpzi.js} +1 -1
  175. package/dist/gateway/static/root/assets/{terminal-panel-store-DJbLuUku.js → terminal-panel-store-CgPqgrm7.js} +1 -1
  176. package/dist/gateway/static/root/assets/{theme-store-QGcjV6pN.js → theme-store-DxF7S6I2.js} +1 -1
  177. package/dist/gateway/static/root/assets/{tracing-settings-page-BKCiPwYL.js → tracing-settings-page-Dvlunx28.js} +1 -1
  178. package/dist/gateway/static/root/assets/{tunnel-api-S7J5Lpzt.js → tunnel-api-CIte6n0U.js} +1 -1
  179. package/dist/gateway/static/root/assets/{understanding-activity-store-BNVhtJkn.js → understanding-activity-store-C2RHmRo8.js} +1 -1
  180. package/dist/gateway/static/root/assets/{understanding-refresh-store-CM6bUcaJ.js → understanding-refresh-store-CPeQIXS_.js} +1 -1
  181. package/dist/gateway/static/root/assets/{usage-page-D-AqzjIx.js → usage-page-DPUjEj39.js} +1 -1
  182. package/dist/gateway/static/root/assets/{use-autosave-CqZbhhCc.js → use-autosave-xX2KrbXw.js} +1 -1
  183. package/dist/gateway/static/root/assets/{use-composer-attachments-BfLhIb2_.js → use-composer-attachments-UhypPQH_.js} +1 -1
  184. package/dist/gateway/static/root/assets/{use-file-preview-expanded-DufxDues.js → use-file-preview-expanded-BvEF3yHL.js} +3 -3
  185. package/dist/gateway/static/root/assets/{use-personal-profile-RnjxZnLa.js → use-personal-profile-BJgaheR4.js} +1 -1
  186. package/dist/gateway/static/root/assets/{use-realtime-voice-w3aHR2dr.js → use-realtime-voice-RQW5KnIN.js} +1 -1
  187. package/dist/gateway/static/root/assets/{use-workspace-tree-2Ck-ql5c.js → use-workspace-tree-B6QFV5gR.js} +1 -1
  188. package/dist/gateway/static/root/assets/{user-model-page-CBcGMhrR.js → user-model-page-hKnsTcMk.js} +1 -1
  189. package/dist/gateway/static/root/assets/{voice-api-key-field-C4rhpgco.js → voice-api-key-field-BeEF7Thh.js} +1 -1
  190. package/dist/gateway/static/root/assets/{voice-config-api-7AHN-ns6.js → voice-config-api-vbBoKnqd.js} +1 -1
  191. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-BbRrj833.js → voice-input-shortcut-events-CKn6X3qL.js} +1 -1
  192. package/dist/gateway/static/root/assets/{voice-settings-wamtp0lg.js → voice-settings-BUrk4mwV.js} +1 -1
  193. package/dist/gateway/static/root/assets/{work-discovery-overlay-fVofN7aP.js → work-discovery-overlay-Ddvqu02U.js} +1 -1
  194. package/dist/gateway/static/root/assets/{work-discovery-page-DcQG5GWy.js → work-discovery-page-BdBpri6P.js} +1 -1
  195. package/dist/gateway/static/root/assets/{working-directory-picker-modal-D8Stwszr.js → working-directory-picker-modal-DStgfCzQ.js} +1 -1
  196. package/dist/gateway/static/root/assets/{workspace-api-D3iuTdNK.js → workspace-api-CscTRODe.js} +2 -2
  197. package/dist/gateway/static/root/assets/workspace-editor-agent-store-CyPjTDSx.js +1 -0
  198. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-BXbL5Y1h.js → workspace-file-preview-dialog-BRQIf4sc.js} +1 -1
  199. package/dist/gateway/static/root/assets/{workspace-open-location-menu-1gFO_BdL.js → workspace-open-location-menu-CBHFZ2iQ.js} +1 -1
  200. package/dist/gateway/static/root/assets/{workspace-preview-store-adwmi4nx.js → workspace-preview-store-DNLnuHlf.js} +1 -1
  201. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DhGh4rm7.js → xopc-cloud-account-card-Cm0Saa8B.js} +1 -1
  202. package/dist/gateway/static/root/index.html +99 -97
  203. package/dist/package.js +1 -1
  204. package/dist/packages/gateway-contract/src/index.js +2 -0
  205. package/dist/packages/gateway-contract/src/product-delivery.js +2 -0
  206. package/dist/packages/gateway-contract/src/video-generation.js +75 -0
  207. package/dist/src/agent/embedded/runs.d.ts +1 -0
  208. package/dist/src/agent/embedded/runs.js +5 -2
  209. package/dist/src/agent/inbound/attachment-pipeline.d.ts +1 -1
  210. package/dist/src/agent/inbound/attachment-pipeline.js +16 -10
  211. package/dist/src/agent/inbound/turn-dispatcher.d.ts +2 -0
  212. package/dist/src/agent/inbound/turn-dispatcher.js +31 -13
  213. package/dist/src/agent/messaging/outbound-coordinator.js +1 -0
  214. package/dist/src/agent/prompt/service-prompt-builder.js +1 -1
  215. package/dist/src/agent/tools/xopc-use-tool.js +12 -1
  216. package/dist/src/channels/bundled-channel-extensions.d.ts +1 -0
  217. package/dist/src/channels/bundled-channel-extensions.js +15 -0
  218. package/dist/src/channels/enterprise/config-surface.d.ts +1 -0
  219. package/dist/src/channels/enterprise/config-surface.js +19 -0
  220. package/dist/src/channels/enterprise/plugin.d.ts +39 -0
  221. package/dist/src/channels/enterprise/plugin.js +219 -0
  222. package/dist/src/channels/enterprise/setup.d.ts +34 -0
  223. package/dist/src/channels/enterprise/setup.js +262 -0
  224. package/dist/src/channels/enterprise/socket.d.ts +12 -0
  225. package/dist/src/channels/enterprise/socket.js +107 -0
  226. package/dist/src/channels/lifecycle-supervisor.js +11 -1
  227. package/dist/src/channels/plugin-types.d.ts +9 -0
  228. package/dist/src/channels/plugins/types.adapters.d.ts +12 -0
  229. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  230. package/dist/src/extensions/activation-planner.js +8 -2
  231. package/dist/src/extensions/bundled-extension-activation.js +9 -0
  232. package/dist/src/gateway/hono/app.js +6 -2
  233. package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
  234. package/dist/src/gateway/hono/lib/config-payload.js +2 -1
  235. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +2 -1
  236. package/dist/src/gateway/hono/routes/channels.js +2 -1
  237. package/dist/src/gateway/hono/routes/home.js +1 -1
  238. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  239. package/dist/src/gateway/hono/routes/video-generation.d.ts +3 -0
  240. package/dist/src/gateway/hono/routes/video-generation.js +166 -0
  241. package/dist/src/gateway/security/gateway-scopes.js +2 -0
  242. package/dist/src/gateway/service/session-input-coordinator.d.ts +2 -0
  243. package/dist/src/gateway/service/session-input-coordinator.js +11 -3
  244. package/dist/src/gateway/service.d.ts +1 -0
  245. package/dist/src/gateway/service.js +8 -4
  246. package/dist/src/home-intelligence/host.js +5 -5
  247. package/dist/src/session/client-history.d.ts +1 -0
  248. package/dist/src/session/client-history.js +5 -6
  249. package/dist/src/session/store.js +4 -0
  250. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  251. package/dist/src/storage/sqlite/schema.js +7 -7
  252. package/dist/src/storage/sqlite/schema.sql +31 -0
  253. package/dist/src/storage/sqlite/session-input-repository.js +5 -2
  254. package/dist/src/storage/sqlite/transcript-repository.js +12 -0
  255. package/dist/src/storage/sqlite/upgrades/275_video_generation.sql +28 -0
  256. package/dist/src/storage/sqlite/upgrades/276_video_provider_selection.sql +11 -0
  257. package/dist/src/video-generation/artifact.d.ts +5 -0
  258. package/dist/src/video-generation/artifact.js +91 -0
  259. package/dist/src/video-generation/provider-types.d.ts +21 -0
  260. package/dist/src/video-generation/provider-types.js +14 -0
  261. package/dist/src/video-generation/providers.d.ts +15 -0
  262. package/dist/src/video-generation/providers.js +72 -0
  263. package/dist/src/video-generation/repository.d.ts +58 -0
  264. package/dist/src/video-generation/repository.js +91 -0
  265. package/dist/src/video-generation/seedance.d.ts +4 -0
  266. package/dist/src/video-generation/seedance.js +72 -0
  267. package/dist/src/video-generation/settings.d.ts +5 -0
  268. package/dist/src/video-generation/settings.js +25 -0
  269. package/dist/src/video-generation/wan.d.ts +9 -0
  270. package/dist/src/video-generation/wan.js +59 -0
  271. package/dist/src/video-generation/worker.d.ts +8 -0
  272. package/dist/src/video-generation/worker.js +98 -0
  273. package/package.json +1 -1
  274. package/dist/gateway/static/root/assets/agents-C2xG8f56.js +0 -77
  275. package/dist/gateway/static/root/assets/arrow-up-right-T72JbQ1Q.js +0 -1
  276. package/dist/gateway/static/root/assets/automation-task-card-D3WXVKRs.js +0 -2
  277. package/dist/gateway/static/root/assets/automations-workspace-2SOvmw-f.js +0 -9
  278. package/dist/gateway/static/root/assets/capabilities-page-U_hQx5ou.js +0 -2
  279. package/dist/gateway/static/root/assets/capabilities-settings-panel-k5CcwhXN.js +0 -8
  280. package/dist/gateway/static/root/assets/channels-BUzno8Pi.js +0 -1
  281. package/dist/gateway/static/root/assets/chat-page-qnsMsF_s.js +0 -71
  282. package/dist/gateway/static/root/assets/gateway-realtime-store-OaEqjNTb.js +0 -1
  283. package/dist/gateway/static/root/assets/index-Cdo4_zon.js +0 -11
  284. package/dist/gateway/static/root/assets/index-DYTktubl.css +0 -1
  285. package/dist/gateway/static/root/assets/messages-e5MhDONm.js +0 -3
  286. package/dist/gateway/static/root/assets/new-chat-navigation-B6NPQ4h4.js +0 -1
  287. package/dist/gateway/static/root/assets/note-image-lightbox-DcDw5kp4.js +0 -1
  288. package/dist/gateway/static/root/assets/page-header-store-DeaRqZgV.js +0 -1
  289. package/dist/gateway/static/root/assets/personal-page-gMRmLCWG.js +0 -1
  290. package/dist/gateway/static/root/assets/product-delivery-BFfqdKLe.js +0 -1
  291. package/dist/gateway/static/root/assets/product-preview-modal-D9f-7kcI.js +0 -2
  292. package/dist/gateway/static/root/assets/project-detail-page-C4Z2HTRZ.js +0 -7
  293. package/dist/gateway/static/root/assets/route-preload-ClsAFFQc.js +0 -2
  294. package/dist/gateway/static/root/assets/schema-form-BxBDgLrg.js +0 -1
  295. package/dist/gateway/static/root/assets/session-manager-XgtApqIh.js +0 -25
  296. package/dist/gateway/static/root/assets/settings-advanced-gate-BBG8dTIY.js +0 -1
  297. package/dist/gateway/static/root/assets/task-detail-page-DmNEMg-l.js +0 -3
  298. package/dist/gateway/static/root/assets/workspace-editor-agent-store-C-J7vr2o.js +0 -1
@@ -0,0 +1,8 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-CdRzEUwF.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{f as a,l as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as u,i as d,l as f,n as p,o as m}from"./locale-store-DIBIYLnI.js";import{t as h}from"./messages-BDBGlBKh.js";import{a as g,i as _,n as v,o as y,r as b,s as x,t as S}from"./dist-CY7CS_D3.js";import{t as C}from"./arrow-right-DSSvoX71.js";import{a as w,d as T,l as E,n as D,o as O,r as k,t as A}from"./api-CG-SjNfw.js";import{t as j}from"./chevron-right-BweFrslA.js";import{n as M,r as N,t as P}from"./popover-select-CLsphyzA.js";import{t as F}from"./circle-check-C23XjkUj.js";import{C as I,S as ee,T as L,_ as R,a as z,b as te,c as B,d as V,f as ne,g as re,h as H,i as U,l as W,m as ie,n as G,o as ae,p as K,r as oe,s as se,t as ce,u as le,v as q,w as ue,x as de,y as fe}from"./connected-providers-grid-D8vBFsbY.js";import{t as pe}from"./cloud-C4-yfnnk.js";import{t as me}from"./external-link-DjqjBmc3.js";import{t as he}from"./secret-input-DsjfQmDn.js";import{t as ge}from"./eye-CABVeTq0.js";import{t as _e}from"./image-Cwyalflz.js";import{t as ve}from"./key-round-DWbpyU2U.js";import{t as J}from"./loader-circle-CifKLtgG.js";import{t as ye}from"./pencil-DmIY3Oa-.js";import{t as be}from"./plug-DKYPEgkR.js";import{t as xe}from"./plus-Q2yW6OE7.js";import{t as Se}from"./refresh-cw-BRlGaq2w.js";import{t as Ce}from"./settings-2-D-csvaET.js";import{t as we}from"./shield-check-BU58siTV.js";import{t as Te}from"./sliders-horizontal-DqsYor6I.js";import{t as Ee}from"./trash-2-DusmjVPV.js";import{t as De}from"./triangle-alert-2JXFNNKU.js";import{t as Oe}from"./wrench-DFb4r8bH.js";import{t as ke}from"./x-B_N4OPjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as X}from"./skeleton-DzdOeGYz.js";import{t as Ae}from"./voice-CDlC6XMH.js";import{a as je,i as Me}from"./vendor-swr-CdRzEUwF.js";import{n as Ne,r as Pe}from"./gateway-config-swr-Dk3FtNv1.js";import{n as Fe,t as Ie}from"./registry-api-pQ0eInzG.js";import{t as Z}from"./button-Cc4hUNTt.js";import{i as Le,o as Re}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as ze}from"./open-capability-settings-DQsmJxI7.js";import{n as Be,t as Ve}from"./interaction-BdhHBbYa.js";import{n as He,t as Ue}from"./voice-settings-BUrk4mwV.js";import{a as We,o as Ge,s as Ke}from"./form-field-width-DJw_jULe.js";import{n as qe}from"./is-masked-secret-DOkL5b_X.js";import{n as Je,t as Ye}from"./secret-input-labels-B5Jl5HqK.js";import{a as Xe}from"./navigation-ByOzYT0t.js";import{t as Ze}from"./electron-env-DHOGevH3.js";import{n as Qe,t as $e}from"./settings-form-draft-Dy10ldo8.js";import{t as et}from"./sliding-tab-list-CmcrqRzN.js";import{t as tt}from"./confirm-dialog-DrA5mTQp.js";import{n as nt,t as rt}from"./model-sort-_Tz8s_4N.js";import{n as it,r as at}from"./model-selector-COGICRIG.js";import{n as ot}from"./agents-app-path-ciChvpCS.js";import{n as st,t as ct}from"./global-defaults-api-gsAa0Kj9.js";import{t as lt}from"./settings-loading-skeleton-CAoOV17i.js";import{i as ut,n as dt,r as ft,t as pt}from"./capability-navigation-CZbCI5C2.js";import{i as mt,r as ht,t as gt}from"./models-hub-cache-aRYHi2dh.js";import{a as _t,r as vt,s as yt,t as bt}from"./providers-api-C26HgxZY.js";import{a as xt,i as St,n as Ct,o as wt,r as Tt,t as Et}from"./oauth-api-enDU_32p.js";import{t as Dt}from"./settings-advanced-section-CnGJr2xp.js";import{n as Ot,r as kt,t as At}from"./oauth-authorization-window-o6URRos4.js";import{t as jt}from"./number-input-El7Szeln.js";import{n as Mt,t as Nt}from"./settings-page-header-wL2jvs-y.js";import"./settings-page-layout-BkUQVmyY.js";import{n as Pt,t as Ft}from"./settings-form-section-num14vSv.js";import{n as It,t as Lt}from"./use-autosave-xX2KrbXw.js";import{c as Rt,h as zt,l as Bt,n as Vt,o as Ht,t as Ut}from"./voice-config-api-vbBoKnqd.js";import{a as Wt,i as Gt,n as Kt,o as qt,r as Jt,s as Yt,t as Xt}from"./image-generation-api-DPn1SBMH.js";import{t as Zt}from"./xopc-cloud-account-card-Cm0Saa8B.js";var Qt=n(),Q=e(t(),1),$=r(),$t={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},en=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function tn(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function nn(e){let t=e.split(`
3
+ `).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function rn({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a,portalContainer:o,onPendingChange:s}){let c=$t[i],[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(``),[h,C]=(0,Q.useState)(`bearer`),[w,E]=(0,Q.useState)(`x-api-key`),[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(``),[N,F]=(0,Q.useState)(`/images/generations`),[I,ee]=(0,Q.useState)(`/images/edits`),[L,R]=(0,Q.useState)(``),[z,te]=(0,Q.useState)(``),[B,V]=(0,Q.useState)([tn()]),[ne,re]=(0,Q.useState)(``),[H,U]=(0,Q.useState)(),[W,ie]=(0,Q.useState)(!1),[G,ae]=(0,Q.useState)(),[K,oe]=(0,Q.useState)(),[se,ce]=(0,Q.useState)();(0,Q.useEffect)(()=>(s?.(!!H),()=>s?.(!1)),[H,s]),(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;u(n?.providerId??``),f(t?.name??``),m(n?.baseUrl??``),C(t?.auth.type??`bearer`),E(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),O(r?`••••••••••••`:``),A(t?.apiKeyUrl??``),M(t?.documentationUrl??``),F(t?.paths?.generations??`/images/generations`),ee(t?.paths?.edits??`/images/edits`),R(t?.network?.allowedHosts.join(`
4
+ `)??``),te(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
5
+ `)),V(t?.models.map(tn)??[tn()]),re(t?.defaultModel??``),oe(void 0),U(void 0),ie(!1),ae(void 0),ce(void 0)},[r,e,n]);let le=(0,Q.useMemo)(()=>B.filter(e=>e.id.trim()).sort(nt).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[B]),q=(e,t)=>{V(n=>n.map((n,r)=>r===e?{...n,...t}:n))},ue=()=>{let e=l.trim(),t=B.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!d.trim()||!p.trim()||t.some(e=>!e.id))throw Error(c.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(c.duplicateModels);let n=ne||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(c.required);let r;try{r=nn(z)}catch{throw Error(c.invalidHeaders)}return{providerId:e,input:{baseUrl:p.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:d.trim(),...j.trim()?{documentationUrl:j.trim()}:{},...k.trim()?{apiKeyUrl:k.trim()}:{},defaultModel:n,auth:h===`header`?{type:`header`,headerName:w.trim()}:{type:h},paths:{...N.trim()?{generations:N.trim()}:{},...I.trim()?{edits:I.trim()}:{}},...L.trim()?{network:{allowedHosts:L.split(`
6
+ `).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},de=async()=>{let e=ue();return await Gt(e.providerId,e.input),h!==`none`&&D.trim()&&!qe(D)&&await Wt(e.providerId,D.trim()),await a(e.providerId),e},fe=async()=>{U(`save`),ae(void 0),oe(void 0);try{await de(),O(h===`none`?``:`••••••••••••`),oe(c.saved)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{U(void 0)}},pe=async()=>{U(`test`),ae(void 0),oe(void 0),ce(void 0);try{let e=await de(),t=await qt(e.providerId,e.input.imageGeneration.defaultModel);ce(t.images[0]?.dataUrl),oe(c.testReady)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{U(void 0)}},me=async()=>{if(n){if(!W){ie(!0);return}U(`delete`),ae(void 0);try{await Xt(n.providerId),await a(),t(!1)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{U(void 0)}}};return(0,$.jsx)(S,{open:e,onOpenChange:e=>{H||t(e)},children:(0,$.jsxs)(y,{container:o,children:[(0,$.jsx)(g,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Re)}),(0,$.jsxs)(b,{className:Y(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,Le),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(x,{className:`font-semibold text-fg`,children:n?c.editTitle:c.addTitle}),(0,$.jsx)(_,{className:`mt-1 text-sm text-fg-muted`,children:c.intro})]}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,disabled:!!H,className:`rounded-md p-1 text-fg-muted hover:bg-surface-inset hover:text-fg`,"aria-label":c.cancel,children:(0,$.jsx)(ke,{className:`size-5`})})})]}),(0,$.jsxs)(`fieldset`,{disabled:!!H,className:`min-h-0 min-w-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:c.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.providerId,(0,$.jsx)(`input`,{value:l,disabled:!!n,onChange:e=>u(e.target.value),placeholder:`my-image-service`,className:en}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.name,(0,$.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`My Image Service`,className:en})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.baseUrl,(0,$.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`https://api.example.com/v1`,className:en})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.auth,(0,$.jsx)(P,{value:h,options:[{value:`bearer`,label:c.bearer},{value:`header`,label:c.header},{value:`none`,label:c.none}],placeholder:c.auth,allowEmpty:!1,onChange:e=>C(e),triggerClassName:`mt-1.5`})]}),h===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.headerName,(0,$.jsx)(`input`,{value:w,onChange:e=>E(e.target.value),className:en})]}):null]}),h===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:c.apiKey}),k.trim()?(0,$.jsxs)(`a`,{href:k.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[c.openKeyPage,(0,$.jsx)(T,{className:`size-3.5`})]}):null]}),(0,$.jsx)(he,{id:`custom-image-api-key`,value:D,onChange:e=>O(qe(D)?e.replace(/^•+/,``):e),labels:{show:c.show,hide:c.hide,copy:c.copy,copied:c.copied},reveal:()=>yt(l).then(e=>e.apiKey),loadFailedLabel:c.revealFailed,notInConfigFile:c.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:c.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.apiKeyUrl,(0,$.jsx)(`input`,{value:k,onChange:e=>A(e.target.value),placeholder:`https://…`,className:en})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.docsUrl,(0,$.jsx)(`input`,{value:j,onChange:e=>M(e.target.value),placeholder:`https://…`,className:en})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:c.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.generationsPath,(0,$.jsx)(`input`,{value:N,onChange:e=>F(e.target.value),className:en})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.editsPath,(0,$.jsx)(`input`,{value:I,onChange:e=>ee(e.target.value),className:en})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.allowedHosts,(0,$.jsx)(`textarea`,{value:L,onChange:e=>R(e.target.value),rows:2,placeholder:`127.0.0.1
7
+ image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.staticHeaders,(0,$.jsx)(`textarea`,{value:z,onChange:e=>te(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:c.models}),(0,$.jsxs)(Z,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>V(e=>[...e,tn()]),children:[(0,$.jsx)(xe,{className:`size-4`}),c.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.defaultModel,(0,$.jsx)(P,{value:ne||B.find(e=>e.id.trim())?.id.trim()||``,options:le,placeholder:c.defaultModel,allowEmpty:!1,onChange:re,triggerClassName:`mt-1.5 max-w-sm`})]}),B.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>q(t,{id:e.target.value}),placeholder:`image-1`,className:en})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>q(t,{name:e.target.value}),className:en})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>q(t,{maxCount:e.target.value}),className:en})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>q(t,{defaultCount:e.target.value}),className:en})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>q(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:en})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.format,(0,$.jsx)(P,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:c.format,allowEmpty:!0,onChange:e=>q(t,{outputFormat:e}),triggerClassName:`mt-1.5`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.supportsSize,onChange:e=>q(t,{supportsSize:e.target.checked})}),c.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>q(t,{editEnabled:e.target.checked})}),c.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:B.length===1,onClick:()=>V(e=>e.filter((e,n)=>n!==t)),className:`ml-auto inline-flex items-center gap-1 text-xs text-red-600 disabled:opacity-40 dark:text-red-400`,children:[(0,$.jsx)(Ee,{className:`size-3.5`}),c.remove]})]})]},t))]}),se?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(ge,{className:`size-4`}),c.testReady]}),(0,$.jsx)(`img`,{src:se,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,K?(0,$.jsx)(`p`,{className:`rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:K}):null,G?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:G}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-5 py-3`,children:[n?(0,$.jsxs)(Z,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!H,onClick:()=>void me(),children:[H===`delete`?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(Ee,{className:`size-4`}),W?c.confirmDelete:c.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(Z,{variant:`secondary`,disabled:!!H,children:c.cancel})}),(0,$.jsxs)(Z,{variant:`secondary`,disabled:!!H,onClick:()=>void pe(),children:[H===`test`?(0,$.jsx)(J,{className:`size-4 animate-spin`}):null,H===`test`?c.testing:c.test]}),(0,$.jsxs)(Z,{variant:`primary`,disabled:!!H,onClick:()=>void fe(),children:[H===`save`?(0,$.jsx)(J,{className:`size-4 animate-spin`}):null,H===`save`?c.saving:c.save]})]})]})]})]})})}var an=`••••••••••••`,on={en:{title:`Image generation`,intro:`Configure the default image model and service. Agents inherit this setting unless overridden in Agent settings.`,provider:`Provider`,model:`Model`,apiKey:`API key`,getApiKey:`Get API key`,apiKeyHint:`Stored in the local credential store, never in xopc.json.`,existingKey:`A credential or environment variable is already available. Leave this blank to reuse it.`,savedKey:`A credential is saved. Use the eye button to view it, or type a new key to replace it.`,revealFailed:`Unable to load the saved API key.`,keyNotRevealable:`This credential comes from an environment variable or another non-revealable source.`,advanced:`Provider settings`,enable:`Enable image generation`,enabling:`Verifying and enabling…`,enabled:`Image generation is ready.`,addService:`Add image service`,manageService:`Manage service`,custom:`Custom`,current:`Current`,configured:`Credential ready`,needsKey:`API key required`,connect:`Connect to a gateway to continue.`,loadError:`Unable to load image generation settings.`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`配置全局图片生成模型和服务。各智能体默认继承此设置,也可在智能体详情中单独覆盖。`,provider:`Provider`,model:`模型`,apiKey:`API Key`,getApiKey:`获取 API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,savedKey:`凭据已保存。点击眼睛可查看,直接输入新密钥可替换。`,revealFailed:`无法读取已保存的 API Key。`,keyNotRevealable:`当前凭据来自环境变量或其他不可查看的来源。`,advanced:`服务商设置`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,addService:`添加图片服务`,manageService:`管理服务`,custom:`自定义`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function sn(){let e=await m(d(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function cn(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function ln(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function un(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function dn(e){let t=(0,Qt.c)(11),{field:n,value:r,onChange:i}=e,a;t[0]!==n.label||t[1]!==n.options||t[2]!==n.placeholder||t[3]!==n.required||t[4]!==n.type||t[5]!==i||t[6]!==r?(a=n.type===`select`?(0,$.jsx)(P,{value:r,options:(n.options??[]).map(fn),placeholder:n.placeholder??n.label,allowEmpty:!n.required,onChange:i,triggerClassName:`mt-1.5`}):(0,$.jsx)(`input`,{type:`url`,value:r,required:n.required,onChange:e=>i(e.target.value),placeholder:n.placeholder,className:`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[0]=n.label,t[1]=n.options,t[2]=n.placeholder,t[3]=n.required,t[4]=n.type,t[5]=i,t[6]=r,t[7]=a):a=t[7];let o;return t[8]!==n.label||t[9]!==a?(o=(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[n.label,a]}),t[8]=n.label,t[9]=a,t[10]=o):o=t[10],o}function fn(e){return{value:e.value,label:e.label}}function pn(){let e=(0,Qt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(X,{className:`h-24 rounded-xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:5}).map(mn)}),(0,$.jsx)(X,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function mn(e,t){return(0,$.jsx)(X,{className:`h-24 rounded-xl`},t)}function hn({connectOnly:e=!1,onConnected:t,onPendingChange:n}={}){let r=p(e=>e.language),a=on[r],o=!!f(e=>e.conversationId),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)({}),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null);(0,Q.useEffect)(()=>(n?.(y||x),()=>n?.(!1)),[y,x,n]);let[E,D]=(0,Q.useState)(),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(),{data:I,isLoading:ee,error:L,mutate:R}=Me(o?d(`/api/image-generation/catalog`):null,Jt,{revalidateOnFocus:!1}),{data:z,isLoading:te,error:B,mutate:V}=Me(o?d(`/api/image-generation/custom-providers`):null,Kt,{revalidateOnFocus:!1}),{data:ne,isLoading:re,error:H,mutate:U}=Me(o?`default-image-generation`:null,sn,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!I||!ne)return;let e=cn(ne.model?.primary),t=I.find(t=>t.id===e)??I.find(e=>e.configured)??I[0];t&&(c(t.id),u(t.id===e&&ln(ne.model?.primary)||t.defaultModel),g(t.configured?an:``),v(un(t)))},[ne,I]);let W=I?.find(e=>e.id===s),ie=W?W.apiKeyUrl??fe(W.id,r)[0]?.href:void 0,G=(0,Q.useMemo)(()=>[...W?.models??[]].sort(rt).map(e=>({value:e,label:e})),[W?.models]),ae=ne?.model?.primary,K=!!(W&&l&&(W.credentialMode!==`api-key`||W.configured||h.trim())&&W.configFields.every(e=>!e.required||_[e.key]?.trim()));if(!o)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.connect});if(ee||te||re)return(0,$.jsx)(pn,{});if(L||B||H||!I||!z)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a.loadError});let oe=e=>{c(e.id),u(e.defaultModel),g(e.configured?an:``),v(un(e)),D(void 0)},se=()=>{N(void 0),j(!0)},ce=()=>{let e=z.find(e=>e.providerId===W?.id);e&&(N(e),j(!0))},le=async n=>{let[r,i]=await Promise.all([V(),R()]);if(n&&i?.some(e=>e.id===n)){let a=i.find(e=>e.id===n);c(a.id),u(a.defaultModel),g(a.configured?an:``),v(un(a)),N(r?.find(e=>e.providerId===n)),e&&a.configured&&t?.()}},q=async()=>{if(!(!W||!K)){b(!0),D(void 0),k(!1);try{if(e){h.trim()&&!qe(h)&&await Wt(W.id,h.trim()),Object.keys(_).length&&await m(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:{[W.id]:_}})});let[e]=await Promise.all([R(),Ne()]);if(!e?.find(e=>e.id===W.id)?.configured)throw Error(r===`zh`?`连接尚未就绪,请先完成对应服务的授权或凭据设置。`:`Connection is not ready. Complete authorization or credentials first.`);k(!0),t?.();return}let n=await m(d(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:W.id,modelId:l,...h.trim()&&!qe(h)?{apiKey:h.trim()}:{},providerConfig:Object.fromEntries(Object.entries(_).filter(([,e])=>e.trim()))})});if(!n.payload)throw Error(`Invalid setup response`);await Promise.all([U(n.payload.default,{revalidate:!1}),R(n.payload.providers,{revalidate:!1}),i(async()=>{let{mutate:e}=await import(`./vendor-swr-CdRzEUwF.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([0,1,2])).then(({mutate:e})=>Promise.all([e(`settings-agent-defaults`),e(`settings-gateway-agents`)])),Ne()]),g(an),k(!0)}catch(e){D(e instanceof Error?e.message:String(e))}finally{b(!1)}}};return(0,$.jsxs)(`div`,{ref:w,className:`flex flex-col gap-4`,children:[(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(_e,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:e?r===`zh`?`连接图片来源,不修改默认模型,也不发送生成测试请求。`:`Connect image sources without changing defaults or sending generation tests.`:a.intro})]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:a.provider}),(0,$.jsxs)(Z,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:se,children:[(0,$.jsx)(xe,{className:`size-4`}),a.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:I.map(e=>{let t=e.id===s,n=e.id===cn(ae);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>oe(e),className:`min-h-24 rounded-xl p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${t?`bg-accent-soft shadow-surface`:`bg-surface-base/55 hover:bg-surface-hover`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-[10px] text-fg-subtle`,children:a.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!n,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${n?``:`invisible`}`,children:a.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(F,{className:`size-3.5`}):(0,$.jsx)(ve,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?a.configured:a.needsKey]})]},e.id)})})]}),W?(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[e?null:(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a.model,(0,$.jsx)(P,{value:l,options:G,placeholder:a.selectModel,allowEmpty:!1,onChange:u,triggerClassName:`mt-1.5`})]}),W.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(dn,{field:e,value:_[e.key]??``,onChange:t=>v(n=>({...n,[e.key]:t}))},e.key))]}),W.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(Z,{variant:`secondary`,onClick:ce,children:[(0,$.jsx)(Ce,{className:`size-4`}),a.manageService]})}):null,W.credentialMode===`api-key`?(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:a.apiKey}),ie?(0,$.jsxs)(`a`,{href:ie,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[a.getApiKey,(0,$.jsx)(T,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(he,{id:`image-generation-api-key`,value:h,onChange:e=>g(qe(h)?e.replace(/^•+/,``):e),placeholder:W.configured?a.existingKey:a.needsKey,labels:{show:a.show,hide:a.hide,copy:a.copy,copied:a.copied},reveal:()=>yt(W.id).then(e=>e.apiKey),loadFailedLabel:a.revealFailed,notInConfigFile:a.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},W.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:W.configured?a.savedKey:a.apiKeyHint})]}):null,W.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(Te,{className:`size-4`}),a.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:W.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(dn,{field:e,value:_[e.key]??``,onChange:t=>v(n=>({...n,[e.key]:t}))},e.key))})]}):null,O?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:e?r===`zh`?`连接已保存`:`Connection saved`:a.enabled}):null,E?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:E}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(Z,{variant:`primary`,disabled:!K||y,onClick:()=>void q(),children:[y?(0,$.jsx)(J,{className:`size-4 animate-spin`}):(0,$.jsx)(F,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:e?y?r===`zh`?`保存中…`:`Saving…`:r===`zh`?`保存图片连接`:`Save image connection`:y?a.enabling:a.enable})]})]})})]}):null,(0,$.jsx)(rn,{portalContainer:C?.closest(`[role="dialog"]`),onPendingChange:S,open:A,onOpenChange:j,provider:M,configured:!!(M&&I.find(e=>e.id===M.providerId)?.configured),language:r,onSaved:le})]})}function gn(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function _n(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map((e,t)=>{let n=e&&typeof e==`object`?e:{},r=n.type,i=r===`brave`||r===`tavily`||r===`bing`||r===`searxng`||r===`deepseek`?r:`brave`;return{clientKey:`search-provider-${t}`,type:i,apiKey:typeof n.apiKey==`string`?n.apiKey:``,url:typeof n.url==`string`?n.url:``,disabled:n.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function vn(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return(e.type===`searxng`||e.type===`deepseek`)&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await m(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),Ne()}async function yn(e){let t=await m(d(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function bn(e){let t=(0,Qt.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function xn(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ke,`dark:border-edge`)}function Sn(){return Y(Ge,We)}var Cn=[`brave`,`tavily`,`bing`,`searxng`,`deepseek`];function wn(){return{clientKey:crypto.randomUUID(),type:`brave`,apiKey:``,url:``,disabled:!1}}var Tn=$e();function En(){let e=h(p(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!f(e=>e.conversationId),[i,a]=(0,Q.useReducer)(Tn,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let u=(0,Q.useRef)(null),{data:d,error:m,isLoading:g,mutate:_}=Pe(r);Qe({enabled:r,parsed:(0,Q.useMemo)(()=>d?.payload?.config===void 0?null:_n(d.payload.config),[d]),dirty:c.current,trackedParsedRef:u,dispatch:a,onResetDirty:()=>{c.current=!1}});let v=!!(r&&g&&d===void 0&&!m),y=m instanceof Error?m.message:m?String(m):null,b=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),x=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),S=Lt({value:o,dirty:b,onSave:(0,Q.useCallback)(async e=>{try{await vn(e),a({type:`saved`,value:e}),c.current=!!(l.current&&JSON.stringify(l.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});if(!r)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(v)return(0,$.jsx)(lt,{rows:3});if(!o)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y??t.loadError}),(0,$.jsx)(Z,{type:`button`,variant:`secondary`,onClick:()=>void _(),children:n.refresh})]});let C=gn(o.providers);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,onBlurCapture:S.onBlurCapture,children:[S.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S.error}):null,(0,$.jsxs)(Ft,{children:[(0,$.jsx)(Pt,{icon:be,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(It,{status:S.status,error:S.error})}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-base/55 px-4 py-3`,children:[(0,$.jsx)(pe,{className:`mt-0.5 size-5 shrink-0 text-accent`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.cloudProvider}),(0,$.jsx)(`span`,{className:Y(`rounded-full px-2 py-0.5 text-[11px] font-medium`,C?`bg-surface-panel text-fg-muted`:`bg-accent-soft text-accent`),children:C?t.cloudOverridden:t.cloudAutomatic})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-subtle`,children:C?t.cloudOverriddenHint:t.cloudAutomaticHint})]})]}),(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(Dn,{row:n,providerIndex:r,labels:t,secretLabels:Je(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,x({providers:t})},onRemove:()=>{x({providers:o.providers.filter((e,t)=>t!==r)})}},n.clientKey??r)),(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>x({providers:[...o.providers,wn()]}),children:[(0,$.jsx)(xe,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(Ft,{children:[(0,$.jsx)(Pt,{icon:Te,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(bn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(M,{className:Sn(),value:o.regionMode,onChange:e=>x({regionMode:e.target.value}),children:[(0,$.jsx)(N,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(N,{value:`cn`,children:t.regionCn}),(0,$.jsx)(N,{value:`global`,children:t.regionGlobal})]})}),(0,$.jsx)(Dt,{title:t.maxResultsLabel,summary:o.maxResults,children:(0,$.jsx)(bn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(jt,{type:`number`,min:1,max:50,className:xn(),value:o.maxResults,onChange:e=>x({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.sectionBlocklist,` · `,o.blocklistEnabled?o.blocklistDomains.length:0]}),(0,$.jsxs)(Ft,{children:[(0,$.jsx)(Pt,{icon:we,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:o.blocklistEnabled,onChange:e=>x({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),o.blocklistEnabled?(0,$.jsx)(bn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:Y(xn(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
8
+ `),placeholder:t.blocklistDomainsPlaceholder,onChange:e=>{let t=e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]});x({blocklistDomains:t})}})}):null]})]})]})]})}function Dn(e){let t=(0,Qt.c)(56),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>yn(r).then(On),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(Sn(),`min-w-[8rem]`),t[2]=u):u=t[2];let d=n.type,f;t[3]!==o||t[4]!==n?(f=e=>o({...n,type:e.target.value,url:``,apiKey:``}),t[3]=o,t[4]=n,t[5]=f):f=t[5];let p;t[6]===i.providerTypes?p=t[7]:(p=Cn.map(e=>(0,$.jsx)(N,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=p);let m;t[8]!==n.type||t[9]!==f||t[10]!==p?(m=(0,$.jsx)(M,{className:u,value:d,onChange:f,children:p}),t[8]=n.type,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]!==o||t[13]!==n?(h=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=h):h=t[14];let g;t[15]!==n.disabled||t[16]!==h?(g=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:h}),t[15]=n.disabled,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==i.disabled||t[19]!==g?(_=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[g,i.disabled]}),t[18]=i.disabled,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Ee,{className:`size-4`}),t[21]=v):v=t[21];let y;t[22]===s?y=t[23]:(y=(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:v}),t[22]=s,t[23]=y);let b;t[24]!==y||t[25]!==_?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_,y]}),t[24]=y,t[25]=_,t[26]=b):b=t[26];let x;t[27]!==b||t[28]!==m?(x=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[m,b]}),t[27]=b,t[28]=m,t[29]=x):x=t[29];let S;t[30]!==i.deepseekUrlDesc||t[31]!==i.deepseekUrlLabel||t[32]!==i.urlDesc||t[33]!==i.urlLabel||t[34]!==o||t[35]!==n?(S=n.type===`searxng`||n.type===`deepseek`?(0,$.jsx)(bn,{label:n.type===`deepseek`?i.deepseekUrlLabel:i.urlLabel,description:n.type===`deepseek`?i.deepseekUrlDesc:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:xn(),value:n.url,placeholder:n.type===`deepseek`?`https://api.deepseek.com`:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.deepseekUrlDesc,t[31]=i.deepseekUrlLabel,t[32]=i.urlDesc,t[33]=i.urlLabel,t[34]=o,t[35]=n,t[36]=S):S=t[36];let C;t[37]!==o||t[38]!==n?(C=e=>o({...n,apiKey:e}),t[37]=o,t[38]=n,t[39]=C):C=t[39];let w;t[40]!==i.keyPlaceholder||t[41]!==i.keyPlaceholderMasked||t[42]!==i.saveError||t[43]!==l||t[44]!==n.apiKey||t[45]!==a||t[46]!==C?(w=(0,$.jsx)(he,{value:n.apiKey,onChange:C,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[40]=i.keyPlaceholder,t[41]=i.keyPlaceholderMasked,t[42]=i.saveError,t[43]=l,t[44]=n.apiKey,t[45]=a,t[46]=C,t[47]=w):w=t[47];let T;t[48]!==i.apiKeyDesc||t[49]!==i.apiKeyLabel||t[50]!==w?(T=(0,$.jsx)(bn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:w}),t[48]=i.apiKeyDesc,t[49]=i.apiKeyLabel,t[50]=w,t[51]=T):T=t[51];let E;return t[52]!==x||t[53]!==S||t[54]!==T?(E=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[x,S,T]}),t[52]=x,t[53]=S,t[54]=T,t[55]=E):E=t[55],E}function On(e){return e.apiKey??null}function kn(e,t,n=[]){return e.filter(e=>!n.includes(e.providerId)&&e.uses.some(e=>e.id===t&&e.choices.length>0))}function An(e){let t=(0,Qt.c)(75),{use:n,data:r,language:i,labels:a,onSaved:o,inline:s,onPendingChange:c,onEditingChange:l}=e,u=s!==void 0&&s,d=i===`zh`,[f,p]=(0,Q.useState)(),[m,h]=(0,Q.useState)(!1),g;t[0]===c?g=t[1]:(g=e=>{h(e),c?.(e)},t[0]=c,t[1]=g);let _=g,v=n===`transcription`?`stt`:n===`speech`?`tts`:void 0,y,b,x;if(t[2]!==r.builtinRows||t[3]!==r.cards||t[4]!==r.customConfig?.providers||t[5]!==r.loading||t[6]!==n){let e=new Set(r.cards.filter(e=>!K(e.id)||!!r.customConfig?.providers?.[e.id]).map(zn));y=[...new Set([...r.builtinRows.map(Rn),...e])].filter(t=>!K(t)||e.has(t)).sort(),b=Me,x=r.loading?null:[`capability-service-connections`,n,y.join(`,`)],t[2]=r.builtinRows,t[3]=r.cards,t[4]=r.customConfig?.providers,t[5]=r.loading,t[6]=n,t[7]=y,t[8]=b,t[9]=x}else y=t[7],b=t[8],x=t[9];let S;t[10]!==y||t[11]!==n||t[12]!==v?(S=async()=>{let e=v===`stt`?await Rt():v===`tts`?await Ht():void 0,t=e?.providers.filter(Ln).map(In),r=e?.providers.filter(Fn).map(Pn)??[],i=t?y.filter(e=>t.includes(e)):y,a=await Promise.allSettled(i.map(ee));return{services:kn(a.flatMap(Nn),n,r),failed:a.some(Mn)}},t[10]=y,t[11]=n,t[12]=v,t[13]=S):S=t[13];let C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},t[14]=C):C=t[14];let{data:w,error:T,isLoading:E,mutate:D}=b(x,S,C),O;t[15]===w?.services?O=t[16]:(O=new Set(w?.services.map(jn)),t[15]=w?.services,t[16]=O);let k=O,A,j;if(t[17]!==l||t[18]!==f?(A=()=>(l?.(!!f),()=>l?.(!1)),j=[f,l],t[17]=l,t[18]=f,t[19]=A,t[20]=j):(A=t[19],j=t[20]),(0,Q.useEffect)(A,j),f&&u){let e;if(t[21]!==r.builtinRows||t[22]!==f){let n;t[24]===f?n=t[25]:(n=e=>e.id===f,t[24]=f,t[25]=n),e=r.builtinRows.find(n),t[21]=r.builtinRows,t[22]=f,t[23]=e}else e=t[23];let a;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>p(void 0),t[26]=a):a=t[26];let s;t[27]!==D||t[28]!==o?(s=()=>{D(),p(void 0),o()},t[27]=D,t[28]=o,t[29]=s):s=t[29];let c;return t[30]!==i||t[31]!==f||t[32]!==_||t[33]!==e||t[34]!==s||t[35]!==n?(c=(0,$.jsx)(`section`,{className:`overflow-hidden rounded-xl border border-edge`,children:(0,$.jsx)(z,{inline:!0,providerId:f,row:e,targetUse:n,language:i,onPendingChange:_,onDone:a,onApplied:s},f)}),t[30]=i,t[31]=f,t[32]=_,t[33]=e,t[34]=s,t[35]=n,t[36]=c):c=t[36],c}let M=d?`选择服务`:`Choose a service`,N;t[37]===M?N=t[38]:(N=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:M}),t[37]=M,t[38]=N);let P;t[39]!==r.loading||t[40]!==E?(P=r.loading||E?(0,$.jsx)(X,{className:`h-24 w-full`}):null,t[39]=r.loading,t[40]=E,t[41]=P):P=t[41];let F;t[42]!==w?.failed||t[43]!==T||t[44]!==D||t[45]!==d?(F=T||w?.failed?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:[d?`部分服务目录暂时不可用。`:`Some service catalogs are unavailable.`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void D(),children:d?`重试`:`Retry`})]}):null,t[42]=w?.failed,t[43]=T,t[44]=D,t[45]=d,t[46]=F):F=t[46];let I;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(I=[!0,!1],t[47]=I):I=t[47];let L;t[48]!==m||t[49]!==w?.services||t[50]!==d?(L=I.map(e=>{let t=w?.services.filter(t=>t.configured===e)??[];return t.length?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:e?d?`已连接`:`Connected`:d?`添加服务`:`Add a service`}),t.map(t=>(0,$.jsxs)(`button`,{type:`button`,disabled:m,onClick:()=>p(t.providerId),className:`flex min-h-14 w-full items-center justify-between gap-3 rounded-lg px-3 py-3 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg`,children:W(t.providerId,t.profile.name,d)}),(0,$.jsx)(`span`,{className:`shrink-0 text-sm text-accent-fg`,children:e?d?`选择`:`Choose`:d?`连接`:`Connect`})]},t.providerId))]},String(e)):null}),t[48]=m,t[49]=w?.services,t[50]=d,t[51]=L):L=t[51];let R;t[52]!==w||t[53]!==d?(R=w&&!w.services.length&&!w.failed?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d?`暂无支持此能力的模型服务。`:`No model services currently support this capability.`}):null,t[52]=w,t[53]=d,t[54]=R):R=t[54];let te=d?`仅列出支持${dt[n][0]}的服务。`:`Only compatible services are shown. Reuse saved credentials, then return to select a model.`,B;t[55]===te?B=t[56]:(B=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:te}),t[55]=te,t[56]=B);let V;t[57]!==r.builtinRows||t[58]!==r.customConfig||t[59]!==k||t[60]!==a||t[61]!==i||t[62]!==D||t[63]!==o||t[64]!==f||t[65]!==n?(V=f?(0,$.jsx)(oe,{open:!0,initialProviderId:f,initialUse:n,connectOnly:!0,onOpenChange:e=>{e||p(void 0)},builtinRows:r.builtinRows.filter(e=>k.has(e.id)),customConfig:r.customConfig,labels:a,language:i,onSaved:()=>{D(),p(void 0),o()}},f):null,t[57]=r.builtinRows,t[58]=r.customConfig,t[59]=k,t[60]=a,t[61]=i,t[62]=D,t[63]=o,t[64]=f,t[65]=n,t[66]=V):V=t[66];let ne;return t[67]!==N||t[68]!==P||t[69]!==F||t[70]!==L||t[71]!==R||t[72]!==B||t[73]!==V?(ne=(0,$.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[N,P,F,L,R,B,V]}),t[67]=N,t[68]=P,t[69]=F,t[70]=L,t[71]=R,t[72]=B,t[73]=V,t[74]=ne):ne=t[74],ne}function jn(e){return e.providerId}function Mn(e){return e.status===`rejected`}function Nn(e){return e.status===`fulfilled`?[e.value]:[]}function Pn(e){return e.id}function Fn(e){return e.diagnostics.requiresApiKey}function In(e){return e.id}function Ln(e){return!e.diagnostics.requiresApiKey}function Rn(e){return e.id}function zn(e){return e.id}function Bn({zh:e,kind:t,modelServiceIds:n,onSaved:r,onPendingChange:i}){let{data:a,error:o,mutate:s}=Me([`native-voice-connections`,t??`all`,n.join(`,`)],async()=>{let[e,r]=await Promise.all([t===`tts`?Promise.resolve({providers:[]}):Rt(),t===`stt`?Promise.resolve({providers:[]}):Ht()]);return[...e.providers.map(e=>({...e,kind:`stt`})),...r.providers.map(e=>({...e,kind:`tts`}))].filter(e=>e.diagnostics.requiresApiKey||!n.includes(e.id))}),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)({}),[p,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(!1),[_,v]=(0,Q.useState)(``);(0,Q.useEffect)(()=>(i?.(p),()=>i?.(!1)),[p,i]);let y=a?.find(e=>`${e.kind}:${e.id}`===c),b=y?.fields.filter(e=>e.secret||e.type===`password`||[`baseUrl`,`region`,`groupId`].includes(e.key))??[],x=async()=>{if(!(!y||g.current)){g.current=!0,h(!0),v(``);try{let t=Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()).map(([e,t])=>[e,t.trim()]));Object.keys(t).length&&await m(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({[y.kind]:{providers:{[y.id]:t}}})});let[n]=await Promise.all([s(),mt()]);if(!n?.find(e=>e.kind===y.kind&&e.id===y.id)?.configured)throw Error(e?`连接尚未就绪,请补齐所需凭据。`:`Connection is not ready. Complete the required credentials.`);f({}),r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g.current=!1,h(!1)}}};return a&&!a.length?null:(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e?`其他语音服务与本地语音`:`Other voice services and local speech`}),(0,$.jsxs)(`section`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t===`stt`?e?`其他识别服务`:`Other recognition services`:t===`tts`?e?`其他合成服务与本地语音`:`Other synthesis services and local speech`:e?`语音 API 与本地语音`:`Voice APIs and local speech`}),!a&&!o?(0,$.jsx)(X,{className:`h-20 w-full`}):null,o?(0,$.jsxs)(`p`,{role:`alert`,children:[e?`语音服务加载失败`:`Could not load voice services`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void s(),children:e?`重试`:`Retry`})]}):null,(0,$.jsxs)(M,{value:c,disabled:p,"aria-label":e?`语音服务接入`:`Connect voice service`,onChange:e=>{l(e.target.value),f({}),v(``)},children:[(0,$.jsx)(N,{value:``,children:e?`选择语音来源`:`Choose a voice source`}),a?.map(n=>(0,$.jsxs)(N,{value:`${n.kind}:${n.id}`,children:[n.displayName,t?``:` · ${n.kind.toUpperCase()}`,n.configured?e?` · 已连接`:` · Connected`:``]},`${n.kind}:${n.id}`))]}),y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:y.diagnostics.requiresApiKey?e?`此服务使用独立的 API Key。保存连接后,可在“模型与参数”中选用。`:`This service uses its own API key. Save the connection, then choose it in Model and parameters.`:e?`此来源无需 API Key,可返回能力设置选择。`:`No API key needed. Choose this source in capability settings.`}),b.map(t=>(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm text-fg`,children:[(0,$.jsx)(`span`,{children:t.label}),t.secret||t.type===`password`?(0,$.jsx)(he,{labels:Ye,value:u[t.key]??``,onChange:e=>f(n=>({...n,[t.key]:e})),disabled:p}):t.options?.length?(0,$.jsxs)(M,{value:u[t.key]??``,disabled:p,onChange:e=>f(n=>({...n,[t.key]:e.target.value})),children:[(0,$.jsx)(N,{value:``,children:e?`保留现有值`:`Keep existing`}),(t.key===`model`?[...t.options].sort(nt):t.options).map(e=>(0,$.jsx)(N,{value:e.id,children:e.name},e.id))]}):(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel p-2`,value:u[t.key]??``,disabled:p,placeholder:t.placeholder,onChange:e=>f(n=>({...n,[t.key]:e.target.value}))})]},t.key)),_?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:_}):null,(0,$.jsx)(Z,{disabled:p||!y.configured&&y.diagnostics.requiresApiKey&&!Object.values(u).some(e=>e.trim()),onClick:()=>void x(),children:p?e?`保存中…`:`Saving…`:e?`保存连接`:`Save connection`})]}):null]})]})}function Vn(e){let t=(0,Qt.c)(8),{section:n,title:r,children:i}=e,a;t[0]===r?a=t[1]:(a=(0,$.jsx)(`h3`,{className:`border-b border-edge-subtle bg-surface-inset/40 px-4 py-1.5 text-xs font-medium text-fg-muted`,children:r}),t[0]=r,t[1]=a);let o;t[2]===i?o=t[3]:(o=(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:i}),t[2]=i,t[3]=o);let s;return t[4]!==n||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`section`,{"data-model-section":n,className:`min-w-0 border-t border-edge first:border-t-0`,children:[a,o]}),t[4]=n,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Hn(e){let t=(0,Qt.c)(10),{name:n,manageLabel:r,onManage:i,disabled:a}=e;if(!i){let e;return t[0]===n?e=t[1]:(e=n?(0,$.jsx)(`p`,{className:`px-1 text-xs text-fg-muted`,children:n}):null,t[0]=n,t[1]=e),e}let o=n?`${r} · ${n}`:r,s=n||r,c;t[2]===s?c=t[3]:(c=(0,$.jsx)(`span`,{className:`truncate`,children:s}),t[2]=s,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(j,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=l):l=t[4];let u;return t[5]!==a||t[6]!==i||t[7]!==o||t[8]!==c?(u=(0,$.jsxs)(Z,{variant:`ghost`,disabled:a,"aria-label":o,className:`min-h-8 max-w-full justify-start gap-1 rounded-md px-1 py-1 text-xs font-normal`,onClick:i,children:[c,l]}),t[5]=a,t[6]=i,t[7]=o,t[8]=c,t[9]=u):u=t[9],u}function Un(e){let t=(0,Qt.c)(13),{description:n,picker:r,actions:i,inline:a,actionColumn:o}=e;if(a){let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(`div`,{className:`min-w-0 space-y-1 py-2`,children:r}),t[0]=r,t[1]=e),e}let s=`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 py-2.5 @min-[40rem]:gap-x-4 ${o?`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_4.5rem]`:`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)]`}`,c;t[2]===n?c=t[3]:(c=(0,$.jsx)(`div`,{className:`col-start-1 row-start-1 min-w-0`,children:n}),t[2]=n,t[3]=c);let l;t[4]===r?l=t[5]:(l=(0,$.jsx)(`div`,{className:`col-span-2 row-start-2 w-full min-w-0 @min-[40rem]:col-span-1 @min-[40rem]:col-start-2 @min-[40rem]:row-start-1`,children:r}),t[4]=r,t[5]=l);let u;t[6]===i?u=t[7]:(u=i&&(0,$.jsx)(`div`,{className:`col-start-2 row-start-1 flex justify-end @min-[40rem]:col-start-3`,children:i}),t[6]=i,t[7]=u);let d;return t[8]!==s||t[9]!==c||t[10]!==l||t[11]!==u?(d=(0,$.jsxs)(`div`,{className:s,children:[c,l,u]}),t[8]=s,t[9]=c,t[10]=l,t[11]=u,t[12]=d):d=t[12],d}var Wn=`clear-natural-model`;function Gn({label:e,value:t,currentLabel:n,options:r,loading:i,disabled:a,zh:o,onConnect:s,onManage:c,onSelect:l}){let[u,d]=(0,Q.useState)(``),f=u.trim().toLowerCase().split(/\s+/).filter(Boolean),p=[...r].sort((e,t)=>(e.group??``).localeCompare(t.group??``,`en`,{numeric:!0,sensitivity:`base`})||rt(e.label,t.label)||rt(e.value,t.value)).filter(e=>{let t=`${e.label} ${e.group} ${e.value} ${e.searchText??``}`.toLowerCase();return f.every(e=>t.includes(e))}),m=r.find(e=>e.value===t),h=m?.group??r.find(e=>e.value.split(`/`)[0]===t?.split(`/`)[0])?.group,g=m?.label??(t?.endsWith(`/default`)?o?`默认模型`:`Default model`:n??t),_=h?`${g} · ${h}`:g;return!i&&!r.length?(0,$.jsx)(Z,{variant:`secondary`,className:`min-h-11 w-full sm:justify-start`,"aria-label":`${o?`连接`:`Connect`} ${e}`,disabled:a,onClick:s,children:o?`连接服务以启用`:`Connect a service to enable`}):(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(P,{value:t??``,options:p,selectedLabel:g,title:_,placeholder:o?`选择模型`:`Choose a model`,ariaLabel:`${o?`选择`:`Select`} ${e}`,allowEmpty:!1,disabled:a,loading:i,onChange:l,searchPlaceholder:o?`搜索模型或服务`:`Search models or services`,searchValue:u,onSearchChange:d,statusMessage:p.length?void 0:o?`没有可用模型`:`No available models`,triggerClassName:`min-h-11`}),(0,$.jsx)(Hn,{name:h,manageLabel:o?`管理服务`:`Manage services`,onManage:c,disabled:a})]})}function Kn({data:e,zh:t,onChange:n,onSettings:r,onlyUse:i,disabled:a=!1,onPendingChange:o,videoRow:s}){let{data:c,error:l,mutate:u}=Me(`settings-agent-defaults`,ct),{data:f}=Pe(!0),{data:p,mutate:m}=Me(!i||i===`conversation`?d(Ut):null,Vt),{data:h,isLoading:g,error:_,mutate:v}=Me(`model-capability-media-sources`,async()=>{let e=await Promise.allSettled([Ht(),Rt(),Jt()]);return{ids:[...new Set(e.flatMap(e=>e.status===`fulfilled`?(Array.isArray(e.value)?e.value:e.value.providers).filter(e=>e.configured).map(e=>e.id):[]))],failed:e.some(e=>e.status===`rejected`)}}),y=[...new Set([...e.cards.filter(t=>t.configured&&(!K(t.id)||!!e.customConfig?.providers?.[t.id])).map(e=>e.id),...h?.ids??[]])].sort(),{data:b,isLoading:x,mutate:S}=Me(e.loading?null:[`model-use-choices`,...y],async()=>{let e=await Promise.allSettled(y.map(ee));return{previews:e.flatMap(e=>e.status===`fulfilled`&&e.value.configured?[e.value]:[]),failed:e.some(e=>e.status===`rejected`)}},{revalidateOnFocus:!1}),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(null),D=(0,Q.useRef)(!1),O=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>o?.(!1),[o]);let k=async(e,t)=>{if(D.current||a)return;let n=b?.previews.find(n=>n.uses.some(n=>n.id===e&&n.choices.some(e=>e.id===t))),r=e===`conversation`&&(t===`boson/higgs-realtime`||t===Wn);if(!n&&!r)return;D.current=!0,o?.(!0),w(e),E(null);let i={mode:`replace`,selected:[e],overrides:{[e]:t}};try{if(r)await m(await zt({defaultForNatural:t===Ae}),{revalidate:!1}),await Ne();else if(n){let t=await I(n.providerId,i);await de(n.providerId,i,t.revision),await Promise.all([u(),S(),...e===`conversation`?[m(),Ne()]:[]])}E({use:e})}catch(t){E({use:e,error:t instanceof Error?t.message:String(t)}),Promise.allSettled([u(),S()])}finally{D.current=!1,w(null),o?.(!1),requestAnimationFrame(()=>O.current?.querySelector(`[data-capability="${e}"] button[aria-label]`)?.focus())}},A=f?.payload?.config?Bt(f.payload.config):void 0;if(!c&&!l)return(0,$.jsx)(X,{className:`h-48 w-full rounded-xl`});if(l)return(0,$.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[t?`模型用途加载失败`:`Could not load model uses`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void u(),children:t?`重试`:`Retry`})]});let j=c.defaults.models,M=A?.voice.realtime,N=M?.enabled&&M.omni?`${M.omni.provider}/${M.omni.model}`:void 0,P=p?.defaultForNatural??M?.boson?.defaultForNatural?Ae:N,F=j.background?.primary??j.chat.primary,L=e.builtinRows.find(e=>e.id===F.split(`/`)[0])?.setupProfile?.interactiveOnly!==!0,R=b?.previews[0]?.uses.find(e=>e.id===`background`),z=R?R.current:L?F:void 0,te=[{id:`chat`,label:t?`对话与任务`:`Chat and tasks`,ref:j.chat.primary},{id:`vision`,label:t?`看图`:`Image understanding`,ref:j.imageUnderstanding?.primary},{id:`image`,label:t?`画图`:`Image generation`,ref:j.imageGeneration?.primary},{id:`background`,label:t?`后台任务`:`Background tasks`,ref:z,inherited:!j.background&&!!z},{id:`transcription`,label:t?`录音与听写`:`Recording and dictation`,ref:A?.stt.enabled?`${A.stt.provider}/${A.stt.providers?.[A.stt.provider]?.model??`default`}`:void 0},{id:`speech`,label:t?`语音合成`:`Speech synthesis`,ref:A?.tts.enabled?`${A.tts.provider}/${A.tts.providers?.[A.tts.provider]?.model??`default`}`:void 0},{id:`conversation`,label:t?`自然语音模型`:`Natural voice model`,ref:P}];return(0,$.jsxs)(`section`,{ref:O,className:`@container min-w-0`,children:[(0,$.jsx)(`h2`,{className:i?`mb-2 text-sm font-semibold text-fg`:`sr-only`,children:i?t?`当前模型`:`Current model`:t?`能力总览`:`Capabilities`}),(0,$.jsx)(`div`,{className:i?`space-y-4`:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:pt.filter(e=>!i||e.uses.includes(i)).map(o=>{let c=o.uses.filter(e=>!i||e===i).map(o=>{let s=te.find(e=>e.id===o),c=qn(b?.previews??[],s.id,t);s.id===`conversation`&&((p?.credentialSource||s.ref===`boson/higgs-realtime`)&&c.push({value:Ae,label:`Higgs Realtime`,group:`Boson AI`,disabled:!p?.credentialSource}),s.ref===`boson/higgs-realtime`&&!c.some(e=>e.value!==`boson/higgs-realtime`)&&c.push({value:Wn,label:t?`取消默认模型`:`Clear default model`}));let l=s.ref?e.allModels.find(e=>e.id===s.ref):void 0,u=l?at(l,t?`zh`:`en`):s.ref;return(0,$.jsx)(`div`,{"data-capability":s.id,children:(0,$.jsx)(Un,{inline:!!i,actionColumn:!!r,description:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:dt[s.id][+!t]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:s.ref?c.some(e=>e.value===s.ref||s.ref?.endsWith(`/default`)&&e.value.split(`/`)[0]===s.ref.split(`/`)[0])?null:t?`待连接`:`Connection needed`:t?`未配置`:`Not set up`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:B[s.id][+!t]}),s.inherited?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t?`继承默认对话`:`Inherits chat default`}):null]}),picker:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Gn,{label:s.id===`conversation`?s.label:dt[s.id][+!t],value:s.ref,currentLabel:u,options:c,loading:e.loading||x||g,disabled:C!==null||a,zh:t,onConnect:()=>n(s.id),onManage:r?()=>n(s.id):void 0,onSelect:e=>{e!==s.ref&&k(s.id,e)}}),C===s.id?(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:t?`正在切换…`:`Switching…`}):null,T?.use===s.id?(0,$.jsx)(`div`,{role:T.error?`alert`:`status`,className:`text-xs text-fg-muted`,children:T.error?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-danger`,children:t?`未能切换模型,请重试。`:`Could not switch models. Please retry.`}),(0,$.jsxs)(`details`,{className:`mt-1`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:t?`查看详情`:`Show details`}),(0,$.jsx)(`p`,{className:`mt-1 break-words`,children:T.error})]})]}):t?`已切换`:`Model changed`}):null]}),actions:r&&(s.id===`conversation`||c.length>0||x||g)?(0,$.jsx)(Z,{variant:`ghost`,className:`min-h-11`,disabled:C!==null||a,onClick:()=>r(s.id),children:t?`设置`:`Settings`}):null})},s.id)});return i?(0,$.jsx)(`div`,{className:`min-w-0 divide-y divide-edge-subtle`,children:c},o.uses[0]):(0,$.jsxs)(Vn,{section:o.uses[0],title:o.label[+!t],children:[c,o.uses.includes(`vision`)&&s]},o.uses[0])})}),(!r||i)&&(b?.failed||h?.failed||_)?(0,$.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:[t?`部分服务的模型加载失败`:`Some model services could not be loaded`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void Promise.all([v(),S()]),children:t?`重试`:`Retry`})]}):null,i||r?null:(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t?`快速与复杂任务模型随对话配置;音色、流式听写及电脑操作可在详细设置中调整。`:`Fast and complex task models follow chat setup. Voices, streaming dictation and Computer Use have detailed settings.`})]})}function qn(e,t,n=!1){return e.flatMap(e=>e.uses.find(e=>e.id===t)?.choices.map(t=>({value:t.id,label:t.name,group:W(e.providerId,e.profile.name,n),searchText:e.profile.name}))??[])}var Jn={id:`services`,label:[`服务账户`,`Service accounts`]},Yn=[...pt.map(e=>({id:e.uses[0],label:e.label})),Jn];function Xn(e){let t=e.parentElement;for(;t&&!/^(auto|scroll|overlay)$/.test(getComputedStyle(t).overflowY);)t=t.parentElement;return t}function Zn(){return window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`}function Qn(e){let t=(0,Qt.c)(37),{zh:n,children:r}=e,i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(Yn[0].id),u,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{let e=i.current,t=a.current;if(!e||!t)return;let n=Xn(e);if(!n)return;let r=0,o=()=>{if(r=0,s.current!==null){Math.abs(n.scrollTop-s.current)<=1&&(s.current=null);return}let i=[...e.querySelectorAll(`[data-model-section]`)],a=t.getBoundingClientRect().bottom+9,o=n.scrollHeight-n.clientHeight,c=(o>1&&n.scrollTop>=o-1?i.at(-1):i.findLast(e=>e.getBoundingClientRect().top<=a))??i[0];c?.dataset.modelSection&&l(c.dataset.modelSection)},c=()=>{r||=requestAnimationFrame(o)},u=()=>{s.current=null},d=()=>{s.current===null||Math.abs(n.scrollTop-s.current)<=1||(u(),c())},f=e=>{[`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `].includes(e.key)&&u()};n.addEventListener(`scroll`,c,{passive:!0}),n.addEventListener(`scrollend`,d),n.addEventListener(`wheel`,u,{passive:!0}),n.addEventListener(`touchstart`,u,{passive:!0}),n.addEventListener(`pointerdown`,u),n.addEventListener(`keydown`,f);let p=typeof ResizeObserver>`u`?null:new ResizeObserver(c);return p?.observe(e),p?.observe(n),c(),()=>{cancelAnimationFrame(r),p?.disconnect(),n.removeEventListener(`scroll`,c),n.removeEventListener(`scrollend`,d),n.removeEventListener(`wheel`,u),n.removeEventListener(`touchstart`,u),n.removeEventListener(`pointerdown`,u),n.removeEventListener(`keydown`,f)}},d=[],t[0]=u,t[1]=d):(u=t[0],d=t[1]),(0,Q.useEffect)(u,d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=o.current,t=e?.querySelector(`[aria-current="location"]`);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.left<n.left?r.left-n.left:Math.max(0,r.right-n.right);i&&e.scrollBy({left:i,behavior:Zn()})},t[2]=f):f=t[2];let p;t[3]===c?p=t[4]:(p=[c],t[3]=c,t[4]=p),(0,Q.useEffect)(f,p);let m,h,g,_,v,y,b,x,S,C,w,T;if(t[5]!==c||t[6]!==n){let e=function(e){let t=i.current,n=a.current,r=t?.querySelector(`[data-model-section="${e}"]`);if(!t||!n||!r)return;l(e);let o=Xn(t);if(!o){r.scrollIntoView?.({block:`start`,behavior:Zn()});return}let c=Math.max(0,Math.min(o.scrollHeight-o.clientHeight,o.scrollTop+r.getBoundingClientRect().top-o.getBoundingClientRect().top-o.clientTop-n.getBoundingClientRect().height-8));if(Math.abs(o.scrollTop-c)<1){s.current!==null&&o.scrollTo({top:c,behavior:`instant`}),s.current=null;return}s.current=c,o.scrollTo({top:c,behavior:Zn()})};y=i,b=`flex min-w-0 flex-col gap-5`,_=a,v=`sticky top-0 z-10 min-w-0 bg-surface-panel py-1`,m=et,x=`nav`,S=o,C=n?`模型配置分区`:`Model settings sections`,w=!1,T=`flex w-full gap-0.5 overflow-x-auto rounded-xl bg-surface-inset p-1`,h=`rounded-lg bg-surface-panel ring-1 ring-edge-subtle motion-reduce:transition-none`,g=Yn.map(t=>(0,$.jsx)(`button`,{type:`button`,"aria-current":c===t.id?`location`:void 0,"aria-pressed":c===t.id,className:Y(`touch-target relative z-10 min-h-9 min-w-max flex-1 whitespace-nowrap rounded-lg px-3 text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,c===t.id?`text-fg`:`text-fg-muted hover:text-fg`),onClick:()=>e(t.id),children:t.label[+!n]},t.id)),t[5]=c,t[6]=n,t[7]=m,t[8]=h,t[9]=g,t[10]=_,t[11]=v,t[12]=y,t[13]=b,t[14]=x,t[15]=S,t[16]=C,t[17]=w,t[18]=T}else m=t[7],h=t[8],g=t[9],_=t[10],v=t[11],y=t[12],b=t[13],x=t[14],S=t[15],C=t[16],w=t[17],T=t[18];let E;t[19]!==m||t[20]!==h||t[21]!==g||t[22]!==x||t[23]!==S||t[24]!==C||t[25]!==w||t[26]!==T?(E=(0,$.jsx)(m,{as:x,ref:S,"aria-label":C,scrollFocusedItemIntoView:w,className:T,indicatorClassName:h,children:g}),t[19]=m,t[20]=h,t[21]=g,t[22]=x,t[23]=S,t[24]=C,t[25]=w,t[26]=T,t[27]=E):E=t[27];let D;t[28]!==_||t[29]!==v||t[30]!==E?(D=(0,$.jsx)(`div`,{ref:_,className:v,children:E}),t[28]=_,t[29]=v,t[30]=E,t[31]=D):D=t[31];let O;return t[32]!==r||t[33]!==y||t[34]!==b||t[35]!==D?(O=(0,$.jsxs)(`div`,{ref:y,className:b,children:[D,r]}),t[32]=r,t[33]=y,t[34]=b,t[35]=D,t[36]=O):O=t[36],O}function $n(e){let t=(0,Qt.c)(208),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=p(tr)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:re(``),t[0]=n,t[1]=l);let[u,d]=(0,Q.useState)(l),[f,m]=(0,Q.useState)(er),h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{d(n=>({...n,[e]:t})),m(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=h):h=t[2];let g=h,_;t[3]!==u.computerUse||t[4]!==u.contextWindow||t[5]!==u.id||t[6]!==u.input||t[7]!==u.maxTokens||t[8]!==s.modelIdRequired||t[9]!==s.mustBePositive||t[10]!==c?(_=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,s.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),u.computerUse&&!u.input?.includes(`image`)&&e.set(`computerUse`,c?`电脑控制模型必须支持图片输入`:`Computer Use requires image input`),m(e),e.size===0},t[3]=u.computerUse,t[4]=u.contextWindow,t[5]=u.id,t[6]=u.input,t[7]=u.maxTokens,t[8]=s.modelIdRequired,t[9]=s.mustBePositive,t[10]=c,t[11]=_):_=t[11];let y=_,b;t[12]!==u||t[13]!==o||t[14]!==a||t[15]!==y?(b=()=>{if(!y())return;let e=(u.id||``).trim(),t={...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}};a(t),o()},t[12]=u,t[13]=o,t[14]=a,t[15]=y,t[16]=b):b=t[16];let S=b,C=u,w;t[17]===C?w=t[18]:(w=ie(C),t[17]=C,t[18]=w);let T=w,E=r?s.addModelTitle:s.editModelTitle,D;t[19]===E?D=t[20]:(D=(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:E}),t[19]=E,t[20]=D);let O;t[21]!==s.modelProviderLabel||t[22]!==i?(O=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[21]=s.modelProviderLabel,t[22]=i,t[23]=O):O=t[23];let k;t[24]!==D||t[25]!==O?(k=(0,$.jsxs)(`div`,{children:[D,O]}),t[24]=D,t[25]=O,t[26]=k):k=t[26];let A;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(A=Y(Ve,`p-1.5 hover:bg-surface-base`),t[27]=A):A=t[27];let j;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(ke,{className:`size-4`}),t[28]=j):j=t[28];let P;t[29]===s.close?P=t[30]:(P=(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:A,"aria-label":s.close,children:j})}),t[29]=s.close,t[30]=P);let F;t[31]!==k||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[k,P]}),t[31]=k,t[32]=P,t[33]=F):F=t[33];let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=I):I=t[34];let ee;t[35]===s.modelId?ee=t[36]:(ee=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,I]}),t[35]=s.modelId,t[36]=ee);let L;t[37]===f?L=t[38]:(L=Y(V(),f.has(`id`)&&`border-red-500`),t[37]=f,t[38]=L);let R=u.id||``,z;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>g(`id`,e.target.value),t[39]=z):z=t[39];let te=!r,B;t[40]!==L||t[41]!==R||t[42]!==te?(B=(0,$.jsx)(`input`,{className:L,value:R,onChange:z,placeholder:`e.g. llama3.1:8b`,disabled:te}),t[40]=L,t[41]=R,t[42]=te,t[43]=B):B=t[43];let U;t[44]===f?U=t[45]:(U=f.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[44]=f,t[45]=U);let W;t[46]!==ee||t[47]!==B||t[48]!==U?(W=(0,$.jsxs)(`div`,{children:[ee,B,U]}),t[46]=ee,t[47]=B,t[48]=U,t[49]=W):W=t[49];let G;t[50]===s.displayName?G=t[51]:(G=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=G);let ae;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(ae=V(),t[52]=ae):ae=t[52];let K=u.name||``,oe;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>g(`name`,e.target.value),t[53]=oe):oe=t[53];let se;t[54]===K?se=t[55]:(se=(0,$.jsx)(`input`,{className:ae,value:K,onChange:oe}),t[54]=K,t[55]=se);let ce;t[56]!==G||t[57]!==se?(ce=(0,$.jsxs)(`div`,{children:[G,se]}),t[56]=G,t[57]=se,t[58]=ce):ce=t[58];let q;t[59]===s.inputTypes?q=t[60]:(q=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=q);let ue;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(ue=H(),t[61]=ue):ue=t[61];let de;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>g(`input`,ne(e.target.value)),t[62]=de):de=t[62];let fe;t[63]===s?fe=t[64]:(fe=le.map(e=>(0,$.jsx)(N,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=fe);let pe;t[65]!==T||t[66]!==fe?(pe=(0,$.jsx)(M,{className:ue,value:T,onChange:de,children:fe}),t[65]=T,t[66]=fe,t[67]=pe):pe=t[67];let me;t[68]!==q||t[69]!==pe?(me=(0,$.jsxs)(`div`,{children:[q,pe]}),t[68]=q,t[69]=pe,t[70]=me):me=t[70];let he=u.reasoning||!1,ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>g(`reasoning`,e.target.checked),t[71]=ge):ge=t[71];let _e;t[72]===he?_e=t[73]:(_e=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:he,onChange:ge}),t[72]=he,t[73]=_e);let ve;t[74]!==s.reasoning||t[75]!==_e?(ve=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[_e,s.reasoning]}),t[74]=s.reasoning,t[75]=_e,t[76]=ve):ve=t[76];let J;t[77]!==me||t[78]!==ve?(J=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[me,ve]}),t[77]=me,t[78]=ve,t[79]=J):J=t[79];let ye;t[80]===s.contextWindow?ye=t[81]:(ye=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=ye);let be;t[82]===f?be=t[83]:(be=Y(V(),f.has(`contextWindow`)&&`border-red-500`),t[82]=f,t[83]=be);let xe=u.contextWindow??128e3,Se;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Se=e=>g(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=Se):Se=t[84];let Ce;t[85]!==be||t[86]!==xe?(Ce=(0,$.jsx)(jt,{type:`number`,min:1,className:be,value:xe,onChange:Se}),t[85]=be,t[86]=xe,t[87]=Ce):Ce=t[87];let we;t[88]===f?we=t[89]:(we=f.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[88]=f,t[89]=we);let Te;t[90]!==ye||t[91]!==Ce||t[92]!==we?(Te=(0,$.jsxs)(`div`,{children:[ye,Ce,we]}),t[90]=ye,t[91]=Ce,t[92]=we,t[93]=Te):Te=t[93];let Ee;t[94]===s.maxOutputTokens?Ee=t[95]:(Ee=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=Ee);let De;t[96]===f?De=t[97]:(De=Y(V(),f.has(`maxTokens`)&&`border-red-500`),t[96]=f,t[97]=De);let Oe=u.maxTokens??16384,X;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(X=e=>g(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=X):X=t[98];let Ae;t[99]!==De||t[100]!==Oe?(Ae=(0,$.jsx)(jt,{type:`number`,min:1,className:De,value:Oe,onChange:X}),t[99]=De,t[100]=Oe,t[101]=Ae):Ae=t[101];let je;t[102]===f?je=t[103]:(je=f.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[102]=f,t[103]=je);let Me;t[104]!==Ee||t[105]!==Ae||t[106]!==je?(Me=(0,$.jsxs)(`div`,{children:[Ee,Ae,je]}),t[104]=Ee,t[105]=Ae,t[106]=je,t[107]=Me):Me=t[107];let Ne;t[108]!==Te||t[109]!==Me?(Ne=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Te,Me]}),t[108]=Te,t[109]=Me,t[110]=Ne):Ne=t[110];let Pe;t[111]===s.costSection?Pe=t[112]:(Pe=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=Pe);let Fe;t[113]===s.costInput?Fe=t[114]:(Fe=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Fe);let Ie;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=V(),t[115]=Ie):Ie=t[115];let Le=u.cost?.input??0,Re;t[116]===u.cost?Re=t[117]:(Re=e=>g(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[116]=u.cost,t[117]=Re);let ze;t[118]!==Le||t[119]!==Re?(ze=(0,$.jsx)(jt,{type:`number`,step:`any`,min:0,className:Ie,value:Le,onChange:Re}),t[118]=Le,t[119]=Re,t[120]=ze):ze=t[120];let Be;t[121]!==Fe||t[122]!==ze?(Be=(0,$.jsxs)(`div`,{children:[Fe,ze]}),t[121]=Fe,t[122]=ze,t[123]=Be):Be=t[123];let He;t[124]===s.costOutput?He=t[125]:(He=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=He);let Ue;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=V(),t[126]=Ue):Ue=t[126];let We=u.cost?.output??0,Ge;t[127]===u.cost?Ge=t[128]:(Ge=e=>g(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[127]=u.cost,t[128]=Ge);let Ke;t[129]!==We||t[130]!==Ge?(Ke=(0,$.jsx)(jt,{type:`number`,step:`any`,min:0,className:Ue,value:We,onChange:Ge}),t[129]=We,t[130]=Ge,t[131]=Ke):Ke=t[131];let qe;t[132]!==He||t[133]!==Ke?(qe=(0,$.jsxs)(`div`,{children:[He,Ke]}),t[132]=He,t[133]=Ke,t[134]=qe):qe=t[134];let Je;t[135]!==Be||t[136]!==qe?(Je=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Be,qe]}),t[135]=Be,t[136]=qe,t[137]=Je):Je=t[137];let Ye;t[138]!==Pe||t[139]!==Je?(Ye=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Pe,Je]}),t[138]=Pe,t[139]=Je,t[140]=Ye):Ye=t[140];let Xe;t[141]!==W||t[142]!==ce||t[143]!==J||t[144]!==Ne||t[145]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[W,ce,J,Ne,Ye]}),t[141]=W,t[142]=ce,t[143]=J,t[144]=Ne,t[145]=Ye,t[146]=Xe):Xe=t[146];let Ze=c?`高级:手机操作协议`:`Advanced: Phone Use protocol`,Qe;t[147]===Ze?Qe=t[148]:(Qe=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ze}),t[147]=Ze,t[148]=Qe);let $e=c?`手机操作协议`:`Phone Use protocol`,et=u.phoneUse?.profile??``,tt;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(tt=e=>g(`phoneUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=tt):tt=t[149];let nt=c?`自动识别`:`Automatic`,rt;t[150]===nt?rt=t[151]:(rt=(0,$.jsx)(N,{value:``,children:nt}),t[150]=nt,t[151]=rt);let it,at,ot,st,ct;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(it=(0,$.jsx)(N,{value:`autoglm-phone-v1`,children:`AutoGLM Phone`}),at=(0,$.jsx)(N,{value:`structured-phone-v1`,children:`Structured Phone`}),ot=(0,$.jsx)(N,{value:`structured-tools-phone-v1`,children:`Visual function tools`}),st=(0,$.jsx)(N,{value:`doubao-seed-phone-v1`,children:`Doubao Seed GUI`}),ct=(0,$.jsx)(N,{value:`gui-owl-phone-v1`,children:`GUI-Owl 1.5`}),t[152]=it,t[153]=at,t[154]=ot,t[155]=st,t[156]=ct):(it=t[152],at=t[153],ot=t[154],st=t[155],ct=t[156]);let lt;t[157]!==$e||t[158]!==et||t[159]!==rt?(lt=(0,$.jsxs)(M,{"aria-label":$e,value:et,onChange:tt,children:[rt,it,at,ot,st,ct]}),t[157]=$e,t[158]=et,t[159]=rt,t[160]=lt):lt=t[160];let ut=c?`通用视觉模型支持图片输入和工具调用时会自动显示;也可指定专用手机协议。`:`Visual models with image input and function tools appear automatically. Dedicated phone protocols can also be selected.`,dt;t[161]===ut?dt=t[162]:(dt=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ut}),t[161]=ut,t[162]=dt);let ft;t[163]!==lt||t[164]!==dt?(ft=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[lt,dt]}),t[163]=lt,t[164]=dt,t[165]=ft):ft=t[165];let pt;t[166]!==Qe||t[167]!==ft?(pt=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Qe,ft]}),t[166]=Qe,t[167]=ft,t[168]=pt):pt=t[168];let mt=c?`高级:电脑控制协议`:`Advanced: Computer Use protocol`,ht;t[169]===mt?ht=t[170]:(ht=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:mt}),t[169]=mt,t[170]=ht);let gt=c?`电脑控制协议`:`Computer Use protocol`,_t=u.computerUse?.profile??``,vt;t[171]===Symbol.for(`react.memo_cache_sentinel`)?(vt=e=>g(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[171]=vt):vt=t[171];let yt=c?`自动识别`:`Automatic`,bt;t[172]===yt?bt=t[173]:(bt=(0,$.jsx)(N,{value:``,children:yt}),t[172]=yt,t[173]=bt);let xt,St,Ct;t[174]===Symbol.for(`react.memo_cache_sentinel`)?(xt=(0,$.jsx)(N,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),St=(0,$.jsx)(N,{value:`structured-tools-v1`,children:`structured-tools-v1`}),Ct=(0,$.jsx)(N,{value:`openai-responses-computer-v1`,children:`OpenAI Responses Computer`}),t[174]=xt,t[175]=St,t[176]=Ct):(xt=t[174],St=t[175],Ct=t[176]);let wt;t[177]!==gt||t[178]!==_t||t[179]!==bt?(wt=(0,$.jsxs)(M,{"aria-label":gt,value:_t,onChange:vt,children:[bt,xt,St,Ct]}),t[177]=gt,t[178]=_t,t[179]=bt,t[180]=wt):wt=t[180];let Tt=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,Et;t[181]===Tt?Et=t[182]:(Et=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:Tt}),t[181]=Tt,t[182]=Et);let Dt;t[183]===f?Dt=t[184]:(Dt=f.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:f.get(`computerUse`)}),t[183]=f,t[184]=Dt);let Ot;t[185]!==Et||t[186]!==Dt||t[187]!==wt?(Ot=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[wt,Et,Dt]}),t[185]=Et,t[186]=Dt,t[187]=wt,t[188]=Ot):Ot=t[188];let kt;t[189]!==Ot||t[190]!==ht?(kt=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[ht,Ot]}),t[189]=Ot,t[190]=ht,t[191]=kt):kt=t[191];let At;t[192]!==kt||t[193]!==Xe||t[194]!==pt?(At=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Xe,pt,kt]}),t[192]=kt,t[193]=Xe,t[194]=pt,t[195]=At):At=t[195];let Mt;t[196]===s.cancel?Mt=t[197]:(Mt=(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(Z,{type:`button`,variant:`secondary`,children:s.cancel})}),t[196]=s.cancel,t[197]=Mt);let Nt=r?s.addModelConfirm:s.saveModelConfirm,Pt;t[198]!==S||t[199]!==Nt?(Pt=(0,$.jsx)(Z,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:S,children:Nt}),t[198]=S,t[199]=Nt,t[200]=Pt):Pt=t[200];let Ft;t[201]!==Mt||t[202]!==Pt?(Ft=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Mt,Pt]}),t[201]=Mt,t[202]=Pt,t[203]=Ft):Ft=t[203];let It;return t[204]!==At||t[205]!==Ft||t[206]!==F?(It=(0,$.jsxs)($.Fragment,{children:[F,At,Ft]}),t[204]=At,t[205]=Ft,t[206]=F,t[207]=It):It=t[207],It}function er(){return new Map}function tr(e){return e.language}function nr(e){let t=(0,Qt.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(g,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Re)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col`,Le,`overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`),t[1]=u):u=t[1];let d;t[2]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(d=n?(0,$.jsx)($n,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=d):d=t[9];let f;t[10]===d?f=t[11]:(f=(0,$.jsxs)(y,{children:[l,(0,$.jsx)(b,{className:u,onOpenAutoFocus:rr,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(S,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function rr(e){return e.preventDefault()}function ir(e){let t=(0,Qt.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>yt(n).then(ar),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(he,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function ar(e){return e.apiKey??null}function or(e){let t=(0,Qt.c)(23),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f=(0,Q.useRef)(null),[p,m]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(null),v;t[0]===r?v=t[1]:(v=e=>{e||(_(null),m(!1)),r(e)},t[0]=r,t[1]=v);let x=v,C;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(g,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Re)}),t[2]=C):C=t[2];let w,T,E;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{f.current=document.activeElement instanceof HTMLElement?document.activeElement:null},T=e=>{f.current?.isConnected&&(e.preventDefault(),f.current.focus({preventScroll:!0}))},E=Y(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(85vh,720px)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,Le),t[3]=w,t[4]=T,t[5]=E):(w=t[3],T=t[4],E=t[5]);let D;t[6]!==c||t[7]!==o||t[8]!==s||t[9]!==x||t[10]!==a||t[11]!==l||t[12]!==u||t[13]!==r||t[14]!==d||t[15]!==i||t[16]!==p||t[17]!==h?(D=(0,$.jsxs)(y,{children:[C,(0,$.jsx)(b,{onOpenAutoFocus:w,onCloseAutoFocus:T,className:E,children:h?(0,$.jsx)(U,{target:h,zh:u===`zh`,onDone:()=>x(!1)}):!a&&p?(0,$.jsx)(z,{providerId:i,existingConnection:!0,row:o.find(e=>e.id===i),language:u,onApplied:d,onBack:()=>m(!1),onDone:()=>x(!1)}):a?(0,$.jsx)(cr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onModelAdded:e=>_({providerId:i,modelIds:[e]})}):(0,$.jsx)(sr,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onQuickSetup:()=>m(!0)},i)})]}),t[6]=c,t[7]=o,t[8]=s,t[9]=x,t[10]=a,t[11]=l,t[12]=u,t[13]=r,t[14]=d,t[15]=i,t[16]=p,t[17]=h,t[18]=D):D=t[18];let O;return t[19]!==x||t[20]!==n||t[21]!==D?(O=(0,$.jsx)(S,{open:n,onOpenChange:x,children:D}),t[19]=x,t[20]=n,t[21]=D,t[22]=O):O=t[22],O}function sr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o,onQuickSetup:s}){let c=t.find(t=>t.id===e),u=q[e],d=n.filter(t=>t.provider===e),[f,p]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(c?.apiKey??``),[_,y]=(0,Q.useState)(!1),[b,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),D=h(i).providersSettings,O=c?.supportsApiKey!==!1,k=c?.supportsOAuth===!0,[A,j]=(0,Q.useState)(c?.authMode===`oauth`||!O?`oauth`:`api-key`),M=c?.authMode===`oauth`&&c.authStatus===`connected`,N=c?.configured===!0&&c.authMode!==`oauth`&&c.activeKeySource!==`env`&&c.activeKeySource!==`extension`&&c.activeKeySource!==`models_json`,[P,I]=(0,Q.useState)(null),[ee,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(`idle`),[B,V]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null),[W,ie]=(0,Q.useState)(``),G=(0,Q.useRef)(null),K=(0,Q.useRef)(null),oe=R===`waiting`||R===`waiting_code`,ce=(0,Q.useMemo)(()=>fe(e,i),[e,i]),le=m!==(c?.apiKey??``),de=async()=>{let t=m.trim();if(!(!t||!O||vt(t))){y(!0),w(null);try{await _t({[e]:t}),S(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){w(e instanceof Error?e.message:r.saveError)}finally{y(!1)}}};(0,Q.useEffect)(()=>{if(!P||!oe)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Tt(P);t.status===`waiting_auth`||t.status===`waiting_code`?(z(t.status===`waiting_code`?`waiting_code`:`waiting`),L(t.message??null),V(t.authUrl??null),re(t.instructions??null),U(t.deviceCode??null),t.authUrl&&t.authUrl!==K.current&&(K.current=t.authUrl,Ot(t.authUrl,G.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),At(G.current),G.current=null,z(`success`),L(t.message??D.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),At(G.current),G.current=null,z(`error`),L(t.error??t.message??D.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,oe,a,o,D.revokeFailed,D.saved]),(0,Q.useEffect)(()=>()=>{P&&Ct(P).catch(()=>{})},[P]),(0,Q.useEffect)(()=>()=>{At(G.current),G.current=null},[]);let pe=async()=>{try{await bt(e),o(),a()}catch{}},he=async()=>{At(G.current),G.current=kt(),K.current=null,z(`waiting`),L(D.oauthStarting),V(null),re(null),U(null),w(null);try{let t=await xt(e);I(t.sessionId)}catch(e){At(G.current),G.current=null,z(`error`),L(e instanceof Error?e.message:D.revokeFailed)}},ge=async()=>{if(P){try{await Et(P)}catch{}At(G.current),G.current=null,K.current=null,z(`idle`),L(null),I(null),V(null),re(null),U(null)}},_e=async()=>{if(!(!P||!W.trim()))try{await wt(P,W.trim()),ie(``),L(D.oauthProcessingCode)}catch(e){z(`error`),L(e instanceof Error?e.message:D.revokeFailed)}},ve=async()=>{try{await St(e),o(),a()}catch(e){w(e instanceof Error?e.message:D.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Be.press),children:(0,$.jsx)(ke,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 py-4`,children:[u?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,(0,$.jsx)(se,{row:c,language:i}),O&&k?(0,$.jsx)(ae,{value:A,onChange:j,language:i,disabled:oe||_}):null,O&&A===`api-key`?(0,$.jsx)(ir,{providerId:e,inputId:`manage-api-key`,value:m,onChange:e=>{g(e),S(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):!O&&c?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),c?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(c.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(me,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,k&&A===`oauth`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:D.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:M?i===`zh`?`账号已连接`:`Account connected`:c?.authMode===`oauth`&&c.authStatus===`expired`?i===`zh`?`授权已过期,请重新登录`:`Authorization expired. Sign in again.`:i===`zh`?`通过浏览器授权连接账号`:`Authorize your account in the browser`})]}),M?(0,$.jsx)(Z,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void ve(),children:D.revoke}):(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:oe,onClick:()=>void he(),children:[oe?(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),D.oauth]})]}),ee?(0,$.jsx)(`p`,{className:Y(`text-xs`,R===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:ee}):null,R===`waiting`||R===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[B?(0,$.jsxs)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover`,children:[(0,$.jsx)(me,{className:`size-4`,"aria-hidden":!0}),D.openAuthPage]}):null,(0,$.jsx)(Z,{type:`button`,variant:`secondary`,onClick:()=>void ge(),children:D.cancelOAuth})]}):null,ne?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ne}):null,H?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:D.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:H}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:D.deviceCodeHint})]}):null,R===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:W,onChange:e=>ie(e.target.value),onKeyDown:e=>e.key===`Enter`&&void _e(),"aria-label":D.pasteRedirectUrl,placeholder:D.pasteRedirectUrl,className:Y(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Ke)}),(0,$.jsx)(Z,{type:`button`,variant:`primary`,onClick:()=>void _e(),children:D.submitCode})]}):null]}):null,ce.length>0&&O&&A===`api-key`?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ce.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[te(e,r),(0,$.jsx)(me,{className:`size-3`,"aria-hidden":!0})]},e))}):null,A===`api-key`&&c?.baseUrl?(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:i===`zh`?`高级设置`:`Advanced settings`}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all font-mono text-xs text-fg-muted`,children:c.baseUrl})]})]}):c?.category===`extension`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.apiUrlExtensionHint}):null,d.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[i===`zh`?`模型目录`:`Model catalog`,` (`,d.length,`)`]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i===`zh`?`此服务的模型目录;实际访问权限取决于当前生效的凭据和账号。`:`Models registered for this provider. Access depends on the active credentials and account.`}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:f,onChange:e=>p(e.target.checked)}),i===`zh`?`仅电脑控制模型`:`Computer Use only`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.filter(e=>!f||e.computerUse).map(e=>(0,$.jsxs)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:[at(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),s?(0,$.jsx)(Z,{variant:`secondary`,disabled:le||oe||c?.authStatus!==`connected`,onClick:s,children:i===`zh`?`配置模型用途`:`Configure model uses`}):null,C?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[N?(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>E(!0),children:[(0,$.jsx)(Ee,{className:`size-3.5`,"aria-hidden":!0}),i===`zh`?`移除 API Key`:`Remove API key`]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:O&&A===`api-key`&&le&&!vt(m.trim())?(0,$.jsx)(Z,{type:`button`,variant:`primary`,disabled:!m.trim()||_||b,onClick:()=>void de(),children:b?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(tt,{open:T,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,c?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void pe(),onCancel:()=>E(!1)})]})}function cr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a,onModelAdded:o}){let s=h(r).modelsSettings,c=t?.providers[e],[l,u]=(0,Q.useState)(c?.baseUrl??``),[d,f]=(0,Q.useState)(c?.apiKey??``),[p,m]=(0,Q.useState)(c?.models??[]),[g,_]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(c?.modelDiscovery?.enabled===!0),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),P=n=>{if(!t)return null;let r=d.trim(),i={...c,baseUrl:l.trim()||void 0,apiKey:vt(r)?c?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},F=async()=>{let e=P({models:p,modelDiscovery:{enabled:y}});if(e){C(!0),T(null);try{await R(e),a(),i()}catch(e){T(e instanceof Error?e.message:n.saveError)}finally{C(!1)}}},I=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await R({providers:r}),a(),i()}catch{}},ee=(e,t)=>{N({model:e,isNew:t}),j(!0)},L=async e=>{if(!M)return;let t=M.isNew&&!p.some(t=>t.id===e.id),r=M.isNew?[...p,e]:p.map(t=>t.id===e.id?e:t);m(r);let i=P({models:r});if(i)try{await R(i),a(),t&&!e.computerUse&&o(e.id)}catch(e){T(e instanceof Error?e.message:n.saveError)}},z=async e=>{let t=p.filter(t=>t.id!==e);m(t),k(null);let r=P({models:t});if(r)try{await R(r),a()}catch(e){T(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Be.press),children:(0,$.jsx)(ke,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:l,onChange:e=>u(e.target.value),className:Y(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Ke)})]}),(0,$.jsx)(ir,{providerId:e,inputId:`manage-custom-api-key`,value:d,onChange:f,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[s.modelsSection,p.length>0?` (${p.length})`:``]}),(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>ee(null,!0),children:[(0,$.jsx)(xe,{className:`size-3.5`,"aria-hidden":!0}),s.addModel]})]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:g,onChange:e=>_(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),p.filter(e=>!g||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:p.filter(e=>!g||e.computerUse).map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.computerUse&&(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Computer Use`}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Be.press),onClick:()=>ee(e,!1),"aria-label":s.editModel,children:(0,$.jsx)(ye,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,Be.press),onClick:()=>k(e.id),"aria-label":s.removeModel,children:(0,$.jsx)(Ee,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),w?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>D(!0),children:[(0,$.jsx)(Ee,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(Z,{type:`button`,variant:`primary`,disabled:S,onClick:()=>void F(),children:S?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(tt,{open:E,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void I(),onCancel:()=>D(!1)}),(0,$.jsx)(tt,{open:O!==null,title:s.removeModel,description:s.removeModelConfirm.replace(`{{id}}`,O??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{O&&z(O)},onCancel:()=>k(null)}),(0,$.jsx)(nr,{open:A,onOpenChange:e=>{j(e),e||N(null)},providerId:e,model:M?.model??null,isNew:M?.isNew??!1,onSave:e=>void L(e),m:s})]})}var lr=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],ur=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`,dr={en:{fast:[`Fast tasks`,`Short, low-latency work`],reasoning:[`Complex reasoning`,`Planning and multi-step analysis`],coding:[`Coding`,`Implementation and debugging`],review:[`Review`,`Critique and verification`],vision:[`Vision`,`Image and visual analysis`],understanding:[`Understanding`,`Long-form content comprehension`]},zh:{fast:[`快速任务`,`简短、低延迟的工作`],reasoning:[`复杂推理`,`规划和多步骤分析`],coding:[`编程`,`实现、调试和代码修改`],review:[`审查`,`检查、批评和验证`],vision:[`视觉任务`,`图片和视觉内容分析`],understanding:[`内容理解`,`长内容阅读和理解`]}};function fr(e,t){return{primary:t,fallbacks:e?.fallbacks??[]}}function pr(e){let t=(0,Qt.c)(38),{draft:n,setDraft:r,zh:i,capability:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[0]=o):o=t[0];let s=Me(Ie,Fe,o),c;t[1]===s.data?c=t[2]:(c=s.data??[],t[1]=s.data,t[2]=c);let l=c,u=i?dr.zh:dr.en,d;t[3]!==n||t[4]!==r?(d=(e,t)=>{let i={...n.models.intents};t?i[e]=fr(i[e],t):delete i[e],r({...n,models:{...n.models,intents:i}})},t[3]=n,t[4]=r,t[5]=d):d=t[5];let f=d,p;t[6]!==a||t[7]!==n||t[8]!==l||t[9]!==s.error||t[10]!==s.isLoading||t[11]!==r||t[12]!==i?(p=a===`chat`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:(0,$.jsx)(Dt,{title:i?`模型回退`:`Model fallbacks`,summary:i?`已配置 ${n.models.chat.fallbacks.length} 个备用模型。`:`${n.models.chat.fallbacks.length} fallback models configured.`,children:(0,$.jsx)(`div`,{className:`mt-6 rounded-xl bg-surface-base/45 p-4`,children:(0,$.jsx)(Yt,{primary:n.models.chat.primary,value:n.models.chat.fallbacks,models:l,loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,chat:{...n.models.chat,fallbacks:e}}})})})})}):null,t[6]=a,t[7]=n,t[8]=l,t[9]=s.error,t[10]=s.isLoading,t[11]=r,t[12]=i,t[13]=p):p=t[13];let m;t[14]!==a||t[15]!==n||t[16]!==r||t[17]!==i?(m=a===`image`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:n.models.imageGeneration?(0,$.jsx)(Dt,{title:i?`图片执行策略`:`Image execution policy`,summary:i?`当前超时与回退策略继续生效。`:`The current timeout and fallback policy remains active.`,children:(0,$.jsxs)(`div`,{className:`mt-5 grid gap-4 rounded-xl bg-surface-base/45 p-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[i?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,$.jsx)(jt,{allowEmpty:!0,type:`number`,min:1,className:`${ur} mt-2`,value:n.models.imageGeneration.timeoutMs??``,onChange:e=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,timeoutMs:e.target.value?Number(e.target.value):void 0}}})})]}),(0,$.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(`span`,{children:i?`服务商自动回退`:`Automatic provider fallback`}),(0,$.jsx)(et,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,role:`group`,"aria-label":i?`服务商自动回退`:`Automatic provider fallback`,children:[!0,!1].map(e=>(0,$.jsx)(Z,{"aria-pressed":n.models.imageGeneration?.autoProviderFallback===e,variant:n.models.imageGeneration?.autoProviderFallback===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,autoProviderFallback:e}}}),children:e?i?`开启`:`On`:i?`关闭`:`Off`},String(e)))})]})]})}):null}):null,t[14]=a,t[15]=n,t[16]=r,t[17]=i,t[18]=m):m=t[18];let h;t[19]!==a||t[20]!==n||t[21]!==l||t[22]!==s.error||t[23]!==s.isLoading||t[24]!==r||t[25]!==i?(h=a===`vision`&&n.models.imageUnderstanding?(0,$.jsx)(Dt,{title:i?`模型回退`:`Model fallbacks`,summary:i?`主模型不可用时使用已配置的备用模型。`:`Use configured fallback models when the primary is unavailable.`,children:(0,$.jsx)(Yt,{primary:n.models.imageUnderstanding.primary,value:n.models.imageUnderstanding.fallbacks,models:l.filter(mr),loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,imageUnderstanding:{...n.models.imageUnderstanding,fallbacks:e}}})})}):null,t[19]=a,t[20]=n,t[21]=l,t[22]=s.error,t[23]=s.isLoading,t[24]=r,t[25]=i,t[26]=h):h=t[26];let g;t[27]!==a||t[28]!==u||t[29]!==n||t[30]!==f||t[31]!==i?(g=a===`chat`?(0,$.jsx)(Dt,{title:i?`任务模型路由`:`Task model routing`,summary:i?`已配置 ${Object.keys(n.models.intents).length} 类任务路由;其他任务使用默认模型。`:`${Object.keys(n.models.intents).length} task routes configured; other tasks use the default model.`,children:(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:i?`按任务选择模型`:`Route by task`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i?`仅在确实需要不同模型时设置;否则保持“使用默认对话模型”。`:`Set a route only when a task genuinely needs another model; otherwise keep the default.`}),(0,$.jsx)(`div`,{className:`mt-5 grid gap-3 lg:grid-cols-2`,children:lr.map(e=>(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/55 p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:u[e][0]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u[e][1]})]}),(0,$.jsx)(it,{value:n.models.intents[e]?.primary??``,placeholder:i?`使用默认对话模型`:`Use default conversation model`,searchPlaceholder:i?`搜索模型或服务商`:`Search models or providers`,noMatches:i?`没有匹配的模型`:`No matching models`,allowEmpty:!0,emptyLabel:i?`使用默认对话模型`:`Use default conversation model`,showProviderInTrigger:!1,contentAlign:`start`,className:`w-full`,ariaLabel:i?`${u[e][0]}模型`:`${u[e][0]} model`,onChange:t=>f(e,t)})]},e))})]})}):null,t[27]=a,t[28]=u,t[29]=n,t[30]=f,t[31]=i,t[32]=g):g=t[32];let _;return t[33]!==p||t[34]!==m||t[35]!==h||t[36]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-5`,children:[p,m,h,g]}),t[33]=p,t[34]=m,t[35]=h,t[36]=g,t[37]=_):_=t[37],_}function mr(e){return e.vision}function hr(e){let t=(0,Qt.c)(9),{data:n,error:r}=Me(`settings-agent-defaults`,ct);if(r&&!n){let e=String(r),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e}),t[0]=e,t[1]=n),n}if(!n){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{className:`h-32 rounded-xl`}),t[2]=e):e=t[2],e}let i;t[3]===n.defaults.models?i=t[4]:(i=JSON.stringify(n.defaults.models),t[3]=n.defaults.models,t[4]=i);let a;return t[5]!==n.defaults||t[6]!==e||t[7]!==i?(a=(0,$.jsx)(gr,{...e,initial:n.defaults},i),t[5]=n.defaults,t[6]=e,t[7]=i,t[8]=a):a=t[8],a}function gr(e){let t=(0,Qt.c)(36),{initial:n,capability:r,zh:i,disabled:a,onPendingChange:o}=e,s;t[0]===n?s=t[1]:(s=()=>structuredClone(n),t[0]=n,t[1]=s);let[c,l]=(0,Q.useState)(s),u;t[2]===n?u=t[3]:(u=()=>structuredClone(n),t[2]=n,t[3]=u);let[d,f]=(0,Q.useState)(u),p;t[4]===c.models?p=t[5]:(p=JSON.stringify(c.models),t[4]=c.models,t[5]=p);let m;t[6]===d.models?m=t[7]:(m=JSON.stringify(d.models),t[6]=d.models,t[7]=m);let h=p!==m,g;t[8]!==n.models||t[9]!==i?(g=async e=>{let t=await ct();if(JSON.stringify(t.defaults.models)!==JSON.stringify(n.models))throw Error(i?`模型设置已变化,请刷新后重试。`:`Model settings changed. Refresh before retrying.`);let r=await st({...t.defaults,models:e.models},{scope:`models`,expectedModels:n.models});f(r.defaults),await mt()},t[8]=n.models,t[9]=i,t[10]=g):g=t[10];let _=g,v;t[11]!==h||t[12]!==c||t[13]!==_?(v={value:c,dirty:h,onSave:_,delayMs:0},t[11]=h,t[12]=c,t[13]=_,t[14]=v):v=t[14];let y=Lt(v),b=h||y.status===`saving`||!!y.error,x,S;t[15]!==o||t[16]!==b?(x=()=>(o(b),()=>o(!1)),S=[b,o],t[15]=o,t[16]=b,t[17]=x,t[18]=S):(x=t[17],S=t[18]),(0,Q.useEffect)(x,S);let C=a||y.status===`saving`,w;t[19]!==y.error||t[20]!==y.status?(w=(0,$.jsx)(It,{status:y.status,error:y.error}),t[19]=y.error,t[20]=y.status,t[21]=w):w=t[21];let T;t[22]!==y.error||t[23]!==y.retry||t[24]!==i?(T=y.error?(0,$.jsx)(Z,{variant:`secondary`,onClick:y.retry,children:i?`重试保存`:`Retry saving`}):null,t[22]=y.error,t[23]=y.retry,t[24]=i,t[25]=T):T=t[25];let E;t[26]!==r||t[27]!==c||t[28]!==i?(E=(0,$.jsx)(pr,{capability:r,draft:c,setDraft:l,zh:i}),t[26]=r,t[27]=c,t[28]=i,t[29]=E):E=t[29];let D;return t[30]!==y.onBlurCapture||t[31]!==w||t[32]!==T||t[33]!==E||t[34]!==C?(D=(0,$.jsxs)(`fieldset`,{disabled:C,onBlurCapture:y.onBlurCapture,className:`min-w-0 space-y-3`,children:[w,T,E]}),t[30]=y.onBlurCapture,t[31]=w,t[32]=T,t[33]=E,t[34]=C,t[35]=D):D=t[35],D}function _r(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function vr(e,t){if(e.startsWith(`agentCatalog.defaults.models`))return{label:t?`模型与能力`:`Models and capabilities`,href:`/settings/capabilities/models`};let n=e.match(/^agentCatalog\.agents\.([^.]+)\.models/);return n?.[1]?{label:t?`智能体 ${n[1]}`:`Agent ${n[1]}`,href:ot(n[1])}:e.startsWith(`sessions.`)?{label:t?`会话模型覆盖`:`Session model override`,href:`/settings/sessions`}:{label:e,href:`/settings/agent-defaults`}}function yr(e,t){switch(e){case`computer-use`:return{guidance:t?`选择兼容的电脑控制模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑控制`:`Configure computer use`};case`vision`:return{guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{guidance:t?`选择语音识别服务,或安装自管 STT 插件`:`Choose a speech-to-text service or install a self-managed STT plugin`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}async function br(){let e=await u(d(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}async function xr(){let e=await u(d(`/api/capabilities/readiness`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function Sr({showCapabilities:e=!0,embedded:t=!1}={}){let n=p(e=>e.language)===`zh`,{data:r,error:i,isLoading:a}=Me(ht,br,{revalidateOnFocus:!0,refreshInterval:6e4}),{data:o}=Me(gt,xr,{revalidateOnFocus:!1}),[s,c]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(null),h=Object.values(r?.sources??{}),g=h.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),_=(r?.references??[]).filter(e=>e.availability===`unavailable`),v=r?.sync.lastSuccessAt??Math.max(0,...h.map(e=>e.lastSuccessAt)),y=!!i,b=r?.sync.sourceErrors??{},x=[...r?.sync.lastError?[[`catalog`,r.sync.lastError]]:[],...Object.entries(b),...f?[[`refresh`,f]]:[],...i instanceof Error?[[`load`,i.message]]:[]],S=r?.sync.lastAttemptAt??v,w=Object.entries(o?.capabilities??{}).filter(([e])=>e!==`computer-use`||Ze()),T=w.some(([,e])=>{let t=_r(e);return t===`degraded`||t===`misconfigured`}),E=w.filter(([,e])=>_r(e)===`ready`).length,D=(0,Q.useRef)(null);if((0,Q.useEffect)(()=>{T&&!a&&D.current?.setAttribute(`open`,``)},[T,a]),a)return(0,$.jsx)(X,{className:`h-24 w-full rounded-2xl`});let O=async()=>{c(!0),m(null);try{let e=await u(d(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await mt()}catch(e){m(e instanceof Error?e.message:String(e))}finally{c(!1)}},k=(0,$.jsx)(`div`,{className:`mt-2 space-y-1 rounded-lg bg-surface-base/45 p-2 font-mono text-[11px] leading-5`,"aria-label":n?`同步错误详情`:`Sync error details`,children:x.map(([e,t],n)=>(0,$.jsxs)(`p`,{className:`break-words`,children:[e,`: `,t]},`${e}-${n}`))}),A=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:n?`${h.length} 个来源,${g} 个可用模型${v?` · 最近同步 ${new Date(v).toLocaleString()}`:``}`:`${h.length} sources, ${g} available models${v?` · Last synced ${new Date(v).toLocaleString()}`:``}`}),x.length>0?t?(0,$.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-base/45 p-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer rounded text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`高级诊断`:`Advanced diagnostics`}),k]}):k:null]}),(0,$.jsxs)(Z,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:s,onClick:()=>void O(),children:[s?(0,$.jsx)(J,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Se,{className:`size-4`,"aria-hidden":!0}),s?n?`刷新中…`:`Refreshing…`:n?`刷新目录`:`Refresh catalog`]})]});return(0,$.jsxs)(`section`,{className:t?`mt-4 border-t border-edge-subtle pt-1`:`rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[e?(0,$.jsxs)(`details`,{ref:D,className:`group`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2`,children:[T?(0,$.jsx)(De,{className:`size-4 text-amber-500`,"aria-hidden":!0}):E===w.length&&w.length>0?(0,$.jsx)(F,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(L,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:n?`可选能力`:`Optional capabilities`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-fg-muted`,children:n?`${E}/${w.length} 项已配置,不影响基础聊天功能`:`${E} of ${w.length} configured · Not required for chat`})]}),(0,$.jsx)(j,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]})}),o?(0,$.jsx)(`div`,{className:`mt-3 grid gap-1 sm:grid-cols-2`,children:Object.entries(o.capabilities).map(([e,t])=>{if(e===`computer-use`&&!Ze())return null;let r=e===`vision`?n?`图片理解`:`Vision`:e===`image-generation`?n?`图片生成`:`Image generation`:e===`computer-use`?n?`电脑控制模型`:`Computer use model`:e.toUpperCase(),i=t.selectionSource!==`explicit-config`,a=_r(t),o=a===`degraded`||a===`misconfigured`,s=yr(e,n),c=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-xs font-medium text-fg`,children:r}),(0,$.jsx)(`span`,{className:a===`ready`?`shrink-0 text-xs text-emerald-600 dark:text-emerald-400`:a===`off`||a===`not-configured`?`shrink-0 text-xs text-fg-muted`:`shrink-0 text-xs text-amber-600 dark:text-amber-400`,children:a===`ready`?e===`computer-use`?n?`已配置`:`Configured`:n?`可用`:`Ready`:a===`off`?n?`已关闭`:`Off`:a===`not-configured`?n?`未配置`:`Not configured`:a===`degraded`?n?`正在使用备用方案`:`Using fallback`:n?`需处理`:`Needs attention`})]}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,title:t.primary?`${t.primary.provider}/${t.primary.model}`:void 0,children:t.primary?`${i?n?`自动`:`Auto`:n?`显式`:`Explicit`} · ${t.primary.provider}/${t.primary.model}`:a===`not-configured`?n?`可稍后按需配置`:`Set up later if needed`:n?`已配置的模型不可用`:`The configured model is unavailable`}),o?(0,$.jsxs)(`div`,{className:`mt-2 rounded-lg bg-amber-500/10 p-2`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-amber-700 dark:text-amber-300`,children:t.status===`degraded`?n?`当前配置不可用,正在使用备用方案。${s.guidance}`:`The current configuration is unavailable, so a fallback is in use. ${s.guidance}.`:s.guidance}),(0,$.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent`,children:[s.action,(0,$.jsx)(C,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]}),u={"aria-label":o?`${r}:${s.action}`:`${n?`配置`:`Configure`} ${r}`,className:Y(`rounded-lg bg-surface-base/45 px-3 py-3 text-left transition-colors`,o?`bg-amber-500/5 hover:bg-amber-500/10`:`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`)};if(e===`computer-use`)return(0,$.jsx)(l,{to:`/settings/computer-use`,...u,children:c},e);let d={vision:`vision`,"image-generation":`image`,stt:`transcription`,tts:`speech`}[e];return(0,$.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,...u,onClick:()=>ze(d,o?`services`:`settings`),children:c},e)})}):null]}):null,_.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-2`,"aria-live":`polite`,children:_.map(e=>(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 p-3`,children:(()=>{let t=e.ref.split(`/`)[0]??``,r=!!b[t],i=vr(e.locations[0]??``,n);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(De,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`p`,{className:`break-words text-sm font-medium text-fg`,children:[e.ref,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-amber-700 dark:text-amber-300`,children:r?n?`暂时无法验证`:`Temporarily unverified`:n?`不可用`:`Unavailable`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r?n?`模型目录同步暂时失败,当前状态可能已过期;不会影响其他可用模型。`:`Catalog sync temporarily failed, so this status may be stale. Other available models are unaffected.`:n?`此模型已无法从当前配置中解析,使用它的功能可能失败。`:`This model no longer resolves from the current configuration. Features using it may fail.`,S?` · ${n?`最近检测`:`Last checked`} ${new Date(S).toLocaleString()}`:``]}),e.suggestedRef?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[n?`可替换为`:`Suggested replacement`,`:`,(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.suggestedRef})]}):null]})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:[(0,$.jsxs)(Z,{className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,disabled:s,onClick:()=>void O(),children:[s?(0,$.jsx)(J,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Se,{className:`size-3.5`,"aria-hidden":!0}),s?n?`检测中…`:`Checking…`:n?`重新检测`:`Check again`]}),(0,$.jsx)(Z,{asChild:!0,className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,children:(0,$.jsxs)(l,{to:i.href,children:[(0,$.jsx)(Oe,{className:`size-3.5`,"aria-hidden":!0}),e.suggestedRef?n?`更换模型`:`Replace model`:n?`调整配置`:`Adjust configuration`]})}),(0,$.jsxs)(`details`,{className:`group/references`,children:[(0,$.jsxs)(`summary`,{className:`touch-target inline-flex cursor-pointer list-none items-center gap-1 rounded-xl px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n?`查看 ${e.locations.length} 处引用`:`View ${e.locations.length} ${e.locations.length===1?`reference`:`references`}`,(0,$.jsx)(j,{className:`size-3.5 transition-transform group-open/references:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 pl-2 text-xs text-fg-muted`,children:e.locations.map(e=>{let t=vr(e,n);return(0,$.jsx)(`li`,{children:(0,$.jsx)(l,{className:`inline-flex rounded px-1.5 py-1 text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,to:t.href,title:e,children:t.label})},e)})})]})]})]})})()},e.ref))}):null,y||f?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:y?n?`暂时无法读取模型状态,请重新检测;详细信息可在高级诊断中查看。`:`Model status is temporarily unavailable. Check again; details are available in Advanced diagnostics.`:n?`重新检测失败,请稍后重试;详细信息可在高级诊断中查看。`:`The check failed. Try again later; details are available in Advanced diagnostics.`}):null,t?A:(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`summary`,{className:`min-h-8 cursor-pointer rounded-md py-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`高级诊断`:`Advanced diagnostics`}),A]})]})}function Cr({zh:e,disabled:t,onManage:n}){let{data:r,error:i,mutate:a}=D(),{mutate:o}=je(),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),h=r&&w[r.modelRef],C=h&&r?.configured[h.provider],T=t=>t===`dashscope-cn`?e?`阿里云百炼`:`Alibaba Cloud Bailian`:e?`火山方舟`:`Volcengine Ark`;async function A(e,n){if(t||s)return!1;c(!0),u(``);try{let t=await m(d(k),{method:e,body:JSON.stringify(n)});return await a(t,{revalidate:!1}),o(e=>typeof e==`string`&&e.startsWith(d(`/api/video-generation/sessions/`))),!0}catch(e){return u(e instanceof Error?e.message:String(e)),!1}finally{c(!1)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{"data-capability":`video`,children:(0,$.jsx)(Un,{actionColumn:!0,description:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e?`生成视频`:`Video generation`}),h&&!C&&(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e?`待连接`:`Connection needed`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:e?`文生视频和图生视频`:`Text-to-video and image-to-video`})]}),picker:r&&h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{placeholder:e?`选择模型`:`Choose a model`,ariaLabel:e?`选择视频生成模型`:`Select video generation model`,value:r.modelRef,triggerClassName:`min-h-11`,allowEmpty:!1,disabled:t||s,onChange:e=>{e!==r.modelRef&&A(`PUT`,{modelRef:e})},options:O.map(e=>{let t=w[e];return{value:e,label:t.name,group:T(t.provider)}})}),(0,$.jsx)(Hn,{name:T(h.provider),manageLabel:e?`管理服务`:`Manage services`,onManage:()=>n(h.provider),disabled:t||s}),s&&(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:e?`正在切换…`:`Switching…`}),!f&&l&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:l})]}):i?(0,$.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[e?`视频模型加载失败`:`Could not load video models`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void a(),children:e?`重试`:`Retry`})]}):(0,$.jsx)(X,{className:`h-11 w-full rounded-xl`}),actions:r&&h&&(0,$.jsx)(Z,{variant:`ghost`,className:`min-h-11`,disabled:t||s,onClick:()=>{u(``),p({modelRef:r.modelRef,...r.defaults})},children:e?`设置`:`Settings`})})}),(0,$.jsx)(S,{open:!!f,onOpenChange:e=>{!e&&!s&&(p(null),u(``))},children:(0,$.jsxs)(y,{children:[(0,$.jsx)(g,{className:`fixed inset-0 z-[150] bg-scrim`}),(0,$.jsxs)(b,{className:`fixed left-1/2 top-1/2 z-[151] 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`,children:[(0,$.jsxs)(`header`,{className:`border-b border-edge px-5 py-4`,children:[(0,$.jsx)(x,{className:`font-semibold text-fg`,children:e?`视频生成设置`:`Video generation settings`}),(0,$.jsxs)(_,{className:`mt-1 text-sm text-fg-muted`,children:[f&&w[f.modelRef].name,` · `,e?`新任务的默认参数`:`Defaults for new jobs`]})]}),f&&(0,$.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:async e=>{e.preventDefault(),await A(`PATCH`,f)&&p(null)},children:[(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4 text-sm`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{children:e?`默认时长`:`Default duration`}),(0,$.jsx)(M,{"aria-label":e?`默认时长`:`Default duration`,value:String(f.duration),disabled:s,onChange:e=>p({...f,duration:Number(e.target.value)}),children:E(w[f.modelRef]).map(t=>(0,$.jsx)(N,{value:String(t),children:t===-1?e?`自动`:`Auto`:`${t}s`},t))})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{children:e?`默认分辨率`:`Default resolution`}),(0,$.jsx)(M,{"aria-label":e?`默认分辨率`:`Default resolution`,value:f.resolution,disabled:s,onChange:e=>p({...f,resolution:e.target.value}),children:w[f.modelRef].resolutions.map(e=>(0,$.jsx)(N,{value:e,children:e.toLowerCase()},e))})]}),l&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:l})]}),(0,$.jsxs)(`footer`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-3`,children:[(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,disabled:s,children:e?`取消`:`Cancel`})}),(0,$.jsx)(Z,{type:`submit`,variant:`primary`,disabled:s,children:s?e?`正在保存…`:`Saving…`:e?`保存`:`Save`})]})]})]})]})})]})}function wr(e){let t=(0,Qt.c)(178),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{inlineUse:r,inlineView:i,onViewChange:u,onPendingChange:d}=n,f=i===void 0?`settings`:i,m=p(Or),g=m===`zh`,_;t[2]===m?_=t[3]:(_=h(m),t[2]=m,t[3]=_);let v=_.capabilitiesSettings,{capability:y}=a(),[b,x]=s(),{state:S}=o(),C;t[4]===b?C=t[5]:(C=ft(b.get(`returnTo`)),t[4]=b,t[5]=C);let w=C,[T,E]=(0,Q.useState)(),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),F=j||N||k,[I,ee]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(null),z=G(),te;t[6]===z.cards?te=t[7]:(te=z.cards.some(Dr),t[6]=z.cards,t[7]=te);let B=te,V=Er,ne,re;t[8]!==d||t[9]!==F?(ne=()=>(d?.(F),()=>d?.(!1)),re=[F,d],t[8]=d,t[9]=F,t[10]=ne,t[11]=re):(ne=t[10],re=t[11]),(0,Q.useEffect)(ne,re);let H,U;t[12]!==y||t[13]!==r||t[14]!==S||t[15]!==b||t[16]!==x?(H=()=>{if(r||y!==`models`)return;let e=ut(b.get(`configure`));if(!e&&b.get(`add`)!==`1`)return;let t=window.setTimeout(()=>{e?ze(e,b.get(`tab`)===`services`?`services`:`settings`):ee(!0);let t=new URLSearchParams(b);t.delete(`configure`),t.delete(`tab`),t.delete(`add`),x(t,{replace:!0,state:S})},0);return()=>window.clearTimeout(t)},U=[y,r,b,x,S],t[12]=y,t[13]=r,t[14]=S,t[15]=b,t[16]=x,t[17]=H,t[18]=U):(H=t[17],U=t[18]),(0,Q.useEffect)(H,U);let W;t[19]!==r||t[20]!==u||t[21]!==F?(W=e=>{if(!F){if(!r){ze(e,`services`);return}u?.(`services`),E(void 0)}},t[19]=r,t[20]=u,t[21]=F,t[22]=W):W=t[22];let ie=W,ae;t[23]===u?ae=t[24]:(ae=e=>{V(),u?.(`settings`),E(e)},t[23]=u,t[24]=ae);let K=ae;if(r){let e=f===`services`,n=N||k,i;t[25]!==r||t[26]!==ie||t[27]!==z||t[28]!==n||t[29]!==g?(i=(0,$.jsx)(Kn,{data:z,zh:g,onlyUse:r,disabled:n,onPendingChange:M,onChange:ie}),t[25]=r,t[26]=ie,t[27]=z,t[28]=n,t[29]=g,t[30]=i):i=t[30];let a;t[31]!==e||t[32]!==i?(a=(0,$.jsx)(`div`,{hidden:e,children:i}),t[31]=e,t[32]=i,t[33]=a):a=t[33];let o;t[34]!==T||t[35]!==r||t[36]!==f||t[37]!==g?(o=T===r&&f===`settings`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:g?`服务设置已保存`:`Service settings saved`}):null,t[34]=T,t[35]=r,t[36]=f,t[37]=g,t[38]=o):o=t[38];let s=f!==`services`,c;t[39]!==K||t[40]!==r?(c=()=>K(r),t[39]=K,t[40]=r,t[41]=c):c=t[41];let l;t[42]!==v.addProviderDialog||t[43]!==r||t[44]!==m||t[45]!==z||t[46]!==c?(l=(0,$.jsx)(An,{inline:!0,onEditingChange:O,use:r,data:z,language:m,labels:v.addProviderDialog,onPendingChange:A,onSaved:c},r),t[42]=v.addProviderDialog,t[43]=r,t[44]=m,t[45]=z,t[46]=c,t[47]=l):l=t[47];let d;t[48]!==K||t[49]!==D||t[50]!==r||t[51]!==z.builtinRows||t[52]!==g?(d=r===`transcription`||r===`speech`?(0,$.jsx)(`div`,{hidden:D,children:(0,$.jsx)(Bn,{kind:r===`transcription`?`stt`:`tts`,modelServiceIds:z.builtinRows.map(Tr),zh:g,onPendingChange:A,onSaved:()=>K(r)},r)}):null,t[48]=K,t[49]=D,t[50]=r,t[51]=z.builtinRows,t[52]=g,t[53]=d):d=t[53];let p;t[54]!==D||t[55]!==r||t[56]!==u||t[57]!==g?(p=r===`conversation`&&!D&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`span`,{className:`text-sm text-fg`,children:`Boson AI · Higgs Realtime`}),(0,$.jsx)(Z,{variant:`secondary`,onClick:()=>u?.(`settings`),children:g?`配置 Boson`:`Configure Boson`})]}),t[54]=D,t[55]=r,t[56]=u,t[57]=g,t[58]=p):p=t[58];let h;t[59]!==K||t[60]!==r?(h=r===`image`?(0,$.jsx)(hn,{connectOnly:!0,onPendingChange:A,onConnected:()=>K(r)}):null,t[59]=K,t[60]=r,t[61]=h):h=t[61];let _;t[62]!==k||t[63]!==s||t[64]!==l||t[65]!==d||t[66]!==p||t[67]!==h?(_=(0,$.jsxs)(`fieldset`,{hidden:s,disabled:k,className:`min-w-0 space-y-3`,children:[l,d,p,h]}),t[62]=k,t[63]=s,t[64]=l,t[65]=d,t[66]=p,t[67]=h,t[68]=_):_=t[68];let y=f===`services`,b;t[69]!==k||t[70]!==r||t[71]!==j?(b=r===`transcription`||r===`speech`||r===`conversation`?(0,$.jsx)(Ue,{capability:r,onPendingChange:P,disabled:j||k},r):null,t[69]=k,t[70]=r,t[71]=j,t[72]=b):b=t[72];let x;t[73]!==k||t[74]!==r||t[75]!==j||t[76]!==g?(x=r===`chat`||r===`vision`||r===`image`?(0,$.jsx)(hr,{capability:r,zh:g,disabled:j||k,onPendingChange:P}):null,t[73]=k,t[74]=r,t[75]=j,t[76]=g,t[77]=x):x=t[77];let S;t[78]!==r||t[79]!==g?(S=r===`background`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g?`使用所选模型执行自动化、定时和无人值守任务。此设置不会启用任务,也不会自动改用其他计费服务。`:`Use the selected model for automations, schedules and unattended tasks. This does not enable tasks or automatically switch billing services.`}):null,t[78]=r,t[79]=g,t[80]=S):S=t[80];let C;t[81]!==y||t[82]!==b||t[83]!==x||t[84]!==S?(C=(0,$.jsxs)(`div`,{hidden:y,className:`space-y-4`,children:[b,x,S]}),t[81]=y,t[82]=b,t[83]=x,t[84]=S,t[85]=C):C=t[85];let w;t[86]!==ie||t[87]!==o||t[88]!==_||t[89]!==C?(w=(0,$.jsxs)(He.Provider,{value:ie,children:[o,_,C]}),t[86]=ie,t[87]=o,t[88]=_,t[89]=C,t[90]=w):w=t[90];let E;return t[91]!==a||t[92]!==w?(E=(0,$.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[a,w]}),t[91]=a,t[92]=w,t[93]=E):E=t[93],E}if(y===`search`){let e;t[94]===m?e=t[95]:(e=h(m),t[94]=m,t[95]=e);let n;t[96]===e.nav.settingsSearch?n=t[97]:(n=(0,$.jsx)(Nt,{title:e.nav.settingsSearch}),t[96]=e.nav.settingsSearch,t[97]=n);let r;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(En,{}),t[98]=r):r=t[98];let i;return t[99]===n?i=t[100]:(i=(0,$.jsxs)(Mt,{children:[n,r]}),t[99]=n,t[100]=i),i}if(y!==`models`){let e;return t[101]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(c,{to:`/settings/capabilities/models`,replace:!0}),t[101]=e):e=t[101],e}let se=g?`模型与能力`:`Models and capabilities`,le=g?`按用途选择模型,点击服务商名称管理连接。`:`Choose models by purpose. Select a provider name to manage its connection.`,q;t[102]===m?q=t[103]:(q=Xe(m,`configuration`),t[102]=m,t[103]=q);let ue;t[104]!==v.docsLink||t[105]!==q?(ue=(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(`a`,{href:q,target:`_blank`,rel:`noreferrer`,className:`inline-flex min-h-11 items-center rounded-lg px-2 text-xs text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v.docsLink})}),t[104]=v.docsLink,t[105]=q,t[106]=ue):ue=t[106];let de;t[107]!==se||t[108]!==le||t[109]!==ue?(de=(0,$.jsx)(Nt,{title:se,subtitle:le,actions:ue}),t[107]=se,t[108]=le,t[109]=ue,t[110]=de):de=t[110];let fe;t[111]!==w||t[112]!==g?(fe=w?(0,$.jsx)(l,{to:w,className:`text-sm text-accent-fg hover:underline`,children:w===`/settings/phone-use`?g?`返回手机控制并测试模型`:`Return to phone control and test the model`:g?`返回原来的工作`:`Return to your work`}):null,t[111]=w,t[112]=g,t[113]=fe):fe=t[113];let pe;t[114]!==w||t[115]!==g?(pe=w?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:w===`/settings/phone-use`?g?`正在为手机控制连接模型服务;此处保存服务设置后,还需返回选择并测试手机模型。`:`Connect a model service for phone control, then return to select and test the phone model.`:g?`正在为原来的工作配置模型。服务保存、模型选择和实际运行验证分别生效。`:`Configure models for your work. Saving a service, choosing a model and verifying a run are separate steps.`}):null,t[114]=w,t[115]=g,t[116]=pe):pe=t[116];let me;t[117]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>R({providerId:e,isCustom:!1}),t[117]=me):me=t[117];let he;t[118]!==F||t[119]!==g?(he=(0,$.jsx)(Cr,{zh:g,disabled:F,onManage:me}),t[118]=F,t[119]=g,t[120]=he):he=t[120];let ge;t[121]===F?ge=t[122]:(ge=e=>{F||ze(e)},t[121]=F,t[122]=ge);let _e;t[123]!==ie||t[124]!==z||t[125]!==F||t[126]!==he||t[127]!==ge||t[128]!==g?(_e=(0,$.jsx)(Kn,{data:z,zh:g,videoRow:he,disabled:F,onPendingChange:M,onChange:ie,onSettings:ge}),t[123]=ie,t[124]=z,t[125]=F,t[126]=he,t[127]=ge,t[128]=g,t[129]=_e):_e=t[129];let ve=g?`连接的服务`:`Connected services`,J;t[130]===ve?J=t[131]:(J=(0,$.jsx)(`h2`,{id:`model-services-heading`,className:`text-base font-semibold text-fg`,children:ve}),t[130]=ve,t[131]=J);let ye=g?`在这里管理账户和密钥;各项能力的模型与参数在上方调整。`:`Manage accounts and keys here. Choose models and adjust capability settings above.`,be;t[132]===ye?be=t[133]:(be=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ye}),t[132]=ye,t[133]=be);let xe;t[134]!==J||t[135]!==be?(xe=(0,$.jsxs)(`div`,{children:[J,be]}),t[134]=J,t[135]=be,t[136]=xe):xe=t[136];let Se;t[137]!==v.xopcCloudAccount||t[138]!==B?(Se=B?(0,$.jsx)(Zt,{labels:v.xopcCloudAccount,children:(0,$.jsx)(Sr,{showCapabilities:!1,embedded:!0})}):null,t[137]=v.xopcCloudAccount,t[138]=B,t[139]=Se):Se=t[139];let Ce,we;t[140]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=()=>ee(!0),we=(e,t)=>R({providerId:e,isCustom:t}),t[140]=Ce,t[141]=we):(Ce=t[140],we=t[141]);let Te;t[142]!==v.connectedProviders||t[143]!==z?(Te=(0,$.jsx)(ce,{labels:v.connectedProviders,data:z,onAdd:Ce,onManage:we}),t[142]=v.connectedProviders,t[143]=z,t[144]=Te):Te=t[144];let Ee;t[145]!==B||t[146]!==z.cards.length?(Ee=!B&&z.cards.length>0?(0,$.jsx)(Sr,{showCapabilities:!1}):null,t[145]=B,t[146]=z.cards.length,t[147]=Ee):Ee=t[147];let De;t[148]!==xe||t[149]!==Se||t[150]!==Te||t[151]!==Ee?(De=(0,$.jsxs)(`section`,{"data-model-section":`services`,"aria-labelledby":`model-services-heading`,className:`space-y-4 scroll-mt-4 rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[xe,Se,Te,Ee]}),t[148]=xe,t[149]=Se,t[150]=Te,t[151]=Ee,t[152]=De):De=t[152];let Oe;t[153]!==_e||t[154]!==De||t[155]!==g?(Oe=(0,$.jsxs)(Qn,{zh:g,children:[_e,De]}),t[153]=_e,t[154]=De,t[155]=g,t[156]=Oe):Oe=t[156];let ke;t[157]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>{V(),ee(!1)},t[157]=ke):ke=t[157];let Y;t[158]!==I||t[159]!==v.addProviderDialog||t[160]!==m||t[161]!==z.builtinRows||t[162]!==z.customConfig?(Y=(0,$.jsx)(oe,{open:I,connectOnly:!0,onOpenChange:ee,builtinRows:z.builtinRows,customConfig:z.customConfig,labels:v.addProviderDialog,language:m,onSaved:ke}),t[158]=I,t[159]=v.addProviderDialog,t[160]=m,t[161]=z.builtinRows,t[162]=z.customConfig,t[163]=Y):Y=t[163];let X;t[164]!==v.manageProviderDialog||t[165]!==m||t[166]!==L||t[167]!==z.allModels||t[168]!==z.builtinRows||t[169]!==z.customConfig?(X=L?(0,$.jsx)(or,{open:!0,onOpenChange:e=>{e||R(null)},providerId:L.providerId,isCustom:L.isCustom,builtinRows:z.builtinRows,customConfig:z.customConfig,allModels:z.allModels,labels:v.manageProviderDialog,language:m,onSaved:V}):null,t[164]=v.manageProviderDialog,t[165]=m,t[166]=L,t[167]=z.allModels,t[168]=z.builtinRows,t[169]=z.customConfig,t[170]=X):X=t[170];let Ae;return t[171]!==de||t[172]!==fe||t[173]!==pe||t[174]!==Oe||t[175]!==Y||t[176]!==X?(Ae=(0,$.jsxs)(Mt,{children:[de,fe,pe,Oe,Y,X]}),t[171]=de,t[172]=fe,t[173]=pe,t[174]=Oe,t[175]=Y,t[176]=X,t[177]=Ae):Ae=t[177],Ae}function Tr(e){return e.id}function Er(){mt(),A()}function Dr(e){return e.id===`xopc-cloud`&&!e.isCustom}function Or(e){return e.language}export{wr as CapabilitiesSettingsPanel};
@@ -1 +1 @@
1
- var e=[{label:[`文本`,`Text`],uses:[`chat`]},{label:[`图片`,`Images`],uses:[`vision`,`image`]},{label:[`语音`,`Voice`],uses:[`transcription`,`speech`,`conversation`]},{label:[`后台`,`Background`],uses:[`background`]}],t={chat:[`对话与任务`,`Chat and tasks`],vision:[`看图`,`Image understanding`],image:[`生成图片`,`Image generation`],transcription:[`录音与听写`,`Recording and dictation`],speech:[`文字转语音`,`Text to speech`],conversation:[`实时语音对话`,`Realtime conversation`],background:[`自动与后台任务`,`Background tasks`]};function n(e){return e&&Object.hasOwn(t,e)?e:void 0}function r(e){return e&&!/[\\\r\n]/.test(e)&&(e.startsWith(`/chat/`)||e===`/personal`||e===`/settings/phone-use`||e.startsWith(`/automations`))?e:void 0}function i(e,t){let[n,i]=e.split(`?`),a=new URLSearchParams(i),o=r(t.get(`returnTo`));return o&&a.set(`returnTo`,o),`${n}${a.size?`?${a}`:``}`}export{i as a,n as i,t as n,r,e as t};
1
+ var e=[{label:[`文本`,`Text`],uses:[`chat`]},{label:[`视觉`,`Visual`],uses:[`vision`,`image`]},{label:[`语音`,`Voice`],uses:[`transcription`,`speech`,`conversation`]},{label:[`后台`,`Background`],uses:[`background`]}],t={chat:[`对话与任务`,`Chat and tasks`],vision:[`看图`,`Image understanding`],image:[`生成图片`,`Image generation`],transcription:[`录音与听写`,`Recording and dictation`],speech:[`文字转语音`,`Text to speech`],conversation:[`实时语音对话`,`Realtime conversation`],background:[`自动与后台任务`,`Background tasks`]};function n(e){return e&&Object.hasOwn(t,e)?e:void 0}function r(e){return e&&!/[\\\r\n]/.test(e)&&(e.startsWith(`/chat/`)||e===`/personal`||e===`/settings/phone-use`||e.startsWith(`/automations`))?e:void 0}function i(e,t){let[n,i]=e.split(`?`),a=new URLSearchParams(i),o=r(t.get(`returnTo`));return o&&a.set(`returnTo`,o),`${n}${a.size?`?${a}`:``}`}export{i as a,n as i,t as n,r,e as t};
@@ -0,0 +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{u as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a,i as o,l as s,n as c,o as l}from"./locale-store-DIBIYLnI.js";import{t as u}from"./messages-BDBGlBKh.js";import{a 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{s as v,t as y}from"./popover-select-CLsphyzA.js";import{t as b}from"./circle-alert-BEjgurr2.js";import{t as x}from"./circle-check-C23XjkUj.js";import{t as S}from"./external-link-DjqjBmc3.js";import{t as C}from"./key-round-DWbpyU2U.js";import{t as w}from"./loader-circle-CifKLtgG.js";import{i as T,n as E,r as D,t as O}from"./channels-routes-r2g-9DdC.js";import{t as k}from"./rotate-ccw-JM1TBLpp.js";import{t as A}from"./settings-2-D-csvaET.js";import{t as j}from"./settings-uiTATseT.js";import{t as M}from"./stethoscope-DRqTAtjD.js";import{t as N}from"./triangle-alert-2JXFNNKU.js";import{t as P}from"./x-B_N4OPjy.js";import{t as F}from"./cn-0WouolD0.js";import{t as I}from"./skeleton-DzdOeGYz.js";import{t as L}from"./session-channel-icon-COynhpeK.js";import{i as R}from"./vendor-swr-CdRzEUwF.js";import{t as z}from"./chat-agents-api-BksS0CNy.js";import{t as B}from"./button-Cc4hUNTt.js";import{i as V,o as H}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as ee}from"./copy-to-clipboard-HOJ79TWv.js";import{t as te}from"./interaction-BdhHBbYa.js";import{n as ne}from"./secret-input-labels-B5Jl5HqK.js";import{i as re}from"./navigation-ByOzYT0t.js";import{t as U}from"./agent-avatar-display-BO1bqKlR.js";import{n as ie}from"./agent-display-names-Bje7vfSn.js";import{t as W}from"./refresh-button-DiWdGAaX.js";import{t as ae}from"./extension-iframe-host-CjfRKtQ4.js";import{n as oe}from"./settings-loading-skeleton-CAoOV17i.js";import{t as se}from"./browser-BLJWD7WI.js";import{t as ce}from"./settings-advanced-section-CnGJr2xp.js";import{n as le}from"./settings-page-header-wL2jvs-y.js";import"./settings-page-layout-BkUQVmyY.js";import{n as ue,t as de}from"./schema-form-DXHzZPMr.js";var G=n(),K=r();function fe(e){let t=(0,G.c)(18),{language:n}=e,r=n===`zh`,i=r?`Telegram 接入步骤`:`Telegram setup steps`,a=r?`连接 Telegram 机器人`:`Connect a Telegram bot`,o;t[0]===a?o=t[1]:(o=(0,K.jsx)(`h3`,{className:`font-medium text-fg`,children:a}),t[0]=a,t[1]=o);let s=r?`在 Telegram 打开 `:`Open `,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,K.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noreferrer`,className:`text-accent hover:underline`,children:`@BotFather`}),t[2]=c):c=t[2];let l=r?`,发送 /newbot 创建机器人并获取 Bot Token。请勿把 Token 发给其他人。`:` in Telegram. Send /newbot to create a bot and obtain its token. Keep the token private.`,u;t[3]!==s||t[4]!==l?(u=(0,K.jsxs)(`li`,{children:[s,c,l]}),t[3]=s,t[4]=l,t[5]=u):u=t[5];let d=r?`在 xopc 粘贴 Bot Token,再扫码或点击链接打开机器人。`:`Paste the bot token in xopc, then scan the QR code or open the link.`,f;t[6]===d?f=t[7]:(f=(0,K.jsx)(`li`,{children:d}),t[6]=d,t[7]=f);let p=r?`在 Telegram 点击开始,收到回复后回到 xopc 确认本人。`:`Tap Start in Telegram. After the bot replies, confirm your account in xopc.`,m;t[8]===p?m=t[9]:(m=(0,K.jsx)(`li`,{children:p}),t[8]=p,t[9]=m);let h;t[10]!==m||t[11]!==u||t[12]!==f?(h=(0,K.jsxs)(`ol`,{className:`mt-2 list-decimal space-y-2 pl-5 text-fg-muted`,children:[u,f,m]}),t[10]=m,t[11]=u,t[12]=f,t[13]=h):h=t[13];let g;return t[14]!==i||t[15]!==h||t[16]!==o?(g=(0,K.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4 text-sm`,"aria-label":i,children:[o,h]}),t[14]=i,t[15]=h,t[16]=o,t[17]=g):g=t[17],g}var q=e(t(),1);async function pe(){return(await l(o(`/api/channels/status`))).payload?.channels||[]}function me(){return o(`/api/channels/status`)}var he=pe;function ge(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var _e=e(se(),1);function ve(e){return e.type!==`qr`||!e.statusAction?null:{actionId:e.statusAction,conversationId:e.conversationId,accountId:e.accountId,cancelAction:e.cancelAction,intervalMs:Math.max(1e3,e.pollIntervalMs??2500)}}async function J(e){let t=await a(o(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function Y(e){return e?.type===`poll`&&e.phase!==`pending`}function ye(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function be(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function X(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function xe({entry:e,locale:t,messages:n,onChanged:r,onStarted:i,compact:a=!1,quick:o=!1}){let s=t.toLowerCase().startsWith(`zh`),[c,l]=(0,q.useState)(`feishu`),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(!1),m=(0,q.useMemo)(()=>ge(e),[e]),h=(0,q.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[g,_]=(0,q.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null}),v=(0,q.useRef)(!1),y=(0,q.useRef)(!1),b=(0,q.useRef)(null),E=(0,q.useCallback)(async n=>{n?.cancelAction&&await J({channelId:e.id,actionId:n.cancelAction,locale:t,accountId:n.accountId,input:{conversationId:n.conversationId}})},[e.id,t]);(0,q.useEffect)(()=>(y.current=!0,()=>{y.current=!1}),[]),(0,q.useEffect)(()=>{if(o)return()=>{E(b.current).catch(()=>{})}},[E,o]);let D=(0,q.useCallback)(async(n,i,a,s=!1)=>{_(e=>({...e,busy:!0,error:null,...s?{payload:null,poll:null}:{}}));try{if(s){let e=b.current;b.current=null,await E(e).catch(()=>{})}p(!1);let c=await J({channelId:e.id,actionId:n,locale:t,input:i,accountId:a}),l=ve(c);if(!y.current){o&&E(l).catch(()=>{}),`configChanged`in c&&c.configChanged===!0&&await r();return}(l||c.type!==`poll`||c.phase!==`pending`)&&(b.current=l),_(e=>({...e,payload:c,poll:l??(c.type===`poll`&&c.phase===`pending`?e.poll:null),busy:!1,formDraft:c.type===`form`?c.values??{}:{}})),`configChanged`in c&&c.configChanged===!0&&await r()}catch(e){y.current&&_(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[E,e.id,t,r,o]),O=(t=c,n=!1)=>{m&&(i?.(),D(m[0],e.id===`feishu`?{domain:t}:void 0,void 0,n))},k=m?.[0];(0,q.useEffect)(()=>{!o||!k||v.current||(v.current=!0,D(k,e.id===`feishu`?{domain:`feishu`}:void 0))},[e.id,k,o,D]);let A=be(g.payload,e.id);(0,q.useEffect)(()=>{let e=A;if(!e){_(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let t=!1;return _(e=>e.generatedQr?{...e,generatedQr:null}:e),_e.toDataURL(e,{width:220,margin:1}).then(e=>{t||_(t=>({...t,generatedQr:e}))}).catch(()=>{t||_(e=>({...e,error:n.failed}))}),()=>{t=!0}},[n.failed,A]),(0,q.useEffect)(()=>{let n=g.poll;if(!n||g.busy)return;let i=!1,a,s=async()=>{try{let a=await J({channelId:e.id,actionId:n.actionId,accountId:n.accountId,locale:t,input:{conversationId:n.conversationId}}),s=ve(a);if(i){o&&!y.current&&E(s).catch(()=>{}),`configChanged`in a&&a.configChanged===!0&&await r();return}if((s||Y(a))&&(b.current=s),_(e=>({...e,payload:a.type===`poll`&&a.phase===`pending`&&e.payload?.type===`qr`?{...e.payload,...a,pinAction:a.pinAction,type:`qr`}:a,poll:s??(Y(a)?null:e.poll),error:null})),`configChanged`in a&&a.configChanged===!0&&await r(),s||Y(a))return}catch(e){i||_(t=>({...t,error:e instanceof Error?e.message:String(e)}))}i||(a=window.setTimeout(()=>void s(),n.intervalMs))};return a=window.setTimeout(()=>void s(),n.intervalMs),()=>{i=!0,window.clearTimeout(a)}},[E,e.id,t,r,o,g.busy,g.poll]);let j=m?.[1].label??(e.configured?n.reconnect:n.connect),N=e.actions?.[`doctor.run`]?.label??n.diagnose,P=ye(g.payload),L=A?g.generatedQr:X(g.payload),R=g.payload?.type===`qr`?g.payload.verificationCode:void 0,z=g.payload?.type===`qr`?g.payload.botName:void 0,V=g.payload?.type===`qr`?g.payload.setupHint:void 0,H=g.payload?.type===`poll`?g.payload.confirmAction:void 0,te=g.payload&&`pinAction`in g.payload&&typeof g.payload.pinAction==`string`?g.payload.pinAction:void 0,ne=!!(!te&&(A||L)),re=()=>{let e=g.poll;e?.cancelAction&&(d(``),D(e.cancelAction,{conversationId:e.conversationId},e.accountId))},U=g.payload?.type===`form`?g.payload:null,ie=g.payload?.type===`ok`||g.payload?.type===`form`?g.payload.setupLink:void 0,W=U?.schema,ae=Array.isArray(W?.required)?W.required.filter(e=>typeof e==`string`):[],oe=W?.properties,se=W&&o&&oe&&ae.length>0?{...W,properties:Object.fromEntries([...ae,...e.id===`feishu`?[`domain`]:[]].filter(e=>Object.hasOwn(oe,e)).map((e,t)=>[e,{...oe[e],"x-order":t}]))}:W,ce=g.payload?.type===`ok`&&g.payload.configChanged===!0,le=g.payload?.type===`poll`&&g.payload.phase===`done`&&g.payload.ok,G=e.actions?.[`setup.manual`]&&m?.[0]!==`setup.manual`&&!U&&!ce&&!le&&(!g.poll||o&&g.poll.actionId===`setup.status`),fe=!g.poll&&!U&&!!(g.error||Y(g.payload))&&!le,pe=e.id===`feishu`?c===`lark`?`Lark`:s?`飞书`:`Feishu`:e.label,me=ae.some(e=>{let t=g.formDraft[e];return t==null||typeof t==`string`&&!t.trim()}),he=g.payload?.type===`diagnostics`?g.payload.checks:null;return(0,K.jsxs)(`div`,{className:a||o?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,K.jsxs)(`div`,{className:F(`flex flex-wrap items-start gap-3`,a||o?`justify-end`:`justify-between`),children:[!a&&!o?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}):null,(0,K.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[e.id===`feishu`&&(o?!U&&!ce&&!le&&(!g.poll||g.poll.actionId===`setup.status`):!g.poll)?(0,K.jsx)(ue,{label:s?`平台`:`Platform`,value:c,disabled:g.busy,onChange:e=>{l(e),o&&O(e,!0)},options:[{value:`feishu`,label:s?`飞书`:`Feishu`},{value:`lark`,label:`Lark`}]}):null,m&&(o?fe:!g.poll)?(0,K.jsxs)(B,{type:`button`,variant:`primary`,disabled:g.busy,onClick:()=>O(c,o),children:[g.busy?(0,K.jsx)(w,{className:`size-4 animate-spin`}):m[1].result===`qr`?(0,K.jsx)(T,{className:`size-4`}):(0,K.jsx)(C,{className:`size-4`}),o?m[1].result===`qr`?n.newSetupCode:n.retry:j]}):null,!o&&G?(0,K.jsx)(B,{type:`button`,variant:`secondary`,disabled:g.busy,onClick:()=>{i?.(),D(`setup.manual`,e.id===`feishu`?{domain:c}:void 0)},children:e.actions?.[`setup.manual`]?.label}):null,!o&&g.poll?.cancelAction?(0,K.jsx)(B,{type:`button`,variant:`secondary`,disabled:g.busy,onClick:re,children:s?`取消`:`Cancel`}):null,!o&&e.actions?.[`doctor.run`]&&!g.poll?(0,K.jsxs)(B,{type:`button`,variant:`secondary`,disabled:g.busy,onClick:()=>void D(`doctor.run`),children:[(0,K.jsx)(M,{className:`size-4`}),N]}):null]})]}),o&&!g.payload&&(g.busy||!g.error)?(0,K.jsx)(`div`,{className:`flex justify-center`,"aria-busy":`true`,role:`status`,"aria-label":n.loading,children:(0,K.jsx)(I,{className:m?.[1].result===`qr`?`size-52 rounded-lg`:`h-24 w-full rounded-lg`})}):null,P&&!(o&&(U?.setupTemplate||ne&&m?.[1].result===`qr`&&g.poll?.actionId!==`setup.verify.status`))&&(!Y(g.payload)||H)?(0,K.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:P}):null,ie?(0,K.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-sm text-accent hover:underline`,href:ie.url,target:`_blank`,rel:`noreferrer`,children:[ie.label,(0,K.jsx)(S,{className:`size-3.5`})]}):null,z?(0,K.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:z}):null,R?(0,K.jsx)(`code`,{className:`mt-2 block select-all break-all rounded-md bg-surface-base p-2 text-sm`,children:R}):null,V?(0,K.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:V}):null,te&&g.poll?(0,K.jsxs)(`form`,{className:`mt-3 flex items-end gap-2`,onSubmit:e=>{e.preventDefault(),g.poll&&(D(te,{conversationId:g.poll.conversationId,code:u},g.poll.accountId),d(``))},children:[(0,K.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[s?`微信验证码`:`WeChat verification code`,(0,K.jsx)(`input`,{className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2`,inputMode:`numeric`,autoComplete:`one-time-code`,value:u,onChange:e=>d(e.target.value)})]}),(0,K.jsx)(B,{type:`submit`,disabled:g.busy||!/^\d{4,8}$/.test(u),children:s?`提交`:`Submit`})]}):null,H&&g.payload?.type===`poll`?(0,K.jsx)(B,{type:`button`,className:`mt-3`,disabled:g.busy,onClick:()=>{let e=g.payload;e?.type===`poll`&&D(H,{conversationId:e.conversationId},e.accountId)},children:s?`确认连接`:`Confirm connection`}):null,g.error?(0,K.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:g.error}):null,ne?(0,K.jsxs)(`div`,{className:F(`flex items-center justify-center gap-4 rounded-lg bg-surface-base p-3 shadow-surface`,o?`flex-col text-center`:`mt-4 flex-col sm:flex-row`,a&&!o&&`mt-1 text-center sm:text-left`),children:[(0,K.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:L?(0,K.jsx)(`img`,{src:L,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,K.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,K.jsx)(I,{className:`size-48 rounded-md`})})}),(0,K.jsxs)(`div`,{className:F(`min-w-0 max-w-sm text-sm text-fg-muted`,a&&`w-full sm:w-auto`),children:[L?(0,K.jsx)(`p`,{className:`line-clamp-3`,children:o&&g.poll?.actionId!==`setup.verify.status`?n.scanLoginHint.replace(`{{channel}}`,pe):n.waitingConfirmation}):(0,K.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,K.jsx)(I,{className:`h-4 w-48 max-w-full`}),(0,K.jsx)(I,{className:`h-4 w-36 max-w-full`})]}),A?(0,K.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:A,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,K.jsx)(S,{className:`size-3.5`})]}):null]})]}):null,g.payload?.type===`poll`&&Y(g.payload)&&!H?(0,K.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,K.jsx)(x,{className:g.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,K.jsx)(`span`,{className:g.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:g.payload.message??(g.payload.ok?n.complete:n.failed)})]}):null,U?(0,K.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,K.jsx)(de,{schema:se??U.schema,values:g.formDraft,onChange:e=>_(t=>({...t,formDraft:e})),disabled:g.busy,labels:h}),U.setupTemplate?(0,K.jsxs)(`details`,{open:!o||void 0,className:`space-y-2`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent`,children:n.howToGetCredentials}),o&&P?(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:P}):null,(0,K.jsx)(`textarea`,{readOnly:!0,"aria-label":`App Manifest`,value:U.setupTemplate.content,className:`h-28 w-full resize-y rounded-md border border-edge bg-surface-base p-2 font-mono text-xs text-fg`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,K.jsx)(B,{type:`button`,variant:`secondary`,onClick:async()=>{let e=U.setupTemplate;e&&p(await ee(e.content))},children:f?s?`已复制`:`Copied`:s?`复制 App Manifest`:`Copy App Manifest`}),(0,K.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-sm text-accent hover:underline`,href:U.setupTemplate.url,target:`_blank`,rel:`noreferrer`,children:[s?`打开 Slack 应用管理`:`Open Slack apps`,(0,K.jsx)(S,{className:`size-3.5`})]})]})]}):null,(0,K.jsx)(B,{type:`button`,variant:`primary`,disabled:g.busy||me,onClick:()=>void D(U.submitAction,g.formDraft),children:o?n.verifyAndConnect:n.saveSetup})]}):null,o&&G?(0,K.jsx)(B,{type:`button`,variant:`ghost`,className:`min-h-11`,disabled:g.busy,onClick:()=>void D(`setup.manual`,e.id===`feishu`?{domain:c}:void 0,void 0,!0),children:n.useSetupCredentials}):null,o&&U&&m?.[1].result===`qr`?(0,K.jsx)(B,{type:`button`,variant:`ghost`,className:`min-h-11`,disabled:g.busy,onClick:()=>O(c,!0),children:n.scanToConnect}):null,o&&ce?(0,K.jsxs)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:[n.setupSaved,` `,n.testMessageHint]}):null,he?(0,K.jsx)(`div`,{className:`mt-4 space-y-2`,children:he.map((e,t)=>(0,K.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,K.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,K.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var Se=40;function Ce(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function we(e,t){return e.find(e=>e.id===Ce(t))?.agentId?.trim().toLowerCase()??``}function Te(e,t,n){let r=Ce(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:Se,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function Ee(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function De(e,t,n){let r=Ee(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Oe(e,t=!1,n=!1){return e===`drawer`?F(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,V):F(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,n&&`h-[min(calc(100dvh-2rem),32rem)] w-[min(calc(100%-2rem),28rem)]`,V,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function ke(e){let t=(0,G.c)(34),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:u,footer:y,wide:b,compact:x,headerExtra:S}=e,C=b!==void 0&&b,w=x!==void 0&&x,T=n===`drawer`,[E,D]=(0,q.useState)(null),O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,K.jsx)(d,{className:F(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,H)}),t[0]=O):O=t[0];let k;t[1]!==w||t[2]!==n||t[3]!==C?(k=Oe(n,C,w),t[1]=w,t[2]=n,t[3]=C,t[4]=k):k=t[4];let A;t[5]===s?A=t[6]:(A=s?(0,K.jsx)(g,{className:`sr-only`,children:s}):null,t[5]=s,t[6]=A);let j;t[7]===c?j=t[8]:(j=c?(0,K.jsx)(f,{className:`sr-only`,children:c}):null,t[7]=c,t[8]=j);let M;t[9]!==l||t[10]!==o||t[11]!==S||t[12]!==T||t[13]!==a?(M=T?(0,K.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,K.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,K.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,K.jsx)(p,{asChild:!0,children:(0,K.jsx)(B,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,K.jsx)(P,{className:`size-5`,strokeWidth:1.75})})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(p,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,className:F(te,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,K.jsx)(P,{className:`size-4`})})}),S]}),t[9]=l,t[10]=o,t[11]=S,t[12]=T,t[13]=a,t[14]=M):M=t[14];let N=T?`p-4`:`p-6`,I;t[15]===N?I=t[16]:(I=F(`min-h-0 flex-1 overflow-y-auto`,N),t[15]=N,t[16]=I);let L;t[17]!==u||t[18]!==I?(L=(0,K.jsx)(`div`,{className:I,children:u}),t[17]=u,t[18]=I,t[19]=L):L=t[19];let R;t[20]!==y||t[21]!==E||t[22]!==L||t[23]!==A||t[24]!==j||t[25]!==M?(R=(0,K.jsxs)(v,{layer:`modal`,portalContainer:E,children:[A,j,M,L,y]}),t[20]=y,t[21]=E,t[22]=L,t[23]=A,t[24]=j,t[25]=M,t[26]=R):R=t[26];let z;t[27]!==R||t[28]!==k?(z=(0,K.jsxs)(m,{children:[O,(0,K.jsx)(h,{ref:D,className:k,onOpenAutoFocus:Ae,children:R})]}),t[27]=R,t[28]=k,t[29]=z):z=t[29];let V;return t[30]!==i||t[31]!==r||t[32]!==z?(V=(0,K.jsx)(_,{open:r,onOpenChange:i,children:z}),t[30]=i,t[31]=r,t[32]=z,t[33]=V):V=t[33],V}function Ae(e){return e.preventDefault()}var je=(0,q.memo)(function(e){let t=(0,G.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,K.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,K.jsx)(W,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,K.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Me(e){let t=(0,G.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0||c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,K.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,K.jsx)(B,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,K.jsx)(B,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,K.jsx)(B,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,K.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,K.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-overlay px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Ne(e){return o(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Pe(e){return(await l(Ne(e))).payload?.channels??[]}function Fe(e,t){let n=(0,G.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Ne(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Pe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=R(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ie=`channels-status`;function Le(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Re(e){let t=t=>e(t.detail);return window.addEventListener(Ie,t),()=>window.removeEventListener(Ie,t)}function ze(e,t){let n=(0,G.c)(4),r=t===void 0||t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Re(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,q.useEffect)(i,a)}function Be(e){return e?o(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Ve(e){return(await l(o(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var He=[`enabled`],Ue=`max-w-7xl`,We=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Ge(){return{bindings:(await l(o(`/api/config`))).payload?.config?.bindings??[]}}function Ke(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function qe(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Z(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Je(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ye(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Xe(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`}function Ze(e){if(!e)return[];let t=e.uiHints??{},n=Q(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Z(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=new Set([`dmPolicy`,`groupPolicy`,`allowFrom`,`groupAllowFrom`]),a=[...Object.keys(t).filter(e=>!e.includes(`*`)&&i.has(e.split(`.`).at(-1)??``)),...Object.keys(Q(e.configSchema?.properties)?e.configSchema.properties:{}).filter(e=>i.has(e))],o=Object.entries(t).filter(([,e])=>!Q(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!He.includes(e));return Array.from(new Set([...o,...a,...n,...r])).filter(e=>!He.includes(e))}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Qe(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function $e(e,t){let n={...Qe(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Q(r)||!Q(r[n]))break;let o=Q(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Qe(r[n]),properties:{}}),e===t.length-1){o[n]=Qe(r[n]);break}i=r[n],a=o[n]}}return n}function et(e){let t=e.properties;if(!Q(t))return!1;for(let[e,n]of Object.entries(t))Q(n)&&n.type===`object`&&et(n)&&delete t[e];return Object.keys(t).length===0}function tt(e,t){let n=Qe(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Q(i))break;if(e===t.length-1){delete i[n];break}if(!Q(i[n]))break;r=i[n]}}return et(n),n}function nt(e){return e.type===`object`&&Q(e.properties)&&Object.keys(e.properties).length>0}function rt(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function it({entry:e}){let[t,n]=(0,q.useState)(!1),r=(0,q.useMemo)(()=>!e.ui?.icon||t?null:new URL(o(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Ke(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,K.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,K.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,K.jsx)(L,{sourceChannel:e.id,className:`size-7`})})}function at(e){let t=(0,G.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=F(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=F(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,K.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,K.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function ot(e){let t=(0,G.c)(45),{entry:n,runtime:r,busy:i,restarting:a,ch:o,onOpen:s,onSettings:c,onToggle:l,onRestart:u}=e,d=(0,q.useId)(),f=ge(n),p=r===`disabled`?o.enableChannel:r===`stopped`?o.restartChannel:r===`running`?o.testMessage:f?.[1].result===`qr`?o.scanToConnect:o.connect,m=i||a||r===`checking`,h;t[0]!==i||t[1]!==o||t[2]!==a||t[3]!==r?(h=a?o.restartingChannel:i?o.enablingChannel:r===`needs_setup`?o.pendingSetup:r===`running`?o.connected:Je(r,o),t[0]=i,t[1]=o,t[2]=a,t[3]=r,t[4]=h):h=t[4];let g=h,_;t[5]!==o.channelSettingsLabel||t[6]!==n.label?(_=o.channelSettingsLabel.replace(`{{channel}}`,n.label),t[5]=o.channelSettingsLabel,t[6]=n.label,t[7]=_):_=t[7];let v=_,y=!m&&`hover:bg-surface-hover dark:hover:bg-surface-hover`,b;t[8]===y?b=t[9]:(b=F(`relative flex items-start justify-between gap-2 rounded-2xl bg-surface-inset p-4 transition-colors dark:bg-surface-overlay`,y),t[8]=y,t[9]=b);let x=`${n.label} · ${p}`,S=m?void 0:p,C=r===`disabled`?l:r===`stopped`?u:s,T;t[10]!==m||t[11]!==d||t[12]!==x||t[13]!==S||t[14]!==C?(T=(0,K.jsx)(`button`,{type:`button`,className:`absolute inset-0 cursor-pointer rounded-2xl focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent disabled:cursor-default`,"aria-label":x,"aria-describedby":d,title:S,onClick:C,disabled:m}),t[10]=m,t[11]=d,t[12]=x,t[13]=S,t[14]=C,t[15]=T):T=t[15];let E;t[16]===n?E=t[17]:(E=(0,K.jsx)(it,{entry:n}),t[16]=n,t[17]=E);let D;t[18]===n.label?D=t[19]:(D=(0,K.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[18]=n.label,t[19]=D);let O;t[20]!==m||t[21]!==r?(O=F(`mt-1 inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium`,Xe(m?`checking`:r)),t[20]=m,t[21]=r,t[22]=O):O=t[22];let k;t[23]===m?k=t[24]:(k=m?(0,K.jsx)(w,{"aria-hidden":!0,className:`size-3 shrink-0 motion-safe:animate-spin`}):null,t[23]=m,t[24]=k);let A;t[25]!==g||t[26]!==d||t[27]!==O||t[28]!==k?(A=(0,K.jsxs)(`span`,{id:d,className:O,children:[k,g]}),t[25]=g,t[26]=d,t[27]=O,t[28]=k,t[29]=A):A=t[29];let M;t[30]!==D||t[31]!==A?(M=(0,K.jsxs)(`div`,{className:`min-w-0`,children:[D,A]}),t[30]=D,t[31]=A,t[32]=M):M=t[32];let N;t[33]!==M||t[34]!==E?(N=(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[E,M]}),t[33]=M,t[34]=E,t[35]=N):N=t[35];let P;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,K.jsx)(j,{className:`size-4`}),t[36]=P):P=t[36];let I;t[37]!==c||t[38]!==v?(I=(0,K.jsx)(B,{type:`button`,variant:`ghost`,className:`relative size-11 shrink-0 p-0`,"aria-label":v,title:v,onClick:c,children:P}),t[37]=c,t[38]=v,t[39]=I):I=t[39];let L;return t[40]!==N||t[41]!==I||t[42]!==b||t[43]!==T?(L=(0,K.jsxs)(`article`,{className:b,children:[T,N,I]}),t[40]=N,t[41]=I,t[42]=b,t[43]=T,t[44]=L):L=t[44],L}function st(e){let t=(0,G.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:s,onRestart:c,onCheck:l,onManageConnection:u}=e,d=n===`running`?x:n===`stopped`||n===`needs_setup`?b:w,f=n===`running`&&`text-emerald-600 dark:text-emerald-400`,p=n===`stopped`&&`text-red-600 dark:text-red-400`,m=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,h=n===`disabled`&&`text-fg-muted`,g=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,_;t[0]!==f||t[1]!==p||t[2]!==m||t[3]!==h||t[4]!==g?(_=F(`mt-0.5 size-5 shrink-0`,f,p,m,h,g),t[0]=f,t[1]=p,t[2]=m,t[3]=h,t[4]=g,t[5]=_):_=t[5];let v;t[6]!==d||t[7]!==_?(v=(0,K.jsx)(d,{className:_}),t[6]=d,t[7]=_,t[8]=v):v=t[8];let y;t[9]===s.connectionStatus?y=t[10]:(y=(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectionStatus}),t[9]=s.connectionStatus,t[10]=y);let S;t[11]!==s||t[12]!==n?(S=Ye(n,s),t[11]=s,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,K.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let T;t[16]!==C||t[17]!==y?(T=(0,K.jsxs)(`div`,{children:[y,C]}),t[16]=C,t[17]=y,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==v?(E=(0,K.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[v,T]}),t[19]=T,t[20]=v,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,K.jsx)(w,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let A=i?s.checkingConnection:s.checkConnection,j;t[24]!==l||t[25]!==D||t[26]!==O||t[27]!==A?(j=(0,K.jsxs)(B,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:l,children:[O,A]}),t[24]=l,t[25]=D,t[26]=O,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==s.restartChannel||t[30]!==s.restartingChannel||t[31]!==i||t[32]!==c||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,K.jsxs)(B,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:c,children:[r?(0,K.jsx)(w,{className:`size-4 animate-spin`}):(0,K.jsx)(k,{className:`size-4`}),r?s.restartingChannel:s.restartChannel]}):null,t[29]=s.restartChannel,t[30]=s.restartingChannel,t[31]=i,t[32]=c,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==o||t[37]!==s.connectionOptions||t[38]!==s.hideConnectionOptions||t[39]!==i||t[40]!==u||t[41]!==r||t[42]!==a?(N=o?(0,K.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:u,children:a?s.hideConnectionOptions:s.connectionOptions}):null,t[36]=o,t[37]=s.connectionOptions,t[38]=s.hideConnectionOptions,t[39]=i,t[40]=u,t[41]=r,t[42]=a,t[43]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let I;return t[48]!==E||t[49]!==P?(I=(0,K.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,P]})}),t[48]=E,t[49]=P,t[50]=I):I=t[50],I}function ct(e){let t=(0,G.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Z(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,K.jsx)(N,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,K.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,K.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,K.jsx)(`li`,{children:rt(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,K.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,K.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,K.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,K.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function lt({channelId:e,onHeaderActionChange:t}){let n=c(e=>e.language),r=u(n),l=s(e=>!!e.conversationId),d=i(),f=D(e),p=Fe(l,n),m=p.mutate,h=p.entries,{data:g,mutate:_,isValidating:v}=R(l?me():null,he,{revalidateOnFocus:!0}),{data:b,mutate:x}=R(l?`channels-config-map`:null,Ge,{revalidateOnFocus:!1}),C=b?.bindings??[],{data:w}=R(l?`channel-routing-agents`:null,z,{revalidateOnFocus:!1}),T=(0,q.useMemo)(()=>h.find(e=>e.id===f),[f,h]),k=T?qe(T):null,{data:M,mutate:N}=R(l&&k?Be(k):null,()=>Ve(k)),[P,I]=(0,q.useState)(null),L=h.find(e=>e.id===P?.id),[V,H]=(0,q.useState)(null),[ee,te]=(0,q.useState)(!1),[W,se]=(0,q.useState)(null),[ue,G]=(0,q.useState)(null),[pe,_e]=(0,q.useState)(!1),[ve,J]=(0,q.useState)(null),[Y,ye]=(0,q.useState)(null),be=V??M??{},X=r.channelsSettings,Se=(0,q.useMemo)(()=>T?.configSchema??{type:`object`,properties:{}},[T?.configSchema]),Ce=(0,q.useMemo)(()=>tt(Se,He),[Se]),Ee=(0,q.useMemo)(()=>Ze(T),[T]),Oe=(0,q.useMemo)(()=>T?.id===`telegram`?ut($e(Ce,Ee)):$e(Ce,Ee),[T?.id,Ee,Ce]),Ae=(0,q.useMemo)(()=>tt(Ce,Ee),[T?.id,Ee,Ce]),Ne=(0,q.useMemo)(()=>nt(Oe),[Oe]),Pe=T?Y??we(C,T.id):``,Ie=(0,q.useMemo)(()=>(w?.items??[]).map(e=>({value:e.id,label:ie(e,r.agentsSettings),icon:(0,K.jsx)(U,{agentId:e.id,avatar:e.avatar,size:20})})),[w?.items,r.agentsSettings]),Re=w?.items.find(e=>e.id===w.defaultId),Ke=Re?ie(Re,r.agentsSettings):w?.defaultId??``,Ye=Ke?X.agentRoutingDefault.replace(`{{agent}}`,Ke):X.agentRoutingSelect,Q=(0,q.useMemo)(()=>({secretInputLabels:ne(X),defaultBooleanLabel:X.schemaBooleanDefault,unsupportedArrayType:X.schemaUnsupportedArrayType,arrayAddPlaceholder:X.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>X.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[X]),Qe=(0,q.useMemo)(()=>new Map((g??[]).map(e=>[e.name,e])),[g]),et=g!==void 0,rt=(0,q.useCallback)(e=>De(e,Qe.get(e.id),et),[Qe,et]),lt=(0,q.useCallback)(async()=>{await Promise.all([m(),_()])},[m,_]),dt=(0,q.useCallback)(async()=>{await Promise.all([lt(),x()])},[lt,x]),ft=(0,q.useCallback)(async()=>{await Promise.all([dt(),N()])},[dt,N]);ze((0,q.useCallback)(e=>{let t=Le(e);t&&_(t,!1)},[_]),l);let pt=(0,q.useMemo)(()=>l?{secondary:(0,K.jsx)(je,{ch:X,refreshing:p.isValidating||v,saveOk:!1,onRefresh:()=>void lt()})}:null,[p.isValidating,X,l,v,lt]);(0,q.useLayoutEffect)(()=>(t?.(pt),()=>t?.(null)),[pt,t]);let mt=(0,q.useCallback)(e=>{I(null),d(E(e)),H(null),ye(null),J(null)},[d]),ht=(0,q.useCallback)(()=>{d(O),H(null),ye(null),J(null)},[d]),gt=(0,q.useCallback)(async e=>{G(e.id),J(null);try{let t=await a(o(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await lt()}catch(e){J(e instanceof Error?e.message:String(e))}finally{G(null)}},[lt]);(0,q.useEffect)(()=>{ye(null),_e(!1)},[T?.id]);let _t=(0,q.useCallback)(async()=>{if(!T||!V&&Y===null)return!1;let e=qe(T);te(!0),J(null);try{let t=await a(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({...V?{channels:{[e]:V}}:{},...Y===null?{}:{bindings:Te(C,T.id,Y)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return V&&await N(V,!1),await x(),await p.mutate(),H(null),ye(null),!0}catch(e){return J(e instanceof Error?e.message:String(e)),!1}finally{te(!1)}},[T,Y,C,p,V,x,N]),vt=(0,q.useCallback)(async e=>{let t=Z(e),n=qe(e),r=T?.id===e.id?V:null;if(!t.enabled&&!t.ready&&!r){mt(e.id);return}se(e.id),J(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},s=await a(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error?.message??s.statusText)}await p.mutate(),await x(),await _(),T?.id===e.id&&(await N(),H(null))}catch(e){J(e instanceof Error?e.message:String(e))}finally{se(null)}},[T?.id,p,V,x,N,_,mt]),$=T?.ui?.modal,yt=$?.placement!==`replace-config`,bt=T?rt(T):`checking`,xt=T?!Z(T).ready||pe:!1;return l?(0,K.jsxs)(le,{gap:`gap-4`,className:Ue,padding:We,children:[p.isLoading?(0,K.jsx)(oe,{sections:2}):p.error?(0,K.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(p.error)}):(0,K.jsx)(`div`,{className:`grid gap-5 md:grid-cols-2 md:gap-6 xl:grid-cols-3`,children:h.map(e=>(0,K.jsx)(ot,{entry:e,runtime:rt(e),busy:W===e.id,restarting:ue===e.id,ch:X,onOpen:()=>{let t=rt(e)===`running`;t||ge(e)&&e.ui?.modal?.placement!==`replace-config`?I({id:e.id,test:t}):mt(e.id)},onSettings:()=>mt(e.id),onToggle:()=>void vt(e),onRestart:()=>void gt(e)},e.id))}),ve?(0,K.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:ve}):null,(0,K.jsx)(ke,{presentation:`modal`,open:!!L&&!T,onOpenChange:e=>{e||I(null)},closeAriaLabel:X.close,srTitle:L?.label??X.connect,srDescription:L?.description??X.setupEmptyHint,compact:!0,headerExtra:L?(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge py-3 pl-6 pr-14`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:L.label}),(0,K.jsx)(B,{type:`button`,variant:`ghost`,className:`size-11 shrink-0 p-0`,"aria-label":X.channelSettingsLabel.replace(`{{channel}}`,L.label),title:X.advancedConfiguration,onClick:()=>mt(L.id),children:(0,K.jsx)(j,{className:`size-4`})})]}):null,children:L&&P?.test?(0,K.jsxs)(`div`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,K.jsx)(`p`,{children:X.testMessageHint}),L.docsPath?(0,K.jsxs)(`a`,{href:re(n,L.docsPath),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent hover:underline`,children:[X.docs,(0,K.jsx)(S,{className:`size-3.5`})]}):null]}):L?(0,K.jsx)(xe,{entry:L,locale:n,messages:X,onChanged:dt,quick:!0},L.id):null}),(0,K.jsx)(ke,{presentation:`modal`,open:!!T,onOpenChange:e=>{e||ht()},closeAriaLabel:X.close,srTitle:T?.label??X.selectChannel,srDescription:T?.description,wide:!0,footer:T?(0,K.jsx)(Me,{ch:X,dirty:!!V||Y!==null,saving:ee,onCancel:ht,onDiscard:()=>{H(null),ye(null)},onSave:_t}):null,children:T?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,K.jsx)(it,{entry:T}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,K.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:T.label}),(0,K.jsx)(`span`,{className:F(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Xe(bt)),children:Je(bt,X)})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:!Z(T).ready&&ge(T)?.[1].result===`qr`?X.scanLoginHint.replace(`{{channel}}`,T.label):T.description}),T.docsPath?(0,K.jsxs)(`a`,{href:re(n,T.docsPath),target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[X.docs,(0,K.jsx)(S,{className:`size-3.5`})]}):null]})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,K.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Z(T).enabled?X.enabledLabel:X.disabledLabel}),(0,K.jsx)(at,{checked:Z(T).enabled,disabled:W===T.id,label:X.toggleChannel.replace(`{{channel}}`,T.label),onToggle:()=>void vt(T)})]})]})}),(0,K.jsx)(st,{runtime:bt,restarting:ue===T.id,checking:v,showConnectionOptions:pe,canManageConnection:Z(T).ready&&$?.placement!==`replace-config`,ch:X,onRestart:()=>void gt(T),onCheck:()=>void lt(),onManageConnection:()=>_e(e=>!e)}),(0,K.jsx)(ct,{entry:T,ch:X}),T.id===`telegram`?(0,K.jsx)(fe,{language:n}):null,xt&&$?.placement!==`replace-config`?(0,K.jsx)(xe,{entry:T,locale:n,messages:X,compact:!0,onStarted:()=>_e(!0),onChanged:ft},T.id):null,$?.entrypoint&&$.placement===`before-config`?(0,K.jsx)(ae,{extensionId:T.extensionId,extensionName:T.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:T.id,entry:T,config:be}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,K.jsx)(ae,{extensionId:T.extensionId,extensionName:T.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:T.id,entry:T,config:be}}):null,yt&&Ne?(0,K.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:X.basicConfiguration}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:X.basicConfigurationHint})]}),(0,K.jsx)(de,{schema:Oe,values:be,onChange:e=>H(e),disabled:ee,labels:Q})]}):null,(0,K.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,K.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(A,{className:`size-4 text-fg-muted`}),X.messageHandling]}),(0,K.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:X.agentRouting}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:X.agentRoutingHint})]}),(0,K.jsx)(y,{value:Pe,options:Ie,placeholder:Ye,ariaLabel:X.agentRouting,disabled:ee||!w,onChange:e=>ye(e)})]})]}),yt&&nt(Ae)?(0,K.jsx)(ce,{title:X.advancedConfiguration,summary:X.messageHandlingHint,children:(0,K.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,K.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(A,{className:`size-4 text-fg-muted`}),X.advancedConfiguration]}),(0,K.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,K.jsx)(de,{schema:Ae,values:be,onChange:e=>H(e),disabled:ee,labels:Q})})]})}):null,ve?(0,K.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ve}):null]}):null})]}):(0,K.jsx)(le,{gap:`gap-3`,className:Ue,padding:We,children:(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:X.tokenRequired})})}function ut(e){let t=e.properties;if(!t)return e;let n=[`botToken`,`dmPolicy`,`allowFrom`,`groupPolicy`,`groupAllowFrom`];return{...e,properties:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...ut(t),...n.includes(e)?{"x-order":n.indexOf(e)}:{}}]))}}export{lt as ChannelsSettingsPanel};
@@ -1 +1 @@
1
- import{a as e,i as t}from"./locale-store-tI9VX7dp.js";import{t as n}from"./gateway-config-swr-DOwezeL2.js";var r=null;async function i(){return r||(r=a().finally(()=>{r=null}),r)}async function a(){let r=await e(t(`/api/agents`));if(r.ok){let e=await r.json();if(e.ok&&e.payload?.defaultId&&Array.isArray(e.payload.agents)){let t=e.payload.defaultId.trim().toLowerCase(),n=e.payload.agents.filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),...e.override?.purpose?{purpose:e.override.purpose}:{},name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{},skills:(e.effective?.skills?.mode===`selected`?e.effective.skills.include??[]:[]).filter(e=>typeof e==`string`&&!!e.trim())}));if(n.length>0)return{defaultId:t,items:n}}}let i=(await n()).payload?.config?.agents,a=(i?.defaultId??`main`).trim().toLowerCase(),o=(Array.isArray(i?.list)?i.list:[]).filter(e=>!!(e&&e.enabled!==!1&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),...e.purpose?{purpose:e.purpose}:{}}));return o.length===0?{defaultId:a,items:[{id:a}]}:{defaultId:a,items:o}}export{i as t};
1
+ import{a as e,i as t}from"./locale-store-DIBIYLnI.js";import{t as n}from"./gateway-config-swr-Dk3FtNv1.js";var r=null;async function i(){return r||(r=a().finally(()=>{r=null}),r)}async function a(){let r=await e(t(`/api/agents`));if(r.ok){let e=await r.json();if(e.ok&&e.payload?.defaultId&&Array.isArray(e.payload.agents)){let t=e.payload.defaultId.trim().toLowerCase(),n=e.payload.agents.filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),...e.override?.purpose?{purpose:e.override.purpose}:{},name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{},skills:(e.effective?.skills?.mode===`selected`?e.effective.skills.include??[]:[]).filter(e=>typeof e==`string`&&!!e.trim())}));if(n.length>0)return{defaultId:t,items:n}}}let i=(await n()).payload?.config?.agents,a=(i?.defaultId??`main`).trim().toLowerCase(),o=(Array.isArray(i?.list)?i.list:[]).filter(e=>!!(e&&e.enabled!==!1&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),...e.purpose?{purpose:e.purpose}:{}}));return o.length===0?{defaultId:a,items:[{id:a}]}:{defaultId:a,items:o}}export{i as t};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid-render-oOellPHt.js","assets/rolldown-runtime-aKtaBQYM.js","assets/highlight-code-BH65IIbJ.js","assets/xml-_d7dTN2Q.js","assets/echarts-runtime-QSmTlXOu.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{n as a}from"./locale-store-tI9VX7dp.js";import{t as o}from"./messages-e5MhDONm.js";import{a as s,i as c,n as l,o as u,r as d,s as f,t as p}from"./dist-CY7CS_D3.js";import{t as m}from"./check-DUBLcKHA.js";import{t as h}from"./copy-Dv6d4Dvw.js";import{t as g}from"./download-Dk-ZjtO6.js";import{G as _,W as v,a as y,i as b,o as x,q as S,s as C}from"./markdown-view-CSpQhSka.js";import{t as w}from"./x-B_N4OPjy.js";import{t as T}from"./skeleton-DzdOeGYz.js";import{t as E}from"./copy-to-clipboard-HOJ79TWv.js";var D=n(),O=e(t(),1),k=r(),A=2,j=(0,O.createContext)(null);function M(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function N(e){let t=(0,D.c)(14),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=(0,O.useRef)(r),a=(0,O.useRef)(0),o=(0,O.useRef)(null),s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,t[1]=s):s=t[1];let[c,l]=(0,O.useState)(s),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=new Set,t[2]=u):u=t[2];let[d,f]=(0,O.useState)(u),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{if(document.visibilityState===`hidden`){l(R);return}let e=[...i.current.entries()].filter(L).sort(I),t=new Set(e.slice(0,A).map(F)),n=new Set(e.map(P));l(e=>M(e,t)?e:t),f(e=>M(e,n)?e:n)},t[3]=p):p=t[3];let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{let n=i.current.get(e);if(n&&o.current?.unobserve(n.element),!t){i.current.delete(e),m();return}i.current.set(e,{element:t,near:!1,visible:!1,manualPriority:n?.manualPriority??0,distance:1/0}),o.current?.observe(t)},t[4]=h):h=t[4];let g=h,_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{let t=i.current.get(e);t&&(a.current+=1,t.manualPriority=a.current,t.near=!0,t.visible=!0,t.distance=0,m())},t[5]=_):_=t[5];let v=_,y,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{if(typeof IntersectionObserver>`u`)return;o.current=new IntersectionObserver(e=>{for(let t of e){let e=[...i.current.values()].find(e=>e.element===t.target);if(!e)continue;let n=t.boundingClientRect;e.near=t.isIntersecting,e.visible=t.isIntersecting&&n.bottom>0&&n.top<window.innerHeight,e.distance=Math.abs((n.top+n.bottom)/2-window.innerHeight/2),e.near||(e.manualPriority=0)}m()},{rootMargin:`480px 0px`,threshold:0});for(let e of i.current.values())o.current.observe(e.element);let e=()=>m();return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),o.current?.disconnect(),o.current=null}},b=[m],t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,O.useEffect)(y,b);let x;t[8]!==c||t[9]!==d?(x={activeIds:c,nearIds:d,register:g,activate:v},t[8]=c,t[9]=d,t[10]=x):x=t[10];let S=x,C;return t[11]!==n||t[12]!==S?(C=(0,k.jsx)(j.Provider,{value:S,children:n}),t[11]=n,t[12]=S,t[13]=C):C=t[13],C}function P(e){let[t]=e;return t}function F(e){let[t]=e;return t}function I(e,t){let[,n]=e,[,r]=t;return r.manualPriority-n.manualPriority||Number(r.visible)-Number(n.visible)||n.distance-r.distance}function L(e){let[,t]=e;return t.near||t.manualPriority>0}function R(e){return e.size?new Set:e}function z(e){let t=(0,D.c)(16),n=(0,O.useContext)(j),r=n?.register,i=n?.activate,a;t[0]!==e||t[1]!==r?(a=t=>r?.(e,t),t[0]=e,t[1]=r,t[2]=a):a=t[2];let o=a;if(!n){let e;return t[3]===o?e=t[4]:(e={active:!0,state:`active`,containerRef:o,activate:B},t[3]=o,t[4]=e),e}let s;t[5]!==e||t[6]!==n.activeIds?(s=n.activeIds.has(e),t[5]=e,t[6]=n.activeIds,t[7]=s):s=t[7];let c=s,l=c?`active`:n.nearIds.has(e)?`queued`:`dormant`,u;t[8]!==e||t[9]!==i?(u=()=>i?.(e),t[8]=e,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==o||t[13]!==l||t[14]!==u?(d={active:c,state:l,containerRef:o,activate:u},t[11]=c,t[12]=o,t[13]=l,t[14]=u,t[15]=d):d=t[15],d}function B(){}var V=new class{maxBytes;maxEntries;entries=new Map;bytes=0;constructor(e=8*1024*1024,t=256){this.maxBytes=e,this.maxEntries=t}get(e){let t=this.entries.get(e);if(t)return this.entries.delete(e),this.entries.set(e,t),t.value}set(e,t){let n=this.entries.get(e);n&&(this.bytes-=n.bytes),this.entries.delete(e);let r=(e.length+t.length)*2;if(!(r>this.maxBytes))for(this.entries.set(e,{value:t,bytes:r}),this.bytes+=r;this.bytes>this.maxBytes||this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.bytes-=this.entries.get(e).bytes,this.entries.delete(e)}}get sizeBytes(){return this.bytes}},H=(0,O.memo)(function({code:e,language:t,incomplete:n,renderMermaid:r,actions:s,copy:c}){let l=z((0,O.useId)()),u=(0,O.useRef)(null),[d,f]=(0,O.useState)(null),[p,w]=(0,O.useState)(null),[T,D]=(0,O.useState)(!1),[A,j]=(0,O.useState)(!1),[M,N]=(0,O.useState)(0),P=(0,O.useRef)(null),F=(0,O.useRef)(!1),I=(0,O.useRef)(e),L=o(a(e=>e.language)).chat,R=(t===`mermaid`||!t&&y(e))&&r&&!n,B=`${R?`mermaid`:`code`}:${t}:${e}`;(0,O.useEffect)(()=>{if(n||!l.active||new TextEncoder().encode(e).byteLength>100*1024)return;let r=!0;j(!1);let a=V.get(B);return(a===void 0?R?i(async()=>{let{renderMermaidSvg:e}=await import(`./mermaid-render-oOellPHt.js`).then(e=>e.t);return{renderMermaidSvg:e}},__vite__mapDeps([0,1])).then(({renderMermaidSvg:t})=>v(t(e))):i(async()=>{let{highlightCode:e}=await import(`./highlight-code-BH65IIbJ.js`);return{highlightCode:e}},__vite__mapDeps([2,3,1])).then(({highlightCode:n})=>_.sanitize(n(e,t),{ALLOWED_TAGS:[`span`],ALLOWED_ATTR:[`class`]})):Promise.resolve(a)).then(e=>{r&&(V.set(B,e),f({key:B,value:e}))}).catch(()=>{r&&j(!0)}),()=>{r=!1}},[B,e,R,n,t,l.active,M]),(0,O.useLayoutEffect)(()=>{I.current=e},[e]),(0,O.useEffect)(()=>(F.current=!0,()=>{F.current=!1,P.current&&clearTimeout(P.current)}),[]);let H=()=>{let e=u.current,t=e?.querySelector(`svg`);return e&&t?x(t,e):null},U=d?.key===B?d.value:null,W=R&&!!U&&!A,G={title:L.mermaidPreviewTitle,close:L.mermaidPreviewClose,zoomIn:L.mermaidZoomIn,zoomOut:L.mermaidZoomOut,fit:L.mermaidFit,downloadPng:L.mermaidDownloadPng,downloadSvg:L.mermaidDownloadSvg,downloadFailed:L.mermaidDownloadFailed};return(0,k.jsxs)(`div`,{ref:l.containerRef,className:W?`markdown-mermaid markdown-mermaid-interactive`:`markdown-code-block`,"data-mermaid-diagram":W?``:void 0,children:[W?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{ref:u,dangerouslySetInnerHTML:{__html:U}}),s&&(0,k.jsxs)(`div`,{className:`markdown-mermaid-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`markdown-mermaid-action-button`,title:L.mermaidPreview,"aria-label":L.mermaidPreview,onClick:()=>{let e=H();e&&w({snapshot:e,baseName:`diagram`})},children:(0,k.jsx)(S,{className:`size-4`,"aria-hidden":!0})}),(0,k.jsx)(`button`,{type:`button`,className:`markdown-mermaid-action-button`,title:L.mermaidDownloadPng,"aria-label":L.mermaidDownloadPng,onClick:()=>{let e=H();e&&C(e,`diagram.png`).catch(()=>{F.current&&j(!0)})},children:(0,k.jsx)(g,{className:`size-4`,"aria-hidden":!0})})]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`markdown-code-block-header`,children:[(0,k.jsx)(`span`,{className:`markdown-code-block-lang`,children:t||`text`}),R&&(0,k.jsx)(`button`,{type:`button`,className:`markdown-code-copy-btn`,title:L.mermaidPreview,"aria-label":L.mermaidPreview,onClick:()=>{l.activate(),N(e=>e+1)},children:(0,k.jsx)(S,{})}),c&&(0,k.jsx)(`button`,{type:`button`,className:`markdown-code-copy-btn`,title:T?L.messageCopied:L.codeBlockCopy,"aria-label":T?L.messageCopied:L.codeBlockCopy,onClick:()=>{E(e).then(t=>{!t||!F.current||I.current!==e||(D(!0),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>D(!1),2e3))})},children:T?(0,k.jsx)(m,{"aria-hidden":`true`}):(0,k.jsx)(h,{"aria-hidden":`true`})})]}),(0,k.jsx)(`pre`,{children:(0,k.jsx)(`code`,{className:`hljs${t?` language-${t}`:``}`,children:U&&!R?(0,k.jsx)(`span`,{dangerouslySetInnerHTML:{__html:U}}):e})}),A&&R&&(0,k.jsx)(`p`,{className:`markdown-mermaid-error-message`,role:`status`,children:L.mermaidRenderError})]}),(0,k.jsx)(b,{preview:p,labels:G,onClose:()=>w(null)})]})}),U={bytes:100*1024,series:20,points:1e4,text:200,summary:2e3},W=class extends Error{path;code;constructor(e,t){super(`${e}: ${t}`),this.path=e,this.code=t,this.name=`ChartSpecError`}};function G(e,t){throw new W(e,t)}function K(e,t,n){(!e||typeof e!=`object`||Array.isArray(e))&&G(n,`OBJECT_REQUIRED`);let r=e;for(let e of Object.keys(r))t.includes(e)||G(`${n}.${e}`,`UNKNOWN_FIELD`);return r}function q(e,t,n=U.text){return(typeof e!=`string`||!e.trim()||e.length>n)&&G(t,`INVALID_TEXT`),e}function J(e,t,n){return(!Array.isArray(e)||e.length===0||e.length>n)&&G(t,`INVALID_ARRAY`),e}function Y(e){(e.length>U.bytes||new TextEncoder().encode(e).byteLength>U.bytes)&&G(`$`,`TOO_LARGE`);let t;try{t=JSON.parse(e)}catch{G(`$`,`INVALID_JSON`)}let n=K(t,[`version`,`type`,`title`,`summary`,`dataKind`,`sources`,`xAxis`,`yAxis`,`series`],`$`);n.version!==1&&G(`$.version`,`UNSUPPORTED_VERSION`),n.type!==`line`&&n.type!==`bar`&&G(`$.type`,`UNSUPPORTED_TYPE`),n.dataKind!==`real`&&n.dataKind!==`example`&&G(`$.dataKind`,`INVALID_DATA_KIND`);let r=K(n.xAxis,[`label`,`values`],`$.xAxis`),i=K(n.yAxis,[`label`,`unit`],`$.yAxis`),a=J(r.values,`$.xAxis.values`,U.points).map((e,t)=>q(e,`$.xAxis.values[${t}]`)),o=new Set,s=J(n.series,`$.series`,U.series).map((e,t)=>{let n=`$.series[${t}]`,r=K(e,[`name`,`values`],n),i=q(r.name,`${n}.name`);o.has(i)&&G(`${n}.name`,`DUPLICATE_SERIES`),o.add(i);let s=J(r.values,`${n}.values`,U.points);return s.length!==a.length&&G(`${n}.values`,`LENGTH_MISMATCH`),{name:i,values:s.map((e,t)=>e===null?null:((typeof e!=`number`||!Number.isFinite(e))&&G(`${n}.values[${t}]`,`INVALID_NUMBER`),e))}});s.length*a.length>U.points&&G(`$.series`,`TOO_MANY_POINTS`),s.some(e=>e.values.some(e=>e!==null))||G(`$.series`,`EMPTY_DATA`);let c=n.sources===void 0?void 0:J(n.sources,`$.sources`,20).map((e,t)=>q(e,`$.sources[${t}]`,2e3));return n.dataKind===`real`&&!c&&G(`$.sources`,`SOURCES_REQUIRED`),{version:1,type:n.type,title:q(n.title,`$.title`),summary:q(n.summary,`$.summary`,U.summary),dataKind:n.dataKind,...c?{sources:c}:{},xAxis:{label:q(r.label,`$.xAxis.label`),values:a},yAxis:{label:q(i.label,`$.yAxis.label`),unit:q(i.unit,`$.yAxis.unit`)},series:s}}function X(e,t){return{animation:!1,backgroundColor:t.background,color:[t.accent,t.muted,`#659c95`,`#b49166`,`#927daf`],textStyle:{color:t.foreground,fontFamily:`sans-serif`},grid:{left:16,right:24,top:84,bottom:48,outerBoundsMode:`same`,outerBoundsContain:`all`},legend:{type:`scroll`,top:8,textStyle:{color:t.foreground,width:160,overflow:`truncate`}},tooltip:{trigger:`axis`,renderMode:`richText`,confine:!0},xAxis:{type:`category`,data:[...e.xAxis.values],name:e.xAxis.label,nameLocation:`middle`,nameGap:32,nameTextStyle:{color:t.muted},boundaryGap:e.type===`bar`,axisLabel:{color:t.muted,width:72,overflow:`truncate`,hideOverlap:!0},axisLine:{lineStyle:{color:t.border}},axisTick:{show:!1}},yAxis:{type:`value`,name:`${e.yAxis.label} (${e.yAxis.unit})`,nameTextStyle:{color:t.muted,width:200,overflow:`truncate`,align:`left`},scale:!1,axisLabel:{color:t.muted},splitLine:{lineStyle:{color:t.border}}},series:e.series.map((t,n)=>e.type===`line`?{name:t.name,type:`line`,data:[...t.values],smooth:!1,connectNulls:!1,showSymbol:e.xAxis.values.length<=100,symbol:[`circle`,`rect`,`triangle`,`diamond`,`roundRect`][n%5],lineStyle:{type:n%2?`dashed`:`solid`}}:{name:t.name,type:`bar`,data:[...t.values],barMaxWidth:40})}}function Z(e,t){return X(e,t)}function ee(e){let t=getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n;return{foreground:n(`--color-fg`,`#111111`),muted:n(`--color-fg-muted`,`#666666`),border:n(`--color-edge`,`#ececec`),background:n(`--color-surface-panel`,`#ffffff`),accent:n(`--color-accent`,`#3a6bff`)}}function te(){return i(()=>import(`./echarts-runtime-QSmTlXOu.js`),__vite__mapDeps([4,1]))}function Q({spec:e,onError:t,expanded:n=!1}){let r=(0,O.useRef)(null),i=(0,O.useRef)(null),[s,c]=(0,O.useState)(!1),[l,u]=(0,O.useState)(!1),d=o(a(e=>e.language)).chat.chart;return(0,O.useEffect)(()=>{let n=r.current;if(!n)return;let a=!0,o,s,l=0,u=0,d=``;c(!1);let f=()=>{let r=n.clientWidth,s=n.clientHeight;if(!(!a||!o||r<=0||s<=0))try{let t=ee(n),a=JSON.stringify(t);i.current||(i.current=o.init(n,void 0,{renderer:`canvas`,devicePixelRatio:Math.min(window.devicePixelRatio||1,2)}),c(!0)),a!==d&&(i.current.setOption(Z(e,t),{notMerge:!0}),d=a),l&&(r!==l||s!==u)&&i.current.resize(),l=r,u=s}catch{i.current?.dispose(),i.current=null,t()}},p=()=>{!a||s!==void 0||(s=requestAnimationFrame(()=>{s=void 0,f()}))},m=typeof ResizeObserver>`u`?null:new ResizeObserver(p);m?.observe(n);let h=new MutationObserver(p);return h.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-theme`,`data-color-scheme`,`style`]}),window.addEventListener(`resize`,p),te().then(e=>{a&&(o=e,f())}).catch(()=>{a&&t()}),()=>{a=!1,s!==void 0&&cancelAnimationFrame(s),m?.disconnect(),h.disconnect(),window.removeEventListener(`resize`,p),i.current?.dispose(),i.current=null}},[e,t]),(0,k.jsxs)(`div`,{className:n?`relative h-full min-h-0`:`relative h-[280px] sm:h-[360px]`,children:[(0,k.jsx)(`div`,{ref:r,className:`h-full w-full`,role:`img`,"aria-label":`${e.title}. ${e.summary}`}),!s&&(0,k.jsx)(`div`,{className:`absolute inset-0 p-4`,role:`status`,"aria-label":d.loading,children:(0,k.jsx)(T,{className:`h-full w-full`})}),s&&(0,k.jsxs)(`button`,{type:`button`,className:`absolute bottom-1 right-1 flex min-h-9 items-center gap-1 rounded-md bg-surface-overlay px-2 text-xs text-fg-muted hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,onClick:()=>{if(i.current)try{let e=i.current,t=Math.min(2,8192/e.getWidth(),8192/e.getHeight(),Math.sqrt(32e6/(e.getWidth()*e.getHeight()))),n=e.getDataURL({type:`png`,pixelRatio:t}),r=document.createElement(`a`);r.href=n,r.download=`chart.png`,document.body.append(r),r.click(),r.remove(),u(!1)}catch{u(!0)}},"aria-label":d.download,children:[(0,k.jsx)(g,{className:`size-4`,"aria-hidden":!0}),`PNG`]}),l&&(0,k.jsx)(`p`,{role:`status`,className:`absolute bottom-10 right-2 bg-surface-overlay p-2 text-xs text-fg-muted`,children:d.downloadFailed})]})}var $=`min-h-11 rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-accent sm:min-h-9`;function ne({spec:e,source:t,copy:n}){let r=z((0,O.useId)()),[i,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1),[_,v]=(0,O.useState)(!1),[y,b]=(0,O.useState)(!1),[x,C]=(0,O.useState)(!1),[D,A]=(0,O.useState)(!1),[j,M]=(0,O.useState)(!1),N=(0,O.useCallback)(()=>g(!0),[]),P=(0,O.useCallback)(()=>b(!0),[]),F=a(e=>e.language),I=o(F).chat.chart,L=i||h;return(0,k.jsxs)(`figure`,{ref:r.containerRef,className:`my-4 min-w-0 overflow-hidden rounded-lg border border-edge bg-surface-panel`,"data-chart-block":``,children:[(0,k.jsxs)(`figcaption`,{className:`flex flex-wrap items-center gap-1 border-b border-edge px-3 py-1`,children:[(0,k.jsx)(`span`,{className:`min-w-0 basis-full break-words text-sm font-medium text-fg sm:flex-1 sm:basis-0`,children:e.title}),e.dataKind===`example`&&(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:I.example}),(0,k.jsx)(`button`,{type:`button`,className:$,"aria-pressed":L,onClick:()=>m(!L),disabled:h,children:L?I.chart:I.source}),n&&(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>{E(t).then(e=>{A(!e),M(e)})},children:j?o(F).chat.messageCopied:I.copy}),(0,k.jsx)(`button`,{type:`button`,className:$,"aria-label":I.preview,onClick:()=>{b(!1),v(!0)},children:(0,k.jsx)(S,{className:`size-4`,"aria-hidden":!0})})]}),D&&(0,k.jsx)(`p`,{role:`status`,className:`px-3 text-xs text-fg-muted`,children:I.copyFailed}),h&&(0,k.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-fg-muted`,role:`status`,children:[I.failed,(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>{r.activate(),g(!1),m(!1)},children:I.retry})]}),L?(0,k.jsx)(`pre`,{className:`max-h-[360px] overflow-auto p-3 text-xs`,children:(0,k.jsx)(`code`,{className:`language-json`,children:t})}):r.active&&!_?(0,k.jsx)(Q,{spec:e,onError:N}):(0,k.jsxs)(`div`,{className:`relative h-[280px] p-4 sm:h-[360px]`,children:[(0,k.jsx)(T,{className:`h-full w-full`}),(0,k.jsx)(`button`,{type:`button`,className:`${$} absolute inset-0 m-auto h-10 w-fit bg-surface-overlay`,onClick:r.activate,children:I.activate})]}),(0,k.jsx)(`p`,{className:`px-3 pb-2 text-xs text-fg-muted`,children:e.summary}),e.sources&&(0,k.jsxs)(`p`,{className:`px-3 pb-2 text-xs text-fg-muted`,children:[I.sources,`: `,e.sources.join(` · `)]}),(0,k.jsxs)(`details`,{className:`border-t border-edge px-3 py-2 text-xs text-fg-muted`,onToggle:e=>C(e.currentTarget.open),children:[(0,k.jsx)(`summary`,{className:`cursor-pointer`,children:I.data}),x&&(0,k.jsx)(`div`,{className:`max-h-64 overflow-auto`,children:(0,k.jsxs)(`table`,{children:[(0,k.jsxs)(`caption`,{children:[e.yAxis.label,` (`,e.yAxis.unit,`)`]}),(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`col`,children:e.xAxis.label}),e.series.map(e=>(0,k.jsx)(`th`,{scope:`col`,children:e.name},e.name))]})}),(0,k.jsx)(`tbody`,{children:e.xAxis.values.map((t,n)=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`row`,children:t}),e.series.map(e=>(0,k.jsx)(`td`,{children:e.values[n]??`—`},e.name))]},n))})]})})]}),(0,k.jsx)(p,{open:_,onOpenChange:v,children:(0,k.jsxs)(u,{children:[(0,k.jsx)(s,{className:`fixed inset-0 z-[90] bg-scrim/90 backdrop-blur-sm`}),(0,k.jsxs)(d,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[91] flex h-[min(90dvh,52rem)] w-[min(96vw,80rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay outline-none`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-3 py-2`,children:[(0,k.jsx)(f,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.title}),(0,k.jsx)(l,{className:$,"aria-label":I.close,children:(0,k.jsx)(w,{className:`size-4`,"aria-hidden":!0})})]}),(0,k.jsx)(c,{className:`line-clamp-2 shrink-0 px-3 py-2 text-xs text-fg-muted`,children:e.summary}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden p-2`,children:y?(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:I.failed}):(0,k.jsx)(Q,{spec:e,expanded:!0,onError:P})})]})]})})]})}var re=(0,O.memo)(function(e){let t=(0,D.c)(35),{source:n,incomplete:r,streaming:i,copy:s}=e,c=a(ie),l;t[0]===c?l=t[1]:(l=o(c),t[0]=c,t[1]=l);let u=l.chat.chart,d;bb0:{if(r){d=null;break bb0}try{let e;t[2]===n?e=t[3]:(e=Y(n),t[2]=n,t[3]=e);let r;t[4]===e?r=t[5]:(r={spec:e},t[4]=e,t[5]=r),d=r}catch(e){let n=e,r;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(r={error:n instanceof W?n:new W(`$`,`INVALID_JSON`)},t[6]=r):r=t[6],d=r}}let f=d;if(!f){let e;t[7]!==u.generating||t[8]!==u.incomplete||t[9]!==i?(e=i?(0,k.jsx)(`div`,{className:`h-[280px] sm:h-[360px]`,role:`status`,"aria-label":u.generating,children:(0,k.jsx)(T,{className:`h-full w-full`})}):(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:u.incomplete}),t[7]=u.generating,t[8]=u.incomplete,t[9]=i,t[10]=e):e=t[10];let r;t[11]===u.source?r=t[12]:(r=(0,k.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:u.source}),t[11]=u.source,t[12]=r);let a;t[13]===n?a=t[14]:(a=(0,k.jsx)(`pre`,{className:`max-h-64 overflow-auto text-xs`,children:(0,k.jsx)(`code`,{children:n})}),t[13]=n,t[14]=a);let o;t[15]!==r||t[16]!==a?(o=(0,k.jsxs)(`details`,{children:[r,a]}),t[15]=r,t[16]=a,t[17]=o):o=t[17];let s;return t[18]!==e||t[19]!==o?(s=(0,k.jsxs)(`div`,{className:`my-4 rounded-lg border border-edge p-3`,"data-chart-pending":``,children:[e,o]}),t[18]=e,t[19]=o,t[20]=s):s=t[20],s}if(f.error){let e=u.errors[f.error.code]??u.invalid,r;t[21]!==u.invalid||t[22]!==f.error.path||t[23]!==e?(r=(0,k.jsxs)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:[u.invalid,` (`,f.error.path,`: `,e,`)`]}),t[21]=u.invalid,t[22]=f.error.path,t[23]=e,t[24]=r):r=t[24];let i;t[25]!==s||t[26]!==n?(i=(0,k.jsx)(H,{code:n,language:`json`,incomplete:!1,renderMermaid:!1,actions:!1,copy:s}),t[25]=s,t[26]=n,t[27]=i):i=t[27];let a;return t[28]!==r||t[29]!==i?(a=(0,k.jsxs)(`div`,{className:`my-4 rounded-lg border border-edge p-3`,"data-chart-error":``,children:[r,i]}),t[28]=r,t[29]=i,t[30]=a):a=t[30],a}let p;return t[31]!==s||t[32]!==f.spec||t[33]!==n?(p=(0,k.jsx)(ne,{spec:f.spec,source:n,copy:s},n),t[31]=s,t[32]=f.spec,t[33]=n,t[34]=p):p=t[34],p});function ie(e){return e.language}export{z as i,H as n,N as r,re as t};
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{n as a}from"./locale-store-DIBIYLnI.js";import{t as o}from"./messages-BDBGlBKh.js";import{a as s,i as c,n as l,o as u,r as d,s as f,t as p}from"./dist-CY7CS_D3.js";import{t as m}from"./check-DUBLcKHA.js";import{t as h}from"./copy-Dv6d4Dvw.js";import{t as g}from"./download-Dk-ZjtO6.js";import{G as _,W as v,a as y,i as b,o as x,q as S,s as C}from"./markdown-view-C30KvTaE.js";import{t as w}from"./x-B_N4OPjy.js";import{t as T}from"./skeleton-DzdOeGYz.js";import{t as E}from"./copy-to-clipboard-HOJ79TWv.js";var D=n(),O=e(t(),1),k=r(),A=2,j=(0,O.createContext)(null);function M(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function N(e){let t=(0,D.c)(14),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=(0,O.useRef)(r),a=(0,O.useRef)(0),o=(0,O.useRef)(null),s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,t[1]=s):s=t[1];let[c,l]=(0,O.useState)(s),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=new Set,t[2]=u):u=t[2];let[d,f]=(0,O.useState)(u),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{if(document.visibilityState===`hidden`){l(R);return}let e=[...i.current.entries()].filter(L).sort(I),t=new Set(e.slice(0,A).map(F)),n=new Set(e.map(P));l(e=>M(e,t)?e:t),f(e=>M(e,n)?e:n)},t[3]=p):p=t[3];let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{let n=i.current.get(e);if(n&&o.current?.unobserve(n.element),!t){i.current.delete(e),m();return}i.current.set(e,{element:t,near:!1,visible:!1,manualPriority:n?.manualPriority??0,distance:1/0}),o.current?.observe(t)},t[4]=h):h=t[4];let g=h,_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{let t=i.current.get(e);t&&(a.current+=1,t.manualPriority=a.current,t.near=!0,t.visible=!0,t.distance=0,m())},t[5]=_):_=t[5];let v=_,y,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{if(typeof IntersectionObserver>`u`)return;o.current=new IntersectionObserver(e=>{for(let t of e){let e=[...i.current.values()].find(e=>e.element===t.target);if(!e)continue;let n=t.boundingClientRect;e.near=t.isIntersecting,e.visible=t.isIntersecting&&n.bottom>0&&n.top<window.innerHeight,e.distance=Math.abs((n.top+n.bottom)/2-window.innerHeight/2),e.near||(e.manualPriority=0)}m()},{rootMargin:`480px 0px`,threshold:0});for(let e of i.current.values())o.current.observe(e.element);let e=()=>m();return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),o.current?.disconnect(),o.current=null}},b=[m],t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,O.useEffect)(y,b);let x;t[8]!==c||t[9]!==d?(x={activeIds:c,nearIds:d,register:g,activate:v},t[8]=c,t[9]=d,t[10]=x):x=t[10];let S=x,C;return t[11]!==n||t[12]!==S?(C=(0,k.jsx)(j.Provider,{value:S,children:n}),t[11]=n,t[12]=S,t[13]=C):C=t[13],C}function P(e){let[t]=e;return t}function F(e){let[t]=e;return t}function I(e,t){let[,n]=e,[,r]=t;return r.manualPriority-n.manualPriority||Number(r.visible)-Number(n.visible)||n.distance-r.distance}function L(e){let[,t]=e;return t.near||t.manualPriority>0}function R(e){return e.size?new Set:e}function z(e){let t=(0,D.c)(16),n=(0,O.useContext)(j),r=n?.register,i=n?.activate,a;t[0]!==e||t[1]!==r?(a=t=>r?.(e,t),t[0]=e,t[1]=r,t[2]=a):a=t[2];let o=a;if(!n){let e;return t[3]===o?e=t[4]:(e={active:!0,state:`active`,containerRef:o,activate:B},t[3]=o,t[4]=e),e}let s;t[5]!==e||t[6]!==n.activeIds?(s=n.activeIds.has(e),t[5]=e,t[6]=n.activeIds,t[7]=s):s=t[7];let c=s,l=c?`active`:n.nearIds.has(e)?`queued`:`dormant`,u;t[8]!==e||t[9]!==i?(u=()=>i?.(e),t[8]=e,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==o||t[13]!==l||t[14]!==u?(d={active:c,state:l,containerRef:o,activate:u},t[11]=c,t[12]=o,t[13]=l,t[14]=u,t[15]=d):d=t[15],d}function B(){}var V=new class{maxBytes;maxEntries;entries=new Map;bytes=0;constructor(e=8*1024*1024,t=256){this.maxBytes=e,this.maxEntries=t}get(e){let t=this.entries.get(e);if(t)return this.entries.delete(e),this.entries.set(e,t),t.value}set(e,t){let n=this.entries.get(e);n&&(this.bytes-=n.bytes),this.entries.delete(e);let r=(e.length+t.length)*2;if(!(r>this.maxBytes))for(this.entries.set(e,{value:t,bytes:r}),this.bytes+=r;this.bytes>this.maxBytes||this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.bytes-=this.entries.get(e).bytes,this.entries.delete(e)}}get sizeBytes(){return this.bytes}},H=(0,O.memo)(function({code:e,language:t,incomplete:n,renderMermaid:r,actions:s,copy:c}){let l=z((0,O.useId)()),u=(0,O.useRef)(null),[d,f]=(0,O.useState)(null),[p,w]=(0,O.useState)(null),[T,D]=(0,O.useState)(!1),[A,j]=(0,O.useState)(!1),[M,N]=(0,O.useState)(0),P=(0,O.useRef)(null),F=(0,O.useRef)(!1),I=(0,O.useRef)(e),L=o(a(e=>e.language)).chat,R=(t===`mermaid`||!t&&y(e))&&r&&!n,B=`${R?`mermaid`:`code`}:${t}:${e}`;(0,O.useEffect)(()=>{if(n||!l.active||new TextEncoder().encode(e).byteLength>100*1024)return;let r=!0;j(!1);let a=V.get(B);return(a===void 0?R?i(async()=>{let{renderMermaidSvg:e}=await import(`./mermaid-render-oOellPHt.js`).then(e=>e.t);return{renderMermaidSvg:e}},__vite__mapDeps([0,1])).then(({renderMermaidSvg:t})=>v(t(e))):i(async()=>{let{highlightCode:e}=await import(`./highlight-code-BH65IIbJ.js`);return{highlightCode:e}},__vite__mapDeps([2,3,1])).then(({highlightCode:n})=>_.sanitize(n(e,t),{ALLOWED_TAGS:[`span`],ALLOWED_ATTR:[`class`]})):Promise.resolve(a)).then(e=>{r&&(V.set(B,e),f({key:B,value:e}))}).catch(()=>{r&&j(!0)}),()=>{r=!1}},[B,e,R,n,t,l.active,M]),(0,O.useLayoutEffect)(()=>{I.current=e},[e]),(0,O.useEffect)(()=>(F.current=!0,()=>{F.current=!1,P.current&&clearTimeout(P.current)}),[]);let H=()=>{let e=u.current,t=e?.querySelector(`svg`);return e&&t?x(t,e):null},U=d?.key===B?d.value:null,W=R&&!!U&&!A,G={title:L.mermaidPreviewTitle,close:L.mermaidPreviewClose,zoomIn:L.mermaidZoomIn,zoomOut:L.mermaidZoomOut,fit:L.mermaidFit,downloadPng:L.mermaidDownloadPng,downloadSvg:L.mermaidDownloadSvg,downloadFailed:L.mermaidDownloadFailed};return(0,k.jsxs)(`div`,{ref:l.containerRef,className:W?`markdown-mermaid markdown-mermaid-interactive`:`markdown-code-block`,"data-mermaid-diagram":W?``:void 0,children:[W?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{ref:u,dangerouslySetInnerHTML:{__html:U}}),s&&(0,k.jsxs)(`div`,{className:`markdown-mermaid-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`markdown-mermaid-action-button`,title:L.mermaidPreview,"aria-label":L.mermaidPreview,onClick:()=>{let e=H();e&&w({snapshot:e,baseName:`diagram`})},children:(0,k.jsx)(S,{className:`size-4`,"aria-hidden":!0})}),(0,k.jsx)(`button`,{type:`button`,className:`markdown-mermaid-action-button`,title:L.mermaidDownloadPng,"aria-label":L.mermaidDownloadPng,onClick:()=>{let e=H();e&&C(e,`diagram.png`).catch(()=>{F.current&&j(!0)})},children:(0,k.jsx)(g,{className:`size-4`,"aria-hidden":!0})})]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`markdown-code-block-header`,children:[(0,k.jsx)(`span`,{className:`markdown-code-block-lang`,children:t||`text`}),R&&(0,k.jsx)(`button`,{type:`button`,className:`markdown-code-copy-btn`,title:L.mermaidPreview,"aria-label":L.mermaidPreview,onClick:()=>{l.activate(),N(e=>e+1)},children:(0,k.jsx)(S,{})}),c&&(0,k.jsx)(`button`,{type:`button`,className:`markdown-code-copy-btn`,title:T?L.messageCopied:L.codeBlockCopy,"aria-label":T?L.messageCopied:L.codeBlockCopy,onClick:()=>{E(e).then(t=>{!t||!F.current||I.current!==e||(D(!0),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>D(!1),2e3))})},children:T?(0,k.jsx)(m,{"aria-hidden":`true`}):(0,k.jsx)(h,{"aria-hidden":`true`})})]}),(0,k.jsx)(`pre`,{children:(0,k.jsx)(`code`,{className:`hljs${t?` language-${t}`:``}`,children:U&&!R?(0,k.jsx)(`span`,{dangerouslySetInnerHTML:{__html:U}}):e})}),A&&R&&(0,k.jsx)(`p`,{className:`markdown-mermaid-error-message`,role:`status`,children:L.mermaidRenderError})]}),(0,k.jsx)(b,{preview:p,labels:G,onClose:()=>w(null)})]})}),U={bytes:100*1024,series:20,points:1e4,text:200,summary:2e3},W=class extends Error{path;code;constructor(e,t){super(`${e}: ${t}`),this.path=e,this.code=t,this.name=`ChartSpecError`}};function G(e,t){throw new W(e,t)}function K(e,t,n){(!e||typeof e!=`object`||Array.isArray(e))&&G(n,`OBJECT_REQUIRED`);let r=e;for(let e of Object.keys(r))t.includes(e)||G(`${n}.${e}`,`UNKNOWN_FIELD`);return r}function q(e,t,n=U.text){return(typeof e!=`string`||!e.trim()||e.length>n)&&G(t,`INVALID_TEXT`),e}function J(e,t,n){return(!Array.isArray(e)||e.length===0||e.length>n)&&G(t,`INVALID_ARRAY`),e}function Y(e){(e.length>U.bytes||new TextEncoder().encode(e).byteLength>U.bytes)&&G(`$`,`TOO_LARGE`);let t;try{t=JSON.parse(e)}catch{G(`$`,`INVALID_JSON`)}let n=K(t,[`version`,`type`,`title`,`summary`,`dataKind`,`sources`,`xAxis`,`yAxis`,`series`],`$`);n.version!==1&&G(`$.version`,`UNSUPPORTED_VERSION`),n.type!==`line`&&n.type!==`bar`&&G(`$.type`,`UNSUPPORTED_TYPE`),n.dataKind!==`real`&&n.dataKind!==`example`&&G(`$.dataKind`,`INVALID_DATA_KIND`);let r=K(n.xAxis,[`label`,`values`],`$.xAxis`),i=K(n.yAxis,[`label`,`unit`],`$.yAxis`),a=J(r.values,`$.xAxis.values`,U.points).map((e,t)=>q(e,`$.xAxis.values[${t}]`)),o=new Set,s=J(n.series,`$.series`,U.series).map((e,t)=>{let n=`$.series[${t}]`,r=K(e,[`name`,`values`],n),i=q(r.name,`${n}.name`);o.has(i)&&G(`${n}.name`,`DUPLICATE_SERIES`),o.add(i);let s=J(r.values,`${n}.values`,U.points);return s.length!==a.length&&G(`${n}.values`,`LENGTH_MISMATCH`),{name:i,values:s.map((e,t)=>e===null?null:((typeof e!=`number`||!Number.isFinite(e))&&G(`${n}.values[${t}]`,`INVALID_NUMBER`),e))}});s.length*a.length>U.points&&G(`$.series`,`TOO_MANY_POINTS`),s.some(e=>e.values.some(e=>e!==null))||G(`$.series`,`EMPTY_DATA`);let c=n.sources===void 0?void 0:J(n.sources,`$.sources`,20).map((e,t)=>q(e,`$.sources[${t}]`,2e3));return n.dataKind===`real`&&!c&&G(`$.sources`,`SOURCES_REQUIRED`),{version:1,type:n.type,title:q(n.title,`$.title`),summary:q(n.summary,`$.summary`,U.summary),dataKind:n.dataKind,...c?{sources:c}:{},xAxis:{label:q(r.label,`$.xAxis.label`),values:a},yAxis:{label:q(i.label,`$.yAxis.label`),unit:q(i.unit,`$.yAxis.unit`)},series:s}}function X(e,t){return{animation:!1,backgroundColor:t.background,color:[t.accent,t.muted,`#659c95`,`#b49166`,`#927daf`],textStyle:{color:t.foreground,fontFamily:`sans-serif`},grid:{left:16,right:24,top:84,bottom:48,outerBoundsMode:`same`,outerBoundsContain:`all`},legend:{type:`scroll`,top:8,textStyle:{color:t.foreground,width:160,overflow:`truncate`}},tooltip:{trigger:`axis`,renderMode:`richText`,confine:!0},xAxis:{type:`category`,data:[...e.xAxis.values],name:e.xAxis.label,nameLocation:`middle`,nameGap:32,nameTextStyle:{color:t.muted},boundaryGap:e.type===`bar`,axisLabel:{color:t.muted,width:72,overflow:`truncate`,hideOverlap:!0},axisLine:{lineStyle:{color:t.border}},axisTick:{show:!1}},yAxis:{type:`value`,name:`${e.yAxis.label} (${e.yAxis.unit})`,nameTextStyle:{color:t.muted,width:200,overflow:`truncate`,align:`left`},scale:!1,axisLabel:{color:t.muted},splitLine:{lineStyle:{color:t.border}}},series:e.series.map((t,n)=>e.type===`line`?{name:t.name,type:`line`,data:[...t.values],smooth:!1,connectNulls:!1,showSymbol:e.xAxis.values.length<=100,symbol:[`circle`,`rect`,`triangle`,`diamond`,`roundRect`][n%5],lineStyle:{type:n%2?`dashed`:`solid`}}:{name:t.name,type:`bar`,data:[...t.values],barMaxWidth:40})}}function Z(e,t){return X(e,t)}function ee(e){let t=getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n;return{foreground:n(`--color-fg`,`#111111`),muted:n(`--color-fg-muted`,`#666666`),border:n(`--color-edge`,`#ececec`),background:n(`--color-surface-panel`,`#ffffff`),accent:n(`--color-accent`,`#3a6bff`)}}function te(){return i(()=>import(`./echarts-runtime-QSmTlXOu.js`),__vite__mapDeps([4,1]))}function Q({spec:e,onError:t,expanded:n=!1}){let r=(0,O.useRef)(null),i=(0,O.useRef)(null),[s,c]=(0,O.useState)(!1),[l,u]=(0,O.useState)(!1),d=o(a(e=>e.language)).chat.chart;return(0,O.useEffect)(()=>{let n=r.current;if(!n)return;let a=!0,o,s,l=0,u=0,d=``;c(!1);let f=()=>{let r=n.clientWidth,s=n.clientHeight;if(!(!a||!o||r<=0||s<=0))try{let t=ee(n),a=JSON.stringify(t);i.current||(i.current=o.init(n,void 0,{renderer:`canvas`,devicePixelRatio:Math.min(window.devicePixelRatio||1,2)}),c(!0)),a!==d&&(i.current.setOption(Z(e,t),{notMerge:!0}),d=a),l&&(r!==l||s!==u)&&i.current.resize(),l=r,u=s}catch{i.current?.dispose(),i.current=null,t()}},p=()=>{!a||s!==void 0||(s=requestAnimationFrame(()=>{s=void 0,f()}))},m=typeof ResizeObserver>`u`?null:new ResizeObserver(p);m?.observe(n);let h=new MutationObserver(p);return h.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-theme`,`data-color-scheme`,`style`]}),window.addEventListener(`resize`,p),te().then(e=>{a&&(o=e,f())}).catch(()=>{a&&t()}),()=>{a=!1,s!==void 0&&cancelAnimationFrame(s),m?.disconnect(),h.disconnect(),window.removeEventListener(`resize`,p),i.current?.dispose(),i.current=null}},[e,t]),(0,k.jsxs)(`div`,{className:n?`relative h-full min-h-0`:`relative h-[280px] sm:h-[360px]`,children:[(0,k.jsx)(`div`,{ref:r,className:`h-full w-full`,role:`img`,"aria-label":`${e.title}. ${e.summary}`}),!s&&(0,k.jsx)(`div`,{className:`absolute inset-0 p-4`,role:`status`,"aria-label":d.loading,children:(0,k.jsx)(T,{className:`h-full w-full`})}),s&&(0,k.jsxs)(`button`,{type:`button`,className:`absolute bottom-1 right-1 flex min-h-9 items-center gap-1 rounded-md bg-surface-overlay px-2 text-xs text-fg-muted hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,onClick:()=>{if(i.current)try{let e=i.current,t=Math.min(2,8192/e.getWidth(),8192/e.getHeight(),Math.sqrt(32e6/(e.getWidth()*e.getHeight()))),n=e.getDataURL({type:`png`,pixelRatio:t}),r=document.createElement(`a`);r.href=n,r.download=`chart.png`,document.body.append(r),r.click(),r.remove(),u(!1)}catch{u(!0)}},"aria-label":d.download,children:[(0,k.jsx)(g,{className:`size-4`,"aria-hidden":!0}),`PNG`]}),l&&(0,k.jsx)(`p`,{role:`status`,className:`absolute bottom-10 right-2 bg-surface-overlay p-2 text-xs text-fg-muted`,children:d.downloadFailed})]})}var $=`min-h-11 rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-accent sm:min-h-9`;function ne({spec:e,source:t,copy:n}){let r=z((0,O.useId)()),[i,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1),[_,v]=(0,O.useState)(!1),[y,b]=(0,O.useState)(!1),[x,C]=(0,O.useState)(!1),[D,A]=(0,O.useState)(!1),[j,M]=(0,O.useState)(!1),N=(0,O.useCallback)(()=>g(!0),[]),P=(0,O.useCallback)(()=>b(!0),[]),F=a(e=>e.language),I=o(F).chat.chart,L=i||h;return(0,k.jsxs)(`figure`,{ref:r.containerRef,className:`my-4 min-w-0 overflow-hidden rounded-lg border border-edge bg-surface-panel`,"data-chart-block":``,children:[(0,k.jsxs)(`figcaption`,{className:`flex flex-wrap items-center gap-1 border-b border-edge px-3 py-1`,children:[(0,k.jsx)(`span`,{className:`min-w-0 basis-full break-words text-sm font-medium text-fg sm:flex-1 sm:basis-0`,children:e.title}),e.dataKind===`example`&&(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:I.example}),(0,k.jsx)(`button`,{type:`button`,className:$,"aria-pressed":L,onClick:()=>m(!L),disabled:h,children:L?I.chart:I.source}),n&&(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>{E(t).then(e=>{A(!e),M(e)})},children:j?o(F).chat.messageCopied:I.copy}),(0,k.jsx)(`button`,{type:`button`,className:$,"aria-label":I.preview,onClick:()=>{b(!1),v(!0)},children:(0,k.jsx)(S,{className:`size-4`,"aria-hidden":!0})})]}),D&&(0,k.jsx)(`p`,{role:`status`,className:`px-3 text-xs text-fg-muted`,children:I.copyFailed}),h&&(0,k.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-fg-muted`,role:`status`,children:[I.failed,(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>{r.activate(),g(!1),m(!1)},children:I.retry})]}),L?(0,k.jsx)(`pre`,{className:`max-h-[360px] overflow-auto p-3 text-xs`,children:(0,k.jsx)(`code`,{className:`language-json`,children:t})}):r.active&&!_?(0,k.jsx)(Q,{spec:e,onError:N}):(0,k.jsxs)(`div`,{className:`relative h-[280px] p-4 sm:h-[360px]`,children:[(0,k.jsx)(T,{className:`h-full w-full`}),(0,k.jsx)(`button`,{type:`button`,className:`${$} absolute inset-0 m-auto h-10 w-fit bg-surface-overlay`,onClick:r.activate,children:I.activate})]}),(0,k.jsx)(`p`,{className:`px-3 pb-2 text-xs text-fg-muted`,children:e.summary}),e.sources&&(0,k.jsxs)(`p`,{className:`px-3 pb-2 text-xs text-fg-muted`,children:[I.sources,`: `,e.sources.join(` · `)]}),(0,k.jsxs)(`details`,{className:`border-t border-edge px-3 py-2 text-xs text-fg-muted`,onToggle:e=>C(e.currentTarget.open),children:[(0,k.jsx)(`summary`,{className:`cursor-pointer`,children:I.data}),x&&(0,k.jsx)(`div`,{className:`max-h-64 overflow-auto`,children:(0,k.jsxs)(`table`,{children:[(0,k.jsxs)(`caption`,{children:[e.yAxis.label,` (`,e.yAxis.unit,`)`]}),(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`col`,children:e.xAxis.label}),e.series.map(e=>(0,k.jsx)(`th`,{scope:`col`,children:e.name},e.name))]})}),(0,k.jsx)(`tbody`,{children:e.xAxis.values.map((t,n)=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`row`,children:t}),e.series.map(e=>(0,k.jsx)(`td`,{children:e.values[n]??`—`},e.name))]},n))})]})})]}),(0,k.jsx)(p,{open:_,onOpenChange:v,children:(0,k.jsxs)(u,{children:[(0,k.jsx)(s,{className:`fixed inset-0 z-[90] bg-scrim/90 backdrop-blur-sm`}),(0,k.jsxs)(d,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[91] flex h-[min(90dvh,52rem)] w-[min(96vw,80rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay outline-none`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-3 py-2`,children:[(0,k.jsx)(f,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.title}),(0,k.jsx)(l,{className:$,"aria-label":I.close,children:(0,k.jsx)(w,{className:`size-4`,"aria-hidden":!0})})]}),(0,k.jsx)(c,{className:`line-clamp-2 shrink-0 px-3 py-2 text-xs text-fg-muted`,children:e.summary}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden p-2`,children:y?(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:I.failed}):(0,k.jsx)(Q,{spec:e,expanded:!0,onError:P})})]})]})})]})}var re=(0,O.memo)(function(e){let t=(0,D.c)(35),{source:n,incomplete:r,streaming:i,copy:s}=e,c=a(ie),l;t[0]===c?l=t[1]:(l=o(c),t[0]=c,t[1]=l);let u=l.chat.chart,d;bb0:{if(r){d=null;break bb0}try{let e;t[2]===n?e=t[3]:(e=Y(n),t[2]=n,t[3]=e);let r;t[4]===e?r=t[5]:(r={spec:e},t[4]=e,t[5]=r),d=r}catch(e){let n=e,r;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(r={error:n instanceof W?n:new W(`$`,`INVALID_JSON`)},t[6]=r):r=t[6],d=r}}let f=d;if(!f){let e;t[7]!==u.generating||t[8]!==u.incomplete||t[9]!==i?(e=i?(0,k.jsx)(`div`,{className:`h-[280px] sm:h-[360px]`,role:`status`,"aria-label":u.generating,children:(0,k.jsx)(T,{className:`h-full w-full`})}):(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:u.incomplete}),t[7]=u.generating,t[8]=u.incomplete,t[9]=i,t[10]=e):e=t[10];let r;t[11]===u.source?r=t[12]:(r=(0,k.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:u.source}),t[11]=u.source,t[12]=r);let a;t[13]===n?a=t[14]:(a=(0,k.jsx)(`pre`,{className:`max-h-64 overflow-auto text-xs`,children:(0,k.jsx)(`code`,{children:n})}),t[13]=n,t[14]=a);let o;t[15]!==r||t[16]!==a?(o=(0,k.jsxs)(`details`,{children:[r,a]}),t[15]=r,t[16]=a,t[17]=o):o=t[17];let s;return t[18]!==e||t[19]!==o?(s=(0,k.jsxs)(`div`,{className:`my-4 rounded-lg border border-edge p-3`,"data-chart-pending":``,children:[e,o]}),t[18]=e,t[19]=o,t[20]=s):s=t[20],s}if(f.error){let e=u.errors[f.error.code]??u.invalid,r;t[21]!==u.invalid||t[22]!==f.error.path||t[23]!==e?(r=(0,k.jsxs)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:[u.invalid,` (`,f.error.path,`: `,e,`)`]}),t[21]=u.invalid,t[22]=f.error.path,t[23]=e,t[24]=r):r=t[24];let i;t[25]!==s||t[26]!==n?(i=(0,k.jsx)(H,{code:n,language:`json`,incomplete:!1,renderMermaid:!1,actions:!1,copy:s}),t[25]=s,t[26]=n,t[27]=i):i=t[27];let a;return t[28]!==r||t[29]!==i?(a=(0,k.jsxs)(`div`,{className:`my-4 rounded-lg border border-edge p-3`,"data-chart-error":``,children:[r,i]}),t[28]=r,t[29]=i,t[30]=a):a=t[30],a}let p;return t[31]!==s||t[32]!==f.spec||t[33]!==n?(p=(0,k.jsx)(ne,{spec:f.spec,source:n,copy:s},n),t[31]=s,t[32]=f.spec,t[33]=n,t[34]=p):p=t[34],p});function ie(e){return e.language}export{z as i,H as n,N as r,re as t};