@vellumai/web 0.12.4-dev.202609232047.847daa9 → 0.12.4-dev.202609232115.73e8b74

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 (211) hide show
  1. package/dist/assets/{a2a-invite-DK14yL1B.js → a2a-invite-B4CyuLjf.js} +1 -1
  2. package/dist/assets/{about-page-CSbL9caB.js → about-page-CsuJK_Ma.js} +1 -1
  3. package/dist/assets/{account-page-DzhwJw_M.js → account-page-Bgm-hMw0.js} +1 -1
  4. package/dist/assets/{account-shell-DNS_WdCp.js → account-shell-D0mtEmNE.js} +1 -1
  5. package/dist/assets/{acp-run-detail-panel-DUPItGMU.js → acp-run-detail-panel-CViRJef6.js} +1 -1
  6. package/dist/assets/{activation-list-route-BPoaGZVp.js → activation-list-route-C8sNFH9k.js} +1 -1
  7. package/dist/assets/{activity-redirect-page-CDz-9gzW.js → activity-redirect-page-9AIAF6Cd.js} +1 -1
  8. package/dist/assets/{activity-steps-panel-uUl2hvRk.js → activity-steps-panel-D9YxOjxa.js} +1 -1
  9. package/dist/assets/add-credits-modal-_YJTQAL0.js +1 -0
  10. package/dist/assets/{add-credits-modal-Du6I674T.js → add-credits-modal-bZqIcj8Q.js} +1 -1
  11. package/dist/assets/{ai-page-C_03Fdml.js → ai-page-B-K9_9QT.js} +1 -1
  12. package/dist/assets/{all-chats-page-route--TG0ujZ_.js → all-chats-page-route-CX0_HOel.js} +1 -1
  13. package/dist/assets/{android-billing-handoff-AY7PbzeY.js → android-billing-handoff-C6bvESMN.js} +1 -1
  14. package/dist/assets/{animated-stat-square-B5bQZZua.js → animated-stat-square-BwJ3jZTp.js} +1 -1
  15. package/dist/assets/{api-key-screen-Bqj_lbd8.js → api-key-screen-DI76hQB8.js} +1 -1
  16. package/dist/assets/{app-W5eFKD8y.js → app-BcXqNg4_.js} +13 -13
  17. package/dist/assets/app-hw35VYTL.css +2 -0
  18. package/dist/assets/{app-info-CAPYbfpK.js → app-info-DG4ww7QK.js} +1 -1
  19. package/dist/assets/{archive-redirect-page--Mi67i5a.js → archive-redirect-page-Cf5iC70x.js} +1 -1
  20. package/dist/assets/{assistant-handle-modal-CyuH3Adt.js → assistant-handle-modal-Bc6yOkCf.js} +1 -1
  21. package/dist/assets/{assistant-inbox-page-route-HSNnZyvm.js → assistant-inbox-page-route-DBrDToLY.js} +1 -1
  22. package/dist/assets/{assistant-inbox-upgrade-body-CbVeNbw8.js → assistant-inbox-upgrade-body-C51JYfde.js} +1 -1
  23. package/dist/assets/{assistant-status-panel-WQTnvEuF.js → assistant-status-panel-5I0FYNtT.js} +1 -1
  24. package/dist/assets/auth-store-CE7kATa8.js +1 -0
  25. package/dist/assets/{auth-welcome-screen-Cp5LjSCY.js → auth-welcome-screen-CWL37isS.js} +1 -1
  26. package/dist/assets/avatar-bundled-components-CFuA9DnW.js +1 -0
  27. package/dist/assets/{avatar-random-CGe5vXQj.js → avatar-random-DDGRsi1k.js} +2 -2
  28. package/dist/assets/{await-org-header-settled-CnIWNvWg.js → await-org-header-settled-34Kl-jQ7.js} +1 -1
  29. package/dist/assets/{background-task-detail-panel-BFvSS5r5.js → background-task-detail-panel-B6EdSnLU.js} +1 -1
  30. package/dist/assets/{billing-page-CgNVzB39.js → billing-page-BU-lg2am.js} +3 -3
  31. package/dist/assets/{billing-redirect-page-Shu-uP6r.js → billing-redirect-page-DKeb7sZt.js} +1 -1
  32. package/dist/assets/{bookmarks-page-D1l6sOQG.js → bookmarks-page-CxsqGKWt.js} +1 -1
  33. package/dist/assets/{bundle-confirm-page-Bq4I2Bvo.js → bundle-confirm-page-sxWN1w4H.js} +1 -1
  34. package/dist/assets/{channel-transcript-panel-Bm2ZvSz4.js → channel-transcript-panel-DmEZuNl8.js} +1 -1
  35. package/dist/assets/{channels-page-route-BWIcqPhV.js → channels-page-route-coV6aC-A.js} +1 -1
  36. package/dist/assets/{chat-info-panel-DL5TV_DB.js → chat-info-panel-D0YRnetf.js} +1 -1
  37. package/dist/assets/{checkout-continuation-8eFlOktL.js → checkout-continuation-cpWBzucE.js} +1 -1
  38. package/dist/assets/{checkout-page-uPEq9nJG.js → checkout-page-x_YlqEBN.js} +1 -1
  39. package/dist/assets/checkout-return-target-7l_utrfO.js +1 -0
  40. package/dist/assets/{command-palette-CdQLGggO.js → command-palette-CP8u7IgC.js} +1 -1
  41. package/dist/assets/command-palette-IJTojBxi.js +1 -0
  42. package/dist/assets/{command-palette-window-page-Cd863Cso.js → command-palette-window-page-ZL48KB11.js} +1 -1
  43. package/dist/assets/{community-page-Bf1NtFj6.js → community-page-BKm5oOOq.js} +1 -1
  44. package/dist/assets/{companion-accent-EsWUzZXT.js → companion-accent-T2Y0zMX-.js} +1 -1
  45. package/dist/assets/{companion-dock-zones-page-CpFIipOh.js → companion-dock-zones-page-CBaT2Xrg.js} +1 -1
  46. package/dist/assets/{companion-layout-Bwtugj8T.js → companion-layout-DFl1kbtU.js} +1 -1
  47. package/dist/assets/{companion-popover-Dm8KqJsq.js → companion-popover-DAswUdSr.js} +1 -1
  48. package/dist/assets/{companion-popover-page-BcEbTZlc.js → companion-popover-page-2AyXBWDL.js} +1 -1
  49. package/dist/assets/{companion-surface-Dqsqhbyy.js → companion-surface-Odj37uqu.js} +1 -1
  50. package/dist/assets/{companion-surface-page-Du2dIBnv.js → companion-surface-page-BTClJbRZ.js} +1 -1
  51. package/dist/assets/{companion-tour-entry-DYB_ImAn.js → companion-tour-entry-DyvvIoz9.js} +1 -1
  52. package/dist/assets/{companion-watch-frame-page-DgVR__BC.js → companion-watch-frame-page-qHAYLPXz.js} +1 -1
  53. package/dist/assets/{connect-page-DA3DI5Vq.js → connect-page-v9ra_N24.js} +1 -1
  54. package/dist/assets/{consent-controls-CVx7yoXB.js → consent-controls-aHg4YJK7.js} +1 -1
  55. package/dist/assets/{contacts-gateway-C0yOKrVp.js → contacts-gateway-oZcs2p9w.js} +1 -1
  56. package/dist/assets/{contacts-page-route-nzM1kMRK.js → contacts-page-route-CQz3QeEo.js} +1 -1
  57. package/dist/assets/{copy-button-CO_isysL.js → copy-button-DFJkfL6m.js} +1 -1
  58. package/dist/assets/{credential-entry-page-C_mgjeAY.js → credential-entry-page-CJ3zP7LV.js} +1 -1
  59. package/dist/assets/{credentials-page-BkpVbPrd.js → credentials-page-19IRPf3P.js} +1 -1
  60. package/dist/assets/{csv-preview-8Um77npF.js → csv-preview-Dpb7hCX2.js} +1 -1
  61. package/dist/assets/{danger-zone-redirect-page-DIYqJ68d.js → danger-zone-redirect-page-XWsb9RiH.js} +1 -1
  62. package/dist/assets/{debug-page-r7TPuj7D.js → debug-page-Jhh8_Ost.js} +1 -1
  63. package/dist/assets/{deploy-dialogs-CmjO0bsP.js → deploy-dialogs-B6d_VExz.js} +1 -1
  64. package/dist/assets/deploy-dialogs-CMDwWjT6.js +1 -0
  65. package/dist/assets/{desktop-preview-content-CrEzti04.js → desktop-preview-content-CRW6CYYZ.js} +2 -2
  66. package/dist/assets/{desktop-status-Dmi4TuLk.js → desktop-status-BgVH65v4.js} +1 -1
  67. package/dist/assets/{desktop-viewer-BDMI0J2F.js → desktop-viewer-D7Hwlwwt.js} +1 -1
  68. package/dist/assets/{detail-card-BFYv66i_.js → detail-card-Bav4AP9u.js} +1 -1
  69. package/dist/assets/{detail-panel-stop-button-yNAShiP9.js → detail-panel-stop-button-BXHcz4Ub.js} +1 -1
  70. package/dist/assets/{detail-primitives-h0qp0cUk.js → detail-primitives-DV1LUqyp.js} +1 -1
  71. package/dist/assets/{developer-page-BnWtaxhD.js → developer-page-Dimhj_Wl.js} +1 -1
  72. package/dist/assets/{devices-redirect-page-BEjrYCwg.js → devices-redirect-page-7nIsyr3I.js} +1 -1
  73. package/dist/assets/{dictation-overlay-page-Cuf3LEj-.js → dictation-overlay-page-BwG9T0XO.js} +1 -1
  74. package/dist/assets/{document-load-cjY-Yh0x.js → document-load-BD3n9NiD.js} +1 -1
  75. package/dist/assets/document-load-CWMiQMlX.js +1 -0
  76. package/dist/assets/{document-viewer-page-B4Jr4cfa.js → document-viewer-page-DLbZNxOP.js} +1 -1
  77. package/dist/assets/{emails-page-D7bryjFk.js → emails-page-9hUpUiKc.js} +1 -1
  78. package/dist/assets/{file-diff-view-CNyqmRCj.js → file-diff-view-Vu0BVUBc.js} +1 -1
  79. package/dist/assets/{file-view-mode-T-yoVGZd.js → file-view-mode-BnS3LIZ-.js} +1 -1
  80. package/dist/assets/{general-page-vT40xiK2.js → general-page-C1w0z1d3.js} +1 -1
  81. package/dist/assets/{hatching-screen-BJ2t-_LG.js → hatching-screen-Cmb3ashN.js} +1 -1
  82. package/dist/assets/{hosting-screen-D5T0gCyV.js → hosting-screen-D5U4w1oF.js} +1 -1
  83. package/dist/assets/{identity-page-route-Djw2nz_t.js → identity-page-route-F1_0exSe.js} +1 -1
  84. package/dist/assets/{inspect-page-Bblb1Cdi.js → inspect-page-DjaBd8Dh.js} +3 -3
  85. package/dist/assets/{integrations-page-JmetY3oT.js → integrations-page-Di3B_nLV.js} +1 -1
  86. package/dist/assets/{intelligence-layout-DfsvWyzL.js → intelligence-layout-KALOEqoX.js} +1 -1
  87. package/dist/assets/{intelligence-layout-slots-store-CmSZON4_.js → intelligence-layout-slots-store-DBTArMrt.js} +1 -1
  88. package/dist/assets/{keyboard-shortcuts-redirect-page-DI7S3CaZ.js → keyboard-shortcuts-redirect-page-CtOvIMaq.js} +1 -1
  89. package/dist/assets/{latest-assistant-text-BEN0Rdp3.js → latest-assistant-text-BTwIvBap.js} +1 -1
  90. package/dist/assets/{library-detail-page-DNGFYqmZ.js → library-detail-page-C1jiTtOp.js} +1 -1
  91. package/dist/assets/{library-page-D3hK6I9E.js → library-page-B25cou7T.js} +1 -1
  92. package/dist/assets/local-mode-Dn1zxby0.js +1 -0
  93. package/dist/assets/{login-page-Dm49lodB.js → login-page-C7SkVtZC.js} +1 -1
  94. package/dist/assets/{logout-page-BSBMg9Ee.js → logout-page-Bh8qc8RN.js} +1 -1
  95. package/dist/assets/{logs-layout-DCgNrB_X.js → logs-layout-B8xZWltM.js} +1 -1
  96. package/dist/assets/{markdown-preview-q3ozwrGA.js → markdown-preview-C6mVmdPy.js} +1 -1
  97. package/dist/assets/{media-preview-Bwo6FtBZ.js → media-preview-ntMKRw7P.js} +1 -1
  98. package/dist/assets/{memory-page-route-DQv3yAdU.js → memory-page-route-DGElnJNA.js} +1 -1
  99. package/dist/assets/{memory-router-playground-page-R0FcAyJ1.js → memory-router-playground-page-CMRLIpNW.js} +1 -1
  100. package/dist/assets/{message-files-panel-DBM-9qh5.js → message-files-panel-DV6s0gQs.js} +1 -1
  101. package/dist/assets/native-attachment-pickers-Cb9BeS0b.js +1 -0
  102. package/dist/assets/native-file-CTR90FeX.js +1 -0
  103. package/dist/assets/{notifications-page-CP9QSoUY.js → notifications-page-CYJRZTeX.js} +1 -1
  104. package/dist/assets/{oauth-complete-page-IUNqSP6B.js → oauth-complete-page-slx0Hgj8.js} +1 -1
  105. package/dist/assets/{oauth-popup-complete-page-BU2gfLMp.js → oauth-popup-complete-page-DzLaGxif.js} +1 -1
  106. package/dist/assets/paired-platform-identity-BWy2q93U.js +1 -0
  107. package/dist/assets/{pairing-page-Vn-kFDR8.js → pairing-page-oq-BHsp9.js} +1 -1
  108. package/dist/assets/password-reset-page-C24Od2TJ.js +1 -0
  109. package/dist/assets/{pdf-file-preview-Dyem8AHn.js → pdf-file-preview-DAh2D_aQ.js} +1 -1
  110. package/dist/assets/permission-guide-page-BhHwzr5P.js +1 -0
  111. package/dist/assets/permission-guide-page-D6FWkh5j.css +1 -0
  112. package/dist/assets/{permission-setup-rCqf41Zy.js → permission-setup-SqdOe-Hd.js} +1 -1
  113. package/dist/assets/{personality-page-B0L1NefT.js → personality-page-CWzpxPuk.js} +1 -1
  114. package/dist/assets/{personality-page-B0kQf1YF.js → personality-page-DuVaAIdd.js} +1 -1
  115. package/dist/assets/{personality-sliders-DfJ2P7r9.js → personality-sliders-Cc7Y1tYd.js} +1 -1
  116. package/dist/assets/{plans-page-C_K3GxiO.js → plans-page-WKA3H4Z7.js} +1 -1
  117. package/dist/assets/{platform-loopback-page-DAnai3Ub.js → platform-loopback-page-5n2BN_-i.js} +1 -1
  118. package/dist/assets/{plugin-detail-page-BnFsITam.js → plugin-detail-page-Ds8ceFvT.js} +1 -1
  119. package/dist/assets/{plugins-page-Bzft4weE.js → plugins-page-DDCD3Dqs.js} +1 -1
  120. package/dist/assets/plugins-surface-tYpPhDt0.js +1 -0
  121. package/dist/assets/{preview-error-Bli2YEVn.js → preview-error-BNEHJVe7.js} +1 -1
  122. package/dist/assets/{privacy-page-D3BprFML.js → privacy-page-8WuGJQ2e.js} +1 -1
  123. package/dist/assets/{privacy-screen-hRXrgKqM.js → privacy-screen-Ydl3Pm5x.js} +1 -1
  124. package/dist/assets/{profile-card-BCbekJcy.js → profile-card-CWKRpN67.js} +1 -1
  125. package/dist/assets/{provider-callback-page-_KyJv1p3.js → provider-callback-page-CXma-eGi.js} +1 -1
  126. package/dist/assets/{provider-key-nlfjZmE3.js → provider-key-BV8hYHAY.js} +1 -1
  127. package/dist/assets/{provider-signup-page-B70VXN-c.js → provider-signup-page-D5dT8zlA.js} +1 -1
  128. package/dist/assets/{quick-input-page-BFcRSOQq.js → quick-input-page-COSOOPVe.js} +1 -1
  129. package/dist/assets/{referral-modal-CKgOX5GP.js → referral-modal-Dp-m9bCW.js} +1 -1
  130. package/dist/assets/referral-modal-RWP4XJVP.js +1 -0
  131. package/dist/assets/{research-mock-page-DZDtpboD.js → research-mock-page-BNtbCzos.js} +1 -1
  132. package/dist/assets/{research-onboarding-route-NKWzMY6s.js → research-onboarding-route-B3fMO2ea.js} +1 -1
  133. package/dist/assets/{review-terms-screen-CgHEfofs.js → review-terms-screen-DKhdHHRq.js} +1 -1
  134. package/dist/assets/routes-B2jEapR8.js +1 -0
  135. package/dist/assets/{schedules-C6VrWxrr.js → schedules-Dk6DklG6.js} +1 -1
  136. package/dist/assets/{schedules-page-C_Rl5Ay3.js → schedules-page-BBtyCr0c.js} +1 -1
  137. package/dist/assets/{security-redirect-page-j5uB2ZdW.js → security-redirect-page-Dw3zC8zH.js} +1 -1
  138. package/dist/assets/{select-assistant-screen-CgqQhJcZ.js → select-assistant-screen-xaiR-RFR.js} +1 -1
  139. package/dist/assets/{self-hosted-servers-DKiPZTJp.js → self-hosted-servers-C4WeoF_w.js} +1 -1
  140. package/dist/assets/{service-form-controls-BsXim31K.js → service-form-controls-MUXqVY5y.js} +1 -1
  141. package/dist/assets/{setting-row-CYMIjNzC.js → setting-row-7xJez7VT.js} +1 -1
  142. package/dist/assets/{settings-layout-DV2IipkN.js → settings-layout-mx-gKliC.js} +1 -1
  143. package/dist/assets/{share-feedback-modal-DGagyg1_.js → share-feedback-modal-DB8yvW1E.js} +1 -1
  144. package/dist/assets/share-feedback-modal-J9iDE6Fj.js +1 -0
  145. package/dist/assets/{sidebar-tree-1MWDmxDc.js → sidebar-tree-CLvBZZRZ.js} +1 -1
  146. package/dist/assets/{signup-page-m4VmVaQX.js → signup-page-BTpxTyIq.js} +1 -1
  147. package/dist/assets/{signup-shell-BXxLqXSs.js → signup-shell-CoG73jWw.js} +1 -1
  148. package/dist/assets/{skill-detail-page-CsjA3zaF.js → skill-detail-page-BoWT7kZI.js} +1 -1
  149. package/dist/assets/{skill-detail-panel-LHoyF0-o.js → skill-detail-panel-DhvXiOrE.js} +1 -1
  150. package/dist/assets/{skill-removal-dialog-BXn6-yDs.js → skill-removal-dialog-D0g8heBY.js} +1 -1
  151. package/dist/assets/{skills-page-DB48rBrA.js → skills-page-CUA79QBi.js} +1 -1
  152. package/dist/assets/{sounds-page-TqGrGe6b.js → sounds-page-D0bW2n6O.js} +1 -1
  153. package/dist/assets/{start-screen-CuPerTeA.js → start-screen-BWtkDofn.js} +1 -1
  154. package/dist/assets/{step-detail-header-DMOQu3fY.js → step-detail-header-cMcp1wkW.js} +1 -1
  155. package/dist/assets/{stt-language-picker-modal-zYjhVFJl.js → stt-language-picker-modal-BV-QTu7_.js} +1 -1
  156. package/dist/assets/{subagent-detail-panel-D-rK-H7R.js → subagent-detail-panel-DOpmHM0z.js} +1 -1
  157. package/dist/assets/{superpowers-page-0M_q5JV1.js → superpowers-page-DilJcD1K.js} +1 -1
  158. package/dist/assets/{system-events-page-D__Xz7iy.js → system-events-page-a7uGdHfl.js} +1 -1
  159. package/dist/assets/{system-events-redirect-page-DSzgFS0_.js → system-events-redirect-page-DxV_3qZx.js} +1 -1
  160. package/dist/assets/{teleport-gateway-client-D6UT209B.js → teleport-gateway-client-Ohi1dE-N.js} +1 -1
  161. package/dist/assets/{text-preview-Dh6VWXzz.js → text-preview-B3JGuchH.js} +1 -1
  162. package/dist/assets/{theme-stage-page-CnGBMw6P.js → theme-stage-page-C-WrWnNL.js} +1 -1
  163. package/dist/assets/{tiptap-document-editor-DsKQnLOt.js → tiptap-document-editor-DxcvNAD2.js} +1 -1
  164. package/dist/assets/{tool-detail-panel-BlOCSMcV.js → tool-detail-panel-3qQYSadb.js} +1 -1
  165. package/dist/assets/tool-detail-panel-DNISAkIt.js +1 -0
  166. package/dist/assets/{trait-cycle-row-CPxLpiR6.js → trait-cycle-row-CRPUwkPd.js} +1 -1
  167. package/dist/assets/{upgrade-cancel-page-BdXiyBR8.js → upgrade-cancel-page-CM23P5sG.js} +1 -1
  168. package/dist/assets/{upgrade-success-page-CweM091j.js → upgrade-success-page-CwU0STDG.js} +1 -1
  169. package/dist/assets/{usage-redirect-page-D-BVLz04.js → usage-redirect-page-DuGg9ihZ.js} +1 -1
  170. package/dist/assets/{use-app-delete-BTTUfNWx.js → use-app-delete-LGPKVyQS.js} +1 -1
  171. package/dist/assets/{use-assistant-identity-details-lfwq4I6y.js → use-assistant-identity-details-OLYUdfQd.js} +1 -1
  172. package/dist/assets/{use-checkout-dismiss-refresh-x7-rvsNf.js → use-checkout-dismiss-refresh-BLB5BaOf.js} +1 -1
  173. package/dist/assets/{use-edge-swipe-back-CMm9c0LU.js → use-edge-swipe-back-Dueio9pD.js} +1 -1
  174. package/dist/assets/{use-hotkey-recorder-DhkCuMTE.js → use-hotkey-recorder-CoPbiIMN.js} +1 -1
  175. package/dist/assets/{use-invite-link-dialog-CyBeFuyx.js → use-invite-link-dialog-B2h8yVqm.js} +1 -1
  176. package/dist/assets/{use-plugins-list-CbuKCML_.js → use-plugins-list-CkvXGG9K.js} +1 -1
  177. package/dist/assets/{use-return-to-short-circuit-DAJkvmQ2.js → use-return-to-short-circuit-DIkvmgyp.js} +1 -1
  178. package/dist/assets/{use-side-list-room-WocPOAWn.js → use-side-list-room-7HhxA4TR.js} +1 -1
  179. package/dist/assets/{use-skill-actions-RwSESUry.js → use-skill-actions-DTkyf7Ws.js} +1 -1
  180. package/dist/assets/{use-skill-detail-files-D51QU7Jc.js → use-skill-detail-files-CZkDMiHE.js} +1 -1
  181. package/dist/assets/use-supports-credentials-settings-bOBG2G_q.js +1 -0
  182. package/dist/assets/{use-transcript-message-by-id-BOP3XXBl.js → use-transcript-message-by-id-5y7epVj4.js} +1 -1
  183. package/dist/assets/{voice-page-DDkZQxjp.js → voice-page-C5VoBU7s.js} +1 -1
  184. package/dist/assets/{wake-detail-panel-DPNf8T83.js → wake-detail-panel-Deb0YI3w.js} +1 -1
  185. package/dist/assets/{weather-forecast-display-D_iG2kOG.js → weather-forecast-display-1oy5xgMD.js} +1 -1
  186. package/dist/assets/{welcome-screen-r3CNzzYe.js → welcome-screen-DdeSuqb2.js} +1 -1
  187. package/dist/assets/{workflow-detail-panel-jIdbzTcE.js → workflow-detail-panel-DyK2JLY7.js} +1 -1
  188. package/dist/assets/{workspace-page-CbV6T1EP.js → workspace-page-DC1A5Uyw.js} +1 -1
  189. package/dist/index.html +2 -2
  190. package/package.json +1 -1
  191. package/dist/assets/add-credits-modal-D1R63dTO.js +0 -1
  192. package/dist/assets/app-qVZ7H8S5.css +0 -2
  193. package/dist/assets/auth-store-BmaCvfnU.js +0 -1
  194. package/dist/assets/avatar-bundled-components-BHf44q7O.js +0 -1
  195. package/dist/assets/checkout-return-target-Dz-38dZC.js +0 -1
  196. package/dist/assets/command-palette-DMiTb-Ud.js +0 -1
  197. package/dist/assets/deploy-dialogs-FZ-JYMiD.js +0 -1
  198. package/dist/assets/document-load-Bm13wXuy.js +0 -1
  199. package/dist/assets/local-mode-BpTRPsBS.js +0 -1
  200. package/dist/assets/native-attachment-pickers-IND4bHK-.js +0 -1
  201. package/dist/assets/native-file-CiF0vSYS.js +0 -1
  202. package/dist/assets/paired-platform-identity-qfs--xiP.js +0 -1
  203. package/dist/assets/password-reset-page-CG9mZNyB.js +0 -1
  204. package/dist/assets/permission-guide-page-BP9-QJDZ.css +0 -1
  205. package/dist/assets/permission-guide-page-wfI4NRCy.js +0 -1
  206. package/dist/assets/plugins-surface-rl9JJ-eO.js +0 -1
  207. package/dist/assets/referral-modal-DORpruE1.js +0 -1
  208. package/dist/assets/routes-Bp2hZ4oy.js +0 -1
  209. package/dist/assets/share-feedback-modal-BJvJvUlE.js +0 -1
  210. package/dist/assets/tool-detail-panel-C20arrZE.js +0 -1
  211. package/dist/assets/use-supports-credentials-settings-B-BKPtKQ.js +0 -1
