import{__module as r}from"../../_virtual/gitignore.mjs";import t from"../../_virtual/_node_util.mjs";import e from"../../_virtual/_node_fs.mjs";import o from"../../_virtual/_node_path.mjs";import{__require as i}from"../fast-glob/out/index.mjs";import{__require as n}from"./node_modules/ignore/index.mjs";import{__require as s}from"../slash/index.mjs";var a;function c(){if(a)return r.exports;a=1;const{promisify:c}=t,d=e,m=o,l=i(),u=n(),f=s(),p=["**/node_modules/**","**/flow-typed/**","**/coverage/**","**/.git"],w=c(d.readFile),_=(r,t)=>{const e=f(m.relative(t.cwd,m.dirname(t.fileName)));return r.split(/\r?\n/).filter(Boolean).filter(r=>!r.startsWith("#")).map((r=>t=>t.startsWith("!")?"!"+m.posix.join(r,t.slice(1)):m.posix.join(r,t))(e))},g=r=>{const t=u();for(const e of r)t.add(_(e.content,{cwd:e.cwd,fileName:e.filePath}));return t},j=(r,t)=>e=>r.ignores(f(m.relative(t,((r,t)=>{if(r=f(r),m.isAbsolute(t)){if(f(t).startsWith(r))return t;throw new Error(`Path ${t} is not in cwd ${r}`)}return m.join(r,t)})(t,e.path||e)))),h=({ignore:r=[],cwd:t=f(process.cwd())}={})=>({ignore:r,cwd:t});return r.exports=async r=>{r=h(r);const t=await l("**/.gitignore",{ignore:p.concat(r.ignore),cwd:r.cwd}),e=await Promise.all(t.map(t=>(async(r,t)=>{const e=m.join(t,r);return{cwd:t,filePath:e,content:await w(e,"utf8")}})(t,r.cwd))),o=g(e);return j(o,r.cwd)},r.exports.sync=r=>{r=h(r);const t=l.sync("**/.gitignore",{ignore:p.concat(r.ignore),cwd:r.cwd}).map(t=>((r,t)=>{const e=m.join(t,r);return{cwd:t,filePath:e,content:d.readFileSync(e,"utf8")}})(t,r.cwd)),e=g(t);return j(e,r.cwd)},r.exports}export{c as __require};