@vellumai/web 0.8.9-staging.3 → 0.8.9-staging.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{account-page-JOmrd7O5.js → account-page-DLWgiDpL.js} +1 -1
- package/dist/assets/add-credits-modal-KR3l-hlL.js +1 -0
- package/dist/assets/{advanced-page-DfQKcHki.js → advanced-page-CM1prrIX.js} +1 -1
- package/dist/assets/ai-page-DfYw7V-1.js +1 -0
- package/dist/assets/{api-key-screen-BFaPTjaE.js → api-key-screen-_pmVhsup.js} +1 -1
- package/dist/assets/{archive-page-BA9_f8tE.js → archive-page-C3-LAH2o.js} +1 -1
- package/dist/assets/{assistant-status-panel-B2a_ey3l.js → assistant-status-panel-AFf9Mjwp.js} +1 -1
- package/dist/assets/auth-store-CiQCAKS1.js +6 -0
- package/dist/assets/billing-page-o68CnS02.js +34 -0
- package/dist/assets/{chunk-5KNZJZUH-B4b1m-Ya.js → chunk-5KNZJZUH-DdS6bb-3.js} +2 -2
- package/dist/assets/{command-palette-BiZB4OSo.js → command-palette-BcHAzecz.js} +1 -1
- package/dist/assets/{community-page-j-8N5lFa.js → community-page-BCX3CsOx.js} +1 -1
- package/dist/assets/{connect-page-zFzMI9NA.js → connect-page-DXB8Xkpw.js} +1 -1
- package/dist/assets/{contacts-gateway-DjUsIJ09.js → contacts-gateway-DBRvewkn.js} +1 -1
- package/dist/assets/contacts-page-route-8pMuZN4b.js +1 -0
- package/dist/assets/danger-zone-redirect-page-G9ozZFrR.js +1 -0
- package/dist/assets/debug-page-CS2bRZp9.js +3 -0
- package/dist/assets/deploy-dialogs-EImApd6S.js +1 -0
- package/dist/assets/{developer-page-CZfUJHd7.js → developer-page-C6j4GZcn.js} +1 -1
- package/dist/assets/devices-page-C1id1sIt.js +1 -0
- package/dist/assets/{document-viewer-page-DP01_kUJ.js → document-viewer-page-D-zkJQlm.js} +1 -1
- package/dist/assets/{earn-credits-modal-QwO92K15.js → earn-credits-modal-RXLM_09P.js} +1 -1
- package/dist/assets/{emails-page-Bqv0y6Lp.js → emails-page-BFlPmeFT.js} +1 -1
- package/dist/assets/general-page-q3bvwcHU.js +1 -0
- package/dist/assets/{hatching-screen-B8RlGI3J.js → hatching-screen-6TxMgPxR.js} +1 -1
- package/dist/assets/home-page-route-mDiWda9f.js +1 -0
- package/dist/assets/{hosting-screen-DoltpG5X.js → hosting-screen-XKK-VeRo.js} +1 -1
- package/dist/assets/identity-page-route-BCiHzwmk.js +1 -0
- package/dist/assets/index-BjEJFZTJ.js +124 -0
- package/dist/assets/{inspect-page-Dmp2FUpn.js → inspect-page-BrUzgvle.js} +2 -2
- package/dist/assets/{install-Db4K638M.js → install-Uj6CrGld.js} +1 -1
- package/dist/assets/integrations-page-BL9LXHFe.js +1 -0
- package/dist/assets/{intelligence-layout-D96EIdSw.js → intelligence-layout-BwYGHEw7.js} +1 -1
- package/dist/assets/{keyboard-shortcuts-page-LBckCCBl.js → keyboard-shortcuts-page-QHFTyWOo.js} +1 -1
- package/dist/assets/library-detail-page-nUyEDHke.js +1 -0
- package/dist/assets/library-page-B0AzCNkJ.js +1 -0
- package/dist/assets/{login-flow-CaZb4l04.js → login-flow-Bi4ujzeb.js} +1 -1
- package/dist/assets/{login-page-C-HGOjOK.js → login-page-BOH-K9Pj.js} +1 -1
- package/dist/assets/{logout-page-Dl5euYyX.js → logout-page-B1QXMyiH.js} +1 -1
- package/dist/assets/{logs-layout-BTlzvT2f.js → logs-layout-zcrIEQRy.js} +1 -1
- package/dist/assets/{memory-router-playground-page-BBlTxde7.js → memory-router-playground-page-CeZ4XMd2.js} +1 -1
- package/dist/assets/{mobile-sidebar-drawer-9EUmVwhv.js → mobile-sidebar-drawer-BjPgVWjw.js} +1 -1
- package/dist/assets/notifications-page-omwlGRbj.js +1 -0
- package/dist/assets/{oauth-complete-page-AZTJJBVl.js → oauth-complete-page--ojS1AzN.js} +1 -1
- package/dist/assets/{oauth-popup-complete-page-CzA0WXr4.js → oauth-popup-complete-page-D5wVrngS.js} +2 -2
- package/dist/assets/password-reset-page-BJo9vGl_.js +1 -0
- package/dist/assets/{platform-loopback-page-CNTdcgsZ.js → platform-loopback-page--72P008D.js} +1 -1
- package/dist/assets/{plugin-detail-page-CS_wmEDi.js → plugin-detail-page-Co_JFwRa.js} +1 -1
- package/dist/assets/{plugins-page-CRtYNHW4.js → plugins-page-D7VpzRFc.js} +1 -1
- package/dist/assets/pre-chat-flow-BoePpEU7.js +1 -0
- package/dist/assets/privacy-page-DpKZ9VJG.js +1 -0
- package/dist/assets/{privacy-screen-qeQ2XoHu.js → privacy-screen-CEsX-1V3.js} +1 -1
- package/dist/assets/{provider-callback-page-C87AasMA.js → provider-callback-page-DDEEkkDM.js} +1 -1
- package/dist/assets/{provider-signup-page-CfbGs1zY.js → provider-signup-page-CZqSVAQl.js} +1 -1
- package/dist/assets/{review-terms-screen-BnGyRURw.js → review-terms-screen-CYFxXWmR.js} +1 -1
- package/dist/assets/routes-Dk5Qeryt.js +1 -0
- package/dist/assets/schedules-page-Dk-YbWK3.js +1 -0
- package/dist/assets/select-assistant-screen-CYpMf074.js +1 -0
- package/dist/assets/settings-layout-C_sqrv5S.js +1 -0
- package/dist/assets/share-feedback-modal-Cg8gci5A.js +1 -0
- package/dist/assets/{sidebar-tree-DyEHuZeN.js → sidebar-tree-Cme65q7r.js} +1 -1
- package/dist/assets/{signup-page-BTfxDffn.js → signup-page-BBM_CboU.js} +1 -1
- package/dist/assets/skills-page-J6mZv9bN.js +1 -0
- package/dist/assets/{sounds-page-CkLyWMqe.js → sounds-page-DpRhAAJv.js} +1 -1
- package/dist/assets/{step-indicator-dots-BjA1nnWA.js → step-indicator-dots-Dmj2aMuo.js} +1 -1
- package/dist/assets/{subagent-detail-panel-4B8mdN25.js → subagent-detail-panel-Dq-GDI61.js} +2 -2
- package/dist/assets/system-events-page-DNln669W.js +1 -0
- package/dist/assets/system-events-redirect-page-DY7BhERh.js +1 -0
- package/dist/assets/{tiptap-document-editor-D_JJ-i8w.js → tiptap-document-editor-DucA37Km.js} +1 -1
- package/dist/assets/tool-detail-panel-CwQTuANT.js +1 -0
- package/dist/assets/trace-page-CKTCZonQ.js +1 -0
- package/dist/assets/upgrade-cancel-page-BsW23ioD.js +1 -0
- package/dist/assets/upgrade-success-page-DqSBwFJv.js +1 -0
- package/dist/assets/{usage-page-DTCDhatY.js → usage-page-D6cPGTNn.js} +1 -1
- package/dist/assets/{use-current-platform-assistant-4FcCb-TC.js → use-current-platform-assistant-Cu95G65M.js} +1 -1
- package/dist/assets/use-is-org-ready-IPLcsl77.js +1 -0
- package/dist/assets/{use-oauth-complete-deep-link-listener-DODuMYm6.js → use-oauth-complete-deep-link-listener-BQZGv8sr.js} +1 -1
- package/dist/assets/{use-onboarding-login-CEqnm099.js → use-onboarding-login-Cd72-1Qe.js} +1 -1
- package/dist/assets/voice-page-D8IZifkA.js +1 -0
- package/dist/assets/{weather-forecast-display-CEt-zNG2.js → weather-forecast-display-DgqpUX3a.js} +1 -1
- package/dist/assets/{welcome-screen-3Gi6zm9f.js → welcome-screen-B2tizoBp.js} +1 -1
- package/dist/assets/workspace-page-Bu8beso_.js +1 -0
- package/dist/index.html +5 -5
- package/package.json +1 -1
- package/dist/assets/add-credits-modal-D1PUmkv8.js +0 -1
- package/dist/assets/ai-page-BHdzWA1C.js +0 -1
- package/dist/assets/auth-store-oleg80LZ.js +0 -6
- package/dist/assets/billing-page-BtGA4D1N.js +0 -34
- package/dist/assets/contacts-page-route-CIhz_sJO.js +0 -1
- package/dist/assets/danger-zone-redirect-page-BOK4eL8M.js +0 -1
- package/dist/assets/debug-page-EPqbjJSc.js +0 -3
- package/dist/assets/deploy-dialogs-DlIjxp-4.js +0 -1
- package/dist/assets/devices-page-CjKo24zw.js +0 -1
- package/dist/assets/general-page-BSf6qSem.js +0 -1
- package/dist/assets/home-page-route-D3PEij2C.js +0 -1
- package/dist/assets/identity-page-route-MDSvMuG9.js +0 -1
- package/dist/assets/index-DM63H2B6.js +0 -124
- package/dist/assets/integrations-page-DKhH4frU.js +0 -1
- package/dist/assets/library-detail-page-T4MedcS4.js +0 -1
- package/dist/assets/library-page-RtbQs7L5.js +0 -1
- package/dist/assets/notifications-page-DlDftqR1.js +0 -1
- package/dist/assets/password-reset-page-DyimUxBH.js +0 -1
- package/dist/assets/pre-chat-flow-BDhreJ7B.js +0 -1
- package/dist/assets/privacy-page-C1kpEJg_.js +0 -1
- package/dist/assets/routes-DMbyM_oF.js +0 -1
- package/dist/assets/schedules-page-DL7EfeDQ.js +0 -1
- package/dist/assets/select-assistant-screen-BGPc4tCz.js +0 -1
- package/dist/assets/settings-layout-Ce4VYURq.js +0 -1
- package/dist/assets/share-feedback-modal-le4GoR2Z.js +0 -1
- package/dist/assets/skills-page-D_8aU82C.js +0 -1
- package/dist/assets/system-events-page-BuSkwmMl.js +0 -1
- package/dist/assets/system-events-redirect-page-Dq56rHVE.js +0 -1
- package/dist/assets/tool-detail-panel-WvA0b4nW.js +0 -1
- package/dist/assets/trace-page-Ckyukuwf.js +0 -1
- package/dist/assets/upgrade-cancel-page-C_KXGnp0.js +0 -1
- package/dist/assets/upgrade-success-page-yvoI0p_k.js +0 -1
- package/dist/assets/use-is-org-ready-tTrrZoWV.js +0 -1
- package/dist/assets/voice-page-pG9E3NoZ.js +0 -1
- package/dist/assets/workspace-page-DNw6D4Sj.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{T as n}from"./portal-container-DIXEBWUe.js";import{n as r}from"./QueryClientProvider-DNHWXaGq.js";import{t as i}from"./useQuery-D2zf6Uhu.js";import{t as a}from"./useMutation-BuofVRHk.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./queryOptions-BtNi-_9H.js";import{t as c}from"./button-DdEh-9f_.js";import{n as l,r as u,t as d}from"./panel-item-FzMfzMJA.js";import{t as f}from"./input-Cu3PPVCq.js";import{t as p}from"./createLucideIcon-D6d6iDdi.js";import{t as m}from"./chevron-right-zTNPbA1m.js";import{t as h}from"./loader-circle-BSAFLoPH.js";import{t as g}from"./pencil-BA9LOIzP.js";import{t as _}from"./x-BDqbYVtS.js";import{Gn as v,Kn as y,Un as b,Wn as x,qn as S}from"./sdk.gen-AJllUeDf.js";import{n as C}from"./use-is-mobile-D_xrnINF.js";import{Ba as w,Ei as T,Ia as E,Ja as D,La as O,Pa as k,Ra as A,Va as j,Wa as M,Yi as N,ka as P,mo as F,na as I,po as ee}from"./index-BjEJFZTJ.js";import{t as te}from"./use-active-assistant-id-BIhArlF_.js";import{n as L,t as ne}from"./mobile-sidebar-drawer-BjPgVWjw.js";import{n as re,t as ie}from"./file-markdown-DX5x9ziL.js";import{t as R}from"./format-file-size-Cx-rVS-D.js";var ae=p(`arrow-down-a-z`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M20 8h-5`,key:`1vsyxs`}],[`path`,{d:`M15 10V6.5a2.5 2.5 0 0 1 5 0V10`,key:`ag13bf`}],[`path`,{d:`M15 14h5l-5 6h5`,key:`ur5jdg`}]]),oe=p(`arrow-down-wide-narrow`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M11 4h10`,key:`1w87gc`}],[`path`,{d:`M11 8h7`,key:`djye34`}],[`path`,{d:`M11 12h4`,key:`q8tih4`}]]),se=p(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),z=p(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),B=e(t(),1);function ce(e){if(!e)return``;let t=e.indexOf(`;`);return(t===-1?e:e.slice(0,t)).trim()}function le(e,t){return ce(t)===`application/json`?!0:(e??``).toLowerCase().endsWith(`.json`)}function ue(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}var V=o();function H(e){return s({queryFn:async()=>{let{data:t,error:n}=await x({path:e.path,query:{path:e.query.path,...e.query.showHidden?{showHidden:`true`}:{}}});if(n)throw n;return t},queryKey:[`assistantsWorkspaceFileRetrieve`,e]})}function U({mimeType:e}){let t=e.indexOf(`;`),n=(t===-1?e:e.slice(0,t)).trim(),r=O;return n.startsWith(`image/`)?r=P:n.startsWith(`video/`)?r=T:!n.startsWith(`text/`)&&n!==`application/json`&&n!==`application/octet-stream`&&(r=E),(0,V.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 10%, transparent)`},children:(0,V.jsx)(r,{className:`h-3.5 w-3.5`,style:{color:`var(--content-default)`}})})}function W({viewMode:e,onChange:t}){return(0,V.jsx)(`div`,{className:`inline-flex rounded-md p-0.5`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 6%, transparent)`},children:[`preview`,`source`].map(n=>{let r=e===n;return(0,V.jsx)(c,{variant:`ghost`,onClick:()=>t(n),className:`h-auto rounded border-0 px-2.5 py-1 text-body-small-default hover:bg-transparent`,style:{backgroundColor:r?`var(--surface-lift)`:`transparent`,color:r?`var(--content-default)`:`var(--content-tertiary)`,boxShadow:r?`0 1px 2px rgba(0,0,0,0.15)`:void 0},children:n===`preview`?`Preview`:`Source`},n)})})}function G({name:e,mimeType:t,size:n,rightContent:r}){return(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(U,{mimeType:t}),(0,V.jsx)(`span`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),n!=null&&(0,V.jsx)(`span`,{className:`shrink-0 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:R(n)})]}),r]})}function de({assistantId:e,path:t,mimeType:n,showHidden:r}){let{data:a,isLoading:o}=i({queryFn:async()=>{let n=await b({path:{assistant_id:e},query:{path:t,...r?{showHidden:`true`}:{}},parseAs:`blob`});if(n.error)throw n.error;return n.data},queryKey:[`assistantsWorkspaceFileContentRetrieve`,{assistantId:e,path:t,showHidden:r}],enabled:!!t}),[s,c]=(0,B.useState)(null);return(0,B.useEffect)(()=>{if(!a)return;let e=URL.createObjectURL(a);return c(e),()=>{URL.revokeObjectURL(e),c(null)}},[a]),o?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,V.jsx)(h,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):s?n.startsWith(`image/`)?(0,V.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,V.jsx)(`img`,{src:s,alt:t.split(`/`).pop()??`image`,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n.startsWith(`video/`)?(0,V.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,V.jsx)(`video`,{src:s,controls:!0,className:`max-h-[70vh] max-w-full rounded`})}):null:null}function fe(e){return e.split(`/`).some(e=>e.startsWith(`.`))}function pe({isDirty:e,isSaving:t,onSave:n,onDiscard:r}){return(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t px-3 py-2`,style:{borderColor:`var(--border-element)`},children:[(0,V.jsx)(c,{variant:`ghost`,size:`compact`,disabled:t,onClick:r,children:`Discard`}),t&&(0,V.jsx)(h,{className:`h-4 w-4 animate-spin`,style:{color:`var(--content-tertiary)`}}),(0,V.jsx)(c,{variant:`primary`,size:`compact`,disabled:!e||t,onClick:n,children:`Save`})]})}function K({content:e,downloadContent:t,fileName:n,mimeType:r,showEdit:i,isEditing:a,onToggleEdit:o}){let[s,l]=(0,B.useState)(!1),u=(0,B.useRef)(null),d=(0,B.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),1500)})},[e]),f=t??e,p=(0,B.useCallback)(()=>{let e=new Blob([f],{type:r}),t=URL.createObjectURL(e),i=document.createElement(`a`);i.href=t,i.download=n,i.click(),URL.revokeObjectURL(t)},[f,n,r]);return(0,B.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]),a?null:(0,V.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex items-center gap-1 rounded-md bg-[var(--surface-primary)] shadow-sm`,children:[i&&(0,V.jsx)(c,{variant:`ghost`,size:`regular`,iconOnly:(0,V.jsx)(g,{"aria-hidden":!0}),onClick:o,"aria-label":`Edit file`,className:`hover:bg-[var(--surface-base)]`}),(0,V.jsx)(c,{variant:`ghost`,size:`regular`,iconOnly:s?(0,V.jsx)(F,{"aria-hidden":!0}):(0,V.jsx)(D,{"aria-hidden":!0}),onClick:d,"aria-label":s?`Copied`:`Copy file contents`,className:`hover:bg-[var(--surface-base)]`}),(0,V.jsx)(c,{variant:`ghost`,size:`regular`,iconOnly:(0,V.jsx)(M,{"aria-hidden":!0}),onClick:p,"aria-label":`Download file`,className:`hover:bg-[var(--surface-base)]`})]})}var q=`ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace`;function J({value:e,onChange:t,onSave:n}){return(0,V.jsx)(`textarea`,{className:`m-0 h-full w-full resize-none overflow-auto border-none bg-transparent p-4 text-body-medium-lighter leading-relaxed outline-none`,style:{color:`var(--content-default)`,fontFamily:q},value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),n())},spellCheck:!1})}function Y({content:e,readOnly:t,whiteSpace:n=`pre-wrap`,onStartEdit:r}){return(0,V.jsx)(`pre`,{className:`m-0 h-full overflow-auto p-4 text-body-medium-lighter leading-relaxed${t?``:` cursor-text`}`,style:{color:`var(--content-default)`,fontFamily:q,whiteSpace:n},onClick:t?void 0:r,children:e})}function me({assistantId:e,selectedPath:t,showHidden:n,viewMode:o,onChangeViewMode:s,onBrowse:l}){let u=r(),{data:d,isLoading:f}=i({...H({path:{assistant_id:e},query:{path:t??``,showHidden:n}}),enabled:!!t}),[p,m]=(0,B.useState)(null),[g,_]=(0,B.useState)(null),v=p!=null&&p===t,y=d?.content??``,b=g?.path===t?g.content:y,x=()=>{m(null),_(null)},C=a({mutationFn:async({path:t,content:n})=>{let{error:r,response:i}=await S({path:{assistant_id:e},body:{path:t,content:n,encoding:`utf8`},throwOnError:!1});if(!i?.ok||r)throw Error(`Failed to save file`)},onSuccess:(e,t)=>{m(e=>e===t.path?null:e),_(e=>e?.path===t.path?null:e),u.invalidateQueries({queryKey:[`assistantsWorkspaceFileRetrieve`]})}}),w=b!==y,T=(0,B.useCallback)(()=>{t&&w&&!C.isPending&&C.mutate({path:t,content:b})},[t,w,C,b]);if(!t)return(0,V.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3`,children:[(0,V.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view`}),l&&(0,V.jsx)(c,{type:`button`,onClick:l,leftIcon:(0,V.jsx)(se,{"aria-hidden":!0}),className:`sm:hidden`,children:`Browse files`})]});if(f)return(0,V.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,V.jsx)(h,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})});if(!d)return(0,V.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,V.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`File not found`})});let D=d.mimeType??`application/octet-stream`,O=d.name??t.split(`/`).pop()??t,k=re(O,D),A=le(O,D),j=d.content!=null&&!k&&!A,M=t?fe(t):!0,N=v&&(0,V.jsx)(pe,{isDirty:w,isSaving:C.isPending,onSave:T,onDiscard:x});if(k&&d.content!=null){let e=v?b:d.content;return(0,V.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,V.jsx)(G,{name:O,mimeType:D,rightContent:(0,V.jsx)(W,{viewMode:o,onChange:e=>{v&&x(),s(e)}})}),(0,V.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,V.jsx)(K,{content:e,fileName:O,mimeType:D,showEdit:!M&&o===`source`,isEditing:v,onToggleEdit:()=>v?x():m(t)}),o===`preview`?(0,V.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:(0,V.jsx)(ie,{content:e})}):v?(0,V.jsx)(J,{value:b,onChange:e=>_({path:t,content:e}),onSave:T}):(0,V.jsx)(Y,{content:d.content,readOnly:M,onStartEdit:()=>m(t)})]}),N]})}if(A&&d.content!=null){let e=v?b:d.content,n=ue(e);return(0,V.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,V.jsx)(G,{name:O,mimeType:D,rightContent:(0,V.jsx)(W,{viewMode:o,onChange:e=>{v&&x(),s(e)}})}),(0,V.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,V.jsx)(K,{content:o===`preview`?n:e,downloadContent:e,fileName:O,mimeType:D,showEdit:!M&&o===`source`,isEditing:v,onToggleEdit:()=>v?x():m(t)}),o===`preview`?(0,V.jsx)(Y,{content:n,readOnly:!0,whiteSpace:`pre`}):v?(0,V.jsx)(J,{value:b,onChange:e=>_({path:t,content:e}),onSave:T}):(0,V.jsx)(Y,{content:d.content,readOnly:M,onStartEdit:()=>m(t)})]}),N]})}return j?(0,V.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,V.jsx)(G,{name:O,mimeType:D,size:d.size}),(0,V.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,V.jsx)(K,{content:v?b:d.content??``,fileName:O,mimeType:D,showEdit:!M,isEditing:v,onToggleEdit:()=>v?x():m(t)}),v?(0,V.jsx)(J,{value:b,onChange:e=>_({path:t,content:e}),onSave:T}):(0,V.jsx)(Y,{content:d.content??``,readOnly:M,onStartEdit:()=>m(t)})]}),N]}):D.startsWith(`image/`)||D.startsWith(`video/`)?(0,V.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,V.jsx)(G,{name:O,mimeType:D,size:d.size}),(0,V.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,V.jsx)(de,{assistantId:e,path:t,mimeType:D,showHidden:n})})]}):(0,V.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,V.jsx)(G,{name:O,mimeType:D,size:d.size}),(0,V.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg border p-6 text-center`,style:{borderColor:`var(--border-base)`,backgroundColor:`var(--surface-lift)`},children:[(0,V.jsx)(E,{className:`mx-auto h-10 w-10`,style:{color:`var(--content-tertiary)`}}),(0,V.jsx)(`p`,{className:`mt-3 text-body-medium-default`,style:{color:`var(--content-default)`},children:O}),(0,V.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,V.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:D}),(0,V.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:R(d.size,`Unknown size`)}),d.modifiedAt&&(0,V.jsxs)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:[`Modified: `,new Date(d.modifiedAt).toLocaleString()]})]})]})})]})}var he=e(n(),1);function X(e,t){if(t===`name`)return e;let n=e.slice();return n.sort((e,t)=>{let n=e.size??null,r=t.size??null;return n===null&&r===null?(e.name??``).localeCompare(t.name??``):n===null?1:r===null?-1:n===r?(e.name??``).localeCompare(t.name??``):r-n}),n}function Z(e){return s({queryFn:async()=>{let t={};e.query?.path&&(t.path=e.query.path),e.query?.showHidden&&(t.showHidden=`true`),e.query?.includeDirSizes&&(t.includeDirSizes=`true`);let{data:n,error:r}=await y({path:e.path,query:t});if(r)throw r;if(!n)throw Error(`Failed to load workspace tree`);return n},queryKey:[`assistantsWorkspaceTreeRetrieve`,e]})}function ge({entry:e}){return e.type===`directory`?(0,V.jsx)(k,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`image/`)?(0,V.jsx)(P,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`video/`)?(0,V.jsx)(T,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,V.jsx)(O,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}})}function Q({entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:a,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,depth:u}){let d=e.path??``,f=e.name??``,p=e.type===`directory`,h=n.has(d),g=r===d,_=f.startsWith(`.`),v=p&&(h||s.length>0),{data:y}=i({...Z({path:{assistant_id:t},query:{path:d,showHidden:a,includeDirSizes:o===`size`}}),enabled:p&&v}),b=(0,B.useMemo)(()=>X(y?.entries??[],o),[y?.entries,o]),x=s===``||f.toLowerCase().includes(s);return s!==``&&!p&&!x?null:(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`button`,{onClick:()=>{p?c(d):l(d)},className:`group flex w-full items-center gap-1.5 px-2 py-1 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{paddingLeft:`${u*14+8}px`,paddingRight:`8px`,color:g?`var(--content-default)`:_?`var(--content-tertiary)`:`var(--content-default)`,backgroundColor:g?`color-mix(in oklab, var(--primary-base) 12%, transparent)`:void 0,opacity:_&&!g?.7:1},children:[p?v?(0,V.jsx)(ee,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,V.jsx)(m,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,V.jsx)(`span`,{className:`h-3 w-3 shrink-0`}),(0,V.jsx)(ge,{entry:e}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:f}),e.size!=null&&(0,V.jsx)(`span`,{className:`shrink-0 text-label-medium-default tabular-nums`,style:{color:`var(--content-tertiary)`},children:R(e.size)})]}),p&&v&&b.length>0&&(0,V.jsx)(`div`,{children:b.map(e=>(0,V.jsx)(Q,{entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:a,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,depth:u+1},e.path))})]})}function _e({kind:e,onCancel:t,onConfirm:n,pending:r,error:i}){let[a,o]=(0,B.useState)(``),s=a.trim(),l=s.length>0&&!r;return(0,he.createPortal)((0,V.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onKeyDown:e=>{e.key===`Escape`&&t()},onClick:e=>{e.target===e.currentTarget&&t()},children:(0,V.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),l&&n(s)},className:`mx-4 w-full max-w-sm rounded-xl border p-5 shadow-xl`,style:{backgroundColor:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:[(0,V.jsx)(`h2`,{className:`mb-3 text-title-small`,style:{color:`var(--content-default)`},children:e===`file`?`New File`:`New Folder`}),(0,V.jsx)(f,{autoFocus:!0,type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:e===`file`?`filename.md`:`folder-name`,errorText:i??void 0,fullWidth:!0,wrapperClassName:`mb-3`,autoComplete:`off`,spellCheck:!1}),(0,V.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,V.jsx)(c,{type:`button`,variant:`outlined`,onClick:t,disabled:r,children:`Cancel`}),(0,V.jsx)(c,{type:`submit`,disabled:!l,children:r?`Creating…`:`Create`})]})]})}),document.body)}function $({assistantId:e,expandedPaths:t,selectedPath:n,showHidden:o,sortMode:s,onToggleExpand:l,onExpandPath:u,onSelectPath:d,onToggleShowHidden:p,onChangeSortMode:m}){let h=r(),[g,y]=(0,B.useState)(``),b=g.trim().toLowerCase(),[x,C]=(0,B.useState)(!1),[T,E]=(0,B.useState)(null),[D,O]=(0,B.useState)(null),{data:k,isLoading:A}=i(Z({path:{assistant_id:e},query:{showHidden:o,includeDirSizes:s===`size`}})),M=(0,B.useMemo)(()=>X(k?.entries??[],s),[k?.entries,s]),P=(0,B.useCallback)(()=>{h.invalidateQueries({queryKey:[`assistantsWorkspaceTreeRetrieve`]})},[h]),F=a({mutationFn:async t=>{let{error:n,response:r}=t.kind===`file`?await S({path:{assistant_id:e},body:{path:t.name,content:``,encoding:`utf8`},throwOnError:!1}):await v({path:{assistant_id:e},body:{path:t.name},throwOnError:!1});if(n||!r?.ok)throw Error(typeof n==`string`?n:`Failed to create — check the name and try again.`);return t},onSuccess:e=>{E(null),O(null),P(),e.kind===`file`?d(e.name):u(e.name)},onError:e=>{O(e instanceof Error?e.message:`Failed to create.`)}}),I=(0,B.useCallback)(e=>{T&&(O(null),F.mutate({kind:T,name:e}))},[T,F]);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,V.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:`Files`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,V.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:s===`size`?(0,V.jsx)(oe,{"aria-hidden":!0}):(0,V.jsx)(ae,{"aria-hidden":!0}),onClick:()=>m(s===`size`?`name`:`size`),"aria-label":s===`size`?`Sort by name`:`Sort by size`,title:s===`size`?`Sorted by size — switch to name`:`Sorted by name — switch to size`,tintColor:s===`size`?`var(--content-default)`:`var(--content-tertiary)`}),(0,V.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:o?(0,V.jsx)(w,{"aria-hidden":!0}):(0,V.jsx)(j,{"aria-hidden":!0}),onClick:p,"aria-label":o?`Hide hidden files`:`Show hidden files`,title:o?`Hide hidden files`:`Show hidden files`,tintColor:o?`var(--content-default)`:`var(--content-tertiary)`}),(0,V.jsx)(ve,{open:x,onOpenChange:C,onSelectKind:e=>{C(!1),O(null),E(e)}})]})]}),(0,V.jsx)(`div`,{className:`px-3 py-2`,children:(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(f,{type:`text`,value:g,onChange:e=>y(e.target.value),placeholder:`Search files`,leftIcon:(0,V.jsx)(N,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0,spellCheck:!1,autoComplete:`off`}),g&&(0,V.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,V.jsx)(_,{"aria-hidden":!0}),onClick:()=>y(``),"aria-label":`Clear search`,className:`absolute right-1.5 top-1/2 -translate-y-1/2`,tintColor:`var(--content-tertiary)`})]})}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:A?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,V.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`,style:{color:`var(--content-tertiary)`}})}):M.length?M.map(r=>(0,V.jsx)(Q,{entry:r,assistantId:e,expandedPaths:t,selectedPath:n,showHidden:o,sortMode:s,searchLower:b,onToggleExpand:l,onSelectPath:d,depth:0},r.path)):(0,V.jsx)(`p`,{className:`px-3 py-4 text-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`No files found`})}),T!==null&&(0,V.jsx)(_e,{kind:T,onCancel:()=>{E(null),O(null)},onConfirm:I,pending:F.isPending,error:D},T)]})}function ve({open:e,onOpenChange:t,onSelectKind:n}){return C()?(0,V.jsxs)(l.Root,{open:e,onOpenChange:t,children:[(0,V.jsx)(l.Trigger,{asChild:!0,children:(0,V.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,V.jsx)(I,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,V.jsxs)(l.Content,{children:[(0,V.jsx)(l.Header,{className:`sr-only`,children:(0,V.jsx)(l.Title,{children:`Create new`})}),(0,V.jsxs)(l.Body,{className:`pt-0`,children:[(0,V.jsx)(d,{icon:A,label:`New File`,onSelect:()=>n(`file`)}),(0,V.jsx)(d,{icon:z,label:`New Folder`,onSelect:()=>n(`folder`)})]})]})]}):(0,V.jsxs)(u.Root,{open:e,onOpenChange:t,children:[(0,V.jsx)(u.Trigger,{asChild:!0,children:(0,V.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,V.jsx)(I,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,V.jsxs)(u.Content,{align:`end`,sideOffset:4,role:`menu`,className:`w-44 overflow-hidden p-0`,children:[(0,V.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>n(`file`),className:`w-full justify-start rounded-none`,leftIcon:(0,V.jsx)(A,{"aria-hidden":!0,style:{color:`var(--content-tertiary)`}}),role:`menuitem`,children:`New File`}),(0,V.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>n(`folder`),className:`w-full justify-start rounded-none`,leftIcon:(0,V.jsx)(z,{"aria-hidden":!0,style:{color:`var(--content-tertiary)`}}),role:`menuitem`,children:`New Folder`})]})]})}function ye({assistantId:e}){let[t,n]=(0,B.useState)(new Set),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(`name`),[l,u]=(0,B.useState)(`preview`),d=(0,B.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),f=(0,B.useCallback)(e=>{n(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),[p,m]=(0,B.useState)(!1),h={assistantId:e,expandedPaths:t,selectedPath:r,showHidden:a,sortMode:s,onToggleExpand:d,onExpandPath:f,onSelectPath:(0,B.useCallback)(e=>{i(e),m(!1)},[]),onToggleShowHidden:()=>o(e=>!e),onChangeSortMode:c};return(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-4`,children:[(0,V.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,V.jsx)(L,{onClick:()=>m(!0)})}),(0,V.jsx)(ne,{open:p,onClose:()=>m(!1),title:`Files`,children:(0,V.jsx)($,{...h})}),(0,V.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-4 sm:grid-cols-[320px_1fr]`,children:[(0,V.jsx)(`div`,{className:`hidden min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border sm:flex`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,V.jsx)($,{...h})}),(0,V.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,V.jsx)(me,{assistantId:e,selectedPath:r,showHidden:a,viewMode:l,onChangeViewMode:u,onBrowse:()=>m(!0)})})]})]})}function be(){return(0,V.jsx)(ye,{assistantId:te()})}export{be as WorkspacePage};
|
package/dist/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<link rel="apple-touch-icon" href="/assistant/favicon.svg" />
|
|
11
11
|
<title>Vellum Assistant</title>
|
|
12
12
|
<script src="/assistant/theme-init.js"></script>
|
|
13
|
-
<script type="module" crossorigin src="/assistant/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assistant/assets/index-BjEJFZTJ.js"></script>
|
|
14
14
|
<link rel="modulepreload" crossorigin href="/assistant/assets/chunk-jRWAZmH_.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assistant/assets/preload-helper-BewR0kVT.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assistant/assets/dist-B4KYfSON.js">
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
<link rel="modulepreload" crossorigin href="/assistant/assets/minimize-2-CXA_X5M9.js">
|
|
74
74
|
<link rel="modulepreload" crossorigin href="/assistant/assets/pencil-BA9LOIzP.js">
|
|
75
75
|
<link rel="modulepreload" crossorigin href="/assistant/assets/x-BDqbYVtS.js">
|
|
76
|
-
<link rel="modulepreload" crossorigin href="/assistant/assets/chunk-5KNZJZUH-
|
|
76
|
+
<link rel="modulepreload" crossorigin href="/assistant/assets/chunk-5KNZJZUH-DdS6bb-3.js">
|
|
77
77
|
<link rel="modulepreload" crossorigin href="/assistant/assets/misc-MEUnNRwX.js">
|
|
78
78
|
<link rel="modulepreload" crossorigin href="/assistant/assets/impersonate-version-flag-DXEwev6c.js">
|
|
79
79
|
<link rel="modulepreload" crossorigin href="/assistant/assets/assistant-identity-store-dQ1LxIr0.js">
|
|
@@ -82,13 +82,13 @@
|
|
|
82
82
|
<link rel="modulepreload" crossorigin href="/assistant/assets/avatar-api-BwHmtSnS.js">
|
|
83
83
|
<link rel="modulepreload" crossorigin href="/assistant/assets/event-bus-CMBsMREI.js">
|
|
84
84
|
<link rel="modulepreload" crossorigin href="/assistant/assets/device-settings-C07QvMzm.js">
|
|
85
|
-
<link rel="modulepreload" crossorigin href="/assistant/assets/routes-
|
|
86
|
-
<link rel="modulepreload" crossorigin href="/assistant/assets/auth-store-
|
|
85
|
+
<link rel="modulepreload" crossorigin href="/assistant/assets/routes-Dk5Qeryt.js">
|
|
86
|
+
<link rel="modulepreload" crossorigin href="/assistant/assets/auth-store-CiQCAKS1.js">
|
|
87
87
|
<link rel="modulepreload" crossorigin href="/assistant/assets/google-logo-mNxCGWd3.js">
|
|
88
88
|
<link rel="modulepreload" crossorigin href="/assistant/assets/react-query.gen-B8xaBreR.js">
|
|
89
89
|
<link rel="modulepreload" crossorigin href="/assistant/assets/use-bus-subscription-BuU6xaZz.js">
|
|
90
90
|
<link rel="modulepreload" crossorigin href="/assistant/assets/use-is-mobile-D_xrnINF.js">
|
|
91
|
-
<link rel="modulepreload" crossorigin href="/assistant/assets/use-is-org-ready-
|
|
91
|
+
<link rel="modulepreload" crossorigin href="/assistant/assets/use-is-org-ready-IPLcsl77.js">
|
|
92
92
|
<link rel="modulepreload" crossorigin href="/assistant/assets/feature-flag-catalog-D6XoH2hm.js">
|
|
93
93
|
<link rel="modulepreload" crossorigin href="/assistant/assets/query-tags-Cez88bzY.js">
|
|
94
94
|
<link rel="modulepreload" crossorigin href="/assistant/assets/native-file-CS-pobfT.js">
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./chunk-jRWAZmH_.js";import{t as n}from"./react-DJZBPgpf.js";import{m as r,t as i,u as a}from"./chunk-5KNZJZUH-B4b1m-Ya.js";import{n as o}from"./QueryClientProvider-DNHWXaGq.js";import{t as s}from"./useQuery-D2zf6Uhu.js";import{t as c}from"./useMutation-BuofVRHk.js";import{t as l}from"./jsx-runtime-CVSDxk6A.js";import{t as u}from"./button-DdEh-9f_.js";import{t as d}from"./dropdown-CocFV5yi.js";import{t as f}from"./modal-BYMhDpQo.js";import{t as p}from"./loader-circle-BSAFLoPH.js";import{Ga as m,et as h,gn as g,tt as _,uo as v,vn as y}from"./index-DM63H2B6.js";var b=t({AddCreditsModal:()=>E}),x=e(n(),1),S=l(),C=[`10.00`,`20.00`,`30.00`,`40.00`,`50.00`,`60.00`,`70.00`,`80.00`,`90.00`,`100.00`];function w(e){let t=parseFloat(e);if(Number.isNaN(t))return`0 credits`;let n=t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2});return`${n.endsWith(`.00`)?n.slice(0,-3):n} credits`}function T(e){if(e&&typeof e==`object`){let t=e.amount;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0]}return`Failed to create checkout session. Please try again.`}function E({open:e,onOpenChange:t}){let n=o(),{pathname:l}=a(),[b]=r(),E=b.toString()?`${l}?${b.toString()}`:l,{data:D,isLoading:O}=s(g()),k=D?.allowed_top_up_amounts?.length?D.allowed_top_up_amounts:C,[A,j]=(0,x.useState)(null),M=A&&k.includes(A)?A:k[0]??C[0],N=c(y());return(0,x.useEffect)(()=>_(()=>{t(!1),n.invalidateQueries(g())}),[t,n]),(0,S.jsx)(f.Root,{open:e,onOpenChange:t,children:(0,S.jsxs)(f.Content,{size:`sm`,children:[(0,S.jsxs)(f.Header,{children:[(0,S.jsx)(f.Title,{icon:m,children:`Add Credits`}),(0,S.jsx)(f.Description,{children:`Purchase credits to continue using the assistant. You'll be redirected to Stripe to complete the payment.`})]}),(0,S.jsx)(f.Body,{children:(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`add-credits-amount`,className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Amount`}),(0,S.jsx)(d,{id:`add-credits-amount`,value:M,onChange:e=>{j(e),N.isError&&N.reset()},disabled:O||!D,options:k.map(e=>({value:e,label:w(e)}))})]}),N.isError&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,S.jsx)(v,{className:`h-3.5 w-3.5 shrink-0`}),T(N.error)]}),(0,S.jsx)(i,{to:`/assistant/settings/billing`,className:`text-body-small-default text-[var(--content-tertiary)] underline hover:text-[var(--content-secondary)]`,onClick:()=>t(!1),children:`Configure Automatic Top-Ups →`})]})}),(0,S.jsxs)(f.Footer,{children:[(0,S.jsx)(f.Close,{asChild:!0,children:(0,S.jsx)(u,{variant:`outlined`,children:`Cancel`})}),(0,S.jsx)(u,{variant:`primary`,leftIcon:N.isPending?(0,S.jsx)(p,{className:`animate-spin`}):void 0,onClick:()=>{N.isPending||N.mutate({body:{amount:M,return_path:E}},{onSuccess:e=>{h(e.checkout_url)}})},disabled:N.isPending||O||!D,children:`Add credits`})]})]})})}export{b as n,E as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,r as n,s as r}from"./local-settings-lVNyIOJ_.js";import{r as i,t as a}from"./capture-error-CZsNGL6n.js";import{t as o}from"./react-DJZBPgpf.js";import{d as s,m as c}from"./chunk-5KNZJZUH-B4b1m-Ya.js";import{n as l}from"./QueryClientProvider-DNHWXaGq.js";import{t as u}from"./useQuery-D2zf6Uhu.js";import{t as d}from"./useMutation-BuofVRHk.js";import{t as f}from"./jsx-runtime-CVSDxk6A.js";import{t as p}from"./button-DdEh-9f_.js";import{t as m}from"./typography-Czgs_2w_.js";import{t as h}from"./dropdown-CocFV5yi.js";import{t as g}from"./confirm-dialog-NYG-K9zN.js";import{t as _}from"./notice-CF2pptne.js";import{t as v}from"./tag-Ccr7Quy6.js";import{t as y}from"./input-Cu3PPVCq.js";import{t as b}from"./toggle-CEm3M86o.js";import{n as x}from"./stat-square-sRJmexc-.js";import{t as S}from"./modal-BYMhDpQo.js";import{n as C}from"./toast-DU1nH33j.js";import{t as w}from"./createLucideIcon-D6d6iDdi.js";import{n as T,t as E}from"./domain-field-cWBlWR4h.js";import{t as D}from"./external-link-BCB1rbW9.js";import{t as O}from"./loader-circle-BSAFLoPH.js";import{C as k,Et as A,Jt as j,Sn as M,Tt as N,Y as P,b as F}from"./sdk.gen-AJllUeDf.js";import{C as I,R as L,S as R,s as ee}from"./react-query.gen-B8xaBreR.js";import{r as z}from"./api-errors-ChauV4ed.js";import{i as te}from"./routes-DMbyM_oF.js";import{t as B}from"./use-is-org-ready-tTrrZoWV.js";import{r as V}from"./query-tags-Cez88bzY.js";import{t as H}from"./assistant-feature-flag-store-0382ImYF.js";import{t as U}from"./assistant-identity-store-dQ1LxIr0.js";import{$r as W,Ar as G,At as ne,Br as K,Ct as re,Dr as q,Dt as ie,Ea as J,Er as ae,Et as oe,Fr as Y,Gr as se,Hr as X,Ir as ce,Ji as le,Jr as ue,Kr as de,Lr as fe,Mi as pe,Mr as me,Nr as he,Or as ge,Ot as _e,Pr as ve,Qr as ye,Rr as be,St as xe,Tr as Se,Tt as Ce,Ur as we,Vr as Te,Wr as Ee,Xr as De,Yr as Oe,Zr as ke,_i as Ae,ai as je,bt as Me,ci as Ne,co as Pe,di as Fe,ei as Ie,fi as Le,fn as Re,ft as ze,gi as Be,hi as Ve,ii as He,io as Ue,ir as We,jr as Ge,jt as Ke,kr as qe,li as Je,mi as Ye,ni as Xe,oi as Ze,pi as Qe,po as $e,qr as et,ri as tt,si as nt,ti as rt,ui as it,uo as at,vi as ot,vt as st,wt as ct,xt as lt,yi as ut,yt as dt,zr as ft}from"./index-DM63H2B6.js";import{t as pt}from"./use-active-assistant-id-BIhArlF_.js";import{t as mt}from"./detail-card-B5j4Rqau.js";var ht=w(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Z=e(o(),1),Q=f();function gt({mode:e,onChange:t}){return(0,Q.jsx)(`div`,{className:`max-w-[280px]`,children:(0,Q.jsx)(x,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function _t({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,Q.jsxs)(mt,{id:e,title:t,subtitle:n,accessory:(0,Q.jsx)(gt,{mode:r,onChange:i}),children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:a})]})}function $({onClick:e,disabled:t}){return(0,Q.jsx)(p,{onClick:e,disabled:t,children:`Save`})}function vt({onClick:e,filled:t=!1}){return(0,Q.jsx)(p,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function yt({id:e,title:t,subtitle:n,children:r}){return(0,Q.jsxs)(mt,{id:e,title:t,subtitle:n,children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:r})]})}function bt({guide:e}){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(J,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{children:e.description}),(0,Q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[e.linkLabel,(0,Q.jsx)(D,{className:`h-3 w-3`})]})]})]})}function xt({status:e,message:t,isLoading:n}){return n?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,children:[(0,Q.jsx)(O,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-positive-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,title:`DNS records have been verified. Your domain is ready to send and receive email.`,children:[(0,Q.jsx)($e,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-mid-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-mid-strong)]`,title:`DNS records have been provisioned. Waiting for the email provider to verify them — this usually takes a few minutes.`,children:[(0,Q.jsx)(Ue,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-negative-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,title:`Domain verification failed. DNS records may not have propagated correctly. You could try releasing and re-registering the domain.`,children:[(0,Q.jsx)(at,{className:`h-3 w-3`}),`Verification failed`]}):(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,title:`Unable to retrieve domain verification status.`,children:`Unknown status`})}var St=`__custom__`;function Ct(e){return e?!!(e.profile||e.provider||e.model):!1}function wt(e,t){let n=Ct(e);return n===Ct(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function Tt({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,onDraftChange:o,onToggle:s}){let c=Ct(i),l=!i||!c?``:i.provider||i.model?St:i.profile??``,u=l===St,d=i?.provider??Xe[0],f=ot(d??`anthropic`).map(e=>({value:e.id,label:e.displayName})),p=!!i?.provider&&!i?.model;function m(t){if(t===`__custom__`){let t=Xe[0];o(e,{profile:null,provider:t,model:Ae(t)??``})}else t===``?o(e,null):o(e,{profile:t,provider:null,model:null})}function g(t){let n=Ae(t)??``;o(e,{...i??{},profile:null,provider:t,model:n})}function _(t){o(e,{...i??{},model:t})}return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,Q.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,Q.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c&&(0,Q.jsx)(h,{value:l,onChange:m,options:a,className:`w-36`}),(0,Q.jsx)(b,{checked:c,onChange:t=>s(e,t),"aria-label":`Override ${t}`})]})]}),c&&u&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:d??``,onChange:g,options:Xe.map(e=>({value:e,label:tt[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,Q.jsx)(h,{value:i?.model??``,onChange:_,options:f})]})]}),p&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function Et(){let e=pt();return{assistantId:e,resolveAssistantId:(0,Z.useCallback)(async()=>e,[e])}}function Dt(){let{assistantId:e}=Et(),{data:t}=u({queryKey:V(e),queryFn:async()=>{let{data:t}=await F({path:{assistant_id:e},throwOnError:!0});return t},enabled:!!e,staleTime:3e4,refetchOnWindowFocus:!1}),n=(0,Z.useMemo)(()=>t?.llm?.profiles??{},[t?.llm?.profiles]),r=(0,Z.useMemo)(()=>t?.llm?.profileOrder??[],[t?.llm?.profileOrder]),i=(0,Z.useMemo)(()=>t?.llm?.activeProfile??null,[t?.llm?.activeProfile]),a=(0,Z.useMemo)(()=>t?.llm?.callSites??{},[t?.llm?.callSites]);return{assistantId:e,config:t,profiles:n,profileOrder:r,orderedProfiles:(0,Z.useMemo)(()=>de(n,r),[n,r]),activeProfile:i,callSites:a}}function Ot(){let e=l(),{assistantId:t,resolveAssistantId:n}=Et();return d({mutationFn:async e=>{let t=await n(),{data:r}=await k({path:{assistant_id:t},body:e,throwOnError:!0});return{data:r,resolvedId:t}},onMutate:async n=>{if(!t)return;let r=V(t);await e.cancelQueries({queryKey:r});let i=e.getQueryData(r),a=i?ue(i,n):void 0;return e.setQueryData(r,e=>e&&Ee(e,n)),{rollback:a,queryKey:r}},onError:(t,n,r)=>{let{queryKey:i,rollback:a}=r??{};i&&a&&e.setQueryData(i,e=>e&&Ee(e,a))},onSettled:n=>{let r=n?.resolvedId??t;e.invalidateQueries({queryKey:V(r)})}})}function kt(){let{resolveAssistantId:e}=Et();return(0,Z.useCallback)(async(t,n)=>{try{let{data:r}=await M({path:{assistant_id:await e()},body:{value:n,type:`api_key`,name:t},throwOnError:!0});se(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?C.error(`Assistant not ready. Please try again.`):C.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}function At({isOpen:e,onClose:t,assistantId:n}){let r=(0,Z.useRef)(!1);return(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{!e&&!r.current&&t()},children:e?(0,Q.jsx)(jt,{assistantId:n,onClose:t,onSavingChange:e=>{r.current=e}}):null})}function jt({assistantId:e,onClose:t,onSavingChange:n}){let{orderedProfiles:r,callSites:i,config:o}=Dt(),s=Ot(),[c,l]=(0,Z.useState)(``),[d,f]=(0,Z.useState)({}),[m,h]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),b=H.use.analyzeConversation(),{data:x,isLoading:w,isError:T,refetch:E}=u({...ee({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),D=(0,Z.useMemo)(()=>{let e=(x?.callSites??[]).filter(e=>e.id!==`mainAgent`);return b?e:e.filter(e=>e.id!==`analyzeConversation`)},[x,b]),k=!w&&!T&&!!x&&!!o,A=(0,Z.useMemo)(()=>D.map(e=>e.id),[D]),j=(0,Z.useMemo)(()=>{if(!k)return{};let e={};for(let t of A)if(t in d)e[t]=d[t];else{let n=i[t];e[t]=n?{...n}:{}}return e},[k,A,i,d]),M=(0,Z.useMemo)(()=>new Set(A),[A]),N=(0,Z.useMemo)(()=>Object.entries(i).some(([e,t])=>M.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[i,M]),P=(0,Z.useMemo)(()=>{if(!k)return!1;for(let e of Object.keys(j))if(!wt(j[e],i[e]))return!0;return!1},[k,j,i]),F=(0,Z.useMemo)(()=>Object.values(j).some(e=>Ct(e)&&!!e?.provider&&!e?.model),[j]),I=H.use.queryComplexityRouting(),L=(0,Z.useCallback)(e=>[...K(we(r,[e]),I).map(e=>({value:e.name,label:Te(e)})),{value:St,label:`Custom`}],[r,I]),R=(0,Z.useMemo)(()=>{if(!c.trim())return D;let e=c.toLowerCase();return D.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[D,c]),z=(0,Z.useMemo)(()=>{if(!x)return[];let e=x.domains.map(e=>e.id),t=new Map(x.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=R.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=R.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[x,R]),te=(0,Z.useCallback)((e,t)=>{f(n=>({...n,[e]:t}))},[]),B=(0,Z.useCallback)((e,t)=>{if(!t){f(t=>({...t,[e]:null}));return}let n=X(r,D.find(t=>t.id===e)?.defaultProfile,I);if(n)f(t=>({...t,[e]:{profile:n}}));else{let t=Xe[0],n=Ae(t)??``;f(r=>({...r,[e]:{provider:t,model:n}}))}},[D,r,I]),V=(0,Z.useCallback)(async()=>{h(!0),n?.(!0);try{let e={};for(let t of Object.keys(j)){let n=j[t]??null;e[t]=Ct(n)?{profile:n?.profile??null,provider:n?.provider??null,model:n?.model??null}:null}await s.mutateAsync({llm:{callSites:e}}),t(),C.success(`Overrides saved.`)}catch(e){C.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{h(!1),n?.(!1)}},[j,t,s,n]),U=(0,Z.useCallback)(async()=>{h(!0),n?.(!0);try{let e={};for(let t of Object.keys(j))e[t]=null;await s.mutateAsync({llm:{callSites:e}}),t(),C.success(`Overrides reset.`)}catch(e){C.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{h(!1),n?.(!1)}},[j,t,s,n]);return(0,Q.jsxs)(S.Content,{size:`lg`,hideCloseButton:!0,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Action Overrides`}),(0,Q.jsx)(S.Description,{children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`})]}),(0,Q.jsxs)(S.Body,{children:[(0,Q.jsx)(`div`,{className:`mb-4`,children:(0,Q.jsx)(y,{type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:`Search actions…`,leftIcon:(0,Q.jsx)(le,{className:`h-4 w-4`}),fullWidth:!0})}),w&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(O,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),T&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>void E(),children:`Retry`})]}),!w&&!T&&x&&(0,Q.jsx)(`div`,{className:`space-y-4`,children:z.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):z.map(({domain:e,sites:t})=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=(()=>{let t=j[e.id]??null;return!t||!Ct(t)?``:t.provider||t.model?`__custom__`:t.profile??``})(),n=e.defaultProfile?r.find(t=>t.name===e.defaultProfile)?.label??e.defaultProfile:null;return(0,Q.jsx)(Tt,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:n,draft:j[e.id]??null,profileOptions:L(t===``||t===`__custom__`?null:t),onDraftChange:te,onToggle:B},e.id)})})]},e.id))})]}),(0,Q.jsxs)(S.Footer,{children:[N&&(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>v(!0),disabled:m||!k,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:t,disabled:m,children:`Cancel`}),(0,Q.jsx)(p,{variant:`primary`,size:`compact`,onClick:()=>void V(),disabled:!P||F||m,children:m?(0,Q.jsx)(O,{className:`h-4 w-4 animate-spin`}):`Save`})]}),(0,Q.jsx)(g,{open:_,title:`Reset to Defaults`,message:`Every task override will be reset and will follow your active profile. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{v(!1),U()},onCancel:()=>v(!1)})]})}function Mt({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let c=``;if(e){let t=e.label||e.name;c=e.isActive&&e.callSiteIds.length>0?`"${t}" is the active profile and is used by ${e.callSiteIds.length} call site(s). Pick a replacement profile.`:e.isActive?`"${t}" is the active profile. Pick a different active profile before deleting, or select a replacement below.`:`"${t}" is used by ${e.callSiteIds.length} call site(s). Select a replacement profile to reassign them before deleting.`}return(0,Q.jsx)(S.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,Q.jsxs)(S.Content,{size:`sm`,children:[(0,Q.jsx)(S.Header,{children:(0,Q.jsx)(S.Title,{children:`Can't Delete Profile`})}),(0,Q.jsxs)(S.Body,{className:`space-y-4`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`p`,children:c}),e&&e.callSiteIds.length>0&&(0,Q.jsx)(`ul`,{className:`space-y-1 pl-1`,children:e.callSiteIds.map(e=>(0,Q.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,(0,Q.jsx)(`code`,{children:e})]},e))}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Replacement profile`}),(0,Q.jsx)(h,{"aria-label":`Replacement profile`,value:n,onChange:r,options:[{value:``,label:`Select a replacement…`},...t.map(e=>({value:e.name,label:e.label??e.name}))]})]}),i&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,Q.jsxs)(S.Footer,{children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,Q.jsx)(p,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function Nt({profile:e,isDragging:t,dropTarget:n,isDeleting:r,deleteError:i,isToggling:a,onDragStart:o,onDragEnd:s,onDragOver:c,onDragLeave:l,onDrop:u,onEditClick:d,onDeleteClick:f,onStatusToggle:h}){let g=e.source===`managed`,_=e.status!==`disabled`,y=e.name===ft;return(0,Q.jsxs)(`div`,{className:`relative`,children:[n?.name===e.name&&!n.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg pr-2 py-2${t?` opacity-50`:``}`,draggable:!g,onDragStart:o,onDragEnd:s,onDragOver:c,onDragLeave:l,onDrop:u,children:[(0,Q.jsx)(ht,{className:`h-4 w-4 shrink-0 ${g?`invisible`:`cursor-grab text-[var(--content-tertiary)]`}`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1${_?``:` opacity-55`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),g&&e.name!==`auto`&&(0,Q.jsx)(v,{tone:`positive`,title:`Managed by Platform — auth is locked, but you can rename or disable this profile.`,children:`Platform`})]}),e.description?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:e.description}):null,e.model??e.provider?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:e.model??e.provider}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center`,title:_?`Active — toggle to hide from pickers`:`Disabled — toggle to show in pickers`,children:(0,Q.jsx)(b,{checked:_,onChange:e=>h(e),disabled:a,"aria-label":`${_?`Disable`:`Enable`} ${e.label??e.name}`})}),(0,Q.jsxs)(`div`,{className:`flex w-[92px] items-center justify-end gap-2${y?` invisible`:``}`,children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:d,children:g?`View`:`Edit`}),(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),"aria-label":`Delete ${e.label??e.name}`,disabled:g||r,title:g?`Managed profiles cannot be deleted`:void 0,onClick:f,tintColor:`var(--system-negative-strong)`})]})]})]}),n?.name===e.name&&n.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),i?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:i}):null,e.name===`auto`&&(0,Q.jsx)(`div`,{className:`mx-2 mt-1 border-b border-[var(--border-subtle)]`})]})}function Pt({isOpen:e,assistantId:t,onClose:n}){let{profiles:r,profileOrder:i,orderedProfiles:o,activeProfile:s,callSites:c}=Dt(),l=Ot(),d=H.use.openAICompatibleEndpoints(),f=H.use.chatgptSubscriptionAuth(),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),{data:_}=u({...R({path:{assistant_id:t}}),enabled:e}),v=(0,Z.useMemo)(()=>_?ce(_.connections,d):void 0,[_,d]),y=Object.keys(r);async function b(e,t,n){let o=n?.mode??`replace`,s=!(e in r);if(o===`merge`&&!s){await l.mutateAsync({llm:{profiles:{[e]:t}}}),m(!1),g(null);return}let c={profiles:{[e]:t}};if(s&&(c.profileOrder=i.includes(e)?i:[...i,e]),s)await l.mutateAsync({llm:c});else{let t=r[e];await l.mutateAsync({llm:{profiles:{[e]:null}}});try{await l.mutateAsync({llm:c})}catch(n){throw a(n,{context:`settings-ai-profile-edit-recreate`}),t!=null&&await l.mutateAsync({llm:{profiles:{[e]:t}}}).catch(()=>{}),n}}s&&C.success(`Profile "${t.label??e}" created`),m(!1),g(null)}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,Q.jsx)(Ft,{profiles:r,profileOrder:i,orderedProfiles:o,activeProfile:s,callSiteOverrides:c,onClose:n,onEditClick:e=>{g(e),m(!0)},onNewClick:()=>{g(null),m(!0)}}):null}),(0,Q.jsx)(Se,{isOpen:p,mode:h?h.source===`managed`?`view`:`edit`:`create`,profileName:h?.name,initialValues:h??void 0,existingNames:y,connections:v,openAICompatibleEndpointsEnabled:d,assistantId:t,chatgptSubscriptionEnabled:f,onSave:b,onCancel:()=>{m(!1),g(null)}})]})}function Ft({profiles:e,profileOrder:t,orderedProfiles:n,activeProfile:r,callSiteOverrides:i,onClose:o,onEditClick:s,onNewClick:c}){let l=Ot(),[u,d]=(0,Z.useState)({}),[f,h]=(0,Z.useState)({}),[g,_]=(0,Z.useState)(new Set),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),D=(0,Z.useRef)(null),O=(0,Z.useRef)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(!1),L=H.use.queryComplexityRouting(),R=(0,Z.useMemo)(()=>K(n,L),[n,L]);async function ee(t,n){if(g.has(t.name))return!1;_(e=>new Set(e).add(t.name)),y(null);let r=n?`active`:`disabled`;if(!e[t.name])return _(e=>{let n=new Set(e);return n.delete(t.name),n}),!1;try{return await l.mutateAsync({llm:{profiles:{[t.name]:{status:r}}}}),!0}catch(e){return a(e,{context:`settings-ai-profile-toggle`}),y(`Couldn't update "${t.label??t.name}". Please try again.`),!1}finally{_(e=>{let n=new Set(e);return n.delete(t.name),n})}}async function z(e){h(t=>({...t,[e]:!0})),d(t=>{let n={...t};return delete n[e],n});try{let n=t.filter(t=>t!==e);await l.mutateAsync({llm:{profiles:{[e]:null},profileOrder:n}})}catch(t){a(t,{context:`settings-ai-profile-delete`}),d(t=>({...t,[e]:`Failed to delete profile. Please try again.`}))}finally{h(t=>{let n={...t};return delete n[e],n})}}function te(e){let t=R.find(t=>t.name===e)?.label??e,n=e===r,a=Object.entries(i).filter(([t,n])=>t!==`mainAgent`&&n?.profile===e).map(([e])=>e);if(n||a.length>0){A({name:e,label:t,isActive:n,callSiteIds:a}),P(``),M(null);return}z(e)}async function B(){if(!k||!N)return;I(!0),M(null);let e={};if(k.isActive&&(e.activeProfile=N),k.callSiteIds.length>0){let t={};for(let e of k.callSiteIds)t[e]={profile:N};e.callSites=t}if(Object.keys(e).length>0)try{await l.mutateAsync({llm:e})}catch(e){a(e,{context:`settings-ai-profile-reassign-delete`}),M(`Failed to reassign references. Please try again.`),I(!1);return}let t=k.name;A(null),I(!1),z(t)}async function V(e,n){if(e===n.name)return;E(null);let r=t.filter(t=>t!==e),i=r.indexOf(n.name);if(i===-1)return;n.after&&(i+=1);let o=[...r.slice(0,i),e,...r.slice(i)];try{await l.mutateAsync({llm:{profileOrder:o}})}catch(e){a(e,{context:`settings-ai-profile-reorder`}),E(`Failed to reorder profiles. Please try again.`)}}let U=R.filter(e=>e.name!==k?.name&&e.source!==`managed`),W=U.length>0?U:R.filter(e=>e.name!==k?.name);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Model Profiles`}),(0,Q.jsx)(S.Description,{children:`Bundle a provider and model into a named profile. Assign profiles to specific actions or swap between them when chatting.`})]}),(0,Q.jsxs)(S.Body,{children:[R.length===0?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No profiles yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:R.map(e=>(0,Q.jsx)(Nt,{profile:e,isDragging:b===e.name,dropTarget:C,isDeleting:f[e.name]??!1,deleteError:u[e.name],isToggling:g.has(e.name),onDragStart:t=>{D.current=e.name,x(e.name),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{D.current=null,O.current=null,x(null),w(null)},onDragOver:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>n.top+n.height/2,i={name:e.name,after:r};O.current=i,w(i)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||(O.current=null,w(t=>t?.name===e.name?null:t))},onDrop:e=>{e.preventDefault();let t=D.current,n=O.current;D.current=null,O.current=null,x(null),w(null),t&&n&&V(t,n)},onEditClick:()=>s(e),onDeleteClick:()=>te(e.name),onStatusToggle:t=>void ee(e,t)},e.name))}),T&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:T}),v&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:v})]}),(0,Q.jsxs)(S.Footer,{className:`justify-between`,children:[(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:c,children:`+ New Profile`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:o,children:`Done`})]})]}),(0,Q.jsx)(Mt,{blocked:k,availableReplacements:W,replacement:N,onReplacementChange:P,error:j,saving:F,onClose:()=>{A(null),M(null)},onConfirm:()=>void B()})]})}function It({mode:e,connection:t,assistantId:n,existingNames:r,openAICompatibleEndpointsEnabled:i=!1,chatgptSubscriptionEnabled:a=!1,onSave:o,onCancel:s}){let[c,u]=(0,Z.useState)(e),[d,f]=(0,Z.useState)(void 0),g=c===`managed-edit`,[_,v]=(0,Z.useState)(t?.label??``),[b,x]=(0,Z.useState)(t?.name??``),[C,w]=(0,Z.useState)(t?.provider??`anthropic`),[T,E]=(0,Z.useState)(()=>t?t.auth.type:`platform`),[D,O]=(0,Z.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[k,j]=(0,Z.useState)(t?.baseUrl??``),[N,P]=(0,Z.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[F,I]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(null),ee=C===`openai-compatible`,z=(0,Z.useMemo)(()=>{let e=i?Ge:Ge.filter(e=>e!==`openai-compatible`);return C&&!e.includes(C)?[...e,C]:e},[i,C]),{handleLabelChange:te,resetDirty:B}=ge(c,v,x),[V,H]=(0,Z.useState)(``),[U,W]=(0,Z.useState)(!1),ne=l(),K=(0,Z.useMemo)(()=>he(D),[D]),re=T===`api_key`&&K!==null,{hasStoredCredential:ie,isLoading:J,queryKey:oe}=be({assistantId:n,credentialKind:`credential`,credentialName:K?`${K.service}:${K.field}`:``,enabled:re,errorContext:`settings-provider-editor-credential-presence`}),{credentials:se,queryKey:X}=q({assistantId:n,enabled:T===`api_key`});(0,Z.useEffect)(()=>{let e=t?.provider??`anthropic`;v(t?.label??``),x(t?.name??``),w(e),E(t?t.auth.type:`platform`),t?.auth.type===`api_key`?O(t.auth.credential):O(t?``:`credential/${e}/api_key`),B(),R(null),j(t?.baseUrl??``),P(t?.models?t.models.map(e=>e.id).join(`, `):``),H(``),W(!1)},[t,B]);function ce(){u(`create`),f(C===`ollama`?`none`:`api_key`)}let le=b.trim().length>0;async function ue(){if(le){I(!0),R(null);try{let e;if(T===`api_key`){let t=D.trim()||`credential/${C}/api_key`,r=V.trim();if(r){W(!0);try{let e=he(t);await M({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:C,value:r},throwOnError:!0}),ne.setQueryData(oe,!0),ne.invalidateQueries({queryKey:X})}catch{R(`Failed to save API key. Please try again.`);return}finally{W(!1)}}e={type:`api_key`,credential:t}}else if(T===`oauth_subscription`)if(t?.auth.type===`oauth_subscription`)e=t.auth;else{R(`Use the "Sign in with ChatGPT" button to connect your subscription.`);return}else e=T===`none`?{type:`none`}:{type:`platform`};let r=_.trim()||null,i={auth:e,label:r,...ee&&{base_url:k.trim()||null,models:N.trim()?N.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:a,response:s}=await A({path:{assistant_id:n,name:t?.name??b.trim()},body:i});if(!s?.ok){R(me(s?.status,b.trim()));return}if(!a){R(`Server returned an empty response. Please try again.`);return}o(a)}catch{R(`Failed to save connection. Please try again.`)}finally{I(!1)}}}let de=se.filter(e=>e.service===C),pe=c!==`create`&&t?.auth.type===`api_key`,_e=de.length>0||pe,ye=qe(`Enter your API key`,ie);return c===`create`?(0,Q.jsx)(ae,{variant:`modal`,assistantId:n,existingNames:r,openAICompatibleEndpointsEnabled:i,chatgptSubscriptionEnabled:a,defaultProviderType:C,defaultAuthType:d,onCreated:o,onCancel:s},C):(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Edit Connection`}),(0,Q.jsx)(S.Description,{children:g?`Managed by Vellum — auth is locked, but you can rename "${t?.name}".`:`Editing "${t?.name}".`})]}),(0,Q.jsxs)(S.Body,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,Q.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,Q.jsx)(y,{value:_,onChange:e=>te(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Key`}),(0,Q.jsx)(y,{value:b,placeholder:`e.g. anthropic-personal`,disabled:!0,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{"aria-label":`Provider`,value:C,onChange:e=>w(e),disabled:!0,options:z.map(e=>({value:e,label:Y[e]}))})]}),ee&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,Q.jsx)(y,{value:k,onChange:e=>j(e.target.value),placeholder:`https://api.example.com/v1`,disabled:g,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,Q.jsx)(y,{value:N,onChange:e=>P(e.target.value),placeholder:`model-1, model-2`,disabled:g,fullWidth:!0}),(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Auth Type`}),(0,Q.jsx)(h,{"aria-label":`Auth type`,value:T,onChange:e=>{E(e),R(null)},disabled:g||C===`ollama`,options:(()=>{let e;return e=C===`ollama`?[`none`]:ut(C)?[`api_key`,`platform`]:[`api_key`],T&&!e.includes(T)&&e.push(T),e.map(e=>({value:e,label:G[e]}))})()})]}),T===`api_key`&&(0,Q.jsx)(ve,{apiKeyValue:V,onApiKeyChange:H,credential:D,onCredentialChange:O,isAuthLocked:g,isLoadingCredential:J,apiKeyPlaceholder:ye,provider:C,providerCredentials:de,showAdvancedSection:_e,onError:R}),T===`oauth_subscription`&&(0,Q.jsx)(fe,{assistantId:n,onConnected:o}),L&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:L})]}),(0,Q.jsxs)(S.Footer,{children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:s,children:`Cancel`}),c===`managed-edit`&&(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:ce,disabled:F||U,children:`Save as New`}),(0,Q.jsx)(p,{variant:`primary`,size:`compact`,disabled:!le||F||U,onClick:()=>void ue(),children:F?`Saving…`:`Save`})]})]})}function Lt(e){switch(e.type){case`api_key`:return`API key · ${e.credential}`;case`oauth_subscription`:return`ChatGPT Subscription`;case`platform`:return`Managed proxy`;case`none`:return`None (local)`;default:return e.type}}function Rt({isOpen:e,assistantId:t,onClose:n}){let r=H.use.openAICompatibleEndpoints(),i=H.use.chatgptSubscriptionAuth(),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),d=l(),{data:f,isLoading:p,isError:m}=u({...R({path:{assistant_id:t}}),enabled:e}),h=(0,Z.useMemo)(()=>ce(f?.connections??[],r),[f,r]);function g(e){d.invalidateQueries({queryKey:I({path:{assistant_id:t}})}),o(!1),c(null)}let _=h.map(e=>e.name),v=()=>{o(!1),c(null)};return(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{e||(a?v():n())},children:e?a?(0,Q.jsx)(It,{mode:s?s.isManaged?`managed-edit`:`edit`:`create`,connection:s??void 0,assistantId:t,existingNames:_,openAICompatibleEndpointsEnabled:r,chatgptSubscriptionEnabled:i,onSave:g,onCancel:v}):(0,Q.jsx)(zt,{connections:h,loading:p,isError:m,assistantId:t,onClose:n,onEditClick:e=>{c(e),o(!0)},onNewClick:()=>{c(null),o(!0)},onConnectionDeleted:()=>{d.invalidateQueries({queryKey:I({path:{assistant_id:t}})})}}):null})}function zt({connections:e,loading:t,isError:n,assistantId:r,onClose:i,onEditClick:a,onNewClick:o,onConnectionDeleted:s}){let[c,l]=(0,Z.useState)({}),[u,d]=(0,Z.useState)({});async function f(e){d(t=>({...t,[e]:!0})),l(t=>{let n={...t};return delete n[e],n});try{let{response:t}=await N({path:{assistant_id:r,name:e}});t?.ok||t?.status===404?s(e):t?.status===409?l(t=>({...t,[e]:`Connection is in use by one or more profiles. Remove those references first.`})):l(t=>({...t,[e]:`Failed to delete connection. Please try again.`}))}catch{l(t=>({...t,[e]:`Failed to delete connection. Please try again.`}))}finally{d(t=>{let n={...t};return delete n[e],n})}}return(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Provider Connections`}),(0,Q.jsx)(S.Description,{children:`Manage inference provider connections. Each connection binds a name to a provider and auth configuration.`})]}),(0,Q.jsx)(S.Body,{children:t?(0,Q.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-10 animate-pulse rounded-lg bg-[var(--surface-active)]`},e))}):n?(0,Q.jsx)(m,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:`Failed to load connections. Please try again.`}):e.length===0?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No connections yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>{let t=u[e.name]??!1,n=c[e.name],r=e.isManaged??!1;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg px-2 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),r&&(0,Q.jsx)(v,{tone:`positive`,title:`Managed by Platform — auth is locked, but you can rename this connection.`,children:`Platform`})]}),(0,Q.jsxs)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:[e.label?`${e.name} · `:``,Y[e.provider]??e.provider,` · `,Lt(e.auth)]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,onClick:()=>a(e),children:`Edit`}),(0,Q.jsx)(p,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),"aria-label":`Delete ${e.name}`,disabled:r||t,title:r?`Managed connections cannot be deleted`:void 0,onClick:()=>void f(e.name),tintColor:`var(--system-negative-strong)`})]})]}),n?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:n}):null]},e.name)})})}),(0,Q.jsxs)(S.Footer,{className:`justify-between`,children:[(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:o,children:`+ New Connection`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:i,children:`Done`})]})]})}function Bt(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Z.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}function Vt(){let{assistantId:e,orderedProfiles:t,activeProfile:n,callSites:r}=Dt(),i=Ot(),[o,s]=Bt(n),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,g]=(0,Z.useState)(!1),_=H.use.queryComplexityRouting(),v=(0,Z.useMemo)(()=>K(we(t,[o]),_),[t,o,_]),y=Object.entries(r).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length,b=y===1?`1 Override`:y>0?`${y} Overrides`:`Overrides`,x=o!==n,S=(0,Z.useCallback)(async()=>{try{await i.mutateAsync({llm:{activeProfile:o}}),C.success(`Profile saved.`)}catch(e){C.error(`Failed to switch profile. Please try again.`),a(e,{context:`settings-ai-language-model-save`})}},[o,i]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yt,{title:`Language Model`,subtitle:`Configure the LLMs that power your assistant`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Default Profile`}),(0,Q.jsx)(h,{value:o??``,onChange:e=>{s(e===``?null:e)},placeholder:`Select a default profile…`,options:v.map(e=>({value:e.name,label:e.name===`auto`?`Automatically switch between profiles`:Te(e)}))}),_&&o===`auto`&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2 rounded-lg bg-[var(--surface-warning-subtle)] px-3 py-2`,children:(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-warning)]`,children:`Auto may use more powerful models when needed, which can increase costs.`})}),v.length===0?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`No profiles yet. Click Profiles below to create one.`}):null]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>g(!0),children:`Providers`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>l(!0),children:`Profiles`}),(0,Q.jsx)(p,{variant:`outlined`,size:`compact`,onClick:()=>d(!0),children:b})]}),x&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:S,disabled:i.isPending}),i.isPending&&(0,Q.jsx)(O,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]})}),e&&(0,Q.jsx)(Pt,{isOpen:c,assistantId:e,onClose:()=>l(!1)}),e&&(0,Q.jsx)(At,{isOpen:u,onClose:()=>d(!1),assistantId:e}),e&&(0,Q.jsx)(Rt,{isOpen:f,assistantId:e,onClose:()=>g(!1)})]})}function Ht(){let{assistantId:e,config:i}=Dt(),o=Ot(),s=kt(),c=l(),{serverWebSearchMode:u,serverWebSearchProvider:d}=(0,Z.useMemo)(()=>{if(!i)return{serverWebSearchMode:n(Qe,`your-own`),serverWebSearchProvider:n(Ye,`inference-provider-native`)};let e=i.services?.[`web-search`],t=e?.mode;return{serverWebSearchMode:t===`managed`||t===`your-own`?t:n(Qe,`your-own`),serverWebSearchProvider:e?.provider||n(`vellum:ai:webSearchProvider`,`inference-provider-native`)}},[i]),[f,p]=(0,Z.useState)(!1),[m,g]=Bt(u),[_,v]=Bt(d),[b,x]=(0,Z.useState)(``),S=Oe.has(_),{hasStoredCredential:w,queryKey:T}=be({assistantId:e,credentialKind:`api_key`,credentialName:_,enabled:S,errorContext:`settings-ai-web-search-read-credential`}),E=b.trim().length>0,D=f||m===`your-own`&&S&&!w&&!E||!(m!==u||(m===`managed`?`inference-provider-native`:_)!==d)&&!E,k=qe(ye[_]??`Enter your API key`,w),A=(0,Z.useCallback)(async()=>{p(!0);let e=b.trim(),t=m===`managed`?`inference-provider-native`:_,n=et(t),i=m===`your-own`&&S&&e.length>0;try{i&&await s(t,e),await o.mutateAsync({services:{"web-search":{mode:m,provider:t}}}).catch(e=>{throw C.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{p(!1);return}p(!1);try{r(Qe,m),r(Ye,t),i&&(n&&r(n,e),c.setQueryData(T,!0),c.invalidateQueries({queryKey:T}),x(``)),C.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),C.error(`Saved, but local preferences could not be written.`)}},[S,o,s,c,T,b,m,_]),j=(0,Z.useCallback)(()=>{let e=et(_);e&&t(e),x(``),v(`inference-provider-native`),r(Ye,`inference-provider-native`)},[_,v]);return(0,Q.jsx)(_t,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,mode:m,onModeChange:e=>g(e),children:m===`managed`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Web search is included with managed inference.`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:A,disabled:D}),f&&(0,Q.jsx)(O,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:_,onChange:v,options:ke.map(e=>({value:e,label:De[e]??e}))})]}),S&&(0,Q.jsx)(y,{label:`API Key`,type:`password`,value:b,onChange:e=>x(e.target.value),placeholder:k,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:A,disabled:D}),f&&(0,Q.jsx)(O,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),S&&(0,Q.jsx)(vt,{onClick:j,filled:!0})]})]})})}function Ut({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=l(),i=s(),[o,f]=c(),[m,h]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,w]=(0,Z.useState)(``),[D,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{v||!t||m||(h(t),y(!0))},[t,v,m]);let I=u({...Re(),enabled:!0}),L=I.data,R=L?.entitlements,ee=R?.managed_email===!0,B=!!R&&!ee,V=!L&&I.isError&&!I.isFetching,H=u({...Me({path:{assistant_id:e}}),enabled:!B}),U=u({...Ce({path:{assistant_id:e}}),enabled:!B}),W=H.data?.results?.[0],G=U.data?.results?.[0],ne=W?`${W.subdomain}.${n}`:null,K=u({...ie({path:{assistant_id:e,id:G?.id??``}}),enabled:!!G?.id,refetchOnWindowFocus:!1}),q=u({...xe({path:{assistant_id:e,id:W?.id??``}}),enabled:!!W?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Z.useEffect)(()=>{o.get(`release`)!==`1`||!W||G||(N(!0),f(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[G,W,o,f]);let J=d(st()),ae=d(dt()),Y=d(re()),se=d(ct()),X=(0,Z.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:lt({path:t})}),r.invalidateQueries({queryKey:oe({path:t})}),G?.id&&r.invalidateQueries({queryKey:_e({path:{...t,id:G.id}})}),r.invalidateQueries({queryKey:Ke()})},[G?.id,e,r]),ce=(0,Z.useCallback)(async()=>{let t=m.trim().toLowerCase();if(!t){x(`Enter a subdomain.`);return}j(!1);try{await J.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),h(``),x(null),X(),C.success(`Domain ${t}.${n} registered.`)}catch(e){x(z(e,void 0,`Failed to register domain.`))}},[e,n,X,J,m]),le=(0,Z.useCallback)(async()=>{let t=S.trim().toLowerCase();if(!t){k(`Enter an email username.`);return}try{await Y.mutateAsync({path:{assistant_id:e},body:{username:t}}),w(``),k(null),X(),C.success(`Email address created.`)}catch(e){k(z(e,void 0,`Failed to create email address.`))}},[e,X,Y,S]),ue=(0,Z.useCallback)(async()=>{if(G?.id){F(!1);try{await se.mutateAsync({path:{assistant_id:e,id:G.id}}),X(),C.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),C.error(`Failed to remove email address.`)}}},[G?.id,e,se,X]),de=(0,Z.useCallback)(async()=>{if(!W?.id)return;if(G){C.error(`Remove the email address first.`);return}N(!1);let t=W.subdomain;try{await ae.mutateAsync({path:{assistant_id:e,id:W.id}}),h(t),X(),C.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),C.error(`Failed to release domain.`)}},[G,e,ae,W?.id,W?.subdomain,X]);if(I.isLoading)return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(O,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(B)return(0,Q.jsxs)(_,{tone:`info`,icon:(0,Q.jsx)(T,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Get a dedicated email address for your assistant`,actions:(0,Q.jsx)(p,{size:`compact`,onClick:()=>i(`${te.settings.billing}?adjust_plan`),children:`Upgrade to Pro`}),children:[`Pro plans include a managed`,` `,`<your-subdomain>.${n}`,` inbox — no provider setup required. Or switch to `,(0,Q.jsx)(`strong`,{children:`Your Own`}),` to bring an existing provider.`]});let fe=V?(0,Q.jsx)(_,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,Q.jsx)(p,{size:`compact`,variant:`outlined`,onClick:()=>I.refetch(),children:`Retry`}),children:`We couldn't reach the billing service. The form below assumes managed email is enabled for your org — if it isn't, registering a domain will fail.`}):null;return W?G?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[fe,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:G.address}),(0,Q.jsx)(xt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(p,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),onClick:()=>F(!0),disabled:se.isPending,"aria-label":`Remove email address`})]}),(0,Q.jsx)(g,{open:P,title:`Remove Email Address`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to remove `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:G.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:ue,onCancel:()=>F(!1)})]}),K.data?.usage&&(0,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[K.data.usage.sent_today,` /`,` `,K.data.usage.daily_limit,` sent today ·`,` `,K.data.usage.received_today,` received`]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[fe,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[W.subdomain,`.`,n]}),(0,Q.jsx)(xt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(p,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),onClick:()=>N(!0),disabled:ae.isPending,"aria-label":`Release domain`})]}),(0,Q.jsx)(g,{open:M,title:`Release Domain`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to release `,(0,Q.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[W.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:de,onCancel:()=>N(!1)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex h-9 min-w-0 flex-1 items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${D?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,Q.jsx)(`input`,{value:S,onChange:e=>{w(e.target.value.toLowerCase()),D&&k(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!D,className:`h-full min-w-0 flex-1 bg-transparent pl-3 pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,ne]})]}),(0,Q.jsx)(p,{onClick:le,disabled:Y.isPending||!S.trim(),children:Y.isPending?`Creating…`:`Create`})]}),D&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:D})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[fe,(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,Q.jsx)(E,{subdomain:m,onSubdomainChange:e=>{h(e),b&&x(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:b}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Each assistant gets its own subdomain. Lowercase letters, numbers, and hyphens only.`}),(0,Q.jsx)(p,{onClick:()=>j(!0),disabled:J.isPending||!m.trim(),children:J.isPending?`Registering…`:`Register`}),(0,Q.jsx)(g,{open:A,title:`Set Subdomain`,message:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:m.trim().toLowerCase()||`subdomain`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:ce,onCancel:()=>j(!1)})]})}function Wt(){let e=pt(),{data:t}=u(ne()),o=t?.results?.[0]?.handle,s=We.use.emailRootDomain(),c=ze(),[l,d]=(0,Z.useState)(()=>c===`gated`?`your-own`:n(je,`managed`)),[f,p]=(0,Z.useState)(()=>n(He,`resend`)),m=u({queryKey:[`byoEmailCredential`,e,f],queryFn:async()=>{let{data:t}=await P({path:{assistant_id:e},body:{service:f,field:`api_key`},throwOnError:!0});return t},enabled:l===`your-own`||c===`gated`,staleTime:6e4,retry:i,meta:{errorContext:`byo_email_credential_check`}});(0,Z.useEffect)(()=>{m.error&&a(m.error,{context:`byo_email_credential_check`,bestEffort:!0})},[m.error]);let g=m.data?.hasSecret===!0,v=(0,Z.useCallback)(e=>{d(e),r(je,e)},[]),y=(0,Z.useCallback)(()=>{r(He,f),C.success(`Email settings saved.`)},[f]),b=(0,Z.useMemo)(()=>Ie.find(e=>e.id===f)??Ie[0],[f]),x=(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(J,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{children:[`Configure `,b.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:b.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,Q.jsxs)(`a`,{href:b.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,b.displayName,(0,Q.jsx)(D,{className:`h-3 w-3`})]})]})]}),S=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:f,onChange:e=>p(e),options:Ie.map(e=>({value:e.id,label:e.displayName}))})]}),g?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--system-positive-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-default)]`,children:[(0,Q.jsx)(Pe,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`span`,{children:[b.displayName,` API key configured. To reconfigure, run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:b.setupSkill}),` `,`skill.`]})]}),(0,Q.jsxs)(`a`,{href:b.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-body-small-default text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,b.displayName,(0,Q.jsx)(D,{className:`h-3 w-3`})]})]}):x,(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)($,{onClick:y,disabled:!1})})]});return c===`gated`?(0,Q.jsx)(yt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:S}):(0,Q.jsx)(_t,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:l,onModeChange:v,children:l===`managed`?(0,Q.jsx)(`div`,{className:`space-y-4`,children:c===`disabled`?(0,Q.jsx)(_,{tone:`info`,children:`Log in to the Vellum platform to manage email settings.`}):(0,Q.jsx)(Ut,{assistantId:e,assistantHandle:o,emailRootDomain:s})}):S})}function Gt(){let{config:e}=Dt(),{resolveAssistantId:t}=Et(),i=l(),o=Ot(),s=kt(),[c,u]=Bt((0,Z.useMemo)(()=>{if(!e)return n(Ze,`your-own`);let t=e.services?.[`image-generation`]?.mode;return t===`managed`||t===`your-own`?t:n(Ze,`your-own`)},[e])),[d,f]=(0,Z.useState)(()=>n(nt,`gemini-3.1-flash-image-preview`)),[p,m]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),v=(0,Z.useCallback)(async()=>{_(!0);let e=p.trim(),n=c===`your-own`&&e.length>0;try{n&&await s(`gemini`,e),await o.mutateAsync({services:{"image-generation":{mode:c}}}).catch(e=>{throw C.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});let r=await t();try{await j({path:{assistant_id:r},body:{modelId:d},throwOnError:!0})}catch(e){throw C.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{i.invalidateQueries({queryKey:V(r)})}}catch{_(!1);return}_(!1);try{r(Ze,c),r(nt,d),n&&m(``),C.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),C.error(`Saved, but local preferences could not be written.`)}},[p,c,d,o,s,t,i]),b=(0,Z.useCallback)(()=>{m(``),f(`gemini-3.1-flash-image-preview`),r(nt,`gemini-3.1-flash-image-preview`)},[]);return(0,Q.jsx)(_t,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,mode:c,onModeChange:e=>u(e),children:c===`managed`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Q.jsx)(h,{className:`flex-1`,value:d,onChange:f,options:W.map(e=>({value:e,label:rt[e]??e}))}),(0,Q.jsx)($,{onClick:v,disabled:g}),g&&(0,Q.jsx)(O,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(y,{label:`API Key`,type:`password`,value:p,onChange:e=>m(e.target.value),placeholder:`Enter your Gemini API key`,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsx)(h,{value:d,onChange:f,options:W.map(e=>({value:e,label:rt[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:v,disabled:g}),g&&(0,Q.jsx)(O,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),(0,Q.jsx)(vt,{onClick:b})]})]})})}async function Kt(e){let{provider:t,apiKey:n,voiceId:r,text:i}=e;if(n.trim().length===0)return{kind:`error`,message:`Save an API key for this provider first.`};try{return t===`elevenlabs`?await qt(n,r,i):t===`deepgram`?await Jt(n,i):t===`fish-audio`?{kind:`unsupported`,message:`Fish Audio TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:t===`xai`?{kind:`unsupported`,message:`xAI TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:{kind:`unsupported`,message:`TTS testing for "${t}" is not supported from the browser yet.`}}catch(e){return{kind:`error`,message:e instanceof Error?e.message:`Failed to reach the TTS provider.`}}}async function qt(e,t,n){let r=t.trim();if(r.length===0)return{kind:`error`,message:`Enter and save a Voice ID before testing ElevenLabs.`};let i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(r)}?output_format=mp3_44100_128`,{method:`POST`,headers:{"xi-api-key":e,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:n,model_id:`eleven_turbo_v2_5`})});return i.ok?{kind:`audio`,blob:await i.blob()}:{kind:`error`,message:await Yt(i,`ElevenLabs rejected the request.`)}}async function Jt(e,t){let n=await fetch(`https://api.deepgram.com/v1/speak?model=aura-2-thalia-en`,{method:`POST`,headers:{Authorization:`Token ${e}`,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:t})});return n.ok?{kind:`audio`,blob:await n.blob()}:{kind:`error`,message:await Yt(n,`Deepgram rejected the request.`)}}async function Yt(e,t){try{let n=await e.text();if(n.length===0)return`${t} (HTTP ${e.status})`;try{let e=JSON.parse(n);if(e&&typeof e==`object`&&`detail`in e&&typeof e.detail==`string`)return e.detail;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message}catch{}return n.slice(0,200)}catch{return`${t} (HTTP ${e.status})`}}function Xt(){let e=pt(),t=U.use.name()??`your assistant`,i=B(),{data:a}=u({...L({path:{assistant_id:e}}),enabled:i,staleTime:1/0}),o=a?.providers??Be,s=o[0]?.id??`elevenlabs`,[c,l]=(0,Z.useState)(()=>n(Fe,s)),[d,f]=(0,Z.useState)(c),[m,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(``),[S,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),D=(0,Z.useMemo)(()=>o.find(e=>e.id===c)??o[0],[c,o]),O=(0,Z.useCallback)(e=>{let t=n(it+e,``),r=n(Le+e,``);w(t.length>0),v(r),x(r),g(``)},[]);(0,Z.useEffect)(()=>{O(c)},[c,O]);let k=(0,Z.useMemo)(()=>{let e=c!==d,t=m.trim().length>0,n=_.trim()!==b;return e||t||n},[c,d,m,_,b]),A=(0,Z.useCallback)(()=>{r(Fe,c);let e=m.trim();e.length>0&&(r(it+c,e),w(!0));let t=_.trim();r(Le+c,t),f(c),x(t),g(``)},[c,m,_]),j=(0,Z.useCallback)(()=>{r(it+c,``),w(!1),g(``)},[c]),M=(0,Z.useCallback)(async()=>{E(!0);try{let e=n(it+c,``),r=m.trim(),i=r.length>0?r:e;if(i.length===0){C.error(`Save an API key for this provider before testing.`);return}let a=n(Le+c,``),o=_.trim(),s=await Kt({provider:c,apiKey:i,voiceId:o.length>0?o:a,text:`Hey! It's ${t}. How does this sound?`});if(s.kind!==`audio`){C.error(s.message);return}let l=URL.createObjectURL(s.blob);try{let e=new Audio(l);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(l)}}finally{E(!1)}},[t,m,c,_]),N=S?`•••••••• (Enter a new key to replace)`:D.apiKeyPlaceholder;return(0,Q.jsx)(yt,{title:`Text-to-Speech`,subtitle:D.subtitle,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:c,onChange:l,options:o.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(y,{type:`password`,value:m,onChange:e=>g(e.target.value),placeholder:N,fullWidth:!0})]}),D.supportsVoiceSelection&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,Q.jsx)(y,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),(0,Q.jsx)(bt,{guide:D.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(p,{variant:`outlined`,onClick:M,disabled:T,children:T?`Testing…`:`Test`}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:A,disabled:!k}),S&&(0,Q.jsx)(vt,{onClick:j})]})]})]})})}function Zt(){let e=Ve[0]?.id??`deepgram`,[t,i]=(0,Z.useState)(()=>n(Je,e)),[a,o]=(0,Z.useState)(t),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),d=(0,Z.useMemo)(()=>Ve.find(e=>e.id===t)??Ve[0],[t]);(0,Z.useEffect)(()=>{u(n(Ne+t,``).length>0),c(``)},[t]);let f=(0,Z.useMemo)(()=>{let e=t!==a,n=s.trim().length>0;return e||n},[t,a,s]),p=(0,Z.useCallback)(()=>{r(Je,t);let e=s.trim();e.length>0&&(r(Ne+t,e),u(!0)),o(t),c(``)},[t,s]),m=(0,Z.useCallback)(()=>{r(Ne+t,``),u(!1),c(``)},[t]),g=l?`•••••••• (Enter a new key to replace)`:d.apiKeyPlaceholder;return(0,Q.jsx)(yt,{title:`Speech-to-Text`,subtitle:d.subtitle,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:t,onChange:i,options:Ve.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(y,{type:`password`,value:s,onChange:e=>c(e.target.value),placeholder:g,fullWidth:!0})]}),(0,Q.jsx)(bt,{guide:d.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Q.jsx)($,{onClick:p,disabled:!f}),l&&(0,Q.jsx)(vt,{onClick:m})]})]})})}function Qt(){return(0,Z.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]),(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,Q.jsx)(J,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,Q.jsxs)(`a`,{href:`https://www.vellum.ai/docs/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--primary-base)] hover:underline`,children:[`View pricing`,(0,Q.jsx)(D,{className:`h-3.5 w-3.5`})]})]})]}),(0,Q.jsx)(Vt,{}),(0,Q.jsx)(Ht,{}),(0,Q.jsx)(Wt,{}),(0,Q.jsx)(Gt,{}),(0,Q.jsx)(Xt,{}),(0,Q.jsx)(Zt,{})]})}export{Qt as AiPage};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{a as t,c as n,i as r,t as i}from"./local-settings-lVNyIOJ_.js";import{a,n as o,t as s}from"./device-settings-C07QvMzm.js";import{o as c,t as l}from"./capture-error-CZsNGL6n.js";import{t as u}from"./react-DJZBPgpf.js";import{t as d}from"./useQuery-D2zf6Uhu.js";import{n as f,t as p}from"./create-selectors-CDULelrw.js";import{A as m,D as h,E as ee,O as te,T as ne,a as re,b as ie,f as g,h as ae,i as oe,k as _,l as se,m as ce,n as le,s as v,t as y,w as b,y as ue}from"./resolved-assistants-store-ub66utfl.js";import{t as de}from"./is-electron-CavSPgmY.js";import{n as fe,r as x,t as pe}from"./api-errors-ChauV4ed.js";import{c as S,d as me,o as he,r as ge}from"./api-DEEx3e9R.js";import{t as C}from"./client.gen-BKAMS0D0.js";import{ht as _e}from"./sdk.gen-BO4vbMAj.js";import{i as ve,t as ye}from"./dist-B4KYfSON.js";import{i as w}from"./routes-DMbyM_oF.js";import{n as be}from"./event-bus-CMBsMREI.js";var T=p(f(()=>({assistantState:{kind:`loading`},expectingFirstMessage:!1})));function E(e){if(e.ok)switch(e.data.status){case`active`:return e.data.is_local?{kind:`self_hosted`}:{kind:`active`};case`initializing`:return{kind:`initializing`};case`to_be_deleted`:return{kind:`cleaning_up`};default:return{kind:`error`,message:`Unexpected assistant status: ${e.data.status}`}}return e.status===404?{kind:`auto_hatch`}:{kind:`error`,message:x(e.error,void 0,`Failed to check assistant status.`)}}function xe(e){return e===void 0||e>=500}var Se=`platform_hosted_disabled`,Ce=`We are at capacity for Vellum Managed Assistants, more will be available soon!`;function we(e,t){return e===503?t?.code===Se:!1}var Te=3e5;function D(){return{kind:`error`,message:`Your assistant is taking longer than expected to start. Please try again, or check the community for help.`}}var O=[`assistant`,`current`],k=3e3,Ee=new Set([`initializing`,`cleaning_up`]);function De(e){if(!e)return!1;let t=E(e);return Ee.has(t.kind)?k:!1}function Oe(e){return e?[...O,e]:O}function ke(e){let t=e.selectedPlatformAssistantId??null;return d({queryKey:Oe(t),queryFn:()=>ge(t??void 0),enabled:e.enabled,retry:!1,refetchInterval:e=>De(e.state.data),refetchOnWindowFocus:!1})}var A=e=>e===`authenticated`,Ae=e=>e!==`initializing`,j=e=>e===`present`,je=3,Me=3,Ne=e=>{},Pe=()=>null,M=new class{state={kind:`loading`};hatching=!1;hatchRetryCount=0;initializingAssistantId=null;initializingRecoveryCount=0;hatchingVersion=void 0;generation=0;initializingTimeout=null;ready=!1;inputs={sessionStatus:`initializing`,isRetired:!1,isNonProduction:!1,hasPlatformSession:!1,onRedirect:Ne,resolveOnboardingRedirect:Pe,queryClient:null,selectedPlatformAssistantId:null};setInputs(e){this.inputs=e,this.ready=!0}resetForLogout(){y.getState().activeAssistantId!==null&&y.getState().setActiveAssistantId(null),this.state.kind!==`loading`&&this.transition({kind:`loading`}),this.clearExpectingFirstMessage()}async respondToInputs(){if(this.ready){if(!A(this.inputs.sessionStatus)){this.resetForLogout();return}if(m()){this.applyGatewayAuthShortCircuit();return}if(g()&&!m()&&!this.inputs.hasPlatformSession){let e=this.inputs.resolveOnboardingRedirect({intendedDestination:window.location.pathname});e&&this.inputs.onRedirect(e);return}this.inputs.hasPlatformSession&&b(null),this.inputs.isOrgReady&&await this.checkAssistant()}}async applyServerResult(e){this.ready&&(this.state.kind!==`initializing`&&this.state.kind!==`cleaning_up`||await this.applyServerStateUpdate(e))}async checkAssistant(){if(!this.ready)return;if(m()){this.applyGatewayAuthShortCircuit();return}let e=this.generation;try{let t=this.inputs.selectedPlatformAssistantId??null,n=await this.inputs.queryClient.fetchQuery({queryKey:Oe(t),queryFn:()=>ge(t??void 0),staleTime:0});if(e!==this.generation)return;await this.applyServerStateUpdate(n)}catch(t){if(console.error(`Error checking assistant status:`,t),l(t,{context:`check_assistant`}),e!==this.generation)return;this.transition({kind:`error`,message:`Network error. Please check your connection and try again.`})}}retryAssistant(){this.ready&&(this.hatchRetryCount=0,this.initializingRecoveryCount=0,this.checkAssistant())}hatchVersion(e){this.ready&&(this.hatchRetryCount=0,this.markExpectingFirstMessage(),this.hatchAndCheck(e))}markExpectingFirstMessage(){T.getState().expectingFirstMessage||T.setState({expectingFirstMessage:!0})}clearExpectingFirstMessage(){T.getState().expectingFirstMessage&&T.setState({expectingFirstMessage:!1})}transition(e){let t=this.state.kind;this.state=e,T.setState({assistantState:e}),e.kind===`initializing`?t!==`initializing`&&this.armInitializingWatchdog():this.initializingTimeout&&=(clearTimeout(this.initializingTimeout),null),e.kind!==`initializing`&&e.kind!==`active`&&this.clearExpectingFirstMessage()}armInitializingWatchdog(){this.initializingTimeout&&clearTimeout(this.initializingTimeout),this.initializingTimeout=setTimeout(()=>{c(`Assistant hatch stuck in initializing state`,{level:`warning`,extra:{timeoutMs:Te}}),this.recoverStuckInitializingAssistant()},Te)}projectActive(e){let t=e.data.maintenance_mode;b(null),y.getState().setActiveAssistantId(e.data.id),this.transition({kind:`active`,isLocal:e.data.is_local??!1,maintenanceMode:{enabled:t?.enabled}})}projectSelfHosted(e){b({url:e.data.ingress_url,token:e.data.platform_actor_token}),y.getState().setActiveAssistantId(e.data.id),this.transition({kind:`self_hosted`})}applyGatewayAuthShortCircuit(){let e=window.location.origin,t=`self`,n=re();if(n){let r=se();e=`${window.location.origin}${n}`,t=r?.assistantId??t}b({url:e,token:h()}),y.getState().setActiveAssistantId(t),this.transition({kind:`active`,isLocal:!0})}async applyServerStateUpdate(e){let t=this.generation,n=E(e);if(e.ok&&n.kind===`initializing`?this.initializingAssistantId=e.data.id:n.kind!==`initializing`&&(this.initializingAssistantId=null),n.kind===`auto_hatch`){if(this.inputs.isRetired){this.transition({kind:`retired`});return}let e=this.inputs.resolveOnboardingRedirect({intendedDestination:window.location.pathname});if(e){this.inputs.onRedirect(e);return}if(this.inputs.isNonProduction){this.transition({kind:`awaiting_version_selection`});return}this.markExpectingFirstMessage(),await this.hatchAndCheck();return}if(n.kind===`active`&&e.ok){this.initializingRecoveryCount=0,this.hatchingVersion=void 0,this.projectActive(e);return}if(n.kind===`self_hosted`&&e.ok){this.initializingRecoveryCount=0,this.hatchingVersion=void 0,this.projectSelfHosted(e);return}t===this.generation&&n.kind!==`active`&&this.transition(n)}async hatchAndCheck(e){if(this.hatching)return;if(this.hatchRetryCount>=je){this.transition({kind:`error`,message:`Failed to start your assistant after multiple attempts. Please refresh the page to try again.`});return}this.hatching=!0,this.hatchingVersion=e;let t=this.generation;this.transition({kind:`initializing`}),this.armInitializingWatchdog();try{let n=await he(e?{version:e}:void 0);if(t!==this.generation)return;if(n.ok&&(this.initializingAssistantId=n.data.id,this.inputs.queryClient.setQueryData(O,{ok:!0,status:n.status,data:n.data})),!n.ok){if(this.hatchRetryCount+=1,c(`Hatch request failed`,{level:`warning`,extra:{status:n.status,error:n.error,attempt:this.hatchRetryCount}}),we(n.status,n.error)){this.transition({kind:`error`,message:Ce});return}if(xe(n.status)){this.transition({kind:`initializing`}),setTimeout(()=>{this.inputs.queryClient.invalidateQueries({queryKey:O})},k);return}this.transition({kind:`error`,message:x(n.error,void 0,`Failed to start your assistant. Please refresh the page to try again.`)});return}this.hatchRetryCount=0}catch(e){if(this.hatchRetryCount+=1,l(e,{context:`hatch_assistant`}),t!==this.generation)return;this.transition({kind:`initializing`}),setTimeout(()=>{this.inputs.queryClient.invalidateQueries({queryKey:O})},k);return}finally{this.hatching=!1}t===this.generation&&this.transition({kind:`initializing`})}async recoverStuckInitializingAssistant(){if(this.initializingRecoveryCount>=Me){this.generation++,this.transition(D());return}this.initializingRecoveryCount++,this.generation++;let e=this.generation;try{let t=this.initializingAssistantId;if(!t){let n=await this.inputs.queryClient.fetchQuery({queryKey:O,queryFn:()=>ge(),staleTime:0});if(e!==this.generation)return;if(n.ok&&n.data.status===`initializing`)t=n.data.id;else{let e=E(n);this.initializingAssistantId=null,e.kind===`auto_hatch`?await this.hatchAndCheck(this.hatchingVersion):e.kind===`active`&&n.ok?(this.initializingRecoveryCount=0,this.projectActive(n)):e.kind===`self_hosted`&&n.ok?(this.initializingRecoveryCount=0,this.projectSelfHosted(n)):e.kind!==`active`&&this.transition(e);return}}this.hatching=!0;let n=await me(t);if(e!==this.generation){this.hatching=!1;return}if(!n.ok&&n.status!==404){this.hatching=!1,c(`Failed to retire stuck initializing assistant`,{level:`warning`,extra:{status:n.status,error:n.error}}),this.transition(D());return}this.initializingAssistantId=null,y.getState().setActiveAssistantId(null),this.hatching=!1,await this.hatchAndCheck(this.hatchingVersion)}catch(t){if(this.hatching=!1,l(t,{context:`recover_stuck_initializing_assistant`}),e!==this.generation)return;this.transition(D())}}__resetForTesting(){this.initializingTimeout&&=(clearTimeout(this.initializingTimeout),null),this.state={kind:`loading`},this.hatching=!1,this.hatchRetryCount=0,this.initializingAssistantId=null,this.initializingRecoveryCount=0,this.hatchingVersion=void 0,this.generation=0,this.ready=!1,T.setState({expectingFirstMessage:!1}),this.inputs={sessionStatus:`initializing`,isRetired:!1,isNonProduction:!1,hasPlatformSession:!1,onRedirect:Ne,resolveOnboardingRedirect:Pe,queryClient:null},T.setState({assistantState:this.state}),y.setState({activeAssistantId:null})}},Fe={bodySerializer:e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});function Ie({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:r,responseValidator:i,sseDefaultRetryDelay:a,sseMaxRetryAttempts:o,sseMaxRetryDelay:s,sseSleepFn:c,url:l,...u}){let d,f=c??(e=>new Promise(t=>setTimeout(t,e)));return{stream:async function*(){let c=a??3e3,p=0,m=u.signal??new AbortController().signal;for(;!m.aborted;){p++;let a=u.headers instanceof Headers?u.headers:new Headers(u.headers);d!==void 0&&a.set(`Last-Event-ID`,d);try{let t={redirect:`follow`,...u,body:u.serializedBody,headers:a,signal:m},o=new Request(l,t);e&&(o=await e(l,t));let s=await(u.fetch??globalThis.fetch)(o);if(!s.ok)throw Error(`SSE failed: ${s.status} ${s.statusText}`);if(!s.body)throw Error(`No body in SSE response`);let f=s.body.pipeThrough(new TextDecoderStream).getReader(),p=``,h=()=>{try{f.cancel()}catch{}};m.addEventListener(`abort`,h);try{for(;;){let{done:e,value:t}=await f.read();if(e)break;p+=t,p=p.replace(/\r\n?/g,`
|
|
2
|
-
`);let a=p.split(`
|
|
3
|
-
|
|
4
|
-
`);p=a.pop()??``;for(let e of a){let t=e.split(`
|
|
5
|
-
`),a=[],o;for(let e of t)if(e.startsWith(`data:`))a.push(e.replace(/^data:\s*/,``));else if(e.startsWith(`event:`))o=e.replace(/^event:\s*/,``);else if(e.startsWith(`id:`))d=e.replace(/^id:\s*/,``);else if(e.startsWith(`retry:`)){let t=Number.parseInt(e.replace(/^retry:\s*/,``),10);Number.isNaN(t)||(c=t)}let s,l=!1;if(a.length){let e=a.join(`
|
|
6
|
-
`);try{s=JSON.parse(e),l=!0}catch{s=e}}l&&(i&&await i(s),r&&(s=await r(s))),n?.({data:s,event:o,id:d,retry:c}),a.length&&(yield s)}}}finally{m.removeEventListener(`abort`,h),f.releaseLock()}break}catch(e){if(t?.(e),o!==void 0&&p>=o)break;await f(Math.min(c*2**(p-1),s??3e4))}}}()}}var Le=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Re=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},ze=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Be=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(Re(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Le(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):N({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},N=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},Ve=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=ze(r),s=Object.entries(i).map(([t,i])=>N({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},He=/\{[^{}]+\}/g,Ue=({path:e,url:t})=>{let n=t,r=t.match(He);if(r)for(let t of r){let r=!1,i=t.substring(1,t.length-1),a=`simple`;i.endsWith(`*`)&&(r=!0,i=i.substring(0,i.length-1)),i.startsWith(`.`)?(i=i.substring(1),a=`label`):i.startsWith(`;`)&&(i=i.substring(1),a=`matrix`);let o=e[i];if(o==null)continue;if(Array.isArray(o)){n=n.replace(t,Be({explode:r,name:i,style:a,value:o}));continue}if(typeof o==`object`){n=n.replace(t,Ve({explode:r,name:i,style:a,value:o,valueOnly:!0}));continue}if(a===`matrix`){n=n.replace(t,`;${N({name:i,value:o})}`);continue}let s=encodeURIComponent(a===`label`?`.${o}`:o);n=n.replace(t,s)}return n},We=({baseUrl:e,path:t,query:n,querySerializer:r,url:i})=>{let a=i.startsWith(`/`)?i:`/${i}`,o=(e??``)+a;t&&(o=Ue({path:t,url:o}));let s=n?r(n):``;return s.startsWith(`?`)&&(s=s.substring(1)),s&&(o+=`?${s}`),o};function Ge(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return`serializedBody`in e?e.serializedBody!==void 0&&e.serializedBody!==``?e.serializedBody:null:e.body===``?null:e.body;if(t)return e.body}var Ke=async(e,t)=>{let n=typeof t==`function`?await t(e):t;if(n)return e.scheme===`bearer`?`Bearer ${n}`:e.scheme===`basic`?`Basic ${btoa(n)}`:n},qe=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=Be({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=Ve({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=N({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},Je=e=>{if(!e)return`stream`;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if(t===`multipart/form-data`)return`formData`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},Ye=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get(`Cookie`)?.includes(`${t}=`)):!1,Xe=async({security:e,...t})=>{for(let n of e){if(Ye(t,n.name))continue;let e=await Ke(n,t.auth);if(!e)continue;let r=n.name??`Authorization`;switch(n.in){case`query`:t.query||={},t.query[r]=e;break;case`cookie`:t.headers.append(`Cookie`,`${r}=${e}`);break;default:t.headers.set(r,e);break}}},Ze=e=>We({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==`function`?e.querySerializer:qe(e.querySerializer),url:e.url}),Qe=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith(`/`)&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=et(e.headers,t.headers),n},$e=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},et=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?$e(n):Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t},P=class{fns=[];clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e==`number`?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let n=this.getInterceptorIndex(e);return this.fns[n]?(this.fns[n]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}},tt=()=>({error:new P,request:new P,response:new P}),nt=qe({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),rt={"Content-Type":`application/json`},it=(e={})=>({...Fe,headers:rt,parseAs:`auto`,querySerializer:nt,...e}),F=((e={})=>{let t=Qe(it(),e),n=()=>({...t}),r=e=>(t=Qe(t,e),n()),i=tt(),a=async e=>{let n={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:et(t.headers,e.headers),serializedBody:void 0};n.security&&await Xe({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body!==void 0&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.body===void 0||n.serializedBody===``)&&n.headers.delete(`Content-Type`);let r=n;return{opts:r,url:Ze(r)}},o=async e=>{let n=e.throwOnError??t.throwOnError,r=e.responseStyle??t.responseStyle,o,s;try{let{opts:t,url:n}=await a(e),r={redirect:`follow`,...t,body:Ge(t)};o=new Request(n,r);for(let e of i.request.fns)e&&(o=await e(o,t));let c=t.fetch;s=await c(o);for(let e of i.response.fns)e&&(s=await e(s,o,t));let l={request:o,response:s};if(s.ok){let e=(t.parseAs===`auto`?Je(s.headers.get(`Content-Type`)):t.parseAs)??`json`;if(s.status===204||s.headers.get(`Content-Length`)===`0`){let n;switch(e){case`arrayBuffer`:case`blob`:case`text`:n=await s[e]();break;case`formData`:n=new FormData;break;case`stream`:n=s.body;break;default:n={};break}return t.responseStyle===`data`?n:{data:n,...l}}let n;switch(e){case`arrayBuffer`:case`blob`:case`formData`:case`text`:n=await s[e]();break;case`json`:{let e=await s.text();n=e?JSON.parse(e):{};break}case`stream`:return t.responseStyle===`data`?s.body:{data:s.body,...l}}return e===`json`&&(t.responseValidator&&await t.responseValidator(n),t.responseTransformer&&(n=await t.responseTransformer(n))),t.responseStyle===`data`?n:{data:n,...l}}let u=await s.text(),d;try{d=JSON.parse(u)}catch{}throw d??u}catch(t){let a=t;for(let t of i.error.fns)t&&(a=await t(a,s,o,e));if(a||={},n)throw a;return r===`data`?void 0:{error:a,request:o,response:s}}},s=e=>t=>o({...t,method:e}),c=e=>async t=>{let{opts:n,url:r}=await a(t);return Ie({...n,body:n.body,method:e,onRequest:async(e,t)=>{let r=new Request(e,t);for(let e of i.request.fns)e&&(r=await e(r,n));return r},serializedBody:Ge(n),url:r})};return{buildUrl:e=>Ze({...t,...e}),connect:s(`CONNECT`),delete:s(`DELETE`),get:s(`GET`),getConfig:n,head:s(`HEAD`),interceptors:i,options:s(`OPTIONS`),patch:s(`PATCH`),post:s(`POST`),put:s(`PUT`),request:o,setConfig:r,sse:{connect:c(`CONNECT`),delete:c(`DELETE`),get:c(`GET`),head:c(`HEAD`),options:c(`OPTIONS`),patch:c(`PATCH`),post:c(`POST`),put:c(`PUT`),trace:c(`TRACE`)},trace:s(`TRACE`)}})(it()),at=e=>(e.client??F).get({url:`/_allauth/{client}/v1/auth/provider/signup`,...e}),ot=e=>(e.client??F).post({url:`/_allauth/{client}/v1/auth/provider/signup`,...e,headers:{"Content-Type":`application/json`,...e.headers}}),st=e=>(e.client??F).delete({url:`/_allauth/{client}/v1/auth/session`,...e}),ct=e=>(e.client??F).get({url:`/_allauth/{client}/v1/auth/session`,...e});function lt(e){return!e.ok&&e.status===409}function I(e,t){let n=e;if(n&&Array.isArray(n.errors))return{ok:!1,status:t,errors:n.errors};let r=n?.data;return r&&Array.isArray(r.flows)?{ok:!1,status:t,errors:[],flows:r.flows}:{ok:!1,status:t,errors:[]}}async function L(){let{data:e,error:t,response:n}=await ct({path:{client:`browser`}});return e?{ok:!0,data:e.data}:I(t,n?.status)}async function ut(){let{data:e,error:t,response:n}=await st({path:{client:`browser`}});return e?{ok:!0,data:e}:n?.status===401?{ok:!0,data:{}}:I(t,n?.status)}async function dt(){let{data:e,error:t,response:n}=await at({path:{client:`browser`}});return e?{ok:!0,data:e.data}:I(t,n?.status)}async function ft({email:e,username:t}){let{data:n,error:r,response:i}=await ot({path:{client:`browser`},body:{email:e,username:t}});return n?{ok:!0,data:n.data}:I(r,i?.status)}var pt=`__Secure-csrftoken`;function R(){return window.vellum?.csrf?.getToken()||document.cookie.split(`; `).findLast(e=>e.startsWith(`${pt}=`))?.split(`=`).slice(1).join(`=`)}function mt(){document.cookie.split(`; `).filter(e=>e.startsWith(`${pt}=`)).length>1&&(document.cookie=`${pt}=; path=/; max-age=0; secure`)}var ht=null;async function gt(){m()||(mt(),!R()&&(ht||=(async()=>{for(let e=0;e<2;e++)try{if(await ct({path:{client:`browser`}}),R())return}catch{console.warn(`CSRF cookie bootstrap failed (attempt ${e+1}/2)`),e===0&&await new Promise(e=>setTimeout(e,500))}})().finally(()=>{ht=null}),await ht))}var _t=`/accounts/oidc/redirect/`;function vt(e,t,n,r={}){let i={provider:e,callback_url:new URL(t,n).href,process:`login`};return r.intent&&(i.intent=r.intent),r.loginHint&&(i.login_hint=r.loginHint),r.providerHint&&(i.provider_hint=r.providerHint),i}function yt(e){if(!e)throw Error(`Unable to start provider redirect: CSRF token is missing. The session may not be initialized. Please refresh the page and try again.`)}async function bt(e,t,n={}){await gt();let r=R();yt(r);let i=window.location.origin,a=document.createElement(`form`);a.method=`POST`,a.action=`${i}${_t}`;let o=vt(e,t,i,n);o.csrfmiddlewaretoken=r;for(let[e,t]of Object.entries(o)){let n=document.createElement(`input`);n.type=`hidden`,n.name=e,n.value=t,a.appendChild(n)}document.body.appendChild(a),a.submit()}function xt(e,t){return e?{kind:`authenticated`}:t.some(e=>e.id===`provider_signup`&&e.is_pending)?{kind:`provider_signup`}:{kind:`error`,message:`Unexpected authentication state.`}}function St(e){return e===`vellum.ai`||e.endsWith(`.vellum.ai`)}var Ct=/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//;function wt(e,t){if(!e)return t;if(Ct.test(e)){try{let t=new URL(e);if(t.protocol===`https:`&&St(t.hostname))return e}catch{}return t}return e.startsWith(`//`)||e.includes(`\\`)||!e.startsWith(`/`)?t:e}var Tt=`https://www.vellum.ai`,Et=`vellum:loopback:state`,Dt=`vellum:loopback:returnTo`;function Ot(){let e=window.__VELLUM_CONFIG__;return e?.webUrl?{webUrl:e.webUrl}:{webUrl:Tt}}function kt(){let e=new Uint8Array(32);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function At(){return Ot().webUrl===window.location.origin}async function jt(e,t){let{webUrl:n}=Ot(),r=kt(),i=window.location.port||`3000`;sessionStorage.setItem(Et,r),e&&sessionStorage.setItem(Dt,e);let a=`/accounts/cli/callback?port=${i}&state=${r}`,o=`${n}/account/${t?.intent===`signup`?`signup`:`login`}?returnTo=${encodeURIComponent(a)}`;window.location.href=o}async function Mt(e){de()&&await window.vellum?.menu.setPlatformSession(e)}var Nt=e(u(),1),Pt=ve(`NativeAuth`),Ft=w.assistant;function It(){return`${window.location.protocol}//${window.location.host}`}function z(){return typeof window<`u`&&ye.isNativePlatform()}var Lt=()=>()=>{};function Rt(){return(0,Nt.useSyncExternalStore)(Lt,z,()=>!1)}async function zt(e){let t=e?.baseURL??It(),{sessionToken:n}=await Pt.startAuth({baseURL:t,...e?.loginHint?{loginHint:e.loginHint}:{},...e?.providerHint?{providerHint:e.providerHint}:{}});Vt(n),z()&&await Bt(),Yt()&&await Kt(n);let r=wt(e?.returnTo??null,Ft);window.location.href=r}async function Bt(){for(let e=0;e<6;e++){try{let e=await L();if(e.ok&&e.data.user)return}catch{}await new Promise(t=>setTimeout(t,50*(e+1)))}}function Vt(e){let t=`path=/; domain=.vellum.ai; secure; samesite=lax; max-age=1209600`;document.cookie=`sessionid=${e}; ${t}`,document.cookie=`__Secure-sessionid=${e}; ${t}`}function Ht(){if(typeof document>`u`)return null;let e=document.cookie.split(`; `);for(let t of[`__Secure-sessionid`,`sessionid`]){let n=e.find(e=>e.startsWith(`${t}=`));if(n){let e=n.slice(t.length+1);if(e)return e}}return null}async function Ut(e,t,n={}){if(z()){try{await zt({returnTo:n.intent===`signup`?w.onboarding.privacy:n.returnTo??null,loginHint:n.loginHint,providerHint:n.providerHint})}catch(e){if(e?.code===`USER_CANCELLED`)return;throw e}return}if(de()&&window.vellum?.auth?.startOAuth){if((await window.vellum.auth.startOAuth({providerHint:n.providerHint,loginHint:n.loginHint,intent:n.intent}))?.sessionToken){await Mt(!0);let e=wt(n.intent===`signup`?w.onboarding.privacy:n.returnTo??null,Ft);window.location.href=e}return}if(g()&&!At()){await jt(n.returnTo??void 0,{intent:n.intent});return}await bt(e,t,n)}var B=ve(`NativeBiometric`),Wt=`vellum.ai`;async function Gt(){if(!z())return!1;try{let{available:e}=await B.isAvailable();return e}catch{return!1}}async function Kt(e){if(!await Gt())return!1;try{return await B.storeToken({token:e,server:Wt}),!0}catch(e){return console.error(`[native-biometric] failed to store token:`,e),!1}}var V=null;async function qt(){return z()?V||(V=(async()=>{try{let{token:e}=await B.retrieveToken({server:Wt,reason:`Sign in to Vellum`});return e}catch{return null}finally{V=null}})(),V):null}async function Jt(){if(z())try{await B.deleteToken({server:Wt})}catch{}}function Yt(){return o(`biometricEnabled`,!0)}function Xt(e){a(`biometricEnabled`,e)}async function Zt(){if(!z())return`Biometrics`;try{let{biometryType:e}=await B.isAvailable();switch(e){case`faceId`:return`Face ID`;case`touchId`:return`Touch ID`;case`opticId`:return`Optic ID`;default:return`Biometrics`}}catch{return`Biometrics`}}function Qt(e){return e}function $t(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return{code:null,message:n};let r=Qt(e),i=r[t];if(Array.isArray(i)&&i.length>0){let e=i[0];if(typeof e==`string`)return{code:null,message:e};if(e&&typeof e==`object`&&!Array.isArray(e)){let t=Qt(e),r=t.code,i=t.string??t.message;return{code:typeof r==`string`?r:null,message:typeof i==`string`?i:n}}}return typeof r.detail==`string`?{code:null,message:r.detail}:{code:null,message:n}}var en={too_short:`Must be at least 3 characters.`,too_long:`Must be at most 30 characters.`,invalid_chars:`Use only lowercase letters, digits, hyphens, and underscores.`,leading_underscore:`Cannot start with an underscore.`,trailing_underscore:`Cannot end with an underscore.`,leading_hyphen:`Cannot start with a hyphen.`,trailing_hyphen:`Cannot end with a hyphen.`,all_digits:`Cannot be all digits.`,reserved:`This handle is reserved.`,taken:`This handle is already taken.`};async function tn(){let{data:e,error:t,response:n}=await C.get({url:`/v1/user/me/`,throwOnError:!1});if(fe(n,t,`Failed to load profile.`),!n.ok||!e)throw new pe(n.status,x(t,n,`Failed to load profile.`));return e}var nn=`Please choose a different handle.`;async function rn(e){let{data:t,error:n,response:r}=await C.patch({url:`/v1/user/me/`,body:e,throwOnError:!1});if(!r)return{kind:`error`,message:x(n,void 0,`Failed to save profile.`)??`Failed to save profile.`};if(r.ok&&t)return{kind:`ok`,data:t};if(r.status===409){let{message:e}=$t(n,`username`,en.taken);return{kind:`taken`,message:e}}if(r.status===400){let{code:e,message:t}=$t(n,`username`,nn);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:x(n,r,`Failed to save profile.`)}}async function an(e){await C.patch({url:`/v1/user/me/`,body:{consent:e},throwOnError:!0})}async function on(e,t){let{data:n,error:r,response:i}=await C.get({url:`/v1/user/username-available/`,query:{username:e},signal:t,throwOnError:!1});if(fe(i,r,`Failed to check handle availability.`),!i.ok||!n)throw new pe(i.status,i.status===429?`Too many checks — try again in a moment.`:x(r,i,`Failed to check handle availability.`));return n}var sn=s(`shareAnalytics`),cn=s(`shareDiagnostics`),ln=f()(e=>({shareAnalytics:i(sn,!0),shareDiagnostics:i(cn,!0),tosAccepted:!1,aiDataConsent:!1,setShareAnalytics:n=>{e({shareAnalytics:n}),t(sn,n)},setShareDiagnostics:n=>{e({shareDiagnostics:n}),t(cn,n)},setTosAccepted:t=>{e({tosAccepted:t})},setAiDataConsent:t=>{e({aiDataConsent:t})}})),H=p(ln),un=new Map([[sn,`shareAnalytics`],[cn,`shareDiagnostics`]]),dn={shareAnalytics:!0,shareDiagnostics:!0};for(let[e,t]of un)n(e,()=>{let n=i(e,dn[t]??!1);ln.setState({[t]:n})});var U=`2026-06-08`;function W(e,t){return`device:consent:${e}:v${U}:${t}`}function fn(e){if(typeof window>`u`||!e)return{tos:!1,ai:!1};try{let t=i(W(`tos`,e),!1),n=i(W(`ai`,e),!1);if(t||n)return{tos:t,ai:n};let r=i(`vellum:onboarding:tosAccepted`,!1),a=i(`vellum:onboarding:aiDataConsent`,!1);return r||a?(pn(e,r,a),{tos:r,ai:a}):{tos:!1,ai:!1}}catch{return{tos:!1,ai:!1}}}function pn(e,n,r){if(!(typeof window>`u`||!e))try{t(W(`tos`,e),n),t(W(`ai`,e),r)}catch{}}function mn(e){if(r(`vellum:onboarding:tosAccepted`),r(`vellum:onboarding:aiDataConsent`),r(`vellum:onboarding:selectedVersion`),!(typeof window>`u`||!e))try{r(W(`tos`,e)),r(W(`ai`,e))}catch{}}function hn(e){return e?{tos:e.tos_accepted_version===`2026-06-08`&&e.privacy_policy_accepted_version===`2026-06-08`,ai:e.ai_data_sharing_accepted_version===U,shareAnalytics:e.share_analytics,shareDiagnostics:e.share_diagnostics}:{tos:!1,ai:!1,shareAnalytics:null,shareDiagnostics:null}}function gn(e){let t=H.getState();t.setTosAccepted(e.tos),t.setAiDataConsent(e.ai),t.setShareAnalytics(e.shareAnalytics),t.setShareDiagnostics(e.shareDiagnostics),pn(e.userId,e.tos,e.ai),e.hasPlatformSession&&an({tos_accepted_version:e.tos?U:``,privacy_policy_accepted_version:e.tos?U:``,ai_data_sharing_accepted_version:e.ai?U:``,share_analytics:e.shareAnalytics,share_diagnostics:e.shareDiagnostics}).catch(()=>{})}function _n(e,t,n){let r=H.getState();e===`share_analytics`?(r.setShareAnalytics(t),a(`shareAnalytics`,t)):(r.setShareDiagnostics(t),a(`shareDiagnostics`,t)),n&&an({[e]:t}).catch(()=>{})}var vn=`vellum_active_organization_id`;function yn(){return globalThis.sessionStorage===void 0?null:globalThis.sessionStorage}function bn(){let e=yn();if(!e)return null;try{return e.getItem(vn)}catch{return null}}function xn(e){let t=yn();if(t)try{t.setItem(vn,e)}catch{}}function Sn(){let e=yn();if(e)try{e.removeItem(vn)}catch{}}function Cn(e,t){return e.length===0?null:t&&e.some(e=>e.id===t)?t:e[0].id}var G=p(f()((e,t)=>({organizations:[],currentOrganizationId:null,status:`idle`,error:null,fetchOrganizations:async()=>{e({status:`loading`,error:null});try{let n=(await _e()).data?.results??[],r=Cn(n,t().currentOrganizationId??bn());r&&xn(r),e({organizations:n,currentOrganizationId:r,status:r?`ready`:`error`,error:r?null:`No organization available for this user.`})}catch(t){e({status:`error`,error:t instanceof Error&&t.message?t.message:`Failed to load organizations.`})}},setCurrentOrganizationId:n=>{let{organizations:r}=t();r.some(e=>e.id===n)&&(xn(n),e({currentOrganizationId:n,status:`ready`}))},clearOrganization:()=>{Sn(),e({organizations:[],currentOrganizationId:null,status:`idle`,error:null})}})));function wn(){return G.getState().currentOrganizationId??bn()}function Tn(){G.getState().clearOrganization()}function En(){let e=0,t=G.subscribe(t=>{(t.status===`ready`||t.status===`error`)&&(e=Date.now())}),n=$.subscribe((e,t)=>{let n=j(e.platformSession),r=j(t.platformSession);n&&(!r||e.user?.id!==t.user?.id)&&G.getState().fetchOrganizations()}),r=()=>{if(!j($.getState().platformSession))return;let{status:t}=G.getState();(t===`ready`||t===`error`)&&Date.now()-e>1e4&&G.getState().fetchOrganizations()},i=be(`app.resume`,()=>{r()});return()=>{t(),n(),i()}}var Dn=`vellum:`,On=[`onboarding.`,`voice:`,`gw:`,`ff:client:`,`local:`,`integrations.`,`vellumDebug.`,`vellum_`],kn=new Set([`vellum_theme`,`vellum_share_analytics`,`vellum_share_diagnostics`,`vellum_biometric_enabled`,`vellum_llm_log_retention`,`vellum_timezone`,`vellum_media_embeds_enabled`,`vellum_media_embed_domains`,`onboarding.lastUserId`]);function An(e){return e.startsWith(Dn)?!0:kn.has(e)?!1:On.some(t=>e.startsWith(t))}function jn(){try{sessionStorage.clear()}catch{}try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&An(n)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e))}catch{}}function Mn(e){return e?.id??e?.email??e?.username??null}function K(e){return e?{id:Mn(e),username:e.username??null,email:e.email??null,isStaff:e.is_staff??!1,firstName:e.first_name??``,lastName:e.last_name??``}:null}var q=null,J=null,Nn=!1,Pn={id:`gateway-local`,username:`local`,email:null,isStaff:!1,firstName:`Local`,lastName:`User`},Y=e=>({sessionStatus:`authenticated`,user:e,platformSession:`present`}),Fn=()=>({sessionStatus:`authenticated`,user:Pn}),X=()=>({sessionStatus:`unauthenticated`,user:null,platformSession:`absent`});function In(e){(!e||q&&q!==e)&&Tn(),q=e}function Ln(){J?.postMessage(`auth-changed`)}async function Z(e){if(e)try{let t=await tn();if(t.consent){let n=hn(t.consent),r=H.getState();r.setTosAccepted(n.tos),r.setAiDataConsent(n.ai),n.shareAnalytics!==null&&r.setShareAnalytics(n.shareAnalytics),n.shareDiagnostics!==null&&r.setShareDiagnostics(n.shareDiagnostics),pn(e,n.tos,n.ai),In(e);return}let n=fn(e),r=H.getState();r.setTosAccepted(n.tos),r.setAiDataConsent(n.ai),n.tos&&n.ai&&an({tos_accepted_version:U,privacy_policy_accepted_version:U,ai_data_sharing_accepted_version:U}).catch(()=>{}),In(e);return}catch{}let t=fn(e),n=H.getState();n.setTosAccepted(t.tos),n.setAiDataConsent(t.ai),In(e)}var Rn=0;Promise.resolve();function zn(e,t={}){let n=++Rn,r=()=>n!==Rn;L().then(async n=>{if(!r())if(n.ok&&n.data.user){let i=t.setUserOnSuccess?{user:K(n.data.user)}:{};if(g())try{let e=await Promise.race([S(),new Promise((e,t)=>setTimeout(()=>t(Error(`sync timeout`)),3e3))]);!r()&&e.ok&&await ie(e.data)}catch{}if(r())return;e({platformSession:`present`,...i})}else t.clearOnFailure&&e({platformSession:`absent`})}).catch(()=>{r()||t.clearOnFailure&&e({platformSession:`absent`})}).finally(()=>{r()||e(e=>e.platformSession===`unknown`?{platformSession:`absent`}:{})})}function Q(e,t){!g()||_()||v().length>0?zn(e,t):e({platformSession:`absent`})}var $=p(f()(e=>({sessionStatus:`initializing`,user:null,platformSession:`unknown`,initSession:async()=>{if(_()){try{await ce(),e(Fn())}catch{e({sessionStatus:`unauthenticated`,user:null})}Q(e);return}if(g()&&!_()){if(v().length>0){try{let t=await L();if(t.ok&&t.data.user){let n=K(t.data.user);await Z(n?.id??null);try{let t=await S();if(t.ok&&(await ie(t.data),v().length===0&&oe().length===0)){e(Y(n));return}}catch{}e(Y(n));return}}catch{}e(X());return}e(Fn()),Nn?e({platformSession:`absent`}):zn(e,{setUserOnSuccess:!0}),Nn=!1;return}try{let t=await L();if(t.ok&&t.data.user){let n=K(t.data.user);await Z(n?.id??null);try{let e=await S();e.ok&&y.getState().setFromApi(e.data)}catch{}e(Y(n));return}}catch(e){console.error(`auth.initSession failed`,e)}if(z()&&Yt())try{let t=await qt();if(t){Vt(t),await Bt();let n=await L();if(n.ok&&n.data.user){let t=K(n.data.user);await Z(t?.id??null);try{let e=await S();e.ok&&y.getState().setFromApi(e.data)}catch{}e(Y(t));return}}}catch(e){console.warn(`auth.initSession biometric recovery failed`,e)}await Z(null),e(X())},connectLocalAssistant:async t=>{ue(t),await ae(),e(Fn()),Q(e)},connectPlatformAssistant:async t=>{ue(t);let n=await L();if(!n.ok||!n.data.user)throw Error(`Platform authentication required`);let r=K(n.data.user);await Z(r?.id??null),e(Y(r))},refreshSession:async()=>{if(m()){try{await ee(te()),e({sessionStatus:`authenticated`})}catch{return e(X()),!1}return Q(e,{clearOnFailure:!0}),!0}try{let t=await L();if(t.ok&&t.data.user){let n=K(t.data.user);if(await Z(n?.id??null),g())try{let e=await S();e.ok&&await ie(e.data)}catch{}return e(Y(n)),!0}}catch(e){console.warn(`auth.refreshSession failed`,e)}return await Z(null),e(X()),!1},logout:async()=>{if(m()){le(),ne(),Tn(),jn(),M.resetForLogout(),e(X()),Ln();return}Nn=!0;try{await ut()}finally{g()&&(document.cookie=`sessionid=; path=/; samesite=lax; expires=Thu, 01 Jan 1970 00:00:00 UTC`),Jt(),Tn(),jn(),M.resetForLogout(),e(X()),Ln()}}}))),Bn=()=>A($.use.sessionStatus()),Vn=()=>!Ae($.use.sessionStatus()),Hn=()=>j($.use.platformSession());function Un(){let{refreshSession:e}=$.getState(),t=[],n=()=>e().catch(e=>console.warn(`auth.refreshSession failed`,e)),r=be(`app.resume`,()=>{n()});return t.push(r),typeof BroadcastChannel<`u`&&(J=new BroadcastChannel(`auth`),J.onmessage=()=>{jn(),window.location.reload()},t.push(()=>{J?.close(),J=null})),()=>t.forEach(e=>e())}export{At as A,M as B,Kt as C,zt as D,Ut as E,dt as F,Ce as G,A as H,L as I,xe as J,we as K,lt as L,xt as M,gt as N,Rt as O,R as P,ft as R,Xt as S,z as T,Ae as U,j as V,ke as W,T as Y,$t as _,Vn as a,Gt as b,G as c,_n as d,H as f,rn as g,tn as h,Bn as i,wt as j,Mt as k,mn as l,on as m,$ as n,wn as o,en as p,E as q,Hn as r,En as s,Un as t,gn as u,Jt as v,Ht as w,Yt as x,Zt as y,F as z};
|