import{qe as i,re as Eq,se as a,te as fq,ue as g,ve as Fq}from"./cli-0.5.3-12x3qgxn.mjs";import"./cli-0.5.3-r5dy2kd8.mjs";import"./cli-0.5.3-yr9vwzg2.mjs";import"./cli-0.5.3-hj2dsm82.mjs";import"./cli-0.5.3-s5zy1vc9.mjs";import"./cli-0.5.3-4bzdv7a5.mjs";import"./cli-0.5.3-b4y7gc8k.mjs";import{JO as l,MO as A,NO as b,OO as C,Ow as R,PO as n,Qw as _q,YO as t,_O as I,aP as o,cP as bq,iF as k,jF as Bq,wL as $,xL as Wq,yj as d,zj as Uq}from"./cli-0.5.3-jbzr8k4s.mjs";import"./cli-0.5.3-me9jkw92.mjs";import"./cli-0.5.3-bqmztzjc.mjs";import"./cli-0.5.3-ytqxzjff.mjs";import"./cli-0.5.3-h6n812td.mjs";import"./cli-0.5.3-hg8c6qbh.mjs";import"./cli-0.5.3-39jr2yrx.mjs";import"./cli-0.5.3-42e2paz8.mjs";import"./cli-0.5.3-mn45xfck.mjs";import"./cli-0.5.3-m884a3pk.mjs";import"./cli-0.5.3-4f9xxrem.mjs";import"./cli-0.5.3-gr8nsa2k.mjs";import"./cli-0.5.3-yj9nbd9d.mjs";import"./cli-0.5.3-55kd38ff.mjs";import"./cli-0.5.3-e6bjcfwg.mjs";import"./cli-0.5.3-4dbxtwh3.mjs";import"./cli-0.5.3-m0kfmb79.mjs";import"./cli-0.5.3-8zq9vdtg.mjs";import"./cli-0.5.3-vmx7agj7.mjs";import"./cli-0.5.3-h8xs2818.mjs";import"./cli-0.5.3-wcx7cnw5.mjs";import"./cli-0.5.3-9zbakvbf.mjs";import{PU as u,SU as Vq,xU as m,yU as Oq}from"./cli-0.5.3-hx550gz2.mjs";import{IW as T,KW as y,jV as c,nX as Hq,oV as Zq,pV as vq}from"./cli-0.5.3-842pf3t4.mjs";import"./cli-0.5.3-wxead1ct.mjs";import"./cli-0.5.3-s1hz35ye.mjs";import"./cli-0.5.3-g0svn6bx.mjs";import"./cli-0.5.3-sfdh3pkx.mjs";import"./cli-0.5.3-d8tjnxcj.mjs";import"./cli-0.5.3-6zfw1732.mjs";import"./cli-0.5.3-ptjdgcsy.mjs";import"./cli-0.5.3-tp3jye12.mjs";import{NY as Y,OY as F,PY as P}from"./cli-0.5.3-vqmxwet2.mjs";import{QY as zq}from"./cli-0.5.3-rch86nhn.mjs";import"./cli-0.5.3-zg2apr51.mjs";import"./cli-0.5.3-ngnshpb7.mjs";import"./cli-0.5.3-e58xste9.mjs";import"./cli-0.5.3-6163zevg.mjs";import"./cli-0.5.3-jmkkd5ph.mjs";import"./cli-0.5.3-1vt6twff.mjs";import"./cli-0.5.3-7017ez65.mjs";import{V3 as p,W3 as Yq}from"./cli-0.5.3-ea94acj4.mjs";import"./cli-0.5.3-3k22nqvy.mjs";import"./cli-0.5.3-63q4g3zt.mjs";import"./cli-0.5.3-dyhbm5kp.mjs";import"./cli-0.5.3-vpcrbd8n.mjs";import"./cli-0.5.3-jdw3ajfv.mjs";import"./cli-0.5.3-qg4a557t.mjs";import{H6 as Qq,I6 as L,J6 as Xq,z6 as j}from"./cli-0.5.3-t65dek0m.mjs";import"./cli-0.5.3-kavpx97n.mjs";import"./cli-0.5.3-9bdwhdys.mjs";import"./cli-0.5.3-ttc72eq3.mjs";import"./cli-0.5.3-g75gdzrp.mjs";import"./cli-0.5.3-1rg2r7n7.mjs";import"./cli-0.5.3-6j2jk6dt.mjs";import"./cli-0.5.3-66650sba.mjs";import"./cli-0.5.3-9vh3vpap.mjs";import"./cli-0.5.3-n3cxyxpg.mjs";import"./cli-0.5.3-kbvzmaax.mjs";import"./cli-0.5.3-7wdgps7z.mjs";import"./cli-0.5.3-c8bcrqa4.mjs";import{gma as Nq,pia as h,via as w}from"./cli-0.5.3-qrvd6cmy.mjs";import"./cli-0.5.3-2dk1sk8w.mjs";import{Tma as D,Xma as Kq}from"./cli-0.5.3-0df3r78b.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:[L.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){j(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(()=>{Yq();Xq();Nq();Eq();Uq();Bq();Vq();Oq();Zq();Hq();fq();Fq();Wq();Qq();bq();_q();P();r=D(vq(),1),Z=D(zq(),1)});Tq();export{Aq as filterResumableSessions,mq as call};
