import{resolve as urlResolve}from"url";import{getValueFromMdParsedExtension,isJsonLike}from"../utils";const ExternalExamplesCache={};export function getExternalExampleValue(e,r){return r?(r in ExternalExamplesCache||(ExternalExamplesCache[r]=fetch(r).then((r=>r.text().then((t=>{if(!r.ok)return Promise.reject(new Error(t));if(!isJsonLike(e))return t;try{return JSON.parse(t)}catch(e){return t}}))))),ExternalExamplesCache[r]):Promise.resolve(void 0)}export function getExamples({parser:e,infoOrRef:r,mime:t,encoding:n}){let a;const{resolved:l}=e.deref(r),o=l.value,s=l.value,i=getValueFromMdParsedExtension(l,"summary"),u=getValueFromMdParsedExtension(l,"description");return l.externalValue&&(a=urlResolve(e.definitionUrl||"",l.externalValue)),{value:s,rawValue:o,externalValueUrl:a,summary:i,description:u,mime:t,encoding:n}}
//# sourceMappingURL=example.js.map