@vellumai/web 0.10.10-staging.2 → 0.10.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/assets/{account-page-Cn_Ux2k8.js → account-page-B27dNQ3d.js} +1 -1
  2. package/dist/assets/{acp-run-detail-panel-hdemc9Ns.js → acp-run-detail-panel-B0k2rYpM.js} +1 -1
  3. package/dist/assets/{activity-steps-panel-CJDoPVUC.js → activity-steps-panel-LDydO3OK.js} +1 -1
  4. package/dist/assets/{ai-page-DX1CAGiX.js → ai-page-UMlli-yL.js} +1 -1
  5. package/dist/assets/{api-key-screen-C0F9Kodk.js → api-key-screen-BYdMayOl.js} +1 -1
  6. package/dist/assets/{background-task-detail-panel-B3sQQ2WB.js → background-task-detail-panel-wG11sk-D.js} +1 -1
  7. package/dist/assets/{billing-page-DbgQl5CS.js → billing-page-BHg4_D8p.js} +1 -1
  8. package/dist/assets/{bookmarks-page-Bg1kpqdy.js → bookmarks-page-Dj_WhT38.js} +1 -1
  9. package/dist/assets/{channels-page-route-Cm7KQpHs.js → channels-page-route-BLMC84yp.js} +1 -1
  10. package/dist/assets/{command-palette-B23DDF8y.js → command-palette-nEbCvF9B.js} +1 -1
  11. package/dist/assets/{command-palette-window-page-2gnvF4NV.js → command-palette-window-page-Um5WOMD9.js} +1 -1
  12. package/dist/assets/{community-page-De9KLKyn.js → community-page-BpLDD6Gw.js} +1 -1
  13. package/dist/assets/{contacts-page-route-CZwZ6baw.js → contacts-page-route-Na5xsrCM.js} +1 -1
  14. package/dist/assets/{credentials-page-st-zOas5.js → credentials-page-DiPIjJOv.js} +1 -1
  15. package/dist/assets/{debug-page-BhcVrLKj.js → debug-page-Op9gPo8_.js} +1 -1
  16. package/dist/assets/{deploy-dialogs-BJRrRbSc.js → deploy-dialogs-BNZpdpkW.js} +1 -1
  17. package/dist/assets/{detail-panel-stop-button-c0oweWwM.js → detail-panel-stop-button-QQ20Gb80.js} +1 -1
  18. package/dist/assets/{developer-page-DRakR84C.js → developer-page-CEm6gJ5c.js} +1 -1
  19. package/dist/assets/{dictation-overlay-page-jXIAQQGI.js → dictation-overlay-page-DFy73eLq.js} +1 -1
  20. package/dist/assets/{document-viewer-page-B6lpLvJw.js → document-viewer-page-BB8CFKzx.js} +1 -1
  21. package/dist/assets/{emails-page-ChYRO5ST.js → emails-page-DfS8M0KH.js} +1 -1
  22. package/dist/assets/{general-page-0F5njKZW.js → general-page-DRyIIgkk.js} +1 -1
  23. package/dist/assets/{hatching-screen-CW3BRgRH.js → hatching-screen-D0zBF6G3.js} +1 -1
  24. package/dist/assets/{home-page-route-D_8JCZ_Q.js → home-page-route-BMbIyFRk.js} +1 -1
  25. package/dist/assets/{hosting-screen-DHETBcAy.js → hosting-screen-Zb6-T1r9.js} +1 -1
  26. package/dist/assets/identity-page-route-BmQtmPF0.js +7 -0
  27. package/dist/assets/{index-CmaRQR9x.js → index-CgcZXB4g.js} +7 -7
  28. package/dist/assets/{inspect-page-Cj0WVion.js → inspect-page-Iemfgo7r.js} +1 -1
  29. package/dist/assets/{integrations-page-CH-pFd_e.js → integrations-page-8U6yrpy_.js} +1 -1
  30. package/dist/assets/{intelligence-layout-BHGZqgWE.js → intelligence-layout-Bk61phvn.js} +1 -1
  31. package/dist/assets/{latest-assistant-text-DqYv-19M.js → latest-assistant-text-cGlQO-ow.js} +1 -1
  32. package/dist/assets/{library-detail-page-D1SaX446.js → library-detail-page-BCRw2pXt.js} +1 -1
  33. package/dist/assets/{library-page-CY_UIQ7K.js → library-page-BCFKyR7R.js} +1 -1
  34. package/dist/assets/{logout-page-BsVCSXLH.js → logout-page-C27fK6LX.js} +1 -1
  35. package/dist/assets/{logs-layout-D_7jq15m.js → logs-layout-DrBxBaoW.js} +1 -1
  36. package/dist/assets/{memory-page-route-BGWq_aq8.js → memory-page-route-BdF70Wmp.js} +1 -1
  37. package/dist/assets/{memory-router-playground-page-DThWyhXE.js → memory-router-playground-page-BlT9oFs0.js} +1 -1
  38. package/dist/assets/{mobile-sidebar-drawer-XsUj_ej1.js → mobile-sidebar-drawer-BmS9adnj.js} +1 -1
  39. package/dist/assets/{notifications-page-4H3d3TVi.js → notifications-page-DsQJaAsR.js} +1 -1
  40. package/dist/assets/{oauth-complete-page-IYjT22S6.js → oauth-complete-page-BMqOW3MA.js} +1 -1
  41. package/dist/assets/{oauth-popup-complete-page-B2tgdOeo.js → oauth-popup-complete-page-D-r0oM8y.js} +1 -1
  42. package/dist/assets/{pairing-page-BsGxP4RT.js → pairing-page-CELMlJeG.js} +1 -1
  43. package/dist/assets/{personality-page-DWuNCYhT.js → personality-page-BdkuO-Fy.js} +1 -1
  44. package/dist/assets/{plugins-page-O4J9g6Y8.js → plugins-page-DblHkb06.js} +1 -1
  45. package/dist/assets/{prechat-route-CoHHHLoD.js → prechat-route-DcgCgSV8.js} +1 -1
  46. package/dist/assets/{privacy-page-DXHDyrXM.js → privacy-page-Ccn6St6F.js} +1 -1
  47. package/dist/assets/{privacy-screen-N6-nGjeG.js → privacy-screen-IqygR70e.js} +1 -1
  48. package/dist/assets/{provider-callback-page-B6zqXdPZ.js → provider-callback-page-fjZoTIWk.js} +1 -1
  49. package/dist/assets/{quick-input-page-UeFQo32q.js → quick-input-page-BmPU9B6u.js} +1 -1
  50. package/dist/assets/{research-mock-page-DL9B4Lli.js → research-mock-page-CssYNgG7.js} +1 -1
  51. package/dist/assets/{research-onboarding-route-CEPszqjJ.js → research-onboarding-route-sFu5EQW9.js} +1 -1
  52. package/dist/assets/{review-terms-screen-CchSUndG.js → review-terms-screen-Cv_jkYHP.js} +1 -1
  53. package/dist/assets/{schedules-page-Bj5HEJa-.js → schedules-page-DCFEdNCs.js} +1 -1
  54. package/dist/assets/{select-assistant-screen-BQLQKCB5.js → select-assistant-screen-B0qoVKd5.js} +1 -1
  55. package/dist/assets/{settings-layout-Dr3LiWJ0.js → settings-layout-B_NU6GFk.js} +1 -1
  56. package/dist/assets/{share-feedback-modal-DvC-1HRQ.js → share-feedback-modal-c0vGJBMA.js} +1 -1
  57. package/dist/assets/{sidebar-tree-r9N8LP3u.js → sidebar-tree-Cq8ACYzP.js} +1 -1
  58. package/dist/assets/{signup-page-B7lZHfHL.js → signup-page-CQLi5G7p.js} +1 -1
  59. package/dist/assets/{skill-detail-page-onU_WAHM.js → skill-detail-page-C_-DI2tN.js} +1 -1
  60. package/dist/assets/{skill-detail-panel-r5S_O0rZ.js → skill-detail-panel-J7W0DU8J.js} +1 -1
  61. package/dist/assets/{skills-page-Cf86q643.js → skills-page-BhMnBhiu.js} +1 -1
  62. package/dist/assets/{start-screen-kBX69v2m.js → start-screen-Cbh01xPj.js} +1 -1
  63. package/dist/assets/{subagent-detail-panel-D6oy2K_C.js → subagent-detail-panel-D9BXd8vR.js} +1 -1
  64. package/dist/assets/{system-events-page-CXkh6imt.js → system-events-page-BWbjCZVh.js} +1 -1
  65. package/dist/assets/{theme-stage-page-B1KCcRzM.js → theme-stage-page-DUeQZVJ3.js} +1 -1
  66. package/dist/assets/{tiptap-document-editor-BVFwGbyO.js → tiptap-document-editor-yCVhNTRu.js} +1 -1
  67. package/dist/assets/{tool-detail-panel-CI8Z5mU5.js → tool-detail-panel-Dtl2QLOW.js} +1 -1
  68. package/dist/assets/{upgrade-cancel-page-78mnz39g.js → upgrade-cancel-page-DmdDdCjG.js} +1 -1
  69. package/dist/assets/{upgrade-success-page-Dnqc4oxD.js → upgrade-success-page-DQoC2Y_H.js} +1 -1
  70. package/dist/assets/{use-assistant-identity-details-D0dDGwFZ.js → use-assistant-identity-details-D-gTqmOL.js} +1 -1
  71. package/dist/assets/{use-edge-swipe-back-CzIG6Agy.js → use-edge-swipe-back-Dpo-0Weh.js} +1 -1
  72. package/dist/assets/{use-invite-link-dialog-BLqplXYp.js → use-invite-link-dialog-DhVTs4OS.js} +1 -1
  73. package/dist/assets/{use-skill-actions-B58D56j9.js → use-skill-actions-fDejA0nc.js} +1 -1
  74. package/dist/assets/{use-skill-categories-BewT8dcB.js → use-skill-categories-DCOdxAre.js} +1 -1
  75. package/dist/assets/{use-skill-detail-files-S961Kf-o.js → use-skill-detail-files-DS6fk9Xz.js} +1 -1
  76. package/dist/assets/{voice-page-IaJC48fm.js → voice-page-BRscGXct.js} +1 -1
  77. package/dist/assets/{weather-forecast-display-Cd2sZBmz.js → weather-forecast-display-Dcw7Ta6D.js} +1 -1
  78. package/dist/assets/{welcome-screen-CUTRt2OQ.js → welcome-screen-C35jMBVC.js} +1 -1
  79. package/dist/assets/{workflow-detail-panel-BRYRq60N.js → workflow-detail-panel-CYjQlhPc.js} +1 -1
  80. package/dist/assets/{workspace-page-DgDej6f2.js → workspace-page-Dh-OnRd7.js} +1 -1
  81. package/dist/index.html +1 -1
  82. package/package.json +1 -1
  83. package/dist/assets/identity-page-route-B1o8eOMl.js +0 -7
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-BGD3-GQf.js";import{t as n}from"./react-DJZBPgpf.js";import{P as r,t as i}from"./button-BQVYX8n_.js";import{f as a,u as o}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./useQuery-B45lW1Kk.js";import{t as l}from"./jsx-runtime-CVSDxk6A.js";import{t as u}from"./typography-Cqi8q9o7.js";import{t as d}from"./createLucideIcon-Bjb-Kuq7.js";import{t as f}from"./calendar-D0labpMU.js";import{t as p}from"./chevron-down-DpYf9Gwq.js";import{t as m}from"./chevron-right-jRymmL7S.js";import{t as h}from"./clock-LiCGqvyn.js";import{t as g}from"./loader-circle-D57RZgLH.js";import{t as _}from"./repeat-CS_kgMdk.js";import{t as v}from"./x-CswtfvgS.js";import{t as y}from"./notice-BylgS5W_.js";import{i as b,j as x}from"./src-CDdn26Yb.js";import{t as S}from"./tag-B6WeUtBW.js";import{n as C,t as w}from"./input-ZpyYt_a0.js";import{t as T}from"./toggle-QSEiPr3k.js";import{t as E}from"./modal-BtcwNEBj.js";import{t as D}from"./panel-item-Bvqsr5n9.js";import{n as O}from"./toast-ZoZVyeDI.js";import{t as k}from"./dropdown-BMNSccmo.js";import{Bt as A,F as j,Jt as M,M as N,N as P,P as ee,Yt as te,_ as F,c as I,d as L,dt as ne,ft as re,g as R,j as ie,mt as ae,pt as oe,ut as se,v as ce,y as le}from"./react-query.gen-BQH0QRfT.js";import{a as ue}from"./api-BBMl4mW3.js";import{c as z}from"./routes-XPLb07Av.js";import{t as B}from"./effective-timezone-Ct3PoWNH.js";import{t as V}from"./assistant-feature-flag-store-BpbbAIKZ.js";import{$n as H,Br as de,Ma as fe,Qi as pe,Ui as me,Xa as he,ia as ge,zr as _e}from"./index-CmaRQR9x.js";import{t as ve}from"./use-active-assistant-id-9rGx8kT9.js";import{t as ye}from"./detail-card-CA8lPa5K.js";import{a as be,c as xe,i as Se,l as Ce,n as we,o as Te,r as Ee,s as De,t as Oe,u as ke}from"./page-empty-state-DbCk3v6f.js";import{r as Ae,t as je}from"./profile-metadata-DZwV-VFB.js";var Me=d(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),U=e(n(),1),Ne={frequency:`daily`,minute:0,hour24:9,weekdays:[1],dayOfMonth:1},W=[{value:0,letter:`S`,short:`Sun`,full:`Sunday`},{value:1,letter:`M`,short:`Mon`,full:`Monday`},{value:2,letter:`T`,short:`Tue`,full:`Tuesday`},{value:3,letter:`W`,short:`Wed`,full:`Wednesday`},{value:4,letter:`T`,short:`Thu`,full:`Thursday`},{value:5,letter:`F`,short:`Fri`,full:`Friday`},{value:6,letter:`S`,short:`Sat`,full:`Saturday`}],Pe=[1,2,3,4,5];function G(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function Fe(e){let t=Array.from(new Set(e.map(e=>G(e,0,6)).filter(e=>Number.isInteger(e)))).sort((e,t)=>e-t);return t.length>0?t:[1]}function Ie(e){let t=G(e.minute,0,59),n=G(e.hour24,0,23);switch(e.frequency){case`hourly`:return`${t} * * * *`;case`daily`:return`${t} ${n} * * *`;case`weekly`:return`${t} ${n} * * ${Fe(e.weekdays).join(`,`)}`;case`monthly`:return e.dayOfMonth===`last`?`${t} ${n} L * *`:`${t} ${n} ${G(e.dayOfMonth,1,28)} * *`}}function Le(e,t){let n=G(e,0,23),r=G(t,0,59),i=n<12?`AM`:`PM`;return`${n%12==0?12:n%12}:${String(r).padStart(2,`0`)} ${i}`}function Re(e){let t=[`th`,`st`,`nd`,`rd`],n=e%100;return`${e}${t[(n-20)%10]??t[n]??t[0]}`}function ze(e){let t=Fe(e),n=new Set(t);if(t.length===7)return`every day`;if(t.length===5&&Pe.every(e=>n.has(e)))return`every weekday`;if(t.length===2&&n.has(0)&&n.has(6))return`every weekend`;if(t.length===1)return`every ${W[t[0]]?.full??`day`}`;let r=t.map(e=>W[e]?.short??``),i=r.pop();return`every ${r.join(`, `)} & ${i}`}function Be(e){let t=Le(e.hour24,e.minute);switch(e.frequency){case`hourly`:{let t=G(e.minute,0,59);return`Runs every hour at :${String(t).padStart(2,`0`)}`}case`daily`:return`Runs every day at ${t}`;case`weekly`:return`Runs ${ze(e.weekdays)} at ${t}`;case`monthly`:return e.dayOfMonth===`last`?`Runs on the last day of every month at ${t}`:`Runs on the ${Re(G(e.dayOfMonth,1,28))} of every month at ${t}`}}var K=l(),Ve=[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}],He=Array.from({length:12},(e,t)=>{let n=t+1;return{value:String(n),label:String(n)}}),Ue=Array.from({length:12},(e,t)=>{let n=t*5,r=String(n).padStart(2,`0`);return{value:r,label:r}}),We=[...Array.from({length:28},(e,t)=>{let n=t+1;return{value:String(n),label:Re(n)}}),{value:`last`,label:`Last day`}],Ge=[{value:`AM`,label:`AM`},{value:`PM`,label:`PM`}];function Ke(e,t){let n=e%12;return t===`PM`?n+12:n}function qe(e){try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value;return t&&t!==e?`${e} · ${t}`:e}catch{return e}}function Je({isOpen:e,assistantId:t,onClose:n,onCreated:r}){return(0,K.jsx)(E.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,K.jsx)(Ye,{assistantId:t,onClose:n,onCreated:r}):null})}function Ye({assistantId:e,onClose:t,onCreated:n}){let r=H(),[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(`simple`),[p,m]=(0,U.useState)(Ne),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(null),x=a.trim(),S=s.trim(),T=l.trim(),D=h.trim(),O=(0,U.useMemo)(()=>d===`simple`?Ie(p):D,[d,p,D]),k=(0,U.useMemo)(()=>d===`simple`?Be(p):D||`Enter a cron expression to continue.`,[d,p,D]),A=(0,U.useMemo)(()=>qe(r),[r]),j=x.length>0&&S.length>0&&T.length>0&&O.length>0&&!_;return(0,K.jsxs)(E.Content,{size:`md`,children:[(0,K.jsxs)(E.Header,{children:[(0,K.jsx)(E.Title,{children:`Create schedule`}),(0,K.jsx)(E.Description,{children:`Schedule a recurring instruction for your assistant. Runs in execute mode — the message is delivered to the assistant on each fire.`})]}),(0,K.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),j){v(!0),b(null);try{await we(e,{name:x,description:S,expression:O,message:T,timezone:r}),v(!1),n()}catch(e){b(e instanceof Error?e.message:`Failed to create schedule.`),v(!1)}}},children:[(0,K.jsx)(E.Body,{children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsx)(w,{label:`Name`,placeholder:`Morning briefing`,value:a,onChange:e=>o(e.target.value),required:!0,autoFocus:!0,fullWidth:!0}),(0,K.jsx)(C,{label:`Description`,placeholder:`What is this schedule for?`,value:s,onChange:e=>c(e.target.value),required:!0,fullWidth:!0,rows:2}),(0,K.jsx)(et,{label:`Repeat`,children:d===`simple`?(0,K.jsx)(Xe,{cadence:p,onChange:m}):(0,K.jsx)($e,{value:h,onChange:g,onUseSimple:()=>f(`simple`)})}),(0,K.jsx)(tt,{summary:k,mono:d===`advanced`&&D.length>0,timezoneLabel:A}),d===`simple`?(0,K.jsx)(`button`,{type:`button`,onClick:()=>{g(e=>e||Ie(p)),f(`advanced`)},className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`Advanced — write a cron expression`}):null,(0,K.jsx)(C,{label:`Message`,placeholder:`What should the assistant do on each fire?`,value:l,onChange:e=>u(e.target.value),required:!0,fullWidth:!0,rows:4}),y?(0,K.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:y}):null]})}),(0,K.jsxs)(E.Footer,{children:[(0,K.jsx)(i,{variant:`outlined`,onClick:t,type:`button`,children:`Cancel`}),(0,K.jsx)(i,{variant:`primary`,type:`submit`,disabled:!j,children:_?`Creating…`:`Create schedule`})]})]})]})}function Xe({cadence:e,onChange:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(x,{items:Ve,value:e.frequency,onChange:n=>t({...e,frequency:n}),ariaLabel:`How often the schedule runs`}),e.frequency===`hourly`?(0,K.jsx)(q,{label:`At minute`,children:(0,K.jsx)(k,{options:Ue,value:String(e.minute).padStart(2,`0`),onChange:n=>t({...e,minute:Number(n)}),"aria-label":`Minute`,className:`w-24`})}):null,e.frequency===`weekly`?(0,K.jsx)(q,{label:`On these days`,children:(0,K.jsx)(Qe,{value:e.weekdays,onChange:n=>t({...e,weekdays:n})})}):null,e.frequency===`monthly`?(0,K.jsx)(q,{label:`On day`,children:(0,K.jsx)(k,{options:We,value:e.dayOfMonth===`last`?`last`:String(e.dayOfMonth),onChange:n=>t({...e,dayOfMonth:n===`last`?`last`:Number(n)}),"aria-label":`Day of month`,className:`w-32`})}):null,e.frequency===`hourly`?null:(0,K.jsx)(q,{label:`At time`,children:(0,K.jsx)(Ze,{hour24:e.hour24,minute:e.minute,onChange:(n,r)=>t({...e,hour24:n,minute:r})})})]})}function Ze({hour24:e,minute:t,onChange:n}){let r=e<12?`AM`:`PM`,i=e%12==0?12:e%12;return(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(k,{options:He,value:String(i),onChange:e=>n(Ke(Number(e),r),t),"aria-label":`Hour`,className:`w-[72px]`}),(0,K.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`:`}),(0,K.jsx)(k,{options:Ue,value:String(t).padStart(2,`0`),onChange:t=>n(e,Number(t)),"aria-label":`Minute`,className:`w-[72px]`}),(0,K.jsx)(`div`,{className:`w-[112px]`,children:(0,K.jsx)(x,{items:Ge,value:r,onChange:e=>n(Ke(i,e),t),ariaLabel:`AM or PM`})})]})}function Qe({value:e,onChange:t}){let n=new Set(e),i=e=>{let r=new Set(n);r.has(e)?r.size>1&&r.delete(e):r.add(e),t([...r].sort((e,t)=>e-t))};return(0,K.jsx)(`div`,{className:`flex gap-1.5`,children:W.map(e=>{let t=n.has(e.value);return(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),"aria-pressed":t,"aria-label":e.full,title:e.full,className:r(`flex h-9 w-9 items-center justify-center rounded-md border text-body-medium-default transition-colors`,t?`border-[var(--border-active)] bg-[var(--surface-active)] text-[var(--content-emphasised)]`:`border-[var(--field-border)] text-[var(--content-tertiary)] hover:border-[var(--border-active)] hover:text-[var(--content-default)]`),children:e.letter},e.value)})})}function $e({value:e,onChange:t,onUseSimple:n}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(w,{placeholder:`0 9 * * *`,value:e,onChange:e=>t(e.target.value),fullWidth:!0,className:`font-mono`,"aria-label":`Cron expression`,helperText:`Standard 5-field cron (minute hour day month weekday). RRULE expressions are also accepted.`}),(0,K.jsx)(`button`,{type:`button`,onClick:n,className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`← Back to the simple builder`})]})}function et({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:e}),t]})}function q({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,K.jsx)(`span`,{className:`min-w-[88px] text-body-small-default text-[var(--content-tertiary)]`,children:e}),t]})}function tt({summary:e,mono:t,timezoneLabel:n}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-lift)] px-3.5 py-3`,children:[(0,K.jsx)(h,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:r(`text-body-medium-default text-[var(--content-default)]`,t&&`break-all font-mono`),children:e}),(0,K.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[`Times use your timezone — `,n,`.`]})]})]})}function nt(e=B(),t=Date.now()){return Ae(`7d`,e,t)}function J(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0}):`—`}function rt(e){return e==null?`—`:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}var it=new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2});function Y(e){return e==null||!Number.isFinite(e)?`—`:it.format(e)}function at(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}function ot(e){let t=Math.round(e/6e4);return t>=60&&t%60==0?`Every ${t/60} hr`:`Every ${t} min`}function st(e){if(!e)return;let t=new Set,n=[];for(let r of e)for(let e of r.runs)t.has(e.id)||(t.add(e.id),n.push(e));return n}function ct(e){return!!e.conversationId&&e.conversationExists===!0&&e.conversationArchivedAt==null}function lt(e){return ct(e)?e.conversationId??null:null}function X(e){return typeof e==`string`&&e.length>0}var ut={heartbeat:`system-heartbeat`,consolidation:`system-consolidation`,retrospective:`system-memory-retrospective`};function dt(e){if(e.cronExpression)return e.timezone?`Cron: ${e.cronExpression} (${e.timezone})`:`Cron: ${e.cronExpression}`;let t=ot(e.intervalMs);return e.activeHoursStart!=null&&e.activeHoursEnd!=null&&(t+=` (${e.activeHoursStart}:00–${e.activeHoursEnd}:00)`),t}function ft(e){return ot(e.intervalMs)}var pt=`After conversation activity`;function mt(e,t){return e.status===`fired`||e.status===`cancelled`?!0:e.status===`firing`?!1:e.nextRunAt==null||!e.enabled&&e.nextRunAt<=t}function ht(e,t){let n=[],r=[],i=[];for(let a of e)a.isOneShot?mt(a,t)?i.push(a):r.push(a):n.push(a);return n.sort((e,t)=>e.enabled===t.enabled?(e.nextRunAt??1/0)-(t.nextRunAt??1/0):e.enabled?-1:1),r.sort((e,t)=>(e.nextRunAt??1/0)-(t.nextRunAt??1/0)),i.sort((e,t)=>{let n=e.lastRunAt??e.nextRunAt??0;return(t.lastRunAt??t.nextRunAt??0)-n}),{recurring:n,upcomingOneTime:r,pastOneTime:i}}function gt(e,t,n=!0){return{queryKey:[{_id:`schedulesUsagesummaryGet`,path:{assistant_id:e??``},_tz:t}],queryFn:()=>e?be(e,nt(t)):Promise.resolve([]),enabled:n,staleTime:1e4}}function _t(e){return{scheduleId:e,runCount:0,totalEstimatedCostUsd:0,eventCount:0}}function vt(e,t,n){let r=(t??[]).filter(e=>{let t=e.startedAt??e.createdAt;return t>=n.from&&t<=n.to});return{scheduleId:e,runCount:r.length,totalEstimatedCostUsd:r.reduce((e,t)=>{let n=t.estimatedCostUsd;return typeof n==`number`&&Number.isFinite(n)?e+n:e},0),eventCount:0}}function yt({status:e}){return(0,K.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:e===`ok`||e===`completed`?`var(--system-positive-strong)`:e===`error`||e===`failed`?`var(--system-negative-strong)`:`var(--content-tertiary)`},"aria-label":e??`unknown`})}function bt({scheduleName:e,usage:t,onOpenUsage:n}){if(t.status===`loading`)return(0,K.jsxs)(`div`,{"aria-label":`Loading schedule usage`,className:`flex w-[156px] shrink-0 items-center justify-end gap-3`,children:[(0,K.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,K.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`})]});let r=t.status===`error`,i=r?`--`:Y(t.summary.totalEstimatedCostUsd),a=r?`--`:at(t.summary.runCount),o=t.status===`ready`&&!(t.summary.totalEstimatedCostUsd>0),s=t.status===`ready`&&t.summary.runCount===0,c=o?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`,l=s?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`;return(0,K.jsxs)(`div`,{className:`flex w-[156px] shrink-0 items-center justify-end gap-3 text-right text-body-small-default`,children:[n?(0,K.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`View usage for ${e}`,className:`min-w-[64px] cursor-pointer rounded px-1 py-0.5 text-right transition-colors hover:bg-[var(--surface-hover)] ${c}`,children:i}):(0,K.jsx)(`span`,{"aria-label":`Cost for ${e} in the last 7 days: ${i}`,className:`block min-w-[64px] px-1 py-0.5 ${c}`,children:i}),(0,K.jsx)(`span`,{"aria-label":`Runs for ${e} in the last 7 days: ${a}`,className:`block min-w-[64px] px-1 py-0.5 ${l}`,children:a})]})}function xt({name:e,subtitle:t,enabled:n,nextRunAt:r,lastRunAt:i,usage:a,helperText:o,statusLabel:s,statusTone:c=`neutral`,onClick:l}){return(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md px-2 py-3 transition-colors hover:bg-[var(--surface-hover)] [&+&]:border-t [&+&]:border-[var(--border-base)]`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:l,"aria-label":`Open ${e}`,className:`flex min-w-0 flex-1 cursor-pointer flex-wrap items-center gap-3 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e})}),(0,K.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:t}),o?(0,K.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-secondary)]`,children:o}):null,(0,K.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-body-small-default text-[var(--content-tertiary)]`,children:[r?(0,K.jsxs)(`span`,{children:[`Next: `,J(r)]}):null,i?(0,K.jsxs)(`span`,{children:[`Last: `,J(i)]}):null]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-3`,children:[(0,K.jsx)(bt,{scheduleName:e,usage:a}),s?(0,K.jsx)(S,{tone:c,children:s}):(0,K.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:n?`var(--system-positive-strong)`:`var(--content-disabled)`},"aria-label":n?`enabled`:`disabled`}),(0,K.jsx)(m,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})})}function St({heartbeatConfig:e,consolidationConfig:t,retrospectiveConfig:n,heartbeatUsage:r,consolidationUsage:i,retrospectiveUsage:a,isLoading:o,hasError:s,onRetry:c,onSelectHeartbeat:l,onSelectConsolidation:u,onSelectRetrospective:d}){let f=e!=null,m=t?.available===!0,h=n?.available===!0,_=f||m||h;if(!o&&!s&&!_)return null;let v=[...f?[r]:[],...m?[i]:[],...h?[a]:[]].filter(e=>e.status===`ready`),x=v.reduce((e,t)=>e+(t.summary.totalEstimatedCostUsd??0),0),S=o?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(g,{className:`h-5 w-5 animate-spin text-stone-400`})}):s&&!_?(0,K.jsxs)(y,{tone:`error`,children:[`Failed to load system jobs.`,` `,(0,K.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}):(0,K.jsxs)(`div`,{children:[f?(0,K.jsx)(xt,{name:`Heartbeat`,subtitle:dt(e),enabled:e.enabled,nextRunAt:e.nextRunAt,lastRunAt:e.lastRunAt,usage:r,onClick:l}):null,m?(0,K.jsx)(xt,{name:`Consolidation`,subtitle:ft(t),enabled:t.enabled,helperText:t.enabled?void 0:`Memory is off, so consolidation is paused.`,nextRunAt:t.nextRunAt,lastRunAt:t.lastRunAt,usage:i,statusLabel:t.enabled?void 0:`Paused`,statusTone:`warning`,onClick:u}):null,h?(0,K.jsx)(xt,{name:`Memory retrospective`,subtitle:pt,enabled:n.enabled,helperText:n.enabled?void 0:`Memory is off, so retrospectives are paused.`,nextRunAt:n.nextRunAt,lastRunAt:n.lastRunAt,usage:a,statusLabel:n.enabled?void 0:`Paused`,statusTone:`warning`,onClick:d}):null,s?(0,K.jsx)(`div`,{className:`pt-3 first:pt-0`,children:(0,K.jsxs)(y,{tone:`error`,children:[`Some system jobs failed to load.`,` `,(0,K.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]})}):null]});return(0,K.jsx)(ye,{children:(0,K.jsx)(b.Root,{type:`multiple`,children:(0,K.jsxs)(b.Item,{value:`system-jobs`,children:[(0,K.jsxs)(b.Trigger,{className:`group justify-between gap-3`,children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1 text-left`,children:[(0,K.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`System`}),(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Built-in jobs managed by the assistant runtime`})]}),(0,K.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[v.length>0?(0,K.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[Y(x),` (7d)`]}):null,(0,K.jsx)(p,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]})]}),(0,K.jsx)(b.Content,{children:(0,K.jsx)(`div`,{className:`mt-3`,children:S})})]})})})}function Z(e,t){return{id:e.id,jobId:t,status:e.status,startedAt:e.startedAt??e.scheduledFor,finishedAt:e.finishedAt,durationMs:e.durationMs,output:`skipReason`in e&&e.skipReason?`Skipped: ${e.skipReason}`:null,error:e.error,conversationId:e.conversationId,conversationExists:e.conversationExists,conversationArchivedAt:e.conversationArchivedAt,estimatedCostUsd:e.estimatedCostUsd,createdAt:e.createdAt,...`title`in e?{title:e.title}:{}}}function Ct(e){return e.runs.map(e=>Z(e,`heartbeat`))}function wt(e){return e.runs.map(e=>Z(e,`consolidation`))}function Tt(e){return e.runs.map(e=>Z(e,`retrospective`))}var Q=1e4;function Et(e,t,n,r,i){return e?{status:`loading`}:t?{status:`error`}:{status:`ready`,summary:vt(n,r,i)}}function Dt(e,n){let r=s(),i={path:{assistant_id:e??``}},{data:a,isLoading:o,isError:l,refetch:u}=c({...ie(i),enabled:!!e,staleTime:Q}),{data:d,isLoading:f,isError:p,refetch:m}=c({...R(i),enabled:!!e,staleTime:Q}),{data:h,isLoading:g,isError:_,refetch:v}=c({...se(i),enabled:!!e,staleTime:Q}),y={path:{assistant_id:e??``},query:{limit:100}},{data:b,isLoading:x,isError:S,refetch:C}=c({...j(y),select:Ct,enabled:!!e&&a!=null,staleTime:Q}),{data:w,isLoading:T,isError:E,refetch:D}=c({...le(y),select:wt,enabled:!!e&&d?.available===!0,staleTime:Q}),{data:k,isLoading:P,isError:F,refetch:I}=c({...oe(y),select:Tt,enabled:!!e&&h?.available===!0,staleTime:Q}),L=(0,U.useMemo)(()=>nt(n),[n]),ne=(0,U.useMemo)(()=>Et(x,S,ut.heartbeat,b,L),[b,S,x,L]),ae=(0,U.useMemo)(()=>Et(T,E,ut.consolidation,w,L),[w,E,T,L]),ue=(0,U.useMemo)(()=>Et(P,F,ut.retrospective,k,L),[k,F,P,L]),z=t=>{if(!e)return;let n={heartbeat:{config:ie(i).queryKey,runs:j(y).queryKey,infinite:ee(i)},consolidation:{config:R(i).queryKey,runs:le(y).queryKey,infinite:ce(i)},retrospective:{config:se(i).queryKey,runs:oe(y).queryKey,infinite:re(i)}}[t];r.invalidateQueries({queryKey:n.config}),r.invalidateQueries({queryKey:n.runs}),r.invalidateQueries({queryKey:n.infinite})},B=te({onSuccess:e=>{e.ran?O.success(`Heartbeat started.`):O.info(`Heartbeat skipped.`)},onError:e=>{t(e,{context:`heartbeat_run_now`}),O.error(`Failed to run heartbeat.`)},onSettled:()=>z(`heartbeat`)}),V=A({onSuccess:e=>{e.ran?O.success(`Consolidation queued.`):O.info(`Consolidation already queued or running.`)},onError:e=>{t(e,{context:`consolidation_run_now`}),O.error(`Failed to run consolidation.`)},onSettled:()=>z(`consolidation`)}),H=M({onSuccess:e=>{N(r,i,e),O.success(e.enabled?`Heartbeat enabled.`:`Heartbeat disabled.`)},onError:e=>{t(e,{context:`heartbeat_toggle`}),O.error(`Failed to toggle heartbeat.`)}});return{heartbeatConfig:a,consolidationConfig:d,retrospectiveConfig:h,heartbeatUsage:ne,consolidationUsage:ae,retrospectiveUsage:ue,isLoading:o||f||g,hasError:l||p||_,isHeartbeatRunning:B.isPending,isConsolidationRunning:V.isPending,isHeartbeatLoading:o,isHeartbeatError:l,isConsolidationLoading:f,isConsolidationError:p,isRetrospectiveLoading:g,isRetrospectiveError:_,refetchHeartbeat:u,refetchConsolidation:m,refetchRetrospective:v,runHeartbeatNow:()=>{e&&B.mutate({path:{assistant_id:e}})},runConsolidationNow:()=>{e&&V.mutate({path:{assistant_id:e}})},toggleHeartbeat:t=>{e&&H.mutate({body:{enabled:t},path:{assistant_id:e}})},refetchAll:()=>{u(),m(),v(),C(),D(),I()}}}function Ot({children:e}){return(0,K.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function $({label:e,value:t}){return(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-1`,children:[(0,K.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e}),(0,K.jsx)(`span`,{className:`min-w-0 text-right text-body-medium-lighter text-[var(--content-default)]`,children:t})]})}function kt({icon:e,value:t,label:n}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] p-3`,children:[(0,K.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--surface-sunken)] text-[var(--content-secondary)]`,children:e}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-body-large-default text-[var(--content-default)]`,children:t}),(0,K.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:n})]})]})}function At({usage:e}){return e.status===`loading`?(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:Array.from({length:2},(e,t)=>(0,K.jsx)(`div`,{className:`h-[60px] animate-pulse rounded-lg bg-[var(--surface-muted)]`},t))}):e.status===`error`?null:(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:[(0,K.jsx)(kt,{icon:(0,K.jsx)(fe,{className:`h-4 w-4`}),value:Y(e.summary.totalEstimatedCostUsd),label:`7 Day Cost`}),(0,K.jsx)(kt,{icon:(0,K.jsx)(_,{className:`h-4 w-4`}),value:at(e.summary.runCount),label:`7 Day Runs`})]})}function jt(e){return e.exists&&e.archivedAt==null}function Mt({run:e,index:t,isExpanded:n,disableDirectOpen:i,onOpenConversation:a,onToggleDetails:o}){let s=lt(e),c=e.conversations??(s?[{id:s,title:null,exists:!0,archivedAt:null}]:[]),l=X(e.output),u=X(e.error),d=!i&&c.length===1&&jt(c[0])?c[0].id:null,f=!d&&(c.length>0||l||u),p=`schedule-run-details-${t}`,h=!!d||f,g=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yt,{status:e.status}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:J(e.startedAt)}),(0,K.jsxs)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[rt(e.durationMs),` ·`,` `,Y(e.estimatedCostUsd)]}),e.status===`error`&&e.error?(0,K.jsxs)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--system-negative-strong)]`,children:[e.error.slice(0,120),e.error.length>120?`…`:``]}):null]}),h?(0,K.jsx)(m,{className:r(`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform`,f&&n?`rotate-90`:``)}):null]}),_=f&&n?(0,K.jsx)(`div`,{id:p,className:`px-2 pb-3`,children:(0,K.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[c.length>0?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Conversations`}),(0,K.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>jt(e)?(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(e.id),className:`block w-full truncate text-left text-body-small-default text-[var(--content-default)] hover:underline`,children:X(e.title)?e.title:`Conversation`},e.id):(0,K.jsxs)(`span`,{className:`block truncate text-body-small-default text-[var(--content-tertiary)] italic`,children:[X(e.title)?e.title:`Conversation`,` `,e.exists?`(archived)`:`(unavailable)`]},e.id))})]}):null,l?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,u?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null;return d?(0,K.jsx)(`div`,{children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(d),"aria-label":`Open conversation for run at ${J(e.startedAt)}`,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g})}):f?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),"aria-label":`Toggle details for run at ${J(e.startedAt)}`,"aria-expanded":n,"aria-controls":p,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g}),_]}):(0,K.jsx)(`div`,{className:`flex items-center gap-3 px-2 py-3`,children:g})}function Nt({runs:e,isLoading:t,disableDirectOpen:n,onOpenConversation:r}){let[i,a]=(0,U.useState)(null);return t?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,K.jsx)(g,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,K.jsx)(`p`,{className:`py-2 text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:`No runs yet.`}):(0,K.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.map((e,t)=>(0,K.jsx)(Mt,{run:e,index:t,isExpanded:i===e.id,disableDirectOpen:n,onOpenConversation:r,onToggleDetails:e=>a(t=>t===e?null:e)},e.id))})}function Pt({schedule:e,assistantId:n,usage:a,isMobile:s,onClose:l,onDeleted:d}){let f=o(),{data:p,isLoading:m}=c({queryKey:ae({path:{assistant_id:n,id:e.id}}),queryFn:()=>Se(n,e.id),staleTime:1e4}),[h,_]=(0,U.useState)(!1),[y,b]=(0,U.useState)(!1),[x,S]=(0,U.useState)(!1),C=async()=>{_(!0);try{await Te(n,e.id)}catch(e){t(e,{context:`schedule_run_now`}),O.error(`Failed to run schedule.`)}finally{_(!1)}},w=async()=>{S(!0);try{await Ee(n,e.id),d()}catch(e){t(e,{context:`schedule_delete`}),O.error(`Failed to delete schedule.`),S(!1),b(!1)}};return(0,K.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:e.name})}),(0,K.jsx)(i,{variant:`ghost`,iconOnly:(0,K.jsx)(v,{}),onClick:l,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,K.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[e.description?(0,K.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e.description}):null,(0,K.jsxs)(`section`,{children:[(0,K.jsx)(Ot,{children:`Details`}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-2`,children:[e.cadenceDescription?(0,K.jsx)($,{label:`Cadence`,value:e.cadenceDescription}):null,(0,K.jsx)($,{label:`Mode`,value:e.mode}),(0,K.jsx)($,{label:`Status`,value:e.enabled?`Enabled`:`Disabled`}),(0,K.jsx)($,{label:`Next run`,value:J(e.nextRunAt)}),e.lastRunAt?(0,K.jsx)($,{label:`Last run`,value:(0,K.jsxs)(`span`,{className:`flex items-center justify-end gap-2`,children:[(0,K.jsx)(yt,{status:e.lastStatus}),J(e.lastRunAt)]})}):null]})]}),(0,K.jsx)(At,{usage:a}),(0,K.jsxs)(`section`,{children:[(0,K.jsx)(Ot,{children:`Recent runs`}),(0,K.jsx)(Nt,{runs:p?.runs,isLoading:m,disableDirectOpen:e.mode===`script`,onOpenConversation:e=>f(z.conversation(e))})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[y?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(i,{variant:`ghost`,onClick:()=>b(!1),disabled:x,children:`Cancel`}),(0,K.jsx)(i,{variant:`danger`,onClick:()=>void w(),disabled:x,children:x?`Deleting…`:`Yes, delete`})]}):(0,K.jsx)(i,{variant:`dangerOutline`,leftIcon:(0,K.jsx)(me,{className:`h-3.5 w-3.5`}),onClick:()=>b(!0),children:`Delete`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(i,{variant:`outlined`,leftIcon:(0,K.jsx)(Me,{className:`h-3.5 w-3.5`}),onClick:()=>f(z.settings.usageForSchedule(e.id)),children:`View usage`}),e.mode===`script`?(0,K.jsx)(i,{variant:`primary`,leftIcon:h?(0,K.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):void 0,onClick:()=>void C(),disabled:h,children:h?`Running…`:`Run now`}):null]})]})]})}function Ft(e){if(e.status===`loading`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`h-4 w-12 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,K.jsx)(`span`,{className:`h-4 w-10 animate-pulse rounded bg-[var(--surface-muted)]`})]});if(e.status===`error`)return(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`—`});let{summary:t}=e;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:Y(t.totalEstimatedCostUsd)}),(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:at(t.runCount)})]})}function It({name:e,metaParts:t,usage:n,enabled:r,selected:i,onClick:a,onToggle:o,toggleAriaLabel:s}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md px-2 py-3 transition-colors [&+&]:border-t [&+&]:border-[var(--border-base)] ${i?`bg-[var(--surface-active)]`:`hover:bg-[var(--surface-hover)]`}`,children:[o?(0,K.jsx)(T,{checked:r,onChange:o,"aria-label":s}):null,(0,K.jsxs)(`button`,{type:`button`,onClick:a,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-4 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e}),t.length>0?(0,K.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 text-label-small-default text-[var(--content-tertiary)]`,children:t.map((e,t)=>(0,K.jsxs)(U.Fragment,{children:[t>0?(0,K.jsx)(`span`,{className:`h-[3px] w-[3px] shrink-0 rounded-full bg-[var(--content-tertiary)]`}):null,(0,K.jsx)(`span`,{className:`truncate`,children:e})]},t))}):null]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4`,children:[Ft(n),(0,K.jsx)(m,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})]})}function Lt({schedule:e,usage:t,selected:n,onClick:r,onToggle:i}){let a=e.isOneShot?``:e.cadenceDescription.trim(),o=e.lastRunAt??e.nextRunAt,s=[a,o?J(o):``].filter(Boolean);return(0,K.jsx)(It,{name:e.name,metaParts:s,usage:t,enabled:e.enabled,selected:n,onClick:r,onToggle:i,toggleAriaLabel:i?`Toggle ${e.name}`:void 0})}function Rt({recurring:e,oneTime:t,pastOneTime:n,usageForSchedule:r,isLoading:a,isError:o,refetch:s,onToggle:c,onSelectSchedule:l,selectedScheduleId:u,onStartNewChat:d,onCreateSchedule:p,pastOpen:h,onPastOpenChange:g,systemTasksSlot:_}){let v=e=>(0,K.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id),onToggle:t=>c(e.id,t)},e.id),x=e=>(0,K.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id)},e.id),S=n.length>0?(0,K.jsx)(b.Root,{type:`single`,collapsible:!0,className:`mt-3`,value:h?`past`:``,onValueChange:e=>g(e===`past`),children:(0,K.jsxs)(b.Item,{value:`past`,children:[(0,K.jsxs)(b.Trigger,{className:`group gap-[var(--app-spacing-xs)] px-2 text-label-small-default text-[var(--content-tertiary)]`,children:[(0,K.jsx)(m,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,K.jsxs)(`span`,{children:[`Past (`,n.length,`)`]})]}),(0,K.jsx)(b.Content,{children:(0,K.jsx)(`div`,{className:`pt-1`,children:n.map(x)})})]})}):null;return(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[a?(0,K.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2},(e,t)=>(0,K.jsx)(`div`,{className:`h-12 animate-pulse rounded-md bg-[var(--surface-muted)]`},t))}):o&&e.length===0?(0,K.jsx)(y,{tone:`error`,actions:(0,K.jsx)(`button`,{type:`button`,onClick:s,className:`cursor-pointer underline hover:no-underline`,children:`Retry`}),children:`Failed to load schedules.`}):e.length===0&&t.length===0&&n.length===0?(0,K.jsx)(Oe,{icon:f,title:`No schedules yet`,description:`Ask your assistant to set one up, or create one yourself.`,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(i,{variant:`primary`,size:`regular`,onClick:d,children:`New Conversation`}),(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`or`}),(0,K.jsx)(i,{variant:`outlined`,size:`regular`,onClick:p,children:`Create schedule`})]})}):(0,K.jsxs)(`div`,{children:[e.map(v),t.length>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mt-3 px-2 text-label-small-default text-[var(--content-tertiary)]`,children:`One-time`}),t.map(x)]}):null,S]}),_?(0,K.jsx)(`div`,{className:`mt-[var(--app-spacing-lg)]`,children:_}):null]})}var zt=`Default (assistant's main model)`,Bt=`Custom call-site model`;function Vt(e,t){return t?.[e]?.displayName??e}function Ht(e,t){if(e==null)return;if(e.provider!=null||e.model!=null)return Bt;let n=e.profile?.trim();return n?`Override (${Vt(n,t)})`:void 0}function Ut({assistantId:e,pinnedProfile:t,defaultCallSite:n=`mainAgent`,fallbackLabel:r=zt,respectCallSiteOverride:i=!1}){let a=t==null,{data:o}=c({...I({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4}),s=(0,U.useMemo)(()=>o?je(o):{},[o]),{data:l}=c({...L({path:{assistant_id:e}}),enabled:!!e&&a,staleTime:6e4}),u=a&&i?Ht(o?.llm?.callSites?.[n],s):void 0,d=a?l?.callSites.find(e=>e.id===n)?.defaultProfile:void 0,f=t==null?u??(d==null?r:`Default (${Vt(d,s)})`):Vt(t,s);return(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Model profile`}),(0,K.jsx)(`span`,{className:`min-w-0 text-right`,children:f})]})}function Wt({runs:e,isLoading:t,emptyMessage:n=`No runs yet.`,hasMore:r=!1,isLoadingMore:a=!1,onLoadMore:s}){let c=o(),[l,u]=(0,U.useState)(null);return(0,K.jsx)(ye,{title:`Recent runs`,children:t?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(g,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,K.jsx)(`p`,{className:`py-4 text-center text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:n}):(0,K.jsxs)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:[e.map((e,t)=>{let n=lt(e),r=X(e.output),i=X(e.error),a=!n&&(r||i),o=l===e.id,s=`schedule-run-details-${t}`;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(D,{label:(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,K.jsx)(yt,{status:e.status}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate text-body-medium-lighter text-[var(--content-default)]`,children:X(e.title)?e.title:J(e.startedAt)}),(0,K.jsxs)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[X(e.title)?`${J(e.startedAt)} · `:``,rt(e.durationMs),` ·`,` `,Y(e.estimatedCostUsd),e.status===`error`&&e.error&&(0,K.jsxs)(`span`,{className:`ml-2 text-[var(--system-negative-strong)]`,children:[e.error.slice(0,80),e.error.length>80?`…`:``]})]})]}),n||a?(0,K.jsx)(m,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform ${o?`rotate-90`:``}`}):null]}),onSelect:n?()=>c(z.conversation(n)):a?()=>u(o?null:e.id):void 0,"aria-label":`Run at ${J(e.startedAt)}`,"aria-expanded":a?o:void 0,"aria-controls":a?s:void 0,className:`h-auto py-2.5 gap-3 -mx-2 px-2`}),a&&o?(0,K.jsx)(`div`,{id:s,className:`px-2 pb-3`,children:(0,K.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[r?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,i?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null]},e.id)}),r&&s?(0,K.jsx)(`div`,{className:`flex justify-center pt-3`,children:(0,K.jsx)(i,{variant:`outlined`,size:`compact`,onClick:s,disabled:a,leftIcon:a?(0,K.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):void 0,children:a?`Loading…`:`Load more`})}):null]})})}var Gt={heartbeat:`heartbeatAgent`,consolidation:`memoryV2Consolidation`,retrospective:`memoryRetrospective`};function Kt({children:e}){return(0,K.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function qt({kind:e,assistantId:t,systemTasks:n,canOpenMemorySettings:a,isMobile:s,onClose:c}){let l=o(),{heartbeatConfig:d,consolidationConfig:f,retrospectiveConfig:p}=n,m,h,_,b,x,S,C;e===`heartbeat`?(m=`Heartbeat`,h=d?dt(d):``,_=d?.enabled??!1,b=d?.nextRunAt??null,x=d?.lastRunAt??null,S=n.isHeartbeatRunning,C=n.runHeartbeatNow):e===`consolidation`?(m=`Consolidation`,h=f?ft(f):``,_=f?.enabled??!1,b=f?.nextRunAt??null,x=f?.lastRunAt??null,S=n.isConsolidationRunning,C=n.runConsolidationNow):(m=`Memory retrospective`,h=pt,_=p?.enabled??!1,b=p?.nextRunAt??null,x=p?.lastRunAt??null,S=!1,C=void 0);let w=e!==`heartbeat`,E=e===`retrospective`,D=w&&!_,O=S||D,k=w?_?`On · Managed by Memory`:`Paused`:_?`Enabled`:`Disabled`,A=E?`Memory is off, so retrospectives are paused. Turn Memory back on to resume them.`:`Memory is off, so consolidation is paused. Turn Memory back on to resume consolidation.`,j=w&&_&&a,M={path:{assistant_id:t},query:{limit:25}},N=e===`heartbeat`?P(M):e===`consolidation`?F(M):ne(M),{data:ee,isLoading:te,fetchNextPage:I,hasNextPage:L,isFetchingNextPage:re}=he({queryKey:N.queryKey,queryFn:N.queryFn,initialPageParam:{path:M.path,query:{}},getNextPageParam:e=>e.nextCursor??void 0,staleTime:1e4}),R=st(ee?.pages.map(t=>({runs:t.runs.map(t=>Z(t,e))})));return(0,K.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:m}),h?(0,K.jsx)(u,{variant:`body-small-default`,as:`p`,className:`truncate text-[var(--content-tertiary)]`,children:h}):null]}),(0,K.jsx)(i,{variant:`ghost`,iconOnly:(0,K.jsx)(v,{}),onClick:c,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,K.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[(0,K.jsxs)(`section`,{children:[(0,K.jsx)(Kt,{children:`Details`}),(0,K.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-3 text-body-medium-lighter`,children:[(0,K.jsx)(Ut,{assistantId:t,defaultCallSite:Gt[e],fallbackLabel:`Default (system task model)`,respectCallSiteOverride:!0}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Status`}),(0,K.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--content-default)]`,children:[(0,K.jsx)(`span`,{children:k}),w?null:(0,K.jsx)(T,{checked:_,onChange:n.toggleHeartbeat,"aria-label":`Toggle ${m}`})]})]}),E?null:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Next run`}),(0,K.jsx)(`span`,{className:`text-[var(--content-default)]`,children:J(b)})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Last run`}),(0,K.jsx)(`span`,{className:`text-[var(--content-default)]`,children:J(x)})]})]}),D?(0,K.jsx)(y,{tone:`warning`,className:`mt-4`,actions:a?(0,K.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Turn on Memory`}):void 0,children:A}):null]}),(0,K.jsx)(Wt,{runs:R,isLoading:te,hasMore:L,isLoadingMore:re,onLoadMore:()=>void I()})]}),j||C?(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[j?(0,K.jsx)(i,{variant:`outlined`,leftIcon:(0,K.jsx)(pe,{className:`h-3.5 w-3.5`}),onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Memory settings`}):null,C?(0,K.jsx)(i,{variant:`primary`,leftIcon:S?(0,K.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(ge,{className:`h-3.5 w-3.5`}),onClick:C,disabled:O,children:S?`Running…`:`Run now`}):null]}):null]})}function Jt(e){let n=H(),[r]=(0,U.useState)(()=>Date.now()),{data:i,isLoading:a,isError:o,refetch:s}=c(De(e)),{data:l,isLoading:u,isError:d}=c(gt(e,n,!0)),{recurring:f,oneTime:p,pastOneTime:m}=(0,U.useMemo)(()=>{let e=ht(i??[],r);return{recurring:e.recurring,oneTime:e.upcomingOneTime,pastOneTime:e.pastOneTime}},[r,i]),h=(0,U.useMemo)(()=>new Map((l??[]).map(e=>[e.scheduleId,e])),[l]);return{recurring:f,oneTime:p,pastOneTime:m,usageForSchedule:(0,U.useCallback)(e=>u?{status:`loading`}:d?{status:`error`}:{status:`ready`,summary:h.get(e)??_t(e)},[d,u,h]),handleToggle:(0,U.useCallback)(async(n,r)=>{if(e)try{await xe(e,n,r),s()}catch(e){t(e,{context:`schedule_toggle`}),O.error(`Failed to toggle schedule.`)}},[e,s]),isLoading:a,isError:o,refetch:(0,U.useCallback)(()=>{s()},[s])}}function Yt(){let e=o(),{scheduleId:t}=a(),n=ve(),r=_e(),i=H(),s=Jt(n),l=Dt(n,i),{data:u=!1}=c({queryKey:[`assistant-memory-opt-out-capability`,n],queryFn:async()=>{let e=await ue(n);return e.ok&&e.data.capabilities?.memoryOptOut===!0},retry:!1,staleTime:1e4}),d=V.use.settingsDeveloperNav(),f=u&&d===!0,[p,m]=(0,U.useState)(!1),h=t??null,[g,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(!1),b=(0,U.useCallback)(t=>{e(t?z.schedules.detail(t):z.schedules.root)},[e]),x=h?s.recurring.find(e=>e.id===h)??s.oneTime.find(e=>e.id===h)??s.pastOneTime.find(e=>e.id===h)??null:null;(0,U.useEffect)(()=>{h&&!s.isLoading&&!s.isError&&!x&&b(null)},[h,x,s.isLoading,s.isError,b]);let S=g===`heartbeat`?l.heartbeatConfig!=null:g===`consolidation`?l.consolidationConfig?.available===!0:g===`retrospective`?l.retrospectiveConfig?.available===!0:!1;(0,U.useEffect)(()=>{g&&!l.isLoading&&!S&&_(null)},[g,S,l.isLoading]);let C=(0,U.useCallback)(e=>{_(null),b(e)},[b]),w=(0,U.useCallback)(e=>{h&&b(null),_(e)},[b,h]),T=(0,U.useCallback)(()=>{de(e)},[e]),E=(x?(0,K.jsx)(Pt,{schedule:x,assistantId:n,usage:s.usageForSchedule(x.id),isMobile:r,onClose:()=>b(null),onDeleted:()=>{b(null),s.refetch()}}):null)??(g&&S?(0,K.jsx)(qt,{kind:g,assistantId:n,systemTasks:l,canOpenMemorySettings:f,isMobile:r,onClose:()=>_(null)}):null),D=(0,K.jsx)(Rt,{recurring:s.recurring,oneTime:s.oneTime,pastOneTime:s.pastOneTime,usageForSchedule:s.usageForSchedule,isLoading:s.isLoading,isError:s.isError,refetch:s.refetch,onToggle:s.handleToggle,onSelectSchedule:C,selectedScheduleId:h,onStartNewChat:T,onCreateSchedule:()=>m(!0),pastOpen:v,onPastOpenChange:y,systemTasksSlot:(0,K.jsx)(St,{heartbeatConfig:l.heartbeatConfig,consolidationConfig:l.consolidationConfig,retrospectiveConfig:l.retrospectiveConfig,heartbeatUsage:l.heartbeatUsage,consolidationUsage:l.consolidationUsage,retrospectiveUsage:l.retrospectiveUsage,isLoading:l.isLoading,hasError:l.hasError,onRetry:l.refetchAll,onSelectHeartbeat:()=>w(`heartbeat`),onSelectConsolidation:()=>w(`consolidation`),onSelectRetrospective:()=>w(`retrospective`)})});return E&&r?(0,K.jsx)(ke,{children:E}):(0,K.jsxs)(K.Fragment,{children:[E&&!r?(0,K.jsx)(Ce,{storageKey:`schedulesDetailDrawerWidth`,detailKey:h??g??void 0,section:D,detail:E}):D,(0,K.jsx)(Je,{isOpen:p,assistantId:n,onClose:()=>m(!1),onCreated:()=>{m(!1),s.refetch()}})]})}export{Yt as SchedulesPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-BGD3-GQf.js";import{t as n}from"./react-DJZBPgpf.js";import{P as r,t as i}from"./button-BQVYX8n_.js";import{f as a,u as o}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./useQuery-B45lW1Kk.js";import{t as l}from"./jsx-runtime-CVSDxk6A.js";import{t as u}from"./typography-Cqi8q9o7.js";import{t as d}from"./createLucideIcon-Bjb-Kuq7.js";import{t as f}from"./calendar-D0labpMU.js";import{t as p}from"./chevron-down-DpYf9Gwq.js";import{t as m}from"./chevron-right-jRymmL7S.js";import{t as h}from"./clock-LiCGqvyn.js";import{t as g}from"./loader-circle-D57RZgLH.js";import{t as _}from"./repeat-CS_kgMdk.js";import{t as v}from"./x-CswtfvgS.js";import{t as y}from"./notice-BylgS5W_.js";import{i as b,j as x}from"./src-CDdn26Yb.js";import{t as S}from"./tag-B6WeUtBW.js";import{n as C,t as w}from"./input-ZpyYt_a0.js";import{t as T}from"./toggle-QSEiPr3k.js";import{t as E}from"./modal-BtcwNEBj.js";import{t as D}from"./panel-item-Bvqsr5n9.js";import{n as O}from"./toast-ZoZVyeDI.js";import{t as k}from"./dropdown-BMNSccmo.js";import{Bt as A,F as j,Jt as M,M as N,N as P,P as ee,Yt as te,_ as F,c as I,d as L,dt as ne,ft as re,g as R,j as ie,mt as ae,pt as oe,ut as se,v as ce,y as le}from"./react-query.gen-BQH0QRfT.js";import{a as ue}from"./api-BBMl4mW3.js";import{c as z}from"./routes-XPLb07Av.js";import{t as B}from"./effective-timezone-Ct3PoWNH.js";import{t as V}from"./assistant-feature-flag-store-BpbbAIKZ.js";import{$n as H,Br as de,Ma as fe,Qi as pe,Ui as me,Xa as he,ia as ge,zr as _e}from"./index-CgcZXB4g.js";import{t as ve}from"./use-active-assistant-id-9rGx8kT9.js";import{t as ye}from"./detail-card-CA8lPa5K.js";import{a as be,c as xe,i as Se,l as Ce,n as we,o as Te,r as Ee,s as De,t as Oe,u as ke}from"./page-empty-state-DbCk3v6f.js";import{r as Ae,t as je}from"./profile-metadata-DZwV-VFB.js";var Me=d(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),U=e(n(),1),Ne={frequency:`daily`,minute:0,hour24:9,weekdays:[1],dayOfMonth:1},W=[{value:0,letter:`S`,short:`Sun`,full:`Sunday`},{value:1,letter:`M`,short:`Mon`,full:`Monday`},{value:2,letter:`T`,short:`Tue`,full:`Tuesday`},{value:3,letter:`W`,short:`Wed`,full:`Wednesday`},{value:4,letter:`T`,short:`Thu`,full:`Thursday`},{value:5,letter:`F`,short:`Fri`,full:`Friday`},{value:6,letter:`S`,short:`Sat`,full:`Saturday`}],Pe=[1,2,3,4,5];function G(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function Fe(e){let t=Array.from(new Set(e.map(e=>G(e,0,6)).filter(e=>Number.isInteger(e)))).sort((e,t)=>e-t);return t.length>0?t:[1]}function Ie(e){let t=G(e.minute,0,59),n=G(e.hour24,0,23);switch(e.frequency){case`hourly`:return`${t} * * * *`;case`daily`:return`${t} ${n} * * *`;case`weekly`:return`${t} ${n} * * ${Fe(e.weekdays).join(`,`)}`;case`monthly`:return e.dayOfMonth===`last`?`${t} ${n} L * *`:`${t} ${n} ${G(e.dayOfMonth,1,28)} * *`}}function Le(e,t){let n=G(e,0,23),r=G(t,0,59),i=n<12?`AM`:`PM`;return`${n%12==0?12:n%12}:${String(r).padStart(2,`0`)} ${i}`}function Re(e){let t=[`th`,`st`,`nd`,`rd`],n=e%100;return`${e}${t[(n-20)%10]??t[n]??t[0]}`}function ze(e){let t=Fe(e),n=new Set(t);if(t.length===7)return`every day`;if(t.length===5&&Pe.every(e=>n.has(e)))return`every weekday`;if(t.length===2&&n.has(0)&&n.has(6))return`every weekend`;if(t.length===1)return`every ${W[t[0]]?.full??`day`}`;let r=t.map(e=>W[e]?.short??``),i=r.pop();return`every ${r.join(`, `)} & ${i}`}function Be(e){let t=Le(e.hour24,e.minute);switch(e.frequency){case`hourly`:{let t=G(e.minute,0,59);return`Runs every hour at :${String(t).padStart(2,`0`)}`}case`daily`:return`Runs every day at ${t}`;case`weekly`:return`Runs ${ze(e.weekdays)} at ${t}`;case`monthly`:return e.dayOfMonth===`last`?`Runs on the last day of every month at ${t}`:`Runs on the ${Re(G(e.dayOfMonth,1,28))} of every month at ${t}`}}var K=l(),Ve=[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}],He=Array.from({length:12},(e,t)=>{let n=t+1;return{value:String(n),label:String(n)}}),Ue=Array.from({length:12},(e,t)=>{let n=t*5,r=String(n).padStart(2,`0`);return{value:r,label:r}}),We=[...Array.from({length:28},(e,t)=>{let n=t+1;return{value:String(n),label:Re(n)}}),{value:`last`,label:`Last day`}],Ge=[{value:`AM`,label:`AM`},{value:`PM`,label:`PM`}];function Ke(e,t){let n=e%12;return t===`PM`?n+12:n}function qe(e){try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value;return t&&t!==e?`${e} · ${t}`:e}catch{return e}}function Je({isOpen:e,assistantId:t,onClose:n,onCreated:r}){return(0,K.jsx)(E.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,K.jsx)(Ye,{assistantId:t,onClose:n,onCreated:r}):null})}function Ye({assistantId:e,onClose:t,onCreated:n}){let r=H(),[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(`simple`),[p,m]=(0,U.useState)(Ne),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(null),x=a.trim(),S=s.trim(),T=l.trim(),D=h.trim(),O=(0,U.useMemo)(()=>d===`simple`?Ie(p):D,[d,p,D]),k=(0,U.useMemo)(()=>d===`simple`?Be(p):D||`Enter a cron expression to continue.`,[d,p,D]),A=(0,U.useMemo)(()=>qe(r),[r]),j=x.length>0&&S.length>0&&T.length>0&&O.length>0&&!_;return(0,K.jsxs)(E.Content,{size:`md`,children:[(0,K.jsxs)(E.Header,{children:[(0,K.jsx)(E.Title,{children:`Create schedule`}),(0,K.jsx)(E.Description,{children:`Schedule a recurring instruction for your assistant. Runs in execute mode — the message is delivered to the assistant on each fire.`})]}),(0,K.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),j){v(!0),b(null);try{await we(e,{name:x,description:S,expression:O,message:T,timezone:r}),v(!1),n()}catch(e){b(e instanceof Error?e.message:`Failed to create schedule.`),v(!1)}}},children:[(0,K.jsx)(E.Body,{children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsx)(w,{label:`Name`,placeholder:`Morning briefing`,value:a,onChange:e=>o(e.target.value),required:!0,autoFocus:!0,fullWidth:!0}),(0,K.jsx)(C,{label:`Description`,placeholder:`What is this schedule for?`,value:s,onChange:e=>c(e.target.value),required:!0,fullWidth:!0,rows:2}),(0,K.jsx)(et,{label:`Repeat`,children:d===`simple`?(0,K.jsx)(Xe,{cadence:p,onChange:m}):(0,K.jsx)($e,{value:h,onChange:g,onUseSimple:()=>f(`simple`)})}),(0,K.jsx)(tt,{summary:k,mono:d===`advanced`&&D.length>0,timezoneLabel:A}),d===`simple`?(0,K.jsx)(`button`,{type:`button`,onClick:()=>{g(e=>e||Ie(p)),f(`advanced`)},className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`Advanced — write a cron expression`}):null,(0,K.jsx)(C,{label:`Message`,placeholder:`What should the assistant do on each fire?`,value:l,onChange:e=>u(e.target.value),required:!0,fullWidth:!0,rows:4}),y?(0,K.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:y}):null]})}),(0,K.jsxs)(E.Footer,{children:[(0,K.jsx)(i,{variant:`outlined`,onClick:t,type:`button`,children:`Cancel`}),(0,K.jsx)(i,{variant:`primary`,type:`submit`,disabled:!j,children:_?`Creating…`:`Create schedule`})]})]})]})}function Xe({cadence:e,onChange:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(x,{items:Ve,value:e.frequency,onChange:n=>t({...e,frequency:n}),ariaLabel:`How often the schedule runs`}),e.frequency===`hourly`?(0,K.jsx)(q,{label:`At minute`,children:(0,K.jsx)(k,{options:Ue,value:String(e.minute).padStart(2,`0`),onChange:n=>t({...e,minute:Number(n)}),"aria-label":`Minute`,className:`w-24`})}):null,e.frequency===`weekly`?(0,K.jsx)(q,{label:`On these days`,children:(0,K.jsx)(Qe,{value:e.weekdays,onChange:n=>t({...e,weekdays:n})})}):null,e.frequency===`monthly`?(0,K.jsx)(q,{label:`On day`,children:(0,K.jsx)(k,{options:We,value:e.dayOfMonth===`last`?`last`:String(e.dayOfMonth),onChange:n=>t({...e,dayOfMonth:n===`last`?`last`:Number(n)}),"aria-label":`Day of month`,className:`w-32`})}):null,e.frequency===`hourly`?null:(0,K.jsx)(q,{label:`At time`,children:(0,K.jsx)(Ze,{hour24:e.hour24,minute:e.minute,onChange:(n,r)=>t({...e,hour24:n,minute:r})})})]})}function Ze({hour24:e,minute:t,onChange:n}){let r=e<12?`AM`:`PM`,i=e%12==0?12:e%12;return(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(k,{options:He,value:String(i),onChange:e=>n(Ke(Number(e),r),t),"aria-label":`Hour`,className:`w-[72px]`}),(0,K.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`:`}),(0,K.jsx)(k,{options:Ue,value:String(t).padStart(2,`0`),onChange:t=>n(e,Number(t)),"aria-label":`Minute`,className:`w-[72px]`}),(0,K.jsx)(`div`,{className:`w-[112px]`,children:(0,K.jsx)(x,{items:Ge,value:r,onChange:e=>n(Ke(i,e),t),ariaLabel:`AM or PM`})})]})}function Qe({value:e,onChange:t}){let n=new Set(e),i=e=>{let r=new Set(n);r.has(e)?r.size>1&&r.delete(e):r.add(e),t([...r].sort((e,t)=>e-t))};return(0,K.jsx)(`div`,{className:`flex gap-1.5`,children:W.map(e=>{let t=n.has(e.value);return(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),"aria-pressed":t,"aria-label":e.full,title:e.full,className:r(`flex h-9 w-9 items-center justify-center rounded-md border text-body-medium-default transition-colors`,t?`border-[var(--border-active)] bg-[var(--surface-active)] text-[var(--content-emphasised)]`:`border-[var(--field-border)] text-[var(--content-tertiary)] hover:border-[var(--border-active)] hover:text-[var(--content-default)]`),children:e.letter},e.value)})})}function $e({value:e,onChange:t,onUseSimple:n}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(w,{placeholder:`0 9 * * *`,value:e,onChange:e=>t(e.target.value),fullWidth:!0,className:`font-mono`,"aria-label":`Cron expression`,helperText:`Standard 5-field cron (minute hour day month weekday). RRULE expressions are also accepted.`}),(0,K.jsx)(`button`,{type:`button`,onClick:n,className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`← Back to the simple builder`})]})}function et({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:e}),t]})}function q({label:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,K.jsx)(`span`,{className:`min-w-[88px] text-body-small-default text-[var(--content-tertiary)]`,children:e}),t]})}function tt({summary:e,mono:t,timezoneLabel:n}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-lift)] px-3.5 py-3`,children:[(0,K.jsx)(h,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:r(`text-body-medium-default text-[var(--content-default)]`,t&&`break-all font-mono`),children:e}),(0,K.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[`Times use your timezone — `,n,`.`]})]})]})}function nt(e=B(),t=Date.now()){return Ae(`7d`,e,t)}function J(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0}):`—`}function rt(e){return e==null?`—`:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}var it=new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2});function Y(e){return e==null||!Number.isFinite(e)?`—`:it.format(e)}function at(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}function ot(e){let t=Math.round(e/6e4);return t>=60&&t%60==0?`Every ${t/60} hr`:`Every ${t} min`}function st(e){if(!e)return;let t=new Set,n=[];for(let r of e)for(let e of r.runs)t.has(e.id)||(t.add(e.id),n.push(e));return n}function ct(e){return!!e.conversationId&&e.conversationExists===!0&&e.conversationArchivedAt==null}function lt(e){return ct(e)?e.conversationId??null:null}function X(e){return typeof e==`string`&&e.length>0}var ut={heartbeat:`system-heartbeat`,consolidation:`system-consolidation`,retrospective:`system-memory-retrospective`};function dt(e){if(e.cronExpression)return e.timezone?`Cron: ${e.cronExpression} (${e.timezone})`:`Cron: ${e.cronExpression}`;let t=ot(e.intervalMs);return e.activeHoursStart!=null&&e.activeHoursEnd!=null&&(t+=` (${e.activeHoursStart}:00–${e.activeHoursEnd}:00)`),t}function ft(e){return ot(e.intervalMs)}var pt=`After conversation activity`;function mt(e,t){return e.status===`fired`||e.status===`cancelled`?!0:e.status===`firing`?!1:e.nextRunAt==null||!e.enabled&&e.nextRunAt<=t}function ht(e,t){let n=[],r=[],i=[];for(let a of e)a.isOneShot?mt(a,t)?i.push(a):r.push(a):n.push(a);return n.sort((e,t)=>e.enabled===t.enabled?(e.nextRunAt??1/0)-(t.nextRunAt??1/0):e.enabled?-1:1),r.sort((e,t)=>(e.nextRunAt??1/0)-(t.nextRunAt??1/0)),i.sort((e,t)=>{let n=e.lastRunAt??e.nextRunAt??0;return(t.lastRunAt??t.nextRunAt??0)-n}),{recurring:n,upcomingOneTime:r,pastOneTime:i}}function gt(e,t,n=!0){return{queryKey:[{_id:`schedulesUsagesummaryGet`,path:{assistant_id:e??``},_tz:t}],queryFn:()=>e?be(e,nt(t)):Promise.resolve([]),enabled:n,staleTime:1e4}}function _t(e){return{scheduleId:e,runCount:0,totalEstimatedCostUsd:0,eventCount:0}}function vt(e,t,n){let r=(t??[]).filter(e=>{let t=e.startedAt??e.createdAt;return t>=n.from&&t<=n.to});return{scheduleId:e,runCount:r.length,totalEstimatedCostUsd:r.reduce((e,t)=>{let n=t.estimatedCostUsd;return typeof n==`number`&&Number.isFinite(n)?e+n:e},0),eventCount:0}}function yt({status:e}){return(0,K.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:e===`ok`||e===`completed`?`var(--system-positive-strong)`:e===`error`||e===`failed`?`var(--system-negative-strong)`:`var(--content-tertiary)`},"aria-label":e??`unknown`})}function bt({scheduleName:e,usage:t,onOpenUsage:n}){if(t.status===`loading`)return(0,K.jsxs)(`div`,{"aria-label":`Loading schedule usage`,className:`flex w-[156px] shrink-0 items-center justify-end gap-3`,children:[(0,K.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,K.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`})]});let r=t.status===`error`,i=r?`--`:Y(t.summary.totalEstimatedCostUsd),a=r?`--`:at(t.summary.runCount),o=t.status===`ready`&&!(t.summary.totalEstimatedCostUsd>0),s=t.status===`ready`&&t.summary.runCount===0,c=o?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`,l=s?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`;return(0,K.jsxs)(`div`,{className:`flex w-[156px] shrink-0 items-center justify-end gap-3 text-right text-body-small-default`,children:[n?(0,K.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`View usage for ${e}`,className:`min-w-[64px] cursor-pointer rounded px-1 py-0.5 text-right transition-colors hover:bg-[var(--surface-hover)] ${c}`,children:i}):(0,K.jsx)(`span`,{"aria-label":`Cost for ${e} in the last 7 days: ${i}`,className:`block min-w-[64px] px-1 py-0.5 ${c}`,children:i}),(0,K.jsx)(`span`,{"aria-label":`Runs for ${e} in the last 7 days: ${a}`,className:`block min-w-[64px] px-1 py-0.5 ${l}`,children:a})]})}function xt({name:e,subtitle:t,enabled:n,nextRunAt:r,lastRunAt:i,usage:a,helperText:o,statusLabel:s,statusTone:c=`neutral`,onClick:l}){return(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md px-2 py-3 transition-colors hover:bg-[var(--surface-hover)] [&+&]:border-t [&+&]:border-[var(--border-base)]`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:l,"aria-label":`Open ${e}`,className:`flex min-w-0 flex-1 cursor-pointer flex-wrap items-center gap-3 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e})}),(0,K.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:t}),o?(0,K.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-secondary)]`,children:o}):null,(0,K.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-body-small-default text-[var(--content-tertiary)]`,children:[r?(0,K.jsxs)(`span`,{children:[`Next: `,J(r)]}):null,i?(0,K.jsxs)(`span`,{children:[`Last: `,J(i)]}):null]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-3`,children:[(0,K.jsx)(bt,{scheduleName:e,usage:a}),s?(0,K.jsx)(S,{tone:c,children:s}):(0,K.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:n?`var(--system-positive-strong)`:`var(--content-disabled)`},"aria-label":n?`enabled`:`disabled`}),(0,K.jsx)(m,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})})}function St({heartbeatConfig:e,consolidationConfig:t,retrospectiveConfig:n,heartbeatUsage:r,consolidationUsage:i,retrospectiveUsage:a,isLoading:o,hasError:s,onRetry:c,onSelectHeartbeat:l,onSelectConsolidation:u,onSelectRetrospective:d}){let f=e!=null,m=t?.available===!0,h=n?.available===!0,_=f||m||h;if(!o&&!s&&!_)return null;let v=[...f?[r]:[],...m?[i]:[],...h?[a]:[]].filter(e=>e.status===`ready`),x=v.reduce((e,t)=>e+(t.summary.totalEstimatedCostUsd??0),0),S=o?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(g,{className:`h-5 w-5 animate-spin text-stone-400`})}):s&&!_?(0,K.jsxs)(y,{tone:`error`,children:[`Failed to load system jobs.`,` `,(0,K.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}):(0,K.jsxs)(`div`,{children:[f?(0,K.jsx)(xt,{name:`Heartbeat`,subtitle:dt(e),enabled:e.enabled,nextRunAt:e.nextRunAt,lastRunAt:e.lastRunAt,usage:r,onClick:l}):null,m?(0,K.jsx)(xt,{name:`Consolidation`,subtitle:ft(t),enabled:t.enabled,helperText:t.enabled?void 0:`Memory is off, so consolidation is paused.`,nextRunAt:t.nextRunAt,lastRunAt:t.lastRunAt,usage:i,statusLabel:t.enabled?void 0:`Paused`,statusTone:`warning`,onClick:u}):null,h?(0,K.jsx)(xt,{name:`Memory retrospective`,subtitle:pt,enabled:n.enabled,helperText:n.enabled?void 0:`Memory is off, so retrospectives are paused.`,nextRunAt:n.nextRunAt,lastRunAt:n.lastRunAt,usage:a,statusLabel:n.enabled?void 0:`Paused`,statusTone:`warning`,onClick:d}):null,s?(0,K.jsx)(`div`,{className:`pt-3 first:pt-0`,children:(0,K.jsxs)(y,{tone:`error`,children:[`Some system jobs failed to load.`,` `,(0,K.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]})}):null]});return(0,K.jsx)(ye,{children:(0,K.jsx)(b.Root,{type:`multiple`,children:(0,K.jsxs)(b.Item,{value:`system-jobs`,children:[(0,K.jsxs)(b.Trigger,{className:`group justify-between gap-3`,children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1 text-left`,children:[(0,K.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`System`}),(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Built-in jobs managed by the assistant runtime`})]}),(0,K.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[v.length>0?(0,K.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[Y(x),` (7d)`]}):null,(0,K.jsx)(p,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]})]}),(0,K.jsx)(b.Content,{children:(0,K.jsx)(`div`,{className:`mt-3`,children:S})})]})})})}function Z(e,t){return{id:e.id,jobId:t,status:e.status,startedAt:e.startedAt??e.scheduledFor,finishedAt:e.finishedAt,durationMs:e.durationMs,output:`skipReason`in e&&e.skipReason?`Skipped: ${e.skipReason}`:null,error:e.error,conversationId:e.conversationId,conversationExists:e.conversationExists,conversationArchivedAt:e.conversationArchivedAt,estimatedCostUsd:e.estimatedCostUsd,createdAt:e.createdAt,...`title`in e?{title:e.title}:{}}}function Ct(e){return e.runs.map(e=>Z(e,`heartbeat`))}function wt(e){return e.runs.map(e=>Z(e,`consolidation`))}function Tt(e){return e.runs.map(e=>Z(e,`retrospective`))}var Q=1e4;function Et(e,t,n,r,i){return e?{status:`loading`}:t?{status:`error`}:{status:`ready`,summary:vt(n,r,i)}}function Dt(e,n){let r=s(),i={path:{assistant_id:e??``}},{data:a,isLoading:o,isError:l,refetch:u}=c({...ie(i),enabled:!!e,staleTime:Q}),{data:d,isLoading:f,isError:p,refetch:m}=c({...R(i),enabled:!!e,staleTime:Q}),{data:h,isLoading:g,isError:_,refetch:v}=c({...se(i),enabled:!!e,staleTime:Q}),y={path:{assistant_id:e??``},query:{limit:100}},{data:b,isLoading:x,isError:S,refetch:C}=c({...j(y),select:Ct,enabled:!!e&&a!=null,staleTime:Q}),{data:w,isLoading:T,isError:E,refetch:D}=c({...le(y),select:wt,enabled:!!e&&d?.available===!0,staleTime:Q}),{data:k,isLoading:P,isError:F,refetch:I}=c({...oe(y),select:Tt,enabled:!!e&&h?.available===!0,staleTime:Q}),L=(0,U.useMemo)(()=>nt(n),[n]),ne=(0,U.useMemo)(()=>Et(x,S,ut.heartbeat,b,L),[b,S,x,L]),ae=(0,U.useMemo)(()=>Et(T,E,ut.consolidation,w,L),[w,E,T,L]),ue=(0,U.useMemo)(()=>Et(P,F,ut.retrospective,k,L),[k,F,P,L]),z=t=>{if(!e)return;let n={heartbeat:{config:ie(i).queryKey,runs:j(y).queryKey,infinite:ee(i)},consolidation:{config:R(i).queryKey,runs:le(y).queryKey,infinite:ce(i)},retrospective:{config:se(i).queryKey,runs:oe(y).queryKey,infinite:re(i)}}[t];r.invalidateQueries({queryKey:n.config}),r.invalidateQueries({queryKey:n.runs}),r.invalidateQueries({queryKey:n.infinite})},B=te({onSuccess:e=>{e.ran?O.success(`Heartbeat started.`):O.info(`Heartbeat skipped.`)},onError:e=>{t(e,{context:`heartbeat_run_now`}),O.error(`Failed to run heartbeat.`)},onSettled:()=>z(`heartbeat`)}),V=A({onSuccess:e=>{e.ran?O.success(`Consolidation queued.`):O.info(`Consolidation already queued or running.`)},onError:e=>{t(e,{context:`consolidation_run_now`}),O.error(`Failed to run consolidation.`)},onSettled:()=>z(`consolidation`)}),H=M({onSuccess:e=>{N(r,i,e),O.success(e.enabled?`Heartbeat enabled.`:`Heartbeat disabled.`)},onError:e=>{t(e,{context:`heartbeat_toggle`}),O.error(`Failed to toggle heartbeat.`)}});return{heartbeatConfig:a,consolidationConfig:d,retrospectiveConfig:h,heartbeatUsage:ne,consolidationUsage:ae,retrospectiveUsage:ue,isLoading:o||f||g,hasError:l||p||_,isHeartbeatRunning:B.isPending,isConsolidationRunning:V.isPending,isHeartbeatLoading:o,isHeartbeatError:l,isConsolidationLoading:f,isConsolidationError:p,isRetrospectiveLoading:g,isRetrospectiveError:_,refetchHeartbeat:u,refetchConsolidation:m,refetchRetrospective:v,runHeartbeatNow:()=>{e&&B.mutate({path:{assistant_id:e}})},runConsolidationNow:()=>{e&&V.mutate({path:{assistant_id:e}})},toggleHeartbeat:t=>{e&&H.mutate({body:{enabled:t},path:{assistant_id:e}})},refetchAll:()=>{u(),m(),v(),C(),D(),I()}}}function Ot({children:e}){return(0,K.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function $({label:e,value:t}){return(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-1`,children:[(0,K.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e}),(0,K.jsx)(`span`,{className:`min-w-0 text-right text-body-medium-lighter text-[var(--content-default)]`,children:t})]})}function kt({icon:e,value:t,label:n}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] p-3`,children:[(0,K.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--surface-sunken)] text-[var(--content-secondary)]`,children:e}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-body-large-default text-[var(--content-default)]`,children:t}),(0,K.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:n})]})]})}function At({usage:e}){return e.status===`loading`?(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:Array.from({length:2},(e,t)=>(0,K.jsx)(`div`,{className:`h-[60px] animate-pulse rounded-lg bg-[var(--surface-muted)]`},t))}):e.status===`error`?null:(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:[(0,K.jsx)(kt,{icon:(0,K.jsx)(fe,{className:`h-4 w-4`}),value:Y(e.summary.totalEstimatedCostUsd),label:`7 Day Cost`}),(0,K.jsx)(kt,{icon:(0,K.jsx)(_,{className:`h-4 w-4`}),value:at(e.summary.runCount),label:`7 Day Runs`})]})}function jt(e){return e.exists&&e.archivedAt==null}function Mt({run:e,index:t,isExpanded:n,disableDirectOpen:i,onOpenConversation:a,onToggleDetails:o}){let s=lt(e),c=e.conversations??(s?[{id:s,title:null,exists:!0,archivedAt:null}]:[]),l=X(e.output),u=X(e.error),d=!i&&c.length===1&&jt(c[0])?c[0].id:null,f=!d&&(c.length>0||l||u),p=`schedule-run-details-${t}`,h=!!d||f,g=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(yt,{status:e.status}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:J(e.startedAt)}),(0,K.jsxs)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[rt(e.durationMs),` ·`,` `,Y(e.estimatedCostUsd)]}),e.status===`error`&&e.error?(0,K.jsxs)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--system-negative-strong)]`,children:[e.error.slice(0,120),e.error.length>120?`…`:``]}):null]}),h?(0,K.jsx)(m,{className:r(`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform`,f&&n?`rotate-90`:``)}):null]}),_=f&&n?(0,K.jsx)(`div`,{id:p,className:`px-2 pb-3`,children:(0,K.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[c.length>0?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Conversations`}),(0,K.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>jt(e)?(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(e.id),className:`block w-full truncate text-left text-body-small-default text-[var(--content-default)] hover:underline`,children:X(e.title)?e.title:`Conversation`},e.id):(0,K.jsxs)(`span`,{className:`block truncate text-body-small-default text-[var(--content-tertiary)] italic`,children:[X(e.title)?e.title:`Conversation`,` `,e.exists?`(archived)`:`(unavailable)`]},e.id))})]}):null,l?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,u?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null;return d?(0,K.jsx)(`div`,{children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(d),"aria-label":`Open conversation for run at ${J(e.startedAt)}`,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g})}):f?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),"aria-label":`Toggle details for run at ${J(e.startedAt)}`,"aria-expanded":n,"aria-controls":p,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g}),_]}):(0,K.jsx)(`div`,{className:`flex items-center gap-3 px-2 py-3`,children:g})}function Nt({runs:e,isLoading:t,disableDirectOpen:n,onOpenConversation:r}){let[i,a]=(0,U.useState)(null);return t?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,K.jsx)(g,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,K.jsx)(`p`,{className:`py-2 text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:`No runs yet.`}):(0,K.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.map((e,t)=>(0,K.jsx)(Mt,{run:e,index:t,isExpanded:i===e.id,disableDirectOpen:n,onOpenConversation:r,onToggleDetails:e=>a(t=>t===e?null:e)},e.id))})}function Pt({schedule:e,assistantId:n,usage:a,isMobile:s,onClose:l,onDeleted:d}){let f=o(),{data:p,isLoading:m}=c({queryKey:ae({path:{assistant_id:n,id:e.id}}),queryFn:()=>Se(n,e.id),staleTime:1e4}),[h,_]=(0,U.useState)(!1),[y,b]=(0,U.useState)(!1),[x,S]=(0,U.useState)(!1),C=async()=>{_(!0);try{await Te(n,e.id)}catch(e){t(e,{context:`schedule_run_now`}),O.error(`Failed to run schedule.`)}finally{_(!1)}},w=async()=>{S(!0);try{await Ee(n,e.id),d()}catch(e){t(e,{context:`schedule_delete`}),O.error(`Failed to delete schedule.`),S(!1),b(!1)}};return(0,K.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:e.name})}),(0,K.jsx)(i,{variant:`ghost`,iconOnly:(0,K.jsx)(v,{}),onClick:l,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,K.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[e.description?(0,K.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e.description}):null,(0,K.jsxs)(`section`,{children:[(0,K.jsx)(Ot,{children:`Details`}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-2`,children:[e.cadenceDescription?(0,K.jsx)($,{label:`Cadence`,value:e.cadenceDescription}):null,(0,K.jsx)($,{label:`Mode`,value:e.mode}),(0,K.jsx)($,{label:`Status`,value:e.enabled?`Enabled`:`Disabled`}),(0,K.jsx)($,{label:`Next run`,value:J(e.nextRunAt)}),e.lastRunAt?(0,K.jsx)($,{label:`Last run`,value:(0,K.jsxs)(`span`,{className:`flex items-center justify-end gap-2`,children:[(0,K.jsx)(yt,{status:e.lastStatus}),J(e.lastRunAt)]})}):null]})]}),(0,K.jsx)(At,{usage:a}),(0,K.jsxs)(`section`,{children:[(0,K.jsx)(Ot,{children:`Recent runs`}),(0,K.jsx)(Nt,{runs:p?.runs,isLoading:m,disableDirectOpen:e.mode===`script`,onOpenConversation:e=>f(z.conversation(e))})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[y?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(i,{variant:`ghost`,onClick:()=>b(!1),disabled:x,children:`Cancel`}),(0,K.jsx)(i,{variant:`danger`,onClick:()=>void w(),disabled:x,children:x?`Deleting…`:`Yes, delete`})]}):(0,K.jsx)(i,{variant:`dangerOutline`,leftIcon:(0,K.jsx)(me,{className:`h-3.5 w-3.5`}),onClick:()=>b(!0),children:`Delete`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(i,{variant:`outlined`,leftIcon:(0,K.jsx)(Me,{className:`h-3.5 w-3.5`}),onClick:()=>f(z.settings.usageForSchedule(e.id)),children:`View usage`}),e.mode===`script`?(0,K.jsx)(i,{variant:`primary`,leftIcon:h?(0,K.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):void 0,onClick:()=>void C(),disabled:h,children:h?`Running…`:`Run now`}):null]})]})]})}function Ft(e){if(e.status===`loading`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`h-4 w-12 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,K.jsx)(`span`,{className:`h-4 w-10 animate-pulse rounded bg-[var(--surface-muted)]`})]});if(e.status===`error`)return(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`—`});let{summary:t}=e;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:Y(t.totalEstimatedCostUsd)}),(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:at(t.runCount)})]})}function It({name:e,metaParts:t,usage:n,enabled:r,selected:i,onClick:a,onToggle:o,toggleAriaLabel:s}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md px-2 py-3 transition-colors [&+&]:border-t [&+&]:border-[var(--border-base)] ${i?`bg-[var(--surface-active)]`:`hover:bg-[var(--surface-hover)]`}`,children:[o?(0,K.jsx)(T,{checked:r,onChange:o,"aria-label":s}):null,(0,K.jsxs)(`button`,{type:`button`,onClick:a,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-4 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e}),t.length>0?(0,K.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 text-label-small-default text-[var(--content-tertiary)]`,children:t.map((e,t)=>(0,K.jsxs)(U.Fragment,{children:[t>0?(0,K.jsx)(`span`,{className:`h-[3px] w-[3px] shrink-0 rounded-full bg-[var(--content-tertiary)]`}):null,(0,K.jsx)(`span`,{className:`truncate`,children:e})]},t))}):null]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4`,children:[Ft(n),(0,K.jsx)(m,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})]})}function Lt({schedule:e,usage:t,selected:n,onClick:r,onToggle:i}){let a=e.isOneShot?``:e.cadenceDescription.trim(),o=e.lastRunAt??e.nextRunAt,s=[a,o?J(o):``].filter(Boolean);return(0,K.jsx)(It,{name:e.name,metaParts:s,usage:t,enabled:e.enabled,selected:n,onClick:r,onToggle:i,toggleAriaLabel:i?`Toggle ${e.name}`:void 0})}function Rt({recurring:e,oneTime:t,pastOneTime:n,usageForSchedule:r,isLoading:a,isError:o,refetch:s,onToggle:c,onSelectSchedule:l,selectedScheduleId:u,onStartNewChat:d,onCreateSchedule:p,pastOpen:h,onPastOpenChange:g,systemTasksSlot:_}){let v=e=>(0,K.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id),onToggle:t=>c(e.id,t)},e.id),x=e=>(0,K.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id)},e.id),S=n.length>0?(0,K.jsx)(b.Root,{type:`single`,collapsible:!0,className:`mt-3`,value:h?`past`:``,onValueChange:e=>g(e===`past`),children:(0,K.jsxs)(b.Item,{value:`past`,children:[(0,K.jsxs)(b.Trigger,{className:`group gap-[var(--app-spacing-xs)] px-2 text-label-small-default text-[var(--content-tertiary)]`,children:[(0,K.jsx)(m,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,K.jsxs)(`span`,{children:[`Past (`,n.length,`)`]})]}),(0,K.jsx)(b.Content,{children:(0,K.jsx)(`div`,{className:`pt-1`,children:n.map(x)})})]})}):null;return(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[a?(0,K.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2},(e,t)=>(0,K.jsx)(`div`,{className:`h-12 animate-pulse rounded-md bg-[var(--surface-muted)]`},t))}):o&&e.length===0?(0,K.jsx)(y,{tone:`error`,actions:(0,K.jsx)(`button`,{type:`button`,onClick:s,className:`cursor-pointer underline hover:no-underline`,children:`Retry`}),children:`Failed to load schedules.`}):e.length===0&&t.length===0&&n.length===0?(0,K.jsx)(Oe,{icon:f,title:`No schedules yet`,description:`Ask your assistant to set one up, or create one yourself.`,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(i,{variant:`primary`,size:`regular`,onClick:d,children:`New Conversation`}),(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`or`}),(0,K.jsx)(i,{variant:`outlined`,size:`regular`,onClick:p,children:`Create schedule`})]})}):(0,K.jsxs)(`div`,{children:[e.map(v),t.length>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mt-3 px-2 text-label-small-default text-[var(--content-tertiary)]`,children:`One-time`}),t.map(x)]}):null,S]}),_?(0,K.jsx)(`div`,{className:`mt-[var(--app-spacing-lg)]`,children:_}):null]})}var zt=`Default (assistant's main model)`,Bt=`Custom call-site model`;function Vt(e,t){return t?.[e]?.displayName??e}function Ht(e,t){if(e==null)return;if(e.provider!=null||e.model!=null)return Bt;let n=e.profile?.trim();return n?`Override (${Vt(n,t)})`:void 0}function Ut({assistantId:e,pinnedProfile:t,defaultCallSite:n=`mainAgent`,fallbackLabel:r=zt,respectCallSiteOverride:i=!1}){let a=t==null,{data:o}=c({...I({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4}),s=(0,U.useMemo)(()=>o?je(o):{},[o]),{data:l}=c({...L({path:{assistant_id:e}}),enabled:!!e&&a,staleTime:6e4}),u=a&&i?Ht(o?.llm?.callSites?.[n],s):void 0,d=a?l?.callSites.find(e=>e.id===n)?.defaultProfile:void 0,f=t==null?u??(d==null?r:`Default (${Vt(d,s)})`):Vt(t,s);return(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Model profile`}),(0,K.jsx)(`span`,{className:`min-w-0 text-right`,children:f})]})}function Wt({runs:e,isLoading:t,emptyMessage:n=`No runs yet.`,hasMore:r=!1,isLoadingMore:a=!1,onLoadMore:s}){let c=o(),[l,u]=(0,U.useState)(null);return(0,K.jsx)(ye,{title:`Recent runs`,children:t?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(g,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,K.jsx)(`p`,{className:`py-4 text-center text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:n}):(0,K.jsxs)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:[e.map((e,t)=>{let n=lt(e),r=X(e.output),i=X(e.error),a=!n&&(r||i),o=l===e.id,s=`schedule-run-details-${t}`;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(D,{label:(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,K.jsx)(yt,{status:e.status}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate text-body-medium-lighter text-[var(--content-default)]`,children:X(e.title)?e.title:J(e.startedAt)}),(0,K.jsxs)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[X(e.title)?`${J(e.startedAt)} · `:``,rt(e.durationMs),` ·`,` `,Y(e.estimatedCostUsd),e.status===`error`&&e.error&&(0,K.jsxs)(`span`,{className:`ml-2 text-[var(--system-negative-strong)]`,children:[e.error.slice(0,80),e.error.length>80?`…`:``]})]})]}),n||a?(0,K.jsx)(m,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform ${o?`rotate-90`:``}`}):null]}),onSelect:n?()=>c(z.conversation(n)):a?()=>u(o?null:e.id):void 0,"aria-label":`Run at ${J(e.startedAt)}`,"aria-expanded":a?o:void 0,"aria-controls":a?s:void 0,className:`h-auto py-2.5 gap-3 -mx-2 px-2`}),a&&o?(0,K.jsx)(`div`,{id:s,className:`px-2 pb-3`,children:(0,K.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[r?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,i?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null]},e.id)}),r&&s?(0,K.jsx)(`div`,{className:`flex justify-center pt-3`,children:(0,K.jsx)(i,{variant:`outlined`,size:`compact`,onClick:s,disabled:a,leftIcon:a?(0,K.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):void 0,children:a?`Loading…`:`Load more`})}):null]})})}var Gt={heartbeat:`heartbeatAgent`,consolidation:`memoryV2Consolidation`,retrospective:`memoryRetrospective`};function Kt({children:e}){return(0,K.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function qt({kind:e,assistantId:t,systemTasks:n,canOpenMemorySettings:a,isMobile:s,onClose:c}){let l=o(),{heartbeatConfig:d,consolidationConfig:f,retrospectiveConfig:p}=n,m,h,_,b,x,S,C;e===`heartbeat`?(m=`Heartbeat`,h=d?dt(d):``,_=d?.enabled??!1,b=d?.nextRunAt??null,x=d?.lastRunAt??null,S=n.isHeartbeatRunning,C=n.runHeartbeatNow):e===`consolidation`?(m=`Consolidation`,h=f?ft(f):``,_=f?.enabled??!1,b=f?.nextRunAt??null,x=f?.lastRunAt??null,S=n.isConsolidationRunning,C=n.runConsolidationNow):(m=`Memory retrospective`,h=pt,_=p?.enabled??!1,b=p?.nextRunAt??null,x=p?.lastRunAt??null,S=!1,C=void 0);let w=e!==`heartbeat`,E=e===`retrospective`,D=w&&!_,O=S||D,k=w?_?`On · Managed by Memory`:`Paused`:_?`Enabled`:`Disabled`,A=E?`Memory is off, so retrospectives are paused. Turn Memory back on to resume them.`:`Memory is off, so consolidation is paused. Turn Memory back on to resume consolidation.`,j=w&&_&&a,M={path:{assistant_id:t},query:{limit:25}},N=e===`heartbeat`?P(M):e===`consolidation`?F(M):ne(M),{data:ee,isLoading:te,fetchNextPage:I,hasNextPage:L,isFetchingNextPage:re}=he({queryKey:N.queryKey,queryFn:N.queryFn,initialPageParam:{path:M.path,query:{}},getNextPageParam:e=>e.nextCursor??void 0,staleTime:1e4}),R=st(ee?.pages.map(t=>({runs:t.runs.map(t=>Z(t,e))})));return(0,K.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:m}),h?(0,K.jsx)(u,{variant:`body-small-default`,as:`p`,className:`truncate text-[var(--content-tertiary)]`,children:h}):null]}),(0,K.jsx)(i,{variant:`ghost`,iconOnly:(0,K.jsx)(v,{}),onClick:c,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,K.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[(0,K.jsxs)(`section`,{children:[(0,K.jsx)(Kt,{children:`Details`}),(0,K.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-3 text-body-medium-lighter`,children:[(0,K.jsx)(Ut,{assistantId:t,defaultCallSite:Gt[e],fallbackLabel:`Default (system task model)`,respectCallSiteOverride:!0}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Status`}),(0,K.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--content-default)]`,children:[(0,K.jsx)(`span`,{children:k}),w?null:(0,K.jsx)(T,{checked:_,onChange:n.toggleHeartbeat,"aria-label":`Toggle ${m}`})]})]}),E?null:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Next run`}),(0,K.jsx)(`span`,{className:`text-[var(--content-default)]`,children:J(b)})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Last run`}),(0,K.jsx)(`span`,{className:`text-[var(--content-default)]`,children:J(x)})]})]}),D?(0,K.jsx)(y,{tone:`warning`,className:`mt-4`,actions:a?(0,K.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Turn on Memory`}):void 0,children:A}):null]}),(0,K.jsx)(Wt,{runs:R,isLoading:te,hasMore:L,isLoadingMore:re,onLoadMore:()=>void I()})]}),j||C?(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[j?(0,K.jsx)(i,{variant:`outlined`,leftIcon:(0,K.jsx)(pe,{className:`h-3.5 w-3.5`}),onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Memory settings`}):null,C?(0,K.jsx)(i,{variant:`primary`,leftIcon:S?(0,K.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(ge,{className:`h-3.5 w-3.5`}),onClick:C,disabled:O,children:S?`Running…`:`Run now`}):null]}):null]})}function Jt(e){let n=H(),[r]=(0,U.useState)(()=>Date.now()),{data:i,isLoading:a,isError:o,refetch:s}=c(De(e)),{data:l,isLoading:u,isError:d}=c(gt(e,n,!0)),{recurring:f,oneTime:p,pastOneTime:m}=(0,U.useMemo)(()=>{let e=ht(i??[],r);return{recurring:e.recurring,oneTime:e.upcomingOneTime,pastOneTime:e.pastOneTime}},[r,i]),h=(0,U.useMemo)(()=>new Map((l??[]).map(e=>[e.scheduleId,e])),[l]);return{recurring:f,oneTime:p,pastOneTime:m,usageForSchedule:(0,U.useCallback)(e=>u?{status:`loading`}:d?{status:`error`}:{status:`ready`,summary:h.get(e)??_t(e)},[d,u,h]),handleToggle:(0,U.useCallback)(async(n,r)=>{if(e)try{await xe(e,n,r),s()}catch(e){t(e,{context:`schedule_toggle`}),O.error(`Failed to toggle schedule.`)}},[e,s]),isLoading:a,isError:o,refetch:(0,U.useCallback)(()=>{s()},[s])}}function Yt(){let e=o(),{scheduleId:t}=a(),n=ve(),r=_e(),i=H(),s=Jt(n),l=Dt(n,i),{data:u=!1}=c({queryKey:[`assistant-memory-opt-out-capability`,n],queryFn:async()=>{let e=await ue(n);return e.ok&&e.data.capabilities?.memoryOptOut===!0},retry:!1,staleTime:1e4}),d=V.use.settingsDeveloperNav(),f=u&&d===!0,[p,m]=(0,U.useState)(!1),h=t??null,[g,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(!1),b=(0,U.useCallback)(t=>{e(t?z.schedules.detail(t):z.schedules.root)},[e]),x=h?s.recurring.find(e=>e.id===h)??s.oneTime.find(e=>e.id===h)??s.pastOneTime.find(e=>e.id===h)??null:null;(0,U.useEffect)(()=>{h&&!s.isLoading&&!s.isError&&!x&&b(null)},[h,x,s.isLoading,s.isError,b]);let S=g===`heartbeat`?l.heartbeatConfig!=null:g===`consolidation`?l.consolidationConfig?.available===!0:g===`retrospective`?l.retrospectiveConfig?.available===!0:!1;(0,U.useEffect)(()=>{g&&!l.isLoading&&!S&&_(null)},[g,S,l.isLoading]);let C=(0,U.useCallback)(e=>{_(null),b(e)},[b]),w=(0,U.useCallback)(e=>{h&&b(null),_(e)},[b,h]),T=(0,U.useCallback)(()=>{de(e)},[e]),E=(x?(0,K.jsx)(Pt,{schedule:x,assistantId:n,usage:s.usageForSchedule(x.id),isMobile:r,onClose:()=>b(null),onDeleted:()=>{b(null),s.refetch()}}):null)??(g&&S?(0,K.jsx)(qt,{kind:g,assistantId:n,systemTasks:l,canOpenMemorySettings:f,isMobile:r,onClose:()=>_(null)}):null),D=(0,K.jsx)(Rt,{recurring:s.recurring,oneTime:s.oneTime,pastOneTime:s.pastOneTime,usageForSchedule:s.usageForSchedule,isLoading:s.isLoading,isError:s.isError,refetch:s.refetch,onToggle:s.handleToggle,onSelectSchedule:C,selectedScheduleId:h,onStartNewChat:T,onCreateSchedule:()=>m(!0),pastOpen:v,onPastOpenChange:y,systemTasksSlot:(0,K.jsx)(St,{heartbeatConfig:l.heartbeatConfig,consolidationConfig:l.consolidationConfig,retrospectiveConfig:l.retrospectiveConfig,heartbeatUsage:l.heartbeatUsage,consolidationUsage:l.consolidationUsage,retrospectiveUsage:l.retrospectiveUsage,isLoading:l.isLoading,hasError:l.hasError,onRetry:l.refetchAll,onSelectHeartbeat:()=>w(`heartbeat`),onSelectConsolidation:()=>w(`consolidation`),onSelectRetrospective:()=>w(`retrospective`)})});return E&&r?(0,K.jsx)(ke,{children:E}):(0,K.jsxs)(K.Fragment,{children:[E&&!r?(0,K.jsx)(Ce,{storageKey:`schedulesDetailDrawerWidth`,detailKey:h??g??void 0,section:D,detail:E}):D,(0,K.jsx)(Je,{isOpen:p,assistantId:n,onClose:()=>m(!1),onCreated:()=>{m(!1),s.refetch()}})]})}export{Yt as SchedulesPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./check-wF3S-AV4.js";import{t as s}from"./modal-BtcwNEBj.js";import{t as c}from"./confirm-dialog-CCrDkChx.js";import{A as l,F as u,M as d,d as f,lt as p,rt as ee,t as te}from"./local-mode-hyYI6_OH.js";import{t as m}from"./is-electron-DBOtwp5h.js";import{n as h}from"./resolved-assistants-store-DdnJoLGS.js";import{D as g,E as _,i as v,n as y}from"./auth-store-B6EXnaee.js";import{c as b}from"./routes-XPLb07Av.js";import{t as x}from"./use-onboarding-login-D6BGXpJ1.js";import{Na as S,Sa as C,Xn as w,Zn as ne,g as T,vn as E}from"./index-CmaRQR9x.js";var D=e(t(),1),O=a();function k({open:e,assistantName:t,isPending:r,errorMessage:i,onCancel:a,onRepair:o,onRetire:l}){let[u,d]=(0,D.useState)(`menu`);(0,D.useEffect)(()=>{e&&d(`menu`)},[e]);let f=i?(0,O.jsx)(`span`,{className:`mt-3 block text-body-small-default text-[var(--system-negative-strong)]`,children:i}):null;return u===`confirm-repair`?(0,O.jsx)(c,{open:e,title:`Repair Assistant?`,message:(0,O.jsxs)(O.Fragment,{children:[`Repairing re-provisions this assistant’s authentication token. Any other devices or browser sessions connected to it will be signed out and need to reconnect.`,f]}),confirmLabel:`Repair`,isPending:r,onConfirm:o,onCancel:()=>d(`menu`)}):u===`confirm-retire`?(0,O.jsx)(w,{open:e,isPending:r,extraMessage:f,onConfirm:l,onCancel:()=>d(`menu`)}):(0,O.jsx)(s.Root,{open:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,O.jsxs)(s.Content,{size:`sm`,hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),r||a()},children:[(0,O.jsx)(s.Header,{children:(0,O.jsx)(s.Title,{children:`Can’t Authenticate Assistant`})}),(0,O.jsxs)(s.Body,{children:[(0,O.jsxs)(s.Description,{children:[`The authentication token for `,t,` is missing or can no longer be refreshed, so this assistant can’t be connected. You can repair it, retire it, or pick a different assistant.`]}),f,(0,O.jsxs)(`div`,{className:`mt-5 flex w-full flex-col gap-2`,children:[(0,O.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-repair`),children:`Wake & Repair`}),(0,O.jsx)(n,{variant:`dangerOutline`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-retire`),children:`Retire Assistant`}),(0,O.jsx)(n,{variant:`outlined`,fullWidth:!0,disabled:r,onClick:a,children:`Cancel`})]})]})]})})}function A(e){return e.name?e.name:e.isLocal?`Local Assistant`:`Cloud Assistant`}function j(e){if(e.hatchedAt)return`Created ${T(e.hatchedAt)}`}function M(){let e=i(),[t]=r(),a=t.get(`fromLogin`)===`1`,o=t.get(`noAutoSkip`)===`1`,s=m(),c=v(),S=h.use.assistants(),C=_.use.currentOrganizationId(),{loading:w,error:T,login:j,cancel:M}=x(),P=e=>e.isLocal||c,F=S.filter(P),I=S.some(e=>e.isPlatformHosted)&&!c,[L,R]=(0,D.useState)(null),[z,B]=(0,D.useState)(!1),[V,H]=(0,D.useState)(!1),[U,W]=(0,D.useState)(null),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(!1),[Y,X]=(0,D.useState)(null);(0,D.useEffect)(()=>{if(L!=null||F.length===0)return;let e=g(C);R(F.find(t=>t.id===e)?.id??F[0].id)},[L,F,C]);let Z=async t=>{B(!0),W(null);try{t.isLocal?await y.getState().connectLocalAssistant(t.id):await y.getState().connectPlatformAssistant(t.id),e(b.assistant,{replace:!0})}catch(e){console.error(`selectAssistant.handleConnect failed`,e),t.isLocal&&l()&&(d(e)||p(e)||e instanceof te)&&f(t.id)?K(t):W(`Failed to connect. Please try again.`),B(!1)}},Q=()=>{K(null),J(!1),X(null),H(!1)},re=async()=>{if(!(!G||q)){J(!0),X(null);try{let e=await u(G.id,{repairGuardian:!0});if(e.ok){ee(),Q(),Z(G);return}X(e.error||`Repair failed. Please try again.`)}catch(e){console.error(`selectAssistant.recoveryRepair failed`,e),X(`Repair failed. Please try again.`)}J(!1)}},ie=async()=>{if(!(!G||q)){J(!0),X(null);try{let t=await ne(G.id);if(t.ok){Q(),e(t.nextRoute,{replace:!0});return}X(t.error)}catch(e){console.error(`selectAssistant.recoveryRetire failed`,e),X(`Failed to retire assistant. Please try again.`)}J(!1)}};(0,D.useEffect)(()=>{a||o||z||V||S.length!==0&&S.length===1&&F.length===1&&(H(!0),Z(F[0]))},[S.length,F.length]);let ae=()=>{let e=S.find(e=>e.id===L);e&&Z(e)},oe=()=>{e(b.welcome)},$=T??U;return V&&!$&&!G?(0,O.jsx)(E,{children:(0,O.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-xl flex-col items-center justify-center px-6 text-[var(--content-default)]`,children:(0,O.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Connecting to your assistant…`})})}):(0,O.jsxs)(E,{children:[(0,O.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${s?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`min-h-screen px-6 pb-40 pt-16`} text-[var(--content-default)]`,children:[(0,O.jsx)(`h1`,{className:s?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Choose an Assistant`}),(0,O.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${s?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Select which assistant you’d like to use.`}),$&&(0,O.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:$}),(0,O.jsx)(`div`,{className:`flex w-full flex-col ${s?`mt-8 gap-2`:`mt-10 gap-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:S.map(e=>{let t=P(e);return(0,O.jsx)(N,{assistant:e,selected:L===e.id,disabled:!t,badge:!t&&e.isPlatformHosted?`Requires Account`:void 0,onSelect:()=>{t&&R(e.id)}},e.id)})}),(0,O.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${s?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[F.length>0&&(0,O.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:ae,disabled:!L||z,children:z?`Connecting…`:`Continue`}),(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:()=>void e(`${b.onboarding.hosting}?from=select-assistant`),disabled:z||w,children:`Create New Assistant`}),I&&(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:w?M:()=>void j(),disabled:z,children:w?`Cancel`:`Log In`}),(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:oe,disabled:z||w,children:`Back`})]})]}),(0,O.jsx)(k,{open:G!=null,assistantName:G?A(G):``,isPending:q,errorMessage:Y??void 0,onCancel:Q,onRepair:()=>void re(),onRetire:()=>void ie()})]})}function N({assistant:e,selected:t,disabled:n,badge:r,onSelect:i}){let a=j(e),s=m();return(0,O.jsxs)(`button`,{type:`button`,onClick:i,disabled:n,className:[`group flex w-full items-center border text-left`,s?`gap-3 rounded-lg p-3`:`gap-4 rounded-2xl px-5 py-4`,`transition-all duration-200 ease-out`,n?`cursor-not-allowed opacity-50`:`cursor-pointer hover:bg-[var(--surface-secondary)]`,t&&!n?`border-[var(--primary-base)] bg-[var(--primary-base)]/[0.08] shadow-[inset_0_0_0_1px_var(--primary-base)]`:`border-[var(--border-element)] bg-transparent`].join(` `),children:[(0,O.jsx)(`div`,{className:[`flex shrink-0 items-center justify-center transition-colors duration-200`,s?`h-8 w-8 rounded-lg`:`h-10 w-10 rounded-xl`,t&&!n?`bg-[var(--primary-base)]/15 text-[var(--primary-base)]`:`bg-[var(--surface-tertiary)] text-[var(--content-secondary)]`].join(` `),children:e.isLocal?(0,O.jsx)(C,{className:`h-5 w-5`}):(0,O.jsx)(S,{className:`h-5 w-5`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:A(e)}),r&&(0,O.jsx)(`span`,{className:`rounded-full bg-[var(--surface-tertiary)] px-2 py-0.5 text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:r})]}),a&&(0,O.jsx)(`span`,{className:`mt-0.5 block text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:a})]}),!n&&(0,O.jsx)(`div`,{className:[`flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 transition-all duration-200`,t?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--border-element)] group-hover:border-[var(--content-tertiary)]`].join(` `),children:t&&(0,O.jsx)(o,{className:`h-3 w-3 text-[var(--surface-base)]`,strokeWidth:3})})]})}export{M as SelectAssistantScreen};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./check-wF3S-AV4.js";import{t as s}from"./modal-BtcwNEBj.js";import{t as c}from"./confirm-dialog-CCrDkChx.js";import{A as l,F as u,M as d,d as f,lt as p,rt as ee,t as te}from"./local-mode-hyYI6_OH.js";import{t as m}from"./is-electron-DBOtwp5h.js";import{n as h}from"./resolved-assistants-store-DdnJoLGS.js";import{D as g,E as _,i as v,n as y}from"./auth-store-B6EXnaee.js";import{c as b}from"./routes-XPLb07Av.js";import{t as x}from"./use-onboarding-login-D6BGXpJ1.js";import{Na as S,Sa as C,Xn as w,Zn as ne,g as T,vn as E}from"./index-CgcZXB4g.js";var D=e(t(),1),O=a();function k({open:e,assistantName:t,isPending:r,errorMessage:i,onCancel:a,onRepair:o,onRetire:l}){let[u,d]=(0,D.useState)(`menu`);(0,D.useEffect)(()=>{e&&d(`menu`)},[e]);let f=i?(0,O.jsx)(`span`,{className:`mt-3 block text-body-small-default text-[var(--system-negative-strong)]`,children:i}):null;return u===`confirm-repair`?(0,O.jsx)(c,{open:e,title:`Repair Assistant?`,message:(0,O.jsxs)(O.Fragment,{children:[`Repairing re-provisions this assistant’s authentication token. Any other devices or browser sessions connected to it will be signed out and need to reconnect.`,f]}),confirmLabel:`Repair`,isPending:r,onConfirm:o,onCancel:()=>d(`menu`)}):u===`confirm-retire`?(0,O.jsx)(w,{open:e,isPending:r,extraMessage:f,onConfirm:l,onCancel:()=>d(`menu`)}):(0,O.jsx)(s.Root,{open:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,O.jsxs)(s.Content,{size:`sm`,hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),r||a()},children:[(0,O.jsx)(s.Header,{children:(0,O.jsx)(s.Title,{children:`Can’t Authenticate Assistant`})}),(0,O.jsxs)(s.Body,{children:[(0,O.jsxs)(s.Description,{children:[`The authentication token for `,t,` is missing or can no longer be refreshed, so this assistant can’t be connected. You can repair it, retire it, or pick a different assistant.`]}),f,(0,O.jsxs)(`div`,{className:`mt-5 flex w-full flex-col gap-2`,children:[(0,O.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-repair`),children:`Wake & Repair`}),(0,O.jsx)(n,{variant:`dangerOutline`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-retire`),children:`Retire Assistant`}),(0,O.jsx)(n,{variant:`outlined`,fullWidth:!0,disabled:r,onClick:a,children:`Cancel`})]})]})]})})}function A(e){return e.name?e.name:e.isLocal?`Local Assistant`:`Cloud Assistant`}function j(e){if(e.hatchedAt)return`Created ${T(e.hatchedAt)}`}function M(){let e=i(),[t]=r(),a=t.get(`fromLogin`)===`1`,o=t.get(`noAutoSkip`)===`1`,s=m(),c=v(),S=h.use.assistants(),C=_.use.currentOrganizationId(),{loading:w,error:T,login:j,cancel:M}=x(),P=e=>e.isLocal||c,F=S.filter(P),I=S.some(e=>e.isPlatformHosted)&&!c,[L,R]=(0,D.useState)(null),[z,B]=(0,D.useState)(!1),[V,H]=(0,D.useState)(!1),[U,W]=(0,D.useState)(null),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(!1),[Y,X]=(0,D.useState)(null);(0,D.useEffect)(()=>{if(L!=null||F.length===0)return;let e=g(C);R(F.find(t=>t.id===e)?.id??F[0].id)},[L,F,C]);let Z=async t=>{B(!0),W(null);try{t.isLocal?await y.getState().connectLocalAssistant(t.id):await y.getState().connectPlatformAssistant(t.id),e(b.assistant,{replace:!0})}catch(e){console.error(`selectAssistant.handleConnect failed`,e),t.isLocal&&l()&&(d(e)||p(e)||e instanceof te)&&f(t.id)?K(t):W(`Failed to connect. Please try again.`),B(!1)}},Q=()=>{K(null),J(!1),X(null),H(!1)},re=async()=>{if(!(!G||q)){J(!0),X(null);try{let e=await u(G.id,{repairGuardian:!0});if(e.ok){ee(),Q(),Z(G);return}X(e.error||`Repair failed. Please try again.`)}catch(e){console.error(`selectAssistant.recoveryRepair failed`,e),X(`Repair failed. Please try again.`)}J(!1)}},ie=async()=>{if(!(!G||q)){J(!0),X(null);try{let t=await ne(G.id);if(t.ok){Q(),e(t.nextRoute,{replace:!0});return}X(t.error)}catch(e){console.error(`selectAssistant.recoveryRetire failed`,e),X(`Failed to retire assistant. Please try again.`)}J(!1)}};(0,D.useEffect)(()=>{a||o||z||V||S.length!==0&&S.length===1&&F.length===1&&(H(!0),Z(F[0]))},[S.length,F.length]);let ae=()=>{let e=S.find(e=>e.id===L);e&&Z(e)},oe=()=>{e(b.welcome)},$=T??U;return V&&!$&&!G?(0,O.jsx)(E,{children:(0,O.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-xl flex-col items-center justify-center px-6 text-[var(--content-default)]`,children:(0,O.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Connecting to your assistant…`})})}):(0,O.jsxs)(E,{children:[(0,O.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${s?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`min-h-screen px-6 pb-40 pt-16`} text-[var(--content-default)]`,children:[(0,O.jsx)(`h1`,{className:s?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Choose an Assistant`}),(0,O.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${s?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Select which assistant you’d like to use.`}),$&&(0,O.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:$}),(0,O.jsx)(`div`,{className:`flex w-full flex-col ${s?`mt-8 gap-2`:`mt-10 gap-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:S.map(e=>{let t=P(e);return(0,O.jsx)(N,{assistant:e,selected:L===e.id,disabled:!t,badge:!t&&e.isPlatformHosted?`Requires Account`:void 0,onSelect:()=>{t&&R(e.id)}},e.id)})}),(0,O.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${s?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[F.length>0&&(0,O.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:ae,disabled:!L||z,children:z?`Connecting…`:`Continue`}),(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:()=>void e(`${b.onboarding.hosting}?from=select-assistant`),disabled:z||w,children:`Create New Assistant`}),I&&(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:w?M:()=>void j(),disabled:z,children:w?`Cancel`:`Log In`}),(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:oe,disabled:z||w,children:`Back`})]})]}),(0,O.jsx)(k,{open:G!=null,assistantName:G?A(G):``,isPending:q,errorMessage:Y??void 0,onCancel:Q,onRepair:()=>void re(),onRetire:()=>void ie()})]})}function N({assistant:e,selected:t,disabled:n,badge:r,onSelect:i}){let a=j(e),s=m();return(0,O.jsxs)(`button`,{type:`button`,onClick:i,disabled:n,className:[`group flex w-full items-center border text-left`,s?`gap-3 rounded-lg p-3`:`gap-4 rounded-2xl px-5 py-4`,`transition-all duration-200 ease-out`,n?`cursor-not-allowed opacity-50`:`cursor-pointer hover:bg-[var(--surface-secondary)]`,t&&!n?`border-[var(--primary-base)] bg-[var(--primary-base)]/[0.08] shadow-[inset_0_0_0_1px_var(--primary-base)]`:`border-[var(--border-element)] bg-transparent`].join(` `),children:[(0,O.jsx)(`div`,{className:[`flex shrink-0 items-center justify-center transition-colors duration-200`,s?`h-8 w-8 rounded-lg`:`h-10 w-10 rounded-xl`,t&&!n?`bg-[var(--primary-base)]/15 text-[var(--primary-base)]`:`bg-[var(--surface-tertiary)] text-[var(--content-secondary)]`].join(` `),children:e.isLocal?(0,O.jsx)(C,{className:`h-5 w-5`}):(0,O.jsx)(S,{className:`h-5 w-5`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:A(e)}),r&&(0,O.jsx)(`span`,{className:`rounded-full bg-[var(--surface-tertiary)] px-2 py-0.5 text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:r})]}),a&&(0,O.jsx)(`span`,{className:`mt-0.5 block text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:a})]}),!n&&(0,O.jsx)(`div`,{className:[`flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 transition-all duration-200`,t?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--border-element)] group-hover:border-[var(--content-tertiary)]`].join(` `),children:t&&(0,O.jsx)(o,{className:`h-3 w-3 text-[var(--surface-base)]`,strokeWidth:3})})]})}export{M as SelectAssistantScreen};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{l as n,r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./log-in-DWnaKiOt.js";import{i as s}from"./auth-store-B6EXnaee.js";import{c}from"./routes-XPLb07Av.js";import{t as l}from"./client-feature-flag-store-DeUwlUsr.js";import{t as u}from"./use-onboarding-login-D6BGXpJ1.js";import{t as d}from"./assistant-feature-flag-store-BpbbAIKZ.js";import{Ir as f,Wt as p,ga as m,mi as h}from"./index-CmaRQR9x.js";import{n as g,t as _}from"./sidebar-tree-r9N8LP3u.js";var v=e(t(),1),y=a();function b(){let e=d.use.settingsDeveloperNav(),t=d.use.credentialsSettings(),a=l.use.platformNotifications(),b=l.use.bookmarks(),x=h({platformHostedOnly:!0}),{pathname:S}=n(),C=i(),w=s(),{login:T}=u(),E=(0,v.useMemo)(()=>p.filter(e=>!(e.id===`notifications`&&(!a||x===`gated`)||e.id===`bookmarks`&&!b||e.id===`credentials`&&!t||e.id===`developer`)),[a,x,b,t]),D=(0,v.useMemo)(()=>{let t=[];return e&&t.push(...p.filter(e=>e.id===`developer`)),t.push(w?{id:`logout`,label:`Log Out`,icon:m,onSelect:()=>void f(C)}:{id:`login`,label:`Log In`,icon:o,onSelect:()=>void T()}),t},[e,w,C,T]),O=(0,v.useMemo)(()=>{if(S===c.settings.root)return`Settings`;let e=p.find(e=>S===e.href||S.startsWith(e.href+`/`));return e?e.label:`Settings`},[S]);return(0,y.jsx)(g,{backHref:c.assistant,sidebar:(0,y.jsx)(_,{items:E,bottomItems:D,indexPath:c.settings.root}),title:O,children:(0,y.jsx)(r,{})})}export{b as SettingsLayout};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{l as n,r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./log-in-DWnaKiOt.js";import{i as s}from"./auth-store-B6EXnaee.js";import{c}from"./routes-XPLb07Av.js";import{t as l}from"./client-feature-flag-store-DeUwlUsr.js";import{t as u}from"./use-onboarding-login-D6BGXpJ1.js";import{t as d}from"./assistant-feature-flag-store-BpbbAIKZ.js";import{Ir as f,Wt as p,ga as m,mi as h}from"./index-CgcZXB4g.js";import{n as g,t as _}from"./sidebar-tree-Cq8ACYzP.js";var v=e(t(),1),y=a();function b(){let e=d.use.settingsDeveloperNav(),t=d.use.credentialsSettings(),a=l.use.platformNotifications(),b=l.use.bookmarks(),x=h({platformHostedOnly:!0}),{pathname:S}=n(),C=i(),w=s(),{login:T}=u(),E=(0,v.useMemo)(()=>p.filter(e=>!(e.id===`notifications`&&(!a||x===`gated`)||e.id===`bookmarks`&&!b||e.id===`credentials`&&!t||e.id===`developer`)),[a,x,b,t]),D=(0,v.useMemo)(()=>{let t=[];return e&&t.push(...p.filter(e=>e.id===`developer`)),t.push(w?{id:`logout`,label:`Log Out`,icon:m,onSelect:()=>void f(C)}:{id:`login`,label:`Log In`,icon:o,onSelect:()=>void T()}),t},[e,w,C,T]),O=(0,v.useMemo)(()=>{if(S===c.settings.root)return`Settings`;let e=p.find(e=>S===e.href||S.startsWith(e.href+`/`));return e?e.label:`Settings`},[S]);return(0,y.jsx)(g,{backHref:c.assistant,sidebar:(0,y.jsx)(_,{items:E,bottomItems:D,indexPath:c.settings.root}),title:O,children:(0,y.jsx)(r,{})})}export{b as SettingsLayout};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./chunk-jRWAZmH_.js";import{t as n}from"./react-DJZBPgpf.js";import{n as r,t as i,z as a}from"./button-BQVYX8n_.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./bug-YmXTm_XW.js";import{t as l}from"./download-CXYjvgB3.js";import{t as u}from"./info-DPHR_AMJ.js";import{t as ee}from"./loader-circle-D57RZgLH.js";import{t as d}from"./x-CswtfvgS.js";import{t as f}from"./notice-BylgS5W_.js";import{n as p,t as m}from"./input-ZpyYt_a0.js";import{t as h}from"./toggle-QSEiPr3k.js";import{t as g}from"./dropdown-BMNSccmo.js";import{t as _}from"./is-electron-DBOtwp5h.js";import{an as v}from"./sdk.gen-D_Qurj4O.js";import{t as y}from"./impersonate-version-flag-CjFVQtQC.js";import{n as te}from"./auth-store-B6EXnaee.js";import{t as b}from"./dist-CGPrc2vu2.js";import{n as x}from"./diagnostics-CNSs2GQW.js";import{L as S}from"./react-query.gen-BXPoln4i.js";import{$i as C,ba as w,ca as ne,fa as T,ma as re}from"./index-CmaRQR9x.js";var E=e(n(),1),ie=e(a(),1),D=`vellum:debug:`;function ae(){let e={};if(typeof window>`u`)return e;try{for(let t=0;t<window.localStorage.length;t++){let n=window.localStorage.key(t);if(n===null||!n.startsWith(D))continue;let r=window.localStorage.getItem(n);r!==null&&(e[n]=r)}}catch{}return e}function O(){return{collectedAt:new Date().toISOString(),resolved:{impersonateAssistantVersion:y()},overrides:ae()}}var k=t({ShareFeedbackModal:()=>z}),A=s(),j=[{value:`bug_report`,label:`Bug Report`,icon:c,includesLogsByDefault:!0},{value:`feature_request`,label:`Feature Request`,icon:w,includesLogsByDefault:!1},{value:`other`,label:`Other`,icon:T,includesLogsByDefault:!1}],M=[{value:`past_hour`,label:`Past hour`,cutoffMs:3600*1e3},{value:`past_24_hours`,label:`Past 24 hours`,cutoffMs:1440*60*1e3},{value:`all_time`,label:`All time`,cutoffMs:null}],oe=M.map(e=>({value:e.value,label:e.label})),N=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`video/mp4`,`video/quicktime`,`video/webm`]),P=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`mp4`,`mov`,`webm`]),F=10,I=50*1024*1024,se={bug_report:`bug_report`,feature_request:`feature_request`,other:`other`};function ce(){return _()?`electron`:b.getPlatform()===`ios`?`ios`:`web`}function le(e){if(e.size>I)return!1;if(e.type&&N.has(e.type))return!0;if(!e.type){let t=e.name.split(`.`).pop()?.toLowerCase();return t?P.has(t):!1}return!1}function L(e,t){let n=Math.ceil(t.length/512),r=new Uint8Array(512+n*512),i=new TextEncoder,a=(e,t,n)=>{let a=i.encode(e);r.set(a.slice(0,n),t)},o=(e,t,n)=>{a(e.toString(8).padStart(n-1,`0`)+`\0`,t,n)};a(e,0,100),o(420,100,8),o(0,108,8),o(0,116,8),o(t.length,124,12),o(Math.floor(Date.now()/1e3),136,12);for(let e=148;e<156;e++)r[e]=32;r[156]=48,a(`ustar\0`,257,6),a(`00`,263,2);let s=0;for(let e=0;e<512;e++)s+=r[e];return o(s,148,7),r[155]=32,r.set(t,512),r}async function R(e,t){try{let n={};t.window.startTime!=null&&(n.startTime=t.window.startTime,n.endTime=t.window.endTime),t.activeConversationId&&(n.conversationId=t.activeConversationId);let{data:r,error:i}=await v({path:{assistant_id:e},body:n,parseAs:`blob`,throwOnError:!1});if(i||!(r instanceof Blob))return null;let a=await r.arrayBuffer();return new Uint8Array(a)}catch{return null}}async function ue(e,t,n,r={}){if(typeof CompressionStream>`u`)return null;let{diagnosticsProvider:i,doctorSessionId:a,extraLogFiles:o=[]}=r,s=new Date,c=M.find(t=>t.value===e),l=s.getTime(),u=c?.cutoffMs==null?null:l-c.cutoffMs,ee=u==null?null:new Date(u).toISOString(),d=null;try{d=i?.()??null}catch{d=null}let f=x(d),p={collected_at:s.toISOString(),time_range:e,cutoff:ee,log_window:{start_time_ms:u,end_time_ms:l},assistant_id:t,active_conversation_id:n,doctor_session_id:a??null,user_agent:typeof navigator<`u`?navigator.userAgent:``,language:typeof navigator<`u`?navigator.language:``,platform:typeof navigator<`u`?navigator.platform:``,url:typeof window<`u`?window.location.href:``,viewport:typeof window<`u`?{width:window.innerWidth,height:window.innerHeight}:null,screen:typeof screen<`u`?{width:screen.width,height:screen.height}:null,connection:typeof navigator<`u`&&`connection`in navigator?{effectiveType:navigator.connection.effectiveType,downlink:navigator.connection.downlink,rtt:navigator.connection.rtt}:null,deviceMemory:typeof navigator<`u`&&`deviceMemory`in navigator?navigator.deviceMemory:null,hardwareConcurrency:typeof navigator<`u`?navigator.hardwareConcurrency:null},m=new TextEncoder,h=m.encode(JSON.stringify(p,null,2)),g=m.encode(JSON.stringify(f,null,2)),v=[L(`web-client-context.json`,h),L(`web-chat-diagnostics.json`,g)],y=new TextEncoder().encode(JSON.stringify(O(),null,2));v.push(L(`web-debug-flags.json`,y));for(let e of o){let t=e.contents.trim();t&&v.push(L(e.filename,m.encode(t)))}try{let e=typeof window<`u`?window._vellumDebug?.chat:null;if(e){let t={clientMessages:e.getClientMessages?.()??null,transcriptItems:e.getTranscriptItems?.()??null,pendingInteractions:e.listPendingInteractions?.()??null,thinkingIndicator:e.thinkingIndicator?.()??null,streamingRing:e.streamingRing?.()??null,reconciliationDiagnostics:e.getReconciliationDiagnostics?.()??null},n=new TextEncoder().encode(JSON.stringify(t,null,2));v.push(L(`web-chat-debug-api-triage.json`,n))}}catch{}try{let e=typeof window<`u`?window._vellumDebug?.events:null;if(e){let t={focus:typeof document<`u`?{hasFocus:typeof document.hasFocus==`function`?document.hasFocus():null,visibilityState:document.visibilityState}:null,clients:e.getClients().map(({abortSignal:e,...t})=>({...t,aborted:e.aborted})),events:e.getEvents()},n=new TextEncoder().encode(JSON.stringify(t,null,2));v.push(L(`web-sse-liveness-triage.json`,n))}}catch{}if(_()&&window.vellum?.feedback){try{let e=await window.vellum.feedback.diagnostics(),t=new TextEncoder().encode(JSON.stringify(e,null,2));v.push(L(`electron-diagnostics.json`,t))}catch{}try{let e=await window.vellum.feedback.logs();if(e){let t=new TextEncoder().encode(e);v.push(L(`electron-main-logs.txt`,t))}}catch{}}if(t){let e=await R(t,{window:{startTime:u,endTime:l},activeConversationId:n});e&&v.push(L(`platform-logs.tar.gz`,e))}v.push(new Uint8Array(1024));let te=v.reduce((e,t)=>e+t.length,0),b=new Uint8Array(te),S=0;for(let e of v)b.set(e,S),S+=e.length;let C=new Blob([b.buffer]),w=await new Response(C.stream().pipeThrough(new CompressionStream(`gzip`))).blob();return new File([w],`web-client-logs-${s.getTime()}.tar.gz`,{type:`application/gzip`})}function z({open:e,onClose:t,initialReason:n,initialMessage:a,onSubmitted:s,assistantId:c,assistantVersion:v,activeConversationId:y,doctorSessionId:b,doctorSessionLog:x,getDiagnosticsSnapshot:w}){let T=te.use.user(),D=T?.email,ae=T?.isStaff??!1,O=(0,E.useId)(),k=(0,E.useRef)(null),M=(0,E.useRef)(null),N=(0,E.useRef)(null),P=(0,E.useRef)(null),[I,L]=(0,E.useState)(n??`bug_report`),[R,z]=(0,E.useState)(``),[B,pe]=(0,E.useState)(``),[V,H]=(0,E.useState)(j.find(e=>e.value===(n??`bug_report`))?.includesLogsByDefault??!0),[me,he]=(0,E.useState)(!1),[U,W]=(0,E.useState)(`past_hour`),[G,K]=(0,E.useState)([]),[ge,q]=(0,E.useState)(null),[_e,J]=(0,E.useState)(!1),[Y,ve]=(0,E.useState)(!1),[X,ye]=(0,E.useState)(!1),Z=o(S()),[be,Q]=(0,E.useState)(!1),$=Z.isPending||be,xe=!D,Se=(0,E.useMemo)(()=>R.trim().length>0&&B.trim().length>0,[R,B]);(0,E.useEffect)(()=>{if(!e)return;let t=n??`bug_report`;L(t),z(a??``),pe(D??``),H(j.find(e=>e.value===t)?.includesLogsByDefault??!0),he(!1),W(`past_hour`),K([]),ve(!1),ye(!1),q(null),Q(!1),Z.reset();let r=setTimeout(()=>{D?N.current?.focus():P.current?.focus()},50);return()=>clearTimeout(r)},[e]),(0,E.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e]);let Ce=e=>{L(e),me||H(j.find(t=>t.value===e)?.includesLogsByDefault??!1)},we=()=>{H(e=>!e),he(!0)},Te=x?.trim()?[{filename:`doctor-session.txt`,contents:x}]:[],Ee=(0,E.useCallback)(e=>{e.key===`Escape`&&!$&&t()},[t,$]),De=(0,E.useCallback)(e=>{e.target===k.current&&!$&&t()},[t,$]),Oe=(0,E.useCallback)(e=>{K(t=>{let n=F-t.length;if(n<=0)return t;let r=new Set(t.map(e=>`${e.name}:${e.size}`)),i=[];for(let t of e){if(i.length>=n)break;if(!le(t))continue;let e=`${t.name}:${t.size}`;r.has(e)||(r.add(e),i.push(t))}return i.length>0?[...t,...i]:t})},[]),ke=e=>{e.target.files&&Oe(Array.from(e.target.files)),e.target.value=``},Ae=e=>{e.preventDefault(),J(!1),e.dataTransfer.files?.length&&Oe(Array.from(e.dataTransfer.files))},je=e=>{e.preventDefault(),J(!0)},Me=e=>{e.preventDefault(),e.currentTarget===e.target&&J(!1)},Ne=e=>{K(t=>t.filter((t,n)=>n!==e))};return e?(0,ie.createPortal)((0,A.jsx)(`div`,{ref:k,role:`dialog`,"aria-modal":`true`,"aria-labelledby":O,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onKeyDown:Ee,onClick:De,onDrop:Ae,onDragOver:je,onDragLeave:Me,children:(0,A.jsxs)(`div`,{className:`mx-4 flex w-full max-w-lg flex-col rounded-xl border p-6 shadow-xl`,style:{backgroundColor:`var(--surface-lift)`,borderColor:`var(--border-base)`,maxHeight:`calc(100vh - 2rem)`},children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-4`,style:{borderColor:`var(--border-subtle)`},children:[(0,A.jsx)(`h2`,{id:O,className:`!m-0 text-title-small text-[var(--content-default)]`,children:`Share Feedback`}),(0,A.jsx)(i,{variant:`ghost`,iconOnly:(0,A.jsx)(d,{}),onClick:t,disabled:$,"aria-label":`Close`,tintColor:`var(--content-secondary)`})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-3.5 overflow-y-auto pt-4 ${$?`pointer-events-none opacity-60`:``}`,children:[ae&&(0,A.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,A.jsx)(h,{checked:X,onChange:()=>ye(e=>!e),"aria-label":`Download diagnostics directly`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Download diagnostics directly`})]}),(0,A.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Admin only — builds the diagnostics archive locally and downloads it instead of submitting feedback or notifying Slack.`})]}),X?(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Time range`}),(0,A.jsx)(g,{options:oe,value:U,onChange:W,"aria-label":`Diagnostics time range`})]}):(0,A.jsxs)(A.Fragment,{children:[xe&&(0,A.jsx)(m,{id:`${O}-email`,ref:P,label:`Email`,type:`email`,placeholder:`you@example.com`,value:B,onChange:e=>pe(e.target.value),leftIcon:(0,A.jsx)(re,{className:`h-4 w-4`,"aria-hidden":!0}),fullWidth:!0}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,A.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Category`}),(0,A.jsx)(`div`,{className:`flex gap-2`,children:j.map(e=>(0,A.jsx)(de,{option:e,isSelected:I===e.value,onSelect:()=>Ce(e.value)},e.value))})]}),(0,A.jsx)(`hr`,{className:`border-[var(--border-subtle)]`}),I===`bug_report`&&(0,A.jsxs)(f,{tone:`info`,children:[`Tip: Get faster support by posting in our`,` `,(0,A.jsx)(`a`,{href:`https://vellum.ai/community`,target:`_blank`,rel:`noopener noreferrer`,className:`underline text-[var(--content-default)]`,children:`Discord community`})]}),I===`feature_request`&&(0,A.jsxs)(f,{tone:`info`,children:[`Tip: Vote on features on our`,` `,(0,A.jsx)(`a`,{href:`https://vellum.ai/roadmap`,target:`_blank`,rel:`noopener noreferrer`,className:`underline text-[var(--content-default)]`,children:`public roadmap`})]}),(0,A.jsx)(p,{id:`${O}-message`,ref:N,label:I===`bug_report`?`What went wrong?`:I===`feature_request`?`Describe your idea`:`What's on your mind?`,rows:3,placeholder:I===`bug_report`?`What did you expect to happen, and what happened instead?`:I===`feature_request`?`What problem would this solve for you?`:`Share your thoughts...`,value:R,onChange:e=>z(e.target.value),fullWidth:!0}),I!==`feature_request`&&(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5`,children:[(0,A.jsx)(h,{checked:V,onChange:we,"aria-label":`Include browser diagnostics`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter leading-6 text-[var(--content-default)]`,children:`Include diagnostics`})]}),(0,A.jsx)(r,{content:`Diagnostics include browser context, assistant logs, and timestamps — never passwords or credentials.`,children:(0,A.jsx)(`button`,{type:`button`,"aria-label":`About diagnostics`,className:`inline-flex items-center justify-center text-[var(--content-tertiary)]`,children:(0,A.jsx)(u,{className:`h-3.5 w-3.5`})})})]}),V&&(0,A.jsx)(g,{options:oe,value:U,onChange:W,"aria-label":`Diagnostics time range`})]}),_()&&y&&I!==`feature_request`&&(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5`,children:[(0,A.jsx)(h,{checked:Y,onChange:()=>ve(e=>!e),"aria-label":`Include the most recent conversation`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter leading-6 text-[var(--content-default)]`,children:`Include the most recent conversation`})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:[`Attachments`,G.length>0&&(0,A.jsxs)(`span`,{className:`text-[var(--content-tertiary)]`,children:[` · `,G.length,`/`,F]})]}),(0,A.jsx)(i,{variant:`outlined`,size:`compact`,leftIcon:(0,A.jsx)(ne,{}),onClick:()=>M.current?.click(),disabled:G.length>=F,children:`Add files`}),(0,A.jsx)(`input`,{ref:M,type:`file`,multiple:!0,accept:`image/png,image/jpeg,image/gif,image/webp,video/mp4,video/quicktime,video/webm`,onChange:ke,className:`hidden`})]}),G.length>0&&(0,A.jsx)(`div`,{className:`flex gap-2 overflow-x-auto`,children:G.map((e,t)=>(0,A.jsx)(fe,{file:e,onRemove:()=>Ne(t)},`${e.name}-${t}`))}),_e&&(0,A.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Drop files to attach…`})]})]}),ge&&(0,A.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:ge})]}),(0,A.jsx)(`div`,{className:`mt-4 flex items-center justify-end gap-2 border-t pt-4`,style:{borderColor:`var(--border-subtle)`},children:$?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,A.jsx)(ee,{className:`h-4 w-4 animate-spin`}),X?`Preparing diagnostics…`:`Sending feedback…`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(i,{variant:`ghost`,onClick:t,children:`Cancel`}),X?(0,A.jsx)(i,{variant:`primary`,leftIcon:(0,A.jsx)(l,{}),onClick:async()=>{if(!$){q(null),Q(!0);try{let e=await ue(U,c??null,_()?Y?y??null:null:y??null,{diagnosticsProvider:w,doctorSessionId:b,extraLogFiles:Te});if(!e){q(`Diagnostics export isn't supported in this browser.`);return}let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=e.name,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),0),t()}catch(e){q(e instanceof Error?e.message:`Failed to build diagnostics. Please try again.`)}finally{Q(!1)}}},children:`Download diagnostics`}):(0,A.jsx)(i,{variant:`primary`,leftIcon:(0,A.jsx)(C,{}),onClick:async()=>{if(!(!Se||$)){q(null),Q(!0);try{let e=V&&I!==`feature_request`?await ue(U,c??null,_()?Y?y??null:null:y??null,{diagnosticsProvider:w,doctorSessionId:b,extraLogFiles:Te}):null;await Z.mutateAsync({headers:{"Content-Type":null},body:{message:R.trim(),classification:se[I],email:B.trim(),client:ce(),client_version:void 0,...c?{assistant_id:c}:{},...v?{assistant_version:v}:{},...b?{doctor_session_id:b}:{},...e?{logs_file:e}:{},...G.length?{attachments:G}:{}},bodySerializer:e=>{let t=new FormData;for(let[n,r]of Object.entries(e))if(r!=null){if(n===`attachments`&&Array.isArray(r)){for(let e of r)t.append(`attachments`,e);continue}r instanceof Blob?t.append(n,r):t.append(n,String(r))}return t}}),s?.(),t()}catch(e){q(e instanceof Error?e.message:`Failed to submit feedback. Please try again.`)}finally{Q(!1)}}},disabled:!Se,children:`Submit`})]})})]})}),document.body):null}function de({option:e,isSelected:t,onSelect:n}){let r=e.icon;return(0,A.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,className:`flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-left transition-colors`,style:{borderColor:t?`var(--primary-base)`:`var(--border-base)`,backgroundColor:t?`color-mix(in oklab, var(--primary-base) 10%, transparent)`:`transparent`},children:[(0,A.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`,style:{color:t?`var(--primary-base)`:`var(--content-secondary)`}}),(0,A.jsx)(`span`,{className:`text-body-small-default`,style:{color:t?`var(--primary-base)`:`var(--content-default)`},children:e.label})]})}function fe({file:e,onRemove:t}){let n=e.type.startsWith(`image/`),r=(0,E.useMemo)(()=>n?URL.createObjectURL(e):null,[e,n]);return(0,E.useEffect)(()=>{if(r)return()=>URL.revokeObjectURL(r)},[r]),(0,A.jsxs)(`div`,{className:`relative flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)]`,title:e.name,children:[n&&r?(0,A.jsx)(`img`,{src:r,alt:e.name,className:`h-full w-full object-cover`}):(0,A.jsx)(ne,{className:`h-5 w-5 text-[var(--content-secondary)]`}),(0,A.jsx)(i,{variant:`ghost`,size:`compact`,iconOnly:(0,A.jsx)(d,{}),onClick:t,"aria-label":`Remove ${e.name}`,className:`absolute top-0.5 right-0.5 h-4 w-4 rounded-full bg-black/60 text-white hover:bg-black/70`,tintColor:`#fff`})]})}export{k as n,z as t};
1
+ import{o as e,r as t}from"./chunk-jRWAZmH_.js";import{t as n}from"./react-DJZBPgpf.js";import{n as r,t as i,z as a}from"./button-BQVYX8n_.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./bug-YmXTm_XW.js";import{t as l}from"./download-CXYjvgB3.js";import{t as u}from"./info-DPHR_AMJ.js";import{t as ee}from"./loader-circle-D57RZgLH.js";import{t as d}from"./x-CswtfvgS.js";import{t as f}from"./notice-BylgS5W_.js";import{n as p,t as m}from"./input-ZpyYt_a0.js";import{t as h}from"./toggle-QSEiPr3k.js";import{t as g}from"./dropdown-BMNSccmo.js";import{t as _}from"./is-electron-DBOtwp5h.js";import{an as v}from"./sdk.gen-D_Qurj4O.js";import{t as y}from"./impersonate-version-flag-CjFVQtQC.js";import{n as te}from"./auth-store-B6EXnaee.js";import{t as b}from"./dist-CGPrc2vu2.js";import{n as x}from"./diagnostics-CNSs2GQW.js";import{L as S}from"./react-query.gen-BXPoln4i.js";import{$i as C,ba as w,ca as ne,fa as T,ma as re}from"./index-CgcZXB4g.js";var E=e(n(),1),ie=e(a(),1),D=`vellum:debug:`;function ae(){let e={};if(typeof window>`u`)return e;try{for(let t=0;t<window.localStorage.length;t++){let n=window.localStorage.key(t);if(n===null||!n.startsWith(D))continue;let r=window.localStorage.getItem(n);r!==null&&(e[n]=r)}}catch{}return e}function O(){return{collectedAt:new Date().toISOString(),resolved:{impersonateAssistantVersion:y()},overrides:ae()}}var k=t({ShareFeedbackModal:()=>z}),A=s(),j=[{value:`bug_report`,label:`Bug Report`,icon:c,includesLogsByDefault:!0},{value:`feature_request`,label:`Feature Request`,icon:w,includesLogsByDefault:!1},{value:`other`,label:`Other`,icon:T,includesLogsByDefault:!1}],M=[{value:`past_hour`,label:`Past hour`,cutoffMs:3600*1e3},{value:`past_24_hours`,label:`Past 24 hours`,cutoffMs:1440*60*1e3},{value:`all_time`,label:`All time`,cutoffMs:null}],oe=M.map(e=>({value:e.value,label:e.label})),N=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`video/mp4`,`video/quicktime`,`video/webm`]),P=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`mp4`,`mov`,`webm`]),F=10,I=50*1024*1024,se={bug_report:`bug_report`,feature_request:`feature_request`,other:`other`};function ce(){return _()?`electron`:b.getPlatform()===`ios`?`ios`:`web`}function le(e){if(e.size>I)return!1;if(e.type&&N.has(e.type))return!0;if(!e.type){let t=e.name.split(`.`).pop()?.toLowerCase();return t?P.has(t):!1}return!1}function L(e,t){let n=Math.ceil(t.length/512),r=new Uint8Array(512+n*512),i=new TextEncoder,a=(e,t,n)=>{let a=i.encode(e);r.set(a.slice(0,n),t)},o=(e,t,n)=>{a(e.toString(8).padStart(n-1,`0`)+`\0`,t,n)};a(e,0,100),o(420,100,8),o(0,108,8),o(0,116,8),o(t.length,124,12),o(Math.floor(Date.now()/1e3),136,12);for(let e=148;e<156;e++)r[e]=32;r[156]=48,a(`ustar\0`,257,6),a(`00`,263,2);let s=0;for(let e=0;e<512;e++)s+=r[e];return o(s,148,7),r[155]=32,r.set(t,512),r}async function R(e,t){try{let n={};t.window.startTime!=null&&(n.startTime=t.window.startTime,n.endTime=t.window.endTime),t.activeConversationId&&(n.conversationId=t.activeConversationId);let{data:r,error:i}=await v({path:{assistant_id:e},body:n,parseAs:`blob`,throwOnError:!1});if(i||!(r instanceof Blob))return null;let a=await r.arrayBuffer();return new Uint8Array(a)}catch{return null}}async function ue(e,t,n,r={}){if(typeof CompressionStream>`u`)return null;let{diagnosticsProvider:i,doctorSessionId:a,extraLogFiles:o=[]}=r,s=new Date,c=M.find(t=>t.value===e),l=s.getTime(),u=c?.cutoffMs==null?null:l-c.cutoffMs,ee=u==null?null:new Date(u).toISOString(),d=null;try{d=i?.()??null}catch{d=null}let f=x(d),p={collected_at:s.toISOString(),time_range:e,cutoff:ee,log_window:{start_time_ms:u,end_time_ms:l},assistant_id:t,active_conversation_id:n,doctor_session_id:a??null,user_agent:typeof navigator<`u`?navigator.userAgent:``,language:typeof navigator<`u`?navigator.language:``,platform:typeof navigator<`u`?navigator.platform:``,url:typeof window<`u`?window.location.href:``,viewport:typeof window<`u`?{width:window.innerWidth,height:window.innerHeight}:null,screen:typeof screen<`u`?{width:screen.width,height:screen.height}:null,connection:typeof navigator<`u`&&`connection`in navigator?{effectiveType:navigator.connection.effectiveType,downlink:navigator.connection.downlink,rtt:navigator.connection.rtt}:null,deviceMemory:typeof navigator<`u`&&`deviceMemory`in navigator?navigator.deviceMemory:null,hardwareConcurrency:typeof navigator<`u`?navigator.hardwareConcurrency:null},m=new TextEncoder,h=m.encode(JSON.stringify(p,null,2)),g=m.encode(JSON.stringify(f,null,2)),v=[L(`web-client-context.json`,h),L(`web-chat-diagnostics.json`,g)],y=new TextEncoder().encode(JSON.stringify(O(),null,2));v.push(L(`web-debug-flags.json`,y));for(let e of o){let t=e.contents.trim();t&&v.push(L(e.filename,m.encode(t)))}try{let e=typeof window<`u`?window._vellumDebug?.chat:null;if(e){let t={clientMessages:e.getClientMessages?.()??null,transcriptItems:e.getTranscriptItems?.()??null,pendingInteractions:e.listPendingInteractions?.()??null,thinkingIndicator:e.thinkingIndicator?.()??null,streamingRing:e.streamingRing?.()??null,reconciliationDiagnostics:e.getReconciliationDiagnostics?.()??null},n=new TextEncoder().encode(JSON.stringify(t,null,2));v.push(L(`web-chat-debug-api-triage.json`,n))}}catch{}try{let e=typeof window<`u`?window._vellumDebug?.events:null;if(e){let t={focus:typeof document<`u`?{hasFocus:typeof document.hasFocus==`function`?document.hasFocus():null,visibilityState:document.visibilityState}:null,clients:e.getClients().map(({abortSignal:e,...t})=>({...t,aborted:e.aborted})),events:e.getEvents()},n=new TextEncoder().encode(JSON.stringify(t,null,2));v.push(L(`web-sse-liveness-triage.json`,n))}}catch{}if(_()&&window.vellum?.feedback){try{let e=await window.vellum.feedback.diagnostics(),t=new TextEncoder().encode(JSON.stringify(e,null,2));v.push(L(`electron-diagnostics.json`,t))}catch{}try{let e=await window.vellum.feedback.logs();if(e){let t=new TextEncoder().encode(e);v.push(L(`electron-main-logs.txt`,t))}}catch{}}if(t){let e=await R(t,{window:{startTime:u,endTime:l},activeConversationId:n});e&&v.push(L(`platform-logs.tar.gz`,e))}v.push(new Uint8Array(1024));let te=v.reduce((e,t)=>e+t.length,0),b=new Uint8Array(te),S=0;for(let e of v)b.set(e,S),S+=e.length;let C=new Blob([b.buffer]),w=await new Response(C.stream().pipeThrough(new CompressionStream(`gzip`))).blob();return new File([w],`web-client-logs-${s.getTime()}.tar.gz`,{type:`application/gzip`})}function z({open:e,onClose:t,initialReason:n,initialMessage:a,onSubmitted:s,assistantId:c,assistantVersion:v,activeConversationId:y,doctorSessionId:b,doctorSessionLog:x,getDiagnosticsSnapshot:w}){let T=te.use.user(),D=T?.email,ae=T?.isStaff??!1,O=(0,E.useId)(),k=(0,E.useRef)(null),M=(0,E.useRef)(null),N=(0,E.useRef)(null),P=(0,E.useRef)(null),[I,L]=(0,E.useState)(n??`bug_report`),[R,z]=(0,E.useState)(``),[B,pe]=(0,E.useState)(``),[V,H]=(0,E.useState)(j.find(e=>e.value===(n??`bug_report`))?.includesLogsByDefault??!0),[me,he]=(0,E.useState)(!1),[U,W]=(0,E.useState)(`past_hour`),[G,K]=(0,E.useState)([]),[ge,q]=(0,E.useState)(null),[_e,J]=(0,E.useState)(!1),[Y,ve]=(0,E.useState)(!1),[X,ye]=(0,E.useState)(!1),Z=o(S()),[be,Q]=(0,E.useState)(!1),$=Z.isPending||be,xe=!D,Se=(0,E.useMemo)(()=>R.trim().length>0&&B.trim().length>0,[R,B]);(0,E.useEffect)(()=>{if(!e)return;let t=n??`bug_report`;L(t),z(a??``),pe(D??``),H(j.find(e=>e.value===t)?.includesLogsByDefault??!0),he(!1),W(`past_hour`),K([]),ve(!1),ye(!1),q(null),Q(!1),Z.reset();let r=setTimeout(()=>{D?N.current?.focus():P.current?.focus()},50);return()=>clearTimeout(r)},[e]),(0,E.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e]);let Ce=e=>{L(e),me||H(j.find(t=>t.value===e)?.includesLogsByDefault??!1)},we=()=>{H(e=>!e),he(!0)},Te=x?.trim()?[{filename:`doctor-session.txt`,contents:x}]:[],Ee=(0,E.useCallback)(e=>{e.key===`Escape`&&!$&&t()},[t,$]),De=(0,E.useCallback)(e=>{e.target===k.current&&!$&&t()},[t,$]),Oe=(0,E.useCallback)(e=>{K(t=>{let n=F-t.length;if(n<=0)return t;let r=new Set(t.map(e=>`${e.name}:${e.size}`)),i=[];for(let t of e){if(i.length>=n)break;if(!le(t))continue;let e=`${t.name}:${t.size}`;r.has(e)||(r.add(e),i.push(t))}return i.length>0?[...t,...i]:t})},[]),ke=e=>{e.target.files&&Oe(Array.from(e.target.files)),e.target.value=``},Ae=e=>{e.preventDefault(),J(!1),e.dataTransfer.files?.length&&Oe(Array.from(e.dataTransfer.files))},je=e=>{e.preventDefault(),J(!0)},Me=e=>{e.preventDefault(),e.currentTarget===e.target&&J(!1)},Ne=e=>{K(t=>t.filter((t,n)=>n!==e))};return e?(0,ie.createPortal)((0,A.jsx)(`div`,{ref:k,role:`dialog`,"aria-modal":`true`,"aria-labelledby":O,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onKeyDown:Ee,onClick:De,onDrop:Ae,onDragOver:je,onDragLeave:Me,children:(0,A.jsxs)(`div`,{className:`mx-4 flex w-full max-w-lg flex-col rounded-xl border p-6 shadow-xl`,style:{backgroundColor:`var(--surface-lift)`,borderColor:`var(--border-base)`,maxHeight:`calc(100vh - 2rem)`},children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-4`,style:{borderColor:`var(--border-subtle)`},children:[(0,A.jsx)(`h2`,{id:O,className:`!m-0 text-title-small text-[var(--content-default)]`,children:`Share Feedback`}),(0,A.jsx)(i,{variant:`ghost`,iconOnly:(0,A.jsx)(d,{}),onClick:t,disabled:$,"aria-label":`Close`,tintColor:`var(--content-secondary)`})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-3.5 overflow-y-auto pt-4 ${$?`pointer-events-none opacity-60`:``}`,children:[ae&&(0,A.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,A.jsx)(h,{checked:X,onChange:()=>ye(e=>!e),"aria-label":`Download diagnostics directly`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Download diagnostics directly`})]}),(0,A.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Admin only — builds the diagnostics archive locally and downloads it instead of submitting feedback or notifying Slack.`})]}),X?(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Time range`}),(0,A.jsx)(g,{options:oe,value:U,onChange:W,"aria-label":`Diagnostics time range`})]}):(0,A.jsxs)(A.Fragment,{children:[xe&&(0,A.jsx)(m,{id:`${O}-email`,ref:P,label:`Email`,type:`email`,placeholder:`you@example.com`,value:B,onChange:e=>pe(e.target.value),leftIcon:(0,A.jsx)(re,{className:`h-4 w-4`,"aria-hidden":!0}),fullWidth:!0}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,A.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Category`}),(0,A.jsx)(`div`,{className:`flex gap-2`,children:j.map(e=>(0,A.jsx)(de,{option:e,isSelected:I===e.value,onSelect:()=>Ce(e.value)},e.value))})]}),(0,A.jsx)(`hr`,{className:`border-[var(--border-subtle)]`}),I===`bug_report`&&(0,A.jsxs)(f,{tone:`info`,children:[`Tip: Get faster support by posting in our`,` `,(0,A.jsx)(`a`,{href:`https://vellum.ai/community`,target:`_blank`,rel:`noopener noreferrer`,className:`underline text-[var(--content-default)]`,children:`Discord community`})]}),I===`feature_request`&&(0,A.jsxs)(f,{tone:`info`,children:[`Tip: Vote on features on our`,` `,(0,A.jsx)(`a`,{href:`https://vellum.ai/roadmap`,target:`_blank`,rel:`noopener noreferrer`,className:`underline text-[var(--content-default)]`,children:`public roadmap`})]}),(0,A.jsx)(p,{id:`${O}-message`,ref:N,label:I===`bug_report`?`What went wrong?`:I===`feature_request`?`Describe your idea`:`What's on your mind?`,rows:3,placeholder:I===`bug_report`?`What did you expect to happen, and what happened instead?`:I===`feature_request`?`What problem would this solve for you?`:`Share your thoughts...`,value:R,onChange:e=>z(e.target.value),fullWidth:!0}),I!==`feature_request`&&(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5`,children:[(0,A.jsx)(h,{checked:V,onChange:we,"aria-label":`Include browser diagnostics`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter leading-6 text-[var(--content-default)]`,children:`Include diagnostics`})]}),(0,A.jsx)(r,{content:`Diagnostics include browser context, assistant logs, and timestamps — never passwords or credentials.`,children:(0,A.jsx)(`button`,{type:`button`,"aria-label":`About diagnostics`,className:`inline-flex items-center justify-center text-[var(--content-tertiary)]`,children:(0,A.jsx)(u,{className:`h-3.5 w-3.5`})})})]}),V&&(0,A.jsx)(g,{options:oe,value:U,onChange:W,"aria-label":`Diagnostics time range`})]}),_()&&y&&I!==`feature_request`&&(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5`,children:[(0,A.jsx)(h,{checked:Y,onChange:()=>ve(e=>!e),"aria-label":`Include the most recent conversation`}),(0,A.jsx)(`span`,{className:`text-body-medium-lighter leading-6 text-[var(--content-default)]`,children:`Include the most recent conversation`})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:[`Attachments`,G.length>0&&(0,A.jsxs)(`span`,{className:`text-[var(--content-tertiary)]`,children:[` · `,G.length,`/`,F]})]}),(0,A.jsx)(i,{variant:`outlined`,size:`compact`,leftIcon:(0,A.jsx)(ne,{}),onClick:()=>M.current?.click(),disabled:G.length>=F,children:`Add files`}),(0,A.jsx)(`input`,{ref:M,type:`file`,multiple:!0,accept:`image/png,image/jpeg,image/gif,image/webp,video/mp4,video/quicktime,video/webm`,onChange:ke,className:`hidden`})]}),G.length>0&&(0,A.jsx)(`div`,{className:`flex gap-2 overflow-x-auto`,children:G.map((e,t)=>(0,A.jsx)(fe,{file:e,onRemove:()=>Ne(t)},`${e.name}-${t}`))}),_e&&(0,A.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Drop files to attach…`})]})]}),ge&&(0,A.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:ge})]}),(0,A.jsx)(`div`,{className:`mt-4 flex items-center justify-end gap-2 border-t pt-4`,style:{borderColor:`var(--border-subtle)`},children:$?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,A.jsx)(ee,{className:`h-4 w-4 animate-spin`}),X?`Preparing diagnostics…`:`Sending feedback…`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(i,{variant:`ghost`,onClick:t,children:`Cancel`}),X?(0,A.jsx)(i,{variant:`primary`,leftIcon:(0,A.jsx)(l,{}),onClick:async()=>{if(!$){q(null),Q(!0);try{let e=await ue(U,c??null,_()?Y?y??null:null:y??null,{diagnosticsProvider:w,doctorSessionId:b,extraLogFiles:Te});if(!e){q(`Diagnostics export isn't supported in this browser.`);return}let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=e.name,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),0),t()}catch(e){q(e instanceof Error?e.message:`Failed to build diagnostics. Please try again.`)}finally{Q(!1)}}},children:`Download diagnostics`}):(0,A.jsx)(i,{variant:`primary`,leftIcon:(0,A.jsx)(C,{}),onClick:async()=>{if(!(!Se||$)){q(null),Q(!0);try{let e=V&&I!==`feature_request`?await ue(U,c??null,_()?Y?y??null:null:y??null,{diagnosticsProvider:w,doctorSessionId:b,extraLogFiles:Te}):null;await Z.mutateAsync({headers:{"Content-Type":null},body:{message:R.trim(),classification:se[I],email:B.trim(),client:ce(),client_version:void 0,...c?{assistant_id:c}:{},...v?{assistant_version:v}:{},...b?{doctor_session_id:b}:{},...e?{logs_file:e}:{},...G.length?{attachments:G}:{}},bodySerializer:e=>{let t=new FormData;for(let[n,r]of Object.entries(e))if(r!=null){if(n===`attachments`&&Array.isArray(r)){for(let e of r)t.append(`attachments`,e);continue}r instanceof Blob?t.append(n,r):t.append(n,String(r))}return t}}),s?.(),t()}catch(e){q(e instanceof Error?e.message:`Failed to submit feedback. Please try again.`)}finally{Q(!1)}}},disabled:!Se,children:`Submit`})]})})]})}),document.body):null}function de({option:e,isSelected:t,onSelect:n}){let r=e.icon;return(0,A.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,className:`flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-left transition-colors`,style:{borderColor:t?`var(--primary-base)`:`var(--border-base)`,backgroundColor:t?`color-mix(in oklab, var(--primary-base) 10%, transparent)`:`transparent`},children:[(0,A.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`,style:{color:t?`var(--primary-base)`:`var(--content-secondary)`}}),(0,A.jsx)(`span`,{className:`text-body-small-default`,style:{color:t?`var(--primary-base)`:`var(--content-default)`},children:e.label})]})}function fe({file:e,onRemove:t}){let n=e.type.startsWith(`image/`),r=(0,E.useMemo)(()=>n?URL.createObjectURL(e):null,[e,n]);return(0,E.useEffect)(()=>{if(r)return()=>URL.revokeObjectURL(r)},[r]),(0,A.jsxs)(`div`,{className:`relative flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)]`,title:e.name,children:[n&&r?(0,A.jsx)(`img`,{src:r,alt:e.name,className:`h-full w-full object-cover`}):(0,A.jsx)(ne,{className:`h-5 w-5 text-[var(--content-secondary)]`}),(0,A.jsx)(i,{variant:`ghost`,size:`compact`,iconOnly:(0,A.jsx)(d,{}),onClick:t,"aria-label":`Remove ${e.name}`,className:`absolute top-0.5 right-0.5 h-4 w-4 rounded-full bg-black/60 text-white hover:bg-black/70`,tintColor:`#fff`})]})}export{k as n,z as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{l as r,t as i,u as a}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./typography-Cqi8q9o7.js";import{t as c}from"./arrow-left-C2re-gYj.js";import{t as l}from"./chevron-right-jRymmL7S.js";import{o as u}from"./src-CDdn26Yb.js";import{t as d}from"./is-electron-DBOtwp5h.js";import{c as f}from"./routes-XPLb07Av.js";import{Nn as p,Qn as m,zr as h}from"./index-CmaRQR9x.js";import{t as g}from"./use-edge-swipe-back-CzIG6Agy.js";var _=e(t(),1),v=o();function y({sidebar:e,children:t,actions:o,backHref:l,title:u=`Settings`,menuRoute:y=f.settings.root}){let{pathname:b}=r(),x=a(),S=b===y,C=h(),w=(0,_.useRef)(null),T=(0,_.useRef)(null);(0,_.useLayoutEffect)(()=>{T.current?.scrollTo(0,0)},[b]);let E=S?l:y;g({containerRef:w,onBack:(0,_.useCallback)(()=>{x(E)},[x,E]),enabled:C,navKey:b});let D=d(),O=S?`Back from ${u}`:`Back to ${u} menu`,k=(0,v.jsx)(n,{variant:`ghost`,iconOnly:(0,v.jsx)(c,{}),"aria-label":O,tintColor:`var(--content-secondary)`,onClick:()=>x(E)}),A=(0,v.jsx)(n,{asChild:!0,variant:`outlined`,"aria-label":`Back from ${u}`,className:`h-8 w-8 px-0`,tintColor:`var(--content-secondary)`,children:(0,v.jsx)(i,{to:l,className:`flex items-center justify-center no-underline`,children:(0,v.jsx)(c,{size:16,"aria-hidden":`true`})})});return(0,v.jsxs)(`div`,{ref:w,className:`flex h-full min-h-0 w-full flex-1 flex-col gap-4 p-4 sm:p-6 md:gap-0`,style:{paddingTop:D?`3.75rem`:`1rem`},children:[(0,v.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 md:hidden`,children:[k,(0,v.jsx)(s,{as:`h1`,variant:`body-large-default`,className:`flex-1 truncate text-center`,style:{color:`var(--content-tertiary)`,lineHeight:1.4},children:u}),(0,v.jsx)(`div`,{className:`h-10 w-10 shrink-0`,"aria-hidden":`true`})]}),D?(0,v.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 pb-4 empty:hidden`,children:[(0,v.jsx)(m,{placement:`electron`,className:`px-0 pt-0`}),(0,v.jsx)(p,{placement:`electron`,className:`px-0 pt-0`})]}):null,(0,v.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:rounded-[12px] md:border md:border-[var(--border-base)] md:bg-[var(--surface-overlay)]`,children:[(0,v.jsxs)(`div`,{className:`hidden shrink-0 items-center justify-between gap-4 px-6 py-5 md:flex`,children:[(0,v.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[A,(0,v.jsx)(`h1`,{className:`text-title-large truncate`,style:{color:`var(--content-emphasised)`,lineHeight:1.2},children:u})]}),(0,v.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:o})]}),(0,v.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,v.jsx)(`aside`,{className:`hidden w-64 shrink-0 overflow-y-auto md:block`,"aria-label":`${u} navigation`,children:e}),S?(0,v.jsx)(`div`,{className:`flex min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overflow-x-hidden pb-6 md:hidden`,children:e}):null,(0,v.jsx)(`main`,{ref:T,className:`min-w-0 min-h-0 flex-1 flex-col gap-4 overflow-y-auto overflow-x-hidden pb-6 md:flex md:px-6 md:pt-0 ${S?`hidden`:`flex`}`,children:t})]})]})]})}function b({items:e,bottomItems:t,indexPath:n}){let{pathname:i}=r(),o=a(),s=h(),c=(e,t,r)=>{let{href:a,onSelect:c}=e,d=a!=null&&(i===a||i.startsWith(a+`/`)||!s&&r&&n!=null&&i===n);return(0,v.jsxs)(_.Fragment,{children:[(0,v.jsx)(u.Item,{icon:e.icon,label:e.label,active:d,trailingIcon:a==null?void 0:l,trailingIconClassName:a==null?void 0:`md:hidden`,href:a,onSelect:c,onClick:a==null?void 0:e=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0||(e.preventDefault(),o(a))}}),!t&&(0,v.jsx)(`div`,{role:`presentation`,"aria-hidden":!0,className:`my-2 h-px w-full bg-[var(--border-base)] md:hidden`})]},e.id)};return(0,v.jsxs)(`nav`,{"aria-label":`Sidebar navigation`,className:`flex min-h-full flex-col md:gap-2 md:px-6 md:pb-4`,children:[e.map((n,r)=>c(n,r===e.length-1&&!t?.length,r===0)),t&&t.length>0&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`flex-1`}),(0,v.jsx)(`div`,{role:`presentation`,"aria-hidden":!0,className:`mx-0 my-2 h-px w-full bg-[var(--border-base)] md:mx-0`}),t.map((e,n)=>c(e,n===t.length-1,!1))]})]})}export{y as n,b as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{l as r,t as i,u as a}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./typography-Cqi8q9o7.js";import{t as c}from"./arrow-left-C2re-gYj.js";import{t as l}from"./chevron-right-jRymmL7S.js";import{o as u}from"./src-CDdn26Yb.js";import{t as d}from"./is-electron-DBOtwp5h.js";import{c as f}from"./routes-XPLb07Av.js";import{Nn as p,Qn as m,zr as h}from"./index-CgcZXB4g.js";import{t as g}from"./use-edge-swipe-back-Dpo-0Weh.js";var _=e(t(),1),v=o();function y({sidebar:e,children:t,actions:o,backHref:l,title:u=`Settings`,menuRoute:y=f.settings.root}){let{pathname:b}=r(),x=a(),S=b===y,C=h(),w=(0,_.useRef)(null),T=(0,_.useRef)(null);(0,_.useLayoutEffect)(()=>{T.current?.scrollTo(0,0)},[b]);let E=S?l:y;g({containerRef:w,onBack:(0,_.useCallback)(()=>{x(E)},[x,E]),enabled:C,navKey:b});let D=d(),O=S?`Back from ${u}`:`Back to ${u} menu`,k=(0,v.jsx)(n,{variant:`ghost`,iconOnly:(0,v.jsx)(c,{}),"aria-label":O,tintColor:`var(--content-secondary)`,onClick:()=>x(E)}),A=(0,v.jsx)(n,{asChild:!0,variant:`outlined`,"aria-label":`Back from ${u}`,className:`h-8 w-8 px-0`,tintColor:`var(--content-secondary)`,children:(0,v.jsx)(i,{to:l,className:`flex items-center justify-center no-underline`,children:(0,v.jsx)(c,{size:16,"aria-hidden":`true`})})});return(0,v.jsxs)(`div`,{ref:w,className:`flex h-full min-h-0 w-full flex-1 flex-col gap-4 p-4 sm:p-6 md:gap-0`,style:{paddingTop:D?`3.75rem`:`1rem`},children:[(0,v.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 md:hidden`,children:[k,(0,v.jsx)(s,{as:`h1`,variant:`body-large-default`,className:`flex-1 truncate text-center`,style:{color:`var(--content-tertiary)`,lineHeight:1.4},children:u}),(0,v.jsx)(`div`,{className:`h-10 w-10 shrink-0`,"aria-hidden":`true`})]}),D?(0,v.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 pb-4 empty:hidden`,children:[(0,v.jsx)(m,{placement:`electron`,className:`px-0 pt-0`}),(0,v.jsx)(p,{placement:`electron`,className:`px-0 pt-0`})]}):null,(0,v.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:rounded-[12px] md:border md:border-[var(--border-base)] md:bg-[var(--surface-overlay)]`,children:[(0,v.jsxs)(`div`,{className:`hidden shrink-0 items-center justify-between gap-4 px-6 py-5 md:flex`,children:[(0,v.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[A,(0,v.jsx)(`h1`,{className:`text-title-large truncate`,style:{color:`var(--content-emphasised)`,lineHeight:1.2},children:u})]}),(0,v.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:o})]}),(0,v.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,v.jsx)(`aside`,{className:`hidden w-64 shrink-0 overflow-y-auto md:block`,"aria-label":`${u} navigation`,children:e}),S?(0,v.jsx)(`div`,{className:`flex min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overflow-x-hidden pb-6 md:hidden`,children:e}):null,(0,v.jsx)(`main`,{ref:T,className:`min-w-0 min-h-0 flex-1 flex-col gap-4 overflow-y-auto overflow-x-hidden pb-6 md:flex md:px-6 md:pt-0 ${S?`hidden`:`flex`}`,children:t})]})]})]})}function b({items:e,bottomItems:t,indexPath:n}){let{pathname:i}=r(),o=a(),s=h(),c=(e,t,r)=>{let{href:a,onSelect:c}=e,d=a!=null&&(i===a||i.startsWith(a+`/`)||!s&&r&&n!=null&&i===n);return(0,v.jsxs)(_.Fragment,{children:[(0,v.jsx)(u.Item,{icon:e.icon,label:e.label,active:d,trailingIcon:a==null?void 0:l,trailingIconClassName:a==null?void 0:`md:hidden`,href:a,onSelect:c,onClick:a==null?void 0:e=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0||(e.preventDefault(),o(a))}}),!t&&(0,v.jsx)(`div`,{role:`presentation`,"aria-hidden":!0,className:`my-2 h-px w-full bg-[var(--border-base)] md:hidden`})]},e.id)};return(0,v.jsxs)(`nav`,{"aria-label":`Sidebar navigation`,className:`flex min-h-full flex-col md:gap-2 md:px-6 md:pb-4`,children:[e.map((n,r)=>c(n,r===e.length-1&&!t?.length,r===0)),t&&t.length>0&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`flex-1`}),(0,v.jsx)(`div`,{role:`presentation`,"aria-hidden":!0,className:`mx-0 my-2 h-px w-full bg-[var(--border-base)] md:mx-0`}),t.map((e,n)=>c(e,n===t.length-1,!1))]})]})}export{y as n,b as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{m as n}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{f as i}from"./native-biometric-gWkPFBiw.js";import{n as a,r as o}from"./login-flow-CsH-88pb.js";import{t as s}from"./proxy-BzlH_XAe.js";import{t as c}from"./AnimatePresence-C8APSgIu.js";import{St as l}from"./index-CmaRQR9x.js";import{t as u}from"./signup-shell-B1qn4Jpy.js";var d=e(t(),1),f=r();function p({words:e}){let[t,n]=(0,d.useState)(0),r=(0,d.useMemo)(()=>e.reduce((e,t)=>e.length>=t.length?e:t),[e]);return(0,d.useEffect)(()=>{let t=setInterval(()=>{n(t=>(t+1)%e.length)},2400);return()=>clearInterval(t)},[e.length]),(0,f.jsxs)(`span`,{className:`signup__rotating`,children:[(0,f.jsxs)(`span`,{className:`signup__rotating-sizer`,"aria-hidden":!0,children:[r,`.`]}),(0,f.jsx)(c,{mode:`wait`,children:(0,f.jsxs)(s.em,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},transition:{duration:.3,ease:`easeInOut`},children:[e[t],`.`]},e[t])})]})}var m=[`Personal Intelligence`,`Software Engineer`,`Finance Ops`,`Household Manager`,`GTM Engineer`,`Product Lead`];function h({returnTo:e}){let[t,n]=(0,d.useState)(null),r=o(e,{authIntent:`signup`});return(0,f.jsxs)(u,{children:[(0,f.jsxs)(`h1`,{className:`signup__title`,children:[`Meet your new`,(0,f.jsx)(`br`,{}),(0,f.jsx)(p,{words:m})]}),(0,f.jsx)(`p`,{className:`signup__subtitle`,children:`The most powerful assistant that can handle your work and life admin tasks.`}),(0,f.jsx)(`div`,{className:`signup__buttons`,children:(0,f.jsx)(`button`,{type:`button`,className:`signup__btn`,onClick:()=>{n(null),i(a,r,{returnTo:e,intent:`signup`}).catch(e=>{console.error(`[signup] auth flow failed:`,e),n(`Something went wrong. Please try again.`)})},children:`Continue`})}),t&&(0,f.jsx)(`p`,{className:`signup__error`,children:t}),(0,f.jsxs)(`p`,{className:`signup__footer`,children:[`Already have an account?`,` `,(0,f.jsx)(`button`,{type:`button`,className:`signup__link`,onClick:()=>{n(null),i(a,o(e),{returnTo:e}).catch(e=>{console.error(`[signup] sign-in flow failed:`,e),n(`Something went wrong. Please try again.`)})},children:`Sign in`})]}),(0,f.jsxs)(`a`,{className:`signup__download`,href:`/downloads`,children:[(0,f.jsx)(l,{size:16}),`Download for macOS`]})]})}function g(){let[e]=n();return(0,f.jsx)(h,{returnTo:e.get(`returnTo`)})}export{g as SignupPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{m as n}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{f as i}from"./native-biometric-gWkPFBiw.js";import{n as a,r as o}from"./login-flow-CsH-88pb.js";import{t as s}from"./proxy-BzlH_XAe.js";import{t as c}from"./AnimatePresence-C8APSgIu.js";import{St as l}from"./index-CgcZXB4g.js";import{t as u}from"./signup-shell-B1qn4Jpy.js";var d=e(t(),1),f=r();function p({words:e}){let[t,n]=(0,d.useState)(0),r=(0,d.useMemo)(()=>e.reduce((e,t)=>e.length>=t.length?e:t),[e]);return(0,d.useEffect)(()=>{let t=setInterval(()=>{n(t=>(t+1)%e.length)},2400);return()=>clearInterval(t)},[e.length]),(0,f.jsxs)(`span`,{className:`signup__rotating`,children:[(0,f.jsxs)(`span`,{className:`signup__rotating-sizer`,"aria-hidden":!0,children:[r,`.`]}),(0,f.jsx)(c,{mode:`wait`,children:(0,f.jsxs)(s.em,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},transition:{duration:.3,ease:`easeInOut`},children:[e[t],`.`]},e[t])})]})}var m=[`Personal Intelligence`,`Software Engineer`,`Finance Ops`,`Household Manager`,`GTM Engineer`,`Product Lead`];function h({returnTo:e}){let[t,n]=(0,d.useState)(null),r=o(e,{authIntent:`signup`});return(0,f.jsxs)(u,{children:[(0,f.jsxs)(`h1`,{className:`signup__title`,children:[`Meet your new`,(0,f.jsx)(`br`,{}),(0,f.jsx)(p,{words:m})]}),(0,f.jsx)(`p`,{className:`signup__subtitle`,children:`The most powerful assistant that can handle your work and life admin tasks.`}),(0,f.jsx)(`div`,{className:`signup__buttons`,children:(0,f.jsx)(`button`,{type:`button`,className:`signup__btn`,onClick:()=>{n(null),i(a,r,{returnTo:e,intent:`signup`}).catch(e=>{console.error(`[signup] auth flow failed:`,e),n(`Something went wrong. Please try again.`)})},children:`Continue`})}),t&&(0,f.jsx)(`p`,{className:`signup__error`,children:t}),(0,f.jsxs)(`p`,{className:`signup__footer`,children:[`Already have an account?`,` `,(0,f.jsx)(`button`,{type:`button`,className:`signup__link`,onClick:()=>{n(null),i(a,o(e),{returnTo:e}).catch(e=>{console.error(`[signup] sign-in flow failed:`,e),n(`Something went wrong. Please try again.`)})},children:`Sign in`})]}),(0,f.jsxs)(`a`,{className:`signup__download`,href:`/downloads`,children:[(0,f.jsx)(l,{size:16}),`Download for macOS`]})]})}function g(){let[e]=n();return(0,f.jsx)(h,{returnTo:e.get(`returnTo`)})}export{g as SignupPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-BGD3-GQf.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r,z as i}from"./button-BQVYX8n_.js";import{f as a,l as o,n as s,u as c}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./jsx-runtime-CVSDxk6A.js";import{t as f}from"./card-D8zyWtZh.js";import{t as p}from"./createLucideIcon-Bjb-Kuq7.js";import{t as m}from"./arrow-left-C2re-gYj.js";import{a as h,c as g,i as _,n as v,r as y,s as b,t as x}from"./use-skill-actions-B58D56j9.js";import{t as S}from"./chevron-down-DpYf9Gwq.js";import{t as C}from"./menu-DpEE6Pur.js";import{t as w}from"./code-B_ruRFrX.js";import{t as T}from"./external-link-5a-JuPGf.js";import{t as E}from"./eye-Cvo8rdU0.js";import{t as D}from"./file-text-E5adVLLN.js";import{t as O}from"./loader-circle-D57RZgLH.js";import{j as k}from"./src-CDdn26Yb.js";import{n as A,t as j}from"./file-markdown-DZhQRECx.js";import{St as M,bt as N,on as P}from"./react-query.gen-BQH0QRfT.js";import{c as F}from"./routes-XPLb07Av.js";import{Da as I,Ja as L,Ui as R,zr as z}from"./index-CmaRQR9x.js";import{t as B}from"./use-active-assistant-id-9rGx8kT9.js";import{n as V,t as H}from"./use-skill-detail-files-S961Kf-o.js";import{n as U,r as W,t as G}from"./skills-DJft07cl.js";import{t as K}from"./use-edge-swipe-back-CzIG6Agy.js";import{i as q,n as J,r as Y,t as X}from"./file-editor-kHnQQ-I8.js";var ee=p(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),Z=e(n(),1),Q=d();function te({assistantId:e,skill:t,onBack:n,onInstall:i,onRemove:a,isInstalling:o=!1,isRemoving:s=!1,sourceConversationId:c}){let l=h(t),u=U(t),{fileEntries:d,setSelectedPath:p,activePath:_,activeFile:v,isFilesLoading:y,fileContent:x,isBinary:S,isContentLoading:C}=H(e,t.id);return(0,Q.jsxs)(`div`,{className:`flex h-[calc(100vh-14rem)] flex-col`,children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,Q.jsx)(r,{type:`button`,variant:`ghost`,iconOnly:(0,Q.jsx)(m,{"aria-hidden":!0}),"aria-label":`Back to skills`,onClick:n}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,Q.jsx)(g,{skill:t,className:`h-8 w-8 text-3xl`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`h2`,{className:`text-title-medium`,style:{color:`var(--content-default)`},children:t.name}),(0,Q.jsx)(b,{origin:t.origin})]}),(0,Q.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:t.description}),(0,Q.jsx)(V,{skill:{origin:t.origin,sourceConversationId:c},className:`mt-1`})]})]}),l?o?(0,Q.jsx)(`div`,{className:`flex h-9 items-center px-3`,children:(0,Q.jsx)(O,{className:`h-4 w-4 animate-spin`,style:{color:`var(--content-tertiary)`}})}):(0,Q.jsx)(r,{type:`button`,onClick:i,disabled:!i,leftIcon:(0,Q.jsx)(L,{"aria-hidden":!0}),children:`Install`}):(0,Q.jsx)(r,{type:`button`,variant:u?`dangerOutline`:`outlined`,onClick:a,disabled:!u||s||!a,leftIcon:s?(0,Q.jsx)(O,{className:`animate-spin`,"aria-hidden":!0}):(0,Q.jsx)(R,{"aria-hidden":!0}),children:`Remove`})]})]}),(0,Q.jsx)(f.Root,{asChild:!0,noPadding:!0,children:(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden sm:grid`,style:{gridTemplateColumns:`240px 1fr`},children:[(0,Q.jsx)(`div`,{className:`max-h-40 shrink-0 overflow-y-auto border-b p-2 sm:max-h-none sm:border-b-0 sm:border-r`,style:{borderColor:`var(--border-base)`},children:y?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Q.jsx)(O,{className:`h-4 w-4 animate-spin`,style:{color:`var(--content-tertiary)`}})}):d.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-4 text-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`No files available.`}):d.map(e=>{let t=_===e.path,n=(e.mimeType??``).endsWith(`/directory`);return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{color:t?`var(--primary-base)`:`var(--content-default)`,backgroundColor:t?`color-mix(in oklab, var(--primary-base) 10%, transparent)`:void 0},children:[n?(0,Q.jsx)(I,{className:`h-4 w-4 shrink-0`,style:{color:`var(--system-mid-strong)`}}):(0,Q.jsx)(D,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)})}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:C?(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsx)(O,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):v?(0,Q.jsx)(ne,{assistantId:e,skillId:t.id,fileName:v.name,filePath:v.path,content:x,isBinary:S,editable:t.kind===`installed`},`${t.id}/${v.path}`):(0,Q.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view its contents.`})})]})})]})}function ne({assistantId:e,skillId:n,fileName:i,filePath:a,content:o,isBinary:s,editable:u}){let d=c(),f=l(),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``),_=`skills/${n}/${a}`,v=P({onSuccess:()=>{m(!1),g(``),f.invalidateQueries({queryKey:[{_id:`skillsByIdFilesContentGet`}]}),f.invalidateQueries({queryKey:[{_id:`skillsByIdFilesGet`}]}),a===`SKILL.md`&&G(f,e)},onError:e=>{t(e,{context:`skill-file-save`,bestEffort:!0})}}),y=p&&h!==(o??``),b=(0,Z.useCallback)(()=>{!y||v.isPending||v.mutate({path:{assistant_id:e},body:{path:_,content:h,encoding:`utf8`}})},[y,v,e,_,h]),x=(0,Z.useCallback)(()=>{m(!0),g(o??``),v.reset()},[o,v]),S=(0,Z.useCallback)(()=>{m(!1),g(``),v.reset()},[v]);if(s)return(0,Q.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Binary file — no preview available.`});if(o===null)return(0,Q.jsxs)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[`No preview available for `,i,`.`]});let C=u?(0,Q.jsx)(r,{variant:`ghost`,size:`regular`,iconOnly:(0,Q.jsx)(T,{"aria-hidden":!0}),onClick:()=>d(`${F.workspace}?file=${encodeURIComponent(_)}`),"aria-label":`Open in Workspace`,className:`hover:bg-[var(--surface-base)]`}):void 0;return A(i,void 0)&&!p?(0,Q.jsx)(`div`,{className:`relative flex h-full flex-col`,children:(0,Q.jsxs)(`div`,{className:`relative flex-1 overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:[(0,Q.jsx)(X,{content:o,fileName:i,showEdit:u,isEditing:!1,onToggleEdit:x,extraActions:C}),(0,Q.jsx)(j,{content:o})]})}):(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Q.jsx)(X,{content:p?h:o,fileName:i,showEdit:u,isEditing:p,onToggleEdit:()=>p?S():x(),extraActions:C}),p?(0,Q.jsx)(Y,{value:h,onChange:g,onSave:b}):(0,Q.jsx)(q,{content:o,readOnly:!u,onStartEdit:x})]}),p&&(0,Q.jsx)(J,{isDirty:y,isSaving:v.isPending,error:v.isError?`Save failed`:null,onSave:b,onDiscard:S})]})}var re=e(i(),1);function ie({fileName:e,content:t,isBinary:n,viewMode:r=`preview`}){return n?(0,Q.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Binary file — no preview available.`}):t===null?(0,Q.jsxs)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[`No preview available for `,e,`.`]}):A(e,void 0)&&r===`preview`?(0,Q.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:(0,Q.jsx)(j,{content:t})}):(0,Q.jsx)(`pre`,{className:`h-full overflow-y-auto whitespace-pre-wrap break-words p-4 font-mono text-body-small-default`,style:{color:`var(--content-default)`},children:t})}function ae({assistantId:e,skill:t,onBack:n,onInstall:i,onRemove:a,isInstalling:o=!1,isRemoving:s=!1,swipeContainerRef:c,sourceConversationId:l}){let u=h(t),d=U(t),{fileEntries:p,setSelectedPath:_,activePath:v,activeFile:y,isFilesLoading:x,fileContent:S,isBinary:C,isContentLoading:T}=H(e,t.id),[D,j]=(0,Z.useState)(`preview`);(0,Z.useEffect)(()=>{j(`preview`)},[v]);let[M,N]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{N(document.getElementById(`viewport-overlays`))},[]);let P=y?A(y.name,void 0):!1,F=P?D:`raw`,I=(0,Q.jsxs)(`div`,{ref:c,className:`fixed inset-0 z-40 flex flex-col overflow-hidden bg-[var(--surface-overlay)]`,style:{paddingTop:`calc(8px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,paddingBottom:`calc(8px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))`,paddingLeft:`calc(12px + var(--safe-area-inset-left, env(safe-area-inset-left, 0px)))`,paddingRight:`calc(12px + var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(r,{variant:`ghost`,iconOnly:(0,Q.jsx)(m,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Back to skills`,onClick:n,className:`max-md:bg-[var(--surface-active)]`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate px-2 text-center text-body-medium-default`,style:{color:`var(--content-secondary)`},children:t.name}),(0,Q.jsx)(oe,{available:u,removable:d,isInstalling:o,isRemoving:s,onInstall:i,onRemove:a})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(g,{skill:t,className:`h-6 w-6 shrink-0 text-[22px] leading-none`}),(0,Q.jsx)(`h2`,{className:`min-w-0 truncate text-title-medium`,style:{color:`var(--content-emphasised)`},children:t.name})]}),(0,Q.jsx)(b,{origin:t.origin})]}),(0,Q.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:t.description}),(0,Q.jsx)(V,{skill:{origin:t.origin,sourceConversationId:l}})]}),(0,Q.jsx)(f.Root,{asChild:!0,noPadding:!0,children:(0,Q.jsxs)(`div`,{className:`mt-6 flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border bg-[var(--surface-lift)]`,style:{borderColor:`var(--border-hover)`},children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-3 py-2`,style:{borderColor:`var(--border-hover)`},children:[(0,Q.jsx)(ce,{fileEntries:p,activePath:v,activeName:y?.name??null,onSelect:_}),(0,Q.jsx)(k,{iconOnly:!0,ariaLabel:`File view mode`,value:F,onChange:j,items:[{value:`preview`,label:`Preview`,icon:(0,Q.jsx)(E,{"aria-hidden":!0}),disabled:!P},{value:`raw`,label:`Source`,icon:(0,Q.jsx)(w,{"aria-hidden":!0})}]})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:x||T?(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsx)(O,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):y?(0,Q.jsx)(ie,{fileName:y.name,content:S,isBinary:C,viewMode:F}):(0,Q.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view its contents.`})})]})})]});return M?(0,re.createPortal)(I,M):I}function oe({available:e,removable:t,isInstalling:n,isRemoving:i,onInstall:a,onRemove:o}){return n||i?(0,Q.jsx)(r,{variant:`ghost`,iconOnly:(0,Q.jsx)(O,{className:`animate-spin`,"aria-hidden":!0}),expandOnMobile:!0,disabled:!0,"aria-label":`Pending`,className:`max-md:bg-[var(--surface-active)]`}):e?(0,Q.jsx)(r,{variant:`ghost`,iconOnly:(0,Q.jsx)(L,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Install skill`,onClick:a,disabled:!a,className:`max-md:bg-[var(--surface-active)]`}):t?(0,Q.jsx)(r,{variant:`dangerGhost`,iconOnly:(0,Q.jsx)(R,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Remove skill`,onClick:o,disabled:!o,className:`max-md:rounded-full max-md:bg-[var(--system-negative-weak)]`}):(0,Q.jsx)(r,{variant:`dangerGhost`,iconOnly:(0,Q.jsx)(R,{"aria-hidden":!0}),expandOnMobile:!0,disabled:!0,title:`Bundled skills cannot be removed`,"aria-label":`Bundled skill cannot be removed`,className:`max-md:rounded-full max-md:bg-[var(--system-negative-weak)]`})}function se(e){return(e??``).endsWith(`/directory`)}function ce({fileEntries:e,activePath:t,activeName:n,onSelect:r}){let i=n??`Select a file`;return e.length===0?(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-body-medium-default`,style:{color:`var(--content-emphasised)`},children:[(0,Q.jsx)($,{}),(0,Q.jsx)(`span`,{className:`truncate`,children:i})]}):(0,Q.jsxs)(C.Root,{children:[(0,Q.jsx)(C.Trigger,{children:(0,Q.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-2 rounded-md text-body-medium-default`,style:{color:`var(--content-emphasised)`},children:[(0,Q.jsx)($,{}),(0,Q.jsx)(`span`,{className:`truncate`,children:i}),(0,Q.jsx)(S,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`},"aria-hidden":!0})]})}),(0,Q.jsx)(C.Content,{align:`start`,children:e.map(e=>{let n=se(e.mimeType);return(0,Q.jsx)(C.Item,{onSelect:()=>r(e.path),leftIcon:n?(0,Q.jsx)(I,{}):(0,Q.jsx)(D,{}),"aria-current":e.path===t?`true`:void 0,children:e.name},e.path)})})]})}function $(){return(0,Q.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[var(--surface-base)]`,"aria-hidden":!0,children:(0,Q.jsx)(D,{className:`h-4 w-4`,style:{color:`var(--content-secondary)`}})})}function le(){let e=B(),{skillId:t}=a(),n=c(),i=o(),{pathname:l}=i,d=z(),f=(0,Z.useRef)(null),p=i.state,h=typeof p?.listSearch==`string`?p.listSearch:``,g=u({...M({path:{assistant_id:e},query:{include:`catalog`}}),select:e=>e.skills,refetchOnMount:`always`}),b=(0,Z.useCallback)(()=>{n(`${F.skills.root}${h}`,{replace:!0})},[n,h]);K({containerRef:f,onBack:b,enabled:d,navKey:l});let{handleInstall:S,handleRemove:C,isInstallingSkill:w,isRemovingSkill:T,skillPendingRemoval:E,confirmRemove:D,cancelRemove:O}=x(e,{onRemoved:b}),k=g.data,A=(0,Z.useMemo)(()=>k?.find(e=>e.id===t)??null,[k,t]),j=u({...N({path:{assistant_id:e,id:t??``}}),enabled:!!t&&A?.origin===`assistant-memory`,select:e=>e.skill.origin===`assistant-memory`?e.skill.sourceConversationId??null:null});if(!t)return(0,Q.jsx)(s,{to:F.skills.root,replace:!0});if(g.isLoading)return(0,Q.jsx)(v,{});if(g.isError&&!A)return(0,Q.jsx)(y,{});if(!A&&g.isFetching)return(0,Q.jsx)(v,{});if(!A)return(0,Q.jsx)(_,{icon:ee,title:`Skill not found`,subtitle:`This skill may have been removed, or the link is out of date.`,children:(0,Q.jsx)(r,{type:`button`,variant:`outlined`,className:`mt-4`,leftIcon:(0,Q.jsx)(m,{"aria-hidden":!0}),onClick:b,children:`Back to skills`})});let P={assistantId:e,skill:A,onBack:b,onInstall:()=>S(A),onRemove:()=>C(A),isInstalling:w(A),isRemoving:T(A),sourceConversationId:j.data??void 0};return(0,Q.jsxs)(Q.Fragment,{children:[d?(0,Q.jsx)(ae,{...P,swipeContainerRef:f}):(0,Q.jsx)(te,{...P}),(0,Q.jsx)(W,{skillName:E?.name??null,onConfirm:D,onCancel:O})]})}export{le as SkillDetailPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-BGD3-GQf.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r,z as i}from"./button-BQVYX8n_.js";import{f as a,l as o,n as s,u as c}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./jsx-runtime-CVSDxk6A.js";import{t as f}from"./card-D8zyWtZh.js";import{t as p}from"./createLucideIcon-Bjb-Kuq7.js";import{t as m}from"./arrow-left-C2re-gYj.js";import{a as h,c as g,i as _,n as v,r as y,s as b,t as x}from"./use-skill-actions-fDejA0nc.js";import{t as S}from"./chevron-down-DpYf9Gwq.js";import{t as C}from"./menu-DpEE6Pur.js";import{t as w}from"./code-B_ruRFrX.js";import{t as T}from"./external-link-5a-JuPGf.js";import{t as E}from"./eye-Cvo8rdU0.js";import{t as D}from"./file-text-E5adVLLN.js";import{t as O}from"./loader-circle-D57RZgLH.js";import{j as k}from"./src-CDdn26Yb.js";import{n as A,t as j}from"./file-markdown-DZhQRECx.js";import{St as M,bt as N,on as P}from"./react-query.gen-BQH0QRfT.js";import{c as F}from"./routes-XPLb07Av.js";import{Da as I,Ja as L,Ui as R,zr as z}from"./index-CgcZXB4g.js";import{t as B}from"./use-active-assistant-id-9rGx8kT9.js";import{n as V,t as H}from"./use-skill-detail-files-DS6fk9Xz.js";import{n as U,r as W,t as G}from"./skills-DJft07cl.js";import{t as K}from"./use-edge-swipe-back-Dpo-0Weh.js";import{i as q,n as J,r as Y,t as X}from"./file-editor-kHnQQ-I8.js";var ee=p(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),Z=e(n(),1),Q=d();function te({assistantId:e,skill:t,onBack:n,onInstall:i,onRemove:a,isInstalling:o=!1,isRemoving:s=!1,sourceConversationId:c}){let l=h(t),u=U(t),{fileEntries:d,setSelectedPath:p,activePath:_,activeFile:v,isFilesLoading:y,fileContent:x,isBinary:S,isContentLoading:C}=H(e,t.id);return(0,Q.jsxs)(`div`,{className:`flex h-[calc(100vh-14rem)] flex-col`,children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,Q.jsx)(r,{type:`button`,variant:`ghost`,iconOnly:(0,Q.jsx)(m,{"aria-hidden":!0}),"aria-label":`Back to skills`,onClick:n}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,Q.jsx)(g,{skill:t,className:`h-8 w-8 text-3xl`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`h2`,{className:`text-title-medium`,style:{color:`var(--content-default)`},children:t.name}),(0,Q.jsx)(b,{origin:t.origin})]}),(0,Q.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:t.description}),(0,Q.jsx)(V,{skill:{origin:t.origin,sourceConversationId:c},className:`mt-1`})]})]}),l?o?(0,Q.jsx)(`div`,{className:`flex h-9 items-center px-3`,children:(0,Q.jsx)(O,{className:`h-4 w-4 animate-spin`,style:{color:`var(--content-tertiary)`}})}):(0,Q.jsx)(r,{type:`button`,onClick:i,disabled:!i,leftIcon:(0,Q.jsx)(L,{"aria-hidden":!0}),children:`Install`}):(0,Q.jsx)(r,{type:`button`,variant:u?`dangerOutline`:`outlined`,onClick:a,disabled:!u||s||!a,leftIcon:s?(0,Q.jsx)(O,{className:`animate-spin`,"aria-hidden":!0}):(0,Q.jsx)(R,{"aria-hidden":!0}),children:`Remove`})]})]}),(0,Q.jsx)(f.Root,{asChild:!0,noPadding:!0,children:(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden sm:grid`,style:{gridTemplateColumns:`240px 1fr`},children:[(0,Q.jsx)(`div`,{className:`max-h-40 shrink-0 overflow-y-auto border-b p-2 sm:max-h-none sm:border-b-0 sm:border-r`,style:{borderColor:`var(--border-base)`},children:y?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Q.jsx)(O,{className:`h-4 w-4 animate-spin`,style:{color:`var(--content-tertiary)`}})}):d.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-4 text-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`No files available.`}):d.map(e=>{let t=_===e.path,n=(e.mimeType??``).endsWith(`/directory`);return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>p(e.path),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{color:t?`var(--primary-base)`:`var(--content-default)`,backgroundColor:t?`color-mix(in oklab, var(--primary-base) 10%, transparent)`:void 0},children:[n?(0,Q.jsx)(I,{className:`h-4 w-4 shrink-0`,style:{color:`var(--system-mid-strong)`}}):(0,Q.jsx)(D,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)})}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:C?(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsx)(O,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):v?(0,Q.jsx)(ne,{assistantId:e,skillId:t.id,fileName:v.name,filePath:v.path,content:x,isBinary:S,editable:t.kind===`installed`},`${t.id}/${v.path}`):(0,Q.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view its contents.`})})]})})]})}function ne({assistantId:e,skillId:n,fileName:i,filePath:a,content:o,isBinary:s,editable:u}){let d=c(),f=l(),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``),_=`skills/${n}/${a}`,v=P({onSuccess:()=>{m(!1),g(``),f.invalidateQueries({queryKey:[{_id:`skillsByIdFilesContentGet`}]}),f.invalidateQueries({queryKey:[{_id:`skillsByIdFilesGet`}]}),a===`SKILL.md`&&G(f,e)},onError:e=>{t(e,{context:`skill-file-save`,bestEffort:!0})}}),y=p&&h!==(o??``),b=(0,Z.useCallback)(()=>{!y||v.isPending||v.mutate({path:{assistant_id:e},body:{path:_,content:h,encoding:`utf8`}})},[y,v,e,_,h]),x=(0,Z.useCallback)(()=>{m(!0),g(o??``),v.reset()},[o,v]),S=(0,Z.useCallback)(()=>{m(!1),g(``),v.reset()},[v]);if(s)return(0,Q.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Binary file — no preview available.`});if(o===null)return(0,Q.jsxs)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[`No preview available for `,i,`.`]});let C=u?(0,Q.jsx)(r,{variant:`ghost`,size:`regular`,iconOnly:(0,Q.jsx)(T,{"aria-hidden":!0}),onClick:()=>d(`${F.workspace}?file=${encodeURIComponent(_)}`),"aria-label":`Open in Workspace`,className:`hover:bg-[var(--surface-base)]`}):void 0;return A(i,void 0)&&!p?(0,Q.jsx)(`div`,{className:`relative flex h-full flex-col`,children:(0,Q.jsxs)(`div`,{className:`relative flex-1 overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:[(0,Q.jsx)(X,{content:o,fileName:i,showEdit:u,isEditing:!1,onToggleEdit:x,extraActions:C}),(0,Q.jsx)(j,{content:o})]})}):(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Q.jsx)(X,{content:p?h:o,fileName:i,showEdit:u,isEditing:p,onToggleEdit:()=>p?S():x(),extraActions:C}),p?(0,Q.jsx)(Y,{value:h,onChange:g,onSave:b}):(0,Q.jsx)(q,{content:o,readOnly:!u,onStartEdit:x})]}),p&&(0,Q.jsx)(J,{isDirty:y,isSaving:v.isPending,error:v.isError?`Save failed`:null,onSave:b,onDiscard:S})]})}var re=e(i(),1);function ie({fileName:e,content:t,isBinary:n,viewMode:r=`preview`}){return n?(0,Q.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Binary file — no preview available.`}):t===null?(0,Q.jsxs)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[`No preview available for `,e,`.`]}):A(e,void 0)&&r===`preview`?(0,Q.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:(0,Q.jsx)(j,{content:t})}):(0,Q.jsx)(`pre`,{className:`h-full overflow-y-auto whitespace-pre-wrap break-words p-4 font-mono text-body-small-default`,style:{color:`var(--content-default)`},children:t})}function ae({assistantId:e,skill:t,onBack:n,onInstall:i,onRemove:a,isInstalling:o=!1,isRemoving:s=!1,swipeContainerRef:c,sourceConversationId:l}){let u=h(t),d=U(t),{fileEntries:p,setSelectedPath:_,activePath:v,activeFile:y,isFilesLoading:x,fileContent:S,isBinary:C,isContentLoading:T}=H(e,t.id),[D,j]=(0,Z.useState)(`preview`);(0,Z.useEffect)(()=>{j(`preview`)},[v]);let[M,N]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{N(document.getElementById(`viewport-overlays`))},[]);let P=y?A(y.name,void 0):!1,F=P?D:`raw`,I=(0,Q.jsxs)(`div`,{ref:c,className:`fixed inset-0 z-40 flex flex-col overflow-hidden bg-[var(--surface-overlay)]`,style:{paddingTop:`calc(8px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,paddingBottom:`calc(8px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))`,paddingLeft:`calc(12px + var(--safe-area-inset-left, env(safe-area-inset-left, 0px)))`,paddingRight:`calc(12px + var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(r,{variant:`ghost`,iconOnly:(0,Q.jsx)(m,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Back to skills`,onClick:n,className:`max-md:bg-[var(--surface-active)]`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate px-2 text-center text-body-medium-default`,style:{color:`var(--content-secondary)`},children:t.name}),(0,Q.jsx)(oe,{available:u,removable:d,isInstalling:o,isRemoving:s,onInstall:i,onRemove:a})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(g,{skill:t,className:`h-6 w-6 shrink-0 text-[22px] leading-none`}),(0,Q.jsx)(`h2`,{className:`min-w-0 truncate text-title-medium`,style:{color:`var(--content-emphasised)`},children:t.name})]}),(0,Q.jsx)(b,{origin:t.origin})]}),(0,Q.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:t.description}),(0,Q.jsx)(V,{skill:{origin:t.origin,sourceConversationId:l}})]}),(0,Q.jsx)(f.Root,{asChild:!0,noPadding:!0,children:(0,Q.jsxs)(`div`,{className:`mt-6 flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border bg-[var(--surface-lift)]`,style:{borderColor:`var(--border-hover)`},children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-3 py-2`,style:{borderColor:`var(--border-hover)`},children:[(0,Q.jsx)(ce,{fileEntries:p,activePath:v,activeName:y?.name??null,onSelect:_}),(0,Q.jsx)(k,{iconOnly:!0,ariaLabel:`File view mode`,value:F,onChange:j,items:[{value:`preview`,label:`Preview`,icon:(0,Q.jsx)(E,{"aria-hidden":!0}),disabled:!P},{value:`raw`,label:`Source`,icon:(0,Q.jsx)(w,{"aria-hidden":!0})}]})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:x||T?(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsx)(O,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):y?(0,Q.jsx)(ie,{fileName:y.name,content:S,isBinary:C,viewMode:F}):(0,Q.jsx)(`p`,{className:`flex h-full items-center justify-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view its contents.`})})]})})]});return M?(0,re.createPortal)(I,M):I}function oe({available:e,removable:t,isInstalling:n,isRemoving:i,onInstall:a,onRemove:o}){return n||i?(0,Q.jsx)(r,{variant:`ghost`,iconOnly:(0,Q.jsx)(O,{className:`animate-spin`,"aria-hidden":!0}),expandOnMobile:!0,disabled:!0,"aria-label":`Pending`,className:`max-md:bg-[var(--surface-active)]`}):e?(0,Q.jsx)(r,{variant:`ghost`,iconOnly:(0,Q.jsx)(L,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Install skill`,onClick:a,disabled:!a,className:`max-md:bg-[var(--surface-active)]`}):t?(0,Q.jsx)(r,{variant:`dangerGhost`,iconOnly:(0,Q.jsx)(R,{"aria-hidden":!0}),expandOnMobile:!0,"aria-label":`Remove skill`,onClick:o,disabled:!o,className:`max-md:rounded-full max-md:bg-[var(--system-negative-weak)]`}):(0,Q.jsx)(r,{variant:`dangerGhost`,iconOnly:(0,Q.jsx)(R,{"aria-hidden":!0}),expandOnMobile:!0,disabled:!0,title:`Bundled skills cannot be removed`,"aria-label":`Bundled skill cannot be removed`,className:`max-md:rounded-full max-md:bg-[var(--system-negative-weak)]`})}function se(e){return(e??``).endsWith(`/directory`)}function ce({fileEntries:e,activePath:t,activeName:n,onSelect:r}){let i=n??`Select a file`;return e.length===0?(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-body-medium-default`,style:{color:`var(--content-emphasised)`},children:[(0,Q.jsx)($,{}),(0,Q.jsx)(`span`,{className:`truncate`,children:i})]}):(0,Q.jsxs)(C.Root,{children:[(0,Q.jsx)(C.Trigger,{children:(0,Q.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-2 rounded-md text-body-medium-default`,style:{color:`var(--content-emphasised)`},children:[(0,Q.jsx)($,{}),(0,Q.jsx)(`span`,{className:`truncate`,children:i}),(0,Q.jsx)(S,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`},"aria-hidden":!0})]})}),(0,Q.jsx)(C.Content,{align:`start`,children:e.map(e=>{let n=se(e.mimeType);return(0,Q.jsx)(C.Item,{onSelect:()=>r(e.path),leftIcon:n?(0,Q.jsx)(I,{}):(0,Q.jsx)(D,{}),"aria-current":e.path===t?`true`:void 0,children:e.name},e.path)})})]})}function $(){return(0,Q.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[var(--surface-base)]`,"aria-hidden":!0,children:(0,Q.jsx)(D,{className:`h-4 w-4`,style:{color:`var(--content-secondary)`}})})}function le(){let e=B(),{skillId:t}=a(),n=c(),i=o(),{pathname:l}=i,d=z(),f=(0,Z.useRef)(null),p=i.state,h=typeof p?.listSearch==`string`?p.listSearch:``,g=u({...M({path:{assistant_id:e},query:{include:`catalog`}}),select:e=>e.skills,refetchOnMount:`always`}),b=(0,Z.useCallback)(()=>{n(`${F.skills.root}${h}`,{replace:!0})},[n,h]);K({containerRef:f,onBack:b,enabled:d,navKey:l});let{handleInstall:S,handleRemove:C,isInstallingSkill:w,isRemovingSkill:T,skillPendingRemoval:E,confirmRemove:D,cancelRemove:O}=x(e,{onRemoved:b}),k=g.data,A=(0,Z.useMemo)(()=>k?.find(e=>e.id===t)??null,[k,t]),j=u({...N({path:{assistant_id:e,id:t??``}}),enabled:!!t&&A?.origin===`assistant-memory`,select:e=>e.skill.origin===`assistant-memory`?e.skill.sourceConversationId??null:null});if(!t)return(0,Q.jsx)(s,{to:F.skills.root,replace:!0});if(g.isLoading)return(0,Q.jsx)(v,{});if(g.isError&&!A)return(0,Q.jsx)(y,{});if(!A&&g.isFetching)return(0,Q.jsx)(v,{});if(!A)return(0,Q.jsx)(_,{icon:ee,title:`Skill not found`,subtitle:`This skill may have been removed, or the link is out of date.`,children:(0,Q.jsx)(r,{type:`button`,variant:`outlined`,className:`mt-4`,leftIcon:(0,Q.jsx)(m,{"aria-hidden":!0}),onClick:b,children:`Back to skills`})});let P={assistantId:e,skill:A,onBack:b,onInstall:()=>S(A),onRemove:()=>C(A),isInstalling:w(A),isRemoving:T(A),sourceConversationId:j.data??void 0};return(0,Q.jsxs)(Q.Fragment,{children:[d?(0,Q.jsx)(ae,{...P,swipeContainerRef:f}):(0,Q.jsx)(te,{...P}),(0,Q.jsx)(W,{skillName:E?.name??null,onConfirm:D,onCancel:O})]})}export{le as SkillDetailPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-BGD3-GQf.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-BQVYX8n_.js";import{u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as a}from"./QueryClientProvider-DKhXIxGb.js";import{t as o}from"./useQuery-B45lW1Kk.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./typography-Cqi8q9o7.js";import{t as l}from"./brain-CMiHVWFK.js";import{t as u}from"./menu-DpEE6Pur.js";import{t as d}from"./loader-circle-D57RZgLH.js";import"./src-CDdn26Yb.js";import{t as f}from"./file-markdown-DZhQRECx.js";import{n as p}from"./resolved-assistants-store-DdnJoLGS.js";import{an as m,bt as h}from"./react-query.gen-BQH0QRfT.js";import{c as g}from"./routes-XPLb07Av.js";import{Aa as _,E as v,Ui as y}from"./index-CmaRQR9x.js";import{n as b,t as x}from"./use-skill-detail-files-S961Kf-o.js";import{n as S,r as C,t as w}from"./skills-DJft07cl.js";var T=e(n(),1),E=s();function D({skillId:e,onClose:n}){let s=i(),D=a(),O=p.use.activeAssistantId(),[k,A]=(0,T.useState)(!1),j=o({...h({path:{assistant_id:O??``,id:e}}),select:e=>e.skill,enabled:!!O}),M=j.data,{skillMd:N,fileContent:P,isFilesPending:F,isContentPending:I}=x(O,e),L=m({onSuccess:()=>{O&&w(D,O),n()},onError:e=>{t(e,{context:`skill-detail-panel-remove`})}}),R=()=>{O&&(L.mutate({path:{assistant_id:O,id:e}}),A(!1))},z=j.isPending||F||N!=null&&I,B=M!=null&&S(M);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v,{icon:M?.emoji?(0,E.jsx)(`span`,{className:`text-xl leading-none`,"aria-hidden":!0,children:M.emoji}):void 0,Glyph:l,title:M?.name??`Skill`,closeLabel:`Close skill details`,onClose:n,headerActions:B?(0,E.jsxs)(u.Root,{children:[(0,E.jsx)(u.Trigger,{asChild:!0,children:(0,E.jsx)(r,{variant:`ghost`,iconOnly:(0,E.jsx)(_,{}),"aria-label":`Skill actions`,className:`shrink-0`})}),(0,E.jsx)(u.Content,{side:`bottom`,align:`end`,children:(0,E.jsx)(u.Item,{leftIcon:(0,E.jsx)(y,{size:14}),onSelect:()=>A(!0),children:`Remove skill`})})]}):void 0,footer:(0,E.jsx)(r,{fullWidth:!0,onClick:()=>s(g.skills.detail(e)),children:`Go to Skill`}),children:j.isError&&!M?(0,E.jsx)(c,{variant:`body-medium-lighter`,as:`p`,className:`py-8 text-center text-[var(--content-tertiary)]`,children:`This skill could not be loaded. It may have been removed.`}):z?(0,E.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,E.jsx)(d,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,E.jsxs)(E.Fragment,{children:[M?.description&&(0,E.jsx)(c,{variant:`body-medium-lighter`,as:`p`,className:`mb-4 text-[var(--content-secondary)]`,children:M.description}),M&&(0,E.jsx)(b,{skill:M,className:`mb-4`,onNavigate:n}),P&&(0,E.jsx)(f,{content:P})]})}),(0,E.jsx)(C,{skillName:k&&M?M.name:null,onConfirm:R,onCancel:()=>A(!1)})]})}export{D as SkillDetailPanel};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-BGD3-GQf.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-BQVYX8n_.js";import{u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as a}from"./QueryClientProvider-DKhXIxGb.js";import{t as o}from"./useQuery-B45lW1Kk.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./typography-Cqi8q9o7.js";import{t as l}from"./brain-CMiHVWFK.js";import{t as u}from"./menu-DpEE6Pur.js";import{t as d}from"./loader-circle-D57RZgLH.js";import"./src-CDdn26Yb.js";import{t as f}from"./file-markdown-DZhQRECx.js";import{n as p}from"./resolved-assistants-store-DdnJoLGS.js";import{an as m,bt as h}from"./react-query.gen-BQH0QRfT.js";import{c as g}from"./routes-XPLb07Av.js";import{Aa as _,E as v,Ui as y}from"./index-CgcZXB4g.js";import{n as b,t as x}from"./use-skill-detail-files-DS6fk9Xz.js";import{n as S,r as C,t as w}from"./skills-DJft07cl.js";var T=e(n(),1),E=s();function D({skillId:e,onClose:n}){let s=i(),D=a(),O=p.use.activeAssistantId(),[k,A]=(0,T.useState)(!1),j=o({...h({path:{assistant_id:O??``,id:e}}),select:e=>e.skill,enabled:!!O}),M=j.data,{skillMd:N,fileContent:P,isFilesPending:F,isContentPending:I}=x(O,e),L=m({onSuccess:()=>{O&&w(D,O),n()},onError:e=>{t(e,{context:`skill-detail-panel-remove`})}}),R=()=>{O&&(L.mutate({path:{assistant_id:O,id:e}}),A(!1))},z=j.isPending||F||N!=null&&I,B=M!=null&&S(M);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v,{icon:M?.emoji?(0,E.jsx)(`span`,{className:`text-xl leading-none`,"aria-hidden":!0,children:M.emoji}):void 0,Glyph:l,title:M?.name??`Skill`,closeLabel:`Close skill details`,onClose:n,headerActions:B?(0,E.jsxs)(u.Root,{children:[(0,E.jsx)(u.Trigger,{asChild:!0,children:(0,E.jsx)(r,{variant:`ghost`,iconOnly:(0,E.jsx)(_,{}),"aria-label":`Skill actions`,className:`shrink-0`})}),(0,E.jsx)(u.Content,{side:`bottom`,align:`end`,children:(0,E.jsx)(u.Item,{leftIcon:(0,E.jsx)(y,{size:14}),onSelect:()=>A(!0),children:`Remove skill`})})]}):void 0,footer:(0,E.jsx)(r,{fullWidth:!0,onClick:()=>s(g.skills.detail(e)),children:`Go to Skill`}),children:j.isError&&!M?(0,E.jsx)(c,{variant:`body-medium-lighter`,as:`p`,className:`py-8 text-center text-[var(--content-tertiary)]`,children:`This skill could not be loaded. It may have been removed.`}):z?(0,E.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,E.jsx)(d,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,E.jsxs)(E.Fragment,{children:[M?.description&&(0,E.jsx)(c,{variant:`body-medium-lighter`,as:`p`,className:`mb-4 text-[var(--content-secondary)]`,children:M.description}),M&&(0,E.jsx)(b,{skill:M,className:`mb-4`,onNavigate:n}),P&&(0,E.jsx)(f,{content:P})]})}),(0,E.jsx)(C,{skillName:k&&M?M.name:null,onConfirm:R,onCancel:()=>A(!1)})]})}export{D as SkillDetailPanel};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./local-settings-C-dW2vkq.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-BQVYX8n_.js";import{l as a,m as o,n as s,u as c}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as l}from"./useQuery-B45lW1Kk.js";import{t as u}from"./jsx-runtime-CVSDxk6A.js";import{t as d}from"./card-D8zyWtZh.js";import{a as f,c as p,i as m,l as h,n as ee,o as g,r as te,s as _,t as ne}from"./use-skill-actions-B58D56j9.js";import{t as v}from"./brain-CMiHVWFK.js";import{t as y}from"./check-wF3S-AV4.js";import{t as b}from"./cloud-off-DT0KnUQ4.js";import{i as x,n as re,r as S,t as ie}from"./use-skill-categories-BewT8dcB.js";import{t as C}from"./globe-Dx8dM0gj.js";import{t as w}from"./loader-circle-D57RZgLH.js";import{t as T}from"./sparkles-DDIsk_nZ.js";import{t as E}from"./x-CswtfvgS.js";import"./src-CDdn26Yb.js";import{t as D}from"./popover-Bl6742nZ.js";import{t as O}from"./input-ZpyYt_a0.js";import{n as k,t as A}from"./panel-item-Bvqsr5n9.js";import{St as j}from"./react-query.gen-BQH0QRfT.js";import{c as M}from"./routes-XPLb07Av.js";import{Fi as N,Ha as P,Ja as F,Ui as I,Vi as L,Wi as R,ea as z,la as B,xa as V,zr as H}from"./index-CmaRQR9x.js";import{t as U}from"./use-active-assistant-id-9rGx8kT9.js";import{n as ae,r as oe}from"./skills-DJft07cl.js";var W=e(r(),1),G=u(),K=[{value:`all`,label:`All`,icon:V},{value:`installed`,label:`Installed`,icon:P},{value:`available`,label:`Available`,icon:F}],q=[{value:`vellum`,label:`Vellum`,icon:h},{value:`clawhub`,label:`Clawhub`,icon:C},{value:`skillssh`,label:`skills.sh`,icon:R},{value:`custom`,label:`Custom`,icon:L},{value:`assistant-memory`,label:`Assistant's Memory`,icon:v}];function se({search:e,onSearchChange:t,filter:n,onFilterChange:r,isSearching:i,categories:a,category:o,onCategoryChange:s,counts:c,totalCount:l,showCounts:u}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(O,{type:`search`,value:e,onChange:e=>{t(e.target.value)},placeholder:`Search skills`,"aria-label":`Search skills`,leftIcon:(0,G.jsx)(z,{className:`h-4 w-4`,"aria-hidden":!0}),rightIcon:i?(0,G.jsx)(w,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):void 0,fullWidth:!0,wrapperClassName:`flex-1`}),(0,G.jsx)(ce,{filter:n,onFilterChange:r,categories:a,category:o,onCategoryChange:s,counts:c,totalCount:l,showCounts:u})]})}function ce(e){let t=H(),[n,r]=(0,W.useState)(!1),a=(0,G.jsx)(i,{type:`button`,variant:`outlined`,iconOnly:(0,G.jsx)(x,{"aria-hidden":!0}),"aria-label":`Filter skills`,"aria-haspopup":t?`dialog`:`listbox`,"aria-expanded":n,tintColor:`var(--primary-base)`});return t?(0,G.jsx)(le,{...e,open:n,onOpenChange:r,trigger:a}):(0,G.jsxs)(D.Root,{open:n,onOpenChange:r,children:[(0,G.jsx)(D.Trigger,{asChild:!0,children:a}),(0,G.jsx)(D.Content,{align:`end`,sideOffset:4,className:`w-44 overflow-hidden p-0`,children:(0,G.jsxs)(`ul`,{role:`listbox`,children:[(0,G.jsx)(X,{label:`Status`,options:K,selected:e.filter,onSelect:t=>{e.onFilterChange(t),r(!1)}}),(0,G.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),(0,G.jsx)(X,{label:`Source`,options:q,selected:e.filter,onSelect:t=>{e.onFilterChange(t),r(!1)}})]})})]})}function le({filter:e,onFilterChange:t,categories:n,category:r,onCategoryChange:a,counts:o,totalCount:s,showCounts:c,open:l,onOpenChange:u,trigger:d}){let f=[...n].sort((e,t)=>e.label.localeCompare(t.label));return(0,G.jsxs)(k.Root,{open:l,onOpenChange:u,children:[(0,G.jsx)(k.Trigger,{asChild:!0,children:d}),(0,G.jsxs)(k.Content,{className:`max-h-[85dvh]`,"aria-describedby":void 0,children:[(0,G.jsx)(`div`,{"aria-hidden":!0,className:`mx-auto mb-3 h-1 w-9 shrink-0 rounded-full bg-[var(--border-element)]`}),(0,G.jsx)(k.Header,{children:(0,G.jsx)(k.Title,{children:`Filters`})}),(0,G.jsxs)(k.Body,{className:`flex flex-col gap-3 pt-2`,children:[(0,G.jsx)(J,{label:`Status`,children:K.map(n=>(0,G.jsx)(Y,{icon:n.icon,label:n.label,active:e===n.value,onSelect:()=>t(n.value)},n.value))}),(0,G.jsx)(J,{label:`Source`,children:q.map(n=>(0,G.jsx)(Y,{icon:n.icon,label:n.label,active:e===n.value,onSelect:()=>t(n.value)},n.value))}),(0,G.jsxs)(J,{label:`Categories`,children:[(0,G.jsx)(Y,{icon:V,label:`All`,active:r===null,badge:c?s:void 0,onSelect:()=>a(null)}),f.map(e=>(0,G.jsx)(Y,{icon:S(e.icon)??V,label:e.label,active:r===e.slug,badge:c?o[e.slug]??0:void 0,onSelect:()=>a(e.slug)},e.slug))]})]}),(0,G.jsx)(k.Footer,{children:(0,G.jsx)(i,{type:`button`,variant:`primary`,fullWidth:!0,onClick:()=>u(!1),children:`Done`})})]})]})}function J({label:e,children:t}){return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`px-2 pb-1 text-body-small-default uppercase tracking-wide`,style:{color:`var(--content-tertiary)`},children:e}),t]})}function Y({icon:e,label:t,active:n,badge:r,onSelect:i}){return(0,G.jsx)(A,{icon:e,label:t,active:n,activeVariant:`branded`,badge:r,trailingAction:n&&r==null?(0,G.jsx)(y,{className:`h-4 w-4 text-[var(--primary-base)]`,"aria-hidden":!0}):void 0,onSelect:i})}function X({label:e,options:t,selected:n,onSelect:r}){return(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-body-small-default uppercase tracking-wide`,style:{color:`var(--content-tertiary)`},children:e}),(0,G.jsx)(`ul`,{children:t.map(e=>{let t=e.icon,i=n===e.value;return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),role:`option`,"aria-selected":i,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{color:i?`var(--primary-base)`:`var(--content-default)`},children:[(0,G.jsx)(t,{className:`h-4 w-4`,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`flex-1`,children:e.label}),i&&(0,G.jsx)(P,{className:`h-3.5 w-3.5`,"aria-hidden":!0})]})},e.value)})})]})}function ue({skill:e,onSelect:t,onInstall:n,onRemove:r,isInstalling:a=!1,isRemoving:o=!1}){let s=f(e),c=ae(e);return(0,G.jsx)(d.Root,{asChild:!0,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:`flex cursor-pointer items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-[var(--surface-hover)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,G.jsx)(`div`,{className:`flex shrink-0 items-center justify-center text-[28px] leading-none`,children:(0,G.jsx)(p,{skill:e,className:`h-7 w-7`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-emphasised)`},children:e.name}),(0,G.jsx)(_,{origin:e.origin})]}),(0,G.jsx)(`p`,{className:`mt-1 truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:e.description})]}),s?a?(0,G.jsx)(i,{type:`button`,iconOnly:(0,G.jsx)(w,{className:`animate-spin`,"aria-hidden":!0}),disabled:!0,"aria-label":`Installing`,expandOnMobile:!1}):(0,G.jsx)(i,{type:`button`,iconOnly:(0,G.jsx)(F,{"aria-hidden":!0}),onClick:e=>{e.stopPropagation(),n?.()},disabled:!n,"aria-label":`Install skill`,expandOnMobile:!1}):(0,G.jsx)(i,{type:`button`,variant:`dangerOutline`,iconOnly:o?(0,G.jsx)(w,{className:`animate-spin`,"aria-hidden":!0}):(0,G.jsx)(I,{"aria-hidden":!0}),onClick:e=>{e.stopPropagation(),r?.()},disabled:!c||o||!r,"aria-label":c?`Remove skill`:`Bundled skill cannot be removed`,title:c?void 0:`Bundled skills cannot be removed`,expandOnMobile:!1})]})})}var de=new Set([`all`,`installed`,`available`,`vellum`,`clawhub`,`skillssh`,`custom`,`assistant-memory`]);function fe(e){let t=e.get(`filter`),n=e.get(`category`);return{q:e.get(`q`)??``,filter:me(t)?t:`all`,category:n||null}}function pe(e,t){let n=new URLSearchParams(e);return t.q!==void 0&&Z(n,`q`,t.q.trim()||null),t.filter!==void 0&&Z(n,`filter`,t.filter===`all`?null:t.filter),t.category!==void 0&&Z(n,`category`,t.category),n}function Z(e,t,n){n===null?e.delete(t):e.set(t,n)}function me(e){return e!==null&&de.has(e)}function he(e){switch(e){case`installed`:return{kind:`installed`};case`available`:return{kind:`available`};case`vellum`:case`clawhub`:case`skillssh`:case`custom`:case`assistant-memory`:return{origin:e};default:return{}}}function ge(e){return[...e].sort((e,t)=>{let n=g(e);return n===g(t)?e.name.localeCompare(t.name,void 0,{sensitivity:`base`}):n?-1:1})}function Q(e,t){let[n,r]=(0,W.useState)(e);return(0,W.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>clearTimeout(n)},[e,t]),n}var _e=300,$=`vellum:skills:tipDismissed`;function ve({assistantId:e}){let r=c(),i=a(),[s,u]=o(),{q:d,filter:f,category:p}=(0,W.useMemo)(()=>fe(s),[s]),m=(0,W.useCallback)(e=>{u(t=>pe(t,e),{replace:!0})},[u]),[h,g]=(0,W.useState)(d),_=Q(h.trim(),_e),v=(0,W.useRef)(d);(0,W.useEffect)(()=>{if(d!==v.current&&(v.current=d,d!==h.trim())){g(d);return}_!==d&&_===h.trim()&&(v.current=_,m({q:_}))},[_,d,h,m]);let y=(0,W.useCallback)(e=>m({filter:e}),[m]),b=(0,W.useCallback)(e=>m({category:e}),[m]),[x,S]=(0,W.useState)(()=>n($,!1)),{handleInstall:C,handleRemove:w,isInstallingSkill:T,isRemovingSkill:E,skillPendingRemoval:D,confirmRemove:O,cancelRemove:k}=ne(e),{data:A=[]}=ie(e),{origin:N,kind:P}=(0,W.useMemo)(()=>he(f),[f]),F=l({...j({path:{assistant_id:e},query:{include:`catalog`,origin:N,kind:P,q:_||void 0,category:p??void 0}}),select:e=>({skills:e.skills,categoryCounts:e.categoryCounts,totalCount:e.totalCount}),enabled:!!e}),I=l({...j({path:{assistant_id:e},query:{include:`catalog`,origin:N,kind:P,q:_||void 0}}),select:e=>({skills:e.skills,categoryCounts:e.categoryCounts,totalCount:e.totalCount}),enabled:!!e&&p!==null}),L=(0,W.useCallback)(()=>{S(!0),t($,!0)},[]),R=(0,W.useMemo)(()=>F.data?.skills??[],[F.data?.skills]),z=p===null?F.data:I.data,{counts:B,totalCount:V}=ye(z?.skills??R,z?.categoryCounts,z?.totalCount),H=(0,W.useMemo)(()=>ge(R),[R]),U=F.isFetching&&!!_;return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col gap-4`,children:[!x&&(0,G.jsx)(be,{onDismiss:L}),(0,G.jsx)(se,{search:h,onSearchChange:g,filter:f,onFilterChange:y,isSearching:U,categories:A,category:p,onCategoryChange:b,counts:B,totalCount:V,showCounts:!U}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-6`,children:[(0,G.jsx)(`aside`,{className:`hidden w-56 shrink-0 overflow-y-auto sm:block`,children:(0,G.jsx)(re,{selected:p,onSelect:b,counts:B,totalCount:V,showCounts:!U,categories:A})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 overflow-y-auto`,children:F.isLoading?(0,G.jsx)(ee,{}):F.isError?(0,G.jsx)(te,{}):H.length===0?(0,G.jsx)(xe,{filter:f,category:p}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-2`,children:H.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(ue,{skill:e,onSelect:()=>r(M.skills.detail(e.id),{state:{listSearch:i.search}}),onInstall:()=>C(e),onRemove:()=>w(e),isInstalling:T(e),isRemoving:E(e)})},e.id))})})]}),(0,G.jsx)(oe,{skillName:D?.name??null,onConfirm:O,onCancel:k})]})}function ye(e,t,n){return(0,W.useMemo)(()=>{if(t&&Object.keys(t).length>0)return{counts:t,totalCount:n??e.length};let r={};for(let t of e){let e=t.category??`system`;r[e]=(r[e]??0)+1}return{counts:r,totalCount:n??e.length}},[e,t,n])}function be({onDismiss:e}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-4 py-2.5 text-body-small-default`,style:{backgroundColor:`var(--surface-base)`,color:`var(--content-secondary)`},children:[(0,G.jsx)(T,{className:`h-4 w-4 shrink-0`,style:{color:`var(--primary-base)`}}),(0,G.jsx)(`p`,{className:`flex-1`,children:`You can create a new custom skill by describing what you want in chat.`}),(0,G.jsx)(i,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,G.jsx)(E,{"aria-hidden":!0}),onClick:e,"aria-label":`Dismiss tip`,tintColor:`var(--content-tertiary)`,expandOnMobile:!1})]})}function xe({filter:e,category:t}){let{title:n,subtitle:r,Icon:i}=Se(e,t);return(0,G.jsx)(m,{icon:i,title:n,subtitle:r})}function Se(e,t){if(t)return{title:`No skills in this category`,subtitle:`Try selecting a different category or clearing the filter.`,Icon:V};switch(e){case`installed`:return{title:`No Skills Installed`,subtitle:`Ask your assistant in chat to search for and install new skills.`,Icon:N};case`available`:return{title:`No Skills Available`,subtitle:`All available skills have been installed.`,Icon:P};case`vellum`:return{title:`No Vellum Skills`,subtitle:`No bundled Vellum skills found.`,Icon:B};case`clawhub`:return{title:`No Clawhub Skills`,subtitle:`No Clawhub skills found. Try searching the catalog.`,Icon:C};case`skillssh`:return{title:`No skills.sh Skills`,subtitle:`No skills.sh skills found. Try searching the catalog.`,Icon:R};case`custom`:return{title:`No Custom Skills`,subtitle:`Create a custom skill by describing what you want in chat.`,Icon:L};default:return{title:`No Skills Available`,subtitle:`Check your connection to the Vellum catalog.`,Icon:b}}}function Ce(){let e=U(),[t]=o(),n=t.get(`skill`);return n?(0,G.jsx)(s,{to:M.skills.detail(n),replace:!0}):(0,G.jsx)(ve,{assistantId:e})}export{Ce as SkillsPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./local-settings-C-dW2vkq.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-BQVYX8n_.js";import{l as a,m as o,n as s,u as c}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as l}from"./useQuery-B45lW1Kk.js";import{t as u}from"./jsx-runtime-CVSDxk6A.js";import{t as d}from"./card-D8zyWtZh.js";import{a as f,c as p,i as m,l as h,n as ee,o as g,r as te,s as _,t as ne}from"./use-skill-actions-fDejA0nc.js";import{t as v}from"./brain-CMiHVWFK.js";import{t as y}from"./check-wF3S-AV4.js";import{t as b}from"./cloud-off-DT0KnUQ4.js";import{i as x,n as re,r as S,t as ie}from"./use-skill-categories-DCOdxAre.js";import{t as C}from"./globe-Dx8dM0gj.js";import{t as w}from"./loader-circle-D57RZgLH.js";import{t as T}from"./sparkles-DDIsk_nZ.js";import{t as E}from"./x-CswtfvgS.js";import"./src-CDdn26Yb.js";import{t as D}from"./popover-Bl6742nZ.js";import{t as O}from"./input-ZpyYt_a0.js";import{n as k,t as A}from"./panel-item-Bvqsr5n9.js";import{St as j}from"./react-query.gen-BQH0QRfT.js";import{c as M}from"./routes-XPLb07Av.js";import{Fi as N,Ha as P,Ja as F,Ui as I,Vi as L,Wi as R,ea as z,la as B,xa as V,zr as H}from"./index-CgcZXB4g.js";import{t as U}from"./use-active-assistant-id-9rGx8kT9.js";import{n as ae,r as oe}from"./skills-DJft07cl.js";var W=e(r(),1),G=u(),K=[{value:`all`,label:`All`,icon:V},{value:`installed`,label:`Installed`,icon:P},{value:`available`,label:`Available`,icon:F}],q=[{value:`vellum`,label:`Vellum`,icon:h},{value:`clawhub`,label:`Clawhub`,icon:C},{value:`skillssh`,label:`skills.sh`,icon:R},{value:`custom`,label:`Custom`,icon:L},{value:`assistant-memory`,label:`Assistant's Memory`,icon:v}];function se({search:e,onSearchChange:t,filter:n,onFilterChange:r,isSearching:i,categories:a,category:o,onCategoryChange:s,counts:c,totalCount:l,showCounts:u}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(O,{type:`search`,value:e,onChange:e=>{t(e.target.value)},placeholder:`Search skills`,"aria-label":`Search skills`,leftIcon:(0,G.jsx)(z,{className:`h-4 w-4`,"aria-hidden":!0}),rightIcon:i?(0,G.jsx)(w,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):void 0,fullWidth:!0,wrapperClassName:`flex-1`}),(0,G.jsx)(ce,{filter:n,onFilterChange:r,categories:a,category:o,onCategoryChange:s,counts:c,totalCount:l,showCounts:u})]})}function ce(e){let t=H(),[n,r]=(0,W.useState)(!1),a=(0,G.jsx)(i,{type:`button`,variant:`outlined`,iconOnly:(0,G.jsx)(x,{"aria-hidden":!0}),"aria-label":`Filter skills`,"aria-haspopup":t?`dialog`:`listbox`,"aria-expanded":n,tintColor:`var(--primary-base)`});return t?(0,G.jsx)(le,{...e,open:n,onOpenChange:r,trigger:a}):(0,G.jsxs)(D.Root,{open:n,onOpenChange:r,children:[(0,G.jsx)(D.Trigger,{asChild:!0,children:a}),(0,G.jsx)(D.Content,{align:`end`,sideOffset:4,className:`w-44 overflow-hidden p-0`,children:(0,G.jsxs)(`ul`,{role:`listbox`,children:[(0,G.jsx)(X,{label:`Status`,options:K,selected:e.filter,onSelect:t=>{e.onFilterChange(t),r(!1)}}),(0,G.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),(0,G.jsx)(X,{label:`Source`,options:q,selected:e.filter,onSelect:t=>{e.onFilterChange(t),r(!1)}})]})})]})}function le({filter:e,onFilterChange:t,categories:n,category:r,onCategoryChange:a,counts:o,totalCount:s,showCounts:c,open:l,onOpenChange:u,trigger:d}){let f=[...n].sort((e,t)=>e.label.localeCompare(t.label));return(0,G.jsxs)(k.Root,{open:l,onOpenChange:u,children:[(0,G.jsx)(k.Trigger,{asChild:!0,children:d}),(0,G.jsxs)(k.Content,{className:`max-h-[85dvh]`,"aria-describedby":void 0,children:[(0,G.jsx)(`div`,{"aria-hidden":!0,className:`mx-auto mb-3 h-1 w-9 shrink-0 rounded-full bg-[var(--border-element)]`}),(0,G.jsx)(k.Header,{children:(0,G.jsx)(k.Title,{children:`Filters`})}),(0,G.jsxs)(k.Body,{className:`flex flex-col gap-3 pt-2`,children:[(0,G.jsx)(J,{label:`Status`,children:K.map(n=>(0,G.jsx)(Y,{icon:n.icon,label:n.label,active:e===n.value,onSelect:()=>t(n.value)},n.value))}),(0,G.jsx)(J,{label:`Source`,children:q.map(n=>(0,G.jsx)(Y,{icon:n.icon,label:n.label,active:e===n.value,onSelect:()=>t(n.value)},n.value))}),(0,G.jsxs)(J,{label:`Categories`,children:[(0,G.jsx)(Y,{icon:V,label:`All`,active:r===null,badge:c?s:void 0,onSelect:()=>a(null)}),f.map(e=>(0,G.jsx)(Y,{icon:S(e.icon)??V,label:e.label,active:r===e.slug,badge:c?o[e.slug]??0:void 0,onSelect:()=>a(e.slug)},e.slug))]})]}),(0,G.jsx)(k.Footer,{children:(0,G.jsx)(i,{type:`button`,variant:`primary`,fullWidth:!0,onClick:()=>u(!1),children:`Done`})})]})]})}function J({label:e,children:t}){return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`px-2 pb-1 text-body-small-default uppercase tracking-wide`,style:{color:`var(--content-tertiary)`},children:e}),t]})}function Y({icon:e,label:t,active:n,badge:r,onSelect:i}){return(0,G.jsx)(A,{icon:e,label:t,active:n,activeVariant:`branded`,badge:r,trailingAction:n&&r==null?(0,G.jsx)(y,{className:`h-4 w-4 text-[var(--primary-base)]`,"aria-hidden":!0}):void 0,onSelect:i})}function X({label:e,options:t,selected:n,onSelect:r}){return(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-body-small-default uppercase tracking-wide`,style:{color:`var(--content-tertiary)`},children:e}),(0,G.jsx)(`ul`,{children:t.map(e=>{let t=e.icon,i=n===e.value;return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),role:`option`,"aria-selected":i,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{color:i?`var(--primary-base)`:`var(--content-default)`},children:[(0,G.jsx)(t,{className:`h-4 w-4`,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`flex-1`,children:e.label}),i&&(0,G.jsx)(P,{className:`h-3.5 w-3.5`,"aria-hidden":!0})]})},e.value)})})]})}function ue({skill:e,onSelect:t,onInstall:n,onRemove:r,isInstalling:a=!1,isRemoving:o=!1}){let s=f(e),c=ae(e);return(0,G.jsx)(d.Root,{asChild:!0,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:`flex cursor-pointer items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-[var(--surface-hover)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,G.jsx)(`div`,{className:`flex shrink-0 items-center justify-center text-[28px] leading-none`,children:(0,G.jsx)(p,{skill:e,className:`h-7 w-7`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-emphasised)`},children:e.name}),(0,G.jsx)(_,{origin:e.origin})]}),(0,G.jsx)(`p`,{className:`mt-1 truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:e.description})]}),s?a?(0,G.jsx)(i,{type:`button`,iconOnly:(0,G.jsx)(w,{className:`animate-spin`,"aria-hidden":!0}),disabled:!0,"aria-label":`Installing`,expandOnMobile:!1}):(0,G.jsx)(i,{type:`button`,iconOnly:(0,G.jsx)(F,{"aria-hidden":!0}),onClick:e=>{e.stopPropagation(),n?.()},disabled:!n,"aria-label":`Install skill`,expandOnMobile:!1}):(0,G.jsx)(i,{type:`button`,variant:`dangerOutline`,iconOnly:o?(0,G.jsx)(w,{className:`animate-spin`,"aria-hidden":!0}):(0,G.jsx)(I,{"aria-hidden":!0}),onClick:e=>{e.stopPropagation(),r?.()},disabled:!c||o||!r,"aria-label":c?`Remove skill`:`Bundled skill cannot be removed`,title:c?void 0:`Bundled skills cannot be removed`,expandOnMobile:!1})]})})}var de=new Set([`all`,`installed`,`available`,`vellum`,`clawhub`,`skillssh`,`custom`,`assistant-memory`]);function fe(e){let t=e.get(`filter`),n=e.get(`category`);return{q:e.get(`q`)??``,filter:me(t)?t:`all`,category:n||null}}function pe(e,t){let n=new URLSearchParams(e);return t.q!==void 0&&Z(n,`q`,t.q.trim()||null),t.filter!==void 0&&Z(n,`filter`,t.filter===`all`?null:t.filter),t.category!==void 0&&Z(n,`category`,t.category),n}function Z(e,t,n){n===null?e.delete(t):e.set(t,n)}function me(e){return e!==null&&de.has(e)}function he(e){switch(e){case`installed`:return{kind:`installed`};case`available`:return{kind:`available`};case`vellum`:case`clawhub`:case`skillssh`:case`custom`:case`assistant-memory`:return{origin:e};default:return{}}}function ge(e){return[...e].sort((e,t)=>{let n=g(e);return n===g(t)?e.name.localeCompare(t.name,void 0,{sensitivity:`base`}):n?-1:1})}function Q(e,t){let[n,r]=(0,W.useState)(e);return(0,W.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>clearTimeout(n)},[e,t]),n}var _e=300,$=`vellum:skills:tipDismissed`;function ve({assistantId:e}){let r=c(),i=a(),[s,u]=o(),{q:d,filter:f,category:p}=(0,W.useMemo)(()=>fe(s),[s]),m=(0,W.useCallback)(e=>{u(t=>pe(t,e),{replace:!0})},[u]),[h,g]=(0,W.useState)(d),_=Q(h.trim(),_e),v=(0,W.useRef)(d);(0,W.useEffect)(()=>{if(d!==v.current&&(v.current=d,d!==h.trim())){g(d);return}_!==d&&_===h.trim()&&(v.current=_,m({q:_}))},[_,d,h,m]);let y=(0,W.useCallback)(e=>m({filter:e}),[m]),b=(0,W.useCallback)(e=>m({category:e}),[m]),[x,S]=(0,W.useState)(()=>n($,!1)),{handleInstall:C,handleRemove:w,isInstallingSkill:T,isRemovingSkill:E,skillPendingRemoval:D,confirmRemove:O,cancelRemove:k}=ne(e),{data:A=[]}=ie(e),{origin:N,kind:P}=(0,W.useMemo)(()=>he(f),[f]),F=l({...j({path:{assistant_id:e},query:{include:`catalog`,origin:N,kind:P,q:_||void 0,category:p??void 0}}),select:e=>({skills:e.skills,categoryCounts:e.categoryCounts,totalCount:e.totalCount}),enabled:!!e}),I=l({...j({path:{assistant_id:e},query:{include:`catalog`,origin:N,kind:P,q:_||void 0}}),select:e=>({skills:e.skills,categoryCounts:e.categoryCounts,totalCount:e.totalCount}),enabled:!!e&&p!==null}),L=(0,W.useCallback)(()=>{S(!0),t($,!0)},[]),R=(0,W.useMemo)(()=>F.data?.skills??[],[F.data?.skills]),z=p===null?F.data:I.data,{counts:B,totalCount:V}=ye(z?.skills??R,z?.categoryCounts,z?.totalCount),H=(0,W.useMemo)(()=>ge(R),[R]),U=F.isFetching&&!!_;return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col gap-4`,children:[!x&&(0,G.jsx)(be,{onDismiss:L}),(0,G.jsx)(se,{search:h,onSearchChange:g,filter:f,onFilterChange:y,isSearching:U,categories:A,category:p,onCategoryChange:b,counts:B,totalCount:V,showCounts:!U}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-6`,children:[(0,G.jsx)(`aside`,{className:`hidden w-56 shrink-0 overflow-y-auto sm:block`,children:(0,G.jsx)(re,{selected:p,onSelect:b,counts:B,totalCount:V,showCounts:!U,categories:A})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 overflow-y-auto`,children:F.isLoading?(0,G.jsx)(ee,{}):F.isError?(0,G.jsx)(te,{}):H.length===0?(0,G.jsx)(xe,{filter:f,category:p}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-2`,children:H.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(ue,{skill:e,onSelect:()=>r(M.skills.detail(e.id),{state:{listSearch:i.search}}),onInstall:()=>C(e),onRemove:()=>w(e),isInstalling:T(e),isRemoving:E(e)})},e.id))})})]}),(0,G.jsx)(oe,{skillName:D?.name??null,onConfirm:O,onCancel:k})]})}function ye(e,t,n){return(0,W.useMemo)(()=>{if(t&&Object.keys(t).length>0)return{counts:t,totalCount:n??e.length};let r={};for(let t of e){let e=t.category??`system`;r[e]=(r[e]??0)+1}return{counts:r,totalCount:n??e.length}},[e,t,n])}function be({onDismiss:e}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-4 py-2.5 text-body-small-default`,style:{backgroundColor:`var(--surface-base)`,color:`var(--content-secondary)`},children:[(0,G.jsx)(T,{className:`h-4 w-4 shrink-0`,style:{color:`var(--primary-base)`}}),(0,G.jsx)(`p`,{className:`flex-1`,children:`You can create a new custom skill by describing what you want in chat.`}),(0,G.jsx)(i,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,G.jsx)(E,{"aria-hidden":!0}),onClick:e,"aria-label":`Dismiss tip`,tintColor:`var(--content-tertiary)`,expandOnMobile:!1})]})}function xe({filter:e,category:t}){let{title:n,subtitle:r,Icon:i}=Se(e,t);return(0,G.jsx)(m,{icon:i,title:n,subtitle:r})}function Se(e,t){if(t)return{title:`No skills in this category`,subtitle:`Try selecting a different category or clearing the filter.`,Icon:V};switch(e){case`installed`:return{title:`No Skills Installed`,subtitle:`Ask your assistant in chat to search for and install new skills.`,Icon:N};case`available`:return{title:`No Skills Available`,subtitle:`All available skills have been installed.`,Icon:P};case`vellum`:return{title:`No Vellum Skills`,subtitle:`No bundled Vellum skills found.`,Icon:B};case`clawhub`:return{title:`No Clawhub Skills`,subtitle:`No Clawhub skills found. Try searching the catalog.`,Icon:C};case`skillssh`:return{title:`No skills.sh Skills`,subtitle:`No skills.sh skills found. Try searching the catalog.`,Icon:R};case`custom`:return{title:`No Custom Skills`,subtitle:`Create a custom skill by describing what you want in chat.`,Icon:L};default:return{title:`No Skills Available`,subtitle:`Check your connection to the Vellum catalog.`,Icon:b}}}function Ce(){let e=U(),[t]=o(),n=t.get(`skill`);return n?(0,G.jsx)(s,{to:M.skills.detail(n),replace:!0}):(0,G.jsx)(ve,{assistantId:e})}export{Ce as SkillsPage};