import{getNodeAttribute as p}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as u}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{FileNotFoundError as y,resolveAssetPath as A}from"../../../utils/index.js";import{MdResolveError as d}from"./md-resolve-error.js";import{getLinkOriginalAttrName as v}from"./utils.js";async function P(e,i,f,{actions:{contentDir:c,outdir:m},context:g}){const l=e,h=p(e,i),a=v(i),s=l[a]??h;if(!Array.isArray(s))return;l[a]=s;const r=[],o=[];for(const t of s){if(typeof t!="string"){r.push(t);continue}try{r.push(await A(t,g.fs,{fromFileRelativePath:f,contentDir:c,outdir:m}))}catch(n){if(n instanceof y)r.push(t),o.push(n.filePath);else throw n}}if(u(e,i,r),o.length>0){const[t]=o;throw new d(o.length===1?`File ${t} does not exist`:`Files do not exist: ${o.join(", ")}`,{rawLink:t,link:t})}}export{P as resolveImageGallery};
