import f from"node:path";import{Config as b,bundle as g}from"@redocly/openapi-core";import{getNodeAttribute as R,setNodeAttributeValue as l}from"../../../../shared/markdoc.js";import{ExternalResolver as v}from"../../../fs/utils/external-ref-resolver.js";import{formatBundleFromMarkdocError as w}from"../errors.js";import{MdResolveError as h}from"./md-resolve-error.js";async function k(o,e,s,{context:m,actions:p}){const r=R(o,e),t=p.contentDir;if(typeof r!="object"||!r)return;const n=f.resolve(t,s),a={config:new b({styleguide:{},apis:{}}),base:f.dirname(n),doc:{source:{absoluteRef:n},parsed:JSON.parse(JSON.stringify({openapi:"3.1.0",components:{schemas:{__root:r}}}))},externalRefResolver:new v(m.fs)},{bundle:{parsed:d},problems:u}=await g(a);l(o,e+"Resolved",d);const i=u[0];if(!i)return{};const c=w(i,s,t);throw l(o,e+"ResolvedErrors",[c]),new h(c,{rawLink:""})}export{k as resolveJsonSchemaRef};
