@whoz-oss/coday-server 0.248.0 → 0.248.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whoz-oss/coday-server",
3
- "version": "0.248.0",
3
+ "version": "0.248.2",
4
4
  "repository": "https://github.com/whoz-oss/coday",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
package/server.js CHANGED
@@ -902,7 +902,7 @@ I answer: `:"",c=a?`"${a}"`:i?'nothing."':"";return(a||i)&&n.addCommands(`@ ${o}
902
902
  `);o={role:"assistant",content:[{type:"text",text:a.optionalQuestion?`${a.optionalQuestion}
903
903
  ${a.invite}
904
904
  ${f}`:`${a.invite}
905
- ${f}`,...c&&{cache_control:{type:"ephemeral"}}}]}}else a instanceof Cn&&(o={role:"user",content:[{type:"text",text:a.answer,...c&&{cache_control:{type:"ephemeral"}}}]});return o}).filter(a=>!!a)}getOrUpdateCacheMarker(r,n,i){let s=n.length;if(s<GHt)return this.interactor.debug(`\u{1F4CB} Cache: Conversation too short (${s} messages), no marker`),null;r.data.anthropic||(r.data.anthropic={});let a=r.data.anthropic.cacheMarkerMessageId;if(a&&!i){let f=n.findIndex(d=>d.timestamp===a);if(f!==-1){let d=f/s,p=Math.round(d*100),h=Math.round(jIe*100),m=Math.round(bre*100);if(d>=jIe&&d<=bre)return this.interactor.debug(`\u2705 Cache: Keeping marker at message ${f+1}/${s} (${p}%)`),a;this.interactor.debug(`\u{1F504} Cache: Marker at ${p}% is out of range (${h}-${m}%), repositioning...`)}else this.interactor.debug("\u26A0\uFE0F Cache: Marker message not found, creating new marker")}else this.interactor.debug("\u{1F195} Cache: No existing marker, creating first marker");let o=Math.floor(s*bre),c=n[o]?.timestamp,u=Math.round(o/s*100);return c?(r.data.anthropic.cacheMarkerMessageId=c,this.interactor.debug(`\u{1F4CD} Cache: Placed marker at message ${o+1}/${s} (${u}%) - ID: ${c}`),c):(this.interactor.debug(`\u274C Cache: Failed to place marker at position ${o}`),null)}getClaudeTools(r){let n=r.getTools().map(i=>({name:i.function.name,description:i.function.description,input_schema:i.function.parameters}));return n.length>0&&(n[n.length-1].cache_control={type:"ephemeral"}),n}async streamApiCall(r,n,i,s,a,o,c=!1){let u=new Set(i.tools.getTools().map(m=>m.function.name)),f=await this.getMessages(s,a,n.name,i.name,u),d=this.toClaudeMessage(f.messages,s,c),p=r.messages.stream({model:n.name,messages:d,system:[{text:i.systemInstructions,type:"text",cache_control:{type:"ephemeral"}}],tools:this.getClaudeTools(i.tools),...(i.definition.temperature??n.temperature)!==void 0&&{temperature:i.definition.temperature??n.temperature},max_tokens:i.definition.maxOutputTokens??n.maxOutputTokens??8192});return p.on("text",m=>{if(!this.shouldProceed(s)){p.abort();return}o.next(new t0({chunk:m,threadId:s.id}))}),{data:await p.finalMessage(),response:void 0}}getHeader=(r,n)=>r?r instanceof Headers?r.get(n):r[n]||null:null;updateRateLimitsFromHeaders(r){if(!r){this.rateLimitInfo=null;return}let n=this.getHeader(r,"anthropic-ratelimit-input-tokens-remaining"),i=this.getHeader(r,"anthropic-ratelimit-output-tokens-remaining"),s=this.getHeader(r,"anthropic-ratelimit-requests-remaining"),a=this.getHeader(r,"anthropic-ratelimit-input-tokens-limit"),o=this.getHeader(r,"anthropic-ratelimit-output-tokens-limit"),c=this.getHeader(r,"anthropic-ratelimit-requests-limit");n&&!isNaN(parseInt(n))||i&&!isNaN(parseInt(i))||s&&!isNaN(parseInt(s))?this.rateLimitInfo={inputTokensRemaining:n?parseInt(n):999999,outputTokensRemaining:i?parseInt(i):999999,requestsRemaining:s?parseInt(s):999999,inputTokensLimit:a?parseInt(a):2e5,outputTokensLimit:o?parseInt(o):8e4,requestsLimit:c?parseInt(c):4e3}:this.rateLimitInfo=null}async applyThrottlingDelay(){if(!this.rateLimitInfo)return;let r=this.rateLimitInfo.inputTokensRemaining/Math.max(this.rateLimitInfo.inputTokensLimit,1),n=this.rateLimitInfo.outputTokensRemaining/Math.max(this.rateLimitInfo.outputTokensLimit,1),i=this.rateLimitInfo.requestsRemaining/Math.max(this.rateLimitInfo.requestsLimit,1);this.interactor.debug(`Rate limit ratios: ${JSON.stringify({inputTokensRatio:r,outputTokensRatio:n,requestsRatio:i,rateLimitInfo:this.rateLimitInfo})}`);let s=Math.min(r,n,i);if(s<yre){let a=(yre-s)/yre,o=Math.max(1,Math.round(a*WHt));this.interactor.displayText(`\u23F3 Rate limit approaching (${Math.round(s*100)}% remaining), waiting ${o} seconds...`);try{await this.delay(o*1e3,"throttling")}catch{throw new Error("Throttling delay interrupted by shutdown")}}}displayRateLimitStatus(r){let n=parseInt(r["anthropic-ratelimit-input-tokens-remaining"]??"0"),i=parseInt(r["anthropic-ratelimit-output-tokens-remaining"]??"0"),s=parseInt(r["anthropic-ratelimit-requests-remaining"]??"0"),a="unknown";n===0?a="input tokens":i===0?a="output tokens":s===0&&(a="requests"),this.interactor.debug(`\u{1F6A8} Rate limit exceeded: ${a} limit reached`)}handleError(r,n,i){super.handleError(r,n,i)}async complete(r,n){let i=this.isAnthropicReady();if(!i)throw new Error("Anthropic client not ready");let s=n?.model??this.models.find(c=>c.alias==="SMALL")?.name??"claude-3-5-haiku-latest",a=n?.maxTokens??100,o=a>VHt;try{let c;return o?c=await i.messages.stream({model:s,messages:[{role:"user",content:r}],max_tokens:a,...n?.temperature!==void 0&&{temperature:n.temperature},stop_sequences:n?.stopSequences}).finalMessage():c=await i.messages.create({model:s,messages:[{role:"user",content:r}],max_tokens:a,...n?.temperature!==void 0&&{temperature:n.temperature},stop_sequences:n?.stopSequences}),c.content.filter(u=>u.type==="text").map(u=>u.text.trim()).join(" ")}catch(c){let u=o?"streaming":"non-streaming";throw console.error(`Anthropic completion error (${u}):`,c),new Error(`Anthropic completion failed (${u}): ${c.message}`)}}};var qN=class extends mt{constructor(r){super({commandWord:"debug",description:"allows to set the debug logs (ex: `debug true` or `debug false`). False by default.",isInternal:!0});this.interactor=r}async handle(r,n){let i=this.getSubCommand(r);return i==="true"&&(this.interactor.debugLevelEnabled=!0,this.interactor.displayText("Set debug at true")),i==="false"&&(this.interactor.debugLevelEnabled=!1,this.interactor.displayText("Set debug at false")),n}};var xre=(t,e,r)=>{let n=t instanceof RegExp?NIe(t,r):t,i=e instanceof RegExp?NIe(e,r):e,s=n!==null&&i!=null&&ZHt(n,i,r);return s&&{start:s[0],end:s[1],pre:r.slice(0,s[0]),body:r.slice(s[0]+n.length,s[1]),post:r.slice(s[1]+i.length)}},NIe=(t,e)=>{let r=e.match(t);return r?r[0]:null},ZHt=(t,e,r)=>{let n,i,s,a,o,c=r.indexOf(t),u=r.indexOf(e,c+1),f=c;if(c>=0&&u>0){if(t===e)return[c,u];for(n=[],s=r.length;f>=0&&!o;){if(f===c)n.push(f),c=r.indexOf(t,f+1);else if(n.length===1){let d=n.pop();d!==void 0&&(o=[d,u])}else i=n.pop(),i!==void 0&&i<s&&(s=i,a=u),u=r.indexOf(e,f+1);f=c<u&&c>=0?c:u}n.length&&a!==void 0&&(o=[s,a])}return o};var FIe="\0SLASH"+Math.random()+"\0",MIe="\0OPEN"+Math.random()+"\0",wre="\0CLOSE"+Math.random()+"\0",LIe="\0COMMA"+Math.random()+"\0",qIe="\0PERIOD"+Math.random()+"\0",KHt=new RegExp(FIe,"g"),JHt=new RegExp(MIe,"g"),XHt=new RegExp(wre,"g"),YHt=new RegExp(LIe,"g"),QHt=new RegExp(qIe,"g"),eWt=/\\\\/g,tWt=/\\{/g,rWt=/\\}/g,nWt=/\\,/g,iWt=/\\\./g,sWt=1e5;function _re(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function aWt(t){return t.replace(eWt,FIe).replace(tWt,MIe).replace(rWt,wre).replace(nWt,LIe).replace(iWt,qIe)}function oWt(t){return t.replace(KHt,"\\").replace(JHt,"{").replace(XHt,"}").replace(YHt,",").replace(QHt,".")}function BIe(t){if(!t)return[""];let e=[],r=xre("{","}",t);if(!r)return t.split(",");let{pre:n,body:i,post:s}=r,a=n.split(",");a[a.length-1]+="{"+i+"}";let o=BIe(s);return s.length&&(a[a.length-1]+=o.shift(),a.push.apply(a,o)),e.push.apply(e,a),e}function UIe(t,e={}){if(!t)return[];let{max:r=sWt}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),vS(aWt(t),r,!0).map(oWt)}function cWt(t){return"{"+t+"}"}function uWt(t){return/^-?0\d/.test(t)}function lWt(t,e){return t<=e}function fWt(t,e){return t>=e}function vS(t,e,r){let n=[],i=xre("{","}",t);if(!i)return[t];let s=i.pre,a=i.post.length?vS(i.post,e,!1):[""];if(/\$$/.test(i.pre))for(let o=0;o<a.length&&o<e;o++){let c=s+"{"+i.body+"}"+a[o];n.push(c)}else{let o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),u=o||c,f=i.body.indexOf(",")>=0;if(!u&&!f)return i.post.match(/,(?!,).*\}/)?(t=i.pre+"{"+i.body+wre+i.post,vS(t,e,!0)):[t];let d;if(u)d=i.body.split(/\.\./);else if(d=BIe(i.body),d.length===1&&d[0]!==void 0&&(d=vS(d[0],e,!1).map(cWt),d.length===1))return a.map(h=>i.pre+d[0]+h);let p;if(u&&d[0]!==void 0&&d[1]!==void 0){let h=_re(d[0]),m=_re(d[1]),g=Math.max(d[0].length,d[1].length),v=d.length===3&&d[2]!==void 0?Math.max(Math.abs(_re(d[2])),1):1,y=lWt;m<h&&(v*=-1,y=fWt);let x=d.some(uWt);p=[];for(let k=h;y(k,m);k+=v){let A;if(c)A=String.fromCharCode(k),A==="\\"&&(A="");else if(A=String(k),x){let P=g-A.length;if(P>0){let R=new Array(P+1).join("0");k<0?A="-"+R+A.slice(1):A=R+A}}p.push(A)}}else{p=[];for(let h=0;h<d.length;h++)p.push.apply(p,vS(d[h],e,!1))}for(let h=0;h<p.length;h++)for(let m=0;m<a.length&&n.length<e;m++){let g=s+p[h]+a[m];(!r||u||g)&&n.push(g)}}return n}var yS=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var dWt={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},bS=t=>t.replace(/[[\]\\-]/g,"\\$&"),pWt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),zIe=t=>t.join(""),HIe=(t,e)=>{let r=e;if(t.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,a=!1,o=!1,c=!1,u=!1,f=r,d="";e:for(;s<t.length;){let g=t.charAt(s);if((g==="!"||g==="^")&&s===r+1){u=!0,s++;continue}if(g==="]"&&a&&!c){f=s+1;break}if(a=!0,g==="\\"&&!c){c=!0,s++;continue}if(g==="["&&!c){for(let[v,[y,b,x]]of Object.entries(dWt))if(t.startsWith(v,s)){if(d)return["$.",!1,t.length-r,!0];s+=v.length,x?i.push(y):n.push(y),o=o||b;continue e}}if(c=!1,d){g>d?n.push(bS(d)+"-"+bS(g)):g===d&&n.push(bS(g)),d="",s++;continue}if(t.startsWith("-]",s+1)){n.push(bS(g+"-")),s+=2;continue}if(t.startsWith("-",s+1)){d=g,s+=2;continue}n.push(bS(g)),s++}if(f<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,t.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let g=n[0].length===2?n[0].slice(-1):n[0];return[pWt(g),!1,f-r,!1]}let p="["+(u?"^":"")+zIe(n)+"]",h="["+(u?"":"^")+zIe(i)+"]";return[n.length&&i.length?"("+p+"|"+h+")":n.length?p:h,o,f-r,!0]};var cf=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!0}={})=>r?e?t.replace(/\[([^/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):e?t.replace(/\[([^/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var bc,hWt=new Set(["!","?","+","*","@"]),Sre=t=>hWt.has(t),WIe=t=>Sre(t.type),mWt=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),gWt=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),vWt=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),VIe=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),yWt="(?!(?:^|/)\\.\\.?(?:$|/))",BN="(?!\\.)",bWt=new Set(["[","."]),xWt=new Set(["..","."]),_Wt=new Set("().*{}+?[]^$\\!"),wWt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ere="[^/]",GIe=Ere+"*?",ZIe=Ere+"+?",SWt=0,j1=class{type;#e;#t;#n=!1;#r=[];#a;#h;#l;#c=!1;#i;#f;#d=!1;id=++SWt;get depth(){return(this.#a?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#a?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,r,n={}){this.type=e,e&&(this.#t=!0),this.#a=r,this.#e=this.#a?this.#a.#e:this,this.#i=this.#e===this?n:this.#e.#i,this.#l=this.#e===this?[]:this.#e.#l,e==="!"&&!this.#e.#c&&this.#l.push(this),this.#h=this.#a?this.#a.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#f!==void 0?this.#f:this.type?this.#f=this.type+"("+this.#r.map(e=>String(e)).join("|")+")":this.#f=this.#r.map(e=>String(e)).join("")}#u(){if(this!==this.#e)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let e;for(;e=this.#l.pop();){if(e.type!=="!")continue;let r=e,n=r.#a;for(;n;){for(let i=r.#h+1;!n.type&&i<n.#r.length;i++)for(let s of e.#r){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#r[i])}r=n,n=r.#a}}return this}push(...e){for(let r of e)if(r!==""){if(typeof r!="string"&&!(r instanceof bc&&r.#a===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let e=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#c&&this.#a?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#a?.isStart())return!1;if(this.#h===0)return!0;let e=this.#a;for(let r=0;r<this.#h;r++){let n=e.#r[r];if(!(n instanceof bc&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#a?.type==="!")return!0;if(!this.#a?.isEnd())return!1;if(!this.type)return this.#a?.isEnd();let e=this.#a?this.#a.#r.length:0;return this.#h===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let r=new bc(this.type,e);for(let n of this.#r)r.copyIn(n);return r}static#o(e,r,n,i,s){let a=i.maxExtglobRecursion??2,o=!1,c=!1,u=-1,f=!1;if(r.type===null){let g=n,v="";for(;g<e.length;){let y=e.charAt(g++);if(o||y==="\\"){o=!o,v+=y;continue}if(c){g===u+1?(y==="^"||y==="!")&&(f=!0):y==="]"&&!(g===u+2&&f)&&(c=!1),v+=y;continue}else if(y==="["){c=!0,u=g,f=!1,v+=y;continue}if(!i.noext&&Sre(y)&&e.charAt(g)==="("&&s<=a){r.push(v),v="";let x=new bc(y,r);g=bc.#o(e,x,g,i,s+1),r.push(x);continue}v+=y}return r.push(v),g}let d=n+1,p=new bc(null,r),h=[],m="";for(;d<e.length;){let g=e.charAt(d++);if(o||g==="\\"){o=!o,m+=g;continue}if(c){d===u+1?(g==="^"||g==="!")&&(f=!0):g==="]"&&!(d===u+2&&f)&&(c=!1),m+=g;continue}else if(g==="["){c=!0,u=d,f=!1,m+=g;continue}if(!i.noext&&Sre(g)&&e.charAt(d)==="("&&(s<=a||r&&r.#g(g))){let y=r&&r.#g(g)?0:1;p.push(m),m="";let b=new bc(g,p);p.push(b),d=bc.#o(e,b,d,i,s+y);continue}if(g==="|"){p.push(m),m="",h.push(p),p=new bc(null,r);continue}if(g===")")return m===""&&r.#r.length===0&&(r.#d=!0),p.push(m),m="",r.push(...h,p),d;m+=g}return r.type=null,r.#t=void 0,r.#r=[e.substring(n-1)],d}#x(e){return this.#w(e,gWt)}#w(e,r=mWt){if(!e||typeof e!="object"||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#g(n.type,r)}#g(e,r=vWt){return!!r.get(this.type)?.includes(e)}#v(e,r){let n=e.#r[0],i=new bc(null,n,this.options);i.#r.push(""),n.push(i),this.#A(e,r)}#A(e,r){let n=e.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#a=this);this.#f=void 0}#y(e){return!!VIe.get(this.type)?.has(e)}#S(e){if(!e||typeof e!="object"||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=e.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type)}#E(e){let r=VIe.get(this.type),n=e.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let s of this.#r)typeof s=="object"&&(s.#a=this);this.type=i,this.#f=void 0,this.#d=!1}static fromGlob(e,r={}){let n=new bc(null,void 0,r);return bc.#o(e,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#t||this.#i.nocase&&!this.#i.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let o=(this.#i.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,o),{_src:r,_glob:e})}get options(){return this.#i}toRegExpSource(e){let r=e??!!this.#i.dot;if(this.#e===this&&(this.#m(),this.#u()),!WIe(this)){let c=this.isStart()&&this.isEnd()&&!this.#r.some(h=>typeof h!="string"),u=this.#r.map(h=>{let[m,g,v,y]=typeof h=="string"?bc.#_(h,this.#t,c):h.toRegExpSource(e);return this.#t=this.#t||v,this.#n=this.#n||y,m}).join(""),f="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&xWt.has(this.#r[0]))){let m=bWt,g=r&&m.has(u.charAt(0))||u.startsWith("\\.")&&m.has(u.charAt(2))||u.startsWith("\\.\\.")&&m.has(u.charAt(4)),v=!r&&!e&&m.has(u.charAt(0));f=g?yWt:v?BN:""}let d="";return this.isEnd()&&this.#e.#c&&this.#a?.type==="!"&&(d="(?:$|\\/)"),[f+u+d,cf(u),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#b(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#r=[c],u.type=null,u.#t=void 0,[c,cf(this.toString()),!1,!1]}let a=!n||e||r||!BN?"":this.#b(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let o="";if(this.type==="!"&&this.#d)o=(this.isStart()&&!r?BN:"")+ZIe;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!e?BN:"")+GIe+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;o=i+s+c}return[o,cf(s),this.#t=!!this.#t,this.#n]}#m(){if(WIe(this)){let e=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#m(),this.#w(i)?(r=!1,this.#A(i,n)):this.#x(i)?(r=!1,this.#v(i,n)):this.#S(i)&&(r=!1,this.#E(i)))}}while(!r&&++e<10)}else for(let e of this.#r)typeof e=="object"&&e.#m();this.#f=void 0}#b(e){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,a]=r.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#_(e,r,n=!1){let i=!1,s="",a=!1,o=!1;for(let c=0;c<e.length;c++){let u=e.charAt(c);if(i){i=!1,s+=(_Wt.has(u)?"\\":"")+u;continue}if(u==="*"){if(o)continue;o=!0,s+=n&&/^[*]+$/.test(e)?ZIe:GIe,r=!0;continue}else o=!1;if(u==="\\"){c===e.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[f,d,p,h]=HIe(e,c);if(p){s+=f,a=a||d,c+=p-1,r=r||h;continue}}if(u==="?"){s+=Ere,r=!0;continue}s+=wWt(u)}return[s,cf(e),!!r,a]}};bc=j1;var z8=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!1}={})=>r?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var Fo=(t,e,r={})=>(yS(e),!r.nocomment&&e.charAt(0)==="#"?!1:new du(e,r).match(t)),EWt=/^\*+([^+@!?*[(]*)$/,kWt=t=>e=>!e.startsWith(".")&&e.endsWith(t),AWt=t=>e=>e.endsWith(t),CWt=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),TWt=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),PWt=/^\*+\.\*+$/,OWt=t=>!t.startsWith(".")&&t.includes("."),IWt=t=>t!=="."&&t!==".."&&t.includes("."),DWt=/^\.\*+$/,RWt=t=>t!=="."&&t!==".."&&t.startsWith("."),$Wt=/^\*+$/,jWt=t=>t.length!==0&&!t.startsWith("."),NWt=t=>t.length!==0&&t!=="."&&t!=="..",FWt=/^\?+([^+@!?*[(]*)?$/,MWt=([t,e=""])=>{let r=XIe([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},LWt=([t,e=""])=>{let r=YIe([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},qWt=([t,e=""])=>{let r=YIe([t]);return e?n=>r(n)&&n.endsWith(e):r},BWt=([t,e=""])=>{let r=XIe([t]);return e?n=>r(n)&&n.endsWith(e):r},XIe=([t])=>{let e=t.length;return r=>r.length===e&&!r.startsWith(".")},YIe=([t])=>{let e=t.length;return r=>r.length===e&&r!=="."&&r!==".."},QIe=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",KIe={win32:{sep:"\\"},posix:{sep:"/"}},UWt=QIe==="win32"?KIe.win32.sep:KIe.posix.sep;Fo.sep=UWt;var ms=Symbol("globstar **");Fo.GLOBSTAR=ms;var zWt="[^/]",HWt=zWt+"*?",WWt="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",VWt="(?:(?!(?:\\/|^)\\.).)*?",GWt=(t,e={})=>r=>Fo(r,t,e);Fo.filter=GWt;var cl=(t,e={})=>Object.assign({},t,e),ZWt=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return Fo;let e=Fo;return Object.assign((n,i,s={})=>e(n,i,cl(t,s)),{Minimatch:class extends e.Minimatch{constructor(i,s={}){super(i,cl(t,s))}static defaults(i){return e.defaults(cl(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,s,a={}){super(i,s,cl(t,a))}static fromGlob(i,s={}){return e.AST.fromGlob(i,cl(t,s))}},unescape:(n,i={})=>e.unescape(n,cl(t,i)),escape:(n,i={})=>e.escape(n,cl(t,i)),filter:(n,i={})=>e.filter(n,cl(t,i)),defaults:n=>e.defaults(cl(t,n)),makeRe:(n,i={})=>e.makeRe(n,cl(t,i)),braceExpand:(n,i={})=>e.braceExpand(n,cl(t,i)),match:(n,i,s={})=>e.match(n,i,cl(t,s)),sep:e.sep,GLOBSTAR:ms})};Fo.defaults=ZWt;var eDe=(t,e={})=>(yS(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:UIe(t,{max:e.braceExpandMax}));Fo.braceExpand=eDe;var KWt=(t,e={})=>new du(t,e).makeRe();Fo.makeRe=KWt;var JWt=(t,e,r={})=>{let n=new du(e,r);return t=t.filter(i=>n.match(i)),n.options.nonull&&!t.length&&t.push(e),t};Fo.match=JWt;var JIe=/[?*]|[+@!]\(.*?\)|\[|\]/,XWt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),du=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,r={}){yS(e),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=e,this.platform=r.platform||QIe,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let r of e)if(typeof r!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,r=this.options;if(!r.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,a,o)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!JIe.test(s[2]))&&!JIe.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(f=>this.parse(f))];if(u)return[s[0],...s.slice(1).map(f=>this.parse(f))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let a=this.set[s];a[0]===""&&a[1]===""&&this.globParts[s][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let n of e)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):r>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(e){return e.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let s=e[i];i===1&&s===""&&e[0]===""||(s==="."||s==="")&&(r=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(r=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,e.splice(n-1,2),n-=2)}}while(r);return e.length===0?[""]:e}firstPhasePreProcess(e){let r=!1;do{r=!1;for(let n of e){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let a=i;for(;n[a+1]==="**";)a++;a>i&&n.splice(i+1,a-i);let o=n[i+1],c=n[i+2],u=n[i+3];if(o!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(i,1);let f=n.slice(0);f[i]="**",e.push(f),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<n.length-1;a++){let o=n[a];a===1&&o===""&&n[0]===""||(o==="."||o==="")&&(r=!0,n.splice(a,1),a--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let a=n[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){r=!0;let c=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...c),n.length===0&&n.push(""),s-=2}}}}while(r);return e}secondPhasePreProcess(e){for(let r=0;r<e.length-1;r++)for(let n=r+1;n<e.length;n++){let i=this.partsMatch(e[r],e[n],!this.preserveMultipleSlashes);if(i){e[r]=[],e[n]=i;break}}return e.filter(r=>r.length)}partsMatch(e,r,n=!1){let i=0,s=0,a=[],o="";for(;i<e.length&&s<r.length;)if(e[i]===r[s])a.push(o==="b"?r[s]:e[i]),i++,s++;else if(n&&e[i]==="**"&&r[s]===e[i+1])a.push(e[i]),i++;else if(n&&r[s]==="**"&&e[i]===r[s+1])a.push(r[s]),s++;else if(e[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(o==="b")return!1;o="a",a.push(e[i]),i++,s++}else if(r[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(o==="a")return!1;o="b",a.push(r[s]),i++,s++}else return!1;return e.length===r.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,r=!1,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=e.slice(n)),this.negate=r}matchOne(e,r,n=!1){let i=0,s=0;if(this.isWindows){let o=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),c=!o&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),u=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),f=!u&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=c?3:o?0:void 0,p=f?3:u?0:void 0;if(typeof d=="number"&&typeof p=="number"){let[h,m]=[e[d],r[p]];h.toLowerCase()===m.toLowerCase()&&(r[p]=h,s=p,i=d)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),r.includes(ms)?this.#e(e,r,n,i,s):this.#n(e,r,n,i,s)}#e(e,r,n,i,s){let a=r.indexOf(ms,s),o=r.lastIndexOf(ms),[c,u,f]=n?[r.slice(s,a),r.slice(a+1),[]]:[r.slice(s,a),r.slice(a+1,o),r.slice(o+1)];if(c.length){let b=e.slice(i,i+c.length);if(!this.#n(b,c,n,0,0))return!1;i+=c.length,s+=c.length}let d=0;if(f.length){if(f.length+i>e.length)return!1;let b=e.length-f.length;if(this.#n(e,f,n,b,0))d=f.length;else{if(e[e.length-1]!==""||i+f.length===e.length||(b--,!this.#n(e,f,n,b,0)))return!1;d=f.length+1}}if(!u.length){let b=!!d;for(let x=i;x<e.length-d;x++){let k=String(e[x]);if(b=!0,k==="."||k===".."||!this.options.dot&&k.startsWith("."))return!1}return n||b}let p=[[[],0]],h=p[0],m=0,g=[0];for(let b of u)b===ms?(g.push(m),h=[[],0],p.push(h)):(h[0].push(b),m++);let v=p.length-1,y=e.length-d;for(let b of p)b[1]=y-(g[v--]+b[0].length);return!!this.#t(e,p,i,0,n,0,!!d)}#t(e,r,n,i,s,a,o){let c=r[i];if(!c){for(let d=n;d<e.length;d++){o=!0;let p=e[d];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return o}let[u,f]=c;for(;n<=f;){if(this.#n(e.slice(0,n+u.length),u,s,n,0)&&a<this.maxGlobstarRecursion){let h=this.#t(e,r,n+u.length,i+1,s,a+1,o);if(h!==!1)return h}let p=e[n];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;n++}return s||null}#n(e,r,n,i,s){let a,o,c,u;for(a=i,o=s,u=e.length,c=r.length;a<u&&o<c;a++,o++){this.debug("matchOne loop");let f=r[o],d=e[a];if(this.debug(r,f,d),f===!1||f===ms)return!1;let p;if(typeof f=="string"?(p=d===f,this.debug("string match",f,d,p)):(p=f.test(d),this.debug("pattern match",f,d,p)),!p)return!1}if(a===u&&o===c)return!0;if(a===u)return n;if(o===c)return a===u-1&&e[a]==="";throw new Error("wtf?")}braceExpand(){return eDe(this.pattern,this.options)}parse(e){yS(e);let r=this.options;if(e==="**")return ms;if(e==="")return"";let n,i=null;(n=e.match($Wt))?i=r.dot?NWt:jWt:(n=e.match(EWt))?i=(r.nocase?r.dot?TWt:CWt:r.dot?AWt:kWt)(n[1]):(n=e.match(FWt))?i=(r.nocase?r.dot?LWt:MWt:r.dot?qWt:BWt)(n):(n=e.match(PWt))?i=r.dot?IWt:OWt:(n=e.match(DWt))&&(i=RWt);let s=j1.fromGlob(e,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?HWt:r.dot?WWt:VWt,i=new Set(r.nocase?["i"]:[]),s=e.map(c=>{let u=c.map(d=>{if(d instanceof RegExp)for(let p of d.flags.split(""))i.add(p);return typeof d=="string"?XWt(d):d===ms?ms:d._src});u.forEach((d,p)=>{let h=u[p+1],m=u[p-1];d!==ms||m===ms||(m===void 0?h!==void 0&&h!==ms?u[p+1]="(?:\\/|"+n+"\\/)?"+h:u[p]=n:h===void 0?u[p-1]=m+"(?:\\/|\\/"+n+")?":h!==ms&&(u[p-1]=m+"(?:\\/|\\/"+n+"\\/)"+h,u[p+1]=ms))});let f=u.filter(d=>d!==ms);if(this.partial&&f.length>=1){let d=[];for(let p=1;p<=f.length;p++)d.push(f.slice(0,p).join("/"));return"(?:"+d.join("|")+")"}return f.join("/")}).join("|"),[a,o]=e.length>1?["(?:",")"]:["",""];s="^"+a+s+o+"$",this.partial&&(s="^(?:\\/|"+a+s.slice(1,-1)+o+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,r=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&r)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let a=i[i.length-1];if(!a)for(let o=i.length-2;!a&&o>=0;o--)a=i[o];for(let o of s){let c=i;if(n.matchBase&&o.length===1&&(c=[a]),this.matchOne(c,o,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return Fo.defaults(e).Minimatch}};Fo.AST=j1;Fo.Minimatch=du;Fo.escape=z8;Fo.unescape=cf;import{fileURLToPath as IVt}from"node:url";var YWt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,rDe=new Set,kre=typeof process=="object"&&process?process:{},nDe=(t,e,r,n)=>{typeof kre.emitWarning=="function"?kre.emitWarning(t,e,r,n):console.error(`[${r}] ${e}: ${t}`)},zN=globalThis.AbortController,tDe=globalThis.AbortSignal;if(typeof zN>"u"){tDe=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(r,n){this._onabort.push(n)}},zN=class{constructor(){e()}signal=new tDe;abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(let n of this.signal._onabort)n(r);this.signal.onabort?.(r)}}};let t=kre.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,nDe("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var QWt=t=>!rDe.has(t),efn=Symbol("type"),b0=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),iDe=t=>b0(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?UN:null:null,UN=class extends Array{constructor(t){super(t),this.fill(0)}},eVt=class xS{heap;length;static#e=!1;static create(e){let r=iDe(e);if(!r)return[];xS.#e=!0;let n=new xS(e,r);return xS.#e=!1,n}constructor(e,r){if(!xS.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},_S=class sDe{#e;#t;#n;#r;#a;#h;#l;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#i;#f;#d;#u;#o;#x;#w;#g;#v;#A;#y;#S;#E;#m;#b;#_;#C;#s;#$;static unsafeExposeInternals(e){return{starts:e.#E,ttls:e.#m,autopurgeTimers:e.#b,sizes:e.#S,keyMap:e.#d,keyList:e.#u,valList:e.#o,next:e.#x,prev:e.#w,get head(){return e.#g},get tail(){return e.#v},free:e.#A,isBackgroundFetch:r=>e.#p(r),backgroundFetch:(r,n,i,s)=>e.#U(r,n,i,s),moveToTail:r=>e.#N(r),indexes:r=>e.#O(r),rindexes:r=>e.#I(r),isStale:r=>e.#k(r)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#f}get size(){return this.#i}get fetchMethod(){return this.#h}get memoMethod(){return this.#l}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#a}constructor(e){let{max:r=0,ttl:n,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:o,allowStale:c,dispose:u,onInsert:f,disposeAfter:d,noDisposeOnSet:p,noUpdateTTL:h,maxSize:m=0,maxEntrySize:g=0,sizeCalculation:v,fetchMethod:y,memoMethod:b,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:k,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:P,ignoreFetchAbort:R,perf:$}=e;if($!==void 0&&typeof $?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#c=$??YWt,r!==0&&!b0(r))throw new TypeError("max option must be a nonnegative integer");let E=r?iDe(r):Array;if(!E)throw new Error("invalid max value: "+r);if(this.#e=r,this.#t=m,this.maxEntrySize=g||this.#t,this.sizeCalculation=v,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(b!==void 0&&typeof b!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#l=b,y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#h=y,this.#C=!!y,this.#d=new Map,this.#u=new Array(r).fill(void 0),this.#o=new Array(r).fill(void 0),this.#x=new E(r),this.#w=new E(r),this.#g=0,this.#v=0,this.#A=eVt.create(r),this.#i=0,this.#f=0,typeof u=="function"&&(this.#n=u),typeof f=="function"&&(this.#r=f),typeof d=="function"?(this.#a=d,this.#y=[]):(this.#a=void 0,this.#y=void 0),this.#_=!!this.#n,this.#$=!!this.#r,this.#s=!!this.#a,this.noDisposeOnSet=!!p,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!R,this.maxEntrySize!==0){if(this.#t!==0&&!b0(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!b0(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#H()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!k,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!o,this.ttlResolution=b0(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=n||0,this.ttl){if(!b0(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#D()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let T="LRU_CACHE_UNBOUNDED";QWt(T)&&(rDe.add(T),nDe("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",T,sDe))}}getRemainingTTL(e){return this.#d.has(e)?1/0:0}#D(){let e=new UN(this.#e),r=new UN(this.#e);this.#m=e,this.#E=r;let n=this.ttlAutopurge?new Array(this.#e):void 0;this.#b=n,this.#M=(o,c,u=this.#c.now())=>{r[o]=c!==0?u:0,e[o]=c,i(o,c)},this.#T=o=>{r[o]=e[o]!==0?this.#c.now():0,i(o,e[o])};let i=this.ttlAutopurge?(o,c)=>{if(n?.[o]&&(clearTimeout(n[o]),n[o]=void 0),c&&c!==0&&n){let u=setTimeout(()=>{this.#k(o)&&this.#P(this.#u[o],"expire")},c+1);u.unref&&u.unref(),n[o]=u}}:()=>{};this.#R=(o,c)=>{if(e[c]){let u=e[c],f=r[c];if(!u||!f)return;o.ttl=u,o.start=f,o.now=s||a();let d=o.now-f;o.remainingTTL=u-d}};let s=0,a=()=>{let o=this.#c.now();if(this.ttlResolution>0){s=o;let c=setTimeout(()=>s=0,this.ttlResolution);c.unref&&c.unref()}return o};this.getRemainingTTL=o=>{let c=this.#d.get(o);if(c===void 0)return 0;let u=e[c],f=r[c];if(!u||!f)return 1/0;let d=(s||a())-f;return u-d},this.#k=o=>{let c=r[o],u=e[o];return!!u&&!!c&&(s||a())-c>u}}#T=()=>{};#R=()=>{};#M=()=>{};#k=()=>!1;#H(){let e=new UN(this.#e);this.#f=0,this.#S=e,this.#F=r=>{this.#f-=e[r],e[r]=0},this.#L=(r,n,i,s)=>{if(this.#p(n))return 0;if(!b0(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(n,r),!b0(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#j=(r,n,i)=>{if(e[r]=n,this.#t){let s=this.#t-e[r];for(;this.#f>s;)this.#B(!0)}this.#f+=e[r],i&&(i.entrySize=n,i.totalCalculatedSize=this.#f)}}#F=e=>{};#j=(e,r,n)=>{};#L=(e,r,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:e=this.allowStale}={}){if(this.#i)for(let r=this.#v;!(!this.#q(r)||((e||!this.#k(r))&&(yield r),r===this.#g));)r=this.#w[r]}*#I({allowStale:e=this.allowStale}={}){if(this.#i)for(let r=this.#g;!(!this.#q(r)||((e||!this.#k(r))&&(yield r),r===this.#v));)r=this.#x[r]}#q(e){return e!==void 0&&this.#d.get(this.#u[e])===e}*entries(){for(let e of this.#O())this.#o[e]!==void 0&&this.#u[e]!==void 0&&!this.#p(this.#o[e])&&(yield[this.#u[e],this.#o[e]])}*rentries(){for(let e of this.#I())this.#o[e]!==void 0&&this.#u[e]!==void 0&&!this.#p(this.#o[e])&&(yield[this.#u[e],this.#o[e]])}*keys(){for(let e of this.#O()){let r=this.#u[e];r!==void 0&&!this.#p(this.#o[e])&&(yield r)}}*rkeys(){for(let e of this.#I()){let r=this.#u[e];r!==void 0&&!this.#p(this.#o[e])&&(yield r)}}*values(){for(let e of this.#O())this.#o[e]!==void 0&&!this.#p(this.#o[e])&&(yield this.#o[e])}*rvalues(){for(let e of this.#I())this.#o[e]!==void 0&&!this.#p(this.#o[e])&&(yield this.#o[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,r={}){for(let n of this.#O()){let i=this.#o[n],s=this.#p(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#u[n],this))return this.get(this.#u[n],r)}}forEach(e,r=this){for(let n of this.#O()){let i=this.#o[n],s=this.#p(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(r,s,this.#u[n],this)}}rforEach(e,r=this){for(let n of this.#I()){let i=this.#o[n],s=this.#p(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(r,s,this.#u[n],this)}}purgeStale(){let e=!1;for(let r of this.#I({allowStale:!0}))this.#k(r)&&(this.#P(this.#u[r],"expire"),e=!0);return e}info(e){let r=this.#d.get(e);if(r===void 0)return;let n=this.#o[r],i=this.#p(n)?n.__staleWhileFetching:n;if(i===void 0)return;let s={value:i};if(this.#m&&this.#E){let a=this.#m[r],o=this.#E[r];if(a&&o){let c=a-(this.#c.now()-o);s.ttl=c,s.start=Date.now()}}return this.#S&&(s.size=this.#S[r]),s}dump(){let e=[];for(let r of this.#O({allowStale:!0})){let n=this.#u[r],i=this.#o[r],s=this.#p(i)?i.__staleWhileFetching:i;if(s===void 0||n===void 0)continue;let a={value:s};if(this.#m&&this.#E){a.ttl=this.#m[r];let o=this.#c.now()-this.#E[r];a.start=Math.floor(Date.now()-o)}this.#S&&(a.size=this.#S[r]),e.unshift([n,a])}return e}load(e){this.clear();for(let[r,n]of e){if(n.start){let i=Date.now()-n.start;n.start=this.#c.now()-i}this.set(r,n.value,n)}}set(e,r,n={}){if(r===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:c}=n,{noUpdateTTL:u=this.noUpdateTTL}=n,f=this.#L(e,r,n.size||0,o);if(this.maxEntrySize&&f>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#P(e,"set"),this;let d=this.#i===0?void 0:this.#d.get(e);if(d===void 0)d=this.#i===0?this.#v:this.#A.length!==0?this.#A.pop():this.#i===this.#e?this.#B(!1):this.#i,this.#u[d]=e,this.#o[d]=r,this.#d.set(e,d),this.#x[this.#v]=d,this.#w[d]=this.#v,this.#v=d,this.#i++,this.#j(d,f,c),c&&(c.set="add"),u=!1,this.#$&&this.#r?.(r,e,"add");else{this.#N(d);let p=this.#o[d];if(r!==p){if(this.#C&&this.#p(p)){p.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:h}=p;h!==void 0&&!a&&(this.#_&&this.#n?.(h,e,"set"),this.#s&&this.#y?.push([h,e,"set"]))}else a||(this.#_&&this.#n?.(p,e,"set"),this.#s&&this.#y?.push([p,e,"set"]));if(this.#F(d),this.#j(d,f,c),this.#o[d]=r,c){c.set="replace";let h=p&&this.#p(p)?p.__staleWhileFetching:p;h!==void 0&&(c.oldValue=h)}}else c&&(c.set="update");this.#$&&this.onInsert?.(r,e,r===p?"update":"replace")}if(i!==0&&!this.#m&&this.#D(),this.#m&&(u||this.#M(d,i,s),c&&this.#R(c,d)),!a&&this.#s&&this.#y){let p=this.#y,h;for(;h=p?.shift();)this.#a?.(...h)}return this}pop(){try{for(;this.#i;){let e=this.#o[this.#g];if(this.#B(!0),this.#p(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#s&&this.#y){let e=this.#y,r;for(;r=e?.shift();)this.#a?.(...r)}}}#B(e){let r=this.#g,n=this.#u[r],i=this.#o[r];return this.#C&&this.#p(i)?i.__abortController.abort(new Error("evicted")):(this.#_||this.#s)&&(this.#_&&this.#n?.(i,n,"evict"),this.#s&&this.#y?.push([i,n,"evict"])),this.#F(r),this.#b?.[r]&&(clearTimeout(this.#b[r]),this.#b[r]=void 0),e&&(this.#u[r]=void 0,this.#o[r]=void 0,this.#A.push(r)),this.#i===1?(this.#g=this.#v=0,this.#A.length=0):this.#g=this.#x[r],this.#d.delete(n),this.#i--,r}has(e,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=r,s=this.#d.get(e);if(s!==void 0){let a=this.#o[s];if(this.#p(a)&&a.__staleWhileFetching===void 0)return!1;if(this.#k(s))i&&(i.has="stale",this.#R(i,s));else return n&&this.#T(s),i&&(i.has="hit",this.#R(i,s)),!0}else i&&(i.has="miss");return!1}peek(e,r={}){let{allowStale:n=this.allowStale}=r,i=this.#d.get(e);if(i===void 0||!n&&this.#k(i))return;let s=this.#o[i];return this.#p(s)?s.__staleWhileFetching:s}#U(e,r,n,i){let s=r===void 0?void 0:this.#o[r];if(this.#p(s))return s;let a=new zN,{signal:o}=n;o?.addEventListener("abort",()=>a.abort(o.reason),{signal:a.signal});let c={signal:a.signal,options:n,context:i},u=(g,v=!1)=>{let{aborted:y}=a.signal,b=n.ignoreFetchAbort&&g!==void 0,x=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&g!==void 0);if(n.status&&(y&&!v?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,b&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),y&&!b&&!v)return d(a.signal.reason,x);let k=h,A=this.#o[r];return(A===h||b&&v&&A===void 0)&&(g===void 0?k.__staleWhileFetching!==void 0?this.#o[r]=k.__staleWhileFetching:this.#P(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,g,c.options))),g},f=g=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=g),d(g,!1)),d=(g,v)=>{let{aborted:y}=a.signal,b=y&&n.allowStaleOnFetchAbort,x=b||n.allowStaleOnFetchRejection,k=x||n.noDeleteOnFetchRejection,A=h;if(this.#o[r]===h&&(!k||!v&&A.__staleWhileFetching===void 0?this.#P(e,"fetch"):b||(this.#o[r]=A.__staleWhileFetching)),x)return n.status&&A.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),A.__staleWhileFetching;if(A.__returned===A)throw g},p=(g,v)=>{let y=this.#h?.(e,s,c);y&&y instanceof Promise&&y.then(b=>g(b===void 0?void 0:b),v),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(g(void 0),n.allowStaleOnFetchAbort&&(g=b=>u(b,!0)))})};n.status&&(n.status.fetchDispatched=!0);let h=new Promise(p).then(u,f),m=Object.assign(h,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return r===void 0?(this.set(e,m,{...c.options,status:void 0}),r=this.#d.get(e)):this.#o[r]=m,m}#p(e){if(!this.#C)return!1;let r=e;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof zN}async fetch(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:c=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:h=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:g,forceRefresh:v=!1,status:y,signal:b}=r;if(!this.#C)return y&&(y.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:y});let x={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:o,size:c,sizeCalculation:u,noUpdateTTL:f,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:m,ignoreFetchAbort:h,status:y,signal:b},k=this.#d.get(e);if(k===void 0){y&&(y.fetch="miss");let A=this.#U(e,k,x,g);return A.__returned=A}else{let A=this.#o[k];if(this.#p(A)){let E=n&&A.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",E&&(y.returnedStale=!0)),E?A.__staleWhileFetching:A.__returned=A}let P=this.#k(k);if(!v&&!P)return y&&(y.fetch="hit"),this.#N(k),i&&this.#T(k),y&&this.#R(y,k),A;let R=this.#U(e,k,x,g),$=R.__staleWhileFetching!==void 0&&n;return y&&(y.fetch=P?"stale":"refresh",$&&P&&(y.returnedStale=!0)),$?R.__staleWhileFetching:R.__returned=R}}async forceFetch(e,r={}){let n=await this.fetch(e,r);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,r={}){let n=this.#l;if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:s,...a}=r,o=this.get(e,a);if(!s&&o!==void 0)return o;let c=n(e,o,{options:a,context:i});return this.set(e,c,a),c}get(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=r,o=this.#d.get(e);if(o!==void 0){let c=this.#o[o],u=this.#p(c);return a&&this.#R(a,o),this.#k(o)?(a&&(a.get="stale"),u?(a&&n&&c.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?c.__staleWhileFetching:void 0):(s||this.#P(e,"expire"),a&&n&&(a.returnedStale=!0),n?c:void 0)):(a&&(a.get="hit"),u?c.__staleWhileFetching:(this.#N(o),i&&this.#T(o),c))}else a&&(a.get="miss")}#z(e,r){this.#w[r]=e,this.#x[e]=r}#N(e){e!==this.#v&&(e===this.#g?this.#g=this.#x[e]:this.#z(this.#w[e],this.#x[e]),this.#z(this.#v,e),this.#v=e)}delete(e){return this.#P(e,"delete")}#P(e,r){let n=!1;if(this.#i!==0){let i=this.#d.get(e);if(i!==void 0)if(this.#b?.[i]&&(clearTimeout(this.#b?.[i]),this.#b[i]=void 0),n=!0,this.#i===1)this.#W(r);else{this.#F(i);let s=this.#o[i];if(this.#p(s)?s.__abortController.abort(new Error("deleted")):(this.#_||this.#s)&&(this.#_&&this.#n?.(s,e,r),this.#s&&this.#y?.push([s,e,r])),this.#d.delete(e),this.#u[i]=void 0,this.#o[i]=void 0,i===this.#v)this.#v=this.#w[i];else if(i===this.#g)this.#g=this.#x[i];else{let a=this.#w[i];this.#x[a]=this.#x[i];let o=this.#x[i];this.#w[o]=this.#w[i]}this.#i--,this.#A.push(i)}}if(this.#s&&this.#y?.length){let i=this.#y,s;for(;s=i?.shift();)this.#a?.(...s)}return n}clear(){return this.#W("delete")}#W(e){for(let r of this.#I({allowStale:!0})){let n=this.#o[r];if(this.#p(n))n.__abortController.abort(new Error("deleted"));else{let i=this.#u[r];this.#_&&this.#n?.(n,i,e),this.#s&&this.#y?.push([n,i,e])}}if(this.#d.clear(),this.#o.fill(void 0),this.#u.fill(void 0),this.#m&&this.#E){this.#m.fill(0),this.#E.fill(0);for(let r of this.#b??[])r!==void 0&&clearTimeout(r);this.#b?.fill(void 0)}if(this.#S&&this.#S.fill(0),this.#g=0,this.#v=0,this.#A.length=0,this.#f=0,this.#i=0,this.#s&&this.#y){let r=this.#y,n;for(;n=r?.shift();)this.#a?.(...n)}}};import{posix as fVt,win32 as jre}from"node:path";import{fileURLToPath as dVt}from"node:url";import{lstatSync as pVt,readdir as hVt,readdirSync as mVt,readlinkSync as gVt,realpathSync as vVt}from"fs";import*as yVt from"node:fs";import{lstat as xVt,readdir as _Vt,readlink as wVt,realpath as SVt}from"node:fs/promises";import{EventEmitter as Dre}from"node:events";import lDe from"node:stream";import{StringDecoder as tVt}from"node:string_decoder";var aDe=typeof process=="object"&&process?process:{stdout:null,stderr:null},rVt=t=>!!t&&typeof t=="object"&&(t instanceof _0||t instanceof lDe||nVt(t)||iVt(t)),nVt=t=>!!t&&typeof t=="object"&&t instanceof Dre&&typeof t.pipe=="function"&&t.pipe!==lDe.Writable.prototype.pipe,iVt=t=>!!t&&typeof t=="object"&&t instanceof Dre&&typeof t.write=="function"&&typeof t.end=="function",th=Symbol("EOF"),rh=Symbol("maybeEmitEnd"),x0=Symbol("emittedEnd"),HN=Symbol("emittingEnd"),wS=Symbol("emittedError"),WN=Symbol("closed"),oDe=Symbol("read"),VN=Symbol("flush"),cDe=Symbol("flushChunk"),uf=Symbol("encoding"),H8=Symbol("decoder"),ca=Symbol("flowing"),SS=Symbol("paused"),W8=Symbol("resume"),ua=Symbol("buffer"),Mo=Symbol("pipes"),la=Symbol("bufferLength"),Are=Symbol("bufferPush"),GN=Symbol("bufferShift"),no=Symbol("objectMode"),gs=Symbol("destroyed"),Cre=Symbol("error"),Tre=Symbol("emitData"),uDe=Symbol("emitEnd"),Pre=Symbol("emitEnd2"),Pd=Symbol("async"),Ore=Symbol("abort"),ZN=Symbol("aborted"),ES=Symbol("signal"),N1=Symbol("dataListeners"),pu=Symbol("discarded"),kS=t=>Promise.resolve().then(t),sVt=t=>t(),aVt=t=>t==="end"||t==="finish"||t==="prefinish",oVt=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,cVt=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),KN=class{src;dest;opts;ondrain;constructor(e,r,n){this.src=e,this.dest=r,this.opts=n,this.ondrain=()=>e[W8](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Ire=class extends KN{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,r,n){super(e,r,n),this.proxyErrors=i=>this.dest.emit("error",i),e.on("error",this.proxyErrors)}},uVt=t=>!!t.objectMode,lVt=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",_0=class extends Dre{[ca]=!1;[SS]=!1;[Mo]=[];[ua]=[];[no];[uf];[Pd];[H8];[th]=!1;[x0]=!1;[HN]=!1;[WN]=!1;[wS]=null;[la]=0;[gs]=!1;[ES];[ZN]=!1;[N1]=0;[pu]=!1;writable=!0;readable=!0;constructor(...e){let r=e[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");uVt(r)?(this[no]=!0,this[uf]=null):lVt(r)?(this[uf]=r.encoding,this[no]=!1):(this[no]=!1,this[uf]=null),this[Pd]=!!r.async,this[H8]=this[uf]?new tVt(this[uf]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[ua]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Mo]});let{signal:n}=r;n&&(this[ES]=n,n.aborted?this[Ore]():n.addEventListener("abort",()=>this[Ore]()))}get bufferLength(){return this[la]}get encoding(){return this[uf]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[no]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Pd]}set async(e){this[Pd]=this[Pd]||!!e}[Ore](){this[ZN]=!0,this.emit("abort",this[ES]?.reason),this.destroy(this[ES]?.reason)}get aborted(){return this[ZN]}set aborted(e){}write(e,r,n){if(this[ZN])return!1;if(this[th])throw new Error("write after end");if(this[gs])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(n=r,r="utf8"),r||(r="utf8");let i=this[Pd]?kS:sVt;if(!this[no]&&!Buffer.isBuffer(e)){if(cVt(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(oVt(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[no]?(this[ca]&&this[la]!==0&&this[VN](!0),this[ca]?this.emit("data",e):this[Are](e),this[la]!==0&&this.emit("readable"),n&&i(n),this[ca]):e.length?(typeof e=="string"&&!(r===this[uf]&&!this[H8]?.lastNeed)&&(e=Buffer.from(e,r)),Buffer.isBuffer(e)&&this[uf]&&(e=this[H8].write(e)),this[ca]&&this[la]!==0&&this[VN](!0),this[ca]?this.emit("data",e):this[Are](e),this[la]!==0&&this.emit("readable"),n&&i(n),this[ca]):(this[la]!==0&&this.emit("readable"),n&&i(n),this[ca])}read(e){if(this[gs])return null;if(this[pu]=!1,this[la]===0||e===0||e&&e>this[la])return this[rh](),null;this[no]&&(e=null),this[ua].length>1&&!this[no]&&(this[ua]=[this[uf]?this[ua].join(""):Buffer.concat(this[ua],this[la])]);let r=this[oDe](e||null,this[ua][0]);return this[rh](),r}[oDe](e,r){if(this[no])this[GN]();else{let n=r;e===n.length||e===null?this[GN]():typeof n=="string"?(this[ua][0]=n.slice(e),r=n.slice(0,e),this[la]-=e):(this[ua][0]=n.subarray(e),r=n.subarray(0,e),this[la]-=e)}return this.emit("data",r),!this[ua].length&&!this[th]&&this.emit("drain"),r}end(e,r,n){return typeof e=="function"&&(n=e,e=void 0),typeof r=="function"&&(n=r,r="utf8"),e!==void 0&&this.write(e,r),n&&this.once("end",n),this[th]=!0,this.writable=!1,(this[ca]||!this[SS])&&this[rh](),this}[W8](){this[gs]||(!this[N1]&&!this[Mo].length&&(this[pu]=!0),this[SS]=!1,this[ca]=!0,this.emit("resume"),this[ua].length?this[VN]():this[th]?this[rh]():this.emit("drain"))}resume(){return this[W8]()}pause(){this[ca]=!1,this[SS]=!0,this[pu]=!1}get destroyed(){return this[gs]}get flowing(){return this[ca]}get paused(){return this[SS]}[Are](e){this[no]?this[la]+=1:this[la]+=e.length,this[ua].push(e)}[GN](){return this[no]?this[la]-=1:this[la]-=this[ua][0].length,this[ua].shift()}[VN](e=!1){do;while(this[cDe](this[GN]())&&this[ua].length);!e&&!this[ua].length&&!this[th]&&this.emit("drain")}[cDe](e){return this.emit("data",e),this[ca]}pipe(e,r){if(this[gs])return e;this[pu]=!1;let n=this[x0];return r=r||{},e===aDe.stdout||e===aDe.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,n?r.end&&e.end():(this[Mo].push(r.proxyErrors?new Ire(this,e,r):new KN(this,e,r)),this[Pd]?kS(()=>this[W8]()):this[W8]()),e}unpipe(e){let r=this[Mo].find(n=>n.dest===e);r&&(this[Mo].length===1?(this[ca]&&this[N1]===0&&(this[ca]=!1),this[Mo]=[]):this[Mo].splice(this[Mo].indexOf(r),1),r.unpipe())}addListener(e,r){return this.on(e,r)}on(e,r){let n=super.on(e,r);if(e==="data")this[pu]=!1,this[N1]++,!this[Mo].length&&!this[ca]&&this[W8]();else if(e==="readable"&&this[la]!==0)super.emit("readable");else if(aVt(e)&&this[x0])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[wS]){let i=r;this[Pd]?kS(()=>i.call(this,this[wS])):i.call(this,this[wS])}return n}removeListener(e,r){return this.off(e,r)}off(e,r){let n=super.off(e,r);return e==="data"&&(this[N1]=this.listeners("data").length,this[N1]===0&&!this[pu]&&!this[Mo].length&&(this[ca]=!1)),n}removeAllListeners(e){let r=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[N1]=0,!this[pu]&&!this[Mo].length&&(this[ca]=!1)),r}get emittedEnd(){return this[x0]}[rh](){!this[HN]&&!this[x0]&&!this[gs]&&this[ua].length===0&&this[th]&&(this[HN]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[WN]&&this.emit("close"),this[HN]=!1)}emit(e,...r){let n=r[0];if(e!=="error"&&e!=="close"&&e!==gs&&this[gs])return!1;if(e==="data")return!this[no]&&!n?!1:this[Pd]?(kS(()=>this[Tre](n)),!0):this[Tre](n);if(e==="end")return this[uDe]();if(e==="close"){if(this[WN]=!0,!this[x0]&&!this[gs])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[wS]=n,super.emit(Cre,n);let s=!this[ES]||this.listeners("error").length?super.emit("error",n):!1;return this[rh](),s}else if(e==="resume"){let s=super.emit("resume");return this[rh](),s}else if(e==="finish"||e==="prefinish"){let s=super.emit(e);return this.removeAllListeners(e),s}let i=super.emit(e,...r);return this[rh](),i}[Tre](e){for(let n of this[Mo])n.dest.write(e)===!1&&this.pause();let r=this[pu]?!1:super.emit("data",e);return this[rh](),r}[uDe](){return this[x0]?!1:(this[x0]=!0,this.readable=!1,this[Pd]?(kS(()=>this[Pre]()),!0):this[Pre]())}[Pre](){if(this[H8]){let r=this[H8].end();if(r){for(let n of this[Mo])n.dest.write(r);this[pu]||super.emit("data",r)}}for(let r of this[Mo])r.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[no]||(e.dataLength=0);let r=this.promise();return this.on("data",n=>{e.push(n),this[no]||(e.dataLength+=n.length)}),await r,e}async concat(){if(this[no])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[uf]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,r)=>{this.on(gs,()=>r(new Error("stream destroyed"))),this.on("error",n=>r(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[pu]=!1;let e=!1,r=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return r();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[th])return r();let s,a,o=d=>{this.off("data",c),this.off("end",u),this.off(gs,f),r(),a(d)},c=d=>{this.off("error",o),this.off("end",u),this.off(gs,f),this.pause(),s({value:d,done:!!this[th]})},u=()=>{this.off("error",o),this.off("data",c),this.off(gs,f),r(),s({done:!0,value:void 0})},f=()=>o(new Error("stream destroyed"));return new Promise((d,p)=>{a=p,s=d,this.once(gs,f),this.once("error",o),this.once("end",u),this.once("data",c)})},throw:r,return:r,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[pu]=!1;let e=!1,r=()=>(this.pause(),this.off(Cre,r),this.off(gs,r),this.off("end",r),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return r();let i=this.read();return i===null?r():{done:!1,value:i}};return this.once("end",r),this.once(Cre,r),this.once(gs,r),{next:n,throw:r,return:r,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[gs])return e?this.emit("error",e):this.emit(gs),this;this[gs]=!0,this[pu]=!0,this[ua].length=0,this[la]=0;let r=this;return typeof r.close=="function"&&!this[WN]&&r.close(),e?this.emit("error",e):this.emit(gs),this}static get isStream(){return rVt}};var bVt=vVt.native,CS={lstatSync:pVt,readdir:hVt,readdirSync:mVt,readlinkSync:gVt,realpathSync:bVt,promises:{lstat:xVt,readdir:_Vt,readlink:wVt,realpath:SVt}},mDe=t=>!t||t===CS||t===yVt?CS:{...CS,...t,promises:{...CS.promises,...t.promises||{}}},gDe=/^\\\\\?\\([a-z]:)\\?$/i,EVt=t=>t.replace(/\//g,"\\").replace(gDe,"$1\\"),kVt=/[\\\/]/,ll=0,vDe=1,yDe=2,Od=4,bDe=6,xDe=8,F1=10,_De=12,ul=15,AS=~ul,Rre=16,fDe=32,TS=64,lf=128,JN=256,YN=512,dDe=TS|lf|YN,AVt=1023,$re=t=>t.isFile()?xDe:t.isDirectory()?Od:t.isSymbolicLink()?F1:t.isCharacterDevice()?yDe:t.isBlockDevice()?bDe:t.isSocket()?_De:t.isFIFO()?vDe:ll,pDe=new _S({max:2**12}),PS=t=>{let e=pDe.get(t);if(e)return e;let r=t.normalize("NFKD");return pDe.set(t,r),r},hDe=new _S({max:2**12}),XN=t=>{let e=hDe.get(t);if(e)return e;let r=PS(t.toLowerCase());return hDe.set(t,r),r},QN=class extends _S{constructor(){super({max:256})}},Nre=class extends _S{constructor(e=16*1024){super({maxSize:e,sizeCalculation:r=>r.length+1})}},wDe=Symbol("PathScurry setAsCwd"),io=class{name;root;roots;parent;nocase;isCWD=!1;#e;#t;get dev(){return this.#t}#n;get mode(){return this.#n}#r;get nlink(){return this.#r}#a;get uid(){return this.#a}#h;get gid(){return this.#h}#l;get rdev(){return this.#l}#c;get blksize(){return this.#c}#i;get ino(){return this.#i}#f;get size(){return this.#f}#d;get blocks(){return this.#d}#u;get atimeMs(){return this.#u}#o;get mtimeMs(){return this.#o}#x;get ctimeMs(){return this.#x}#w;get birthtimeMs(){return this.#w}#g;get atime(){return this.#g}#v;get mtime(){return this.#v}#A;get ctime(){return this.#A}#y;get birthtime(){return this.#y}#S;#E;#m;#b;#_;#C;#s;#$;#D;#T;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,r=ll,n,i,s,a,o){this.name=e,this.#S=s?XN(e):PS(e),this.#s=r&AVt,this.nocase=s,this.roots=i,this.root=n||this,this.#$=a,this.#m=o.fullpath,this.#_=o.relative,this.#C=o.relativePosix,this.parent=o.parent,this.parent?this.#e=this.parent.#e:this.#e=mDe(o.fs)}depth(){return this.#E!==void 0?this.#E:this.parent?this.#E=this.parent.depth()+1:this.#E=0}childrenCache(){return this.#$}resolve(e){if(!e)return this;let r=this.getRootString(e),i=e.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#R(i):this.#R(i)}#R(e){let r=this;for(let n of e)r=r.child(n);return r}children(){let e=this.#$.get(this);if(e)return e;let r=Object.assign([],{provisional:0});return this.#$.set(this,r),this.#s&=~Rre,r}child(e,r){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let n=this.children(),i=this.nocase?XN(e):PS(e);for(let c of n)if(c.#S===i)return c;let s=this.parent?this.sep:"",a=this.#m?this.#m+s+e:void 0,o=this.newChild(e,ll,{...r,parent:this,fullpath:a});return this.canReaddir()||(o.#s|=lf),n.push(o),o}relative(){if(this.isCWD)return"";if(this.#_!==void 0)return this.#_;let e=this.name,r=this.parent;if(!r)return this.#_=this.name;let n=r.relative();return n+(!n||!r.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#C!==void 0)return this.#C;let e=this.name,r=this.parent;if(!r)return this.#C=this.fullpathPosix();let n=r.relativePosix();return n+(!n||!r.parent?"":"/")+e}fullpath(){if(this.#m!==void 0)return this.#m;let e=this.name,r=this.parent;if(!r)return this.#m=this.name;let i=r.fullpath()+(r.parent?this.sep:"")+e;return this.#m=i}fullpathPosix(){if(this.#b!==void 0)return this.#b;if(this.sep==="/")return this.#b=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#b=`//?/${i}`:this.#b=i}let e=this.parent,r=e.fullpathPosix(),n=r+(!r||!e.parent?"":"/")+this.name;return this.#b=n}isUnknown(){return(this.#s&ul)===ll}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#s&ul)===xDe}isDirectory(){return(this.#s&ul)===Od}isCharacterDevice(){return(this.#s&ul)===yDe}isBlockDevice(){return(this.#s&ul)===bDe}isFIFO(){return(this.#s&ul)===vDe}isSocket(){return(this.#s&ul)===_De}isSymbolicLink(){return(this.#s&F1)===F1}lstatCached(){return this.#s&fDe?this:void 0}readlinkCached(){return this.#D}realpathCached(){return this.#T}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#D)return!0;if(!this.parent)return!1;let e=this.#s&ul;return!(e!==ll&&e!==F1||this.#s&JN||this.#s&lf)}calledReaddir(){return!!(this.#s&Rre)}isENOENT(){return!!(this.#s&lf)}isNamed(e){return this.nocase?this.#S===XN(e):this.#S===PS(e)}async readlink(){let e=this.#D;if(e)return e;if(this.canReadlink()&&this.parent)try{let r=await this.#e.promises.readlink(this.fullpath()),n=(await this.parent.realpath())?.resolve(r);if(n)return this.#D=n}catch(r){this.#I(r.code);return}}readlinkSync(){let e=this.#D;if(e)return e;if(this.canReadlink()&&this.parent)try{let r=this.#e.readlinkSync(this.fullpath()),n=this.parent.realpathSync()?.resolve(r);if(n)return this.#D=n}catch(r){this.#I(r.code);return}}#M(e){this.#s|=Rre;for(let r=e.provisional;r<e.length;r++){let n=e[r];n&&n.#k()}}#k(){this.#s&lf||(this.#s=(this.#s|lf)&AS,this.#H())}#H(){let e=this.children();e.provisional=0;for(let r of e)r.#k()}#F(){this.#s|=YN,this.#j()}#j(){if(this.#s&TS)return;let e=this.#s;(e&ul)===Od&&(e&=AS),this.#s=e|TS,this.#H()}#L(e=""){e==="ENOTDIR"||e==="EPERM"?this.#j():e==="ENOENT"?this.#k():this.children().provisional=0}#O(e=""){e==="ENOTDIR"?this.parent.#j():e==="ENOENT"&&this.#k()}#I(e=""){let r=this.#s;r|=JN,e==="ENOENT"&&(r|=lf),(e==="EINVAL"||e==="UNKNOWN")&&(r&=AS),this.#s=r,e==="ENOTDIR"&&this.parent&&this.parent.#j()}#q(e,r){return this.#U(e,r)||this.#B(e,r)}#B(e,r){let n=$re(e),i=this.newChild(e.name,n,{parent:this}),s=i.#s&ul;return s!==Od&&s!==F1&&s!==ll&&(i.#s|=TS),r.unshift(i),r.provisional++,i}#U(e,r){for(let n=r.provisional;n<r.length;n++){let i=r[n];if((this.nocase?XN(e.name):PS(e.name))===i.#S)return this.#p(e,i,n,r)}}#p(e,r,n,i){let s=r.name;return r.#s=r.#s&AS|$re(e),s!==e.name&&(r.name=e.name),n!==i.provisional&&(n===i.length-1?i.pop():i.splice(n,1),i.unshift(r)),i.provisional++,r}async lstat(){if((this.#s&lf)===0)try{return this.#z(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#O(e.code)}}lstatSync(){if((this.#s&lf)===0)try{return this.#z(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#O(e.code)}}#z(e){let{atime:r,atimeMs:n,birthtime:i,birthtimeMs:s,blksize:a,blocks:o,ctime:c,ctimeMs:u,dev:f,gid:d,ino:p,mode:h,mtime:m,mtimeMs:g,nlink:v,rdev:y,size:b,uid:x}=e;this.#g=r,this.#u=n,this.#y=i,this.#w=s,this.#c=a,this.#d=o,this.#A=c,this.#x=u,this.#t=f,this.#h=d,this.#i=p,this.#n=h,this.#v=m,this.#o=g,this.#r=v,this.#l=y,this.#f=b,this.#a=x;let k=$re(e);this.#s=this.#s&AS|k|fDe,k!==ll&&k!==Od&&k!==F1&&(this.#s|=TS)}#N=[];#P=!1;#W(e){this.#P=!1;let r=this.#N.slice();this.#N.length=0,r.forEach(n=>n(null,e))}readdirCB(e,r=!1){if(!this.canReaddir()){r?e(null,[]):queueMicrotask(()=>e(null,[]));return}let n=this.children();if(this.calledReaddir()){let s=n.slice(0,n.provisional);r?e(null,s):queueMicrotask(()=>e(null,s));return}if(this.#N.push(e),this.#P)return;this.#P=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(s,a)=>{if(s)this.#L(s.code),n.provisional=0;else{for(let o of a)this.#q(o,n);this.#M(n)}this.#W(n.slice(0,n.provisional))})}#V;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let r=this.fullpath();if(this.#V)await this.#V;else{let n=()=>{};this.#V=new Promise(i=>n=i);try{for(let i of await this.#e.promises.readdir(r,{withFileTypes:!0}))this.#q(i,e);this.#M(e)}catch(i){this.#L(i.code),e.provisional=0}this.#V=void 0,n()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let r=this.fullpath();try{for(let n of this.#e.readdirSync(r,{withFileTypes:!0}))this.#q(n,e);this.#M(e)}catch(n){this.#L(n.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#s&dDe)return!1;let e=ul&this.#s;return e===ll||e===Od||e===F1}shouldWalk(e,r){return(this.#s&Od)===Od&&!(this.#s&dDe)&&!e.has(this)&&(!r||r(this))}async realpath(){if(this.#T)return this.#T;if(!((YN|JN|lf)&this.#s))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#T=this.resolve(e)}catch{this.#F()}}realpathSync(){if(this.#T)return this.#T;if(!((YN|JN|lf)&this.#s))try{let e=this.#e.realpathSync(this.fullpath());return this.#T=this.resolve(e)}catch{this.#F()}}[wDe](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let r=new Set([]),n=[],i=this;for(;i&&i.parent;)r.add(i),i.#_=n.join(this.sep),i.#C=n.join("/"),i=i.parent,n.push("..");for(i=e;i&&i.parent&&!r.has(i);)i.#_=void 0,i.#C=void 0,i=i.parent}},eF=class t extends io{sep="\\";splitSep=kVt;constructor(e,r=ll,n,i,s,a,o){super(e,r,n,i,s,a,o)}newChild(e,r=ll,n={}){return new t(e,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(e){return jre.parse(e).root}getRoot(e){if(e=EVt(e.toUpperCase()),e===this.root.name)return this.root;for(let[r,n]of Object.entries(this.roots))if(this.sameRoot(e,r))return this.roots[e]=n;return this.roots[e]=new V8(e,this).root}sameRoot(e,r=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(gDe,"$1\\"),e===r}},tF=class t extends io{splitSep="/";sep="/";constructor(e,r=ll,n,i,s,a,o){super(e,r,n,i,s,a,o)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,r=ll,n={}){return new t(e,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}},rF=class{root;rootPath;roots;cwd;#e;#t;#n;nocase;#r;constructor(e=process.cwd(),r,n,{nocase:i,childrenCacheSize:s=16*1024,fs:a=CS}={}){this.#r=mDe(a),(e instanceof URL||e.startsWith("file://"))&&(e=dVt(e));let o=r.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(o),this.#e=new QN,this.#t=new QN,this.#n=new Nre(s);let c=o.substring(this.rootPath.length).split(n);if(c.length===1&&!c[0]&&c.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let u=this.root,f=c.length-1,d=r.sep,p=this.rootPath,h=!1;for(let m of c){let g=f--;u=u.child(m,{relative:new Array(g).fill("..").join(d),relativePosix:new Array(g).fill("..").join("/"),fullpath:p+=(h?"":d)+m}),h=!0}this.cwd=u}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#n}resolve(...e){let r="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(r=r?`${a}/${r}`:a,this.isAbsolute(a)))break}let n=this.#e.get(r);if(n!==void 0)return n;let i=this.cwd.resolve(r).fullpath();return this.#e.set(r,i),i}resolvePosix(...e){let r="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(r=r?`${a}/${r}`:a,this.isAbsolute(a)))break}let n=this.#t.get(r);if(n!==void 0)return n;let i=this.cwd.resolve(r).fullpathPosix();return this.#t.set(r,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,r={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n}=r;if(e.canReaddir()){let i=await e.readdir();return n?i:i.map(s=>s.name)}else return[]}readdirSync(e=this.cwd,r={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0}=r;return e.canReaddir()?n?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e.withFileTypes,e=this.cwd);let n=await e.readlink();return r?n:n?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e.withFileTypes,e=this.cwd);let n=e.readlinkSync();return r?n:n?.fullpath()}async realpath(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e.withFileTypes,e=this.cwd);let n=await e.realpath();return r?n:n?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e.withFileTypes,e=this.cwd);let n=e.realpathSync();return r?n:n?.fullpath()}async walk(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:a}=r,o=[];(!s||s(e))&&o.push(n?e:e.fullpath());let c=new Set,u=(d,p)=>{c.add(d),d.readdirCB((h,m)=>{if(h)return p(h);let g=m.length;if(!g)return p();let v=()=>{--g===0&&p()};for(let y of m)(!s||s(y))&&o.push(n?y:y.fullpath()),i&&y.isSymbolicLink()?y.realpath().then(b=>b?.isUnknown()?b.lstat():b).then(b=>b?.shouldWalk(c,a)?u(b,v):v()):y.shouldWalk(c,a)?u(y,v):v()},!0)},f=e;return new Promise((d,p)=>{u(f,h=>{if(h)return p(h);d(o)})})}walkSync(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:a}=r,o=[];(!s||s(e))&&o.push(n?e:e.fullpath());let c=new Set([e]);for(let u of c){let f=u.readdirSync();for(let d of f){(!s||s(d))&&o.push(n?d:d.fullpath());let p=d;if(d.isSymbolicLink()){if(!(i&&(p=d.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(c,a)&&c.add(p)}}return o}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,r={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd),this.stream(e,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:a}=r;(!s||s(e))&&(yield n?e:e.fullpath());let o=new Set([e]);for(let c of o){let u=c.readdirSync();for(let f of u){(!s||s(f))&&(yield n?f:f.fullpath());let d=f;if(f.isSymbolicLink()){if(!(i&&(d=f.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(o,a)&&o.add(d)}}}stream(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:a}=r,o=new _0({objectMode:!0});(!s||s(e))&&o.write(n?e:e.fullpath());let c=new Set,u=[e],f=0,d=()=>{let p=!1;for(;!p;){let h=u.shift();if(!h){f===0&&o.end();return}f++,c.add(h);let m=(v,y,b=!1)=>{if(v)return o.emit("error",v);if(i&&!b){let x=[];for(let k of y)k.isSymbolicLink()&&x.push(k.realpath().then(A=>A?.isUnknown()?A.lstat():A));if(x.length){Promise.all(x).then(()=>m(null,y,!0));return}}for(let x of y)x&&(!s||s(x))&&(o.write(n?x:x.fullpath())||(p=!0));f--;for(let x of y){let k=x.realpathCached()||x;k.shouldWalk(c,a)&&u.push(k)}p&&!o.flowing?o.once("drain",d):g||d()},g=!0;h.readdirCB(m,!0),g=!1}};return d(),o}streamSync(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:a}=r,o=new _0({objectMode:!0}),c=new Set;(!s||s(e))&&o.write(n?e:e.fullpath());let u=[e],f=0,d=()=>{let p=!1;for(;!p;){let h=u.shift();if(!h){f===0&&o.end();return}f++,c.add(h);let m=h.readdirSync();for(let g of m)(!s||s(g))&&(o.write(n?g:g.fullpath())||(p=!0));f--;for(let g of m){let v=g;if(g.isSymbolicLink()){if(!(i&&(v=g.realpathSync())))continue;v.isUnknown()&&v.lstatSync()}v.shouldWalk(c,a)&&u.push(v)}}p&&!o.flowing&&o.once("drain",d)};return d(),o}chdir(e=this.cwd){let r=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[wDe](r)}},V8=class extends rF{sep="\\";constructor(e=process.cwd(),r={}){let{nocase:n=!0}=r;super(e,jre,"\\",{...r,nocase:n}),this.nocase=n;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return jre.parse(e).root.toUpperCase()}newRoot(e){return new eF(this.rootPath,Od,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},G8=class extends rF{sep="/";constructor(e=process.cwd(),r={}){let{nocase:n=!1}=r;super(e,fVt,"/",{...r,nocase:n}),this.nocase=n}parseRootPath(e){return"/"}newRoot(e){return new tF(this.rootPath,Od,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},OS=class extends G8{constructor(e=process.cwd(),r={}){let{nocase:n=!0}=r;super(e,{...r,nocase:n})}},mfn=process.platform==="win32"?eF:tF,SDe=process.platform==="win32"?V8:process.platform==="darwin"?OS:G8;var CVt=t=>t.length>=1,TVt=t=>t.length>=1,Z8=class t{#e;#t;#n;length;#r;#a;#h;#l;#c;#i;#f=!0;constructor(e,r,n,i){if(!CVt(e))throw new TypeError("empty pattern list");if(!TVt(r))throw new TypeError("empty glob list");if(r.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,n<0||n>=this.length)throw new TypeError("index out of range");if(this.#e=e,this.#t=r,this.#n=n,this.#r=i,this.#n===0){if(this.isUNC()){let[s,a,o,c,...u]=this.#e,[f,d,p,h,...m]=this.#t;u[0]===""&&(u.shift(),m.shift());let g=[s,a,o,c,""].join("/"),v=[f,d,p,h,""].join("/");this.#e=[g,...u],this.#t=[v,...m],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[s,...a]=this.#e,[o,...c]=this.#t;a[0]===""&&(a.shift(),c.shift());let u=s+"/",f=o+"/";this.#e=[u,...a],this.#t=[f,...c],this.length=this.#e.length}}}pattern(){return this.#e[this.#n]}isString(){return typeof this.#e[this.#n]=="string"}isGlobstar(){return this.#e[this.#n]===ms}isRegExp(){return this.#e[this.#n]instanceof RegExp}globString(){return this.#h=this.#h||(this.#n===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join("/"):this.#t.join("/"):this.#t.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#a!==void 0?this.#a:this.hasMore()?(this.#a=new t(this.#e,this.#t,this.#n+1,this.#r),this.#a.#i=this.#i,this.#a.#c=this.#c,this.#a.#l=this.#l,this.#a):this.#a=null}isUNC(){let e=this.#e;return this.#c!==void 0?this.#c:this.#c=this.#r==="win32"&&this.#n===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#e;return this.#l!==void 0?this.#l:this.#l=this.#r==="win32"&&this.#n===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#e;return this.#i!==void 0?this.#i:this.#i=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#e[0];return typeof e=="string"&&this.isAbsolute()&&this.#n===0?e:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#f)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#f?!1:(this.#f=!1,!0)}};var PVt=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",K8=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:r,nocase:n,noext:i,noglobstar:s,platform:a=PVt}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=a,this.mmopts={dot:!0,nobrace:r,nocase:n,noext:i,noglobstar:s,optimizationLevel:2,platform:a,nocomment:!0,nonegate:!0};for(let o of e)this.add(o)}add(e){let r=new du(e,this.mmopts);for(let n=0;n<r.set.length;n++){let i=r.set[n],s=r.globParts[n];if(!i||!s)throw new Error("invalid pattern object");for(;i[0]==="."&&s[0]===".";)i.shift(),s.shift();let a=new Z8(i,s,0,this.platform),o=new du(a.globString(),this.mmopts),c=s[s.length-1]==="**",u=a.isAbsolute();u?this.absolute.push(o):this.relative.push(o),c&&(u?this.absoluteChildren.push(o):this.relativeChildren.push(o))}}ignored(e){let r=e.fullpath(),n=`${r}/`,i=e.relative()||".",s=`${i}/`;for(let a of this.relative)if(a.match(i)||a.match(s))return!0;for(let a of this.absolute)if(a.match(r)||a.match(n))return!0;return!1}childrenIgnored(e){let r=e.fullpath()+"/",n=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(n))return!0;for(let i of this.absoluteChildren)if(i.match(r))return!0;return!1}};var Fre=class t{store;constructor(e=new Map){this.store=e}copy(){return new t(new Map(this.store))}hasWalked(e,r){return this.store.get(e.fullpath())?.has(r.globString())}storeWalked(e,r){let n=e.fullpath(),i=this.store.get(n);i?i.add(r.globString()):this.store.set(n,new Set([r.globString()]))}},Mre=class{store=new Map;add(e,r,n){let i=(r?2:0)|(n?1:0),s=this.store.get(e);this.store.set(e,s===void 0?i:i&s)}entries(){return[...this.store.entries()].map(([e,r])=>[e,!!(r&2),!!(r&1)])}},Lre=class{store=new Map;add(e,r){if(!e.canReaddir())return;let n=this.store.get(e);n?n.find(i=>i.globString()===r.globString())||n.push(r):this.store.set(e,[r])}get(e){let r=this.store.get(e);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},IS=class t{hasWalkedCache;matches=new Mre;subwalks=new Lre;patterns;follow;dot;opts;constructor(e,r){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=r?r.copy():new Fre}processPatterns(e,r){this.patterns=r;let n=r.map(i=>[e,i]);for(let[i,s]of n){this.hasWalkedCache.storeWalked(i,s);let a=s.root(),o=s.isAbsolute()&&this.opts.absolute!==!1;if(a){i=i.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let d=s.rest();if(d)s=d;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let c,u,f=!1;for(;typeof(c=s.pattern())=="string"&&(u=s.rest());)i=i.resolve(c),s=u,f=!0;if(c=s.pattern(),u=s.rest(),f){if(this.hasWalkedCache.hasWalked(i,s))continue;this.hasWalkedCache.storeWalked(i,s)}if(typeof c=="string"){let d=c===".."||c===""||c===".";this.matches.add(i.resolve(c),o,d);continue}else if(c===ms){(!i.isSymbolicLink()||this.follow||s.checkFollowGlobstar())&&this.subwalks.add(i,s);let d=u?.pattern(),p=u?.rest();if(!u||(d===""||d===".")&&!p)this.matches.add(i,o,d===""||d===".");else if(d===".."){let h=i.parent||i;p?this.hasWalkedCache.hasWalked(h,p)||this.subwalks.add(h,p):this.matches.add(h,o,!0)}}else c instanceof RegExp&&this.subwalks.add(i,s)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new t(this.opts,this.hasWalkedCache)}filterEntries(e,r){let n=this.subwalks.get(e),i=this.child();for(let s of r)for(let a of n){let o=a.isAbsolute(),c=a.pattern(),u=a.rest();c===ms?i.testGlobstar(s,a,u,o):c instanceof RegExp?i.testRegExp(s,c,u,o):i.testString(s,c,u,o)}return i}testGlobstar(e,r,n,i){if((this.dot||!e.name.startsWith("."))&&(r.hasMore()||this.matches.add(e,i,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,r):e.isSymbolicLink()&&(n&&r.checkFollowGlobstar()?this.subwalks.add(e,n):r.markFollowGlobstar()&&this.subwalks.add(e,r)))),n){let s=n.pattern();if(typeof s=="string"&&s!==".."&&s!==""&&s!==".")this.testString(e,s,n.rest(),i);else if(s===".."){let a=e.parent||e;this.subwalks.add(a,n)}else s instanceof RegExp&&this.testRegExp(e,s,n.rest(),i)}}testRegExp(e,r,n,i){r.test(e.name)&&(n?this.subwalks.add(e,n):this.matches.add(e,i,!1))}testString(e,r,n,i){e.isNamed(r)&&(n?this.subwalks.add(e,n):this.matches.add(e,i,!1))}};var OVt=(t,e)=>typeof t=="string"?new K8([t],e):Array.isArray(t)?new K8(t,e):t,nF=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#t;#n;signal;maxDepth;includeChildMatches;constructor(e,r,n){if(this.patterns=e,this.path=r,this.opts=n,this.#n=!n.posix&&n.platform==="win32"?"\\":"/",this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#t=OVt(n.ignore??[],n),!this.includeChildMatches&&typeof this.#t.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#r(e){return this.seen.has(e)||!!this.#t?.ignored?.(e)}#a(e){return!!this.#t?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||await e.realpath(),!n)return;e=n}let s=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=await s.realpath();a&&(a.isUnknown()||this.opts.stat)&&await a.lstat()}return this.matchCheckTest(s,r)}matchCheckTest(e,r){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!r||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#r(e)?e:void 0}matchCheckSync(e,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||e.realpathSync(),!n)return;e=n}let s=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=s.realpathSync();a&&(a?.isUnknown()||this.opts.stat)&&a.lstatSync()}return this.matchCheckTest(s,r)}matchFinish(e,r){if(this.#r(e))return;if(!this.includeChildMatches&&this.#t?.add){let s=`${e.relativePosix()}/**`;this.#t.add(s)}let n=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(n){let s=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(s+i)}else{let s=this.opts.posix?e.relativePosix():e.relative(),a=this.opts.dotRelative&&!s.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(s?a+s+i:"."+i)}}async match(e,r,n){let i=await this.matchCheck(e,n);i&&this.matchFinish(i,r)}matchSync(e,r,n){let i=this.matchCheckSync(e,n);i&&this.matchFinish(i,r)}walkCB(e,r,n){this.signal?.aborted&&n(),this.walkCB2(e,r,new IS(this.opts),n)}walkCB2(e,r,n,i){if(this.#a(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,r,n,i));return}n.processPatterns(e,r);let s=1,a=()=>{--s===0&&i()};for(let[o,c,u]of n.matches.entries())this.#r(o)||(s++,this.match(o,c,u).then(()=>a()));for(let o of n.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;s++;let c=o.readdirCached();o.calledReaddir()?this.walkCB3(o,c,n,a):o.readdirCB((u,f)=>this.walkCB3(o,f,n,a),!0)}a()}walkCB3(e,r,n,i){n=n.filterEntries(e,r);let s=1,a=()=>{--s===0&&i()};for(let[o,c,u]of n.matches.entries())this.#r(o)||(s++,this.match(o,c,u).then(()=>a()));for(let[o,c]of n.subwalks.entries())s++,this.walkCB2(o,c,n.child(),a);a()}walkCBSync(e,r,n){this.signal?.aborted&&n(),this.walkCB2Sync(e,r,new IS(this.opts),n)}walkCB2Sync(e,r,n,i){if(this.#a(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,r,n,i));return}n.processPatterns(e,r);let s=1,a=()=>{--s===0&&i()};for(let[o,c,u]of n.matches.entries())this.#r(o)||this.matchSync(o,c,u);for(let o of n.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;s++;let c=o.readdirSync();this.walkCB3Sync(o,c,n,a)}a()}walkCB3Sync(e,r,n,i){n=n.filterEntries(e,r);let s=1,a=()=>{--s===0&&i()};for(let[o,c,u]of n.matches.entries())this.#r(o)||this.matchSync(o,c,u);for(let[o,c]of n.subwalks.entries())s++,this.walkCB2Sync(o,c,n.child(),a);a()}},DS=class extends nF{matches=new Set;constructor(e,r,n){super(e,r,n)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},RS=class extends nF{results;constructor(e,r,n){super(e,r,n),this.results=new _0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var DVt=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",ff=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=IVt(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(c=>c.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=e,this.platform=r.platform||DVt,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let c=r.platform==="win32"?V8:r.platform==="darwin"?OS:r.platform?G8:SDe;this.scurry=new c(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let n=this.platform==="darwin"||this.platform==="win32",i={...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},s=this.pattern.map(c=>new du(c,i)),[a,o]=s.reduce((c,u)=>(c[0].push(...u.set),c[1].push(...u.globParts),c),[[],[]]);this.patterns=a.map((c,u)=>{let f=o[u];if(!f)throw new Error("invalid pattern object");return new Z8(c,f,0,this.platform)})}async walk(){return[...await new DS(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new DS(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new RS(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new RS(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var qre=(t,e={})=>{Array.isArray(t)||(t=[t]);for(let r of t)if(new du(r,e).hasMagic())return!0;return!1};function sF(t,e={}){return new ff(t,e).streamSync()}function kDe(t,e={}){return new ff(t,e).stream()}function ADe(t,e={}){return new ff(t,e).walkSync()}async function EDe(t,e={}){return new ff(t,e).walk()}function aF(t,e={}){return new ff(t,e).iterateSync()}function CDe(t,e={}){return new ff(t,e).iterate()}var RVt=sF,$Vt=Object.assign(kDe,{sync:sF}),jVt=aF,NVt=Object.assign(CDe,{sync:aF}),FVt=Object.assign(ADe,{stream:sF,iterate:aF}),iF=Object.assign(EDe,{glob:EDe,globSync:ADe,sync:FVt,globStream:kDe,stream:$Vt,globStreamSync:sF,streamSync:RVt,globIterate:CDe,iterate:NVt,globIterateSync:aF,iterateSync:jVt,Glob:ff,hasMagic:qre,escape:z8,unescape:cf});iF.glob=iF;var MVt=5e3,w0=async({text:t,path:e,root:r,timeout:n,limit:i})=>{let s=e?.startsWith("/")?e.substring(1):e,a=`${e?s+"/":""}**/*${t}*`,o=await iF(a,{cwd:r,absolute:!1,dotRelative:!1,follow:!1,signal:AbortSignal.timeout(n||MVt),ignore:["**/node_modules/**","**/build/**"]});return!i||o.length<i?o:[`Search returned too many results (${o.length}), try again with a more restrictive search.`]};import{execSync as LVt}from"child_process";import{rgPath as qVt}from"@vscode/ripgrep";var BVt=50*1024*1024;function TDe(t,e,r=1e4,n=2e5){try{e.displayText("Mapping project files...");let s=LVt(`"${qVt}" --files`,{cwd:t,encoding:"utf-8",timeout:r,maxBuffer:BVt}).split(`
905
+ ${f}`,...c&&{cache_control:{type:"ephemeral"}}}]}}else a instanceof Cn&&(o={role:"user",content:[{type:"text",text:a.answer,...c&&{cache_control:{type:"ephemeral"}}}]});return o}).filter(a=>!!a)}getOrUpdateCacheMarker(r,n,i){let s=n.length;if(s<GHt)return this.interactor.debug(`\u{1F4CB} Cache: Conversation too short (${s} messages), no marker`),null;r.data.anthropic||(r.data.anthropic={});let a=r.data.anthropic.cacheMarkerMessageId;if(a&&!i){let f=n.findIndex(d=>d.timestamp===a);if(f!==-1){let d=f/s,p=Math.round(d*100),h=Math.round(jIe*100),m=Math.round(bre*100);if(d>=jIe&&d<=bre)return this.interactor.debug(`\u2705 Cache: Keeping marker at message ${f+1}/${s} (${p}%)`),a;this.interactor.debug(`\u{1F504} Cache: Marker at ${p}% is out of range (${h}-${m}%), repositioning...`)}else this.interactor.debug("\u26A0\uFE0F Cache: Marker message not found, creating new marker")}else this.interactor.debug("\u{1F195} Cache: No existing marker, creating first marker");let o=Math.floor(s*bre),c=n[o]?.timestamp,u=Math.round(o/s*100);return c?(r.data.anthropic.cacheMarkerMessageId=c,this.interactor.debug(`\u{1F4CD} Cache: Placed marker at message ${o+1}/${s} (${u}%) - ID: ${c}`),c):(this.interactor.debug(`\u274C Cache: Failed to place marker at position ${o}`),null)}getClaudeTools(r){let n=r.getTools().map(i=>({name:i.function.name,description:i.function.description,input_schema:i.function.parameters}));return n.length>0&&(n[n.length-1].cache_control={type:"ephemeral"}),n}async streamApiCall(r,n,i,s,a,o,c=!1){let u=new Set(i.tools.getTools().map(m=>m.function.name)),f=await this.getMessages(s,a,n.name,i.name,u),d=this.toClaudeMessage(f.messages,s,c),p=r.messages.stream({model:n.name,messages:d,system:[{text:i.systemInstructions,type:"text",cache_control:{type:"ephemeral"}}],tools:this.getClaudeTools(i.tools),...(i.definition.temperature??n.temperature)!==void 0&&{temperature:i.definition.temperature??n.temperature},max_tokens:i.definition.maxOutputTokens??n.maxOutputTokens??8192});return p.on("text",m=>{if(!this.shouldProceed(s)){p.abort();return}o.next(new t0({chunk:m,threadId:s.id}))}),{data:await p.finalMessage(),response:void 0}}getHeader=(r,n)=>r?r instanceof Headers?r.get(n):r[n]||null:null;updateRateLimitsFromHeaders(r){if(!r){this.rateLimitInfo=null;return}let n=this.getHeader(r,"anthropic-ratelimit-input-tokens-remaining"),i=this.getHeader(r,"anthropic-ratelimit-output-tokens-remaining"),s=this.getHeader(r,"anthropic-ratelimit-requests-remaining"),a=this.getHeader(r,"anthropic-ratelimit-input-tokens-limit"),o=this.getHeader(r,"anthropic-ratelimit-output-tokens-limit"),c=this.getHeader(r,"anthropic-ratelimit-requests-limit");n&&!isNaN(parseInt(n))||i&&!isNaN(parseInt(i))||s&&!isNaN(parseInt(s))?this.rateLimitInfo={inputTokensRemaining:n?parseInt(n):999999,outputTokensRemaining:i?parseInt(i):999999,requestsRemaining:s?parseInt(s):999999,inputTokensLimit:a?parseInt(a):2e5,outputTokensLimit:o?parseInt(o):8e4,requestsLimit:c?parseInt(c):4e3}:this.rateLimitInfo=null}async applyThrottlingDelay(){if(!this.rateLimitInfo)return;let r=this.rateLimitInfo.inputTokensRemaining/Math.max(this.rateLimitInfo.inputTokensLimit,1),n=this.rateLimitInfo.outputTokensRemaining/Math.max(this.rateLimitInfo.outputTokensLimit,1),i=this.rateLimitInfo.requestsRemaining/Math.max(this.rateLimitInfo.requestsLimit,1);this.interactor.debug(`Rate limit ratios: ${JSON.stringify({inputTokensRatio:r,outputTokensRatio:n,requestsRatio:i,rateLimitInfo:this.rateLimitInfo})}`);let s=Math.min(r,n,i);if(s<yre){let a=(yre-s)/yre,o=Math.max(1,Math.round(a*WHt));this.interactor.displayText(`\u23F3 Rate limit approaching (${Math.round(s*100)}% remaining), waiting ${o} seconds...`);try{await this.delay(o*1e3,"throttling")}catch{throw new Error("Throttling delay interrupted by shutdown")}}}displayRateLimitStatus(r){let n=parseInt(r["anthropic-ratelimit-input-tokens-remaining"]??"0"),i=parseInt(r["anthropic-ratelimit-output-tokens-remaining"]??"0"),s=parseInt(r["anthropic-ratelimit-requests-remaining"]??"0"),a="unknown";n===0?a="input tokens":i===0?a="output tokens":s===0&&(a="requests"),this.interactor.debug(`\u{1F6A8} Rate limit exceeded: ${a} limit reached`)}handleError(r,n,i){super.handleError(r,n,i)}async complete(r,n){let i=this.isAnthropicReady();if(!i)throw new Error("Anthropic client not ready");let s=n?.model??this.models.find(c=>c.alias==="SMALL")?.name??"claude-3-5-haiku-latest",a=n?.maxTokens??100,o=a>VHt;try{let c;return o?c=await i.messages.stream({model:s,messages:[{role:"user",content:r}],max_tokens:a,...n?.temperature!==void 0&&{temperature:n.temperature},stop_sequences:n?.stopSequences}).finalMessage():c=await i.messages.create({model:s,messages:[{role:"user",content:r}],max_tokens:a,...n?.temperature!==void 0&&{temperature:n.temperature},stop_sequences:n?.stopSequences}),c.content.filter(u=>u.type==="text").map(u=>u.text.trim()).join(" ")}catch(c){let u=o?"streaming":"non-streaming";throw console.error(`Anthropic completion error (${u}):`,c),new Error(`Anthropic completion failed (${u}): ${c.message}`)}}};var qN=class extends mt{constructor(r){super({commandWord:"debug",description:"allows to set the debug logs (ex: `debug true` or `debug false`). False by default.",isInternal:!0});this.interactor=r}async handle(r,n){let i=this.getSubCommand(r);return i==="true"&&(this.interactor.debugLevelEnabled=!0,this.interactor.displayText("Set debug at true")),i==="false"&&(this.interactor.debugLevelEnabled=!1,this.interactor.displayText("Set debug at false")),n}};var xre=(t,e,r)=>{let n=t instanceof RegExp?NIe(t,r):t,i=e instanceof RegExp?NIe(e,r):e,s=n!==null&&i!=null&&ZHt(n,i,r);return s&&{start:s[0],end:s[1],pre:r.slice(0,s[0]),body:r.slice(s[0]+n.length,s[1]),post:r.slice(s[1]+i.length)}},NIe=(t,e)=>{let r=e.match(t);return r?r[0]:null},ZHt=(t,e,r)=>{let n,i,s,a,o,c=r.indexOf(t),u=r.indexOf(e,c+1),f=c;if(c>=0&&u>0){if(t===e)return[c,u];for(n=[],s=r.length;f>=0&&!o;){if(f===c)n.push(f),c=r.indexOf(t,f+1);else if(n.length===1){let d=n.pop();d!==void 0&&(o=[d,u])}else i=n.pop(),i!==void 0&&i<s&&(s=i,a=u),u=r.indexOf(e,f+1);f=c<u&&c>=0?c:u}n.length&&a!==void 0&&(o=[s,a])}return o};var FIe="\0SLASH"+Math.random()+"\0",MIe="\0OPEN"+Math.random()+"\0",wre="\0CLOSE"+Math.random()+"\0",LIe="\0COMMA"+Math.random()+"\0",qIe="\0PERIOD"+Math.random()+"\0",KHt=new RegExp(FIe,"g"),JHt=new RegExp(MIe,"g"),XHt=new RegExp(wre,"g"),YHt=new RegExp(LIe,"g"),QHt=new RegExp(qIe,"g"),eWt=/\\\\/g,tWt=/\\{/g,rWt=/\\}/g,nWt=/\\,/g,iWt=/\\\./g,sWt=1e5;function _re(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function aWt(t){return t.replace(eWt,FIe).replace(tWt,MIe).replace(rWt,wre).replace(nWt,LIe).replace(iWt,qIe)}function oWt(t){return t.replace(KHt,"\\").replace(JHt,"{").replace(XHt,"}").replace(YHt,",").replace(QHt,".")}function BIe(t){if(!t)return[""];let e=[],r=xre("{","}",t);if(!r)return t.split(",");let{pre:n,body:i,post:s}=r,a=n.split(",");a[a.length-1]+="{"+i+"}";let o=BIe(s);return s.length&&(a[a.length-1]+=o.shift(),a.push.apply(a,o)),e.push.apply(e,a),e}function UIe(t,e={}){if(!t)return[];let{max:r=sWt}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),vS(aWt(t),r,!0).map(oWt)}function cWt(t){return"{"+t+"}"}function uWt(t){return/^-?0\d/.test(t)}function lWt(t,e){return t<=e}function fWt(t,e){return t>=e}function vS(t,e,r){let n=[],i=xre("{","}",t);if(!i)return[t];let s=i.pre,a=i.post.length?vS(i.post,e,!1):[""];if(/\$$/.test(i.pre))for(let o=0;o<a.length&&o<e;o++){let c=s+"{"+i.body+"}"+a[o];n.push(c)}else{let o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),u=o||c,f=i.body.indexOf(",")>=0;if(!u&&!f)return i.post.match(/,(?!,).*\}/)?(t=i.pre+"{"+i.body+wre+i.post,vS(t,e,!0)):[t];let d;if(u)d=i.body.split(/\.\./);else if(d=BIe(i.body),d.length===1&&d[0]!==void 0&&(d=vS(d[0],e,!1).map(cWt),d.length===1))return a.map(h=>i.pre+d[0]+h);let p;if(u&&d[0]!==void 0&&d[1]!==void 0){let h=_re(d[0]),m=_re(d[1]),g=Math.max(d[0].length,d[1].length),v=d.length===3&&d[2]!==void 0?Math.max(Math.abs(_re(d[2])),1):1,y=lWt;m<h&&(v*=-1,y=fWt);let x=d.some(uWt);p=[];for(let k=h;y(k,m);k+=v){let A;if(c)A=String.fromCharCode(k),A==="\\"&&(A="");else if(A=String(k),x){let P=g-A.length;if(P>0){let R=new Array(P+1).join("0");k<0?A="-"+R+A.slice(1):A=R+A}}p.push(A)}}else{p=[];for(let h=0;h<d.length;h++)p.push.apply(p,vS(d[h],e,!1))}for(let h=0;h<p.length;h++)for(let m=0;m<a.length&&n.length<e;m++){let g=s+p[h]+a[m];(!r||u||g)&&n.push(g)}}return n}var yS=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var dWt={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},bS=t=>t.replace(/[[\]\\-]/g,"\\$&"),pWt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),zIe=t=>t.join(""),HIe=(t,e)=>{let r=e;if(t.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,a=!1,o=!1,c=!1,u=!1,f=r,d="";e:for(;s<t.length;){let g=t.charAt(s);if((g==="!"||g==="^")&&s===r+1){u=!0,s++;continue}if(g==="]"&&a&&!c){f=s+1;break}if(a=!0,g==="\\"&&!c){c=!0,s++;continue}if(g==="["&&!c){for(let[v,[y,b,x]]of Object.entries(dWt))if(t.startsWith(v,s)){if(d)return["$.",!1,t.length-r,!0];s+=v.length,x?i.push(y):n.push(y),o=o||b;continue e}}if(c=!1,d){g>d?n.push(bS(d)+"-"+bS(g)):g===d&&n.push(bS(g)),d="",s++;continue}if(t.startsWith("-]",s+1)){n.push(bS(g+"-")),s+=2;continue}if(t.startsWith("-",s+1)){d=g,s+=2;continue}n.push(bS(g)),s++}if(f<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,t.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let g=n[0].length===2?n[0].slice(-1):n[0];return[pWt(g),!1,f-r,!1]}let p="["+(u?"^":"")+zIe(n)+"]",h="["+(u?"":"^")+zIe(i)+"]";return[n.length&&i.length?"("+p+"|"+h+")":n.length?p:h,o,f-r,!0]};var cf=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!0}={})=>r?e?t.replace(/\[([^/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):e?t.replace(/\[([^/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var bc,hWt=new Set(["!","?","+","*","@"]),Sre=t=>hWt.has(t),WIe=t=>Sre(t.type),mWt=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),gWt=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),vWt=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),VIe=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),yWt="(?!(?:^|/)\\.\\.?(?:$|/))",BN="(?!\\.)",bWt=new Set(["[","."]),xWt=new Set(["..","."]),_Wt=new Set("().*{}+?[]^$\\!"),wWt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ere="[^/]",GIe=Ere+"*?",ZIe=Ere+"+?",SWt=0,j1=class{type;#e;#t;#n=!1;#r=[];#a;#h;#l;#c=!1;#i;#f;#d=!1;id=++SWt;get depth(){return(this.#a?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#a?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,r,n={}){this.type=e,e&&(this.#t=!0),this.#a=r,this.#e=this.#a?this.#a.#e:this,this.#i=this.#e===this?n:this.#e.#i,this.#l=this.#e===this?[]:this.#e.#l,e==="!"&&!this.#e.#c&&this.#l.push(this),this.#h=this.#a?this.#a.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#f!==void 0?this.#f:this.type?this.#f=this.type+"("+this.#r.map(e=>String(e)).join("|")+")":this.#f=this.#r.map(e=>String(e)).join("")}#u(){if(this!==this.#e)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let e;for(;e=this.#l.pop();){if(e.type!=="!")continue;let r=e,n=r.#a;for(;n;){for(let i=r.#h+1;!n.type&&i<n.#r.length;i++)for(let s of e.#r){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#r[i])}r=n,n=r.#a}}return this}push(...e){for(let r of e)if(r!==""){if(typeof r!="string"&&!(r instanceof bc&&r.#a===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let e=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#c&&this.#a?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#a?.isStart())return!1;if(this.#h===0)return!0;let e=this.#a;for(let r=0;r<this.#h;r++){let n=e.#r[r];if(!(n instanceof bc&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#a?.type==="!")return!0;if(!this.#a?.isEnd())return!1;if(!this.type)return this.#a?.isEnd();let e=this.#a?this.#a.#r.length:0;return this.#h===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let r=new bc(this.type,e);for(let n of this.#r)r.copyIn(n);return r}static#o(e,r,n,i,s){let a=i.maxExtglobRecursion??2,o=!1,c=!1,u=-1,f=!1;if(r.type===null){let g=n,v="";for(;g<e.length;){let y=e.charAt(g++);if(o||y==="\\"){o=!o,v+=y;continue}if(c){g===u+1?(y==="^"||y==="!")&&(f=!0):y==="]"&&!(g===u+2&&f)&&(c=!1),v+=y;continue}else if(y==="["){c=!0,u=g,f=!1,v+=y;continue}if(!i.noext&&Sre(y)&&e.charAt(g)==="("&&s<=a){r.push(v),v="";let x=new bc(y,r);g=bc.#o(e,x,g,i,s+1),r.push(x);continue}v+=y}return r.push(v),g}let d=n+1,p=new bc(null,r),h=[],m="";for(;d<e.length;){let g=e.charAt(d++);if(o||g==="\\"){o=!o,m+=g;continue}if(c){d===u+1?(g==="^"||g==="!")&&(f=!0):g==="]"&&!(d===u+2&&f)&&(c=!1),m+=g;continue}else if(g==="["){c=!0,u=d,f=!1,m+=g;continue}if(!i.noext&&Sre(g)&&e.charAt(d)==="("&&(s<=a||r&&r.#g(g))){let y=r&&r.#g(g)?0:1;p.push(m),m="";let b=new bc(g,p);p.push(b),d=bc.#o(e,b,d,i,s+y);continue}if(g==="|"){p.push(m),m="",h.push(p),p=new bc(null,r);continue}if(g===")")return m===""&&r.#r.length===0&&(r.#d=!0),p.push(m),m="",r.push(...h,p),d;m+=g}return r.type=null,r.#t=void 0,r.#r=[e.substring(n-1)],d}#x(e){return this.#w(e,gWt)}#w(e,r=mWt){if(!e||typeof e!="object"||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#g(n.type,r)}#g(e,r=vWt){return!!r.get(this.type)?.includes(e)}#v(e,r){let n=e.#r[0],i=new bc(null,n,this.options);i.#r.push(""),n.push(i),this.#A(e,r)}#A(e,r){let n=e.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#a=this);this.#f=void 0}#y(e){return!!VIe.get(this.type)?.has(e)}#S(e){if(!e||typeof e!="object"||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=e.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type)}#E(e){let r=VIe.get(this.type),n=e.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let s of this.#r)typeof s=="object"&&(s.#a=this);this.type=i,this.#f=void 0,this.#d=!1}static fromGlob(e,r={}){let n=new bc(null,void 0,r);return bc.#o(e,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#t||this.#i.nocase&&!this.#i.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let o=(this.#i.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,o),{_src:r,_glob:e})}get options(){return this.#i}toRegExpSource(e){let r=e??!!this.#i.dot;if(this.#e===this&&(this.#m(),this.#u()),!WIe(this)){let c=this.isStart()&&this.isEnd()&&!this.#r.some(h=>typeof h!="string"),u=this.#r.map(h=>{let[m,g,v,y]=typeof h=="string"?bc.#_(h,this.#t,c):h.toRegExpSource(e);return this.#t=this.#t||v,this.#n=this.#n||y,m}).join(""),f="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&xWt.has(this.#r[0]))){let m=bWt,g=r&&m.has(u.charAt(0))||u.startsWith("\\.")&&m.has(u.charAt(2))||u.startsWith("\\.\\.")&&m.has(u.charAt(4)),v=!r&&!e&&m.has(u.charAt(0));f=g?yWt:v?BN:""}let d="";return this.isEnd()&&this.#e.#c&&this.#a?.type==="!"&&(d="(?:$|\\/)"),[f+u+d,cf(u),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#b(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#r=[c],u.type=null,u.#t=void 0,[c,cf(this.toString()),!1,!1]}let a=!n||e||r||!BN?"":this.#b(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let o="";if(this.type==="!"&&this.#d)o=(this.isStart()&&!r?BN:"")+ZIe;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!e?BN:"")+GIe+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;o=i+s+c}return[o,cf(s),this.#t=!!this.#t,this.#n]}#m(){if(WIe(this)){let e=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#m(),this.#w(i)?(r=!1,this.#A(i,n)):this.#x(i)?(r=!1,this.#v(i,n)):this.#S(i)&&(r=!1,this.#E(i)))}}while(!r&&++e<10)}else for(let e of this.#r)typeof e=="object"&&e.#m();this.#f=void 0}#b(e){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,a]=r.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#_(e,r,n=!1){let i=!1,s="",a=!1,o=!1;for(let c=0;c<e.length;c++){let u=e.charAt(c);if(i){i=!1,s+=(_Wt.has(u)?"\\":"")+u;continue}if(u==="*"){if(o)continue;o=!0,s+=n&&/^[*]+$/.test(e)?ZIe:GIe,r=!0;continue}else o=!1;if(u==="\\"){c===e.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[f,d,p,h]=HIe(e,c);if(p){s+=f,a=a||d,c+=p-1,r=r||h;continue}}if(u==="?"){s+=Ere,r=!0;continue}s+=wWt(u)}return[s,cf(e),!!r,a]}};bc=j1;var z8=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!1}={})=>r?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var Fo=(t,e,r={})=>(yS(e),!r.nocomment&&e.charAt(0)==="#"?!1:new du(e,r).match(t)),EWt=/^\*+([^+@!?*[(]*)$/,kWt=t=>e=>!e.startsWith(".")&&e.endsWith(t),AWt=t=>e=>e.endsWith(t),CWt=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),TWt=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),PWt=/^\*+\.\*+$/,OWt=t=>!t.startsWith(".")&&t.includes("."),IWt=t=>t!=="."&&t!==".."&&t.includes("."),DWt=/^\.\*+$/,RWt=t=>t!=="."&&t!==".."&&t.startsWith("."),$Wt=/^\*+$/,jWt=t=>t.length!==0&&!t.startsWith("."),NWt=t=>t.length!==0&&t!=="."&&t!=="..",FWt=/^\?+([^+@!?*[(]*)?$/,MWt=([t,e=""])=>{let r=XIe([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},LWt=([t,e=""])=>{let r=YIe([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},qWt=([t,e=""])=>{let r=YIe([t]);return e?n=>r(n)&&n.endsWith(e):r},BWt=([t,e=""])=>{let r=XIe([t]);return e?n=>r(n)&&n.endsWith(e):r},XIe=([t])=>{let e=t.length;return r=>r.length===e&&!r.startsWith(".")},YIe=([t])=>{let e=t.length;return r=>r.length===e&&r!=="."&&r!==".."},QIe=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",KIe={win32:{sep:"\\"},posix:{sep:"/"}},UWt=QIe==="win32"?KIe.win32.sep:KIe.posix.sep;Fo.sep=UWt;var ms=Symbol("globstar **");Fo.GLOBSTAR=ms;var zWt="[^/]",HWt=zWt+"*?",WWt="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",VWt="(?:(?!(?:\\/|^)\\.).)*?",GWt=(t,e={})=>r=>Fo(r,t,e);Fo.filter=GWt;var cl=(t,e={})=>Object.assign({},t,e),ZWt=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return Fo;let e=Fo;return Object.assign((n,i,s={})=>e(n,i,cl(t,s)),{Minimatch:class extends e.Minimatch{constructor(i,s={}){super(i,cl(t,s))}static defaults(i){return e.defaults(cl(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,s,a={}){super(i,s,cl(t,a))}static fromGlob(i,s={}){return e.AST.fromGlob(i,cl(t,s))}},unescape:(n,i={})=>e.unescape(n,cl(t,i)),escape:(n,i={})=>e.escape(n,cl(t,i)),filter:(n,i={})=>e.filter(n,cl(t,i)),defaults:n=>e.defaults(cl(t,n)),makeRe:(n,i={})=>e.makeRe(n,cl(t,i)),braceExpand:(n,i={})=>e.braceExpand(n,cl(t,i)),match:(n,i,s={})=>e.match(n,i,cl(t,s)),sep:e.sep,GLOBSTAR:ms})};Fo.defaults=ZWt;var eDe=(t,e={})=>(yS(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:UIe(t,{max:e.braceExpandMax}));Fo.braceExpand=eDe;var KWt=(t,e={})=>new du(t,e).makeRe();Fo.makeRe=KWt;var JWt=(t,e,r={})=>{let n=new du(e,r);return t=t.filter(i=>n.match(i)),n.options.nonull&&!t.length&&t.push(e),t};Fo.match=JWt;var JIe=/[?*]|[+@!]\(.*?\)|\[|\]/,XWt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),du=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,r={}){yS(e),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=e,this.platform=r.platform||QIe,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let r of e)if(typeof r!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,r=this.options;if(!r.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,a,o)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!JIe.test(s[2]))&&!JIe.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(f=>this.parse(f))];if(u)return[s[0],...s.slice(1).map(f=>this.parse(f))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let a=this.set[s];a[0]===""&&a[1]===""&&this.globParts[s][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let n of e)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):r>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(e){return e.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let s=e[i];i===1&&s===""&&e[0]===""||(s==="."||s==="")&&(r=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(r=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,e.splice(n-1,2),n-=2)}}while(r);return e.length===0?[""]:e}firstPhasePreProcess(e){let r=!1;do{r=!1;for(let n of e){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let a=i;for(;n[a+1]==="**";)a++;a>i&&n.splice(i+1,a-i);let o=n[i+1],c=n[i+2],u=n[i+3];if(o!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(i,1);let f=n.slice(0);f[i]="**",e.push(f),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<n.length-1;a++){let o=n[a];a===1&&o===""&&n[0]===""||(o==="."||o==="")&&(r=!0,n.splice(a,1),a--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let a=n[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){r=!0;let c=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...c),n.length===0&&n.push(""),s-=2}}}}while(r);return e}secondPhasePreProcess(e){for(let r=0;r<e.length-1;r++)for(let n=r+1;n<e.length;n++){let i=this.partsMatch(e[r],e[n],!this.preserveMultipleSlashes);if(i){e[r]=[],e[n]=i;break}}return e.filter(r=>r.length)}partsMatch(e,r,n=!1){let i=0,s=0,a=[],o="";for(;i<e.length&&s<r.length;)if(e[i]===r[s])a.push(o==="b"?r[s]:e[i]),i++,s++;else if(n&&e[i]==="**"&&r[s]===e[i+1])a.push(e[i]),i++;else if(n&&r[s]==="**"&&e[i]===r[s+1])a.push(r[s]),s++;else if(e[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(o==="b")return!1;o="a",a.push(e[i]),i++,s++}else if(r[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(o==="a")return!1;o="b",a.push(r[s]),i++,s++}else return!1;return e.length===r.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,r=!1,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=e.slice(n)),this.negate=r}matchOne(e,r,n=!1){let i=0,s=0;if(this.isWindows){let o=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),c=!o&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),u=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),f=!u&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=c?3:o?0:void 0,p=f?3:u?0:void 0;if(typeof d=="number"&&typeof p=="number"){let[h,m]=[e[d],r[p]];h.toLowerCase()===m.toLowerCase()&&(r[p]=h,s=p,i=d)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),r.includes(ms)?this.#e(e,r,n,i,s):this.#n(e,r,n,i,s)}#e(e,r,n,i,s){let a=r.indexOf(ms,s),o=r.lastIndexOf(ms),[c,u,f]=n?[r.slice(s,a),r.slice(a+1),[]]:[r.slice(s,a),r.slice(a+1,o),r.slice(o+1)];if(c.length){let b=e.slice(i,i+c.length);if(!this.#n(b,c,n,0,0))return!1;i+=c.length,s+=c.length}let d=0;if(f.length){if(f.length+i>e.length)return!1;let b=e.length-f.length;if(this.#n(e,f,n,b,0))d=f.length;else{if(e[e.length-1]!==""||i+f.length===e.length||(b--,!this.#n(e,f,n,b,0)))return!1;d=f.length+1}}if(!u.length){let b=!!d;for(let x=i;x<e.length-d;x++){let k=String(e[x]);if(b=!0,k==="."||k===".."||!this.options.dot&&k.startsWith("."))return!1}return n||b}let p=[[[],0]],h=p[0],m=0,g=[0];for(let b of u)b===ms?(g.push(m),h=[[],0],p.push(h)):(h[0].push(b),m++);let v=p.length-1,y=e.length-d;for(let b of p)b[1]=y-(g[v--]+b[0].length);return!!this.#t(e,p,i,0,n,0,!!d)}#t(e,r,n,i,s,a,o){let c=r[i];if(!c){for(let d=n;d<e.length;d++){o=!0;let p=e[d];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return o}let[u,f]=c;for(;n<=f;){if(this.#n(e.slice(0,n+u.length),u,s,n,0)&&a<this.maxGlobstarRecursion){let h=this.#t(e,r,n+u.length,i+1,s,a+1,o);if(h!==!1)return h}let p=e[n];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;n++}return s||null}#n(e,r,n,i,s){let a,o,c,u;for(a=i,o=s,u=e.length,c=r.length;a<u&&o<c;a++,o++){this.debug("matchOne loop");let f=r[o],d=e[a];if(this.debug(r,f,d),f===!1||f===ms)return!1;let p;if(typeof f=="string"?(p=d===f,this.debug("string match",f,d,p)):(p=f.test(d),this.debug("pattern match",f,d,p)),!p)return!1}if(a===u&&o===c)return!0;if(a===u)return n;if(o===c)return a===u-1&&e[a]==="";throw new Error("wtf?")}braceExpand(){return eDe(this.pattern,this.options)}parse(e){yS(e);let r=this.options;if(e==="**")return ms;if(e==="")return"";let n,i=null;(n=e.match($Wt))?i=r.dot?NWt:jWt:(n=e.match(EWt))?i=(r.nocase?r.dot?TWt:CWt:r.dot?AWt:kWt)(n[1]):(n=e.match(FWt))?i=(r.nocase?r.dot?LWt:MWt:r.dot?qWt:BWt)(n):(n=e.match(PWt))?i=r.dot?IWt:OWt:(n=e.match(DWt))&&(i=RWt);let s=j1.fromGlob(e,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?HWt:r.dot?WWt:VWt,i=new Set(r.nocase?["i"]:[]),s=e.map(c=>{let u=c.map(d=>{if(d instanceof RegExp)for(let p of d.flags.split(""))i.add(p);return typeof d=="string"?XWt(d):d===ms?ms:d._src});u.forEach((d,p)=>{let h=u[p+1],m=u[p-1];d!==ms||m===ms||(m===void 0?h!==void 0&&h!==ms?u[p+1]="(?:\\/|"+n+"\\/)?"+h:u[p]=n:h===void 0?u[p-1]=m+"(?:\\/|\\/"+n+")?":h!==ms&&(u[p-1]=m+"(?:\\/|\\/"+n+"\\/)"+h,u[p+1]=ms))});let f=u.filter(d=>d!==ms);if(this.partial&&f.length>=1){let d=[];for(let p=1;p<=f.length;p++)d.push(f.slice(0,p).join("/"));return"(?:"+d.join("|")+")"}return f.join("/")}).join("|"),[a,o]=e.length>1?["(?:",")"]:["",""];s="^"+a+s+o+"$",this.partial&&(s="^(?:\\/|"+a+s.slice(1,-1)+o+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,r=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&r)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let a=i[i.length-1];if(!a)for(let o=i.length-2;!a&&o>=0;o--)a=i[o];for(let o of s){let c=i;if(n.matchBase&&o.length===1&&(c=[a]),this.matchOne(c,o,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return Fo.defaults(e).Minimatch}};Fo.AST=j1;Fo.Minimatch=du;Fo.escape=z8;Fo.unescape=cf;import{fileURLToPath as IVt}from"node:url";var YWt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,rDe=new Set,kre=typeof process=="object"&&process?process:{},nDe=(t,e,r,n)=>{typeof kre.emitWarning=="function"?kre.emitWarning(t,e,r,n):console.error(`[${r}] ${e}: ${t}`)},zN=globalThis.AbortController,tDe=globalThis.AbortSignal;if(typeof zN>"u"){tDe=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(r,n){this._onabort.push(n)}},zN=class{constructor(){e()}signal=new tDe;abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(let n of this.signal._onabort)n(r);this.signal.onabort?.(r)}}};let t=kre.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,nDe("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var QWt=t=>!rDe.has(t),efn=Symbol("type"),b0=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),iDe=t=>b0(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?UN:null:null,UN=class extends Array{constructor(t){super(t),this.fill(0)}},eVt=class xS{heap;length;static#e=!1;static create(e){let r=iDe(e);if(!r)return[];xS.#e=!0;let n=new xS(e,r);return xS.#e=!1,n}constructor(e,r){if(!xS.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},_S=class sDe{#e;#t;#n;#r;#a;#h;#l;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#i;#f;#d;#u;#o;#x;#w;#g;#v;#A;#y;#S;#E;#m;#b;#_;#C;#s;#$;static unsafeExposeInternals(e){return{starts:e.#E,ttls:e.#m,autopurgeTimers:e.#b,sizes:e.#S,keyMap:e.#d,keyList:e.#u,valList:e.#o,next:e.#x,prev:e.#w,get head(){return e.#g},get tail(){return e.#v},free:e.#A,isBackgroundFetch:r=>e.#p(r),backgroundFetch:(r,n,i,s)=>e.#U(r,n,i,s),moveToTail:r=>e.#N(r),indexes:r=>e.#O(r),rindexes:r=>e.#I(r),isStale:r=>e.#k(r)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#f}get size(){return this.#i}get fetchMethod(){return this.#h}get memoMethod(){return this.#l}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#a}constructor(e){let{max:r=0,ttl:n,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:o,allowStale:c,dispose:u,onInsert:f,disposeAfter:d,noDisposeOnSet:p,noUpdateTTL:h,maxSize:m=0,maxEntrySize:g=0,sizeCalculation:v,fetchMethod:y,memoMethod:b,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:k,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:P,ignoreFetchAbort:R,perf:$}=e;if($!==void 0&&typeof $?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#c=$??YWt,r!==0&&!b0(r))throw new TypeError("max option must be a nonnegative integer");let E=r?iDe(r):Array;if(!E)throw new Error("invalid max value: "+r);if(this.#e=r,this.#t=m,this.maxEntrySize=g||this.#t,this.sizeCalculation=v,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(b!==void 0&&typeof b!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#l=b,y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#h=y,this.#C=!!y,this.#d=new Map,this.#u=new Array(r).fill(void 0),this.#o=new Array(r).fill(void 0),this.#x=new E(r),this.#w=new E(r),this.#g=0,this.#v=0,this.#A=eVt.create(r),this.#i=0,this.#f=0,typeof u=="function"&&(this.#n=u),typeof f=="function"&&(this.#r=f),typeof d=="function"?(this.#a=d,this.#y=[]):(this.#a=void 0,this.#y=void 0),this.#_=!!this.#n,this.#$=!!this.#r,this.#s=!!this.#a,this.noDisposeOnSet=!!p,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!R,this.maxEntrySize!==0){if(this.#t!==0&&!b0(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!b0(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#H()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!k,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!o,this.ttlResolution=b0(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=n||0,this.ttl){if(!b0(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#D()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let T="LRU_CACHE_UNBOUNDED";QWt(T)&&(rDe.add(T),nDe("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",T,sDe))}}getRemainingTTL(e){return this.#d.has(e)?1/0:0}#D(){let e=new UN(this.#e),r=new UN(this.#e);this.#m=e,this.#E=r;let n=this.ttlAutopurge?new Array(this.#e):void 0;this.#b=n,this.#M=(o,c,u=this.#c.now())=>{r[o]=c!==0?u:0,e[o]=c,i(o,c)},this.#T=o=>{r[o]=e[o]!==0?this.#c.now():0,i(o,e[o])};let i=this.ttlAutopurge?(o,c)=>{if(n?.[o]&&(clearTimeout(n[o]),n[o]=void 0),c&&c!==0&&n){let u=setTimeout(()=>{this.#k(o)&&this.#P(this.#u[o],"expire")},c+1);u.unref&&u.unref(),n[o]=u}}:()=>{};this.#R=(o,c)=>{if(e[c]){let u=e[c],f=r[c];if(!u||!f)return;o.ttl=u,o.start=f,o.now=s||a();let d=o.now-f;o.remainingTTL=u-d}};let s=0,a=()=>{let o=this.#c.now();if(this.ttlResolution>0){s=o;let c=setTimeout(()=>s=0,this.ttlResolution);c.unref&&c.unref()}return o};this.getRemainingTTL=o=>{let c=this.#d.get(o);if(c===void 0)return 0;let u=e[c],f=r[c];if(!u||!f)return 1/0;let d=(s||a())-f;return u-d},this.#k=o=>{let c=r[o],u=e[o];return!!u&&!!c&&(s||a())-c>u}}#T=()=>{};#R=()=>{};#M=()=>{};#k=()=>!1;#H(){let e=new UN(this.#e);this.#f=0,this.#S=e,this.#F=r=>{this.#f-=e[r],e[r]=0},this.#L=(r,n,i,s)=>{if(this.#p(n))return 0;if(!b0(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(n,r),!b0(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#j=(r,n,i)=>{if(e[r]=n,this.#t){let s=this.#t-e[r];for(;this.#f>s;)this.#B(!0)}this.#f+=e[r],i&&(i.entrySize=n,i.totalCalculatedSize=this.#f)}}#F=e=>{};#j=(e,r,n)=>{};#L=(e,r,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:e=this.allowStale}={}){if(this.#i)for(let r=this.#v;!(!this.#q(r)||((e||!this.#k(r))&&(yield r),r===this.#g));)r=this.#w[r]}*#I({allowStale:e=this.allowStale}={}){if(this.#i)for(let r=this.#g;!(!this.#q(r)||((e||!this.#k(r))&&(yield r),r===this.#v));)r=this.#x[r]}#q(e){return e!==void 0&&this.#d.get(this.#u[e])===e}*entries(){for(let e of this.#O())this.#o[e]!==void 0&&this.#u[e]!==void 0&&!this.#p(this.#o[e])&&(yield[this.#u[e],this.#o[e]])}*rentries(){for(let e of this.#I())this.#o[e]!==void 0&&this.#u[e]!==void 0&&!this.#p(this.#o[e])&&(yield[this.#u[e],this.#o[e]])}*keys(){for(let e of this.#O()){let r=this.#u[e];r!==void 0&&!this.#p(this.#o[e])&&(yield r)}}*rkeys(){for(let e of this.#I()){let r=this.#u[e];r!==void 0&&!this.#p(this.#o[e])&&(yield r)}}*values(){for(let e of this.#O())this.#o[e]!==void 0&&!this.#p(this.#o[e])&&(yield this.#o[e])}*rvalues(){for(let e of this.#I())this.#o[e]!==void 0&&!this.#p(this.#o[e])&&(yield this.#o[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,r={}){for(let n of this.#O()){let i=this.#o[n],s=this.#p(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#u[n],this))return this.get(this.#u[n],r)}}forEach(e,r=this){for(let n of this.#O()){let i=this.#o[n],s=this.#p(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(r,s,this.#u[n],this)}}rforEach(e,r=this){for(let n of this.#I()){let i=this.#o[n],s=this.#p(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(r,s,this.#u[n],this)}}purgeStale(){let e=!1;for(let r of this.#I({allowStale:!0}))this.#k(r)&&(this.#P(this.#u[r],"expire"),e=!0);return e}info(e){let r=this.#d.get(e);if(r===void 0)return;let n=this.#o[r],i=this.#p(n)?n.__staleWhileFetching:n;if(i===void 0)return;let s={value:i};if(this.#m&&this.#E){let a=this.#m[r],o=this.#E[r];if(a&&o){let c=a-(this.#c.now()-o);s.ttl=c,s.start=Date.now()}}return this.#S&&(s.size=this.#S[r]),s}dump(){let e=[];for(let r of this.#O({allowStale:!0})){let n=this.#u[r],i=this.#o[r],s=this.#p(i)?i.__staleWhileFetching:i;if(s===void 0||n===void 0)continue;let a={value:s};if(this.#m&&this.#E){a.ttl=this.#m[r];let o=this.#c.now()-this.#E[r];a.start=Math.floor(Date.now()-o)}this.#S&&(a.size=this.#S[r]),e.unshift([n,a])}return e}load(e){this.clear();for(let[r,n]of e){if(n.start){let i=Date.now()-n.start;n.start=this.#c.now()-i}this.set(r,n.value,n)}}set(e,r,n={}){if(r===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:c}=n,{noUpdateTTL:u=this.noUpdateTTL}=n,f=this.#L(e,r,n.size||0,o);if(this.maxEntrySize&&f>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#P(e,"set"),this;let d=this.#i===0?void 0:this.#d.get(e);if(d===void 0)d=this.#i===0?this.#v:this.#A.length!==0?this.#A.pop():this.#i===this.#e?this.#B(!1):this.#i,this.#u[d]=e,this.#o[d]=r,this.#d.set(e,d),this.#x[this.#v]=d,this.#w[d]=this.#v,this.#v=d,this.#i++,this.#j(d,f,c),c&&(c.set="add"),u=!1,this.#$&&this.#r?.(r,e,"add");else{this.#N(d);let p=this.#o[d];if(r!==p){if(this.#C&&this.#p(p)){p.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:h}=p;h!==void 0&&!a&&(this.#_&&this.#n?.(h,e,"set"),this.#s&&this.#y?.push([h,e,"set"]))}else a||(this.#_&&this.#n?.(p,e,"set"),this.#s&&this.#y?.push([p,e,"set"]));if(this.#F(d),this.#j(d,f,c),this.#o[d]=r,c){c.set="replace";let h=p&&this.#p(p)?p.__staleWhileFetching:p;h!==void 0&&(c.oldValue=h)}}else c&&(c.set="update");this.#$&&this.onInsert?.(r,e,r===p?"update":"replace")}if(i!==0&&!this.#m&&this.#D(),this.#m&&(u||this.#M(d,i,s),c&&this.#R(c,d)),!a&&this.#s&&this.#y){let p=this.#y,h;for(;h=p?.shift();)this.#a?.(...h)}return this}pop(){try{for(;this.#i;){let e=this.#o[this.#g];if(this.#B(!0),this.#p(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#s&&this.#y){let e=this.#y,r;for(;r=e?.shift();)this.#a?.(...r)}}}#B(e){let r=this.#g,n=this.#u[r],i=this.#o[r];return this.#C&&this.#p(i)?i.__abortController.abort(new Error("evicted")):(this.#_||this.#s)&&(this.#_&&this.#n?.(i,n,"evict"),this.#s&&this.#y?.push([i,n,"evict"])),this.#F(r),this.#b?.[r]&&(clearTimeout(this.#b[r]),this.#b[r]=void 0),e&&(this.#u[r]=void 0,this.#o[r]=void 0,this.#A.push(r)),this.#i===1?(this.#g=this.#v=0,this.#A.length=0):this.#g=this.#x[r],this.#d.delete(n),this.#i--,r}has(e,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=r,s=this.#d.get(e);if(s!==void 0){let a=this.#o[s];if(this.#p(a)&&a.__staleWhileFetching===void 0)return!1;if(this.#k(s))i&&(i.has="stale",this.#R(i,s));else return n&&this.#T(s),i&&(i.has="hit",this.#R(i,s)),!0}else i&&(i.has="miss");return!1}peek(e,r={}){let{allowStale:n=this.allowStale}=r,i=this.#d.get(e);if(i===void 0||!n&&this.#k(i))return;let s=this.#o[i];return this.#p(s)?s.__staleWhileFetching:s}#U(e,r,n,i){let s=r===void 0?void 0:this.#o[r];if(this.#p(s))return s;let a=new zN,{signal:o}=n;o?.addEventListener("abort",()=>a.abort(o.reason),{signal:a.signal});let c={signal:a.signal,options:n,context:i},u=(g,v=!1)=>{let{aborted:y}=a.signal,b=n.ignoreFetchAbort&&g!==void 0,x=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&g!==void 0);if(n.status&&(y&&!v?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,b&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),y&&!b&&!v)return d(a.signal.reason,x);let k=h,A=this.#o[r];return(A===h||b&&v&&A===void 0)&&(g===void 0?k.__staleWhileFetching!==void 0?this.#o[r]=k.__staleWhileFetching:this.#P(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,g,c.options))),g},f=g=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=g),d(g,!1)),d=(g,v)=>{let{aborted:y}=a.signal,b=y&&n.allowStaleOnFetchAbort,x=b||n.allowStaleOnFetchRejection,k=x||n.noDeleteOnFetchRejection,A=h;if(this.#o[r]===h&&(!k||!v&&A.__staleWhileFetching===void 0?this.#P(e,"fetch"):b||(this.#o[r]=A.__staleWhileFetching)),x)return n.status&&A.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),A.__staleWhileFetching;if(A.__returned===A)throw g},p=(g,v)=>{let y=this.#h?.(e,s,c);y&&y instanceof Promise&&y.then(b=>g(b===void 0?void 0:b),v),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(g(void 0),n.allowStaleOnFetchAbort&&(g=b=>u(b,!0)))})};n.status&&(n.status.fetchDispatched=!0);let h=new Promise(p).then(u,f),m=Object.assign(h,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return r===void 0?(this.set(e,m,{...c.options,status:void 0}),r=this.#d.get(e)):this.#o[r]=m,m}#p(e){if(!this.#C)return!1;let r=e;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof zN}async fetch(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:c=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:h=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:g,forceRefresh:v=!1,status:y,signal:b}=r;if(!this.#C)return y&&(y.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:y});let x={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:o,size:c,sizeCalculation:u,noUpdateTTL:f,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:m,ignoreFetchAbort:h,status:y,signal:b},k=this.#d.get(e);if(k===void 0){y&&(y.fetch="miss");let A=this.#U(e,k,x,g);return A.__returned=A}else{let A=this.#o[k];if(this.#p(A)){let E=n&&A.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",E&&(y.returnedStale=!0)),E?A.__staleWhileFetching:A.__returned=A}let P=this.#k(k);if(!v&&!P)return y&&(y.fetch="hit"),this.#N(k),i&&this.#T(k),y&&this.#R(y,k),A;let R=this.#U(e,k,x,g),$=R.__staleWhileFetching!==void 0&&n;return y&&(y.fetch=P?"stale":"refresh",$&&P&&(y.returnedStale=!0)),$?R.__staleWhileFetching:R.__returned=R}}async forceFetch(e,r={}){let n=await this.fetch(e,r);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,r={}){let n=this.#l;if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:s,...a}=r,o=this.get(e,a);if(!s&&o!==void 0)return o;let c=n(e,o,{options:a,context:i});return this.set(e,c,a),c}get(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=r,o=this.#d.get(e);if(o!==void 0){let c=this.#o[o],u=this.#p(c);return a&&this.#R(a,o),this.#k(o)?(a&&(a.get="stale"),u?(a&&n&&c.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?c.__staleWhileFetching:void 0):(s||this.#P(e,"expire"),a&&n&&(a.returnedStale=!0),n?c:void 0)):(a&&(a.get="hit"),u?c.__staleWhileFetching:(this.#N(o),i&&this.#T(o),c))}else a&&(a.get="miss")}#z(e,r){this.#w[r]=e,this.#x[e]=r}#N(e){e!==this.#v&&(e===this.#g?this.#g=this.#x[e]:this.#z(this.#w[e],this.#x[e]),this.#z(this.#v,e),this.#v=e)}delete(e){return this.#P(e,"delete")}#P(e,r){let n=!1;if(this.#i!==0){let i=this.#d.get(e);if(i!==void 0)if(this.#b?.[i]&&(clearTimeout(this.#b?.[i]),this.#b[i]=void 0),n=!0,this.#i===1)this.#W(r);else{this.#F(i);let s=this.#o[i];if(this.#p(s)?s.__abortController.abort(new Error("deleted")):(this.#_||this.#s)&&(this.#_&&this.#n?.(s,e,r),this.#s&&this.#y?.push([s,e,r])),this.#d.delete(e),this.#u[i]=void 0,this.#o[i]=void 0,i===this.#v)this.#v=this.#w[i];else if(i===this.#g)this.#g=this.#x[i];else{let a=this.#w[i];this.#x[a]=this.#x[i];let o=this.#x[i];this.#w[o]=this.#w[i]}this.#i--,this.#A.push(i)}}if(this.#s&&this.#y?.length){let i=this.#y,s;for(;s=i?.shift();)this.#a?.(...s)}return n}clear(){return this.#W("delete")}#W(e){for(let r of this.#I({allowStale:!0})){let n=this.#o[r];if(this.#p(n))n.__abortController.abort(new Error("deleted"));else{let i=this.#u[r];this.#_&&this.#n?.(n,i,e),this.#s&&this.#y?.push([n,i,e])}}if(this.#d.clear(),this.#o.fill(void 0),this.#u.fill(void 0),this.#m&&this.#E){this.#m.fill(0),this.#E.fill(0);for(let r of this.#b??[])r!==void 0&&clearTimeout(r);this.#b?.fill(void 0)}if(this.#S&&this.#S.fill(0),this.#g=0,this.#v=0,this.#A.length=0,this.#f=0,this.#i=0,this.#s&&this.#y){let r=this.#y,n;for(;n=r?.shift();)this.#a?.(...n)}}};import{posix as fVt,win32 as jre}from"node:path";import{fileURLToPath as dVt}from"node:url";import{lstatSync as pVt,readdir as hVt,readdirSync as mVt,readlinkSync as gVt,realpathSync as vVt}from"fs";import*as yVt from"node:fs";import{lstat as xVt,readdir as _Vt,readlink as wVt,realpath as SVt}from"node:fs/promises";import{EventEmitter as Dre}from"node:events";import lDe from"node:stream";import{StringDecoder as tVt}from"node:string_decoder";var aDe=typeof process=="object"&&process?process:{stdout:null,stderr:null},rVt=t=>!!t&&typeof t=="object"&&(t instanceof _0||t instanceof lDe||nVt(t)||iVt(t)),nVt=t=>!!t&&typeof t=="object"&&t instanceof Dre&&typeof t.pipe=="function"&&t.pipe!==lDe.Writable.prototype.pipe,iVt=t=>!!t&&typeof t=="object"&&t instanceof Dre&&typeof t.write=="function"&&typeof t.end=="function",th=Symbol("EOF"),rh=Symbol("maybeEmitEnd"),x0=Symbol("emittedEnd"),HN=Symbol("emittingEnd"),wS=Symbol("emittedError"),WN=Symbol("closed"),oDe=Symbol("read"),VN=Symbol("flush"),cDe=Symbol("flushChunk"),uf=Symbol("encoding"),H8=Symbol("decoder"),ca=Symbol("flowing"),SS=Symbol("paused"),W8=Symbol("resume"),ua=Symbol("buffer"),Mo=Symbol("pipes"),la=Symbol("bufferLength"),Are=Symbol("bufferPush"),GN=Symbol("bufferShift"),no=Symbol("objectMode"),gs=Symbol("destroyed"),Cre=Symbol("error"),Tre=Symbol("emitData"),uDe=Symbol("emitEnd"),Pre=Symbol("emitEnd2"),Pd=Symbol("async"),Ore=Symbol("abort"),ZN=Symbol("aborted"),ES=Symbol("signal"),N1=Symbol("dataListeners"),pu=Symbol("discarded"),kS=t=>Promise.resolve().then(t),sVt=t=>t(),aVt=t=>t==="end"||t==="finish"||t==="prefinish",oVt=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,cVt=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),KN=class{src;dest;opts;ondrain;constructor(e,r,n){this.src=e,this.dest=r,this.opts=n,this.ondrain=()=>e[W8](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Ire=class extends KN{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,r,n){super(e,r,n),this.proxyErrors=i=>this.dest.emit("error",i),e.on("error",this.proxyErrors)}},uVt=t=>!!t.objectMode,lVt=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",_0=class extends Dre{[ca]=!1;[SS]=!1;[Mo]=[];[ua]=[];[no];[uf];[Pd];[H8];[th]=!1;[x0]=!1;[HN]=!1;[WN]=!1;[wS]=null;[la]=0;[gs]=!1;[ES];[ZN]=!1;[N1]=0;[pu]=!1;writable=!0;readable=!0;constructor(...e){let r=e[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");uVt(r)?(this[no]=!0,this[uf]=null):lVt(r)?(this[uf]=r.encoding,this[no]=!1):(this[no]=!1,this[uf]=null),this[Pd]=!!r.async,this[H8]=this[uf]?new tVt(this[uf]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[ua]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Mo]});let{signal:n}=r;n&&(this[ES]=n,n.aborted?this[Ore]():n.addEventListener("abort",()=>this[Ore]()))}get bufferLength(){return this[la]}get encoding(){return this[uf]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[no]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Pd]}set async(e){this[Pd]=this[Pd]||!!e}[Ore](){this[ZN]=!0,this.emit("abort",this[ES]?.reason),this.destroy(this[ES]?.reason)}get aborted(){return this[ZN]}set aborted(e){}write(e,r,n){if(this[ZN])return!1;if(this[th])throw new Error("write after end");if(this[gs])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(n=r,r="utf8"),r||(r="utf8");let i=this[Pd]?kS:sVt;if(!this[no]&&!Buffer.isBuffer(e)){if(cVt(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(oVt(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[no]?(this[ca]&&this[la]!==0&&this[VN](!0),this[ca]?this.emit("data",e):this[Are](e),this[la]!==0&&this.emit("readable"),n&&i(n),this[ca]):e.length?(typeof e=="string"&&!(r===this[uf]&&!this[H8]?.lastNeed)&&(e=Buffer.from(e,r)),Buffer.isBuffer(e)&&this[uf]&&(e=this[H8].write(e)),this[ca]&&this[la]!==0&&this[VN](!0),this[ca]?this.emit("data",e):this[Are](e),this[la]!==0&&this.emit("readable"),n&&i(n),this[ca]):(this[la]!==0&&this.emit("readable"),n&&i(n),this[ca])}read(e){if(this[gs])return null;if(this[pu]=!1,this[la]===0||e===0||e&&e>this[la])return this[rh](),null;this[no]&&(e=null),this[ua].length>1&&!this[no]&&(this[ua]=[this[uf]?this[ua].join(""):Buffer.concat(this[ua],this[la])]);let r=this[oDe](e||null,this[ua][0]);return this[rh](),r}[oDe](e,r){if(this[no])this[GN]();else{let n=r;e===n.length||e===null?this[GN]():typeof n=="string"?(this[ua][0]=n.slice(e),r=n.slice(0,e),this[la]-=e):(this[ua][0]=n.subarray(e),r=n.subarray(0,e),this[la]-=e)}return this.emit("data",r),!this[ua].length&&!this[th]&&this.emit("drain"),r}end(e,r,n){return typeof e=="function"&&(n=e,e=void 0),typeof r=="function"&&(n=r,r="utf8"),e!==void 0&&this.write(e,r),n&&this.once("end",n),this[th]=!0,this.writable=!1,(this[ca]||!this[SS])&&this[rh](),this}[W8](){this[gs]||(!this[N1]&&!this[Mo].length&&(this[pu]=!0),this[SS]=!1,this[ca]=!0,this.emit("resume"),this[ua].length?this[VN]():this[th]?this[rh]():this.emit("drain"))}resume(){return this[W8]()}pause(){this[ca]=!1,this[SS]=!0,this[pu]=!1}get destroyed(){return this[gs]}get flowing(){return this[ca]}get paused(){return this[SS]}[Are](e){this[no]?this[la]+=1:this[la]+=e.length,this[ua].push(e)}[GN](){return this[no]?this[la]-=1:this[la]-=this[ua][0].length,this[ua].shift()}[VN](e=!1){do;while(this[cDe](this[GN]())&&this[ua].length);!e&&!this[ua].length&&!this[th]&&this.emit("drain")}[cDe](e){return this.emit("data",e),this[ca]}pipe(e,r){if(this[gs])return e;this[pu]=!1;let n=this[x0];return r=r||{},e===aDe.stdout||e===aDe.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,n?r.end&&e.end():(this[Mo].push(r.proxyErrors?new Ire(this,e,r):new KN(this,e,r)),this[Pd]?kS(()=>this[W8]()):this[W8]()),e}unpipe(e){let r=this[Mo].find(n=>n.dest===e);r&&(this[Mo].length===1?(this[ca]&&this[N1]===0&&(this[ca]=!1),this[Mo]=[]):this[Mo].splice(this[Mo].indexOf(r),1),r.unpipe())}addListener(e,r){return this.on(e,r)}on(e,r){let n=super.on(e,r);if(e==="data")this[pu]=!1,this[N1]++,!this[Mo].length&&!this[ca]&&this[W8]();else if(e==="readable"&&this[la]!==0)super.emit("readable");else if(aVt(e)&&this[x0])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[wS]){let i=r;this[Pd]?kS(()=>i.call(this,this[wS])):i.call(this,this[wS])}return n}removeListener(e,r){return this.off(e,r)}off(e,r){let n=super.off(e,r);return e==="data"&&(this[N1]=this.listeners("data").length,this[N1]===0&&!this[pu]&&!this[Mo].length&&(this[ca]=!1)),n}removeAllListeners(e){let r=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[N1]=0,!this[pu]&&!this[Mo].length&&(this[ca]=!1)),r}get emittedEnd(){return this[x0]}[rh](){!this[HN]&&!this[x0]&&!this[gs]&&this[ua].length===0&&this[th]&&(this[HN]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[WN]&&this.emit("close"),this[HN]=!1)}emit(e,...r){let n=r[0];if(e!=="error"&&e!=="close"&&e!==gs&&this[gs])return!1;if(e==="data")return!this[no]&&!n?!1:this[Pd]?(kS(()=>this[Tre](n)),!0):this[Tre](n);if(e==="end")return this[uDe]();if(e==="close"){if(this[WN]=!0,!this[x0]&&!this[gs])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[wS]=n,super.emit(Cre,n);let s=!this[ES]||this.listeners("error").length?super.emit("error",n):!1;return this[rh](),s}else if(e==="resume"){let s=super.emit("resume");return this[rh](),s}else if(e==="finish"||e==="prefinish"){let s=super.emit(e);return this.removeAllListeners(e),s}let i=super.emit(e,...r);return this[rh](),i}[Tre](e){for(let n of this[Mo])n.dest.write(e)===!1&&this.pause();let r=this[pu]?!1:super.emit("data",e);return this[rh](),r}[uDe](){return this[x0]?!1:(this[x0]=!0,this.readable=!1,this[Pd]?(kS(()=>this[Pre]()),!0):this[Pre]())}[Pre](){if(this[H8]){let r=this[H8].end();if(r){for(let n of this[Mo])n.dest.write(r);this[pu]||super.emit("data",r)}}for(let r of this[Mo])r.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[no]||(e.dataLength=0);let r=this.promise();return this.on("data",n=>{e.push(n),this[no]||(e.dataLength+=n.length)}),await r,e}async concat(){if(this[no])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[uf]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,r)=>{this.on(gs,()=>r(new Error("stream destroyed"))),this.on("error",n=>r(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[pu]=!1;let e=!1,r=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return r();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[th])return r();let s,a,o=d=>{this.off("data",c),this.off("end",u),this.off(gs,f),r(),a(d)},c=d=>{this.off("error",o),this.off("end",u),this.off(gs,f),this.pause(),s({value:d,done:!!this[th]})},u=()=>{this.off("error",o),this.off("data",c),this.off(gs,f),r(),s({done:!0,value:void 0})},f=()=>o(new Error("stream destroyed"));return new Promise((d,p)=>{a=p,s=d,this.once(gs,f),this.once("error",o),this.once("end",u),this.once("data",c)})},throw:r,return:r,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[pu]=!1;let e=!1,r=()=>(this.pause(),this.off(Cre,r),this.off(gs,r),this.off("end",r),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return r();let i=this.read();return i===null?r():{done:!1,value:i}};return this.once("end",r),this.once(Cre,r),this.once(gs,r),{next:n,throw:r,return:r,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[gs])return e?this.emit("error",e):this.emit(gs),this;this[gs]=!0,this[pu]=!0,this[ua].length=0,this[la]=0;let r=this;return typeof r.close=="function"&&!this[WN]&&r.close(),e?this.emit("error",e):this.emit(gs),this}static get isStream(){return rVt}};var bVt=vVt.native,CS={lstatSync:pVt,readdir:hVt,readdirSync:mVt,readlinkSync:gVt,realpathSync:bVt,promises:{lstat:xVt,readdir:_Vt,readlink:wVt,realpath:SVt}},mDe=t=>!t||t===CS||t===yVt?CS:{...CS,...t,promises:{...CS.promises,...t.promises||{}}},gDe=/^\\\\\?\\([a-z]:)\\?$/i,EVt=t=>t.replace(/\//g,"\\").replace(gDe,"$1\\"),kVt=/[\\\/]/,ll=0,vDe=1,yDe=2,Od=4,bDe=6,xDe=8,F1=10,_De=12,ul=15,AS=~ul,Rre=16,fDe=32,TS=64,lf=128,JN=256,YN=512,dDe=TS|lf|YN,AVt=1023,$re=t=>t.isFile()?xDe:t.isDirectory()?Od:t.isSymbolicLink()?F1:t.isCharacterDevice()?yDe:t.isBlockDevice()?bDe:t.isSocket()?_De:t.isFIFO()?vDe:ll,pDe=new _S({max:2**12}),PS=t=>{let e=pDe.get(t);if(e)return e;let r=t.normalize("NFKD");return pDe.set(t,r),r},hDe=new _S({max:2**12}),XN=t=>{let e=hDe.get(t);if(e)return e;let r=PS(t.toLowerCase());return hDe.set(t,r),r},QN=class extends _S{constructor(){super({max:256})}},Nre=class extends _S{constructor(e=16*1024){super({maxSize:e,sizeCalculation:r=>r.length+1})}},wDe=Symbol("PathScurry setAsCwd"),io=class{name;root;roots;parent;nocase;isCWD=!1;#e;#t;get dev(){return this.#t}#n;get mode(){return this.#n}#r;get nlink(){return this.#r}#a;get uid(){return this.#a}#h;get gid(){return this.#h}#l;get rdev(){return this.#l}#c;get blksize(){return this.#c}#i;get ino(){return this.#i}#f;get size(){return this.#f}#d;get blocks(){return this.#d}#u;get atimeMs(){return this.#u}#o;get mtimeMs(){return this.#o}#x;get ctimeMs(){return this.#x}#w;get birthtimeMs(){return this.#w}#g;get atime(){return this.#g}#v;get mtime(){return this.#v}#A;get ctime(){return this.#A}#y;get birthtime(){return this.#y}#S;#E;#m;#b;#_;#C;#s;#$;#D;#T;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,r=ll,n,i,s,a,o){this.name=e,this.#S=s?XN(e):PS(e),this.#s=r&AVt,this.nocase=s,this.roots=i,this.root=n||this,this.#$=a,this.#m=o.fullpath,this.#_=o.relative,this.#C=o.relativePosix,this.parent=o.parent,this.parent?this.#e=this.parent.#e:this.#e=mDe(o.fs)}depth(){return this.#E!==void 0?this.#E:this.parent?this.#E=this.parent.depth()+1:this.#E=0}childrenCache(){return this.#$}resolve(e){if(!e)return this;let r=this.getRootString(e),i=e.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#R(i):this.#R(i)}#R(e){let r=this;for(let n of e)r=r.child(n);return r}children(){let e=this.#$.get(this);if(e)return e;let r=Object.assign([],{provisional:0});return this.#$.set(this,r),this.#s&=~Rre,r}child(e,r){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let n=this.children(),i=this.nocase?XN(e):PS(e);for(let c of n)if(c.#S===i)return c;let s=this.parent?this.sep:"",a=this.#m?this.#m+s+e:void 0,o=this.newChild(e,ll,{...r,parent:this,fullpath:a});return this.canReaddir()||(o.#s|=lf),n.push(o),o}relative(){if(this.isCWD)return"";if(this.#_!==void 0)return this.#_;let e=this.name,r=this.parent;if(!r)return this.#_=this.name;let n=r.relative();return n+(!n||!r.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#C!==void 0)return this.#C;let e=this.name,r=this.parent;if(!r)return this.#C=this.fullpathPosix();let n=r.relativePosix();return n+(!n||!r.parent?"":"/")+e}fullpath(){if(this.#m!==void 0)return this.#m;let e=this.name,r=this.parent;if(!r)return this.#m=this.name;let i=r.fullpath()+(r.parent?this.sep:"")+e;return this.#m=i}fullpathPosix(){if(this.#b!==void 0)return this.#b;if(this.sep==="/")return this.#b=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#b=`//?/${i}`:this.#b=i}let e=this.parent,r=e.fullpathPosix(),n=r+(!r||!e.parent?"":"/")+this.name;return this.#b=n}isUnknown(){return(this.#s&ul)===ll}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#s&ul)===xDe}isDirectory(){return(this.#s&ul)===Od}isCharacterDevice(){return(this.#s&ul)===yDe}isBlockDevice(){return(this.#s&ul)===bDe}isFIFO(){return(this.#s&ul)===vDe}isSocket(){return(this.#s&ul)===_De}isSymbolicLink(){return(this.#s&F1)===F1}lstatCached(){return this.#s&fDe?this:void 0}readlinkCached(){return this.#D}realpathCached(){return this.#T}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#D)return!0;if(!this.parent)return!1;let e=this.#s&ul;return!(e!==ll&&e!==F1||this.#s&JN||this.#s&lf)}calledReaddir(){return!!(this.#s&Rre)}isENOENT(){return!!(this.#s&lf)}isNamed(e){return this.nocase?this.#S===XN(e):this.#S===PS(e)}async readlink(){let e=this.#D;if(e)return e;if(this.canReadlink()&&this.parent)try{let r=await this.#e.promises.readlink(this.fullpath()),n=(await this.parent.realpath())?.resolve(r);if(n)return this.#D=n}catch(r){this.#I(r.code);return}}readlinkSync(){let e=this.#D;if(e)return e;if(this.canReadlink()&&this.parent)try{let r=this.#e.readlinkSync(this.fullpath()),n=this.parent.realpathSync()?.resolve(r);if(n)return this.#D=n}catch(r){this.#I(r.code);return}}#M(e){this.#s|=Rre;for(let r=e.provisional;r<e.length;r++){let n=e[r];n&&n.#k()}}#k(){this.#s&lf||(this.#s=(this.#s|lf)&AS,this.#H())}#H(){let e=this.children();e.provisional=0;for(let r of e)r.#k()}#F(){this.#s|=YN,this.#j()}#j(){if(this.#s&TS)return;let e=this.#s;(e&ul)===Od&&(e&=AS),this.#s=e|TS,this.#H()}#L(e=""){e==="ENOTDIR"||e==="EPERM"?this.#j():e==="ENOENT"?this.#k():this.children().provisional=0}#O(e=""){e==="ENOTDIR"?this.parent.#j():e==="ENOENT"&&this.#k()}#I(e=""){let r=this.#s;r|=JN,e==="ENOENT"&&(r|=lf),(e==="EINVAL"||e==="UNKNOWN")&&(r&=AS),this.#s=r,e==="ENOTDIR"&&this.parent&&this.parent.#j()}#q(e,r){return this.#U(e,r)||this.#B(e,r)}#B(e,r){let n=$re(e),i=this.newChild(e.name,n,{parent:this}),s=i.#s&ul;return s!==Od&&s!==F1&&s!==ll&&(i.#s|=TS),r.unshift(i),r.provisional++,i}#U(e,r){for(let n=r.provisional;n<r.length;n++){let i=r[n];if((this.nocase?XN(e.name):PS(e.name))===i.#S)return this.#p(e,i,n,r)}}#p(e,r,n,i){let s=r.name;return r.#s=r.#s&AS|$re(e),s!==e.name&&(r.name=e.name),n!==i.provisional&&(n===i.length-1?i.pop():i.splice(n,1),i.unshift(r)),i.provisional++,r}async lstat(){if((this.#s&lf)===0)try{return this.#z(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#O(e.code)}}lstatSync(){if((this.#s&lf)===0)try{return this.#z(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#O(e.code)}}#z(e){let{atime:r,atimeMs:n,birthtime:i,birthtimeMs:s,blksize:a,blocks:o,ctime:c,ctimeMs:u,dev:f,gid:d,ino:p,mode:h,mtime:m,mtimeMs:g,nlink:v,rdev:y,size:b,uid:x}=e;this.#g=r,this.#u=n,this.#y=i,this.#w=s,this.#c=a,this.#d=o,this.#A=c,this.#x=u,this.#t=f,this.#h=d,this.#i=p,this.#n=h,this.#v=m,this.#o=g,this.#r=v,this.#l=y,this.#f=b,this.#a=x;let k=$re(e);this.#s=this.#s&AS|k|fDe,k!==ll&&k!==Od&&k!==F1&&(this.#s|=TS)}#N=[];#P=!1;#W(e){this.#P=!1;let r=this.#N.slice();this.#N.length=0,r.forEach(n=>n(null,e))}readdirCB(e,r=!1){if(!this.canReaddir()){r?e(null,[]):queueMicrotask(()=>e(null,[]));return}let n=this.children();if(this.calledReaddir()){let s=n.slice(0,n.provisional);r?e(null,s):queueMicrotask(()=>e(null,s));return}if(this.#N.push(e),this.#P)return;this.#P=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(s,a)=>{if(s)this.#L(s.code),n.provisional=0;else{for(let o of a)this.#q(o,n);this.#M(n)}this.#W(n.slice(0,n.provisional))})}#V;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let r=this.fullpath();if(this.#V)await this.#V;else{let n=()=>{};this.#V=new Promise(i=>n=i);try{for(let i of await this.#e.promises.readdir(r,{withFileTypes:!0}))this.#q(i,e);this.#M(e)}catch(i){this.#L(i.code),e.provisional=0}this.#V=void 0,n()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let r=this.fullpath();try{for(let n of this.#e.readdirSync(r,{withFileTypes:!0}))this.#q(n,e);this.#M(e)}catch(n){this.#L(n.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#s&dDe)return!1;let e=ul&this.#s;return e===ll||e===Od||e===F1}shouldWalk(e,r){return(this.#s&Od)===Od&&!(this.#s&dDe)&&!e.has(this)&&(!r||r(this))}async realpath(){if(this.#T)return this.#T;if(!((YN|JN|lf)&this.#s))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#T=this.resolve(e)}catch{this.#F()}}realpathSync(){if(this.#T)return this.#T;if(!((YN|JN|lf)&this.#s))try{let e=this.#e.realpathSync(this.fullpath());return this.#T=this.resolve(e)}catch{this.#F()}}[wDe](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let r=new Set([]),n=[],i=this;for(;i&&i.parent;)r.add(i),i.#_=n.join(this.sep),i.#C=n.join("/"),i=i.parent,n.push("..");for(i=e;i&&i.parent&&!r.has(i);)i.#_=void 0,i.#C=void 0,i=i.parent}},eF=class t extends io{sep="\\";splitSep=kVt;constructor(e,r=ll,n,i,s,a,o){super(e,r,n,i,s,a,o)}newChild(e,r=ll,n={}){return new t(e,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(e){return jre.parse(e).root}getRoot(e){if(e=EVt(e.toUpperCase()),e===this.root.name)return this.root;for(let[r,n]of Object.entries(this.roots))if(this.sameRoot(e,r))return this.roots[e]=n;return this.roots[e]=new V8(e,this).root}sameRoot(e,r=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(gDe,"$1\\"),e===r}},tF=class t extends io{splitSep="/";sep="/";constructor(e,r=ll,n,i,s,a,o){super(e,r,n,i,s,a,o)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,r=ll,n={}){return new t(e,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}},rF=class{root;rootPath;roots;cwd;#e;#t;#n;nocase;#r;constructor(e=process.cwd(),r,n,{nocase:i,childrenCacheSize:s=16*1024,fs:a=CS}={}){this.#r=mDe(a),(e instanceof URL||e.startsWith("file://"))&&(e=dVt(e));let o=r.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(o),this.#e=new QN,this.#t=new QN,this.#n=new Nre(s);let c=o.substring(this.rootPath.length).split(n);if(c.length===1&&!c[0]&&c.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let u=this.root,f=c.length-1,d=r.sep,p=this.rootPath,h=!1;for(let m of c){let g=f--;u=u.child(m,{relative:new Array(g).fill("..").join(d),relativePosix:new Array(g).fill("..").join("/"),fullpath:p+=(h?"":d)+m}),h=!0}this.cwd=u}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#n}resolve(...e){let r="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(r=r?`${a}/${r}`:a,this.isAbsolute(a)))break}let n=this.#e.get(r);if(n!==void 0)return n;let i=this.cwd.resolve(r).fullpath();return this.#e.set(r,i),i}resolvePosix(...e){let r="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(r=r?`${a}/${r}`:a,this.isAbsolute(a)))break}let n=this.#t.get(r);if(n!==void 0)return n;let i=this.cwd.resolve(r).fullpathPosix();return this.#t.set(r,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,r={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n}=r;if(e.canReaddir()){let i=await e.readdir();return n?i:i.map(s=>s.name)}else return[]}readdirSync(e=this.cwd,r={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0}=r;return e.canReaddir()?n?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e.withFileTypes,e=this.cwd);let n=await e.readlink();return r?n:n?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e.withFileTypes,e=this.cwd);let n=e.readlinkSync();return r?n:n?.fullpath()}async realpath(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e.withFileTypes,e=this.cwd);let n=await e.realpath();return r?n:n?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e.withFileTypes,e=this.cwd);let n=e.realpathSync();return r?n:n?.fullpath()}async walk(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:a}=r,o=[];(!s||s(e))&&o.push(n?e:e.fullpath());let c=new Set,u=(d,p)=>{c.add(d),d.readdirCB((h,m)=>{if(h)return p(h);let g=m.length;if(!g)return p();let v=()=>{--g===0&&p()};for(let y of m)(!s||s(y))&&o.push(n?y:y.fullpath()),i&&y.isSymbolicLink()?y.realpath().then(b=>b?.isUnknown()?b.lstat():b).then(b=>b?.shouldWalk(c,a)?u(b,v):v()):y.shouldWalk(c,a)?u(y,v):v()},!0)},f=e;return new Promise((d,p)=>{u(f,h=>{if(h)return p(h);d(o)})})}walkSync(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:a}=r,o=[];(!s||s(e))&&o.push(n?e:e.fullpath());let c=new Set([e]);for(let u of c){let f=u.readdirSync();for(let d of f){(!s||s(d))&&o.push(n?d:d.fullpath());let p=d;if(d.isSymbolicLink()){if(!(i&&(p=d.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(c,a)&&c.add(p)}}return o}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,r={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd),this.stream(e,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:a}=r;(!s||s(e))&&(yield n?e:e.fullpath());let o=new Set([e]);for(let c of o){let u=c.readdirSync();for(let f of u){(!s||s(f))&&(yield n?f:f.fullpath());let d=f;if(f.isSymbolicLink()){if(!(i&&(d=f.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(o,a)&&o.add(d)}}}stream(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:a}=r,o=new _0({objectMode:!0});(!s||s(e))&&o.write(n?e:e.fullpath());let c=new Set,u=[e],f=0,d=()=>{let p=!1;for(;!p;){let h=u.shift();if(!h){f===0&&o.end();return}f++,c.add(h);let m=(v,y,b=!1)=>{if(v)return o.emit("error",v);if(i&&!b){let x=[];for(let k of y)k.isSymbolicLink()&&x.push(k.realpath().then(A=>A?.isUnknown()?A.lstat():A));if(x.length){Promise.all(x).then(()=>m(null,y,!0));return}}for(let x of y)x&&(!s||s(x))&&(o.write(n?x:x.fullpath())||(p=!0));f--;for(let x of y){let k=x.realpathCached()||x;k.shouldWalk(c,a)&&u.push(k)}p&&!o.flowing?o.once("drain",d):g||d()},g=!0;h.readdirCB(m,!0),g=!1}};return d(),o}streamSync(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof io||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:a}=r,o=new _0({objectMode:!0}),c=new Set;(!s||s(e))&&o.write(n?e:e.fullpath());let u=[e],f=0,d=()=>{let p=!1;for(;!p;){let h=u.shift();if(!h){f===0&&o.end();return}f++,c.add(h);let m=h.readdirSync();for(let g of m)(!s||s(g))&&(o.write(n?g:g.fullpath())||(p=!0));f--;for(let g of m){let v=g;if(g.isSymbolicLink()){if(!(i&&(v=g.realpathSync())))continue;v.isUnknown()&&v.lstatSync()}v.shouldWalk(c,a)&&u.push(v)}}p&&!o.flowing&&o.once("drain",d)};return d(),o}chdir(e=this.cwd){let r=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[wDe](r)}},V8=class extends rF{sep="\\";constructor(e=process.cwd(),r={}){let{nocase:n=!0}=r;super(e,jre,"\\",{...r,nocase:n}),this.nocase=n;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return jre.parse(e).root.toUpperCase()}newRoot(e){return new eF(this.rootPath,Od,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},G8=class extends rF{sep="/";constructor(e=process.cwd(),r={}){let{nocase:n=!1}=r;super(e,fVt,"/",{...r,nocase:n}),this.nocase=n}parseRootPath(e){return"/"}newRoot(e){return new tF(this.rootPath,Od,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},OS=class extends G8{constructor(e=process.cwd(),r={}){let{nocase:n=!0}=r;super(e,{...r,nocase:n})}},mfn=process.platform==="win32"?eF:tF,SDe=process.platform==="win32"?V8:process.platform==="darwin"?OS:G8;var CVt=t=>t.length>=1,TVt=t=>t.length>=1,Z8=class t{#e;#t;#n;length;#r;#a;#h;#l;#c;#i;#f=!0;constructor(e,r,n,i){if(!CVt(e))throw new TypeError("empty pattern list");if(!TVt(r))throw new TypeError("empty glob list");if(r.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,n<0||n>=this.length)throw new TypeError("index out of range");if(this.#e=e,this.#t=r,this.#n=n,this.#r=i,this.#n===0){if(this.isUNC()){let[s,a,o,c,...u]=this.#e,[f,d,p,h,...m]=this.#t;u[0]===""&&(u.shift(),m.shift());let g=[s,a,o,c,""].join("/"),v=[f,d,p,h,""].join("/");this.#e=[g,...u],this.#t=[v,...m],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[s,...a]=this.#e,[o,...c]=this.#t;a[0]===""&&(a.shift(),c.shift());let u=s+"/",f=o+"/";this.#e=[u,...a],this.#t=[f,...c],this.length=this.#e.length}}}pattern(){return this.#e[this.#n]}isString(){return typeof this.#e[this.#n]=="string"}isGlobstar(){return this.#e[this.#n]===ms}isRegExp(){return this.#e[this.#n]instanceof RegExp}globString(){return this.#h=this.#h||(this.#n===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join("/"):this.#t.join("/"):this.#t.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#a!==void 0?this.#a:this.hasMore()?(this.#a=new t(this.#e,this.#t,this.#n+1,this.#r),this.#a.#i=this.#i,this.#a.#c=this.#c,this.#a.#l=this.#l,this.#a):this.#a=null}isUNC(){let e=this.#e;return this.#c!==void 0?this.#c:this.#c=this.#r==="win32"&&this.#n===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#e;return this.#l!==void 0?this.#l:this.#l=this.#r==="win32"&&this.#n===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#e;return this.#i!==void 0?this.#i:this.#i=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#e[0];return typeof e=="string"&&this.isAbsolute()&&this.#n===0?e:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#f)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#f?!1:(this.#f=!1,!0)}};var PVt=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",K8=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:r,nocase:n,noext:i,noglobstar:s,platform:a=PVt}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=a,this.mmopts={dot:!0,nobrace:r,nocase:n,noext:i,noglobstar:s,optimizationLevel:2,platform:a,nocomment:!0,nonegate:!0};for(let o of e)this.add(o)}add(e){let r=new du(e,this.mmopts);for(let n=0;n<r.set.length;n++){let i=r.set[n],s=r.globParts[n];if(!i||!s)throw new Error("invalid pattern object");for(;i[0]==="."&&s[0]===".";)i.shift(),s.shift();let a=new Z8(i,s,0,this.platform),o=new du(a.globString(),this.mmopts),c=s[s.length-1]==="**",u=a.isAbsolute();u?this.absolute.push(o):this.relative.push(o),c&&(u?this.absoluteChildren.push(o):this.relativeChildren.push(o))}}ignored(e){let r=e.fullpath(),n=`${r}/`,i=e.relative()||".",s=`${i}/`;for(let a of this.relative)if(a.match(i)||a.match(s))return!0;for(let a of this.absolute)if(a.match(r)||a.match(n))return!0;return!1}childrenIgnored(e){let r=e.fullpath()+"/",n=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(n))return!0;for(let i of this.absoluteChildren)if(i.match(r))return!0;return!1}};var Fre=class t{store;constructor(e=new Map){this.store=e}copy(){return new t(new Map(this.store))}hasWalked(e,r){return this.store.get(e.fullpath())?.has(r.globString())}storeWalked(e,r){let n=e.fullpath(),i=this.store.get(n);i?i.add(r.globString()):this.store.set(n,new Set([r.globString()]))}},Mre=class{store=new Map;add(e,r,n){let i=(r?2:0)|(n?1:0),s=this.store.get(e);this.store.set(e,s===void 0?i:i&s)}entries(){return[...this.store.entries()].map(([e,r])=>[e,!!(r&2),!!(r&1)])}},Lre=class{store=new Map;add(e,r){if(!e.canReaddir())return;let n=this.store.get(e);n?n.find(i=>i.globString()===r.globString())||n.push(r):this.store.set(e,[r])}get(e){let r=this.store.get(e);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},IS=class t{hasWalkedCache;matches=new Mre;subwalks=new Lre;patterns;follow;dot;opts;constructor(e,r){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=r?r.copy():new Fre}processPatterns(e,r){this.patterns=r;let n=r.map(i=>[e,i]);for(let[i,s]of n){this.hasWalkedCache.storeWalked(i,s);let a=s.root(),o=s.isAbsolute()&&this.opts.absolute!==!1;if(a){i=i.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let d=s.rest();if(d)s=d;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let c,u,f=!1;for(;typeof(c=s.pattern())=="string"&&(u=s.rest());)i=i.resolve(c),s=u,f=!0;if(c=s.pattern(),u=s.rest(),f){if(this.hasWalkedCache.hasWalked(i,s))continue;this.hasWalkedCache.storeWalked(i,s)}if(typeof c=="string"){let d=c===".."||c===""||c===".";this.matches.add(i.resolve(c),o,d);continue}else if(c===ms){(!i.isSymbolicLink()||this.follow||s.checkFollowGlobstar())&&this.subwalks.add(i,s);let d=u?.pattern(),p=u?.rest();if(!u||(d===""||d===".")&&!p)this.matches.add(i,o,d===""||d===".");else if(d===".."){let h=i.parent||i;p?this.hasWalkedCache.hasWalked(h,p)||this.subwalks.add(h,p):this.matches.add(h,o,!0)}}else c instanceof RegExp&&this.subwalks.add(i,s)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new t(this.opts,this.hasWalkedCache)}filterEntries(e,r){let n=this.subwalks.get(e),i=this.child();for(let s of r)for(let a of n){let o=a.isAbsolute(),c=a.pattern(),u=a.rest();c===ms?i.testGlobstar(s,a,u,o):c instanceof RegExp?i.testRegExp(s,c,u,o):i.testString(s,c,u,o)}return i}testGlobstar(e,r,n,i){if((this.dot||!e.name.startsWith("."))&&(r.hasMore()||this.matches.add(e,i,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,r):e.isSymbolicLink()&&(n&&r.checkFollowGlobstar()?this.subwalks.add(e,n):r.markFollowGlobstar()&&this.subwalks.add(e,r)))),n){let s=n.pattern();if(typeof s=="string"&&s!==".."&&s!==""&&s!==".")this.testString(e,s,n.rest(),i);else if(s===".."){let a=e.parent||e;this.subwalks.add(a,n)}else s instanceof RegExp&&this.testRegExp(e,s,n.rest(),i)}}testRegExp(e,r,n,i){r.test(e.name)&&(n?this.subwalks.add(e,n):this.matches.add(e,i,!1))}testString(e,r,n,i){e.isNamed(r)&&(n?this.subwalks.add(e,n):this.matches.add(e,i,!1))}};var OVt=(t,e)=>typeof t=="string"?new K8([t],e):Array.isArray(t)?new K8(t,e):t,nF=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#t;#n;signal;maxDepth;includeChildMatches;constructor(e,r,n){if(this.patterns=e,this.path=r,this.opts=n,this.#n=!n.posix&&n.platform==="win32"?"\\":"/",this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#t=OVt(n.ignore??[],n),!this.includeChildMatches&&typeof this.#t.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#r(e){return this.seen.has(e)||!!this.#t?.ignored?.(e)}#a(e){return!!this.#t?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||await e.realpath(),!n)return;e=n}let s=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=await s.realpath();a&&(a.isUnknown()||this.opts.stat)&&await a.lstat()}return this.matchCheckTest(s,r)}matchCheckTest(e,r){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!r||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#r(e)?e:void 0}matchCheckSync(e,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||e.realpathSync(),!n)return;e=n}let s=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=s.realpathSync();a&&(a?.isUnknown()||this.opts.stat)&&a.lstatSync()}return this.matchCheckTest(s,r)}matchFinish(e,r){if(this.#r(e))return;if(!this.includeChildMatches&&this.#t?.add){let s=`${e.relativePosix()}/**`;this.#t.add(s)}let n=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(n){let s=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(s+i)}else{let s=this.opts.posix?e.relativePosix():e.relative(),a=this.opts.dotRelative&&!s.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(s?a+s+i:"."+i)}}async match(e,r,n){let i=await this.matchCheck(e,n);i&&this.matchFinish(i,r)}matchSync(e,r,n){let i=this.matchCheckSync(e,n);i&&this.matchFinish(i,r)}walkCB(e,r,n){this.signal?.aborted&&n(),this.walkCB2(e,r,new IS(this.opts),n)}walkCB2(e,r,n,i){if(this.#a(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,r,n,i));return}n.processPatterns(e,r);let s=1,a=()=>{--s===0&&i()};for(let[o,c,u]of n.matches.entries())this.#r(o)||(s++,this.match(o,c,u).then(()=>a()));for(let o of n.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;s++;let c=o.readdirCached();o.calledReaddir()?this.walkCB3(o,c,n,a):o.readdirCB((u,f)=>this.walkCB3(o,f,n,a),!0)}a()}walkCB3(e,r,n,i){n=n.filterEntries(e,r);let s=1,a=()=>{--s===0&&i()};for(let[o,c,u]of n.matches.entries())this.#r(o)||(s++,this.match(o,c,u).then(()=>a()));for(let[o,c]of n.subwalks.entries())s++,this.walkCB2(o,c,n.child(),a);a()}walkCBSync(e,r,n){this.signal?.aborted&&n(),this.walkCB2Sync(e,r,new IS(this.opts),n)}walkCB2Sync(e,r,n,i){if(this.#a(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,r,n,i));return}n.processPatterns(e,r);let s=1,a=()=>{--s===0&&i()};for(let[o,c,u]of n.matches.entries())this.#r(o)||this.matchSync(o,c,u);for(let o of n.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;s++;let c=o.readdirSync();this.walkCB3Sync(o,c,n,a)}a()}walkCB3Sync(e,r,n,i){n=n.filterEntries(e,r);let s=1,a=()=>{--s===0&&i()};for(let[o,c,u]of n.matches.entries())this.#r(o)||this.matchSync(o,c,u);for(let[o,c]of n.subwalks.entries())s++,this.walkCB2Sync(o,c,n.child(),a);a()}},DS=class extends nF{matches=new Set;constructor(e,r,n){super(e,r,n)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},RS=class extends nF{results;constructor(e,r,n){super(e,r,n),this.results=new _0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var DVt=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",ff=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=IVt(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(c=>c.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=e,this.platform=r.platform||DVt,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let c=r.platform==="win32"?V8:r.platform==="darwin"?OS:r.platform?G8:SDe;this.scurry=new c(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let n=this.platform==="darwin"||this.platform==="win32",i={...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},s=this.pattern.map(c=>new du(c,i)),[a,o]=s.reduce((c,u)=>(c[0].push(...u.set),c[1].push(...u.globParts),c),[[],[]]);this.patterns=a.map((c,u)=>{let f=o[u];if(!f)throw new Error("invalid pattern object");return new Z8(c,f,0,this.platform)})}async walk(){return[...await new DS(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new DS(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new RS(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new RS(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var qre=(t,e={})=>{Array.isArray(t)||(t=[t]);for(let r of t)if(new du(r,e).hasMagic())return!0;return!1};function sF(t,e={}){return new ff(t,e).streamSync()}function kDe(t,e={}){return new ff(t,e).stream()}function ADe(t,e={}){return new ff(t,e).walkSync()}async function EDe(t,e={}){return new ff(t,e).walk()}function aF(t,e={}){return new ff(t,e).iterateSync()}function CDe(t,e={}){return new ff(t,e).iterate()}var RVt=sF,$Vt=Object.assign(kDe,{sync:sF}),jVt=aF,NVt=Object.assign(CDe,{sync:aF}),FVt=Object.assign(ADe,{stream:sF,iterate:aF}),iF=Object.assign(EDe,{glob:EDe,globSync:ADe,sync:FVt,globStream:kDe,stream:$Vt,globStreamSync:sF,streamSync:RVt,globIterate:CDe,iterate:NVt,globIterateSync:aF,iterateSync:jVt,Glob:ff,hasMagic:qre,escape:z8,unescape:cf});iF.glob=iF;var MVt=5e3,w0=async({text:t,path:e,root:r,timeout:n,limit:i})=>{let s=e?.startsWith("/")?e.substring(1):e,a=`${e?s+"/":""}**/*${t}*`,o=await iF(a,{cwd:r,absolute:!1,dotRelative:!1,follow:!1,signal:AbortSignal.timeout(n||MVt),maxDepth:5,ignore:["**/node_modules","**/node_modules/**","**/build","**/build/**","**/dist","**/dist/**","**/.git","**/.git/**","**/.nx","**/.nx/**","**/.angular","**/.angular/**","**/coverage","**/coverage/**","**/tmp","**/tmp/**","**/out-tsc","**/out-tsc/**"]});return!i||o.length<i?o:[`Search returned too many results (${o.length}), try again with a more restrictive search.`]};import{execSync as LVt}from"child_process";import{rgPath as qVt}from"@vscode/ripgrep";var BVt=50*1024*1024;function TDe(t,e,r=1e4,n=2e5){try{e.displayText("Mapping project files...");let s=LVt(`"${qVt}" --files`,{cwd:t,encoding:"utf-8",timeout:r,maxBuffer:BVt}).split(`
906
906
  `).filter(Boolean).sort();e.displayText(`... mapped ${s.length} files.`);let a=s.join(`
