import{fs as e}from"./app-server-manager-signals-Yn0WSnoY.js";import{A as t,lt as n,u as r,v as i}from"./vscode-api-DjORcpSo.js";import{i as a,t as o}from"./use-is-plugins-enabled-CJvW81OO.js";import{_ as s,a as c,d as l}from"./use-plugins-C_eNkElf.js";var u=n(),d=[`plugins`,`detail`];function f(n){let d=(0,u.c)(31),{hostId:f,marketplacePath:h,pluginName:_,remoteMarketplaceName:v,enabled:y}=n,b=y===void 0?!0:y,x=f??`local`,S;d[0]===x?S=d[1]:(S={hostId:x},d[0]=x,d[1]=S);let C=o(S),w=t(),T;d[2]===_?T=d[3]:(T=_!=null&&l(_),d[2]=_,d[3]=T);let E=T,D;d[4]!==x||d[5]!==E?(D={enabled:E,hostId:x},d[4]=x,d[5]=E,d[6]=D):D=d[6];let O=a(D),k=(h!=null||v!=null)&&_!=null,A=C&&b&&k&&E&&O.isLoading,j=C&&b&&k&&(!E||O.available),M;d[7]!==x||d[8]!==h||d[9]!==_||d[10]!==v?(M=m({hostId:x,marketplacePath:h,pluginName:_,remoteMarketplaceName:v}),d[7]=x,d[8]=h,d[9]=_,d[10]=v,d[11]=M):M=d[11];let N;d[12]!==x||d[13]!==h||d[14]!==_||d[15]!==w||d[16]!==v?(N=async()=>{if(_==null)throw Error(`plugin detail query requires pluginName`);let{plugin:t}=await e(`read-plugin`,{hostId:x,...c({marketplacePath:h,remoteMarketplaceName:v}),pluginName:_}),n=s(t.summary.interface?.logo,x,w),r=s(t.summary.interface?.composerIcon,x,w),i=Promise.all(t.skills.map(async e=>{if(e.interface==null)return null;let[t,n]=await Promise.all([s(e.interface.iconSmall,x,w),s(e.interface.iconLarge,x,w)]);return{iconSmallDataUrl:t,iconLargeDataUrl:n}})),[a,o,l]=await Promise.all([r,n,i]);return g(t,{composerIconDataUrl:a,logoDataUrl:o,skillImageDataUrls:l})},d[12]=x,d[13]=h,d[14]=_,d[15]=w,d[16]=v,d[17]=N):N=d[17];let P;d[18]!==j||d[19]!==M||d[20]!==N?(P={queryKey:M,queryFn:N,enabled:j,staleTime:r.FIVE_MINUTES},d[18]=j,d[19]=M,d[20]=N,d[21]=P):P=d[21];let F=i(P);if(!j){let e;return d[22]===A?e=d[23]:(e={errorMessage:null,isLoading:A,plugin:null,refetch:p},d[22]=A,d[23]=e),e}let I=F.error?String(F.error.message):null,L=F.data??null,R;d[24]===F?R=d[25]:(R=async()=>{await F.refetch()},d[24]=F,d[25]=R);let z;return d[26]!==F.isLoading||d[27]!==R||d[28]!==I||d[29]!==L?(z={errorMessage:I,isLoading:F.isLoading,plugin:L,refetch:R},d[26]=F.isLoading,d[27]=R,d[28]=I,d[29]=L,d[30]=z):z=d[30],z}async function p(){}function m({hostId:e,marketplacePath:t,pluginName:n,remoteMarketplaceName:r}){return[...d,e,t??``,r??``,n??``]}function h(e){return d.every((t,n)=>e[n]===t)}function g(e,{logoDataUrl:t,composerIconDataUrl:n,skillImageDataUrls:r}){let i=e.summary.interface,a=e.skills.map((e,t)=>{let n=r[t]??null;return e.interface==null||n==null?e:{...e,interface:{...e.interface,...n.iconSmallDataUrl==null?{}:{iconSmall:n.iconSmallDataUrl},...n.iconLargeDataUrl==null?{}:{iconLarge:n.iconLargeDataUrl}}}}),o=i!=null&&(n!=null||t!=null);return{...e,summary:o?{...e.summary,interface:{...i,...n==null?{}:{composerIcon:n},...t==null?{}:{logo:t}}}:e.summary,skills:a}}export{h as n,f as r,m as t};
//# sourceMappingURL=plugin-detail-queries-QOeY335-.js.map