"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../../../../../../_virtual/Explorer.js"),v=require("../../../../../../_virtual/___vite-browser-external.js"),E=require("./ExplorerBase.js"),C=require("./readFile.js"),F=require("./cacheWrapper.js"),g=require("./getDirectory.js");var _;function q(){if(_)return n.__exports;_=1,Object.defineProperty(n.__exports,"__esModule",{value:!0}),n.__exports.Explorer=void 0;var c=m(v),y=E.__require(),u=C.__require(),h=F.__require(),p=g.__require();function m(o){return o&&o.__esModule?o:{default:o}}function w(o){var r;if(typeof Symbol<"u"&&(Symbol.asyncIterator&&(r=o[Symbol.asyncIterator],r!=null)||Symbol.iterator&&(r=o[Symbol.iterator],r!=null)))return r.call(o);throw new TypeError("Object is not async iterable")}class x extends y.ExplorerBase{constructor(r){super(r)}async search(r=process.cwd()){const e=await(0,p.getDirectory)(r);return await this.searchFromDirectory(e)}async searchFromDirectory(r){const e=c.default.resolve(process.cwd(),r),t=async()=>{const a=await this.searchDirectory(e),s=this.nextDirectoryToSearch(e,a);return s?this.searchFromDirectory(s):await this.config.transform(a)};return this.searchCache?(0,h.cacheWrapper)(this.searchCache,e,t):t()}async searchDirectory(r){var e=!0,t=!1,a;try{for(var s=w(this.config.searchPlaces),i,d;i=await s.next(),e=i.done,d=await i.value,!e;e=!0){const l=d,f=await this.loadSearchPlace(r,l);if(this.shouldSearchStopWithResult(f)===!0)return f}}catch(l){t=!0,a=l}finally{try{!e&&s.return!=null&&await s.return()}finally{if(t)throw a}}return null}async loadSearchPlace(r,e){const t=c.default.join(r,e),a=await(0,u.readFile)(t);return await this.createCosmiconfigResult(t,a)}async loadFileContent(r,e){return e===null?null:e.trim()===""?void 0:await this.getLoaderEntryForFile(r)(r,e)}async createCosmiconfigResult(r,e){const t=await this.loadFileContent(r,e);return this.loadedContentToCosmiconfigResult(r,t)}async load(r){this.validateFilePath(r);const e=c.default.resolve(process.cwd(),r),t=async()=>{const a=await(0,u.readFile)(e,{throwNotFound:!0}),s=await this.createCosmiconfigResult(e,a);return await this.config.transform(s)};return this.loadCache?(0,h.cacheWrapper)(this.loadCache,e,t):t()}}return n.__exports.Explorer=x,n.__exports}exports.__require=q;
//# sourceMappingURL=Explorer.js.map
