import{__module as r}from"../../_virtual/index32.mjs";import t from"../../_virtual/_node_fs.mjs";import{__require as e}from"../array-union/index.mjs";import{__require as o}from"../merge2/index.mjs";import{__require as n}from"../fast-glob/out/index.mjs";import{__require as i}from"../dir-glob/index.mjs";import{__require as s}from"./gitignore.mjs";import{__require as a}from"./stream-utils.mjs";var p;function c(){if(p)return r.exports;p=1;const c=t,m=e(),u=o(),f=n(),g=i(),d=s(),{FilterStream:l,UniqueStream:y}=a(),x=()=>!1,w=r=>"!"===r[0],_=(r,t)=>{(r=>{if(!r.every(r=>"string"==typeof r))throw new TypeError("Patterns must be a string or an array of strings")})(r=m([].concat(r))),((r={})=>{if(!r.cwd)return;let t;try{t=c.statSync(r.cwd)}catch{return}if(!t.isDirectory())throw new Error("The `cwd` option must be a path to a directory")})(t);const e=[];t={ignore:[],expandDirectories:!0,...t};for(const[o,n]of r.entries()){if(w(n))continue;const i=r.slice(o).filter(r=>w(r)).map(r=>r.slice(1)),s={...t,ignore:t.ignore.concat(i)};e.push({pattern:n,options:s})}return e},h=(r,t)=>r.options.expandDirectories?((r,t)=>{let e={};return r.options.cwd&&(e.cwd=r.options.cwd),Array.isArray(r.options.expandDirectories)?e={...e,files:r.options.expandDirectories}:"object"==typeof r.options.expandDirectories&&(e={...e,...r.options.expandDirectories}),t(r.pattern,e)})(r,t):[r.pattern],j=r=>r&&r.gitignore?d.sync({cwd:r.cwd,ignore:r.ignore}):x,D=r=>t=>{const{options:e}=r;return e.ignore&&Array.isArray(e.ignore)&&e.expandDirectories&&(e.ignore=g.sync(e.ignore)),{pattern:t,options:e}};return r.exports=async(r,t)=>{const e=_(r,t),[o,n]=await Promise.all([(async()=>t&&t.gitignore?d({cwd:t.cwd,ignore:t.ignore}):x)(),(async()=>{const r=await Promise.all(e.map(async r=>{const t=await h(r,g);return Promise.all(t.map(D(r)))}));return m(...r)})()]),i=await Promise.all(n.map(r=>f(r.pattern,r.options)));return m(...i).filter(r=>{return!o((t=r,t.stats instanceof c.Stats?t.path:t));var t})},r.exports.sync=(r,t)=>{const e=_(r,t),o=[];for(const r of e){const t=h(r,g.sync).map(D(r));o.push(...t)}const n=j(t);let i=[];for(const r of o)i=m(i,f.sync(r.pattern,r.options));return i.filter(r=>!n(r))},r.exports.stream=(r,t)=>{const e=_(r,t),o=[];for(const r of e){const t=h(r,g.sync).map(D(r));o.push(...t)}const n=j(t),i=new l(r=>!n(r)),s=new y;return u(o.map(r=>f.stream(r.pattern,r.options))).pipe(i).pipe(s)},r.exports.generateGlobTasks=_,r.exports.hasMagic=(r,t)=>[].concat(r).some(r=>f.isDynamicPattern(r,t)),r.exports.gitignore=d,r.exports}export{c as __require};