import{s as e}from"./chunk-Bj-mKKzh.js";import{Kn as t}from"./src-BOCweS1p.js";import{n,t as r}from"./jsx-runtime-CiQ1k8xo.js";import{F as i,I as a,P as o,W as s,f as c,h as l,lt as u,p as d,s as f}from"./vscode-api-DjORcpSo.js";import{c as p,o as m}from"./lib-MoKmYgcO.js";import{t as h}from"./thread-context-inputs-C9hcxtXy.js";import{r as g}from"./tooltip-BBqUFIYI.js";import{t as _}from"./route-scope-CLteRG86.js";import{t as v}from"./open-workspace-file-CJcJ-CWR.js";import{r as y}from"./thread-context-DcUpp6ZL.js";import{t as b}from"./project-context-signal-Ml33v7A8.js";import{b as x}from"./process-manager-target-n7BvYgee.js";import{t as S}from"./use-stable-callback-CvFJzJNa.js";import{r as C}from"./use-register-command-yA_5KLgb.js";import{a as w}from"./command-keybindings-DSs_0e8Z.js";import{t as T}from"./search-C0nm-Ej1.js";import{n as E,t as D}from"./dist-CVLmMoVW.js";import{t as O}from"./slash-command-item-CizdJ7h9.js";import{n as k}from"./at-mention-list-CryjCnyI.js";var A=`command-menu-first-file-item`,j=`command-menu-first-chat-item`,M=s(l,`root`),N=u(),P=e(n(),1),F=r();function I(e){let t=(0,N.c)(31),{clearSearch:n,close:r,hostId:s,onSelectFile:c,workspaceRoot:u}=e,d=i(l),f=p(),h=o(w,`searchFiles`),_=D(R),v=a(C),y=a(M),b=y===`files`?_:``,x;t[0]===u?x=t[1]:(x=[u],t[0]=u,t[1]=x);let S;t[2]!==s||t[3]!==b||t[4]!==x?(S={hostId:s,query:b,roots:x},t[2]=s,t[3]=b,t[4]=x,t[5]=S):S=t[5];let{sections:j}=k(S),I=j[0],z,B;if(t[6]!==v||t[7]!==d?(z=()=>{v||d.set(M,`root`)},B=[v,d],t[6]=v,t[7]=d,t[8]=z,t[9]=B):(z=t[8],B=t[9]),(0,P.useEffect)(z,B),y!==`files`){let e;t[10]===f?e=t[11]:(e=f.formatMessage({id:`thread.fileCommandMenu.searchFiles`,defaultMessage:`Search files`,description:`Command menu item that opens workspace file search`}),t[10]=f,t[11]=e);let r=h??``,i;t[12]===r?i=t[13]:(i=(0,F.jsx)(g,{keysLabel:r}),t[12]=r,t[13]=i);let a;t[14]!==n||t[15]!==d?(a=()=>{n(),d.set(M,`files`)},t[14]=n,t[15]=d,t[16]=a):a=t[16];let o;return t[17]!==e||t[18]!==i||t[19]!==a?(o=(0,F.jsx)(O,{value:`search files workspace project cmd+p`,title:e,LeftIcon:T,rightAccessory:i,onSelect:a},`search-files`),t[17]=e,t[18]=i,t[19]=a,t[20]=o):o=t[20],o}if(I==null||I.items.length===0&&I.emptyState==null)return null;let V;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,F.jsx)(`span`,{className:`block px-2 pt-2 text-sm text-token-description-foreground`,children:(0,F.jsx)(m,{id:`thread.fileCommandMenu.filesGroup`,defaultMessage:`Files`,description:`Group label for workspace file search results`})}),t[21]=V):V=t[21];let H;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(H={gap:`var(--spacing)`},t[22]=H):H=t[22];let U;t[23]!==r||t[24]!==I.emptyState||t[25]!==I.items||t[26]!==f||t[27]!==c?(U=I.items.length>0?I.items.map((e,t)=>(0,F.jsx)(O,{description:e.detail??void 0,forceMount:!0,LeftIcon:e.icon,onSelect:()=>{c(e.key.replace(/^file:/,``)),r()},title:e.label,value:t===0?A:[e.label,e.detail].join(` `)},e.key)):I.emptyState==null?null:(0,F.jsx)(E.Item,{"data-command-menu-loading":!0,forceMount:!0,onSelect:L,value:A,children:(0,F.jsx)(`div`,{className:`flex w-full min-w-0 items-center gap-2`,children:(0,F.jsx)(`div`,{className:`min-w-0 flex-1 truncate`,children:f.formatMessage(I.emptyState)})})}),t[23]=r,t[24]=I.emptyState,t[25]=I.items,t[26]=f,t[27]=c,t[28]=U):U=t[28];let W;return t[29]===U?W=t[30]:(W=(0,F.jsx)(E.Group,{forceMount:!0,heading:V,className:`flex flex-col`,style:H,children:U},`group-files`),t[29]=U,t[30]=W),W}function L(){}function R(e){return e.search}function z(){let e=(0,N.c)(23),n=i(_),r=a(M),o=f(`open-file`),s=a(y),l=a(b),{data:u}=a(h),p=u?.roots?.[0]??null,m=s.kind===`local`?p:null,g=l.kind===`git`?l.git.root:l.kind===`plain`?m??l.cwd:null,w=g!=null,T;e[0]!==w||e[1]!==s||e[2]!==o||e[3]!==n||e[4]!==g?(T=e=>{!w||g==null||v({scope:n,path:e,cwd:t(g),hostConfig:s,hostId:s.id,openFile:o.mutate,openInSidePanel:!0})},e[0]=w,e[1]=s,e[2]=o,e[3]=n,e[4]=g,e[5]=T):T=e[5];let E=T,D;e[6]!==w||e[7]!==n?(D=()=>{w&&(c.dispatchHostMessage({type:`command-menu`,query:``}),n.set(M,`files`),n.set(C,!0))},e[6]=w,e[7]=n,e[8]=D):D=e[8],d(`file-search-command-menu`,S(D));let O;e[9]!==w||e[10]!==r||e[11]!==s.id||e[12]!==g?(O=[w,r,s.id,g],e[9]=w,e[10]=r,e[11]=s.id,e[12]=g,e[13]=O):O=e[13];let k=r===`files`,A;e[14]!==s.id||e[15]!==E||e[16]!==g?(A=(e,t)=>g==null?null:(0,F.jsx)(I,{clearSearch:t,close:e,hostId:s.id,onSelectFile:E,workspaceRoot:g}),e[14]=s.id,e[15]=E,e[16]=g,e[17]=A):A=e[17];let j;return e[18]!==w||e[19]!==O||e[20]!==k||e[21]!==A?(j={dependencies:O,enabled:w,exclusive:k,groupKey:`suggested`,id:`thread-file-search`,order:-1e3,render:A},e[18]=w,e[19]=O,e[20]=k,e[21]=A,e[22]=j):j=e[22],x(j),null}export{M as i,j as n,A as r,z as t};
//# sourceMappingURL=workspace-file-command-menu-bridge-CsMVxqxD.js.map