@vellumai/web 0.10.10-staging.2 → 0.10.10

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 (83) hide show
  1. package/dist/assets/{account-page-Cn_Ux2k8.js → account-page-B27dNQ3d.js} +1 -1
  2. package/dist/assets/{acp-run-detail-panel-hdemc9Ns.js → acp-run-detail-panel-B0k2rYpM.js} +1 -1
  3. package/dist/assets/{activity-steps-panel-CJDoPVUC.js → activity-steps-panel-LDydO3OK.js} +1 -1
  4. package/dist/assets/{ai-page-DX1CAGiX.js → ai-page-UMlli-yL.js} +1 -1
  5. package/dist/assets/{api-key-screen-C0F9Kodk.js → api-key-screen-BYdMayOl.js} +1 -1
  6. package/dist/assets/{background-task-detail-panel-B3sQQ2WB.js → background-task-detail-panel-wG11sk-D.js} +1 -1
  7. package/dist/assets/{billing-page-DbgQl5CS.js → billing-page-BHg4_D8p.js} +1 -1
  8. package/dist/assets/{bookmarks-page-Bg1kpqdy.js → bookmarks-page-Dj_WhT38.js} +1 -1
  9. package/dist/assets/{channels-page-route-Cm7KQpHs.js → channels-page-route-BLMC84yp.js} +1 -1
  10. package/dist/assets/{command-palette-B23DDF8y.js → command-palette-nEbCvF9B.js} +1 -1
  11. package/dist/assets/{command-palette-window-page-2gnvF4NV.js → command-palette-window-page-Um5WOMD9.js} +1 -1
  12. package/dist/assets/{community-page-De9KLKyn.js → community-page-BpLDD6Gw.js} +1 -1
  13. package/dist/assets/{contacts-page-route-CZwZ6baw.js → contacts-page-route-Na5xsrCM.js} +1 -1
  14. package/dist/assets/{credentials-page-st-zOas5.js → credentials-page-DiPIjJOv.js} +1 -1
  15. package/dist/assets/{debug-page-BhcVrLKj.js → debug-page-Op9gPo8_.js} +1 -1
  16. package/dist/assets/{deploy-dialogs-BJRrRbSc.js → deploy-dialogs-BNZpdpkW.js} +1 -1
  17. package/dist/assets/{detail-panel-stop-button-c0oweWwM.js → detail-panel-stop-button-QQ20Gb80.js} +1 -1
  18. package/dist/assets/{developer-page-DRakR84C.js → developer-page-CEm6gJ5c.js} +1 -1
  19. package/dist/assets/{dictation-overlay-page-jXIAQQGI.js → dictation-overlay-page-DFy73eLq.js} +1 -1
  20. package/dist/assets/{document-viewer-page-B6lpLvJw.js → document-viewer-page-BB8CFKzx.js} +1 -1
  21. package/dist/assets/{emails-page-ChYRO5ST.js → emails-page-DfS8M0KH.js} +1 -1
  22. package/dist/assets/{general-page-0F5njKZW.js → general-page-DRyIIgkk.js} +1 -1
  23. package/dist/assets/{hatching-screen-CW3BRgRH.js → hatching-screen-D0zBF6G3.js} +1 -1
  24. package/dist/assets/{home-page-route-D_8JCZ_Q.js → home-page-route-BMbIyFRk.js} +1 -1
  25. package/dist/assets/{hosting-screen-DHETBcAy.js → hosting-screen-Zb6-T1r9.js} +1 -1
  26. package/dist/assets/identity-page-route-BmQtmPF0.js +7 -0
  27. package/dist/assets/{index-CmaRQR9x.js → index-CgcZXB4g.js} +7 -7
  28. package/dist/assets/{inspect-page-Cj0WVion.js → inspect-page-Iemfgo7r.js} +1 -1
  29. package/dist/assets/{integrations-page-CH-pFd_e.js → integrations-page-8U6yrpy_.js} +1 -1
  30. package/dist/assets/{intelligence-layout-BHGZqgWE.js → intelligence-layout-Bk61phvn.js} +1 -1
  31. package/dist/assets/{latest-assistant-text-DqYv-19M.js → latest-assistant-text-cGlQO-ow.js} +1 -1
  32. package/dist/assets/{library-detail-page-D1SaX446.js → library-detail-page-BCRw2pXt.js} +1 -1
  33. package/dist/assets/{library-page-CY_UIQ7K.js → library-page-BCFKyR7R.js} +1 -1
  34. package/dist/assets/{logout-page-BsVCSXLH.js → logout-page-C27fK6LX.js} +1 -1
  35. package/dist/assets/{logs-layout-D_7jq15m.js → logs-layout-DrBxBaoW.js} +1 -1
  36. package/dist/assets/{memory-page-route-BGWq_aq8.js → memory-page-route-BdF70Wmp.js} +1 -1
  37. package/dist/assets/{memory-router-playground-page-DThWyhXE.js → memory-router-playground-page-BlT9oFs0.js} +1 -1
  38. package/dist/assets/{mobile-sidebar-drawer-XsUj_ej1.js → mobile-sidebar-drawer-BmS9adnj.js} +1 -1
  39. package/dist/assets/{notifications-page-4H3d3TVi.js → notifications-page-DsQJaAsR.js} +1 -1
  40. package/dist/assets/{oauth-complete-page-IYjT22S6.js → oauth-complete-page-BMqOW3MA.js} +1 -1
  41. package/dist/assets/{oauth-popup-complete-page-B2tgdOeo.js → oauth-popup-complete-page-D-r0oM8y.js} +1 -1
  42. package/dist/assets/{pairing-page-BsGxP4RT.js → pairing-page-CELMlJeG.js} +1 -1
  43. package/dist/assets/{personality-page-DWuNCYhT.js → personality-page-BdkuO-Fy.js} +1 -1
  44. package/dist/assets/{plugins-page-O4J9g6Y8.js → plugins-page-DblHkb06.js} +1 -1
  45. package/dist/assets/{prechat-route-CoHHHLoD.js → prechat-route-DcgCgSV8.js} +1 -1
  46. package/dist/assets/{privacy-page-DXHDyrXM.js → privacy-page-Ccn6St6F.js} +1 -1
  47. package/dist/assets/{privacy-screen-N6-nGjeG.js → privacy-screen-IqygR70e.js} +1 -1
  48. package/dist/assets/{provider-callback-page-B6zqXdPZ.js → provider-callback-page-fjZoTIWk.js} +1 -1
  49. package/dist/assets/{quick-input-page-UeFQo32q.js → quick-input-page-BmPU9B6u.js} +1 -1
  50. package/dist/assets/{research-mock-page-DL9B4Lli.js → research-mock-page-CssYNgG7.js} +1 -1
  51. package/dist/assets/{research-onboarding-route-CEPszqjJ.js → research-onboarding-route-sFu5EQW9.js} +1 -1
  52. package/dist/assets/{review-terms-screen-CchSUndG.js → review-terms-screen-Cv_jkYHP.js} +1 -1
  53. package/dist/assets/{schedules-page-Bj5HEJa-.js → schedules-page-DCFEdNCs.js} +1 -1
  54. package/dist/assets/{select-assistant-screen-BQLQKCB5.js → select-assistant-screen-B0qoVKd5.js} +1 -1
  55. package/dist/assets/{settings-layout-Dr3LiWJ0.js → settings-layout-B_NU6GFk.js} +1 -1
  56. package/dist/assets/{share-feedback-modal-DvC-1HRQ.js → share-feedback-modal-c0vGJBMA.js} +1 -1
  57. package/dist/assets/{sidebar-tree-r9N8LP3u.js → sidebar-tree-Cq8ACYzP.js} +1 -1
  58. package/dist/assets/{signup-page-B7lZHfHL.js → signup-page-CQLi5G7p.js} +1 -1
  59. package/dist/assets/{skill-detail-page-onU_WAHM.js → skill-detail-page-C_-DI2tN.js} +1 -1
  60. package/dist/assets/{skill-detail-panel-r5S_O0rZ.js → skill-detail-panel-J7W0DU8J.js} +1 -1
  61. package/dist/assets/{skills-page-Cf86q643.js → skills-page-BhMnBhiu.js} +1 -1
  62. package/dist/assets/{start-screen-kBX69v2m.js → start-screen-Cbh01xPj.js} +1 -1
  63. package/dist/assets/{subagent-detail-panel-D6oy2K_C.js → subagent-detail-panel-D9BXd8vR.js} +1 -1
  64. package/dist/assets/{system-events-page-CXkh6imt.js → system-events-page-BWbjCZVh.js} +1 -1
  65. package/dist/assets/{theme-stage-page-B1KCcRzM.js → theme-stage-page-DUeQZVJ3.js} +1 -1
  66. package/dist/assets/{tiptap-document-editor-BVFwGbyO.js → tiptap-document-editor-yCVhNTRu.js} +1 -1
  67. package/dist/assets/{tool-detail-panel-CI8Z5mU5.js → tool-detail-panel-Dtl2QLOW.js} +1 -1
  68. package/dist/assets/{upgrade-cancel-page-78mnz39g.js → upgrade-cancel-page-DmdDdCjG.js} +1 -1
  69. package/dist/assets/{upgrade-success-page-Dnqc4oxD.js → upgrade-success-page-DQoC2Y_H.js} +1 -1
  70. package/dist/assets/{use-assistant-identity-details-D0dDGwFZ.js → use-assistant-identity-details-D-gTqmOL.js} +1 -1
  71. package/dist/assets/{use-edge-swipe-back-CzIG6Agy.js → use-edge-swipe-back-Dpo-0Weh.js} +1 -1
  72. package/dist/assets/{use-invite-link-dialog-BLqplXYp.js → use-invite-link-dialog-DhVTs4OS.js} +1 -1
  73. package/dist/assets/{use-skill-actions-B58D56j9.js → use-skill-actions-fDejA0nc.js} +1 -1
  74. package/dist/assets/{use-skill-categories-BewT8dcB.js → use-skill-categories-DCOdxAre.js} +1 -1
  75. package/dist/assets/{use-skill-detail-files-S961Kf-o.js → use-skill-detail-files-DS6fk9Xz.js} +1 -1
  76. package/dist/assets/{voice-page-IaJC48fm.js → voice-page-BRscGXct.js} +1 -1
  77. package/dist/assets/{weather-forecast-display-Cd2sZBmz.js → weather-forecast-display-Dcw7Ta6D.js} +1 -1
  78. package/dist/assets/{welcome-screen-CUTRt2OQ.js → welcome-screen-C35jMBVC.js} +1 -1
  79. package/dist/assets/{workflow-detail-panel-BRYRq60N.js → workflow-detail-panel-CYjQlhPc.js} +1 -1
  80. package/dist/assets/{workspace-page-DgDej6f2.js → workspace-page-Dh-OnRd7.js} +1 -1
  81. package/dist/index.html +1 -1
  82. package/package.json +1 -1
  83. package/dist/assets/identity-page-route-B1o8eOMl.js +0 -7
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,r as n}from"./device-settings-DXp9L4iB.js";import{t as r}from"./capture-error-BGD3-GQf.js";import{t as i}from"./react-DJZBPgpf.js";import{t as a}from"./button-BQVYX8n_.js";import{m as o,t as s,u as c}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./useMutation-Lj4VunQV.js";import{t as f}from"./jsx-runtime-CVSDxk6A.js";import{t as p}from"./card-D8zyWtZh.js";import{t as m}from"./createLucideIcon-Bjb-Kuq7.js";import{t as h}from"./bell-BbESwsZk.js";import{t as g}from"./check-wF3S-AV4.js";import{t as _}from"./chevron-down-DpYf9Gwq.js";import{t as v}from"./circle-alert-CTnM6GCb.js";import{t as y}from"./circle-check-DqvTjWle.js";import{o as b}from"./list-row-9xgQystQ.js";import{t as x}from"./hard-drive-BxDRcYId.js";import{t as S}from"./loader-circle-D57RZgLH.js";import{t as C}from"./monitor-DTDBOcSy.js";import{t as w}from"./moon-Ci1LuSVx.js";import{t as T}from"./refresh-cw-CMEIZvPt.js";import{a as E,c as D,o as O,r as k,s as A,t as j}from"./resize-errors-B4T7-3eS.js";import{t as M}from"./sparkles-DDIsk_nZ.js";import{t as N}from"./triangle-alert-DXEpFOj_.js";import{t as P}from"./x-CswtfvgS.js";import{t as F}from"./notice-BylgS5W_.js";import{t as I}from"./progress-bar-Bqv7D4mZ.js";import{M as ee,N as L,i as R,j as z,n as te}from"./src-CDdn26Yb.js";import{t as ne}from"./tag-B6WeUtBW.js";import{t as B}from"./input-ZpyYt_a0.js";import{t as V}from"./toggle-QSEiPr3k.js";import{t as H}from"./modal-BtcwNEBj.js";import{n as U}from"./toast-ZoZVyeDI.js";import{t as re}from"./confirm-dialog-CCrDkChx.js";import{t as ie}from"./dropdown-BMNSccmo.js";import{C as W,D as ae,S as oe,_ as se,c as ce,f as le,g as ue,i as de,k as fe,l as pe,p as me,r as he}from"./local-mode-hyYI6_OH.js";import{t as G}from"./is-electron-DBOtwp5h.js";import{n as ge}from"./resolved-assistants-store-DdnJoLGS.js";import{r as _e,t as ve}from"./semver-CRR7tMUr.js";import{n as ye,r as be,t as xe}from"./api-errors-CDe82ZvY.js";import{E as Se,O as Ce,_ as we,a as Te,h as Ee,l as De,m as Oe,n as ke,v as Ae,w as je,x as Me,y as Ne}from"./auth-store-B6EXnaee.js";import{t as K}from"./client.gen-DZZugzSk.js";import{C as Pe,H as Fe,M as Ie,Rt as Le,T as Re,X as ze,Z as Be,j as Ve}from"./sdk.gen-BJsTUGAk.js";import{a as He,o as Ue}from"./api-BBMl4mW3.js";import{c as q}from"./routes-XPLb07Av.js";import{a as We,r as Ge}from"./platform-detection-1awANa55.js";import{t as J}from"./client-feature-flag-store-DeUwlUsr.js";import{A as Ke,At as qe,D as Je,E as Ye,F as Xe,M as Ze,Mt as Qe,Nt as $e,Ot as et,P as tt,T as nt,Tt as rt,bt as it,c as at,it as ot,j as st,jt as ct,k as lt,kt as ut,nt as dt,v as ft,w as pt,wt as mt}from"./react-query.gen-BXPoln4i.js";import{t as ht}from"./assistant-feature-flag-store-BpbbAIKZ.js";import{t as gt}from"./pointer-Cdz7NGHe.js";import{t as _t}from"./proxy-BzlH_XAe.js";import{t as vt}from"./AnimatePresence-C8APSgIu.js";import{t as yt}from"./use-reduced-motion-CcGT6CHV.js";import{Cn as bt,Fn as xt,Gi as St,In as Ct,Ln as wt,Lr as Tt,N as Et,P as Dt,Pn as Ot,Qt as kt,Ta as At,U as jt,Xn as Mt,Yi as Nt,Zn as Pt,fi as Ft,j as It,mi as Lt,na as Rt,pi as zt,ta as Bt,wt as Vt}from"./index-CmaRQR9x.js";import{t as Ht}from"./use-active-assistant-id-9rGx8kT9.js";import{t as Y}from"./detail-card-CA8lPa5K.js";import{t as Ut}from"./app-info-Dwct98Bb.js";import{t as Wt}from"./environment-store-D_Bc9wnl.js";import{a as Gt,i as Kt,n as qt,r as Jt,t as Yt}from"./assistant-status-panel-DDvWvhN1.js";import{t as Xt}from"./settings-divider-Dk_uJxp_.js";var Zt=m(`fingerprint-pattern`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),Qt=m(`vibrate`,[[`path`,{d:`m2 8 2 2-2 2 2 2-2 2`,key:`sv1b1`}],[`path`,{d:`m22 8-2 2 2 2-2 2 2 2`,key:`101i4y`}],[`rect`,{width:`8`,height:`14`,x:`8`,y:`5`,rx:`1`,key:`1oyrl4`}]]),X=e(i(),1),$t=Oe,en=`Please choose a different handle.`;async function tn(e,t){let{data:n,error:r,response:i}=await Ie({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:be(r,void 0,`Failed to save handle.`)??`Failed to save handle.`};if(i.ok&&n)return{kind:`ok`,data:n};if(i.status===409){let{message:e}=Ne(r,`handle`,$t.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=Ne(r,`handle`,en);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:be(r,i,`Failed to save handle.`)}}async function nn(e,t,n){let{data:r,error:i,response:a}=await Pe({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(ye(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new xe(a.status,a.status===429?`Too many checks — try again in a moment.`:be(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function rn(e){return/\d{2,}$/.test(e)}var Z=f(),an=300,on=1400;function sn({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:o,onSaved:s,saveSuccessToast:c,fieldId:l}){let[u,d]=(0,X.useState)(e),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[_,y]=(0,X.useState)(`idle`),[b,x]=(0,X.useState)(null),C=yt(),w=(0,X.useRef)(null),T=(0,X.useMemo)(()=>u.trim().toLowerCase(),[u]),E=T===e.toLowerCase();(0,X.useEffect)(()=>{if(E||T.length===0){h(!1),w.current?.abort();return}let e=new AbortController;w.current?.abort(),w.current=e,h(!0);let t=window.setTimeout(async()=>{try{let t=await i(T,e.signal);e.signal.aborted||p(t)}catch(t){e.signal.aborted||x(t instanceof Error?t.message:`Couldn't check availability.`)}finally{e.signal.aborted||h(!1)}},an);return()=>{window.clearTimeout(t),e.abort()}},[T,E,i]);let D=(()=>{if(b)return b;if(f&&!f.available){let e=f.code;return f.message??(e?$t[e]:`Please choose a different handle.`)}return null})(),O=D?n:E?r??null:m?`Checking availability…`:f?.available?`Available.`:null,k=!E&&!m&&f?.available!==!1&&_!==`saving`,A=(0,X.useCallback)(async()=>{if(!k)return;y(`saving`),x(null);let e=await o(T);if(e.kind===`ok`){y(`saved`),s(e.data),U.success(c),window.setTimeout(()=>y(`idle`),on);return}if(e.kind===`taken`){y(`idle`),p({available:!1,code:`taken`,message:e.message});return}if(e.kind===`invalid`){y(`idle`),p({available:!1,code:e.code,message:e.message});return}y(`error`),x(e.message),U.error(e.message)},[k,T,s,o,c]),j=(()=>{if(E&&u.length>0||u.length===0)return null;let e=m?`checking`:f?.available?`available`:f?.available===!1?`invalid`:null;return e?(0,Z.jsx)(vt,{mode:`wait`,initial:!1,children:(0,Z.jsxs)(_t.span,{initial:C?!1:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:C?void 0:{opacity:0,scale:.85},transition:{duration:.14,ease:`easeOut`},className:`flex items-center`,"aria-hidden":e!==`available`&&e!==`invalid`,children:[e===`checking`&&(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,Z.jsx)(g,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,Z.jsx)(v,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),M=(()=>{switch(_){case`saving`:return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(S,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Saving…`]});case`saved`:return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Saved`]});default:return`Save`}})();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(B,{label:t,value:u,onChange:e=>{d(e.target.value.replace(/\s+/g,``)),p(null),x(null)},autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,maxLength:30,leftIcon:(0,Z.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),rightIcon:j,errorText:D??void 0,helperText:O??void 0,"aria-invalid":!!D,fullWidth:!0,"data-testid":`${l}-input`}),(!E||_!==`idle`)&&(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(a,{variant:`primary`,size:`compact`,onClick:A,disabled:!k,"aria-live":`polite`,"data-testid":`${l}-save`,children:M})})]})}function cn({initial:e,onSaved:t}){let n=ke.use.refreshSession(),r=rn(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,X.useCallback)(async e=>await Ae({username:e}),[]),a=(0,X.useCallback)((e,t)=>Ee(e,t),[]),o=(0,X.useCallback)(e=>{t(e),n()},[t,n]);return(0,Z.jsx)(sn,{initialHandle:e.username,inputLabel:`User handle`,helperText:`Lowercase letters, digits, hyphens, and underscores. 3–30 characters.`,idleHelperText:r,checkAvailable:a,save:i,onSaved:o,saveSuccessToast:`Profile updated.`,fieldId:`user-handle`})}function ln({assistant:e,onSaved:t}){let n=e.handle??``,r=u({...at({path:{assistant_id:e.id}})}).data?.results?.[0],i=!!r&&r.subdomain.toLowerCase()===n.toLowerCase(),a=n.length===0?`Your assistant doesn't have a handle yet — claim one to make it mentionable.`:void 0,o=(0,X.useCallback)(async t=>await tn(e.id,t),[e.id]),c=(0,X.useCallback)((t,n)=>nn(e.id,t,n),[e.id]);return i?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(B,{label:`Assistant handle`,value:n,readOnly:!0,disabled:!0,leftIcon:(0,Z.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,Z.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Your assistant's handle is locked because it's used as its email subdomain. To change it,`,` `,(0,Z.jsx)(s,{to:`${q.settings.ai}?release=1#email`,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`,children:`release the subdomain`}),` `,`first.`]})]}):(0,Z.jsx)(sn,{initialHandle:n,inputLabel:`Assistant handle`,helperText:`Lowercase letters, digits, hyphens, and underscores. 3–30 characters.`,idleHelperText:a,checkAvailable:c,save:o,onSaved:t,saveSuccessToast:`Assistant handle updated.`,fieldId:`assistant-handle`})}function un(){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Z.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Z.jsx)(`div`,{className:`h-3 w-72 animate-pulse rounded bg-[var(--surface-muted)]`})]}),(0,Z.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`h-3 w-60 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Z.jsx)(`div`,{className:`h-7 w-16 animate-pulse rounded-md bg-[var(--surface-muted)]`})]}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Loading your profile…`})]})}function dn(){return(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`})}function fn({assistant:e,showHandles:t=!0,children:n}={}){let r=ke.use.user?.()?.email??null;return(0,Z.jsx)(Y,{title:`Profile`,subtitle:`Manage your account details and preferences.`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[r&&(0,Z.jsx)(`div`,{className:`max-w-[420px]`,children:(0,Z.jsx)(B,{label:`Email`,value:r,disabled:!0,readOnly:!0})}),t&&(0,Z.jsxs)(Z.Fragment,{children:[r&&(0,Z.jsx)(dn,{}),(0,Z.jsx)(pn,{assistant:e})]}),n!=null&&(0,Z.jsxs)(Z.Fragment,{children:[(r||t)&&(0,Z.jsx)(dn,{}),n]})]})})}function pn({assistant:e}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(null),a=yt(),[o,s]=(0,X.useState)(e??null);return(0,X.useEffect)(()=>{s(e??null)},[e]),(0,X.useEffect)(()=>{let e=!1;return we().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),r?(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,Z.jsxs)(_t.div,{initial:a?!1:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.22,ease:`easeOut`},className:`flex flex-col gap-6`,children:[(0,Z.jsx)(cn,{initial:t,onSaved:n}),o&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Z.jsx)(ln,{assistant:o,onSaved:s})]})]}):(0,Z.jsx)(un,{})}var mn=ft({query:{hosting:`platform`}});function hn(){let e=Ht(),t=u(mn),n=t.data?.results??[];return t.isPending||n.length<2?null:(0,Z.jsx)(Y,{title:`Switch Assistant`,subtitle:`Choose which assistant is active for this account.`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>{let n=t.id===e;return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-lg border px-4 py-3 ${n?`border-[var(--border-focus)] bg-[var(--surface-lift)]`:`border-[var(--border-base)] bg-[var(--surface-default)]`}`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(C,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:t.name||`Unnamed`}),t.status!==`active`&&(0,Z.jsx)(ne,{tone:`warning`,children:t.status})]})})]}),(0,Z.jsx)(`div`,{className:`shrink-0`,children:n?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,Z.jsx)(g,{className:`h-4 w-4`}),`Active`]}):(0,Z.jsx)(a,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{Ce(t.id),U.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var gn=[{label:`Never`,seconds:0},{label:`5 min`,seconds:300,devOnly:!0},{label:`10 min`,seconds:600,devOnly:!0},{label:`1 hour`,seconds:3600},{label:`3 hours`,seconds:10800},{label:`1 day`,seconds:86400},{label:`3 days`,seconds:259200},{label:`7 days`,seconds:604800},{label:`14 days`,seconds:1209600},{label:`30 days`,seconds:2592e3}];function _n(e){if(e===0)return`Never (sleep disabled)`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600);if(t>0&&n>0)return`${t}d ${n}h`;if(t>0)return`${t} day${t===1?``:`s`}`;if(n>0)return`${n} hour${n===1?``:`s`}`;let r=Math.floor(e/60);return r>0?`${r} minute${r===1?``:`s`}`:`${e}s`}function vn({assistantId:e}){let t=l(),n=Wt.use.isNonProduction(),r=(0,X.useMemo)(()=>gn.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:o,isError:s}=u(st({path:{id:e}})),c=(0,X.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[d,f]=(0,X.useState)(null),p=d??c,m=d!==null,h=rt({onSuccess:()=>{U.success(`Sleep policy saved.`),f(null),t.invalidateQueries({queryKey:Ze({path:{id:e}})})},onError:()=>{U.error(`Failed to save sleep policy. Please try again.`)}});return o?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):s?(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:`Failed to load sleep policy. Refresh the page to try again.`}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Idle timeout`}),(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`How long the assistant can be idle before it is put to sleep. "Never" disables idle sleep entirely.`}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:r.map(e=>(0,Z.jsx)(a,{variant:`outlined`,active:p===e.seconds,onClick:()=>f(e.seconds),children:e.label},e.seconds))}),(0,Z.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,_n(p)]})]}),m&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(a,{variant:`primary`,leftIcon:h.isPending?(0,Z.jsx)(S,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,Z.jsx)(a,{variant:`outlined`,onClick:()=>f(null),disabled:h.isPending,children:`Cancel`})]})]})}function yn(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var bn=3e3;function xn({version:e,assistantId:t}){let{onTap:n,message:r}=Kt(t);return(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`block min-w-0 break-all text-left text-body-medium-lighter text-[var(--content-default)]`,onClick:n,children:e??`—`}),r&&(0,Z.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:r})]})}function Sn({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=ht.use.rollbackEnabled(),o=J.use.previewChannel(),s=l(),c=xt(n,o),f=c===`preview`,[p,m]=(0,X.useState)(!1),h=(0,X.useRef)(null),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[C,w]=(0,X.useState)(null),E=e=>e&&h.current&&e===h.current?(queueMicrotask(()=>{w(b?`Successfully rolled back to version ${h.current}.`:`Successfully updated to version ${h.current}.`),m(!1),h.current=null,_(null),U.success(b?`Rollback complete — assistant is healthy.`:`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),r?.()}),!1):bn;u({...lt({path:{id:e}}),refetchInterval:p?e=>E(e.state.data?.current_release_version):!1});let{data:D,isLoading:O}=u(it({query:{channel:c}})),k=D?.find(e=>e.is_stable!==!1)??D?.[0],A=g??k?.version??null,j=(0,X.useMemo)(()=>{if(!i||!A||!t)return!1;let e=_e(A),n=_e(t);return!e||!n?!1:ve(e,n)<0},[i,A,t]),M=(0,X.useMemo)(()=>{if(!A)return!1;if(!t)return!0;let e=_e(A),n=_e(t);if(!e||!n)return A!==t;let r=ve(e,n);return i?r!==0:r>0},[i,A,t]),N=d({mutationFn:async t=>{let{data:n}=await ze({path:{id:e},body:t,throwOnError:!0});return n}}),P=d({mutationFn:async t=>{let{data:n}=await Fe({path:{id:e},body:t,throwOnError:!0});return n}});return(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 md:grid md:grid-cols-[auto_minmax(0,1fr)] md:items-center md:gap-x-8 md:gap-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Z.jsx)(xn,{version:t,assistantId:e})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:f?`Preview release`:M?j?`Rollback to`:`Update to`:`Selected`}),(0,Z.jsx)(`span`,{className:`block min-w-0`,children:O?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(S,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):D&&D.length>0?i?(0,Z.jsx)(ie,{value:A??``,onChange:e=>_(e===k?.version?null:e),disabled:p||N.isPending||P.isPending,options:D.map(e=>({value:e.version,label:yn(e,t,k?.version)}))}):(0,Z.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:k?yn(k,t,k.version):`—`}):`No releases available`})]})]}),(0,Z.jsx)(a,{variant:j?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:N.isPending||P.isPending||p?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(T,{}),onClick:()=>y(!0),disabled:!M||N.isPending||P.isPending||p||O||!D?.length,children:p?b?`Rolling back...`:`Updating...`:j?`Rollback`:f?`Update preview`:`Update`}),f&&(0,Z.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Using Preview releases.`,` `,(0,Z.jsx)(`a`,{href:`#preview-release-channel`,className:`text-[var(--primary-base)] underline-offset-2 hover:underline`,children:`Switch back to Stable`})]}),!M&&t&&A&&!O&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:C??`You are already on this version.`}),(0,Z.jsx)(re,{open:v,title:j?`Rollback assistant`:f?`Update preview release`:`Update assistant`,message:j?`Rollback to version ${A??`unknown`}? The assistant will be briefly unavailable.`:f?`Update to preview version ${A??`latest`}? The assistant will be briefly unavailable during the update.`:`Update to version ${A??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:j?`Rollback`:f?`Update preview`:`Update`,onConfirm:async()=>{y(!1),w(null);let t=g??void 0;try{if(j){let e=await P.mutateAsync({version:t});h.current=e.version??t??null,U.success(e.detail||`Rollback to ${t} initiated.`)}else{let e=await N.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){U.warning(e.detail);return}h.current=e.version??t??null,U.success(e.detail||`Update to ${e.version??t??`latest`} initiated.`)}x(j),m(!0),s.invalidateQueries({queryKey:Ke({path:{id:e}})})}catch{U.error(j?`Failed to trigger rollback. Please try again.`:`Failed to trigger update. Please try again.`)}},onCancel:()=>y(!1)})]})}function Cn({assistantId:e,currentVersion:t,onUpgradeComplete:n}){let[r,i]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null),{data:c,isLoading:l}=u(it({query:{stable:!0,limit:100}})),d=(0,X.useMemo)(()=>Ot(c),[c]),f=d?.version,p=t?Ct(t,f):!!f,m=wt({assistantId:e,targetVersion:f});return(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 md:grid md:grid-cols-[auto_minmax(0,1fr)] md:items-center md:gap-x-8 md:gap-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Z.jsx)(xn,{version:t,assistantId:e})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Update to`}),(0,Z.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:l?`Loading...`:f&&d?yn(d,t,f):`No releases available`})]})]}),(0,Z.jsx)(a,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(T,{}),onClick:()=>i(!0),disabled:m.isPending||l||!f||!p,children:m.isPending?`Updating...`:f?`Update to ${f}`:`Update`}),o&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:o}),!o&&!p&&f&&!l&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:`You are already on this version.`}),(0,Z.jsx)(re,{open:r,title:`Update assistant`,message:`Update to version ${f??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:`Update`,onConfirm:async()=>{i(!1),s(null);try{let e=await m.upgrade();s(e.version?`Successfully updated to version ${e.version}.`:`Successfully updated to version ${f??`latest`}.`),U.success(`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),n?.()}catch(e){U.error(e instanceof Error?e.message:`Failed to trigger update. Please try again.`)}},onCancel:()=>i(!1)})]})}function wn(){let e=Lt({platformHostedOnly:!0}),t=zt(),n=ke.use.user()?.id??null,r=ke.use.logout(),[i,o]=(0,X.useState)(!1),s=et({onSuccess:async()=>{U.success(`Account deletion requested. You will be logged out shortly.`),De(n),await r(),Tt(q.account.login)},onError:()=>{U.error(`Failed to request account deletion. Please try again.`)}}),c=e===`full`&&t;return(0,X.useEffect)(()=>{c&&i&&o(!1)},[c,i]),e===`gated`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Delete Account`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently delete your account and all associated data.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:e===`disabled`?(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to delete your account.`}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(a,{variant:`dangerOutline`,onClick:()=>o(!0),disabled:s.isPending||c,className:`self-start`,children:`Delete My Account`}),c&&(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})})]}),(0,Z.jsx)(re,{open:i,title:`Delete Account`,message:`This will permanently delete your account and all associated data. This action cannot be undone.`,confirmLabel:`Delete Account`,destructive:!0,onConfirm:()=>{if(c){o(!1);return}o(!1),s.mutate({})},onCancel:()=>o(!1)})]})}function Tn({title:e,subtitle:t,benefits:n,ctaLabel:r,ctaLeftIcon:i,onAction:o}){return(0,Z.jsx)(Y,{title:e,subtitle:t,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(`ul`,{className:`space-y-3`,children:n.map(({icon:e,text:t})=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,Z.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,Z.jsx)(a,{variant:`primary`,size:`regular`,leftIcon:i,onClick:o,className:`self-start`,children:r})]})})}function En(){return We()?(0,Z.jsx)(Tn,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:h,text:`Push notifications`},{icon:Zt,text:`Biometric login`},{icon:Qt,text:`Native haptics`},{icon:Nt,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,Z.jsx)(Nt,{size:16}),onAction:()=>{Et(),It()}}):null}async function Dn(){if(!G())return[];let e=window.vellum;return e?.hotkeys?e.hotkeys.get():[]}async function On(e,t){if(!G())return;let n=window.vellum;n?.hotkeys&&await n.hotkeys.set(e,t)}function kn(e){if(!G())return()=>{};let t=window.vellum;return t?.hotkeys?t.hotkeys.onChange(e):()=>{}}var An={ArrowUp:`Up`,ArrowDown:`Down`,ArrowLeft:`Left`,ArrowRight:`Right`,Enter:`Return`,NumpadEnter:`Return`,Space:`Space`,Tab:`Tab`,Escape:`Escape`,Backspace:`Backspace`,Delete:`Delete`,Insert:`Insert`,Home:`Home`,End:`End`,PageUp:`PageUp`,PageDown:`PageDown`,Minus:`-`,Equal:`=`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,Semicolon:`;`,Quote:`'`,Backquote:"`",Comma:`,`,Period:`.`,Slash:`/`},jn=new Set([`MetaLeft`,`MetaRight`,`ControlLeft`,`ControlRight`,`AltLeft`,`AltRight`,`ShiftLeft`,`ShiftRight`]),Mn=e=>{let t=e.code;return jn.has(t)?null:/^Key[A-Z]$/.test(t)?t.slice(3):/^Digit[0-9]$/.test(t)?t.slice(5):/^Numpad[0-9]$/.test(t)?`num${t.slice(6)}`:/^F[0-9]{1,2}$/.test(t)?t:An[t]??null},Nn=e=>{let t=Mn(e);if(t===null)return null;let n=[];return e.metaKey&&n.push(`CmdOrCtrl`),e.ctrlKey&&n.push(`Control`),e.altKey&&n.push(`Alt`),e.shiftKey&&n.push(`Shift`),[...n,t].join(`+`)},Pn=(e,t,n)=>n===``?null:e.find(e=>e.key!==t&&e.accelerator===n)??null,Fn=[{scope:`global`,title:`Global shortcuts`,description:`Work anywhere, even when Vellum is in the background.`},{scope:`menu`,title:`App shortcuts`,description:`Work while a Vellum window is focused.`}];function In({hotkey:e,recording:t,conflictLabel:n,onStartRecording:r,onCancelRecording:i,onReset:o,onRemove:s}){let c=e.accelerator===``,l=e.override!==null;return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-body-medium-lighter text-[var(--content-default)]`,children:e.label}),n!==null&&(0,Z.jsxs)(`div`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:[`Already used by `,n]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Recording… press a shortcut, or Esc to cancel`}):c?(0,Z.jsx)(`span`,{className:`text-body-small-default italic text-[var(--content-disabled)]`,children:`Disabled`}):(0,Z.jsx)(te,{accelerator:e.accelerator}),t?(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,onClick:i,children:`Cancel`}):(0,Z.jsx)(a,{variant:`outlined`,size:`compact`,onClick:r,"aria-label":`Record shortcut for ${e.label}`,children:`Record`}),(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,disabled:!l,leftIcon:(0,Z.jsx)(Bt,{className:`h-3.5 w-3.5`}),onClick:o,"aria-label":`Reset ${e.label} to default`}),(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,disabled:c,leftIcon:(0,Z.jsx)(P,{className:`h-3.5 w-3.5`}),onClick:s,"aria-label":`Remove ${e.label} binding`})]})]})}function Ln(){let[e,t]=(0,X.useState)([]),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(null),o=(0,X.useCallback)(()=>{Dn().then(t)},[]);(0,X.useEffect)(()=>(o(),kn(t)),[o]);let s=(0,X.useCallback)(()=>{r(null),a(null)},[]);(0,X.useEffect)(()=>{if(n===null)return;let t=t=>{if(t.preventDefault(),t.stopPropagation(),t.code===`Escape`){s();return}let r=Nn(t);if(r===null)return;let i=Pn(e,n,r);if(i!==null){a({key:n,label:i.label});return}On(n,r).then(o),s()};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[n,e,o,s]);let c=(0,X.useCallback)(e=>{a(null),r(e)},[]),l=(0,X.useCallback)(t=>{let n=Pn(e,t,e.find(e=>e.key===t)?.defaultAccelerator??``);if(n!==null){r(null),a({key:t,label:n.label});return}s(),On(t,null).then(o)},[e,o,s]),u=(0,X.useCallback)(e=>{s(),On(e,``).then(o)},[o,s]),d=(0,X.useMemo)(()=>Fn.map(t=>({...t,commands:e.filter(e=>e.rebindable&&e.scope===t.scope)})).filter(e=>e.commands.length>0),[e]);return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[i!==null&&(0,Z.jsxs)(F,{tone:`warning`,children:[`That shortcut is already used by `,i.label,`.`,` `,n===null?`Remove or change that binding before resetting.`:`Pick a different combination, or press Esc to cancel.`]}),d.map(e=>(0,Z.jsxs)(p,{bordered:!0,children:[(0,Z.jsxs)(`div`,{className:`mb-2`,children:[(0,Z.jsx)(`div`,{className:`text-body-medium-emphasised text-[var(--content-default)]`,children:e.title}),(0,Z.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e.description})]}),(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.commands.map(e=>(0,Z.jsx)(In,{hotkey:e,recording:n===e.key,conflictLabel:i!==null&&i.key===e.key?i.label:null,onStartRecording:()=>c(e.key),onCancelRecording:s,onReset:()=>l(e.key),onRemove:()=>u(e.key)},e.key))})]},e.scope))]})}async function Rn(){if(!G())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function zn(e){if(!G())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function Bn(){let e=J.use.velvet(),{theme:t,setThemePreference:n}=bt(),r=[{value:`system`,label:`System`,icon:(0,Z.jsx)(C,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,Z.jsx)(St,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,Z.jsx)(w,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,Z.jsx)(At,{className:`h-4 w-4`})}]:[]];return(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Appearance`}),(0,Z.jsx)(`div`,{className:`mt-2 max-w-[360px]`,children:(0,Z.jsx)(z,{ariaLabel:`Theme`,value:t,onChange:n,items:r})})]})}function Vn(){let e=Dt.useValue();if(gt())return null;let t=Ge()?`Cmd`:`Ctrl`;return(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Composer`}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(V,{checked:e,onChange:Dt.save,label:`Send with ${t}+Enter`,helperText:`When enabled, Enter inserts a new line and ${t}+Enter sends.`})})]})}function Hn(){let[e,t]=(0,X.useState)(!1);(0,X.useEffect)(()=>{Rn().then(t)},[]);let n=async e=>{t(e);try{await zn(e)}catch{t(!e)}};return(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Launch at Login`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Automatically start Vellum when you log in to your Mac.`}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(V,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})]})}function Un({open:e,onClose:t}){return(0,Z.jsx)(H.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,Z.jsxs)(H.Content,{size:`lg`,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{children:`Preferences`}),(0,Z.jsx)(H.Description,{children:`Customize shortcuts and how Vellum behaves on this device.`})]}),(0,Z.jsx)(H.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsx)(Bn,{}),G()&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Keyboard Shortcuts`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Customize the shortcuts for Vellum's commands.`}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(Ln,{})})]}),(0,Z.jsx)(Vn,{}),G()&&(0,Z.jsx)(Hn,{})]})})]})})}function Wn(e){return e===`preview`?`preview`:`stable`}function Gn(e){if(!e)return`Unknown`;let t=new Date(e);return Number.isNaN(t.getTime())?`Unknown`:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function Kn(e){return e.source_release_version?`Stable ${e.source_release_version}`:e.snapshot_name}function qn(e){return e.filter(e=>e.ready_to_use)}function Jn(e){return e?.feature_enabled===!1}function Yn({assistantId:e,onComplete:t}){let n=J.use.previewChannel(),r=l(),[i,a]=(0,X.useState)(),[o,s]=(0,X.useState)(!1),[c,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(`restore_backup`),[h,g]=(0,X.useState)(``),v=Ye({path:{assistant_id:e}}),y=Je({path:{assistant_id:e}}),b=Ke({path:{id:e}}),{data:x,isLoading:C,isError:w}=u({...v,enabled:n,retry:!1}),T=x?.preview_backups??[],E=(0,X.useMemo)(()=>qn(T),[T]),D=E[0],O=E.find(e=>e.snapshot_name===h)??D,k=()=>{r.invalidateQueries({queryKey:y}),r.invalidateQueries({queryKey:b}),t?.()},A=d(pt()),j=d(nt()),M=Wn(x?.current_channel),N=A.isPending||j.isPending,P=N||Jn(x)||!x?.latest_preview_release,I=p===`restore_backup`&&!O;if((0,X.useEffect)(()=>{a(M===`preview`?`release-channel`:void 0)},[M]),!n)return null;let ee=x?.standard_upgrade_available??!1;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R.Root,{type:`single`,collapsible:!0,value:i,onValueChange:e=>a(e||void 0),className:`mt-5 border-t border-[var(--border-base)] pt-5`,children:(0,Z.jsxs)(R.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,Z.jsxs)(R.Trigger,{className:`group justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Release Channel`}),x&&(0,Z.jsx)(ne,{tone:M===`preview`?`warning`:`neutral`,children:M===`preview`?`Preview`:`Stable`})]}),(0,Z.jsx)(_,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Z.jsx)(R.Content,{children:(0,Z.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[C&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),w&&(0,Z.jsx)(F,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),x&&(0,Z.jsxs)(Z.Fragment,{children:[Jn(x)&&(0,Z.jsx)(F,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),M===`stable`?(0,Z.jsx)(Xn,{status:x,isChangingChannel:N,optInDisabled:P,onOptIn:()=>s(!0)}):(0,Z.jsx)(Zn,{status:x,isChangingChannel:N,onOptOut:()=>{let e=D;g(e?.snapshot_name??``),m(e?`restore_backup`:ee?`standard_upgrade`:`restore_backup`),f(!0)}})]})]})})]})}),(0,Z.jsx)($n,{open:o,isPending:A.isPending,previewVersion:x?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await A.mutateAsync({path:{assistant_id:e}});U.success(t.detail||`Preview channel enabled.`),s(!1),k()}catch(e){U.error(be(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,Z.jsx)(er,{open:c,backups:E,mode:p,selectedSnapshotName:O?.snapshot_name??``,isPending:j.isPending,restoreModeDisabled:I,standardUpgradeAvailable:ee,onModeChange:m,onSnapshotChange:g,onConfirm:async()=>{if(!I)try{let t=await j.mutateAsync({path:{assistant_id:e},body:p===`restore_backup`?{mode:`restore_backup`,snapshot_name:O?.snapshot_name}:{mode:`standard_upgrade`}});U.success(t.detail||`Stable channel enabled.`),f(!1),k()}catch(e){U.error(be(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>f(!1)})]})}function Xn({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Qn,{status:e}),!e.latest_preview_release&&(0,Z.jsx)(F,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,Z.jsx)(a,{variant:`outlined`,leftIcon:t?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(Rt,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function Zn({status:e,isChangingChannel:t,onOptOut:n}){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Qn,{status:e}),(0,Z.jsx)(a,{variant:`outlined`,leftIcon:t?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(Bt,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function Qn({status:e}){return(0,Z.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Stable`}),(0,Z.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??`None`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Preview`}),(0,Z.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_preview_release?.version??`None`})]})]})}function $n({open:e,isPending:t,previewVersion:n,onConfirm:r,onCancel:i}){return(0,Z.jsx)(H.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,Z.jsxs)(H.Content,{size:`md`,hideCloseButton:t,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{icon:N,children:`Opt in to Preview`}),(0,Z.jsx)(H.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,Z.jsx)(H.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(F,{tone:`warning`,title:`Data loss may occur when returning to Stable`,children:`Preview data may not be compatible with the Stable channel. The safety backup lets you restore the Stable-channel data that existed before opt-in.`}),(0,Z.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,Z.jsx)(`li`,{children:`Create and verify a Preview safety backup.`}),(0,Z.jsxs)(`li`,{children:[`Switch to Preview image `,n??`latest`,`.`]}),(0,Z.jsx)(`li`,{children:`Run the normal upgrade path and wait for health.`})]})]})}),(0,Z.jsxs)(H.Footer,{children:[(0,Z.jsx)(a,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,Z.jsx)(a,{variant:`primary`,disabled:t,leftIcon:t?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(Rt,{}),onClick:r,children:t?`Switching...`:`Take Backup and Switch`})]})]})})}function er({open:e,backups:t,mode:n,selectedSnapshotName:r,isPending:i,restoreModeDisabled:o,standardUpgradeAvailable:s,onModeChange:c,onSnapshotChange:l,onConfirm:u,onCancel:d}){return(0,Z.jsx)(H.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,Z.jsxs)(H.Content,{size:`md`,hideCloseButton:i,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{icon:N,children:`Switch back to Stable`}),(0,Z.jsx)(H.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,Z.jsx)(H.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(L,{value:n,onValueChange:c,disabled:i,"aria-label":`Stable channel return method`,children:[(0,Z.jsx)(ee,{value:`restore_backup`,disabled:t.length===0,label:`Restore safety backup`,helperText:`Return to the Stable-channel data captured before Preview opt-in.`}),(0,Z.jsx)(ee,{value:`standard_upgrade`,disabled:!s,label:`Switch to Stable without restoring backup`,helperText:s?`Keep the current data and directly switch to the Stable image.`:`Unavailable because the latest Stable release is older than this assistant's Preview release.`})]}),n===`restore_backup`&&t.length>0&&(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[`Safety backup`,(0,Z.jsx)(ie,{value:r,onChange:l,disabled:i,options:t.map(e=>({value:e.snapshot_name,label:`${Kn(e)} - ${Gn(e.created_at)}`}))})]}),n===`restore_backup`&&t.length===0&&!s&&(0,Z.jsx)(F,{tone:`error`,title:`Stable requires a safety backup`,children:`This Preview release is newer than the latest Stable release, so switching directly is blocked. Wait for a newer Stable release, or run Vellum Doctor if the safety backup is missing.`}),n===`standard_upgrade`&&(0,Z.jsx)(F,{tone:`error`,title:`Preview data may not survive this`,children:`Switching directly to the Stable image without restoring the safety backup may cause data loss or leave the assistant unusable if Preview data is incompatible with Stable.`})]})}),(0,Z.jsxs)(H.Footer,{children:[(0,Z.jsx)(a,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,Z.jsx)(a,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||o||n===`standard_upgrade`&&!s,leftIcon:i?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(T,{}),onClick:u,children:i?`Switching...`:`Switch to Stable`})]})]})})}function tr({assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:o}){let l=c(),d=u(ot()),f=d.data,p=!e.is_local,m=f?.plan_id===`pro`,h=u({...dt(),enabled:m}),g=e.machine_size||`small`,_=E(h.data?.max_machine_tier??null),v=(0,X.useMemo)(()=>O(_,g,(0,Z.jsx)(ne,{tone:`positive`,children:`Current`})),[_,g]),y=h.data?.selected_storage_gib??null,[b,C]=(0,X.useState)(!1),w=_.length>0?_[_.length-1]:null,[N,P]=(0,X.useState)(null),I=N??w??g,[ee,L]=(0,X.useState)(null),[R,z]=(0,X.useState)(null),te=mt({onSuccess:(e,n)=>{U.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),z(null),P(null),C(!1),n.body?.machine_size==null?i():o(t)},onError:e=>{z(j(e,`Failed to resize assistant. Please try again.`))}});if(d.isError&&f==null)return(0,Z.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Z.jsx)(F,{tone:`error`,children:`Could not load your subscription. Please try again.`})});let B=m&&_.includes(I)&&I!==g?I:null,V=m&&y!=null&&!0,re=m&&_.length>0&&A(g)<A(_[_.length-1]),W=te.isPending||r,ae=y==null?t?.disk?.totalMb??null:y*1024,oe=t?.disk&&ae!=null?{value:t.disk.usedMb,max:ae,caption:`${Yt(t.disk.usedMb)} of ${Yt(ae)}`}:null,se=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,ce=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${Yt(t.memory.currentMb)} of ${Yt(t.memory.maxMb)}`}:null,le=p?m?V?(0,Z.jsxs)(`button`,{type:`button`,disabled:W,onClick:()=>C(!0),className:`flex items-center gap-1.5 rounded-lg border border-amber-500/30 bg-amber-500/15 px-3 py-1.5 text-body-small-default font-medium text-amber-400 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,children:[(0,Z.jsx)(M,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,disabled:W,onClick:()=>C(!0),children:`Resize`}):(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,onClick:()=>L(`storage`),children:`Resize`}):null,ue=p?m?re?(0,Z.jsxs)(`button`,{type:`button`,disabled:W,onClick:()=>C(!0),className:`flex items-center gap-1.5 rounded-lg border border-amber-500/30 bg-amber-500/15 px-3 py-1.5 text-body-small-default font-medium text-amber-400 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,children:[(0,Z.jsx)(M,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,disabled:W,onClick:()=>C(!0),children:`Resize`}):(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,onClick:()=>L(`machine`),children:`Resize`}):null;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,compactAccessory:!0,accessory:(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(T,{}),tooltip:r?`Applying resize…`:`Refresh resource metrics`,"aria-label":`Refresh resource metrics`,disabled:n||r,onClick:()=>void i()}),children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Z.jsx)(x,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),le]}),(0,Z.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Storage`}),oe?(0,Z.jsx)(Gt,{value:oe.value,max:oe.max,caption:oe.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Unavailable`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Z.jsx)(D,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Machine`}),(0,Z.jsx)(ne,{tone:`neutral`,children:k[g]})]}),ue]}),(0,Z.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`CPU`}),se?(0,Z.jsx)(Gt,{value:se.value,max:se.max,caption:se.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Memory`}),ce?(0,Z.jsx)(Gt,{value:ce.value,max:ce.max,caption:ce.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,Z.jsx)(H.Root,{open:ee!=null,onOpenChange:e=>{e||L(null)},children:(0,Z.jsxs)(H.Content,{size:`sm`,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{children:`Upgrade to Pro`}),(0,Z.jsx)(H.Description,{children:ee===`storage`?`Upgrade to the Pro plan to increase your storage allocation and get more space for your assistant.`:`Upgrade to the Pro plan to unlock larger machine sizes with more CPU and memory for your assistant.`})]}),(0,Z.jsxs)(H.Footer,{children:[(0,Z.jsx)(a,{variant:`ghost`,onClick:()=>L(null),children:`Cancel`}),(0,Z.jsx)(a,{onClick:()=>{L(null),l(`${q.settings.billing}?adjust_plan=1`)},children:`Upgrade`})]})]})}),(0,Z.jsx)(H.Root,{open:b,onOpenChange:e=>{e||(C(!1),P(null),z(null))},children:(0,Z.jsxs)(H.Content,{size:`sm`,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{icon:D,children:`Resize Assistant`}),(0,Z.jsx)(H.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,Z.jsx)(H.Body,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[_.length===0?(0,Z.jsx)(F,{tone:`warning`,children:`No machine tier configured. Visit the community for help.`}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:`Machine Size`}),(0,Z.jsx)(ie,{options:v,value:I,onChange:P,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),V?(0,Z.jsx)(F,{tone:`info`,children:`Storage will be expanded to ${y} GiB.`}):(0,Z.jsx)(F,{tone:`neutral`,children:`Storage will not change.`}),R&&(0,Z.jsx)(F,{tone:`error`,children:R})]})}),(0,Z.jsxs)(H.Footer,{className:`items-center justify-between`,children:[(0,Z.jsxs)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:[`Need more?`,` `,(0,Z.jsx)(s,{to:`${q.settings.billing}?adjust_plan=1`,className:`text-[var(--content-secondary)] underline decoration-[var(--border-element)] underline-offset-2 transition-colors hover:text-[var(--content-default)]`,onClick:()=>C(!1),children:`Upgrade plan`})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(a,{variant:`ghost`,onClick:()=>{C(!1),P(null),z(null)},children:`Cancel`}),(0,Z.jsx)(a,{disabled:B==null&&!V||W,leftIcon:W?(0,Z.jsx)(S,{className:`animate-spin`}):void 0,onClick:()=>{z(null);let t={};B!=null&&(t.machine_size=B),V&&y!=null&&(t.storage_gib=y),te.mutate({path:{id:e.id},body:t})},children:R?`Retry`:`Apply`})]})]})]})})]})}function nr({assistantId:e}){let t=c(),[n,r]=(0,X.useState)(!1),[i,o]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(a,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,Z.jsx)(Mt,{open:n,isPending:i,onConfirm:async()=>{o(!0);let n=await Pt(e);if(n.ok){r(!1),t(n.nextRoute,{replace:!0});return}U.error(n.error),o(!1),r(!1)},onCancel:()=>r(!1)})]})}var rr=`UTC.Africa/Cairo.Africa/Johannesburg.Africa/Lagos.Africa/Nairobi.America/Anchorage.America/Argentina/Buenos_Aires.America/Bogota.America/Chicago.America/Denver.America/Halifax.America/Lima.America/Los_Angeles.America/Mexico_City.America/New_York.America/Phoenix.America/Santiago.America/Sao_Paulo.America/Toronto.America/Vancouver.Asia/Bangkok.Asia/Dubai.Asia/Hong_Kong.Asia/Jakarta.Asia/Jerusalem.Asia/Karachi.Asia/Kolkata.Asia/Kuala_Lumpur.Asia/Manila.Asia/Seoul.Asia/Shanghai.Asia/Singapore.Asia/Taipei.Asia/Tokyo.Australia/Melbourne.Australia/Perth.Australia/Sydney.Europe/Amsterdam.Europe/Athens.Europe/Berlin.Europe/Brussels.Europe/Dublin.Europe/Istanbul.Europe/Lisbon.Europe/London.Europe/Madrid.Europe/Moscow.Europe/Paris.Europe/Rome.Europe/Stockholm.Europe/Vienna.Europe/Warsaw.Europe/Zurich.Pacific/Auckland.Pacific/Honolulu`.split(`.`);function ir(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...rr].sort()}function ar(e){let t=e.split(`/`),n=(t[t.length-1]??e).replace(/_/g,` `),r=t.length>1?(t[0]??``).replace(/_/g,` `):``,i=0,a=``;try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??`GMT`;a=t.startsWith(`GMT`)||t.startsWith(`UTC`)?t:`GMT ${t}`;let n=t.match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(n){let e=n[1]===`-`?-1:1,t=parseInt(n[2]??`0`,10),r=parseInt(n[3]??`0`,10);i=e*(t*60+r)}}catch{return null}return{identifier:e,city:n,region:r,offsetLabel:a,offsetMinutes:i}}function or(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function sr(e){if(!e)return`Not set`;try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`long`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value;if(t)return t}catch{}return e.replace(/_/g,` `)}function cr({value:e,onChange:t}){let[n,r]=(0,X.useState)(``),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(null),l=(0,X.useRef)(null),u=(0,X.useMemo)(()=>ir().map(e=>ar(e)).filter(e=>e!==null),[]);(0,X.useEffect)(()=>{let e=window.setTimeout(()=>{a(n.trim().toLowerCase())},200);return()=>window.clearTimeout(e)},[n]),(0,X.useEffect)(()=>{if(!o)return;let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let d=(0,X.useMemo)(()=>i?u.filter(e=>e.city.toLowerCase().includes(i)||e.region.toLowerCase().includes(i)||e.offsetLabel.toLowerCase().includes(i)||e.identifier.toLowerCase().includes(i)):u,[u,i]),f=(0,X.useMemo)(()=>{if(!e)return``;let t=e.split(`/`);return(t[t.length-1]??e).replace(/_/g,` `)},[e]),p=e=>{t(e),r(``),s(!1),l.current?.blur()};return(0,Z.jsxs)(`div`,{ref:c,className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Closest city`}),(0,Z.jsxs)(`div`,{className:`relative w-full md:max-w-[280px]`,children:[(0,Z.jsx)(B,{ref:l,type:`text`,value:n,placeholder:f||`Search city or country...`,onChange:e=>{r(e.target.value),s(!0)},onFocus:()=>s(!0),onKeyDown:e=>{e.key===`Escape`&&(r(``),s(!1),l.current?.blur())},fullWidth:!0}),o&&d.length>0&&(0,Z.jsx)(`div`,{className:`absolute left-0 right-0 top-full z-20 mt-1 max-h-[240px] overflow-y-auto rounded-md border border-[var(--border-base)] bg-[var(--surface-lift)] shadow-lg`,children:d.slice(0,200).map(t=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>p(t.identifier),className:`flex w-full cursor-pointer items-center justify-between gap-3 px-3 py-2 text-left text-body-medium-lighter transition-colors ${t.identifier===e?`bg-[var(--surface-active)] text-[var(--content-default)]`:`text-[var(--content-default)] hover:bg-[var(--surface-active)]`}`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-body-medium-default`,children:t.city}),t.region&&(0,Z.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:t.region})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(`span`,{children:or(t.identifier)}),(0,Z.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,Z.jsx)(Xt,{}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Time zone`}),(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:sr(e)})]})]})}function lr(){let e=ge.use.activeAssistantId(),[i,a]=(0,X.useState)(()=>n(`timezone`,``)),o=(0,X.useRef)(e);(0,X.useEffect)(()=>{o.current=e},[e]);let s=(0,X.useRef)(!1),c=(0,X.useRef)(null),l=(0,X.useRef)(()=>{}),u=e=>{if(s.current){c.current=e;return}let t=o.current;if(!t){c.current=null;return}s.current=!0,c.current=null,K.patch({url:`/v1/assistants/{assistant_id}/config`,path:{assistant_id:t},body:{ui:{userTimezone:e}},throwOnError:!0}).catch(e=>{r(e,{context:`settings-timezone-override`})}).finally(()=>{s.current=!1;let e=c.current;c.current=null,e!==null&&l.current(e)})};return(0,X.useEffect)(()=>{l.current=u}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Timezone`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Used when displaying times and scheduling reminders.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:(0,Z.jsx)(cr,{value:i,onChange:e=>{a(e),t(`timezone`,e),u(e)}})})]})}var ur=[[`Mon`,0],[`Tue`,1],[`Wed`,2],[`Thu`,3],[`Fri`,4],[`Sat`,5],[`Sun`,6]];function dr(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 fr(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 pr(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function mr(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:dr(t),windowEnd:dr(n)}}function hr({assistantId:e}){let t=l(),{data:n,isLoading:r,isError:i}=u(tt({path:{id:e}})),o=(0,X.useMemo)(()=>mr(n),[n]),[s,c]=(0,X.useState)(null),f=s??o,p=s!==null,m=(0,X.useMemo)(()=>pr(),[]),[h,g]=(0,X.useState)(null),_=h??f.daysOfMonth.join(`, `),v=d({mutationFn:async t=>{let{data:n}=await Be({path:{id:e},body:t,throwOnError:!0});return n}}),y=e=>{c(t=>({...t??o,...e}))},b=e=>{y({daysOfWeek:f.daysOfWeek.includes(e)?f.daysOfWeek.filter(t=>t!==e):[...f.daysOfWeek,e].sort((e,t)=>e-t)})},x=e=>e.split(`,`).map(e=>parseInt(e.trim(),10)).filter(e=>!isNaN(e)&&e>=1&&e<=31);return r?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading update window settings...`]}):i?(0,Z.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,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsx)(V,{checked:f.enabled,onChange:e=>y({enabled:e}),label:`Automatic updates`,helperText:`Update automatically during a configured time window`}),f.enabled&&(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Frequency`}),(0,Z.jsx)(`div`,{className:`max-w-[400px]`,children:(0,Z.jsx)(z,{ariaLabel:`Frequency`,value:f.frequency,onChange:e=>{e!==`monthly`&&g(null),y({frequency:e})},items:[{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}]})})]}),f.frequency===`weekly`&&(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Day(s) of week`}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:ur.map(([e,t])=>(0,Z.jsx)(a,{variant:`outlined`,size:`compact`,active:f.daysOfWeek.includes(t),onClick:()=>b(t),children:e},t))})]}),f.frequency===`monthly`&&(0,Z.jsx)(B,{label:`Day(s) of month`,type:`text`,value:_,onChange:e=>g(e.target.value),onBlur:e=>{let t=x(e.target.value);y({daysOfMonth:t}),g(t.join(`, `))},placeholder:`e.g. 1, 15`,helperText:`Comma-separated day numbers (1–31)`,className:`w-48`}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:[`Update window`,m?` (${m})`:``]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(B,{type:`time`,value:f.windowStart,onChange:e=>y({windowStart:e.target.value})}),(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`to`}),(0,Z.jsx)(B,{type:`time`,value:f.windowEnd,onChange:e=>y({windowEnd:e.target.value})})]})]})]}),(0,Z.jsx)(a,{variant:`primary`,leftIcon:v.isPending?(0,Z.jsx)(S,{className:`animate-spin`}):void 0,onClick:async()=>{let n=f.frequency===`monthly`&&h!==null?x(h):f.daysOfMonth;try{await v.mutateAsync({enabled:f.enabled,timezone:`UTC`,schedule:{frequency:f.frequency,days_of_week:f.frequency===`weekly`?f.daysOfWeek:[],days_of_month:f.frequency===`monthly`?n:[],window:{start:fr(f.windowStart),end:fr(f.windowEnd)}}}),U.success(`Auto-update policy saved.`),c(null),g(null),t.invalidateQueries({queryKey:Xe({path:{id:e}})})}catch{U.error(`Failed to save policy. Please try again.`)}},disabled:v.isPending||!p,children:`Save policy`})]})}function gr({assistantId:e,open:t,onClose:n}){return(0,Z.jsx)(H.Root,{open:t,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(H.Content,{size:`md`,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{children:`Update Window`}),(0,Z.jsx)(H.Description,{children:`Configure when automatic updates are applied.`})]}),(0,Z.jsx)(H.Body,{children:(0,Z.jsx)(hr,{assistantId:e})})]})})}function _r(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`)return t}}function vr({open:e,onOpenChange:t}){let n=l(),[r,i]=(0,X.useState)(null),[o,s]=(0,X.useState)(``),[c,u]=(0,X.useState)(null),d=(0,X.useRef)(!1),f=(0,X.useRef)(e),p=()=>n.invalidateQueries({queryKey:$e()}),m=e=>{Le({path:{id:e}}).catch(()=>void 0).finally(()=>void p())},h=ut({onSuccess:e=>{if(!f.current){m(e.factor_id);return}i(e)},onError:e=>{let n=_r(e);n===`no_workos_account`?U.error(`Two-factor authentication is only available for Vellum platform accounts.`):n===`throttled`||n===`workos_rate_limited`?U.error(`Too many attempts. Try again in a minute.`):n===`factor_limit_reached`?U.error(`An authenticator app is already set up. Remove it before adding another.`):U.error(`Failed to start setup. Please try again.`),t(!1)}}),g=ct({onSuccess:e=>{e.valid?(d.current=!0,U.success(`Two-factor authentication is on.`),p(),t(!1)):u(`That code didn't match. Check your authenticator app and try again.`)},onError:e=>{let n=_r(e);if(n===`challenge_already_verified`){d.current=!0,U.success(`Two-factor authentication is on.`),p(),t(!1);return}if(n===`challenge_expired`||n===`challenge_not_found`){r&&m(r.factor_id),i(null),s(``),u(`This setup session expired. Scan the new QR code and try again.`),h.mutate({});return}if(n===`throttled`||n===`workos_rate_limited`){u(`Too many attempts. Wait a minute and try again.`);return}u(`Couldn't verify the code. Wait a moment and try again.`)}});(0,X.useEffect)(()=>{f.current=e,e&&(d.current=!1,i(null),s(``),u(null),h.mutate({}))},[e]);let _=e=>{!e&&g.isPending||(!e&&r&&!d.current&&m(r.factor_id),t(e))},v=()=>{r&&navigator.clipboard.writeText(r.secret).then(()=>U.success(`Setup key copied.`)).catch(()=>U.error(`Couldn't copy the setup key.`))},y=()=>{!r||o.length!==6||g.isPending||(u(null),g.mutate({body:{challenge_id:r.challenge_id,code:o}}))};return(0,Z.jsx)(H.Root,{open:e,onOpenChange:_,children:(0,Z.jsxs)(H.Content,{size:`sm`,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{children:`Set up authenticator app`}),(0,Z.jsx)(H.Description,{children:`Scan the QR code with an authenticator app such as Google Authenticator or 1Password, then enter the 6-digit code it shows.`})]}),(0,Z.jsx)(H.Body,{children:r===null?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Z.jsx)(S,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,Z.jsxs)(`form`,{className:`flex flex-col items-center gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,Z.jsx)(`img`,{src:r.qr_code,alt:`QR code for your authenticator app`,className:`h-44 w-44 rounded-lg bg-white p-2`}),(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Can't scan it? Enter this setup key manually:`}),(0,Z.jsxs)(`button`,{type:`button`,onClick:v,className:`flex cursor-pointer items-center gap-2 self-start font-mono text-body-small-default text-[var(--content-default)] hover:text-[var(--content-emphasised)]`,children:[(0,Z.jsx)(`span`,{className:`break-all text-left`,children:r.secret}),(0,Z.jsx)(b,{className:`h-3.5 w-3.5 shrink-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`totp-code`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:`6-digit code`}),(0,Z.jsx)(B,{id:`totp-code`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,placeholder:`123456`,value:o,onChange:e=>s(e.target.value.replace(/\D/g,``).slice(0,6))}),c&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--system-negative-strong)]`,children:c})]})]})}),(0,Z.jsxs)(H.Footer,{children:[(0,Z.jsx)(a,{variant:`outlined`,onClick:()=>_(!1),disabled:g.isPending,children:`Cancel`}),(0,Z.jsx)(a,{onClick:y,disabled:r===null||o.length!==6||g.isPending,children:g.isPending?`Verifying…`:`Verify`})]})]})})}function yr(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function br(){let e=l(),[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(null),o=u({...Qe()}),s=o.data??[],c=()=>e.invalidateQueries({queryKey:$e()}),d=qe({onSuccess:()=>{U.success(`Authenticator app removed.`),c()},onError:e=>{if(_r(e)===`factor_not_found`){c();return}U.error(`Failed to remove the authenticator app. Please try again.`)}});return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.isPending?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin`}),(0,Z.jsx)(`span`,{className:`text-body-medium-default`,children:`Loading authenticator apps…`})]}):o.isError?(0,Z.jsxs)(F,{tone:`error`,children:[`Couldn't load your authenticator apps.`,` `,(0,Z.jsx)(`button`,{type:`button`,className:`cursor-pointer underline`,onClick:()=>void o.refetch(),children:`Try again`})]}):s.length===0?(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`No authenticator app is set up. Add one to require a one-time code at sign-in.`}):(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:s.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(Nt,{className:`h-5 w-5 shrink-0 text-[var(--content-tertiary)]`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Authenticator app`}),(0,Z.jsxs)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:[e.user,e.created_at?` · Added ${yr(e.created_at)}`:``]})]})]}),(0,Z.jsx)(a,{variant:`dangerOutline`,onClick:()=>i(e),disabled:d.isPending,children:`Remove`})]},e.id))}),!o.isPending&&!o.isError&&s.length===0&&(0,Z.jsx)(a,{onClick:()=>n(!0),className:`self-start`,children:`Add authenticator app`}),(0,Z.jsx)(vr,{open:t,onOpenChange:n}),(0,Z.jsx)(re,{open:r!==null,title:`Remove authenticator app`,message:`Signing in will no longer ask for a code from this app. You can set up a new authenticator app at any time.`,confirmLabel:`Remove`,destructive:!0,onConfirm:()=>{r&&d.mutate({path:{id:r.id}}),i(null)},onCancel:()=>i(null)})]})}var Q=class extends Error{code;constructor(e,t){super(t),this.name=`TeleportError`,this.code=e}},xr=`local`,Sr=`docker`,Cr=`vellum`;function wr(e){switch((e??``).toLowerCase()){case xr:return`local`;case Sr:return`docker`;case Cr:return`managed`;default:return`other`}}function Tr(e){let t=wr(e);return t===`managed`?`local`:t===`local`?`platform`:null}function Er(e){switch(e){case`docker`:return`Move to Docker`;case`platform`:return`Move to Cloud (Platform)`;case`local`:return`Move to Local`}}function Dr(e){switch(e){case`docker`:return`Run your assistant in a Docker container on this Mac.`;case`platform`:return`Run your assistant in the cloud, managed by the Vellum platform.`;case`local`:return`Run your assistant locally on this Mac.`}}function Or(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.reason!==`version_mismatch`)return null;let n=t.bundle_compat,r=t.target_runtime_version;if(!n||typeof n!=`object`||typeof r!=`string`)return null;let i=n,a=i.min_runtime_version;if(typeof a!=`string`)return null;let o=typeof i.max_runtime_version==`string`?i.max_runtime_version:null;return`Cannot import: bundle requires runtime ${o?`${a}–${o}`:`${a}+`}, but this local runtime is ${r}. Update your local runtime before importing.`}async function kr(e,t){let n=Number(e.headers.get(`Content-Length`)??0);if(!e.body||!t||n<=0){let n=await e.arrayBuffer();return t?.(1),n}let r=e.body.getReader(),i=[],a=0;for(;;){let{done:e,value:o}=await r.read();if(e)break;i.push(o),a+=o.length,t(a/n)}let o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return t(1),o.buffer}function Ar(e){let t=de(e);if(!t)throw new Q(`local_assistant_not_found`,`Assistant ${e.assistantId} has no resolved local gateway.`);return`${window.location.origin}${t}`}async function jr(e,t){let n=await ae(e.assistantId),r=await fetch(`${t}/auth/token`,{method:`POST`,headers:{Authorization:`Bearer ${n}`}});if(!r.ok)throw new Q(`not_signed_in`,`Gateway token request failed (HTTP ${r.status}).`);let{token:i}=await r.json();return i}async function Mr(e,t){let n=Ar(e),r=await jr(e,n),i=await fetch(`${n}/v1/migrations/export`,{method:`POST`,headers:{Authorization:`Bearer ${r}`}});if(!i.ok)throw new Q(`export_failed`,`Export failed (HTTP ${i.status}).`);return kr(i,t)}async function Nr(e,t){let n=Ar(e),r=await jr(e,n),i=await fetch(`${n}/v1/migrations/import`,{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:new Blob([t],{type:`application/octet-stream`})});if(!i.ok)throw new Q(`import_failed`,`Import failed (HTTP ${i.status}).`);let a=await Ir(i);if(a&&a.success===!1)throw new Q(`import_failed`,a.error??`Import reported failure`)}async function Pr(e,t){let{data:n,response:r}=await K.post({url:`/v1/assistants/{assistant_id}/migrations/export-to-gcs/`,path:{assistant_id:e},body:{upload_url:t},throwOnError:!1}),i=r?.status??0;if(!(r?.ok??!1)&&i!==202)throw new Q(`export_failed`,`Export failed (HTTP ${i}).`);let a=n?.job_id;if(!a)throw new Q(`export_failed`,`Export accepted but no job ID was returned.`);return a}async function Fr(e,t){let{data:n,response:r}=await K.get({url:`/v1/assistants/{assistant_id}/migrations/jobs/{job_id}`,path:{assistant_id:e,job_id:t},throwOnError:!1}),i=r?.status??0;if(i>=500)return`processing`;if(!(r?.ok??!1))throw new Q(`export_job_failed`,`Job status check failed (HTTP ${i})`);let a=n;if(a?.status===`failed`)throw new Q(`export_job_failed`,a.error??`Export job failed`);return a?.status??`processing`}async function Ir(e){try{return await e.json()}catch{return null}}var Lr=new Set([500,502,503,504]),$=3,Rr=e=>new Promise(t=>setTimeout(t,e));async function zr(e,t=new Set){for(let n=0;n<=$;n++){let{response:r,data:i,error:a}=await e(),o=r?.status??0;if(n<$&&Lr.has(o)&&!t.has(o)){await Rr(2**n*1e3);continue}return{status:o,data:i,error:a}}throw new Q(`unknown`,`Unexpected retry loop exit`)}async function Br(e,t){let n={operation:`upload`};e&&(n.min_runtime_version=e,n.max_runtime_version=null),t&&(n.consumer=t);let{status:r,data:i}=await zr(()=>K.post({url:`/v1/migrations/signed-url/`,body:n,throwOnError:!1}),new Set([404,503]));if(r===503||r===404)throw new Q(`export_failed`,`Signed URL uploads are not available — the platform may not support this feature yet.`);if(r!==201)throw new Q(`export_failed`,`Migration request failed (HTTP ${r}).`);let a=i;return{url:a.url,bundleKey:a.bundle_key,expiresAt:a.expires_at}}async function Vr(e,t){let{status:n,data:r,error:i}=await zr(()=>K.post({url:`/v1/migrations/signed-url/`,body:{operation:`download`,bundle_key:e,target_runtime_version:t},throwOnError:!1}),new Set([422]));if(n===422){let e=Or(i);if(e)throw new Q(`version_mismatch`,e)}if(n!==200&&n!==201)throw new Q(`import_failed`,`Migration request failed (HTTP ${n}).`);return r.url}async function Hr(e,t,n){for(let r=0;r<=$;r++){let i=await Ur(e,t,n);if(r<$&&Lr.has(i)){await Rr(2**r*1e3),n?.(0);continue}if(i<200||i>=300)throw new Q(`export_failed`,`Bundle upload failed (HTTP ${i}).`);return}}function Ur(e,t,n){return new Promise((r,i)=>{let a=new XMLHttpRequest;a.open(`PUT`,e),a.setRequestHeader(`Content-Type`,`application/octet-stream`),a.timeout=36e5,n&&(a.upload.onprogress=e=>{e.lengthComputable&&n(e.loaded/e.total)}),a.onload=()=>{n?.(1),r(a.status)},a.onerror=()=>i(new Q(`export_failed`,`Bundle upload failed.`)),a.ontimeout=()=>i(new Q(`export_timed_out`,`Bundle upload timed out.`)),a.send(t)})}async function Wr(e,t){for(let n=0;n<=$;n++){let r=await fetch(e,{method:`GET`});if(n<$&&Lr.has(r.status)){await Rr(2**n*1e3),t?.(0);continue}if(!r.ok)throw new Q(`import_failed`,`Bundle download failed (HTTP ${r.status}).`);return kr(r,t)}throw new Q(`import_failed`,`Unexpected retry loop exit`)}async function Gr(e){let{status:t,data:n,error:r}=await zr(()=>K.post({url:`/v1/migrations/import-from-gcs/`,body:{bundle_key:e},throwOnError:!1}));return{status:t,body:n??r??null}}async function Kr(e){let{status:t,data:n}=await zr(()=>K.get({url:`/v1/migrations/jobs/{job_id}/`,path:{job_id:e},throwOnError:!1}));if(t!==200)throw new Q(`import_failed`,`Job status check failed (HTTP ${t})`);let r=n??{};return{status:typeof r.status==`string`?r.status:`unknown`,jobId:typeof r.job_id==`string`?r.job_id:null,error:typeof r.error==`string`?r.error:null}}var qr=5e3,Jr=36e5,Yr=5*6e4,Xr=30,Zr=e=>new Promise(t=>setTimeout(t,e));function Qr(){let e=c(),t=pe(),n=Tr(t?.cloud),[i,a]=(0,X.useState)({kind:`idle`}),[o,s]=(0,X.useState)(!1),l=(0,X.useRef)(null),u=(0,X.useRef)(null),d=(0,X.useCallback)(e=>{a({kind:`transferring`,step:e,progress:null})},[]),f=(0,X.useCallback)(e=>{a(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,X.useCallback)(async()=>{if(!(!t||!n)){u.current={id:t.assistantId,kind:wr(t.cloud)===`managed`?`managed`:`local`,createdFresh:!1};try{if(n===`platform`)await $r(t,d,f,l);else if(n===`local`)await ei(t,d,f,l);else throw new Q(`unknown`,`Unsupported teleport destination.`);a({kind:`verifying`})}catch(e){a({kind:`failed`,error:`Teleport failed: ${e instanceof Q||e instanceof Error?e.message:`Teleport failed.`}`}),r(e,{context:`teleport-execute`}),await ni(l.current,u.current,`teleport-execute-cleanup`),l.current=null}}},[t,n,d,f]),m=(0,X.useCallback)(()=>s(!0),[]),h=(0,X.useCallback)(()=>s(!1),[]),g=(0,X.useCallback)(()=>{s(!1),p()},[p]),_=(0,X.useCallback)(()=>{l.current=null,u.current=null,a({kind:`idle`})},[]);return{destination:n,phase:i,confirmOpen:o,requestTeleport:m,cancelConfirm:h,confirm:g,confirmAndSwitch:(0,X.useCallback)(()=>{let t=l.current,n=u.current;t&&(async()=>{try{let e=ke.getState();t.kind===`managed`?await e.connectPlatformAssistant(t.id):(await e.connectLocalAssistant(t.id),Me(t.id,{onError:e=>r(e,{context:`teleport-inject-platform-identity`})}))}catch(e){a({kind:`failed`,error:`Switch failed: ${e instanceof Error?e.message:`Failed to switch assistant.`}`}),r(e,{context:`teleport-confirm-switch`});return}n&&Pt(n.id).then(e=>{e.ok||r(Error(e.error),{context:`teleport-retire-source`})}),_(),e(q.assistant,{replace:!0})})()},[e,_]),cancelTeleport:(0,X.useCallback)(()=>{let e=l.current,t=u.current;l.current=null,u.current=null,a({kind:`idle`}),ni(e,t,`teleport-cancel-retire-target`)},[]),reset:_}}async function $r(e,t,n,r){t(`Exporting assistant data...`);let i=await Mr(e,n);t(`Resolving organization...`);let a=await ii();t(`Checking for existing assistant...`);let o=(await Re({query:{hosting:`platform`},throwOnError:!1})).data?.results?.[0];if(o)throw new Q(`existing_platform_assistant`,`You already have a platform assistant '${o.id}'. Retire it first, then retry the teleport.`);t(`Uploading data to cloud...`);let s=await Br(e.resources?.runtimeVersion);await Hr(s.url,i,n),t(`Setting up cloud assistant...`);let c=await Ue(void 0,`create`);if(!c.ok)throw new Q(`import_failed`,`Failed to set up the cloud assistant.`);if(c.status===200)throw new Q(`existing_platform_assistant`,`You already have a platform assistant '${c.data.id}'. Retire it first, then retry the teleport.`);let l=c.data.id;await oe({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:ce(),hatchedAt:c.data.created??new Date().toISOString(),organizationId:a}),await W(e.assistantId),r.current={id:l,kind:`managed`,createdFresh:!0},t(`Finalizing cloud assistant...`),await ai(l),t(`Importing data to cloud...`);let u=await Gr(s.bundleKey);if(u.status<200||u.status>=300){let e=u.body;throw new Q(`import_failed`,e?.error??`Import failed (HTTP ${u.status}).`)}if(u.status===202){let e=u.body?.job_id;if(!e)throw new Q(`import_failed`,`Import accepted but no job ID returned.`);await oi(e)}else{let e=u.body;if(e&&e.success===!1)throw new Q(`import_failed`,e.error??`Import reported failure.`)}}async function ei(e,t,n,r){t(`Preparing export...`);let i=await Br(await ri(e.assistantId),`runtime`);t(`Exporting cloud data...`);let a=await Pr(e.assistantId,i.url);await si(e.assistantId,a),t(`Preparing local assistant...`);let{assistant:o,createdFresh:s}=await ci();r.current={id:o.assistantId,kind:`local`,createdFresh:s};let c=await ti(o,s);if(!c)throw new Q(`local_assistant_not_found`,`Could not determine the local assistant's runtime version. Restart or upgrade the local assistant, then retry the teleport.`);t(`Preparing import...`);let l=await Vr(i.bundleKey,c);t(`Downloading data...`);let u=await Wr(l,n);t(`Importing data...`),await ui(o,u),await W(e.assistantId)}async function ti(e,t){if(e.resources?.runtimeVersion)return e.resources.runtimeVersion;if(t)return(await Ut())?.version??void 0}async function ni(e,t,n){if(e?.createdFresh){let t=await Pt(e.id);t.ok||r(Error(t.error),{context:n})}t&&await W(t.id)}async function ri(e){let t=await He(e);return t.ok?t.data.version??void 0:void 0}async function ii(){let e=Se.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=Se.getState().organizations,n=je();if(n&&t.some(e=>e.id===n))return n;if(t.length===0)throw new Q(`no_organizations`,`No organizations found for this account.`);if(t.length>1)throw new Q(`multiple_organizations`,`Multiple organizations found — please select one in account settings first.`);let r=t[0].id;return Se.getState().setCurrentOrganizationId(r),r}async function ai(e){let t=Date.now();for(;Date.now()-t<Yr;){let{data:t,response:n}=await Ve({path:{id:e},throwOnError:!1});if(n?.ok&&t?.state===`active`)return;await Zr(qr)}}async function oi(e){let t=Date.now();for(;Date.now()-t<Jr;){await Zr(qr);let t=await Kr(e);if(t.status===`complete`)return;if(t.status===`failed`)throw new Q(`import_failed`,t.error??`Import job failed`)}throw new Q(`import_failed`,`Import timed out after 60 minutes.`)}async function si(e,t){let n=Date.now();for(;Date.now()-n<Jr;)if(await Zr(qr),await Fr(e,t)===`complete`)return;throw new Q(`export_timed_out`,`Export timed out.`)}async function ci(){let e=await fe(void 0,void 0);if(!e.ok)throw new Q(`local_assistant_not_found`,e.error??`Could not create a local assistant.`);await se();let t=e.assistantId?he().find(t=>t.assistantId===e.assistantId):li();if(!t)throw new Q(`local_assistant_not_found`,`Could not find or create a local assistant.`);return{assistant:t,createdFresh:!0}}function li(){return he().slice().sort((e,t)=>(t.hatchedAt??``).localeCompare(e.hatchedAt??``))[0]}async function ui(e,t){let n;for(let r=0;r<Xr;r++)try{await Nr(e,t);return}catch(e){n=e,await Zr(1e3)}throw n instanceof Error?n:new Q(`import_failed`,`Import failed.`)}function di(){let e=Qr(),{destination:t,phase:n}=e;return t?(0,Z.jsxs)(Y,{title:`Teleport`,subtitle:`Move your assistant to a different hosting environment.`,children:[n.kind===`idle`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:Dr(t)}),(0,Z.jsx)(a,{variant:`outlined`,className:`self-start`,onClick:e.requestTeleport,children:Er(t)})]}),n.kind===`transferring`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.progress==null&&(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:n.step})]}),n.progress!=null&&(0,Z.jsx)(I,{value:n.progress,"aria-label":`Teleport progress`,className:`max-w-[240px]`})]}),n.kind===`verifying`&&(0,Z.jsx)(F,{tone:`success`,icon:(0,Z.jsx)(y,{className:`h-4 w-4`}),title:`Transfer complete — verify your new assistant is working.`,actions:(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(a,{variant:`primary`,onClick:e.confirmAndSwitch,children:`Confirm & Switch`}),(0,Z.jsx)(a,{variant:`outlined`,onClick:e.cancelTeleport,children:`Cancel`})]})}),n.kind===`failed`&&(0,Z.jsx)(F,{tone:`error`,title:n.error,actions:(0,Z.jsx)(a,{variant:`outlined`,onClick:e.reset,children:`Try Again`})}),(0,Z.jsx)(re,{open:e.confirmOpen,title:Er(t),message:`Your data will be copied to the new environment. The current assistant will remain available until you confirm the new one works.`,confirmLabel:`Teleport`,onConfirm:e.confirm,onCancel:e.cancelConfirm})]}):null}function fi(){let{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:s}=qt(),l=J.use.multiPlatformAssistant(),u=J.use.teleport(),d=J.use.accountMfa(),f=ht.use.settingsSleepPolicy(),p=Te(),m=c(),h=Lt(),g=Lt({platformHostedOnly:!0}),_=Ft(),v=kt({assistantId:e?.id??null,enabled:g===`full`&&_}),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(!1),[C,w]=o();(0,X.useEffect)(()=>{if(C.get(`preferences`)!==`open`)return;let e=new URLSearchParams(C);e.delete(`preferences`),w(e,{replace:!0}),S(!0)},[C,w]);let T=e?.is_local&&!me()?null:e,E=pe(),D=me()&&!!e&&!!E&&le(E),O=D,k=D&&!ue(),A=g===`full`&&!!T||k&&!!e;(0,X.useEffect)(()=>{!e||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[e]);let j=t?.version??e?.current_release_version??null,M=(h===`full`||O)&&!!T||h===`disabled`&&!O,N=g!==`gated`;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[v.status&&v.mode!==`inactive`&&(0,Z.jsx)(Vt,{status:v.status,mode:v.mode,isAcknowledging:v.isAcknowledging,acknowledgeError:v.acknowledgeError?.message??null,onAcknowledge:()=>void v.acknowledge(),onReviewWorkspaceData:()=>void m(`${q.workspace}?sort=size`),onUpgradeStorage:g===`full`?()=>void m(`${q.settings.billing}?adjust_plan=1`):null}),(0,Z.jsxs)(fn,{assistant:_?T:null,showHandles:p&&h===`full`,children:[(0,Z.jsx)(lr,{}),d&&h!==`gated`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Two-Factor Authentication`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Require a code from an authenticator app when you sign in.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:h===`disabled`?(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to manage two-factor authentication.`}):(0,Z.jsx)(br,{})})]})]})]}),(0,Z.jsx)(Y,{title:`Version`,subtitle:`Manage your assistant's software version and updates.`,accessory:g===`full`&&T?(0,Z.jsx)(a,{variant:`outlined`,onClick:()=>b(!0),children:`Update Window`}):void 0,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g===`full`&&T&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Sn,{assistantId:T.id,currentVersion:j,releaseChannel:T.release_channel,onUpgradeComplete:()=>{i()}}),(0,Z.jsx)(Yn,{assistantId:T.id,onComplete:()=>{i()}})]}),k&&e&&(0,Z.jsx)(Cn,{assistantId:e.id,currentVersion:j,onUpgradeComplete:()=>{i()}}),!A&&e&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Z.jsx)(Jt,{version:j,loading:n&&!e.current_release_version,assistantId:e.id??null})]}),g===`disabled`&&!k&&(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to manage software updates.`})]})}),g===`full`&&T&&(0,Z.jsx)(gr,{assistantId:T.id,open:y,onClose:()=>b(!1)}),g===`full`&&e&&(0,Z.jsx)(tr,{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:s}),g===`disabled`&&(0,Z.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to manage compute resources.`})}),(0,Z.jsx)(Y,{title:`Preferences`,subtitle:`Customize appearance, shortcuts, and how Vellum behaves on this device.`,accessory:(0,Z.jsx)(a,{variant:`outlined`,onClick:()=>S(!0),children:`Customize`})}),(0,Z.jsx)(Un,{open:x,onClose:()=>S(!1)}),u&&G()&&(0,Z.jsx)(di,{}),(0,Z.jsx)(En,{}),g===`full`&&T&&f&&(0,Z.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Z.jsx)(vn,{assistantId:T.id})}),g===`disabled`&&f&&(0,Z.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to manage sleep policy.`})}),l&&(0,Z.jsx)(hn,{}),(M||N)&&(0,Z.jsx)(Y,{variant:`danger`,title:`Danger Zone`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[M&&(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Retire Assistant`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently retire this assistant and delete all associated data.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:(h===`full`||O)&&T?(0,Z.jsx)(nr,{assistantId:T.id}):(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to retire this assistant.`})})]}),M&&N&&(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Z.jsx)(wn,{})]})})]})}export{fi as GeneralPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,r as n}from"./device-settings-DXp9L4iB.js";import{t as r}from"./capture-error-BGD3-GQf.js";import{t as i}from"./react-DJZBPgpf.js";import{t as a}from"./button-BQVYX8n_.js";import{m as o,t as s,u as c}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./useMutation-Lj4VunQV.js";import{t as f}from"./jsx-runtime-CVSDxk6A.js";import{t as p}from"./card-D8zyWtZh.js";import{t as m}from"./createLucideIcon-Bjb-Kuq7.js";import{t as h}from"./bell-BbESwsZk.js";import{t as g}from"./check-wF3S-AV4.js";import{t as _}from"./chevron-down-DpYf9Gwq.js";import{t as v}from"./circle-alert-CTnM6GCb.js";import{t as y}from"./circle-check-DqvTjWle.js";import{o as b}from"./list-row-9xgQystQ.js";import{t as x}from"./hard-drive-BxDRcYId.js";import{t as S}from"./loader-circle-D57RZgLH.js";import{t as C}from"./monitor-DTDBOcSy.js";import{t as w}from"./moon-Ci1LuSVx.js";import{t as T}from"./refresh-cw-CMEIZvPt.js";import{a as E,c as D,o as O,r as k,s as A,t as j}from"./resize-errors-B4T7-3eS.js";import{t as M}from"./sparkles-DDIsk_nZ.js";import{t as N}from"./triangle-alert-DXEpFOj_.js";import{t as P}from"./x-CswtfvgS.js";import{t as F}from"./notice-BylgS5W_.js";import{t as I}from"./progress-bar-Bqv7D4mZ.js";import{M as ee,N as L,i as R,j as z,n as te}from"./src-CDdn26Yb.js";import{t as ne}from"./tag-B6WeUtBW.js";import{t as B}from"./input-ZpyYt_a0.js";import{t as V}from"./toggle-QSEiPr3k.js";import{t as H}from"./modal-BtcwNEBj.js";import{n as U}from"./toast-ZoZVyeDI.js";import{t as re}from"./confirm-dialog-CCrDkChx.js";import{t as ie}from"./dropdown-BMNSccmo.js";import{C as W,D as ae,S as oe,_ as se,c as ce,f as le,g as ue,i as de,k as fe,l as pe,p as me,r as he}from"./local-mode-hyYI6_OH.js";import{t as G}from"./is-electron-DBOtwp5h.js";import{n as ge}from"./resolved-assistants-store-DdnJoLGS.js";import{r as _e,t as ve}from"./semver-CRR7tMUr.js";import{n as ye,r as be,t as xe}from"./api-errors-CDe82ZvY.js";import{E as Se,O as Ce,_ as we,a as Te,h as Ee,l as De,m as Oe,n as ke,v as Ae,w as je,x as Me,y as Ne}from"./auth-store-B6EXnaee.js";import{t as K}from"./client.gen-DZZugzSk.js";import{C as Pe,H as Fe,M as Ie,Rt as Le,T as Re,X as ze,Z as Be,j as Ve}from"./sdk.gen-BJsTUGAk.js";import{a as He,o as Ue}from"./api-BBMl4mW3.js";import{c as q}from"./routes-XPLb07Av.js";import{a as We,r as Ge}from"./platform-detection-1awANa55.js";import{t as J}from"./client-feature-flag-store-DeUwlUsr.js";import{A as Ke,At as qe,D as Je,E as Ye,F as Xe,M as Ze,Mt as Qe,Nt as $e,Ot as et,P as tt,T as nt,Tt as rt,bt as it,c as at,it as ot,j as st,jt as ct,k as lt,kt as ut,nt as dt,v as ft,w as pt,wt as mt}from"./react-query.gen-BXPoln4i.js";import{t as ht}from"./assistant-feature-flag-store-BpbbAIKZ.js";import{t as gt}from"./pointer-Cdz7NGHe.js";import{t as _t}from"./proxy-BzlH_XAe.js";import{t as vt}from"./AnimatePresence-C8APSgIu.js";import{t as yt}from"./use-reduced-motion-CcGT6CHV.js";import{Cn as bt,Fn as xt,Gi as St,In as Ct,Ln as wt,Lr as Tt,N as Et,P as Dt,Pn as Ot,Qt as kt,Ta as At,U as jt,Xn as Mt,Yi as Nt,Zn as Pt,fi as Ft,j as It,mi as Lt,na as Rt,pi as zt,ta as Bt,wt as Vt}from"./index-CgcZXB4g.js";import{t as Ht}from"./use-active-assistant-id-9rGx8kT9.js";import{t as Y}from"./detail-card-CA8lPa5K.js";import{t as Ut}from"./app-info-Dwct98Bb.js";import{t as Wt}from"./environment-store-D_Bc9wnl.js";import{a as Gt,i as Kt,n as qt,r as Jt,t as Yt}from"./assistant-status-panel-DDvWvhN1.js";import{t as Xt}from"./settings-divider-Dk_uJxp_.js";var Zt=m(`fingerprint-pattern`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),Qt=m(`vibrate`,[[`path`,{d:`m2 8 2 2-2 2 2 2-2 2`,key:`sv1b1`}],[`path`,{d:`m22 8-2 2 2 2-2 2 2 2`,key:`101i4y`}],[`rect`,{width:`8`,height:`14`,x:`8`,y:`5`,rx:`1`,key:`1oyrl4`}]]),X=e(i(),1),$t=Oe,en=`Please choose a different handle.`;async function tn(e,t){let{data:n,error:r,response:i}=await Ie({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:be(r,void 0,`Failed to save handle.`)??`Failed to save handle.`};if(i.ok&&n)return{kind:`ok`,data:n};if(i.status===409){let{message:e}=Ne(r,`handle`,$t.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=Ne(r,`handle`,en);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:be(r,i,`Failed to save handle.`)}}async function nn(e,t,n){let{data:r,error:i,response:a}=await Pe({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(ye(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new xe(a.status,a.status===429?`Too many checks — try again in a moment.`:be(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function rn(e){return/\d{2,}$/.test(e)}var Z=f(),an=300,on=1400;function sn({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:o,onSaved:s,saveSuccessToast:c,fieldId:l}){let[u,d]=(0,X.useState)(e),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[_,y]=(0,X.useState)(`idle`),[b,x]=(0,X.useState)(null),C=yt(),w=(0,X.useRef)(null),T=(0,X.useMemo)(()=>u.trim().toLowerCase(),[u]),E=T===e.toLowerCase();(0,X.useEffect)(()=>{if(E||T.length===0){h(!1),w.current?.abort();return}let e=new AbortController;w.current?.abort(),w.current=e,h(!0);let t=window.setTimeout(async()=>{try{let t=await i(T,e.signal);e.signal.aborted||p(t)}catch(t){e.signal.aborted||x(t instanceof Error?t.message:`Couldn't check availability.`)}finally{e.signal.aborted||h(!1)}},an);return()=>{window.clearTimeout(t),e.abort()}},[T,E,i]);let D=(()=>{if(b)return b;if(f&&!f.available){let e=f.code;return f.message??(e?$t[e]:`Please choose a different handle.`)}return null})(),O=D?n:E?r??null:m?`Checking availability…`:f?.available?`Available.`:null,k=!E&&!m&&f?.available!==!1&&_!==`saving`,A=(0,X.useCallback)(async()=>{if(!k)return;y(`saving`),x(null);let e=await o(T);if(e.kind===`ok`){y(`saved`),s(e.data),U.success(c),window.setTimeout(()=>y(`idle`),on);return}if(e.kind===`taken`){y(`idle`),p({available:!1,code:`taken`,message:e.message});return}if(e.kind===`invalid`){y(`idle`),p({available:!1,code:e.code,message:e.message});return}y(`error`),x(e.message),U.error(e.message)},[k,T,s,o,c]),j=(()=>{if(E&&u.length>0||u.length===0)return null;let e=m?`checking`:f?.available?`available`:f?.available===!1?`invalid`:null;return e?(0,Z.jsx)(vt,{mode:`wait`,initial:!1,children:(0,Z.jsxs)(_t.span,{initial:C?!1:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:C?void 0:{opacity:0,scale:.85},transition:{duration:.14,ease:`easeOut`},className:`flex items-center`,"aria-hidden":e!==`available`&&e!==`invalid`,children:[e===`checking`&&(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,Z.jsx)(g,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,Z.jsx)(v,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),M=(()=>{switch(_){case`saving`:return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(S,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Saving…`]});case`saved`:return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Saved`]});default:return`Save`}})();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(B,{label:t,value:u,onChange:e=>{d(e.target.value.replace(/\s+/g,``)),p(null),x(null)},autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,maxLength:30,leftIcon:(0,Z.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),rightIcon:j,errorText:D??void 0,helperText:O??void 0,"aria-invalid":!!D,fullWidth:!0,"data-testid":`${l}-input`}),(!E||_!==`idle`)&&(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(a,{variant:`primary`,size:`compact`,onClick:A,disabled:!k,"aria-live":`polite`,"data-testid":`${l}-save`,children:M})})]})}function cn({initial:e,onSaved:t}){let n=ke.use.refreshSession(),r=rn(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,X.useCallback)(async e=>await Ae({username:e}),[]),a=(0,X.useCallback)((e,t)=>Ee(e,t),[]),o=(0,X.useCallback)(e=>{t(e),n()},[t,n]);return(0,Z.jsx)(sn,{initialHandle:e.username,inputLabel:`User handle`,helperText:`Lowercase letters, digits, hyphens, and underscores. 3–30 characters.`,idleHelperText:r,checkAvailable:a,save:i,onSaved:o,saveSuccessToast:`Profile updated.`,fieldId:`user-handle`})}function ln({assistant:e,onSaved:t}){let n=e.handle??``,r=u({...at({path:{assistant_id:e.id}})}).data?.results?.[0],i=!!r&&r.subdomain.toLowerCase()===n.toLowerCase(),a=n.length===0?`Your assistant doesn't have a handle yet — claim one to make it mentionable.`:void 0,o=(0,X.useCallback)(async t=>await tn(e.id,t),[e.id]),c=(0,X.useCallback)((t,n)=>nn(e.id,t,n),[e.id]);return i?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(B,{label:`Assistant handle`,value:n,readOnly:!0,disabled:!0,leftIcon:(0,Z.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,Z.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Your assistant's handle is locked because it's used as its email subdomain. To change it,`,` `,(0,Z.jsx)(s,{to:`${q.settings.ai}?release=1#email`,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`,children:`release the subdomain`}),` `,`first.`]})]}):(0,Z.jsx)(sn,{initialHandle:n,inputLabel:`Assistant handle`,helperText:`Lowercase letters, digits, hyphens, and underscores. 3–30 characters.`,idleHelperText:a,checkAvailable:c,save:o,onSaved:t,saveSuccessToast:`Assistant handle updated.`,fieldId:`assistant-handle`})}function un(){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Z.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Z.jsx)(`div`,{className:`h-3 w-72 animate-pulse rounded bg-[var(--surface-muted)]`})]}),(0,Z.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`h-3 w-60 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Z.jsx)(`div`,{className:`h-7 w-16 animate-pulse rounded-md bg-[var(--surface-muted)]`})]}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Loading your profile…`})]})}function dn(){return(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`})}function fn({assistant:e,showHandles:t=!0,children:n}={}){let r=ke.use.user?.()?.email??null;return(0,Z.jsx)(Y,{title:`Profile`,subtitle:`Manage your account details and preferences.`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[r&&(0,Z.jsx)(`div`,{className:`max-w-[420px]`,children:(0,Z.jsx)(B,{label:`Email`,value:r,disabled:!0,readOnly:!0})}),t&&(0,Z.jsxs)(Z.Fragment,{children:[r&&(0,Z.jsx)(dn,{}),(0,Z.jsx)(pn,{assistant:e})]}),n!=null&&(0,Z.jsxs)(Z.Fragment,{children:[(r||t)&&(0,Z.jsx)(dn,{}),n]})]})})}function pn({assistant:e}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(null),a=yt(),[o,s]=(0,X.useState)(e??null);return(0,X.useEffect)(()=>{s(e??null)},[e]),(0,X.useEffect)(()=>{let e=!1;return we().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),r?(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,Z.jsxs)(_t.div,{initial:a?!1:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.22,ease:`easeOut`},className:`flex flex-col gap-6`,children:[(0,Z.jsx)(cn,{initial:t,onSaved:n}),o&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Z.jsx)(ln,{assistant:o,onSaved:s})]})]}):(0,Z.jsx)(un,{})}var mn=ft({query:{hosting:`platform`}});function hn(){let e=Ht(),t=u(mn),n=t.data?.results??[];return t.isPending||n.length<2?null:(0,Z.jsx)(Y,{title:`Switch Assistant`,subtitle:`Choose which assistant is active for this account.`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>{let n=t.id===e;return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-lg border px-4 py-3 ${n?`border-[var(--border-focus)] bg-[var(--surface-lift)]`:`border-[var(--border-base)] bg-[var(--surface-default)]`}`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(C,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:t.name||`Unnamed`}),t.status!==`active`&&(0,Z.jsx)(ne,{tone:`warning`,children:t.status})]})})]}),(0,Z.jsx)(`div`,{className:`shrink-0`,children:n?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,Z.jsx)(g,{className:`h-4 w-4`}),`Active`]}):(0,Z.jsx)(a,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{Ce(t.id),U.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var gn=[{label:`Never`,seconds:0},{label:`5 min`,seconds:300,devOnly:!0},{label:`10 min`,seconds:600,devOnly:!0},{label:`1 hour`,seconds:3600},{label:`3 hours`,seconds:10800},{label:`1 day`,seconds:86400},{label:`3 days`,seconds:259200},{label:`7 days`,seconds:604800},{label:`14 days`,seconds:1209600},{label:`30 days`,seconds:2592e3}];function _n(e){if(e===0)return`Never (sleep disabled)`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600);if(t>0&&n>0)return`${t}d ${n}h`;if(t>0)return`${t} day${t===1?``:`s`}`;if(n>0)return`${n} hour${n===1?``:`s`}`;let r=Math.floor(e/60);return r>0?`${r} minute${r===1?``:`s`}`:`${e}s`}function vn({assistantId:e}){let t=l(),n=Wt.use.isNonProduction(),r=(0,X.useMemo)(()=>gn.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:o,isError:s}=u(st({path:{id:e}})),c=(0,X.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[d,f]=(0,X.useState)(null),p=d??c,m=d!==null,h=rt({onSuccess:()=>{U.success(`Sleep policy saved.`),f(null),t.invalidateQueries({queryKey:Ze({path:{id:e}})})},onError:()=>{U.error(`Failed to save sleep policy. Please try again.`)}});return o?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):s?(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:`Failed to load sleep policy. Refresh the page to try again.`}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Idle timeout`}),(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`How long the assistant can be idle before it is put to sleep. "Never" disables idle sleep entirely.`}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:r.map(e=>(0,Z.jsx)(a,{variant:`outlined`,active:p===e.seconds,onClick:()=>f(e.seconds),children:e.label},e.seconds))}),(0,Z.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,_n(p)]})]}),m&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(a,{variant:`primary`,leftIcon:h.isPending?(0,Z.jsx)(S,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,Z.jsx)(a,{variant:`outlined`,onClick:()=>f(null),disabled:h.isPending,children:`Cancel`})]})]})}function yn(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var bn=3e3;function xn({version:e,assistantId:t}){let{onTap:n,message:r}=Kt(t);return(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`block min-w-0 break-all text-left text-body-medium-lighter text-[var(--content-default)]`,onClick:n,children:e??`—`}),r&&(0,Z.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:r})]})}function Sn({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=ht.use.rollbackEnabled(),o=J.use.previewChannel(),s=l(),c=xt(n,o),f=c===`preview`,[p,m]=(0,X.useState)(!1),h=(0,X.useRef)(null),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[C,w]=(0,X.useState)(null),E=e=>e&&h.current&&e===h.current?(queueMicrotask(()=>{w(b?`Successfully rolled back to version ${h.current}.`:`Successfully updated to version ${h.current}.`),m(!1),h.current=null,_(null),U.success(b?`Rollback complete — assistant is healthy.`:`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),r?.()}),!1):bn;u({...lt({path:{id:e}}),refetchInterval:p?e=>E(e.state.data?.current_release_version):!1});let{data:D,isLoading:O}=u(it({query:{channel:c}})),k=D?.find(e=>e.is_stable!==!1)??D?.[0],A=g??k?.version??null,j=(0,X.useMemo)(()=>{if(!i||!A||!t)return!1;let e=_e(A),n=_e(t);return!e||!n?!1:ve(e,n)<0},[i,A,t]),M=(0,X.useMemo)(()=>{if(!A)return!1;if(!t)return!0;let e=_e(A),n=_e(t);if(!e||!n)return A!==t;let r=ve(e,n);return i?r!==0:r>0},[i,A,t]),N=d({mutationFn:async t=>{let{data:n}=await ze({path:{id:e},body:t,throwOnError:!0});return n}}),P=d({mutationFn:async t=>{let{data:n}=await Fe({path:{id:e},body:t,throwOnError:!0});return n}});return(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 md:grid md:grid-cols-[auto_minmax(0,1fr)] md:items-center md:gap-x-8 md:gap-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Z.jsx)(xn,{version:t,assistantId:e})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:f?`Preview release`:M?j?`Rollback to`:`Update to`:`Selected`}),(0,Z.jsx)(`span`,{className:`block min-w-0`,children:O?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(S,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):D&&D.length>0?i?(0,Z.jsx)(ie,{value:A??``,onChange:e=>_(e===k?.version?null:e),disabled:p||N.isPending||P.isPending,options:D.map(e=>({value:e.version,label:yn(e,t,k?.version)}))}):(0,Z.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:k?yn(k,t,k.version):`—`}):`No releases available`})]})]}),(0,Z.jsx)(a,{variant:j?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:N.isPending||P.isPending||p?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(T,{}),onClick:()=>y(!0),disabled:!M||N.isPending||P.isPending||p||O||!D?.length,children:p?b?`Rolling back...`:`Updating...`:j?`Rollback`:f?`Update preview`:`Update`}),f&&(0,Z.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Using Preview releases.`,` `,(0,Z.jsx)(`a`,{href:`#preview-release-channel`,className:`text-[var(--primary-base)] underline-offset-2 hover:underline`,children:`Switch back to Stable`})]}),!M&&t&&A&&!O&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:C??`You are already on this version.`}),(0,Z.jsx)(re,{open:v,title:j?`Rollback assistant`:f?`Update preview release`:`Update assistant`,message:j?`Rollback to version ${A??`unknown`}? The assistant will be briefly unavailable.`:f?`Update to preview version ${A??`latest`}? The assistant will be briefly unavailable during the update.`:`Update to version ${A??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:j?`Rollback`:f?`Update preview`:`Update`,onConfirm:async()=>{y(!1),w(null);let t=g??void 0;try{if(j){let e=await P.mutateAsync({version:t});h.current=e.version??t??null,U.success(e.detail||`Rollback to ${t} initiated.`)}else{let e=await N.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){U.warning(e.detail);return}h.current=e.version??t??null,U.success(e.detail||`Update to ${e.version??t??`latest`} initiated.`)}x(j),m(!0),s.invalidateQueries({queryKey:Ke({path:{id:e}})})}catch{U.error(j?`Failed to trigger rollback. Please try again.`:`Failed to trigger update. Please try again.`)}},onCancel:()=>y(!1)})]})}function Cn({assistantId:e,currentVersion:t,onUpgradeComplete:n}){let[r,i]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null),{data:c,isLoading:l}=u(it({query:{stable:!0,limit:100}})),d=(0,X.useMemo)(()=>Ot(c),[c]),f=d?.version,p=t?Ct(t,f):!!f,m=wt({assistantId:e,targetVersion:f});return(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 md:grid md:grid-cols-[auto_minmax(0,1fr)] md:items-center md:gap-x-8 md:gap-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Z.jsx)(xn,{version:t,assistantId:e})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Update to`}),(0,Z.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:l?`Loading...`:f&&d?yn(d,t,f):`No releases available`})]})]}),(0,Z.jsx)(a,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(T,{}),onClick:()=>i(!0),disabled:m.isPending||l||!f||!p,children:m.isPending?`Updating...`:f?`Update to ${f}`:`Update`}),o&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:o}),!o&&!p&&f&&!l&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:`You are already on this version.`}),(0,Z.jsx)(re,{open:r,title:`Update assistant`,message:`Update to version ${f??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:`Update`,onConfirm:async()=>{i(!1),s(null);try{let e=await m.upgrade();s(e.version?`Successfully updated to version ${e.version}.`:`Successfully updated to version ${f??`latest`}.`),U.success(`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),n?.()}catch(e){U.error(e instanceof Error?e.message:`Failed to trigger update. Please try again.`)}},onCancel:()=>i(!1)})]})}function wn(){let e=Lt({platformHostedOnly:!0}),t=zt(),n=ke.use.user()?.id??null,r=ke.use.logout(),[i,o]=(0,X.useState)(!1),s=et({onSuccess:async()=>{U.success(`Account deletion requested. You will be logged out shortly.`),De(n),await r(),Tt(q.account.login)},onError:()=>{U.error(`Failed to request account deletion. Please try again.`)}}),c=e===`full`&&t;return(0,X.useEffect)(()=>{c&&i&&o(!1)},[c,i]),e===`gated`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Delete Account`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently delete your account and all associated data.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:e===`disabled`?(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to delete your account.`}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(a,{variant:`dangerOutline`,onClick:()=>o(!0),disabled:s.isPending||c,className:`self-start`,children:`Delete My Account`}),c&&(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})})]}),(0,Z.jsx)(re,{open:i,title:`Delete Account`,message:`This will permanently delete your account and all associated data. This action cannot be undone.`,confirmLabel:`Delete Account`,destructive:!0,onConfirm:()=>{if(c){o(!1);return}o(!1),s.mutate({})},onCancel:()=>o(!1)})]})}function Tn({title:e,subtitle:t,benefits:n,ctaLabel:r,ctaLeftIcon:i,onAction:o}){return(0,Z.jsx)(Y,{title:e,subtitle:t,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(`ul`,{className:`space-y-3`,children:n.map(({icon:e,text:t})=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,Z.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,Z.jsx)(a,{variant:`primary`,size:`regular`,leftIcon:i,onClick:o,className:`self-start`,children:r})]})})}function En(){return We()?(0,Z.jsx)(Tn,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:h,text:`Push notifications`},{icon:Zt,text:`Biometric login`},{icon:Qt,text:`Native haptics`},{icon:Nt,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,Z.jsx)(Nt,{size:16}),onAction:()=>{Et(),It()}}):null}async function Dn(){if(!G())return[];let e=window.vellum;return e?.hotkeys?e.hotkeys.get():[]}async function On(e,t){if(!G())return;let n=window.vellum;n?.hotkeys&&await n.hotkeys.set(e,t)}function kn(e){if(!G())return()=>{};let t=window.vellum;return t?.hotkeys?t.hotkeys.onChange(e):()=>{}}var An={ArrowUp:`Up`,ArrowDown:`Down`,ArrowLeft:`Left`,ArrowRight:`Right`,Enter:`Return`,NumpadEnter:`Return`,Space:`Space`,Tab:`Tab`,Escape:`Escape`,Backspace:`Backspace`,Delete:`Delete`,Insert:`Insert`,Home:`Home`,End:`End`,PageUp:`PageUp`,PageDown:`PageDown`,Minus:`-`,Equal:`=`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,Semicolon:`;`,Quote:`'`,Backquote:"`",Comma:`,`,Period:`.`,Slash:`/`},jn=new Set([`MetaLeft`,`MetaRight`,`ControlLeft`,`ControlRight`,`AltLeft`,`AltRight`,`ShiftLeft`,`ShiftRight`]),Mn=e=>{let t=e.code;return jn.has(t)?null:/^Key[A-Z]$/.test(t)?t.slice(3):/^Digit[0-9]$/.test(t)?t.slice(5):/^Numpad[0-9]$/.test(t)?`num${t.slice(6)}`:/^F[0-9]{1,2}$/.test(t)?t:An[t]??null},Nn=e=>{let t=Mn(e);if(t===null)return null;let n=[];return e.metaKey&&n.push(`CmdOrCtrl`),e.ctrlKey&&n.push(`Control`),e.altKey&&n.push(`Alt`),e.shiftKey&&n.push(`Shift`),[...n,t].join(`+`)},Pn=(e,t,n)=>n===``?null:e.find(e=>e.key!==t&&e.accelerator===n)??null,Fn=[{scope:`global`,title:`Global shortcuts`,description:`Work anywhere, even when Vellum is in the background.`},{scope:`menu`,title:`App shortcuts`,description:`Work while a Vellum window is focused.`}];function In({hotkey:e,recording:t,conflictLabel:n,onStartRecording:r,onCancelRecording:i,onReset:o,onRemove:s}){let c=e.accelerator===``,l=e.override!==null;return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-body-medium-lighter text-[var(--content-default)]`,children:e.label}),n!==null&&(0,Z.jsxs)(`div`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:[`Already used by `,n]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Recording… press a shortcut, or Esc to cancel`}):c?(0,Z.jsx)(`span`,{className:`text-body-small-default italic text-[var(--content-disabled)]`,children:`Disabled`}):(0,Z.jsx)(te,{accelerator:e.accelerator}),t?(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,onClick:i,children:`Cancel`}):(0,Z.jsx)(a,{variant:`outlined`,size:`compact`,onClick:r,"aria-label":`Record shortcut for ${e.label}`,children:`Record`}),(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,disabled:!l,leftIcon:(0,Z.jsx)(Bt,{className:`h-3.5 w-3.5`}),onClick:o,"aria-label":`Reset ${e.label} to default`}),(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,disabled:c,leftIcon:(0,Z.jsx)(P,{className:`h-3.5 w-3.5`}),onClick:s,"aria-label":`Remove ${e.label} binding`})]})]})}function Ln(){let[e,t]=(0,X.useState)([]),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(null),o=(0,X.useCallback)(()=>{Dn().then(t)},[]);(0,X.useEffect)(()=>(o(),kn(t)),[o]);let s=(0,X.useCallback)(()=>{r(null),a(null)},[]);(0,X.useEffect)(()=>{if(n===null)return;let t=t=>{if(t.preventDefault(),t.stopPropagation(),t.code===`Escape`){s();return}let r=Nn(t);if(r===null)return;let i=Pn(e,n,r);if(i!==null){a({key:n,label:i.label});return}On(n,r).then(o),s()};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[n,e,o,s]);let c=(0,X.useCallback)(e=>{a(null),r(e)},[]),l=(0,X.useCallback)(t=>{let n=Pn(e,t,e.find(e=>e.key===t)?.defaultAccelerator??``);if(n!==null){r(null),a({key:t,label:n.label});return}s(),On(t,null).then(o)},[e,o,s]),u=(0,X.useCallback)(e=>{s(),On(e,``).then(o)},[o,s]),d=(0,X.useMemo)(()=>Fn.map(t=>({...t,commands:e.filter(e=>e.rebindable&&e.scope===t.scope)})).filter(e=>e.commands.length>0),[e]);return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[i!==null&&(0,Z.jsxs)(F,{tone:`warning`,children:[`That shortcut is already used by `,i.label,`.`,` `,n===null?`Remove or change that binding before resetting.`:`Pick a different combination, or press Esc to cancel.`]}),d.map(e=>(0,Z.jsxs)(p,{bordered:!0,children:[(0,Z.jsxs)(`div`,{className:`mb-2`,children:[(0,Z.jsx)(`div`,{className:`text-body-medium-emphasised text-[var(--content-default)]`,children:e.title}),(0,Z.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e.description})]}),(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.commands.map(e=>(0,Z.jsx)(In,{hotkey:e,recording:n===e.key,conflictLabel:i!==null&&i.key===e.key?i.label:null,onStartRecording:()=>c(e.key),onCancelRecording:s,onReset:()=>l(e.key),onRemove:()=>u(e.key)},e.key))})]},e.scope))]})}async function Rn(){if(!G())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function zn(e){if(!G())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function Bn(){let e=J.use.velvet(),{theme:t,setThemePreference:n}=bt(),r=[{value:`system`,label:`System`,icon:(0,Z.jsx)(C,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,Z.jsx)(St,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,Z.jsx)(w,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,Z.jsx)(At,{className:`h-4 w-4`})}]:[]];return(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Appearance`}),(0,Z.jsx)(`div`,{className:`mt-2 max-w-[360px]`,children:(0,Z.jsx)(z,{ariaLabel:`Theme`,value:t,onChange:n,items:r})})]})}function Vn(){let e=Dt.useValue();if(gt())return null;let t=Ge()?`Cmd`:`Ctrl`;return(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Composer`}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(V,{checked:e,onChange:Dt.save,label:`Send with ${t}+Enter`,helperText:`When enabled, Enter inserts a new line and ${t}+Enter sends.`})})]})}function Hn(){let[e,t]=(0,X.useState)(!1);(0,X.useEffect)(()=>{Rn().then(t)},[]);let n=async e=>{t(e);try{await zn(e)}catch{t(!e)}};return(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Launch at Login`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Automatically start Vellum when you log in to your Mac.`}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(V,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})]})}function Un({open:e,onClose:t}){return(0,Z.jsx)(H.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,Z.jsxs)(H.Content,{size:`lg`,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{children:`Preferences`}),(0,Z.jsx)(H.Description,{children:`Customize shortcuts and how Vellum behaves on this device.`})]}),(0,Z.jsx)(H.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsx)(Bn,{}),G()&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Keyboard Shortcuts`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Customize the shortcuts for Vellum's commands.`}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(Ln,{})})]}),(0,Z.jsx)(Vn,{}),G()&&(0,Z.jsx)(Hn,{})]})})]})})}function Wn(e){return e===`preview`?`preview`:`stable`}function Gn(e){if(!e)return`Unknown`;let t=new Date(e);return Number.isNaN(t.getTime())?`Unknown`:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function Kn(e){return e.source_release_version?`Stable ${e.source_release_version}`:e.snapshot_name}function qn(e){return e.filter(e=>e.ready_to_use)}function Jn(e){return e?.feature_enabled===!1}function Yn({assistantId:e,onComplete:t}){let n=J.use.previewChannel(),r=l(),[i,a]=(0,X.useState)(),[o,s]=(0,X.useState)(!1),[c,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(`restore_backup`),[h,g]=(0,X.useState)(``),v=Ye({path:{assistant_id:e}}),y=Je({path:{assistant_id:e}}),b=Ke({path:{id:e}}),{data:x,isLoading:C,isError:w}=u({...v,enabled:n,retry:!1}),T=x?.preview_backups??[],E=(0,X.useMemo)(()=>qn(T),[T]),D=E[0],O=E.find(e=>e.snapshot_name===h)??D,k=()=>{r.invalidateQueries({queryKey:y}),r.invalidateQueries({queryKey:b}),t?.()},A=d(pt()),j=d(nt()),M=Wn(x?.current_channel),N=A.isPending||j.isPending,P=N||Jn(x)||!x?.latest_preview_release,I=p===`restore_backup`&&!O;if((0,X.useEffect)(()=>{a(M===`preview`?`release-channel`:void 0)},[M]),!n)return null;let ee=x?.standard_upgrade_available??!1;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R.Root,{type:`single`,collapsible:!0,value:i,onValueChange:e=>a(e||void 0),className:`mt-5 border-t border-[var(--border-base)] pt-5`,children:(0,Z.jsxs)(R.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,Z.jsxs)(R.Trigger,{className:`group justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Release Channel`}),x&&(0,Z.jsx)(ne,{tone:M===`preview`?`warning`:`neutral`,children:M===`preview`?`Preview`:`Stable`})]}),(0,Z.jsx)(_,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Z.jsx)(R.Content,{children:(0,Z.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[C&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),w&&(0,Z.jsx)(F,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),x&&(0,Z.jsxs)(Z.Fragment,{children:[Jn(x)&&(0,Z.jsx)(F,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),M===`stable`?(0,Z.jsx)(Xn,{status:x,isChangingChannel:N,optInDisabled:P,onOptIn:()=>s(!0)}):(0,Z.jsx)(Zn,{status:x,isChangingChannel:N,onOptOut:()=>{let e=D;g(e?.snapshot_name??``),m(e?`restore_backup`:ee?`standard_upgrade`:`restore_backup`),f(!0)}})]})]})})]})}),(0,Z.jsx)($n,{open:o,isPending:A.isPending,previewVersion:x?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await A.mutateAsync({path:{assistant_id:e}});U.success(t.detail||`Preview channel enabled.`),s(!1),k()}catch(e){U.error(be(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,Z.jsx)(er,{open:c,backups:E,mode:p,selectedSnapshotName:O?.snapshot_name??``,isPending:j.isPending,restoreModeDisabled:I,standardUpgradeAvailable:ee,onModeChange:m,onSnapshotChange:g,onConfirm:async()=>{if(!I)try{let t=await j.mutateAsync({path:{assistant_id:e},body:p===`restore_backup`?{mode:`restore_backup`,snapshot_name:O?.snapshot_name}:{mode:`standard_upgrade`}});U.success(t.detail||`Stable channel enabled.`),f(!1),k()}catch(e){U.error(be(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>f(!1)})]})}function Xn({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Qn,{status:e}),!e.latest_preview_release&&(0,Z.jsx)(F,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,Z.jsx)(a,{variant:`outlined`,leftIcon:t?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(Rt,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function Zn({status:e,isChangingChannel:t,onOptOut:n}){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Qn,{status:e}),(0,Z.jsx)(a,{variant:`outlined`,leftIcon:t?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(Bt,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function Qn({status:e}){return(0,Z.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Stable`}),(0,Z.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??`None`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Preview`}),(0,Z.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_preview_release?.version??`None`})]})]})}function $n({open:e,isPending:t,previewVersion:n,onConfirm:r,onCancel:i}){return(0,Z.jsx)(H.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,Z.jsxs)(H.Content,{size:`md`,hideCloseButton:t,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{icon:N,children:`Opt in to Preview`}),(0,Z.jsx)(H.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,Z.jsx)(H.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(F,{tone:`warning`,title:`Data loss may occur when returning to Stable`,children:`Preview data may not be compatible with the Stable channel. The safety backup lets you restore the Stable-channel data that existed before opt-in.`}),(0,Z.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,Z.jsx)(`li`,{children:`Create and verify a Preview safety backup.`}),(0,Z.jsxs)(`li`,{children:[`Switch to Preview image `,n??`latest`,`.`]}),(0,Z.jsx)(`li`,{children:`Run the normal upgrade path and wait for health.`})]})]})}),(0,Z.jsxs)(H.Footer,{children:[(0,Z.jsx)(a,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,Z.jsx)(a,{variant:`primary`,disabled:t,leftIcon:t?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(Rt,{}),onClick:r,children:t?`Switching...`:`Take Backup and Switch`})]})]})})}function er({open:e,backups:t,mode:n,selectedSnapshotName:r,isPending:i,restoreModeDisabled:o,standardUpgradeAvailable:s,onModeChange:c,onSnapshotChange:l,onConfirm:u,onCancel:d}){return(0,Z.jsx)(H.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,Z.jsxs)(H.Content,{size:`md`,hideCloseButton:i,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{icon:N,children:`Switch back to Stable`}),(0,Z.jsx)(H.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,Z.jsx)(H.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(L,{value:n,onValueChange:c,disabled:i,"aria-label":`Stable channel return method`,children:[(0,Z.jsx)(ee,{value:`restore_backup`,disabled:t.length===0,label:`Restore safety backup`,helperText:`Return to the Stable-channel data captured before Preview opt-in.`}),(0,Z.jsx)(ee,{value:`standard_upgrade`,disabled:!s,label:`Switch to Stable without restoring backup`,helperText:s?`Keep the current data and directly switch to the Stable image.`:`Unavailable because the latest Stable release is older than this assistant's Preview release.`})]}),n===`restore_backup`&&t.length>0&&(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[`Safety backup`,(0,Z.jsx)(ie,{value:r,onChange:l,disabled:i,options:t.map(e=>({value:e.snapshot_name,label:`${Kn(e)} - ${Gn(e.created_at)}`}))})]}),n===`restore_backup`&&t.length===0&&!s&&(0,Z.jsx)(F,{tone:`error`,title:`Stable requires a safety backup`,children:`This Preview release is newer than the latest Stable release, so switching directly is blocked. Wait for a newer Stable release, or run Vellum Doctor if the safety backup is missing.`}),n===`standard_upgrade`&&(0,Z.jsx)(F,{tone:`error`,title:`Preview data may not survive this`,children:`Switching directly to the Stable image without restoring the safety backup may cause data loss or leave the assistant unusable if Preview data is incompatible with Stable.`})]})}),(0,Z.jsxs)(H.Footer,{children:[(0,Z.jsx)(a,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,Z.jsx)(a,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||o||n===`standard_upgrade`&&!s,leftIcon:i?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(T,{}),onClick:u,children:i?`Switching...`:`Switch to Stable`})]})]})})}function tr({assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:o}){let l=c(),d=u(ot()),f=d.data,p=!e.is_local,m=f?.plan_id===`pro`,h=u({...dt(),enabled:m}),g=e.machine_size||`small`,_=E(h.data?.max_machine_tier??null),v=(0,X.useMemo)(()=>O(_,g,(0,Z.jsx)(ne,{tone:`positive`,children:`Current`})),[_,g]),y=h.data?.selected_storage_gib??null,[b,C]=(0,X.useState)(!1),w=_.length>0?_[_.length-1]:null,[N,P]=(0,X.useState)(null),I=N??w??g,[ee,L]=(0,X.useState)(null),[R,z]=(0,X.useState)(null),te=mt({onSuccess:(e,n)=>{U.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),z(null),P(null),C(!1),n.body?.machine_size==null?i():o(t)},onError:e=>{z(j(e,`Failed to resize assistant. Please try again.`))}});if(d.isError&&f==null)return(0,Z.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Z.jsx)(F,{tone:`error`,children:`Could not load your subscription. Please try again.`})});let B=m&&_.includes(I)&&I!==g?I:null,V=m&&y!=null&&!0,re=m&&_.length>0&&A(g)<A(_[_.length-1]),W=te.isPending||r,ae=y==null?t?.disk?.totalMb??null:y*1024,oe=t?.disk&&ae!=null?{value:t.disk.usedMb,max:ae,caption:`${Yt(t.disk.usedMb)} of ${Yt(ae)}`}:null,se=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,ce=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${Yt(t.memory.currentMb)} of ${Yt(t.memory.maxMb)}`}:null,le=p?m?V?(0,Z.jsxs)(`button`,{type:`button`,disabled:W,onClick:()=>C(!0),className:`flex items-center gap-1.5 rounded-lg border border-amber-500/30 bg-amber-500/15 px-3 py-1.5 text-body-small-default font-medium text-amber-400 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,children:[(0,Z.jsx)(M,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,disabled:W,onClick:()=>C(!0),children:`Resize`}):(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,onClick:()=>L(`storage`),children:`Resize`}):null,ue=p?m?re?(0,Z.jsxs)(`button`,{type:`button`,disabled:W,onClick:()=>C(!0),className:`flex items-center gap-1.5 rounded-lg border border-amber-500/30 bg-amber-500/15 px-3 py-1.5 text-body-small-default font-medium text-amber-400 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,children:[(0,Z.jsx)(M,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,disabled:W,onClick:()=>C(!0),children:`Resize`}):(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,onClick:()=>L(`machine`),children:`Resize`}):null;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,compactAccessory:!0,accessory:(0,Z.jsx)(a,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,Z.jsx)(S,{className:`animate-spin`}):(0,Z.jsx)(T,{}),tooltip:r?`Applying resize…`:`Refresh resource metrics`,"aria-label":`Refresh resource metrics`,disabled:n||r,onClick:()=>void i()}),children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Z.jsx)(x,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),le]}),(0,Z.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Storage`}),oe?(0,Z.jsx)(Gt,{value:oe.value,max:oe.max,caption:oe.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Unavailable`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Z.jsx)(D,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Machine`}),(0,Z.jsx)(ne,{tone:`neutral`,children:k[g]})]}),ue]}),(0,Z.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`CPU`}),se?(0,Z.jsx)(Gt,{value:se.value,max:se.max,caption:se.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Memory`}),ce?(0,Z.jsx)(Gt,{value:ce.value,max:ce.max,caption:ce.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,Z.jsx)(H.Root,{open:ee!=null,onOpenChange:e=>{e||L(null)},children:(0,Z.jsxs)(H.Content,{size:`sm`,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{children:`Upgrade to Pro`}),(0,Z.jsx)(H.Description,{children:ee===`storage`?`Upgrade to the Pro plan to increase your storage allocation and get more space for your assistant.`:`Upgrade to the Pro plan to unlock larger machine sizes with more CPU and memory for your assistant.`})]}),(0,Z.jsxs)(H.Footer,{children:[(0,Z.jsx)(a,{variant:`ghost`,onClick:()=>L(null),children:`Cancel`}),(0,Z.jsx)(a,{onClick:()=>{L(null),l(`${q.settings.billing}?adjust_plan=1`)},children:`Upgrade`})]})]})}),(0,Z.jsx)(H.Root,{open:b,onOpenChange:e=>{e||(C(!1),P(null),z(null))},children:(0,Z.jsxs)(H.Content,{size:`sm`,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{icon:D,children:`Resize Assistant`}),(0,Z.jsx)(H.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,Z.jsx)(H.Body,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[_.length===0?(0,Z.jsx)(F,{tone:`warning`,children:`No machine tier configured. Visit the community for help.`}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:`Machine Size`}),(0,Z.jsx)(ie,{options:v,value:I,onChange:P,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),V?(0,Z.jsx)(F,{tone:`info`,children:`Storage will be expanded to ${y} GiB.`}):(0,Z.jsx)(F,{tone:`neutral`,children:`Storage will not change.`}),R&&(0,Z.jsx)(F,{tone:`error`,children:R})]})}),(0,Z.jsxs)(H.Footer,{className:`items-center justify-between`,children:[(0,Z.jsxs)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:[`Need more?`,` `,(0,Z.jsx)(s,{to:`${q.settings.billing}?adjust_plan=1`,className:`text-[var(--content-secondary)] underline decoration-[var(--border-element)] underline-offset-2 transition-colors hover:text-[var(--content-default)]`,onClick:()=>C(!1),children:`Upgrade plan`})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(a,{variant:`ghost`,onClick:()=>{C(!1),P(null),z(null)},children:`Cancel`}),(0,Z.jsx)(a,{disabled:B==null&&!V||W,leftIcon:W?(0,Z.jsx)(S,{className:`animate-spin`}):void 0,onClick:()=>{z(null);let t={};B!=null&&(t.machine_size=B),V&&y!=null&&(t.storage_gib=y),te.mutate({path:{id:e.id},body:t})},children:R?`Retry`:`Apply`})]})]})]})})]})}function nr({assistantId:e}){let t=c(),[n,r]=(0,X.useState)(!1),[i,o]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(a,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,Z.jsx)(Mt,{open:n,isPending:i,onConfirm:async()=>{o(!0);let n=await Pt(e);if(n.ok){r(!1),t(n.nextRoute,{replace:!0});return}U.error(n.error),o(!1),r(!1)},onCancel:()=>r(!1)})]})}var rr=`UTC.Africa/Cairo.Africa/Johannesburg.Africa/Lagos.Africa/Nairobi.America/Anchorage.America/Argentina/Buenos_Aires.America/Bogota.America/Chicago.America/Denver.America/Halifax.America/Lima.America/Los_Angeles.America/Mexico_City.America/New_York.America/Phoenix.America/Santiago.America/Sao_Paulo.America/Toronto.America/Vancouver.Asia/Bangkok.Asia/Dubai.Asia/Hong_Kong.Asia/Jakarta.Asia/Jerusalem.Asia/Karachi.Asia/Kolkata.Asia/Kuala_Lumpur.Asia/Manila.Asia/Seoul.Asia/Shanghai.Asia/Singapore.Asia/Taipei.Asia/Tokyo.Australia/Melbourne.Australia/Perth.Australia/Sydney.Europe/Amsterdam.Europe/Athens.Europe/Berlin.Europe/Brussels.Europe/Dublin.Europe/Istanbul.Europe/Lisbon.Europe/London.Europe/Madrid.Europe/Moscow.Europe/Paris.Europe/Rome.Europe/Stockholm.Europe/Vienna.Europe/Warsaw.Europe/Zurich.Pacific/Auckland.Pacific/Honolulu`.split(`.`);function ir(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...rr].sort()}function ar(e){let t=e.split(`/`),n=(t[t.length-1]??e).replace(/_/g,` `),r=t.length>1?(t[0]??``).replace(/_/g,` `):``,i=0,a=``;try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??`GMT`;a=t.startsWith(`GMT`)||t.startsWith(`UTC`)?t:`GMT ${t}`;let n=t.match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(n){let e=n[1]===`-`?-1:1,t=parseInt(n[2]??`0`,10),r=parseInt(n[3]??`0`,10);i=e*(t*60+r)}}catch{return null}return{identifier:e,city:n,region:r,offsetLabel:a,offsetMinutes:i}}function or(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function sr(e){if(!e)return`Not set`;try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`long`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value;if(t)return t}catch{}return e.replace(/_/g,` `)}function cr({value:e,onChange:t}){let[n,r]=(0,X.useState)(``),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(null),l=(0,X.useRef)(null),u=(0,X.useMemo)(()=>ir().map(e=>ar(e)).filter(e=>e!==null),[]);(0,X.useEffect)(()=>{let e=window.setTimeout(()=>{a(n.trim().toLowerCase())},200);return()=>window.clearTimeout(e)},[n]),(0,X.useEffect)(()=>{if(!o)return;let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let d=(0,X.useMemo)(()=>i?u.filter(e=>e.city.toLowerCase().includes(i)||e.region.toLowerCase().includes(i)||e.offsetLabel.toLowerCase().includes(i)||e.identifier.toLowerCase().includes(i)):u,[u,i]),f=(0,X.useMemo)(()=>{if(!e)return``;let t=e.split(`/`);return(t[t.length-1]??e).replace(/_/g,` `)},[e]),p=e=>{t(e),r(``),s(!1),l.current?.blur()};return(0,Z.jsxs)(`div`,{ref:c,className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Closest city`}),(0,Z.jsxs)(`div`,{className:`relative w-full md:max-w-[280px]`,children:[(0,Z.jsx)(B,{ref:l,type:`text`,value:n,placeholder:f||`Search city or country...`,onChange:e=>{r(e.target.value),s(!0)},onFocus:()=>s(!0),onKeyDown:e=>{e.key===`Escape`&&(r(``),s(!1),l.current?.blur())},fullWidth:!0}),o&&d.length>0&&(0,Z.jsx)(`div`,{className:`absolute left-0 right-0 top-full z-20 mt-1 max-h-[240px] overflow-y-auto rounded-md border border-[var(--border-base)] bg-[var(--surface-lift)] shadow-lg`,children:d.slice(0,200).map(t=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>p(t.identifier),className:`flex w-full cursor-pointer items-center justify-between gap-3 px-3 py-2 text-left text-body-medium-lighter transition-colors ${t.identifier===e?`bg-[var(--surface-active)] text-[var(--content-default)]`:`text-[var(--content-default)] hover:bg-[var(--surface-active)]`}`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-body-medium-default`,children:t.city}),t.region&&(0,Z.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:t.region})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(`span`,{children:or(t.identifier)}),(0,Z.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,Z.jsx)(Xt,{}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Time zone`}),(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:sr(e)})]})]})}function lr(){let e=ge.use.activeAssistantId(),[i,a]=(0,X.useState)(()=>n(`timezone`,``)),o=(0,X.useRef)(e);(0,X.useEffect)(()=>{o.current=e},[e]);let s=(0,X.useRef)(!1),c=(0,X.useRef)(null),l=(0,X.useRef)(()=>{}),u=e=>{if(s.current){c.current=e;return}let t=o.current;if(!t){c.current=null;return}s.current=!0,c.current=null,K.patch({url:`/v1/assistants/{assistant_id}/config`,path:{assistant_id:t},body:{ui:{userTimezone:e}},throwOnError:!0}).catch(e=>{r(e,{context:`settings-timezone-override`})}).finally(()=>{s.current=!1;let e=c.current;c.current=null,e!==null&&l.current(e)})};return(0,X.useEffect)(()=>{l.current=u}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Timezone`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Used when displaying times and scheduling reminders.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:(0,Z.jsx)(cr,{value:i,onChange:e=>{a(e),t(`timezone`,e),u(e)}})})]})}var ur=[[`Mon`,0],[`Tue`,1],[`Wed`,2],[`Thu`,3],[`Fri`,4],[`Sat`,5],[`Sun`,6]];function dr(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 fr(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 pr(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function mr(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:dr(t),windowEnd:dr(n)}}function hr({assistantId:e}){let t=l(),{data:n,isLoading:r,isError:i}=u(tt({path:{id:e}})),o=(0,X.useMemo)(()=>mr(n),[n]),[s,c]=(0,X.useState)(null),f=s??o,p=s!==null,m=(0,X.useMemo)(()=>pr(),[]),[h,g]=(0,X.useState)(null),_=h??f.daysOfMonth.join(`, `),v=d({mutationFn:async t=>{let{data:n}=await Be({path:{id:e},body:t,throwOnError:!0});return n}}),y=e=>{c(t=>({...t??o,...e}))},b=e=>{y({daysOfWeek:f.daysOfWeek.includes(e)?f.daysOfWeek.filter(t=>t!==e):[...f.daysOfWeek,e].sort((e,t)=>e-t)})},x=e=>e.split(`,`).map(e=>parseInt(e.trim(),10)).filter(e=>!isNaN(e)&&e>=1&&e<=31);return r?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading update window settings...`]}):i?(0,Z.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,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsx)(V,{checked:f.enabled,onChange:e=>y({enabled:e}),label:`Automatic updates`,helperText:`Update automatically during a configured time window`}),f.enabled&&(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Frequency`}),(0,Z.jsx)(`div`,{className:`max-w-[400px]`,children:(0,Z.jsx)(z,{ariaLabel:`Frequency`,value:f.frequency,onChange:e=>{e!==`monthly`&&g(null),y({frequency:e})},items:[{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}]})})]}),f.frequency===`weekly`&&(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Day(s) of week`}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:ur.map(([e,t])=>(0,Z.jsx)(a,{variant:`outlined`,size:`compact`,active:f.daysOfWeek.includes(t),onClick:()=>b(t),children:e},t))})]}),f.frequency===`monthly`&&(0,Z.jsx)(B,{label:`Day(s) of month`,type:`text`,value:_,onChange:e=>g(e.target.value),onBlur:e=>{let t=x(e.target.value);y({daysOfMonth:t}),g(t.join(`, `))},placeholder:`e.g. 1, 15`,helperText:`Comma-separated day numbers (1–31)`,className:`w-48`}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:[`Update window`,m?` (${m})`:``]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(B,{type:`time`,value:f.windowStart,onChange:e=>y({windowStart:e.target.value})}),(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`to`}),(0,Z.jsx)(B,{type:`time`,value:f.windowEnd,onChange:e=>y({windowEnd:e.target.value})})]})]})]}),(0,Z.jsx)(a,{variant:`primary`,leftIcon:v.isPending?(0,Z.jsx)(S,{className:`animate-spin`}):void 0,onClick:async()=>{let n=f.frequency===`monthly`&&h!==null?x(h):f.daysOfMonth;try{await v.mutateAsync({enabled:f.enabled,timezone:`UTC`,schedule:{frequency:f.frequency,days_of_week:f.frequency===`weekly`?f.daysOfWeek:[],days_of_month:f.frequency===`monthly`?n:[],window:{start:fr(f.windowStart),end:fr(f.windowEnd)}}}),U.success(`Auto-update policy saved.`),c(null),g(null),t.invalidateQueries({queryKey:Xe({path:{id:e}})})}catch{U.error(`Failed to save policy. Please try again.`)}},disabled:v.isPending||!p,children:`Save policy`})]})}function gr({assistantId:e,open:t,onClose:n}){return(0,Z.jsx)(H.Root,{open:t,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(H.Content,{size:`md`,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{children:`Update Window`}),(0,Z.jsx)(H.Description,{children:`Configure when automatic updates are applied.`})]}),(0,Z.jsx)(H.Body,{children:(0,Z.jsx)(hr,{assistantId:e})})]})})}function _r(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`)return t}}function vr({open:e,onOpenChange:t}){let n=l(),[r,i]=(0,X.useState)(null),[o,s]=(0,X.useState)(``),[c,u]=(0,X.useState)(null),d=(0,X.useRef)(!1),f=(0,X.useRef)(e),p=()=>n.invalidateQueries({queryKey:$e()}),m=e=>{Le({path:{id:e}}).catch(()=>void 0).finally(()=>void p())},h=ut({onSuccess:e=>{if(!f.current){m(e.factor_id);return}i(e)},onError:e=>{let n=_r(e);n===`no_workos_account`?U.error(`Two-factor authentication is only available for Vellum platform accounts.`):n===`throttled`||n===`workos_rate_limited`?U.error(`Too many attempts. Try again in a minute.`):n===`factor_limit_reached`?U.error(`An authenticator app is already set up. Remove it before adding another.`):U.error(`Failed to start setup. Please try again.`),t(!1)}}),g=ct({onSuccess:e=>{e.valid?(d.current=!0,U.success(`Two-factor authentication is on.`),p(),t(!1)):u(`That code didn't match. Check your authenticator app and try again.`)},onError:e=>{let n=_r(e);if(n===`challenge_already_verified`){d.current=!0,U.success(`Two-factor authentication is on.`),p(),t(!1);return}if(n===`challenge_expired`||n===`challenge_not_found`){r&&m(r.factor_id),i(null),s(``),u(`This setup session expired. Scan the new QR code and try again.`),h.mutate({});return}if(n===`throttled`||n===`workos_rate_limited`){u(`Too many attempts. Wait a minute and try again.`);return}u(`Couldn't verify the code. Wait a moment and try again.`)}});(0,X.useEffect)(()=>{f.current=e,e&&(d.current=!1,i(null),s(``),u(null),h.mutate({}))},[e]);let _=e=>{!e&&g.isPending||(!e&&r&&!d.current&&m(r.factor_id),t(e))},v=()=>{r&&navigator.clipboard.writeText(r.secret).then(()=>U.success(`Setup key copied.`)).catch(()=>U.error(`Couldn't copy the setup key.`))},y=()=>{!r||o.length!==6||g.isPending||(u(null),g.mutate({body:{challenge_id:r.challenge_id,code:o}}))};return(0,Z.jsx)(H.Root,{open:e,onOpenChange:_,children:(0,Z.jsxs)(H.Content,{size:`sm`,children:[(0,Z.jsxs)(H.Header,{children:[(0,Z.jsx)(H.Title,{children:`Set up authenticator app`}),(0,Z.jsx)(H.Description,{children:`Scan the QR code with an authenticator app such as Google Authenticator or 1Password, then enter the 6-digit code it shows.`})]}),(0,Z.jsx)(H.Body,{children:r===null?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Z.jsx)(S,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,Z.jsxs)(`form`,{className:`flex flex-col items-center gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,Z.jsx)(`img`,{src:r.qr_code,alt:`QR code for your authenticator app`,className:`h-44 w-44 rounded-lg bg-white p-2`}),(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Can't scan it? Enter this setup key manually:`}),(0,Z.jsxs)(`button`,{type:`button`,onClick:v,className:`flex cursor-pointer items-center gap-2 self-start font-mono text-body-small-default text-[var(--content-default)] hover:text-[var(--content-emphasised)]`,children:[(0,Z.jsx)(`span`,{className:`break-all text-left`,children:r.secret}),(0,Z.jsx)(b,{className:`h-3.5 w-3.5 shrink-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`totp-code`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:`6-digit code`}),(0,Z.jsx)(B,{id:`totp-code`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,placeholder:`123456`,value:o,onChange:e=>s(e.target.value.replace(/\D/g,``).slice(0,6))}),c&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--system-negative-strong)]`,children:c})]})]})}),(0,Z.jsxs)(H.Footer,{children:[(0,Z.jsx)(a,{variant:`outlined`,onClick:()=>_(!1),disabled:g.isPending,children:`Cancel`}),(0,Z.jsx)(a,{onClick:y,disabled:r===null||o.length!==6||g.isPending,children:g.isPending?`Verifying…`:`Verify`})]})]})})}function yr(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function br(){let e=l(),[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(null),o=u({...Qe()}),s=o.data??[],c=()=>e.invalidateQueries({queryKey:$e()}),d=qe({onSuccess:()=>{U.success(`Authenticator app removed.`),c()},onError:e=>{if(_r(e)===`factor_not_found`){c();return}U.error(`Failed to remove the authenticator app. Please try again.`)}});return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.isPending?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin`}),(0,Z.jsx)(`span`,{className:`text-body-medium-default`,children:`Loading authenticator apps…`})]}):o.isError?(0,Z.jsxs)(F,{tone:`error`,children:[`Couldn't load your authenticator apps.`,` `,(0,Z.jsx)(`button`,{type:`button`,className:`cursor-pointer underline`,onClick:()=>void o.refetch(),children:`Try again`})]}):s.length===0?(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`No authenticator app is set up. Add one to require a one-time code at sign-in.`}):(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:s.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(Nt,{className:`h-5 w-5 shrink-0 text-[var(--content-tertiary)]`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Authenticator app`}),(0,Z.jsxs)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:[e.user,e.created_at?` · Added ${yr(e.created_at)}`:``]})]})]}),(0,Z.jsx)(a,{variant:`dangerOutline`,onClick:()=>i(e),disabled:d.isPending,children:`Remove`})]},e.id))}),!o.isPending&&!o.isError&&s.length===0&&(0,Z.jsx)(a,{onClick:()=>n(!0),className:`self-start`,children:`Add authenticator app`}),(0,Z.jsx)(vr,{open:t,onOpenChange:n}),(0,Z.jsx)(re,{open:r!==null,title:`Remove authenticator app`,message:`Signing in will no longer ask for a code from this app. You can set up a new authenticator app at any time.`,confirmLabel:`Remove`,destructive:!0,onConfirm:()=>{r&&d.mutate({path:{id:r.id}}),i(null)},onCancel:()=>i(null)})]})}var Q=class extends Error{code;constructor(e,t){super(t),this.name=`TeleportError`,this.code=e}},xr=`local`,Sr=`docker`,Cr=`vellum`;function wr(e){switch((e??``).toLowerCase()){case xr:return`local`;case Sr:return`docker`;case Cr:return`managed`;default:return`other`}}function Tr(e){let t=wr(e);return t===`managed`?`local`:t===`local`?`platform`:null}function Er(e){switch(e){case`docker`:return`Move to Docker`;case`platform`:return`Move to Cloud (Platform)`;case`local`:return`Move to Local`}}function Dr(e){switch(e){case`docker`:return`Run your assistant in a Docker container on this Mac.`;case`platform`:return`Run your assistant in the cloud, managed by the Vellum platform.`;case`local`:return`Run your assistant locally on this Mac.`}}function Or(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.reason!==`version_mismatch`)return null;let n=t.bundle_compat,r=t.target_runtime_version;if(!n||typeof n!=`object`||typeof r!=`string`)return null;let i=n,a=i.min_runtime_version;if(typeof a!=`string`)return null;let o=typeof i.max_runtime_version==`string`?i.max_runtime_version:null;return`Cannot import: bundle requires runtime ${o?`${a}–${o}`:`${a}+`}, but this local runtime is ${r}. Update your local runtime before importing.`}async function kr(e,t){let n=Number(e.headers.get(`Content-Length`)??0);if(!e.body||!t||n<=0){let n=await e.arrayBuffer();return t?.(1),n}let r=e.body.getReader(),i=[],a=0;for(;;){let{done:e,value:o}=await r.read();if(e)break;i.push(o),a+=o.length,t(a/n)}let o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return t(1),o.buffer}function Ar(e){let t=de(e);if(!t)throw new Q(`local_assistant_not_found`,`Assistant ${e.assistantId} has no resolved local gateway.`);return`${window.location.origin}${t}`}async function jr(e,t){let n=await ae(e.assistantId),r=await fetch(`${t}/auth/token`,{method:`POST`,headers:{Authorization:`Bearer ${n}`}});if(!r.ok)throw new Q(`not_signed_in`,`Gateway token request failed (HTTP ${r.status}).`);let{token:i}=await r.json();return i}async function Mr(e,t){let n=Ar(e),r=await jr(e,n),i=await fetch(`${n}/v1/migrations/export`,{method:`POST`,headers:{Authorization:`Bearer ${r}`}});if(!i.ok)throw new Q(`export_failed`,`Export failed (HTTP ${i.status}).`);return kr(i,t)}async function Nr(e,t){let n=Ar(e),r=await jr(e,n),i=await fetch(`${n}/v1/migrations/import`,{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:new Blob([t],{type:`application/octet-stream`})});if(!i.ok)throw new Q(`import_failed`,`Import failed (HTTP ${i.status}).`);let a=await Ir(i);if(a&&a.success===!1)throw new Q(`import_failed`,a.error??`Import reported failure`)}async function Pr(e,t){let{data:n,response:r}=await K.post({url:`/v1/assistants/{assistant_id}/migrations/export-to-gcs/`,path:{assistant_id:e},body:{upload_url:t},throwOnError:!1}),i=r?.status??0;if(!(r?.ok??!1)&&i!==202)throw new Q(`export_failed`,`Export failed (HTTP ${i}).`);let a=n?.job_id;if(!a)throw new Q(`export_failed`,`Export accepted but no job ID was returned.`);return a}async function Fr(e,t){let{data:n,response:r}=await K.get({url:`/v1/assistants/{assistant_id}/migrations/jobs/{job_id}`,path:{assistant_id:e,job_id:t},throwOnError:!1}),i=r?.status??0;if(i>=500)return`processing`;if(!(r?.ok??!1))throw new Q(`export_job_failed`,`Job status check failed (HTTP ${i})`);let a=n;if(a?.status===`failed`)throw new Q(`export_job_failed`,a.error??`Export job failed`);return a?.status??`processing`}async function Ir(e){try{return await e.json()}catch{return null}}var Lr=new Set([500,502,503,504]),$=3,Rr=e=>new Promise(t=>setTimeout(t,e));async function zr(e,t=new Set){for(let n=0;n<=$;n++){let{response:r,data:i,error:a}=await e(),o=r?.status??0;if(n<$&&Lr.has(o)&&!t.has(o)){await Rr(2**n*1e3);continue}return{status:o,data:i,error:a}}throw new Q(`unknown`,`Unexpected retry loop exit`)}async function Br(e,t){let n={operation:`upload`};e&&(n.min_runtime_version=e,n.max_runtime_version=null),t&&(n.consumer=t);let{status:r,data:i}=await zr(()=>K.post({url:`/v1/migrations/signed-url/`,body:n,throwOnError:!1}),new Set([404,503]));if(r===503||r===404)throw new Q(`export_failed`,`Signed URL uploads are not available — the platform may not support this feature yet.`);if(r!==201)throw new Q(`export_failed`,`Migration request failed (HTTP ${r}).`);let a=i;return{url:a.url,bundleKey:a.bundle_key,expiresAt:a.expires_at}}async function Vr(e,t){let{status:n,data:r,error:i}=await zr(()=>K.post({url:`/v1/migrations/signed-url/`,body:{operation:`download`,bundle_key:e,target_runtime_version:t},throwOnError:!1}),new Set([422]));if(n===422){let e=Or(i);if(e)throw new Q(`version_mismatch`,e)}if(n!==200&&n!==201)throw new Q(`import_failed`,`Migration request failed (HTTP ${n}).`);return r.url}async function Hr(e,t,n){for(let r=0;r<=$;r++){let i=await Ur(e,t,n);if(r<$&&Lr.has(i)){await Rr(2**r*1e3),n?.(0);continue}if(i<200||i>=300)throw new Q(`export_failed`,`Bundle upload failed (HTTP ${i}).`);return}}function Ur(e,t,n){return new Promise((r,i)=>{let a=new XMLHttpRequest;a.open(`PUT`,e),a.setRequestHeader(`Content-Type`,`application/octet-stream`),a.timeout=36e5,n&&(a.upload.onprogress=e=>{e.lengthComputable&&n(e.loaded/e.total)}),a.onload=()=>{n?.(1),r(a.status)},a.onerror=()=>i(new Q(`export_failed`,`Bundle upload failed.`)),a.ontimeout=()=>i(new Q(`export_timed_out`,`Bundle upload timed out.`)),a.send(t)})}async function Wr(e,t){for(let n=0;n<=$;n++){let r=await fetch(e,{method:`GET`});if(n<$&&Lr.has(r.status)){await Rr(2**n*1e3),t?.(0);continue}if(!r.ok)throw new Q(`import_failed`,`Bundle download failed (HTTP ${r.status}).`);return kr(r,t)}throw new Q(`import_failed`,`Unexpected retry loop exit`)}async function Gr(e){let{status:t,data:n,error:r}=await zr(()=>K.post({url:`/v1/migrations/import-from-gcs/`,body:{bundle_key:e},throwOnError:!1}));return{status:t,body:n??r??null}}async function Kr(e){let{status:t,data:n}=await zr(()=>K.get({url:`/v1/migrations/jobs/{job_id}/`,path:{job_id:e},throwOnError:!1}));if(t!==200)throw new Q(`import_failed`,`Job status check failed (HTTP ${t})`);let r=n??{};return{status:typeof r.status==`string`?r.status:`unknown`,jobId:typeof r.job_id==`string`?r.job_id:null,error:typeof r.error==`string`?r.error:null}}var qr=5e3,Jr=36e5,Yr=5*6e4,Xr=30,Zr=e=>new Promise(t=>setTimeout(t,e));function Qr(){let e=c(),t=pe(),n=Tr(t?.cloud),[i,a]=(0,X.useState)({kind:`idle`}),[o,s]=(0,X.useState)(!1),l=(0,X.useRef)(null),u=(0,X.useRef)(null),d=(0,X.useCallback)(e=>{a({kind:`transferring`,step:e,progress:null})},[]),f=(0,X.useCallback)(e=>{a(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,X.useCallback)(async()=>{if(!(!t||!n)){u.current={id:t.assistantId,kind:wr(t.cloud)===`managed`?`managed`:`local`,createdFresh:!1};try{if(n===`platform`)await $r(t,d,f,l);else if(n===`local`)await ei(t,d,f,l);else throw new Q(`unknown`,`Unsupported teleport destination.`);a({kind:`verifying`})}catch(e){a({kind:`failed`,error:`Teleport failed: ${e instanceof Q||e instanceof Error?e.message:`Teleport failed.`}`}),r(e,{context:`teleport-execute`}),await ni(l.current,u.current,`teleport-execute-cleanup`),l.current=null}}},[t,n,d,f]),m=(0,X.useCallback)(()=>s(!0),[]),h=(0,X.useCallback)(()=>s(!1),[]),g=(0,X.useCallback)(()=>{s(!1),p()},[p]),_=(0,X.useCallback)(()=>{l.current=null,u.current=null,a({kind:`idle`})},[]);return{destination:n,phase:i,confirmOpen:o,requestTeleport:m,cancelConfirm:h,confirm:g,confirmAndSwitch:(0,X.useCallback)(()=>{let t=l.current,n=u.current;t&&(async()=>{try{let e=ke.getState();t.kind===`managed`?await e.connectPlatformAssistant(t.id):(await e.connectLocalAssistant(t.id),Me(t.id,{onError:e=>r(e,{context:`teleport-inject-platform-identity`})}))}catch(e){a({kind:`failed`,error:`Switch failed: ${e instanceof Error?e.message:`Failed to switch assistant.`}`}),r(e,{context:`teleport-confirm-switch`});return}n&&Pt(n.id).then(e=>{e.ok||r(Error(e.error),{context:`teleport-retire-source`})}),_(),e(q.assistant,{replace:!0})})()},[e,_]),cancelTeleport:(0,X.useCallback)(()=>{let e=l.current,t=u.current;l.current=null,u.current=null,a({kind:`idle`}),ni(e,t,`teleport-cancel-retire-target`)},[]),reset:_}}async function $r(e,t,n,r){t(`Exporting assistant data...`);let i=await Mr(e,n);t(`Resolving organization...`);let a=await ii();t(`Checking for existing assistant...`);let o=(await Re({query:{hosting:`platform`},throwOnError:!1})).data?.results?.[0];if(o)throw new Q(`existing_platform_assistant`,`You already have a platform assistant '${o.id}'. Retire it first, then retry the teleport.`);t(`Uploading data to cloud...`);let s=await Br(e.resources?.runtimeVersion);await Hr(s.url,i,n),t(`Setting up cloud assistant...`);let c=await Ue(void 0,`create`);if(!c.ok)throw new Q(`import_failed`,`Failed to set up the cloud assistant.`);if(c.status===200)throw new Q(`existing_platform_assistant`,`You already have a platform assistant '${c.data.id}'. Retire it first, then retry the teleport.`);let l=c.data.id;await oe({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:ce(),hatchedAt:c.data.created??new Date().toISOString(),organizationId:a}),await W(e.assistantId),r.current={id:l,kind:`managed`,createdFresh:!0},t(`Finalizing cloud assistant...`),await ai(l),t(`Importing data to cloud...`);let u=await Gr(s.bundleKey);if(u.status<200||u.status>=300){let e=u.body;throw new Q(`import_failed`,e?.error??`Import failed (HTTP ${u.status}).`)}if(u.status===202){let e=u.body?.job_id;if(!e)throw new Q(`import_failed`,`Import accepted but no job ID returned.`);await oi(e)}else{let e=u.body;if(e&&e.success===!1)throw new Q(`import_failed`,e.error??`Import reported failure.`)}}async function ei(e,t,n,r){t(`Preparing export...`);let i=await Br(await ri(e.assistantId),`runtime`);t(`Exporting cloud data...`);let a=await Pr(e.assistantId,i.url);await si(e.assistantId,a),t(`Preparing local assistant...`);let{assistant:o,createdFresh:s}=await ci();r.current={id:o.assistantId,kind:`local`,createdFresh:s};let c=await ti(o,s);if(!c)throw new Q(`local_assistant_not_found`,`Could not determine the local assistant's runtime version. Restart or upgrade the local assistant, then retry the teleport.`);t(`Preparing import...`);let l=await Vr(i.bundleKey,c);t(`Downloading data...`);let u=await Wr(l,n);t(`Importing data...`),await ui(o,u),await W(e.assistantId)}async function ti(e,t){if(e.resources?.runtimeVersion)return e.resources.runtimeVersion;if(t)return(await Ut())?.version??void 0}async function ni(e,t,n){if(e?.createdFresh){let t=await Pt(e.id);t.ok||r(Error(t.error),{context:n})}t&&await W(t.id)}async function ri(e){let t=await He(e);return t.ok?t.data.version??void 0:void 0}async function ii(){let e=Se.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=Se.getState().organizations,n=je();if(n&&t.some(e=>e.id===n))return n;if(t.length===0)throw new Q(`no_organizations`,`No organizations found for this account.`);if(t.length>1)throw new Q(`multiple_organizations`,`Multiple organizations found — please select one in account settings first.`);let r=t[0].id;return Se.getState().setCurrentOrganizationId(r),r}async function ai(e){let t=Date.now();for(;Date.now()-t<Yr;){let{data:t,response:n}=await Ve({path:{id:e},throwOnError:!1});if(n?.ok&&t?.state===`active`)return;await Zr(qr)}}async function oi(e){let t=Date.now();for(;Date.now()-t<Jr;){await Zr(qr);let t=await Kr(e);if(t.status===`complete`)return;if(t.status===`failed`)throw new Q(`import_failed`,t.error??`Import job failed`)}throw new Q(`import_failed`,`Import timed out after 60 minutes.`)}async function si(e,t){let n=Date.now();for(;Date.now()-n<Jr;)if(await Zr(qr),await Fr(e,t)===`complete`)return;throw new Q(`export_timed_out`,`Export timed out.`)}async function ci(){let e=await fe(void 0,void 0);if(!e.ok)throw new Q(`local_assistant_not_found`,e.error??`Could not create a local assistant.`);await se();let t=e.assistantId?he().find(t=>t.assistantId===e.assistantId):li();if(!t)throw new Q(`local_assistant_not_found`,`Could not find or create a local assistant.`);return{assistant:t,createdFresh:!0}}function li(){return he().slice().sort((e,t)=>(t.hatchedAt??``).localeCompare(e.hatchedAt??``))[0]}async function ui(e,t){let n;for(let r=0;r<Xr;r++)try{await Nr(e,t);return}catch(e){n=e,await Zr(1e3)}throw n instanceof Error?n:new Q(`import_failed`,`Import failed.`)}function di(){let e=Qr(),{destination:t,phase:n}=e;return t?(0,Z.jsxs)(Y,{title:`Teleport`,subtitle:`Move your assistant to a different hosting environment.`,children:[n.kind===`idle`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:Dr(t)}),(0,Z.jsx)(a,{variant:`outlined`,className:`self-start`,onClick:e.requestTeleport,children:Er(t)})]}),n.kind===`transferring`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.progress==null&&(0,Z.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:n.step})]}),n.progress!=null&&(0,Z.jsx)(I,{value:n.progress,"aria-label":`Teleport progress`,className:`max-w-[240px]`})]}),n.kind===`verifying`&&(0,Z.jsx)(F,{tone:`success`,icon:(0,Z.jsx)(y,{className:`h-4 w-4`}),title:`Transfer complete — verify your new assistant is working.`,actions:(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(a,{variant:`primary`,onClick:e.confirmAndSwitch,children:`Confirm & Switch`}),(0,Z.jsx)(a,{variant:`outlined`,onClick:e.cancelTeleport,children:`Cancel`})]})}),n.kind===`failed`&&(0,Z.jsx)(F,{tone:`error`,title:n.error,actions:(0,Z.jsx)(a,{variant:`outlined`,onClick:e.reset,children:`Try Again`})}),(0,Z.jsx)(re,{open:e.confirmOpen,title:Er(t),message:`Your data will be copied to the new environment. The current assistant will remain available until you confirm the new one works.`,confirmLabel:`Teleport`,onConfirm:e.confirm,onCancel:e.cancelConfirm})]}):null}function fi(){let{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:s}=qt(),l=J.use.multiPlatformAssistant(),u=J.use.teleport(),d=J.use.accountMfa(),f=ht.use.settingsSleepPolicy(),p=Te(),m=c(),h=Lt(),g=Lt({platformHostedOnly:!0}),_=Ft(),v=kt({assistantId:e?.id??null,enabled:g===`full`&&_}),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(!1),[C,w]=o();(0,X.useEffect)(()=>{if(C.get(`preferences`)!==`open`)return;let e=new URLSearchParams(C);e.delete(`preferences`),w(e,{replace:!0}),S(!0)},[C,w]);let T=e?.is_local&&!me()?null:e,E=pe(),D=me()&&!!e&&!!E&&le(E),O=D,k=D&&!ue(),A=g===`full`&&!!T||k&&!!e;(0,X.useEffect)(()=>{!e||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[e]);let j=t?.version??e?.current_release_version??null,M=(h===`full`||O)&&!!T||h===`disabled`&&!O,N=g!==`gated`;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[v.status&&v.mode!==`inactive`&&(0,Z.jsx)(Vt,{status:v.status,mode:v.mode,isAcknowledging:v.isAcknowledging,acknowledgeError:v.acknowledgeError?.message??null,onAcknowledge:()=>void v.acknowledge(),onReviewWorkspaceData:()=>void m(`${q.workspace}?sort=size`),onUpgradeStorage:g===`full`?()=>void m(`${q.settings.billing}?adjust_plan=1`):null}),(0,Z.jsxs)(fn,{assistant:_?T:null,showHandles:p&&h===`full`,children:[(0,Z.jsx)(lr,{}),d&&h!==`gated`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Two-Factor Authentication`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Require a code from an authenticator app when you sign in.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:h===`disabled`?(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to manage two-factor authentication.`}):(0,Z.jsx)(br,{})})]})]})]}),(0,Z.jsx)(Y,{title:`Version`,subtitle:`Manage your assistant's software version and updates.`,accessory:g===`full`&&T?(0,Z.jsx)(a,{variant:`outlined`,onClick:()=>b(!0),children:`Update Window`}):void 0,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g===`full`&&T&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Sn,{assistantId:T.id,currentVersion:j,releaseChannel:T.release_channel,onUpgradeComplete:()=>{i()}}),(0,Z.jsx)(Yn,{assistantId:T.id,onComplete:()=>{i()}})]}),k&&e&&(0,Z.jsx)(Cn,{assistantId:e.id,currentVersion:j,onUpgradeComplete:()=>{i()}}),!A&&e&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Z.jsx)(Jt,{version:j,loading:n&&!e.current_release_version,assistantId:e.id??null})]}),g===`disabled`&&!k&&(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to manage software updates.`})]})}),g===`full`&&T&&(0,Z.jsx)(gr,{assistantId:T.id,open:y,onClose:()=>b(!1)}),g===`full`&&e&&(0,Z.jsx)(tr,{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:s}),g===`disabled`&&(0,Z.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to manage compute resources.`})}),(0,Z.jsx)(Y,{title:`Preferences`,subtitle:`Customize appearance, shortcuts, and how Vellum behaves on this device.`,accessory:(0,Z.jsx)(a,{variant:`outlined`,onClick:()=>S(!0),children:`Customize`})}),(0,Z.jsx)(Un,{open:x,onClose:()=>S(!1)}),u&&G()&&(0,Z.jsx)(di,{}),(0,Z.jsx)(En,{}),g===`full`&&T&&f&&(0,Z.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Z.jsx)(vn,{assistantId:T.id})}),g===`disabled`&&f&&(0,Z.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to manage sleep policy.`})}),l&&(0,Z.jsx)(hn,{}),(M||N)&&(0,Z.jsx)(Y,{variant:`danger`,title:`Danger Zone`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[M&&(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Retire Assistant`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently retire this assistant and delete all associated data.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:(h===`full`||O)&&T?(0,Z.jsx)(nr,{assistantId:T.id}):(0,Z.jsx)(jt,{children:`Log in to the Vellum platform to retire this assistant.`})})]}),M&&N&&(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Z.jsx)(wn,{})]})})]})}export{fi as GeneralPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./capture-error-BGD3-GQf.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-BQVYX8n_.js";import{m as a,u as o}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./jsx-runtime-CVSDxk6A.js";import{t as l}from"./progress-bar-Bqv7D4mZ.js";import{S as u,_ as ee,b as te,c as d,k as ne,p as f,rt as re,v as ie}from"./local-mode-hyYI6_OH.js";import{t as p}from"./is-electron-DBOtwp5h.js";import{n as m}from"./resolved-assistants-store-DdnJoLGS.js";import{r as ae}from"./api-errors-CDe82ZvY.js";import{E as h,I as oe,L as se,N as g,O as _,R as v,k as ce,n as y,z as le}from"./auth-store-B6EXnaee.js";import{a as ue,o as de,r as b}from"./api-BBMl4mW3.js";import{u as fe}from"./native-biometric-gWkPFBiw.js";import{c as x}from"./routes-XPLb07Av.js";import{m as pe,o as me}from"./prefs-wApndUEh.js";import{r as S,t as C}from"./build-state-DR-w7k-Q.js";import{t as w}from"./avatar-bundled-components--1Wyhs4r.js";import{t as T}from"./avatar-svg-compositor-CnDf9Ibf.js";import{Mr as E,Or as D,jr as O,vn as k}from"./index-CmaRQR9x.js";import{t as he}from"./provider-key-BGsg7FL-.js";var A=e(r(),1);async function ge(e,t,r){try{await O(e)||await E(e,t),r.invalidateQueries({queryKey:D(e)})}catch(e){n(e,{context:`onboarding_avatar_sync`})}}function j(e){let t=e=>e[Math.floor(Math.random()*e.length)];return{bodyShape:t(e.bodyShapes).id,eyeStyle:t(e.eyeStyles).id,color:t(e.colors).id}}var M=c(),N=3e3,_e=800,P=3e5,F=null,I=null,L=null;function R(){F=null,I=null,L=null}var ve={initializing:0,provisioning:.33,connecting:.66,ready:1},z=1500,ye={initializing:`Getting things ready…`,provisioning:`Setting up your assistant…`,connecting:`Connecting to your assistant…`,ready:`Ready`};function be(e,t,n){if(e>=t)return t;let r=1-(1-Math.min(1,n/z))**3;return e+(t-e)*r}function xe(){let e=S(C(),{kind:`hatch-gate`});return e.action===`redirect`?{kind:`redirect`,to:e.to}:e.action===`wait`?{kind:`wait`}:{kind:`proceed`}}function B(){let e=o(),r=s(),[c]=a(),S=c.get(`hosting`),C=c.get(`fail`),E=p(),D=f()&&S!==null&&S!==`vellum-cloud`,O=y.use.sessionStatus(),z=D?g(O):O,[B]=(0,A.useState)(()=>L??=j(w)),V=(0,A.useMemo)(()=>{let e=T(w,B.bodyShape,B.eyeStyle,B.color,320);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`},[B]),[H,U]=(0,A.useState)(`initializing`),[W,G]=(0,A.useState)(null),[Se,K]=(0,A.useState)(!1),[Ce,we]=(0,A.useState)(0),[Te,q]=(0,A.useState)(0),[Ee,J]=(0,A.useState)(0),Y=(0,A.useRef)(H),X=(0,A.useRef)(0),Z=(0,A.useRef)(0),Q=(0,A.useRef)(0),$=(0,A.useCallback)(e=>{X.current=Q.current,Z.current=Date.now(),Y.current=e,U(e),J(e=>e+1)},[]);return(0,A.useEffect)(()=>{if(C!==null){G(`Simulated hatch failure (developer menu → Replay Hatch Failure).`);return}let i=xe();if(i.kind===`redirect`){e(i.to,{replace:!0});return}if(i.kind===`wait`)return;K(!1);let a=!1,o=null,s=null,c=null,l=Date.now(),p,g=!1,w=!1,T=me(),E=t=>{try{pe(``)}catch(e){n(e,{context:`onboarding_mark_completed`})}q(1),Q.current=1,X.current=1,U(`ready`),Y.current=`ready`,s=setTimeout(()=>{a||(R(),(async()=>{if(await ce.checkAssistant(),!a){if(fe()){ce.markExpectingFirstMessage(),e(`${x.assistant}?onboarding=1`,{replace:!0});return}if(D){let n=new URLSearchParams;S&&n.set(`hosting`,S),t&&n.set(`assistant`,t);let r=n.toString();e(`${x.onboarding.research}${r?`?${r}`:``}`,{replace:!0});return}e(x.onboarding.prechat,{replace:!0})}})())},_e)},O=e=>ge(e,B,r),k=async()=>{if($(`provisioning`),!D){try{let e=await b(),t=v(e);if(!a&&e.ok&&t.kind===`active`){f()&&u({assistantId:e.data.id,name:e.data.name,cloud:`vellum`,runtimeUrl:d(),hatchedAt:new Date().toISOString(),organizationId:h.getState().currentOrganizationId??void 0}),E();return}t.kind===`auto_hatch`&&(w=!0)}catch{}if(a)return}if(D){try{F||=ne(void 0,S===`docker`?`docker`:void 0);let e=await F;if(a)return;if(!e.ok){R(),G(e.error??`Failed to hatch local assistant.`);return}await ee(),e.assistantId&&_(e.assistantId),$(`connecting`);let t=!1;for(;!a&&!t;){if(await te()){re(),await ie(),t=!0;break}if(Date.now()-l>=P){R(),G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{c=setTimeout(e,N)}),c=null}if(a)return;if(e.assistantId)try{await he(e.assistantId)}catch(e){n(e,{context:`onboarding_apply_provider_key`})}e.assistantId&&await y.getState().connectLocalAssistant(e.assistantId),e.assistantId&&(m.getState().upsertFromApi({id:e.assistantId,name:e.assistantId,status:`active`,is_local:!0,created:new Date().toISOString()}),_(e.assistantId),O(e.assistantId)),E(e.assistantId)}catch{if(R(),a)return;G(`Failed to hatch local assistant. Check CLI logs for details.`)}return}try{I||=de(T?{version:T}:void 0);let e=await I;if(I=null,a)return;if(e.ok&&(p=e.data.id),g=e.ok&&e.status===201,!e.ok){if(t(`Onboarding hatch request failed`,{level:`warning`,extra:{status:e.status,error:e.error}}),se(e.status,e.error)){G(oe),K(!0);return}if(!le(e.status)){G(ae(e.error,void 0,`Failed to start your assistant. Please try again.`));return}}}catch(e){if(I=null,n(e,{context:`onboarding_hatch_assistant`}),a)return}A(0)},A=e=>{a||(o=setTimeout(j,e))},j=async()=>{if(!a){if(Date.now()-l>=P){t(`Onboarding hatch wait exceeded timeout`,{level:`warning`,extra:{maxWaitMs:P}}),G(`Your assistant is taking longer than expected. Please try again.`);return}try{let e=await b(p);if(a||p&&!e.ok&&e.status===404&&(p=void 0,e=await b(),a))return;let t=v(e);if(t.kind===`active`){if(e.ok){let t=e.data.id;for(m.getState().upsertFromApi(e.data),_(t),(g||w)&&O(t),f()&&u({assistantId:t,name:e.data.name,cloud:`vellum`,runtimeUrl:d(),hatchedAt:new Date().toISOString(),organizationId:h.getState().currentOrganizationId??void 0}),$(`connecting`);!a;){try{if((await ue(t)).ok)break}catch{}if(Date.now()-l>=P){G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{o=setTimeout(e,N)}),o=null}if(a)return}E();return}if(t.kind===`error`){G(t.message);return}t.kind!==`auto_hatch`&&Y.current===`provisioning`&&$(`connecting`),A(N)}catch(e){if(n(e,{context:`onboarding_poll_assistant`}),a)return;A(N)}}};return k(),()=>{a=!0,o&&clearTimeout(o),s&&clearTimeout(s),c&&clearTimeout(c)}},[Ce,C,B,z,e,r,$,D]),(0,A.useEffect)(()=>{Z.current===0&&(Z.current=Date.now());let e,t=()=>{let n=Date.now()-Z.current,r=ve[Y.current],i=be(X.current,r,n);Q.current=i,q(i),r-i>1e-6&&(e=requestAnimationFrame(t))};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[Ee]),W?(0,M.jsx)(k,{children:(0,M.jsxs)(`div`,{role:`alert`,className:`mx-auto flex w-full max-w-xl flex-col items-center ${E?`min-h-full px-8 pt-21 pb-28 electron-prechat-type`:`min-h-screen justify-center px-6 pb-40`} text-center text-[var(--content-default)]`,children:[(0,M.jsx)(`h1`,{className:E?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:`Something went wrong`}),(0,M.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${E?`mt-3.5`:`mt-4`}`,children:W}),Se&&(0,M.jsxs)(`div`,{className:`mt-6 flex w-full max-w-sm flex-col items-center gap-3`,children:[(0,M.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Get started today with a local assistant`}),(0,M.jsx)(i,{asChild:!0,variant:`primary`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,children:(0,M.jsx)(`a`,{href:`${window.location.origin}/download`,children:`Download the macOS app`})})]}),(0,M.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${E?`my-auto py-8`:`my-16`} onboarding-avatar-failed`}),(0,M.jsxs)(`div`,{className:`flex w-full flex-col ${E?`gap-2.5 max-w-[280px]`:`gap-2 max-w-sm`}`,children:[(0,M.jsx)(i,{variant:`primary`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,onClick:()=>{X.current=0,Z.current=Date.now(),Y.current=`initializing`,Q.current=0,U(`initializing`),q(0),J(e=>e+1),G(null),K(!1),we(e=>e+1)},children:`Try again`}),(0,M.jsx)(i,{variant:`outlined`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,onClick:()=>void e(D?x.onboarding.hosting:x.onboarding.privacy,{replace:!0}),children:`Back`})]})]})}):(0,M.jsx)(k,{children:(0,M.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${E?`min-h-full px-8 pt-21 pb-28 electron-prechat-type`:`min-h-screen justify-center px-6 pb-40`} text-center text-[var(--content-default)]`,children:[(0,M.jsx)(`h1`,{className:E?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:H===`ready`?`Your assistant is ready!`:`Waking up…`}),H!==`ready`&&(0,M.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${E?`mt-3.5`:`mt-4`}`,children:`Hang tight — your assistant will have a few questions for you once it's up.`}),(0,M.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${E?`my-auto py-8`:`my-16`} ${H===`ready`?`onboarding-avatar-awake`:`onboarding-avatar-pulse`}`}),(0,M.jsx)(l,{value:Te,height:6,className:`w-full ${E?`max-w-[200px]`:`max-w-sm`}`,"aria-label":`Assistant startup progress`}),(0,M.jsx)(`p`,{className:`text-[var(--content-tertiary)] ${E?`mt-4 text-label-small-default`:`mt-3 text-body-small-default`}`,children:ye[H]})]})})}export{B as HatchingScreen};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./capture-error-BGD3-GQf.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-BQVYX8n_.js";import{m as a,u as o}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./jsx-runtime-CVSDxk6A.js";import{t as l}from"./progress-bar-Bqv7D4mZ.js";import{S as u,_ as ee,b as te,c as d,k as ne,p as f,rt as re,v as ie}from"./local-mode-hyYI6_OH.js";import{t as p}from"./is-electron-DBOtwp5h.js";import{n as m}from"./resolved-assistants-store-DdnJoLGS.js";import{r as ae}from"./api-errors-CDe82ZvY.js";import{E as h,I as oe,L as se,N as g,O as _,R as v,k as ce,n as y,z as le}from"./auth-store-B6EXnaee.js";import{a as ue,o as de,r as b}from"./api-BBMl4mW3.js";import{u as fe}from"./native-biometric-gWkPFBiw.js";import{c as x}from"./routes-XPLb07Av.js";import{m as pe,o as me}from"./prefs-wApndUEh.js";import{r as S,t as C}from"./build-state-DR-w7k-Q.js";import{t as w}from"./avatar-bundled-components--1Wyhs4r.js";import{t as T}from"./avatar-svg-compositor-CnDf9Ibf.js";import{Mr as E,Or as D,jr as O,vn as k}from"./index-CgcZXB4g.js";import{t as he}from"./provider-key-BGsg7FL-.js";var A=e(r(),1);async function ge(e,t,r){try{await O(e)||await E(e,t),r.invalidateQueries({queryKey:D(e)})}catch(e){n(e,{context:`onboarding_avatar_sync`})}}function j(e){let t=e=>e[Math.floor(Math.random()*e.length)];return{bodyShape:t(e.bodyShapes).id,eyeStyle:t(e.eyeStyles).id,color:t(e.colors).id}}var M=c(),N=3e3,_e=800,P=3e5,F=null,I=null,L=null;function R(){F=null,I=null,L=null}var ve={initializing:0,provisioning:.33,connecting:.66,ready:1},z=1500,ye={initializing:`Getting things ready…`,provisioning:`Setting up your assistant…`,connecting:`Connecting to your assistant…`,ready:`Ready`};function be(e,t,n){if(e>=t)return t;let r=1-(1-Math.min(1,n/z))**3;return e+(t-e)*r}function xe(){let e=S(C(),{kind:`hatch-gate`});return e.action===`redirect`?{kind:`redirect`,to:e.to}:e.action===`wait`?{kind:`wait`}:{kind:`proceed`}}function B(){let e=o(),r=s(),[c]=a(),S=c.get(`hosting`),C=c.get(`fail`),E=p(),D=f()&&S!==null&&S!==`vellum-cloud`,O=y.use.sessionStatus(),z=D?g(O):O,[B]=(0,A.useState)(()=>L??=j(w)),V=(0,A.useMemo)(()=>{let e=T(w,B.bodyShape,B.eyeStyle,B.color,320);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`},[B]),[H,U]=(0,A.useState)(`initializing`),[W,G]=(0,A.useState)(null),[Se,K]=(0,A.useState)(!1),[Ce,we]=(0,A.useState)(0),[Te,q]=(0,A.useState)(0),[Ee,J]=(0,A.useState)(0),Y=(0,A.useRef)(H),X=(0,A.useRef)(0),Z=(0,A.useRef)(0),Q=(0,A.useRef)(0),$=(0,A.useCallback)(e=>{X.current=Q.current,Z.current=Date.now(),Y.current=e,U(e),J(e=>e+1)},[]);return(0,A.useEffect)(()=>{if(C!==null){G(`Simulated hatch failure (developer menu → Replay Hatch Failure).`);return}let i=xe();if(i.kind===`redirect`){e(i.to,{replace:!0});return}if(i.kind===`wait`)return;K(!1);let a=!1,o=null,s=null,c=null,l=Date.now(),p,g=!1,w=!1,T=me(),E=t=>{try{pe(``)}catch(e){n(e,{context:`onboarding_mark_completed`})}q(1),Q.current=1,X.current=1,U(`ready`),Y.current=`ready`,s=setTimeout(()=>{a||(R(),(async()=>{if(await ce.checkAssistant(),!a){if(fe()){ce.markExpectingFirstMessage(),e(`${x.assistant}?onboarding=1`,{replace:!0});return}if(D){let n=new URLSearchParams;S&&n.set(`hosting`,S),t&&n.set(`assistant`,t);let r=n.toString();e(`${x.onboarding.research}${r?`?${r}`:``}`,{replace:!0});return}e(x.onboarding.prechat,{replace:!0})}})())},_e)},O=e=>ge(e,B,r),k=async()=>{if($(`provisioning`),!D){try{let e=await b(),t=v(e);if(!a&&e.ok&&t.kind===`active`){f()&&u({assistantId:e.data.id,name:e.data.name,cloud:`vellum`,runtimeUrl:d(),hatchedAt:new Date().toISOString(),organizationId:h.getState().currentOrganizationId??void 0}),E();return}t.kind===`auto_hatch`&&(w=!0)}catch{}if(a)return}if(D){try{F||=ne(void 0,S===`docker`?`docker`:void 0);let e=await F;if(a)return;if(!e.ok){R(),G(e.error??`Failed to hatch local assistant.`);return}await ee(),e.assistantId&&_(e.assistantId),$(`connecting`);let t=!1;for(;!a&&!t;){if(await te()){re(),await ie(),t=!0;break}if(Date.now()-l>=P){R(),G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{c=setTimeout(e,N)}),c=null}if(a)return;if(e.assistantId)try{await he(e.assistantId)}catch(e){n(e,{context:`onboarding_apply_provider_key`})}e.assistantId&&await y.getState().connectLocalAssistant(e.assistantId),e.assistantId&&(m.getState().upsertFromApi({id:e.assistantId,name:e.assistantId,status:`active`,is_local:!0,created:new Date().toISOString()}),_(e.assistantId),O(e.assistantId)),E(e.assistantId)}catch{if(R(),a)return;G(`Failed to hatch local assistant. Check CLI logs for details.`)}return}try{I||=de(T?{version:T}:void 0);let e=await I;if(I=null,a)return;if(e.ok&&(p=e.data.id),g=e.ok&&e.status===201,!e.ok){if(t(`Onboarding hatch request failed`,{level:`warning`,extra:{status:e.status,error:e.error}}),se(e.status,e.error)){G(oe),K(!0);return}if(!le(e.status)){G(ae(e.error,void 0,`Failed to start your assistant. Please try again.`));return}}}catch(e){if(I=null,n(e,{context:`onboarding_hatch_assistant`}),a)return}A(0)},A=e=>{a||(o=setTimeout(j,e))},j=async()=>{if(!a){if(Date.now()-l>=P){t(`Onboarding hatch wait exceeded timeout`,{level:`warning`,extra:{maxWaitMs:P}}),G(`Your assistant is taking longer than expected. Please try again.`);return}try{let e=await b(p);if(a||p&&!e.ok&&e.status===404&&(p=void 0,e=await b(),a))return;let t=v(e);if(t.kind===`active`){if(e.ok){let t=e.data.id;for(m.getState().upsertFromApi(e.data),_(t),(g||w)&&O(t),f()&&u({assistantId:t,name:e.data.name,cloud:`vellum`,runtimeUrl:d(),hatchedAt:new Date().toISOString(),organizationId:h.getState().currentOrganizationId??void 0}),$(`connecting`);!a;){try{if((await ue(t)).ok)break}catch{}if(Date.now()-l>=P){G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{o=setTimeout(e,N)}),o=null}if(a)return}E();return}if(t.kind===`error`){G(t.message);return}t.kind!==`auto_hatch`&&Y.current===`provisioning`&&$(`connecting`),A(N)}catch(e){if(n(e,{context:`onboarding_poll_assistant`}),a)return;A(N)}}};return k(),()=>{a=!0,o&&clearTimeout(o),s&&clearTimeout(s),c&&clearTimeout(c)}},[Ce,C,B,z,e,r,$,D]),(0,A.useEffect)(()=>{Z.current===0&&(Z.current=Date.now());let e,t=()=>{let n=Date.now()-Z.current,r=ve[Y.current],i=be(X.current,r,n);Q.current=i,q(i),r-i>1e-6&&(e=requestAnimationFrame(t))};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[Ee]),W?(0,M.jsx)(k,{children:(0,M.jsxs)(`div`,{role:`alert`,className:`mx-auto flex w-full max-w-xl flex-col items-center ${E?`min-h-full px-8 pt-21 pb-28 electron-prechat-type`:`min-h-screen justify-center px-6 pb-40`} text-center text-[var(--content-default)]`,children:[(0,M.jsx)(`h1`,{className:E?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:`Something went wrong`}),(0,M.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${E?`mt-3.5`:`mt-4`}`,children:W}),Se&&(0,M.jsxs)(`div`,{className:`mt-6 flex w-full max-w-sm flex-col items-center gap-3`,children:[(0,M.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Get started today with a local assistant`}),(0,M.jsx)(i,{asChild:!0,variant:`primary`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,children:(0,M.jsx)(`a`,{href:`${window.location.origin}/download`,children:`Download the macOS app`})})]}),(0,M.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${E?`my-auto py-8`:`my-16`} onboarding-avatar-failed`}),(0,M.jsxs)(`div`,{className:`flex w-full flex-col ${E?`gap-2.5 max-w-[280px]`:`gap-2 max-w-sm`}`,children:[(0,M.jsx)(i,{variant:`primary`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,onClick:()=>{X.current=0,Z.current=Date.now(),Y.current=`initializing`,Q.current=0,U(`initializing`),q(0),J(e=>e+1),G(null),K(!1),we(e=>e+1)},children:`Try again`}),(0,M.jsx)(i,{variant:`outlined`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,onClick:()=>void e(D?x.onboarding.hosting:x.onboarding.privacy,{replace:!0}),children:`Back`})]})]})}):(0,M.jsx)(k,{children:(0,M.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${E?`min-h-full px-8 pt-21 pb-28 electron-prechat-type`:`min-h-screen justify-center px-6 pb-40`} text-center text-[var(--content-default)]`,children:[(0,M.jsx)(`h1`,{className:E?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:H===`ready`?`Your assistant is ready!`:`Waking up…`}),H!==`ready`&&(0,M.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${E?`mt-3.5`:`mt-4`}`,children:`Hang tight — your assistant will have a few questions for you once it's up.`}),(0,M.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${E?`my-auto py-8`:`my-16`} ${H===`ready`?`onboarding-avatar-awake`:`onboarding-avatar-pulse`}`}),(0,M.jsx)(l,{value:Te,height:6,className:`w-full ${E?`max-w-[200px]`:`max-w-sm`}`,"aria-label":`Assistant startup progress`}),(0,M.jsx)(`p`,{className:`text-[var(--content-tertiary)] ${E?`mt-4 text-label-small-default`:`mt-3 text-body-small-default`}`,children:ye[H]})]})})}export{B as HatchingScreen};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{P as n,t as r}from"./button-BQVYX8n_.js";import{l as i,u as a}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as o}from"./QueryClientProvider-DKhXIxGb.js";import{t as s}from"./useQuery-B45lW1Kk.js";import{t as c}from"./jsx-runtime-CVSDxk6A.js";import{t as l}from"./typography-Cqi8q9o7.js";import{t as u}from"./arrow-left-C2re-gYj.js";import{t as d}from"./bell-BbESwsZk.js";import{t as f}from"./calendar-D0labpMU.js";import{t as p}from"./chevron-right-jRymmL7S.js";import{t as m}from"./x-CswtfvgS.js";import{d as h,h as g,i as _}from"./src-CDdn26Yb.js";import{t as v}from"./tag-B6WeUtBW.js";import{R as y,z as b}from"./react-query.gen-BQH0QRfT.js";import{c as x}from"./routes-XPLb07Av.js";import{Dr as S,Gn as C,Nt as w,Ui as T,Un as E,Wn as D,Yn as O,_ as ee,a as k,c as A,d as j,f as M,g as N,h as P,ha as F,i as I,l as L,ma as R,n as te,o as ne,p as z,r as re,s as ie,ta as ae,u as B,zr as V}from"./index-CmaRQR9x.js";import{t as H}from"./use-active-assistant-id-9rGx8kT9.js";import{t as U}from"./page-shell-DeTaZ_s4.js";import{l as W,s as G,t as K,u as q}from"./page-empty-state-DbCk3v6f.js";var J=e(t(),1),Y=c(),oe={p:({children:e})=>(0,Y.jsx)(`p`,{className:`mb-2 text-body-medium-default last:mb-0`,style:{color:`var(--content-secondary)`},children:e}),strong:({children:e})=>(0,Y.jsx)(`strong`,{style:{color:`var(--content-default)`},children:e}),em:({children:e})=>(0,Y.jsx)(`em`,{style:{color:`var(--content-default)`},children:e}),a:({href:e,children:t})=>(0,Y.jsx)(`a`,{href:e,className:`underline`,style:{color:`var(--content-link)`},target:`_blank`,rel:`noopener noreferrer`,onClick:t=>w(t,e),children:t}),ul:({children:e})=>(0,Y.jsx)(`ul`,{className:`mb-2 list-disc pl-5 text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),ol:({children:e})=>(0,Y.jsx)(`ol`,{className:`mb-2 list-decimal pl-5 text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),li:({children:e})=>(0,Y.jsx)(`li`,{className:`mb-0.5`,children:e}),code:({children:e})=>(0,Y.jsx)(`code`,{className:`rounded px-1 py-0.5 font-mono text-[0.85em]`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 8%, transparent)`,color:`var(--content-default)`},children:e}),pre:({children:e})=>(0,Y.jsx)(`pre`,{className:`mb-2 overflow-x-auto rounded p-3 font-mono text-[0.85em]`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 6%, transparent)`,color:`var(--content-default)`},children:e}),h1:({children:e})=>(0,Y.jsx)(`h1`,{className:`mb-2 text-title-medium first:mt-0`,style:{color:`var(--content-default)`},children:e}),h2:({children:e})=>(0,Y.jsx)(`h2`,{className:`mb-2 text-title-small first:mt-0`,style:{color:`var(--content-default)`},children:e}),h3:({children:e})=>(0,Y.jsx)(`h3`,{className:`mb-1 text-body-medium-default first:mt-0`,style:{color:`var(--content-default)`},children:e}),blockquote:({children:e})=>(0,Y.jsx)(`blockquote`,{className:`mb-2 border-l-2 pl-3 text-body-medium-default`,style:{borderColor:`var(--border-base)`,color:`var(--content-tertiary)`},children:e}),table:({children:e})=>(0,Y.jsx)(`div`,{className:`mb-2 overflow-x-auto`,children:(0,Y.jsx)(`table`,{className:`w-full border-collapse text-body-small-default`,style:{color:`var(--content-secondary)`},children:e})}),thead:({children:e})=>(0,Y.jsx)(`thead`,{style:{backgroundColor:`var(--surface-lift)`},children:e}),tbody:({children:e})=>(0,Y.jsx)(`tbody`,{children:e}),tr:({children:e})=>(0,Y.jsx)(`tr`,{style:{borderBottom:`1px solid var(--border-base)`},children:e}),th:({children:e})=>(0,Y.jsx)(`th`,{className:`px-2 py-1.5 text-left font-semibold`,style:{color:`var(--content-default)`},children:e}),td:({children:e})=>(0,Y.jsx)(`td`,{className:`px-2 py-1.5 align-top`,children:e})};function se({content:e,className:t}){return(0,Y.jsx)(`div`,{className:n(`text-body-medium-default`,t),children:(0,Y.jsx)(g,{remarkPlugins:[h],components:oe,children:e})})}function X({item:e}){return(0,Y.jsx)(se,{content:e.summary})}function ce(e){switch(e){case`revoked`:case`expired`:return`var(--system-negative-strong)`;case`missing_scopes`:case`missing_token`:case`ping_failed`:return`var(--system-mid-strong)`;default:return`var(--content-disabled)`}}function le(e){return e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Z({item:e}){let t=e.metadata,n=t?.provider;if(!n)return(0,Y.jsx)(l,{variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:e.title??e.summary});let r=t?.accountInfo??null,i=t?.status??`unreachable`,a=t?.details??``,o=Array.isArray(t?.missingScopes)?t.missingScopes:[];return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-md)]`,children:[(0,Y.jsx)(l,{variant:`title-small`,as:`h3`,children:n}),r?(0,Y.jsx)(l,{variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:r}):null,(0,Y.jsxs)(`div`,{className:`flex items-center gap-[var(--app-spacing-sm)]`,children:[(0,Y.jsx)(`span`,{className:`inline-block shrink-0 rounded-full`,style:{width:8,height:8,backgroundColor:ce(i)},"aria-hidden":`true`}),(0,Y.jsx)(l,{variant:`body-medium-default`,className:`text-[var(--content-default)]`,children:le(i)})]}),a?(0,Y.jsx)(l,{variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:a}):null,o.length>0?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)]`,children:[(0,Y.jsx)(l,{variant:`body-small-emphasised`,className:`text-[var(--content-secondary)]`,children:`Missing scopes`}),(0,Y.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-[var(--app-spacing-xxs)] pl-[var(--app-spacing-lg)]`,children:o.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(l,{variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:e})},e))})]}):null]})}function ue(e){return e&&M[e]?M[e]:M.system}function de(e){return e.title?e.title:e.category?e.category.charAt(0).toUpperCase()+e.category.slice(1):`Notification`}function fe({item:e,isMobile:t,validConversationIds:n,onClose:i,onGoToThread:a,onUpdateStatus:o,onDismiss:s,onViewSchedule:c}){if(!e)return null;let d=e.detailPanel?.kind,p=de(e),h=ue(e.category),g=h.icon,_=e.status===`new`,y=e.status===`dismissed`,b=!!e.conversationId&&n.has(e.conversationId);return t?(0,Y.jsxs)(`div`,{className:`flex h-full flex-col bg-[var(--surface-overlay)]`,children:[(0,Y.jsxs)(`div`,{className:`relative flex shrink-0 items-center px-3 py-2`,children:[(0,Y.jsx)(r,{variant:`ghost`,iconOnly:(0,Y.jsx)(u,{}),onClick:i,"aria-label":`Back`,tooltip:`Back`}),(0,Y.jsx)(l,{variant:`body-medium-default`,className:`pointer-events-none absolute inset-x-0 text-center text-[var(--content-secondary)]`,children:`Details`}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Y.jsx)(r,{variant:`ghost`,iconOnly:_?(0,Y.jsx)(F,{}):(0,Y.jsx)(R,{}),onClick:()=>o(e.id,_?`seen`:`new`),"aria-label":_?`Mark as read`:`Mark as unread`,tooltip:_?`Mark as read`:`Mark as unread`}),y?(0,Y.jsx)(r,{variant:`ghost`,iconOnly:(0,Y.jsx)(ae,{}),onClick:()=>o(e.id,`seen`),"aria-label":`Restore`,tooltip:`Restore`}):(0,Y.jsx)(r,{variant:`ghost`,iconOnly:(0,Y.jsx)(T,{}),onClick:()=>s(e.id),"aria-label":`Dismiss`,tooltip:`Dismiss`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center justify-center rounded-full`,style:{width:40,height:40,backgroundColor:h.weak},"aria-hidden":`true`,children:(0,Y.jsx)(g,{width:18,height:18,style:{color:h.strong}})}),(0,Y.jsx)(l,{variant:`title-small`,className:`min-w-0 text-[var(--content-default)]`,children:p}),(0,Y.jsx)(v,{tone:`neutral`,className:`shrink-0`,title:P(e.timestamp),children:N(e.timestamp)})]}),(0,Y.jsx)(`div`,{className:`mx-4 border-b border-[var(--border-disabled)]`}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:d===`toolPermission`?(0,Y.jsx)(Z,{item:e}):(0,Y.jsx)(X,{item:e})}),b||c?(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 px-4 pb-4 pt-2`,children:[c?(0,Y.jsx)(r,{variant:`outlined`,fullWidth:!0,leftIcon:(0,Y.jsx)(f,{className:`size-4`}),onClick:c,children:`View schedule`}):null,b?(0,Y.jsx)(r,{variant:`primary`,fullWidth:!0,onClick:()=>a(e.conversationId),children:`Go to Conversation`}):null]}):null]}):(0,Y.jsxs)(`div`,{className:`flex h-full flex-col rounded-[var(--radius-xl)] border border-[var(--border-base)] bg-[var(--surface-overlay)]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-[var(--app-spacing-sm)] border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center justify-center rounded-full`,style:{width:28,height:28,backgroundColor:h.weak},"aria-hidden":`true`,children:(0,Y.jsx)(g,{width:14,height:14,style:{color:h.strong}})}),(0,Y.jsx)(l,{variant:`title-small`,className:`min-w-0 flex-1 truncate text-[var(--content-default)]`,children:p}),b?(0,Y.jsx)(r,{variant:`outlined`,onClick:()=>a(e.conversationId),children:`Go to Convo`}):null,(0,Y.jsx)(r,{variant:`outlined`,iconOnly:(0,Y.jsx)(m,{}),onClick:i,"aria-label":`Close detail panel`,tooltip:`Close`})]}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-[var(--app-spacing-lg)]`,children:[d===`toolPermission`?(0,Y.jsx)(Z,{item:e}):(0,Y.jsx)(X,{item:e}),(0,Y.jsx)(`div`,{className:`mt-[var(--app-spacing-md)]`,children:(0,Y.jsx)(v,{tone:`neutral`,title:P(e.timestamp),children:N(e.timestamp)})})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-[var(--app-spacing-sm)] border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,Y.jsx)(`div`,{children:c?(0,Y.jsx)(r,{variant:`outlined`,leftIcon:(0,Y.jsx)(f,{className:`size-4`}),onClick:c,children:`View schedule`}):null}),(0,Y.jsx)(`div`,{className:`flex items-center gap-[var(--app-spacing-sm)]`,children:y?(0,Y.jsx)(r,{variant:`primary`,onClick:()=>o(e.id,`seen`),children:`Restore`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{variant:`outlined`,onClick:()=>o(e.id,_?`seen`:`new`),children:_?`Mark as read`:`Mark as unread`}),(0,Y.jsx)(r,{variant:`primary`,onClick:()=>s(e.id),children:`Dismiss`})]})})]})]})}var pe={today:`Today`,yesterday:`Yesterday`,older:`Older`},me=10080*60*1e3;function Q(e,t){return e.status===`new`||e.status===`dismissed`?!1:t-new Date(e.createdAt).getTime()>me}function he({items:e,selectedItemId:t,validConversationIds:n,onSelectItem:r,onDismissItem:i,onRestoreItem:a,onToggleRead:o,onGoToThread:s,archivedOpen:c,onArchivedOpenChange:u,dismissedOpen:f,onDismissedOpenChange:m}){let[h,g]=(0,J.useState)(null),[v]=(0,J.useState)(()=>Date.now()),y=re(e.filter(e=>e.status!==`dismissed`)),b=y.filter(e=>!Q(e,v)),x=L(y.filter(e=>Q(e,v))),S=k(b),C=h&&S.includes(h)?h:null;h!==C&&g(C);let w=ie(L(I(b,C))),T=e.filter(e=>e.status===`dismissed`).sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-lg)]`,children:[(0,Y.jsx)(z,{categories:S,activeFilter:C,onFilterChange:g}),w.size===0?C?(0,Y.jsx)(l,{variant:`body-medium-lighter`,className:`py-[var(--app-spacing-xl)] text-center text-[var(--content-disabled)]`,children:`No items match the selected filter.`}):(0,Y.jsx)(K,{icon:d,title:`No notifications yet`,description:`Updates and activity from your assistant will appear here.`}):[...w.entries()].map(([e,a])=>(0,Y.jsxs)(`section`,{className:`flex flex-col gap-[var(--app-spacing-md)]`,children:[(0,Y.jsx)(l,{variant:`body-small-default`,as:`h3`,className:`text-[var(--content-tertiary)]`,children:pe[e]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)]`,children:a.map(e=>(0,Y.jsx)(j,{item:e,isActive:e.id===t,validConversationIds:n,onSelect:r,onDismiss:i,onToggleRead:o,onGoToThread:s},e.id))})]},e)),x.length>0&&(0,Y.jsx)(_.Root,{type:`single`,collapsible:!0,value:c?`archived-read`:``,onValueChange:e=>u?.(e===`archived-read`),children:(0,Y.jsxs)(_.Item,{value:`archived-read`,children:[(0,Y.jsxs)(_.Trigger,{className:`group gap-[var(--app-spacing-xs)] text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Y.jsx)(p,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,Y.jsxs)(`span`,{children:[`Earlier (`,x.length,`)`]})]}),(0,Y.jsx)(_.Content,{children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)] pt-[var(--app-spacing-sm)]`,children:x.map(e=>(0,Y.jsx)(j,{item:e,isActive:e.id===t,validConversationIds:n,onSelect:r,onDismiss:i,onToggleRead:o,onGoToThread:s},e.id))})})]})}),T.length>0&&(0,Y.jsx)(_.Root,{type:`single`,collapsible:!0,value:f?`dismissed`:``,onValueChange:e=>m?.(e===`dismissed`),children:(0,Y.jsxs)(_.Item,{value:`dismissed`,children:[(0,Y.jsxs)(_.Trigger,{className:`group gap-[var(--app-spacing-xs)] text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Y.jsx)(p,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,Y.jsxs)(`span`,{children:[`Dismissed (`,T.length,`)`]})]}),(0,Y.jsx)(_.Content,{children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)] pt-[var(--app-spacing-sm)]`,children:T.map(e=>(0,Y.jsx)(j,{item:e,onSelect:r,onDismiss:a,trailingAction:`restore`},e.id))})})]})})]})}function ge(){return(0,Y.jsx)(`h1`,{className:`shrink-0 text-title-large text-[var(--content-default)]`,children:`Activity`})}function $(e){let t=o(),n=(0,J.useMemo)(()=>b({path:{assistant_id:e??``}}),[e]),r=s({...y({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4}),i=(0,J.useCallback)(()=>{e&&t.invalidateQueries({queryKey:n})},[e,t,n]);return{...r,invalidate:i}}function _e(){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xl)]`,children:[(0,Y.jsx)(`div`,{className:`h-7 w-64 animate-pulse rounded-md bg-[var(--surface-lift)]`}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-sm)]`,children:Array.from({length:4},(e,t)=>(0,Y.jsx)(`div`,{className:`h-16 animate-pulse rounded-md bg-[var(--surface-lift)]`},t))})]})}function ve(e){let t=e?.metadata?.scheduleId;return typeof t==`string`&&t.length>0?t:null}function ye({assistantId:e,validConversationIds:t,onOpenConversation:n,onViewSchedule:i,initialFeedItemId:a,navigationKey:o,onInitialFeedItemConsumed:c}){let l=V(),u=B(e);$(e);let{data:d}=s(G(e)),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(!1),v=(0,J.useCallback)(e=>{e.status===`new`?(p({...e,status:`seen`}),u.updateStatus.mutate({itemId:e.id,status:`seen`})):p(e)},[u.updateStatus]),y=(0,J.useCallback)(()=>{p(null)},[]),b=(0,J.useCallback)(e=>{u.updateStatus.mutate({itemId:e,status:`dismissed`}),f?.id===e&&p(null)},[u.updateStatus,f?.id]),x=(0,J.useCallback)(e=>{u.updateStatus.mutate({itemId:e,status:`seen`}),p(t=>t?.id===e?{...t,status:`seen`}:t)},[u.updateStatus]),S=(0,J.useCallback)((e,t)=>{u.updateStatus.mutate({itemId:e,status:t}),p(n=>n?.id===e?{...n,status:t}:n)},[u.updateStatus]),C=(0,J.useCallback)(e=>{p(null),n(e)},[n]),w=u.data?.items??[],[T,E]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(!a||o===T||u.isLoading)return;E(o??null);let e=w.find(e=>e.id===a);e&&e.status!==`dismissed`&&v(e),c?.()},[a,o,T,u.isLoading,w,v,c]);let D=ne(w),O=D.filter(e=>e.status===`new`).length,k=D.length,j=ee(),M=(0,J.useCallback)(()=>{u.markAll.mutate(A(D))},[u.markAll,D]),N=(0,J.useCallback)(()=>{u.markAll.mutate(te(D)),p(null)},[u.markAll,D]),P=ve(f),F=P!=null&&(d??[]).some(e=>e.id===P),I=f?(0,Y.jsx)(fe,{item:f,isMobile:l,validConversationIds:t,onClose:y,onGoToThread:C,onUpdateStatus:S,onDismiss:b,onViewSchedule:F?()=>i(P):void 0}):null,L=(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-[var(--app-spacing-lg)] overflow-y-auto`,children:[u.isError?(0,Y.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-[var(--system-negative-weak)] bg-[var(--system-negative-weak)] px-[var(--app-spacing-lg)] py-[var(--app-spacing-md)] text-[var(--system-negative-strong)]`,children:[`Couldn't load home feed`,u.error instanceof Error?`: ${u.error.message}`:`.`]}):null,j&&(O>0||k>0)&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-[var(--app-spacing-sm)]`,children:[O>0&&(0,Y.jsx)(r,{variant:`ghost`,size:`compact`,onClick:M,disabled:u.markAll.isPending,children:`Mark all as read`}),k>0&&(0,Y.jsx)(r,{variant:`ghost`,size:`compact`,onClick:N,disabled:u.markAll.isPending,children:`Clear all`})]}),(0,Y.jsx)(he,{items:w,selectedItemId:f?.id,validConversationIds:t,onSelectItem:v,onDismissItem:b,onRestoreItem:x,onToggleRead:S,onGoToThread:C,archivedOpen:m,onArchivedOpenChange:h,dismissedOpen:g,onDismissedOpenChange:_})]}),R=I&&!l?(0,Y.jsx)(W,{storageKey:`homeDetailDrawerWidth`,detailKey:f?.id,section:L,detail:I}):L,z=u.isLoading?(0,Y.jsx)(_e,{}):(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-[var(--app-spacing-xl)]`,children:[l?null:(0,Y.jsx)(ge,{}),R]});return I&&l?(0,Y.jsx)(q,{children:I}):(0,Y.jsx)(U,{children:z})}function be(){let e=a(),t=i(),n=H(),r=t.state?.feedItemId??null,o=(0,J.useCallback)(()=>{e(t.pathname+t.search,{replace:!0})},[e,t.pathname,t.search]),s=O.use.setTopBarCenter(),c=V(),{conversations:u}=D(n),{conversations:d}=E(n,!0),{conversations:f}=C(n,!0),p=(0,J.useMemo)(()=>new Set(S(u,d,f).map(e=>e.conversationId)),[u,d,f]);return(0,J.useEffect)(()=>(s(c?(0,Y.jsx)(l,{variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:`Activity`}):null),()=>{s(null)}),[c,s]),(0,Y.jsx)(ye,{assistantId:n,validConversationIds:p,initialFeedItemId:r,navigationKey:t.key,onInitialFeedItemConsumed:o,onOpenConversation:t=>e(x.conversation(t)),onViewSchedule:t=>e(x.schedules.detail(t))})}export{be as HomePageRoute};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{P as n,t as r}from"./button-BQVYX8n_.js";import{l as i,u as a}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as o}from"./QueryClientProvider-DKhXIxGb.js";import{t as s}from"./useQuery-B45lW1Kk.js";import{t as c}from"./jsx-runtime-CVSDxk6A.js";import{t as l}from"./typography-Cqi8q9o7.js";import{t as u}from"./arrow-left-C2re-gYj.js";import{t as d}from"./bell-BbESwsZk.js";import{t as f}from"./calendar-D0labpMU.js";import{t as p}from"./chevron-right-jRymmL7S.js";import{t as m}from"./x-CswtfvgS.js";import{d as h,h as g,i as _}from"./src-CDdn26Yb.js";import{t as v}from"./tag-B6WeUtBW.js";import{R as y,z as b}from"./react-query.gen-BQH0QRfT.js";import{c as x}from"./routes-XPLb07Av.js";import{Dr as S,Gn as C,Nt as w,Ui as T,Un as E,Wn as D,Yn as O,_ as ee,a as k,c as A,d as j,f as M,g as N,h as P,ha as F,i as I,l as L,ma as R,n as te,o as ne,p as z,r as re,s as ie,ta as ae,u as B,zr as V}from"./index-CgcZXB4g.js";import{t as H}from"./use-active-assistant-id-9rGx8kT9.js";import{t as U}from"./page-shell-DeTaZ_s4.js";import{l as W,s as G,t as K,u as q}from"./page-empty-state-DbCk3v6f.js";var J=e(t(),1),Y=c(),oe={p:({children:e})=>(0,Y.jsx)(`p`,{className:`mb-2 text-body-medium-default last:mb-0`,style:{color:`var(--content-secondary)`},children:e}),strong:({children:e})=>(0,Y.jsx)(`strong`,{style:{color:`var(--content-default)`},children:e}),em:({children:e})=>(0,Y.jsx)(`em`,{style:{color:`var(--content-default)`},children:e}),a:({href:e,children:t})=>(0,Y.jsx)(`a`,{href:e,className:`underline`,style:{color:`var(--content-link)`},target:`_blank`,rel:`noopener noreferrer`,onClick:t=>w(t,e),children:t}),ul:({children:e})=>(0,Y.jsx)(`ul`,{className:`mb-2 list-disc pl-5 text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),ol:({children:e})=>(0,Y.jsx)(`ol`,{className:`mb-2 list-decimal pl-5 text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),li:({children:e})=>(0,Y.jsx)(`li`,{className:`mb-0.5`,children:e}),code:({children:e})=>(0,Y.jsx)(`code`,{className:`rounded px-1 py-0.5 font-mono text-[0.85em]`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 8%, transparent)`,color:`var(--content-default)`},children:e}),pre:({children:e})=>(0,Y.jsx)(`pre`,{className:`mb-2 overflow-x-auto rounded p-3 font-mono text-[0.85em]`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 6%, transparent)`,color:`var(--content-default)`},children:e}),h1:({children:e})=>(0,Y.jsx)(`h1`,{className:`mb-2 text-title-medium first:mt-0`,style:{color:`var(--content-default)`},children:e}),h2:({children:e})=>(0,Y.jsx)(`h2`,{className:`mb-2 text-title-small first:mt-0`,style:{color:`var(--content-default)`},children:e}),h3:({children:e})=>(0,Y.jsx)(`h3`,{className:`mb-1 text-body-medium-default first:mt-0`,style:{color:`var(--content-default)`},children:e}),blockquote:({children:e})=>(0,Y.jsx)(`blockquote`,{className:`mb-2 border-l-2 pl-3 text-body-medium-default`,style:{borderColor:`var(--border-base)`,color:`var(--content-tertiary)`},children:e}),table:({children:e})=>(0,Y.jsx)(`div`,{className:`mb-2 overflow-x-auto`,children:(0,Y.jsx)(`table`,{className:`w-full border-collapse text-body-small-default`,style:{color:`var(--content-secondary)`},children:e})}),thead:({children:e})=>(0,Y.jsx)(`thead`,{style:{backgroundColor:`var(--surface-lift)`},children:e}),tbody:({children:e})=>(0,Y.jsx)(`tbody`,{children:e}),tr:({children:e})=>(0,Y.jsx)(`tr`,{style:{borderBottom:`1px solid var(--border-base)`},children:e}),th:({children:e})=>(0,Y.jsx)(`th`,{className:`px-2 py-1.5 text-left font-semibold`,style:{color:`var(--content-default)`},children:e}),td:({children:e})=>(0,Y.jsx)(`td`,{className:`px-2 py-1.5 align-top`,children:e})};function se({content:e,className:t}){return(0,Y.jsx)(`div`,{className:n(`text-body-medium-default`,t),children:(0,Y.jsx)(g,{remarkPlugins:[h],components:oe,children:e})})}function X({item:e}){return(0,Y.jsx)(se,{content:e.summary})}function ce(e){switch(e){case`revoked`:case`expired`:return`var(--system-negative-strong)`;case`missing_scopes`:case`missing_token`:case`ping_failed`:return`var(--system-mid-strong)`;default:return`var(--content-disabled)`}}function le(e){return e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Z({item:e}){let t=e.metadata,n=t?.provider;if(!n)return(0,Y.jsx)(l,{variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:e.title??e.summary});let r=t?.accountInfo??null,i=t?.status??`unreachable`,a=t?.details??``,o=Array.isArray(t?.missingScopes)?t.missingScopes:[];return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-md)]`,children:[(0,Y.jsx)(l,{variant:`title-small`,as:`h3`,children:n}),r?(0,Y.jsx)(l,{variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:r}):null,(0,Y.jsxs)(`div`,{className:`flex items-center gap-[var(--app-spacing-sm)]`,children:[(0,Y.jsx)(`span`,{className:`inline-block shrink-0 rounded-full`,style:{width:8,height:8,backgroundColor:ce(i)},"aria-hidden":`true`}),(0,Y.jsx)(l,{variant:`body-medium-default`,className:`text-[var(--content-default)]`,children:le(i)})]}),a?(0,Y.jsx)(l,{variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:a}):null,o.length>0?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)]`,children:[(0,Y.jsx)(l,{variant:`body-small-emphasised`,className:`text-[var(--content-secondary)]`,children:`Missing scopes`}),(0,Y.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-[var(--app-spacing-xxs)] pl-[var(--app-spacing-lg)]`,children:o.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(l,{variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:e})},e))})]}):null]})}function ue(e){return e&&M[e]?M[e]:M.system}function de(e){return e.title?e.title:e.category?e.category.charAt(0).toUpperCase()+e.category.slice(1):`Notification`}function fe({item:e,isMobile:t,validConversationIds:n,onClose:i,onGoToThread:a,onUpdateStatus:o,onDismiss:s,onViewSchedule:c}){if(!e)return null;let d=e.detailPanel?.kind,p=de(e),h=ue(e.category),g=h.icon,_=e.status===`new`,y=e.status===`dismissed`,b=!!e.conversationId&&n.has(e.conversationId);return t?(0,Y.jsxs)(`div`,{className:`flex h-full flex-col bg-[var(--surface-overlay)]`,children:[(0,Y.jsxs)(`div`,{className:`relative flex shrink-0 items-center px-3 py-2`,children:[(0,Y.jsx)(r,{variant:`ghost`,iconOnly:(0,Y.jsx)(u,{}),onClick:i,"aria-label":`Back`,tooltip:`Back`}),(0,Y.jsx)(l,{variant:`body-medium-default`,className:`pointer-events-none absolute inset-x-0 text-center text-[var(--content-secondary)]`,children:`Details`}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Y.jsx)(r,{variant:`ghost`,iconOnly:_?(0,Y.jsx)(F,{}):(0,Y.jsx)(R,{}),onClick:()=>o(e.id,_?`seen`:`new`),"aria-label":_?`Mark as read`:`Mark as unread`,tooltip:_?`Mark as read`:`Mark as unread`}),y?(0,Y.jsx)(r,{variant:`ghost`,iconOnly:(0,Y.jsx)(ae,{}),onClick:()=>o(e.id,`seen`),"aria-label":`Restore`,tooltip:`Restore`}):(0,Y.jsx)(r,{variant:`ghost`,iconOnly:(0,Y.jsx)(T,{}),onClick:()=>s(e.id),"aria-label":`Dismiss`,tooltip:`Dismiss`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center justify-center rounded-full`,style:{width:40,height:40,backgroundColor:h.weak},"aria-hidden":`true`,children:(0,Y.jsx)(g,{width:18,height:18,style:{color:h.strong}})}),(0,Y.jsx)(l,{variant:`title-small`,className:`min-w-0 text-[var(--content-default)]`,children:p}),(0,Y.jsx)(v,{tone:`neutral`,className:`shrink-0`,title:P(e.timestamp),children:N(e.timestamp)})]}),(0,Y.jsx)(`div`,{className:`mx-4 border-b border-[var(--border-disabled)]`}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:d===`toolPermission`?(0,Y.jsx)(Z,{item:e}):(0,Y.jsx)(X,{item:e})}),b||c?(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 px-4 pb-4 pt-2`,children:[c?(0,Y.jsx)(r,{variant:`outlined`,fullWidth:!0,leftIcon:(0,Y.jsx)(f,{className:`size-4`}),onClick:c,children:`View schedule`}):null,b?(0,Y.jsx)(r,{variant:`primary`,fullWidth:!0,onClick:()=>a(e.conversationId),children:`Go to Conversation`}):null]}):null]}):(0,Y.jsxs)(`div`,{className:`flex h-full flex-col rounded-[var(--radius-xl)] border border-[var(--border-base)] bg-[var(--surface-overlay)]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-[var(--app-spacing-sm)] border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center justify-center rounded-full`,style:{width:28,height:28,backgroundColor:h.weak},"aria-hidden":`true`,children:(0,Y.jsx)(g,{width:14,height:14,style:{color:h.strong}})}),(0,Y.jsx)(l,{variant:`title-small`,className:`min-w-0 flex-1 truncate text-[var(--content-default)]`,children:p}),b?(0,Y.jsx)(r,{variant:`outlined`,onClick:()=>a(e.conversationId),children:`Go to Convo`}):null,(0,Y.jsx)(r,{variant:`outlined`,iconOnly:(0,Y.jsx)(m,{}),onClick:i,"aria-label":`Close detail panel`,tooltip:`Close`})]}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-[var(--app-spacing-lg)]`,children:[d===`toolPermission`?(0,Y.jsx)(Z,{item:e}):(0,Y.jsx)(X,{item:e}),(0,Y.jsx)(`div`,{className:`mt-[var(--app-spacing-md)]`,children:(0,Y.jsx)(v,{tone:`neutral`,title:P(e.timestamp),children:N(e.timestamp)})})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-[var(--app-spacing-sm)] border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,Y.jsx)(`div`,{children:c?(0,Y.jsx)(r,{variant:`outlined`,leftIcon:(0,Y.jsx)(f,{className:`size-4`}),onClick:c,children:`View schedule`}):null}),(0,Y.jsx)(`div`,{className:`flex items-center gap-[var(--app-spacing-sm)]`,children:y?(0,Y.jsx)(r,{variant:`primary`,onClick:()=>o(e.id,`seen`),children:`Restore`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{variant:`outlined`,onClick:()=>o(e.id,_?`seen`:`new`),children:_?`Mark as read`:`Mark as unread`}),(0,Y.jsx)(r,{variant:`primary`,onClick:()=>s(e.id),children:`Dismiss`})]})})]})]})}var pe={today:`Today`,yesterday:`Yesterday`,older:`Older`},me=10080*60*1e3;function Q(e,t){return e.status===`new`||e.status===`dismissed`?!1:t-new Date(e.createdAt).getTime()>me}function he({items:e,selectedItemId:t,validConversationIds:n,onSelectItem:r,onDismissItem:i,onRestoreItem:a,onToggleRead:o,onGoToThread:s,archivedOpen:c,onArchivedOpenChange:u,dismissedOpen:f,onDismissedOpenChange:m}){let[h,g]=(0,J.useState)(null),[v]=(0,J.useState)(()=>Date.now()),y=re(e.filter(e=>e.status!==`dismissed`)),b=y.filter(e=>!Q(e,v)),x=L(y.filter(e=>Q(e,v))),S=k(b),C=h&&S.includes(h)?h:null;h!==C&&g(C);let w=ie(L(I(b,C))),T=e.filter(e=>e.status===`dismissed`).sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-lg)]`,children:[(0,Y.jsx)(z,{categories:S,activeFilter:C,onFilterChange:g}),w.size===0?C?(0,Y.jsx)(l,{variant:`body-medium-lighter`,className:`py-[var(--app-spacing-xl)] text-center text-[var(--content-disabled)]`,children:`No items match the selected filter.`}):(0,Y.jsx)(K,{icon:d,title:`No notifications yet`,description:`Updates and activity from your assistant will appear here.`}):[...w.entries()].map(([e,a])=>(0,Y.jsxs)(`section`,{className:`flex flex-col gap-[var(--app-spacing-md)]`,children:[(0,Y.jsx)(l,{variant:`body-small-default`,as:`h3`,className:`text-[var(--content-tertiary)]`,children:pe[e]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)]`,children:a.map(e=>(0,Y.jsx)(j,{item:e,isActive:e.id===t,validConversationIds:n,onSelect:r,onDismiss:i,onToggleRead:o,onGoToThread:s},e.id))})]},e)),x.length>0&&(0,Y.jsx)(_.Root,{type:`single`,collapsible:!0,value:c?`archived-read`:``,onValueChange:e=>u?.(e===`archived-read`),children:(0,Y.jsxs)(_.Item,{value:`archived-read`,children:[(0,Y.jsxs)(_.Trigger,{className:`group gap-[var(--app-spacing-xs)] text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Y.jsx)(p,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,Y.jsxs)(`span`,{children:[`Earlier (`,x.length,`)`]})]}),(0,Y.jsx)(_.Content,{children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)] pt-[var(--app-spacing-sm)]`,children:x.map(e=>(0,Y.jsx)(j,{item:e,isActive:e.id===t,validConversationIds:n,onSelect:r,onDismiss:i,onToggleRead:o,onGoToThread:s},e.id))})})]})}),T.length>0&&(0,Y.jsx)(_.Root,{type:`single`,collapsible:!0,value:f?`dismissed`:``,onValueChange:e=>m?.(e===`dismissed`),children:(0,Y.jsxs)(_.Item,{value:`dismissed`,children:[(0,Y.jsxs)(_.Trigger,{className:`group gap-[var(--app-spacing-xs)] text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Y.jsx)(p,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,Y.jsxs)(`span`,{children:[`Dismissed (`,T.length,`)`]})]}),(0,Y.jsx)(_.Content,{children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)] pt-[var(--app-spacing-sm)]`,children:T.map(e=>(0,Y.jsx)(j,{item:e,onSelect:r,onDismiss:a,trailingAction:`restore`},e.id))})})]})})]})}function ge(){return(0,Y.jsx)(`h1`,{className:`shrink-0 text-title-large text-[var(--content-default)]`,children:`Activity`})}function $(e){let t=o(),n=(0,J.useMemo)(()=>b({path:{assistant_id:e??``}}),[e]),r=s({...y({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4}),i=(0,J.useCallback)(()=>{e&&t.invalidateQueries({queryKey:n})},[e,t,n]);return{...r,invalidate:i}}function _e(){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xl)]`,children:[(0,Y.jsx)(`div`,{className:`h-7 w-64 animate-pulse rounded-md bg-[var(--surface-lift)]`}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-sm)]`,children:Array.from({length:4},(e,t)=>(0,Y.jsx)(`div`,{className:`h-16 animate-pulse rounded-md bg-[var(--surface-lift)]`},t))})]})}function ve(e){let t=e?.metadata?.scheduleId;return typeof t==`string`&&t.length>0?t:null}function ye({assistantId:e,validConversationIds:t,onOpenConversation:n,onViewSchedule:i,initialFeedItemId:a,navigationKey:o,onInitialFeedItemConsumed:c}){let l=V(),u=B(e);$(e);let{data:d}=s(G(e)),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(!1),v=(0,J.useCallback)(e=>{e.status===`new`?(p({...e,status:`seen`}),u.updateStatus.mutate({itemId:e.id,status:`seen`})):p(e)},[u.updateStatus]),y=(0,J.useCallback)(()=>{p(null)},[]),b=(0,J.useCallback)(e=>{u.updateStatus.mutate({itemId:e,status:`dismissed`}),f?.id===e&&p(null)},[u.updateStatus,f?.id]),x=(0,J.useCallback)(e=>{u.updateStatus.mutate({itemId:e,status:`seen`}),p(t=>t?.id===e?{...t,status:`seen`}:t)},[u.updateStatus]),S=(0,J.useCallback)((e,t)=>{u.updateStatus.mutate({itemId:e,status:t}),p(n=>n?.id===e?{...n,status:t}:n)},[u.updateStatus]),C=(0,J.useCallback)(e=>{p(null),n(e)},[n]),w=u.data?.items??[],[T,E]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(!a||o===T||u.isLoading)return;E(o??null);let e=w.find(e=>e.id===a);e&&e.status!==`dismissed`&&v(e),c?.()},[a,o,T,u.isLoading,w,v,c]);let D=ne(w),O=D.filter(e=>e.status===`new`).length,k=D.length,j=ee(),M=(0,J.useCallback)(()=>{u.markAll.mutate(A(D))},[u.markAll,D]),N=(0,J.useCallback)(()=>{u.markAll.mutate(te(D)),p(null)},[u.markAll,D]),P=ve(f),F=P!=null&&(d??[]).some(e=>e.id===P),I=f?(0,Y.jsx)(fe,{item:f,isMobile:l,validConversationIds:t,onClose:y,onGoToThread:C,onUpdateStatus:S,onDismiss:b,onViewSchedule:F?()=>i(P):void 0}):null,L=(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-[var(--app-spacing-lg)] overflow-y-auto`,children:[u.isError?(0,Y.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-[var(--system-negative-weak)] bg-[var(--system-negative-weak)] px-[var(--app-spacing-lg)] py-[var(--app-spacing-md)] text-[var(--system-negative-strong)]`,children:[`Couldn't load home feed`,u.error instanceof Error?`: ${u.error.message}`:`.`]}):null,j&&(O>0||k>0)&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-[var(--app-spacing-sm)]`,children:[O>0&&(0,Y.jsx)(r,{variant:`ghost`,size:`compact`,onClick:M,disabled:u.markAll.isPending,children:`Mark all as read`}),k>0&&(0,Y.jsx)(r,{variant:`ghost`,size:`compact`,onClick:N,disabled:u.markAll.isPending,children:`Clear all`})]}),(0,Y.jsx)(he,{items:w,selectedItemId:f?.id,validConversationIds:t,onSelectItem:v,onDismissItem:b,onRestoreItem:x,onToggleRead:S,onGoToThread:C,archivedOpen:m,onArchivedOpenChange:h,dismissedOpen:g,onDismissedOpenChange:_})]}),R=I&&!l?(0,Y.jsx)(W,{storageKey:`homeDetailDrawerWidth`,detailKey:f?.id,section:L,detail:I}):L,z=u.isLoading?(0,Y.jsx)(_e,{}):(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-[var(--app-spacing-xl)]`,children:[l?null:(0,Y.jsx)(ge,{}),R]});return I&&l?(0,Y.jsx)(q,{children:I}):(0,Y.jsx)(U,{children:z})}function be(){let e=a(),t=i(),n=H(),r=t.state?.feedItemId??null,o=(0,J.useCallback)(()=>{e(t.pathname+t.search,{replace:!0})},[e,t.pathname,t.search]),s=O.use.setTopBarCenter(),c=V(),{conversations:u}=D(n),{conversations:d}=E(n,!0),{conversations:f}=C(n,!0),p=(0,J.useMemo)(()=>new Set(S(u,d,f).map(e=>e.conversationId)),[u,d,f]);return(0,J.useEffect)(()=>(s(c?(0,Y.jsx)(l,{variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:`Activity`}):null),()=>{s(null)}),[c,s]),(0,Y.jsx)(ye,{assistantId:n,validConversationIds:p,initialFeedItemId:r,navigationKey:t.key,onInitialFeedItemConsumed:o,onOpenConversation:t=>e(x.conversation(t)),onViewSchedule:t=>e(x.schedules.detail(t))})}export{be as HomePageRoute};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{nt as o,rt as s}from"./local-mode-hyYI6_OH.js";import{t as c}from"./is-electron-DBOtwp5h.js";import{n as l}from"./resolved-assistants-store-DdnJoLGS.js";import{i as u}from"./auth-store-B6EXnaee.js";import{c as d,r as f}from"./routes-XPLb07Av.js";import{t as p}from"./client-feature-flag-store-DeUwlUsr.js";import{t as m}from"./use-onboarding-login-D6BGXpJ1.js";import{Na as h,Sa as g,vn as _}from"./index-CmaRQR9x.js";import{r as v}from"./provider-key-BGsg7FL-.js";var y=e(t(),1),b=a(),x=`h-5 w-5 shrink-0 text-[var(--content-secondary)]`;function S(){let e=u(),t=p.use.multiPlatformAssistant(),n=l.use.assistants().some(e=>e.isPlatformHosted);return[{mode:`vellum-cloud`,label:`Vellum Cloud`,subtitle:`Always on, 24/7, even when your computer is off. Runs on Vellum's secure infrastructure.`,icon:(0,b.jsx)(h,{className:x}),...!e||!t&&n?{disabled:!0,badge:e?`Limit Reached`:`Requires Account`}:{}},{mode:`local`,label:`Local`,subtitle:`Runs directly on your machine. Your data never leaves your computer.`,icon:(0,b.jsx)(g,{className:x})}]}function C(){let e=i(),[t]=r(),a=t.get(`from`)===`select-assistant`,l=u(),p=c(),h=S(),g=h.find(e=>e.mode===`vellum-cloud`)?.disabled,[x,C]=(0,y.useState)(l&&!g?`vellum-cloud`:`local`);(0,y.useEffect)(()=>{g&&x===`vellum-cloud`&&C(`local`)},[g,x]);let{loading:T,error:E,login:D,cancel:O}=m(`${d.onboarding.hosting}?from=select-assistant`),k=a&&!l&&!p;return(0,b.jsx)(_,{children:(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${p?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`min-h-screen px-6 pb-40 pt-16`} text-[var(--content-default)]`,children:[(0,b.jsx)(`h1`,{className:p?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Hosting`}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${p?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Where do you want your assistant to live?`}),E&&(0,b.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:E}),(0,b.jsx)(`div`,{className:`grid w-full ${p?`mt-8 gap-2`:`auto-rows-fr mt-10 gap-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:h.map(e=>(0,b.jsx)(w,{option:e,selected:x===e.mode,onSelect:()=>{e.disabled||C(e.mode)}},e.mode))}),(0,b.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${p?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[(0,b.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,className:p?void 0:`h-11 text-base`,onClick:()=>{x===`vellum-cloud`?(s(),o(null),v(null),e(d.onboarding.privacy)):e(`${d.onboarding.apiKey}?hosting=${x}`)},children:`Continue`}),k&&(0,b.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:T?O:()=>void D(),children:T?`Cancel`:`Log In`}),(0,b.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:p?void 0:`h-11 text-base`,onClick:()=>{e(a?d.selectAssistant:d.welcome)},disabled:T,children:`Back`})]}),(0,b.jsx)(`a`,{href:f(d.docs.hostingOptions),target:`_blank`,rel:`noreferrer`,className:`prechat-md-regular mt-6 text-body-medium-default text-[var(--content-default)] underline`,style:{animation:`fadeInUp 0.5s ease-out 0.6s both`},children:`Need help choosing?`})]})})}function w({option:e,selected:t,onSelect:n}){let r=c();return(0,b.jsxs)(`button`,{type:`button`,onClick:n,disabled:e.disabled,className:`flex w-full items-center border text-left transition-colors ${r?`h-[72px] gap-3 rounded-lg p-3`:`gap-4 rounded-xl px-4 py-4`} ${e.disabled?`cursor-not-allowed opacity-60`:`cursor-pointer`} ${t&&!e.disabled?`${r?`border-[var(--primary-base)]/50`:`border-[var(--primary-base)]`} bg-[var(--primary-base)]/5`:`${r?`border-[var(--border-disabled)]`:`border-[var(--border-element)]`} bg-transparent`}`,children:[e.icon,(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e.label}),e.badge&&(0,b.jsx)(`span`,{className:`rounded-full bg-[var(--surface-tertiary)] px-2 py-0.5 text-[var(--content-tertiary)] ${r?`text-label-medium-default`:`text-body-small-default`}`,children:e.badge})]}),(0,b.jsx)(`span`,{className:`mt-0.5 line-clamp-2 text-[var(--content-tertiary)] ${r?`text-label-medium-default leading-[14px]`:`text-body-small-default`}`,children:e.subtitle})]}),!e.disabled&&(0,b.jsx)(`div`,{className:`flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${r?`border-[1.5px]`:`border-2`} ${t?r?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--primary-base)]`:`border-[var(--border-element)]`}`,children:t&&(0,b.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-[var(--aux-white)]`:`bg-[var(--primary-base)]`}`})})]})}export{C as HostingScreen};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{nt as o,rt as s}from"./local-mode-hyYI6_OH.js";import{t as c}from"./is-electron-DBOtwp5h.js";import{n as l}from"./resolved-assistants-store-DdnJoLGS.js";import{i as u}from"./auth-store-B6EXnaee.js";import{c as d,r as f}from"./routes-XPLb07Av.js";import{t as p}from"./client-feature-flag-store-DeUwlUsr.js";import{t as m}from"./use-onboarding-login-D6BGXpJ1.js";import{Na as h,Sa as g,vn as _}from"./index-CgcZXB4g.js";import{r as v}from"./provider-key-BGsg7FL-.js";var y=e(t(),1),b=a(),x=`h-5 w-5 shrink-0 text-[var(--content-secondary)]`;function S(){let e=u(),t=p.use.multiPlatformAssistant(),n=l.use.assistants().some(e=>e.isPlatformHosted);return[{mode:`vellum-cloud`,label:`Vellum Cloud`,subtitle:`Always on, 24/7, even when your computer is off. Runs on Vellum's secure infrastructure.`,icon:(0,b.jsx)(h,{className:x}),...!e||!t&&n?{disabled:!0,badge:e?`Limit Reached`:`Requires Account`}:{}},{mode:`local`,label:`Local`,subtitle:`Runs directly on your machine. Your data never leaves your computer.`,icon:(0,b.jsx)(g,{className:x})}]}function C(){let e=i(),[t]=r(),a=t.get(`from`)===`select-assistant`,l=u(),p=c(),h=S(),g=h.find(e=>e.mode===`vellum-cloud`)?.disabled,[x,C]=(0,y.useState)(l&&!g?`vellum-cloud`:`local`);(0,y.useEffect)(()=>{g&&x===`vellum-cloud`&&C(`local`)},[g,x]);let{loading:T,error:E,login:D,cancel:O}=m(`${d.onboarding.hosting}?from=select-assistant`),k=a&&!l&&!p;return(0,b.jsx)(_,{children:(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${p?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`min-h-screen px-6 pb-40 pt-16`} text-[var(--content-default)]`,children:[(0,b.jsx)(`h1`,{className:p?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Hosting`}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${p?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Where do you want your assistant to live?`}),E&&(0,b.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:E}),(0,b.jsx)(`div`,{className:`grid w-full ${p?`mt-8 gap-2`:`auto-rows-fr mt-10 gap-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:h.map(e=>(0,b.jsx)(w,{option:e,selected:x===e.mode,onSelect:()=>{e.disabled||C(e.mode)}},e.mode))}),(0,b.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${p?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[(0,b.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,className:p?void 0:`h-11 text-base`,onClick:()=>{x===`vellum-cloud`?(s(),o(null),v(null),e(d.onboarding.privacy)):e(`${d.onboarding.apiKey}?hosting=${x}`)},children:`Continue`}),k&&(0,b.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:T?O:()=>void D(),children:T?`Cancel`:`Log In`}),(0,b.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:p?void 0:`h-11 text-base`,onClick:()=>{e(a?d.selectAssistant:d.welcome)},disabled:T,children:`Back`})]}),(0,b.jsx)(`a`,{href:f(d.docs.hostingOptions),target:`_blank`,rel:`noreferrer`,className:`prechat-md-regular mt-6 text-body-medium-default text-[var(--content-default)] underline`,style:{animation:`fadeInUp 0.5s ease-out 0.6s both`},children:`Need help choosing?`})]})})}function w({option:e,selected:t,onSelect:n}){let r=c();return(0,b.jsxs)(`button`,{type:`button`,onClick:n,disabled:e.disabled,className:`flex w-full items-center border text-left transition-colors ${r?`h-[72px] gap-3 rounded-lg p-3`:`gap-4 rounded-xl px-4 py-4`} ${e.disabled?`cursor-not-allowed opacity-60`:`cursor-pointer`} ${t&&!e.disabled?`${r?`border-[var(--primary-base)]/50`:`border-[var(--primary-base)]`} bg-[var(--primary-base)]/5`:`${r?`border-[var(--border-disabled)]`:`border-[var(--border-element)]`} bg-transparent`}`,children:[e.icon,(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e.label}),e.badge&&(0,b.jsx)(`span`,{className:`rounded-full bg-[var(--surface-tertiary)] px-2 py-0.5 text-[var(--content-tertiary)] ${r?`text-label-medium-default`:`text-body-small-default`}`,children:e.badge})]}),(0,b.jsx)(`span`,{className:`mt-0.5 line-clamp-2 text-[var(--content-tertiary)] ${r?`text-label-medium-default leading-[14px]`:`text-body-small-default`}`,children:e.subtitle})]}),!e.disabled&&(0,b.jsx)(`div`,{className:`flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${r?`border-[1.5px]`:`border-2`} ${t?r?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--primary-base)]`:`border-[var(--border-element)]`}`,children:t&&(0,b.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-[var(--aux-white)]`:`bg-[var(--primary-base)]`}`})})]})}export{C as HostingScreen};