import{loadConfig as c}from"@redocly/openapi-core";import g from"node:path";import{access as l}from"node:fs/promises";import{ExternalResolver as m}from"../../../../server/fs/utils/external-ref-resolver.js";const R=async({store:a,context:t})=>{const e=[];for(const{relativePath:r,isVirtual:s}of t.fs.scan(/redocly\.yaml$/)){if(s)continue;const o=await u(r,a,t.fs);e.push(...o)}return{version:"1",name:"refsUsageStats",value:JSON.stringify(e)}};async function u(a,t,e){const r=g.join(t.contentDir,a),s=new m(e);try{await l(r)}catch{return[]}const{resolvedRefMap:o}=await c({configPath:r,externalRefResolver:s});return o?Array.from(o.keys()).map(n=>{const[f,i]=n.split("::");return{configPath:f,refPath:i}}):[]}export{R as getRefsUsage};
