import fs from "node:fs/promises";
import { inspectOpenApiDocument } from "./inspect.js";
import { parseOpenApiDocument, readOpenApiSourceText } from "./spec-source.js";
export async function inspectOpenApiSource(source, options = {}) {
    if (typeof source !== "string" && !(source instanceof URL)) {
        return inspectOpenApiDocument(source);
    }
    const sourceText = await readOpenApiSourceText(source, {
        cwd: options.cwd ?? process.cwd(),
        fetch: options.fetch ?? globalThis.fetch,
        fs: options.fs ?? fs
    });
    return inspectOpenApiDocument(parseOpenApiDocument(sourceText, source));
}
