@vellumai/web 0.11.2-staging.1 → 0.11.2-staging.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/{access-DRXEXX07.js → access-CVnesk0m.js} +1 -1
- package/dist/assets/{account-page-CX6hJQwg.js → account-page-mMG1nL1O.js} +1 -1
- package/dist/assets/{acp-run-detail-panel-CiQqwf32.js → acp-run-detail-panel-SN6NIuW5.js} +1 -1
- package/dist/assets/activity-steps-panel-bduSS8_d.js +1 -0
- package/dist/assets/{ai-page-DMad1ZuI.js → ai-page-BMqECtJX.js} +1 -1
- package/dist/assets/{app-card-CiARsZNb.js → app-card-BJigGog3.js} +1 -1
- package/dist/assets/{assistant-status-panel-BcO4L1Ot.js → assistant-status-panel-DyjhJvK6.js} +1 -1
- package/dist/assets/auth-store-C9aYqB9U.js +2 -0
- package/dist/assets/background-task-actions-DmocXKSr.js +1 -0
- package/dist/assets/{background-task-detail-panel-Cwy0aX1X.js → background-task-detail-panel-DCtBOnvF.js} +1 -1
- package/dist/assets/{billing-page-DtY1C_1i.js → billing-page-TF_LgX6K.js} +1 -1
- package/dist/assets/{bookmarks-page-CR6qlXH4.js → bookmarks-page-Brvj5Jf6.js} +1 -1
- package/dist/assets/{build-state-dDRg651i.js → build-state-9uUe0jN5.js} +1 -1
- package/dist/assets/{channels-page-route-BkAp7hp5.js → channels-page-route-8vJJE2LN.js} +1 -1
- package/dist/assets/{chat-markdown-message-Da34digC.js → chat-markdown-message-B7qvlO44.js} +1 -1
- package/dist/assets/{checkout-page-ChHhRSW7.js → checkout-page-MpIPAAgf.js} +1 -1
- package/dist/assets/{command-palette-window-page-BYRKvEj-.js → command-palette-window-page-CoweYsZl.js} +1 -1
- package/dist/assets/{contacts-page-route-6Pnu98io.js → contacts-page-route-BOpVOsYK.js} +1 -1
- package/dist/assets/{conversation-navigation-BqoIExAQ.js → conversation-navigation-Bf3cDRKh.js} +1 -1
- package/dist/assets/{conversation-queries-Dcm9S7mz.js → conversation-queries-BBj4FfQn.js} +1 -1
- package/dist/assets/{credentials-page-BnxIymyf.js → credentials-page-DBLT8nUI.js} +1 -1
- package/dist/assets/{debug-page-Bjdmoc6_.js → debug-page-DfPZPo6D.js} +1 -1
- package/dist/assets/{developer-page-CiJvs_Lu.js → developer-page-DwBmhm09.js} +1 -1
- package/dist/assets/{document-viewer-page-CsLTrhRq.js → document-viewer-page-CA1ParJ6.js} +1 -1
- package/dist/assets/{emails-page-DPdeEAZJ.js → emails-page-Bo0Bwem2.js} +1 -1
- package/dist/assets/{first-run-scope-CXWfJKeP.js → first-run-scope-CPJpXaWU.js} +1 -1
- package/dist/assets/{general-page-DYnUkwRE.js → general-page-BXeIQDGi.js} +1 -1
- package/dist/assets/{hatching-screen-CxSp0qa2.js → hatching-screen-BUpSlvBy.js} +1 -1
- package/dist/assets/{home-page-route-dqvJQwjW.js → home-page-route-BPht0PNp.js} +1 -1
- package/dist/assets/{hosting-screen-kj-kAK7Q.js → hosting-screen-DxtyBx0I.js} +1 -1
- package/dist/assets/index-C7_04HXM.css +2 -0
- package/dist/assets/index-CPeIfypI.js +11 -0
- package/dist/assets/{inspect-page-BlY6O00x.js → inspect-page-C8aLJOd6.js} +1 -1
- package/dist/assets/{integrations-page-49zuLodO.js → integrations-page-Bp2Q81Qt.js} +1 -1
- package/dist/assets/{library-detail-page-fsYlOanf.js → library-detail-page-gC4yIWnV.js} +1 -1
- package/dist/assets/{library-page-CjJhvK-9.js → library-page-B10gnbXU.js} +1 -1
- package/dist/assets/{local-runtime-upgrade-BvHY1msh.js → local-runtime-upgrade-CnY-6TiF.js} +1 -1
- package/dist/assets/{login-flow-DmQTk-x9.js → login-flow-CQhvCbQQ.js} +1 -1
- package/dist/assets/{login-page-BvisuxEP.js → login-page-CbWRbJDE.js} +1 -1
- package/dist/assets/{logout-page-BMKKBE_F.js → logout-page-DCyzi0V6.js} +1 -1
- package/dist/assets/{logs-layout-BJe9y8po.js → logs-layout-CYkqau4S.js} +1 -1
- package/dist/assets/{memory-page-route-BcZNNNO7.js → memory-page-route-j_3602nh.js} +1 -1
- package/dist/assets/{memory-router-playground-page-DTR4Mrw4.js → memory-router-playground-page-x5X662qi.js} +1 -1
- package/dist/assets/message-content-B6_GZQl9.js +1 -0
- package/dist/assets/{message-files-panel-CKeLnC4N.js → message-files-panel-C8JokH6e.js} +1 -1
- package/dist/assets/{messages-QgGSiklY.js → messages-Dyp1xUqz.js} +1 -1
- package/dist/assets/{notifications-rSx7pNPi.js → notifications-BTG4cTbF.js} +1 -1
- package/dist/assets/{notifications-page-Cu8hoFGy.js → notifications-page-BA2BW5y6.js} +1 -1
- package/dist/assets/{open-workspace-file-B_Rft7dd.js → open-workspace-file-CivxJWcw.js} +2 -2
- package/dist/assets/{plans-page-BDMR-ZtU.js → plans-page-BfyCgy38.js} +1 -1
- package/dist/assets/{platform-login-notice-q7ZuGeuo.js → platform-login-notice-DFmjUE9q.js} +1 -1
- package/dist/assets/{platform-loopback-page-e9XVrvYR.js → platform-loopback-page-BGF_H8f_.js} +1 -1
- package/dist/assets/{privacy-page-BZSbEQ1K.js → privacy-page-BhEGh78C.js} +1 -1
- package/dist/assets/{privacy-screen-BnQiOWl7.js → privacy-screen-CWVCI_KU.js} +1 -1
- package/dist/assets/{provider-callback-page-z2Cgryjl.js → provider-callback-page-DP5cKqPE.js} +1 -1
- package/dist/assets/{provider-signup-page-B-Li8WKA.js → provider-signup-page-BjiiJWS_.js} +1 -1
- package/dist/assets/{research-onboarding-route-C7jtWVgW.js → research-onboarding-route-DZF-B2Rk.js} +1 -1
- package/dist/assets/{retire-confirm-dialog-CgvcI85l.js → retire-confirm-dialog-8xlq4bkx.js} +1 -1
- package/dist/assets/{review-terms-screen-Bwu6-idm.js → review-terms-screen-C5BAI3Rx.js} +1 -1
- package/dist/assets/routes-uGHUgv4F.js +23 -0
- package/dist/assets/{runtime-upgrade-banner-BhPmj3_g.js → runtime-upgrade-banner-DjFuJawk.js} +1 -1
- package/dist/assets/{schedules-page-CT6myKlW.js → schedules-page-3ZE1nR6I.js} +1 -1
- package/dist/assets/{select-assistant-screen-DbeX0PLD.js → select-assistant-screen-D4WHHv61.js} +1 -1
- package/dist/assets/{settings-layout-ChyYdGV8.js → settings-layout-BmOglXDq.js} +1 -1
- package/dist/assets/{settings-navigation-DNl4C8Cc.js → settings-navigation-CyH-twYD.js} +1 -1
- package/dist/assets/{share-feedback-modal-7O61hwO1.js → share-feedback-modal-Rwuho_1S.js} +1 -1
- package/dist/assets/{sidebar-tree-CsfghEZ-.js → sidebar-tree-Dxx5qLMQ.js} +1 -1
- package/dist/assets/{signup-page-DDuZGMBS.js → signup-page-BAEo45pt.js} +1 -1
- package/dist/assets/site-favicon-CDH0mg6Q.js +1 -0
- package/dist/assets/{skill-detail-page-u1LBXWn1.js → skill-detail-page-DswXTTyb.js} +1 -1
- package/dist/assets/{subagent-detail-panel-8-Z5ZMUL.js → subagent-detail-panel-CidisBCf.js} +1 -1
- package/dist/assets/{system-events-page-DLvxCVqo.js → system-events-page-BrvTNeiN.js} +1 -1
- package/dist/assets/{tool-detail-panel-BmohMKch.js → tool-detail-panel-B2CIRZkB.js} +2 -2
- package/dist/assets/transcript-message-body-shared-BfKwS5qD.js +1 -0
- package/dist/assets/{upgrade-cancel-page-DcWOus4Y.js → upgrade-cancel-page-DjeqfvTa.js} +1 -1
- package/dist/assets/{upgrade-success-page-BSzX2vWY.js → upgrade-success-page-B4TCn340.js} +1 -1
- package/dist/assets/{use-checkout-dismiss-refresh-BcEeQKyP.js → use-checkout-dismiss-refresh-CV_H4uEB.js} +1 -1
- package/dist/assets/{use-command-palette-sections-DvMBAWZC.js → use-command-palette-sections-BshFMe0w.js} +1 -1
- package/dist/assets/{use-edit-app-DOmv9zsZ.js → use-edit-app-Bd1eXXFq.js} +1 -1
- package/dist/assets/{use-is-org-ready-Df3qfx4p.js → use-is-org-ready-3vHDbj4G.js} +1 -1
- package/dist/assets/{use-onboarding-login-V-vR-6Zd.js → use-onboarding-login-CiQyxJLM.js} +1 -1
- package/dist/assets/{use-platform-assistant-id-y2pWr9on.js → use-platform-assistant-id-DgrNmSy2.js} +1 -1
- package/dist/assets/{use-platform-gate-B_3hHMqw.js → use-platform-gate-C5bNA5Pn.js} +1 -1
- package/dist/assets/{use-return-to-short-circuit-DzCxe5P0.js → use-return-to-short-circuit-g88hMnN8.js} +1 -1
- package/dist/assets/{use-sticky-profiles-DamFnjb1.js → use-sticky-profiles-D5TVHOgw.js} +1 -1
- package/dist/assets/use-subagent-card-data-bjGydvhR.js +1 -0
- package/dist/assets/{use-transcript-message-by-id-BxaY6TIY.js → use-transcript-message-by-id-BgyP3Ki5.js} +1 -1
- package/dist/assets/{use-transcript-messages-CgESPWZ3.js → use-transcript-messages-C2uwkjKL.js} +1 -1
- package/dist/assets/{viewer-store-Cp5tMX-G.js → viewer-store-DbIS4l8d.js} +1 -1
- package/dist/assets/{voice-list-yvKUrPIf.js → voice-list-D26Lzbpv.js} +1 -1
- package/dist/assets/{voice-page-C8EoRpvD.js → voice-page-CQ2Vp8p4.js} +1 -1
- package/dist/assets/{welcome-screen-DzQAH74J.js → welcome-screen-CdsjDVfi.js} +1 -1
- package/dist/index.html +34 -34
- package/package.json +1 -1
- package/dist/assets/activity-steps-panel-Ds6C3Jf0.js +0 -1
- package/dist/assets/auth-store-CWJoXmMk.js +0 -2
- package/dist/assets/background-task-actions-762wxVkT.js +0 -1
- package/dist/assets/index-DQqBZlYO.js +0 -11
- package/dist/assets/index-OYTmjL3q.css +0 -2
- package/dist/assets/risk-Bnj8QXuk.js +0 -1
- package/dist/assets/routes-SchRo2Ae.js +0 -23
- package/dist/assets/site-favicon-FokoB0J2.js +0 -1
- package/dist/assets/transcript-message-body-shared-DkwwIkg0.js +0 -1
- package/dist/assets/use-subagent-card-data-B31LofB3.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{n as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{c as a,g as o,n as s}from"./QueryClientProvider-CMu7CkQU.js";import{t as c}from"./useQuery-Bz-fbQ-m.js";import{t as l}from"./useMutation-CXGTrp4W.js";import{t as u}from"./jsx-runtime-D3ZM-ToX.js";import{t as d}from"./typography-DEI9Ra9z.js";import{t as f}from"./createLucideIcon-CAM1RhH8.js";import{t as p}from"./arrow-right-ChqGeAaW.js";import{t as m}from"./check-Dt2rQhdg.js";import{t as h}from"./circle-alert-DQMH8VJH.js";import{t as g}from"./circle-check-DvrCdroD.js";import{t as _}from"./coins-CcTuNVlN.js";import{n as v,t as y}from"./sliders-horizontal-BwdOIxz8.js";import{t as b}from"./hard-drive-sI2ZzmqM.js";import{t as x}from"./info-DkhVkzmK.js";import{t as S}from"./loader-circle-DWWXcfTQ.js";import{t as C}from"./triangle-alert-D6bAGtMw.js";import{t as w}from"./notice-Dslxs3H6.js";import{t as T}from"./modal-xr_vw1ZO.js";import{n as E}from"./toast-BtFgiPe3.js";import{t as ee}from"./confirm-dialog-j9o2h3xs.js";import{t as D}from"./dropdown-B3FHWc_n.js";import{n as O}from"./resolved-assistants-store-C6oDdTxB.js";import{at as k,d as A,f as j,l as te,tt as M,u as N}from"./auth-store-CWJoXmMk.js";import{S as ne,b as re}from"./native-biometric-DetUqtjl.js";import{d as ie}from"./routes-DrfnNoYS.js";import{d as P}from"./platform-detection-AHYibqOx.js";import{n as F}from"./use-assistant-avatar-Bjqx8JUy.js";import{r as ae}from"./use-is-org-ready-Df3qfx4p.js";import{n as oe,r as I}from"./browser-CcdNg0HN.js";import{$ as se,C as ce,O as le,at as ue,c as de,ct as L,et as R,it as fe,jt as z,l as pe,lt as me,nt as he,ot as ge,r as _e,rt as ve,st as ye,tt as be,ut as B,y as xe}from"./react-query.gen-BtYBixpk.js";import{t as V}from"./avatar-bundled-components-BvKt7I7O.js";import{r as Se}from"./use-avatar-accent-var-BafXGBXW.js";import{t as H}from"./misc-BBsGq1IU.js";import{n as Ce,t as we}from"./avatar-tone-D99t9DAP.js";import{t as Te}from"./chat-avatar-B5fx9Xm3.js";import{t as Ee}from"./avatar-renderer-TpNgmnU1.js";import{n as U}from"./use-bundled-avatar-components-BcyasJwu.js";import{t as De}from"./android-consumption-only-D3L1Nc41.js";import{c as Oe,i as W,l as ke,n as G,r as Ae,t as je}from"./machine-sizes-B9nt_h-U.js";import{a as Me,i as Ne,n as Pe,r as Fe,t as Ie}from"./provisioning-targets-Cah9jNBe.js";import{t as Le}from"./environment-store-DxX3xxt2.js";var Re=f(`computer`,[[`rect`,{width:`14`,height:`8`,x:`5`,y:`2`,rx:`2`,key:`wc9tft`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6 18h2`,key:`rwmk9e`}],[`path`,{d:`M12 18h6`,key:`aqd8w3`}]]),K=u();function ze({children:e,redirectToBilling:t=!1}){return P()?t?(0,K.jsx)(r,{replace:!0,to:ie.settings.usageBilling}):(0,K.jsx)(w,{tone:`info`,children:De}):e}var q=e(t(),1);function Be({icon:e}){return(0,K.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-negative-strong) 12%, transparent)`},children:(0,K.jsx)(e,{className:`h-5 w-5`,style:{color:`var(--system-negative-strong)`},"aria-hidden":`true`})})}var J={fontFamily:`var(--font-serif)`,fontSize:`32px`,fontWeight:400,lineHeight:1.2,letterSpacing:`0.64px`};function Y({title:e,subtitle:t}){return(0,K.jsxs)(`header`,{className:`flex flex-col items-center gap-2 pt-12 text-center`,children:[(0,K.jsx)(`h2`,{className:`text-[var(--content-emphasised)]`,style:J,children:e}),t&&(0,K.jsx)(`p`,{className:`text-[14px] font-normal text-[var(--content-secondary)]`,children:t})]})}var Ve=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1},{bodyShape:`stack`,eyeStyle:`gentle`,color:`purple`,size:110,position:`-left-[39px] top-[74%]`,rotate:0},{bodyShape:`urchin`,eyeStyle:`goofy`,color:`pink`,size:137,position:`-right-[42px] -bottom-[40px]`,rotate:180},{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`,size:72,position:`left-[37%] -bottom-[22px] -translate-x-1/2`,rotate:0}],He=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1}];function Ue({variant:e=`full`}){let t=U();return t?(0,K.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`creature-corners`,className:`pointer-events-none absolute inset-0 select-none`,children:(e===`top`?He:Ve).map((e,n)=>(0,K.jsx)(`span`,{className:`absolute ${e.position}`,style:{rotate:`${e.rotate}deg`},children:(0,K.jsx)(Ee,{components:t,bodyShapeId:e.bodyShape,eyeStyleId:e.eyeStyle,colorId:e.color,size:e.size})},n))}):null}var X={waitingStatus:`Upgrading your assistant…`,snagStatus:`We hit a snag upgrading your assistant`,snagCaption:`Retry in the background and we'll keep working on your upgrade.`,confirmingStatus:`Confirming your upgrade…`,confirmTimeoutStatus:`Still confirming your upgrade`,confirmTimeoutCaption:`Your payment went through safely. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still upgrading. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your upgrade continues in the background.`,backgroundRetryToast:`We'll retry your upgrade in the background.`,completeSubtitle:`Enjoy the new found power.`,fetchErrorBody:`We hit a problem checking your subscription. Your upgrade may still be processing. Return to billing to refresh.`},Z={waitingStatus:`Updating your assistant…`,snagStatus:`We hit a snag updating your assistant`,snagCaption:`Retry in the background and we'll keep working on your plan change.`,confirmingStatus:`Confirming your plan change…`,confirmTimeoutStatus:`Still confirming your plan change`,confirmTimeoutCaption:`Your plan change was submitted. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still updating. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your plan change continues in the background.`,backgroundRetryToast:`We'll retry your plan change in the background.`,completeSubtitle:`Your plan changes are live.`,fetchErrorBody:`We hit a problem checking your subscription. Your plan change may still be processing. Return to billing to refresh.`},Q={upgrade:X,downgrade:Z,change:Z};function We(e=`upgrade`){return Q[e]}function Ge(e,t=!0){let{data:n}=c({..._e(),enabled:t&&e==null}),{data:r}=c({...le({path:{id:e??``}}),enabled:t&&e!=null});return e==null?n:r}function Ke({assistantId:e,direction:t}){let r=i(),a=Ge(e,ae())?.name||`your assistant`;return(0,K.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 pb-16 [animation:onboarding-step-in_350ms_ease-out] motion-reduce:[animation:none]`,children:[(0,K.jsx)(Ue,{variant:`full`}),(0,K.jsxs)(`div`,{className:`relative flex w-full flex-col items-center`,children:[(0,K.jsx)(Y,{title:`You're all set!`,subtitle:We(t).completeSubtitle}),(0,K.jsx)(`div`,{className:`mt-10 flex w-full flex-col items-center gap-10`,children:(0,K.jsxs)(n,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>{e!=null&&M(e),r(ie.assistant,{replace:!0})},children:[`Return to `,a]})})]})]})}function qe(e=!0,t){let n=Ge(t,e),r=t??n?.id,{data:i,isError:a,isFetching:o,dataUpdatedAt:s,errorUpdatedAt:l}=c({...de({path:{assistant_id:r??``}}),enabled:e&&!!r});return{assistant:n,assistantId:r,domains:i,domainsError:a,domainsFetching:o,domainsUpdatedAt:s,domainsErrorUpdatedAt:l}}var Je=1e3,Ye=1e4,Xe=2500,Ze=2e3,Qe=1e4,$e=[`machine_size`,`subdomain`,`non_field_errors`],et={subdomain_taken:`That subdomain is already taken. Try another.`,assistant_already_has_domain:`Your assistant already has a custom domain.`,no_assistant_to_attach_domain:`We couldn't find an assistant to attach this domain to.`,exceeds_machine_tier:`That machine size isn't available on your plan.`,provisioning_submission_failed:`We couldn't queue your upgrade just now. Try again in a moment.`,no_active_pro:`We couldn't confirm your Pro plan yet. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to upgrade yet. Try again in a moment.`},tt={provisioning_submission_failed:`We couldn't queue your plan change just now. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to update yet. Try again in a moment.`};function nt(e,t,n=`upgrade`){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=(n===`upgrade`?void 0:tt[t.error])??et[t.error];if(e)return e}for(let e of $e){let n=t[e];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(typeof t.detail==`string`)return t.detail}return t}var rt=`h-8 rounded-lg border border-[var(--border-element)] bg-[var(--field-bg)] px-2.5 text-[14px] text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none transition-[border-color] duration-150 focus:border-[var(--border-active)] disabled:cursor-not-allowed disabled:opacity-60`,it=`text-[11px] font-medium text-[var(--content-secondary)]`;function at({onExit:e,machineBusy:t=!1,assistantId:r}){let i=s(),a=Le.use.emailRootDomain(),{assistant:o,assistantId:c,domains:u}=qe(!0,r),d=u?.results[0],[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(`hi`),[g,_]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!g){if(d){p(d.subdomain),_(!0);return}!o?.handle||f||(p(o.handle),_(!0))}},[o?.handle,d,g,f]);let[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(!1),S=l(ue()),C=!!d||b,E=S.isPending||b;return(0,q.useEffect)(()=>{if(!b)return;let t=setTimeout(e,800);return()=>clearTimeout(t)},[b,e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(T.Body,{className:`animate-[onboarding-step-in_350ms_ease-out] space-y-6 pb-0 motion-reduce:animate-none`,children:[(0,K.jsx)(Ue,{variant:`top`}),(0,K.jsx)(Y,{title:`Assistant Email`,subtitle:`Set up an email for your assistant.`}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`label`,{htmlFor:`onboarding-email-prefix`,className:it,children:`Prefix`}),(0,K.jsx)(`input`,{id:`onboarding-email-prefix`,value:m,onChange:e=>h(e.target.value.toLowerCase().trim()),disabled:E||C,readOnly:C,placeholder:`hi`,className:`${rt} w-24`})]}),(0,K.jsx)(`span`,{className:`flex h-8 items-center text-[var(--content-secondary)]`,children:`@`}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(`label`,{htmlFor:`onboarding-email-handle`,className:it,children:`Handle (public)`}),(0,K.jsx)(`input`,{id:`onboarding-email-handle`,value:f,onChange:e=>{p(e.target.value.toLowerCase().trim()),v&&y(null)},disabled:E||C,readOnly:C,autoFocus:!0,placeholder:`my-assistant`,"aria-invalid":!!v,className:`${rt} w-full min-w-0`})]}),(0,K.jsxs)(`span`,{className:`flex h-8 shrink-0 items-center text-[14px] text-[var(--content-tertiary)]`,children:[`.`,a]})]}),v&&(0,K.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:v}),C&&(0,K.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`This domain has been set and cannot be changed.`})]}),t&&!C&&(0,K.jsx)(w,{tone:`neutral`,children:`Your assistant is restarting — you can set the domain in a moment.`}),!C&&(0,K.jsx)(w,{tone:`info`,className:`border-transparent bg-[var(--surface-active)]`,children:(0,K.jsx)(`span`,{className:`font-medium text-[var(--content-tertiary)]`,children:`You won't be able to change the handle once set.`})}),b?(0,K.jsx)(w,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,K.jsx)(T.Footer,{className:`items-center pt-6`,children:C?(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:e,children:`Continue`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-domain-skip`,disabled:E,onClick:()=>{E||S.mutate({body:{skipped:!0}},{onSuccess:e,onError:()=>e()})},children:`Skip`}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!f||E||t,onClick:()=>{E||t||!f||S.mutate({body:{subdomain:f,...m?{email_username:m}:{}}},{onSuccess:()=>{y(null),x(!0),i.invalidateQueries({queryKey:xe()}),i.invalidateQueries({queryKey:pe({path:{assistant_id:c??``}})}),i.invalidateQueries({queryKey:L()})},onError:e=>{y(nt(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Next`})]})})]})}function ot({onGoToBilling:e,direction:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,K.jsx)(Be,{icon:h}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(d,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,K.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:We(t).fetchErrorBody})]}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function st(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function $(e){return`${st(e)}/mo`}function ct(e){return`${e>0?`+`:`−`}${st(Math.abs(e))}/mo`}function lt(e){return`${e} GB storage`}function ut(e){return`${st(e*100)} of bundled credits`}function dt(e){let{targets:t,fromSnapshot:n,machineFloor:r,credits:i}=e,a=[];return t.machineSize==null?r!=null&&n.machineSize!=null&&n.machineSize!==r&&a.push({key:`machine`,label:`Machine`,from:W[n.machineSize],to:W[r]}):n.machineSize!==t.machineSize&&a.push({key:`machine`,label:`Machine`,from:n.machineSize==null?void 0:W[n.machineSize],to:W[t.machineSize]}),t.storageGib!=null&&(n.storageGib==null||t.storageGib>n.storageGib)&&a.push({key:`storage`,label:`Storage`,from:n.storageGib==null?void 0:`${n.storageGib} GB`,to:`${t.storageGib} GB`}),i!=null&&a.push({key:`credits`,label:`Credits`,from:i.from,to:i.to}),a}var ft=60,pt=ft*2;function mt({imageUrl:e,animateIn:t=!0}){return(0,K.jsxs)(`div`,{"aria-hidden":!0,"data-testid":`takeover-backdrop`,className:`pointer-events-none absolute inset-0 overflow-hidden${t?` provision-avatar-reveal`:``}`,children:[(0,K.jsx)(`img`,{src:e,alt:``,decoding:`async`,draggable:!1,className:`absolute left-1/2 top-1/2 max-w-none -translate-x-1/2 -translate-y-1/2 object-cover object-center`,style:{filter:`blur(${ft}px)`,width:`calc(100% + ${pt*2}px)`,height:`calc(100% + ${pt*2}px)`}}),(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/55`})]})}function ht(e){let t=e?.match(/^credits_(\d+)$/)?.[1];return t==null?null:Number(t)}function gt(e,t){if(t!=null)return e?.credit_tiers?.find(e=>e.tier===t)}function _t(e){let t=ae(),{data:n}=c({...se(),enabled:t&&e});return n?.plans.find(e=>e.id===`pro`)}function vt(e,t){return t==null?0:gt(e,t)?.credits_usd??ht(t)}function yt(e){let t=_t(e!=null);if(e==null||t==null)return null;let n;if(e.kind===`package`){let r=t.packages.find(t=>t.key===e.packageKey);n=r?.credits_usd??gt(t,r?.credit_tier)?.credits_usd}else n=gt(t,e.creditTier)?.credits_usd;return n==null?null:{fromUsd:0,toUsd:n}}function bt(e){let t=_t(e!=null);if(e==null)return null;let n=vt(t,e.fromTier),r=vt(t,e.toTier);return n==null||r==null?null:{fromUsd:n,toUsd:r}}function xt(e){let t=O.use.activeAssistantId(),n=e===void 0?t:e,{components:r,traits:i,customImageUrl:a,isLoading:o}=F(n),s=(0,q.useMemo)(()=>A(),[j()]),c=s!=null&&N(s)?s:null,l=n!=null&&!o,u=c!=null&&(n==null||n===c.assistantId),d=u&&!(l&&(r!=null||i!=null||a!=null))?c:null,f=d?d.components:r,p=d?d.traits:i,m=d?null:a,h=l||u,g=Se(f,p)??(m?null:(f??V).colors?.[0]?.hex??null);return{tintHex:h&&g?Ce(g):we,backdropImageUrl:h?m:null,ready:h,avatar:{components:f,traits:p,customImageUrl:m}}}function St(e,t){let[n,r]=(0,q.useState)(e),i=(0,q.useRef)(0);return(0,q.useEffect)(()=>{i.current=performance.now()},[]),(0,q.useEffect)(()=>{if(t<=0||e===n)return;let a=t-(performance.now()-i.current);if(a<=0){i.current=performance.now(),r(e);return}let o=setTimeout(()=>{i.current=performance.now(),r(e)},a);return()=>clearTimeout(o)},[e,n,t]),t<=0?e:n}var Ct=`--takeover-surface`,wt=`var(${Ct},${we})`,Tt=`color-mix(in srgb, var(--content-emphasised) 10%, transparent)`,Et=240,Dt=1.414,Ot=[{minHeight:680,size:Et},{minHeight:600,size:184}],kt=132;function At(e){for(let t of Ot)if(e>=t.minHeight)return t.size;return kt}function jt(){let[e,t]=(0,q.useState)(()=>At(typeof window>`u`?1/0:window.innerHeight));return(0,q.useEffect)(()=>{let e=()=>t(At(window.innerHeight));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var Mt={machine:v,storage:b,credits:_},Nt={idle:``,working:` is-working`,settling:` is-settling`,stalled:` is-stalled`,grown:` is-evolved`};function Pt(e,t){return e===`DONE`||e===`NOT_APPLICABLE`?`grown`:e===`STALLED`?`stalled`:e===`WAITING`||e===`RESIZING`?t?`settling`:`working`:`idle`}function Ft({assistantId:e,mode:t,downsizing:n=!1}){let{avatar:r,ready:i}=xt(e),a=U(),o=jt(),s=t===`working`||t===`settling`;return(0,K.jsxs)(`div`,{"aria-hidden":!0,className:`provision-avatar-evolve relative z-10 flex flex-col items-center${Nt[i?t:`idle`]}${n?` is-downsizing`:``}`,style:{"--provision-avatar-size":`${o}px`,"--provision-avatar-growth":Dt},children:[(0,K.jsxs)(`div`,{className:`provision-avatar-stage`,children:[(0,K.jsx)(`div`,{"data-testid":`provision-avatar-placeholder`,className:`provision-avatar-placeholder${i?` is-resolved`:``}`}),(0,K.jsx)(`div`,{className:`provision-avatar-layer`,children:(0,K.jsx)(`div`,{className:`provision-avatar-current`,children:(0,K.jsx)(`div`,{className:`provision-avatar-strain`,children:i&&(0,K.jsx)(`div`,{className:`provision-avatar-reveal`,children:(0,K.jsx)(Te,{components:r.components??a,traits:r.traits,customImageUrl:r.customImageUrl,size:o,isAssistantBusy:s})})})})})]}),(0,K.jsx)(`div`,{className:`provision-avatar-shadow`})]})}function It({status:e,caption:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,K.jsx)(`h1`,{className:`text-[var(--content-emphasised)]`,style:J,children:e}),t&&(0,K.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`max-w-sm text-[var(--content-secondary)]`,children:t})]})}function Lt({icon:e,label:t,from:n,to:r,done:i=!1,pending:a=!1,testId:o}){let s=null;return i?s=`Complete`:a&&(s=`Pending`),(0,K.jsxs)(`div`,{"data-testid":o,className:`flex min-w-0 flex-auto items-center gap-2 rounded-lg px-2 py-1.5${a?` opacity-70`:``}`,style:{backgroundColor:Tt},children:[(0,K.jsx)(`span`,{className:`hidden h-6 w-6 shrink-0 items-center justify-center min-[420px]:flex`,children:(0,K.jsx)(e,{className:`h-3.5 w-3.5 text-[var(--content-tertiary)]`,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 text-left wrap-anywhere`,children:[(0,K.jsx)(`span`,{className:`text-[12px] font-medium leading-tight text-[var(--content-tertiary)]`,children:t}),(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-[14px] font-medium leading-[18px] text-[var(--content-emphasised)]`,children:[n&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:n}),(0,K.jsx)(`span`,{className:`sr-only`,children:`to`}),(0,K.jsx)(p,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":`true`})]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{children:r}),i?(0,K.jsx)(m,{"data-testid":`chip-check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`,"aria-hidden":`true`}):a&&(0,K.jsx)(S,{"data-testid":`chip-spinner`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--content-tertiary)] motion-reduce:animate-none`,"aria-hidden":`true`})]}),s&&(0,K.jsx)(`span`,{className:`sr-only`,children:s})]})]})]})}function Rt({label:e}){return(0,K.jsx)(`span`,{className:`rounded-lg px-3 py-2 text-[14px] text-[var(--content-emphasised)]`,style:{backgroundColor:Tt},children:e})}function zt({children:e,wide:t=!1,testId:n}){return(0,K.jsx)(`div`,{"data-testid":n,className:`flex w-full ${t?`max-w-2xl`:`max-w-sm`} items-stretch justify-center gap-2`,children:e})}function Bt(e,t){return e===`credits`?!0:t?.[e]===!0}function Vt({intent:e,creditsChange:t,targets:n,fromSnapshot:r,machineFloor:i,landed:a,allDone:o=!1,creditsOnly:s=!1}){let c=yt(e),l=bt(t),u=c??l,d=dt({targets:n,fromSnapshot:r,machineFloor:i,credits:u==null?null:{from:$(u.fromUsd*100),to:$(u.toUsd*100)}}),f=s?d.filter(e=>e.key===`credits`):d,p=f.filter(e=>o||Bt(e.key,a)).map(e=>e.label).join(`, `),[m]=(0,q.useState)(p),h=p===m?``:`${p} complete`;return f.length===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(zt,{testId:`resource-chips`,wide:f.length>=3,children:f.map(e=>{let t=o||Bt(e.key,a);return(0,K.jsx)(Lt,{testId:`chip-${e.key}`,icon:Mt[e.key],label:e.label,from:e.from,to:e.to,done:t,pending:!t},e.key)})}),(0,K.jsx)(`p`,{"aria-live":`polite`,className:`sr-only`,"data-testid":`chip-announcement`,children:h})]})}function Ht({intent:e}){if(e.kind===`package`)return(0,K.jsx)(zt,{children:(0,K.jsx)(Rt,{label:`${e.packageKey.charAt(0).toUpperCase()+e.packageKey.slice(1)} package`})});let t=[e.machineTier,e.storageTier,e.creditTier].filter(e=>e!=null).length;return(0,K.jsxs)(zt,{wide:t>=3,children:[e.machineTier!=null&&(0,K.jsx)(Lt,{icon:v,label:`Machine`,to:G[e.machineTier]??e.machineTier}),e.storageTier!=null&&(0,K.jsx)(Lt,{icon:b,label:`Storage`,to:e.storageTier.toUpperCase()}),e.creditTier!=null&&(0,K.jsx)(Rt,{label:`${e.creditTier.replace(`credits_`,``)} credits`})]})}function Ut({state:e,direction:t,softWaiting:r,intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,celebrating:u,onCelebrationEnd:d,assistantId:f,escapeAvailable:p,onEscape:m,onPhaseChange:h,kickError:g,confirm:_,dwellMs:v=Xe,phaseMinMs:y=900}){let b=We(t),x=(0,q.useRef)(d);(0,q.useEffect)(()=>{x.current=d},[d]);let S=St(e,y),C=S===`DONE`||S===`NOT_APPLICABLE`,w=S===`RESIZING`?`WAITING`:S,T=(0,q.useRef)(h);(0,q.useEffect)(()=>{T.current=h},[h]),(0,q.useEffect)(()=>{T.current?.(S)},[S]);let{tintHex:E,backdropImageUrl:ee}=xt(f),D=u&&C;return(0,q.useEffect)(()=>{if(!D)return;let e=setTimeout(()=>x.current(),v);return()=>clearTimeout(e)},[D,v]),(0,K.jsxs)(`div`,{"data-theme":`dark`,className:`provision-surface-settle relative flex h-full min-h-[420px] w-full flex-col items-center [justify-content:safe_center] gap-10 px-6 py-10 text-center`,style:{[Ct]:E,backgroundColor:wt},children:[ee&&(0,K.jsx)(mt,{imageUrl:ee}),(0,K.jsx)(Ft,{assistantId:f,mode:Pt(S,r),downsizing:t===`downgrade`}),(0,K.jsx)(`div`,{className:`relative z-10 flex min-h-[144px] w-full flex-col items-center gap-8 [animation:onboarding-step-in_420ms_ease-out] motion-reduce:[animation:none]`,children:A()},w)]});function O(e=`Continue in the background`){return p?(0,K.jsx)(n,{variant:`ghost`,"data-testid":`provisioning-escape`,onClick:m,children:e}):null}function k({allDone:e=!1,creditsOnly:t=!1}={}){return(0,K.jsx)(Vt,{intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,allDone:e,creditsOnly:t})}function A(){if(S===`CONFIRMING`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.confirmingStatus,caption:`This might take a couple seconds.`}),i&&(0,K.jsx)(Ht,{intent:i}),O()]});if(S===`WAITING`||S===`RESIZING`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.waitingStatus,caption:r?`Still working — this can take a minute or two.`:`This might take a couple seconds.`}),k(),O()]});if(S===`DONE`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:`All done!`}),k({allDone:!0})]});if(S===`NOT_APPLICABLE`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:`Your plan is ready`}),k({allDone:!0,creditsOnly:!0})]});if(S===`STALLED`){let e=g!=null;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:e?b.snagStatus:`This is taking longer than expected`,caption:e?nt(g,b.snagCaption,t):`This may take a couple of minutes.`}),k(),e?O(`Retry in the background`):O()]})}return S===`CONFIRM_TIMEOUT`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.confirmTimeoutStatus,caption:b.confirmTimeoutCaption}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:_.onGoToBilling,children:`Go to billing`}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:_.onRetry,children:`Try again`})]})]}):null}}function Wt(e){let{planId:t,targets:n,actuals:r,initialActuals:i,resizeOperationInFlight:a,sawOperation:o,msSinceWatchStart:s,confirmExpired:c,serverVerdict:l=null,statusObservedSinceTargetsMet:u=!0,targetsProveNoop:d=!0}=e;if(t!==`pro`)return{state:c?`CONFIRM_TIMEOUT`:`CONFIRMING`,softWaiting:!1};let f=o||a,p=l===`started`||l===`in_progress`,m=o||d&&u;if(!a){let e=p?m:f||l===`already_done`||i!=null&&!Me(n,i);if(Me(n,r)){if(e)return{state:`DONE`,softWaiting:!1};if(!p&&(d||l===`not_applicable`))return{state:`NOT_APPLICABLE`,softWaiting:!1}}else{if(l===`already_done`)return{state:`DONE`,softWaiting:!1};if(l===`not_applicable`)return{state:`NOT_APPLICABLE`,softWaiting:!1}}}return s!=null&&s>=9e4?{state:`STALLED`,softWaiting:!1}:f||l===`started`||l===`in_progress`?{state:`RESIZING`,softWaiting:!1}:{state:`WAITING`,softWaiting:s!=null&&s>=3e4}}var Gt=2e3,Kt=1e3,qt=[`DONE`,`NOT_APPLICABLE`,`CONFIRM_TIMEOUT`],Jt={assistantId:null,machine:null,storage:null};function Yt({open:e,canLowerResources:t=!1,verdictRecheckMs:n=Qe}){let r=s(),i=ae(),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(0),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),[w,T]=(0,q.useState)(null),[E,ee]=(0,q.useState)(Jt),[D,O]=(0,q.useState)(null),[A,j]=(0,q.useState)(!1),te=(0,q.useRef)(!1),M=(0,q.useRef)(!1),N=(0,q.useRef)(0),[ne,re]=(0,q.useState)(!1),[ie,P]=(0,q.useState)(null),[F,oe]=(0,q.useState)(null),[I,se]=(0,q.useState)(null),[ue,de]=(0,q.useState)(()=>Date.now()),[R,fe]=(0,q.useState)(!0);(0,q.useEffect)(()=>{e||(d(!1),p(0),h(null),_(null),y(null),re(!1),P(null),oe(null),se(null),fe(!0),x(null),C(null),T(null),ee(Jt),O(null),j(!1),te.current=!1,M.current=!1,N.current+=1)},[e]),(0,q.useEffect)(()=>{e&&(h(Date.now()),r.invalidateQueries({queryKey:B()}),r.invalidateQueries({queryKey:L()}))},[e,r]);let z=g!=null,pe=c({...me(),refetchInterval:e=>e.state.data?.plan_id===`pro`||u?!1:Je,refetchIntervalInBackground:!1,enabled:e&&i&&!z}),he=(m!=null&&pe.dataUpdatedAt>=m?pe.data?.plan_id:null)??null;(0,q.useEffect)(()=>{if(!e||z||he!==`pro`)return;let t=Date.now();_(t),de(t)},[e,z,he]),(0,q.useEffect)(()=>{if(!e||z)return;let t=setTimeout(()=>d(!0),Ye);return()=>clearTimeout(t)},[e,z,f]);let ve=(0,q.useCallback)(()=>{d(!1),p(e=>e+1),k.getState().fetchOrganizations(),r.invalidateQueries({queryKey:B()})},[r]),be=(0,q.useCallback)(()=>{let e=Date.now();y(e),de(e)},[]),{mutate:xe}=l(ge()),V=(0,q.useCallback)(e=>{let t=N.current;xe({},{onSuccess:n=>{t===N.current&&(O(null),Pe(n)?M.current?O({error:n.reason??`no_active_pro`}):(M.current=!0,j(!0),e===`escape`&&be()):(x(n.state),e===`escape`&&be()))},onError:e=>{t===N.current&&O(e)}})},[xe,be]);(0,q.useEffect)(()=>{!e||!i||!z||te.current||(te.current=!0,V(`auto`))},[e,i,z,V]),(0,q.useEffect)(()=>{if(!A)return;let e=N.current,t=setTimeout(()=>{j(!1),e===N.current&&V(`auto`)},Ze);return()=>clearTimeout(t)},[A,V]);let Se=(0,q.useCallback)(()=>V(`escape`),[V]),H=c({...ye(),enabled:e&&i&&z}),Ce=R?Gt:!1,we=c({..._e(),enabled:e&&i&&z,refetchInterval:e=>e.state.data?.id==null?Ce:!1,retry:!1}),Te=z&&m!=null&&H.dataUpdatedAt>=m,Ee=Te&&!H.isPending&&!H.isFetching,U=(Te?H.data?.primary_assistant_id:null)??(H.isPending?null:we.data?.id??null),De=c({...le({path:{id:U??`unresolved`}}),enabled:e&&i&&z&&U!=null,refetchInterval:Ce,retry:!1}),W=ce({path:{id:U??`unresolved`}}),G=c({...W,enabled:e&&i&&z&&U!=null,refetchInterval:Ce,retry:!1}),Ae=(0,q.useRef)(0),[Le,Re]=(0,q.useState)(0),K=o(W.queryKey);(0,q.useEffect)(()=>r.getQueryCache().subscribe(t=>{if(!(t.type!==`updated`||t.query.queryHash!==K)){if(t.action.type===`fetch`)Ae.current+=1;else if(t.action.type===`success`&&!t.action.manual){let n=Ae.current,r=e&&Fe(t.action.data);a.schedule(()=>{Re(n),r&&(re(!0),P(U))})}}}),[r,K,e,U]);let ze=Fe(G.data),Be=ie===U,J=H.data,Y=(0,q.useMemo)(()=>J?{machineSize:Oe(J.max_machine_tier),storageGib:J.selected_storage_gib??null}:null,[J]),Ve=J!=null&&J.max_machine_tier==null?je:null,He=J?J.domain_setup_available&&J.primary_assistant_id!=null:void 0,Ue=De.data,X=(0,q.useMemo)(()=>Ue?{machineSize:Ue.machine_size??null,storageGib:Ue.provisioned_storage_gib??null}:null,[Ue]),Z=I===U,Q=(0,q.useMemo)(()=>{let e=Ie(Y,X),t=Y?.machineSize??Ve;if(t==null)return e;let n=X?.machineSize??null;if(n==null)return{...e,machine:!1};let r=(Z?F?.machineSize:null)??n,i=ke(t)<ke(r);return{...e,machine:i?ke(n)<=ke(t):ke(n)>=ke(t)}},[Y,X,F,Z,Ve]),We=Me(Y,X),Ge=w===U;(0,q.useEffect)(()=>{e&&(We?(C(e=>e!=null&&Ge?e:Date.now()),T(U)):(C(null),T(null)))},[e,We,U,Ge]);let Ke=E.assistantId===U;(0,q.useEffect)(()=>{if(!e)return;let t=Ae.current;ee(e=>{let n=e.assistantId===U?e:Jt,r=Q.machine?n.machine??t:null,i=Q.storage?n.storage??t:null;return e.assistantId===U&&e.machine===r&&e.storage===i?e:{assistantId:U,machine:r,storage:i}})},[e,Q,U]);let qe=(0,q.useMemo)(()=>{let e=Ne(G.data),t=e=>e!=null&&Ke&&Le>e;return{machine:Q.machine&&!e.machine&&t(E.machine),storage:Q.storage&&!e.storage&&t(E.storage)}},[Q,E,Ke,Le,G.data]);(0,q.useEffect)(()=>{!e||!X||F!=null&&Z||(oe(X),se(U))},[e,X,U,F,Z]);let Xe=v??g,$e=Xe==null?null:Math.max(0,ue-Xe),et=!t,{state:tt,softWaiting:nt}=Wt({planId:z?`pro`:he,targets:Y,actuals:X,initialActuals:Z?F:null,resizeOperationInFlight:ze,sawOperation:ne&&Be,msSinceWatchStart:$e,confirmExpired:u,serverVerdict:b,statusObservedSinceTargetsMet:S!=null&&Ge&&G.dataUpdatedAt>S,targetsProveNoop:et}),rt=qt.includes(tt),it=e&&z&&!rt;(0,q.useEffect)(()=>{fe(it)},[it]),(0,q.useEffect)(()=>{if(!e||!z||rt)return;let t=setInterval(()=>de(Date.now()),Kt);return()=>clearInterval(t)},[e,z,rt]);let at=!et&&(b===`started`||b===`in_progress`)&&!(ne&&Be);return(0,q.useEffect)(()=>{if(!e||!z||rt||!at)return;let t=setInterval(()=>V(`auto`),n);return()=>clearInterval(t)},[e,z,rt,at,n,V]),{state:tt,softWaiting:nt,targets:Y,actualsSnapshot:F,machineFloor:Ve,landed:qe,assistantId:U,domainStepAvailable:He,onboardingSettled:Ee,confirmError:!z&&pe.isError,targetsError:z&&H.isError&&(!J||!Te),escapeEligible:$e!=null&&$e>=6e4,retryConfirm:ve,kickProvisioning:Se,kickError:D}}var Xt=200,Zt=380;function Qt(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0}var $t=e=>e===`WAITING`||e===`RESIZING`||e===`STALLED`,en=e=>e===`DONE`||e===`NOT_APPLICABLE`,tn={machineSize:null,storageGib:null};function nn({open:e,onClose:t,dwellMs:n,phaseMinMs:r,mode:i=`checkout`,resizeContext:a}){let o=i===`resize`,c=s(),[l,u]=(0,q.useState)(`provisioning`),[d,f]=(0,q.useState)(`idle`),p=(0,q.useRef)([]),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(!1),S=o?a?.direction:void 0,C=We(S),w=Yt({open:e,canLowerResources:o?a?.canLowerResources===!0:!1}),D=(0,q.useRef)(!1);(0,q.useEffect)(()=>{if(e){D.current=!0,h(o?null:ne()),y(e=>e??Date.now());return}p.current.forEach(clearTimeout),p.current=[],u(`provisioning`),f(`idle`),_(null),y(null),x(!1),D.current&&(D.current=!1,te())},[e,o]),(0,q.useEffect)(()=>()=>{p.current.forEach(clearTimeout)},[]),(0,q.useEffect)(()=>{l===`complete`&&re()},[l]);let O=$t(w.state),k=en(g??w.state),{targets:A,assistantId:j,domainStepAvailable:M,onboardingSettled:N}=w,ie=o?a?.fromSnapshot:void 0,P=w.actualsSnapshot,F={machineSize:ie?.machineSize??P?.machineSize??null,storageGib:ie?.storageGib??P?.storageGib??null},{tintHex:ae,backdropImageUrl:oe}=xt(j),I=o&&M===!0,{domains:se,domainsError:ce,domainsFetching:le,domainsUpdatedAt:ue,domainsErrorUpdatedAt:de}=qe(e&&I,j),L=(se?.results.length??0)>0,R=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!e){R.current=null;return}!I||j==null||R.current!==j&&(R.current=j,c.invalidateQueries({queryKey:pe({path:{assistant_id:j}})}))},[e,I,j,c]);let fe=!le&&(v!=null&&ue>=v||v!=null&&!!ce&&de>=v),[z,me]=(0,q.useState)(!1),he=N&&(!I||fe);(0,q.useEffect)(()=>{if(!e){me(!1);return}he&&me(!0)},[e,he]);let ge=(0,q.useCallback)(()=>{let e=o?M===!0&&!L?`domain`:`complete`:M===!1?`complete`:`domain`;if(Qt()){u(e);return}f(`covering`),p.current.push(setTimeout(()=>{u(e),f(`revealing`),p.current.push(setTimeout(()=>f(`idle`),Zt))},Xt))},[M,o,L]),_e=(0,q.useCallback)(()=>{x(!0)},[]),ve=(0,q.useCallback)(()=>{w.kickProvisioning(),E.info(w.kickError==null?C.backgroundExitToast:C.backgroundRetryToast),x(!1),t()},[w,t,C]),ye=(0,q.useCallback)(()=>{x(!1)},[]),be=l===`provisioning`&&(w.confirmError||w.targetsError),B=l===`provisioning`&&!be,xe=B&&!k,V=`transition-[background-color] duration-300 ease-out${B?` bg-black p-0`:``}`,Se=B?`[animation:fadeIn_0.45s_ease-out_both]`:d===`revealing`?`[animation:fadeInUp_0.42s_ease-out_0.12s_both]`:`[animation:fadeIn_0.25s_ease-out_both]`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,K.jsxs)(T.Content,{size:`md`,hideCloseButton:l!==`complete`,dismissOnOverlayClick:!xe,onEscapeKeyDown:xe?e=>e.preventDefault():void 0,onInteractOutside:xe?e=>e.preventDefault():void 0,"data-theme":B?`dark`:void 0,overlayClassName:V,className:B?`overflow-y-auto inset-0 max-w-none w-screen h-screen max-h-none rounded-none border-0`:`overflow-hidden`,style:{[Ct]:ae},children:[(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col motion-reduce:[animation:none] ${Se}`,children:H()},l),d!==`idle`&&(0,K.jsx)(`div`,{"aria-hidden":!0,"data-testid":`takeover-exit-sheet`,className:`pointer-events-none fixed inset-0 z-50 ${d===`covering`?`[animation:fadeIn_200ms_ease-in_both]`:`[animation:fadeIn_380ms_ease-out_both_reverse]`}`,style:{backgroundColor:wt},children:oe&&(0,K.jsx)(mt,{imageUrl:oe,animateIn:!1})})]})}),(0,K.jsx)(ee,{open:b&&O,title:`Continue in the background?`,message:C.backgroundConfirmMessage,confirmLabel:`Continue`,cancelLabel:`Keep waiting`,onConfirm:ve,onCancel:ye})]});function H(){return l===`provisioning`?w.confirmError||w.targetsError?(0,K.jsx)(ot,{onGoToBilling:t,direction:S}):(0,K.jsx)(Ut,{state:w.state,direction:S,softWaiting:w.softWaiting,intent:m,creditsChange:o?a?.credits:void 0,targets:A??tn,fromSnapshot:F,machineFloor:w.machineFloor,landed:w.landed,celebrating:z,onCelebrationEnd:ge,assistantId:j,escapeAvailable:O&&w.escapeEligible,onEscape:_e,onPhaseChange:_,kickError:w.kickError,confirm:{onRetry:w.retryConfirm,onGoToBilling:t},dwellMs:n,phaseMinMs:r}):l===`domain`?(0,K.jsx)(at,{machineBusy:O,assistantId:j,onExit:()=>u(`complete`)}):(0,K.jsx)(Ke,{assistantId:j,direction:S})}}function rn(e){return e!=null&&!e.customized}function an(e){return rn(e)?e.name:`Custom`}var on=[`mighty`,`super`,`ultra`],sn=[`free`,...on];function cn(e){return sn.indexOf(e)}function ln(e,t){if(e===null)return`upgrade`;let n=cn(e),r=cn(t);return n===-1||r===-1?`upgrade`:r===n?`current`:r<n?`downgrade`:`upgrade`}function un(e,t){if(e.length===0)return null;let n=[...e].sort((e,t)=>on.indexOf(e.key)-on.indexOf(t.key));if(!t)return n[0];let r=n.findIndex(e=>e.key===t);return r===-1?n[0]:r>=n.length-1?null:n[r+1]}var dn={free:{bodyShape:`ninja`,eyeStyle:`angry`,color:`yellow`},mighty:{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`},super:{bodyShape:`urchin`,eyeStyle:`goofy`,color:`teal`},ultra:{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`}};function fn({tier:e,size:t=40}){let n=dn[e]??dn.free,r=U();return(0,K.jsx)(`div`,{"aria-hidden":!0,className:`inline-flex shrink-0`,children:r?(0,K.jsx)(Ee,{components:r,bodyShapeId:n.bodyShape,colorId:n.color,size:t}):(0,K.jsx)(`div`,{style:{width:t,height:t}})})}var pn=`Small`;function mn(e){return e?.machine_size?W[e.machine_size]??e.machine_size:pn}function hn(e){let t=e?.credits_usd??0,n=e?.storage_gib??4;return[{icon:Re,label:`${mn(e)} Machine`},{icon:_,label:`${st(t*100)} credits`},{icon:b,label:`${n} GB`}]}function gn(e,t=[]){let n=e?.credits_usd??0,r=e?.storage_gib??4,i=Ae[e?.machine_size??`small`];return[`${mn(e)} machine${i?` (${i})`:``}`,lt(r),ut(n),...t]}var _n={machine:`Configurable machine size`,storage:`Configurable storage`,credits:`Pay-as-you-go and bundled credits`};function vn(e,t){let n=[`${e.machineTier?G[e.machineTier]??t.machine_tiers.find(t=>t.tier===e.machineTier)?.label??e.machineTier:pn} Machine`];if(e.storageGib!=null&&n.push(`${e.storageGib} GB`),e.creditTier!=null){let r=gt(t,e.creditTier)?.credits_usd??ht(e.creditTier);n.push(r==null?`Credit bundle`:`${r} credits/mo`)}return n}function yn(e,t){let n=new Set([_n.machine]);return e.storageGib!=null&&n.add(_n.storage),e.creditTier!=null&&n.add(_n.credits),[...vn(e,t),...t.included_features.filter(e=>!n.has(e))]}var bn=`billing-portal-return-snapshot`;function xn(e){try{sessionStorage.removeItem(bn),sessionStorage.setItem(bn,JSON.stringify(e))}catch{}}function Sn(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(bn);if(!e)return null;let t=JSON.parse(e);return typeof t.cancel_at_period_end!=`boolean`||typeof t.plan_id!=`string`?null:{cancel_at_period_end:t.cancel_at_period_end,cancel_at:t.cancel_at??null,plan_id:t.plan_id}}catch{return null}}function Cn(){try{sessionStorage.removeItem(bn)}catch{}}function wn(e){return e?{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at??null,plan_id:e.plan_id}:null}function Tn(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function En(e){return e?e.cancel_at??e.current_period_end??null:null}function Dn(e){let t=s();return(0,q.useEffect)(()=>I(()=>{t.invalidateQueries(me())}),[t]),z({onSuccess:t=>{e&&xn(e),oe(t.portal_url)},onError:()=>{E.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function On(e){return e.disabled===!0}function kn({machineTiers:e,storageTiers:t,selectedMachineTier:n,selectedStorageTier:r,onMachineTierChange:i,onStorageTierChange:a,currentMachinePriceCents:o,currentStoragePriceCents:s}){let c=(0,q.useMemo)(()=>e.map(e=>{let t=G[e.tier]??e.label,n=o==null?`+${$(e.price_cents)}`:e.price_cents===o?`(${$(e.price_cents)}, current)`:ct(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:On(e)}}),[e,o]),l=(0,q.useMemo)(()=>t.map(e=>{let t=s==null?`+${$(e.price_cents)}`:e.price_cents===s?`(${$(e.price_cents)}, current)`:ct(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GB ${t}`,disabled:On(e)}}),[t,s]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,K.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,K.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(D,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,K.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,K.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(D,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var An=new Set([`active`,`trialing`,`past_due`]);function jn(e){return e.plan_id!==`base`&&e.cancel_at_period_end!==!0&&!e.cancel_at&&e.status!=null&&An.has(e.status)}var Mn=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`package`,`non_field_errors`];function Nn(e,t){if(e&&typeof e==`object`){for(let t of Mn)if(t in e){let n=e[t];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(`detail`in e&&typeof e.detail==`string`)return e.detail}return t}function Pn(e,t){let n=e.filter(e=>!On(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Fn(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function In(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Ln(){let e=s(),t=l(ve());return{changePackage:async n=>{try{let r=await t.mutateAsync({body:{package:n}});return await Promise.all([e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:R()}),e.invalidateQueries({queryKey:L()})]),r}catch(e){return E.error(Nn(e,`Failed to change your plan. Please try again.`)),null}},isPending:t.isPending}}function Rn({enabled:e=!0}={}){let t=s(),n=ae(),r=e&&n,i=c({...me(),enabled:r}),a=i.data,o=a!=null&&a.plan_id!==`base`,u=c({...ye(),enabled:r&&o}),d=c({...se(),enabled:r&&o}).data?.plans.find(e=>e.id===`pro`)?.machine_tiers??[],f=e=>d.find(t=>t.tier===e)?.price_cents??null,p=l(he()),m=l(fe()),h=l(be()),g={machineTier:u.data?.max_machine_tier??null,storageTier:u.data?.selected_storage_tier??null,storageGib:u.data?.selected_storage_gib??null,creditTier:a?.selected_credit_tier??null},_=a!=null&&a.plan_id!==`base`&&a.status!=null&&An.has(a.status)&&a.cancel_at_period_end!==!0&&!a.cancel_at,v=!o||!u.isPending,y=!o||u.isSuccess&&u.data!=null&&!u.isFetching&&u.dataUpdatedAt>=i.dataUpdatedAt,b=p.isPending||m.isPending||h.isPending,x=()=>Promise.all([t.invalidateQueries({queryKey:B()}),t.invalidateQueries({queryKey:L()}),t.invalidateQueries({queryKey:R()})]);return{changeTiers:async e=>{let t=e.machineTier!==g.machineTier,n=e.storageTier!==g.storageTier,r=e.creditTier!==g.creditTier,i=f(e.machineTier),a=f(g.machineTier),o=t&&i!=null&&a!=null&&i<a,s=[];if(t&&s.push(new Promise(t=>{p.mutate({body:{machine_tier:e.machineTier}},{onSuccess:()=>t({dimension:`machine`,ok:!0}),onError:e=>t({dimension:`machine`,ok:!1,error:e})})})),n&&s.push(new Promise(t=>{m.mutate({body:{storage_tier:e.storageTier}},{onSuccess:()=>t({dimension:`storage`,ok:!0}),onError:e=>t({dimension:`storage`,ok:!1,error:e})})})),r&&s.push(new Promise(t=>{h.mutate({body:{credit_tier:e.creditTier}},{onSuccess:()=>t({dimension:`credit`,ok:!0}),onError:e=>t({dimension:`credit`,ok:!1,error:e})})})),s.length===0)return{needsResize:!1,creditChanged:!1};let c=await Promise.all(s);await x();let l=c.some(e=>e.ok&&e.dimension===`machine`)&&!o,u=c.some(e=>e.ok&&e.dimension===`storage`),d=l||u,_=c.some(e=>e.ok&&e.dimension===`credit`),v=c.filter(e=>!e.ok);if(v.length>0){let e=v.map(e=>Nn(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);return E.error(e),d||_?{needsResize:d,creditChanged:_}:null}return{needsResize:d,creditChanged:_}},isPending:b,current:g,eligible:_,currentReady:v,currentKnown:y,primaryAssistantId:y?u.data?.primary_assistant_id??null:null}}var zn=`__none__`,Bn=`No extra credits`;function Vn(e){let{proPlan:t,seed:n,machineTier:r,storageTier:i,creditChoice:a}=e,o=t.machine_tiers,s=t.storage_tiers,c=t.credit_tiers??[],l=o.find(e=>e.tier===r)??null,u=s.find(e=>e.tier===i)??null,d=a&&a!==`__none__`?c.find(e=>e.tier===a)??null:null,f=n==null?null:o.find(e=>e.tier===n.machineTier)??null,p=n==null?null:s.find(e=>e.tier===n.storageTier)??null,m=n!=null&&n.creditTier!=null?c.find(e=>e.tier===n.creditTier)??null:null,h=n!=null&&n.machineTier!=null&&f==null,g=n!=null&&p==null,_=[{key:`base`,label:`Platform fee: ${$(t.base_price_cents)}`,changed:!1}];if(l!=null){let e=n!=null&&!h&&f?.tier!==l.tier;_.push({key:`machine`,label:l.description,previousLabel:e&&f!=null?f.description:void 0,changed:e})}if(u!=null){let e=n!=null&&!g&&p?.tier!==u.tier;_.push({key:`storage`,label:lt(u.storage_gib),previousLabel:e&&p!=null?lt(p.storage_gib):void 0,changed:e})}let v=a===`__none__`?Bn:d==null?null:ut(d.credits_usd);if(v!=null){let e=n!=null&&(n.creditTier??`__none__`)!==a,t=n?.creditTier==null?Bn:m==null?void 0:ut(m.credits_usd);_.push({key:`credit`,label:v,previousLabel:e?t:void 0,changed:e})}let y=t.base_price_cents+(l?.price_cents??0)+(u?.price_cents??0)+(d?.price_cents??0),b=h||g||n!=null&&n.creditTier!=null&&m==null;if(n==null||b)return{totalCents:y,previousTotalCents:null,deltaCents:null,rows:_};let x=t.base_price_cents+(f?.price_cents??0)+(p?.price_cents??0)+(m?.price_cents??0);return{totalCents:y,previousTotalCents:x,deltaCents:y-x,rows:_}}function Hn(e){return(0,K.jsxs)(`span`,{className:`text-[12px] font-medium text-[var(--content-disabled)]`,children:[`+`,$(e)]})}function Un({open:e,proPlan:t,pending:r,currentStorageGib:i,initialSelection:a,onClose:o,onContinue:s}){let c=e?a??null:null,[l,u]=(0,q.useState)(()=>c?.machineTier??``),[d,f]=(0,q.useState)(()=>c?.storageTier??``),[p,m]=(0,q.useState)(()=>c?c.creditTier??`__none__`:``),[h,v]=(0,q.useState)({open:e,initialSelection:a});(h.open!==e||h.initialSelection!==a)&&(v({open:e,initialSelection:a}),u(c?.machineTier??``),f(c?.storageTier??``),m(c?c.creditTier??`__none__`:``));let x=t.machine_tiers,S=(0,q.useMemo)(()=>t.storage_tiers.filter(e=>!e.legacy||e.tier===a?.storageTier),[t.storage_tiers,a?.storageTier]),C=t.credit_tiers??[],w=(0,q.useMemo)(()=>(t.credit_tiers??[]).filter(e=>!e.legacy),[t.credit_tiers]),E=e=>On(e)||e.legacy&&e.tier!==a?.storageTier||i!=null&&e.storage_gib<i,ee=x.map(e=>({value:e.tier,label:e.description,icon:(0,K.jsx)(Re,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:On(e)})),O=S.map(e=>({value:e.tier,label:e.label,icon:(0,K.jsx)(b,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:E(e)})),k=p&&p!==`__none__`?C.find(e=>e.tier===p)??null:null,A=k?.legacy?k:null,j=[{value:zn,label:Bn,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0})},...w.map(e=>({value:e.tier,label:e.label,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents)})),...A?[{value:A.tier,label:A.label,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(A.price_cents),disabled:!0}]:[]],te=x.find(e=>e.tier===l)??null,M=d!==``&&d===a?.storageTier,N=S.find(e=>e.tier===d&&(M||!E(e)))??null,ne=p===`__none__`||p===a?.creditTier||w.some(e=>e.tier===p),re=p!==``&&ne?p:null,ie=te!=null&&N!=null&&re!=null,P=a!=null&&l===(a.machineTier??``)&&d===a.storageTier&&p===(a.creditTier??`__none__`),F=(0,q.useMemo)(()=>Vn({proPlan:t,seed:a??null,machineTier:l,storageTier:d,creditChoice:p}),[t,a,l,d,p]);return(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{e||o()},children:(0,K.jsx)(T.Content,{size:`lg`,"data-theme":`light`,hideCloseButton:!0,overlayClassName:`backdrop-blur-[2px]`,className:`max-w-[820px] md:min-h-[min(608px,calc(100vh-4rem))]`,children:(0,K.jsx)(T.Body,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-8 md:flex-row md:gap-12`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6 md:flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`flex shrink-0 items-center justify-center rounded-xl bg-[var(--surface-active)] p-[14px]`,children:(0,K.jsx)(y,{className:`h-6 w-6 text-[var(--content-emphasised)]`,"aria-hidden":!0})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,K.jsx)(T.Title,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Create a custom plan`}),(0,K.jsx)(T.Description,{className:`mt-0 text-[14px] font-medium leading-[18px] text-[var(--content-tertiary)]`,children:`Just better.`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select a machine size:`}),(0,K.jsx)(D,{"aria-label":`Machine size`,placeholder:`Select a machine size`,value:l,onChange:u,options:ee})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select storage:`}),(0,K.jsx)(D,{"aria-label":`Storage`,placeholder:`Select storage`,value:d,onChange:f,options:O})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Bundle some credits:`}),(0,K.jsx)(D,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,value:p,onChange:m,options:j})]})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-16 md:pt-[5px]`,children:[(0,K.jsx)(`span`,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Recap`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[24px] font-medium text-[var(--content-default)]`,children:$(F.totalCents)}),F.deltaCents!=null&&F.deltaCents!==0&&F.previousTotalCents!=null&&(0,K.jsxs)(`span`,{className:`text-[12px] font-medium ${F.deltaCents>0?`text-[var(--system-positive-strong)]`:`text-[var(--system-negative-strong)]`}`,children:[ct(F.deltaCents),` compared to previous (`,st(F.previousTotalCents),`)`]}),(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-tertiary)]`,children:`Total`})]}),(0,K.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,K.jsx)(`span`,{className:`text-[12px] font-medium text-[var(--content-tertiary)]`,children:`Your selection:`}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:F.rows.map(e=>(0,K.jsxs)(`li`,{className:`flex flex-col gap-2`,children:[e.previousLabel!=null&&(0,K.jsxs)(`div`,{className:`relative flex w-fit items-start gap-2`,children:[(0,K.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-disabled)]`,"aria-hidden":!0}),(0,K.jsx)(`s`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-disabled)] no-underline`,children:e.previousLabel}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute -left-1 right-0 top-[9px] h-px bg-[var(--content-disabled)]`})]}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 ${e.changed?`text-[var(--system-positive-strong)]`:`text-[var(--content-secondary)]`}`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-secondary)]`,children:e.label})]})]},e.key))}),(0,K.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:!ie||P||r,onClick:()=>{!ie||P||r||s({machineTier:te.tier,storageTier:N.tier,creditTier:re===`__none__`?null:re})},children:`Continue`}),(0,K.jsx)(n,{variant:`ghost`,fullWidth:!0,disabled:r,onClick:o,children:`Cancel`})]})]})]})})})})}function Wn({className:e,"data-testid":t,children:n}){return(0,K.jsx)(`div`,{"aria-hidden":!0,"data-testid":t,className:H(`flex size-[52px] shrink-0 items-center justify-center rounded-xl`,e),children:n})}var Gn=32;function Kn(){let{ready:e,avatar:t}=xt();return(0,K.jsx)(Wn,{"data-testid":`assistant-avatar-tile`,className:`bg-[var(--surface-active)]`,children:e?(0,K.jsx)(Te,{components:t.components,traits:t.traits,customImageUrl:t.customImageUrl,size:Gn}):null})}var qn={free:{tagline:`Get to know your assistant.`,cta:`Start Free`,priceCaption:`Forever`},mighty:{tagline:`More capacity for consistent use.`,cta:`Power Up`,priceCaption:`Billed monthly`,recommended:!0},super:{tagline:`Do more, think less about the how.`,cta:`Go Super`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]},ultra:{tagline:`Your second brain, running full speed.`,cta:`Unleash Ultra`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]}};function Jn(e){return qn[e]}function Yn(e){return`Downgrade to ${e}`}var Xn=`Billed monthly · prorated difference charged today`,Zn=`Billed monthly · prorated difference charged today or credited next invoice`,Qn=`Billed monthly · prorated credit on your next invoice`,$n=`Your machine downsizes now and your storage stays. No refund.`,er=`Continue`,tr=`The plan includes`,nr=`Your plan will include`;function rr(e,t,n){let r=n?Jn(n)?.tagline??``:``;switch(e){case`downgrade`:return{title:Yn(t),subtitle:``,priceCaption:Qn,checklistHeading:nr,note:$n,confirmLabel:Yn(t),destructive:!0};case`switch`:return{title:`Switch to ${t}`,subtitle:r,priceCaption:Zn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1};default:return{title:`Upgrade to ${t}`,subtitle:r,priceCaption:Xn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1}}}function ir({open:e,relation:t,packageName:r,targetPackage:i,pending:a,onCancel:o,onConfirm:s}){let c=(0,q.useRef)(null),l=(0,q.useId)(),u=rr(t,r,i?.key??null),f=i?{price:$(i.total_price_cents),highlights:gn(i,Jn(i.key)?.extraFeatures??[])}:null,p=u.subtitle,m=u.note?{"aria-describedby":l}:p?{}:{"aria-describedby":void 0};return(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{!e&&!a&&o()},children:(0,K.jsxs)(T.Content,{size:`sm`,hideCloseButton:!0,className:`gap-4 p-4 max-w-[421px]`,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus()},...m,children:[(0,K.jsxs)(T.Header,{className:`flex-row items-center gap-3 p-0 pb-2`,children:[u.destructive?(0,K.jsx)(Wn,{"data-testid":`package-switch-warning-tile`,className:`bg-[var(--system-negative-weak)]`,children:(0,K.jsx)(C,{className:`size-6 text-[var(--system-negative-strong)]`})}):(0,K.jsx)(Kn,{}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(T.Title,{className:`text-title-small text-[var(--content-emphasised)] [&>span]:whitespace-normal`,children:u.title}),p?(0,K.jsx)(T.Description,{className:`mt-0 text-body-medium-default text-[var(--content-tertiary)]`,children:p}):null]})]}),f?(0,K.jsxs)(T.Body,{className:`flex flex-col gap-4 p-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsx)(d,{as:`p`,variant:`title-large`,className:`text-[var(--content-default)]`,children:f.price}),(0,K.jsx)(d,{as:`p`,variant:`label-medium-default`,className:`leading-[15px] text-[var(--content-tertiary)]`,children:u.priceCaption})]}),(0,K.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,K.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:u.checklistHeading}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:f.highlights.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(g,{className:`size-4 shrink-0 text-[var(--content-secondary)]`,"aria-hidden":!0}),(0,K.jsx)(d,{as:`span`,variant:`body-medium-default`,className:`text-[var(--content-default)]`,children:e})]},e))})]}):null,u.note?(0,K.jsx)(d,{id:l,as:`p`,variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:u.note}):null,(0,K.jsxs)(T.Footer,{className:`flex-col gap-4 p-0`,children:[(0,K.jsx)(n,{fullWidth:!0,variant:u.destructive?`danger`:`primary`,onClick:s,disabled:a,"data-testid":`confirm-package-switch-button`,children:u.confirmLabel}),(0,K.jsx)(n,{ref:c,fullWidth:!0,variant:`ghost`,onClick:o,disabled:a,children:`Cancel`})]})]})})}function ar(){let e=s();(0,q.useEffect)(()=>I(()=>{e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:R()}),e.invalidateQueries({queryKey:L()})}),[e])}export{ln as A,mn as C,rn as D,on as E,qe as F,Ge as I,ze as L,ct as M,st as N,un as O,$ as P,vn as S,fn as T,Tn as _,Un as a,Dn as b,An as c,In as d,Fn as f,Cn as g,wn as h,Jn as i,nn as j,an as k,Nn as l,kn as m,ir as n,Rn as o,Pn as p,Yn as r,Ln as s,ar as t,jn as u,En as v,hn as w,yn as x,Sn as y};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{n as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{c as a,g as o,n as s}from"./QueryClientProvider-CMu7CkQU.js";import{t as c}from"./useQuery-Bz-fbQ-m.js";import{t as l}from"./useMutation-CXGTrp4W.js";import{t as u}from"./jsx-runtime-D3ZM-ToX.js";import{t as d}from"./typography-DEI9Ra9z.js";import{t as f}from"./createLucideIcon-CAM1RhH8.js";import{t as p}from"./arrow-right-ChqGeAaW.js";import{t as m}from"./check-Dt2rQhdg.js";import{t as h}from"./circle-alert-DQMH8VJH.js";import{t as g}from"./circle-check-DvrCdroD.js";import{t as _}from"./coins-CcTuNVlN.js";import{n as v,t as y}from"./sliders-horizontal-BwdOIxz8.js";import{t as b}from"./hard-drive-sI2ZzmqM.js";import{t as x}from"./info-DkhVkzmK.js";import{t as S}from"./loader-circle-DWWXcfTQ.js";import{t as C}from"./triangle-alert-D6bAGtMw.js";import{t as w}from"./notice-Dslxs3H6.js";import{t as T}from"./modal-xr_vw1ZO.js";import{n as E}from"./toast-BtFgiPe3.js";import{t as ee}from"./confirm-dialog-j9o2h3xs.js";import{t as D}from"./dropdown-B3FHWc_n.js";import{n as O}from"./resolved-assistants-store-C6oDdTxB.js";import{at as k,d as A,f as j,l as te,tt as M,u as N}from"./auth-store-C9aYqB9U.js";import{S as ne,b as re}from"./native-biometric-DetUqtjl.js";import{d as ie}from"./routes-DrfnNoYS.js";import{d as P}from"./platform-detection-AHYibqOx.js";import{n as F}from"./use-assistant-avatar-Bjqx8JUy.js";import{r as ae}from"./use-is-org-ready-3vHDbj4G.js";import{n as oe,r as I}from"./browser-CcdNg0HN.js";import{$ as se,C as ce,O as le,at as ue,c as de,ct as L,et as R,it as fe,jt as z,l as pe,lt as me,nt as he,ot as ge,r as _e,rt as ve,st as ye,tt as be,ut as B,y as xe}from"./react-query.gen-BtYBixpk.js";import{t as V}from"./avatar-bundled-components-BvKt7I7O.js";import{r as Se}from"./use-avatar-accent-var-BafXGBXW.js";import{t as H}from"./misc-BBsGq1IU.js";import{n as Ce,t as we}from"./avatar-tone-D99t9DAP.js";import{t as Te}from"./chat-avatar-B5fx9Xm3.js";import{t as Ee}from"./avatar-renderer-TpNgmnU1.js";import{n as U}from"./use-bundled-avatar-components-BcyasJwu.js";import{t as De}from"./android-consumption-only-D3L1Nc41.js";import{c as Oe,i as W,l as ke,n as G,r as Ae,t as je}from"./machine-sizes-B9nt_h-U.js";import{a as Me,i as Ne,n as Pe,r as Fe,t as Ie}from"./provisioning-targets-Cah9jNBe.js";import{t as Le}from"./environment-store-DxX3xxt2.js";var Re=f(`computer`,[[`rect`,{width:`14`,height:`8`,x:`5`,y:`2`,rx:`2`,key:`wc9tft`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6 18h2`,key:`rwmk9e`}],[`path`,{d:`M12 18h6`,key:`aqd8w3`}]]),K=u();function ze({children:e,redirectToBilling:t=!1}){return P()?t?(0,K.jsx)(r,{replace:!0,to:ie.settings.usageBilling}):(0,K.jsx)(w,{tone:`info`,children:De}):e}var q=e(t(),1);function Be({icon:e}){return(0,K.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-negative-strong) 12%, transparent)`},children:(0,K.jsx)(e,{className:`h-5 w-5`,style:{color:`var(--system-negative-strong)`},"aria-hidden":`true`})})}var J={fontFamily:`var(--font-serif)`,fontSize:`32px`,fontWeight:400,lineHeight:1.2,letterSpacing:`0.64px`};function Y({title:e,subtitle:t}){return(0,K.jsxs)(`header`,{className:`flex flex-col items-center gap-2 pt-12 text-center`,children:[(0,K.jsx)(`h2`,{className:`text-[var(--content-emphasised)]`,style:J,children:e}),t&&(0,K.jsx)(`p`,{className:`text-[14px] font-normal text-[var(--content-secondary)]`,children:t})]})}var Ve=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1},{bodyShape:`stack`,eyeStyle:`gentle`,color:`purple`,size:110,position:`-left-[39px] top-[74%]`,rotate:0},{bodyShape:`urchin`,eyeStyle:`goofy`,color:`pink`,size:137,position:`-right-[42px] -bottom-[40px]`,rotate:180},{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`,size:72,position:`left-[37%] -bottom-[22px] -translate-x-1/2`,rotate:0}],He=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1}];function Ue({variant:e=`full`}){let t=U();return t?(0,K.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`creature-corners`,className:`pointer-events-none absolute inset-0 select-none`,children:(e===`top`?He:Ve).map((e,n)=>(0,K.jsx)(`span`,{className:`absolute ${e.position}`,style:{rotate:`${e.rotate}deg`},children:(0,K.jsx)(Ee,{components:t,bodyShapeId:e.bodyShape,eyeStyleId:e.eyeStyle,colorId:e.color,size:e.size})},n))}):null}var X={waitingStatus:`Upgrading your assistant…`,snagStatus:`We hit a snag upgrading your assistant`,snagCaption:`Retry in the background and we'll keep working on your upgrade.`,confirmingStatus:`Confirming your upgrade…`,confirmTimeoutStatus:`Still confirming your upgrade`,confirmTimeoutCaption:`Your payment went through safely. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still upgrading. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your upgrade continues in the background.`,backgroundRetryToast:`We'll retry your upgrade in the background.`,completeSubtitle:`Enjoy the new found power.`,fetchErrorBody:`We hit a problem checking your subscription. Your upgrade may still be processing. Return to billing to refresh.`},Z={waitingStatus:`Updating your assistant…`,snagStatus:`We hit a snag updating your assistant`,snagCaption:`Retry in the background and we'll keep working on your plan change.`,confirmingStatus:`Confirming your plan change…`,confirmTimeoutStatus:`Still confirming your plan change`,confirmTimeoutCaption:`Your plan change was submitted. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still updating. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your plan change continues in the background.`,backgroundRetryToast:`We'll retry your plan change in the background.`,completeSubtitle:`Your plan changes are live.`,fetchErrorBody:`We hit a problem checking your subscription. Your plan change may still be processing. Return to billing to refresh.`},Q={upgrade:X,downgrade:Z,change:Z};function We(e=`upgrade`){return Q[e]}function Ge(e,t=!0){let{data:n}=c({..._e(),enabled:t&&e==null}),{data:r}=c({...le({path:{id:e??``}}),enabled:t&&e!=null});return e==null?n:r}function Ke({assistantId:e,direction:t}){let r=i(),a=Ge(e,ae())?.name||`your assistant`;return(0,K.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 pb-16 [animation:onboarding-step-in_350ms_ease-out] motion-reduce:[animation:none]`,children:[(0,K.jsx)(Ue,{variant:`full`}),(0,K.jsxs)(`div`,{className:`relative flex w-full flex-col items-center`,children:[(0,K.jsx)(Y,{title:`You're all set!`,subtitle:We(t).completeSubtitle}),(0,K.jsx)(`div`,{className:`mt-10 flex w-full flex-col items-center gap-10`,children:(0,K.jsxs)(n,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>{e!=null&&M(e),r(ie.assistant,{replace:!0})},children:[`Return to `,a]})})]})]})}function qe(e=!0,t){let n=Ge(t,e),r=t??n?.id,{data:i,isError:a,isFetching:o,dataUpdatedAt:s,errorUpdatedAt:l}=c({...de({path:{assistant_id:r??``}}),enabled:e&&!!r});return{assistant:n,assistantId:r,domains:i,domainsError:a,domainsFetching:o,domainsUpdatedAt:s,domainsErrorUpdatedAt:l}}var Je=1e3,Ye=1e4,Xe=2500,Ze=2e3,Qe=1e4,$e=[`machine_size`,`subdomain`,`non_field_errors`],et={subdomain_taken:`That subdomain is already taken. Try another.`,assistant_already_has_domain:`Your assistant already has a custom domain.`,no_assistant_to_attach_domain:`We couldn't find an assistant to attach this domain to.`,exceeds_machine_tier:`That machine size isn't available on your plan.`,provisioning_submission_failed:`We couldn't queue your upgrade just now. Try again in a moment.`,no_active_pro:`We couldn't confirm your Pro plan yet. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to upgrade yet. Try again in a moment.`},tt={provisioning_submission_failed:`We couldn't queue your plan change just now. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to update yet. Try again in a moment.`};function nt(e,t,n=`upgrade`){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=(n===`upgrade`?void 0:tt[t.error])??et[t.error];if(e)return e}for(let e of $e){let n=t[e];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(typeof t.detail==`string`)return t.detail}return t}var rt=`h-8 rounded-lg border border-[var(--border-element)] bg-[var(--field-bg)] px-2.5 text-[14px] text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none transition-[border-color] duration-150 focus:border-[var(--border-active)] disabled:cursor-not-allowed disabled:opacity-60`,it=`text-[11px] font-medium text-[var(--content-secondary)]`;function at({onExit:e,machineBusy:t=!1,assistantId:r}){let i=s(),a=Le.use.emailRootDomain(),{assistant:o,assistantId:c,domains:u}=qe(!0,r),d=u?.results[0],[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(`hi`),[g,_]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!g){if(d){p(d.subdomain),_(!0);return}!o?.handle||f||(p(o.handle),_(!0))}},[o?.handle,d,g,f]);let[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(!1),S=l(ue()),C=!!d||b,E=S.isPending||b;return(0,q.useEffect)(()=>{if(!b)return;let t=setTimeout(e,800);return()=>clearTimeout(t)},[b,e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(T.Body,{className:`animate-[onboarding-step-in_350ms_ease-out] space-y-6 pb-0 motion-reduce:animate-none`,children:[(0,K.jsx)(Ue,{variant:`top`}),(0,K.jsx)(Y,{title:`Assistant Email`,subtitle:`Set up an email for your assistant.`}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`label`,{htmlFor:`onboarding-email-prefix`,className:it,children:`Prefix`}),(0,K.jsx)(`input`,{id:`onboarding-email-prefix`,value:m,onChange:e=>h(e.target.value.toLowerCase().trim()),disabled:E||C,readOnly:C,placeholder:`hi`,className:`${rt} w-24`})]}),(0,K.jsx)(`span`,{className:`flex h-8 items-center text-[var(--content-secondary)]`,children:`@`}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(`label`,{htmlFor:`onboarding-email-handle`,className:it,children:`Handle (public)`}),(0,K.jsx)(`input`,{id:`onboarding-email-handle`,value:f,onChange:e=>{p(e.target.value.toLowerCase().trim()),v&&y(null)},disabled:E||C,readOnly:C,autoFocus:!0,placeholder:`my-assistant`,"aria-invalid":!!v,className:`${rt} w-full min-w-0`})]}),(0,K.jsxs)(`span`,{className:`flex h-8 shrink-0 items-center text-[14px] text-[var(--content-tertiary)]`,children:[`.`,a]})]}),v&&(0,K.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:v}),C&&(0,K.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`This domain has been set and cannot be changed.`})]}),t&&!C&&(0,K.jsx)(w,{tone:`neutral`,children:`Your assistant is restarting — you can set the domain in a moment.`}),!C&&(0,K.jsx)(w,{tone:`info`,className:`border-transparent bg-[var(--surface-active)]`,children:(0,K.jsx)(`span`,{className:`font-medium text-[var(--content-tertiary)]`,children:`You won't be able to change the handle once set.`})}),b?(0,K.jsx)(w,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,K.jsx)(T.Footer,{className:`items-center pt-6`,children:C?(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:e,children:`Continue`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-domain-skip`,disabled:E,onClick:()=>{E||S.mutate({body:{skipped:!0}},{onSuccess:e,onError:()=>e()})},children:`Skip`}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!f||E||t,onClick:()=>{E||t||!f||S.mutate({body:{subdomain:f,...m?{email_username:m}:{}}},{onSuccess:()=>{y(null),x(!0),i.invalidateQueries({queryKey:xe()}),i.invalidateQueries({queryKey:pe({path:{assistant_id:c??``}})}),i.invalidateQueries({queryKey:L()})},onError:e=>{y(nt(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Next`})]})})]})}function ot({onGoToBilling:e,direction:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,K.jsx)(Be,{icon:h}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(d,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,K.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:We(t).fetchErrorBody})]}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function st(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function $(e){return`${st(e)}/mo`}function ct(e){return`${e>0?`+`:`−`}${st(Math.abs(e))}/mo`}function lt(e){return`${e} GB storage`}function ut(e){return`${st(e*100)} of bundled credits`}function dt(e){let{targets:t,fromSnapshot:n,machineFloor:r,credits:i}=e,a=[];return t.machineSize==null?r!=null&&n.machineSize!=null&&n.machineSize!==r&&a.push({key:`machine`,label:`Machine`,from:W[n.machineSize],to:W[r]}):n.machineSize!==t.machineSize&&a.push({key:`machine`,label:`Machine`,from:n.machineSize==null?void 0:W[n.machineSize],to:W[t.machineSize]}),t.storageGib!=null&&(n.storageGib==null||t.storageGib>n.storageGib)&&a.push({key:`storage`,label:`Storage`,from:n.storageGib==null?void 0:`${n.storageGib} GB`,to:`${t.storageGib} GB`}),i!=null&&a.push({key:`credits`,label:`Credits`,from:i.from,to:i.to}),a}var ft=60,pt=ft*2;function mt({imageUrl:e,animateIn:t=!0}){return(0,K.jsxs)(`div`,{"aria-hidden":!0,"data-testid":`takeover-backdrop`,className:`pointer-events-none absolute inset-0 overflow-hidden${t?` provision-avatar-reveal`:``}`,children:[(0,K.jsx)(`img`,{src:e,alt:``,decoding:`async`,draggable:!1,className:`absolute left-1/2 top-1/2 max-w-none -translate-x-1/2 -translate-y-1/2 object-cover object-center`,style:{filter:`blur(${ft}px)`,width:`calc(100% + ${pt*2}px)`,height:`calc(100% + ${pt*2}px)`}}),(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/55`})]})}function ht(e){let t=e?.match(/^credits_(\d+)$/)?.[1];return t==null?null:Number(t)}function gt(e,t){if(t!=null)return e?.credit_tiers?.find(e=>e.tier===t)}function _t(e){let t=ae(),{data:n}=c({...se(),enabled:t&&e});return n?.plans.find(e=>e.id===`pro`)}function vt(e,t){return t==null?0:gt(e,t)?.credits_usd??ht(t)}function yt(e){let t=_t(e!=null);if(e==null||t==null)return null;let n;if(e.kind===`package`){let r=t.packages.find(t=>t.key===e.packageKey);n=r?.credits_usd??gt(t,r?.credit_tier)?.credits_usd}else n=gt(t,e.creditTier)?.credits_usd;return n==null?null:{fromUsd:0,toUsd:n}}function bt(e){let t=_t(e!=null);if(e==null)return null;let n=vt(t,e.fromTier),r=vt(t,e.toTier);return n==null||r==null?null:{fromUsd:n,toUsd:r}}function xt(e){let t=O.use.activeAssistantId(),n=e===void 0?t:e,{components:r,traits:i,customImageUrl:a,isLoading:o}=F(n),s=(0,q.useMemo)(()=>A(),[j()]),c=s!=null&&N(s)?s:null,l=n!=null&&!o,u=c!=null&&(n==null||n===c.assistantId),d=u&&!(l&&(r!=null||i!=null||a!=null))?c:null,f=d?d.components:r,p=d?d.traits:i,m=d?null:a,h=l||u,g=Se(f,p)??(m?null:(f??V).colors?.[0]?.hex??null);return{tintHex:h&&g?Ce(g):we,backdropImageUrl:h?m:null,ready:h,avatar:{components:f,traits:p,customImageUrl:m}}}function St(e,t){let[n,r]=(0,q.useState)(e),i=(0,q.useRef)(0);return(0,q.useEffect)(()=>{i.current=performance.now()},[]),(0,q.useEffect)(()=>{if(t<=0||e===n)return;let a=t-(performance.now()-i.current);if(a<=0){i.current=performance.now(),r(e);return}let o=setTimeout(()=>{i.current=performance.now(),r(e)},a);return()=>clearTimeout(o)},[e,n,t]),t<=0?e:n}var Ct=`--takeover-surface`,wt=`var(${Ct},${we})`,Tt=`color-mix(in srgb, var(--content-emphasised) 10%, transparent)`,Et=240,Dt=1.414,Ot=[{minHeight:680,size:Et},{minHeight:600,size:184}],kt=132;function At(e){for(let t of Ot)if(e>=t.minHeight)return t.size;return kt}function jt(){let[e,t]=(0,q.useState)(()=>At(typeof window>`u`?1/0:window.innerHeight));return(0,q.useEffect)(()=>{let e=()=>t(At(window.innerHeight));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var Mt={machine:v,storage:b,credits:_},Nt={idle:``,working:` is-working`,settling:` is-settling`,stalled:` is-stalled`,grown:` is-evolved`};function Pt(e,t){return e===`DONE`||e===`NOT_APPLICABLE`?`grown`:e===`STALLED`?`stalled`:e===`WAITING`||e===`RESIZING`?t?`settling`:`working`:`idle`}function Ft({assistantId:e,mode:t,downsizing:n=!1}){let{avatar:r,ready:i}=xt(e),a=U(),o=jt(),s=t===`working`||t===`settling`;return(0,K.jsxs)(`div`,{"aria-hidden":!0,className:`provision-avatar-evolve relative z-10 flex flex-col items-center${Nt[i?t:`idle`]}${n?` is-downsizing`:``}`,style:{"--provision-avatar-size":`${o}px`,"--provision-avatar-growth":Dt},children:[(0,K.jsxs)(`div`,{className:`provision-avatar-stage`,children:[(0,K.jsx)(`div`,{"data-testid":`provision-avatar-placeholder`,className:`provision-avatar-placeholder${i?` is-resolved`:``}`}),(0,K.jsx)(`div`,{className:`provision-avatar-layer`,children:(0,K.jsx)(`div`,{className:`provision-avatar-current`,children:(0,K.jsx)(`div`,{className:`provision-avatar-strain`,children:i&&(0,K.jsx)(`div`,{className:`provision-avatar-reveal`,children:(0,K.jsx)(Te,{components:r.components??a,traits:r.traits,customImageUrl:r.customImageUrl,size:o,isAssistantBusy:s})})})})})]}),(0,K.jsx)(`div`,{className:`provision-avatar-shadow`})]})}function It({status:e,caption:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,K.jsx)(`h1`,{className:`text-[var(--content-emphasised)]`,style:J,children:e}),t&&(0,K.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`max-w-sm text-[var(--content-secondary)]`,children:t})]})}function Lt({icon:e,label:t,from:n,to:r,done:i=!1,pending:a=!1,testId:o}){let s=null;return i?s=`Complete`:a&&(s=`Pending`),(0,K.jsxs)(`div`,{"data-testid":o,className:`flex min-w-0 flex-auto items-center gap-2 rounded-lg px-2 py-1.5${a?` opacity-70`:``}`,style:{backgroundColor:Tt},children:[(0,K.jsx)(`span`,{className:`hidden h-6 w-6 shrink-0 items-center justify-center min-[420px]:flex`,children:(0,K.jsx)(e,{className:`h-3.5 w-3.5 text-[var(--content-tertiary)]`,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 text-left wrap-anywhere`,children:[(0,K.jsx)(`span`,{className:`text-[12px] font-medium leading-tight text-[var(--content-tertiary)]`,children:t}),(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-[14px] font-medium leading-[18px] text-[var(--content-emphasised)]`,children:[n&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:n}),(0,K.jsx)(`span`,{className:`sr-only`,children:`to`}),(0,K.jsx)(p,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":`true`})]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{children:r}),i?(0,K.jsx)(m,{"data-testid":`chip-check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`,"aria-hidden":`true`}):a&&(0,K.jsx)(S,{"data-testid":`chip-spinner`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--content-tertiary)] motion-reduce:animate-none`,"aria-hidden":`true`})]}),s&&(0,K.jsx)(`span`,{className:`sr-only`,children:s})]})]})]})}function Rt({label:e}){return(0,K.jsx)(`span`,{className:`rounded-lg px-3 py-2 text-[14px] text-[var(--content-emphasised)]`,style:{backgroundColor:Tt},children:e})}function zt({children:e,wide:t=!1,testId:n}){return(0,K.jsx)(`div`,{"data-testid":n,className:`flex w-full ${t?`max-w-2xl`:`max-w-sm`} items-stretch justify-center gap-2`,children:e})}function Bt(e,t){return e===`credits`?!0:t?.[e]===!0}function Vt({intent:e,creditsChange:t,targets:n,fromSnapshot:r,machineFloor:i,landed:a,allDone:o=!1,creditsOnly:s=!1}){let c=yt(e),l=bt(t),u=c??l,d=dt({targets:n,fromSnapshot:r,machineFloor:i,credits:u==null?null:{from:$(u.fromUsd*100),to:$(u.toUsd*100)}}),f=s?d.filter(e=>e.key===`credits`):d,p=f.filter(e=>o||Bt(e.key,a)).map(e=>e.label).join(`, `),[m]=(0,q.useState)(p),h=p===m?``:`${p} complete`;return f.length===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(zt,{testId:`resource-chips`,wide:f.length>=3,children:f.map(e=>{let t=o||Bt(e.key,a);return(0,K.jsx)(Lt,{testId:`chip-${e.key}`,icon:Mt[e.key],label:e.label,from:e.from,to:e.to,done:t,pending:!t},e.key)})}),(0,K.jsx)(`p`,{"aria-live":`polite`,className:`sr-only`,"data-testid":`chip-announcement`,children:h})]})}function Ht({intent:e}){if(e.kind===`package`)return(0,K.jsx)(zt,{children:(0,K.jsx)(Rt,{label:`${e.packageKey.charAt(0).toUpperCase()+e.packageKey.slice(1)} package`})});let t=[e.machineTier,e.storageTier,e.creditTier].filter(e=>e!=null).length;return(0,K.jsxs)(zt,{wide:t>=3,children:[e.machineTier!=null&&(0,K.jsx)(Lt,{icon:v,label:`Machine`,to:G[e.machineTier]??e.machineTier}),e.storageTier!=null&&(0,K.jsx)(Lt,{icon:b,label:`Storage`,to:e.storageTier.toUpperCase()}),e.creditTier!=null&&(0,K.jsx)(Rt,{label:`${e.creditTier.replace(`credits_`,``)} credits`})]})}function Ut({state:e,direction:t,softWaiting:r,intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,celebrating:u,onCelebrationEnd:d,assistantId:f,escapeAvailable:p,onEscape:m,onPhaseChange:h,kickError:g,confirm:_,dwellMs:v=Xe,phaseMinMs:y=900}){let b=We(t),x=(0,q.useRef)(d);(0,q.useEffect)(()=>{x.current=d},[d]);let S=St(e,y),C=S===`DONE`||S===`NOT_APPLICABLE`,w=S===`RESIZING`?`WAITING`:S,T=(0,q.useRef)(h);(0,q.useEffect)(()=>{T.current=h},[h]),(0,q.useEffect)(()=>{T.current?.(S)},[S]);let{tintHex:E,backdropImageUrl:ee}=xt(f),D=u&&C;return(0,q.useEffect)(()=>{if(!D)return;let e=setTimeout(()=>x.current(),v);return()=>clearTimeout(e)},[D,v]),(0,K.jsxs)(`div`,{"data-theme":`dark`,className:`provision-surface-settle relative flex h-full min-h-[420px] w-full flex-col items-center [justify-content:safe_center] gap-10 px-6 py-10 text-center`,style:{[Ct]:E,backgroundColor:wt},children:[ee&&(0,K.jsx)(mt,{imageUrl:ee}),(0,K.jsx)(Ft,{assistantId:f,mode:Pt(S,r),downsizing:t===`downgrade`}),(0,K.jsx)(`div`,{className:`relative z-10 flex min-h-[144px] w-full flex-col items-center gap-8 [animation:onboarding-step-in_420ms_ease-out] motion-reduce:[animation:none]`,children:A()},w)]});function O(e=`Continue in the background`){return p?(0,K.jsx)(n,{variant:`ghost`,"data-testid":`provisioning-escape`,onClick:m,children:e}):null}function k({allDone:e=!1,creditsOnly:t=!1}={}){return(0,K.jsx)(Vt,{intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,allDone:e,creditsOnly:t})}function A(){if(S===`CONFIRMING`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.confirmingStatus,caption:`This might take a couple seconds.`}),i&&(0,K.jsx)(Ht,{intent:i}),O()]});if(S===`WAITING`||S===`RESIZING`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.waitingStatus,caption:r?`Still working — this can take a minute or two.`:`This might take a couple seconds.`}),k(),O()]});if(S===`DONE`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:`All done!`}),k({allDone:!0})]});if(S===`NOT_APPLICABLE`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:`Your plan is ready`}),k({allDone:!0,creditsOnly:!0})]});if(S===`STALLED`){let e=g!=null;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:e?b.snagStatus:`This is taking longer than expected`,caption:e?nt(g,b.snagCaption,t):`This may take a couple of minutes.`}),k(),e?O(`Retry in the background`):O()]})}return S===`CONFIRM_TIMEOUT`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.confirmTimeoutStatus,caption:b.confirmTimeoutCaption}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:_.onGoToBilling,children:`Go to billing`}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:_.onRetry,children:`Try again`})]})]}):null}}function Wt(e){let{planId:t,targets:n,actuals:r,initialActuals:i,resizeOperationInFlight:a,sawOperation:o,msSinceWatchStart:s,confirmExpired:c,serverVerdict:l=null,statusObservedSinceTargetsMet:u=!0,targetsProveNoop:d=!0}=e;if(t!==`pro`)return{state:c?`CONFIRM_TIMEOUT`:`CONFIRMING`,softWaiting:!1};let f=o||a,p=l===`started`||l===`in_progress`,m=o||d&&u;if(!a){let e=p?m:f||l===`already_done`||i!=null&&!Me(n,i);if(Me(n,r)){if(e)return{state:`DONE`,softWaiting:!1};if(!p&&(d||l===`not_applicable`))return{state:`NOT_APPLICABLE`,softWaiting:!1}}else{if(l===`already_done`)return{state:`DONE`,softWaiting:!1};if(l===`not_applicable`)return{state:`NOT_APPLICABLE`,softWaiting:!1}}}return s!=null&&s>=9e4?{state:`STALLED`,softWaiting:!1}:f||l===`started`||l===`in_progress`?{state:`RESIZING`,softWaiting:!1}:{state:`WAITING`,softWaiting:s!=null&&s>=3e4}}var Gt=2e3,Kt=1e3,qt=[`DONE`,`NOT_APPLICABLE`,`CONFIRM_TIMEOUT`],Jt={assistantId:null,machine:null,storage:null};function Yt({open:e,canLowerResources:t=!1,verdictRecheckMs:n=Qe}){let r=s(),i=ae(),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(0),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),[w,T]=(0,q.useState)(null),[E,ee]=(0,q.useState)(Jt),[D,O]=(0,q.useState)(null),[A,j]=(0,q.useState)(!1),te=(0,q.useRef)(!1),M=(0,q.useRef)(!1),N=(0,q.useRef)(0),[ne,re]=(0,q.useState)(!1),[ie,P]=(0,q.useState)(null),[F,oe]=(0,q.useState)(null),[I,se]=(0,q.useState)(null),[ue,de]=(0,q.useState)(()=>Date.now()),[R,fe]=(0,q.useState)(!0);(0,q.useEffect)(()=>{e||(d(!1),p(0),h(null),_(null),y(null),re(!1),P(null),oe(null),se(null),fe(!0),x(null),C(null),T(null),ee(Jt),O(null),j(!1),te.current=!1,M.current=!1,N.current+=1)},[e]),(0,q.useEffect)(()=>{e&&(h(Date.now()),r.invalidateQueries({queryKey:B()}),r.invalidateQueries({queryKey:L()}))},[e,r]);let z=g!=null,pe=c({...me(),refetchInterval:e=>e.state.data?.plan_id===`pro`||u?!1:Je,refetchIntervalInBackground:!1,enabled:e&&i&&!z}),he=(m!=null&&pe.dataUpdatedAt>=m?pe.data?.plan_id:null)??null;(0,q.useEffect)(()=>{if(!e||z||he!==`pro`)return;let t=Date.now();_(t),de(t)},[e,z,he]),(0,q.useEffect)(()=>{if(!e||z)return;let t=setTimeout(()=>d(!0),Ye);return()=>clearTimeout(t)},[e,z,f]);let ve=(0,q.useCallback)(()=>{d(!1),p(e=>e+1),k.getState().fetchOrganizations(),r.invalidateQueries({queryKey:B()})},[r]),be=(0,q.useCallback)(()=>{let e=Date.now();y(e),de(e)},[]),{mutate:xe}=l(ge()),V=(0,q.useCallback)(e=>{let t=N.current;xe({},{onSuccess:n=>{t===N.current&&(O(null),Pe(n)?M.current?O({error:n.reason??`no_active_pro`}):(M.current=!0,j(!0),e===`escape`&&be()):(x(n.state),e===`escape`&&be()))},onError:e=>{t===N.current&&O(e)}})},[xe,be]);(0,q.useEffect)(()=>{!e||!i||!z||te.current||(te.current=!0,V(`auto`))},[e,i,z,V]),(0,q.useEffect)(()=>{if(!A)return;let e=N.current,t=setTimeout(()=>{j(!1),e===N.current&&V(`auto`)},Ze);return()=>clearTimeout(t)},[A,V]);let Se=(0,q.useCallback)(()=>V(`escape`),[V]),H=c({...ye(),enabled:e&&i&&z}),Ce=R?Gt:!1,we=c({..._e(),enabled:e&&i&&z,refetchInterval:e=>e.state.data?.id==null?Ce:!1,retry:!1}),Te=z&&m!=null&&H.dataUpdatedAt>=m,Ee=Te&&!H.isPending&&!H.isFetching,U=(Te?H.data?.primary_assistant_id:null)??(H.isPending?null:we.data?.id??null),De=c({...le({path:{id:U??`unresolved`}}),enabled:e&&i&&z&&U!=null,refetchInterval:Ce,retry:!1}),W=ce({path:{id:U??`unresolved`}}),G=c({...W,enabled:e&&i&&z&&U!=null,refetchInterval:Ce,retry:!1}),Ae=(0,q.useRef)(0),[Le,Re]=(0,q.useState)(0),K=o(W.queryKey);(0,q.useEffect)(()=>r.getQueryCache().subscribe(t=>{if(!(t.type!==`updated`||t.query.queryHash!==K)){if(t.action.type===`fetch`)Ae.current+=1;else if(t.action.type===`success`&&!t.action.manual){let n=Ae.current,r=e&&Fe(t.action.data);a.schedule(()=>{Re(n),r&&(re(!0),P(U))})}}}),[r,K,e,U]);let ze=Fe(G.data),Be=ie===U,J=H.data,Y=(0,q.useMemo)(()=>J?{machineSize:Oe(J.max_machine_tier),storageGib:J.selected_storage_gib??null}:null,[J]),Ve=J!=null&&J.max_machine_tier==null?je:null,He=J?J.domain_setup_available&&J.primary_assistant_id!=null:void 0,Ue=De.data,X=(0,q.useMemo)(()=>Ue?{machineSize:Ue.machine_size??null,storageGib:Ue.provisioned_storage_gib??null}:null,[Ue]),Z=I===U,Q=(0,q.useMemo)(()=>{let e=Ie(Y,X),t=Y?.machineSize??Ve;if(t==null)return e;let n=X?.machineSize??null;if(n==null)return{...e,machine:!1};let r=(Z?F?.machineSize:null)??n,i=ke(t)<ke(r);return{...e,machine:i?ke(n)<=ke(t):ke(n)>=ke(t)}},[Y,X,F,Z,Ve]),We=Me(Y,X),Ge=w===U;(0,q.useEffect)(()=>{e&&(We?(C(e=>e!=null&&Ge?e:Date.now()),T(U)):(C(null),T(null)))},[e,We,U,Ge]);let Ke=E.assistantId===U;(0,q.useEffect)(()=>{if(!e)return;let t=Ae.current;ee(e=>{let n=e.assistantId===U?e:Jt,r=Q.machine?n.machine??t:null,i=Q.storage?n.storage??t:null;return e.assistantId===U&&e.machine===r&&e.storage===i?e:{assistantId:U,machine:r,storage:i}})},[e,Q,U]);let qe=(0,q.useMemo)(()=>{let e=Ne(G.data),t=e=>e!=null&&Ke&&Le>e;return{machine:Q.machine&&!e.machine&&t(E.machine),storage:Q.storage&&!e.storage&&t(E.storage)}},[Q,E,Ke,Le,G.data]);(0,q.useEffect)(()=>{!e||!X||F!=null&&Z||(oe(X),se(U))},[e,X,U,F,Z]);let Xe=v??g,$e=Xe==null?null:Math.max(0,ue-Xe),et=!t,{state:tt,softWaiting:nt}=Wt({planId:z?`pro`:he,targets:Y,actuals:X,initialActuals:Z?F:null,resizeOperationInFlight:ze,sawOperation:ne&&Be,msSinceWatchStart:$e,confirmExpired:u,serverVerdict:b,statusObservedSinceTargetsMet:S!=null&&Ge&&G.dataUpdatedAt>S,targetsProveNoop:et}),rt=qt.includes(tt),it=e&&z&&!rt;(0,q.useEffect)(()=>{fe(it)},[it]),(0,q.useEffect)(()=>{if(!e||!z||rt)return;let t=setInterval(()=>de(Date.now()),Kt);return()=>clearInterval(t)},[e,z,rt]);let at=!et&&(b===`started`||b===`in_progress`)&&!(ne&&Be);return(0,q.useEffect)(()=>{if(!e||!z||rt||!at)return;let t=setInterval(()=>V(`auto`),n);return()=>clearInterval(t)},[e,z,rt,at,n,V]),{state:tt,softWaiting:nt,targets:Y,actualsSnapshot:F,machineFloor:Ve,landed:qe,assistantId:U,domainStepAvailable:He,onboardingSettled:Ee,confirmError:!z&&pe.isError,targetsError:z&&H.isError&&(!J||!Te),escapeEligible:$e!=null&&$e>=6e4,retryConfirm:ve,kickProvisioning:Se,kickError:D}}var Xt=200,Zt=380;function Qt(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0}var $t=e=>e===`WAITING`||e===`RESIZING`||e===`STALLED`,en=e=>e===`DONE`||e===`NOT_APPLICABLE`,tn={machineSize:null,storageGib:null};function nn({open:e,onClose:t,dwellMs:n,phaseMinMs:r,mode:i=`checkout`,resizeContext:a}){let o=i===`resize`,c=s(),[l,u]=(0,q.useState)(`provisioning`),[d,f]=(0,q.useState)(`idle`),p=(0,q.useRef)([]),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(!1),S=o?a?.direction:void 0,C=We(S),w=Yt({open:e,canLowerResources:o?a?.canLowerResources===!0:!1}),D=(0,q.useRef)(!1);(0,q.useEffect)(()=>{if(e){D.current=!0,h(o?null:ne()),y(e=>e??Date.now());return}p.current.forEach(clearTimeout),p.current=[],u(`provisioning`),f(`idle`),_(null),y(null),x(!1),D.current&&(D.current=!1,te())},[e,o]),(0,q.useEffect)(()=>()=>{p.current.forEach(clearTimeout)},[]),(0,q.useEffect)(()=>{l===`complete`&&re()},[l]);let O=$t(w.state),k=en(g??w.state),{targets:A,assistantId:j,domainStepAvailable:M,onboardingSettled:N}=w,ie=o?a?.fromSnapshot:void 0,P=w.actualsSnapshot,F={machineSize:ie?.machineSize??P?.machineSize??null,storageGib:ie?.storageGib??P?.storageGib??null},{tintHex:ae,backdropImageUrl:oe}=xt(j),I=o&&M===!0,{domains:se,domainsError:ce,domainsFetching:le,domainsUpdatedAt:ue,domainsErrorUpdatedAt:de}=qe(e&&I,j),L=(se?.results.length??0)>0,R=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!e){R.current=null;return}!I||j==null||R.current!==j&&(R.current=j,c.invalidateQueries({queryKey:pe({path:{assistant_id:j}})}))},[e,I,j,c]);let fe=!le&&(v!=null&&ue>=v||v!=null&&!!ce&&de>=v),[z,me]=(0,q.useState)(!1),he=N&&(!I||fe);(0,q.useEffect)(()=>{if(!e){me(!1);return}he&&me(!0)},[e,he]);let ge=(0,q.useCallback)(()=>{let e=o?M===!0&&!L?`domain`:`complete`:M===!1?`complete`:`domain`;if(Qt()){u(e);return}f(`covering`),p.current.push(setTimeout(()=>{u(e),f(`revealing`),p.current.push(setTimeout(()=>f(`idle`),Zt))},Xt))},[M,o,L]),_e=(0,q.useCallback)(()=>{x(!0)},[]),ve=(0,q.useCallback)(()=>{w.kickProvisioning(),E.info(w.kickError==null?C.backgroundExitToast:C.backgroundRetryToast),x(!1),t()},[w,t,C]),ye=(0,q.useCallback)(()=>{x(!1)},[]),be=l===`provisioning`&&(w.confirmError||w.targetsError),B=l===`provisioning`&&!be,xe=B&&!k,V=`transition-[background-color] duration-300 ease-out${B?` bg-black p-0`:``}`,Se=B?`[animation:fadeIn_0.45s_ease-out_both]`:d===`revealing`?`[animation:fadeInUp_0.42s_ease-out_0.12s_both]`:`[animation:fadeIn_0.25s_ease-out_both]`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,K.jsxs)(T.Content,{size:`md`,hideCloseButton:l!==`complete`,dismissOnOverlayClick:!xe,onEscapeKeyDown:xe?e=>e.preventDefault():void 0,onInteractOutside:xe?e=>e.preventDefault():void 0,"data-theme":B?`dark`:void 0,overlayClassName:V,className:B?`overflow-y-auto inset-0 max-w-none w-screen h-screen max-h-none rounded-none border-0`:`overflow-hidden`,style:{[Ct]:ae},children:[(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col motion-reduce:[animation:none] ${Se}`,children:H()},l),d!==`idle`&&(0,K.jsx)(`div`,{"aria-hidden":!0,"data-testid":`takeover-exit-sheet`,className:`pointer-events-none fixed inset-0 z-50 ${d===`covering`?`[animation:fadeIn_200ms_ease-in_both]`:`[animation:fadeIn_380ms_ease-out_both_reverse]`}`,style:{backgroundColor:wt},children:oe&&(0,K.jsx)(mt,{imageUrl:oe,animateIn:!1})})]})}),(0,K.jsx)(ee,{open:b&&O,title:`Continue in the background?`,message:C.backgroundConfirmMessage,confirmLabel:`Continue`,cancelLabel:`Keep waiting`,onConfirm:ve,onCancel:ye})]});function H(){return l===`provisioning`?w.confirmError||w.targetsError?(0,K.jsx)(ot,{onGoToBilling:t,direction:S}):(0,K.jsx)(Ut,{state:w.state,direction:S,softWaiting:w.softWaiting,intent:m,creditsChange:o?a?.credits:void 0,targets:A??tn,fromSnapshot:F,machineFloor:w.machineFloor,landed:w.landed,celebrating:z,onCelebrationEnd:ge,assistantId:j,escapeAvailable:O&&w.escapeEligible,onEscape:_e,onPhaseChange:_,kickError:w.kickError,confirm:{onRetry:w.retryConfirm,onGoToBilling:t},dwellMs:n,phaseMinMs:r}):l===`domain`?(0,K.jsx)(at,{machineBusy:O,assistantId:j,onExit:()=>u(`complete`)}):(0,K.jsx)(Ke,{assistantId:j,direction:S})}}function rn(e){return e!=null&&!e.customized}function an(e){return rn(e)?e.name:`Custom`}var on=[`mighty`,`super`,`ultra`],sn=[`free`,...on];function cn(e){return sn.indexOf(e)}function ln(e,t){if(e===null)return`upgrade`;let n=cn(e),r=cn(t);return n===-1||r===-1?`upgrade`:r===n?`current`:r<n?`downgrade`:`upgrade`}function un(e,t){if(e.length===0)return null;let n=[...e].sort((e,t)=>on.indexOf(e.key)-on.indexOf(t.key));if(!t)return n[0];let r=n.findIndex(e=>e.key===t);return r===-1?n[0]:r>=n.length-1?null:n[r+1]}var dn={free:{bodyShape:`ninja`,eyeStyle:`angry`,color:`yellow`},mighty:{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`},super:{bodyShape:`urchin`,eyeStyle:`goofy`,color:`teal`},ultra:{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`}};function fn({tier:e,size:t=40}){let n=dn[e]??dn.free,r=U();return(0,K.jsx)(`div`,{"aria-hidden":!0,className:`inline-flex shrink-0`,children:r?(0,K.jsx)(Ee,{components:r,bodyShapeId:n.bodyShape,colorId:n.color,size:t}):(0,K.jsx)(`div`,{style:{width:t,height:t}})})}var pn=`Small`;function mn(e){return e?.machine_size?W[e.machine_size]??e.machine_size:pn}function hn(e){let t=e?.credits_usd??0,n=e?.storage_gib??4;return[{icon:Re,label:`${mn(e)} Machine`},{icon:_,label:`${st(t*100)} credits`},{icon:b,label:`${n} GB`}]}function gn(e,t=[]){let n=e?.credits_usd??0,r=e?.storage_gib??4,i=Ae[e?.machine_size??`small`];return[`${mn(e)} machine${i?` (${i})`:``}`,lt(r),ut(n),...t]}var _n={machine:`Configurable machine size`,storage:`Configurable storage`,credits:`Pay-as-you-go and bundled credits`};function vn(e,t){let n=[`${e.machineTier?G[e.machineTier]??t.machine_tiers.find(t=>t.tier===e.machineTier)?.label??e.machineTier:pn} Machine`];if(e.storageGib!=null&&n.push(`${e.storageGib} GB`),e.creditTier!=null){let r=gt(t,e.creditTier)?.credits_usd??ht(e.creditTier);n.push(r==null?`Credit bundle`:`${r} credits/mo`)}return n}function yn(e,t){let n=new Set([_n.machine]);return e.storageGib!=null&&n.add(_n.storage),e.creditTier!=null&&n.add(_n.credits),[...vn(e,t),...t.included_features.filter(e=>!n.has(e))]}var bn=`billing-portal-return-snapshot`;function xn(e){try{sessionStorage.removeItem(bn),sessionStorage.setItem(bn,JSON.stringify(e))}catch{}}function Sn(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(bn);if(!e)return null;let t=JSON.parse(e);return typeof t.cancel_at_period_end!=`boolean`||typeof t.plan_id!=`string`?null:{cancel_at_period_end:t.cancel_at_period_end,cancel_at:t.cancel_at??null,plan_id:t.plan_id}}catch{return null}}function Cn(){try{sessionStorage.removeItem(bn)}catch{}}function wn(e){return e?{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at??null,plan_id:e.plan_id}:null}function Tn(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function En(e){return e?e.cancel_at??e.current_period_end??null:null}function Dn(e){let t=s();return(0,q.useEffect)(()=>I(()=>{t.invalidateQueries(me())}),[t]),z({onSuccess:t=>{e&&xn(e),oe(t.portal_url)},onError:()=>{E.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function On(e){return e.disabled===!0}function kn({machineTiers:e,storageTiers:t,selectedMachineTier:n,selectedStorageTier:r,onMachineTierChange:i,onStorageTierChange:a,currentMachinePriceCents:o,currentStoragePriceCents:s}){let c=(0,q.useMemo)(()=>e.map(e=>{let t=G[e.tier]??e.label,n=o==null?`+${$(e.price_cents)}`:e.price_cents===o?`(${$(e.price_cents)}, current)`:ct(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:On(e)}}),[e,o]),l=(0,q.useMemo)(()=>t.map(e=>{let t=s==null?`+${$(e.price_cents)}`:e.price_cents===s?`(${$(e.price_cents)}, current)`:ct(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GB ${t}`,disabled:On(e)}}),[t,s]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,K.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,K.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(D,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,K.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,K.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(D,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var An=new Set([`active`,`trialing`,`past_due`]);function jn(e){return e.plan_id!==`base`&&e.cancel_at_period_end!==!0&&!e.cancel_at&&e.status!=null&&An.has(e.status)}var Mn=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`package`,`non_field_errors`];function Nn(e,t){if(e&&typeof e==`object`){for(let t of Mn)if(t in e){let n=e[t];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(`detail`in e&&typeof e.detail==`string`)return e.detail}return t}function Pn(e,t){let n=e.filter(e=>!On(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Fn(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function In(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Ln(){let e=s(),t=l(ve());return{changePackage:async n=>{try{let r=await t.mutateAsync({body:{package:n}});return await Promise.all([e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:R()}),e.invalidateQueries({queryKey:L()})]),r}catch(e){return E.error(Nn(e,`Failed to change your plan. Please try again.`)),null}},isPending:t.isPending}}function Rn({enabled:e=!0}={}){let t=s(),n=ae(),r=e&&n,i=c({...me(),enabled:r}),a=i.data,o=a!=null&&a.plan_id!==`base`,u=c({...ye(),enabled:r&&o}),d=c({...se(),enabled:r&&o}).data?.plans.find(e=>e.id===`pro`)?.machine_tiers??[],f=e=>d.find(t=>t.tier===e)?.price_cents??null,p=l(he()),m=l(fe()),h=l(be()),g={machineTier:u.data?.max_machine_tier??null,storageTier:u.data?.selected_storage_tier??null,storageGib:u.data?.selected_storage_gib??null,creditTier:a?.selected_credit_tier??null},_=a!=null&&a.plan_id!==`base`&&a.status!=null&&An.has(a.status)&&a.cancel_at_period_end!==!0&&!a.cancel_at,v=!o||!u.isPending,y=!o||u.isSuccess&&u.data!=null&&!u.isFetching&&u.dataUpdatedAt>=i.dataUpdatedAt,b=p.isPending||m.isPending||h.isPending,x=()=>Promise.all([t.invalidateQueries({queryKey:B()}),t.invalidateQueries({queryKey:L()}),t.invalidateQueries({queryKey:R()})]);return{changeTiers:async e=>{let t=e.machineTier!==g.machineTier,n=e.storageTier!==g.storageTier,r=e.creditTier!==g.creditTier,i=f(e.machineTier),a=f(g.machineTier),o=t&&i!=null&&a!=null&&i<a,s=[];if(t&&s.push(new Promise(t=>{p.mutate({body:{machine_tier:e.machineTier}},{onSuccess:()=>t({dimension:`machine`,ok:!0}),onError:e=>t({dimension:`machine`,ok:!1,error:e})})})),n&&s.push(new Promise(t=>{m.mutate({body:{storage_tier:e.storageTier}},{onSuccess:()=>t({dimension:`storage`,ok:!0}),onError:e=>t({dimension:`storage`,ok:!1,error:e})})})),r&&s.push(new Promise(t=>{h.mutate({body:{credit_tier:e.creditTier}},{onSuccess:()=>t({dimension:`credit`,ok:!0}),onError:e=>t({dimension:`credit`,ok:!1,error:e})})})),s.length===0)return{needsResize:!1,creditChanged:!1};let c=await Promise.all(s);await x();let l=c.some(e=>e.ok&&e.dimension===`machine`)&&!o,u=c.some(e=>e.ok&&e.dimension===`storage`),d=l||u,_=c.some(e=>e.ok&&e.dimension===`credit`),v=c.filter(e=>!e.ok);if(v.length>0){let e=v.map(e=>Nn(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);return E.error(e),d||_?{needsResize:d,creditChanged:_}:null}return{needsResize:d,creditChanged:_}},isPending:b,current:g,eligible:_,currentReady:v,currentKnown:y,primaryAssistantId:y?u.data?.primary_assistant_id??null:null}}var zn=`__none__`,Bn=`No extra credits`;function Vn(e){let{proPlan:t,seed:n,machineTier:r,storageTier:i,creditChoice:a}=e,o=t.machine_tiers,s=t.storage_tiers,c=t.credit_tiers??[],l=o.find(e=>e.tier===r)??null,u=s.find(e=>e.tier===i)??null,d=a&&a!==`__none__`?c.find(e=>e.tier===a)??null:null,f=n==null?null:o.find(e=>e.tier===n.machineTier)??null,p=n==null?null:s.find(e=>e.tier===n.storageTier)??null,m=n!=null&&n.creditTier!=null?c.find(e=>e.tier===n.creditTier)??null:null,h=n!=null&&n.machineTier!=null&&f==null,g=n!=null&&p==null,_=[{key:`base`,label:`Platform fee: ${$(t.base_price_cents)}`,changed:!1}];if(l!=null){let e=n!=null&&!h&&f?.tier!==l.tier;_.push({key:`machine`,label:l.description,previousLabel:e&&f!=null?f.description:void 0,changed:e})}if(u!=null){let e=n!=null&&!g&&p?.tier!==u.tier;_.push({key:`storage`,label:lt(u.storage_gib),previousLabel:e&&p!=null?lt(p.storage_gib):void 0,changed:e})}let v=a===`__none__`?Bn:d==null?null:ut(d.credits_usd);if(v!=null){let e=n!=null&&(n.creditTier??`__none__`)!==a,t=n?.creditTier==null?Bn:m==null?void 0:ut(m.credits_usd);_.push({key:`credit`,label:v,previousLabel:e?t:void 0,changed:e})}let y=t.base_price_cents+(l?.price_cents??0)+(u?.price_cents??0)+(d?.price_cents??0),b=h||g||n!=null&&n.creditTier!=null&&m==null;if(n==null||b)return{totalCents:y,previousTotalCents:null,deltaCents:null,rows:_};let x=t.base_price_cents+(f?.price_cents??0)+(p?.price_cents??0)+(m?.price_cents??0);return{totalCents:y,previousTotalCents:x,deltaCents:y-x,rows:_}}function Hn(e){return(0,K.jsxs)(`span`,{className:`text-[12px] font-medium text-[var(--content-disabled)]`,children:[`+`,$(e)]})}function Un({open:e,proPlan:t,pending:r,currentStorageGib:i,initialSelection:a,onClose:o,onContinue:s}){let c=e?a??null:null,[l,u]=(0,q.useState)(()=>c?.machineTier??``),[d,f]=(0,q.useState)(()=>c?.storageTier??``),[p,m]=(0,q.useState)(()=>c?c.creditTier??`__none__`:``),[h,v]=(0,q.useState)({open:e,initialSelection:a});(h.open!==e||h.initialSelection!==a)&&(v({open:e,initialSelection:a}),u(c?.machineTier??``),f(c?.storageTier??``),m(c?c.creditTier??`__none__`:``));let x=t.machine_tiers,S=(0,q.useMemo)(()=>t.storage_tiers.filter(e=>!e.legacy||e.tier===a?.storageTier),[t.storage_tiers,a?.storageTier]),C=t.credit_tiers??[],w=(0,q.useMemo)(()=>(t.credit_tiers??[]).filter(e=>!e.legacy),[t.credit_tiers]),E=e=>On(e)||e.legacy&&e.tier!==a?.storageTier||i!=null&&e.storage_gib<i,ee=x.map(e=>({value:e.tier,label:e.description,icon:(0,K.jsx)(Re,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:On(e)})),O=S.map(e=>({value:e.tier,label:e.label,icon:(0,K.jsx)(b,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:E(e)})),k=p&&p!==`__none__`?C.find(e=>e.tier===p)??null:null,A=k?.legacy?k:null,j=[{value:zn,label:Bn,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0})},...w.map(e=>({value:e.tier,label:e.label,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents)})),...A?[{value:A.tier,label:A.label,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(A.price_cents),disabled:!0}]:[]],te=x.find(e=>e.tier===l)??null,M=d!==``&&d===a?.storageTier,N=S.find(e=>e.tier===d&&(M||!E(e)))??null,ne=p===`__none__`||p===a?.creditTier||w.some(e=>e.tier===p),re=p!==``&&ne?p:null,ie=te!=null&&N!=null&&re!=null,P=a!=null&&l===(a.machineTier??``)&&d===a.storageTier&&p===(a.creditTier??`__none__`),F=(0,q.useMemo)(()=>Vn({proPlan:t,seed:a??null,machineTier:l,storageTier:d,creditChoice:p}),[t,a,l,d,p]);return(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{e||o()},children:(0,K.jsx)(T.Content,{size:`lg`,"data-theme":`light`,hideCloseButton:!0,overlayClassName:`backdrop-blur-[2px]`,className:`max-w-[820px] md:min-h-[min(608px,calc(100vh-4rem))]`,children:(0,K.jsx)(T.Body,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-8 md:flex-row md:gap-12`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6 md:flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`flex shrink-0 items-center justify-center rounded-xl bg-[var(--surface-active)] p-[14px]`,children:(0,K.jsx)(y,{className:`h-6 w-6 text-[var(--content-emphasised)]`,"aria-hidden":!0})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,K.jsx)(T.Title,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Create a custom plan`}),(0,K.jsx)(T.Description,{className:`mt-0 text-[14px] font-medium leading-[18px] text-[var(--content-tertiary)]`,children:`Just better.`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select a machine size:`}),(0,K.jsx)(D,{"aria-label":`Machine size`,placeholder:`Select a machine size`,value:l,onChange:u,options:ee})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select storage:`}),(0,K.jsx)(D,{"aria-label":`Storage`,placeholder:`Select storage`,value:d,onChange:f,options:O})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Bundle some credits:`}),(0,K.jsx)(D,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,value:p,onChange:m,options:j})]})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-16 md:pt-[5px]`,children:[(0,K.jsx)(`span`,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Recap`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[24px] font-medium text-[var(--content-default)]`,children:$(F.totalCents)}),F.deltaCents!=null&&F.deltaCents!==0&&F.previousTotalCents!=null&&(0,K.jsxs)(`span`,{className:`text-[12px] font-medium ${F.deltaCents>0?`text-[var(--system-positive-strong)]`:`text-[var(--system-negative-strong)]`}`,children:[ct(F.deltaCents),` compared to previous (`,st(F.previousTotalCents),`)`]}),(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-tertiary)]`,children:`Total`})]}),(0,K.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,K.jsx)(`span`,{className:`text-[12px] font-medium text-[var(--content-tertiary)]`,children:`Your selection:`}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:F.rows.map(e=>(0,K.jsxs)(`li`,{className:`flex flex-col gap-2`,children:[e.previousLabel!=null&&(0,K.jsxs)(`div`,{className:`relative flex w-fit items-start gap-2`,children:[(0,K.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-disabled)]`,"aria-hidden":!0}),(0,K.jsx)(`s`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-disabled)] no-underline`,children:e.previousLabel}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute -left-1 right-0 top-[9px] h-px bg-[var(--content-disabled)]`})]}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 ${e.changed?`text-[var(--system-positive-strong)]`:`text-[var(--content-secondary)]`}`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-secondary)]`,children:e.label})]})]},e.key))}),(0,K.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:!ie||P||r,onClick:()=>{!ie||P||r||s({machineTier:te.tier,storageTier:N.tier,creditTier:re===`__none__`?null:re})},children:`Continue`}),(0,K.jsx)(n,{variant:`ghost`,fullWidth:!0,disabled:r,onClick:o,children:`Cancel`})]})]})]})})})})}function Wn({className:e,"data-testid":t,children:n}){return(0,K.jsx)(`div`,{"aria-hidden":!0,"data-testid":t,className:H(`flex size-[52px] shrink-0 items-center justify-center rounded-xl`,e),children:n})}var Gn=32;function Kn(){let{ready:e,avatar:t}=xt();return(0,K.jsx)(Wn,{"data-testid":`assistant-avatar-tile`,className:`bg-[var(--surface-active)]`,children:e?(0,K.jsx)(Te,{components:t.components,traits:t.traits,customImageUrl:t.customImageUrl,size:Gn}):null})}var qn={free:{tagline:`Get to know your assistant.`,cta:`Start Free`,priceCaption:`Forever`},mighty:{tagline:`More capacity for consistent use.`,cta:`Power Up`,priceCaption:`Billed monthly`,recommended:!0},super:{tagline:`Do more, think less about the how.`,cta:`Go Super`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]},ultra:{tagline:`Your second brain, running full speed.`,cta:`Unleash Ultra`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]}};function Jn(e){return qn[e]}function Yn(e){return`Downgrade to ${e}`}var Xn=`Billed monthly · prorated difference charged today`,Zn=`Billed monthly · prorated difference charged today or credited next invoice`,Qn=`Billed monthly · prorated credit on your next invoice`,$n=`Your machine downsizes now and your storage stays. No refund.`,er=`Continue`,tr=`The plan includes`,nr=`Your plan will include`;function rr(e,t,n){let r=n?Jn(n)?.tagline??``:``;switch(e){case`downgrade`:return{title:Yn(t),subtitle:``,priceCaption:Qn,checklistHeading:nr,note:$n,confirmLabel:Yn(t),destructive:!0};case`switch`:return{title:`Switch to ${t}`,subtitle:r,priceCaption:Zn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1};default:return{title:`Upgrade to ${t}`,subtitle:r,priceCaption:Xn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1}}}function ir({open:e,relation:t,packageName:r,targetPackage:i,pending:a,onCancel:o,onConfirm:s}){let c=(0,q.useRef)(null),l=(0,q.useId)(),u=rr(t,r,i?.key??null),f=i?{price:$(i.total_price_cents),highlights:gn(i,Jn(i.key)?.extraFeatures??[])}:null,p=u.subtitle,m=u.note?{"aria-describedby":l}:p?{}:{"aria-describedby":void 0};return(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{!e&&!a&&o()},children:(0,K.jsxs)(T.Content,{size:`sm`,hideCloseButton:!0,className:`gap-4 p-4 max-w-[421px]`,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus()},...m,children:[(0,K.jsxs)(T.Header,{className:`flex-row items-center gap-3 p-0 pb-2`,children:[u.destructive?(0,K.jsx)(Wn,{"data-testid":`package-switch-warning-tile`,className:`bg-[var(--system-negative-weak)]`,children:(0,K.jsx)(C,{className:`size-6 text-[var(--system-negative-strong)]`})}):(0,K.jsx)(Kn,{}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(T.Title,{className:`text-title-small text-[var(--content-emphasised)] [&>span]:whitespace-normal`,children:u.title}),p?(0,K.jsx)(T.Description,{className:`mt-0 text-body-medium-default text-[var(--content-tertiary)]`,children:p}):null]})]}),f?(0,K.jsxs)(T.Body,{className:`flex flex-col gap-4 p-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsx)(d,{as:`p`,variant:`title-large`,className:`text-[var(--content-default)]`,children:f.price}),(0,K.jsx)(d,{as:`p`,variant:`label-medium-default`,className:`leading-[15px] text-[var(--content-tertiary)]`,children:u.priceCaption})]}),(0,K.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,K.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:u.checklistHeading}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:f.highlights.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(g,{className:`size-4 shrink-0 text-[var(--content-secondary)]`,"aria-hidden":!0}),(0,K.jsx)(d,{as:`span`,variant:`body-medium-default`,className:`text-[var(--content-default)]`,children:e})]},e))})]}):null,u.note?(0,K.jsx)(d,{id:l,as:`p`,variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:u.note}):null,(0,K.jsxs)(T.Footer,{className:`flex-col gap-4 p-0`,children:[(0,K.jsx)(n,{fullWidth:!0,variant:u.destructive?`danger`:`primary`,onClick:s,disabled:a,"data-testid":`confirm-package-switch-button`,children:u.confirmLabel}),(0,K.jsx)(n,{ref:c,fullWidth:!0,variant:`ghost`,onClick:o,disabled:a,children:`Cancel`})]})]})})}function ar(){let e=s();(0,q.useEffect)(()=>I(()=>{e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:R()}),e.invalidateQueries({queryKey:L()})}),[e])}export{ln as A,mn as C,rn as D,on as E,qe as F,Ge as I,ze as L,ct as M,st as N,un as O,$ as P,vn as S,fn as T,Tn as _,Un as a,Dn as b,An as c,In as d,Fn as f,Cn as g,wn as h,Jn as i,nn as j,an as k,Nn as l,kn as m,ir as n,Rn as o,Pn as p,Yn as r,Ln as s,ar as t,jn as u,En as v,hn as w,yn as x,Sn as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n}from"./QueryClientProvider-CMu7CkQU.js";import{t as r}from"./useQuery-Bz-fbQ-m.js";import{t as i}from"./createLucideIcon-CAM1RhH8.js";import{t as a}from"./calendar-qrPKlf1H.js";import{t as o}from"./globe-CdLn4IX7.js";import{t as s}from"./layout-grid-Ct4RT2Ea.js";import{t as c}from"./message-square-CHUvAEY9.js";import{t as l}from"./monitor-RX4oi4Nj.js";import{t as u}from"./settings-6_RIT4kT.js";import{n as d,t as f}from"./create-selectors-BfxF8Sx_.js";import{dt as p,f as m,h,r as g}from"./local-mode-DHueA-BJ.js";import{t as _}from"./is-electron-DIlIrdJX.js";import{n as v}from"./resolved-assistants-store-C6oDdTxB.js";import{i as y}from"./utils-DtVy-_pB.js";import{i as b,n as x}from"./api-errors-BRGPPSWw.js";import{lt as S,mt as C,nt as w,st as T}from"./auth-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n}from"./QueryClientProvider-CMu7CkQU.js";import{t as r}from"./useQuery-Bz-fbQ-m.js";import{t as i}from"./createLucideIcon-CAM1RhH8.js";import{t as a}from"./calendar-qrPKlf1H.js";import{t as o}from"./globe-CdLn4IX7.js";import{t as s}from"./layout-grid-Ct4RT2Ea.js";import{t as c}from"./message-square-CHUvAEY9.js";import{t as l}from"./monitor-RX4oi4Nj.js";import{t as u}from"./settings-6_RIT4kT.js";import{n as d,t as f}from"./create-selectors-BfxF8Sx_.js";import{dt as p,f as m,h,r as g}from"./local-mode-DHueA-BJ.js";import{t as _}from"./is-electron-DIlIrdJX.js";import{n as v}from"./resolved-assistants-store-C6oDdTxB.js";import{i as y}from"./utils-DtVy-_pB.js";import{i as b,n as x}from"./api-errors-BRGPPSWw.js";import{lt as S,mt as C,nt as w,st as T}from"./auth-store-C9aYqB9U.js";import{nt as E}from"./sdk.gen-ies09CqM.js";import{ir as D}from"./sdk.gen-CjtCuSlS.js";import{a as O,i as k,r as A}from"./feature-flag-catalog-CpyCubJW.js";import{t as j}from"./client-feature-flag-store-Cw39NfCq.js";import{d as M}from"./routes-DrfnNoYS.js";import{i as ee,r as N}from"./use-is-org-ready-3vHDbj4G.js";import{t as P}from"./haptics-C4p_Rjba.js";import{F}from"./react-query.gen-BtYBixpk.js";import{s as te}from"./chat-Dy2BC2i1.js";var I=i(`contact`,[[`path`,{d:`M16 2v2`,key:`scm5qe`}],[`path`,{d:`M7 22v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2`,key:`1waht3`}],[`path`,{d:`M8 2v2`,key:`pbkmx`}],[`circle`,{cx:`12`,cy:`11`,r:`3`,key:`itu57m`}],[`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`,key:`12vinp`}]]),L=i(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),R=e(t(),1);function z({sessionStatus:e,hasPlatformSession:t}){let r=n(),i=N(),a=S(e)&&!p()&&(t||!m())&&i;v.use.assistants();let o=w(),s=o&&!g().some(e=>e.assistantId===o)?o:null,{data:c}=C({enabled:a,selectedPlatformAssistantId:s});(0,R.useEffect)(()=>{T.setInputs({sessionStatus:e,hasPlatformSession:t,queryClient:r,selectedPlatformAssistantId:s,isOrgReady:i}),T.respondToInputs()},[e,t,r,s,i]),(0,R.useEffect)(()=>{c&&T.applyServerResult(c)},[c])}var B=`0.8.5`,V=5e3,H=6e4;function U(e,t=!0){return y(B)&&t?{staleTime:e,refetchInterval:!1}:{staleTime:V,refetchInterval:V}}function W(){return U(H)}function G(e){return U(1/0,e)}var K=new Set(Object.keys(A)),q=new Set(Object.keys(k));async function J(e){let t=j.getState().scopeKey,{data:n,error:r,response:i}=await E({throwOnError:!1,signal:e});if(x(i,r,`Failed to fetch client feature flags`),!i.ok||!n)throw b(r,i);return{scopeKey:t,flags:n.flags}}function Y(e){let t={},n={};for(let[r,i]of Object.entries(e)){let e=O(r);typeof i==`boolean`&&K.has(e)?t[e]=i:typeof i==`string`&&q.has(e)&&(n[e]=i)}return{boolFlags:t,stringFlags:n}}function X(e,t=!1){let n=G(t),i=ee(),a=j.use.scopeKey(),o=e&&!h(),s=o&&i===`ready`,{data:c,isError:l}=r({queryKey:F(),queryFn:({signal:e})=>J(e),enabled:s,...n,refetchOnWindowFocus:!1,refetchOnReconnect:!1});(0,R.useEffect)(()=>{if(c?.flags){let{boolFlags:e,stringFlags:t}=Y(c.flags),n=j.getState();n.setFlags(e,c.scopeKey),Object.keys(t).length>0&&n.setStringFlags(t,c.scopeKey);return}e&&(!o||i===`unavailable`||l)&&j.getState().settleWithoutServerValues(a)},[a,c,e,l,o,i])}var Z=f(d((e,t)=>({isOpen:!1,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1}),toggle:()=>e({isOpen:!t().isOpen})})));async function ne(){if(!_())return!1;let e=window.vellum?.commandPalette?.open;return e?(await e(),!0):!1}async function re(){_()&&await window.vellum?.commandPalette?.dismiss()}async function ie(e){_()&&await window.vellum?.commandPalette?.select(e)}var Q={query:``,queryTokens:[],results:{conversations:[],memories:[],schedules:[],contacts:[]}};function ae(e,t){return e||t.split(/\s+/).filter(e=>e.length>0)}async function oe(e,t,n){let r=n?.limit??10;try{let{data:i,response:a}=await D({path:{assistant_id:e},query:{q:t,limit:r,categories:`conversations,schedules,contacts`},throwOnError:!1,signal:n?.signal});return!a?.ok||!i?Q:{query:i.query,queryTokens:ae(i.queryTokens,i.query),results:i.results}}catch(n){return n instanceof DOMException&&n.name===`AbortError`||console.error(`[global-search] search failed`,{assistantId:e,query:t,err:n}),Q}}var se=150,ce=2,$=[];function le({itemCount:e,onSelect:t,assistantId:n,isOpen:r,onClose:i}){let a=Z.use.isOpen(),o=r??a,s=Z.use.open(),c=Z.use.close(),[l,u]=(0,R.useState)(``),[d,f]=(0,R.useState)(0),[p,m]=(0,R.useState)(!1),[h,g]=(0,R.useState)(null),[_,v]=(0,R.useState)($),y=(0,R.useRef)(()=>0);(0,R.useLayoutEffect)(()=>{y.current=typeof e==`function`?e:()=>e});let b=(0,R.useRef)(null),x=(0,R.useRef)(null),S=(0,R.useCallback)(()=>{b.current&&=(clearTimeout(b.current),null),x.current?.abort(),x.current=null},[]),C=(0,R.useCallback)(()=>{s(),f(0)},[s]),w=(0,R.useCallback)(()=>{c(),u(``),f(0),m(!1),g(null),v($),S(),i?.()},[c,S,i]),T=(0,R.useCallback)(()=>{o?w():C()},[o,w,C]);(0,R.useEffect)(()=>{o||(u(``),f(0),m(!1),g(null),v($),S())},[o,S]);let E=(0,R.useCallback)(e=>{S();let t=e.trim();if(t.length<ce||!n){m(!1),g(null),v($);return}m(!0),b.current=setTimeout(()=>{if(!n){m(!1);return}let e=new AbortController;x.current=e,oe(n,t,{signal:e.signal}).then(t=>{x.current===e&&(g(t.results),v(t.queryTokens),m(!1))}).catch(()=>{x.current===e&&m(!1)})},se)},[S,n]),D=(0,R.useCallback)(e=>{u(e),f(0),E(e)},[E]);return(0,R.useEffect)(()=>()=>{x.current?.abort(),b.current&&clearTimeout(b.current)},[]),{isOpen:o,query:l,selectedIndex:d,isSearching:p,searchResults:h,searchTokens:_,open:C,close:w,toggle:T,setQuery:D,handleKeyDown:(0,R.useCallback)(e=>{if(e.key===`k`&&(e.metaKey||e.ctrlKey)){e.preventDefault(),w();return}let n=y.current();switch(e.key){case`ArrowDown`:e.preventDefault(),n>0&&f(e=>Math.min(e+1,n-1));break;case`ArrowUp`:e.preventDefault(),f(e=>Math.max(e-1,0));break;case`Enter`:e.preventDefault(),n>0&&t?.(d);break;case`Escape`:e.preventDefault(),w();break}},[t,d,w])}}function ue(e){return{id:`actions`,label:`Actions`,items:[{id:`action-new-conversation`,icon:L,title:`New Conversation`,shortcutHint:_()?`⌘N`:`⌘⇧O`},{id:`action-current-conversation`,icon:l,title:`Current Conversation`,shortcutHint:`⌘⇧N`},{id:`action-settings`,icon:u,title:`Settings`,shortcutHint:`⌘,`},{id:`action-library`,icon:s,title:`Library`},{id:`action-intelligence`,icon:o,title:e}]}}function de(e,t){let n=[],r=e.conversations.filter(e=>!t.has(e.id)).map(e=>({id:`search-conv-${e.id}`,icon:c,title:e.title??`Untitled`,snippet:e.excerpt||void 0}));r.length>0&&n.push({id:`search-conversations`,label:`Conversations`,items:r});let i=e.schedules.map(e=>({id:`search-schedule-${e.id}`,icon:a,title:e.name,subtitle:e.expression??e.message}));i.length>0&&n.push({id:`search-schedules`,label:`Schedules`,items:i});let o=e.contacts.map(e=>({id:`search-contact-${e.id}`,icon:I,title:e.displayName,subtitle:e.notes??void 0}));return o.length>0&&n.push({id:`search-contacts`,label:`Contacts`,items:o}),n}function fe(e){return{id:`conversations`,label:`Recent`,items:e.slice(0,5).map(e=>({id:`conv-${e.conversationId}`,icon:c,title:e.title??`Untitled`,subtitle:e.lastMessageAt?te(e.lastMessageAt):void 0}))}}function pe(e,t){switch(e.id){case`action-new-conversation`:t.startNewConversation();break;case`action-current-conversation`:P.light(),t.navigate(M.assistant);break;case`action-settings`:P.light(),t.navigateToSettings();break;case`action-intelligence`:P.light(),t.navigate(M.identity);break;case`action-library`:P.light(),t.navigate(M.library.root);break;default:if(e.id.startsWith(`conv-`)){let n=e.id.slice(5);t.switchConversation(n)}else if(e.id.startsWith(`search-conv-`)){let n=e.id.slice(12);t.switchConversation(n)}else e.id.startsWith(`search-schedule-`)?(P.light(),t.navigate(M.schedules.detail(e.id.slice(16)))):e.id.startsWith(`search-contact-`)&&(P.light(),t.navigate(M.identity));break}}function me({assistantId:e,assistantName:t,conversations:n,activeConversationId:r,startNewConversation:i,switchConversation:a,navigate:o,navigateToSettings:s,isOpen:c,onClose:l,onItemSelect:u}){let d=(0,R.useMemo)(()=>{let e=ue(t??`Assistant`),r=fe(n);return[e,...r.items.length>0?[r]:[]]},[n,t]),f=(0,R.useMemo)(()=>new Set(n.slice(0,5).map(e=>e.conversationId)),[n]),p=(0,R.useCallback)(e=>{if(u){u(e);return}pe(e,{startNewConversation:i,switchConversation:a,navigate:o,activeConversationId:r,navigateToSettings:s})},[i,a,o,r,s,u]),m=(0,R.useRef)([]),h=(0,R.useRef)(()=>{}),g=le({itemCount:()=>m.current.reduce((e,t)=>e+t.items.length,0),onSelect:(0,R.useCallback)(e=>{let t=e;for(let e of m.current){if(t<e.items.length){let n=e.items[t];p(n),h.current();return}t-=e.items.length}},[p]),assistantId:e,isOpen:c,onClose:l});(0,R.useLayoutEffect)(()=>{h.current=g.close});let _=(0,R.useMemo)(()=>{if(!g.query.trim())return d;let e=g.query.toLowerCase().trim();return d.map(t=>({...t,items:t.items.filter(t=>t.title.toLowerCase().includes(e))})).filter(e=>e.items.length>0)},[d,g.query]),v=(0,R.useMemo)(()=>{let e=g.searchResults?de(g.searchResults,f):[];return[..._,...e]},[_,g.searchResults,f]);return(0,R.useLayoutEffect)(()=>{m.current=v}),{commandPalette:g,mergedSections:v,handleItemSelect:(0,R.useCallback)(e=>{p(e),h.current()},[p])}}export{Z as a,z as c,ie as i,L as l,re as n,X as o,ne as r,W as s,me as t,I as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{l as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./typography-DEI9Ra9z.js";import{t as s}from"./createLucideIcon-CAM1RhH8.js";import{t as c}from"./chevron-up-DofScvyy.js";import{t as l}from"./menu-wESJw6y3.js";import"./src-Da9g8qsW.js";import{t as u}from"./globe-CdLn4IX7.js";import{t as d}from"./loader-circle-DWWXcfTQ.js";import{n as f,t as p}from"./minimize-2-Dj9FY4aF.js";import{t as m}from"./pencil-Cm5DdeRM.js";import{t as h}from"./x-D4O9yIS7.js";import{n as g,t as _}from"./panel-item-CJh95P_q.js";import{n as v}from"./resolved-assistants-store-C6oDdTxB.js";import{t as y}from"./client.gen-Dq2brHDV.js";import{n as b}from"./event-bus-CbDg1VDt.js";import{d as x}from"./routes-DrfnNoYS.js";import{t as S}from"./conversation-store-CTMy9QPV.js";import{i as C}from"./viewer-store-Cp5tMX-G.js";import{n as w}from"./use-is-mobile-MmHo-OM6.js";import{t as T}from"./misc-BBsGq1IU.js";import{r as E,t as D}from"./edit-chat-session-DVzLQLWl.js";import{n as O,t as k}from"./sandbox-bridge-B5H4c27m.js";var A=s(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),j=s(`share`,[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]),M=a(),N=e(t(),1),P=`_vellumDebug`,F=`apps`,I=`disableIframeSandbox`,L=!1,R=new Set;function z(){return L}function B(e){let t=e===!0;if(t!==L){L=t,t?console.warn(`[vellumDebug] ${F}.${I} = true: app iframes render without the sandbox attribute. App HTML runs same-origin with the host and can reach its DOM, storage, and cookies. Open apps reload to pick this up. Set it back to false, or reload the page, to restore the sandbox.`):console.info(`[vellumDebug] ${F}.${I} = false: app iframes are sandboxed again.`);for(let e of R)e()}}function V(e){return R.add(e),()=>{R.delete(e)}}function H(){return(0,N.useSyncExternalStore)(V,z,()=>!1)}function U(){if(typeof window>`u`)return;let e=window,t=e[P]??{},n=t[F]??{};Object.defineProperty(n,I,{configurable:!0,enumerable:!0,get:z,set:B}),t[F]=n,e[P]=t}function W({appName:e,onEdit:t,isEditing:r,onShare:i,isSharing:a,onDeploy:s,isDeploying:l,onToggleFullscreen:p,onClose:g}){let _=w(),v=_&&r===!0&&t!=null,y=i!=null&&s!=null;return(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-t-xl bg-[var(--surface-lift)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`hidden md:flex items-center min-w-[72px]`,children:t!=null&&(r?(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(A,{}),onClick:t,tooltip:`Expand app`,"aria-label":`Expand app`}):(0,M.jsx)(n,{onClick:t,children:`Edit`}))}),(0,M.jsx)(o,{variant:`body-large-default`,className:T(`flex-1 truncate text-left md:text-center text-[var(--content-emphasised)]`,v&&`cursor-pointer`),style:{lineHeight:1.4},onClick:v?t:void 0,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-[72px] justify-end`,children:[y?(0,M.jsx)(G,{onShare:i,isSharing:a,onDeploy:s,isDeploying:l,isMobile:_}):(0,M.jsxs)(M.Fragment,{children:[s!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:l?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(u,{}),onClick:s,disabled:l,tooltip:l?`Deploying…`:`Deploy`,"aria-label":l?`Deploying…`:`Deploy`}),i!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:a?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),onClick:i,disabled:a,tooltip:a?`Sharing…`:`Share`,"aria-label":a?`Sharing…`:`Share`})]}),p!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(f,{}),onClick:p,tooltip:`Fullscreen`,"aria-label":`Fullscreen`}),t!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:r?(0,M.jsx)(c,{}):(0,M.jsx)(m,{}),onClick:t,tooltip:r?`Open app`:`Edit`,"aria-label":r?`Open app`:`Edit`,active:r,className:`md:hidden`}),(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(h,{}),onClick:g,tooltip:`Close`,"aria-label":`Close`})]})]})}function G({onShare:e,isSharing:t,onDeploy:r,isDeploying:i,isMobile:a}){let[o,s]=(0,N.useState)(!1),c=t||i,f=c?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),p=t?`Sharing…`:i?`Deploying…`:`Share & deploy`;return a?(0,M.jsxs)(g.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(g.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(g.Content,{"aria-describedby":void 0,children:[(0,M.jsx)(g.Header,{className:`sr-only`,children:(0,M.jsx)(g.Title,{children:`Share & deploy`})}),(0,M.jsxs)(g.Body,{className:`pt-0`,children:[(0,M.jsx)(_,{icon:j,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Share`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Export as .vellum file`})]}),onSelect:()=>{s(!1),e()}}),(0,M.jsx)(_,{icon:u,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Deploy to Vercel`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Publish as a static page`})]}),onSelect:()=>{s(!1),r()}})]})]})]}):(0,M.jsxs)(l.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(l.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(l.Content,{align:`end`,sideOffset:4,children:[(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(j,{size:14}),onSelect:()=>e(),className:`whitespace-nowrap`,children:`Share`}),(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(u,{size:14}),onSelect:()=>r(),className:`whitespace-nowrap`,children:`Deploy to Vercel`})]})]})}var K=[`assistant:`,`conversation:`,`conversations:`,`apps:`,`plugins:`,`feature-flags:`];function q(e){return K.some(t=>e.startsWith(t))}function J(e,t){if(e.length===0)return[];let n=new Set(e);return t.filter(e=>n.has(e)&&!q(e))}function Y(e,t){let{frameId:n,assistantId:r,appId:i,enabled:a=!0,onAction:o,onOpenVellumLink:s}=t,c=(0,N.useRef)(new Map);(0,N.useEffect)(()=>{let t=c.current,l=async c=>{let l=c.data;if(!l||l.frameId!==n||c.source!==e.current?.contentWindow)return;if(l.type===`vellum_subscribe`){if(!a)return;let{subId:e,tags:n}=l;typeof e==`string`&&Array.isArray(n)&&t.set(e,new Set(n.filter(e=>typeof e==`string`)));return}if(l.type===`vellum_unsubscribe`){let{subId:e}=l;typeof e==`string`&&t.delete(e);return}if(l.type===`vellum_surface_action`){o?.(l.actionId,l.data);return}if(l.type===`vellum_open_link`){if(!navigator.userActivation?.isActive)return;s?.(l.href,l.linkText);return}if(l.type===`vellum_asset_request`){let{callId:t,path:n}=l,o=e.current,s=(e,t)=>{o?.contentWindow?.postMessage(e,`*`,t??[])};if(!a){s({type:`vellum_asset_response`,callId:t,error:`Asset proxy disabled`});return}if(!i){s({type:`vellum_asset_response`,callId:t,error:`No app context for assets`});return}if(typeof n!=`string`||n===``||n.includes(`..`)){s({type:`vellum_asset_response`,callId:t,error:`Invalid asset path`});return}try{let e=`/v1/assistants/${r}/apps/${i}/asset/${n.split(`/`).map(encodeURIComponent).join(`/`)}`,{data:a,response:o}=await y.get({url:e,parseAs:`blob`,throwOnError:!1});if(!o?.ok||!(a instanceof Blob)){s({type:`vellum_asset_response`,callId:t,error:`Asset fetch failed (${o?.status??0})`});return}let c=await a.arrayBuffer();s({type:`vellum_asset_response`,callId:t,buffer:c,contentType:a.type||`application/octet-stream`},[c])}catch(e){s({type:`vellum_asset_response`,callId:t,error:e instanceof Error?e.message:`Asset proxy error`})}return}if(!a||l.type!==`vellum_fetch_request`)return;let{callId:u,path:d,method:f,headers:p,body:m}=l,h=e.current,g=e=>{h?.contentWindow?.postMessage(e,`*`)};if(!k.test(d)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: only /v1/x/ custom routes are allowed`});return}try{let e=new URL(d,`https://placeholder`).pathname;if(!k.test(e)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: path traversal detected`});return}}catch{g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: invalid path`});return}let _=`/v1/assistants/${r}/${d.replace(/^\/v1\//,``)}`;try{let e={url:_,throwOnError:!1,headers:p&&Object.keys(p).length>0?p:void 0,body:m?JSON.parse(m):void 0},t=await(f===`POST`?y.post:f===`PUT`?y.put:f===`PATCH`?y.patch:f===`DELETE`?y.delete:y.get)(e),n=t.response,r=t.data??t.error,i=r==null?``:typeof r==`string`?r:JSON.stringify(r);g({type:`vellum_fetch_response`,callId:u,status:n?.status??0,statusText:n?.statusText??``,body:i})}catch(e){g({type:`vellum_fetch_response`,callId:u,error:e instanceof Error?e.message:`Fetch proxy error`})}};window.addEventListener(`message`,l);let u=b(`sse.event`,r=>{let i=r.message;if(!i||i.type!==`sync_changed`||!Array.isArray(i.tags))return;let a=e.current?.contentWindow;if(!a||t.size===0)return;let o=i.tags.filter(e=>typeof e==`string`);for(let[e,r]of t){let t=J([...r],o);t.length>0&&a.postMessage({type:`vellum_event`,frameId:n,subId:e,event:{type:`sync_changed`,tags:t}},`*`)}});return()=>{window.removeEventListener(`message`,l),u()}},[n,r,i,a,o,s,e])}var X=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function Z({appId:e,appName:t,html:r,assistantId:i,onClose:a,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,route:f,enableFullscreen:m=!1,onAction:h}){let g=(0,N.useRef)(null),[_,v]=(0,N.useState)(!1),y=(0,N.useCallback)(()=>v(e=>!e),[]);(0,N.useEffect)(()=>{v(!1)},[e]),(0,N.useEffect)(()=>{if(!_)return;let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),v(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_]);let b=(0,N.useMemo)(()=>O(r,e,{fetch:!0,route:f}),[r,e,f]),x=H(),S=(0,N.useMemo)(()=>{let t=0;for(let e=0;e<r.length;e++)t=(t<<5)-t+r.charCodeAt(e)|0;return`app-${e}-${t}${x?`-nosandbox`:``}`},[r,e,x]);return Y(g,{frameId:e,assistantId:i,appId:e,onAction:h}),(0,M.jsxs)(`div`,{"data-testid":`app-viewer-root`,className:T(`flex flex-col overflow-hidden bg-[var(--surface-base)]`,_?`fixed inset-0 z-[60]`:`h-full rounded-xl`),children:[!_&&(0,M.jsx)(W,{appName:t,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,onToggleFullscreen:m?y:void 0,onClose:a}),(0,M.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[_&&(0,M.jsx)(`div`,{className:`absolute z-10`,style:{top:`max(0.75rem, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,right:`max(0.75rem, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:(0,M.jsx)(n,{variant:`primary`,iconOnly:(0,M.jsx)(p,{}),onClick:y,tooltip:`Exit fullscreen`})}),(0,M.jsx)(`iframe`,{ref:g,srcDoc:b,sandbox:x?void 0:X,referrerPolicy:`no-referrer`,title:t,className:`h-full w-full border-none`},S)]})]})}function Q(){let e=v.use.activeAssistantId(),t=w(),n=i(),{pathname:a}=r();return(0,N.useCallback)(r=>{if(!e)return;let i=D(e,r.appId)??crypto.randomUUID();E(e,r.appId,i);let o=C.getState();(o.activeAppId!==r.appId||!o.openedAppState)&&(o.openApp(r.appId),o.setLoadedApp(r)),S.getState().setEditingConversationId(i),t?o.minimizeApp():o.enterAppEditing();let s=x.conversation(i);a!==s&&n(s)},[e,t,n,a])}export{j as a,U as i,Z as n,Y as r,Q as t};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{l as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./typography-DEI9Ra9z.js";import{t as s}from"./createLucideIcon-CAM1RhH8.js";import{t as c}from"./chevron-up-DofScvyy.js";import{t as l}from"./menu-wESJw6y3.js";import"./src-Da9g8qsW.js";import{t as u}from"./globe-CdLn4IX7.js";import{t as d}from"./loader-circle-DWWXcfTQ.js";import{n as f,t as p}from"./minimize-2-Dj9FY4aF.js";import{t as m}from"./pencil-Cm5DdeRM.js";import{t as h}from"./x-D4O9yIS7.js";import{n as g,t as _}from"./panel-item-CJh95P_q.js";import{n as v}from"./resolved-assistants-store-C6oDdTxB.js";import{t as y}from"./client.gen-Dq2brHDV.js";import{n as b}from"./event-bus-CbDg1VDt.js";import{d as x}from"./routes-DrfnNoYS.js";import{t as S}from"./conversation-store-CTMy9QPV.js";import{i as C}from"./viewer-store-DbIS4l8d.js";import{n as w}from"./use-is-mobile-MmHo-OM6.js";import{t as T}from"./misc-BBsGq1IU.js";import{r as E,t as D}from"./edit-chat-session-DVzLQLWl.js";import{n as O,t as k}from"./sandbox-bridge-B5H4c27m.js";var A=s(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),j=s(`share`,[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]),M=a(),N=e(t(),1),P=`_vellumDebug`,F=`apps`,I=`disableIframeSandbox`,L=!1,R=new Set;function z(){return L}function B(e){let t=e===!0;if(t!==L){L=t,t?console.warn(`[vellumDebug] ${F}.${I} = true: app iframes render without the sandbox attribute. App HTML runs same-origin with the host and can reach its DOM, storage, and cookies. Open apps reload to pick this up. Set it back to false, or reload the page, to restore the sandbox.`):console.info(`[vellumDebug] ${F}.${I} = false: app iframes are sandboxed again.`);for(let e of R)e()}}function V(e){return R.add(e),()=>{R.delete(e)}}function H(){return(0,N.useSyncExternalStore)(V,z,()=>!1)}function U(){if(typeof window>`u`)return;let e=window,t=e[P]??{},n=t[F]??{};Object.defineProperty(n,I,{configurable:!0,enumerable:!0,get:z,set:B}),t[F]=n,e[P]=t}function W({appName:e,onEdit:t,isEditing:r,onShare:i,isSharing:a,onDeploy:s,isDeploying:l,onToggleFullscreen:p,onClose:g}){let _=w(),v=_&&r===!0&&t!=null,y=i!=null&&s!=null;return(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-t-xl bg-[var(--surface-lift)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`hidden md:flex items-center min-w-[72px]`,children:t!=null&&(r?(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(A,{}),onClick:t,tooltip:`Expand app`,"aria-label":`Expand app`}):(0,M.jsx)(n,{onClick:t,children:`Edit`}))}),(0,M.jsx)(o,{variant:`body-large-default`,className:T(`flex-1 truncate text-left md:text-center text-[var(--content-emphasised)]`,v&&`cursor-pointer`),style:{lineHeight:1.4},onClick:v?t:void 0,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-[72px] justify-end`,children:[y?(0,M.jsx)(G,{onShare:i,isSharing:a,onDeploy:s,isDeploying:l,isMobile:_}):(0,M.jsxs)(M.Fragment,{children:[s!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:l?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(u,{}),onClick:s,disabled:l,tooltip:l?`Deploying…`:`Deploy`,"aria-label":l?`Deploying…`:`Deploy`}),i!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:a?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),onClick:i,disabled:a,tooltip:a?`Sharing…`:`Share`,"aria-label":a?`Sharing…`:`Share`})]}),p!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(f,{}),onClick:p,tooltip:`Fullscreen`,"aria-label":`Fullscreen`}),t!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:r?(0,M.jsx)(c,{}):(0,M.jsx)(m,{}),onClick:t,tooltip:r?`Open app`:`Edit`,"aria-label":r?`Open app`:`Edit`,active:r,className:`md:hidden`}),(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(h,{}),onClick:g,tooltip:`Close`,"aria-label":`Close`})]})]})}function G({onShare:e,isSharing:t,onDeploy:r,isDeploying:i,isMobile:a}){let[o,s]=(0,N.useState)(!1),c=t||i,f=c?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),p=t?`Sharing…`:i?`Deploying…`:`Share & deploy`;return a?(0,M.jsxs)(g.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(g.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(g.Content,{"aria-describedby":void 0,children:[(0,M.jsx)(g.Header,{className:`sr-only`,children:(0,M.jsx)(g.Title,{children:`Share & deploy`})}),(0,M.jsxs)(g.Body,{className:`pt-0`,children:[(0,M.jsx)(_,{icon:j,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Share`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Export as .vellum file`})]}),onSelect:()=>{s(!1),e()}}),(0,M.jsx)(_,{icon:u,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Deploy to Vercel`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Publish as a static page`})]}),onSelect:()=>{s(!1),r()}})]})]})]}):(0,M.jsxs)(l.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(l.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(l.Content,{align:`end`,sideOffset:4,children:[(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(j,{size:14}),onSelect:()=>e(),className:`whitespace-nowrap`,children:`Share`}),(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(u,{size:14}),onSelect:()=>r(),className:`whitespace-nowrap`,children:`Deploy to Vercel`})]})]})}var K=[`assistant:`,`conversation:`,`conversations:`,`apps:`,`plugins:`,`feature-flags:`];function q(e){return K.some(t=>e.startsWith(t))}function J(e,t){if(e.length===0)return[];let n=new Set(e);return t.filter(e=>n.has(e)&&!q(e))}function Y(e,t){let{frameId:n,assistantId:r,appId:i,enabled:a=!0,onAction:o,onOpenVellumLink:s}=t,c=(0,N.useRef)(new Map);(0,N.useEffect)(()=>{let t=c.current,l=async c=>{let l=c.data;if(!l||l.frameId!==n||c.source!==e.current?.contentWindow)return;if(l.type===`vellum_subscribe`){if(!a)return;let{subId:e,tags:n}=l;typeof e==`string`&&Array.isArray(n)&&t.set(e,new Set(n.filter(e=>typeof e==`string`)));return}if(l.type===`vellum_unsubscribe`){let{subId:e}=l;typeof e==`string`&&t.delete(e);return}if(l.type===`vellum_surface_action`){o?.(l.actionId,l.data);return}if(l.type===`vellum_open_link`){if(!navigator.userActivation?.isActive)return;s?.(l.href,l.linkText);return}if(l.type===`vellum_asset_request`){let{callId:t,path:n}=l,o=e.current,s=(e,t)=>{o?.contentWindow?.postMessage(e,`*`,t??[])};if(!a){s({type:`vellum_asset_response`,callId:t,error:`Asset proxy disabled`});return}if(!i){s({type:`vellum_asset_response`,callId:t,error:`No app context for assets`});return}if(typeof n!=`string`||n===``||n.includes(`..`)){s({type:`vellum_asset_response`,callId:t,error:`Invalid asset path`});return}try{let e=`/v1/assistants/${r}/apps/${i}/asset/${n.split(`/`).map(encodeURIComponent).join(`/`)}`,{data:a,response:o}=await y.get({url:e,parseAs:`blob`,throwOnError:!1});if(!o?.ok||!(a instanceof Blob)){s({type:`vellum_asset_response`,callId:t,error:`Asset fetch failed (${o?.status??0})`});return}let c=await a.arrayBuffer();s({type:`vellum_asset_response`,callId:t,buffer:c,contentType:a.type||`application/octet-stream`},[c])}catch(e){s({type:`vellum_asset_response`,callId:t,error:e instanceof Error?e.message:`Asset proxy error`})}return}if(!a||l.type!==`vellum_fetch_request`)return;let{callId:u,path:d,method:f,headers:p,body:m}=l,h=e.current,g=e=>{h?.contentWindow?.postMessage(e,`*`)};if(!k.test(d)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: only /v1/x/ custom routes are allowed`});return}try{let e=new URL(d,`https://placeholder`).pathname;if(!k.test(e)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: path traversal detected`});return}}catch{g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: invalid path`});return}let _=`/v1/assistants/${r}/${d.replace(/^\/v1\//,``)}`;try{let e={url:_,throwOnError:!1,headers:p&&Object.keys(p).length>0?p:void 0,body:m?JSON.parse(m):void 0},t=await(f===`POST`?y.post:f===`PUT`?y.put:f===`PATCH`?y.patch:f===`DELETE`?y.delete:y.get)(e),n=t.response,r=t.data??t.error,i=r==null?``:typeof r==`string`?r:JSON.stringify(r);g({type:`vellum_fetch_response`,callId:u,status:n?.status??0,statusText:n?.statusText??``,body:i})}catch(e){g({type:`vellum_fetch_response`,callId:u,error:e instanceof Error?e.message:`Fetch proxy error`})}};window.addEventListener(`message`,l);let u=b(`sse.event`,r=>{let i=r.message;if(!i||i.type!==`sync_changed`||!Array.isArray(i.tags))return;let a=e.current?.contentWindow;if(!a||t.size===0)return;let o=i.tags.filter(e=>typeof e==`string`);for(let[e,r]of t){let t=J([...r],o);t.length>0&&a.postMessage({type:`vellum_event`,frameId:n,subId:e,event:{type:`sync_changed`,tags:t}},`*`)}});return()=>{window.removeEventListener(`message`,l),u()}},[n,r,i,a,o,s,e])}var X=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function Z({appId:e,appName:t,html:r,assistantId:i,onClose:a,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,route:f,enableFullscreen:m=!1,onAction:h}){let g=(0,N.useRef)(null),[_,v]=(0,N.useState)(!1),y=(0,N.useCallback)(()=>v(e=>!e),[]);(0,N.useEffect)(()=>{v(!1)},[e]),(0,N.useEffect)(()=>{if(!_)return;let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),v(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_]);let b=(0,N.useMemo)(()=>O(r,e,{fetch:!0,route:f}),[r,e,f]),x=H(),S=(0,N.useMemo)(()=>{let t=0;for(let e=0;e<r.length;e++)t=(t<<5)-t+r.charCodeAt(e)|0;return`app-${e}-${t}${x?`-nosandbox`:``}`},[r,e,x]);return Y(g,{frameId:e,assistantId:i,appId:e,onAction:h}),(0,M.jsxs)(`div`,{"data-testid":`app-viewer-root`,className:T(`flex flex-col overflow-hidden bg-[var(--surface-base)]`,_?`fixed inset-0 z-[60]`:`h-full rounded-xl`),children:[!_&&(0,M.jsx)(W,{appName:t,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,onToggleFullscreen:m?y:void 0,onClose:a}),(0,M.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[_&&(0,M.jsx)(`div`,{className:`absolute z-10`,style:{top:`max(0.75rem, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,right:`max(0.75rem, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:(0,M.jsx)(n,{variant:`primary`,iconOnly:(0,M.jsx)(p,{}),onClick:y,tooltip:`Exit fullscreen`})}),(0,M.jsx)(`iframe`,{ref:g,srcDoc:b,sandbox:x?void 0:X,referrerPolicy:`no-referrer`,title:t,className:`h-full w-full border-none`},S)]})]})}function Q(){let e=v.use.activeAssistantId(),t=w(),n=i(),{pathname:a}=r();return(0,N.useCallback)(r=>{if(!e)return;let i=D(e,r.appId)??crypto.randomUUID();E(e,r.appId,i);let o=C.getState();(o.activeAppId!==r.appId||!o.openedAppState)&&(o.openApp(r.appId),o.setLoadedApp(r)),S.getState().setEditingConversationId(i),t?o.minimizeApp():o.enterAppEditing();let s=x.conversation(i);a!==s&&n(s)},[e,t,n,a])}export{j as a,U as i,Z as n,Y as r,Q as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{at as e,ct as t,i as n,n as r,ot as i,rt as a}from"./auth-store-
|
|
1
|
+
import{at as e,ct as t,i as n,n as r,ot as i,rt as a}from"./auth-store-C9aYqB9U.js";var o=5e3;function s(e,t,n){return!n||e!=null?`ready`:t===`error`?`unavailable`:`resolving`}function c(){return s(i(),e.use.status(),n())}function l(){return s(a(),e.getState().status,t(r.getState().platformSession))}function u(){return c()===`ready`}export{c as i,l as n,u as r,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{l as n}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as r}from"./is-electron-DIlIrdJX.js";import{f as i}from"./native-biometric-DetUqtjl.js";import{d as a}from"./routes-DrfnNoYS.js";import{i as o}from"./navigation-resolver-CzEY-5nE.js";import{t as s}from"./build-state-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{l as n}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as r}from"./is-electron-DIlIrdJX.js";import{f as i}from"./native-biometric-DetUqtjl.js";import{d as a}from"./routes-DrfnNoYS.js";import{i as o}from"./navigation-resolver-CzEY-5nE.js";import{t as s}from"./build-state-9uUe0jN5.js";import{n as c}from"./login-flow-CQhvCbQQ.js";var l=e(t(),1);function u(e){let t=n(),[u,d]=(0,l.useState)(!1),[f,p]=(0,l.useState)(null),m=(0,l.useRef)(0);return{loading:u,error:f,login:async()=>{let n=e??o(s({sessionSettled:!0,isAuthenticated:!0}),t.pathname),r=++m.current;p(null),d(!0);try{await i(c,`${a.account.providerCallback}?returnTo=${encodeURIComponent(n)}`,{returnTo:n})}catch{if(r!==m.current)return;p(`Something went wrong. Please try again.`),d(!1)}},cancel:()=>{m.current++,d(!1),p(null),r()&&window.vellum?.auth?.cancelOAuth()}}}export{u as t};
|
package/dist/assets/{use-platform-assistant-id-y2pWr9on.js → use-platform-assistant-id-DgrNmSy2.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{Q as n}from"./auth-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{Q as n}from"./auth-store-C9aYqB9U.js";var r=e(t(),1);function i(e,t){let[i,a]=(0,r.useState)({platformAssistantId:null,isLoading:!1,error:null});return(0,r.useEffect)(()=>{if(!t||!e){a({platformAssistantId:null,isLoading:!1,error:null});return}let r=!0;return a({platformAssistantId:null,isLoading:!0,error:null}),n(e).then(e=>{r&&a({platformAssistantId:e,isLoading:!1,error:null})}).catch(e=>{r&&a({platformAssistantId:null,isLoading:!1,error:e instanceof Error?e:Error(String(e))})}),()=>{r=!1}},[e,t]),i}export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{f as n,m as r}from"./local-mode-DHueA-BJ.js";import{i,o as a,xt as o}from"./auth-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{f as n,m as r}from"./local-mode-DHueA-BJ.js";import{i,o as a,xt as o}from"./auth-store-C9aYqB9U.js";var s=e(t(),1);function c(){let e=o.use.assistantState();return!!(e.kind===`self_hosted`||e.kind===`active`&&e.isLocal)}function l(){let e=o.use.assistantState();return e.kind===`active`&&!e.isLocal}function u(){let e=o.use.assistantState();return e.kind===`loading`||e.kind===`initializing`||e.kind===`cleaning_up`}function d(e={}){let t=p(e);return t===`pending`?`disabled`:t}function f(e={}){let t=p(e),n=m(t===`pending`,e.settleTimeoutMs??5e3);return t===`pending`&&n?`disabled`:t}function p(e){let t=i(),o=a(),s=r(),l=c(),u=o?`disabled`:`pending`;return e.platformHostedOnly?l?`gated`:t?`full`:u:n()&&s?`gated`:t?`full`:u}function m(e,t){let[n,r]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{if(!e){r(!1);return}let n=setTimeout(()=>r(!0),t);return()=>{clearTimeout(n)}},[e,t]),n}export{f as a,d as i,c as n,u as r,l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{m as n,n as r}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./loader-circle-DWWXcfTQ.js";import{a as o,s}from"./auth-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{m as n,n as r}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./loader-circle-DWWXcfTQ.js";import{a as o,s}from"./auth-store-C9aYqB9U.js";import{w as c}from"./native-biometric-DetUqtjl.js";import{d as l}from"./routes-DrfnNoYS.js";import{a as u}from"./use-platform-gate-C5bNA5Pn.js";import{t as d}from"./hard-navigate-BYoBFmE4.js";import{a as f,o as p}from"./login-flow-CQhvCbQQ.js";var m=i();function h(){return(0,m.jsx)(a,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`,"aria-label":`Loading`})}var g=e(t(),1);function _({to:e}){let t=f(e);return(0,g.useEffect)(()=>{t&&d(e)},[t,e]),t?null:(0,m.jsx)(r,{to:e,replace:!0})}function v(){let[e]=n(),t=o(),r=s(),i=u(),a=e.get(`returnTo`),d=c(a,l.assistant);if(!a)return{kind:`proceed`,returnTo:null};if(r)return{kind:`wait`};if(!t)return{kind:`proceed`,returnTo:d};if(p(d)){if(i===`pending`)return{kind:`wait`};if(i===`disabled`)return{kind:`proceed`,returnTo:d}}return{kind:`redirect`,node:(0,m.jsx)(_,{to:d})}}export{h as n,v as t};
|