import{qc as Z,rc as _,sc as $,vc as O}from"./cli-0.5.12-27ngaysm.mjs";import{Td as Y,Yd as x}from"./cli-0.5.12-brdpkyjd.mjs";import{EI as V,jI as U,oI as W,tI as S,uI as X}from"./cli-0.5.12-zc0qwdy2.mjs";import{fga as R,iga as K}from"./cli-0.5.12-p5ps8gf0.mjs";import{Gga as C,zga as Q}from"./cli-0.5.12-tfdwzg37.mjs";x();K();C();V();S();O();function b(G,J,L){let H=new Set(J.plugins.map((z)=>z.name)),A=`@${L}`,q=[];for(let z of Object.keys(G.plugins)){if(!z.endsWith(A))continue;let h=z.slice(0,-A.length);if(!H.has(h))q.push(z)}return q}async function F(){await Z();let G=X(),J=_(),L=await U(),H=[];for(let A of Object.keys(L))try{let q=await W(A);if(!q.forceRemoveDeletedPlugins)continue;let z=b(G,q,A);for(let h of z){if(h in J)continue;let T=G.plugins[h]??[];if(!T.some((B)=>B.scope==="user"||B.scope==="project"||B.scope==="local"))continue;for(let B of T){let{scope:E}=B;if(E!=="user"&&E!=="project"&&E!=="local")continue;try{await Y(h,E)}catch(v){R(`Failed to auto-uninstall delisted plugin ${h} from ${E}: ${Q(v)}`,{level:"error"})}}await $(h),H.push(h)}}catch(q){R(`Failed to check for delisted plugins in "${A}": ${Q(q)}`,{level:"warn"})}return H}
export{F as db};
