@vellumai/web 0.12.2-staging.4 → 0.12.2-staging.5

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 (198) hide show
  1. package/dist/assets/{a2a-invite-C-d__v0P.js → a2a-invite-D7Z1FvN-.js} +1 -1
  2. package/dist/assets/{about-page-BMTVVfA2.js → about-page-JRNWZ7kb.js} +1 -1
  3. package/dist/assets/{account-page-Bu04CQvW.js → account-page-Fw9S3qL2.js} +1 -1
  4. package/dist/assets/{account-shell-0TviHaBf.js → account-shell-BZp2-g1N.js} +1 -1
  5. package/dist/assets/{acp-run-detail-panel-w4reCx6D.js → acp-run-detail-panel-2Nc7KPDZ.js} +1 -1
  6. package/dist/assets/{activation-list-route-CSuVtIeq.js → activation-list-route-L2lNhfTD.js} +1 -1
  7. package/dist/assets/{activity-redirect-page-Cgmmb8Rc.js → activity-redirect-page-ClzSvQoo.js} +1 -1
  8. package/dist/assets/{activity-steps-panel-C26DS_qd.js → activity-steps-panel-DSJiB6_Z.js} +1 -1
  9. package/dist/assets/{add-credits-modal-IIKnKS9l.js → add-credits-modal-CAUxaNjZ.js} +1 -1
  10. package/dist/assets/add-credits-modal-CXZ_HMMM.js +1 -0
  11. package/dist/assets/{ai-page-_iWq21vC.js → ai-page-yAJ8z8PM.js} +1 -1
  12. package/dist/assets/{android-billing-handoff-BVx_2Qs0.js → android-billing-handoff-BxVpZpp4.js} +1 -1
  13. package/dist/assets/{api-key-screen-xui6n8NR.js → api-key-screen-Ccta6gO2.js} +1 -1
  14. package/dist/assets/{app-info-4gR8gnBC.js → app-info-Csu7V_TE.js} +1 -1
  15. package/dist/assets/app-p4YU9h0P.js +392 -0
  16. package/dist/assets/{archive-redirect-page-D1zUz-Kn.js → archive-redirect-page-CzxO3IP6.js} +1 -1
  17. package/dist/assets/{assistant-status-panel-B-woG0mJ.js → assistant-status-panel-WAUlzwkS.js} +1 -1
  18. package/dist/assets/auth-store-Ck1z7eSl.js +1 -0
  19. package/dist/assets/{auth-welcome-screen-BsYIoTpq.js → auth-welcome-screen-pfPKjv5w.js} +1 -1
  20. package/dist/assets/avatar-bundled-components-D1XVsaGL.js +1 -0
  21. package/dist/assets/{avatar-random-DTCQMspt.js → avatar-random-Cki-Ly_C.js} +2 -2
  22. package/dist/assets/{await-org-header-settled-euao9G4w.js → await-org-header-settled-6bT0rbUs.js} +1 -1
  23. package/dist/assets/{background-task-detail-panel-Bm7wkZ5w.js → background-task-detail-panel-BYCUOtG5.js} +1 -1
  24. package/dist/assets/{billing-page-BkUfkbYS.js → billing-page-DUNd0r_e.js} +3 -3
  25. package/dist/assets/{billing-redirect-page-A8_L7A4l.js → billing-redirect-page-Dl__amIR.js} +1 -1
  26. package/dist/assets/{bookmarks-page-Db3QFcDm.js → bookmarks-page-5HR6Klms.js} +1 -1
  27. package/dist/assets/{bundle-confirm-page-Cnb49ExR.js → bundle-confirm-page-BxHGHYtw.js} +1 -1
  28. package/dist/assets/{channel-transcript-panel-DFDoSX5e.js → channel-transcript-panel-O29G6BfM.js} +1 -1
  29. package/dist/assets/{channels-page-route-9NljMyj4.js → channels-page-route-BsAycszP.js} +1 -1
  30. package/dist/assets/{chat-info-panel-BENFQ0tW.js → chat-info-panel-C3GOJkgC.js} +1 -1
  31. package/dist/assets/{checkout-continuation-C38t4ayV.js → checkout-continuation-CI0HG33e.js} +1 -1
  32. package/dist/assets/{checkout-page-B6HAgaEv.js → checkout-page-KqQmNMqQ.js} +1 -1
  33. package/dist/assets/checkout-return-target-B4WZzAGx.js +1 -0
  34. package/dist/assets/command-palette-BPcXUSG_.js +1 -0
  35. package/dist/assets/{command-palette-BIYpDozl.js → command-palette-DxolRnp8.js} +1 -1
  36. package/dist/assets/{command-palette-window-page-BMC7dzK0.js → command-palette-window-page-B4sEAiOF.js} +1 -1
  37. package/dist/assets/{community-page-BxDoLG0_.js → community-page-OsB5Ahr9.js} +1 -1
  38. package/dist/assets/{companion-accent-pu5Xu8Z6.js → companion-accent-BhdiAsTr.js} +1 -1
  39. package/dist/assets/{companion-dock-zones-page-BEfMdIVO.js → companion-dock-zones-page-xJmPXMgY.js} +1 -1
  40. package/dist/assets/{companion-layout-Ye64fIzN.js → companion-layout-BPhlz6Wp.js} +1 -1
  41. package/dist/assets/{companion-popover-Bs6A6445.js → companion-popover-BsbCOPDj.js} +1 -1
  42. package/dist/assets/{companion-popover-page-7jpYeiIN.js → companion-popover-page-4ULIStvW.js} +1 -1
  43. package/dist/assets/{companion-surface-page-BrMY3X-F.js → companion-surface-page-BU0SxRLT.js} +1 -1
  44. package/dist/assets/{companion-watch-frame-page-Bk0N7E-g.js → companion-watch-frame-page-BwKy3_MW.js} +1 -1
  45. package/dist/assets/{connect-page-Bf8bYBAk.js → connect-page-BDVFjuF6.js} +1 -1
  46. package/dist/assets/{consent-controls-N6cnmytV.js → consent-controls-BXRj0Z62.js} +1 -1
  47. package/dist/assets/{contacts-gateway-C_BunUUf.js → contacts-gateway-jgC2hJQu.js} +1 -1
  48. package/dist/assets/{contacts-page-route-DIxMGBde.js → contacts-page-route-C8DyP00R.js} +1 -1
  49. package/dist/assets/{credential-entry-page-2ek7NaCu.js → credential-entry-page-DZm1DSNe.js} +1 -1
  50. package/dist/assets/{credentials-page-D3PvFMgc.js → credentials-page-BFptIyXc.js} +1 -1
  51. package/dist/assets/{csv-preview-BB-EmIxC.js → csv-preview-DYuTN03x.js} +1 -1
  52. package/dist/assets/{danger-zone-redirect-page-BVmYzrKj.js → danger-zone-redirect-page-BgNNmPcD.js} +1 -1
  53. package/dist/assets/{debug-page-CJOt0BAt.js → debug-page-CsudFgfJ.js} +1 -1
  54. package/dist/assets/{deploy-dialogs-BSCor8jx.js → deploy-dialogs-BXow2FID.js} +1 -1
  55. package/dist/assets/deploy-dialogs-Bh91S82o.js +1 -0
  56. package/dist/assets/{desktop-preview-content-BIp4Vpgt.js → desktop-preview-content-DZb6VLVc.js} +2 -2
  57. package/dist/assets/{desktop-status-CHoj8auj.js → desktop-status-Dg1h8ABX.js} +1 -1
  58. package/dist/assets/{desktop-viewer-86gYrlm2.js → desktop-viewer-38EXOmZ4.js} +1 -1
  59. package/dist/assets/{detail-card-CGafPdBQ.js → detail-card-BpqiAUnN.js} +1 -1
  60. package/dist/assets/{detail-panel-stop-button-BqhRaB6y.js → detail-panel-stop-button-BFDJ5Gir.js} +1 -1
  61. package/dist/assets/{detail-primitives-DIBzx3XJ.js → detail-primitives-CYiljnNr.js} +1 -1
  62. package/dist/assets/{developer-page-p4Ylxemb.js → developer-page-BIPONPKj.js} +1 -1
  63. package/dist/assets/{devices-redirect-page-BcyaUgzH.js → devices-redirect-page-DwI95Deo.js} +1 -1
  64. package/dist/assets/{dictation-overlay-page-C9yEcxKh.js → dictation-overlay-page-Du7FXduO.js} +1 -1
  65. package/dist/assets/{document-load-CZeb0od7.js → document-load-B4r-kmWD.js} +1 -1
  66. package/dist/assets/document-load-Bcy7cK7m.js +1 -0
  67. package/dist/assets/{document-viewer-page-L_O7lYHa.js → document-viewer-page-BzftukxE.js} +1 -1
  68. package/dist/assets/{emails-page-fgZebuJ7.js → emails-page-Cp6XS4Jh.js} +1 -1
  69. package/dist/assets/{environment-store-7mW8BRRm.js → environment-store-DXa_IPIU.js} +1 -1
  70. package/dist/assets/{file-diff-view-B9dRfPbB.js → file-diff-view-DIBSfwHd.js} +1 -1
  71. package/dist/assets/{file-editor-DtbuATs6.js → file-editor-gXTdPzcn.js} +1 -1
  72. package/dist/assets/{general-page-iMRa5Ucp.js → general-page-Du-jPHaf.js} +1 -1
  73. package/dist/assets/{hatching-screen-C9GXGQ2P.js → hatching-screen-BZup1IEp.js} +1 -1
  74. package/dist/assets/{hosting-screen-D8bCW4Uz.js → hosting-screen-B1uKDCEA.js} +1 -1
  75. package/dist/assets/{identity-page-route-D0fpi7db.js → identity-page-route-Cm6K_bBR.js} +1 -1
  76. package/dist/assets/{inspect-page-C2T5Wpgw.js → inspect-page-iBkyiBTD.js} +3 -3
  77. package/dist/assets/{integrations-page-3cwkXYyq.js → integrations-page-CVmr89JP.js} +1 -1
  78. package/dist/assets/{intelligence-layout-jyahyAWu.js → intelligence-layout-CzYFqgC5.js} +1 -1
  79. package/dist/assets/intelligence-layout-slots-store-C5ni0SPd.js +1 -0
  80. package/dist/assets/{keyboard-shortcuts-redirect-page-Bcl-FjyB.js → keyboard-shortcuts-redirect-page-VOpK_vkw.js} +1 -1
  81. package/dist/assets/{latest-assistant-text-HB3-JTrf.js → latest-assistant-text-CRS_nZkk.js} +1 -1
  82. package/dist/assets/{library-detail-page-DTptYQAF.js → library-detail-page-CYDXCYR7.js} +1 -1
  83. package/dist/assets/{library-page-D0OfVER_.js → library-page-DU9_fODf.js} +1 -1
  84. package/dist/assets/local-mode-BwMCd1ly.js +1 -0
  85. package/dist/assets/{login-page-BA3GjFvS.js → login-page-OqpqflhY.js} +1 -1
  86. package/dist/assets/{logout-page-Dp--IQJm.js → logout-page-B75MMPkh.js} +1 -1
  87. package/dist/assets/{logs-layout-C4SjgNAl.js → logs-layout-Dj1ybnfw.js} +1 -1
  88. package/dist/assets/{markdown-preview-CBu26q1U.js → markdown-preview-r7bRpgS4.js} +1 -1
  89. package/dist/assets/{media-preview-CrddXQMc.js → media-preview-ozDVMMcK.js} +1 -1
  90. package/dist/assets/{memory-page-route-BzLfpam9.js → memory-page-route-DSoeQ_G0.js} +1 -1
  91. package/dist/assets/{memory-router-playground-page-CP0Eurny.js → memory-router-playground-page-Cica9Nbb.js} +1 -1
  92. package/dist/assets/{message-files-panel-CDzpeEx4.js → message-files-panel-DwXYI7Vj.js} +1 -1
  93. package/dist/assets/{metric-card-Dkx47Ug0.js → metric-card-CRZNAmE4.js} +1 -1
  94. package/dist/assets/native-attachment-pickers-DH76HUOD.js +1 -0
  95. package/dist/assets/native-file-AwxfXJFy.js +1 -0
  96. package/dist/assets/{notifications-page-1r0ehmHL.js → notifications-page-8XrbAs9c.js} +1 -1
  97. package/dist/assets/{oauth-complete-page-D8yKCOVn.js → oauth-complete-page-B-oiboUF.js} +1 -1
  98. package/dist/assets/{oauth-popup-complete-page-DzPqlG80.js → oauth-popup-complete-page-DbkS3Ktn.js} +1 -1
  99. package/dist/assets/paired-platform-identity-BN-Q3FiP.js +1 -0
  100. package/dist/assets/{pairing-page-DhmG1Tkg.js → pairing-page-CL3aDKN8.js} +1 -1
  101. package/dist/assets/password-reset-page-9EUcZrPc.js +1 -0
  102. package/dist/assets/{pdf-file-preview-ElX646lL.js → pdf-file-preview-DWb95OOo.js} +1 -1
  103. package/dist/assets/{personality-page-DXW5MuRz.js → personality-page-Cd4rs_nw.js} +1 -1
  104. package/dist/assets/{personality-page-BqW5uuDF.js → personality-page-DRi1SkGz.js} +1 -1
  105. package/dist/assets/{personality-sliders-BuInNb35.js → personality-sliders-r9DH0oqr.js} +1 -1
  106. package/dist/assets/{plans-page-B87o5Bm-.js → plans-page-3TPIVG-V.js} +1 -1
  107. package/dist/assets/{platform-loopback-page--ynU4rVO.js → platform-loopback-page-6AkvXRD1.js} +1 -1
  108. package/dist/assets/{plugin-detail-page-lbmmlIpx.js → plugin-detail-page-C2PIC2NZ.js} +1 -1
  109. package/dist/assets/{plugins-page-BM44sOv4.js → plugins-page-Y18LhhDz.js} +1 -1
  110. package/dist/assets/plugins-surface-rSnCf7eu.js +1 -0
  111. package/dist/assets/{preview-error-B6mdXJ98.js → preview-error-BWXX5254.js} +1 -1
  112. package/dist/assets/{privacy-page-BqqU59zB.js → privacy-page-zDZFH9JY.js} +1 -1
  113. package/dist/assets/{privacy-screen-CW2gbeYL.js → privacy-screen-BdvoQ-DB.js} +1 -1
  114. package/dist/assets/{provider-callback-page-PVHvQXqC.js → provider-callback-page-CFS4DEY_.js} +1 -1
  115. package/dist/assets/{provider-key-fvCko3IH.js → provider-key-CYTAv7Kh.js} +1 -1
  116. package/dist/assets/{provider-signup-page-D6kN0d9F.js → provider-signup-page-C89a_7j5.js} +1 -1
  117. package/dist/assets/{quick-input-page-DMs0592w.js → quick-input-page-5f0AEU1o.js} +1 -1
  118. package/dist/assets/referral-modal-BciUQDfu.js +1 -0
  119. package/dist/assets/{referral-modal-C5ePy9XT.js → referral-modal-Dk1Vo23P.js} +1 -1
  120. package/dist/assets/{research-mock-page-D3X9Fw83.js → research-mock-page-DWfJd3UP.js} +1 -1
  121. package/dist/assets/{research-onboarding-route-Bk2Zl9y9.js → research-onboarding-route-Bd2vn3i5.js} +1 -1
  122. package/dist/assets/{review-terms-screen-CU9h0Gz5.js → review-terms-screen-M8IjrJH-.js} +1 -1
  123. package/dist/assets/routes-D_UALtH1.js +1 -0
  124. package/dist/assets/{schedules-Cslj2E_n.js → schedules-C83Ua4R6.js} +1 -1
  125. package/dist/assets/{schedules-page-7QBCwWLg.js → schedules-page-lT5NcWNK.js} +1 -1
  126. package/dist/assets/{security-redirect-page-D6C5fIZt.js → security-redirect-page-BcTO6hEV.js} +1 -1
  127. package/dist/assets/{select-assistant-screen-BO9WTRBj.js → select-assistant-screen-DAwfV-mz.js} +1 -1
  128. package/dist/assets/{self-hosted-servers-sqp6RgAQ.js → self-hosted-servers-BmfZpV_S.js} +1 -1
  129. package/dist/assets/{service-form-controls-C5nQsTzh.js → service-form-controls-B3_1_Epi.js} +1 -1
  130. package/dist/assets/{setting-row-Dqextrfj.js → setting-row-Dz9SXznO.js} +1 -1
  131. package/dist/assets/{settings-divider-D-IFmB_l.js → settings-divider-C1j4hJMG.js} +1 -1
  132. package/dist/assets/{settings-layout-Bh7MaZ4H.js → settings-layout-CQfyqDUr.js} +1 -1
  133. package/dist/assets/{share-feedback-modal-DsaGXNnY.js → share-feedback-modal-Ka1FQwFE.js} +1 -1
  134. package/dist/assets/share-feedback-modal-sGkJieen.js +1 -0
  135. package/dist/assets/{sidebar-tree-BgVhUiEU.js → sidebar-tree-BSRyDJ-e.js} +1 -1
  136. package/dist/assets/{signup-page-CzQJSqzn.js → signup-page-CcJHavhm.js} +1 -1
  137. package/dist/assets/{signup-shell-C1cGo11n.js → signup-shell-D9ohM8Rf.js} +1 -1
  138. package/dist/assets/{skill-detail-page-BN8Rwzuu.js → skill-detail-page-CGtKgK0P.js} +1 -1
  139. package/dist/assets/{skill-detail-panel-DVrh3t_h.js → skill-detail-panel-Bpl_9hRY.js} +1 -1
  140. package/dist/assets/{skill-removal-dialog-CkduZswH.js → skill-removal-dialog-C91c4ZfS.js} +1 -1
  141. package/dist/assets/{skills-page-DS76T-t4.js → skills-page-DpwPDybh.js} +1 -1
  142. package/dist/assets/{sounds-page-Bqrv7A7h.js → sounds-page-CzL0Egaq.js} +1 -1
  143. package/dist/assets/{start-screen-Cz9LflKA.js → start-screen-Cph32ejI.js} +1 -1
  144. package/dist/assets/{stt-language-picker-modal-Ckz32Oh1.js → stt-language-picker-modal-3iCIcD10.js} +1 -1
  145. package/dist/assets/{subagent-detail-panel-C2AI9zu4.js → subagent-detail-panel-DF4ZXV2K.js} +1 -1
  146. package/dist/assets/{superpowers-page-CMOvPhlc.js → superpowers-page-DmqxKZ6y.js} +1 -1
  147. package/dist/assets/{system-events-page-D0fUUNzD.js → system-events-page-BP_Rw924.js} +1 -1
  148. package/dist/assets/{system-events-redirect-page-Dr4-w7Y1.js → system-events-redirect-page-sLsausvS.js} +1 -1
  149. package/dist/assets/{text-preview-DozGQuv6.js → text-preview-CKO4jBfL.js} +1 -1
  150. package/dist/assets/{theme-stage-page-CcBBPfjV.js → theme-stage-page-BIBA5J8a.js} +1 -1
  151. package/dist/assets/{tiptap-document-editor-Db4_RKhj.js → tiptap-document-editor-C3jfHfr_.js} +1 -1
  152. package/dist/assets/{tool-detail-panel-CNNnmtM6.js → tool-detail-panel-BkWuCCm0.js} +1 -1
  153. package/dist/assets/tool-detail-panel-msAhgoxJ.js +1 -0
  154. package/dist/assets/{trait-cycle-row-C1uqLkCi.js → trait-cycle-row-leO22btH.js} +1 -1
  155. package/dist/assets/{upgrade-cancel-page-CKZWRtvT.js → upgrade-cancel-page-B0iduvhi.js} +1 -1
  156. package/dist/assets/{upgrade-success-page-CkXzT8Ty.js → upgrade-success-page-BClAIdZm.js} +1 -1
  157. package/dist/assets/{usage-redirect-page-CRrl2BDL.js → usage-redirect-page-BxTlrAZu.js} +1 -1
  158. package/dist/assets/{use-app-delete-CFfw_T0x.js → use-app-delete-Cj0xy5H5.js} +1 -1
  159. package/dist/assets/{use-assistant-identity-details-CGJTkSlu.js → use-assistant-identity-details-Bj-VqGPz.js} +1 -1
  160. package/dist/assets/{use-checkout-dismiss-refresh-DB9VdW8-.js → use-checkout-dismiss-refresh-Clbra-UV.js} +1 -1
  161. package/dist/assets/{use-edge-swipe-back-DYPOVsUT.js → use-edge-swipe-back-D1eHj9sf.js} +1 -1
  162. package/dist/assets/{use-hotkey-recorder-Cj-vFxW2.js → use-hotkey-recorder-KK0SXCtP.js} +1 -1
  163. package/dist/assets/{use-invite-link-dialog-B4f3yyUN.js → use-invite-link-dialog-BYTs8NpU.js} +1 -1
  164. package/dist/assets/{use-platform-assistant-id-D8KGJAMf.js → use-platform-assistant-id-B1MuVrYX.js} +1 -1
  165. package/dist/assets/{use-return-to-short-circuit-Db6fiXSQ.js → use-return-to-short-circuit-CkdO0Q2j.js} +1 -1
  166. package/dist/assets/{use-side-list-room-CSNBqjJu.js → use-side-list-room-BSP_B7R_.js} +1 -1
  167. package/dist/assets/{use-skill-actions-BNpUjvgz.js → use-skill-actions-Dk64pbQd.js} +1 -1
  168. package/dist/assets/{use-skill-detail-files-C5BA-Phb.js → use-skill-detail-files-DmOW_S89.js} +1 -1
  169. package/dist/assets/use-supports-credentials-settings-BSQpJ09k.js +1 -0
  170. package/dist/assets/{use-transcript-message-by-id-ZVUnXf5k.js → use-transcript-message-by-id-diLlPoiw.js} +1 -1
  171. package/dist/assets/{voice-page-DDLtbhsC.js → voice-page-0iijkFuD.js} +1 -1
  172. package/dist/assets/{wake-detail-panel-C5K2zAvp.js → wake-detail-panel-DaKaOAfd.js} +1 -1
  173. package/dist/assets/{weather-forecast-display-CWGsPOa9.js → weather-forecast-display-ChYkwma2.js} +1 -1
  174. package/dist/assets/{welcome-screen-DuUuJIJ2.js → welcome-screen-Dwra_l1I.js} +1 -1
  175. package/dist/assets/{workflow-detail-panel-D6ip8R9Y.js → workflow-detail-panel-CgyFYiiF.js} +1 -1
  176. package/dist/assets/{workspace-page-D_4QLZh3.js → workspace-page-D-ZvFFGb.js} +1 -1
  177. package/dist/index.html +1 -1
  178. package/package.json +1 -1
  179. package/dist/assets/add-credits-modal-Byhxttdb.js +0 -1
  180. package/dist/assets/app-DFXcEvsi.js +0 -392
  181. package/dist/assets/auth-store-BFk7tSVA.js +0 -1
  182. package/dist/assets/avatar-bundled-components-B-TO2nC_.js +0 -1
  183. package/dist/assets/checkout-return-target-CrM-Nhda.js +0 -1
  184. package/dist/assets/command-palette-Dj-GW7dm.js +0 -1
  185. package/dist/assets/deploy-dialogs-DY0pTVu1.js +0 -1
  186. package/dist/assets/document-load-B9O1A5E9.js +0 -1
  187. package/dist/assets/intelligence-layout-slots-store-CI7IhmZv.js +0 -1
  188. package/dist/assets/local-mode-Dve-u3Zf.js +0 -1
  189. package/dist/assets/native-attachment-pickers-DVsB4Q0l.js +0 -1
  190. package/dist/assets/native-file-BKR4KkJt.js +0 -1
  191. package/dist/assets/paired-platform-identity-C4IGgtxq.js +0 -1
  192. package/dist/assets/password-reset-page-7yc-z_Pf.js +0 -1
  193. package/dist/assets/plugins-surface-2i_lZYet.js +0 -1
  194. package/dist/assets/referral-modal-VQ2vsPTh.js +0 -1
  195. package/dist/assets/routes-NC2Xyogy.js +0 -1
  196. package/dist/assets/share-feedback-modal-D44y3KhU.js +0 -1
  197. package/dist/assets/tool-detail-panel-PjXqpW5b.js +0 -1
  198. package/dist/assets/use-supports-credentials-settings-DIKVOLU1.js +0 -1
