import f from"node:path";import{getNodeAttribute as p,setNodeAttributeValue as w}from"../../../../shared/markdoc.js";import{isOpenapiDoc as A}from"../../openapi-docs/is-openapi-doc.js";import{OPENAPI_SHARED_DATA_PREFIX as d}from"../../openapi-docs/constants.js";import{MdResolveError as m}from"./md-resolve-error.js";import{getLinkOriginalAttrName as g}from"./utils.js";async function I(r,t,e,{context:n}){const s=g(t);let o=r[s]||p(r,t);if(o||await A(e,n)&&(o=f.basename(e)),r[s]=o,!o)return;const i=f.posix.join(f.posix.dirname(e),o),a=d+i;if(w(r,t,a),!await n.fs.exists(i))throw new m(`Definition file ${i} does not exist`,{rawLink:i});if(await n.isPathIgnored(i))throw new m(`Definition file ${i} is ignored in config`,{rawLink:i});return{sharedDataId:a}}export{I as resolveOpenApiRef};
