@vellumai/web 0.11.1-dev.202608041836.2a522b8 → 0.11.1-dev.202608042001.feb8dd6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/assets/{acp-run-detail-panel-DM5Bhk6n.js → acp-run-detail-panel-1fP6d_ON.js} +1 -1
  2. package/dist/assets/{activity-steps-panel-BCMjPosR.js → activity-steps-panel-CFkZ8xns.js} +1 -1
  3. package/dist/assets/animate-piJqb5cQ.js +1 -0
  4. package/dist/assets/{app-card-ClwFu1LN.js → app-card-BVXlnqNM.js} +1 -1
  5. package/dist/assets/{background-task-detail-panel-BmpQdq-y.js → background-task-detail-panel-DK0IqywD.js} +1 -1
  6. package/dist/assets/{billing-page-DXzpxKdv.js → billing-page-DaYHDjYO.js} +1 -1
  7. package/dist/assets/{bookmarks-page-DvMPEZmy.js → bookmarks-page-CqD7wCeL.js} +1 -1
  8. package/dist/assets/{channels-page-route-BNXoujCx.js → channels-page-route-b1l_ABbb.js} +1 -1
  9. package/dist/assets/{chat-markdown-message-CiJp6NwX.js → chat-markdown-message-CUdfr2wG.js} +1 -1
  10. package/dist/assets/{contacts-page-route-BntmoT1q.js → contacts-page-route-sCeHWsd0.js} +1 -1
  11. package/dist/assets/{conversation-navigation-Cx_JZlxF.js → conversation-navigation-k0nLUcrV.js} +1 -1
  12. package/dist/assets/{debug-page-KbZ23yRm.js → debug-page-8R3JDz4U.js} +1 -1
  13. package/dist/assets/{document-viewer-page-BiIrX_Id.js → document-viewer-page-DvoWqXG4.js} +1 -1
  14. package/dist/assets/first-run-scope-C7NUo0oy.js +1 -0
  15. package/dist/assets/{home-page-route-CZCY0nEA.js → home-page-route-Ch2FbX2b.js} +1 -1
  16. package/dist/assets/identity-page-route-BRt2ck1_.js +7 -0
  17. package/dist/assets/index-C3w1NiEH.css +2 -0
  18. package/dist/assets/{index-Dhip4b6y.js → index-lOqt4q0A.js} +1 -1
  19. package/dist/assets/{inspect-page-D0p9B0vZ.js → inspect-page-Clek0T5C.js} +1 -1
  20. package/dist/assets/{integrations-page-DXorhDgJ.js → integrations-page-DAulhj-a.js} +1 -1
  21. package/dist/assets/{library-detail-page-C8s5b0ug.js → library-detail-page-CM48qI75.js} +1 -1
  22. package/dist/assets/{library-page-BZTrg8rP.js → library-page-Basy_ltt.js} +1 -1
  23. package/dist/assets/{memory-page-route-D7DsI72U.js → memory-page-route-A6-_GkCM.js} +1 -1
  24. package/dist/assets/{message-files-panel-CSWUz3fN.js → message-files-panel-DGJ1_tEm.js} +1 -1
  25. package/dist/assets/{messages-CW87Dtd_.js → messages-S9VSjR8B.js} +1 -1
  26. package/dist/assets/{open-workspace-file-B7_lXQau.js → open-workspace-file-gzML_adc.js} +2 -2
  27. package/dist/assets/research-onboarding-route-D4wx73V1.js +50 -0
  28. package/dist/assets/routes-kaTsc8gq.js +23 -0
  29. package/dist/assets/{schedules-page-gJTkpWvU.js → schedules-page-vTzrVOtu.js} +1 -1
  30. package/dist/assets/{skill-detail-page-wzM7dFk2.js → skill-detail-page-DuefXZlk.js} +1 -1
  31. package/dist/assets/{subagent-detail-panel-DGT3JpGj.js → subagent-detail-panel-Ci26mpW-.js} +1 -1
  32. package/dist/assets/{tool-detail-panel-C0l0SwkG.js → tool-detail-panel-BXQ92OcJ.js} +1 -1
  33. package/dist/assets/{transcript-message-body-shared-a-m7amCu.js → transcript-message-body-shared-KhIrDX7O.js} +1 -1
  34. package/dist/assets/{use-edit-app-3dKcJKAP.js → use-edit-app-Dp4Gw1kj.js} +1 -1
  35. package/dist/assets/use-transcript-message-by-id-BDMwOUgh.js +1 -0
  36. package/dist/assets/{use-transcript-messages-Bs3EjduJ.js → use-transcript-messages-DjwHicXg.js} +1 -1
  37. package/dist/assets/{viewer-store-Dc5epEgj.js → viewer-store-CDzOG6-y.js} +1 -1
  38. package/dist/index.html +14 -14
  39. package/package.json +1 -1
  40. package/dist/assets/dices-C3diFTyP.js +0 -1
  41. package/dist/assets/first-run-scope-BaNgebhs.js +0 -1
  42. package/dist/assets/identity-page-route-AA6gv_H4.js +0 -7
  43. package/dist/assets/index-BSM1Vpxy.css +0 -2
  44. package/dist/assets/research-onboarding-route-aYybZo60.js +0 -50
  45. package/dist/assets/routes-Flf73W7-.js +0 -23
  46. package/dist/assets/use-transcript-message-by-id-Bmzp4W6P.js +0 -1
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-fyWSnR9X.js";import{l as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./typography-DEI9Ra9z.js";import{t as s}from"./createLucideIcon-CAM1RhH8.js";import{t as c}from"./chevron-up-DofScvyy.js";import{t as l}from"./menu-D7gzADvH.js";import"./src-Co3nj9N_.js";import{t as u}from"./globe-CdLn4IX7.js";import{t as d}from"./loader-circle-DWWXcfTQ.js";import{n as f,t as p}from"./minimize-2-Dj9FY4aF.js";import{t as m}from"./pencil-Cm5DdeRM.js";import{t as h}from"./x-D4O9yIS7.js";import{n as g,t as _}from"./panel-item-DKyA_s0w.js";import{n as v}from"./resolved-assistants-store-C6oDdTxB.js";import{t as y}from"./client.gen-Dq2brHDV.js";import{n as b}from"./event-bus-CbDg1VDt.js";import{d as x}from"./routes-DrfnNoYS.js";import{t as S}from"./conversation-store-CTMy9QPV.js";import{i as C}from"./viewer-store-Dc5epEgj.js";import{n as w}from"./use-is-mobile-MmHo-OM6.js";import{t as T}from"./misc-BBsGq1IU.js";import{r as E,t as D}from"./edit-chat-session-DVzLQLWl.js";import{n as O,t as k}from"./sandbox-bridge-B5H4c27m.js";var A=s(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),j=s(`share`,[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]),M=a(),N=e(t(),1),P=`flags.toggleAppsSandboxDisabled`,F=!1,I=new Set;function L(){return F}function R(e){let t=e===void 0?!F:e===!0;if(t===F)return console.info(`[vellumDebug] ${P}: already ${String(t)}.`),F;F=t,t?console.warn(`[vellumDebug] ${P} = true: app iframes render without the sandbox attribute. App HTML runs same-origin with the host and can reach its DOM, storage, and cookies. Open apps reload to pick this up. Call it again, or reload the page, to restore the sandbox.`):console.info(`[vellumDebug] ${P} = false: app iframes are sandboxed again.`);for(let e of I)e();return F}function z(e){return I.add(e),()=>{I.delete(e)}}function B(){return(0,N.useSyncExternalStore)(z,L,()=>!1)}function V({appName:e,onEdit:t,isEditing:r,onShare:i,isSharing:a,onDeploy:s,isDeploying:l,onToggleFullscreen:p,onClose:g}){let _=w(),v=_&&r===!0&&t!=null,y=i!=null&&s!=null;return(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-t-xl bg-[var(--surface-lift)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`hidden md:flex items-center min-w-[72px]`,children:t!=null&&(r?(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(A,{}),onClick:t,tooltip:`Expand app`,"aria-label":`Expand app`}):(0,M.jsx)(n,{onClick:t,children:`Edit`}))}),(0,M.jsx)(o,{variant:`body-large-default`,className:T(`flex-1 truncate text-left md:text-center text-[var(--content-emphasised)]`,v&&`cursor-pointer`),style:{lineHeight:1.4},onClick:v?t:void 0,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-[72px] justify-end`,children:[y?(0,M.jsx)(H,{onShare:i,isSharing:a,onDeploy:s,isDeploying:l,isMobile:_}):(0,M.jsxs)(M.Fragment,{children:[s!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:l?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(u,{}),onClick:s,disabled:l,tooltip:l?`Deploying…`:`Deploy`,"aria-label":l?`Deploying…`:`Deploy`}),i!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:a?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),onClick:i,disabled:a,tooltip:a?`Sharing…`:`Share`,"aria-label":a?`Sharing…`:`Share`})]}),p!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(f,{}),onClick:p,tooltip:`Fullscreen`,"aria-label":`Fullscreen`}),t!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:r?(0,M.jsx)(c,{}):(0,M.jsx)(m,{}),onClick:t,tooltip:r?`Open app`:`Edit`,"aria-label":r?`Open app`:`Edit`,active:r,className:`md:hidden`}),(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(h,{}),onClick:g,tooltip:`Close`,"aria-label":`Close`})]})]})}function H({onShare:e,isSharing:t,onDeploy:r,isDeploying:i,isMobile:a}){let[o,s]=(0,N.useState)(!1),c=t||i,f=c?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),p=t?`Sharing…`:i?`Deploying…`:`Share & deploy`;return a?(0,M.jsxs)(g.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(g.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(g.Content,{"aria-describedby":void 0,children:[(0,M.jsx)(g.Header,{className:`sr-only`,children:(0,M.jsx)(g.Title,{children:`Share & deploy`})}),(0,M.jsxs)(g.Body,{className:`pt-0`,children:[(0,M.jsx)(_,{icon:j,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Share`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Export as .vellum file`})]}),onSelect:()=>{s(!1),e()}}),(0,M.jsx)(_,{icon:u,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Deploy to Vercel`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Publish as a static page`})]}),onSelect:()=>{s(!1),r()}})]})]})]}):(0,M.jsxs)(l.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(l.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(l.Content,{align:`end`,sideOffset:4,children:[(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(j,{size:14}),onSelect:()=>e(),className:`whitespace-nowrap`,children:`Share`}),(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(u,{size:14}),onSelect:()=>r(),className:`whitespace-nowrap`,children:`Deploy to Vercel`})]})]})}var U=[`assistant:`,`conversation:`,`conversations:`,`apps:`,`plugins:`,`feature-flags:`];function W(e){return U.some(t=>e.startsWith(t))}function G(e,t){if(e.length===0)return[];let n=new Set(e);return t.filter(e=>n.has(e)&&!W(e))}function K(e,t){let{frameId:n,assistantId:r,appId:i,enabled:a=!0,onAction:o,onOpenVellumLink:s}=t,c=(0,N.useRef)(new Map);(0,N.useEffect)(()=>{let t=c.current,l=async c=>{let l=c.data;if(!l||l.frameId!==n||c.source!==e.current?.contentWindow)return;if(l.type===`vellum_subscribe`){if(!a)return;let{subId:e,tags:n}=l;typeof e==`string`&&Array.isArray(n)&&t.set(e,new Set(n.filter(e=>typeof e==`string`)));return}if(l.type===`vellum_unsubscribe`){let{subId:e}=l;typeof e==`string`&&t.delete(e);return}if(l.type===`vellum_surface_action`){o?.(l.actionId,l.data);return}if(l.type===`vellum_open_link`){if(!navigator.userActivation?.isActive)return;s?.(l.href,l.linkText);return}if(l.type===`vellum_asset_request`){let{callId:t,path:n}=l,o=e.current,s=(e,t)=>{o?.contentWindow?.postMessage(e,`*`,t??[])};if(!a){s({type:`vellum_asset_response`,callId:t,error:`Asset proxy disabled`});return}if(!i){s({type:`vellum_asset_response`,callId:t,error:`No app context for assets`});return}if(typeof n!=`string`||n===``||n.includes(`..`)){s({type:`vellum_asset_response`,callId:t,error:`Invalid asset path`});return}try{let e=`/v1/assistants/${r}/apps/${i}/asset/${n.split(`/`).map(encodeURIComponent).join(`/`)}`,{data:a,response:o}=await y.get({url:e,parseAs:`blob`,throwOnError:!1});if(!o?.ok||!(a instanceof Blob)){s({type:`vellum_asset_response`,callId:t,error:`Asset fetch failed (${o?.status??0})`});return}let c=await a.arrayBuffer();s({type:`vellum_asset_response`,callId:t,buffer:c,contentType:a.type||`application/octet-stream`},[c])}catch(e){s({type:`vellum_asset_response`,callId:t,error:e instanceof Error?e.message:`Asset proxy error`})}return}if(!a||l.type!==`vellum_fetch_request`)return;let{callId:u,path:d,method:f,headers:p,body:m}=l,h=e.current,g=e=>{h?.contentWindow?.postMessage(e,`*`)};if(!k.test(d)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: only /v1/x/ custom routes are allowed`});return}try{let e=new URL(d,`https://placeholder`).pathname;if(!k.test(e)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: path traversal detected`});return}}catch{g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: invalid path`});return}let _=`/v1/assistants/${r}/${d.replace(/^\/v1\//,``)}`;try{let e={url:_,throwOnError:!1,headers:p&&Object.keys(p).length>0?p:void 0,body:m?JSON.parse(m):void 0},t=await(f===`POST`?y.post:f===`PUT`?y.put:f===`PATCH`?y.patch:f===`DELETE`?y.delete:y.get)(e),n=t.response,r=t.data??t.error,i=r==null?``:typeof r==`string`?r:JSON.stringify(r);g({type:`vellum_fetch_response`,callId:u,status:n?.status??0,statusText:n?.statusText??``,body:i})}catch(e){g({type:`vellum_fetch_response`,callId:u,error:e instanceof Error?e.message:`Fetch proxy error`})}};window.addEventListener(`message`,l);let u=b(`sse.event`,r=>{let i=r.message;if(!i||i.type!==`sync_changed`||!Array.isArray(i.tags))return;let a=e.current?.contentWindow;if(!a||t.size===0)return;let o=i.tags.filter(e=>typeof e==`string`);for(let[e,r]of t){let t=G([...r],o);t.length>0&&a.postMessage({type:`vellum_event`,frameId:n,subId:e,event:{type:`sync_changed`,tags:t}},`*`)}});return()=>{window.removeEventListener(`message`,l),u()}},[n,r,i,a,o,s,e])}var q=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function J({appId:e,appName:t,html:r,assistantId:i,onClose:a,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,route:f,enableFullscreen:m=!1,onAction:h}){let g=(0,N.useRef)(null),[_,v]=(0,N.useState)(!1),y=(0,N.useCallback)(()=>v(e=>!e),[]);(0,N.useEffect)(()=>{v(!1)},[e]),(0,N.useEffect)(()=>{if(!_)return;let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),v(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_]);let b=(0,N.useMemo)(()=>O(r,e,{fetch:!0,route:f}),[r,e,f]),x=B(),S=(0,N.useMemo)(()=>{let t=0;for(let e=0;e<r.length;e++)t=(t<<5)-t+r.charCodeAt(e)|0;return`app-${e}-${t}${x?`-nosandbox`:``}`},[r,e,x]);return K(g,{frameId:e,assistantId:i,appId:e,onAction:h}),(0,M.jsxs)(`div`,{"data-testid":`app-viewer-root`,className:T(`flex flex-col overflow-hidden bg-[var(--surface-base)]`,_?`fixed inset-0 z-[60]`:`h-full rounded-xl`),children:[!_&&(0,M.jsx)(V,{appName:t,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,onToggleFullscreen:m?y:void 0,onClose:a}),(0,M.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[_&&(0,M.jsx)(`div`,{className:`absolute z-10`,style:{top:`max(0.75rem, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,right:`max(0.75rem, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:(0,M.jsx)(n,{variant:`primary`,iconOnly:(0,M.jsx)(p,{}),onClick:y,tooltip:`Exit fullscreen`})}),(0,M.jsx)(`iframe`,{ref:g,srcDoc:b,sandbox:x?void 0:q,referrerPolicy:`no-referrer`,title:t,className:`h-full w-full border-none`},S)]})]})}function Y(){let e=v.use.activeAssistantId(),t=w(),n=i(),{pathname:a}=r();return(0,N.useCallback)(r=>{if(!e)return;let i=D(e,r.appId)??crypto.randomUUID();E(e,r.appId,i);let o=C.getState();(o.activeAppId!==r.appId||!o.openedAppState)&&(o.openApp(r.appId),o.setLoadedApp(r)),S.getState().setEditingConversationId(i),t?o.minimizeApp():o.enterAppEditing();let s=x.conversation(i);a!==s&&n(s)},[e,t,n,a])}export{j as a,R as i,J as n,K as r,Y as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-fyWSnR9X.js";import{l as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./typography-DEI9Ra9z.js";import{t as s}from"./createLucideIcon-CAM1RhH8.js";import{t as c}from"./chevron-up-DofScvyy.js";import{t as l}from"./menu-D7gzADvH.js";import"./src-Co3nj9N_.js";import{t as u}from"./globe-CdLn4IX7.js";import{t as d}from"./loader-circle-DWWXcfTQ.js";import{n as f,t as p}from"./minimize-2-Dj9FY4aF.js";import{t as m}from"./pencil-Cm5DdeRM.js";import{t as h}from"./x-D4O9yIS7.js";import{n as g,t as _}from"./panel-item-DKyA_s0w.js";import{n as v}from"./resolved-assistants-store-C6oDdTxB.js";import{t as y}from"./client.gen-Dq2brHDV.js";import{n as b}from"./event-bus-CbDg1VDt.js";import{d as x}from"./routes-DrfnNoYS.js";import{t as S}from"./conversation-store-CTMy9QPV.js";import{i as C}from"./viewer-store-CDzOG6-y.js";import{n as w}from"./use-is-mobile-MmHo-OM6.js";import{t as T}from"./misc-BBsGq1IU.js";import{r as E,t as D}from"./edit-chat-session-DVzLQLWl.js";import{n as O,t as k}from"./sandbox-bridge-B5H4c27m.js";var A=s(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),j=s(`share`,[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]),M=a(),N=e(t(),1),P=`flags.toggleAppsSandboxDisabled`,F=!1,I=new Set;function L(){return F}function R(e){let t=e===void 0?!F:e===!0;if(t===F)return console.info(`[vellumDebug] ${P}: already ${String(t)}.`),F;F=t,t?console.warn(`[vellumDebug] ${P} = true: app iframes render without the sandbox attribute. App HTML runs same-origin with the host and can reach its DOM, storage, and cookies. Open apps reload to pick this up. Call it again, or reload the page, to restore the sandbox.`):console.info(`[vellumDebug] ${P} = false: app iframes are sandboxed again.`);for(let e of I)e();return F}function z(e){return I.add(e),()=>{I.delete(e)}}function B(){return(0,N.useSyncExternalStore)(z,L,()=>!1)}function V({appName:e,onEdit:t,isEditing:r,onShare:i,isSharing:a,onDeploy:s,isDeploying:l,onToggleFullscreen:p,onClose:g}){let _=w(),v=_&&r===!0&&t!=null,y=i!=null&&s!=null;return(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-t-xl bg-[var(--surface-lift)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`hidden md:flex items-center min-w-[72px]`,children:t!=null&&(r?(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(A,{}),onClick:t,tooltip:`Expand app`,"aria-label":`Expand app`}):(0,M.jsx)(n,{onClick:t,children:`Edit`}))}),(0,M.jsx)(o,{variant:`body-large-default`,className:T(`flex-1 truncate text-left md:text-center text-[var(--content-emphasised)]`,v&&`cursor-pointer`),style:{lineHeight:1.4},onClick:v?t:void 0,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-[72px] justify-end`,children:[y?(0,M.jsx)(H,{onShare:i,isSharing:a,onDeploy:s,isDeploying:l,isMobile:_}):(0,M.jsxs)(M.Fragment,{children:[s!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:l?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(u,{}),onClick:s,disabled:l,tooltip:l?`Deploying…`:`Deploy`,"aria-label":l?`Deploying…`:`Deploy`}),i!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:a?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),onClick:i,disabled:a,tooltip:a?`Sharing…`:`Share`,"aria-label":a?`Sharing…`:`Share`})]}),p!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(f,{}),onClick:p,tooltip:`Fullscreen`,"aria-label":`Fullscreen`}),t!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:r?(0,M.jsx)(c,{}):(0,M.jsx)(m,{}),onClick:t,tooltip:r?`Open app`:`Edit`,"aria-label":r?`Open app`:`Edit`,active:r,className:`md:hidden`}),(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(h,{}),onClick:g,tooltip:`Close`,"aria-label":`Close`})]})]})}function H({onShare:e,isSharing:t,onDeploy:r,isDeploying:i,isMobile:a}){let[o,s]=(0,N.useState)(!1),c=t||i,f=c?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),p=t?`Sharing…`:i?`Deploying…`:`Share & deploy`;return a?(0,M.jsxs)(g.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(g.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(g.Content,{"aria-describedby":void 0,children:[(0,M.jsx)(g.Header,{className:`sr-only`,children:(0,M.jsx)(g.Title,{children:`Share & deploy`})}),(0,M.jsxs)(g.Body,{className:`pt-0`,children:[(0,M.jsx)(_,{icon:j,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Share`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Export as .vellum file`})]}),onSelect:()=>{s(!1),e()}}),(0,M.jsx)(_,{icon:u,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Deploy to Vercel`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Publish as a static page`})]}),onSelect:()=>{s(!1),r()}})]})]})]}):(0,M.jsxs)(l.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(l.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(l.Content,{align:`end`,sideOffset:4,children:[(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(j,{size:14}),onSelect:()=>e(),className:`whitespace-nowrap`,children:`Share`}),(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(u,{size:14}),onSelect:()=>r(),className:`whitespace-nowrap`,children:`Deploy to Vercel`})]})]})}var U=[`assistant:`,`conversation:`,`conversations:`,`apps:`,`plugins:`,`feature-flags:`];function W(e){return U.some(t=>e.startsWith(t))}function G(e,t){if(e.length===0)return[];let n=new Set(e);return t.filter(e=>n.has(e)&&!W(e))}function K(e,t){let{frameId:n,assistantId:r,appId:i,enabled:a=!0,onAction:o,onOpenVellumLink:s}=t,c=(0,N.useRef)(new Map);(0,N.useEffect)(()=>{let t=c.current,l=async c=>{let l=c.data;if(!l||l.frameId!==n||c.source!==e.current?.contentWindow)return;if(l.type===`vellum_subscribe`){if(!a)return;let{subId:e,tags:n}=l;typeof e==`string`&&Array.isArray(n)&&t.set(e,new Set(n.filter(e=>typeof e==`string`)));return}if(l.type===`vellum_unsubscribe`){let{subId:e}=l;typeof e==`string`&&t.delete(e);return}if(l.type===`vellum_surface_action`){o?.(l.actionId,l.data);return}if(l.type===`vellum_open_link`){if(!navigator.userActivation?.isActive)return;s?.(l.href,l.linkText);return}if(l.type===`vellum_asset_request`){let{callId:t,path:n}=l,o=e.current,s=(e,t)=>{o?.contentWindow?.postMessage(e,`*`,t??[])};if(!a){s({type:`vellum_asset_response`,callId:t,error:`Asset proxy disabled`});return}if(!i){s({type:`vellum_asset_response`,callId:t,error:`No app context for assets`});return}if(typeof n!=`string`||n===``||n.includes(`..`)){s({type:`vellum_asset_response`,callId:t,error:`Invalid asset path`});return}try{let e=`/v1/assistants/${r}/apps/${i}/asset/${n.split(`/`).map(encodeURIComponent).join(`/`)}`,{data:a,response:o}=await y.get({url:e,parseAs:`blob`,throwOnError:!1});if(!o?.ok||!(a instanceof Blob)){s({type:`vellum_asset_response`,callId:t,error:`Asset fetch failed (${o?.status??0})`});return}let c=await a.arrayBuffer();s({type:`vellum_asset_response`,callId:t,buffer:c,contentType:a.type||`application/octet-stream`},[c])}catch(e){s({type:`vellum_asset_response`,callId:t,error:e instanceof Error?e.message:`Asset proxy error`})}return}if(!a||l.type!==`vellum_fetch_request`)return;let{callId:u,path:d,method:f,headers:p,body:m}=l,h=e.current,g=e=>{h?.contentWindow?.postMessage(e,`*`)};if(!k.test(d)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: only /v1/x/ custom routes are allowed`});return}try{let e=new URL(d,`https://placeholder`).pathname;if(!k.test(e)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: path traversal detected`});return}}catch{g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: invalid path`});return}let _=`/v1/assistants/${r}/${d.replace(/^\/v1\//,``)}`;try{let e={url:_,throwOnError:!1,headers:p&&Object.keys(p).length>0?p:void 0,body:m?JSON.parse(m):void 0},t=await(f===`POST`?y.post:f===`PUT`?y.put:f===`PATCH`?y.patch:f===`DELETE`?y.delete:y.get)(e),n=t.response,r=t.data??t.error,i=r==null?``:typeof r==`string`?r:JSON.stringify(r);g({type:`vellum_fetch_response`,callId:u,status:n?.status??0,statusText:n?.statusText??``,body:i})}catch(e){g({type:`vellum_fetch_response`,callId:u,error:e instanceof Error?e.message:`Fetch proxy error`})}};window.addEventListener(`message`,l);let u=b(`sse.event`,r=>{let i=r.message;if(!i||i.type!==`sync_changed`||!Array.isArray(i.tags))return;let a=e.current?.contentWindow;if(!a||t.size===0)return;let o=i.tags.filter(e=>typeof e==`string`);for(let[e,r]of t){let t=G([...r],o);t.length>0&&a.postMessage({type:`vellum_event`,frameId:n,subId:e,event:{type:`sync_changed`,tags:t}},`*`)}});return()=>{window.removeEventListener(`message`,l),u()}},[n,r,i,a,o,s,e])}var q=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function J({appId:e,appName:t,html:r,assistantId:i,onClose:a,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,route:f,enableFullscreen:m=!1,onAction:h}){let g=(0,N.useRef)(null),[_,v]=(0,N.useState)(!1),y=(0,N.useCallback)(()=>v(e=>!e),[]);(0,N.useEffect)(()=>{v(!1)},[e]),(0,N.useEffect)(()=>{if(!_)return;let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),v(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_]);let b=(0,N.useMemo)(()=>O(r,e,{fetch:!0,route:f}),[r,e,f]),x=B(),S=(0,N.useMemo)(()=>{let t=0;for(let e=0;e<r.length;e++)t=(t<<5)-t+r.charCodeAt(e)|0;return`app-${e}-${t}${x?`-nosandbox`:``}`},[r,e,x]);return K(g,{frameId:e,assistantId:i,appId:e,onAction:h}),(0,M.jsxs)(`div`,{"data-testid":`app-viewer-root`,className:T(`flex flex-col overflow-hidden bg-[var(--surface-base)]`,_?`fixed inset-0 z-[60]`:`h-full rounded-xl`),children:[!_&&(0,M.jsx)(V,{appName:t,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,onToggleFullscreen:m?y:void 0,onClose:a}),(0,M.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[_&&(0,M.jsx)(`div`,{className:`absolute z-10`,style:{top:`max(0.75rem, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,right:`max(0.75rem, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:(0,M.jsx)(n,{variant:`primary`,iconOnly:(0,M.jsx)(p,{}),onClick:y,tooltip:`Exit fullscreen`})}),(0,M.jsx)(`iframe`,{ref:g,srcDoc:b,sandbox:x?void 0:q,referrerPolicy:`no-referrer`,title:t,className:`h-full w-full border-none`},S)]})]})}function Y(){let e=v.use.activeAssistantId(),t=w(),n=i(),{pathname:a}=r();return(0,N.useCallback)(r=>{if(!e)return;let i=D(e,r.appId)??crypto.randomUUID();E(e,r.appId,i);let o=C.getState();(o.activeAppId!==r.appId||!o.openedAppState)&&(o.openApp(r.appId),o.setLoadedApp(r)),S.getState().setEditingConversationId(i),t?o.minimizeApp():o.enterAppEditing();let s=x.conversation(i);a!==s&&n(s)},[e,t,n,a])}export{j as a,R as i,J as n,K as r,Y as t};
@@ -0,0 +1 @@
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n,x as r}from"./use-transcript-messages-DjwHicXg.js";var i=e(t(),1);function a(e){let t=n();return(0,i.useMemo)(()=>{if(e)return t.find(t=>r(t).includes(e))},[t,e])}export{a as t};
@@ -1,3 +1,3 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n}from"./local-settings-Bx7FsNo5.js";import{t as r}from"./react-BFJW0bSv.js";import{i}from"./use-attachment-preview-BoxwFwUx.js";import{n as a,t as o}from"./create-selectors-BfxF8Sx_.js";import{r as s}from"./typed-storage-OO7emDaU.js";import{a as c}from"./diagnostics-DykDXmF3.js";import{t as l}from"./conversation-store-CTMy9QPV.js";import{s as u,u as d}from"./messages-CW87Dtd_.js";import{C as ee,D as f,n as p,t as te,w as ne,x as re}from"./chat-Dy2BC2i1.js";var ie=e(r(),1),m=1e3,ae=15,oe=0,h=new Map,g=[];function se(e){let t=`sse-${++oe}`,n={id:t,abortSignal:e,initiatedAt:Date.now(),establishedAt:null,lastTrafficAt:null,lastDataAt:null,dataFrames:0,keepalives:0,endedAt:null,endReason:null};h.set(t,n),_e();let r=()=>{ge(t,`aborted`)};return e.aborted?r():e.addEventListener(`abort`,r,{once:!0}),t}function ce(e){let t=h.get(e);t&&t.establishedAt===null&&(t.establishedAt=Date.now())}function le(e,t){let n=h.get(e);if(!n)return;let r=Date.now();n.lastTrafficAt=r,t?(n.lastDataAt=r,n.dataFrames++):n.keepalives++}function ue(e,t){g.push({clientId:e,receivedAt:new Date().toISOString(),...t}),g.length>m&&g.shift()}var de=`events-tail`;function fe(e){if(e.length===0)return;let t=new Set;for(let e of g)typeof e.seq==`number`&&t.add(e.seq);for(let n of e)typeof n.seq==`number`&&t.has(n.seq)||g.push({clientId:de,receivedAt:new Date().toISOString(),...n});for(;g.length>m;)g.shift()}function pe(){return Array.from(h.values())}function me(e=m){let t=Math.max(0,g.length-e);return g.slice(t)}function he(e,t){if(t===null)return null;let n=1/0;for(let e of g)typeof e.seq==`number`&&(n=Math.min(n,e.seq));return n!==1/0&&n>t+1?null:g.filter(n=>n.conversationId===e&&typeof n.seq==`number`&&n.seq>t).sort((e,t)=>e.seq-t.seq)}function ge(e,t){let n=h.get(e);n&&(n.endedAt===null?(n.endedAt=Date.now(),n.endReason=t):n.endReason===`aborted`&&t!==`aborted`&&(n.endReason=t),_e())}function _e(){let e=0;for(let t of h.values())t.endedAt!==null&&e++;if(!(e<=ae))for(let[t,n]of h){if(e<=ae)break;n.endedAt!==null&&(h.delete(t),e--)}}var _={phase:`idle`,pendingQueuedCount:0,activeToolCallCount:0,activeTurnId:null,lastTerminalReason:null,statusText:null,liveWebActivity:{}};function v(e){return e===`queued`||e===`thinking`||e===`streaming`||e===`awaiting_user_input`}function ve(e){return e===`thinking`}function y(e){return(e.phase===`idle`||e.phase===`errored`)&&!e.activeTurnId}var ye=o(a()((e,t)=>({..._,requestSend:t=>e(e=>({phase:`thinking`,activeTurnId:t??e.activeTurnId,lastTerminalReason:null,activeToolCallCount:0,statusText:null})),acceptSend:t=>e(e=>({activeTurnId:t,...e.phase===`idle`||e.phase===`errored`?{phase:`thinking`,lastTerminalReason:null}:null})),onTextDelta:()=>{let n=t();if(n.phase===`idle`||n.phase===`errored`){if(!n.activeTurnId)return;e({phase:`streaming`});return}(n.phase===`thinking`||n.phase===`queued`)&&e({phase:`streaming`})},onToolUseStart:()=>{let n=t();y(n)||e({phase:n.phase===`idle`||n.phase===`errored`||n.phase===`queued`?`thinking`:n.phase,activeToolCallCount:n.activeToolCallCount+1})},onToolResult:()=>e(e=>({activeToolCallCount:Math.max(0,e.activeToolCallCount-1)})),onToolActivityMetadata:(n,r)=>{let i=t();y(i)||e({liveWebActivity:{...i.liveWebActivity,[n]:r}})},onActivityThinking:(n,r)=>{let i=t();if(y(i)){if(!r?.canStartFromIdle)return;e({phase:`thinking`,statusText:n??null,lastTerminalReason:null});return}i.phase!==`awaiting_user_input`&&e({phase:`thinking`,statusText:n??null})},recoverFromAwaitingUserInput:()=>{t().phase===`awaiting_user_input`&&e({phase:`thinking`})},showSurface:n=>{y(t())||n&&e({phase:`awaiting_user_input`})},updateSurface:()=>{},dismissSurface:()=>{let n=t();n.phase===`awaiting_user_input`&&n.activeToolCallCount===0&&e({phase:`thinking`})},completeSurface:()=>{let n=t();n.phase===`awaiting_user_input`&&n.activeToolCallCount===0&&e({phase:`thinking`})},onSecretRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onConfirmationRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onQuestionRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onContactRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},completeTurn:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},handoffGeneration:()=>{y(t())||e({phase:`thinking`,activeToolCallCount:0,statusText:null})},cancelGeneration:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`cancelled`,statusText:null,liveWebActivity:{}})},onStreamError:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`error`,statusText:null,liveWebActivity:{}}),onSessionError:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`session_error`,statusText:null,liveWebActivity:{}}),onTurnTimeout:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`timeout`,statusText:null,liveWebActivity:{}}),onPollReconciled:n=>{let r=t();n&&n!==r.activeTurnId||v(r.phase)&&e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},resetTurn:()=>e({..._}),clearStaleTurn:()=>{let n=t();n.activeTurnId&&v(n.phase)||e({..._})},enqueueMessage:()=>e(e=>({pendingQueuedCount:e.pendingQueuedCount+1})),dequeueMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(y(n)){e({pendingQueuedCount:r});return}e({phase:`thinking`,pendingQueuedCount:r})},deleteQueuedMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(r===0&&n.phase===`queued`){e({phase:`idle`,pendingQueuedCount:0,activeTurnId:null,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}});return}e({pendingQueuedCount:r})}}))),be=3670016,xe=[.85,.75,.65,.5],Se=2e7,Ce=new Set([`image/jpeg`,`image/jpg`,`image/png`,`image/webp`,`image/heic`,`image/heif`,`image/bmp`,`image/tiff`]),we=new Set([`jpg`,`jpeg`,`png`,`webp`,`heic`,`heif`,`bmp`,`tif`,`tiff`]);function b(e){let t=e.type.trim().toLowerCase();if(Ce.has(t))return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n?we.has(n):!1}function Te(e){return b(e)&&e.size>3670016}function Ee(e){let t=e.type.trim().toLowerCase();if(t===`image/heic`||t===`image/heif`)return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n===`heic`||n===`heif`}function De(e){return Te(e)||Ee(e)}function Oe(e){if(/^image\/jpe?g$/i.test(e))return`jpg`;let t=e.slice(6).toLowerCase();return/^[a-z0-9]+$/.test(t)?t:`jpg`}function ke(e,t=`image/jpeg`){let n=`attachment`,r=e.trim()||n,i=Oe(t),a=r.match(/\.([^./\\]+)$/)?.[1]?.toLowerCase();return a===i||i===`jpg`&&a===`jpeg`?r:`${r.replace(/\.[^./\\]+$/,``)||n}.${i}`}async function Ae(e){if(!De(e)||await Me(e))return{status:`unchanged`,file:e};if(e.size>104857600)return{status:`failed`,error:`This image is too large to process safely. Please choose a smaller image.`};let t;try{t=await je(e)}catch{return{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`}}try{let n;try{n=await Pe(t,e.size)}catch{n=null}if(!n||!Ee(e)&&n.size>=e.size)return{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`};let r=n.type.startsWith(`image/`)?n.type:`image/jpeg`;return{status:`resized`,file:new File([n],ke(e.name,r),{type:r,lastModified:e.lastModified})}}finally{t.close()}}async function je(e){if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e,{imageOrientation:`from-image`});return{source:t,width:t.width,height:t.height,close:()=>t.close()}}catch{}if(typeof Image>`u`)throw Error(`No browser image decoder is available.`);let t=URL.createObjectURL(e);return await new Promise((e,n)=>{let r=new Image;r.onload=()=>{e({source:r,width:r.naturalWidth||r.width,height:r.naturalHeight||r.height,close:()=>URL.revokeObjectURL(t)})},r.onerror=()=>{URL.revokeObjectURL(t),n(Error(`Image decode failed.`))},r.src=t})}async function Me(e){if(!Ne(e))return!1;let t;try{t=new Uint8Array(await e.slice(0,Math.min(e.size,1024*1024)).arrayBuffer())}catch{return!0}if(!S(t,0,`RIFF`)||!S(t,8,`WEBP`))return!1;let n=x(t,`VP8X`);return n>=0&&(t[n+8]??0)&2?!0:x(t,`ANIM`)>=0||x(t,`ANMF`)>=0}function Ne(e){return e.type.trim().toLowerCase()===`image/webp`||/\.webp$/i.test(e.name)}function x(e,t){for(let n=0;n<=e.length-t.length;n+=1)if(S(e,n,t))return n;return-1}function S(e,t,n){if(t+n.length>e.length)return!1;for(let r=0;r<n.length;r+=1)if(e[t+r]!==n.charCodeAt(r))return!1;return!0}async function Pe(e,t){let n=e.width*e.height,r=null;if(n<=Se)for(let t of xe){let n=await w(e.source,e.width,e.height,t);if(r=C(r,n),n&&n.size<=3670016)return n}let i=r?.size??t,a=Math.min(Math.sqrt(be/i*.9),.95);for(let t=0;t<4;t+=1){let t=Math.max(Math.floor(e.width*a),1),n=Math.max(Math.floor(e.height*a),1),o=null;for(let i of xe){let a=await w(e.source,t,n,i);if(r=C(r,a),o=C(o,a),a&&a.size<=3670016)return a}i=o?.size??i,a*=Math.min(Math.sqrt(be/i*.9),.9)}return null}function C(e,t){return t&&(!e||t.size<e.size)?t:e}async function w(e,t,n,r){if(typeof document>`u`)return null;let i=document.createElement(`canvas`);i.width=t,i.height=n;let a=i.getContext(`2d`);if(!a||typeof i.toBlob!=`function`)return null;a.fillStyle=`#fff`,a.fillRect(0,0,t,n),a.drawImage(e,0,0,t,n);try{return await new Promise(e=>{i.toBlob(t=>e(t),`image/jpeg`,r)})}finally{i.width=0,i.height=0}}var Fe=`vellum:chatDrafts:`;function Ie(e){return`${Fe}${e}`}function Le(e){let n=t(Ie(e),``);if(!n)return new Map;try{let e=JSON.parse(n);return typeof e!=`object`||!e||Array.isArray(e)?new Map:new Map(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return new Map}}function T(e,t){n(Ie(e),JSON.stringify(Object.fromEntries(t)))}function Re(){return`att-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function ze(e){return b(e)?`100 MB`:`50 MB`}function Be(e){return e.size<=52428800?!0:b(e)&&e.size<=104857600}function Ve(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var E=new Map,D=null,O=new Map,k=new Set,He=a()((e,t)=>({input:``,restoredDraftConversationId:null,attachments:[],attachmentLastError:null,setInput:t=>{e(e=>({input:typeof t==`function`?t(e.input):t}))},saveDraft:(e,t)=>{t.trim()?E.set(e,t):E.delete(e),D&&T(D,E)},clearDraft:e=>{E.delete(e),D&&T(D,E)},handleConversationSwitch:({previousKey:n,nextKey:r})=>{if(!(n!==null&&n!==r)||!n)return;let i=t().input;i.trim()?E.set(n,i):E.delete(n);let a=(r&&E.get(r))??``;e({input:a,restoredDraftConversationId:a.length>0&&r?r:null}),D&&T(D,E)},loadAssistantDrafts:(n,r)=>{if(D&&D!==n){let n=t().input;r&&(n.trim()?E.set(r,n):E.delete(r)),T(D,E),e({input:``,restoredDraftConversationId:null})}E=Le(n),D=n},clearRestoredDraftNotice:()=>{e({restoredDraftConversationId:null})},restoreDraftIfEmpty:n=>{let r=E.get(n);r&&r.trim()&&!t().input.trim()&&e({input:r,restoredDraftConversationId:n})},addFiles:(t,n)=>{let r=Array.from(t);if(r.length===0)return;if(!n){e({attachmentLastError:`No active assistant. Please try again.`});return}let a=[],o=[];for(let e of r)Be(e)?o.push(e):a.push(e);let s=a[0];if(e(s?{attachmentLastError:a.length===1?`${s.name} is larger than ${ze(s)} and can't be attached.`:`${a.length} files are too large and can't be attached.`}:{attachmentLastError:null}),o.length===0)return;let c=o.map(e=>({pending:{kind:`uploading`,localId:Re(),filename:e.name||`attachment`,mimeType:e.type||`application/octet-stream`,sizeBytes:e.size},file:e}));e(e=>({attachments:[...e.attachments,...c.map(e=>e.pending)]}));for(let{pending:t,file:r}of c)(async()=>{try{let a=await Ae(r);if(k.has(t.localId)){k.delete(t.localId);return}if(a.status===`failed`&&r.size>52428800){A(e,t.localId,a.error);return}let o=a.status===`failed`?r:a.file;if(o.size>52428800){A(e,t.localId,`This attachment is still larger than 50 MB after resizing. Try a smaller image.`);return}a.status===`resized`&&e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId&&e.kind===`uploading`?{...e,filename:o.name||`attachment`,mimeType:o.type||`application/octet-stream`,sizeBytes:o.size}:e)}));let s=await u(n,o);if(k.has(t.localId)){k.delete(t.localId);return}if(!s.ok){A(e,t.localId,s.error.detail??`Upload failed`);return}let c=o.type||`application/octet-stream`,l=s.filename??(o.name||`attachment`),d=s.mimeType??c,ee=s.sizeBytes??o.size,f=o;if(d.startsWith(`image/`)&&d!==c){let e=await i(n,s.id);if(k.has(t.localId)){k.delete(t.localId);return}e&&(f=e)}let p=null;try{p=URL.createObjectURL(f),O.set(t.localId,p)}catch{p=null}e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId?{kind:`uploaded`,localId:t.localId,id:s.id,filename:l,mimeType:d,sizeBytes:ee,previewUrl:p,thumbnailUrl:null}:e)}))}catch{if(k.has(t.localId)){k.delete(t.localId);return}A(e,t.localId,`Upload failed`)}})()},addPathReferences:t=>{let n=[];for(let e of t){let t=e.trim();t&&n.push({kind:`path-reference`,localId:Re(),path:t,filename:Ve(t)||t})}n.length!==0&&e(e=>({attachments:[...e.attachments,...n],attachmentLastError:null}))},removeAttachment:t=>{e(e=>{let n=e.attachments.find(e=>e.localId===t);return n&&n.kind===`uploading`&&k.add(t),{attachments:e.attachments.filter(e=>e.localId!==t)}}),Ue(t)},resetAttachments:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&k.add(t.localId);return{attachments:[],attachmentLastError:null}})},fullReset:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&k.add(t.localId);return{attachments:[],attachmentLastError:null}}),O.forEach(e=>URL.revokeObjectURL(e)),O.clear()},dismissAttachmentError:()=>{e({attachmentLastError:null})}}));function A(e,t,n){e(e=>({attachments:e.attachments.map(e=>e.localId!==t||e.kind!==`uploading`?e:{kind:`failed`,localId:t,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes,error:n})}))}function Ue(e){let t=O.get(e);t&&(URL.revokeObjectURL(t),O.delete(e))}function We(e){return e.reduce((e,t)=>t.kind===`uploading`?e+1:e,0)}function Ge(e){return e.filter(e=>e.kind===`uploaded`).map(e=>e.id)}function Ke(e){return e.filter(e=>e.kind===`path-reference`).map(e=>e.path)}var j=o(He);function qe(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Je(e){let t=JSON.parse(e);return qe(t)?t:null}function M(e,t){let n=[...e??[]],r=n.findIndex(e=>e.type===`surface`&&e.surface.surfaceId===t.surfaceId);return r===-1?n.push({type:`surface`,surface:t}):n[r]={type:`surface`,surface:t},n}function Ye(e,t){return e?.filter(e=>!(e.type===`surface`&&e.surface.surfaceId===t))}function Xe(e,t){if(!e.surfaces?.length)return e;let n=!1,r=e.contentBlocks,i=e.surfaces.map(e=>{let i=t(e);return i!==e&&(n=!0,r=M(r,i)),i});return n?{...e,surfaces:i,contentBlocks:r}:e}function Ze(e,t){if(!e.surfaces?.length)return e;let n=e.surfaces.filter(t);if(n.length===e.surfaces.length)return e;let r=new Set(e.surfaces.filter(e=>!t(e)).map(e=>e.surfaceId));return{...e,surfaces:n,contentOrder:e.contentOrder?.filter(e=>!(e.type===`surface`&&r.has(e.id))),contentBlocks:e.contentBlocks?.filter(e=>!(e.type===`surface`&&r.has(e.surface.surfaceId)))}}var Qe=500,$e=s({keyFn:e=>`vellum:dismissed-surfaces:${e}`,scope:`user`,parseValue:e=>qe(e)?e:null,fallback:{},maxEntries:200});function et(e,t){let n=$e.get(e,t);return n?new Set(n):new Set}function tt(e,t,n){let r=Array.from(n);r.length>Qe&&(r=r.slice(r.length-Qe)),$e.set(e,t,r)}var nt=[];function rt(e,t){if(!e)return nt;if(t.size===0)return e;let n=!1,r=e.map(e=>{let r=Ze(e,e=>!t.has(e.surfaceId));return r!==e&&(n=!0),r});return n?r:e}function it(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(typeof t.tokens!=`number`||!Number.isFinite(t.tokens)||t.maxTokens!==null&&(typeof t.maxTokens!=`number`||!Number.isFinite(t.maxTokens))||t.fillRatio!==null&&(typeof t.fillRatio!=`number`||!Number.isFinite(t.fillRatio)))}var at=s({keyFn:e=>`vellum:ctxwindow:${e}`,scope:`user`,parseValue:e=>it(e)?e:null,fallback:{},maxEntries:200});function ot(e){return new Map(Object.entries(at.load(e)))}function st(e,t,n){at.set(e,t,n)}var ct=`PROVIDER_BILLING`,lt=`PROVIDER_NOT_CONFIGURED`,ut=`MANAGED_KEY_INVALID`,dt=`credits_exhausted`,ft=`provider_billing`,pt=`daily_limit_reached`;function mt(e){return e?e.category?e.category.endsWith(dt):e.code===ct:!1}function ht(e){return e?mt({code:e.code,category:e.errorCategory}):!1}function gt(e){return e?.errorCategory?e.errorCategory.endsWith(ft):!1}function _t(e){return e?.errorCategory?e.errorCategory.endsWith(pt):!1}function vt(e){return _t(e)?`daily_limit`:ht(e)?`managed_credits`:gt(e)?`provider_billing`:null}function yt(e){return e.billingBannerDecision===`daily_limit`?`daily_limit`:e.billingBannerDecision===`provider_billing`?`provider_billing`:e.billingBannerDecision===`managed_credits`?null:e.isLowBalance&&!e.dismissed?`low_balance`:null}function N(e){return vt(e)!==null||e?.code===lt||e?.displayAs===`modal`}function bt(e){return!!e&&!N(e)}function xt(e){return e?.code===ut}var P={pendingSecret:null,isSubmittingSecret:!1,secretSaved:!1,pendingConfirmation:null,isSubmittingConfirmation:!1,pendingContactRequest:null,isSubmittingContactRequest:!1,contactRequestAccepted:!1,pendingQuestion:null,isSubmittingQuestion:!1,isQuestionCardDismissed:!1,inlineConfirmationToolCallId:null,pendingAcpConnect:null,dismissedAcpConnectToolUseIds:new Set,pendingAcpContinue:!1,unknownNudgeToolCallIds:new Set},F=o(a()((e,t)=>({...P,showSecret:n=>{let{pendingSecret:r}=t();if(r&&r.requestId===n.requestId){let t={};for(let e of Object.keys(n))n[e]!==void 0&&(t[e]=n[e]);e({pendingSecret:{...r,...t}});return}e({pendingSecret:n,isSubmittingSecret:!1,secretSaved:!1})},submitSecretStart:()=>e({isSubmittingSecret:!0}),submitSecretEnd:t=>e({isSubmittingSecret:!1,secretSaved:t??!1}),dismissSecret:()=>e({pendingSecret:null,isSubmittingSecret:!1}),updateSecret:(n,r)=>{let{pendingSecret:i}=t();!i||i.requestId!==n||e({pendingSecret:{...i,...r}})},showConfirmation:t=>e({pendingConfirmation:t,isSubmittingConfirmation:!1}),submitConfirmationStart:()=>e({isSubmittingConfirmation:!0}),submitConfirmationEnd:()=>e({isSubmittingConfirmation:!1}),dismissConfirmation:()=>e({pendingConfirmation:null,isSubmittingConfirmation:!1}),dismissConfirmationIfMatches:n=>{let{pendingConfirmation:r}=t();!r||r.requestId!==n||e({pendingConfirmation:null,isSubmittingConfirmation:!1})},updateConfirmation:(n,r)=>{let{pendingConfirmation:i}=t();!i||i.requestId!==n||e({pendingConfirmation:{...i,...r}})},setInlineConfirmationToolCallId:t=>e({inlineConfirmationToolCallId:t}),showContactRequest:t=>e({pendingContactRequest:t,isSubmittingContactRequest:!1,contactRequestAccepted:!1}),submitContactRequestStart:()=>e({isSubmittingContactRequest:!0}),submitContactRequestEnd:()=>e({isSubmittingContactRequest:!1}),dismissContactRequest:()=>e({pendingContactRequest:null,isSubmittingContactRequest:!1}),acceptContactRequest:()=>e({contactRequestAccepted:!0}),showQuestion:t=>e({pendingQuestion:t,isSubmittingQuestion:!1,isQuestionCardDismissed:!1}),submitQuestionStart:()=>e({isSubmittingQuestion:!0}),submitQuestionEnd:()=>e({isSubmittingQuestion:!1}),dismissQuestion:()=>e({pendingQuestion:null,isSubmittingQuestion:!1,isQuestionCardDismissed:!1}),dismissQuestionCard:()=>e({isQuestionCardDismissed:!0}),resetSecretAndConfirmation:()=>e({pendingSecret:null,isSubmittingSecret:!1,secretSaved:!1,pendingConfirmation:null,isSubmittingConfirmation:!1,inlineConfirmationToolCallId:null}),showAcpConnect:t=>e(e=>e.dismissedAcpConnectToolUseIds.has(t.toolUseId)?{}:{pendingAcpConnect:t}),dismissAcpConnect:()=>e(e=>({pendingAcpConnect:null,dismissedAcpConnectToolUseIds:e.pendingAcpConnect?new Set(e.dismissedAcpConnectToolUseIds).add(e.pendingAcpConnect.toolUseId):e.dismissedAcpConnectToolUseIds})),requestAcpContinue:()=>e({pendingAcpContinue:!0}),clearAcpContinue:()=>e({pendingAcpContinue:!1}),addUnknownNudgeToolCallId:n=>{let r=t().unknownNudgeToolCallIds;r.has(n)||e({unknownNudgeToolCallIds:new Set([...r,n])})},removeUnknownNudgeToolCallId:n=>{let r=t().unknownNudgeToolCallIds;if(!r.has(n))return;let i=new Set(r);i.delete(n),e({unknownNudgeToolCallIds:i})},resetAll:()=>e(P)})));function St(e){if(e.length===0)return``;let t=e[0]??``;for(let n=1;n<e.length;n++){let r=t[t.length-1],i=e[n][0];r&&i&&r!==` `&&r!==`
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n}from"./local-settings-Bx7FsNo5.js";import{t as r}from"./react-BFJW0bSv.js";import{i}from"./use-attachment-preview-BoxwFwUx.js";import{n as a,t as o}from"./create-selectors-BfxF8Sx_.js";import{r as s}from"./typed-storage-OO7emDaU.js";import{a as c}from"./diagnostics-DykDXmF3.js";import{t as l}from"./conversation-store-CTMy9QPV.js";import{s as u,u as d}from"./messages-S9VSjR8B.js";import{C as ee,D as f,n as p,t as te,w as ne,x as re}from"./chat-Dy2BC2i1.js";var ie=e(r(),1),m=1e3,ae=15,oe=0,h=new Map,g=[];function se(e){let t=`sse-${++oe}`,n={id:t,abortSignal:e,initiatedAt:Date.now(),establishedAt:null,lastTrafficAt:null,lastDataAt:null,dataFrames:0,keepalives:0,endedAt:null,endReason:null};h.set(t,n),_e();let r=()=>{ge(t,`aborted`)};return e.aborted?r():e.addEventListener(`abort`,r,{once:!0}),t}function ce(e){let t=h.get(e);t&&t.establishedAt===null&&(t.establishedAt=Date.now())}function le(e,t){let n=h.get(e);if(!n)return;let r=Date.now();n.lastTrafficAt=r,t?(n.lastDataAt=r,n.dataFrames++):n.keepalives++}function ue(e,t){g.push({clientId:e,receivedAt:new Date().toISOString(),...t}),g.length>m&&g.shift()}var de=`events-tail`;function fe(e){if(e.length===0)return;let t=new Set;for(let e of g)typeof e.seq==`number`&&t.add(e.seq);for(let n of e)typeof n.seq==`number`&&t.has(n.seq)||g.push({clientId:de,receivedAt:new Date().toISOString(),...n});for(;g.length>m;)g.shift()}function pe(){return Array.from(h.values())}function me(e=m){let t=Math.max(0,g.length-e);return g.slice(t)}function he(e,t){if(t===null)return null;let n=1/0;for(let e of g)typeof e.seq==`number`&&(n=Math.min(n,e.seq));return n!==1/0&&n>t+1?null:g.filter(n=>n.conversationId===e&&typeof n.seq==`number`&&n.seq>t).sort((e,t)=>e.seq-t.seq)}function ge(e,t){let n=h.get(e);n&&(n.endedAt===null?(n.endedAt=Date.now(),n.endReason=t):n.endReason===`aborted`&&t!==`aborted`&&(n.endReason=t),_e())}function _e(){let e=0;for(let t of h.values())t.endedAt!==null&&e++;if(!(e<=ae))for(let[t,n]of h){if(e<=ae)break;n.endedAt!==null&&(h.delete(t),e--)}}var _={phase:`idle`,pendingQueuedCount:0,activeToolCallCount:0,activeTurnId:null,lastTerminalReason:null,statusText:null,liveWebActivity:{}};function v(e){return e===`queued`||e===`thinking`||e===`streaming`||e===`awaiting_user_input`}function ve(e){return e===`thinking`}function y(e){return(e.phase===`idle`||e.phase===`errored`)&&!e.activeTurnId}var ye=o(a()((e,t)=>({..._,requestSend:t=>e(e=>({phase:`thinking`,activeTurnId:t??e.activeTurnId,lastTerminalReason:null,activeToolCallCount:0,statusText:null})),acceptSend:t=>e(e=>({activeTurnId:t,...e.phase===`idle`||e.phase===`errored`?{phase:`thinking`,lastTerminalReason:null}:null})),onTextDelta:()=>{let n=t();if(n.phase===`idle`||n.phase===`errored`){if(!n.activeTurnId)return;e({phase:`streaming`});return}(n.phase===`thinking`||n.phase===`queued`)&&e({phase:`streaming`})},onToolUseStart:()=>{let n=t();y(n)||e({phase:n.phase===`idle`||n.phase===`errored`||n.phase===`queued`?`thinking`:n.phase,activeToolCallCount:n.activeToolCallCount+1})},onToolResult:()=>e(e=>({activeToolCallCount:Math.max(0,e.activeToolCallCount-1)})),onToolActivityMetadata:(n,r)=>{let i=t();y(i)||e({liveWebActivity:{...i.liveWebActivity,[n]:r}})},onActivityThinking:(n,r)=>{let i=t();if(y(i)){if(!r?.canStartFromIdle)return;e({phase:`thinking`,statusText:n??null,lastTerminalReason:null});return}i.phase!==`awaiting_user_input`&&e({phase:`thinking`,statusText:n??null})},recoverFromAwaitingUserInput:()=>{t().phase===`awaiting_user_input`&&e({phase:`thinking`})},showSurface:n=>{y(t())||n&&e({phase:`awaiting_user_input`})},updateSurface:()=>{},dismissSurface:()=>{let n=t();n.phase===`awaiting_user_input`&&n.activeToolCallCount===0&&e({phase:`thinking`})},completeSurface:()=>{let n=t();n.phase===`awaiting_user_input`&&n.activeToolCallCount===0&&e({phase:`thinking`})},onSecretRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onConfirmationRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onQuestionRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onContactRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},completeTurn:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},handoffGeneration:()=>{y(t())||e({phase:`thinking`,activeToolCallCount:0,statusText:null})},cancelGeneration:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`cancelled`,statusText:null,liveWebActivity:{}})},onStreamError:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`error`,statusText:null,liveWebActivity:{}}),onSessionError:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`session_error`,statusText:null,liveWebActivity:{}}),onTurnTimeout:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`timeout`,statusText:null,liveWebActivity:{}}),onPollReconciled:n=>{let r=t();n&&n!==r.activeTurnId||v(r.phase)&&e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},resetTurn:()=>e({..._}),clearStaleTurn:()=>{let n=t();n.activeTurnId&&v(n.phase)||e({..._})},enqueueMessage:()=>e(e=>({pendingQueuedCount:e.pendingQueuedCount+1})),dequeueMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(y(n)){e({pendingQueuedCount:r});return}e({phase:`thinking`,pendingQueuedCount:r})},deleteQueuedMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(r===0&&n.phase===`queued`){e({phase:`idle`,pendingQueuedCount:0,activeTurnId:null,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}});return}e({pendingQueuedCount:r})}}))),be=3670016,xe=[.85,.75,.65,.5],Se=2e7,Ce=new Set([`image/jpeg`,`image/jpg`,`image/png`,`image/webp`,`image/heic`,`image/heif`,`image/bmp`,`image/tiff`]),we=new Set([`jpg`,`jpeg`,`png`,`webp`,`heic`,`heif`,`bmp`,`tif`,`tiff`]);function b(e){let t=e.type.trim().toLowerCase();if(Ce.has(t))return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n?we.has(n):!1}function Te(e){return b(e)&&e.size>3670016}function Ee(e){let t=e.type.trim().toLowerCase();if(t===`image/heic`||t===`image/heif`)return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n===`heic`||n===`heif`}function De(e){return Te(e)||Ee(e)}function Oe(e){if(/^image\/jpe?g$/i.test(e))return`jpg`;let t=e.slice(6).toLowerCase();return/^[a-z0-9]+$/.test(t)?t:`jpg`}function ke(e,t=`image/jpeg`){let n=`attachment`,r=e.trim()||n,i=Oe(t),a=r.match(/\.([^./\\]+)$/)?.[1]?.toLowerCase();return a===i||i===`jpg`&&a===`jpeg`?r:`${r.replace(/\.[^./\\]+$/,``)||n}.${i}`}async function Ae(e){if(!De(e)||await Me(e))return{status:`unchanged`,file:e};if(e.size>104857600)return{status:`failed`,error:`This image is too large to process safely. Please choose a smaller image.`};let t;try{t=await je(e)}catch{return{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`}}try{let n;try{n=await Pe(t,e.size)}catch{n=null}if(!n||!Ee(e)&&n.size>=e.size)return{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`};let r=n.type.startsWith(`image/`)?n.type:`image/jpeg`;return{status:`resized`,file:new File([n],ke(e.name,r),{type:r,lastModified:e.lastModified})}}finally{t.close()}}async function je(e){if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e,{imageOrientation:`from-image`});return{source:t,width:t.width,height:t.height,close:()=>t.close()}}catch{}if(typeof Image>`u`)throw Error(`No browser image decoder is available.`);let t=URL.createObjectURL(e);return await new Promise((e,n)=>{let r=new Image;r.onload=()=>{e({source:r,width:r.naturalWidth||r.width,height:r.naturalHeight||r.height,close:()=>URL.revokeObjectURL(t)})},r.onerror=()=>{URL.revokeObjectURL(t),n(Error(`Image decode failed.`))},r.src=t})}async function Me(e){if(!Ne(e))return!1;let t;try{t=new Uint8Array(await e.slice(0,Math.min(e.size,1024*1024)).arrayBuffer())}catch{return!0}if(!S(t,0,`RIFF`)||!S(t,8,`WEBP`))return!1;let n=x(t,`VP8X`);return n>=0&&(t[n+8]??0)&2?!0:x(t,`ANIM`)>=0||x(t,`ANMF`)>=0}function Ne(e){return e.type.trim().toLowerCase()===`image/webp`||/\.webp$/i.test(e.name)}function x(e,t){for(let n=0;n<=e.length-t.length;n+=1)if(S(e,n,t))return n;return-1}function S(e,t,n){if(t+n.length>e.length)return!1;for(let r=0;r<n.length;r+=1)if(e[t+r]!==n.charCodeAt(r))return!1;return!0}async function Pe(e,t){let n=e.width*e.height,r=null;if(n<=Se)for(let t of xe){let n=await w(e.source,e.width,e.height,t);if(r=C(r,n),n&&n.size<=3670016)return n}let i=r?.size??t,a=Math.min(Math.sqrt(be/i*.9),.95);for(let t=0;t<4;t+=1){let t=Math.max(Math.floor(e.width*a),1),n=Math.max(Math.floor(e.height*a),1),o=null;for(let i of xe){let a=await w(e.source,t,n,i);if(r=C(r,a),o=C(o,a),a&&a.size<=3670016)return a}i=o?.size??i,a*=Math.min(Math.sqrt(be/i*.9),.9)}return null}function C(e,t){return t&&(!e||t.size<e.size)?t:e}async function w(e,t,n,r){if(typeof document>`u`)return null;let i=document.createElement(`canvas`);i.width=t,i.height=n;let a=i.getContext(`2d`);if(!a||typeof i.toBlob!=`function`)return null;a.fillStyle=`#fff`,a.fillRect(0,0,t,n),a.drawImage(e,0,0,t,n);try{return await new Promise(e=>{i.toBlob(t=>e(t),`image/jpeg`,r)})}finally{i.width=0,i.height=0}}var Fe=`vellum:chatDrafts:`;function Ie(e){return`${Fe}${e}`}function Le(e){let n=t(Ie(e),``);if(!n)return new Map;try{let e=JSON.parse(n);return typeof e!=`object`||!e||Array.isArray(e)?new Map:new Map(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return new Map}}function T(e,t){n(Ie(e),JSON.stringify(Object.fromEntries(t)))}function Re(){return`att-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function ze(e){return b(e)?`100 MB`:`50 MB`}function Be(e){return e.size<=52428800?!0:b(e)&&e.size<=104857600}function Ve(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var E=new Map,D=null,O=new Map,k=new Set,He=a()((e,t)=>({input:``,restoredDraftConversationId:null,attachments:[],attachmentLastError:null,setInput:t=>{e(e=>({input:typeof t==`function`?t(e.input):t}))},saveDraft:(e,t)=>{t.trim()?E.set(e,t):E.delete(e),D&&T(D,E)},clearDraft:e=>{E.delete(e),D&&T(D,E)},handleConversationSwitch:({previousKey:n,nextKey:r})=>{if(!(n!==null&&n!==r)||!n)return;let i=t().input;i.trim()?E.set(n,i):E.delete(n);let a=(r&&E.get(r))??``;e({input:a,restoredDraftConversationId:a.length>0&&r?r:null}),D&&T(D,E)},loadAssistantDrafts:(n,r)=>{if(D&&D!==n){let n=t().input;r&&(n.trim()?E.set(r,n):E.delete(r)),T(D,E),e({input:``,restoredDraftConversationId:null})}E=Le(n),D=n},clearRestoredDraftNotice:()=>{e({restoredDraftConversationId:null})},restoreDraftIfEmpty:n=>{let r=E.get(n);r&&r.trim()&&!t().input.trim()&&e({input:r,restoredDraftConversationId:n})},addFiles:(t,n)=>{let r=Array.from(t);if(r.length===0)return;if(!n){e({attachmentLastError:`No active assistant. Please try again.`});return}let a=[],o=[];for(let e of r)Be(e)?o.push(e):a.push(e);let s=a[0];if(e(s?{attachmentLastError:a.length===1?`${s.name} is larger than ${ze(s)} and can't be attached.`:`${a.length} files are too large and can't be attached.`}:{attachmentLastError:null}),o.length===0)return;let c=o.map(e=>({pending:{kind:`uploading`,localId:Re(),filename:e.name||`attachment`,mimeType:e.type||`application/octet-stream`,sizeBytes:e.size},file:e}));e(e=>({attachments:[...e.attachments,...c.map(e=>e.pending)]}));for(let{pending:t,file:r}of c)(async()=>{try{let a=await Ae(r);if(k.has(t.localId)){k.delete(t.localId);return}if(a.status===`failed`&&r.size>52428800){A(e,t.localId,a.error);return}let o=a.status===`failed`?r:a.file;if(o.size>52428800){A(e,t.localId,`This attachment is still larger than 50 MB after resizing. Try a smaller image.`);return}a.status===`resized`&&e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId&&e.kind===`uploading`?{...e,filename:o.name||`attachment`,mimeType:o.type||`application/octet-stream`,sizeBytes:o.size}:e)}));let s=await u(n,o);if(k.has(t.localId)){k.delete(t.localId);return}if(!s.ok){A(e,t.localId,s.error.detail??`Upload failed`);return}let c=o.type||`application/octet-stream`,l=s.filename??(o.name||`attachment`),d=s.mimeType??c,ee=s.sizeBytes??o.size,f=o;if(d.startsWith(`image/`)&&d!==c){let e=await i(n,s.id);if(k.has(t.localId)){k.delete(t.localId);return}e&&(f=e)}let p=null;try{p=URL.createObjectURL(f),O.set(t.localId,p)}catch{p=null}e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId?{kind:`uploaded`,localId:t.localId,id:s.id,filename:l,mimeType:d,sizeBytes:ee,previewUrl:p,thumbnailUrl:null}:e)}))}catch{if(k.has(t.localId)){k.delete(t.localId);return}A(e,t.localId,`Upload failed`)}})()},addPathReferences:t=>{let n=[];for(let e of t){let t=e.trim();t&&n.push({kind:`path-reference`,localId:Re(),path:t,filename:Ve(t)||t})}n.length!==0&&e(e=>({attachments:[...e.attachments,...n],attachmentLastError:null}))},removeAttachment:t=>{e(e=>{let n=e.attachments.find(e=>e.localId===t);return n&&n.kind===`uploading`&&k.add(t),{attachments:e.attachments.filter(e=>e.localId!==t)}}),Ue(t)},resetAttachments:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&k.add(t.localId);return{attachments:[],attachmentLastError:null}})},fullReset:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&k.add(t.localId);return{attachments:[],attachmentLastError:null}}),O.forEach(e=>URL.revokeObjectURL(e)),O.clear()},dismissAttachmentError:()=>{e({attachmentLastError:null})}}));function A(e,t,n){e(e=>({attachments:e.attachments.map(e=>e.localId!==t||e.kind!==`uploading`?e:{kind:`failed`,localId:t,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes,error:n})}))}function Ue(e){let t=O.get(e);t&&(URL.revokeObjectURL(t),O.delete(e))}function We(e){return e.reduce((e,t)=>t.kind===`uploading`?e+1:e,0)}function Ge(e){return e.filter(e=>e.kind===`uploaded`).map(e=>e.id)}function Ke(e){return e.filter(e=>e.kind===`path-reference`).map(e=>e.path)}var j=o(He);function qe(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Je(e){let t=JSON.parse(e);return qe(t)?t:null}function M(e,t){let n=[...e??[]],r=n.findIndex(e=>e.type===`surface`&&e.surface.surfaceId===t.surfaceId);return r===-1?n.push({type:`surface`,surface:t}):n[r]={type:`surface`,surface:t},n}function Ye(e,t){return e?.filter(e=>!(e.type===`surface`&&e.surface.surfaceId===t))}function Xe(e,t){if(!e.surfaces?.length)return e;let n=!1,r=e.contentBlocks,i=e.surfaces.map(e=>{let i=t(e);return i!==e&&(n=!0,r=M(r,i)),i});return n?{...e,surfaces:i,contentBlocks:r}:e}function Ze(e,t){if(!e.surfaces?.length)return e;let n=e.surfaces.filter(t);if(n.length===e.surfaces.length)return e;let r=new Set(e.surfaces.filter(e=>!t(e)).map(e=>e.surfaceId));return{...e,surfaces:n,contentOrder:e.contentOrder?.filter(e=>!(e.type===`surface`&&r.has(e.id))),contentBlocks:e.contentBlocks?.filter(e=>!(e.type===`surface`&&r.has(e.surface.surfaceId)))}}var Qe=500,$e=s({keyFn:e=>`vellum:dismissed-surfaces:${e}`,scope:`user`,parseValue:e=>qe(e)?e:null,fallback:{},maxEntries:200});function et(e,t){let n=$e.get(e,t);return n?new Set(n):new Set}function tt(e,t,n){let r=Array.from(n);r.length>Qe&&(r=r.slice(r.length-Qe)),$e.set(e,t,r)}var nt=[];function rt(e,t){if(!e)return nt;if(t.size===0)return e;let n=!1,r=e.map(e=>{let r=Ze(e,e=>!t.has(e.surfaceId));return r!==e&&(n=!0),r});return n?r:e}function it(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(typeof t.tokens!=`number`||!Number.isFinite(t.tokens)||t.maxTokens!==null&&(typeof t.maxTokens!=`number`||!Number.isFinite(t.maxTokens))||t.fillRatio!==null&&(typeof t.fillRatio!=`number`||!Number.isFinite(t.fillRatio)))}var at=s({keyFn:e=>`vellum:ctxwindow:${e}`,scope:`user`,parseValue:e=>it(e)?e:null,fallback:{},maxEntries:200});function ot(e){return new Map(Object.entries(at.load(e)))}function st(e,t,n){at.set(e,t,n)}var ct=`PROVIDER_BILLING`,lt=`PROVIDER_NOT_CONFIGURED`,ut=`MANAGED_KEY_INVALID`,dt=`credits_exhausted`,ft=`provider_billing`,pt=`daily_limit_reached`;function mt(e){return e?e.category?e.category.endsWith(dt):e.code===ct:!1}function ht(e){return e?mt({code:e.code,category:e.errorCategory}):!1}function gt(e){return e?.errorCategory?e.errorCategory.endsWith(ft):!1}function _t(e){return e?.errorCategory?e.errorCategory.endsWith(pt):!1}function vt(e){return _t(e)?`daily_limit`:ht(e)?`managed_credits`:gt(e)?`provider_billing`:null}function yt(e){return e.billingBannerDecision===`daily_limit`?`daily_limit`:e.billingBannerDecision===`provider_billing`?`provider_billing`:e.billingBannerDecision===`managed_credits`?null:e.isLowBalance&&!e.dismissed?`low_balance`:null}function N(e){return vt(e)!==null||e?.code===lt||e?.displayAs===`modal`}function bt(e){return!!e&&!N(e)}function xt(e){return e?.code===ut}var P={pendingSecret:null,isSubmittingSecret:!1,secretSaved:!1,pendingConfirmation:null,isSubmittingConfirmation:!1,pendingContactRequest:null,isSubmittingContactRequest:!1,contactRequestAccepted:!1,pendingQuestion:null,isSubmittingQuestion:!1,isQuestionCardDismissed:!1,inlineConfirmationToolCallId:null,pendingAcpConnect:null,dismissedAcpConnectToolUseIds:new Set,pendingAcpContinue:!1,unknownNudgeToolCallIds:new Set},F=o(a()((e,t)=>({...P,showSecret:n=>{let{pendingSecret:r}=t();if(r&&r.requestId===n.requestId){let t={};for(let e of Object.keys(n))n[e]!==void 0&&(t[e]=n[e]);e({pendingSecret:{...r,...t}});return}e({pendingSecret:n,isSubmittingSecret:!1,secretSaved:!1})},submitSecretStart:()=>e({isSubmittingSecret:!0}),submitSecretEnd:t=>e({isSubmittingSecret:!1,secretSaved:t??!1}),dismissSecret:()=>e({pendingSecret:null,isSubmittingSecret:!1}),updateSecret:(n,r)=>{let{pendingSecret:i}=t();!i||i.requestId!==n||e({pendingSecret:{...i,...r}})},showConfirmation:t=>e({pendingConfirmation:t,isSubmittingConfirmation:!1}),submitConfirmationStart:()=>e({isSubmittingConfirmation:!0}),submitConfirmationEnd:()=>e({isSubmittingConfirmation:!1}),dismissConfirmation:()=>e({pendingConfirmation:null,isSubmittingConfirmation:!1}),dismissConfirmationIfMatches:n=>{let{pendingConfirmation:r}=t();!r||r.requestId!==n||e({pendingConfirmation:null,isSubmittingConfirmation:!1})},updateConfirmation:(n,r)=>{let{pendingConfirmation:i}=t();!i||i.requestId!==n||e({pendingConfirmation:{...i,...r}})},setInlineConfirmationToolCallId:t=>e({inlineConfirmationToolCallId:t}),showContactRequest:t=>e({pendingContactRequest:t,isSubmittingContactRequest:!1,contactRequestAccepted:!1}),submitContactRequestStart:()=>e({isSubmittingContactRequest:!0}),submitContactRequestEnd:()=>e({isSubmittingContactRequest:!1}),dismissContactRequest:()=>e({pendingContactRequest:null,isSubmittingContactRequest:!1}),acceptContactRequest:()=>e({contactRequestAccepted:!0}),showQuestion:t=>e({pendingQuestion:t,isSubmittingQuestion:!1,isQuestionCardDismissed:!1}),submitQuestionStart:()=>e({isSubmittingQuestion:!0}),submitQuestionEnd:()=>e({isSubmittingQuestion:!1}),dismissQuestion:()=>e({pendingQuestion:null,isSubmittingQuestion:!1,isQuestionCardDismissed:!1}),dismissQuestionCard:()=>e({isQuestionCardDismissed:!0}),resetSecretAndConfirmation:()=>e({pendingSecret:null,isSubmittingSecret:!1,secretSaved:!1,pendingConfirmation:null,isSubmittingConfirmation:!1,inlineConfirmationToolCallId:null}),showAcpConnect:t=>e(e=>e.dismissedAcpConnectToolUseIds.has(t.toolUseId)?{}:{pendingAcpConnect:t}),dismissAcpConnect:()=>e(e=>({pendingAcpConnect:null,dismissedAcpConnectToolUseIds:e.pendingAcpConnect?new Set(e.dismissedAcpConnectToolUseIds).add(e.pendingAcpConnect.toolUseId):e.dismissedAcpConnectToolUseIds})),requestAcpContinue:()=>e({pendingAcpContinue:!0}),clearAcpContinue:()=>e({pendingAcpContinue:!1}),addUnknownNudgeToolCallId:n=>{let r=t().unknownNudgeToolCallIds;r.has(n)||e({unknownNudgeToolCallIds:new Set([...r,n])})},removeUnknownNudgeToolCallId:n=>{let r=t().unknownNudgeToolCallIds;if(!r.has(n))return;let i=new Set(r);i.delete(n),e({unknownNudgeToolCallIds:i})},resetAll:()=>e(P)})));function St(e){if(e.length===0)return``;let t=e[0]??``;for(let n=1;n<e.length;n++){let r=t[t.length-1],i=e[n][0];r&&i&&r!==` `&&r!==`
2
2
  `&&r!==` `&&i!==` `&&i!==`
3
3
  `&&i!==` `&&(t+=` `),t+=e[n]}return t}function I(e){let t=[];for(let n of e?.contentBlocks??[])n.type===`text`&&t.push(n.text);return St(t)}function Ct(e){if(!(!e||e.length===0))return e.map(e=>{let{previewUrl:t,thumbnailUrl:n}=d(e.mimeType,e.data,e.thumbnailData,e.id!=null);return{id:e.id??e.filename,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes??(e.data?Math.floor(e.data.length*3/4):0),previewUrl:t,thumbnailUrl:n}})}function wt(e){return[...new Set([e.id,...e.mergedMessageIds??[]].filter(e=>typeof e==`string`&&e.length>0))]}function L(e){let t=wt(e);return e.clientMessageId&&!t.includes(e.clientMessageId)?[...t,e.clientMessageId]:t}function R(e,t){return e.id===t||e.clientMessageId===t||(e.mergedMessageIds?.includes(t)??!1)}function z(e){let t=e[e.length-1];return!!t&&t.role===`assistant`}function Tt(e,t){if(!t)return null;let n=e.length-1;for(;n>=0&&e[n].role===`user`&&e[n].queueStatus===`queued`;)n--;let r=e[n];return!r||r.role!==`assistant`?null:r.id}function B(e,t){return e.findIndex(e=>e.role===`assistant`&&(e.id===t||!!e.mergedMessageIds?.includes(t)))}function V(e,t){if(t){let n=B(e,t);if(n!==-1)return n}let n=e.findLastIndex(e=>e.role===`user`&&e.queueStatus!==`queued`)+1;for(let t=e.length-1;t>=n;t--)if(e[t]?.role===`assistant`)return t;return-1}function H(e,t){if(!t||e.id===t)return e;let n=e.mergedMessageIds??[];return n.includes(t)?e:{...e,mergedMessageIds:[...n,t]}}function U(e,t=Date.now()){if(!e.toolCalls?.some(e=>f(e)))return null;let n=t;return{toolCalls:e.toolCalls.map(e=>f(e)?{...e,completedAt:n}:e),contentBlocks:e.contentBlocks?.map(e=>e.type===`tool_use`&&f(e.toolCall)?{type:`tool_use`,toolCall:{...e.toolCall,completedAt:n}}:e)}}function Et(e,t,n){return e.map(e=>e.id===t?{...e,queuePosition:n}:e)}function Dt(e,t){return e.map(e=>R(e,t)?{...e,queueStatus:void 0,queuePosition:void 0}:e)}function Ot(e,t){return e.map(e=>R(e,t)?{...e,...e.clientMessageId?{}:{isOptimistic:!0},queueStatus:void 0,queuePosition:void 0}:e)}function kt(e,t,n){return e.map(e=>R(e,t)?{...e,queueStatus:`queued`,queuePosition:n}:e)}function At(e,t){return e.filter(e=>!R(e,t))}function jt(e,t,n,r=Date.now()){return[...e,{id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,textSegments:[t],contentOrder:[{type:`text`,id:`0`}],contentBlocks:[{type:`text`,text:t}],timestamp:r}]}function Mt(e,t,n){n&&e[e.length-1]?.type===t.type?e[e.length-1]=t:e.push(t)}function W(e,t,n,r){let i=H(e[t],r),a=[...i.textSegments??[]],o=[...i.contentOrder??[]],s=[...i.contentBlocks??[]],c=o[o.length-1]?.type===`text`&&a.length>0;c?a[a.length-1]=a[a.length-1]+n:(o.push({type:`text`,id:String(a.length)}),a.push(n)),Mt(s,{type:`text`,text:a[a.length-1]},c);let l=[...e];return l[t]={...i,textSegments:a,contentOrder:o,contentBlocks:s},l}function G(e,t,n,r){let i=H(e[t],r),a=[...i.thinkingSegments??[]],o=[...i.contentOrder??[]],s=[...i.contentBlocks??[]],c=o[o.length-1]?.type===`thinking`&&a.length>0;c?a[a.length-1]=a[a.length-1]+n:(o.push({type:`thinking`,id:String(a.length)}),a.push(n)),Mt(s,{type:`thinking`,thinking:a[a.length-1]},c);let l=[...e];return l[t]={...i,thinkingSegments:a,contentOrder:o,contentBlocks:s},l}function Nt(e,t,n,r,i=Date.now()){if(n){let a=B(e,n);if(a>=0)return W(e,a,t,n);if(z(e))return W(e,e.length-1,t,n);let o=r?.();return o?W([...e,o],e.length,t,n):jt(e,t,n,i)}return z(e)?W(e,e.length-1,t,void 0):jt(e,t,n,i)}function Pt(e,t,n,r=Date.now()){return[...e,{id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,thinkingSegments:[t],contentOrder:[{type:`thinking`,id:`0`}],contentBlocks:[{type:`thinking`,thinking:t}],timestamp:r}]}function Ft(e,t,n,r,i=Date.now()){if(n){let a=B(e,n);if(a>=0)return G(e,a,t,n);if(z(e))return G(e,e.length-1,t,n);let o=r?.();return o?G([...e,o],e.length,t,n):Pt(e,t,n,i)}return z(e)?G(e,e.length-1,t,void 0):Pt(e,t,n,i)}function It(e,t=Date.now()){let n=!1,r=e.map(e=>{if(e.role!==`assistant`)return e;let r=U(e,t);return r?(n=!0,{...e,...r}):e});return n?r:e}function Lt(e,t,n=Date.now()){let r=e[e.length-1],i=Ct(t.attachments);if(r?.role!==`assistant`)return i?[...e,{id:t.messageId??crypto.randomUUID(),...t.messageId?{}:{isOptimistic:!0},role:`assistant`,timestamp:n,attachments:i}]:e;let a=U(r,n),o=r.isOptimistic===!0&&!!t.messageId;return[...e.slice(0,-1),{...r,...o?{id:t.messageId,isOptimistic:!1}:{},...i?{attachments:i}:{},...a??{}}]}function Rt(e,t){if(t!==void 0)return e.findIndex(e=>e.role===`user`&&e.clientMessageId===t);let n=-1;for(let t=e.length-1;t>=0;t--){let r=e[t];if(r&&r.role===`user`&&r.isOptimistic===!0){if(!r.clientMessageId)return t;n===-1&&(n=t)}}return n}function zt(e,t,n=Date.now()){let r=t.messageId;if(r!==void 0&&e.some(e=>e.role===`user`&&(e.id===r||e.mergedMessageIds?.includes(r))))return e;let i=Rt(e,t.clientMessageId);if(i!==-1){if(r===void 0)return e;let t=[...e];return t[i]={...t[i],id:r,isOptimistic:!1,queueStatus:void 0,queuePosition:void 0},t}return[...e,{id:r??crypto.randomUUID(),...r===void 0?{isOptimistic:!0}:{},...t.clientMessageId?{clientMessageId:t.clientMessageId}:{},role:`user`,textSegments:[t.text],contentOrder:[{type:`text`,id:`0`}],contentBlocks:[{type:`text`,text:t.text}],timestamp:n}]}function Bt(e,t=Date.now()){let n=e.length-1,r=e[n];if(!r||r.role!==`assistant`)return e;let i=U(r,t);if(!(I(r).trim().length>0||r.thinkingSegments!=null&&r.thinkingSegments.length>0||r.toolCalls!=null&&r.toolCalls.length>0||r.surfaces!=null&&r.surfaces.length>0))return e.slice(0,-1);let a=[...e];return a[n]={...r,...i??{}},a}function K(e,t){let n=[...e??[]],r=n.findIndex(e=>e.type===`tool_use`&&e.toolCall.id===t.id);return r===-1?n.push({type:`tool_use`,toolCall:t}):n[r]={type:`tool_use`,toolCall:t},n}function q(e,t,n,r){let i=H(e[t],r),a=i.toolCalls?.findIndex(e=>e.id===n.id)??-1,o=[...e];if(a!==-1){let e=[...i.toolCalls??[]],r={...e[a],...n};return e[a]=r,o[t]={...i,toolCalls:e,contentBlocks:K(i.contentBlocks,r)},o}return o[t]={...i,toolCalls:[...i.toolCalls??[],n],contentOrder:[...i.contentOrder??[],{type:`toolCall`,id:n.id}],contentBlocks:K(i.contentBlocks,n)},o}function Vt(e,t,n,r=Date.now()){if(n){let r=B(e,n);if(r>=0)return q(e,r,t,n);if(z(e))return q(e,e.length-1,t,n)}else if(z(e))return q(e,e.length-1,t);return[...e,{id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,toolCalls:[t],contentOrder:[{type:`toolCall`,id:t.id}],contentBlocks:[{type:`tool_use`,toolCall:t}],timestamp:r}]}function Ht(e,t){let n=-1,r=-1;if(t.toolUseId)for(let i=e.length-1;i>=0;i--){let a=e[i];if(a?.role!==`assistant`||!a.toolCalls?.length)continue;let o=a.toolCalls.findIndex(e=>e.id===t.toolUseId);if(o!==-1){n=i,r=o;break}}if(n===-1){if(n=e.findLastIndex(e=>e.role===`assistant`&&e.toolCalls&&e.toolCalls.length>0),n===-1)return e;let t=e[n];if(!t?.toolCalls)return e;r=t.toolCalls.findLastIndex(e=>f(e))}if(r===-1)return e;let i=e[n],a=i.toolCalls[r];if(!a)return e;let o=t.imageDataList===void 0?t.imageData===void 0?void 0:[t.imageData]:t.imageDataList,s=t.imageData===void 0?o?.[0]:t.imageData,c=[...i.toolCalls],l={...a,result:t.result,isError:t.isError,riskLevel:t.riskLevel,riskReason:t.riskReason,matchedTrustRuleId:t.matchedTrustRuleId,approvalMode:t.approvalMode,approvalReason:t.approvalReason,riskThreshold:t.riskThreshold,riskAllowlistOptions:t.riskAllowlistOptions,riskScopeOptions:t.riskScopeOptions,riskDirectoryScopeOptions:t.riskDirectoryScopeOptions,...s===void 0?{}:{imageData:s},...o===void 0?{}:{imageDataList:o},...t.activityMetadata===void 0?{}:{activityMetadata:t.activityMetadata},...t.errorCode===void 0?{}:{errorCode:t.errorCode},completedAt:t.completedAt??Date.now(),streamedOutput:void 0};c[r]=l;let u=[...e];return u[n]={...i,toolCalls:c,contentBlocks:K(i.contentBlocks,l)},u}var Ut=16384;function Wt(e){return e.length<=16384?e:e.slice(e.length-Ut)}function Gt(e,t){if(!t.chunk)return e;let n=-1,r=-1;if(t.toolUseId){if(t.messageId){let i=B(e,t.messageId);if(i>=0){let a=e[i].toolCalls?.findIndex(e=>e.id===t.toolUseId)??-1;a!==-1&&(n=i,r=a)}}if(n===-1)for(let i=e.length-1;i>=0;i--){let a=e[i];if(a?.role!==`assistant`||!a.toolCalls?.length)continue;let o=a.toolCalls.findIndex(e=>e.id===t.toolUseId);if(o!==-1){n=i,r=o;break}}}else{if(n=e.findLastIndex(e=>e.role===`assistant`&&e.toolCalls&&e.toolCalls.length>0),n===-1)return e;let t=e[n];if(!t?.toolCalls)return e;r=t.toolCalls.findLastIndex(e=>f(e))}if(n===-1||r===-1)return e;let i=e[n],a=i.toolCalls[r];if(!a)return e;let o={...a,streamedOutput:Wt((a.streamedOutput??``)+t.chunk)},s=[...i.toolCalls];s[r]=o;let c=[...e];return c[n]={...i,toolCalls:s,contentBlocks:K(i.contentBlocks,o)},c}function Kt(e,t,n,r=Date.now()){let i=V(e,n),a=[...e];if(i===-1)a.push({id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,surfaces:[t],contentOrder:[{type:`surface`,id:t.surfaceId}],contentBlocks:[{type:`surface`,surface:t}],timestamp:r});else{let r=H(e[i],n);if(r.contentOrder?.some(e=>e.type===`surface`&&e.id===t.surfaceId)||r.surfaces?.some(e=>e.surfaceId===t.surfaceId))return e;a[i]={...r,surfaces:[...r.surfaces??[],t],contentOrder:[...r.contentOrder??[],{type:`surface`,id:t.surfaceId}],contentBlocks:M(r.contentBlocks,t)}}return a}function qt(e,t,n){let r=V(e,n);if(r===-1)return e;let i=e[r];if(i.pendingVisualToolUseIds?.includes(t))return e;let a=[...e];return a[r]={...H(i,n),pendingVisualToolUseIds:[...i.pendingVisualToolUseIds??[],t]},a}function J(e,t={}){let n=t.toolUseId===void 0&&t.messageId!==void 0?V(e,t.messageId):void 0,r=!1,i=e.map((e,i)=>{let a=e.pendingVisualToolUseIds;if(!a||a.length===0||n!==void 0&&i!==n)return e;let o=t.toolUseId===void 0?[]:a.filter(e=>e!==t.toolUseId);if(o.length===a.length)return e;r=!0;let s={...e};return o.length===0?delete s.pendingVisualToolUseIds:s.pendingVisualToolUseIds=o,s});return r?i:e}function Jt(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r],a=i.surfaces?.findIndex(e=>e.surfaceId===t)??-1;if(a===-1)continue;let o=i.surfaces[a],s={...o.data,...n};o.data.templateData&&n.templateData&&typeof o.data.templateData==`object`&&typeof n.templateData==`object`&&(s.templateData={...o.data.templateData,...n.templateData});let c={...o,data:s},l=[...e],u=[...i.surfaces];return u[a]=c,l[r]={...i,surfaces:u,contentBlocks:M(i.contentBlocks,c)},l}return e}function Yt(e,t){for(let n=e.length-1;n>=0;n--){if(!e[n].surfaces?.some(e=>e.surfaceId===t))continue;let r=[...e];return r[n]={...e[n],surfaces:e[n].surfaces?.filter(e=>e.surfaceId!==t),contentOrder:e[n].contentOrder?.filter(e=>!(e.type===`surface`&&e.id===t)),contentBlocks:Ye(e[n].contentBlocks,t)},r}return e}function Xt(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r].surfaces?.find(e=>e.surfaceId===t);if(!i)continue;let a={...i,completed:!0,completionSummary:n},o=[...e];return o[r]={...e[r],surfaces:e[r].surfaces?.map(e=>e.surfaceId===t?a:e),contentBlocks:M(e[r].contentBlocks,a)},o}return e}var Zt=[`choice`,`oauth_connect`,`form`,`confirmation`,`file_upload`,`card`,`list`,`table`,`browser_view`,`task_preferences`];function Qt(e){return e==null||e.hasPendingConfirmation||e.hasUncompletedVisibleSurface}function $t(e,t){let n=!1,r=e.map(e=>{let r=re(e,e=>e.pendingConfirmation?.requestId===t?{...e,pendingConfirmation:void 0}:e);return r!==e&&(n=!0),r});return n?r:e}function en(e){let t=!1,n=e.map(e=>{let n=re(e,e=>e.pendingConfirmation?{...e,pendingConfirmation:void 0}:e);return n!==e&&(t=!0),n});return t?n:e}function tn(e,t){let n=new Set;for(let e of t)if(e.surfaces)for(let t of e.surfaces)ne(t)&&n.add(t.surfaceId);return n.size===0?{updatedMessages:e,dismissedIds:n}:{updatedMessages:e.map(e=>Ze(e,e=>!n.has(e.surfaceId))),dismissedIds:n}}function nn(e,t,n,r,i){for(let a=e.length-1;a>=0;a--){let o=e[a].surfaces?.find(e=>e.surfaceId===t);if(!o)continue;if(!Zt.includes(o.surfaceType)||o.completed)return e;let s=o.actions?.find(e=>e.id===n),c=n===`cancel`||n===`dismiss`,l=[...e];return l[a]=Xe(e[a],e=>e.surfaceId===t?{...e,completed:!0,completionSummary:c?`Cancelled`:r??s?.label??void 0,...i?.tone?{completionTone:i.tone}:{}}:e),l}return e}function rn(e,t,n){return e&&te[e]||t||n}function Y(e){return typeof e==`string`?e:void 0}function X(e){return typeof e==`boolean`?e:void 0}function an(e){return Array.isArray(e)?e:void 0}function on(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Z(e){return Array.isArray(e)?e:void 0}function sn(e){return{requestId:typeof e.requestId==`string`?e.requestId:``,label:Y(e.label),service:Y(e.service),field:Y(e.field),description:Y(e.description),placeholder:Y(e.placeholder),allowOneTimeSend:X(e.allowOneTimeSend),allowedTools:an(e.allowedTools),allowedDomains:an(e.allowedDomains),purpose:Y(e.purpose)}}function cn(e){let t={requestId:typeof e.requestId==`string`?e.requestId:``,title:Y(e.title),description:Y(e.description),toolName:Y(e.toolName),riskLevel:Y(e.riskLevel),riskReason:Y(e.riskReason),allowlistOptions:Z(e.allowlistOptions),scopeOptions:Z(e.scopeOptions),directoryScopeOptions:Z(e.directoryScopeOptions),persistentDecisionsAllowed:X(e.persistentDecisionsAllowed),input:on(e.input),toolUseId:Y(e.toolUseId)};return{confData:t,state:{...t,confirmLabel:Y(e.confirmLabel),denyLabel:Y(e.denyLabel)}}}function ln(){return`turn-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function un(e,t){let n=Date.parse(e);return Number.isFinite(n)?n:typeof t==`number`?t:0}function dn(e,t,n){switch(t.type){case`assistant_text_delta`:return Nt(e,t.text,t.messageId,void 0,n);case`assistant_thinking_delta`:return Ft(e,t.thinking,t.messageId,void 0,n);case`message_complete`:return J(Lt(e,t,n));case`user_message_echo`:return zt(e,{text:t.text,messageId:t.messageId,clientMessageId:t.clientMessageId},n);case`message_dequeued`:return Ot(e,t.requestId);case`message_requeued`:return kt(e,t.requestId,t.position);case`message_queued_deleted`:return At(e,t.requestId);case`assistant_activity_state`:return t.phase===`idle`?J(It(e,n)):e;case`conversation_error`:return J(Bt(e,n));case`tool_use_preview_start`:return Vt(e,{id:t.toolUseId,name:t.toolName,input:{},previewStartedAt:typeof t.previewStartedAt==`number`?t.previewStartedAt:n},t.messageId,n);case`tool_use_start`:return Vt(e,{id:t.toolUseId??`tool-${n}`,name:t.toolName,input:t.input,startedAt:`startedAt`in t&&typeof t.startedAt==`number`?t.startedAt:n,...`previewStartedAt`in t&&typeof t.previewStartedAt==`number`?{previewStartedAt:t.previewStartedAt}:{}},t.messageId,n);case`tool_result`:return Ht(J(e,{toolUseId:t.toolUseId}),{toolUseId:t.toolUseId,result:t.result,isError:t.isError,riskLevel:t.riskLevel,riskReason:t.riskReason,matchedTrustRuleId:t.matchedTrustRuleId,approvalMode:t.approvalMode,approvalReason:t.approvalReason,riskThreshold:t.riskThreshold,riskAllowlistOptions:t.riskAllowlistOptions,riskScopeOptions:t.riskScopeOptions,riskDirectoryScopeOptions:t.riskDirectoryScopeOptions,imageData:t.imageData,imageDataList:t.imageDataList,activityMetadata:t.activityMetadata,errorCode:t.errorCode,completedAt:`completedAt`in t&&typeof t.completedAt==`number`?t.completedAt:n});case`tool_output_chunk`:return t.chunk?Gt(e,{chunk:t.chunk,toolUseId:t.toolUseId,messageId:t.messageId}):e;case`ui_surface_pending`:return qt(e,t.toolUseId,t.messageId);case`ui_surface_show`:{let r={surfaceId:t.surfaceId,surfaceType:t.surfaceType,title:t.title,data:t.data,actions:t.actions,display:t.display};return r.display=ee(r),Kt(r.surfaceType===`visual`?J(e,t.toolCallId?{toolUseId:t.toolCallId}:{messageId:t.messageId}):e,r,t.messageId,n)}case`ui_surface_update`:return Jt(e,t.surfaceId,t.data);case`ui_surface_dismiss`:return Yt(e,t.surfaceId);case`ui_surface_complete`:return Xt(e,t.surfaceId,t.summary);case`confirmation_request`:return p(e,{requestId:t.requestId,toolName:t.toolName,riskLevel:t.riskLevel,riskReason:t.riskReason,allowlistOptions:t.allowlistOptions,scopeOptions:t.scopeOptions,directoryScopeOptions:t.directoryScopeOptions,persistentDecisionsAllowed:t.persistentDecisionsAllowed,input:t.input,toolUseId:t.toolUseId}).updatedMessages;case`interaction_resolved`:return t.kind===`confirmation`||t.kind===`acp_confirmation`?$t(e,t.requestId):e;default:return e}}function fn(e,t,n){if(e!==void 0){if(typeof n!=`number`)return e;switch(t.type){case`assistant_turn_start`:case`assistant_text_delta`:case`assistant_thinking_delta`:return!0;case`assistant_activity_state`:return t.phase!==`idle`;case`message_complete`:return!1;default:return e}}}function pn(e,t){let{seq:n}=t;if(typeof n==`number`&&typeof e.seq==`number`&&n<=e.seq)return e;let r=un(t.emittedAt,n),i=dn(e.messages,t.message,r),a=typeof n==`number`?Math.max(e.seq??-1,n):e.seq??null,o=fn(e.processing,t.message,n);return{...e,messages:i,seq:a,processing:o}}function mn(e,t){return t.reduce(pn,e)}function hn(e,t){return t===null?e:mn(e,t)}var gn={hasMore:!1,oldestTimestamp:null,isLoadingOlder:!1};function _n(){return{snapshot:null,optimisticSends:[],error:null,notice:null,isLoadingHistory:!0,transcriptPagination:{...gn},contextWindowUsage:null,ephemeralMetaResults:[],compactionCircuitOpenUntil:null,dismissedSurfaceIds:new Set,streamingMessageIds:new Set,pendingQueuedMessageIds:[],requestIdToMessageId:new Map,pendingLocalDeletions:new Set,confirmationToolCallMap:new Map,expandedToolCallIds:new Set,expandedCardIds:new Map,contextWindowUsageByConversation:new Map,previousConversationId:null,previousAssistantId:null,draftConversationIdResolution:!1}}function Q(e,t){return typeof t==`function`?t(e):t}function vn(e,t){if(e.length===0)return e;let n=new Map;for(let e of t)for(let t of L(e))n.has(t)||n.set(t,e);let r=e.filter(e=>{let t;for(let r of L(e))if(t=n.get(r),t)break;return t?!!e.attachments?.length&&!t.attachments?.length:!0});return r.length===e.length?e:r}var $=o(a()((e,t)=>({..._n(),seedSnapshot:(n,r)=>{let i=t().snapshot;if(r.seq==null&&i!==null&&typeof i.seq==`number`){c(`history_seed_skipped_anchorless`,{conversationId:n,liveSeq:i.seq});return}let a=he(n,r.seq??null);if(a===null&&i!==null&&typeof i.seq==`number`&&typeof r.seq==`number`&&r.seq<i.seq){c(`history_seed_skipped_stale_anchor`,{conversationId:n,liveSeq:i.seq,fetchedSeq:r.seq});return}let o=hn(r,a);e(e=>({snapshot:o,optimisticSends:vn(e.optimisticSends,o.messages)}))},applyEnvelopeToSnapshot:t=>e(e=>e.snapshot?{snapshot:pn(e.snapshot,t)}:{}),addOptimisticSend:t=>e(e=>({optimisticSends:[...e.optimisticSends,t]})),setOptimisticSends:t=>e(e=>({optimisticSends:Q(e.optimisticSends,t)})),patchSnapshotMessages:t=>e(e=>e.snapshot?{snapshot:{...e.snapshot,messages:t(e.snapshot.messages)}}:{}),setError:t=>e(e=>({error:Q(e.error,t)})),setNotice:t=>e(e=>({notice:Q(e.notice,t)})),setIsLoadingHistory:t=>e({isLoadingHistory:t}),setTranscriptPagination:t=>e(e=>({transcriptPagination:Q(e.transcriptPagination,t)})),setContextWindowUsage:t=>e(e=>({contextWindowUsage:Q(e.contextWindowUsage,t)})),setCompactionCircuitOpenUntil:t=>e(e=>({compactionCircuitOpenUntil:Q(e.compactionCircuitOpenUntil,t)})),switchToConversation:({assistantId:n,activeConversationId:r})=>{let i=t();if(i.draftConversationIdResolution){e({draftConversationIdResolution:!1});return}let a=i.previousConversationId;if(a&&a!==r&&a){let e=F.getState();(e.pendingSecret||e.pendingConfirmation)&&l.getState().addAttentionConversationId(a)}let o=i.previousAssistantId!==null&&i.previousAssistantId!==n,s=o||i.previousAssistantId===null;c(`conversation_switch_reset`,{assistantId:n,conversationId:r,outgoingConversationId:a??null}),j.getState().handleConversationSwitch({previousKey:a??null,nextKey:r}),ye.getState().resetTurn(),F.getState().resetAll(),o?j.getState().fullReset():j.getState().resetAttachments();let u=s?ot(n):i.contextWindowUsageByConversation;e({snapshot:null,optimisticSends:[],ephemeralMetaResults:[],error:N(i.error)?i.error:null,notice:null,isLoadingHistory:!0,transcriptPagination:{...gn},contextWindowUsage:u.get(r)??null,compactionCircuitOpenUntil:null,dismissedSurfaceIds:et(n,r),streamingMessageIds:new Set,pendingQueuedMessageIds:[],requestIdToMessageId:new Map,pendingLocalDeletions:new Set,confirmationToolCallMap:new Map,expandedToolCallIds:new Set,expandedCardIds:new Map,contextWindowUsageByConversation:u,previousConversationId:r,previousAssistantId:n,draftConversationIdResolution:!1})},markDraftResolution:()=>e({draftConversationIdResolution:!0}),setConfirmationToolCall:(t,n)=>e(e=>{let r=new Map(e.confirmationToolCallMap);return r.set(t,n),{confirmationToolCallMap:r}}),deleteConfirmationToolCall:t=>e(e=>{let n=new Map(e.confirmationToolCallMap);return n.delete(t),{confirmationToolCallMap:n}}),clearConfirmationToolCallMap:()=>e({confirmationToolCallMap:new Map}),addDismissedSurfaceId:t=>e(e=>{let n=new Set(e.dismissedSurfaceIds);return n.add(t),{dismissedSurfaceIds:n}}),addDismissedSurfaceIds:t=>e(e=>{let n=new Set(e.dismissedSurfaceIds);for(let e of t)n.add(e);return{dismissedSurfaceIds:n}}),batchUpdateStreamingMessageIds:(t,n)=>e(e=>{let r=new Set(e.streamingMessageIds);for(let e of t)r.add(e);for(let e of n)r.delete(e);return{streamingMessageIds:r}}),pushPendingQueuedMessageId:t=>e(e=>({pendingQueuedMessageIds:[...e.pendingQueuedMessageIds,t]})),shiftPendingQueuedMessageId:()=>{let n=t().pendingQueuedMessageIds;if(n.length===0)return;let[r,...i]=n;return e({pendingQueuedMessageIds:i}),r},takePendingQueuedMessageId:n=>{let r=t().pendingQueuedMessageIds;if(r.includes(n))return e({pendingQueuedMessageIds:r.filter(e=>e!==n)}),n},setRequestIdMapping:(t,n)=>e(e=>{let r=new Map(e.requestIdToMessageId);return r.set(t,n),{requestIdToMessageId:r}}),popRequestIdMapping:n=>{let r=t().requestIdToMessageId,i=r.get(n);if(i!==void 0){let t=new Map(r);t.delete(n),e({requestIdToMessageId:t})}return i},addPendingLocalDeletion:t=>e(e=>{let n=new Set(e.pendingLocalDeletions);return n.add(t),{pendingLocalDeletions:n}}),consumePendingLocalDeletion:n=>{let r=t().pendingLocalDeletions;if(!r.has(n))return!1;let i=new Set(r);return i.delete(n),e({pendingLocalDeletions:i}),!0},setExpandedToolCallId:(t,n)=>e(e=>{let r=new Set(e.expandedToolCallIds);return n?r.add(t):r.delete(t),{expandedToolCallIds:r}}),setExpandedCardId:(t,n)=>e(e=>{let r=new Map(e.expandedCardIds);return r.set(t,n),{expandedCardIds:r}}),setContextWindowUsageForConversation:(t,n)=>e(e=>{let r=new Map(e.contextWindowUsageByConversation);return r.set(t,n),{contextWindowUsageByConversation:r}}),addEphemeralMetaResult:t=>e(e=>({ephemeralMetaResults:[...e.ephemeralMetaResults,t]})),clearEphemeralMetaResults:()=>e(e=>e.ephemeralMetaResults.length===0?e:{ephemeralMetaResults:[]})})));function yn(e,t){if(t.length===0)return e;let n=new Map;for(let e of t)for(let t of L(e))n.has(t)||n.set(t,e);let r=[],i=new Set;for(let t of e){let e;for(let r of L(t)){let t=n.get(r);if(t){e=t;break}}if(e){i.has(e)||(r.push(e),i.add(e));continue}r.push(t)}for(let e of t)i.has(e)||r.push(e);return r}function bn(){let e=$.use.snapshot()?.messages,t=$.use.optimisticSends(),n=$.use.dismissedSurfaceIds();return(0,ie.useMemo)(()=>yn(rt(e,n),t),[e,t,n])}export{N as A,ve as B,I as C,xt as D,mt as E,Ke as F,fe as G,ge as H,Ge as I,le as J,ce as K,We as L,tt as M,Xe as N,yt as O,Je as P,j as R,R as S,vt as T,pe as U,ye as V,me as W,se as Y,At as _,en as a,wt as b,ln as c,rn as d,Qt as f,kt as g,Tt as h,$t as i,st as j,bt as k,cn as l,Dt as m,yn as n,nn as o,Ot as p,ue as q,$ as r,tn as s,bn as t,sn as u,Et as v,F as w,L as x,z as y,v as z};
@@ -1 +1 @@
1
- import{t as e}from"./capture-error-CqtAGHQu.js";import"./src-Co3nj9N_.js";import{n as t}from"./toast-elfTwkN2.js";import{n,t as r}from"./create-selectors-BfxF8Sx_.js";import{t as i}from"./api-errors-BRGPPSWw.js";import{Ct as a,n as o,xt as s}from"./sdk.gen-CjtCuSlS.js";import{t as c}from"./open-workspace-file-B7_lXQau.js";import{o as l}from"./workspace-path-links-vDBIljq_.js";var u=new Map;function d(e,t){return`${e}::${t}`}function f(e,t){let n=d(e,t),r=u.get(n);return r??(r=o({path:{assistant_id:e,id:t},throwOnError:!0}).then(e=>e.data.html).catch(e=>{throw u.delete(n),e}),u.set(n,r)),r}function p(e,t,n){u.set(d(e,t),Promise.resolve(n))}function m(e,t){u.delete(d(e,t))}function h(e){if(typeof e!=`object`||!e)return!1;let t=e.error;if(typeof t!=`object`||!t||t.code!==`NOT_FOUND`)return!1;let n=t.message;return typeof n==`string`&&n.startsWith(`App not found`)}function g(e){return e instanceof i&&e.status<500&&e.message?e.message:`Couldn't open this file`}var _=[`File not found`,`The file backing this document no longer exists`];function v(e){return!(e instanceof i)||e.status!==404?!1:!_.some(t=>e.message.startsWith(t))}function y(e,t){let n=e.mainView;return n===`document`||n===`subagent-detail`||n===`tool-detail`||n===`activity-steps`||n===`message-files`||n===`workflow-detail`||n===`acp-run-detail`||n===`background-task-detail`||n===`skill-detail`||n===`channel-setup`?e[t]:n}function b(e,t){return e===null||e.source!==t.source?!1:e.source===`document`&&t.source===`document`?e.surfaceId===t.surfaceId:e.source===`document`||t.source===`document`?!1:e.workspacePath===t.workspacePath}function x(e,t){return e.messageId!=null||t.messageId!=null?e.messageId===t.messageId&&e.groupIndex===t.groupIndex:e.toolCalls[0]?.id===t.toolCalls[0]?.id}function S(e,t){return e.messageId===t.messageId}function C(e,t){return t.messageId==null?e.thinkingText===t.thinkingText:e.messageId===t.messageId&&e.thinkingGroupIndex===t.thinkingGroupIndex&&e.thinkingItemIndex===t.thinkingItemIndex}var w={mainView:`chat`,activeAppId:null,openedAppState:null,activeDocumentTarget:null,openedDocumentState:null,isAppMinimized:!1,intelligenceTab:`identity`,assetsRefreshKey:0,viewBeforeDocument:`chat`,activeSubagentId:null,viewBeforeSubagentDetail:`chat`,activeToolDetail:null,viewBeforeToolDetail:`chat`,activeActivitySteps:null,viewBeforeActivitySteps:`chat`,activeMessageFiles:null,viewBeforeMessageFiles:`chat`,activeWorkflowRunId:null,viewBeforeWorkflowDetail:`chat`,activeAcpRunId:null,viewBeforeAcpRunDetail:`chat`,activeBackgroundTaskId:null,viewBeforeBackgroundTaskDetail:`chat`,activeSkillDetailId:null,viewBeforeSkillDetail:`chat`,activeChannelSetup:null,viewBeforeChannelSetup:`chat`,ruleEditorRequestSeq:0,ruleEditorRequestToolCallId:null},T=r(n()((n,r)=>({...w,setMainView:e=>{r().mainView!==e&&n({mainView:e})},setIntelligenceTab:e=>{r().intelligenceTab!==e&&n({intelligenceTab:e})},openApp:e=>{n({mainView:`app`,activeAppId:e,openedAppState:null,isAppMinimized:!1})},loadApp:async(t,i)=>{n({mainView:`app`,activeAppId:i,openedAppState:null,isAppMinimized:!1});try{let{data:e}=await o({path:{assistant_id:t,id:i},throwOnError:!0});if(r().activeAppId!==i)return;n({openedAppState:{appId:e.appId,dirName:e.dirName,name:e.name,html:e.html}}),p(t,e.appId,e.html)}catch(t){if(r().activeAppId!==i)return;h(t)||e(t,{context:`openApp`}),n({mainView:`chat`,activeAppId:null,openedAppState:null})}},setLoadedApp:e=>{n({openedAppState:e})},handleAppLoadFailed:()=>{n({mainView:`chat`,activeAppId:null,openedAppState:null})},closeApp:()=>{n({mainView:`chat`,activeAppId:null,openedAppState:null,isAppMinimized:!1})},toggleAppMinimized:()=>{n({isAppMinimized:!r().isAppMinimized})},minimizeApp:()=>{n({isAppMinimized:!0})},handleAppUnpinned:e=>{let t=r();return t.activeAppId!==e||t.mainView!==`app`&&t.mainView!==`app-editing`?!1:(r().closeApp(),!0)},enterAppEditing:()=>{n({mainView:`app-editing`})},exitAppEditing:()=>{n({mainView:`app`})},openSubagentDetail:e=>{n({mainView:`subagent-detail`,activeSubagentId:e,viewBeforeSubagentDetail:y(r(),`viewBeforeSubagentDetail`)})},closeSubagentDetail:()=>{n({mainView:r().viewBeforeSubagentDetail,activeSubagentId:null})},openWorkflowDetail:e=>{n({mainView:`workflow-detail`,activeWorkflowRunId:e,viewBeforeWorkflowDetail:y(r(),`viewBeforeWorkflowDetail`)})},closeWorkflowDetail:()=>{n({mainView:r().viewBeforeWorkflowDetail,activeWorkflowRunId:null})},openAcpRunDetail:e=>{n({mainView:`acp-run-detail`,activeAcpRunId:e,viewBeforeAcpRunDetail:y(r(),`viewBeforeAcpRunDetail`)})},closeAcpRunDetail:()=>{n({mainView:r().viewBeforeAcpRunDetail,activeAcpRunId:null})},openBackgroundTaskDetail:e=>{n({mainView:`background-task-detail`,activeBackgroundTaskId:e,viewBeforeBackgroundTaskDetail:y(r(),`viewBeforeBackgroundTaskDetail`)})},closeBackgroundTaskDetail:()=>{n({mainView:r().viewBeforeBackgroundTaskDetail,activeBackgroundTaskId:null})},openSkillDetail:e=>{n({mainView:`skill-detail`,activeSkillDetailId:e,viewBeforeSkillDetail:y(r(),`viewBeforeSkillDetail`)})},closeSkillDetail:()=>{n({mainView:r().viewBeforeSkillDetail,activeSkillDetailId:null})},openProcessDetail:({kind:e,id:t})=>{switch(e){case`subagent`:r().openSubagentDetail(t);return;case`workflow`:r().openWorkflowDetail(t);return;case`acp-run`:r().openAcpRunDetail(t);return;case`background-task`:r().openBackgroundTaskDetail(t);return;default:}},closeActiveOverlay:()=>{switch(r().mainView){case`document`:return r().closeDocument(),!0;case`subagent-detail`:return r().closeSubagentDetail(),!0;case`tool-detail`:return r().closeToolDetail(),!0;case`activity-steps`:return r().closeActivitySteps(),!0;case`message-files`:return r().closeMessageFiles(),!0;case`workflow-detail`:return r().closeWorkflowDetail(),!0;case`acp-run-detail`:return r().closeAcpRunDetail(),!0;case`background-task-detail`:return r().closeBackgroundTaskDetail(),!0;case`skill-detail`:return r().closeSkillDetail(),!0;case`channel-setup`:return r().closeChannelSetup(),!0;default:return!1}},openChannelSetup:e=>{n({mainView:`channel-setup`,activeChannelSetup:e,viewBeforeChannelSetup:y(r(),`viewBeforeChannelSetup`)})},closeChannelSetup:()=>{n({mainView:r().viewBeforeChannelSetup,activeChannelSetup:null})},openToolDetail:e=>{n({mainView:`tool-detail`,activeToolDetail:e,viewBeforeToolDetail:y(r(),`viewBeforeToolDetail`)})},toggleToolDetail:e=>{let t=r(),n=t.activeToolDetail;t.mainView===`tool-detail`&&n!=null&&(e.kind===`thinking`?n.kind===`thinking`&&C(n,e):n.kind!==`thinking`&&n.toolCallId===e.toolCallId)?r().closeToolDetail():r().openToolDetail(e)},closeToolDetail:()=>{n({mainView:r().viewBeforeToolDetail,activeToolDetail:null})},requestRuleEditor:e=>{e&&n(t=>({ruleEditorRequestSeq:t.ruleEditorRequestSeq+1,ruleEditorRequestToolCallId:e}))},openActivitySteps:e=>{n({mainView:`activity-steps`,activeActivitySteps:e,viewBeforeActivitySteps:y(r(),`viewBeforeActivitySteps`)})},toggleActivitySteps:e=>{let t=r(),n=t.activeActivitySteps;t.mainView===`activity-steps`&&n!=null&&x(n,e)?r().closeActivitySteps():r().openActivitySteps(e)},closeActivitySteps:()=>{n({mainView:r().viewBeforeActivitySteps,activeActivitySteps:null})},openMessageFiles:e=>{n({mainView:`message-files`,activeMessageFiles:e,viewBeforeMessageFiles:y(r(),`viewBeforeMessageFiles`)})},toggleMessageFiles:e=>{let t=r(),n=t.activeMessageFiles;t.mainView===`message-files`&&n!=null&&S(n,e)?r().closeMessageFiles():r().openMessageFiles(e)},closeMessageFiles:()=>{n({mainView:r().viewBeforeMessageFiles,activeMessageFiles:null})},clearTranscriptPanelPayloads:()=>{n({activeMessageFiles:null,activeActivitySteps:null,activeToolDetail:null})},openDocument:()=>{n({mainView:`document`,openedDocumentState:null,viewBeforeDocument:y(r(),`viewBeforeDocument`)})},loadDocument:async(e,t)=>{let i=y(r(),`viewBeforeDocument`),a={source:`document`,surfaceId:t};n({mainView:`document`,activeDocumentTarget:a,openedDocumentState:null,viewBeforeDocument:i});try{let{data:o}=await s({path:{assistant_id:e,id:t},throwOnError:!0});if(!b(r().activeDocumentTarget,a))return;if(!o){n({mainView:i,activeDocumentTarget:null,openedDocumentState:null});return}n({openedDocumentState:{source:`document`,surfaceId:o.surfaceId,conversationId:o.conversationId,documentName:o.title??`Untitled`,content:o.content??``,workspacePath:o.workspacePath}})}catch{if(!b(r().activeDocumentTarget,a))return;n({mainView:i,activeDocumentTarget:null,openedDocumentState:null})}},loadWorkspaceFileDocument:async(e,i,o)=>{let s=y(r(),`viewBeforeDocument`),l={source:`workspace-file`,workspacePath:i};n({mainView:`document`,activeDocumentTarget:l,openedDocumentState:null,viewBeforeDocument:s});let u=e=>{if(b(r().activeDocumentTarget,l)){if(n({mainView:s,activeDocumentTarget:null,openedDocumentState:null}),v(e)){c(i);return}t.error(g(e))}};try{let{data:t}=await a({path:{assistant_id:e},body:{path:i,conversationId:o},throwOnError:!0});if(!b(r().activeDocumentTarget,l))return;if(!t){u(null);return}n({activeDocumentTarget:{source:`document`,surfaceId:t.surfaceId},openedDocumentState:{source:`document`,surfaceId:t.surfaceId,conversationId:t.conversationId,documentName:t.title||`Untitled`,content:t.content??``,workspacePath:t.workspacePath}})}catch(e){u(e)}},openWorkspaceFilePreview:(e,t)=>{n({mainView:`document`,activeDocumentTarget:{source:`workspace-file-preview`,workspacePath:e},openedDocumentState:{source:`workspace-file-preview`,workspacePath:e,documentName:l(e),previewKind:t},viewBeforeDocument:y(r(),`viewBeforeDocument`)})},setLoadedDocument:e=>{n({openedDocumentState:e})},updateDocumentContent:(e,t,i)=>{let a=r().openedDocumentState;if(!a||a.source!==`document`||a.surfaceId!==e)return;let o=i===`append`?a.content+t:t;n({openedDocumentState:{...a,content:o}})},handleDocumentLoadFailed:()=>{n({mainView:r().viewBeforeDocument,activeDocumentTarget:null,openedDocumentState:null})},closeDocument:()=>{n({mainView:r().viewBeforeDocument,activeDocumentTarget:null,openedDocumentState:null})},refreshAssets:()=>{n({assetsRefreshKey:r().assetsRefreshKey+1})},reset:()=>n({...w})})));export{m as a,T as i,S as n,f as o,C as r,p as s,x as t};
1
+ import{t as e}from"./capture-error-CqtAGHQu.js";import"./src-Co3nj9N_.js";import{n as t}from"./toast-elfTwkN2.js";import{n,t as r}from"./create-selectors-BfxF8Sx_.js";import{t as i}from"./api-errors-BRGPPSWw.js";import{Ct as a,n as o,xt as s}from"./sdk.gen-CjtCuSlS.js";import{t as c}from"./open-workspace-file-gzML_adc.js";import{o as l}from"./workspace-path-links-vDBIljq_.js";var u=new Map;function d(e,t){return`${e}::${t}`}function f(e,t){let n=d(e,t),r=u.get(n);return r??(r=o({path:{assistant_id:e,id:t},throwOnError:!0}).then(e=>e.data.html).catch(e=>{throw u.delete(n),e}),u.set(n,r)),r}function p(e,t,n){u.set(d(e,t),Promise.resolve(n))}function m(e,t){u.delete(d(e,t))}function h(e){if(typeof e!=`object`||!e)return!1;let t=e.error;if(typeof t!=`object`||!t||t.code!==`NOT_FOUND`)return!1;let n=t.message;return typeof n==`string`&&n.startsWith(`App not found`)}function g(e){return e instanceof i&&e.status<500&&e.message?e.message:`Couldn't open this file`}var _=[`File not found`,`The file backing this document no longer exists`];function v(e){return!(e instanceof i)||e.status!==404?!1:!_.some(t=>e.message.startsWith(t))}function y(e,t){let n=e.mainView;return n===`document`||n===`subagent-detail`||n===`tool-detail`||n===`activity-steps`||n===`message-files`||n===`workflow-detail`||n===`acp-run-detail`||n===`background-task-detail`||n===`skill-detail`||n===`channel-setup`?e[t]:n}function b(e,t){return e===null||e.source!==t.source?!1:e.source===`document`&&t.source===`document`?e.surfaceId===t.surfaceId:e.source===`document`||t.source===`document`?!1:e.workspacePath===t.workspacePath}function x(e,t){return e.messageId!=null||t.messageId!=null?e.messageId===t.messageId&&e.groupIndex===t.groupIndex:e.toolCalls[0]?.id===t.toolCalls[0]?.id}function S(e,t){return e.messageId===t.messageId}function C(e,t){return t.messageId==null?e.thinkingText===t.thinkingText:e.messageId===t.messageId&&e.thinkingGroupIndex===t.thinkingGroupIndex&&e.thinkingItemIndex===t.thinkingItemIndex}var w={mainView:`chat`,activeAppId:null,openedAppState:null,activeDocumentTarget:null,openedDocumentState:null,isAppMinimized:!1,intelligenceTab:`identity`,assetsRefreshKey:0,viewBeforeDocument:`chat`,activeSubagentId:null,viewBeforeSubagentDetail:`chat`,activeToolDetail:null,viewBeforeToolDetail:`chat`,activeActivitySteps:null,viewBeforeActivitySteps:`chat`,activeMessageFiles:null,viewBeforeMessageFiles:`chat`,activeWorkflowRunId:null,viewBeforeWorkflowDetail:`chat`,activeAcpRunId:null,viewBeforeAcpRunDetail:`chat`,activeBackgroundTaskId:null,viewBeforeBackgroundTaskDetail:`chat`,activeSkillDetailId:null,viewBeforeSkillDetail:`chat`,activeChannelSetup:null,viewBeforeChannelSetup:`chat`,ruleEditorRequestSeq:0,ruleEditorRequestToolCallId:null},T=r(n()((n,r)=>({...w,setMainView:e=>{r().mainView!==e&&n({mainView:e})},setIntelligenceTab:e=>{r().intelligenceTab!==e&&n({intelligenceTab:e})},openApp:e=>{n({mainView:`app`,activeAppId:e,openedAppState:null,isAppMinimized:!1})},loadApp:async(t,i)=>{n({mainView:`app`,activeAppId:i,openedAppState:null,isAppMinimized:!1});try{let{data:e}=await o({path:{assistant_id:t,id:i},throwOnError:!0});if(r().activeAppId!==i)return;n({openedAppState:{appId:e.appId,dirName:e.dirName,name:e.name,html:e.html}}),p(t,e.appId,e.html)}catch(t){if(r().activeAppId!==i)return;h(t)||e(t,{context:`openApp`}),n({mainView:`chat`,activeAppId:null,openedAppState:null})}},setLoadedApp:e=>{n({openedAppState:e})},handleAppLoadFailed:()=>{n({mainView:`chat`,activeAppId:null,openedAppState:null})},closeApp:()=>{n({mainView:`chat`,activeAppId:null,openedAppState:null,isAppMinimized:!1})},toggleAppMinimized:()=>{n({isAppMinimized:!r().isAppMinimized})},minimizeApp:()=>{n({isAppMinimized:!0})},handleAppUnpinned:e=>{let t=r();return t.activeAppId!==e||t.mainView!==`app`&&t.mainView!==`app-editing`?!1:(r().closeApp(),!0)},enterAppEditing:()=>{n({mainView:`app-editing`})},exitAppEditing:()=>{n({mainView:`app`})},openSubagentDetail:e=>{n({mainView:`subagent-detail`,activeSubagentId:e,viewBeforeSubagentDetail:y(r(),`viewBeforeSubagentDetail`)})},closeSubagentDetail:()=>{n({mainView:r().viewBeforeSubagentDetail,activeSubagentId:null})},openWorkflowDetail:e=>{n({mainView:`workflow-detail`,activeWorkflowRunId:e,viewBeforeWorkflowDetail:y(r(),`viewBeforeWorkflowDetail`)})},closeWorkflowDetail:()=>{n({mainView:r().viewBeforeWorkflowDetail,activeWorkflowRunId:null})},openAcpRunDetail:e=>{n({mainView:`acp-run-detail`,activeAcpRunId:e,viewBeforeAcpRunDetail:y(r(),`viewBeforeAcpRunDetail`)})},closeAcpRunDetail:()=>{n({mainView:r().viewBeforeAcpRunDetail,activeAcpRunId:null})},openBackgroundTaskDetail:e=>{n({mainView:`background-task-detail`,activeBackgroundTaskId:e,viewBeforeBackgroundTaskDetail:y(r(),`viewBeforeBackgroundTaskDetail`)})},closeBackgroundTaskDetail:()=>{n({mainView:r().viewBeforeBackgroundTaskDetail,activeBackgroundTaskId:null})},openSkillDetail:e=>{n({mainView:`skill-detail`,activeSkillDetailId:e,viewBeforeSkillDetail:y(r(),`viewBeforeSkillDetail`)})},closeSkillDetail:()=>{n({mainView:r().viewBeforeSkillDetail,activeSkillDetailId:null})},openProcessDetail:({kind:e,id:t})=>{switch(e){case`subagent`:r().openSubagentDetail(t);return;case`workflow`:r().openWorkflowDetail(t);return;case`acp-run`:r().openAcpRunDetail(t);return;case`background-task`:r().openBackgroundTaskDetail(t);return;default:}},closeActiveOverlay:()=>{switch(r().mainView){case`document`:return r().closeDocument(),!0;case`subagent-detail`:return r().closeSubagentDetail(),!0;case`tool-detail`:return r().closeToolDetail(),!0;case`activity-steps`:return r().closeActivitySteps(),!0;case`message-files`:return r().closeMessageFiles(),!0;case`workflow-detail`:return r().closeWorkflowDetail(),!0;case`acp-run-detail`:return r().closeAcpRunDetail(),!0;case`background-task-detail`:return r().closeBackgroundTaskDetail(),!0;case`skill-detail`:return r().closeSkillDetail(),!0;case`channel-setup`:return r().closeChannelSetup(),!0;default:return!1}},openChannelSetup:e=>{n({mainView:`channel-setup`,activeChannelSetup:e,viewBeforeChannelSetup:y(r(),`viewBeforeChannelSetup`)})},closeChannelSetup:()=>{n({mainView:r().viewBeforeChannelSetup,activeChannelSetup:null})},openToolDetail:e=>{n({mainView:`tool-detail`,activeToolDetail:e,viewBeforeToolDetail:y(r(),`viewBeforeToolDetail`)})},toggleToolDetail:e=>{let t=r(),n=t.activeToolDetail;t.mainView===`tool-detail`&&n!=null&&(e.kind===`thinking`?n.kind===`thinking`&&C(n,e):n.kind!==`thinking`&&n.toolCallId===e.toolCallId)?r().closeToolDetail():r().openToolDetail(e)},closeToolDetail:()=>{n({mainView:r().viewBeforeToolDetail,activeToolDetail:null})},requestRuleEditor:e=>{e&&n(t=>({ruleEditorRequestSeq:t.ruleEditorRequestSeq+1,ruleEditorRequestToolCallId:e}))},openActivitySteps:e=>{n({mainView:`activity-steps`,activeActivitySteps:e,viewBeforeActivitySteps:y(r(),`viewBeforeActivitySteps`)})},toggleActivitySteps:e=>{let t=r(),n=t.activeActivitySteps;t.mainView===`activity-steps`&&n!=null&&x(n,e)?r().closeActivitySteps():r().openActivitySteps(e)},closeActivitySteps:()=>{n({mainView:r().viewBeforeActivitySteps,activeActivitySteps:null})},openMessageFiles:e=>{n({mainView:`message-files`,activeMessageFiles:e,viewBeforeMessageFiles:y(r(),`viewBeforeMessageFiles`)})},toggleMessageFiles:e=>{let t=r(),n=t.activeMessageFiles;t.mainView===`message-files`&&n!=null&&S(n,e)?r().closeMessageFiles():r().openMessageFiles(e)},closeMessageFiles:()=>{n({mainView:r().viewBeforeMessageFiles,activeMessageFiles:null})},clearTranscriptPanelPayloads:()=>{n({activeMessageFiles:null,activeActivitySteps:null,activeToolDetail:null})},openDocument:()=>{n({mainView:`document`,openedDocumentState:null,viewBeforeDocument:y(r(),`viewBeforeDocument`)})},loadDocument:async(e,t)=>{let i=y(r(),`viewBeforeDocument`),a={source:`document`,surfaceId:t};n({mainView:`document`,activeDocumentTarget:a,openedDocumentState:null,viewBeforeDocument:i});try{let{data:o}=await s({path:{assistant_id:e,id:t},throwOnError:!0});if(!b(r().activeDocumentTarget,a))return;if(!o){n({mainView:i,activeDocumentTarget:null,openedDocumentState:null});return}n({openedDocumentState:{source:`document`,surfaceId:o.surfaceId,conversationId:o.conversationId,documentName:o.title??`Untitled`,content:o.content??``,workspacePath:o.workspacePath}})}catch{if(!b(r().activeDocumentTarget,a))return;n({mainView:i,activeDocumentTarget:null,openedDocumentState:null})}},loadWorkspaceFileDocument:async(e,i,o)=>{let s=y(r(),`viewBeforeDocument`),l={source:`workspace-file`,workspacePath:i};n({mainView:`document`,activeDocumentTarget:l,openedDocumentState:null,viewBeforeDocument:s});let u=e=>{if(b(r().activeDocumentTarget,l)){if(n({mainView:s,activeDocumentTarget:null,openedDocumentState:null}),v(e)){c(i);return}t.error(g(e))}};try{let{data:t}=await a({path:{assistant_id:e},body:{path:i,conversationId:o},throwOnError:!0});if(!b(r().activeDocumentTarget,l))return;if(!t){u(null);return}n({activeDocumentTarget:{source:`document`,surfaceId:t.surfaceId},openedDocumentState:{source:`document`,surfaceId:t.surfaceId,conversationId:t.conversationId,documentName:t.title||`Untitled`,content:t.content??``,workspacePath:t.workspacePath}})}catch(e){u(e)}},openWorkspaceFilePreview:(e,t)=>{n({mainView:`document`,activeDocumentTarget:{source:`workspace-file-preview`,workspacePath:e},openedDocumentState:{source:`workspace-file-preview`,workspacePath:e,documentName:l(e),previewKind:t},viewBeforeDocument:y(r(),`viewBeforeDocument`)})},setLoadedDocument:e=>{n({openedDocumentState:e})},updateDocumentContent:(e,t,i)=>{let a=r().openedDocumentState;if(!a||a.source!==`document`||a.surfaceId!==e)return;let o=i===`append`?a.content+t:t;n({openedDocumentState:{...a,content:o}})},handleDocumentLoadFailed:()=>{n({mainView:r().viewBeforeDocument,activeDocumentTarget:null,openedDocumentState:null})},closeDocument:()=>{n({mainView:r().viewBeforeDocument,activeDocumentTarget:null,openedDocumentState:null})},refreshAssets:()=>{n({assetsRefreshKey:r().assetsRefreshKey+1})},reset:()=>n({...w})})));export{m as a,T as i,S as n,f as o,C as r,p as s,x as t};
package/dist/index.html CHANGED
@@ -51,7 +51,7 @@
51
51
  <meta name="twitter:image:alt" content="Vellum: Your Personal Intelligence" />
52
52
 
53
53
  <script src="/assistant/theme-init.js"></script>
54
- <script type="module" crossorigin src="/assistant/assets/index-Dhip4b6y.js"></script>
54
+ <script type="module" crossorigin src="/assistant/assets/index-lOqt4q0A.js"></script>
55
55
  <link rel="modulepreload" crossorigin href="/assistant/assets/chunk-jRWAZmH_.js">
56
56
  <link rel="modulepreload" crossorigin href="/assistant/assets/preload-helper-Cv2QeVDK.js">
57
57
  <link rel="modulepreload" crossorigin href="/assistant/assets/is-electron-DIlIrdJX.js">
@@ -170,20 +170,20 @@
170
170
  <link rel="modulepreload" crossorigin href="/assistant/assets/add-credential-modal-gbivp7Mj.js">
171
171
  <link rel="modulepreload" crossorigin href="/assistant/assets/edge-swipe-arbiter-store-BwC23ScO.js">
172
172
  <link rel="modulepreload" crossorigin href="/assistant/assets/workspace-path-links-vDBIljq_.js">
173
- <link rel="modulepreload" crossorigin href="/assistant/assets/open-workspace-file-B7_lXQau.js">
174
- <link rel="modulepreload" crossorigin href="/assistant/assets/viewer-store-Dc5epEgj.js">
173
+ <link rel="modulepreload" crossorigin href="/assistant/assets/open-workspace-file-gzML_adc.js">
174
+ <link rel="modulepreload" crossorigin href="/assistant/assets/viewer-store-CDzOG6-y.js">
175
175
  <link rel="modulepreload" crossorigin href="/assistant/assets/pointer-CQ4DXHXb.js">
176
176
  <link rel="modulepreload" crossorigin href="/assistant/assets/sandbox-bridge-B5H4c27m.js">
177
177
  <link rel="modulepreload" crossorigin href="/assistant/assets/external-link-GPGZ1LGU.js">
178
178
  <link rel="modulepreload" crossorigin href="/assistant/assets/puzzle-4NgH5snP.js">
179
- <link rel="modulepreload" crossorigin href="/assistant/assets/app-card-ClwFu1LN.js">
179
+ <link rel="modulepreload" crossorigin href="/assistant/assets/app-card-BVXlnqNM.js">
180
180
  <link rel="modulepreload" crossorigin href="/assistant/assets/use-is-mobile-MmHo-OM6.js">
181
181
  <link rel="modulepreload" crossorigin href="/assistant/assets/conversation-store-CTMy9QPV.js">
182
182
  <link rel="modulepreload" crossorigin href="/assistant/assets/edit-chat-session-DVzLQLWl.js">
183
183
  <link rel="modulepreload" crossorigin href="/assistant/assets/chevron-up-DofScvyy.js">
184
184
  <link rel="modulepreload" crossorigin href="/assistant/assets/minimize-2-Dj9FY4aF.js">
185
185
  <link rel="modulepreload" crossorigin href="/assistant/assets/pencil-Cm5DdeRM.js">
186
- <link rel="modulepreload" crossorigin href="/assistant/assets/use-edit-app-3dKcJKAP.js">
186
+ <link rel="modulepreload" crossorigin href="/assistant/assets/use-edit-app-Dp4Gw1kj.js">
187
187
  <link rel="modulepreload" crossorigin href="/assistant/assets/avatar-svg-compositor-axSwKFvf.js">
188
188
  <link rel="modulepreload" crossorigin href="/assistant/assets/avatar-renderer-TpNgmnU1.js">
189
189
  <link rel="modulepreload" crossorigin href="/assistant/assets/proxy-DrtKRLtr.js">
@@ -228,14 +228,14 @@
228
228
  <link rel="modulepreload" crossorigin href="/assistant/assets/prechat-C4MZwKWX.js">
229
229
  <link rel="modulepreload" crossorigin href="/assistant/assets/browser-timezone-Br-HawKV.js">
230
230
  <link rel="modulepreload" crossorigin href="/assistant/assets/effective-timezone-BX46fWmk.js">
231
- <link rel="modulepreload" crossorigin href="/assistant/assets/messages-CW87Dtd_.js">
231
+ <link rel="modulepreload" crossorigin href="/assistant/assets/messages-S9VSjR8B.js">
232
232
  <link rel="modulepreload" crossorigin href="/assistant/assets/background-task-store-DpOSZFT8.js">
233
233
  <link rel="modulepreload" crossorigin href="/assistant/assets/file-markdown-B_8FkKff.js">
234
234
  <link rel="modulepreload" crossorigin href="/assistant/assets/pdf-preview-j8vnExmw.js">
235
235
  <link rel="modulepreload" crossorigin href="/assistant/assets/chevron-left-CrxnPze-.js">
236
236
  <link rel="modulepreload" crossorigin href="/assistant/assets/file-DOePafLU.js">
237
237
  <link rel="modulepreload" crossorigin href="/assistant/assets/use-attachment-preview-BoxwFwUx.js">
238
- <link rel="modulepreload" crossorigin href="/assistant/assets/use-transcript-messages-Bs3EjduJ.js">
238
+ <link rel="modulepreload" crossorigin href="/assistant/assets/use-transcript-messages-DjwHicXg.js">
239
239
  <link rel="modulepreload" crossorigin href="/assistant/assets/code-D6SOwRrI.js">
240
240
  <link rel="modulepreload" crossorigin href="/assistant/assets/acp-run-actions-zSUs8U3N.js">
241
241
  <link rel="modulepreload" crossorigin href="/assistant/assets/message-content-B6_GZQl9.js">
@@ -250,7 +250,7 @@
250
250
  <link rel="modulepreload" crossorigin href="/assistant/assets/circle-x-DTjJzoQl.js">
251
251
  <link rel="modulepreload" crossorigin href="/assistant/assets/file-plus-DjC7wnGp.js">
252
252
  <link rel="modulepreload" crossorigin href="/assistant/assets/terminal-BucMVaPU.js">
253
- <link rel="modulepreload" crossorigin href="/assistant/assets/transcript-message-body-shared-a-m7amCu.js">
253
+ <link rel="modulepreload" crossorigin href="/assistant/assets/transcript-message-body-shared-KhIrDX7O.js">
254
254
  <link rel="modulepreload" crossorigin href="/assistant/assets/archive-BQ3zdIPv.js">
255
255
  <link rel="modulepreload" crossorigin href="/assistant/assets/use-attachment-squares-DEkxhoxy.js">
256
256
  <link rel="modulepreload" crossorigin href="/assistant/assets/native-file-DuYDoSmQ.js">
@@ -260,13 +260,13 @@
260
260
  <link rel="modulepreload" crossorigin href="/assistant/assets/ellipsis-C5fQnusC.js">
261
261
  <link rel="modulepreload" crossorigin href="/assistant/assets/eye-off-DQ4xakzN.js">
262
262
  <link rel="modulepreload" crossorigin href="/assistant/assets/eye-B_jBDDRn.js">
263
- <link rel="modulepreload" crossorigin href="/assistant/assets/chat-markdown-message-CiJp6NwX.js">
263
+ <link rel="modulepreload" crossorigin href="/assistant/assets/chat-markdown-message-CUdfr2wG.js">
264
264
  <link rel="modulepreload" crossorigin href="/assistant/assets/preview-skeleton-Biw3dosM.js">
265
265
  <link rel="modulepreload" crossorigin href="/assistant/assets/surface-parse-helpers-iPHZ9D7N.js">
266
266
  <link rel="modulepreload" crossorigin href="/assistant/assets/workflow-status-D0bBEpGp.js">
267
267
  <link rel="modulepreload" crossorigin href="/assistant/assets/workflow-store-zCcRcvi8.js">
268
268
  <link rel="modulepreload" crossorigin href="/assistant/assets/conversation-selection-CJs3Fnse.js">
269
- <link rel="modulepreload" crossorigin href="/assistant/assets/conversation-navigation-Cx_JZlxF.js">
269
+ <link rel="modulepreload" crossorigin href="/assistant/assets/conversation-navigation-k0nLUcrV.js">
270
270
  <link rel="modulepreload" crossorigin href="/assistant/assets/use-subagent-card-data-MH8Ipd2J.js">
271
271
  <link rel="modulepreload" crossorigin href="/assistant/assets/assistant-feature-flag-store-Czv-BYTG.js">
272
272
  <link rel="modulepreload" crossorigin href="/assistant/assets/access-Bj1jggPa.js">
@@ -285,7 +285,7 @@
285
285
  <link rel="modulepreload" crossorigin href="/assistant/assets/invalidate-plugin-queries-B0OpJSUW.js">
286
286
  <link rel="modulepreload" crossorigin href="/assistant/assets/oauth-connection-utils-BrGz4Zc5.js">
287
287
  <link rel="modulepreload" crossorigin href="/assistant/assets/oauth-popup-DAMkjCsP.js">
288
- <link rel="modulepreload" crossorigin href="/assistant/assets/first-run-scope-BaNgebhs.js">
288
+ <link rel="modulepreload" crossorigin href="/assistant/assets/first-run-scope-C7NUo0oy.js">
289
289
  <link rel="modulepreload" crossorigin href="/assistant/assets/onboarding-layout-Q6fY5uKC.js">
290
290
  <link rel="modulepreload" crossorigin href="/assistant/assets/hard-navigate-BYoBFmE4.js">
291
291
  <link rel="modulepreload" crossorigin href="/assistant/assets/use-supports-bookmarks-DwTpI8uM.js">
@@ -324,6 +324,7 @@
324
324
  <link rel="modulepreload" crossorigin href="/assistant/assets/use-bundled-avatar-components-BcyasJwu.js">
325
325
  <link rel="modulepreload" crossorigin href="/assistant/assets/use-effective-timezone-BM5B7KHp.js">
326
326
  <link rel="modulepreload" crossorigin href="/assistant/assets/useInfiniteQuery-Dk8q0n49.js">
327
+ <link rel="modulepreload" crossorigin href="/assistant/assets/animate-piJqb5cQ.js">
327
328
  <link rel="modulepreload" crossorigin href="/assistant/assets/arrow-down-to-line-DMGjBlMw.js">
328
329
  <link rel="modulepreload" crossorigin href="/assistant/assets/arrow-right-ChqGeAaW.js">
329
330
  <link rel="modulepreload" crossorigin href="/assistant/assets/arrow-up-CWzHzcyU.js">
@@ -332,7 +333,6 @@
332
333
  <link rel="modulepreload" crossorigin href="/assistant/assets/cloud-q4J30bVb.js">
333
334
  <link rel="modulepreload" crossorigin href="/assistant/assets/coins-CcTuNVlN.js">
334
335
  <link rel="modulepreload" crossorigin href="/assistant/assets/target-CJU4DUFo.js">
335
- <link rel="modulepreload" crossorigin href="/assistant/assets/dices-C3diFTyP.js">
336
336
  <link rel="modulepreload" crossorigin href="/assistant/assets/file-code-CrtJR2ax.js">
337
337
  <link rel="modulepreload" crossorigin href="/assistant/assets/video-Dtwi0MD9.js">
338
338
  <link rel="modulepreload" crossorigin href="/assistant/assets/folder-_l8GIyQp.js">
@@ -349,9 +349,9 @@
349
349
  <link rel="modulepreload" crossorigin href="/assistant/assets/smartphone-CIrxb2NM.js">
350
350
  <link rel="modulepreload" crossorigin href="/assistant/assets/sun-BauGiwdK.js">
351
351
  <link rel="modulepreload" crossorigin href="/assistant/assets/workflow-Bsy5y3W0.js">
352
- <link rel="modulepreload" crossorigin href="/assistant/assets/routes-Flf73W7-.js">
352
+ <link rel="modulepreload" crossorigin href="/assistant/assets/routes-kaTsc8gq.js">
353
353
  <link rel="stylesheet" crossorigin href="/assistant/assets/src-CfUWwwYf.css">
354
- <link rel="stylesheet" crossorigin href="/assistant/assets/index-BSM1Vpxy.css">
354
+ <link rel="stylesheet" crossorigin href="/assistant/assets/index-C3w1NiEH.css">
355
355
  <script>window.__VELLUM_CONFIG__={"webUrl":"https://www.vellum.ai","platformUrl":"https://platform.vellum.ai"}</script></head>
356
356
  <body>
357
357
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/web",
3
- "version": "0.11.1-dev.202608041836.2a522b8",
3
+ "version": "0.11.1-dev.202608042001.feb8dd6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Pre-built web SPA for the Vellum Assistant",
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-CAM1RhH8.js";var t=e(`dices`,[[`rect`,{width:`12`,height:`12`,x:`2`,y:`10`,rx:`2`,ry:`2`,key:`6agr2n`}],[`path`,{d:`m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6`,key:`1o487t`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`M10 14h.01`,key:`ssrbsk`}],[`path`,{d:`M15 6h.01`,key:`cblpky`}],[`path`,{d:`M18 9h.01`,key:`2061c0`}]]);export{t};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n}from"./QueryClientProvider-CMu7CkQU.js";import{n as r}from"./toast-elfTwkN2.js";import{n as i,t as a}from"./create-selectors-BfxF8Sx_.js";import{r as o}from"./api-errors-BRGPPSWw.js";import{Q as s}from"./auth-store-s7Pi2EMi.js";import{In as c}from"./sdk.gen-CjtCuSlS.js";import{m as l}from"./native-biometric-DetUqtjl.js";import{d as u}from"./routes-DrfnNoYS.js";import{n as d,r as f}from"./browser-QH7RKn0h.js";import{Ot as p,b as m}from"./react-query.gen-BtYBixpk.js";import{A as h,B as g,C as _,D as v,E as y,F as b,H as x,I as S,L as C,M as w,N as T,O as E,P as D,R as O,S as k,U as A,_ as j,a as M,b as N,c as P,f as F,h as ee,i as te,j as ne,k as re,m as ie,o as ae,p as oe,s as se,v as ce,w as le,x as I,y as ue,z as de}from"./proxy-DrtKRLtr.js";import{a as fe,i as pe}from"./oauth-connection-utils-BrGz4Zc5.js";import{i as L,n as me,r as he,t as ge}from"./oauth-popup-DAMkjCsP.js";var _e=a(i(e=>({focused:!1,enterFocus:()=>e({focused:!0}),exitFocus:()=>e({focused:!1,pendingFollowupMessage:null,checkinPending:!1,sidebarCollapseRequested:!1}),pendingAvatarTraits:null,setPendingAvatarTraits:t=>e({pendingAvatarTraits:t}),pendingAvatarVoice:null,setPendingAvatarVoice:t=>e({pendingAvatarVoice:t}),pendingFollowupMessage:null,requestFollowup:t=>e({pendingFollowupMessage:t}),clearFollowup:()=>e({pendingFollowupMessage:null}),checkinPending:!1,checkinUserName:null,beginCheckin:t=>e({checkinPending:!0,checkinUserName:t??null}),endCheckin:()=>e({checkinPending:!1}),sidebarCollapseRequested:!1,requestSidebarCollapse:()=>e({sidebarCollapseRequested:!0}),consumeSidebarCollapse:()=>e({sidebarCollapseRequested:!1})}))),ve=(e,t,n)=>{let r=t-e;return((n-e)%r+r)%r+e};function R(e,t){return D(e)?e[ve(0,e.length,t)]:e}var ye=class{constructor(e){this.stop=()=>this.runAll(`stop`),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;n<this.animations.length;n++)this.animations[n][e]=t}attachTimeline(e){let t=this.animations.map(t=>t.attachTimeline(e));return()=>{t.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll(`time`)}set time(e){this.setAll(`time`,e)}get speed(){return this.getAll(`speed`)}set speed(e){this.setAll(`speed`,e)}get state(){return this.getAll(`state`)}get startTime(){return this.getAll(`startTime`)}get duration(){return z(this.animations,`duration`)}get iterationDuration(){return z(this.animations,`iterationDuration`)}runAll(e){this.animations.forEach(t=>t[e]())}play(){this.runAll(`play`)}pause(){this.runAll(`pause`)}cancel(){this.runAll(`cancel`)}complete(){this.runAll(`complete`)}};function z(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r][t];i!==null&&i>n&&(n=i)}return n}var be=class extends ye{then(e,t){return this.finished.finally(e).then(()=>{})}};function xe(...e){let t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],i=e[1+n],a=e[2+n],o=e[3+n],s=E(i,a,o);return t?s(r):s}function Se(e,t){return e in t}var Ce=class extends P{constructor(){super(...arguments),this.type=`object`}readValueFromInstance(e,t){if(Se(t,e)){let n=e[t];if(typeof n==`string`||typeof n==`number`)return n}}getBaseTargetFromProps(){}removeValueFromRenderState(e,t){delete t.output[e]}measureInstanceViewportBox(){return oe()}build(e,t){Object.assign(e.output,t)}renderInstance(e,{output:t}){Object.assign(e,t)}sortInstanceNodePosition(){return 0}},B=e(t(),1);function V(e){let t=A(()=>_(e)),{isStatic:n}=(0,B.useContext)(te);if(n){let[,n]=(0,B.useState)(e);(0,B.useEffect)(()=>t.on(`change`,n),[])}return t}function H(e,t){let n=V(t()),r=()=>n.set(t());return r(),x(()=>{let t=()=>T.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return()=>{n.forEach(e=>e()),w(r)}}),n}function we(e){k.current=[],e();let t=H(k.current,e);return k.current=void 0,t}function U(e,t,n,r){if(typeof e==`function`)return we(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return Te(e,t,n,r);let i=typeof t==`function`?t:xe(t,n,r),a=Array.isArray(e)?W(e,i):W([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;return o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1&&(a.accelerate={...o,times:t,keyframes:n,isTransformed:!0,...r?.ease?{ease:r.ease}:{}}),a}function W(e,t){let n=A(()=>[]);return H(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function Te(e,t,n,r){let i=A(()=>Object.keys(n)),a=A(()=>({}));for(let o of i)a[o]=U(e,t,n[o],r);return a}function Ee(e){e.values.forEach(e=>e.stop())}function G(e,t){[...t].reverse().forEach(n=>{let r=e.getVariant(n);r&&I(e,r),e.variantChildren&&e.variantChildren.forEach(e=>{G(e,t)})})}function De(e,t){if(Array.isArray(t))return G(e,t);if(typeof t==`string`)return G(e,[t]);I(e,t)}function Oe(){let e=!1,t=new Set,n={subscribe(e){return t.add(e),()=>void t.delete(e)},start(n,r){O(e,`controls.start() should only be called after a component has mounted. Consider calling within a useEffect hook.`);let i=[];return t.forEach(e=>{i.push(ce(e,n,{transitionOverride:r}))}),Promise.all(i)},set(n){return O(e,`controls.set() should only be called after a component has mounted. Consider calling within a useEffect hook.`),t.forEach(e=>{De(e,n)})},stop(){t.forEach(e=>{Ee(e)})},mount(){return e=!0,()=>{e=!1,n.stop()}}};return n}function K(e){return typeof e==`object`&&!Array.isArray(e)}function q(e,t,n,r){return e==null?[]:typeof e==`string`&&K(t)?j(e,n,r):e instanceof NodeList?Array.from(e):Array.isArray(e)?e.filter(e=>e!=null):[e]}function ke(e,t,n){return e*(t+1)+n*t}function J(e,t,n,r){return typeof t==`number`?t:t.startsWith(`-`)||t.startsWith(`+`)?Math.max(0,e+parseFloat(t)):t===`<`?n:t.startsWith(`<`)?Math.max(0,n+parseFloat(t.slice(1))):r.get(t)??e}function Ae(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];i.at>t&&i.at<n&&(g(e,i),r--)}}function je(e,t,n,r,i,a){Ae(e,i,a);for(let o=0;o<t.length;o++)e.push({value:t[o],at:ne(i,a,r[o]),easing:R(n,o)})}function Me(e,t,n=0){let r=t+1+t*n;for(let t=0;t<e.length;t++)e[t]=e[t]/r}function Ne(e,t){return e.at===t.at?e.value===null?1:t.value===null?-1:0:e.at-t.at}var Pe=`easeInOut`,Y=20;function Fe(e,{defaultTransition:t={},...n}={},r,i){let a=t.duration||.3,o=new Map,s=new Map,c={},l=new Map,u=0,d=0,f=0;for(let n=0;n<e.length;n++){let o=e[n];if(typeof o==`string`){l.set(o,d);continue}else if(!Array.isArray(o)){l.set(o.name,J(d,o.at,u,l));continue}let[p,m,g={}]=o;g.at!==void 0&&(d=J(d,g.at,u,l));let _=0,x=(e,n,r,o=0,s=0)=>{let c=Ie(e),{delay:l=0,times:u=y(c),type:p=t.type||`keyframes`,repeat:m,repeatType:g,repeatDelay:x=0,...C}=n,{ease:w=t.ease||`easeOut`,duration:T}=n,E=typeof l==`function`?l(o,s):l,D=c.length,O=le(p)?p:i?.[p||`keyframes`];if(D<=2&&O){let e=100;if(D===2&&ze(c)){let t=c[1]-c[0];e=Math.abs(t)}let n={...t,...C};T!==void 0&&(n.duration=S(T));let r=h(n,e,O);w=r.ease,T=r.duration}T??=a;let k=d+E;u.length===1&&u[0]===0&&(u[1]=1);let A=u.length-c.length;if(A>0&&v(u,A),c.length===1&&c.unshift(null),m&&de(m<Y,`Sequence segments can't repeat ${m} times — ignoring repeat option. Use a value below ${Y} or apply repeat at the sequence level instead.`),m&&m<Y){let e=T>0?x/T:0;T=ke(T,m,x);let t=[...c],n=[...u];w=Array.isArray(w)?[...w]:[w];let r=[...w],i=g===`reverse`||g===`mirror`,a=t,o=r;i&&(a=[...t].reverse(),g===`reverse`&&(o=[...r].reverse().map(e=>typeof e==`function`?b(e):e)));for(let s=0;s<m;s++){let l=i&&s%2==0,d=l?a:t,f=l?o:r,p=(s+1)*(1+e);e>0&&(c.push(c[c.length-1]),u.push(p),w.push(`linear`)),c.push(...d);for(let e=0;e<d.length;e++)u.push(n[e]+p),w.push(e===0?`linear`:R(f,e-1))}Me(u,m,e)}let j=k+T;je(r,c,w,u,k,j),_=Math.max(E+T,_),f=Math.max(j,f)};if(N(p)){let e=X(p,s);x(m,g,Z(`default`,e))}else{let e=q(p,m,r,c),t=e.length;for(let n=0;n<t;n++){m=m,g=g;let r=e[n],i=X(r,s);for(let e in m)x(m[e],Le(g,e),Z(e,i),n,t)}}u=d,d+=_}return s.forEach((e,r)=>{for(let i in e){let a=e[i];a.sort(Ne);let s=[],c=[],l=[];for(let e=0;e<a.length;e++){let{at:t,value:n,easing:r}=a[e];s.push(n),c.push(C(0,f,t)),l.push(r||`easeOut`)}c[0]!==0&&(c.unshift(0),s.unshift(s[0]),l.unshift(Pe)),c[c.length-1]!==1&&(c.push(1),s.push(null)),o.has(r)||o.set(r,{keyframes:{},transition:{}});let u=o.get(r);u.keyframes[i]=s;let{type:d,...p}=t;u.transition[i]={...p,duration:f,ease:l,times:c,...n}}}),o}function X(e,t){return!t.has(e)&&t.set(e,{}),t.get(e)}function Z(e,t){return t[e]||(t[e]=[]),t[e]}function Ie(e){return Array.isArray(e)?e:[e]}function Le(e,t){return e&&e[t]?{...e,...e[t]}:{...e}}var Re=e=>typeof e==`number`,ze=e=>e.every(Re);function Be(e){let t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=ee(e)&&!ie(e)?new ae(t):new se(t);n.mount(e),F.set(e,n)}function Ve(e){let t=new Ce({presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}});t.mount(e),F.set(e,t)}function He(e,t){return N(e)||typeof e==`number`||typeof e==`string`&&!K(t)}function Q(e,t,n,r){let i=[];if(He(e,t))i.push(M(e,K(t)&&t.default||t,n&&(n.default||n)));else{if(e==null)return i;let a=q(e,t,r),o=a.length;O(!!o,`No valid elements provided.`,`no-valid-elements`);for(let e=0;e<o;e++){let r=a[e],s=r instanceof Element?Be:Ve;F.has(r)||s(r);let c=F.get(r),l={...n};`delay`in l&&typeof l.delay==`function`&&(l.delay=l.delay(e,o)),i.push(...ue(c,{...t,transition:l},{}))}}return i}function Ue(e,t,n){let r=[];return Fe(e.map(e=>{if(Array.isArray(e)&&typeof e[0]==`function`){let t=e[0],n=_(0);return n.on(`change`,t),e.length===1?[n,[0,1]]:e.length===2?[n,[0,1],e[1]]:[n,e[1],e[2]]}return e}),t,n,{spring:re}).forEach(({keyframes:e,transition:t},n)=>{r.push(...Q(n,e,t))}),r}function We(e){return Array.isArray(e)&&e.some(Array.isArray)}function Ge(e={}){let{scope:t,reduceMotion:n,skipAnimations:r}=e;function i(e,i,a){let o=[],s,c={};if(n!==void 0&&(c.reduceMotion=n),r!==void 0&&(c.skipAnimations=r),We(e)){let{onComplete:n,...r}=i||{};typeof n==`function`&&(s=n),o=Ue(e,{...c,...r},t)}else{let{onComplete:n,...r}=a||{};typeof n==`function`&&(s=n),o=Q(e,i,{...c,...r},t)}let l=new be(o);return s&&l.finished.then(s),t&&(t.animations.push(l),l.finished.then(()=>{g(t.animations,l)})),l}return i}var Ke=Ge();function qe(){let e=A(Oe);return x(e.mount,[]),e}async function Je({assistantId:e,userName:t,assistantName:n}){try{let r;try{r=Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{r=void 0}let i=await c({path:{assistant_id:e},body:{userName:t?.trim()||void 0,assistantName:n?.trim()||void 0,timezone:r},throwOnError:!1});return i.response?.ok===!0&&i.data?.scheduled===!0?{scheduled:!0,start:i.data?.start,timeZone:i.data?.timeZone}:{scheduled:!1}}catch{return{scheduled:!1}}}var $=`google`,Ye=8,Xe=750,Ze=`https://www.googleapis.com/auth/calendar.events`,Qe=[`openid`,`https://www.googleapis.com/auth/userinfo.email`,Ze];function $e({assistantId:e,requestedScopes:t=Qe,onConnect:i}){let a=n(),c=l(),h=(0,B.useRef)(null),g=(0,B.useRef)(null),_=(0,B.useRef)(null),v=(0,B.useRef)(null),y=(0,B.useRef)(null),b=(0,B.useRef)(null),x=(0,B.useRef)(null),S=(0,B.useRef)(null),[C,w]=(0,B.useState)(!1),T=(0,B.useCallback)(()=>{g.current=null,w(!1)},[]),E=(0,B.useCallback)(()=>{b.current&&=(window.removeEventListener(`message`,b.current),null),x.current&&=(window.removeEventListener(`storage`,x.current),null)},[]),D=(0,B.useCallback)(()=>{h.current&&!h.current.closed&&h.current.close(),h.current=null,v.current&&=(clearInterval(v.current),null),y.current&&=(clearTimeout(y.current),null)},[]),O=p();(0,B.useEffect)(()=>()=>{v.current&&clearInterval(v.current),y.current&&clearTimeout(y.current),h.current&&!h.current.closed&&h.current.close(),b.current&&window.removeEventListener(`message`,b.current),x.current&&window.removeEventListener(`storage`,x.current),S.current&&=(S.current(),null)},[]);let k=(0,B.useCallback)(async()=>{try{let t=_.current??e;return(await a.fetchQuery({...m({path:{assistant_id:t}}),staleTime:0})).find(e=>e.provider===$&&e.connected)??null}catch{return null}},[e,a]),A=(0,B.useCallback)(async()=>{for(let e=0;e<Ye;e+=1){e>0&&await pe(Xe);let t=await k();if(t)return t}return null},[k]),j=(0,B.useCallback)(async()=>{D(),T(),i((await k())?.scopes_granted??[])},[T,D,k,i]),M=(0,B.useCallback)(e=>{e.type===`vellum:oauth-complete`&&(!g.current||e.requestId!==g.current.requestId||(e.oauthStatus===`connected`?j():(D(),T())))},[T,D,j]),N=(0,B.useCallback)(e=>{let t=g.current;if(!t)return;let n=ge(e,window.location.origin,t.requestId);n&&M(n)},[M]),P=(0,B.useCallback)(e=>{let t=g.current;if(!t)return;let n=me(e,t.requestId);n&&(M(n),window.localStorage.removeItem(L(t.requestId)))},[M]);return fe((0,B.useCallback)(e=>{let t=g.current;t&&e.requestId===t.requestId&&M({type:`vellum:oauth-complete`,requestId:e.requestId,oauthStatus:e.oauthStatus,oauthProvider:e.oauthProvider,oauthCode:e.oauthCode})},[M])),{handleConnect:(0,B.useCallback)(()=>{let n=crypto.randomUUID();E(),b.current=N,x.current=P;let i=async(i,a)=>{let c;try{c=await s(e)}catch(e){a(),r.error(e instanceof Error?e.message:`Failed to start Google Calendar authorization.`);return}_.current=c,O.mutate({path:{assistant_id:c,provider:$},body:{requested_scopes:t,redirect_after_connect:`${u.account.oauth.popupComplete}?requestId=${n}${i?``:`&native=1`}`}},{onSuccess(e){if(!i){d(e.connect_url);return}i.closed?g.current&&a():i.location.href=e.connect_url},onError(e){a(),r.error(o(e,void 0,`Failed to start Google Calendar authorization.`))}})};if(c){w(!0),g.current={requestId:n},i(null,()=>{T(),E()}),window.addEventListener(`message`,N),window.addEventListener(`storage`,P),S.current&&S.current();let e=f(()=>{if(!g.current){e(),S.current=null;return}(async()=>{let t=await A();g.current&&(t?await j():T(),E(),e(),S.current=null)})()});S.current=e;return}let a=window.open(``,`_blank`,`width=500,height=600`);if(a===null){E();return}h.current=a,w(!0),g.current={requestId:n},window.addEventListener(`message`,N),window.addEventListener(`storage`,P),v.current=setInterval(()=>{h.current&&h.current.closed&&g.current&&!y.current&&(y.current=setTimeout(async()=>{y.current=null;let e=g.current;if(!e)return;let t=window.localStorage.getItem(L(e.requestId));if(t)try{let n=JSON.parse(t);if(he(n,e.requestId)){M(n),window.localStorage.removeItem(L(e.requestId)),E();return}}catch{}let n=await A();g.current&&(n?await j():(D(),T()),E())},1e3))},100),i(a,()=>{D(),T(),E()})},[e,T,D,M,N,P,j,c,E,t,O,A]),oauthInProgress:C||O.isPending}}var et=`firstRunScope`,tt=[`work`,`personal`,`both`];function nt(e){return tt.includes(e)}export{Je as a,U as c,$e as i,V as l,nt as n,qe as o,Ze as r,Ke as s,et as t,_e as u};
@@ -1,7 +0,0 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-fyWSnR9X.js";import{t as r}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as i}from"./QueryClientProvider-CMu7CkQU.js";import{t as a}from"./useQuery-Bz-fbQ-m.js";import{t as o}from"./jsx-runtime-D3ZM-ToX.js";import{t as s}from"./card-DRIctGVs.js";import{t as c}from"./createLucideIcon-CAM1RhH8.js";import{t as l}from"./brain-CN4zzNgU.js";import{n as u,t as d}from"./upload-DsWG9TbD.js";import{t as f}from"./chevron-left-CrxnPze-.js";import{t as p}from"./chevron-right-CANAtgGn.js";import"./src-Co3nj9N_.js";import{t as m}from"./dices-C3diFTyP.js";import{t as h}from"./folder-open-BTlvhHNO.js";import{t as g}from"./layout-grid-Ct4RT2Ea.js";import{t as _}from"./pencil-Cm5DdeRM.js";import{t as v}from"./sparkles-DfEFn3Bh.js";import{t as y}from"./users-OcC3p9Jn.js";import{n as b,t as x}from"./installed-plugins-query-3ACToZeY.js";import{t as S}from"./modal-D5t4FWFB.js";import{n as C}from"./toast-elfTwkN2.js";import{t as w}from"./assistant-identity-store-B51BX78j.js";import{d as T,r as E}from"./routes-DrfnNoYS.js";import{a as ee,n as D,o as O,r as te}from"./use-assistant-avatar-Bjqx8JUy.js";import{E as k,_t as A,b as j,fn as M,o as N,t as P,wt as ne}from"./react-query.gen-C7om930f.js";import{n as F,t as I}from"./get-memory-stats-BnRGtUPT.js";import{t as L}from"./plugins-surface-C_pFzsVo.js";import{t as R}from"./proxy-DrtKRLtr.js";import{t as z}from"./use-reduced-motion-fR0m_opJ.js";import{r as B}from"./avatar-tone-D99t9DAP.js";import{n as V,t as H}from"./eye-bbox-CRs175_n.js";import{t as re}from"./chat-avatar-B5fx9Xm3.js";import{t as ie}from"./avatar-renderer-TpNgmnU1.js";import{t as ae}from"./use-active-assistant-id-BK7MNTh-.js";import{t as oe}from"./page-shell-BUZg56AQ.js";import{a as U,o as W,r as G,s as se}from"./latest-assistant-text-yzZ5l9Cu.js";import{a as K,n as ce,r as le,s as ue,t as de}from"./use-assistant-identity-details-B90DC4R-.js";import{t as fe}from"./schedules-BcyU9gXh.js";var pe=c(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),q=e(t(),1),J=o();function Y(e,t,n){return n===`forward`?(e+1)%t:(e-1+t)%t}function me({open:e,onClose:t,assistantId:r,components:i,traits:a,customImageUrl:o,onSaveCharacter:s,onUploadImage:c,assistantName:l,onRenameSubmit:u,isRenaming:f=!1}){let p=(0,q.useRef)(null),[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(!1),y=i??h,[b,x]=(0,q.useState)(0),[C,w]=(0,q.useState)(0),[T,E]=(0,q.useState)(0),[D,k]=(0,q.useState)(`character`),[A,j]=(0,q.useState)(null),[M,N]=(0,q.useState)(!1),[P,ne]=(0,q.useState)(!1),[F,I]=(0,q.useState)(l??``),L=A??o,R=!!L;(0,q.useEffect)(()=>{e&&I(l??``)},[e,l]);let z=(0,q.useRef)(!1);(0,q.useEffect)(()=>{e&&!z.current&&k(o?`custom`:`character`),z.current=e},[e,o]),(0,q.useEffect)(()=>{if(e)if(y&&a){let e=y.bodyShapes.findIndex(e=>e.id===a.bodyShape),t=y.eyeStyles.findIndex(e=>e.id===a.eyeStyle),n=y.colors.findIndex(e=>e.id===a.color);x(e>=0?e:0),w(t>=0?t:0),E(n>=0?n:0)}else x(0),w(0),E(0)},[e,y,a]),(0,q.useEffect)(()=>{if(!e||y||_)return;let t=!1;return v(!0),te(r).then(e=>{t||(g(e),v(!1))}),()=>{t=!0}},[e,y,_,r]),(0,q.useEffect)(()=>{if(A)return()=>{URL.revokeObjectURL(A)}},[A]),(0,q.useEffect)(()=>{e||j(null)},[e]);let B=F.trim(),V=!!u&&B.length>0&&B!==(l??``),H=(0,q.useCallback)(()=>{y&&(k(`character`),x(Math.floor(Math.random()*y.bodyShapes.length)),w(Math.floor(Math.random()*y.eyeStyles.length)),E(Math.floor(Math.random()*y.colors.length)))},[y]),re=(0,q.useCallback)(()=>{p.current?.click()},[]),ae=(0,q.useCallback)(async e=>{let t=e.target.files?.[0];if(!t)return;ne(!0);let n=await O(r,t);ne(!1),n&&(c(),j(URL.createObjectURL(t)),k(`custom`)),p.current&&(p.current.value=``)},[r,c]),oe=(0,q.useCallback)(async e=>{if(e.preventDefault(),!(M||f)){if(V&&u&&u(B),y&&D===`character`){let e={bodyShape:y.bodyShapes[b].id,eyeStyle:y.eyeStyles[C].id,color:y.colors[T].id};N(!0);try{await ee(r,e),j(null),s(e)}finally{N(!1)}}t()}},[M,f,V,u,B,y,D,b,C,T,r,s,t]),U=y?.bodyShapes[b],W=y?.eyeStyles[C],G=y?.colors[T],se=D===`custom`&&R,K=l!==void 0&&u?(0,J.jsx)(he,{value:F,onChange:I,disabled:f}):null;return(0,J.jsx)(S.Root,{open:e,onOpenChange:e=>!e&&t(),children:(0,J.jsxs)(S.Content,{size:`sm`,children:[(0,J.jsx)(S.Header,{children:(0,J.jsx)(S.Title,{children:`Update Avatar`})}),(0,J.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:oe,children:[(0,J.jsx)(S.Body,{className:`space-y-4`,children:se?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`flex justify-center`,children:(0,J.jsx)(`div`,{className:`rounded-2xl bg-[var(--surface-sunken)] p-6`,children:(0,J.jsx)(`img`,{src:L,alt:`Uploaded avatar`,className:`h-40 w-40 rounded-xl object-cover`})})}),(0,J.jsxs)(`div`,{className:`space-y-3`,children:[K,(0,J.jsx)(ge,{label:`Use a character instead`,description:`Pick from our built-in avatars`,onClick:()=>k(`character`),thumbnail:y&&U&&W&&G?(0,J.jsx)(ie,{components:y,bodyShapeId:U.id,eyeStyleId:W.id,colorId:G.id,size:32}):(0,J.jsx)(m,{className:`h-4 w-4`,style:{color:`var(--content-secondary)`}})})]})]}):y?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`flex justify-center`,children:(0,J.jsx)(`div`,{className:`rounded-2xl bg-[var(--surface-sunken)] p-6`,children:(0,J.jsx)(ie,{components:y,bodyShapeId:U.id,eyeStyleId:W.id,colorId:G.id,size:160})})}),(0,J.jsxs)(`div`,{className:`space-y-3`,children:[K,(0,J.jsx)(_e,{label:`Body`,value:U.id,onPrev:()=>x(Y(b,y.bodyShapes.length,`backward`)),onNext:()=>x(Y(b,y.bodyShapes.length,`forward`))}),(0,J.jsx)(_e,{label:`Eyes`,value:W.id,onPrev:()=>w(Y(C,y.eyeStyles.length,`backward`)),onNext:()=>w(Y(C,y.eyeStyles.length,`forward`))}),(0,J.jsx)(_e,{label:`Color`,value:G.id,colorHex:G.hex,onPrev:()=>E(Y(T,y.colors.length,`backward`)),onNext:()=>E(Y(T,y.colors.length,`forward`))})]}),R&&(0,J.jsx)(ge,{label:`Keep your uploaded image`,description:`Saving the character replaces it`,onClick:()=>k(`custom`),thumbnail:(0,J.jsx)(`img`,{src:L,alt:``,className:`h-8 w-8 rounded-md object-cover`})})]}):(0,J.jsxs)(J.Fragment,{children:[K,_?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,J.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--border-element)] border-t-[var(--content-tertiary)]`})}):(0,J.jsx)(`div`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-quiet)]`,children:`Unable to load avatar components. Make sure your assistant is running.`})]})}),(0,J.jsxs)(S.Footer,{className:`justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(n,{type:`button`,variant:`outlined`,iconOnly:(0,J.jsx)(m,{}),"aria-label":`Randomize`,tooltip:`Randomize`,onClick:H,disabled:!y}),(0,J.jsx)(n,{type:`button`,variant:`outlined`,iconOnly:(0,J.jsx)(d,{}),"aria-label":`Upload image`,tooltip:`Upload image`,onClick:re,disabled:P})]}),(0,J.jsx)(n,{type:`submit`,variant:`primary`,disabled:M||f||P,children:M||f?`Saving…`:`Save`})]})]}),(0,J.jsx)(`input`,{ref:p,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif`,className:`hidden`,onChange:ae})]})})}function he({value:e,onChange:t,disabled:n}){return(0,J.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-lift)] px-3 py-2`,children:[(0,J.jsx)(`span`,{className:`text-body-small-default uppercase tracking-wider text-[var(--content-quiet)]`,children:`Name`}),(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`flex min-w-[80px] items-center justify-center`,children:(0,J.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),disabled:n,maxLength:40,size:8,placeholder:`Name`,"aria-label":`Name`,className:`h-7 min-w-0 field-sizing-content bg-transparent text-center text-body-medium-default text-[var(--content-strong)] outline-none placeholder:text-[var(--content-tertiary)] disabled:cursor-not-allowed disabled:opacity-60`})}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`h-7 w-7 shrink-0`})]})]})}function ge({label:e,description:t,thumbnail:n,onClick:r}){return(0,J.jsxs)(`button`,{type:`button`,onClick:r,className:`flex w-full cursor-pointer items-center gap-3 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-lift)] px-3 py-2 text-left transition-colors hover:bg-[var(--surface-hover)]`,children:[(0,J.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-md bg-[var(--surface-sunken)]`,children:n}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block truncate text-body-medium-default text-[var(--content-strong)]`,children:e}),(0,J.jsx)(`span`,{className:`block truncate text-body-small-default text-[var(--content-quiet)]`,children:t})]}),(0,J.jsx)(p,{className:`h-4 w-4 shrink-0 text-[var(--content-quiet)]`})]})}function _e({label:e,value:t,colorHex:n,onPrev:r,onNext:i}){return(0,J.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-lift)] px-3 py-2`,children:[(0,J.jsx)(`span`,{className:`text-body-small-default uppercase tracking-wider text-[var(--content-quiet)]`,children:e}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Previous ${e.toLowerCase()}`,className:`flex h-7 w-7 cursor-pointer items-center justify-center rounded-md text-[var(--content-quiet)] transition-colors hover:bg-[var(--surface-active)]`,children:(0,J.jsx)(f,{className:`h-4 w-4`})}),(0,J.jsxs)(`div`,{className:`flex min-w-[80px] items-center justify-center gap-2`,children:[n&&(0,J.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-[var(--border-element)]`,style:{backgroundColor:n}}),(0,J.jsx)(`span`,{className:`text-body-medium-default capitalize text-[var(--content-strong)]`,children:t})]}),(0,J.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Next ${e.toLowerCase()}`,className:`flex h-7 w-7 cursor-pointer items-center justify-center rounded-md text-[var(--content-quiet)] transition-colors hover:bg-[var(--surface-active)]`,children:(0,J.jsx)(p,{className:`h-4 w-4`})})]})]})}function ve(e){let t=e.trim();return`<system-message>
2
- The user renamed you: your name is now ${t}.
3
-
4
- Update IDENTITY.md so its name line reads exactly \`- **Name:** ${t}\`. This is a rename only — keep everything else in IDENTITY.md and SOUL.md exactly as it is, and do not touch users/ (that is your user's profile, not your identity). If your name appears elsewhere in those files, update those mentions to ${t} too.
5
-
6
- Reply with a single short sentence acknowledging your new name.
7
- </system-message>`}async function ye(e,t){return le({assistantId:e,content:ve(t),title:`Updating name`,context:`identity_overview_rename`})}var be=6e4,xe=3;function X(e,t,n){return e===1?t:n}function Se(e,{supportsPlugins:t}){let n={assistant_id:e},r={staleTime:be,retry:!1,enabled:!0},i=a({...ne({path:n,query:{kind:`installed`}}),select:e=>e.skills.length,...r}),o=a({...x(e),select:e=>e.plugins.length,enabled:t}),s=a({...P({path:n}),select:e=>e.apps.length,...r}),c=a({...k({path:n}),select:e=>e.documents.length,...r}),l=a({...M({path:n}),select:e=>e.entries.length,...r}),u=a({...j({path:n}),select:e=>e.contacts.length,...r}),d=a({...N({path:n}),select:e=>e.snapshots.filter(e=>e.ready).length,...r}),f=a({queryKey:A({path:n}),queryFn:()=>fe(e),select:e=>{let t=e.filter(e=>e.enabled).sort((e,t)=>e.nextRunAt-t.nextRunAt);return{count:t.length,items:t.slice(0,xe).map(e=>({id:e.id,name:e.name,cadence:e.cadenceDescription,nextRunAt:e.nextRunAt}))}},...r}),p=a({queryKey:se(e),queryFn:()=>W(e),...r});return{personality:{radar:p.data===void 0?void 0:U(p.data??{})},superpowers:i.data===void 0?void 0:{text:[`${i.data} ${X(i.data,`skill`,`skills`)}`,...o.data===void 0?[]:[`${o.data} ${X(o.data,`plugin`,`plugins`)}`]].join(` · `)},library:s.data===void 0?void 0:{text:[`${s.data} ${X(s.data,`app`,`apps`)}`,...c.data===void 0?[]:[`${c.data} ${X(c.data,`doc`,`docs`)}`]].join(` · `)},workspace:l.data===void 0?void 0:{value:l.data,label:X(l.data,`item`,`items`)},contacts:u.data===void 0?void 0:{value:u.data,label:X(u.data,`person`,`people`)},channels:d.data===void 0?void 0:{value:d.data,label:`connected`},schedules:f.data===void 0?void 0:f.data.count===0?{text:`Nothing scheduled yet`}:{value:f.data.count,label:`active`,schedules:{items:f.data.items,more:f.data.count-f.data.items.length}}}}var Ce=96,we=150,Te=36,Ee=46,De=58,Oe=(e,t,n)=>Math.max(t,Math.min(n,e));function ke(e,t,n){let r=Oe(n.x-e.left,Ce,e.width-Ce),i=Oe(n.y-e.top,Ce,e.height-Ce);return{rect:e,facing:t,peek:t===`top`?{x:r,y:0}:t===`bottom`?{x:r,y:e.height}:t===`left`?{x:0,y:i}:{x:e.width,y:i}}}var Ae={top:{x:0,y:-1},bottom:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0}},je={type:`spring`,stiffness:150,damping:19},Me=.22,Ne=.15;function Pe({hex:e,components:t,traits:n,target:r}){let i=r!==null,[a,o]=(0,q.useState)(null);r&&r!==a&&o(r);let s=r??a,[c,l]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let e=!1,t,n=()=>{t=setTimeout(()=>{e||(l(!0),t=setTimeout(()=>{e||(l(!1),n())},140))},2500+Math.random()*4e3)};return n(),()=>{e=!0,clearTimeout(t)}},[]);let u=(0,q.useMemo)(()=>{let e=t.eyeStyles.find(e=>e.id===n.eyeStyle);return e?{paths:e.paths,bbox:V(e.paths.map(e=>H(e.svgPath)))}:null},[t,n.eyeStyle]);if(!u||!s)return null;let{rect:d,facing:f,peek:p}=s,m={x:d.left+p.x,y:d.top+p.y},h=Ae[f],g=u.bbox.h/u.bbox.w,_=De,v=_*g,y={x:m.x+h.x*Te,y:m.y+h.y*Te},b={x:-h.x*Ee,y:-h.y*Ee},x=u.bbox.x+u.bbox.w/2,S=u.bbox.y+u.bbox.h/2,C=i?{...je,delay:Me,opacity:{duration:.15,delay:Me}}:{duration:Ne};return(0,J.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-0`,children:[(0,J.jsx)(R.div,{className:`absolute top-0 left-0 rounded-full`,style:{backgroundColor:e,width:we,height:we},initial:!1,animate:{x:m.x-we/2+(i?0:b.x),y:m.y-we/2+(i?0:b.y),opacity:+!!i},transition:C}),(0,J.jsx)(R.div,{className:`absolute top-0 left-0`,initial:!1,animate:{x:y.x-_/2+(i?0:b.x),y:y.y-v/2+(i?0:b.y),width:_,height:v,opacity:+!!i},transition:C,children:(0,J.jsx)(`svg`,{viewBox:`${u.bbox.x} ${u.bbox.y} ${u.bbox.w} ${u.bbox.h}`,width:`100%`,height:`100%`,preserveAspectRatio:`xMidYMid meet`,style:{overflow:`visible`,display:`block`},children:(0,J.jsx)(`g`,{style:{transform:c?`scaleY(0.1)`:`scaleY(1)`,transformOrigin:`${x}px ${S}px`,transition:`transform 0.14s ease-in-out`},children:u.paths.map((e,t)=>(0,J.jsx)(`path`,{d:e.svgPath,fill:e.color},t))})})})]})}var Fe=65,Ie=26;function Le(e,t){let n=z(),[r,i]=(0,q.useState)(n?e.length:0);return(0,q.useEffect)(()=>{if(n){i(e.length);return}i(0);let r=setInterval(()=>{i(t=>t>=e.length?(clearInterval(r),t):t+1)},t);return()=>clearInterval(r)},[e,t,n]),{typed:e.slice(0,r),typing:r<e.length}}function Re({name:e,isRenaming:t,overrideText:n=null}){let r=n??`Hi, I’m ${e}`,{typed:i,typing:a}=Le(r,n?Ie:Fe);return(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,J.jsxs)(`h1`,{"aria-label":r,className:`relative leading-none whitespace-nowrap text-[var(--content-strong)] ${n?`text-[2.1rem] max-sm:text-[1.4rem]`:`text-[3.25rem] max-sm:text-[2rem]`}`,style:{fontFamily:`var(--font-serif)`},children:[(0,J.jsx)(`span`,{className:`invisible`,"aria-hidden":`true`,children:r}),(0,J.jsxs)(`span`,{className:`absolute inset-0`,"aria-hidden":`true`,children:[i,a&&(0,J.jsx)(`span`,{className:`animate-pulse`,children:`▎`})]})]}),!n&&t&&(0,J.jsx)(`div`,{"aria-label":`Renaming in progress`,className:`h-5 w-5 shrink-0 animate-spin rounded-full border-2 border-[var(--border-base)]`,style:{borderTopColor:`var(--content-default)`}})]})}function Z(e,t){let{label:n,to:r}=E(e);return{key:e,label:n,description:t,to:r}}function ze(){return[{key:`personality`,label:`Personality`,description:`Tune how I talk`,to:T.personality},Z(`schedules`,`My routines`),Z(`superpowers`,`What I can do`),Z(`memory`,`What I remember`),Z(`library`,`My apps & docs`),Z(`workspace`,`My files`),Z(`contacts`,`People I know`),Z(`channels`,`Where I listen`)]}var Q=[{label:`Coworker`,sub:`vs. companion`,value:e=>$(e,`companion-coworker`)},{label:`Baby Boomer`,sub:`vs. Gen Z`,value:e=>$(e,`genz-boomer`)},{label:`Collaborative`,sub:`vs. independent`,value:e=>$(e,`execute-collaborate`)},{label:`Serious`,sub:`vs. playful`,value:e=>$(e,`playful-serious`)},{label:`Unfiltered`,sub:`vs. polite`,value:e=>$(e,`polite-unfiltered`)}];function $(e,t){let n=e[t]??K;return Math.max(0,Math.min(100,n))}var Be=356,Ve=246,He=Be/2,Ue=132,We=100,Ge=.1,Ke=[.25,.5,.75,1],qe=[{anchor:`middle`,dx:0,dy:-18},{anchor:`start`,dx:9,dy:-2},{anchor:`start`,dx:-10,dy:17},{anchor:`end`,dx:10,dy:17},{anchor:`end`,dx:-9,dy:-2}];function Je(e,t){let n=-Math.PI/2+e*2*Math.PI/Q.length;return{x:He+t*Math.cos(n),y:Ue+t*Math.sin(n)}}function Ye(e){return Q.map((t,n)=>{let r=Je(n,e(n));return`${r.x.toFixed(1)},${r.y.toFixed(1)}`}).join(` `)}function Xe({values:e,className:t}){let n=Q.map(t=>`${t.label} ${Math.round(t.value(e))}`).join(`, `);return(0,J.jsxs)(`svg`,{viewBox:`0 0 ${Be} ${Ve}`,role:`img`,"aria-label":`Personality: ${n}`,className:t,children:[Ke.map(e=>(0,J.jsx)(`polygon`,{points:Ye(()=>We*e),fill:`none`,stroke:`currentColor`,strokeOpacity:.25,strokeWidth:1,strokeLinejoin:`round`},e)),Q.map((e,t)=>{let n=Je(t,We);return(0,J.jsx)(`line`,{x1:He,y1:Ue,x2:n.x,y2:n.y,stroke:`currentColor`,strokeOpacity:.25,strokeWidth:1},t)}),(0,J.jsx)(R.g,{initial:{scale:.4,opacity:0},animate:{scale:1,opacity:1},transition:{type:`spring`,stiffness:140,damping:16},style:{transformOrigin:`${He}px ${Ue}px`},children:(0,J.jsx)(`polygon`,{points:Ye(t=>We*Math.max(Ge,Q[t].value(e)/100)),fill:`var(--radar-fill, var(--card-accent))`,stroke:`var(--card-accent)`,strokeWidth:2,strokeLinejoin:`round`,style:{fillOpacity:`var(--radar-fill-opacity, 0.25)`}})}),Q.map((e,t)=>{let n=qe[t],r=Je(t,We),i=r.x+n.dx;return(0,J.jsxs)(`text`,{x:i,y:r.y+n.dy,textAnchor:n.anchor,children:[(0,J.jsx)(`tspan`,{x:i,fontSize:11.5,fontWeight:500,fill:`currentColor`,children:e.label}),(0,J.jsx)(`tspan`,{x:i,dy:12.5,fontSize:10,fill:`currentColor`,fillOpacity:.8,children:e.sub})]},e.label)})]})}var Ze={personality:v,schedules:u,superpowers:b,memory:l,library:g,workspace:h,contacts:y,channels:pe},Qe={personality:`rounded-3xl`,schedules:`rounded-3xl`,superpowers:`rounded-[1.25rem_2.75rem_1.25rem_2.5rem]`,channels:`rounded-[2.25rem_1rem_2.5rem_1.25rem]`,contacts:`rounded-[1rem_2.5rem_1.25rem_2.75rem]`,workspace:`rounded-[1.25rem_2.5rem_1rem_2.5rem]`},$e=720,et=480,tt=[`superpowers`,`memory`,`library`,`workspace`,`contacts`,`channels`],nt={personality:`Go ahead, tweak my soul`,superpowers:`Everything I know how to do`,memory:`Everything I remember`,library:`The apps and docs I've made for you`,schedules:`What I do on repeat`,workspace:`All the files that power me`,contacts:`The people I know and trust`,channels:`All the places you can reach me`};function rt(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}var it=280,at=140,ot=.44,st=1118,ct=300,lt=.09,ut=14,dt=5,ft=22,pt={"--card-bg":`#24292e`,"--card-feature-bg":`rgba(23, 25, 28, 0.35)`,"--card-hover":`#2d3339`,"--card-accent":`#bd4900`,"--radar-fill":`#fea973`,"--radar-fill-opacity":`0.1`,"--card-flood-fg":`#fdfdfc`,"--content-default":`#fdfdfc`,"--content-strong":`#fdfdfc`,"--content-secondary":`#a9b2bb`,"--content-tertiary":`#8d99a5`,"--border-base":`rgba(255, 255, 255, 0.08)`};function mt({assistantId:e}){let t=i(),{components:n,traits:r,customImageUrl:o,isLoading:s,invalidate:c}=D(e),l=ce(e),u=Se(e,{supportsPlugins:L()}),d=I(a(F(e)).data),f={...u,memory:d===void 0?void 0:{value:d,label:d===1?`memory`:`memories`}},[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),_=(0,q.useCallback)(n=>{g(!0),ye(e,n).then(r=>{if(g(!1),r){t.invalidateQueries({queryKey:de(e)});let{version:r,assistantId:i,setIdentity:a}=w.getState();a(n,r,i),C.success(`Say hi to ${n}!`)}else C.error(`The rename didn't go through. Please try again.`)})},[e,t]),v=(0,q.useCallback)(()=>{c()},[c]),y=ze(),b=s||l.isLoading,x=ue(n,r),S=!!o&&!x;return(0,J.jsxs)(oe,{className:S?`relative overflow-hidden`:void 0,style:x?{backgroundColor:`color-mix(in srgb, ${x} ${ut}%, var(--surface-overlay))`}:void 0,children:[S&&o&&(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,children:(0,J.jsx)(`img`,{src:o,alt:``,className:`h-full w-full scale-110 object-cover blur-[60px] brightness-[0.65]`})}),b?(0,J.jsx)(`div`,{className:`relative flex flex-1 items-center justify-center`,children:(0,J.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2`,style:{borderColor:`var(--border-base)`,borderTopColor:`var(--content-tertiary)`}})}):(0,J.jsx)(_t,{components:n,traits:r,customImageUrl:o,name:l.data?.identity?.name||`Assistant`,sections:y,stats:f,avatarHex:x,photoBackdrop:S,isRenaming:h,onOpenAvatarModal:()=>m(!0)}),(0,J.jsx)(me,{open:p,onClose:()=>m(!1),assistantId:e,components:n,traits:r,customImageUrl:o,onSaveCharacter:v,onUploadImage:v,assistantName:l.data?.identity?.name||`Assistant`,onRenameSubmit:_,isRenaming:h})]})}function ht({section:e,stat:t,gridArea:n,cardStyle:i,hoverFill:a,mini:o,flooded:c=!1,floodOrigin:l,photoBackdrop:u=!1,linkRef:d,onHoverChange:f}){let p=Ze[e.key]??v,[m,h]=(0,q.useState)({x:50,y:100});l&&l!==m&&h(l);let g=c?`text-[var(--card-flood-fg)]`:`text-[var(--content-default)]`,_=c?`text-[var(--card-flood-fg)]`:`text-[var(--content-strong)]`,y=c?`text-[var(--card-flood-fg)] opacity-75`:`text-[var(--content-secondary)]`,b=(0,J.jsx)(R.span,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,style:{backgroundColor:`var(--card-accent)`},initial:!1,animate:{clipPath:c?`circle(141% at ${m.x}% ${m.y}%)`:`circle(0% at ${m.x}% ${m.y}%)`},transition:c?{duration:.5,ease:`easeOut`}:{duration:.35,ease:`easeIn`}});if(o){let n=t?.value===void 0?t?.text:`${t.value} ${t.label}`;return(0,J.jsx)(s.Root,{asChild:!0,bordered:!1,elevated:!0,clipContents:!0,className:`rounded-[12px] border-0 bg-[var(--card-bg)]`,children:(0,J.jsxs)(r,{to:e.to,ref:d,onMouseEnter:()=>f?.(!0),onMouseLeave:()=>f?.(!1),className:`relative flex h-full flex-1 cursor-pointer items-center gap-2 px-4 py-2.5 transition-all duration-150 active:scale-[0.98] ${a?`hover:bg-[var(--card-hover)]`:``}`,children:[b,(0,J.jsx)(`span`,{className:`relative flex h-10 w-10 shrink-0 items-center justify-center`,children:(0,J.jsx)(p,{className:`h-5 w-5 transition-colors duration-300 ${y}`,"aria-hidden":!0})}),(0,J.jsxs)(`span`,{className:`relative flex min-w-0 flex-col gap-0`,children:[(0,J.jsx)(`span`,{className:`truncate text-title-small leading-normal transition-colors duration-300 ${_}`,children:e.label}),n&&(0,J.jsx)(`span`,{className:`truncate text-[11px] leading-normal font-medium transition-colors duration-300 ${c?`text-[var(--card-flood-fg)] opacity-75`:`text-[var(--content-tertiary)]`}`,children:n})]})]})})}let x=e.key===`personality`||e.key===`schedules`;return(0,J.jsx)(s.Root,{asChild:!0,bordered:!x,elevated:!x,className:`${Qe[e.key]??``} ${x?`border bg-[var(--card-feature-bg,var(--card-bg))] ${u?`border-transparent backdrop-blur-[32px]`:`border-[var(--border-base)]`}`:`bg-[var(--card-bg)]`}`,style:{...n?{gridArea:n}:{},...i},children:(0,J.jsxs)(r,{to:e.to,ref:d,onMouseEnter:()=>f?.(!0),onMouseLeave:()=>f?.(!1),className:`relative flex h-full w-full cursor-pointer flex-col justify-between gap-3 overflow-hidden p-5 text-left transition-all duration-150 active:scale-[0.98] ${a?`hover:bg-[var(--card-hover)]`:``}`,children:[b,n&&t?.radar&&(0,J.jsx)(`span`,{className:`absolute inset-x-5 top-14 bottom-4 flex items-center justify-center transition-colors duration-300 ${c?`text-[var(--card-flood-fg)]`:u?`text-[var(--content-default)]`:`text-[var(--content-secondary)]`}`,style:c?{"--card-accent":`var(--card-flood-fg)`}:void 0,children:(0,J.jsx)(Xe,{values:t.radar,className:`h-auto w-full`})}),x?(0,J.jsxs)(`span`,{className:`relative flex items-center gap-2`,children:[(0,J.jsx)(p,{className:`h-5 w-5 transition-colors duration-300 ${g}`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-body-medium-default transition-colors duration-300 ${g}`,children:e.label})]}):(0,J.jsxs)(`span`,{className:`relative flex flex-col items-start gap-1.5`,children:[(0,J.jsx)(p,{className:`h-6 w-6 transition-colors duration-300 ${g}`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-body-medium-default transition-colors duration-300 ${g}`,children:e.label}),(0,J.jsx)(`span`,{className:`text-[13px] transition-colors duration-300 ${y}`,children:e.description})]})]}),n&&t?.schedules&&t.schedules.items.length>0&&(0,J.jsxs)(`span`,{className:`relative flex min-h-0 flex-1 flex-col justify-start gap-2 overflow-hidden py-2`,children:[t.schedules.items.map(e=>(0,J.jsxs)(`span`,{className:`flex flex-col gap-0.5 rounded-xl px-3 py-2 transition-colors duration-300`,style:{backgroundColor:c?`color-mix(in srgb, var(--card-flood-fg) 12%, transparent)`:`color-mix(in srgb, var(--content-default) 5%, transparent)`},children:[(0,J.jsx)(`span`,{className:`truncate text-[13px] font-medium transition-colors duration-300 ${g}`,children:e.name}),(0,J.jsxs)(`span`,{className:`truncate text-[12px] transition-colors duration-300 ${y}`,children:[e.cadence,` · next `,rt(e.nextRunAt)]})]},e.id)),t.schedules.more>0&&(0,J.jsxs)(`span`,{className:`text-[12px] font-medium transition-colors duration-300 ${y}`,children:[`View `,t.schedules.more,` more…`]})]}),t?.value===void 0?t?.text?(0,J.jsx)(`span`,{className:`relative text-[14px] font-medium italic transition-colors duration-300 ${g}`,children:t.text}):null:(0,J.jsxs)(`span`,{className:`relative flex flex-col leading-none`,children:[(0,J.jsx)(`span`,{className:`text-[3.25rem] transition-colors duration-300 max-lg:text-[2.5rem] ${_}`,style:{fontFamily:`var(--font-serif)`},children:t.value}),(0,J.jsx)(`span`,{className:`mt-1 text-[13px] transition-colors duration-300 ${y}`,children:t.label})]})]})})}function gt({components:e,traits:t,customImageUrl:n,name:r,avatarSize:i,isRenaming:a,onEdit:o}){return(0,J.jsxs)(`div`,{className:`relative z-[1] flex flex-col items-center justify-center gap-5`,children:[(0,J.jsx)(Re,{name:r,isRenaming:a}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`Update avatar and name`,title:`Update avatar and name`,onClick:o,className:`avatar-edit-cursor outline-none keyboard-focus:ring-2 keyboard-focus:ring-[var(--ring)]`,children:n&&!t?(0,J.jsx)(`img`,{src:n,alt:``,width:i,height:i,className:`rounded-[32px] object-cover`,style:{width:i,height:i}}):(0,J.jsx)(re,{components:e,traits:t,customImageUrl:n,size:i,interactive:!0})})]})}function _t({components:e,traits:t,customImageUrl:n,name:i,sections:a,stats:o,avatarHex:c,photoBackdrop:l,isRenaming:d,onOpenAvatarModal:f}){let{ref:m,size:h}=G(),g=z(),y=h.w>=$e&&h.h>=et,b=Math.round(Math.min(it,Math.max(at,Math.min(h.w,h.h)*.32))),x=!!(c&&e&&t),S=y&&!g&&x,C=(0,q.useRef)(null),w=(0,q.useRef)({}),[T,E]=(0,q.useState)(null),ee=(0,q.useCallback)(e=>{C.current=e,m(e)},[m]),D=(0,q.useCallback)((e,t)=>{if(!S)return;if(!t){E(null);return}let n=C.current,r=w.current[e];if(!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect(),o={left:a.left-i.left,top:a.top-i.top,width:a.width,height:a.height},s=(o.left+o.width/2-i.width/2)/(i.width/2),c=(o.top+o.height/2-i.height/2)/(i.height/2),l=ke(o,Math.abs(s)>Math.abs(c)?s<0?`right`:`left`:c<0?`bottom`:`top`,{x:i.width/2,y:i.height/2});E({key:e,target:l,origin:{x:l.peek.x/o.width*100,y:l.peek.y/o.height*100}})},[S]),O=S?T:null,te=O?nt[O.key]??null:null,k=l?pt:{"--card-bg":c?`color-mix(in srgb, ${c} var(--card-tint-pct, ${dt}%), var(--card-surface, var(--surface-lift)))`:`var(--surface-lift)`,"--card-feature-bg":c?`color-mix(in srgb, var(--card-accent) 28%, var(--card-surface, var(--surface-lift)))`:`var(--surface-lift)`,"--card-hover":c?`color-mix(in srgb, ${c} ${ft}%, var(--card-surface, var(--surface-lift)))`:`var(--surface-hover)`,"--card-accent":c??`var(--content-default)`,"--card-flood-fg":c?B(c):`var(--content-default)`},A=(h.h-8)/(1-lt),j=Math.round(Math.min(st,A,Math.max(ct,h.w*ot))),M=Math.round(j*lt),N=(0,J.jsx)(gt,{components:e,traits:t,customImageUrl:n,name:i,avatarSize:b,isRenaming:d,onEdit:f});if(!y){let e=a.find(e=>e.key===`schedules`),t=a.find(e=>e.key===`personality`),n=a.filter(e=>e.key!==`schedules`&&e.key!==`personality`),i=o.schedules?.schedules,c=i?i.items.length+i.more:void 0,d=o.personality?.radar,f=`w-full rounded-[12px] border bg-[var(--card-feature-bg,var(--card-bg))] ${l?`border-transparent backdrop-blur-[32px]`:`border-[var(--border-base)]`}`;return(0,J.jsxs)(`div`,{ref:ee,className:`identity-bento relative flex min-h-0 flex-1 flex-col items-center gap-6 overflow-y-auto px-2 py-4`,style:l?{...k,"--card-bg":`#17191c`}:k,children:[N,(0,J.jsxs)(`div`,{className:`flex w-full max-w-md shrink-0 flex-col gap-2`,children:[e&&(0,J.jsx)(s.Root,{asChild:!0,bordered:!1,elevated:!1,clipContents:!0,className:f,children:(0,J.jsxs)(r,{to:e.to,className:`flex w-full cursor-pointer items-center gap-2 p-4 transition-all duration-150 hover:bg-[var(--card-hover)] active:scale-[0.98]`,children:[(0,J.jsx)(u,{className:`h-5 w-5 shrink-0 text-[var(--content-default)]`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e.label}),c!==void 0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`h-[3px] w-[3px] shrink-0 rounded-full bg-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:c})]})]}),(0,J.jsx)(p,{className:`h-4 w-4 shrink-0 text-[var(--content-default)]`,"aria-hidden":!0})]})}),t&&(0,J.jsx)(s.Root,{asChild:!0,bordered:!1,elevated:!1,clipContents:!0,className:f,children:(0,J.jsxs)(r,{to:t.to,className:`flex w-full cursor-pointer flex-col gap-4 px-4 pt-4 pb-6 transition-all duration-150 hover:bg-[var(--card-hover)] active:scale-[0.98]`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(v,{className:`h-5 w-5 text-[var(--content-default)]`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:t.label})]}),d&&(0,J.jsx)(`span`,{className:`flex items-center justify-center ${l?`text-[var(--content-default)]`:`text-[var(--content-secondary)]`}`,children:(0,J.jsx)(Xe,{values:d,className:`h-auto w-full`})})]})}),(0,J.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:n.map(e=>(0,J.jsx)(ht,{section:e,stat:o[e.key],hoverFill:!0,mini:!0},e.key))})]})]})}let P=a.filter(e=>!tt.includes(e.key)),ne=a.filter(e=>tt.includes(e.key)),F=[1.15,1,.45,.3],I=(h.h-(F.length-1)*12)/F.reduce((e,t)=>e+t,0),L=Math.round(I*F[0]),V=(x?[`"personality greeting greeting greeting schedules"`,`". . . . schedules"`,`". . . . ."`,`"smalls smalls smalls smalls smalls"`]:[`"personality greeting greeting greeting schedules"`,`". avatar avatar avatar schedules"`,`". avatar avatar avatar ."`,`"smalls smalls smalls smalls smalls"`]).join(` `),H=e=>({section:e,stat:o[e.key],hoverFill:!S,photoBackdrop:l,flooded:O?.key===e.key,floodOrigin:O?.key===e.key?O.origin:void 0,linkRef:t=>{w.current[e.key]=t},onHoverChange:t=>D(e.key,t)});return(0,J.jsxs)(`div`,{ref:ee,className:`identity-bento relative grid min-h-0 flex-1 gap-3 overflow-hidden`,style:{...k,gridTemplateColumns:`1.55fr 1fr 1fr 1fr 1.55fr`,gridTemplateRows:F.map(e=>`${e}fr`).join(` `),gridTemplateAreas:V},children:[x?(0,J.jsx)(R.div,{className:`pointer-events-none absolute left-1/2 z-0`,style:{width:j,height:j,bottom:-M,x:`-50%`},initial:!1,animate:O?{scale:.4,opacity:0}:{scale:1,opacity:1},transition:O?{duration:.15}:{delay:.25,type:`spring`,stiffness:210,damping:18},children:(0,J.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`Update avatar and name`,title:`Update avatar and name`,onClick:f,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f())},className:`avatar-edit-cursor group pointer-events-auto relative h-full w-full scale-100 outline-none transition-transform duration-200 ease-out hover:scale-105 keyboard-focus:ring-2 keyboard-focus:ring-[var(--ring)]`,children:[(0,J.jsx)(re,{components:e,traits:t,customImageUrl:n,size:j,interactive:!0}),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 flex items-center justify-center opacity-0 transition-opacity duration-150 group-hover:opacity-100`,children:(0,J.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full bg-black/40`,children:(0,J.jsx)(_,{className:`h-5 w-5 text-white`})})})]})}):(0,J.jsx)(`div`,{className:`relative z-[1] flex items-start justify-center`,style:{gridArea:`avatar`},children:(0,J.jsx)(`button`,{type:`button`,"aria-label":`Update avatar and name`,title:`Update avatar and name`,onClick:f,className:`avatar-edit-cursor rounded-full outline-none keyboard-focus:ring-2 keyboard-focus:ring-[var(--ring)]`,children:n?(0,J.jsx)(`img`,{src:n,alt:``,width:b,height:b,className:`rounded-full object-cover`,style:{width:b,height:b}}):(0,J.jsx)(re,{components:e,traits:t,customImageUrl:null,size:b})})}),(0,J.jsx)(`div`,{className:`relative z-[1] flex items-center justify-center`,style:{gridArea:`greeting`},children:(0,J.jsx)(Re,{name:i,isRenaming:d,overrideText:te})}),S&&c&&e&&t&&(0,J.jsx)(Pe,{hex:c,components:e,traits:t,target:O?.target??null}),P.map(e=>(0,J.jsx)(ht,{...H(e),gridArea:e.key,cardStyle:e.key===`schedules`?{alignSelf:`start`,height:`auto`,minHeight:L}:void 0},e.key)),(0,J.jsx)(`div`,{className:`flex min-h-0 items-stretch gap-3`,style:{gridArea:`smalls`},children:ne.map(e=>(0,J.jsx)(ht,{...H(e),mini:!0},e.key))})]})}function vt(){return(0,J.jsx)(mt,{assistantId:ae()})}function yt(){return(0,J.jsx)(vt,{},ae())}export{yt as IdentityPageRoute};