@@ -1 +1 @@
1
- import{Tb as e}from"./app-DFXcEvsi.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{Tb as e}from"./app-p4YU9h0P.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{Eb as t,th as n}from"./app-DFXcEvsi.js";import{j as r}from"./vendor-DYOeoIwg.js";import{t as i,x as a}from"./react-B9IgSVeK.js";import{n as o,t as s}from"./app-info-4gR8gnBC.js";var c=e(a(),1),l=i();function u(){let{t:e}=r(),i=n(),[a,u]=(0,c.useState)(null);(0,c.useEffect)(()=>{s().then(u)},[]);let f=a??d;return(0,l.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,l.jsx)(`h1`,{className:`mt-4 text-2xl font-semibold`,children:f.appName}),(0,l.jsx)(`p`,{className:`text-muted-foreground mt-1 mb-7 text-xs`,children:e(i===`windows`?`aboutPage.taglineWindows`:`aboutPage.taglineMacOS`)}),(0,l.jsxs)(`dl`,{className:`mb-7 grid grid-cols-[auto_auto] gap-x-4 gap-y-1.5 text-sm`,children:[(0,l.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.version`)}),(0,l.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:f.version}),(0,l.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.build`)}),(0,l.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:f.commitSha})]}),(0,l.jsx)(`a`,{href:f.website,className:`text-primary text-sm hover:underline`,onClick:e=>{t()&&(e.preventDefault(),o())},children:new URL(f.website).host}),(0,l.jsx)(`div`,{className:`text-muted-foreground mt-auto pt-6 text-[11px]`,children:f.copyright})]})}var d={appName:`Vellum`,version:`—`,commitSha:`—`,copyright:`© ${new Date().getFullYear()} Vellum`,website:`https://vellum.ai`};export{u as AboutPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Eb as t,th as n}from"./app-p4YU9h0P.js";import{j as r}from"./vendor-DYOeoIwg.js";import{t as i,x as a}from"./react-B9IgSVeK.js";import{n as o,t as s}from"./app-info-Csu7V_TE.js";var c=e(a(),1),l=i();function u(){let{t:e}=r(),i=n(),[a,u]=(0,c.useState)(null);(0,c.useEffect)(()=>{s().then(u)},[]);let f=a??d;return(0,l.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,l.jsx)(`h1`,{className:`mt-4 text-2xl font-semibold`,children:f.appName}),(0,l.jsx)(`p`,{className:`text-muted-foreground mt-1 mb-7 text-xs`,children:e(i===`windows`?`aboutPage.taglineWindows`:`aboutPage.taglineMacOS`)}),(0,l.jsxs)(`dl`,{className:`mb-7 grid grid-cols-[auto_auto] gap-x-4 gap-y-1.5 text-sm`,children:[(0,l.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.version`)}),(0,l.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:f.version}),(0,l.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.build`)}),(0,l.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:f.commitSha})]}),(0,l.jsx)(`a`,{href:f.website,className:`text-primary text-sm hover:underline`,onClick:e=>{t()&&(e.preventDefault(),o())},children:new URL(f.website).host}),(0,l.jsx)(`div`,{className:`text-muted-foreground mt-auto pt-6 text-[11px]`,children:f.copyright})]})}var d={appName:`Vellum`,version:`—`,commitSha:`—`,copyright:`© ${new Date().getFullYear()} Vellum`,website:`https://vellum.ai`};export{u as AboutPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{As as t,Dp as n,Ss as r,Tb as i,ev as a,kp as o,wp as s,xs as c}from"./app-DFXcEvsi.js";import{j as l}from"./vendor-DYOeoIwg.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-0TviHaBf.js";var h=e(f(),1),g=d();function _(){let{t:e}=l(`account`),d=n(),f=o(),_=s.use.user(),v=s.use.logout(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(!1),C=async()=>{b(null),S(!0);try{await a(r,c)}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:i.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(),t(i.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{As as t,Dp as n,Ss as r,Tb as i,ev as a,kp as o,wp as s,xs as c}from"./app-p4YU9h0P.js";import{j as l}from"./vendor-DYOeoIwg.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-BZp2-g1N.js";var h=e(f(),1),g=d();function _(){let{t:e}=l(`account`),d=n(),f=o(),_=s.use.user(),v=s.use.logout(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(!1),C=async()=>{b(null),S(!0);try{await a(r,c)}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:i.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(),t(i.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{Bx as e}from"./app-DFXcEvsi.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{Bx as e}from"./app-p4YU9h0P.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{An as t,Gn as n,Hx as r,Ix as i,Kn as a,Kx as o,Pb as s,Ux as c,Yn as l,_r as u,bn as d,gr as f,hr as p,mr as m,qn as h}from"./app-DFXcEvsi.js";import{I as g,j as _}from"./vendor-DYOeoIwg.js";import{t as v,x as y}from"./react-B9IgSVeK.js";import{Ba as b,E as x,Fi as S,Gi as C,Ja as w,Ki as T,Mr as E,N as D,Ot as O,Q as ee,Ri as k,Sr as A,Va as te,Wi as j,Zn as ne,_t as re,gt as ie,k as ae,ki as oe,ma as M,pi as se,zr as N}from"./icons-QG1KAFmx.js";import{i as P,n as ce,r as F,t as I}from"./metric-card-Dkx47Ug0.js";import{t as le}from"./file-diff-view-B9dRfPbB.js";import{t as ue}from"./detail-panel-stop-button-BqhRaB6y.js";import{t as de}from"./status-badge-pill-Dw3L9IOE.js";var fe=w(`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`}]]),L=e(y(),1),R=``;function z(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 B(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`&&B(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??R,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??R,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!==R&&r&&r.kind===`agent`&&r.messageId===R&&!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??R,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:z(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:z(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=pe(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 pe(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 me(e){let t=[];for(let n of e)U(t,n);return t}function he(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 ge(){let e=null,t=[];function n(n){return t=me(n),e=n,t}function r(r){let i=he(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 _e(e){let t=(0,L.useRef)(null);return t.current??=ge(),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=ve(e);t&&r.push(t)}return r}function ve(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`content`:return{type:`content`,text:ye(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=be(t);return e===void 0?{type:`terminal`}:{type:`terminal`,text:e}}default:return null}}function ye(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.text;if(typeof t==`string`)return t}return``}function be(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{An as t,Gn as n,Hx as r,Ix as i,Kn as a,Kx as o,Pb as s,Ux as c,Yn as l,_r as u,bn as d,gr as f,hr as p,mr as m,qn as h}from"./app-p4YU9h0P.js";import{I as g,j as _}from"./vendor-DYOeoIwg.js";import{t as v,x as y}from"./react-B9IgSVeK.js";import{Ba as b,E as x,Fi as S,Gi as C,Ja as w,Ki as T,Mr as E,N as D,Ot as O,Q as ee,Ri as k,Sr as A,Va as te,Wi as j,Zn as ne,_t as re,gt as ie,k as ae,ki as oe,ma as M,pi as se,zr as N}from"./icons-QG1KAFmx.js";import{i as P,n as ce,r as F,t as I}from"./metric-card-CRZNAmE4.js";import{t as le}from"./file-diff-view-DIBSfwHd.js";import{t as ue}from"./detail-panel-stop-button-BFDJ5Gir.js";import{t as de}from"./status-badge-pill-Dw3L9IOE.js";var fe=w(`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`}]]),L=e(y(),1),R=``;function z(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 B(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`&&B(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??R,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??R,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!==R&&r&&r.kind===`agent`&&r.messageId===R&&!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??R,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:z(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:z(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=pe(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 pe(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 me(e){let t=[];for(let n of e)U(t,n);return t}function he(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 ge(){let e=null,t=[];function n(n){return t=me(n),e=n,t}function r(r){let i=he(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 _e(e){let t=(0,L.useRef)(null);return t.current??=ge(),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=ve(e);t&&r.push(t)}return r}function ve(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`content`:return{type:`content`,text:ye(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=be(t);return e===void 0?{type:`terminal`}:{type:`terminal`,text:e}}default:return null}}function ye(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.text;if(typeof t==`string`)return t}return``}function be(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=v();function xe({content:e,isComplete:n,assistantId:r}){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)(d,{content:e,assistantId:r}),!n&&(0,X.jsx)(t,{className:`mt-1`,"data-testid":`acp-chat-agent-streaming`})]})}function Se({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)(ne,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(r,{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)(k,{"aria-hidden":!0,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}):(0,X.jsx)(oe,{"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 Z(e){switch(e){case`max_tokens`:case`max_turn_requests`:return g(`chat:acpChatTerminalBlock.stoppedLimitReached`);case`refusal`:return g(`chat:acpChatTerminalBlock.refused`);case`cancelled`:return g(`chat:acpChatTerminalBlock.cancelled`);default:return g(`chat:acpChatTerminalBlock.completed`)}}function Ce(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:Ce(e)})})}function we({status:e,stopReason:t,error:n,completedAt:r}){let{t:i}=_(`chat`);if(u(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)(x,{className:`h-4 w-4`})}),(0,X.jsx)(`span`,{children:n??i(`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)(S,{"aria-hidden":!0,className:`h-4 w-4 shrink-0`}),(0,X.jsx)(`span`,{children:i(`acpChatTerminalBlock.cancelled`)}),(0,X.jsx)(Q,{completedAt:r})]});let a=Z(t);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)(k,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,X.jsx)(`span`,{children:a}),(0,X.jsx)(Q,{completedAt:r})]})}function Te({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 Ee({content:e,isComplete:n,assistantId:r}){let[i,a]=(0,L.useState)(null),o=i??!n,s=e.trim().length>0,c=n?`Thought process`:`Thinking`,l=n?(0,X.jsx)(M,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,X.jsx)(t,{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:()=>a(!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)(T,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,X.jsx)(j,{"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)(d,{content:e,assistantId:r})})]}):(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 De={running:`neutral`,completed:`positive`,error:`negative`,ended:`neutral`},Oe={running:`Running`,completed:`Completed`,error:`Failed`,ended:`Ended`},ke={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`},Ae=`Tool call`,je={read:N,edit:fe,delete:ae,move:E,search:re,execute:D,think:M,fetch:A,switch_mode:O},Me=new Set([`read`,`edit`,`delete`,`move`]);function Ne({toolKind:e}){return(0,X.jsx)(e&&je[e]||se,{"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 Pe({block:e,isTerminal:n=!1,onOpenDiff:a,onOpenOutput:o}){let{t:s}=_(`chat`),[c,l]=(0,L.useState)(!1),u=(0,L.useMemo)(()=>G(e.content),[e.content]),d=(0,L.useMemo)(()=>q(e.content),[e.content]),f=(0,L.useMemo)(()=>d.split(`
3
3
  `).map(e=>e.trim()).find(e=>e.length>0&&!e.startsWith("```"))||`View output`,[d]),p=(0,L.useMemo)(()=>Y(u,e.locations),[u,e.locations]),m=n&&e.status===`running`?`ended`:e.status,h=m===`running`,g=e.toolKind&&ke[e.toolKind]||Ae,v=K(e.rawInput)??e.title,y=v&&v!==g&&(!Me.has(e.toolKind??``)||p.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)(Ne,{toolKind:e.toolKind}),(0,X.jsx)(r,{variant:`body-small-emphasised`,className:`min-w-0 flex-1 truncate text-[var(--content-default)]`,title:e.title,children:g}),(0,X.jsx)(i,{tone:De[m],"data-testid":`acp-chat-tool-status`,children:Oe[m]}),h&&(0,X.jsx)(t,{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}),p.length>0&&(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:p.map(t=>{let n=t.oldText!==void 0||t.newText!==void 0,r=`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:()=>a(e.toolCallId,t),title:t.path,className:`${r} cursor-pointer transition-colors hover:bg-[var(--surface-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--border-focus)]`,children:[(0,X.jsx)(N,{"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:r,children:[(0,X.jsx)(N,{"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)})}),d.length>0&&(0,X.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-output-open`,onClick:()=>o?.(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(--border-focus)]`,children:[(0,X.jsx)(D,{"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:f}),(0,X.jsx)(j,{"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":c,onClick:()=>l(e=>!e),className:`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-default)]`,children:[c?(0,X.jsx)(T,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,X.jsx)(j,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{children:s(c?`acpChatToolCard.hideRaw`:`acpChatToolCard.showRaw`)})]}),c&&(0,X.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-2`,children:[b!==void 0&&(0,X.jsx)($,{label:s(`acpChatToolCard.rawInput`),value:b,testId:`acp-chat-tool-raw-input`}),x!==void 0&&(0,X.jsx)($,{label:s(`acpChatToolCard.rawOutput`),value:x,testId:`acp-chat-tool-raw-output`})]})]})]})}function Fe({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 Ie({model:e,options:t}){let{t:n}=_(`chat`),r=t?.find(t=>t.value===e)?.label??e;return(0,X.jsx)(ce,{icon:(0,X.jsx)(ee,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),value:r,valueTitle:r,label:n(`acpRunChatView.modelLabel`)})}function Le({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)(d,{content:q(e),hardLineBreaks:!0,assistantId:t})})}var Re=80;function ze(e){return e.scrollHeight-e.clientHeight-e.scrollTop<=Re}function Be(e){let t=(0,L.useRef)(null),n=(0,L.useRef)(!0),[r,i]=(0,L.useState)(!1),a=(0,L.useCallback)(()=>{let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[]),o=(0,L.useCallback)(()=>{let e=t.current;if(!e)return;let r=ze(e);n.current=r,i(e=>e===!r?e:!r)},[]),s=(0,L.useCallback)(()=>{n.current=!0,a(),i(!1)},[a]),c=(0,L.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,L.useLayoutEffect)(()=>{n.current?a():o()},[e,a,o]),{scrollRef:c,showScrollToLatest:r,scrollToLatest:s}}function Ve(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 He=[];function Ue({entry:e,onClose:t,assistantId:n}){let{t:i}=_(`chat`),a=u(e.status),{model:s}=e,l=e.inputTokens!==void 0||e.outputTokens!==void 0,d=_e(p(t=>t.byId[e.acpSessionId]?.events??He)),[f,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(e.acpSessionId);h!==e.acpSessionId&&(g(e.acpSessionId),m(null));let v=(0,L.useCallback)((e,t)=>m({kind:`diff`,toolCallId:e,path:t.path}),[]),y=(0,L.useCallback)(e=>m({kind:`output`,toolCallId:e}),[]),x=(0,L.useCallback)(()=>m(null),[]),S=(0,L.useMemo)(()=>f?d.find(e=>e.kind===`tool`&&e.toolCallId===f.toolCallId)??null:null,[f,d]),C=(0,L.useMemo)(()=>f?.kind!==`diff`||!S?null:Y(G(S.content),S.locations).find(e=>e.path===f.path)??null,[f,S]),w=f?.kind===`diff`?f.path:S?K(S.rawInput)??S.title??`Output`:`Output`,{scrollRef:T,showScrollToLatest:E,scrollToLatest:D}=Be((0,L.useMemo)(()=>({blocks:d,status:e.status,completedAt:e.completedAt}),[d,e.status,e.completedAt])),O=!a;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:x,title:e.agent,className:`min-w-0 shrink cursor-pointer truncate text-left text-[var(--content-default)] hover:underline`,children:(0,X.jsx)(r,{variant:`body-small-default`,as:`span`,children:e.agent})}),(0,X.jsx)(j,{className:`h-2.5 w-2.5 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,X.jsx)(r,{variant:`body-small-default`,as:`span`,title:w,className:`min-w-0 shrink truncate font-mono text-[var(--content-secondary)]`,children:w})]}),(0,X.jsx)(We,{entry:e,isRunning:a,onClose:t,showBack:!!f,onBack:x},`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)(le,{path:f.path,oldText:C?.oldText,newText:C?.newText}):(0,X.jsx)(Le,{content:S?.content,assistantId:n})}):(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,X.jsxs)(`div`,{ref:T,"data-testid":`acp-chat-conversation`,className:`flex h-full flex-col gap-4 overflow-y-auto px-5 py-5`,children:[(l||s!==void 0)&&(0,X.jsxs)(`div`,{className:o(`grid gap-3`,l?`grid-cols-2`:`grid-cols-1`),"data-testid":`acp-run-metrics`,children:[l&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{icon:(0,X.jsx)(te,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.inputTokens??0,format:e=>F(Math.round(e)),label:i(`acpRunChatView.inputLabel`)}),(0,X.jsx)(I,{icon:(0,X.jsx)(P,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.outputTokens??0,format:e=>F(Math.round(e)),label:i(`acpRunChatView.outputLabel`)})]}),s!==void 0&&(0,X.jsx)(`div`,{className:l?`col-span-2`:void 0,children:(0,X.jsx)(Ie,{model:s,options:e.availableModels})})]}),(0,X.jsx)(Ge,{task:e.task}),(0,X.jsx)(`div`,{className:`flex flex-col`,"data-testid":`acp-chat-timeline`,children:d.map((e,t)=>(0,X.jsx)(Te,{showDot:t===0||t===d.length-1||e.kind===`tool`||e.kind===`plan`,isLast:t===d.length-1,children:(0,X.jsx)(Ke,{block:e,isTerminal:O,onOpenDiff:v,onOpenOutput:y,assistantId:n})},Ve(e,t)))}),!a&&(0,X.jsx)(we,{status:e.status,stopReason:e.stopReason,error:e.error,completedAt:e.completedAt})]}),E&&(0,X.jsx)(c,{variant:`outlined`,size:`compact`,iconOnly:(0,X.jsx)(b,{}),onClick:D,"aria-label":i(`acpRunChatView.goToNewest`),tooltip:i(`acpRunChatView.goToNewest`),"data-testid":`acp-chat-scroll-to-latest`,className:`absolute bottom-3 left-1/2 -translate-x-1/2 rounded-full shadow-md`})]}),a&&!f&&(0,X.jsx)(qe,{acpSessionId:e.acpSessionId},`steer-${e.acpSessionId}`)]})}function We({entry:e,isRunning:t,onClose:n,showBack:r=!1,onBack:i}){let{t:o}=_(`chat`),[u,d]=(0,L.useState)(!1),p=f(e.status,e.stopReason),m=(0,L.useCallback)(()=>{d(!0),a(e.acpSessionId).catch(e=>{d(!1),s(e,{context:`AcpRunChatView.stop`})})},[e.acpSessionId]);return(0,X.jsx)(l,{icon:(0,X.jsxs)(X.Fragment,{children:[r&&(0,X.jsx)(c,{variant:`outlined`,iconOnly:(0,X.jsx)(C,{}),onClick:i,"aria-label":o(`acpRunChatView.backToConversationAria`),tooltip:o(`acpRunChatView.backTooltip`),"data-testid":`acp-chat-diff-back`,className:`shrink-0`}),(0,X.jsx)(h,{agent:e.agent,className:`h-5 w-5 shrink-0`})]}),title:e.agent,headerTrailing:(0,X.jsx)(de,{color:p.color,label:p.label}),headerActions:t?(0,X.jsx)(ue,{onStop:m,ariaLabel:o(`acpRunChatView.stopRunAria`),disabled:u}):void 0,closeLabel:o(`acpRunChatView.closeRunDetail`),onClose:n})}function Ge({task:e}){let{t}=_(`chat`);return e?(0,X.jsxs)(`div`,{"data-testid":`acp-chat-objective`,children:[(0,X.jsx)(r,{variant:`body-medium-default`,as:`h3`,className:`mb-1 text-[var(--content-emphasised)]`,children:t(`acpRunChatView.objective`)}),(0,X.jsx)(r,{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 Ke({block:e,isTerminal:t,onOpenDiff:n,onOpenOutput:r,assistantId:i}){switch(e.kind){case`user`:return(0,X.jsx)(Fe,{content:e.content});case`agent`:return(0,X.jsx)(xe,{content:e.content,isComplete:e.isComplete||t,assistantId:i});case`thinking`:return(0,X.jsx)(Ee,{content:e.content,isComplete:e.isComplete||t,assistantId:i});case`tool`:return(0,X.jsx)(Pe,{block:e,isTerminal:t,onOpenDiff:n,onOpenOutput:r});case`plan`:return(0,X.jsx)(Se,{entries:e.entries})}}function qe({acpSessionId:e}){let{t}=_(`chat`),[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(!1);return(0,X.jsx)(`form`,{onSubmit:(0,L.useCallback)(t=>{t.preventDefault();let c=r.trim();if(!c||a)return;o(!0);let l=p.getState().appendLocalMarker({acpSessionId:e,content:`${m}${c}`});n(e,c).then(()=>i(``)).catch(t=>{l&&p.getState().removeLocalMarker({acpSessionId:e,markerId:l}),s(t,{context:`AcpRunChatView.steer`})}).finally(()=>o(!1))},[r,a,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:r,onChange:e=>i(e.target.value),placeholder:t(`acpRunChatView.steerPlaceholder`),disabled:a,"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)(c,{type:`submit`,variant:`primary`,size:`compact`,iconOnly:(0,X.jsx)(ie,{}),disabled:a||r.trim()===``,"aria-label":t(`acpRunChatView.sendSteerAria`),className:`shrink-0`})]})})}function Je({entry:e,onClose:t,assistantId:n}){return(0,X.jsx)(Ue,{entry:e,onClose:t,assistantId:n})}export{Je as AcpRunDetailPanel};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$r as t,Tb as n,a as r,c as i,ei as a,hc as o,l as s,s as c,sy as l,ti as u}from"./app-DFXcEvsi.js";import{j as d}from"./vendor-DYOeoIwg.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=l.use.activeAssistantId(),v=t(),y=u(),{data:b}=a(),{starters:x,items:S}=s(v??``),{launch:C,pendingTaskIds:w}=i(v??``),T=(0,g.useMemo)(()=>[...x,...S],[x,S]),E=(0,g.useCallback)(async t=>{c(await C(t),m,t=>{o(e,t)})},[C,e,m]);return v===null?y?(0,_.jsx)(p,{to:n.assistant,replace:!0}):null:(0,_.jsx)(r,{tasks:T,progress:b?.tasks,pendingTaskIds:w,onLaunch:e=>{E(e)},onOpenConversation:t=>{o(e,t)},assistantId:h??void 0})}export{v as ActivationListRoute};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$r as t,Tb as n,a as r,c as i,ei as a,hc as o,l as s,s as c,sy as l,ti as u}from"./app-p4YU9h0P.js";import{j as d}from"./vendor-DYOeoIwg.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=l.use.activeAssistantId(),v=t(),y=u(),{data:b}=a(),{starters:x,items:S}=s(v??``),{launch:C,pendingTaskIds:w}=i(v??``),T=(0,g.useMemo)(()=>[...x,...S],[x,S]),E=(0,g.useCallback)(async t=>{c(await C(t),m,t=>{o(e,t)})},[C,e,m]);return v===null?y?(0,_.jsx)(p,{to:n.assistant,replace:!0}):null:(0,_.jsx)(r,{tasks:T,progress:b?.tasks,pendingTaskIds:w,onLaunch:e=>{E(e)},onOpenConversation:t=>{o(e,t)},assistantId:h??void 0})}export{v as ActivationListRoute};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Tb as t}from"./app-DFXcEvsi.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{Tb as t}from"./app-p4YU9h0P.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{Cc as t,Fn as n,Ht as r,Hx as i,In as a,Io as o,Jn as s,Ln as c,Mn as l,Pn as u,Rt as d,St as f,Ux as p,Vt as m,Zn as h,_t as g,bt as _,fn as v,ft as y,hr as b,ht as x,mt as S,pt as C,vt as w,xr as T,yt as E,zn as D,zt as O}from"./app-DFXcEvsi.js";import{j as k}from"./vendor-DYOeoIwg.js";import{t as A,x as j}from"./react-B9IgSVeK.js";import{Gi as M}from"./icons-QG1KAFmx.js";import{t as N}from"./use-transcript-message-by-id-ZVUnXf5k.js";import{a as P,n as F,t as I}from"./tool-detail-panel-CNNnmtM6.js";var L=e(j(),1);function R(e,t,n){let i=O(t,n.workflow),a=e=>{let t=r(e,n.workflow.byToolUseId);if(t!==null&&i.has(t))return!0;let a=d(e,n.acpByToolUseId);if(a!==null&&n.acpById[a]!==void 0)return!0;let o=m(e);return o!==void 0&&n.backgroundTaskById[o]!==void 0},o=t.filter(e=>!a(e));if(o.length===t.length)return{items:e,toolCalls:t};let s=new Set(o.map(e=>e.id));return{items:e.filter(e=>e.kind!==`toolCall`||s.has(e.toolCall.id)),toolCalls:o}}function z(e,r){let i=N(e),o=v(),s=t.use.byId(),l=t.use.byToolUseId(),u=t.use.notFoundRunIds(),d=t.use.hydrationFailedRunIds(),f=b.use.byId(),p=b.use.byToolUseId(),m=T.use.byId();return(0,L.useMemo)(()=>{if(!i||r==null)return null;let e=a(i.contentBlocks??[],c(i,o))[r];if(!e||e.type!==`activity`)return null;let{cardItems:t,toolCalls:h}=n(e.items);return R(t,h,{workflow:{byId:s,byToolUseId:l,notFoundRunIds:u,hydrationFailedRunIds:d},acpById:f,acpByToolUseId:p,backgroundTaskById:m})},[i,r,o,s,l,u,d,f,p,m])}var B=A(),V=60;function H({payload:e,onClose:t,assistantId:n}){let{t:r}=k(`chat`),[a,o]=(0,L.useState)(null),c=z(e.messageId,e.groupIndex),u=c?.items??e.items,d=c?.toolCalls??e.toolCalls,m=x(u),g=C(m.steps),_=S(m.state,m.steps),v=_===`loading`,b=y(_,m.totalDurationLabel??``,g.failed),w=v&&m.currentStepTitle||b,T=new Map(d.map(e=>[e.id,e]));return(0,B.jsx)(s,{icon:a?(0,B.jsx)(p,{variant:`outlined`,iconOnly:(0,B.jsx)(M,{}),"aria-label":r(`activityStepsPanel.backAria`),tooltip:r(`activityStepsPanel.backTooltip`),onClick:()=>o(null),className:`shrink-0`}):void 0,titleNode:a?a.kind===`thinking`?(0,B.jsx)(i,{variant:`title-medium`,className:`min-w-0 shrink truncate py-0.5 leading-snug text-[var(--content-default)]`,children:r(`activityStepsPanel.thinkingTitle`)}):(0,B.jsx)(F,{detail:a}):(0,B.jsx)(h,{title:v?(0,B.jsx)(l,{children:w}):w,count:m.stepCount}),closeLabel:r(`activityStepsPanel.closeSteps`),onClose:t,children:a?(0,B.jsx)(W,{detail:a,assistantId:n}):(0,B.jsx)(f,{steps:m.steps,timeline:!0,renderStep:t=>(0,B.jsx)(U,{step:t,activeDetail:a,onOpenDetail:o,lookupToolCall:e=>T.get(e),messageId:e.messageId,groupIndex:e.groupIndex})})})}function U({step:e,activeDetail:t,onOpenDetail:n,lookupToolCall:r,messageId:i,groupIndex:a}){let{t:s}=k(`chat`);if(e.kind===`thinking`){let t=i!=null&&e.thinkingItemIndex!=null?{messageId:i,thinkingGroupIndex:a,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,B.jsx)(E,{iconName:`brain`,label:o(D(e.text),V),ariaLabel:s(`activityStepsPanel.viewThinkingAria`),active:!1,onClick:()=>n({kind:`thinking`,toolCallId:``,toolName:``,title:s(`activityStepsPanel.thinkingTitle`),activity:``,input:{},status:`completed`,thinkingText:e.text,...t})})}if(e.kind===`web_search`)return(0,B.jsx)(w,{step:e});if(e.kind===`web_search_error`)return(0,B.jsx)(g,{step:e});if(e.kind!==`tool`)return(0,B.jsx)(_,{step:e});let c=r(e.toolCallId);return(0,B.jsx)(E,{iconName:e.iconName,label:e.activity||e.info||e.title,active:t?.toolCallId===e.toolCallId,onClick:()=>{c&&n(u(c))}})}function W({detail:e,assistantId:t}){return(0,B.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.kind===`thinking`?(0,B.jsx)(P,{detail:e,assistantId:t}):(0,B.jsx)(I,{detail:e,assistantId:t})})}export{H as ActivityStepsPanel};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Cc as t,Fn as n,Ht as r,Hx as i,In as a,Io as o,Jn as s,Ln as c,Mn as l,Pn as u,Rt as d,St as f,Ux as p,Vt as m,Zn as h,_t as g,bt as _,fn as v,ft as y,hr as b,ht as x,mt as S,pt as C,vt as w,xr as T,yt as E,zn as D,zt as O}from"./app-p4YU9h0P.js";import{j as k}from"./vendor-DYOeoIwg.js";import{t as A,x as j}from"./react-B9IgSVeK.js";import{Gi as M}from"./icons-QG1KAFmx.js";import{t as N}from"./use-transcript-message-by-id-diLlPoiw.js";import{a as P,n as F,t as I}from"./tool-detail-panel-BkWuCCm0.js";var L=e(j(),1);function R(e,t,n){let i=O(t,n.workflow),a=e=>{let t=r(e,n.workflow.byToolUseId);if(t!==null&&i.has(t))return!0;let a=d(e,n.acpByToolUseId);if(a!==null&&n.acpById[a]!==void 0)return!0;let o=m(e);return o!==void 0&&n.backgroundTaskById[o]!==void 0},o=t.filter(e=>!a(e));if(o.length===t.length)return{items:e,toolCalls:t};let s=new Set(o.map(e=>e.id));return{items:e.filter(e=>e.kind!==`toolCall`||s.has(e.toolCall.id)),toolCalls:o}}function z(e,r){let i=N(e),o=v(),s=t.use.byId(),l=t.use.byToolUseId(),u=t.use.notFoundRunIds(),d=t.use.hydrationFailedRunIds(),f=b.use.byId(),p=b.use.byToolUseId(),m=T.use.byId();return(0,L.useMemo)(()=>{if(!i||r==null)return null;let e=a(i.contentBlocks??[],c(i,o))[r];if(!e||e.type!==`activity`)return null;let{cardItems:t,toolCalls:h}=n(e.items);return R(t,h,{workflow:{byId:s,byToolUseId:l,notFoundRunIds:u,hydrationFailedRunIds:d},acpById:f,acpByToolUseId:p,backgroundTaskById:m})},[i,r,o,s,l,u,d,f,p,m])}var B=A(),V=60;function H({payload:e,onClose:t,assistantId:n}){let{t:r}=k(`chat`),[a,o]=(0,L.useState)(null),c=z(e.messageId,e.groupIndex),u=c?.items??e.items,d=c?.toolCalls??e.toolCalls,m=x(u),g=C(m.steps),_=S(m.state,m.steps),v=_===`loading`,b=y(_,m.totalDurationLabel??``,g.failed),w=v&&m.currentStepTitle||b,T=new Map(d.map(e=>[e.id,e]));return(0,B.jsx)(s,{icon:a?(0,B.jsx)(p,{variant:`outlined`,iconOnly:(0,B.jsx)(M,{}),"aria-label":r(`activityStepsPanel.backAria`),tooltip:r(`activityStepsPanel.backTooltip`),onClick:()=>o(null),className:`shrink-0`}):void 0,titleNode:a?a.kind===`thinking`?(0,B.jsx)(i,{variant:`title-medium`,className:`min-w-0 shrink truncate py-0.5 leading-snug text-[var(--content-default)]`,children:r(`activityStepsPanel.thinkingTitle`)}):(0,B.jsx)(F,{detail:a}):(0,B.jsx)(h,{title:v?(0,B.jsx)(l,{children:w}):w,count:m.stepCount}),closeLabel:r(`activityStepsPanel.closeSteps`),onClose:t,children:a?(0,B.jsx)(W,{detail:a,assistantId:n}):(0,B.jsx)(f,{steps:m.steps,timeline:!0,renderStep:t=>(0,B.jsx)(U,{step:t,activeDetail:a,onOpenDetail:o,lookupToolCall:e=>T.get(e),messageId:e.messageId,groupIndex:e.groupIndex})})})}function U({step:e,activeDetail:t,onOpenDetail:n,lookupToolCall:r,messageId:i,groupIndex:a}){let{t:s}=k(`chat`);if(e.kind===`thinking`){let t=i!=null&&e.thinkingItemIndex!=null?{messageId:i,thinkingGroupIndex:a,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,B.jsx)(E,{iconName:`brain`,label:o(D(e.text),V),ariaLabel:s(`activityStepsPanel.viewThinkingAria`),active:!1,onClick:()=>n({kind:`thinking`,toolCallId:``,toolName:``,title:s(`activityStepsPanel.thinkingTitle`),activity:``,input:{},status:`completed`,thinkingText:e.text,...t})})}if(e.kind===`web_search`)return(0,B.jsx)(w,{step:e});if(e.kind===`web_search_error`)return(0,B.jsx)(g,{step:e});if(e.kind!==`tool`)return(0,B.jsx)(_,{step:e});let c=r(e.toolCallId);return(0,B.jsx)(E,{iconName:e.iconName,label:e.activity||e.info||e.title,active:t?.toolCallId===e.toolCallId,onClick:()=>{c&&n(u(c))}})}function W({detail:e,assistantId:t}){return(0,B.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.kind===`thinking`?(0,B.jsx)(P,{detail:e,assistantId:t}):(0,B.jsx)(I,{detail:e,assistantId:t})})}export{H as ActivityStepsPanel};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Tb as t,Tu as n,Tx as r,Ux as i,X_ as a,Yl as o,Z_ as s,px as c,ql as l}from"./app-DFXcEvsi.js";import{Jn as u,Zn as d,j as f}from"./vendor-DYOeoIwg.js";import{_ as p,d as m,n as h,t as g,x as _}from"./react-B9IgSVeK.js";import{Hi as v,Wi as y,qn as b}from"./icons-QG1KAFmx.js";import{n as x}from"./android-billing-handoff-BVx_2Qs0.js";import{t as S}from"./checkout-return-target-CrM-Nhda.js";var C=e(_(),1),w=g(),T=[`10.00`,`20.00`,`30.00`,`40.00`,`50.00`,`60.00`,`70.00`,`80.00`,`90.00`,`100.00`];function E(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 D(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 O({open:e,onOpenChange:g}){let{t:_}=f(),{pathname:x}=m(),[O]=p(),k=O.toString()?`${x}?${O.toString()}`:x,{data:A,isLoading:j}=d(l()),M=A?.allowed_top_up_amounts?.length?A.allowed_top_up_amounts:T,[N,P]=(0,C.useState)(null),F=N&&M.includes(N)?N:M[0]??T[0],I=u(o());return(0,C.useEffect)(()=>s(()=>{g(!1)}),[g]),n(`deeplink.billingCheckoutComplete`,({flow:e})=>{e===`top_up`&&g(!1)}),(0,w.jsx)(r.Root,{open:e,onOpenChange:g,children:(0,w.jsxs)(r.Content,{size:`sm`,children:[(0,w.jsxs)(r.Header,{children:[(0,w.jsx)(r.Title,{children:_(`addCreditsModal.title`)}),(0,w.jsx)(r.Description,{children:_(`addCreditsModal.description`)})]}),(0,w.jsx)(r.Body,{children:(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`label`,{htmlFor:`add-credits-amount`,className:`block text-body-small-default text-[var(--content-tertiary)]`,children:_(`addCreditsModal.amount`)}),(0,w.jsx)(c,{id:`add-credits-amount`,value:F,onChange:e=>{P(e),I.isError&&I.reset()},disabled:j||!A,options:M.map(e=>({value:e,label:E(e)}))})]}),I.isError&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,w.jsx)(v,{className:`h-3.5 w-3.5 shrink-0`}),D(I.error)]}),(0,w.jsxs)(h,{to:t.settings.usageBillingConfigureTopUps,className:`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)] hover:text-[var(--content-secondary)]`,onClick:()=>g(!1),children:[_(`addCreditsModal.configureAutoReload`),(0,w.jsx)(y,{className:`size-4`})]}),(0,w.jsx)(`div`,{className:`h-px w-full bg-[var(--border-subtle)]`})]})}),(0,w.jsxs)(r.Footer,{children:[(0,w.jsx)(r.Close,{asChild:!0,children:(0,w.jsx)(i,{variant:`outlined`,children:_(`addCreditsModal.cancel`)})}),(0,w.jsx)(i,{variant:`primary`,leftIcon:I.isPending?(0,w.jsx)(b,{className:`animate-spin`}):void 0,onClick:()=>{I.isPending||I.mutate({body:{amount:F,return_path:k,return_target:S()}},{onSuccess:e=>{a(e.checkout_url)}})},disabled:I.isPending||j||!A,children:_(`addCreditsModal.continue`)})]})]})})}function k(e){return x({open:e.open,path:t.settings.usageBilling,onClose:()=>e.onOpenChange(!1)})?null:(0,w.jsx)(O,{...e})}export{k as t};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Tb as t,Tu as n,Tx as r,Ux as i,X_ as a,Yl as o,Z_ as s,px as c,ql as l}from"./app-p4YU9h0P.js";import{Jn as u,Zn as d,j as f}from"./vendor-DYOeoIwg.js";import{_ as p,d as m,n as h,t as g,x as _}from"./react-B9IgSVeK.js";import{Hi as v,Wi as y,qn as b}from"./icons-QG1KAFmx.js";import{n as x}from"./android-billing-handoff-BxVpZpp4.js";import{t as S}from"./checkout-return-target-B4WZzAGx.js";var C=e(_(),1),w=g(),T=[`10.00`,`20.00`,`30.00`,`40.00`,`50.00`,`60.00`,`70.00`,`80.00`,`90.00`,`100.00`];function E(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 D(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 O({open:e,onOpenChange:g}){let{t:_}=f(),{pathname:x}=m(),[O]=p(),k=O.toString()?`${x}?${O.toString()}`:x,{data:A,isLoading:j}=d(l()),M=A?.allowed_top_up_amounts?.length?A.allowed_top_up_amounts:T,[N,P]=(0,C.useState)(null),F=N&&M.includes(N)?N:M[0]??T[0],I=u(o());return(0,C.useEffect)(()=>s(()=>{g(!1)}),[g]),n(`deeplink.billingCheckoutComplete`,({flow:e})=>{e===`top_up`&&g(!1)}),(0,w.jsx)(r.Root,{open:e,onOpenChange:g,children:(0,w.jsxs)(r.Content,{size:`sm`,children:[(0,w.jsxs)(r.Header,{children:[(0,w.jsx)(r.Title,{children:_(`addCreditsModal.title`)}),(0,w.jsx)(r.Description,{children:_(`addCreditsModal.description`)})]}),(0,w.jsx)(r.Body,{children:(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`label`,{htmlFor:`add-credits-amount`,className:`block text-body-small-default text-[var(--content-tertiary)]`,children:_(`addCreditsModal.amount`)}),(0,w.jsx)(c,{id:`add-credits-amount`,value:F,onChange:e=>{P(e),I.isError&&I.reset()},disabled:j||!A,options:M.map(e=>({value:e,label:E(e)}))})]}),I.isError&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,w.jsx)(v,{className:`h-3.5 w-3.5 shrink-0`}),D(I.error)]}),(0,w.jsxs)(h,{to:t.settings.usageBillingConfigureTopUps,className:`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)] hover:text-[var(--content-secondary)]`,onClick:()=>g(!1),children:[_(`addCreditsModal.configureAutoReload`),(0,w.jsx)(y,{className:`size-4`})]}),(0,w.jsx)(`div`,{className:`h-px w-full bg-[var(--border-subtle)]`})]})}),(0,w.jsxs)(r.Footer,{children:[(0,w.jsx)(r.Close,{asChild:!0,children:(0,w.jsx)(i,{variant:`outlined`,children:_(`addCreditsModal.cancel`)})}),(0,w.jsx)(i,{variant:`primary`,leftIcon:I.isPending?(0,w.jsx)(b,{className:`animate-spin`}):void 0,onClick:()=>{I.isPending||I.mutate({body:{amount:F,return_path:k,return_target:S()}},{onSuccess:e=>{a(e.checkout_url)}})},disabled:I.isPending||j||!A,children:_(`addCreditsModal.continue`)})]})]})})}function k(e){return x({open:e.open,path:t.settings.usageBilling,onClose:()=>e.onOpenChange(!1)})?null:(0,w.jsx)(O,{...e})}export{k as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./add-credits-modal-CAUxaNjZ.js";export{e as AddCreditsModal};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$u as t,$v as n,Ao as r,Bb as i,Bv as a,Bx as o,Cd as s,Cf as c,Co as l,Cx as u,Dd as d,Do as f,Ed as p,Ff as m,Fv as h,Fx as g,G as _,Gb as v,Gv as y,Hv as b,Hx as x,If as S,Iv as C,Ix as w,J as T,Jd as E,Jg as D,Jn as O,Jv as k,K as A,Kv as j,Lv as M,Mx as N,Nv as P,Nx as F,Od as I,Og as L,Oo as R,Pb as z,Pv as B,Qg as ee,Qu as V,Qv as te,Rv as ne,Sf as re,Sx as ie,Td as ae,To as oe,Tx as H,Uv as se,Ux as U,Vf as ce,Vm as le,Vv as ue,W as de,Wb as W,Wt as fe,Wv as pe,Wx as me,X as he,Xd as ge,Xu as _e,Xv as ve,Y as ye,Yd as be,Yf as xe,Yv as Se,Z as Ce,Zg as we,Zu as Te,Zv as Ee,_a as De,_c as Oe,_o as ke,_p as Ae,ai as je,at as Me,ay as Ne,bo as Pe,cp as Fe,cx as Ie,dd as Le,dp as Re,ed as ze,et as Be,ey as Ve,fd as He,fp as Ue,ga as We,gd as Ge,go as Ke,gp as qe,gx as Je,h_ as Ye,hd as Xe,ho as Ze,hp as Qe,ii as $e,it as et,iy as tt,j_ as nt,jo as rt,jx as it,kd as at,ko as ot,lb as st,lp as ct,md as lt,mo as ut,mp as dt,nd as ft,nh as pt,nt as mt,nx as ht,ny as gt,oh as _t,pd as vt,po as yt,pp as bt,px as G,q as xt,qb as K,qd as St,qv as Ct,rd as wt,rh as Tt,ry as Et,sp as Dt,td as Ot,ty as kt,up as At,va as jt,vo as Mt,vp as Nt,vx as q,wd as Pt,wf as Ft,wo as It,xo as Lt,ym as Rt,yo as zt,zg as Bt,zv as Vt}from"./app-DFXcEvsi.js";import{I as J,Jn as Ht,N as Ut,Zn as Y,er as X,j as Z}from"./vendor-DYOeoIwg.js";import{b as Wt,t as Gt,x as Kt}from"./react-B9IgSVeK.js";import{E as qt,Hi as Jt,It as Yt,Jn as Xt,Xr as Zt,_t as Qt,k as $t,qn as en,ur as tn}from"./icons-QG1KAFmx.js";import{t as nn}from"./ellipsis-vertical-Dbz00Lo-.js";import{i as rn,n as an,r as on,t as sn}from"./service-form-controls-C5nQsTzh.js";import{d as cn,o as ln,u as un}from"./schedules-Cslj2E_n.js";import{t as dn}from"./stt-language-picker-modal-Ckz32Oh1.js";var Q=e(Kt(),1);function fn(){let e=Be();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await nt({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});P(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?u.error(J(`settings:useDaemonConfig.assistantNotReadyToast`)):u.error(J(`settings:useDaemonConfig.saveApiKeyFailedToast`,{providerName:t})),z(e,{context:`provision_provider_key`}),e}},[e])}function pn(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 mn=`0.11.0`;function hn(){return pt(mn)}var $=Gt(),gn=`gemini-3.1-flash-image-preview`;function _n(){let{t:e}=Z(`settings`),t=Be(),n=X(),r=Rt(),{data:i}=Y({...s({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),a=ce({onSuccess:e=>{ae(n,{path:{assistant_id:t}},e)}}),o=fn(),[c,d]=pn((0,Q.useMemo)(()=>{if(!i)return W(ut,`gemini`);let e=i.services?.[`image-generation`];return e?.mode===`managed`?`vellum`:e?.provider||W(`vellum:ai:imageGenProvider`,`gemini`)},[i])),[f,p]=(0,Q.useState)(()=>W(yt,gn)),m=R(c),h=m.includes(f)?f:m[0]??gn,[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(!1),b=It.map(e=>({value:e,label:oe[e]??e})),x=(0,Q.useMemo)(()=>R(c).map(e=>({value:e,label:l[e]??e})),[c]),S=c===`gemini`||c===`openai`,{hasStoredCredential:C}=Fe({assistantId:t,credentialKind:`api_key`,credentialName:c,enabled:S}),w=d,T=(0,Q.useCallback)(async()=>{y(!0);let r=g.trim(),i=S&&r.length>0;try{i&&await o(ot(h),r),await _t();let s=c===`vellum`&&!hn()?{mode:`managed`}:{provider:c,mode:c===`vellum`?`managed`:`your-own`};await a.mutateAsync({path:{assistant_id:t},body:{services:{"image-generation":s}}}).catch(t=>{throw u.error(e(`imageGenerationCard.configUpdateFailedToast`)),z(t,{context:`patch_daemon_config`}),t});try{await Ye({path:{assistant_id:t},body:{modelId:h},throwOnError:!0})}catch(t){throw u.error(e(`imageGenerationCard.modelUpdateFailedToast`)),z(t,{context:`set_image_gen_model`}),t}finally{n.invalidateQueries({queryKey:Pt({path:{assistant_id:t}})})}}catch{y(!1);return}y(!1);try{if(K(ut,c),K(yt,h),i){let e=Dt(t,`api_key`,c);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),_(``)}u.success(e(`imageGenerationCard.savedToast`))}catch(t){z(t,{context:`settings-ai-image-gen-persist-local`}),u.error(e(`imageGenerationCard.localPreferencesFailedToast`))}},[g,c,S,h,t,a,o,n,e]),E=(0,Q.useCallback)(()=>{_(``),p(gn),K(yt,gn)},[]);return(0,$.jsx)(rn,{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)(G,{"aria-label":e(`imageGenerationCard.providerAriaLabel`),value:c,onChange:w,options:b})]}),c===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.vellumNote`)}),S&&(0,$.jsx)(F,{label:e(`imageGenerationCard.apiKeyLabel`),type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:vt(e(c===`openai`?`imageGenerationCard.openaiApiKeyPlaceholder`:`imageGenerationCard.geminiApiKeyPlaceholder`),C),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`)}),(0,$.jsx)(G,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:h,onChange:p,options:x})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(on,{onClick:T,disabled:v}),v&&(0,$.jsx)(en,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),S&&(0,$.jsx)(an,{onClick:E})]})]})})}function vn({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)(x,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(x,{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 yn(e){return e.scheduleNames.length>0||e.deferredReminderCount>0||e.scheduleLookupFailed}var bn=5;function xn({title:e,items:t,mono:n}){return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(x,{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 Sn(e){let t=e.label||e.name,n=[];e.isActive&&n.push(J(`settings:manageProfilesBlockedDeleteModal.clauseDefaultProfile`)),e.callSiteIds.length>0&&n.push(J(`settings:manageProfilesBlockedDeleteModal.clauseActionOverrides`,{count:e.callSiteIds.length}));let r=e.scheduleNames.length,i=e.deferredReminderCount;return r>0&&i>0?n.push(J(`settings:manageProfilesBlockedDeleteModal.clauseRunsBoth`,{schedules:r,reminders:i})):r>0?n.push(J(`settings:manageProfilesBlockedDeleteModal.clauseRunsSchedules`,{count:r})):i>0&&n.push(J(`settings:manageProfilesBlockedDeleteModal.clauseRunsReminders`,{count:i})),n.length===0?J(`settings:manageProfilesBlockedDeleteModal.summaryNoReferences`,{display:t}):n.length===1?J(`settings:manageProfilesBlockedDeleteModal.summaryOneClause`,{display:t,clause1:n[0]}):n.length===2?J(`settings:manageProfilesBlockedDeleteModal.summaryTwoClauses`,{display:t,clause1:n[0],clause2:n[1]}):J(`settings:manageProfilesBlockedDeleteModal.summaryThreeClauses`,{display:t,clause1:n[0],clause2:n[1],clause3:n[2]})}function Cn({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let{t:c}=Z(`settings`),l=e?.scheduleNames??[],u=l.slice(0,bn),d=l.length-u.length,f=e!=null&&yn(e);return(0,$.jsx)(H.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(H.Content,{size:`sm`,children:[(0,$.jsx)(H.Header,{children:(0,$.jsx)(H.Title,{children:c(`manageProfilesBlockedDeleteModal.title`)})}),(0,$.jsxs)(H.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(x,{variant:`body-medium-default`,as:`p`,children:Sn(e)}),e&&e.callSiteIds.length>0&&(0,$.jsx)(xn,{title:c(`manageProfilesBlockedDeleteModal.actionOverridesTitle`),items:e.callSiteIds,mono:!0}),u.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(xn,{title:c(`manageProfilesBlockedDeleteModal.schedulesTitle`),items:u}),d>0&&(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.moreSchedules`,{count:d})})]}),e?.scheduleLookupFailed&&(0,$.jsx)(x,{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)(G,{"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:xt(e),disabled:t,tooltip:t?c(`manageProfilesBlockedDeleteModal.disabledTargetTooltip`):void 0}})})]}),i&&(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(H.Footer,{children:[(0,$.jsx)(U,{variant:`ghost`,size:`compact`,onClick:o,children:c(`manageProfilesBlockedDeleteModal.cancel`)}),(0,$.jsx)(U,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:c(a?`manageProfilesBlockedDeleteModal.saving`:`manageProfilesBlockedDeleteModal.reassignAndDelete`)})]})]})})}function wn({profile:e,isActiveProfile:n,selected:r,connections:i,deletePending:a=!1,onOpen:o,onMakeActive:s,onSetStatus:c,onDelete:l}){let{t:u}=Z(`settings`),d=e.source===`managed`,f=e.status===`disabled`,p=e.label??e.name,m=[];e.model&&m.push(t(e.provider??void 0,e.model,i)),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)(ht,{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:r,disabled:a,contentAriaLabel:u(`profileRow.openProfileAriaLabel`,{displayName:p}),trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[y==null?null:(0,$.jsx)(me,{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)(Jt,{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)(Jt,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-label":y,role:`img`})})}),f?(0,$.jsx)(w,{tone:`neutral`,children:u(`profileRow.disabledTag`)}):null,n?(0,$.jsx)(w,{tone:`positive`,children:u(`profileRow.defaultTag`)}):null,(0,$.jsxs)(q.Root,{children:[(0,$.jsx)(q.Trigger,{asChild:!0,children:(0,$.jsx)(U,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(nn,{}),"aria-label":u(`profileRow.actionsAriaLabel`,{displayName:p}),disabled:a})}),(0,$.jsxs)(q.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(q.Item,{onSelect:o,children:u(d?`profileRow.view`:`profileRow.edit`)}),!n&&!f?(0,$.jsx)(q.Item,{onSelect:s,children:u(`profileRow.makeDefault`)}):null,f?(0,$.jsx)(q.Item,{onSelect:()=>c(!0),children:u(`profileRow.enable`)}):d?null:(0,$.jsx)(q.Item,{onSelect:()=>c(!1),children:u(`profileRow.disable`)}),d?null:(0,$.jsx)(q.Item,{onSelect:l,className:Je.anchored,children:u(`profileRow.delete`)})]})]})]})})}function Tn(e,t){let n=$e(),{data:r}=Y({...St({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=de(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:B(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 En=`0.10.8`;function Dn(e){return Tt(En,e)}var On=`settings-ai-profile-make-active`,kn=`Failed to set the active profile. Please try again.`;function An(e){let t=Te(),n=X(),r=Dn(e),a=xe({onSuccess:()=>{n.invalidateQueries({queryKey:Pt({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:E({path:{assistant_id:e}})})}});async function o(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw z(e,{context:r}),u.error(i),e}}async function s(t){if(!r){await o({activeProfile:t},On,kn);return}try{await a.mutateAsync({path:{assistant_id:e},body:{name:t}})}catch(e){let t=i(e);throw u.error(t??kn),t||z(e,{context:On}),e}}return{makeActive:s,setStatus:(e,t)=>o({profiles:{[e]:{status:t?`active`:`disabled`}}},`settings-ai-profile-toggle`,`Failed to update the profile. Please try again.`),deleteProfile:(e,t,n)=>o({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:o,isPending:t.isPending||a.isPending}}var jn=`The profile was not deleted.`,Mn=`Failed to move the schedules. ${jn}`;function Nn(e){let t=i(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${jn}`:Mn}function Pn(e,t,n){let r=An(e),i=X(),a=Ce(),o=t?.llm?.activeProfile??null,s=t?.llm?.advisorProfile??null,l=t?.llm?.callSites??{},u=(0,Q.useMemo)(()=>t?.llm?.profiles??{},[t?.llm?.profiles]),d=(0,Q.useMemo)(()=>t?.llm?.profileOrder??[],[t?.llm?.profileOrder]),f=(0,Q.useMemo)(()=>B(u,d),[u,d]),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),w=(0,Q.useRef)(!1);function T(e){return f.filter(t=>t.name===e?!1:t.status===`disabled`?!0:_(t,f,{requireOwnProviderAndModel:a}))}function E(e,t){let n=T(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 D(e){try{await r.deleteProfile(e,d,{isAdvisor:e===s}),n?.onDeleted?.(e)}catch{}}async function O(t){let n=u[t]?.label??t,r=t===o,a=Object.entries(l).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),s=[],c=0,d=!1;try{let n=(await i.fetchQuery({...re({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),c=n.filter(e=>e.isDeferred).length}catch(e){z(e,{context:`settings-ai-profile-delete-schedule-scan`}),d=!0}if(!(r||a.length>0||s.length>0||c>0)&&!d){await D(t);return}let f={name:t,label:n,isActive:r,callSiteIds:a,scheduleNames:s,deferredReminderCount:c,scheduleLookupFailed:d};m(f),y(E(t,yn(f))),g(null)}function k(e){t==null||w.current||(w.current=!0,C(e),O(e).finally(()=>{w.current=!1,C(null)}))}async function A(){if(!p||!v)return;if(x(!0),g(null),yn(p))try{await ln(e,p.name,v),await i.invalidateQueries({queryKey:c({path:{assistant_id:e}})})}catch(e){z(e,{context:`settings-ai-profile-reassign-schedules`}),g(Nn(e)),x(!1);return}let t={};if(p.isActive&&(t.activeProfile=v),p.callSiteIds.length>0){let e={};for(let t of p.callSiteIds)e[t]={profile:v};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{g(`Failed to reassign references. Please try again.`),x(!1);return}let n=p.name;m(null),x(!1),D(n)}return{requestDelete:k,pendingDeleteName:S,blockedDeleteModalProps:{blocked:p,availableReplacements:T(p?.name??null),replacement:v,onReplacementChange:y,error:h,saving:b,onClose:()=>{m(null),g(null)},onConfirm:()=>void A()}}}function Fn(){}function In({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{t:s}=Z(`settings`),{entries:c}=Tn(e,t),l=An(e),u=Pn(e,t,{onDeleted:o}),d=t?.llm?.activeProfile??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{title:s(`profilesSection.title`),action:(0,$.jsx)(U,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(Yt,{}),disabled:t==null,children:s(`profilesSection.createProfile`)}),children:t==null?(0,$.jsx)(x,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.loading`)}):c.length===0?(0,$.jsx)(x,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.emptyState`)}):c.map(e=>(0,$.jsx)(wn,{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(Fn),onSetStatus:t=>void l.setStatus(e.name,t).catch(Fn),onDelete:()=>u.requestDelete(e.name)},e.name))}),(0,$.jsx)(Cn,{...u.blockedDeleteModalProps})]})}var Ln={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 Rn(e){return e in Ln}function zn(e){if(!e.baseUrl)return null;try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function Bn(e){let t=zn(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 Vn(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 Hn(e){if(e.provider===`vellum`)return`Included with your plan`;if(e.provider===`openai-compatible`)return Bn(e);let t=[];if(e.provider===`ollama`||e.provider===`opencode`){let n=zn(e);n&&t.push(n)}let n=e.provider===`chatgpt`?`openai`:e.provider,r=e.auth.type===`oauth_subscription`?Ot(n):tt(n),i=e.models?.length??r.length;i>0&&t.push(`${i} ${i===1?`model`:`models`}`);let a=Vn(e);return a&&t.push(a),t.join(` • `)}function Un({connection:e,isDefault:t,supportsDefaultProvider:n,selected:r,isSettingDefault:i,onOpen:a,onSetDefault:o,onDelete:s}){let{t:c}=Z(`settings`),l=e.isManaged??!1,u=Qe(e),d=Rn(e.provider),f=Hn(e),p=n&&!t&&d,m=!l&&a!=null,h=!l&&!t,g=p||m||h;return(0,$.jsx)(ht,{title:u,subtitle:f.length>0?f:void 0,onClick:a,showChevron:!1,selected:r,contentAriaLabel:a?c(`providerRow.openProviderAriaLabel`,{displayName:u}):void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[l?(0,$.jsx)(w,{tone:`neutral`,title:c(`providerRow.managedTagTitle`),children:c(`providerRow.managedTag`)}):null,t?(0,$.jsx)(w,{tone:`info`,title:c(`providerRow.defaultTagTitle`),children:c(`providerRow.defaultTag`)}):null,e.provider===`ollama`?(0,$.jsx)(w,{tone:`neutral`,title:c(`providerRow.localTagTitle`),children:c(`providerRow.localTag`)}):null,e.provider===`openai-compatible`?(0,$.jsx)(w,{tone:`neutral`,title:c(`providerRow.customTagTitle`),children:c(`providerRow.customTag`)}):null,g?(0,$.jsxs)(q.Root,{children:[(0,$.jsx)(q.Trigger,{asChild:!0,children:(0,$.jsx)(U,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(nn,{}),"aria-label":c(`providerRow.actionsAriaLabel`,{displayName:u})})}),(0,$.jsxs)(q.Content,{align:`end`,sideOffset:4,children:[m?(0,$.jsx)(q.Item,{onSelect:a,children:c(`providerRow.edit`)}):null,p?(0,$.jsx)(q.Item,{disabled:i,onSelect:o,children:c(`providerRow.setAsDefault`)}):null,h?(0,$.jsx)(q.Item,{onSelect:s,className:Je.anchored,children:c(`providerRow.delete`)}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function Wn(e,t){let n=X(),r={path:{assistant_id:e}},i=Ht({...at(),onSuccess:()=>{n.invalidateQueries({queryKey:I(r)}),n.invalidateQueries({queryKey:Pt(r)}),n.invalidateQueries({queryKey:E(r)})},onError:e=>{z(e,{context:`settings-ai-set-default-provider`}),u.error(J(`settings:useProviderActions.setDefaultFailedToast`))}});function a(t){Rn(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 we({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:ge(r)}),t?.onDeleted?.(i)):a?.status===409?u.error(J(`settings:useProviderActions.deleteInUseToast`)):u.error(J(`settings:useProviderActions.deleteFailedToast`))}catch(e){z(e,{context:`settings-ai-provider-delete`}),u.error(J(`settings:useProviderActions.deleteFailedToast`))}}return{setDefault:a,isSettingDefault:o,deleteConnection:s}}function Gn({assistantId:e,selectedConnectionName:t,onOpenConnection:r,onAddProvider:i,onConnectionDeleted:a}){let{t:o}=Z(`settings`),{data:s,isLoading:c,isError:l}=Y(be({path:{assistant_id:e}})),u=je(),{data:f}=Y({...d({path:{assistant_id:e}}),enabled:u}),p=u?f?.resolvedConnectionName??null:null,m=Wn(e,{onDeleted:a}),h=(0,Q.useMemo)(()=>{let e=s?.connections??[];return[...e.filter(e=>e.provider===n),...e.filter(e=>e.provider!==n)]},[s]);return(0,$.jsx)(vn,{title:o(`providersSection.title`),action:(0,$.jsx)(U,{variant:`outlined`,onClick:i,leftIcon:(0,$.jsx)(Yt,{}),children:o(`providersSection.addProvider`)}),children:c?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(Ie,{className:`h-10 rounded-lg`},e))}):l?(0,$.jsx)(x,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:o(`providersSection.loadError`)}):h.length===0?(0,$.jsx)(x,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:o(`providersSection.empty`)}):h.map(e=>(0,$.jsx)(Un,{connection:e,isDefault:e.name===p,supportsDefaultProvider:u,selected:e.name===t,isSettingDefault:m.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>r(e.name),onSetDefault:()=>m.setDefault(e),onDelete:()=>void m.deleteConnection(e.name)},e.name))})}function Kn({panel:e,onOpenPanel:t,onClosePanel:n}){let{t:r}=Z(`settings`),i=Be(),{data:a}=Y({...s({path:{assistant_id:i}}),staleTime:3e4}),c=je(),{data:l}=Y({...d({path:{assistant_id:i}}),enabled:c}),u=l?.availability,{data:f}=Y({...be({path:{assistant_id:i}})}),p=f?.connections,m=a?.llm?.callSites??{},h=Object.entries(m).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length;return(0,$.jsx)(rn,{title:r(`languageModelCard.title`),subtitle:r(`languageModelCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[u&&u.status!==`ok`&&(0,$.jsx)(o,{tone:u.status===`unknown`?`warning`:`error`,children:u.message??r(`languageModelCard.defaultProviderUnavailable`)}),i&&(0,$.jsx)(In,{assistantId:i,config:a,connections:p,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)(Gn,{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)(vn,{title:r(`languageModelCard.overridesTitle`),count:h,action:(0,$.jsx)(U,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:r(`languageModelCard.manage`)})})]})})}function qn({children:e}){return(0,$.jsxs)(`a`,{href:`https://www.vellum.ai/docs/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--primary-base)] hover:underline`,children:[e,(0,$.jsx)(Zt,{className:`h-3.5 w-3.5`})]})}function Jn(){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)(tn,{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)(Ut,{i18nKey:`managedServicesBanner.body`,ns:`common`,components:{link:(0,$.jsx)(qn,{})}})})]})}function Yn({assistantId:e,profileName:t,onClose:n}){let{t:r}=Z(`settings`),{data:i}=Y({...s({path:{assistant_id:e}}),staleTime:3e4}),{data:a}=Y({...be({path:{assistant_id:e}})}),o=a?.connections,c=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),l=Object.keys(c),u=(0,Q.useMemo)(()=>{if(t==null)return;let e=c[t];return e?{name:t,...e}:void 0},[t,c]),d=t==null?`create`:u?.source===`managed`||u?.invariant===!0?`view`:`edit`,{saveProfile:f,isPending:p}=_e(e,{onSaved:n}),m=V({mode:d,profileName:t??void 0,initialValues:u,existingNames:l,connections:o,assistantId:e,onSave:f}),h=Pn(e,i,{onDeleted:()=>n()}),g=t!=null&&h.pendingDeleteName===t,_=t!=null&&i!=null&&!(t in c);(0,Q.useEffect)(()=>{_&&!m.saving&&!p&&n()},[_,m.saving,p,n]);let v=d===`view`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{title:m.effectiveMode===`create`?r(`profileDetailPanel.createTitle`):u?.label??t??r(`profileDetailPanel.defaultTitle`),closeVariant:`outlined`,onClose:n,headerTrailing:v&&m.effectiveMode!==`create`?(0,$.jsx)(w,{tone:`neutral`,children:r(`profileDetailPanel.managedTag`)}):null,headerActions:m.effectiveMode!==`create`&&!m.isReadOnly?(0,$.jsx)(U,{variant:`dangerOutline`,iconOnly:g?(0,$.jsx)(en,{className:`animate-spin`}):(0,$.jsx)($t,{}),"aria-label":r(g?`profileDetailPanel.deleting`:`profileDetailPanel.delete`),tooltip:r(`profileDetailPanel.delete`),onClick:()=>{t!=null&&h.requestDelete(t)},disabled:m.saving||g}):null,footer:m.isReadOnly?(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(U,{variant:`outlined`,onClick:m.switchToSaveAsNew,disabled:m.saving,children:r(`profileDetailPanel.saveAsNew`)}),m.hasViewModeChanges?(0,$.jsx)(U,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.saving,children:m.saving?r(`profileDetailPanel.saving`):r(`profileDetailPanel.save`)}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(U,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.isInvalid||m.saving,children:m.saving?r(`profileDetailPanel.saving`):m.effectiveMode===`create`?r(`profileDetailPanel.create`):r(`profileDetailPanel.saveChanges`)})}),children:(0,$.jsx)(ze,{editor:m,assistantId:e,connections:o,variant:`panel`})}),(0,$.jsx)(Cn,{...h.blockedDeleteModalProps})]})}function Xn({value:e,profileOptions:t,disabled:n,onChange:r}){let{t:i}=Z(`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)(G,{value:e,onChange:r,options:t,placeholder:i(`advisorProfileRow.chooseProfilePlaceholder`),className:`w-44`,menuMinWidth:280,menuAlign:`start`,disabled:n})]})})}var Zn=`__custom__`;function Qn(e){return e?!!(e.profile||e.provider||e.model):!1}function $n(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 er(e,t){let n=Qn(e);return n===Qn(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function tr({assistantId:e,callSites:t,domains:n,persistedOverrides:r,orderedProfiles:a,onClose:s,onApplied:c}){let{t:l}=Z(`settings`),d=Te(),f=Ce(),p=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:f}),[f]),m=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t){let t=$n(n,r[n.id]);t&&e.set(n.id,t)}return e},[t,r]),h=(0,Q.useMemo)(()=>{let e=new Set(Array.from(m.values(),e=>e.profile));return a.filter(t=>e.has(t.name))},[a,m]),[g,_]=(0,Q.useState)(()=>h[0]?.name??``),[v,y]=(0,Q.useState)(``),[b,S]=(0,Q.useState)(new Set),[C,w]=(0,Q.useState)(!1),T=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[n]),E=(0,Q.useMemo)(()=>t.filter(e=>m.get(e.id)?.profile===g),[t,m,g]),D=(0,Q.useMemo)(()=>E.map(e=>e.id).filter(e=>!b.has(e)),[E,b]),O=(0,Q.useMemo)(()=>h.map(e=>({value:e.name,label:xt(e)})),[h]),k=(0,Q.useMemo)(()=>he(a,[],p).filter(e=>e.name!==g).map(e=>({value:e.name,label:xt(e)})),[a,g,p]),A=M(a,g),j=M(a,v),N=b.size===0;function P(e){_(e),S(new Set),e===v&&y(``)}function F(e,t){S(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function I(){if(!(!g||!v||D.length===0)){w(!0);try{let t={};for(let e of D)t[e]={profile:v};await d.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),u.success(l(`bulkOverrideSwapModal.successToast`,{count:D.length,targetLabel:j})),c(),s()}catch(e){let t=i(e);u.error(t??l(`bulkOverrideSwapModal.updateFailedToast`)),t||z(e,{context:`settings-ai-bulk-override-swap`})}finally{w(!1)}}}return(0,$.jsx)(H.Root,{open:!0,onOpenChange:e=>{e||s()},children:(0,$.jsxs)(H.Content,{size:`md`,children:[(0,$.jsx)(H.Header,{children:(0,$.jsx)(H.Title,{children:l(`bulkOverrideSwapModal.title`)})}),(0,$.jsxs)(H.Body,{className:`space-y-4`,children:[(0,$.jsx)(x,{variant:`body-medium-default`,as:`p`,children:l(`bulkOverrideSwapModal.intro`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(G,{id:`bulk-swap-source`,label:l(`bulkOverrideSwapModal.currentlyUsingLabel`),value:g,onChange:P,options:O}),(0,$.jsx)(G,{id:`bulk-swap-target`,label:l(`bulkOverrideSwapModal.changeToLabel`),value:v,onChange:y,options:k,placeholder:l(`bulkOverrideSwapModal.targetPlaceholder`)})]}),(0,$.jsx)(o,{tone:`info`,title:l(`bulkOverrideSwapModal.noticeTitle`),children:l(`bulkOverrideSwapModal.noticeBody`,{sourceLabel:A})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(x,{variant:`body-medium-default`,as:`p`,children:l(`bulkOverrideSwapModal.affectedSummary`,{count:E.length,profile:A})}),(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:l(`bulkOverrideSwapModal.chooseActions`)})]}),(0,$.jsx)(U,{variant:`ghost`,onClick:()=>S(N?new Set(E.map(e=>e.id)):new Set),children:l(N?`bulkOverrideSwapModal.clearAll`:`bulkOverrideSwapModal.selectAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:E.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)(it,{checked:!b.has(e.id),onCheckedChange:t=>F(e.id,t===!0),disabled:C,label:e.displayName,helperText:T(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:m.get(e.id)?.via===`override`?l(`bulkOverrideSwapModal.viaOverride`):l(`bulkOverrideSwapModal.viaDefault`)})]},e.id))})]})]}),(0,$.jsxs)(H.Footer,{children:[(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:l(`bulkOverrideSwapModal.willChange`,{count:D.length})}),(0,$.jsx)(U,{variant:`ghost`,onClick:s,disabled:C,children:l(`bulkOverrideSwapModal.cancel`)}),(0,$.jsx)(U,{variant:`primary`,disabled:!g||!v||D.length===0||C,onClick:()=>void I(),children:C?(0,$.jsx)(en,{className:`h-4 w-4 animate-spin`}):l(`bulkOverrideSwapModal.applyTo`,{count:D.length})})]})]})})}function nr({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,connections:o,onDraftChange:s,onToggle:c}){let{t:l}=Z(`settings`),u=gt({hostedInference:wt.use.vellumHostedInference()}),d=Qn(i),f=!i||!d?``:i.provider||i.model?Zn:i.profile??``,p=f===Zn,m=Re(),h=ct(),g=(o??[]).some(e=>e.provider===Ee),_=[...te,...g?[Ee]:[]],v=m[0]??te[0],y=i?.provider,b=Ve(y)?y:y===`chatgpt`?Ee:void 0,x=b!==void 0&&_.some(e=>e===b),S=b??v,C=ft(S,``,(o??[]).filter(e=>At(e.provider,S)))?Ot(S):Ne(S,u),w=C.map(e=>({value:e.id,label:e.displayName})),T=typeof i?.model==`string`?i.model:``;if(T&&!C.some(e=>e.id===T)){let e=tt(S).find(e=>e.id===T)?.displayName??T;w.push({value:T,label:l(`callSiteOverridesRow.unavailableOption`,{name:e})})}let E=!!i?.provider&&!i?.model,D=[..._.map(e=>({value:e,label:kt[e]??e,...h(e)})),...b&&!x?[{value:b,label:l(`callSiteOverridesRow.unavailableOption`,{name:kt[b]??b})}]:[]];function O(t){t===`__custom__`?s(e,{profile:null,provider:v,model:Et(v)??``}):t===``?s(e,null):s(e,{profile:t,provider:null,model:null})}function k(t){let n=Et(t)??``;s(e,{...i??{},profile:null,provider:t,model:n})}function A(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:l(`callSiteOverridesRow.defaultProfileSuffix`,{label:r})})]})]}),(0,$.jsx)(N,{checked:d,onChange:t=>c(e,t),"aria-label":l(`callSiteOverridesRow.overrideAriaLabel`,{displayName:t}),className:`shrink-0`})]}),d&&(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(G,{value:f,onChange:O,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`start`})}),d&&p&&(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:l(`callSiteOverridesRow.providerLabel`)}),(0,$.jsx)(G,{value:S??``,onChange:k,options:D})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:l(`callSiteOverridesRow.modelLabel`)}),(0,$.jsx)(G,{value:i?.model??``,onChange:A,options:w})]})]}),E&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:l(`callSiteOverridesRow.pickModelError`)})]})]})}function rr({groups:e,drafts:t,buildProfileOptionsForRow:n,profileLabelFor:r,advisorMatchesSearch:i,connections:a,onDraftChange:o,onToggle:s}){let{t:c}=Z(`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)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>{let i=(()=>{let n=t[e.id]??null;return!n||!Qn(n)?``:n.provider||n.model?Zn:n.profile??``})(),c=e.shippedDefaultProfile??e.defaultProfile,l=c?r(c):null;return(0,$.jsx)(nr,{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 ir(e,t){let n={};for(let r of Object.keys(e)){let i=e[r]??null;Qn(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 ar(e){let t={};for(let n of Object.keys(e))t[n]=null;return t}function or({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(!er(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=>Qn(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)(()=>ir(c,i),[c,i]),buildResetPatch:(0,Q.useCallback)(()=>ar(c),[c])}}function sr({assistantId:e,onClose:t}){let{t:n}=Z(`settings`),{data:r}=Y({...s({path:{assistant_id:e}}),staleTime:3e4}),i=(0,Q.useMemo)(()=>r?.llm?.profiles??{},[r?.llm?.profiles]),a=(0,Q.useMemo)(()=>r?.llm?.profileOrder??[],[r?.llm?.profileOrder]),o=(0,Q.useMemo)(()=>r?.llm?.callSites??{},[r?.llm?.callSites]),c=(0,Q.useMemo)(()=>B(i,a),[i,a]),l=Re(),d=Ce(),f=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:d}),[d]),m=Te(),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),{data:C,isLoading:w,isError:E,refetch:D}=Y({...p({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),{data:k}=Y({...be({path:{assistant_id:e}}),enabled:!!e}),j=(0,Q.useMemo)(()=>(C?.callSites??[]).filter(e=>e.id!==`mainAgent`),[C]),N=!w&&!E&&!!C,P=!!r,I=N&&P,L=(0,Q.useMemo)(()=>j.map(e=>e.id),[j]),R=r?.llm?.advisorProfile??``,{drafts:ee,advisorProfile:V,advisorDirty:ne,callSiteDraftsDirty:re,hasUnsavedDrafts:ae,hasValidationError:oe,setDraft:H,setAdvisor:se,clearEdits:ce,buildSavePatch:le,buildResetPatch:ue}=or({catalogCallSiteIds:L,persistedOverrides:o,persistedAdvisor:R,isSeeded:I}),de=(0,Q.useMemo)(()=>new Set(L),[L]),W=(0,Q.useCallback)(e=>M(c,e),[c]),fe=(0,Q.useCallback)(e=>({value:e.name,label:xt(e),...A(e,c,f)===`undispatchable`?{icon:(0,$.jsx)(Jt,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:ye(e)}:{}}),[c,f]),pe=(0,Q.useMemo)(()=>he(c,[R],f).map(fe),[c,R,fe,f]),me=(0,Q.useMemo)(()=>{let e=h.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[h]),ge=(0,Q.useMemo)(()=>j.some(e=>$n(e,o[e.id])!==null),[j,o]),_e=(0,Q.useMemo)(()=>Object.entries(o).some(([e,t])=>de.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[o,de]),ve=(0,Q.useCallback)(e=>[...he(c,[e],f).map(fe),{value:Zn,label:n(`overridesDetailPanel.customProfileOption`)}],[c,fe,f,n]),xe=(0,Q.useMemo)(()=>{if(!h.trim())return j;let e=h.toLowerCase();return j.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[j,h]),Se=(0,Q.useMemo)(()=>{if(!C)return[];let e=C.domains.map(e=>e.id),t=new Map(C.domains.map(e=>[e.id,e])),r=[];for(let n of e){let e=xe.filter(e=>e.domain===n);e.length>0&&r.push({domain:t.get(n),sites:e})}let i=new Set(e),a=xe.filter(e=>!i.has(e.domain));return a.length>0&&r.push({domain:{id:`other`,displayName:n(`overridesDetailPanel.otherDomain`)},sites:a}),r},[C,xe,n]),we=(0,Q.useCallback)((e,t)=>{if(!t){H(e,null);return}let n=T(c,j.find(t=>t.id===e)?.defaultProfile,f);if(n)H(e,{profile:n});else{let t=l[0]??te[0];H(e,{provider:t,model:Et(t)??``})}},[j,c,l,H,f]),Ee=(0,Q.useCallback)(async()=>{v(!0);try{let r=le();await m.mutateAsync({path:{assistant_id:e},body:{llm:{...re?{callSites:r}:{},...ne?{advisorProfile:V}:{}}}}),t(),u.success(n(`overridesDetailPanel.overridesSavedToast`))}catch(e){u.error(n(`overridesDetailPanel.saveFailedToast`)),z(e,{context:`call_site_overrides_save`})}finally{v(!1)}},[le,re,ne,V,t,m,e,n]),De=(0,Q.useCallback)(async()=>{v(!0);try{let r=ue();await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:r}}}),t(),u.success(n(`overridesDetailPanel.overridesResetToast`))}catch(e){u.error(n(`overridesDetailPanel.resetFailedToast`)),z(e,{context:`call_site_overrides_reset`})}finally{v(!1)}},[ue,t,m,e,n]),Oe=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[_e&&(0,$.jsx)(U,{variant:`outlined`,onClick:()=>b(!0),disabled:_||!I,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:n(`overridesDetailPanel.resetToDefaults`)}),(0,$.jsx)(U,{variant:`primary`,onClick:()=>void Ee(),disabled:!ae||oe||_,children:_?(0,$.jsx)(en,{className:`h-4 w-4 animate-spin`}):n(`overridesDetailPanel.save`)})]});return(0,$.jsxs)(O,{title:n(`overridesDetailPanel.title`),closeVariant:`outlined`,onClose:t,footer:Oe,children:[(0,$.jsx)(`p`,{className:`mb-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`overridesDetailPanel.description`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(F,{type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:n(`overridesDetailPanel.searchPlaceholder`),leftIcon:(0,$.jsx)(Qt,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(U,{variant:`outlined`,onClick:()=>S(!0),disabled:!I||_||ae||!ge,title:ae?n(`overridesDetailPanel.bulkChangeUnsavedTitle`):ge?void 0:n(`overridesDetailPanel.bulkChangeNoCandidatesTitle`),children:n(`overridesDetailPanel.bulkChange`)})]}),P&&me&&(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:n(`overridesDetailPanel.advisorSection`)}),(0,$.jsx)(Xn,{value:V,profileOptions:pe,disabled:_,onChange:se})]}),w&&(0,$.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,$.jsx)(en,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),E&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:n(`overridesDetailPanel.loadErrorTitle`)}),(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`overridesDetailPanel.loadErrorHint`)}),(0,$.jsx)(U,{variant:`outlined`,onClick:()=>void D(),children:n(`overridesDetailPanel.retry`)})]}),!w&&!E&&C&&(0,$.jsx)(rr,{groups:Se,drafts:ee,buildProfileOptionsForRow:ve,profileLabelFor:W,advisorMatchesSearch:me,connections:k?.connections,onDraftChange:H,onToggle:we})]}),x&&C&&(0,$.jsx)(tr,{assistantId:e,callSites:j,domains:C.domains,persistedOverrides:o,orderedProfiles:c,onClose:()=>S(!1),onApplied:ce}),(0,$.jsx)(ie,{open:y,title:n(`overridesDetailPanel.resetToDefaults`),message:n(`overridesDetailPanel.resetConfirmMessage`),confirmLabel:n(`overridesDetailPanel.resetToDefaults`),destructive:!0,onConfirm:()=>{b(!1),De()},onCancel:()=>b(!1)})]})}var cr=e(Wt(),1);function lr({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,variant:a=`modal`,actionsSlot:o,onSave:s,onCancel:c}){let{t:l}=Z(`settings`),[u,d]=(0,Q.useState)(t?.label??``),f=t?.name??``,p=t?.provider??`anthropic`,m=t?.auth.type??`api_key`,[h,g]=(0,Q.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[_,v]=(0,Q.useState)(t?.baseUrl??``),[y,b]=(0,Q.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),E=p===`openai-compatible`,D=dt(p),O=qe(p),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),N=X(),P=(0,Q.useMemo)(()=>bt(h),[h]),I=m===`api_key`&&P!==null,{hasStoredCredential:R,isLoading:z}=Fe({assistantId:n,credentialKind:`credential`,credentialName:P?`${P.service}:${P.field}`:``,enabled:I}),{credentials:B}=He({assistantId:n,enabled:m===`api_key`});(0,Q.useEffect)(()=>{let e=t?.provider??`anthropic`;d(t?.label??``),t?.auth.type===`api_key`?g(t.auth.credential):g(t?``:`credential/${e}/api_key`),T(null),v(t?.baseUrl??``),b(t?.models?t.models.map(e=>e.id).join(`, `):``),A(``),M(!1)},[t]);let V=u.trim()!==(t?.label??``).trim(),te=E&&V?Ge(u,i,t?.name):null,ne=f.trim().length>0&&te===null;async function re(){if(ne){C(!0),T(null);try{let e;if(m===`api_key`){let t=h.trim()||`credential/${p}/api_key`,r=k.trim();if(r){M(!0);try{let e=bt(t);await nt({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:p,value:r},throwOnError:!0});let i=Dt(n,`credential`,e?`${e.service}:${e.field}`:``);N.setQueryData(i,!0),N.invalidateQueries({queryKey:Ft({path:{assistant_id:n}})})}catch{T(l(`providerEditorContent.failedSaveApiKey`));return}finally{M(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{T(l(`providerEditorContent.nothingToEdit`));return}let r=u.trim()||null,i={auth:e,label:r,...D&&{base_url:_.trim()||null},...O&&{models:y.trim()?y.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:a,error:o,response:c}=await ee({path:{assistant_id:n,name:t?.name??f.trim()},body:i});if(!c?.ok){T(Ae(c?.status,o)??Ue(c?.status));return}if(!a){T(l(`providerEditorContent.emptyServerResponse`));return}Nt(a,l),s(a)}catch{T(l(`providerEditorContent.failedSaveProvider`))}finally{C(!1)}}}let ie=B.filter(e=>e.service===p),ae=e!==`create`&&t?.auth.type===`api_key`,oe=ie.length>0||ae,se=vt(l(`providerEditorContent.apiKeyPlaceholder`),R);if(e===`create`)return(0,$.jsx)(Le,{variant:a===`panel`?`inline`:`modal`,actionsSlot:o,assistantId:n,existingNames:r,connections:i,defaultProviderType:p,onCreated:s,onCancel:c});let ce=(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)(Ut,{i18nKey:`providerEditorContent.displayNameLabel`,ns:`settings`,components:{optional:(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`})}})}),(0,$.jsx)(F,{value:u,onChange:e=>d(e.target.value),placeholder:l(`providerEditorContent.displayNamePlaceholder`),fullWidth:!0}),te?(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:Xe[te]}):null]}),D&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlLabel`)}),(0,$.jsx)(F,{value:_,onChange:e=>v(e.target.value),placeholder:l(p===`ollama`?`providerEditorContent.baseUrlPlaceholderOllama`:p===`opencode`?`providerEditorContent.baseUrlPlaceholderOpencode`:`providerEditorContent.baseUrlPlaceholder`),fullWidth:!0}),p===`ollama`?(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlHintOllama`)}):null,p===`opencode`?(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlHintOpencode`)}):null]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`providerEditorContent.modelsLabel`)}),(0,$.jsx)(F,{value:y,onChange:e=>b(e.target.value),placeholder:l(`providerEditorContent.modelsPlaceholder`),fullWidth:!0}),(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.modelsHint`)})]}),m===`api_key`&&(0,$.jsx)(lt,{apiKeyValue:k,onApiKeyChange:A,credential:h,onCredentialChange:g,isLoadingCredential:z,apiKeyPlaceholder:se,provider:p,providerCredentials:ie,showAdvancedSection:oe,onError:T}),m===`oauth_subscription`&&(0,$.jsx)(L,{assistantId:n,onConnected:s}),w&&(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:w})]}),le=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{variant:`ghost`,onClick:c,children:l(`providerEditorContent.cancel`)}),(0,$.jsx)(U,{variant:`primary`,disabled:!ne||S||j,onClick:()=>void re(),children:l(S?`providerEditorContent.saving`:`providerEditorContent.saveChanges`)})]});return a===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ce,o===void 0?(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:le}):o&&(0,cr.createPortal)(le,o)]}):(0,$.jsxs)(H.Content,{size:`md`,children:[(0,$.jsxs)(H.Header,{children:[(0,$.jsx)(H.Title,{children:l(`providerEditorContent.editProviderTitle`)}),(0,$.jsx)(H.Description,{children:t?l(`providerEditorContent.editingConnection`,{name:Qe(t)}):l(`providerEditorContent.editProviderSettingsFallback`)})]}),(0,$.jsx)(H.Body,{children:ce}),(0,$.jsx)(H.Footer,{children:le})]})}function ur({assistantId:e,connectionName:t,onClose:n}){let{t:r}=Z(`settings`),i=X(),[a,o]=(0,Q.useState)(null),{data:s}=Y(be({path:{assistant_id:e}})),c=(0,Q.useMemo)(()=>s?.connections??[],[s]),l=(0,Q.useMemo)(()=>t==null?void 0:c.find(e=>e.name===t),[t,c]),u=t!=null&&s!=null&&l==null;(0,Q.useEffect)(()=>{u&&n()},[u,n]);function d(){i.invalidateQueries({queryKey:ge({path:{assistant_id:e}})}),i.invalidateQueries({queryKey:I({path:{assistant_id:e}})}),n()}return(0,$.jsx)(O,{title:l?Qe(l):r(`providerDetailPanel.addProviderTitle`),closeVariant:`outlined`,onClose:n,footer:(0,$.jsx)(`div`,{ref:o,className:`flex justify-end gap-2`}),children:t==null||l!=null?(0,$.jsx)(lr,{mode:l?`edit`:`create`,connection:l,variant:`panel`,actionsSlot:a,assistantId:e,existingNames:c.map(e=>e.name),connections:c,onSave:d,onCancel:n}):null})}var dr={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},fr={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},pr=`deepgram`;function mr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:i}={}){let a=Be(),o=e??a,c=Rt(),l=X(),{t:d}=Z(),f=(0,Q.useMemo)(()=>r(le(),{displayName:d(`sttProviderForm.windowsNativeDisplayName`),subtitle:d(`sttProviderForm.windowsNativeSubtitle`),setupWarning:d(`sttProviderForm.windowsNativeSetupWarning`)}).filter(e=>!e.requiresNativeDictation||rt()),[d]),p=pr,{data:m}=Y({...s({path:{assistant_id:o}}),enabled:c,staleTime:3e4}),h=m?.services?.stt,g=h?.mode===`managed`?`vellum`:h?.provider,_=(0,Q.useMemo)(()=>{let e=g?fr[g]:void 0;if(e&&f.some(t=>t.id===e))return e;let t=W(Ke,p);return f.some(e=>e.id===t)?t:p},[g,f,p]),v=!!g,[y,b]=pn(_),{available:x,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T}=mt(o),[E,O]=(0,Q.useState)(!1),k=x&&y===_&&(dr[y]?.provider===C||!!g&&!fr[g]),[A,j]=(0,Q.useState)(``),[M,N]=(0,Q.useState)(!1),[P,I]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=W(Ke,p);e===`macos-native`&&!f.some(t=>t.id===e)&&K(Ke,p)},[f,p]);let L=(0,Q.useMemo)(()=>f.find(e=>e.id===y)??f[0],[f,y]),R=L.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{N(W(Ze+y,``).length>0),j(``)},[y]);let z=(0,Q.useMemo)(()=>{let e=y!==_,t=A.trim().length>0;return e||t},[y,_,A]),B=(0,Q.useCallback)(async()=>{let e=A.trim();K(Ke,y),e.length>0&&K(Ze+y,e);let t=dr[y];I(!0);try{if(t?.credentialService){let n=e.length>0?e:W(Ze+y,``);if(n.length>0){let{response:e}=await D({path:{assistant_id:o},body:{service:t.credentialService,field:`api_key`,value:n,label:`${L.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(y!==_||!v)||g===`vellum`&&y!==`vellum`){let e=t?.provider??pr,{response:n}=await Bt({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:Pt({path:{assistant_id:o}})}),u.success(d(`sttProviderForm.saveSuccess`)),!0}catch(e){return u.error(e instanceof Error?e.message:d(`sttProviderForm.saveFailed`)),!1}finally{I(!1)}},[o,y,A,L,_,v,g,l,d]);(0,Q.useEffect)(()=>{i?.({hasChanges:z,saving:P,save:B})},[i,z,P,B]);let ee=(0,Q.useCallback)(()=>{K(Ze+y,``),N(!1),j(``)},[y]),V=M?d(`sttProviderForm.apiKeyPlaceholderReplace`):L.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:d(`sttProviderForm.providerLabel`)}),(0,$.jsx)(G,{value:y,onChange:b,options:f.map(e=>({value:e.id,label:e.displayName})),"aria-label":d(`sttProviderForm.providerAriaLabel`)})]}),k&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:d(`sttProviderForm.spokenLanguage`)}),(0,$.jsx)(Me,{"aria-label":d(`sttProviderForm.spokenLanguage`),"aria-haspopup":`dialog`,onClick:()=>O(!0),value:et(S,C)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:d(`sttProviderForm.spokenLanguageApplies`)}),(0,$.jsx)(dn,{open:E,onOpenChange:O,title:d(`sttProviderForm.spokenLanguage`),currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T})]}),R&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:d(`sttProviderForm.apiKeyLabel`)}),(0,$.jsx)(F,{type:`password`,value:A,onChange:e=>j(e.target.value),placeholder:V,fullWidth:!0})]}),L.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)(qt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,$.jsx)(`span`,{children:L.setupWarning})]}),!n&&L.credentialsGuide&&(0,$.jsx)(sn,{guide:L.credentialsGuide}),y===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:d(`sttProviderForm.vellumTranscription`)}),(!t||M)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!t&&(0,$.jsx)(on,{onClick:B,disabled:!z||P}),M&&(0,$.jsx)(an,{onClick:ee})]})]})}var hr={batch:`sttRoleOverrides.role.batch`,dictation:`sttRoleOverrides.role.dictation`,liveVoice:`sttRoleOverrides.role.liveVoice`,telephony:`sttRoleOverrides.role.telephony`,watch:`sttRoleOverrides.role.watch`};function gr(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 _r({assistantId:e}){let{t}=Z(`settings`),n=X(),r=Rt(),[i,a]=(0,Q.useState)(null),{data:o}=Y({...s({path:{assistant_id:e}}),enabled:r,staleTime:3e4}),c=o?.services?.stt,l=gr(c),{data:d}=Y({...m({path:{assistant_id:e}}),enabled:r&&l.length>0,staleTime:5*6e4});if(l.length===0)return null;let f=e=>d?.providers?.find(t=>t.id===e)?.displayName??e,p=async r=>{a(r);try{let{response:t}=await Bt({path:{assistant_id:e},body:{services:{stt:{roles:{[r]:null}}}},throwOnError:!1});if(!t?.ok)throw Error(String(t?.status??``));await n.invalidateQueries({queryKey:Pt({path:{assistant_id:e}})})}catch{u.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:l.map(e=>{let n=hr[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?`${f(e.provider)} · ${e.model}`:f(e.provider)}),(0,$.jsx)(U,{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 p(e.role),children:t(`sttRoleOverrides.clear`)})]},e.role)})})]})}function vr(){let{t:e}=Z(`settings`),t=Be();return(0,$.jsxs)(rn,{title:e(`speechToTextCard.title`),subtitle:e(`speechToTextCard.subtitle`),children:[(0,$.jsx)(mr,{}),(0,$.jsx)(_r,{assistantId:t})]})}async function yr(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 br(n,r,i):t===`deepgram`?await xr(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 br(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 Sr(i,`ElevenLabs rejected the request.`)}}async function xr(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 Sr(n,`Deepgram rejected the request.`)}}async function Sr(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 Cr({assistantId:e,value:t,onChange:n,className:r}){let{t:i}=Z(),[a,o]=(0,Q.useState)(!1),{voices:s}=De(e);if(s.length===0)return null;let c=s.find(e=>e.model===t)??s[0];return(0,$.jsxs)(g.Root,{open:a,onOpenChange:o,children:[(0,$.jsx)(g.Trigger,{asChild:!0,children:(0,$.jsx)(Me,{"aria-label":i(`voicePickerField.ariaLabel`),value:c?We(c.description):i(`voicePickerField.selectVoice`),className:r})}),(0,$.jsx)(g.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)(fe,{assistantId:e,value:t,onChange:n,onSelect:()=>o(!1),showSource:!0,autoScrollToSelected:!0})})]})}var wr={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Tr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:r}={}){let{t:i}=Z(),a=Be(),o=e??a,c=st.use.name()??`your assistant`,l=Rt(),d=X(),{data:p}=Y({...S({path:{assistant_id:o}}),enabled:l,staleTime:1/0}),m=(0,Q.useMemo)(()=>{let e=p?.providers;if(!e)return f;if(e.some(e=>e.id===`vellum`))return e;let t=f.find(e=>e.id===`vellum`);return t?[t,...e]:e},[p]),{data:h}=Y({...s({path:{assistant_id:o}}),enabled:l,staleTime:3e4}),g=h?.services?.tts,_=g?.mode===`managed`?`vellum`:g?.provider,v=`elevenlabs`,y=(0,Q.useMemo)(()=>_??W(`vellum:voice:ttsProvider`,v),[_,v]),b=!!_,[x,C]=pn(y),[w,T]=(0,Q.useState)(``),[E,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1),{voices:R,defaultModel:z,fetched:B}=jt(o,{enabled:x===`vellum`}),ee=g?.providers?.vellum?.model??z??``,[V,te]=pn(ee),ne=R.find(e=>e.model===V)??R[0],[re,ie]=(0,Q.useState)(null),ae=R.some(e=>e.model===ee),oe=re??(B&&ee!==``&&!ae),H=(0,Q.useMemo)(()=>m.find(e=>e.id===x)??m[0],[x,m]),se=x===`vellum`&&H.supportsVoiceSelection&&V.trim()!==``&&V.trim()!==ee,ce=(0,Q.useCallback)(e=>{let t=W(ke+e,``),n=W(zt+e,``);M(t.length>0),O(n),A(n),T(``)},[]);(0,Q.useEffect)(()=>{ce(x)},[x,ce]);let le=(0,Q.useMemo)(()=>{let e=x!==y,t=w.trim().length>0,n=E.trim()!==k;return e||t||n||se},[x,y,w,E,k,se]),ue=(0,Q.useCallback)(async()=>{let e=w.trim(),t=E.trim(),n=H.id;K(Mt,n),e.length>0&&K(ke+n,e),K(zt+n,t);let r=e.length>0?e:W(ke+n,``),a=wr[n];L(!0);try{if(r.length>0){let{response:e}=await D({path:{assistant_id:o},body:{service:n,field:`api_key`,value:r,label:`${H.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...x!==y||!b?{provider:n,mode:n===`vellum`?`managed`:`your-own`}:{},...a?{providers:{[n]:{[a]:t}}}:{},...se?{providers:{vellum:{model:V.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await Bt({path:{assistant_id:o},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(r.length>0),A(t),T(``),d.invalidateQueries({queryKey:Pt({path:{assistant_id:o}})}),u.success(i(`ttsProviderForm.saved`)),!0}catch(e){return u.error(e instanceof Error?e.message:i(`ttsProviderForm.saveFailed`)),!1}finally{L(!1)}},[o,x,V,se,w,E,H,y,b,d,i]);(0,Q.useEffect)(()=>{r?.({hasChanges:le,saving:I,save:ue})},[r,le,I,ue]);let de=(0,Q.useCallback)(()=>{K(ke+x,``),M(!1),T(``)},[x]),fe=(0,Q.useCallback)(async()=>{P(!0);try{let e=W(ke+x,``),t=w.trim(),n=t.length>0?t:e;if(n.length===0){u.error(i(`ttsProviderForm.apiKeyRequired`));return}let r=W(zt+x,``),a=E.trim(),o=await yr({provider:x,apiKey:n,voiceId:a.length>0?a:r,text:`Hey! It's ${c}. How does this sound?`});if(o.kind!==`audio`){u.error(o.message);return}let s=URL.createObjectURL(o.blob);try{let e=new Audio(s);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(s)}}finally{P(!1)}},[c,w,x,E,i]),pe=j?`•••••••• (Enter a new key to replace)`:H.apiKeyPlaceholder,me=x===`vellum`,he=me&&H.supportsVoiceSelection,ge=(0,$.jsxs)(U,{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===V)||te(z||R[0]?.model||``)},children:[(0,$.jsx)(Xt,{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)(G,{value:x,onChange:C,options:m.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)(F,{type:`password`,value:w,onChange:e=>T(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)(F,{type:`text`,value:V,onChange:e=>te(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),"aria-label":i(`ttsProviderForm.customVoiceIdAriaLabel`),fullWidth:!0}):ne?(0,$.jsx)(Cr,{assistantId:o,value:V,onChange:te}):B&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.noManagedVoices`)})]}),H.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)(F,{type:`text`,value:E,onChange:e=>O(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),fullWidth:!0})]}),!n&&!me&&(0,$.jsx)(sn,{guide:H.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!me&&(0,$.jsx)(U,{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)(on,{onClick:ue,disabled:!le||I}),j&&!me&&(0,$.jsx)(an,{onClick:de})]})]})]})}function Er(){let{t:e}=Z(`settings`);return(0,$.jsx)(rn,{id:`text-to-speech`,title:e(`textToSpeechCard.title`),subtitle:e(`textToSpeechCard.subtitle`),children:(0,$.jsx)(Tr,{})})}var Dr=`default`;function Or(){let{t:e}=Z(`settings`),t=Be(),n=X(),{data:r}=Y({...s({path:{assistant_id:t}}),staleTime:3e4}),i=ce({onSuccess:e=>{ae(n,{path:{assistant_id:t}},e)}}),a=fn(),o=(0,Q.useMemo)(()=>r?r.services?.[`web-fetch`]?.provider||W(`vellum:ai:webFetchProvider`,Dr):W(Pe,Dr),[r]),c=(0,Q.useMemo)(()=>r?.services?.[`web-fetch`]?.apiBase??``,[r]),[l,d]=(0,Q.useState)(!1),[f,p]=pn(o),[m,g]=pn(c),[_,b]=(0,Q.useState)(``),x=y.has(f),S=j.has(f),{hasStoredCredential:C}=Fe({assistantId:t,credentialKind:`api_key`,credentialName:f,enabled:S}),w=_.trim().length>0,T=m.trim(),E=x&&T.length>0,D=f!==o||x&&T!==c.trim(),O=l||S&&!E&&!C&&!w||!D&&!w,A=vt(ve[f]??e(`webFetchCard.apiKeyPlaceholder`),C),M=Ct[f]??``,N=(0,Q.useCallback)(async()=>{d(!0);let r=_.trim(),o=S&&r.length>0;try{o&&await a(f,r),await i.mutateAsync({path:{assistant_id:t},body:{services:{"web-fetch":{provider:f,...x?{apiBase:T}:{}}}}}).catch(t=>{throw u.error(e(`webFetchCard.configUpdateFailedToast`)),z(t,{context:`patch_daemon_config`}),t})}catch{d(!1);return}d(!1);try{if(K(Pe,f),o){let e=h(f);e&&K(e,r);let i=Dt(t,`api_key`,f);n.setQueryData(i,!0),n.invalidateQueries({queryKey:i}),b(``)}u.success(e(`webFetchCard.savedToast`))}catch(t){z(t,{context:`settings-ai-web-fetch-persist-local`}),u.error(e(`webFetchCard.localPreferencesFailedToast`))}},[S,i,a,n,t,_,f,x,T,e]),P=(0,Q.useCallback)(()=>{let e=h(f);e&&v(e),b(``),g(``),p(Dr),K(Pe,Dr)},[f,p,g]);return(0,$.jsx)(rn,{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)(G,{value:f,onChange:p,options:Se.map(e=>({value:e,label:k[e]??e}))})]}),x&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(F,{label:e(`webFetchCard.apiBaseLabel`),type:`url`,value:m,onChange:e=>g(e.target.value),placeholder:M||e(`webFetchCard.apiBasePlaceholder`),fullWidth:!0}),M?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webFetchCard.apiBaseHint`,{defaultBase:M})}):null]}),S&&(0,$.jsx)(F,{label:e(`webFetchCard.apiKeyLabel`),type:`password`,value:_,onChange:e=>b(e.target.value),placeholder:A,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(on,{onClick:N,disabled:O}),l&&(0,$.jsx)(en,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),S&&(0,$.jsx)(an,{onClick:P,filled:!0})]})]})})}var kr=`0.10.12`;function Ar(){return pt(kr)}function jr(){let{t:e}=Z(`settings`),t=Be(),n=X(),r=Rt(),{data:i}=Y({...s({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),o=ce({onSuccess:e=>{ae(n,{path:{assistant_id:t}},e)}}),c=fn(),l=(0,Q.useMemo)(()=>{if(!i)return W(Lt,`inference-provider-native`);let e=i.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||W(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[i]),d=(0,Q.useMemo)(()=>i?.services?.[`web-search`]?.apiBase??``,[i]),[f,p]=(0,Q.useState)(!1),[m,h]=pn(l),[g,_]=pn(d),[y,x]=(0,Q.useState)(``),S=ne.has(m),w=Vt.has(m),T=a.has(m),{hasStoredCredential:E}=Fe({assistantId:t,credentialKind:`api_key`,credentialName:m,enabled:w}),D=y.trim().length>0,O=g.trim(),k=S&&O.length>0,A=m!==l||S&&O!==d.trim(),j=f||w&&!T&&!k&&!E&&!D||!A&&!D,M=vt(pe[m]??e(`webSearchCard.apiKeyPlaceholder`),E),N=ue[m]??``,P=(0,Q.useCallback)(async()=>{p(!0);let r=y.trim(),i=C(m),a=w&&r.length>0;try{a&&await c(m,r),await _t();let n=m===`vellum`?Ar()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:m,mode:`your-own`,...S?{apiBase:O}:{}};await o.mutateAsync({path:{assistant_id:t},body:{services:{"web-search":n}}}).catch(t=>{throw u.error(e(`webSearchCard.configUpdateFailedToast`)),z(t,{context:`patch_daemon_config`}),t})}catch{p(!1);return}p(!1);try{if(K(Lt,m),a){i&&K(i,r);let e=Dt(t,`api_key`,m);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),x(``)}u.success(e(`webSearchCard.savedToast`))}catch(t){z(t,{context:`settings-ai-web-search-persist-local`}),u.error(e(`webSearchCard.localPreferencesFailedToast`))}},[w,o,c,n,t,y,m,S,O,e]),I=(0,Q.useCallback)(()=>{let e=C(m);e&&v(e),x(``),_(``),h(`inference-provider-native`),K(Lt,`inference-provider-native`)},[m,h,_]);return(0,$.jsx)(rn,{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)(G,{"aria-label":e(`webSearchCard.providerAriaLabel`),value:m,onChange:h,options:se.map(e=>({value:e,label:b[e]??e}))})]}),m===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.vellumNote`)}),S&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(F,{label:e(`webSearchCard.apiBaseLabel`),type:`url`,value:g,onChange:e=>_(e.target.value),placeholder:N||e(`webSearchCard.apiBasePlaceholder`),fullWidth:!0}),N?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.apiBaseHint`,{defaultBase:N})}):null]}),w&&(0,$.jsx)(F,{label:e(`webSearchCard.apiKeyLabel`),type:`password`,value:y,onChange:e=>x(e.target.value),placeholder:M,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(on,{onClick:P,disabled:j}),f&&(0,$.jsx)(en,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),w&&(0,$.jsx)(an,{onClick:I,filled:!0})]})]})})}function Mr(){let e=Be(),t=Oe(),[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)(Jn,{}),(0,$.jsx)(Kn,{panel:n,onOpenPanel:r,onClosePanel:()=>r(null)}),(0,$.jsx)(jr,{}),(0,$.jsx)(Or,{}),(0,$.jsx)(_n,{}),(0,$.jsx)(Er,{}),(0,$.jsx)(vr,{})]}),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)(sr,{assistantId:e,onClose:()=>r(null)},a):o?(0,$.jsx)(ur,{assistantId:e,connectionName:n.kind===`provider`?n.name:null,onClose:()=>r(null)},a):(0,$.jsx)(Yn,{assistantId:e,profileName:n.kind===`profile`?n.name:null,onClose:()=>r(null)},a):null;return s&&t?(0,$.jsx)(cn,{children:s}):s?(0,$.jsx)(un,{storageKey:`aiSettingsDetailDrawerWidth`,detailKey:a,section:i,detail:s}):i}export{Mr as AiPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$u as t,$v as n,Ao as r,Bb as i,Bv as a,Bx as o,Cd as s,Cf as c,Co as l,Cx as u,Dd as d,Do as f,Ed as p,Ff as m,Fv as h,Fx as g,G as _,Gb as v,Gv as y,Hv as b,Hx as x,If as S,Iv as C,Ix as w,J as T,Jd as E,Jg as D,Jn as O,Jv as k,K as A,Kv as j,Lv as M,Mx as N,Nv as P,Nx as F,Od as I,Og as L,Oo as R,Pb as z,Pv as B,Qg as ee,Qu as V,Qv as te,Rv as ne,Sf as re,Sx as ie,Td as ae,To as oe,Tx as H,Uv as se,Ux as U,Vf as ce,Vm as le,Vv as ue,W as de,Wb as W,Wt as fe,Wv as pe,Wx as me,X as he,Xd as ge,Xu as _e,Xv as ve,Y as ye,Yd as be,Yf as xe,Yv as Se,Z as Ce,Zg as we,Zu as Te,Zv as Ee,_a as De,_c as Oe,_o as ke,_p as Ae,ai as je,at as Me,ay as Ne,bo as Pe,cp as Fe,cx as Ie,dd as Le,dp as Re,ed as ze,et as Be,ey as Ve,fd as He,fp as Ue,ga as We,gd as Ge,go as Ke,gp as qe,gx as Je,h_ as Ye,hd as Xe,ho as Ze,hp as Qe,ii as $e,it as et,iy as tt,j_ as nt,jo as rt,jx as it,kd as at,ko as ot,lb as st,lp as ct,md as lt,mo as ut,mp as dt,nd as ft,nh as pt,nt as mt,nx as ht,ny as gt,oh as _t,pd as vt,po as yt,pp as bt,px as G,q as xt,qb as K,qd as St,qv as Ct,rd as wt,rh as Tt,ry as Et,sp as Dt,td as Ot,ty as kt,up as At,va as jt,vo as Mt,vp as Nt,vx as q,wd as Pt,wf as Ft,wo as It,xo as Lt,ym as Rt,yo as zt,zg as Bt,zv as Vt}from"./app-p4YU9h0P.js";import{I as J,Jn as Ht,N as Ut,Zn as Y,er as X,j as Z}from"./vendor-DYOeoIwg.js";import{b as Wt,t as Gt,x as Kt}from"./react-B9IgSVeK.js";import{E as qt,Hi as Jt,It as Yt,Jn as Xt,Xr as Zt,_t as Qt,k as $t,qn as en,ur as tn}from"./icons-QG1KAFmx.js";import{t as nn}from"./ellipsis-vertical-Dbz00Lo-.js";import{i as rn,n as an,r as on,t as sn}from"./service-form-controls-B3_1_Epi.js";import{d as cn,o as ln,u as un}from"./schedules-C83Ua4R6.js";import{t as dn}from"./stt-language-picker-modal-3iCIcD10.js";var Q=e(Kt(),1);function fn(){let e=Be();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await nt({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});P(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?u.error(J(`settings:useDaemonConfig.assistantNotReadyToast`)):u.error(J(`settings:useDaemonConfig.saveApiKeyFailedToast`,{providerName:t})),z(e,{context:`provision_provider_key`}),e}},[e])}function pn(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 mn=`0.11.0`;function hn(){return pt(mn)}var $=Gt(),gn=`gemini-3.1-flash-image-preview`;function _n(){let{t:e}=Z(`settings`),t=Be(),n=X(),r=Rt(),{data:i}=Y({...s({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),a=ce({onSuccess:e=>{ae(n,{path:{assistant_id:t}},e)}}),o=fn(),[c,d]=pn((0,Q.useMemo)(()=>{if(!i)return W(ut,`gemini`);let e=i.services?.[`image-generation`];return e?.mode===`managed`?`vellum`:e?.provider||W(`vellum:ai:imageGenProvider`,`gemini`)},[i])),[f,p]=(0,Q.useState)(()=>W(yt,gn)),m=R(c),h=m.includes(f)?f:m[0]??gn,[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(!1),b=It.map(e=>({value:e,label:oe[e]??e})),x=(0,Q.useMemo)(()=>R(c).map(e=>({value:e,label:l[e]??e})),[c]),S=c===`gemini`||c===`openai`,{hasStoredCredential:C}=Fe({assistantId:t,credentialKind:`api_key`,credentialName:c,enabled:S}),w=d,T=(0,Q.useCallback)(async()=>{y(!0);let r=g.trim(),i=S&&r.length>0;try{i&&await o(ot(h),r),await _t();let s=c===`vellum`&&!hn()?{mode:`managed`}:{provider:c,mode:c===`vellum`?`managed`:`your-own`};await a.mutateAsync({path:{assistant_id:t},body:{services:{"image-generation":s}}}).catch(t=>{throw u.error(e(`imageGenerationCard.configUpdateFailedToast`)),z(t,{context:`patch_daemon_config`}),t});try{await Ye({path:{assistant_id:t},body:{modelId:h},throwOnError:!0})}catch(t){throw u.error(e(`imageGenerationCard.modelUpdateFailedToast`)),z(t,{context:`set_image_gen_model`}),t}finally{n.invalidateQueries({queryKey:Pt({path:{assistant_id:t}})})}}catch{y(!1);return}y(!1);try{if(K(ut,c),K(yt,h),i){let e=Dt(t,`api_key`,c);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),_(``)}u.success(e(`imageGenerationCard.savedToast`))}catch(t){z(t,{context:`settings-ai-image-gen-persist-local`}),u.error(e(`imageGenerationCard.localPreferencesFailedToast`))}},[g,c,S,h,t,a,o,n,e]),E=(0,Q.useCallback)(()=>{_(``),p(gn),K(yt,gn)},[]);return(0,$.jsx)(rn,{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)(G,{"aria-label":e(`imageGenerationCard.providerAriaLabel`),value:c,onChange:w,options:b})]}),c===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.vellumNote`)}),S&&(0,$.jsx)(F,{label:e(`imageGenerationCard.apiKeyLabel`),type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:vt(e(c===`openai`?`imageGenerationCard.openaiApiKeyPlaceholder`:`imageGenerationCard.geminiApiKeyPlaceholder`),C),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`)}),(0,$.jsx)(G,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:h,onChange:p,options:x})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(on,{onClick:T,disabled:v}),v&&(0,$.jsx)(en,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),S&&(0,$.jsx)(an,{onClick:E})]})]})})}function vn({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)(x,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(x,{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 yn(e){return e.scheduleNames.length>0||e.deferredReminderCount>0||e.scheduleLookupFailed}var bn=5;function xn({title:e,items:t,mono:n}){return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(x,{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 Sn(e){let t=e.label||e.name,n=[];e.isActive&&n.push(J(`settings:manageProfilesBlockedDeleteModal.clauseDefaultProfile`)),e.callSiteIds.length>0&&n.push(J(`settings:manageProfilesBlockedDeleteModal.clauseActionOverrides`,{count:e.callSiteIds.length}));let r=e.scheduleNames.length,i=e.deferredReminderCount;return r>0&&i>0?n.push(J(`settings:manageProfilesBlockedDeleteModal.clauseRunsBoth`,{schedules:r,reminders:i})):r>0?n.push(J(`settings:manageProfilesBlockedDeleteModal.clauseRunsSchedules`,{count:r})):i>0&&n.push(J(`settings:manageProfilesBlockedDeleteModal.clauseRunsReminders`,{count:i})),n.length===0?J(`settings:manageProfilesBlockedDeleteModal.summaryNoReferences`,{display:t}):n.length===1?J(`settings:manageProfilesBlockedDeleteModal.summaryOneClause`,{display:t,clause1:n[0]}):n.length===2?J(`settings:manageProfilesBlockedDeleteModal.summaryTwoClauses`,{display:t,clause1:n[0],clause2:n[1]}):J(`settings:manageProfilesBlockedDeleteModal.summaryThreeClauses`,{display:t,clause1:n[0],clause2:n[1],clause3:n[2]})}function Cn({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let{t:c}=Z(`settings`),l=e?.scheduleNames??[],u=l.slice(0,bn),d=l.length-u.length,f=e!=null&&yn(e);return(0,$.jsx)(H.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(H.Content,{size:`sm`,children:[(0,$.jsx)(H.Header,{children:(0,$.jsx)(H.Title,{children:c(`manageProfilesBlockedDeleteModal.title`)})}),(0,$.jsxs)(H.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(x,{variant:`body-medium-default`,as:`p`,children:Sn(e)}),e&&e.callSiteIds.length>0&&(0,$.jsx)(xn,{title:c(`manageProfilesBlockedDeleteModal.actionOverridesTitle`),items:e.callSiteIds,mono:!0}),u.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(xn,{title:c(`manageProfilesBlockedDeleteModal.schedulesTitle`),items:u}),d>0&&(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.moreSchedules`,{count:d})})]}),e?.scheduleLookupFailed&&(0,$.jsx)(x,{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)(G,{"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:xt(e),disabled:t,tooltip:t?c(`manageProfilesBlockedDeleteModal.disabledTargetTooltip`):void 0}})})]}),i&&(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(H.Footer,{children:[(0,$.jsx)(U,{variant:`ghost`,size:`compact`,onClick:o,children:c(`manageProfilesBlockedDeleteModal.cancel`)}),(0,$.jsx)(U,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:c(a?`manageProfilesBlockedDeleteModal.saving`:`manageProfilesBlockedDeleteModal.reassignAndDelete`)})]})]})})}function wn({profile:e,isActiveProfile:n,selected:r,connections:i,deletePending:a=!1,onOpen:o,onMakeActive:s,onSetStatus:c,onDelete:l}){let{t:u}=Z(`settings`),d=e.source===`managed`,f=e.status===`disabled`,p=e.label??e.name,m=[];e.model&&m.push(t(e.provider??void 0,e.model,i)),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)(ht,{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:r,disabled:a,contentAriaLabel:u(`profileRow.openProfileAriaLabel`,{displayName:p}),trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[y==null?null:(0,$.jsx)(me,{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)(Jt,{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)(Jt,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-label":y,role:`img`})})}),f?(0,$.jsx)(w,{tone:`neutral`,children:u(`profileRow.disabledTag`)}):null,n?(0,$.jsx)(w,{tone:`positive`,children:u(`profileRow.defaultTag`)}):null,(0,$.jsxs)(q.Root,{children:[(0,$.jsx)(q.Trigger,{asChild:!0,children:(0,$.jsx)(U,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(nn,{}),"aria-label":u(`profileRow.actionsAriaLabel`,{displayName:p}),disabled:a})}),(0,$.jsxs)(q.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(q.Item,{onSelect:o,children:u(d?`profileRow.view`:`profileRow.edit`)}),!n&&!f?(0,$.jsx)(q.Item,{onSelect:s,children:u(`profileRow.makeDefault`)}):null,f?(0,$.jsx)(q.Item,{onSelect:()=>c(!0),children:u(`profileRow.enable`)}):d?null:(0,$.jsx)(q.Item,{onSelect:()=>c(!1),children:u(`profileRow.disable`)}),d?null:(0,$.jsx)(q.Item,{onSelect:l,className:Je.anchored,children:u(`profileRow.delete`)})]})]})]})})}function Tn(e,t){let n=$e(),{data:r}=Y({...St({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=de(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:B(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 En=`0.10.8`;function Dn(e){return Tt(En,e)}var On=`settings-ai-profile-make-active`,kn=`Failed to set the active profile. Please try again.`;function An(e){let t=Te(),n=X(),r=Dn(e),a=xe({onSuccess:()=>{n.invalidateQueries({queryKey:Pt({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:E({path:{assistant_id:e}})})}});async function o(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw z(e,{context:r}),u.error(i),e}}async function s(t){if(!r){await o({activeProfile:t},On,kn);return}try{await a.mutateAsync({path:{assistant_id:e},body:{name:t}})}catch(e){let t=i(e);throw u.error(t??kn),t||z(e,{context:On}),e}}return{makeActive:s,setStatus:(e,t)=>o({profiles:{[e]:{status:t?`active`:`disabled`}}},`settings-ai-profile-toggle`,`Failed to update the profile. Please try again.`),deleteProfile:(e,t,n)=>o({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:o,isPending:t.isPending||a.isPending}}var jn=`The profile was not deleted.`,Mn=`Failed to move the schedules. ${jn}`;function Nn(e){let t=i(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${jn}`:Mn}function Pn(e,t,n){let r=An(e),i=X(),a=Ce(),o=t?.llm?.activeProfile??null,s=t?.llm?.advisorProfile??null,l=t?.llm?.callSites??{},u=(0,Q.useMemo)(()=>t?.llm?.profiles??{},[t?.llm?.profiles]),d=(0,Q.useMemo)(()=>t?.llm?.profileOrder??[],[t?.llm?.profileOrder]),f=(0,Q.useMemo)(()=>B(u,d),[u,d]),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),w=(0,Q.useRef)(!1);function T(e){return f.filter(t=>t.name===e?!1:t.status===`disabled`?!0:_(t,f,{requireOwnProviderAndModel:a}))}function E(e,t){let n=T(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 D(e){try{await r.deleteProfile(e,d,{isAdvisor:e===s}),n?.onDeleted?.(e)}catch{}}async function O(t){let n=u[t]?.label??t,r=t===o,a=Object.entries(l).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),s=[],c=0,d=!1;try{let n=(await i.fetchQuery({...re({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),c=n.filter(e=>e.isDeferred).length}catch(e){z(e,{context:`settings-ai-profile-delete-schedule-scan`}),d=!0}if(!(r||a.length>0||s.length>0||c>0)&&!d){await D(t);return}let f={name:t,label:n,isActive:r,callSiteIds:a,scheduleNames:s,deferredReminderCount:c,scheduleLookupFailed:d};m(f),y(E(t,yn(f))),g(null)}function k(e){t==null||w.current||(w.current=!0,C(e),O(e).finally(()=>{w.current=!1,C(null)}))}async function A(){if(!p||!v)return;if(x(!0),g(null),yn(p))try{await ln(e,p.name,v),await i.invalidateQueries({queryKey:c({path:{assistant_id:e}})})}catch(e){z(e,{context:`settings-ai-profile-reassign-schedules`}),g(Nn(e)),x(!1);return}let t={};if(p.isActive&&(t.activeProfile=v),p.callSiteIds.length>0){let e={};for(let t of p.callSiteIds)e[t]={profile:v};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{g(`Failed to reassign references. Please try again.`),x(!1);return}let n=p.name;m(null),x(!1),D(n)}return{requestDelete:k,pendingDeleteName:S,blockedDeleteModalProps:{blocked:p,availableReplacements:T(p?.name??null),replacement:v,onReplacementChange:y,error:h,saving:b,onClose:()=>{m(null),g(null)},onConfirm:()=>void A()}}}function Fn(){}function In({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{t:s}=Z(`settings`),{entries:c}=Tn(e,t),l=An(e),u=Pn(e,t,{onDeleted:o}),d=t?.llm?.activeProfile??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{title:s(`profilesSection.title`),action:(0,$.jsx)(U,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(Yt,{}),disabled:t==null,children:s(`profilesSection.createProfile`)}),children:t==null?(0,$.jsx)(x,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.loading`)}):c.length===0?(0,$.jsx)(x,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.emptyState`)}):c.map(e=>(0,$.jsx)(wn,{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(Fn),onSetStatus:t=>void l.setStatus(e.name,t).catch(Fn),onDelete:()=>u.requestDelete(e.name)},e.name))}),(0,$.jsx)(Cn,{...u.blockedDeleteModalProps})]})}var Ln={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 Rn(e){return e in Ln}function zn(e){if(!e.baseUrl)return null;try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function Bn(e){let t=zn(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 Vn(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 Hn(e){if(e.provider===`vellum`)return`Included with your plan`;if(e.provider===`openai-compatible`)return Bn(e);let t=[];if(e.provider===`ollama`||e.provider===`opencode`){let n=zn(e);n&&t.push(n)}let n=e.provider===`chatgpt`?`openai`:e.provider,r=e.auth.type===`oauth_subscription`?Ot(n):tt(n),i=e.models?.length??r.length;i>0&&t.push(`${i} ${i===1?`model`:`models`}`);let a=Vn(e);return a&&t.push(a),t.join(` • `)}function Un({connection:e,isDefault:t,supportsDefaultProvider:n,selected:r,isSettingDefault:i,onOpen:a,onSetDefault:o,onDelete:s}){let{t:c}=Z(`settings`),l=e.isManaged??!1,u=Qe(e),d=Rn(e.provider),f=Hn(e),p=n&&!t&&d,m=!l&&a!=null,h=!l&&!t,g=p||m||h;return(0,$.jsx)(ht,{title:u,subtitle:f.length>0?f:void 0,onClick:a,showChevron:!1,selected:r,contentAriaLabel:a?c(`providerRow.openProviderAriaLabel`,{displayName:u}):void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[l?(0,$.jsx)(w,{tone:`neutral`,title:c(`providerRow.managedTagTitle`),children:c(`providerRow.managedTag`)}):null,t?(0,$.jsx)(w,{tone:`info`,title:c(`providerRow.defaultTagTitle`),children:c(`providerRow.defaultTag`)}):null,e.provider===`ollama`?(0,$.jsx)(w,{tone:`neutral`,title:c(`providerRow.localTagTitle`),children:c(`providerRow.localTag`)}):null,e.provider===`openai-compatible`?(0,$.jsx)(w,{tone:`neutral`,title:c(`providerRow.customTagTitle`),children:c(`providerRow.customTag`)}):null,g?(0,$.jsxs)(q.Root,{children:[(0,$.jsx)(q.Trigger,{asChild:!0,children:(0,$.jsx)(U,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(nn,{}),"aria-label":c(`providerRow.actionsAriaLabel`,{displayName:u})})}),(0,$.jsxs)(q.Content,{align:`end`,sideOffset:4,children:[m?(0,$.jsx)(q.Item,{onSelect:a,children:c(`providerRow.edit`)}):null,p?(0,$.jsx)(q.Item,{disabled:i,onSelect:o,children:c(`providerRow.setAsDefault`)}):null,h?(0,$.jsx)(q.Item,{onSelect:s,className:Je.anchored,children:c(`providerRow.delete`)}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function Wn(e,t){let n=X(),r={path:{assistant_id:e}},i=Ht({...at(),onSuccess:()=>{n.invalidateQueries({queryKey:I(r)}),n.invalidateQueries({queryKey:Pt(r)}),n.invalidateQueries({queryKey:E(r)})},onError:e=>{z(e,{context:`settings-ai-set-default-provider`}),u.error(J(`settings:useProviderActions.setDefaultFailedToast`))}});function a(t){Rn(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 we({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:ge(r)}),t?.onDeleted?.(i)):a?.status===409?u.error(J(`settings:useProviderActions.deleteInUseToast`)):u.error(J(`settings:useProviderActions.deleteFailedToast`))}catch(e){z(e,{context:`settings-ai-provider-delete`}),u.error(J(`settings:useProviderActions.deleteFailedToast`))}}return{setDefault:a,isSettingDefault:o,deleteConnection:s}}function Gn({assistantId:e,selectedConnectionName:t,onOpenConnection:r,onAddProvider:i,onConnectionDeleted:a}){let{t:o}=Z(`settings`),{data:s,isLoading:c,isError:l}=Y(be({path:{assistant_id:e}})),u=je(),{data:f}=Y({...d({path:{assistant_id:e}}),enabled:u}),p=u?f?.resolvedConnectionName??null:null,m=Wn(e,{onDeleted:a}),h=(0,Q.useMemo)(()=>{let e=s?.connections??[];return[...e.filter(e=>e.provider===n),...e.filter(e=>e.provider!==n)]},[s]);return(0,$.jsx)(vn,{title:o(`providersSection.title`),action:(0,$.jsx)(U,{variant:`outlined`,onClick:i,leftIcon:(0,$.jsx)(Yt,{}),children:o(`providersSection.addProvider`)}),children:c?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(Ie,{className:`h-10 rounded-lg`},e))}):l?(0,$.jsx)(x,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:o(`providersSection.loadError`)}):h.length===0?(0,$.jsx)(x,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:o(`providersSection.empty`)}):h.map(e=>(0,$.jsx)(Un,{connection:e,isDefault:e.name===p,supportsDefaultProvider:u,selected:e.name===t,isSettingDefault:m.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>r(e.name),onSetDefault:()=>m.setDefault(e),onDelete:()=>void m.deleteConnection(e.name)},e.name))})}function Kn({panel:e,onOpenPanel:t,onClosePanel:n}){let{t:r}=Z(`settings`),i=Be(),{data:a}=Y({...s({path:{assistant_id:i}}),staleTime:3e4}),c=je(),{data:l}=Y({...d({path:{assistant_id:i}}),enabled:c}),u=l?.availability,{data:f}=Y({...be({path:{assistant_id:i}})}),p=f?.connections,m=a?.llm?.callSites??{},h=Object.entries(m).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length;return(0,$.jsx)(rn,{title:r(`languageModelCard.title`),subtitle:r(`languageModelCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[u&&u.status!==`ok`&&(0,$.jsx)(o,{tone:u.status===`unknown`?`warning`:`error`,children:u.message??r(`languageModelCard.defaultProviderUnavailable`)}),i&&(0,$.jsx)(In,{assistantId:i,config:a,connections:p,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)(Gn,{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)(vn,{title:r(`languageModelCard.overridesTitle`),count:h,action:(0,$.jsx)(U,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:r(`languageModelCard.manage`)})})]})})}function qn({children:e}){return(0,$.jsxs)(`a`,{href:`https://www.vellum.ai/docs/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--primary-base)] hover:underline`,children:[e,(0,$.jsx)(Zt,{className:`h-3.5 w-3.5`})]})}function Jn(){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)(tn,{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)(Ut,{i18nKey:`managedServicesBanner.body`,ns:`common`,components:{link:(0,$.jsx)(qn,{})}})})]})}function Yn({assistantId:e,profileName:t,onClose:n}){let{t:r}=Z(`settings`),{data:i}=Y({...s({path:{assistant_id:e}}),staleTime:3e4}),{data:a}=Y({...be({path:{assistant_id:e}})}),o=a?.connections,c=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),l=Object.keys(c),u=(0,Q.useMemo)(()=>{if(t==null)return;let e=c[t];return e?{name:t,...e}:void 0},[t,c]),d=t==null?`create`:u?.source===`managed`||u?.invariant===!0?`view`:`edit`,{saveProfile:f,isPending:p}=_e(e,{onSaved:n}),m=V({mode:d,profileName:t??void 0,initialValues:u,existingNames:l,connections:o,assistantId:e,onSave:f}),h=Pn(e,i,{onDeleted:()=>n()}),g=t!=null&&h.pendingDeleteName===t,_=t!=null&&i!=null&&!(t in c);(0,Q.useEffect)(()=>{_&&!m.saving&&!p&&n()},[_,m.saving,p,n]);let v=d===`view`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{title:m.effectiveMode===`create`?r(`profileDetailPanel.createTitle`):u?.label??t??r(`profileDetailPanel.defaultTitle`),closeVariant:`outlined`,onClose:n,headerTrailing:v&&m.effectiveMode!==`create`?(0,$.jsx)(w,{tone:`neutral`,children:r(`profileDetailPanel.managedTag`)}):null,headerActions:m.effectiveMode!==`create`&&!m.isReadOnly?(0,$.jsx)(U,{variant:`dangerOutline`,iconOnly:g?(0,$.jsx)(en,{className:`animate-spin`}):(0,$.jsx)($t,{}),"aria-label":r(g?`profileDetailPanel.deleting`:`profileDetailPanel.delete`),tooltip:r(`profileDetailPanel.delete`),onClick:()=>{t!=null&&h.requestDelete(t)},disabled:m.saving||g}):null,footer:m.isReadOnly?(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(U,{variant:`outlined`,onClick:m.switchToSaveAsNew,disabled:m.saving,children:r(`profileDetailPanel.saveAsNew`)}),m.hasViewModeChanges?(0,$.jsx)(U,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.saving,children:m.saving?r(`profileDetailPanel.saving`):r(`profileDetailPanel.save`)}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(U,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.isInvalid||m.saving,children:m.saving?r(`profileDetailPanel.saving`):m.effectiveMode===`create`?r(`profileDetailPanel.create`):r(`profileDetailPanel.saveChanges`)})}),children:(0,$.jsx)(ze,{editor:m,assistantId:e,connections:o,variant:`panel`})}),(0,$.jsx)(Cn,{...h.blockedDeleteModalProps})]})}function Xn({value:e,profileOptions:t,disabled:n,onChange:r}){let{t:i}=Z(`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)(G,{value:e,onChange:r,options:t,placeholder:i(`advisorProfileRow.chooseProfilePlaceholder`),className:`w-44`,menuMinWidth:280,menuAlign:`start`,disabled:n})]})})}var Zn=`__custom__`;function Qn(e){return e?!!(e.profile||e.provider||e.model):!1}function $n(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 er(e,t){let n=Qn(e);return n===Qn(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function tr({assistantId:e,callSites:t,domains:n,persistedOverrides:r,orderedProfiles:a,onClose:s,onApplied:c}){let{t:l}=Z(`settings`),d=Te(),f=Ce(),p=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:f}),[f]),m=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t){let t=$n(n,r[n.id]);t&&e.set(n.id,t)}return e},[t,r]),h=(0,Q.useMemo)(()=>{let e=new Set(Array.from(m.values(),e=>e.profile));return a.filter(t=>e.has(t.name))},[a,m]),[g,_]=(0,Q.useState)(()=>h[0]?.name??``),[v,y]=(0,Q.useState)(``),[b,S]=(0,Q.useState)(new Set),[C,w]=(0,Q.useState)(!1),T=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[n]),E=(0,Q.useMemo)(()=>t.filter(e=>m.get(e.id)?.profile===g),[t,m,g]),D=(0,Q.useMemo)(()=>E.map(e=>e.id).filter(e=>!b.has(e)),[E,b]),O=(0,Q.useMemo)(()=>h.map(e=>({value:e.name,label:xt(e)})),[h]),k=(0,Q.useMemo)(()=>he(a,[],p).filter(e=>e.name!==g).map(e=>({value:e.name,label:xt(e)})),[a,g,p]),A=M(a,g),j=M(a,v),N=b.size===0;function P(e){_(e),S(new Set),e===v&&y(``)}function F(e,t){S(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function I(){if(!(!g||!v||D.length===0)){w(!0);try{let t={};for(let e of D)t[e]={profile:v};await d.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),u.success(l(`bulkOverrideSwapModal.successToast`,{count:D.length,targetLabel:j})),c(),s()}catch(e){let t=i(e);u.error(t??l(`bulkOverrideSwapModal.updateFailedToast`)),t||z(e,{context:`settings-ai-bulk-override-swap`})}finally{w(!1)}}}return(0,$.jsx)(H.Root,{open:!0,onOpenChange:e=>{e||s()},children:(0,$.jsxs)(H.Content,{size:`md`,children:[(0,$.jsx)(H.Header,{children:(0,$.jsx)(H.Title,{children:l(`bulkOverrideSwapModal.title`)})}),(0,$.jsxs)(H.Body,{className:`space-y-4`,children:[(0,$.jsx)(x,{variant:`body-medium-default`,as:`p`,children:l(`bulkOverrideSwapModal.intro`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(G,{id:`bulk-swap-source`,label:l(`bulkOverrideSwapModal.currentlyUsingLabel`),value:g,onChange:P,options:O}),(0,$.jsx)(G,{id:`bulk-swap-target`,label:l(`bulkOverrideSwapModal.changeToLabel`),value:v,onChange:y,options:k,placeholder:l(`bulkOverrideSwapModal.targetPlaceholder`)})]}),(0,$.jsx)(o,{tone:`info`,title:l(`bulkOverrideSwapModal.noticeTitle`),children:l(`bulkOverrideSwapModal.noticeBody`,{sourceLabel:A})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(x,{variant:`body-medium-default`,as:`p`,children:l(`bulkOverrideSwapModal.affectedSummary`,{count:E.length,profile:A})}),(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:l(`bulkOverrideSwapModal.chooseActions`)})]}),(0,$.jsx)(U,{variant:`ghost`,onClick:()=>S(N?new Set(E.map(e=>e.id)):new Set),children:l(N?`bulkOverrideSwapModal.clearAll`:`bulkOverrideSwapModal.selectAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:E.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)(it,{checked:!b.has(e.id),onCheckedChange:t=>F(e.id,t===!0),disabled:C,label:e.displayName,helperText:T(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:m.get(e.id)?.via===`override`?l(`bulkOverrideSwapModal.viaOverride`):l(`bulkOverrideSwapModal.viaDefault`)})]},e.id))})]})]}),(0,$.jsxs)(H.Footer,{children:[(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:l(`bulkOverrideSwapModal.willChange`,{count:D.length})}),(0,$.jsx)(U,{variant:`ghost`,onClick:s,disabled:C,children:l(`bulkOverrideSwapModal.cancel`)}),(0,$.jsx)(U,{variant:`primary`,disabled:!g||!v||D.length===0||C,onClick:()=>void I(),children:C?(0,$.jsx)(en,{className:`h-4 w-4 animate-spin`}):l(`bulkOverrideSwapModal.applyTo`,{count:D.length})})]})]})})}function nr({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,connections:o,onDraftChange:s,onToggle:c}){let{t:l}=Z(`settings`),u=gt({hostedInference:wt.use.vellumHostedInference()}),d=Qn(i),f=!i||!d?``:i.provider||i.model?Zn:i.profile??``,p=f===Zn,m=Re(),h=ct(),g=(o??[]).some(e=>e.provider===Ee),_=[...te,...g?[Ee]:[]],v=m[0]??te[0],y=i?.provider,b=Ve(y)?y:y===`chatgpt`?Ee:void 0,x=b!==void 0&&_.some(e=>e===b),S=b??v,C=ft(S,``,(o??[]).filter(e=>At(e.provider,S)))?Ot(S):Ne(S,u),w=C.map(e=>({value:e.id,label:e.displayName})),T=typeof i?.model==`string`?i.model:``;if(T&&!C.some(e=>e.id===T)){let e=tt(S).find(e=>e.id===T)?.displayName??T;w.push({value:T,label:l(`callSiteOverridesRow.unavailableOption`,{name:e})})}let E=!!i?.provider&&!i?.model,D=[..._.map(e=>({value:e,label:kt[e]??e,...h(e)})),...b&&!x?[{value:b,label:l(`callSiteOverridesRow.unavailableOption`,{name:kt[b]??b})}]:[]];function O(t){t===`__custom__`?s(e,{profile:null,provider:v,model:Et(v)??``}):t===``?s(e,null):s(e,{profile:t,provider:null,model:null})}function k(t){let n=Et(t)??``;s(e,{...i??{},profile:null,provider:t,model:n})}function A(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:l(`callSiteOverridesRow.defaultProfileSuffix`,{label:r})})]})]}),(0,$.jsx)(N,{checked:d,onChange:t=>c(e,t),"aria-label":l(`callSiteOverridesRow.overrideAriaLabel`,{displayName:t}),className:`shrink-0`})]}),d&&(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(G,{value:f,onChange:O,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`start`})}),d&&p&&(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:l(`callSiteOverridesRow.providerLabel`)}),(0,$.jsx)(G,{value:S??``,onChange:k,options:D})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:l(`callSiteOverridesRow.modelLabel`)}),(0,$.jsx)(G,{value:i?.model??``,onChange:A,options:w})]})]}),E&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:l(`callSiteOverridesRow.pickModelError`)})]})]})}function rr({groups:e,drafts:t,buildProfileOptionsForRow:n,profileLabelFor:r,advisorMatchesSearch:i,connections:a,onDraftChange:o,onToggle:s}){let{t:c}=Z(`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)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>{let i=(()=>{let n=t[e.id]??null;return!n||!Qn(n)?``:n.provider||n.model?Zn:n.profile??``})(),c=e.shippedDefaultProfile??e.defaultProfile,l=c?r(c):null;return(0,$.jsx)(nr,{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 ir(e,t){let n={};for(let r of Object.keys(e)){let i=e[r]??null;Qn(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 ar(e){let t={};for(let n of Object.keys(e))t[n]=null;return t}function or({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(!er(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=>Qn(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)(()=>ir(c,i),[c,i]),buildResetPatch:(0,Q.useCallback)(()=>ar(c),[c])}}function sr({assistantId:e,onClose:t}){let{t:n}=Z(`settings`),{data:r}=Y({...s({path:{assistant_id:e}}),staleTime:3e4}),i=(0,Q.useMemo)(()=>r?.llm?.profiles??{},[r?.llm?.profiles]),a=(0,Q.useMemo)(()=>r?.llm?.profileOrder??[],[r?.llm?.profileOrder]),o=(0,Q.useMemo)(()=>r?.llm?.callSites??{},[r?.llm?.callSites]),c=(0,Q.useMemo)(()=>B(i,a),[i,a]),l=Re(),d=Ce(),f=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:d}),[d]),m=Te(),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),{data:C,isLoading:w,isError:E,refetch:D}=Y({...p({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),{data:k}=Y({...be({path:{assistant_id:e}}),enabled:!!e}),j=(0,Q.useMemo)(()=>(C?.callSites??[]).filter(e=>e.id!==`mainAgent`),[C]),N=!w&&!E&&!!C,P=!!r,I=N&&P,L=(0,Q.useMemo)(()=>j.map(e=>e.id),[j]),R=r?.llm?.advisorProfile??``,{drafts:ee,advisorProfile:V,advisorDirty:ne,callSiteDraftsDirty:re,hasUnsavedDrafts:ae,hasValidationError:oe,setDraft:H,setAdvisor:se,clearEdits:ce,buildSavePatch:le,buildResetPatch:ue}=or({catalogCallSiteIds:L,persistedOverrides:o,persistedAdvisor:R,isSeeded:I}),de=(0,Q.useMemo)(()=>new Set(L),[L]),W=(0,Q.useCallback)(e=>M(c,e),[c]),fe=(0,Q.useCallback)(e=>({value:e.name,label:xt(e),...A(e,c,f)===`undispatchable`?{icon:(0,$.jsx)(Jt,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:ye(e)}:{}}),[c,f]),pe=(0,Q.useMemo)(()=>he(c,[R],f).map(fe),[c,R,fe,f]),me=(0,Q.useMemo)(()=>{let e=h.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[h]),ge=(0,Q.useMemo)(()=>j.some(e=>$n(e,o[e.id])!==null),[j,o]),_e=(0,Q.useMemo)(()=>Object.entries(o).some(([e,t])=>de.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[o,de]),ve=(0,Q.useCallback)(e=>[...he(c,[e],f).map(fe),{value:Zn,label:n(`overridesDetailPanel.customProfileOption`)}],[c,fe,f,n]),xe=(0,Q.useMemo)(()=>{if(!h.trim())return j;let e=h.toLowerCase();return j.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[j,h]),Se=(0,Q.useMemo)(()=>{if(!C)return[];let e=C.domains.map(e=>e.id),t=new Map(C.domains.map(e=>[e.id,e])),r=[];for(let n of e){let e=xe.filter(e=>e.domain===n);e.length>0&&r.push({domain:t.get(n),sites:e})}let i=new Set(e),a=xe.filter(e=>!i.has(e.domain));return a.length>0&&r.push({domain:{id:`other`,displayName:n(`overridesDetailPanel.otherDomain`)},sites:a}),r},[C,xe,n]),we=(0,Q.useCallback)((e,t)=>{if(!t){H(e,null);return}let n=T(c,j.find(t=>t.id===e)?.defaultProfile,f);if(n)H(e,{profile:n});else{let t=l[0]??te[0];H(e,{provider:t,model:Et(t)??``})}},[j,c,l,H,f]),Ee=(0,Q.useCallback)(async()=>{v(!0);try{let r=le();await m.mutateAsync({path:{assistant_id:e},body:{llm:{...re?{callSites:r}:{},...ne?{advisorProfile:V}:{}}}}),t(),u.success(n(`overridesDetailPanel.overridesSavedToast`))}catch(e){u.error(n(`overridesDetailPanel.saveFailedToast`)),z(e,{context:`call_site_overrides_save`})}finally{v(!1)}},[le,re,ne,V,t,m,e,n]),De=(0,Q.useCallback)(async()=>{v(!0);try{let r=ue();await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:r}}}),t(),u.success(n(`overridesDetailPanel.overridesResetToast`))}catch(e){u.error(n(`overridesDetailPanel.resetFailedToast`)),z(e,{context:`call_site_overrides_reset`})}finally{v(!1)}},[ue,t,m,e,n]),Oe=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[_e&&(0,$.jsx)(U,{variant:`outlined`,onClick:()=>b(!0),disabled:_||!I,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:n(`overridesDetailPanel.resetToDefaults`)}),(0,$.jsx)(U,{variant:`primary`,onClick:()=>void Ee(),disabled:!ae||oe||_,children:_?(0,$.jsx)(en,{className:`h-4 w-4 animate-spin`}):n(`overridesDetailPanel.save`)})]});return(0,$.jsxs)(O,{title:n(`overridesDetailPanel.title`),closeVariant:`outlined`,onClose:t,footer:Oe,children:[(0,$.jsx)(`p`,{className:`mb-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`overridesDetailPanel.description`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(F,{type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:n(`overridesDetailPanel.searchPlaceholder`),leftIcon:(0,$.jsx)(Qt,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(U,{variant:`outlined`,onClick:()=>S(!0),disabled:!I||_||ae||!ge,title:ae?n(`overridesDetailPanel.bulkChangeUnsavedTitle`):ge?void 0:n(`overridesDetailPanel.bulkChangeNoCandidatesTitle`),children:n(`overridesDetailPanel.bulkChange`)})]}),P&&me&&(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:n(`overridesDetailPanel.advisorSection`)}),(0,$.jsx)(Xn,{value:V,profileOptions:pe,disabled:_,onChange:se})]}),w&&(0,$.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,$.jsx)(en,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),E&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:n(`overridesDetailPanel.loadErrorTitle`)}),(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`overridesDetailPanel.loadErrorHint`)}),(0,$.jsx)(U,{variant:`outlined`,onClick:()=>void D(),children:n(`overridesDetailPanel.retry`)})]}),!w&&!E&&C&&(0,$.jsx)(rr,{groups:Se,drafts:ee,buildProfileOptionsForRow:ve,profileLabelFor:W,advisorMatchesSearch:me,connections:k?.connections,onDraftChange:H,onToggle:we})]}),x&&C&&(0,$.jsx)(tr,{assistantId:e,callSites:j,domains:C.domains,persistedOverrides:o,orderedProfiles:c,onClose:()=>S(!1),onApplied:ce}),(0,$.jsx)(ie,{open:y,title:n(`overridesDetailPanel.resetToDefaults`),message:n(`overridesDetailPanel.resetConfirmMessage`),confirmLabel:n(`overridesDetailPanel.resetToDefaults`),destructive:!0,onConfirm:()=>{b(!1),De()},onCancel:()=>b(!1)})]})}var cr=e(Wt(),1);function lr({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,variant:a=`modal`,actionsSlot:o,onSave:s,onCancel:c}){let{t:l}=Z(`settings`),[u,d]=(0,Q.useState)(t?.label??``),f=t?.name??``,p=t?.provider??`anthropic`,m=t?.auth.type??`api_key`,[h,g]=(0,Q.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[_,v]=(0,Q.useState)(t?.baseUrl??``),[y,b]=(0,Q.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),E=p===`openai-compatible`,D=dt(p),O=qe(p),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),N=X(),P=(0,Q.useMemo)(()=>bt(h),[h]),I=m===`api_key`&&P!==null,{hasStoredCredential:R,isLoading:z}=Fe({assistantId:n,credentialKind:`credential`,credentialName:P?`${P.service}:${P.field}`:``,enabled:I}),{credentials:B}=He({assistantId:n,enabled:m===`api_key`});(0,Q.useEffect)(()=>{let e=t?.provider??`anthropic`;d(t?.label??``),t?.auth.type===`api_key`?g(t.auth.credential):g(t?``:`credential/${e}/api_key`),T(null),v(t?.baseUrl??``),b(t?.models?t.models.map(e=>e.id).join(`, `):``),A(``),M(!1)},[t]);let V=u.trim()!==(t?.label??``).trim(),te=E&&V?Ge(u,i,t?.name):null,ne=f.trim().length>0&&te===null;async function re(){if(ne){C(!0),T(null);try{let e;if(m===`api_key`){let t=h.trim()||`credential/${p}/api_key`,r=k.trim();if(r){M(!0);try{let e=bt(t);await nt({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:p,value:r},throwOnError:!0});let i=Dt(n,`credential`,e?`${e.service}:${e.field}`:``);N.setQueryData(i,!0),N.invalidateQueries({queryKey:Ft({path:{assistant_id:n}})})}catch{T(l(`providerEditorContent.failedSaveApiKey`));return}finally{M(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{T(l(`providerEditorContent.nothingToEdit`));return}let r=u.trim()||null,i={auth:e,label:r,...D&&{base_url:_.trim()||null},...O&&{models:y.trim()?y.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:a,error:o,response:c}=await ee({path:{assistant_id:n,name:t?.name??f.trim()},body:i});if(!c?.ok){T(Ae(c?.status,o)??Ue(c?.status));return}if(!a){T(l(`providerEditorContent.emptyServerResponse`));return}Nt(a,l),s(a)}catch{T(l(`providerEditorContent.failedSaveProvider`))}finally{C(!1)}}}let ie=B.filter(e=>e.service===p),ae=e!==`create`&&t?.auth.type===`api_key`,oe=ie.length>0||ae,se=vt(l(`providerEditorContent.apiKeyPlaceholder`),R);if(e===`create`)return(0,$.jsx)(Le,{variant:a===`panel`?`inline`:`modal`,actionsSlot:o,assistantId:n,existingNames:r,connections:i,defaultProviderType:p,onCreated:s,onCancel:c});let ce=(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)(Ut,{i18nKey:`providerEditorContent.displayNameLabel`,ns:`settings`,components:{optional:(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`})}})}),(0,$.jsx)(F,{value:u,onChange:e=>d(e.target.value),placeholder:l(`providerEditorContent.displayNamePlaceholder`),fullWidth:!0}),te?(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:Xe[te]}):null]}),D&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlLabel`)}),(0,$.jsx)(F,{value:_,onChange:e=>v(e.target.value),placeholder:l(p===`ollama`?`providerEditorContent.baseUrlPlaceholderOllama`:p===`opencode`?`providerEditorContent.baseUrlPlaceholderOpencode`:`providerEditorContent.baseUrlPlaceholder`),fullWidth:!0}),p===`ollama`?(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlHintOllama`)}):null,p===`opencode`?(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlHintOpencode`)}):null]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`providerEditorContent.modelsLabel`)}),(0,$.jsx)(F,{value:y,onChange:e=>b(e.target.value),placeholder:l(`providerEditorContent.modelsPlaceholder`),fullWidth:!0}),(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.modelsHint`)})]}),m===`api_key`&&(0,$.jsx)(lt,{apiKeyValue:k,onApiKeyChange:A,credential:h,onCredentialChange:g,isLoadingCredential:z,apiKeyPlaceholder:se,provider:p,providerCredentials:ie,showAdvancedSection:oe,onError:T}),m===`oauth_subscription`&&(0,$.jsx)(L,{assistantId:n,onConnected:s}),w&&(0,$.jsx)(x,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:w})]}),le=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{variant:`ghost`,onClick:c,children:l(`providerEditorContent.cancel`)}),(0,$.jsx)(U,{variant:`primary`,disabled:!ne||S||j,onClick:()=>void re(),children:l(S?`providerEditorContent.saving`:`providerEditorContent.saveChanges`)})]});return a===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ce,o===void 0?(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:le}):o&&(0,cr.createPortal)(le,o)]}):(0,$.jsxs)(H.Content,{size:`md`,children:[(0,$.jsxs)(H.Header,{children:[(0,$.jsx)(H.Title,{children:l(`providerEditorContent.editProviderTitle`)}),(0,$.jsx)(H.Description,{children:t?l(`providerEditorContent.editingConnection`,{name:Qe(t)}):l(`providerEditorContent.editProviderSettingsFallback`)})]}),(0,$.jsx)(H.Body,{children:ce}),(0,$.jsx)(H.Footer,{children:le})]})}function ur({assistantId:e,connectionName:t,onClose:n}){let{t:r}=Z(`settings`),i=X(),[a,o]=(0,Q.useState)(null),{data:s}=Y(be({path:{assistant_id:e}})),c=(0,Q.useMemo)(()=>s?.connections??[],[s]),l=(0,Q.useMemo)(()=>t==null?void 0:c.find(e=>e.name===t),[t,c]),u=t!=null&&s!=null&&l==null;(0,Q.useEffect)(()=>{u&&n()},[u,n]);function d(){i.invalidateQueries({queryKey:ge({path:{assistant_id:e}})}),i.invalidateQueries({queryKey:I({path:{assistant_id:e}})}),n()}return(0,$.jsx)(O,{title:l?Qe(l):r(`providerDetailPanel.addProviderTitle`),closeVariant:`outlined`,onClose:n,footer:(0,$.jsx)(`div`,{ref:o,className:`flex justify-end gap-2`}),children:t==null||l!=null?(0,$.jsx)(lr,{mode:l?`edit`:`create`,connection:l,variant:`panel`,actionsSlot:a,assistantId:e,existingNames:c.map(e=>e.name),connections:c,onSave:d,onCancel:n}):null})}var dr={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},fr={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},pr=`deepgram`;function mr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:i}={}){let a=Be(),o=e??a,c=Rt(),l=X(),{t:d}=Z(),f=(0,Q.useMemo)(()=>r(le(),{displayName:d(`sttProviderForm.windowsNativeDisplayName`),subtitle:d(`sttProviderForm.windowsNativeSubtitle`),setupWarning:d(`sttProviderForm.windowsNativeSetupWarning`)}).filter(e=>!e.requiresNativeDictation||rt()),[d]),p=pr,{data:m}=Y({...s({path:{assistant_id:o}}),enabled:c,staleTime:3e4}),h=m?.services?.stt,g=h?.mode===`managed`?`vellum`:h?.provider,_=(0,Q.useMemo)(()=>{let e=g?fr[g]:void 0;if(e&&f.some(t=>t.id===e))return e;let t=W(Ke,p);return f.some(e=>e.id===t)?t:p},[g,f,p]),v=!!g,[y,b]=pn(_),{available:x,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T}=mt(o),[E,O]=(0,Q.useState)(!1),k=x&&y===_&&(dr[y]?.provider===C||!!g&&!fr[g]),[A,j]=(0,Q.useState)(``),[M,N]=(0,Q.useState)(!1),[P,I]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=W(Ke,p);e===`macos-native`&&!f.some(t=>t.id===e)&&K(Ke,p)},[f,p]);let L=(0,Q.useMemo)(()=>f.find(e=>e.id===y)??f[0],[f,y]),R=L.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{N(W(Ze+y,``).length>0),j(``)},[y]);let z=(0,Q.useMemo)(()=>{let e=y!==_,t=A.trim().length>0;return e||t},[y,_,A]),B=(0,Q.useCallback)(async()=>{let e=A.trim();K(Ke,y),e.length>0&&K(Ze+y,e);let t=dr[y];I(!0);try{if(t?.credentialService){let n=e.length>0?e:W(Ze+y,``);if(n.length>0){let{response:e}=await D({path:{assistant_id:o},body:{service:t.credentialService,field:`api_key`,value:n,label:`${L.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(y!==_||!v)||g===`vellum`&&y!==`vellum`){let e=t?.provider??pr,{response:n}=await Bt({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:Pt({path:{assistant_id:o}})}),u.success(d(`sttProviderForm.saveSuccess`)),!0}catch(e){return u.error(e instanceof Error?e.message:d(`sttProviderForm.saveFailed`)),!1}finally{I(!1)}},[o,y,A,L,_,v,g,l,d]);(0,Q.useEffect)(()=>{i?.({hasChanges:z,saving:P,save:B})},[i,z,P,B]);let ee=(0,Q.useCallback)(()=>{K(Ze+y,``),N(!1),j(``)},[y]),V=M?d(`sttProviderForm.apiKeyPlaceholderReplace`):L.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:d(`sttProviderForm.providerLabel`)}),(0,$.jsx)(G,{value:y,onChange:b,options:f.map(e=>({value:e.id,label:e.displayName})),"aria-label":d(`sttProviderForm.providerAriaLabel`)})]}),k&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:d(`sttProviderForm.spokenLanguage`)}),(0,$.jsx)(Me,{"aria-label":d(`sttProviderForm.spokenLanguage`),"aria-haspopup":`dialog`,onClick:()=>O(!0),value:et(S,C)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:d(`sttProviderForm.spokenLanguageApplies`)}),(0,$.jsx)(dn,{open:E,onOpenChange:O,title:d(`sttProviderForm.spokenLanguage`),currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T})]}),R&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:d(`sttProviderForm.apiKeyLabel`)}),(0,$.jsx)(F,{type:`password`,value:A,onChange:e=>j(e.target.value),placeholder:V,fullWidth:!0})]}),L.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)(qt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,$.jsx)(`span`,{children:L.setupWarning})]}),!n&&L.credentialsGuide&&(0,$.jsx)(sn,{guide:L.credentialsGuide}),y===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:d(`sttProviderForm.vellumTranscription`)}),(!t||M)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!t&&(0,$.jsx)(on,{onClick:B,disabled:!z||P}),M&&(0,$.jsx)(an,{onClick:ee})]})]})}var hr={batch:`sttRoleOverrides.role.batch`,dictation:`sttRoleOverrides.role.dictation`,liveVoice:`sttRoleOverrides.role.liveVoice`,telephony:`sttRoleOverrides.role.telephony`,watch:`sttRoleOverrides.role.watch`};function gr(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 _r({assistantId:e}){let{t}=Z(`settings`),n=X(),r=Rt(),[i,a]=(0,Q.useState)(null),{data:o}=Y({...s({path:{assistant_id:e}}),enabled:r,staleTime:3e4}),c=o?.services?.stt,l=gr(c),{data:d}=Y({...m({path:{assistant_id:e}}),enabled:r&&l.length>0,staleTime:5*6e4});if(l.length===0)return null;let f=e=>d?.providers?.find(t=>t.id===e)?.displayName??e,p=async r=>{a(r);try{let{response:t}=await Bt({path:{assistant_id:e},body:{services:{stt:{roles:{[r]:null}}}},throwOnError:!1});if(!t?.ok)throw Error(String(t?.status??``));await n.invalidateQueries({queryKey:Pt({path:{assistant_id:e}})})}catch{u.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:l.map(e=>{let n=hr[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?`${f(e.provider)} · ${e.model}`:f(e.provider)}),(0,$.jsx)(U,{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 p(e.role),children:t(`sttRoleOverrides.clear`)})]},e.role)})})]})}function vr(){let{t:e}=Z(`settings`),t=Be();return(0,$.jsxs)(rn,{title:e(`speechToTextCard.title`),subtitle:e(`speechToTextCard.subtitle`),children:[(0,$.jsx)(mr,{}),(0,$.jsx)(_r,{assistantId:t})]})}async function yr(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 br(n,r,i):t===`deepgram`?await xr(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 br(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 Sr(i,`ElevenLabs rejected the request.`)}}async function xr(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 Sr(n,`Deepgram rejected the request.`)}}async function Sr(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 Cr({assistantId:e,value:t,onChange:n,className:r}){let{t:i}=Z(),[a,o]=(0,Q.useState)(!1),{voices:s}=De(e);if(s.length===0)return null;let c=s.find(e=>e.model===t)??s[0];return(0,$.jsxs)(g.Root,{open:a,onOpenChange:o,children:[(0,$.jsx)(g.Trigger,{asChild:!0,children:(0,$.jsx)(Me,{"aria-label":i(`voicePickerField.ariaLabel`),value:c?We(c.description):i(`voicePickerField.selectVoice`),className:r})}),(0,$.jsx)(g.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)(fe,{assistantId:e,value:t,onChange:n,onSelect:()=>o(!1),showSource:!0,autoScrollToSelected:!0})})]})}var wr={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Tr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:r}={}){let{t:i}=Z(),a=Be(),o=e??a,c=st.use.name()??`your assistant`,l=Rt(),d=X(),{data:p}=Y({...S({path:{assistant_id:o}}),enabled:l,staleTime:1/0}),m=(0,Q.useMemo)(()=>{let e=p?.providers;if(!e)return f;if(e.some(e=>e.id===`vellum`))return e;let t=f.find(e=>e.id===`vellum`);return t?[t,...e]:e},[p]),{data:h}=Y({...s({path:{assistant_id:o}}),enabled:l,staleTime:3e4}),g=h?.services?.tts,_=g?.mode===`managed`?`vellum`:g?.provider,v=`elevenlabs`,y=(0,Q.useMemo)(()=>_??W(`vellum:voice:ttsProvider`,v),[_,v]),b=!!_,[x,C]=pn(y),[w,T]=(0,Q.useState)(``),[E,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1),{voices:R,defaultModel:z,fetched:B}=jt(o,{enabled:x===`vellum`}),ee=g?.providers?.vellum?.model??z??``,[V,te]=pn(ee),ne=R.find(e=>e.model===V)??R[0],[re,ie]=(0,Q.useState)(null),ae=R.some(e=>e.model===ee),oe=re??(B&&ee!==``&&!ae),H=(0,Q.useMemo)(()=>m.find(e=>e.id===x)??m[0],[x,m]),se=x===`vellum`&&H.supportsVoiceSelection&&V.trim()!==``&&V.trim()!==ee,ce=(0,Q.useCallback)(e=>{let t=W(ke+e,``),n=W(zt+e,``);M(t.length>0),O(n),A(n),T(``)},[]);(0,Q.useEffect)(()=>{ce(x)},[x,ce]);let le=(0,Q.useMemo)(()=>{let e=x!==y,t=w.trim().length>0,n=E.trim()!==k;return e||t||n||se},[x,y,w,E,k,se]),ue=(0,Q.useCallback)(async()=>{let e=w.trim(),t=E.trim(),n=H.id;K(Mt,n),e.length>0&&K(ke+n,e),K(zt+n,t);let r=e.length>0?e:W(ke+n,``),a=wr[n];L(!0);try{if(r.length>0){let{response:e}=await D({path:{assistant_id:o},body:{service:n,field:`api_key`,value:r,label:`${H.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...x!==y||!b?{provider:n,mode:n===`vellum`?`managed`:`your-own`}:{},...a?{providers:{[n]:{[a]:t}}}:{},...se?{providers:{vellum:{model:V.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await Bt({path:{assistant_id:o},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(r.length>0),A(t),T(``),d.invalidateQueries({queryKey:Pt({path:{assistant_id:o}})}),u.success(i(`ttsProviderForm.saved`)),!0}catch(e){return u.error(e instanceof Error?e.message:i(`ttsProviderForm.saveFailed`)),!1}finally{L(!1)}},[o,x,V,se,w,E,H,y,b,d,i]);(0,Q.useEffect)(()=>{r?.({hasChanges:le,saving:I,save:ue})},[r,le,I,ue]);let de=(0,Q.useCallback)(()=>{K(ke+x,``),M(!1),T(``)},[x]),fe=(0,Q.useCallback)(async()=>{P(!0);try{let e=W(ke+x,``),t=w.trim(),n=t.length>0?t:e;if(n.length===0){u.error(i(`ttsProviderForm.apiKeyRequired`));return}let r=W(zt+x,``),a=E.trim(),o=await yr({provider:x,apiKey:n,voiceId:a.length>0?a:r,text:`Hey! It's ${c}. How does this sound?`});if(o.kind!==`audio`){u.error(o.message);return}let s=URL.createObjectURL(o.blob);try{let e=new Audio(s);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(s)}}finally{P(!1)}},[c,w,x,E,i]),pe=j?`•••••••• (Enter a new key to replace)`:H.apiKeyPlaceholder,me=x===`vellum`,he=me&&H.supportsVoiceSelection,ge=(0,$.jsxs)(U,{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===V)||te(z||R[0]?.model||``)},children:[(0,$.jsx)(Xt,{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)(G,{value:x,onChange:C,options:m.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)(F,{type:`password`,value:w,onChange:e=>T(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)(F,{type:`text`,value:V,onChange:e=>te(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),"aria-label":i(`ttsProviderForm.customVoiceIdAriaLabel`),fullWidth:!0}):ne?(0,$.jsx)(Cr,{assistantId:o,value:V,onChange:te}):B&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.noManagedVoices`)})]}),H.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)(F,{type:`text`,value:E,onChange:e=>O(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),fullWidth:!0})]}),!n&&!me&&(0,$.jsx)(sn,{guide:H.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!me&&(0,$.jsx)(U,{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)(on,{onClick:ue,disabled:!le||I}),j&&!me&&(0,$.jsx)(an,{onClick:de})]})]})]})}function Er(){let{t:e}=Z(`settings`);return(0,$.jsx)(rn,{id:`text-to-speech`,title:e(`textToSpeechCard.title`),subtitle:e(`textToSpeechCard.subtitle`),children:(0,$.jsx)(Tr,{})})}var Dr=`default`;function Or(){let{t:e}=Z(`settings`),t=Be(),n=X(),{data:r}=Y({...s({path:{assistant_id:t}}),staleTime:3e4}),i=ce({onSuccess:e=>{ae(n,{path:{assistant_id:t}},e)}}),a=fn(),o=(0,Q.useMemo)(()=>r?r.services?.[`web-fetch`]?.provider||W(`vellum:ai:webFetchProvider`,Dr):W(Pe,Dr),[r]),c=(0,Q.useMemo)(()=>r?.services?.[`web-fetch`]?.apiBase??``,[r]),[l,d]=(0,Q.useState)(!1),[f,p]=pn(o),[m,g]=pn(c),[_,b]=(0,Q.useState)(``),x=y.has(f),S=j.has(f),{hasStoredCredential:C}=Fe({assistantId:t,credentialKind:`api_key`,credentialName:f,enabled:S}),w=_.trim().length>0,T=m.trim(),E=x&&T.length>0,D=f!==o||x&&T!==c.trim(),O=l||S&&!E&&!C&&!w||!D&&!w,A=vt(ve[f]??e(`webFetchCard.apiKeyPlaceholder`),C),M=Ct[f]??``,N=(0,Q.useCallback)(async()=>{d(!0);let r=_.trim(),o=S&&r.length>0;try{o&&await a(f,r),await i.mutateAsync({path:{assistant_id:t},body:{services:{"web-fetch":{provider:f,...x?{apiBase:T}:{}}}}}).catch(t=>{throw u.error(e(`webFetchCard.configUpdateFailedToast`)),z(t,{context:`patch_daemon_config`}),t})}catch{d(!1);return}d(!1);try{if(K(Pe,f),o){let e=h(f);e&&K(e,r);let i=Dt(t,`api_key`,f);n.setQueryData(i,!0),n.invalidateQueries({queryKey:i}),b(``)}u.success(e(`webFetchCard.savedToast`))}catch(t){z(t,{context:`settings-ai-web-fetch-persist-local`}),u.error(e(`webFetchCard.localPreferencesFailedToast`))}},[S,i,a,n,t,_,f,x,T,e]),P=(0,Q.useCallback)(()=>{let e=h(f);e&&v(e),b(``),g(``),p(Dr),K(Pe,Dr)},[f,p,g]);return(0,$.jsx)(rn,{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)(G,{value:f,onChange:p,options:Se.map(e=>({value:e,label:k[e]??e}))})]}),x&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(F,{label:e(`webFetchCard.apiBaseLabel`),type:`url`,value:m,onChange:e=>g(e.target.value),placeholder:M||e(`webFetchCard.apiBasePlaceholder`),fullWidth:!0}),M?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webFetchCard.apiBaseHint`,{defaultBase:M})}):null]}),S&&(0,$.jsx)(F,{label:e(`webFetchCard.apiKeyLabel`),type:`password`,value:_,onChange:e=>b(e.target.value),placeholder:A,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(on,{onClick:N,disabled:O}),l&&(0,$.jsx)(en,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),S&&(0,$.jsx)(an,{onClick:P,filled:!0})]})]})})}var kr=`0.10.12`;function Ar(){return pt(kr)}function jr(){let{t:e}=Z(`settings`),t=Be(),n=X(),r=Rt(),{data:i}=Y({...s({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),o=ce({onSuccess:e=>{ae(n,{path:{assistant_id:t}},e)}}),c=fn(),l=(0,Q.useMemo)(()=>{if(!i)return W(Lt,`inference-provider-native`);let e=i.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||W(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[i]),d=(0,Q.useMemo)(()=>i?.services?.[`web-search`]?.apiBase??``,[i]),[f,p]=(0,Q.useState)(!1),[m,h]=pn(l),[g,_]=pn(d),[y,x]=(0,Q.useState)(``),S=ne.has(m),w=Vt.has(m),T=a.has(m),{hasStoredCredential:E}=Fe({assistantId:t,credentialKind:`api_key`,credentialName:m,enabled:w}),D=y.trim().length>0,O=g.trim(),k=S&&O.length>0,A=m!==l||S&&O!==d.trim(),j=f||w&&!T&&!k&&!E&&!D||!A&&!D,M=vt(pe[m]??e(`webSearchCard.apiKeyPlaceholder`),E),N=ue[m]??``,P=(0,Q.useCallback)(async()=>{p(!0);let r=y.trim(),i=C(m),a=w&&r.length>0;try{a&&await c(m,r),await _t();let n=m===`vellum`?Ar()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:m,mode:`your-own`,...S?{apiBase:O}:{}};await o.mutateAsync({path:{assistant_id:t},body:{services:{"web-search":n}}}).catch(t=>{throw u.error(e(`webSearchCard.configUpdateFailedToast`)),z(t,{context:`patch_daemon_config`}),t})}catch{p(!1);return}p(!1);try{if(K(Lt,m),a){i&&K(i,r);let e=Dt(t,`api_key`,m);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),x(``)}u.success(e(`webSearchCard.savedToast`))}catch(t){z(t,{context:`settings-ai-web-search-persist-local`}),u.error(e(`webSearchCard.localPreferencesFailedToast`))}},[w,o,c,n,t,y,m,S,O,e]),I=(0,Q.useCallback)(()=>{let e=C(m);e&&v(e),x(``),_(``),h(`inference-provider-native`),K(Lt,`inference-provider-native`)},[m,h,_]);return(0,$.jsx)(rn,{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)(G,{"aria-label":e(`webSearchCard.providerAriaLabel`),value:m,onChange:h,options:se.map(e=>({value:e,label:b[e]??e}))})]}),m===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.vellumNote`)}),S&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(F,{label:e(`webSearchCard.apiBaseLabel`),type:`url`,value:g,onChange:e=>_(e.target.value),placeholder:N||e(`webSearchCard.apiBasePlaceholder`),fullWidth:!0}),N?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.apiBaseHint`,{defaultBase:N})}):null]}),w&&(0,$.jsx)(F,{label:e(`webSearchCard.apiKeyLabel`),type:`password`,value:y,onChange:e=>x(e.target.value),placeholder:M,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(on,{onClick:P,disabled:j}),f&&(0,$.jsx)(en,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),w&&(0,$.jsx)(an,{onClick:I,filled:!0})]})]})})}function Mr(){let e=Be(),t=Oe(),[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)(Jn,{}),(0,$.jsx)(Kn,{panel:n,onOpenPanel:r,onClosePanel:()=>r(null)}),(0,$.jsx)(jr,{}),(0,$.jsx)(Or,{}),(0,$.jsx)(_n,{}),(0,$.jsx)(Er,{}),(0,$.jsx)(vr,{})]}),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)(sr,{assistantId:e,onClose:()=>r(null)},a):o?(0,$.jsx)(ur,{assistantId:e,connectionName:n.kind===`provider`?n.name:null,onClose:()=>r(null)},a):(0,$.jsx)(Yn,{assistantId:e,profileName:n.kind===`profile`?n.name:null,onClose:()=>r(null)},a):null;return s&&t?(0,$.jsx)(cn,{children:s}):s?(0,$.jsx)(un,{storageKey:`aiSettingsDetailDrawerWidth`,detailKey:a,section:i,detail:s}):i}export{Mr as AiPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Qm as t,X_ as n}from"./app-DFXcEvsi.js";import{x as r}from"./react-B9IgSVeK.js";var i=e(r(),1);function a(e){return new URL(e,window.location.origin).toString()}function o(e){n(a(e))}function s(e){let{open:n,path:r,onClose:a}=e,s=t(),c=(0,i.useRef)(a);return(0,i.useEffect)(()=>{c.current=a}),(0,i.useEffect)(()=>{s&&n&&(o(r),c.current())},[s,n,r]),s}export{s as n,o as t};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Qm as t,X_ as n}from"./app-p4YU9h0P.js";import{x as r}from"./react-B9IgSVeK.js";var i=e(r(),1);function a(e){return new URL(e,window.location.origin).toString()}function o(e){n(a(e))}function s(e){let{open:n,path:r,onClose:a}=e,s=t(),c=(0,i.useRef)(a);return(0,i.useEffect)(()=>{c.current=a}),(0,i.useEffect)(()=>{s&&n&&(o(r),c.current())},[s,n,r]),s}export{s as n,o as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Eb as t,Hr as n,Kr as r,Nx as i,Tb as a,Ux as o,_v as s,px as c}from"./app-DFXcEvsi.js";import{j as l}from"./vendor-DYOeoIwg.js";import{_ as u,f as d,t as f,x as p}from"./react-B9IgSVeK.js";import{a as m,c as h,i as g,o as _,r as v,s as y}from"./provider-key-fvCko3IH.js";import"./onboarding-step-layout-XiwLE8P3.js";var b=e(p(),1),x=f();function S(){let{t:e}=l(`onboarding`),f=d(),[p]=u(),S=p.get(`hosting`),C=t(),w=v(),[T,E]=(0,b.useState)(()=>w?.provider??m.id),[D,O]=(0,b.useState)(()=>w?.key??``),[k,A]=(0,b.useState)(()=>w?.model??y(w?.provider??m.id)??``),[j,M]=(0,b.useState)(()=>w?.baseUrl??``),[N,P]=(0,b.useState)(()=>w?.customModels??``),F=h(T)??m,I=F.models??[],L=F.requiresKey,R=I.length>0,z=T===`openai-compatible`,B=(!(L&&!z)||D.trim().length>0)&&(!R||k.trim().length>0)&&(!z||j.trim().length>0&&N.trim().length>0);return(0,x.jsx)(n,{avatarWave:`beside`,children:(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${C?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`px-6 py-16`} text-[var(--content-default)]`,children:[(0,x.jsx)(`h1`,{className:C?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:e(`apiKeyScreen.title`)}),(0,x.jsx)(`p`,{className:`text-center text-body-medium-lighter text-[var(--content-tertiary)] ${C?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:e(`apiKeyScreen.body`)}),(0,x.jsxs)(`div`,{className:`flex w-full flex-col gap-4 ${C?`mt-8`:`mt-10`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:[(0,x.jsxs)(`div`,{className:`flex flex-col ${C?`gap-2`:`gap-1`}`,children:[(0,x.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e(`apiKeyScreen.providerLabel`)}),(0,x.jsx)(c,{"aria-label":e(`apiKeyScreen.providerLabel`),value:T,onChange:e=>{let t=h(e);t&&(E(t.id),O(``),A(y(t.id)??``))},options:_.map(e=>({value:e.id,label:e.displayName}))})]}),I.length>0&&(0,x.jsxs)(`div`,{className:`flex flex-col ${C?`gap-2`:`gap-1`}`,children:[(0,x.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e(`apiKeyScreen.modelLabel`)}),(0,x.jsx)(c,{"aria-label":e(`apiKeyScreen.modelLabel`),value:k,onChange:A,options:I.map(e=>({value:e.id,label:e.displayName}))})]}),z&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`flex flex-col ${C?`gap-2`:`gap-1`}`,children:[(0,x.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e(`apiKeyScreen.baseUrlLabel`)}),(0,x.jsx)(i,{type:`text`,placeholder:`http://localhost:1234/v1`,value:j,onChange:e=>M(e.target.value),fullWidth:!0})]}),(0,x.jsxs)(`div`,{className:`flex flex-col ${C?`gap-2`:`gap-1`}`,children:[(0,x.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e(`apiKeyScreen.modelsLabel`)}),(0,x.jsx)(i,{type:`text`,placeholder:e(`apiKeyScreen.modelsPlaceholder`),value:N,onChange:e=>P(e.target.value),fullWidth:!0}),(0,x.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`apiKeyScreen.modelsHelp`)})]})]}),L&&(0,x.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,x.jsx)(i,{type:`password`,label:e(`apiKeyScreen.apiKeyLabel`,{provider:F.displayName}),placeholder:F.apiKeyPlaceholder??e(`apiKeyScreen.apiKeyPlaceholder`),value:D,onChange:e=>O(e.target.value),className:`touch-mobile:text-[16px]`,fullWidth:!0}),F.docsUrl&&(0,x.jsxs)(`p`,{className:`self-start text-body-medium-lighter text-[var(--content-tertiary)]`,children:[e(`apiKeyScreen.noKeyPrompt`),` `,(0,x.jsx)(`a`,{href:F.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[var(--content-default)] underline`,children:e(`apiKeyScreen.getKeyLink`)})]})]})]}),(0,x.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${C?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[(0,x.jsx)(o,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:!B,onClick:()=>{if(!B)return;let e=k.trim()||y(T);g({provider:T,key:D.trim(),...e?{model:e}:{},...z?{baseUrl:j.trim(),customModels:N.trim()}:{}});let t=new URLSearchParams({[s]:`1`});S&&t.set(`hosting`,S),f(`${a.onboarding.privacy}?${t.toString()}`,r)},className:C?void 0:`h-11 text-base`,children:e(`actions.continue`)}),(0,x.jsx)(o,{variant:`outlined`,size:`regular`,fullWidth:!0,onClick:()=>{f(a.onboarding.hosting,r)},className:C?void 0:`h-11 text-base`,children:e(`actions.back`)})]})]})})}export{S as ApiKeyScreen};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Eb as t,Hr as n,Kr as r,Nx as i,Tb as a,Ux as o,_v as s,px as c}from"./app-p4YU9h0P.js";import{j as l}from"./vendor-DYOeoIwg.js";import{_ as u,f as d,t as f,x as p}from"./react-B9IgSVeK.js";import{a as m,c as h,i as g,o as _,r as v,s as y}from"./provider-key-CYTAv7Kh.js";import"./onboarding-step-layout-XiwLE8P3.js";var b=e(p(),1),x=f();function S(){let{t:e}=l(`onboarding`),f=d(),[p]=u(),S=p.get(`hosting`),C=t(),w=v(),[T,E]=(0,b.useState)(()=>w?.provider??m.id),[D,O]=(0,b.useState)(()=>w?.key??``),[k,A]=(0,b.useState)(()=>w?.model??y(w?.provider??m.id)??``),[j,M]=(0,b.useState)(()=>w?.baseUrl??``),[N,P]=(0,b.useState)(()=>w?.customModels??``),F=h(T)??m,I=F.models??[],L=F.requiresKey,R=I.length>0,z=T===`openai-compatible`,B=(!(L&&!z)||D.trim().length>0)&&(!R||k.trim().length>0)&&(!z||j.trim().length>0&&N.trim().length>0);return(0,x.jsx)(n,{avatarWave:`beside`,children:(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${C?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`px-6 py-16`} text-[var(--content-default)]`,children:[(0,x.jsx)(`h1`,{className:C?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:e(`apiKeyScreen.title`)}),(0,x.jsx)(`p`,{className:`text-center text-body-medium-lighter text-[var(--content-tertiary)] ${C?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:e(`apiKeyScreen.body`)}),(0,x.jsxs)(`div`,{className:`flex w-full flex-col gap-4 ${C?`mt-8`:`mt-10`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:[(0,x.jsxs)(`div`,{className:`flex flex-col ${C?`gap-2`:`gap-1`}`,children:[(0,x.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e(`apiKeyScreen.providerLabel`)}),(0,x.jsx)(c,{"aria-label":e(`apiKeyScreen.providerLabel`),value:T,onChange:e=>{let t=h(e);t&&(E(t.id),O(``),A(y(t.id)??``))},options:_.map(e=>({value:e.id,label:e.displayName}))})]}),I.length>0&&(0,x.jsxs)(`div`,{className:`flex flex-col ${C?`gap-2`:`gap-1`}`,children:[(0,x.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e(`apiKeyScreen.modelLabel`)}),(0,x.jsx)(c,{"aria-label":e(`apiKeyScreen.modelLabel`),value:k,onChange:A,options:I.map(e=>({value:e.id,label:e.displayName}))})]}),z&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`flex flex-col ${C?`gap-2`:`gap-1`}`,children:[(0,x.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e(`apiKeyScreen.baseUrlLabel`)}),(0,x.jsx)(i,{type:`text`,placeholder:`http://localhost:1234/v1`,value:j,onChange:e=>M(e.target.value),fullWidth:!0})]}),(0,x.jsxs)(`div`,{className:`flex flex-col ${C?`gap-2`:`gap-1`}`,children:[(0,x.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e(`apiKeyScreen.modelsLabel`)}),(0,x.jsx)(i,{type:`text`,placeholder:e(`apiKeyScreen.modelsPlaceholder`),value:N,onChange:e=>P(e.target.value),fullWidth:!0}),(0,x.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`apiKeyScreen.modelsHelp`)})]})]}),L&&(0,x.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,x.jsx)(i,{type:`password`,label:e(`apiKeyScreen.apiKeyLabel`,{provider:F.displayName}),placeholder:F.apiKeyPlaceholder??e(`apiKeyScreen.apiKeyPlaceholder`),value:D,onChange:e=>O(e.target.value),className:`touch-mobile:text-[16px]`,fullWidth:!0}),F.docsUrl&&(0,x.jsxs)(`p`,{className:`self-start text-body-medium-lighter text-[var(--content-tertiary)]`,children:[e(`apiKeyScreen.noKeyPrompt`),` `,(0,x.jsx)(`a`,{href:F.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[var(--content-default)] underline`,children:e(`apiKeyScreen.getKeyLink`)})]})]})]}),(0,x.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${C?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[(0,x.jsx)(o,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:!B,onClick:()=>{if(!B)return;let e=k.trim()||y(T);g({provider:T,key:D.trim(),...e?{model:e}:{},...z?{baseUrl:j.trim(),customModels:N.trim()}:{}});let t=new URLSearchParams({[s]:`1`});S&&t.set(`hosting`,S),f(`${a.onboarding.privacy}?${t.toString()}`,r)},className:C?void 0:`h-11 text-base`,children:e(`actions.continue`)}),(0,x.jsx)(o,{variant:`outlined`,size:`regular`,fullWidth:!0,onClick:()=>{f(a.onboarding.hosting,r)},className:C?void 0:`h-11 text-base`,children:e(`actions.back`)})]})]})})}export{S as ApiKeyScreen};
@@ -1 +1 @@
1
- import{Eb as e}from"./app-DFXcEvsi.js";async function t(){return e()?await window.vellum?.app.versionInfo()??null:null}async function n(){e()&&await window.vellum?.app.openWebsite()}export{n,t};
1
+ import{Eb as e}from"./app-p4YU9h0P.js";async function t(){return e()?await window.vellum?.app.versionInfo()??null:null}async function n(){e()&&await window.vellum?.app.openWebsite()}export{n,t};