import { __exports as n } from "../../../../../../_virtual/ExplorerSync.js";
import S from "../../../../../../_virtual/___vite-browser-external.js";
import { __require as m } from "./ExplorerBase.js";
import { __require as _ } from "./readFile.js";
import { __require as R } from "./cacheWrapper.js";
import { __require as x } from "./getDirectory.js";
var l;
function E() {
  if (l)
    return n;
  l = 1, Object.defineProperty(n, "__esModule", {
    value: !0
  }), n.ExplorerSync = void 0;
  var i = d(S), h = m(), a = _(), u = R(), y = x();
  function d(s) {
    return s && s.__esModule ? s : { default: s };
  }
  class f extends h.ExplorerBase {
    constructor(e) {
      super(e);
    }
    searchSync(e = process.cwd()) {
      const r = (0, y.getDirectorySync)(e);
      return this.searchFromDirectorySync(r);
    }
    searchFromDirectorySync(e) {
      const r = i.default.resolve(process.cwd(), e), t = () => {
        const o = this.searchDirectorySync(r), c = this.nextDirectoryToSearch(r, o);
        return c ? this.searchFromDirectorySync(c) : this.config.transform(o);
      };
      return this.searchCache ? (0, u.cacheWrapperSync)(this.searchCache, r, t) : t();
    }
    searchDirectorySync(e) {
      for (const r of this.config.searchPlaces) {
        const t = this.loadSearchPlaceSync(e, r);
        if (this.shouldSearchStopWithResult(t) === !0)
          return t;
      }
      return null;
    }
    loadSearchPlaceSync(e, r) {
      const t = i.default.join(e, r), o = (0, a.readFileSync)(t);
      return this.createCosmiconfigResultSync(t, o);
    }
    loadFileContentSync(e, r) {
      return r === null ? null : r.trim() === "" ? void 0 : this.getLoaderEntryForFile(e)(e, r);
    }
    createCosmiconfigResultSync(e, r) {
      const t = this.loadFileContentSync(e, r);
      return this.loadedContentToCosmiconfigResult(e, t);
    }
    loadSync(e) {
      this.validateFilePath(e);
      const r = i.default.resolve(process.cwd(), e), t = () => {
        const o = (0, a.readFileSync)(r, {
          throwNotFound: !0
        }), c = this.createCosmiconfigResultSync(r, o);
        return this.config.transform(c);
      };
      return this.loadCache ? (0, u.cacheWrapperSync)(this.loadCache, r, t) : t();
    }
  }
  return n.ExplorerSync = f, n;
}
export {
  E as __require
};
//# sourceMappingURL=ExplorerSync.js.map
