@vellumai/web 0.8.7-dev.202606052232.2ddc989 → 0.8.8-dev.202606052332.17fc8ea

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 (71) hide show
  1. package/dist/assets/{account-page-BiBMYABT.js → account-page-D9ieQhLb.js} +1 -1
  2. package/dist/assets/{add-credits-modal-BnkD4oSj.js → add-credits-modal-CbR1WQ39.js} +1 -1
  3. package/dist/assets/{advanced-page-CTM9ByJs.js → advanced-page-B2-Dxt6w.js} +1 -1
  4. package/dist/assets/{ai-page-D4pxJbNn.js → ai-page-De9FJuZk.js} +1 -1
  5. package/dist/assets/{archive-page-CSspL6oa.js → archive-page-DjsGaMFO.js} +1 -1
  6. package/dist/assets/{assistant-status-panel-GQ4MBaan.js → assistant-status-panel-DS1a-BkB.js} +1 -1
  7. package/dist/assets/{billing-page-BS8qVqsa.js → billing-page-DBH7feV9.js} +1 -1
  8. package/dist/assets/{command-palette-doCEl_ro.js → command-palette-D1ZzGyBc.js} +1 -1
  9. package/dist/assets/{community-page-C16cwwBL.js → community-page-C0ZzRdyS.js} +1 -1
  10. package/dist/assets/{connect-page-BCxdL8Jq.js → connect-page-UvWOjsaE.js} +1 -1
  11. package/dist/assets/{contacts-page-route-BDv_9GZ0.js → contacts-page-route-pj3hPE9P.js} +1 -1
  12. package/dist/assets/{debug-page--WT90LG1.js → debug-page-BUtGvDxR.js} +2 -2
  13. package/dist/assets/{deploy-dialogs-Bnsia9oU.js → deploy-dialogs-cg44W61S.js} +1 -1
  14. package/dist/assets/{developer-page-jgraj43o.js → developer-page-CJl3mX8c.js} +1 -1
  15. package/dist/assets/{devices-page-BRAQG74I.js → devices-page-C1flF26j.js} +1 -1
  16. package/dist/assets/{document-viewer-page-DZSH_KXd.js → document-viewer-page-Dj_g4JCV.js} +1 -1
  17. package/dist/assets/{earn-credits-modal-xyZYOdPP.js → earn-credits-modal-SBh4BzrC.js} +1 -1
  18. package/dist/assets/{emails-page-SNlhYBQq.js → emails-page-Dj_SZpJx.js} +1 -1
  19. package/dist/assets/{general-page-Dw5lzX9J.js → general-page-CZMMjoD3.js} +1 -1
  20. package/dist/assets/{hatching-screen-Q3XECwIH.js → hatching-screen-DfSk81B-.js} +1 -1
  21. package/dist/assets/{home-page-route-D1gJnqOJ.js → home-page-route-DdwOXcgm.js} +1 -1
  22. package/dist/assets/{hosting-screen-D6IVMcMS.js → hosting-screen-XuTESqkt.js} +1 -1
  23. package/dist/assets/identity-page-route-BuE2mbtR.js +1 -0
  24. package/dist/assets/index-Byws1OMu.js +124 -0
  25. package/dist/assets/{inspect-page-Bc6T9uiq.js → inspect-page-C8hjaKFb.js} +1 -1
  26. package/dist/assets/{install-CqQAdH7r.js → install-BoabKlGA.js} +1 -1
  27. package/dist/assets/{integrations-page-O1TEamRL.js → integrations-page-uHffcFWa.js} +1 -1
  28. package/dist/assets/{intelligence-layout-CK1ONzMq.js → intelligence-layout-Cmo5qG7D.js} +1 -1
  29. package/dist/assets/{library-detail-page-DSVyFZMh.js → library-detail-page-J-pibC1D.js} +1 -1
  30. package/dist/assets/{library-page-FryrD29R.js → library-page-BYSOcWZP.js} +1 -1
  31. package/dist/assets/{login-flow-YoZiK8pc.js → login-flow-BSo9NuDo.js} +1 -1
  32. package/dist/assets/{login-page-N9rNKdE4.js → login-page-BxhZAIcp.js} +1 -1
  33. package/dist/assets/{logout-page-BlH38xxk.js → logout-page-mNeBVzCS.js} +1 -1
  34. package/dist/assets/{logs-layout-dVZP7y5S.js → logs-layout-PinehuDE.js} +1 -1
  35. package/dist/assets/{memory-router-playground-page-CR1ipK38.js → memory-router-playground-page-CGs0kBrH.js} +1 -1
  36. package/dist/assets/{mobile-sidebar-drawer-B18QHDel.js → mobile-sidebar-drawer-Bvs3iVvj.js} +1 -1
  37. package/dist/assets/{notifications-page-5Etr_SRn.js → notifications-page-z1owPY7D.js} +1 -1
  38. package/dist/assets/{oauth-complete-page-DdkJeVpO.js → oauth-complete-page-D3ICmuGS.js} +1 -1
  39. package/dist/assets/{oauth-popup-complete-page-Z_ICryrb.js → oauth-popup-complete-page-BhHdXB8J.js} +2 -2
  40. package/dist/assets/{plugins-page-CwkVF9QF.js → plugins-page-DrfGJPNY.js} +1 -1
  41. package/dist/assets/pre-chat-flow-Bc3w6Kxf.js +1 -0
  42. package/dist/assets/{privacy-page-CX4-SR5S.js → privacy-page-bdVaAafA.js} +1 -1
  43. package/dist/assets/{privacy-screen-BlkfCqKf.js → privacy-screen-DUS9zQO1.js} +1 -1
  44. package/dist/assets/{provider-callback-page-DY_r1O5H.js → provider-callback-page-B3DESwuO.js} +1 -1
  45. package/dist/assets/{provider-signup-page-D6hTVQgJ.js → provider-signup-page-BuP3aFFP.js} +1 -1
  46. package/dist/assets/{schedules-page-nXeTZw2c.js → schedules-page-l9RDxQj8.js} +1 -1
  47. package/dist/assets/{settings-layout-D48zDU-G.js → settings-layout-CP6TBHhP.js} +1 -1
  48. package/dist/assets/{share-feedback-modal-HxZUa0Ql.js → share-feedback-modal-CqMSXA48.js} +1 -1
  49. package/dist/assets/{sidebar-tree-TZtCYoFo.js → sidebar-tree-aGQ67ydN.js} +1 -1
  50. package/dist/assets/{signup-page-9RqRMZse.js → signup-page-BUjjUFwI.js} +1 -1
  51. package/dist/assets/{skills-page-DwZbBgsd.js → skills-page-V2Ap_1Nl.js} +1 -1
  52. package/dist/assets/{sounds-page-CUiVOLN8.js → sounds-page-DoklJSF7.js} +1 -1
  53. package/dist/assets/{step-indicator-dots-Bef_HABf.js → step-indicator-dots-Bm0kxLBB.js} +1 -1
  54. package/dist/assets/{subagent-detail-panel-CaJSI4fI.js → subagent-detail-panel-DERepumn.js} +2 -2
  55. package/dist/assets/{system-events-page-BPAFAOyb.js → system-events-page-CZ5bKf0W.js} +1 -1
  56. package/dist/assets/{tiptap-document-editor-BQqVV46h.js → tiptap-document-editor-B9Tho-o2.js} +1 -1
  57. package/dist/assets/{tool-detail-panel-bd15yZOi.js → tool-detail-panel-DAR1Gwto.js} +1 -1
  58. package/dist/assets/{trace-page-CcJ5f1s8.js → trace-page-CqmK0wMM.js} +1 -1
  59. package/dist/assets/{upgrade-cancel-page-CCGPhKky.js → upgrade-cancel-page-7Auf5tST.js} +1 -1
  60. package/dist/assets/{upgrade-success-page-DaxBtc0m.js → upgrade-success-page-DsJJ6dsP.js} +1 -1
  61. package/dist/assets/{usage-page-B-E9ob9F.js → usage-page-Ddum0hfO.js} +1 -1
  62. package/dist/assets/{use-current-platform-assistant-B3gP7gen.js → use-current-platform-assistant-CQU1hSXO.js} +1 -1
  63. package/dist/assets/{use-oauth-complete-deep-link-listener-ZuAGEydM.js → use-oauth-complete-deep-link-listener-3roRJO5m.js} +1 -1
  64. package/dist/assets/{voice-page-BIVGEiiK.js → voice-page-DcyuaOFj.js} +1 -1
  65. package/dist/assets/{weather-forecast-display-Co0Tm-Os.js → weather-forecast-display-B-syIc4v.js} +1 -1
  66. package/dist/assets/{workspace-page-CEddn9j8.js → workspace-page-BKoiZbHO.js} +1 -1
  67. package/dist/index.html +1 -1
  68. package/package.json +1 -1
  69. package/dist/assets/identity-page-route-Cqpwctvb.js +0 -1
  70. package/dist/assets/index-DmTi6dG-.js +0 -124
  71. package/dist/assets/pre-chat-flow-DRxx1hYL.js +0 -1
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./chunk-5KNZJZUH-BpLAEZ0-.js";import{t as r}from"./jsx-runtime-XSukodg_.js";import{a as i,i as a,n as o}from"./auth-store-NinzEiLF.js";import{d as s}from"./native-biometric-V5gaOHYQ.js";import{i as c}from"./routes-Dfo11DAg.js";import{lt as l}from"./index-DmTi6dG-.js";import{r as u,t as d}from"./account-shell-BZu7oVl3.js";import{n as f,t as p}from"./login-flow-YoZiK8pc.js";var m=e(t(),1),h=r();function g(){let e=a(),t=i(),r=o.use.user(),g=o.use.logout(),[_,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(!1),x=async()=>{v(null),b(!0);try{await s(f,p)}catch(e){console.error(`[account] auth flow failed:`,e),v(`Something went wrong. Please try again.`),b(!1)}};return t?(0,h.jsx)(d,{children:(0,h.jsx)(u,{title:`Loading...`})}):e?(0,h.jsxs)(d,{children:[(0,h.jsx)(u,{title:`Welcome${r?.username?`, ${r.username}`:``}!`,subtitle:`You are signed in.`}),(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,h.jsx)(n,{to:c.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-white no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:`Go to your assistant`}),(0,h.jsx)(`button`,{type:`button`,onClick:async()=>{await g(),l(c.account.login)},className:`cursor-pointer bg-transparent text-sm font-normal text-stone-400 transition-colors hover:text-stone-300`,children:`Sign out`})]})]}):(0,h.jsxs)(d,{children:[(0,h.jsx)(u,{title:`Welcome to Vellum`,subtitle:`Sign in to get started.`}),_&&(0,h.jsx)(`p`,{className:`text-center text-sm text-[var(--system-negative-strong)]`,children:_}),(0,h.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,h.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:y,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-white transition-colors hover:bg-[var(--primary-hover)] disabled:opacity-50`,children:`Sign in`})})]})}export{g as AccountPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./chunk-5KNZJZUH-BpLAEZ0-.js";import{t as r}from"./jsx-runtime-XSukodg_.js";import{a as i,i as a,n as o}from"./auth-store-NinzEiLF.js";import{d as s}from"./native-biometric-V5gaOHYQ.js";import{i as c}from"./routes-Dfo11DAg.js";import{lt as l}from"./index-Byws1OMu.js";import{r as u,t as d}from"./account-shell-BZu7oVl3.js";import{n as f,t as p}from"./login-flow-BSo9NuDo.js";var m=e(t(),1),h=r();function g(){let e=a(),t=i(),r=o.use.user(),g=o.use.logout(),[_,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(!1),x=async()=>{v(null),b(!0);try{await s(f,p)}catch(e){console.error(`[account] auth flow failed:`,e),v(`Something went wrong. Please try again.`),b(!1)}};return t?(0,h.jsx)(d,{children:(0,h.jsx)(u,{title:`Loading...`})}):e?(0,h.jsxs)(d,{children:[(0,h.jsx)(u,{title:`Welcome${r?.username?`, ${r.username}`:``}!`,subtitle:`You are signed in.`}),(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,h.jsx)(n,{to:c.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-white no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:`Go to your assistant`}),(0,h.jsx)(`button`,{type:`button`,onClick:async()=>{await g(),l(c.account.login)},className:`cursor-pointer bg-transparent text-sm font-normal text-stone-400 transition-colors hover:text-stone-300`,children:`Sign out`})]})]}):(0,h.jsxs)(d,{children:[(0,h.jsx)(u,{title:`Welcome to Vellum`,subtitle:`Sign in to get started.`}),_&&(0,h.jsx)(`p`,{className:`text-center text-sm text-[var(--system-negative-strong)]`,children:_}),(0,h.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,h.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:y,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-white transition-colors hover:bg-[var(--primary-hover)] disabled:opacity-50`,children:`Sign in`})})]})}export{g as AccountPage};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./chunk-jRWAZmH_.js";import{t as n}from"./react-DJZBPgpf.js";import{m as r,t as i,u as a}from"./chunk-5KNZJZUH-BpLAEZ0-.js";import{n as o}from"./QueryClientProvider-DBAeGN3q.js";import{t as s}from"./useQuery-DAtrV0RI.js";import{t as c}from"./useMutation-DTb3lMvF.js";import{t as l}from"./jsx-runtime-XSukodg_.js";import{t as u}from"./button-Cs9tc8OR.js";import{t as d}from"./dropdown-PPtOL9bp.js";import{t as f}from"./modal-C7CS3Y_X.js";import{t as p}from"./loader-circle-FEkI0Am4.js";import{$ as m,Ga as h,et as g,gn as _,uo as v,vn as y}from"./index-DmTi6dG-.js";var b=t({AddCreditsModal:()=>E}),x=e(n(),1),S=l(),C=[`10.00`,`20.00`,`30.00`,`40.00`,`50.00`,`60.00`,`70.00`,`80.00`,`90.00`,`100.00`];function w(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 T(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 E({open:e,onOpenChange:t}){let n=o(),{pathname:l}=a(),[b]=r(),E=b.toString()?`${l}?${b.toString()}`:l,{data:D,isLoading:O}=s(_()),k=D?.allowed_top_up_amounts?.length?D.allowed_top_up_amounts:C,[A,j]=(0,x.useState)(null),M=A&&k.includes(A)?A:k[0]??C[0],N=c(y());return(0,x.useEffect)(()=>g(()=>{t(!1),n.invalidateQueries(_())}),[t,n]),(0,S.jsx)(f.Root,{open:e,onOpenChange:t,children:(0,S.jsxs)(f.Content,{size:`sm`,children:[(0,S.jsxs)(f.Header,{children:[(0,S.jsx)(f.Title,{icon:h,children:`Add Credits`}),(0,S.jsx)(f.Description,{children:`Purchase credits to continue using the assistant. You'll be redirected to Stripe to complete the payment.`})]}),(0,S.jsx)(f.Body,{children:(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`add-credits-amount`,className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Amount`}),(0,S.jsx)(d,{id:`add-credits-amount`,value:M,onChange:e=>{j(e),N.isError&&N.reset()},disabled:O||!D,options:k.map(e=>({value:e,label:w(e)}))})]}),N.isError&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,S.jsx)(v,{className:`h-3.5 w-3.5 shrink-0`}),T(N.error)]}),(0,S.jsx)(i,{to:`/assistant/settings/billing`,className:`text-body-small-default text-[var(--content-tertiary)] underline hover:text-[var(--content-secondary)]`,onClick:()=>t(!1),children:`Configure Automatic Top-Ups →`})]})}),(0,S.jsxs)(f.Footer,{children:[(0,S.jsx)(f.Close,{asChild:!0,children:(0,S.jsx)(u,{variant:`outlined`,children:`Cancel`})}),(0,S.jsx)(u,{variant:`primary`,leftIcon:N.isPending?(0,S.jsx)(p,{className:`animate-spin`}):void 0,onClick:()=>{N.isPending||N.mutate({body:{amount:M,return_path:E}},{onSuccess:e=>{m(e.checkout_url)}})},disabled:N.isPending||O||!D,children:`Add credits`})]})]})})}export{b as n,E as t};
1
+ import{o as e,r as t}from"./chunk-jRWAZmH_.js";import{t as n}from"./react-DJZBPgpf.js";import{m as r,t as i,u as a}from"./chunk-5KNZJZUH-BpLAEZ0-.js";import{n as o}from"./QueryClientProvider-DBAeGN3q.js";import{t as s}from"./useQuery-DAtrV0RI.js";import{t as c}from"./useMutation-DTb3lMvF.js";import{t as l}from"./jsx-runtime-XSukodg_.js";import{t as u}from"./button-Cs9tc8OR.js";import{t as d}from"./dropdown-PPtOL9bp.js";import{t as f}from"./modal-C7CS3Y_X.js";import{t as p}from"./loader-circle-FEkI0Am4.js";import{$ as m,Ga as h,et as g,gn as _,uo as v,vn as y}from"./index-Byws1OMu.js";var b=t({AddCreditsModal:()=>E}),x=e(n(),1),S=l(),C=[`10.00`,`20.00`,`30.00`,`40.00`,`50.00`,`60.00`,`70.00`,`80.00`,`90.00`,`100.00`];function w(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 T(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 E({open:e,onOpenChange:t}){let n=o(),{pathname:l}=a(),[b]=r(),E=b.toString()?`${l}?${b.toString()}`:l,{data:D,isLoading:O}=s(_()),k=D?.allowed_top_up_amounts?.length?D.allowed_top_up_amounts:C,[A,j]=(0,x.useState)(null),M=A&&k.includes(A)?A:k[0]??C[0],N=c(y());return(0,x.useEffect)(()=>g(()=>{t(!1),n.invalidateQueries(_())}),[t,n]),(0,S.jsx)(f.Root,{open:e,onOpenChange:t,children:(0,S.jsxs)(f.Content,{size:`sm`,children:[(0,S.jsxs)(f.Header,{children:[(0,S.jsx)(f.Title,{icon:h,children:`Add Credits`}),(0,S.jsx)(f.Description,{children:`Purchase credits to continue using the assistant. You'll be redirected to Stripe to complete the payment.`})]}),(0,S.jsx)(f.Body,{children:(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`add-credits-amount`,className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Amount`}),(0,S.jsx)(d,{id:`add-credits-amount`,value:M,onChange:e=>{j(e),N.isError&&N.reset()},disabled:O||!D,options:k.map(e=>({value:e,label:w(e)}))})]}),N.isError&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,S.jsx)(v,{className:`h-3.5 w-3.5 shrink-0`}),T(N.error)]}),(0,S.jsx)(i,{to:`/assistant/settings/billing`,className:`text-body-small-default text-[var(--content-tertiary)] underline hover:text-[var(--content-secondary)]`,onClick:()=>t(!1),children:`Configure Automatic Top-Ups →`})]})}),(0,S.jsxs)(f.Footer,{children:[(0,S.jsx)(f.Close,{asChild:!0,children:(0,S.jsx)(u,{variant:`outlined`,children:`Cancel`})}),(0,S.jsx)(u,{variant:`primary`,leftIcon:N.isPending?(0,S.jsx)(p,{className:`animate-spin`}):void 0,onClick:()=>{N.isPending||N.mutate({body:{amount:M,return_path:E}},{onSuccess:e=>{m(e.checkout_url)}})},disabled:N.isPending||O||!D,children:`Add credits`})]})]})})}export{b as n,E as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{n}from"./QueryClientProvider-DBAeGN3q.js";import{t as r}from"./useQuery-DAtrV0RI.js";import{t as i}from"./useMutation-DTb3lMvF.js";import{t as a}from"./jsx-runtime-XSukodg_.js";import{t as o}from"./button-Cs9tc8OR.js";import{t as s}from"./notice-BWm2kHlI.js";import{t as c}from"./input-DwAJUlac.js";import{t as l}from"./toggle-DGzEs0L1.js";import{n as u}from"./stat-square-CMFH3mHq.js";import{t as d}from"./toast-Cii5pffK.js";import{t as f}from"./loader-circle-FEkI0Am4.js";import{W as p}from"./sdk.gen-Dvq7zGs0.js";import{Jt as m,ft as h,qt as g}from"./index-DmTi6dG-.js";import{t as _}from"./detail-card-Y8InXOgy.js";import{r as v}from"./assistant-status-panel-GQ4MBaan.js";var y=e(t(),1),b=a(),x=[[`Mon`,0],[`Tue`,1],[`Wed`,2],[`Thu`,3],[`Fri`,4],[`Sat`,5],[`Sun`,6]];function S(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),t,n));return`${i.getHours().toString().padStart(2,`0`)}:${i.getMinutes().toString().padStart(2,`0`)}`}function C(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),t,n);return`${i.getUTCHours().toString().padStart(2,`0`)}:${i.getUTCMinutes().toString().padStart(2,`0`)}`}function w(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function T(e){let t=e?.schedule?.window.start??`06:00`,n=e?.schedule?.window.end??`08:00`;return{enabled:e?.enabled??!0,timezone:`UTC`,frequency:e?.schedule?.frequency??`weekly`,daysOfWeek:e?.schedule?.days_of_week??[0],daysOfMonth:e?.schedule?.days_of_month??[],windowStart:S(t),windowEnd:S(n)}}function E({assistantId:e}){let t=n(),{data:a,isLoading:s,isError:h}=r(g({path:{id:e}})),_=(0,y.useMemo)(()=>T(a),[a]),[v,S]=(0,y.useState)(null),E=v??_,D=v!==null,O=(0,y.useMemo)(()=>w(),[]),[k,A]=(0,y.useState)(null),j=k??E.daysOfMonth.join(`, `),M=i({mutationFn:async t=>{let{data:n}=await p({path:{id:e},body:t,throwOnError:!0});return n}}),N=e=>{S(t=>({...t??_,...e}))},P=e=>{N({daysOfWeek:E.daysOfWeek.includes(e)?E.daysOfWeek.filter(t=>t!==e):[...E.daysOfWeek,e].sort((e,t)=>e-t)})},F=e=>e.split(`,`).map(e=>parseInt(e.trim(),10)).filter(e=>!isNaN(e)&&e>=1&&e<=31);return s?(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,b.jsx)(f,{className:`h-4 w-4 animate-spin`}),`Loading update window settings...`]}):h?(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:`Failed to load update window policy. Refresh the page to try again.`}):(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsx)(l,{checked:E.enabled,onChange:e=>N({enabled:e}),label:`Automatic updates`,helperText:`Update automatically during a configured time window`}),E.enabled&&(0,b.jsxs)(`div`,{className:`space-y-5`,children:[(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Frequency`}),(0,b.jsx)(`div`,{className:`max-w-[400px]`,children:(0,b.jsx)(u,{ariaLabel:`Frequency`,value:E.frequency,onChange:e=>{e!==`monthly`&&A(null),N({frequency:e})},items:[{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}]})})]}),E.frequency===`weekly`&&(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Day(s) of week`}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:x.map(([e,t])=>(0,b.jsx)(o,{variant:`outlined`,size:`compact`,active:E.daysOfWeek.includes(t),onClick:()=>P(t),children:e},t))})]}),E.frequency===`monthly`&&(0,b.jsx)(c,{label:`Day(s) of month`,type:`text`,value:j,onChange:e=>A(e.target.value),onBlur:e=>{let t=F(e.target.value);N({daysOfMonth:t}),A(t.join(`, `))},placeholder:`e.g. 1, 15`,helperText:`Comma-separated day numbers (1–31)`,className:`w-48`}),(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:[`Update window`,O?` (${O})`:``]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(c,{type:`time`,value:E.windowStart,onChange:e=>N({windowStart:e.target.value})}),(0,b.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`to`}),(0,b.jsx)(c,{type:`time`,value:E.windowEnd,onChange:e=>N({windowEnd:e.target.value})})]})]})]}),(0,b.jsx)(o,{variant:`primary`,leftIcon:M.isPending?(0,b.jsx)(f,{className:`animate-spin`}):void 0,onClick:async()=>{let n=E.frequency===`monthly`&&k!==null?F(k):E.daysOfMonth;try{await M.mutateAsync({enabled:E.enabled,timezone:`UTC`,schedule:{frequency:E.frequency,days_of_week:E.frequency===`weekly`?E.daysOfWeek:[],days_of_month:E.frequency===`monthly`?n:[],window:{start:C(E.windowStart),end:C(E.windowEnd)}}}),d.success(`Auto-update policy saved.`),S(null),A(null),t.invalidateQueries({queryKey:m({path:{id:e}})})}catch{d.error(`Failed to save policy. Please try again.`)}},disabled:M.isPending||!D,children:`Save policy`})]})}function D(){let{assistant:e}=v(),t=h({platformHostedOnly:!0}),n=e?.is_local?null:e;return(0,b.jsxs)(`div`,{className:`space-y-4`,children:[t===`full`&&n&&(0,b.jsx)(_,{title:`Update Window`,subtitle:`Configure when automatic updates are applied.`,children:(0,b.jsx)(E,{assistantId:n.id})}),t===`disabled`&&(0,b.jsx)(_,{title:`Update Window`,subtitle:`Configure when automatic updates are applied.`,children:(0,b.jsx)(s,{tone:`info`,children:`Log in to the Vellum platform to manage update window policy.`})})]})}export{D as AdvancedPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{n}from"./QueryClientProvider-DBAeGN3q.js";import{t as r}from"./useQuery-DAtrV0RI.js";import{t as i}from"./useMutation-DTb3lMvF.js";import{t as a}from"./jsx-runtime-XSukodg_.js";import{t as o}from"./button-Cs9tc8OR.js";import{t as s}from"./notice-BWm2kHlI.js";import{t as c}from"./input-DwAJUlac.js";import{t as l}from"./toggle-DGzEs0L1.js";import{n as u}from"./stat-square-CMFH3mHq.js";import{t as d}from"./toast-Cii5pffK.js";import{t as f}from"./loader-circle-FEkI0Am4.js";import{W as p}from"./sdk.gen-Dvq7zGs0.js";import{Jt as m,ft as h,qt as g}from"./index-Byws1OMu.js";import{t as _}from"./detail-card-Y8InXOgy.js";import{r as v}from"./assistant-status-panel-DS1a-BkB.js";var y=e(t(),1),b=a(),x=[[`Mon`,0],[`Tue`,1],[`Wed`,2],[`Thu`,3],[`Fri`,4],[`Sat`,5],[`Sun`,6]];function S(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),t,n));return`${i.getHours().toString().padStart(2,`0`)}:${i.getMinutes().toString().padStart(2,`0`)}`}function C(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),t,n);return`${i.getUTCHours().toString().padStart(2,`0`)}:${i.getUTCMinutes().toString().padStart(2,`0`)}`}function w(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function T(e){let t=e?.schedule?.window.start??`06:00`,n=e?.schedule?.window.end??`08:00`;return{enabled:e?.enabled??!0,timezone:`UTC`,frequency:e?.schedule?.frequency??`weekly`,daysOfWeek:e?.schedule?.days_of_week??[0],daysOfMonth:e?.schedule?.days_of_month??[],windowStart:S(t),windowEnd:S(n)}}function E({assistantId:e}){let t=n(),{data:a,isLoading:s,isError:h}=r(g({path:{id:e}})),_=(0,y.useMemo)(()=>T(a),[a]),[v,S]=(0,y.useState)(null),E=v??_,D=v!==null,O=(0,y.useMemo)(()=>w(),[]),[k,A]=(0,y.useState)(null),j=k??E.daysOfMonth.join(`, `),M=i({mutationFn:async t=>{let{data:n}=await p({path:{id:e},body:t,throwOnError:!0});return n}}),N=e=>{S(t=>({...t??_,...e}))},P=e=>{N({daysOfWeek:E.daysOfWeek.includes(e)?E.daysOfWeek.filter(t=>t!==e):[...E.daysOfWeek,e].sort((e,t)=>e-t)})},F=e=>e.split(`,`).map(e=>parseInt(e.trim(),10)).filter(e=>!isNaN(e)&&e>=1&&e<=31);return s?(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,b.jsx)(f,{className:`h-4 w-4 animate-spin`}),`Loading update window settings...`]}):h?(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:`Failed to load update window policy. Refresh the page to try again.`}):(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsx)(l,{checked:E.enabled,onChange:e=>N({enabled:e}),label:`Automatic updates`,helperText:`Update automatically during a configured time window`}),E.enabled&&(0,b.jsxs)(`div`,{className:`space-y-5`,children:[(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Frequency`}),(0,b.jsx)(`div`,{className:`max-w-[400px]`,children:(0,b.jsx)(u,{ariaLabel:`Frequency`,value:E.frequency,onChange:e=>{e!==`monthly`&&A(null),N({frequency:e})},items:[{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}]})})]}),E.frequency===`weekly`&&(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Day(s) of week`}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:x.map(([e,t])=>(0,b.jsx)(o,{variant:`outlined`,size:`compact`,active:E.daysOfWeek.includes(t),onClick:()=>P(t),children:e},t))})]}),E.frequency===`monthly`&&(0,b.jsx)(c,{label:`Day(s) of month`,type:`text`,value:j,onChange:e=>A(e.target.value),onBlur:e=>{let t=F(e.target.value);N({daysOfMonth:t}),A(t.join(`, `))},placeholder:`e.g. 1, 15`,helperText:`Comma-separated day numbers (1–31)`,className:`w-48`}),(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:[`Update window`,O?` (${O})`:``]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(c,{type:`time`,value:E.windowStart,onChange:e=>N({windowStart:e.target.value})}),(0,b.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`to`}),(0,b.jsx)(c,{type:`time`,value:E.windowEnd,onChange:e=>N({windowEnd:e.target.value})})]})]})]}),(0,b.jsx)(o,{variant:`primary`,leftIcon:M.isPending?(0,b.jsx)(f,{className:`animate-spin`}):void 0,onClick:async()=>{let n=E.frequency===`monthly`&&k!==null?F(k):E.daysOfMonth;try{await M.mutateAsync({enabled:E.enabled,timezone:`UTC`,schedule:{frequency:E.frequency,days_of_week:E.frequency===`weekly`?E.daysOfWeek:[],days_of_month:E.frequency===`monthly`?n:[],window:{start:C(E.windowStart),end:C(E.windowEnd)}}}),d.success(`Auto-update policy saved.`),S(null),A(null),t.invalidateQueries({queryKey:m({path:{id:e}})})}catch{d.error(`Failed to save policy. Please try again.`)}},disabled:M.isPending||!D,children:`Save policy`})]})}function D(){let{assistant:e}=v(),t=h({platformHostedOnly:!0}),n=e?.is_local?null:e;return(0,b.jsxs)(`div`,{className:`space-y-4`,children:[t===`full`&&n&&(0,b.jsx)(_,{title:`Update Window`,subtitle:`Configure when automatic updates are applied.`,children:(0,b.jsx)(E,{assistantId:n.id})}),t===`disabled`&&(0,b.jsx)(_,{title:`Update Window`,subtitle:`Configure when automatic updates are applied.`,children:(0,b.jsx)(s,{tone:`info`,children:`Log in to the Vellum platform to manage update window policy.`})})]})}export{D as AdvancedPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,r as n,s as r}from"./local-settings-lVNyIOJ_.js";import{i,t as a}from"./capture-error-23NwnaZt.js";import{t as o}from"./react-DJZBPgpf.js";import{d as s,m as c}from"./chunk-5KNZJZUH-BpLAEZ0-.js";import{n as l}from"./QueryClientProvider-DBAeGN3q.js";import{t as u}from"./useQuery-DAtrV0RI.js";import{t as d}from"./useMutation-DTb3lMvF.js";import{t as f}from"./jsx-runtime-XSukodg_.js";import{t as p}from"./button-Cs9tc8OR.js";import{t as m}from"./typography-PN7B1rrW.js";import{t as h}from"./dropdown-PPtOL9bp.js";import{t as g}from"./confirm-dialog-DavdF-L4.js";import{t as _}from"./notice-BWm2kHlI.js";import{t as v}from"./tag-BkZB4euH.js";import{t as y}from"./input-DwAJUlac.js";import{t as b}from"./toggle-DGzEs0L1.js";import{n as x}from"./stat-square-CMFH3mHq.js";import{t as S}from"./modal-C7CS3Y_X.js";import{t as C}from"./toast-Cii5pffK.js";import{t as w}from"./selection-store-BCKoLRDh.js";import{t as T}from"./createLucideIcon-D8wUFCt3.js";import{n as E,t as D}from"./domain-field-CyNgwvDW.js";import{t as O}from"./external-link-CcV79Arv.js";import{t as k}from"./loader-circle-FEkI0Am4.js";import{C as A,Et as j,Jt as M,Tt as N,Y as P,b as F,yn as I}from"./sdk.gen-up8j0_uF.js";import{C as L,N as R,S as z,s as B}from"./react-query.gen-CfXF72qo.js";import{r as ee}from"./api-errors-DhNZwQy5.js";import{i as te}from"./routes-Dfo11DAg.js";import{t as ne}from"./use-is-org-ready-C0KPmJ3X.js";import{r as V}from"./query-tags-DAoC-jzg.js";import{t as H}from"./assistant-feature-flag-store-XFfKSl8X.js";import{$r as U,Ar as W,At as G,Br as K,Ct as re,Dr as q,Dt as ie,Ea as J,Er as ae,Et as oe,Fr as Y,Gr as se,Hr as X,Ir as ce,Ji as le,Jr as ue,Kr as de,Lr as fe,Mi as pe,Mr as me,Nr as he,Or as ge,Ot as _e,Pr as ve,Qr as ye,Rr as be,St as xe,Tr as Se,Tt as Ce,Ur as we,Vr as Te,Wr as Ee,Xr as De,Yr as Oe,Zr as ke,_i as Ae,ai as je,bt as Me,ci as Ne,co as Pe,di as Fe,ei as Ie,fi as Le,fn as Re,ft as ze,hi as Be,ii as Ve,io as He,jr as Ue,jt as We,kr as Ge,li as Ke,mi as qe,ni as Je,oi as Ye,pi as Xe,po as Ze,qr as Qe,ri as $e,rr as et,si as tt,ti as nt,ui as rt,uo as it,vi as at,vt as ot,wr as st,wt as ct,xt as lt,yi as ut,yt as dt,zr as ft}from"./index-DmTi6dG-.js";import{t as pt}from"./detail-card-Y8InXOgy.js";var mt=T(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Z=e(o(),1),Q=f();function ht({mode:e,onChange:t}){return(0,Q.jsx)(`div`,{className:`max-w-[280px]`,children:(0,Q.jsx)(x,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function gt({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,Q.jsxs)(pt,{id:e,title:t,subtitle:n,accessory:(0,Q.jsx)(ht,{mode:r,onChange:i}),children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:a})]})}function $({onClick:e,disabled:t}){return(0,Q.jsx)(p,{onClick:e,disabled:t,children:`Save`})}function _t({onClick:e,filled:t=!1}){return(0,Q.jsx)(p,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function vt({id:e,title:t,subtitle:n,children:r}){return(0,Q.jsxs)(pt,{id:e,title:t,subtitle:n,children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:r})]})}function yt({guide:e}){return(0,Q.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,Q.jsx)(J,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{children:e.description}),(0,Q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[e.linkLabel,(0,Q.jsx)(O,{className:`h-3 w-3`})]})]})]})}function bt({status:e,message:t,isLoading:n}){return n?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,children:[(0,Q.jsx)(k,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-positive-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,title:`DNS records have been verified. Your domain is ready to send and receive email.`,children:[(0,Q.jsx)(Ze,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-mid-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-mid-strong)]`,title:`DNS records have been provisioned. Waiting for the email provider to verify them — this usually takes a few minutes.`,children:[(0,Q.jsx)(He,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-negative-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,title:`Domain verification failed. DNS records may not have propagated correctly. You could try releasing and re-registering the domain.`,children:[(0,Q.jsx)(it,{className:`h-3 w-3`}),`Verification failed`]}):(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,title:`Unable to retrieve domain verification status.`,children:`Unknown status`})}var xt=`__custom__`;function St(e){return e?!!(e.profile||e.provider||e.model):!1}function Ct(e,t){let n=St(e);return n===St(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function wt({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,onDraftChange:o,onToggle:s}){let c=St(i),l=!i||!c?``:i.provider||i.model?xt:i.profile??``,u=l===xt,d=i?.provider??nt[0],f=at(d??`anthropic`).map(e=>({value:e.id,label:e.displayName})),p=!!i?.provider&&!i?.model;function m(t){if(t===`__custom__`){let t=nt[0];o(e,{profile:null,provider:t,model:Ae(t)??``})}else t===``?o(e,null):o(e,{profile:t,provider:null,model:null})}function g(t){let n=Ae(t)??``;o(e,{...i??{},profile:null,provider:t,model:n})}function _(t){o(e,{...i??{},model:t})}return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,Q.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,Q.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c&&(0,Q.jsx)(h,{value:l,onChange:m,options:a,className:`w-36`}),(0,Q.jsx)(b,{checked:c,onChange:t=>s(e,t),"aria-label":`Override ${t}`})]})]}),c&&u&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:d??``,onChange:g,options:nt.map(e=>({value:e,label:Je[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,Q.jsx)(h,{value:i?.model??``,onChange:_,options:f})]})]}),p&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function Tt(){let e=l(),{data:t}=u(G()),n=t?.results?.[0]?.id;return{assistantId:n,resolveAssistantId:(0,Z.useCallback)(async()=>{if(n)return n;let t=(await e.fetchQuery(G())).results?.[0]?.id;if(!t)throw Error(`No assistant found`);return t},[n,e])}}function Et(){let{assistantId:e}=Tt(),{data:t}=u({queryKey:V(e),queryFn:async()=>{let{data:t}=await F({path:{assistant_id:e},throwOnError:!0});return t},enabled:!!e,staleTime:3e4,refetchOnWindowFocus:!1}),n=(0,Z.useMemo)(()=>t?.llm?.profiles??{},[t?.llm?.profiles]),r=(0,Z.useMemo)(()=>t?.llm?.profileOrder??[],[t?.llm?.profileOrder]),i=(0,Z.useMemo)(()=>t?.llm?.activeProfile??null,[t?.llm?.activeProfile]),a=(0,Z.useMemo)(()=>t?.llm?.callSites??{},[t?.llm?.callSites]);return{assistantId:e,config:t,profiles:n,profileOrder:r,orderedProfiles:(0,Z.useMemo)(()=>se(n,r),[n,r]),activeProfile:i,callSites:a}}function Dt(){let e=l(),{assistantId:t,resolveAssistantId:n}=Tt();return d({mutationFn:async e=>{let t=await n(),{data:r}=await A({path:{assistant_id:t},body:e,throwOnError:!0});return{data:r,resolvedId:t}},onMutate:async n=>{if(!t)return;let r=V(t);await e.cancelQueries({queryKey:r});let i=e.getQueryData(r),a=i?Qe(i,n):void 0;return e.setQueryData(r,e=>e&&we(e,n)),{rollback:a,queryKey:r}},onError:(t,n,r)=>{let{queryKey:i,rollback:a}=r??{};i&&a&&e.setQueryData(i,e=>e&&we(e,a))},onSettled:n=>{let r=n?.resolvedId??t;e.invalidateQueries({queryKey:V(r)})}})}function Ot(){let{resolveAssistantId:e}=Tt();return(0,Z.useCallback)(async(t,n)=>{try{let{data:r}=await I({path:{assistant_id:await e()},body:{value:n,type:`api_key`,name:t},throwOnError:!0});Ee(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?C.error(`Assistant not ready. Please try again.`):C.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}function kt({isOpen:e,onClose:t,assistantId:n}){let r=(0,Z.useRef)(!1);return(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{!e&&!r.current&&t()},children:e?(0,Q.jsx)(At,{assistantId:n,onClose:t,onSavingChange:e=>{r.current=e}}):null})}function At({assistantId:e,onClose:t,onSavingChange:n}){let{orderedProfiles:r,callSites:i,config:o}=Et(),s=Dt(),[c,l]=(0,Z.useState)(``),[d,f]=(0,Z.useState)({}),[m,h]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),b=H.use.analyzeConversation(),{data:x,isLoading:w,isError:T,refetch:E}=u({...B({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),D=(0,Z.useMemo)(()=>{let e=(x?.callSites??[]).filter(e=>e.id!==`mainAgent`);return b?e:e.filter(e=>e.id!==`analyzeConversation`)},[x,b]),O=!w&&!T&&!!x&&!!o,A=(0,Z.useMemo)(()=>D.map(e=>e.id),[D]),j=(0,Z.useMemo)(()=>{if(!O)return{};let e={};for(let t of A)if(t in d)e[t]=d[t];else{let n=i[t];e[t]=n?{...n}:{}}return e},[O,A,i,d]),M=(0,Z.useMemo)(()=>new Set(A),[A]),N=(0,Z.useMemo)(()=>Object.entries(i).some(([e,t])=>M.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[i,M]),P=(0,Z.useMemo)(()=>{if(!O)return!1;for(let e of Object.keys(j))if(!Ct(j[e],i[e]))return!0;return!1},[O,j,i]),F=(0,Z.useMemo)(()=>Object.values(j).some(e=>St(e)&&!!e?.provider&&!e?.model),[j]),I=H.use.queryComplexityRouting(),L=(0,Z.useCallback)(e=>[...ft(X(r,[e]),I).map(e=>({value:e.name,label:K(e)})),{value:xt,label:`Custom`}],[r,I]),R=(0,Z.useMemo)(()=>{if(!c.trim())return D;let e=c.toLowerCase();return D.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[D,c]),z=(0,Z.useMemo)(()=>{if(!x)return[];let e=x.domains.map(e=>e.id),t=new Map(x.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=R.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=R.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[x,R]),ee=(0,Z.useCallback)((e,t)=>{f(n=>({...n,[e]:t}))},[]),te=(0,Z.useCallback)((e,t)=>{if(!t){f(t=>({...t,[e]:null}));return}let n=Te(r,D.find(t=>t.id===e)?.defaultProfile,I);if(n)f(t=>({...t,[e]:{profile:n}}));else{let t=nt[0],n=Ae(t)??``;f(r=>({...r,[e]:{provider:t,model:n}}))}},[D,r,I]),ne=(0,Z.useCallback)(async()=>{h(!0),n?.(!0);try{let e={};for(let t of Object.keys(j)){let n=j[t]??null;e[t]=St(n)?{profile:n?.profile??null,provider:n?.provider??null,model:n?.model??null}:null}await s.mutateAsync({llm:{callSites:e}}),t(),C.success(`Overrides saved.`)}catch(e){C.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{h(!1),n?.(!1)}},[j,t,s,n]),V=(0,Z.useCallback)(async()=>{h(!0),n?.(!0);try{let e={};for(let t of Object.keys(j))e[t]=null;await s.mutateAsync({llm:{callSites:e}}),t(),C.success(`Overrides reset.`)}catch(e){C.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{h(!1),n?.(!1)}},[j,t,s,n]);return(0,Q.jsxs)(S.Content,{size:`lg`,hideCloseButton:!0,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Action Overrides`}),(0,Q.jsx)(S.Description,{children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`})]}),(0,Q.jsxs)(S.Body,{children:[(0,Q.jsx)(`div`,{className:`mb-4`,children:(0,Q.jsx)(y,{type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:`Search actions…`,leftIcon:(0,Q.jsx)(le,{className:`h-4 w-4`}),fullWidth:!0})}),w&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(k,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),T&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>void E(),children:`Retry`})]}),!w&&!T&&x&&(0,Q.jsx)(`div`,{className:`space-y-4`,children:z.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):z.map(({domain:e,sites:t})=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=(()=>{let t=j[e.id]??null;return!t||!St(t)?``:t.provider||t.model?`__custom__`:t.profile??``})(),n=e.defaultProfile?r.find(t=>t.name===e.defaultProfile)?.label??e.defaultProfile:null;return(0,Q.jsx)(wt,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:n,draft:j[e.id]??null,profileOptions:L(t===``||t===`__custom__`?null:t),onDraftChange:ee,onToggle:te},e.id)})})]},e.id))})]}),(0,Q.jsxs)(S.Footer,{children:[N&&(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>v(!0),disabled:m||!O,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:t,disabled:m,children:`Cancel`}),(0,Q.jsx)(p,{variant:`primary`,size:`compact`,onClick:()=>void ne(),disabled:!P||F||m,children:m?(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin`}):`Save`})]}),(0,Q.jsx)(g,{open:_,title:`Reset to Defaults`,message:`Every task override will be reset and will follow your active profile. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{v(!1),V()},onCancel:()=>v(!1)})]})}function jt({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let c=``;if(e){let t=e.label||e.name;c=e.isActive&&e.callSiteIds.length>0?`"${t}" is the active profile and is used by ${e.callSiteIds.length} call site(s). Pick a replacement profile.`:e.isActive?`"${t}" is the active profile. Pick a different active profile before deleting, or select a replacement below.`:`"${t}" is used by ${e.callSiteIds.length} call site(s). Select a replacement profile to reassign them before deleting.`}return(0,Q.jsx)(S.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,Q.jsxs)(S.Content,{size:`sm`,children:[(0,Q.jsx)(S.Header,{children:(0,Q.jsx)(S.Title,{children:`Can't Delete Profile`})}),(0,Q.jsxs)(S.Body,{className:`space-y-4`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`p`,children:c}),e&&e.callSiteIds.length>0&&(0,Q.jsx)(`ul`,{className:`space-y-1 pl-1`,children:e.callSiteIds.map(e=>(0,Q.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,(0,Q.jsx)(`code`,{children:e})]},e))}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Replacement profile`}),(0,Q.jsx)(h,{"aria-label":`Replacement profile`,value:n,onChange:r,options:[{value:``,label:`Select a replacement…`},...t.map(e=>({value:e.name,label:e.label??e.name}))]})]}),i&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,Q.jsxs)(S.Footer,{children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,Q.jsx)(p,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function Mt({profile:e,isDragging:t,dropTarget:n,isDeleting:r,deleteError:i,isToggling:a,onDragStart:o,onDragEnd:s,onDragOver:c,onDragLeave:l,onDrop:u,onEditClick:d,onDeleteClick:f,onStatusToggle:h}){let g=e.source===`managed`,_=e.status!==`disabled`,y=e.name===be;return(0,Q.jsxs)(`div`,{className:`relative`,children:[n?.name===e.name&&!n.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg pr-2 py-2${t?` opacity-50`:``}`,draggable:!g,onDragStart:o,onDragEnd:s,onDragOver:c,onDragLeave:l,onDrop:u,children:[(0,Q.jsx)(mt,{className:`h-4 w-4 shrink-0 ${g?`invisible`:`cursor-grab text-[var(--content-tertiary)]`}`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1${_?``:` opacity-55`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),g&&e.name!==`auto`&&(0,Q.jsx)(v,{tone:`positive`,title:`Managed by Platform — auth is locked, but you can rename or disable this profile.`,children:`Platform`})]}),e.description?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:e.description}):null,e.model??e.provider?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:e.model??e.provider}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center`,title:_?`Active — toggle to hide from pickers`:`Disabled — toggle to show in pickers`,children:(0,Q.jsx)(b,{checked:_,onChange:e=>h(e),disabled:a,"aria-label":`${_?`Disable`:`Enable`} ${e.label??e.name}`})}),(0,Q.jsxs)(`div`,{className:`flex w-[92px] items-center justify-end gap-2${y?` invisible`:``}`,children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:d,children:g?`View`:`Edit`}),(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),"aria-label":`Delete ${e.label??e.name}`,disabled:g||r,title:g?`Managed profiles cannot be deleted`:void 0,onClick:f,tintColor:`var(--system-negative-strong)`})]})]})]}),n?.name===e.name&&n.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),i?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:i}):null,e.name===`auto`&&(0,Q.jsx)(`div`,{className:`mx-2 mt-1 border-b border-[var(--border-subtle)]`})]})}function Nt({isOpen:e,assistantId:t,onClose:n}){let{profiles:r,profileOrder:i,orderedProfiles:o,activeProfile:s,callSites:c}=Et(),l=Dt(),d=H.use.openAICompatibleEndpoints(),f=H.use.chatgptSubscriptionAuth(),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),{data:_}=u({...z({path:{assistant_id:t}}),enabled:e}),v=(0,Z.useMemo)(()=>_?Y(_.connections,d):void 0,[_,d]),y=Object.keys(r);async function b(e,t,n){let o=n?.mode??`replace`,s=!(e in r);if(o===`merge`&&!s){await l.mutateAsync({llm:{profiles:{[e]:t}}}),m(!1),g(null);return}let c={profiles:{[e]:t}};if(s&&(c.profileOrder=i.includes(e)?i:[...i,e]),s)await l.mutateAsync({llm:c});else{let t=r[e];await l.mutateAsync({llm:{profiles:{[e]:null}}});try{await l.mutateAsync({llm:c})}catch(n){throw a(n,{context:`settings-ai-profile-edit-recreate`}),t!=null&&await l.mutateAsync({llm:{profiles:{[e]:t}}}).catch(()=>{}),n}}s&&C.success(`Profile "${t.label??e}" created`),m(!1),g(null)}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,Q.jsx)(Pt,{profiles:r,profileOrder:i,orderedProfiles:o,activeProfile:s,callSiteOverrides:c,onClose:n,onEditClick:e=>{g(e),m(!0)},onNewClick:()=>{g(null),m(!0)}}):null}),(0,Q.jsx)(st,{isOpen:p,mode:h?h.source===`managed`?`view`:`edit`:`create`,profileName:h?.name,initialValues:h??void 0,existingNames:y,connections:v,openAICompatibleEndpointsEnabled:d,assistantId:t,chatgptSubscriptionEnabled:f,onSave:b,onCancel:()=>{m(!1),g(null)}})]})}function Pt({profiles:e,profileOrder:t,orderedProfiles:n,activeProfile:r,callSiteOverrides:i,onClose:o,onEditClick:s,onNewClick:c}){let l=Dt(),[u,d]=(0,Z.useState)({}),[f,h]=(0,Z.useState)({}),[g,_]=(0,Z.useState)(new Set),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),D=(0,Z.useRef)(null),O=(0,Z.useRef)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(!1),L=H.use.queryComplexityRouting(),R=(0,Z.useMemo)(()=>ft(n,L),[n,L]);async function z(t,n){if(g.has(t.name))return!1;_(e=>new Set(e).add(t.name)),y(null);let r=n?`active`:`disabled`;if(!e[t.name])return _(e=>{let n=new Set(e);return n.delete(t.name),n}),!1;try{return await l.mutateAsync({llm:{profiles:{[t.name]:{status:r}}}}),!0}catch(e){return a(e,{context:`settings-ai-profile-toggle`}),y(`Couldn't update "${t.label??t.name}". Please try again.`),!1}finally{_(e=>{let n=new Set(e);return n.delete(t.name),n})}}async function B(e){h(t=>({...t,[e]:!0})),d(t=>{let n={...t};return delete n[e],n});try{let n=t.filter(t=>t!==e);await l.mutateAsync({llm:{profiles:{[e]:null},profileOrder:n}})}catch(t){a(t,{context:`settings-ai-profile-delete`}),d(t=>({...t,[e]:`Failed to delete profile. Please try again.`}))}finally{h(t=>{let n={...t};return delete n[e],n})}}function ee(e){let t=R.find(t=>t.name===e)?.label??e,n=e===r,a=Object.entries(i).filter(([t,n])=>t!==`mainAgent`&&n?.profile===e).map(([e])=>e);if(n||a.length>0){A({name:e,label:t,isActive:n,callSiteIds:a}),P(``),M(null);return}B(e)}async function te(){if(!k||!N)return;I(!0),M(null);let e={};if(k.isActive&&(e.activeProfile=N),k.callSiteIds.length>0){let t={};for(let e of k.callSiteIds)t[e]={profile:N};e.callSites=t}if(Object.keys(e).length>0)try{await l.mutateAsync({llm:e})}catch(e){a(e,{context:`settings-ai-profile-reassign-delete`}),M(`Failed to reassign references. Please try again.`),I(!1);return}let t=k.name;A(null),I(!1),B(t)}async function ne(e,n){if(e===n.name)return;E(null);let r=t.filter(t=>t!==e),i=r.indexOf(n.name);if(i===-1)return;n.after&&(i+=1);let o=[...r.slice(0,i),e,...r.slice(i)];try{await l.mutateAsync({llm:{profileOrder:o}})}catch(e){a(e,{context:`settings-ai-profile-reorder`}),E(`Failed to reorder profiles. Please try again.`)}}let V=R.filter(e=>e.name!==k?.name&&e.source!==`managed`),U=V.length>0?V:R.filter(e=>e.name!==k?.name);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Model Profiles`}),(0,Q.jsx)(S.Description,{children:`Bundle a provider and model into a named profile. Assign profiles to specific actions or swap between them when chatting.`})]}),(0,Q.jsxs)(S.Body,{children:[R.length===0?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No profiles yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:R.map(e=>(0,Q.jsx)(Mt,{profile:e,isDragging:b===e.name,dropTarget:C,isDeleting:f[e.name]??!1,deleteError:u[e.name],isToggling:g.has(e.name),onDragStart:t=>{D.current=e.name,x(e.name),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{D.current=null,O.current=null,x(null),w(null)},onDragOver:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>n.top+n.height/2,i={name:e.name,after:r};O.current=i,w(i)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||(O.current=null,w(t=>t?.name===e.name?null:t))},onDrop:e=>{e.preventDefault();let t=D.current,n=O.current;D.current=null,O.current=null,x(null),w(null),t&&n&&ne(t,n)},onEditClick:()=>s(e),onDeleteClick:()=>ee(e.name),onStatusToggle:t=>void z(e,t)},e.name))}),T&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:T}),v&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:v})]}),(0,Q.jsxs)(S.Footer,{className:`justify-between`,children:[(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:c,children:`+ New Profile`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:o,children:`Done`})]})]}),(0,Q.jsx)(jt,{blocked:k,availableReplacements:U,replacement:N,onReplacementChange:P,error:j,saving:F,onClose:()=>{A(null),M(null)},onConfirm:()=>void te()})]})}function Ft({mode:e,connection:t,assistantId:n,existingNames:r,openAICompatibleEndpointsEnabled:i=!1,chatgptSubscriptionEnabled:a=!1,onSave:o,onCancel:s}){let[c,u]=(0,Z.useState)(e),[d,f]=(0,Z.useState)(void 0),g=c===`managed-edit`,[_,v]=(0,Z.useState)(t?.label??``),[b,x]=(0,Z.useState)(t?.name??``),[C,w]=(0,Z.useState)(t?.provider??`anthropic`),[T,E]=(0,Z.useState)(()=>t?t.auth.type:`platform`),[D,O]=(0,Z.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[k,A]=(0,Z.useState)(t?.baseUrl??``),[M,N]=(0,Z.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[P,F]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(null),z=C===`openai-compatible`,B=(0,Z.useMemo)(()=>{let e=i?W:W.filter(e=>e!==`openai-compatible`);return C&&!e.includes(C)?[...e,C]:e},[i,C]),{handleLabelChange:ee,resetDirty:te}=q(c,v,x),[ne,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(!1),G=l(),K=(0,Z.useMemo)(()=>me(D),[D]),re=T===`api_key`&&K!==null,{hasStoredCredential:ie,isLoading:J,queryKey:oe}=fe({assistantId:n,credentialKind:`credential`,credentialName:K?`${K.service}:${K.field}`:``,enabled:re,errorContext:`settings-provider-editor-credential-presence`}),{credentials:Y,queryKey:se}=ae({assistantId:n,enabled:T===`api_key`});(0,Z.useEffect)(()=>{let e=t?.provider??`anthropic`;v(t?.label??``),x(t?.name??``),w(e),E(t?t.auth.type:`platform`),t?.auth.type===`api_key`?O(t.auth.credential):O(t?``:`credential/${e}/api_key`),te(),R(null),A(t?.baseUrl??``),N(t?.models?t.models.map(e=>e.id).join(`, `):``),V(``),U(!1)},[t,te]);function X(){u(`create`),f(C===`ollama`?`none`:`api_key`)}let le=b.trim().length>0;async function ue(){if(le){F(!0),R(null);try{let e;if(T===`api_key`){let t=D.trim()||`credential/${C}/api_key`,r=ne.trim();if(r){U(!0);try{let e=me(t);await I({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:C,value:r},throwOnError:!0}),G.setQueryData(oe,!0),G.invalidateQueries({queryKey:se})}catch{R(`Failed to save API key. Please try again.`);return}finally{U(!1)}}e={type:`api_key`,credential:t}}else if(T===`oauth_subscription`)if(t?.auth.type===`oauth_subscription`)e=t.auth;else{R(`Use the "Sign in with ChatGPT" button to connect your subscription.`);return}else e=T===`none`?{type:`none`}:{type:`platform`};let r=_.trim()||null,i={auth:e,label:r,...z&&{base_url:k.trim()||null,models:M.trim()?M.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:a,response:s}=await j({path:{assistant_id:n,name:t?.name??b.trim()},body:i});if(!s?.ok){R(Ue(s?.status,b.trim()));return}if(!a){R(`Server returned an empty response. Please try again.`);return}o(a)}catch{R(`Failed to save connection. Please try again.`)}finally{F(!1)}}}let de=Y.filter(e=>e.service===C),pe=c!==`create`&&t?.auth.type===`api_key`,_e=de.length>0||pe,ye=ge(`Enter your API key`,ie);return c===`create`?(0,Q.jsx)(Se,{variant:`modal`,assistantId:n,existingNames:r,openAICompatibleEndpointsEnabled:i,chatgptSubscriptionEnabled:a,defaultProviderType:C,defaultAuthType:d,onCreated:o,onCancel:s},C):(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Edit Connection`}),(0,Q.jsx)(S.Description,{children:g?`Managed by Vellum — auth is locked, but you can rename "${t?.name}".`:`Editing "${t?.name}".`})]}),(0,Q.jsxs)(S.Body,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,Q.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,Q.jsx)(y,{value:_,onChange:e=>ee(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Key`}),(0,Q.jsx)(y,{value:b,placeholder:`e.g. anthropic-personal`,disabled:!0,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{"aria-label":`Provider`,value:C,onChange:e=>w(e),disabled:!0,options:B.map(e=>({value:e,label:ve[e]}))})]}),z&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,Q.jsx)(y,{value:k,onChange:e=>A(e.target.value),placeholder:`https://api.example.com/v1`,disabled:g,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,Q.jsx)(y,{value:M,onChange:e=>N(e.target.value),placeholder:`model-1, model-2`,disabled:g,fullWidth:!0}),(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Auth Type`}),(0,Q.jsx)(h,{"aria-label":`Auth type`,value:T,onChange:e=>{E(e),R(null)},disabled:g||C===`ollama`,options:(()=>{let e;return e=C===`ollama`?[`none`]:ut(C)?[`api_key`,`platform`]:[`api_key`],T&&!e.includes(T)&&e.push(T),e.map(e=>({value:e,label:Ge[e]}))})()})]}),T===`api_key`&&(0,Q.jsx)(he,{apiKeyValue:ne,onApiKeyChange:V,credential:D,onCredentialChange:O,isAuthLocked:g,isLoadingCredential:J,apiKeyPlaceholder:ye,provider:C,providerCredentials:de,showAdvancedSection:_e,onError:R}),T===`oauth_subscription`&&(0,Q.jsx)(ce,{assistantId:n,onConnected:o}),L&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:L})]}),(0,Q.jsxs)(S.Footer,{children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:s,children:`Cancel`}),c===`managed-edit`&&(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:X,disabled:P||H,children:`Save as New`}),(0,Q.jsx)(p,{variant:`primary`,size:`compact`,disabled:!le||P||H,onClick:()=>void ue(),children:P?`Saving…`:`Save`})]})]})}function It(e){switch(e.type){case`api_key`:return`API key · ${e.credential}`;case`oauth_subscription`:return`ChatGPT Subscription`;case`platform`:return`Managed proxy`;case`none`:return`None (local)`;default:return e.type}}function Lt({isOpen:e,assistantId:t,onClose:n}){let r=H.use.openAICompatibleEndpoints(),i=H.use.chatgptSubscriptionAuth(),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),d=l(),{data:f,isLoading:p,isError:m}=u({...z({path:{assistant_id:t}}),enabled:e}),h=(0,Z.useMemo)(()=>Y(f?.connections??[],r),[f,r]);function g(e){d.invalidateQueries({queryKey:L({path:{assistant_id:t}})}),o(!1),c(null)}let _=h.map(e=>e.name),v=()=>{o(!1),c(null)};return(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{e||(a?v():n())},children:e?a?(0,Q.jsx)(Ft,{mode:s?s.isManaged?`managed-edit`:`edit`:`create`,connection:s??void 0,assistantId:t,existingNames:_,openAICompatibleEndpointsEnabled:r,chatgptSubscriptionEnabled:i,onSave:g,onCancel:v}):(0,Q.jsx)(Rt,{connections:h,loading:p,isError:m,assistantId:t,onClose:n,onEditClick:e=>{c(e),o(!0)},onNewClick:()=>{c(null),o(!0)},onConnectionDeleted:()=>{d.invalidateQueries({queryKey:L({path:{assistant_id:t}})})}}):null})}function Rt({connections:e,loading:t,isError:n,assistantId:r,onClose:i,onEditClick:a,onNewClick:o,onConnectionDeleted:s}){let[c,l]=(0,Z.useState)({}),[u,d]=(0,Z.useState)({});async function f(e){d(t=>({...t,[e]:!0})),l(t=>{let n={...t};return delete n[e],n});try{let{response:t}=await N({path:{assistant_id:r,name:e}});t?.ok||t?.status===404?s(e):t?.status===409?l(t=>({...t,[e]:`Connection is in use by one or more profiles. Remove those references first.`})):l(t=>({...t,[e]:`Failed to delete connection. Please try again.`}))}catch{l(t=>({...t,[e]:`Failed to delete connection. Please try again.`}))}finally{d(t=>{let n={...t};return delete n[e],n})}}return(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Provider Connections`}),(0,Q.jsx)(S.Description,{children:`Manage inference provider connections. Each connection binds a name to a provider and auth configuration.`})]}),(0,Q.jsx)(S.Body,{children:t?(0,Q.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-10 animate-pulse rounded-lg bg-[var(--surface-active)]`},e))}):n?(0,Q.jsx)(m,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:`Failed to load connections. Please try again.`}):e.length===0?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No connections yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>{let t=u[e.name]??!1,n=c[e.name],r=e.isManaged??!1;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg px-2 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),r&&(0,Q.jsx)(v,{tone:`positive`,title:`Managed by Platform — auth is locked, but you can rename this connection.`,children:`Platform`})]}),(0,Q.jsxs)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:[e.label?`${e.name} · `:``,ve[e.provider]??e.provider,` · `,It(e.auth)]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:()=>a(e),children:`Edit`}),(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),"aria-label":`Delete ${e.name}`,disabled:r||t,title:r?`Managed connections cannot be deleted`:void 0,onClick:()=>void f(e.name),tintColor:`var(--system-negative-strong)`})]})]}),n?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:n}):null]},e.name)})})}),(0,Q.jsxs)(S.Footer,{className:`justify-between`,children:[(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:o,children:`+ New Connection`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:i,children:`Done`})]})]})}function zt(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Z.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}function Bt(){let{assistantId:e,orderedProfiles:t,activeProfile:n,callSites:r}=Et(),i=Dt(),[o,s]=zt(n),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,g]=(0,Z.useState)(!1),_=H.use.queryComplexityRouting(),v=(0,Z.useMemo)(()=>ft(X(t,[o]),_),[t,o,_]),y=Object.entries(r).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length,b=y===1?`1 Override`:y>0?`${y} Overrides`:`Overrides`,x=o!==n,S=(0,Z.useCallback)(async()=>{try{await i.mutateAsync({llm:{activeProfile:o}}),C.success(`Profile saved.`)}catch(e){C.error(`Failed to switch profile. Please try again.`),a(e,{context:`settings-ai-language-model-save`})}},[o,i]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vt,{title:`Language Model`,subtitle:`Configure the LLMs that power your assistant`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Default Profile`}),(0,Q.jsx)(h,{value:o??``,onChange:e=>{s(e===``?null:e)},placeholder:`Select a default profile…`,options:v.map(e=>({value:e.name,label:e.name===`auto`?`Automatically switch between profiles`:K(e)}))}),_&&o===`auto`&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2 rounded-lg bg-[var(--surface-warning-subtle)] px-3 py-2`,children:(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-warning)]`,children:`Auto may use more powerful models when needed, which can increase costs.`})}),v.length===0?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`No profiles yet. Click Profiles below to create one.`}):null]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>g(!0),children:`Providers`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>l(!0),children:`Profiles`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>d(!0),children:b})]}),x&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:S,disabled:i.isPending}),i.isPending&&(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]})}),e&&(0,Q.jsx)(Nt,{isOpen:c,assistantId:e,onClose:()=>l(!1)}),e&&(0,Q.jsx)(kt,{isOpen:u,onClose:()=>d(!1),assistantId:e}),e&&(0,Q.jsx)(Lt,{isOpen:f,assistantId:e,onClose:()=>g(!1)})]})}function Vt(){let{assistantId:e,config:i}=Et(),o=Dt(),s=Ot(),c=l(),{serverWebSearchMode:u,serverWebSearchProvider:d}=(0,Z.useMemo)(()=>{if(!i)return{serverWebSearchMode:n(Le,`your-own`),serverWebSearchProvider:n(Xe,`inference-provider-native`)};let e=i.services?.[`web-search`],t=e?.mode;return{serverWebSearchMode:t===`managed`||t===`your-own`?t:n(Le,`your-own`),serverWebSearchProvider:e?.provider||n(`vellum:ai:webSearchProvider`,`inference-provider-native`)}},[i]),[f,p]=(0,Z.useState)(!1),[m,g]=zt(u),[_,v]=zt(d),[b,x]=(0,Z.useState)(``),S=ue.has(_),{hasStoredCredential:w,queryKey:T}=fe({assistantId:e,credentialKind:`api_key`,credentialName:_,enabled:S,errorContext:`settings-ai-web-search-read-credential`}),E=b.trim().length>0,D=f||m===`your-own`&&S&&!w&&!E||!(m!==u||(m===`managed`?`inference-provider-native`:_)!==d)&&!E,O=ge(ke[_]??`Enter your API key`,w),A=(0,Z.useCallback)(async()=>{p(!0);let e=b.trim(),t=m===`managed`?`inference-provider-native`:_,n=de(t),i=m===`your-own`&&S&&e.length>0;try{i&&await s(t,e),await o.mutateAsync({services:{"web-search":{mode:m,provider:t}}}).catch(e=>{throw C.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{p(!1);return}p(!1);try{r(Le,m),r(Xe,t),i&&(n&&r(n,e),c.setQueryData(T,!0),c.invalidateQueries({queryKey:T}),x(``)),C.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),C.error(`Saved, but local preferences could not be written.`)}},[S,o,s,c,T,b,m,_]),j=(0,Z.useCallback)(()=>{let e=de(_);e&&t(e),x(``),v(`inference-provider-native`),r(Xe,`inference-provider-native`)},[_,v]);return(0,Q.jsx)(gt,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,mode:m,onModeChange:e=>g(e),children:m===`managed`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Web search is included with managed inference.`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:A,disabled:D}),f&&(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:_,onChange:v,options:De.map(e=>({value:e,label:Oe[e]??e}))})]}),S&&(0,Q.jsx)(y,{label:`API Key`,type:`password`,value:b,onChange:e=>x(e.target.value),placeholder:O,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:A,disabled:D}),f&&(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),S&&(0,Q.jsx)(_t,{onClick:j,filled:!0})]})]})})}function Ht({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=l(),i=s(),[o,f]=c(),[m,h]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,w]=(0,Z.useState)(``),[T,O]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{v||!t||m||(h(t),y(!0))},[t,v,m]);let I=u({...Re(),enabled:!0}),L=I.data,R=L?.entitlements,z=R?.managed_email===!0,B=!!R&&!z,ne=!L&&I.isError&&!I.isFetching,V=u({...Me({path:{assistant_id:e}}),enabled:!B}),H=u({...Ce({path:{assistant_id:e}}),enabled:!B}),U=V.data?.results?.[0],W=H.data?.results?.[0],G=U?`${U.subdomain}.${n}`:null,K=u({...ie({path:{assistant_id:e,id:W?.id??``}}),enabled:!!W?.id,refetchOnWindowFocus:!1}),q=u({...xe({path:{assistant_id:e,id:U?.id??``}}),enabled:!!U?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Z.useEffect)(()=>{o.get(`release`)!==`1`||!U||W||(N(!0),f(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[W,U,o,f]);let J=d(ot()),ae=d(dt()),Y=d(re()),se=d(ct()),X=(0,Z.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:lt({path:t})}),r.invalidateQueries({queryKey:oe({path:t})}),W?.id&&r.invalidateQueries({queryKey:_e({path:{...t,id:W.id}})}),r.invalidateQueries({queryKey:We()})},[W?.id,e,r]),ce=(0,Z.useCallback)(async()=>{let t=m.trim().toLowerCase();if(!t){x(`Enter a subdomain.`);return}j(!1);try{await J.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),h(``),x(null),X(),C.success(`Domain ${t}.${n} registered.`)}catch(e){x(ee(e,void 0,`Failed to register domain.`))}},[e,n,X,J,m]),le=(0,Z.useCallback)(async()=>{let t=S.trim().toLowerCase();if(!t){O(`Enter an email username.`);return}try{await Y.mutateAsync({path:{assistant_id:e},body:{username:t}}),w(``),O(null),X(),C.success(`Email address created.`)}catch(e){O(ee(e,void 0,`Failed to create email address.`))}},[e,X,Y,S]),ue=(0,Z.useCallback)(async()=>{if(W?.id){F(!1);try{await se.mutateAsync({path:{assistant_id:e,id:W.id}}),X(),C.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),C.error(`Failed to remove email address.`)}}},[W?.id,e,se,X]),de=(0,Z.useCallback)(async()=>{if(!U?.id)return;if(W){C.error(`Remove the email address first.`);return}N(!1);let t=U.subdomain;try{await ae.mutateAsync({path:{assistant_id:e,id:U.id}}),h(t),X(),C.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),C.error(`Failed to release domain.`)}},[W,e,ae,U?.id,U?.subdomain,X]);if(I.isLoading)return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(B)return(0,Q.jsxs)(_,{tone:`info`,icon:(0,Q.jsx)(E,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Get a dedicated email address for your assistant`,actions:(0,Q.jsx)(p,{size:`compact`,onClick:()=>i(`${te.settings.billing}?adjust_plan`),children:`Upgrade to Pro`}),children:[`Pro plans include a managed`,` `,`<your-subdomain>.${n}`,` inbox — no provider setup required. Or switch to `,(0,Q.jsx)(`strong`,{children:`Your Own`}),` to bring an existing provider.`]});let fe=ne?(0,Q.jsx)(_,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,Q.jsx)(p,{size:`compact`,variant:`outlined`,onClick:()=>I.refetch(),children:`Retry`}),children:`We couldn't reach the billing service. The form below assumes managed email is enabled for your org — if it isn't, registering a domain will fail.`}):null;return U?W?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[fe,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:W.address}),(0,Q.jsx)(bt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(p,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),onClick:()=>F(!0),disabled:se.isPending,"aria-label":`Remove email address`})]}),(0,Q.jsx)(g,{open:P,title:`Remove Email Address`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to remove `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:W.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:ue,onCancel:()=>F(!1)})]}),K.data?.usage&&(0,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[K.data.usage.sent_today,` /`,` `,K.data.usage.daily_limit,` sent today ·`,` `,K.data.usage.received_today,` received`]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[fe,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[U.subdomain,`.`,n]}),(0,Q.jsx)(bt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(p,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),onClick:()=>N(!0),disabled:ae.isPending,"aria-label":`Release domain`})]}),(0,Q.jsx)(g,{open:M,title:`Release Domain`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to release `,(0,Q.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[U.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:de,onCancel:()=>N(!1)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex h-9 min-w-0 flex-1 items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${T?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,Q.jsx)(`input`,{value:S,onChange:e=>{w(e.target.value.toLowerCase()),T&&O(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!T,className:`h-full min-w-0 flex-1 bg-transparent pl-3 pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,G]})]}),(0,Q.jsx)(p,{onClick:le,disabled:Y.isPending||!S.trim(),children:Y.isPending?`Creating…`:`Create`})]}),T&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:T})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[fe,(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,Q.jsx)(D,{subdomain:m,onSubdomainChange:e=>{h(e),b&&x(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:b}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Each assistant gets its own subdomain. Lowercase letters, numbers, and hyphens only.`}),(0,Q.jsx)(p,{onClick:()=>j(!0),disabled:J.isPending||!m.trim(),children:J.isPending?`Registering…`:`Register`}),(0,Q.jsx)(g,{open:A,title:`Set Subdomain`,message:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:m.trim().toLowerCase()||`subdomain`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:ce,onCancel:()=>j(!1)})]})}function Ut(){let{data:e}=u(G()),t=e?.results?.[0]?.id,o=e?.results?.[0]?.handle,s=et.use.emailRootDomain(),c=ze(),l=w.use.activeAssistantId(),d=t??l,[f,p]=(0,Z.useState)(()=>c===`gated`?`your-own`:n(Ve,`managed`)),[m,g]=(0,Z.useState)(()=>n($e,`resend`)),v=u({queryKey:[`byoEmailCredential`,d,m],queryFn:async()=>{let{data:e}=await P({path:{assistant_id:d},body:{service:m,field:`api_key`},throwOnError:!0});return e},enabled:!!d&&(f===`your-own`||c===`gated`),staleTime:6e4,retry:i,meta:{errorContext:`byo_email_credential_check`}});(0,Z.useEffect)(()=>{v.error&&a(v.error,{context:`byo_email_credential_check`,bestEffort:!0})},[v.error]);let y=v.data?.hasSecret===!0,b=(0,Z.useCallback)(e=>{p(e),r(Ve,e)},[]),x=(0,Z.useCallback)(()=>{r($e,m),C.success(`Email settings saved.`)},[m]),S=(0,Z.useMemo)(()=>U.find(e=>e.id===m)??U[0],[m]),T=(0,Q.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,Q.jsx)(J,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{children:[`Configure `,S.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:S.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,Q.jsxs)(`a`,{href:S.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,S.displayName,(0,Q.jsx)(O,{className:`h-3 w-3`})]})]})]}),E=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:m,onChange:e=>g(e),options:U.map(e=>({value:e.id,label:e.displayName}))})]}),y?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--system-positive-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-default)]`,children:[(0,Q.jsx)(Pe,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`span`,{children:[S.displayName,` API key configured. To reconfigure, run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:S.setupSkill}),` `,`skill.`]})]}),(0,Q.jsxs)(`a`,{href:S.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-body-small-default text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,S.displayName,(0,Q.jsx)(O,{className:`h-3 w-3`})]})]}):T,(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)($,{onClick:x,disabled:!1})})]});return c===`gated`?(0,Q.jsx)(vt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:E}):(0,Q.jsx)(gt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:f,onModeChange:b,children:f===`managed`?(0,Q.jsx)(`div`,{className:`space-y-4`,children:c===`disabled`?(0,Q.jsx)(_,{tone:`info`,children:`Log in to the Vellum platform to manage email settings.`}):t?(0,Q.jsx)(Ht,{assistantId:t,assistantHandle:o,emailRootDomain:s}):(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No assistant found yet.`})}):E})}function Wt(){let{config:e}=Et(),{resolveAssistantId:t}=Tt(),i=l(),o=Dt(),s=Ot(),[c,u]=zt((0,Z.useMemo)(()=>{if(!e)return n(je,`your-own`);let t=e.services?.[`image-generation`]?.mode;return t===`managed`||t===`your-own`?t:n(je,`your-own`)},[e])),[d,f]=(0,Z.useState)(()=>n(Ye,`gemini-3.1-flash-image-preview`)),[p,m]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),v=(0,Z.useCallback)(async()=>{_(!0);let e=p.trim(),n=c===`your-own`&&e.length>0;try{n&&await s(`gemini`,e),await o.mutateAsync({services:{"image-generation":{mode:c}}}).catch(e=>{throw C.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});let r=await t();try{await M({path:{assistant_id:r},body:{modelId:d},throwOnError:!0})}catch(e){throw C.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{i.invalidateQueries({queryKey:V(r)})}}catch{_(!1);return}_(!1);try{r(je,c),r(Ye,d),n&&m(``),C.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),C.error(`Saved, but local preferences could not be written.`)}},[p,c,d,o,s,t,i]),b=(0,Z.useCallback)(()=>{m(``),f(`gemini-3.1-flash-image-preview`),r(Ye,`gemini-3.1-flash-image-preview`)},[]);return(0,Q.jsx)(gt,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,mode:c,onModeChange:e=>u(e),children:c===`managed`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Q.jsx)(h,{className:`flex-1`,value:d,onChange:f,options:ye.map(e=>({value:e,label:Ie[e]??e}))}),(0,Q.jsx)($,{onClick:v,disabled:g}),g&&(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(y,{label:`API Key`,type:`password`,value:p,onChange:e=>m(e.target.value),placeholder:`Enter your Gemini API key`,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsx)(h,{value:d,onChange:f,options:ye.map(e=>({value:e,label:Ie[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:v,disabled:g}),g&&(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),(0,Q.jsx)(_t,{onClick:b})]})]})})}async function Gt(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 Kt(n,r,i):t===`deepgram`?await qt(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 Kt(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 Jt(i,`ElevenLabs rejected the request.`)}}async function qt(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 Jt(n,`Deepgram rejected the request.`)}}async function Jt(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 Yt(){let{data:e}=u(G()),t=e?.results?.[0]?.id,i=e?.results?.[0]?.name??`your assistant`,a=ne(),{data:o}=u({...R({path:{assistant_id:t}}),enabled:!!t&&a,staleTime:1/0}),s=o?.providers??Be,c=s[0]?.id??`elevenlabs`,[l,d]=(0,Z.useState)(()=>n(rt,c)),[f,m]=(0,Z.useState)(l),[g,_]=(0,Z.useState)(``),[v,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(``),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),O=(0,Z.useMemo)(()=>s.find(e=>e.id===l)??s[0],[l,s]),k=(0,Z.useCallback)(e=>{let t=n(Ke+e,``),r=n(Fe+e,``);T(t.length>0),b(r),S(r),_(``)},[]);(0,Z.useEffect)(()=>{k(l)},[l,k]);let A=(0,Z.useMemo)(()=>{let e=l!==f,t=g.trim().length>0,n=v.trim()!==x;return e||t||n},[l,f,g,v,x]),j=(0,Z.useCallback)(()=>{r(rt,l);let e=g.trim();e.length>0&&(r(Ke+l,e),T(!0));let t=v.trim();r(Fe+l,t),m(l),S(t),_(``)},[l,g,v]),M=(0,Z.useCallback)(()=>{r(Ke+l,``),T(!1),_(``)},[l]),N=(0,Z.useCallback)(async()=>{D(!0);try{let e=n(Ke+l,``),t=g.trim(),r=t.length>0?t:e;if(r.length===0){C.error(`Save an API key for this provider before testing.`);return}let a=n(Fe+l,``),o=v.trim(),s=await Gt({provider:l,apiKey:r,voiceId:o.length>0?o:a,text:`Hey! It's ${i}. How does this sound?`});if(s.kind!==`audio`){C.error(s.message);return}let c=URL.createObjectURL(s.blob);try{let e=new Audio(c);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(c)}}finally{D(!1)}},[i,g,l,v]),P=w?`•••••••• (Enter a new key to replace)`:O.apiKeyPlaceholder;return(0,Q.jsx)(vt,{title:`Text-to-Speech`,subtitle:O.subtitle,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:l,onChange:d,options:s.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(y,{type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:P,fullWidth:!0})]}),O.supportsVoiceSelection&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,Q.jsx)(y,{type:`text`,value:v,onChange:e=>b(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),(0,Q.jsx)(yt,{guide:O.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(p,{variant:`outlined`,onClick:N,disabled:E,children:E?`Testing…`:`Test`}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:j,disabled:!A}),w&&(0,Q.jsx)(_t,{onClick:M})]})]})]})})}function Xt(){let e=qe[0]?.id??`deepgram`,[t,i]=(0,Z.useState)(()=>n(Ne,e)),[a,o]=(0,Z.useState)(t),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),d=(0,Z.useMemo)(()=>qe.find(e=>e.id===t)??qe[0],[t]);(0,Z.useEffect)(()=>{u(n(tt+t,``).length>0),c(``)},[t]);let f=(0,Z.useMemo)(()=>{let e=t!==a,n=s.trim().length>0;return e||n},[t,a,s]),p=(0,Z.useCallback)(()=>{r(Ne,t);let e=s.trim();e.length>0&&(r(tt+t,e),u(!0)),o(t),c(``)},[t,s]),m=(0,Z.useCallback)(()=>{r(tt+t,``),u(!1),c(``)},[t]),g=l?`•••••••• (Enter a new key to replace)`:d.apiKeyPlaceholder;return(0,Q.jsx)(vt,{title:`Speech-to-Text`,subtitle:d.subtitle,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:t,onChange:i,options:qe.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(y,{type:`password`,value:s,onChange:e=>c(e.target.value),placeholder:g,fullWidth:!0})]}),(0,Q.jsx)(yt,{guide:d.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Q.jsx)($,{onClick:p,disabled:!f}),l&&(0,Q.jsx)(_t,{onClick:m})]})]})})}function Zt(){return(0,Z.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]),(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.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,Q.jsx)(J,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,Q.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:[`View pricing`,(0,Q.jsx)(O,{className:`h-3.5 w-3.5`})]})]})]}),(0,Q.jsx)(Bt,{}),(0,Q.jsx)(Vt,{}),(0,Q.jsx)(Ut,{}),(0,Q.jsx)(Wt,{}),(0,Q.jsx)(Yt,{}),(0,Q.jsx)(Xt,{})]})}export{Zt as AiPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,r as n,s as r}from"./local-settings-lVNyIOJ_.js";import{i,t as a}from"./capture-error-23NwnaZt.js";import{t as o}from"./react-DJZBPgpf.js";import{d as s,m as c}from"./chunk-5KNZJZUH-BpLAEZ0-.js";import{n as l}from"./QueryClientProvider-DBAeGN3q.js";import{t as u}from"./useQuery-DAtrV0RI.js";import{t as d}from"./useMutation-DTb3lMvF.js";import{t as f}from"./jsx-runtime-XSukodg_.js";import{t as p}from"./button-Cs9tc8OR.js";import{t as m}from"./typography-PN7B1rrW.js";import{t as h}from"./dropdown-PPtOL9bp.js";import{t as g}from"./confirm-dialog-DavdF-L4.js";import{t as _}from"./notice-BWm2kHlI.js";import{t as v}from"./tag-BkZB4euH.js";import{t as y}from"./input-DwAJUlac.js";import{t as b}from"./toggle-DGzEs0L1.js";import{n as x}from"./stat-square-CMFH3mHq.js";import{t as S}from"./modal-C7CS3Y_X.js";import{t as C}from"./toast-Cii5pffK.js";import{t as w}from"./selection-store-BCKoLRDh.js";import{t as T}from"./createLucideIcon-D8wUFCt3.js";import{n as E,t as D}from"./domain-field-CyNgwvDW.js";import{t as O}from"./external-link-CcV79Arv.js";import{t as k}from"./loader-circle-FEkI0Am4.js";import{C as A,Et as j,Jt as M,Tt as N,Y as P,b as F,yn as I}from"./sdk.gen-up8j0_uF.js";import{C as L,N as R,S as z,s as B}from"./react-query.gen-CfXF72qo.js";import{r as ee}from"./api-errors-DhNZwQy5.js";import{i as te}from"./routes-Dfo11DAg.js";import{t as ne}from"./use-is-org-ready-C0KPmJ3X.js";import{r as V}from"./query-tags-DAoC-jzg.js";import{t as H}from"./assistant-feature-flag-store-XFfKSl8X.js";import{$r as U,Ar as W,At as G,Br as K,Ct as re,Dr as q,Dt as ie,Ea as J,Er as ae,Et as oe,Fr as Y,Gr as se,Hr as X,Ir as ce,Ji as le,Jr as ue,Kr as de,Lr as fe,Mi as pe,Mr as me,Nr as he,Or as ge,Ot as _e,Pr as ve,Qr as ye,Rr as be,St as xe,Tr as Se,Tt as Ce,Ur as we,Vr as Te,Wr as Ee,Xr as De,Yr as Oe,Zr as ke,_i as Ae,ai as je,bt as Me,ci as Ne,co as Pe,di as Fe,ei as Ie,fi as Le,fn as Re,ft as ze,hi as Be,ii as Ve,io as He,jr as Ue,jt as We,kr as Ge,li as Ke,mi as qe,ni as Je,oi as Ye,pi as Xe,po as Ze,qr as Qe,ri as $e,rr as et,si as tt,ti as nt,ui as rt,uo as it,vi as at,vt as ot,wr as st,wt as ct,xt as lt,yi as ut,yt as dt,zr as ft}from"./index-Byws1OMu.js";import{t as pt}from"./detail-card-Y8InXOgy.js";var mt=T(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Z=e(o(),1),Q=f();function ht({mode:e,onChange:t}){return(0,Q.jsx)(`div`,{className:`max-w-[280px]`,children:(0,Q.jsx)(x,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function gt({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,Q.jsxs)(pt,{id:e,title:t,subtitle:n,accessory:(0,Q.jsx)(ht,{mode:r,onChange:i}),children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:a})]})}function $({onClick:e,disabled:t}){return(0,Q.jsx)(p,{onClick:e,disabled:t,children:`Save`})}function _t({onClick:e,filled:t=!1}){return(0,Q.jsx)(p,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function vt({id:e,title:t,subtitle:n,children:r}){return(0,Q.jsxs)(pt,{id:e,title:t,subtitle:n,children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:r})]})}function yt({guide:e}){return(0,Q.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,Q.jsx)(J,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{children:e.description}),(0,Q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[e.linkLabel,(0,Q.jsx)(O,{className:`h-3 w-3`})]})]})]})}function bt({status:e,message:t,isLoading:n}){return n?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,children:[(0,Q.jsx)(k,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-positive-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,title:`DNS records have been verified. Your domain is ready to send and receive email.`,children:[(0,Q.jsx)(Ze,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-mid-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-mid-strong)]`,title:`DNS records have been provisioned. Waiting for the email provider to verify them — this usually takes a few minutes.`,children:[(0,Q.jsx)(He,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-negative-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,title:`Domain verification failed. DNS records may not have propagated correctly. You could try releasing and re-registering the domain.`,children:[(0,Q.jsx)(it,{className:`h-3 w-3`}),`Verification failed`]}):(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,title:`Unable to retrieve domain verification status.`,children:`Unknown status`})}var xt=`__custom__`;function St(e){return e?!!(e.profile||e.provider||e.model):!1}function Ct(e,t){let n=St(e);return n===St(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function wt({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,onDraftChange:o,onToggle:s}){let c=St(i),l=!i||!c?``:i.provider||i.model?xt:i.profile??``,u=l===xt,d=i?.provider??nt[0],f=at(d??`anthropic`).map(e=>({value:e.id,label:e.displayName})),p=!!i?.provider&&!i?.model;function m(t){if(t===`__custom__`){let t=nt[0];o(e,{profile:null,provider:t,model:Ae(t)??``})}else t===``?o(e,null):o(e,{profile:t,provider:null,model:null})}function g(t){let n=Ae(t)??``;o(e,{...i??{},profile:null,provider:t,model:n})}function _(t){o(e,{...i??{},model:t})}return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,Q.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,Q.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c&&(0,Q.jsx)(h,{value:l,onChange:m,options:a,className:`w-36`}),(0,Q.jsx)(b,{checked:c,onChange:t=>s(e,t),"aria-label":`Override ${t}`})]})]}),c&&u&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:d??``,onChange:g,options:nt.map(e=>({value:e,label:Je[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,Q.jsx)(h,{value:i?.model??``,onChange:_,options:f})]})]}),p&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function Tt(){let e=l(),{data:t}=u(G()),n=t?.results?.[0]?.id;return{assistantId:n,resolveAssistantId:(0,Z.useCallback)(async()=>{if(n)return n;let t=(await e.fetchQuery(G())).results?.[0]?.id;if(!t)throw Error(`No assistant found`);return t},[n,e])}}function Et(){let{assistantId:e}=Tt(),{data:t}=u({queryKey:V(e),queryFn:async()=>{let{data:t}=await F({path:{assistant_id:e},throwOnError:!0});return t},enabled:!!e,staleTime:3e4,refetchOnWindowFocus:!1}),n=(0,Z.useMemo)(()=>t?.llm?.profiles??{},[t?.llm?.profiles]),r=(0,Z.useMemo)(()=>t?.llm?.profileOrder??[],[t?.llm?.profileOrder]),i=(0,Z.useMemo)(()=>t?.llm?.activeProfile??null,[t?.llm?.activeProfile]),a=(0,Z.useMemo)(()=>t?.llm?.callSites??{},[t?.llm?.callSites]);return{assistantId:e,config:t,profiles:n,profileOrder:r,orderedProfiles:(0,Z.useMemo)(()=>se(n,r),[n,r]),activeProfile:i,callSites:a}}function Dt(){let e=l(),{assistantId:t,resolveAssistantId:n}=Tt();return d({mutationFn:async e=>{let t=await n(),{data:r}=await A({path:{assistant_id:t},body:e,throwOnError:!0});return{data:r,resolvedId:t}},onMutate:async n=>{if(!t)return;let r=V(t);await e.cancelQueries({queryKey:r});let i=e.getQueryData(r),a=i?Qe(i,n):void 0;return e.setQueryData(r,e=>e&&we(e,n)),{rollback:a,queryKey:r}},onError:(t,n,r)=>{let{queryKey:i,rollback:a}=r??{};i&&a&&e.setQueryData(i,e=>e&&we(e,a))},onSettled:n=>{let r=n?.resolvedId??t;e.invalidateQueries({queryKey:V(r)})}})}function Ot(){let{resolveAssistantId:e}=Tt();return(0,Z.useCallback)(async(t,n)=>{try{let{data:r}=await I({path:{assistant_id:await e()},body:{value:n,type:`api_key`,name:t},throwOnError:!0});Ee(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?C.error(`Assistant not ready. Please try again.`):C.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}function kt({isOpen:e,onClose:t,assistantId:n}){let r=(0,Z.useRef)(!1);return(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{!e&&!r.current&&t()},children:e?(0,Q.jsx)(At,{assistantId:n,onClose:t,onSavingChange:e=>{r.current=e}}):null})}function At({assistantId:e,onClose:t,onSavingChange:n}){let{orderedProfiles:r,callSites:i,config:o}=Et(),s=Dt(),[c,l]=(0,Z.useState)(``),[d,f]=(0,Z.useState)({}),[m,h]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),b=H.use.analyzeConversation(),{data:x,isLoading:w,isError:T,refetch:E}=u({...B({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),D=(0,Z.useMemo)(()=>{let e=(x?.callSites??[]).filter(e=>e.id!==`mainAgent`);return b?e:e.filter(e=>e.id!==`analyzeConversation`)},[x,b]),O=!w&&!T&&!!x&&!!o,A=(0,Z.useMemo)(()=>D.map(e=>e.id),[D]),j=(0,Z.useMemo)(()=>{if(!O)return{};let e={};for(let t of A)if(t in d)e[t]=d[t];else{let n=i[t];e[t]=n?{...n}:{}}return e},[O,A,i,d]),M=(0,Z.useMemo)(()=>new Set(A),[A]),N=(0,Z.useMemo)(()=>Object.entries(i).some(([e,t])=>M.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[i,M]),P=(0,Z.useMemo)(()=>{if(!O)return!1;for(let e of Object.keys(j))if(!Ct(j[e],i[e]))return!0;return!1},[O,j,i]),F=(0,Z.useMemo)(()=>Object.values(j).some(e=>St(e)&&!!e?.provider&&!e?.model),[j]),I=H.use.queryComplexityRouting(),L=(0,Z.useCallback)(e=>[...ft(X(r,[e]),I).map(e=>({value:e.name,label:K(e)})),{value:xt,label:`Custom`}],[r,I]),R=(0,Z.useMemo)(()=>{if(!c.trim())return D;let e=c.toLowerCase();return D.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[D,c]),z=(0,Z.useMemo)(()=>{if(!x)return[];let e=x.domains.map(e=>e.id),t=new Map(x.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=R.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=R.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[x,R]),ee=(0,Z.useCallback)((e,t)=>{f(n=>({...n,[e]:t}))},[]),te=(0,Z.useCallback)((e,t)=>{if(!t){f(t=>({...t,[e]:null}));return}let n=Te(r,D.find(t=>t.id===e)?.defaultProfile,I);if(n)f(t=>({...t,[e]:{profile:n}}));else{let t=nt[0],n=Ae(t)??``;f(r=>({...r,[e]:{provider:t,model:n}}))}},[D,r,I]),ne=(0,Z.useCallback)(async()=>{h(!0),n?.(!0);try{let e={};for(let t of Object.keys(j)){let n=j[t]??null;e[t]=St(n)?{profile:n?.profile??null,provider:n?.provider??null,model:n?.model??null}:null}await s.mutateAsync({llm:{callSites:e}}),t(),C.success(`Overrides saved.`)}catch(e){C.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{h(!1),n?.(!1)}},[j,t,s,n]),V=(0,Z.useCallback)(async()=>{h(!0),n?.(!0);try{let e={};for(let t of Object.keys(j))e[t]=null;await s.mutateAsync({llm:{callSites:e}}),t(),C.success(`Overrides reset.`)}catch(e){C.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{h(!1),n?.(!1)}},[j,t,s,n]);return(0,Q.jsxs)(S.Content,{size:`lg`,hideCloseButton:!0,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Action Overrides`}),(0,Q.jsx)(S.Description,{children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`})]}),(0,Q.jsxs)(S.Body,{children:[(0,Q.jsx)(`div`,{className:`mb-4`,children:(0,Q.jsx)(y,{type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:`Search actions…`,leftIcon:(0,Q.jsx)(le,{className:`h-4 w-4`}),fullWidth:!0})}),w&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(k,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),T&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>void E(),children:`Retry`})]}),!w&&!T&&x&&(0,Q.jsx)(`div`,{className:`space-y-4`,children:z.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):z.map(({domain:e,sites:t})=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=(()=>{let t=j[e.id]??null;return!t||!St(t)?``:t.provider||t.model?`__custom__`:t.profile??``})(),n=e.defaultProfile?r.find(t=>t.name===e.defaultProfile)?.label??e.defaultProfile:null;return(0,Q.jsx)(wt,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:n,draft:j[e.id]??null,profileOptions:L(t===``||t===`__custom__`?null:t),onDraftChange:ee,onToggle:te},e.id)})})]},e.id))})]}),(0,Q.jsxs)(S.Footer,{children:[N&&(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>v(!0),disabled:m||!O,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:t,disabled:m,children:`Cancel`}),(0,Q.jsx)(p,{variant:`primary`,size:`compact`,onClick:()=>void ne(),disabled:!P||F||m,children:m?(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin`}):`Save`})]}),(0,Q.jsx)(g,{open:_,title:`Reset to Defaults`,message:`Every task override will be reset and will follow your active profile. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{v(!1),V()},onCancel:()=>v(!1)})]})}function jt({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let c=``;if(e){let t=e.label||e.name;c=e.isActive&&e.callSiteIds.length>0?`"${t}" is the active profile and is used by ${e.callSiteIds.length} call site(s). Pick a replacement profile.`:e.isActive?`"${t}" is the active profile. Pick a different active profile before deleting, or select a replacement below.`:`"${t}" is used by ${e.callSiteIds.length} call site(s). Select a replacement profile to reassign them before deleting.`}return(0,Q.jsx)(S.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,Q.jsxs)(S.Content,{size:`sm`,children:[(0,Q.jsx)(S.Header,{children:(0,Q.jsx)(S.Title,{children:`Can't Delete Profile`})}),(0,Q.jsxs)(S.Body,{className:`space-y-4`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`p`,children:c}),e&&e.callSiteIds.length>0&&(0,Q.jsx)(`ul`,{className:`space-y-1 pl-1`,children:e.callSiteIds.map(e=>(0,Q.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,(0,Q.jsx)(`code`,{children:e})]},e))}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Replacement profile`}),(0,Q.jsx)(h,{"aria-label":`Replacement profile`,value:n,onChange:r,options:[{value:``,label:`Select a replacement…`},...t.map(e=>({value:e.name,label:e.label??e.name}))]})]}),i&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,Q.jsxs)(S.Footer,{children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,Q.jsx)(p,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function Mt({profile:e,isDragging:t,dropTarget:n,isDeleting:r,deleteError:i,isToggling:a,onDragStart:o,onDragEnd:s,onDragOver:c,onDragLeave:l,onDrop:u,onEditClick:d,onDeleteClick:f,onStatusToggle:h}){let g=e.source===`managed`,_=e.status!==`disabled`,y=e.name===be;return(0,Q.jsxs)(`div`,{className:`relative`,children:[n?.name===e.name&&!n.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg pr-2 py-2${t?` opacity-50`:``}`,draggable:!g,onDragStart:o,onDragEnd:s,onDragOver:c,onDragLeave:l,onDrop:u,children:[(0,Q.jsx)(mt,{className:`h-4 w-4 shrink-0 ${g?`invisible`:`cursor-grab text-[var(--content-tertiary)]`}`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1${_?``:` opacity-55`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),g&&e.name!==`auto`&&(0,Q.jsx)(v,{tone:`positive`,title:`Managed by Platform — auth is locked, but you can rename or disable this profile.`,children:`Platform`})]}),e.description?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:e.description}):null,e.model??e.provider?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:e.model??e.provider}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center`,title:_?`Active — toggle to hide from pickers`:`Disabled — toggle to show in pickers`,children:(0,Q.jsx)(b,{checked:_,onChange:e=>h(e),disabled:a,"aria-label":`${_?`Disable`:`Enable`} ${e.label??e.name}`})}),(0,Q.jsxs)(`div`,{className:`flex w-[92px] items-center justify-end gap-2${y?` invisible`:``}`,children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:d,children:g?`View`:`Edit`}),(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),"aria-label":`Delete ${e.label??e.name}`,disabled:g||r,title:g?`Managed profiles cannot be deleted`:void 0,onClick:f,tintColor:`var(--system-negative-strong)`})]})]})]}),n?.name===e.name&&n.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),i?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:i}):null,e.name===`auto`&&(0,Q.jsx)(`div`,{className:`mx-2 mt-1 border-b border-[var(--border-subtle)]`})]})}function Nt({isOpen:e,assistantId:t,onClose:n}){let{profiles:r,profileOrder:i,orderedProfiles:o,activeProfile:s,callSites:c}=Et(),l=Dt(),d=H.use.openAICompatibleEndpoints(),f=H.use.chatgptSubscriptionAuth(),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),{data:_}=u({...z({path:{assistant_id:t}}),enabled:e}),v=(0,Z.useMemo)(()=>_?Y(_.connections,d):void 0,[_,d]),y=Object.keys(r);async function b(e,t,n){let o=n?.mode??`replace`,s=!(e in r);if(o===`merge`&&!s){await l.mutateAsync({llm:{profiles:{[e]:t}}}),m(!1),g(null);return}let c={profiles:{[e]:t}};if(s&&(c.profileOrder=i.includes(e)?i:[...i,e]),s)await l.mutateAsync({llm:c});else{let t=r[e];await l.mutateAsync({llm:{profiles:{[e]:null}}});try{await l.mutateAsync({llm:c})}catch(n){throw a(n,{context:`settings-ai-profile-edit-recreate`}),t!=null&&await l.mutateAsync({llm:{profiles:{[e]:t}}}).catch(()=>{}),n}}s&&C.success(`Profile "${t.label??e}" created`),m(!1),g(null)}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,Q.jsx)(Pt,{profiles:r,profileOrder:i,orderedProfiles:o,activeProfile:s,callSiteOverrides:c,onClose:n,onEditClick:e=>{g(e),m(!0)},onNewClick:()=>{g(null),m(!0)}}):null}),(0,Q.jsx)(st,{isOpen:p,mode:h?h.source===`managed`?`view`:`edit`:`create`,profileName:h?.name,initialValues:h??void 0,existingNames:y,connections:v,openAICompatibleEndpointsEnabled:d,assistantId:t,chatgptSubscriptionEnabled:f,onSave:b,onCancel:()=>{m(!1),g(null)}})]})}function Pt({profiles:e,profileOrder:t,orderedProfiles:n,activeProfile:r,callSiteOverrides:i,onClose:o,onEditClick:s,onNewClick:c}){let l=Dt(),[u,d]=(0,Z.useState)({}),[f,h]=(0,Z.useState)({}),[g,_]=(0,Z.useState)(new Set),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),D=(0,Z.useRef)(null),O=(0,Z.useRef)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(!1),L=H.use.queryComplexityRouting(),R=(0,Z.useMemo)(()=>ft(n,L),[n,L]);async function z(t,n){if(g.has(t.name))return!1;_(e=>new Set(e).add(t.name)),y(null);let r=n?`active`:`disabled`;if(!e[t.name])return _(e=>{let n=new Set(e);return n.delete(t.name),n}),!1;try{return await l.mutateAsync({llm:{profiles:{[t.name]:{status:r}}}}),!0}catch(e){return a(e,{context:`settings-ai-profile-toggle`}),y(`Couldn't update "${t.label??t.name}". Please try again.`),!1}finally{_(e=>{let n=new Set(e);return n.delete(t.name),n})}}async function B(e){h(t=>({...t,[e]:!0})),d(t=>{let n={...t};return delete n[e],n});try{let n=t.filter(t=>t!==e);await l.mutateAsync({llm:{profiles:{[e]:null},profileOrder:n}})}catch(t){a(t,{context:`settings-ai-profile-delete`}),d(t=>({...t,[e]:`Failed to delete profile. Please try again.`}))}finally{h(t=>{let n={...t};return delete n[e],n})}}function ee(e){let t=R.find(t=>t.name===e)?.label??e,n=e===r,a=Object.entries(i).filter(([t,n])=>t!==`mainAgent`&&n?.profile===e).map(([e])=>e);if(n||a.length>0){A({name:e,label:t,isActive:n,callSiteIds:a}),P(``),M(null);return}B(e)}async function te(){if(!k||!N)return;I(!0),M(null);let e={};if(k.isActive&&(e.activeProfile=N),k.callSiteIds.length>0){let t={};for(let e of k.callSiteIds)t[e]={profile:N};e.callSites=t}if(Object.keys(e).length>0)try{await l.mutateAsync({llm:e})}catch(e){a(e,{context:`settings-ai-profile-reassign-delete`}),M(`Failed to reassign references. Please try again.`),I(!1);return}let t=k.name;A(null),I(!1),B(t)}async function ne(e,n){if(e===n.name)return;E(null);let r=t.filter(t=>t!==e),i=r.indexOf(n.name);if(i===-1)return;n.after&&(i+=1);let o=[...r.slice(0,i),e,...r.slice(i)];try{await l.mutateAsync({llm:{profileOrder:o}})}catch(e){a(e,{context:`settings-ai-profile-reorder`}),E(`Failed to reorder profiles. Please try again.`)}}let V=R.filter(e=>e.name!==k?.name&&e.source!==`managed`),U=V.length>0?V:R.filter(e=>e.name!==k?.name);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Model Profiles`}),(0,Q.jsx)(S.Description,{children:`Bundle a provider and model into a named profile. Assign profiles to specific actions or swap between them when chatting.`})]}),(0,Q.jsxs)(S.Body,{children:[R.length===0?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No profiles yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:R.map(e=>(0,Q.jsx)(Mt,{profile:e,isDragging:b===e.name,dropTarget:C,isDeleting:f[e.name]??!1,deleteError:u[e.name],isToggling:g.has(e.name),onDragStart:t=>{D.current=e.name,x(e.name),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{D.current=null,O.current=null,x(null),w(null)},onDragOver:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>n.top+n.height/2,i={name:e.name,after:r};O.current=i,w(i)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||(O.current=null,w(t=>t?.name===e.name?null:t))},onDrop:e=>{e.preventDefault();let t=D.current,n=O.current;D.current=null,O.current=null,x(null),w(null),t&&n&&ne(t,n)},onEditClick:()=>s(e),onDeleteClick:()=>ee(e.name),onStatusToggle:t=>void z(e,t)},e.name))}),T&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:T}),v&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:v})]}),(0,Q.jsxs)(S.Footer,{className:`justify-between`,children:[(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:c,children:`+ New Profile`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:o,children:`Done`})]})]}),(0,Q.jsx)(jt,{blocked:k,availableReplacements:U,replacement:N,onReplacementChange:P,error:j,saving:F,onClose:()=>{A(null),M(null)},onConfirm:()=>void te()})]})}function Ft({mode:e,connection:t,assistantId:n,existingNames:r,openAICompatibleEndpointsEnabled:i=!1,chatgptSubscriptionEnabled:a=!1,onSave:o,onCancel:s}){let[c,u]=(0,Z.useState)(e),[d,f]=(0,Z.useState)(void 0),g=c===`managed-edit`,[_,v]=(0,Z.useState)(t?.label??``),[b,x]=(0,Z.useState)(t?.name??``),[C,w]=(0,Z.useState)(t?.provider??`anthropic`),[T,E]=(0,Z.useState)(()=>t?t.auth.type:`platform`),[D,O]=(0,Z.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[k,A]=(0,Z.useState)(t?.baseUrl??``),[M,N]=(0,Z.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[P,F]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(null),z=C===`openai-compatible`,B=(0,Z.useMemo)(()=>{let e=i?W:W.filter(e=>e!==`openai-compatible`);return C&&!e.includes(C)?[...e,C]:e},[i,C]),{handleLabelChange:ee,resetDirty:te}=q(c,v,x),[ne,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(!1),G=l(),K=(0,Z.useMemo)(()=>me(D),[D]),re=T===`api_key`&&K!==null,{hasStoredCredential:ie,isLoading:J,queryKey:oe}=fe({assistantId:n,credentialKind:`credential`,credentialName:K?`${K.service}:${K.field}`:``,enabled:re,errorContext:`settings-provider-editor-credential-presence`}),{credentials:Y,queryKey:se}=ae({assistantId:n,enabled:T===`api_key`});(0,Z.useEffect)(()=>{let e=t?.provider??`anthropic`;v(t?.label??``),x(t?.name??``),w(e),E(t?t.auth.type:`platform`),t?.auth.type===`api_key`?O(t.auth.credential):O(t?``:`credential/${e}/api_key`),te(),R(null),A(t?.baseUrl??``),N(t?.models?t.models.map(e=>e.id).join(`, `):``),V(``),U(!1)},[t,te]);function X(){u(`create`),f(C===`ollama`?`none`:`api_key`)}let le=b.trim().length>0;async function ue(){if(le){F(!0),R(null);try{let e;if(T===`api_key`){let t=D.trim()||`credential/${C}/api_key`,r=ne.trim();if(r){U(!0);try{let e=me(t);await I({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:C,value:r},throwOnError:!0}),G.setQueryData(oe,!0),G.invalidateQueries({queryKey:se})}catch{R(`Failed to save API key. Please try again.`);return}finally{U(!1)}}e={type:`api_key`,credential:t}}else if(T===`oauth_subscription`)if(t?.auth.type===`oauth_subscription`)e=t.auth;else{R(`Use the "Sign in with ChatGPT" button to connect your subscription.`);return}else e=T===`none`?{type:`none`}:{type:`platform`};let r=_.trim()||null,i={auth:e,label:r,...z&&{base_url:k.trim()||null,models:M.trim()?M.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:a,response:s}=await j({path:{assistant_id:n,name:t?.name??b.trim()},body:i});if(!s?.ok){R(Ue(s?.status,b.trim()));return}if(!a){R(`Server returned an empty response. Please try again.`);return}o(a)}catch{R(`Failed to save connection. Please try again.`)}finally{F(!1)}}}let de=Y.filter(e=>e.service===C),pe=c!==`create`&&t?.auth.type===`api_key`,_e=de.length>0||pe,ye=ge(`Enter your API key`,ie);return c===`create`?(0,Q.jsx)(Se,{variant:`modal`,assistantId:n,existingNames:r,openAICompatibleEndpointsEnabled:i,chatgptSubscriptionEnabled:a,defaultProviderType:C,defaultAuthType:d,onCreated:o,onCancel:s},C):(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Edit Connection`}),(0,Q.jsx)(S.Description,{children:g?`Managed by Vellum — auth is locked, but you can rename "${t?.name}".`:`Editing "${t?.name}".`})]}),(0,Q.jsxs)(S.Body,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,Q.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,Q.jsx)(y,{value:_,onChange:e=>ee(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Key`}),(0,Q.jsx)(y,{value:b,placeholder:`e.g. anthropic-personal`,disabled:!0,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{"aria-label":`Provider`,value:C,onChange:e=>w(e),disabled:!0,options:B.map(e=>({value:e,label:ve[e]}))})]}),z&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,Q.jsx)(y,{value:k,onChange:e=>A(e.target.value),placeholder:`https://api.example.com/v1`,disabled:g,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,Q.jsx)(y,{value:M,onChange:e=>N(e.target.value),placeholder:`model-1, model-2`,disabled:g,fullWidth:!0}),(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Auth Type`}),(0,Q.jsx)(h,{"aria-label":`Auth type`,value:T,onChange:e=>{E(e),R(null)},disabled:g||C===`ollama`,options:(()=>{let e;return e=C===`ollama`?[`none`]:ut(C)?[`api_key`,`platform`]:[`api_key`],T&&!e.includes(T)&&e.push(T),e.map(e=>({value:e,label:Ge[e]}))})()})]}),T===`api_key`&&(0,Q.jsx)(he,{apiKeyValue:ne,onApiKeyChange:V,credential:D,onCredentialChange:O,isAuthLocked:g,isLoadingCredential:J,apiKeyPlaceholder:ye,provider:C,providerCredentials:de,showAdvancedSection:_e,onError:R}),T===`oauth_subscription`&&(0,Q.jsx)(ce,{assistantId:n,onConnected:o}),L&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:L})]}),(0,Q.jsxs)(S.Footer,{children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:s,children:`Cancel`}),c===`managed-edit`&&(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:X,disabled:P||H,children:`Save as New`}),(0,Q.jsx)(p,{variant:`primary`,size:`compact`,disabled:!le||P||H,onClick:()=>void ue(),children:P?`Saving…`:`Save`})]})]})}function It(e){switch(e.type){case`api_key`:return`API key · ${e.credential}`;case`oauth_subscription`:return`ChatGPT Subscription`;case`platform`:return`Managed proxy`;case`none`:return`None (local)`;default:return e.type}}function Lt({isOpen:e,assistantId:t,onClose:n}){let r=H.use.openAICompatibleEndpoints(),i=H.use.chatgptSubscriptionAuth(),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),d=l(),{data:f,isLoading:p,isError:m}=u({...z({path:{assistant_id:t}}),enabled:e}),h=(0,Z.useMemo)(()=>Y(f?.connections??[],r),[f,r]);function g(e){d.invalidateQueries({queryKey:L({path:{assistant_id:t}})}),o(!1),c(null)}let _=h.map(e=>e.name),v=()=>{o(!1),c(null)};return(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{e||(a?v():n())},children:e?a?(0,Q.jsx)(Ft,{mode:s?s.isManaged?`managed-edit`:`edit`:`create`,connection:s??void 0,assistantId:t,existingNames:_,openAICompatibleEndpointsEnabled:r,chatgptSubscriptionEnabled:i,onSave:g,onCancel:v}):(0,Q.jsx)(Rt,{connections:h,loading:p,isError:m,assistantId:t,onClose:n,onEditClick:e=>{c(e),o(!0)},onNewClick:()=>{c(null),o(!0)},onConnectionDeleted:()=>{d.invalidateQueries({queryKey:L({path:{assistant_id:t}})})}}):null})}function Rt({connections:e,loading:t,isError:n,assistantId:r,onClose:i,onEditClick:a,onNewClick:o,onConnectionDeleted:s}){let[c,l]=(0,Z.useState)({}),[u,d]=(0,Z.useState)({});async function f(e){d(t=>({...t,[e]:!0})),l(t=>{let n={...t};return delete n[e],n});try{let{response:t}=await N({path:{assistant_id:r,name:e}});t?.ok||t?.status===404?s(e):t?.status===409?l(t=>({...t,[e]:`Connection is in use by one or more profiles. Remove those references first.`})):l(t=>({...t,[e]:`Failed to delete connection. Please try again.`}))}catch{l(t=>({...t,[e]:`Failed to delete connection. Please try again.`}))}finally{d(t=>{let n={...t};return delete n[e],n})}}return(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Provider Connections`}),(0,Q.jsx)(S.Description,{children:`Manage inference provider connections. Each connection binds a name to a provider and auth configuration.`})]}),(0,Q.jsx)(S.Body,{children:t?(0,Q.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-10 animate-pulse rounded-lg bg-[var(--surface-active)]`},e))}):n?(0,Q.jsx)(m,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:`Failed to load connections. Please try again.`}):e.length===0?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No connections yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>{let t=u[e.name]??!1,n=c[e.name],r=e.isManaged??!1;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg px-2 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),r&&(0,Q.jsx)(v,{tone:`positive`,title:`Managed by Platform — auth is locked, but you can rename this connection.`,children:`Platform`})]}),(0,Q.jsxs)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:[e.label?`${e.name} · `:``,ve[e.provider]??e.provider,` · `,It(e.auth)]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:()=>a(e),children:`Edit`}),(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),"aria-label":`Delete ${e.name}`,disabled:r||t,title:r?`Managed connections cannot be deleted`:void 0,onClick:()=>void f(e.name),tintColor:`var(--system-negative-strong)`})]})]}),n?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:n}):null]},e.name)})})}),(0,Q.jsxs)(S.Footer,{className:`justify-between`,children:[(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:o,children:`+ New Connection`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:i,children:`Done`})]})]})}function zt(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Z.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}function Bt(){let{assistantId:e,orderedProfiles:t,activeProfile:n,callSites:r}=Et(),i=Dt(),[o,s]=zt(n),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,g]=(0,Z.useState)(!1),_=H.use.queryComplexityRouting(),v=(0,Z.useMemo)(()=>ft(X(t,[o]),_),[t,o,_]),y=Object.entries(r).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length,b=y===1?`1 Override`:y>0?`${y} Overrides`:`Overrides`,x=o!==n,S=(0,Z.useCallback)(async()=>{try{await i.mutateAsync({llm:{activeProfile:o}}),C.success(`Profile saved.`)}catch(e){C.error(`Failed to switch profile. Please try again.`),a(e,{context:`settings-ai-language-model-save`})}},[o,i]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vt,{title:`Language Model`,subtitle:`Configure the LLMs that power your assistant`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Default Profile`}),(0,Q.jsx)(h,{value:o??``,onChange:e=>{s(e===``?null:e)},placeholder:`Select a default profile…`,options:v.map(e=>({value:e.name,label:e.name===`auto`?`Automatically switch between profiles`:K(e)}))}),_&&o===`auto`&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2 rounded-lg bg-[var(--surface-warning-subtle)] px-3 py-2`,children:(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-warning)]`,children:`Auto may use more powerful models when needed, which can increase costs.`})}),v.length===0?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`No profiles yet. Click Profiles below to create one.`}):null]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>g(!0),children:`Providers`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>l(!0),children:`Profiles`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>d(!0),children:b})]}),x&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:S,disabled:i.isPending}),i.isPending&&(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]})}),e&&(0,Q.jsx)(Nt,{isOpen:c,assistantId:e,onClose:()=>l(!1)}),e&&(0,Q.jsx)(kt,{isOpen:u,onClose:()=>d(!1),assistantId:e}),e&&(0,Q.jsx)(Lt,{isOpen:f,assistantId:e,onClose:()=>g(!1)})]})}function Vt(){let{assistantId:e,config:i}=Et(),o=Dt(),s=Ot(),c=l(),{serverWebSearchMode:u,serverWebSearchProvider:d}=(0,Z.useMemo)(()=>{if(!i)return{serverWebSearchMode:n(Le,`your-own`),serverWebSearchProvider:n(Xe,`inference-provider-native`)};let e=i.services?.[`web-search`],t=e?.mode;return{serverWebSearchMode:t===`managed`||t===`your-own`?t:n(Le,`your-own`),serverWebSearchProvider:e?.provider||n(`vellum:ai:webSearchProvider`,`inference-provider-native`)}},[i]),[f,p]=(0,Z.useState)(!1),[m,g]=zt(u),[_,v]=zt(d),[b,x]=(0,Z.useState)(``),S=ue.has(_),{hasStoredCredential:w,queryKey:T}=fe({assistantId:e,credentialKind:`api_key`,credentialName:_,enabled:S,errorContext:`settings-ai-web-search-read-credential`}),E=b.trim().length>0,D=f||m===`your-own`&&S&&!w&&!E||!(m!==u||(m===`managed`?`inference-provider-native`:_)!==d)&&!E,O=ge(ke[_]??`Enter your API key`,w),A=(0,Z.useCallback)(async()=>{p(!0);let e=b.trim(),t=m===`managed`?`inference-provider-native`:_,n=de(t),i=m===`your-own`&&S&&e.length>0;try{i&&await s(t,e),await o.mutateAsync({services:{"web-search":{mode:m,provider:t}}}).catch(e=>{throw C.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{p(!1);return}p(!1);try{r(Le,m),r(Xe,t),i&&(n&&r(n,e),c.setQueryData(T,!0),c.invalidateQueries({queryKey:T}),x(``)),C.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),C.error(`Saved, but local preferences could not be written.`)}},[S,o,s,c,T,b,m,_]),j=(0,Z.useCallback)(()=>{let e=de(_);e&&t(e),x(``),v(`inference-provider-native`),r(Xe,`inference-provider-native`)},[_,v]);return(0,Q.jsx)(gt,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,mode:m,onModeChange:e=>g(e),children:m===`managed`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Web search is included with managed inference.`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:A,disabled:D}),f&&(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:_,onChange:v,options:De.map(e=>({value:e,label:Oe[e]??e}))})]}),S&&(0,Q.jsx)(y,{label:`API Key`,type:`password`,value:b,onChange:e=>x(e.target.value),placeholder:O,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:A,disabled:D}),f&&(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),S&&(0,Q.jsx)(_t,{onClick:j,filled:!0})]})]})})}function Ht({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=l(),i=s(),[o,f]=c(),[m,h]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,w]=(0,Z.useState)(``),[T,O]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{v||!t||m||(h(t),y(!0))},[t,v,m]);let I=u({...Re(),enabled:!0}),L=I.data,R=L?.entitlements,z=R?.managed_email===!0,B=!!R&&!z,ne=!L&&I.isError&&!I.isFetching,V=u({...Me({path:{assistant_id:e}}),enabled:!B}),H=u({...Ce({path:{assistant_id:e}}),enabled:!B}),U=V.data?.results?.[0],W=H.data?.results?.[0],G=U?`${U.subdomain}.${n}`:null,K=u({...ie({path:{assistant_id:e,id:W?.id??``}}),enabled:!!W?.id,refetchOnWindowFocus:!1}),q=u({...xe({path:{assistant_id:e,id:U?.id??``}}),enabled:!!U?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Z.useEffect)(()=>{o.get(`release`)!==`1`||!U||W||(N(!0),f(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[W,U,o,f]);let J=d(ot()),ae=d(dt()),Y=d(re()),se=d(ct()),X=(0,Z.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:lt({path:t})}),r.invalidateQueries({queryKey:oe({path:t})}),W?.id&&r.invalidateQueries({queryKey:_e({path:{...t,id:W.id}})}),r.invalidateQueries({queryKey:We()})},[W?.id,e,r]),ce=(0,Z.useCallback)(async()=>{let t=m.trim().toLowerCase();if(!t){x(`Enter a subdomain.`);return}j(!1);try{await J.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),h(``),x(null),X(),C.success(`Domain ${t}.${n} registered.`)}catch(e){x(ee(e,void 0,`Failed to register domain.`))}},[e,n,X,J,m]),le=(0,Z.useCallback)(async()=>{let t=S.trim().toLowerCase();if(!t){O(`Enter an email username.`);return}try{await Y.mutateAsync({path:{assistant_id:e},body:{username:t}}),w(``),O(null),X(),C.success(`Email address created.`)}catch(e){O(ee(e,void 0,`Failed to create email address.`))}},[e,X,Y,S]),ue=(0,Z.useCallback)(async()=>{if(W?.id){F(!1);try{await se.mutateAsync({path:{assistant_id:e,id:W.id}}),X(),C.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),C.error(`Failed to remove email address.`)}}},[W?.id,e,se,X]),de=(0,Z.useCallback)(async()=>{if(!U?.id)return;if(W){C.error(`Remove the email address first.`);return}N(!1);let t=U.subdomain;try{await ae.mutateAsync({path:{assistant_id:e,id:U.id}}),h(t),X(),C.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),C.error(`Failed to release domain.`)}},[W,e,ae,U?.id,U?.subdomain,X]);if(I.isLoading)return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(B)return(0,Q.jsxs)(_,{tone:`info`,icon:(0,Q.jsx)(E,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Get a dedicated email address for your assistant`,actions:(0,Q.jsx)(p,{size:`compact`,onClick:()=>i(`${te.settings.billing}?adjust_plan`),children:`Upgrade to Pro`}),children:[`Pro plans include a managed`,` `,`<your-subdomain>.${n}`,` inbox — no provider setup required. Or switch to `,(0,Q.jsx)(`strong`,{children:`Your Own`}),` to bring an existing provider.`]});let fe=ne?(0,Q.jsx)(_,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,Q.jsx)(p,{size:`compact`,variant:`outlined`,onClick:()=>I.refetch(),children:`Retry`}),children:`We couldn't reach the billing service. The form below assumes managed email is enabled for your org — if it isn't, registering a domain will fail.`}):null;return U?W?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[fe,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:W.address}),(0,Q.jsx)(bt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(p,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),onClick:()=>F(!0),disabled:se.isPending,"aria-label":`Remove email address`})]}),(0,Q.jsx)(g,{open:P,title:`Remove Email Address`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to remove `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:W.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:ue,onCancel:()=>F(!1)})]}),K.data?.usage&&(0,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[K.data.usage.sent_today,` /`,` `,K.data.usage.daily_limit,` sent today ·`,` `,K.data.usage.received_today,` received`]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[fe,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[U.subdomain,`.`,n]}),(0,Q.jsx)(bt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(p,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),onClick:()=>N(!0),disabled:ae.isPending,"aria-label":`Release domain`})]}),(0,Q.jsx)(g,{open:M,title:`Release Domain`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to release `,(0,Q.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[U.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:de,onCancel:()=>N(!1)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex h-9 min-w-0 flex-1 items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${T?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,Q.jsx)(`input`,{value:S,onChange:e=>{w(e.target.value.toLowerCase()),T&&O(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!T,className:`h-full min-w-0 flex-1 bg-transparent pl-3 pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,G]})]}),(0,Q.jsx)(p,{onClick:le,disabled:Y.isPending||!S.trim(),children:Y.isPending?`Creating…`:`Create`})]}),T&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:T})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[fe,(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,Q.jsx)(D,{subdomain:m,onSubdomainChange:e=>{h(e),b&&x(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:b}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Each assistant gets its own subdomain. Lowercase letters, numbers, and hyphens only.`}),(0,Q.jsx)(p,{onClick:()=>j(!0),disabled:J.isPending||!m.trim(),children:J.isPending?`Registering…`:`Register`}),(0,Q.jsx)(g,{open:A,title:`Set Subdomain`,message:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:m.trim().toLowerCase()||`subdomain`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:ce,onCancel:()=>j(!1)})]})}function Ut(){let{data:e}=u(G()),t=e?.results?.[0]?.id,o=e?.results?.[0]?.handle,s=et.use.emailRootDomain(),c=ze(),l=w.use.activeAssistantId(),d=t??l,[f,p]=(0,Z.useState)(()=>c===`gated`?`your-own`:n(Ve,`managed`)),[m,g]=(0,Z.useState)(()=>n($e,`resend`)),v=u({queryKey:[`byoEmailCredential`,d,m],queryFn:async()=>{let{data:e}=await P({path:{assistant_id:d},body:{service:m,field:`api_key`},throwOnError:!0});return e},enabled:!!d&&(f===`your-own`||c===`gated`),staleTime:6e4,retry:i,meta:{errorContext:`byo_email_credential_check`}});(0,Z.useEffect)(()=>{v.error&&a(v.error,{context:`byo_email_credential_check`,bestEffort:!0})},[v.error]);let y=v.data?.hasSecret===!0,b=(0,Z.useCallback)(e=>{p(e),r(Ve,e)},[]),x=(0,Z.useCallback)(()=>{r($e,m),C.success(`Email settings saved.`)},[m]),S=(0,Z.useMemo)(()=>U.find(e=>e.id===m)??U[0],[m]),T=(0,Q.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,Q.jsx)(J,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{children:[`Configure `,S.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:S.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,Q.jsxs)(`a`,{href:S.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,S.displayName,(0,Q.jsx)(O,{className:`h-3 w-3`})]})]})]}),E=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:m,onChange:e=>g(e),options:U.map(e=>({value:e.id,label:e.displayName}))})]}),y?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--system-positive-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-default)]`,children:[(0,Q.jsx)(Pe,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`span`,{children:[S.displayName,` API key configured. To reconfigure, run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:S.setupSkill}),` `,`skill.`]})]}),(0,Q.jsxs)(`a`,{href:S.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-body-small-default text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,S.displayName,(0,Q.jsx)(O,{className:`h-3 w-3`})]})]}):T,(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)($,{onClick:x,disabled:!1})})]});return c===`gated`?(0,Q.jsx)(vt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:E}):(0,Q.jsx)(gt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:f,onModeChange:b,children:f===`managed`?(0,Q.jsx)(`div`,{className:`space-y-4`,children:c===`disabled`?(0,Q.jsx)(_,{tone:`info`,children:`Log in to the Vellum platform to manage email settings.`}):t?(0,Q.jsx)(Ht,{assistantId:t,assistantHandle:o,emailRootDomain:s}):(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No assistant found yet.`})}):E})}function Wt(){let{config:e}=Et(),{resolveAssistantId:t}=Tt(),i=l(),o=Dt(),s=Ot(),[c,u]=zt((0,Z.useMemo)(()=>{if(!e)return n(je,`your-own`);let t=e.services?.[`image-generation`]?.mode;return t===`managed`||t===`your-own`?t:n(je,`your-own`)},[e])),[d,f]=(0,Z.useState)(()=>n(Ye,`gemini-3.1-flash-image-preview`)),[p,m]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),v=(0,Z.useCallback)(async()=>{_(!0);let e=p.trim(),n=c===`your-own`&&e.length>0;try{n&&await s(`gemini`,e),await o.mutateAsync({services:{"image-generation":{mode:c}}}).catch(e=>{throw C.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});let r=await t();try{await M({path:{assistant_id:r},body:{modelId:d},throwOnError:!0})}catch(e){throw C.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{i.invalidateQueries({queryKey:V(r)})}}catch{_(!1);return}_(!1);try{r(je,c),r(Ye,d),n&&m(``),C.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),C.error(`Saved, but local preferences could not be written.`)}},[p,c,d,o,s,t,i]),b=(0,Z.useCallback)(()=>{m(``),f(`gemini-3.1-flash-image-preview`),r(Ye,`gemini-3.1-flash-image-preview`)},[]);return(0,Q.jsx)(gt,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,mode:c,onModeChange:e=>u(e),children:c===`managed`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Q.jsx)(h,{className:`flex-1`,value:d,onChange:f,options:ye.map(e=>({value:e,label:Ie[e]??e}))}),(0,Q.jsx)($,{onClick:v,disabled:g}),g&&(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(y,{label:`API Key`,type:`password`,value:p,onChange:e=>m(e.target.value),placeholder:`Enter your Gemini API key`,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsx)(h,{value:d,onChange:f,options:ye.map(e=>({value:e,label:Ie[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:v,disabled:g}),g&&(0,Q.jsx)(k,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),(0,Q.jsx)(_t,{onClick:b})]})]})})}async function Gt(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 Kt(n,r,i):t===`deepgram`?await qt(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 Kt(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 Jt(i,`ElevenLabs rejected the request.`)}}async function qt(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 Jt(n,`Deepgram rejected the request.`)}}async function Jt(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 Yt(){let{data:e}=u(G()),t=e?.results?.[0]?.id,i=e?.results?.[0]?.name??`your assistant`,a=ne(),{data:o}=u({...R({path:{assistant_id:t}}),enabled:!!t&&a,staleTime:1/0}),s=o?.providers??Be,c=s[0]?.id??`elevenlabs`,[l,d]=(0,Z.useState)(()=>n(rt,c)),[f,m]=(0,Z.useState)(l),[g,_]=(0,Z.useState)(``),[v,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(``),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),O=(0,Z.useMemo)(()=>s.find(e=>e.id===l)??s[0],[l,s]),k=(0,Z.useCallback)(e=>{let t=n(Ke+e,``),r=n(Fe+e,``);T(t.length>0),b(r),S(r),_(``)},[]);(0,Z.useEffect)(()=>{k(l)},[l,k]);let A=(0,Z.useMemo)(()=>{let e=l!==f,t=g.trim().length>0,n=v.trim()!==x;return e||t||n},[l,f,g,v,x]),j=(0,Z.useCallback)(()=>{r(rt,l);let e=g.trim();e.length>0&&(r(Ke+l,e),T(!0));let t=v.trim();r(Fe+l,t),m(l),S(t),_(``)},[l,g,v]),M=(0,Z.useCallback)(()=>{r(Ke+l,``),T(!1),_(``)},[l]),N=(0,Z.useCallback)(async()=>{D(!0);try{let e=n(Ke+l,``),t=g.trim(),r=t.length>0?t:e;if(r.length===0){C.error(`Save an API key for this provider before testing.`);return}let a=n(Fe+l,``),o=v.trim(),s=await Gt({provider:l,apiKey:r,voiceId:o.length>0?o:a,text:`Hey! It's ${i}. How does this sound?`});if(s.kind!==`audio`){C.error(s.message);return}let c=URL.createObjectURL(s.blob);try{let e=new Audio(c);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(c)}}finally{D(!1)}},[i,g,l,v]),P=w?`•••••••• (Enter a new key to replace)`:O.apiKeyPlaceholder;return(0,Q.jsx)(vt,{title:`Text-to-Speech`,subtitle:O.subtitle,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:l,onChange:d,options:s.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(y,{type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:P,fullWidth:!0})]}),O.supportsVoiceSelection&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,Q.jsx)(y,{type:`text`,value:v,onChange:e=>b(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),(0,Q.jsx)(yt,{guide:O.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(p,{variant:`outlined`,onClick:N,disabled:E,children:E?`Testing…`:`Test`}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:j,disabled:!A}),w&&(0,Q.jsx)(_t,{onClick:M})]})]})]})})}function Xt(){let e=qe[0]?.id??`deepgram`,[t,i]=(0,Z.useState)(()=>n(Ne,e)),[a,o]=(0,Z.useState)(t),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),d=(0,Z.useMemo)(()=>qe.find(e=>e.id===t)??qe[0],[t]);(0,Z.useEffect)(()=>{u(n(tt+t,``).length>0),c(``)},[t]);let f=(0,Z.useMemo)(()=>{let e=t!==a,n=s.trim().length>0;return e||n},[t,a,s]),p=(0,Z.useCallback)(()=>{r(Ne,t);let e=s.trim();e.length>0&&(r(tt+t,e),u(!0)),o(t),c(``)},[t,s]),m=(0,Z.useCallback)(()=>{r(tt+t,``),u(!1),c(``)},[t]),g=l?`•••••••• (Enter a new key to replace)`:d.apiKeyPlaceholder;return(0,Q.jsx)(vt,{title:`Speech-to-Text`,subtitle:d.subtitle,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:t,onChange:i,options:qe.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(y,{type:`password`,value:s,onChange:e=>c(e.target.value),placeholder:g,fullWidth:!0})]}),(0,Q.jsx)(yt,{guide:d.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Q.jsx)($,{onClick:p,disabled:!f}),l&&(0,Q.jsx)(_t,{onClick:m})]})]})})}function Zt(){return(0,Z.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]),(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.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,Q.jsx)(J,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,Q.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:[`View pricing`,(0,Q.jsx)(O,{className:`h-3.5 w-3.5`})]})]})]}),(0,Q.jsx)(Bt,{}),(0,Q.jsx)(Vt,{}),(0,Q.jsx)(Ut,{}),(0,Q.jsx)(Wt,{}),(0,Q.jsx)(Yt,{}),(0,Q.jsx)(Xt,{})]})}export{Zt as AiPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-23NwnaZt.js";import{t as n}from"./react-DJZBPgpf.js";import{n as r}from"./QueryClientProvider-DBAeGN3q.js";import{t as i}from"./useQuery-DAtrV0RI.js";import{t as a}from"./jsx-runtime-XSukodg_.js";import{t as o}from"./button-Cs9tc8OR.js";import{t as s}from"./card-BcKGvsaa.js";import"./src-Bah0_lDG.js";import{t as c}from"./toast-Cii5pffK.js";import{t as l}from"./archive-yWA8_b2E.js";import{t as u}from"./loader-circle-FEkI0Am4.js";import{B as d}from"./sdk.gen-up8j0_uF.js";import{Ai as f,At as p,Ln as m,Zi as h,er as g}from"./index-DmTi6dG-.js";var _=e(n(),1),v=a();function y(e){if(e==null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0})}function b(){return(0,v.jsx)(s,{children:(0,v.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,v.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,v.jsx)(l,{className:`h-6 w-6 text-[var(--content-disabled)] dark:text-[var(--content-default)]`})}),(0,v.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No archived conversations`}),(0,v.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Conversations you archive will appear here.`})]})})}function x({conversation:e,isFirst:t,onUnarchive:n,isPending:r}){let i=[y(e.createdAt),e.source??`vellum-assistant`].filter(Boolean).join(` · `),a=e.title&&e.title.trim().length>0?e.title:`Untitled conversation`;return(0,v.jsxs)(`div`,{className:`flex items-center gap-3 py-3 ${t?``:`border-t border-[var(--border-base)]`}`,children:[(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`div`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:a}),(0,v.jsx)(`p`,{className:`mt-0.5 truncate text-body-small-default text-[var(--content-tertiary)]`,children:i})]}),(0,v.jsx)(o,{variant:`outlined`,onClick:n,disabled:r,className:`shrink-0`,children:r?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(u,{className:`h-4 w-4 animate-spin`}),`Unarchiving`]}):`Unarchive`})]})}function S(){let e=r(),{data:n,isLoading:a}=i(p()),l=n?.results?.[0]?.id??null,{conversations:y,isLoading:S,isError:C,refetch:w}=m(l),[T,E]=(0,_.useState)(null),D=(0,_.useCallback)(async n=>{if(l){E(n);try{await d({path:{assistant_id:l,id:n},throwOnError:!0}),g(e,l)}catch(e){t(e,{context:`archive_settings_unarchive_conversation`}),c.error(`Failed to unarchive conversation.`)}finally{E(null)}}},[l,e]);return a||S?(0,v.jsx)(`div`,{className:`w-full`,children:(0,v.jsx)(`div`,{className:`flex min-h-[400px] items-center justify-center`,children:(0,v.jsx)(u,{className:`h-6 w-6 animate-spin text-[var(--content-disabled)]`})})}):C?(0,v.jsx)(`div`,{className:`w-full`,children:(0,v.jsx)(s,{children:(0,v.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,v.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--system-error-lighter)]`,children:(0,v.jsx)(f,{className:`h-6 w-6 text-[var(--system-error-default)]`})}),(0,v.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`Failed to load archived conversations`}),(0,v.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Something went wrong. Please try again.`}),(0,v.jsxs)(o,{variant:`outlined`,onClick:w,className:`mt-4`,children:[(0,v.jsx)(h,{className:`h-4 w-4`}),`Retry`]})]})})}):y.length===0?(0,v.jsx)(`div`,{className:`w-full`,children:(0,v.jsx)(b,{})}):(0,v.jsx)(`div`,{className:`w-full`,children:(0,v.jsx)(s,{noPadding:!0,className:`px-4`,children:y.map((e,t)=>(0,v.jsx)(x,{conversation:e,isFirst:t===0,onUnarchive:()=>{D(e.conversationId)},isPending:T===e.conversationId},e.conversationId))})})}export{S as ArchivePage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-23NwnaZt.js";import{t as n}from"./react-DJZBPgpf.js";import{n as r}from"./QueryClientProvider-DBAeGN3q.js";import{t as i}from"./useQuery-DAtrV0RI.js";import{t as a}from"./jsx-runtime-XSukodg_.js";import{t as o}from"./button-Cs9tc8OR.js";import{t as s}from"./card-BcKGvsaa.js";import"./src-Bah0_lDG.js";import{t as c}from"./toast-Cii5pffK.js";import{t as l}from"./archive-yWA8_b2E.js";import{t as u}from"./loader-circle-FEkI0Am4.js";import{B as d}from"./sdk.gen-up8j0_uF.js";import{Ai as f,At as p,Ln as m,Zi as h,er as g}from"./index-Byws1OMu.js";var _=e(n(),1),v=a();function y(e){if(e==null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0})}function b(){return(0,v.jsx)(s,{children:(0,v.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,v.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,v.jsx)(l,{className:`h-6 w-6 text-[var(--content-disabled)] dark:text-[var(--content-default)]`})}),(0,v.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No archived conversations`}),(0,v.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Conversations you archive will appear here.`})]})})}function x({conversation:e,isFirst:t,onUnarchive:n,isPending:r}){let i=[y(e.createdAt),e.source??`vellum-assistant`].filter(Boolean).join(` · `),a=e.title&&e.title.trim().length>0?e.title:`Untitled conversation`;return(0,v.jsxs)(`div`,{className:`flex items-center gap-3 py-3 ${t?``:`border-t border-[var(--border-base)]`}`,children:[(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`div`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:a}),(0,v.jsx)(`p`,{className:`mt-0.5 truncate text-body-small-default text-[var(--content-tertiary)]`,children:i})]}),(0,v.jsx)(o,{variant:`outlined`,onClick:n,disabled:r,className:`shrink-0`,children:r?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(u,{className:`h-4 w-4 animate-spin`}),`Unarchiving`]}):`Unarchive`})]})}function S(){let e=r(),{data:n,isLoading:a}=i(p()),l=n?.results?.[0]?.id??null,{conversations:y,isLoading:S,isError:C,refetch:w}=m(l),[T,E]=(0,_.useState)(null),D=(0,_.useCallback)(async n=>{if(l){E(n);try{await d({path:{assistant_id:l,id:n},throwOnError:!0}),g(e,l)}catch(e){t(e,{context:`archive_settings_unarchive_conversation`}),c.error(`Failed to unarchive conversation.`)}finally{E(null)}}},[l,e]);return a||S?(0,v.jsx)(`div`,{className:`w-full`,children:(0,v.jsx)(`div`,{className:`flex min-h-[400px] items-center justify-center`,children:(0,v.jsx)(u,{className:`h-6 w-6 animate-spin text-[var(--content-disabled)]`})})}):C?(0,v.jsx)(`div`,{className:`w-full`,children:(0,v.jsx)(s,{children:(0,v.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,v.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--system-error-lighter)]`,children:(0,v.jsx)(f,{className:`h-6 w-6 text-[var(--system-error-default)]`})}),(0,v.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`Failed to load archived conversations`}),(0,v.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Something went wrong. Please try again.`}),(0,v.jsxs)(o,{variant:`outlined`,onClick:w,className:`mt-4`,children:[(0,v.jsx)(h,{className:`h-4 w-4`}),`Retry`]})]})})}):y.length===0?(0,v.jsx)(`div`,{className:`w-full`,children:(0,v.jsx)(b,{})}):(0,v.jsx)(`div`,{className:`w-full`,children:(0,v.jsx)(s,{noPadding:!0,className:`px-4`,children:y.map((e,t)=>(0,v.jsx)(x,{conversation:e,isFirst:t===0,onUnarchive:()=>{D(e.conversationId)},isPending:T===e.conversationId},e.conversationId))})})}export{S as ArchivePage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{r as t,t as n}from"./capture-error-23NwnaZt.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./useQuery-DAtrV0RI.js";import{t as a}from"./jsx-runtime-XSukodg_.js";import"./src-Bah0_lDG.js";import{t as o}from"./tag-BkZB4euH.js";import{t as s}from"./toast-Cii5pffK.js";import{t as c}from"./loader-circle-FEkI0Am4.js";import{n as l}from"./auth-store-NinzEiLF.js";import{a as u,r as d}from"./api-DYTu2hC1.js";import{t as f}from"./assistant-feature-flag-store-XFfKSl8X.js";import{rr as p}from"./index-DmTi6dG-.js";var m=e(r(),1),h=a();function g({value:e,max:t,caption:n}){let r=t>0?Math.max(0,Math.min(e/t*100,100)):0,i=r>90;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-[var(--surface-active)]`,children:(0,h.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-200`,style:{width:`${r}%`,backgroundColor:i?`var(--system-negative-strong)`:`var(--system-positive-strong)`}})}),n&&(0,h.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:n})]})}var _=7,v=2e3;function y({version:e,loading:t,assistantId:n}){let r=(0,m.useRef)(0),i=(0,m.useRef)(null),[a,o]=(0,m.useState)(null),s=(0,m.useCallback)(()=>{if(r.current+=1,r.current>=_){r.current=0;let e=f.getState(),t=!e.settingsDeveloperNav;e.setFlag(`settingsDeveloperNav`,t,n),o(t?`Developer mode enabled`:`Developer mode disabled`),i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{o(null),i.current=null},v)}},[n]);return(0,m.useEffect)(()=>()=>{i.current!==null&&clearTimeout(i.current)},[]),t?(0,h.jsxs)(`span`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,h.jsx)(c,{className:`h-4 w-4 animate-spin`}),`Loading version...`]}):e?(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`button`,{type:`button`,className:`break-all text-left text-body-medium-lighter text-[var(--content-default)]`,onClick:s,children:e}),a&&(0,h.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:a})]}):(0,h.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`—`})}var b=[`currentAssistant`],x=4e3,S=9e4;function C(e,t){return(e.memory?.maxMb??null)!==(t.memory?.maxMb??null)||(e.cpu?.maxCores??null)!==(t.cpu?.maxCores??null)}function w(){let{data:e=null,isLoading:r,refetch:a}=i({queryKey:b,queryFn:async()=>{let e=await d();return e.ok?e.data:null},retry:!1}),o=e?.id,[c,l]=(0,m.useState)(null),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(!1),_=(0,m.useRef)(0),v=(0,m.useRef)(0),y=(0,m.useCallback)(async e=>{if(!o)return l(null),p(!1),null;_.current+=1;let r=_.current;p(!0);try{let t=await u(o);return r===_.current?t.ok?(l(t.data),t.data):(e?.keepStaleOnError||l(null),null):null}catch(i){return r===_.current?(e?.keepStaleOnError||l(null),!t(i)&&!e?.keepStaleOnError&&(n(i,{context:`fetch_assistant_healthz`}),s.error(`Failed to load assistant info`)),null):null}finally{r===_.current&&p(!1)}},[o]);return(0,m.useEffect)(()=>{y()},[y]),(0,m.useEffect)(()=>()=>{v.current+=1,g(!1),l(null)},[o]),{assistant:e,assistantLoading:r,healthz:c,healthzLoading:f,healthzPolling:h,refetch:(0,m.useCallback)(async()=>{await a(),await y()},[a,y]),refetchUntilResized:(0,m.useCallback)(async e=>{let t=++v.current,n=Date.now()+S;g(!0);let r=e;try{for(a();Date.now()<n&&t===v.current;){if(await new Promise(e=>setTimeout(e,x)),t!==v.current)return;let e=await y({keepStaleOnError:!0});if(t!==v.current)return;if(e){if(r==null){r=e;continue}if(C(e,r))return}}}finally{t===v.current&&g(!1)}},[y,a])}}function T({assistant:e,assistantLoading:t,healthz:n,healthzLoading:r}){let i=p.use.isNonProduction(),a=l.use.user()?.email;if(t)return(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,h.jsx)(c,{className:`h-4 w-4 animate-spin`}),`Loading assistant info...`]});if(!e)return(0,h.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No assistant found. Hatch an assistant to get started.`});let s=n?.version??e.current_release_version;return(0,h.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[a&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(D,{children:`Account`}),(0,h.jsx)(O,{children:a})]}),(0,h.jsx)(D,{children:`Name`}),(0,h.jsx)(O,{children:e.name}),e.description&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(D,{children:`Description`}),(0,h.jsx)(O,{children:e.description})]}),(0,h.jsx)(D,{children:`Status`}),(0,h.jsx)(`div`,{children:(0,h.jsx)(o,{tone:e.status===`active`?`positive`:`neutral`,children:e.status})}),(0,h.jsx)(D,{children:`Assistant ID`}),(0,h.jsx)(`span`,{className:`break-all font-mono text-body-small-default text-[var(--content-tertiary)]`,children:e.id}),i&&e.machine_id&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(D,{children:`Machine ID`}),(0,h.jsx)(`span`,{className:`break-all font-mono text-body-small-default text-[var(--content-tertiary)]`,children:e.machine_id})]}),(0,h.jsx)(D,{children:`Created`}),(0,h.jsx)(O,{children:e.created?new Date(e.created).toLocaleDateString():`Unknown`}),(0,h.jsx)(D,{children:`Version`}),(0,h.jsx)(y,{version:s??null,loading:r&&!e.current_release_version,assistantId:e.id??null})]})}function E(e){return e>=1024?`${(e/1024).toFixed(1)} GB`:`${e.toFixed(0)} MB`}function D({children:e}){return(0,h.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e})}function O({children:e}){return(0,h.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:e})}export{g as i,E as n,w as r,T as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{r as t,t as n}from"./capture-error-23NwnaZt.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./useQuery-DAtrV0RI.js";import{t as a}from"./jsx-runtime-XSukodg_.js";import"./src-Bah0_lDG.js";import{t as o}from"./tag-BkZB4euH.js";import{t as s}from"./toast-Cii5pffK.js";import{t as c}from"./loader-circle-FEkI0Am4.js";import{n as l}from"./auth-store-NinzEiLF.js";import{a as u,r as d}from"./api-DYTu2hC1.js";import{t as f}from"./assistant-feature-flag-store-XFfKSl8X.js";import{rr as p}from"./index-Byws1OMu.js";var m=e(r(),1),h=a();function g({value:e,max:t,caption:n}){let r=t>0?Math.max(0,Math.min(e/t*100,100)):0,i=r>90;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-[var(--surface-active)]`,children:(0,h.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-200`,style:{width:`${r}%`,backgroundColor:i?`var(--system-negative-strong)`:`var(--system-positive-strong)`}})}),n&&(0,h.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:n})]})}var _=7,v=2e3;function y({version:e,loading:t,assistantId:n}){let r=(0,m.useRef)(0),i=(0,m.useRef)(null),[a,o]=(0,m.useState)(null),s=(0,m.useCallback)(()=>{if(r.current+=1,r.current>=_){r.current=0;let e=f.getState(),t=!e.settingsDeveloperNav;e.setFlag(`settingsDeveloperNav`,t,n),o(t?`Developer mode enabled`:`Developer mode disabled`),i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{o(null),i.current=null},v)}},[n]);return(0,m.useEffect)(()=>()=>{i.current!==null&&clearTimeout(i.current)},[]),t?(0,h.jsxs)(`span`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,h.jsx)(c,{className:`h-4 w-4 animate-spin`}),`Loading version...`]}):e?(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`button`,{type:`button`,className:`break-all text-left text-body-medium-lighter text-[var(--content-default)]`,onClick:s,children:e}),a&&(0,h.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:a})]}):(0,h.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`—`})}var b=[`currentAssistant`],x=4e3,S=9e4;function C(e,t){return(e.memory?.maxMb??null)!==(t.memory?.maxMb??null)||(e.cpu?.maxCores??null)!==(t.cpu?.maxCores??null)}function w(){let{data:e=null,isLoading:r,refetch:a}=i({queryKey:b,queryFn:async()=>{let e=await d();return e.ok?e.data:null},retry:!1}),o=e?.id,[c,l]=(0,m.useState)(null),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(!1),_=(0,m.useRef)(0),v=(0,m.useRef)(0),y=(0,m.useCallback)(async e=>{if(!o)return l(null),p(!1),null;_.current+=1;let r=_.current;p(!0);try{let t=await u(o);return r===_.current?t.ok?(l(t.data),t.data):(e?.keepStaleOnError||l(null),null):null}catch(i){return r===_.current?(e?.keepStaleOnError||l(null),!t(i)&&!e?.keepStaleOnError&&(n(i,{context:`fetch_assistant_healthz`}),s.error(`Failed to load assistant info`)),null):null}finally{r===_.current&&p(!1)}},[o]);return(0,m.useEffect)(()=>{y()},[y]),(0,m.useEffect)(()=>()=>{v.current+=1,g(!1),l(null)},[o]),{assistant:e,assistantLoading:r,healthz:c,healthzLoading:f,healthzPolling:h,refetch:(0,m.useCallback)(async()=>{await a(),await y()},[a,y]),refetchUntilResized:(0,m.useCallback)(async e=>{let t=++v.current,n=Date.now()+S;g(!0);let r=e;try{for(a();Date.now()<n&&t===v.current;){if(await new Promise(e=>setTimeout(e,x)),t!==v.current)return;let e=await y({keepStaleOnError:!0});if(t!==v.current)return;if(e){if(r==null){r=e;continue}if(C(e,r))return}}}finally{t===v.current&&g(!1)}},[y,a])}}function T({assistant:e,assistantLoading:t,healthz:n,healthzLoading:r}){let i=p.use.isNonProduction(),a=l.use.user()?.email;if(t)return(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,h.jsx)(c,{className:`h-4 w-4 animate-spin`}),`Loading assistant info...`]});if(!e)return(0,h.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No assistant found. Hatch an assistant to get started.`});let s=n?.version??e.current_release_version;return(0,h.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[a&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(D,{children:`Account`}),(0,h.jsx)(O,{children:a})]}),(0,h.jsx)(D,{children:`Name`}),(0,h.jsx)(O,{children:e.name}),e.description&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(D,{children:`Description`}),(0,h.jsx)(O,{children:e.description})]}),(0,h.jsx)(D,{children:`Status`}),(0,h.jsx)(`div`,{children:(0,h.jsx)(o,{tone:e.status===`active`?`positive`:`neutral`,children:e.status})}),(0,h.jsx)(D,{children:`Assistant ID`}),(0,h.jsx)(`span`,{className:`break-all font-mono text-body-small-default text-[var(--content-tertiary)]`,children:e.id}),i&&e.machine_id&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(D,{children:`Machine ID`}),(0,h.jsx)(`span`,{className:`break-all font-mono text-body-small-default text-[var(--content-tertiary)]`,children:e.machine_id})]}),(0,h.jsx)(D,{children:`Created`}),(0,h.jsx)(O,{children:e.created?new Date(e.created).toLocaleDateString():`Unknown`}),(0,h.jsx)(D,{children:`Version`}),(0,h.jsx)(y,{version:s??null,loading:r&&!e.current_release_version,assistantId:e.id??null})]})}function E(e){return e>=1024?`${(e/1024).toFixed(1)} GB`:`${e.toFixed(0)} MB`}function D({children:e}){return(0,h.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e})}function O({children:e}){return(0,h.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:e})}export{g as i,E as n,w as r,T as t};