@@ -1 +1 @@
1
- import{dS as e}from"./app-W5eFKD8y.js";function t(t){let n=typeof window<`u`?window.location.origin:``,r=new URLSearchParams({senderAssistantId:t.senderAssistantId,token:t.token});return`${n}${e.connect}?${r.toString()}`}function n(e){let t=e.get(`senderAssistantId`)?.trim(),n=e.get(`token`)?.trim();return!t||!n?null:{senderAssistantId:t,token:n}}export{n,t};
1
+ import{dS as e}from"./app-BcXqNg4_.js";function t(t){let n=typeof window<`u`?window.location.origin:``,r=new URLSearchParams({senderAssistantId:t.senderAssistantId,token:t.token});return`${n}${e.connect}?${r.toString()}`}function n(e){let t=e.get(`senderAssistantId`)?.trim(),n=e.get(`token`)?.trim();return!t||!n?null:{senderAssistantId:t,token:n}}export{n,t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Eg as t,VC as n,_C as r,fS as i}from"./app-W5eFKD8y.js";import{E as a}from"./vendor-DwMhK7fD.js";import{t as o,x as s}from"./react-B9IgSVeK.js";import{n as c,t as l}from"./app-info-CAPYbfpK.js";var u=e(s(),1),d=o();function f(){let{t:e}=a(),o=t(),[s,f]=(0,u.useState)(null);(0,u.useEffect)(()=>{l().then(f)},[]);let m=s??p;return(0,d.jsxs)(`div`,{className:`flex h-svh w-screen flex-col items-center justify-center bg-background px-8 pt-14 pb-8 text-center text-foreground select-none`,children:[(0,d.jsx)(`h1`,{className:`mt-4 text-2xl font-semibold`,children:m.appName}),(0,d.jsx)(`p`,{className:`text-muted-foreground mt-1 mb-7 text-xs`,children:e(o===`windows`?`aboutPage.taglineWindows`:`aboutPage.taglineMacOS`)}),(0,d.jsxs)(`dl`,{className:`mb-7 grid grid-cols-[auto_auto] gap-x-4 gap-y-1.5 text-sm`,children:[(0,d.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.version`)}),(0,d.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:m.version}),(0,d.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.build`)}),(0,d.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:m.commitSha})]}),(0,d.jsx)(`a`,{href:m.website,className:n(r(),`text-sm`),onClick:e=>{i()&&(e.preventDefault(),c())},children:new URL(m.website).host}),(0,d.jsx)(`div`,{className:`text-muted-foreground mt-auto pt-6 text-[11px]`,children:m.copyright})]})}var p={appName:`Vellum`,version:`—`,commitSha:`—`,copyright:`© ${new Date().getFullYear()} Vellum`,website:`https://vellum.ai`};export{f as AboutPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Eg as t,VC as n,_C as r,fS as i}from"./app-BcXqNg4_.js";import{E as a}from"./vendor-DwMhK7fD.js";import{t as o,x as s}from"./react-B9IgSVeK.js";import{n as c,t as l}from"./app-info-DG4ww7QK.js";var u=e(s(),1),d=o();function f(){let{t:e}=a(),o=t(),[s,f]=(0,u.useState)(null);(0,u.useEffect)(()=>{l().then(f)},[]);let m=s??p;return(0,d.jsxs)(`div`,{className:`flex h-svh w-screen flex-col items-center justify-center bg-background px-8 pt-14 pb-8 text-center text-foreground select-none`,children:[(0,d.jsx)(`h1`,{className:`mt-4 text-2xl font-semibold`,children:m.appName}),(0,d.jsx)(`p`,{className:`text-muted-foreground mt-1 mb-7 text-xs`,children:e(o===`windows`?`aboutPage.taglineWindows`:`aboutPage.taglineMacOS`)}),(0,d.jsxs)(`dl`,{className:`mb-7 grid grid-cols-[auto_auto] gap-x-4 gap-y-1.5 text-sm`,children:[(0,d.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.version`)}),(0,d.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:m.version}),(0,d.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.build`)}),(0,d.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:m.commitSha})]}),(0,d.jsx)(`a`,{href:m.website,className:n(r(),`text-sm`),onClick:e=>{i()&&(e.preventDefault(),c())},children:new URL(m.website).host}),(0,d.jsx)(`div`,{className:`text-muted-foreground mt-auto pt-6 text-[11px]`,children:m.copyright})]})}var p={appName:`Vellum`,version:`—`,commitSha:`—`,copyright:`© ${new Date().getFullYear()} Vellum`,website:`https://vellum.ai`};export{f as AboutPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Jc as t,Ly as n,Yc as r,_h as i,dS as a,fh as o,hh as s,rl as c}from"./app-W5eFKD8y.js";import{E as l}from"./vendor-DwMhK7fD.js";import{n as u,t as d,x as f}from"./react-B9IgSVeK.js";import{r as p,t as m}from"./account-shell-DNS_WdCp.js";var h=e(f(),1),g=d();function _(){let{t:e}=l(`account`),d=s(),f=i(),_=o.use.user(),v=o.use.logout(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(!1),C=async()=>{b(null),S(!0);try{await n(r,t)}catch(t){console.error(`[account] auth flow failed:`,t),b(e(`authErrors.genericFailure`)),S(!1)}};return f?(0,g.jsx)(m,{children:(0,g.jsx)(p,{title:e(`accountPage.loading`)})}):d?(0,g.jsxs)(m,{children:[(0,g.jsx)(p,{title:_?.username?e(`accountPage.signedInTitleNamed`,{name:_.username}):e(`accountPage.signedInTitle`),subtitle:e(`accountPage.signedInSubtitle`)}),(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,g.jsx)(u,{to:a.assistant,className:`inline-flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:e(`accountPage.goToAssistant`)}),(0,g.jsx)(`button`,{type:`button`,onClick:async()=>{await v(),c(a.account.login)},className:`cursor-pointer bg-transparent text-sm font-normal text-[var(--content-secondary)] transition-colors hover:text-[var(--content-default)]`,children:e(`accountPage.signOut`)})]})]}):(0,g.jsxs)(m,{children:[(0,g.jsx)(p,{title:e(`accountPage.welcomeTitle`),subtitle:e(`accountPage.welcomeSubtitle`)}),y&&(0,g.jsx)(`p`,{className:`text-center text-sm text-[var(--system-negative-strong)]`,children:y}),(0,g.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,g.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:x,className:`inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:opacity-50`,children:e(`accountPage.signIn`)})})]})}export{_ as AccountPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Jc as t,Ly as n,Yc as r,_h as i,dS as a,fh as o,hh as s,rl as c}from"./app-BcXqNg4_.js";import{E as l}from"./vendor-DwMhK7fD.js";import{n as u,t as d,x as f}from"./react-B9IgSVeK.js";import{r as p,t as m}from"./account-shell-D0mtEmNE.js";var h=e(f(),1),g=d();function _(){let{t:e}=l(`account`),d=s(),f=i(),_=o.use.user(),v=o.use.logout(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(!1),C=async()=>{b(null),S(!0);try{await n(r,t)}catch(t){console.error(`[account] auth flow failed:`,t),b(e(`authErrors.genericFailure`)),S(!1)}};return f?(0,g.jsx)(m,{children:(0,g.jsx)(p,{title:e(`accountPage.loading`)})}):d?(0,g.jsxs)(m,{children:[(0,g.jsx)(p,{title:_?.username?e(`accountPage.signedInTitleNamed`,{name:_.username}):e(`accountPage.signedInTitle`),subtitle:e(`accountPage.signedInSubtitle`)}),(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,g.jsx)(u,{to:a.assistant,className:`inline-flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:e(`accountPage.goToAssistant`)}),(0,g.jsx)(`button`,{type:`button`,onClick:async()=>{await v(),c(a.account.login)},className:`cursor-pointer bg-transparent text-sm font-normal text-[var(--content-secondary)] transition-colors hover:text-[var(--content-default)]`,children:e(`accountPage.signOut`)})]})]}):(0,g.jsxs)(m,{children:[(0,g.jsx)(p,{title:e(`accountPage.welcomeTitle`),subtitle:e(`accountPage.welcomeSubtitle`)}),y&&(0,g.jsx)(`p`,{className:`text-center text-sm text-[var(--system-negative-strong)]`,children:y}),(0,g.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,g.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:x,className:`inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:opacity-50`,children:e(`accountPage.signIn`)})})]})}export{_ as AccountPage};
@@ -1 +1 @@
1
- import{wC as e}from"./app-W5eFKD8y.js";import{t}from"./react-B9IgSVeK.js";var n=t(),r=(0,n.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,n.jsx)(`path`,{d:`M7.5 15L12.5 10L7.5 5`,stroke:`currentColor`,strokeWidth:`1.67`,strokeLinecap:`round`,strokeLinejoin:`round`})});function i({onSubmit:t,error:i,children:a,submitLabel:o,submittingLabel:s,isSubmitting:c,footer:l}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`form`,{onSubmit:t,className:`flex flex-col gap-4`,children:[i&&(0,n.jsx)(e,{tone:`error`,children:i}),(0,n.jsx)(`div`,{className:`flex flex-col gap-3`,children:a}),(0,n.jsxs)(`button`,{type:`submit`,disabled:c,className:`mt-2 inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:cursor-wait disabled:opacity-50`,children:[c?s:o,r]})]}),l&&(0,n.jsx)(`div`,{className:`mt-8 text-center`,children:l})]})}function a(e){return(0,n.jsx)(`input`,{...e,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] px-4 py-3 text-sm text-[var(--content-default)] outline-none placeholder:text-[var(--content-tertiary)] focus:border-[var(--primary-base)]/50`})}function o({title:e,subtitle:t}){return(0,n.jsxs)(`div`,{className:`mb-8 text-center`,children:[(0,n.jsx)(`h1`,{className:`mb-2 font-serif text-[2rem] font-bold italic text-[var(--content-default)]`,children:e}),t&&(0,n.jsx)(`p`,{className:`text-sm text-[var(--content-secondary)]`,children:t})]})}function s({children:e}){return(0,n.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[var(--surface-base)]`,children:(0,n.jsx)(`div`,{className:`w-full max-w-[480px] px-6`,children:(0,n.jsx)(`div`,{className:`flex flex-col items-center gap-10`,children:(0,n.jsx)(`div`,{className:`w-full`,children:e})})})})}export{a as i,i as n,o as r,s as t};
1
+ import{wC as e}from"./app-BcXqNg4_.js";import{t}from"./react-B9IgSVeK.js";var n=t(),r=(0,n.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,n.jsx)(`path`,{d:`M7.5 15L12.5 10L7.5 5`,stroke:`currentColor`,strokeWidth:`1.67`,strokeLinecap:`round`,strokeLinejoin:`round`})});function i({onSubmit:t,error:i,children:a,submitLabel:o,submittingLabel:s,isSubmitting:c,footer:l}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`form`,{onSubmit:t,className:`flex flex-col gap-4`,children:[i&&(0,n.jsx)(e,{tone:`error`,children:i}),(0,n.jsx)(`div`,{className:`flex flex-col gap-3`,children:a}),(0,n.jsxs)(`button`,{type:`submit`,disabled:c,className:`mt-2 inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:cursor-wait disabled:opacity-50`,children:[c?s:o,r]})]}),l&&(0,n.jsx)(`div`,{className:`mt-8 text-center`,children:l})]})}function a(e){return(0,n.jsx)(`input`,{...e,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] px-4 py-3 text-sm text-[var(--content-default)] outline-none placeholder:text-[var(--content-tertiary)] focus:border-[var(--primary-base)]/50`})}function o({title:e,subtitle:t}){return(0,n.jsxs)(`div`,{className:`mb-8 text-center`,children:[(0,n.jsx)(`h1`,{className:`mb-2 font-serif text-[2rem] font-bold italic text-[var(--content-default)]`,children:e}),t&&(0,n.jsx)(`p`,{className:`text-sm text-[var(--content-secondary)]`,children:t})]})}function s({children:e}){return(0,n.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[var(--surface-base)]`,children:(0,n.jsx)(`div`,{className:`w-full max-w-[480px] px-6`,children:(0,n.jsx)(`div`,{className:`flex flex-col items-center gap-10`,children:(0,n.jsx)(`div`,{className:`w-full`,children:e})})})})}export{a as i,i as n,o as r,s as t};
@@ -1,3 +1,3 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Cr as t,DC as n,Jn as r,LC as i,Nn as a,Qn as o,Sr as s,VC as c,WS as l,Wn as u,Xn as d,Yn as f,bS as p,br as m,xr as h,yC as g}from"./app-W5eFKD8y.js";import{E as _,j as v}from"./vendor-DwMhK7fD.js";import{t as y,x as b}from"./react-B9IgSVeK.js";import{$ as x,$n as S,A as C,Ai as w,Br as T,Cr as E,D,Gi as O,Ha as ee,Ii as te,Ki as ne,Nr as re,P as k,Va as ie,Ya as A,_t as ae,ha as j,kt as oe,mi as M,qi as N,vt as P,zi as F}from"./icons-C0wyat6T.js";import{n as I,r as se,t as L}from"./animated-stat-square-B5bQZZua.js";import{o as ce,t as le}from"./detail-primitives-h0qp0cUk.js";import{t as ue}from"./file-diff-view-CNyqmRCj.js";import{t as de}from"./detail-panel-stop-button-yNAShiP9.js";import{t as fe}from"./status-badge-pill-qGQ5gRiz.js";var pe=A(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),R=e(b(),1),z=``;function B(e,t){switch(e){case`complete`:case`completed`:return`completed`;case`failed`:case`error`:return`error`;case void 0:return t;default:return`running`}}function me(e){return(e.messageId?.startsWith(`local-marker-`)??!1)||(e.content?.startsWith(`↻ Steering: `)??!1)}function V(e){let t=e??``;return t.startsWith(`↻ Steering: `)?t.slice(m.length):t}function H(e){let t=e[e.length-1];t&&(t.kind===`agent`||t.kind===`thinking`)&&!t.isComplete&&(e[e.length-1]={...t,isComplete:!0})}function U(e,t){if(t.updateType===`agent_message_chunk`&&me(t)){H(e),e.push({kind:`user`,id:t.messageId??`steer-${e.length}`,content:V(t.content)});return}switch(t.updateType){case`user_message_chunk`:{let n=t.messageId??z,r=V(t.content),i=e[e.length-1];i&&i.kind===`user`&&i.id===n?e[e.length-1]={...i,content:i.content+r}:(H(e),e.push({kind:`user`,id:n,content:r}));let a=e[e.length-1].content;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.kind===`user`&&n.id.startsWith(`local-marker-`)&&n.content===a){e.splice(t,1);break}}return}case`agent_message_chunk`:{let n=t.messageId??z,r=e[e.length-1];if(r&&r.kind===`agent`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}if(n!==z&&r&&r.kind===`agent`&&r.messageId===z&&!r.isComplete&&r.content===(t.content??``)){e[e.length-1]={...r,messageId:n};return}H(e),e.push({kind:`agent`,messageId:n,content:t.content??``,isComplete:!1});return}case`agent_thought_chunk`:{let n=t.messageId??z,r=e[e.length-1];if(r&&r.kind===`thinking`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}H(e),e.push({kind:`thinking`,messageId:n,content:t.content??``,isComplete:!1});return}case`tool_call`:{let n=t.toolCallId;if(n===void 0)return;H(e),e.push({kind:`tool`,toolCallId:n,title:t.toolTitle??``,toolKind:t.toolKind,status:B(t.toolStatus,`running`),content:t.content,locations:W(t),rawInput:t.rawInput,rawOutput:t.rawOutput});return}case`tool_call_update`:{let n=t.toolCallId;if(n===void 0)return;let r=e.findIndex(e=>e.kind===`tool`&&e.toolCallId===n);if(r===-1)return;let i=e[r],a=W(t);e[r]={...i,title:t.toolTitle??i.title,toolKind:t.toolKind??i.toolKind,status:B(t.toolStatus,i.status),content:t.content??i.content,locations:a??i.locations,rawInput:t.rawInput===void 0?i.rawInput:t.rawInput,rawOutput:t.rawOutput===void 0?i.rawOutput:t.rawOutput};return}case`plan`:{let n=he(t.content);if(n===null)return;let r=e.findIndex(e=>e.kind===`plan`),i={kind:`plan`,entries:n};r===-1?(H(e),e.push(i)):e[r]=i;return}}}function W(e){let t=e.locations;if(!Array.isArray(t))return;let n=[];for(let e of t){let t=e??{};typeof t.path==`string`&&n.push(typeof t.line==`number`?{path:t.path,line:t.line}:{path:t.path})}return n}function he(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=Array.isArray(t)?t:Array.isArray(t?.entries)?t.entries:null;return n===null?null:n.map(e=>{let t=e??{},n=t.content??t.label??``;return{label:typeof n==`string`?n:String(n),checked:t.checked===!0||t.status===`completed`}})}function ge(e){let t=[];for(let n of e)U(t,n);return t}function _e(e,t){if(e===t)return{kind:`identity`};if(e===null)return{kind:`first`};if(t.length<e.length)return{kind:`fallback`};for(let n=0;n<e.length;n++)if(e[n]!==t[n])return n===e.length-1&&t.length===e.length?{kind:`mutate-last`}:{kind:`fallback`};return t.length===e.length?{kind:`identity`}:{kind:`append`,from:e.length}}function ve(){let e=null,t=[];function n(n){return t=ge(n),e=n,t}function r(r){let i=_e(e,r);switch(i.kind){case`identity`:return t;case`first`:return n(r);case`append`:{let n=t.slice();for(let e=i.from;e<r.length;e++)U(n,r[e]);return e=r,t=n,t}case`mutate-last`:case`fallback`:return n(r)}}return{project:r}}function ye(e){let t=(0,R.useRef)(null);return t.current??=ve(),t.current.project(e)}function G(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{let t=e.trimStart();return t.startsWith(`{`)||t.startsWith(`[`)?[]:[{type:`content`,text:e}]}let n=Array.isArray(t)?t:[t],r=[];for(let e of n){let t=be(e);t&&r.push(t)}return r}function be(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`content`:return{type:`content`,text:xe(t.content)};case`diff`:return typeof t.path!=`string`||typeof t.newText!=`string`?null:{type:`diff`,path:t.path,newText:t.newText,...typeof t.oldText==`string`?{oldText:t.oldText}:{}};case`terminal`:{let e=Se(t);return e===void 0?{type:`terminal`}:{type:`terminal`,text:e}}default:return null}}function xe(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.text;if(typeof t==`string`)return t}return``}function Se(e){if(typeof e.text==`string`)return e.text;if(typeof e.output==`string`)return e.output;if(typeof e.content==`string`)return e.content;if(typeof e.content==`object`&&e.content!==null){let t=e.content.text;if(typeof t==`string`)return t}}function K(e){if(typeof e!=`object`||!e)return;let t=e.command;return typeof t==`string`?t:void 0}function q(e){return G(e).filter(e=>e.type===`content`||e.type===`terminal`).map(e=>`text`in e?e.text??``:``).filter(e=>e.length>0).join(`
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Cr as t,DC as n,Jn as r,LC as i,Nn as a,Qn as o,Sr as s,VC as c,WS as l,Wn as u,Xn as d,Yn as f,bS as p,br as m,xr as h,yC as g}from"./app-BcXqNg4_.js";import{E as _,j as v}from"./vendor-DwMhK7fD.js";import{t as y,x as b}from"./react-B9IgSVeK.js";import{$ as x,$n as S,A as C,Ai as w,Br as T,Cr as E,D,Gi as O,Ha as ee,Ii as te,Ki as ne,Nr as re,P as k,Va as ie,Ya as A,_t as ae,ha as j,kt as oe,mi as M,qi as N,vt as P,zi as F}from"./icons-C0wyat6T.js";import{n as I,r as se,t as L}from"./animated-stat-square-BwJ3jZTp.js";import{o as ce,t as le}from"./detail-primitives-DV1LUqyp.js";import{t as ue}from"./file-diff-view-Vu0BVUBc.js";import{t as de}from"./detail-panel-stop-button-BXHcz4Ub.js";import{t as fe}from"./status-badge-pill-qGQ5gRiz.js";var pe=A(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),R=e(b(),1),z=``;function B(e,t){switch(e){case`complete`:case`completed`:return`completed`;case`failed`:case`error`:return`error`;case void 0:return t;default:return`running`}}function me(e){return(e.messageId?.startsWith(`local-marker-`)??!1)||(e.content?.startsWith(`↻ Steering: `)??!1)}function V(e){let t=e??``;return t.startsWith(`↻ Steering: `)?t.slice(m.length):t}function H(e){let t=e[e.length-1];t&&(t.kind===`agent`||t.kind===`thinking`)&&!t.isComplete&&(e[e.length-1]={...t,isComplete:!0})}function U(e,t){if(t.updateType===`agent_message_chunk`&&me(t)){H(e),e.push({kind:`user`,id:t.messageId??`steer-${e.length}`,content:V(t.content)});return}switch(t.updateType){case`user_message_chunk`:{let n=t.messageId??z,r=V(t.content),i=e[e.length-1];i&&i.kind===`user`&&i.id===n?e[e.length-1]={...i,content:i.content+r}:(H(e),e.push({kind:`user`,id:n,content:r}));let a=e[e.length-1].content;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.kind===`user`&&n.id.startsWith(`local-marker-`)&&n.content===a){e.splice(t,1);break}}return}case`agent_message_chunk`:{let n=t.messageId??z,r=e[e.length-1];if(r&&r.kind===`agent`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}if(n!==z&&r&&r.kind===`agent`&&r.messageId===z&&!r.isComplete&&r.content===(t.content??``)){e[e.length-1]={...r,messageId:n};return}H(e),e.push({kind:`agent`,messageId:n,content:t.content??``,isComplete:!1});return}case`agent_thought_chunk`:{let n=t.messageId??z,r=e[e.length-1];if(r&&r.kind===`thinking`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}H(e),e.push({kind:`thinking`,messageId:n,content:t.content??``,isComplete:!1});return}case`tool_call`:{let n=t.toolCallId;if(n===void 0)return;H(e),e.push({kind:`tool`,toolCallId:n,title:t.toolTitle??``,toolKind:t.toolKind,status:B(t.toolStatus,`running`),content:t.content,locations:W(t),rawInput:t.rawInput,rawOutput:t.rawOutput});return}case`tool_call_update`:{let n=t.toolCallId;if(n===void 0)return;let r=e.findIndex(e=>e.kind===`tool`&&e.toolCallId===n);if(r===-1)return;let i=e[r],a=W(t);e[r]={...i,title:t.toolTitle??i.title,toolKind:t.toolKind??i.toolKind,status:B(t.toolStatus,i.status),content:t.content??i.content,locations:a??i.locations,rawInput:t.rawInput===void 0?i.rawInput:t.rawInput,rawOutput:t.rawOutput===void 0?i.rawOutput:t.rawOutput};return}case`plan`:{let n=he(t.content);if(n===null)return;let r=e.findIndex(e=>e.kind===`plan`),i={kind:`plan`,entries:n};r===-1?(H(e),e.push(i)):e[r]=i;return}}}function W(e){let t=e.locations;if(!Array.isArray(t))return;let n=[];for(let e of t){let t=e??{};typeof t.path==`string`&&n.push(typeof t.line==`number`?{path:t.path,line:t.line}:{path:t.path})}return n}function he(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=Array.isArray(t)?t:Array.isArray(t?.entries)?t.entries:null;return n===null?null:n.map(e=>{let t=e??{},n=t.content??t.label??``;return{label:typeof n==`string`?n:String(n),checked:t.checked===!0||t.status===`completed`}})}function ge(e){let t=[];for(let n of e)U(t,n);return t}function _e(e,t){if(e===t)return{kind:`identity`};if(e===null)return{kind:`first`};if(t.length<e.length)return{kind:`fallback`};for(let n=0;n<e.length;n++)if(e[n]!==t[n])return n===e.length-1&&t.length===e.length?{kind:`mutate-last`}:{kind:`fallback`};return t.length===e.length?{kind:`identity`}:{kind:`append`,from:e.length}}function ve(){let e=null,t=[];function n(n){return t=ge(n),e=n,t}function r(r){let i=_e(e,r);switch(i.kind){case`identity`:return t;case`first`:return n(r);case`append`:{let n=t.slice();for(let e=i.from;e<r.length;e++)U(n,r[e]);return e=r,t=n,t}case`mutate-last`:case`fallback`:return n(r)}}return{project:r}}function ye(e){let t=(0,R.useRef)(null);return t.current??=ve(),t.current.project(e)}function G(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{let t=e.trimStart();return t.startsWith(`{`)||t.startsWith(`[`)?[]:[{type:`content`,text:e}]}let n=Array.isArray(t)?t:[t],r=[];for(let e of n){let t=be(e);t&&r.push(t)}return r}function be(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`content`:return{type:`content`,text:xe(t.content)};case`diff`:return typeof t.path!=`string`||typeof t.newText!=`string`?null:{type:`diff`,path:t.path,newText:t.newText,...typeof t.oldText==`string`?{oldText:t.oldText}:{}};case`terminal`:{let e=Se(t);return e===void 0?{type:`terminal`}:{type:`terminal`,text:e}}default:return null}}function xe(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.text;if(typeof t==`string`)return t}return``}function Se(e){if(typeof e.text==`string`)return e.text;if(typeof e.output==`string`)return e.output;if(typeof e.content==`string`)return e.content;if(typeof e.content==`object`&&e.content!==null){let t=e.content.text;if(typeof t==`string`)return t}}function K(e){if(typeof e!=`object`||!e)return;let t=e.command;return typeof t==`string`?t:void 0}function q(e){return G(e).filter(e=>e.type===`content`||e.type===`terminal`).map(e=>`text`in e?e.text??``:``).filter(e=>e.length>0).join(`
2
2
  `)}function J(e){if(e!=null){if(typeof e==`string`)return e;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}}function Y(e,t){let n=new Map;for(let t of e)t.type===`diff`&&n.set(t.path,{path:t.path,newText:t.newText,...t.oldText===void 0?{}:{oldText:t.oldText}});for(let e of t??[])n.has(e.path)||n.set(e.path,{path:e.path});return Array.from(n.values())}var X=y();function Z({content:e,isComplete:t,assistantId:n}){return(0,X.jsxs)(`div`,{"data-testid":`acp-chat-agent-message`,className:`flex w-full flex-col items-start text-chat text-[var(--content-default)]`,children:[(0,X.jsx)(a,{content:e,assistantId:n}),!t&&(0,X.jsx)(u,{className:`mt-1`,"data-testid":`acp-chat-agent-streaming`})]})}function Ce({entries:e}){let{t}=_(`chat`);return e.length===0?null:(0,X.jsxs)(`div`,{"data-testid":`acp-chat-plan-block`,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-[var(--content-tertiary)]`,children:[(0,X.jsx)(S,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(n,{variant:`body-small-emphasised`,className:`text-inherit`,children:t(`acpChatPlanBlock.plan`)})]}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.map((e,t)=>(0,X.jsxs)(`li`,{"data-testid":`acp-chat-plan-entry`,"data-checked":e.checked,className:`flex items-start gap-2`,children:[e.checked?(0,X.jsx)(F,{"aria-hidden":!0,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}):(0,X.jsx)(w,{"aria-hidden":!0,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-disabled)]`}),(0,X.jsx)(`span`,{className:e.checked?`text-body-small-default text-[var(--content-tertiary)] line-through`:`text-body-small-default text-[var(--content-default)]`,children:e.label})]},t))})]})}function we(e){switch(e){case`max_tokens`:case`max_turn_requests`:return v(`chat:acpChatTerminalBlock.stoppedLimitReached`);case`refusal`:return v(`chat:acpChatTerminalBlock.refused`);case`cancelled`:return v(`chat:acpChatTerminalBlock.cancelled`);default:return v(`chat:acpChatTerminalBlock.completed`)}}function Te(e){return new Date(e).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function Q({completedAt:e}){let{t}=_(`chat`);return e===void 0?null:(0,X.jsx)(`span`,{"data-testid":`acp-chat-terminal-time`,children:t(`acpChatTerminalBlock.atTime`,{time:Te(e)})})}function Ee({status:e,stopReason:n,error:r,completedAt:i}){let{t:a}=_(`chat`);if(t(e))return null;if(e===`failed`)return(0,X.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`failed`,className:`flex items-start gap-2 rounded-md bg-[var(--system-negative-weak)] px-3 py-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,"data-testid":`acp-chat-terminal-failed-icon`,className:`flex h-[12px] w-4 shrink-0 items-center justify-center`,children:(0,X.jsx)(D,{className:`h-4 w-4`})}),(0,X.jsx)(`span`,{children:r??a(`acpChatTerminalBlock.runFailed`)})]});if(e===`cancelled`)return(0,X.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`cancelled`,className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,X.jsx)(te,{"aria-hidden":!0,className:`h-4 w-4 shrink-0`}),(0,X.jsx)(`span`,{children:a(`acpChatTerminalBlock.cancelled`)}),(0,X.jsx)(Q,{completedAt:i})]});let o=we(n);return(0,X.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`completed`,className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,X.jsx)(F,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,X.jsx)(`span`,{children:o}),(0,X.jsx)(Q,{completedAt:i})]})}function De({showDot:e,isLast:t,children:n}){return(0,X.jsxs)(`div`,{className:`relative flex items-start gap-2${t?``:` pb-4`}`,children:[!t&&(0,X.jsx)(`div`,{"aria-hidden":!0,className:`absolute bottom-0 left-[6.5px] w-px bg-[var(--border-element)] ${e?`top-[16px]`:`top-0`}`}),e?(0,X.jsx)(`span`,{"aria-hidden":!0,"data-testid":`acp-chat-timeline-dot`,className:`flex h-[14px] w-[14px] shrink-0 items-center justify-center`,children:(0,X.jsx)(`span`,{className:`h-[5px] w-[5px] rounded-full bg-[var(--content-disabled)]`})}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-[14px] w-[14px] shrink-0`}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:n})]})}function Oe({content:e,isComplete:t,assistantId:n}){let[r,i]=(0,R.useState)(null),o=r??!t,s=e.trim().length>0,c=t?`Thought process`:`Thinking`,l=t?(0,X.jsx)(j,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,X.jsx)(u,{dotSize:5,className:`shrink-0`,"data-testid":`acp-chat-thinking-streaming`});return s?(0,X.jsxs)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":o,onClick:()=>i(!o),"data-testid":`acp-chat-thinking-toggle`,className:`flex w-full items-center gap-1.5 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)]`,children:[o?(0,X.jsx)(N,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,X.jsx)(O,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),l,(0,X.jsx)(`span`,{children:c})]}),o&&(0,X.jsx)(`div`,{"data-testid":`acp-chat-thinking-body`,className:`mt-1.5 border-l-2 border-[var(--border-base)] pl-3 text-body-small-default text-[var(--content-tertiary)]`,children:(0,X.jsx)(a,{content:e,assistantId:n})})]}):(0,X.jsx)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:[l,(0,X.jsx)(`span`,{children:c})]})})}var ke={running:`neutral`,completed:`positive`,error:`negative`,ended:`neutral`},Ae={running:`Running`,completed:`Completed`,error:`Failed`,ended:`Ended`},je={read:`Read file`,edit:`Edit file`,delete:`Delete file`,move:`Move file`,search:`Search`,execute:`Run command`,think:`Thinking`,fetch:`Fetch`,switch_mode:`Switch mode`},Me=`Tool call`,Ne={read:T,edit:pe,delete:C,move:re,search:P,execute:k,think:j,fetch:E,switch_mode:oe},Pe=new Set([`read`,`edit`,`delete`,`move`]);function Fe({toolKind:e}){return(0,X.jsx)(e&&Ne[e]||M,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`})}function $({label:e,value:t,testId:n}){return(0,X.jsxs)(`div`,{"data-testid":n,children:[(0,X.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-tertiary)]`,children:e}),(0,X.jsx)(`pre`,{className:`max-h-60 overflow-auto rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] p-2.5 font-mono text-body-small-default text-[var(--content-secondary)]`,children:t})]})}function Ie({block:e,isTerminal:t=!1,onOpenDiff:r,onOpenOutput:i}){let{t:a}=_(`chat`),[o,s]=(0,R.useState)(!1),c=(0,R.useMemo)(()=>G(e.content),[e.content]),l=(0,R.useMemo)(()=>q(e.content),[e.content]),d=(0,R.useMemo)(()=>l.split(`
3
3
  `).map(e=>e.trim()).find(e=>e.length>0&&!e.startsWith("```"))||`View output`,[l]),f=(0,R.useMemo)(()=>Y(c,e.locations),[c,e.locations]),p=t&&e.status===`running`?`ended`:e.status,m=p===`running`,h=e.toolKind&&je[e.toolKind]||Me,v=K(e.rawInput)??e.title,y=v&&v!==h&&(!Pe.has(e.toolKind??``)||f.length===0)?v:null,b=J(e.rawInput),x=J(e.rawOutput),S=b!==void 0||x!==void 0;return(0,X.jsxs)(`div`,{"data-testid":`acp-chat-tool-card`,"data-status":e.status,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Fe,{toolKind:e.toolKind}),(0,X.jsx)(n,{variant:`body-small-emphasised`,className:`min-w-0 flex-1 truncate text-[var(--content-default)]`,title:e.title,children:h}),(0,X.jsx)(g,{tone:ke[p],"data-testid":`acp-chat-tool-status`,children:Ae[p]}),m&&(0,X.jsx)(u,{className:`shrink-0`,"data-testid":`acp-chat-tool-running`})]}),y&&(0,X.jsx)(`div`,{"data-testid":`acp-chat-tool-detail`,className:`mt-1.5 font-mono text-body-small-default whitespace-pre-wrap break-words text-[var(--content-secondary)]`,children:y}),f.length>0&&(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:f.map(t=>{let n=t.oldText!==void 0||t.newText!==void 0,i=`flex max-w-full items-center gap-1.5 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-2 py-1 text-body-small-default text-[var(--content-secondary)]`;return n?(0,X.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-file-chip`,onClick:()=>r(e.toolCallId,t),title:t.path,className:`${i} cursor-pointer transition-colors hover:bg-[var(--surface-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--ring)]`,children:[(0,X.jsx)(T,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate font-mono`,children:t.path})]},t.path):(0,X.jsxs)(`span`,{"data-testid":`acp-chat-tool-file-ref`,title:t.path,className:i,children:[(0,X.jsx)(T,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate font-mono`,children:t.path})]},t.path)})}),l.length>0&&(0,X.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-output-open`,onClick:()=>i?.(e.toolCallId),className:`mt-2 flex w-full items-center gap-2 rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--surface-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--ring)]`,children:[(0,X.jsx)(k,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-body-small-default text-[var(--content-secondary)]`,children:d}),(0,X.jsx)(O,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`})]}),S&&(0,X.jsxs)(`div`,{className:`mt-2`,"data-testid":`acp-chat-tool-raw`,children:[(0,X.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-raw-toggle`,"aria-expanded":o,onClick:()=>s(e=>!e),className:`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-default)]`,children:[o?(0,X.jsx)(N,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,X.jsx)(O,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{children:a(o?`acpChatToolCard.hideRaw`:`acpChatToolCard.showRaw`)})]}),o&&(0,X.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-2`,children:[b!==void 0&&(0,X.jsx)($,{label:a(`acpChatToolCard.rawInput`),value:b,testId:`acp-chat-tool-raw-input`}),x!==void 0&&(0,X.jsx)($,{label:a(`acpChatToolCard.rawOutput`),value:x,testId:`acp-chat-tool-raw-output`})]})]})]})}function Le({content:e}){return(0,X.jsx)(`div`,{"data-testid":`acp-chat-user-turn`,className:`flex w-full justify-end`,children:(0,X.jsx)(`div`,{className:`max-w-[80%] rounded-lg bg-[var(--surface-lift)] px-4 py-3 whitespace-pre-wrap text-chat text-[var(--content-default)]`,children:e})})}function Re({model:e,options:t}){let{t:n}=_(`chat`),r=t?.find(t=>t.value===e)?.label??e;return(0,X.jsx)(l,{icon:(0,X.jsx)(x,{}),value:r,label:n(`acpRunChatView.modelLabel`)})}function ze({content:e,assistantId:t}){return(0,X.jsx)(`div`,{"data-testid":`acp-chat-command-output`,className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3 [&_pre]:!max-h-none`,children:(0,X.jsx)(a,{content:q(e),hardLineBreaks:!0,assistantId:t})})}var Be=80;function Ve(e){return e.scrollHeight-e.clientHeight-e.scrollTop<=Be}function He(e){let t=(0,R.useRef)(null),n=(0,R.useRef)(!0),[r,i]=(0,R.useState)(!1),a=(0,R.useCallback)(()=>{let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[]),o=(0,R.useCallback)(()=>{let e=t.current;if(!e)return;let r=Ve(e);n.current=r,i(e=>e===!r?e:!r)},[]),s=(0,R.useCallback)(()=>{n.current=!0,a(),i(!1)},[a]),c=(0,R.useCallback)(e=>{let r=t.current;r&&r.removeEventListener(`scroll`,o),t.current=e,e&&(e.addEventListener(`scroll`,o,{passive:!0}),n.current?e.scrollTop=e.scrollHeight:o())},[o]);return(0,R.useLayoutEffect)(()=>{n.current?a():o()},[e,a,o]),{scrollRef:c,showScrollToLatest:r,scrollToLatest:s}}function Ue(e,t){switch(e.kind){case`user`:return`user-${e.id||t}`;case`agent`:return`agent-${e.messageId||t}`;case`thinking`:return`thinking-${e.messageId||t}`;case`tool`:return`tool-${e.toolCallId}`;case`plan`:return`plan`}}var We=[];function Ge({entry:e,onClose:r,assistantId:a}){let{t:o}=_(`chat`),s=t(e.status),{model:l}=e,u=e.inputTokens!==void 0||e.outputTokens!==void 0,d=ye(h(t=>t.byId[e.acpSessionId]?.events??We)),[f,p]=(0,R.useState)(null),[m,g]=(0,R.useState)(e.acpSessionId);m!==e.acpSessionId&&(g(e.acpSessionId),p(null));let v=(0,R.useCallback)((e,t)=>p({kind:`diff`,toolCallId:e,path:t.path}),[]),y=(0,R.useCallback)(e=>p({kind:`output`,toolCallId:e}),[]),b=(0,R.useCallback)(()=>p(null),[]),x=(0,R.useMemo)(()=>f?d.find(e=>e.kind===`tool`&&e.toolCallId===f.toolCallId)??null:null,[f,d]),S=(0,R.useMemo)(()=>f?.kind!==`diff`||!x?null:Y(G(x.content),x.locations).find(e=>e.path===f.path)??null,[f,x]),C=f?.kind===`diff`?f.path:x?K(x.rawInput)??x.title??`Output`:`Output`,{scrollRef:w,showScrollToLatest:T,scrollToLatest:E}=He((0,R.useMemo)(()=>({blocks:d,status:e.status,completedAt:e.completedAt}),[d,e.status,e.completedAt])),D=!s;return(0,X.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden rounded-xl bg-[var(--surface-lift)]`,children:[f&&(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--border-hover)] px-5 py-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:b,title:e.agent,className:`min-w-0 shrink cursor-pointer truncate text-left text-[var(--content-default)] hover:underline`,children:(0,X.jsx)(n,{variant:`body-small-default`,as:`span`,children:e.agent})}),(0,X.jsx)(O,{className:`h-2.5 w-2.5 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,X.jsx)(n,{variant:`body-small-default`,as:`span`,title:C,className:`min-w-0 shrink truncate font-mono text-[var(--content-secondary)]`,children:C})]}),(0,X.jsx)(Ke,{entry:e,isRunning:s,onClose:r,showBack:!!f,onBack:b},`header-${e.acpSessionId}`),f?(0,X.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-5`,children:f.kind===`diff`?(0,X.jsx)(ue,{path:f.path,oldText:S?.oldText,newText:S?.newText}):(0,X.jsx)(ze,{content:x?.content,assistantId:a})}):(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,X.jsxs)(`div`,{ref:w,"data-testid":`acp-chat-conversation`,className:`flex h-full flex-col gap-4 overflow-y-auto px-5 py-5`,children:[(u||l!==void 0)&&(0,X.jsxs)(`div`,{className:c(`grid gap-3`,u?`grid-cols-2`:`grid-cols-1`),"data-testid":`acp-run-metrics`,children:[u&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{icon:(0,X.jsx)(ee,{}),target:e.inputTokens??0,format:e=>I(Math.round(e)),label:o(`acpRunChatView.inputLabel`)}),(0,X.jsx)(L,{icon:(0,X.jsx)(se,{}),target:e.outputTokens??0,format:e=>I(Math.round(e)),label:o(`acpRunChatView.outputLabel`)})]}),l!==void 0&&(0,X.jsx)(`div`,{className:u?`col-span-2`:void 0,children:(0,X.jsx)(Re,{model:l,options:e.availableModels})})]}),(0,X.jsx)(qe,{task:e.task},`objective-${e.acpSessionId}`),(0,X.jsx)(`div`,{className:`flex flex-col`,"data-testid":`acp-chat-timeline`,children:d.map((e,t)=>(0,X.jsx)(De,{showDot:t===0||t===d.length-1||e.kind===`tool`||e.kind===`plan`,isLast:t===d.length-1,children:(0,X.jsx)(Je,{block:e,isTerminal:D,onOpenDiff:v,onOpenOutput:y,assistantId:a})},Ue(e,t)))}),!s&&(0,X.jsx)(Ee,{status:e.status,stopReason:e.stopReason,error:e.error,completedAt:e.completedAt})]}),T&&(0,X.jsx)(i,{shape:`pill`,variant:`outlined`,size:`compact`,iconOnly:(0,X.jsx)(ie,{}),onClick:E,"aria-label":o(`acpRunChatView.goToNewest`),tooltip:o(`acpRunChatView.goToNewest`),"data-testid":`acp-chat-scroll-to-latest`,className:`absolute bottom-3 left-1/2 -translate-x-1/2 shadow-md`})]}),s&&!f&&(0,X.jsx)(Ye,{acpSessionId:e.acpSessionId},`steer-${e.acpSessionId}`)]})}function Ke({entry:e,isRunning:t,onClose:n,showBack:r=!1,onBack:a}){let{t:c}=_(`chat`),[l,u]=(0,R.useState)(!1),m=s(e.status,e.stopReason),h=(0,R.useCallback)(()=>{u(!0),f(e.acpSessionId).catch(e=>{u(!1),p(e,{context:`AcpRunChatView.stop`})})},[e.acpSessionId]);return(0,X.jsx)(o,{icon:(0,X.jsxs)(X.Fragment,{children:[r&&(0,X.jsx)(i,{variant:`outlined`,iconOnly:(0,X.jsx)(ne,{}),onClick:a,"aria-label":c(`acpRunChatView.backToConversationAria`),tooltip:c(`acpRunChatView.backTooltip`),"data-testid":`acp-chat-diff-back`,className:`shrink-0`}),(0,X.jsx)(d,{agent:e.agent,className:`h-5 w-5 shrink-0`})]}),title:e.agent,headerTrailing:(0,X.jsx)(fe,{color:m.color,label:m.label}),headerActions:t?(0,X.jsx)(de,{onStop:h,ariaLabel:c(`acpRunChatView.stopRunAria`),disabled:l}):void 0,closeLabel:c(`acpRunChatView.closeRunDetail`),onClose:n})}function qe({task:e}){let{t}=_(`chat`);return e?(0,X.jsxs)(`div`,{"data-testid":`acp-chat-objective`,children:[(0,X.jsx)(ce,{as:`h3`,children:t(`acpRunChatView.objective`)}),(0,X.jsx)(le,{label:t(`acpRunChatView.objective`),children:(0,X.jsx)(n,{variant:`body-medium-lighter`,as:`p`,className:`whitespace-pre-wrap break-words leading-relaxed text-[var(--content-default)]`,children:e})}),(0,X.jsx)(`div`,{className:`mt-4 h-px w-full bg-[var(--border-hover)]`})]}):null}function Je({block:e,isTerminal:t,onOpenDiff:n,onOpenOutput:r,assistantId:i}){switch(e.kind){case`user`:return(0,X.jsx)(Le,{content:e.content});case`agent`:return(0,X.jsx)(Z,{content:e.content,isComplete:e.isComplete||t,assistantId:i});case`thinking`:return(0,X.jsx)(Oe,{content:e.content,isComplete:e.isComplete||t,assistantId:i});case`tool`:return(0,X.jsx)(Ie,{block:e,isTerminal:t,onOpenDiff:n,onOpenOutput:r});case`plan`:return(0,X.jsx)(Ce,{entries:e.entries})}}function Ye({acpSessionId:e}){let{t}=_(`chat`),[n,a]=(0,R.useState)(``),[o,s]=(0,R.useState)(!1);return(0,X.jsx)(`form`,{onSubmit:(0,R.useCallback)(t=>{t.preventDefault();let i=n.trim();if(!i||o)return;s(!0);let c=h.getState().appendLocalMarker({acpSessionId:e,content:`${m}${i}`});r(e,i).then(()=>a(``)).catch(t=>{c&&h.getState().removeLocalMarker({acpSessionId:e,markerId:c}),p(t,{context:`AcpRunChatView.steer`})}).finally(()=>s(!1))},[n,o,e]),"data-testid":`acp-chat-steer-form`,className:`sticky bottom-0 z-10 shrink-0 border-t border-[var(--border-hover)] bg-[var(--surface-lift)] px-5 py-3`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-[var(--surface-base)] px-3 py-2`,children:[(0,X.jsx)(`input`,{type:`text`,value:n,onChange:e=>a(e.target.value),placeholder:t(`acpRunChatView.steerPlaceholder`),disabled:o,"aria-label":t(`acpRunChatView.steerAria`),className:`text-body-medium-default min-w-0 flex-1 bg-transparent text-[color:var(--content-default)] placeholder:text-[color:var(--content-tertiary)] focus:outline-none disabled:opacity-50`}),(0,X.jsx)(i,{type:`submit`,variant:`primary`,size:`compact`,iconOnly:(0,X.jsx)(ae,{}),disabled:o||n.trim()===``,"aria-label":t(`acpRunChatView.sendSteerAria`),className:`shrink-0`})]})})}function Xe({entry:e,onClose:t,assistantId:n}){return(0,X.jsx)(Ge,{entry:e,onClose:t,assistantId:n})}export{Xe as AcpRunDetailPanel};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Fi as t,Ii as n,Kb as r,Pi as i,Wl as a,a as o,c as s,d as c,dS as l,s as u}from"./app-W5eFKD8y.js";import{E as d}from"./vendor-DwMhK7fD.js";import{f,r as p,t as m,x as h}from"./react-B9IgSVeK.js";var g=e(h(),1),_=m();function v(){let e=f(),{t:m}=d(`activation`),h=r.use.activeAssistantId(),v=i(),y=n(),{data:b}=t(),{starters:x,items:S}=c(v??``),{launch:C,pendingTaskIds:w}=s(v??``),T=(0,g.useMemo)(()=>[...x,...S],[x,S]),E=(0,g.useCallback)(async t=>{u(await C(t),m,t=>{a(e,t)})},[C,e,m]);return v===null?y?(0,_.jsx)(p,{to:l.assistant,replace:!0}):null:(0,_.jsx)(o,{tasks:T,progress:b?.tasks,pendingTaskIds:w,onLaunch:e=>{E(e)},onOpenConversation:t=>{a(e,t)},assistantId:h??void 0})}export{v as ActivationListRoute};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Fi as t,Ii as n,Kb as r,Pi as i,Wl as a,a as o,c as s,d as c,dS as l,s as u}from"./app-BcXqNg4_.js";import{E as d}from"./vendor-DwMhK7fD.js";import{f,r as p,t as m,x as h}from"./react-B9IgSVeK.js";var g=e(h(),1),_=m();function v(){let e=f(),{t:m}=d(`activation`),h=r.use.activeAssistantId(),v=i(),y=n(),{data:b}=t(),{starters:x,items:S}=c(v??``),{launch:C,pendingTaskIds:w}=s(v??``),T=(0,g.useMemo)(()=>[...x,...S],[x,S]),E=(0,g.useCallback)(async t=>{u(await C(t),m,t=>{a(e,t)})},[C,e,m]);return v===null?y?(0,_.jsx)(p,{to:l.assistant,replace:!0}):null:(0,_.jsx)(o,{tasks:T,progress:b?.tasks,pendingTaskIds:w,onLaunch:e=>{E(e)},onOpenConversation:t=>{a(e,t)},assistantId:h??void 0})}export{v as ActivationListRoute};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{dS as t}from"./app-W5eFKD8y.js";import{d as n,f as r,x as i}from"./react-B9IgSVeK.js";var a=e(i(),1);function o(){let e=r(),{search:i,hash:o}=n();return(0,a.useEffect)(()=>{e(`${t.assistant}${i}${o}`,{replace:!0})},[e,i,o]),null}export{o as ActivityRedirectPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{dS as t}from"./app-BcXqNg4_.js";import{d as n,f as r,x as i}from"./react-B9IgSVeK.js";var a=e(i(),1);function o(){let e=r(),{search:i,hash:o}=n();return(0,a.useEffect)(()=>{e(`${t.assistant}${i}${o}`,{replace:!0})},[e,i,o]),null}export{o as ActivityRedirectPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{At as t,Ct as n,Dr as r,Er as i,Et as a,Ft as o,Gr as s,Hn as c,In as l,It as u,Jr as d,Jt as f,Kr as p,Ks as m,Kt as h,LC as g,Lt as _,Qt as v,Rt as y,St as b,Tn as x,Xh as ee,Xr as S,Yh as C,Yt as w,Zn as T,Zt as E,_t as te,cv as D,gt as ne,mi as O,nu as k,qr as A,tr as j,vt as M,wh as N,wt as P,xr as F,xt as I,yt as L}from"./app-W5eFKD8y.js";import{E as R}from"./vendor-DwMhK7fD.js";import{t as z,x as B}from"./react-B9IgSVeK.js";import{Ki as V,Yn as H}from"./icons-C0wyat6T.js";import{t as U}from"./use-transcript-message-by-id-BOP3XXBl.js";import{l as W,n as G,o as K,t as q}from"./tool-detail-panel-BlOCSMcV.js";import{n as J,t as Y}from"./step-detail-header-DMOQu3fY.js";var X=e(B(),1),Z=z();function re({assistantId:e,image:t,title:n,ariaLabel:r,onPreview:i}){let a=(0,X.useRef)(null),{url:o,isError:s,isPending:l}=c(e,t,u(a)||typeof IntersectionObserver>`u`),[d,f]=(0,X.useState)(null);(0,X.useEffect)(()=>{f(null)},[t.id,t.previewUrl]);let p=o===d?null:o,m=l?null:{...t,previewUrl:p??null};return(0,Z.jsx)(`div`,{ref:a,"data-testid":`activity-screenshot-tile`,"data-tool-call-id":t.toolCallId,children:(0,Z.jsx)(h,{attachment:m,placeholder:s?null:(0,Z.jsx)(H,{className:`h-6 w-6 animate-spin`,"aria-hidden":`true`}),labels:{title:n,ariaLabel:r,secondary:null},hideCaptions:!0,onPreview:()=>i(a.current?.firstElementChild instanceof HTMLElement?a.current.firstElementChild:null),onPreviewError:()=>f(o)})})}function ie(e,t){return e[t]?.type===`activity`&&t===e.length-1}function ae(e,t){let n=t.at(-1);if(!n)return!1;let r=new Set(N(n));return N(e).some(e=>r.has(e))}function oe(e,t,n){if(!n)return e[t]?.type===`activity`?t:null;let r=t=>{let r=e[t];return!r||r.type!==`activity`?!1:p(r.items).toolCalls.some(e=>e.id===n)};if(r(t))return t;let i=e.findIndex((e,t)=>r(t));return i===-1?null:i}function se(e,t,n){let r=w(t,n.workflow),i=e=>{let t=v(e,n.workflow.byToolUseId);if(t!==null&&r.has(t))return!0;let i=f(e,n.acpByToolUseId);if(i!==null&&n.acpById[i]!==void 0)return!0;let a=E(e);return a!==void 0&&n.backgroundTaskById[a]!==void 0},a=t.filter(e=>!i(e));if(a.length===t.length)return{items:e,toolCalls:t};let o=new Set(a.map(e=>e.id));return{items:e.filter(e=>e.kind!==`toolCall`||o.has(e.toolCall.id)),toolCalls:a}}function ce(e,t,n){let a=U(e),o=i(),s=x(),c=k.use.byId(),l=k.use.byToolUseId(),u=k.use.notFoundRunIds(),f=k.use.hydrationFailedRunIds(),m=F.use.byId(),h=F.use.byToolUseId(),g=r.use.byId();return(0,X.useMemo)(()=>{if(!a||t==null)return null;let e=A(a.contentBlocks??[],d(a,s)),r=oe(e,t,n);if(r==null)return null;let i=e[r];if(!i||i.type!==`activity`)return null;let{cardItems:_,toolCalls:v}=p(i.items);return{...se(_,v,{workflow:{byId:c,byToolUseId:l,notFoundRunIds:u,hydrationFailedRunIds:f},acpById:m,acpByToolUseId:h,backgroundTaskById:g}),isLastGroup:ie(e,r),isLatestMessage:ae(a,o),groupIndex:r}},[a,o,t,n,s,c,l,u,f,m,h,g])}var le=60;function Q(e,t){return $(e,t.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]))}function $(e,t,n=y){let r=new Set(t),i=new Set(e.filter(e=>r.has(e.id)&&D(e.name,e.input)).map(e=>e.id)),a=new Map;for(let t of n(e,(e,t,n)=>i.has(e.id)&&t===n))a.set(t.toolCallId,t);let o=[],s=new Set;for(let e of t){if(s.has(e))continue;let t=a.get(e);t&&(s.add(e),o.push({image:t,occurrenceKey:e}))}return o}function ue({payload:e,onClose:t,assistantId:n}){return(0,Z.jsx)(fe,{payload:e,onClose:t,assistantId:n},de(e))}function de(e){if(e.messageId!=null){let t=e.groupToolCallIds?.[0];return JSON.stringify(t==null?[`message`,e.messageId,`index`,e.groupIndex??null]:[`message`,e.messageId,`tool`,t])}let t=e.toolCalls[0]?.id;return JSON.stringify(t==null?[`snapshot`,`index`,e.groupIndex??null]:[`snapshot`,`tool`,t])}function fe({payload:e,onClose:t,assistantId:n}){let{t:r}=R(`chat`),[i,o]=(0,X.useState)(null),s=J(i),c=e.groupToolCallIds?.[0]??e.toolCalls[0]?.id,u=ce(e.messageId,e.groupIndex,c),d=u?.items??e.items,f=u?.toolCalls??e.toolCalls,p=ee.use.phase(),m=u?u.isLastGroup&&u.isLatestMessage:e.messageId==null,h=L(d,{active:e.active===!0&&m&&C(p)}),v=(0,X.useMemo)(()=>d.flatMap(e=>e.kind===`toolCall`?[e.toolCall.id]:[]),[d]),y=(0,X.useMemo)(()=>_(),[]),b=(0,X.useMemo)(()=>$(f,v,y),[f,v,y]),x=(0,X.useMemo)(()=>b.map(e=>e.occurrenceKey),[b]),S=(0,X.useMemo)(()=>new Map(b.map((e,t)=>[e.occurrenceKey,t])),[b]),w=(0,X.useMemo)(()=>b.map(e=>e.image),[b]),E=(0,X.useRef)(null),{openPreview:D,previewModal:k}=l(n,w,x,{scopeKey:`${n??``}:${e.messageId??``}:${c??e.groupIndex??``}`,getFallbackFocus:()=>E.current?.querySelector(`button, [role="button"][tabindex="0"]`)??null}),A=te(h.steps),N=M(h.state,h.steps),P=N===`loading`,F=ne(N,h.totalDurationLabel??``,A.failed),I=P&&h.currentStepTitle||F,z=(0,X.useMemo)(()=>new Map(f.map(e=>[e.id,e])),[f]);return(0,Z.jsx)(`div`,{ref:E,className:`contents`,children:(0,Z.jsxs)(T,{icon:i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(g,{variant:`outlined`,iconOnly:(0,Z.jsx)(V,{}),"aria-label":r(`activityStepsPanel.backAria`),tooltip:r(`activityStepsPanel.backTooltip`),onClick:()=>o(null),className:`shrink-0`}),(0,Z.jsx)(Y,{detail:i,source:K})]}):void 0,title:s,titleNode:i?i.kind===`thinking`?void 0:(0,Z.jsx)(G,{detail:i,source:K}):(0,Z.jsx)(j,{title:P?(0,Z.jsx)(O,{children:I}):I,count:h.stepCount}),closeLabel:r(`activityStepsPanel.closeSteps`),onClose:t,children:[i?(0,Z.jsx)(he,{detail:i,assistantId:n}):(0,Z.jsx)(a,{steps:h.steps,timeline:!0,renderStep:t=>(0,Z.jsx)(me,{step:t,activeDetail:i,onOpenDetail:o,lookupToolCall:e=>z.get(e),messageId:e.messageId,groupIndex:u?.groupIndex??e.groupIndex}),renderPhaseFooter:e=>{let t=pe(e,b,S);if(!t)return null;let{entry:i,step:a,index:o}=t,s=a.activity?.trim(),c=s?r(`activityStepsPanel.screenshotTitle`,{activity:s}):r(`activityStepsPanel.screenshotFallbackTitle`),l=s?r(`activityStepsPanel.screenshotAria`,{activity:s}):r(`activityStepsPanel.screenshotFallbackAria`);return(0,Z.jsx)(re,{assistantId:n,image:i.image,title:c,ariaLabel:l,onPreview:e=>D(i.image,o,e)})}}),k]})})}function pe(e,n,r){if(!t(e.label))return null;for(let t=e.steps.length-1;t>=0;--t){let i=e.steps[t];if(i?.kind!==`tool`)continue;let a=r.get(i.toolCallId);if(a!==void 0)return{entry:n[a],step:i,index:a}}return null}function me({step:e,activeDetail:t,onOpenDetail:r,lookupToolCall:i,messageId:a,groupIndex:c}){let{t:l}=R(`chat`),u=o();if(e.kind===`thinking`){let t=a!=null&&e.thinkingItemIndex!=null?{messageId:a,thinkingGroupIndex:c,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,Z.jsx)(n,{iconName:`brain`,label:m(S(e.text),le),ariaLabel:l(`activityStepsPanel.viewThinkingAria`),active:!1,onClick:()=>r({kind:`thinking`,toolCallId:``,toolName:``,title:l(`thinkingDetail.title`),activity:``,input:{},status:`completed`,thinkingText:e.text,...t})})}if(e.kind===`web_search`)return(0,Z.jsx)(b,{step:e});if(e.kind===`web_search_error`)return(0,Z.jsx)(I,{step:e});if(e.kind!==`tool`)return(0,Z.jsx)(P,{step:e});let d=i(e.toolCallId);return(0,Z.jsx)(n,{iconName:e.iconName,label:u({activity:e.activity,actionDisplayKey:e.actionDisplayKey,fallback:e.activity||e.info||e.title}),active:t?.toolCallId===e.toolCallId,onClick:()=>{d&&r(s(d))}})}function he({detail:e,assistantId:t}){return e.kind===`thinking`?(0,Z.jsx)(W,{detail:e,assistantId:t}):(0,Z.jsx)(q,{detail:e,source:K,assistantId:t})}export{ue as ActivityStepsPanel,Q as buildActivityScreenshotGallery};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{At as t,Ct as n,Dr as r,Er as i,Et as a,Ft as o,Gr as s,Hn as c,In as l,It as u,Jr as d,Jt as f,Kr as p,Ks as m,Kt as h,LC as g,Lt as _,Qt as v,Rt as y,St as b,Tn as x,Xh as ee,Xr as S,Yh as C,Yt as w,Zn as T,Zt as E,_t as te,cv as D,gt as ne,mi as O,nu as k,qr as A,tr as j,vt as M,wh as N,wt as P,xr as F,xt as I,yt as L}from"./app-BcXqNg4_.js";import{E as R}from"./vendor-DwMhK7fD.js";import{t as z,x as B}from"./react-B9IgSVeK.js";import{Ki as V,Yn as H}from"./icons-C0wyat6T.js";import{t as U}from"./use-transcript-message-by-id-5y7epVj4.js";import{l as W,n as G,o as K,t as q}from"./tool-detail-panel-3qQYSadb.js";import{n as J,t as Y}from"./step-detail-header-cMcp1wkW.js";var X=e(B(),1),Z=z();function re({assistantId:e,image:t,title:n,ariaLabel:r,onPreview:i}){let a=(0,X.useRef)(null),{url:o,isError:s,isPending:l}=c(e,t,u(a)||typeof IntersectionObserver>`u`),[d,f]=(0,X.useState)(null);(0,X.useEffect)(()=>{f(null)},[t.id,t.previewUrl]);let p=o===d?null:o,m=l?null:{...t,previewUrl:p??null};return(0,Z.jsx)(`div`,{ref:a,"data-testid":`activity-screenshot-tile`,"data-tool-call-id":t.toolCallId,children:(0,Z.jsx)(h,{attachment:m,placeholder:s?null:(0,Z.jsx)(H,{className:`h-6 w-6 animate-spin`,"aria-hidden":`true`}),labels:{title:n,ariaLabel:r,secondary:null},hideCaptions:!0,onPreview:()=>i(a.current?.firstElementChild instanceof HTMLElement?a.current.firstElementChild:null),onPreviewError:()=>f(o)})})}function ie(e,t){return e[t]?.type===`activity`&&t===e.length-1}function ae(e,t){let n=t.at(-1);if(!n)return!1;let r=new Set(N(n));return N(e).some(e=>r.has(e))}function oe(e,t,n){if(!n)return e[t]?.type===`activity`?t:null;let r=t=>{let r=e[t];return!r||r.type!==`activity`?!1:p(r.items).toolCalls.some(e=>e.id===n)};if(r(t))return t;let i=e.findIndex((e,t)=>r(t));return i===-1?null:i}function se(e,t,n){let r=w(t,n.workflow),i=e=>{let t=v(e,n.workflow.byToolUseId);if(t!==null&&r.has(t))return!0;let i=f(e,n.acpByToolUseId);if(i!==null&&n.acpById[i]!==void 0)return!0;let a=E(e);return a!==void 0&&n.backgroundTaskById[a]!==void 0},a=t.filter(e=>!i(e));if(a.length===t.length)return{items:e,toolCalls:t};let o=new Set(a.map(e=>e.id));return{items:e.filter(e=>e.kind!==`toolCall`||o.has(e.toolCall.id)),toolCalls:a}}function ce(e,t,n){let a=U(e),o=i(),s=x(),c=k.use.byId(),l=k.use.byToolUseId(),u=k.use.notFoundRunIds(),f=k.use.hydrationFailedRunIds(),m=F.use.byId(),h=F.use.byToolUseId(),g=r.use.byId();return(0,X.useMemo)(()=>{if(!a||t==null)return null;let e=A(a.contentBlocks??[],d(a,s)),r=oe(e,t,n);if(r==null)return null;let i=e[r];if(!i||i.type!==`activity`)return null;let{cardItems:_,toolCalls:v}=p(i.items);return{...se(_,v,{workflow:{byId:c,byToolUseId:l,notFoundRunIds:u,hydrationFailedRunIds:f},acpById:m,acpByToolUseId:h,backgroundTaskById:g}),isLastGroup:ie(e,r),isLatestMessage:ae(a,o),groupIndex:r}},[a,o,t,n,s,c,l,u,f,m,h,g])}var le=60;function Q(e,t){return $(e,t.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]))}function $(e,t,n=y){let r=new Set(t),i=new Set(e.filter(e=>r.has(e.id)&&D(e.name,e.input)).map(e=>e.id)),a=new Map;for(let t of n(e,(e,t,n)=>i.has(e.id)&&t===n))a.set(t.toolCallId,t);let o=[],s=new Set;for(let e of t){if(s.has(e))continue;let t=a.get(e);t&&(s.add(e),o.push({image:t,occurrenceKey:e}))}return o}function ue({payload:e,onClose:t,assistantId:n}){return(0,Z.jsx)(fe,{payload:e,onClose:t,assistantId:n},de(e))}function de(e){if(e.messageId!=null){let t=e.groupToolCallIds?.[0];return JSON.stringify(t==null?[`message`,e.messageId,`index`,e.groupIndex??null]:[`message`,e.messageId,`tool`,t])}let t=e.toolCalls[0]?.id;return JSON.stringify(t==null?[`snapshot`,`index`,e.groupIndex??null]:[`snapshot`,`tool`,t])}function fe({payload:e,onClose:t,assistantId:n}){let{t:r}=R(`chat`),[i,o]=(0,X.useState)(null),s=J(i),c=e.groupToolCallIds?.[0]??e.toolCalls[0]?.id,u=ce(e.messageId,e.groupIndex,c),d=u?.items??e.items,f=u?.toolCalls??e.toolCalls,p=ee.use.phase(),m=u?u.isLastGroup&&u.isLatestMessage:e.messageId==null,h=L(d,{active:e.active===!0&&m&&C(p)}),v=(0,X.useMemo)(()=>d.flatMap(e=>e.kind===`toolCall`?[e.toolCall.id]:[]),[d]),y=(0,X.useMemo)(()=>_(),[]),b=(0,X.useMemo)(()=>$(f,v,y),[f,v,y]),x=(0,X.useMemo)(()=>b.map(e=>e.occurrenceKey),[b]),S=(0,X.useMemo)(()=>new Map(b.map((e,t)=>[e.occurrenceKey,t])),[b]),w=(0,X.useMemo)(()=>b.map(e=>e.image),[b]),E=(0,X.useRef)(null),{openPreview:D,previewModal:k}=l(n,w,x,{scopeKey:`${n??``}:${e.messageId??``}:${c??e.groupIndex??``}`,getFallbackFocus:()=>E.current?.querySelector(`button, [role="button"][tabindex="0"]`)??null}),A=te(h.steps),N=M(h.state,h.steps),P=N===`loading`,F=ne(N,h.totalDurationLabel??``,A.failed),I=P&&h.currentStepTitle||F,z=(0,X.useMemo)(()=>new Map(f.map(e=>[e.id,e])),[f]);return(0,Z.jsx)(`div`,{ref:E,className:`contents`,children:(0,Z.jsxs)(T,{icon:i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(g,{variant:`outlined`,iconOnly:(0,Z.jsx)(V,{}),"aria-label":r(`activityStepsPanel.backAria`),tooltip:r(`activityStepsPanel.backTooltip`),onClick:()=>o(null),className:`shrink-0`}),(0,Z.jsx)(Y,{detail:i,source:K})]}):void 0,title:s,titleNode:i?i.kind===`thinking`?void 0:(0,Z.jsx)(G,{detail:i,source:K}):(0,Z.jsx)(j,{title:P?(0,Z.jsx)(O,{children:I}):I,count:h.stepCount}),closeLabel:r(`activityStepsPanel.closeSteps`),onClose:t,children:[i?(0,Z.jsx)(he,{detail:i,assistantId:n}):(0,Z.jsx)(a,{steps:h.steps,timeline:!0,renderStep:t=>(0,Z.jsx)(me,{step:t,activeDetail:i,onOpenDetail:o,lookupToolCall:e=>z.get(e),messageId:e.messageId,groupIndex:u?.groupIndex??e.groupIndex}),renderPhaseFooter:e=>{let t=pe(e,b,S);if(!t)return null;let{entry:i,step:a,index:o}=t,s=a.activity?.trim(),c=s?r(`activityStepsPanel.screenshotTitle`,{activity:s}):r(`activityStepsPanel.screenshotFallbackTitle`),l=s?r(`activityStepsPanel.screenshotAria`,{activity:s}):r(`activityStepsPanel.screenshotFallbackAria`);return(0,Z.jsx)(re,{assistantId:n,image:i.image,title:c,ariaLabel:l,onPreview:e=>D(i.image,o,e)})}}),k]})})}function pe(e,n,r){if(!t(e.label))return null;for(let t=e.steps.length-1;t>=0;--t){let i=e.steps[t];if(i?.kind!==`tool`)continue;let a=r.get(i.toolCallId);if(a!==void 0)return{entry:n[a],step:i,index:a}}return null}function me({step:e,activeDetail:t,onOpenDetail:r,lookupToolCall:i,messageId:a,groupIndex:c}){let{t:l}=R(`chat`),u=o();if(e.kind===`thinking`){let t=a!=null&&e.thinkingItemIndex!=null?{messageId:a,thinkingGroupIndex:c,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,Z.jsx)(n,{iconName:`brain`,label:m(S(e.text),le),ariaLabel:l(`activityStepsPanel.viewThinkingAria`),active:!1,onClick:()=>r({kind:`thinking`,toolCallId:``,toolName:``,title:l(`thinkingDetail.title`),activity:``,input:{},status:`completed`,thinkingText:e.text,...t})})}if(e.kind===`web_search`)return(0,Z.jsx)(b,{step:e});if(e.kind===`web_search_error`)return(0,Z.jsx)(I,{step:e});if(e.kind!==`tool`)return(0,Z.jsx)(P,{step:e});let d=i(e.toolCallId);return(0,Z.jsx)(n,{iconName:e.iconName,label:u({activity:e.activity,actionDisplayKey:e.actionDisplayKey,fallback:e.activity||e.info||e.title}),active:t?.toolCallId===e.toolCallId,onClick:()=>{d&&r(s(d))}})}function he({detail:e,assistantId:t}){return e.kind===`thinking`?(0,Z.jsx)(W,{detail:e,assistantId:t}):(0,Z.jsx)(q,{detail:e,source:K,assistantId:t})}export{ue as ActivityStepsPanel,Q as buildActivityScreenshotGallery};
@@ -0,0 +1 @@
1
+ import{t as e}from"./add-credits-modal-bZqIcj8Q.js";export{e as AddCreditsModal};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Dd as t,LC as n,Ny as r,Py as i,VC as a,_C as o,aC as s,dS as c,kd as l,of as u,tC as d}from"./app-W5eFKD8y.js";import{$n as f,E as p,Xn as m}from"./vendor-DwMhK7fD.js";import{_ as h,d as g,n as _,t as v,x as y}from"./react-B9IgSVeK.js";import{Gi as b,Ui as x}from"./icons-C0wyat6T.js";import{n as S}from"./android-billing-handoff-AY7PbzeY.js";import{t as C}from"./checkout-return-target-Dz-38dZC.js";var w=e(y(),1),T=v(),E=[`10.00`,`20.00`,`30.00`,`40.00`,`50.00`,`60.00`,`70.00`,`80.00`,`90.00`,`100.00`];function D(e){let t=parseFloat(e);if(Number.isNaN(t))return`0 credits`;let n=t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2});return`${n.endsWith(`.00`)?n.slice(0,-3):n} credits`}function O(e){if(e&&typeof e==`object`){let t=e.amount;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0]}return`Failed to create checkout session. Please try again.`}function k({open:e,onOpenChange:v}){let{t:y}=p(),{pathname:S}=g(),[k]=h(),A=k.toString()?`${S}?${k.toString()}`:S,{data:j,isLoading:M}=f(t()),N=j?.allowed_top_up_amounts?.length?j.allowed_top_up_amounts:E,[P,F]=(0,w.useState)(null),I=P&&N.includes(P)?P:N[0]??E[0],L=m(l());return(0,w.useEffect)(()=>i(()=>{v(!1)}),[v]),u(`deeplink.billingCheckoutComplete`,({flow:e})=>{e===`top_up`&&v(!1)}),(0,T.jsx)(s.Root,{open:e,onOpenChange:v,children:(0,T.jsxs)(s.Content,{size:`sm`,children:[(0,T.jsxs)(s.Header,{children:[(0,T.jsx)(s.Title,{children:y(`addCreditsModal.title`)}),(0,T.jsx)(s.Description,{children:y(`addCreditsModal.description`)})]}),(0,T.jsx)(s.Body,{children:(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`add-credits-amount`,className:`block text-body-small-default text-[var(--content-tertiary)]`,children:y(`addCreditsModal.amount`)}),(0,T.jsx)(d,{id:`add-credits-amount`,value:I,onChange:e=>{F(e),L.isError&&L.reset()},disabled:M||!j,options:N.map(e=>({value:e,label:D(e)}))})]}),L.isError&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,T.jsx)(x,{className:`h-3.5 w-3.5 shrink-0`}),O(L.error)]}),(0,T.jsxs)(_,{to:c.settings.usageBillingConfigureTopUps,className:a(o({tone:`quiet`}),`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)]`),onClick:()=>v(!1),children:[y(`addCreditsModal.configureAutoReload`),(0,T.jsx)(b,{className:`size-4`})]}),(0,T.jsx)(`div`,{className:`h-px w-full bg-[var(--border-subtle)]`})]})}),(0,T.jsxs)(s.Footer,{children:[(0,T.jsx)(s.Close,{asChild:!0,children:(0,T.jsx)(n,{variant:`outlined`,children:y(`addCreditsModal.cancel`)})}),(0,T.jsx)(n,{variant:`primary`,loading:L.isPending,onClick:()=>{L.isPending||L.mutate({body:{amount:I,return_path:A,return_target:C()}},{onSuccess:e=>{r(e.checkout_url)}})},disabled:L.isPending||M||!j,children:y(`addCreditsModal.continue`)})]})]})})}function A(e){return S({open:e.open,path:c.settings.usageBilling,onClose:()=>e.onOpenChange(!1)})?null:(0,T.jsx)(k,{...e})}export{A as t};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Dd as t,LC as n,Ny as r,Py as i,VC as a,_C as o,aC as s,dS as c,kd as l,of as u,tC as d}from"./app-BcXqNg4_.js";import{$n as f,E as p,Xn as m}from"./vendor-DwMhK7fD.js";import{_ as h,d as g,n as _,t as v,x as y}from"./react-B9IgSVeK.js";import{Gi as b,Ui as x}from"./icons-C0wyat6T.js";import{n as S}from"./android-billing-handoff-C6bvESMN.js";import{t as C}from"./checkout-return-target-7l_utrfO.js";var w=e(y(),1),T=v(),E=[`10.00`,`20.00`,`30.00`,`40.00`,`50.00`,`60.00`,`70.00`,`80.00`,`90.00`,`100.00`];function D(e){let t=parseFloat(e);if(Number.isNaN(t))return`0 credits`;let n=t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2});return`${n.endsWith(`.00`)?n.slice(0,-3):n} credits`}function O(e){if(e&&typeof e==`object`){let t=e.amount;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0]}return`Failed to create checkout session. Please try again.`}function k({open:e,onOpenChange:v}){let{t:y}=p(),{pathname:S}=g(),[k]=h(),A=k.toString()?`${S}?${k.toString()}`:S,{data:j,isLoading:M}=f(t()),N=j?.allowed_top_up_amounts?.length?j.allowed_top_up_amounts:E,[P,F]=(0,w.useState)(null),I=P&&N.includes(P)?P:N[0]??E[0],L=m(l());return(0,w.useEffect)(()=>i(()=>{v(!1)}),[v]),u(`deeplink.billingCheckoutComplete`,({flow:e})=>{e===`top_up`&&v(!1)}),(0,T.jsx)(s.Root,{open:e,onOpenChange:v,children:(0,T.jsxs)(s.Content,{size:`sm`,children:[(0,T.jsxs)(s.Header,{children:[(0,T.jsx)(s.Title,{children:y(`addCreditsModal.title`)}),(0,T.jsx)(s.Description,{children:y(`addCreditsModal.description`)})]}),(0,T.jsx)(s.Body,{children:(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`add-credits-amount`,className:`block text-body-small-default text-[var(--content-tertiary)]`,children:y(`addCreditsModal.amount`)}),(0,T.jsx)(d,{id:`add-credits-amount`,value:I,onChange:e=>{F(e),L.isError&&L.reset()},disabled:M||!j,options:N.map(e=>({value:e,label:D(e)}))})]}),L.isError&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,T.jsx)(x,{className:`h-3.5 w-3.5 shrink-0`}),O(L.error)]}),(0,T.jsxs)(_,{to:c.settings.usageBillingConfigureTopUps,className:a(o({tone:`quiet`}),`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)]`),onClick:()=>v(!1),children:[y(`addCreditsModal.configureAutoReload`),(0,T.jsx)(b,{className:`size-4`})]}),(0,T.jsx)(`div`,{className:`h-px w-full bg-[var(--border-subtle)]`})]})}),(0,T.jsxs)(s.Footer,{children:[(0,T.jsx)(s.Close,{asChild:!0,children:(0,T.jsx)(n,{variant:`outlined`,children:y(`addCreditsModal.cancel`)})}),(0,T.jsx)(n,{variant:`primary`,loading:L.isPending,onClick:()=>{L.isPending||L.mutate({body:{amount:I,return_path:A,return_target:C()}},{onSuccess:e=>{r(e.checkout_url)}})},disabled:L.isPending||M||!j,children:y(`addCreditsModal.continue`)})]})]})})}function A(e){return S({open:e.open,path:c.settings.usageBilling,onClose:()=>e.onOpenChange(!1)})?null:(0,T.jsx)(k,{...e})}export{A as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$f as t,$m as n,$n as r,AC as i,AS as a,Ab as o,Av as s,Bb as c,Bf as l,Bi as u,Cb as d,Cs as f,DC as p,Db as m,Dg as h,Ds as g,ES as _,Eb as v,Eo as y,Fb as b,Ff as x,Fs as S,Fv as C,Gm as w,Hb as T,Ib as E,If as D,J as O,Jf as k,Jm as A,Jx as j,K as M,Kl as N,LC as P,Lb as F,Lf as I,MC as L,Mb as R,Mm as ee,Mp as z,Ms as B,NS as V,Nb as H,Nf as te,Np as ne,Ns as re,Ob as ie,Og as ae,Os as oe,Pb as U,Pf as se,Pp as ce,Ps as le,Pv as ue,Q as de,Qf as fe,Qm as pe,Qv as me,Rb as he,Rf as ge,Sb as _e,Ss as ve,Tb as ye,Tm as be,To as xe,Ts as Se,US as Ce,Ub as we,Vb as Te,Wb as Ee,Wm as De,X as Oe,XS as ke,Xf as Ae,Xm as je,Y as Me,Yf as Ne,Z as Pe,Zf as Fe,Zm as Ie,Zn as Le,_b as Re,_s as ze,aC as W,ah as Be,at as Ve,bS as G,bb as He,bm as Ue,bs as We,cm as Ge,cp as Ke,dC as qe,dp as Je,eh as Ye,en as Xe,fC as Ze,fg as Qe,fp as $e,gb as et,gs as tt,hC as nt,iC as K,ih as rt,jS as it,jb as at,jg as ot,jp as st,js as ct,kb as lt,ks as ut,ky as dt,lp as ft,my as pt,nh as mt,om as ht,op as gt,ot as _t,pC as q,pn as vt,q as yt,rC as bt,rh as xt,rt as St,sm as Ct,sp as wt,tC as J,th as Tt,tt as Et,up as Dt,uv as Ot,vb as kt,vs as At,wC as jt,wb as Mt,wo as Nt,ws as Pt,xb as Ft,xs as It,xv as Lt,yC as Rt,yb as zt,ym as Bt,ys as Vt,zC as Ht,zb as Ut,zf as Wt,zi as Gt}from"./app-W5eFKD8y.js";import{$n as Y,E as X,O as Kt,Xn as qt,j as Z,nr as Jt}from"./vendor-DwMhK7fD.js";import{b as Yt,t as Xt,x as Zt}from"./react-B9IgSVeK.js";import{A as Qt,D as $t,Lt as en,Ui as tn,Xn as nn,Yn as rn,Zr as an,fr as on,vt as sn}from"./icons-C0wyat6T.js";import{t as cn}from"./ellipsis-vertical-Bg7ccW1x.js";import{i as ln,n as un,r as dn,t as fn}from"./service-form-controls-BsXim31K.js";import{o as pn}from"./detail-primitives-h0qp0cUk.js";import{d as mn,o as hn,u as gn}from"./schedules-C6VrWxrr.js";import{t as _n}from"./stt-language-picker-modal-zYjhVFJl.js";var Q=e(Zt(),1);function vn(){let e=Et();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await pt({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});Re(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?K.error(Z(`settings:useDaemonConfig.assistantNotReadyToast`)):K.error(Z(`settings:useDaemonConfig.saveApiKeyFailedToast`,{providerName:t})),G(e,{context:`provision_provider_key`}),e}},[e])}function yn(e){let[t,n]=(0,Q.useState)(void 0);return(0,Q.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Q.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}var bn=`0.11.0`;function xn(){return h(bn)}var $=Xt(),Sn=`gemini-3.1-flash-image-preview`;function Cn(e,t){return e===`openrouter`?`openrouter`:re(t)}function wn(){let{t:e}=X(`settings`),t=Et(),n=Jt(),r=A(),{data:i}=Y({...gt({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),o=be({onSuccess:e=>{Ke(n,{path:{assistant_id:t}},e)}}),s=vn(),c=i?.services?.[`image-generation`],l=(0,Q.useMemo)(()=>i?c?.mode===`managed`?`vellum`:c?.provider||a(`vellum:ai:imageGenProvider`,`gemini`):a(ze,`gemini`),[i,c?.mode,c?.provider]),[u,d]=yn(l),[f,p]=(0,Q.useState)(()=>a(tt,Sn)),[m,h]=(0,Q.useState)(null),_=l===`openrouter`&&typeof c?.model==`string`?c.model:void 0,v=m??_??a(`vellum:ai:imageGenModel`,`google/gemini-3.1-flash-image-preview`),y=u===`openrouter`,b=B(u),x=y?v.trim()||`google/gemini-3.1-flash-image-preview`:b.includes(f)?f:b[0]??Sn,[S,C]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(!1),D=oe.map(e=>({value:e,label:ut[e]??e})),O=(0,Q.useMemo)(()=>B(u).map(e=>({value:e,label:g[e]??e})),[u]),k=u===`gemini`||u===`openai`||u===`openrouter`,{hasStoredCredential:j}=w({assistantId:t,credentialKind:`api_key`,credentialName:u,enabled:k}),M=(0,Q.useCallback)(e=>{d(e),e===`openrouter`&&m===null&&h(_??`google/gemini-3.1-flash-image-preview`)},[m,_,d]),N=(0,Q.useCallback)(async()=>{E(!0);let r=S.trim(),i=k&&r.length>0;try{await ot(),i&&await s(Cn(u,x),r);let a=u===`vellum`&&!xn()?{mode:`managed`}:{provider:u,mode:u===`vellum`?`managed`:`your-own`};await o.mutateAsync({path:{assistant_id:t},body:{services:{"image-generation":a}}}).catch(t=>{throw K.error(e(`imageGenerationCard.configUpdateFailedToast`)),G(t,{context:`patch_daemon_config`}),t});try{await me({path:{assistant_id:t},body:{modelId:x},throwOnError:!0})}catch(t){throw K.error(e(`imageGenerationCard.modelUpdateFailedToast`)),G(t,{context:`set_image_gen_model`}),t}finally{n.invalidateQueries({queryKey:wt({path:{assistant_id:t}})})}}catch{E(!1);return}E(!1);try{if(V(ze,u),V(tt,x),i){let e=De(t,`api_key`,u);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),C(``)}K.success(e(`imageGenerationCard.savedToast`))}catch(t){G(t,{context:`settings-ai-image-gen-persist-local`}),K.error(e(`imageGenerationCard.localPreferencesFailedToast`))}},[S,u,k,x,t,o,s,n,e]),P=(0,Q.useCallback)(()=>{if(C(``),u===`openrouter`){h(Se),V(tt,Se);return}p(Sn),V(tt,Sn)},[u]),F=e(u===`openai`?`imageGenerationCard.openaiApiKeyPlaceholder`:u===`openrouter`?`imageGenerationCard.openrouterApiKeyPlaceholder`:`imageGenerationCard.geminiApiKeyPlaceholder`);return(0,$.jsx)(ln,{title:e(`imageGenerationCard.title`),subtitle:e(`imageGenerationCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.providerLabel`)}),(0,$.jsx)(J,{"aria-label":e(`imageGenerationCard.providerAriaLabel`),value:u,onChange:M,options:D})]}),u===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.vellumNote`)}),k&&(0,$.jsx)(q,{label:e(`imageGenerationCard.apiKeyLabel`),type:`password`,value:S,onChange:e=>C(e.target.value),placeholder:Ae(F,j),fullWidth:!0}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.activeModelLabel`)}),y?(0,$.jsx)(q,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:v,onChange:e=>h(e.target.value),placeholder:e(`imageGenerationCard.openrouterModelPlaceholder`),fullWidth:!0}):(0,$.jsx)(J,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:x,onChange:p,options:O})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:N,disabled:T}),T&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),k&&(0,$.jsx)(un,{onClick:P})]})]})})}function Tn({title:e,count:t,action:n,children:r}){return(0,$.jsxs)(`section`,{className:`rounded-xl border border-[var(--border-hover)] bg-[var(--surface-overlay)] px-3 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(p,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(p,{variant:`body-large-default`,as:`span`,"aria-label":`${t} ${e.toLowerCase()}`,className:`text-[var(--content-disabled)]`,children:[`·`,` `,t]})]}),n]}),r==null?null:(0,$.jsx)(`div`,{className:`mt-4 border-t border-[var(--border-base)]`,children:r})]})}function En(e){return e.scheduleNames.length>0||e.deferredReminderCount>0||e.scheduleLookupFailed}var Dn=5;function On({title:e,items:t,mono:n}){return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-(--content-tertiary)`,children:e}),(0,$.jsx)(`ul`,{className:`space-y-1 pl-1`,children:t.map(e=>(0,$.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,n?(0,$.jsx)(`code`,{children:e}):e]},e))})]})}function kn(e){let t=e.label||e.name,n=[];e.isActive&&n.push(Z(`settings:manageProfilesBlockedDeleteModal.clauseDefaultProfile`)),e.callSiteIds.length>0&&n.push(Z(`settings:manageProfilesBlockedDeleteModal.clauseActionOverrides`,{count:e.callSiteIds.length}));let r=e.scheduleNames.length,i=e.deferredReminderCount;return r>0&&i>0?n.push(Z(`settings:manageProfilesBlockedDeleteModal.clauseRunsBoth`,{schedules:r,reminders:i})):r>0?n.push(Z(`settings:manageProfilesBlockedDeleteModal.clauseRunsSchedules`,{count:r})):i>0&&n.push(Z(`settings:manageProfilesBlockedDeleteModal.clauseRunsReminders`,{count:i})),n.length===0?Z(`settings:manageProfilesBlockedDeleteModal.summaryNoReferences`,{display:t}):n.length===1?Z(`settings:manageProfilesBlockedDeleteModal.summaryOneClause`,{display:t,clause1:n[0]}):n.length===2?Z(`settings:manageProfilesBlockedDeleteModal.summaryTwoClauses`,{display:t,clause1:n[0],clause2:n[1]}):Z(`settings:manageProfilesBlockedDeleteModal.summaryThreeClauses`,{display:t,clause1:n[0],clause2:n[1],clause3:n[2]})}function An({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let{t:c}=X(`settings`),l=e?.scheduleNames??[],u=l.slice(0,Dn),d=l.length-u.length,f=e!=null&&En(e);return(0,$.jsx)(W.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(W.Content,{size:`sm`,children:[(0,$.jsx)(W.Header,{children:(0,$.jsx)(W.Title,{children:c(`manageProfilesBlockedDeleteModal.title`)})}),(0,$.jsxs)(W.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(p,{variant:`body-medium-default`,as:`p`,children:kn(e)}),e&&e.callSiteIds.length>0&&(0,$.jsx)(On,{title:c(`manageProfilesBlockedDeleteModal.actionOverridesTitle`),items:e.callSiteIds,mono:!0}),u.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(On,{title:c(`manageProfilesBlockedDeleteModal.schedulesTitle`),items:u}),d>0&&(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.moreSchedules`,{count:d})})]}),e?.scheduleLookupFailed&&(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-(--system-mid-strong)`,children:c(`manageProfilesBlockedDeleteModal.scheduleLookupFailed`)}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.replacementLabel`)}),(0,$.jsx)(J,{"aria-label":c(`manageProfilesBlockedDeleteModal.replacementLabel`),value:n,onChange:r,placeholder:c(`manageProfilesBlockedDeleteModal.replacementPlaceholder`),options:t.map(e=>{let t=f&&e.status===`disabled`;return{value:e.name,label:O(e),disabled:t,tooltip:t?c(`manageProfilesBlockedDeleteModal.disabledTargetTooltip`):void 0}})})]}),i&&(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(W.Footer,{children:[(0,$.jsx)(P,{variant:`ghost`,size:`compact`,onClick:o,children:c(`manageProfilesBlockedDeleteModal.cancel`)}),(0,$.jsx)(P,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:c(a?`manageProfilesBlockedDeleteModal.saving`:`manageProfilesBlockedDeleteModal.reassignAndDelete`)})]})]})})}function jn({profile:e,isActiveProfile:t,selected:n,connections:r,deletePending:a=!1,onOpen:o,onMakeActive:s,onSetStatus:c,onDelete:l}){let{t:u}=X(`settings`),d=e.source===`managed`,f=e.status===`disabled`,p=e.label??e.name,m=[];e.model&&m.push(D(e.provider??void 0,e.model,r)),d&&m.push(u(`profileRow.managedByVellum`));let h=e.availability,g=e.config_issue,_=g!=null||h?.status===`incomplete`,v=h?.message??u(`profileRow.providerUnavailableDefault`),y=g==null?h!=null&&h.status!==`ok`?_?u(`profileRow.providerUnavailableFixable`,{message:v}):v:null:u(`profileRow.providerUnavailableFixable`,{message:u(g.code===`over_output_cap`?`profileRow.configIssueOverOutputCap`:g.code===`no_input_room`?`profileRow.configIssueNoInputRoom`:`profileRow.configIssueModelUnknown`)});return(0,$.jsx)(Ce,{title:(0,$.jsx)(`span`,{className:f?`opacity-55`:void 0,children:p}),subtitle:m.length>0?m.join(` • `):void 0,onClick:o,showChevron:!1,selected:n,disabled:a,contentAriaLabel:u(`profileRow.openProfileAriaLabel`,{displayName:p}),trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[y==null?null:(0,$.jsx)(Ht,{content:y,children:_?(0,$.jsx)(`button`,{type:`button`,onClick:o,"aria-label":y,className:`inline-flex cursor-pointer rounded-sm p-0.5 keyboard-focus:ring-2 keyboard-focus:ring-[var(--ring)]`,children:(0,$.jsx)(tn,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-hidden":`true`})}):(0,$.jsx)(`span`,{className:`inline-flex p-0.5`,tabIndex:0,children:(0,$.jsx)(tn,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-label":y,role:`img`})})}),f?(0,$.jsx)(Rt,{tone:`neutral`,children:u(`profileRow.disabledTag`)}):null,t?(0,$.jsx)(Rt,{tone:`positive`,children:u(`profileRow.defaultTag`)}):null,(0,$.jsxs)(L.Root,{children:[(0,$.jsx)(L.Trigger,{asChild:!0,children:(0,$.jsx)(P,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":u(`profileRow.actionsAriaLabel`,{displayName:p}),disabled:a})}),(0,$.jsxs)(L.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(L.Item,{onSelect:o,children:u(d?`profileRow.view`:`profileRow.edit`)}),!t&&!f&&Te(e.provider,e.model)?(0,$.jsx)(L.Item,{onSelect:s,children:u(`profileRow.makeDefault`)}):null,f?(0,$.jsx)(L.Item,{onSelect:()=>c(!0),children:u(`profileRow.enable`)}):d?null:(0,$.jsx)(L.Item,{onSelect:()=>c(!1),children:u(`profileRow.disable`)}),d?null:(0,$.jsx)(L.Item,{onSelect:l,className:i.anchored,children:u(`profileRow.delete`)})]})]})]})})}function Mn(e,t){let n=Gt(),{data:r}=Y({...st({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=vt(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:kt(i,a).map(e=>({name:e.name,label:e.label??null,provider:e.provider??null,model:e.model??null,status:e.status===`disabled`?`disabled`:`active`,source:e.source===`managed`?`managed`:`user`,provider_connection:e.provider_connection,availability:null})),isEffectiveCatalog:!1}:{entries:r.profiles,isEffectiveCatalog:!0},[r,i,a])}var Nn=`0.10.8`;function Pn(e){return ae(Nn,e)}var Fn=`settings-ai-profile-make-active`,In=`Failed to set the active profile. Please try again.`;function Ln(e){let t=se(),n=Jt(),r=Pn(e),i=ee({onSuccess:()=>{n.invalidateQueries({queryKey:wt({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:z({path:{assistant_id:e}})})}});async function a(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw G(e,{context:r}),K.error(i),e}}async function o(t){if(!r){await a({activeProfile:t},Fn,In);return}try{await i.mutateAsync({path:{assistant_id:e},body:{name:t}})}catch(e){let t=_(e);throw K.error(t??In),t||G(e,{context:Fn}),e}}return{makeActive:o,setStatus:(e,t)=>a({profiles:{[e]:{status:t?`active`:`disabled`}}},`settings-ai-profile-toggle`,`Failed to update the profile. Please try again.`),deleteProfile:(e,t,n)=>a({profiles:{[e]:null},profileOrder:t.filter(t=>t!==e),...n?.isAdvisor?{advisorProfile:null}:{}},`settings-ai-profile-delete`,`Failed to delete the profile. Please try again.`),patchLlm:a,isPending:t.isPending||i.isPending}}var Rn=`The profile was not deleted.`,zn=`Failed to move the schedules. ${Rn}`;function Bn(e){let t=_(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${Rn}`:zn}function Vn(e,t,n){let r=Ln(e),i=Jt(),a=de(),o=t?.llm?.activeProfile??null,s=t?.llm?.advisorProfile??null,c=t?.llm?.callSites??{},l=(0,Q.useMemo)(()=>t?.llm?.profiles??{},[t?.llm?.profiles]),u=(0,Q.useMemo)(()=>t?.llm?.profileOrder??[],[t?.llm?.profileOrder]),d=(0,Q.useMemo)(()=>kt(l,u),[l,u]),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(!1);function C(e){return d.filter(t=>t.name===e?!1:t.status===`disabled`?!0:M(t,d,{requireOwnProviderAndModel:a}))}function w(e,t){let n=C(e).filter(e=>!t||e.status!==`disabled`),r=n.find(e=>e.name===o),i=n.find(e=>e.source!==`managed`);return(r??i??n[0])?.name??``}async function T(e){try{await r.deleteProfile(e,u,{isAdvisor:e===s}),n?.onDeleted?.(e)}catch{}}async function E(t){let n=l[t]?.label??t,r=t===o,a=Object.entries(c).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),s=[],u=0,d=!1;try{let n=(await i.fetchQuery({...ht({path:{assistant_id:e},query:{inference_profile:t,include_all:`true`}}),retry:!1,staleTime:0})).schedules??[];s=n.filter(e=>!e.isDeferred).map(e=>e.name),u=n.filter(e=>e.isDeferred).length}catch(e){G(e,{context:`settings-ai-profile-delete-schedule-scan`}),d=!0}if(!(r||a.length>0||s.length>0||u>0)&&!d){await T(t);return}let f={name:t,label:n,isActive:r,callSiteIds:a,scheduleNames:s,deferredReminderCount:u,scheduleLookupFailed:d};p(f),_(w(t,En(f))),h(null)}function D(e){t==null||S.current||(S.current=!0,x(e),E(e).finally(()=>{S.current=!1,x(null)}))}async function O(){if(!f||!g)return;if(y(!0),h(null),En(f))try{await hn(e,f.name,g),await i.invalidateQueries({queryKey:Ct({path:{assistant_id:e}})})}catch(e){G(e,{context:`settings-ai-profile-reassign-schedules`}),h(Bn(e)),y(!1);return}let t={};if(f.isActive&&(t.activeProfile=g),f.callSiteIds.length>0){let e={};for(let t of f.callSiteIds)e[t]={profile:g};t.callSites=e}if(Object.keys(t).length>0)try{await r.patchLlm(t,`settings-ai-profile-reassign-delete`,`Failed to reassign references. Please try again.`)}catch{h(`Failed to reassign references. Please try again.`),y(!1);return}let n=f.name;p(null),y(!1),T(n)}return{requestDelete:D,pendingDeleteName:b,blockedDeleteModalProps:{blocked:f,availableReplacements:C(f?.name??null),replacement:g,onReplacementChange:_,error:m,saving:v,onClose:()=>{p(null),h(null)},onConfirm:()=>void O()}}}function Hn(){}function Un({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{t:s}=X(`settings`),{entries:c}=Mn(e,t),l=Ln(e),u=Vn(e,t,{onDeleted:o}),d=t?.llm?.activeProfile??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Tn,{title:s(`profilesSection.title`),action:(0,$.jsx)(P,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(en,{}),disabled:t==null,children:s(`profilesSection.createProfile`)}),children:t==null?(0,$.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.loading`)}):c.length===0?(0,$.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.emptyState`)}):c.map(e=>(0,$.jsx)(jn,{profile:e,isActiveProfile:e.name===d,selected:e.name===r,connections:n,deletePending:u.pendingDeleteName===e.name,onOpen:()=>i(e.name),onMakeActive:()=>void l.makeActive(e.name).catch(Hn),onSetStatus:t=>void l.setStatus(e.name,t).catch(Hn),onDelete:()=>u.requestDelete(e.name)},e.name))}),(0,$.jsx)(An,{...u.blockedDeleteModalProps})]})}var Wn={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,chatgpt:!0,vellum:!0,together:!0,"vercel-ai-gateway":!0,minimax:!0,atlascloud:!0,baseten:!0,poolside:!0};function Gn(e){return e in Wn}function Kn(e){if(!e.baseUrl)return null;try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function qn(e){let t=Kn(e)??``,n=[];t&&n.push(t);let r=e.models?.length??0;return r>0&&n.push(`${r} ${r===1?`model`:`models`}`),e.auth.type===`none`&&n.push(`keyless`),n.join(` · `)}function Jn(e){switch(e.auth.type){case`api_key`:return`Own API key`;case`oauth_subscription`:return`ChatGPT subscription`;case`none`:return`No API key needed`;default:return null}}function Yn(e){if(e.provider===`vellum`)return`Included with your plan`;if(e.provider===`openai-compatible`)return qn(e);let t=[];if(e.provider===`ollama`||e.provider===`opencode`){let n=Kn(e);n&&t.push(n)}let n=e.provider===`chatgpt`?`openai`:e.provider,r=e.auth.type===`oauth_subscription`?ge(n):we(n),i=e.models?.length??r.length;i>0&&t.push(`${i} ${i===1?`model`:`models`}`);let a=Jn(e);return a&&t.push(a),t.join(` • `)}function Xn({connection:e,isDefault:t,supportsDefaultProvider:n,selected:r,isSettingDefault:a,onOpen:o,onSetDefault:s,onDelete:c}){let{t:l}=X(`settings`),u=e.isManaged??!1,d=mt(e),f=Gn(e.provider),p=Yn(e),m=n&&!t&&f,h=!u&&o!=null,g=!u&&!t,_=m||h||g;return(0,$.jsx)(Ce,{title:d,subtitle:p.length>0?p:void 0,onClick:o,showChevron:!1,selected:r,contentAriaLabel:o?l(`providerRow.openProviderAriaLabel`,{displayName:d}):void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(Rt,{tone:`neutral`,title:l(`providerRow.managedTagTitle`),children:l(`providerRow.managedTag`)}):null,t?(0,$.jsx)(Rt,{tone:`info`,title:l(`providerRow.defaultTagTitle`),children:l(`providerRow.defaultTag`)}):null,e.provider===`ollama`?(0,$.jsx)(Rt,{tone:`neutral`,title:l(`providerRow.localTagTitle`),children:l(`providerRow.localTag`)}):null,e.provider===`openai-compatible`?(0,$.jsx)(Rt,{tone:`neutral`,title:l(`providerRow.customTagTitle`),children:l(`providerRow.customTag`)}):null,_?(0,$.jsxs)(L.Root,{children:[(0,$.jsx)(L.Trigger,{asChild:!0,children:(0,$.jsx)(P,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":l(`providerRow.actionsAriaLabel`,{displayName:d})})}),(0,$.jsxs)(L.Content,{align:`end`,sideOffset:4,children:[h?(0,$.jsx)(L.Item,{onSelect:o,children:l(`providerRow.edit`)}):null,m?(0,$.jsx)(L.Item,{disabled:a,onSelect:s,children:l(`providerRow.setAsDefault`)}):null,g?(0,$.jsx)(L.Item,{onSelect:c,className:i.anchored,children:l(`providerRow.delete`)}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function Zn(e,t){let n=Jt(),r={path:{assistant_id:e}},i=qt({...$e(),onSuccess:()=>{n.invalidateQueries({queryKey:Je(r)}),n.invalidateQueries({queryKey:wt(r)}),n.invalidateQueries({queryKey:z(r)})},onError:e=>{G(e,{context:`settings-ai-set-default-provider`}),K.error(Z(`settings:useProviderActions.setDefaultFailedToast`))}});function a(t){Gn(t.provider)&&i.mutate({path:{assistant_id:e},body:{provider:t.provider,connectionName:t.name}})}function o(e){return i.isPending&&i.variables?.body?.connectionName===e}async function s(i){try{let{response:a}=await ue({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:ce(r)}),t?.onDeleted?.(i)):a?.status===409?K.error(Z(`settings:useProviderActions.deleteInUseToast`)):K.error(Z(`settings:useProviderActions.deleteFailedToast`))}catch(e){G(e,{context:`settings-ai-provider-delete`}),K.error(Z(`settings:useProviderActions.deleteFailedToast`))}}return{setDefault:a,isSettingDefault:o,deleteConnection:s}}function Qn({assistantId:e,selectedConnectionName:t,onOpenConnection:n,onAddProvider:r,onConnectionDeleted:i}){let{t:a}=X(`settings`),{data:o,isLoading:s,isError:c}=Y(ne({path:{assistant_id:e}})),l=u(),{data:d}=Y({...Dt({path:{assistant_id:e}}),enabled:l}),f=l?d?.resolvedConnectionName??null:null,m=Zn(e,{onDeleted:i}),h=(0,Q.useMemo)(()=>{let e=o?.connections??[];return[...e.filter(e=>e.provider===F),...e.filter(e=>e.provider!==F)]},[o]);return(0,$.jsx)(Tn,{title:a(`providersSection.title`),action:(0,$.jsx)(P,{variant:`outlined`,onClick:r,leftIcon:(0,$.jsx)(en,{}),children:a(`providersSection.addProvider`)}),children:s?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(ke,{className:`h-10 rounded-lg`},e))}):c?(0,$.jsx)(p,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:a(`providersSection.loadError`)}):h.length===0?(0,$.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:a(`providersSection.empty`)}):h.map(e=>(0,$.jsx)(Xn,{connection:e,isDefault:e.name===f,supportsDefaultProvider:l,selected:e.name===t,isSettingDefault:m.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>n(e.name),onSetDefault:()=>m.setDefault(e),onDelete:()=>void m.deleteConnection(e.name)},e.name))})}function $n({panel:e,onOpenPanel:t,onClosePanel:n}){let{t:r}=X(`settings`),i=Et(),{data:a}=Y({...gt({path:{assistant_id:i}}),staleTime:3e4}),o=u(),{data:s}=Y({...Dt({path:{assistant_id:i}}),enabled:o}),c=s?.availability,{data:l}=Y({...ne({path:{assistant_id:i}})}),d=l?.connections,f=a?.llm?.callSites??{},p=Object.entries(f).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length;return(0,$.jsx)(ln,{title:r(`languageModelCard.title`),subtitle:r(`languageModelCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[c&&c.status!==`ok`&&(0,$.jsx)(jt,{tone:c.status===`unknown`?`warning`:`error`,children:c.message??r(`languageModelCard.defaultProviderUnavailable`)}),i&&(0,$.jsx)(Un,{assistantId:i,config:a,connections:d,selectedProfileName:e?.kind===`profile`?e.name:null,onOpenProfile:e=>t({kind:`profile`,name:e}),onCreateProfile:()=>t({kind:`create-profile`}),onProfileDeleted:t=>{e?.kind===`profile`&&e.name===t&&n()}}),i&&(0,$.jsx)(Qn,{assistantId:i,selectedConnectionName:e?.kind===`provider`?e.name:null,onOpenConnection:e=>t({kind:`provider`,name:e}),onAddProvider:()=>t({kind:`add-provider`}),onConnectionDeleted:t=>{e?.kind===`provider`&&e.name===t&&n()}}),(0,$.jsx)(Tn,{title:r(`languageModelCard.overridesTitle`),count:p,action:(0,$.jsx)(P,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:r(`languageModelCard.manage`)})})]})})}function er({children:e}){return(0,$.jsxs)(dt,{href:`https://www.vellum.ai/docs/pricing`,tone:`default`,className:`inline-flex items-center gap-1`,glyph:!1,children:[e,(0,$.jsx)(an,{className:`h-3.5 w-3.5`})]})}function tr(){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,$.jsx)(on,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:(0,$.jsx)(Kt,{i18nKey:`managedServicesBanner.body`,ns:`common`,components:{link:(0,$.jsx)(er,{})}})})]})}function nr({assistantId:e,profileName:t,onClose:n}){let{t:r}=X(`settings`),{data:i}=Y({...gt({path:{assistant_id:e}}),staleTime:3e4}),{data:a}=Y({...ne({path:{assistant_id:e}})}),o=a?.connections,s=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),c=Object.keys(s),l=(0,Q.useMemo)(()=>{if(t==null)return;let e=s[t];return e?{name:t,...e}:void 0},[t,s]),u=t==null?`create`:l?.source===`managed`||l?.invariant===!0?`view`:`edit`,{saveProfile:d,isPending:f}=te(e,{onSaved:n}),p=x({mode:u,profileName:t??void 0,initialValues:l,existingNames:c,connections:o,assistantId:e,onSave:d}),m=Vn(e,i,{onDeleted:()=>n()}),h=t!=null&&m.pendingDeleteName===t,g=t!=null&&i!=null&&!(t in s);(0,Q.useEffect)(()=>{g&&!p.saving&&!f&&n()},[g,p.saving,f,n]);let _=u===`view`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Le,{title:p.effectiveMode===`create`?r(`profileDetailPanel.createTitle`):l?.label??t??r(`profileDetailPanel.defaultTitle`),closeVariant:`outlined`,onClose:n,headerTrailing:_&&p.effectiveMode!==`create`?(0,$.jsx)(Rt,{tone:`neutral`,children:r(`profileDetailPanel.managedTag`)}):null,headerActions:p.effectiveMode!==`create`&&!p.isReadOnly?(0,$.jsx)(P,{variant:`dangerOutline`,loading:h,iconOnly:(0,$.jsx)(Qt,{}),"aria-label":r(h?`profileDetailPanel.deleting`:`profileDetailPanel.delete`),tooltip:r(`profileDetailPanel.delete`),onClick:()=>{t!=null&&m.requestDelete(t)},disabled:p.saving||h}):null,footer:p.isReadOnly?(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(P,{variant:`outlined`,onClick:p.switchToSaveAsNew,disabled:p.saving,children:r(`profileDetailPanel.saveAsNew`)}),p.hasViewModeChanges?(0,$.jsx)(P,{variant:`primary`,onClick:()=>void p.handleSave(),disabled:p.saving,children:p.saving?r(`profileDetailPanel.saving`):r(`profileDetailPanel.save`)}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(P,{variant:`primary`,onClick:()=>void p.handleSave(),disabled:p.isInvalid||p.saving,children:p.saving?r(`profileDetailPanel.saving`):p.effectiveMode===`create`?r(`profileDetailPanel.create`):r(`profileDetailPanel.saveChanges`)})}),children:(0,$.jsx)(I,{editor:p,assistantId:e,connections:o,variant:`panel`})}),(0,$.jsx)(An,{...m.blockedDeleteModalProps})]})}function rr({value:e,profileOptions:t,disabled:n,onChange:r}){let{t:i}=X(`settings`);return(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:i(`advisorProfileRow.title`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-body-small-lighter text-[var(--content-tertiary)]`,children:i(`advisorProfileRow.description`)})]}),(0,$.jsx)(J,{value:e,onChange:r,options:t,placeholder:i(`advisorProfileRow.chooseProfilePlaceholder`),className:`w-44`,menuMinWidth:280,menuAlign:`start`,disabled:n})]})})}var ir=`__custom__`;function ar(e){return e?!!(e.profile||e.provider||e.model):!1}function or(e,t){if(t?.provider||t?.model)return null;let n=e.defaultProfile??e.shippedDefaultProfile;return n?{profile:n,via:t?.profile===n?`override`:`default`}:null}function sr(e,t){let n=ar(e);return n===ar(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function cr({assistantId:e,callSites:t,domains:n,persistedOverrides:r,orderedProfiles:i,onClose:a,onApplied:o}){let{t:s}=X(`settings`),c=se(),l=de(),u=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:l,requireTextGeneration:!1}),[l]),d=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t){let t=or(n,r[n.id]);t&&e.set(n.id,t)}return e},[t,r]),f=(0,Q.useMemo)(()=>{let e=new Set(Array.from(d.values(),e=>e.profile));return i.filter(t=>e.has(t.name))},[i,d]),[m,h]=(0,Q.useState)(()=>f[0]?.name??``),[g,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(new Set),[x,S]=(0,Q.useState)(!1),C=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[n]),w=(0,Q.useMemo)(()=>t.filter(e=>d.get(e.id)?.profile===m),[t,d,m]),T=(0,Q.useMemo)(()=>w.map(e=>e.id).filter(e=>!y.has(e)),[w,y]),E=(0,Q.useMemo)(()=>f.map(e=>({value:e.name,label:O(e)})),[f]),D=(0,Q.useMemo)(()=>Pe(i,[],u).filter(e=>e.name!==m).map(e=>({value:e.name,label:O(e)})),[i,m,u]),k=Ft(i,m),A=Ft(i,g),j=y.size===0;function M(e){h(e),b(new Set),e===g&&v(``)}function N(e,t){b(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function F(){if(!(!m||!g||T.length===0)){S(!0);try{let t={};for(let e of T)t[e]={profile:g};await c.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),K.success(s(`bulkOverrideSwapModal.successToast`,{count:T.length,targetLabel:A})),o(),a()}catch(e){let t=_(e);K.error(t??s(`bulkOverrideSwapModal.updateFailedToast`)),t||G(e,{context:`settings-ai-bulk-override-swap`})}finally{S(!1)}}}return(0,$.jsx)(W.Root,{open:!0,onOpenChange:e=>{e||a()},children:(0,$.jsxs)(W.Content,{size:`md`,children:[(0,$.jsx)(W.Header,{children:(0,$.jsx)(W.Title,{children:s(`bulkOverrideSwapModal.title`)})}),(0,$.jsxs)(W.Body,{className:`space-y-4`,children:[(0,$.jsx)(p,{variant:`body-medium-default`,as:`p`,children:s(`bulkOverrideSwapModal.intro`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(J,{id:`bulk-swap-source`,label:s(`bulkOverrideSwapModal.currentlyUsingLabel`),value:m,onChange:M,options:E}),(0,$.jsx)(J,{id:`bulk-swap-target`,label:s(`bulkOverrideSwapModal.changeToLabel`),value:g,onChange:v,options:D,placeholder:s(`bulkOverrideSwapModal.targetPlaceholder`)})]}),(0,$.jsx)(jt,{tone:`info`,title:s(`bulkOverrideSwapModal.noticeTitle`),children:s(`bulkOverrideSwapModal.noticeBody`,{sourceLabel:k})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(p,{variant:`body-medium-default`,as:`p`,children:s(`bulkOverrideSwapModal.affectedSummary`,{count:w.length,profile:k})}),(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:s(`bulkOverrideSwapModal.chooseActions`)})]}),(0,$.jsx)(P,{variant:`ghost`,onClick:()=>b(j?new Set(w.map(e=>e.id)):new Set),children:s(j?`bulkOverrideSwapModal.clearAll`:`bulkOverrideSwapModal.selectAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:w.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-[var(--border-base)] px-3 py-2`,children:[(0,$.jsx)(qe,{checked:!y.has(e.id),onCheckedChange:t=>N(e.id,t===!0),disabled:x,label:e.displayName,helperText:C(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:d.get(e.id)?.via===`override`?s(`bulkOverrideSwapModal.viaOverride`):s(`bulkOverrideSwapModal.viaDefault`)})]},e.id))})]})]}),(0,$.jsxs)(W.Footer,{children:[(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:s(`bulkOverrideSwapModal.willChange`,{count:T.length})}),(0,$.jsx)(P,{variant:`ghost`,onClick:a,disabled:x,children:s(`bulkOverrideSwapModal.cancel`)}),(0,$.jsx)(P,{variant:`primary`,loading:x,disabled:!m||!g||T.length===0||x,onClick:()=>void F(),children:s(`bulkOverrideSwapModal.applyTo`,{count:T.length})})]})]})})}function lr({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,connections:o,onDraftChange:s,onToggle:u}){let{t:d}=X(`settings`),f=c({hostedInference:l.use.vellumHostedInference()}),p=ar(i),m=!i||!p?``:i.provider||i.model?ir:i.profile??``,h=m===ir,g=pe(),_=je(),v=(o??[]).some(e=>e.provider===b),y=[...E,...v?[b]:[]],x=g[0]??E[0],S=i?.provider,C=he(S)?S:S===`chatgpt`?b:void 0,w=C!==void 0&&y.some(e=>e===C),D=C??x,O=Wt(D,``,(o??[]).filter(e=>Ie(e.provider,D)))?ge(D):Ee(D,f),k=O.map(e=>({value:e.id,label:e.displayName})),A=typeof i?.model==`string`?i.model:``;if(A&&!O.some(e=>e.id===A)){let e=we(D).find(e=>e.id===A)?.displayName??A;k.push({value:A,label:d(`callSiteOverridesRow.unavailableOption`,{name:e})})}let j=!!i?.provider&&!i?.model,M=[...y.map(e=>({value:e,label:Ut[e]??e,..._(e)})),...C&&!w?[{value:C,label:d(`callSiteOverridesRow.unavailableOption`,{name:Ut[C]??C})}]:[]];function N(t){t===`__custom__`?s(e,{profile:null,provider:x,model:T(x)??``}):t===``?s(e,null):s(e,{profile:t,provider:null,model:null})}function P(t){let n=T(t)??``;s(e,{...i??{},profile:null,provider:t,model:n})}function F(t){s(e,{...i??{},model:t})}return(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,$.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,$.jsx)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:d(`callSiteOverridesRow.defaultProfileSuffix`,{label:r})})]})]}),(0,$.jsx)(Ze,{checked:p,onChange:t=>u(e,t),"aria-label":d(`callSiteOverridesRow.overrideAriaLabel`,{displayName:t}),className:`shrink-0`})]}),p&&(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(J,{value:m,onChange:N,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`start`})}),p&&h&&(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:d(`callSiteOverridesRow.providerLabel`)}),(0,$.jsx)(J,{value:D??``,onChange:P,options:M})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:d(`callSiteOverridesRow.modelLabel`)}),(0,$.jsx)(J,{value:i?.model??``,onChange:F,options:k})]})]}),j&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:d(`callSiteOverridesRow.pickModelError`)})]})]})}function ur({groups:e,drafts:t,buildProfileOptionsForRow:n,profileLabelFor:r,advisorMatchesSearch:i,connections:a,onDraftChange:o,onToggle:s}){let{t:c}=X(`settings`);return(0,$.jsx)(`div`,{className:`space-y-4`,children:e.length===0?i?null:(0,$.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:c(`overridesCallSiteList.emptySearch`)}):e.map(({domain:e,sites:i})=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(pn,{children:e.displayName}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>{let i=(()=>{let n=t[e.id]??null;return!n||!ar(n)?``:n.provider||n.model?ir:n.profile??``})(),c=e.shippedDefaultProfile??e.defaultProfile,l=c?r(c):null;return(0,$.jsx)(lr,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:l,draft:t[e.id]??null,profileOptions:n(i===``||i===`__custom__`?null:i),connections:a,onDraftChange:o,onToggle:s},e.id)})})]},e.id))})}function dr(e,t){let n={};for(let r of Object.keys(e)){let i=e[r]??null;ar(i)?n[r]={profile:i?.profile??null,provider:i?.provider??null,model:i?.model??null}:r in t&&t[r]===null&&(n[r]=null)}return n}function fr(e){let t={};for(let n of Object.keys(e))t[n]=null;return t}function pr({catalogCallSiteIds:e,persistedOverrides:t,persistedAdvisor:n,isSeeded:r}){let[i,a]=(0,Q.useState)({}),[o,s]=(0,Q.useState)(void 0),c=(0,Q.useMemo)(()=>{if(!r)return{};let n={};for(let r of e)if(r in i)n[r]=i[r];else{let e=t[r];n[r]=e?{...e}:{}}return n},[r,e,t,i]),l=o??n,u=l!==n,d=(0,Q.useMemo)(()=>{if(!r)return!1;for(let e of Object.keys(c))if(!sr(c[e],t[e]))return!0;return!1},[r,c,t]);return{drafts:c,advisorProfile:l,advisorDirty:u,callSiteDraftsDirty:d,hasUnsavedDrafts:u||d,hasValidationError:(0,Q.useMemo)(()=>Object.values(c).some(e=>ar(e)&&!!e?.provider&&!e?.model),[c]),setDraft:(0,Q.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[]),setAdvisor:(0,Q.useCallback)(e=>{s(e)},[]),clearEdits:(0,Q.useCallback)(()=>{a({}),s(void 0)},[]),buildSavePatch:(0,Q.useCallback)(()=>dr(c,i),[c,i]),buildResetPatch:(0,Q.useCallback)(()=>fr(c),[c])}}function mr({assistantId:e,onClose:t}){let{t:n}=X(`settings`),{data:i}=Y({...gt({path:{assistant_id:e}}),staleTime:3e4}),a=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),o=(0,Q.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),s=(0,Q.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),c=(0,Q.useMemo)(()=>kt(a,o),[a,o]),l=pe(),u=de(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),f=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u,requireTextGeneration:!1}),[u]),p=se(),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),{data:S,isLoading:C,isError:w,refetch:D}=Y({...ft({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),{data:k}=Y({...ne({path:{assistant_id:e}}),enabled:!!e}),A=(0,Q.useMemo)(()=>(S?.callSites??[]).filter(e=>e.id!==`mainAgent`),[S]),j=!C&&!w&&!!S,M=!!i,N=j&&M,F=(0,Q.useMemo)(()=>A.map(e=>e.id),[A]),I=i?.llm?.advisorProfile??``,{drafts:L,advisorProfile:R,advisorDirty:ee,callSiteDraftsDirty:z,hasUnsavedDrafts:B,hasValidationError:V,setDraft:H,setAdvisor:te,clearEdits:re,buildSavePatch:ie,buildResetPatch:ae}=pr({catalogCallSiteIds:F,persistedOverrides:s,persistedAdvisor:I,isSeeded:N}),oe=(0,Q.useMemo)(()=>new Set(F),[F]),U=(0,Q.useCallback)(e=>Ft(c,e),[c]),ce=(0,Q.useCallback)((e,t)=>({value:e.name,label:O(e),...yt(e,c,t)===`undispatchable`?{icon:(0,$.jsx)(tn,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:Oe(e)}:{}}),[c]),le=(0,Q.useMemo)(()=>Pe(c,[I],d).map(e=>ce(e,d)),[c,I,ce,d]),ue=(0,Q.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[m]),fe=(0,Q.useMemo)(()=>A.some(e=>or(e,s[e.id])!==null),[A,s]),me=(0,Q.useMemo)(()=>Object.entries(s).some(([e,t])=>oe.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[s,oe]),he=(0,Q.useCallback)(e=>[...Pe(c,[e],f).map(e=>ce(e,f)),{value:ir,label:n(`overridesDetailPanel.customProfileOption`)}],[c,ce,f,n]),ge=(0,Q.useMemo)(()=>{if(!m.trim())return A;let e=m.toLowerCase();return A.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[A,m]),_e=(0,Q.useMemo)(()=>{if(!S)return[];let e=S.domains.map(e=>e.id),t=new Map(S.domains.map(e=>[e.id,e])),r=[];for(let n of e){let e=ge.filter(e=>e.domain===n);e.length>0&&r.push({domain:t.get(n),sites:e})}let i=new Set(e),a=ge.filter(e=>!i.has(e.domain));return a.length>0&&r.push({domain:{id:`other`,displayName:n(`overridesDetailPanel.otherDomain`)},sites:a}),r},[S,ge,n]),ve=(0,Q.useCallback)((e,t)=>{if(!t){H(e,null);return}let n=Me(c,A.find(t=>t.id===e)?.defaultProfile,f);if(n)H(e,{profile:n});else{let t=l[0]??E[0];H(e,{provider:t,model:T(t)??``})}},[A,c,l,H,f]),ye=(0,Q.useCallback)(async()=>{_(!0);try{let r=ie();await p.mutateAsync({path:{assistant_id:e},body:{llm:{...z?{callSites:r}:{},...ee?{advisorProfile:R}:{}}}}),t(),K.success(n(`overridesDetailPanel.overridesSavedToast`))}catch(e){K.error(n(`overridesDetailPanel.saveFailedToast`)),G(e,{context:`call_site_overrides_save`})}finally{_(!1)}},[ie,z,ee,R,t,p,e,n]),be=(0,Q.useCallback)(async()=>{_(!0);try{let r=ae();await p.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:r}}}),t(),K.success(n(`overridesDetailPanel.overridesResetToast`))}catch(e){K.error(n(`overridesDetailPanel.resetFailedToast`)),G(e,{context:`call_site_overrides_reset`})}finally{_(!1)}},[ae,t,p,e,n]),xe=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[me&&(0,$.jsx)(P,{variant:`outlined`,onClick:()=>y(!0),disabled:g||!N,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:n(`overridesDetailPanel.resetToDefaults`)}),(0,$.jsx)(P,{variant:`primary`,onClick:()=>void ye(),loading:g,disabled:!B||V||g,children:n(`overridesDetailPanel.save`)})]});return(0,$.jsxs)(Le,{title:n(`overridesDetailPanel.title`),closeVariant:`outlined`,onClose:t,footer:xe,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`overridesDetailPanel.description`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(q,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:n(`overridesDetailPanel.searchPlaceholder`),leftIcon:(0,$.jsx)(sn,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(P,{variant:`outlined`,onClick:()=>x(!0),disabled:!N||g||B||!fe,title:B?n(`overridesDetailPanel.bulkChangeUnsavedTitle`):fe?void 0:n(`overridesDetailPanel.bulkChangeNoCandidatesTitle`),children:n(`overridesDetailPanel.bulkChange`)})]}),M&&ue&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(pn,{children:n(`overridesDetailPanel.advisorSection`)}),(0,$.jsx)(rr,{value:R,profileOptions:le,disabled:g,onChange:te})]}),C&&(0,$.jsx)(r,{placement:`panel`}),w&&(0,$.jsx)(jt,{tone:`error`,title:n(`overridesDetailPanel.loadErrorTitle`),actions:(0,$.jsx)(P,{variant:`outlined`,onClick:()=>void D(),children:n(`overridesDetailPanel.retry`)}),children:n(`overridesDetailPanel.loadErrorHint`)}),!C&&!w&&S&&(0,$.jsx)(ur,{groups:_e,drafts:L,buildProfileOptionsForRow:he,profileLabelFor:U,advisorMatchesSearch:ue,connections:k?.connections,onDraftChange:H,onToggle:ve})]})]}),b&&S&&(0,$.jsx)(cr,{assistantId:e,callSites:A,domains:S.domains,persistedOverrides:s,orderedProfiles:c,onClose:()=>x(!1),onApplied:re}),(0,$.jsx)(bt,{open:v,title:n(`overridesDetailPanel.resetToDefaults`),message:n(`overridesDetailPanel.resetConfirmMessage`),confirmLabel:n(`overridesDetailPanel.resetToDefaults`),destructive:!0,onConfirm:()=>{y(!1),be()},onCancel:()=>y(!1)})]})}var hr=e(Yt(),1);function gr({mode:e,connection:r,assistantId:i,existingNames:a,connections:o,variant:s=`modal`,actionsSlot:c,onSave:l,onCancel:u}){let{t:d}=X(`settings`),[f,m]=(0,Q.useState)(r?.label??``),h=r?.name??``,g=r?.provider??`anthropic`,_=r?.auth.type??`api_key`,[v,y]=(0,Q.useState)(()=>r?.auth.type===`api_key`?r.auth.credential:r?``:`credential/anthropic/api_key`),[b,x]=(0,Q.useState)(r?.baseUrl??``),[S,T]=(0,Q.useState)(()=>r?.models?r.models.map(e=>e.id).join(`, `):``),[E,D]=(0,Q.useState)(!1),[O,A]=(0,Q.useState)(null),j=g===`openai-compatible`,M=Tt(g),N=xt(g),[F,I]=(0,Q.useState)(``),[L,R]=(0,Q.useState)(!1),ee=Jt(),z=(0,Q.useMemo)(()=>Ye(v),[v]),B=_===`api_key`&&z!==null,{hasStoredCredential:V,isLoading:H}=w({assistantId:i,credentialKind:`credential`,credentialName:z?`${z.service}:${z.field}`:``,enabled:B}),{credentials:te}=Ne({assistantId:i,enabled:_===`api_key`});(0,Q.useEffect)(()=>{let e=r?.provider??`anthropic`;m(r?.label??``),r?.auth.type===`api_key`?y(r.auth.credential):y(r?``:`credential/${e}/api_key`),A(null),x(r?.baseUrl??``),T(r?.models?r.models.map(e=>e.id).join(`, `):``),I(``),R(!1)},[r]);let ne=f.trim()!==(r?.label??``).trim(),re=j&&ne?t(f,o,r?.name):null,ie=h.trim().length>0&&re===null;async function ae(){if(ie){D(!0),A(null);try{let e;if(_===`api_key`){let t=v.trim()||`credential/${g}/api_key`,n=F.trim();if(n){R(!0);try{let e=Ye(t);await pt({path:{assistant_id:i},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:n}:{type:`api_key`,name:g,value:n},throwOnError:!0});let r=De(i,`credential`,e?`${e.service}:${e.field}`:``);ee.setQueryData(r,!0),ee.invalidateQueries({queryKey:Ge({path:{assistant_id:i}})})}catch{A(d(`providerEditorContent.failedSaveApiKey`));return}finally{R(!1)}}e={type:`api_key`,credential:t}}else if(r)e=r.auth;else{A(d(`providerEditorContent.nothingToEdit`));return}let t=f.trim()||null,a={auth:e,label:t,...M&&{base_url:b.trim()||null},...N&&{models:S.trim()?S.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:o,error:s,response:c}=await C({path:{assistant_id:i,name:r?.name??h.trim()},body:a});if(!c?.ok){A(rt(c?.status,s)??n(c?.status));return}if(!o){A(d(`providerEditorContent.emptyServerResponse`));return}Be(o,d),l(o)}catch{A(d(`providerEditorContent.failedSaveProvider`))}finally{D(!1)}}}let oe=te.filter(e=>e.service===g),U=e!==`create`&&r?.auth.type===`api_key`,se=oe.length>0||U,ce=Ae(d(`providerEditorContent.apiKeyPlaceholder`),V);if(e===`create`)return(0,$.jsx)(k,{variant:s===`panel`?`inline`:`modal`,actionsSlot:c,assistantId:i,existingNames:a,connections:o,defaultProviderType:g,onCreated:l,onCancel:u});let le=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:(0,$.jsx)(Kt,{i18nKey:`providerEditorContent.displayNameLabel`,ns:`settings`,components:{optional:(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`})}})}),(0,$.jsx)(q,{value:f,onChange:e=>m(e.target.value),placeholder:d(`providerEditorContent.displayNamePlaceholder`),fullWidth:!0}),re?(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:fe[re]}):null]}),M&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:d(`providerEditorContent.baseUrlLabel`)}),(0,$.jsx)(q,{value:b,onChange:e=>x(e.target.value),placeholder:d(g===`ollama`?`providerEditorContent.baseUrlPlaceholderOllama`:g===`opencode`?`providerEditorContent.baseUrlPlaceholderOpencode`:`providerEditorContent.baseUrlPlaceholder`),fullWidth:!0}),g===`ollama`?(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:d(`providerEditorContent.baseUrlHintOllama`)}):null,g===`opencode`?(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:d(`providerEditorContent.baseUrlHintOpencode`)}):null]}),N&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:d(`providerEditorContent.modelsLabel`)}),(0,$.jsx)(q,{value:S,onChange:e=>T(e.target.value),placeholder:d(`providerEditorContent.modelsPlaceholder`),fullWidth:!0}),(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:d(`providerEditorContent.modelsHint`)})]}),_===`api_key`&&(0,$.jsx)(Fe,{apiKeyValue:F,onApiKeyChange:I,credential:v,onCredentialChange:y,isLoadingCredential:H,apiKeyPlaceholder:ce,provider:g,providerCredentials:oe,showAdvancedSection:se,onError:A}),_===`oauth_subscription`&&(0,$.jsx)(Ot,{assistantId:i,onConnected:l}),O&&(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:O})]}),ue=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{variant:`ghost`,onClick:u,children:d(`providerEditorContent.cancel`)}),(0,$.jsx)(P,{variant:`primary`,disabled:!ie||E||L,onClick:()=>void ae(),children:d(E?`providerEditorContent.saving`:`providerEditorContent.saveChanges`)})]});return s===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[le,c===void 0?(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:ue}):c&&(0,hr.createPortal)(ue,c)]}):(0,$.jsxs)(W.Content,{size:`md`,children:[(0,$.jsxs)(W.Header,{children:[(0,$.jsx)(W.Title,{children:d(`providerEditorContent.editProviderTitle`)}),(0,$.jsx)(W.Description,{children:r?d(`providerEditorContent.editingConnection`,{name:mt(r)}):d(`providerEditorContent.editProviderSettingsFallback`)})]}),(0,$.jsx)(W.Body,{children:le}),(0,$.jsx)(W.Footer,{children:ue})]})}function _r({assistantId:e,connectionName:t,onClose:n}){let{t:i}=X(`settings`),a=Jt(),[o,s]=(0,Q.useState)(null),{data:c,isLoading:l}=Y(ne({path:{assistant_id:e}})),u=(0,Q.useMemo)(()=>c?.connections??[],[c]),d=(0,Q.useMemo)(()=>t==null?void 0:u.find(e=>e.name===t),[t,u]),f=t!=null&&c!=null&&d==null;(0,Q.useEffect)(()=>{f&&n()},[f,n]);function p(){a.invalidateQueries({queryKey:ce({path:{assistant_id:e}})}),a.invalidateQueries({queryKey:Je({path:{assistant_id:e}})}),n()}return(0,$.jsx)(Le,{title:d?mt(d):i(`providerDetailPanel.addProviderTitle`),closeVariant:`outlined`,onClose:n,footer:(0,$.jsx)(`div`,{ref:s,className:`flex justify-end gap-2`}),children:t!=null&&l?(0,$.jsx)(r,{placement:`panel`}):t==null||d!=null?(0,$.jsx)(gr,{mode:d?`edit`:`create`,connection:d,variant:`panel`,actionsSlot:o,assistantId:e,existingNames:u.map(e=>e.name),connections:u,onSave:p,onCancel:n}):null})}var vr={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},yr={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},br=`deepgram`;function xr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:r}={}){let i=Et(),o=e??i,c=A(),l=Jt(),{t:u}=X(),d=(0,Q.useMemo)(()=>le(Qe(),{displayName:u(`sttProviderForm.windowsNativeDisplayName`),subtitle:u(`sttProviderForm.windowsNativeSubtitle`),setupWarning:u(`sttProviderForm.windowsNativeSetupWarning`)}).filter(e=>!e.requiresNativeDictation||S()),[u]),f=br,{data:p}=Y({...gt({path:{assistant_id:o}}),enabled:c,staleTime:3e4}),m=p?.services?.stt,h=m?.mode===`managed`?`vellum`:m?.provider,g=(0,Q.useMemo)(()=>{let e=h?yr[h]:void 0;if(e&&d.some(t=>t.id===e))return e;let t=a(Vt,f);return d.some(e=>e.id===t)?t:f},[h,d,f]),_=!!h,[v,y]=yn(g),{available:b,currentCode:x,configuredProviderId:C,selectLanguage:w,selecting:T}=St(o),[E,D]=(0,Q.useState)(!1),O=b&&v===g&&(vr[v]?.provider===C||!!h&&!yr[h]),[k,j]=(0,Q.useState)(``),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=a(Vt,f);e===`macos-native`&&!d.some(t=>t.id===e)&&V(Vt,f)},[d,f]);let I=(0,Q.useMemo)(()=>d.find(e=>e.id===v)??d[0],[d,v]),L=I.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{N(a(At+v,``).length>0),j(``)},[v]);let R=(0,Q.useMemo)(()=>{let e=v!==g,t=k.trim().length>0;return e||t},[v,g,k]),ee=(0,Q.useCallback)(async()=>{let e=k.trim();V(Vt,v),e.length>0&&V(At+v,e);let t=vr[v];F(!0);try{if(t?.credentialService){let n=e.length>0?e:a(At+v,``);if(n.length>0){let{response:e}=await s({path:{assistant_id:o},body:{service:t.credentialService,field:`api_key`,value:n,label:`${I.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(v!==g||!_)||h===`vellum`&&v!==`vellum`){let e=t?.provider??br,{response:n}=await Lt({path:{assistant_id:o},body:{services:{stt:{provider:e,mode:e===`vellum`?`managed`:`your-own`}}},throwOnError:!1});if(!n?.ok)throw Error(`Failed to save configuration (HTTP ${n?.status??`?`})`)}return e.length>0&&N(!0),j(``),l.invalidateQueries({queryKey:wt({path:{assistant_id:o}})}),K.success(u(`sttProviderForm.saveSuccess`)),!0}catch(e){return K.error(e instanceof Error?e.message:u(`sttProviderForm.saveFailed`)),!1}finally{F(!1)}},[o,v,k,I,g,_,h,l,u]);(0,Q.useEffect)(()=>{r?.({hasChanges:R,saving:P,save:ee})},[r,R,P,ee]);let z=(0,Q.useCallback)(()=>{V(At+v,``),N(!1),j(``)},[v]),B=M?u(`sttProviderForm.apiKeyPlaceholderReplace`):I.apiKeyPlaceholder;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:u(`sttProviderForm.providerLabel`)}),(0,$.jsx)(J,{value:v,onChange:y,options:d.map(e=>({value:e.id,label:e.displayName})),"aria-label":u(`sttProviderForm.providerAriaLabel`)})]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:u(`sttProviderForm.spokenLanguage`)}),(0,$.jsx)(_t,{"aria-label":u(`sttProviderForm.spokenLanguage`),"aria-haspopup":`dialog`,onClick:()=>D(!0),value:Ve(x,C)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:u(`sttProviderForm.spokenLanguageApplies`)}),(0,$.jsx)(_n,{open:E,onOpenChange:D,title:u(`sttProviderForm.spokenLanguage`),currentCode:x,configuredProviderId:C,selectLanguage:w,selecting:T})]}),L&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:u(`sttProviderForm.apiKeyLabel`)}),(0,$.jsx)(q,{type:`password`,value:k,onChange:e=>j(e.target.value),placeholder:B,fullWidth:!0})]}),I.setupWarning&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)($t,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,$.jsx)(`span`,{children:I.setupWarning})]}),!n&&I.credentialsGuide&&(0,$.jsx)(fn,{guide:I.credentialsGuide}),v===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:u(`sttProviderForm.vellumTranscription`)}),(!t||M)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!t&&(0,$.jsx)(dn,{onClick:ee,disabled:!R||P}),M&&(0,$.jsx)(un,{onClick:z})]})]})}var Sr={batch:`sttRoleOverrides.role.batch`,dictation:`sttRoleOverrides.role.dictation`,liveVoice:`sttRoleOverrides.role.liveVoice`,telephony:`sttRoleOverrides.role.telephony`,watch:`sttRoleOverrides.role.watch`};function Cr(e){let t=e?.roles;if(!t)return[];let n=e?.provider,r=n?e?.providers?.[n]?.model:void 0,i=[];for(let[e,a]of Object.entries(t)){let t=a?.provider;t&&(t===n&&a?.model===r||i.push({role:e,provider:t,...a?.model===void 0?{}:{model:a.model}}))}return i}function wr({assistantId:e}){let{t}=X(`settings`),n=Jt(),r=A(),[i,a]=(0,Q.useState)(null),{data:o}=Y({...gt({path:{assistant_id:e}}),enabled:r,staleTime:3e4}),s=o?.services?.stt,c=Cr(s),{data:l}=Y({...Bt({path:{assistant_id:e}}),enabled:r&&c.length>0,staleTime:5*6e4});if(c.length===0)return null;let u=e=>l?.providers?.find(t=>t.id===e)?.displayName??e,d=async r=>{a(r);try{let{response:t}=await Lt({path:{assistant_id:e},body:{services:{stt:{roles:{[r]:null}}}},throwOnError:!1});if(!t?.ok)throw Error(String(t?.status??``));await n.invalidateQueries({queryKey:wt({path:{assistant_id:e}})})}catch{K.error(t(`sttRoleOverrides.clearFailed`))}finally{a(null)}};return(0,$.jsxs)(`div`,{className:`mt-1 flex flex-col gap-2 border-t border-[var(--border-subtle)] pt-4`,children:[(0,$.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:t(`sttRoleOverrides.title`)}),(0,$.jsx)(`ul`,{className:`flex flex-col gap-1`,children:c.map(e=>{let n=Sr[e.role];return(0,$.jsxs)(`li`,{className:`flex items-center gap-4 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-lighter text-[var(--content-default)]`,children:n?t(n):e.role}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-body-small-default text-[var(--content-default)]`,children:e.model?`${u(e.provider)} · ${e.model}`:u(e.provider)}),(0,$.jsx)(P,{variant:`ghost`,size:`compact`,"aria-label":t(`sttRoleOverrides.clearAria`,{feature:n?t(n):e.role}),className:`[--vbtn-fg:var(--content-tertiary)]`,disabled:i===e.role,onClick:()=>void d(e.role),children:t(`sttRoleOverrides.clear`)})]},e.role)})})]})}function Tr(){let{t:e}=X(`settings`),t=Et();return(0,$.jsxs)(ln,{title:e(`speechToTextCard.title`),subtitle:e(`speechToTextCard.subtitle`),children:[(0,$.jsx)(xr,{}),(0,$.jsx)(wr,{assistantId:t})]})}async function Er(e){let{provider:t,apiKey:n,voiceId:r,text:i}=e;if(n.trim().length===0)return{kind:`error`,message:`Save an API key for this provider first.`};try{return t===`elevenlabs`?await Dr(n,r,i):t===`deepgram`?await Or(n,i):t===`fish-audio`?{kind:`unsupported`,message:`Fish Audio TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:t===`xai`?{kind:`unsupported`,message:`xAI TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:{kind:`unsupported`,message:`TTS testing for "${t}" is not supported from the browser yet.`}}catch(e){return{kind:`error`,message:e instanceof Error?e.message:`Failed to reach the TTS provider.`}}}async function Dr(e,t,n){let r=t.trim();if(r.length===0)return{kind:`error`,message:`Enter and save a Voice ID before testing ElevenLabs.`};let i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(r)}?output_format=mp3_44100_128`,{method:`POST`,headers:{"xi-api-key":e,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:n,model_id:`eleven_turbo_v2_5`})});return i.ok?{kind:`audio`,blob:await i.blob()}:{kind:`error`,message:await kr(i,`ElevenLabs rejected the request.`)}}async function Or(e,t){let n=await fetch(`https://api.deepgram.com/v1/speak?model=aura-2-thalia-en`,{method:`POST`,headers:{Authorization:`Token ${e}`,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:t})});return n.ok?{kind:`audio`,blob:await n.blob()}:{kind:`error`,message:await kr(n,`Deepgram rejected the request.`)}}async function kr(e,t){try{let n=await e.text();if(n.length===0)return`${t} (HTTP ${e.status})`;try{let e=JSON.parse(n);if(e&&typeof e==`object`&&`detail`in e&&typeof e.detail==`string`)return e.detail;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message}catch{}return n.slice(0,200)}catch{return`${t} (HTTP ${e.status})`}}function Ar({assistantId:e,value:t,onChange:n,className:r}){let{t:i}=X(),[a,o]=(0,Q.useState)(!1),{voices:s}=xe(e);if(s.length===0)return null;let c=s.find(e=>e.model===t)??s[0];return(0,$.jsxs)(nt.Root,{open:a,onOpenChange:o,children:[(0,$.jsx)(nt.Trigger,{asChild:!0,children:(0,$.jsx)(_t,{"aria-label":i(`voicePickerField.ariaLabel`),value:c?Nt(c.description):i(`voicePickerField.selectVoice`),className:r})}),(0,$.jsx)(nt.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)(Xe,{assistantId:e,value:t,onChange:n,onSelect:()=>o(!1),showSource:!0,autoScrollToSelected:!0})})]})}var jr={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Mr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:r}={}){let{t:i}=X(),o=Et(),c=e??o,l=j.use.name()??`your assistant`,u=A(),d=Jt(),{data:f}=Y({...Ue({path:{assistant_id:c}}),enabled:u,staleTime:1/0}),p=(0,Q.useMemo)(()=>{let e=f?.providers;if(!e)return ct;if(e.some(e=>e.id===`vellum`))return e;let t=ct.find(e=>e.id===`vellum`);return t?[t,...e]:e},[f]),{data:m}=Y({...gt({path:{assistant_id:c}}),enabled:u,staleTime:3e4}),h=m?.services?.tts,g=h?.mode===`managed`?`vellum`:h?.provider,_=`elevenlabs`,v=(0,Q.useMemo)(()=>g??a(`vellum:voice:ttsProvider`,_),[g,_]),b=!!g,[x,S]=yn(v),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(``),[D,O]=(0,Q.useState)(``),[k,M]=(0,Q.useState)(!1),[N,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1),{voices:R,defaultModel:ee,fetched:z}=y(c,{enabled:x===`vellum`}),B=h?.providers?.vellum?.model??ee??``,[H,te]=yn(B),ne=R.find(e=>e.model===H)??R[0],[re,ie]=(0,Q.useState)(null),ae=R.some(e=>e.model===B),oe=re??(z&&B!==``&&!ae),U=(0,Q.useMemo)(()=>p.find(e=>e.id===x)??p[0],[x,p]),se=x===`vellum`&&U.supportsVoiceSelection&&H.trim()!==``&&H.trim()!==B,ce=(0,Q.useCallback)(e=>{let t=a(We+e,``),n=a(ve+e,``);M(t.length>0),E(n),O(n),w(``)},[]);(0,Q.useEffect)(()=>{ce(x)},[x,ce]);let le=(0,Q.useMemo)(()=>{let e=x!==v,t=C.trim().length>0,n=T.trim()!==D;return e||t||n||se},[x,v,C,T,D,se]),ue=(0,Q.useCallback)(async()=>{let e=C.trim(),t=T.trim(),n=U.id;V(It,n),e.length>0&&V(We+n,e),V(ve+n,t);let r=e.length>0?e:a(We+n,``),o=jr[n];L(!0);try{if(r.length>0){let{response:e}=await s({path:{assistant_id:c},body:{service:n,field:`api_key`,value:r,label:`${U.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...x!==v||!b?{provider:n,mode:n===`vellum`?`managed`:`your-own`}:{},...o?{providers:{[n]:{[o]:t}}}:{},...se?{providers:{vellum:{model:H.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await Lt({path:{assistant_id:c},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(r.length>0),O(t),w(``),d.invalidateQueries({queryKey:wt({path:{assistant_id:c}})}),K.success(i(`ttsProviderForm.saved`)),!0}catch(e){return K.error(e instanceof Error?e.message:i(`ttsProviderForm.saveFailed`)),!1}finally{L(!1)}},[c,x,H,se,C,T,U,v,b,d,i]);(0,Q.useEffect)(()=>{r?.({hasChanges:le,saving:I,save:ue})},[r,le,I,ue]);let de=(0,Q.useCallback)(()=>{V(We+x,``),M(!1),w(``)},[x]),fe=(0,Q.useCallback)(async()=>{F(!0);try{let e=a(We+x,``),t=C.trim(),n=t.length>0?t:e;if(n.length===0){K.error(i(`ttsProviderForm.apiKeyRequired`));return}let r=a(ve+x,``),o=T.trim(),s=await Er({provider:x,apiKey:n,voiceId:o.length>0?o:r,text:`Hey! It's ${l}. How does this sound?`});if(s.kind!==`audio`){K.error(s.message);return}let c=URL.createObjectURL(s.blob);try{let e=new Audio(c);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(c)}}finally{F(!1)}},[l,C,x,T,i]),pe=k?`•••••••• (Enter a new key to replace)`:U.apiKeyPlaceholder,me=x===`vellum`,he=me&&U.supportsVoiceSelection,ge=(0,$.jsxs)(P,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{ie(!1),R.some(e=>e.model===H)||te(ee||R[0]?.model||``)},children:[(0,$.jsx)(nn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(`ttsProviderForm.chooseFromCatalog`)]}),_e=he&&oe&&R.length>0?ge:null;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.provider`)}),(0,$.jsx)(J,{value:x,onChange:S,options:p.map(e=>({value:e.id,label:e.displayName})),"aria-label":i(`ttsProviderForm.providerAriaLabel`)})]}),!me&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.apiKey`)}),(0,$.jsx)(q,{type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:pe,fullWidth:!0})]}),he&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.voice`)}),oe?(0,$.jsx)(q,{type:`text`,value:H,onChange:e=>te(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),"aria-label":i(`ttsProviderForm.customVoiceIdAriaLabel`),fullWidth:!0}):ne?(0,$.jsx)(Ar,{assistantId:c,value:H,onChange:te}):z&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.noManagedVoices`)})]}),U.supportsVoiceSelection&&!me&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.voiceId`)}),(0,$.jsx)(q,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),fullWidth:!0})]}),!n&&!me&&(0,$.jsx)(fn,{guide:U.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!me&&(0,$.jsx)(P,{variant:`outlined`,onClick:fe,disabled:N,children:i(N?`ttsProviderForm.testing`:`ttsProviderForm.test`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[_e,!t&&(0,$.jsx)(dn,{onClick:ue,disabled:!le||I}),k&&!me&&(0,$.jsx)(un,{onClick:de})]})]})]})}function Nr(){let{t:e}=X(`settings`);return(0,$.jsx)(ln,{id:`text-to-speech`,title:e(`textToSpeechCard.title`),subtitle:e(`textToSpeechCard.subtitle`),children:(0,$.jsx)(Mr,{})})}var Pr=`default`;function Fr(){let{t:e}=X(`settings`),t=Et(),n=Jt(),{data:r}=Y({...gt({path:{assistant_id:t}}),staleTime:3e4}),i=be({onSuccess:e=>{Ke(n,{path:{assistant_id:t}},e)}}),s=vn(),c=(0,Q.useMemo)(()=>r?r.services?.[`web-fetch`]?.provider||a(`vellum:ai:webFetchProvider`,Pr):a(f,Pr),[r]),l=(0,Q.useMemo)(()=>r?.services?.[`web-fetch`]?.apiBase??``,[r]),[u,d]=(0,Q.useState)(!1),[p,m]=yn(c),[h,g]=yn(l),[_,v]=(0,Q.useState)(``),y=lt.has(p),b=o.has(p),{hasStoredCredential:x}=w({assistantId:t,credentialKind:`api_key`,credentialName:p,enabled:b}),S=_.trim().length>0,C=h.trim(),T=et(p,y&&C.length>0),E=p!==c||y&&C!==l.trim(),D=u||b&&!T&&!x&&!S||!E&&!S,O=Ae(U[p]??e(`webFetchCard.apiKeyPlaceholder`),x),k=at[p]??``,A=(0,Q.useCallback)(async()=>{d(!0);let r=_.trim(),a=b&&r.length>0;try{a&&await s(p,r),await i.mutateAsync({path:{assistant_id:t},body:{services:{"web-fetch":{provider:p,...y?{apiBase:C}:{}}}}}).catch(t=>{throw K.error(e(`webFetchCard.configUpdateFailedToast`)),G(t,{context:`patch_daemon_config`}),t})}catch{d(!1);return}d(!1);try{if(V(f,p),a){let e=zt(p);e&&V(e,r);let i=De(t,`api_key`,p);n.setQueryData(i,!0),n.invalidateQueries({queryKey:i}),v(``)}K.success(e(`webFetchCard.savedToast`))}catch(t){G(t,{context:`settings-ai-web-fetch-persist-local`}),K.error(e(`webFetchCard.localPreferencesFailedToast`))}},[b,i,s,n,t,_,p,y,C,e]),j=(0,Q.useCallback)(()=>{let e=zt(p);e&&it(e),v(``),g(``),m(Pr),V(f,Pr)},[p,m,g]);return(0,$.jsx)(ln,{id:`web-fetch`,title:e(`webFetchCard.title`),subtitle:e(`webFetchCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`webFetchCard.providerLabel`)}),(0,$.jsx)(J,{value:p,onChange:m,options:H.map(e=>({value:e,label:R[e]??e}))})]}),y&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{label:e(`webFetchCard.apiBaseLabel`),type:`url`,value:h,onChange:e=>g(e.target.value),placeholder:k||e(`webFetchCard.apiBasePlaceholder`),fullWidth:!0}),k?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webFetchCard.apiBaseHint`,{defaultBase:k})}):null]}),b&&(0,$.jsx)(q,{label:e(`webFetchCard.apiKeyLabel`),type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:O,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:A,disabled:D}),u&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),b&&(0,$.jsx)(un,{onClick:j,filled:!0})]})]})})}var Ir=`0.10.12`;function Lr(){return h(Ir)}function Rr(){let{t:e}=X(`settings`),t=Et(),n=Jt(),r=A(),{data:i}=Y({...gt({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),o=be({onSuccess:e=>{Ke(n,{path:{assistant_id:t}},e)}}),s=vn(),c=(0,Q.useMemo)(()=>{if(!i)return a(Pt,`inference-provider-native`);let e=i.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||a(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[i]),l=(0,Q.useMemo)(()=>i?.services?.[`web-search`]?.apiBase??``,[i]),[u,f]=(0,Q.useState)(!1),[p,h]=yn(c),[g,_]=yn(l),[y,b]=(0,Q.useState)(``),x=_e.has(p),S=d.has(p),C=Mt.has(p),{hasStoredCredential:T}=w({assistantId:t,credentialKind:`api_key`,credentialName:p,enabled:S}),E=y.trim().length>0,D=g.trim(),O=et(p,x&&D.length>0),k=p!==c||x&&D!==l.trim(),j=ye[p]??``,M=S&&!C&&!O&&!T&&!E,N=x&&j.length===0&&!D,P=u||M||N||!k&&!E,F=Ae(ie[p]??e(`webSearchCard.apiKeyPlaceholder`),T),I=(0,Q.useCallback)(async()=>{f(!0);let r=y.trim(),i=He(p),a=S&&r.length>0;try{a&&await s(p,r),await ot();let n=p===`vellum`?Lr()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:p,mode:`your-own`,...x?{apiBase:D}:{}};await o.mutateAsync({path:{assistant_id:t},body:{services:{"web-search":n}}}).catch(t=>{throw K.error(e(`webSearchCard.configUpdateFailedToast`)),G(t,{context:`patch_daemon_config`}),t})}catch{f(!1);return}f(!1);try{if(V(Pt,p),a){i&&V(i,r);let e=De(t,`api_key`,p);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),b(``)}K.success(e(`webSearchCard.savedToast`))}catch(t){G(t,{context:`settings-ai-web-search-persist-local`}),K.error(e(`webSearchCard.localPreferencesFailedToast`))}},[S,o,s,n,t,y,p,x,D,e]),L=(0,Q.useCallback)(()=>{let e=He(p);e&&it(e),b(``),_(``),h(`inference-provider-native`),V(Pt,`inference-provider-native`)},[p,h,_]);return(0,$.jsx)(ln,{title:e(`webSearchCard.title`),subtitle:e(`webSearchCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`webSearchCard.providerLabel`)}),(0,$.jsx)(J,{"aria-label":e(`webSearchCard.providerAriaLabel`),value:p,onChange:h,options:m.map(e=>({value:e,label:v[e]??e}))})]}),p===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.vellumNote`)}),x&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{label:e(`webSearchCard.apiBaseLabel`),type:`url`,value:g,onChange:e=>_(e.target.value),placeholder:j||e(`webSearchCard.apiBasePlaceholder`),fullWidth:!0}),j?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.apiBaseHint`,{defaultBase:j})}):null]}),S&&(0,$.jsx)(q,{label:e(`webSearchCard.apiKeyLabel`),type:`password`,value:y,onChange:e=>b(e.target.value),placeholder:F,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:I,disabled:P}),u&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),S&&(0,$.jsx)(un,{onClick:L,filled:!0})]})]})})}function zr(){let e=Et(),t=N(),[n,r]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]);let i=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto`,children:[(0,$.jsx)(tr,{}),(0,$.jsx)($n,{panel:n,onOpenPanel:r,onClosePanel:()=>r(null)}),(0,$.jsx)(Rr,{}),(0,$.jsx)(Fr,{}),(0,$.jsx)(wn,{}),(0,$.jsx)(Nr,{}),(0,$.jsx)(Tr,{})]}),a=`${e??`none`}:${n?.kind===`profile`?`profile:${n.name}`:n?.kind===`provider`?`provider:${n.name}`:n?.kind??`closed`}`,o=n?.kind===`provider`||n?.kind===`add-provider`,s=n!=null&&e?n.kind===`overrides`?(0,$.jsx)(mr,{assistantId:e,onClose:()=>r(null)},a):o?(0,$.jsx)(_r,{assistantId:e,connectionName:n.kind===`provider`?n.name:null,onClose:()=>r(null)},a):(0,$.jsx)(nr,{assistantId:e,profileName:n.kind===`profile`?n.name:null,onClose:()=>r(null)},a):null;return s&&t?(0,$.jsx)(mn,{children:s}):s?(0,$.jsx)(gn,{storageKey:`aiSettingsDetailDrawerWidth`,detailKey:a,section:i,detail:s}):i}export{zr as AiPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$f as t,$m as n,$n as r,AC as i,AS as a,Ab as o,Av as s,Bb as c,Bf as l,Bi as u,Cb as d,Cs as f,DC as p,Db as m,Dg as h,Ds as g,ES as _,Eb as v,Eo as y,Fb as b,Ff as x,Fs as S,Fv as C,Gm as w,Hb as T,Ib as E,If as D,J as O,Jf as k,Jm as A,Jx as j,K as M,Kl as N,LC as P,Lb as F,Lf as I,MC as L,Mb as R,Mm as ee,Mp as z,Ms as B,NS as V,Nb as H,Nf as te,Np as ne,Ns as re,Ob as ie,Og as ae,Os as oe,Pb as U,Pf as se,Pp as ce,Ps as le,Pv as ue,Q as de,Qf as fe,Qm as pe,Qv as me,Rb as he,Rf as ge,Sb as _e,Ss as ve,Tb as ye,Tm as be,To as xe,Ts as Se,US as Ce,Ub as we,Vb as Te,Wb as Ee,Wm as De,X as Oe,XS as ke,Xf as Ae,Xm as je,Y as Me,Yf as Ne,Z as Pe,Zf as Fe,Zm as Ie,Zn as Le,_b as Re,_s as ze,aC as W,ah as Be,at as Ve,bS as G,bb as He,bm as Ue,bs as We,cm as Ge,cp as Ke,dC as qe,dp as Je,eh as Ye,en as Xe,fC as Ze,fg as Qe,fp as $e,gb as et,gs as tt,hC as nt,iC as K,ih as rt,jS as it,jb as at,jg as ot,jp as st,js as ct,kb as lt,ks as ut,ky as dt,lp as ft,my as pt,nh as mt,om as ht,op as gt,ot as _t,pC as q,pn as vt,q as yt,rC as bt,rh as xt,rt as St,sm as Ct,sp as wt,tC as J,th as Tt,tt as Et,up as Dt,uv as Ot,vb as kt,vs as At,wC as jt,wb as Mt,wo as Nt,ws as Pt,xb as Ft,xs as It,xv as Lt,yC as Rt,yb as zt,ym as Bt,ys as Vt,zC as Ht,zb as Ut,zf as Wt,zi as Gt}from"./app-BcXqNg4_.js";import{$n as Y,E as X,O as Kt,Xn as qt,j as Z,nr as Jt}from"./vendor-DwMhK7fD.js";import{b as Yt,t as Xt,x as Zt}from"./react-B9IgSVeK.js";import{A as Qt,D as $t,Lt as en,Ui as tn,Xn as nn,Yn as rn,Zr as an,fr as on,vt as sn}from"./icons-C0wyat6T.js";import{t as cn}from"./ellipsis-vertical-Bg7ccW1x.js";import{i as ln,n as un,r as dn,t as fn}from"./service-form-controls-MUXqVY5y.js";import{o as pn}from"./detail-primitives-DV1LUqyp.js";import{d as mn,o as hn,u as gn}from"./schedules-Dk6DklG6.js";import{t as _n}from"./stt-language-picker-modal-BV-QTu7_.js";var Q=e(Zt(),1);function vn(){let e=Et();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await pt({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});Re(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?K.error(Z(`settings:useDaemonConfig.assistantNotReadyToast`)):K.error(Z(`settings:useDaemonConfig.saveApiKeyFailedToast`,{providerName:t})),G(e,{context:`provision_provider_key`}),e}},[e])}function yn(e){let[t,n]=(0,Q.useState)(void 0);return(0,Q.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Q.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}var bn=`0.11.0`;function xn(){return h(bn)}var $=Xt(),Sn=`gemini-3.1-flash-image-preview`;function Cn(e,t){return e===`openrouter`?`openrouter`:re(t)}function wn(){let{t:e}=X(`settings`),t=Et(),n=Jt(),r=A(),{data:i}=Y({...gt({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),o=be({onSuccess:e=>{Ke(n,{path:{assistant_id:t}},e)}}),s=vn(),c=i?.services?.[`image-generation`],l=(0,Q.useMemo)(()=>i?c?.mode===`managed`?`vellum`:c?.provider||a(`vellum:ai:imageGenProvider`,`gemini`):a(ze,`gemini`),[i,c?.mode,c?.provider]),[u,d]=yn(l),[f,p]=(0,Q.useState)(()=>a(tt,Sn)),[m,h]=(0,Q.useState)(null),_=l===`openrouter`&&typeof c?.model==`string`?c.model:void 0,v=m??_??a(`vellum:ai:imageGenModel`,`google/gemini-3.1-flash-image-preview`),y=u===`openrouter`,b=B(u),x=y?v.trim()||`google/gemini-3.1-flash-image-preview`:b.includes(f)?f:b[0]??Sn,[S,C]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(!1),D=oe.map(e=>({value:e,label:ut[e]??e})),O=(0,Q.useMemo)(()=>B(u).map(e=>({value:e,label:g[e]??e})),[u]),k=u===`gemini`||u===`openai`||u===`openrouter`,{hasStoredCredential:j}=w({assistantId:t,credentialKind:`api_key`,credentialName:u,enabled:k}),M=(0,Q.useCallback)(e=>{d(e),e===`openrouter`&&m===null&&h(_??`google/gemini-3.1-flash-image-preview`)},[m,_,d]),N=(0,Q.useCallback)(async()=>{E(!0);let r=S.trim(),i=k&&r.length>0;try{await ot(),i&&await s(Cn(u,x),r);let a=u===`vellum`&&!xn()?{mode:`managed`}:{provider:u,mode:u===`vellum`?`managed`:`your-own`};await o.mutateAsync({path:{assistant_id:t},body:{services:{"image-generation":a}}}).catch(t=>{throw K.error(e(`imageGenerationCard.configUpdateFailedToast`)),G(t,{context:`patch_daemon_config`}),t});try{await me({path:{assistant_id:t},body:{modelId:x},throwOnError:!0})}catch(t){throw K.error(e(`imageGenerationCard.modelUpdateFailedToast`)),G(t,{context:`set_image_gen_model`}),t}finally{n.invalidateQueries({queryKey:wt({path:{assistant_id:t}})})}}catch{E(!1);return}E(!1);try{if(V(ze,u),V(tt,x),i){let e=De(t,`api_key`,u);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),C(``)}K.success(e(`imageGenerationCard.savedToast`))}catch(t){G(t,{context:`settings-ai-image-gen-persist-local`}),K.error(e(`imageGenerationCard.localPreferencesFailedToast`))}},[S,u,k,x,t,o,s,n,e]),P=(0,Q.useCallback)(()=>{if(C(``),u===`openrouter`){h(Se),V(tt,Se);return}p(Sn),V(tt,Sn)},[u]),F=e(u===`openai`?`imageGenerationCard.openaiApiKeyPlaceholder`:u===`openrouter`?`imageGenerationCard.openrouterApiKeyPlaceholder`:`imageGenerationCard.geminiApiKeyPlaceholder`);return(0,$.jsx)(ln,{title:e(`imageGenerationCard.title`),subtitle:e(`imageGenerationCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.providerLabel`)}),(0,$.jsx)(J,{"aria-label":e(`imageGenerationCard.providerAriaLabel`),value:u,onChange:M,options:D})]}),u===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.vellumNote`)}),k&&(0,$.jsx)(q,{label:e(`imageGenerationCard.apiKeyLabel`),type:`password`,value:S,onChange:e=>C(e.target.value),placeholder:Ae(F,j),fullWidth:!0}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.activeModelLabel`)}),y?(0,$.jsx)(q,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:v,onChange:e=>h(e.target.value),placeholder:e(`imageGenerationCard.openrouterModelPlaceholder`),fullWidth:!0}):(0,$.jsx)(J,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:x,onChange:p,options:O})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:N,disabled:T}),T&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),k&&(0,$.jsx)(un,{onClick:P})]})]})})}function Tn({title:e,count:t,action:n,children:r}){return(0,$.jsxs)(`section`,{className:`rounded-xl border border-[var(--border-hover)] bg-[var(--surface-overlay)] px-3 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(p,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(p,{variant:`body-large-default`,as:`span`,"aria-label":`${t} ${e.toLowerCase()}`,className:`text-[var(--content-disabled)]`,children:[`·`,` `,t]})]}),n]}),r==null?null:(0,$.jsx)(`div`,{className:`mt-4 border-t border-[var(--border-base)]`,children:r})]})}function En(e){return e.scheduleNames.length>0||e.deferredReminderCount>0||e.scheduleLookupFailed}var Dn=5;function On({title:e,items:t,mono:n}){return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-(--content-tertiary)`,children:e}),(0,$.jsx)(`ul`,{className:`space-y-1 pl-1`,children:t.map(e=>(0,$.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,n?(0,$.jsx)(`code`,{children:e}):e]},e))})]})}function kn(e){let t=e.label||e.name,n=[];e.isActive&&n.push(Z(`settings:manageProfilesBlockedDeleteModal.clauseDefaultProfile`)),e.callSiteIds.length>0&&n.push(Z(`settings:manageProfilesBlockedDeleteModal.clauseActionOverrides`,{count:e.callSiteIds.length}));let r=e.scheduleNames.length,i=e.deferredReminderCount;return r>0&&i>0?n.push(Z(`settings:manageProfilesBlockedDeleteModal.clauseRunsBoth`,{schedules:r,reminders:i})):r>0?n.push(Z(`settings:manageProfilesBlockedDeleteModal.clauseRunsSchedules`,{count:r})):i>0&&n.push(Z(`settings:manageProfilesBlockedDeleteModal.clauseRunsReminders`,{count:i})),n.length===0?Z(`settings:manageProfilesBlockedDeleteModal.summaryNoReferences`,{display:t}):n.length===1?Z(`settings:manageProfilesBlockedDeleteModal.summaryOneClause`,{display:t,clause1:n[0]}):n.length===2?Z(`settings:manageProfilesBlockedDeleteModal.summaryTwoClauses`,{display:t,clause1:n[0],clause2:n[1]}):Z(`settings:manageProfilesBlockedDeleteModal.summaryThreeClauses`,{display:t,clause1:n[0],clause2:n[1],clause3:n[2]})}function An({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let{t:c}=X(`settings`),l=e?.scheduleNames??[],u=l.slice(0,Dn),d=l.length-u.length,f=e!=null&&En(e);return(0,$.jsx)(W.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(W.Content,{size:`sm`,children:[(0,$.jsx)(W.Header,{children:(0,$.jsx)(W.Title,{children:c(`manageProfilesBlockedDeleteModal.title`)})}),(0,$.jsxs)(W.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(p,{variant:`body-medium-default`,as:`p`,children:kn(e)}),e&&e.callSiteIds.length>0&&(0,$.jsx)(On,{title:c(`manageProfilesBlockedDeleteModal.actionOverridesTitle`),items:e.callSiteIds,mono:!0}),u.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(On,{title:c(`manageProfilesBlockedDeleteModal.schedulesTitle`),items:u}),d>0&&(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.moreSchedules`,{count:d})})]}),e?.scheduleLookupFailed&&(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-(--system-mid-strong)`,children:c(`manageProfilesBlockedDeleteModal.scheduleLookupFailed`)}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.replacementLabel`)}),(0,$.jsx)(J,{"aria-label":c(`manageProfilesBlockedDeleteModal.replacementLabel`),value:n,onChange:r,placeholder:c(`manageProfilesBlockedDeleteModal.replacementPlaceholder`),options:t.map(e=>{let t=f&&e.status===`disabled`;return{value:e.name,label:O(e),disabled:t,tooltip:t?c(`manageProfilesBlockedDeleteModal.disabledTargetTooltip`):void 0}})})]}),i&&(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(W.Footer,{children:[(0,$.jsx)(P,{variant:`ghost`,size:`compact`,onClick:o,children:c(`manageProfilesBlockedDeleteModal.cancel`)}),(0,$.jsx)(P,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:c(a?`manageProfilesBlockedDeleteModal.saving`:`manageProfilesBlockedDeleteModal.reassignAndDelete`)})]})]})})}function jn({profile:e,isActiveProfile:t,selected:n,connections:r,deletePending:a=!1,onOpen:o,onMakeActive:s,onSetStatus:c,onDelete:l}){let{t:u}=X(`settings`),d=e.source===`managed`,f=e.status===`disabled`,p=e.label??e.name,m=[];e.model&&m.push(D(e.provider??void 0,e.model,r)),d&&m.push(u(`profileRow.managedByVellum`));let h=e.availability,g=e.config_issue,_=g!=null||h?.status===`incomplete`,v=h?.message??u(`profileRow.providerUnavailableDefault`),y=g==null?h!=null&&h.status!==`ok`?_?u(`profileRow.providerUnavailableFixable`,{message:v}):v:null:u(`profileRow.providerUnavailableFixable`,{message:u(g.code===`over_output_cap`?`profileRow.configIssueOverOutputCap`:g.code===`no_input_room`?`profileRow.configIssueNoInputRoom`:`profileRow.configIssueModelUnknown`)});return(0,$.jsx)(Ce,{title:(0,$.jsx)(`span`,{className:f?`opacity-55`:void 0,children:p}),subtitle:m.length>0?m.join(` • `):void 0,onClick:o,showChevron:!1,selected:n,disabled:a,contentAriaLabel:u(`profileRow.openProfileAriaLabel`,{displayName:p}),trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[y==null?null:(0,$.jsx)(Ht,{content:y,children:_?(0,$.jsx)(`button`,{type:`button`,onClick:o,"aria-label":y,className:`inline-flex cursor-pointer rounded-sm p-0.5 keyboard-focus:ring-2 keyboard-focus:ring-[var(--ring)]`,children:(0,$.jsx)(tn,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-hidden":`true`})}):(0,$.jsx)(`span`,{className:`inline-flex p-0.5`,tabIndex:0,children:(0,$.jsx)(tn,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-label":y,role:`img`})})}),f?(0,$.jsx)(Rt,{tone:`neutral`,children:u(`profileRow.disabledTag`)}):null,t?(0,$.jsx)(Rt,{tone:`positive`,children:u(`profileRow.defaultTag`)}):null,(0,$.jsxs)(L.Root,{children:[(0,$.jsx)(L.Trigger,{asChild:!0,children:(0,$.jsx)(P,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":u(`profileRow.actionsAriaLabel`,{displayName:p}),disabled:a})}),(0,$.jsxs)(L.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(L.Item,{onSelect:o,children:u(d?`profileRow.view`:`profileRow.edit`)}),!t&&!f&&Te(e.provider,e.model)?(0,$.jsx)(L.Item,{onSelect:s,children:u(`profileRow.makeDefault`)}):null,f?(0,$.jsx)(L.Item,{onSelect:()=>c(!0),children:u(`profileRow.enable`)}):d?null:(0,$.jsx)(L.Item,{onSelect:()=>c(!1),children:u(`profileRow.disable`)}),d?null:(0,$.jsx)(L.Item,{onSelect:l,className:i.anchored,children:u(`profileRow.delete`)})]})]})]})})}function Mn(e,t){let n=Gt(),{data:r}=Y({...st({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=vt(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:kt(i,a).map(e=>({name:e.name,label:e.label??null,provider:e.provider??null,model:e.model??null,status:e.status===`disabled`?`disabled`:`active`,source:e.source===`managed`?`managed`:`user`,provider_connection:e.provider_connection,availability:null})),isEffectiveCatalog:!1}:{entries:r.profiles,isEffectiveCatalog:!0},[r,i,a])}var Nn=`0.10.8`;function Pn(e){return ae(Nn,e)}var Fn=`settings-ai-profile-make-active`,In=`Failed to set the active profile. Please try again.`;function Ln(e){let t=se(),n=Jt(),r=Pn(e),i=ee({onSuccess:()=>{n.invalidateQueries({queryKey:wt({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:z({path:{assistant_id:e}})})}});async function a(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw G(e,{context:r}),K.error(i),e}}async function o(t){if(!r){await a({activeProfile:t},Fn,In);return}try{await i.mutateAsync({path:{assistant_id:e},body:{name:t}})}catch(e){let t=_(e);throw K.error(t??In),t||G(e,{context:Fn}),e}}return{makeActive:o,setStatus:(e,t)=>a({profiles:{[e]:{status:t?`active`:`disabled`}}},`settings-ai-profile-toggle`,`Failed to update the profile. Please try again.`),deleteProfile:(e,t,n)=>a({profiles:{[e]:null},profileOrder:t.filter(t=>t!==e),...n?.isAdvisor?{advisorProfile:null}:{}},`settings-ai-profile-delete`,`Failed to delete the profile. Please try again.`),patchLlm:a,isPending:t.isPending||i.isPending}}var Rn=`The profile was not deleted.`,zn=`Failed to move the schedules. ${Rn}`;function Bn(e){let t=_(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${Rn}`:zn}function Vn(e,t,n){let r=Ln(e),i=Jt(),a=de(),o=t?.llm?.activeProfile??null,s=t?.llm?.advisorProfile??null,c=t?.llm?.callSites??{},l=(0,Q.useMemo)(()=>t?.llm?.profiles??{},[t?.llm?.profiles]),u=(0,Q.useMemo)(()=>t?.llm?.profileOrder??[],[t?.llm?.profileOrder]),d=(0,Q.useMemo)(()=>kt(l,u),[l,u]),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(!1);function C(e){return d.filter(t=>t.name===e?!1:t.status===`disabled`?!0:M(t,d,{requireOwnProviderAndModel:a}))}function w(e,t){let n=C(e).filter(e=>!t||e.status!==`disabled`),r=n.find(e=>e.name===o),i=n.find(e=>e.source!==`managed`);return(r??i??n[0])?.name??``}async function T(e){try{await r.deleteProfile(e,u,{isAdvisor:e===s}),n?.onDeleted?.(e)}catch{}}async function E(t){let n=l[t]?.label??t,r=t===o,a=Object.entries(c).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),s=[],u=0,d=!1;try{let n=(await i.fetchQuery({...ht({path:{assistant_id:e},query:{inference_profile:t,include_all:`true`}}),retry:!1,staleTime:0})).schedules??[];s=n.filter(e=>!e.isDeferred).map(e=>e.name),u=n.filter(e=>e.isDeferred).length}catch(e){G(e,{context:`settings-ai-profile-delete-schedule-scan`}),d=!0}if(!(r||a.length>0||s.length>0||u>0)&&!d){await T(t);return}let f={name:t,label:n,isActive:r,callSiteIds:a,scheduleNames:s,deferredReminderCount:u,scheduleLookupFailed:d};p(f),_(w(t,En(f))),h(null)}function D(e){t==null||S.current||(S.current=!0,x(e),E(e).finally(()=>{S.current=!1,x(null)}))}async function O(){if(!f||!g)return;if(y(!0),h(null),En(f))try{await hn(e,f.name,g),await i.invalidateQueries({queryKey:Ct({path:{assistant_id:e}})})}catch(e){G(e,{context:`settings-ai-profile-reassign-schedules`}),h(Bn(e)),y(!1);return}let t={};if(f.isActive&&(t.activeProfile=g),f.callSiteIds.length>0){let e={};for(let t of f.callSiteIds)e[t]={profile:g};t.callSites=e}if(Object.keys(t).length>0)try{await r.patchLlm(t,`settings-ai-profile-reassign-delete`,`Failed to reassign references. Please try again.`)}catch{h(`Failed to reassign references. Please try again.`),y(!1);return}let n=f.name;p(null),y(!1),T(n)}return{requestDelete:D,pendingDeleteName:b,blockedDeleteModalProps:{blocked:f,availableReplacements:C(f?.name??null),replacement:g,onReplacementChange:_,error:m,saving:v,onClose:()=>{p(null),h(null)},onConfirm:()=>void O()}}}function Hn(){}function Un({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{t:s}=X(`settings`),{entries:c}=Mn(e,t),l=Ln(e),u=Vn(e,t,{onDeleted:o}),d=t?.llm?.activeProfile??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Tn,{title:s(`profilesSection.title`),action:(0,$.jsx)(P,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(en,{}),disabled:t==null,children:s(`profilesSection.createProfile`)}),children:t==null?(0,$.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.loading`)}):c.length===0?(0,$.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.emptyState`)}):c.map(e=>(0,$.jsx)(jn,{profile:e,isActiveProfile:e.name===d,selected:e.name===r,connections:n,deletePending:u.pendingDeleteName===e.name,onOpen:()=>i(e.name),onMakeActive:()=>void l.makeActive(e.name).catch(Hn),onSetStatus:t=>void l.setStatus(e.name,t).catch(Hn),onDelete:()=>u.requestDelete(e.name)},e.name))}),(0,$.jsx)(An,{...u.blockedDeleteModalProps})]})}var Wn={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,chatgpt:!0,vellum:!0,together:!0,"vercel-ai-gateway":!0,minimax:!0,atlascloud:!0,baseten:!0,poolside:!0};function Gn(e){return e in Wn}function Kn(e){if(!e.baseUrl)return null;try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function qn(e){let t=Kn(e)??``,n=[];t&&n.push(t);let r=e.models?.length??0;return r>0&&n.push(`${r} ${r===1?`model`:`models`}`),e.auth.type===`none`&&n.push(`keyless`),n.join(` · `)}function Jn(e){switch(e.auth.type){case`api_key`:return`Own API key`;case`oauth_subscription`:return`ChatGPT subscription`;case`none`:return`No API key needed`;default:return null}}function Yn(e){if(e.provider===`vellum`)return`Included with your plan`;if(e.provider===`openai-compatible`)return qn(e);let t=[];if(e.provider===`ollama`||e.provider===`opencode`){let n=Kn(e);n&&t.push(n)}let n=e.provider===`chatgpt`?`openai`:e.provider,r=e.auth.type===`oauth_subscription`?ge(n):we(n),i=e.models?.length??r.length;i>0&&t.push(`${i} ${i===1?`model`:`models`}`);let a=Jn(e);return a&&t.push(a),t.join(` • `)}function Xn({connection:e,isDefault:t,supportsDefaultProvider:n,selected:r,isSettingDefault:a,onOpen:o,onSetDefault:s,onDelete:c}){let{t:l}=X(`settings`),u=e.isManaged??!1,d=mt(e),f=Gn(e.provider),p=Yn(e),m=n&&!t&&f,h=!u&&o!=null,g=!u&&!t,_=m||h||g;return(0,$.jsx)(Ce,{title:d,subtitle:p.length>0?p:void 0,onClick:o,showChevron:!1,selected:r,contentAriaLabel:o?l(`providerRow.openProviderAriaLabel`,{displayName:d}):void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(Rt,{tone:`neutral`,title:l(`providerRow.managedTagTitle`),children:l(`providerRow.managedTag`)}):null,t?(0,$.jsx)(Rt,{tone:`info`,title:l(`providerRow.defaultTagTitle`),children:l(`providerRow.defaultTag`)}):null,e.provider===`ollama`?(0,$.jsx)(Rt,{tone:`neutral`,title:l(`providerRow.localTagTitle`),children:l(`providerRow.localTag`)}):null,e.provider===`openai-compatible`?(0,$.jsx)(Rt,{tone:`neutral`,title:l(`providerRow.customTagTitle`),children:l(`providerRow.customTag`)}):null,_?(0,$.jsxs)(L.Root,{children:[(0,$.jsx)(L.Trigger,{asChild:!0,children:(0,$.jsx)(P,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":l(`providerRow.actionsAriaLabel`,{displayName:d})})}),(0,$.jsxs)(L.Content,{align:`end`,sideOffset:4,children:[h?(0,$.jsx)(L.Item,{onSelect:o,children:l(`providerRow.edit`)}):null,m?(0,$.jsx)(L.Item,{disabled:a,onSelect:s,children:l(`providerRow.setAsDefault`)}):null,g?(0,$.jsx)(L.Item,{onSelect:c,className:i.anchored,children:l(`providerRow.delete`)}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function Zn(e,t){let n=Jt(),r={path:{assistant_id:e}},i=qt({...$e(),onSuccess:()=>{n.invalidateQueries({queryKey:Je(r)}),n.invalidateQueries({queryKey:wt(r)}),n.invalidateQueries({queryKey:z(r)})},onError:e=>{G(e,{context:`settings-ai-set-default-provider`}),K.error(Z(`settings:useProviderActions.setDefaultFailedToast`))}});function a(t){Gn(t.provider)&&i.mutate({path:{assistant_id:e},body:{provider:t.provider,connectionName:t.name}})}function o(e){return i.isPending&&i.variables?.body?.connectionName===e}async function s(i){try{let{response:a}=await ue({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:ce(r)}),t?.onDeleted?.(i)):a?.status===409?K.error(Z(`settings:useProviderActions.deleteInUseToast`)):K.error(Z(`settings:useProviderActions.deleteFailedToast`))}catch(e){G(e,{context:`settings-ai-provider-delete`}),K.error(Z(`settings:useProviderActions.deleteFailedToast`))}}return{setDefault:a,isSettingDefault:o,deleteConnection:s}}function Qn({assistantId:e,selectedConnectionName:t,onOpenConnection:n,onAddProvider:r,onConnectionDeleted:i}){let{t:a}=X(`settings`),{data:o,isLoading:s,isError:c}=Y(ne({path:{assistant_id:e}})),l=u(),{data:d}=Y({...Dt({path:{assistant_id:e}}),enabled:l}),f=l?d?.resolvedConnectionName??null:null,m=Zn(e,{onDeleted:i}),h=(0,Q.useMemo)(()=>{let e=o?.connections??[];return[...e.filter(e=>e.provider===F),...e.filter(e=>e.provider!==F)]},[o]);return(0,$.jsx)(Tn,{title:a(`providersSection.title`),action:(0,$.jsx)(P,{variant:`outlined`,onClick:r,leftIcon:(0,$.jsx)(en,{}),children:a(`providersSection.addProvider`)}),children:s?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(ke,{className:`h-10 rounded-lg`},e))}):c?(0,$.jsx)(p,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:a(`providersSection.loadError`)}):h.length===0?(0,$.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:a(`providersSection.empty`)}):h.map(e=>(0,$.jsx)(Xn,{connection:e,isDefault:e.name===f,supportsDefaultProvider:l,selected:e.name===t,isSettingDefault:m.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>n(e.name),onSetDefault:()=>m.setDefault(e),onDelete:()=>void m.deleteConnection(e.name)},e.name))})}function $n({panel:e,onOpenPanel:t,onClosePanel:n}){let{t:r}=X(`settings`),i=Et(),{data:a}=Y({...gt({path:{assistant_id:i}}),staleTime:3e4}),o=u(),{data:s}=Y({...Dt({path:{assistant_id:i}}),enabled:o}),c=s?.availability,{data:l}=Y({...ne({path:{assistant_id:i}})}),d=l?.connections,f=a?.llm?.callSites??{},p=Object.entries(f).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length;return(0,$.jsx)(ln,{title:r(`languageModelCard.title`),subtitle:r(`languageModelCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[c&&c.status!==`ok`&&(0,$.jsx)(jt,{tone:c.status===`unknown`?`warning`:`error`,children:c.message??r(`languageModelCard.defaultProviderUnavailable`)}),i&&(0,$.jsx)(Un,{assistantId:i,config:a,connections:d,selectedProfileName:e?.kind===`profile`?e.name:null,onOpenProfile:e=>t({kind:`profile`,name:e}),onCreateProfile:()=>t({kind:`create-profile`}),onProfileDeleted:t=>{e?.kind===`profile`&&e.name===t&&n()}}),i&&(0,$.jsx)(Qn,{assistantId:i,selectedConnectionName:e?.kind===`provider`?e.name:null,onOpenConnection:e=>t({kind:`provider`,name:e}),onAddProvider:()=>t({kind:`add-provider`}),onConnectionDeleted:t=>{e?.kind===`provider`&&e.name===t&&n()}}),(0,$.jsx)(Tn,{title:r(`languageModelCard.overridesTitle`),count:p,action:(0,$.jsx)(P,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:r(`languageModelCard.manage`)})})]})})}function er({children:e}){return(0,$.jsxs)(dt,{href:`https://www.vellum.ai/docs/pricing`,tone:`default`,className:`inline-flex items-center gap-1`,glyph:!1,children:[e,(0,$.jsx)(an,{className:`h-3.5 w-3.5`})]})}function tr(){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,$.jsx)(on,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:(0,$.jsx)(Kt,{i18nKey:`managedServicesBanner.body`,ns:`common`,components:{link:(0,$.jsx)(er,{})}})})]})}function nr({assistantId:e,profileName:t,onClose:n}){let{t:r}=X(`settings`),{data:i}=Y({...gt({path:{assistant_id:e}}),staleTime:3e4}),{data:a}=Y({...ne({path:{assistant_id:e}})}),o=a?.connections,s=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),c=Object.keys(s),l=(0,Q.useMemo)(()=>{if(t==null)return;let e=s[t];return e?{name:t,...e}:void 0},[t,s]),u=t==null?`create`:l?.source===`managed`||l?.invariant===!0?`view`:`edit`,{saveProfile:d,isPending:f}=te(e,{onSaved:n}),p=x({mode:u,profileName:t??void 0,initialValues:l,existingNames:c,connections:o,assistantId:e,onSave:d}),m=Vn(e,i,{onDeleted:()=>n()}),h=t!=null&&m.pendingDeleteName===t,g=t!=null&&i!=null&&!(t in s);(0,Q.useEffect)(()=>{g&&!p.saving&&!f&&n()},[g,p.saving,f,n]);let _=u===`view`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Le,{title:p.effectiveMode===`create`?r(`profileDetailPanel.createTitle`):l?.label??t??r(`profileDetailPanel.defaultTitle`),closeVariant:`outlined`,onClose:n,headerTrailing:_&&p.effectiveMode!==`create`?(0,$.jsx)(Rt,{tone:`neutral`,children:r(`profileDetailPanel.managedTag`)}):null,headerActions:p.effectiveMode!==`create`&&!p.isReadOnly?(0,$.jsx)(P,{variant:`dangerOutline`,loading:h,iconOnly:(0,$.jsx)(Qt,{}),"aria-label":r(h?`profileDetailPanel.deleting`:`profileDetailPanel.delete`),tooltip:r(`profileDetailPanel.delete`),onClick:()=>{t!=null&&m.requestDelete(t)},disabled:p.saving||h}):null,footer:p.isReadOnly?(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(P,{variant:`outlined`,onClick:p.switchToSaveAsNew,disabled:p.saving,children:r(`profileDetailPanel.saveAsNew`)}),p.hasViewModeChanges?(0,$.jsx)(P,{variant:`primary`,onClick:()=>void p.handleSave(),disabled:p.saving,children:p.saving?r(`profileDetailPanel.saving`):r(`profileDetailPanel.save`)}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(P,{variant:`primary`,onClick:()=>void p.handleSave(),disabled:p.isInvalid||p.saving,children:p.saving?r(`profileDetailPanel.saving`):p.effectiveMode===`create`?r(`profileDetailPanel.create`):r(`profileDetailPanel.saveChanges`)})}),children:(0,$.jsx)(I,{editor:p,assistantId:e,connections:o,variant:`panel`})}),(0,$.jsx)(An,{...m.blockedDeleteModalProps})]})}function rr({value:e,profileOptions:t,disabled:n,onChange:r}){let{t:i}=X(`settings`);return(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:i(`advisorProfileRow.title`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-body-small-lighter text-[var(--content-tertiary)]`,children:i(`advisorProfileRow.description`)})]}),(0,$.jsx)(J,{value:e,onChange:r,options:t,placeholder:i(`advisorProfileRow.chooseProfilePlaceholder`),className:`w-44`,menuMinWidth:280,menuAlign:`start`,disabled:n})]})})}var ir=`__custom__`;function ar(e){return e?!!(e.profile||e.provider||e.model):!1}function or(e,t){if(t?.provider||t?.model)return null;let n=e.defaultProfile??e.shippedDefaultProfile;return n?{profile:n,via:t?.profile===n?`override`:`default`}:null}function sr(e,t){let n=ar(e);return n===ar(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function cr({assistantId:e,callSites:t,domains:n,persistedOverrides:r,orderedProfiles:i,onClose:a,onApplied:o}){let{t:s}=X(`settings`),c=se(),l=de(),u=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:l,requireTextGeneration:!1}),[l]),d=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t){let t=or(n,r[n.id]);t&&e.set(n.id,t)}return e},[t,r]),f=(0,Q.useMemo)(()=>{let e=new Set(Array.from(d.values(),e=>e.profile));return i.filter(t=>e.has(t.name))},[i,d]),[m,h]=(0,Q.useState)(()=>f[0]?.name??``),[g,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(new Set),[x,S]=(0,Q.useState)(!1),C=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[n]),w=(0,Q.useMemo)(()=>t.filter(e=>d.get(e.id)?.profile===m),[t,d,m]),T=(0,Q.useMemo)(()=>w.map(e=>e.id).filter(e=>!y.has(e)),[w,y]),E=(0,Q.useMemo)(()=>f.map(e=>({value:e.name,label:O(e)})),[f]),D=(0,Q.useMemo)(()=>Pe(i,[],u).filter(e=>e.name!==m).map(e=>({value:e.name,label:O(e)})),[i,m,u]),k=Ft(i,m),A=Ft(i,g),j=y.size===0;function M(e){h(e),b(new Set),e===g&&v(``)}function N(e,t){b(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function F(){if(!(!m||!g||T.length===0)){S(!0);try{let t={};for(let e of T)t[e]={profile:g};await c.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),K.success(s(`bulkOverrideSwapModal.successToast`,{count:T.length,targetLabel:A})),o(),a()}catch(e){let t=_(e);K.error(t??s(`bulkOverrideSwapModal.updateFailedToast`)),t||G(e,{context:`settings-ai-bulk-override-swap`})}finally{S(!1)}}}return(0,$.jsx)(W.Root,{open:!0,onOpenChange:e=>{e||a()},children:(0,$.jsxs)(W.Content,{size:`md`,children:[(0,$.jsx)(W.Header,{children:(0,$.jsx)(W.Title,{children:s(`bulkOverrideSwapModal.title`)})}),(0,$.jsxs)(W.Body,{className:`space-y-4`,children:[(0,$.jsx)(p,{variant:`body-medium-default`,as:`p`,children:s(`bulkOverrideSwapModal.intro`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(J,{id:`bulk-swap-source`,label:s(`bulkOverrideSwapModal.currentlyUsingLabel`),value:m,onChange:M,options:E}),(0,$.jsx)(J,{id:`bulk-swap-target`,label:s(`bulkOverrideSwapModal.changeToLabel`),value:g,onChange:v,options:D,placeholder:s(`bulkOverrideSwapModal.targetPlaceholder`)})]}),(0,$.jsx)(jt,{tone:`info`,title:s(`bulkOverrideSwapModal.noticeTitle`),children:s(`bulkOverrideSwapModal.noticeBody`,{sourceLabel:k})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(p,{variant:`body-medium-default`,as:`p`,children:s(`bulkOverrideSwapModal.affectedSummary`,{count:w.length,profile:k})}),(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:s(`bulkOverrideSwapModal.chooseActions`)})]}),(0,$.jsx)(P,{variant:`ghost`,onClick:()=>b(j?new Set(w.map(e=>e.id)):new Set),children:s(j?`bulkOverrideSwapModal.clearAll`:`bulkOverrideSwapModal.selectAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:w.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-[var(--border-base)] px-3 py-2`,children:[(0,$.jsx)(qe,{checked:!y.has(e.id),onCheckedChange:t=>N(e.id,t===!0),disabled:x,label:e.displayName,helperText:C(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:d.get(e.id)?.via===`override`?s(`bulkOverrideSwapModal.viaOverride`):s(`bulkOverrideSwapModal.viaDefault`)})]},e.id))})]})]}),(0,$.jsxs)(W.Footer,{children:[(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:s(`bulkOverrideSwapModal.willChange`,{count:T.length})}),(0,$.jsx)(P,{variant:`ghost`,onClick:a,disabled:x,children:s(`bulkOverrideSwapModal.cancel`)}),(0,$.jsx)(P,{variant:`primary`,loading:x,disabled:!m||!g||T.length===0||x,onClick:()=>void F(),children:s(`bulkOverrideSwapModal.applyTo`,{count:T.length})})]})]})})}function lr({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,connections:o,onDraftChange:s,onToggle:u}){let{t:d}=X(`settings`),f=c({hostedInference:l.use.vellumHostedInference()}),p=ar(i),m=!i||!p?``:i.provider||i.model?ir:i.profile??``,h=m===ir,g=pe(),_=je(),v=(o??[]).some(e=>e.provider===b),y=[...E,...v?[b]:[]],x=g[0]??E[0],S=i?.provider,C=he(S)?S:S===`chatgpt`?b:void 0,w=C!==void 0&&y.some(e=>e===C),D=C??x,O=Wt(D,``,(o??[]).filter(e=>Ie(e.provider,D)))?ge(D):Ee(D,f),k=O.map(e=>({value:e.id,label:e.displayName})),A=typeof i?.model==`string`?i.model:``;if(A&&!O.some(e=>e.id===A)){let e=we(D).find(e=>e.id===A)?.displayName??A;k.push({value:A,label:d(`callSiteOverridesRow.unavailableOption`,{name:e})})}let j=!!i?.provider&&!i?.model,M=[...y.map(e=>({value:e,label:Ut[e]??e,..._(e)})),...C&&!w?[{value:C,label:d(`callSiteOverridesRow.unavailableOption`,{name:Ut[C]??C})}]:[]];function N(t){t===`__custom__`?s(e,{profile:null,provider:x,model:T(x)??``}):t===``?s(e,null):s(e,{profile:t,provider:null,model:null})}function P(t){let n=T(t)??``;s(e,{...i??{},profile:null,provider:t,model:n})}function F(t){s(e,{...i??{},model:t})}return(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,$.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,$.jsx)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:d(`callSiteOverridesRow.defaultProfileSuffix`,{label:r})})]})]}),(0,$.jsx)(Ze,{checked:p,onChange:t=>u(e,t),"aria-label":d(`callSiteOverridesRow.overrideAriaLabel`,{displayName:t}),className:`shrink-0`})]}),p&&(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(J,{value:m,onChange:N,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`start`})}),p&&h&&(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:d(`callSiteOverridesRow.providerLabel`)}),(0,$.jsx)(J,{value:D??``,onChange:P,options:M})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:d(`callSiteOverridesRow.modelLabel`)}),(0,$.jsx)(J,{value:i?.model??``,onChange:F,options:k})]})]}),j&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:d(`callSiteOverridesRow.pickModelError`)})]})]})}function ur({groups:e,drafts:t,buildProfileOptionsForRow:n,profileLabelFor:r,advisorMatchesSearch:i,connections:a,onDraftChange:o,onToggle:s}){let{t:c}=X(`settings`);return(0,$.jsx)(`div`,{className:`space-y-4`,children:e.length===0?i?null:(0,$.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:c(`overridesCallSiteList.emptySearch`)}):e.map(({domain:e,sites:i})=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(pn,{children:e.displayName}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>{let i=(()=>{let n=t[e.id]??null;return!n||!ar(n)?``:n.provider||n.model?ir:n.profile??``})(),c=e.shippedDefaultProfile??e.defaultProfile,l=c?r(c):null;return(0,$.jsx)(lr,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:l,draft:t[e.id]??null,profileOptions:n(i===``||i===`__custom__`?null:i),connections:a,onDraftChange:o,onToggle:s},e.id)})})]},e.id))})}function dr(e,t){let n={};for(let r of Object.keys(e)){let i=e[r]??null;ar(i)?n[r]={profile:i?.profile??null,provider:i?.provider??null,model:i?.model??null}:r in t&&t[r]===null&&(n[r]=null)}return n}function fr(e){let t={};for(let n of Object.keys(e))t[n]=null;return t}function pr({catalogCallSiteIds:e,persistedOverrides:t,persistedAdvisor:n,isSeeded:r}){let[i,a]=(0,Q.useState)({}),[o,s]=(0,Q.useState)(void 0),c=(0,Q.useMemo)(()=>{if(!r)return{};let n={};for(let r of e)if(r in i)n[r]=i[r];else{let e=t[r];n[r]=e?{...e}:{}}return n},[r,e,t,i]),l=o??n,u=l!==n,d=(0,Q.useMemo)(()=>{if(!r)return!1;for(let e of Object.keys(c))if(!sr(c[e],t[e]))return!0;return!1},[r,c,t]);return{drafts:c,advisorProfile:l,advisorDirty:u,callSiteDraftsDirty:d,hasUnsavedDrafts:u||d,hasValidationError:(0,Q.useMemo)(()=>Object.values(c).some(e=>ar(e)&&!!e?.provider&&!e?.model),[c]),setDraft:(0,Q.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[]),setAdvisor:(0,Q.useCallback)(e=>{s(e)},[]),clearEdits:(0,Q.useCallback)(()=>{a({}),s(void 0)},[]),buildSavePatch:(0,Q.useCallback)(()=>dr(c,i),[c,i]),buildResetPatch:(0,Q.useCallback)(()=>fr(c),[c])}}function mr({assistantId:e,onClose:t}){let{t:n}=X(`settings`),{data:i}=Y({...gt({path:{assistant_id:e}}),staleTime:3e4}),a=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),o=(0,Q.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),s=(0,Q.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),c=(0,Q.useMemo)(()=>kt(a,o),[a,o]),l=pe(),u=de(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),f=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u,requireTextGeneration:!1}),[u]),p=se(),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),{data:S,isLoading:C,isError:w,refetch:D}=Y({...ft({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),{data:k}=Y({...ne({path:{assistant_id:e}}),enabled:!!e}),A=(0,Q.useMemo)(()=>(S?.callSites??[]).filter(e=>e.id!==`mainAgent`),[S]),j=!C&&!w&&!!S,M=!!i,N=j&&M,F=(0,Q.useMemo)(()=>A.map(e=>e.id),[A]),I=i?.llm?.advisorProfile??``,{drafts:L,advisorProfile:R,advisorDirty:ee,callSiteDraftsDirty:z,hasUnsavedDrafts:B,hasValidationError:V,setDraft:H,setAdvisor:te,clearEdits:re,buildSavePatch:ie,buildResetPatch:ae}=pr({catalogCallSiteIds:F,persistedOverrides:s,persistedAdvisor:I,isSeeded:N}),oe=(0,Q.useMemo)(()=>new Set(F),[F]),U=(0,Q.useCallback)(e=>Ft(c,e),[c]),ce=(0,Q.useCallback)((e,t)=>({value:e.name,label:O(e),...yt(e,c,t)===`undispatchable`?{icon:(0,$.jsx)(tn,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:Oe(e)}:{}}),[c]),le=(0,Q.useMemo)(()=>Pe(c,[I],d).map(e=>ce(e,d)),[c,I,ce,d]),ue=(0,Q.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[m]),fe=(0,Q.useMemo)(()=>A.some(e=>or(e,s[e.id])!==null),[A,s]),me=(0,Q.useMemo)(()=>Object.entries(s).some(([e,t])=>oe.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[s,oe]),he=(0,Q.useCallback)(e=>[...Pe(c,[e],f).map(e=>ce(e,f)),{value:ir,label:n(`overridesDetailPanel.customProfileOption`)}],[c,ce,f,n]),ge=(0,Q.useMemo)(()=>{if(!m.trim())return A;let e=m.toLowerCase();return A.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[A,m]),_e=(0,Q.useMemo)(()=>{if(!S)return[];let e=S.domains.map(e=>e.id),t=new Map(S.domains.map(e=>[e.id,e])),r=[];for(let n of e){let e=ge.filter(e=>e.domain===n);e.length>0&&r.push({domain:t.get(n),sites:e})}let i=new Set(e),a=ge.filter(e=>!i.has(e.domain));return a.length>0&&r.push({domain:{id:`other`,displayName:n(`overridesDetailPanel.otherDomain`)},sites:a}),r},[S,ge,n]),ve=(0,Q.useCallback)((e,t)=>{if(!t){H(e,null);return}let n=Me(c,A.find(t=>t.id===e)?.defaultProfile,f);if(n)H(e,{profile:n});else{let t=l[0]??E[0];H(e,{provider:t,model:T(t)??``})}},[A,c,l,H,f]),ye=(0,Q.useCallback)(async()=>{_(!0);try{let r=ie();await p.mutateAsync({path:{assistant_id:e},body:{llm:{...z?{callSites:r}:{},...ee?{advisorProfile:R}:{}}}}),t(),K.success(n(`overridesDetailPanel.overridesSavedToast`))}catch(e){K.error(n(`overridesDetailPanel.saveFailedToast`)),G(e,{context:`call_site_overrides_save`})}finally{_(!1)}},[ie,z,ee,R,t,p,e,n]),be=(0,Q.useCallback)(async()=>{_(!0);try{let r=ae();await p.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:r}}}),t(),K.success(n(`overridesDetailPanel.overridesResetToast`))}catch(e){K.error(n(`overridesDetailPanel.resetFailedToast`)),G(e,{context:`call_site_overrides_reset`})}finally{_(!1)}},[ae,t,p,e,n]),xe=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[me&&(0,$.jsx)(P,{variant:`outlined`,onClick:()=>y(!0),disabled:g||!N,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:n(`overridesDetailPanel.resetToDefaults`)}),(0,$.jsx)(P,{variant:`primary`,onClick:()=>void ye(),loading:g,disabled:!B||V||g,children:n(`overridesDetailPanel.save`)})]});return(0,$.jsxs)(Le,{title:n(`overridesDetailPanel.title`),closeVariant:`outlined`,onClose:t,footer:xe,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`overridesDetailPanel.description`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(q,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:n(`overridesDetailPanel.searchPlaceholder`),leftIcon:(0,$.jsx)(sn,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(P,{variant:`outlined`,onClick:()=>x(!0),disabled:!N||g||B||!fe,title:B?n(`overridesDetailPanel.bulkChangeUnsavedTitle`):fe?void 0:n(`overridesDetailPanel.bulkChangeNoCandidatesTitle`),children:n(`overridesDetailPanel.bulkChange`)})]}),M&&ue&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(pn,{children:n(`overridesDetailPanel.advisorSection`)}),(0,$.jsx)(rr,{value:R,profileOptions:le,disabled:g,onChange:te})]}),C&&(0,$.jsx)(r,{placement:`panel`}),w&&(0,$.jsx)(jt,{tone:`error`,title:n(`overridesDetailPanel.loadErrorTitle`),actions:(0,$.jsx)(P,{variant:`outlined`,onClick:()=>void D(),children:n(`overridesDetailPanel.retry`)}),children:n(`overridesDetailPanel.loadErrorHint`)}),!C&&!w&&S&&(0,$.jsx)(ur,{groups:_e,drafts:L,buildProfileOptionsForRow:he,profileLabelFor:U,advisorMatchesSearch:ue,connections:k?.connections,onDraftChange:H,onToggle:ve})]})]}),b&&S&&(0,$.jsx)(cr,{assistantId:e,callSites:A,domains:S.domains,persistedOverrides:s,orderedProfiles:c,onClose:()=>x(!1),onApplied:re}),(0,$.jsx)(bt,{open:v,title:n(`overridesDetailPanel.resetToDefaults`),message:n(`overridesDetailPanel.resetConfirmMessage`),confirmLabel:n(`overridesDetailPanel.resetToDefaults`),destructive:!0,onConfirm:()=>{y(!1),be()},onCancel:()=>y(!1)})]})}var hr=e(Yt(),1);function gr({mode:e,connection:r,assistantId:i,existingNames:a,connections:o,variant:s=`modal`,actionsSlot:c,onSave:l,onCancel:u}){let{t:d}=X(`settings`),[f,m]=(0,Q.useState)(r?.label??``),h=r?.name??``,g=r?.provider??`anthropic`,_=r?.auth.type??`api_key`,[v,y]=(0,Q.useState)(()=>r?.auth.type===`api_key`?r.auth.credential:r?``:`credential/anthropic/api_key`),[b,x]=(0,Q.useState)(r?.baseUrl??``),[S,T]=(0,Q.useState)(()=>r?.models?r.models.map(e=>e.id).join(`, `):``),[E,D]=(0,Q.useState)(!1),[O,A]=(0,Q.useState)(null),j=g===`openai-compatible`,M=Tt(g),N=xt(g),[F,I]=(0,Q.useState)(``),[L,R]=(0,Q.useState)(!1),ee=Jt(),z=(0,Q.useMemo)(()=>Ye(v),[v]),B=_===`api_key`&&z!==null,{hasStoredCredential:V,isLoading:H}=w({assistantId:i,credentialKind:`credential`,credentialName:z?`${z.service}:${z.field}`:``,enabled:B}),{credentials:te}=Ne({assistantId:i,enabled:_===`api_key`});(0,Q.useEffect)(()=>{let e=r?.provider??`anthropic`;m(r?.label??``),r?.auth.type===`api_key`?y(r.auth.credential):y(r?``:`credential/${e}/api_key`),A(null),x(r?.baseUrl??``),T(r?.models?r.models.map(e=>e.id).join(`, `):``),I(``),R(!1)},[r]);let ne=f.trim()!==(r?.label??``).trim(),re=j&&ne?t(f,o,r?.name):null,ie=h.trim().length>0&&re===null;async function ae(){if(ie){D(!0),A(null);try{let e;if(_===`api_key`){let t=v.trim()||`credential/${g}/api_key`,n=F.trim();if(n){R(!0);try{let e=Ye(t);await pt({path:{assistant_id:i},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:n}:{type:`api_key`,name:g,value:n},throwOnError:!0});let r=De(i,`credential`,e?`${e.service}:${e.field}`:``);ee.setQueryData(r,!0),ee.invalidateQueries({queryKey:Ge({path:{assistant_id:i}})})}catch{A(d(`providerEditorContent.failedSaveApiKey`));return}finally{R(!1)}}e={type:`api_key`,credential:t}}else if(r)e=r.auth;else{A(d(`providerEditorContent.nothingToEdit`));return}let t=f.trim()||null,a={auth:e,label:t,...M&&{base_url:b.trim()||null},...N&&{models:S.trim()?S.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:o,error:s,response:c}=await C({path:{assistant_id:i,name:r?.name??h.trim()},body:a});if(!c?.ok){A(rt(c?.status,s)??n(c?.status));return}if(!o){A(d(`providerEditorContent.emptyServerResponse`));return}Be(o,d),l(o)}catch{A(d(`providerEditorContent.failedSaveProvider`))}finally{D(!1)}}}let oe=te.filter(e=>e.service===g),U=e!==`create`&&r?.auth.type===`api_key`,se=oe.length>0||U,ce=Ae(d(`providerEditorContent.apiKeyPlaceholder`),V);if(e===`create`)return(0,$.jsx)(k,{variant:s===`panel`?`inline`:`modal`,actionsSlot:c,assistantId:i,existingNames:a,connections:o,defaultProviderType:g,onCreated:l,onCancel:u});let le=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:(0,$.jsx)(Kt,{i18nKey:`providerEditorContent.displayNameLabel`,ns:`settings`,components:{optional:(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`})}})}),(0,$.jsx)(q,{value:f,onChange:e=>m(e.target.value),placeholder:d(`providerEditorContent.displayNamePlaceholder`),fullWidth:!0}),re?(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:fe[re]}):null]}),M&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:d(`providerEditorContent.baseUrlLabel`)}),(0,$.jsx)(q,{value:b,onChange:e=>x(e.target.value),placeholder:d(g===`ollama`?`providerEditorContent.baseUrlPlaceholderOllama`:g===`opencode`?`providerEditorContent.baseUrlPlaceholderOpencode`:`providerEditorContent.baseUrlPlaceholder`),fullWidth:!0}),g===`ollama`?(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:d(`providerEditorContent.baseUrlHintOllama`)}):null,g===`opencode`?(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:d(`providerEditorContent.baseUrlHintOpencode`)}):null]}),N&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:d(`providerEditorContent.modelsLabel`)}),(0,$.jsx)(q,{value:S,onChange:e=>T(e.target.value),placeholder:d(`providerEditorContent.modelsPlaceholder`),fullWidth:!0}),(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:d(`providerEditorContent.modelsHint`)})]}),_===`api_key`&&(0,$.jsx)(Fe,{apiKeyValue:F,onApiKeyChange:I,credential:v,onCredentialChange:y,isLoadingCredential:H,apiKeyPlaceholder:ce,provider:g,providerCredentials:oe,showAdvancedSection:se,onError:A}),_===`oauth_subscription`&&(0,$.jsx)(Ot,{assistantId:i,onConnected:l}),O&&(0,$.jsx)(p,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:O})]}),ue=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{variant:`ghost`,onClick:u,children:d(`providerEditorContent.cancel`)}),(0,$.jsx)(P,{variant:`primary`,disabled:!ie||E||L,onClick:()=>void ae(),children:d(E?`providerEditorContent.saving`:`providerEditorContent.saveChanges`)})]});return s===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[le,c===void 0?(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:ue}):c&&(0,hr.createPortal)(ue,c)]}):(0,$.jsxs)(W.Content,{size:`md`,children:[(0,$.jsxs)(W.Header,{children:[(0,$.jsx)(W.Title,{children:d(`providerEditorContent.editProviderTitle`)}),(0,$.jsx)(W.Description,{children:r?d(`providerEditorContent.editingConnection`,{name:mt(r)}):d(`providerEditorContent.editProviderSettingsFallback`)})]}),(0,$.jsx)(W.Body,{children:le}),(0,$.jsx)(W.Footer,{children:ue})]})}function _r({assistantId:e,connectionName:t,onClose:n}){let{t:i}=X(`settings`),a=Jt(),[o,s]=(0,Q.useState)(null),{data:c,isLoading:l}=Y(ne({path:{assistant_id:e}})),u=(0,Q.useMemo)(()=>c?.connections??[],[c]),d=(0,Q.useMemo)(()=>t==null?void 0:u.find(e=>e.name===t),[t,u]),f=t!=null&&c!=null&&d==null;(0,Q.useEffect)(()=>{f&&n()},[f,n]);function p(){a.invalidateQueries({queryKey:ce({path:{assistant_id:e}})}),a.invalidateQueries({queryKey:Je({path:{assistant_id:e}})}),n()}return(0,$.jsx)(Le,{title:d?mt(d):i(`providerDetailPanel.addProviderTitle`),closeVariant:`outlined`,onClose:n,footer:(0,$.jsx)(`div`,{ref:s,className:`flex justify-end gap-2`}),children:t!=null&&l?(0,$.jsx)(r,{placement:`panel`}):t==null||d!=null?(0,$.jsx)(gr,{mode:d?`edit`:`create`,connection:d,variant:`panel`,actionsSlot:o,assistantId:e,existingNames:u.map(e=>e.name),connections:u,onSave:p,onCancel:n}):null})}var vr={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},yr={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},br=`deepgram`;function xr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:r}={}){let i=Et(),o=e??i,c=A(),l=Jt(),{t:u}=X(),d=(0,Q.useMemo)(()=>le(Qe(),{displayName:u(`sttProviderForm.windowsNativeDisplayName`),subtitle:u(`sttProviderForm.windowsNativeSubtitle`),setupWarning:u(`sttProviderForm.windowsNativeSetupWarning`)}).filter(e=>!e.requiresNativeDictation||S()),[u]),f=br,{data:p}=Y({...gt({path:{assistant_id:o}}),enabled:c,staleTime:3e4}),m=p?.services?.stt,h=m?.mode===`managed`?`vellum`:m?.provider,g=(0,Q.useMemo)(()=>{let e=h?yr[h]:void 0;if(e&&d.some(t=>t.id===e))return e;let t=a(Vt,f);return d.some(e=>e.id===t)?t:f},[h,d,f]),_=!!h,[v,y]=yn(g),{available:b,currentCode:x,configuredProviderId:C,selectLanguage:w,selecting:T}=St(o),[E,D]=(0,Q.useState)(!1),O=b&&v===g&&(vr[v]?.provider===C||!!h&&!yr[h]),[k,j]=(0,Q.useState)(``),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=a(Vt,f);e===`macos-native`&&!d.some(t=>t.id===e)&&V(Vt,f)},[d,f]);let I=(0,Q.useMemo)(()=>d.find(e=>e.id===v)??d[0],[d,v]),L=I.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{N(a(At+v,``).length>0),j(``)},[v]);let R=(0,Q.useMemo)(()=>{let e=v!==g,t=k.trim().length>0;return e||t},[v,g,k]),ee=(0,Q.useCallback)(async()=>{let e=k.trim();V(Vt,v),e.length>0&&V(At+v,e);let t=vr[v];F(!0);try{if(t?.credentialService){let n=e.length>0?e:a(At+v,``);if(n.length>0){let{response:e}=await s({path:{assistant_id:o},body:{service:t.credentialService,field:`api_key`,value:n,label:`${I.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(v!==g||!_)||h===`vellum`&&v!==`vellum`){let e=t?.provider??br,{response:n}=await Lt({path:{assistant_id:o},body:{services:{stt:{provider:e,mode:e===`vellum`?`managed`:`your-own`}}},throwOnError:!1});if(!n?.ok)throw Error(`Failed to save configuration (HTTP ${n?.status??`?`})`)}return e.length>0&&N(!0),j(``),l.invalidateQueries({queryKey:wt({path:{assistant_id:o}})}),K.success(u(`sttProviderForm.saveSuccess`)),!0}catch(e){return K.error(e instanceof Error?e.message:u(`sttProviderForm.saveFailed`)),!1}finally{F(!1)}},[o,v,k,I,g,_,h,l,u]);(0,Q.useEffect)(()=>{r?.({hasChanges:R,saving:P,save:ee})},[r,R,P,ee]);let z=(0,Q.useCallback)(()=>{V(At+v,``),N(!1),j(``)},[v]),B=M?u(`sttProviderForm.apiKeyPlaceholderReplace`):I.apiKeyPlaceholder;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:u(`sttProviderForm.providerLabel`)}),(0,$.jsx)(J,{value:v,onChange:y,options:d.map(e=>({value:e.id,label:e.displayName})),"aria-label":u(`sttProviderForm.providerAriaLabel`)})]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:u(`sttProviderForm.spokenLanguage`)}),(0,$.jsx)(_t,{"aria-label":u(`sttProviderForm.spokenLanguage`),"aria-haspopup":`dialog`,onClick:()=>D(!0),value:Ve(x,C)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:u(`sttProviderForm.spokenLanguageApplies`)}),(0,$.jsx)(_n,{open:E,onOpenChange:D,title:u(`sttProviderForm.spokenLanguage`),currentCode:x,configuredProviderId:C,selectLanguage:w,selecting:T})]}),L&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:u(`sttProviderForm.apiKeyLabel`)}),(0,$.jsx)(q,{type:`password`,value:k,onChange:e=>j(e.target.value),placeholder:B,fullWidth:!0})]}),I.setupWarning&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)($t,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,$.jsx)(`span`,{children:I.setupWarning})]}),!n&&I.credentialsGuide&&(0,$.jsx)(fn,{guide:I.credentialsGuide}),v===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:u(`sttProviderForm.vellumTranscription`)}),(!t||M)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!t&&(0,$.jsx)(dn,{onClick:ee,disabled:!R||P}),M&&(0,$.jsx)(un,{onClick:z})]})]})}var Sr={batch:`sttRoleOverrides.role.batch`,dictation:`sttRoleOverrides.role.dictation`,liveVoice:`sttRoleOverrides.role.liveVoice`,telephony:`sttRoleOverrides.role.telephony`,watch:`sttRoleOverrides.role.watch`};function Cr(e){let t=e?.roles;if(!t)return[];let n=e?.provider,r=n?e?.providers?.[n]?.model:void 0,i=[];for(let[e,a]of Object.entries(t)){let t=a?.provider;t&&(t===n&&a?.model===r||i.push({role:e,provider:t,...a?.model===void 0?{}:{model:a.model}}))}return i}function wr({assistantId:e}){let{t}=X(`settings`),n=Jt(),r=A(),[i,a]=(0,Q.useState)(null),{data:o}=Y({...gt({path:{assistant_id:e}}),enabled:r,staleTime:3e4}),s=o?.services?.stt,c=Cr(s),{data:l}=Y({...Bt({path:{assistant_id:e}}),enabled:r&&c.length>0,staleTime:5*6e4});if(c.length===0)return null;let u=e=>l?.providers?.find(t=>t.id===e)?.displayName??e,d=async r=>{a(r);try{let{response:t}=await Lt({path:{assistant_id:e},body:{services:{stt:{roles:{[r]:null}}}},throwOnError:!1});if(!t?.ok)throw Error(String(t?.status??``));await n.invalidateQueries({queryKey:wt({path:{assistant_id:e}})})}catch{K.error(t(`sttRoleOverrides.clearFailed`))}finally{a(null)}};return(0,$.jsxs)(`div`,{className:`mt-1 flex flex-col gap-2 border-t border-[var(--border-subtle)] pt-4`,children:[(0,$.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:t(`sttRoleOverrides.title`)}),(0,$.jsx)(`ul`,{className:`flex flex-col gap-1`,children:c.map(e=>{let n=Sr[e.role];return(0,$.jsxs)(`li`,{className:`flex items-center gap-4 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-lighter text-[var(--content-default)]`,children:n?t(n):e.role}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-body-small-default text-[var(--content-default)]`,children:e.model?`${u(e.provider)} · ${e.model}`:u(e.provider)}),(0,$.jsx)(P,{variant:`ghost`,size:`compact`,"aria-label":t(`sttRoleOverrides.clearAria`,{feature:n?t(n):e.role}),className:`[--vbtn-fg:var(--content-tertiary)]`,disabled:i===e.role,onClick:()=>void d(e.role),children:t(`sttRoleOverrides.clear`)})]},e.role)})})]})}function Tr(){let{t:e}=X(`settings`),t=Et();return(0,$.jsxs)(ln,{title:e(`speechToTextCard.title`),subtitle:e(`speechToTextCard.subtitle`),children:[(0,$.jsx)(xr,{}),(0,$.jsx)(wr,{assistantId:t})]})}async function Er(e){let{provider:t,apiKey:n,voiceId:r,text:i}=e;if(n.trim().length===0)return{kind:`error`,message:`Save an API key for this provider first.`};try{return t===`elevenlabs`?await Dr(n,r,i):t===`deepgram`?await Or(n,i):t===`fish-audio`?{kind:`unsupported`,message:`Fish Audio TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:t===`xai`?{kind:`unsupported`,message:`xAI TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:{kind:`unsupported`,message:`TTS testing for "${t}" is not supported from the browser yet.`}}catch(e){return{kind:`error`,message:e instanceof Error?e.message:`Failed to reach the TTS provider.`}}}async function Dr(e,t,n){let r=t.trim();if(r.length===0)return{kind:`error`,message:`Enter and save a Voice ID before testing ElevenLabs.`};let i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(r)}?output_format=mp3_44100_128`,{method:`POST`,headers:{"xi-api-key":e,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:n,model_id:`eleven_turbo_v2_5`})});return i.ok?{kind:`audio`,blob:await i.blob()}:{kind:`error`,message:await kr(i,`ElevenLabs rejected the request.`)}}async function Or(e,t){let n=await fetch(`https://api.deepgram.com/v1/speak?model=aura-2-thalia-en`,{method:`POST`,headers:{Authorization:`Token ${e}`,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:t})});return n.ok?{kind:`audio`,blob:await n.blob()}:{kind:`error`,message:await kr(n,`Deepgram rejected the request.`)}}async function kr(e,t){try{let n=await e.text();if(n.length===0)return`${t} (HTTP ${e.status})`;try{let e=JSON.parse(n);if(e&&typeof e==`object`&&`detail`in e&&typeof e.detail==`string`)return e.detail;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message}catch{}return n.slice(0,200)}catch{return`${t} (HTTP ${e.status})`}}function Ar({assistantId:e,value:t,onChange:n,className:r}){let{t:i}=X(),[a,o]=(0,Q.useState)(!1),{voices:s}=xe(e);if(s.length===0)return null;let c=s.find(e=>e.model===t)??s[0];return(0,$.jsxs)(nt.Root,{open:a,onOpenChange:o,children:[(0,$.jsx)(nt.Trigger,{asChild:!0,children:(0,$.jsx)(_t,{"aria-label":i(`voicePickerField.ariaLabel`),value:c?Nt(c.description):i(`voicePickerField.selectVoice`),className:r})}),(0,$.jsx)(nt.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)(Xe,{assistantId:e,value:t,onChange:n,onSelect:()=>o(!1),showSource:!0,autoScrollToSelected:!0})})]})}var jr={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Mr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:r}={}){let{t:i}=X(),o=Et(),c=e??o,l=j.use.name()??`your assistant`,u=A(),d=Jt(),{data:f}=Y({...Ue({path:{assistant_id:c}}),enabled:u,staleTime:1/0}),p=(0,Q.useMemo)(()=>{let e=f?.providers;if(!e)return ct;if(e.some(e=>e.id===`vellum`))return e;let t=ct.find(e=>e.id===`vellum`);return t?[t,...e]:e},[f]),{data:m}=Y({...gt({path:{assistant_id:c}}),enabled:u,staleTime:3e4}),h=m?.services?.tts,g=h?.mode===`managed`?`vellum`:h?.provider,_=`elevenlabs`,v=(0,Q.useMemo)(()=>g??a(`vellum:voice:ttsProvider`,_),[g,_]),b=!!g,[x,S]=yn(v),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(``),[D,O]=(0,Q.useState)(``),[k,M]=(0,Q.useState)(!1),[N,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1),{voices:R,defaultModel:ee,fetched:z}=y(c,{enabled:x===`vellum`}),B=h?.providers?.vellum?.model??ee??``,[H,te]=yn(B),ne=R.find(e=>e.model===H)??R[0],[re,ie]=(0,Q.useState)(null),ae=R.some(e=>e.model===B),oe=re??(z&&B!==``&&!ae),U=(0,Q.useMemo)(()=>p.find(e=>e.id===x)??p[0],[x,p]),se=x===`vellum`&&U.supportsVoiceSelection&&H.trim()!==``&&H.trim()!==B,ce=(0,Q.useCallback)(e=>{let t=a(We+e,``),n=a(ve+e,``);M(t.length>0),E(n),O(n),w(``)},[]);(0,Q.useEffect)(()=>{ce(x)},[x,ce]);let le=(0,Q.useMemo)(()=>{let e=x!==v,t=C.trim().length>0,n=T.trim()!==D;return e||t||n||se},[x,v,C,T,D,se]),ue=(0,Q.useCallback)(async()=>{let e=C.trim(),t=T.trim(),n=U.id;V(It,n),e.length>0&&V(We+n,e),V(ve+n,t);let r=e.length>0?e:a(We+n,``),o=jr[n];L(!0);try{if(r.length>0){let{response:e}=await s({path:{assistant_id:c},body:{service:n,field:`api_key`,value:r,label:`${U.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...x!==v||!b?{provider:n,mode:n===`vellum`?`managed`:`your-own`}:{},...o?{providers:{[n]:{[o]:t}}}:{},...se?{providers:{vellum:{model:H.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await Lt({path:{assistant_id:c},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(r.length>0),O(t),w(``),d.invalidateQueries({queryKey:wt({path:{assistant_id:c}})}),K.success(i(`ttsProviderForm.saved`)),!0}catch(e){return K.error(e instanceof Error?e.message:i(`ttsProviderForm.saveFailed`)),!1}finally{L(!1)}},[c,x,H,se,C,T,U,v,b,d,i]);(0,Q.useEffect)(()=>{r?.({hasChanges:le,saving:I,save:ue})},[r,le,I,ue]);let de=(0,Q.useCallback)(()=>{V(We+x,``),M(!1),w(``)},[x]),fe=(0,Q.useCallback)(async()=>{F(!0);try{let e=a(We+x,``),t=C.trim(),n=t.length>0?t:e;if(n.length===0){K.error(i(`ttsProviderForm.apiKeyRequired`));return}let r=a(ve+x,``),o=T.trim(),s=await Er({provider:x,apiKey:n,voiceId:o.length>0?o:r,text:`Hey! It's ${l}. How does this sound?`});if(s.kind!==`audio`){K.error(s.message);return}let c=URL.createObjectURL(s.blob);try{let e=new Audio(c);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(c)}}finally{F(!1)}},[l,C,x,T,i]),pe=k?`•••••••• (Enter a new key to replace)`:U.apiKeyPlaceholder,me=x===`vellum`,he=me&&U.supportsVoiceSelection,ge=(0,$.jsxs)(P,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{ie(!1),R.some(e=>e.model===H)||te(ee||R[0]?.model||``)},children:[(0,$.jsx)(nn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(`ttsProviderForm.chooseFromCatalog`)]}),_e=he&&oe&&R.length>0?ge:null;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.provider`)}),(0,$.jsx)(J,{value:x,onChange:S,options:p.map(e=>({value:e.id,label:e.displayName})),"aria-label":i(`ttsProviderForm.providerAriaLabel`)})]}),!me&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.apiKey`)}),(0,$.jsx)(q,{type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:pe,fullWidth:!0})]}),he&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.voice`)}),oe?(0,$.jsx)(q,{type:`text`,value:H,onChange:e=>te(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),"aria-label":i(`ttsProviderForm.customVoiceIdAriaLabel`),fullWidth:!0}):ne?(0,$.jsx)(Ar,{assistantId:c,value:H,onChange:te}):z&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.noManagedVoices`)})]}),U.supportsVoiceSelection&&!me&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.voiceId`)}),(0,$.jsx)(q,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),fullWidth:!0})]}),!n&&!me&&(0,$.jsx)(fn,{guide:U.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!me&&(0,$.jsx)(P,{variant:`outlined`,onClick:fe,disabled:N,children:i(N?`ttsProviderForm.testing`:`ttsProviderForm.test`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[_e,!t&&(0,$.jsx)(dn,{onClick:ue,disabled:!le||I}),k&&!me&&(0,$.jsx)(un,{onClick:de})]})]})]})}function Nr(){let{t:e}=X(`settings`);return(0,$.jsx)(ln,{id:`text-to-speech`,title:e(`textToSpeechCard.title`),subtitle:e(`textToSpeechCard.subtitle`),children:(0,$.jsx)(Mr,{})})}var Pr=`default`;function Fr(){let{t:e}=X(`settings`),t=Et(),n=Jt(),{data:r}=Y({...gt({path:{assistant_id:t}}),staleTime:3e4}),i=be({onSuccess:e=>{Ke(n,{path:{assistant_id:t}},e)}}),s=vn(),c=(0,Q.useMemo)(()=>r?r.services?.[`web-fetch`]?.provider||a(`vellum:ai:webFetchProvider`,Pr):a(f,Pr),[r]),l=(0,Q.useMemo)(()=>r?.services?.[`web-fetch`]?.apiBase??``,[r]),[u,d]=(0,Q.useState)(!1),[p,m]=yn(c),[h,g]=yn(l),[_,v]=(0,Q.useState)(``),y=lt.has(p),b=o.has(p),{hasStoredCredential:x}=w({assistantId:t,credentialKind:`api_key`,credentialName:p,enabled:b}),S=_.trim().length>0,C=h.trim(),T=et(p,y&&C.length>0),E=p!==c||y&&C!==l.trim(),D=u||b&&!T&&!x&&!S||!E&&!S,O=Ae(U[p]??e(`webFetchCard.apiKeyPlaceholder`),x),k=at[p]??``,A=(0,Q.useCallback)(async()=>{d(!0);let r=_.trim(),a=b&&r.length>0;try{a&&await s(p,r),await i.mutateAsync({path:{assistant_id:t},body:{services:{"web-fetch":{provider:p,...y?{apiBase:C}:{}}}}}).catch(t=>{throw K.error(e(`webFetchCard.configUpdateFailedToast`)),G(t,{context:`patch_daemon_config`}),t})}catch{d(!1);return}d(!1);try{if(V(f,p),a){let e=zt(p);e&&V(e,r);let i=De(t,`api_key`,p);n.setQueryData(i,!0),n.invalidateQueries({queryKey:i}),v(``)}K.success(e(`webFetchCard.savedToast`))}catch(t){G(t,{context:`settings-ai-web-fetch-persist-local`}),K.error(e(`webFetchCard.localPreferencesFailedToast`))}},[b,i,s,n,t,_,p,y,C,e]),j=(0,Q.useCallback)(()=>{let e=zt(p);e&&it(e),v(``),g(``),m(Pr),V(f,Pr)},[p,m,g]);return(0,$.jsx)(ln,{id:`web-fetch`,title:e(`webFetchCard.title`),subtitle:e(`webFetchCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`webFetchCard.providerLabel`)}),(0,$.jsx)(J,{value:p,onChange:m,options:H.map(e=>({value:e,label:R[e]??e}))})]}),y&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{label:e(`webFetchCard.apiBaseLabel`),type:`url`,value:h,onChange:e=>g(e.target.value),placeholder:k||e(`webFetchCard.apiBasePlaceholder`),fullWidth:!0}),k?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webFetchCard.apiBaseHint`,{defaultBase:k})}):null]}),b&&(0,$.jsx)(q,{label:e(`webFetchCard.apiKeyLabel`),type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:O,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:A,disabled:D}),u&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),b&&(0,$.jsx)(un,{onClick:j,filled:!0})]})]})})}var Ir=`0.10.12`;function Lr(){return h(Ir)}function Rr(){let{t:e}=X(`settings`),t=Et(),n=Jt(),r=A(),{data:i}=Y({...gt({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),o=be({onSuccess:e=>{Ke(n,{path:{assistant_id:t}},e)}}),s=vn(),c=(0,Q.useMemo)(()=>{if(!i)return a(Pt,`inference-provider-native`);let e=i.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||a(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[i]),l=(0,Q.useMemo)(()=>i?.services?.[`web-search`]?.apiBase??``,[i]),[u,f]=(0,Q.useState)(!1),[p,h]=yn(c),[g,_]=yn(l),[y,b]=(0,Q.useState)(``),x=_e.has(p),S=d.has(p),C=Mt.has(p),{hasStoredCredential:T}=w({assistantId:t,credentialKind:`api_key`,credentialName:p,enabled:S}),E=y.trim().length>0,D=g.trim(),O=et(p,x&&D.length>0),k=p!==c||x&&D!==l.trim(),j=ye[p]??``,M=S&&!C&&!O&&!T&&!E,N=x&&j.length===0&&!D,P=u||M||N||!k&&!E,F=Ae(ie[p]??e(`webSearchCard.apiKeyPlaceholder`),T),I=(0,Q.useCallback)(async()=>{f(!0);let r=y.trim(),i=He(p),a=S&&r.length>0;try{a&&await s(p,r),await ot();let n=p===`vellum`?Lr()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:p,mode:`your-own`,...x?{apiBase:D}:{}};await o.mutateAsync({path:{assistant_id:t},body:{services:{"web-search":n}}}).catch(t=>{throw K.error(e(`webSearchCard.configUpdateFailedToast`)),G(t,{context:`patch_daemon_config`}),t})}catch{f(!1);return}f(!1);try{if(V(Pt,p),a){i&&V(i,r);let e=De(t,`api_key`,p);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),b(``)}K.success(e(`webSearchCard.savedToast`))}catch(t){G(t,{context:`settings-ai-web-search-persist-local`}),K.error(e(`webSearchCard.localPreferencesFailedToast`))}},[S,o,s,n,t,y,p,x,D,e]),L=(0,Q.useCallback)(()=>{let e=He(p);e&&it(e),b(``),_(``),h(`inference-provider-native`),V(Pt,`inference-provider-native`)},[p,h,_]);return(0,$.jsx)(ln,{title:e(`webSearchCard.title`),subtitle:e(`webSearchCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`webSearchCard.providerLabel`)}),(0,$.jsx)(J,{"aria-label":e(`webSearchCard.providerAriaLabel`),value:p,onChange:h,options:m.map(e=>({value:e,label:v[e]??e}))})]}),p===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.vellumNote`)}),x&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{label:e(`webSearchCard.apiBaseLabel`),type:`url`,value:g,onChange:e=>_(e.target.value),placeholder:j||e(`webSearchCard.apiBasePlaceholder`),fullWidth:!0}),j?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.apiBaseHint`,{defaultBase:j})}):null]}),S&&(0,$.jsx)(q,{label:e(`webSearchCard.apiKeyLabel`),type:`password`,value:y,onChange:e=>b(e.target.value),placeholder:F,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:I,disabled:P}),u&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),S&&(0,$.jsx)(un,{onClick:L,filled:!0})]})]})})}function zr(){let e=Et(),t=N(),[n,r]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]);let i=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto`,children:[(0,$.jsx)(tr,{}),(0,$.jsx)($n,{panel:n,onOpenPanel:r,onClosePanel:()=>r(null)}),(0,$.jsx)(Rr,{}),(0,$.jsx)(Fr,{}),(0,$.jsx)(wn,{}),(0,$.jsx)(Nr,{}),(0,$.jsx)(Tr,{})]}),a=`${e??`none`}:${n?.kind===`profile`?`profile:${n.name}`:n?.kind===`provider`?`provider:${n.name}`:n?.kind??`closed`}`,o=n?.kind===`provider`||n?.kind===`add-provider`,s=n!=null&&e?n.kind===`overrides`?(0,$.jsx)(mr,{assistantId:e,onClose:()=>r(null)},a):o?(0,$.jsx)(_r,{assistantId:e,connectionName:n.kind===`provider`?n.name:null,onClose:()=>r(null)},a):(0,$.jsx)(nr,{assistantId:e,profileName:n.kind===`profile`?n.name:null,onClose:()=>r(null)},a):null;return s&&t?(0,$.jsx)(mn,{children:s}):s?(0,$.jsx)(gn,{storageKey:`aiSettingsDetailDrawerWidth`,detailKey:a,section:i,detail:s}):i}export{zr as AiPage};