@vellumai/web 0.10.11-dev.202607222129.31c06e5 → 0.10.11-dev.202607222325.35fc367
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.
- package/dist/assets/{account-page-CzZuoekz.js → account-page-GZyBTNUh.js} +1 -1
- package/dist/assets/{acp-run-detail-panel-DssICbn8.js → acp-run-detail-panel-rUaOd-hf.js} +1 -1
- package/dist/assets/{activity-steps-panel-CeLVlAeY.js → activity-steps-panel-5VIG5OqK.js} +1 -1
- package/dist/assets/{add-credits-modal-BFTdUmH6.js → add-credits-modal-CzzFGQWP.js} +1 -1
- package/dist/assets/{ai-page-ukSnDSJr.js → ai-page-CM4iIEf6.js} +1 -1
- package/dist/assets/api-Cg02JjXP.js +1 -0
- package/dist/assets/{api-CxAtNZ-r.js → api-Jhp24FhR.js} +1 -1
- package/dist/assets/{api-key-screen-DD_TJKco.js → api-key-screen-XB0o3VGu.js} +1 -1
- package/dist/assets/{assistant-status-panel-gpwr0glD.js → assistant-status-panel-3QLq7XTz.js} +1 -1
- package/dist/assets/{auth-store-Lzg3kiaw.js → auth-store-quPkF_4z.js} +1 -1
- package/dist/assets/{background-task-detail-panel-BCXH3MXV.js → background-task-detail-panel-CtnQ4o8Y.js} +1 -1
- package/dist/assets/{billing-page-BZwgqWS1.js → billing-page-BuH7Flj1.js} +1 -1
- package/dist/assets/{bookmarks-page-B-PbfvFN.js → bookmarks-page-BPYxHwvq.js} +1 -1
- package/dist/assets/{build-state-Bo2Ut5Js.js → build-state-rDsVeVLA.js} +1 -1
- package/dist/assets/{channels-page-route-DEwl411M.js → channels-page-route-CPi_Fp88.js} +1 -1
- package/dist/assets/chat-AyO7_TjY.js +1 -0
- package/dist/assets/{command-palette-DNujIsf0.js → command-palette-DSjWseMw.js} +1 -1
- package/dist/assets/{command-palette-window-page-mWNMMe4I.js → command-palette-window-page-Dj8qEe_8.js} +1 -1
- package/dist/assets/{community-page-DEcDCjsQ.js → community-page-C5z-9PeA.js} +1 -1
- package/dist/assets/{connect-page-DuBhY8KD.js → connect-page-CovLqmQK.js} +1 -1
- package/dist/assets/{contacts-page-route-BS2duMoh.js → contacts-page-route-C0blpiOy.js} +1 -1
- package/dist/assets/{credentials-page-DDgYexAA.js → credentials-page-BYLMj-Vi.js} +1 -1
- package/dist/assets/{debug-page-B_us491I.js → debug-page-BXDNUKAc.js} +1 -1
- package/dist/assets/{deploy-dialogs-CB5PSyxZ.js → deploy-dialogs-SI8FNwW3.js} +1 -1
- package/dist/assets/{detail-panel-stop-button-26G26Tqs.js → detail-panel-stop-button-DYV4AyIE.js} +1 -1
- package/dist/assets/{developer-page-Dqug_k0U.js → developer-page-4qC6bfMI.js} +1 -1
- package/dist/assets/{dictation-overlay-page-Rz3bqW3f.js → dictation-overlay-page-w-7_v7vX.js} +1 -1
- package/dist/assets/{document-viewer-page-DmHPShuz.js → document-viewer-page-D5v9jurM.js} +1 -1
- package/dist/assets/{emails-page-s9TxP6jP.js → emails-page-CrxG8ZDa.js} +1 -1
- package/dist/assets/{general-page-DsrG3cM2.js → general-page-ZuhMFVx3.js} +1 -1
- package/dist/assets/{hatching-screen-CuzULcU_.js → hatching-screen-CeQF1pRn.js} +1 -1
- package/dist/assets/{home-page-route-Cc3ksf3X.js → home-page-route-BSswnfjb.js} +1 -1
- package/dist/assets/{hosting-screen-DufVMlwF.js → hosting-screen-CoPWPYM0.js} +1 -1
- package/dist/assets/{identity-page-route-CUrEsO_0.js → identity-page-route-5CTzy7R7.js} +1 -1
- package/dist/assets/{index-C7ix_asE.js → index-Ck1SrvnM.js} +15 -15
- package/dist/assets/index-Co1WDHMj.css +2 -0
- package/dist/assets/{inspect-page-BUAbv6xj.js → inspect-page-CbL5eNZP.js} +1 -1
- package/dist/assets/{integrations-page-9JcrAORp.js → integrations-page-hX8eENSt.js} +1 -1
- package/dist/assets/{intelligence-layout-DJjUScCy.js → intelligence-layout-Che-CPPC.js} +1 -1
- package/dist/assets/{library-detail-page-BCAZmbR6.js → library-detail-page-CHLvGvqm.js} +1 -1
- package/dist/assets/{library-page-CiTHHvZ5.js → library-page-CyX22JKU.js} +1 -1
- package/dist/assets/{login-flow-DYrO-od6.js → login-flow-DbD8dpQO.js} +1 -1
- package/dist/assets/{login-page-DAFzFbRp.js → login-page-Bk7ZkXmL.js} +1 -1
- package/dist/assets/{logout-page-CsPkQ-4I.js → logout-page-b5UKcm6I.js} +1 -1
- package/dist/assets/{logs-layout-DBJaWlOK.js → logs-layout-DqmiOqxX.js} +1 -1
- package/dist/assets/{memory-page-route-CpPfBU9j.js → memory-page-route-z1B9mzGX.js} +1 -1
- package/dist/assets/{memory-router-playground-page-DfGhXcZW.js → memory-router-playground-page-BkNOYakH.js} +1 -1
- package/dist/assets/{mobile-sidebar-drawer-CVT3O8os.js → mobile-sidebar-drawer-CZXirrGr.js} +1 -1
- package/dist/assets/{notifications-page-DcHyVoSk.js → notifications-page-ChodICPa.js} +1 -1
- package/dist/assets/{oauth-complete-page-DjKBNbdN.js → oauth-complete-page-DAbVLddu.js} +1 -1
- package/dist/assets/{oauth-popup-complete-page-2KKVC5zM.js → oauth-popup-complete-page-DgH2GYyB.js} +1 -1
- package/dist/assets/{pairing-page-7NMcVDJj.js → pairing-page-B7TF3mjM.js} +1 -1
- package/dist/assets/{personality-page-CwaMBzXV.js → personality-page-BfD3xcZs.js} +1 -1
- package/dist/assets/{plans-page-Cre3Gpys.js → plans-page-BkxM9GzA.js} +1 -1
- package/dist/assets/{platform-loopback-page-CIcVs3UP.js → platform-loopback-page-CdL_j5rg.js} +1 -1
- package/dist/assets/{plugin-detail-page-R7HOcOd1.js → plugin-detail-page-DD3KG_Ob.js} +1 -1
- package/dist/assets/{privacy-page-CTQpOjs-.js → privacy-page-BOhDW3Tr.js} +1 -1
- package/dist/assets/{privacy-screen-DgHmBdN-.js → privacy-screen-DsKCxStT.js} +1 -1
- package/dist/assets/{provider-callback-page-kcYxB4WF.js → provider-callback-page-Dy-XHz3J.js} +1 -1
- package/dist/assets/{provider-signup-page-D9aI4WFt.js → provider-signup-page-Cw_EuUcw.js} +1 -1
- package/dist/assets/{quick-input-page-D2Bqa3St.js → quick-input-page-DgKCQboP.js} +1 -1
- package/dist/assets/{research-mock-page-C6zrZtBI.js → research-mock-page-DuWAP5WQ.js} +1 -1
- package/dist/assets/{research-onboarding-route-AYDHEowO.js → research-onboarding-route-DqSzV4R1.js} +1 -1
- package/dist/assets/{review-terms-screen-BSa9jNvG.js → review-terms-screen-C4VOK9eY.js} +1 -1
- package/dist/assets/{risk-C-ZyBTAb.js → risk-BbqTlLoT.js} +1 -1
- package/dist/assets/{schedules-page-gqD1Tbf8.js → schedules-page-CKnLdKQE.js} +1 -1
- package/dist/assets/{select-assistant-screen-CFvCmydl.js → select-assistant-screen-CKk_y6Wj.js} +1 -1
- package/dist/assets/{settings-layout-XYxLMpW0.js → settings-layout-Cntp7oUe.js} +1 -1
- package/dist/assets/{share-feedback-modal-Bjh3dK-n.js → share-feedback-modal-vBcYayA4.js} +1 -1
- package/dist/assets/{sidebar-tree-CDqUGPSK.js → sidebar-tree-X01ptIng.js} +1 -1
- package/dist/assets/{signup-page-DgYRwrxX.js → signup-page-CkcipBzC.js} +1 -1
- package/dist/assets/{site-favicon-DHBOONR1.js → site-favicon-qbssi9h0.js} +1 -1
- package/dist/assets/{skill-detail-page-Dnh8ep5N.js → skill-detail-page-sf-eYZtq.js} +1 -1
- package/dist/assets/{skill-detail-panel-DIn7RLCC.js → skill-detail-panel-bqurW7AD.js} +1 -1
- package/dist/assets/{start-screen-CJb-0lgs.js → start-screen-BGwp_xBH.js} +1 -1
- package/dist/assets/{subagent-detail-panel-V44LtNl6.js → subagent-detail-panel-BzMMipi4.js} +1 -1
- package/dist/assets/{subagent-store-CPEG25fH.js → subagent-store-ZCAfa32m.js} +1 -1
- package/dist/assets/{superpowers-page-X0kSM_TF.js → superpowers-page-D3EekoAk.js} +1 -1
- package/dist/assets/{system-events-page-Duos2ubJ.js → system-events-page-tOTktdXx.js} +1 -1
- package/dist/assets/{theme-stage-page-BU-Gj4c2.js → theme-stage-page-CkPg3HLk.js} +1 -1
- package/dist/assets/{tier-upgrade-resize-modal-CbRtJhAf.js → tier-upgrade-resize-modal-BWDhujpc.js} +1 -1
- package/dist/assets/{tiptap-document-editor-D1aVS6nK.js → tiptap-document-editor-4dcMTA_h.js} +1 -1
- package/dist/assets/{tool-detail-panel-C-O4opDs.js → tool-detail-panel-hH1I4AMa.js} +1 -1
- package/dist/assets/{upgrade-cancel-page-UaVSwAVr.js → upgrade-cancel-page-B_bh0PIP.js} +1 -1
- package/dist/assets/{upgrade-success-page-CBs03tVb.js → upgrade-success-page-DmQqjklp.js} +1 -1
- package/dist/assets/{use-assistant-identity-details-CKel0e_r.js → use-assistant-identity-details-DRCMhHXZ.js} +1 -1
- package/dist/assets/{use-edge-swipe-back-Dv1ShCT7.js → use-edge-swipe-back-2Yjfb81V.js} +1 -1
- package/dist/assets/{use-invite-link-dialog-BfVPh6F5.js → use-invite-link-dialog-DNAxfIHK.js} +1 -1
- package/dist/assets/use-is-org-ready-DP2_SBJo.js +1 -0
- package/dist/assets/{use-onboarding-login-DMLLDHRX.js → use-onboarding-login-6LWa5XdQ.js} +1 -1
- package/dist/assets/{use-skill-actions-DPXX5qWL.js → use-skill-actions-FLVJkX9f.js} +1 -1
- package/dist/assets/{use-skill-detail-files-CuoCiyOy.js → use-skill-detail-files-DHBiaT9K.js} +1 -1
- package/dist/assets/{voice-page-DdjI8A76.js → voice-page-Cex0WiYJ.js} +1 -1
- package/dist/assets/{weather-forecast-display-0GtxW555.js → weather-forecast-display-BoH2wKfc.js} +1 -1
- package/dist/assets/{welcome-screen-DZhajJW3.js → welcome-screen-BE8PhNfU.js} +1 -1
- package/dist/assets/{workflow-detail-panel-Cw0kRLTK.js → workflow-detail-panel-CO0C-Lqo.js} +1 -1
- package/dist/assets/{workspace-page-7j1DZUlp.js → workspace-page-eR-YtX-j.js} +1 -1
- package/dist/index.html +13 -13
- package/package.json +1 -1
- package/dist/assets/api-DqHVnn1b.js +0 -1
- package/dist/assets/chat-CNlH625o.js +0 -1
- package/dist/assets/index-BRSW3eiH.css +0 -2
- package/dist/assets/use-is-org-ready-Ba5vxuqM.js +0 -1
|
@@ -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-anSemq95.js";import{t as i}from"./react-DJZBPgpf.js";import{t as a}from"./button-CW7wKp2r.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-Cf8bWrcq.js";import{t as m}from"./createLucideIcon-Bjb-Kuq7.js";import{t as h}from"./bell-V9BYKY__.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-CVw67M2Z.js";import{t as x}from"./hard-drive-DVmyHlZR.js";import{t as S}from"./loader-circle-Ck8fq3yv.js";import{t as C}from"./monitor-BFX2ySFb.js";import{t as w}from"./moon-h3xmz34k.js";import{t as T}from"./refresh-cw-cau3ebz1.js";import{a as E,c as D,i as O,o as k,s as A,t as j}from"./resize-errors-ORrW5M6r.js";import{t as M}from"./sparkles-BK3KXCjl.js";import{t as N}from"./triangle-alert-CnjNKhNx.js";import{t as P}from"./x-CswtfvgS.js";import{t as F}from"./notice-CvJ7MBx5.js";import{t as I}from"./progress-bar-DrwFU9Ti.js";import{M as ee,N as te,i as L,j as R,n as ne}from"./src-BT0gNVcT.js";import{t as re}from"./tag-CJyI1Y2J.js";import{t as z}from"./input-D3MhHg0d.js";import{t as B}from"./toggle-Ca1aoG-l.js";import{t as V}from"./modal-D_Y2RPD5.js";import{n as H}from"./toast-zHo1wvF9.js";import{t as ie}from"./confirm-dialog-DxBl6zcI.js";import{t as ae}from"./dropdown-DQozlhbb.js";import{E as U,O as oe,S as W,c as G,d as se,f as ce,g as le,h as ue,i as de,nt as fe,r as pe,x as me}from"./local-mode-Dydd46cS.js";import{t as K}from"./is-electron-y5bNUVyG.js";import{n as he}from"./resolved-assistants-store-DdHm-7v4.js";import{r as ge,t as _e}from"./semver-DIkpaM51.js";import{n as ve,r as ye,t as be}from"./api-errors-CoE1wFl2.js";import{D as xe,S as Se,T as Ce,a as we,b as Te,g as Ee,h as De,k as Oe,n as ke,u as Ae,v as je,y as Me}from"./auth-store-Lzg3kiaw.js";import{t as q}from"./client.gen-DVfIRXUZ.js";import{C as Ne,H as Pe,M as Fe,T as Ie,Vt as Le,X as Re,Z as ze,j as Be}from"./sdk.gen-BCFkwLHb.js";import{a as Ve,o as He}from"./api-CxAtNZ-r.js";import{u as J}from"./routes-D4ff4ONd.js";import{i as Ue,o as We}from"./platform-detection-BBQ3eUv5.js";import{t as Y}from"./client-feature-flag-store-BOcAh56y.js";import{t as Ge}from"./assistant-feature-flag-store-Bh-_qc7v.js";import{t as Ke}from"./pointer-DcD0Nt7Z.js";import{t as qe}from"./proxy-DoUA9mK6.js";import{t as Je}from"./AnimatePresence-C42g9zWi.js";import{t as Ye}from"./use-reduced-motion-DpK6cQN-.js";import{$o as Xe,Ba as Ze,Ca as Qe,Dt as $e,Gn as et,H as tt,Hn as nt,J as rt,Ji as it,Ki as at,Kn as ot,M as st,N as ct,Nn as lt,Qo as ut,Sa as dt,Uo as ft,Vn as pt,Wn as mt,Xt as ht,Yr as gt,_i as _t,ai as vt,ba as yt,bi as bt,bn as xt,di as St,do as Ct,fi as wt,fo as Tt,gi as Et,ha as Dt,hi as Ot,j as kt,ma as At,mi as jt,or as Mt,pi as Nt,qn as Pt,qo as Ft,sr as It,ua as Lt,uo as Rt,va as zt,vi as Bt,xa as Vt,xi as Ht,xs as Ut,ya as Wt,zn as Gt}from"./index-C7ix_asE.js";import{t as X}from"./detail-card-CAHT277C.js";import{t as Kt}from"./app-info-DDWMarAq.js";import{t as qt}from"./environment-store-geigPfHz.js";import{a as Jt,i as Yt,n as Xt,r as Zt,t as Qt}from"./assistant-status-panel-gpwr0glD.js";import{t as $t}from"./settings-divider-RhnS0iml.js";var en=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`}]]),tn=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`}]]),Z=e(i(),1),Q=f();function nn(){let e=Y.use.velvet(),{theme:t,setThemePreference:n}=xt(),r=[{value:`system`,label:`System`,icon:(0,Q.jsx)(C,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,Q.jsx)(ft,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,Q.jsx)(w,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,Q.jsx)(Ut,{className:`h-4 w-4`})}]:[]];return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Theme`}),(0,Q.jsx)(`div`,{className:`mt-2 max-w-[360px]`,children:(0,Q.jsx)(R,{ariaLabel:`Theme`,value:t,onChange:n,items:r})})]})}var rn=De,an=`Please choose a different handle.`;async function on(e,t){let{data:n,error:r,response:i}=await Fe({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:ye(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}=Te(r,`handle`,rn.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=Te(r,`handle`,an);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:ye(r,i,`Failed to save handle.`)}}async function sn(e,t,n){let{data:r,error:i,response:a}=await Ne({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(ve(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new be(a.status,a.status===429?`Too many checks — try again in a moment.`:ye(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function cn(e){return/\d{2,}$/.test(e)}var ln=300,un=1400;function dn({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:o,onSaved:s,saveSuccessToast:c,fieldId:l}){let[u,d]=(0,Z.useState)(e),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[_,y]=(0,Z.useState)(`idle`),[b,x]=(0,Z.useState)(null),C=Ye(),w=(0,Z.useRef)(null),T=(0,Z.useMemo)(()=>u.trim().toLowerCase(),[u]),E=T===e.toLowerCase();(0,Z.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)}},ln);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?rn[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,Z.useCallback)(async()=>{if(!k)return;y(`saving`),x(null);let e=await o(T);if(e.kind===`ok`){y(`saved`),s(e.data),H.success(c),window.setTimeout(()=>y(`idle`),un);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),H.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,Q.jsx)(Je,{mode:`wait`,initial:!1,children:(0,Q.jsxs)(qe.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,Q.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,Q.jsx)(g,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,Q.jsx)(v,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),M=(()=>{switch(_){case`saving`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(S,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Saving…`]});case`saved`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Saved`]});default:return`Save`}})();return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(z,{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,Q.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,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(a,{variant:`primary`,size:`compact`,onClick:A,disabled:!k,"aria-live":`polite`,"data-testid":`${l}-save`,children:M})})]})}function fn({initial:e,onSaved:t}){let n=ke.use.refreshSession(),r=cn(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,Z.useCallback)(async e=>await Me({username:e}),[]),a=(0,Z.useCallback)((e,t)=>Ee(e,t),[]),o=(0,Z.useCallback)(e=>{t(e),n()},[t,n]);return(0,Q.jsx)(dn,{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 pn({assistant:e,onSaved:t}){let n=e.handle??``,r=u({...gt({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,Z.useCallback)(async t=>await on(e.id,t),[e.id]),c=(0,Z.useCallback)((t,n)=>sn(e.id,t,n),[e.id]);return i?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(z,{label:`Assistant handle`,value:n,readOnly:!0,disabled:!0,leftIcon:(0,Q.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,Q.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,Q.jsx)(s,{to:`${J.settings.ai}?release=1#email`,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`,children:`release the subdomain`}),` `,`first.`]})]}):(0,Q.jsx)(dn,{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 mn(){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-3 w-72 animate-pulse rounded bg-[var(--surface-muted)]`})]}),(0,Q.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`div`,{className:`h-3 w-60 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-7 w-16 animate-pulse rounded-md bg-[var(--surface-muted)]`})]}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Loading your profile…`})]})}function hn(){return(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`})}function gn({assistant:e,showHandles:t=!0,children:n}={}){let r=ke.use.user?.()?.email??null;return(0,Q.jsx)(X,{title:`Profile`,subtitle:`Manage your account details and preferences.`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[r&&(0,Q.jsx)(`div`,{className:`max-w-[420px]`,children:(0,Q.jsx)(z,{label:`Email`,value:r,disabled:!0,readOnly:!0})}),t&&(0,Q.jsxs)(Q.Fragment,{children:[r&&(0,Q.jsx)(hn,{}),(0,Q.jsx)(_n,{assistant:e})]}),n!=null&&(0,Q.jsxs)(Q.Fragment,{children:[(r||t)&&(0,Q.jsx)(hn,{}),n]})]})})}function _n({assistant:e}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(null),a=Ye(),[o,s]=(0,Z.useState)(e??null);return(0,Z.useEffect)(()=>{s(e??null)},[e]),(0,Z.useEffect)(()=>{let e=!1;return je().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),r?(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,Q.jsxs)(qe.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,Q.jsx)(fn,{initial:t,onSaved:n}),o&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsx)(pn,{assistant:o,onSaved:s})]})]}):(0,Q.jsx)(mn,{})}var vn=vt({query:{hosting:`platform`}});function yn(){let e=rt(),t=u(vn),n=t.data?.results??[];return t.isPending||n.length<2?null:(0,Q.jsx)(X,{title:`Switch Assistant`,subtitle:`Choose which assistant is active for this account.`,children:(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>{let n=t.id===e;return(0,Q.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,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(C,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:t.name||`Unnamed`}),t.status!==`active`&&(0,Q.jsx)(re,{tone:`warning`,children:t.status})]})})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:n?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,Q.jsx)(g,{className:`h-4 w-4`}),`Active`]}):(0,Q.jsx)(a,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{Oe(t.id),H.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var bn=[{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 xn(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 Sn({assistantId:e}){let t=l(),n=qt.use.isNonProduction(),r=(0,Z.useMemo)(()=>bn.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:o,isError:s}=u(_t({path:{id:e}})),c=(0,Z.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[d,f]=(0,Z.useState)(null),p=d??c,m=d!==null,h=Dt({onSuccess:()=>{H.success(`Sleep policy saved.`),f(null),t.invalidateQueries({queryKey:Bt({path:{id:e}})})},onError:()=>{H.error(`Failed to save sleep policy. Please try again.`)}});return o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):s?(0,Q.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,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Idle timeout`}),(0,Q.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,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:r.map(e=>(0,Q.jsx)(a,{variant:`outlined`,active:p===e.seconds,onClick:()=>f(e.seconds),children:e.label},e.seconds))}),(0,Q.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,xn(p)]})]}),m&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(a,{variant:`primary`,leftIcon:h.isPending?(0,Q.jsx)(S,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,Q.jsx)(a,{variant:`outlined`,onClick:()=>f(null),disabled:h.isPending,children:`Cancel`})]})]})}function Cn(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var wn=3e3;function Tn({version:e,assistantId:t}){let{onTap:n,message:r}=Yt(t);return(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.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,Q.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:r})]})}function En({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=Ge.use.rollbackEnabled(),o=Y.use.previewChannel(),s=l(),c=et(n,o),f=c===`preview`,[p,m]=(0,Z.useState)(!1),h=(0,Z.useRef)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[C,w]=(0,Z.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),H.success(b?`Rollback complete — assistant is healthy.`:`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),r?.()}),!1):wn;u({...Ot({path:{id:e}}),refetchInterval:p?e=>E(e.state.data?.current_release_version):!1});let{data:D,isLoading:O}=u(Lt({query:{channel:c}})),k=D?.find(e=>e.is_stable!==!1)??D?.[0],A=g??k?.version??null,j=(0,Z.useMemo)(()=>{if(!i||!A||!t)return!1;let e=ge(A),n=ge(t);return!e||!n?!1:_e(e,n)<0},[i,A,t]),M=(0,Z.useMemo)(()=>{if(!A)return!1;if(!t)return!0;let e=ge(A),n=ge(t);if(!e||!n)return A!==t;let r=_e(e,n);return i?r!==0:r>0},[i,A,t]),N=d({mutationFn:async t=>{let{data:n}=await Re({path:{id:e},body:t,throwOnError:!0});return n}}),P=d({mutationFn:async t=>{let{data:n}=await Pe({path:{id:e},body:t,throwOnError:!0});return n}});return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Q.jsx)(Tn,{version:t,assistantId:e})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:f?`Preview release`:M?j?`Rollback to`:`Update to`:`Selected`}),(0,Q.jsx)(`span`,{className:`block min-w-0`,children:O?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(S,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):D&&D.length>0?i?(0,Q.jsx)(ae,{value:A??``,onChange:e=>_(e===k?.version?null:e),disabled:p||N.isPending||P.isPending,options:D.map(e=>({value:e.version,label:Cn(e,t,k?.version)}))}):(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:k?Cn(k,t,k.version):`—`}):`No releases available`})]})]}),(0,Q.jsx)(a,{variant:j?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:N.isPending||P.isPending||p?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.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,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Using Preview releases.`,` `,(0,Q.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,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:C??`You are already on this version.`}),(0,Q.jsx)(ie,{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,H.success(e.detail||`Rollback to ${t} initiated.`)}else{let e=await N.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){H.warning(e.detail);return}h.current=e.version??t??null,H.success(e.detail||`Update to ${e.version??t??`latest`} initiated.`)}x(j),m(!0),s.invalidateQueries({queryKey:Et({path:{id:e}})})}catch{H.error(j?`Failed to trigger rollback. Please try again.`:`Failed to trigger update. Please try again.`)}},onCancel:()=>y(!1)})]})}function Dn({assistantId:e,currentVersion:t,onUpgradeComplete:n}){let[r,i]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),{data:c,isLoading:l}=u(Lt({query:{stable:!0,limit:100}})),d=(0,Z.useMemo)(()=>mt(c),[c]),f=d?.version,p=t?ot(t,f):!!f,m=Pt({assistantId:e,targetVersion:f});return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Q.jsx)(Tn,{version:t,assistantId:e})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Update to`}),(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:l?`Loading...`:f&&d?Cn(d,t,f):`No releases available`})]})]}),(0,Q.jsx)(a,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(T,{}),onClick:()=>i(!0),disabled:m.isPending||l||!f||!p,children:m.isPending?`Updating...`:f?`Update to ${f}`:`Update`}),o&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:o}),!o&&!p&&f&&!l&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:`You are already on this version.`}),(0,Q.jsx)(ie,{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`}.`),H.success(`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),n?.()}catch(e){H.error(e instanceof Error?e.message:`Failed to trigger update. Please try again.`)}},onCancel:()=>i(!1)})]})}function On(){let e=Tt({platformHostedOnly:!0}),t=Ct(),n=ke.use.user()?.id??null,r=ke.use.logout(),[i,o]=(0,Z.useState)(!1),s=zt({onSuccess:async()=>{H.success(`Account deletion requested. You will be logged out shortly.`),Ae(n),await r(),Ze(J.account.login)},onError:()=>{H.error(`Failed to request account deletion. Please try again.`)}}),c=e===`full`&&t;return(0,Z.useEffect)(()=>{c&&i&&o(!1)},[c,i]),e===`gated`?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Delete Account`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently delete your account and all associated data.`}),(0,Q.jsx)(`div`,{className:`mt-1`,children:e===`disabled`?(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to delete your account.`}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(a,{variant:`dangerOutline`,onClick:()=>o(!0),disabled:s.isPending||c,className:`self-start`,children:`Delete My Account`}),c&&(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})})]}),(0,Q.jsx)(ie,{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 kn({title:e,subtitle:t,benefits:n,ctaLabel:r,ctaLeftIcon:i,onAction:o}){return(0,Q.jsx)(X,{title:e,subtitle:t,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`ul`,{className:`space-y-3`,children:n.map(({icon:e,text:t})=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,Q.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,Q.jsx)(a,{variant:`primary`,size:`regular`,leftIcon:i,onClick:o,className:`self-start`,children:r})]})})}function An(){return We()?(0,Q.jsx)(kn,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:h,text:`Push notifications`},{icon:en,text:`Biometric login`},{icon:tn,text:`Native haptics`},{icon:Ft,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,Q.jsx)(Ft,{size:16}),onAction:()=>{st(),kt()}}):null}async function jn(){if(!K())return[];let e=window.vellum;return e?.hotkeys?e.hotkeys.get():[]}async function Mn(e,t){if(!K())return;let n=window.vellum;n?.hotkeys&&await n.hotkeys.set(e,t)}function Nn(e){if(!K())return()=>{};let t=window.vellum;return t?.hotkeys?t.hotkeys.onChange(e):()=>{}}var Pn={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:`/`},Fn=new Set([`MetaLeft`,`MetaRight`,`ControlLeft`,`ControlRight`,`AltLeft`,`AltRight`,`ShiftLeft`,`ShiftRight`]),In=e=>{let t=e.code;return Fn.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:Pn[t]??null},Ln=e=>{let t=In(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(`+`)},Rn=(e,t,n)=>n===``?null:e.find(e=>e.key!==t&&e.accelerator===n)??null,zn=[{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 Bn({hotkey:e,recording:t,conflictLabel:n,onStartRecording:r,onCancelRecording:i,onReset:o,onRemove:s}){let c=e.accelerator===``,l=e.override!==null;return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-body-medium-lighter text-[var(--content-default)]`,children:e.label}),n!==null&&(0,Q.jsxs)(`div`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:[`Already used by `,n]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Recording… press a shortcut, or Esc to cancel`}):c?(0,Q.jsx)(`span`,{className:`text-body-small-default italic text-[var(--content-disabled)]`,children:`Disabled`}):(0,Q.jsx)(ne,{accelerator:e.accelerator}),t?(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,onClick:i,children:`Cancel`}):(0,Q.jsx)(a,{variant:`outlined`,size:`compact`,onClick:r,"aria-label":`Record shortcut for ${e.label}`,children:`Record`}),(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,disabled:!l,leftIcon:(0,Q.jsx)(ut,{className:`h-3.5 w-3.5`}),onClick:o,"aria-label":`Reset ${e.label} to default`}),(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,disabled:c,leftIcon:(0,Q.jsx)(P,{className:`h-3.5 w-3.5`}),onClick:s,"aria-label":`Remove ${e.label} binding`})]})]})}function Vn(){let[e,t]=(0,Z.useState)([]),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),o=(0,Z.useCallback)(()=>{jn().then(t)},[]);(0,Z.useEffect)(()=>(o(),Nn(t)),[o]);let s=(0,Z.useCallback)(()=>{r(null),a(null)},[]);(0,Z.useEffect)(()=>{if(n===null)return;let t=t=>{if(t.preventDefault(),t.stopPropagation(),t.code===`Escape`){s();return}let r=Ln(t);if(r===null)return;let i=Rn(e,n,r);if(i!==null){a({key:n,label:i.label});return}Mn(n,r).then(o),s()};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[n,e,o,s]);let c=(0,Z.useCallback)(e=>{a(null),r(e)},[]),l=(0,Z.useCallback)(t=>{let n=Rn(e,t,e.find(e=>e.key===t)?.defaultAccelerator??``);if(n!==null){r(null),a({key:t,label:n.label});return}s(),Mn(t,null).then(o)},[e,o,s]),u=(0,Z.useCallback)(e=>{s(),Mn(e,``).then(o)},[o,s]),d=(0,Z.useMemo)(()=>zn.map(t=>({...t,commands:e.filter(e=>e.rebindable&&e.scope===t.scope)})).filter(e=>e.commands.length>0),[e]);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[i!==null&&(0,Q.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,Q.jsxs)(p,{bordered:!0,children:[(0,Q.jsxs)(`div`,{className:`mb-2`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-emphasised text-[var(--content-default)]`,children:e.title}),(0,Q.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e.description})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.commands.map(e=>(0,Q.jsx)(Bn,{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 Hn(){if(!K())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function Un(e){if(!K())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function Wn(){let e=ct.useValue();if(Ke())return null;let t=Ue()?`Cmd`:`Ctrl`;return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Composer`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(B,{checked:e,onChange:ct.save,label:`Send with ${t}+Enter`,helperText:`When enabled, Enter inserts a new line and ${t}+Enter sends.`})})]})}function Gn(){let[e,t]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{Hn().then(t)},[]);let n=async e=>{t(e);try{await Un(e)}catch{t(!e)}};return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Launch at Login`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Automatically start Vellum when you log in to your Mac.`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(B,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})]})}function Kn({open:e,onClose:t}){return(0,Q.jsx)(V.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(V.Content,{size:`lg`,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{children:`Preferences`}),(0,Q.jsx)(V.Description,{children:`Customize shortcuts and how Vellum behaves on this device.`})]}),(0,Q.jsx)(V.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[K()&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Keyboard Shortcuts`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Customize the shortcuts for Vellum's commands.`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(Vn,{})})]}),(0,Q.jsx)(Wn,{}),K()&&(0,Q.jsx)(Gn,{})]})})]})})}function qn(e){return e===`preview`?`preview`:`stable`}function Jn(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 Yn(e){return e.source_release_version?`Stable ${e.source_release_version}`:e.snapshot_name}function Xn(e){return e.filter(e=>e.ready_to_use)}function Zn(e){return e?.feature_enabled===!1}function Qn({assistantId:e,onComplete:t}){let n=Y.use.previewChannel(),r=l(),[i,a]=(0,Z.useState)(),[o,s]=(0,Z.useState)(!1),[c,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(`restore_backup`),[h,g]=(0,Z.useState)(``),v=Nt({path:{assistant_id:e}}),y=jt({path:{assistant_id:e}}),b=Et({path:{id:e}}),{data:x,isLoading:C,isError:w}=u({...v,enabled:n,retry:!1}),T=x?.preview_backups??[],E=(0,Z.useMemo)(()=>Xn(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(St()),j=d(wt()),M=qn(x?.current_channel),N=A.isPending||j.isPending,P=N||Zn(x)||!x?.latest_preview_release,I=p===`restore_backup`&&!O;if((0,Z.useEffect)(()=>{a(M===`preview`?`release-channel`:void 0)},[M]),!n)return null;let ee=x?.standard_upgrade_available??!1;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L.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,Q.jsxs)(L.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,Q.jsxs)(L.Trigger,{className:`group justify-between gap-3`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Release Channel`}),x&&(0,Q.jsx)(re,{tone:M===`preview`?`warning`:`neutral`,children:M===`preview`?`Preview`:`Stable`})]}),(0,Q.jsx)(_,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(L.Content,{children:(0,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[C&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),w&&(0,Q.jsx)(F,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),x&&(0,Q.jsxs)(Q.Fragment,{children:[Zn(x)&&(0,Q.jsx)(F,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),M===`stable`?(0,Q.jsx)($n,{status:x,isChangingChannel:N,optInDisabled:P,onOptIn:()=>s(!0)}):(0,Q.jsx)(er,{status:x,isChangingChannel:N,onOptOut:()=>{let e=D;g(e?.snapshot_name??``),m(e?`restore_backup`:ee?`standard_upgrade`:`restore_backup`),f(!0)}})]})]})})]})}),(0,Q.jsx)(nr,{open:o,isPending:A.isPending,previewVersion:x?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await A.mutateAsync({path:{assistant_id:e}});H.success(t.detail||`Preview channel enabled.`),s(!1),k()}catch(e){H.error(ye(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,Q.jsx)(rr,{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`}});H.success(t.detail||`Stable channel enabled.`),f(!1),k()}catch(e){H.error(ye(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>f(!1)})]})}function $n({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(tr,{status:e}),!e.latest_preview_release&&(0,Q.jsx)(F,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,Q.jsx)(a,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(Xe,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function er({status:e,isChangingChannel:t,onOptOut:n}){return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(tr,{status:e}),(0,Q.jsx)(a,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(ut,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function tr({status:e}){return(0,Q.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Stable`}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??`None`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Preview`}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_preview_release?.version??`None`})]})]})}function nr({open:e,isPending:t,previewVersion:n,onConfirm:r,onCancel:i}){return(0,Q.jsx)(V.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,Q.jsxs)(V.Content,{size:`md`,hideCloseButton:t,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{icon:N,children:`Opt in to Preview`}),(0,Q.jsx)(V.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,Q.jsx)(V.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.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,Q.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,Q.jsx)(`li`,{children:`Create and verify a Preview safety backup.`}),(0,Q.jsxs)(`li`,{children:[`Switch to Preview image `,n??`latest`,`.`]}),(0,Q.jsx)(`li`,{children:`Run the normal upgrade path and wait for health.`})]})]})}),(0,Q.jsxs)(V.Footer,{children:[(0,Q.jsx)(a,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,Q.jsx)(a,{variant:`primary`,disabled:t,leftIcon:t?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(Xe,{}),onClick:r,children:t?`Switching...`:`Take Backup and Switch`})]})]})})}function rr({open:e,backups:t,mode:n,selectedSnapshotName:r,isPending:i,restoreModeDisabled:o,standardUpgradeAvailable:s,onModeChange:c,onSnapshotChange:l,onConfirm:u,onCancel:d}){return(0,Q.jsx)(V.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,Q.jsxs)(V.Content,{size:`md`,hideCloseButton:i,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{icon:N,children:`Switch back to Stable`}),(0,Q.jsx)(V.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,Q.jsx)(V.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(te,{value:n,onValueChange:c,disabled:i,"aria-label":`Stable channel return method`,children:[(0,Q.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,Q.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,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[`Safety backup`,(0,Q.jsx)(ae,{value:r,onChange:l,disabled:i,options:t.map(e=>({value:e.snapshot_name,label:`${Yn(e)} - ${Jn(e.created_at)}`}))})]}),n===`restore_backup`&&t.length===0&&!s&&(0,Q.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,Q.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,Q.jsxs)(V.Footer,{children:[(0,Q.jsx)(a,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,Q.jsx)(a,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||o||n===`standard_upgrade`&&!s,leftIcon:i?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(T,{}),onClick:u,children:i?`Switching...`:`Switch to Stable`})]})]})})}function ir({assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:o}){let l=c(),d=u(it()),f=d.data,p=!e.is_local,m=f?.plan_id===`pro`,h=u({...at(),enabled:m}),g=e.machine_size||`small`,_=E(h.data?.max_machine_tier??null),v=(0,Z.useMemo)(()=>k(_,g,(0,Q.jsx)(re,{tone:`positive`,children:`Current`})),[_,g]),y=h.data?.selected_storage_gib??null,[b,C]=(0,Z.useState)(!1),w=_.length>0?_[_.length-1]:null,[N,P]=(0,Z.useState)(null),I=N??w??g,[ee,te]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(null),ne=At({onSuccess:(e,n)=>{H.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),R(null),P(null),C(!1),n.body?.machine_size==null?i():o(t)},onError:e=>{R(j(e,`Failed to resize assistant. Please try again.`))}});if(d.isError&&f==null)return(0,Q.jsx)(X,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Q.jsx)(F,{tone:`error`,children:`Could not load your subscription. Please try again.`})});let z=m&&_.includes(I)&&I!==g?I:null,B=m&&y!=null&&!0,ie=m&&_.length>0&&A(g)<A(_[_.length-1]),U=ne.isPending||r,oe=y==null?t?.disk?.totalMb??null:y*1024,W=t?.disk&&oe!=null?{value:t.disk.usedMb,max:oe,caption:`${Qt(t.disk.usedMb)} of ${Qt(oe)}`}:null,G=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,se=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${Qt(t.memory.currentMb)} of ${Qt(t.memory.maxMb)}`}:null,ce=p?m?B?(0,Q.jsxs)(`button`,{type:`button`,disabled:U,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,Q.jsx)(M,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,disabled:U,onClick:()=>C(!0),children:`Resize`}):(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,onClick:()=>te(`storage`),children:`Resize`}):null,le=p?m?ie?(0,Q.jsxs)(`button`,{type:`button`,disabled:U,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,Q.jsx)(M,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,disabled:U,onClick:()=>C(!0),children:`Resize`}):(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,onClick:()=>te(`machine`),children:`Resize`}):null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,compactAccessory:!0,accessory:(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(T,{}),tooltip:r?`Applying resize…`:`Refresh resource metrics`,"aria-label":`Refresh resource metrics`,disabled:n||r,onClick:()=>void i()}),children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(x,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),ce]}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Storage`}),W?(0,Q.jsx)(Jt,{value:W.value,max:W.max,caption:W.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Unavailable`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(D,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Machine`}),(0,Q.jsx)(re,{tone:`neutral`,children:O[g]})]}),le]}),(0,Q.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`CPU`}),G?(0,Q.jsx)(Jt,{value:G.value,max:G.max,caption:G.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Memory`}),se?(0,Q.jsx)(Jt,{value:se.value,max:se.max,caption:se.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,Q.jsx)(V.Root,{open:ee!=null,onOpenChange:e=>{e||te(null)},children:(0,Q.jsxs)(V.Content,{size:`sm`,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{children:`Upgrade to Pro`}),(0,Q.jsx)(V.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,Q.jsxs)(V.Footer,{children:[(0,Q.jsx)(a,{variant:`ghost`,onClick:()=>te(null),children:`Cancel`}),(0,Q.jsx)(a,{onClick:()=>{te(null),l(`${J.settings.usage}?tab=billing&adjust_plan=1`)},children:`Upgrade`})]})]})}),(0,Q.jsx)(V.Root,{open:b,onOpenChange:e=>{e||(C(!1),P(null),R(null))},children:(0,Q.jsxs)(V.Content,{size:`sm`,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{icon:D,children:`Resize Assistant`}),(0,Q.jsx)(V.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,Q.jsx)(V.Body,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[_.length===0?(0,Q.jsx)(F,{tone:`warning`,children:`No machine tier configured. Visit the community for help.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:`Machine Size`}),(0,Q.jsx)(ae,{options:v,value:I,onChange:P,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),B?(0,Q.jsx)(F,{tone:`info`,children:`Storage will be expanded to ${y} GB.`}):(0,Q.jsx)(F,{tone:`neutral`,children:`Storage will not change.`}),L&&(0,Q.jsx)(F,{tone:`error`,children:L})]})}),(0,Q.jsxs)(V.Footer,{className:`items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:[`Need more?`,` `,(0,Q.jsx)(s,{to:`${J.settings.usage}?tab=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,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(a,{variant:`ghost`,onClick:()=>{C(!1),P(null),R(null)},children:`Cancel`}),(0,Q.jsx)(a,{disabled:z==null&&!B||U,leftIcon:U?(0,Q.jsx)(S,{className:`animate-spin`}):void 0,onClick:()=>{R(null);let t={};z!=null&&(t.machine_size=z),B&&y!=null&&(t.storage_gib=y),ne.mutate({path:{id:e.id},body:t})},children:L?`Retry`:`Apply`})]})]})]})})]})}function ar({assistantId:e}){let t=c(),[n,r]=(0,Z.useState)(!1),[i,o]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,Q.jsx)(Mt,{open:n,isPending:i,onConfirm:async()=>{o(!0);let n=await It(e);if(n.ok){r(!1),t(n.nextRoute,{replace:!0});return}H.error(n.error),o(!1),r(!1)},onCancel:()=>r(!1)})]})}function or(){let e=nt(),t=Gt.useValue();return pt(e)?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Show tips`}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Occasional tips in the sidebar that highlight features you haven't tried yet.`})]}),(0,Q.jsx)(B,{checked:t,onChange:t=>{Gt.save(t),t||lt(`settings`,`dont_show_again`,e)},"aria-label":`Show tips`})]}):null}var sr=`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 cr(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...sr].sort()}function lr(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 ur(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function dr(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 fr({value:e,onChange:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),u=(0,Z.useMemo)(()=>cr().map(e=>lr(e)).filter(e=>e!==null),[]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{a(n.trim().toLowerCase())},200);return()=>window.clearTimeout(e)},[n]),(0,Z.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,Z.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,Z.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,Q.jsxs)(`div`,{ref:c,className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Closest city`}),(0,Q.jsxs)(`div`,{className:`relative w-full md:max-w-[280px]`,children:[(0,Q.jsx)(z,{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,Q.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,Q.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,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-body-medium-default`,children:t.city}),t.region&&(0,Q.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:t.region})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(`span`,{children:ur(t.identifier)}),(0,Q.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,Q.jsx)($t,{}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Time zone`}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:dr(e)})]})]})}function pr(){let e=he.use.activeAssistantId(),[i,a]=(0,Z.useState)(()=>n(`timezone`,``)),o=(0,Z.useRef)(e);(0,Z.useEffect)(()=>{o.current=e},[e]);let s=(0,Z.useRef)(!1),c=(0,Z.useRef)(null),l=(0,Z.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,q.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,Z.useEffect)(()=>{l.current=u}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Timezone`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Used when displaying times and scheduling reminders.`}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(fr,{value:i,onChange:e=>{a(e),t(`timezone`,e),u(e)}})})]})}var mr=[[`Mon`,0],[`Tue`,1],[`Wed`,2],[`Thu`,3],[`Fri`,4],[`Sat`,5],[`Sun`,6]];function hr(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 gr(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 _r(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function vr(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:hr(t),windowEnd:hr(n)}}function yr({assistantId:e}){let t=l(),{data:n,isLoading:r,isError:i}=u(bt({path:{id:e}})),o=(0,Z.useMemo)(()=>vr(n),[n]),[s,c]=(0,Z.useState)(null),f=s??o,p=s!==null,m=(0,Z.useMemo)(()=>_r(),[]),[h,g]=(0,Z.useState)(null),_=h??f.daysOfMonth.join(`, `),v=d({mutationFn:async t=>{let{data:n}=await ze({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,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading update window settings...`]}):i?(0,Q.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,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(B,{checked:f.enabled,onChange:e=>y({enabled:e}),label:`Automatic updates`,helperText:`Update automatically during a configured time window`}),f.enabled&&(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Frequency`}),(0,Q.jsx)(`div`,{className:`max-w-[400px]`,children:(0,Q.jsx)(R,{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,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Day(s) of week`}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:mr.map(([e,t])=>(0,Q.jsx)(a,{variant:`outlined`,size:`compact`,active:f.daysOfWeek.includes(t),onClick:()=>b(t),children:e},t))})]}),f.frequency===`monthly`&&(0,Q.jsx)(z,{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,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:[`Update window`,m?` (${m})`:``]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(z,{type:`time`,value:f.windowStart,onChange:e=>y({windowStart:e.target.value})}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`to`}),(0,Q.jsx)(z,{type:`time`,value:f.windowEnd,onChange:e=>y({windowEnd:e.target.value})})]})]})]}),(0,Q.jsx)(a,{variant:`primary`,leftIcon:v.isPending?(0,Q.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:gr(f.windowStart),end:gr(f.windowEnd)}}}),H.success(`Auto-update policy saved.`),c(null),g(null),t.invalidateQueries({queryKey:Ht({path:{id:e}})})}catch{H.error(`Failed to save policy. Please try again.`)}},disabled:v.isPending||!p,children:`Save policy`})]})}function br({assistantId:e,open:t,onClose:n}){return(0,Q.jsx)(V.Root,{open:t,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(V.Content,{size:`md`,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{children:`Update Window`}),(0,Q.jsx)(V.Description,{children:`Configure when automatic updates are applied.`})]}),(0,Q.jsx)(V.Body,{children:(0,Q.jsx)(yr,{assistantId:e})})]})})}function xr(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`)return t}}function Sr({open:e,onOpenChange:t}){let n=l(),[r,i]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(``),[c,u]=(0,Z.useState)(null),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(e),p=()=>n.invalidateQueries({queryKey:Qe()}),m=e=>{Le({path:{id:e}}).catch(()=>void 0).finally(()=>void p())},h=Wt({onSuccess:e=>{if(!f.current){m(e.factor_id);return}i(e)},onError:e=>{let n=xr(e);n===`no_workos_account`?H.error(`Two-factor authentication is only available for Vellum platform accounts.`):n===`throttled`||n===`workos_rate_limited`?H.error(`Too many attempts. Try again in a minute.`):n===`factor_limit_reached`?H.error(`An authenticator app is already set up. Remove it before adding another.`):H.error(`Failed to start setup. Please try again.`),t(!1)}}),g=Vt({onSuccess:e=>{e.valid?(d.current=!0,H.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=xr(e);if(n===`challenge_already_verified`){d.current=!0,H.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,Z.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(()=>H.success(`Setup key copied.`)).catch(()=>H.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,Q.jsx)(V.Root,{open:e,onOpenChange:_,children:(0,Q.jsxs)(V.Content,{size:`sm`,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{children:`Set up authenticator app`}),(0,Q.jsx)(V.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,Q.jsx)(V.Body,{children:r===null?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Q.jsx)(S,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,Q.jsxs)(`form`,{className:`flex flex-col items-center gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,Q.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,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Can't scan it? Enter this setup key manually:`}),(0,Q.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,Q.jsx)(`span`,{className:`break-all text-left`,children:r.secret}),(0,Q.jsx)(b,{className:`h-3.5 w-3.5 shrink-0`})]})]}),(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Q.jsx)(`label`,{htmlFor:`totp-code`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:`6-digit code`}),(0,Q.jsx)(z,{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,Q.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--system-negative-strong)]`,children:c})]})]})}),(0,Q.jsxs)(V.Footer,{children:[(0,Q.jsx)(a,{variant:`outlined`,onClick:()=>_(!1),disabled:g.isPending,children:`Cancel`}),(0,Q.jsx)(a,{onClick:y,disabled:r===null||o.length!==6||g.isPending,children:g.isPending?`Verifying…`:`Verify`})]})]})})}function Cr(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function wr(){let e=l(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(null),o=u({...dt()}),s=o.data??[],c=()=>e.invalidateQueries({queryKey:Qe()}),d=yt({onSuccess:()=>{H.success(`Authenticator app removed.`),c()},onError:e=>{if(xr(e)===`factor_not_found`){c();return}H.error(`Failed to remove the authenticator app. Please try again.`)}});return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.isPending?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-body-medium-default`,children:`Loading authenticator apps…`})]}):o.isError?(0,Q.jsxs)(F,{tone:`error`,children:[`Couldn't load your authenticator apps.`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`cursor-pointer underline`,onClick:()=>void o.refetch(),children:`Try again`})]}):s.length===0?(0,Q.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,Q.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:s.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(Ft,{className:`h-5 w-5 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Authenticator app`}),(0,Q.jsxs)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:[e.user,e.created_at?` · Added ${Cr(e.created_at)}`:``]})]})]}),(0,Q.jsx)(a,{variant:`dangerOutline`,onClick:()=>i(e),disabled:d.isPending,children:`Remove`})]},e.id))}),!o.isPending&&!o.isError&&s.length===0&&(0,Q.jsx)(a,{onClick:()=>n(!0),className:`self-start`,children:`Add authenticator app`}),(0,Q.jsx)(Sr,{open:t,onOpenChange:n}),(0,Q.jsx)(ie,{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 $=class extends Error{code;constructor(e,t){super(t),this.name=`TeleportError`,this.code=e}},Tr=`local`,Er=`docker`,Dr=`vellum`;function Or(e){switch((e??``).toLowerCase()){case Tr:return`local`;case Er:return`docker`;case Dr:return`managed`;default:return`other`}}function kr(e){let t=Or(e);return t===`managed`?`local`:t===`local`?`platform`:null}function Ar(e){switch(e){case`docker`:return`Move to Docker`;case`platform`:return`Move to Cloud (Platform)`;case`local`:return`Move to Local`}}function jr(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 Mr(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 Nr(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 Pr(e){let t=de(e);if(!t)throw new $(`local_assistant_not_found`,`Assistant ${e.assistantId} has no resolved local gateway.`);return`${window.location.origin}${t}`}async function Fr(e,t){let n=await U(e.assistantId),r=await fetch(`${t}/auth/token`,{method:`POST`,headers:{Authorization:`Bearer ${n}`}});if(!r.ok)throw new $(`not_signed_in`,`Gateway token request failed (HTTP ${r.status}).`);let{token:i}=await r.json();return i}async function Ir(e,t){let n=Pr(e),r=await Fr(e,n),i=await fetch(`${n}/v1/migrations/export`,{method:`POST`,headers:{Authorization:`Bearer ${r}`}});if(!i.ok)throw new $(`export_failed`,`Export failed (HTTP ${i.status}).`);return Nr(i,t)}async function Lr(e,t){let n=Pr(e),r=await Fr(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 $(`import_failed`,`Import failed (HTTP ${i.status}).`);let a=await Br(i);if(a&&a.success===!1)throw new $(`import_failed`,a.error??`Import reported failure`)}async function Rr(e,t){let{data:n,response:r}=await q.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 $(`export_failed`,`Export failed (HTTP ${i}).`);let a=n?.job_id;if(!a)throw new $(`export_failed`,`Export accepted but no job ID was returned.`);return a}async function zr(e,t){let{data:n,response:r}=await q.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 $(`export_job_failed`,`Job status check failed (HTTP ${i})`);let a=n;if(a?.status===`failed`)throw new $(`export_job_failed`,a.error??`Export job failed`);return a?.status??`processing`}async function Br(e){try{return await e.json()}catch{return null}}var Vr=new Set([500,502,503,504]),Hr=3,Ur=e=>new Promise(t=>setTimeout(t,e));async function Wr(e,t=new Set){for(let n=0;n<=Hr;n++){let{response:r,data:i,error:a}=await e(),o=r?.status??0;if(n<Hr&&Vr.has(o)&&!t.has(o)){await Ur(2**n*1e3);continue}return{status:o,data:i,error:a}}throw new $(`unknown`,`Unexpected retry loop exit`)}async function Gr(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 Wr(()=>q.post({url:`/v1/migrations/signed-url/`,body:n,throwOnError:!1}),new Set([404,503]));if(r===503||r===404)throw new $(`export_failed`,`Signed URL uploads are not available — the platform may not support this feature yet.`);if(r!==201)throw new $(`export_failed`,`Migration request failed (HTTP ${r}).`);let a=i;return{url:a.url,bundleKey:a.bundle_key,expiresAt:a.expires_at}}async function Kr(e,t){let{status:n,data:r,error:i}=await Wr(()=>q.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=Mr(i);if(e)throw new $(`version_mismatch`,e)}if(n!==200&&n!==201)throw new $(`import_failed`,`Migration request failed (HTTP ${n}).`);return r.url}async function qr(e,t,n){for(let r=0;r<=Hr;r++){let i=await Jr(e,t,n);if(r<Hr&&Vr.has(i)){await Ur(2**r*1e3),n?.(0);continue}if(i<200||i>=300)throw new $(`export_failed`,`Bundle upload failed (HTTP ${i}).`);return}}function Jr(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 $(`export_failed`,`Bundle upload failed.`)),a.ontimeout=()=>i(new $(`export_timed_out`,`Bundle upload timed out.`)),a.send(t)})}async function Yr(e,t){for(let n=0;n<=Hr;n++){let r=await fetch(e,{method:`GET`});if(n<Hr&&Vr.has(r.status)){await Ur(2**n*1e3),t?.(0);continue}if(!r.ok)throw new $(`import_failed`,`Bundle download failed (HTTP ${r.status}).`);return Nr(r,t)}throw new $(`import_failed`,`Unexpected retry loop exit`)}async function Xr(e){let{status:t,data:n,error:r}=await Wr(()=>q.post({url:`/v1/migrations/import-from-gcs/`,body:{bundle_key:e},throwOnError:!1}));return{status:t,body:n??r??null}}async function Zr(e){let{status:t,data:n}=await Wr(()=>q.get({url:`/v1/migrations/jobs/{job_id}/`,path:{job_id:e},throwOnError:!1}));if(t!==200)throw new $(`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,$r=36e5,ei=5*6e4,ti=30,ni=e=>new Promise(t=>setTimeout(t,e));function ri(){let e=c(),t=G(),n=kr(t?.cloud),[i,a]=(0,Z.useState)({kind:`idle`}),[o,s]=(0,Z.useState)(!1),l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),d=(0,Z.useCallback)(e=>{a({kind:`transferring`,step:e,progress:null})},[]),f=(0,Z.useCallback)(e=>{a(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,Z.useCallback)(async()=>{if(!(!t||!n)){u.current={id:t.assistantId,kind:Or(t.cloud)===`managed`?`managed`:`local`,createdFresh:!1};try{if(n===`platform`)await ii(t,d,f,l);else if(n===`local`)await ai(t,d,f,l);else throw new $(`unknown`,`Unsupported teleport destination.`);a({kind:`verifying`})}catch(e){a({kind:`failed`,error:`Teleport failed: ${e instanceof $||e instanceof Error?e.message:`Teleport failed.`}`}),r(e,{context:`teleport-execute`}),await si(l.current,u.current,`teleport-execute-cleanup`),l.current=null}}},[t,n,d,f]),m=(0,Z.useCallback)(()=>s(!0),[]),h=(0,Z.useCallback)(()=>s(!1),[]),g=(0,Z.useCallback)(()=>{s(!1),p()},[p]),_=(0,Z.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,Z.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),Se(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&&It(n.id).then(e=>{e.ok||r(Error(e.error),{context:`teleport-retire-source`})}),_(),e(J.assistant,{replace:!0})})()},[e,_]),cancelTeleport:(0,Z.useCallback)(()=>{let e=l.current,t=u.current;l.current=null,u.current=null,a({kind:`idle`}),si(e,t,`teleport-cancel-retire-target`)},[]),reset:_}}async function ii(e,t,n,r){t(`Exporting assistant data...`);let i=await Ir(e,n);t(`Resolving organization...`);let a=await li();t(`Checking for existing assistant...`);let o=(await Ie({query:{hosting:`platform`},throwOnError:!1})).data?.results?.[0];if(o)throw new $(`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 Gr(e.resources?.runtimeVersion);await qr(s.url,i,n),t(`Setting up cloud assistant...`);let c=await He(void 0,`create`);if(!c.ok)throw new $(`import_failed`,`Failed to set up the cloud assistant.`);if(c.status===200)throw new $(`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 me({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:fe(),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 ui(l),t(`Importing data to cloud...`);let u=await Xr(s.bundleKey);if(u.status<200||u.status>=300){let e=u.body;throw new $(`import_failed`,e?.error??`Import failed (HTTP ${u.status}).`)}if(u.status===202){let e=u.body?.job_id;if(!e)throw new $(`import_failed`,`Import accepted but no job ID returned.`);await di(e)}else{let e=u.body;if(e&&e.success===!1)throw new $(`import_failed`,e.error??`Import reported failure.`)}}async function ai(e,t,n,r){t(`Preparing export...`);let i=await Gr(await ci(e.assistantId),`runtime`);t(`Exporting cloud data...`);let a=await Rr(e.assistantId,i.url);await fi(e.assistantId,a),t(`Preparing local assistant...`);let{assistant:o,createdFresh:s}=await pi();r.current={id:o.assistantId,kind:`local`,createdFresh:s};let c=await oi(o,s);if(!c)throw new $(`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 Kr(i.bundleKey,c);t(`Downloading data...`);let u=await Yr(l,n);t(`Importing data...`),await hi(o,u),await W(e.assistantId)}async function oi(e,t){if(e.resources?.runtimeVersion)return e.resources.runtimeVersion;if(t)return(await Kt())?.version??void 0}async function si(e,t,n){if(e?.createdFresh){let t=await It(e.id);t.ok||r(Error(t.error),{context:n})}t&&await W(t.id)}async function ci(e){let t=await Ve(e);return t.ok?t.data.version??void 0:void 0}async function li(){let e=xe.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=xe.getState().organizations,n=Ce();if(n&&t.some(e=>e.id===n))return n;if(t.length===0)throw new $(`no_organizations`,`No organizations found for this account.`);if(t.length>1)throw new $(`multiple_organizations`,`Multiple organizations found — please select one in account settings first.`);let r=t[0].id;return xe.getState().setCurrentOrganizationId(r),r}async function ui(e){let t=Date.now();for(;Date.now()-t<ei;){let{data:t,response:n}=await Be({path:{id:e},throwOnError:!1});if(n?.ok&&t?.state===`active`)return;await ni(Qr)}}async function di(e){let t=Date.now();for(;Date.now()-t<$r;){await ni(Qr);let t=await Zr(e);if(t.status===`complete`)return;if(t.status===`failed`)throw new $(`import_failed`,t.error??`Import job failed`)}throw new $(`import_failed`,`Import timed out after 60 minutes.`)}async function fi(e,t){let n=Date.now();for(;Date.now()-n<$r;)if(await ni(Qr),await zr(e,t)===`complete`)return;throw new $(`export_timed_out`,`Export timed out.`)}async function pi(){let e=await oe(void 0,void 0);if(!e.ok)throw new $(`local_assistant_not_found`,e.error??`Could not create a local assistant.`);await le();let t=e.assistantId?pe().find(t=>t.assistantId===e.assistantId):mi();if(!t)throw new $(`local_assistant_not_found`,`Could not find or create a local assistant.`);return{assistant:t,createdFresh:!0}}function mi(){return pe().slice().sort((e,t)=>(t.hatchedAt??``).localeCompare(e.hatchedAt??``))[0]}async function hi(e,t){let n;for(let r=0;r<ti;r++)try{await Lr(e,t);return}catch(e){n=e,await ni(1e3)}throw n instanceof Error?n:new $(`import_failed`,`Import failed.`)}function gi(){let e=ri(),{destination:t,phase:n}=e;return t?(0,Q.jsxs)(X,{title:`Teleport`,subtitle:`Move your assistant to a different hosting environment.`,children:[n.kind===`idle`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:jr(t)}),(0,Q.jsx)(a,{variant:`outlined`,className:`self-start`,onClick:e.requestTeleport,children:Ar(t)})]}),n.kind===`transferring`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.progress==null&&(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:n.step})]}),n.progress!=null&&(0,Q.jsx)(I,{value:n.progress,"aria-label":`Teleport progress`,className:`max-w-[240px]`})]}),n.kind===`verifying`&&(0,Q.jsx)(F,{tone:`success`,icon:(0,Q.jsx)(y,{className:`h-4 w-4`}),title:`Transfer complete — verify your new assistant is working.`,actions:(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(a,{variant:`primary`,onClick:e.confirmAndSwitch,children:`Confirm & Switch`}),(0,Q.jsx)(a,{variant:`outlined`,onClick:e.cancelTeleport,children:`Cancel`})]})}),n.kind===`failed`&&(0,Q.jsx)(F,{tone:`error`,title:n.error,actions:(0,Q.jsx)(a,{variant:`outlined`,onClick:e.reset,children:`Try Again`})}),(0,Q.jsx)(ie,{open:e.confirmOpen,title:Ar(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 _i(){let{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:s}=Xt(),l=Y.use.multiPlatformAssistant(),u=Y.use.teleport(),d=Y.use.accountMfa(),f=Ge.use.settingsSleepPolicy(),p=we(),m=c(),h=Tt(),g=Tt({platformHostedOnly:!0}),_=Rt(),v=ht({assistantId:e?.id??null,enabled:g===`full`&&_}),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=o();(0,Z.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&&!ce()?null:e,E=G(),D=ce()&&!!e&&!!E&&se(E),O=D,k=D&&!ue(),A=g===`full`&&!!T||k&&!!e;(0,Z.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`,P=K()||!Ke();return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[v.status&&v.mode!==`inactive`&&(0,Q.jsx)($e,{status:v.status,mode:v.mode,isAcknowledging:v.isAcknowledging,acknowledgeError:v.acknowledgeError?.message??null,onAcknowledge:()=>void v.acknowledge(),onReviewWorkspaceData:()=>void m(`${J.workspace}?sort=size`),onUpgradeStorage:g===`full`?()=>void m(`${J.settings.usage}?tab=billing&adjust_plan=1`):null}),(0,Q.jsxs)(gn,{assistant:_?T:null,showHandles:p&&h===`full`,children:[(0,Q.jsx)(pr,{}),d&&h!==`gated`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Two-Factor Authentication`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Require a code from an authenticator app when you sign in.`}),(0,Q.jsx)(`div`,{className:`mt-1`,children:h===`disabled`?(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to manage two-factor authentication.`}):(0,Q.jsx)(wr,{})})]})]})]}),(0,Q.jsx)(X,{title:`Version`,subtitle:`Manage your assistant's software version and updates.`,accessory:g===`full`&&T?(0,Q.jsx)(a,{variant:`outlined`,onClick:()=>b(!0),children:`Update Window`}):void 0,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g===`full`&&T&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(En,{assistantId:T.id,currentVersion:j,releaseChannel:T.release_channel,onUpgradeComplete:()=>{i()}}),(0,Q.jsx)(Qn,{assistantId:T.id,onComplete:()=>{i()}})]}),k&&e&&(0,Q.jsx)(Dn,{assistantId:e.id,currentVersion:j,onUpgradeComplete:()=>{i()}}),!A&&e&&(0,Q.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Q.jsx)(Zt,{version:j,loading:n&&!e.current_release_version,assistantId:e.id??null})]}),g===`disabled`&&!k&&(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to manage software updates.`})]})}),g===`full`&&T&&(0,Q.jsx)(br,{assistantId:T.id,open:y,onClose:()=>b(!1)}),g===`full`&&e&&(0,Q.jsx)(ir,{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:s}),g===`disabled`&&(0,Q.jsx)(X,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to manage compute resources.`})}),(0,Q.jsx)(X,{title:`Preferences`,subtitle:`Customize how Vellum looks and behaves on this device.`,accessory:P?(0,Q.jsx)(a,{variant:`outlined`,onClick:()=>S(!0),children:`Customize`}):void 0,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(nn,{}),(0,Q.jsx)(or,{})]})}),P&&(0,Q.jsx)(Kn,{open:x,onClose:()=>S(!1)}),u&&K()&&(0,Q.jsx)(gi,{}),(0,Q.jsx)(An,{}),g===`full`&&T&&f&&(0,Q.jsx)(X,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Q.jsx)(Sn,{assistantId:T.id})}),g===`disabled`&&f&&(0,Q.jsx)(X,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to manage sleep policy.`})}),l&&(0,Q.jsx)(yn,{}),(M||N)&&(0,Q.jsx)(X,{variant:`danger`,title:`Danger Zone`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[M&&(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Retire Assistant`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently retire this assistant and delete all associated data.`}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(h===`full`||O)&&T?(0,Q.jsx)(ar,{assistantId:T.id}):(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to retire this assistant.`})})]}),M&&N&&(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsx)(On,{})]})})]})}export{_i 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-anSemq95.js";import{t as i}from"./react-DJZBPgpf.js";import{t as a}from"./button-CW7wKp2r.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-Cf8bWrcq.js";import{t as m}from"./createLucideIcon-Bjb-Kuq7.js";import{t as h}from"./bell-V9BYKY__.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-CVw67M2Z.js";import{t as x}from"./hard-drive-DVmyHlZR.js";import{t as S}from"./loader-circle-Ck8fq3yv.js";import{t as C}from"./monitor-BFX2ySFb.js";import{t as w}from"./moon-h3xmz34k.js";import{t as T}from"./refresh-cw-cau3ebz1.js";import{a as E,c as D,i as O,o as k,s as A,t as j}from"./resize-errors-ORrW5M6r.js";import{t as M}from"./sparkles-BK3KXCjl.js";import{t as N}from"./triangle-alert-CnjNKhNx.js";import{t as P}from"./x-CswtfvgS.js";import{t as F}from"./notice-CvJ7MBx5.js";import{t as I}from"./progress-bar-DrwFU9Ti.js";import{M as ee,N as te,i as L,j as R,n as ne}from"./src-BT0gNVcT.js";import{t as re}from"./tag-CJyI1Y2J.js";import{t as z}from"./input-D3MhHg0d.js";import{t as B}from"./toggle-Ca1aoG-l.js";import{t as V}from"./modal-D_Y2RPD5.js";import{n as H}from"./toast-zHo1wvF9.js";import{t as ie}from"./confirm-dialog-DxBl6zcI.js";import{t as ae}from"./dropdown-DQozlhbb.js";import{E as U,O as oe,S as W,c as G,d as se,f as ce,g as le,h as ue,i as de,nt as fe,r as pe,x as me}from"./local-mode-Dydd46cS.js";import{t as K}from"./is-electron-y5bNUVyG.js";import{n as he}from"./resolved-assistants-store-DdHm-7v4.js";import{r as ge,t as _e}from"./semver-DIkpaM51.js";import{n as ve,r as ye,t as be}from"./api-errors-CoE1wFl2.js";import{D as xe,S as Se,T as Ce,a as we,b as Te,g as Ee,h as De,k as Oe,n as ke,u as Ae,v as je,y as Me}from"./auth-store-quPkF_4z.js";import{t as q}from"./client.gen-DVfIRXUZ.js";import{C as Ne,H as Pe,M as Fe,T as Ie,Vt as Le,X as Re,Z as ze,j as Be}from"./sdk.gen-BCFkwLHb.js";import{a as Ve,o as He}from"./api-Jhp24FhR.js";import{u as J}from"./routes-D4ff4ONd.js";import{i as Ue,o as We}from"./platform-detection-BBQ3eUv5.js";import{t as Y}from"./client-feature-flag-store-BOcAh56y.js";import{t as Ge}from"./assistant-feature-flag-store-Bh-_qc7v.js";import{t as Ke}from"./pointer-DcD0Nt7Z.js";import{t as qe}from"./proxy-DoUA9mK6.js";import{t as Je}from"./AnimatePresence-C42g9zWi.js";import{t as Ye}from"./use-reduced-motion-DpK6cQN-.js";import{$o as Xe,Ba as Ze,Ca as Qe,Dt as $e,Gn as et,H as tt,Hn as nt,J as rt,Ji as it,Ki as at,Kn as ot,M as st,N as ct,Nn as lt,Qo as ut,Sa as dt,Uo as ft,Vn as pt,Wn as mt,Xt as ht,Yr as gt,_i as _t,ai as vt,ba as yt,bi as bt,bn as xt,di as St,do as Ct,fi as wt,fo as Tt,gi as Et,ha as Dt,hi as Ot,j as kt,ma as At,mi as jt,or as Mt,pi as Nt,qn as Pt,qo as Ft,sr as It,ua as Lt,uo as Rt,va as zt,vi as Bt,xa as Vt,xi as Ht,xs as Ut,ya as Wt,zn as Gt}from"./index-Ck1SrvnM.js";import{t as X}from"./detail-card-CAHT277C.js";import{t as Kt}from"./app-info-DDWMarAq.js";import{t as qt}from"./environment-store-geigPfHz.js";import{a as Jt,i as Yt,n as Xt,r as Zt,t as Qt}from"./assistant-status-panel-3QLq7XTz.js";import{t as $t}from"./settings-divider-RhnS0iml.js";var en=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`}]]),tn=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`}]]),Z=e(i(),1),Q=f();function nn(){let e=Y.use.velvet(),{theme:t,setThemePreference:n}=xt(),r=[{value:`system`,label:`System`,icon:(0,Q.jsx)(C,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,Q.jsx)(ft,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,Q.jsx)(w,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,Q.jsx)(Ut,{className:`h-4 w-4`})}]:[]];return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Theme`}),(0,Q.jsx)(`div`,{className:`mt-2 max-w-[360px]`,children:(0,Q.jsx)(R,{ariaLabel:`Theme`,value:t,onChange:n,items:r})})]})}var rn=De,an=`Please choose a different handle.`;async function on(e,t){let{data:n,error:r,response:i}=await Fe({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:ye(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}=Te(r,`handle`,rn.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=Te(r,`handle`,an);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:ye(r,i,`Failed to save handle.`)}}async function sn(e,t,n){let{data:r,error:i,response:a}=await Ne({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(ve(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new be(a.status,a.status===429?`Too many checks — try again in a moment.`:ye(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function cn(e){return/\d{2,}$/.test(e)}var ln=300,un=1400;function dn({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:o,onSaved:s,saveSuccessToast:c,fieldId:l}){let[u,d]=(0,Z.useState)(e),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[_,y]=(0,Z.useState)(`idle`),[b,x]=(0,Z.useState)(null),C=Ye(),w=(0,Z.useRef)(null),T=(0,Z.useMemo)(()=>u.trim().toLowerCase(),[u]),E=T===e.toLowerCase();(0,Z.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)}},ln);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?rn[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,Z.useCallback)(async()=>{if(!k)return;y(`saving`),x(null);let e=await o(T);if(e.kind===`ok`){y(`saved`),s(e.data),H.success(c),window.setTimeout(()=>y(`idle`),un);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),H.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,Q.jsx)(Je,{mode:`wait`,initial:!1,children:(0,Q.jsxs)(qe.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,Q.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,Q.jsx)(g,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,Q.jsx)(v,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),M=(()=>{switch(_){case`saving`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(S,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Saving…`]});case`saved`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Saved`]});default:return`Save`}})();return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(z,{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,Q.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,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(a,{variant:`primary`,size:`compact`,onClick:A,disabled:!k,"aria-live":`polite`,"data-testid":`${l}-save`,children:M})})]})}function fn({initial:e,onSaved:t}){let n=ke.use.refreshSession(),r=cn(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,Z.useCallback)(async e=>await Me({username:e}),[]),a=(0,Z.useCallback)((e,t)=>Ee(e,t),[]),o=(0,Z.useCallback)(e=>{t(e),n()},[t,n]);return(0,Q.jsx)(dn,{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 pn({assistant:e,onSaved:t}){let n=e.handle??``,r=u({...gt({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,Z.useCallback)(async t=>await on(e.id,t),[e.id]),c=(0,Z.useCallback)((t,n)=>sn(e.id,t,n),[e.id]);return i?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(z,{label:`Assistant handle`,value:n,readOnly:!0,disabled:!0,leftIcon:(0,Q.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,Q.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,Q.jsx)(s,{to:`${J.settings.ai}?release=1#email`,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`,children:`release the subdomain`}),` `,`first.`]})]}):(0,Q.jsx)(dn,{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 mn(){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-3 w-72 animate-pulse rounded bg-[var(--surface-muted)]`})]}),(0,Q.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`div`,{className:`h-3 w-60 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-7 w-16 animate-pulse rounded-md bg-[var(--surface-muted)]`})]}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Loading your profile…`})]})}function hn(){return(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`})}function gn({assistant:e,showHandles:t=!0,children:n}={}){let r=ke.use.user?.()?.email??null;return(0,Q.jsx)(X,{title:`Profile`,subtitle:`Manage your account details and preferences.`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[r&&(0,Q.jsx)(`div`,{className:`max-w-[420px]`,children:(0,Q.jsx)(z,{label:`Email`,value:r,disabled:!0,readOnly:!0})}),t&&(0,Q.jsxs)(Q.Fragment,{children:[r&&(0,Q.jsx)(hn,{}),(0,Q.jsx)(_n,{assistant:e})]}),n!=null&&(0,Q.jsxs)(Q.Fragment,{children:[(r||t)&&(0,Q.jsx)(hn,{}),n]})]})})}function _n({assistant:e}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(null),a=Ye(),[o,s]=(0,Z.useState)(e??null);return(0,Z.useEffect)(()=>{s(e??null)},[e]),(0,Z.useEffect)(()=>{let e=!1;return je().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),r?(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,Q.jsxs)(qe.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,Q.jsx)(fn,{initial:t,onSaved:n}),o&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsx)(pn,{assistant:o,onSaved:s})]})]}):(0,Q.jsx)(mn,{})}var vn=vt({query:{hosting:`platform`}});function yn(){let e=rt(),t=u(vn),n=t.data?.results??[];return t.isPending||n.length<2?null:(0,Q.jsx)(X,{title:`Switch Assistant`,subtitle:`Choose which assistant is active for this account.`,children:(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>{let n=t.id===e;return(0,Q.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,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(C,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:t.name||`Unnamed`}),t.status!==`active`&&(0,Q.jsx)(re,{tone:`warning`,children:t.status})]})})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:n?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,Q.jsx)(g,{className:`h-4 w-4`}),`Active`]}):(0,Q.jsx)(a,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{Oe(t.id),H.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var bn=[{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 xn(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 Sn({assistantId:e}){let t=l(),n=qt.use.isNonProduction(),r=(0,Z.useMemo)(()=>bn.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:o,isError:s}=u(_t({path:{id:e}})),c=(0,Z.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[d,f]=(0,Z.useState)(null),p=d??c,m=d!==null,h=Dt({onSuccess:()=>{H.success(`Sleep policy saved.`),f(null),t.invalidateQueries({queryKey:Bt({path:{id:e}})})},onError:()=>{H.error(`Failed to save sleep policy. Please try again.`)}});return o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):s?(0,Q.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,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Idle timeout`}),(0,Q.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,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:r.map(e=>(0,Q.jsx)(a,{variant:`outlined`,active:p===e.seconds,onClick:()=>f(e.seconds),children:e.label},e.seconds))}),(0,Q.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,xn(p)]})]}),m&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(a,{variant:`primary`,leftIcon:h.isPending?(0,Q.jsx)(S,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,Q.jsx)(a,{variant:`outlined`,onClick:()=>f(null),disabled:h.isPending,children:`Cancel`})]})]})}function Cn(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var wn=3e3;function Tn({version:e,assistantId:t}){let{onTap:n,message:r}=Yt(t);return(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.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,Q.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:r})]})}function En({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=Ge.use.rollbackEnabled(),o=Y.use.previewChannel(),s=l(),c=et(n,o),f=c===`preview`,[p,m]=(0,Z.useState)(!1),h=(0,Z.useRef)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[C,w]=(0,Z.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),H.success(b?`Rollback complete — assistant is healthy.`:`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),r?.()}),!1):wn;u({...Ot({path:{id:e}}),refetchInterval:p?e=>E(e.state.data?.current_release_version):!1});let{data:D,isLoading:O}=u(Lt({query:{channel:c}})),k=D?.find(e=>e.is_stable!==!1)??D?.[0],A=g??k?.version??null,j=(0,Z.useMemo)(()=>{if(!i||!A||!t)return!1;let e=ge(A),n=ge(t);return!e||!n?!1:_e(e,n)<0},[i,A,t]),M=(0,Z.useMemo)(()=>{if(!A)return!1;if(!t)return!0;let e=ge(A),n=ge(t);if(!e||!n)return A!==t;let r=_e(e,n);return i?r!==0:r>0},[i,A,t]),N=d({mutationFn:async t=>{let{data:n}=await Re({path:{id:e},body:t,throwOnError:!0});return n}}),P=d({mutationFn:async t=>{let{data:n}=await Pe({path:{id:e},body:t,throwOnError:!0});return n}});return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Q.jsx)(Tn,{version:t,assistantId:e})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:f?`Preview release`:M?j?`Rollback to`:`Update to`:`Selected`}),(0,Q.jsx)(`span`,{className:`block min-w-0`,children:O?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(S,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):D&&D.length>0?i?(0,Q.jsx)(ae,{value:A??``,onChange:e=>_(e===k?.version?null:e),disabled:p||N.isPending||P.isPending,options:D.map(e=>({value:e.version,label:Cn(e,t,k?.version)}))}):(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:k?Cn(k,t,k.version):`—`}):`No releases available`})]})]}),(0,Q.jsx)(a,{variant:j?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:N.isPending||P.isPending||p?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.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,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Using Preview releases.`,` `,(0,Q.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,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:C??`You are already on this version.`}),(0,Q.jsx)(ie,{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,H.success(e.detail||`Rollback to ${t} initiated.`)}else{let e=await N.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){H.warning(e.detail);return}h.current=e.version??t??null,H.success(e.detail||`Update to ${e.version??t??`latest`} initiated.`)}x(j),m(!0),s.invalidateQueries({queryKey:Et({path:{id:e}})})}catch{H.error(j?`Failed to trigger rollback. Please try again.`:`Failed to trigger update. Please try again.`)}},onCancel:()=>y(!1)})]})}function Dn({assistantId:e,currentVersion:t,onUpgradeComplete:n}){let[r,i]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),{data:c,isLoading:l}=u(Lt({query:{stable:!0,limit:100}})),d=(0,Z.useMemo)(()=>mt(c),[c]),f=d?.version,p=t?ot(t,f):!!f,m=Pt({assistantId:e,targetVersion:f});return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Q.jsx)(Tn,{version:t,assistantId:e})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Update to`}),(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:l?`Loading...`:f&&d?Cn(d,t,f):`No releases available`})]})]}),(0,Q.jsx)(a,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(T,{}),onClick:()=>i(!0),disabled:m.isPending||l||!f||!p,children:m.isPending?`Updating...`:f?`Update to ${f}`:`Update`}),o&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:o}),!o&&!p&&f&&!l&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:`You are already on this version.`}),(0,Q.jsx)(ie,{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`}.`),H.success(`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),n?.()}catch(e){H.error(e instanceof Error?e.message:`Failed to trigger update. Please try again.`)}},onCancel:()=>i(!1)})]})}function On(){let e=Tt({platformHostedOnly:!0}),t=Ct(),n=ke.use.user()?.id??null,r=ke.use.logout(),[i,o]=(0,Z.useState)(!1),s=zt({onSuccess:async()=>{H.success(`Account deletion requested. You will be logged out shortly.`),Ae(n),await r(),Ze(J.account.login)},onError:()=>{H.error(`Failed to request account deletion. Please try again.`)}}),c=e===`full`&&t;return(0,Z.useEffect)(()=>{c&&i&&o(!1)},[c,i]),e===`gated`?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Delete Account`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently delete your account and all associated data.`}),(0,Q.jsx)(`div`,{className:`mt-1`,children:e===`disabled`?(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to delete your account.`}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(a,{variant:`dangerOutline`,onClick:()=>o(!0),disabled:s.isPending||c,className:`self-start`,children:`Delete My Account`}),c&&(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})})]}),(0,Q.jsx)(ie,{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 kn({title:e,subtitle:t,benefits:n,ctaLabel:r,ctaLeftIcon:i,onAction:o}){return(0,Q.jsx)(X,{title:e,subtitle:t,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`ul`,{className:`space-y-3`,children:n.map(({icon:e,text:t})=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,Q.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,Q.jsx)(a,{variant:`primary`,size:`regular`,leftIcon:i,onClick:o,className:`self-start`,children:r})]})})}function An(){return We()?(0,Q.jsx)(kn,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:h,text:`Push notifications`},{icon:en,text:`Biometric login`},{icon:tn,text:`Native haptics`},{icon:Ft,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,Q.jsx)(Ft,{size:16}),onAction:()=>{st(),kt()}}):null}async function jn(){if(!K())return[];let e=window.vellum;return e?.hotkeys?e.hotkeys.get():[]}async function Mn(e,t){if(!K())return;let n=window.vellum;n?.hotkeys&&await n.hotkeys.set(e,t)}function Nn(e){if(!K())return()=>{};let t=window.vellum;return t?.hotkeys?t.hotkeys.onChange(e):()=>{}}var Pn={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:`/`},Fn=new Set([`MetaLeft`,`MetaRight`,`ControlLeft`,`ControlRight`,`AltLeft`,`AltRight`,`ShiftLeft`,`ShiftRight`]),In=e=>{let t=e.code;return Fn.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:Pn[t]??null},Ln=e=>{let t=In(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(`+`)},Rn=(e,t,n)=>n===``?null:e.find(e=>e.key!==t&&e.accelerator===n)??null,zn=[{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 Bn({hotkey:e,recording:t,conflictLabel:n,onStartRecording:r,onCancelRecording:i,onReset:o,onRemove:s}){let c=e.accelerator===``,l=e.override!==null;return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-body-medium-lighter text-[var(--content-default)]`,children:e.label}),n!==null&&(0,Q.jsxs)(`div`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:[`Already used by `,n]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Recording… press a shortcut, or Esc to cancel`}):c?(0,Q.jsx)(`span`,{className:`text-body-small-default italic text-[var(--content-disabled)]`,children:`Disabled`}):(0,Q.jsx)(ne,{accelerator:e.accelerator}),t?(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,onClick:i,children:`Cancel`}):(0,Q.jsx)(a,{variant:`outlined`,size:`compact`,onClick:r,"aria-label":`Record shortcut for ${e.label}`,children:`Record`}),(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,disabled:!l,leftIcon:(0,Q.jsx)(ut,{className:`h-3.5 w-3.5`}),onClick:o,"aria-label":`Reset ${e.label} to default`}),(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,disabled:c,leftIcon:(0,Q.jsx)(P,{className:`h-3.5 w-3.5`}),onClick:s,"aria-label":`Remove ${e.label} binding`})]})]})}function Vn(){let[e,t]=(0,Z.useState)([]),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),o=(0,Z.useCallback)(()=>{jn().then(t)},[]);(0,Z.useEffect)(()=>(o(),Nn(t)),[o]);let s=(0,Z.useCallback)(()=>{r(null),a(null)},[]);(0,Z.useEffect)(()=>{if(n===null)return;let t=t=>{if(t.preventDefault(),t.stopPropagation(),t.code===`Escape`){s();return}let r=Ln(t);if(r===null)return;let i=Rn(e,n,r);if(i!==null){a({key:n,label:i.label});return}Mn(n,r).then(o),s()};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[n,e,o,s]);let c=(0,Z.useCallback)(e=>{a(null),r(e)},[]),l=(0,Z.useCallback)(t=>{let n=Rn(e,t,e.find(e=>e.key===t)?.defaultAccelerator??``);if(n!==null){r(null),a({key:t,label:n.label});return}s(),Mn(t,null).then(o)},[e,o,s]),u=(0,Z.useCallback)(e=>{s(),Mn(e,``).then(o)},[o,s]),d=(0,Z.useMemo)(()=>zn.map(t=>({...t,commands:e.filter(e=>e.rebindable&&e.scope===t.scope)})).filter(e=>e.commands.length>0),[e]);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[i!==null&&(0,Q.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,Q.jsxs)(p,{bordered:!0,children:[(0,Q.jsxs)(`div`,{className:`mb-2`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-emphasised text-[var(--content-default)]`,children:e.title}),(0,Q.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e.description})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.commands.map(e=>(0,Q.jsx)(Bn,{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 Hn(){if(!K())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function Un(e){if(!K())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function Wn(){let e=ct.useValue();if(Ke())return null;let t=Ue()?`Cmd`:`Ctrl`;return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Composer`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(B,{checked:e,onChange:ct.save,label:`Send with ${t}+Enter`,helperText:`When enabled, Enter inserts a new line and ${t}+Enter sends.`})})]})}function Gn(){let[e,t]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{Hn().then(t)},[]);let n=async e=>{t(e);try{await Un(e)}catch{t(!e)}};return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Launch at Login`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Automatically start Vellum when you log in to your Mac.`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(B,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})]})}function Kn({open:e,onClose:t}){return(0,Q.jsx)(V.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(V.Content,{size:`lg`,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{children:`Preferences`}),(0,Q.jsx)(V.Description,{children:`Customize shortcuts and how Vellum behaves on this device.`})]}),(0,Q.jsx)(V.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[K()&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Keyboard Shortcuts`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Customize the shortcuts for Vellum's commands.`}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(Vn,{})})]}),(0,Q.jsx)(Wn,{}),K()&&(0,Q.jsx)(Gn,{})]})})]})})}function qn(e){return e===`preview`?`preview`:`stable`}function Jn(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 Yn(e){return e.source_release_version?`Stable ${e.source_release_version}`:e.snapshot_name}function Xn(e){return e.filter(e=>e.ready_to_use)}function Zn(e){return e?.feature_enabled===!1}function Qn({assistantId:e,onComplete:t}){let n=Y.use.previewChannel(),r=l(),[i,a]=(0,Z.useState)(),[o,s]=(0,Z.useState)(!1),[c,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(`restore_backup`),[h,g]=(0,Z.useState)(``),v=Nt({path:{assistant_id:e}}),y=jt({path:{assistant_id:e}}),b=Et({path:{id:e}}),{data:x,isLoading:C,isError:w}=u({...v,enabled:n,retry:!1}),T=x?.preview_backups??[],E=(0,Z.useMemo)(()=>Xn(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(St()),j=d(wt()),M=qn(x?.current_channel),N=A.isPending||j.isPending,P=N||Zn(x)||!x?.latest_preview_release,I=p===`restore_backup`&&!O;if((0,Z.useEffect)(()=>{a(M===`preview`?`release-channel`:void 0)},[M]),!n)return null;let ee=x?.standard_upgrade_available??!1;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L.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,Q.jsxs)(L.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,Q.jsxs)(L.Trigger,{className:`group justify-between gap-3`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Release Channel`}),x&&(0,Q.jsx)(re,{tone:M===`preview`?`warning`:`neutral`,children:M===`preview`?`Preview`:`Stable`})]}),(0,Q.jsx)(_,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(L.Content,{children:(0,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[C&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),w&&(0,Q.jsx)(F,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),x&&(0,Q.jsxs)(Q.Fragment,{children:[Zn(x)&&(0,Q.jsx)(F,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),M===`stable`?(0,Q.jsx)($n,{status:x,isChangingChannel:N,optInDisabled:P,onOptIn:()=>s(!0)}):(0,Q.jsx)(er,{status:x,isChangingChannel:N,onOptOut:()=>{let e=D;g(e?.snapshot_name??``),m(e?`restore_backup`:ee?`standard_upgrade`:`restore_backup`),f(!0)}})]})]})})]})}),(0,Q.jsx)(nr,{open:o,isPending:A.isPending,previewVersion:x?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await A.mutateAsync({path:{assistant_id:e}});H.success(t.detail||`Preview channel enabled.`),s(!1),k()}catch(e){H.error(ye(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,Q.jsx)(rr,{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`}});H.success(t.detail||`Stable channel enabled.`),f(!1),k()}catch(e){H.error(ye(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>f(!1)})]})}function $n({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(tr,{status:e}),!e.latest_preview_release&&(0,Q.jsx)(F,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,Q.jsx)(a,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(Xe,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function er({status:e,isChangingChannel:t,onOptOut:n}){return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(tr,{status:e}),(0,Q.jsx)(a,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(ut,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function tr({status:e}){return(0,Q.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Stable`}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??`None`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Preview`}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_preview_release?.version??`None`})]})]})}function nr({open:e,isPending:t,previewVersion:n,onConfirm:r,onCancel:i}){return(0,Q.jsx)(V.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,Q.jsxs)(V.Content,{size:`md`,hideCloseButton:t,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{icon:N,children:`Opt in to Preview`}),(0,Q.jsx)(V.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,Q.jsx)(V.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.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,Q.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,Q.jsx)(`li`,{children:`Create and verify a Preview safety backup.`}),(0,Q.jsxs)(`li`,{children:[`Switch to Preview image `,n??`latest`,`.`]}),(0,Q.jsx)(`li`,{children:`Run the normal upgrade path and wait for health.`})]})]})}),(0,Q.jsxs)(V.Footer,{children:[(0,Q.jsx)(a,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,Q.jsx)(a,{variant:`primary`,disabled:t,leftIcon:t?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(Xe,{}),onClick:r,children:t?`Switching...`:`Take Backup and Switch`})]})]})})}function rr({open:e,backups:t,mode:n,selectedSnapshotName:r,isPending:i,restoreModeDisabled:o,standardUpgradeAvailable:s,onModeChange:c,onSnapshotChange:l,onConfirm:u,onCancel:d}){return(0,Q.jsx)(V.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,Q.jsxs)(V.Content,{size:`md`,hideCloseButton:i,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{icon:N,children:`Switch back to Stable`}),(0,Q.jsx)(V.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,Q.jsx)(V.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(te,{value:n,onValueChange:c,disabled:i,"aria-label":`Stable channel return method`,children:[(0,Q.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,Q.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,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[`Safety backup`,(0,Q.jsx)(ae,{value:r,onChange:l,disabled:i,options:t.map(e=>({value:e.snapshot_name,label:`${Yn(e)} - ${Jn(e.created_at)}`}))})]}),n===`restore_backup`&&t.length===0&&!s&&(0,Q.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,Q.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,Q.jsxs)(V.Footer,{children:[(0,Q.jsx)(a,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,Q.jsx)(a,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||o||n===`standard_upgrade`&&!s,leftIcon:i?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(T,{}),onClick:u,children:i?`Switching...`:`Switch to Stable`})]})]})})}function ir({assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:o}){let l=c(),d=u(it()),f=d.data,p=!e.is_local,m=f?.plan_id===`pro`,h=u({...at(),enabled:m}),g=e.machine_size||`small`,_=E(h.data?.max_machine_tier??null),v=(0,Z.useMemo)(()=>k(_,g,(0,Q.jsx)(re,{tone:`positive`,children:`Current`})),[_,g]),y=h.data?.selected_storage_gib??null,[b,C]=(0,Z.useState)(!1),w=_.length>0?_[_.length-1]:null,[N,P]=(0,Z.useState)(null),I=N??w??g,[ee,te]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(null),ne=At({onSuccess:(e,n)=>{H.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),R(null),P(null),C(!1),n.body?.machine_size==null?i():o(t)},onError:e=>{R(j(e,`Failed to resize assistant. Please try again.`))}});if(d.isError&&f==null)return(0,Q.jsx)(X,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Q.jsx)(F,{tone:`error`,children:`Could not load your subscription. Please try again.`})});let z=m&&_.includes(I)&&I!==g?I:null,B=m&&y!=null&&!0,ie=m&&_.length>0&&A(g)<A(_[_.length-1]),U=ne.isPending||r,oe=y==null?t?.disk?.totalMb??null:y*1024,W=t?.disk&&oe!=null?{value:t.disk.usedMb,max:oe,caption:`${Qt(t.disk.usedMb)} of ${Qt(oe)}`}:null,G=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,se=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${Qt(t.memory.currentMb)} of ${Qt(t.memory.maxMb)}`}:null,ce=p?m?B?(0,Q.jsxs)(`button`,{type:`button`,disabled:U,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,Q.jsx)(M,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,disabled:U,onClick:()=>C(!0),children:`Resize`}):(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,onClick:()=>te(`storage`),children:`Resize`}):null,le=p?m?ie?(0,Q.jsxs)(`button`,{type:`button`,disabled:U,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,Q.jsx)(M,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,disabled:U,onClick:()=>C(!0),children:`Resize`}):(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,onClick:()=>te(`machine`),children:`Resize`}):null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,compactAccessory:!0,accessory:(0,Q.jsx)(a,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,Q.jsx)(S,{className:`animate-spin`}):(0,Q.jsx)(T,{}),tooltip:r?`Applying resize…`:`Refresh resource metrics`,"aria-label":`Refresh resource metrics`,disabled:n||r,onClick:()=>void i()}),children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(x,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),ce]}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Storage`}),W?(0,Q.jsx)(Jt,{value:W.value,max:W.max,caption:W.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Unavailable`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(D,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Machine`}),(0,Q.jsx)(re,{tone:`neutral`,children:O[g]})]}),le]}),(0,Q.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`CPU`}),G?(0,Q.jsx)(Jt,{value:G.value,max:G.max,caption:G.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Memory`}),se?(0,Q.jsx)(Jt,{value:se.value,max:se.max,caption:se.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(S,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,Q.jsx)(V.Root,{open:ee!=null,onOpenChange:e=>{e||te(null)},children:(0,Q.jsxs)(V.Content,{size:`sm`,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{children:`Upgrade to Pro`}),(0,Q.jsx)(V.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,Q.jsxs)(V.Footer,{children:[(0,Q.jsx)(a,{variant:`ghost`,onClick:()=>te(null),children:`Cancel`}),(0,Q.jsx)(a,{onClick:()=>{te(null),l(`${J.settings.usage}?tab=billing&adjust_plan=1`)},children:`Upgrade`})]})]})}),(0,Q.jsx)(V.Root,{open:b,onOpenChange:e=>{e||(C(!1),P(null),R(null))},children:(0,Q.jsxs)(V.Content,{size:`sm`,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{icon:D,children:`Resize Assistant`}),(0,Q.jsx)(V.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,Q.jsx)(V.Body,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[_.length===0?(0,Q.jsx)(F,{tone:`warning`,children:`No machine tier configured. Visit the community for help.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:`Machine Size`}),(0,Q.jsx)(ae,{options:v,value:I,onChange:P,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),B?(0,Q.jsx)(F,{tone:`info`,children:`Storage will be expanded to ${y} GB.`}):(0,Q.jsx)(F,{tone:`neutral`,children:`Storage will not change.`}),L&&(0,Q.jsx)(F,{tone:`error`,children:L})]})}),(0,Q.jsxs)(V.Footer,{className:`items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:[`Need more?`,` `,(0,Q.jsx)(s,{to:`${J.settings.usage}?tab=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,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(a,{variant:`ghost`,onClick:()=>{C(!1),P(null),R(null)},children:`Cancel`}),(0,Q.jsx)(a,{disabled:z==null&&!B||U,leftIcon:U?(0,Q.jsx)(S,{className:`animate-spin`}):void 0,onClick:()=>{R(null);let t={};z!=null&&(t.machine_size=z),B&&y!=null&&(t.storage_gib=y),ne.mutate({path:{id:e.id},body:t})},children:L?`Retry`:`Apply`})]})]})]})})]})}function ar({assistantId:e}){let t=c(),[n,r]=(0,Z.useState)(!1),[i,o]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,Q.jsx)(Mt,{open:n,isPending:i,onConfirm:async()=>{o(!0);let n=await It(e);if(n.ok){r(!1),t(n.nextRoute,{replace:!0});return}H.error(n.error),o(!1),r(!1)},onCancel:()=>r(!1)})]})}function or(){let e=nt(),t=Gt.useValue();return pt(e)?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Show tips`}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Occasional tips in the sidebar that highlight features you haven't tried yet.`})]}),(0,Q.jsx)(B,{checked:t,onChange:t=>{Gt.save(t),t||lt(`settings`,`dont_show_again`,e)},"aria-label":`Show tips`})]}):null}var sr=`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 cr(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...sr].sort()}function lr(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 ur(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function dr(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 fr({value:e,onChange:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),u=(0,Z.useMemo)(()=>cr().map(e=>lr(e)).filter(e=>e!==null),[]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{a(n.trim().toLowerCase())},200);return()=>window.clearTimeout(e)},[n]),(0,Z.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,Z.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,Z.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,Q.jsxs)(`div`,{ref:c,className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Closest city`}),(0,Q.jsxs)(`div`,{className:`relative w-full md:max-w-[280px]`,children:[(0,Q.jsx)(z,{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,Q.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,Q.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,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-body-medium-default`,children:t.city}),t.region&&(0,Q.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:t.region})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(`span`,{children:ur(t.identifier)}),(0,Q.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,Q.jsx)($t,{}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Time zone`}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:dr(e)})]})]})}function pr(){let e=he.use.activeAssistantId(),[i,a]=(0,Z.useState)(()=>n(`timezone`,``)),o=(0,Z.useRef)(e);(0,Z.useEffect)(()=>{o.current=e},[e]);let s=(0,Z.useRef)(!1),c=(0,Z.useRef)(null),l=(0,Z.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,q.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,Z.useEffect)(()=>{l.current=u}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Timezone`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Used when displaying times and scheduling reminders.`}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(fr,{value:i,onChange:e=>{a(e),t(`timezone`,e),u(e)}})})]})}var mr=[[`Mon`,0],[`Tue`,1],[`Wed`,2],[`Thu`,3],[`Fri`,4],[`Sat`,5],[`Sun`,6]];function hr(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 gr(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 _r(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function vr(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:hr(t),windowEnd:hr(n)}}function yr({assistantId:e}){let t=l(),{data:n,isLoading:r,isError:i}=u(bt({path:{id:e}})),o=(0,Z.useMemo)(()=>vr(n),[n]),[s,c]=(0,Z.useState)(null),f=s??o,p=s!==null,m=(0,Z.useMemo)(()=>_r(),[]),[h,g]=(0,Z.useState)(null),_=h??f.daysOfMonth.join(`, `),v=d({mutationFn:async t=>{let{data:n}=await ze({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,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading update window settings...`]}):i?(0,Q.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,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(B,{checked:f.enabled,onChange:e=>y({enabled:e}),label:`Automatic updates`,helperText:`Update automatically during a configured time window`}),f.enabled&&(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Frequency`}),(0,Q.jsx)(`div`,{className:`max-w-[400px]`,children:(0,Q.jsx)(R,{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,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Day(s) of week`}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:mr.map(([e,t])=>(0,Q.jsx)(a,{variant:`outlined`,size:`compact`,active:f.daysOfWeek.includes(t),onClick:()=>b(t),children:e},t))})]}),f.frequency===`monthly`&&(0,Q.jsx)(z,{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,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:[`Update window`,m?` (${m})`:``]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(z,{type:`time`,value:f.windowStart,onChange:e=>y({windowStart:e.target.value})}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`to`}),(0,Q.jsx)(z,{type:`time`,value:f.windowEnd,onChange:e=>y({windowEnd:e.target.value})})]})]})]}),(0,Q.jsx)(a,{variant:`primary`,leftIcon:v.isPending?(0,Q.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:gr(f.windowStart),end:gr(f.windowEnd)}}}),H.success(`Auto-update policy saved.`),c(null),g(null),t.invalidateQueries({queryKey:Ht({path:{id:e}})})}catch{H.error(`Failed to save policy. Please try again.`)}},disabled:v.isPending||!p,children:`Save policy`})]})}function br({assistantId:e,open:t,onClose:n}){return(0,Q.jsx)(V.Root,{open:t,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(V.Content,{size:`md`,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{children:`Update Window`}),(0,Q.jsx)(V.Description,{children:`Configure when automatic updates are applied.`})]}),(0,Q.jsx)(V.Body,{children:(0,Q.jsx)(yr,{assistantId:e})})]})})}function xr(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`)return t}}function Sr({open:e,onOpenChange:t}){let n=l(),[r,i]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(``),[c,u]=(0,Z.useState)(null),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(e),p=()=>n.invalidateQueries({queryKey:Qe()}),m=e=>{Le({path:{id:e}}).catch(()=>void 0).finally(()=>void p())},h=Wt({onSuccess:e=>{if(!f.current){m(e.factor_id);return}i(e)},onError:e=>{let n=xr(e);n===`no_workos_account`?H.error(`Two-factor authentication is only available for Vellum platform accounts.`):n===`throttled`||n===`workos_rate_limited`?H.error(`Too many attempts. Try again in a minute.`):n===`factor_limit_reached`?H.error(`An authenticator app is already set up. Remove it before adding another.`):H.error(`Failed to start setup. Please try again.`),t(!1)}}),g=Vt({onSuccess:e=>{e.valid?(d.current=!0,H.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=xr(e);if(n===`challenge_already_verified`){d.current=!0,H.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,Z.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(()=>H.success(`Setup key copied.`)).catch(()=>H.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,Q.jsx)(V.Root,{open:e,onOpenChange:_,children:(0,Q.jsxs)(V.Content,{size:`sm`,children:[(0,Q.jsxs)(V.Header,{children:[(0,Q.jsx)(V.Title,{children:`Set up authenticator app`}),(0,Q.jsx)(V.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,Q.jsx)(V.Body,{children:r===null?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Q.jsx)(S,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,Q.jsxs)(`form`,{className:`flex flex-col items-center gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,Q.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,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Can't scan it? Enter this setup key manually:`}),(0,Q.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,Q.jsx)(`span`,{className:`break-all text-left`,children:r.secret}),(0,Q.jsx)(b,{className:`h-3.5 w-3.5 shrink-0`})]})]}),(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Q.jsx)(`label`,{htmlFor:`totp-code`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:`6-digit code`}),(0,Q.jsx)(z,{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,Q.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--system-negative-strong)]`,children:c})]})]})}),(0,Q.jsxs)(V.Footer,{children:[(0,Q.jsx)(a,{variant:`outlined`,onClick:()=>_(!1),disabled:g.isPending,children:`Cancel`}),(0,Q.jsx)(a,{onClick:y,disabled:r===null||o.length!==6||g.isPending,children:g.isPending?`Verifying…`:`Verify`})]})]})})}function Cr(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function wr(){let e=l(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(null),o=u({...dt()}),s=o.data??[],c=()=>e.invalidateQueries({queryKey:Qe()}),d=yt({onSuccess:()=>{H.success(`Authenticator app removed.`),c()},onError:e=>{if(xr(e)===`factor_not_found`){c();return}H.error(`Failed to remove the authenticator app. Please try again.`)}});return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.isPending?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-body-medium-default`,children:`Loading authenticator apps…`})]}):o.isError?(0,Q.jsxs)(F,{tone:`error`,children:[`Couldn't load your authenticator apps.`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`cursor-pointer underline`,onClick:()=>void o.refetch(),children:`Try again`})]}):s.length===0?(0,Q.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,Q.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:s.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(Ft,{className:`h-5 w-5 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Authenticator app`}),(0,Q.jsxs)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:[e.user,e.created_at?` · Added ${Cr(e.created_at)}`:``]})]})]}),(0,Q.jsx)(a,{variant:`dangerOutline`,onClick:()=>i(e),disabled:d.isPending,children:`Remove`})]},e.id))}),!o.isPending&&!o.isError&&s.length===0&&(0,Q.jsx)(a,{onClick:()=>n(!0),className:`self-start`,children:`Add authenticator app`}),(0,Q.jsx)(Sr,{open:t,onOpenChange:n}),(0,Q.jsx)(ie,{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 $=class extends Error{code;constructor(e,t){super(t),this.name=`TeleportError`,this.code=e}},Tr=`local`,Er=`docker`,Dr=`vellum`;function Or(e){switch((e??``).toLowerCase()){case Tr:return`local`;case Er:return`docker`;case Dr:return`managed`;default:return`other`}}function kr(e){let t=Or(e);return t===`managed`?`local`:t===`local`?`platform`:null}function Ar(e){switch(e){case`docker`:return`Move to Docker`;case`platform`:return`Move to Cloud (Platform)`;case`local`:return`Move to Local`}}function jr(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 Mr(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 Nr(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 Pr(e){let t=de(e);if(!t)throw new $(`local_assistant_not_found`,`Assistant ${e.assistantId} has no resolved local gateway.`);return`${window.location.origin}${t}`}async function Fr(e,t){let n=await U(e.assistantId),r=await fetch(`${t}/auth/token`,{method:`POST`,headers:{Authorization:`Bearer ${n}`}});if(!r.ok)throw new $(`not_signed_in`,`Gateway token request failed (HTTP ${r.status}).`);let{token:i}=await r.json();return i}async function Ir(e,t){let n=Pr(e),r=await Fr(e,n),i=await fetch(`${n}/v1/migrations/export`,{method:`POST`,headers:{Authorization:`Bearer ${r}`}});if(!i.ok)throw new $(`export_failed`,`Export failed (HTTP ${i.status}).`);return Nr(i,t)}async function Lr(e,t){let n=Pr(e),r=await Fr(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 $(`import_failed`,`Import failed (HTTP ${i.status}).`);let a=await Br(i);if(a&&a.success===!1)throw new $(`import_failed`,a.error??`Import reported failure`)}async function Rr(e,t){let{data:n,response:r}=await q.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 $(`export_failed`,`Export failed (HTTP ${i}).`);let a=n?.job_id;if(!a)throw new $(`export_failed`,`Export accepted but no job ID was returned.`);return a}async function zr(e,t){let{data:n,response:r}=await q.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 $(`export_job_failed`,`Job status check failed (HTTP ${i})`);let a=n;if(a?.status===`failed`)throw new $(`export_job_failed`,a.error??`Export job failed`);return a?.status??`processing`}async function Br(e){try{return await e.json()}catch{return null}}var Vr=new Set([500,502,503,504]),Hr=3,Ur=e=>new Promise(t=>setTimeout(t,e));async function Wr(e,t=new Set){for(let n=0;n<=Hr;n++){let{response:r,data:i,error:a}=await e(),o=r?.status??0;if(n<Hr&&Vr.has(o)&&!t.has(o)){await Ur(2**n*1e3);continue}return{status:o,data:i,error:a}}throw new $(`unknown`,`Unexpected retry loop exit`)}async function Gr(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 Wr(()=>q.post({url:`/v1/migrations/signed-url/`,body:n,throwOnError:!1}),new Set([404,503]));if(r===503||r===404)throw new $(`export_failed`,`Signed URL uploads are not available — the platform may not support this feature yet.`);if(r!==201)throw new $(`export_failed`,`Migration request failed (HTTP ${r}).`);let a=i;return{url:a.url,bundleKey:a.bundle_key,expiresAt:a.expires_at}}async function Kr(e,t){let{status:n,data:r,error:i}=await Wr(()=>q.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=Mr(i);if(e)throw new $(`version_mismatch`,e)}if(n!==200&&n!==201)throw new $(`import_failed`,`Migration request failed (HTTP ${n}).`);return r.url}async function qr(e,t,n){for(let r=0;r<=Hr;r++){let i=await Jr(e,t,n);if(r<Hr&&Vr.has(i)){await Ur(2**r*1e3),n?.(0);continue}if(i<200||i>=300)throw new $(`export_failed`,`Bundle upload failed (HTTP ${i}).`);return}}function Jr(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 $(`export_failed`,`Bundle upload failed.`)),a.ontimeout=()=>i(new $(`export_timed_out`,`Bundle upload timed out.`)),a.send(t)})}async function Yr(e,t){for(let n=0;n<=Hr;n++){let r=await fetch(e,{method:`GET`});if(n<Hr&&Vr.has(r.status)){await Ur(2**n*1e3),t?.(0);continue}if(!r.ok)throw new $(`import_failed`,`Bundle download failed (HTTP ${r.status}).`);return Nr(r,t)}throw new $(`import_failed`,`Unexpected retry loop exit`)}async function Xr(e){let{status:t,data:n,error:r}=await Wr(()=>q.post({url:`/v1/migrations/import-from-gcs/`,body:{bundle_key:e},throwOnError:!1}));return{status:t,body:n??r??null}}async function Zr(e){let{status:t,data:n}=await Wr(()=>q.get({url:`/v1/migrations/jobs/{job_id}/`,path:{job_id:e},throwOnError:!1}));if(t!==200)throw new $(`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,$r=36e5,ei=5*6e4,ti=30,ni=e=>new Promise(t=>setTimeout(t,e));function ri(){let e=c(),t=G(),n=kr(t?.cloud),[i,a]=(0,Z.useState)({kind:`idle`}),[o,s]=(0,Z.useState)(!1),l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),d=(0,Z.useCallback)(e=>{a({kind:`transferring`,step:e,progress:null})},[]),f=(0,Z.useCallback)(e=>{a(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,Z.useCallback)(async()=>{if(!(!t||!n)){u.current={id:t.assistantId,kind:Or(t.cloud)===`managed`?`managed`:`local`,createdFresh:!1};try{if(n===`platform`)await ii(t,d,f,l);else if(n===`local`)await ai(t,d,f,l);else throw new $(`unknown`,`Unsupported teleport destination.`);a({kind:`verifying`})}catch(e){a({kind:`failed`,error:`Teleport failed: ${e instanceof $||e instanceof Error?e.message:`Teleport failed.`}`}),r(e,{context:`teleport-execute`}),await si(l.current,u.current,`teleport-execute-cleanup`),l.current=null}}},[t,n,d,f]),m=(0,Z.useCallback)(()=>s(!0),[]),h=(0,Z.useCallback)(()=>s(!1),[]),g=(0,Z.useCallback)(()=>{s(!1),p()},[p]),_=(0,Z.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,Z.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),Se(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&&It(n.id).then(e=>{e.ok||r(Error(e.error),{context:`teleport-retire-source`})}),_(),e(J.assistant,{replace:!0})})()},[e,_]),cancelTeleport:(0,Z.useCallback)(()=>{let e=l.current,t=u.current;l.current=null,u.current=null,a({kind:`idle`}),si(e,t,`teleport-cancel-retire-target`)},[]),reset:_}}async function ii(e,t,n,r){t(`Exporting assistant data...`);let i=await Ir(e,n);t(`Resolving organization...`);let a=await li();t(`Checking for existing assistant...`);let o=(await Ie({query:{hosting:`platform`},throwOnError:!1})).data?.results?.[0];if(o)throw new $(`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 Gr(e.resources?.runtimeVersion);await qr(s.url,i,n),t(`Setting up cloud assistant...`);let c=await He(void 0,`create`);if(!c.ok)throw new $(`import_failed`,`Failed to set up the cloud assistant.`);if(c.status===200)throw new $(`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 me({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:fe(),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 ui(l),t(`Importing data to cloud...`);let u=await Xr(s.bundleKey);if(u.status<200||u.status>=300){let e=u.body;throw new $(`import_failed`,e?.error??`Import failed (HTTP ${u.status}).`)}if(u.status===202){let e=u.body?.job_id;if(!e)throw new $(`import_failed`,`Import accepted but no job ID returned.`);await di(e)}else{let e=u.body;if(e&&e.success===!1)throw new $(`import_failed`,e.error??`Import reported failure.`)}}async function ai(e,t,n,r){t(`Preparing export...`);let i=await Gr(await ci(e.assistantId),`runtime`);t(`Exporting cloud data...`);let a=await Rr(e.assistantId,i.url);await fi(e.assistantId,a),t(`Preparing local assistant...`);let{assistant:o,createdFresh:s}=await pi();r.current={id:o.assistantId,kind:`local`,createdFresh:s};let c=await oi(o,s);if(!c)throw new $(`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 Kr(i.bundleKey,c);t(`Downloading data...`);let u=await Yr(l,n);t(`Importing data...`),await hi(o,u),await W(e.assistantId)}async function oi(e,t){if(e.resources?.runtimeVersion)return e.resources.runtimeVersion;if(t)return(await Kt())?.version??void 0}async function si(e,t,n){if(e?.createdFresh){let t=await It(e.id);t.ok||r(Error(t.error),{context:n})}t&&await W(t.id)}async function ci(e){let t=await Ve(e);return t.ok?t.data.version??void 0:void 0}async function li(){let e=xe.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=xe.getState().organizations,n=Ce();if(n&&t.some(e=>e.id===n))return n;if(t.length===0)throw new $(`no_organizations`,`No organizations found for this account.`);if(t.length>1)throw new $(`multiple_organizations`,`Multiple organizations found — please select one in account settings first.`);let r=t[0].id;return xe.getState().setCurrentOrganizationId(r),r}async function ui(e){let t=Date.now();for(;Date.now()-t<ei;){let{data:t,response:n}=await Be({path:{id:e},throwOnError:!1});if(n?.ok&&t?.state===`active`)return;await ni(Qr)}}async function di(e){let t=Date.now();for(;Date.now()-t<$r;){await ni(Qr);let t=await Zr(e);if(t.status===`complete`)return;if(t.status===`failed`)throw new $(`import_failed`,t.error??`Import job failed`)}throw new $(`import_failed`,`Import timed out after 60 minutes.`)}async function fi(e,t){let n=Date.now();for(;Date.now()-n<$r;)if(await ni(Qr),await zr(e,t)===`complete`)return;throw new $(`export_timed_out`,`Export timed out.`)}async function pi(){let e=await oe(void 0,void 0);if(!e.ok)throw new $(`local_assistant_not_found`,e.error??`Could not create a local assistant.`);await le();let t=e.assistantId?pe().find(t=>t.assistantId===e.assistantId):mi();if(!t)throw new $(`local_assistant_not_found`,`Could not find or create a local assistant.`);return{assistant:t,createdFresh:!0}}function mi(){return pe().slice().sort((e,t)=>(t.hatchedAt??``).localeCompare(e.hatchedAt??``))[0]}async function hi(e,t){let n;for(let r=0;r<ti;r++)try{await Lr(e,t);return}catch(e){n=e,await ni(1e3)}throw n instanceof Error?n:new $(`import_failed`,`Import failed.`)}function gi(){let e=ri(),{destination:t,phase:n}=e;return t?(0,Q.jsxs)(X,{title:`Teleport`,subtitle:`Move your assistant to a different hosting environment.`,children:[n.kind===`idle`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:jr(t)}),(0,Q.jsx)(a,{variant:`outlined`,className:`self-start`,onClick:e.requestTeleport,children:Ar(t)})]}),n.kind===`transferring`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.progress==null&&(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:n.step})]}),n.progress!=null&&(0,Q.jsx)(I,{value:n.progress,"aria-label":`Teleport progress`,className:`max-w-[240px]`})]}),n.kind===`verifying`&&(0,Q.jsx)(F,{tone:`success`,icon:(0,Q.jsx)(y,{className:`h-4 w-4`}),title:`Transfer complete — verify your new assistant is working.`,actions:(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(a,{variant:`primary`,onClick:e.confirmAndSwitch,children:`Confirm & Switch`}),(0,Q.jsx)(a,{variant:`outlined`,onClick:e.cancelTeleport,children:`Cancel`})]})}),n.kind===`failed`&&(0,Q.jsx)(F,{tone:`error`,title:n.error,actions:(0,Q.jsx)(a,{variant:`outlined`,onClick:e.reset,children:`Try Again`})}),(0,Q.jsx)(ie,{open:e.confirmOpen,title:Ar(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 _i(){let{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:s}=Xt(),l=Y.use.multiPlatformAssistant(),u=Y.use.teleport(),d=Y.use.accountMfa(),f=Ge.use.settingsSleepPolicy(),p=we(),m=c(),h=Tt(),g=Tt({platformHostedOnly:!0}),_=Rt(),v=ht({assistantId:e?.id??null,enabled:g===`full`&&_}),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=o();(0,Z.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&&!ce()?null:e,E=G(),D=ce()&&!!e&&!!E&&se(E),O=D,k=D&&!ue(),A=g===`full`&&!!T||k&&!!e;(0,Z.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`,P=K()||!Ke();return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[v.status&&v.mode!==`inactive`&&(0,Q.jsx)($e,{status:v.status,mode:v.mode,isAcknowledging:v.isAcknowledging,acknowledgeError:v.acknowledgeError?.message??null,onAcknowledge:()=>void v.acknowledge(),onReviewWorkspaceData:()=>void m(`${J.workspace}?sort=size`),onUpgradeStorage:g===`full`?()=>void m(`${J.settings.usage}?tab=billing&adjust_plan=1`):null}),(0,Q.jsxs)(gn,{assistant:_?T:null,showHandles:p&&h===`full`,children:[(0,Q.jsx)(pr,{}),d&&h!==`gated`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Two-Factor Authentication`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Require a code from an authenticator app when you sign in.`}),(0,Q.jsx)(`div`,{className:`mt-1`,children:h===`disabled`?(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to manage two-factor authentication.`}):(0,Q.jsx)(wr,{})})]})]})]}),(0,Q.jsx)(X,{title:`Version`,subtitle:`Manage your assistant's software version and updates.`,accessory:g===`full`&&T?(0,Q.jsx)(a,{variant:`outlined`,onClick:()=>b(!0),children:`Update Window`}):void 0,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g===`full`&&T&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(En,{assistantId:T.id,currentVersion:j,releaseChannel:T.release_channel,onUpgradeComplete:()=>{i()}}),(0,Q.jsx)(Qn,{assistantId:T.id,onComplete:()=>{i()}})]}),k&&e&&(0,Q.jsx)(Dn,{assistantId:e.id,currentVersion:j,onUpgradeComplete:()=>{i()}}),!A&&e&&(0,Q.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Q.jsx)(Zt,{version:j,loading:n&&!e.current_release_version,assistantId:e.id??null})]}),g===`disabled`&&!k&&(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to manage software updates.`})]})}),g===`full`&&T&&(0,Q.jsx)(br,{assistantId:T.id,open:y,onClose:()=>b(!1)}),g===`full`&&e&&(0,Q.jsx)(ir,{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:s}),g===`disabled`&&(0,Q.jsx)(X,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to manage compute resources.`})}),(0,Q.jsx)(X,{title:`Preferences`,subtitle:`Customize how Vellum looks and behaves on this device.`,accessory:P?(0,Q.jsx)(a,{variant:`outlined`,onClick:()=>S(!0),children:`Customize`}):void 0,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(nn,{}),(0,Q.jsx)(or,{})]})}),P&&(0,Q.jsx)(Kn,{open:x,onClose:()=>S(!1)}),u&&K()&&(0,Q.jsx)(gi,{}),(0,Q.jsx)(An,{}),g===`full`&&T&&f&&(0,Q.jsx)(X,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Q.jsx)(Sn,{assistantId:T.id})}),g===`disabled`&&f&&(0,Q.jsx)(X,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to manage sleep policy.`})}),l&&(0,Q.jsx)(yn,{}),(M||N)&&(0,Q.jsx)(X,{variant:`danger`,title:`Danger Zone`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[M&&(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Retire Assistant`}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently retire this assistant and delete all associated data.`}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(h===`full`||O)&&T?(0,Q.jsx)(ar,{assistantId:T.id}):(0,Q.jsx)(tt,{children:`Log in to the Vellum platform to retire this assistant.`})})]}),M&&N&&(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsx)(On,{})]})})]})}export{_i as GeneralPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./capture-error-anSemq95.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-CW7wKp2r.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-DrwFU9Ti.js";import{O as ee,_ as te,f as u,g as ne,nt as d,rt as re,x as f,y as ie}from"./local-mode-Dydd46cS.js";import{t as p}from"./is-electron-y5bNUVyG.js";import{n as m}from"./resolved-assistants-store-DdHm-7v4.js";import{r as ae}from"./api-errors-CoE1wFl2.js";import{A as oe,B as se,D as ce,L as le,N as h,R as ue,k as g,n as _,z as v}from"./auth-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./capture-error-anSemq95.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-CW7wKp2r.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-DrwFU9Ti.js";import{O as ee,_ as te,f as u,g as ne,nt as d,rt as re,x as f,y as ie}from"./local-mode-Dydd46cS.js";import{t as p}from"./is-electron-y5bNUVyG.js";import{n as m}from"./resolved-assistants-store-DdHm-7v4.js";import{r as ae}from"./api-errors-CoE1wFl2.js";import{A as oe,B as se,D as ce,L as le,N as h,R as ue,k as g,n as _,z as v}from"./auth-store-quPkF_4z.js";import{a as de,o as fe,r as y}from"./api-Jhp24FhR.js";import{u as pe}from"./native-biometric-DG8Pfu_V.js";import{u as b}from"./routes-D4ff4ONd.js";import{m as me,o as he}from"./prefs-CzauL-hH.js";import{r as x,t as S}from"./build-state-rDsVeVLA.js";import{t as C}from"./avatar-bundled-components-ELDcio1Z.js";import{t as w}from"./avatar-svg-compositor-D7Dy9s1k.js";import{Fa as T,Pa as E,hn as D,ja as O}from"./index-Ck1SrvnM.js";import{t as ge}from"./provider-key-BPINSkGG.js";import{t as k}from"./plugin-attribution-meUNq3wV.js";var A=e(r(),1);async function _e(e,t,r){try{await E(e)||await T(e,t),r.invalidateQueries({queryKey:O(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,ve=800,P=3e5,F=null,I=null,L=null;function R(){F=null,I=null,L=null}var ye={initializing:0,provisioning:.33,connecting:.66,ready:1},z=1500,be={initializing:`Getting things ready…`,provisioning:`Setting up your assistant…`,connecting:`Connecting to your assistant…`,ready:`Ready`};function xe(e,t,n){if(e>=t)return t;let r=1-(1-Math.min(1,n/z))**3;return e+(t-e)*r}function Se(){let e=x(S(),{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(),x=c.get(`hosting`),S=c.get(`fail`),T=c.get(k),E=p(),O=u()&&x!==null&&x!==`vellum-cloud`,z=_.use.sessionStatus(),B=O?h(z):z,[V]=(0,A.useState)(()=>L??=j(C)),H=(0,A.useMemo)(()=>{let e=w(C,V.bodyShape,V.eyeStyle,V.color,320);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`},[V]),[U,W]=(0,A.useState)(`initializing`),[G,K]=(0,A.useState)(null),[Ce,q]=(0,A.useState)(!1),[we,Te]=(0,A.useState)(0),[Ee,J]=(0,A.useState)(0),[De,Oe]=(0,A.useState)(0),Y=(0,A.useRef)(U),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,W(e),Oe(e=>e+1)},[]);return(0,A.useEffect)(()=>{if(S!==null){K(`Simulated hatch failure (developer menu → Replay Hatch Failure).`);return}let i=Se();if(i.kind===`redirect`){e(i.to,{replace:!0});return}if(i.kind===`wait`)return;q(!1);let a=!1,o=null,s=null,c=null,l=Date.now(),p,h=!1,C=!1,w=he(),E=t=>{try{me(``)}catch(e){n(e,{context:`onboarding_mark_completed`})}J(1),Q.current=1,X.current=1,W(`ready`),Y.current=`ready`,s=setTimeout(()=>{a||(R(),(async()=>{if(await oe.checkAssistant(),!a){if(pe()){oe.markExpectingFirstMessage(),e(`${b.assistant}?onboarding=1`,{replace:!0});return}if(O){let n=new URLSearchParams;x&&n.set(`hosting`,x),t&&n.set(`assistant`,t),T&&n.set(k,T);let r=n.toString();e(`${b.onboarding.research}${r?`?${r}`:``}`,{replace:!0});return}e(b.onboarding.research,{replace:!0})}})())},ve)},D=e=>_e(e,V,r),A=async()=>{if($(`provisioning`),!O){try{let e=await y(),t=v(e);if(!a&&e.ok&&t.kind===`active`){u()&&f({assistantId:e.data.id,name:e.data.name,cloud:`vellum`,runtimeUrl:d(),hatchedAt:new Date().toISOString(),organizationId:ce.getState().currentOrganizationId??void 0}),E();return}t.kind===`auto_hatch`&&(C=!0)}catch{}if(a)return}if(O){try{F||=ee(void 0,x===`docker`?`docker`:void 0);let e=await F;if(a)return;if(!e.ok){R(),K(e.error??`Failed to hatch local assistant.`);return}await ne(),e.assistantId&&g(e.assistantId),$(`connecting`);let t=!1;for(;!a&&!t;){if(await ie()){re(),await te(),t=!0;break}if(Date.now()-l>=P){R(),K(`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 ge(e.assistantId)}catch(e){n(e,{context:`onboarding_apply_provider_key`})}e.assistantId&&await _.getState().connectLocalAssistant(e.assistantId),e.assistantId&&(m.getState().upsertFromApi({id:e.assistantId,name:e.assistantId,status:`active`,is_local:!0,created:new Date().toISOString()}),g(e.assistantId),D(e.assistantId)),E(e.assistantId)}catch{if(R(),a)return;K(`Failed to hatch local assistant. Check CLI logs for details.`)}return}try{I||=fe(w?{version:w}:void 0);let e=await I;if(I=null,a)return;if(e.ok&&(p=e.data.id),h=e.ok&&e.status===201,!e.ok){if(t(`Onboarding hatch request failed`,{level:`warning`,extra:{status:e.status,error:e.error}}),ue(e.status,e.error)){K(le),q(!0);return}if(!se(e.status)){K(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}j(0)},j=e=>{a||(o=setTimeout(M,e))},M=async()=>{if(!a){if(Date.now()-l>=P){t(`Onboarding hatch wait exceeded timeout`,{level:`warning`,extra:{maxWaitMs:P}}),K(`Your assistant is taking longer than expected. Please try again.`);return}try{let e=await y(p);if(a||p&&!e.ok&&e.status===404&&(p=void 0,e=await y(),a))return;let t=v(e);if(t.kind===`active`){if(e.ok){let t=e.data.id;for(m.getState().upsertFromApi(e.data),g(t),(h||C)&&D(t),u()&&f({assistantId:t,name:e.data.name,cloud:`vellum`,runtimeUrl:d(),hatchedAt:new Date().toISOString(),organizationId:ce.getState().currentOrganizationId??void 0}),$(`connecting`);!a;){try{if((await de(t)).ok)break}catch{}if(Date.now()-l>=P){K(`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`){K(t.message);return}t.kind!==`auto_hatch`&&Y.current===`provisioning`&&$(`connecting`),j(N)}catch(e){if(n(e,{context:`onboarding_poll_assistant`}),a)return;j(N)}}};return A(),()=>{a=!0,o&&clearTimeout(o),s&&clearTimeout(s),c&&clearTimeout(c)}},[we,S,V,B,e,r,$,O]),(0,A.useEffect)(()=>{Z.current===0&&(Z.current=Date.now());let e,t=()=>{let n=Date.now()-Z.current,r=ye[Y.current],i=xe(X.current,r,n);Q.current=i,J(i),r-i>1e-6&&(e=requestAnimationFrame(t))};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[De]),G?(0,M.jsx)(D,{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:G}),Ce&&(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:H,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,W(`initializing`),J(0),Oe(e=>e+1),K(null),q(!1),Te(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(O?b.onboarding.hosting:b.onboarding.privacy,{replace:!0}),children:`Back`})]})]})}):(0,M.jsx)(D,{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:U===`ready`?`Your assistant is ready!`:`Waking up…`}),U!==`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:H,alt:``,width:160,height:160,className:`${E?`my-auto py-8`:`my-16`} ${U===`ready`?`onboarding-avatar-awake`:`onboarding-avatar-pulse`}`}),(0,M.jsx)(l,{value:Ee,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:be[U]})]})})}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-CW7wKp2r.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-1kyF_Eu1.js";import{t as u}from"./arrow-left-C2re-gYj.js";import{t as d}from"./bell-V9BYKY__.js";import{n as f}from"./settings-wSv59mkN.js";import{r as p}from"./panel-item-D1WbMkez.js";import{t as m}from"./x-CswtfvgS.js";import{d as h,h as g,i as _}from"./src-BT0gNVcT.js";import{t as v}from"./tag-CJyI1Y2J.js";import{R as y,z as b}from"./react-query.gen-DfzfX_Jv.js";import{u as x}from"./routes-D4ff4ONd.js";import{t as S}from"./native-anchor-ChGbTnsU.js";import{$n as C,Aa as w,Ha as T,J as E,Qo as D,Ua as O,Vo as k,_ as ee,a as A,ar as j,c as te,d as M,ds as N,er as P,f as F,g as I,h as L,i as R,l as z,n as ne,o as re,p as ie,r as ae,s as B,tr as V,u as H,us as U}from"./index-C7ix_asE.js";import{t as W}from"./page-shell-BUD21prh.js";import{l as G,s as K,t as q,u as oe}from"./page-empty-state-DhwyXbFT.js";var J=e(t(),1),Y=c(),se={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=>S(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 ce({content:e,className:t}){return(0,Y.jsx)(`div`,{className:n(`text-body-medium-default`,t),children:(0,Y.jsx)(g,{remarkPlugins:[h],components:se,children:e})})}function X({item:e}){return(0,Y.jsx)(ce,{content:e.summary})}function le(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 ue(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:le(i)},"aria-hidden":`true`}),(0,Y.jsx)(l,{variant:`body-medium-default`,className:`text-[var(--content-default)]`,children:ue(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 de(e){return e&&F[e]?F[e]:F.system}function fe(e){return e.title?e.title:e.category?e.category.charAt(0).toUpperCase()+e.category.slice(1):`Notification`}function pe({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=fe(e),h=de(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)(N,{}):(0,Y.jsx)(U,{}),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)(D,{}),onClick:()=>o(e.id,`seen`),"aria-label":`Restore`,tooltip:`Restore`}):(0,Y.jsx)(r,{variant:`ghost`,iconOnly:(0,Y.jsx)(k,{}),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:L(e.timestamp),children:I(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:L(e.timestamp),children:I(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 me={today:`Today`,yesterday:`Yesterday`,older:`Older`},Q=10080*60*1e3;function $(e,t){return e.status===`new`||e.status===`dismissed`?!1:t-new Date(e.createdAt).getTime()>Q}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=ae(e.filter(e=>e.status!==`dismissed`)),b=y.filter(e=>!$(e,v)),x=z(y.filter(e=>$(e,v))),S=A(b),C=h&&S.includes(h)?h:null;h!==C&&g(C);let w=B(z(R(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)(ie,{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)(q,{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:me[e]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)]`,children:a.map(e=>(0,Y.jsx)(M,{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)(M,{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)(M,{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(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 ve(){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 ye(e){let t=e?.metadata?.scheduleId;return typeof t==`string`&&t.length>0?t:null}function be({assistantId:e,validConversationIds:t,onOpenConversation:n,onViewSchedule:i,initialFeedItemId:a,navigationKey:o,onInitialFeedItemConsumed:c}){let l=T(),u=H(e);_e(e);let{data:d}=s(K(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??[],[E,D]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(!a||o===E||u.isLoading)return;D(o??null);let e=w.find(e=>e.id===a);e&&e.status!==`dismissed`&&v(e),c?.()},[a,o,E,u.isLoading,w,v,c]);let O=re(w),k=O.filter(e=>e.status===`new`).length,A=O.length,j=ee(),M=(0,J.useCallback)(()=>{u.markAll.mutate(te(O))},[u.markAll,O]),N=(0,J.useCallback)(()=>{u.markAll.mutate(ne(O)),p(null)},[u.markAll,O]),P=ye(f),F=P!=null&&(d??[]).some(e=>e.id===P),I=f?(0,Y.jsx)(pe,{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&&(k>0||A>0)&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-[var(--app-spacing-sm)]`,children:[k>0&&(0,Y.jsx)(r,{variant:`ghost`,size:`compact`,onClick:M,disabled:u.markAll.isPending,children:`Mark all as read`}),A>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)(G,{storageKey:`homeDetailDrawerWidth`,detailKey:f?.id,section:L,detail:I}):L,z=u.isLoading?(0,Y.jsx)(ve,{}):(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)(oe,{children:I}):(0,Y.jsx)(W,{children:z})}function xe(){let e=a(),t=i(),n=E(),r=t.state?.feedItemId??null,o=(0,J.useCallback)(()=>{e(t.pathname+t.search,{replace:!0})},[e,t.pathname,t.search]),s=j.use.setTopBarCenter(),c=T(),{conversations:u}=P(n),{conversations:d}=C(n,!0),{conversations:f}=V(n,!0),p=(0,J.useMemo)(()=>new Set(w(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)(be,{assistantId:n,validConversationIds:p,initialFeedItemId:r,navigationKey:t.key,onInitialFeedItemConsumed:o,onOpenConversation:t=>O(e,t),onViewSchedule:t=>e(x.schedules.detail(t))})}export{xe 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-CW7wKp2r.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-1kyF_Eu1.js";import{t as u}from"./arrow-left-C2re-gYj.js";import{t as d}from"./bell-V9BYKY__.js";import{n as f}from"./settings-wSv59mkN.js";import{r as p}from"./panel-item-D1WbMkez.js";import{t as m}from"./x-CswtfvgS.js";import{d as h,h as g,i as _}from"./src-BT0gNVcT.js";import{t as v}from"./tag-CJyI1Y2J.js";import{R as y,z as b}from"./react-query.gen-DfzfX_Jv.js";import{u as x}from"./routes-D4ff4ONd.js";import{t as S}from"./native-anchor-ChGbTnsU.js";import{$n as C,Aa as w,Ha as T,J as E,Qo as D,Ua as O,Vo as k,_ as ee,a as A,ar as j,c as te,d as M,ds as N,er as P,f as F,g as I,h as L,i as R,l as z,n as ne,o as re,p as ie,r as ae,s as B,tr as V,u as H,us as U}from"./index-Ck1SrvnM.js";import{t as W}from"./page-shell-BUD21prh.js";import{l as G,s as K,t as q,u as oe}from"./page-empty-state-DhwyXbFT.js";var J=e(t(),1),Y=c(),se={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=>S(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 ce({content:e,className:t}){return(0,Y.jsx)(`div`,{className:n(`text-body-medium-default`,t),children:(0,Y.jsx)(g,{remarkPlugins:[h],components:se,children:e})})}function X({item:e}){return(0,Y.jsx)(ce,{content:e.summary})}function le(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 ue(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:le(i)},"aria-hidden":`true`}),(0,Y.jsx)(l,{variant:`body-medium-default`,className:`text-[var(--content-default)]`,children:ue(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 de(e){return e&&F[e]?F[e]:F.system}function fe(e){return e.title?e.title:e.category?e.category.charAt(0).toUpperCase()+e.category.slice(1):`Notification`}function pe({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=fe(e),h=de(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)(N,{}):(0,Y.jsx)(U,{}),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)(D,{}),onClick:()=>o(e.id,`seen`),"aria-label":`Restore`,tooltip:`Restore`}):(0,Y.jsx)(r,{variant:`ghost`,iconOnly:(0,Y.jsx)(k,{}),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:L(e.timestamp),children:I(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:L(e.timestamp),children:I(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 me={today:`Today`,yesterday:`Yesterday`,older:`Older`},Q=10080*60*1e3;function $(e,t){return e.status===`new`||e.status===`dismissed`?!1:t-new Date(e.createdAt).getTime()>Q}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=ae(e.filter(e=>e.status!==`dismissed`)),b=y.filter(e=>!$(e,v)),x=z(y.filter(e=>$(e,v))),S=A(b),C=h&&S.includes(h)?h:null;h!==C&&g(C);let w=B(z(R(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)(ie,{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)(q,{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:me[e]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)]`,children:a.map(e=>(0,Y.jsx)(M,{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)(M,{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)(M,{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(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 ve(){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 ye(e){let t=e?.metadata?.scheduleId;return typeof t==`string`&&t.length>0?t:null}function be({assistantId:e,validConversationIds:t,onOpenConversation:n,onViewSchedule:i,initialFeedItemId:a,navigationKey:o,onInitialFeedItemConsumed:c}){let l=T(),u=H(e);_e(e);let{data:d}=s(K(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??[],[E,D]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(!a||o===E||u.isLoading)return;D(o??null);let e=w.find(e=>e.id===a);e&&e.status!==`dismissed`&&v(e),c?.()},[a,o,E,u.isLoading,w,v,c]);let O=re(w),k=O.filter(e=>e.status===`new`).length,A=O.length,j=ee(),M=(0,J.useCallback)(()=>{u.markAll.mutate(te(O))},[u.markAll,O]),N=(0,J.useCallback)(()=>{u.markAll.mutate(ne(O)),p(null)},[u.markAll,O]),P=ye(f),F=P!=null&&(d??[]).some(e=>e.id===P),I=f?(0,Y.jsx)(pe,{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&&(k>0||A>0)&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-[var(--app-spacing-sm)]`,children:[k>0&&(0,Y.jsx)(r,{variant:`ghost`,size:`compact`,onClick:M,disabled:u.markAll.isPending,children:`Mark all as read`}),A>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)(G,{storageKey:`homeDetailDrawerWidth`,detailKey:f?.id,section:L,detail:I}):L,z=u.isLoading?(0,Y.jsx)(ve,{}):(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)(oe,{children:I}):(0,Y.jsx)(W,{children:z})}function xe(){let e=a(),t=i(),n=E(),r=t.state?.feedItemId??null,o=(0,J.useCallback)(()=>{e(t.pathname+t.search,{replace:!0})},[e,t.pathname,t.search]),s=j.use.setTopBarCenter(),c=T(),{conversations:u}=P(n),{conversations:d}=C(n,!0),{conversations:f}=V(n,!0),p=(0,J.useMemo)(()=>new Set(w(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)(be,{assistantId:n,validConversationIds:p,initialFeedItemId:r,navigationKey:t.key,onInitialFeedItemConsumed:o,onOpenConversation:t=>O(e,t),onViewSchedule:t=>e(x.schedules.detail(t))})}export{xe 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-CW7wKp2r.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{rt as o,tt as s}from"./local-mode-Dydd46cS.js";import{t as c}from"./is-electron-y5bNUVyG.js";import{n as l}from"./resolved-assistants-store-DdHm-7v4.js";import{i as u}from"./auth-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-CW7wKp2r.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{rt as o,tt as s}from"./local-mode-Dydd46cS.js";import{t as c}from"./is-electron-y5bNUVyG.js";import{n as l}from"./resolved-assistants-store-DdHm-7v4.js";import{i as u}from"./auth-store-quPkF_4z.js";import{a as d,u as f}from"./routes-D4ff4ONd.js";import{t as p}from"./client-feature-flag-store-BOcAh56y.js";import{t as m}from"./use-onboarding-login-6LWa5XdQ.js";import{hn as h,js as g,vs as _}from"./index-Ck1SrvnM.js";import{r as v}from"./provider-key-BPINSkGG.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)(g,{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)(_,{className:x})}]}function C(){let e=i(),[t]=r(),a=t.get(`from`)===`select-assistant`,l=u(),p=c(),g=S(),_=g.find(e=>e.mode===`vellum-cloud`)?.disabled,[x,C]=(0,y.useState)(l&&!_?`vellum-cloud`:`local`);(0,y.useEffect)(()=>{_&&x===`vellum-cloud`&&C(`local`)},[_,x]);let{loading:T,error:E,login:D,cancel:O}=m(`${f.onboarding.hosting}?from=select-assistant`),k=a&&!l&&!p;return(0,b.jsx)(h,{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:g.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`?(o(),s(null),v(null),e(f.onboarding.privacy)):e(`${f.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?f.selectAssistant:f.welcome)},disabled:T,children:`Back`})]}),(0,b.jsx)(`a`,{href:d(f.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};
|