import{Ae as i,Be as Eq,Ce as a,De as fq,Ee as g,Fe as Fq}from"./cli-0.5.12-ssw8vd5p.mjs";import"./cli-0.5.12-am3j4jcx.mjs";import"./cli-0.5.12-3v7zr435.mjs";import"./cli-0.5.12-had5m07e.mjs";import"./cli-0.5.12-xdrtyw81.mjs";import"./cli-0.5.12-ajgk4ksj.mjs";import"./cli-0.5.12-g4ffbdep.mjs";import{JP as l,ML as $,MP as A,NL as Wq,NP as b,OP as C,PP as n,Rw as R,Tw as _q,YP as t,_P as I,aQ as o,cQ as bq,sk as d,tk as Uq,uF as k,vF as Bq}from"./cli-0.5.12-zc0qwdy2.mjs";import"./cli-0.5.12-whfz3xsx.mjs";import"./cli-0.5.12-z100r543.mjs";import"./cli-0.5.12-bzab36pn.mjs";import"./cli-0.5.12-pp1549k7.mjs";import"./cli-0.5.12-9mq24qzr.mjs";import"./cli-0.5.12-7repzgzv.mjs";import"./cli-0.5.12-pdqnfqg3.mjs";import"./cli-0.5.12-c2yq69h9.mjs";import"./cli-0.5.12-kez9r81a.mjs";import"./cli-0.5.12-zbcr8cbk.mjs";import"./cli-0.5.12-2wf629mh.mjs";import"./cli-0.5.12-ghtxkxqx.mjs";import"./cli-0.5.12-xg7a0dy4.mjs";import"./cli-0.5.12-s0h788we.mjs";import"./cli-0.5.12-m22yxpb9.mjs";import"./cli-0.5.12-cw1qs4bg.mjs";import"./cli-0.5.12-yq8ds97a.mjs";import"./cli-0.5.12-qew4mzgp.mjs";import"./cli-0.5.12-gwg1e43k.mjs";import"./cli-0.5.12-36swspqa.mjs";import"./cli-0.5.12-4dn79vqp.mjs";import{BV as Vq,gV as m,hV as Oq,yV as u}from"./cli-0.5.12-f5pfjvdk.mjs";import{UV as c,YX as Hq,ZV as Zq,_V as vq,rX as T,tX as y}from"./cli-0.5.12-fqp5s15p.mjs";import"./cli-0.5.12-rc1p9wk6.mjs";import"./cli-0.5.12-x479axrj.mjs";import"./cli-0.5.12-ysy6e9rz.mjs";import"./cli-0.5.12-cqv7z22w.mjs";import"./cli-0.5.12-7cn41yy7.mjs";import"./cli-0.5.12-34cd39ve.mjs";import"./cli-0.5.12-m2gh4ewc.mjs";import{BZ as Y,CZ as F,DZ as P}from"./cli-0.5.12-c6whkxmz.mjs";import{EZ as zq}from"./cli-0.5.12-w3hy6c60.mjs";import"./cli-0.5.12-5d3qcvf5.mjs";import"./cli-0.5.12-f141d2qa.mjs";import"./cli-0.5.12-khvy67r3.mjs";import"./cli-0.5.12-pycnjaeg.mjs";import"./cli-0.5.12-8v5w8znc.mjs";import{A4 as Qq,z4 as p}from"./cli-0.5.12-ctqkj6ve.mjs";import"./cli-0.5.12-cbevkwg4.mjs";import"./cli-0.5.12-w00qj83e.mjs";import"./cli-0.5.12-nbcjwzzn.mjs";import"./cli-0.5.12-3t06hwwh.mjs";import"./cli-0.5.12-057c2cp2.mjs";import"./cli-0.5.12-ecgx5n54.mjs";import{A6 as Xq,Bca as L,Jca as Yq,z6 as j}from"./cli-0.5.12-g4wb8mj2.mjs";import"./cli-0.5.12-vp5smcs1.mjs";import"./cli-0.5.12-y2kq7fe8.mjs";import"./cli-0.5.12-7vxpqr5a.mjs";import"./cli-0.5.12-hvtcdcev.mjs";import"./cli-0.5.12-asbn3d19.mjs";import"./cli-0.5.12-k1crwtdc.mjs";import"./cli-0.5.12-2jxq8gnm.mjs";import"./cli-0.5.12-p5ps8gf0.mjs";import"./cli-0.5.12-hp0508v9.mjs";import"./cli-0.5.12-tfdwzg37.mjs";import"./cli-0.5.12-60w1a0bs.mjs";import{Aia as h,Gia as w,rma as Nq}from"./cli-0.5.12-c8f4daey.mjs";import"./cli-0.5.12-0qasc0ef.mjs";import"./cli-0.5.12-f8850v2j.mjs";import"./cli-0.5.12-495d826j.mjs";import"./cli-0.5.12-rt0k97yj.mjs";import"./cli-0.5.12-1vyz0tt9.mjs";import{Yna as D,aoa as Kq}from"./cli-0.5.12-xzeb7mtb.mjs";function S(G){switch(G.resultType){case"sessionNotFound":return`Session ${p.bold(G.arg)} was not found.`;case"multipleMatches":return`Found ${G.count} sessions matching ${p.bold(G.arg)}. Please use /resume to pick a specific session.`}}function M(G){let q=r.c(10),{message:O,args:U,onDone:K}=G,_,V;if(q[0]!==K)_=()=>{let J=setTimeout(K,0);return()=>clearTimeout(J)},V=[K],q[0]=K,q[1]=_,q[2]=V;else _=q[1],V=q[2];Z.useEffect(_,V);let Q;if(q[3]!==U)Q=F(y,{dimColor:!0,children:[j.pointer," /resume ",U]}),q[3]=U,q[4]=Q;else Q=q[4];let z;if(q[5]!==O)z=Y(d,{children:Y(y,{children:O})}),q[5]=O,q[6]=z;else z=q[6];let N;if(q[7]!==Q||q[8]!==z)N=F(T,{flexDirection:"column",children:[Q,z]}),q[7]=Q,q[8]=z,q[9]=N;else N=q[9];return N}function yq({onDone:G,onResume:q}){let[O,U]=Z.useState([]),[K,_]=Z.useState([]),[V,Q]=Z.useState(!0),[z,N]=Z.useState(!1),[J,X]=Z.useState(!1),{rows:v}=m(),s=u(),f=Z.useCallback(async(H,B)=>{Q(!0);try{let E=H?await t():await I(B),W=Aq(E,h());if(W.length===0){G("No conversations found to resume");return}U(W)}catch(E){G("Failed to load conversations")}finally{Q(!1)}},[G]);Z.useEffect(()=>{async function H(){let B=await $(w());_(B),f(!1,B)}H()},[f]);let e=Z.useCallback(()=>{let H=!J;X(H),f(H,K)},[J,f,K]);async function qq(H){let B=R(A(H));if(!B){G("Failed to resume conversation");return}let E=b(H)?await C(H):H,W=g(E,J,K);if(W.isCrossProject){if(W.isSameRepoWorktree){N(!0),q(B,E,"slash_command_picker");return}let x=await c(W.command);if(x)process.stdout.write(x);let Jq=["","This conversation is from a different directory.","","To resume, run:",`  ${W.command}`,"","(Command copied to clipboard)",""].join(`
`);G(Jq,{display:"user"});return}N(!0),q(B,E,"slash_command_picker")}function Gq(){G("Resume cancelled",{display:"system"})}if(V)return F(T,{children:[Y(k,{}),Y(y,{children:" Loading conversations…"})]});if(z)return F(T,{children:[Y(k,{}),Y(y,{children:" Resuming conversation…"})]});return Y(i,{logs:O,maxHeight:s?Math.floor(v/2):v-2,onCancel:Gq,onSelect:qq,onLogsChanged:()=>f(J,K),showAllProjects:J,onToggleAllProjects:e,onAgenticSearch:a})}function Aq(G,q){return G.filter((O)=>!O.isSidechain&&A(O)!==q)}var r,Z,mq=async(G,q,O)=>{let U=async(N,J,X)=>{try{await q.resume?.(N,J,X),G(void 0,{display:"skip"})}catch(v){L(v),G(`Failed to resume: ${v.message}`)}},K=O?.trim();if(!K)return Y(yq,{onDone:G,onResume:U},Date.now());let _=await $(w()),V=await I(_);if(V.length===0)return Y(M,{message:"No conversations found to resume.",args:K,onDone:()=>G("No conversations found to resume.")});let Q=R(K);if(Q){let N=V.filter((X)=>A(X)===Q).sort((X,v)=>v.modified.getTime()-X.modified.getTime());if(N.length>0){let X=N[0],v=b(X)?await C(X):X;return U(Q,v,"slash_command_session_id"),null}let J=await n(Q);if(J)return U(Q,J,"slash_command_session_id"),null}if(l()){let N=await o(K,{exact:!0});if(N.length===1){let J=N[0],X=A(J);if(X){let v=b(J)?await C(J):J;return U(X,v,"slash_command_title"),null}}if(N.length>1){let J=S({resultType:"multipleMatches",arg:K,count:N.length});return Y(M,{message:J,args:K,onDone:()=>G(J)})}}let z=S({resultType:"sessionNotFound",arg:K});return Y(M,{message:z,args:K,onDone:()=>G(z)})};var Tq=Kq(()=>{Qq();Xq();Nq();Eq();Uq();Bq();Vq();Oq();Zq();Hq();fq();Fq();Wq();Yq();bq();_q();P();r=D(vq(),1),Z=D(zq(),1)});Tq();export{Aq as filterResumableSessions,mq as call};
