@vellumai/web 0.11.2-staging.2 → 0.11.2
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/{Combination-CWTYp834.js → Combination-TPH8qx8I.js} +1 -1
- package/dist/assets/{access-CVnesk0m.js → access-PKx6h0AJ.js} +1 -1
- package/dist/assets/{account-page-mMG1nL1O.js → account-page-DucijMvM.js} +1 -1
- package/dist/assets/{account-shell-BmH96-Ie.js → account-shell-BBDh-DzD.js} +1 -1
- package/dist/assets/{acp-run-detail-panel-SN6NIuW5.js → acp-run-detail-panel-DJ6moBbf.js} +1 -1
- package/dist/assets/{activity-steps-panel-bduSS8_d.js → activity-steps-panel-C95hN_fd.js} +1 -1
- package/dist/assets/{add-credential-modal-4zzd0MPK.js → add-credential-modal-BbvTHJmF.js} +1 -1
- package/dist/assets/{add-credits-modal-DNYP2NMD.js → add-credits-modal-C5d63VSi.js} +1 -1
- package/dist/assets/{ai-page-BMqECtJX.js → ai-page-CbNTYziv.js} +1 -1
- package/dist/assets/{api-key-screen-tqtaQUVf.js → api-key-screen-B5zgGiwa.js} +1 -1
- package/dist/assets/{app-card-BJigGog3.js → app-card-CxO44OqN.js} +1 -1
- package/dist/assets/{assistant-feature-flag-store-BvLDPeej.js → assistant-feature-flag-store-BojuHxUH.js} +1 -1
- package/dist/assets/{assistant-status-panel-DyjhJvK6.js → assistant-status-panel-ZdWgKADH.js} +1 -1
- package/dist/assets/{background-task-detail-panel-DCtBOnvF.js → background-task-detail-panel-BvgkgKs6.js} +1 -1
- package/dist/assets/{billing-page-TF_LgX6K.js → billing-page-CSxWbmCW.js} +2 -2
- package/dist/assets/{bookmarks-page-Brvj5Jf6.js → bookmarks-page-hFDlAWts.js} +1 -1
- package/dist/assets/{button-Dy5001j6.js → button-BwFudwM5.js} +1 -1
- package/dist/assets/{channels-page-route-8vJJE2LN.js → channels-page-route-Cxn_zS-J.js} +1 -1
- package/dist/assets/{chat-markdown-message-B7qvlO44.js → chat-markdown-message-BZZsrGyj.js} +1 -1
- package/dist/assets/{checkbox-PU47Djxg.js → checkbox-fzrjTRTI.js} +1 -1
- package/dist/assets/{checkout-page-MpIPAAgf.js → checkout-page-lDrK4V11.js} +1 -1
- package/dist/assets/{command-palette-Bd1GTwZQ.js → command-palette-Bzsl-t3p.js} +1 -1
- package/dist/assets/{command-palette-window-page-CoweYsZl.js → command-palette-window-page-DjfAe-7N.js} +1 -1
- package/dist/assets/{community-page-BWMwSeEZ.js → community-page-CktLEQl7.js} +1 -1
- package/dist/assets/{confirm-dialog-j9o2h3xs.js → confirm-dialog-B7WBNDbT.js} +1 -1
- package/dist/assets/{connect-page-BxSNhZ8N.js → connect-page-hrIJuX_v.js} +1 -1
- package/dist/assets/{consent-controls-Bs63UL5k.js → consent-controls-HYcVhQZ2.js} +1 -1
- package/dist/assets/{contacts-page-route-BOpVOsYK.js → contacts-page-route-CX57wU3L.js} +1 -1
- package/dist/assets/{conversation-navigation-Bf3cDRKh.js → conversation-navigation-CIHBMx2t.js} +1 -1
- package/dist/assets/{copy-to-clipboard-DgY-nZpm.js → copy-to-clipboard-Y0mxY68V.js} +1 -1
- package/dist/assets/{credential-entry-page-CreYYbwf.js → credential-entry-page-DQOv-Jyx.js} +1 -1
- package/dist/assets/credentials-page-C0eeGia5.js +1 -0
- package/dist/assets/{csv-preview-cEf_PW-P.js → csv-preview-C4T5JLx3.js} +1 -1
- package/dist/assets/{debug-page-DfPZPo6D.js → debug-page-DzXHo3zM.js} +2 -2
- package/dist/assets/{deploy-dialogs-CuaO05wL.js → deploy-dialogs-DQGwptOi.js} +1 -1
- package/dist/assets/{deploy-store-BDIOP-i9.js → deploy-store-BJh0AR_u.js} +1 -1
- package/dist/assets/{detail-card-BElAV1cp.js → detail-card-Br_T-73R.js} +1 -1
- package/dist/assets/{detail-drawer-Cd_EQJkJ.js → detail-drawer-Cbj_q7o7.js} +1 -1
- package/dist/assets/{detail-panel-stop-button-Bhew_kym.js → detail-panel-stop-button-DN2NrxEh.js} +1 -1
- package/dist/assets/{detail-shell-BjqibXNX.js → detail-shell-BuJMM-9z.js} +1 -1
- package/dist/assets/{developer-page-DwBmhm09.js → developer-page-Cj9JWAsX.js} +1 -1
- package/dist/assets/{dist-EanpjdWC.js → dist-B5IUaBWa.js} +1 -1
- package/dist/assets/{dist-C68qFSny.js → dist-BrrL0-_M.js} +1 -1
- package/dist/assets/dist-DWcXIgDR.js +1 -0
- package/dist/assets/{document-viewer-container-iB63ww7P.js → document-viewer-container-CPc9KTln.js} +2 -2
- package/dist/assets/{document-viewer-page-CA1ParJ6.js → document-viewer-page-BqJvQQmH.js} +1 -1
- package/dist/assets/{dropdown-B3FHWc_n.js → dropdown-CJVkL1Yp.js} +1 -1
- package/dist/assets/{emails-page-Bo0Bwem2.js → emails-page-DwQ-FnOD.js} +1 -1
- package/dist/assets/{file-editor-BfJR0ScX.js → file-editor-BigdI9HF.js} +1 -1
- package/dist/assets/{file-markdown-DnVLY_b_.js → file-markdown-eU8RUJQZ.js} +1 -1
- package/dist/assets/{first-run-scope-CPJpXaWU.js → first-run-scope-DqdWmMO-.js} +1 -1
- package/dist/assets/{general-page-BXeIQDGi.js → general-page-uFG7UTqR.js} +1 -1
- package/dist/assets/hatching-screen-CWZvcZVI.js +1 -0
- package/dist/assets/{home-page-route-BPht0PNp.js → home-page-route-zQaUf7gb.js} +1 -1
- package/dist/assets/{hosting-screen-DxtyBx0I.js → hosting-screen-lGuLVQVG.js} +1 -1
- package/dist/assets/{identity-page-route-DgmrXhhV.js → identity-page-route-C64OsL5_.js} +1 -1
- package/dist/assets/index-Cn_k9u0x.css +2 -0
- package/dist/assets/{index-CPeIfypI.js → index-D-1mlWsA.js} +1 -1
- package/dist/assets/{input-tXUFa7Eo.js → input-CgGeKtja.js} +1 -1
- package/dist/assets/{inspect-page-C8aLJOd6.js → inspect-page-DdXP831Q.js} +1 -1
- package/dist/assets/integrations-page-DmQCd8GV.js +1 -0
- package/dist/assets/{intelligence-layout-BRC0qkZ7.js → intelligence-layout-IptAIgHy.js} +1 -1
- package/dist/assets/{library-detail-page-gC4yIWnV.js → library-detail-page-Ddel5wXb.js} +1 -1
- package/dist/assets/{library-page-B10gnbXU.js → library-page-B4k0PNa8.js} +1 -1
- package/dist/assets/{login-page-CbWRbJDE.js → login-page-CRIed3qa.js} +1 -1
- package/dist/assets/{logout-page-DCyzi0V6.js → logout-page-Ne05SAbm.js} +1 -1
- package/dist/assets/{logs-layout-CYkqau4S.js → logs-layout-BN5HA58-.js} +1 -1
- package/dist/assets/{memory-page-route-j_3602nh.js → memory-page-route-Mz8GlpcX.js} +1 -1
- package/dist/assets/{memory-router-playground-page-x5X662qi.js → memory-router-playground-page-CeIkpuOW.js} +1 -1
- package/dist/assets/{menu-wESJw6y3.js → menu-Cfi4A3sw.js} +1 -1
- package/dist/assets/{message-files-panel-C8JokH6e.js → message-files-panel-C8sWLQ58.js} +1 -1
- package/dist/assets/{messages-Dyp1xUqz.js → messages-BTSYvzWZ.js} +1 -1
- package/dist/assets/{metric-card-DpZFp8-q.js → metric-card-CczTqF_s.js} +1 -1
- package/dist/assets/{mobile-sidebar-drawer-BwCIAm23.js → mobile-sidebar-drawer-CSAugzxJ.js} +1 -1
- package/dist/assets/{modal-xr_vw1ZO.js → modal-DagTZ8xj.js} +1 -1
- package/dist/assets/mutation-error-Cp0Jaqnt.js +1 -0
- package/dist/assets/{not-found-Bh7ZsdAo.js → not-found-C1zvwDkh.js} +1 -1
- package/dist/assets/{notifications-page-BA2BW5y6.js → notifications-page-BzoWNM1e.js} +1 -1
- package/dist/assets/{onboarding-layout-iPzXbZk1.js → onboarding-layout-CNKJRWfe.js} +1 -1
- package/dist/assets/{open-workspace-file-CivxJWcw.js → open-workspace-file-DAlt8chN.js} +2 -2
- package/dist/assets/{page-shell-ZNQR4ZTn.js → page-shell-Dx-efyAO.js} +1 -1
- package/dist/assets/pairing-page-BqjYohpZ.js +1 -0
- package/dist/assets/{panel-item-CJh95P_q.js → panel-item-5YQ3jbso.js} +1 -1
- package/dist/assets/{personality-page-Bz_rNBSs.js → personality-page-CB98MeIQ.js} +1 -1
- package/dist/assets/{plans-page-BfyCgy38.js → plans-page-BcR_kjJL.js} +1 -1
- package/dist/assets/{platform-login-notice-DFmjUE9q.js → platform-login-notice-DvWjpI2S.js} +1 -1
- package/dist/assets/popover-CBYgK7Wt.js +1 -0
- package/dist/assets/{preview-error-BrLE2D3A.js → preview-error-DzUxX6Jy.js} +1 -1
- package/dist/assets/{privacy-page-BhEGh78C.js → privacy-page-B9zfD9a-.js} +1 -1
- package/dist/assets/{privacy-screen-CWVCI_KU.js → privacy-screen-Btqk8OjG.js} +1 -1
- package/dist/assets/{provider-callback-page-DP5cKqPE.js → provider-callback-page-Jul4gNdZ.js} +1 -1
- package/dist/assets/provider-key-BZOwvE14.js +1 -0
- package/dist/assets/{provider-signup-page-BjiiJWS_.js → provider-signup-page-C47ij2Um.js} +1 -1
- package/dist/assets/{research-mock-page-CGkqkXHp.js → research-mock-page-DthnGXhi.js} +1 -1
- package/dist/assets/{research-onboarding-route-DZF-B2Rk.js → research-onboarding-route-Cql_2-1F.js} +1 -1
- package/dist/assets/{research-results-view-BFZFPpev.js → research-results-view-BYpW36E0.js} +1 -1
- package/dist/assets/{retire-confirm-dialog-8xlq4bkx.js → retire-confirm-dialog-PvFzzHrQ.js} +1 -1
- package/dist/assets/{review-terms-screen-C5BAI3Rx.js → review-terms-screen-BpE_z8HY.js} +1 -1
- package/dist/assets/routes-DRAnvlxS.js +23 -0
- package/dist/assets/{runtime-upgrade-banner-DjFuJawk.js → runtime-upgrade-banner-Blp8EyfL.js} +1 -1
- package/dist/assets/{schedules-page-3ZE1nR6I.js → schedules-page-D6KPJIUP.js} +1 -1
- package/dist/assets/{select-assistant-screen-D4WHHv61.js → select-assistant-screen-DH6QRKdk.js} +1 -1
- package/dist/assets/{settings-divider-BkLQFMlW.js → settings-divider-COV4-sHz.js} +1 -1
- package/dist/assets/{settings-layout-BmOglXDq.js → settings-layout-CyMD8Ey7.js} +1 -1
- package/dist/assets/{share-feedback-modal-Rwuho_1S.js → share-feedback-modal-NfuDPoEg.js} +1 -1
- package/dist/assets/{sidebar-tree-Dxx5qLMQ.js → sidebar-tree-DTcPYrOG.js} +1 -1
- package/dist/assets/{site-favicon-CDH0mg6Q.js → site-favicon-DkjZF9mC.js} +1 -1
- package/dist/assets/{skill-detail-page-DswXTTyb.js → skill-detail-page-CzCcXCkp.js} +1 -1
- package/dist/assets/{skill-detail-panel-DhQFBAFF.js → skill-detail-panel-B1Kxa3zf.js} +1 -1
- package/dist/assets/{skills-CbF2uKXV.js → skills-CrZ3GlyK.js} +1 -1
- package/dist/assets/{slack-setup-wizard-DPzdheN0.js → slack-setup-wizard-CeBY_rKV.js} +1 -1
- package/dist/assets/src-CwGlaCIx.js +293 -0
- package/dist/assets/{start-screen-CSxaBn88.js → start-screen-wyemTUjV.js} +1 -1
- package/dist/assets/{subagent-detail-panel-CidisBCf.js → subagent-detail-panel-C3II8umu.js} +1 -1
- package/dist/assets/{superpowers-page-BouZK3P4.js → superpowers-page-DmIZ_ed4.js} +1 -1
- package/dist/assets/{system-events-page-BrvTNeiN.js → system-events-page-DAbap4FJ.js} +1 -1
- package/dist/assets/{tag-gOOX7fbA.js → tag-G0ELn_cq.js} +1 -1
- package/dist/assets/{text-preview-DwgKh8PW.js → text-preview-DLiOtb-y.js} +1 -1
- package/dist/assets/{theme-stage-page-LIhQbqRQ.js → theme-stage-page-Dt0ShS5G.js} +1 -1
- package/dist/assets/{tiptap-document-editor-BvGaiGeN.js → tiptap-document-editor-LwU6S_hn.js} +2 -2
- package/dist/assets/{toast-BtFgiPe3.js → toast-BHjG1kP8.js} +1 -1
- package/dist/assets/{tool-detail-panel-B2CIRZkB.js → tool-detail-panel-tFQRRPbP.js} +1 -1
- package/dist/assets/{transcript-message-body-shared-BfKwS5qD.js → transcript-message-body-shared-DdXeU1D-.js} +1 -1
- package/dist/assets/{upgrade-cancel-page-DjeqfvTa.js → upgrade-cancel-page-isK2Rvv6.js} +1 -1
- package/dist/assets/{upgrade-success-page-B4TCn340.js → upgrade-success-page-B7ZaoDsy.js} +1 -1
- package/dist/assets/{use-assistant-identity-details-D-7oN9gr.js → use-assistant-identity-details-BLHiMTpS.js} +1 -1
- package/dist/assets/{use-attachment-preview-CQjpDfsc.js → use-attachment-preview-TAzqhvwh.js} +1 -1
- package/dist/assets/{use-attachment-squares-8Hx-p8ls.js → use-attachment-squares-Cnn6a6er.js} +1 -1
- package/dist/assets/{use-bookmarks-DO9wmU-2.js → use-bookmarks-BKYsQrf9.js} +1 -1
- package/dist/assets/{use-checkout-dismiss-refresh-CV_H4uEB.js → use-checkout-dismiss-refresh-ChquCG4n.js} +1 -1
- package/dist/assets/{use-edit-app-Bd1eXXFq.js → use-edit-app-LCywIVb9.js} +1 -1
- package/dist/assets/{use-invite-link-dialog-TNGI1l4g.js → use-invite-link-dialog-CnOeFYBH.js} +1 -1
- package/dist/assets/{use-ios-app-nudge-CadXZRJC.js → use-ios-app-nudge-9Qqz96FD.js} +1 -1
- package/dist/assets/{use-skill-actions-B_tz3CI7.js → use-skill-actions-Ik0rj4or.js} +1 -1
- package/dist/assets/{use-sticky-profiles-D5TVHOgw.js → use-sticky-profiles-BwaZUy6p.js} +1 -1
- package/dist/assets/{use-subagent-card-data-bjGydvhR.js → use-subagent-card-data-1nEhEj8_.js} +1 -1
- package/dist/assets/{use-transcript-message-by-id-BgyP3Ki5.js → use-transcript-message-by-id-RhDDYgbY.js} +1 -1
- package/dist/assets/{use-transcript-messages-C2uwkjKL.js → use-transcript-messages-C5t358ZW.js} +1 -1
- package/dist/assets/{utils-3IBGVjNS.js → utils-B6xfBCpN.js} +1 -1
- package/dist/assets/{viewer-store-DbIS4l8d.js → viewer-store-DxLOGAkL.js} +1 -1
- package/dist/assets/{voice-list-D26Lzbpv.js → voice-list-DP4_zhJe.js} +1 -1
- package/dist/assets/{voice-page-CQ2Vp8p4.js → voice-page-Bn0QH4eT.js} +1 -1
- package/dist/assets/{voice-providers-note-Ck7hNTfp.js → voice-providers-note-F4pLO3zK.js} +1 -1
- package/dist/assets/{welcome-screen-CdsjDVfi.js → welcome-screen-B6BjQt9n.js} +1 -1
- package/dist/assets/{workflow-detail-panel-CsRhUrbM.js → workflow-detail-panel-H3N7Md_X.js} +1 -1
- package/dist/assets/{workspace-page-CFuSxp5s.js → workspace-page-B4sn6pzo.js} +1 -1
- package/dist/index.html +55 -55
- package/package.json +1 -1
- package/dist/assets/credentials-page-DBLT8nUI.js +0 -1
- package/dist/assets/dist-BDdp8zqz.js +0 -1
- package/dist/assets/hatching-screen-BUpSlvBy.js +0 -1
- package/dist/assets/index-C7_04HXM.css +0 -2
- package/dist/assets/integrations-page-Bp2Q81Qt.js +0 -1
- package/dist/assets/mutation-error-YLfUU5XL.js +0 -1
- package/dist/assets/pairing-page-P5ghxF0M.js +0 -1
- package/dist/assets/popover-B-3isZCV.js +0 -1
- package/dist/assets/provider-key-CgC-RLmR.js +0 -1
- package/dist/assets/routes-uGHUgv4F.js +0 -23
- package/dist/assets/src-Da9g8qsW.js +0 -293
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n}from"./local-settings-Bx7FsNo5.js";import{o as r,r as i}from"./device-settings-CUIsZfaf.js";import{t as a}from"./capture-error-CqtAGHQu.js";import{t as o}from"./react-BFJW0bSv.js";import{t as s}from"./button-Dy5001j6.js";import{m as c,t as l,u}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as d}from"./QueryClientProvider-CMu7CkQU.js";import{t as f}from"./useQuery-Bz-fbQ-m.js";import{t as p}from"./useMutation-CXGTrp4W.js";import{t as m}from"./jsx-runtime-D3ZM-ToX.js";import{t as h}from"./card-DRIctGVs.js";import{t as g}from"./createLucideIcon-CAM1RhH8.js";import{t as _}from"./bell-2SnK9BVD.js";import{t as v}from"./check-Dt2rQhdg.js";import{t as y}from"./chevron-down-BNidRDh1.js";import{t as b}from"./circle-alert-DQMH8VJH.js";import{t as x}from"./circle-check-DvrCdroD.js";import{B as S,I as C,L as w,P as T,a as E,n as D}from"./src-Da9g8qsW.js";import{t as O}from"./hard-drive-sI2ZzmqM.js";import{t as k}from"./heart-DFD4eqW-.js";import{t as A}from"./loader-circle-DWWXcfTQ.js";import{t as j}from"./monitor-RX4oi4Nj.js";import{t as M}from"./moon-CHW45huN.js";import{S as N,a as P,b as F,c as ee,f as I,l as te,n as ne,o as L,p as re,s as ie,v as ae,x as oe}from"./use-ios-app-nudge-CadXZRJC.js";import{t as se}from"./refresh-cw-EZQqnaxp.js";import{t as ce}from"./rotate-ccw-CL6IkaAI.js";import{t as le}from"./smartphone-CIrxb2NM.js";import{t as ue}from"./sparkles-DfEFn3Bh.js";import{t as de}from"./sun-BauGiwdK.js";import{t as fe}from"./triangle-alert-D6bAGtMw.js";import{t as pe}from"./x-D4O9yIS7.js";import{t as R}from"./notice-Dslxs3H6.js";import{t as me}from"./progress-bar-3GUUAhXi.js";import{t as he}from"./tag-gOOX7fbA.js";import{t as z}from"./input-tXUFa7Eo.js";import{t as ge}from"./toggle-BEPV0rQM.js";import{t as B}from"./modal-xr_vw1ZO.js";import{n as V}from"./toast-BtFgiPe3.js";import{t as _e}from"./confirm-dialog-j9o2h3xs.js";import{t as ve}from"./dropdown-B3FHWc_n.js";import{C as ye,T as be,at as xe,c as Se,d as Ce,f as we,g as Te,h as Ee,i as De,j as Oe,k as ke,r as Ae}from"./local-mode-DHueA-BJ.js";import{t as H}from"./is-electron-DIlIrdJX.js";import{n as je}from"./resolved-assistants-store-C6oDdTxB.js";import{r as Me,t as Ne}from"./semver-Bfq1LtyW.js";import{i as Pe}from"./utils-DtVy-_pB.js";import{n as Fe,r as U,t as Ie}from"./api-errors-BRGPPSWw.js";import{C as Le,T as Re,Z as ze,a as Be,at as Ve,b as He,h as Ue,n as We,rt as Ge,tt as Ke,w as qe,x as Je}from"./auth-store-C9aYqB9U.js";import{t as W}from"./client.gen-Dq2brHDV.js";import{$ as Ye,C as Xe,N as Ze,P as Qe,Q as $e,T as et,W as tt,Wt as nt}from"./sdk.gen-ies09CqM.js";import{a as rt,o as it}from"./api-CGsj1Pig.js";import{t as G}from"./client-feature-flag-store-Cw39NfCq.js";import{d as K}from"./routes-DrfnNoYS.js";import{a as at,d as ot,l as st}from"./platform-detection-AHYibqOx.js";import{i as ct,r as lt,t as ut}from"./use-platform-gate-C5bNA5Pn.js";import{t as dt}from"./hard-navigate-BYoBFmE4.js";import{A as ft,At as pt,D as mt,E as ht,Ft as gt,It as _t,Lt as vt,N as yt,Nt as bt,O as xt,P as St,Pt as Ct,Rt as wt,T as Tt,Tt as Et,c as Dt,j as Ot,k as kt,kt as At,lt as jt,st as Mt,v as Nt,w as Pt}from"./react-query.gen-BtYBixpk.js";import{t as Ft}from"./assistant-feature-flag-store-BvLDPeej.js";import{t as It}from"./pointer-CQ4DXHXb.js";import{n as Lt,t as Rt}from"./retire-confirm-dialog-8xlq4bkx.js";import{a as zt,i as Bt,r as Vt,s as Ht}from"./local-runtime-upgrade-CnY-6TiF.js";import{t as Ut}from"./proxy-DrtKRLtr.js";import{t as Wt}from"./AnimatePresence-CHo6D7IH.js";import{t as Gt}from"./use-reduced-motion-fR0m_opJ.js";import{t as Kt}from"./copy-to-clipboard-DgY-nZpm.js";import{t as q}from"./platform-login-notice-DFmjUE9q.js";import{t as qt}from"./use-active-assistant-id-JLsAfn3e.js";import{t as Jt}from"./use-copy-to-clipboard-RUBxQIiE.js";import{t as J}from"./detail-card-BElAV1cp.js";import{t as Yt}from"./app-info-BDq_9VB8.js";import{a as Xt,i as Zt,l as Qt,o as $t}from"./machine-sizes-B9nt_h-U.js";import{t as en}from"./environment-store-DxX3xxt2.js";import{a as tn,i as nn,n as rn,r as an,t as on}from"./assistant-status-panel-DyjhJvK6.js";import{t as sn}from"./settings-divider-BkLQFMlW.js";var cn=g(`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`}]]),ln=g(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),un=g(`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`}]]),Y=e(o(),1),X=m();function dn(){let e=G.use.velvet(),{theme:t,setThemePreference:n}=I(),r=[{value:`system`,label:`System`,icon:(0,X.jsx)(j,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,X.jsx)(de,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,X.jsx)(M,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,X.jsx)(k,{className:`h-4 w-4`})}]:[]];return(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Theme`}),(0,X.jsx)(`div`,{className:`mt-2 max-w-[360px]`,children:(0,X.jsx)(T,{ariaLabel:`Theme`,value:t,onChange:n,items:r})})]})}var fn=He,pn=`Please choose a different handle.`;async function mn(e,t){let{data:n,error:r,response:i}=await Qe({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:U(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}=Re(r,`handle`,fn.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=Re(r,`handle`,pn);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:U(r,i,`Failed to save handle.`)}}async function hn(e,t,n){let{data:r,error:i,response:a}=await Xe({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(Fe(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new Ie(a.status,a.status===429?`Too many checks — try again in a moment.`:U(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function gn(e){return/\d{2,}$/.test(e)}var _n=300,vn=1400;function yn({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:a,onSaved:o,saveSuccessToast:c,fieldId:l}){let[u,d]=(0,Y.useState)(e),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(`idle`),[y,x]=(0,Y.useState)(null),S=Gt(),C=(0,Y.useRef)(null),w=(0,Y.useMemo)(()=>u.trim().toLowerCase(),[u]),T=w===e.toLowerCase();(0,Y.useEffect)(()=>{if(T||w.length===0){h(!1),C.current?.abort();return}let e=new AbortController;C.current?.abort(),C.current=e,h(!0);let t=window.setTimeout(async()=>{try{let t=await i(w,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)}},_n);return()=>{window.clearTimeout(t),e.abort()}},[w,T,i]);let E=(()=>{if(y)return y;if(f&&!f.available){let e=f.code;return f.message??(e?fn[e]:`Please choose a different handle.`)}return null})(),D=E?n:T?r??null:m?`Checking availability…`:f?.available?`Available.`:null,O=!T&&!m&&f?.available!==!1&&g!==`saving`,k=(0,Y.useCallback)(async()=>{if(!O)return;_(`saving`),x(null);let e=await a(w);if(e.kind===`ok`){_(`saved`),o(e.data),V.success(c),window.setTimeout(()=>_(`idle`),vn);return}if(e.kind===`taken`){_(`idle`),p({available:!1,code:`taken`,message:e.message});return}if(e.kind===`invalid`){_(`idle`),p({available:!1,code:e.code,message:e.message});return}_(`error`),x(e.message),V.error(e.message)},[O,w,o,a,c]),j=(()=>{if(T&&u.length>0||u.length===0)return null;let e=m?`checking`:f?.available?`available`:f?.available===!1?`invalid`:null;return e?(0,X.jsx)(Wt,{mode:`wait`,initial:!1,children:(0,X.jsxs)(Ut.span,{initial:S?!1:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:S?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,X.jsx)(A,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,X.jsx)(v,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,X.jsx)(b,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),M=(()=>{switch(g){case`saving`:return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Saving…`]});case`saved`:return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(v,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Saved`]});default:return`Save`}})();return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.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,X.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),rightIcon:j,errorText:E??void 0,helperText:D??void 0,"aria-invalid":!!E,fullWidth:!0,"data-testid":`${l}-input`}),(!T||g!==`idle`)&&(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(s,{variant:`primary`,size:`compact`,onClick:k,disabled:!O,"aria-live":`polite`,"data-testid":`${l}-save`,children:M})})]})}function bn({initial:e,onSaved:t}){let n=We.use.refreshSession(),r=gn(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,Y.useCallback)(async e=>await qe({username:e}),[]),a=(0,Y.useCallback)((e,t)=>Je(e,t),[]),o=(0,Y.useCallback)(e=>{t(e),n()},[t,n]);return(0,X.jsx)(yn,{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 xn({assistant:e,onSaved:t}){let n=e.handle??``,r=f({...Dt({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,Y.useCallback)(async t=>await mn(e.id,t),[e.id]),s=(0,Y.useCallback)((t,n)=>hn(e.id,t,n),[e.id]);return i?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(z,{label:`Assistant handle`,value:n,readOnly:!0,disabled:!0,leftIcon:(0,X.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,X.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,X.jsx)(l,{to:`${K.settings.ai}?release=1#email`,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`,children:`release the subdomain`}),` `,`first.`]})]}):(0,X.jsx)(yn,{initialHandle:n,inputLabel:`Assistant handle`,helperText:`Lowercase letters, digits, hyphens, and underscores. 3–30 characters.`,idleHelperText:a,checkAvailable:s,save:o,onSaved:t,saveSuccessToast:`Assistant handle updated.`,fieldId:`assistant-handle`})}function Sn(){return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-3 w-72 animate-pulse rounded bg-[var(--surface-muted)]`})]}),(0,X.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`h-3 w-60 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-7 w-16 animate-pulse rounded-md bg-[var(--surface-muted)]`})]}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Loading your profile…`})]})}function Cn(){return(0,X.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`})}function wn({assistant:e,showHandles:t=!0,children:n}={}){let r=We.use.user?.()?.email??null;return(0,X.jsx)(J,{title:`Profile`,subtitle:`Manage your account details and preferences.`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[r&&(0,X.jsx)(`div`,{className:`max-w-[420px]`,children:(0,X.jsx)(z,{label:`Email`,value:r,disabled:!0,readOnly:!0})}),t&&(0,X.jsxs)(X.Fragment,{children:[r&&(0,X.jsx)(Cn,{}),(0,X.jsx)(Tn,{assistant:e})]}),n!=null&&(0,X.jsxs)(X.Fragment,{children:[(r||t)&&(0,X.jsx)(Cn,{}),n]})]})})}function Tn({assistant:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),a=Gt(),[o,s]=(0,Y.useState)(e??null);return(0,Y.useEffect)(()=>{s(e??null)},[e]),(0,Y.useEffect)(()=>{let e=!1;return Le().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),r?(0,X.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,X.jsxs)(Ut.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,X.jsx)(bn,{initial:t,onSaved:n}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,X.jsx)(xn,{assistant:o,onSaved:s})]})]}):(0,X.jsx)(Sn,{})}var En=Nt({query:{hosting:`platform`}});function Dn(){let e=qt(),t=f(En),n=t.data?.results??[];return t.isPending||n.length<2?null:(0,X.jsx)(J,{title:`Switch Assistant`,subtitle:`Choose which assistant is active for this account.`,children:(0,X.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>{let n=t.id===e;return(0,X.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,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(j,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:t.name||`Unnamed`}),t.status!==`active`&&(0,X.jsx)(he,{tone:`warning`,children:t.status})]})})]}),(0,X.jsx)(`div`,{className:`shrink-0`,children:n?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,X.jsx)(v,{className:`h-4 w-4`}),`Active`]}):(0,X.jsx)(s,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{Ke(t.id),V.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var On=[{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 kn(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 An({assistantId:e}){let t=d(),n=en.use.isNonProduction(),r=(0,Y.useMemo)(()=>On.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:a,isError:o}=f(ft({path:{id:e}})),c=(0,Y.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[l,u]=(0,Y.useState)(null),p=l??c,m=l!==null,h=pt({onSuccess:()=>{V.success(`Sleep policy saved.`),u(null),t.invalidateQueries({queryKey:Ot({path:{id:e}})})},onError:()=>{V.error(`Failed to save sleep policy. Please try again.`)}});return a?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):o?(0,X.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,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Idle timeout`}),(0,X.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,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:r.map(e=>(0,X.jsx)(s,{variant:`outlined`,active:p===e.seconds,onClick:()=>u(e.seconds),children:e.label},e.seconds))}),(0,X.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,kn(p)]})]}),m&&(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(s,{variant:`primary`,leftIcon:h.isPending?(0,X.jsx)(A,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,X.jsx)(s,{variant:`outlined`,onClick:()=>u(null),disabled:h.isPending,children:`Cancel`})]})]})}function jn(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var Mn=3e3;function Nn({version:e,assistantId:t}){let{onTap:n,message:r}=nn(t);return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.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,X.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:r})]})}function Pn({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=Ft.use.rollbackEnabled(),a=G.use.previewChannel(),o=d(),c=Bt(n,a),l=c===`preview`,[u,m]=(0,Y.useState)(!1),h=(0,Y.useRef)(null),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(null),w=e=>e&&h.current&&e===h.current?(queueMicrotask(()=>{C(b?`Successfully rolled back to version ${h.current}.`:`Successfully updated to version ${h.current}.`),m(!1),h.current=null,_(null),V.success(b?`Rollback complete — assistant is healthy.`:`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),r?.()}),!1):Mn;f({...xt({path:{id:e}}),refetchInterval:u?e=>w(e.state.data?.current_release_version):!1});let{data:T,isLoading:E}=f(Et({query:{channel:c}})),D=T?.find(e=>e.is_stable!==!1)??T?.[0],O=g??D?.version??null,k=(0,Y.useMemo)(()=>{if(!i||!O||!t)return!1;let e=Me(O),n=Me(t);return!e||!n?!1:Ne(e,n)<0},[i,O,t]),j=(0,Y.useMemo)(()=>{if(!O)return!1;if(!t)return!0;let e=Me(O),n=Me(t);if(!e||!n)return O!==t;let r=Ne(e,n);return i?r!==0:r>0},[i,O,t]),M=p({mutationFn:async t=>{let{data:n}=await $e({path:{id:e},body:t,throwOnError:!0});return n}}),N=p({mutationFn:async t=>{let{data:n}=await tt({path:{id:e},body:t,throwOnError:!0});return n}});return(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,X.jsx)(Nn,{version:t,assistantId:e})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:l?`Preview release`:j?k?`Rollback to`:`Update to`:`Selected`}),(0,X.jsx)(`span`,{className:`block min-w-0`,children:E?(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(A,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):T&&T.length>0?i?(0,X.jsx)(ve,{value:O??``,onChange:e=>_(e===D?.version?null:e),disabled:u||M.isPending||N.isPending,options:T.map(e=>({value:e.version,label:jn(e,t,D?.version)}))}):(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:D?jn(D,t,D.version):`—`}):`No releases available`})]})]}),(0,X.jsx)(s,{variant:k?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:M.isPending||N.isPending||u?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(se,{}),onClick:()=>y(!0),disabled:!j||M.isPending||N.isPending||u||E||!T?.length,children:u?b?`Rolling back...`:`Updating...`:k?`Rollback`:l?`Update preview`:`Update`}),l&&(0,X.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Using Preview releases.`,` `,(0,X.jsx)(`a`,{href:`#preview-release-channel`,className:`text-[var(--primary-base)] underline-offset-2 hover:underline`,children:`Switch back to Stable`})]}),!j&&t&&O&&!E&&(0,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:S??`You are already on this version.`}),(0,X.jsx)(_e,{open:v,title:k?`Rollback assistant`:l?`Update preview release`:`Update assistant`,message:k?`Rollback to version ${O??`unknown`}? The assistant will be briefly unavailable.`:l?`Update to preview version ${O??`latest`}? The assistant will be briefly unavailable during the update.`:`Update to version ${O??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:k?`Rollback`:l?`Update preview`:`Update`,onConfirm:async()=>{y(!1),C(null);let t=g??void 0;try{if(k){let e=await N.mutateAsync({version:t});h.current=e.version??t??null,V.success(e.detail||`Rollback to ${t} initiated.`)}else{let e=await M.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){V.warning(e.detail);return}h.current=e.version??t??null,V.success(e.detail||`Update to ${e.version??t??`latest`} initiated.`)}x(k),m(!0),o.invalidateQueries({queryKey:kt({path:{id:e}})})}catch{V.error(k?`Failed to trigger rollback. Please try again.`:`Failed to trigger update. Please try again.`)}},onCancel:()=>y(!1)})]})}function Fn({assistantId:e,currentVersion:t,onUpgradeComplete:n}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(null),{data:c,isLoading:l}=f(Et({query:{stable:!0,limit:100}})),u=(0,Y.useMemo)(()=>Vt(c),[c]),d=u?.version,p=t?zt(t,d):!!d,m=Ht({assistantId:e,targetVersion:d});return(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,X.jsx)(Nn,{version:t,assistantId:e})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Update to`}),(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:l?`Loading...`:d&&u?jn(u,t,d):`No releases available`})]})]}),(0,X.jsx)(s,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(se,{}),onClick:()=>i(!0),disabled:m.isPending||l||!d||!p,children:m.isPending?`Updating...`:d?`Update to ${d}`:`Update`}),a&&(0,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:a}),!a&&!p&&d&&!l&&(0,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:`You are already on this version.`}),(0,X.jsx)(_e,{open:r,title:`Update assistant`,message:`Update to version ${d??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:`Update`,onConfirm:async()=>{i(!1),o(null);try{let e=await m.upgrade();o(e.version?`Successfully updated to version ${e.version}.`:`Successfully updated to version ${d??`latest`}.`),V.success(`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),n?.()}catch(e){V.error(e instanceof Error?e.message:`Failed to trigger update. Please try again.`)}},onCancel:()=>i(!1)})]})}function In(){let e=ct({platformHostedOnly:!0}),t=lt(),n=We.use.user()?.id??null,r=We.use.logout(),[i,a]=(0,Y.useState)(!1),o=bt({onSuccess:async()=>{V.success(`Account deletion requested. You will be logged out shortly.`),Ue(n),await r(),dt(K.account.login)},onError:()=>{V.error(`Failed to request account deletion. Please try again.`)}}),c=e===`full`&&t;return(0,Y.useEffect)(()=>{c&&i&&a(!1)},[c,i]),e===`gated`?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Delete Account`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently delete your account and all associated data.`}),(0,X.jsx)(`div`,{className:`mt-1`,children:e===`disabled`?(0,X.jsx)(q,{children:`Log in to the Vellum platform to delete your account.`}):(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(s,{variant:`dangerOutline`,onClick:()=>a(!0),disabled:o.isPending||c,className:`self-start`,children:`Delete My Account`}),c&&(0,X.jsx)(A,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})})]}),(0,X.jsx)(_e,{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){a(!1);return}a(!1),o.mutate({})},onCancel:()=>a(!1)})]})}function Ln({title:e,subtitle:t,benefits:n,ctaLabel:r,ctaLeftIcon:i,onAction:a}){return(0,X.jsx)(J,{title:e,subtitle:t,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(`ul`,{className:`space-y-3`,children:n.map(({icon:e,text:t})=>(0,X.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,X.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,X.jsx)(s,{variant:`primary`,size:`regular`,leftIcon:i,onClick:a,className:`self-start`,children:r})]})})}function Rn(){return st()?(0,X.jsx)(Ln,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:_,text:`Push notifications`},{icon:cn,text:`Biometric login`},{icon:un,text:`Native haptics`},{icon:le,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,X.jsx)(le,{size:16}),onAction:()=>{P(),ne()}}):null}var zn=`0.10.0`;function Bn(){return Pe(zn)}var Vn=[`login.tailscale.com`,`tailscale.com`,`www.tailscale.com`,`ngrok.com`,`dashboard.ngrok.com`,`dash.cloudflare.com`,`cloudflare.com`,`www.cloudflare.com`];function Hn(e){let t;try{t=new URL(e).hostname}catch{return!1}return Vn.includes(t)}function Un(e){let t;try{t=new URL(e).hostname}catch{return null}return Vn.includes(t)?t.includes(`tailscale`)?`Tailscale`:t.includes(`ngrok`)?`ngrok`:t.includes(`cloudflare`)?`Cloudflare`:null:null}function Wn(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`[::1]`||/^127(?:\.\d{1,3}){3}$/.test(t)}catch{return!1}}function Gn(e){let t=new URL(e);t.search=``,t.hash=``;let n=t.pathname.split(`/`).filter(Boolean),r=n.indexOf(`assistant`);return r>=0&&n.splice(r),t.pathname=n.length?`/${n.join(`/`)}`:`/`,t.toString().replace(/\/+$/,``)}function Kn(e){let t;try{t=Gn(e)}catch{return{ok:!1,reason:`unparseable`}}return Wn(t)?{ok:!1,reason:`loopback`}:Hn(t)?{ok:!1,reason:`service-website`}:new URL(t).protocol===`https:`?{ok:!0,url:t}:{ok:!1,reason:`non-https`}}function qn(e){let t=new URL(e.verificationUri);return t.hash=new URLSearchParams({device_code:e.deviceCode}).toString(),t.toString()}function Jn(e,t){switch(e){case`unparseable`:return`Enter a valid URL, e.g. https://your-assistant.ts.net.`;case`loopback`:return`This is a loopback address other devices can't reach. Enter the assistant's public https URL.`;case`non-https`:return`The URL must use https so your devices can connect securely.`;case`service-website`:return`This is ${t&&Un(t)||`the tunnel provider`}'s website, not your assistant's address. Run \`vellum tunnel\` on the host to get one.`}}var Yn=`/v1/remote-web/pairing-challenge`,Xn=`/v1/remote-web/pairing-verification`,Zn="If a scan can't connect, enable remote web access on the host with `vellum flags set web-remote-ingress true`, then generate a new code.",Qn=class extends Error{hint;constructor(e,t){super(e),this.name=`PairDeviceError`,this.hint=t}};function $n(){if(typeof window>`u`)return null;let e=Se(),t=De(e);return t?{base:`${window.location.origin}${t}`,assistantName:e?.name?.trim()||null,ingressUrl:e?.ingressUrl?.trim()||null}:null}function er(e){let t=e?.error?.message;return typeof t==`string`&&t.trim()?t:null}async function tr(e,t,n){let r;try{r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t),signal:n})}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?e:new Qn(`Couldn't reach the assistant. Make sure it's running and try again.`)}let i=await r.json().catch(()=>null);if(!r.ok)throw new Qn(er(i)??`Pairing failed (HTTP ${r.status}).`,Zn);if(typeof i!=`object`||!i)throw new Qn(`The assistant returned an unexpected response.`);return i}async function nr(e){let{base:t,publicBaseUrl:n,signal:r}=e,i=await tr(`${t}${Yn}`,{publicBaseUrl:n},r);return await tr(`${t}${Xn}`,{userCode:i.userCode},r),{pairUrl:qn(i),expiresAt:i.expiresAt}}var rr=Object.defineProperty,ir=Object.getOwnPropertySymbols,ar=Object.prototype.hasOwnProperty,or=Object.prototype.propertyIsEnumerable,sr=(e,t,n)=>t in e?rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cr=(e,t)=>{for(var n in t||={})ar.call(t,n)&&sr(e,n,t[n]);if(ir)for(var n of ir(t))or.call(t,n)&&sr(e,n,t[n]);return e},lr=(e,t)=>{var n={};for(var r in e)ar.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ir)for(var r of ir(e))t.indexOf(r)<0&&or.call(e,r)&&(n[r]=e[r]);return n},ur;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(ur||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(ur||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(ur||={});var Z=ur,dr={L:Z.QrCode.Ecc.LOW,M:Z.QrCode.Ecc.MEDIUM,Q:Z.QrCode.Ecc.QUARTILE,H:Z.QrCode.Ecc.HIGH},fr=128,pr=`L`,mr=`#FFFFFF`,hr=`#000000`,gr=!1,_r=1,vr=4,yr=0,br=.1;function xr(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function Sr(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function Cr(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*br),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function wr(e,t){return t==null?e?vr:yr:Math.max(Math.floor(t),0)}function Tr({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=Y.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...Z.QrSegment.makeSegments(t)),e),[]);return Z.QrCode.encodeSegments(r,dr[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=Y.useMemo(()=>{let e=c.getModules(),t=wr(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:Cr(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var Er=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Dr=Y.forwardRef(function(e,t){let n=e,{value:r,size:i=fr,level:a=pr,bgColor:o=mr,fgColor:s=hr,includeMargin:c=gr,minVersion:l=_r,boostLevel:u,marginSize:d,imageSettings:f}=n,p=lr(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=lr(p,[`style`]),g=f?.src,_=Y.useRef(null),v=Y.useRef(null),y=Y.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=Y.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=Tr({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});Y.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=Sr(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,Er?t.fill(new Path2D(xr(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),Y.useEffect(()=>{x(!1)},[g]);let E=cr({height:i,width:i},m),D=null;return g!=null&&(D=Y.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),Y.createElement(Y.Fragment,null,Y.createElement(`canvas`,cr({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});Dr.displayName=`QRCodeCanvas`;var Or=Y.forwardRef(function(e,t){let n=e,{value:r,size:i=fr,level:a=pr,bgColor:o=mr,fgColor:s=hr,includeMargin:c=gr,minVersion:l=_r,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=lr(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=Tr({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=Sr(g,v.excavation)),b=Y.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=xr(y,h);return Y.createElement(`svg`,cr({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&Y.createElement(`title`,null,d),Y.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),Y.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});Or.displayName=`QRCodeSVG`;function kr(e){if(!Number.isFinite(e)||e<=0)return`Single-use.`;let t=Math.ceil(e/1e3);return`Expires in ${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)} · single-use.`}function Ar({pairUrl:e,remainingMs:t,expired:n,copied:r,onCopy:i}){return n?(0,X.jsx)(R,{tone:`warning`,title:`This pairing code expired.`,children:`Generate a new code to pair a device.`}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`w-fit rounded-lg bg-white p-3`,children:(0,X.jsx)(Or,{value:e,size:192,level:`M`,title:`Device pairing QR code`})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`code`,{"data-testid":`pair-device-url`,className:`min-w-0 flex-1 truncate rounded-md bg-[var(--surface-active)] px-2.5 py-1.5 text-body-small-default text-[var(--content-secondary)]`,children:e}),(0,X.jsx)(s,{variant:`outlined`,size:`compact`,leftIcon:r?(0,X.jsx)(v,{}):(0,X.jsx)(S,{}),onClick:()=>i(e),children:r?`Copied`:`Copy`})]}),(0,X.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:kr(t)})]})}var jr=`vellum:pair-device:public-base-url`;function Mr(e){let n=e?.trim();if(n)return{url:n,source:`tunnel`};let r=t(jr,``).trim();return r?{url:r,source:`stored`}:{url:``,source:`none`}}function Nr(e,t,r){let[i]=(0,Y.useState)(()=>Mr(r)),[o,s]=(0,Y.useState)(i.url),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)({kind:`idle`}),[f,p]=(0,Y.useState)(()=>Date.now()),m=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>m.current?.abort(),[]),(0,Y.useEffect)(()=>{if(u.kind!==`ready`)return;p(Date.now());let e=setInterval(()=>p(Date.now()),1e3);return()=>clearInterval(e)},[u]);let h=(0,Y.useCallback)(e=>{s(e),l(null)},[]),g=(0,Y.useCallback)(()=>{if(!e)return;let r=o.trim(),i=Kn(r);if(!i.ok){l(Jn(i.reason,r));return}if(l(null),!t){d({kind:`error`,message:`Remote web access is disabled on this assistant, so a scanned code couldn't connect.`,hint:Zn});return}m.current?.abort();let s=new AbortController;m.current=s,d({kind:`minting`}),(async()=>{try{let t=await nr({base:e,publicBaseUrl:i.url,signal:s.signal});if(s.signal.aborted)return;n(jr,i.url),d({kind:`ready`,pairUrl:t.pairUrl,expiresAtMs:Date.parse(t.expiresAt)})}catch(e){if(s.signal.aborted)return;if(e instanceof Qn){d({kind:`error`,message:e.message,hint:e.hint});return}a(e,{context:`pair-device-mint`}),d({kind:`error`,message:`Something went wrong while generating the code.`})}})()},[e,o,t]),_=u.kind===`ready`?Math.max(0,u.expiresAtMs-f):0,v=u.kind===`ready`&&_<=0;return{publicBaseUrl:o,setPublicBaseUrl:h,prefillSource:i.source,inputError:c,phase:u,remainingMs:_,expired:v,generate:g}}function Pr(){let e=$n(),t=Bn(),n=Ft.use.hasHydrated(),r=Ft.use.webRemoteIngress(),i=Nr(e?.base??null,r,e?.ingressUrl??null),{copy:a,copied:o}=Jt();if(!e||!t)return null;let{phase:c}=i,l=c.kind===`minting`,u=c.kind===`ready`,d=i.prefillSource===`tunnel`,f=i.prefillSource===`none`&&i.publicBaseUrl.trim()===``,p=n?l?`Generating…`:u?`Generate new code`:`Generate pairing QR`:`Loading…`,m=()=>{n&&i.generate()};return(0,X.jsx)(J,{title:`Pair a device`,subtitle:`Scan with another device's camera — or open the link on it — to use ${e.assistantName??`this assistant`} there.`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f&&(0,X.jsx)(R,{tone:`info`,title:`No tunnel detected`,children:"On this computer, run `vellum tunnel --provider tailscale` (or another provider) — its address appears here."}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(z,{label:`Public URL`,fullWidth:!0,placeholder:`https://your-assistant.ts.net`,helperText:d?"This address comes from `vellum tunnel` on this computer. Edit it if your devices reach this assistant at a different URL.":`The https address your devices can reach this assistant at (your Tailscale URL, or another tunnel's).`,value:i.publicBaseUrl,errorText:i.inputError??void 0,disabled:l,onChange:e=>i.setPublicBaseUrl(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),m())}}),(0,X.jsx)(s,{variant:`primary`,className:`self-start`,disabled:!n||l||i.publicBaseUrl.trim()===``,onClick:m,children:p})]}),c.kind===`error`&&(0,X.jsx)(R,{tone:`error`,title:c.message,children:c.hint}),u&&(0,X.jsx)(Ar,{pairUrl:c.pairUrl,remainingMs:i.remainingMs,expired:i.expired,copied:o,onCopy:a})]})})}async function Fr(){if(!H())return[];let e=window.vellum;return e?.hotkeys?e.hotkeys.get():[]}async function Ir(e,t){if(!H())return;let n=window.vellum;n?.hotkeys&&await n.hotkeys.set(e,t)}function Lr(e){if(!H())return()=>{};let t=window.vellum;return t?.hotkeys?t.hotkeys.onChange(e):()=>{}}var Rr={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:`/`},zr=new Set([`MetaLeft`,`MetaRight`,`ControlLeft`,`ControlRight`,`AltLeft`,`AltRight`,`ShiftLeft`,`ShiftRight`]),Br=e=>{let t=e.code;return zr.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:Rr[t]??null},Vr=e=>{let t=Br(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(`+`)},Hr=(e,t,n)=>n===``?null:e.find(e=>e.key!==t&&e.accelerator===n)??null,Ur=[{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 Wr({hotkey:e,recording:t,conflictLabel:n,onStartRecording:r,onCancelRecording:i,onReset:a,onRemove:o}){let c=e.accelerator===``,l=e.override!==null;return(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`truncate text-body-medium-lighter text-[var(--content-default)]`,children:e.label}),n!==null&&(0,X.jsxs)(`div`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:[`Already used by `,n]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,X.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Recording… press a shortcut, or Esc to cancel`}):c?(0,X.jsx)(`span`,{className:`text-body-small-default italic text-[var(--content-disabled)]`,children:`Disabled`}):(0,X.jsx)(D,{accelerator:e.accelerator}),t?(0,X.jsx)(s,{variant:`ghost`,size:`compact`,onClick:i,children:`Cancel`}):(0,X.jsx)(s,{variant:`outlined`,size:`compact`,onClick:r,"aria-label":`Record shortcut for ${e.label}`,children:`Record`}),(0,X.jsx)(s,{variant:`ghost`,size:`compact`,disabled:!l,leftIcon:(0,X.jsx)(ce,{className:`h-3.5 w-3.5`}),onClick:a,"aria-label":`Reset ${e.label} to default`}),(0,X.jsx)(s,{variant:`ghost`,size:`compact`,disabled:c,leftIcon:(0,X.jsx)(pe,{className:`h-3.5 w-3.5`}),onClick:o,"aria-label":`Remove ${e.label} binding`})]})]})}function Gr(){let[e,t]=(0,Y.useState)([]),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),o=(0,Y.useCallback)(()=>{Fr().then(t)},[]);(0,Y.useEffect)(()=>(o(),Lr(t)),[o]);let s=(0,Y.useCallback)(()=>{r(null),a(null)},[]);(0,Y.useEffect)(()=>{if(n===null)return;let t=t=>{if(t.preventDefault(),t.stopPropagation(),t.code===`Escape`){s();return}let r=Vr(t);if(r===null)return;let i=Hr(e,n,r);if(i!==null){a({key:n,label:i.label});return}Ir(n,r).then(o),s()};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[n,e,o,s]);let c=(0,Y.useCallback)(e=>{a(null),r(e)},[]),l=(0,Y.useCallback)(t=>{let n=Hr(e,t,e.find(e=>e.key===t)?.defaultAccelerator??``);if(n!==null){r(null),a({key:t,label:n.label});return}s(),Ir(t,null).then(o)},[e,o,s]),u=(0,Y.useCallback)(e=>{s(),Ir(e,``).then(o)},[o,s]),d=(0,Y.useMemo)(()=>Ur.map(t=>({...t,commands:e.filter(e=>e.rebindable&&e.scope===t.scope)})).filter(e=>e.commands.length>0),[e]);return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[i!==null&&(0,X.jsxs)(R,{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,X.jsxs)(h,{bordered:!0,children:[(0,X.jsxs)(`div`,{className:`mb-2`,children:[(0,X.jsx)(`div`,{className:`text-body-medium-emphasised text-[var(--content-default)]`,children:e.title}),(0,X.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e.description})]}),(0,X.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.commands.map(e=>(0,X.jsx)(Wr,{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 Kr(){if(!H())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function qr(e){if(!H())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function Jr(){let e=L.useValue(),t=ie.useValue(),n=!It(),r=at()?`Cmd`:`Ctrl`;return(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Composer`}),(0,X.jsxs)(`div`,{className:`mt-2 space-y-4`,children:[n&&(0,X.jsx)(ge,{checked:e,onChange:L.save,label:`Send with ${r}+Enter`,helperText:`When enabled, Enter inserts a new line and ${r}+Enter sends.`}),(0,X.jsx)(ge,{checked:t,onChange:ie.save,label:`Show context window usage`,helperText:`Adds a ring to the composer tracking how full the context window is. Your assistant compacts its context automatically either way.`})]})]})}function Yr(){let[e,t]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{Kr().then(t)},[]);let n=async e=>{t(e);try{await qr(e)}catch{t(!e)}};return(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Launch at Login`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Automatically start Vellum when you log in to your Mac.`}),(0,X.jsx)(`div`,{className:`mt-2`,children:(0,X.jsx)(ge,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})]})}function Xr({open:e,onClose:t}){return(0,X.jsx)(B.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(B.Content,{size:`lg`,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{children:`Preferences`}),(0,X.jsx)(B.Description,{children:`Customize shortcuts and how Vellum behaves on this device.`})]}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(`div`,{className:`space-y-6`,children:[H()&&(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Keyboard Shortcuts`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Customize the shortcuts for Vellum's commands.`}),(0,X.jsx)(`div`,{className:`mt-2`,children:(0,X.jsx)(Gr,{})})]}),(0,X.jsx)(Jr,{}),H()&&(0,X.jsx)(Yr,{})]})})]})})}function Zr(e){return e===`preview`?`preview`:`stable`}function Qr(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 $r(e){return e.source_release_version?`Stable ${e.source_release_version}`:e.snapshot_name}function ei(e){return e.filter(e=>e.ready_to_use)}function ti(e){return e?.feature_enabled===!1}function ni({assistantId:e,onComplete:t}){let n=G.use.previewChannel(),r=d(),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,m]=(0,Y.useState)(`restore_backup`),[h,g]=(0,Y.useState)(``),_=ht({path:{assistant_id:e}}),v=mt({path:{assistant_id:e}}),b=kt({path:{id:e}}),{data:x,isLoading:S,isError:C}=f({..._,enabled:n,retry:!1}),w=x?.preview_backups??[],T=(0,Y.useMemo)(()=>ei(w),[w]),D=T[0],O=T.find(e=>e.snapshot_name===h)??D,k=()=>{r.invalidateQueries({queryKey:v}),r.invalidateQueries({queryKey:b}),t?.()},j=p(Pt()),M=p(Tt()),N=Zr(x?.current_channel),P=j.isPending||M.isPending,F=P||ti(x)||!x?.latest_preview_release,ee=u===`restore_backup`&&!O;if((0,Y.useEffect)(()=>{a(N===`preview`?`release-channel`:void 0)},[N]),!n)return null;let I=x?.standard_upgrade_available??!1;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E.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,X.jsxs)(E.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,X.jsxs)(E.Trigger,{className:`group justify-between gap-3`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Release Channel`}),x&&(0,X.jsx)(he,{tone:N===`preview`?`warning`:`neutral`,children:N===`preview`?`Preview`:`Stable`})]}),(0,X.jsx)(y,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,X.jsx)(E.Content,{children:(0,X.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[S&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),C&&(0,X.jsx)(R,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),x&&(0,X.jsxs)(X.Fragment,{children:[ti(x)&&(0,X.jsx)(R,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),N===`stable`?(0,X.jsx)(ri,{status:x,isChangingChannel:P,optInDisabled:F,onOptIn:()=>s(!0)}):(0,X.jsx)(ii,{status:x,isChangingChannel:P,onOptOut:()=>{let e=D;g(e?.snapshot_name??``),m(e?`restore_backup`:I?`standard_upgrade`:`restore_backup`),l(!0)}})]})]})})]})}),(0,X.jsx)(oi,{open:o,isPending:j.isPending,previewVersion:x?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await j.mutateAsync({path:{assistant_id:e}});V.success(t.detail||`Preview channel enabled.`),s(!1),k()}catch(e){V.error(U(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,X.jsx)(si,{open:c,backups:T,mode:u,selectedSnapshotName:O?.snapshot_name??``,isPending:M.isPending,restoreModeDisabled:ee,standardUpgradeAvailable:I,onModeChange:m,onSnapshotChange:g,onConfirm:async()=>{if(!ee)try{let t=await M.mutateAsync({path:{assistant_id:e},body:u===`restore_backup`?{mode:`restore_backup`,snapshot_name:O?.snapshot_name}:{mode:`standard_upgrade`}});V.success(t.detail||`Stable channel enabled.`),l(!1),k()}catch(e){V.error(U(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>l(!1)})]})}function ri({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(ai,{status:e}),!e.latest_preview_release&&(0,X.jsx)(R,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,X.jsx)(s,{variant:`outlined`,leftIcon:t?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(N,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function ii({status:e,isChangingChannel:t,onOptOut:n}){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(ai,{status:e}),(0,X.jsx)(s,{variant:`outlined`,leftIcon:t?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(ce,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function ai({status:e}){return(0,X.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Stable`}),(0,X.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??`None`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Preview`}),(0,X.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_preview_release?.version??`None`})]})]})}function oi({open:e,isPending:t,previewVersion:n,onConfirm:r,onCancel:i}){return(0,X.jsx)(B.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,X.jsxs)(B.Content,{size:`md`,hideCloseButton:t,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{icon:fe,children:`Opt in to Preview`}),(0,X.jsx)(B.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(R,{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,X.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,X.jsx)(`li`,{children:`Create and verify a Preview safety backup.`}),(0,X.jsxs)(`li`,{children:[`Switch to Preview image `,n??`latest`,`.`]}),(0,X.jsx)(`li`,{children:`Run the normal upgrade path and wait for health.`})]})]})}),(0,X.jsxs)(B.Footer,{children:[(0,X.jsx)(s,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,X.jsx)(s,{variant:`primary`,disabled:t,leftIcon:t?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(N,{}),onClick:r,children:t?`Switching...`:`Take Backup and Switch`})]})]})})}function si({open:e,backups:t,mode:n,selectedSnapshotName:r,isPending:i,restoreModeDisabled:a,standardUpgradeAvailable:o,onModeChange:c,onSnapshotChange:l,onConfirm:u,onCancel:d}){return(0,X.jsx)(B.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,X.jsxs)(B.Content,{size:`md`,hideCloseButton:i,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{icon:fe,children:`Switch back to Stable`}),(0,X.jsx)(B.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(w,{value:n,onValueChange:c,disabled:i,"aria-label":`Stable channel return method`,children:[(0,X.jsx)(C,{value:`restore_backup`,disabled:t.length===0,label:`Restore safety backup`,helperText:`Return to the Stable-channel data captured before Preview opt-in.`}),(0,X.jsx)(C,{value:`standard_upgrade`,disabled:!o,label:`Switch to Stable without restoring backup`,helperText:o?`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,X.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[`Safety backup`,(0,X.jsx)(ve,{value:r,onChange:l,disabled:i,options:t.map(e=>({value:e.snapshot_name,label:`${$r(e)} - ${Qr(e.created_at)}`}))})]}),n===`restore_backup`&&t.length===0&&!o&&(0,X.jsx)(R,{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,X.jsx)(R,{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,X.jsxs)(B.Footer,{children:[(0,X.jsx)(s,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,X.jsx)(s,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||a||n===`standard_upgrade`&&!o,leftIcon:i?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(se,{}),onClick:u,children:i?`Switching...`:`Switch to Stable`})]})]})})}var ci=new Set([`exceeds_machine_tier`,`exceeds_storage_tier`]);function li(e,t){return e&&typeof e==`object`&&!Array.isArray(e)&&`error`in e&&typeof e.error==`string`&&ci.has(e.error)?`That size isn't available on your plan.`:U(e,void 0,t)}function ui({assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}){let o=u(),c=ot(),d=f(jt()),p=d.data,m=!e.is_local,h=p?.plan_id===`pro`,g=f({...Mt(),enabled:h}),_=e.machine_size||`small`,v=Xt(g.data?.max_machine_tier??null),y=(0,Y.useMemo)(()=>$t(v,_,(0,X.jsx)(he,{tone:`positive`,children:`Current`})),[v,_]),b=g.data?.selected_storage_gib??null,[x,S]=(0,Y.useState)(!1),C=v.length>0?v[v.length-1]:null,[w,T]=(0,Y.useState)(null),E=w??C??_,[D,k]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(null),N=At({onSuccess:(e,n)=>{V.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),M(null),T(null),S(!1),n.body?.machine_size==null?i():a(t)},onError:e=>{M(li(e,`Failed to resize assistant. Please try again.`))}});if(d.isError&&p==null)return(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,X.jsx)(R,{tone:`error`,children:`Could not load your subscription. Please try again.`})});let P=h&&v.includes(E)&&E!==_?E:null,F=h&&b!=null&&!0,ee=h&&v.length>0&&Qt(_)<Qt(v[v.length-1]),I=N.isPending||r,te=b==null?t?.disk?.totalMb??null:b*1024,ne=t?.disk&&te!=null?{value:t.disk.usedMb,max:te,caption:`${on(t.disk.usedMb)} of ${on(te)}`}:null,L=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,re=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${on(t.memory.currentMb)} of ${on(t.memory.maxMb)}`}:null,ie=c?null:(0,X.jsx)(s,{variant:`ghost`,size:`compact`,onClick:()=>k(!0),children:`Resize`}),ae=m?h?F?(0,X.jsxs)(`button`,{type:`button`,disabled:I,onClick:()=>S(!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,X.jsx)(ue,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,X.jsx)(s,{variant:`ghost`,size:`compact`,disabled:I,onClick:()=>S(!0),children:`Resize`}):ie:null,oe=m?h?ee?(0,X.jsxs)(`button`,{type:`button`,disabled:I,onClick:()=>S(!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,X.jsx)(ue,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,X.jsx)(s,{variant:`ghost`,size:`compact`,disabled:I,onClick:()=>S(!0),children:`Resize`}):ie:null;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,compactAccessory:!0,accessory:(0,X.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(se,{}),tooltip:r?`Applying resize…`:`Refresh resource metrics`,"aria-label":`Refresh resource metrics`,disabled:n||r,onClick:()=>void i()}),children:(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,X.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),ae]}),(0,X.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Storage`}),ne?(0,X.jsx)(tn,{value:ne.value,max:ne.max,caption:ne.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(A,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Unavailable`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,X.jsx)(ln,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Machine`}),(0,X.jsx)(he,{tone:`neutral`,children:Zt[_]})]}),oe]}),(0,X.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`CPU`}),L?(0,X.jsx)(tn,{value:L.value,max:L.max,caption:L.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(A,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Memory`}),re?(0,X.jsx)(tn,{value:re.value,max:re.max,caption:re.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(A,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,X.jsx)(B.Root,{open:D,onOpenChange:e=>{e||k(!1)},children:(0,X.jsxs)(B.Content,{size:`sm`,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{children:`Upgrade your plan`}),(0,X.jsx)(B.Description,{children:`Move to a higher plan for more power, more storage, and a larger credit bundle.`})]}),(0,X.jsxs)(B.Footer,{children:[(0,X.jsx)(s,{variant:`ghost`,onClick:()=>k(!1),children:`Cancel`}),(0,X.jsx)(s,{onClick:()=>{k(!1),o(K.plans)},children:`Upgrade`})]})]})}),(0,X.jsx)(B.Root,{open:x,onOpenChange:e=>{e||(S(!1),T(null),M(null))},children:(0,X.jsxs)(B.Content,{size:`sm`,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{icon:ln,children:`Resize Assistant`}),(0,X.jsx)(B.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[v.length===0?(0,X.jsx)(R,{tone:`warning`,children:`No machine tier configured. Visit the community for help.`}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:`Machine Size`}),(0,X.jsx)(ve,{options:y,value:E,onChange:T,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),F?(0,X.jsx)(R,{tone:`info`,children:`Storage will be expanded to ${b} GB.`}):(0,X.jsx)(R,{tone:`neutral`,children:`Storage will not change.`}),j&&(0,X.jsx)(R,{tone:`error`,children:j})]})}),(0,X.jsxs)(B.Footer,{className:c?`justify-end`:`items-center justify-between`,children:[c?null:(0,X.jsxs)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:[`Need more?`,` `,(0,X.jsx)(l,{to:K.plans,className:`text-[var(--content-secondary)] underline decoration-[var(--border-element)] underline-offset-2 transition-colors hover:text-[var(--content-default)]`,onClick:()=>S(!1),children:`Upgrade plan`})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(s,{variant:`ghost`,onClick:()=>{S(!1),T(null),M(null)},children:`Cancel`}),(0,X.jsx)(s,{disabled:P==null&&!F||I,leftIcon:I?(0,X.jsx)(A,{className:`animate-spin`}):void 0,onClick:()=>{M(null);let t={};P!=null&&(t.machine_size=P),F&&b!=null&&(t.storage_gib=b),N.mutate({path:{id:e.id},body:t})},children:j?`Retry`:`Apply`})]})]})]})})]})}function di({assistantId:e}){let t=u(),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(s,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,X.jsx)(Rt,{open:n,isPending:i,onConfirm:async()=>{a(!0);let n=await Lt(e);if(n.ok){r(!1),t(n.nextRoute,{replace:!0});return}V.error(n.error),a(!1),r(!1)},onCancel:()=>r(!1)})]})}function fi(){let e=oe(),t=ae.useValue();return F(e)?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,X.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Show tips`}),(0,X.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,X.jsx)(ge,{checked:t,onChange:t=>{ae.save(t),t||re(`settings`,`dont_show_again`,e)},"aria-label":`Show tips`})]}):null}var pi=`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 mi(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...pi].sort()}function hi(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 gi(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function _i(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 vi({value:e,onChange:t}){let[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useMemo)(()=>mi().map(e=>hi(e)).filter(e=>e!==null),[]);(0,Y.useEffect)(()=>{let e=window.setTimeout(()=>{a(n.trim().toLowerCase())},200);return()=>window.clearTimeout(e)},[n]),(0,Y.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,Y.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,Y.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,X.jsxs)(`div`,{ref:c,className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Closest city`}),(0,X.jsxs)(`div`,{className:`relative w-full md:max-w-[280px]`,children:[(0,X.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`&&(e.preventDefault(),r(``),s(!1),l.current?.blur())},fullWidth:!0}),o&&d.length>0&&(0,X.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,X.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,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-body-medium-default`,children:t.city}),t.region&&(0,X.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:t.region})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,X.jsx)(`span`,{children:gi(t.identifier)}),(0,X.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,X.jsx)(sn,{}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Time zone`}),(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:_i(e)})]})]})}function yi(){let e=je.use.activeAssistantId(),[t,n]=(0,Y.useState)(()=>i(`timezone`,``)),o=(0,Y.useRef)(e);(0,Y.useEffect)(()=>{o.current=e},[e]);let s=(0,Y.useRef)(!1),c=(0,Y.useRef)(null),l=(0,Y.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,W.patch({url:`/v1/assistants/{assistant_id}/config`,path:{assistant_id:t},body:{ui:{userTimezone:e}},throwOnError:!0}).catch(e=>{a(e,{context:`settings-timezone-override`})}).finally(()=>{s.current=!1;let e=c.current;c.current=null,e!==null&&l.current(e)})};return(0,Y.useEffect)(()=>{l.current=u}),(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Timezone`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Used when displaying times and scheduling reminders.`}),(0,X.jsx)(`div`,{className:`mt-1`,children:(0,X.jsx)(vi,{value:t,onChange:e=>{n(e),r(`timezone`,e),u(e)}})})]})}var bi=[[`Mon`,0],[`Tue`,1],[`Wed`,2],[`Thu`,3],[`Fri`,4],[`Sat`,5],[`Sun`,6]];function xi(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 Si(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 Ci(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function wi(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:xi(t),windowEnd:xi(n)}}function Ti({assistantId:e}){let t=d(),{data:n,isLoading:r,isError:i}=f(yt({path:{id:e}})),a=(0,Y.useMemo)(()=>wi(n),[n]),[o,c]=(0,Y.useState)(null),l=o??a,u=o!==null,m=(0,Y.useMemo)(()=>Ci(),[]),[h,g]=(0,Y.useState)(null),_=h??l.daysOfMonth.join(`, `),v=p({mutationFn:async t=>{let{data:n}=await Ye({path:{id:e},body:t,throwOnError:!0});return n}}),y=e=>{c(t=>({...t??a,...e}))},b=e=>{y({daysOfWeek:l.daysOfWeek.includes(e)?l.daysOfWeek.filter(t=>t!==e):[...l.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,X.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading update window settings...`]}):i?(0,X.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,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsx)(ge,{checked:l.enabled,onChange:e=>y({enabled:e}),label:`Automatic updates`,helperText:`Update automatically during a configured time window`}),l.enabled&&(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Frequency`}),(0,X.jsx)(`div`,{className:`max-w-[400px]`,children:(0,X.jsx)(T,{ariaLabel:`Frequency`,value:l.frequency,onChange:e=>{e!==`monthly`&&g(null),y({frequency:e})},items:[{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}]})})]}),l.frequency===`weekly`&&(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Day(s) of week`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:bi.map(([e,t])=>(0,X.jsx)(s,{variant:`outlined`,size:`compact`,active:l.daysOfWeek.includes(t),onClick:()=>b(t),children:e},t))})]}),l.frequency===`monthly`&&(0,X.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,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:[`Update window`,m?` (${m})`:``]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(z,{type:`time`,value:l.windowStart,onChange:e=>y({windowStart:e.target.value})}),(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`to`}),(0,X.jsx)(z,{type:`time`,value:l.windowEnd,onChange:e=>y({windowEnd:e.target.value})})]})]})]}),(0,X.jsx)(s,{variant:`primary`,leftIcon:v.isPending?(0,X.jsx)(A,{className:`animate-spin`}):void 0,onClick:async()=>{let n=l.frequency===`monthly`&&h!==null?x(h):l.daysOfMonth;try{await v.mutateAsync({enabled:l.enabled,timezone:`UTC`,schedule:{frequency:l.frequency,days_of_week:l.frequency===`weekly`?l.daysOfWeek:[],days_of_month:l.frequency===`monthly`?n:[],window:{start:Si(l.windowStart),end:Si(l.windowEnd)}}}),V.success(`Auto-update policy saved.`),c(null),g(null),t.invalidateQueries({queryKey:St({path:{id:e}})})}catch{V.error(`Failed to save policy. Please try again.`)}},disabled:v.isPending||!u,children:`Save policy`})]})}function Ei({assistantId:e,open:t,onClose:n}){return(0,X.jsx)(B.Root,{open:t,onOpenChange:e=>{e||n()},children:(0,X.jsxs)(B.Content,{size:`md`,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{children:`Update Window`}),(0,X.jsx)(B.Description,{children:`Configure when automatic updates are applied.`})]}),(0,X.jsx)(B.Body,{children:(0,X.jsx)(Ti,{assistantId:e})})]})})}function Di(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`)return t}}function Oi({open:e,onOpenChange:t}){let n=d(),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(!1),f=(0,Y.useRef)(e),p=()=>n.invalidateQueries({queryKey:wt()}),m=e=>{nt({path:{id:e}}).catch(()=>void 0).finally(()=>void p())},h=Ct({onSuccess:e=>{if(!f.current){m(e.factor_id);return}i(e)},onError:e=>{let n=Di(e);n===`no_workos_account`?V.error(`Two-factor authentication is only available for Vellum platform accounts.`):n===`throttled`||n===`workos_rate_limited`?V.error(`Too many attempts. Try again in a minute.`):n===`factor_limit_reached`?V.error(`An authenticator app is already set up. Remove it before adding another.`):V.error(`Failed to start setup. Please try again.`),t(!1)}}),g=_t({onSuccess:e=>{e.valid?(u.current=!0,V.success(`Two-factor authentication is on.`),p(),t(!1)):l(`That code didn't match. Check your authenticator app and try again.`)},onError:e=>{let n=Di(e);if(n===`challenge_already_verified`){u.current=!0,V.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),o(``),l(`This setup session expired. Scan the new QR code and try again.`),h.mutate({});return}if(n===`throttled`||n===`workos_rate_limited`){l(`Too many attempts. Wait a minute and try again.`);return}l(`Couldn't verify the code. Wait a moment and try again.`)}});(0,Y.useEffect)(()=>{f.current=e,e&&(u.current=!1,i(null),o(``),l(null),h.mutate({}))},[e]);let _=e=>{!e&&g.isPending||(!e&&r&&!u.current&&m(r.factor_id),t(e))},v=()=>{r&&Kt(r.secret,{successMessage:`Setup key copied.`,errorMessage:`Couldn't copy the setup key.`})},y=()=>{!r||a.length!==6||g.isPending||(l(null),g.mutate({body:{challenge_id:r.challenge_id,code:a}}))};return(0,X.jsx)(B.Root,{open:e,onOpenChange:_,children:(0,X.jsxs)(B.Content,{size:`sm`,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{children:`Set up authenticator app`}),(0,X.jsx)(B.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,X.jsx)(B.Body,{children:r===null?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,X.jsx)(A,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,X.jsxs)(`form`,{className:`flex flex-col items-center gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,X.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,X.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Can't scan it? Enter this setup key manually:`}),(0,X.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,X.jsx)(`span`,{className:`break-all text-left`,children:r.secret}),(0,X.jsx)(S,{className:`h-3.5 w-3.5 shrink-0`})]})]}),(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,X.jsx)(`label`,{htmlFor:`totp-code`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:`6-digit code`}),(0,X.jsx)(z,{id:`totp-code`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,placeholder:`123456`,value:a,onChange:e=>o(e.target.value.replace(/\D/g,``).slice(0,6))}),c&&(0,X.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--system-negative-strong)]`,children:c})]})]})}),(0,X.jsxs)(B.Footer,{children:[(0,X.jsx)(s,{variant:`outlined`,onClick:()=>_(!1),disabled:g.isPending,children:`Cancel`}),(0,X.jsx)(s,{onClick:y,disabled:r===null||a.length!==6||g.isPending,children:g.isPending?`Verifying…`:`Verify`})]})]})})}function ki(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function Ai(){let e=d(),[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(null),a=f({...vt()}),o=a.data??[],c=()=>e.invalidateQueries({queryKey:wt()}),l=gt({onSuccess:()=>{V.success(`Authenticator app removed.`),c()},onError:e=>{if(Di(e)===`factor_not_found`){c();return}V.error(`Failed to remove the authenticator app. Please try again.`)}});return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[a.isPending?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,X.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,X.jsx)(`span`,{className:`text-body-medium-default`,children:`Loading authenticator apps…`})]}):a.isError?(0,X.jsxs)(R,{tone:`error`,children:[`Couldn't load your authenticator apps.`,` `,(0,X.jsx)(`button`,{type:`button`,className:`cursor-pointer underline`,onClick:()=>void a.refetch(),children:`Try again`})]}):o.length===0?(0,X.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,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:o.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(le,{className:`h-5 w-5 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Authenticator app`}),(0,X.jsxs)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:[e.user,e.created_at?` · Added ${ki(e.created_at)}`:``]})]})]}),(0,X.jsx)(s,{variant:`dangerOutline`,onClick:()=>i(e),disabled:l.isPending,children:`Remove`})]},e.id))}),!a.isPending&&!a.isError&&o.length===0&&(0,X.jsx)(s,{onClick:()=>n(!0),className:`self-start`,children:`Add authenticator app`}),(0,X.jsx)(Oi,{open:t,onOpenChange:n}),(0,X.jsx)(_e,{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&&l.mutate({path:{id:r.id}}),i(null)},onCancel:()=>i(null)})]})}var Q=class extends Error{code;constructor(e,t){super(t),this.name=`TeleportError`,this.code=e}},ji=`local`,Mi=`docker`,Ni=`vellum`;function Pi(e){switch((e??``).toLowerCase()){case ji:return`local`;case Mi:return`docker`;case Ni:return`managed`;default:return`other`}}function Fi(e){let t=Pi(e);return t===`managed`?`local`:t===`local`?`platform`:null}function Ii(e){switch(e){case`docker`:return`Move to Docker`;case`platform`:return`Move to Cloud (Platform)`;case`local`:return`Move to Local`}}function Li(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 Ri(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 zi(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 Bi(e){let t=De(e);if(!t)throw new Q(`local_assistant_not_found`,`Assistant ${e.assistantId} has no resolved local gateway.`);return`${window.location.origin}${t}`}async function Vi(e,t){let n=await ke(e.assistantId),r=await fetch(`${t}/auth/token`,{method:`POST`,headers:{Authorization:`Bearer ${n}`}});if(!r.ok)throw new Q(`not_signed_in`,`Gateway token request failed (HTTP ${r.status}).`);let{token:i}=await r.json();return i}async function Hi(e,t){let n=Bi(e),r=await Vi(e,n),i=await fetch(`${n}/v1/migrations/export`,{method:`POST`,headers:{Authorization:`Bearer ${r}`}});if(!i.ok)throw new Q(`export_failed`,`Export failed (HTTP ${i.status}).`);return zi(i,t)}async function Ui(e,t){let n=Bi(e),r=await Vi(e,n),i=await fetch(`${n}/v1/migrations/import`,{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:new Blob([t],{type:`application/octet-stream`})});if(!i.ok)throw new Q(`import_failed`,`Import failed (HTTP ${i.status}).`);let a=await Ki(i);if(a&&a.success===!1)throw new Q(`import_failed`,a.error??`Import reported failure`)}async function Wi(e,t){let{data:n,response:r}=await W.post({url:`/v1/assistants/{assistant_id}/migrations/export-to-gcs/`,path:{assistant_id:e},body:{upload_url:t},throwOnError:!1}),i=r?.status??0;if(!(r?.ok??!1)&&i!==202)throw new Q(`export_failed`,`Export failed (HTTP ${i}).`);let a=n?.job_id;if(!a)throw new Q(`export_failed`,`Export accepted but no job ID was returned.`);return a}async function Gi(e,t){let{data:n,response:r}=await W.get({url:`/v1/assistants/{assistant_id}/migrations/jobs/{job_id}`,path:{assistant_id:e,job_id:t},throwOnError:!1}),i=r?.status??0;if(i>=500)return`processing`;if(!(r?.ok??!1))throw new Q(`export_job_failed`,`Job status check failed (HTTP ${i})`);let a=n;if(a?.status===`failed`)throw new Q(`export_job_failed`,a.error??`Export job failed`);return a?.status??`processing`}async function Ki(e){try{return await e.json()}catch{return null}}var qi=new Set([500,502,503,504]),$=3,Ji=e=>new Promise(t=>setTimeout(t,e));async function Yi(e,t=new Set){for(let n=0;n<=$;n++){let{response:r,data:i,error:a}=await e(),o=r?.status??0;if(n<$&&qi.has(o)&&!t.has(o)){await Ji(2**n*1e3);continue}return{status:o,data:i,error:a}}throw new Q(`unknown`,`Unexpected retry loop exit`)}async function Xi(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 Yi(()=>W.post({url:`/v1/migrations/signed-url/`,body:n,throwOnError:!1}),new Set([404,503]));if(r===503||r===404)throw new Q(`export_failed`,`Signed URL uploads are not available — the platform may not support this feature yet.`);if(r!==201)throw new Q(`export_failed`,`Migration request failed (HTTP ${r}).`);let a=i;return{url:a.url,bundleKey:a.bundle_key,expiresAt:a.expires_at}}async function Zi(e,t){let{status:n,data:r,error:i}=await Yi(()=>W.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=Ri(i);if(e)throw new Q(`version_mismatch`,e)}if(n!==200&&n!==201)throw new Q(`import_failed`,`Migration request failed (HTTP ${n}).`);return r.url}async function Qi(e,t,n){for(let r=0;r<=$;r++){let i=await $i(e,t,n);if(r<$&&qi.has(i)){await Ji(2**r*1e3),n?.(0);continue}if(i<200||i>=300)throw new Q(`export_failed`,`Bundle upload failed (HTTP ${i}).`);return}}function $i(e,t,n){return new Promise((r,i)=>{let a=new XMLHttpRequest;a.open(`PUT`,e),a.setRequestHeader(`Content-Type`,`application/octet-stream`),a.timeout=36e5,n&&(a.upload.onprogress=e=>{e.lengthComputable&&n(e.loaded/e.total)}),a.onload=()=>{n?.(1),r(a.status)},a.onerror=()=>i(new Q(`export_failed`,`Bundle upload failed.`)),a.ontimeout=()=>i(new Q(`export_timed_out`,`Bundle upload timed out.`)),a.send(t)})}async function ea(e,t){for(let n=0;n<=$;n++){let r=await fetch(e,{method:`GET`});if(n<$&&qi.has(r.status)){await Ji(2**n*1e3),t?.(0);continue}if(!r.ok)throw new Q(`import_failed`,`Bundle download failed (HTTP ${r.status}).`);return zi(r,t)}throw new Q(`import_failed`,`Unexpected retry loop exit`)}async function ta(e){let{status:t,data:n,error:r}=await Yi(()=>W.post({url:`/v1/migrations/import-from-gcs/`,body:{bundle_key:e},throwOnError:!1}));return{status:t,body:n??r??null}}async function na(e){let{status:t,data:n}=await Yi(()=>W.get({url:`/v1/migrations/jobs/{job_id}/`,path:{job_id:e},throwOnError:!1}));if(t!==200)throw new Q(`import_failed`,`Job status check failed (HTTP ${t})`);let r=n??{};return{status:typeof r.status==`string`?r.status:`unknown`,jobId:typeof r.job_id==`string`?r.job_id:null,error:typeof r.error==`string`?r.error:null}}var ra=5e3,ia=36e5,aa=5*6e4,oa=30,sa=e=>new Promise(t=>setTimeout(t,e));function ca(){let e=u(),t=Se(),n=Fi(t?.cloud),[r,i]=(0,Y.useState)({kind:`idle`}),[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),d=(0,Y.useCallback)(e=>{i({kind:`transferring`,step:e,progress:null})},[]),f=(0,Y.useCallback)(e=>{i(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,Y.useCallback)(async()=>{if(!(!t||!n)){l.current={id:t.assistantId,kind:Pi(t.cloud)===`managed`?`managed`:`local`,createdFresh:!1};try{if(n===`platform`)await la(t,d,f,c);else if(n===`local`)await ua(t,d,f,c);else throw new Q(`unknown`,`Unsupported teleport destination.`);i({kind:`verifying`})}catch(e){i({kind:`failed`,error:`Teleport failed: ${e instanceof Q||e instanceof Error?e.message:`Teleport failed.`}`}),a(e,{context:`teleport-execute`}),await fa(c.current,l.current,`teleport-execute-cleanup`),c.current=null}}},[t,n,d,f]),m=(0,Y.useCallback)(()=>s(!0),[]),h=(0,Y.useCallback)(()=>s(!1),[]),g=(0,Y.useCallback)(()=>{s(!1),p()},[p]),_=(0,Y.useCallback)(()=>{c.current=null,l.current=null,i({kind:`idle`})},[]);return{destination:n,phase:r,confirmOpen:o,requestTeleport:m,cancelConfirm:h,confirm:g,confirmAndSwitch:(0,Y.useCallback)(()=>{let t=c.current,n=l.current;t&&(async()=>{try{let e=We.getState();t.kind===`managed`?await e.connectPlatformAssistant(t.id):(await e.connectLocalAssistant(t.id),ze(t.id,{onError:e=>a(e,{context:`teleport-inject-platform-identity`})}))}catch(e){i({kind:`failed`,error:`Switch failed: ${e instanceof Error?e.message:`Failed to switch assistant.`}`}),a(e,{context:`teleport-confirm-switch`});return}n&&Lt(n.id).then(e=>{e.ok||a(Error(e.error),{context:`teleport-retire-source`})}),_(),e(K.assistant,{replace:!0})})()},[e,_]),cancelTeleport:(0,Y.useCallback)(()=>{let e=c.current,t=l.current;c.current=null,l.current=null,i({kind:`idle`}),fa(e,t,`teleport-cancel-retire-target`)},[]),reset:_}}async function la(e,t,n,r){t(`Exporting assistant data...`);let i=await Hi(e,n);t(`Resolving organization...`);let a=await ma();t(`Checking for existing assistant...`);let o=(await et({query:{hosting:`platform`},throwOnError:!1})).data?.results?.[0];if(o)throw new Q(`existing_platform_assistant`,`You already have a platform assistant '${o.id}'. Retire it first, then retry the teleport.`);t(`Uploading data to cloud...`);let s=await Xi(e.resources?.runtimeVersion);await Qi(s.url,i,n),t(`Setting up cloud assistant...`);let c=await it(void 0,`create`);if(!c.ok)throw new Q(`import_failed`,`Failed to set up the cloud assistant.`);if(c.status===200)throw new Q(`existing_platform_assistant`,`You already have a platform assistant '${c.data.id}'. Retire it first, then retry the teleport.`);let l=c.data.id;await ye({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:xe(),hatchedAt:c.data.created??new Date().toISOString(),organizationId:a}),await be(e.assistantId),r.current={id:l,kind:`managed`,createdFresh:!0},t(`Finalizing cloud assistant...`),await ha(l),t(`Importing data to cloud...`);let u=await ta(s.bundleKey);if(u.status<200||u.status>=300){let e=u.body;throw new Q(`import_failed`,e?.error??`Import failed (HTTP ${u.status}).`)}if(u.status===202){let e=u.body?.job_id;if(!e)throw new Q(`import_failed`,`Import accepted but no job ID returned.`);await ga(e)}else{let e=u.body;if(e&&e.success===!1)throw new Q(`import_failed`,e.error??`Import reported failure.`)}}async function ua(e,t,n,r){t(`Preparing export...`);let i=await Xi(await pa(e.assistantId),`runtime`);t(`Exporting cloud data...`);let a=await Wi(e.assistantId,i.url);await _a(e.assistantId,a),t(`Preparing local assistant...`);let{assistant:o,createdFresh:s}=await va();r.current={id:o.assistantId,kind:`local`,createdFresh:s};let c=await da(o,s);if(!c)throw new Q(`local_assistant_not_found`,`Could not determine the local assistant's runtime version. Restart or upgrade the local assistant, then retry the teleport.`);t(`Preparing import...`);let l=await Zi(i.bundleKey,c);t(`Downloading data...`);let u=await ea(l,n);t(`Importing data...`),await ba(o,u),await be(e.assistantId)}async function da(e,t){if(e.resources?.runtimeVersion)return e.resources.runtimeVersion;if(t)return(await Yt())?.version??void 0}async function fa(e,t,n){if(e?.createdFresh){let t=await Lt(e.id);t.ok||a(Error(t.error),{context:n})}t&&await be(t.id)}async function pa(e){let t=await rt(e);return t.ok?t.data.version??void 0:void 0}async function ma(){let e=Ve.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=Ve.getState().organizations,n=Ge();if(n&&t.some(e=>e.id===n))return n;if(t.length===0)throw new Q(`no_organizations`,`No organizations found for this account.`);if(t.length>1)throw new Q(`multiple_organizations`,`Multiple organizations found — please select one in account settings first.`);let r=t[0].id;return Ve.getState().setCurrentOrganizationId(r),r}async function ha(e){let t=Date.now();for(;Date.now()-t<aa;){let{data:t,response:n}=await Ze({path:{id:e},throwOnError:!1});if(n?.ok&&t?.state===`active`)return;await sa(ra)}}async function ga(e){let t=Date.now();for(;Date.now()-t<ia;){await sa(ra);let t=await na(e);if(t.status===`complete`)return;if(t.status===`failed`)throw new Q(`import_failed`,t.error??`Import job failed`)}throw new Q(`import_failed`,`Import timed out after 60 minutes.`)}async function _a(e,t){let n=Date.now();for(;Date.now()-n<ia;)if(await sa(ra),await Gi(e,t)===`complete`)return;throw new Q(`export_timed_out`,`Export timed out.`)}async function va(){let e=await Oe(void 0,void 0);if(!e.ok)throw new Q(`local_assistant_not_found`,e.error??`Could not create a local assistant.`);await Te();let t=e.assistantId?Ae().find(t=>t.assistantId===e.assistantId):ya();if(!t)throw new Q(`local_assistant_not_found`,`Could not find or create a local assistant.`);return{assistant:t,createdFresh:!0}}function ya(){return Ae().slice().sort((e,t)=>(t.hatchedAt??``).localeCompare(e.hatchedAt??``))[0]}async function ba(e,t){let n;for(let r=0;r<oa;r++)try{await Ui(e,t);return}catch(e){n=e,await sa(1e3)}throw n instanceof Error?n:new Q(`import_failed`,`Import failed.`)}function xa(){let e=ca(),{destination:t,phase:n}=e;return t?(0,X.jsxs)(J,{title:`Teleport`,subtitle:`Move your assistant to a different hosting environment.`,children:[n.kind===`idle`&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:Li(t)}),(0,X.jsx)(s,{variant:`outlined`,className:`self-start`,onClick:e.requestTeleport,children:Ii(t)})]}),n.kind===`transferring`&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.progress==null&&(0,X.jsx)(A,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:n.step})]}),n.progress!=null&&(0,X.jsx)(me,{value:n.progress,"aria-label":`Teleport progress`,className:`max-w-[240px]`})]}),n.kind===`verifying`&&(0,X.jsx)(R,{tone:`success`,icon:(0,X.jsx)(x,{className:`h-4 w-4`}),title:`Transfer complete — verify your new assistant is working.`,actions:(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(s,{variant:`primary`,onClick:e.confirmAndSwitch,children:`Confirm & Switch`}),(0,X.jsx)(s,{variant:`outlined`,onClick:e.cancelTeleport,children:`Cancel`})]})}),n.kind===`failed`&&(0,X.jsx)(R,{tone:`error`,title:n.error,actions:(0,X.jsx)(s,{variant:`outlined`,onClick:e.reset,children:`Try Again`})}),(0,X.jsx)(_e,{open:e.confirmOpen,title:Ii(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 Sa(){let{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}=rn(),o=G.use.multiPlatformAssistant(),l=G.use.assistantSwitcher()&&we(),d=G.use.teleport(),f=G.use.accountMfa(),p=Ft.use.settingsSleepPolicy(),m=Be(),h=u(),g=ct(),_=ct({platformHostedOnly:!0}),v=ut(),y=ot(),b=te({assistantId:e?.id??null,enabled:_===`full`&&v}),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(!1),[T,E]=c();(0,Y.useEffect)(()=>{if(T.get(`preferences`)!==`open`)return;let e=new URLSearchParams(T);e.delete(`preferences`),E(e,{replace:!0}),w(!0)},[T,E]);let D=e?.is_local&&!we()?null:e,O=Se(),k=we()&&!!e&&!!O&&Ce(O),A=k,j=k&&!Ee(),M=_===`full`&&!!D||j&&!!e;(0,Y.useEffect)(()=>{!e||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[e]);let N=t?.version??e?.current_release_version??null,P=(g===`full`||A)&&!!D||g===`disabled`&&!A,F=_!==`gated`;return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[b.status&&b.mode!==`inactive`&&(0,X.jsx)(ee,{status:b.status,mode:b.mode,isAcknowledging:b.isAcknowledging,acknowledgeError:b.acknowledgeError?.message??null,onAcknowledge:()=>void b.acknowledge(),onReviewWorkspaceData:()=>void h(`${K.workspace}?sort=size`),onUpgradeStorage:_===`full`&&!y?()=>void h(K.plans):null}),(0,X.jsxs)(wn,{assistant:v?D:null,showHandles:m&&g===`full`,children:[(0,X.jsx)(yi,{}),f&&g!==`gated`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Two-Factor Authentication`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Require a code from an authenticator app when you sign in.`}),(0,X.jsx)(`div`,{className:`mt-1`,children:g===`disabled`?(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage two-factor authentication.`}):(0,X.jsx)(Ai,{})})]})]})]}),(0,X.jsx)(J,{title:`Version`,subtitle:`Manage your assistant's software version and updates.`,accessory:_===`full`&&D?(0,X.jsx)(s,{variant:`outlined`,onClick:()=>S(!0),children:`Update Window`}):void 0,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[_===`full`&&D&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pn,{assistantId:D.id,currentVersion:N,releaseChannel:D.release_channel,onUpgradeComplete:()=>{i()}}),(0,X.jsx)(ni,{assistantId:D.id,onComplete:()=>{i()}})]}),j&&e&&(0,X.jsx)(Fn,{assistantId:e.id,currentVersion:N,onUpgradeComplete:()=>{i()}}),!M&&e&&(0,X.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,X.jsx)(an,{version:N,loading:n&&!e.current_release_version,assistantId:e.id??null})]}),_===`disabled`&&!j&&(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage software updates.`})]})}),_===`full`&&D&&(0,X.jsx)(Ei,{assistantId:D.id,open:x,onClose:()=>S(!1)}),_===`full`&&e&&(0,X.jsx)(ui,{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}),_===`disabled`&&(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage compute resources.`})}),(0,X.jsx)(J,{title:`Preferences`,subtitle:`Customize how Vellum looks and behaves on this device.`,accessory:(0,X.jsx)(s,{variant:`outlined`,onClick:()=>w(!0),children:`Customize`}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsx)(dn,{}),(0,X.jsx)(fi,{})]})}),(0,X.jsx)(Xr,{open:C,onClose:()=>w(!1)}),d&&H()&&(0,X.jsx)(xa,{}),(0,X.jsx)(Rn,{}),(0,X.jsx)(Pr,{}),_===`full`&&D&&p&&(0,X.jsx)(J,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,X.jsx)(An,{assistantId:D.id})}),_===`disabled`&&p&&(0,X.jsx)(J,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage sleep policy.`})}),o&&!l&&(0,X.jsx)(Dn,{}),l&&(0,X.jsx)(J,{title:`Switch Assistant`,subtitle:`Choose which assistant this device is connected to.`,accessory:(0,X.jsx)(s,{variant:`outlined`,onClick:()=>void h(`${K.selectAssistant}?noAutoSkip=1`),children:`Choose Assistant`})}),(P||F)&&(0,X.jsx)(J,{variant:`danger`,title:`Danger Zone`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[P&&(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Retire Assistant`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently retire this assistant and delete all associated data.`}),(0,X.jsx)(`div`,{className:`mt-1`,children:(g===`full`||A)&&D?(0,X.jsx)(di,{assistantId:D.id}):(0,X.jsx)(q,{children:`Log in to the Vellum platform to retire this assistant.`})})]}),P&&F&&(0,X.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,X.jsx)(In,{})]})})]})}export{Sa as GeneralPage};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n}from"./local-settings-Bx7FsNo5.js";import{o as r,r as i}from"./device-settings-CUIsZfaf.js";import{t as a}from"./capture-error-CqtAGHQu.js";import{t as o}from"./react-BFJW0bSv.js";import{t as s}from"./button-BwFudwM5.js";import{m as c,t as l,u}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as d}from"./QueryClientProvider-CMu7CkQU.js";import{t as f}from"./useQuery-Bz-fbQ-m.js";import{t as p}from"./useMutation-CXGTrp4W.js";import{t as m}from"./jsx-runtime-D3ZM-ToX.js";import{t as h}from"./card-DRIctGVs.js";import{t as g}from"./createLucideIcon-CAM1RhH8.js";import{t as _}from"./bell-2SnK9BVD.js";import{t as v}from"./check-Dt2rQhdg.js";import{t as y}from"./chevron-down-BNidRDh1.js";import{t as b}from"./circle-alert-DQMH8VJH.js";import{t as x}from"./circle-check-DvrCdroD.js";import{F as S,L as C,R as w,V as T,a as E,n as D}from"./src-CwGlaCIx.js";import{t as O}from"./hard-drive-sI2ZzmqM.js";import{t as k}from"./heart-DFD4eqW-.js";import{t as A}from"./loader-circle-DWWXcfTQ.js";import{t as j}from"./monitor-RX4oi4Nj.js";import{t as M}from"./moon-CHW45huN.js";import{S as N,a as P,b as F,c as ee,f as I,l as te,n as ne,o as L,p as re,s as ie,v as ae,x as oe}from"./use-ios-app-nudge-9Qqz96FD.js";import{t as se}from"./refresh-cw-EZQqnaxp.js";import{t as ce}from"./rotate-ccw-CL6IkaAI.js";import{t as le}from"./smartphone-CIrxb2NM.js";import{t as ue}from"./sparkles-DfEFn3Bh.js";import{t as de}from"./sun-BauGiwdK.js";import{t as fe}from"./triangle-alert-D6bAGtMw.js";import{t as pe}from"./x-D4O9yIS7.js";import{t as R}from"./notice-Dslxs3H6.js";import{t as me}from"./progress-bar-3GUUAhXi.js";import{t as he}from"./tag-G0ELn_cq.js";import{t as z}from"./input-CgGeKtja.js";import{t as ge}from"./toggle-BEPV0rQM.js";import{t as B}from"./modal-DagTZ8xj.js";import{n as V}from"./toast-BHjG1kP8.js";import{t as _e}from"./confirm-dialog-B7WBNDbT.js";import{t as ve}from"./dropdown-CJVkL1Yp.js";import{C as ye,T as be,at as xe,c as Se,d as Ce,f as we,g as Te,h as Ee,i as De,j as Oe,k as ke,r as Ae}from"./local-mode-DHueA-BJ.js";import{t as H}from"./is-electron-DIlIrdJX.js";import{n as je}from"./resolved-assistants-store-C6oDdTxB.js";import{r as Me,t as Ne}from"./semver-Bfq1LtyW.js";import{i as Pe}from"./utils-DtVy-_pB.js";import{n as Fe,r as U,t as Ie}from"./api-errors-BRGPPSWw.js";import{C as Le,T as Re,Z as ze,a as Be,at as Ve,b as He,h as Ue,n as We,rt as Ge,tt as Ke,w as qe,x as Je}from"./auth-store-C9aYqB9U.js";import{t as W}from"./client.gen-Dq2brHDV.js";import{$ as Ye,C as Xe,N as Ze,P as Qe,Q as $e,T as et,W as tt,Wt as nt}from"./sdk.gen-ies09CqM.js";import{a as rt,o as it}from"./api-CGsj1Pig.js";import{t as G}from"./client-feature-flag-store-Cw39NfCq.js";import{d as K}from"./routes-DrfnNoYS.js";import{a as at,d as ot,l as st}from"./platform-detection-AHYibqOx.js";import{i as ct,r as lt,t as ut}from"./use-platform-gate-C5bNA5Pn.js";import{t as dt}from"./hard-navigate-BYoBFmE4.js";import{A as ft,At as pt,D as mt,E as ht,Ft as gt,It as _t,Lt as vt,N as yt,Nt as bt,O as xt,P as St,Pt as Ct,Rt as wt,T as Tt,Tt as Et,c as Dt,j as Ot,k as kt,kt as At,lt as jt,st as Mt,v as Nt,w as Pt}from"./react-query.gen-BtYBixpk.js";import{t as Ft}from"./assistant-feature-flag-store-BojuHxUH.js";import{t as It}from"./pointer-CQ4DXHXb.js";import{n as Lt,t as Rt}from"./retire-confirm-dialog-PvFzzHrQ.js";import{a as zt,i as Bt,r as Vt,s as Ht}from"./local-runtime-upgrade-CnY-6TiF.js";import{t as Ut}from"./proxy-DrtKRLtr.js";import{t as Wt}from"./AnimatePresence-CHo6D7IH.js";import{t as Gt}from"./use-reduced-motion-fR0m_opJ.js";import{t as Kt}from"./copy-to-clipboard-Y0mxY68V.js";import{t as q}from"./platform-login-notice-DvWjpI2S.js";import{t as qt}from"./use-active-assistant-id-JLsAfn3e.js";import{t as Jt}from"./use-copy-to-clipboard-RUBxQIiE.js";import{t as J}from"./detail-card-Br_T-73R.js";import{t as Yt}from"./app-info-BDq_9VB8.js";import{a as Xt,i as Zt,l as Qt,o as $t}from"./machine-sizes-B9nt_h-U.js";import{t as en}from"./environment-store-DxX3xxt2.js";import{a as tn,i as nn,n as rn,r as an,t as on}from"./assistant-status-panel-ZdWgKADH.js";import{t as sn}from"./settings-divider-COV4-sHz.js";var cn=g(`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`}]]),ln=g(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),un=g(`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`}]]),Y=e(o(),1),X=m();function dn(){let e=G.use.velvet(),{theme:t,setThemePreference:n}=I(),r=[{value:`system`,label:`System`,icon:(0,X.jsx)(j,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,X.jsx)(de,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,X.jsx)(M,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,X.jsx)(k,{className:`h-4 w-4`})}]:[]];return(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Theme`}),(0,X.jsx)(`div`,{className:`mt-2 max-w-[360px]`,children:(0,X.jsx)(S,{ariaLabel:`Theme`,value:t,onChange:n,items:r})})]})}var fn=He,pn=`Please choose a different handle.`;async function mn(e,t){let{data:n,error:r,response:i}=await Qe({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:U(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}=Re(r,`handle`,fn.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=Re(r,`handle`,pn);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:U(r,i,`Failed to save handle.`)}}async function hn(e,t,n){let{data:r,error:i,response:a}=await Xe({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(Fe(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new Ie(a.status,a.status===429?`Too many checks — try again in a moment.`:U(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function gn(e){return/\d{2,}$/.test(e)}var _n=300,vn=1400;function yn({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:a,onSaved:o,saveSuccessToast:c,fieldId:l}){let[u,d]=(0,Y.useState)(e),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(`idle`),[y,x]=(0,Y.useState)(null),S=Gt(),C=(0,Y.useRef)(null),w=(0,Y.useMemo)(()=>u.trim().toLowerCase(),[u]),T=w===e.toLowerCase();(0,Y.useEffect)(()=>{if(T||w.length===0){h(!1),C.current?.abort();return}let e=new AbortController;C.current?.abort(),C.current=e,h(!0);let t=window.setTimeout(async()=>{try{let t=await i(w,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)}},_n);return()=>{window.clearTimeout(t),e.abort()}},[w,T,i]);let E=(()=>{if(y)return y;if(f&&!f.available){let e=f.code;return f.message??(e?fn[e]:`Please choose a different handle.`)}return null})(),D=E?n:T?r??null:m?`Checking availability…`:f?.available?`Available.`:null,O=!T&&!m&&f?.available!==!1&&g!==`saving`,k=(0,Y.useCallback)(async()=>{if(!O)return;_(`saving`),x(null);let e=await a(w);if(e.kind===`ok`){_(`saved`),o(e.data),V.success(c),window.setTimeout(()=>_(`idle`),vn);return}if(e.kind===`taken`){_(`idle`),p({available:!1,code:`taken`,message:e.message});return}if(e.kind===`invalid`){_(`idle`),p({available:!1,code:e.code,message:e.message});return}_(`error`),x(e.message),V.error(e.message)},[O,w,o,a,c]),j=(()=>{if(T&&u.length>0||u.length===0)return null;let e=m?`checking`:f?.available?`available`:f?.available===!1?`invalid`:null;return e?(0,X.jsx)(Wt,{mode:`wait`,initial:!1,children:(0,X.jsxs)(Ut.span,{initial:S?!1:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:S?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,X.jsx)(A,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,X.jsx)(v,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,X.jsx)(b,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),M=(()=>{switch(g){case`saving`:return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Saving…`]});case`saved`:return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(v,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Saved`]});default:return`Save`}})();return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.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,X.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),rightIcon:j,errorText:E??void 0,helperText:D??void 0,"aria-invalid":!!E,fullWidth:!0,"data-testid":`${l}-input`}),(!T||g!==`idle`)&&(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(s,{variant:`primary`,size:`compact`,onClick:k,disabled:!O,"aria-live":`polite`,"data-testid":`${l}-save`,children:M})})]})}function bn({initial:e,onSaved:t}){let n=We.use.refreshSession(),r=gn(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,Y.useCallback)(async e=>await qe({username:e}),[]),a=(0,Y.useCallback)((e,t)=>Je(e,t),[]),o=(0,Y.useCallback)(e=>{t(e),n()},[t,n]);return(0,X.jsx)(yn,{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 xn({assistant:e,onSaved:t}){let n=e.handle??``,r=f({...Dt({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,Y.useCallback)(async t=>await mn(e.id,t),[e.id]),s=(0,Y.useCallback)((t,n)=>hn(e.id,t,n),[e.id]);return i?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(z,{label:`Assistant handle`,value:n,readOnly:!0,disabled:!0,leftIcon:(0,X.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,X.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,X.jsx)(l,{to:`${K.settings.ai}?release=1#email`,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`,children:`release the subdomain`}),` `,`first.`]})]}):(0,X.jsx)(yn,{initialHandle:n,inputLabel:`Assistant handle`,helperText:`Lowercase letters, digits, hyphens, and underscores. 3–30 characters.`,idleHelperText:a,checkAvailable:s,save:o,onSaved:t,saveSuccessToast:`Assistant handle updated.`,fieldId:`assistant-handle`})}function Sn(){return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-3 w-72 animate-pulse rounded bg-[var(--surface-muted)]`})]}),(0,X.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`h-3 w-60 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-7 w-16 animate-pulse rounded-md bg-[var(--surface-muted)]`})]}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Loading your profile…`})]})}function Cn(){return(0,X.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`})}function wn({assistant:e,showHandles:t=!0,children:n}={}){let r=We.use.user?.()?.email??null;return(0,X.jsx)(J,{title:`Profile`,subtitle:`Manage your account details and preferences.`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[r&&(0,X.jsx)(`div`,{className:`max-w-[420px]`,children:(0,X.jsx)(z,{label:`Email`,value:r,disabled:!0,readOnly:!0})}),t&&(0,X.jsxs)(X.Fragment,{children:[r&&(0,X.jsx)(Cn,{}),(0,X.jsx)(Tn,{assistant:e})]}),n!=null&&(0,X.jsxs)(X.Fragment,{children:[(r||t)&&(0,X.jsx)(Cn,{}),n]})]})})}function Tn({assistant:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),a=Gt(),[o,s]=(0,Y.useState)(e??null);return(0,Y.useEffect)(()=>{s(e??null)},[e]),(0,Y.useEffect)(()=>{let e=!1;return Le().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),r?(0,X.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,X.jsxs)(Ut.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,X.jsx)(bn,{initial:t,onSaved:n}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,X.jsx)(xn,{assistant:o,onSaved:s})]})]}):(0,X.jsx)(Sn,{})}var En=Nt({query:{hosting:`platform`}});function Dn(){let e=qt(),t=f(En),n=t.data?.results??[];return t.isPending||n.length<2?null:(0,X.jsx)(J,{title:`Switch Assistant`,subtitle:`Choose which assistant is active for this account.`,children:(0,X.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>{let n=t.id===e;return(0,X.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,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(j,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:t.name||`Unnamed`}),t.status!==`active`&&(0,X.jsx)(he,{tone:`warning`,children:t.status})]})})]}),(0,X.jsx)(`div`,{className:`shrink-0`,children:n?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,X.jsx)(v,{className:`h-4 w-4`}),`Active`]}):(0,X.jsx)(s,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{Ke(t.id),V.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var On=[{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 kn(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 An({assistantId:e}){let t=d(),n=en.use.isNonProduction(),r=(0,Y.useMemo)(()=>On.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:a,isError:o}=f(ft({path:{id:e}})),c=(0,Y.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[l,u]=(0,Y.useState)(null),p=l??c,m=l!==null,h=pt({onSuccess:()=>{V.success(`Sleep policy saved.`),u(null),t.invalidateQueries({queryKey:Ot({path:{id:e}})})},onError:()=>{V.error(`Failed to save sleep policy. Please try again.`)}});return a?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):o?(0,X.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,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Idle timeout`}),(0,X.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,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:r.map(e=>(0,X.jsx)(s,{variant:`outlined`,active:p===e.seconds,onClick:()=>u(e.seconds),children:e.label},e.seconds))}),(0,X.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,kn(p)]})]}),m&&(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(s,{variant:`primary`,leftIcon:h.isPending?(0,X.jsx)(A,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,X.jsx)(s,{variant:`outlined`,onClick:()=>u(null),disabled:h.isPending,children:`Cancel`})]})]})}function jn(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var Mn=3e3;function Nn({version:e,assistantId:t}){let{onTap:n,message:r}=nn(t);return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.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,X.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:r})]})}function Pn({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=Ft.use.rollbackEnabled(),a=G.use.previewChannel(),o=d(),c=Bt(n,a),l=c===`preview`,[u,m]=(0,Y.useState)(!1),h=(0,Y.useRef)(null),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(null),w=e=>e&&h.current&&e===h.current?(queueMicrotask(()=>{C(b?`Successfully rolled back to version ${h.current}.`:`Successfully updated to version ${h.current}.`),m(!1),h.current=null,_(null),V.success(b?`Rollback complete — assistant is healthy.`:`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),r?.()}),!1):Mn;f({...xt({path:{id:e}}),refetchInterval:u?e=>w(e.state.data?.current_release_version):!1});let{data:T,isLoading:E}=f(Et({query:{channel:c}})),D=T?.find(e=>e.is_stable!==!1)??T?.[0],O=g??D?.version??null,k=(0,Y.useMemo)(()=>{if(!i||!O||!t)return!1;let e=Me(O),n=Me(t);return!e||!n?!1:Ne(e,n)<0},[i,O,t]),j=(0,Y.useMemo)(()=>{if(!O)return!1;if(!t)return!0;let e=Me(O),n=Me(t);if(!e||!n)return O!==t;let r=Ne(e,n);return i?r!==0:r>0},[i,O,t]),M=p({mutationFn:async t=>{let{data:n}=await $e({path:{id:e},body:t,throwOnError:!0});return n}}),N=p({mutationFn:async t=>{let{data:n}=await tt({path:{id:e},body:t,throwOnError:!0});return n}});return(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,X.jsx)(Nn,{version:t,assistantId:e})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:l?`Preview release`:j?k?`Rollback to`:`Update to`:`Selected`}),(0,X.jsx)(`span`,{className:`block min-w-0`,children:E?(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(A,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):T&&T.length>0?i?(0,X.jsx)(ve,{value:O??``,onChange:e=>_(e===D?.version?null:e),disabled:u||M.isPending||N.isPending,options:T.map(e=>({value:e.version,label:jn(e,t,D?.version)}))}):(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:D?jn(D,t,D.version):`—`}):`No releases available`})]})]}),(0,X.jsx)(s,{variant:k?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:M.isPending||N.isPending||u?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(se,{}),onClick:()=>y(!0),disabled:!j||M.isPending||N.isPending||u||E||!T?.length,children:u?b?`Rolling back...`:`Updating...`:k?`Rollback`:l?`Update preview`:`Update`}),l&&(0,X.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Using Preview releases.`,` `,(0,X.jsx)(`a`,{href:`#preview-release-channel`,className:`text-[var(--primary-base)] underline-offset-2 hover:underline`,children:`Switch back to Stable`})]}),!j&&t&&O&&!E&&(0,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:S??`You are already on this version.`}),(0,X.jsx)(_e,{open:v,title:k?`Rollback assistant`:l?`Update preview release`:`Update assistant`,message:k?`Rollback to version ${O??`unknown`}? The assistant will be briefly unavailable.`:l?`Update to preview version ${O??`latest`}? The assistant will be briefly unavailable during the update.`:`Update to version ${O??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:k?`Rollback`:l?`Update preview`:`Update`,onConfirm:async()=>{y(!1),C(null);let t=g??void 0;try{if(k){let e=await N.mutateAsync({version:t});h.current=e.version??t??null,V.success(e.detail||`Rollback to ${t} initiated.`)}else{let e=await M.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){V.warning(e.detail);return}h.current=e.version??t??null,V.success(e.detail||`Update to ${e.version??t??`latest`} initiated.`)}x(k),m(!0),o.invalidateQueries({queryKey:kt({path:{id:e}})})}catch{V.error(k?`Failed to trigger rollback. Please try again.`:`Failed to trigger update. Please try again.`)}},onCancel:()=>y(!1)})]})}function Fn({assistantId:e,currentVersion:t,onUpgradeComplete:n}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(null),{data:c,isLoading:l}=f(Et({query:{stable:!0,limit:100}})),u=(0,Y.useMemo)(()=>Vt(c),[c]),d=u?.version,p=t?zt(t,d):!!d,m=Ht({assistantId:e,targetVersion:d});return(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,X.jsx)(Nn,{version:t,assistantId:e})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Update to`}),(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:l?`Loading...`:d&&u?jn(u,t,d):`No releases available`})]})]}),(0,X.jsx)(s,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(se,{}),onClick:()=>i(!0),disabled:m.isPending||l||!d||!p,children:m.isPending?`Updating...`:d?`Update to ${d}`:`Update`}),a&&(0,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:a}),!a&&!p&&d&&!l&&(0,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:`You are already on this version.`}),(0,X.jsx)(_e,{open:r,title:`Update assistant`,message:`Update to version ${d??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:`Update`,onConfirm:async()=>{i(!1),o(null);try{let e=await m.upgrade();o(e.version?`Successfully updated to version ${e.version}.`:`Successfully updated to version ${d??`latest`}.`),V.success(`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),n?.()}catch(e){V.error(e instanceof Error?e.message:`Failed to trigger update. Please try again.`)}},onCancel:()=>i(!1)})]})}function In(){let e=ct({platformHostedOnly:!0}),t=lt(),n=We.use.user()?.id??null,r=We.use.logout(),[i,a]=(0,Y.useState)(!1),o=bt({onSuccess:async()=>{V.success(`Account deletion requested. You will be logged out shortly.`),Ue(n),await r(),dt(K.account.login)},onError:()=>{V.error(`Failed to request account deletion. Please try again.`)}}),c=e===`full`&&t;return(0,Y.useEffect)(()=>{c&&i&&a(!1)},[c,i]),e===`gated`?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Delete Account`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently delete your account and all associated data.`}),(0,X.jsx)(`div`,{className:`mt-1`,children:e===`disabled`?(0,X.jsx)(q,{children:`Log in to the Vellum platform to delete your account.`}):(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(s,{variant:`dangerOutline`,onClick:()=>a(!0),disabled:o.isPending||c,className:`self-start`,children:`Delete My Account`}),c&&(0,X.jsx)(A,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})})]}),(0,X.jsx)(_e,{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){a(!1);return}a(!1),o.mutate({})},onCancel:()=>a(!1)})]})}function Ln({title:e,subtitle:t,benefits:n,ctaLabel:r,ctaLeftIcon:i,onAction:a}){return(0,X.jsx)(J,{title:e,subtitle:t,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(`ul`,{className:`space-y-3`,children:n.map(({icon:e,text:t})=>(0,X.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,X.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,X.jsx)(s,{variant:`primary`,size:`regular`,leftIcon:i,onClick:a,className:`self-start`,children:r})]})})}function Rn(){return st()?(0,X.jsx)(Ln,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:_,text:`Push notifications`},{icon:cn,text:`Biometric login`},{icon:un,text:`Native haptics`},{icon:le,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,X.jsx)(le,{size:16}),onAction:()=>{P(),ne()}}):null}var zn=`0.10.0`;function Bn(){return Pe(zn)}var Vn=[`login.tailscale.com`,`tailscale.com`,`www.tailscale.com`,`ngrok.com`,`dashboard.ngrok.com`,`dash.cloudflare.com`,`cloudflare.com`,`www.cloudflare.com`];function Hn(e){let t;try{t=new URL(e).hostname}catch{return!1}return Vn.includes(t)}function Un(e){let t;try{t=new URL(e).hostname}catch{return null}return Vn.includes(t)?t.includes(`tailscale`)?`Tailscale`:t.includes(`ngrok`)?`ngrok`:t.includes(`cloudflare`)?`Cloudflare`:null:null}function Wn(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`[::1]`||/^127(?:\.\d{1,3}){3}$/.test(t)}catch{return!1}}function Gn(e){let t=new URL(e);t.search=``,t.hash=``;let n=t.pathname.split(`/`).filter(Boolean),r=n.indexOf(`assistant`);return r>=0&&n.splice(r),t.pathname=n.length?`/${n.join(`/`)}`:`/`,t.toString().replace(/\/+$/,``)}function Kn(e){let t;try{t=Gn(e)}catch{return{ok:!1,reason:`unparseable`}}return Wn(t)?{ok:!1,reason:`loopback`}:Hn(t)?{ok:!1,reason:`service-website`}:new URL(t).protocol===`https:`?{ok:!0,url:t}:{ok:!1,reason:`non-https`}}function qn(e){let t=new URL(e.verificationUri);return t.hash=new URLSearchParams({device_code:e.deviceCode}).toString(),t.toString()}function Jn(e,t){switch(e){case`unparseable`:return`Enter a valid URL, e.g. https://your-assistant.ts.net.`;case`loopback`:return`This is a loopback address other devices can't reach. Enter the assistant's public https URL.`;case`non-https`:return`The URL must use https so your devices can connect securely.`;case`service-website`:return`This is ${t&&Un(t)||`the tunnel provider`}'s website, not your assistant's address. Run \`vellum tunnel\` on the host to get one.`}}var Yn=`/v1/remote-web/pairing-challenge`,Xn=`/v1/remote-web/pairing-verification`,Zn="If a scan can't connect, enable remote web access on the host with `vellum flags set web-remote-ingress true`, then generate a new code.",Qn=class extends Error{hint;constructor(e,t){super(e),this.name=`PairDeviceError`,this.hint=t}};function $n(){if(typeof window>`u`)return null;let e=Se(),t=De(e);return t?{base:`${window.location.origin}${t}`,assistantName:e?.name?.trim()||null,ingressUrl:e?.ingressUrl?.trim()||null}:null}function er(e){let t=e?.error?.message;return typeof t==`string`&&t.trim()?t:null}async function tr(e,t,n){let r;try{r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t),signal:n})}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?e:new Qn(`Couldn't reach the assistant. Make sure it's running and try again.`)}let i=await r.json().catch(()=>null);if(!r.ok)throw new Qn(er(i)??`Pairing failed (HTTP ${r.status}).`,Zn);if(typeof i!=`object`||!i)throw new Qn(`The assistant returned an unexpected response.`);return i}async function nr(e){let{base:t,publicBaseUrl:n,signal:r}=e,i=await tr(`${t}${Yn}`,{publicBaseUrl:n},r);return await tr(`${t}${Xn}`,{userCode:i.userCode},r),{pairUrl:qn(i),expiresAt:i.expiresAt}}var rr=Object.defineProperty,ir=Object.getOwnPropertySymbols,ar=Object.prototype.hasOwnProperty,or=Object.prototype.propertyIsEnumerable,sr=(e,t,n)=>t in e?rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cr=(e,t)=>{for(var n in t||={})ar.call(t,n)&&sr(e,n,t[n]);if(ir)for(var n of ir(t))or.call(t,n)&&sr(e,n,t[n]);return e},lr=(e,t)=>{var n={};for(var r in e)ar.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ir)for(var r of ir(e))t.indexOf(r)<0&&or.call(e,r)&&(n[r]=e[r]);return n},ur;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(ur||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(ur||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(ur||={});var Z=ur,dr={L:Z.QrCode.Ecc.LOW,M:Z.QrCode.Ecc.MEDIUM,Q:Z.QrCode.Ecc.QUARTILE,H:Z.QrCode.Ecc.HIGH},fr=128,pr=`L`,mr=`#FFFFFF`,hr=`#000000`,gr=!1,_r=1,vr=4,yr=0,br=.1;function xr(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function Sr(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function Cr(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*br),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function wr(e,t){return t==null?e?vr:yr:Math.max(Math.floor(t),0)}function Tr({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=Y.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...Z.QrSegment.makeSegments(t)),e),[]);return Z.QrCode.encodeSegments(r,dr[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=Y.useMemo(()=>{let e=c.getModules(),t=wr(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:Cr(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var Er=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Dr=Y.forwardRef(function(e,t){let n=e,{value:r,size:i=fr,level:a=pr,bgColor:o=mr,fgColor:s=hr,includeMargin:c=gr,minVersion:l=_r,boostLevel:u,marginSize:d,imageSettings:f}=n,p=lr(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=lr(p,[`style`]),g=f?.src,_=Y.useRef(null),v=Y.useRef(null),y=Y.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=Y.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=Tr({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});Y.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=Sr(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,Er?t.fill(new Path2D(xr(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),Y.useEffect(()=>{x(!1)},[g]);let E=cr({height:i,width:i},m),D=null;return g!=null&&(D=Y.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),Y.createElement(Y.Fragment,null,Y.createElement(`canvas`,cr({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});Dr.displayName=`QRCodeCanvas`;var Or=Y.forwardRef(function(e,t){let n=e,{value:r,size:i=fr,level:a=pr,bgColor:o=mr,fgColor:s=hr,includeMargin:c=gr,minVersion:l=_r,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=lr(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=Tr({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=Sr(g,v.excavation)),b=Y.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=xr(y,h);return Y.createElement(`svg`,cr({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&Y.createElement(`title`,null,d),Y.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),Y.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});Or.displayName=`QRCodeSVG`;function kr(e){if(!Number.isFinite(e)||e<=0)return`Single-use.`;let t=Math.ceil(e/1e3);return`Expires in ${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)} · single-use.`}function Ar({pairUrl:e,remainingMs:t,expired:n,copied:r,onCopy:i}){return n?(0,X.jsx)(R,{tone:`warning`,title:`This pairing code expired.`,children:`Generate a new code to pair a device.`}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`w-fit rounded-lg bg-white p-3`,children:(0,X.jsx)(Or,{value:e,size:192,level:`M`,title:`Device pairing QR code`})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`code`,{"data-testid":`pair-device-url`,className:`min-w-0 flex-1 truncate rounded-md bg-[var(--surface-active)] px-2.5 py-1.5 text-body-small-default text-[var(--content-secondary)]`,children:e}),(0,X.jsx)(s,{variant:`outlined`,size:`compact`,leftIcon:r?(0,X.jsx)(v,{}):(0,X.jsx)(T,{}),onClick:()=>i(e),children:r?`Copied`:`Copy`})]}),(0,X.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:kr(t)})]})}var jr=`vellum:pair-device:public-base-url`;function Mr(e){let n=e?.trim();if(n)return{url:n,source:`tunnel`};let r=t(jr,``).trim();return r?{url:r,source:`stored`}:{url:``,source:`none`}}function Nr(e,t,r){let[i]=(0,Y.useState)(()=>Mr(r)),[o,s]=(0,Y.useState)(i.url),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)({kind:`idle`}),[f,p]=(0,Y.useState)(()=>Date.now()),m=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>m.current?.abort(),[]),(0,Y.useEffect)(()=>{if(u.kind!==`ready`)return;p(Date.now());let e=setInterval(()=>p(Date.now()),1e3);return()=>clearInterval(e)},[u]);let h=(0,Y.useCallback)(e=>{s(e),l(null)},[]),g=(0,Y.useCallback)(()=>{if(!e)return;let r=o.trim(),i=Kn(r);if(!i.ok){l(Jn(i.reason,r));return}if(l(null),!t){d({kind:`error`,message:`Remote web access is disabled on this assistant, so a scanned code couldn't connect.`,hint:Zn});return}m.current?.abort();let s=new AbortController;m.current=s,d({kind:`minting`}),(async()=>{try{let t=await nr({base:e,publicBaseUrl:i.url,signal:s.signal});if(s.signal.aborted)return;n(jr,i.url),d({kind:`ready`,pairUrl:t.pairUrl,expiresAtMs:Date.parse(t.expiresAt)})}catch(e){if(s.signal.aborted)return;if(e instanceof Qn){d({kind:`error`,message:e.message,hint:e.hint});return}a(e,{context:`pair-device-mint`}),d({kind:`error`,message:`Something went wrong while generating the code.`})}})()},[e,o,t]),_=u.kind===`ready`?Math.max(0,u.expiresAtMs-f):0,v=u.kind===`ready`&&_<=0;return{publicBaseUrl:o,setPublicBaseUrl:h,prefillSource:i.source,inputError:c,phase:u,remainingMs:_,expired:v,generate:g}}function Pr(){let e=$n(),t=Bn(),n=Ft.use.hasHydrated(),r=Ft.use.webRemoteIngress(),i=Nr(e?.base??null,r,e?.ingressUrl??null),{copy:a,copied:o}=Jt();if(!e||!t)return null;let{phase:c}=i,l=c.kind===`minting`,u=c.kind===`ready`,d=i.prefillSource===`tunnel`,f=i.prefillSource===`none`&&i.publicBaseUrl.trim()===``,p=n?l?`Generating…`:u?`Generate new code`:`Generate pairing QR`:`Loading…`,m=()=>{n&&i.generate()};return(0,X.jsx)(J,{title:`Pair a device`,subtitle:`Scan with another device's camera — or open the link on it — to use ${e.assistantName??`this assistant`} there.`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f&&(0,X.jsx)(R,{tone:`info`,title:`No tunnel detected`,children:"On this computer, run `vellum tunnel --provider tailscale` (or another provider) — its address appears here."}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(z,{label:`Public URL`,fullWidth:!0,placeholder:`https://your-assistant.ts.net`,helperText:d?"This address comes from `vellum tunnel` on this computer. Edit it if your devices reach this assistant at a different URL.":`The https address your devices can reach this assistant at (your Tailscale URL, or another tunnel's).`,value:i.publicBaseUrl,errorText:i.inputError??void 0,disabled:l,onChange:e=>i.setPublicBaseUrl(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),m())}}),(0,X.jsx)(s,{variant:`primary`,className:`self-start`,disabled:!n||l||i.publicBaseUrl.trim()===``,onClick:m,children:p})]}),c.kind===`error`&&(0,X.jsx)(R,{tone:`error`,title:c.message,children:c.hint}),u&&(0,X.jsx)(Ar,{pairUrl:c.pairUrl,remainingMs:i.remainingMs,expired:i.expired,copied:o,onCopy:a})]})})}async function Fr(){if(!H())return[];let e=window.vellum;return e?.hotkeys?e.hotkeys.get():[]}async function Ir(e,t){if(!H())return;let n=window.vellum;n?.hotkeys&&await n.hotkeys.set(e,t)}function Lr(e){if(!H())return()=>{};let t=window.vellum;return t?.hotkeys?t.hotkeys.onChange(e):()=>{}}var Rr={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:`/`},zr=new Set([`MetaLeft`,`MetaRight`,`ControlLeft`,`ControlRight`,`AltLeft`,`AltRight`,`ShiftLeft`,`ShiftRight`]),Br=e=>{let t=e.code;return zr.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:Rr[t]??null},Vr=e=>{let t=Br(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(`+`)},Hr=(e,t,n)=>n===``?null:e.find(e=>e.key!==t&&e.accelerator===n)??null,Ur=[{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 Wr({hotkey:e,recording:t,conflictLabel:n,onStartRecording:r,onCancelRecording:i,onReset:a,onRemove:o}){let c=e.accelerator===``,l=e.override!==null;return(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`truncate text-body-medium-lighter text-[var(--content-default)]`,children:e.label}),n!==null&&(0,X.jsxs)(`div`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:[`Already used by `,n]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,X.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Recording… press a shortcut, or Esc to cancel`}):c?(0,X.jsx)(`span`,{className:`text-body-small-default italic text-[var(--content-disabled)]`,children:`Disabled`}):(0,X.jsx)(D,{accelerator:e.accelerator}),t?(0,X.jsx)(s,{variant:`ghost`,size:`compact`,onClick:i,children:`Cancel`}):(0,X.jsx)(s,{variant:`outlined`,size:`compact`,onClick:r,"aria-label":`Record shortcut for ${e.label}`,children:`Record`}),(0,X.jsx)(s,{variant:`ghost`,size:`compact`,disabled:!l,leftIcon:(0,X.jsx)(ce,{className:`h-3.5 w-3.5`}),onClick:a,"aria-label":`Reset ${e.label} to default`}),(0,X.jsx)(s,{variant:`ghost`,size:`compact`,disabled:c,leftIcon:(0,X.jsx)(pe,{className:`h-3.5 w-3.5`}),onClick:o,"aria-label":`Remove ${e.label} binding`})]})]})}function Gr(){let[e,t]=(0,Y.useState)([]),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),o=(0,Y.useCallback)(()=>{Fr().then(t)},[]);(0,Y.useEffect)(()=>(o(),Lr(t)),[o]);let s=(0,Y.useCallback)(()=>{r(null),a(null)},[]);(0,Y.useEffect)(()=>{if(n===null)return;let t=t=>{if(t.preventDefault(),t.stopPropagation(),t.code===`Escape`){s();return}let r=Vr(t);if(r===null)return;let i=Hr(e,n,r);if(i!==null){a({key:n,label:i.label});return}Ir(n,r).then(o),s()};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[n,e,o,s]);let c=(0,Y.useCallback)(e=>{a(null),r(e)},[]),l=(0,Y.useCallback)(t=>{let n=Hr(e,t,e.find(e=>e.key===t)?.defaultAccelerator??``);if(n!==null){r(null),a({key:t,label:n.label});return}s(),Ir(t,null).then(o)},[e,o,s]),u=(0,Y.useCallback)(e=>{s(),Ir(e,``).then(o)},[o,s]),d=(0,Y.useMemo)(()=>Ur.map(t=>({...t,commands:e.filter(e=>e.rebindable&&e.scope===t.scope)})).filter(e=>e.commands.length>0),[e]);return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[i!==null&&(0,X.jsxs)(R,{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,X.jsxs)(h,{bordered:!0,children:[(0,X.jsxs)(`div`,{className:`mb-2`,children:[(0,X.jsx)(`div`,{className:`text-body-medium-emphasised text-[var(--content-default)]`,children:e.title}),(0,X.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e.description})]}),(0,X.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.commands.map(e=>(0,X.jsx)(Wr,{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 Kr(){if(!H())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function qr(e){if(!H())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function Jr(){let e=L.useValue(),t=ie.useValue(),n=!It(),r=at()?`Cmd`:`Ctrl`;return(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Composer`}),(0,X.jsxs)(`div`,{className:`mt-2 space-y-4`,children:[n&&(0,X.jsx)(ge,{checked:e,onChange:L.save,label:`Send with ${r}+Enter`,helperText:`When enabled, Enter inserts a new line and ${r}+Enter sends.`}),(0,X.jsx)(ge,{checked:t,onChange:ie.save,label:`Show context window usage`,helperText:`Adds a ring to the composer tracking how full the context window is. Your assistant compacts its context automatically either way.`})]})]})}function Yr(){let[e,t]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{Kr().then(t)},[]);let n=async e=>{t(e);try{await qr(e)}catch{t(!e)}};return(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Launch at Login`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Automatically start Vellum when you log in to your Mac.`}),(0,X.jsx)(`div`,{className:`mt-2`,children:(0,X.jsx)(ge,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})]})}function Xr({open:e,onClose:t}){return(0,X.jsx)(B.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(B.Content,{size:`lg`,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{children:`Preferences`}),(0,X.jsx)(B.Description,{children:`Customize shortcuts and how Vellum behaves on this device.`})]}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(`div`,{className:`space-y-6`,children:[H()&&(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Keyboard Shortcuts`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Customize the shortcuts for Vellum's commands.`}),(0,X.jsx)(`div`,{className:`mt-2`,children:(0,X.jsx)(Gr,{})})]}),(0,X.jsx)(Jr,{}),H()&&(0,X.jsx)(Yr,{})]})})]})})}function Zr(e){return e===`preview`?`preview`:`stable`}function Qr(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 $r(e){return e.source_release_version?`Stable ${e.source_release_version}`:e.snapshot_name}function ei(e){return e.filter(e=>e.ready_to_use)}function ti(e){return e?.feature_enabled===!1}function ni({assistantId:e,onComplete:t}){let n=G.use.previewChannel(),r=d(),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,m]=(0,Y.useState)(`restore_backup`),[h,g]=(0,Y.useState)(``),_=ht({path:{assistant_id:e}}),v=mt({path:{assistant_id:e}}),b=kt({path:{id:e}}),{data:x,isLoading:S,isError:C}=f({..._,enabled:n,retry:!1}),w=x?.preview_backups??[],T=(0,Y.useMemo)(()=>ei(w),[w]),D=T[0],O=T.find(e=>e.snapshot_name===h)??D,k=()=>{r.invalidateQueries({queryKey:v}),r.invalidateQueries({queryKey:b}),t?.()},j=p(Pt()),M=p(Tt()),N=Zr(x?.current_channel),P=j.isPending||M.isPending,F=P||ti(x)||!x?.latest_preview_release,ee=u===`restore_backup`&&!O;if((0,Y.useEffect)(()=>{a(N===`preview`?`release-channel`:void 0)},[N]),!n)return null;let I=x?.standard_upgrade_available??!1;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E.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,X.jsxs)(E.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,X.jsxs)(E.Trigger,{className:`group justify-between gap-3`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Release Channel`}),x&&(0,X.jsx)(he,{tone:N===`preview`?`warning`:`neutral`,children:N===`preview`?`Preview`:`Stable`})]}),(0,X.jsx)(y,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,X.jsx)(E.Content,{children:(0,X.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[S&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),C&&(0,X.jsx)(R,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),x&&(0,X.jsxs)(X.Fragment,{children:[ti(x)&&(0,X.jsx)(R,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),N===`stable`?(0,X.jsx)(ri,{status:x,isChangingChannel:P,optInDisabled:F,onOptIn:()=>s(!0)}):(0,X.jsx)(ii,{status:x,isChangingChannel:P,onOptOut:()=>{let e=D;g(e?.snapshot_name??``),m(e?`restore_backup`:I?`standard_upgrade`:`restore_backup`),l(!0)}})]})]})})]})}),(0,X.jsx)(oi,{open:o,isPending:j.isPending,previewVersion:x?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await j.mutateAsync({path:{assistant_id:e}});V.success(t.detail||`Preview channel enabled.`),s(!1),k()}catch(e){V.error(U(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,X.jsx)(si,{open:c,backups:T,mode:u,selectedSnapshotName:O?.snapshot_name??``,isPending:M.isPending,restoreModeDisabled:ee,standardUpgradeAvailable:I,onModeChange:m,onSnapshotChange:g,onConfirm:async()=>{if(!ee)try{let t=await M.mutateAsync({path:{assistant_id:e},body:u===`restore_backup`?{mode:`restore_backup`,snapshot_name:O?.snapshot_name}:{mode:`standard_upgrade`}});V.success(t.detail||`Stable channel enabled.`),l(!1),k()}catch(e){V.error(U(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>l(!1)})]})}function ri({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(ai,{status:e}),!e.latest_preview_release&&(0,X.jsx)(R,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,X.jsx)(s,{variant:`outlined`,leftIcon:t?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(N,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function ii({status:e,isChangingChannel:t,onOptOut:n}){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(ai,{status:e}),(0,X.jsx)(s,{variant:`outlined`,leftIcon:t?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(ce,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function ai({status:e}){return(0,X.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Stable`}),(0,X.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??`None`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Preview`}),(0,X.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_preview_release?.version??`None`})]})]})}function oi({open:e,isPending:t,previewVersion:n,onConfirm:r,onCancel:i}){return(0,X.jsx)(B.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,X.jsxs)(B.Content,{size:`md`,hideCloseButton:t,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{icon:fe,children:`Opt in to Preview`}),(0,X.jsx)(B.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(R,{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,X.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,X.jsx)(`li`,{children:`Create and verify a Preview safety backup.`}),(0,X.jsxs)(`li`,{children:[`Switch to Preview image `,n??`latest`,`.`]}),(0,X.jsx)(`li`,{children:`Run the normal upgrade path and wait for health.`})]})]})}),(0,X.jsxs)(B.Footer,{children:[(0,X.jsx)(s,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,X.jsx)(s,{variant:`primary`,disabled:t,leftIcon:t?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(N,{}),onClick:r,children:t?`Switching...`:`Take Backup and Switch`})]})]})})}function si({open:e,backups:t,mode:n,selectedSnapshotName:r,isPending:i,restoreModeDisabled:a,standardUpgradeAvailable:o,onModeChange:c,onSnapshotChange:l,onConfirm:u,onCancel:d}){return(0,X.jsx)(B.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,X.jsxs)(B.Content,{size:`md`,hideCloseButton:i,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{icon:fe,children:`Switch back to Stable`}),(0,X.jsx)(B.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(w,{value:n,onValueChange:c,disabled:i,"aria-label":`Stable channel return method`,children:[(0,X.jsx)(C,{value:`restore_backup`,disabled:t.length===0,label:`Restore safety backup`,helperText:`Return to the Stable-channel data captured before Preview opt-in.`}),(0,X.jsx)(C,{value:`standard_upgrade`,disabled:!o,label:`Switch to Stable without restoring backup`,helperText:o?`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,X.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[`Safety backup`,(0,X.jsx)(ve,{value:r,onChange:l,disabled:i,options:t.map(e=>({value:e.snapshot_name,label:`${$r(e)} - ${Qr(e.created_at)}`}))})]}),n===`restore_backup`&&t.length===0&&!o&&(0,X.jsx)(R,{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,X.jsx)(R,{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,X.jsxs)(B.Footer,{children:[(0,X.jsx)(s,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,X.jsx)(s,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||a||n===`standard_upgrade`&&!o,leftIcon:i?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(se,{}),onClick:u,children:i?`Switching...`:`Switch to Stable`})]})]})})}var ci=new Set([`exceeds_machine_tier`,`exceeds_storage_tier`]);function li(e,t){return e&&typeof e==`object`&&!Array.isArray(e)&&`error`in e&&typeof e.error==`string`&&ci.has(e.error)?`That size isn't available on your plan.`:U(e,void 0,t)}function ui({assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}){let o=u(),c=ot(),d=f(jt()),p=d.data,m=!e.is_local,h=p?.plan_id===`pro`,g=f({...Mt(),enabled:h}),_=e.machine_size||`small`,v=Xt(g.data?.max_machine_tier??null),y=(0,Y.useMemo)(()=>$t(v,_,(0,X.jsx)(he,{tone:`positive`,children:`Current`})),[v,_]),b=g.data?.selected_storage_gib??null,[x,S]=(0,Y.useState)(!1),C=v.length>0?v[v.length-1]:null,[w,T]=(0,Y.useState)(null),E=w??C??_,[D,k]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(null),N=At({onSuccess:(e,n)=>{V.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),M(null),T(null),S(!1),n.body?.machine_size==null?i():a(t)},onError:e=>{M(li(e,`Failed to resize assistant. Please try again.`))}});if(d.isError&&p==null)return(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,X.jsx)(R,{tone:`error`,children:`Could not load your subscription. Please try again.`})});let P=h&&v.includes(E)&&E!==_?E:null,F=h&&b!=null&&!0,ee=h&&v.length>0&&Qt(_)<Qt(v[v.length-1]),I=N.isPending||r,te=b==null?t?.disk?.totalMb??null:b*1024,ne=t?.disk&&te!=null?{value:t.disk.usedMb,max:te,caption:`${on(t.disk.usedMb)} of ${on(te)}`}:null,L=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,re=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${on(t.memory.currentMb)} of ${on(t.memory.maxMb)}`}:null,ie=c?null:(0,X.jsx)(s,{variant:`ghost`,size:`compact`,onClick:()=>k(!0),children:`Resize`}),ae=m?h?F?(0,X.jsxs)(`button`,{type:`button`,disabled:I,onClick:()=>S(!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,X.jsx)(ue,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,X.jsx)(s,{variant:`ghost`,size:`compact`,disabled:I,onClick:()=>S(!0),children:`Resize`}):ie:null,oe=m?h?ee?(0,X.jsxs)(`button`,{type:`button`,disabled:I,onClick:()=>S(!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,X.jsx)(ue,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,X.jsx)(s,{variant:`ghost`,size:`compact`,disabled:I,onClick:()=>S(!0),children:`Resize`}):ie:null;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,compactAccessory:!0,accessory:(0,X.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,X.jsx)(A,{className:`animate-spin`}):(0,X.jsx)(se,{}),tooltip:r?`Applying resize…`:`Refresh resource metrics`,"aria-label":`Refresh resource metrics`,disabled:n||r,onClick:()=>void i()}),children:(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,X.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),ae]}),(0,X.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Storage`}),ne?(0,X.jsx)(tn,{value:ne.value,max:ne.max,caption:ne.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(A,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Unavailable`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,X.jsx)(ln,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Machine`}),(0,X.jsx)(he,{tone:`neutral`,children:Zt[_]})]}),oe]}),(0,X.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`CPU`}),L?(0,X.jsx)(tn,{value:L.value,max:L.max,caption:L.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(A,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Memory`}),re?(0,X.jsx)(tn,{value:re.value,max:re.max,caption:re.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(A,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,X.jsx)(B.Root,{open:D,onOpenChange:e=>{e||k(!1)},children:(0,X.jsxs)(B.Content,{size:`sm`,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{children:`Upgrade your plan`}),(0,X.jsx)(B.Description,{children:`Move to a higher plan for more power, more storage, and a larger credit bundle.`})]}),(0,X.jsxs)(B.Footer,{children:[(0,X.jsx)(s,{variant:`ghost`,onClick:()=>k(!1),children:`Cancel`}),(0,X.jsx)(s,{onClick:()=>{k(!1),o(K.plans)},children:`Upgrade`})]})]})}),(0,X.jsx)(B.Root,{open:x,onOpenChange:e=>{e||(S(!1),T(null),M(null))},children:(0,X.jsxs)(B.Content,{size:`sm`,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{icon:ln,children:`Resize Assistant`}),(0,X.jsx)(B.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,X.jsx)(B.Body,{children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[v.length===0?(0,X.jsx)(R,{tone:`warning`,children:`No machine tier configured. Visit the community for help.`}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:`Machine Size`}),(0,X.jsx)(ve,{options:y,value:E,onChange:T,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),F?(0,X.jsx)(R,{tone:`info`,children:`Storage will be expanded to ${b} GB.`}):(0,X.jsx)(R,{tone:`neutral`,children:`Storage will not change.`}),j&&(0,X.jsx)(R,{tone:`error`,children:j})]})}),(0,X.jsxs)(B.Footer,{className:c?`justify-end`:`items-center justify-between`,children:[c?null:(0,X.jsxs)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:[`Need more?`,` `,(0,X.jsx)(l,{to:K.plans,className:`text-[var(--content-secondary)] underline decoration-[var(--border-element)] underline-offset-2 transition-colors hover:text-[var(--content-default)]`,onClick:()=>S(!1),children:`Upgrade plan`})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(s,{variant:`ghost`,onClick:()=>{S(!1),T(null),M(null)},children:`Cancel`}),(0,X.jsx)(s,{disabled:P==null&&!F||I,leftIcon:I?(0,X.jsx)(A,{className:`animate-spin`}):void 0,onClick:()=>{M(null);let t={};P!=null&&(t.machine_size=P),F&&b!=null&&(t.storage_gib=b),N.mutate({path:{id:e.id},body:t})},children:j?`Retry`:`Apply`})]})]})]})})]})}function di({assistantId:e}){let t=u(),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(s,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,X.jsx)(Rt,{open:n,isPending:i,onConfirm:async()=>{a(!0);let n=await Lt(e);if(n.ok){r(!1),t(n.nextRoute,{replace:!0});return}V.error(n.error),a(!1),r(!1)},onCancel:()=>r(!1)})]})}function fi(){let e=oe(),t=ae.useValue();return F(e)?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,X.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Show tips`}),(0,X.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,X.jsx)(ge,{checked:t,onChange:t=>{ae.save(t),t||re(`settings`,`dont_show_again`,e)},"aria-label":`Show tips`})]}):null}var pi=`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 mi(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...pi].sort()}function hi(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 gi(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function _i(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 vi({value:e,onChange:t}){let[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useMemo)(()=>mi().map(e=>hi(e)).filter(e=>e!==null),[]);(0,Y.useEffect)(()=>{let e=window.setTimeout(()=>{a(n.trim().toLowerCase())},200);return()=>window.clearTimeout(e)},[n]),(0,Y.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,Y.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,Y.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,X.jsxs)(`div`,{ref:c,className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Closest city`}),(0,X.jsxs)(`div`,{className:`relative w-full md:max-w-[280px]`,children:[(0,X.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`&&(e.preventDefault(),r(``),s(!1),l.current?.blur())},fullWidth:!0}),o&&d.length>0&&(0,X.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,X.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,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-body-medium-default`,children:t.city}),t.region&&(0,X.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:t.region})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,X.jsx)(`span`,{children:gi(t.identifier)}),(0,X.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,X.jsx)(sn,{}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Time zone`}),(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:_i(e)})]})]})}function yi(){let e=je.use.activeAssistantId(),[t,n]=(0,Y.useState)(()=>i(`timezone`,``)),o=(0,Y.useRef)(e);(0,Y.useEffect)(()=>{o.current=e},[e]);let s=(0,Y.useRef)(!1),c=(0,Y.useRef)(null),l=(0,Y.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,W.patch({url:`/v1/assistants/{assistant_id}/config`,path:{assistant_id:t},body:{ui:{userTimezone:e}},throwOnError:!0}).catch(e=>{a(e,{context:`settings-timezone-override`})}).finally(()=>{s.current=!1;let e=c.current;c.current=null,e!==null&&l.current(e)})};return(0,Y.useEffect)(()=>{l.current=u}),(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Timezone`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Used when displaying times and scheduling reminders.`}),(0,X.jsx)(`div`,{className:`mt-1`,children:(0,X.jsx)(vi,{value:t,onChange:e=>{n(e),r(`timezone`,e),u(e)}})})]})}var bi=[[`Mon`,0],[`Tue`,1],[`Wed`,2],[`Thu`,3],[`Fri`,4],[`Sat`,5],[`Sun`,6]];function xi(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 Si(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 Ci(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function wi(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:xi(t),windowEnd:xi(n)}}function Ti({assistantId:e}){let t=d(),{data:n,isLoading:r,isError:i}=f(yt({path:{id:e}})),a=(0,Y.useMemo)(()=>wi(n),[n]),[o,c]=(0,Y.useState)(null),l=o??a,u=o!==null,m=(0,Y.useMemo)(()=>Ci(),[]),[h,g]=(0,Y.useState)(null),_=h??l.daysOfMonth.join(`, `),v=p({mutationFn:async t=>{let{data:n}=await Ye({path:{id:e},body:t,throwOnError:!0});return n}}),y=e=>{c(t=>({...t??a,...e}))},b=e=>{y({daysOfWeek:l.daysOfWeek.includes(e)?l.daysOfWeek.filter(t=>t!==e):[...l.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,X.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading update window settings...`]}):i?(0,X.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,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsx)(ge,{checked:l.enabled,onChange:e=>y({enabled:e}),label:`Automatic updates`,helperText:`Update automatically during a configured time window`}),l.enabled&&(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Frequency`}),(0,X.jsx)(`div`,{className:`max-w-[400px]`,children:(0,X.jsx)(S,{ariaLabel:`Frequency`,value:l.frequency,onChange:e=>{e!==`monthly`&&g(null),y({frequency:e})},items:[{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}]})})]}),l.frequency===`weekly`&&(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Day(s) of week`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:bi.map(([e,t])=>(0,X.jsx)(s,{variant:`outlined`,size:`compact`,active:l.daysOfWeek.includes(t),onClick:()=>b(t),children:e},t))})]}),l.frequency===`monthly`&&(0,X.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,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:[`Update window`,m?` (${m})`:``]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(z,{type:`time`,value:l.windowStart,onChange:e=>y({windowStart:e.target.value})}),(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`to`}),(0,X.jsx)(z,{type:`time`,value:l.windowEnd,onChange:e=>y({windowEnd:e.target.value})})]})]})]}),(0,X.jsx)(s,{variant:`primary`,leftIcon:v.isPending?(0,X.jsx)(A,{className:`animate-spin`}):void 0,onClick:async()=>{let n=l.frequency===`monthly`&&h!==null?x(h):l.daysOfMonth;try{await v.mutateAsync({enabled:l.enabled,timezone:`UTC`,schedule:{frequency:l.frequency,days_of_week:l.frequency===`weekly`?l.daysOfWeek:[],days_of_month:l.frequency===`monthly`?n:[],window:{start:Si(l.windowStart),end:Si(l.windowEnd)}}}),V.success(`Auto-update policy saved.`),c(null),g(null),t.invalidateQueries({queryKey:St({path:{id:e}})})}catch{V.error(`Failed to save policy. Please try again.`)}},disabled:v.isPending||!u,children:`Save policy`})]})}function Ei({assistantId:e,open:t,onClose:n}){return(0,X.jsx)(B.Root,{open:t,onOpenChange:e=>{e||n()},children:(0,X.jsxs)(B.Content,{size:`md`,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{children:`Update Window`}),(0,X.jsx)(B.Description,{children:`Configure when automatic updates are applied.`})]}),(0,X.jsx)(B.Body,{children:(0,X.jsx)(Ti,{assistantId:e})})]})})}function Di(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`)return t}}function Oi({open:e,onOpenChange:t}){let n=d(),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(!1),f=(0,Y.useRef)(e),p=()=>n.invalidateQueries({queryKey:wt()}),m=e=>{nt({path:{id:e}}).catch(()=>void 0).finally(()=>void p())},h=Ct({onSuccess:e=>{if(!f.current){m(e.factor_id);return}i(e)},onError:e=>{let n=Di(e);n===`no_workos_account`?V.error(`Two-factor authentication is only available for Vellum platform accounts.`):n===`throttled`||n===`workos_rate_limited`?V.error(`Too many attempts. Try again in a minute.`):n===`factor_limit_reached`?V.error(`An authenticator app is already set up. Remove it before adding another.`):V.error(`Failed to start setup. Please try again.`),t(!1)}}),g=_t({onSuccess:e=>{e.valid?(u.current=!0,V.success(`Two-factor authentication is on.`),p(),t(!1)):l(`That code didn't match. Check your authenticator app and try again.`)},onError:e=>{let n=Di(e);if(n===`challenge_already_verified`){u.current=!0,V.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),o(``),l(`This setup session expired. Scan the new QR code and try again.`),h.mutate({});return}if(n===`throttled`||n===`workos_rate_limited`){l(`Too many attempts. Wait a minute and try again.`);return}l(`Couldn't verify the code. Wait a moment and try again.`)}});(0,Y.useEffect)(()=>{f.current=e,e&&(u.current=!1,i(null),o(``),l(null),h.mutate({}))},[e]);let _=e=>{!e&&g.isPending||(!e&&r&&!u.current&&m(r.factor_id),t(e))},v=()=>{r&&Kt(r.secret,{successMessage:`Setup key copied.`,errorMessage:`Couldn't copy the setup key.`})},y=()=>{!r||a.length!==6||g.isPending||(l(null),g.mutate({body:{challenge_id:r.challenge_id,code:a}}))};return(0,X.jsx)(B.Root,{open:e,onOpenChange:_,children:(0,X.jsxs)(B.Content,{size:`sm`,children:[(0,X.jsxs)(B.Header,{children:[(0,X.jsx)(B.Title,{children:`Set up authenticator app`}),(0,X.jsx)(B.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,X.jsx)(B.Body,{children:r===null?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,X.jsx)(A,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,X.jsxs)(`form`,{className:`flex flex-col items-center gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,X.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,X.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Can't scan it? Enter this setup key manually:`}),(0,X.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,X.jsx)(`span`,{className:`break-all text-left`,children:r.secret}),(0,X.jsx)(T,{className:`h-3.5 w-3.5 shrink-0`})]})]}),(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,X.jsx)(`label`,{htmlFor:`totp-code`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:`6-digit code`}),(0,X.jsx)(z,{id:`totp-code`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,placeholder:`123456`,value:a,onChange:e=>o(e.target.value.replace(/\D/g,``).slice(0,6))}),c&&(0,X.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--system-negative-strong)]`,children:c})]})]})}),(0,X.jsxs)(B.Footer,{children:[(0,X.jsx)(s,{variant:`outlined`,onClick:()=>_(!1),disabled:g.isPending,children:`Cancel`}),(0,X.jsx)(s,{onClick:y,disabled:r===null||a.length!==6||g.isPending,children:g.isPending?`Verifying…`:`Verify`})]})]})})}function ki(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function Ai(){let e=d(),[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(null),a=f({...vt()}),o=a.data??[],c=()=>e.invalidateQueries({queryKey:wt()}),l=gt({onSuccess:()=>{V.success(`Authenticator app removed.`),c()},onError:e=>{if(Di(e)===`factor_not_found`){c();return}V.error(`Failed to remove the authenticator app. Please try again.`)}});return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[a.isPending?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,X.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,X.jsx)(`span`,{className:`text-body-medium-default`,children:`Loading authenticator apps…`})]}):a.isError?(0,X.jsxs)(R,{tone:`error`,children:[`Couldn't load your authenticator apps.`,` `,(0,X.jsx)(`button`,{type:`button`,className:`cursor-pointer underline`,onClick:()=>void a.refetch(),children:`Try again`})]}):o.length===0?(0,X.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,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:o.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(le,{className:`h-5 w-5 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Authenticator app`}),(0,X.jsxs)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:[e.user,e.created_at?` · Added ${ki(e.created_at)}`:``]})]})]}),(0,X.jsx)(s,{variant:`dangerOutline`,onClick:()=>i(e),disabled:l.isPending,children:`Remove`})]},e.id))}),!a.isPending&&!a.isError&&o.length===0&&(0,X.jsx)(s,{onClick:()=>n(!0),className:`self-start`,children:`Add authenticator app`}),(0,X.jsx)(Oi,{open:t,onOpenChange:n}),(0,X.jsx)(_e,{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&&l.mutate({path:{id:r.id}}),i(null)},onCancel:()=>i(null)})]})}var Q=class extends Error{code;constructor(e,t){super(t),this.name=`TeleportError`,this.code=e}},ji=`local`,Mi=`docker`,Ni=`vellum`;function Pi(e){switch((e??``).toLowerCase()){case ji:return`local`;case Mi:return`docker`;case Ni:return`managed`;default:return`other`}}function Fi(e){let t=Pi(e);return t===`managed`?`local`:t===`local`?`platform`:null}function Ii(e){switch(e){case`docker`:return`Move to Docker`;case`platform`:return`Move to Cloud (Platform)`;case`local`:return`Move to Local`}}function Li(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 Ri(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 zi(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 Bi(e){let t=De(e);if(!t)throw new Q(`local_assistant_not_found`,`Assistant ${e.assistantId} has no resolved local gateway.`);return`${window.location.origin}${t}`}async function Vi(e,t){let n=await ke(e.assistantId),r=await fetch(`${t}/auth/token`,{method:`POST`,headers:{Authorization:`Bearer ${n}`}});if(!r.ok)throw new Q(`not_signed_in`,`Gateway token request failed (HTTP ${r.status}).`);let{token:i}=await r.json();return i}async function Hi(e,t){let n=Bi(e),r=await Vi(e,n),i=await fetch(`${n}/v1/migrations/export`,{method:`POST`,headers:{Authorization:`Bearer ${r}`}});if(!i.ok)throw new Q(`export_failed`,`Export failed (HTTP ${i.status}).`);return zi(i,t)}async function Ui(e,t){let n=Bi(e),r=await Vi(e,n),i=await fetch(`${n}/v1/migrations/import`,{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:new Blob([t],{type:`application/octet-stream`})});if(!i.ok)throw new Q(`import_failed`,`Import failed (HTTP ${i.status}).`);let a=await Ki(i);if(a&&a.success===!1)throw new Q(`import_failed`,a.error??`Import reported failure`)}async function Wi(e,t){let{data:n,response:r}=await W.post({url:`/v1/assistants/{assistant_id}/migrations/export-to-gcs/`,path:{assistant_id:e},body:{upload_url:t},throwOnError:!1}),i=r?.status??0;if(!(r?.ok??!1)&&i!==202)throw new Q(`export_failed`,`Export failed (HTTP ${i}).`);let a=n?.job_id;if(!a)throw new Q(`export_failed`,`Export accepted but no job ID was returned.`);return a}async function Gi(e,t){let{data:n,response:r}=await W.get({url:`/v1/assistants/{assistant_id}/migrations/jobs/{job_id}`,path:{assistant_id:e,job_id:t},throwOnError:!1}),i=r?.status??0;if(i>=500)return`processing`;if(!(r?.ok??!1))throw new Q(`export_job_failed`,`Job status check failed (HTTP ${i})`);let a=n;if(a?.status===`failed`)throw new Q(`export_job_failed`,a.error??`Export job failed`);return a?.status??`processing`}async function Ki(e){try{return await e.json()}catch{return null}}var qi=new Set([500,502,503,504]),$=3,Ji=e=>new Promise(t=>setTimeout(t,e));async function Yi(e,t=new Set){for(let n=0;n<=$;n++){let{response:r,data:i,error:a}=await e(),o=r?.status??0;if(n<$&&qi.has(o)&&!t.has(o)){await Ji(2**n*1e3);continue}return{status:o,data:i,error:a}}throw new Q(`unknown`,`Unexpected retry loop exit`)}async function Xi(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 Yi(()=>W.post({url:`/v1/migrations/signed-url/`,body:n,throwOnError:!1}),new Set([404,503]));if(r===503||r===404)throw new Q(`export_failed`,`Signed URL uploads are not available — the platform may not support this feature yet.`);if(r!==201)throw new Q(`export_failed`,`Migration request failed (HTTP ${r}).`);let a=i;return{url:a.url,bundleKey:a.bundle_key,expiresAt:a.expires_at}}async function Zi(e,t){let{status:n,data:r,error:i}=await Yi(()=>W.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=Ri(i);if(e)throw new Q(`version_mismatch`,e)}if(n!==200&&n!==201)throw new Q(`import_failed`,`Migration request failed (HTTP ${n}).`);return r.url}async function Qi(e,t,n){for(let r=0;r<=$;r++){let i=await $i(e,t,n);if(r<$&&qi.has(i)){await Ji(2**r*1e3),n?.(0);continue}if(i<200||i>=300)throw new Q(`export_failed`,`Bundle upload failed (HTTP ${i}).`);return}}function $i(e,t,n){return new Promise((r,i)=>{let a=new XMLHttpRequest;a.open(`PUT`,e),a.setRequestHeader(`Content-Type`,`application/octet-stream`),a.timeout=36e5,n&&(a.upload.onprogress=e=>{e.lengthComputable&&n(e.loaded/e.total)}),a.onload=()=>{n?.(1),r(a.status)},a.onerror=()=>i(new Q(`export_failed`,`Bundle upload failed.`)),a.ontimeout=()=>i(new Q(`export_timed_out`,`Bundle upload timed out.`)),a.send(t)})}async function ea(e,t){for(let n=0;n<=$;n++){let r=await fetch(e,{method:`GET`});if(n<$&&qi.has(r.status)){await Ji(2**n*1e3),t?.(0);continue}if(!r.ok)throw new Q(`import_failed`,`Bundle download failed (HTTP ${r.status}).`);return zi(r,t)}throw new Q(`import_failed`,`Unexpected retry loop exit`)}async function ta(e){let{status:t,data:n,error:r}=await Yi(()=>W.post({url:`/v1/migrations/import-from-gcs/`,body:{bundle_key:e},throwOnError:!1}));return{status:t,body:n??r??null}}async function na(e){let{status:t,data:n}=await Yi(()=>W.get({url:`/v1/migrations/jobs/{job_id}/`,path:{job_id:e},throwOnError:!1}));if(t!==200)throw new Q(`import_failed`,`Job status check failed (HTTP ${t})`);let r=n??{};return{status:typeof r.status==`string`?r.status:`unknown`,jobId:typeof r.job_id==`string`?r.job_id:null,error:typeof r.error==`string`?r.error:null}}var ra=5e3,ia=36e5,aa=5*6e4,oa=30,sa=e=>new Promise(t=>setTimeout(t,e));function ca(){let e=u(),t=Se(),n=Fi(t?.cloud),[r,i]=(0,Y.useState)({kind:`idle`}),[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),d=(0,Y.useCallback)(e=>{i({kind:`transferring`,step:e,progress:null})},[]),f=(0,Y.useCallback)(e=>{i(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,Y.useCallback)(async()=>{if(!(!t||!n)){l.current={id:t.assistantId,kind:Pi(t.cloud)===`managed`?`managed`:`local`,createdFresh:!1};try{if(n===`platform`)await la(t,d,f,c);else if(n===`local`)await ua(t,d,f,c);else throw new Q(`unknown`,`Unsupported teleport destination.`);i({kind:`verifying`})}catch(e){i({kind:`failed`,error:`Teleport failed: ${e instanceof Q||e instanceof Error?e.message:`Teleport failed.`}`}),a(e,{context:`teleport-execute`}),await fa(c.current,l.current,`teleport-execute-cleanup`),c.current=null}}},[t,n,d,f]),m=(0,Y.useCallback)(()=>s(!0),[]),h=(0,Y.useCallback)(()=>s(!1),[]),g=(0,Y.useCallback)(()=>{s(!1),p()},[p]),_=(0,Y.useCallback)(()=>{c.current=null,l.current=null,i({kind:`idle`})},[]);return{destination:n,phase:r,confirmOpen:o,requestTeleport:m,cancelConfirm:h,confirm:g,confirmAndSwitch:(0,Y.useCallback)(()=>{let t=c.current,n=l.current;t&&(async()=>{try{let e=We.getState();t.kind===`managed`?await e.connectPlatformAssistant(t.id):(await e.connectLocalAssistant(t.id),ze(t.id,{onError:e=>a(e,{context:`teleport-inject-platform-identity`})}))}catch(e){i({kind:`failed`,error:`Switch failed: ${e instanceof Error?e.message:`Failed to switch assistant.`}`}),a(e,{context:`teleport-confirm-switch`});return}n&&Lt(n.id).then(e=>{e.ok||a(Error(e.error),{context:`teleport-retire-source`})}),_(),e(K.assistant,{replace:!0})})()},[e,_]),cancelTeleport:(0,Y.useCallback)(()=>{let e=c.current,t=l.current;c.current=null,l.current=null,i({kind:`idle`}),fa(e,t,`teleport-cancel-retire-target`)},[]),reset:_}}async function la(e,t,n,r){t(`Exporting assistant data...`);let i=await Hi(e,n);t(`Resolving organization...`);let a=await ma();t(`Checking for existing assistant...`);let o=(await et({query:{hosting:`platform`},throwOnError:!1})).data?.results?.[0];if(o)throw new Q(`existing_platform_assistant`,`You already have a platform assistant '${o.id}'. Retire it first, then retry the teleport.`);t(`Uploading data to cloud...`);let s=await Xi(e.resources?.runtimeVersion);await Qi(s.url,i,n),t(`Setting up cloud assistant...`);let c=await it(void 0,`create`);if(!c.ok)throw new Q(`import_failed`,`Failed to set up the cloud assistant.`);if(c.status===200)throw new Q(`existing_platform_assistant`,`You already have a platform assistant '${c.data.id}'. Retire it first, then retry the teleport.`);let l=c.data.id;await ye({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:xe(),hatchedAt:c.data.created??new Date().toISOString(),organizationId:a}),await be(e.assistantId),r.current={id:l,kind:`managed`,createdFresh:!0},t(`Finalizing cloud assistant...`),await ha(l),t(`Importing data to cloud...`);let u=await ta(s.bundleKey);if(u.status<200||u.status>=300){let e=u.body;throw new Q(`import_failed`,e?.error??`Import failed (HTTP ${u.status}).`)}if(u.status===202){let e=u.body?.job_id;if(!e)throw new Q(`import_failed`,`Import accepted but no job ID returned.`);await ga(e)}else{let e=u.body;if(e&&e.success===!1)throw new Q(`import_failed`,e.error??`Import reported failure.`)}}async function ua(e,t,n,r){t(`Preparing export...`);let i=await Xi(await pa(e.assistantId),`runtime`);t(`Exporting cloud data...`);let a=await Wi(e.assistantId,i.url);await _a(e.assistantId,a),t(`Preparing local assistant...`);let{assistant:o,createdFresh:s}=await va();r.current={id:o.assistantId,kind:`local`,createdFresh:s};let c=await da(o,s);if(!c)throw new Q(`local_assistant_not_found`,`Could not determine the local assistant's runtime version. Restart or upgrade the local assistant, then retry the teleport.`);t(`Preparing import...`);let l=await Zi(i.bundleKey,c);t(`Downloading data...`);let u=await ea(l,n);t(`Importing data...`),await ba(o,u),await be(e.assistantId)}async function da(e,t){if(e.resources?.runtimeVersion)return e.resources.runtimeVersion;if(t)return(await Yt())?.version??void 0}async function fa(e,t,n){if(e?.createdFresh){let t=await Lt(e.id);t.ok||a(Error(t.error),{context:n})}t&&await be(t.id)}async function pa(e){let t=await rt(e);return t.ok?t.data.version??void 0:void 0}async function ma(){let e=Ve.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=Ve.getState().organizations,n=Ge();if(n&&t.some(e=>e.id===n))return n;if(t.length===0)throw new Q(`no_organizations`,`No organizations found for this account.`);if(t.length>1)throw new Q(`multiple_organizations`,`Multiple organizations found — please select one in account settings first.`);let r=t[0].id;return Ve.getState().setCurrentOrganizationId(r),r}async function ha(e){let t=Date.now();for(;Date.now()-t<aa;){let{data:t,response:n}=await Ze({path:{id:e},throwOnError:!1});if(n?.ok&&t?.state===`active`)return;await sa(ra)}}async function ga(e){let t=Date.now();for(;Date.now()-t<ia;){await sa(ra);let t=await na(e);if(t.status===`complete`)return;if(t.status===`failed`)throw new Q(`import_failed`,t.error??`Import job failed`)}throw new Q(`import_failed`,`Import timed out after 60 minutes.`)}async function _a(e,t){let n=Date.now();for(;Date.now()-n<ia;)if(await sa(ra),await Gi(e,t)===`complete`)return;throw new Q(`export_timed_out`,`Export timed out.`)}async function va(){let e=await Oe(void 0,void 0);if(!e.ok)throw new Q(`local_assistant_not_found`,e.error??`Could not create a local assistant.`);await Te();let t=e.assistantId?Ae().find(t=>t.assistantId===e.assistantId):ya();if(!t)throw new Q(`local_assistant_not_found`,`Could not find or create a local assistant.`);return{assistant:t,createdFresh:!0}}function ya(){return Ae().slice().sort((e,t)=>(t.hatchedAt??``).localeCompare(e.hatchedAt??``))[0]}async function ba(e,t){let n;for(let r=0;r<oa;r++)try{await Ui(e,t);return}catch(e){n=e,await sa(1e3)}throw n instanceof Error?n:new Q(`import_failed`,`Import failed.`)}function xa(){let e=ca(),{destination:t,phase:n}=e;return t?(0,X.jsxs)(J,{title:`Teleport`,subtitle:`Move your assistant to a different hosting environment.`,children:[n.kind===`idle`&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:Li(t)}),(0,X.jsx)(s,{variant:`outlined`,className:`self-start`,onClick:e.requestTeleport,children:Ii(t)})]}),n.kind===`transferring`&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.progress==null&&(0,X.jsx)(A,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:n.step})]}),n.progress!=null&&(0,X.jsx)(me,{value:n.progress,"aria-label":`Teleport progress`,className:`max-w-[240px]`})]}),n.kind===`verifying`&&(0,X.jsx)(R,{tone:`success`,icon:(0,X.jsx)(x,{className:`h-4 w-4`}),title:`Transfer complete — verify your new assistant is working.`,actions:(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(s,{variant:`primary`,onClick:e.confirmAndSwitch,children:`Confirm & Switch`}),(0,X.jsx)(s,{variant:`outlined`,onClick:e.cancelTeleport,children:`Cancel`})]})}),n.kind===`failed`&&(0,X.jsx)(R,{tone:`error`,title:n.error,actions:(0,X.jsx)(s,{variant:`outlined`,onClick:e.reset,children:`Try Again`})}),(0,X.jsx)(_e,{open:e.confirmOpen,title:Ii(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 Sa(){let{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}=rn(),o=G.use.multiPlatformAssistant(),l=G.use.assistantSwitcher()&&we(),d=G.use.teleport(),f=G.use.accountMfa(),p=Ft.use.settingsSleepPolicy(),m=Be(),h=u(),g=ct(),_=ct({platformHostedOnly:!0}),v=ut(),y=ot(),b=te({assistantId:e?.id??null,enabled:_===`full`&&v}),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(!1),[T,E]=c();(0,Y.useEffect)(()=>{if(T.get(`preferences`)!==`open`)return;let e=new URLSearchParams(T);e.delete(`preferences`),E(e,{replace:!0}),w(!0)},[T,E]);let D=e?.is_local&&!we()?null:e,O=Se(),k=we()&&!!e&&!!O&&Ce(O),A=k,j=k&&!Ee(),M=_===`full`&&!!D||j&&!!e;(0,Y.useEffect)(()=>{!e||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[e]);let N=t?.version??e?.current_release_version??null,P=(g===`full`||A)&&!!D||g===`disabled`&&!A,F=_!==`gated`;return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[b.status&&b.mode!==`inactive`&&(0,X.jsx)(ee,{status:b.status,mode:b.mode,isAcknowledging:b.isAcknowledging,acknowledgeError:b.acknowledgeError?.message??null,onAcknowledge:()=>void b.acknowledge(),onReviewWorkspaceData:()=>void h(`${K.workspace}?sort=size`),onUpgradeStorage:_===`full`&&!y?()=>void h(K.plans):null}),(0,X.jsxs)(wn,{assistant:v?D:null,showHandles:m&&g===`full`,children:[(0,X.jsx)(yi,{}),f&&g!==`gated`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Two-Factor Authentication`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Require a code from an authenticator app when you sign in.`}),(0,X.jsx)(`div`,{className:`mt-1`,children:g===`disabled`?(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage two-factor authentication.`}):(0,X.jsx)(Ai,{})})]})]})]}),(0,X.jsx)(J,{title:`Version`,subtitle:`Manage your assistant's software version and updates.`,accessory:_===`full`&&D?(0,X.jsx)(s,{variant:`outlined`,onClick:()=>S(!0),children:`Update Window`}):void 0,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[_===`full`&&D&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pn,{assistantId:D.id,currentVersion:N,releaseChannel:D.release_channel,onUpgradeComplete:()=>{i()}}),(0,X.jsx)(ni,{assistantId:D.id,onComplete:()=>{i()}})]}),j&&e&&(0,X.jsx)(Fn,{assistantId:e.id,currentVersion:N,onUpgradeComplete:()=>{i()}}),!M&&e&&(0,X.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,X.jsx)(an,{version:N,loading:n&&!e.current_release_version,assistantId:e.id??null})]}),_===`disabled`&&!j&&(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage software updates.`})]})}),_===`full`&&D&&(0,X.jsx)(Ei,{assistantId:D.id,open:x,onClose:()=>S(!1)}),_===`full`&&e&&(0,X.jsx)(ui,{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}),_===`disabled`&&(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage compute resources.`})}),(0,X.jsx)(J,{title:`Preferences`,subtitle:`Customize how Vellum looks and behaves on this device.`,accessory:(0,X.jsx)(s,{variant:`outlined`,onClick:()=>w(!0),children:`Customize`}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsx)(dn,{}),(0,X.jsx)(fi,{})]})}),(0,X.jsx)(Xr,{open:C,onClose:()=>w(!1)}),d&&H()&&(0,X.jsx)(xa,{}),(0,X.jsx)(Rn,{}),(0,X.jsx)(Pr,{}),_===`full`&&D&&p&&(0,X.jsx)(J,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,X.jsx)(An,{assistantId:D.id})}),_===`disabled`&&p&&(0,X.jsx)(J,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage sleep policy.`})}),o&&!l&&(0,X.jsx)(Dn,{}),l&&(0,X.jsx)(J,{title:`Switch Assistant`,subtitle:`Choose which assistant this device is connected to.`,accessory:(0,X.jsx)(s,{variant:`outlined`,onClick:()=>void h(`${K.selectAssistant}?noAutoSkip=1`),children:`Choose Assistant`})}),(P||F)&&(0,X.jsx)(J,{variant:`danger`,title:`Danger Zone`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[P&&(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Retire Assistant`}),(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently retire this assistant and delete all associated data.`}),(0,X.jsx)(`div`,{className:`mt-1`,children:(g===`full`||A)&&D?(0,X.jsx)(di,{assistantId:D.id}):(0,X.jsx)(q,{children:`Log in to the Vellum platform to retire this assistant.`})})]}),P&&F&&(0,X.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,X.jsx)(In,{})]})})]})}export{Sa as GeneralPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./capture-error-CqtAGHQu.js";import{t as r}from"./react-BFJW0bSv.js";import{t as i}from"./button-BwFudwM5.js";import{m as a,u as o}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as s}from"./QueryClientProvider-CMu7CkQU.js";import{t as c}from"./jsx-runtime-D3ZM-ToX.js";import{t as l}from"./progress-bar-3GUUAhXi.js";import{_ as ee,b as te,f as u,g as ne,it as re,j as ie,ot as d,w as f}from"./local-mode-DHueA-BJ.js";import{t as p}from"./is-electron-DIlIrdJX.js";import{n as m}from"./resolved-assistants-store-C6oDdTxB.js";import{r as ae}from"./api-errors-BRGPPSWw.js";import{_t as oe,dt as h,gt as se,ht as ce,n as g,rt as le,st as ue,tt as _,vt as de}from"./auth-store-C9aYqB9U.js";import{a as fe,o as pe,r as v}from"./api-CGsj1Pig.js";import{d as y}from"./routes-DrfnNoYS.js";import{h as me,o as he}from"./prefs-CfRaGUUx.js";import{a as b,t as x}from"./navigation-resolver-CzEY-5nE.js";import{t as S}from"./build-state-9uUe0jN5.js";import{t as C}from"./avatar-bundled-components-BvKt7I7O.js";import{t as w}from"./avatar-svg-compositor-axSwKFvf.js";import{t as T}from"./onboarding-layout-CNKJRWfe.js";import{c as ge,n as _e,t as ve}from"./provider-key-BZOwvE14.js";import{a as ye,i as be,n as E,r as D,t as O}from"./avatar-random-BR8w4F35.js";import{t as k}from"./plugin-attribution-DAf_69AU.js";var A=e(r(),1),j=c(),xe=800,M=null,N,P=null,F=null;function I(){M=null,N=void 0,P=null,F=null}var Se={initializing:0,provisioning:.33,connecting:.66,resizing:.85,ready:1},L=1500,Ce={initializing:`Getting things ready…`,provisioning:`Setting up your assistant…`,connecting:`Connecting to your assistant…`,resizing:`Setting up your machine…`,ready:`Ready`};function we(e,t,n){if(e>=t)return t;let r=1-(1-Math.min(1,n/L))**3;return e+(t-e)*r}function Te(){let e=b(S(),{kind:`hatch-gate`});return e.action===`redirect`?{kind:`redirect`,to:e.to}:e.action===`wait`?{kind:`wait`}:{kind:`proceed`}}function R(){let e=o(),r=s(),[c]=a(),b=c.get(`hosting`),S=c.get(`fail`),L=c.get(k),R=p(),z=u()&&b!==null&&b!==`vellum-cloud`,B=b===`vellum-cloud`,V=c.get(x)===`1`,H=g.use.sessionStatus(),Ee=z?h(H):H,[U]=(0,A.useState)(()=>F??=O(C)),De=(0,A.useMemo)(()=>{let e=w(C,U.bodyShape,U.eyeStyle,U.color,320);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`},[U]),[W,G]=(0,A.useState)(`initializing`),[Oe,K]=(0,A.useState)(null),[ke,q]=(0,A.useState)(!1),[Ae,je]=(0,A.useState)(!1),[Me,Ne]=(0,A.useState)(0),[Pe,J]=(0,A.useState)(0),[Fe,Ie]=(0,A.useState)(0),Y=(0,A.useRef)(W),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,G(e),Ie(e=>e+1)},[]);return(0,A.useEffect)(()=>{if(S!==null){K(`Simulated hatch failure (developer menu → Replay Hatch Failure).`);return}let i=Te();if(i.kind===`redirect`){e(i.to,{replace:!0});return}if(i.kind===`wait`)return;B&&u()&&(d(),re(null)),q(!1),je(!1);let a=!1,o=null,s=null,c=null,l=Date.now(),p,h=!1,x=!1,C=he(),w=t=>{try{me(``)}catch(e){n(e,{context:`onboarding_mark_completed`})}J(1),Q.current=1,X.current=1,G(`ready`),Y.current=`ready`,s=setTimeout(()=>{a||(I(),(async()=>{if(await ue.checkAssistant(),!a){if(z){let n=new URLSearchParams;b&&n.set(`hosting`,b),t&&n.set(`assistant`,t),L&&n.set(k,L);let r=n.toString();e(`${y.onboarding.research}${r?`?${r}`:``}`,{replace:!0});return}e(y.onboarding.research,{replace:!0})}})())},xe)},T=e=>ye(e,U,r),O=async()=>{if($(`provisioning`),!z){try{let e=await v(),t=oe(e);if(!a&&e.ok&&t.kind===`active`){u()&&f(e.data.id,e.data.name,le()??void 0),await j(e.data.id);return}t.kind===`auto_hatch`&&(x=!0)}catch{}if(a)return}if(z){try{let e=b===`docker`?`docker`:void 0;M&&N!==e&&I(),M||=(N=e,ie(void 0,e));let t=await M;if(a)return;if(!t.ok){I(),K(t.error??`Failed to hatch local assistant.`);return}await ne(),t.assistantId&&_(t.assistantId),$(`connecting`);let r=!1;for(;!a&&!r;){if(await te()){d(),await ee(),r=!0;break}if(Date.now()-l>=3e5){I(),K(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{c=setTimeout(e,D)}),c=null}if(a)return;if(t.assistantId)try{await _e(t.assistantId)}catch(e){if(e instanceof ve){if(!a){let t=ge(e.provider)?.displayName??e.provider;je(!0);let n=`Update your ${t} API key to continue.`;K(e.reason?`${e.reason} ${n}`:n)}return}n(e,{context:`onboarding_apply_provider_key`})}t.assistantId&&await g.getState().connectLocalAssistant(t.assistantId),t.assistantId&&(m.getState().upsertFromApi({id:t.assistantId,name:t.assistantId,status:`active`,is_local:!0,created:new Date().toISOString()}),_(t.assistantId),T(t.assistantId)),w(t.assistantId)}catch{if(I(),a)return;K(`Failed to hatch local assistant. Check CLI logs for details.`)}return}try{P||=pe(C?{version:C}:void 0);let e=await P;if(P=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}}),se(e.status,e.error)){K(ce),q(!0);return}if(!de(e.status)){K(ae(e.error,void 0,`Failed to start your assistant. Please try again.`));return}}}catch(e){if(P=null,n(e,{context:`onboarding_hatch_assistant`}),a)return}A(0)},A=e=>{a||(o=setTimeout(F,e))},j=async e=>{for($(`connecting`);!a;){try{if((await fe(e)).ok)break}catch{}if(Date.now()-l>=3e5){K(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{o=setTimeout(e,D)}),o=null}if(a)return;let n=await be({assistantId:e,postCheckoutReturn:V,managedHatch:B,hatchStartMs:l,isCancelled:()=>a,onResizeWait:()=>$(`resizing`),registerTimer:e=>{o=e}});if(!a){if(n===`health_timeout`){t(`Onboarding hatch wait exceeded timeout`,{level:`warning`,extra:{maxWaitMs:E,stage:`post_resize_health`}}),K(`Your assistant is taking longer than expected. Please try again.`);return}w()}},F=async()=>{if(!a){if(Date.now()-l>=3e5){t(`Onboarding hatch wait exceeded timeout`,{level:`warning`,extra:{maxWaitMs:E}}),K(`Your assistant is taking longer than expected. Please try again.`);return}try{let e=await v(p);if(a||p&&!e.ok&&e.status===404&&(p=void 0,e=await v(),a))return;let t=oe(e);if(t.kind===`active`){if(e.ok){let t=e.data.id;m.getState().upsertFromApi(e.data),_(t),(h||x)&&T(t),u()&&f(t,e.data.name,le()??void 0),await j(t);return}w();return}if(t.kind===`error`){K(t.message);return}t.kind!==`auto_hatch`&&Y.current===`provisioning`&&$(`connecting`),A(D)}catch(e){if(n(e,{context:`onboarding_poll_assistant`}),a)return;A(D)}}};return O(),()=>{a=!0,o&&clearTimeout(o),s&&clearTimeout(s),c&&clearTimeout(c)}},[Me,S,U,B,V,Ee,e,r,$,z]),(0,A.useEffect)(()=>{Z.current===0&&(Z.current=Date.now());let e,t=()=>{let n=Date.now()-Z.current,r=Se[Y.current],i=we(X.current,r,n);Q.current=i,J(i),r-i>1e-6&&(e=requestAnimationFrame(t))};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[Fe]),Oe?(0,j.jsx)(T,{children:(0,j.jsxs)(`div`,{role:`alert`,className:`mx-auto flex w-full max-w-xl flex-col items-center ${R?`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,j.jsx)(`h1`,{className:R?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:Ae?`Your API key didn't work`:`Something went wrong`}),(0,j.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${R?`mt-3.5`:`mt-4`}`,children:Oe}),ke&&(0,j.jsxs)(`div`,{className:`mt-6 flex w-full max-w-sm flex-col items-center gap-3`,children:[(0,j.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Get started today with a local assistant`}),(0,j.jsx)(i,{asChild:!0,variant:`primary`,size:`regular`,fullWidth:!0,className:R?void 0:`h-11 text-base`,children:(0,j.jsx)(`a`,{href:`${window.location.origin}/download`,children:`Download the macOS app`})})]}),(0,j.jsx)(`img`,{src:De,alt:``,width:160,height:160,className:`${R?`my-auto py-8`:`my-16`} onboarding-avatar-failed`}),(0,j.jsxs)(`div`,{className:`flex w-full flex-col ${R?`gap-2.5 max-w-[280px]`:`gap-2 max-w-sm`}`,children:[Ae?(0,j.jsx)(i,{variant:`primary`,size:`regular`,fullWidth:!0,className:R?void 0:`h-11 text-base`,onClick:()=>void e(b?`${y.onboarding.apiKey}?hosting=${b}`:y.onboarding.apiKey,{replace:!0}),children:`Update API key`}):(0,j.jsx)(i,{variant:`primary`,size:`regular`,fullWidth:!0,className:R?void 0:`h-11 text-base`,onClick:()=>{X.current=0,Z.current=Date.now(),Y.current=`initializing`,Q.current=0,G(`initializing`),J(0),Ie(e=>e+1),K(null),q(!1),Ne(e=>e+1)},children:`Try again`}),(0,j.jsx)(i,{variant:`outlined`,size:`regular`,fullWidth:!0,className:R?void 0:`h-11 text-base`,onClick:()=>void e(z?y.onboarding.hosting:y.onboarding.privacy,{replace:!0}),children:`Back`})]})]})}):(0,j.jsx)(T,{children:(0,j.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${R?`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,j.jsx)(`h1`,{className:R?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:W===`ready`?`Your assistant is ready!`:`Waking up…`}),W!==`ready`&&(0,j.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${R?`mt-3.5`:`mt-4`}`,children:`Hang tight — your assistant will have a few questions for you once it's up.`}),(0,j.jsx)(`img`,{src:De,alt:``,width:160,height:160,className:`${R?`my-auto py-8`:`my-16`} ${W===`ready`?`onboarding-avatar-awake`:`onboarding-avatar-pulse`}`}),(0,j.jsx)(l,{value:Pe,height:6,className:`w-full ${R?`max-w-[200px]`:`max-w-sm`}`,"aria-label":`Assistant startup progress`}),(0,j.jsx)(`p`,{className:`text-[var(--content-tertiary)] ${R?`mt-4 text-label-small-default`:`mt-3 text-body-small-default`}`,children:Ce[W]})]})})}export{R as HatchingScreen};
|