907
907
  `),o=Math.ceil(a.length/n),c=`
908
908
 
@@ -1408,7 +1408,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
1408
1408
  `,n),a=-1;if(i!==-1&&s!==-1?a=Math.min(i,s):i!==-1?i===t.length-1?a=-1:a=i:s!==-1&&(a=s),a===-1){r=t.slice(n);break}else{let o=t.slice(n,a);e.push(o),n=a+1,t[n-1]==="\r"&&t[n]===`
1409
1409
  `&&n++}}return[e,r]}var IU=class extends TransformStream{constructor({onError:e,onRetry:r,onComment:n}={}){let i;super({start(s){i=OU({onEvent:a=>{s.enqueue(a)},onError(a){e==="terminate"?s.error(a):typeof e=="function"&&e(a)},onRetry:r,onComment:n})},transform(s){i.feed(s)}})}};var f0r={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},p4=class extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}},H7=class{constructor(e,r){var n;this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=TU(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=(n=r?.reconnectionOptions)!==null&&n!==void 0?n:f0r}async _authThenStart(){var e;if(!this._authProvider)throw new Xo("No auth provider");let r;try{r=await Fh(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(e=this.onerror)===null||e===void 0||e.call(this,n),n}if(r!=="AUTHORIZED")throw new Xo;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var e;let r={};if(this._authProvider){let i=await this._authProvider.tokens();i&&(r.Authorization=`Bearer ${i.access_token}`)}this._sessionId&&(r["mcp-session-id"]=this._sessionId),this._protocolVersion&&(r["mcp-protocol-version"]=this._protocolVersion);let n=CU((e=this._requestInit)===null||e===void 0?void 0:e.headers);return new Headers({...r,...n})}async _startOrAuthSse(e){var r,n,i;let{resumptionToken:s}=e;try{let a=await this._commonHeaders();a.set("Accept","text/event-stream"),s&&a.set("last-event-id",s);let o=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,{method:"GET",headers:a,signal:(n=this._abortController)===null||n===void 0?void 0:n.signal});if(!o.ok){if(o.status===401&&this._authProvider)return await this._authThenStart();if(o.status===405)return;throw new p4(o.status,`Failed to open SSE stream: ${o.statusText}`)}this._handleSseStream(o.body,e,!0)}catch(a){throw(i=this.onerror)===null||i===void 0||i.call(this,a),a}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,i=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,e),i)}_scheduleReconnection(e,r=0){var n;let i=this._reconnectionOptions.maxRetries;if(i>0&&r>=i){(n=this.onerror)===null||n===void 0||n.call(this,new Error(`Maximum reconnection attempts (${i}) exceeded.`));return}let s=this._getNextReconnectionDelay(r);setTimeout(()=>{this._startOrAuthSse(e).catch(a=>{var o;(o=this.onerror)===null||o===void 0||o.call(this,new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(e,r+1)})},s)}_handleSseStream(e,r,n){if(!e)return;let{onresumptiontoken:i,replayMessageId:s}=r,a,o=!1;(async()=>{var u,f,d,p;try{let h=e.pipeThrough(new TextDecoderStream).pipeThrough(new IU({onRetry:g=>{this._serverRetryMs=g}})).getReader();for(;;){let{value:g,done:v}=await h.read();if(v)break;if(g.id&&(a=g.id,o=!0,i?.(g.id)),!g.event||g.event==="message")try{let y=mm.parse(JSON.parse(g.data));s!==void 0&&hA(y)&&(y.id=s),(u=this.onmessage)===null||u===void 0||u.call(this,y)}catch(y){(f=this.onerror)===null||f===void 0||f.call(this,y)}}(n||o)&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:i,replayMessageId:s},0)}catch(h){if((d=this.onerror)===null||d===void 0||d.call(this,new Error(`SSE stream disconnected: ${h}`)),(n||o)&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:i,replayMessageId:s},0)}catch(g){(p=this.onerror)===null||p===void 0||p.call(this,new Error(`Failed to reconnect: ${g instanceof Error?g.message:String(g)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Xo("No auth provider");if(await Fh(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Xo("Failed to authorize")}async close(){var e,r;(e=this._abortController)===null||e===void 0||e.abort(),(r=this.onclose)===null||r===void 0||r.call(this)}async send(e,r){var n,i,s,a;try{let{resumptionToken:o,onresumptiontoken:c}=r||{};if(o){this._startOrAuthSse({resumptionToken:o,replayMessageId:IB(e)?e.id:void 0}).catch(v=>{var y;return(y=this.onerror)===null||y===void 0?void 0:y.call(this,v)});return}let u=await this._commonHeaders();u.set("content-type","application/json"),u.set("accept","application/json, text/event-stream");let f={...this._requestInit,method:"POST",headers:u,body:JSON.stringify(e),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},d=await((i=this._fetch)!==null&&i!==void 0?i:fetch)(this._url,f),p=d.headers.get("mcp-session-id");if(p&&(this._sessionId=p),!d.ok){if(d.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new p4(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:y,scope:b}=z7(d);if(this._resourceMetadataUrl=y,this._scope=b,await Fh(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Xo;return this._hasCompletedAuthFlow=!0,this.send(e)}if(d.status===403&&this._authProvider){let{resourceMetadataUrl:y,scope:b,error:x}=z7(d);if(x==="insufficient_scope"){let k=d.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===k)throw new p4(403,"Server returned 403 after trying upscoping");if(b&&(this._scope=b),y&&(this._resourceMetadataUrl=y),this._lastUpscopingHeader=k??void 0,await Fh(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Xo;return this.send(e)}}let v=await d.text().catch(()=>null);throw new Error(`Error POSTing to endpoint (HTTP ${d.status}): ${v}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,d.status===202){nze(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(v=>{var y;return(y=this.onerror)===null||y===void 0?void 0:y.call(this,v)});return}let m=(Array.isArray(e)?e:[e]).filter(v=>"method"in v&&"id"in v&&v.id!==void 0).length>0,g=d.headers.get("content-type");if(m)if(g?.includes("text/event-stream"))this._handleSseStream(d.body,{onresumptiontoken:c},!1);else if(g?.includes("application/json")){let v=await d.json(),y=Array.isArray(v)?v.map(b=>mm.parse(b)):[mm.parse(v)];for(let b of y)(s=this.onmessage)===null||s===void 0||s.call(this,b)}else throw new p4(-1,`Unexpected content type: ${g}`)}catch(o){throw(a=this.onerror)===null||a===void 0||a.call(this,o),o}}get sessionId(){return this._sessionId}async terminateSession(){var e,r,n;if(this._sessionId)try{let i=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:i,signal:(e=this._abortController)===null||e===void 0?void 0:e.signal},a=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,s);if(!a.ok&&a.status!==405)throw new p4(a.status,`Failed to terminate session: ${a.statusText}`);this._sessionId=void 0}catch(i){throw(n=this.onerror)===null||n===void 0||n.call(this,i),i}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r?.onresumptiontoken})}};var RU=class extends Event{constructor(e,r){var n,i;super(e),this.code=(n=r?.code)!=null?n:void 0,this.message=(i=r?.message)!=null?i:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return n(YVe(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(YVe(this),r)}};function d0r(t){let e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function ghe(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(ghe).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${ghe(t.cause)}`:t.message:`${t}`}function YVe(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var eGe=t=>{throw TypeError(t)},Ehe=(t,e,r)=>e.has(t)||eGe("Cannot "+r),tn=(t,e,r)=>(Ehe(t,e,"read from private field"),r?r.call(t):e.get(t)),Xs=(t,e,r)=>e.has(t)?eGe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),$i=(t,e,r,n)=>(Ehe(t,e,"write to private field"),e.set(t,r),r),Mh=(t,e,r)=>(Ehe(t,e,"access private method"),r),Mc,h4,W7,DU,$U,sC,Z7,aC,Em,V7,K7,G7,nC,If,vhe,yhe,bhe,QVe,xhe,_he,iC,whe,She,m4=class extends EventTarget{constructor(e,r){var n,i;super(),Xs(this,If),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Xs(this,Mc),Xs(this,h4),Xs(this,W7),Xs(this,DU),Xs(this,$U),Xs(this,sC),Xs(this,Z7),Xs(this,aC,null),Xs(this,Em),Xs(this,V7),Xs(this,K7,null),Xs(this,G7,null),Xs(this,nC,null),Xs(this,yhe,async s=>{var a;tn(this,V7).reset();let{body:o,redirected:c,status:u,headers:f}=s;if(u===204){Mh(this,If,iC).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?$i(this,W7,new URL(s.url)):$i(this,W7,void 0),u!==200){Mh(this,If,iC).call(this,`Non-200 status code (${u})`,u);return}if(!(f.get("content-type")||"").startsWith("text/event-stream")){Mh(this,If,iC).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(tn(this,Mc)===this.CLOSED)return;$i(this,Mc,this.OPEN);let d=new Event("open");if((a=tn(this,nC))==null||a.call(this,d),this.dispatchEvent(d),typeof o!="object"||!o||!("getReader"in o)){Mh(this,If,iC).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}let p=new TextDecoder,h=o.getReader(),m=!0;do{let{done:g,value:v}=await h.read();v&&tn(this,V7).feed(p.decode(v,{stream:!g})),g&&(m=!1,tn(this,V7).reset(),Mh(this,If,whe).call(this))}while(m)}),Xs(this,bhe,s=>{$i(this,Em,void 0),!(s.name==="AbortError"||s.type==="aborted")&&Mh(this,If,whe).call(this,ghe(s))}),Xs(this,xhe,s=>{typeof s.id=="string"&&$i(this,aC,s.id);let a=new MessageEvent(s.event||"message",{data:s.data,origin:tn(this,W7)?tn(this,W7).origin:tn(this,h4).origin,lastEventId:s.id||""});tn(this,G7)&&(!s.event||s.event==="message")&&tn(this,G7).call(this,a),this.dispatchEvent(a)}),Xs(this,_he,s=>{$i(this,sC,s)}),Xs(this,She,()=>{$i(this,Z7,void 0),tn(this,Mc)===this.CONNECTING&&Mh(this,If,vhe).call(this)});try{if(e instanceof URL)$i(this,h4,e);else if(typeof e=="string")$i(this,h4,new URL(e,p0r()));else throw new Error("Invalid URL")}catch{throw d0r("An invalid or illegal string was specified")}$i(this,V7,OU({onEvent:tn(this,xhe),onRetry:tn(this,_he)})),$i(this,Mc,this.CONNECTING),$i(this,sC,3e3),$i(this,$U,(n=r?.fetch)!=null?n:globalThis.fetch),$i(this,DU,(i=r?.withCredentials)!=null?i:!1),Mh(this,If,vhe).call(this)}get readyState(){return tn(this,Mc)}get url(){return tn(this,h4).href}get withCredentials(){return tn(this,DU)}get onerror(){return tn(this,K7)}set onerror(e){$i(this,K7,e)}get onmessage(){return tn(this,G7)}set onmessage(e){$i(this,G7,e)}get onopen(){return tn(this,nC)}set onopen(e){$i(this,nC,e)}addEventListener(e,r,n){let i=r;super.addEventListener(e,i,n)}removeEventListener(e,r,n){let i=r;super.removeEventListener(e,i,n)}close(){tn(this,Z7)&&clearTimeout(tn(this,Z7)),tn(this,Mc)!==this.CLOSED&&(tn(this,Em)&&tn(this,Em).abort(),$i(this,Mc,this.CLOSED),$i(this,Em,void 0))}};Mc=new WeakMap,h4=new WeakMap,W7=new WeakMap,DU=new WeakMap,$U=new WeakMap,sC=new WeakMap,Z7=new WeakMap,aC=new WeakMap,Em=new WeakMap,V7=new WeakMap,K7=new WeakMap,G7=new WeakMap,nC=new WeakMap,If=new WeakSet,vhe=function(){$i(this,Mc,this.CONNECTING),$i(this,Em,new AbortController),tn(this,$U)(tn(this,h4),Mh(this,If,QVe).call(this)).then(tn(this,yhe)).catch(tn(this,bhe))},yhe=new WeakMap,bhe=new WeakMap,QVe=function(){var t;let e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...tn(this,aC)?{"Last-Event-ID":tn(this,aC)}:void 0},cache:"no-store",signal:(t=tn(this,Em))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},xhe=new WeakMap,_he=new WeakMap,iC=function(t,e){var r;tn(this,Mc)!==this.CLOSED&&$i(this,Mc,this.CLOSED);let n=new RU("error",{code:e,message:t});(r=tn(this,K7))==null||r.call(this,n),this.dispatchEvent(n)},whe=function(t,e){var r;if(tn(this,Mc)===this.CLOSED)return;$i(this,Mc,this.CONNECTING);let n=new RU("error",{code:e,message:t});(r=tn(this,K7))==null||r.call(this,n),this.dispatchEvent(n),$i(this,Z7,setTimeout(tn(this,She),tn(this,sC)))},She=new WeakMap,m4.CONNECTING=0,m4.OPEN=1,m4.CLOSED=2;function p0r(){let t="document"in globalThis?globalThis.document:void 0;return t&&typeof t=="object"&&"baseURI"in t&&typeof t.baseURI=="string"?t.baseURI:void 0}var khe=class extends Error{constructor(e,r,n){super(`SSE error: ${r}`),this.code=e,this.event=n}},J7=class{constructor(e,r){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=r?.eventSourceInit,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=TU(r?.fetch,r?.requestInit)}async _authThenStart(){var e;if(!this._authProvider)throw new Xo("No auth provider");let r;try{r=await Fh(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(e=this.onerror)===null||e===void 0||e.call(this,n),n}if(r!=="AUTHORIZED")throw new Xo;return await this._startOrAuth()}async _commonHeaders(){var e;let r={};if(this._authProvider){let n=await this._authProvider.tokens();n&&(r.Authorization=`Bearer ${n.access_token}`)}return this._protocolVersion&&(r["mcp-protocol-version"]=this._protocolVersion),new Headers({...r,...(e=this._requestInit)===null||e===void 0?void 0:e.headers})}_startOrAuth(){var e,r,n;let i=(n=(r=(e=this===null||this===void 0?void 0:this._eventSourceInit)===null||e===void 0?void 0:e.fetch)!==null&&r!==void 0?r:this._fetch)!==null&&n!==void 0?n:fetch;return new Promise((s,a)=>{this._eventSource=new m4(this._url.href,{...this._eventSourceInit,fetch:async(o,c)=>{let u=await this._commonHeaders();u.set("Accept","text/event-stream");let f=await i(o,{...c,headers:u});if(f.status===401&&f.headers.has("www-authenticate")){let{resourceMetadataUrl:d,scope:p}=z7(f);this._resourceMetadataUrl=d,this._scope=p}return f}}),this._abortController=new AbortController,this._eventSource.onerror=o=>{var c;if(o.code===401&&this._authProvider){this._authThenStart().then(s,a);return}let u=new khe(o.code,o.message,o);a(u),(c=this.onerror)===null||c===void 0||c.call(this,u)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",o=>{var c;let u=o;try{if(this._endpoint=new URL(u.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(f){a(f),(c=this.onerror)===null||c===void 0||c.call(this,f),this.close();return}s()}),this._eventSource.onmessage=o=>{var c,u;let f=o,d;try{d=mm.parse(JSON.parse(f.data))}catch(p){(c=this.onerror)===null||c===void 0||c.call(this,p);return}(u=this.onmessage)===null||u===void 0||u.call(this,d)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new Xo("No auth provider");if(await Fh(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Xo("Failed to authorize")}async close(){var e,r,n;(e=this._abortController)===null||e===void 0||e.abort(),(r=this._eventSource)===null||r===void 0||r.close(),(n=this.onclose)===null||n===void 0||n.call(this)}async send(e){var r,n,i;if(!this._endpoint)throw new Error("Not connected");try{let s=await this._commonHeaders();s.set("content-type","application/json");let a={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(e),signal:(r=this._abortController)===null||r===void 0?void 0:r.signal},o=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._endpoint,a);if(!o.ok){if(o.status===401&&this._authProvider){let{resourceMetadataUrl:u,scope:f}=z7(o);if(this._resourceMetadataUrl=u,this._scope=f,await Fh(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Xo;return this.send(e)}let c=await o.text().catch(()=>null);throw new Error(`Error POSTing to endpoint (HTTP ${o.status}): ${c}`)}}catch(s){throw(i=this.onerror)===null||i===void 0||i.call(this,s),s}}setProtocolVersion(e){this._protocolVersion=e}};import{spawn as h0r}from"child_process";var tGe=15e3,m0r=300*1e3,jU=class extends Tr{constructor(r,n,i,s,a){super(new bd("not used"),r.name);this.serverConfig=r;this.name=r.name,this.mcpInteractor=n,this.mcpUserService=i,this.mcpProjectName=s,this.mcpBaseUrl=a}clientPromise;toolsPromise;inspectorProcess;transport;serverProcessPid=null;name="Not defined yet";errorLogged=!1;lastUsed=Date.now();oauthProvider;_killed=!1;_usingLegacySSE=!1;_reconnectAttempts=0;_reconnectDelay=2e3;mcpInteractor;mcpUserService;mcpProjectName;mcpBaseUrl;async handleOAuthCallback(r){await this.oauthProvider?.handleCallback(r)}async kill(){if(this._killed=!0,this._reconnectAttempts=0,this._reconnectDelay=2e3,this.tools=[],console.log(`Closing mcp client ${this.serverConfig.name}`),this.inspectorProcess){console.log(`Stopping MCP Inspector process for ${this.serverConfig.name}`);try{this.inspectorProcess.kill("SIGTERM"),await new Promise(r=>setTimeout(r,100)),this.inspectorProcess.killed||this.inspectorProcess.kill("SIGKILL")}catch(r){console.log(`Error killing inspector process: ${r}`)}this.inspectorProcess=void 0}try{await(await this.clientPromise)?.close()}catch{console.log(`MCP client ${this.serverConfig.name} was already failed/closed`)}if(this.transport){try{await this.transport.close(),console.log(`Transport closed for ${this.serverConfig.name}`),this.serverProcessPid=null}catch(r){console.log(`Error closing transport for ${this.serverConfig.name}: ${r}`)}this.transport=void 0}if(this.serverProcessPid){try{process.kill(this.serverProcessPid,0),console.log(`Force killing MCP server process ${this.serverProcessPid} for ${this.serverConfig.name}`),process.kill(this.serverProcessPid,"SIGTERM"),await new Promise(r=>setTimeout(r,100));try{process.kill(this.serverProcessPid,0),process.kill(this.serverProcessPid,"SIGKILL"),console.log(`Force killed with SIGKILL: ${this.serverProcessPid}`)}catch{}}catch(r){r.code!=="ESRCH"&&console.log(`Error killing MCP server process ${this.serverProcessPid}: ${r}`)}this.serverProcessPid=null}console.log(`Closed mcp client ${this.serverConfig.name}`)}async buildTools(r,n){if(this.tools.length)return this.tools;if(!this.serverConfig.enabled)return console.debug(`[MCP] Server ${this.serverConfig.name} is disabled, skipping`),[];try{this.clientPromise||(console.log(`Initializing MCP server ${this.serverConfig.name}...`),this.clientPromise=this.buildClient());let i=await this.clientPromise;this.toolsPromise||(this.toolsPromise=this.buildInternalTools(i));let s=await this.toolsPromise;return console.log(`[MCP] Server ${this.serverConfig.name} loaded ${s.length} tools successfully`),s}catch(i){let s=i instanceof Error?i.message:String(i);return this.errorLogged||(this.errorLogged=!0,console.error(`[MCP] Server ${this.serverConfig.name} failed to initialize: ${s}`),console.warn(`[MCP] Server '${this.serverConfig.name}' is unavailable and will be skipped: ${s}`)),[]}}async buildClient(){let r=new wU({name:"Coday MCP Client",version:"1.0.0"},{capabilities:{}});if(this.serverConfig.url)console.log(`[MCP] ${this.serverConfig.name}: building remote transport for ${this.serverConfig.url}`),this.transport=this.buildRemoteTransport();else if(this.serverConfig.command){let n={};if(this.serverConfig.debug&&!this.inspectorProcess){let s=["@modelcontextprotocol/inspector",this.serverConfig.command,...this.serverConfig.args||[]],a={};this.serverConfig.env&&Object.keys(this.serverConfig.env).length>0&&(a.env=this.serverConfig.env),this.serverConfig.cwd&&(a.cwd=this.serverConfig.cwd),console.log(`Starting MCP Inspector process for ${this.serverConfig.name}}`),this.inspectorProcess=h0r("npx",s,{stdio:"inherit",...a}),this.inspectorProcess.on("exit",(o,c)=>{console.log(`MCP Inspector process for ${this.serverConfig.name} exited (code: ${o}, signal: ${c})`)})}n.command=this.serverConfig.command,n.args=this.serverConfig.args||[],this.serverConfig.env&&Object.keys(this.serverConfig.env).length>0&&(n.env=this.serverConfig.env,console.log(`Using custom environment variables for MCP server ${this.serverConfig.name}`)),this.serverConfig.cwd&&(n.cwd=this.serverConfig.cwd,console.log(`Using working directory: ${this.serverConfig.cwd}`)),this.transport=new kU(n),console.log(`Starting MCP server ${this.serverConfig.name} with command: ${n.command}`),this.transport.onerror=i=>{console.error(`MCP server ${this.serverConfig.name} transport error:`,i)},this.transport.onclose=()=>{console.log(`MCP server ${this.serverConfig.name} transport closed`),this.serverProcessPid=null}}else throw new Error(`MCP server ${this.serverConfig.name} has neither url nor command configured.`);try{return await this.connectWithTimeout(r),this.serverConfig.url&&this.wireRemoteReconnect(r),this.transport&&"pid"in this.transport?(this.serverProcessPid=this.transport.pid,console.log(`Successfully connected to MCP server ${this.serverConfig.name} (PID: ${this.serverProcessPid})`)):console.log(`Successfully connected to MCP server ${this.serverConfig.name}${this._usingLegacySSE?" (legacy SSE transport)":""}`),this._reconnectAttempts=0,this._reconnectDelay=2e3,r}catch(n){await this.cleanupOnError();let i=n instanceof Error?n.message:String(n);throw console.error(`Failed to connect to MCP server ${this.serverConfig.name}: ${i}`),i.includes("docker")||i.includes("Docker")||i.includes("container")||i.includes("Container")?new Error(`MCP server ${this.serverConfig.name} failed to start. This may be because Docker is not available or the Docker container failed to start. Original error: ${i}`):i.includes("timeout")||i.includes("Connection timeout")?new Error(`MCP server ${this.serverConfig.name} did not respond within ${tGe}ms. Check if the server command is correct and the server starts quickly. Original error: ${i}`):i.includes("ENOENT")||i.includes("command not found")?new Error(`MCP server ${this.serverConfig.name} command not found. Check that the command '${this.serverConfig.command}' is available in your PATH. Original error: ${i}`):new Error(`MCP server ${this.serverConfig.name} connection failed: ${i}`)}}async connectWithTimeout(r){let n=!!this.serverConfig.url,i=this.serverConfig.oauth2?m0r:tGe,s=async()=>{console.log(`[MCP] ${this.serverConfig.name}: connecting (timeout=${i}ms)...`);let a=r.connect(this.transport),o,c=new Promise((u,f)=>{o=setTimeout(()=>f(new Error(`Connection timeout after ${i}ms`)),i)});try{await Promise.race([a,c])}finally{clearTimeout(o)}};if(!n){await s();return}try{await s(),this._usingLegacySSE=!1}catch(a){let o=a instanceof Error?a.message:String(a),c=this.oauthProvider?.waitForAuth();if(c){console.log(`[MCP] ${this.serverConfig.name}: waiting for OAuth authorization to complete...`),await c;try{await this.transport.close()}catch{}this.transport=this.buildRemoteTransport(),this._usingLegacySSE=!1,console.log(`[MCP] ${this.serverConfig.name}: OAuth complete, retrying connection`),await s();return}if(!this.shouldFallbackToSSE(o))throw a;console.warn(`[MCP] ${this.serverConfig.name}: StreamableHTTP connection failed (${o}), falling back to legacy SSEClientTransport`);try{await this.transport.close()}catch{}let u=new URL(this.serverConfig.url);this.oauthProvider?this.transport=new J7(u,{authProvider:this.oauthProvider}):this.serverConfig.authToken?this.transport=new J7(u,{requestInit:{headers:{Authorization:`Bearer ${this.serverConfig.authToken}`}}}):this.transport=new J7(u),this._usingLegacySSE=!0,console.log(`[MCP] ${this.serverConfig.name}: retrying with legacy SSE transport`),await s()}}shouldFallbackToSSE(r){return!!(/\b4\d{2}\b/.test(r)||/not supported|method not allowed|unsupported/i.test(r))}wireRemoteReconnect(r){if(!this.transport)return;let n=5,i=3e4;this.transport.onclose=()=>{if(this._killed){console.log(`[MCP] ${this.serverConfig.name}: transport closed (killed, no reconnect)`);return}if(this._reconnectAttempts>=n){console.error(`[MCP] ${this.serverConfig.name}: transport closed after ${n} reconnect attempts \u2014 giving up`);return}let s=++this._reconnectAttempts,a=this._reconnectDelay;this._reconnectDelay=Math.min(this._reconnectDelay*2,i),console.warn(`[MCP] ${this.serverConfig.name}: transport closed unexpectedly \u2014 reconnecting in ${a}ms (attempt ${s}/${n})`),setTimeout(async()=>{if(this._killed){console.log(`[MCP] ${this.serverConfig.name}: reconnect cancelled (killed)`);return}console.log(`[MCP] ${this.serverConfig.name}: attempting reconnect #${s}...`),this.clientPromise=void 0,this.toolsPromise=void 0,this.tools=[],this.errorLogged=!1,this._usingLegacySSE=!1,this.transport=this.buildRemoteTransport();try{await this.connectWithTimeout(r),this.wireRemoteReconnect(r),this.clientPromise=Promise.resolve(r),console.log(`[MCP] ${this.serverConfig.name}: reconnected successfully (attempt ${s})`),this._reconnectAttempts=0,this._reconnectDelay=2e3}catch(o){let c=o instanceof Error?o.message:String(o);console.error(`[MCP] ${this.serverConfig.name}: reconnect #${s} failed: ${c}`)}},a)}}buildRemoteTransport(){let r=new URL(this.serverConfig.url);if(this.serverConfig.oauth2){if(!this.mcpInteractor||!this.mcpUserService||!this.mcpProjectName)throw new Error(`MCP server ${this.serverConfig.name}: oauth2 requires interactor, userService and projectName \u2014 pass them to McpToolsFactory constructor`);let n=this.serverConfig.oauthRedirectUri??(this.mcpBaseUrl?`${this.mcpBaseUrl}/oauth/callback`:void 0);if(!n)throw new Error(`MCP server ${this.serverConfig.name}: oauth2 requires a redirect URI \u2014 set oauthRedirectUri in the server config or ensure mcpBaseUrl is provided`);console.log(`[MCP] ${this.serverConfig.name}: using OAuth 2.1 transport (redirectUri=${n})`),this.oauthProvider=new SB(this.mcpInteractor,this.mcpUserService,this.mcpProjectName,this.serverConfig.id,n,this.serverConfig.oauthClientId,this.serverConfig.oauthClientSecret,this.serverConfig.oauthScope),console.log(`[MCP] ${this.serverConfig.name}: McpOAuthProvider created for mcpId=${this.serverConfig.id}${this.serverConfig.oauthClientId?` (static client_id=${this.serverConfig.oauthClientId})`:" (dynamic registration)"}`);let i=new H7(r,{authProvider:this.oauthProvider});return this.oauthProvider.setFinishAuth(s=>i.finishAuth(s)),console.log(`[MCP] ${this.serverConfig.name}: OAuth transport ready`),i}if(this.serverConfig.authToken){let n={headers:{Authorization:`Bearer ${this.serverConfig.authToken}`}};return console.log(`[MCP] ${this.serverConfig.name}: using static Bearer token`),new H7(r,{requestInit:n})}return console.log(`[MCP] ${this.serverConfig.name}: connecting without authentication`),new H7(r)}async cleanupOnError(){if(console.log(`Cleaning up failed MCP connection for ${this.serverConfig.name}`),this.inspectorProcess){try{this.inspectorProcess.kill("SIGTERM"),await new Promise(r=>setTimeout(r,100)),this.inspectorProcess.killed||this.inspectorProcess.kill("SIGKILL")}catch(r){console.log(`Error killing inspector during cleanup: ${r}`)}this.inspectorProcess=void 0}if(this.transport){try{await this.transport.close()}catch(r){console.log(`Error closing transport during cleanup: ${r}`)}this.transport=void 0}if(this.serverProcessPid){try{process.kill(this.serverProcessPid,0),console.log(`Force killing MCP server process ${this.serverProcessPid} for ${this.serverConfig.name}`),process.kill(this.serverProcessPid,"SIGTERM"),await new Promise(r=>setTimeout(r,100));try{process.kill(this.serverProcessPid,0),process.kill(this.serverProcessPid,"SIGKILL"),console.log(`Force killed with SIGKILL: ${this.serverProcessPid}`)}catch{}}catch(r){r.code!=="ESRCH"&&console.log(`Error killing MCP server process ${this.serverProcessPid}: ${r}`)}this.serverProcessPid=null}}async buildInternalTools(r){let n=[];console.log(`[MCP] ${this.serverConfig.name}: listing resource templates...`);try{let i=await r.listResourceTemplates();if(i&&i.templates&&Array.isArray(i.templates)){console.log(`[MCP] ${this.serverConfig.name}: found ${i.templates.length} resource template(s)`);for(let s of i.templates)n.push(this.createResourceTool(this.serverConfig,r,s))}}catch(i){i instanceof Error&&!i.message.includes("-32601: Method not found")?console.warn(`[MCP] Error listing resource templates from server ${this.serverConfig.name}: ${i}`):console.debug(`[MCP] Server ${this.serverConfig.name} doesn't support resource templates, continuing with tools only.`)}console.log(`[MCP] ${this.serverConfig.name}: listing tools...`);try{let i=await r.listTools();if(i&&i.tools&&Array.isArray(i.tools)){console.log(`[MCP] ${this.serverConfig.name}: found ${i.tools.length} tool(s): ${i.tools.map(s=>s.name).join(", ")}`);for(let s of i.tools)n.push(this.createFunctionTool(this.serverConfig,r,s))}}catch(i){console.warn(`[MCP] Error listing tools from server ${this.serverConfig.name}: ${i}`)}if(this.serverConfig.debug){let i=n.map(s=>`- ${s.function.name}
1410
1410
  `).join();console.debug(`[MCP] ${this.serverConfig.name}:
1411
- ${i}`)}return n}createResourceTool(r,n,i){let s=`mcp__${r.id}__${i.name}`,a=async u=>{try{this.lastUsed=Date.now();let f=i.uriTemplate.replace(/\{([^}]+)\}/g,(p,h)=>encodeURIComponent(u[h]||"")),d=await n.readResource({uri:f});if(!d||!d.contents)throw new Error(`No content returned from resource ${i.name}`);return d.contents.map(p=>"text"in p?{uri:p.uri,text:p.text,mimeType:p.mimeType||"text/plain"}:"blob"in p?{uri:p.uri,blob:p.blob,mimeType:p.mimeType||"application/octet-stream"}:p)}catch(f){throw console.error(`[MCP] Error retrieving resource ${i.name}: ${f}`),new Error(`Failed to retrieve resource: ${f}`)}},o={},c=i.uriTemplate.match(/\{([^}]+)\}/g)||[];for(let u of c){let f=u.slice(1,-1);o[f]={type:"string",description:`Parameter ${f} for resource ${i.name}`}}return{type:"function",function:{name:s,description:i.description||`Resource from MCP server ${r.name}`,parameters:{type:"object",properties:o},parse:JSON.parse,function:a}}}createFunctionTool(r,n,i){let s=`${r.name}__${i.name}`,a=async o=>{this.lastUsed=Date.now(),this.serverConfig.debug&&console.debug(`[MCP] ${s} input:
1411
+ ${i}`)}return n}sanitizeToolName(r){return r.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,128)}createResourceTool(r,n,i){let s=this.sanitizeToolName(`mcp__${r.id}__${i.name}`),a=async u=>{try{this.lastUsed=Date.now();let f=i.uriTemplate.replace(/\{([^}]+)\}/g,(p,h)=>encodeURIComponent(u[h]||"")),d=await n.readResource({uri:f});if(!d||!d.contents)throw new Error(`No content returned from resource ${i.name}`);return d.contents.map(p=>"text"in p?{uri:p.uri,text:p.text,mimeType:p.mimeType||"text/plain"}:"blob"in p?{uri:p.uri,blob:p.blob,mimeType:p.mimeType||"application/octet-stream"}:p)}catch(f){throw console.error(`[MCP] Error retrieving resource ${i.name}: ${f}`),new Error(`Failed to retrieve resource: ${f}`)}},o={},c=i.uriTemplate.match(/\{([^}]+)\}/g)||[];for(let u of c){let f=u.slice(1,-1);o[f]={type:"string",description:`Parameter ${f} for resource ${i.name}`}}return{type:"function",function:{name:s,description:i.description||`Resource from MCP server ${r.name}`,parameters:{type:"object",properties:o},parse:JSON.parse,function:a}}}createFunctionTool(r,n,i){let s=this.sanitizeToolName(`${r.name}__${i.name}`),a=async o=>{this.lastUsed=Date.now(),this.serverConfig.debug&&console.debug(`[MCP] ${s} input:
1412
1412
 
1413
1413
  \`\`\`json
1414
1414
  `+JSON.stringify(o)+"\n```");try{let c=await n.callTool({name:i.name,arguments:o});if(this.serverConfig.debug&&console.debug("[MCP] Tool output:\n\n```json\n"+JSON.stringify(c)+"\n```"),c&&"content"in c&&Array.isArray(c.content)){let u=c.content.map(f=>f.type==="text"?f.text:f.type==="image"&&f.data?{type:"image",content:f.data,mimeType:f.mimeType||"image/png",...f.width&&{width:f.width},...f.height&&{height:f.height}}:f.type==="resource"?f.resource:f);return u.length===1?u[0]:u}else if(c&&"toolResult"in c)return c.toolResult;return c}catch(c){throw console.error(`[MCP] Error calling function ${i.name}: ${c}`),new Error(`Failed to call function: ${c}`)}};return{type:"function",function:{name:s,description:i.description||`Function from MCP server ${r.name}`,parameters:{type:"object",properties:i.inputSchema?.properties||{}},parse:JSON.parse,function:a}}}};var oC=class extends Tr{constructor(r,n,i,s){super(r,n,i);this.baseUrl=s}static TYPE="CORE";async buildTools(r,n){return[{type:"function",function:{name:`${this.name}__get_context_info`,description:"Get current contextual information including time, date, username, and conversation URL",parameters:{type:"object",properties:{}},parse:JSON.parse,function:async()=>{let i=new Date,s=r.aiThread?.id??"no-thread",a=r.project.name??"no-project",o={currentTime:i.toISOString(),currentDate:i.toISOString().split("T")[0],dayOfWeek:i.toLocaleDateString("en-US",{weekday:"long"}),username:r.username,threadId:s};if(this.baseUrl){let c=this.baseUrl,u=c.endsWith("://")?"":"/";o.conversationUrl=`${c}${u}project/${a}/thread/${s}`}return JSON.stringify(o,null,2)}}},{type:"function",function:{name:`${this.name}__wait`,description:`Pause execution for a specified number of seconds.