import{__require as e}from"./utils.mjs";import{__require as s}from"./constants.mjs";var i,t;function o(){if(t)return i;t=1;const o=e(),{CHAR_ASTERISK:r,CHAR_AT:a,CHAR_BACKWARD_SLASH:n,CHAR_COMMA:l,CHAR_DOT:f,CHAR_EXCLAMATION_MARK:c,CHAR_FORWARD_SLASH:A,CHAR_LEFT_CURLY_BRACE:b,CHAR_LEFT_PARENTHESES:u,CHAR_LEFT_SQUARE_BRACKET:R,CHAR_PLUS:_,CHAR_QUESTION_MARK:h,CHAR_RIGHT_CURLY_BRACE:p,CHAR_RIGHT_PARENTHESES:k,CHAR_RIGHT_SQUARE_BRACKET:C}=s(),m=e=>e===A||e===n,E=e=>{!0!==e.isPrefix&&(e.depth=e.isGlobstar?1/0:1)};return i=(e,s)=>{const i=s||{},t=e.length-1,H=!0===i.parts||!0===i.scanToEnd,d=[],G=[],T=[];let g,S,B=e,x=-1,L=0,v=0,U=!1,D=!1,I=!1,K=!1,P=!1,M=!1,O=!1,q=!1,F=!1,N=!1,Q=0,j={value:"",depth:0,isGlob:!1};const W=()=>x>=t,Y=()=>B.charCodeAt(x+1),X=()=>(g=S,B.charCodeAt(++x));for(;x<t;){let e;if(S=X(),S!==n){if(!0===M||S===b){for(Q++;!0!==W()&&(S=X());)if(S!==n)if(S!==b){if(!0!==M&&S===f&&(S=X())===f){if(U=j.isBrace=!0,I=j.isGlob=!0,N=!0,!0===H)continue;break}if(!0!==M&&S===l){if(U=j.isBrace=!0,I=j.isGlob=!0,N=!0,!0===H)continue;break}if(S===p&&(Q--,0===Q)){M=!1,U=j.isBrace=!0,N=!0;break}}else Q++;else O=j.backslashes=!0,X();if(!0===H)continue;break}if(S!==A){if(!0!==i.noext){if(!0===(S===_||S===a||S===r||S===h||S===c)&&Y()===u){if(I=j.isGlob=!0,K=j.isExtglob=!0,N=!0,S===c&&x===L&&(F=!0),!0===H){for(;!0!==W()&&(S=X());)if(S!==n){if(S===k){I=j.isGlob=!0,N=!0;break}}else O=j.backslashes=!0,S=X();continue}break}}if(S===r){if(g===r&&(P=j.isGlobstar=!0),I=j.isGlob=!0,N=!0,!0===H)continue;break}if(S===h){if(I=j.isGlob=!0,N=!0,!0===H)continue;break}if(S===R){for(;!0!==W()&&(e=X());)if(e!==n){if(e===C){D=j.isBracket=!0,I=j.isGlob=!0,N=!0;break}}else O=j.backslashes=!0,X();if(!0===H)continue;break}if(!0===i.nonegate||S!==c||x!==L){if(!0!==i.noparen&&S===u){if(I=j.isGlob=!0,!0===H){for(;!0!==W()&&(S=X());)if(S!==u){if(S===k){N=!0;break}}else O=j.backslashes=!0,S=X();continue}break}if(!0===I){if(N=!0,!0===H)continue;break}}else q=j.negated=!0,L++}else{if(d.push(x),G.push(j),j={value:"",depth:0,isGlob:!1},!0===N)continue;if(g===f&&x===L+1){L+=2;continue}v=x+1}}else O=j.backslashes=!0,S=X(),S===b&&(M=!0)}!0===i.noext&&(K=!1,I=!1);let w=B,y="",z="";L>0&&(y=B.slice(0,L),B=B.slice(L),v-=L),w&&!0===I&&v>0?(w=B.slice(0,v),z=B.slice(v)):!0===I?(w="",z=B):w=B,w&&""!==w&&"/"!==w&&w!==B&&m(w.charCodeAt(w.length-1))&&(w=w.slice(0,-1)),!0===i.unescape&&(z&&(z=o.removeBackslashes(z)),w&&!0===O&&(w=o.removeBackslashes(w)));const J={prefix:y,input:e,start:L,base:w,glob:z,isBrace:U,isBracket:D,isGlob:I,isExtglob:K,isGlobstar:P,negated:q,negatedExtglob:F};if(!0===i.tokens&&(J.maxDepth=0,m(S)||G.push(j),J.tokens=G),!0===i.parts||!0===i.tokens){let s;for(let t=0;t<d.length;t++){const o=s?s+1:L,r=d[t],a=e.slice(o,r);i.tokens&&(0===t&&0!==L?(G[t].isPrefix=!0,G[t].value=y):G[t].value=a,E(G[t]),J.maxDepth+=G[t].depth),0===t&&""===a||T.push(a),s=r}if(s&&s+1<e.length){const t=e.slice(s+1);T.push(t),i.tokens&&(G[G.length-1].value=t,E(G[G.length-1]),J.maxDepth+=G[G.length-1].depth)}J.slashes=d,J.parts=T}return J}}export{o as __require};import r from"node:url";import a from"node:path";import n from"node:module";const l=r.fileURLToPath(import.meta.url);a.dirname(l),n.createRequire(import.meta.url);