@drincs/pixi-vn-ink
Version:
Pixi'VN gives you the ability to write your own narrative using Ink
4 lines • 45.6 kB
JavaScript
import {a,b as b$1}from'./chunk-I6LBNKYY.mjs';export{a as INK_DEV_API_HASHTAG_COMMANDS,b as INK_DEV_API_TEXT_REPLACES}from'./chunk-I6LBNKYY.mjs';import {b,c,g,h,e,d}from'./chunk-CYMNGEOH.mjs';import {InkCompiler}from'@drincs/pixi-vn-ink/parser';import Y from'fs/promises';import k,{resolve,posix,sep,isAbsolute,basename,dirname,normalize,relative}from'path';import*as Xe from'fs';import {statSync,stat,realpathSync,realpath,readdirSync,readdir}from'fs';import {fileURLToPath}from'url';import {createRequire}from'module';var ut=b((gs,te)=>{var Qt="[^\\\\/]",Bn="(?=.)",Vt="[^/]",Et="(?:\\/|$)",Yt="(?:^|\\/)",bt=`\\.{1,2}${Et}`,Wn="(?!\\.)",Un=`(?!${Yt}${bt})`,Kn=`(?!\\.{0,1}${Et})`,qn=`(?!${bt})`,Xn="[^.\\/]",jn=`${Vt}*?`,Jn="/",Zt={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:Bn,QMARK:Vt,END_ANCHOR:Et,DOTS_SLASH:bt,NO_DOT:Wn,NO_DOTS:Un,NO_DOT_SLASH:Kn,NO_DOTS_SLASH:qn,QMARK_NO_DOT:Xn,STAR:jn,START_ANCHOR:Yt,SEP:Jn},zn={...Zt,SLASH_LITERAL:"[\\\\/]",QMARK:Qt,STAR:`${Qt}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},Qn={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};te.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:Qn,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(t){return {"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===true?zn:Zt}};});var at=b(q=>{var{REGEX_BACKSLASH:Vn,REGEX_REMOVE_BACKSLASH:Yn,REGEX_SPECIAL_CHARS:Zn,REGEX_SPECIAL_CHARS_GLOBAL:tr}=ut();q.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);q.hasRegexChars=t=>Zn.test(t);q.isRegexChar=t=>t.length===1&&q.hasRegexChars(t);q.escapeRegex=t=>t.replace(tr,"\\$1");q.toPosixSlashes=t=>t.replace(Vn,"/");q.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let t=navigator.platform.toLowerCase();return t==="win32"||t==="windows"}return typeof process<"u"&&process.platform?process.platform==="win32":false};q.removeBackslashes=t=>t.replace(Yn,n=>n==="\\"?"":n);q.escapeLast=(t,n,e)=>{let s=t.lastIndexOf(n,e);return s===-1?t:t[s-1]==="\\"?q.escapeLast(t,n,s-1):`${t.slice(0,s)}\\${t.slice(s)}`};q.removePrefix=(t,n={})=>{let e=t;return e.startsWith("./")&&(e=e.slice(2),n.prefix="./"),e};q.wrapOutput=(t,n={},e={})=>{let s=e.contains?"":"^",r=e.contains?"":"$",i=`${s}(?:${t})${r}`;return n.negated===true&&(i=`(?:^(?!${i}).*$)`),i};q.basename=(t,{windows:n}={})=>{let e=t.split(n?/[\\/]/:"/"),s=e[e.length-1];return s===""?e[e.length-2]:s};});var ae=b((ms,ue)=>{var ee=at(),{CHAR_ASTERISK:xt,CHAR_AT:er,CHAR_BACKWARD_SLASH:ct,CHAR_COMMA:nr,CHAR_DOT:Ct,CHAR_EXCLAMATION_MARK:vt,CHAR_FORWARD_SLASH:ie,CHAR_LEFT_CURLY_BRACE:$t,CHAR_LEFT_PARENTHESES:wt,CHAR_LEFT_SQUARE_BRACKET:rr,CHAR_PLUS:sr,CHAR_QUESTION_MARK:ne,CHAR_RIGHT_CURLY_BRACE:or,CHAR_RIGHT_PARENTHESES:re,CHAR_RIGHT_SQUARE_BRACKET:ir}=ut(),se=t=>t===ie||t===ct,oe=t=>{t.isPrefix!==true&&(t.depth=t.isGlobstar?1/0:1);},ur=(t,n)=>{let e=n||{},s=t.length-1,r=e.parts===true||e.scanToEnd===true,i=[],o=[],l=[],g=t,d=-1,h=0,y=0,A=false,R=false,m=false,E=false,$=false,H=false,_=false,B=false,W=false,I=false,w=0,O,S,C={value:"",depth:0,isGlob:false},c=()=>d>=s,K=()=>g.charCodeAt(d+1),F=()=>(O=S,g.charCodeAt(++d));for(;d<s;){S=F();let v;if(S===ct){_=C.backslashes=true,S=F(),S===$t&&(H=true);continue}if(H===true||S===$t){for(w++;c()!==true&&(S=F());){if(S===ct){_=C.backslashes=true,F();continue}if(S===$t){w++;continue}if(H!==true&&S===Ct&&(S=F())===Ct){if(A=C.isBrace=true,m=C.isGlob=true,I=true,r===true)continue;break}if(H!==true&&S===nr){if(A=C.isBrace=true,m=C.isGlob=true,I=true,r===true)continue;break}if(S===or&&(w--,w===0)){H=false,A=C.isBrace=true,I=true;break}}if(r===true)continue;break}if(S===ie){if(i.push(d),o.push(C),C={value:"",depth:0,isGlob:false},I===true)continue;if(O===Ct&&d===h+1){h+=2;continue}y=d+1;continue}if(e.noext!==true&&(S===sr||S===er||S===xt||S===ne||S===vt)===true&&K()===wt){if(m=C.isGlob=true,E=C.isExtglob=true,I=true,S===vt&&d===h&&(W=true),r===true){for(;c()!==true&&(S=F());){if(S===ct){_=C.backslashes=true,S=F();continue}if(S===re){m=C.isGlob=true,I=true;break}}continue}break}if(S===xt){if(O===xt&&($=C.isGlobstar=true),m=C.isGlob=true,I=true,r===true)continue;break}if(S===ne){if(m=C.isGlob=true,I=true,r===true)continue;break}if(S===rr){for(;c()!==true&&(v=F());){if(v===ct){_=C.backslashes=true,F();continue}if(v===ir){R=C.isBracket=true,m=C.isGlob=true,I=true;break}}if(r===true)continue;break}if(e.nonegate!==true&&S===vt&&d===h){B=C.negated=true,h++;continue}if(e.noparen!==true&&S===wt){if(m=C.isGlob=true,r===true){for(;c()!==true&&(S=F());){if(S===wt){_=C.backslashes=true,S=F();continue}if(S===re){I=true;break}}continue}break}if(m===true){if(I=true,r===true)continue;break}}e.noext===true&&(E=false,m=false);let N=g,a="",u="";h>0&&(a=g.slice(0,h),g=g.slice(h),y-=h),N&&m===true&&y>0?(N=g.slice(0,y),u=g.slice(y)):m===true?(N="",u=g):N=g,N&&N!==""&&N!=="/"&&N!==g&&se(N.charCodeAt(N.length-1))&&(N=N.slice(0,-1)),e.unescape===true&&(u&&(u=ee.removeBackslashes(u)),N&&_===true&&(N=ee.removeBackslashes(N)));let j={prefix:a,input:t,start:h,base:N,glob:u,isBrace:A,isBracket:R,isGlob:m,isExtglob:E,isGlobstar:$,negated:B,negatedExtglob:W};if(e.tokens===true&&(j.maxDepth=0,se(S)||o.push(C),j.tokens=o),e.parts===true||e.tokens===true){let v;for(let D=0;D<i.length;D++){let V=v?v+1:h,J=i[D],Z=t.slice(V,J);e.tokens&&(D===0&&h!==0?(o[D].isPrefix=true,o[D].value=a):o[D].value=Z,oe(o[D]),j.maxDepth+=o[D].depth),(D!==0||Z!=="")&&l.push(Z),v=J;}if(v&&v+1<t.length){let D=t.slice(v+1);l.push(D),e.tokens&&(o[o.length-1].value=D,oe(o[o.length-1]),j.maxDepth+=o[o.length-1].depth);}j.slashes=i,j.parts=l;}return j};ue.exports=ur;});var he=b((ys,pe)=>{var lt=ut(),X=at(),{MAX_LENGTH:At,POSIX_REGEX_SOURCE:ar,REGEX_NON_SPECIAL_CHARS:cr,REGEX_SPECIAL_CHARS_BACKREF:lr,REPLACEMENTS:ce}=lt,fr=(t,n)=>{if(typeof n.expandRange=="function")return n.expandRange(...t,n);t.sort();let e=`[${t.join("-")}]`;try{new RegExp(e);}catch{return t.map(r=>X.escapeRegex(r)).join("..")}return e},st=(t,n)=>`Missing ${t}: "${n}" - use "\\\\${n}" to match literal characters`,le=t=>{let n=[],e=0,s=0,r=0,i="",o=false;for(let l of t){if(o===true){i+=l,o=false;continue}if(l==="\\"){i+=l,o=true;continue}if(l==='"'){r=r===1?0:1,i+=l;continue}if(r===0){if(l==="[")e++;else if(l==="]"&&e>0)e--;else if(e===0){if(l==="(")s++;else if(l===")"&&s>0)s--;else if(l==="|"&&s===0){n.push(i),i="";continue}}}i+=l;}return n.push(i),n},pr=t=>{let n=false;for(let e of t){if(n===true){n=false;continue}if(e==="\\"){n=true;continue}if(/[?*+@!()[\]{}]/.test(e))return false}return true},fe=t=>{let n=t.trim(),e=true;for(;e===true;)e=false,/^@\([^\\()[\]{}|]+\)$/.test(n)&&(n=n.slice(2,-1),e=true);if(pr(n))return n.replace(/\\(.)/g,"$1")},hr=t=>{let n=t.map(fe).filter(Boolean);for(let e=0;e<n.length;e++)for(let s=e+1;s<n.length;s++){let r=n[e],i=n[s],o=r[0];if(!(!o||r!==o.repeat(r.length)||i!==o.repeat(i.length))&&(r===i||r.startsWith(i)||i.startsWith(r)))return true}return false},Ot=(t,n=true)=>{if(t[0]!=="+"&&t[0]!=="*"||t[1]!=="(")return;let e=0,s=0,r=0,i=false;for(let o=1;o<t.length;o++){let l=t[o];if(i===true){i=false;continue}if(l==="\\"){i=true;continue}if(l==='"'){r=r===1?0:1;continue}if(r!==1){if(l==="["){e++;continue}if(l==="]"&&e>0){e--;continue}if(!(e>0)){if(l==="("){s++;continue}if(l===")"&&(s--,s===0))return n===true&&o!==t.length-1?void 0:{type:t[0],body:t.slice(2,o),end:o}}}}},gr=t=>{let n=0,e=[];for(;n<t.length;){let r=Ot(t.slice(n),false);if(!r||r.type!=="*")return;let i=le(r.body).map(l=>l.trim());if(i.length!==1)return;let o=fe(i[0]);if(!o||o.length!==1)return;e.push(o),n+=r.end+1;}return e.length<1?void 0:`${e.length===1?X.escapeRegex(e[0]):`[${e.map(r=>X.escapeRegex(r)).join("")}]`}*`},dr=t=>{let n=0,e=t.trim(),s=Ot(e);for(;s;)n++,e=s.body.trim(),s=Ot(e);return n},mr=(t,n)=>{if(n.maxExtglobRecursion===false)return {risky:false};let e=typeof n.maxExtglobRecursion=="number"?n.maxExtglobRecursion:lt.DEFAULT_MAX_EXTGLOB_RECURSION,s=le(t).map(r=>r.trim());if(s.length>1&&(s.some(r=>r==="")||s.some(r=>/^[*?]+$/.test(r))||hr(s)))return {risky:true};for(let r of s){let i=gr(r);if(i)return {risky:true,safeOutput:i};if(dr(r)>e)return {risky:true}}return {risky:false}},It=(t,n)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=ce[t]||t;let e={...n},s=typeof e.maxLength=="number"?Math.min(At,e.maxLength):At,r=t.length;if(r>s)throw new SyntaxError(`Input length: ${r}, exceeds maximum allowed length: ${s}`);let i={type:"bos",value:"",output:e.prepend||""},o=[i],l=e.capture?"":"?:",g=lt.globChars(e.windows),d=lt.extglobChars(g),{DOT_LITERAL:h,PLUS_LITERAL:y,SLASH_LITERAL:A,ONE_CHAR:R,DOTS_SLASH:m,NO_DOT:E,NO_DOT_SLASH:$,NO_DOTS_SLASH:H,QMARK:_,QMARK_NO_DOT:B,STAR:W,START_ANCHOR:I}=g,w=p=>`(${l}(?:(?!${I}${p.dot?m:h}).)*?)`,O=e.dot?"":E,S=e.dot?_:B,C=e.bash===true?w(e):W;e.capture&&(C=`(${C})`),typeof e.noext=="boolean"&&(e.noextglob=e.noext);let c={input:t,index:-1,start:0,dot:e.dot===true,consumed:"",output:"",prefix:"",backtrack:false,negated:false,brackets:0,braces:0,parens:0,quotes:0,globstar:false,tokens:o};t=X.removePrefix(t,c),r=t.length;let K=[],F=[],N=[],a=i,u,j=()=>c.index===r-1,v=c.peek=(p=1)=>t[c.index+p],D=c.advance=()=>t[++c.index]||"",V=()=>t.slice(c.index+1),J=(p="",P=0)=>{c.consumed+=p,c.index+=P;},Z=p=>{c.output+=p.output!=null?p.output:p.value,J(p.value);},Me=()=>{let p=1;for(;v()==="!"&&(v(2)!=="("||v(3)==="?");)D(),c.start++,p++;return p%2===0?false:(c.negated=true,c.start++,true)},gt=p=>{c[p]++,N.push(p);},tt=p=>{c[p]--,N.pop();},b=p=>{if(a.type==="globstar"){let P=c.braces>0&&(p.type==="comma"||p.type==="brace"),f=p.extglob===true||K.length&&(p.type==="pipe"||p.type==="paren");p.type!=="slash"&&p.type!=="paren"&&!P&&!f&&(c.output=c.output.slice(0,-a.output.length),a.type="star",a.value="*",a.output=C,c.output+=a.output);}if(K.length&&p.type!=="paren"&&(K[K.length-1].inner+=p.value),(p.value||p.output)&&Z(p),a&&a.type==="text"&&p.type==="text"){a.output=(a.output||a.value)+p.value,a.value+=p.value;return}p.prev=a,o.push(p),a=p;},dt=(p,P)=>{let f={...d[P],conditions:1,inner:""};f.prev=a,f.parens=c.parens,f.output=c.output,f.startIndex=c.index,f.tokensIndex=o.length;let x=(e.capture?"(":"")+f.open;gt("parens"),b({type:p,value:P,output:c.output?"":R}),b({type:"paren",extglob:true,value:D(),output:x}),K.push(f);},Fe=p=>{let P=t.slice(p.startIndex,c.index+1),f=t.slice(p.startIndex+2,c.index),x=mr(f,e);if((p.type==="plus"||p.type==="star")&&x.risky){let L=x.safeOutput?(p.output?"":R)+(e.capture?`(${x.safeOutput})`:x.safeOutput):void 0,z=o[p.tokensIndex];z.type="text",z.value=P,z.output=L||X.escapeRegex(P);for(let Q=p.tokensIndex+1;Q<o.length;Q++)o[Q].value="",o[Q].output="",delete o[Q].suffix;c.output=p.output+z.output,c.backtrack=true,b({type:"paren",extglob:true,value:u,output:""}),tt("parens");return}let T=p.close+(e.capture?")":""),U;if(p.type==="negate"){let L=C;if(p.inner&&p.inner.length>1&&p.inner.includes("/")&&(L=w(e)),(L!==C||j()||/^\)+$/.test(V()))&&(T=p.close=`)$))${L}`),p.inner.includes("*")&&(U=V())&&/^\.[^\\/.]+$/.test(U)){let z=It(U,{...n,fastpaths:false}).output;T=p.close=`)${z})${L})`;}p.prev.type==="bos"&&(c.negatedExtglob=true);}b({type:"paren",extglob:true,value:u,output:T}),tt("parens");};if(e.fastpaths!==false&&!/(^[*!]|[/()[\]{}"])/.test(t)){let p=false,P=t.replace(lr,(f,x,T,U,L,z)=>U==="\\"?(p=true,f):U==="?"?x?x+U+(L?_.repeat(L.length):""):z===0?S+(L?_.repeat(L.length):""):_.repeat(T.length):U==="."?h.repeat(T.length):U==="*"?x?x+U+(L?C:""):C:x?f:`\\${f}`);return p===true&&(e.unescape===true?P=P.replace(/\\/g,""):P=P.replace(/\\+/g,f=>f.length%2===0?"\\\\":f?"\\":"")),P===t&&e.contains===true?(c.output=t,c):(c.output=X.wrapOutput(P,c,n),c)}for(;!j();){if(u=D(),u==="\0")continue;if(u==="\\"){let f=v();if(f==="/"&&e.bash!==true||f==="."||f===";")continue;if(!f){u+="\\",b({type:"text",value:u});continue}let x=/^\\+/.exec(V()),T=0;if(x&&x[0].length>2&&(T=x[0].length,c.index+=T,T%2!==0&&(u+="\\")),e.unescape===true?u=D():u+=D(),c.brackets===0){b({type:"text",value:u});continue}}if(c.brackets>0&&(u!=="]"||a.value==="["||a.value==="[^")){if(e.posix!==false&&u===":"){let f=a.value.slice(1);if(f.includes("[")&&(a.posix=true,f.includes(":"))){let x=a.value.lastIndexOf("["),T=a.value.slice(0,x),U=a.value.slice(x+2),L=ar[U];if(L){a.value=T+L,c.backtrack=true,D(),!i.output&&o.indexOf(a)===1&&(i.output=R);continue}}}(u==="["&&v()!==":"||u==="-"&&v()==="]")&&(u=`\\${u}`),u==="]"&&(a.value==="["||a.value==="[^")&&(u=`\\${u}`),e.posix===true&&u==="!"&&a.value==="["&&(u="^"),a.value+=u,Z({value:u});continue}if(c.quotes===1&&u!=='"'){u=X.escapeRegex(u),a.value+=u,Z({value:u});continue}if(u==='"'){c.quotes=c.quotes===1?0:1,e.keepQuotes===true&&b({type:"text",value:u});continue}if(u==="("){gt("parens"),b({type:"paren",value:u});continue}if(u===")"){if(c.parens===0&&e.strictBrackets===true)throw new SyntaxError(st("opening","("));let f=K[K.length-1];if(f&&c.parens===f.parens+1){Fe(K.pop());continue}b({type:"paren",value:u,output:c.parens?")":"\\)"}),tt("parens");continue}if(u==="["){if(e.nobracket===true||!V().includes("]")){if(e.nobracket!==true&&e.strictBrackets===true)throw new SyntaxError(st("closing","]"));u=`\\${u}`;}else gt("brackets");b({type:"bracket",value:u});continue}if(u==="]"){if(e.nobracket===true||a&&a.type==="bracket"&&a.value.length===1){b({type:"text",value:u,output:`\\${u}`});continue}if(c.brackets===0){if(e.strictBrackets===true)throw new SyntaxError(st("opening","["));b({type:"text",value:u,output:`\\${u}`});continue}tt("brackets");let f=a.value.slice(1);if(a.posix!==true&&f[0]==="^"&&!f.includes("/")&&(u=`/${u}`),a.value+=u,Z({value:u}),e.literalBrackets===false||X.hasRegexChars(f))continue;let x=X.escapeRegex(a.value);if(c.output=c.output.slice(0,-a.value.length),e.literalBrackets===true){c.output+=x,a.value=x;continue}a.value=`(${l}${x}|${a.value})`,c.output+=a.value;continue}if(u==="{"&&e.nobrace!==true){gt("braces");let f={type:"brace",value:u,output:"(",outputIndex:c.output.length,tokensIndex:c.tokens.length};F.push(f),b(f);continue}if(u==="}"){let f=F[F.length-1];if(e.nobrace===true||!f){b({type:"text",value:u,output:u});continue}let x=")";if(f.dots===true){let T=o.slice(),U=[];for(let L=T.length-1;L>=0&&(o.pop(),T[L].type!=="brace");L--)T[L].type!=="dots"&&U.unshift(T[L].value);x=fr(U,e),c.backtrack=true;}if(f.comma!==true&&f.dots!==true){let T=c.output.slice(0,f.outputIndex),U=c.tokens.slice(f.tokensIndex);f.value=f.output="\\{",u=x="\\}",c.output=T;for(let L of U)c.output+=L.output||L.value;}b({type:"brace",value:u,output:x}),tt("braces"),F.pop();continue}if(u==="|"){K.length>0&&K[K.length-1].conditions++,b({type:"text",value:u});continue}if(u===","){let f=u,x=F[F.length-1];x&&N[N.length-1]==="braces"&&(x.comma=true,f="|"),b({type:"comma",value:u,output:f});continue}if(u==="/"){if(a.type==="dot"&&c.index===c.start+1){c.start=c.index+1,c.consumed="",c.output="",o.pop(),a=i;continue}b({type:"slash",value:u,output:A});continue}if(u==="."){if(c.braces>0&&a.type==="dot"){a.value==="."&&(a.output=h);let f=F[F.length-1];a.type="dots",a.output+=u,a.value+=u,f.dots=true;continue}if(c.braces+c.parens===0&&a.type!=="bos"&&a.type!=="slash"){b({type:"text",value:u,output:h});continue}b({type:"dot",value:u,output:h});continue}if(u==="?"){if(!(a&&a.value==="(")&&e.noextglob!==true&&v()==="("&&v(2)!=="?"){dt("qmark",u);continue}if(a&&a.type==="paren"){let x=v(),T=u;(a.value==="("&&!/[!=<:]/.test(x)||x==="<"&&!/<([!=]|\w+>)/.test(V()))&&(T=`\\${u}`),b({type:"text",value:u,output:T});continue}if(e.dot!==true&&(a.type==="slash"||a.type==="bos")){b({type:"qmark",value:u,output:B});continue}b({type:"qmark",value:u,output:_});continue}if(u==="!"){if(e.noextglob!==true&&v()==="("&&(v(2)!=="?"||!/[!=<:]/.test(v(3)))){dt("negate",u);continue}if(e.nonegate!==true&&c.index===0){Me();continue}}if(u==="+"){if(e.noextglob!==true&&v()==="("&&v(2)!=="?"){dt("plus",u);continue}if(a&&a.value==="("||e.regex===false){b({type:"plus",value:u,output:y});continue}if(a&&(a.type==="bracket"||a.type==="paren"||a.type==="brace")||c.parens>0){b({type:"plus",value:u});continue}b({type:"plus",value:y});continue}if(u==="@"){if(e.noextglob!==true&&v()==="("&&v(2)!=="?"){b({type:"at",extglob:true,value:u,output:""});continue}b({type:"text",value:u});continue}if(u!=="*"){(u==="$"||u==="^")&&(u=`\\${u}`);let f=cr.exec(V());f&&(u+=f[0],c.index+=f[0].length),b({type:"text",value:u});continue}if(a&&(a.type==="globstar"||a.star===true)){a.type="star",a.star=true,a.value+=u,a.output=C,c.backtrack=true,c.globstar=true,J(u);continue}let p=V();if(e.noextglob!==true&&/^\([^?]/.test(p)){dt("star",u);continue}if(a.type==="star"){if(e.noglobstar===true){J(u);continue}let f=a.prev,x=f.prev,T=f.type==="slash"||f.type==="bos",U=x&&(x.type==="star"||x.type==="globstar");if(e.bash===true&&(!T||p[0]&&p[0]!=="/")){b({type:"star",value:u,output:""});continue}let L=c.braces>0&&(f.type==="comma"||f.type==="brace"),z=K.length&&(f.type==="pipe"||f.type==="paren");if(!T&&f.type!=="paren"&&!L&&!z){b({type:"star",value:u,output:""});continue}for(;p.slice(0,3)==="/**";){let Q=t[c.index+4];if(Q&&Q!=="/")break;p=p.slice(3),J("/**",3);}if(f.type==="bos"&&j()){a.type="globstar",a.value+=u,a.output=w(e),c.output=a.output,c.globstar=true,J(u);continue}if(f.type==="slash"&&f.prev.type!=="bos"&&!U&&j()){c.output=c.output.slice(0,-(f.output+a.output).length),f.output=`(?:${f.output}`,a.type="globstar",a.output=w(e)+(e.strictSlashes?")":"|$)"),a.value+=u,c.globstar=true,c.output+=f.output+a.output,J(u);continue}if(f.type==="slash"&&f.prev.type!=="bos"&&p[0]==="/"){let Q=p[1]!==void 0?"|$":"";c.output=c.output.slice(0,-(f.output+a.output).length),f.output=`(?:${f.output}`,a.type="globstar",a.output=`${w(e)}${A}|${A}${Q})`,a.value+=u,c.output+=f.output+a.output,c.globstar=true,J(u+D()),b({type:"slash",value:"/",output:""});continue}if(f.type==="bos"&&p[0]==="/"){a.type="globstar",a.value+=u,a.output=`(?:^|${A}|${w(e)}${A})`,c.output=a.output,c.globstar=true,J(u+D()),b({type:"slash",value:"/",output:""});continue}c.output=c.output.slice(0,-a.output.length),a.type="globstar",a.output=w(e),a.value+=u,c.output+=a.output,c.globstar=true,J(u);continue}let P={type:"star",value:u,output:C};if(e.bash===true){P.output=".*?",(a.type==="bos"||a.type==="slash")&&(P.output=O+P.output),b(P);continue}if(a&&(a.type==="bracket"||a.type==="paren")&&e.regex===true){P.output=u,b(P);continue}(c.index===c.start||a.type==="slash"||a.type==="dot")&&(a.type==="dot"?(c.output+=$,a.output+=$):e.dot===true?(c.output+=H,a.output+=H):(c.output+=O,a.output+=O),v()!=="*"&&(c.output+=R,a.output+=R)),b(P);}for(;c.brackets>0;){if(e.strictBrackets===true)throw new SyntaxError(st("closing","]"));c.output=X.escapeLast(c.output,"["),tt("brackets");}for(;c.parens>0;){if(e.strictBrackets===true)throw new SyntaxError(st("closing",")"));c.output=X.escapeLast(c.output,"("),tt("parens");}for(;c.braces>0;){if(e.strictBrackets===true)throw new SyntaxError(st("closing","}"));c.output=X.escapeLast(c.output,"{"),tt("braces");}if(e.strictSlashes!==true&&(a.type==="star"||a.type==="bracket")&&b({type:"maybe_slash",value:"",output:`${A}?`}),c.backtrack===true){c.output="";for(let p of c.tokens)c.output+=p.output!=null?p.output:p.value,p.suffix&&(c.output+=p.suffix);}return c};It.fastpaths=(t,n)=>{let e={...n},s=typeof e.maxLength=="number"?Math.min(At,e.maxLength):At,r=t.length;if(r>s)throw new SyntaxError(`Input length: ${r}, exceeds maximum allowed length: ${s}`);t=ce[t]||t;let{DOT_LITERAL:i,SLASH_LITERAL:o,ONE_CHAR:l,DOTS_SLASH:g,NO_DOT:d,NO_DOTS:h,NO_DOTS_SLASH:y,STAR:A,START_ANCHOR:R}=lt.globChars(e.windows),m=e.dot?h:d,E=e.dot?y:d,$=e.capture?"":"?:",H={negated:false,prefix:""},_=e.bash===true?".*?":A;e.capture&&(_=`(${_})`);let B=O=>O.noglobstar===true?_:`(${$}(?:(?!${R}${O.dot?g:i}).)*?)`,W=O=>{switch(O){case "*":return `${m}${l}${_}`;case ".*":return `${i}${l}${_}`;case "*.*":return `${m}${_}${i}${l}${_}`;case "*/*":return `${m}${_}${o}${l}${E}${_}`;case "**":return m+B(e);case "**/*":return `(?:${m}${B(e)}${o})?${E}${l}${_}`;case "**/*.*":return `(?:${m}${B(e)}${o})?${E}${_}${i}${l}${_}`;case "**/.*":return `(?:${m}${B(e)}${o})?${i}${l}${_}`;default:{let S=/^(.*?)\.(\w+)$/.exec(O);if(!S)return;let C=W(S[1]);return C?C+i+S[2]:void 0}}},I=X.removePrefix(t,H),w=W(I);return w&&e.strictSlashes!==true&&(w+=`${o}?`),w};pe.exports=It;});var me=b((As,de)=>{var yr=ae(),Lt=he(),ge=at(),Ar=ut(),Rr=t=>t&&typeof t=="object"&&!Array.isArray(t),M=(t,n,e=false)=>{if(Array.isArray(t)){let h=t.map(A=>M(A,n,e));return A=>{for(let R of h){let m=R(A);if(m)return m}return false}}let s=Rr(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!s)throw new TypeError("Expected pattern to be a non-empty string");let r=n||{},i=r.windows,o=s?M.compileRe(t,n):M.makeRe(t,n,false,true),l=o.state;delete o.state;let g=()=>false;if(r.ignore){let h={...n,ignore:null,onMatch:null,onResult:null};g=M(r.ignore,h,e);}let d=(h,y=false)=>{let{isMatch:A,match:R,output:m}=M.test(h,o,n,{glob:t,posix:i}),E={glob:t,state:l,regex:o,posix:i,input:h,output:m,match:R,isMatch:A};return typeof r.onResult=="function"&&r.onResult(E),A===false?(E.isMatch=false,y?E:false):g(h)?(typeof r.onIgnore=="function"&&r.onIgnore(E),E.isMatch=false,y?E:false):(typeof r.onMatch=="function"&&r.onMatch(E),y?E:true)};return e&&(d.state=l),d};M.test=(t,n,e,{glob:s,posix:r}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return {isMatch:false,output:""};let i=e||{},o=i.format||(r?ge.toPosixSlashes:null),l=t===s,g=l&&o?o(t):t;return l===false&&(g=o?o(t):t,l=g===s),(l===false||i.capture===true)&&(i.matchBase===true||i.basename===true?l=M.matchBase(t,n,e,r):l=n.exec(g)),{isMatch:!!l,match:l,output:g}};M.matchBase=(t,n,e)=>(n instanceof RegExp?n:M.makeRe(n,e)).test(ge.basename(t));M.isMatch=(t,n,e)=>M(n,e)(t);M.parse=(t,n)=>Array.isArray(t)?t.map(e=>M.parse(e,n)):Lt(t,{...n,fastpaths:false});M.scan=(t,n)=>yr(t,n);M.compileRe=(t,n,e=false,s=false)=>{if(e===true)return t.output;let r=n||{},i=r.contains?"":"^",o=r.contains?"":"$",l=`${i}(?:${t.output})${o}`;t&&t.negated===true&&(l=`^(?!${l}).*$`);let g=M.toRegex(l,n);return s===true&&(g.state=t),g};M.makeRe=(t,n={},e=false,s=false)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let r={negated:false,fastpaths:true};return n.fastpaths!==false&&(t[0]==="."||t[0]==="*")&&(r.output=Lt.fastpaths(t,n)),r.output||(r=Lt(t,n)),M.compileRe(r,n,e,s)};M.toRegex=(t,n)=>{try{let e=n||{};return new RegExp(t,e.flags||(e.nocase?"i":""))}catch(e){if(n&&n.debug===true)throw e;return /$^/}};M.constants=Ar;de.exports=M;});var _e=b((Rs,Re)=>{var ye=me(),_r=at();function Ae(t,n,e=false){return n&&(n.windows===null||n.windows===void 0)&&(n={...n,windows:_r.isWindows()}),ye(t,n,e)}Object.assign(Ae,ye);Re.exports=Ae;});var Pt=c(g(),1);var Ft=createRequire(import.meta.url);function je(t){let n=normalize(t);return n.length>1&&n[n.length-1]===sep&&(n=n.substring(0,n.length-1)),n}var Je=/[\\/]/g;function Wt(t,n){return t.replace(Je,n)}var ze=/^[a-z]:[\\/]$/i;function Qe(t){return t==="/"||ze.test(t)}function _t(t,n){let{resolvePaths:e,normalizePath:s,pathSeparator:r}=n,i=process.platform==="win32"&&t.includes("/")||t.startsWith(".");if(e&&(t=resolve(t)),(s||i)&&(t=je(t)),t===".")return "";let o=t[t.length-1]!==r;return Wt(o?t+r:t,r)}function Ut(t,n){return n+t}function Ve(t,n){return function(e,s){return s.startsWith(t)?s.slice(t.length)+e:Wt(relative(t,s),n.pathSeparator)+n.pathSeparator+e}}function Ye(t){return t}function Ze(t,n,e){return n+t+e}function tn(t,n){let{relativePaths:e,includeBasePath:s}=n;return e&&t?Ve(t,n):s?Ut:Ye}function en(t){return function(n,e){e.push(n.substring(t.length)||".");}}function nn(t){return function(n,e,s){let r=n.substring(t.length)||".";s.every(i=>i(r,true))&&e.push(r);}}var rn=(t,n)=>{n.push(t||".");},sn=(t,n,e)=>{let s=t||".";e.every(r=>r(s,true))&&n.push(s);},on=()=>{};function un(t,n){let{includeDirs:e,filters:s,relativePaths:r}=n;return e?r?s&&s.length?nn(t):en(t):s&&s.length?sn:rn:on}var an=(t,n,e,s)=>{s.every(r=>r(t,false))&&e.files++;},cn=(t,n,e,s)=>{s.every(r=>r(t,false))&&n.push(t);},ln=(t,n,e,s)=>{e.files++;},fn=(t,n)=>{n.push(t);},pn=()=>{};function hn(t){let{excludeFiles:n,filters:e,onlyCounts:s}=t;return n?pn:e&&e.length?s?an:cn:s?ln:fn}var gn=t=>t,dn=()=>[""].slice(0,0);function mn(t){return t.group?dn:gn}var yn=(t,n,e)=>{t.push({directory:n,files:e,dir:n});},An=()=>{};function Rn(t){return t.group?yn:An}var _n=function(t,n,e){let{queue:s,fs:r,options:{suppressErrors:i}}=n;s.enqueue(),r.realpath(t,(o,l)=>{if(o)return s.dequeue(i?null:o,n);r.stat(l,(g,d)=>{if(g)return s.dequeue(i?null:g,n);if(d.isDirectory()&&Kt(t,l,n))return s.dequeue(null,n);e(d,l),s.dequeue(null,n);});});},Sn=function(t,n,e){let{queue:s,fs:r,options:{suppressErrors:i}}=n;s.enqueue();try{let o=r.realpathSync(t),l=r.statSync(o);if(l.isDirectory()&&Kt(t,o,n))return;e(l,o);}catch(o){if(!i)throw o}};function En(t,n){return !t.resolveSymlinks||t.excludeSymlinks?null:n?Sn:_n}function Kt(t,n,e){if(e.options.useRealPaths)return bn(n,e);let s=dirname(t),r=1;for(;s!==e.root&&r<2;){let i=e.symlinks.get(s);!!i&&(i===n||i.startsWith(n)||n.startsWith(i))?r++:s=dirname(s);}return e.symlinks.set(t,n),r>1}function bn(t,n){return n.visited.includes(t+n.options.pathSeparator)}var xn=t=>t.counts,Cn=t=>t.groups,vn=t=>t.paths,$n=t=>t.paths.slice(0,t.options.maxFiles),wn=(t,n,e)=>(yt(n,e,t.counts,t.options.suppressErrors),null),On=(t,n,e)=>(yt(n,e,t.paths,t.options.suppressErrors),null),In=(t,n,e)=>(yt(n,e,t.paths.slice(0,t.options.maxFiles),t.options.suppressErrors),null),Ln=(t,n,e)=>(yt(n,e,t.groups,t.options.suppressErrors),null);function yt(t,n,e,s){n(t&&!s?t:null,e);}function kn(t,n){let{onlyCounts:e,group:s,maxFiles:r}=t;return e?n?xn:wn:s?n?Cn:Ln:r?n?$n:In:n?vn:On}var qt={withFileTypes:true},Tn=(t,n,e,s,r)=>{if(t.queue.enqueue(),s<0)return t.queue.dequeue(null,t);let{fs:i}=t;t.visited.push(n),t.counts.directories++,i.readdir(n||".",qt,(o,l=[])=>{r(l,e,s),t.queue.dequeue(t.options.suppressErrors?null:o,t);});},Hn=(t,n,e,s,r)=>{let{fs:i}=t;if(s<0)return;t.visited.push(n),t.counts.directories++;let o=[];try{o=i.readdirSync(n||".",qt);}catch(l){if(!t.options.suppressErrors)throw l}r(o,e,s);};function Pn(t){return t?Hn:Tn}var Dn=class{constructor(t){d(this,"count",0);this.onQueueEmpty=t;}enqueue(){return this.count++,this.count}dequeue(t,n){this.onQueueEmpty&&(--this.count<=0||t)&&(this.onQueueEmpty(t,n),t&&(n.controller.abort(),this.onQueueEmpty=void 0));}},Nn=class{constructor(){d(this,"_files",0);d(this,"_directories",0);}set files(t){this._files=t;}get files(){return this._files}set directories(t){this._directories=t;}get directories(){return this._directories}get dirs(){return this._directories}},Mn=class{constructor(){d(this,"aborted",false);}abort(){this.aborted=true;}},Xt=class{constructor(t,n,e){d(this,"root");d(this,"isSynchronous");d(this,"state");d(this,"joinPath");d(this,"pushDirectory");d(this,"pushFile");d(this,"getArray");d(this,"groupFiles");d(this,"resolveSymlink");d(this,"walkDirectory");d(this,"callbackInvoker");d(this,"walk",(t,n,e)=>{let{paths:s,options:{filters:r,resolveSymlinks:i,excludeSymlinks:o,exclude:l,maxFiles:g,signal:d,useRealPaths:h,pathSeparator:y},controller:A}=this.state;if(A.aborted||d&&d.aborted||g&&s.length>g)return;let R=this.getArray(this.state.paths);for(let m=0;m<t.length;++m){let E=t[m];if(E.isFile()||E.isSymbolicLink()&&!i&&!o){let $=this.joinPath(E.name,n);this.pushFile($,R,this.state.counts,r);}else if(E.isDirectory()){let $=Ze(E.name,n,this.state.options.pathSeparator);if(l&&l(E.name,$))continue;this.pushDirectory($,s,r),this.walkDirectory(this.state,$,$,e-1,this.walk);}else if(this.resolveSymlink&&E.isSymbolicLink()){let $=Ut(E.name,n);this.resolveSymlink($,this.state,(H,_)=>{if(H.isDirectory()){if(_=_t(_,this.state.options),l&&l(E.name,h?_:$+y))return;this.walkDirectory(this.state,_,h?_:$+y,e-1,this.walk);}else {_=h?_:$;let B=basename(_),W=_t(dirname(_),this.state.options);_=this.joinPath(B,W),this.pushFile(_,R,this.state.counts,r);}});}}this.groupFiles(this.state.groups,n,R);});this.isSynchronous=!e,this.callbackInvoker=kn(n,this.isSynchronous),this.root=_t(t,n),this.state={root:Qe(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new Nn,options:n,queue:new Dn((s,r)=>this.callbackInvoker(r,s,e)),symlinks:new Map,visited:[""].slice(0,0),controller:new Mn,fs:n.fs||Xe},this.joinPath=tn(this.root,n),this.pushDirectory=un(this.root,n),this.pushFile=hn(n),this.getArray=mn(n),this.groupFiles=Rn(n),this.resolveSymlink=En(n,this.isSynchronous),this.walkDirectory=Pn(this.isSynchronous);}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}};function Fn(t,n){return new Promise((e,s)=>{jt(t,n,(r,i)=>{if(r)return s(r);e(i);});})}function jt(t,n,e){new Xt(t,n,e).start();}function Gn(t,n){return new Xt(t,n).start()}var Gt=class{constructor(t,n){this.root=t,this.options=n;}withPromise(){return Fn(this.root,this.options)}withCallback(t){jt(this.root,this.options,t);}sync(){return Gn(this.root,this.options)}},Jt=null;try{Ft.resolve("picomatch"),Jt=Ft("picomatch");}catch{}var zt=class{constructor(t){d(this,"globCache",{});d(this,"options",{maxDepth:1/0,suppressErrors:true,pathSeparator:sep,filters:[]});d(this,"globFunction");this.options={...this.options,...t},this.globFunction=this.options.globFunction;}group(){return this.options.group=true,this}withPathSeparator(t){return this.options.pathSeparator=t,this}withBasePath(){return this.options.includeBasePath=true,this}withRelativePaths(){return this.options.relativePaths=true,this}withDirs(){return this.options.includeDirs=true,this}withMaxDepth(t){return this.options.maxDepth=t,this}withMaxFiles(t){return this.options.maxFiles=t,this}withFullPaths(){return this.options.resolvePaths=true,this.options.includeBasePath=true,this}withErrors(){return this.options.suppressErrors=false,this}withSymlinks({resolvePaths:t=true}={}){return this.options.resolveSymlinks=true,this.options.useRealPaths=t,this.withFullPaths()}withAbortSignal(t){return this.options.signal=t,this}normalize(){return this.options.normalizePath=true,this}filter(t){return this.options.filters.push(t),this}onlyDirs(){return this.options.excludeFiles=true,this.options.includeDirs=true,this}exclude(t){return this.options.exclude=t,this}onlyCounts(){return this.options.onlyCounts=true,this}crawl(t){return new Gt(t||".",this.options)}withGlobFunction(t){return this.globFunction=t,this}crawlWithOptions(t,n){return this.options={...this.options,...n},new Gt(t||".",this.options)}glob(...t){return this.globFunction?this.globWithOptions(t):this.globWithOptions(t,{dot:true})}globWithOptions(t,...n){let e=this.globFunction||Jt;if(!e)throw new Error("Please specify a glob function to use glob matching.");var s=this.globCache[t.join("\0")];return s||(s=e(t,...n),this.globCache[t.join("\0")]=s),this.options.filters.push(r=>s(r)),this}};var ot=c(_e(),1),Ir=Array.isArray,Ee=/\\/g,be=process.platform==="win32",Lr=/^(\/?\.\.)+$/;function kr(t,n={}){let e=t.length,s=Array(e),r=Array(e),i,o;for(i=0;i<e;i++){let l=xe(t[i]);s[i]=l;let g=l.length,d=Array(g);for(o=0;o<g;o++)d[o]=(0, ot.default)(l[o],n);r[i]=d;}return l=>{let g=l.split("/");if(g[0]===".."&&Lr.test(l))return true;for(i=0;i<e;i++){let d=s[i],h=r[i],y=g.length,A=Math.min(y,d.length);for(o=0;o<A;){let R=d[o];if(R.includes("/"))return true;if(!h[o](g[o]))break;if(!n.noglobstar&&R==="**")return true;o++;}if(o===y)return true}return false}}var Tr=/^[A-Z]:\/$/i,Hr=be?t=>Tr.test(t):t=>t==="/";function Se(t,n,e){if(t===n||n.startsWith(`${t}/`)){if(e){let r=t.length+ +!Hr(t);return (i,o)=>i.slice(r,o?-1:void 0)||"."}let s=n.slice(t.length+1);return s?(r,i)=>{if(r===".")return s;let o=`${s}/${r}`;return i?o.slice(0,-1):o}:(r,i)=>i&&r!=="."?r.slice(0,-1):r}return e?s=>posix.relative(t,s)||".":s=>posix.relative(t,`${n}/${s}`)||"."}function Pr(t,n){if(n.startsWith(`${t}/`)){let e=n.slice(t.length+1);return s=>`${e}/${s}`}return e=>{let s=posix.relative(t,`${n}/${e}`);return e[e.length-1]==="/"&&s!==""?`${s}/`:s||"."}}var Dr={parts:true};function xe(t){var n;let e=ot.default.scan(t,Dr);return !((n=e.parts)===null||n===void 0)&&n.length?e.parts:[t]}var Nr=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,Mr=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,Fr=t=>t.replace(Nr,"\\$&"),Gr=t=>t.replace(Mr,"\\$&"),Br=be?Gr:Fr;function Wr(t,n){let e=ot.default.scan(t);return e.isGlob||e.negated}function ft(...t){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...t);}function Ce(t){return typeof t=="string"?[t]:t??[]}var Ur=/^(\/?\.\.)+/,Kr=/\\(?=[()[\]{}!*+?@|])/g;function kt(t,n,e,s){var r;let i=n.cwd,o=t;t[t.length-1]==="/"&&(o=t.slice(0,-1)),o[o.length-1]!=="*"&&n.expandDirectories&&(o+="/**");let l=Br(i);o=isAbsolute(o.replace(Kr,""))?posix.relative(l,o):posix.normalize(o);let g=(r=Ur.exec(o))===null||r===void 0?void 0:r[0],d=xe(o);if(g){let y=(g.length+1)/3,A=0,R=l.split("/");for(;A<y&&d[A+y]===R[R.length+A-y];)o=o.slice(0,(y-A-1)*3)+o.slice((y-A)*3+d[A+y].length+1)||".",A++;let m=posix.join(i,g.slice(A*3));m[0]!=="."&&e.root.length>m.length&&(e.root=m,e.depthOffset=-y+A);}if(!s&&e.depthOffset>=0){var h;(h=e.commonPath)!==null&&h!==void 0||(e.commonPath=d);let y=[],A=Math.min(e.commonPath.length,d.length);for(let R=0;R<A;R++){let m=d[R];if(m==="**"&&!d[R+1]){y.pop();break}if(R===d.length-1||m!==e.commonPath[R]||Wr(m))break;y.push(m);}e.depthOffset=y.length,e.commonPath=y,e.root=y.length>0?posix.join(i,...y):i;}return o}function qr(t,n,e){let s=[],r=[];for(let i of t.ignore)i&&(i[0]!=="!"||i[1]==="(")&&r.push(kt(i,t,e,true));for(let i of n)i&&(i[0]!=="!"||i[1]==="("?s.push(kt(i,t,e,false)):(i[1]!=="!"||i[2]==="(")&&r.push(kt(i.slice(1),t,e,true)));return {match:s,ignore:r}}function Xr(t,n){let e=t.cwd,s={root:e,depthOffset:0},r=qr(t,n,s);t.debug&&ft("internal processing patterns:",r);let{absolute:i,caseSensitiveMatch:o,debug:l,dot:g,followSymbolicLinks:d,onlyDirectories:h}=t,y=s.root.replace(Ee,""),A={dot:g,nobrace:t.braceExpansion===false,nocase:!o,noextglob:t.extglob===false,noglobstar:t.globstar===false,posix:true},R=(0, ot.default)(r.match,A),m=(0, ot.default)(r.ignore,A),E=kr(r.match,A),$=Se(e,y,i),H=i?$:Se(e,y,true),_=(I,w)=>{let O=H(w,true);return O!=="."&&!E(O)||m(O)},B;t.deep!==void 0&&(B=Math.round(t.deep-s.depthOffset));let W=new zt({filters:[l?(I,w)=>{let O=$(I,w),S=R(O)&&!m(O);return S&&ft(`matched ${O}`),S}:(I,w)=>{let O=$(I,w);return R(O)&&!m(O)}],exclude:l?(I,w)=>{let O=_(I,w);return ft(`${O?"skipped":"crawling"} ${w}`),O}:_,fs:t.fs,pathSeparator:"/",relativePaths:!i,resolvePaths:i,includeBasePath:i,resolveSymlinks:d,excludeSymlinks:!d,excludeFiles:h,includeDirs:h||!t.onlyFiles,maxDepth:B,signal:t.signal}).crawl(y);return t.debug&&ft("internal properties:",{...s,root:y}),[W,e!==y&&!i&&Pr(e,y)]}function jr(t,n){if(n)for(let e=t.length-1;e>=0;e--)t[e]=n(t[e]);return t}var Jr={caseSensitiveMatch:true,cwd:process.cwd(),debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:true,followSymbolicLinks:true,onlyFiles:true};function zr(t){let n={...Jr,...t};return n.cwd=(n.cwd instanceof URL?fileURLToPath(n.cwd):resolve(n.cwd)).replace(Ee,"/"),n.ignore=Ce(n.ignore),n.fs&&(n.fs={readdir:n.fs.readdir||readdir,readdirSync:n.fs.readdirSync||readdirSync,realpath:n.fs.realpath||realpath,realpathSync:n.fs.realpathSync||realpathSync,stat:n.fs.stat||stat,statSync:n.fs.statSync||statSync}),n.debug&&ft("globbing with options:",n),n}function Qr(t,n={}){var e;if(t&&n?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");let s=Ir(t)||typeof t=="string",r=Ce((e=s?t:t.patterns)!==null&&e!==void 0?e:"**/*"),i=zr(s?n:t);return r.length>0?Xr(i,r):[]}async function Tt(t,n){let[e,s]=Qr(t,n);return e?jr(await e.withPromise(),s):[]}var He="virtual:pixi-vn-ink",$e=`\0${He}`,Vr="manifest.json",Pe=/\[(name|ext|extname|file|path|dir)\]/g,Yr=/(?:^|<>)\s*#\s*([^\r\n]+)/g,we=new Map;function et(t){return t.replaceAll("\\","/")}function Ht(t){let n=et(t.trim());if(!n)throw new Error("vitePluginInk option `inkGlob` must not be empty.");let e=n.replace(/^\.?\//,"");if(!e||e.startsWith("../"))throw new Error("vitePluginInk option `inkGlob` must be rooted in Vite `root` and cannot escape it.");return e}function Oe(t,n){let e=et(n).split("/"),s=[];for(let r of e)if(!(r==="."||r==="")){if(/[*!?[\]{}()]/.test(r))break;s.push(r);}return k.resolve(t,...s)}function Ie(t,n){if(!n)return;let e=n.trim();if(!e)throw new Error("vitePluginInk option `inkJsonOutputPattern` must not be empty.");return k.isAbsolute(e)?k.normalize(e):k.resolve(t,e)}function Zr(t,n,e){if(!e)return k.join(n,Vr);let s=e.trim();if(!s)throw new Error("vitePluginInk option `inkJsonManifestPath` must not be empty.");return k.isAbsolute(s)?k.normalize(s):k.resolve(t,s)}function Le(t){let n=t.search(Pe);if(n===-1)return k.dirname(t);let e=t.slice(0,n).replace(/[\\/]+$/g,"");if(!e)throw new Error("vitePluginInk option `inkJsonOutputPattern` must start with a static directory before placeholders.");return k.normalize(e)}function pt(t,n){let e=k.relative(t,n);return !e.startsWith("..")&&!k.isAbsolute(e)}function ts(t,n,e,s){let r=et(k.relative(e,s)),i=k.posix.parse(r),o=et(k.relative(n,s)),l=k.posix.dirname(o),g=k.posix.dirname(r),d={name:i.name,ext:i.ext.startsWith(".")?i.ext.slice(1):i.ext,extname:i.ext,file:r,path:g==="."?"":`${g}/`,dir:l==="."?"":`${l}/`},h=et(t).replace(Pe,(y,A)=>d[A]??"");return k.normalize(h)}function es(t,n,e){return pt(e,t)?`/${et(k.relative(e,t))}`:pt(n,t)?et(k.relative(n,t)):et(t)}function ns(t){let n=t.split(/\r?\n/),e$1=[];for(let s=0;s<n.length;s++){let r=n[s];for(let i of r.matchAll(Yr)){let o=(i[1]??"").trim();if(!o)continue;let l=e.convertTagTolist(o);l.length!==0&&e$1.push({line:s+1,command:o,tokens:l});}}return e$1}function De(t,n){let e=JSON.stringify([n,t]),s=we.get(e);if(s)return s;let r=new RegExp(t,n);return we.set(e,r),r}function ht(t,n){if(!n||typeof n!="object")return false;let e=n,s=e.anyOf;if(Array.isArray(s))return s.some(o=>ht(t,o));let r=e.oneOf;if(Array.isArray(r))return r.some(o=>ht(t,o));let i=e.allOf;if(Array.isArray(i))return i.every(o=>ht(t,o));if(typeof e.const=="string")return t===e.const;if(Array.isArray(e.enum))return e.enum.some(o=>typeof o=="string"&&o===t);if(e.type!=="string"||typeof e.minLength=="number"&&t.length<e.minLength||typeof e.maxLength=="number"&&t.length>e.maxLength)return false;if(typeof e.pattern=="string")try{if(!De(e.pattern,"").test(t))return !1}catch{return false}return true}function Rt(t,n){if(!n||typeof n!="object")return false;let e=n,s=e.anyOf;if(Array.isArray(s))return s.some(l=>Rt(t,l));let r=e.oneOf;if(Array.isArray(r))return r.some(l=>Rt(t,l));let i=e.allOf;if(Array.isArray(i))return i.every(l=>Rt(t,l));if(e.type!=="array"||typeof e.minItems=="number"&&t.length<e.minItems||typeof e.maxItems=="number"&&t.length>e.maxItems)return false;let o=Array.isArray(e.prefixItems)?e.prefixItems:[];if(t.length<o.length)return false;for(let l=0;l<o.length;l++)if(!ht(t[l],o[l]))return false;return t.length===o.length?true:e.items===false||typeof e.items>"u"?false:e.items===true?true:t.slice(o.length).every(l=>ht(l,e.items))}function rs(t,n){if(n.type==="regexp")try{let e=De(n.source,n.flags);return e.lastIndex=0,e.test(t.join(" "))}catch{return false}return n.type==="literal"?t.join(" ")===n.value:Rt(t,n.schema)}function ke(t,n,e,s){let r=ns(t).filter(({tokens:i})=>!e.some(({validation:o})=>rs(i,o)));r.forEach(({command:i,line:o})=>{s(`${n}:${o} Unknown hashtag command "# ${i}": no registered handler matched this command.`);}),r.length>0&&s(`${n}: Hashtag command metadata is available via ${a}.`);}function Te(t){return new Promise((n,e)=>{let s="";t.on("data",r=>{s+=r.toString();}),t.on("end",()=>n(s)),t.on("error",e);})}function Ne(t){let{inkGlob:n,inkJsonOutputPattern:e,inkJsonManifestPath:s}=t??{},r,i=[],o=[],l=async()=>{if(!r||!n)return;let g=Ie(r.root,e);if(!g)return;let d=Ht(n),h$1=Le(g),y=Oe(r.root,d);if(!pt(r.root,y))throw new Error("vitePluginInk option `inkGlob` must be rooted in Vite `root` and cannot escape it.");let A=await Tt(d,{absolute:true,cwd:r.root,onlyFiles:true}),R=[],m=new Set;await Y.mkdir(h$1,{recursive:true});for(let H of A){let _=await Y.readFile(H,"utf-8"),B;try{B=h(_);}catch(I){let w=I instanceof Error?I:new Error(String(I));r.logger.error(`[vite-plugin-ink] Failed to convert "${H}" to JSON.`,{error:w});continue}let W=ts(g,r.root,y,H);if(!pt(h$1,W)){r.logger.error(`[vite-plugin-ink] Output path "${W}" escapes managed directory "${h$1}".`);continue}if(m.add(W),!B){await Y.rm(W,{force:true});continue}await Y.mkdir(k.dirname(W),{recursive:true}),await Y.writeFile(W,`${JSON.stringify(B,null,2)}
`,"utf-8"),R.push(es(W,r.root,r.publicDir));}let E=Zr(r.root,h$1,s),$=await Tt("**/*.json",{absolute:true,cwd:h$1,onlyFiles:true});for(let H of $)k.resolve(H)!==k.resolve(E)&&!m.has(H)&&await Y.rm(H,{force:true});R.sort((H,_)=>H.localeCompare(_)),await Y.mkdir(k.dirname(E),{recursive:true}),await Y.writeFile(E,`${JSON.stringify(R,null,2)}
`,"utf-8");};return {name:"vite-plugin-ink",enforce:"pre",configResolved(g){r=g;let d=n?Ht(n):void 0;if(d){let h=Oe(g.root,d);if(!pt(g.root,h))throw new Error("vitePluginInk option `inkGlob` must be rooted in Vite `root` and cannot escape it.")}if(e&&!n)throw new Error("vitePluginInk option `inkJsonOutputPattern` requires `inkGlob` to be set.");if(e){let h=Ie(g.root,e);if(!h)return;let y=Le(h);if(k.resolve(y)===k.resolve(g.root))throw new Error("vitePluginInk option `inkJsonOutputPattern` must target a directory different from Vite `root`.")}},async buildStart(){await l();},configureServer(g){g.middlewares.use(async(d,h,y)=>{let A=d.url,R=d.method;if(A===a){if(R==="GET"){h.setHeader("Content-Type","application/json"),h.end(JSON.stringify(i));return}if(R==="POST"){try{let m=await Te(d);i=JSON.parse(m),h.statusCode=204,h.end();}catch(m){r?.logger.warn(`[vite-plugin-ink] Invalid JSON body for POST ${a}: ${String(m)}`),h.statusCode=400,h.end();}return}}if(A===b$1){if(R==="GET"){h.setHeader("Content-Type","application/json"),h.end(JSON.stringify(o));return}if(R==="POST"){try{let m=await Te(d);o=JSON.parse(m),h.statusCode=204,h.end();}catch(m){r?.logger.warn(`[vite-plugin-ink] Invalid JSON body for POST ${b$1}: ${String(m)}`),h.statusCode=400,h.end();}return}}y();}),l().catch(d=>{let h=d instanceof Error?d:new Error(String(d));r?.logger.error("[vite-plugin-ink] Failed to export Ink JSON files during server initialization or restart.",{error:h});});},resolveId(g){if(g===He)return $e},load(g){if(g===$e){if(!n)return "export default [];";let d=Ht(n);return [`const modules = import.meta.glob(${JSON.stringify(`/${d}`)}, { eager: true, import: 'default' });`,"export default Object.values(modules);"].join(`
`)}},async handleHotUpdate({file:g,server:d,read:h}){if(g.endsWith(".ink")){let y=await h(),{issues:A}=InkCompiler.compile(y),R;return A.forEach(({line:m,message:E,type:$})=>{$===Pt.ErrorType.Warning?d.config.logger.warn(`${g}:${m} ${E}`):(d.config.logger.error(`${g}:${m} ${E}`),R=E);}),ke(y,g,i,m=>d.config.logger.info(m)),await l(),R?d.ws.send({type:"error",err:{message:R,stack:g,plugin:"vite-plugin-ink"}}):(d.ws.send({type:"error",err:null}),d.ws.send({type:"custom",event:"ink-updated",data:y})),[]}},async transform(g,d){if(!d.endsWith(".ink"))return null;let h=await Y.readFile(d,"utf-8"),{issues:y}=InkCompiler.compile(h);return y.forEach(({line:A,message:R,type:m})=>{m===Pt.ErrorType.Warning?this.warn(`${d}:${A} ${R}`):this.error(`${d}:${A} ${R}`);}),ke(h,d,i,A=>this.info(A)),{code:`export default ${JSON.stringify(h)};`,map:null}}}}export{Ne as noHmrInkPlugin,Ne as vitePluginInk};