@vellumai/web 0.10.8-dev.202607130516.157ae8a → 0.10.8-dev.202607130914.073396f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{account-page-UU87NTst.js → account-page-B67xFKjm.js} +1 -1
- package/dist/assets/{acp-run-detail-panel-DVigkJ3N.js → acp-run-detail-panel-BEnETelW.js} +1 -1
- package/dist/assets/{activity-steps-panel-U_gKoMYV.js → activity-steps-panel-DMsLr2uV.js} +1 -1
- package/dist/assets/advanced-page-Bvn9JSkD.js +1 -0
- package/dist/assets/{ai-page-Dc6ZkcRu.js → ai-page-0BJ8t9t5.js} +1 -1
- package/dist/assets/{api-key-screen-CgLh1AgF.js → api-key-screen-JmzpzkXU.js} +1 -1
- package/dist/assets/{archive-page-8kZtqi4J.js → archive-page-BOTTpmhV.js} +1 -1
- package/dist/assets/{background-task-detail-panel-987qMmXb.js → background-task-detail-panel-D1R5Gt1o.js} +1 -1
- package/dist/assets/{billing-page-CVEGF4xu.js → billing-page-BTZrOF6Z.js} +1 -1
- package/dist/assets/{bookmarks-page-BsaqP8bd.js → bookmarks-page-Bnyq2PrZ.js} +1 -1
- package/dist/assets/{channels-page-route-BITEvtWC.js → channels-page-route-B4I54Hlh.js} +1 -1
- package/dist/assets/{command-palette-BRG7p3d3.js → command-palette-C-0sQNrv.js} +1 -1
- package/dist/assets/{command-palette-window-page-CCuDQ8yT.js → command-palette-window-page-DrUa3Q2F.js} +1 -1
- package/dist/assets/{community-page-B7zbsnWc.js → community-page-CgAJFZNK.js} +1 -1
- package/dist/assets/{contacts-page-route-DfDgxRhr.js → contacts-page-route-CWbVfl5E.js} +1 -1
- package/dist/assets/{credentials-page-6OzHjgOl.js → credentials-page-pxVj-Uhn.js} +1 -1
- package/dist/assets/{debug-page-DjVLqSsP.js → debug-page-DzEi2hun.js} +1 -1
- package/dist/assets/{deploy-dialogs-BuaLNuIF.js → deploy-dialogs-BN6e216c.js} +1 -1
- package/dist/assets/{detail-panel-stop-button-B_gN09QB.js → detail-panel-stop-button-DvrlIwGa.js} +1 -1
- package/dist/assets/{developer-page-CtbAjQ01.js → developer-page-DtzoMLif.js} +1 -1
- package/dist/assets/{devices-page-CzrEId9_.js → devices-page-BziUD9Iq.js} +1 -1
- package/dist/assets/{dictation-overlay-page-MgsYi7qB.js → dictation-overlay-page-DGQtwqBJ.js} +1 -1
- package/dist/assets/{document-viewer-page-lipFhePS.js → document-viewer-page-DzVnrcGq.js} +1 -1
- package/dist/assets/{earn-credits-modal-BZv8KPY_.js → earn-credits-modal-DL7lfK6t.js} +1 -1
- package/dist/assets/{emails-page-DziOOHlk.js → emails-page-D8GSgBLY.js} +1 -1
- package/dist/assets/{general-page-DtuPOASz.js → general-page-CiWyAF5P.js} +1 -1
- package/dist/assets/{hatching-screen-D0Agbpdq.js → hatching-screen-ailefwrE.js} +1 -1
- package/dist/assets/{home-page-route-DY1AJULD.js → home-page-route-CylhN3gG.js} +1 -1
- package/dist/assets/{hosting-screen-CrIrr7mq.js → hosting-screen-YMMLNHga.js} +1 -1
- package/dist/assets/{identity-page-route-D0EaKgXT.js → identity-page-route-PSzRLEe-.js} +1 -1
- package/dist/assets/{index-RjTgjtTV.js → index-DZAcojtQ.js} +7 -7
- package/dist/assets/{inspect-page-D-S9Ra2c.js → inspect-page-g6y4i5zi.js} +1 -1
- package/dist/assets/{integrations-page-C2trjkg8.js → integrations-page-Du0F3Ua7.js} +1 -1
- package/dist/assets/{intelligence-layout-BHgcBpNy.js → intelligence-layout-Bba5MZF7.js} +1 -1
- package/dist/assets/{keyboard-shortcuts-page-CM9iWfga.js → keyboard-shortcuts-page-CTb_Vety.js} +1 -1
- package/dist/assets/{library-detail-page-BrPf4P72.js → library-detail-page-CKGG9pVO.js} +1 -1
- package/dist/assets/{library-page-D98-vEZ0.js → library-page-Fq7jxL5c.js} +1 -1
- package/dist/assets/{logout-page-DwRkr0Ll.js → logout-page-4N_BNkhc.js} +1 -1
- package/dist/assets/{logs-layout-C-lBgxOg.js → logs-layout-C4N_HD_G.js} +1 -1
- package/dist/assets/{memory-router-playground-page-CA8Z85_u.js → memory-router-playground-page-BG1rEtqt.js} +1 -1
- package/dist/assets/{mobile-sidebar-drawer-5UcOVnnQ.js → mobile-sidebar-drawer-pUdMI0nM.js} +1 -1
- package/dist/assets/{notifications-page-COYD_xli.js → notifications-page-DXEZUbks.js} +1 -1
- package/dist/assets/{oauth-complete-page-BnpquKqe.js → oauth-complete-page-CqHxojfu.js} +1 -1
- package/dist/assets/{oauth-popup-complete-page-ZrRK9-cQ.js → oauth-popup-complete-page-2I2d9rcr.js} +1 -1
- package/dist/assets/{pairing-page-DLM_4IgB.js → pairing-page-WAsvnehl.js} +1 -1
- package/dist/assets/{plugins-page-D-p7zFRr.js → plugins-page-4teaAuVM.js} +1 -1
- package/dist/assets/{prechat-route-CWKxgYYD.js → prechat-route-HxZdIW5I.js} +1 -1
- package/dist/assets/{privacy-page-D8fMhz6c.js → privacy-page-BCzzz-IJ.js} +1 -1
- package/dist/assets/{privacy-screen-Byw47xQ6.js → privacy-screen-CCLy3Ir_.js} +1 -1
- package/dist/assets/{provider-callback-page-jipvOSTr.js → provider-callback-page-Du2X2TQs.js} +1 -1
- package/dist/assets/{quick-input-page-BazYwlo9.js → quick-input-page-CTBO1nKc.js} +1 -1
- package/dist/assets/{research-mock-page-BWoKWBPA.js → research-mock-page-BOec_5uX.js} +1 -1
- package/dist/assets/{research-onboarding-route-CcCRJt6_.js → research-onboarding-route-D3xtPwAg.js} +1 -1
- package/dist/assets/{review-terms-screen-CbLdPZfl.js → review-terms-screen--rmGv19B.js} +1 -1
- package/dist/assets/{security-page-ZEB54DPw.js → security-page-D90hoGUL.js} +1 -1
- package/dist/assets/{select-assistant-screen-CHKkEZUx.js → select-assistant-screen-CeLqmAZq.js} +1 -1
- package/dist/assets/{settings-layout-uK-Lpqba.js → settings-layout-C3gSCos2.js} +1 -1
- package/dist/assets/{share-feedback-modal-DG2r1qqN.js → share-feedback-modal-B6IobSaG.js} +1 -1
- package/dist/assets/{sidebar-tree-DDUEsAa4.js → sidebar-tree-BZf-fXXQ.js} +1 -1
- package/dist/assets/{signup-page-CVz_aWrx.js → signup-page-D0ttNeK8.js} +1 -1
- package/dist/assets/{skill-detail-page-CFU0jrZM.js → skill-detail-page-BwGLZ6Ir.js} +1 -1
- package/dist/assets/{skill-detail-panel-I2VWbqAo.js → skill-detail-panel-BuEo14Fm.js} +1 -1
- package/dist/assets/{skills-page-C3PhHEgJ.js → skills-page-CilXonLL.js} +1 -1
- package/dist/assets/{sounds-page-DgYrB7pS.js → sounds-page-Cj5HBP8M.js} +1 -1
- package/dist/assets/{subagent-detail-panel-Bw63q_Dd.js → subagent-detail-panel-B8sWapcO.js} +1 -1
- package/dist/assets/{system-events-page-LYtpCXvB.js → system-events-page-_-6CuelL.js} +1 -1
- package/dist/assets/{theme-stage-page-Dk-HbOXU.js → theme-stage-page-BQXyG45_.js} +1 -1
- package/dist/assets/{tiptap-document-editor-BaW3QmDp.js → tiptap-document-editor-BQB6DhNb.js} +1 -1
- package/dist/assets/{tool-detail-panel-CCQlm9BO.js → tool-detail-panel-BdvoDAc2.js} +1 -1
- package/dist/assets/{upgrade-cancel-page-BZNW20Qh.js → upgrade-cancel-page-D6AO1Dz2.js} +1 -1
- package/dist/assets/{upgrade-success-page-Ctct25DK.js → upgrade-success-page-BnoD0JID.js} +1 -1
- package/dist/assets/{usage-page-DmIP57yv.js → usage-page-CLW0y6Sj.js} +1 -1
- package/dist/assets/{use-edge-swipe-back-BYWAzQmV.js → use-edge-swipe-back-DYSaS9WM.js} +1 -1
- package/dist/assets/{use-invite-link-dialog-BtmP79fG.js → use-invite-link-dialog-Cfjjavpg.js} +1 -1
- package/dist/assets/{use-skill-actions-BPNpVrzC.js → use-skill-actions-CYhk4mEs.js} +1 -1
- package/dist/assets/{use-skill-categories-BO2u03Xu.js → use-skill-categories-veSnULDv.js} +1 -1
- package/dist/assets/{use-skill-detail-files-iXFvM76E.js → use-skill-detail-files-DROqozrr.js} +1 -1
- package/dist/assets/{voice-page-D9-Pw5kg.js → voice-page-Dz_Gph0z.js} +1 -1
- package/dist/assets/{weather-forecast-display-IOKkzlZQ.js → weather-forecast-display-DxWFsOIg.js} +1 -1
- package/dist/assets/{welcome-screen-B9bJeuZV.js → welcome-screen-BOEMLIps.js} +1 -1
- package/dist/assets/{workflow-detail-panel-DOS1dpe8.js → workflow-detail-panel-B-53KW59.js} +1 -1
- package/dist/assets/{workspace-page-NtATtw_E.js → workspace-page-B2N85fT0.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/advanced-page-h6aomSQb.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-amTXFI-2.js";import{d as r,h as i}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./sparkles-PGiR5v1g.js";import{t as c}from"./triangle-alert-Z0Gq0IuB.js";import"./src-DZbMXyC2.js";import{t as l}from"./dropdown-ByHOpeOU.js";import{xr as u}from"./sdk.gen-BwnFjFcp.js";import{Ft as d,It as f,Lt as ee,Rt as te,c as ne,d as re,ht as ie}from"./react-query.gen-C6wVk6Rw.js";import{t as p}from"./api-errors-CrWDzVca.js";import{Fn as ae,xr as m}from"./index-RjTgjtTV.js";import{t as h}from"./use-active-assistant-id-CGeH4Gl6.js";import{i as g,o as _,r as v}from"./llm-dimension-Tz2Fx8qB.js";import{n as y}from"./usage-window-CCdJWJ0U.js";import{n as oe,t as se}from"./schedules-wrzKkPOD.js";var b=e(t(),1);function ce(e){if(!e)return{};let t={};for(let n of e.callSites)!n.id||!n.displayName||(t[n.id]={id:n.id,displayName:n.displayName,description:n.description,domain:n.domain});return t}function x(e){return Number.isFinite(e)?Math.round(e).toLocaleString():`0`}function S(e){return!Number.isFinite(e)||e===0?`$0.00`:`$${e.toFixed(2)}`}function C(e,t,n){if(e===`task`){let e=t.groupKey;return e?n.callSites?.[e]?.displayName??t.group:t.group}if(e===`profile`){let e=t.groupKey;return e?n.profiles?.[e]?.displayName??t.group:t.group||`Default / Unset`}return t.group}function le(e,t,n){return!e||e.length===0?[]:e.map(e=>{let r=C(t,e,n);return r===e.group?e:{...e,group:r}})}var w=6,T=`value:`,E=`null:`;function D(e,t=`schedule`){return e===null?`${E}${g(t)?_(t):t}`:`${T}${e}`}function O(e){return[...e].sort((e,t)=>{if(e.date!==t.date)return e.date<t.date?-1:1;let n=j(e.bucketId),r=j(t.bucketId);return n===r?e.bucketId===t.bucketId?0:e.bucketId<t.bucketId?-1:1:n-r})}function ue(e){return e.map(e=>({bucketId:e.bucketId,date:e.date,displayLabel:e.displayLabel,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,groups:{}}))}function de(e,t,n){return t!==`task`&&t!==`profile`?[...e]:e.map(e=>{let r=!1,i={};for(let[a,o]of Object.entries(e.groups)){let e=C(t,A(o),n);e===o.group?i[a]=o:(r=!0,i[a]={...o,group:e})}return r?{...e,groups:i}:e})}function k(e){let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n.groups)){let n=t.get(e);t.set(e,{label:n?.label??r.group,totalEstimatedCostUsd:(n?.totalEstimatedCostUsd??0)+r.totalEstimatedCostUsd})}let n=Array.from(t.entries()).sort(([e,t],[n,r])=>t.totalEstimatedCostUsd===r.totalEstimatedCostUsd?t.label===r.label?e===n?0:e<n?-1:1:t.label<r.label?-1:1:r.totalEstimatedCostUsd-t.totalEstimatedCostUsd).map(([e,t],n)=>({seriesKey:e,label:t.label,totalEstimatedCostUsd:t.totalEstimatedCostUsd,colorIndex:n}));return{items:n,visibleItems:n.slice(0,w)}}function A(e){return{group:e.group,groupId:e.groupKey,groupKey:e.groupKey,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalCacheCreationTokens:0,totalCacheReadTokens:0,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,turnCount:null}}function j(e){let t=e.lastIndexOf(`|`);if(t<0)return 0;let n=Number(e.slice(t+1));return Number.isFinite(n)?n:0}var M=o(),N=140,P=40,F=28,fe=2,pe=2,me=1e-6,I=12,he=220,ge=56,_e=[40,80,60,100,50,70,30],ve=[18,24,28,35,42,50,64,78,92,106,118,96,84,74,68,80,88,72,56,48,40,34,26,20],L=[`var(--usage-trend-stack-positive, var(--system-positive-strong, #10b981))`,`var(--usage-trend-stack-info, var(--system-info-strong, #3b82f6))`,`var(--usage-trend-stack-mid, var(--system-mid-strong, #f59e0b))`,`var(--usage-trend-stack-secondary, var(--content-secondary, #6b7280))`,`var(--usage-trend-stack-negative, var(--system-negative-strong, #f87171))`,`var(--usage-trend-stack-tertiary, var(--content-tertiary, #9ca3af))`];function R(e){return L[e%L.length]}function z(e){return e.displayLabel?e.displayLabel:e.date}function ye(e,t){let n=e+I,r=t+I;return n+he>window.innerWidth&&(n=e-he-I),r+ge>window.innerHeight&&(r=t-ge-I),{x:n,y:r}}function be({buckets:e,isHourly:t,legendItems:n}){let[r,i]=(0,b.useState)(null),a=(0,b.useMemo)(()=>O(e),[e]),o=(0,b.useMemo)(()=>k(e),[e]),s=n??o.items,c=n??o.visibleItems,l=(0,b.useMemo)(()=>a.reduce((e,t)=>Math.max(e,t.totalEstimatedCostUsd),0),[a]),u=(0,b.useCallback)((e,t)=>{let n=ye(e.clientX,e.clientY);i({...t,x:n.x,y:n.y})},[]),d=(0,b.useCallback)(()=>i(null),[]);if(a.length===0){let e=(0,M.jsx)(we,{title:t?`No hourly data`:`No daily data`,subtitle:`No usage recorded in this time range`});return c.length===0?e:(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,(0,M.jsx)(B,{items:c})]})}let f=t?F:P;return(0,M.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${N}px`},"aria-hidden":`true`,children:a.map(e=>{let t=l>0?e.totalEstimatedCostUsd/l:0,r=Math.max(fe,N*t);return(0,M.jsx)(`div`,{className:`flex items-end`,style:{width:`${f}px`,minWidth:`${f}px`,height:`${r}px`,opacity:e.totalEstimatedCostUsd>0?1:.3},title:`${z(e)}: ${S(e.totalEstimatedCostUsd)}`,"data-usage-series-bar":e.bucketId,children:(0,M.jsx)(Se,{bucket:e,height:r,legendItems:s,hasLegendOverride:n!=null,onSegmentHover:u,onSegmentLeave:d})},e.bucketId)})}),(0,M.jsx)(`div`,{className:`flex items-start gap-2`,children:a.map(e=>(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5`,style:{width:`${f}px`,minWidth:`${f}px`},children:[(0,M.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-secondary)`},children:S(e.totalEstimatedCostUsd)}),(0,M.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`},children:z(e)})]},e.bucketId))}),c.length>0?(0,M.jsx)(B,{items:c}):null]}),r?(0,M.jsx)(Ce,{tooltip:r}):null]})}function xe({isHourly:e}){let t=e?ve:_e,n=e?F:P;return(0,M.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${N}px`},"aria-hidden":`true`,children:t.map((e,t)=>(0,M.jsx)(`div`,{className:`rounded-sm`,style:{width:`${n}px`,height:`${e}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}},t))})}function Se({bucket:e,height:t,legendItems:n,hasLegendOverride:r,onSegmentHover:i,onSegmentLeave:a}){let o=Object.keys(e.groups).length>0,s=n.filter(e=>(e.state??`active`)===`active`).flatMap(t=>{let n=e.groups[t.seriesKey];return!n||n.totalEstimatedCostUsd<=0?[]:[{item:t,value:n}]});if(s.length===0&&!o&&!r){let n={label:`Total`,bucketLabel:z(e),cost:S(e.totalEstimatedCostUsd)};return(0,M.jsx)(`div`,{className:`w-full rounded-sm`,title:`${n.label}: ${n.cost}`,onMouseEnter:e=>i(e,n),onMouseMove:e=>i(e,n),onMouseLeave:a,style:{height:`${t}px`,background:R(0)},"data-usage-series-segment-label":n.label,"data-usage-fallback-segment":`true`})}return s.length===0?null:(0,M.jsx)(`div`,{className:`flex w-full flex-col-reverse overflow-hidden rounded-sm`,style:{height:`${t}px`},"data-usage-series-stack":e.bucketId,children:s.map(({item:n,value:r})=>{let o={label:n.label,bucketLabel:z(e),cost:S(r.totalEstimatedCostUsd)};return(0,M.jsx)(`div`,{title:`${o.label}: ${o.cost}`,onMouseEnter:e=>i(e,o),onMouseMove:e=>i(e,o),onMouseLeave:a,style:{height:`${Math.max(pe,t*r.totalEstimatedCostUsd/Math.max(e.totalEstimatedCostUsd,me))}px`,background:R(n.colorIndex)},"data-usage-series-segment":n.seriesKey,"data-usage-series-segment-label":n.label,"data-usage-series-color-index":n.colorIndex},n.seriesKey)})})}function Ce({tooltip:e}){return(0,M.jsxs)(`div`,{className:`pointer-events-none fixed z-50 max-w-[220px] rounded-md border px-2 py-1 shadow-xl`,style:{left:`${e.x}px`,top:`${e.y}px`,background:`var(--surface-overlay, var(--surface-lift))`,borderColor:`var(--border-base)`},"aria-hidden":`true`,children:[(0,M.jsx)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-default)`},children:e.label}),(0,M.jsxs)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[e.bucketLabel,` · `,e.cost]})]})}function B({items:e}){return(0,M.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pt-1`,children:e.map(e=>{let t=e.state??`active`,n=t===`inactive`;return(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,"data-usage-legend-state":t,children:[(0,M.jsx)(`span`,{className:`h-[7px] w-[7px] shrink-0 rounded-full`,style:{background:n?`var(--content-tertiary)`:R(e.colorIndex),opacity:n?.45:1},"aria-hidden":`true`,"data-usage-series-color-index":e.colorIndex}),(0,M.jsx)(`span`,{className:n?`truncate text-[10px] line-through`:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`,opacity:n?.65:1},children:e.label})]},e.seriesKey)})})}function we({title:e,subtitle:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md py-12 text-center`,style:{color:`var(--content-tertiary)`},children:[(0,M.jsx)(`p`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),(0,M.jsx)(`p`,{className:`mt-1 text-body-small-default`,children:t})]})}function V(e){return g(e)?_(e):e}function Te(e){return U({from:e.from,to:e.to},e.scheduleId)}function Ee(e){return U({from:e.from,to:e.to,...e.granularity?{granularity:e.granularity}:{},...e.tz?{tz:e.tz}:{}},e.scheduleId)}function H(e){return U({from:e.from,to:e.to,groupBy:V(e.groupBy)},e.scheduleId)}function De(e){return U({from:e.from,to:e.to,granularity:e.granularity,groupBy:V(e.groupBy),...e.tz?{tz:e.tz}:{}},e.scheduleId)}function U(e,t){return t?{...e,scheduleId:t}:e}function Oe(e){return[`${x(e.totalInputTokens)} direct`,`${x(e.totalCacheCreationTokens)} cache created`,`${x(e.totalCacheReadTokens)} cache read`,`${x(e.totalOutputTokens)} out`].join(` / `)}function ke(e){return!Number.isFinite(e)||e===0?`0`:e>=1e6||e>=999950&&e<1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toLocaleString()}function Ae(e){return`${ke(e.totalInputTokens+e.totalCacheCreationTokens+e.totalCacheReadTokens)} in / ${ke(e.totalOutputTokens)} out`}var je=`task`,W=`model`,Me=new Set([400,404,422]),Ne=3,Pe=new Set([`today`,`yesterday`,`7d`,`30d`,`90d`,`all`]),Fe=new Set([`actor`,`provider`,`model`,`conversation`,`task`,`profile`,`schedule`]),G={task:v.task,profile:v.profile,model:v.model,provider:`Provider`,actor:`Actor`,conversation:`Conversation`,schedule:`Schedule`},Ie=[{value:`task`,label:G.task},{value:`profile`,label:G.profile},{value:`model`,label:G.model},{value:`provider`,label:G.provider},{value:`schedule`,label:G.schedule},{value:`conversation`,label:G.conversation}];function Le(e){let t=e.get(`range`),n=e.get(`groupBy`),r=Ve(n)?n:je;return{range:Be(t)?t:`7d`,groupBy:r,scheduleId:r===`schedule`?Re(e):void 0}}function Re(e){let t=e.get(`scheduleId`);if(!(!t||t.trim().length===0))return t}function ze(e,t){let n=new URLSearchParams(e);return t.range!==void 0&&n.set(`range`,t.range),t.groupBy!==void 0&&n.set(`groupBy`,t.groupBy),t.scheduleId!==void 0&&(t.scheduleId===null||t.scheduleId.trim().length===0?n.delete(`scheduleId`):n.set(`scheduleId`,t.scheduleId)),n.get(`groupBy`)!==`schedule`&&n.delete(`scheduleId`),n}function Be(e){return e!=null&&Pe.has(e)}function Ve(e){return e!=null&&Fe.has(e)}function He(e){return e!==`conversation`}function Ue(e,t){return e!==`task`&&e!==`profile`?!1:q(t)}function K(e,t){return!q(t)&&e<Ne}function q(e){return e instanceof p&&Me.has(e.status)}function We(e,t){let n=e===`hourly`?`Hourly Trend`:`Daily Trend`;return!t||t===`conversation`?n:`${n} by ${G[t]}`}function Ge({requestedGranularity:e,isLoading:t,buckets:n}){return e===`hourly`&&(t||!n||n.length===0||n.some(Ke))?`hourly`:`daily`}function Ke(e){return e.bucketId.includes(`|`)||qe(e.date)}function qe(e){return/^\d{4}-\d{2}-\d{2} ([01]\d|2[0-3]):00$/.test(e)}function Je(e,t,n=Date.now()){return y(e,t,n)}function Ye(e){return e===`today`||e===`yesterday`?`hourly`:`daily`}function J({prompt:e,children:t,variant:i=`outlined`,size:a=`regular`,className:o}){let c=r(),l=(0,b.useCallback)(()=>{m(c,{prompt:e})},[c,e]);return(0,M.jsx)(n,{variant:i,size:a,leftIcon:(0,M.jsx)(s,{}),onClick:l,className:o,children:t})}var Xe=[{value:`today`,label:`Today`},{value:`yesterday`,label:`Yesterday`},{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`},{value:`90d`,label:`Last 90 days`},{value:`all`,label:`All time`}],Ze=300*1e3,Qe=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and explain the biggest cost contributors by call site, model, and profile.`,`Check my current llm.default, llm.callSites, and llm.profiles.`,`Give me a concise summary of what is driving cost and what you would optimize first.`,`Do not change config yet.`].join(` `),$e=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and current LLM config, then recommend the safest cost-optimization changes.`,`If changes are clearly safe, show me the exact config commands you would run and ask for confirmation before applying them.`].join(` `);function et({assistantId:e}){let[t,n]=i(),{range:r,groupBy:o,scheduleId:s}=(0,b.useMemo)(()=>Le(t),[t]),c=ae(),l=(0,b.useCallback)(e=>{n(t=>ze(t,e),{replace:!0})},[n]),p=(0,b.useMemo)(()=>Je(r,c),[r,c]),m=(0,b.useMemo)(()=>Ye(r),[r]),h=a({queryKey:ie({path:{assistant_id:e}}),queryFn:()=>se(e),staleTime:1e4}),g=(0,b.useCallback)(e=>{l({range:e})},[l]),_=a({...te({path:{assistant_id:e},query:Te({from:p.from,to:p.to,scheduleId:s})})}),v=a({queryKey:d({path:{assistant_id:e},query:H({from:p.from,to:p.to,groupBy:o,scheduleId:s})}),queryFn:async({signal:t})=>{try{let{data:n}=await u({path:{assistant_id:e},query:H({from:p.from,to:p.to,groupBy:o,scheduleId:s}),signal:t,throwOnError:!0});return{groupBy:o,response:n}}catch(n){if(!Ue(o,n))throw n;let{data:r}=await u({path:{assistant_id:e},query:H({from:p.from,to:p.to,groupBy:W,scheduleId:s}),signal:t,throwOnError:!0});return{groupBy:W,response:r}}},retry:K}),y=v.data?.groupBy??o,x=He(y)?y:void 0,S=a({...ee({path:{assistant_id:e},query:De({from:p.from,to:p.to,granularity:m,groupBy:x??`actor`,tz:c,scheduleId:s})}),enabled:!!x,retry:K}),C=a({...f({path:{assistant_id:e},query:Ee({from:p.from,to:p.to,granularity:m,tz:c,scheduleId:s})}),enabled:!x||S.isError}),w=a({...re({path:{assistant_id:e}}),enabled:y===`task`,staleTime:1/0}),T=a({...ne({path:{assistant_id:e}}),select:oe,enabled:y===`profile`,staleTime:Ze}),E=(0,b.useMemo)(()=>({callSites:ce(w.data),profiles:T.data??{}}),[w.data,T.data]),D=(0,b.useMemo)(()=>{let e=v.data;if(e)return le(e.response.breakdown,e.groupBy,E)},[v.data,E]),O=(0,b.useMemo)(()=>{if(!(!x||!S.data))return de(S.data.buckets,x,E)},[S.data,x,E]),k=(0,b.useMemo)(()=>{if(C.data)return ue(C.data.buckets)},[C.data]),A=(0,b.useMemo)(()=>x?S.error?k?{isLoading:!1,error:null,data:k,refetch:C.refetch}:{isLoading:C.isLoading||!k&&!C.error,error:C.error??S.error,data:void 0,refetch:C.error?C.refetch:S.refetch}:{isLoading:S.isLoading,error:S.error,data:O,refetch:S.refetch}:{isLoading:C.isLoading,error:C.error,data:k,refetch:C.refetch},[k,C.error,C.isLoading,C.refetch,O,x,S.error,S.isLoading,S.refetch]),j=Ge({requestedGranularity:m,isLoading:A.isLoading,buckets:A.data}),N=j===`hourly`,P=x&&S.error?void 0:y,F=(0,b.useMemo)(()=>{if(!(y!==`schedule`||!s))return tt(h.data,s)},[y,s,h.data]);return(0,M.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,M.jsx)(`h3`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:`Usage`}),(0,M.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,M.jsx)(it,{range:r,onChange:g})})]}),(0,M.jsx)(`section`,{"aria-label":`Totals`,children:(0,M.jsx)(X,{query:_,skeleton:(0,M.jsx)(ot,{}),render:e=>(0,M.jsx)(at,{totals:e})})}),(0,M.jsx)(Y,{title:`Inference Usage`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,M.jsx)(`h4`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:We(j,P)}),(0,M.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,M.jsx)(st,{value:y,onChange:e=>{e===o&&y!==o&&(v.refetch(),S.refetch()),l({groupBy:e,scheduleId:e===`schedule`?void 0:null})}})})]}),(0,M.jsx)(X,{query:A,skeleton:(0,M.jsx)(xe,{isHourly:N}),render:e=>(0,M.jsx)(be,{buckets:e,isHourly:N,legendItems:F})})]})}),(0,M.jsx)(ct,{query:v,groups:D}),(0,M.jsx)(rt,{})]})}function tt(e,t){let n=e??[];return[...n.some(e=>e.id===t)?[]:[{id:t,label:nt(t)}],...n.map(e=>({id:e.id,label:e.name||e.id}))].map((e,n)=>({seriesKey:D(e.id,`schedule`),label:e.label,colorIndex:n,state:e.id===t?`active`:`inactive`}))}function nt(e){return`Unknown schedule (${e})`}function rt(){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsx)(`div`,{className:`h-px w-full`,style:{background:`linear-gradient(to right, transparent, var(--border-base), transparent)`}}),(0,M.jsx)(Y,{title:`Cost assistant`,subtitle:`Review recent spend and tune model profile choices.`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md px-3 py-3 sm:flex-row sm:items-center`,children:[(0,M.jsx)(J,{prompt:Qe,children:`Analyze costs with assistant`}),(0,M.jsx)(J,{prompt:$e,variant:`ghost`,children:`Optimize settings`})]})})]})}function it({range:e,onChange:t}){return(0,M.jsx)(`div`,{className:`flex items-center`,children:(0,M.jsx)(l,{value:e,onChange:t,options:Xe.map(e=>({value:e.value,label:e.label}))})})}function Y({title:e,subtitle:t,children:n}){return(0,M.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-md border px-4 py-4`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`h3`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),t?(0,M.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t}):null]}),n]})}function X({query:e,skeleton:t,render:n}){return e.isLoading?(0,M.jsx)(M.Fragment,{children:t}):e.error?(0,M.jsx)(ft,{message:e.error instanceof Error?e.error.message:`Failed to load usage.`,onRetry:()=>e.refetch()}):e.data?(0,M.jsx)(M.Fragment,{children:n(e.data)}):(0,M.jsx)(M.Fragment,{children:t})}function at({totals:e}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`span`,{style:{fontSize:`30px`,fontWeight:600,lineHeight:1,color:`var(--content-default)`},children:S(e.totalEstimatedCostUsd)}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`Cost`})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`span`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:x(e.eventCount)}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`LLM Calls`})]})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,M.jsx)(Z,{label:`Direct Input Tokens`,value:x(e.totalInputTokens)}),(0,M.jsx)(Z,{label:`Output Tokens`,value:x(e.totalOutputTokens)}),(0,M.jsx)(Z,{label:`Cache Created`,value:x(e.totalCacheCreationTokens)}),(0,M.jsx)(Z,{label:`Cache Read`,value:x(e.totalCacheReadTokens)})]})]})}function Z({label:e,value:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-default)`},children:t}),(0,M.jsx)(`span`,{className:`text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:e})]})}function ot(){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)($,{width:140,height:30}),(0,M.jsx)($,{width:90,height:12})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)($,{width:60,height:16}),(0,M.jsx)($,{width:60,height:12})]})]}),(0,M.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:Array.from({length:4}).map((e,t)=>(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,M.jsx)($,{width:`50%`,height:12}),(0,M.jsx)($,{width:`70%`,height:11})]},t))})]})}function st({value:e,onChange:t}){return(0,M.jsx)(`div`,{className:`flex items-center`,children:(0,M.jsx)(l,{value:e,onChange:t,menuAlign:`end`,menuMinWidth:196,options:Ie.map(e=>({value:e.value,label:e.label}))})})}function ct({query:e,groups:t}){let[n,r]=(0,b.useState)(new Set),i=e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,M.jsx)(Y,{title:`Breakdown`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(Q,{label:`% of total`,active:n.has(`pct`),onClick:()=>i(`pct`)}),(0,M.jsx)(Q,{label:`Tokens`,active:n.has(`tokens`),onClick:()=>i(`tokens`)}),(0,M.jsx)(Q,{label:`Turns`,active:n.has(`turns`),onClick:()=>i(`turns`)})]}),(0,M.jsx)(X,{query:e,skeleton:(0,M.jsx)(ut,{}),render:e=>(0,M.jsx)(lt,{groups:t??e.response.breakdown,showPct:n.has(`pct`),showTokens:n.has(`tokens`),showTurns:n.has(`turns`)})})]})})}function Q({label:e,active:t,onClick:n}){return(0,M.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full border px-2.5 py-1 text-label-medium-default`,style:{borderColor:t?`var(--content-secondary)`:`var(--border-base)`,background:t?`color-mix(in srgb, var(--content-secondary) 15%, transparent)`:`transparent`,color:t?`var(--content-default)`:`var(--content-tertiary)`},children:e})}function lt({groups:e,showPct:t,showTokens:n,showTurns:r}){if(e.length===0)return(0,M.jsx)(dt,{title:`No breakdown data`,subtitle:`No usage recorded for this grouping`});let i=e.reduce((e,t)=>e+t.totalEstimatedCostUsd,0);return(0,M.jsx)(`div`,{className:`overflow-hidden rounded-md`,children:(0,M.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{style:{borderBottom:`1px solid var(--border-base)`},children:[(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:`Group`}),n?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`35%`},children:`Tokens`}):null,r?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`72px`},children:`Turns`}):null,t?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`64px`},children:`%`}):null,(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`100px`},children:`Cost`})]})}),(0,M.jsx)(`tbody`,{children:e.map((e,a)=>{let o=Oe(e),s=Ae(e),c=i>0?Math.round(e.totalEstimatedCostUsd/i*100):0;return(0,M.jsxs)(`tr`,{style:{borderTop:a===0?`none`:`1px solid var(--border-base)`},children:[(0,M.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-default)`},children:(0,M.jsx)(`span`,{className:`block truncate text-body-medium-lighter`,title:e.group,children:e.group})}),n?(0,M.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-secondary)`},children:(0,M.jsx)(`span`,{className:`block truncate text-body-small-default`,title:o,children:s})}):null,r?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e.turnCount==null?`—`:e.turnCount.toLocaleString()})}):null,t?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsxs)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[c,`%`]})}):null,(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:S(e.totalEstimatedCostUsd)})})]},e.groupKey??e.groupId??`${e.group}-${a}`)})})]})})}function ut(){return(0,M.jsx)(`div`,{className:`flex flex-col gap-2`,"aria-hidden":`true`,children:Array.from({length:4}).map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)($,{width:100,height:14}),(0,M.jsx)($,{width:`60%`,height:12}),(0,M.jsx)($,{width:50,height:14})]},t))})}function $({width:e,height:t}){return(0,M.jsx)(`div`,{className:`rounded-sm`,style:{width:typeof e==`number`?`${e}px`:e,height:`${t}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}})}function dt({title:e,subtitle:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-1 py-8 text-center`,children:[(0,M.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t})]})}function ft({message:e,onRetry:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(c,{className:`h-4 w-4 shrink-0`,style:{color:`var(--system-negative-strong, #f87171)`}}),(0,M.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:e})]}),t?(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`self-start rounded-md border px-3 py-1 text-body-small-default`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`,color:`var(--content-default)`},children:`Retry`}):null]})}function pt(){return(0,M.jsx)(et,{assistantId:h()})}export{pt as UsagePage};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-amTXFI-2.js";import{d as r,h as i}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./sparkles-PGiR5v1g.js";import{t as c}from"./triangle-alert-Z0Gq0IuB.js";import"./src-DZbMXyC2.js";import{t as l}from"./dropdown-ByHOpeOU.js";import{xr as u}from"./sdk.gen-BwnFjFcp.js";import{Ft as d,It as f,Lt as ee,Rt as te,c as ne,d as re,ht as ie}from"./react-query.gen-C6wVk6Rw.js";import{t as p}from"./api-errors-CrWDzVca.js";import{Fn as ae,xr as m}from"./index-DZAcojtQ.js";import{t as h}from"./use-active-assistant-id-CGeH4Gl6.js";import{i as g,o as _,r as v}from"./llm-dimension-Tz2Fx8qB.js";import{n as y}from"./usage-window-CCdJWJ0U.js";import{n as oe,t as se}from"./schedules-wrzKkPOD.js";var b=e(t(),1);function ce(e){if(!e)return{};let t={};for(let n of e.callSites)!n.id||!n.displayName||(t[n.id]={id:n.id,displayName:n.displayName,description:n.description,domain:n.domain});return t}function x(e){return Number.isFinite(e)?Math.round(e).toLocaleString():`0`}function S(e){return!Number.isFinite(e)||e===0?`$0.00`:`$${e.toFixed(2)}`}function C(e,t,n){if(e===`task`){let e=t.groupKey;return e?n.callSites?.[e]?.displayName??t.group:t.group}if(e===`profile`){let e=t.groupKey;return e?n.profiles?.[e]?.displayName??t.group:t.group||`Default / Unset`}return t.group}function le(e,t,n){return!e||e.length===0?[]:e.map(e=>{let r=C(t,e,n);return r===e.group?e:{...e,group:r}})}var w=6,T=`value:`,E=`null:`;function D(e,t=`schedule`){return e===null?`${E}${g(t)?_(t):t}`:`${T}${e}`}function O(e){return[...e].sort((e,t)=>{if(e.date!==t.date)return e.date<t.date?-1:1;let n=j(e.bucketId),r=j(t.bucketId);return n===r?e.bucketId===t.bucketId?0:e.bucketId<t.bucketId?-1:1:n-r})}function ue(e){return e.map(e=>({bucketId:e.bucketId,date:e.date,displayLabel:e.displayLabel,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,groups:{}}))}function de(e,t,n){return t!==`task`&&t!==`profile`?[...e]:e.map(e=>{let r=!1,i={};for(let[a,o]of Object.entries(e.groups)){let e=C(t,A(o),n);e===o.group?i[a]=o:(r=!0,i[a]={...o,group:e})}return r?{...e,groups:i}:e})}function k(e){let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n.groups)){let n=t.get(e);t.set(e,{label:n?.label??r.group,totalEstimatedCostUsd:(n?.totalEstimatedCostUsd??0)+r.totalEstimatedCostUsd})}let n=Array.from(t.entries()).sort(([e,t],[n,r])=>t.totalEstimatedCostUsd===r.totalEstimatedCostUsd?t.label===r.label?e===n?0:e<n?-1:1:t.label<r.label?-1:1:r.totalEstimatedCostUsd-t.totalEstimatedCostUsd).map(([e,t],n)=>({seriesKey:e,label:t.label,totalEstimatedCostUsd:t.totalEstimatedCostUsd,colorIndex:n}));return{items:n,visibleItems:n.slice(0,w)}}function A(e){return{group:e.group,groupId:e.groupKey,groupKey:e.groupKey,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalCacheCreationTokens:0,totalCacheReadTokens:0,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,turnCount:null}}function j(e){let t=e.lastIndexOf(`|`);if(t<0)return 0;let n=Number(e.slice(t+1));return Number.isFinite(n)?n:0}var M=o(),N=140,P=40,F=28,fe=2,pe=2,me=1e-6,I=12,he=220,ge=56,_e=[40,80,60,100,50,70,30],ve=[18,24,28,35,42,50,64,78,92,106,118,96,84,74,68,80,88,72,56,48,40,34,26,20],L=[`var(--usage-trend-stack-positive, var(--system-positive-strong, #10b981))`,`var(--usage-trend-stack-info, var(--system-info-strong, #3b82f6))`,`var(--usage-trend-stack-mid, var(--system-mid-strong, #f59e0b))`,`var(--usage-trend-stack-secondary, var(--content-secondary, #6b7280))`,`var(--usage-trend-stack-negative, var(--system-negative-strong, #f87171))`,`var(--usage-trend-stack-tertiary, var(--content-tertiary, #9ca3af))`];function R(e){return L[e%L.length]}function z(e){return e.displayLabel?e.displayLabel:e.date}function ye(e,t){let n=e+I,r=t+I;return n+he>window.innerWidth&&(n=e-he-I),r+ge>window.innerHeight&&(r=t-ge-I),{x:n,y:r}}function be({buckets:e,isHourly:t,legendItems:n}){let[r,i]=(0,b.useState)(null),a=(0,b.useMemo)(()=>O(e),[e]),o=(0,b.useMemo)(()=>k(e),[e]),s=n??o.items,c=n??o.visibleItems,l=(0,b.useMemo)(()=>a.reduce((e,t)=>Math.max(e,t.totalEstimatedCostUsd),0),[a]),u=(0,b.useCallback)((e,t)=>{let n=ye(e.clientX,e.clientY);i({...t,x:n.x,y:n.y})},[]),d=(0,b.useCallback)(()=>i(null),[]);if(a.length===0){let e=(0,M.jsx)(we,{title:t?`No hourly data`:`No daily data`,subtitle:`No usage recorded in this time range`});return c.length===0?e:(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,(0,M.jsx)(B,{items:c})]})}let f=t?F:P;return(0,M.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${N}px`},"aria-hidden":`true`,children:a.map(e=>{let t=l>0?e.totalEstimatedCostUsd/l:0,r=Math.max(fe,N*t);return(0,M.jsx)(`div`,{className:`flex items-end`,style:{width:`${f}px`,minWidth:`${f}px`,height:`${r}px`,opacity:e.totalEstimatedCostUsd>0?1:.3},title:`${z(e)}: ${S(e.totalEstimatedCostUsd)}`,"data-usage-series-bar":e.bucketId,children:(0,M.jsx)(Se,{bucket:e,height:r,legendItems:s,hasLegendOverride:n!=null,onSegmentHover:u,onSegmentLeave:d})},e.bucketId)})}),(0,M.jsx)(`div`,{className:`flex items-start gap-2`,children:a.map(e=>(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5`,style:{width:`${f}px`,minWidth:`${f}px`},children:[(0,M.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-secondary)`},children:S(e.totalEstimatedCostUsd)}),(0,M.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`},children:z(e)})]},e.bucketId))}),c.length>0?(0,M.jsx)(B,{items:c}):null]}),r?(0,M.jsx)(Ce,{tooltip:r}):null]})}function xe({isHourly:e}){let t=e?ve:_e,n=e?F:P;return(0,M.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${N}px`},"aria-hidden":`true`,children:t.map((e,t)=>(0,M.jsx)(`div`,{className:`rounded-sm`,style:{width:`${n}px`,height:`${e}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}},t))})}function Se({bucket:e,height:t,legendItems:n,hasLegendOverride:r,onSegmentHover:i,onSegmentLeave:a}){let o=Object.keys(e.groups).length>0,s=n.filter(e=>(e.state??`active`)===`active`).flatMap(t=>{let n=e.groups[t.seriesKey];return!n||n.totalEstimatedCostUsd<=0?[]:[{item:t,value:n}]});if(s.length===0&&!o&&!r){let n={label:`Total`,bucketLabel:z(e),cost:S(e.totalEstimatedCostUsd)};return(0,M.jsx)(`div`,{className:`w-full rounded-sm`,title:`${n.label}: ${n.cost}`,onMouseEnter:e=>i(e,n),onMouseMove:e=>i(e,n),onMouseLeave:a,style:{height:`${t}px`,background:R(0)},"data-usage-series-segment-label":n.label,"data-usage-fallback-segment":`true`})}return s.length===0?null:(0,M.jsx)(`div`,{className:`flex w-full flex-col-reverse overflow-hidden rounded-sm`,style:{height:`${t}px`},"data-usage-series-stack":e.bucketId,children:s.map(({item:n,value:r})=>{let o={label:n.label,bucketLabel:z(e),cost:S(r.totalEstimatedCostUsd)};return(0,M.jsx)(`div`,{title:`${o.label}: ${o.cost}`,onMouseEnter:e=>i(e,o),onMouseMove:e=>i(e,o),onMouseLeave:a,style:{height:`${Math.max(pe,t*r.totalEstimatedCostUsd/Math.max(e.totalEstimatedCostUsd,me))}px`,background:R(n.colorIndex)},"data-usage-series-segment":n.seriesKey,"data-usage-series-segment-label":n.label,"data-usage-series-color-index":n.colorIndex},n.seriesKey)})})}function Ce({tooltip:e}){return(0,M.jsxs)(`div`,{className:`pointer-events-none fixed z-50 max-w-[220px] rounded-md border px-2 py-1 shadow-xl`,style:{left:`${e.x}px`,top:`${e.y}px`,background:`var(--surface-overlay, var(--surface-lift))`,borderColor:`var(--border-base)`},"aria-hidden":`true`,children:[(0,M.jsx)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-default)`},children:e.label}),(0,M.jsxs)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[e.bucketLabel,` · `,e.cost]})]})}function B({items:e}){return(0,M.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pt-1`,children:e.map(e=>{let t=e.state??`active`,n=t===`inactive`;return(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,"data-usage-legend-state":t,children:[(0,M.jsx)(`span`,{className:`h-[7px] w-[7px] shrink-0 rounded-full`,style:{background:n?`var(--content-tertiary)`:R(e.colorIndex),opacity:n?.45:1},"aria-hidden":`true`,"data-usage-series-color-index":e.colorIndex}),(0,M.jsx)(`span`,{className:n?`truncate text-[10px] line-through`:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`,opacity:n?.65:1},children:e.label})]},e.seriesKey)})})}function we({title:e,subtitle:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md py-12 text-center`,style:{color:`var(--content-tertiary)`},children:[(0,M.jsx)(`p`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),(0,M.jsx)(`p`,{className:`mt-1 text-body-small-default`,children:t})]})}function V(e){return g(e)?_(e):e}function Te(e){return U({from:e.from,to:e.to},e.scheduleId)}function Ee(e){return U({from:e.from,to:e.to,...e.granularity?{granularity:e.granularity}:{},...e.tz?{tz:e.tz}:{}},e.scheduleId)}function H(e){return U({from:e.from,to:e.to,groupBy:V(e.groupBy)},e.scheduleId)}function De(e){return U({from:e.from,to:e.to,granularity:e.granularity,groupBy:V(e.groupBy),...e.tz?{tz:e.tz}:{}},e.scheduleId)}function U(e,t){return t?{...e,scheduleId:t}:e}function Oe(e){return[`${x(e.totalInputTokens)} direct`,`${x(e.totalCacheCreationTokens)} cache created`,`${x(e.totalCacheReadTokens)} cache read`,`${x(e.totalOutputTokens)} out`].join(` / `)}function ke(e){return!Number.isFinite(e)||e===0?`0`:e>=1e6||e>=999950&&e<1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toLocaleString()}function Ae(e){return`${ke(e.totalInputTokens+e.totalCacheCreationTokens+e.totalCacheReadTokens)} in / ${ke(e.totalOutputTokens)} out`}var je=`task`,W=`model`,Me=new Set([400,404,422]),Ne=3,Pe=new Set([`today`,`yesterday`,`7d`,`30d`,`90d`,`all`]),Fe=new Set([`actor`,`provider`,`model`,`conversation`,`task`,`profile`,`schedule`]),G={task:v.task,profile:v.profile,model:v.model,provider:`Provider`,actor:`Actor`,conversation:`Conversation`,schedule:`Schedule`},Ie=[{value:`task`,label:G.task},{value:`profile`,label:G.profile},{value:`model`,label:G.model},{value:`provider`,label:G.provider},{value:`schedule`,label:G.schedule},{value:`conversation`,label:G.conversation}];function Le(e){let t=e.get(`range`),n=e.get(`groupBy`),r=Ve(n)?n:je;return{range:Be(t)?t:`7d`,groupBy:r,scheduleId:r===`schedule`?Re(e):void 0}}function Re(e){let t=e.get(`scheduleId`);if(!(!t||t.trim().length===0))return t}function ze(e,t){let n=new URLSearchParams(e);return t.range!==void 0&&n.set(`range`,t.range),t.groupBy!==void 0&&n.set(`groupBy`,t.groupBy),t.scheduleId!==void 0&&(t.scheduleId===null||t.scheduleId.trim().length===0?n.delete(`scheduleId`):n.set(`scheduleId`,t.scheduleId)),n.get(`groupBy`)!==`schedule`&&n.delete(`scheduleId`),n}function Be(e){return e!=null&&Pe.has(e)}function Ve(e){return e!=null&&Fe.has(e)}function He(e){return e!==`conversation`}function Ue(e,t){return e!==`task`&&e!==`profile`?!1:q(t)}function K(e,t){return!q(t)&&e<Ne}function q(e){return e instanceof p&&Me.has(e.status)}function We(e,t){let n=e===`hourly`?`Hourly Trend`:`Daily Trend`;return!t||t===`conversation`?n:`${n} by ${G[t]}`}function Ge({requestedGranularity:e,isLoading:t,buckets:n}){return e===`hourly`&&(t||!n||n.length===0||n.some(Ke))?`hourly`:`daily`}function Ke(e){return e.bucketId.includes(`|`)||qe(e.date)}function qe(e){return/^\d{4}-\d{2}-\d{2} ([01]\d|2[0-3]):00$/.test(e)}function Je(e,t,n=Date.now()){return y(e,t,n)}function Ye(e){return e===`today`||e===`yesterday`?`hourly`:`daily`}function J({prompt:e,children:t,variant:i=`outlined`,size:a=`regular`,className:o}){let c=r(),l=(0,b.useCallback)(()=>{m(c,{prompt:e})},[c,e]);return(0,M.jsx)(n,{variant:i,size:a,leftIcon:(0,M.jsx)(s,{}),onClick:l,className:o,children:t})}var Xe=[{value:`today`,label:`Today`},{value:`yesterday`,label:`Yesterday`},{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`},{value:`90d`,label:`Last 90 days`},{value:`all`,label:`All time`}],Ze=300*1e3,Qe=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and explain the biggest cost contributors by call site, model, and profile.`,`Check my current llm.default, llm.callSites, and llm.profiles.`,`Give me a concise summary of what is driving cost and what you would optimize first.`,`Do not change config yet.`].join(` `),$e=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and current LLM config, then recommend the safest cost-optimization changes.`,`If changes are clearly safe, show me the exact config commands you would run and ask for confirmation before applying them.`].join(` `);function et({assistantId:e}){let[t,n]=i(),{range:r,groupBy:o,scheduleId:s}=(0,b.useMemo)(()=>Le(t),[t]),c=ae(),l=(0,b.useCallback)(e=>{n(t=>ze(t,e),{replace:!0})},[n]),p=(0,b.useMemo)(()=>Je(r,c),[r,c]),m=(0,b.useMemo)(()=>Ye(r),[r]),h=a({queryKey:ie({path:{assistant_id:e}}),queryFn:()=>se(e),staleTime:1e4}),g=(0,b.useCallback)(e=>{l({range:e})},[l]),_=a({...te({path:{assistant_id:e},query:Te({from:p.from,to:p.to,scheduleId:s})})}),v=a({queryKey:d({path:{assistant_id:e},query:H({from:p.from,to:p.to,groupBy:o,scheduleId:s})}),queryFn:async({signal:t})=>{try{let{data:n}=await u({path:{assistant_id:e},query:H({from:p.from,to:p.to,groupBy:o,scheduleId:s}),signal:t,throwOnError:!0});return{groupBy:o,response:n}}catch(n){if(!Ue(o,n))throw n;let{data:r}=await u({path:{assistant_id:e},query:H({from:p.from,to:p.to,groupBy:W,scheduleId:s}),signal:t,throwOnError:!0});return{groupBy:W,response:r}}},retry:K}),y=v.data?.groupBy??o,x=He(y)?y:void 0,S=a({...ee({path:{assistant_id:e},query:De({from:p.from,to:p.to,granularity:m,groupBy:x??`actor`,tz:c,scheduleId:s})}),enabled:!!x,retry:K}),C=a({...f({path:{assistant_id:e},query:Ee({from:p.from,to:p.to,granularity:m,tz:c,scheduleId:s})}),enabled:!x||S.isError}),w=a({...re({path:{assistant_id:e}}),enabled:y===`task`,staleTime:1/0}),T=a({...ne({path:{assistant_id:e}}),select:oe,enabled:y===`profile`,staleTime:Ze}),E=(0,b.useMemo)(()=>({callSites:ce(w.data),profiles:T.data??{}}),[w.data,T.data]),D=(0,b.useMemo)(()=>{let e=v.data;if(e)return le(e.response.breakdown,e.groupBy,E)},[v.data,E]),O=(0,b.useMemo)(()=>{if(!(!x||!S.data))return de(S.data.buckets,x,E)},[S.data,x,E]),k=(0,b.useMemo)(()=>{if(C.data)return ue(C.data.buckets)},[C.data]),A=(0,b.useMemo)(()=>x?S.error?k?{isLoading:!1,error:null,data:k,refetch:C.refetch}:{isLoading:C.isLoading||!k&&!C.error,error:C.error??S.error,data:void 0,refetch:C.error?C.refetch:S.refetch}:{isLoading:S.isLoading,error:S.error,data:O,refetch:S.refetch}:{isLoading:C.isLoading,error:C.error,data:k,refetch:C.refetch},[k,C.error,C.isLoading,C.refetch,O,x,S.error,S.isLoading,S.refetch]),j=Ge({requestedGranularity:m,isLoading:A.isLoading,buckets:A.data}),N=j===`hourly`,P=x&&S.error?void 0:y,F=(0,b.useMemo)(()=>{if(!(y!==`schedule`||!s))return tt(h.data,s)},[y,s,h.data]);return(0,M.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,M.jsx)(`h3`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:`Usage`}),(0,M.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,M.jsx)(it,{range:r,onChange:g})})]}),(0,M.jsx)(`section`,{"aria-label":`Totals`,children:(0,M.jsx)(X,{query:_,skeleton:(0,M.jsx)(ot,{}),render:e=>(0,M.jsx)(at,{totals:e})})}),(0,M.jsx)(Y,{title:`Inference Usage`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,M.jsx)(`h4`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:We(j,P)}),(0,M.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,M.jsx)(st,{value:y,onChange:e=>{e===o&&y!==o&&(v.refetch(),S.refetch()),l({groupBy:e,scheduleId:e===`schedule`?void 0:null})}})})]}),(0,M.jsx)(X,{query:A,skeleton:(0,M.jsx)(xe,{isHourly:N}),render:e=>(0,M.jsx)(be,{buckets:e,isHourly:N,legendItems:F})})]})}),(0,M.jsx)(ct,{query:v,groups:D}),(0,M.jsx)(rt,{})]})}function tt(e,t){let n=e??[];return[...n.some(e=>e.id===t)?[]:[{id:t,label:nt(t)}],...n.map(e=>({id:e.id,label:e.name||e.id}))].map((e,n)=>({seriesKey:D(e.id,`schedule`),label:e.label,colorIndex:n,state:e.id===t?`active`:`inactive`}))}function nt(e){return`Unknown schedule (${e})`}function rt(){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsx)(`div`,{className:`h-px w-full`,style:{background:`linear-gradient(to right, transparent, var(--border-base), transparent)`}}),(0,M.jsx)(Y,{title:`Cost assistant`,subtitle:`Review recent spend and tune model profile choices.`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md px-3 py-3 sm:flex-row sm:items-center`,children:[(0,M.jsx)(J,{prompt:Qe,children:`Analyze costs with assistant`}),(0,M.jsx)(J,{prompt:$e,variant:`ghost`,children:`Optimize settings`})]})})]})}function it({range:e,onChange:t}){return(0,M.jsx)(`div`,{className:`flex items-center`,children:(0,M.jsx)(l,{value:e,onChange:t,options:Xe.map(e=>({value:e.value,label:e.label}))})})}function Y({title:e,subtitle:t,children:n}){return(0,M.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-md border px-4 py-4`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`h3`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),t?(0,M.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t}):null]}),n]})}function X({query:e,skeleton:t,render:n}){return e.isLoading?(0,M.jsx)(M.Fragment,{children:t}):e.error?(0,M.jsx)(ft,{message:e.error instanceof Error?e.error.message:`Failed to load usage.`,onRetry:()=>e.refetch()}):e.data?(0,M.jsx)(M.Fragment,{children:n(e.data)}):(0,M.jsx)(M.Fragment,{children:t})}function at({totals:e}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`span`,{style:{fontSize:`30px`,fontWeight:600,lineHeight:1,color:`var(--content-default)`},children:S(e.totalEstimatedCostUsd)}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`Cost`})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)(`span`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:x(e.eventCount)}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`LLM Calls`})]})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,M.jsx)(Z,{label:`Direct Input Tokens`,value:x(e.totalInputTokens)}),(0,M.jsx)(Z,{label:`Output Tokens`,value:x(e.totalOutputTokens)}),(0,M.jsx)(Z,{label:`Cache Created`,value:x(e.totalCacheCreationTokens)}),(0,M.jsx)(Z,{label:`Cache Read`,value:x(e.totalCacheReadTokens)})]})]})}function Z({label:e,value:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-default)`},children:t}),(0,M.jsx)(`span`,{className:`text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:e})]})}function ot(){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)($,{width:140,height:30}),(0,M.jsx)($,{width:90,height:12})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,M.jsx)($,{width:60,height:16}),(0,M.jsx)($,{width:60,height:12})]})]}),(0,M.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:Array.from({length:4}).map((e,t)=>(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,M.jsx)($,{width:`50%`,height:12}),(0,M.jsx)($,{width:`70%`,height:11})]},t))})]})}function st({value:e,onChange:t}){return(0,M.jsx)(`div`,{className:`flex items-center`,children:(0,M.jsx)(l,{value:e,onChange:t,menuAlign:`end`,menuMinWidth:196,options:Ie.map(e=>({value:e.value,label:e.label}))})})}function ct({query:e,groups:t}){let[n,r]=(0,b.useState)(new Set),i=e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,M.jsx)(Y,{title:`Breakdown`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(Q,{label:`% of total`,active:n.has(`pct`),onClick:()=>i(`pct`)}),(0,M.jsx)(Q,{label:`Tokens`,active:n.has(`tokens`),onClick:()=>i(`tokens`)}),(0,M.jsx)(Q,{label:`Turns`,active:n.has(`turns`),onClick:()=>i(`turns`)})]}),(0,M.jsx)(X,{query:e,skeleton:(0,M.jsx)(ut,{}),render:e=>(0,M.jsx)(lt,{groups:t??e.response.breakdown,showPct:n.has(`pct`),showTokens:n.has(`tokens`),showTurns:n.has(`turns`)})})]})})}function Q({label:e,active:t,onClick:n}){return(0,M.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full border px-2.5 py-1 text-label-medium-default`,style:{borderColor:t?`var(--content-secondary)`:`var(--border-base)`,background:t?`color-mix(in srgb, var(--content-secondary) 15%, transparent)`:`transparent`,color:t?`var(--content-default)`:`var(--content-tertiary)`},children:e})}function lt({groups:e,showPct:t,showTokens:n,showTurns:r}){if(e.length===0)return(0,M.jsx)(dt,{title:`No breakdown data`,subtitle:`No usage recorded for this grouping`});let i=e.reduce((e,t)=>e+t.totalEstimatedCostUsd,0);return(0,M.jsx)(`div`,{className:`overflow-hidden rounded-md`,children:(0,M.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{style:{borderBottom:`1px solid var(--border-base)`},children:[(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:`Group`}),n?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`35%`},children:`Tokens`}):null,r?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`72px`},children:`Turns`}):null,t?(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`64px`},children:`%`}):null,(0,M.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`100px`},children:`Cost`})]})}),(0,M.jsx)(`tbody`,{children:e.map((e,a)=>{let o=Oe(e),s=Ae(e),c=i>0?Math.round(e.totalEstimatedCostUsd/i*100):0;return(0,M.jsxs)(`tr`,{style:{borderTop:a===0?`none`:`1px solid var(--border-base)`},children:[(0,M.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-default)`},children:(0,M.jsx)(`span`,{className:`block truncate text-body-medium-lighter`,title:e.group,children:e.group})}),n?(0,M.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-secondary)`},children:(0,M.jsx)(`span`,{className:`block truncate text-body-small-default`,title:o,children:s})}):null,r?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e.turnCount==null?`—`:e.turnCount.toLocaleString()})}):null,t?(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsxs)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[c,`%`]})}):null,(0,M.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,M.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:S(e.totalEstimatedCostUsd)})})]},e.groupKey??e.groupId??`${e.group}-${a}`)})})]})})}function ut(){return(0,M.jsx)(`div`,{className:`flex flex-col gap-2`,"aria-hidden":`true`,children:Array.from({length:4}).map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)($,{width:100,height:14}),(0,M.jsx)($,{width:`60%`,height:12}),(0,M.jsx)($,{width:50,height:14})]},t))})}function $({width:e,height:t}){return(0,M.jsx)(`div`,{className:`rounded-sm`,style:{width:typeof e==`number`?`${e}px`:e,height:`${t}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}})}function dt({title:e,subtitle:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-1 py-8 text-center`,children:[(0,M.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),(0,M.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t})]})}function ft({message:e,onRetry:t}){return(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(c,{className:`h-4 w-4 shrink-0`,style:{color:`var(--system-negative-strong, #f87171)`}}),(0,M.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:e})]}),t?(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`self-start rounded-md border px-3 py-1 text-body-small-default`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`,color:`var(--content-default)`},children:`Retry`}):null]})}function pt(){return(0,M.jsx)(et,{assistantId:h()})}export{pt as UsagePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./edge-swipe-arbiter-store-CE52YiHe.js";import{Dn as r,On as i}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./edge-swipe-arbiter-store-CE52YiHe.js";import{Dn as r,On as i}from"./index-DZAcojtQ.js";var a=e(t(),1),o=200,s=180,c=200,l=.25,u=50;function d(e){e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.opacity=``}function f({containerRef:e,onBack:t,enabled:f,navKey:p}){let m=(0,a.useRef)(t);(0,a.useLayoutEffect)(()=>{m.current=t},[t]);let h=(0,a.useRef)(!1),g=(0,a.useRef)(new Set),_=(0,a.useRef)(!1),v=n.use.registerBackOwner(),y=n.use.unregisterBackOwner();(0,a.useEffect)(()=>{if(f)return v(),y},[f,v,y]),(0,a.useEffect)(()=>{_.current=!1;let t=g.current;return()=>{_.current=!0;for(let e of t)clearTimeout(e);t.clear();let n=e.current;n&&d(n)}},[e]);let b=(e,t)=>{let n=setTimeout(()=>{g.current.delete(n),_.current||e()},t);g.current.add(n)},x=(e,t)=>{e.style.transform=t===0?``:`translateX(${t}px)`},S=e=>{e.style.transition=`transform ${o}ms ease-out`,x(e,0);let t=()=>{e.removeEventListener(`transitionend`,t),d(e)};e.addEventListener(`transitionend`,t,{once:!0}),b(()=>d(e),o+u)},C=e=>{e.style.transition=`transform ${s}ms ease-in`,x(e,window.innerWidth);let t=!1,n=()=>{if(t||_.current)return;t=!0,e.removeEventListener(`transitionend`,n);let r=-(window.innerWidth*l);e.style.transition=`none`,e.style.transform=`translateX(${r}px)`,e.style.opacity=`0`,e.offsetWidth,h.current=!0,m.current(),b(()=>{h.current&&(h.current=!1,d(e))},c*2)};e.addEventListener(`transitionend`,n,{once:!0}),b(n,s+u)};i({enabled:f,onConfirm:()=>{let t=e.current;t&&(t.style.transition=`none`,t.style.willChange=`transform`)},onMove:(t,n)=>{let i=e.current;i&&x(i,r(t,n))},onCommit:()=>{let t=e.current;if(!t){m.current();return}C(t)},onCancel:t=>{let n=e.current;n&&(t?S(n):d(n))}}),(0,a.useLayoutEffect)(()=>{if(!h.current)return;h.current=!1;let t=e.current;if(!t)return;let n=!1,r=()=>{n||(n=!0,t.removeEventListener(`transitionend`,r),d(t))};t.style.transition=`transform ${c}ms ease-out, opacity ${c}ms ease-out`,t.style.transform=``,t.style.opacity=``,t.addEventListener(`transitionend`,r,{once:!0});let i=setTimeout(r,c+u);return()=>{clearTimeout(i),t.removeEventListener(`transitionend`,r),d(t)}},[p,e])}export{f as t};
|
package/dist/assets/{use-invite-link-dialog-BtmP79fG.js → use-invite-link-dialog-Cfjjavpg.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-amTXFI-2.js";import{n as r}from"./QueryClientProvider-DKhXIxGb.js";import{t as i}from"./useQuery-B45lW1Kk.js";import{t as a}from"./useMutation-Lj4VunQV.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./typography-D5f7kt80.js";import{t as c}from"./check-DFNrQERi.js";import{t as l}from"./copy-Cn1FKrEp.js";import{t as u}from"./link-2-4bMylQ5v.js";import{t as d}from"./loader-circle-Cz7opInR.js";import{t as f}from"./input-CoUmPnRU.js";import{t as p}from"./modal-D5nLWNN9.js";import{Kt as m,Qt as h,Xt as g}from"./sdk.gen-BwnFjFcp.js";import{G as _,K as v,U as y,W as b,o as x,s as S,x as C}from"./react-query.gen-C6wVk6Rw.js";import{n as w}from"./utils-xg2dl_KJ.js";import{n as T,r as E,t as D}from"./api-errors-CrWDzVca.js";import{n as O}from"./sdk.gen-CenbOmmb.js";import{t as k}from"./assistant-feature-flag-store-4edQKaeq.js";import{Nt as A,Pt as j,a as ee,ar as M,i as te,ir as N,o as ne,s as re}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-amTXFI-2.js";import{n as r}from"./QueryClientProvider-DKhXIxGb.js";import{t as i}from"./useQuery-B45lW1Kk.js";import{t as a}from"./useMutation-Lj4VunQV.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./typography-D5f7kt80.js";import{t as c}from"./check-DFNrQERi.js";import{t as l}from"./copy-Cn1FKrEp.js";import{t as u}from"./link-2-4bMylQ5v.js";import{t as d}from"./loader-circle-Cz7opInR.js";import{t as f}from"./input-CoUmPnRU.js";import{t as p}from"./modal-D5nLWNN9.js";import{Kt as m,Qt as h,Xt as g}from"./sdk.gen-BwnFjFcp.js";import{G as _,K as v,U as y,W as b,o as x,s as S,x as C}from"./react-query.gen-C6wVk6Rw.js";import{n as w}from"./utils-xg2dl_KJ.js";import{n as T,r as E,t as D}from"./api-errors-CrWDzVca.js";import{n as O}from"./sdk.gen-CenbOmmb.js";import{t as k}from"./assistant-feature-flag-store-4edQKaeq.js";import{Nt as A,Pt as j,a as ee,ar as M,i as te,ir as N,o as ne,s as re}from"./index-DZAcojtQ.js";import{t as P}from"./mutation-error-Bk_4pjgm.js";import{t as F}from"./a2a-invite-BgVgm24S.js";function I(e){return e?.trim()||`your assistant`}var L=e(t(),1),R=o(),z=[`no_one`,`guardian_only`,`trusted_contacts`,`any_contact`,`strangers`],B=`trusted_contacts`,V=new Set([`platform`,`a2a`]),H=new Set([`vellum`,`whatsapp`]);function U(e){return H.has(e)}var W={no_one:`No one`,guardian_only:`Only you`,trusted_contacts:`Verified contacts`,any_contact:`Any contact`,strangers:`Strangers`};function G(e){return{no_one:`No one can message ${e} on this channel — every message is blocked, including yours.`,guardian_only:`Only you can message ${e}. Everyone else is turned away.`,trusted_contacts:`You and the people you’ve verified can message ${e}. Anyone else is asked to verify first, and you’re notified.`,any_contact:`You and any known contact can message ${e}, including contacts you haven’t verified yet. Strangers are asked to verify first.`,strangers:`Anyone can message ${e}, including complete strangers.`}}function K(e){let t=e-Date.now();if(t<=0)return`Expired`;let n=Math.ceil(t/(1e3*60*60*24));return n===1?`Expires in 1 day`:`Expires in ${n} days`}function q({open:e,assistantId:t,onClose:r}){let[i,o]=(0,L.useState)(!1),u=(0,L.useRef)(null),m=(0,L.useRef)(!1),h=a({...y({path:{assistant_id:t}})}),g=(0,L.useRef)(h.mutate);(0,L.useLayoutEffect)(()=>{g.current=h.mutate});let _=(0,L.useRef)(h.reset);(0,L.useLayoutEffect)(()=>{_.current=h.reset}),(0,L.useEffect)(()=>{e&&!m.current&&g.current({path:{assistant_id:t}}),m.current=e},[e,t]),(0,L.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);let v=(0,L.useCallback)(()=>{_.current(),o(!1),u.current&&=(clearTimeout(u.current),null),r()},[r]),b=(0,L.useCallback)(e=>{navigator.clipboard.writeText(e).then(()=>{o(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>o(!1),2e3)})},[]),x=h.isSuccess&&h.data.token?F({senderAssistantId:t,token:h.data.token}):``;return(0,R.jsx)(p.Root,{open:e,onOpenChange:e=>{e||v()},children:(0,R.jsxs)(p.Content,{size:`sm`,children:[(0,R.jsx)(p.Header,{children:(0,R.jsx)(p.Title,{children:`Share Connection Link`})}),(0,R.jsx)(p.Body,{children:h.isPending?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[(0,R.jsx)(d,{className:`h-4 w-4 animate-spin`}),`Creating invite link…`]}):h.isError?(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsx)(`p`,{role:`alert`,className:`!m-0 text-body-medium-lighter`,style:{color:`var(--system-negative-strong)`},children:`Failed to create invite link. Make sure A2A is enabled for your assistant.`}),(0,R.jsx)(n,{variant:`outlined`,onClick:()=>h.mutate({path:{assistant_id:t}}),children:`Try Again`})]}):h.isSuccess?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(s,{variant:`body-medium-lighter`,style:{color:`var(--content-secondary)`},children:`Share this link with another assistant owner to establish a connection.`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(f,{type:`text`,readOnly:!0,value:x,fullWidth:!0,wrapperClassName:`flex-1`,className:`font-mono`,onFocus:e=>e.currentTarget.select()}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>b(x),"aria-label":`Copy invite link`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-[var(--border-base)] hover:bg-[var(--surface-hover)]`,children:i?(0,R.jsx)(c,{className:`h-4 w-4`}):(0,R.jsx)(l,{className:`h-4 w-4`})})]}),h.data.expiresAt!=null&&(0,R.jsx)(s,{variant:`body-small-default`,style:{color:`var(--content-tertiary)`},children:K(h.data.expiresAt)})]}):null}),(0,R.jsx)(p.Footer,{children:(0,R.jsx)(n,{variant:`outlined`,onClick:v,children:`Done`})})]})})}function J({onClick:e}){return(0,R.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:(0,R.jsx)(u,{className:`h-3.5 w-3.5`}),onClick:e,children:`Share Connection Link`})}function Y(e){return typeof e==`string`&&z.includes(e)}function X(e){return V.has(e)}function Z(e){return(e?.policies??[]).filter(e=>!X(e.channelType)&&!U(e.channelType)).map(e=>({...e,policy:Y(e.policy)?e.policy:`trusted_contacts`}))}async function ie(e,t,n,r){if(X(t))throw new D(403,`Channel "${t}" is internal and is not user-configurable.`);let{data:i,error:a,response:o}=await O({path:{assistant_id:e,channel_type:t},body:{policy:n,note:r??null},throwOnError:!1});if(T(o,a,`Failed to save channel policy.`),!o.ok)throw new D(o.status,E(a,o,`Failed to save channel policy.`));if(!i?.policy)throw new D(500,`Gateway returned no policy in response.`);return i.policy}var ae=`0.10.0`;function Q(){return w(ae)}function oe(e){let t=r(),n=k.use.channelTrustFloors(),o=Q(),s=n&&o,c=(0,L.useMemo)(()=>({path:{assistant_id:e}}),[e]),l=(0,L.useMemo)(()=>M(c),[c]),u=i({...N(c),enabled:s,select:Z}),d=(0,L.useMemo)(()=>{let e={};for(let t of u.data??[])j(t.channelType)&&(e[t.channelType]=t.policy);return e},[u.data]),f=a({mutationFn:({channelKey:t,policy:n})=>ie(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:l}),onError:P(`Failed to save channel policy`)}),p=(0,L.useCallback)((e,t)=>{f.mutate({channelKey:e,policy:t})},[f]);return s?{policies:d,savingKey:f.isPending?f.variables?.channelKey??null:null,isLoading:u.isPending,isError:u.isError,onChange:p}:{policies:void 0,savingKey:null,isLoading:!1,isError:!1,onChange:void 0}}var $={slack:`I want to reach you on Slack. Let's set it up.`,telegram:`I want to reach you on Telegram. Let's set it up.`,phone:`I want to be able to call you. Let's set you up with a phone number.`},se=15e3;function ce({assistantId:e,onStartSetupConversation:t}){let n=r(),o=(0,L.useMemo)(()=>({path:{assistant_id:e}}),[e]),s=(0,L.useMemo)(()=>S(o),[o]),c=i({...x(o),enabled:!!e,refetchInterval:se,select:e=>e.snapshots}),l=(0,L.useMemo)(()=>le(c.data??[]),[c.data]),u=l.some(e=>e.key===`slack`&&e.status===`ready`),d=i({...b(o),enabled:u,select:e=>e.threadMode}),f=oe(e),p=(0,L.useCallback)(()=>n.invalidateQueries({queryKey:s}),[n,s]),y=a({mutationFn:async t=>{let n={path:{assistant_id:e},throwOnError:!0};t===`slack`?await m(n):t===`telegram`?await g(n):t===`phone`&&await h(n)},onSettled:(t,r,i)=>{p(),i===`slack`&&re(n,e)}}),C=ee({assistantId:e}),w=ne({assistantId:e}),T=te({assistantId:e}),E=a({...v(),onSuccess:()=>{n.invalidateQueries({queryKey:_(o)})}}),D=C.mutateAsync,O=(0,L.useCallback)(async e=>{await D(e)},[D]),k=w.mutate,A=(0,L.useCallback)((e,t)=>{k({botToken:e,appToken:t})},[k]),j=E.mutate,M=(0,L.useCallback)(t=>{j({path:{assistant_id:e},body:{threadMode:t}})},[j,e]),N=T.mutateAsync,P=(0,L.useCallback)(async(e,t)=>{await N({accountSid:e,authToken:t})},[N]),F=(0,L.useCallback)(e=>{t&&t($[e])},[t]),I=y.mutate,R=(0,L.useCallback)(e=>{I(e)},[I]);return{channels:l,pendingChannelKey:y.isPending?y.variables??null:null,slackThreadMode:d.data,slackThreadModePending:E.isPending,channelPolicies:f.policies,policySavingKey:f.savingKey,policiesLoading:f.isLoading,policiesError:f.isError,onChannelPolicyChange:f.onChange,onSetup:t?F:void 0,onDisconnect:R,onSaveTelegramToken:O,onSaveSlackConfig:A,slackSaveStatus:w.status,slackSaveError:w.error?.message??null,onSlackThreadModeChange:M,onSaveTwilioCredentials:P}}function le(e){let t=new Map;for(let n of e)t.set(n.channel,n);return A.map(e=>{let n=t.get(e);return{key:e,status:ue(n),address:n?.channelHandle??void 0}})}function ue(e){return e?e.ready||e.setupStatus===`ready`?`ready`:e.setupStatus===`incomplete`?`incomplete`:`not_configured`:`not_configured`}function de(e){let t=r(),[n,i]=(0,L.useState)(!1);return{isOpen:n,open:(0,L.useCallback)(()=>{i(!0)},[]),close:(0,L.useCallback)(()=>{i(!1),t.invalidateQueries({queryKey:C({path:{assistant_id:e}})})},[t,e])}}export{J as a,z as c,I as d,Z as i,W as l,ce as n,q as o,Q as r,B as s,de as t,G as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{n}from"./QueryClientProvider-DKhXIxGb.js";import{t as r}from"./useMutation-Lj4VunQV.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./card-Bv5O5juh.js";import{t as o}from"./createLucideIcon-IRfcSUxS.js";import{t as s}from"./brain-BLDXGaUy.js";import{t as c}from"./globe-4qSOWE2N.js";import{t as l}from"./loader-circle-Cz7opInR.js";import{t as u}from"./triangle-alert-Z0Gq0IuB.js";import"./src-DZbMXyC2.js";import{t as d}from"./tag-CV4v7fRF.js";import{cr as f}from"./sdk.gen-BwnFjFcp.js";import{an as p}from"./react-query.gen-C6wVk6Rw.js";import{n as m,r as h,t as g}from"./api-errors-CrWDzVca.js";import{Pi as _,gi as v,yi as y}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{n}from"./QueryClientProvider-DKhXIxGb.js";import{t as r}from"./useMutation-Lj4VunQV.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./card-Bv5O5juh.js";import{t as o}from"./createLucideIcon-IRfcSUxS.js";import{t as s}from"./brain-BLDXGaUy.js";import{t as c}from"./globe-4qSOWE2N.js";import{t as l}from"./loader-circle-Cz7opInR.js";import{t as u}from"./triangle-alert-Z0Gq0IuB.js";import"./src-DZbMXyC2.js";import{t as d}from"./tag-CV4v7fRF.js";import{cr as f}from"./sdk.gen-BwnFjFcp.js";import{an as p}from"./react-query.gen-C6wVk6Rw.js";import{n as m,r as h,t as g}from"./api-errors-CrWDzVca.js";import{Pi as _,gi as v,yi as y}from"./index-DZAcojtQ.js";import{t as b}from"./skills-DSdrs4Rb.js";var x=o(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),S=e(t(),1),C=i(),w={vellum:{label:`Vellum`,icon:x},clawhub:{label:`Clawhub`,icon:c},skillssh:{label:`skills.sh`,icon:y},custom:{label:`Custom`,icon:v},"assistant-memory":{label:`Assistant's Memory`,icon:s}};function T({origin:e}){let t=e in w?w[e]:{label:e.replace(/-/g,` `),icon:_};return(0,C.jsx)(d,{tone:`neutral`,leftIcon:(0,S.createElement)(t.icon),className:`capitalize`,children:t.label})}function E(e){return e.kind===`installed`||e.kind===`bundled`}function D(e){return e.kind===`catalog`}function O({icon:e,iconColor:t=`var(--content-tertiary)`,title:n,subtitle:r,children:i}){return(0,C.jsx)(a.Root,{children:(0,C.jsxs)(a.Body,{className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,C.jsx)(e,{className:`mb-3 h-8 w-8`,style:{color:t},"aria-hidden":!0}),(0,C.jsx)(`h3`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:n}),(0,C.jsx)(`p`,{className:`mt-1 max-w-sm text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:r}),i]})})}function k(){return(0,C.jsx)(O,{icon:u,iconColor:`var(--system-danger)`,title:`Failed to load skills`,subtitle:`Something went wrong. Try refreshing the page.`})}function A(){return(0,C.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,C.jsx)(l,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})})}async function j(e,t,n){let{data:r,error:i,response:a}=await f({path:{assistant_id:e},body:n?{slug:t,version:n}:{slug:t},throwOnError:!1});if(m(a,i,`Failed to install skill.`),!a.ok)throw new g(a.status,h(i,a,`Failed to install skill.`));return r??{ok:!0}}function M(e,{onRemoved:t}={}){let i=n(),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(null),d=(0,S.useCallback)(()=>{b(i,e)},[e,i]),f=r({mutationFn:t=>j(e,t),onMutate:e=>o(e),onSettled:()=>{o(null),d()}}),m=p({onMutate:e=>c(e.path.id),onSuccess:()=>{t?.()},onSettled:()=>{c(null),d()}}),h=(0,S.useCallback)(e=>{f.mutate(e.slug??e.id)},[f]),g=(0,S.useCallback)(e=>{u(e)},[]),_=(0,S.useCallback)(()=>{l&&(m.mutate({path:{assistant_id:e,id:l.id}}),u(null))},[e,l,m]),v=(0,S.useCallback)(()=>{u(null)},[]);return{handleInstall:h,handleRemove:g,isInstallingSkill:(0,S.useCallback)(e=>a===(e.slug??e.id),[a]),isRemovingSkill:(0,S.useCallback)(e=>s===e.id,[s]),skillPendingRemoval:l,confirmRemove:_,cancelRemove:v}}export{D as a,x as c,O as i,A as n,E as o,k as r,T as s,M as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./button-amTXFI-2.js";import{t}from"./useQuery-B45lW1Kk.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./createLucideIcon-IRfcSUxS.js";import{t as i}from"./calendar-h-mv1itX.js";import{t as a}from"./code-Czx7d7SK.js";import{t as o}from"./globe-4qSOWE2N.js";import{t as s}from"./link-2-4bMylQ5v.js";import"./src-DZbMXyC2.js";import{xt as c}from"./react-query.gen-C6wVk6Rw.js";import{Gi as l,Hi as u,Oi as d,Ti as f,ea as p,ia as m,qi as h,ui as g}from"./index-
|
|
1
|
+
import{t as e}from"./button-amTXFI-2.js";import{t}from"./useQuery-B45lW1Kk.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./createLucideIcon-IRfcSUxS.js";import{t as i}from"./calendar-h-mv1itX.js";import{t as a}from"./code-Czx7d7SK.js";import{t as o}from"./globe-4qSOWE2N.js";import{t as s}from"./link-2-4bMylQ5v.js";import"./src-DZbMXyC2.js";import{xt as c}from"./react-query.gen-C6wVk6Rw.js";import{Gi as l,Hi as u,Oi as d,Ti as f,ea as p,ia as m,qi as h,ui as g}from"./index-DZAcojtQ.js";var _=r(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),v={mail:h,calendar:i,"message-circle":l,globe:o,zap:g,code:a,mic:u,"shopping-cart":f,palette:r(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),heart:m,settings:d,"link-2":s};function y(e){return v[e]}var b=n();function x({selected:e,onSelect:t,counts:n,totalCount:r,showCounts:i,categories:a,ariaLabel:o=`Skill categories`}){let s=[...a].sort((e,t)=>e.label.localeCompare(t.label));return(0,b.jsxs)(`nav`,{className:`flex flex-col gap-1`,"aria-label":o,children:[(0,b.jsx)(S,{icon:p,label:`All`,count:r,isActive:e===null,showCount:i,onClick:()=>t(null)}),s.map(r=>(0,b.jsx)(S,{icon:y(r.icon)??p,label:r.label,count:n[r.slug]??0,isActive:e===r.slug,showCount:i,onClick:()=>t(r.slug)},r.slug))]})}function S({icon:t,label:n,count:r,isActive:i,showCount:a,onClick:o}){return(0,b.jsxs)(e,{variant:`ghost`,onClick:o,"aria-pressed":i,className:`h-auto justify-between gap-3 rounded-lg border-0 bg-transparent px-3 py-2 text-left hover:bg-[var(--ghost-hover)]`,style:{backgroundColor:i?`var(--surface-active)`:void 0,color:i?`var(--content-default)`:`var(--content-secondary)`},children:[(0,b.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,b.jsx)(t,{className:`h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,b.jsx)(`span`,{className:`text-body-medium-default`,children:n})]}),a&&(0,b.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:r})]})}function C(e){return t({...c({path:{assistant_id:e}}),select:e=>e.categories,staleTime:300*1e3})}export{_ as i,x as n,y as r,C as t};
|
package/dist/assets/{use-skill-detail-files-iXFvM76E.js → use-skill-detail-files-DROqozrr.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as r}from"./useQuery-B45lW1Kk.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{vt as a,yt as o}from"./react-query.gen-C6wVk6Rw.js";import{c as s}from"./routes-DYcJgn9k.js";import{t as c}from"./misc-DnHIYCE9.js";import{Aa as l}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as r}from"./useQuery-B45lW1Kk.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{vt as a,yt as o}from"./react-query.gen-C6wVk6Rw.js";import{c as s}from"./routes-DYcJgn9k.js";import{t as c}from"./misc-DnHIYCE9.js";import{Aa as l}from"./index-DZAcojtQ.js";var u=i();function d({skill:e,className:t,onNavigate:r}){return e.origin!==`assistant-memory`||!e.sourceConversationId?null:(0,u.jsxs)(n,{to:s.conversation(e.sourceConversationId),onClick:r,className:c(`inline-flex w-fit items-center gap-1 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)] hover:underline`,t),children:[`Learned from this conversation`,(0,u.jsx)(l,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0})]})}var f=e(t(),1);function p(e,t){return t??e.find(e=>e.name===`SKILL.md`)?.path??null}function m(e,t){let[n,i]=(0,f.useState)(null),s=r({...o({path:{assistant_id:e??``,id:t}}),select:e=>e??null,enabled:!!e}),c=(0,f.useMemo)(()=>s.data?.files??[],[s.data]),l=(0,f.useMemo)(()=>c.find(e=>e.name===`SKILL.md`),[c]),u=p(c,n),d=r({...a({path:{assistant_id:e??``,id:t},query:{path:u??``}}),select:e=>e??null,enabled:!!(e&&u)});return{fileEntries:c,skillMd:l,selectedPath:n,setSelectedPath:i,activePath:u,activeFile:c.find(e=>e.path===u),isFilesLoading:s.isLoading,isFilesPending:s.isPending,fileContent:d.data?.content??null,isBinary:!!d.data?.isBinary,isContentLoading:d.isLoading,isContentPending:d.isPending}}export{d as n,m as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,r as n,s as r}from"./local-settings-lVNyIOJ_.js";import{t as i}from"./react-DJZBPgpf.js";import{t as a}from"./button-amTXFI-2.js";import{t as o}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{r as c}from"./middleware-pbPQ0upo.js";import{t as l}from"./info-DsOyuMO9.js";import{t as u}from"./toggle-CDfguvUz.js";import{t as d}from"./dropdown-ByHOpeOU.js";import{c as f}from"./routes-DYcJgn9k.js";import{Bn as p,Gn as m,Hn as h,Jn as g,Kn as _,O as v,Un as y,Vn as b,Wn as x,er as S,k as C,qn as w,tr as T,zn as E}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,r as n,s as r}from"./local-settings-lVNyIOJ_.js";import{t as i}from"./react-DJZBPgpf.js";import{t as a}from"./button-amTXFI-2.js";import{t as o}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{r as c}from"./middleware-pbPQ0upo.js";import{t as l}from"./info-DsOyuMO9.js";import{t as u}from"./toggle-CDfguvUz.js";import{t as d}from"./dropdown-ByHOpeOU.js";import{c as f}from"./routes-DYcJgn9k.js";import{Bn as p,Gn as m,Hn as h,Jn as g,Kn as _,O as v,Un as y,Vn as b,Wn as x,er as S,k as C,qn as w,tr as T,zn as E}from"./index-DZAcojtQ.js";import{t as D}from"./detail-card-GPqFZVmX.js";var O=e(i(),1),k=s(),A=`vellum:voice:conversationTimeoutSeconds`,j=[{label:`Ctrl`,activator:{kind:`modifierOnly`,modifiers:[`control`]}},{label:`Alt`,activator:{kind:`modifierOnly`,modifiers:[`option`]}},{label:`Ctrl+Shift`,activator:{kind:`modifierOnly`,modifiers:[`control`,`shift`]}}],M={label:`Fn`,activator:b},N=[{label:`5 seconds`,value:`5`},{label:`10 seconds`,value:`10`},{label:`15 seconds`,value:`15`},{label:`30 seconds`,value:`30`},{label:`60 seconds`,value:`60`}],P=`30`,F=`text-body-small-default text-[var(--content-tertiary)]`;function I(){return(0,k.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,k.jsx)(R,{}),(0,k.jsx)(B,{}),(0,k.jsx)(V,{}),(0,k.jsx)(U,{}),(0,k.jsx)(L,{})]})}function L(){return(0,k.jsx)(D,{title:`Transcription`,subtitle:`Show live text of what you and the assistant say during a voice conversation.`,children:(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(v,{showDescription:!0}),(0,k.jsx)(`p`,{className:`${F} pt-1`,children:C})]})})}function R(){return(0,k.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--field-bg)] px-3 py-2`,children:[(0,k.jsx)(l,{className:`h-3.5 w-3.5 shrink-0 text-[var(--primary-base)]`}),(0,k.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Looking to configure Speech-to-Text or Text-to-Speech models?`}),(0,k.jsxs)(o,{to:f.settings.ai,className:`inline-flex items-center gap-1 text-body-medium-lighter text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Go to Models & Services`,(0,k.jsx)(c,{className:`h-3 w-3`})]})]})}var z=``;function B(){let[e,n]=(0,O.useState)([]),[i,o]=(0,O.useState)(!1),[s,c]=(0,O.useState)(()=>T()),l=(0,O.useCallback)(async()=>{if(navigator.mediaDevices?.enumerateDevices)try{let e=(await navigator.mediaDevices.enumerateDevices()).filter(e=>e.kind===`audioinput`);o(e.length>0&&e.every(e=>!e.label)),n(e.filter(e=>e.deviceId!==``&&e.deviceId!==`default`&&e.deviceId!==`communications`))}catch{n([]),o(!1)}},[]),u=(0,O.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop()}catch{}l()},[l]);(0,O.useEffect)(()=>{l();let e=navigator.mediaDevices;if(!e?.addEventListener)return;let t=()=>void l();return e.addEventListener(`devicechange`,t),()=>e.removeEventListener(`devicechange`,t)},[l]);let f=(0,O.useMemo)(()=>[{value:z,label:`System Default`},...e.map((e,t)=>({value:e.deviceId,label:e.label||`Microphone ${t+1}`}))],[e]),p=(0,O.useCallback)(e=>{c(e),e===z?t(S):r(S,e)},[]);return(0,k.jsx)(D,{title:`Microphone`,subtitle:`Which input device is used for dictation and voice conversations.`,children:(0,k.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,k.jsx)(`div`,{className:`max-w-xs`,children:(0,k.jsx)(d,{options:f,value:f.some(e=>e.value===s)?s:z,onChange:p,"aria-label":`Microphone`})}),i&&(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(a,{variant:`outlined`,onClick:u,children:`Allow Microphone Access`}),(0,k.jsx)(`span`,{className:F,children:`Grant microphone access to list your available input devices.`})]})]})})}function V(){let e=E(),[t,i]=(0,O.useState)(()=>{let t=n(h,``);return t?_(t,{preserveFunction:e}):e?M.activator:{kind:`off`}}),[a,o]=(0,O.useState)(!1),[s,c]=(0,O.useState)([]),d=(0,O.useRef)(null),f=(0,O.useRef)(!1),v=(0,O.useMemo)(()=>e?[M,...j]:j,[e]),S=t.kind!==`off`,C=S&&!e,T=(0,O.useCallback)(e=>{i(e),r(h,w(e)),o(!1),c([])},[]),A=(0,O.useCallback)(()=>{o(!0),c([]),f.current=!1,requestAnimationFrame(()=>{d.current?.focus()})},[]),N=(0,O.useCallback)(()=>{o(!1),c([]),f.current=!1},[]),P=(0,O.useCallback)(t=>{let n=[];return e&&t.getModifierState(`Fn`)&&n.push(`function`),t.ctrlKey&&n.push(`control`),t.altKey&&n.push(`option`),t.shiftKey&&n.push(`shift`),t.metaKey&&n.push(`command`),n},[e]),I=(0,O.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){N();return}let t=P(e),n=e.key;if(n===`Control`||n===`Alt`||n===`Shift`||n===`Meta`||n===`Fn`){c(t.includes(`function`)?b.modifiers:g(t));return}if(t.includes(`function`)){T(b);return}f.current=!0,T({kind:`key`,label:n.length===1?n.toUpperCase():n,modifiers:t})},[N,P,T]),L=(0,O.useCallback)(e=>{if(!a)return;e.preventDefault(),e.stopPropagation();let t=e.key;if(t===`Control`||t===`Alt`||t===`Shift`||t===`Meta`||t===`Fn`){if(f.current){f.current=!1,c([]);return}P(e).length===0&&s.length>0&&T({kind:`modifierOnly`,modifiers:s})}},[P,a,s,T]);(0,O.useEffect)(()=>{if(!a)return;let e=e=>{d.current&&!d.current.contains(e.target)&&N()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[N,a]);let R=S&&!v.some(e=>x(e.activator,t));return(0,k.jsx)(D,{title:`Push to Talk`,subtitle:`Hold the activation key to dictate text or start a voice conversation.`,children:(0,k.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,k.jsx)(u,{checked:S,onChange:n=>{n?t.kind===`off`&&T(e?M.activator:p):T({kind:`off`})},label:`Enable Push to Talk`}),S&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:F,children:`Activation Key:`}),(0,k.jsxs)(`div`,{ref:d,tabIndex:a?0:-1,onKeyDown:a?I:void 0,onKeyUp:a?L:void 0,className:`flex flex-wrap items-center gap-2 focus:outline-none`,children:[v.map(e=>{let n=x(e.activator,t);return(0,k.jsx)(H,{label:e.label,selected:n,onClick:()=>T(e.activator)},e.label)}),a?(0,k.jsx)(H,{label:s.length>0?m(s):`Press any key…`,selected:!0,recording:!0,onClick:N}):(0,k.jsx)(H,{label:R?y(t):`Custom`,selected:R,onClick:A})]}),C&&(0,k.jsxs)(`div`,{className:`flex items-start gap-1 pt-1 text-body-small-default text-[var(--content-quiet)]`,children:[(0,k.jsx)(l,{className:`mt-0.5 h-3 w-3 shrink-0`}),(0,k.jsx)(`span`,{children:`Push-to-Talk only works while this tab is focused, and browsers may intercept some shortcuts (e.g. Ctrl+T) before the page can see them. For always-on PTT, use the Vellum desktop app.`})]})]})]})})}function H({label:e,selected:t,recording:n=!1,onClick:r}){return(0,k.jsxs)(`button`,{type:`button`,onClick:r,className:[`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 text-body-medium-lighter transition-colors`,`border-[var(--border-subtle)]`,t?`bg-[var(--surface-active)]`:`bg-[var(--surface-lift)] hover:bg-[var(--surface-hover)]`,n?`animate-pulse`:``].filter(Boolean).join(` `),children:[(0,k.jsx)(`span`,{className:[`inline-block h-2.5 w-2.5 rounded-full border`,t?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--border-element)]`].join(` `)}),(0,k.jsx)(`span`,{className:`text-[var(--content-default)]`,children:e})]})}function U(){let[e,t]=(0,O.useState)(()=>{let e=n(A,P);return N.find(t=>t.value===e)?.value??P});return(0,k.jsx)(D,{title:`Conversation Timeout`,subtitle:`How long the assistant waits for you to start speaking before ending a voice conversation turn.`,children:(0,k.jsx)(`div`,{className:`max-w-xs`,children:(0,k.jsx)(d,{options:N,value:e,onChange:(0,O.useCallback)(e=>{t(e),r(A,e)},[]),"aria-label":`Conversation timeout`})})})}export{I as VoicePage};
|
package/dist/assets/{weather-forecast-display-IOKkzlZQ.js → weather-forecast-display-DxWFsOIg.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./moon-B8qiwjrW.js";import{t as i}from"./misc-DnHIYCE9.js";import{Ci as a,G as o,J as s,K as c,_a as l,ba as u,bi as d,ga as f,ha as p,pa as m,pi as h,q as g,va as _,ya as v}from"./index-RjTgjtTV.js";var y=e(t(),1),b={"sun.max.fill":{icon:d,className:`text-orange-500`},"cloud.sun.fill":{icon:f,className:`text-amber-400`},"moon.fill":{icon:r,className:`text-blue-400`},"cloud.moon.fill":{icon:_,className:`text-blue-400`},"cloud.fill":{icon:p,className:`text-stone-400`},"cloud.rain.fill":{icon:l,className:`text-blue-400`},snowflake:{icon:a,className:`text-blue-300`},"cloud.bolt.fill":{icon:v,className:`text-orange-500`},"cloud.fog.fill":{icon:u,className:`text-stone-400`}},x={sunny:{icon:d,className:`text-orange-500`},clear:{icon:d,className:`text-orange-500`},"partly cloudy":{icon:f,className:`text-amber-400`},"mostly sunny":{icon:f,className:`text-amber-400`},cloudy:{icon:p,className:`text-stone-400`},overcast:{icon:p,className:`text-stone-400`},rainy:{icon:l,className:`text-blue-400`},rain:{icon:l,className:`text-blue-400`},drizzle:{icon:l,className:`text-blue-400`},snow:{icon:a,className:`text-blue-300`},snowy:{icon:a,className:`text-blue-300`},thunderstorm:{icon:v,className:`text-orange-500`},thunder:{icon:v,className:`text-orange-500`},foggy:{icon:u,className:`text-stone-400`},fog:{icon:u,className:`text-stone-400`},mist:{icon:u,className:`text-stone-400`},hazy:{icon:u,className:`text-stone-400`},night:{icon:r,className:`text-blue-400`},"mainly clear":{icon:d,className:`text-orange-500`},"mostly cloudy":{icon:p,className:`text-stone-400`},breezy:{icon:h,className:`text-stone-400`},windy:{icon:h,className:`text-stone-400`},cool:{icon:p,className:`text-stone-400`},warm:{icon:d,className:`text-orange-500`},hot:{icon:d,className:`text-orange-500`},cold:{icon:a,className:`text-blue-300`},"cold snap":{icon:a,className:`text-blue-300`},"warm, mostly sunny":{icon:f,className:`text-amber-400`},"cooler, breezy":{icon:h,className:`text-stone-400`}},S={icon:p,className:`text-stone-400`};function C(e){let t=b[e];if(t)return t;let n=e.toLowerCase(),r=x[n];if(r)return r;for(let[e,t]of Object.entries(x))if(n.includes(e))return t;return S}function w(e){if(typeof e==`string`){let t=e.match(/^(\d+)\s*mph\s*(.*)/i);if(t)return{speed:Number(t[1]),direction:t[2]?.trim()||void 0}}return{}}function T(e){let t;if(typeof e.location==`string`)t=e.location;else{let n=g(e.location);n&&typeof n.name==`string`&&(t=n.name)}if(!t)return null;let n=g(e.current),r=c(n?.temp)??c(e.currentTemp)??c(e.temperature)??c(e.temp),i=c(n?.feelsLike)??c(n?.feels_like)??c(n?.apparentTemperature)??c(e.feelsLike)??c(e.feels_like)??c(e.apparentTemperature),a=s(n?.condition)??s(e.condition),l=c(n?.humidity)??c(e.humidity),u=w(n?.wind??e.wind),d=c(n?.windSpeed)??c(n?.wind_speed)??c(e.windSpeed)??c(e.wind_speed)??u.speed,f=s(n?.windDirection)??s(n?.wind_direction)??s(e.windDirection)??s(e.wind_direction)??u.direction,p=g(e.units),m=s(p?.temperature)??s(n?.unit)??s(e.unit)??`F`,h=s(p?.speed)??s(e.windUnit)??s(e.wind_unit),_=o(e.hourly).map((e,t)=>({id:s(e.id)??String(t),time:s(e.time)??``,icon:s(e.icon)??s(e.condition)??`cloud.fill`,temp:c(e.tempC)??c(e.temp)??c(e.temperature),tempC:c(e.tempC)})),v=o([e.forecast,e.daily,e.days].find(Array.isArray)).map((e,t)=>({id:s(e.id)??String(t),day:s(e.day)??s(e.date),dayLabel:s(e.dayLabel)??s(e.date),icon:s(e.icon)??s(e.condition)??`cloud.fill`,low:c(e.low),high:c(e.high),lowC:c(e.lowC),highC:c(e.highC),precip:c(e.precip)??c(e.precipitation)??c(e.precipitationProbability),condition:s(e.condition)}));return{location:t,currentTemp:r,feelsLike:i,condition:a,humidity:l,windSpeed:d,windDirection:f,windUnit:h,unit:m,hourly:_.length>0?_:void 0,forecast:v.length>0?v:void 0}}function E(e){return e*9/5+32}function D(e){return(e-32)*5/9}function O(e,t,n){if(e===void 0)return null;let r=e;return t&&!n&&(r=D(e)),!t&&n&&(r=E(e)),`${Math.round(r)}`}function k(e,t,n){return e.tempC===void 0?e.temp===void 0?null:O(e.temp,t,n):O(e.tempC,!1,n)}function A(e,t,n){return e.lowC===void 0?O(e.low,t,n):O(e.lowC,!1,n)}function j(e,t,n){return e.highC===void 0?O(e.high,t,n):O(e.highC,!1,n)}var M=n();function N({icon:e,size:t=20}){let{icon:n,className:r}=C(e);return(0,M.jsx)(n,{width:t,height:t,className:r})}function P({useFahrenheit:e,onToggle:t}){return(0,M.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border border-[var(--border-element)]`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>t(!0),className:i(`px-2 py-0.5 text-body-small-default transition-colors`,e?`bg-[var(--primary-base)] text-[var(--content-inset)]`:`bg-transparent text-[var(--content-quiet)]`),children:`°F`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:i(`px-2 py-0.5 text-body-small-default transition-colors`,e?`bg-transparent text-[var(--content-quiet)]`:`bg-[var(--primary-base)] text-[var(--content-inset)]`),children:`°C`})]})}function F({data:e,sourceIsFahrenheit:t,useFahrenheit:n,onToggle:r}){let i=e.location,a=O(e.currentTemp,t,n),o=O(e.feelsLike,t,n),s=n?`F`:`C`,c=e.forecast?.[0],l=c?j(c,t,n):null,u=c?A(c,t,n):null,d=null;return e.windSpeed!==void 0&&(d=`${Math.round(e.windSpeed)} ${e.windUnit??`mph`}`,e.windDirection&&(d=`${e.windDirection} ${d}`)),(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:i}),a!==null&&(0,M.jsxs)(`div`,{className:`mt-1 text-4xl font-light text-[var(--content-default)]`,children:[a,`°`,s]}),e.condition&&(0,M.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-quiet)]`,children:e.condition})]}),(0,M.jsx)(P,{useFahrenheit:n,onToggle:r})]}),(0,M.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3`,children:[o!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-quiet)]`,children:[`Feels like `,o,`°`]}),l!==null&&u!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-quiet)]`,children:[`H:`,l,`° L:`,u,`°`]}),d&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2 py-0.5 text-label-medium-default text-[var(--content-tertiary)]`,children:[(0,M.jsx)(h,{width:12,height:12}),d]}),e.humidity!==void 0&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2 py-0.5 text-label-medium-default text-[var(--content-tertiary)]`,children:[(0,M.jsx)(m,{width:12,height:12}),e.humidity,`%`]})]})]})}function I({hourly:e,sourceIsFahrenheit:t,useFahrenheit:n}){return(0,M.jsx)(`div`,{className:`mt-3 border-t border-[var(--border-element)] pt-3`,children:(0,M.jsx)(`div`,{className:`flex gap-3 overflow-x-auto`,children:e.map((e,r)=>{let i=e.time.toLowerCase()===`now`,a=k(e,t,n);return(0,M.jsxs)(`div`,{className:`flex min-w-[3rem] shrink-0 flex-col items-center gap-1`,children:[(0,M.jsx)(`span`,{className:i?`text-body-small-emphasised text-[var(--content-default)]`:`text-label-medium-default text-[var(--content-quiet)]`,children:i?`Now`:e.time}),(0,M.jsx)(N,{icon:e.icon,size:18}),a!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-default)]`,children:[a,`°`]})]},e.id??r)})})})}function L({forecast:e,currentTemp:t,sourceIsFahrenheit:n,useFahrenheit:r}){let{globalMin:a,globalMax:o}=(0,y.useMemo)(()=>{let t=1/0,n=-1/0;for(let r of e){let e=r.lowC??r.low,i=r.highC??r.high;e!==void 0&&e<t&&(t=e),i!==void 0&&i>n&&(n=i)}return{globalMin:t===1/0?0:t,globalMax:n===-1/0?100:n}},[e]),s=o-a||1;return(0,M.jsx)(`div`,{className:`mt-3 border-t border-[var(--border-element)] pt-3`,children:(0,M.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map((e,c)=>{let l=e.dayLabel??e.day??`Day ${c+1}`,u=l.toLowerCase()===`today`,d=A(e,n,r),f=j(e,n,r),p=e.precip,m=e.lowC??e.low??a,h=e.highC??e.high??o,g=(m-a)/s*100,_=(h-a)/s*100,v=Math.max(_-g,2),y=null;if(u&&t!==void 0){let r=(e.lowC!==void 0||e.highC!==void 0)&&n?(t-32)*5/9:t;y=h===m?50:(Math.max(m,Math.min(h,r))-m)/(h-m)*100}return(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`span`,{className:i(`w-12 shrink-0 truncate text-body-small-default`,u?`text-[var(--content-default)]`:`text-[var(--content-quiet)]`),children:l}),(0,M.jsxs)(`div`,{className:`flex w-10 shrink-0 items-center justify-center gap-0.5`,children:[(0,M.jsx)(N,{icon:e.icon,size:16}),p!==void 0&&p>0&&(0,M.jsxs)(`span`,{className:`text-label-small-default text-blue-400`,children:[Math.round(p),`%`]})]}),(0,M.jsx)(`span`,{className:`w-7 shrink-0 text-right text-body-small-default text-[var(--content-faint)]`,children:d===null?`--`:`${d}°`}),(0,M.jsxs)(`div`,{className:`relative h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--border-subtle)]`,children:[(0,M.jsx)(`div`,{className:`absolute top-0 h-full rounded-full bg-[var(--primary-base)]`,style:{left:`${g}%`,width:`${v}%`}}),y!==null&&(0,M.jsx)(`div`,{className:`absolute top-1/2 h-2.5 w-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-[var(--aux-white)] bg-[var(--aux-white)] shadow-sm`,style:{left:`${g+y/100*v}%`}})]}),(0,M.jsx)(`span`,{className:`w-7 shrink-0 text-right text-body-small-default text-[var(--content-default)]`,children:f===null?`--`:`${f}°`})]},e.id??c)})})})}function R({templateData:e,fallback:t}){let n=(0,y.useMemo)(()=>T(e),[e]),r=n?.unit?.toUpperCase()===`F`||n?.unit?.toLowerCase()===`fahrenheit`,[i,a]=(0,y.useState)(null),o=i??r;return!n||n.currentTemp===void 0&&!n.forecast?.length?t??null:(0,M.jsxs)(`div`,{className:`mt-3`,children:[(0,M.jsx)(F,{data:n,sourceIsFahrenheit:r,useFahrenheit:o,onToggle:a}),n.hourly&&n.hourly.length>0&&(0,M.jsx)(I,{hourly:n.hourly,sourceIsFahrenheit:r,useFahrenheit:o}),n.forecast&&n.forecast.length>0&&(0,M.jsx)(L,{forecast:n.forecast,currentTemp:n.currentTemp,sourceIsFahrenheit:r,useFahrenheit:o})]})}export{R as WeatherForecastDisplay};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./moon-B8qiwjrW.js";import{t as i}from"./misc-DnHIYCE9.js";import{Ci as a,G as o,J as s,K as c,_a as l,ba as u,bi as d,ga as f,ha as p,pa as m,pi as h,q as g,va as _,ya as v}from"./index-DZAcojtQ.js";var y=e(t(),1),b={"sun.max.fill":{icon:d,className:`text-orange-500`},"cloud.sun.fill":{icon:f,className:`text-amber-400`},"moon.fill":{icon:r,className:`text-blue-400`},"cloud.moon.fill":{icon:_,className:`text-blue-400`},"cloud.fill":{icon:p,className:`text-stone-400`},"cloud.rain.fill":{icon:l,className:`text-blue-400`},snowflake:{icon:a,className:`text-blue-300`},"cloud.bolt.fill":{icon:v,className:`text-orange-500`},"cloud.fog.fill":{icon:u,className:`text-stone-400`}},x={sunny:{icon:d,className:`text-orange-500`},clear:{icon:d,className:`text-orange-500`},"partly cloudy":{icon:f,className:`text-amber-400`},"mostly sunny":{icon:f,className:`text-amber-400`},cloudy:{icon:p,className:`text-stone-400`},overcast:{icon:p,className:`text-stone-400`},rainy:{icon:l,className:`text-blue-400`},rain:{icon:l,className:`text-blue-400`},drizzle:{icon:l,className:`text-blue-400`},snow:{icon:a,className:`text-blue-300`},snowy:{icon:a,className:`text-blue-300`},thunderstorm:{icon:v,className:`text-orange-500`},thunder:{icon:v,className:`text-orange-500`},foggy:{icon:u,className:`text-stone-400`},fog:{icon:u,className:`text-stone-400`},mist:{icon:u,className:`text-stone-400`},hazy:{icon:u,className:`text-stone-400`},night:{icon:r,className:`text-blue-400`},"mainly clear":{icon:d,className:`text-orange-500`},"mostly cloudy":{icon:p,className:`text-stone-400`},breezy:{icon:h,className:`text-stone-400`},windy:{icon:h,className:`text-stone-400`},cool:{icon:p,className:`text-stone-400`},warm:{icon:d,className:`text-orange-500`},hot:{icon:d,className:`text-orange-500`},cold:{icon:a,className:`text-blue-300`},"cold snap":{icon:a,className:`text-blue-300`},"warm, mostly sunny":{icon:f,className:`text-amber-400`},"cooler, breezy":{icon:h,className:`text-stone-400`}},S={icon:p,className:`text-stone-400`};function C(e){let t=b[e];if(t)return t;let n=e.toLowerCase(),r=x[n];if(r)return r;for(let[e,t]of Object.entries(x))if(n.includes(e))return t;return S}function w(e){if(typeof e==`string`){let t=e.match(/^(\d+)\s*mph\s*(.*)/i);if(t)return{speed:Number(t[1]),direction:t[2]?.trim()||void 0}}return{}}function T(e){let t;if(typeof e.location==`string`)t=e.location;else{let n=g(e.location);n&&typeof n.name==`string`&&(t=n.name)}if(!t)return null;let n=g(e.current),r=c(n?.temp)??c(e.currentTemp)??c(e.temperature)??c(e.temp),i=c(n?.feelsLike)??c(n?.feels_like)??c(n?.apparentTemperature)??c(e.feelsLike)??c(e.feels_like)??c(e.apparentTemperature),a=s(n?.condition)??s(e.condition),l=c(n?.humidity)??c(e.humidity),u=w(n?.wind??e.wind),d=c(n?.windSpeed)??c(n?.wind_speed)??c(e.windSpeed)??c(e.wind_speed)??u.speed,f=s(n?.windDirection)??s(n?.wind_direction)??s(e.windDirection)??s(e.wind_direction)??u.direction,p=g(e.units),m=s(p?.temperature)??s(n?.unit)??s(e.unit)??`F`,h=s(p?.speed)??s(e.windUnit)??s(e.wind_unit),_=o(e.hourly).map((e,t)=>({id:s(e.id)??String(t),time:s(e.time)??``,icon:s(e.icon)??s(e.condition)??`cloud.fill`,temp:c(e.tempC)??c(e.temp)??c(e.temperature),tempC:c(e.tempC)})),v=o([e.forecast,e.daily,e.days].find(Array.isArray)).map((e,t)=>({id:s(e.id)??String(t),day:s(e.day)??s(e.date),dayLabel:s(e.dayLabel)??s(e.date),icon:s(e.icon)??s(e.condition)??`cloud.fill`,low:c(e.low),high:c(e.high),lowC:c(e.lowC),highC:c(e.highC),precip:c(e.precip)??c(e.precipitation)??c(e.precipitationProbability),condition:s(e.condition)}));return{location:t,currentTemp:r,feelsLike:i,condition:a,humidity:l,windSpeed:d,windDirection:f,windUnit:h,unit:m,hourly:_.length>0?_:void 0,forecast:v.length>0?v:void 0}}function E(e){return e*9/5+32}function D(e){return(e-32)*5/9}function O(e,t,n){if(e===void 0)return null;let r=e;return t&&!n&&(r=D(e)),!t&&n&&(r=E(e)),`${Math.round(r)}`}function k(e,t,n){return e.tempC===void 0?e.temp===void 0?null:O(e.temp,t,n):O(e.tempC,!1,n)}function A(e,t,n){return e.lowC===void 0?O(e.low,t,n):O(e.lowC,!1,n)}function j(e,t,n){return e.highC===void 0?O(e.high,t,n):O(e.highC,!1,n)}var M=n();function N({icon:e,size:t=20}){let{icon:n,className:r}=C(e);return(0,M.jsx)(n,{width:t,height:t,className:r})}function P({useFahrenheit:e,onToggle:t}){return(0,M.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border border-[var(--border-element)]`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>t(!0),className:i(`px-2 py-0.5 text-body-small-default transition-colors`,e?`bg-[var(--primary-base)] text-[var(--content-inset)]`:`bg-transparent text-[var(--content-quiet)]`),children:`°F`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:i(`px-2 py-0.5 text-body-small-default transition-colors`,e?`bg-transparent text-[var(--content-quiet)]`:`bg-[var(--primary-base)] text-[var(--content-inset)]`),children:`°C`})]})}function F({data:e,sourceIsFahrenheit:t,useFahrenheit:n,onToggle:r}){let i=e.location,a=O(e.currentTemp,t,n),o=O(e.feelsLike,t,n),s=n?`F`:`C`,c=e.forecast?.[0],l=c?j(c,t,n):null,u=c?A(c,t,n):null,d=null;return e.windSpeed!==void 0&&(d=`${Math.round(e.windSpeed)} ${e.windUnit??`mph`}`,e.windDirection&&(d=`${e.windDirection} ${d}`)),(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:i}),a!==null&&(0,M.jsxs)(`div`,{className:`mt-1 text-4xl font-light text-[var(--content-default)]`,children:[a,`°`,s]}),e.condition&&(0,M.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-quiet)]`,children:e.condition})]}),(0,M.jsx)(P,{useFahrenheit:n,onToggle:r})]}),(0,M.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3`,children:[o!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-quiet)]`,children:[`Feels like `,o,`°`]}),l!==null&&u!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-quiet)]`,children:[`H:`,l,`° L:`,u,`°`]}),d&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2 py-0.5 text-label-medium-default text-[var(--content-tertiary)]`,children:[(0,M.jsx)(h,{width:12,height:12}),d]}),e.humidity!==void 0&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2 py-0.5 text-label-medium-default text-[var(--content-tertiary)]`,children:[(0,M.jsx)(m,{width:12,height:12}),e.humidity,`%`]})]})]})}function I({hourly:e,sourceIsFahrenheit:t,useFahrenheit:n}){return(0,M.jsx)(`div`,{className:`mt-3 border-t border-[var(--border-element)] pt-3`,children:(0,M.jsx)(`div`,{className:`flex gap-3 overflow-x-auto`,children:e.map((e,r)=>{let i=e.time.toLowerCase()===`now`,a=k(e,t,n);return(0,M.jsxs)(`div`,{className:`flex min-w-[3rem] shrink-0 flex-col items-center gap-1`,children:[(0,M.jsx)(`span`,{className:i?`text-body-small-emphasised text-[var(--content-default)]`:`text-label-medium-default text-[var(--content-quiet)]`,children:i?`Now`:e.time}),(0,M.jsx)(N,{icon:e.icon,size:18}),a!==null&&(0,M.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-default)]`,children:[a,`°`]})]},e.id??r)})})})}function L({forecast:e,currentTemp:t,sourceIsFahrenheit:n,useFahrenheit:r}){let{globalMin:a,globalMax:o}=(0,y.useMemo)(()=>{let t=1/0,n=-1/0;for(let r of e){let e=r.lowC??r.low,i=r.highC??r.high;e!==void 0&&e<t&&(t=e),i!==void 0&&i>n&&(n=i)}return{globalMin:t===1/0?0:t,globalMax:n===-1/0?100:n}},[e]),s=o-a||1;return(0,M.jsx)(`div`,{className:`mt-3 border-t border-[var(--border-element)] pt-3`,children:(0,M.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map((e,c)=>{let l=e.dayLabel??e.day??`Day ${c+1}`,u=l.toLowerCase()===`today`,d=A(e,n,r),f=j(e,n,r),p=e.precip,m=e.lowC??e.low??a,h=e.highC??e.high??o,g=(m-a)/s*100,_=(h-a)/s*100,v=Math.max(_-g,2),y=null;if(u&&t!==void 0){let r=(e.lowC!==void 0||e.highC!==void 0)&&n?(t-32)*5/9:t;y=h===m?50:(Math.max(m,Math.min(h,r))-m)/(h-m)*100}return(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`span`,{className:i(`w-12 shrink-0 truncate text-body-small-default`,u?`text-[var(--content-default)]`:`text-[var(--content-quiet)]`),children:l}),(0,M.jsxs)(`div`,{className:`flex w-10 shrink-0 items-center justify-center gap-0.5`,children:[(0,M.jsx)(N,{icon:e.icon,size:16}),p!==void 0&&p>0&&(0,M.jsxs)(`span`,{className:`text-label-small-default text-blue-400`,children:[Math.round(p),`%`]})]}),(0,M.jsx)(`span`,{className:`w-7 shrink-0 text-right text-body-small-default text-[var(--content-faint)]`,children:d===null?`--`:`${d}°`}),(0,M.jsxs)(`div`,{className:`relative h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--border-subtle)]`,children:[(0,M.jsx)(`div`,{className:`absolute top-0 h-full rounded-full bg-[var(--primary-base)]`,style:{left:`${g}%`,width:`${v}%`}}),y!==null&&(0,M.jsx)(`div`,{className:`absolute top-1/2 h-2.5 w-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-[var(--aux-white)] bg-[var(--aux-white)] shadow-sm`,style:{left:`${g+y/100*v}%`}})]}),(0,M.jsx)(`span`,{className:`w-7 shrink-0 text-right text-body-small-default text-[var(--content-default)]`,children:f===null?`--`:`${f}°`})]},e.id??c)})})})}function R({templateData:e,fallback:t}){let n=(0,y.useMemo)(()=>T(e),[e]),r=n?.unit?.toUpperCase()===`F`||n?.unit?.toLowerCase()===`fahrenheit`,[i,a]=(0,y.useState)(null),o=i??r;return!n||n.currentTemp===void 0&&!n.forecast?.length?t??null:(0,M.jsxs)(`div`,{className:`mt-3`,children:[(0,M.jsx)(F,{data:n,sourceIsFahrenheit:r,useFahrenheit:o,onToggle:a}),n.hourly&&n.hourly.length>0&&(0,M.jsx)(I,{hourly:n.hourly,sourceIsFahrenheit:r,useFahrenheit:o}),n.forecast&&n.forecast.length>0&&(0,M.jsx)(L,{forecast:n.forecast,currentTemp:n.currentTemp,sourceIsFahrenheit:r,useFahrenheit:o})]})}export{R as WeatherForecastDisplay};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./button-amTXFI-2.js";import{d as t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{u as r}from"./local-mode-Bskd5bsT.js";import{c as i}from"./routes-DYcJgn9k.js";import{t as a}from"./use-onboarding-login-DHS-9ToL.js";import{in as o}from"./index-
|
|
1
|
+
import{t as e}from"./button-amTXFI-2.js";import{d as t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{u as r}from"./local-mode-Bskd5bsT.js";import{c as i}from"./routes-DYcJgn9k.js";import{t as a}from"./use-onboarding-login-DHS-9ToL.js";import{in as o}from"./index-DZAcojtQ.js";var s=n();function c(){let n=t(),{loading:c,error:l,login:u,cancel:d}=a();return(0,s.jsx)(o,{children:(0,s.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-xl flex-col items-center px-6 pb-40 text-[var(--content-default)]`,children:(0,s.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center`,children:[(0,s.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Welcome to Vellum`}),(0,s.jsx)(`p`,{className:`mt-3 text-body-medium-lighter text-[var(--content-tertiary)]`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Your own personal intelligence is just a step away.`}),l&&(0,s.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:l}),(0,s.jsxs)(`div`,{className:`mt-10 flex w-full max-w-sm flex-col gap-3`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[(0,s.jsx)(e,{variant:`primary`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:c?d:()=>void u(),children:c?`Cancel`:`Log In`}),(0,s.jsx)(e,{variant:`ghost`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:()=>{c&&d(),r()?n(i.selectAssistant):n(i.onboarding.hosting)},children:`Continue without account`})]})]})})})}export{c as WelcomeScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-amTXFI-2.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./typography-D5f7kt80.js";import{t as a}from"./arrow-left-DI9551VI.js";import{n as o,r as s,t as c}from"./metric-card-cvhtzRdM.js";import{t as l}from"./ban-CVKGuUAQ.js";import{t as u}from"./chevron-right-DqqmezXC.js";import{t as d}from"./circle-check-VSiny8yl.js";import{t as f}from"./triangle-alert-Z0Gq0IuB.js";import{t as p}from"./x-CkSVp1Ok.js";import"./src-DZbMXyC2.js";import{n as m,r as h,t as g}from"./workflow-status-PqQ1OqJN.js";import{t as _}from"./proxy-Cadlowdl.js";import{t as v}from"./AnimatePresence-TZWSGjkI.js";import{t as y}from"./use-reduced-motion-BPBlq9_a.js";import{t as b}from"./three-dot-indicator-BuZzHFUJ.js";import{Ma as x,Si as S,et as C,fi as w,hi as T,nt as E,rt as D}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-amTXFI-2.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./typography-D5f7kt80.js";import{t as a}from"./arrow-left-DI9551VI.js";import{n as o,r as s,t as c}from"./metric-card-cvhtzRdM.js";import{t as l}from"./ban-CVKGuUAQ.js";import{t as u}from"./chevron-right-DqqmezXC.js";import{t as d}from"./circle-check-VSiny8yl.js";import{t as f}from"./triangle-alert-Z0Gq0IuB.js";import{t as p}from"./x-CkSVp1Ok.js";import"./src-DZbMXyC2.js";import{n as m,r as h,t as g}from"./workflow-status-PqQ1OqJN.js";import{t as _}from"./proxy-Cadlowdl.js";import{t as v}from"./AnimatePresence-TZWSGjkI.js";import{t as y}from"./use-reduced-motion-BPBlq9_a.js";import{t as b}from"./three-dot-indicator-BuZzHFUJ.js";import{Ma as x,Si as S,et as C,fi as w,hi as T,nt as E,rt as D}from"./index-DZAcojtQ.js";import{t as O}from"./status-badge-pill-B_ninpnM.js";var k=e(t(),1),A=r();function j({onClick:e,ariaLabel:t}){return(0,A.jsxs)(`button`,{type:`button`,"aria-label":t,onClick:e,className:`flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border border-[var(--system-negative-strong)] bg-transparent px-2.5 py-1.5 text-[var(--system-negative-strong)] transition-colors hover:bg-[var(--system-negative-weak)]`,children:[(0,A.jsx)(S,{className:`h-3 w-3`,fill:`currentColor`}),(0,A.jsx)(i,{variant:`label-small-default`,children:`Stop`})]})}function M({title:e,body:t,emptyText:n}){return(0,A.jsxs)(`div`,{className:`mb-5`,children:[(0,A.jsx)(i,{variant:`body-medium-default`,as:`h3`,className:`mb-2 text-[var(--content-emphasised)]`,children:e}),t?(0,A.jsx)(i,{variant:`body-medium-lighter`,as:`p`,className:`whitespace-pre-wrap break-words leading-relaxed text-[var(--content-default)]`,children:t}):(0,A.jsx)(i,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-tertiary)]`,children:n})]})}function N({leaf:e}){let t=e.status===`running`?`Running…`:`No result summary`;return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`mb-5 grid grid-cols-2 gap-3`,children:[(0,A.jsx)(c,{icon:(0,A.jsx)(x,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.inputTokens??0,format:e=>o(Math.round(e)),label:`Input`}),(0,A.jsx)(c,{icon:(0,A.jsx)(s,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.outputTokens??0,format:e=>o(Math.round(e)),label:`Output`})]}),(0,A.jsx)(M,{title:`Prompt`,body:e.promptSummary,emptyText:`No prompt summary`}),(0,A.jsx)(M,{title:`Result`,body:e.resultSummary,emptyText:t})]})}function P({status:e}){return(0,A.jsx)(O,{color:m(e),label:h(e)})}function F(e){switch(e){case`completed`:return`var(--system-positive-strong)`;case`failed`:return`var(--system-negative-strong)`;case`cancelled`:return`var(--content-secondary)`;default:return`var(--primary-base)`}}function I(e){switch(e){case`completed`:return`Completed`;case`failed`:return`Failed`;case`cancelled`:return`Cancelled`;default:return`Running`}}function L({status:e}){return(0,A.jsx)(O,{color:F(e),label:I(e)})}function R({status:e}){let t=y(),n=`h-3.5 w-3.5 shrink-0`,r;return r=e===`running`?(0,A.jsx)(b,{className:`shrink-0`,dotSize:4,gap:2}):e===`completed`?(0,A.jsx)(d,{className:n,style:{color:`var(--system-positive-strong)`}}):e===`failed`?(0,A.jsx)(f,{className:n,style:{color:`var(--system-negative-strong)`}}):(0,A.jsx)(l,{className:n,style:{color:`var(--content-secondary)`},role:`img`,"aria-label":`Cancelled`}),(0,A.jsx)(v,{mode:`wait`,initial:!1,children:(0,A.jsx)(_.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t?{duration:0}:{duration:.15,ease:[.16,1,.3,1]},className:`flex shrink-0 items-center`,children:r},e)})}function z({runId:e,leaf:t,components:n,onSelect:r}){let a=t.label??`Subagent ${t.seq}`,o=t.promptSummary,s=C(`${e}:${t.seq}`);return(0,A.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Open ${a} details`,className:`flex w-full cursor-pointer items-center justify-between gap-2 rounded-[6px] px-2 py-1.5 text-left transition-colors hover:bg-[var(--surface-overlay)]`,children:(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,A.jsx)(R,{status:t.status}),n?(0,A.jsx)(D,{components:n,bodyShapeId:s.bodyShape,eyeStyleId:s.eyeStyle,colorId:s.color,size:16}):(0,A.jsx)(`div`,{style:{width:16,height:16,flexShrink:0},"aria-hidden":!0}),(0,A.jsx)(i,{variant:`body-medium-default`,title:a,className:`max-w-[60%] shrink-0 truncate text-[var(--content-default)]`,children:a}),o&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-[var(--content-tertiary)] opacity-10`,children:`|`}),(0,A.jsx)(i,{variant:`body-medium-lighter`,title:o,className:`min-w-0 truncate text-[var(--content-tertiary)]`,children:o})]})]})})}function B({entry:e,onClose:t,onStop:r,onRequestJournal:l}){let d=g(e.status),f=y(),m=e.label??e.runId,h=e.agentsSpawned||e.leaves.size,v=E(),b=[...e.leaves.values()].sort((e,t)=>e.seq-t.seq),[S,O]=(0,k.useState)(null),[M,F]=(0,k.useState)(e.runId);M!==e.runId&&(F(e.runId),O(null));let I=S==null?void 0:e.leaves.get(S),R=I?C(`${e.runId}:${I.seq}`):void 0,B=(0,k.useCallback)(()=>O(null),[]),V=I?I.label??`Subagent ${I.seq}`:``,H=I?V:m,U=d?`live`:`final`;return(0,k.useEffect)(()=>{l?.(e.runId)},[e.runId,U,l]),(0,A.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden rounded-xl bg-[var(--surface-lift)]`,children:[I&&(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--border-hover)] px-5 py-3`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:B,title:m,className:`min-w-0 shrink cursor-pointer truncate text-left text-[var(--content-default)] hover:underline`,children:(0,A.jsx)(i,{variant:`body-small-default`,as:`span`,children:m})}),(0,A.jsx)(u,{className:`h-2.5 w-2.5 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,A.jsx)(i,{variant:`body-small-default`,as:`span`,title:V,className:`min-w-0 shrink truncate text-[var(--content-secondary)]`,children:V})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-hover)] px-5 py-4`,children:[I&&(0,A.jsx)(n,{variant:`outlined`,iconOnly:(0,A.jsx)(a,{}),onClick:B,"aria-label":`Back to subagents`,tooltip:`Back`,className:`shrink-0 rounded-lg`}),I?v&&R?(0,A.jsx)(D,{components:v,bodyShapeId:R.bodyShape,eyeStyleId:R.eyeStyle,colorId:R.color,size:32}):(0,A.jsx)(`div`,{style:{width:32,height:32,flexShrink:0},"aria-hidden":!0}):(0,A.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-[6px] bg-[var(--surface-overlay)]`,children:(0,A.jsx)(w,{className:`h-4 w-4`,style:{color:`var(--content-secondary)`}})}),(0,A.jsx)(i,{variant:`title-medium`,title:H,className:`min-w-0 shrink truncate text-[var(--content-default)]`,children:H}),I?(0,A.jsx)(L,{status:I.status}):(0,A.jsx)(P,{status:e.status}),(0,A.jsx)(`span`,{className:`flex-1`}),d&&r&&(0,A.jsx)(j,{onClick:()=>r(e.runId),ariaLabel:`Stop workflow`}),(0,A.jsx)(n,{variant:`outlined`,iconOnly:(0,A.jsx)(p,{}),onClick:t,"aria-label":`Close workflow detail`,tooltip:`Close`,className:`shrink-0 rounded-lg`})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-5`,children:(0,A.jsx)(_.div,{initial:{opacity:0},animate:{opacity:1},transition:f?{duration:0}:{duration:.18,ease:[.16,1,.3,1]},children:I?(0,A.jsx)(N,{leaf:I}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`mb-5 grid grid-cols-3 gap-3`,children:[(0,A.jsx)(c,{icon:(0,A.jsx)(x,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.inputTokens,format:e=>o(Math.round(e)),label:`Input`}),(0,A.jsx)(c,{icon:(0,A.jsx)(s,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:e.outputTokens,format:e=>o(Math.round(e)),label:`Output`}),(0,A.jsx)(c,{icon:(0,A.jsx)(T,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),target:h,format:e=>o(Math.round(e)),label:`Agents`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(i,{variant:`body-medium-default`,as:`h3`,className:`mb-4 text-[var(--content-emphasised)]`,children:`Subagents`}),b.length===0?(0,A.jsx)(i,{variant:`body-small-default`,className:`py-4 text-center text-[var(--content-tertiary)]`,children:`No subagents yet`}):(0,A.jsx)(`div`,{className:`flex flex-col gap-1`,children:b.map(t=>(0,A.jsx)(z,{runId:e.runId,leaf:t,components:v,onSelect:()=>O(t.seq)},t.seq))})]})]})},I?String(I.seq):`list`)})]})}export{B as WorkflowDetailPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-amTXFI-2.js";import{h as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./queryOptions-BtNi-_9H.js";import{t as l}from"./createLucideIcon-IRfcSUxS.js";import{t as u}from"./chevron-down-qD-re7AW.js";import{t as d}from"./chevron-right-DqqmezXC.js";import{t as f}from"./menu-Dy5QbnTj.js";import{t as p}from"./download-CAuK-nZ6.js";import{t as m}from"./file-text-CYJz-GvF.js";import{t as h}from"./file-DsyJLS2u.js";import{t as g}from"./loader-circle-Cz7opInR.js";import{t as _}from"./pencil-CUIr0IFo.js";import{t as v}from"./plus-DItfr5ux.js";import{t as y}from"./x-CkSVp1Ok.js";import{E as b}from"./src-DZbMXyC2.js";import{t as x}from"./input-CoUmPnRU.js";import{t as S}from"./modal-D5nLWNN9.js";import{n as C,t as w}from"./panel-item-CouW2A55.js";import{t as T}from"./confirm-dialog-CSkhRFRk.js";import{n as E,t as D}from"./file-markdown-ZKvQUuGy.js";import{Ar as O,Fr as k,Mr as A,Or as j,Pr as M,jr as N,kr as P}from"./sdk.gen-BwnFjFcp.js";import{n as F}from"./native-file-H6DBFhbO.js";import{Ai as I,br as L,ca as R,da as ee,mi as z,ra as B,sa as V,ua as te,vi as ne}from"./index-RjTgjtTV.js";import{t as H}from"./use-active-assistant-id-CGeH4Gl6.js";import{n as U,t as W}from"./mobile-sidebar-drawer-5UcOVnnQ.js";import{i as G,n as re,r as K,t as q}from"./file-editor-CgjwckHX.js";import{t as J}from"./format-file-size-BLrV7wUA.js";var ie=l(`arrow-down-a-z`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M20 8h-5`,key:`1vsyxs`}],[`path`,{d:`M15 10V6.5a2.5 2.5 0 0 1 5 0V10`,key:`ag13bf`}],[`path`,{d:`M15 14h5l-5 6h5`,key:`ur5jdg`}]]),ae=l(`arrow-down-wide-narrow`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M11 4h10`,key:`1w87gc`}],[`path`,{d:`M11 8h7`,key:`djye34`}],[`path`,{d:`M11 12h4`,key:`q8tih4`}]]),oe=l(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Y=l(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),X=e(t(),1);async function se(e){let{data:t,error:n}=await P({path:{assistant_id:e.assistantId},query:{path:e.path,...e.showHidden?{showHidden:`true`}:{}},parseAs:`blob`,throwOnError:!1});if(n||!(t instanceof Blob))throw Error(`Failed to download file`);await F(t,e.filename)}function ce(e){if(!e)return``;let t=e.indexOf(`;`);return(t===-1?e:e.slice(0,t)).trim()}function le(e,t){return ce(t)===`application/json`?!0:(e??``).toLowerCase().endsWith(`.json`)}function ue(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function de(e){return e.split(`/`).some(e=>e.startsWith(`.`))}var Z=s();function fe(e){return c({queryFn:async()=>{let{data:t,error:n}=await O({path:e.path,query:{path:e.query.path,...e.query.showHidden?{showHidden:`true`}:{}}});if(n)throw n;return t},queryKey:[`assistantsWorkspaceFileRetrieve`,e]})}function pe({mimeType:e}){let t=e.indexOf(`;`),n=(t===-1?e:e.slice(0,t)).trim(),r=m;return n.startsWith(`image/`)?r=B:n.startsWith(`video/`)?r=z:!n.startsWith(`text/`)&&n!==`application/json`&&n!==`application/octet-stream`&&(r=h),(0,Z.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 10%, transparent)`},children:(0,Z.jsx)(r,{className:`h-3.5 w-3.5`,style:{color:`var(--content-default)`}})})}function me({viewMode:e,onChange:t}){return(0,Z.jsx)(`div`,{className:`inline-flex rounded-md p-0.5`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 6%, transparent)`},children:[`preview`,`source`].map(r=>{let i=e===r;return(0,Z.jsx)(n,{variant:`ghost`,onClick:()=>t(r),className:`h-auto rounded border-0 px-2.5 py-1 text-body-small-default hover:bg-transparent`,style:{backgroundColor:i?`var(--surface-lift)`:`transparent`,color:i?`var(--content-default)`:`var(--content-tertiary)`,boxShadow:i?`0 1px 2px rgba(0,0,0,0.15)`:void 0},children:r===`preview`?`Preview`:`Source`},r)})})}function Q({name:e,mimeType:t,size:n,rightContent:r}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(pe,{mimeType:t}),(0,Z.jsx)(`span`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),n!=null&&(0,Z.jsx)(`span`,{className:`shrink-0 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:J(n)})]}),r]})}function he({assistantId:e,path:t,mimeType:n,showHidden:r}){let{data:i,isLoading:o}=a({queryFn:async()=>{let n=await P({path:{assistant_id:e},query:{path:t,...r?{showHidden:`true`}:{}},parseAs:`blob`});if(n.error)throw n.error;return n.data},queryKey:[`assistantsWorkspaceFileContentRetrieve`,{assistantId:e,path:t,showHidden:r}],enabled:!!t}),[s,c]=(0,X.useState)(null);return(0,X.useEffect)(()=>{if(!i)return;let e=URL.createObjectURL(i);return c(e),()=>{URL.revokeObjectURL(e),c(null)}},[i]),o?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Z.jsx)(g,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):s?n.startsWith(`image/`)?(0,Z.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Z.jsx)(`img`,{src:s,alt:t.split(`/`).pop()??`image`,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n.startsWith(`video/`)?(0,Z.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Z.jsx)(`video`,{src:s,controls:!0,className:`max-h-[70vh] max-w-full rounded`})}):null:null}function ge({assistantId:e,path:t,name:r,mimeType:i,size:a,modifiedAt:o,showHidden:s}){let[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),f=(0,X.useCallback)(async()=>{d(!1),l(!0);try{await se({assistantId:e,path:t,filename:r,showHidden:s})}catch{d(!0)}finally{l(!1)}},[e,t,r,s]);return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:r,mimeType:i,size:a}),(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,Z.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg border p-6 text-center`,style:{borderColor:`var(--border-base)`,backgroundColor:`var(--surface-lift)`},children:[(0,Z.jsx)(h,{className:`mx-auto h-10 w-10`,style:{color:`var(--content-tertiary)`}}),(0,Z.jsx)(`p`,{className:`mt-3 text-body-medium-default`,style:{color:`var(--content-default)`},children:r}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:i}),(0,Z.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:J(a,`Unknown size`)}),o&&(0,Z.jsxs)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:[`Modified: `,new Date(o).toLocaleString()]})]}),(0,Z.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:c?(0,Z.jsx)(g,{className:`animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(p,{"aria-hidden":!0}),onClick:f,disabled:c,"aria-label":`Download ${r}`,className:`mt-4`,children:c?`Downloading…`:`Download`}),u&&(0,Z.jsx)(`p`,{className:`mt-2 text-body-small-default`,style:{color:`var(--system-error)`},children:`Download failed. Try again.`})]})})]})}function _e({assistantId:e,selectedPath:t,showHidden:r,viewMode:s,onChangeViewMode:c,onBrowse:l,pathRename:u,pathDelete:d}){let f=i(),{data:p,isLoading:m}=a({...fe({path:{assistant_id:e},query:{path:t??``,showHidden:r}}),enabled:!!t}),[h,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(null);(0,X.useEffect)(()=>{if(!u)return;let{from:e,to:t}=u,n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;_(e=>e==null?e:n(e)),y(e=>e==null?e:{...e,path:n(e.path)})},[u]),(0,X.useEffect)(()=>{if(!d)return;let{path:e}=d,t=t=>t===e||t.startsWith(`${e}/`);_(e=>e!=null&&t(e)?null:e),y(e=>e!=null&&t(e.path)?null:e)},[d]);let b=h!=null&&h===t,x=p?.content??``,S=v?.path===t?v.content:x,C=()=>{_(null),y(null)},w=o({mutationFn:async({path:t,content:n})=>{let{error:r,response:i}=await k({path:{assistant_id:e},body:{path:t,content:n,encoding:`utf8`},throwOnError:!1});if(!i?.ok||r)throw Error(`Failed to save file`)},onSuccess:(e,t)=>{_(e=>e===t.path?null:e),y(e=>e?.path===t.path?null:e),f.invalidateQueries({queryKey:[`assistantsWorkspaceFileRetrieve`]})}}),T=S!==x,O=(0,X.useCallback)(()=>{t&&T&&!w.isPending&&w.mutate({path:t,content:S})},[t,T,w,S]);if(!t)return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view`}),l&&(0,Z.jsx)(n,{type:`button`,onClick:l,leftIcon:(0,Z.jsx)(oe,{"aria-hidden":!0}),className:`sm:hidden`,children:`Browse files`})]});if(m)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(g,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})});if(!p)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`File not found`})});let A=p.mimeType??`application/octet-stream`,j=p.name??t.split(`/`).pop()??t,M=E(j,A),N=le(j,A),P=p.content!=null&&!M&&!N,F=t?de(t):!0,I=b&&(0,Z.jsx)(re,{isDirty:T,isSaving:w.isPending,error:w.isError?`Save failed`:null,onSave:O,onDiscard:C});if(M&&p.content!=null){let e=b?S:p.content;return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:j,mimeType:A,rightContent:(0,Z.jsx)(me,{viewMode:s,onChange:e=>{b&&C(),c(e)}})}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:e,fileName:j,mimeType:A,showEdit:!F&&s===`source`,isEditing:b,onToggleEdit:()=>b?C():_(t)}),s===`preview`?(0,Z.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:(0,Z.jsx)(D,{content:e})}):b?(0,Z.jsx)(K,{value:S,onChange:e=>y({path:t,content:e}),onSave:O}):(0,Z.jsx)(G,{content:p.content,readOnly:F,onStartEdit:()=>_(t)})]}),I]})}if(N&&p.content!=null){let e=b?S:p.content,n=ue(e);return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:j,mimeType:A,rightContent:(0,Z.jsx)(me,{viewMode:s,onChange:e=>{b&&C(),c(e)}})}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:s===`preview`?n:e,downloadContent:e,fileName:j,mimeType:A,showEdit:!F&&s===`source`,isEditing:b,onToggleEdit:()=>b?C():_(t)}),s===`preview`?(0,Z.jsx)(G,{content:n,readOnly:!0,whiteSpace:`pre`}):b?(0,Z.jsx)(K,{value:S,onChange:e=>y({path:t,content:e}),onSave:O}):(0,Z.jsx)(G,{content:p.content,readOnly:F,onStartEdit:()=>_(t)})]}),I]})}return P?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:j,mimeType:A,size:p.size}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:b?S:p.content??``,fileName:j,mimeType:A,showEdit:!F,isEditing:b,onToggleEdit:()=>b?C():_(t)}),b?(0,Z.jsx)(K,{value:S,onChange:e=>y({path:t,content:e}),onSave:O}):(0,Z.jsx)(G,{content:p.content??``,readOnly:F,onStartEdit:()=>_(t)})]}),I]}):A.startsWith(`image/`)||A.startsWith(`video/`)?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:j,mimeType:A,size:p.size}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Z.jsx)(he,{assistantId:e,path:t,mimeType:A,showHidden:r})})]}):(0,Z.jsx)(ge,{assistantId:e,path:t,name:j,mimeType:A,size:p.size,modifiedAt:p.modifiedAt,showHidden:r})}function ve(e,t){if(t===`name`)return e;let n=e.slice();return n.sort((e,t)=>{let n=e.size??null,r=t.size??null;return n===null&&r===null?(e.name??``).localeCompare(t.name??``):n===null?1:r===null?-1:n===r?(e.name??``).localeCompare(t.name??``):r-n}),n}function ye(e){return c({queryFn:async()=>{let t={};e.query?.path&&(t.path=e.query.path),e.query?.showHidden&&(t.showHidden=`true`),e.query?.includeDirSizes&&(t.includeDirSizes=`true`);let{data:n,error:r}=await M({path:e.path,query:t});if(r)throw r;if(!n)throw Error(`Failed to load workspace tree`);return n},queryKey:[`assistantsWorkspaceTreeRetrieve`,e]})}async function be(e,t,n,r){let i=n.toLowerCase(),a=r?.toLowerCase(),{data:o}=await M({path:{assistant_id:e},query:t?{path:t}:{}});if(o?.entries?.some(e=>{let t=(e.name??``).toLowerCase();return t===i&&t!==a}))throw Error(`"${n}" already exists here.`)}function xe({entry:e}){return e.type===`directory`?(0,Z.jsx)(V,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`image/`)?(0,Z.jsx)(B,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`video/`)?(0,Z.jsx)(z,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(m,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}})}function Se({entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:f,onRequestRename:p,onRequestCreate:m,depth:h}){let g=e.path??``,v=e.name??``,y=e.type===`directory`,x=n.has(g),S=r===g,C=v.startsWith(`.`),w=!de(g),T=y&&(x||s.length>0),{data:E}=a({...ye({path:{assistant_id:t},query:{path:g,showHidden:i,includeDirSizes:o===`size`}}),enabled:y&&T}),D=(0,X.useMemo)(()=>ve(E?.entries??[],o),[E?.entries,o]),O=s===``||v.toLowerCase().includes(s);if(s!==``&&!y&&!O)return null;let k=(0,Z.jsxs)(`button`,{onClick:()=>{y?c(g):l(g)},className:`flex w-full items-center gap-1.5 px-2 py-1 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{paddingLeft:`${h*14+8}px`,paddingRight:`8px`,color:S?`var(--content-default)`:C?`var(--content-tertiary)`:`var(--content-default)`,backgroundColor:S?`color-mix(in oklab, var(--primary-base) 12%, transparent)`:void 0,opacity:C&&!S?.7:1},children:[y?T?(0,Z.jsx)(u,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(d,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(`span`,{className:`h-3 w-3 shrink-0`}),(0,Z.jsx)(xe,{entry:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v}),e.size!=null&&(0,Z.jsx)(`span`,{className:`shrink-0 text-label-medium-default tabular-nums`,style:{color:`var(--content-tertiary)`},children:J(e.size)})]});return(0,Z.jsxs)(`div`,{children:[w?(0,Z.jsxs)(b.Root,{children:[(0,Z.jsx)(b.Trigger,{children:k}),(0,Z.jsxs)(b.Content,{children:[y&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(b.Item,{leftIcon:(0,Z.jsx)(R,{className:`h-3.5 w-3.5`}),onSelect:()=>m({kind:`file`,parentPath:g}),children:`New File`}),(0,Z.jsx)(b.Item,{leftIcon:(0,Z.jsx)(Y,{className:`h-3.5 w-3.5`}),onSelect:()=>m({kind:`folder`,parentPath:g}),children:`New Folder`}),(0,Z.jsx)(b.Separator,{})]}),(0,Z.jsx)(b.Item,{leftIcon:(0,Z.jsx)(ne,{className:`h-3.5 w-3.5`}),onSelect:()=>f({path:g,name:v,isDirectory:y}),children:`Delete`}),(0,Z.jsx)(b.Item,{leftIcon:(0,Z.jsx)(_,{className:`h-3.5 w-3.5`}),onSelect:()=>p({path:g,name:v,isDirectory:y}),children:`Rename`})]})]}):k,y&&T&&D.length>0&&(0,Z.jsx)(`div`,{children:D.map(e=>(0,Z.jsx)(Se,{entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:f,onRequestRename:p,onRequestCreate:m,depth:h+1},e.path))})]})}function Ce({title:e,placeholder:t,confirmLabel:r,pendingLabel:i,initialName:a,onCancel:o,onConfirm:s,pending:c,error:l}){let u=(0,X.useRef)(null),[d,f]=(0,X.useState)(a??``),p=d.trim(),m=p.length>0&&(/[/\\]/.test(p)||p===`.`||p===`..`),h=p.length>0&&!m&&!c;return(0,Z.jsx)(S.Root,{open:!0,onOpenChange:e=>{!e&&!c&&o()},children:(0,Z.jsx)(S.Content,{size:`sm`,hideCloseButton:!0,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault();let t=u.current;t&&(t.focus(),requestAnimationFrame(()=>{t.setSelectionRange(0,t.value.length)}))},onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),c||o()},children:(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h&&s(p)},children:[(0,Z.jsx)(S.Header,{children:(0,Z.jsx)(S.Title,{children:e})}),(0,Z.jsx)(S.Body,{children:(0,Z.jsx)(x,{ref:u,label:`Name`,value:d,onChange:e=>f(e.target.value),placeholder:t,errorText:l??(m?`Enter a single file or folder name without slashes.`:void 0),autoComplete:`off`,spellCheck:!1,fullWidth:!0})}),(0,Z.jsxs)(S.Footer,{children:[(0,Z.jsx)(n,{type:`button`,variant:`outlined`,onClick:o,disabled:c,children:`Cancel`}),(0,Z.jsx)(n,{type:`submit`,variant:`primary`,disabled:!h,children:c?i:r})]})]})})})}function $({assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,onToggleExpand:l,onExpandPath:u,onSelectPath:d,onToggleShowHidden:f,onChangeSortMode:p,onPathDeleted:m,onPathRenamed:h}){let g=i(),[_,v]=(0,X.useState)(``),b=_.trim().toLowerCase(),[S,C]=(0,X.useState)(!1),[w,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(null),M=(0,X.useCallback)(()=>{E(null),O(null)},[]),{data:P,isLoading:F}=a(ye({path:{assistant_id:e},query:{showHidden:s,includeDirSizes:c===`size`}})),L=(0,X.useMemo)(()=>ve(P?.entries??[],c),[P?.entries,c]),R=(0,X.useCallback)(()=>{for(let e of[`assistantsWorkspaceTreeRetrieve`,`assistantsWorkspaceFileRetrieve`,`assistantsWorkspaceFileContentRetrieve`])g.invalidateQueries({queryKey:[e]})},[g]),z=o({mutationFn:async t=>{let n=t.parentPath?`${t.parentPath}/${t.name}`:t.name;await be(e,t.parentPath,t.name);let{error:r,response:i}=t.kind===`file`?await k({path:{assistant_id:e},body:{path:n,content:``,encoding:`utf8`},throwOnError:!1}):await N({path:{assistant_id:e},body:{path:n},throwOnError:!1});if(r||!i?.ok)throw Error(typeof r==`string`?r:`Failed to create — check the name and try again.`);return{...t,path:n}},onSuccess:e=>{M(),R(),e.parentPath&&u(e.parentPath),e.kind===`file`?d(e.path):u(e.path)},onError:e=>{O(e instanceof Error?e.message:`Failed to create.`)}}),B=o({mutationFn:async t=>{let n=t.oldPath.lastIndexOf(`/`),r=n===-1?``:t.oldPath.slice(0,n),i=t.oldPath.slice(n+1),a=r?`${r}/${t.newName}`:t.newName;await be(e,r,t.newName,i);let{error:o,response:s}=await A({path:{assistant_id:e},body:{oldPath:t.oldPath,newPath:a},throwOnError:!1});if(o||!s?.ok)throw Error(typeof o==`string`?o:`Failed to rename — check the name and try again.`);return{oldPath:t.oldPath,newPath:a}},onSuccess:({oldPath:e,newPath:t})=>{M(),R(),h(e,t)},onError:e=>{O(e instanceof Error?e.message:`Failed to rename.`)}}),V=(0,X.useCallback)(e=>{O(null),E({type:`create`,...e})},[]),ne=(0,X.useCallback)(e=>{O(null),E({type:`rename`,path:e.path,name:e.name})},[]),[H,U]=(0,X.useState)(null),W=o({mutationFn:async t=>{let{error:n,response:r}=await j({path:{assistant_id:e},body:{path:t.path},throwOnError:!1});if(n||!r?.ok)throw Error(typeof n==`string`?n:`Failed to delete — try again.`);return t},onSuccess:e=>{U(null),R(),m(e.path)}}),G=(0,X.useCallback)(e=>{W.reset(),U(e)},[W]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:`Files`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:c===`size`?(0,Z.jsx)(ae,{"aria-hidden":!0}):(0,Z.jsx)(ie,{"aria-hidden":!0}),onClick:()=>p(c===`size`?`name`:`size`),"aria-label":c===`size`?`Sort by name`:`Sort by size`,title:c===`size`?`Sorted by size — switch to name`:`Sorted by name — switch to size`,tintColor:c===`size`?`var(--content-default)`:`var(--content-tertiary)`}),(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:s?(0,Z.jsx)(te,{"aria-hidden":!0}):(0,Z.jsx)(ee,{"aria-hidden":!0}),onClick:f,"aria-label":s?`Hide hidden files`:`Show hidden files`,title:s?`Hide hidden files`:`Show hidden files`,tintColor:s?`var(--content-default)`:`var(--content-tertiary)`}),(0,Z.jsx)(we,{open:S,onOpenChange:C,onSelectKind:e=>{C(!1),V({kind:e,parentPath:``})}})]})]}),(0,Z.jsx)(`div`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(x,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`Search files`,leftIcon:(0,Z.jsx)(I,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0,spellCheck:!1,autoComplete:`off`}),_&&(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(y,{"aria-hidden":!0}),onClick:()=>v(``),"aria-label":`Clear search`,className:`absolute right-1.5 top-1/2 -translate-y-1/2`,tintColor:`var(--content-tertiary)`})]})}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:F?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`,style:{color:`var(--content-tertiary)`}})}):L.length?L.map(n=>(0,Z.jsx)(Se,{entry:n,assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,searchLower:b,onToggleExpand:l,onSelectPath:d,onRequestDelete:G,onRequestRename:ne,onRequestCreate:V,depth:0},n.path)):(0,Z.jsx)(`p`,{className:`px-3 py-4 text-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`No files found`})}),w?.type===`create`&&(0,Z.jsx)(Ce,{title:w.kind===`file`?`New File`:`New Folder`,placeholder:w.kind===`file`?`filename.md`:`folder-name`,confirmLabel:`Create`,pendingLabel:`Creating…`,onCancel:M,onConfirm:e=>{O(null),z.mutate({kind:w.kind,parentPath:w.parentPath,name:e})},pending:z.isPending,error:D},`create-${w.kind}-${w.parentPath}`),w?.type===`rename`&&(0,Z.jsx)(Ce,{title:`Rename`,placeholder:w.name,confirmLabel:`Rename`,pendingLabel:`Renaming…`,initialName:w.name,onCancel:M,onConfirm:e=>{if(e===w.name){M();return}O(null),B.mutate({oldPath:w.path,newName:e})},pending:B.isPending,error:D},`rename-${w.path}`),(0,Z.jsx)(T,{open:H!==null,title:H?.isDirectory?`Delete Folder`:`Delete File`,message:(0,Z.jsxs)(Z.Fragment,{children:[`Are you sure you want to delete`,` `,(0,Z.jsx)(`span`,{style:{color:`var(--content-default)`},children:H?.name}),H?.isDirectory?` and all of its contents`:``,`? This cannot be undone.`,W.error&&(0,Z.jsx)(`span`,{className:`mt-2 block`,style:{color:`var(--system-negative-strong)`},children:W.error.message})]}),confirmLabel:W.isPending?`Deleting…`:`Delete`,destructive:!0,isPending:W.isPending,onConfirm:()=>{H&&W.mutate(H)},onCancel:()=>U(null)})]})}function we({open:e,onOpenChange:t,onSelectKind:r}){return L()?(0,Z.jsxs)(C.Root,{open:e,onOpenChange:t,children:[(0,Z.jsx)(C.Trigger,{asChild:!0,children:(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(v,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Z.jsxs)(C.Content,{children:[(0,Z.jsx)(C.Header,{className:`sr-only`,children:(0,Z.jsx)(C.Title,{children:`Create new`})}),(0,Z.jsxs)(C.Body,{className:`pt-0`,children:[(0,Z.jsx)(w,{icon:R,label:`New File`,onSelect:()=>r(`file`)}),(0,Z.jsx)(w,{icon:Y,label:`New Folder`,onSelect:()=>r(`folder`)})]})]})]}):(0,Z.jsxs)(f.Root,{open:e,onOpenChange:t,children:[(0,Z.jsx)(f.Trigger,{asChild:!0,children:(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(v,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Z.jsxs)(f.Content,{align:`end`,sideOffset:4,children:[(0,Z.jsx)(f.Item,{leftIcon:(0,Z.jsx)(R,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`file`),children:`New File`}),(0,Z.jsx)(f.Item,{leftIcon:(0,Z.jsx)(Y,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`folder`),children:`New Folder`})]})]})}function Te(e){let t=e.split(`/`),n=new Set;for(let e=1;e<t.length;e++)n.add(t.slice(0,e).join(`/`));return n}function Ee({assistantId:e}){let[t,n]=r(),[i,a]=(0,X.useState)(()=>{let e=t.get(`file`);return e?Te(e):new Set}),[o,s]=(0,X.useState)(()=>t.get(`file`)),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(()=>t.get(`sort`)===`size`?`size`:`name`),[f,p]=(0,X.useState)(`preview`);(0,X.useEffect)(()=>{t.get(`file`)&&n(e=>{let t=new URLSearchParams(e);return t.delete(`file`),t},{replace:!0})},[]);let m=(0,X.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),h=(0,X.useCallback)(e=>{a(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),[g,_]=(0,X.useState)(!1),v=(0,X.useCallback)(e=>{s(e),_(!1)},[]),[y,b]=(0,X.useState)(null),x=(0,X.useCallback)(e=>{let t=t=>t===e||t.startsWith(`${e}/`);s(e=>e!==null&&t(e)?null:e),a(e=>{let n=new Set([...e].filter(e=>!t(e)));return n.size===e.size?e:n}),b({path:e})},[]),[S,C]=(0,X.useState)(null),w={assistantId:e,expandedPaths:i,selectedPath:o,showHidden:c,sortMode:u,onToggleExpand:m,onExpandPath:h,onSelectPath:v,onToggleShowHidden:()=>l(e=>!e),onChangeSortMode:d,onPathDeleted:x,onPathRenamed:(0,X.useCallback)((e,t)=>{let n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;s(e=>e===null?e:n(e)),a(e=>{let t=!1,r=new Set;for(let i of e){let e=n(i);e!==i&&(t=!0),r.add(e)}return t?r:e}),C({from:e,to:t})},[])};return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-4`,children:[(0,Z.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,Z.jsx)(U,{onClick:()=>_(!0)})}),(0,Z.jsx)(W,{open:g,onClose:()=>_(!1),title:`Files`,children:(0,Z.jsx)($,{...w})}),(0,Z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-4 sm:grid-cols-[320px_1fr]`,children:[(0,Z.jsx)(`div`,{className:`hidden min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border sm:flex`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Z.jsx)($,{...w})}),(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Z.jsx)(_e,{assistantId:e,selectedPath:o,showHidden:c,viewMode:f,onChangeViewMode:p,onBrowse:()=>_(!0),pathRename:S,pathDelete:y})})]})]})}function De(){return(0,Z.jsx)(Ee,{assistantId:H()})}export{De as WorkspacePage};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-amTXFI-2.js";import{h as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./queryOptions-BtNi-_9H.js";import{t as l}from"./createLucideIcon-IRfcSUxS.js";import{t as u}from"./chevron-down-qD-re7AW.js";import{t as d}from"./chevron-right-DqqmezXC.js";import{t as f}from"./menu-Dy5QbnTj.js";import{t as p}from"./download-CAuK-nZ6.js";import{t as m}from"./file-text-CYJz-GvF.js";import{t as h}from"./file-DsyJLS2u.js";import{t as g}from"./loader-circle-Cz7opInR.js";import{t as _}from"./pencil-CUIr0IFo.js";import{t as v}from"./plus-DItfr5ux.js";import{t as y}from"./x-CkSVp1Ok.js";import{E as b}from"./src-DZbMXyC2.js";import{t as x}from"./input-CoUmPnRU.js";import{t as S}from"./modal-D5nLWNN9.js";import{n as C,t as w}from"./panel-item-CouW2A55.js";import{t as T}from"./confirm-dialog-CSkhRFRk.js";import{n as E,t as D}from"./file-markdown-ZKvQUuGy.js";import{Ar as O,Fr as k,Mr as A,Or as j,Pr as M,jr as N,kr as P}from"./sdk.gen-BwnFjFcp.js";import{n as F}from"./native-file-H6DBFhbO.js";import{Ai as I,br as L,ca as R,da as ee,mi as z,ra as B,sa as V,ua as te,vi as ne}from"./index-DZAcojtQ.js";import{t as H}from"./use-active-assistant-id-CGeH4Gl6.js";import{n as U,t as W}from"./mobile-sidebar-drawer-pUdMI0nM.js";import{i as G,n as re,r as K,t as q}from"./file-editor-CgjwckHX.js";import{t as J}from"./format-file-size-BLrV7wUA.js";var ie=l(`arrow-down-a-z`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M20 8h-5`,key:`1vsyxs`}],[`path`,{d:`M15 10V6.5a2.5 2.5 0 0 1 5 0V10`,key:`ag13bf`}],[`path`,{d:`M15 14h5l-5 6h5`,key:`ur5jdg`}]]),ae=l(`arrow-down-wide-narrow`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M11 4h10`,key:`1w87gc`}],[`path`,{d:`M11 8h7`,key:`djye34`}],[`path`,{d:`M11 12h4`,key:`q8tih4`}]]),oe=l(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Y=l(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),X=e(t(),1);async function se(e){let{data:t,error:n}=await P({path:{assistant_id:e.assistantId},query:{path:e.path,...e.showHidden?{showHidden:`true`}:{}},parseAs:`blob`,throwOnError:!1});if(n||!(t instanceof Blob))throw Error(`Failed to download file`);await F(t,e.filename)}function ce(e){if(!e)return``;let t=e.indexOf(`;`);return(t===-1?e:e.slice(0,t)).trim()}function le(e,t){return ce(t)===`application/json`?!0:(e??``).toLowerCase().endsWith(`.json`)}function ue(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function de(e){return e.split(`/`).some(e=>e.startsWith(`.`))}var Z=s();function fe(e){return c({queryFn:async()=>{let{data:t,error:n}=await O({path:e.path,query:{path:e.query.path,...e.query.showHidden?{showHidden:`true`}:{}}});if(n)throw n;return t},queryKey:[`assistantsWorkspaceFileRetrieve`,e]})}function pe({mimeType:e}){let t=e.indexOf(`;`),n=(t===-1?e:e.slice(0,t)).trim(),r=m;return n.startsWith(`image/`)?r=B:n.startsWith(`video/`)?r=z:!n.startsWith(`text/`)&&n!==`application/json`&&n!==`application/octet-stream`&&(r=h),(0,Z.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 10%, transparent)`},children:(0,Z.jsx)(r,{className:`h-3.5 w-3.5`,style:{color:`var(--content-default)`}})})}function me({viewMode:e,onChange:t}){return(0,Z.jsx)(`div`,{className:`inline-flex rounded-md p-0.5`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 6%, transparent)`},children:[`preview`,`source`].map(r=>{let i=e===r;return(0,Z.jsx)(n,{variant:`ghost`,onClick:()=>t(r),className:`h-auto rounded border-0 px-2.5 py-1 text-body-small-default hover:bg-transparent`,style:{backgroundColor:i?`var(--surface-lift)`:`transparent`,color:i?`var(--content-default)`:`var(--content-tertiary)`,boxShadow:i?`0 1px 2px rgba(0,0,0,0.15)`:void 0},children:r===`preview`?`Preview`:`Source`},r)})})}function Q({name:e,mimeType:t,size:n,rightContent:r}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(pe,{mimeType:t}),(0,Z.jsx)(`span`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),n!=null&&(0,Z.jsx)(`span`,{className:`shrink-0 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:J(n)})]}),r]})}function he({assistantId:e,path:t,mimeType:n,showHidden:r}){let{data:i,isLoading:o}=a({queryFn:async()=>{let n=await P({path:{assistant_id:e},query:{path:t,...r?{showHidden:`true`}:{}},parseAs:`blob`});if(n.error)throw n.error;return n.data},queryKey:[`assistantsWorkspaceFileContentRetrieve`,{assistantId:e,path:t,showHidden:r}],enabled:!!t}),[s,c]=(0,X.useState)(null);return(0,X.useEffect)(()=>{if(!i)return;let e=URL.createObjectURL(i);return c(e),()=>{URL.revokeObjectURL(e),c(null)}},[i]),o?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Z.jsx)(g,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):s?n.startsWith(`image/`)?(0,Z.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Z.jsx)(`img`,{src:s,alt:t.split(`/`).pop()??`image`,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n.startsWith(`video/`)?(0,Z.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Z.jsx)(`video`,{src:s,controls:!0,className:`max-h-[70vh] max-w-full rounded`})}):null:null}function ge({assistantId:e,path:t,name:r,mimeType:i,size:a,modifiedAt:o,showHidden:s}){let[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),f=(0,X.useCallback)(async()=>{d(!1),l(!0);try{await se({assistantId:e,path:t,filename:r,showHidden:s})}catch{d(!0)}finally{l(!1)}},[e,t,r,s]);return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:r,mimeType:i,size:a}),(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,Z.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg border p-6 text-center`,style:{borderColor:`var(--border-base)`,backgroundColor:`var(--surface-lift)`},children:[(0,Z.jsx)(h,{className:`mx-auto h-10 w-10`,style:{color:`var(--content-tertiary)`}}),(0,Z.jsx)(`p`,{className:`mt-3 text-body-medium-default`,style:{color:`var(--content-default)`},children:r}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:i}),(0,Z.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:J(a,`Unknown size`)}),o&&(0,Z.jsxs)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:[`Modified: `,new Date(o).toLocaleString()]})]}),(0,Z.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:c?(0,Z.jsx)(g,{className:`animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(p,{"aria-hidden":!0}),onClick:f,disabled:c,"aria-label":`Download ${r}`,className:`mt-4`,children:c?`Downloading…`:`Download`}),u&&(0,Z.jsx)(`p`,{className:`mt-2 text-body-small-default`,style:{color:`var(--system-error)`},children:`Download failed. Try again.`})]})})]})}function _e({assistantId:e,selectedPath:t,showHidden:r,viewMode:s,onChangeViewMode:c,onBrowse:l,pathRename:u,pathDelete:d}){let f=i(),{data:p,isLoading:m}=a({...fe({path:{assistant_id:e},query:{path:t??``,showHidden:r}}),enabled:!!t}),[h,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(null);(0,X.useEffect)(()=>{if(!u)return;let{from:e,to:t}=u,n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;_(e=>e==null?e:n(e)),y(e=>e==null?e:{...e,path:n(e.path)})},[u]),(0,X.useEffect)(()=>{if(!d)return;let{path:e}=d,t=t=>t===e||t.startsWith(`${e}/`);_(e=>e!=null&&t(e)?null:e),y(e=>e!=null&&t(e.path)?null:e)},[d]);let b=h!=null&&h===t,x=p?.content??``,S=v?.path===t?v.content:x,C=()=>{_(null),y(null)},w=o({mutationFn:async({path:t,content:n})=>{let{error:r,response:i}=await k({path:{assistant_id:e},body:{path:t,content:n,encoding:`utf8`},throwOnError:!1});if(!i?.ok||r)throw Error(`Failed to save file`)},onSuccess:(e,t)=>{_(e=>e===t.path?null:e),y(e=>e?.path===t.path?null:e),f.invalidateQueries({queryKey:[`assistantsWorkspaceFileRetrieve`]})}}),T=S!==x,O=(0,X.useCallback)(()=>{t&&T&&!w.isPending&&w.mutate({path:t,content:S})},[t,T,w,S]);if(!t)return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view`}),l&&(0,Z.jsx)(n,{type:`button`,onClick:l,leftIcon:(0,Z.jsx)(oe,{"aria-hidden":!0}),className:`sm:hidden`,children:`Browse files`})]});if(m)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(g,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})});if(!p)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`File not found`})});let A=p.mimeType??`application/octet-stream`,j=p.name??t.split(`/`).pop()??t,M=E(j,A),N=le(j,A),P=p.content!=null&&!M&&!N,F=t?de(t):!0,I=b&&(0,Z.jsx)(re,{isDirty:T,isSaving:w.isPending,error:w.isError?`Save failed`:null,onSave:O,onDiscard:C});if(M&&p.content!=null){let e=b?S:p.content;return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:j,mimeType:A,rightContent:(0,Z.jsx)(me,{viewMode:s,onChange:e=>{b&&C(),c(e)}})}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:e,fileName:j,mimeType:A,showEdit:!F&&s===`source`,isEditing:b,onToggleEdit:()=>b?C():_(t)}),s===`preview`?(0,Z.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:(0,Z.jsx)(D,{content:e})}):b?(0,Z.jsx)(K,{value:S,onChange:e=>y({path:t,content:e}),onSave:O}):(0,Z.jsx)(G,{content:p.content,readOnly:F,onStartEdit:()=>_(t)})]}),I]})}if(N&&p.content!=null){let e=b?S:p.content,n=ue(e);return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:j,mimeType:A,rightContent:(0,Z.jsx)(me,{viewMode:s,onChange:e=>{b&&C(),c(e)}})}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:s===`preview`?n:e,downloadContent:e,fileName:j,mimeType:A,showEdit:!F&&s===`source`,isEditing:b,onToggleEdit:()=>b?C():_(t)}),s===`preview`?(0,Z.jsx)(G,{content:n,readOnly:!0,whiteSpace:`pre`}):b?(0,Z.jsx)(K,{value:S,onChange:e=>y({path:t,content:e}),onSave:O}):(0,Z.jsx)(G,{content:p.content,readOnly:F,onStartEdit:()=>_(t)})]}),I]})}return P?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:j,mimeType:A,size:p.size}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:b?S:p.content??``,fileName:j,mimeType:A,showEdit:!F,isEditing:b,onToggleEdit:()=>b?C():_(t)}),b?(0,Z.jsx)(K,{value:S,onChange:e=>y({path:t,content:e}),onSave:O}):(0,Z.jsx)(G,{content:p.content??``,readOnly:F,onStartEdit:()=>_(t)})]}),I]}):A.startsWith(`image/`)||A.startsWith(`video/`)?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:j,mimeType:A,size:p.size}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Z.jsx)(he,{assistantId:e,path:t,mimeType:A,showHidden:r})})]}):(0,Z.jsx)(ge,{assistantId:e,path:t,name:j,mimeType:A,size:p.size,modifiedAt:p.modifiedAt,showHidden:r})}function ve(e,t){if(t===`name`)return e;let n=e.slice();return n.sort((e,t)=>{let n=e.size??null,r=t.size??null;return n===null&&r===null?(e.name??``).localeCompare(t.name??``):n===null?1:r===null?-1:n===r?(e.name??``).localeCompare(t.name??``):r-n}),n}function ye(e){return c({queryFn:async()=>{let t={};e.query?.path&&(t.path=e.query.path),e.query?.showHidden&&(t.showHidden=`true`),e.query?.includeDirSizes&&(t.includeDirSizes=`true`);let{data:n,error:r}=await M({path:e.path,query:t});if(r)throw r;if(!n)throw Error(`Failed to load workspace tree`);return n},queryKey:[`assistantsWorkspaceTreeRetrieve`,e]})}async function be(e,t,n,r){let i=n.toLowerCase(),a=r?.toLowerCase(),{data:o}=await M({path:{assistant_id:e},query:t?{path:t}:{}});if(o?.entries?.some(e=>{let t=(e.name??``).toLowerCase();return t===i&&t!==a}))throw Error(`"${n}" already exists here.`)}function xe({entry:e}){return e.type===`directory`?(0,Z.jsx)(V,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`image/`)?(0,Z.jsx)(B,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`video/`)?(0,Z.jsx)(z,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(m,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}})}function Se({entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:f,onRequestRename:p,onRequestCreate:m,depth:h}){let g=e.path??``,v=e.name??``,y=e.type===`directory`,x=n.has(g),S=r===g,C=v.startsWith(`.`),w=!de(g),T=y&&(x||s.length>0),{data:E}=a({...ye({path:{assistant_id:t},query:{path:g,showHidden:i,includeDirSizes:o===`size`}}),enabled:y&&T}),D=(0,X.useMemo)(()=>ve(E?.entries??[],o),[E?.entries,o]),O=s===``||v.toLowerCase().includes(s);if(s!==``&&!y&&!O)return null;let k=(0,Z.jsxs)(`button`,{onClick:()=>{y?c(g):l(g)},className:`flex w-full items-center gap-1.5 px-2 py-1 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{paddingLeft:`${h*14+8}px`,paddingRight:`8px`,color:S?`var(--content-default)`:C?`var(--content-tertiary)`:`var(--content-default)`,backgroundColor:S?`color-mix(in oklab, var(--primary-base) 12%, transparent)`:void 0,opacity:C&&!S?.7:1},children:[y?T?(0,Z.jsx)(u,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(d,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(`span`,{className:`h-3 w-3 shrink-0`}),(0,Z.jsx)(xe,{entry:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v}),e.size!=null&&(0,Z.jsx)(`span`,{className:`shrink-0 text-label-medium-default tabular-nums`,style:{color:`var(--content-tertiary)`},children:J(e.size)})]});return(0,Z.jsxs)(`div`,{children:[w?(0,Z.jsxs)(b.Root,{children:[(0,Z.jsx)(b.Trigger,{children:k}),(0,Z.jsxs)(b.Content,{children:[y&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(b.Item,{leftIcon:(0,Z.jsx)(R,{className:`h-3.5 w-3.5`}),onSelect:()=>m({kind:`file`,parentPath:g}),children:`New File`}),(0,Z.jsx)(b.Item,{leftIcon:(0,Z.jsx)(Y,{className:`h-3.5 w-3.5`}),onSelect:()=>m({kind:`folder`,parentPath:g}),children:`New Folder`}),(0,Z.jsx)(b.Separator,{})]}),(0,Z.jsx)(b.Item,{leftIcon:(0,Z.jsx)(ne,{className:`h-3.5 w-3.5`}),onSelect:()=>f({path:g,name:v,isDirectory:y}),children:`Delete`}),(0,Z.jsx)(b.Item,{leftIcon:(0,Z.jsx)(_,{className:`h-3.5 w-3.5`}),onSelect:()=>p({path:g,name:v,isDirectory:y}),children:`Rename`})]})]}):k,y&&T&&D.length>0&&(0,Z.jsx)(`div`,{children:D.map(e=>(0,Z.jsx)(Se,{entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:f,onRequestRename:p,onRequestCreate:m,depth:h+1},e.path))})]})}function Ce({title:e,placeholder:t,confirmLabel:r,pendingLabel:i,initialName:a,onCancel:o,onConfirm:s,pending:c,error:l}){let u=(0,X.useRef)(null),[d,f]=(0,X.useState)(a??``),p=d.trim(),m=p.length>0&&(/[/\\]/.test(p)||p===`.`||p===`..`),h=p.length>0&&!m&&!c;return(0,Z.jsx)(S.Root,{open:!0,onOpenChange:e=>{!e&&!c&&o()},children:(0,Z.jsx)(S.Content,{size:`sm`,hideCloseButton:!0,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault();let t=u.current;t&&(t.focus(),requestAnimationFrame(()=>{t.setSelectionRange(0,t.value.length)}))},onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),c||o()},children:(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h&&s(p)},children:[(0,Z.jsx)(S.Header,{children:(0,Z.jsx)(S.Title,{children:e})}),(0,Z.jsx)(S.Body,{children:(0,Z.jsx)(x,{ref:u,label:`Name`,value:d,onChange:e=>f(e.target.value),placeholder:t,errorText:l??(m?`Enter a single file or folder name without slashes.`:void 0),autoComplete:`off`,spellCheck:!1,fullWidth:!0})}),(0,Z.jsxs)(S.Footer,{children:[(0,Z.jsx)(n,{type:`button`,variant:`outlined`,onClick:o,disabled:c,children:`Cancel`}),(0,Z.jsx)(n,{type:`submit`,variant:`primary`,disabled:!h,children:c?i:r})]})]})})})}function $({assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,onToggleExpand:l,onExpandPath:u,onSelectPath:d,onToggleShowHidden:f,onChangeSortMode:p,onPathDeleted:m,onPathRenamed:h}){let g=i(),[_,v]=(0,X.useState)(``),b=_.trim().toLowerCase(),[S,C]=(0,X.useState)(!1),[w,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(null),M=(0,X.useCallback)(()=>{E(null),O(null)},[]),{data:P,isLoading:F}=a(ye({path:{assistant_id:e},query:{showHidden:s,includeDirSizes:c===`size`}})),L=(0,X.useMemo)(()=>ve(P?.entries??[],c),[P?.entries,c]),R=(0,X.useCallback)(()=>{for(let e of[`assistantsWorkspaceTreeRetrieve`,`assistantsWorkspaceFileRetrieve`,`assistantsWorkspaceFileContentRetrieve`])g.invalidateQueries({queryKey:[e]})},[g]),z=o({mutationFn:async t=>{let n=t.parentPath?`${t.parentPath}/${t.name}`:t.name;await be(e,t.parentPath,t.name);let{error:r,response:i}=t.kind===`file`?await k({path:{assistant_id:e},body:{path:n,content:``,encoding:`utf8`},throwOnError:!1}):await N({path:{assistant_id:e},body:{path:n},throwOnError:!1});if(r||!i?.ok)throw Error(typeof r==`string`?r:`Failed to create — check the name and try again.`);return{...t,path:n}},onSuccess:e=>{M(),R(),e.parentPath&&u(e.parentPath),e.kind===`file`?d(e.path):u(e.path)},onError:e=>{O(e instanceof Error?e.message:`Failed to create.`)}}),B=o({mutationFn:async t=>{let n=t.oldPath.lastIndexOf(`/`),r=n===-1?``:t.oldPath.slice(0,n),i=t.oldPath.slice(n+1),a=r?`${r}/${t.newName}`:t.newName;await be(e,r,t.newName,i);let{error:o,response:s}=await A({path:{assistant_id:e},body:{oldPath:t.oldPath,newPath:a},throwOnError:!1});if(o||!s?.ok)throw Error(typeof o==`string`?o:`Failed to rename — check the name and try again.`);return{oldPath:t.oldPath,newPath:a}},onSuccess:({oldPath:e,newPath:t})=>{M(),R(),h(e,t)},onError:e=>{O(e instanceof Error?e.message:`Failed to rename.`)}}),V=(0,X.useCallback)(e=>{O(null),E({type:`create`,...e})},[]),ne=(0,X.useCallback)(e=>{O(null),E({type:`rename`,path:e.path,name:e.name})},[]),[H,U]=(0,X.useState)(null),W=o({mutationFn:async t=>{let{error:n,response:r}=await j({path:{assistant_id:e},body:{path:t.path},throwOnError:!1});if(n||!r?.ok)throw Error(typeof n==`string`?n:`Failed to delete — try again.`);return t},onSuccess:e=>{U(null),R(),m(e.path)}}),G=(0,X.useCallback)(e=>{W.reset(),U(e)},[W]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:`Files`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:c===`size`?(0,Z.jsx)(ae,{"aria-hidden":!0}):(0,Z.jsx)(ie,{"aria-hidden":!0}),onClick:()=>p(c===`size`?`name`:`size`),"aria-label":c===`size`?`Sort by name`:`Sort by size`,title:c===`size`?`Sorted by size — switch to name`:`Sorted by name — switch to size`,tintColor:c===`size`?`var(--content-default)`:`var(--content-tertiary)`}),(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:s?(0,Z.jsx)(te,{"aria-hidden":!0}):(0,Z.jsx)(ee,{"aria-hidden":!0}),onClick:f,"aria-label":s?`Hide hidden files`:`Show hidden files`,title:s?`Hide hidden files`:`Show hidden files`,tintColor:s?`var(--content-default)`:`var(--content-tertiary)`}),(0,Z.jsx)(we,{open:S,onOpenChange:C,onSelectKind:e=>{C(!1),V({kind:e,parentPath:``})}})]})]}),(0,Z.jsx)(`div`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(x,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`Search files`,leftIcon:(0,Z.jsx)(I,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0,spellCheck:!1,autoComplete:`off`}),_&&(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(y,{"aria-hidden":!0}),onClick:()=>v(``),"aria-label":`Clear search`,className:`absolute right-1.5 top-1/2 -translate-y-1/2`,tintColor:`var(--content-tertiary)`})]})}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:F?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`,style:{color:`var(--content-tertiary)`}})}):L.length?L.map(n=>(0,Z.jsx)(Se,{entry:n,assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,searchLower:b,onToggleExpand:l,onSelectPath:d,onRequestDelete:G,onRequestRename:ne,onRequestCreate:V,depth:0},n.path)):(0,Z.jsx)(`p`,{className:`px-3 py-4 text-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`No files found`})}),w?.type===`create`&&(0,Z.jsx)(Ce,{title:w.kind===`file`?`New File`:`New Folder`,placeholder:w.kind===`file`?`filename.md`:`folder-name`,confirmLabel:`Create`,pendingLabel:`Creating…`,onCancel:M,onConfirm:e=>{O(null),z.mutate({kind:w.kind,parentPath:w.parentPath,name:e})},pending:z.isPending,error:D},`create-${w.kind}-${w.parentPath}`),w?.type===`rename`&&(0,Z.jsx)(Ce,{title:`Rename`,placeholder:w.name,confirmLabel:`Rename`,pendingLabel:`Renaming…`,initialName:w.name,onCancel:M,onConfirm:e=>{if(e===w.name){M();return}O(null),B.mutate({oldPath:w.path,newName:e})},pending:B.isPending,error:D},`rename-${w.path}`),(0,Z.jsx)(T,{open:H!==null,title:H?.isDirectory?`Delete Folder`:`Delete File`,message:(0,Z.jsxs)(Z.Fragment,{children:[`Are you sure you want to delete`,` `,(0,Z.jsx)(`span`,{style:{color:`var(--content-default)`},children:H?.name}),H?.isDirectory?` and all of its contents`:``,`? This cannot be undone.`,W.error&&(0,Z.jsx)(`span`,{className:`mt-2 block`,style:{color:`var(--system-negative-strong)`},children:W.error.message})]}),confirmLabel:W.isPending?`Deleting…`:`Delete`,destructive:!0,isPending:W.isPending,onConfirm:()=>{H&&W.mutate(H)},onCancel:()=>U(null)})]})}function we({open:e,onOpenChange:t,onSelectKind:r}){return L()?(0,Z.jsxs)(C.Root,{open:e,onOpenChange:t,children:[(0,Z.jsx)(C.Trigger,{asChild:!0,children:(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(v,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Z.jsxs)(C.Content,{children:[(0,Z.jsx)(C.Header,{className:`sr-only`,children:(0,Z.jsx)(C.Title,{children:`Create new`})}),(0,Z.jsxs)(C.Body,{className:`pt-0`,children:[(0,Z.jsx)(w,{icon:R,label:`New File`,onSelect:()=>r(`file`)}),(0,Z.jsx)(w,{icon:Y,label:`New Folder`,onSelect:()=>r(`folder`)})]})]})]}):(0,Z.jsxs)(f.Root,{open:e,onOpenChange:t,children:[(0,Z.jsx)(f.Trigger,{asChild:!0,children:(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(v,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Z.jsxs)(f.Content,{align:`end`,sideOffset:4,children:[(0,Z.jsx)(f.Item,{leftIcon:(0,Z.jsx)(R,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`file`),children:`New File`}),(0,Z.jsx)(f.Item,{leftIcon:(0,Z.jsx)(Y,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`folder`),children:`New Folder`})]})]})}function Te(e){let t=e.split(`/`),n=new Set;for(let e=1;e<t.length;e++)n.add(t.slice(0,e).join(`/`));return n}function Ee({assistantId:e}){let[t,n]=r(),[i,a]=(0,X.useState)(()=>{let e=t.get(`file`);return e?Te(e):new Set}),[o,s]=(0,X.useState)(()=>t.get(`file`)),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(()=>t.get(`sort`)===`size`?`size`:`name`),[f,p]=(0,X.useState)(`preview`);(0,X.useEffect)(()=>{t.get(`file`)&&n(e=>{let t=new URLSearchParams(e);return t.delete(`file`),t},{replace:!0})},[]);let m=(0,X.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),h=(0,X.useCallback)(e=>{a(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),[g,_]=(0,X.useState)(!1),v=(0,X.useCallback)(e=>{s(e),_(!1)},[]),[y,b]=(0,X.useState)(null),x=(0,X.useCallback)(e=>{let t=t=>t===e||t.startsWith(`${e}/`);s(e=>e!==null&&t(e)?null:e),a(e=>{let n=new Set([...e].filter(e=>!t(e)));return n.size===e.size?e:n}),b({path:e})},[]),[S,C]=(0,X.useState)(null),w={assistantId:e,expandedPaths:i,selectedPath:o,showHidden:c,sortMode:u,onToggleExpand:m,onExpandPath:h,onSelectPath:v,onToggleShowHidden:()=>l(e=>!e),onChangeSortMode:d,onPathDeleted:x,onPathRenamed:(0,X.useCallback)((e,t)=>{let n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;s(e=>e===null?e:n(e)),a(e=>{let t=!1,r=new Set;for(let i of e){let e=n(i);e!==i&&(t=!0),r.add(e)}return t?r:e}),C({from:e,to:t})},[])};return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-4`,children:[(0,Z.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,Z.jsx)(U,{onClick:()=>_(!0)})}),(0,Z.jsx)(W,{open:g,onClose:()=>_(!1),title:`Files`,children:(0,Z.jsx)($,{...w})}),(0,Z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-4 sm:grid-cols-[320px_1fr]`,children:[(0,Z.jsx)(`div`,{className:`hidden min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border sm:flex`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Z.jsx)($,{...w})}),(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Z.jsx)(_e,{assistantId:e,selectedPath:o,showHidden:c,viewMode:f,onChangeViewMode:p,onBrowse:()=>_(!0),pathRename:S,pathDelete:y})})]})]})}function De(){return(0,Z.jsx)(Ee,{assistantId:H()})}export{De as WorkspacePage};
|
package/dist/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<link rel="apple-touch-icon" href="/assistant/favicon.svg" />
|
|
11
11
|
<title>Vellum Assistant</title>
|
|
12
12
|
<script src="/assistant/theme-init.js"></script>
|
|
13
|
-
<script type="module" crossorigin src="/assistant/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assistant/assets/index-DZAcojtQ.js"></script>
|
|
14
14
|
<link rel="modulepreload" crossorigin href="/assistant/assets/chunk-jRWAZmH_.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assistant/assets/preload-helper-BewR0kVT.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assistant/assets/is-electron-y5bNUVyG.js">
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-Dhiismgm.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-amTXFI-2.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./loader-circle-Cz7opInR.js";import{t as l}from"./input-CoUmPnRU.js";import{t as u}from"./toggle-CDfguvUz.js";import{n as d}from"./stat-square-CTHnQ1jc.js";import{n as f}from"./toast-xTp-xwYL.js";import{X as p,Xt as m,Y as h,Zt as g,c as _,u as v,zt as y}from"./react-query.gen-C6wVk6Rw.js";import{X as b}from"./sdk.gen-CmKfVpgB.js";import{F as x,P as S}from"./react-query.gen-GVQbBTEp.js";import{D as C,Ur as w}from"./index-RjTgjtTV.js";import{t as T}from"./use-active-assistant-id-CGeH4Gl6.js";import{t as E}from"./detail-card-GPqFZVmX.js";import{r as D}from"./assistant-status-panel-DBnGWE8z.js";var O=s();function k({memoryEnabled:e}){let n=T(),r=i(),{data:o}=a({...h({path:{assistant_id:n}}),staleTime:3e4}),s=e=>{p(r,{path:{assistant_id:n}},t=>t&&{...t,workerEnabled:e})},c=m({onSuccess:()=>s(!0)}),l=g({onSuccess:()=>s(!1)}),d=async e=>{try{e?(await c.mutateAsync({path:{assistant_id:n}}),f.success(`Background worker enabled.`)):(await l.mutateAsync({path:{assistant_id:n}}),f.success(`Background worker disabled.`))}catch(e){t(e,{context:`settings-memory-worker-toggle`}),f.error(`Failed to update background worker setting.`)}};if(!o)return null;let _=c.isPending||l.isPending;return(0,O.jsxs)(`div`,{className:`flex flex-row items-start justify-between gap-4 border-t border-[var(--border-subtle)] pt-4`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-body-medium-default text-[var(--content-emphasised)]`,children:`Background worker`}),(0,O.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Run memory consolidation in a dedicated background process instead of inline. Recommended for heavier memory workloads.`})]}),(0,O.jsx)(u,{checked:o.workerEnabled===!0,onChange:e=>void d(e),"aria-label":`Enable background memory worker`,disabled:!e||_})]})}var A=e(n(),1),j=[[`Mon`,0],[`Tue`,1],[`Wed`,2],[`Thu`,3],[`Fri`,4],[`Sat`,5],[`Sun`,6]];function M(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),t,n));return`${i.getHours().toString().padStart(2,`0`)}:${i.getMinutes().toString().padStart(2,`0`)}`}function N(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),t,n);return`${i.getUTCHours().toString().padStart(2,`0`)}:${i.getUTCMinutes().toString().padStart(2,`0`)}`}function P(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function F(e){let t=e?.schedule?.window.start??`06:00`,n=e?.schedule?.window.end??`08:00`;return{enabled:e?.enabled??!0,timezone:`UTC`,frequency:e?.schedule?.frequency??`weekly`,daysOfWeek:e?.schedule?.days_of_week??[0],daysOfMonth:e?.schedule?.days_of_month??[],windowStart:M(t),windowEnd:M(n)}}function I({assistantId:e}){let t=i(),{data:n,isLoading:s,isError:p}=a(S({path:{id:e}})),m=(0,A.useMemo)(()=>F(n),[n]),[h,g]=(0,A.useState)(null),_=h??m,v=h!==null,y=(0,A.useMemo)(()=>P(),[]),[C,w]=(0,A.useState)(null),T=C??_.daysOfMonth.join(`, `),E=o({mutationFn:async t=>{let{data:n}=await b({path:{id:e},body:t,throwOnError:!0});return n}}),D=e=>{g(t=>({...t??m,...e}))},k=e=>{D({daysOfWeek:_.daysOfWeek.includes(e)?_.daysOfWeek.filter(t=>t!==e):[..._.daysOfWeek,e].sort((e,t)=>e-t)})},M=e=>e.split(`,`).map(e=>parseInt(e.trim(),10)).filter(e=>!isNaN(e)&&e>=1&&e<=31);return s?(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,O.jsx)(c,{className:`h-4 w-4 animate-spin`}),`Loading update window settings...`]}):p?(0,O.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:`Failed to load update window policy. Refresh the page to try again.`}):(0,O.jsxs)(`div`,{className:`space-y-6`,children:[(0,O.jsx)(u,{checked:_.enabled,onChange:e=>D({enabled:e}),label:`Automatic updates`,helperText:`Update automatically during a configured time window`}),_.enabled&&(0,O.jsxs)(`div`,{className:`space-y-5`,children:[(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Frequency`}),(0,O.jsx)(`div`,{className:`max-w-[400px]`,children:(0,O.jsx)(d,{ariaLabel:`Frequency`,value:_.frequency,onChange:e=>{e!==`monthly`&&w(null),D({frequency:e})},items:[{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}]})})]}),_.frequency===`weekly`&&(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Day(s) of week`}),(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:j.map(([e,t])=>(0,O.jsx)(r,{variant:`outlined`,size:`compact`,active:_.daysOfWeek.includes(t),onClick:()=>k(t),children:e},t))})]}),_.frequency===`monthly`&&(0,O.jsx)(l,{label:`Day(s) of month`,type:`text`,value:T,onChange:e=>w(e.target.value),onBlur:e=>{let t=M(e.target.value);D({daysOfMonth:t}),w(t.join(`, `))},placeholder:`e.g. 1, 15`,helperText:`Comma-separated day numbers (1–31)`,className:`w-48`}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:[`Update window`,y?` (${y})`:``]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(l,{type:`time`,value:_.windowStart,onChange:e=>D({windowStart:e.target.value})}),(0,O.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`to`}),(0,O.jsx)(l,{type:`time`,value:_.windowEnd,onChange:e=>D({windowEnd:e.target.value})})]})]})]}),(0,O.jsx)(r,{variant:`primary`,leftIcon:E.isPending?(0,O.jsx)(c,{className:`animate-spin`}):void 0,onClick:async()=>{let n=_.frequency===`monthly`&&C!==null?M(C):_.daysOfMonth;try{await E.mutateAsync({enabled:_.enabled,timezone:`UTC`,schedule:{frequency:_.frequency,days_of_week:_.frequency===`weekly`?_.daysOfWeek:[],days_of_month:_.frequency===`monthly`?n:[],window:{start:N(_.windowStart),end:N(_.windowEnd)}}}),f.success(`Auto-update policy saved.`),g(null),w(null),t.invalidateQueries({queryKey:x({path:{id:e}})})}catch{f.error(`Failed to save policy. Please try again.`)}},disabled:E.isPending||!v,children:`Save policy`})]})}function L(){let{assistant:e,healthz:n}=D(),r=w({platformHostedOnly:!0}),o=e?.is_local?null:e,s=T(),c=i(),l=n?.capabilities?.memoryOptOut===!0,{data:d}=a({..._({path:{assistant_id:s}}),staleTime:3e4,enabled:l}),p=y({onSuccess:e=>{v(c,{path:{assistant_id:s}},e)}}),m=d?.memory?.enabled!==!1,h=async e=>{try{await p.mutateAsync({path:{assistant_id:s},body:{memory:{enabled:e}}}),f.success(e?`Memory enabled.`:`Memory disabled.`)}catch(e){t(e,{context:`settings-memory-toggle`}),f.error(`Failed to update memory setting.`)}};return(0,O.jsxs)(`div`,{className:`space-y-4`,children:[r===`full`&&o&&(0,O.jsx)(E,{title:`Update Window`,subtitle:`Configure when automatic updates are applied.`,children:(0,O.jsx)(I,{assistantId:o.id})}),r===`disabled`&&(0,O.jsx)(E,{title:`Update Window`,subtitle:`Configure when automatic updates are applied.`,children:(0,O.jsx)(C,{children:`Log in to the Vellum platform to manage update window policy.`})}),l?(0,O.jsx)(E,{title:`Memory`,subtitle:`Let your assistant remember information from past conversations. Turning this off also pauses memory consolidation.`,accessory:(0,O.jsx)(u,{checked:m,onChange:e=>void h(e),"aria-label":`Enable memory`,disabled:p.isPending}),compactAccessory:!0,children:(0,O.jsx)(k,{memoryEnabled:m})}):null]})}export{L as AdvancedPage};
|