import{bundleOas as r,createEmptyRedoclyConfig as i}from"@redocly/openapi-core/lib/bundle-oas";import{convertSwagger2OpenAPI as c}from"./convertSwagger2OpenAPI.js";import{IS_BROWSER as a}from"./dom.js";async function l(){try{return(await i())?.resolvedConfig.openapi||{}}catch{return{}}}async function p(o){const t=await i(),e={config:t,base:a?window.location.origin:typeof globalThis.process<"u"?globalThis.process.cwd():""};a&&(t.resolve.http.customFetch=globalThis.fetch),typeof o=="object"&&o!==null?e.doc=s(o):e.ref=o;const{bundle:{parsed:n}}=await r(e);return n.swagger!==void 0?c(n):n}function s(o){return{source:{absoluteRef:""},parsed:o}}export{p as loadAndBundleDefinition,l as loadOpenapiConfig};
