cezarion 0.18.0-dev.8468 → 0.18.0-dev.8472

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 (80) hide show
  1. package/package.json +3 -3
  2. package/web/dist/assets/accounts-section-CuihHvuE.js +1 -0
  3. package/web/dist/assets/activity-motion-bKmIl_Ai.js +2 -0
  4. package/web/dist/assets/{activity-route-BAGYVlk1.js → activity-route-Bnz_NdUs.js} +1 -1
  5. package/web/dist/assets/agent-config-section-uQrQrvBR.js +1 -0
  6. package/web/dist/assets/agent-defaults-section-1UTSo5HV.js +1 -0
  7. package/web/dist/assets/{appearance-Bbmz3RPP.js → appearance-CZ0kce28.js} +1 -1
  8. package/web/dist/assets/{archive-on-merge-field-BHtW_R72.js → archive-on-merge-field-CEyCpweg.js} +1 -1
  9. package/web/dist/assets/attention-BFUaj1mU.js +1 -0
  10. package/web/dist/assets/automations-route-Dq90emTh.js +1 -0
  11. package/web/dist/assets/code-editor-B4baSOhz.js +4 -0
  12. package/web/dist/assets/{commit-diff-panel-CR9lCdYd.js → commit-diff-panel-Btc38N2Q.js} +1 -1
  13. package/web/dist/assets/{diff-BUihlcHW.js → diff-C3-63Zgu.js} +2 -2
  14. package/web/dist/assets/{diff-view-Dy1iZUpI.js → diff-view-D2O2Nm5P.js} +1 -1
  15. package/web/dist/assets/file-preview-Bnq2OKGK.js +2 -0
  16. package/web/dist/assets/{folder-browser-OPEKYHN1.js → folder-browser-Bn83Rjyn.js} +1 -1
  17. package/web/dist/assets/{git-toolbar-CUQ8veXw.js → git-toolbar-RA8rF90D.js} +1 -1
  18. package/web/dist/assets/{github-ClGhwLM1.js → github-BRAMTLRU.js} +1 -1
  19. package/web/dist/assets/{global-activity-route-DzdSy7Wm.js → global-activity-route-Ii_-Fqqo.js} +1 -1
  20. package/web/dist/assets/index-2DP8fWMQ.css +1 -0
  21. package/web/dist/assets/index-DCw_bX8I.js +21 -0
  22. package/web/dist/assets/{label-Cptt_zCn.js → label-tOtTf55G.js} +1 -1
  23. package/web/dist/assets/{live-reads-jRSHgWlx.js → live-reads-CR3-q01w.js} +1 -1
  24. package/web/dist/assets/{markdown-DvutydYG.js → markdown-G8tjpJd_.js} +1 -1
  25. package/web/dist/assets/{notifications-section-BAqEIyDN.js → notifications-section-Fk_ebhy_.js} +1 -1
  26. package/web/dist/assets/{open-in-menu-ytsrlsSn.js → open-in-menu-xzDJ4_Tv.js} +1 -1
  27. package/web/dist/assets/plus-CxRU2X8C.js +1 -0
  28. package/web/dist/assets/{preview-pane-connected-BU0pxY0y.js → preview-pane-connected-8HkdMxOW.js} +2 -2
  29. package/web/dist/assets/{project-location-BIWHn5XU.js → project-location-C9WLgY3A.js} +1 -1
  30. package/web/dist/assets/{project-router-CWwXAsqF.js → project-router-DucFIl_x.js} +1 -1
  31. package/web/dist/assets/{project-scope-context-Dq-Iq7xE.js → project-scope-context-C912rTJP.js} +2 -2
  32. package/web/dist/assets/{projects-section-DbCjlMOl.js → projects-section-Dmj4JFoi.js} +1 -1
  33. package/web/dist/assets/{prompt-templates-section-BsAYf057.js → prompt-templates-section-DzfD2GES.js} +1 -1
  34. package/web/dist/assets/queries-DRpvYgai.js +1 -0
  35. package/web/dist/assets/{reference-chip-D52WtrZ9.js → reference-chip-zRuFkaGy.js} +1 -1
  36. package/web/dist/assets/{remote-settings-notice-Buq1mILf.js → remote-settings-notice-CYiMrnys.js} +1 -1
  37. package/web/dist/assets/repo-git-B3tTtvIQ.js +1 -0
  38. package/web/dist/assets/report-reader-DBGA_8LA.js +1 -0
  39. package/web/dist/assets/{reports-D-IUJk8n.js → reports-B-Q6u2X6.js} +1 -1
  40. package/web/dist/assets/{resources-section-CIF3uOPg.js → resources-section-C5ndEonC.js} +1 -1
  41. package/web/dist/assets/run-header-DK4CZ3hY.js +2 -0
  42. package/web/dist/assets/session-context-section-BAw6x6P2.js +119 -0
  43. package/web/dist/assets/{settings-agent-picker-D7x87Fza.js → settings-agent-picker-fkaIrncp.js} +1 -1
  44. package/web/dist/assets/settings-shell-dzuuT5tw.js +1 -0
  45. package/web/dist/assets/{sidebar-section-2j1dPZW-.js → sidebar-section-BIQilcgt.js} +1 -1
  46. package/web/dist/assets/{skills-BZQKuRIK.js → skills-C-jo20DK.js} +1 -1
  47. package/web/dist/assets/{tab-link-qPg641SX.js → tab-link-Bh6CcIR7.js} +1 -1
  48. package/web/dist/assets/{task-changes-CMCstWbh.js → task-changes-DnG-9vJh.js} +1 -1
  49. package/web/dist/assets/{task-commits-De5jDVRc.js → task-commits-mqs3nfjk.js} +1 -1
  50. package/web/dist/assets/task-files-DKB3Xp3N.js +1 -0
  51. package/web/dist/assets/{task-github-item-Da-J1yOO.js → task-github-item-BA7W64bU.js} +1 -1
  52. package/web/dist/assets/{task-groups-CZAR_voe.js → task-groups-ClNnAPRA.js} +1 -1
  53. package/web/dist/assets/task-thread-B8zgMgtO.js +9 -0
  54. package/web/dist/assets/{tasks-table-CPP0rXJp.js → tasks-table-CE_VVk0w.js} +1 -1
  55. package/web/dist/assets/{thread-state-q7EKE8NY.js → thread-state-8okW1FLM.js} +1 -1
  56. package/web/dist/assets/{use-hand-to-agent-state-V15iu0Vf.js → use-hand-to-agent-state-BwLk3gNd.js} +1 -1
  57. package/web/dist/assets/{useInfiniteQuery-D9ecHhMH.js → useInfiniteQuery-CPEWc6dl.js} +1 -1
  58. package/web/dist/assets/useQuery-BOEhMTCg.js +1 -0
  59. package/web/dist/assets/workflows-BhQJM4JW.js +7 -0
  60. package/web/dist/assets/{workspace-tools-BSJXB55E.js → workspace-tools-BZs10pQZ.js} +1 -1
  61. package/web/dist/assets/{worktrees-section-DWfvhcFw.js → worktrees-section-BTNZUVnW.js} +4 -4
  62. package/web/dist/index.html +15 -15
  63. package/web/dist/assets/accounts-section-COnLhVcc.js +0 -1
  64. package/web/dist/assets/activity-motion-BepAhXl7.js +0 -2
  65. package/web/dist/assets/agent-config-section-D3eY8kW2.js +0 -4
  66. package/web/dist/assets/agent-defaults-section-BxIztnP5.js +0 -1
  67. package/web/dist/assets/attention-CexCTxjN.js +0 -1
  68. package/web/dist/assets/automations-route-vO4VXsmB.js +0 -1
  69. package/web/dist/assets/file-preview-Cq_WJ308.js +0 -2
  70. package/web/dist/assets/index-8Pe4JlYM.js +0 -21
  71. package/web/dist/assets/index-HkNWm2JB.css +0 -1
  72. package/web/dist/assets/queries-Dd6O2cf-.js +0 -1
  73. package/web/dist/assets/repo-git-P8s3o1t9.js +0 -1
  74. package/web/dist/assets/report-reader-BGHRGd46.js +0 -1
  75. package/web/dist/assets/run-header-x8ZoTs8l.js +0 -2
  76. package/web/dist/assets/settings-shell-CdsAJa6b.js +0 -1
  77. package/web/dist/assets/task-files-BTaS-k-o.js +0 -1
  78. package/web/dist/assets/task-thread-A2rldNuS.js +0 -9
  79. package/web/dist/assets/useQuery-B0ubYnT2.js +0 -1
  80. package/web/dist/assets/workflows-BWde25JO.js +0 -7
