var __awaiter=this&&this.__awaiter||function(e,n,t,o){return new(t||(t=Promise))((function(r,c){function i(e){try{u(o.next(e))}catch(e){c(e)}}function a(e){try{u(o.throw(e))}catch(e){c(e)}}function u(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(i,a)}u((o=o.apply(e,n||[])).next())}))};import{bundle,Config}from"@redocly/openapi-core";import{convertObj}from"swagger2openapi";import{IS_BROWSER}from"@redocly/theme";import{createParsedDocument}from"./createParsedDocument";export function loadAndBundleDefinition(e){return __awaiter(this,void 0,void 0,(function*(){const n=new Config({}),t={config:n,base:IS_BROWSER?window.location.href:process.cwd()};IS_BROWSER&&(n.resolve.http.customFetch=global.fetch),"object"==typeof e&&null!==e?t.doc=createParsedDocument(e):t.ref=e;const{bundle:{parsed:o}}=yield bundle(t);return void 0!==o.swagger?convertSwagger2OpenAPI(o):o}))}export function convertSwagger2OpenAPI(e){return e.paths||(e.paths={}),new Promise(((n,t)=>convertObj(e,{patch:!0,warnOnly:!0,text:"{}",anchors:!0},((e,o)=>{if(e)return t(e);n(null==o?void 0:o.openapi)}))))}
//# sourceMappingURL=loadAndBundleSpec.js.map