import{__exports as e}from"../../../_virtual/index30.mjs";import{__require as r}from"./defaults.mjs";import{__require as a}from"./Explorer.mjs";import{__require as c}from"./ExplorerSync.mjs";import{__require as n}from"./util.mjs";var o;function t(){return o||(o=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.defaultLoadersSync=e.defaultLoaders=e.globalConfigSearchPlacesSync=e.globalConfigSearchPlaces=e.getDefaultSearchPlacesSync=e.getDefaultSearchPlaces=e.cosmiconfigSync=e.cosmiconfig=void 0;const o=r();Object.defineProperty(e,"defaultLoaders",{enumerable:!0,get:function(){return o.defaultLoaders}}),Object.defineProperty(e,"defaultLoadersSync",{enumerable:!0,get:function(){return o.defaultLoadersSync}}),Object.defineProperty(e,"getDefaultSearchPlaces",{enumerable:!0,get:function(){return o.getDefaultSearchPlaces}}),Object.defineProperty(e,"getDefaultSearchPlacesSync",{enumerable:!0,get:function(){return o.getDefaultSearchPlacesSync}}),Object.defineProperty(e,"globalConfigSearchPlaces",{enumerable:!0,get:function(){return o.globalConfigSearchPlaces}}),Object.defineProperty(e,"globalConfigSearchPlacesSync",{enumerable:!0,get:function(){return o.globalConfigSearchPlacesSync}});const t=a(),l=c(),s=n(),i=function(e){return e};function f(e,r,a){const c=a.searchPlaces?.map(r=>r.replace("{name}",e));return a.mergeSearchPlaces?[...c??[],...r]:c??r}function u(e,r,a){const c=function(){const e=new l.ExplorerSync({moduleName:"cosmiconfig",stopDir:process.cwd(),searchPlaces:o.metaSearchPlaces,ignoreEmptySearchPlaces:!1,applyPackagePropertyPathToConfiguration:!0,loaders:o.defaultLoaders,transform:i,cache:!0,metaConfigFilePath:null,mergeImportArrays:!0,mergeSearchPlaces:!0,searchStrategy:"none"}).search();if(!e)return null;if(e.config?.loaders)throw new Error("Can not specify loaders in meta config file");if(e.config?.searchStrategy)throw new Error("Can not specify searchStrategy in meta config file");const r={mergeSearchPlaces:!0,...e.config??{}};return{config:(0,s.removeUndefinedValuesFromObject)(r),filepath:e.filepath}}();if(!c)return{...r,...(0,s.removeUndefinedValuesFromObject)(a),loaders:{...r.loaders,...a.loaders}};const n=c.config,t=a.searchPlaces??r.searchPlaces;return{...r,...(0,s.removeUndefinedValuesFromObject)(a),metaConfigFilePath:c.filepath,...n,searchPlaces:f(e,t,n),loaders:{...r.loaders,...a.loaders}}}function h(e){if(null!=e.searchStrategy&&"global"!==e.searchStrategy&&e.stopDir)throw new Error('Can not supply `stopDir` option with `searchStrategy` other than "global"')}e.cosmiconfig=function(e,r={}){const a=function(e,r){return h(r),u(e,{moduleName:e,searchPlaces:(0,o.getDefaultSearchPlaces)(e),ignoreEmptySearchPlaces:!0,cache:!0,transform:i,loaders:o.defaultLoaders,metaConfigFilePath:null,mergeImportArrays:!0,mergeSearchPlaces:!0,searchStrategy:r.stopDir?"global":"none"},r)}(e,r),c=new t.Explorer(a);return{search:c.search.bind(c),load:c.load.bind(c),clearLoadCache:c.clearLoadCache.bind(c),clearSearchCache:c.clearSearchCache.bind(c),clearCaches:c.clearCaches.bind(c)}},e.cosmiconfigSync=function(e,r={}){const a=function(e,r){return h(r),u(e,{moduleName:e,searchPlaces:(0,o.getDefaultSearchPlacesSync)(e),ignoreEmptySearchPlaces:!0,cache:!0,transform:i,loaders:o.defaultLoadersSync,metaConfigFilePath:null,mergeImportArrays:!0,mergeSearchPlaces:!0,searchStrategy:r.stopDir?"global":"none"},r)}(e,r),c=new l.ExplorerSync(a);return{search:c.search.bind(c),load:c.load.bind(c),clearLoadCache:c.clearLoadCache.bind(c),clearSearchCache:c.clearSearchCache.bind(c),clearCaches:c.clearCaches.bind(c)}}}(e)),e}export{t as __require};