@@ -1,9 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{l as i,n as a,t as o}from"./utils-DSMR_WLb.js";import{n as s}from"./live-refetch-CZb2VOyu.js";import{$ as c,An as l,Jr as u,Kn as d,Q as f,Qn as p,Tn as m,Tt as h,Yn as g,Yr as _,ci as v,ct as y,it as b,or as x,rt as S,tt as C}from"./project-scope-context-Dq-Iq7xE.js";import{$ as w,G as T,H as E,Ht as D,I as ee,K as O,Kt as k,Lt as A,R as te,Ut as j,X as ne,Xt as re,_ as M,_t as ie,at as N,en as P,et as F,ht as I,in as L,j as R,nn as z,rn as B,rt as ae,st as oe,yt as V}from"./queries-Dd6O2cf-.js";import{t as se}from"./useQuery-B0ubYnT2.js";import{f as ce,h as le,n as ue,p as de}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{d as fe,m as pe,r as me,s as he,v as ge}from"./tasks-table-CPP0rXJp.js";import{n as H}from"./toaster-Bo5vCbz-.js";import{A as _e,B as U,F as ve,K as ye,X as be,at as xe,c as Se,dt as Ce,f as we,g as Te,it as Ee,k as De,l as Oe,m as ke,n as Ae,ot as je,s as Me,u as W,ut as Ne,v as Pe,y as Fe,z as Ie}from"./design-icons-CzEoMH9c.js";import{t as G}from"./createLucideIcon-BHp8sXmF.js";import{_ as Le,a as Re,c as ze,d as Be,f as Ve,g as He,h as Ue,i as We,l as Ge,m as Ke,n as qe,o as Je,p as Ye,r as Xe,s as Ze,t as Qe,u as $e,v as et,y as tt}from"./run-header-x8ZoTs8l.js";import{t as nt}from"./chevron-right-BENZ-1ZN.js";import{t as rt}from"./external-link-BE6y205O.js";import{t as it}from"./eye-B8okNWXU.js";import{n as at}from"./smartphone-Lr8Ug2z_.js";import{a as ot}from"./format-BNCkW110.js";import{t as st}from"./message-square-B-MD-8rD.js";import{a as ct,c as lt,i as ut,l as dt,n as ft,o as pt,r as mt,s as ht,t as gt}from"./thread-state-q7EKE8NY.js";import{i as _t,o as vt,t as yt,u as bt}from"./reference-chip-D52WtrZ9.js";import{t as xt}from"./square-terminal-B6RYYieR.js";import{t as K}from"./button-BQ2y4XRB.js";import{n as q,r as J,t as Y}from"./collapsible-BEV4FO-1.js";import{a as St}from"./popover-BPgUYFyu.js";import{s as Ct,t as X}from"./project-router-CWwXAsqF.js";import"./attention-CexCTxjN.js";import{D as wt,E as Tt,O as Et,S as Dt,b as Ot,f as Z,u as kt,w as At}from"./task-groups-CZAR_voe.js";import{t as jt}from"./status-dot-DtAOFiIi.js";import{n as Mt,t as Nt}from"./centered-state-V15AR_qo.js";import{$n as Pt,F as Ft,Fn as It,G as Lt,I as Rt,In as zt,Jn as Bt,K as Vt,Ln as Ht,M as Ut,N as Wt,P as Gt,Rn as Kt,Sn as qt,W as Jt,X as Yt,Y as Xt,an as Zt,dn as Qt,en as $t,fn as en,hn as tn,i as nn,j as rn,l as an,m as on,mn as sn,n as cn,nn as ln,on as un,pn as dn,rn as fn,s as pn,sn as mn,un as hn,vn as gn,wn as _n,x as vn,xn as yn,y as bn,yn as xn,zn as Sn}from"./index-8Pe4JlYM.js";import{i as Cn,r as wn}from"./highlighter-DvLzHjjY.js";import{t as Tn}from"./zoomable-image-CIQl1Wpe.js";import{i as En,r as Dn,s as On,t as kn}from"./markdown-DvutydYG.js";import{t as An}from"./textarea-vJt9undk.js";import{t as jn}from"./report-title-D4Mbu2Er.js";var Mn=G(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Nn=G(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Pn=G(`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`}]]),Fn=G(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),In=G(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Ln=G(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Rn=G(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Q=e(t(),1),$=r(),zn=12;function Bn({run:e}){let t=v(),n=L({mutationFn:()=>f(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:A.runs.detail(e.id)}),t.invalidateQueries({queryKey:A.runs.list()}),H(`This task will not resume itself`)},onError:e=>H(e.message,{tone:`danger`})});if(!g(e))return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let i=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);return(0,$.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(jt,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,$.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,$.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,zn,`)`]}):(0,$.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,$.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,$.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,$.jsx)(ue,{to:`/settings/global/resources`,"data-slot":`auto-resume-settings-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Auto-resume settings`})]})}function Vn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Hn=/^[A-Za-z0-9_./:=+,@%-]+$/;function Un(e){return e.replaceAll(`'`,`'\\''`)}function Wn(e){return e===``?`''`:Hn.test(e)?e:`\u0027${Un(e)}\u0027`}function Gn(e){if(!Vn(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(Wn).join(` `)}}function Kn(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function qn(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Jn(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function Yn(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Xn(e){let t=Kn(qn(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))Yn(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){Yn(e[2])&&i.push({label:Jn(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Jn(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&Yn(t)&&i.push({label:t,href:t})}return i}var Zn=(0,Q.createContext)(void 0),Qn=(0,Q.createContext)(void 0);function $n(e,t){let n=new Map;for(let r of Xn(e)){let e=En(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function er(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function tr({text:e,messageKey:t}){let n=(0,Q.useContext)(Dn),r=(0,Q.useContext)(Qn),i=t??r;if(!n||i===void 0)return null;let a=$n(e,n);return a.length===0?null:(0,$.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,$.jsx)(nr,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function nr({reference:e,messageKey:t}){let{artifactId:n,runId:r,label:i,href:a}=e,o=(0,Q.useContext)(Zn),s=(0,Q.useContext)(bn);(0,Q.useLayoutEffect)(()=>s?.register(n,r),[s,n,r]);let c=R(r,n),l=ce(),u=de();if(c.isError)return(0,$.jsx)(ue,{id:er(t,n),"data-slot":`report-card-fallback`,to:a,state:{readerFrom:l.pathname+l.search},children:i});let d=c.data?.artifact;if(d&&!On(d.name))return null;let f=new URLSearchParams(l.search);f.set(`report`,n),f.set(`card`,t);let p=new URLSearchParams(l.search).has(`report`)?l.state:null,m=new URLSearchParams(l.search);m.delete(`report`),m.delete(`card`);let h=`${l.pathname}${m.size?`?${m}`:``}`,g=window.navigation,_={reportCardEntry:!0,reportReturnTo:p?.reportReturnTo??h,reportReturnKey:p?.reportReturnKey??g?.currentEntry?.key,reportScrollTop:p?.reportScrollTop},v={pathname:l.pathname,search:`?${f}`,hash:new URL(a,`https://cockpit.invalid`).hash};return(0,$.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":r,"aria-busy":c.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,$.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:d?jn(d):i}),(0,$.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,$.jsx)(ue,{id:er(t,n),to:v,state:_,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),o?.(t);let n=_.reportScrollTop??document.querySelector(`[data-slot="main"]`)?.scrollTop;u(v,{state:{..._,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${c.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var rr={message:!0,reasoning:!0,tool:!0,hook:!0};function ir(e){return Object.hasOwn(rr,e)&&rr[e]}var ar=e=>e.kind===`tool`,or=e=>e.kind===`conversation`,sr=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,cr=(e,t,n)=>`${e} ${e===1?t:n}`;function lr(e,t){let n=[];return e>0&&n.push(cr(e,`file`,`files`)),t>0&&n.push(cr(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function ur(e){return`${e} earlier tool call${e===1?``:`s`}`}var dr=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function fr(e){for(let t of dr)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var pr=new WeakMap;function mr(e){let t=pr.get(e);if(t)return t;let n=hr(e);return pr.set(e,n),n}function hr(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(ar).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=ir(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:lr(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of gr(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(or(e)){s(),c.push(e);continue}l(),ar(e)&&sr(e)&&!r.has(e.id)?o.push(e):(s(),ar(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function gr(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var _r=new Map,vr=(0,Q.createContext)(null);function yr(){return(0,Q.useContext)(vr)}function br({runId:e,children:t}){let n=(0,Q.useMemo)(()=>({get:t=>_r.get(e)?.get(t),set:(t,n)=>{let r=_r.get(e)??new Map;r.set(t,n),_r.set(e,r)}}),[e]);return(0,$.jsx)(vr.Provider,{value:n,children:t})}function xr(e){return e.scrollTop<Math.max(600,e.clientHeight)}function Sr(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function Cr(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function wr(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function Tr(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var Er=new Map;function Dr(e,t){Er.set(e,t)}function Or(e){return Er.get(e)}var kr=new Map;function Ar(e,t){kr.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function jr(e){return kr.get(e)}function Mr(e,t,n){let r=kr.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var Nr=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),Pr=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Fr=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Ir=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Lr=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Rr(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function zr(e){let t=Rr(e);return t===void 0?void 0:Nr.format(t)}function Br(e){let t=Rr(e);return t===void 0?void 0:Pr.format(t)}var Vr=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function Hr(e){let t=Rr(e);return t===void 0?void 0:Vr(t)}function Ur(e,t=new Date){let n=Rr(e);if(n===void 0)return;let r=Vr(n);return r===Vr(t)?`Today`:r===Vr(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Fr:Ir).format(n)}function Wr(e,t){let n=Rr(e),r=Rr(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function Gr({ts:e}){let t=zr(e);return t===void 0?null:(0,$.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Br(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function Kr({startedAt:e,completedAt:t}){let n=zr(t);if(n===void 0)return null;let r=Wr(e,t);return(0,$.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-[11px] leading-none text-soft-foreground`,children:[(0,$.jsx)(`time`,{dateTime:t,title:Br(t),children:n}),r===void 0?null:(0,$.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function qr({ts:e}){let t=Ur(e),n=Rr(e);if(t===void 0||n===void 0)return null;let r=Lr.format(n);return(0,$.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-[11px] font-medium text-soft-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,$.jsx)(`time`,{dateTime:Hr(e),title:r,children:t}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Jr={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function Yr({note:e}){return e.icon===`handoff`?(0,$.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,$.jsx)(Bt,{className:`size-3`})}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,$.jsxs)(Y,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,$.jsxs)(`div`,{className:o(`flex items-start gap-2`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:`· `,e.text]}),(0,$.jsxs)(J,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,$.jsx)(W,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,$.jsx)(q,{children:(0,$.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-[11px] text-muted-foreground`,children:e.details.map((e,t)=>(0,$.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,$.jsxs)(`span`,{className:`font-sans font-medium text-foreground/80`,children:[Jr[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,$.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:o(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}var Xr={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Zr({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let s=Xr[e],c=r===void 0?void 0:zr(r);return(0,$.jsxs)(`article`,{...a,"data-role":e,"aria-label":s.speaker,className:o(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes,n),children:[(0,$.jsxs)(`p`,{className:o(`m-0 flex w-full min-w-0 items-start gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,$.jsx)(st,{"aria-hidden":`true`,className:`size-4 shrink-0`}),s.label]}),i]}),c===void 0?null:(0,$.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,$.jsx)(Gr,{ts:r})})]}),(0,$.jsx)(`div`,{className:o(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,s.body,`leading-[1.6]`),children:t})]})}var Qr=[],$r=(0,Q.memo)(function({text:e,imageCount:t=0,images:n=Qr,ts:r,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(e),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(),y=()=>{m(e),v(void 0),f(!0)},b=async()=>{let t=p.trim();if(!t||t===e){f(!1);return}g(!0),v(void 0);try{await a?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},S=async()=>{g(!0),v(void 0);try{await o?.()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,$.jsxs)(Zr,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,$.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),f(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,$.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>f(!1),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:h?(0,$.jsx)(ot,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,$.jsxs)(Zr,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,$.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[a?(0,$.jsx)(`button`,{type:`button`,"aria-label":s,onClick:y,disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,$.jsx)(Rn,{className:`size-3.5`})}):null,o?(0,$.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void S(),disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,$.jsx)(xe,{className:`size-3.5`})}):null]}):null,_?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,$.jsx)(kn,{breaks:!0,children:e}),n.length>0?(0,$.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>x(e.split(`/`).pop()??``)?(0,$.jsx)(Tn,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,$.jsxs)(`a`,{href:i(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(ye,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,$.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}),ei=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,ti=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function ni(e,t){let n=e.cloneNode(!0);n.querySelectorAll(ti).forEach(e=>e.remove());let r=Xn(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!Yn(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function ri(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=ni(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var ii=(0,Q.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await ri(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,$.jsxs)(Zr,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,$.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:ei,children:[(0,$.jsx)(Pe,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:ei,children:[(0,$.jsx)(Pt,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,$.jsx)(`div`,{ref:r,children:(0,$.jsx)(kn,{breaks:!0,children:e})}),(0,$.jsx)(tr,{text:e,messageKey:n})]})});function ai({incident:e}){let t=re().data;if(!t)return null;let n=j(t,e.provider);return(0,$.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,$.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,$.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var oi=(0,Q.memo)(function({text:e}){let t=(0,Q.useId)();if(e.trim()===``)return null;let n=e.split(`
2
- `,1)[0]??``,r=n.length<e.length;return(0,$.jsxs)(Y,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,$.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,$.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,$.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,$.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,$.jsx)(kn,{inline:!0,children:n})}),r?(0,$.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,$.jsx)(J,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,$.jsx)(q,{children:(0,$.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,$.jsx)(kn,{children:e})})})]})});function si(){return(0,$.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,$.jsx)(ot,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,$.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var ci={read:Pt,edit:Rn,delete:xe,move:In,search:be,execute:xt,think:Nn,fetch:at,task:Me,plan:U,other:Ce},li=e=>e.split(`
3
- `).length;function ui({text:e,streaming:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let s=li(e),c=!t&&!n&&s>12;return(0,$.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":c?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=wr(e.currentTarget)}:void 0,className:o(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,c&&`max-h-[216px] overflow-y-hidden`),children:(0,$.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),c?(0,$.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&s>12?(0,$.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${s} lines`}):null]})}function di({diffs:e}){return(0,$.jsx)($.Fragment,{children:e.map((e,t)=>(0,$.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] wrap-anywhere text-muted-foreground`,children:e.path}),(0,$.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...fi(e.oldText).map((e,t)=>(0,$.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...fi(e.newText).map((e,t)=>(0,$.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
4
- `).map((e,t)=>(0,$.jsx)(pi,{text:e},t))})]},`${e.path}:${t}`))})}function fi(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
5
- `)}function pi({text:e}){return(0,$.jsx)(`span`,{className:o(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function mi(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function hi(e){let t=e.status===`running`||e.status===`pending`,n=fr(e.title),{verb:r,detail:i}=e.toolKind===`execute`&&n.detail===void 0?{verb:`Ran`,detail:e.title}:n;return{busy:t,verb:r,detail:i,expandedCommand:(e.toolKind===`execute`?Gn(e.input):ht(e.name).toolKind===e.toolKind?pt(e.name,e.input):void 0)??i,Icon:ci[e.toolKind]??Ce}}function gi(e,t){return e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t>0}function _i({item:e,busy:t}){return(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,$.jsx)(ot,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,$.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,$.jsx)(`span`,{"data-slot":`tool-exit`,className:o(`rounded-full px-2 py-px font-mono text-[11px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function vi({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,$.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,$.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t}),e.error!==void 0&&e.error!==``?(0,$.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap wrap-anywhere text-signal-word-red`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,$.jsx)(di,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,$.jsx)(ui,{text:e.output,streaming:n}):null,r.length>0?(0,$.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:a?.(r,i??e.id)}):null]})}function yi({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=yr(),[a,s]=(0,Q.useState)(()=>n===void 0?null:i?.get(n)??null),c=e=>{n!==void 0&&i?.set(n,e),s(e)},{busy:l,verb:u,detail:d,expandedCommand:f,Icon:p}=hi(e),m=gi(e,t.length),h=f!==void 0||m,g=h&&(a??(m&&mi(e)));return(0,$.jsxs)(Y,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:g,onOpenChange:c,className:o(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,$.jsxs)(J,{disabled:!h,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,$.jsx)(W,{"aria-hidden":!0,className:o(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,$.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:o(`shrink-0 font-semibold`,l&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),d===void 0?null:(0,$.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,$.jsx)(_i,{item:e,busy:l})]}),(0,$.jsx)(q,{children:(0,$.jsx)(vi,{item:e,command:f,busy:l,nested:t,cacheKey:n,renderNested:r})})]})}function bi(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function xi({item:e,cacheKey:t}){let n=yr(),[r,i]=(0,Q.useState)(()=>t===void 0?!1:n?.get(t)??!1),a=e=>{t!==void 0&&n?.set(t,e),i(e)},s=e.status!==`completed`,c=e.entries.some(e=>e.kind===`context`),l=(e.stdout??``)!==``||(e.stderr??``)!==``,u=bi(e);return(0,$.jsxs)(Y,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:a,className:o(`min-w-0 overflow-hidden rounded-md border bg-card`,s?`border-danger/25`:`border-border`),children:[(0,$.jsxs)(J,{className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] hover:bg-muted`,children:[(0,$.jsx)(W,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,$.jsx)(Mn,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,$.jsx)(`code`,{title:u,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:u}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[s?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):c?(0,$.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,s&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,$.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-[11px] font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,$.jsx)(q,{children:(0,$.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,$.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:o(`px-3 py-2 font-mono text-xs leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]`,(e.kind===`error`||e.kind===`stop`)&&`text-signal-word-red`),children:e.text},t)),e.source===void 0?null:(0,$.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-[11px] text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),l?(0,$.jsxs)(Y,{className:`border-t border-border`,children:[(0,$.jsxs)(J,{"data-slot":`hook-raw-toggle`,className:`group flex w-full items-center gap-1 px-3 py-1 text-left text-xs text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(W,{"aria-hidden":!0,className:`size-3 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),`Raw output${typeof e.exitCode==`number`?` · exit ${e.exitCode}`:``}`]}),(0,$.jsxs)(q,{children:[e.stdout?(0,$.jsx)(`pre`,{"data-slot":`hook-stdout`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.stdout}):null,e.stderr?(0,$.jsx)(`pre`,{"data-slot":`hook-stderr`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap text-signal-word-red [overflow-wrap:anywhere]`,children:e.stderr}):null]})]}):null]})})]})}function Si({group:e,scope:t}){return(0,$.jsxs)(Y,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,$.jsxs)(J,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,$.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,$.jsx)(q,{children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,$.jsx)(yi,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function Ci({count:e,children:t}){return(0,$.jsxs)(Y,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,$.jsxs)(J,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,$.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),ur(e)]}),(0,$.jsx)(q,{children:(0,$.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function wi({image:e}){return(0,$.jsx)(Tn,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}function Ti(e,t,n,r){return Et(e,t)?.runner??e.runner??(t||n?r:void 0)??`claude`}function Ei(e,t,n){let r=new Set;for(let i of e.workflowDef?.steps??[]){if(i.command!==void 0||i.kind===`plugin`)continue;let a=i.runner??t,o=i.agentProfile??(a===(e.runner??t)?e.agentProfile:void 0)??n.repoAccount?.[a];n.readyOn(a,o)||r.add(a)}return[...r]}function Di(e,t,n,r,i){if(!e)return t!==null||!n||r?i:void 0}function Oi(e){return e.needsConfig&&e.configPending?`Checking task settings…`:e.needsConfig&&e.configError?`Task settings could not be loaded.`:e.providersPending?`Checking agent providers…`:e.providersError?`Provider authentication could not be verified.`:e.canContinue?void 0:e.untouched?`Connect the required workflow providers (${e.missing.join(`, `)}) to continue.`:`Connect an agent provider to continue.`}function ki(){let e=V(),t=re();return{providers:e,registered:t,providersPending:e.isPending||t.isPending,providersError:e.isError||t.isError,providersReady:e.isSuccess&&t.isSuccess}}function Ai(e,t=null){let{registered:n,providersPending:r,providersError:i,providersReady:a}=ki(),o=M(),s=mn(e),c=e.removedRunner!==void 0,l=s&&!e.runner||c,u=qt(),d=e.delegation?.role===`worker`,f=o.data?.defaultRunner,m=Ti(e,s,c,D(f,k(n.data))??f),h=(t,n)=>sn(e,t,u.repoAccount,{original:m,target:n},s),{runners:g,signedOut:_}=u.runnersOn(e=>h(e,e)),v=d?m:Rt(t,g,m),y=g.includes(m),b=s?p(e.workflowDef,v,k(n.data)):[v],x=s&&d&&e.workflowDef?Ei(e,v,u):b.filter(e=>!u.readyOn(e,h(e,v))),S=a&&(!l||o.isSuccess)&&x.length===0,C=Oi({needsConfig:l,configPending:o.isPending,configError:o.isError,providersPending:r,providersError:i,canContinue:S,untouched:s,missing:x});return{runners:g,signedOut:_,currentRunner:m,runner:v,currentRunnerConnected:y,canContinue:S,providerPending:r||l&&o.isPending,providerError:i,reason:C,runnerOverride:Di(d,t,y,c,v)}}function ji(e,t,n,r,i,a,o,s,c){let l=Et(e,mn(e)),u=l?l.model:e.model,d=l?l.effort:e.effort,f=!r&&!n&&u?{...i?.defaultModels,[t]:u}:i?.defaultModels,p=r?null:s,m=Wt(t,o,a,[p,f?.[t]]),h=Ft(p,t,o,f,a),g=Ut(h,a),_=r?``:c??d??``,v=Gt(_,g);return{models:m,model:h,effortOptions:g,effort:v,mustClearStoredEffort:!r&&c===null&&_!==``&&v===``}}function Mi(e,t,n,r){let i=Tt(e.steps),a=Et(e,mn(e)),o=a?.agentProfile??e.agentProfile??i?.profileId??`default`;return{sessionStep:i,workerStep:a,account:n?r?.[t]??`default`:o}}function Ni(e,t,n,r,i,a,o,{model:s,effort:c,mustClearStoredEffort:l}){return{text:e.trim()?e:void 0,images:t.length?t:void 0,runner:n,model:!r&&(a!==null||i)?s:void 0,effort:!r&&(o!==null||i)?c:l?``:void 0}}function Pi(e,t,n,r){return!!t&&(r!==wt(t,e)||(n?.agentProfile??e.agentProfile??t.profileId??`default`)!==(t.profileId??`default`))}function Fi({models:e,model:t,effortOptions:n,effort:r}){return{modelLabel:e.find(e=>e.id===t)?.label??`auto`,effortLabel:n.find(e=>e.value===r)?.label??`auto`}}function Ii(e){let t=N(),n=dn(e).continueRun,r=M(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),[c,u]=(0,Q.useState)(null),d=`${e.id}:${Et(e,mn(e))?.id??``}`,[f,p]=(0,Q.useState)(d);f!==d&&(p(d),a(null),s(null),u(null));let m=Ai(e,i),{runners:h,canContinue:g,currentRunner:_,runner:v}=m,{sessionStep:y,workerStep:b,account:x}=Mi(e,v,v!==_,yn().repoAccount),S=I(),w=S.data?.capabilities?.localHandoff!==!1,T=re(),E=P(v,n&&!S.isPending&&!T.isPending,w?x:null),D=r.data?.modelsLocked===!0,ee=v!==_,O=ji(e,v,ee,D,r.data,E.data,T.data,o,c),{models:k,model:A,effortOptions:te,effort:j}=O,{modelLabel:ne,effortLabel:ie}=Fi(O),F=L({mutationFn:({text:t,images:n})=>g?C(B(e.id),Ni(t,n,m.runnerOverride,D,ee,o,c,O)):Promise.reject(Error(m.reason??`Connect an agent provider to continue.`)),onMutate:()=>B(e.id),onSuccess:(e,n,r)=>t.invalidateAfter(`continue`,r),onError:(e,n,r)=>{e instanceof l&&e.status===409&&r&&t.invalidateAfter(`continue`,r)}}),R=e.delegation?.role===`worker`;return{skillRunner:v,skillAccount:x,available:n,canContinue:g,startsNewConversation:Pi(e,y,b,v),reason:m.reason,providerPending:m.providerPending,pills:(0,$.jsx)(`div`,{"data-slot":`follow-up-engine`,className:`session-engine-controls`,children:(0,$.jsxs)(Lt,{children:[!R&&(h.length>1||m.signedOut.length>0)?(0,$.jsx)(Vt,{icon:(0,$.jsx)(Ee,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:h,signedOut:m.signedOut,value:v,onPick:e=>{e!==v&&(a(e),s(null))}}):(0,$.jsx)(Jt,{icon:(0,$.jsx)(Ee,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,disabledHint:R?`Owned workers keep their runner; change model or effort instead.`:void 0,slot:`session-runner-value`,ariaLabel:`Runner`,label:v,value:v,onPick:()=>{},options:[{value:v,label:v}]}),(0,$.jsx)(Jt,{icon:(0,$.jsx)(Fe,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:ne,value:A,readOnly:D,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{s(e);let t=Ut(e,E.data);j!==``&&Gt(j,t)===``&&u(``)},options:k.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:rn(v,T.data,E)}),(0,$.jsx)(Jt,{icon:(0,$.jsx)(De,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:ie,value:j,readOnly:D,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>u(e),options:te.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})}),continueWith:(e,t)=>F.mutateAsync({text:e,images:t})}}var Li=120,Ri=e=>e!==`pending`&&e!==`running`,zi=e=>e.kind===`tool`&&e.toolKind===`task`,Bi=e=>zi(e)&&e.parentItemId===void 0,Vi=e=>ir(e.kind)&&!(e.kind===`tool`&&e.toolKind===`plan`);function Hi(e){let t=e.input;if(typeof t!=`object`||!t)return;let n=t;for(let e of[`subagent_type`,`subagentType`,`agent`]){let t=n[e];if(typeof t==`string`&&t.trim()!==``)return t.trim()}}function Ui(e){if(e.kind===`tool`)return Wi(e.title);if(e.kind===`hook`)return Wi(`${e.event} hook${e.status===`completed`?``:` ${e.status}`}`);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
6
- `);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return Wi(n)}}}function Wi(e){return e.length>Li?`${e.slice(0,Li-1).trimEnd()}…`:e}function Gi(e,t=!1,n=e){let r=Yi(e,e=>e.items.some(Bi));if(r===-1)return[];let i=e=>!t&&!Ri(e.status),a=e=>i(e)&&e.background===!0,o=[],s=!1;for(let t=r-1;t>=0;--t){let n=e[t].items.filter(Bi);n.length!==0&&(!s&&!n.some(i)&&(s=!0),(!s||n.some(a))&&o.unshift(...n))}let c=[...o,...e[r].items.filter(Bi)];return r!==e.length-1&&!c.some(i)?[]:c.map(r=>Ki(r,$i(n,e,r.id),t))}function Ki(e,t,n){let r={id:e.id,title:fr(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=Hi(e);i!==void 0&&(r.agentType=i),n&&!Ri(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=Ui(t[e]);if(n!==void 0){r.activity=n;break}}return r}function qi(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function Ji(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function Yi(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function Xi(e,t,n=!1,r=e){for(let i=e.length-1;i>=0;--i){let a=e[i].items.find(e=>e.id===t&&Bi(e));if(a!==void 0)return Ki(a,$i(r,e,t),n)}}function Zi(e,t){return Yi(e,e=>e.items.some(e=>e.id===t&&Bi(e)))}function Qi(e,t,n){let r=[];for(let i=n;i<e.length;i+=1){let n=e[i];for(let e of n.items)Vi(e)&&e.parentItemId===t&&e.id!==t&&r.push({entry:e,seqs:n.itemSeqs?.get(e.id)})}return r}function $i(e,t,n){let r=Zi(t,n);if(r===-1)return[];let i=Qi(t,n,r);if(e===t)return i.map(({entry:e})=>e);let a=t[r].itemSeqs?.get(n)?.first,o=e=>a===void 0||e.seqs===void 0||e.seqs.first>a,s=new Map;for(let t of Qi(e,n,Math.max(Zi(e,n),0)))o(t)&&!s.has(t.entry.id)&&s.set(t.entry.id,t);for(let e of i){let t=s.get(e.entry.id);s.set(e.entry.id,t===void 0?e:ea(t,e))}return[...s.values()].sort(ta).map(({entry:e})=>e)}function ea(e,t){return e.seqs===void 0||t.seqs===void 0?e:{entry:(t.seqs.last>e.seqs.last?t:e).entry,seqs:{first:Math.min(e.seqs.first,t.seqs.first),last:Math.max(e.seqs.last,t.seqs.last)}}}function ta(e,t){return e.seqs===void 0||t.seqs===void 0?0:e.seqs.first-t.seqs.first}function na(e,t){if(e.kind===`entry`){let n=e.entry;return n.kind===`message`&&n.role===`assistant`?[{messageKey:`${t}:${n.id}`,text:n.text}]:[]}return e.kind===`tool-card`?mr(e.children).flatMap(n=>na(n,`${t}:${e.id}`)):e.kind===`streak`?e.blocks.flatMap(e=>na(e,t)):[]}function ra(e){return e.flatMap((e,t)=>e.content.kind===`block`?na(e.content.block,e.scope).map(n=>({...n,rowKey:e.key,rowIndex:t})):[])}function ia(e,t,n,r){let i=(0,Q.useContext)(bn),{projectId:a}=le(),o=(0,Q.useMemo)(()=>ra(t),[t]);(0,Q.useLayoutEffect)(()=>{if(!i)return;let t=[],s={runId:e,...a?{projectId:a}:{}};for(let e of o){let a=$n(e.text,s);for(let e of a)t.push(i.register(e.artifactId,e.runId));r===`document`&&a.length>0&&t.push(i.registerOpener(e.messageKey,(t,r)=>{let i=er(e.messageKey,t);n.jumpToRow(e.rowKey,e.rowIndex,e=>[...e.querySelectorAll(`[id]`)].find(e=>e.id===i)??null,r)}))}return()=>{for(let e of t)e()}},[i,o,e,a,r,n.jumpToRow])}function aa(e){let t=v();return L({mutationFn:t=>b(e,t),retry:!1,networkMode:`always`,onSettled:()=>{t.invalidateQueries({queryKey:A.runs.all})}})}var oa=e=>(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}),sa=()=>navigator.onLine;function ca({permission:e,runId:t,sessionOpen:n=!1}){return e.status!==`pending`||!n?(0,$.jsx)(ua,{permission:e,state:e.status===`resolved`?`resolved`:`expired`}):(0,$.jsx)(la,{permission:e,runId:t},e.requestId)}function la({permission:e,runId:t}){let n=aa(t),r=(0,Q.useSyncExternalStore)(oa,sa,()=>!1),i=(0,Q.useRef)(!1),[a,o]=(0,Q.useState)(`pending`),[s,c]=(0,Q.useState)(),[u,d]=(0,Q.useState)(),f=async t=>{if(!(i.current||!r||a!==`pending`)){i.current=!0,o(`sending`),d(void 0);try{await n.mutateAsync({requestId:e.requestId,optionId:t}),c(t),o(`resolved`)}catch(e){e instanceof l&&e.status===409?o(`expired`):(d(e instanceof Error?e.message:String(e)),o(`pending`))}finally{i.current=!1}}};return(0,$.jsx)(ua,{permission:{...e,...s===void 0?{}:{optionId:s}},state:a,offline:!r,error:u,onSelect:e=>{f(e)}})}function ua({permission:e,state:t,offline:n=!1,error:r,onSelect:i}){let a=(0,Q.useId)(),o=e.options.find(t=>t.id===e.optionId),s=t!==`pending`||n||!i,c=t===`expired`?`Approval expired. This session can no longer accept a decision.`:t===`resolved`?`Decision sent: ${o?.label??`Recorded`}.`:t===`sending`?`Sending decision…`:n?`Offline. Reconnect to send a decision.`:`Choose an option to respond to this permission request.`;return(0,$.jsxs)(`section`,{"data-slot":`permission-card`,"data-request-id":e.requestId,"data-state":n&&t===`pending`?`offline`:t,"aria-labelledby":a,"aria-busy":t===`sending`,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 text-sm [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Permission request`}),(0,$.jsx)(`h3`,{id:a,className:`font-semibold whitespace-pre-wrap`,children:e.title})]}),e.details?(0,$.jsx)(`pre`,{className:`min-w-0 font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details}):null,(0,$.jsx)(`div`,{role:`group`,"aria-labelledby":a,className:`flex min-w-0 flex-col gap-2`,children:e.options.map(t=>(0,$.jsx)(K,{type:`button`,variant:`outline`,disabled:s,"aria-pressed":e.optionId===t.id,className:`h-auto min-h-11 min-w-0 max-w-full justify-start py-2 text-start whitespace-normal [overflow-wrap:anywhere] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>i?.(t.id),children:t.label},t.id))}),(0,$.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[c,e.reason?` ${e.reason}`:``]}),r&&t===`pending`?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r}):null]})}function da(e,t){if(e.length===1)return[t.replace(RegExp(`^${fa(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function fa(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function pa(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}function ma({ask:e}){let t=e.answer===void 0?void 0:da(e.questions,e.answer);return(0,$.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((n,r)=>{let i=t?.[r],a=pa(n,i),o=i!==void 0&&a.length===0;return(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":n.question,children:[(0,$.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[n.header,` · Question `,r+1,` of `,e.questions.length]}),(0,$.jsx)(`p`,{className:`break-words font-semibold`,children:n.question}),n.options?(0,$.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[n.options.map(e=>(0,$.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,$.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,$.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,$.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,$.jsx)(ha,{text:i}):null]})]}):i===void 0?null:(0,$.jsx)(ha,{text:i})]},n.id??r)}),!t&&e.answer!==void 0?(0,$.jsx)(ha,{text:e.answer}):null]})}function ha({text:e}){return(0,$.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}var ga=(0,Q.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function _a(e,t){let n={};for(let e of t??[])n[e.id]=e.currentStepBackend??e.runner;return n[e.id]=e.steps.find(t=>t.id===e.currentStepId)?.backend??e.runner,n}function va(e,t,n=[]){let r={};for(let e of n)r[e.id]=Z(e);for(let e of t??[])r[e.id]=Z(e);return r[e.id]=Z(e),r}function ya(e,t){return t?.[e]??`Task`}function ba(e,t,n){return t?n?.[e]??`peer task`:ya(e,n)}function xa(e,t){return e.senderRunId===t?`outbound`:`inbound`}function Sa(e){return e?.relationship===`peer`}function Ca(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`}}function wa(e){switch(e){case`pending`:return`Pending`;case`replied`:return`Replied`;case`replied-late`:return`Replied late`;case`timed-out`:return`Timed out`;case`cancelled`:return`Cancelled`;case`completed-without-reply`:return`Completed without reply`;case`failed`:return`Failed`;case`destroyed`:return`Destroyed`;case`sender-closed`:return`Sender closed`;case`human-fallback`:return`Sent to a human`;case`deleted`:return`Recipient deleted`}}function Ta(e){if(e.outcome)return wa(e.outcome.status);if(e.delivery===`not-delivered`)return Ea(`not-delivered`)}function Ea(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`}}function Da(e,t){return e.instruction===void 0?e.delivery===`queued`?`${t?`Queued for delivery. This agent can receive messages during its current turn.`:`Queued for delivery. Timing depends on the recipient agent.`} Pending messages are batched within the size limit; human questions and scheduler capacity can delay delivery.`:e.state===`continuation-required`?Sa(e)?`Not delivered. The recipient is not running. Only its human can continue it.`:`Not delivered. The recipient needs a new instruction to resume. A parent can resume its owned worker with ${gn()} worker resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0:e.instruction}function Oa({id:e,peer:t,taskTitles:n,children:r}){return!t||n?.[e]!==void 0?r({title:ya(e,n),linkable:!0}):(0,$.jsx)(ka,{id:e,children:r})}function ka({id:e,children:t}){let n=O(e);return n.data?t({title:Z(n.data),linkable:!0}):n.isPending?t({title:`Peer task`,linkable:!1}):t({title:n.error instanceof l&&n.error.status===404?`Deleted task`:`Task unavailable`,linkable:!1})}var Aa={outbound:{classes:`border-message-outbound-border bg-message-outbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-outbound-accent`,accent:`text-message-outbound-accent`},inbound:{classes:`border-message-inbound-border bg-message-inbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-inbound-accent`,accent:`text-message-inbound-accent`},peer:{classes:`border-message-peer-border bg-message-peer-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-peer-accent`,accent:`text-message-peer-accent`}},ja=`inline-flex min-h-11 max-w-full items-center break-words underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;function Ma({block:e,runId:t,taskTitles:n,recipientBackends:r}){return(0,$.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,$.jsx)(Na,{batch:e,runId:t,taskTitles:n,recipientBackends:r},e.id))})}function Na({batch:e,runId:t,taskTitles:n,recipientBackends:r}){let i=xa(e.messages[0]??{senderRunId:e.senderRunId},t),a=Sa(e.messages[0]),s=Aa[a?`peer`:i],c=Ha(e.messages.map(e=>i===`outbound`?e.recipientRunId:e.senderRunId)),l=i===`outbound`?`SENT to`:`RECEIVED from`,u=`${l} ${c.map(e=>ba(e,a,n)).join(`, `)}`,d=e.messages[0],f=d?.createdAt??d?.recordedAt;return(0,$.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":i,"data-relationship":a?`peer`:`family`,"data-kind":e.kind,className:o(`flex w-full min-w-0 flex-col gap-2 rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes),children:[(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`p`,{className:o(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,$.jsx)(`span`,{children:l}),c.map((e,t)=>(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,$.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,$.jsx)(Oa,{id:e,peer:a,taskTitles:n,children:t=>(0,$.jsx)(Ra,{view:t,to:`/tasks/${e}`,label:`${l} ${t.title}`})})]},e))]}),a?(0,$.jsx)(`span`,{"data-slot":`conversation-relationship`,className:`rounded-full border border-message-peer-border px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Peer`}):null,(0,$.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:Ca(e.kind)}),e.messages.length===1&&d?(0,$.jsx)(Fa,{message:d}):null]}),(0,$.jsx)(Pa,{at:f,className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-[11px] text-soft-foreground`,children:e.messages.length>1?`First sent`:null})]}),(0,$.jsx)(La,{batch:e},`${t}:${d?.messageId??e.id}`),[...new Set(e.messages.map(e=>Da(e,r?.[e.recipientRunId])))].map(e=>e?(0,$.jsx)(`p`,{"data-slot":`conversation-delivery-explanation`,className:`min-w-0 text-xs leading-relaxed text-muted-foreground [overflow-wrap:anywhere]`,children:e},e):null),e.kind===`request`&&e.messages.length>1?(0,$.jsx)(Ia,{messages:e.messages,peer:a,runId:t,taskTitles:n}):null,e.messages.length===1&&d?(0,$.jsx)(za,{message:d,runId:t,taskTitles:n}):null,(0,$.jsx)(Ba,{batch:e,heading:u})]})}function Pa({at:e,className:t,children:n}){return e===void 0||zr(e)===void 0?null:(0,$.jsxs)(`span`,{className:t,children:[n,(0,$.jsx)(Gr,{ts:e})]})}function Fa({message:e}){let t=Ta(e),n=Ea(e.delivery),r=(e.messageKind===`request`||e.messageKind===`reply`)&&n!==t;return(0,$.jsxs)($.Fragment,{children:[t?(0,$.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:t}):null,r?(0,$.jsx)(`span`,{"data-slot":`conversation-delivery`,className:`text-xs text-muted-foreground`,children:n}):null]})}function Ia({messages:e,peer:t,runId:n,taskTitles:r}){return(0,$.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.map(e=>{let i=Ta(e),a=e.createdAt??e.recordedAt;return(0,$.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(Oa,{id:e.recipientRunId,peer:t,taskTitles:r,children:t=>(0,$.jsx)(Ra,{view:t,to:`/tasks/${e.recipientRunId}`,label:`${t.title}${i?` — ${i}`:``}`})}),i?(0,$.jsx)(`span`,{"data-slot":`conversation-outcome`,children:i}):null,Ea(e.delivery)===i?null:(0,$.jsx)(`span`,{"data-slot":`conversation-delivery`,children:Ea(e.delivery)}),(0,$.jsx)(za,{message:e,runId:n,taskTitles:r}),(0,$.jsx)(Pa,{at:a,className:`ml-auto whitespace-nowrap`})]},e.id)})})}function La({batch:e}){let t=yr(),n=`conversation-body:${e.messages[0]?.messageId??e.id}`,[r,i]=(0,Q.useState)(()=>t?.get(n)??!1),a=(0,$.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,$.jsx)(kn,{breaks:!0,children:e.text})});return e.kind!==`request`&&e.kind!==`reply`?a:(0,$.jsxs)(Y,{"data-slot":`conversation-body`,open:r,onOpenChange:e=>{t?.set(n,e),i(e)},className:`min-w-0`,children:[(0,$.jsxs)(J,{type:`button`,"data-slot":`conversation-body-toggle`,className:`group/body inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-start text-xs font-medium text-muted-foreground [@media(hover:hover)_and_(pointer:fine)]:hover:bg-background/40 [@media(hover:hover)_and_(pointer:fine)]:hover:text-foreground active:bg-background/60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,$.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 group-data-[state=open]/body:rotate-90`}),r?`Hide message`:`Show message`]}),(0,$.jsx)(q,{children:a})]})}function Ra({view:e,to:t,label:n}){return e.linkable?(0,$.jsx)(X,{className:ja,to:t,"aria-label":n,children:e.title}):(0,$.jsx)(`span`,{"data-slot":`conversation-counterpart`,children:e.title})}function za({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:a}=(0,Q.useContext)(ga),s=e.requestId?r.get(e.requestId):void 0,c=e.requestId?s?[s]:[]:i.get(e.messageId)??[],l=e.requestId?`request`:`reply`;return c.length===0?e.requestId||e.outcome?.replyId?(0,$.jsxs)(`p`,{"data-slot":`conversation-connector`,className:`text-xs text-muted-foreground`,children:[`Linked `,l,` is outside loaded history.`]}):null:c.map(e=>{let r=xa(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:o(ja,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>a(e),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),(0,$.jsx)(Oa,{id:i,peer:Sa(e.message),taskTitles:n,children:e=>(0,$.jsxs)($.Fragment,{children:[`View `,l,` `,r?`to`:`from`,` `,e.title]})})]},e.message.messageId)})}function Ba({batch:e,heading:t}){return(0,$.jsxs)(Y,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,$.jsxs)(J,{type:`button`,className:`inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-left text-xs font-medium text-muted-foreground hover:bg-background/40 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,$.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,$.jsx)(q,{children:(0,$.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-[11px] text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>Va(e)).map((e,t)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,$.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function Va(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},...Sa(e)?[{label:`Relationship`,value:`peer`}]:[],{label:`Delivery`,value:Ea(e.delivery)}];return e.requestId&&t.push({label:`Request`,value:e.requestId}),e.outcome?.replyId&&t.push({label:`Reply`,value:e.outcome.replyId}),e.state&&t.push({label:`State`,value:e.state}),e.createdAt&&t.push({label:`Created`,value:e.createdAt}),e.deliveredAt&&t.push({label:e.resumed?`Opening turn completed`:`Delivery acknowledged`,value:e.deliveredAt}),e.recordedAt&&t.push({label:`Event recorded`,value:e.recordedAt}),e.resumed&&t.push({label:`Continuation`,value:`Requested by parent with this instruction`}),e.deadline&&t.push({label:`Deadline`,value:e.deadline}),e.requestHash&&t.push({label:`Hash`,value:e.requestHash}),t}function Ha(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var Ua=e(n(),1),Wa=`pending-ask`;function Ga(e){return e.querySelector(`[data-slot="ask-question"] :is(button, textarea):not(:disabled)`)||(e.tabIndex=-1,e)}function Ka(e){let t=e.querySelector(`[data-slot="ask-card"][data-pinned="true"]`);return t?Ga(t):null}function qa(e,t){let n=`${Wa}:${e}`;return e=>{if(!t())return!1;let r=[...e.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===n);return r?Ka(r):null}}function Ja(e){return e<=0?`Jump to latest`:`Jump to latest (${e} ${e===1?`question`:`questions`} pending)`}function Ya({onGoToQuestion:e}){return(0,$.jsxs)(`div`,{"data-slot":`ask-origin`,className:`flex flex-wrap items-center gap-x-2 rounded-lg border border-dashed border-accent-strong/40 px-3.5 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium text-link-foreground`,children:`Question asked here`}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-go-to-question`,className:`min-h-11 min-w-11 px-2 text-foreground underline underline-offset-4`,onClick:e,children:`Go to the question`})]})}var Xa={viewKey:void 0,generation:0},Za=600,Qa=24;function $a(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,Q.useRef)(e);o.current=e;let c=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),p=(0,Q.useRef)(!0),m=(0,Q.useRef)(0),h=(0,Q.useRef)(0),g=(0,Q.useRef)(new Set),_=(0,Q.useCallback)(e=>{for(let t of[...g.current])t(e)},[]),v=(0,Q.useCallback)(e=>(g.current.add(e),()=>{g.current.delete(e)}),[]),y=(0,Q.useRef)(null),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),C=(0,Q.useCallback)(e=>{let t=c.current;if(!t)return;let n=S.current;n?n.scrollTo(e):t.scrollTop=e},[]),w=(0,Q.useCallback)(()=>{let e=c.current;e&&C(e.scrollHeight-e.clientHeight)},[C]),T=(0,Q.useCallback)(()=>{if(c.current){if(x.current!==e){x.current=e;let t=Or(e);t&&!t.atBottom?(p.current=!1,y.current=t.top,b.current=jr(e)?.rowKeys?{viewKey:e,top:t.top}:null):(p.current=!0,y.current=null,b.current=null)}y.current===null?p.current&&w():C(y.current)}},[e,C,w]),E=(0,Q.useCallback)(e=>b.current?.viewKey===e,[]),D=(0,Q.useCallback)(e=>{let t=b.current;return!t||!E(e)||e!==o.current?!1:(y.current=t.top,p.current=!1,b.current=null,!0)},[E]),ee=(0,Q.useCallback)(e=>{u(e),e&&(c.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="main"]`),T())},[n,T]),O=(0,Q.useCallback)(()=>{p.current&&w()},[w]),k=(0,Q.useRef)(!1),A=(0,Q.useRef)(0),te=(0,Q.useRef)(!1),j=(0,Q.useRef)(void 0),ne=(0,Q.useRef)(!1),re=(0,Q.useRef)(!1),M=(0,Q.useRef)(a);M.current=a;let ie=(0,Q.useCallback)(e=>[...e.querySelectorAll(`[data-slot="thread-row"][data-row-key]`)].map(e=>{let t=e.getBoundingClientRect();return{key:e.dataset.rowKey,top:t.top,bottom:t.bottom}}),[]),N=(0,Q.useRef)(null),P=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(!s())return;let e=e=>{y.current=null,b.current=null,P.current+=1,N.current=null,p.current=!1,C(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[C]);let F=(0,Q.useCallback)(()=>{let e=N.current,t=c.current;if(!e||!t)return;N.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:M.current.indexOf(e.anchor.key),a=S.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):C(Cr(t.scrollTop,r,e.anchor,ie(t),n))},[ie,C]),I=(0,Q.useCallback)(()=>{let e=c.current;if(!e||!r||k.current)return;y.current=null,b.current=null,p.current=!1,k.current=!0;let t=A.current+1;A.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,s=Sr(a,ie(e)),l=s===void 0?-1:M.current.indexOf(s.key),u=o.current,d=P.current;r().then(()=>{o.current===u&&P.current===d&&(N.current={beforeHeight:n,beforeTop:i,anchor:s,anchorIndex:l})},()=>{}).finally(()=>{A.current===t&&(k.current=!1)})},[ie,r]);(0,Q.useEffect)(()=>()=>clearTimeout(j.current),[]);let L=(0,Q.useRef)(null),R=(0,Q.useRef)(0),z=(0,Q.useCallback)(()=>n===`document`?++Xa.generation:++R.current,[n]),B=(0,Q.useCallback)((e,t)=>n===`document`?Xa.viewKey===e&&Xa.generation===t:o.current===e&&R.current===t,[n]);(0,Q.useEffect)(()=>()=>L.current?.disconnect(),[e,l]);let ae=(0,Q.useCallback)((t,n,r,i)=>{let a=c.current;if(!a||!l)return;y.current=null,b.current=null,P.current+=1,N.current=null,p.current=!1,m.current=0,f(!0),z(),L.current?.disconnect();let o=()=>[...l.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),s=()=>{let e=o();if(!e||getComputedStyle(e).visibility===`hidden`)return!1;let t=r?.(e)??e;return t===e&&(e.tabIndex=-1),t.focus({preventScroll:!0}),document.activeElement===t?(L.current?.disconnect(),!0):!1},u=a.querySelector(`[data-slot="run-header"]`),d=u&&getComputedStyle(u).position===`sticky`?u.getBoundingClientRect().height:0,h=S.current;if(i!==void 0)C(i);else if(h)h.scrollToIndex(n,{align:`start`,...d>0?{offset:-d}:{}});else{let e=o();e&&C(a.scrollTop+e.getBoundingClientRect().top-a.getBoundingClientRect().top-d)}s()||(L.current=new MutationObserver(()=>{s()}),L.current.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),Dr(e,{top:i??a.scrollTop,atBottom:!1})},[l,C,e,z]),oe=(0,Q.useCallback)(t=>{let n=z(),r=o.current;L.current?.disconnect();let a=c.current;if(!a)return;y.current=null,b.current=null,P.current+=1,N.current=null,p.current=!0,h.current=0,_({direction:`tail`}),Dr(e,{top:a.scrollHeight-a.clientHeight,atBottom:!0});let s=()=>{p.current&&w()},l=()=>B(r,n),u=()=>{let e=t?.(a);return e===!1?!0:e?(e.focus({preventScroll:!0}),document.activeElement===e):!1};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{s(),requestAnimationFrame(()=>{if(s(),!t||!l()||u())return;L.current?.disconnect();let e=new MutationObserver(()=>{l()?u()&&e.disconnect():e.disconnect()});L.current=e,e.observe(a,{childList:!0,subtree:!0})})})})},[i,e,w,z,B,_]),V=a.at(-1),se=a.length;return(0,Q.useLayoutEffect)(()=>{P.current+=1,N.current=null,k.current=!1,n===`document`?Xa.viewKey!==e&&(Xa.viewKey=e,Xa.generation+=1):R.current+=1},[e,n]),(0,Q.useLayoutEffect)(()=>{let e=N.current;e?(e.anchor===void 0?-1:M.current.indexOf(e.anchor.key))>e.anchorIndex?F():N.current=null:p.current&&w()},[V,se,F,w]),(0,Q.useLayoutEffect)(()=>{!c.current||!l||T()},[l,T]),(0,Q.useEffect)(()=>{let t=c.current,n=l;if(!t||!n)return;m.current=0;let r=null,i=!1,a=t.scrollTop,o,s=0,u,d=e=>{h.current=Date.now(),u=e},g=()=>{z(),L.current?.disconnect(),y.current=null,b.current=null,P.current+=1,N.current=null,p.current=!1,m.current=0},v=()=>{y.current=null,b.current=null,P.current+=1,N.current=null,m.current=Date.now()},x=e=>{if(e.deltaY!==0)if(d(e.deltaY<0?`up`:`down`),e.deltaY<0){g();let e=!te.current;te.current=!0,clearTimeout(j.current),j.current=setTimeout(()=>{te.current=!1},180),e&&xr(t)&&I()}else v()},S=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(d(`up`),g(),!e.repeat&&xr(t)&&I()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&(d(`down`),v())},T=e=>{if(e.target!==t||e.button!==0||e.pointerType===`touch`||e.pointerType===`pen`||t.scrollHeight<=t.clientHeight)return;i=!0,re.current=!1,a=t.scrollTop;let n=t.getBoundingClientRect(),r=getComputedStyle(t),o=parseFloat(r.borderLeftWidth)||0,s=parseFloat(r.borderRightWidth)||0,c=n.left+t.clientLeft,l=c+t.clientWidth;!(e.clientX>=n.left+o&&e.clientX<c||e.clientX>=l&&e.clientX<n.right-s)||e.clientY<n.top+t.clientTop||e.clientY>=n.top+t.clientTop+t.clientHeight||(y.current=null,b.current=null,wr(t,80)||(g(),v()))},D=()=>{i=!1},ee=e=>{ne.current=!1,r=e.touches[0]?.clientY??null},O=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(d(`up`),g(),!ne.current&&xr(t)&&(ne.current=!0,I())):r!==null&&n<r-1&&(d(`down`),v()),r=n)},k=e=>{if(e===0||!i&&Date.now()-h.current>=Za)return;let n=e<0?`up`:`down`;!i&&n!==u||(n!==o&&(o=n,s=0),s+=Math.abs(e),s>=Qa&&(0,Ua.flushSync)(()=>_({direction:n,distanceFromBottom:t.scrollHeight-t.clientHeight-t.scrollTop})))},A=()=>{let n=p.current;k(t.scrollTop-a),i&&t.scrollTop!==a&&(t.scrollTop<a?g():v()),i&&!re.current&&t.scrollTop<a&&xr(t)&&(re.current=!0,I()),a=t.scrollTop;let r=wr(t,80);r&&y.current===null&&(p.current||Date.now()-m.current<2e3)&&(p.current=!0),!n&&p.current&&_({direction:`tail`}),f(!r),y.current===null&&!E(e)&&Dr(e,{top:t.scrollTop,atBottom:r})};t.addEventListener(`scroll`,A,{passive:!0}),t.addEventListener(`wheel`,x,{passive:!0}),t.addEventListener(`touchstart`,ee,{passive:!0}),t.addEventListener(`touchmove`,O,{passive:!0}),t.addEventListener(`pointerdown`,T,{passive:!0}),window.addEventListener(`pointerup`,D,{passive:!0}),window.addEventListener(`pointercancel`,D,{passive:!0}),t.addEventListener(`keydown`,S);let M;if(typeof ResizeObserver<`u`){M=new ResizeObserver(()=>{let e=y.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;C(Math.min(e,n)),n>=e&&(y.current=null)}else p.current&&w()}),M.observe(n);let e=n.closest(`[data-route="task-thread"]`),r=e?.querySelector(`[data-slot="run-header"]`),i=e?.querySelector(`[data-slot="thread-dock"]`);r&&M.observe(r),i&&M.observe(i)}return()=>{t.removeEventListener(`scroll`,A),t.removeEventListener(`wheel`,x),t.removeEventListener(`touchstart`,ee),t.removeEventListener(`touchmove`,O),t.removeEventListener(`pointerdown`,T),window.removeEventListener(`pointerup`,D),window.removeEventListener(`pointercancel`,D),t.removeEventListener(`keydown`,S),M?.disconnect()}},[e,l,I,C,w,E,z,_]),{attachContent:ee,scrollElRef:c,virtualizerRef:S,restoreMeasurements:D,ownsMeasurementRestore:E,pillVisible:d,jumpToLatest:oe,jumpToRow:ae,loadOlder:I,restickIfStuck:O,subscribeReaderScroll:v}}function eo({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,$.jsx)(to,{runId:e,rows:t,controls:r}):(0,$.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,$.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5 [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`,children:e.node},e.key))})}function to({runId:e,rows:t,controls:n}){return(0,$.jsx)(no,{runId:e,rows:t,controls:n},e)}function no({runId:e,rows:t,controls:n}){let r=(0,Q.useRef)(null),i=(0,Q.useRef)(t),a=t[0]?.key,o=i.current[0]?.key,s=a!==o&&(t.some(e=>e.key===o)||i.current.some(e=>e.key===a));(0,Q.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,Q.useState)(()=>jr(e)),[l,u]=(0,Q.useState)(()=>({cache:Mr(e,t.length,t.map(e=>e.key)),generation:0})),d=(0,Q.useRef)(l.cache===void 0&&c?.rowKeys?.length===c?.rows&&c!==void 0);(0,Q.useLayoutEffect)(()=>{let r=c?.rowKeys;if(!d.current){n.restoreMeasurements(e);return}if(!(!c||!r)){if(t.length>c.rows||t.some((e,t)=>e.key!==r[t])){d.current=!1,n.restoreMeasurements(e);return}t.length===c.rows&&(d.current=!1,n.restoreMeasurements(e)&&u({cache:c.cache,generation:1}))}},[c,t,n.restoreMeasurements,e]);let f=(0,Q.useRef)(t.length);f.current=t.length;let p=(0,Q.useRef)(t.map(e=>e.key));p.current=t.map(e=>e.key);let m=(0,Q.useRef)(null),h=(0,Q.useCallback)(t=>{n.virtualizerRef.current=t,t?m.current=t:m.current&&=(d.current&&c?.rowKeys&&f.current<c.rows&&n.ownsMeasurementRestore(e)||Ar(e,{rows:f.current,cache:m.current.cache,rowKeys:p.current}),null)},[e,n.virtualizerRef,n.ownsMeasurementRestore,c]),[g,_]=(0,Q.useState)(0);return(0,Q.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||_(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n.scrollElRef]),(0,$.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,$.jsx)(pn,{ref:h,scrollRef:n.scrollElRef,startMargin:g,shift:s,...l.cache===void 0?{}:{cache:l.cache},children:t.map(e=>(0,$.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))},l.generation)})}function ro({onJump:e,pendingQuestions:t=0}){return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,"data-pending-questions":t>0?t:void 0,onClick:()=>e(),className:`pointer-events-auto inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-modal hover:text-foreground`,children:[(0,$.jsx)(Ae,{"aria-hidden":!0,className:`size-3.5`}),Ja(t)]})}function io(e){return e.consumedAt?`consumed`:e.deliveredAt?`delivered`:`queued`}function ao(e,t){let n=new Map((e.agentInputs??[]).map(e=>[e.id,io(e)]));if(n.size===0)return t;let r=!1,i=t.map(e=>{if(e.kind!==`note`||!e.id.startsWith(`agent-input:`))return e;let t=n.get(e.id.slice(12));return!t||e.delivery===t?e:(r=!0,{...e,delivery:t})});return r?i:t}function oo(e,t,n){return e.kind===`ask`?e.id===t?n===void 0?e:{...e,placement:`origin`}:e.resolved?e:{...e,resolved:!0}:e}var so=new WeakMap;function co(e,t){let n=so.get(e);return n?.length===t.length&&t.every((e,t)=>{let r=n[t];return e===r||Object.keys(e).length===Object.keys(r).length&&Object.entries(e).every(([e,t])=>t===r[e])})?n:(so.set(e,t),t)}function lo(e,t,n=t,r){let i=r==null?void 0:n.turns.flatMap(e=>e.items).find(e=>e.kind===`ask`&&e.id===r&&!e.resolved),a=new Map(n.turns.flatMap(e=>e.items).filter(e=>e.kind===`permission`).map(e=>[e.requestId,e])),o=new Set,s=new Set(t.turns.map(e=>e.userMessage?.ask?.id)),c=[];e.task&&c.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])c.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});for(let n of t.turns)c.push({id:n.id,userMessageKey:`${n.id}:user`,...n.userMessage===void 0?{}:{userMessage:{text:n.userMessage.text,ask:n.userMessage.ask,imageCount:n.userMessage.imageCount,images:n.userMessage.images,...n.userMessage.ts===void 0?{}:{ts:n.userMessage.ts}}},...n.startedAt===void 0?{}:{startedAt:n.startedAt},...n.completed?.ts===void 0?{}:{completedAt:n.completed.ts},entries:co(n.items,ao(e,n.items.filter(t=>!e.task||!lt(t,`opening`)).map(e=>e.kind===`ask`&&s.has(e.id)?{...e,placement:`origin`}:r!==void 0&&e.kind===`ask`?oo(e,r,i):e.kind===`permission`?(o.add(e.requestId),a.get(e.requestId)??(e.status===`pending`?{...e,status:`expired`}:e)):e)))});let l=[...a.values()].filter(e=>e.status===`pending`&&!o.has(e.requestId));return l.length>0&&c.push({id:`pending-permissions`,entries:l,inDaySequence:!1}),i!==void 0&&c.push({id:Wa,entries:[{...i,placement:`pinned`}],inDaySequence:!1}),c}function uo(e,t,n){let r=e.findIndex(({content:e})=>e.kind===`block`&&e.block.kind===`entry`&&e.block.entry.kind===`ask`&&e.block.entry.id===t&&e.block.entry.placement===n);return r<0?void 0:{key:e[r].key,index:r}}function fo(e,t){return[{id:`agent:${e}`,entries:t}]}function po(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function mo(e,t){let n=[],r;for(let t of e){let e=po(t),i=Hr(e);i!==void 0&&e!==void 0&&(r===void 0||i>r)&&(r!==void 0&&n.push({key:`${t.id}:day-separator`,scope:t.id,content:{kind:`day-separator`,ts:e}}),r=i),t.userMessage!==void 0&&n.push({key:t.userMessageKey??`${t.id}:user`,scope:t.id,content:{kind:`user-message`,message:t.userMessage}});for(let e of mr(t.entries))n.push({key:`${t.id}:${e.id}`,scope:t.id,content:{kind:`block`,block:e}});t.completedAt!==void 0&&n.push({key:`${t.id}:turn-time`,scope:t.id,content:{kind:`turn-time`,completedAt:t.completedAt,...t.startedAt===void 0?{}:{startedAt:t.startedAt}}})}return n}function ho({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,renderPermission:o,messageActions:s,scrollControls:c,renderMode:l,taskTitles:u,recipientBackends:d}){let f=(0,Q.useMemo)(()=>mo(n,e),[n,e]),p=$a(`${e}:${t}`,{surface:r}),m=c??p;ia(e,f,m,r);let h=(0,Q.useMemo)(()=>{let e=new Map;f.forEach((t,n)=>{if(!(t.content.kind!==`block`||t.content.block.kind!==`worker-conversation`))for(let r of t.content.block.batches)for(let i of r.messages)e.set(i.messageId,{message:i,rowKey:t.key,rowIndex:n})});let t=new Map;for(let n of e.values()){let{message:e}=n;if(e.messageKind!==`reply`||!e.requestId)continue;let r=t.get(e.requestId)??[];r.push(n),t.set(e.requestId,r)}return{targets:e,replies:t,navigate:e=>m.jumpToRow(e.rowKey,e.rowIndex)}},[f,m.jumpToRow]),g=(0,Q.useMemo)(()=>f.map(t=>({key:t.key,node:go(t,s?.[t.key],a,o,e,u,d)})),[s,a,o,f,e,u,d]),_=l??Tr(``,g.length),v=g.length===0?i??null:(0,$.jsx)(eo,{runId:`${e}:${t}`,rows:g,mode:_,controls:m});return(0,$.jsx)(Ve,{runId:e,children:(0,$.jsx)(br,{runId:e,children:(0,$.jsx)(ga.Provider,{value:h,children:r===`panel`?(0,$.jsxs)(`div`,{"data-slot":`transcript-viewport`,"aria-label":`Agent transcript`,role:`region`,tabIndex:0,className:`relative flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-gutter:stable]`,children:[(0,$.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:v}),m.pillVisible?(0,$.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,$.jsx)(ro,{onJump:m.jumpToLatest})}):null]}):v})})})}function go(e,t,n,r,i,a,o){switch(e.content.kind){case`user-message`:return(0,$.jsx)(_o,{message:e.content.message,actions:t});case`day-separator`:return(0,$.jsx)(qr,{ts:e.content.ts});case`turn-time`:return(0,$.jsx)(Kr,{completedAt:e.content.completedAt,...e.content.startedAt===void 0?{}:{startedAt:e.content.startedAt}});case`block`:return(0,$.jsx)(vo,{block:e.content.block,scope:e.scope,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o});default:return So(e.content)}}function _o({message:e,actions:t}){return(0,$.jsx)($r,{text:e.text,imageCount:e.imageCount,images:e.images,...e.ts===void 0?{}:{ts:e.ts},onEdit:t?.onEdit,onRemove:t?.onRemove,editLabel:t?.editLabel,removeLabel:t?.removeLabel,children:e.ask?(0,$.jsx)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,children:(0,$.jsx)(ma,{ask:e.ask})}):void 0})}function vo({block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`entry`:return(0,$.jsx)(Qn.Provider,{value:`${t}:${e.entry.id}`,children:(0,$.jsx)(bo,{entry:e.entry,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`tool-card`:return(0,$.jsx)(yi,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,$.jsx)(yo,{entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`context-group`:return(0,$.jsx)(Si,{group:e,scope:t});case`streak`:return(0,$.jsx)(Ci,{count:e.count,children:e.blocks.map(e=>(0,$.jsx)(vo,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))});case`worker-conversation`:return(0,$.jsx)(Ma,{block:e,runId:i,taskTitles:a,recipientBackends:o});default:return So(e)}}function yo({entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){return mr(e).map(e=>(0,$.jsx)(vo,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))}function bo({entry:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`message`:return e.role===`assistant`?(0,$.jsx)(ii,{text:e.text,ts:e.ts}):(0,$.jsx)($r,{text:e.text,ts:e.ts});case`reasoning`:return(0,$.jsx)(oi,{text:e.text});case`tool`:return(0,$.jsx)(yi,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return e.attribution?(0,$.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,$.jsxs)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:[e.attribution.source===`agent`?`Agent input from parent ${e.attribution.parentRunId}`:`Worker lifecycle context for parent ${e.attribution.parentRunId}`,e.delivery?` · ${Ea(e.delivery)}`:``]}),(0,$.jsx)(Yr,{note:e})]}):(0,$.jsx)(Yr,{note:e});case`conversation`:return(0,$.jsx)(Ma,{runId:i,taskTitles:a,recipientBackends:o,block:{kind:`worker-conversation`,id:e.id,batches:[{id:e.id,kind:e.messageKind,text:e.text,senderRunId:e.senderRunId,messages:[e]}]}});case`image`:return(0,$.jsx)(wi,{image:e});case`ask`:return n===void 0?(0,$.jsx)(`div`,{"data-slot":`ask-card`,className:`rounded-lg border border-border bg-card px-4 py-3 text-sm`,children:`The agent asked a question. Open the main session to answer it.`}):n(e);case`permission`:return r?r(e):(0,$.jsx)(ca,{permission:e,runId:i});case`provider-auth-required`:return(0,$.jsx)(ai,{incident:e});case`preview-server`:return(0,$.jsx)(xo,{entry:e});case`hook`:return(0,$.jsx)(xi,{item:e,cacheKey:`${t}:${e.id}`});default:return So(e)}}function xo({entry:e}){let t=on(),n=I().data?.capabilities?.preview===!0;return(0,$.jsx)(dt,{entry:t?.worktreeRemoved?{kind:`preview-server`,id:e.id,server:e.server,state:`unavailable`}:e,inPreview:t!==null&&t.open&&t.port===e.server.port,onOpen:t!==null&&n?t.openPane:void 0})}function So(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function Co({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,onClose:a,taskTitles:o,recipientBackends:s}){let c=(0,Q.useContext)(bn),l=(0,Q.useRef)(void 0),u=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>()=>{l.current?.()},[c,e]),(0,$.jsx)(It,{open:r!==void 0,onOpenChange:e=>{e||a()},children:(0,$.jsx)(zt,{"data-slot":`subagent-sheet`,side:`right`,onCloseAutoFocus:e=>{u.current&&=(e.preventDefault(),!1)},className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:r===void 0?null:(0,$.jsx)(Zn.Provider,{value:e=>{let t=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===r?.id);l.current?.(),l.current=c?.registerOpener(e,()=>{t?.focus({preventScroll:!0})}),u.current=!0,a()},children:(0,$.jsx)(wo,{runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:o,recipientBackends:s})})})})}function wo({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:a,recipientBackends:o}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Kt,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,$.jsxs)(Sn,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r.title}),r.agentType===void 0?null:(0,$.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:r.agentType})]}),(0,$.jsxs)(Ht,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(To,{status:r.status}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[r.toolCalls,` `,r.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,$.jsx)(ho,{runId:e,viewId:`agent:${r.id}`,sections:fo(r.id,i),mode:`panel`,renderAsk:t,renderPermission:n,taskTitles:a,recipientBackends:o,empty:(0,$.jsx)(`div`,{"data-slot":`subagent-empty`,className:`py-2 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`})})]})}function To({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,$.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:o(`rounded-full px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}var Eo=/^diff --git /;function Do(e){let t=e.replace(Eo,``),n=t.lastIndexOf(` b/`);return Oo(n>=0?t.slice(n+3):t)}function Oo(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>=2?t.slice(1,-1).replace(/\\(.)/g,`$1`):t}function ko(e){let t=Oo(e.slice(4));if(t!==`/dev/null`)return t.replace(/^[ab]\//,``)}function Ao(e){return{path:Do(e),status:`modified`,binary:!1,additions:0,deletions:0,lines:[]}}function jo(e,t){if(t.startsWith(`rename from `))e.status=`renamed`,e.oldPath=Oo(t.slice(12));else if(t.startsWith(`rename to `))e.status=`renamed`,e.path=Oo(t.slice(10));else if(t.startsWith(`new file mode`))e.status=`added`;else if(t.startsWith(`deleted file mode`))e.status=`deleted`;else if(t.startsWith(`Binary files `)||t===`GIT binary patch`)e.binary=!0;else if(t.startsWith(`+++ `)){let n=ko(t);n!==void 0&&(e.path=n)}else if(t.startsWith(`--- `)){let n=ko(t);n!==void 0&&e.status===`deleted`&&(e.path=n)}}function Mo(e,t){e.lines.push(t),t.startsWith(`+`)?e.additions+=1:t.startsWith(`-`)&&(e.deletions+=1)}function No(e){let t=[],n=null,r=!1;for(let i of e.split(`
7
- `)){if(Eo.test(i)){n=Ao(i),t.push(n),r=!1;continue}if(n){if(!r){i.startsWith(`@@`)?(r=!0,n.lines.push(i)):jo(n,i);continue}Mo(n,i)}}let i=t.at(-1);return i&&i.lines.at(-1)===``&&i.lines.pop(),t}function Po(e){return{files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}}var Fo=20,Io=300;function Lo({runId:e}){let t=v(),n=ne(e);(0,Q.useEffect)(()=>{t.invalidateQueries({queryKey:A.runs.diff(e)})},[t,e]);let r=(0,Q.useMemo)(()=>No(n.data??``),[n.data]),[i,a]=(0,Q.useState)(!1);if(n.isPending)return(0,$.jsx)(`p`,{className:`px-1 text-xs text-soft-foreground`,children:`Loading diff…`});if(n.isError)return(0,$.jsx)(`p`,{className:`px-1 text-xs text-danger`,children:n.error.message});if(r.length===0)return(0,$.jsx)(`p`,{"data-slot":`run-diff-empty`,className:`px-1 font-mono text-xs text-soft-foreground`,children:n.data.trim()||`(no changes)`});let o=Po(r),s=i?r:r.slice(0,Fo);return(0,$.jsxs)(`div`,{"data-slot":`run-diff`,className:`flex min-w-0 flex-col gap-2`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[o.files,` `,o.files===1?`file`:`files`,` changed`]}),(0,$.jsxs)(`span`,{className:`font-mono font-semibold tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,o.additions]}),` `,(0,$.jsxs)(`span`,{className:`text-danger`,children:[`−`,o.deletions]})]})]}),s.map(e=>(0,$.jsx)(zo,{file:e},`${e.oldPath??``}→${e.path}`)),r.length>s.length?(0,$.jsxs)(K,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>a(!0),children:[`Show `,r.length-s.length,` more files`]}):null]})}var Ro={added:`added`,deleted:`deleted`,renamed:`renamed`};function zo({file:e}){let[t,n]=(0,Q.useState)(!0),r=Ro[e.status],i=e.oldPath?`${e.oldPath} → ${e.path}`:e.path;return(0,$.jsxs)(Y,{open:t,onOpenChange:n,"data-slot":`diff-file`,className:`min-w-0 overflow-hidden rounded-md border border-border bg-card`,children:[(0,$.jsxs)(J,{className:`flex w-full items-start gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,$.jsx)(nt,{className:o(`mbs-[1px] size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,$.jsx)(`span`,{"data-slot":`diff-file-path`,title:i,className:`min-w-0 wrap-anywhere font-mono text-xs font-medium`,children:e.oldPath?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),r?(0,$.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:r}):null,e.binary?(0,$.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:`binary`}):null,(0,$.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[11px] font-semibold tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,$.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})]}),(0,$.jsx)(q,{children:(0,$.jsx)(`div`,{className:`border-t border-border/50`,children:e.binary?(0,$.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.lines.length===0?(0,$.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,$.jsx)(Bo,{lines:e.lines})})})]})}function Bo({lines:e}){let[t,n]=(0,Q.useState)(!1),r=t?e:e.slice(0,Io),i=r.join(`
8
- `),[a,s]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=!1;return wn(i,`diff`).then(t=>{e||s({text:i,tokens:t.tokens})}),()=>{e=!0}},[i]);let c=a?.text===i?a.tokens:Cn(i,`diff`)?.tokens??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{"data-slot":`diff-file-body`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:r.map((e,t)=>(0,$.jsxs)(`span`,{"data-line":e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:void 0,className:o(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[c?.[t]===void 0?e:c[t].map((e,t)=>(0,$.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),e===``?` `:``]},t))}),e.length>Io?(0,$.jsx)(`button`,{type:`button`,"data-slot":`diff-file-toggle`,onClick:()=>n(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:t?`Show less`:`Show all ${e.length} lines`}):null]})}function Vo(e){let t=v();return L({mutationFn:()=>y(e),onSuccess:()=>t.invalidateQueries({queryKey:A.runs.all}),onError:e=>H(e.message,{tone:`danger`})})}function Ho({run:e}){return(0,$.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex items-center gap-2.5 rounded-md border border-accent-strong/30 bg-accent-strong/10 px-3.5 py-2.5`,children:[(0,$.jsx)(it,{className:`size-4 shrink-0 text-accent-icon`,"aria-hidden":`true`}),(0,$.jsxs)(`p`,{className:`min-w-0 text-[13px]`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,$.jsx)(Lo,{runId:e.id}),(0,$.jsx)(Uo,{run:e})]})}function Uo({run:e}){let t=N(),n=v(),r=(0,Q.useRef)(null),[i,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(null),u=Vo(e.id),d=Ai(e),f=()=>n.invalidateQueries({queryKey:A.runs.all}),p=L({mutationFn:async t=>d.canContinue?C(B(e.id),{text:`Review feedback:\n${t}`,runner:d.runnerOverride}):null,onMutate:()=>B(e.id),onSuccess:(e,n,r)=>{e!==null&&(o(``),t.invalidateAfter(`continue`,r))},onError:e=>H(e.message,{tone:`danger`})}),m=L({mutationFn:()=>S(e.id),onSuccess:e=>{H(`Draft PR created — ${e.url}`),f()},onError:e=>{e instanceof l&&e.manual!==void 0&&c(e.manual),H(e.message,{tone:`danger`})}}),h=()=>{let e=i.trim();if(e.length===0){H(`Write what to change first.`),r.current?.focus();return}p.mutate(e)};return(0,$.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[(0,$.jsx)(An,{ref:r,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:2,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{Yt({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())},className:`min-h-[52px] text-[13px]`}),d.canContinue?null:(0,$.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:d.reason}),d.providerPending?null:(0,$.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(K,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:d.reason??`Send the notes back into the agent's session`,"aria-describedby":d.canContinue?void 0:`review-provider-guidance`,disabled:p.isPending||!d.canContinue,onClick:h,children:[(0,$.jsx)(Fn,{"aria-hidden":`true`}),`Send back`]}),a(e.pullRequestUrl)?(0,$.jsx)(K,{asChild:!0,variant:`outline`,size:`sm`,children:(0,$.jsxs)(`a`,{"data-slot":`pr-link`,href:e.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,title:`The PR for this task is already open`,children:[(0,$.jsx)(rt,{"aria-hidden":`true`}),`PR ↗`]})}):(0,$.jsxs)(K,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:m.isPending,onClick:()=>m.mutate(),children:[(0,$.jsx)(ve,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,$.jsxs)(K,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`ml-auto`,title:Zt(`review`),disabled:u.isPending,onClick:()=>u.mutate(),children:[(0,$.jsx)(Se,{"aria-hidden":`true`}),`Accept`]}):null]}),s===null?null:(0,$.jsx)(Wo,{command:s})]})}function Wo({command:e}){return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>H(`Command copied to clipboard.`)).catch(()=>H(`Run manually: ${e}`))},className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-[11px] text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,$.jsx)(Pe,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function Go(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Ko=1500;function qo({status:e}){let t=(0,Q.useRef)(e),[n,r]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||Go())return;r(!0);let i=setTimeout(()=>r(!1),Ko);return()=>clearTimeout(i)},[e]),n?(0,$.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,$.jsx)(Mt,{}),(0,$.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,$.jsx)(`span`,{className:`rounded-full border border-accent-strong/30 bg-accent-strong/15 px-4 py-1.5 text-[13px] font-medium text-accent-text shadow-modal`,children:`✓ Changes accepted`})})]}):null}function Jo(e){let t=v(),[n,r]=(0,Q.useState)(),i=Ot(e);(0,Q.useEffect)(()=>{(!i||n&&n!==e.id)&&r(void 0)},[i,e.id,n]);let a=L({mutationFn:async()=>{r(e.id);try{if(!(await c(e.id)).cancelled)throw Error(`The task changed before Stop was accepted. Check its status and retry.`)}catch(e){throw r(void 0),e}},onSettled:()=>t.invalidateQueries({queryKey:A.runs.all})});return{stopping:!!e.stopping||a.isPending||i&&n===e.id,stop:()=>a.mutateAsync()}}function Yo({agents:e,onSelect:t}){return e.length===0?null:(0,$.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,$.jsx)(Xo,{agent:e,onSelect:t},e.id))})}function Xo({agent:e,onSelect:t}){let n=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Zo,{status:e.status,stalled:e.stalled===!0}),(0,$.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,$.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,$.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:Ji(e)}),(0,$.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,$.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,$.jsx)(`button`,{type:`button`,"data-agent-id":e.id,onClick:()=>t(e.id),"aria-haspopup":`dialog`,className:`flex min-h-5 w-full min-w-0 items-center gap-2.5 rounded-sm text-left hover:bg-muted/50`,children:n}):(0,$.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function Zo({status:e,stalled:t=!1}){return t?(0,$.jsx)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,"data-stalled":`true`,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`3 2.5`,children:(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-danger`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,$.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,$.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,$.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function Qo(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function $o({entries:e}){return e.length===0?null:(0,$.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,$.jsx)(es,{entry:e},`${t}:${e.content}`))})}function es({entry:e}){return(0,$.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:o(`flex min-h-5 min-w-0 items-center gap-2.5 text-[13px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-soft-foreground/70 line-through`),children:[(0,$.jsx)(ts,{status:e.status}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,$.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function ts({status:e}){return e===`cancelled`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground/70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,$.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,$.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,$.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,$.jsx)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function ns(e){switch(e){case`done`:return`done`;case`running`:case`waiting`:case`review`:return`active`;case`failed`:case`cancelled`:return`failed`;case`pending`:case`skipped`:return`pending`}}function rs(e){if(e.length===0)return 0;let t=new Set([`done`,`failed`,`cancelled`,`skipped`]),n=new Set([`running`,`waiting`,`review`]),r=0;for(let i of e)t.has(i.status)?r+=1:n.has(i.status)&&(r+=.5);return r/e.length}function is({steps:e}){if(e.length===0)return null;let t=rs(e)*100;return(0,$.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((t,n)=>(0,$.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":ns(t.status),className:`flex min-h-[22px] min-w-0 items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,$.jsx)(as,{visual:ns(t.status)}),(0,$.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:t.name}),t.iterations>1?(0,$.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,t.iterations]}):null,(0,$.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-soft-foreground tabular-nums`,children:[t.pluginKind??t.kind,` · step `,n+1,` of `,e.length]})]},t.id)),(0,$.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${t}%`}})})]})}function as({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,$.jsx)(we,{"aria-hidden":!0,className:o(t,`text-success`)});case`active`:return(0,$.jsx)(ot,{role:`status`,"aria-label":`Step running`,className:o(t,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,$.jsx)(Te,{"aria-hidden":!0,className:o(t,`text-danger`)});case`pending`:return(0,$.jsx)(ke,{"aria-hidden":!0,className:o(t,`text-soft-foreground`)})}}var os={done:`done`,failed:`failed`,cancelled:`cancelled`};function ss(e){let t=os[e.status];return t?e.steps.map(e=>ns(e.status)===`active`?{...e,status:t}:e.status===`pending`?{...e,status:`skipped`}:e):cs(e)}function cs(e){let t=ls(e.currentStepId,e.steps);return e.steps.some((e,n)=>n!==t&&e.status===`waiting`)?e.steps.map((e,n)=>n!==t&&e.status===`waiting`?{...e,status:`done`}:e):e.steps}function ls(e,t){let n=t.findIndex(t=>t.id===e);if(n>=0)return n;let r=t.reduce((e,t,n)=>ns(t.status)===`active`?n:e,-1);if(r>=0)return r;let i=t.findIndex(e=>e.status===`pending`);return i>=0?i:t.reduce((e,t,n)=>t.status===`skipped`?e:n,0)}function us({items:e,lead:t=0}){let n=(0,Q.useRef)(null),[r,i]=(0,Q.useState)(-1/0);return(0,Q.useLayoutEffect)(()=>{let r=n.current;if(!r)return;let a=()=>{let n=r.getBoundingClientRect().width;if(!n&&r.getClientRects().length===0)return;let a=getComputedStyle(r),o=Number.parseFloat(a.width),s=o>0?n/o:1,c=(Number.parseFloat(a.columnGap)||0)*s,l=Array.from(r.children,e=>e.getBoundingClientRect().width),u=e.map((e,t)=>({...e,width:l[t]??0})),d=-1/0,f=()=>u.reduce((e,t)=>e+t.width,0)+Math.max(0,u.length-1)*c+(u.length>0?t*s:0);for(let t of[...new Set(e.map(e=>e.priority))].sort((e,t)=>e-t)){if(f()<=n)break;d=t,u=u.filter(e=>e.priority>t)}i(e=>e===d?e:d)};if(a(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(a);o.observe(r);for(let e of r.children)o.observe(e);return()=>o.disconnect()},[e,t]),(0,$.jsx)(`span`,{ref:n,"data-slot":`activity-summary`,className:`relative flex h-[max(1.5em,22px)] min-w-0 flex-1 items-center gap-2.5 overflow-clip whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:e.map(n=>{let i=n.priority<=r,a=n===e.find(e=>e.priority>r);return(0,$.jsx)(`span`,{"data-summary-item":n.id,"data-hidden":i,"aria-hidden":i||void 0,inert:i||void 0,style:a&&t?{marginInlineStart:t}:void 0,className:`inline-flex w-max shrink-0 items-center gap-1.5 data-[hidden=true]:invisible data-[hidden=true]:absolute`,children:n.content},n.id)})})}function ds({run:e,references:t}){return(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:t.map(t=>(0,$.jsx)(yt,{reference:t,taskTitle:Z(e),inert:!0},he(t)))})}function fs(e){return e.accountId===void 0||e.profilesPending?void 0:e.profilesError?e.accountId:e.accountId==="default"?xn(e.accounts,e.accountBackend)?`default`:void 0:e.known?xn(e.accounts,e.accountBackend)?e.known.label:void 0:`${e.accountId} (removed)`}function ps(e){let t=M(),n=oe(),{accounts:r}=yn(),i=e.runner??t.data?.defaultRunner??`claude`,a=e.model??`auto`,o=e.effort||`auto`,s=[...e.steps].reverse().find(e=>e.profileId),c=s?.profileId,l=s?.backend??i,d=n.data?.profiles.find(e=>e.id===c&&e.provider===l),f=fs({accountId:c,profilesPending:n.isPending,profilesError:n.isError,known:d,accounts:r,accountBackend:l}),p=e.modelIdentity&&e.modelIdentity!==a?e.modelIdentity:void 0;return{runner:e.removedRunner===void 0?i:u(e.removedRunner),...f?{account:f}:{},model:a,effort:o,...p?{identity:p}:{}}}var ms=[`running`,`queued`,`waiting`];function hs(e){return Array.isArray(e)?e.filter(e=>e?.kind===`pr`||e?.kind===`timer`||e?.kind===`worker`||e?.kind===`process`||e?.kind===`peer`||e?.kind===`subagent`||e?.kind===`plugin`):[]}function gs(e){let t=e?new Date(e):void 0;return t&&Number.isFinite(t.getTime())?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(t):void 0}function _s(e,t){return`${e} — ${t.status===`failed`?`not delivered; Continue delivers it, Stop discards it`:t.status===`running`?`current turn still working`:`waiting for capacity`}`}function vs(e){return e.kind!==`worker`&&e.kind!==`peer`&&e.kind!==`subagent`}function ys(e){let t=hs(e.waits),n=ms.includes(e.status),r=t.filter(t=>t.phase===`open`?n:t.phase===`resolved`&&vs(t)&&(n||e.status===`failed`)),i=r.some(e=>e.kind===`pr`),a=[...hs(e.lastWaits),...t.filter(e=>!r.includes(e)&&e.phase!==`open`)],o=i?void 0:a.filter(e=>e.kind===`pr`).at(-1),s=i?void 0:e.lastWaitsError,c=r.some(e=>e.kind===`process`)?void 0:a.filter(e=>e.kind===`process`).at(-1);return r.length||o||s||c?{open:r,lastCi:o,error:s,lastProcess:c}:void 0}function bs(e){return ys(e)!==void 0}function xs(e){return(ys(e)?.open??[]).filter(e=>e.kind===`pr`).map(e=>({kind:`PR`,number:e.prNumber,url:e.prUrl}))}function Ss({run:e}){let t=ys(e);if(!t)return null;let{open:n,lastCi:r,error:i,lastProcess:a}=t;return(0,$.jsxs)(`div`,{"data-slot":`open-waits`,className:`flex min-w-0 flex-col gap-1`,children:[n.map(t=>t.kind===`pr`?(0,$.jsx)(ws,{run:e,wait:t},t.id):t.kind===`worker`?(0,$.jsx)(Ts,{wait:t},t.id):t.kind===`process`?(0,$.jsx)(js,{run:e,wait:t},t.id):t.kind===`peer`?(0,$.jsx)(Es,{wait:t},t.id):t.kind===`subagent`?(0,$.jsx)(Ds,{wait:t},t.id):t.kind===`plugin`?(0,$.jsx)(Os,{run:e,wait:t},t.id):(0,$.jsx)(ks,{run:e,wait:t},t.id)),i?(0,$.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:i}):r?(0,$.jsx)(ws,{run:e,wait:r,settled:!0}):null,a?(0,$.jsx)(js,{run:e,wait:a,settled:!0}):null]})}function Cs(e,t,n){let r=t.result,i=t.until!==`checks`,a={passed:`CI checks passed — observed checks only; not merge approval`,stuck:`CI checks stuck in queue — inspect the PR checks`,failed:`CI checks failed — inspect the PR checks`,conflicting:i?`PR has merge conflicts — inspect the PR; not merged`:`PR has merge conflicts — inspect the PR; not merge approval`,cancelled:i?`Merge wait cancelled`:`CI wait cancelled`,skipped:`CI checks skipped — inspect the PR checks`,no_checks:`No CI checks found — inspect the PR workflows`,startup_failure:`CI workflow never started — inspect the PR workflows`,deadline:i?`Merge wait timed out — merge not confirmed`:`CI wait timed out — inspect the PR checks`,error:i?`Merge wait unavailable — inspect access and the PR`:`CI wait unavailable — inspect access and the PR checks`,head_changed:`CI head changed — ${r?.headSha.slice(0,7)} → ${r?.observedHeadSha?.slice(0,7)??`unknown`}`,merged:`PR merged`,closed:`PR closed without merge — inspect the PR`,blocked:`Initiated merge blocked — inspect the PR; not merged`},o=i?`Merge`:`CI`,s=n&&t.phase===`cancelled`;return n?s?`${o} wait cancelled`:r?a[r.outcome]:`${o} wait unavailable`:t.phase===`resolved`?_s(`${o} result ready`,e):t.until===`merge_or_blocked`?`Waiting for merge or blockage`:i?`Waiting for merge`:`Waiting for CI`}function ws({run:e,wait:t,settled:n=!1}){let r=t.result,i=t.until===`checks`?`CI`:`Merge`,o=n&&t.phase===`cancelled`,s=Cs(e,t,n),c=n?o?t.cancelledAt:r?.observedAt:t.deadline,l=gs(c),u=`${t.repository}#${t.prNumber}`;return(0,$.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-[13px] text-muted-foreground [overflow-wrap:anywhere]`,children:(0,$.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,$.jsx)(`dd`,{children:s}),(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Pull request`}),(0,$.jsx)(`dd`,{className:`min-w-0`,children:a(t.prUrl)?(0,$.jsx)(`a`,{href:t.prUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-11 min-w-11 max-w-full items-center rounded-sm px-1 font-medium text-foreground underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted`,children:u}):(0,$.jsx)(`span`,{children:u})}),l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:n?o?`Cancelled`:`Observed`:`Deadline`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(`time`,{dateTime:c,children:l})})]}):n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Deadline`}),(0,$.jsxs)(`dd`,{children:[i,` deadline unavailable`]})]})]})})}function Ts({wait:e}){let t=e.workerIds!==void 0,n=new Set((t?e.outcomes:e.requestOutcomes)?.map(e=>`workerId`in e?e.workerId:e.requestId)),r=(e.workerIds??e.requestIds??[]).filter(e=>!n.has(e)).length,i=t?r===1?`worker`:`workers`:r===1?`request reply`:`request replies`,a=gs(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`worker-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting on `,r,` `,i]}),a?(0,$.jsxs)(`p`,{children:[`Deadline`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:a})]}):(0,$.jsx)(`p`,{children:`Worker wait deadline unavailable`})]})}function Es({wait:e}){let t=e.peerIds.length,n=gs(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`peer-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting on `,t,` `,t===1?`task`:`tasks`]}),n?(0,$.jsxs)(`p`,{children:[`Deadline`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,$.jsx)(`p`,{children:`Peer wait deadline unavailable`})]})}function Ds({wait:e}){let t=(Array.isArray(e.children)?e.children:[]).filter(e=>e?.status===`running`).length,n=gs(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`subagent-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`subagent`:`subagents`]}),n?(0,$.jsxs)(`p`,{children:[`Check by`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,$.jsx)(`p`,{children:`Subagent wait deadline unavailable`})]})}function Os({run:e,wait:t}){let n=t.phase===`open`?gs(t.deadline):void 0;return(0,$.jsxs)(`div`,{"data-slot":`plugin-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsx)(`p`,{children:t.phase===`resolved`?_s(t.summary,e):t.summary}),n?(0,$.jsxs)(`p`,{children:[`Deadline`,` `,(0,$.jsx)(`time`,{dateTime:t.deadline,children:n})]}):null]})}function ks({run:e,wait:t}){let n=gs(t.deadline);return(0,$.jsxs)(`div`,{"data-slot":`monitoring-schedule`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[t.phase===`resolved`?(0,$.jsx)(`p`,{children:_s(`Automatic check due`,e)}):n?(0,$.jsxs)(`p`,{children:[`Next automatic check`,` `,(0,$.jsx)(`time`,{dateTime:t.deadline,className:`font-medium text-foreground`,children:n})]}):(0,$.jsx)(`p`,{children:`Automatic check time unavailable`}),t.note?(0,$.jsx)(`p`,{children:t.note}):null]})}function As(e){let t=e.result;return t?t.outcome===`exit_file`?t.exitCode===void 0?`PID ${e.pid} wrote an exit file that is not an exit code`:`PID ${e.pid} exited with code ${t.exitCode}`:t.outcome===`exited`?e.startToken===void 0&&t.observedAt===e.registeredAt?`PID ${e.pid} was not running when the wait was registered`:`PID ${e.pid} exited, code unknown`:t.outcome===`deadline`?`PID ${e.pid} still running at the deadline`:`PID ${e.pid} could not be checked`:`PID ${e.pid} still running at the deadline`}function js({run:e,wait:t,settled:n=!1}){let r=n&&t.phase===`cancelled`?`Process wait on PID ${t.pid} cancelled`:n?As(t):t.phase===`resolved`?_s(As(t),e):`Waiting for PID ${t.pid}${t.note?` — ${t.note}`:``}`,i=!n&&t.phase===`open`?gs(t.deadline):void 0;return(0,$.jsxs)(`div`,{"data-slot":`process-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsx)(`p`,{children:r}),i?(0,$.jsxs)(`p`,{children:[`Until`,` `,(0,$.jsx)(`time`,{dateTime:t.deadline,children:i})]}):null]})}var Ms=new Map,Ns=new Map;function Ps(e){let{referenceProjectId:t,repoBase:n,references:r,requests:i}=Le(e.run);return(0,$.jsx)(_t,{projectId:t,repoBase:n,requests:i,children:(0,$.jsx)(Fs,{...e,references:r,prNumbers:i.filter(e=>e.kind===`PR`).map(e=>e.number),hasReferences:r.length>0||!!pe(e.run)||!!fe(e.run,n)})})}function Fs({run:e,thread:t,currentThread:n,currentComplete:r=!0,onOpenWorker:i,readerScroll:a,prNumbers:o,hasReferences:s,references:c}){let l=$t(),u=ps(e),[d,f]=(0,Q.useState)(()=>Ms.get(e.id)??!1),p=Zs(a,d),m=p.open,[h,g]=(0,Q.useState)({}),_=Is(e,t??n,n,r,o),v=He(e),y=t=>h[t]??Ns.get(`${e.id}:${t}`)??t===`workers`,b=t=>{let n=!y(t);Ns.set(`${e.id}:${t}`,n),g(e=>({...e,[t]:n}))},x=e=>({open:y(e),onToggle:()=>b(e)});return(0,$.jsxs)(`section`,{"data-slot":`run-activity-dock`,ref:p.ref,"data-state":m?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,$.jsx)(Vs,{run:e,identity:u,activity:_,references:c,open:m,onToggle:()=>{Ms.set(e.id,!m),f(!m),p.chose(!m)}}),m?(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col border-t border-border`,children:[(0,$.jsx)(Ws,{run:e,activity:_,...x(`status`)}),(0,$.jsx)(Gs,{run:e,desktop:l,automations:_.automations,...x(`workflow`)}),(0,$.jsx)(Ks,{activity:_,desktop:l,onOpenWorker:i,...x(`subagents`)}),(0,$.jsx)(qs,{run:e,...x(`workers`)}),(0,$.jsx)(Js,{activity:_,desktop:l,...x(`plan`)}),(0,$.jsx)(Ys,{run:e,identity:u,activity:_,...x(`usage`)}),(0,$.jsx)(Xs,{run:e,references:c,conflicts:_.conflicts,hasReferences:s,onResume:()=>v.mutate(),...x(`workspace`)})]}):null]})}function Is(e,t,n,r,i){let a=I(),o=cn(a.data),s=F(),c=et(e,{queuePosition:e.status===`queued`?kt(s.data??[]).get(e.id):void 0}),l=vt(i),u=!Dt(e)&&e.status!==`queued`,d=(0,Q.useMemo)(()=>r?Gi(n.turns,u,t.turns):[],[r,n.turns,u,t.turns]),f=gt(n)??[],p=Ge(e),m=qi(d),h=Qo(f);return{line:c,...Ls(e,c,p,r?m:void 0,h),...Rs(e,o),conflicts:l,waitReferences:xs(e),agents:d,agentCounts:m,planEntries:f,planCounts:h,automations:_n(a.data)}}function Ls(e,t,n,r,i){let a=e.steps.every(e=>e.status===`done`||e.status===`skipped`),o=e.status===`done`&&a&&n===`complete`&&r!==void 0&&r.done===r.total&&i.done===i.total;return{allComplete:o,statusText:o?`All complete`:e.status!==`done`||r===void 0?t.label:n===`unknown`?`Workers unavailable`:n===`pending`?`In progress`:`Incomplete`,failed:t.attention.tone===`danger`||e.status===`cancelled`,glyph:o?(0,$.jsx)(we,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success`}):(0,$.jsx)(jt,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse})}}function Rs(e,t){return{cost:t.cost&&e.costUsd!==void 0?me(e.costUsd):void 0,tokens:t.tokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(0,$.jsx)(nn,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):void 0}}function zs(e){return e.allComplete?`text-success`:e.failed&&`text-danger`}function Bs(e){let t=ss(e),n=ls(e.currentStepId,t);return t.length>0?{steps:t,index:n,step:t[n]}:void 0}function Vs({run:e,identity:t,activity:n,references:r,open:i,onToggle:a}){let{cost:s}=n,c=[...new Map([...r,...n.waitReferences].map(e=>[he(e),e])).values()];return(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-label":Hs(e,t,n,c,i),onClick:a,className:o(`flex min-h-11 w-full min-w-0 items-center px-3.5 py-2 text-start text-[14px] hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,i?`gap-2.5`:`gap-2`),children:[(0,$.jsx)(Ie,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,$.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),i?null:(0,$.jsx)(Us,{run:e,identity:t,activity:n,summaryReferences:c}),i&&s?(0,$.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:s}):null,(0,$.jsx)(Oe,{"aria-hidden":!0,className:o(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,i&&!s&&`ms-auto`,i&&`rotate-180`)})]})}function Hs(e,t,n,r,i){let{statusText:a,conflicts:o,cost:s}=n,c=`Session activity: ${a}${o.length?`; pull request conflicts`:``}${s?`; cost ${s}`:``}`;if(i)return c;let l=Bs(e)?.step,u=l?ns(l.status):void 0,d=l?`; step ${l.name}, ${u===`active`?`running`:u}`:``,f=r.length?`; ${r.map(e=>`${e.kind} #${e.number}`).join(`; `)}`:``;return`${c}${d}; runner ${t.runner}; model ${t.model}; effort ${t.effort}${f}`}function Us({run:e,identity:t,activity:n,summaryReferences:r}){let{statusText:i,cost:a,conflicts:s}=n,c=Bs(e)?.step,l=[{id:`runner`,priority:2,content:t.runner},{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:(0,$.jsx)(`span`,{"data-slot":`run-activity-cost`,children:a})}]:[],...r.length||s.length?[{id:`chips`,priority:0,content:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ds,{run:e,references:r}),s.length>0?(0,$.jsxs)(`span`,{"data-slot":`run-activity-conflict`,className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,$.jsx)(je,{"aria-hidden":!0,className:`size-3.5`}),`Conflicts`]}):null]})}]:[]];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{"data-slot":`run-activity-status`,title:i,className:o(`inline-flex min-w-[calc(0.875rem+3ch)] flex-[0_1_auto] items-center gap-1.5 text-[13px] whitespace-nowrap text-muted-foreground`,zs(n)),children:[n.glyph,(0,$.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`min-w-0 truncate`,children:i})]}),c?(0,$.jsxs)(`span`,{"data-slot":`run-activity-step`,className:`flex max-w-max min-w-[calc(1.375rem+2ch)] flex-[1000_1_0] items-center gap-1.5 text-[13px] text-muted-foreground`,children:[(0,$.jsx)(tc,{step:c,decorative:!0}),(0,$.jsx)(`span`,{"data-slot":`run-activity-step-name`,title:c.name,className:`min-w-0 truncate`,children:c.name})]}):null,(0,$.jsx)(`span`,{className:`-ms-2 flex min-w-0 flex-[1_1_0]`,children:(0,$.jsx)(us,{items:l,lead:8})})]})}function Ws({run:e,activity:t,open:n,onToggle:r}){let{line:i,waitReferences:a}=t,s=Je(e);return(0,$.jsxs)($e,{slot:`status-row`,icon:t.glyph,title:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{"data-slot":`run-activity-status`,className:o(`truncate`,zs(t)),children:t.statusText}),i.nextCheck?(0,$.jsxs)(`span`,{"data-slot":`run-activity-next-check`,className:`whitespace-normal text-[13px] font-normal text-muted-foreground`,children:[`Next check `,(0,$.jsx)(`time`,{dateTime:i.nextCheck.at,children:i.nextCheck.text})]}):null]}),summary:!n&&a.length>0?(0,$.jsx)(us,{items:[{id:`chips`,priority:0,content:(0,$.jsx)(ds,{run:e,references:a})}]}):void 0,open:n,onToggle:bs(e)||s?r:void 0,children:[(0,$.jsx)(Ss,{run:e}),s?(0,$.jsx)(We,{run:e}):null]})}function Gs({run:e,desktop:t,automations:n,open:r,onToggle:i}){let a=ge(e),o=Bs(e);return!a&&!o?null:(0,$.jsxs)($e,{slot:`workflow`,icon:o?(0,$.jsx)(tc,{step:o.step}):(0,$.jsx)(Ne,{className:`size-4`}),title:(0,$.jsxs)($.Fragment,{children:[`Workflow`,a?(0,$.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,a]}):null]}),meta:o?{drop:o.step.name,keep:Be(o.index+1,o.steps.length,t,`step`)}:void 0,open:r,onToggle:i,children:[o?(0,$.jsx)(is,{steps:o.steps}):null,(0,$.jsx)(ec,{run:e,available:n})]})}function Ks({activity:e,desktop:t,onOpenWorker:n,open:r,onToggle:i}){let{agents:a,agentCounts:o}=e;return a.length===0?null:(0,$.jsx)($e,{slot:`subagents`,icon:(0,$.jsx)(Me,{className:`size-4`}),title:`Subagents`,meta:Be(o.done,o.total,t),open:r,onToggle:i,children:(0,$.jsx)(Yo,{agents:a,onSelect:n})})}function qs({run:e,open:t,onToggle:n}){return Ze(e)?(0,$.jsx)(Xe,{run:e,open:t,onToggle:n}):null}function Js({activity:e,desktop:t,open:n,onToggle:r}){let{planEntries:i,planCounts:a}=e;return i.length===0?null:(0,$.jsx)($e,{slot:`plan`,icon:(0,$.jsx)(U,{className:`size-4`}),title:`Plan`,meta:Be(a.done,a.total,t),open:n,onToggle:r,children:(0,$.jsx)($o,{entries:i})})}function Ys({run:e,identity:t,activity:n,open:r,onToggle:i}){let{cost:a,tokens:o}=n,s=e.modelIdentity?.includes(`/`)?e.modelIdentity.split(`/`)[0]:void 0,c=[...s?[{id:`provider`,priority:2,content:s}]:[],{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:a}]:[],...o?[{id:`tokens`,priority:0,content:o}]:[]];return(0,$.jsx)($e,{slot:`usage`,icon:(0,$.jsx)(Pn,{className:`size-4`}),title:`Usage & agent`,summary:(0,$.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,$.jsx)(us,{items:c})}),open:r,onToggle:i,children:(0,$.jsx)($s,{run:e,tokens:o,cost:a})})}function Xs({run:e,references:t,conflicts:n,hasReferences:r,onResume:i,open:a,onToggle:o}){let s=e.delegation?.role===`worker`?e.delegation.destroy:void 0;if(!(e.branch||e.worktreePath||r||en(e)||Re(s)))return null;let c=n.length===1?`PR #${n[0]} conflicts`:`${n.length} PRs conflict`;return(0,$.jsx)($e,{slot:`workspace`,icon:(0,$.jsx)(_e,{className:`size-4`}),title:`Workspace`,summary:!a&&t.length>0?(0,$.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,$.jsx)(us,{items:[...e.branch?[{id:`branch`,priority:0,content:(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch})}]:[],{id:`chips`,priority:1,content:(0,$.jsx)(ds,{run:e,references:t})},...n.length>0?[{id:`conflicts`,priority:2,content:(0,$.jsx)(`span`,{className:`font-medium text-conflict`,children:c})}]:[]]})}):void 0,meta:n.length>0?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,$.jsx)(je,{"aria-hidden":!0,className:`size-3.5`}),c]}):e.branch?(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch}):void 0,open:a,onToggle:o,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 text-[13px] text-muted-foreground`,children:[s?(0,$.jsx)(qe,{state:s}):null,(0,$.jsx)(Ke,{run:e}),e.branch?(0,$.jsx)(Qs,{label:`Branch`,children:(0,$.jsx)(Ye,{branch:e.branch})}):null,e.worktreePath?(0,$.jsx)(Qs,{label:`Worktree`,children:(0,$.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[12px] text-foreground`,children:e.worktreePath})}):null,(0,$.jsx)(Ue,{run:e,canResume:dn(e).terminal,onResume:i})]})})}function Zs(e,t){let n=(0,Q.useRef)(null),[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(t);a.current=t;let o=(0,Q.useRef)({active:!1,override:!1});return(0,Q.useEffect)(()=>e?.(e=>{if(e.direction===`tail`){o.current={active:!1,override:!1},i(!1);return}if(e.direction===`down`){i(!1);return}if(o.current.active=!0,o.current.override||!a.current)return;let t=n.current?.closest(`[data-slot="thread-dock"]`);!t||getComputedStyle(t).position!==`sticky`||e.distanceFromBottom<=t.getBoundingClientRect().height||i(!0)}),[e]),{ref:n,open:t&&!r,chose:e=>{i(!1),e&&o.current.active&&(o.current.override=!0)}}}function Qs({label:e,children:t}){return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`w-20 shrink-0 font-medium text-foreground`,children:e}),t]})}function $s({run:e,tokens:t,cost:n}){let{runner:r,account:i,model:a,effort:o,identity:s}=ps(e);return(0,$.jsxs)(`dl`,{"data-slot":`agent-details`,className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-[13px]`,children:[t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Tokens`}),(0,$.jsx)(`dd`,{className:`min-w-0 text-[12px]`,children:t})]}):null,n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Cost`}),(0,$.jsx)(`dd`,{className:`min-w-0 font-mono text-[12px] tabular-nums`,children:n})]}):null,(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Runner`}),(0,$.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:r}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Account`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-account`,className:`min-w-0 break-all font-mono text-[12px]`,children:i})]}):null,(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Model`}),(0,$.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:a}),(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Effort`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-effort`,className:`min-w-0 break-all font-mono text-[12px]`,children:o}),s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Identity`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-identity`,className:`min-w-0 break-all font-mono text-[12px]`,children:s})]}):null]})}function ec({run:e,available:t}){if(!e.automation)return null;let n=`inline-flex min-h-11 items-center rounded-sm text-[13px] font-medium md:min-h-8`;return(0,$.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Launched by`,` `,t?(0,$.jsx)(X,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:o(n,`text-foreground underline underline-offset-2`),children:`Automation`}):(0,$.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:n,children:`Automation`})]})}function tc({step:e,decorative:t=!1}){let n=ns(e.status),r=`size-4 shrink-0`;switch(n){case`active`:return(0,$.jsx)(ot,{...t?{"aria-hidden":!0}:{role:`status`,"aria-label":`Step running`},"data-slot":`workflow-glyph`,"data-visual":n,className:o(r,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,$.jsx)(Te,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:o(r,`text-danger`)});case`pending`:return(0,$.jsx)(ke,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:o(r,`text-soft-foreground`)});case`done`:return(0,$.jsx)(we,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:o(r,`text-success`)})}}var nc={finish:`Closed when the task finished`,superseded:`Closed when the worker went on`,"parent-stopped":`Closed when the parent stopped`,"worker-stopped":`Closed when the worker stopped`,undeliverable:`Closed: not delivered`};function rc(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function ic({ask:e,run:t,onShowOrigin:n}){let r=e.context?(0,$.jsx)(oc,{text:e.context}):null;if(e.resolved)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,(0,$.jsxs)(Zr,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,$.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?nc[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,$.jsx)(ma,{ask:e})]})]});let i=e.placement===`pinned`&&n?n:void 0;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,e.routedToParent?(0,$.jsx)(sc,{ask:e,onShowOrigin:i}):(0,$.jsx)(cc,{ask:e,run:t,onShowOrigin:i})]})}function ac({onShowOrigin:e}){return(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,className:`mbs-2 min-h-11 min-w-11 px-2 text-xs font-medium text-muted-foreground underline underline-offset-4`,onClick:e,children:`Show where it was asked`})}function oc({text:e}){return(0,$.jsx)(Zr,{role:`agent`,children:(0,$.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,$.jsx)(kn,{breaks:!0,children:e})})})}function sc({ask:e,onShowOrigin:t}){return(0,$.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-lg border border-border bg-card px-4 pt-3.5 pb-3.5`,children:[(0,$.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`})}),(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,$.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,$.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,$.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,$.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,$.jsxs)(`li`,{className:`break-words`,children:[(0,$.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,$.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,$.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,$.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`mt-3 text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,$.jsx)(X,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),t?(0,$.jsx)(ac,{onShowOrigin:t}):null]})}function cc({ask:e,run:t,onShowOrigin:n}){let r=ln(t),i=r.blockedBy!==void 0,a=e.questions,o=a.length===1&&a[0]?.options!==void 0&&a[0]?.multiSelect!==!0,[s,c]=(0,Q.useState)({}),[l,u]=(0,Q.useState)({}),d=(e,t)=>c(n=>({...n,[e]:t})),f=e=>u(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),p=e=>{d(e,[]),u(t=>({...t,[e]:t[e]??``}))},m=a.some((e,t)=>!e.options||l[t]!==void 0),h=a.every((e,t)=>(s[t]?.length??0)>0||!!l[t]?.trim()),g=()=>void r.send(a.map((e,t)=>rc(e,s[t]??[],l[t])).join(`
9
- `)),_=r.mode===`resume`;return(0,$.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":r.mode,className:`rounded-lg border border-accent-strong/25 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card px-4 pt-3.5 pb-3.5`,children:[(0,$.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking`})}),(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,children:a.map((e,t)=>(0,$.jsx)(uc,{question:e,disabled:r.isPending||i,selected:s[t]??[],isOther:l[t]!==void 0,otherAnswer:l[t]??``,onSelect:n=>{i||(f(t),o?r.send(rc(e,n)):d(t,n))},onOtherToggle:()=>{i||(l[t]===void 0?p(t):f(t))},onOtherChange:e=>u(n=>({...n,[t]:e}))},e.id??t))}),(0,$.jsx)(lc,{oneTap:o,hasOtherAnswer:m,resuming:_,disabled:r.isPending||i||!h,questionCount:a.length,onSend:g}),r.blockedBy===`provider`?(0,$.jsxs)(`div`,{"data-slot":`ask-provider-gate`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:r.reason}),(0,$.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,r.blockedBy===`no-session`?(0,$.jsx)(`p`,{"data-slot":`ask-no-session`,className:`mt-3 text-xs text-muted-foreground`,children:r.reason}):null,r.error?(0,$.jsx)(`p`,{"data-slot":`ask-error`,role:`alert`,className:`mt-3 text-xs text-danger`,children:r.error}):null,n?(0,$.jsx)(ac,{onShowOrigin:n}):null]})}function lc({oneTap:e,hasOtherAnswer:t,resuming:n,disabled:r,questionCount:i,onSend:a}){return e&&!t?n?(0,$.jsx)(`p`,{"data-slot":`ask-resume-hint`,className:`mbs-3 text-[11px] text-soft-foreground`,children:`The session has ended — your answer reopens it and goes to the agent.`}):null:(0,$.jsxs)(`div`,{className:`mbs-3 flex items-center gap-2.5`,children:[(0,$.jsx)(K,{size:`sm`,className:`min-h-11`,disabled:r,onClick:a,children:n?`Send answer & reopen`:`Send answer`}),(0,$.jsx)(`span`,{"data-slot":n?`ask-resume-hint`:`ask-hint`,className:`text-[11px] text-soft-foreground`,children:n?`the session has ended — sending reopens it`:t?`${i>1?`answer each question above`:`enter your answer above`} — or type a reply below`:`${i>1?`answer each question`:`pick one or more`} — or type a reply below`})]})}function uc({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,onSelect:a,onOtherToggle:s,onOtherChange:c}){let l=(0,Q.useId)(),u=e.options,d=u!==void 0&&e.multiSelect===!0,f=e=>{if(!d){a([e]);return}a(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,$.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,$.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded-md bg-accent-strong px-1.5 py-0.5 text-[12px] font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),d?(0,$.jsx)(`span`,{className:`ml-auto text-[11px] text-soft-foreground`,children:`select all that apply`}):null]}),(0,$.jsx)(`p`,{className:`mb-2.5 break-words text-sm font-semibold text-foreground`,children:e.question}),u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>{let r=n.includes(e.label);return(0,$.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>f(e.label),className:o(`flex min-h-11 w-full flex-col gap-0.5 rounded-md border px-3.5 py-2.5 text-left transition-colors`,`hover:border-accent-strong/50 hover:bg-accent-strong/[0.06] [html:not(.light)_&]:hover:bg-card disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`:`border-border bg-card`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[14px] font-semibold text-foreground`,children:[d?(0,$.jsx)(`span`,{"aria-hidden":!0,className:o(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,$.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)})}),e.allowFreeText===!1?null:(0,$.jsxs)(`div`,{className:`mt-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?l:void 0,disabled:t,onClick:s,className:o(`w-full justify-start text-left`,r&&`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`),children:`Other`}),r?(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[(0,$.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,$.jsx)(An,{id:l,rows:2,value:i,disabled:t,onChange:e=>c(e.target.value),className:`bg-card`})]}):null]})]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,$.jsx)(An,{id:l,rows:2,value:i,disabled:t,onChange:e=>c(e.target.value),className:`bg-card`})]})]})}var dc=2e3;function fc(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`session.ended`&&r.seq>t&&(t=r.seq),(r.type===`session.started`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function pc(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`turn-end`&&r.seq>t&&(t=r.seq),(r.type===`turn.started`||r.type===`session.started`||r.type===`user-message`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function mc(e,t){let n=v(),r=(0,Q.useMemo)(()=>fc(t),[t]),i=(0,Q.useMemo)(()=>pc(t),[t]),a=e?.id,o=e?.status;(0,Q.useEffect)(()=>{if(!(r!==0&&(o===`running`||o===`waiting`))&&!(i!==0&&o===`running`)||a===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:A.runs.detail(a)}),n.invalidateQueries({queryKey:A.runs.list()})},dc);return()=>clearTimeout(e)},[r,i,a,o,n])}function hc(e){let t=e.querySelector(`[data-slot="ask-origin"]`);return t&&(t.tabIndex=-1),t}function gc({pendingAskId:e,askSeq:t,rows:n,history:r,jumpToRow:i}){let[a,o]=(0,Q.useState)(void 0),s=(0,Q.useCallback)(()=>o(e),[e]),c=r?.visibleEvents,l=t!==void 0&&(c?.some(({seq:e})=>e===t)??!1),u=r?.hasOlder??!1,d=r?.isFetchingOlder??!1,f=r?.olderError,p=r?.loadOlder;return(0,Q.useEffect)(()=>{if(a===void 0)return;if(a!==e){o(void 0);return}let r=uo(n,a,`origin`);if(r){o(void 0),i(r.key,r.index,hc);return}if(!(p!==void 0&&u&&f===void 0&&t!==void 0&&!l)){o(void 0);return}d||p().catch(()=>{})},[a,e,n,c,l,u,d,f,p,t,i]),{reveal:s,seeking:a!==void 0&&a===e}}function _c(){let e=(0,Q.useRef)(null);return(0,Q.useLayoutEffect)(()=>{let t=e.current,n=t?.closest(`[data-slot="main"]`),r=t?.querySelector(`[data-slot="run-header"]`),i=t?.querySelector(`[data-slot="thread-dock"]`);if(!n||!r||!i)return;let a=()=>{n.style.setProperty(`--thread-viewport-height`,`${n.clientHeight}px`),n.style.setProperty(`--thread-header-height`,`${r.getBoundingClientRect().height}px`),n.style.setProperty(`--thread-footer-height`,`${i.getBoundingClientRect().height}px`)};a();let o=new ResizeObserver(a);return o.observe(r),o.observe(i),o.observe(n),()=>{o.disconnect(),n.style.removeProperty(`--thread-header-height`),n.style.removeProperty(`--thread-footer-height`),n.style.removeProperty(`--thread-viewport-height`)}},[]),e}function vc(){let{id:e}=le(),t=O(e),n=an(e),r=t.data?.status,i=(0,Q.useMemo)(()=>ft(n.visibleEvents,{activeTurn:r===`running`}),[n.visibleEvents,r]),a=(0,Q.useMemo)(()=>ft(n.currentEvents,{activeTurn:r===`running`}),[n.currentEvents,r]),o=(0,Q.useRef)(void 0),s=(0,Q.useCallback)(e=>{o.current=e},[]),{mutate:c}=te();if((0,Q.useEffect)(()=>{t.data&&o.current!==t.data.id&&At(t.data)&&c(t.data.id)},[c,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),mc(t.data,n.visibleEvents),t.isPending)return(0,$.jsx)(vn,{});if(t.isError){let e=t.error instanceof l&&t.error.status===404;return(0,$.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,$.jsx)(Nt,{icon:e?(0,$.jsx)(bt,{}):(0,$.jsx)(Ln,{}),tone:e?`neutral`:`danger`,title:e?`Task not found`:`Could not load this task`,subtitle:e?`No run has this id. It may have been deleted, or the link is from another machine.`:t.error.message,actions:(0,$.jsx)(K,{asChild:!0,variant:`outline`,children:(0,$.jsx)(X,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,$.jsx)(vn,{}):(0,$.jsx)(bc,{run:t.data,thread:i,currentThread:a,history:n,onMarkedUnread:s})}var yc=e=>({titles:Object.fromEntries(e.map(e=>[e.id,Z(e)])),backends:Object.fromEntries(e.map(e=>[e.id,e.currentStepBackend??e.runner]))});function bc({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:i}){Ct();let a=se({queryKey:A.runs.list(),queryFn:({signal:e})=>h(z(),{signal:e}),select:yc}),{pendingAsk:o,transcriptAsk:s,pendingAskId:c,historyLoading:l}=xc(r,n),u=m(e),f=ut(e.status,e.error,t),p=un(e),g=!p&&e.status!==`queued`,_=e.status===`queued`,v=Ii(e),y=Jo(e),b=Vo(e.id),x=s||d(e),{hasContinuation:S,continuable:C}=Sc(p,_,v),[D,O]=(0,Q.useState)(void 0),[k,te]=(0,Q.useState)(e.id);k!==e.id&&(te(e.id),O(void 0));let j=(0,Q.useMemo)(()=>D===void 0?void 0:Xi(n.turns,D,g,t.turns),[n.turns,D,g,t.turns]),ne=(0,Q.useMemo)(()=>D===void 0?[]:$i(t.turns,n.turns,D),[t.turns,n.turns,D]),re=ae(e.id),M=ln(e),{providerBlocked:N,providerReason:P}=Cc(p,tn(e),S,v),{mutateAsync:F}=E(e.id),{mutateAsync:I}=ee(e.id),{mutateAsync:L}=T(e.id),R=(0,Q.useMemo)(()=>_?{onEditTask:async e=>{await F({task:e})},onEditMessage:(e,t)=>I({msgId:e,message:{text:t}}).then(()=>void 0),onRemoveMessage:e=>L(e).then(()=>void 0)}:void 0,[_,F,I,L]),B=l?void 0:c??null,oe=(0,Q.useMemo)(()=>lo(e,t,n,B),[e,t,n,B]),V=(0,Q.useMemo)(()=>mo(oe,e.id),[oe,e.id]),le=e.delegation?.role===`root`||e.delegation?.role===`worker`,ue=w(e.id,{enabled:le}),de=(0,Q.useMemo)(()=>({...va(e,void 0,ue.data?.titles),...a.data?.titles,[e.id]:Z(e)}),[e,a.data,ue.data]),pe=(0,Q.useMemo)(()=>({...a.data?.backends,..._a(e,void 0)}),[e,a.data]),me=(0,Q.useCallback)(t=>(0,$.jsx)(ca,{permission:t,runId:e.id,sessionOpen:p}),[e.id,p]),he=(0,Q.useMemo)(()=>{if(R===void 0)return;let t={task:{onEdit:R.onEditTask,editLabel:`Edit the prompt`}};for(let n of e.queuedMessages??[])t[`queued:${n.id}`]={onEdit:e=>R.onEditMessage(n.id,e),onRemove:()=>R.onRemoveMessage(n.id)};return t},[R,e.queuedMessages]),ge=fe(e,ie()),{search:H}=ce(),_e=Tr(H,V.length),U=$a(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:V.map(({key:e})=>e)}),{pinnedAsk:ve,pendingQuestions:ye}=wc(oe),be=gc({pendingAskId:c,askSeq:r?o?.seq:void 0,rows:V,history:r,jumpToRow:U.jumpToRow}),xe=(0,Q.useRef)(c);l||(xe.current=c);let Se=(0,Q.useRef)({rows:V,jumpToRow:U.jumpToRow,reveal:be.reveal});Se.current={rows:V,jumpToRow:U.jumpToRow,reveal:be.reveal};let Ce=(0,Q.useCallback)(t=>t.placement===`origin`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.resolved&&t.context?(0,$.jsx)(oc,{text:t.context}):null,t.resolved?null:(0,$.jsx)(Ya,{onGoToQuestion:()=>{let{rows:e,jumpToRow:n}=Se.current,r=uo(e,t.id,`pinned`);r&&n(r.key,r.index,e=>Ka(e))}})]}):(0,$.jsx)(ic,{ask:t,run:e,onShowOrigin:()=>Se.current.reveal()}),[e]);return St(U.restickIfStuck),(0,$.jsxs)(`div`,{ref:_c(),"data-route":`task-thread`,"data-run-id":e.id,className:`flex min-h-full flex-col`,children:[(0,$.jsx)(Qe,{run:e,onMarkedUnread:()=>i?.(e.id)}),(0,$.jsx)(Tc,{run:e,thread:t,history:r,footer:f,issueUrl:ge,sections:oe,renderAsk:Ce,renderPermission:me,messageActions:he,scroll:U,mode:_e,taskTitles:de,recipientBackends:pe}),(0,$.jsx)(qo,{status:e.status}),(0,$.jsx)(Co,{runId:e.id,renderAsk:Ce,renderPermission:me,agent:j,entries:ne,taskTitles:de,recipientBackends:pe,onClose:()=>O(void 0)}),(0,$.jsx)(Ec,{run:e,thread:t,currentThread:n,currentComplete:r?.currentComplete??!0,scroll:U,pendingQuestions:ye,onJump:()=>{let e=ye>0?ve?.id:void 0;U.jumpToLatest(e===void 0?void 0:qa(e,()=>xe.current===e))},onOpenWorker:O,sessionOpen:p,attention:u,queued:_,continuable:C,continueAction:v,stopAction:y,finishAction:b,needsAnswer:x,sendMessage:re,reply:M,providerBlocked:N,providerReason:P}),(0,$.jsx)(`div`,{"data-slot":`thread-tail-anchor`,"aria-hidden":`true`,className:`h-px shrink-0 md:hidden`})]})}function xc(e,t){let n=e?ct(e.currentEvents):void 0;return{pendingAsk:n,transcriptAsk:e?n!==void 0:t.turns.some(e=>e.items.some(e=>e.kind===`ask`&&!e.resolved)),pendingAskId:e?n?.requestId:t.turns.flatMap(e=>e.items).reverse().find(e=>e.kind===`ask`&&!e.resolved)?.id,historyLoading:e!==void 0&&(e.isPending||e.contextPending)}}function Sc(e,t,n){let r=!e&&!t&&n.available;return{hasContinuation:r,continuable:r&&n.canContinue}}function Cc(e,t,n,r){let i=e&&!t.usable,a=n&&!r.canContinue;return{providerBlocked:i||a,providerReason:i?t.reason:r.reason}}function wc(e){let t=e.at(-1),n=t?.id===`pending-ask`?t.entries[0]:void 0;return{pinnedAsk:n,pendingQuestions:n?.kind===`ask`?n.questions.length:0}}function Tc({run:e,thread:t,history:n,footer:r,issueUrl:i,sections:s,renderAsk:c,renderPermission:l,messageActions:u,scroll:d,mode:f,taskTitles:p,recipientBackends:m}){return(0,$.jsxs)(`div`,{"data-slot":`session-conversation`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-1 flex-col gap-2.5 px-[18px] py-3 md:gap-3.5 md:px-16 md:py-5`,children:[n?(0,$.jsx)(jc,{hasOlder:n.hasOlder,loading:n.isFetchingOlder,error:n.olderError,fallback:n.fallback,retainedPages:n.retainedPages,onLoad:d.loadOlder}):null,(0,$.jsx)(ho,{runId:e.id,viewId:`main`,sections:s,mode:`document`,renderAsk:c,renderPermission:l,messageActions:u,scrollControls:d,renderMode:f,taskTitles:p,recipientBackends:m}),t.turns.length===0?e.status===`queued`?(0,$.jsx)(Mc,{run:e}):(0,$.jsx)(`p`,{"data-slot":`thread-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:`No session events yet.`}):null,e.status===`running`?(0,$.jsx)(si,{}):null,r&&r.state===`closed`?(0,$.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":r.state,className:o(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,r.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[r.label,a(pe(e))?(0,$.jsx)(`a`,{"data-slot":`pr-link`,href:pe(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,a(i)?(0,$.jsx)(`a`,{"data-slot":`issue-link`,href:i,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`?(0,$.jsx)(Ho,{run:e}):null]})}function Ec({run:e,thread:t,currentThread:n,currentComplete:r,scroll:i,pendingQuestions:a,onJump:o,onOpenWorker:s,sessionOpen:c,attention:l,queued:u,continuable:d,continueAction:f,stopAction:p,finishAction:m,needsAnswer:h,sendMessage:g,reply:v,providerBlocked:y,providerReason:b}){return(0,$.jsxs)(`div`,{"data-slot":`thread-dock`,className:`relative z-10 bg-background pt-1 pb-2 md:pt-1.5 md:pb-4`,children:[i.pillVisible?(0,$.jsx)(`div`,{"data-slot":`thread-jump`,className:`pointer-events-none z-30 flex justify-center`,children:(0,$.jsx)(ro,{pendingQuestions:a,onJump:o})}):null,(0,$.jsxs)(`div`,{"data-slot":`thread-footer-content`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-col gap-1.5 px-[14px] md:gap-2.5 md:px-16`,children:[(0,$.jsx)(Ps,{run:e,thread:t,currentThread:n,currentComplete:r,onOpenWorker:s,readerScroll:i.subscribeReaderScroll},e.id),(0,$.jsx)(Bn,{run:e}),e.status===`waiting`&&c?(0,$.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(jt,{tone:l.tone,shape:l.shape,pulse:l.pulse}),l.bucket===`permission`?`Choose an approval option above to continue`:l.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${l.label.charAt(0).toUpperCase()}${l.label.slice(1)} — you can send a message to resume`]}):null,u?(0,$.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(jt,{tone:`neutral`,shape:`ring`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,d&&e.removedRunner!==void 0?(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:_(e.removedRunner)}):d&&f.startsNewConversation?(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null,(0,$.jsx)(Oc,{run:e,thread:t,stopAction:p,finishAction:m,attention:l,needsAnswer:h,continuable:d,continueAction:f,queued:u,sendMessage:g,reply:v,providerBlocked:y,providerReason:b,sessionOpen:c})]})]})}function Dc(e,t,n){if(t)return{skillRunner:n.skillRunner,skillAccount:n.skillAccount};let r=e.steps.find(t=>t.id===e.currentStepId),i=e.workflowDef?.steps.find(t=>t.id===e.currentStepId);return{skillRunner:r?.backend??i?.runner??e.runner,skillAccount:r?.profileId??i?.agentProfile??e.agentProfile}}function Oc({run:e,thread:t,stopAction:n,finishAction:r,attention:i,needsAnswer:a,continuable:o,continueAction:s,queued:c,sendMessage:l,reply:u,providerBlocked:d,providerReason:f,sessionOpen:p}){let m=ze(e);return(0,$.jsx)(Xt,{...Dc(e,o,s),onStop:dn(e,m).cancel?n.stop:void 0,onFinish:hn(e)?()=>r.mutateAsync().catch(()=>void 0):void 0,finishing:r.isPending,secondaryAction:fn(e,m)?(0,$.jsx)(tt,{run:e,compactOnMobile:!0}):void 0,stopOnEmpty:kc(e,i,a),stopping:n.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:o?`Continuing…`:`Sending…`,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:o?s.pills:void 0,onSubmit:o?(e,t)=>s.continueWith(e,t):c?(e,t)=>l.mutateAsync({text:e,images:t}):async(e,t)=>{let n=await u.send(e,t);if(n!==void 0)throw Error(n)},disabled:d||!p&&!c&&!o,disabledReason:d?f:`Session closed — no session to resume.`,footerEnd:d&&!s.providerPending?(0,$.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:o&&!a,emptySubmitLabel:o&&!a?`Continue`:void 0,placeholder:Ac(e,c,o),autocompleteSkills:!0,quickReplies:!0,getMentionCandidates:()=>mt(t)})}function kc(e,t,n){return e.status===`queued`||e.status===`running`||e.status===`waiting`&&t.bucket===`none`&&!n}function Ac(e,t,n){return t?`Add to the prompt — sent when the run starts…`:n?`Continue — add a prompt, or send to just reopen the session…`:e.status===`waiting`?`Reply — / for skills, @ for files…`:`Message the agent — / for skills, @ for files…`}function jc({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,$.jsx)(`p`,{"data-slot":`history-fallback`,className:`text-center text-xs text-soft-foreground`,role:`status`,children:`Progressive history is unavailable; showing the complete session.`}):!e&&!n?(0,$.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-[11px] text-soft-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,$.jsxs)(`div`,{"data-slot":`history-boundary`,"data-retained-pages":i,"aria-busy":t,className:`flex min-h-8 items-center justify-center text-xs text-muted-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:a,disabled:t,className:`rounded-md px-3 py-1.5 font-medium hover:bg-muted disabled:cursor-wait`,children:t?`Loading 100 earlier items…`:n?`Couldn’t load earlier items · Retry`:`Load 100 earlier items`}),(0,$.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function Mc({run:e}){let t=Qt(F().data??[],e.id);return(0,$.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,$.jsx)(jt,{tone:`neutral`,shape:`ring`}),(0,$.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,$.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{vc as TaskThreadRoute};
@@ -1 +0,0 @@
1
- import{Qr as e,li as t}from"./project-scope-context-Dq-Iq7xE.js";function n(n,r){return e(n,t,r)}export{n as t};
@@ -1,7 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{An as i,D as a,E as o,c as s,ci as c,d as l}from"./project-scope-context-Dq-Iq7xE.js";import{D as u,E as d,Lt as f,Vt as p,in as m}from"./queries-Dd6O2cf-.js";import{h}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as g}from"./toaster-Bo5vCbz-.js";import{J as ee,S as _,X as v,at as y,b as te,c as ne,ft as re,i as b,l as ie,lt as x,n as ae,ot as oe,st as S,tt as se,v as C,x as w}from"./design-icons-CzEoMH9c.js";import{t as T}from"./button-BQ2y4XRB.js";import{i as E,p as ce,r as D,t as O}from"./dropdown-menu-4e2iKSMT.js";import{i as k,o as le,r as A,s as ue,t as j}from"./dialog-BVF6dIeS.js";import{i as de,l as fe,o as pe}from"./skills-pM_PouEs.js";import{t as me}from"./centered-state-V15AR_qo.js";import{Gn as M,Gt as N,Ht as P,Jt as F,Kt as I,T as he,Ut as L,Vt as R,Wt as z,qt as B}from"./index-8Pe4JlYM.js";import{_ as V,a as ge,c as _e,f as ve,g as ye,h as be,i as xe,m as H,n as Se,o as Ce,p as U,r as W,t as G,u as we}from"./sortable.esm-CAVTYaA3.js";import{t as K}from"./textarea-vJt9undk.js";var q=e(t(),1);function J(e){let t=[];for(let n of e){if(n.kind===`plugin`||n.command||!n.skill||n.prompt!==void 0&&n.prompt!==`{{task}}`||n.name!==void 0&&n.name!==n.skill||n.timeoutMs!==void 0||n.model||n.effort!==void 0||n.runner||n.agentProfile||n.allowedTools||n.bashAllowlist||n.onFail)return null;t.push(n.skill)}return t.length?t:null}function Te(e,t){let n=new Set(t.map(e=>e.id)),r=e;for(let t=2;n.has(r);t++)r=`${e}-${t}`;return{id:r,name:e,skill:e,prompt:`{{task}}`}}function Ee(e,t,n){let r=[...e];return r.splice(Math.max(0,Math.min(n,r.length)),0,t),r}function De(e,t,n){if(t===n||t<0||t>=e.length||n<0||n>=e.length)return[...e];let r=[...e],[i]=r.splice(t,1);return i===void 0?[...e]:(r.splice(n,0,i),r)}function Oe(e,t){return e.filter((e,n)=>n!==t)}function Y(e){let t=String(e),n=/^[A-Za-z0-9._][A-Za-z0-9 ._/-]*$/.test(t)&&!t.endsWith(` `),r=/^(true|false|yes|no|on|off|null|~)$/i.test(t)||/^[-+.]?\d/.test(t);return n&&!r?t:JSON.stringify(t)}function X(e,t,n){let r=` `.repeat(n);return t.includes(`
2
- `)?[`${r}${e}: |`,...t.split(`
3
- `).map(e=>`${r} ${e}`)]:[`${r}${e}: ${Y(t)}`]}function ke(e){let t=[];return e.name&&e.name!==e.id&&t.push(` name: ${Y(e.name)}`),e.skill&&t.push(` skill: ${Y(e.skill)}`),t}function Ae(e){let t=[];return e.model&&t.push(` model: ${Y(e.model)}`),e.timeoutMs!==void 0&&t.push(` timeoutMs: ${e.timeoutMs}`),e.effort!==void 0&&t.push(` effort: ${Y(e.effort)}`),e.runner&&t.push(` runner: ${Y(e.runner)}`),e.agentProfile&&t.push(` agentProfile: ${Y(e.agentProfile)}`),t}function Z(e){let t=[];return e.allowedTools&&t.push(` allowedTools: [${e.allowedTools.map(Y).join(`, `)}]`),e.bashAllowlist&&t.push(` bashAllowlist: [${e.bashAllowlist.map(Y).join(`, `)}]`),t}function je(e){return e.onFail?[` onFail:`,` retry: ${Y(e.onFail.retry)}`,` max: ${e.onFail.max??2}`]:[]}function Me(e){return[` - id: ${Y(e.id)}`,...ke(e),...e.prompt?X(`prompt`,e.prompt,4):[],...e.kind===`plugin`?[` kind: plugin`,` pluginKind: ${Y(e.pluginKind)}`,...e.config===void 0?[]:[` config: ${JSON.stringify(e.config)}`]]:[],...Ae(e),...Z(e),...e.command?X(`command`,e.command,4):[],...je(e)]}function Ne(e,t,n){let r=[`name: ${Y(e.trim()||`my-workflow`)}`];t.trim()&&r.push(...X(`description`,t.trim(),0));let i=J(n);if(i){r.push(`skills:`);for(let e of i)r.push(` - ${Y(e)}`)}else if(n.length){r.push(`steps:`);for(let e of n)r.push(...Me(e))}else r.push(`skills: []`);return`${r.join(`
4
- `)}\n`}function Pe(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`workflow`}function Fe(e){let t=J(e)?`skill`:`step`;return`${e.length} ${t}${e.length===1?``:`s`}`}function Ie(e,t){let n=new Set,r=[];for(let t of e.steps.slice(0,8)){let e=t.id||`step`,i=e;for(let t=2;n.has(i);t++)i=`${e}-${t}`;n.add(i),r.push({...t,id:i})}return{name:e.name?.trim()||t,steps:r}}function Le(e,t,n){let r=J(n);return{name:e.trim(),...t.trim()?{description:t.trim()}:{},...r?{skills:r}:{steps:[...n]}}}var Q=n();function Re({workflows:e,draft:t,trimmedName:n,nameRef:r,onDraft:i,onLoadWorkflow:a}){return(0,Q.jsxs)(`section`,{"data-slot":`wb-metadata`,className:`flex min-w-0 flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{"data-slot":`wb-load`,className:`flex flex-col items-start gap-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`workflow-load`,className:`text-xs text-muted-foreground`,children:`Load an existing workflow`}),(0,Q.jsxs)(`div`,{className:`relative max-w-full`,children:[(0,Q.jsx)(ie,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,Q.jsxs)(`select`,{id:`workflow-load`,value:e.some(e=>e.name===n)?n:``,onChange:t=>{let n=e.find(e=>e.name===t.target.value);n&&a(n)},className:`h-11 max-w-full rounded-lg border border-border bg-card pl-9 pr-3 text-xs font-medium appearance-none focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(`option`,{value:``,disabled:!0,children:`Choose a workflow`}),e.map(e=>(0,Q.jsx)(`option`,{value:e.name,"data-slot":`wb-load-option`,"data-name":e.name,children:e.name},e.name))]})]})]}),(0,Q.jsx)(`label`,{htmlFor:`workflow-name`,className:`text-xs font-semibold`,children:`Workflow name`}),(0,Q.jsx)(M,{id:`workflow-name`,ref:r,"data-slot":`wb-name`,"aria-label":`Workflow name`,spellCheck:!1,value:t.name,onChange:e=>i({...t,name:e.target.value}),className:`h-12 bg-card text-sm`}),(0,Q.jsx)(`label`,{htmlFor:`workflow-description`,className:`text-xs font-semibold`,children:`Description`}),(0,Q.jsx)(K,{id:`workflow-description`,"data-slot":`wb-description`,"aria-label":`Description`,value:t.description,onChange:e=>i({...t,description:e.target.value}),className:`min-h-[72px] bg-card p-3.5 text-sm`})]})}function ze({savedFile:e,autoOpen:t,onImportToggle:n,onExport:r,onAutoToggle:i,onDeleteRequest:a}){return(0,Q.jsxs)(`div`,{"data-slot":`wb-actions`,className:`grid grid-cols-[max-content_max-content] items-center justify-start gap-2 sm:flex sm:flex-wrap [&_button]:min-h-11 [&_button]:border [&_button]:border-border [&_button]:bg-card`,children:[(0,Q.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-import`,className:`col-span-2 justify-self-start`,onClick:n,children:[(0,Q.jsx)(S,{"aria-hidden":`true`,className:`size-3`}),`Import`]}),(0,Q.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-export`,className:`col-span-2 justify-self-start`,title:`Download workflow.yaml`,onClick:r,children:[(0,Q.jsx)(te,{"aria-hidden":`true`,className:`size-3`}),`Export`]}),(0,Q.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-auto`,"aria-expanded":t,title:`Describe a chain — the agent builds it`,onClick:i,children:[(0,Q.jsx)(x,{"aria-hidden":`true`,className:`size-3`}),`Auto`]}),e?(0,Q.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-delete`,className:`text-danger hover:text-danger`,title:`Delete the saved workflow file`,onClick:a,children:[(0,Q.jsx)(y,{"aria-hidden":`true`,className:`size-3`}),`Delete`]}):null]})}function Be({text:e,onTextChange:t,pending:n,onRun:r,onCancel:i}){return(0,Q.jsxs)(`div`,{"data-slot":`wb-auto-panel`,className:`rounded-xl border border-border bg-card p-5 [&_button]:min-h-11`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-normal`,children:`Build a chain from a prompt`}),(0,Q.jsx)(`p`,{className:`mt-4 text-[13px] leading-relaxed text-muted-foreground`,children:`Describe the outcome. An agent proposes a title and ordered skill/check steps. Review the result, edit it, then Save.`}),(0,Q.jsx)(K,{"data-slot":`wb-auto-text`,"aria-label":`Describe the chain to build`,rows:3,autoFocus:!0,placeholder:`e.g. Fix the bug, run the tests, then review the diff for regressions.`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),r())},className:`mt-4 min-h-[108px] bg-background p-4 text-sm`}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,Q.jsxs)(T,{type:`button`,variant:`primary`,size:`sm`,"data-slot":`wb-auto-run`,disabled:n||e.trim()===``,onClick:r,children:[(0,Q.jsx)(x,{"aria-hidden":`true`,className:`size-3`}),n?`Building…`:`Build chain`]}),(0,Q.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-auto-cancel`,onClick:i,children:[(0,Q.jsx)(re,{"aria-hidden":`true`,className:`size-4`}),`Cancel`]})]}),(0,Q.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`Creates an editable draft. Review the generated name and steps before saving.`})]})}function Ve({open:e,onOpenChange:t,text:n,onTextChange:r,error:i,pending:a,onRun:o,onCancel:s}){return(0,Q.jsx)(j,{open:e,onOpenChange:t,children:(0,Q.jsxs)(A,{showCloseButton:!1,"data-slot":`wb-import-panel`,className:`max-md:translate-x-0 max-md:translate-y-0 sm:max-w-[660px] rounded-xl border border-border bg-card p-5 [&_button]:min-h-11`,children:[(0,Q.jsx)(ue,{className:`text-xl font-normal`,children:`Import workflow YAML`}),(0,Q.jsx)(k,{className:`sr-only`,children:`Paste a portable workflow definition to import.`}),(0,Q.jsx)(K,{"data-slot":`wb-import-text`,"aria-label":`Workflow YAML to import`,rows:4,spellCheck:!1,placeholder:`name: my-flow
5
- skills:
6
- - test-conventions
7
- - commit-style`,value:n,onChange:e=>r(e.target.value),className:`mt-4 min-h-[124px] bg-background p-4 font-mono text-[13px] leading-relaxed`}),(0,Q.jsx)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:`Paste a portable workflow definition. Imported steps appear in execution order.`}),i===``?null:(0,Q.jsx)(`p`,{"data-slot":`wb-import-error`,role:`alert`,className:`mt-2 text-xs text-danger`,children:i}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,Q.jsx)(T,{type:`button`,variant:`primary`,size:`sm`,"data-slot":`wb-import-run`,disabled:a,onClick:o,children:`Import`}),(0,Q.jsx)(T,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-import-cancel`,onClick:s,children:`Cancel`})]})]})})}function He({paletteSkills:e,query:t,onQueryChange:n,error:r,inFlow:i,onAdd:a,yaml:o}){return(0,Q.jsxs)(`aside`,{"data-slot":`wb-aside`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:`Available skills`}),(0,Q.jsxs)(`div`,{className:`sw-search relative mt-4`,children:[(0,Q.jsx)(v,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,Q.jsx)(M,{"data-slot":`wb-filter`,placeholder:`Find a skill…`,"aria-label":`Filter skills`,value:t,onChange:e=>n(e.target.value),className:`h-11 pl-9 text-xs`})]}),(0,Q.jsx)(nt,{skills:e,query:t,error:r,inFlow:i,onAdd:a}),(0,Q.jsx)(`h3`,{className:`mt-5 text-sm font-semibold`,children:`workflow.yaml`}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-muted-foreground`,children:`Export the workflow to use this chain in another project.`}),(0,Q.jsxs)(`details`,{className:`mt-4 min-w-0`,children:[(0,Q.jsxs)(`summary`,{"data-slot":`wb-yaml-toggle`,className:`inline-flex min-h-[44px] cursor-pointer items-center rounded-lg border border-border px-3 text-xs font-medium focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(_,{"aria-hidden":`true`,className:`mr-2 size-4`}),`View YAML`]}),(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsx)(it,{yaml:o})}),(0,Q.jsx)(`pre`,{"data-slot":`wb-yaml`,className:`mt-2 max-h-96 overflow-auto rounded-lg border border-border bg-background p-3 font-mono text-[11px] leading-relaxed whitespace-pre text-muted-foreground`,children:o})]})]})}function Ue({dragging:e,steps:t,skills:n}){return e?.type===`palette`?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-1.5 font-mono text-[13px] font-medium shadow-md`,children:[(0,Q.jsx)(se,{"aria-hidden":`true`,className:`size-3.5 text-link-foreground`}),e.skill]}):e?.type===`step`?(0,Q.jsx)(tt,{step:e.step,index:t.findIndex(t=>t.id===e.step.id),skills:n,overlay:!0}):null}function We({open:e,onOpenChange:t,query:n,onQueryChange:r,matches:i,skillsCount:a,error:o,selectedSkill:s,onSelectSkill:c,stepsCount:l,onCloseAutoFocus:u,onCancel:d,onAdd:f}){return(0,Q.jsx)(j,{open:e,onOpenChange:t,children:(0,Q.jsxs)(A,{"data-slot":`wb-add-dialog`,onCloseAutoFocus:u,className:`max-h-[85dvh] overflow-y-auto sm:max-w-[660px] [&_button]:min-h-11`,children:[(0,Q.jsxs)(le,{children:[(0,Q.jsx)(ue,{className:`text-xl font-normal`,children:`Add step`}),(0,Q.jsx)(k,{className:`sr-only`,children:`Choose a skill to append to this workflow.`})]}),(0,Q.jsx)(M,{"aria-label":`Filter skills`,placeholder:`Filter skills…`,value:n,onChange:e=>r(e.target.value)}),o===null?(0,Q.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Available skills`,className:`grid max-h-80 gap-2 overflow-y-auto`,children:[i.map(e=>(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg py-2 has-[:checked]:bg-accent-strong/10 has-[:focus-visible]:outline-2`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`workflow-add-skill`,className:`sr-only`,value:e.id,checked:s===e.id,onChange:()=>c(e.id)}),(0,Q.jsxs)(`span`,{className:`min-w-0 break-words text-sm`,children:[(0,Q.jsx)(`span`,{className:`block`,children:e.name}),(0,Q.jsx)(`span`,{className:`mt-2 block text-xs text-muted-foreground`,children:e.description}),e.path?(0,Q.jsx)(`span`,{className:`block break-all text-xs`,children:e.path}):null]})]},JSON.stringify([e.id,e.path]))),i.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a===0?`No skills available in this project.`:`No matching skills.`}):null]}):(0,Q.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not load skills: `,o]}),n.trim()&&!i.some(e=>e.id===n.trim())?(0,Q.jsxs)(T,{onClick:()=>c(n.trim()),children:[`Use skill id “`,n.trim(),`” (unchecked)`]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsx)(T,{variant:`outline`,onClick:d,children:`Cancel`}),(0,Q.jsx)(T,{variant:`primary`,disabled:!s||l>=8,onClick:()=>{s&&f(s)},children:`Add selected skill`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Append the selected skill, then reorder it in the existing canvas.`}),l>=8?(0,Q.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`A workflow can contain up to `,8,` steps. Remove a step before adding another.`]}):null]})})}function Ge({trimmedName:e,savedFile:t,overwriteOpen:n,onOverwriteDismiss:r,deleteOpen:i,onDeleteDismiss:a,onOverwrite:o,onDelete:s}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(R,{open:n,onOpenChange:e=>!e&&r(),children:(0,Q.jsxs)(z,{"data-slot":`wb-overwrite-dialog`,className:`sw-workflow-confirm sm:max-w-[660px]`,children:[(0,Q.jsxs)(B,{children:[(0,Q.jsxs)(F,{children:[`“`,e,`” already exists`]}),(0,Q.jsx)(N,{children:`Saving overwrites the existing workflow file. There is no undo.`})]}),(0,Q.jsxs)(I,{children:[(0,Q.jsx)(L,{children:`Keep the file`}),(0,Q.jsx)(P,{"data-slot":`wb-overwrite-confirm`,className:`bg-danger text-danger-foreground`,onClick:o,children:`Overwrite`})]})]})}),(0,Q.jsx)(R,{open:i,onOpenChange:e=>!e&&a(),children:(0,Q.jsxs)(z,{"data-slot":`wb-delete-dialog`,className:`sw-workflow-confirm sm:max-w-[660px]`,children:[(0,Q.jsxs)(B,{children:[(0,Q.jsxs)(F,{children:[`Delete workflow “`,e,`”?`]}),(0,Q.jsxs)(N,{children:[`Removes `,t?.path?.split(`/`).pop()??`the saved file`,` from`,` `,(0,Q.jsx)(`span`,{className:`font-mono`,children:`.ai/cezar/workflows/`}),`. There is no undo.`]})]}),(0,Q.jsxs)(I,{children:[(0,Q.jsx)(L,{children:`Keep the file`}),(0,Q.jsx)(P,{"data-slot":`wb-delete-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:s,children:`Delete workflow`})]})]})})]})}function Ke(e){return e.name??e.skill??e.id}function qe(e){return e.prompt?.trim()===`{{task}}`?void 0:e.prompt?.trim()}function Je(e){let t=e.onFail?` — on fail retry from "${e.onFail.retry}" (×${e.onFail.max??2})`:``;return`$ ${e.command}${t}`}function Ye(e,t){return qe(e)||t?.description||`Not listed by this runner and account. Step open will check the skill id.`}function Xe(e,t){return e.command?Je(e):e.skill?Ye(e,t):e.prompt??``}function Ze(e,t){return e.skill&&!t?`unknown`:null}function Qe(e){return e.command?`Command step${e.onFail?` · Retry ×${e.onFail.max??2}`:``}`:e.skill?`Skill step`:`Prompt step`}function $e({index:e,title:t,badge:n,onRemove:i,gripProps:a}){return(0,Q.jsxs)(`div`,{"data-slot":`wb-step-heading`,className:`flex min-w-0 items-center gap-2.5`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-step-grip`,"aria-label":`Reorder step ${e+1}: ${t}`,className:`inline-flex size-[26px] shrink-0 cursor-grab items-center justify-center rounded-md text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,...a,children:(0,Q.jsx)(`span`,{className:`rounded bg-accent-strong/10 px-2 py-1 font-mono text-[12px] text-link-foreground`,children:String(e+1).padStart(2,`0`)})}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1 break-words text-sm font-medium [overflow-wrap:anywhere]`,children:t}),n?(0,Q.jsx)(`span`,{"data-slot":`wb-step-badge`,className:r(`shrink-0 rounded-full border px-2 py-px font-mono text-[11px]`,n===`unknown`&&`border-danger/35 text-danger`),children:n}):null,i?(0,Q.jsxs)(O,{children:[(0,Q.jsx)(ce,{asChild:!0,children:(0,Q.jsx)(T,{"data-slot":`wb-step-actions`,variant:`ghost`,size:`icon`,className:`size-[26px]`,"aria-label":`Step ${e+1} actions: ${t}`,children:(0,Q.jsx)(w,{"aria-hidden":`true`,className:`size-4`})})}),(0,Q.jsx)(D,{align:`end`,children:(0,Q.jsxs)(E,{"data-slot":`wb-step-remove`,"aria-label":`Remove step ${e+1}: ${t}`,onSelect:i,children:[(0,Q.jsx)(y,{"aria-hidden":`true`}),` Remove step`]})})]}):null]})}function et({index:e,onMoveUp:t,onMoveDown:n}){return(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 @min-[900px]:hidden`,children:[(0,Q.jsxs)(T,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":`Move step ${e+1} up`,disabled:!t,onClick:t,children:[(0,Q.jsx)(b,{"aria-hidden":`true`,className:`size-4`}),`Move up`]}),(0,Q.jsxs)(T,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":`Move step ${e+1} down`,disabled:!n,onClick:n,children:[(0,Q.jsx)(ae,{"aria-hidden":`true`,className:`size-4`}),`Move down`]})]})}function tt({step:e,index:t,skills:n,onRemove:i,gripProps:a,onMoveUp:o,onMoveDown:s,overlay:c=!1}){let l=n.find(t=>t.id===e.skill),u=Ke(e),d=Xe(e,l),f=Ze(e,l);return(0,Q.jsxs)(`div`,{"data-slot":`wb-step`,"data-id":e.id,"data-index":t,className:r(`rounded-lg border border-border bg-background p-4`,c&&`shadow-md`),children:[(0,Q.jsx)($e,{index:t,title:u,badge:f,onRemove:i,gripProps:a}),d?(0,Q.jsx)(`div`,{"data-slot":`wb-step-summary`,className:`mt-3 break-words text-xs leading-relaxed text-muted-foreground`,children:d}):null,(0,Q.jsx)(`p`,{"data-slot":`wb-step-kind`,className:`mt-3 text-[12px] text-link-foreground`,children:Qe(e)}),c?null:(0,Q.jsx)(et,{index:t,onMoveUp:o,onMoveDown:s})]})}function nt({skills:e,query:t,error:n,inFlow:r,onAdd:i}){if(n!==null)return(0,Q.jsxs)(`p`,{"data-slot":`wb-palette`,className:`mt-2.5 text-xs text-danger`,children:[`Could not load skills: `,n]});let a=fe(e,t);return(0,Q.jsx)(`div`,{"data-slot":`wb-palette`,className:`mt-2.5 flex flex-col gap-1`,children:a.length>0?a.map(e=>(0,Q.jsx)(rt,{skill:e,inFlow:r.has(e.id),onAdd:i},JSON.stringify([e.id,e.path]))):(0,Q.jsx)(`p`,{className:`py-1 text-xs leading-relaxed text-soft-foreground`,children:e.length>0?`No skills match.`:`This runner reports no skills.`})})}function rt({skill:e,inFlow:t,onAdd:n}){let{attributes:i,listeners:a,setNodeRef:o,isDragging:s}=U({id:`palette:${JSON.stringify([e.id,e.path])}`,data:{type:`palette`,skill:e.id}});return(0,Q.jsxs)(`div`,{ref:o,"data-slot":`wb-skill`,"data-skill":e.id,"data-in-flow":t||void 0,title:e.description??``,className:r(`flex min-h-11 cursor-grab items-center gap-2 rounded-md py-1 transition-colors hover:bg-muted`,s&&`opacity-40`),...i,...a,children:[(0,Q.jsxs)(`span`,{className:r(`min-w-0 flex-1 break-words text-xs`,de(e)?`font-semibold text-foreground`:`font-medium text-muted-foreground`),children:[e.name,e.path?(0,Q.jsx)(`span`,{className:`block break-all text-xs text-soft-foreground`,children:e.path}):null]}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-skill-add`,"aria-label":`Add ${e.name} to the flow`,title:`Add to the flow`,onClick:()=>n(e.id),className:`inline-flex size-11 shrink-0 items-center justify-center rounded-md text-link-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:(0,Q.jsx)(ee,{"aria-hidden":`true`,className:`size-3.5`})})]})}function it({yaml:e}){let[t,n]=(0,q.useState)(!1),r=(0,q.useRef)(null);return(0,q.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-copy`,title:`Copy the YAML`,onClick:()=>{navigator.clipboard?.writeText(e).catch(()=>{}),n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),1600)},className:`flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,children:t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ne,{"aria-hidden":`true`,className:`size-3 text-success`}),`Copied`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(C,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})})}var at=`wb-canvas`;function $(){return{name:`my-workflow`,description:``,steps:[]}}function ot(e){return{name:e.name,description:e.description??``,steps:structuredClone(e.steps??[])}}function st(){let{name:e}=h();return(0,Q.jsx)(ct,{routeName:e},e??``)}function ct({routeName:e}){let t=u(),n=p(),r=d(),h=c(),[_,v]=(0,q.useState)(null),[y,te]=(0,q.useState)(``),[re,b]=(0,q.useState)(!1),[ie,x]=(0,q.useState)(``),[ae,S]=(0,q.useState)(null),[se,C]=(0,q.useState)(!1),[w,E]=(0,q.useState)(``),[ce,D]=(0,q.useState)(``),[O,k]=(0,q.useState)(!1),[le,A]=(0,q.useState)(``),[ue,j]=(0,q.useState)(!1),[de,M]=(0,q.useState)(!1),[N,P]=(0,q.useState)(null),[F,I]=(0,q.useState)(null),L=(0,q.useRef)(null),R=(0,q.useRef)(null),z=t.data?.workflows??[],B=n.data??[],V=pe(B,r.data?.skillUsage),xe=fe(V,ie,r.data?.skillUsage);(0,q.useEffect)(()=>{if(_!==null||t.data===void 0)return;let n=t.data.workflows,r=(e?n.find(t=>t.name===e):void 0)??n.find(e=>e.source===`file`);v(r?ot(r):$())},[_,t.data,e]);let H=e=>v(t=>t===null?t:{...t,steps:e}),U=m({mutationFn:e=>o(e),onSuccess:e=>{v({name:e.name,description:e.description??``,steps:e.steps}),C(!1),E(``),D(``),g(`Imported "${e.name}" — review, then Save.`)},onError:e=>D(e.message)}),W=m({mutationFn:e=>a(e),onSuccess:e=>{v(t=>{let n=t??$(),{name:r,steps:i}=Ie(e,n.name);return{...n,name:r,steps:i}}),k(!1),A(``),g(e.fallback?`Planner unavailable — added a single step. Edit, then Save.`:`Built "${e.name??_?.name??`workflow`}" — review, tweak, then Save.`,e.fallback?{tone:`danger`}:void 0)},onError:e=>g(e instanceof Error?e.message:String(e),{tone:`danger`})}),G=m({mutationFn:e=>s({...Le(_?.name??``,_?.description??``,_?.steps??[]),...e?{overwrite:!0}:{}}),onSuccess:e=>{j(!1),g(`Saved — ${e.path.split(`/`).pop()??e.path}`),h.invalidateQueries({queryKey:f.workflows})},onError:e=>{e instanceof i&&e.exists===!0?j(!0):g(e instanceof Error?e.message:String(e),{tone:`danger`})}}),K=m({mutationFn:e=>l(e),onSuccess:(e,t)=>{M(!1),g(`Deleted "${t}".`),v($()),h.invalidateQueries({queryKey:f.workflows})},onError:e=>{M(!1),g(e instanceof Error?e.message:String(e),{tone:`danger`})}}),J=ye(be(we,{activationConstraint:{distance:4}}),be(_e,{coordinateGetter:Se}));if(t.isError)return(0,Q.jsx)(`div`,{"data-route":`workflows`,className:`@container mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,Q.jsx)(me,{icon:(0,Q.jsx)(oe,{}),tone:`danger`,title:`Could not load workflows`,subtitle:t.error.message})});if(_===null)return(0,Q.jsx)(he,{});let Y=_.steps,X=_.name.trim(),ke=z.find(e=>e.name===X&&e.source===`file`),Ae=Ne(_.name,_.description,Y),Z=(e,t=Y.length)=>{if(Y.length>=8){g(`A workflow holds at most 8 steps.`,{tone:`danger`});return}H(Ee(Y,Te(e,Y),t))};return(0,Q.jsxs)(`div`,{"data-route":`workflows`,className:`@container mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:[(0,Q.jsxs)(`header`,{className:`mb-[22px] flex flex-wrap items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Workflows`}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Portable skill chains. Steps run from top to bottom.`})]}),(0,Q.jsxs)(T,{variant:`primary`,"data-slot":`wb-new`,className:`min-h-11`,onClick:()=>v($()),children:[(0,Q.jsx)(ee,{"aria-hidden":`true`,className:`size-4`}),`New workflow`]})]}),(0,Q.jsxs)(ge,{sensors:J,collisionDetection:ve,onDragStart:e=>{let t=e.active.data.current;P(t??null)},onDragOver:e=>{I(e.over?String(e.over.id):null)},onDragEnd:e=>{P(null),I(null);let{active:t,over:n}=e;if(n===null)return;let r=t.data.current;if(r?.type===`palette`){let e=n.id===at?Y.length:Y.findIndex(e=>e.id===n.id);Z(r.skill,e===-1?Y.length:e);return}if(n.id===t.id)return;let i=Y.findIndex(e=>e.id===t.id),a=Y.findIndex(e=>e.id===n.id);i!==-1&&a!==-1&&H(De(Y,i,a))},onDragCancel:()=>{P(null),I(null)},children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[22px] pb-[calc(32px+env(safe-area-inset-bottom))]`,children:[(0,Q.jsx)(Re,{workflows:z,draft:_,trimmedName:X,nameRef:L,onDraft:v,onLoadWorkflow:e=>v(ot(e))}),(0,Q.jsx)(ze,{savedFile:ke,autoOpen:O,onImportToggle:()=>{D(``),k(!1),C(e=>!e)},onExport:()=>{let e=new Blob([Ae],{type:`text/yaml`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${Pe(_.name)}.yaml`,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(t),1e3)},onAutoToggle:()=>{C(!1),k(e=>!e)},onDeleteRequest:()=>M(!0)}),O?(0,Q.jsx)(Be,{text:le,onTextChange:A,pending:W.isPending,onRun:()=>{let e=le.trim();e===``||W.isPending||W.mutate(e)},onCancel:()=>{k(!1),A(``)}}):null,(0,Q.jsx)(Ve,{open:se,onOpenChange:C,text:w,onTextChange:E,error:ce,pending:U.isPending,onRun:()=>{let e=w.trim();e!==``&&U.mutate(e)},onCancel:()=>{C(!1),E(``),D(``)}}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 items-start gap-[22px] @min-[700px]:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,Q.jsxs)(`section`,{"data-slot":`wb-main`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Steps · `,Y.length,` of `,8,(0,Q.jsx)(`span`,{"data-slot":`wb-count`,className:`sr-only`,children:Fe(Y)})]}),(0,Q.jsx)(lt,{steps:Y,skills:B,dragging:N!==null,overId:F,activeStepId:N?.type===`step`?N.step.id:null,onRemove:e=>H(Oe(Y,e)),onMove:(e,t)=>H(De(Y,e,t))}),(0,Q.jsxs)(T,{ref:R,variant:`outline`,className:`mt-4 min-h-11`,onClick:()=>{S(null),x(``),b(!0)},children:[(0,Q.jsx)(ee,{"aria-hidden":`true`,className:`size-4`}),`Add step`]}),(0,Q.jsxs)(`p`,{className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`hidden @min-[900px]:inline`,children:`Drag to reorder. The agent follows this sequence from top to bottom.`}),(0,Q.jsx)(`span`,{className:`@min-[900px]:hidden`,children:`Use Move up / Move down to reorder without dragging.`})]}),(0,Q.jsxs)(`footer`,{className:`mt-4 flex flex-wrap items-center justify-between gap-4 border-t border-border pt-4`,children:[(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Review the name and steps, then save to a workflow file.`}),(0,Q.jsxs)(T,{type:`button`,variant:`primary`,size:`sm`,className:`min-h-11 max-sm:w-full`,"data-slot":`wb-save`,disabled:G.isPending,onClick:()=>{if(X===``){L.current?.focus();return}if(Y.length===0){g(`Add at least one step first.`,{tone:`danger`});return}G.mutate(!1)},children:[(0,Q.jsx)(ne,{"aria-hidden":`true`,className:`size-3`}),`Save`]})]})]}),(0,Q.jsx)(He,{paletteSkills:V,query:y,onQueryChange:te,error:n.isError?n.error.message:null,inFlow:new Set(Y.map(e=>e.skill).filter(e=>!!e)),onAdd:e=>Z(e),yaml:Ae})]})]}),(0,Q.jsx)(Ce,{children:(0,Q.jsx)(dt,{dragging:N,steps:Y,skills:B})})]}),(0,Q.jsx)(We,{open:re,onOpenChange:b,query:ie,onQueryChange:x,matches:xe,skillsCount:B.length,error:n.isError?n.error.message:null,selectedSkill:ae,onSelectSkill:S,stepsCount:Y.length,onCloseAutoFocus:e=>{e.preventDefault(),R.current?.focus()},onCancel:()=>b(!1),onAdd:e=>{Z(e),b(!1)}}),(0,Q.jsx)(Ge,{trimmedName:X,savedFile:ke,overwriteOpen:ue,onOverwriteDismiss:()=>j(!1),deleteOpen:de,onDeleteDismiss:()=>M(!1),onOverwrite:()=>G.mutate(!0),onDelete:()=>K.mutate(X)})]})}function lt({steps:e,skills:t,dragging:n,overId:i,activeStepId:a,onRemove:o,onMove:s}){let{setNodeRef:c,isOver:l}=H({id:at}),u=n&&i===at;return(0,Q.jsx)(`div`,{ref:c,"data-slot":`wb-steps`,"data-dragging":n||void 0,className:r(`relative mt-4 rounded-lg transition-colors`,l?`border-accent-strong/60 bg-accent-strong/5`:`border-muted-foreground/25`),children:e.length===0?(0,Q.jsx)(`p`,{className:r(`rounded-md px-3 py-10 text-center text-[13px] transition-colors`,l?`text-link-foreground`:`text-muted-foreground`),children:`Drop a skill here — or Import a workflow.yaml`}):(0,Q.jsxs)(G,{items:e.map(e=>e.id),strategy:xe,children:[(0,Q.jsx)(`ol`,{className:`flex flex-col gap-4`,children:e.map((r,c)=>(0,Q.jsx)(ut,{step:r,index:c,skills:t,dragging:n,insertBefore:n&&i===r.id&&a!==r.id,onRemove:()=>o(c),onMoveUp:c>0?()=>s(c,c-1):void 0,onMoveDown:c<e.length-1?()=>s(c,c+1):void 0},r.id))}),(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:r(`absolute inset-x-0 mt-1 h-[3px] rounded-full transition-colors`,u?`bg-accent-strong`:`bg-transparent`)})]})})}function ut({step:e,index:t,insertBefore:n,onRemove:i,onMoveUp:a,onMoveDown:o}){let s=p(e.runner,e.agentProfile),{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:m}=W({id:e.id,data:{type:`step`,step:e}});return(0,Q.jsxs)(`li`,{ref:u,style:{transform:V.Transform.toString(d),transition:f},className:r(`relative`,m&&`opacity-40`),children:[n?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`wb-drop-line`,className:`pointer-events-none absolute -top-[7px] right-0 left-0 h-[3px] rounded-full bg-accent-strong`}):null,(0,Q.jsx)(tt,{step:e,index:t,skills:s.data??[],onRemove:i,onMoveUp:a,onMoveDown:o,gripProps:{...c,...l}})]})}function dt(e){let t=e.dragging?.type===`step`?e.dragging.step:void 0,n=p(t?.runner,t?.agentProfile,!!t);return(0,Q.jsx)(Ue,{...e,skills:t?n.data??[]:e.skills})}export{st as WorkflowsRoute};