import{CONFIG_FILE_NAME as p}from"../../../constants/common.js";import{reporter as o}from"../../tools/notifiers/reporter.js";import{FileNotFoundError as a}from"../../utils/fs.js";import{resolveSrcSet as f}from"../../utils/resolve-src-set.js";import{resolveAssetPath as l}from"../../utils/resolve-asset-path.js";async function w(n={},y,s,i){const r={...n};if(n.entityTypes)for(const c of Object.keys(n.entityTypes)){if(!r.entityTypes?.[c])continue;const e=n.entityTypes[c];if(e.icon?.src)try{e.icon.src=await l(e.icon.src,i,{fromFileRelativePath:y,contentDir:i.cwd,outdir:s})}catch(t){t instanceof a?await o.panicOnBuildContentError('Cannot resolve "entityTypeConfig.icon.src": %rp',e.icon.src):await o.panicOnBuild(`Cannot resolve "entityTypeConfig.icon.src": %rp: ${t.message}`,e.icon.src)}if(e.icon?.srcSet)try{e.icon.srcSet=await f(e.icon.srcSet,i,{fromFileRelativePath:p,contentDir:i.cwd,outdir:s})}catch(t){t instanceof a?await o.panicOnBuildContentError(`Cannot resolve "entityTypeConfig.icon.srcSet" "${e.icon.srcSet}"`):await o.panicOnBuild(`Cannot resolve "entityTypeConfig.icon.srcSet" "${e.icon.srcSet}": ${t.message}`)}r.entityTypes[c]=e}return r}export{w as resolveEntitiesCatalogConfig};
