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:o,context:t})=>{const e=[];for(const{relativePath:r,isVirtual:s}of await t.fs.scan(/redocly\.yaml$/)){if(s)continue;const a=await u(r,o,t.fs);e.push(...a)}return{version:"1",name:"refsUsageStats",value:JSON.stringify(e)}};async function u(o,t,e){const r=g.join(t.contentDir,o),s=new m(e);try{await l(r)}catch{return[]}const{resolvedRefMap:a}=await c({configPath:r,externalRefResolver:s});return a?Array.from(a.keys()).map(n=>{const[f,i]=n.split("::");return{configPath:f,refPath:i}}):[]}export{R as getRefsUsage};
