@easbot/ollama-sdk 0.1.2 → 0.1.3

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.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import Rn,{win32,posix}from'path';import Cn,{realpath,readlink,readdir,lstat}from'fs/promises';import*as Zo from'fs';import {realpathSync,createWriteStream,readlinkSync,readdirSync,readdir as readdir$1,lstatSync}from'fs';import _a from'zod';import {fileURLToPath}from'url';import {EventEmitter}from'events';import Yr from'stream';import {StringDecoder}from'string_decoder';var _n=Object.defineProperty;var zi=e=>{throw TypeError(e)};var Fn=(e,t,s)=>t in e?_n(e,t,{enumerable:true,configurable:true,writable:true,value:s}):e[t]=s;var u=(e,t,s)=>Fn(e,typeof t!="symbol"?t+"":t,s),ai=(e,t,s)=>t.has(e)||zi("Cannot "+s);var r=(e,t,s)=>(ai(e,t,"read from private field"),s?s.call(e):t.get(e)),y=(e,t,s)=>t.has(e)?zi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),d=(e,t,s,i)=>(ai(e,t,"write to private field"),t.set(e,s),s),g=(e,t,s)=>(ai(e,t,"access private method"),s);var _s=(e,t,s,i)=>({set _(n){d(e,t,n);},get _(){return r(e,t,i)}});var Fs=class{constructor(t="http://localhost:11434"){this.baseURL=t;}async*streamChat(t){let s=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:true})});if(!s.ok)throw new Error(`Ollama API error: ${s.status} ${s.statusText}`);if(!s.body)throw new Error("Response body is null");let i=s.body.getReader(),n=new TextDecoder,o="";try{for(;;){let{done:a,value:h}=await i.read();if(a){if(o.trim())try{yield JSON.parse(o);}catch{console.error("Failed to parse final chunk:",o);}break}o+=n.decode(h,{stream:!0});let l=o.split(`
2
- `);o=l.pop()||"";for(let c of l){let f=c.trim();if(f)try{yield JSON.parse(f);}catch{console.error("Failed to parse chunk:",f);}}}}finally{i.releaseLock();}}async chat(t){let s=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:false})});if(!s.ok)throw new Error(`Ollama API error: ${s.status} ${s.statusText}`);return s.json()}};var Me={numCtx:32768,temperature:.7,topK:40,topP:.9,repeatPenalty:1.1,numPredict:32e3},Pn=["numCtx","repeatPenalty","numPredict"];var Qt=class extends Error{constructor(s,i){super(s);this.cause=i;this.name="OllamaError",Object.setPrototypeOf(this,new.target.prototype);}},hi=class extends Qt{constructor(s,i,n){super(s,n);this.url=i;this.name="ConnectionError";}},li=class extends Qt{constructor(s,i){super(`Model not found: ${s}`,i);this.modelId=s;this.name="ModelNotFoundError";}},ci=class extends Qt{constructor(s,i,n,o){super(s,o);this.field=i;this.value=n;this.name="ValidationError";}},ui=class extends Qt{constructor(s,i,n){super(s,n);this.timeoutMs=i;this.name="TimeoutError";}},Je=class extends Qt{constructor(s,i,n){super(`Invalid tool definition for "${s}": missing ${i}`,n);this.toolName=s;this.missingField=i;this.name="InvalidToolDefinitionError";}};var Fr=(e,t,s)=>{let i=e instanceof RegExp?$i(e,s):e,n=t instanceof RegExp?$i(t,s):t,o=i!==null&&n!=null&&Dn(i,n,s);return o&&{start:o[0],end:o[1],pre:s.slice(0,o[0]),body:s.slice(o[0]+i.length,o[1]),post:s.slice(o[1]+n.length)}},$i=(e,t)=>{let s=t.match(e);return s?s[0]:null},Dn=(e,t,s)=>{let i,n,o,a,h,l=s.indexOf(e),c=s.indexOf(t,l+1),f=l;if(l>=0&&c>0){if(e===t)return [l,c];for(i=[],o=s.length;f>=0&&!h;){if(f===l)i.push(f),l=s.indexOf(e,f+1);else if(i.length===1){let p=i.pop();p!==void 0&&(h=[p,c]);}else n=i.pop(),n!==void 0&&n<o&&(o=n,a=c),c=s.indexOf(t,f+1);f=l<c&&l>=0?l:c;}i.length&&a!==void 0&&(h=[o,a]);}return h},Pr="\0SLASH"+Math.random()+"\0",Dr="\0OPEN"+Math.random()+"\0",Pi="\0CLOSE"+Math.random()+"\0",Nr="\0COMMA"+Math.random()+"\0",Ir="\0PERIOD"+Math.random()+"\0",Nn=new RegExp(Pr,"g"),In=new RegExp(Dr,"g"),jn=new RegExp(Pi,"g"),Wn=new RegExp(Nr,"g"),zn=new RegExp(Ir,"g"),$n=/\\\\/g,Un=/\\{/g,Bn=/\\}/g,Gn=/\\,/g,Vn=/\\./g,qn=1e5;function di(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Jn(e){return e.replace($n,Pr).replace(Un,Dr).replace(Bn,Pi).replace(Gn,Nr).replace(Vn,Ir)}function Hn(e){return e.replace(Nn,"\\").replace(In,"{").replace(jn,"}").replace(Wn,",").replace(zn,".")}function jr(e){if(!e)return [""];let t=[],s=Fr("{","}",e);if(!s)return e.split(",");let{pre:i,body:n,post:o}=s,a=i.split(",");a[a.length-1]+="{"+n+"}";let h=jr(o);return o.length&&(a[a.length-1]+=h.shift(),a.push.apply(a,h)),t.push.apply(t,a),t}function Zn(e,t={}){if(!e)return [];let{max:s=qn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),ts(Jn(e),s,true).map(Hn)}function Kn(e){return "{"+e+"}"}function Yn(e){return /^-?0\d/.test(e)}function Qn(e,t){return e<=t}function Xn(e,t){return e>=t}function ts(e,t,s){let i=[],n=Fr("{","}",e);if(!n)return [e];let o=n.pre,a=n.post.length?ts(n.post,t,false):[""];if(/\$$/.test(n.pre))for(let h=0;h<a.length&&h<t;h++){let l=o+"{"+n.body+"}"+a[h];i.push(l);}else {let h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),c=h||l,f=n.body.indexOf(",")>=0;if(!c&&!f)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+Pi+n.post,ts(e,t,true)):[e];let p;if(c)p=n.body.split(/\.\./);else if(p=jr(n.body),p.length===1&&p[0]!==void 0&&(p=ts(p[0],t,false).map(Kn),p.length===1))return a.map(S=>n.pre+p[0]+S);let m;if(c&&p[0]!==void 0&&p[1]!==void 0){let S=di(p[0]),b=di(p[1]),v=Math.max(p[0].length,p[1].length),E=p.length===3&&p[2]!==void 0?Math.abs(di(p[2])):1,w=Qn;b<S&&(E*=-1,w=Xn);let M=p.some(Yn);m=[];for(let C=S;w(C,b);C+=E){let O;if(l)O=String.fromCharCode(C),O==="\\"&&(O="");else if(O=String(C),M){let k=v-O.length;if(k>0){let T=new Array(k+1).join("0");C<0?O="-"+T+O.slice(1):O=T+O;}}m.push(O);}}else {m=[];for(let S=0;S<p.length;S++)m.push.apply(m,ts(p[S],t,false));}for(let S=0;S<m.length;S++)for(let b=0;b<a.length&&i.length<t;b++){let v=o+m[S]+a[b];(!s||c||v)&&i.push(v);}}return i}var Ks=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},to={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",true],"[:alpha:]":["\\p{L}\\p{Nl}",true],"[:ascii:]":["\\x00-\\x7f",false],"[:blank:]":["\\p{Zs}\\t",true],"[:cntrl:]":["\\p{Cc}",true],"[:digit:]":["\\p{Nd}",true],"[:graph:]":["\\p{Z}\\p{C}",true,true],"[:lower:]":["\\p{Ll}",true],"[:print:]":["\\p{C}",true],"[:punct:]":["\\p{P}",true],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",true],"[:upper:]":["\\p{Lu}",true],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",true],"[:xdigit:]":["A-Fa-f0-9",false]},He=e=>e.replace(/[[\]\\-]/g,"\\$&"),eo=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ui=e=>e.join(""),so=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let i=[],n=[],o=s+1,a=false,h=false,l=false,c=false,f=s,p="";t:for(;o<e.length;){let b=e.charAt(o);if((b==="!"||b==="^")&&o===s+1){c=true,o++;continue}if(b==="]"&&a&&!l){f=o+1;break}if(a=true,b==="\\"&&!l){l=true,o++;continue}if(b==="["&&!l){for(let[v,[E,w,M]]of Object.entries(to))if(e.startsWith(v,o)){if(p)return ["$.",false,e.length-s,true];o+=v.length,M?n.push(E):i.push(E),h=h||w;continue t}}if(l=false,p){b>p?i.push(He(p)+"-"+He(b)):b===p&&i.push(He(b)),p="",o++;continue}if(e.startsWith("-]",o+1)){i.push(He(b+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=b,o+=2;continue}i.push(He(b)),o++;}if(f<o)return ["",false,0,false];if(!i.length&&!n.length)return ["$.",false,e.length-s,true];if(n.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!c){let b=i[0].length===2?i[0].slice(-1):i[0];return [eo(b),false,f-s,false]}let m="["+(c?"^":"")+Ui(i)+"]",S="["+(c?"":"^")+Ui(n)+"]";return [i.length&&n.length?"("+m+"|"+S+")":i.length?m:S,h,f-s,true]},_e=(e,{windowsPathsNoEscape:t=false,magicalBraces:s=true}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),io=new Set(["!","?","+","*","@"]),Bi=e=>io.has(e),ro="(?!(?:^|/)\\.\\.?(?:$|/))",Ps="(?!\\.)",no=new Set(["[","."]),oo=new Set(["..","."]),ao=new Set("().*{}+?[]^$\\!"),ho=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Di="[^/]",Gi=Di+"*?",Vi=Di+"+?",U,H,Bt,N,z,re,me,ne,It,ye,as,Oe,zr,ue,Q,Us,vi,$r,Wr=(Q=class{constructor(t,s,i={}){y(this,Oe);u(this,"type");y(this,U);y(this,H);y(this,Bt,false);y(this,N,[]);y(this,z);y(this,re);y(this,me);y(this,ne,false);y(this,It);y(this,ye);y(this,as,false);this.type=t,t&&d(this,H,true),d(this,z,s),d(this,U,r(this,z)?r(r(this,z),U):this),d(this,It,r(this,U)===this?i:r(r(this,U),It)),d(this,me,r(this,U)===this?[]:r(r(this,U),me)),t==="!"&&!r(r(this,U),ne)&&r(this,me).push(this),d(this,re,r(this,z)?r(r(this,z),N).length:0);}get hasMagic(){if(r(this,H)!==void 0)return r(this,H);for(let t of r(this,N))if(typeof t!="string"&&(t.type||t.hasMagic))return d(this,H,true);return r(this,H)}toString(){return r(this,ye)!==void 0?r(this,ye):this.type?d(this,ye,this.type+"("+r(this,N).map(t=>String(t)).join("|")+")"):d(this,ye,r(this,N).map(t=>String(t)).join(""))}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof Q&&r(s,z)===this))throw new Error("invalid part: "+s);r(this,N).push(s);}}toJSON(){let t=this.type===null?r(this,N).slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...r(this,N).map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===r(this,U)||r(r(this,U),ne)&&r(this,z)?.type==="!")&&t.push({}),t}isStart(){if(r(this,U)===this)return true;if(!r(this,z)?.isStart())return false;if(r(this,re)===0)return true;let t=r(this,z);for(let s=0;s<r(this,re);s++){let i=r(t,N)[s];if(!(i instanceof Q&&i.type==="!"))return false}return true}isEnd(){if(r(this,U)===this||r(this,z)?.type==="!")return true;if(!r(this,z)?.isEnd())return false;if(!this.type)return r(this,z)?.isEnd();let t=r(this,z)?r(r(this,z),N).length:0;return r(this,re)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this));}clone(t){let s=new Q(this.type,t);for(let i of r(this,N))s.copyIn(i);return s}static fromGlob(t,s={}){var n;let i=new Q(null,void 0,s);return g(n=Q,ue,Us).call(n,t,i,0,s),i}toMMPattern(){if(this!==r(this,U))return r(this,U).toMMPattern();let t=this.toString(),[s,i,n,o]=this.toRegExpSource();if(!(n||r(this,H)||r(this,It).nocase&&!r(this,It).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(r(this,It).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,a),{_src:s,_glob:t})}get options(){return r(this,It)}toRegExpSource(t){let s=t??!!r(this,It).dot;if(r(this,U)===this&&g(this,Oe,zr).call(this),!this.type){let l=this.isStart()&&this.isEnd()&&!r(this,N).some(m=>typeof m!="string"),c=r(this,N).map(m=>{var w;let[S,b,v,E]=typeof m=="string"?g(w=Q,ue,$r).call(w,m,r(this,H),l):m.toRegExpSource(t);return d(this,H,r(this,H)||v),d(this,Bt,r(this,Bt)||E),S}).join(""),f="";if(this.isStart()&&typeof r(this,N)[0]=="string"&&!(r(this,N).length===1&&oo.has(r(this,N)[0]))){let m=no,S=s&&m.has(c.charAt(0))||c.startsWith("\\.")&&m.has(c.charAt(2))||c.startsWith("\\.\\.")&&m.has(c.charAt(4)),b=!s&&!t&&m.has(c.charAt(0));f=S?ro:b?Ps:"";}let p="";return this.isEnd()&&r(r(this,U),ne)&&r(this,z)?.type==="!"&&(p="(?:$|\\/)"),[f+c+p,_e(c),d(this,H,!!r(this,H)),r(this,Bt)]}let i=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",o=g(this,Oe,vi).call(this,s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString();return d(this,N,[l]),this.type=null,d(this,H,void 0),[l,_e(this.toString()),false,false]}let a=!i||t||s||!Ps?"":g(this,Oe,vi).call(this,true);a===o&&(a=""),a&&(o=`(?:${o})(?:${a})*?`);let h="";if(this.type==="!"&&r(this,as))h=(this.isStart()&&!s?Ps:"")+Vi;else {let l=this.type==="!"?"))"+(this.isStart()&&!s&&!t?Ps:"")+Gi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;h=n+o+l;}return [h,_e(o),d(this,H,!!r(this,H)),r(this,Bt)]}},U=new WeakMap,H=new WeakMap,Bt=new WeakMap,N=new WeakMap,z=new WeakMap,re=new WeakMap,me=new WeakMap,ne=new WeakMap,It=new WeakMap,ye=new WeakMap,as=new WeakMap,Oe=new WeakSet,zr=function(){if(this!==r(this,U))throw new Error("should only call on root");if(r(this,ne))return this;this.toString(),d(this,ne,true);let t;for(;t=r(this,me).pop();){if(t.type!=="!")continue;let s=t,i=r(s,z);for(;i;){for(let n=r(s,re)+1;!i.type&&n<r(i,N).length;n++)for(let o of r(t,N)){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(r(i,N)[n]);}s=i,i=r(s,z);}}return this},ue=new WeakSet,Us=function(t,s,i,n){var S,b;let o=false,a=false,h=-1,l=false;if(s.type===null){let v=i,E="";for(;v<t.length;){let w=t.charAt(v++);if(o||w==="\\"){o=!o,E+=w;continue}if(a){v===h+1?(w==="^"||w==="!")&&(l=true):w==="]"&&!(v===h+2&&l)&&(a=false),E+=w;continue}else if(w==="["){a=true,h=v,l=false,E+=w;continue}if(!n.noext&&Bi(w)&&t.charAt(v)==="("){s.push(E),E="";let M=new Q(w,s);v=g(S=Q,ue,Us).call(S,t,M,v,n),s.push(M);continue}E+=w;}return s.push(E),v}let c=i+1,f=new Q(null,s),p=[],m="";for(;c<t.length;){let v=t.charAt(c++);if(o||v==="\\"){o=!o,m+=v;continue}if(a){c===h+1?(v==="^"||v==="!")&&(l=true):v==="]"&&!(c===h+2&&l)&&(a=false),m+=v;continue}else if(v==="["){a=true,h=c,l=false,m+=v;continue}if(Bi(v)&&t.charAt(c)==="("){f.push(m),m="";let E=new Q(v,f);f.push(E),c=g(b=Q,ue,Us).call(b,t,E,c,n);continue}if(v==="|"){f.push(m),m="",p.push(f),f=new Q(null,s);continue}if(v===")")return m===""&&r(s,N).length===0&&d(s,as,true),f.push(m),m="",s.push(...p,f),c;m+=v;}return s.type=null,d(s,H,void 0),d(s,N,[t.substring(i-1)]),c},vi=function(t){return r(this,N).map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[i,n,o,a]=s.toRegExpSource(t);return d(this,Bt,r(this,Bt)||a),i}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")},$r=function(t,s,i=false){let n=false,o="",a=false;for(let h=0;h<t.length;h++){let l=t.charAt(h);if(n){n=false,o+=(ao.has(l)?"\\":"")+l;continue}if(l==="\\"){h===t.length-1?o+="\\\\":n=true;continue}if(l==="["){let[c,f,p,m]=so(t,h);if(p){o+=c,a=a||f,h+=p-1,s=s||m;continue}}if(l==="*"){o+=i&&t==="*"?Vi:Gi,s=true;continue}if(l==="?"){o+=Di,s=true;continue}o+=ho(l);}return [o,_e(t),!!s,a]},y(Q,ue),Q),Ur=(e,{windowsPathsNoEscape:t=false,magicalBraces:s=false}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),ot=(e,t,s={})=>(Ks(t),!s.nocomment&&t.charAt(0)==="#"?false:new de(t,s).match(e)),lo=/^\*+([^+@!?\*\[\(]*)$/,co=e=>t=>!t.startsWith(".")&&t.endsWith(e),uo=e=>t=>t.endsWith(e),po=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),fo=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),go=/^\*+\.\*+$/,mo=e=>!e.startsWith(".")&&e.includes("."),yo=e=>e!=="."&&e!==".."&&e.includes("."),wo=/^\.\*+$/,bo=e=>e!=="."&&e!==".."&&e.startsWith("."),vo=/^\*+$/,So=e=>e.length!==0&&!e.startsWith("."),xo=e=>e.length!==0&&e!=="."&&e!=="..",Eo=/^\?+([^+@!?\*\[\(]*)?$/,ko=([e,t=""])=>{let s=Br([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},Co=([e,t=""])=>{let s=Gr([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},Oo=([e,t=""])=>{let s=Gr([e]);return t?i=>s(i)&&i.endsWith(t):s},Ro=([e,t=""])=>{let s=Br([e]);return t?i=>s(i)&&i.endsWith(t):s},Br=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},Gr=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Vr=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",qi={win32:{sep:"\\"},posix:{sep:"/"}},To=Vr==="win32"?qi.win32.sep:qi.posix.sep;ot.sep=To;var nt=Symbol("globstar **");ot.GLOBSTAR=nt;var Mo="[^/]",Ao=Mo+"*?",Lo="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_o="(?:(?!(?:\\/|^)\\.).)*?",Fo=(e,t={})=>s=>ot(s,e,t);ot.filter=Fo;var gt=(e,t={})=>Object.assign({},e,t),Po=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return ot;let t=ot;return Object.assign((s,i,n={})=>t(s,i,gt(e,n)),{Minimatch:class extends t.Minimatch{constructor(s,i={}){super(s,gt(e,i));}static defaults(s){return t.defaults(gt(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,i,n={}){super(s,i,gt(e,n));}static fromGlob(s,i={}){return t.AST.fromGlob(s,gt(e,i))}},unescape:(s,i={})=>t.unescape(s,gt(e,i)),escape:(s,i={})=>t.escape(s,gt(e,i)),filter:(s,i={})=>t.filter(s,gt(e,i)),defaults:s=>t.defaults(gt(e,s)),makeRe:(s,i={})=>t.makeRe(s,gt(e,i)),braceExpand:(s,i={})=>t.braceExpand(s,gt(e,i)),match:(s,i,n={})=>t.match(s,i,gt(e,n)),sep:t.sep,GLOBSTAR:nt})};ot.defaults=Po;var qr=(e,t={})=>(Ks(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Zn(e,{max:t.braceExpandMax}));ot.braceExpand=qr;var Do=(e,t={})=>new de(e,t).makeRe();ot.makeRe=Do;var No=(e,t,s={})=>{let i=new de(t,s);return e=e.filter(n=>i.match(n)),i.options.nonull&&!e.length&&e.push(t),e};ot.match=No;var Ji=/[?*]|[+@!]\(.*?\)|\[|\]/,Io=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),de=class{constructor(e,t={}){u(this,"options");u(this,"set");u(this,"pattern");u(this,"windowsPathsNoEscape");u(this,"nonegate");u(this,"negate");u(this,"comment");u(this,"empty");u(this,"preserveMultipleSlashes");u(this,"partial");u(this,"globSet");u(this,"globParts");u(this,"nocase");u(this,"isWindows");u(this,"platform");u(this,"windowsNoMagicRoot");u(this,"regexp");Ks(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||Vr,this.isWindows=this.platform==="win32";let s="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[s]===false,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=false,this.nonegate=!!t.nonegate,this.comment=false,this.empty=false,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make();}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return true;for(let e of this.set)for(let t of e)if(typeof t!="string")return true;return false}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...n)=>console.error(...n)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((n,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let h=n[0]===""&&n[1]===""&&(n[2]==="?"||!Ji.test(n[2]))&&!Ji.test(n[3]),l=/^[a-z]:/i.test(n[0]);if(h)return [...n.slice(0,4),...n.slice(4).map(c=>this.parse(c))];if(l)return [n[0],...n.slice(1).map(c=>this.parse(c))]}return n.map(h=>this.parse(h))});if(this.debug(this.pattern,i),this.set=i.filter(n=>n.indexOf(false)===-1),this.isWindows)for(let n=0;n<this.set.length;n++){let o=this.set[n];o[0]===""&&o[1]===""&&this.globParts[n][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?");}this.debug(this.pattern,this.set);}preprocess(e){if(this.options.noglobstar)for(let s=0;s<e.length;s++)for(let i=0;i<e[s].length;i++)e[s][i]==="**"&&(e[s][i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let s=-1;for(;(s=t.indexOf("**",s+1))!==-1;){let i=s;for(;t[i+1]==="**";)i++;i!==s&&t.splice(s,i-s);}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((s,i)=>{let n=s[s.length-1];return i==="**"&&n==="**"?s:i===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(s.pop(),s):(s.push(i),s)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=false;do{if(t=false,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let n=e[i];i===1&&n===""&&e[0]===""||(n==="."||n==="")&&(t=true,e.splice(i,1),i--);}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=true,e.pop());}let s=0;for(;(s=e.indexOf("..",s+1))!==-1;){let i=e[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=true,e.splice(s-1,2),s-=2);}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=false;do{t=false;for(let s of e){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let o=i;for(;s[o+1]==="**";)o++;o>i&&s.splice(i+1,o-i);let a=s[i+1],h=s[i+2],l=s[i+3];if(a!==".."||!h||h==="."||h===".."||!l||l==="."||l==="..")continue;t=true,s.splice(i,1);let c=s.slice(0);c[i]="**",e.push(c),i--;}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let a=s[o];o===1&&a===""&&s[0]===""||(a==="."||a==="")&&(t=true,s.splice(o,1),o--);}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(t=true,s.pop());}let n=0;for(;(n=s.indexOf("..",n+1))!==-1;){let o=s[n-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=true;let a=n===1&&s[n+1]==="**"?["."]:[];s.splice(n-1,2,...a),s.length===0&&s.push(""),n-=2;}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let s=t+1;s<e.length;s++){let i=this.partsMatch(e[t],e[s],!this.preserveMultipleSlashes);if(i){e[t]=[],e[s]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,s=false){let i=0,n=0,o=[],a="";for(;i<e.length&&n<t.length;)if(e[i]===t[n])o.push(a==="b"?t[n]:e[i]),i++,n++;else if(s&&e[i]==="**"&&t[n]===e[i+1])o.push(e[i]),i++;else if(s&&t[n]==="**"&&e[i]===t[n+1])o.push(t[n]),n++;else if(e[i]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(a==="b")return false;a="a",o.push(e[i]),i++,n++;}else if(t[n]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return false;a="b",o.push(t[n]),i++,n++;}else return false;return e.length===t.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=false,s=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,s++;s&&(this.pattern=e.slice(s)),this.negate=t;}matchOne(e,t,s=false){let i=this.options;if(this.isWindows){let b=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),v=!b&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),E=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),w=!E&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),M=v?3:b?0:void 0,C=w?3:E?0:void 0;if(typeof M=="number"&&typeof C=="number"){let[O,k]=[e[M],t[C]];O.toLowerCase()===k.toLowerCase()&&(t[C]=O,C>M?t=t.slice(C):M>C&&(e=e.slice(M)));}}let{optimizationLevel:n=1}=this.options;n>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var o=0,a=0,h=e.length,l=t.length;o<h&&a<l;o++,a++){this.debug("matchOne loop");var c=t[a],f=e[o];if(this.debug(t,c,f),c===false)return false;if(c===nt){this.debug("GLOBSTAR",[t,c,f]);var p=o,m=a+1;if(m===l){for(this.debug("** at the end");o<h;o++)if(e[o]==="."||e[o]===".."||!i.dot&&e[o].charAt(0)===".")return false;return true}for(;p<h;){var S=e[p];if(this.debug(`
3
- globstar while`,e,p,t,m,S),this.matchOne(e.slice(p),t.slice(m),s))return this.debug("globstar found match!",p,h,S),true;if(S==="."||S===".."||!i.dot&&S.charAt(0)==="."){this.debug("dot detected!",e,p,t,m);break}this.debug("globstar swallow a segment, and continue"),p++;}return !!(s&&(this.debug(`
4
- >>> no match, partial?`,e,p,t,m),p===h))}let b;if(typeof c=="string"?(b=f===c,this.debug("string match",c,f,b)):(b=c.test(f),this.debug("pattern match",c,f,b)),!b)return false}if(o===h&&a===l)return true;if(o===h)return s;if(a===l)return o===h-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return qr(this.pattern,this.options)}parse(e){Ks(e);let t=this.options;if(e==="**")return nt;if(e==="")return "";let s,i=null;(s=e.match(vo))?i=t.dot?xo:So:(s=e.match(lo))?i=(t.nocase?t.dot?fo:po:t.dot?uo:co)(s[1]):(s=e.match(Eo))?i=(t.nocase?t.dot?Co:ko:t.dot?Oo:Ro)(s):(s=e.match(go))?i=t.dot?yo:mo:(s=e.match(wo))&&(i=bo);let n=Wr.fromGlob(e,this.options).toMMPattern();return i&&typeof n=="object"&&Reflect.defineProperty(n,"test",{value:i}),n}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;let e=this.set;if(!e.length)return this.regexp=false,this.regexp;let t=this.options,s=t.noglobstar?Ao:t.dot?Lo:_o,i=new Set(t.nocase?["i"]:[]),n=e.map(h=>{let l=h.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))i.add(p);return typeof f=="string"?Io(f):f===nt?nt:f._src});l.forEach((f,p)=>{let m=l[p+1],S=l[p-1];f!==nt||S===nt||(S===void 0?m!==void 0&&m!==nt?l[p+1]="(?:\\/|"+s+"\\/)?"+m:l[p]=s:m===void 0?l[p-1]=S+"(?:\\/|\\/"+s+")?":m!==nt&&(l[p-1]=S+"(?:\\/|\\/"+s+"\\/)"+m,l[p+1]=nt));});let c=l.filter(f=>f!==nt);if(this.partial&&c.length>=1){let f=[];for(let p=1;p<=c.length;p++)f.push(c.slice(0,p).join("/"));return "(?:"+f.join("|")+")"}return c.join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];n="^"+o+n+a+"$",this.partial&&(n="^(?:\\/|"+o+n.slice(1,-1)+a+")$"),this.negate&&(n="^(?!"+n+").+$");try{this.regexp=new RegExp(n,[...i].join(""));}catch{this.regexp=false;}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return false;if(this.empty)return e==="";if(e==="/"&&t)return true;let s=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let n=this.set;this.debug(this.pattern,"set",n);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a=0;a<n.length;a++){let h=n[a],l=i;if(s.matchBase&&h.length===1&&(l=[o]),this.matchOne(l,h,t))return s.flipNegate?true:!this.negate}return s.flipNegate?false:this.negate}static defaults(e){return ot.defaults(e).Minimatch}};ot.AST=Wr;ot.Minimatch=de;ot.escape=Ur;ot.unescape=_e;var Wo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Jr=new Set,Si=typeof process=="object"&&process?process:{},Hr=(e,t,s,i)=>{typeof Si.emitWarning=="function"?Si.emitWarning(e,t,s,i):console.error(`[${s}] ${t}: ${e}`);},Ys=globalThis.AbortController,Hi=globalThis.AbortSignal;if(typeof Ys>"u"){Hi=class{constructor(){u(this,"onabort");u(this,"_onabort",[]);u(this,"reason");u(this,"aborted",false);}addEventListener(s,i){this._onabort.push(i);}},Ys=class{constructor(){u(this,"signal",new Hi);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s);}}};let e=Si.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=false,Hr("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",t));};}var zo=e=>!Jr.has(e),te=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Zr=e=>te(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Bs:null:null,Bs=class extends Array{constructor(e){super(e),this.fill(0);}},zt,Fe,$o=(zt=class{constructor(t,s){u(this,"heap");u(this,"length");if(!r(zt,Fe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0;}static create(t){let s=Zr(t);if(!s)return [];d(zt,Fe,true);let i=new zt(t,s);return d(zt,Fe,false),i}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},Fe=new WeakMap,y(zt,Fe,false),zt),lr,cr,yt,lt,kt,we,Ct,Pe,De,Ot,B,Rt,$,I,L,st,ct,tt,Z,Tt,K,Mt,At,ut,dt,Lt,oe,it,Ne,x,xi,be,Gt,hs,pt,Kr,ve,Ie,ls,ee,se,Ei,Gs,Vs,D,ki,es,ie,Ci,je,ti=(je=class{constructor(t){y(this,x);y(this,yt);y(this,lt);y(this,kt);y(this,we);y(this,Ct);y(this,Pe);y(this,De);y(this,Ot);u(this,"ttl");u(this,"ttlResolution");u(this,"ttlAutopurge");u(this,"updateAgeOnGet");u(this,"updateAgeOnHas");u(this,"allowStale");u(this,"noDisposeOnSet");u(this,"noUpdateTTL");u(this,"maxEntrySize");u(this,"sizeCalculation");u(this,"noDeleteOnFetchRejection");u(this,"noDeleteOnStaleGet");u(this,"allowStaleOnFetchAbort");u(this,"allowStaleOnFetchRejection");u(this,"ignoreFetchAbort");y(this,B);y(this,Rt);y(this,$);y(this,I);y(this,L);y(this,st);y(this,ct);y(this,tt);y(this,Z);y(this,Tt);y(this,K);y(this,Mt);y(this,At);y(this,ut);y(this,dt);y(this,Lt);y(this,oe);y(this,it);y(this,Ne);y(this,be,()=>{});y(this,Gt,()=>{});y(this,hs,()=>{});y(this,pt,()=>false);y(this,ve,t=>{});y(this,Ie,(t,s,i)=>{});y(this,ls,(t,s,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});u(this,lr,"LRUCache");let{max:s=0,ttl:i,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:l,dispose:c,onInsert:f,disposeAfter:p,noDisposeOnSet:m,noUpdateTTL:S,maxSize:b=0,maxEntrySize:v=0,sizeCalculation:E,fetchMethod:w,memoMethod:M,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:O,allowStaleOnFetchRejection:k,allowStaleOnFetchAbort:T,ignoreFetchAbort:_,perf:P}=t;if(P!==void 0&&typeof P?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(d(this,Ot,P??Wo),s!==0&&!te(s))throw new TypeError("max option must be a nonnegative integer");let F=s?Zr(s):Array;if(!F)throw new Error("invalid max value: "+s);if(d(this,yt,s),d(this,lt,b),this.maxEntrySize=v||r(this,lt),this.sizeCalculation=E,this.sizeCalculation){if(!r(this,lt)&&!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(M!==void 0&&typeof M!="function")throw new TypeError("memoMethod must be a function if defined");if(d(this,De,M),w!==void 0&&typeof w!="function")throw new TypeError("fetchMethod must be a function if specified");if(d(this,Pe,w),d(this,oe,!!w),d(this,$,new Map),d(this,I,new Array(s).fill(void 0)),d(this,L,new Array(s).fill(void 0)),d(this,st,new F(s)),d(this,ct,new F(s)),d(this,tt,0),d(this,Z,0),d(this,Tt,$o.create(s)),d(this,B,0),d(this,Rt,0),typeof c=="function"&&d(this,kt,c),typeof f=="function"&&d(this,we,f),typeof p=="function"?(d(this,Ct,p),d(this,K,[])):(d(this,Ct,void 0),d(this,K,void 0)),d(this,Lt,!!r(this,kt)),d(this,Ne,!!r(this,we)),d(this,it,!!r(this,Ct)),this.noDisposeOnSet=!!m,this.noUpdateTTL=!!S,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!k,this.allowStaleOnFetchAbort=!!T,this.ignoreFetchAbort=!!_,this.maxEntrySize!==0){if(r(this,lt)!==0&&!te(r(this,lt)))throw new TypeError("maxSize must be a positive integer if specified");if(!te(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");g(this,x,Kr).call(this);}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!O,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=te(n)||n===0?n:1,this.ttlAutopurge=!!o,this.ttl=i||0,this.ttl){if(!te(this.ttl))throw new TypeError("ttl must be a positive integer if specified");g(this,x,xi).call(this);}if(r(this,yt)===0&&this.ttl===0&&r(this,lt)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,yt)&&!r(this,lt)){let j="LRU_CACHE_UNBOUNDED";zo(j)&&(Jr.add(j),Hr("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",j,je));}}get perf(){return r(this,Ot)}static unsafeExposeInternals(t){return {starts:r(t,At),ttls:r(t,ut),autopurgeTimers:r(t,dt),sizes:r(t,Mt),keyMap:r(t,$),keyList:r(t,I),valList:r(t,L),next:r(t,st),prev:r(t,ct),get head(){return r(t,tt)},get tail(){return r(t,Z)},free:r(t,Tt),isBackgroundFetch:s=>{var i;return g(i=t,x,D).call(i,s)},backgroundFetch:(s,i,n,o)=>{var a;return g(a=t,x,Vs).call(a,s,i,n,o)},moveToTail:s=>{var i;return g(i=t,x,es).call(i,s)},indexes:s=>{var i;return g(i=t,x,ee).call(i,s)},rindexes:s=>{var i;return g(i=t,x,se).call(i,s)},isStale:s=>{var i;return r(i=t,pt).call(i,s)}}}get max(){return r(this,yt)}get maxSize(){return r(this,lt)}get calculatedSize(){return r(this,Rt)}get size(){return r(this,B)}get fetchMethod(){return r(this,Pe)}get memoMethod(){return r(this,De)}get dispose(){return r(this,kt)}get onInsert(){return r(this,we)}get disposeAfter(){return r(this,Ct)}getRemainingTTL(t){return r(this,$).has(t)?1/0:0}*entries(){for(let t of g(this,x,ee).call(this))r(this,L)[t]!==void 0&&r(this,I)[t]!==void 0&&!g(this,x,D).call(this,r(this,L)[t])&&(yield [r(this,I)[t],r(this,L)[t]]);}*rentries(){for(let t of g(this,x,se).call(this))r(this,L)[t]!==void 0&&r(this,I)[t]!==void 0&&!g(this,x,D).call(this,r(this,L)[t])&&(yield [r(this,I)[t],r(this,L)[t]]);}*keys(){for(let t of g(this,x,ee).call(this)){let s=r(this,I)[t];s!==void 0&&!g(this,x,D).call(this,r(this,L)[t])&&(yield s);}}*rkeys(){for(let t of g(this,x,se).call(this)){let s=r(this,I)[t];s!==void 0&&!g(this,x,D).call(this,r(this,L)[t])&&(yield s);}}*values(){for(let t of g(this,x,ee).call(this))r(this,L)[t]!==void 0&&!g(this,x,D).call(this,r(this,L)[t])&&(yield r(this,L)[t]);}*rvalues(){for(let t of g(this,x,se).call(this))r(this,L)[t]!==void 0&&!g(this,x,D).call(this,r(this,L)[t])&&(yield r(this,L)[t]);}[(cr=Symbol.iterator,lr=Symbol.toStringTag,cr)](){return this.entries()}find(t,s={}){for(let i of g(this,x,ee).call(this)){let n=r(this,L)[i],o=g(this,x,D).call(this,n)?n.__staleWhileFetching:n;if(o!==void 0&&t(o,r(this,I)[i],this))return this.get(r(this,I)[i],s)}}forEach(t,s=this){for(let i of g(this,x,ee).call(this)){let n=r(this,L)[i],o=g(this,x,D).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(s,o,r(this,I)[i],this);}}rforEach(t,s=this){for(let i of g(this,x,se).call(this)){let n=r(this,L)[i],o=g(this,x,D).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(s,o,r(this,I)[i],this);}}purgeStale(){let t=false;for(let s of g(this,x,se).call(this,{allowStale:true}))r(this,pt).call(this,s)&&(g(this,x,ie).call(this,r(this,I)[s],"expire"),t=true);return t}info(t){let s=r(this,$).get(t);if(s===void 0)return;let i=r(this,L)[s],n=g(this,x,D).call(this,i)?i.__staleWhileFetching:i;if(n===void 0)return;let o={value:n};if(r(this,ut)&&r(this,At)){let a=r(this,ut)[s],h=r(this,At)[s];if(a&&h){let l=a-(r(this,Ot).now()-h);o.ttl=l,o.start=Date.now();}}return r(this,Mt)&&(o.size=r(this,Mt)[s]),o}dump(){let t=[];for(let s of g(this,x,ee).call(this,{allowStale:true})){let i=r(this,I)[s],n=r(this,L)[s],o=g(this,x,D).call(this,n)?n.__staleWhileFetching:n;if(o===void 0||i===void 0)continue;let a={value:o};if(r(this,ut)&&r(this,At)){a.ttl=r(this,ut)[s];let h=r(this,Ot).now()-r(this,At)[s];a.start=Math.floor(Date.now()-h);}r(this,Mt)&&(a.size=r(this,Mt)[s]),t.unshift([i,a]);}return t}load(t){this.clear();for(let[s,i]of t){if(i.start){let n=Date.now()-i.start;i.start=r(this,Ot).now()-n;}this.set(s,i.value,i);}}set(t,s,i={}){var m,S,b,v;if(s===void 0)return this.delete(t),this;let{ttl:n=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:l}=i,{noUpdateTTL:c=this.noUpdateTTL}=i,f=r(this,ls).call(this,t,s,i.size||0,h);if(this.maxEntrySize&&f>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=true),g(this,x,ie).call(this,t,"set"),this;let p=r(this,B)===0?void 0:r(this,$).get(t);if(p===void 0)p=r(this,B)===0?r(this,Z):r(this,Tt).length!==0?r(this,Tt).pop():r(this,B)===r(this,yt)?g(this,x,Gs).call(this,false):r(this,B),r(this,I)[p]=t,r(this,L)[p]=s,r(this,$).set(t,p),r(this,st)[r(this,Z)]=p,r(this,ct)[p]=r(this,Z),d(this,Z,p),_s(this,B)._++,r(this,Ie).call(this,p,f,l),l&&(l.set="add"),c=false,r(this,Ne)&&((m=r(this,we))==null||m.call(this,s,t,"add"));else {g(this,x,es).call(this,p);let E=r(this,L)[p];if(s!==E){if(r(this,oe)&&g(this,x,D).call(this,E)){E.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=E;w!==void 0&&!a&&(r(this,Lt)&&((S=r(this,kt))==null||S.call(this,w,t,"set")),r(this,it)&&r(this,K)?.push([w,t,"set"]));}else a||(r(this,Lt)&&((b=r(this,kt))==null||b.call(this,E,t,"set")),r(this,it)&&r(this,K)?.push([E,t,"set"]));if(r(this,ve).call(this,p),r(this,Ie).call(this,p,f,l),r(this,L)[p]=s,l){l.set="replace";let w=E&&g(this,x,D).call(this,E)?E.__staleWhileFetching:E;w!==void 0&&(l.oldValue=w);}}else l&&(l.set="update");r(this,Ne)&&this.onInsert?.(s,t,s===E?"update":"replace");}if(n!==0&&!r(this,ut)&&g(this,x,xi).call(this),r(this,ut)&&(c||r(this,hs).call(this,p,n,o),l&&r(this,Gt).call(this,l,p)),!a&&r(this,it)&&r(this,K)){let E=r(this,K),w;for(;w=E?.shift();)(v=r(this,Ct))==null||v.call(this,...w);}return this}pop(){var t;try{for(;r(this,B);){let s=r(this,L)[r(this,tt)];if(g(this,x,Gs).call(this,!0),g(this,x,D).call(this,s)){if(s.__staleWhileFetching)return s.__staleWhileFetching}else if(s!==void 0)return s}}finally{if(r(this,it)&&r(this,K)){let s=r(this,K),i;for(;i=s?.shift();)(t=r(this,Ct))==null||t.call(this,...i);}}}has(t,s={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=s,o=r(this,$).get(t);if(o!==void 0){let a=r(this,L)[o];if(g(this,x,D).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(r(this,pt).call(this,o))n&&(n.has="stale",r(this,Gt).call(this,n,o));else return i&&r(this,be).call(this,o),n&&(n.has="hit",r(this,Gt).call(this,n,o)),true}else n&&(n.has="miss");return false}peek(t,s={}){let{allowStale:i=this.allowStale}=s,n=r(this,$).get(t);if(n===void 0||!i&&r(this,pt).call(this,n))return;let o=r(this,L)[n];return g(this,x,D).call(this,o)?o.__staleWhileFetching:o}async fetch(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:m=this.allowStaleOnFetchRejection,ignoreFetchAbort:S=this.ignoreFetchAbort,allowStaleOnFetchAbort:b=this.allowStaleOnFetchAbort,context:v,forceRefresh:E=false,status:w,signal:M}=s;if(!r(this,oe))return w&&(w.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,status:w});let C={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:h,size:l,sizeCalculation:c,noUpdateTTL:f,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:b,ignoreFetchAbort:S,status:w,signal:M},O=r(this,$).get(t);if(O===void 0){w&&(w.fetch="miss");let k=g(this,x,Vs).call(this,t,O,C,v);return k.__returned=k}else {let k=r(this,L)[O];if(g(this,x,D).call(this,k)){let F=i&&k.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",F&&(w.returnedStale=true)),F?k.__staleWhileFetching:k.__returned=k}let T=r(this,pt).call(this,O);if(!E&&!T)return w&&(w.fetch="hit"),g(this,x,es).call(this,O),n&&r(this,be).call(this,O),w&&r(this,Gt).call(this,w,O),k;let _=g(this,x,Vs).call(this,t,O,C,v),P=_.__staleWhileFetching!==void 0&&i;return w&&(w.fetch=T?"stale":"refresh",P&&T&&(w.returnedStale=true)),P?_.__staleWhileFetching:_.__returned=_}}async forceFetch(t,s={}){let i=await this.fetch(t,s);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,s={}){let i=r(this,De);if(!i)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:o,...a}=s,h=this.get(t,a);if(!o&&h!==void 0)return h;let l=i(t,h,{options:a,context:n});return this.set(t,l,a),l}get(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=s,h=r(this,$).get(t);if(h!==void 0){let l=r(this,L)[h],c=g(this,x,D).call(this,l);return a&&r(this,Gt).call(this,a,h),r(this,pt).call(this,h)?(a&&(a.get="stale"),c?(a&&i&&l.__staleWhileFetching!==void 0&&(a.returnedStale=true),i?l.__staleWhileFetching:void 0):(o||g(this,x,ie).call(this,t,"expire"),a&&i&&(a.returnedStale=true),i?l:void 0)):(a&&(a.get="hit"),c?l.__staleWhileFetching:(g(this,x,es).call(this,h),n&&r(this,be).call(this,h),l))}else a&&(a.get="miss");}delete(t){return g(this,x,ie).call(this,t,"delete")}clear(){return g(this,x,Ci).call(this,"delete")}},yt=new WeakMap,lt=new WeakMap,kt=new WeakMap,we=new WeakMap,Ct=new WeakMap,Pe=new WeakMap,De=new WeakMap,Ot=new WeakMap,B=new WeakMap,Rt=new WeakMap,$=new WeakMap,I=new WeakMap,L=new WeakMap,st=new WeakMap,ct=new WeakMap,tt=new WeakMap,Z=new WeakMap,Tt=new WeakMap,K=new WeakMap,Mt=new WeakMap,At=new WeakMap,ut=new WeakMap,dt=new WeakMap,Lt=new WeakMap,oe=new WeakMap,it=new WeakMap,Ne=new WeakMap,x=new WeakSet,xi=function(){let t=new Bs(r(this,yt)),s=new Bs(r(this,yt));d(this,ut,t),d(this,At,s);let i=this.ttlAutopurge?new Array(r(this,yt)):void 0;d(this,dt,i),d(this,hs,(a,h,l=r(this,Ot).now())=>{if(s[a]=h!==0?l:0,t[a]=h,i?.[a]&&(clearTimeout(i[a]),i[a]=void 0),h!==0&&i){let c=setTimeout(()=>{r(this,pt).call(this,a)&&g(this,x,ie).call(this,r(this,I)[a],"expire");},h+1);c.unref&&c.unref(),i[a]=c;}}),d(this,be,a=>{s[a]=t[a]!==0?r(this,Ot).now():0;}),d(this,Gt,(a,h)=>{if(t[h]){let l=t[h],c=s[h];if(!l||!c)return;a.ttl=l,a.start=c,a.now=n||o();let f=a.now-c;a.remainingTTL=l-f;}});let n=0,o=()=>{let a=r(this,Ot).now();if(this.ttlResolution>0){n=a;let h=setTimeout(()=>n=0,this.ttlResolution);h.unref&&h.unref();}return a};this.getRemainingTTL=a=>{let h=r(this,$).get(a);if(h===void 0)return 0;let l=t[h],c=s[h];if(!l||!c)return 1/0;let f=(n||o())-c;return l-f},d(this,pt,a=>{let h=s[a],l=t[a];return !!l&&!!h&&(n||o())-h>l});},be=new WeakMap,Gt=new WeakMap,hs=new WeakMap,pt=new WeakMap,Kr=function(){let t=new Bs(r(this,yt));d(this,Rt,0),d(this,Mt,t),d(this,ve,s=>{d(this,Rt,r(this,Rt)-t[s]),t[s]=0;}),d(this,ls,(s,i,n,o)=>{if(g(this,x,D).call(this,i))return 0;if(!te(n))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(n=o(i,s),!te(n))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 n}),d(this,Ie,(s,i,n)=>{if(t[s]=i,r(this,lt)){let o=r(this,lt)-t[s];for(;r(this,Rt)>o;)g(this,x,Gs).call(this,true);}d(this,Rt,r(this,Rt)+t[s]),n&&(n.entrySize=i,n.totalCalculatedSize=r(this,Rt));});},ve=new WeakMap,Ie=new WeakMap,ls=new WeakMap,ee=function*({allowStale:t=this.allowStale}={}){if(r(this,B))for(let s=r(this,Z);!(!g(this,x,Ei).call(this,s)||((t||!r(this,pt).call(this,s))&&(yield s),s===r(this,tt)));)s=r(this,ct)[s];},se=function*({allowStale:t=this.allowStale}={}){if(r(this,B))for(let s=r(this,tt);!(!g(this,x,Ei).call(this,s)||((t||!r(this,pt).call(this,s))&&(yield s),s===r(this,Z)));)s=r(this,st)[s];},Ei=function(t){return t!==void 0&&r(this,$).get(r(this,I)[t])===t},Gs=function(t){var o;let s=r(this,tt),i=r(this,I)[s],n=r(this,L)[s];return r(this,oe)&&g(this,x,D).call(this,n)?n.__abortController.abort(new Error("evicted")):(r(this,Lt)||r(this,it))&&(r(this,Lt)&&((o=r(this,kt))==null||o.call(this,n,i,"evict")),r(this,it)&&r(this,K)?.push([n,i,"evict"])),r(this,ve).call(this,s),r(this,dt)?.[s]&&(clearTimeout(r(this,dt)[s]),r(this,dt)[s]=void 0),t&&(r(this,I)[s]=void 0,r(this,L)[s]=void 0,r(this,Tt).push(s)),r(this,B)===1?(d(this,tt,d(this,Z,0)),r(this,Tt).length=0):d(this,tt,r(this,st)[s]),r(this,$).delete(i),_s(this,B)._--,s},Vs=function(t,s,i,n){let o=s===void 0?void 0:r(this,L)[s];if(g(this,x,D).call(this,o))return o;let a=new Ys,{signal:h}=i;h?.addEventListener("abort",()=>a.abort(h.reason),{signal:a.signal});let l={signal:a.signal,options:i,context:n},c=(v,E=false)=>{let{aborted:w}=a.signal,M=i.ignoreFetchAbort&&v!==void 0,C=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&v!==void 0);if(i.status&&(w&&!E?(i.status.fetchAborted=true,i.status.fetchError=a.signal.reason,M&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),w&&!M&&!E)return p(a.signal.reason,C);let O=S,k=r(this,L)[s];return (k===S||M&&E&&k===void 0)&&(v===void 0?O.__staleWhileFetching!==void 0?r(this,L)[s]=O.__staleWhileFetching:g(this,x,ie).call(this,t,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(t,v,l.options))),v},f=v=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=v),p(v,false)),p=(v,E)=>{let{aborted:w}=a.signal,M=w&&i.allowStaleOnFetchAbort,C=M||i.allowStaleOnFetchRejection,O=C||i.noDeleteOnFetchRejection,k=S;if(r(this,L)[s]===S&&(!O||!E&&k.__staleWhileFetching===void 0?g(this,x,ie).call(this,t,"fetch"):M||(r(this,L)[s]=k.__staleWhileFetching)),C)return i.status&&k.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),k.__staleWhileFetching;if(k.__returned===k)throw v},m=(v,E)=>{var M;let w=(M=r(this,Pe))==null?void 0:M.call(this,t,o,l);w&&w instanceof Promise&&w.then(C=>v(C===void 0?void 0:C),E),a.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(v(void 0),i.allowStaleOnFetchAbort&&(v=C=>c(C,true)));});};i.status&&(i.status.fetchDispatched=true);let S=new Promise(m).then(c,f),b=Object.assign(S,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return s===void 0?(this.set(t,b,{...l.options,status:void 0}),s=r(this,$).get(t)):r(this,L)[s]=b,b},D=function(t){if(!r(this,oe))return false;let s=t;return !!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Ys},ki=function(t,s){r(this,ct)[s]=t,r(this,st)[t]=s;},es=function(t){t!==r(this,Z)&&(t===r(this,tt)?d(this,tt,r(this,st)[t]):g(this,x,ki).call(this,r(this,ct)[t],r(this,st)[t]),g(this,x,ki).call(this,r(this,Z),t),d(this,Z,t));},ie=function(t,s){var n,o;let i=false;if(r(this,B)!==0){let a=r(this,$).get(t);if(a!==void 0)if(r(this,dt)?.[a]&&(clearTimeout(r(this,dt)?.[a]),r(this,dt)[a]=void 0),i=true,r(this,B)===1)g(this,x,Ci).call(this,s);else {r(this,ve).call(this,a);let h=r(this,L)[a];if(g(this,x,D).call(this,h)?h.__abortController.abort(new Error("deleted")):(r(this,Lt)||r(this,it))&&(r(this,Lt)&&((n=r(this,kt))==null||n.call(this,h,t,s)),r(this,it)&&r(this,K)?.push([h,t,s])),r(this,$).delete(t),r(this,I)[a]=void 0,r(this,L)[a]=void 0,a===r(this,Z))d(this,Z,r(this,ct)[a]);else if(a===r(this,tt))d(this,tt,r(this,st)[a]);else {let l=r(this,ct)[a];r(this,st)[l]=r(this,st)[a];let c=r(this,st)[a];r(this,ct)[c]=r(this,ct)[a];}_s(this,B)._--,r(this,Tt).push(a);}}if(r(this,it)&&r(this,K)?.length){let a=r(this,K),h;for(;h=a?.shift();)(o=r(this,Ct))==null||o.call(this,...h);}return i},Ci=function(t){var s,i;for(let n of g(this,x,se).call(this,{allowStale:true})){let o=r(this,L)[n];if(g(this,x,D).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=r(this,I)[n];r(this,Lt)&&((s=r(this,kt))==null||s.call(this,o,a,t)),r(this,it)&&r(this,K)?.push([o,a,t]);}}if(r(this,$).clear(),r(this,L).fill(void 0),r(this,I).fill(void 0),r(this,ut)&&r(this,At)){r(this,ut).fill(0),r(this,At).fill(0);for(let n of r(this,dt)??[])n!==void 0&&clearTimeout(n);r(this,dt)?.fill(void 0);}if(r(this,Mt)&&r(this,Mt).fill(0),d(this,tt,0),d(this,Z,0),r(this,Tt).length=0,d(this,Rt,0),d(this,B,0),r(this,it)&&r(this,K)){let n=r(this,K),o;for(;o=n?.shift();)(i=r(this,Ct))==null||i.call(this,...o);}},je),Zi=typeof process=="object"&&process?process:{stdout:null,stderr:null},ea=e=>!!e&&typeof e=="object"&&(e instanceof Qs||e instanceof Yr||sa(e)||ia(e)),sa=e=>!!e&&typeof e=="object"&&e instanceof EventEmitter&&typeof e.pipe=="function"&&e.pipe!==Yr.Writable.prototype.pipe,ia=e=>!!e&&typeof e=="object"&&e instanceof EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",$t=Symbol("EOF"),Ut=Symbol("maybeEmitEnd"),Xt=Symbol("emittedEnd"),Ds=Symbol("emittingEnd"),Ze=Symbol("emittedError"),Ns=Symbol("closed"),Ki=Symbol("read"),Is=Symbol("flush"),Yi=Symbol("flushChunk"),xt=Symbol("encoding"),Ae=Symbol("decoder"),V=Symbol("flowing"),Ke=Symbol("paused"),Le=Symbol("resume"),q=Symbol("buffer"),et=Symbol("pipes"),J=Symbol("bufferLength"),pi=Symbol("bufferPush"),js=Symbol("bufferShift"),X=Symbol("objectMode"),W=Symbol("destroyed"),fi=Symbol("error"),gi=Symbol("emitData"),Qi=Symbol("emitEnd"),mi=Symbol("emitEnd2"),Dt=Symbol("async"),yi=Symbol("abort"),Ws=Symbol("aborted"),Ye=Symbol("signal"),pe=Symbol("dataListeners"),ht=Symbol("discarded"),Qe=e=>Promise.resolve().then(e),ra=e=>e(),na=e=>e==="end"||e==="finish"||e==="prefinish",oa=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,aa=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),Qr=class{constructor(e,t,s){u(this,"src");u(this,"dest");u(this,"opts");u(this,"ondrain");this.src=e,this.dest=t,this.opts=s,this.ondrain=()=>e[Le](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},ha=class extends Qr{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(e,t,s){super(e,t,s),this.proxyErrors=i=>t.emit("error",i),e.on("error",this.proxyErrors);}},la=e=>!!e.objectMode,ca=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",ur,dr,pr,fr,gr,mr,yr,wr,br,vr,Sr,xr,Er,kr,Cr,Or,Rr,Tr,Mr,Qs=class extends EventEmitter{constructor(...t){let s=t[0]||{};super();u(this,Mr,false);u(this,Tr,false);u(this,Rr,[]);u(this,Or,[]);u(this,Cr);u(this,kr);u(this,Er);u(this,xr);u(this,Sr,false);u(this,vr,false);u(this,br,false);u(this,wr,false);u(this,yr,null);u(this,mr,0);u(this,gr,false);u(this,fr);u(this,pr,false);u(this,dr,0);u(this,ur,false);u(this,"writable",true);u(this,"readable",true);if(s.objectMode&&typeof s.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");la(s)?(this[X]=true,this[xt]=null):ca(s)?(this[xt]=s.encoding,this[X]=false):(this[X]=false,this[xt]=null),this[Dt]=!!s.async,this[Ae]=this[xt]?new StringDecoder(this[xt]):null,s&&s.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[q]}),s&&s.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[et]});let{signal:i}=s;i&&(this[Ye]=i,i.aborted?this[yi]():i.addEventListener("abort",()=>this[yi]()));}get bufferLength(){return this[J]}get encoding(){return this[xt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[X]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Dt]}set async(t){this[Dt]=this[Dt]||!!t;}[(Mr=V,Tr=Ke,Rr=et,Or=q,Cr=X,kr=xt,Er=Dt,xr=Ae,Sr=$t,vr=Xt,br=Ds,wr=Ns,yr=Ze,mr=J,gr=W,fr=Ye,pr=Ws,dr=pe,ur=ht,yi)](){this[Ws]=true,this.emit("abort",this[Ye]?.reason),this.destroy(this[Ye]?.reason);}get aborted(){return this[Ws]}set aborted(t){}write(t,s,i){if(this[Ws])return false;if(this[$t])throw new Error("write after end");if(this[W])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;typeof s=="function"&&(i=s,s="utf8"),s||(s="utf8");let n=this[Dt]?Qe:ra;if(!this[X]&&!Buffer.isBuffer(t)){if(aa(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(oa(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[X]?(this[V]&&this[J]!==0&&this[Is](true),this[V]?this.emit("data",t):this[pi](t),this[J]!==0&&this.emit("readable"),i&&n(i),this[V]):t.length?(typeof t=="string"&&!(s===this[xt]&&!this[Ae]?.lastNeed)&&(t=Buffer.from(t,s)),Buffer.isBuffer(t)&&this[xt]&&(t=this[Ae].write(t)),this[V]&&this[J]!==0&&this[Is](true),this[V]?this.emit("data",t):this[pi](t),this[J]!==0&&this.emit("readable"),i&&n(i),this[V]):(this[J]!==0&&this.emit("readable"),i&&n(i),this[V])}read(t){if(this[W])return null;if(this[ht]=false,this[J]===0||t===0||t&&t>this[J])return this[Ut](),null;this[X]&&(t=null),this[q].length>1&&!this[X]&&(this[q]=[this[xt]?this[q].join(""):Buffer.concat(this[q],this[J])]);let s=this[Ki](t||null,this[q][0]);return this[Ut](),s}[Ki](t,s){if(this[X])this[js]();else {let i=s;t===i.length||t===null?this[js]():typeof i=="string"?(this[q][0]=i.slice(t),s=i.slice(0,t),this[J]-=t):(this[q][0]=i.subarray(t),s=i.subarray(0,t),this[J]-=t);}return this.emit("data",s),!this[q].length&&!this[$t]&&this.emit("drain"),s}end(t,s,i){return typeof t=="function"&&(i=t,t=void 0),typeof s=="function"&&(i=s,s="utf8"),t!==void 0&&this.write(t,s),i&&this.once("end",i),this[$t]=true,this.writable=false,(this[V]||!this[Ke])&&this[Ut](),this}[Le](){this[W]||(!this[pe]&&!this[et].length&&(this[ht]=true),this[Ke]=false,this[V]=true,this.emit("resume"),this[q].length?this[Is]():this[$t]?this[Ut]():this.emit("drain"));}resume(){return this[Le]()}pause(){this[V]=false,this[Ke]=true,this[ht]=false;}get destroyed(){return this[W]}get flowing(){return this[V]}get paused(){return this[Ke]}[pi](t){this[X]?this[J]+=1:this[J]+=t.length,this[q].push(t);}[js](){return this[X]?this[J]-=1:this[J]-=this[q][0].length,this[q].shift()}[Is](t=false){do;while(this[Yi](this[js]())&&this[q].length);!t&&!this[q].length&&!this[$t]&&this.emit("drain");}[Yi](t){return this.emit("data",t),this[V]}pipe(t,s){if(this[W])return t;this[ht]=false;let i=this[Xt];return s=s||{},t===Zi.stdout||t===Zi.stderr?s.end=false:s.end=s.end!==false,s.proxyErrors=!!s.proxyErrors,i?s.end&&t.end():(this[et].push(s.proxyErrors?new ha(this,t,s):new Qr(this,t,s)),this[Dt]?Qe(()=>this[Le]()):this[Le]()),t}unpipe(t){let s=this[et].find(i=>i.dest===t);s&&(this[et].length===1?(this[V]&&this[pe]===0&&(this[V]=false),this[et]=[]):this[et].splice(this[et].indexOf(s),1),s.unpipe());}addListener(t,s){return this.on(t,s)}on(t,s){let i=super.on(t,s);if(t==="data")this[ht]=false,this[pe]++,!this[et].length&&!this[V]&&this[Le]();else if(t==="readable"&&this[J]!==0)super.emit("readable");else if(na(t)&&this[Xt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ze]){let n=s;this[Dt]?Qe(()=>n.call(this,this[Ze])):n.call(this,this[Ze]);}return i}removeListener(t,s){return this.off(t,s)}off(t,s){let i=super.off(t,s);return t==="data"&&(this[pe]=this.listeners("data").length,this[pe]===0&&!this[ht]&&!this[et].length&&(this[V]=false)),i}removeAllListeners(t){let s=super.removeAllListeners(t);return (t==="data"||t===void 0)&&(this[pe]=0,!this[ht]&&!this[et].length&&(this[V]=false)),s}get emittedEnd(){return this[Xt]}[Ut](){!this[Ds]&&!this[Xt]&&!this[W]&&this[q].length===0&&this[$t]&&(this[Ds]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ns]&&this.emit("close"),this[Ds]=false);}emit(t,...s){let i=s[0];if(t!=="error"&&t!=="close"&&t!==W&&this[W])return false;if(t==="data")return !this[X]&&!i?false:this[Dt]?(Qe(()=>this[gi](i)),true):this[gi](i);if(t==="end")return this[Qi]();if(t==="close"){if(this[Ns]=true,!this[Xt]&&!this[W])return false;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Ze]=i,super.emit(fi,i);let o=!this[Ye]||this.listeners("error").length?super.emit("error",i):false;return this[Ut](),o}else if(t==="resume"){let o=super.emit("resume");return this[Ut](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let n=super.emit(t,...s);return this[Ut](),n}[gi](t){for(let i of this[et])i.dest.write(t)===false&&this.pause();let s=this[ht]?false:super.emit("data",t);return this[Ut](),s}[Qi](){return this[Xt]?false:(this[Xt]=true,this.readable=false,this[Dt]?(Qe(()=>this[mi]()),true):this[mi]())}[mi](){if(this[Ae]){let s=this[Ae].end();if(s){for(let i of this[et])i.dest.write(s);this[ht]||super.emit("data",s);}}for(let s of this[et])s.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[X]||(t.dataLength=0);let s=this.promise();return this.on("data",i=>{t.push(i),this[X]||(t.dataLength+=i.length);}),await s,t}async concat(){if(this[X])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[xt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,s)=>{this.on(W,()=>s(new Error("stream destroyed"))),this.on("error",i=>s(i)),this.on("end",()=>t());})}[Symbol.asyncIterator](){this[ht]=false;let t=false,s=async()=>(this.pause(),t=true,{value:void 0,done:true});return {next:()=>{if(t)return s();let i=this.read();if(i!==null)return Promise.resolve({done:false,value:i});if(this[$t])return s();let n,o,a=f=>{this.off("data",h),this.off("end",l),this.off(W,c),s(),o(f);},h=f=>{this.off("error",a),this.off("end",l),this.off(W,c),this.pause(),n({value:f,done:!!this[$t]});},l=()=>{this.off("error",a),this.off("data",h),this.off(W,c),s(),n({done:true,value:void 0});},c=()=>a(new Error("stream destroyed"));return new Promise((f,p)=>{o=p,n=f,this.once(W,c),this.once("error",a),this.once("end",l),this.once("data",h);})},throw:s,return:s,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[ht]=false;let t=false,s=()=>(this.pause(),this.off(fi,s),this.off(W,s),this.off("end",s),t=true,{done:true,value:void 0}),i=()=>{if(t)return s();let n=this.read();return n===null?s():{done:false,value:n}};return this.once("end",s),this.once(fi,s),this.once(W,s),{next:i,throw:s,return:s,[Symbol.iterator](){return this}}}destroy(t){if(this[W])return t?this.emit("error",t):this.emit(W),this;this[W]=true,this[ht]=true,this[q].length=0,this[J]=0;let s=this;return typeof s.close=="function"&&!this[Ns]&&s.close(),t?this.emit("error",t):this.emit(W),this}static get isStream(){return ea}},ua=realpathSync.native,ss={lstatSync:lstatSync,readdir:readdir$1,readdirSync:readdirSync,readlinkSync:readlinkSync,realpathSync:ua,promises:{lstat:lstat,readdir:readdir,readlink:readlink,realpath:realpath}},Xr=e=>!e||e===ss||e===Zo?ss:{...ss,...e,promises:{...ss.promises,...e.promises||{}}},tn=/^\\\\\?\\([a-z]:)\\?$/i,da=e=>e.replace(/\//g,"\\").replace(tn,"$1\\"),pa=/[\\\/]/,wt=0,en=1,sn=2,Nt=4,rn=6,nn=8,fe=10,on=12,mt=15,Xe=~mt,wi=16,Xi=32,is=64,Et=128,zs=256,qs=512,tr=is|Et|qs,fa=1023,bi=e=>e.isFile()?nn:e.isDirectory()?Nt:e.isSymbolicLink()?fe:e.isCharacterDevice()?sn:e.isBlockDevice()?rn:e.isSocket()?on:e.isFIFO()?en:wt,er=new ti({max:2**12}),rs=e=>{let t=er.get(e);if(t)return t;let s=e.normalize("NFKD");return er.set(e,s),s},sr=new ti({max:2**12}),$s=e=>{let t=sr.get(e);if(t)return t;let s=rs(e.toLowerCase());return sr.set(e,s),s},ir=class extends ti{constructor(){super({max:256});}},ga=class extends ti{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1});}},an=Symbol("PathScurry setAsCwd"),rt,cs,us,ds,ps,fs,gs,ms,ys,ws,bs,vs,Ss,xs,Es,ks,Cs,Os,Rs,ae,Se,jt,Vt,qt,Jt,A,xe,Ht,Wt,R,Ri,Js,ns,Ti,Mi,os,Hs,Ai,Li,Zs,hn,ln,cn,_i,We,ze,un,Ee,Ar,at=(Ar=class{constructor(e,t=wt,s,i,n,o,a){y(this,R);u(this,"name");u(this,"root");u(this,"roots");u(this,"parent");u(this,"nocase");u(this,"isCWD",false);y(this,rt);y(this,cs);y(this,us);y(this,ds);y(this,ps);y(this,fs);y(this,gs);y(this,ms);y(this,ys);y(this,ws);y(this,bs);y(this,vs);y(this,Ss);y(this,xs);y(this,Es);y(this,ks);y(this,Cs);y(this,Os);y(this,Rs);y(this,ae);y(this,Se);y(this,jt);y(this,Vt);y(this,qt);y(this,Jt);y(this,A);y(this,xe);y(this,Ht);y(this,Wt);y(this,We,[]);y(this,ze,false);y(this,Ee);this.name=e,d(this,ae,n?$s(e):rs(e)),d(this,A,t&fa),this.nocase=n,this.roots=i,this.root=s||this,d(this,xe,o),d(this,jt,a.fullpath),d(this,qt,a.relative),d(this,Jt,a.relativePosix),this.parent=a.parent,this.parent?d(this,rt,r(this.parent,rt)):d(this,rt,Xr(a.fs));}get dev(){return r(this,cs)}get mode(){return r(this,us)}get nlink(){return r(this,ds)}get uid(){return r(this,ps)}get gid(){return r(this,fs)}get rdev(){return r(this,gs)}get blksize(){return r(this,ms)}get ino(){return r(this,ys)}get size(){return r(this,ws)}get blocks(){return r(this,bs)}get atimeMs(){return r(this,vs)}get mtimeMs(){return r(this,Ss)}get ctimeMs(){return r(this,xs)}get birthtimeMs(){return r(this,Es)}get atime(){return r(this,ks)}get mtime(){return r(this,Cs)}get ctime(){return r(this,Os)}get birthtime(){return r(this,Rs)}get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return r(this,Se)!==void 0?r(this,Se):this.parent?d(this,Se,this.parent.depth()+1):d(this,Se,0)}childrenCache(){return r(this,xe)}resolve(e){var i;if(!e)return this;let t=this.getRootString(e),s=e.substring(t.length).split(this.splitSep);return t?g(i=this.getRoot(t),R,Ri).call(i,s):g(this,R,Ri).call(this,s)}children(){let e=r(this,xe).get(this);if(e)return e;let t=Object.assign([],{provisional:0});return r(this,xe).set(this,t),d(this,A,r(this,A)&~wi),t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),i=this.nocase?$s(e):rs(e);for(let h of s)if(r(h,ae)===i)return h;let n=this.parent?this.sep:"",o=r(this,jt)?r(this,jt)+n+e:void 0,a=this.newChild(e,wt,{...t,parent:this,fullpath:o});return this.canReaddir()||d(a,A,r(a,A)|Et),s.push(a),a}relative(){if(this.isCWD)return "";if(r(this,qt)!==void 0)return r(this,qt);let e=this.name,t=this.parent;if(!t)return d(this,qt,this.name);let s=t.relative();return s+(!s||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return "";if(r(this,Jt)!==void 0)return r(this,Jt);let e=this.name,t=this.parent;if(!t)return d(this,Jt,this.fullpathPosix());let s=t.relativePosix();return s+(!s||!t.parent?"":"/")+e}fullpath(){if(r(this,jt)!==void 0)return r(this,jt);let e=this.name,t=this.parent;if(!t)return d(this,jt,this.name);let s=t.fullpath()+(t.parent?this.sep:"")+e;return d(this,jt,s)}fullpathPosix(){if(r(this,Vt)!==void 0)return r(this,Vt);if(this.sep==="/")return d(this,Vt,this.fullpath());if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(i)?d(this,Vt,`//?/${i}`):d(this,Vt,i)}let e=this.parent,t=e.fullpathPosix(),s=t+(!t||!e.parent?"":"/")+this.name;return d(this,Vt,s)}isUnknown(){return (r(this,A)&mt)===wt}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 (r(this,A)&mt)===nn}isDirectory(){return (r(this,A)&mt)===Nt}isCharacterDevice(){return (r(this,A)&mt)===sn}isBlockDevice(){return (r(this,A)&mt)===rn}isFIFO(){return (r(this,A)&mt)===en}isSocket(){return (r(this,A)&mt)===on}isSymbolicLink(){return (r(this,A)&fe)===fe}lstatCached(){return r(this,A)&Xi?this:void 0}readlinkCached(){return r(this,Ht)}realpathCached(){return r(this,Wt)}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(r(this,Ht))return true;if(!this.parent)return false;let e=r(this,A)&mt;return !(e!==wt&&e!==fe||r(this,A)&zs||r(this,A)&Et)}calledReaddir(){return !!(r(this,A)&wi)}isENOENT(){return !!(r(this,A)&Et)}isNamed(e){return this.nocase?r(this,ae)===$s(e):r(this,ae)===rs(e)}async readlink(){let e=r(this,Ht);if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await r(this,rt).promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(t);if(s)return d(this,Ht,s)}catch(t){g(this,R,Li).call(this,t.code);return}}readlinkSync(){let e=r(this,Ht);if(e)return e;if(this.canReadlink()&&this.parent)try{let t=r(this,rt).readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(t);if(s)return d(this,Ht,s)}catch(t){g(this,R,Li).call(this,t.code);return}}async lstat(){if((r(this,A)&Et)===0)try{return g(this,R,_i).call(this,await r(this,rt).promises.lstat(this.fullpath())),this}catch(e){g(this,R,Ai).call(this,e.code);}}lstatSync(){if((r(this,A)&Et)===0)try{return g(this,R,_i).call(this,r(this,rt).lstatSync(this.fullpath())),this}catch(e){g(this,R,Ai).call(this,e.code);}}readdirCB(e,t=false){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let s=this.children();if(this.calledReaddir()){let n=s.slice(0,s.provisional);t?e(null,n):queueMicrotask(()=>e(null,n));return}if(r(this,We).push(e),r(this,ze))return;d(this,ze,true);let i=this.fullpath();r(this,rt).readdir(i,{withFileTypes:true},(n,o)=>{if(n)g(this,R,Hs).call(this,n.code),s.provisional=0;else {for(let a of o)g(this,R,Zs).call(this,a,s);g(this,R,Js).call(this,s);}g(this,R,un).call(this,s.slice(0,s.provisional));});}async readdir(){if(!this.canReaddir())return [];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(r(this,Ee))await r(this,Ee);else {let s=()=>{};d(this,Ee,new Promise(i=>s=i));try{for(let i of await r(this,rt).promises.readdir(t,{withFileTypes:!0}))g(this,R,Zs).call(this,i,e);g(this,R,Js).call(this,e);}catch(i){g(this,R,Hs).call(this,i.code),e.provisional=0;}d(this,Ee,void 0),s();}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 t=this.fullpath();try{for(let s of r(this,rt).readdirSync(t,{withFileTypes:!0}))g(this,R,Zs).call(this,s,e);g(this,R,Js).call(this,e);}catch(s){g(this,R,Hs).call(this,s.code),e.provisional=0;}return e.slice(0,e.provisional)}canReaddir(){if(r(this,A)&tr)return false;let e=mt&r(this,A);return e===wt||e===Nt||e===fe}shouldWalk(e,t){return (r(this,A)&Nt)===Nt&&!(r(this,A)&tr)&&!e.has(this)&&(!t||t(this))}async realpath(){if(r(this,Wt))return r(this,Wt);if(!((qs|zs|Et)&r(this,A)))try{let e=await r(this,rt).promises.realpath(this.fullpath());return d(this,Wt,this.resolve(e))}catch{g(this,R,Mi).call(this);}}realpathSync(){if(r(this,Wt))return r(this,Wt);if(!((qs|zs|Et)&r(this,A)))try{let e=r(this,rt).realpathSync(this.fullpath());return d(this,Wt,this.resolve(e))}catch{g(this,R,Mi).call(this);}}[an](e){if(e===this)return;e.isCWD=false,this.isCWD=true;let t=new Set([]),s=[],i=this;for(;i&&i.parent;)t.add(i),d(i,qt,s.join(this.sep)),d(i,Jt,s.join("/")),i=i.parent,s.push("..");for(i=e;i&&i.parent&&!t.has(i);)d(i,qt,void 0),d(i,Jt,void 0),i=i.parent;}},rt=new WeakMap,cs=new WeakMap,us=new WeakMap,ds=new WeakMap,ps=new WeakMap,fs=new WeakMap,gs=new WeakMap,ms=new WeakMap,ys=new WeakMap,ws=new WeakMap,bs=new WeakMap,vs=new WeakMap,Ss=new WeakMap,xs=new WeakMap,Es=new WeakMap,ks=new WeakMap,Cs=new WeakMap,Os=new WeakMap,Rs=new WeakMap,ae=new WeakMap,Se=new WeakMap,jt=new WeakMap,Vt=new WeakMap,qt=new WeakMap,Jt=new WeakMap,A=new WeakMap,xe=new WeakMap,Ht=new WeakMap,Wt=new WeakMap,R=new WeakSet,Ri=function(e){let t=this;for(let s of e)t=t.child(s);return t},Js=function(e){var t;d(this,A,r(this,A)|wi);for(let s=e.provisional;s<e.length;s++){let i=e[s];i&&g(t=i,R,ns).call(t);}},ns=function(){r(this,A)&Et||(d(this,A,(r(this,A)|Et)&Xe),g(this,R,Ti).call(this));},Ti=function(){var t;let e=this.children();e.provisional=0;for(let s of e)g(t=s,R,ns).call(t);},Mi=function(){d(this,A,r(this,A)|qs),g(this,R,os).call(this);},os=function(){if(r(this,A)&is)return;let e=r(this,A);(e&mt)===Nt&&(e&=Xe),d(this,A,e|is),g(this,R,Ti).call(this);},Hs=function(e=""){e==="ENOTDIR"||e==="EPERM"?g(this,R,os).call(this):e==="ENOENT"?g(this,R,ns).call(this):this.children().provisional=0;},Ai=function(e=""){var t;e==="ENOTDIR"?g(t=this.parent,R,os).call(t):e==="ENOENT"&&g(this,R,ns).call(this);},Li=function(e=""){var s;let t=r(this,A);t|=zs,e==="ENOENT"&&(t|=Et),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Xe),d(this,A,t),e==="ENOTDIR"&&this.parent&&g(s=this.parent,R,os).call(s);},Zs=function(e,t){return g(this,R,ln).call(this,e,t)||g(this,R,hn).call(this,e,t)},hn=function(e,t){let s=bi(e),i=this.newChild(e.name,s,{parent:this}),n=r(i,A)&mt;return n!==Nt&&n!==fe&&n!==wt&&d(i,A,r(i,A)|is),t.unshift(i),t.provisional++,i},ln=function(e,t){for(let s=t.provisional;s<t.length;s++){let i=t[s];if((this.nocase?$s(e.name):rs(e.name))===r(i,ae))return g(this,R,cn).call(this,e,i,s,t)}},cn=function(e,t,s,i){let n=t.name;return d(t,A,r(t,A)&Xe|bi(e)),n!==e.name&&(t.name=e.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(t)),i.provisional++,t},_i=function(e){let{atime:t,atimeMs:s,birthtime:i,birthtimeMs:n,blksize:o,blocks:a,ctime:h,ctimeMs:l,dev:c,gid:f,ino:p,mode:m,mtime:S,mtimeMs:b,nlink:v,rdev:E,size:w,uid:M}=e;d(this,ks,t),d(this,vs,s),d(this,Rs,i),d(this,Es,n),d(this,ms,o),d(this,bs,a),d(this,Os,h),d(this,xs,l),d(this,cs,c),d(this,fs,f),d(this,ys,p),d(this,us,m),d(this,Cs,S),d(this,Ss,b),d(this,ds,v),d(this,gs,E),d(this,ws,w),d(this,ps,M);let C=bi(e);d(this,A,r(this,A)&Xe|C|Xi),C!==wt&&C!==Nt&&C!==fe&&d(this,A,r(this,A)|is);},We=new WeakMap,ze=new WeakMap,un=function(e){d(this,ze,false);let t=r(this,We).slice();r(this,We).length=0,t.forEach(s=>s(null,e));},Ee=new WeakMap,Ar),dn=class pn extends at{constructor(s,i=wt,n,o,a,h,l){super(s,i,n,o,a,h,l);u(this,"sep","\\");u(this,"splitSep",pa);}newChild(s,i=wt,n={}){return new pn(s,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(s){return win32.parse(s).root}getRoot(s){if(s=da(s.toUpperCase()),s===this.root.name)return this.root;for(let[i,n]of Object.entries(this.roots))if(this.sameRoot(s,i))return this.roots[s]=n;return this.roots[s]=new Ii(s,this).root}sameRoot(s,i=this.root.name){return s=s.toUpperCase().replace(/\//g,"\\").replace(tn,"$1\\"),s===i}},fn=class gn extends at{constructor(s,i=wt,n,o,a,h,l){super(s,i,n,o,a,h,l);u(this,"splitSep","/");u(this,"sep","/");}getRootString(s){return s.startsWith("/")?"/":""}getRoot(s){return this.root}newChild(s,i=wt,n={}){return new gn(s,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}},$e,Ue,Ts,Ms,Lr,mn=(Lr=class{constructor(e=process.cwd(),t,s,{nocase:i,childrenCacheSize:n=16*1024,fs:o=ss}={}){u(this,"root");u(this,"rootPath");u(this,"roots");u(this,"cwd");y(this,$e);y(this,Ue);y(this,Ts);u(this,"nocase");y(this,Ms);d(this,Ms,Xr(o)),(e instanceof URL||e.startsWith("file://"))&&(e=fileURLToPath(e));let a=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),d(this,$e,new ir),d(this,Ue,new ir),d(this,Ts,new ga(n));let h=a.substring(this.rootPath.length).split(s);if(h.length===1&&!h[0]&&h.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(r(this,Ms)),this.roots[this.rootPath]=this.root;let l=this.root,c=h.length-1,f=t.sep,p=this.rootPath,m=false;for(let S of h){let b=c--;l=l.child(S,{relative:new Array(b).fill("..").join(f),relativePosix:new Array(b).fill("..").join("/"),fullpath:p+=(m?"":f)+S}),m=true;}this.cwd=l;}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return r(this,Ts)}resolve(...e){let t="";for(let n=e.length-1;n>=0;n--){let o=e[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=r(this,$e).get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpath();return r(this,$e).set(t,i),i}resolvePosix(...e){let t="";for(let n=e.length-1;n>=0;n--){let o=e[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=r(this,Ue).get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpathPosix();return r(this,Ue).set(t,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,t={withFileTypes:true}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e,e=this.cwd);let{withFileTypes:s}=t;if(e.canReaddir()){let i=await e.readdir();return s?i:i.map(n=>n.name)}else return []}readdirSync(e=this.cwd,t={withFileTypes:true}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e,e=this.cwd);let{withFileTypes:s=true}=t;return e.canReaddir()?s?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:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e.withFileTypes,e=this.cwd);let s=await e.readlink();return t?s:s?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e.withFileTypes,e=this.cwd);let s=e.readlinkSync();return t?s:s?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e.withFileTypes,e=this.cwd);let s=await e.realpath();return t?s:s?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e.withFileTypes,e=this.cwd);let s=e.realpathSync();return t?s:s?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(e))&&a.push(s?e:e.fullpath());let h=new Set,l=(f,p)=>{h.add(f),f.readdirCB((m,S)=>{if(m)return p(m);let b=S.length;if(!b)return p();let v=()=>{--b===0&&p();};for(let E of S)(!n||n(E))&&a.push(s?E:E.fullpath()),i&&E.isSymbolicLink()?E.realpath().then(w=>w?.isUnknown()?w.lstat():w).then(w=>w?.shouldWalk(h,o)?l(w,v):v()):E.shouldWalk(h,o)?l(E,v):v();},true);},c=e;return new Promise((f,p)=>{l(c,m=>{if(m)return p(m);f(a);});})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(e))&&a.push(s?e:e.fullpath());let h=new Set([e]);for(let l of h){let c=l.readdirSync();for(let f of c){(!n||n(f))&&a.push(s?f:f.fullpath());let p=f;if(f.isSymbolicLink()){if(!(i&&(p=f.realpathSync())))continue;p.isUnknown()&&p.lstatSync();}p.shouldWalk(h,o)&&h.add(p);}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t;(!n||n(e))&&(yield s?e:e.fullpath());let a=new Set([e]);for(let h of a){let l=h.readdirSync();for(let c of l){(!n||n(c))&&(yield s?c:c.fullpath());let f=c;if(c.isSymbolicLink()){if(!(i&&(f=c.realpathSync())))continue;f.isUnknown()&&f.lstatSync();}f.shouldWalk(a,o)&&a.add(f);}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=new Qs({objectMode:true});(!n||n(e))&&a.write(s?e:e.fullpath());let h=new Set,l=[e],c=0,f=()=>{let p=false;for(;!p;){let m=l.shift();if(!m){c===0&&a.end();return}c++,h.add(m);let S=(v,E,w=false)=>{if(v)return a.emit("error",v);if(i&&!w){let M=[];for(let C of E)C.isSymbolicLink()&&M.push(C.realpath().then(O=>O?.isUnknown()?O.lstat():O));if(M.length){Promise.all(M).then(()=>S(null,E,true));return}}for(let M of E)M&&(!n||n(M))&&(a.write(s?M:M.fullpath())||(p=true));c--;for(let M of E){let C=M.realpathCached()||M;C.shouldWalk(h,o)&&l.push(C);}p&&!a.flowing?a.once("drain",f):b||f();},b=true;m.readdirCB(S,true),b=false;}};return f(),a}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof at||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=new Qs({objectMode:true}),h=new Set;(!n||n(e))&&a.write(s?e:e.fullpath());let l=[e],c=0,f=()=>{let p=false;for(;!p;){let m=l.shift();if(!m){c===0&&a.end();return}c++,h.add(m);let S=m.readdirSync();for(let b of S)(!n||n(b))&&(a.write(s?b:b.fullpath())||(p=true));c--;for(let b of S){let v=b;if(b.isSymbolicLink()){if(!(i&&(v=b.realpathSync())))continue;v.isUnknown()&&v.lstatSync();}v.shouldWalk(h,o)&&l.push(v);}}p&&!a.flowing&&a.once("drain",f);};return f(),a}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[an](t);}},$e=new WeakMap,Ue=new WeakMap,Ts=new WeakMap,Ms=new WeakMap,Lr),Ii=class extends mn{constructor(t=process.cwd(),s={}){let{nocase:i=true}=s;super(t,win32,"\\",{...s,nocase:i});u(this,"sep","\\");this.nocase=i;for(let n=this.cwd;n;n=n.parent)n.nocase=this.nocase;}parseRootPath(t){return win32.parse(t).root.toUpperCase()}newRoot(t){return new dn(this.rootPath,Nt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},ji=class extends mn{constructor(t=process.cwd(),s={}){let{nocase:i=false}=s;super(t,posix,"/",{...s,nocase:i});u(this,"sep","/");this.nocase=i;}parseRootPath(t){return "/"}newRoot(t){return new fn(this.rootPath,Nt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},yn=class extends ji{constructor(e=process.cwd(),t={}){let{nocase:s=true}=t;super(e,{...t,nocase:s});}};process.platform==="win32"?dn:fn;var ma=process.platform==="win32"?Ii:process.platform==="darwin"?yn:ji,ya=e=>e.length>=1,wa=e=>e.length>=1,G,ft,Y,ke,_t,As,he,le,ce,Be,Ge,wn=(Ge=class{constructor(t,s,i,n){y(this,G);y(this,ft);y(this,Y);u(this,"length");y(this,ke);y(this,_t);y(this,As);y(this,he);y(this,le);y(this,ce);y(this,Be,true);if(!ya(t))throw new TypeError("empty pattern list");if(!wa(s))throw new TypeError("empty glob list");if(s.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,i<0||i>=this.length)throw new TypeError("index out of range");if(d(this,G,t),d(this,ft,s),d(this,Y,i),d(this,ke,n),r(this,Y)===0){if(this.isUNC()){let[o,a,h,l,...c]=r(this,G),[f,p,m,S,...b]=r(this,ft);c[0]===""&&(c.shift(),b.shift());let v=[o,a,h,l,""].join("/"),E=[f,p,m,S,""].join("/");d(this,G,[v,...c]),d(this,ft,[E,...b]),this.length=r(this,G).length;}else if(this.isDrive()||this.isAbsolute()){let[o,...a]=r(this,G),[h,...l]=r(this,ft);a[0]===""&&(a.shift(),l.shift());let c=o+"/",f=h+"/";d(this,G,[c,...a]),d(this,ft,[f,...l]),this.length=r(this,G).length;}}}pattern(){return r(this,G)[r(this,Y)]}isString(){return typeof r(this,G)[r(this,Y)]=="string"}isGlobstar(){return r(this,G)[r(this,Y)]===nt}isRegExp(){return r(this,G)[r(this,Y)]instanceof RegExp}globString(){return d(this,As,r(this,As)||(r(this,Y)===0?this.isAbsolute()?r(this,ft)[0]+r(this,ft).slice(1).join("/"):r(this,ft).join("/"):r(this,ft).slice(r(this,Y)).join("/")))}hasMore(){return this.length>r(this,Y)+1}rest(){return r(this,_t)!==void 0?r(this,_t):this.hasMore()?(d(this,_t,new Ge(r(this,G),r(this,ft),r(this,Y)+1,r(this,ke))),d(r(this,_t),ce,r(this,ce)),d(r(this,_t),le,r(this,le)),d(r(this,_t),he,r(this,he)),r(this,_t)):d(this,_t,null)}isUNC(){let t=r(this,G);return r(this,le)!==void 0?r(this,le):d(this,le,r(this,ke)==="win32"&&r(this,Y)===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3])}isDrive(){let t=r(this,G);return r(this,he)!==void 0?r(this,he):d(this,he,r(this,ke)==="win32"&&r(this,Y)===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]))}isAbsolute(){let t=r(this,G);return r(this,ce)!==void 0?r(this,ce):d(this,ce,t[0]===""&&t.length>1||this.isDrive()||this.isUNC())}root(){let t=r(this,G)[0];return typeof t=="string"&&this.isAbsolute()&&r(this,Y)===0?t:""}checkFollowGlobstar(){return !(r(this,Y)===0||!this.isGlobstar()||!r(this,Be))}markFollowGlobstar(){return r(this,Y)===0||!this.isGlobstar()||!r(this,Be)?false:(d(this,Be,false),true)}},G=new WeakMap,ft=new WeakMap,Y=new WeakMap,ke=new WeakMap,_t=new WeakMap,As=new WeakMap,he=new WeakMap,le=new WeakMap,ce=new WeakMap,Be=new WeakMap,Ge),ba=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",rr=class{constructor(e,{nobrace:t,nocase:s,noext:i,noglobstar:n,platform:o=ba}){u(this,"relative");u(this,"relativeChildren");u(this,"absolute");u(this,"absoluteChildren");u(this,"platform");u(this,"mmopts");this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:true,nobrace:t,nocase:s,noext:i,noglobstar:n,optimizationLevel:2,platform:o,nocomment:true,nonegate:true};for(let a of e)this.add(a);}add(e){let t=new de(e,this.mmopts);for(let s=0;s<t.set.length;s++){let i=t.set[s],n=t.globParts[s];if(!i||!n)throw new Error("invalid pattern object");for(;i[0]==="."&&n[0]===".";)i.shift(),n.shift();let o=new wn(i,n,0,this.platform),a=new de(o.globString(),this.mmopts),h=n[n.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(a):this.relative.push(a),h&&(l?this.absoluteChildren.push(a):this.relativeChildren.push(a));}}ignored(e){let t=e.fullpath(),s=`${t}/`,i=e.relative()||".",n=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(n))return true;for(let o of this.absolute)if(o.match(t)||o.match(s))return true;return false}childrenIgnored(e){let t=e.fullpath()+"/",s=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return true;for(let i of this.absoluteChildren)if(i.match(t))return true;return false}},va=class bn{constructor(t=new Map){u(this,"store");this.store=t;}copy(){return new bn(new Map(this.store))}hasWalked(t,s){return this.store.get(t.fullpath())?.has(s.globString())}storeWalked(t,s){let i=t.fullpath(),n=this.store.get(i);n?n.add(s.globString()):this.store.set(i,new Set([s.globString()]));}},Sa=class{constructor(){u(this,"store",new Map);}add(e,t,s){let i=(t?2:0)|(s?1:0),n=this.store.get(e);this.store.set(e,n===void 0?i:i&n);}entries(){return [...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},xa=class{constructor(){u(this,"store",new Map);}add(e,t){if(!e.canReaddir())return;let s=this.store.get(e);s?s.find(i=>i.globString()===t.globString())||s.push(t):this.store.set(e,[t]);}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return [...this.store.keys()].filter(e=>e.canReaddir())}},nr=class vn{constructor(t,s){u(this,"hasWalkedCache");u(this,"matches",new Sa);u(this,"subwalks",new xa);u(this,"patterns");u(this,"follow");u(this,"dot");u(this,"opts");this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=s?s.copy():new va;}processPatterns(t,s){this.patterns=s;let i=s.map(n=>[t,n]);for(let[n,o]of i){this.hasWalkedCache.storeWalked(n,o);let a=o.root(),h=o.isAbsolute()&&this.opts.absolute!==false;if(a){n=n.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let p=o.rest();if(p)o=p;else {this.matches.add(n,true,false);continue}}if(n.isENOENT())continue;let l,c,f=false;for(;typeof(l=o.pattern())=="string"&&(c=o.rest());)n=n.resolve(l),o=c,f=true;if(l=o.pattern(),c=o.rest(),f){if(this.hasWalkedCache.hasWalked(n,o))continue;this.hasWalkedCache.storeWalked(n,o);}if(typeof l=="string"){let p=l===".."||l===""||l===".";this.matches.add(n.resolve(l),h,p);continue}else if(l===nt){(!n.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(n,o);let p=c?.pattern(),m=c?.rest();if(!c||(p===""||p===".")&&!m)this.matches.add(n,h,p===""||p===".");else if(p===".."){let S=n.parent||n;m?this.hasWalkedCache.hasWalked(S,m)||this.subwalks.add(S,m):this.matches.add(S,h,true);}}else l instanceof RegExp&&this.subwalks.add(n,o);}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new vn(this.opts,this.hasWalkedCache)}filterEntries(t,s){let i=this.subwalks.get(t),n=this.child();for(let o of s)for(let a of i){let h=a.isAbsolute(),l=a.pattern(),c=a.rest();l===nt?n.testGlobstar(o,a,c,h):l instanceof RegExp?n.testRegExp(o,l,c,h):n.testString(o,l,c,h);}return n}testGlobstar(t,s,i,n){if((this.dot||!t.name.startsWith("."))&&(s.hasMore()||this.matches.add(t,n,false),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,s):t.isSymbolicLink()&&(i&&s.checkFollowGlobstar()?this.subwalks.add(t,i):s.markFollowGlobstar()&&this.subwalks.add(t,s)))),i){let o=i.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,i.rest(),n);else if(o===".."){let a=t.parent||t;this.subwalks.add(a,i);}else o instanceof RegExp&&this.testRegExp(t,o,i.rest(),n);}}testRegExp(t,s,i,n){s.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}testString(t,s,i,n){t.isNamed(s)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}},Ea=(e,t)=>typeof e=="string"?new rr([e],t):Array.isArray(e)?new rr(e,t):e,Ve,Zt,Ce,bt,ge,Fi,_r,Sn=(_r=class{constructor(e,t,s){y(this,bt);u(this,"path");u(this,"patterns");u(this,"opts");u(this,"seen",new Set);u(this,"paused",false);u(this,"aborted",false);y(this,Ve,[]);y(this,Zt);y(this,Ce);u(this,"signal");u(this,"maxDepth");u(this,"includeChildMatches");if(this.patterns=e,this.path=t,this.opts=s,d(this,Ce,!s.posix&&s.platform==="win32"?"\\":"/"),this.includeChildMatches=s.includeChildMatches!==false,(s.ignore||!this.includeChildMatches)&&(d(this,Zt,Ea(s.ignore??[],s)),!this.includeChildMatches&&typeof r(this,Zt).add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{r(this,Ve).length=0;}));}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let e;for(;!this.paused&&(e=r(this,Ve).shift());)e();}onResume(e){this.signal?.aborted||(this.paused?r(this,Ve).push(e):e());}async matchCheck(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||await e.realpath(),!s)return;e=s;}let i=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let n=await i.realpath();n&&(n.isUnknown()||this.opts.stat)&&await n.lstat();}return this.matchCheckTest(i,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!g(this,bt,ge).call(this,e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||e.realpathSync(),!s)return;e=s;}let i=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let n=i.realpathSync();n&&(n?.isUnknown()||this.opts.stat)&&n.lstatSync();}return this.matchCheckTest(i,t)}matchFinish(e,t){if(g(this,bt,ge).call(this,e))return;if(!this.includeChildMatches&&r(this,Zt)?.add){let n=`${e.relativePosix()}/**`;r(this,Zt).add(n);}let s=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?r(this,Ce):"";if(this.opts.withFileTypes)this.matchEmit(e);else if(s){let n=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(n+i);}else {let n=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!n.startsWith(".."+r(this,Ce))?"."+r(this,Ce):"";this.matchEmit(n?o+n+i:"."+i);}}async match(e,t,s){let i=await this.matchCheck(e,s);i&&this.matchFinish(i,t);}matchSync(e,t,s){let i=this.matchCheckSync(e,s);i&&this.matchFinish(i,t);}walkCB(e,t,s){this.signal?.aborted&&s(),this.walkCB2(e,t,new nr(this.opts),s);}walkCB2(e,t,s,i){if(g(this,bt,Fi).call(this,e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,s,i));return}s.processPatterns(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,h,l]of s.matches.entries())g(this,bt,ge).call(this,a)||(n++,this.match(a,h,l).then(()=>o()));for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let h=a.readdirCached();a.calledReaddir()?this.walkCB3(a,h,s,o):a.readdirCB((l,c)=>this.walkCB3(a,c,s,o),true);}o();}walkCB3(e,t,s,i){s=s.filterEntries(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,h,l]of s.matches.entries())g(this,bt,ge).call(this,a)||(n++,this.match(a,h,l).then(()=>o()));for(let[a,h]of s.subwalks.entries())n++,this.walkCB2(a,h,s.child(),o);o();}walkCBSync(e,t,s){this.signal?.aborted&&s(),this.walkCB2Sync(e,t,new nr(this.opts),s);}walkCB2Sync(e,t,s,i){if(g(this,bt,Fi).call(this,e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,s,i));return}s.processPatterns(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,h,l]of s.matches.entries())g(this,bt,ge).call(this,a)||this.matchSync(a,h,l);for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let h=a.readdirSync();this.walkCB3Sync(a,h,s,o);}o();}walkCB3Sync(e,t,s,i){s=s.filterEntries(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,h,l]of s.matches.entries())g(this,bt,ge).call(this,a)||this.matchSync(a,h,l);for(let[a,h]of s.subwalks.entries())n++,this.walkCB2Sync(a,h,s.child(),o);o();}},Ve=new WeakMap,Zt=new WeakMap,Ce=new WeakMap,bt=new WeakSet,ge=function(e){return this.seen.has(e)||!!r(this,Zt)?.ignored?.(e)},Fi=function(e){return !!r(this,Zt)?.childrenIgnored?.(e)},_r),or=class extends Sn{constructor(t,s,i){super(t,s,i);u(this,"matches",new Set);}matchEmit(t){this.matches.add(t);}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,s)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?s(this.signal.reason):t(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}},ar=class extends Sn{constructor(t,s,i){super(t,s,i);u(this,"results");this.results=new Qs({signal:this.signal,objectMode:true}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume());}matchEmit(t){this.results.write(t),this.results.flowing||this.pause();}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end());}):this.walkCB(t,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}},ka=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Re=class{constructor(e,t){u(this,"absolute");u(this,"cwd");u(this,"root");u(this,"dot");u(this,"dotRelative");u(this,"follow");u(this,"ignore");u(this,"magicalBraces");u(this,"mark");u(this,"matchBase");u(this,"maxDepth");u(this,"nobrace");u(this,"nocase");u(this,"nodir");u(this,"noext");u(this,"noglobstar");u(this,"pattern");u(this,"platform");u(this,"realpath");u(this,"scurry");u(this,"stat");u(this,"signal");u(this,"windowsPathsNoEscape");u(this,"withFileTypes");u(this,"includeChildMatches");u(this,"opts");u(this,"patterns");if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=fileURLToPath(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==false,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===false,this.windowsPathsNoEscape&&(e=e.map(h=>h.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(h=>h.includes("/")?h:`./**/${h}`);}if(this.pattern=e,this.platform=t.platform||ka,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else {let h=t.platform==="win32"?Ii:t.platform==="darwin"?yn:t.platform?ji:ma;this.scurry=new h(this.cwd,{nocase:t.nocase,fs:t.fs});}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:true,noext:this.noext,nonegate:true,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},n=this.pattern.map(h=>new de(h,i)),[o,a]=n.reduce((h,l)=>(h[0].push(...l.set),h[1].push(...l.globParts),h),[[],[]]);this.patterns=o.map((h,l)=>{let c=a[l];if(!c)throw new Error("invalid pattern object");return new wn(h,c,0,this.platform)});}async walk(){return [...await new or(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 or(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 ar(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 ar(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()}},Ca=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let s of e)if(new de(s,t).hasMagic())return true;return false};function ei(e,t={}){return new Re(e,t).streamSync()}function xn(e,t={}){return new Re(e,t).stream()}function En(e,t={}){return new Re(e,t).walkSync()}async function hr(e,t={}){return new Re(e,t).walk()}function si(e,t={}){return new Re(e,t).iterateSync()}function kn(e,t={}){return new Re(e,t).iterate()}var Oa=ei,Ra=Object.assign(xn,{sync:ei}),Ta=si,Ma=Object.assign(kn,{sync:si}),Aa=Object.assign(En,{stream:ei,iterate:si}),Xs=Object.assign(hr,{glob:hr,globSync:En,sync:Aa,globStream:xn,stream:Ra,globStreamSync:ei,streamSync:Oa,globIterate:kn,iterate:Ma,globIterateSync:si,iterateSync:Ta,Glob:Re,hasMagic:Ca,escape:Ur,unescape:_e});Xs.glob=Xs;var On=Rn.join(process.cwd(),"log"),qe;(O=>{O.Level=_a.enum(["DEBUG","INFO","WARN","ERROR"]).meta({ref:"LogLevel",description:"Log level"});let t={DEBUG:0,INFO:1,WARN:2,ERROR:3},s="INFO";function i(k){return t[k]>=t[s]}function n(){return s}O.getLevel=n;let o=new Map;O.Default=C({service:"default"});let h="";function l(){return h}O.file=l;let c,f,p=false,m=k=>{try{process.stderr.write(k);}catch{}},S=false;async function b(k){if(k.level&&(s=k.level),E(On).catch(T=>{}),k.print){p=true;return}h=Rn.join(On,k.dev?"dev.log":(new Date().toISOString().split(".")[0]??"").replace(/:/g,"")+".log");try{c=await Cn.open(h,"w"),f=createWriteStream("",{fd:c.fd,autoClose:!1}),m=T=>{if(!(S||!f||f.destroyed))try{if(!f.writable)return;f.write(T,_=>{_&&!S&&(S=!0,setTimeout(()=>{S=!1;},1e3));});}catch{S||(S=!0,setTimeout(()=>{S=!1;},1e3));}},p=!0;}catch{m=_=>{try{process.stderr.write(_);}catch{}},p=true;}}O.init=b;async function v(){p&&(f&&!f.destroyed&&(await new Promise((k,T)=>{f.end(_=>{_?T(_):k();});}).catch(k=>{console.error("Failed to close log stream:",k);}),f=void 0),c&&(await c.close().catch(k=>{console.error("Failed to close log file handle:",k);}),c=void 0),m=k=>{try{process.stderr.write(k);}catch{}},p=false);}O.close=v;async function E(k){let T=await Xs("????-??-??T??????.log",{cwd:k,absolute:true});if(T.length<=5)return;let _=T.slice(0,-10);await Promise.all(_.map(P=>Cn.unlink(P).catch(()=>{})));}function w(k,T=0){let _=k.message;return k.cause instanceof Error&&T<10?_+" Caused by: "+w(k.cause,T+1):_}let M=Date.now();function C(k){k=k||{};let T=k.service;if(T&&typeof T=="string"){let F=o.get(T);if(F)return F}function _(F,j){let Kt=Object.entries({...k,...j}).filter(([Wi,Yt])=>Yt!=null).map(([Wi,Yt])=>{let oi=`${Wi}=`;return Yt instanceof Error?oi+w(Yt):typeof Yt=="object"?oi+JSON.stringify(Yt):oi+Yt}).join(" "),St=new Date,Ln=St.getTime()-M;return M=St.getTime(),[St.getFullYear()+"-"+String(St.getMonth()+1).padStart(2,"0")+"-"+String(St.getDate()).padStart(2,"0")+"T"+String(St.getHours()).padStart(2,"0")+":"+String(St.getMinutes()).padStart(2,"0")+":"+String(St.getSeconds()).padStart(2,"0"),"+"+Ln+"ms",Kt,F].filter(Boolean).join(" ")+`
5
- `}let P={debug(F,j){i("DEBUG")&&m("DEBUG "+_(F,j));},info(F,j){i("INFO")&&m("INFO "+_(F,j));},error(F,j){i("ERROR")&&m("ERROR "+_(F,j));},warn(F,j){i("WARN")&&m("WARN "+_(F,j));},tag(F,j){return k&&(k[F]=j),P},clone(){return O.create({...k})},time(F,j){let Kt=Date.now();P.info(F,{status:"started",...j});function St(){P.info(F,{status:"completed",duration:Date.now()-Kt,...j});}return {stop:St,[Symbol.dispose](){St();}}}};return T&&typeof T=="string"&&o.set(T,P),P}O.create=C;})(qe||(qe={}));var vt=qe.create({service:"ollama-sdk",module:"native-language-model"});function ii(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function ri(e){if(!e||e.trim().length===0)return false;try{return JSON.parse(e),!0}catch{return false}}function Tn(e){return typeof e=="string"?e:JSON.stringify(e)}function Mn(e){return !e.tools||e.tools.length===0?{}:{tools:e.tools.map(t=>{if(!t.name)throw new Je(t.name||"unknown","name");let s=t.inputSchema||t.parameters;if(!s)throw new Je(t.name,"inputSchema");return {type:"function",function:{name:t.name,description:t.description,parameters:s}}})}}function An(e){let t=[];for(let s of e)try{switch(s.role){case "system":t.push({role:"system",content:s.content});break;case "user":{let i=s.content.filter(n=>n.type==="text").map(n=>n.text).join(`
6
- `);i&&t.push({role:"user",content:i});break}case "assistant":{let i="",n=[];for(let o of s.content)if(o.type==="text")i+=o.text;else if(o.type==="tool-call"){let a=o;n.push({id:a.toolCallId,type:"function",function:{name:a.toolName,arguments:JSON.stringify(a.input)}});}t.push({role:"assistant",content:i||null,tool_calls:n.length>0?n:void 0});break}case "tool":for(let i of s.content){let n=i.output,o;switch(n.type){case "text":case "error-text":o=n.value;break;case "content":case "json":case "error-json":o=JSON.stringify(n.value);break;default:o=String(n.value);break}t.push({role:"tool",tool_call_id:i.toolCallId,content:o});}break}}catch(i){vt.warn("Failed to convert message",{messageRole:s.role,error:i instanceof Error?i.message:String(i)});}return t}var ni=class{constructor(t,s={}){u(this,"specificationVersion","v2");u(this,"provider","ollama");u(this,"modelId");u(this,"defaultObjectGenerationMode","json");u(this,"supportedUrls",{});u(this,"client");this.modelId=t,this.client=new Fs(s.baseURL);}async doStream(t){let s=ii();vt.debug("Stream request started",{traceId:s,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let i=An(t.prompt),n=Mn({tools:t.tools}),o=JSON.stringify({model:this.modelId,messages:i,options:Me,...n}),a=new ReadableStream({start:async c=>{try{let f=!0,p=!1,m=!1,S="",b="",v=!1,E=[],w=[],M=()=>{if(w.length>0){for(let O of w)c.enqueue(O);w.length=0;}},C=null;for await(let O of this.client.streamChat({model:this.modelId,messages:i,options:Me,...n})){if(C&&C.chunkCount++,f){f=!1;let k={type:"response-metadata",id:ii(),modelId:this.modelId,timestamp:new Date(O.created_at)};c.enqueue(k),C&&C.eventCount++;}if(O.message?.tool_calls){m&&(w.push({type:"reasoning-end",id:"reasoning-0"}),m=!1),p&&(w.push({type:"text-end",id:"txt-0"}),p=!1);for(let k of O.message.tool_calls){if(!k.id||!k.function?.name){let Kt=k.id?"function.name":"id";vt.error("Invalid tool call: missing field",{traceId:s,missingField:Kt,toolCall:void 0}),w.push({type:"error",error:`Invalid tool call: missing ${Kt}`});continue}let T=k.id,_=k.function.name,P=Tn(k.function.arguments),F=E.find(Kt=>Kt.id===T);F?(F.function.arguments+=P,vt.debug("Tool call arguments accumulated",{traceId:s,toolCallId:T,toolName:_,deltaLength:P.length,totalLength:F.function.arguments.length,isComplete:ri(F.function.arguments)}),P&&w.push({type:"tool-input-delta",id:T,delta:P})):(F={id:T,type:"function",function:{name:_,arguments:P},hasFinished:!1},E.push(F),C&&C.toolCallCount++,vt.debug("Tool call received",{traceId:s,toolCallId:T,toolName:_,argumentsLength:P.length,isComplete:ri(P)}),w.push({type:"tool-input-start",id:T,toolName:_}),P&&w.push({type:"tool-input-delta",id:T,delta:P}));let j=ri(F.function.arguments);!F.hasFinished&&j&&(vt.debug("Tool call arguments complete",{traceId:s,toolCallId:T,toolName:_,isComplete:j,argumentsLength:F.function.arguments.length}),w.push({type:"tool-input-end",id:T}),w.push({type:"tool-call",toolCallId:T,toolName:_,input:F.function.arguments}),F.hasFinished=!0);}M(),C&&(C.eventCount+=w.length);}if(O.message?.content){let k=O.message.content;for(b+=k;b.length>0;)if(v){let T=b.indexOf("</think>");if(T===-1){b.length>0&&c.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:b}),b="";break}else {if(T>0){let _=b.substring(0,T);c.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:_});}c.enqueue({type:"reasoning-end",id:"reasoning-0"}),m=!1,v=!1,b=b.substring(T+8);}}else {let T=b.indexOf("<think>");if(T===-1){b.length>0&&(p||(p=!0,c.enqueue({type:"text-start",id:"txt-0"})),c.enqueue({type:"text-delta",id:"txt-0",delta:b}),S+=b),b="";break}else {if(T>0){let _=b.substring(0,T);p||(p=!0,c.enqueue({type:"text-start",id:"txt-0"})),c.enqueue({type:"text-delta",id:"txt-0",delta:_}),S+=_,c.enqueue({type:"text-end",id:"txt-0"}),p=!1;}v=!0,b=b.substring(T+7),m||(m=!0,c.enqueue({type:"reasoning-start",id:"reasoning-0"}));}}}if(O.done){let k=E.filter(P=>!P.hasFinished);for(let P of k)w.push({type:"tool-input-end",id:P.id}),w.push({type:"tool-call",toolCallId:P.id,toolName:P.function.name,input:P.function.arguments});b.length>0&&(v?(w.push({type:"reasoning-delta",id:"reasoning-0",delta:b}),w.push({type:"reasoning-end",id:"reasoning-0"})):(p||(p=!0,w.push({type:"text-start",id:"txt-0"})),w.push({type:"text-delta",id:"txt-0",delta:b}),S+=b)),p&&w.push({type:"text-end",id:"txt-0"});let _=E.length>0?"tool-calls":"stop";if(w.push({type:"finish",finishReason:_,usage:{inputTokens:O.prompt_eval_count||0,outputTokens:O.eval_count||0,totalTokens:(O.prompt_eval_count||0)+(O.eval_count||0)},providerMetadata:{ollama:{totalDuration:O.total_duration||0,loadDuration:O.load_duration||0,promptEvalDuration:O.prompt_eval_duration||0,evalDuration:O.eval_duration||0}}}),M(),C&&(C.eventCount+=w.length),C);E.length=0;}}}catch(f){vt.error("Stream processing error",{traceId:s,error:f instanceof Error?f.message:String(f),stack:void 0}),c.enqueue({type:"error",error:f instanceof Error?f.message:String(f)}),c.enqueue({type:"finish",finishReason:"error",usage:{inputTokens:0,outputTokens:0,totalTokens:0}});}finally{c.close();}}}),[h,l]=a.tee();return {stream:h,fullStream:(async function*(){let c=l.getReader();try{for(;;){let{done:f,value:p}=await c.read();if(f)break;yield p;}}finally{c.releaseLock();}})(),request:{body:o},response:{}}}async doGenerate(t){let s=ii();vt.debug("Generate request started",{traceId:s,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let i=An(t.prompt),n=Mn({tools:t.tools}),o=await this.client.chat({model:this.modelId,messages:i,options:Me,...n}),a=[];if(o.message?.content&&a.push({type:"text",text:o.message.content}),o.message?.tool_calls){vt.debug("Tool calls received in generate",{traceId:s,toolCallCount:o.message.tool_calls.length});for(let c of o.message.tool_calls){let f=c.id||ii(),p=c.function.name,m=Tn(c.function.arguments);vt.debug("Processing tool call in generate",{traceId:s,toolCallId:f,toolName:p,argumentsLength:m.length,isComplete:ri(m)}),a.push({type:"tool-call",toolCallId:f,toolName:p,input:m});}}let h=o.message?.tool_calls&&o.message.tool_calls.length>0,l=h?"tool-calls":"stop";return vt.debug("Generate request completed",{traceId:s,finishReason:l,contentParts:a.length,hasToolCalls:h,inputTokens:o.prompt_eval_count||0,outputTokens:o.eval_count||0}),{content:a,finishReason:l,usage:{inputTokens:o.prompt_eval_count,outputTokens:o.eval_count,totalTokens:(o.prompt_eval_count||0)+(o.eval_count||0)},providerMetadata:{ollama:{totalDuration:o.total_duration,loadDuration:o.load_duration,promptEvalDuration:o.prompt_eval_duration,evalDuration:o.eval_duration}},request:{body:JSON.stringify({model:this.modelId,messages:i,options:Me,...n})},response:{}}}};var Te=class{constructor(t,s={}){u(this,"specificationVersion","v2");u(this,"provider","ollama");u(this,"modelId");u(this,"defaultObjectGenerationMode","json");u(this,"supportedUrls",{});u(this,"nativeModel");this.modelId=t,this.nativeModel=new ni(t,{baseURL:s.baseURL||"http://localhost:11434"});}doGenerate(t){return this.nativeModel.doGenerate(t)}doStream(t){return this.nativeModel.doStream(t)}};var Ls=class{constructor(t,s={}){u(this,"specificationVersion","v2");u(this,"provider","ollama");u(this,"modelId");u(this,"maxEmbeddingsPerCall");u(this,"supportsParallelCalls",true);u(this,"baseURL");this.modelId=t,this.baseURL=s.baseURL||"http://localhost:11434";}async doEmbed(t){let{values:s,abortSignal:i,headers:n}=t,o=qe.create({service:"ollama-embedding"});if(!s||s.length===0)return o.warn("Empty values array provided",{modelId:this.modelId}),{embeddings:[],usage:{tokens:0}};o.debug("Generating text embeddings",{modelId:this.modelId,valuesCount:s.length,baseURL:this.baseURL});try{let a=await Promise.all(s.map(l=>this.generateSingleEmbedding(l,i,n))),h=s.reduce((l,c)=>l+this.estimateTokens(c),0);return o.info("Text embeddings generated successfully",{modelId:this.modelId,embeddingsCount:a.length,totalTokens:h}),{embeddings:a,usage:{tokens:h}}}catch(a){throw o.error("Text embedding generation failed",{modelId:this.modelId,error:a instanceof Error?a.message:String(a),stack:void 0}),a}}async generateSingleEmbedding(t,s,i){let n=`${this.baseURL}/api/embeddings`;try{let o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify({model:this.modelId,prompt:t}),signal:s});if(!o.ok){let h=await o.text();throw new Error(`Ollama embedding API error (${o.status}): ${h}`)}let a=await o.json();if(!a.embedding||!Array.isArray(a.embedding))throw new Error("Invalid response format from Ollama embedding API");return a.embedding}catch(o){throw o instanceof TypeError&&o.message.includes("fetch")?new Error(`Failed to connect to Ollama server at ${this.baseURL}: ${o.message}`):o}}estimateTokens(t){let s=t.match(/[a-zA-Z]/g)?.length||0,i=t.match(/[\u4e00-\u9fa5]/g)?.length||0,n=t.length-s-i;return Math.ceil(s/4)+i+Math.ceil(n*.5)}};function Fa(e={}){return Object.assign(s=>new Te(s,e),{languageModel:s=>new Te(s,e),chat:s=>new Te(s,e),textEmbeddingModel:s=>new Ls(s,e)})}var Pa="0.1.0";
7
- export{hi as ConnectionError,li as ModelNotFoundError,Me as OLLAMA_DEFAULT_OPTIONS,Pn as OLLAMA_SPECIFIC_PARAMS,Ls as OllamaEmbeddingModel,Qt as OllamaError,Te as OllamaLanguageModel,ui as TimeoutError,Pa as VERSION,ci as ValidationError,Fa as createOllama};
1
+ import _a,{win32,posix}from'path';import Rn,{realpath,readlink,readdir,lstat}from'fs/promises';import*as Ho from'fs';import {realpathSync,createWriteStream,readlinkSync,readdirSync,readdir as readdir$1,lstatSync}from'fs';import La from'zod';import {fileURLToPath}from'url';import {EventEmitter}from'events';import Xr from'stream';import {StringDecoder}from'string_decoder';var Ln=Object.defineProperty;var Ui=e=>{throw TypeError(e)};var _n=(e,t,s)=>t in e?Ln(e,t,{enumerable:true,configurable:true,writable:true,value:s}):e[t]=s;var c=(e,t,s)=>_n(e,typeof t!="symbol"?t+"":t,s),hi=(e,t,s)=>t.has(e)||Ui("Cannot "+s);var r=(e,t,s)=>(hi(e,t,"read from private field"),s?s.call(e):t.get(e)),m=(e,t,s)=>t.has(e)?Ui("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),u=(e,t,s,i)=>(hi(e,t,"write to private field"),t.set(e,s),s),g=(e,t,s)=>(hi(e,t,"access private method"),s);var Ps=(e,t,s,i)=>({set _(n){u(e,t,n);},get _(){return r(e,t,i)}});var Ds=class{constructor(t="http://localhost:11434"){this.baseURL=t;}async*streamChat(t){let s=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:true})});if(!s.ok)throw new Error(`Ollama API error: ${s.status} ${s.statusText}`);if(!s.body)throw new Error("Response body is null");let i=s.body.getReader(),n=new TextDecoder,o="";try{for(;;){let{done:a,value:l}=await i.read();if(a){if(o.trim())try{yield JSON.parse(o);}catch{}break}o+=n.decode(l,{stream:!0});let h=o.split(`
2
+ `);o=h.pop()||"";for(let d of h){let f=d.trim();if(f)try{yield JSON.parse(f);}catch{}}}}finally{i.releaseLock();}}async chat(t){let s=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:false})});if(!s.ok)throw new Error(`Ollama API error: ${s.status} ${s.statusText}`);return s.json()}};var Ae={numCtx:262144,temperature:.7,topK:40,topP:.9,repeatPenalty:1.1,numPredict:32e3},Fn=["numCtx","repeatPenalty","numPredict"];var Xt=class extends Error{constructor(s,i){super(s);this.cause=i;this.name="OllamaError",Object.setPrototypeOf(this,new.target.prototype);}},ci=class extends Xt{constructor(s,i,n){super(s,n);this.url=i;this.name="ConnectionError";}},ui=class extends Xt{constructor(s,i){super(`Model not found: ${s}`,i);this.modelId=s;this.name="ModelNotFoundError";}},di=class extends Xt{constructor(s,i,n,o){super(s,o);this.field=i;this.value=n;this.name="ValidationError";}},pi=class extends Xt{constructor(s,i,n){super(s,n);this.timeoutMs=i;this.name="TimeoutError";}},He=class extends Xt{constructor(s,i,n){super(`Invalid tool definition for "${s}": missing ${i}`,n);this.toolName=s;this.missingField=i;this.name="InvalidToolDefinitionError";}};var Dr=(e,t,s)=>{let i=e instanceof RegExp?Bi(e,s):e,n=t instanceof RegExp?Bi(t,s):t,o=i!==null&&n!=null&&Pn(i,n,s);return o&&{start:o[0],end:o[1],pre:s.slice(0,o[0]),body:s.slice(o[0]+i.length,o[1]),post:s.slice(o[1]+n.length)}},Bi=(e,t)=>{let s=t.match(e);return s?s[0]:null},Pn=(e,t,s)=>{let i,n,o,a,l,h=s.indexOf(e),d=s.indexOf(t,h+1),f=h;if(h>=0&&d>0){if(e===t)return [h,d];for(i=[],o=s.length;f>=0&&!l;){if(f===h)i.push(f),h=s.indexOf(e,f+1);else if(i.length===1){let p=i.pop();p!==void 0&&(l=[p,d]);}else n=i.pop(),n!==void 0&&n<o&&(o=n,a=d),d=s.indexOf(t,f+1);f=h<d&&h>=0?h:d;}i.length&&a!==void 0&&(l=[o,a]);}return l},Ir="\0SLASH"+Math.random()+"\0",Nr="\0OPEN"+Math.random()+"\0",Ii="\0CLOSE"+Math.random()+"\0",jr="\0COMMA"+Math.random()+"\0",Wr="\0PERIOD"+Math.random()+"\0",Dn=new RegExp(Ir,"g"),In=new RegExp(Nr,"g"),Nn=new RegExp(Ii,"g"),jn=new RegExp(jr,"g"),Wn=new RegExp(Wr,"g"),zn=/\\\\/g,$n=/\\{/g,Un=/\\}/g,Bn=/\\,/g,Gn=/\\./g,Vn=1e5;function fi(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function qn(e){return e.replace(zn,Ir).replace($n,Nr).replace(Un,Ii).replace(Bn,jr).replace(Gn,Wr)}function Jn(e){return e.replace(Dn,"\\").replace(In,"{").replace(Nn,"}").replace(jn,",").replace(Wn,".")}function zr(e){if(!e)return [""];let t=[],s=Dr("{","}",e);if(!s)return e.split(",");let{pre:i,body:n,post:o}=s,a=i.split(",");a[a.length-1]+="{"+n+"}";let l=zr(o);return o.length&&(a[a.length-1]+=l.shift(),a.push.apply(a,l)),t.push.apply(t,a),t}function Hn(e,t={}){if(!e)return [];let{max:s=Vn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),es(qn(e),s,true).map(Jn)}function Zn(e){return "{"+e+"}"}function Kn(e){return /^-?0\d/.test(e)}function Yn(e,t){return e<=t}function Qn(e,t){return e>=t}function es(e,t,s){let i=[],n=Dr("{","}",e);if(!n)return [e];let o=n.pre,a=n.post.length?es(n.post,t,false):[""];if(/\$$/.test(n.pre))for(let l=0;l<a.length&&l<t;l++){let h=o+"{"+n.body+"}"+a[l];i.push(h);}else {let l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),h=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),d=l||h,f=n.body.indexOf(",")>=0;if(!d&&!f)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+Ii+n.post,es(e,t,true)):[e];let p;if(d)p=n.body.split(/\.\./);else if(p=zr(n.body),p.length===1&&p[0]!==void 0&&(p=es(p[0],t,false).map(Zn),p.length===1))return a.map(b=>n.pre+p[0]+b);let y;if(d&&p[0]!==void 0&&p[1]!==void 0){let b=fi(p[0]),S=fi(p[1]),v=Math.max(p[0].length,p[1].length),E=p.length===3&&p[2]!==void 0?Math.abs(fi(p[2])):1,w=Yn;S<b&&(E*=-1,w=Qn);let O=p.some(Kn);y=[];for(let T=b;w(T,S);T+=E){let C;if(h)C=String.fromCharCode(T),C==="\\"&&(C="");else if(C=String(T),O){let k=v-C.length;if(k>0){let M=new Array(k+1).join("0");T<0?C="-"+M+C.slice(1):C=M+C;}}y.push(C);}}else {y=[];for(let b=0;b<p.length;b++)y.push.apply(y,es(p[b],t,false));}for(let b=0;b<y.length;b++)for(let S=0;S<a.length&&i.length<t;S++){let v=o+y[b]+a[S];(!s||d||v)&&i.push(v);}}return i}var Qs=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},Xn={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",true],"[:alpha:]":["\\p{L}\\p{Nl}",true],"[:ascii:]":["\\x00-\\x7f",false],"[:blank:]":["\\p{Zs}\\t",true],"[:cntrl:]":["\\p{Cc}",true],"[:digit:]":["\\p{Nd}",true],"[:graph:]":["\\p{Z}\\p{C}",true,true],"[:lower:]":["\\p{Ll}",true],"[:print:]":["\\p{C}",true],"[:punct:]":["\\p{P}",true],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",true],"[:upper:]":["\\p{Lu}",true],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",true],"[:xdigit:]":["A-Fa-f0-9",false]},Ze=e=>e.replace(/[[\]\\-]/g,"\\$&"),to=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Gi=e=>e.join(""),eo=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let i=[],n=[],o=s+1,a=false,l=false,h=false,d=false,f=s,p="";t:for(;o<e.length;){let S=e.charAt(o);if((S==="!"||S==="^")&&o===s+1){d=true,o++;continue}if(S==="]"&&a&&!h){f=o+1;break}if(a=true,S==="\\"&&!h){h=true,o++;continue}if(S==="["&&!h){for(let[v,[E,w,O]]of Object.entries(Xn))if(e.startsWith(v,o)){if(p)return ["$.",false,e.length-s,true];o+=v.length,O?n.push(E):i.push(E),l=l||w;continue t}}if(h=false,p){S>p?i.push(Ze(p)+"-"+Ze(S)):S===p&&i.push(Ze(S)),p="",o++;continue}if(e.startsWith("-]",o+1)){i.push(Ze(S+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=S,o+=2;continue}i.push(Ze(S)),o++;}if(f<o)return ["",false,0,false];if(!i.length&&!n.length)return ["$.",false,e.length-s,true];if(n.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!d){let S=i[0].length===2?i[0].slice(-1):i[0];return [to(S),false,f-s,false]}let y="["+(d?"^":"")+Gi(i)+"]",b="["+(d?"":"^")+Gi(n)+"]";return [i.length&&n.length?"("+y+"|"+b+")":i.length?y:b,l,f-s,true]},Fe=(e,{windowsPathsNoEscape:t=false,magicalBraces:s=true}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),so=new Set(["!","?","+","*","@"]),Vi=e=>so.has(e),io="(?!(?:^|/)\\.\\.?(?:$|/))",Is="(?!\\.)",ro=new Set(["[","."]),no=new Set(["..","."]),oo=new Set("().*{}+?[]^$\\!"),ao=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ni="[^/]",qi=Ni+"*?",Ji=Ni+"+?",G,K,Gt,N,U,ne,ye,oe,jt,we,ls,Re,Ur,de,tt,Gs,xi,Br,$r=(tt=class{constructor(t,s,i={}){m(this,Re);c(this,"type");m(this,G);m(this,K);m(this,Gt,false);m(this,N,[]);m(this,U);m(this,ne);m(this,ye);m(this,oe,false);m(this,jt);m(this,we);m(this,ls,false);this.type=t,t&&u(this,K,true),u(this,U,s),u(this,G,r(this,U)?r(r(this,U),G):this),u(this,jt,r(this,G)===this?i:r(r(this,G),jt)),u(this,ye,r(this,G)===this?[]:r(r(this,G),ye)),t==="!"&&!r(r(this,G),oe)&&r(this,ye).push(this),u(this,ne,r(this,U)?r(r(this,U),N).length:0);}get hasMagic(){if(r(this,K)!==void 0)return r(this,K);for(let t of r(this,N))if(typeof t!="string"&&(t.type||t.hasMagic))return u(this,K,true);return r(this,K)}toString(){return r(this,we)!==void 0?r(this,we):this.type?u(this,we,this.type+"("+r(this,N).map(t=>String(t)).join("|")+")"):u(this,we,r(this,N).map(t=>String(t)).join(""))}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof tt&&r(s,U)===this))throw new Error("invalid part: "+s);r(this,N).push(s);}}toJSON(){let t=this.type===null?r(this,N).slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...r(this,N).map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===r(this,G)||r(r(this,G),oe)&&r(this,U)?.type==="!")&&t.push({}),t}isStart(){if(r(this,G)===this)return true;if(!r(this,U)?.isStart())return false;if(r(this,ne)===0)return true;let t=r(this,U);for(let s=0;s<r(this,ne);s++){let i=r(t,N)[s];if(!(i instanceof tt&&i.type==="!"))return false}return true}isEnd(){if(r(this,G)===this||r(this,U)?.type==="!")return true;if(!r(this,U)?.isEnd())return false;if(!this.type)return r(this,U)?.isEnd();let t=r(this,U)?r(r(this,U),N).length:0;return r(this,ne)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this));}clone(t){let s=new tt(this.type,t);for(let i of r(this,N))s.copyIn(i);return s}static fromGlob(t,s={}){var n;let i=new tt(null,void 0,s);return g(n=tt,de,Gs).call(n,t,i,0,s),i}toMMPattern(){if(this!==r(this,G))return r(this,G).toMMPattern();let t=this.toString(),[s,i,n,o]=this.toRegExpSource();if(!(n||r(this,K)||r(this,jt).nocase&&!r(this,jt).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(r(this,jt).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,a),{_src:s,_glob:t})}get options(){return r(this,jt)}toRegExpSource(t){let s=t??!!r(this,jt).dot;if(r(this,G)===this&&g(this,Re,Ur).call(this),!this.type){let h=this.isStart()&&this.isEnd()&&!r(this,N).some(y=>typeof y!="string"),d=r(this,N).map(y=>{var w;let[b,S,v,E]=typeof y=="string"?g(w=tt,de,Br).call(w,y,r(this,K),h):y.toRegExpSource(t);return u(this,K,r(this,K)||v),u(this,Gt,r(this,Gt)||E),b}).join(""),f="";if(this.isStart()&&typeof r(this,N)[0]=="string"&&!(r(this,N).length===1&&no.has(r(this,N)[0]))){let y=ro,b=s&&y.has(d.charAt(0))||d.startsWith("\\.")&&y.has(d.charAt(2))||d.startsWith("\\.\\.")&&y.has(d.charAt(4)),S=!s&&!t&&y.has(d.charAt(0));f=b?io:S?Is:"";}let p="";return this.isEnd()&&r(r(this,G),oe)&&r(this,U)?.type==="!"&&(p="(?:$|\\/)"),[f+d+p,Fe(d),u(this,K,!!r(this,K)),r(this,Gt)]}let i=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",o=g(this,Re,xi).call(this,s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let h=this.toString();return u(this,N,[h]),this.type=null,u(this,K,void 0),[h,Fe(this.toString()),false,false]}let a=!i||t||s||!Is?"":g(this,Re,xi).call(this,true);a===o&&(a=""),a&&(o=`(?:${o})(?:${a})*?`);let l="";if(this.type==="!"&&r(this,ls))l=(this.isStart()&&!s?Is:"")+Ji;else {let h=this.type==="!"?"))"+(this.isStart()&&!s&&!t?Is:"")+qi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;l=n+o+h;}return [l,Fe(o),u(this,K,!!r(this,K)),r(this,Gt)]}},G=new WeakMap,K=new WeakMap,Gt=new WeakMap,N=new WeakMap,U=new WeakMap,ne=new WeakMap,ye=new WeakMap,oe=new WeakMap,jt=new WeakMap,we=new WeakMap,ls=new WeakMap,Re=new WeakSet,Ur=function(){if(this!==r(this,G))throw new Error("should only call on root");if(r(this,oe))return this;this.toString(),u(this,oe,true);let t;for(;t=r(this,ye).pop();){if(t.type!=="!")continue;let s=t,i=r(s,U);for(;i;){for(let n=r(s,ne)+1;!i.type&&n<r(i,N).length;n++)for(let o of r(t,N)){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(r(i,N)[n]);}s=i,i=r(s,U);}}return this},de=new WeakSet,Gs=function(t,s,i,n){var b,S;let o=false,a=false,l=-1,h=false;if(s.type===null){let v=i,E="";for(;v<t.length;){let w=t.charAt(v++);if(o||w==="\\"){o=!o,E+=w;continue}if(a){v===l+1?(w==="^"||w==="!")&&(h=true):w==="]"&&!(v===l+2&&h)&&(a=false),E+=w;continue}else if(w==="["){a=true,l=v,h=false,E+=w;continue}if(!n.noext&&Vi(w)&&t.charAt(v)==="("){s.push(E),E="";let O=new tt(w,s);v=g(b=tt,de,Gs).call(b,t,O,v,n),s.push(O);continue}E+=w;}return s.push(E),v}let d=i+1,f=new tt(null,s),p=[],y="";for(;d<t.length;){let v=t.charAt(d++);if(o||v==="\\"){o=!o,y+=v;continue}if(a){d===l+1?(v==="^"||v==="!")&&(h=true):v==="]"&&!(d===l+2&&h)&&(a=false),y+=v;continue}else if(v==="["){a=true,l=d,h=false,y+=v;continue}if(Vi(v)&&t.charAt(d)==="("){f.push(y),y="";let E=new tt(v,f);f.push(E),d=g(S=tt,de,Gs).call(S,t,E,d,n);continue}if(v==="|"){f.push(y),y="",p.push(f),f=new tt(null,s);continue}if(v===")")return y===""&&r(s,N).length===0&&u(s,ls,true),f.push(y),y="",s.push(...p,f),d;y+=v;}return s.type=null,u(s,K,void 0),u(s,N,[t.substring(i-1)]),d},xi=function(t){return r(this,N).map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[i,n,o,a]=s.toRegExpSource(t);return u(this,Gt,r(this,Gt)||a),i}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")},Br=function(t,s,i=false){let n=false,o="",a=false;for(let l=0;l<t.length;l++){let h=t.charAt(l);if(n){n=false,o+=(oo.has(h)?"\\":"")+h;continue}if(h==="\\"){l===t.length-1?o+="\\\\":n=true;continue}if(h==="["){let[d,f,p,y]=eo(t,l);if(p){o+=d,a=a||f,l+=p-1,s=s||y;continue}}if(h==="*"){o+=i&&t==="*"?Ji:qi,s=true;continue}if(h==="?"){o+=Ni,s=true;continue}o+=ao(h);}return [o,Fe(t),!!s,a]},m(tt,de),tt),Gr=(e,{windowsPathsNoEscape:t=false,magicalBraces:s=false}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),lt=(e,t,s={})=>(Qs(t),!s.nocomment&&t.charAt(0)==="#"?false:new pe(t,s).match(e)),lo=/^\*+([^+@!?\*\[\(]*)$/,ho=e=>t=>!t.startsWith(".")&&t.endsWith(e),co=e=>t=>t.endsWith(e),uo=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),po=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),fo=/^\*+\.\*+$/,go=e=>!e.startsWith(".")&&e.includes("."),mo=e=>e!=="."&&e!==".."&&e.includes("."),yo=/^\.\*+$/,wo=e=>e!=="."&&e!==".."&&e.startsWith("."),bo=/^\*+$/,vo=e=>e.length!==0&&!e.startsWith("."),So=e=>e.length!==0&&e!=="."&&e!=="..",xo=/^\?+([^+@!?\*\[\(]*)?$/,Eo=([e,t=""])=>{let s=Vr([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},Co=([e,t=""])=>{let s=qr([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},ko=([e,t=""])=>{let s=qr([e]);return t?i=>s(i)&&i.endsWith(t):s},Oo=([e,t=""])=>{let s=Vr([e]);return t?i=>s(i)&&i.endsWith(t):s},Vr=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},qr=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Jr=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Hi={win32:{sep:"\\"},posix:{sep:"/"}},Ro=Jr==="win32"?Hi.win32.sep:Hi.posix.sep;lt.sep=Ro;var at=Symbol("globstar **");lt.GLOBSTAR=at;var To="[^/]",Mo=To+"*?",Ao="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Lo="(?:(?!(?:\\/|^)\\.).)*?",_o=(e,t={})=>s=>lt(s,e,t);lt.filter=_o;var yt=(e,t={})=>Object.assign({},e,t),Fo=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return lt;let t=lt;return Object.assign((s,i,n={})=>t(s,i,yt(e,n)),{Minimatch:class extends t.Minimatch{constructor(s,i={}){super(s,yt(e,i));}static defaults(s){return t.defaults(yt(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,i,n={}){super(s,i,yt(e,n));}static fromGlob(s,i={}){return t.AST.fromGlob(s,yt(e,i))}},unescape:(s,i={})=>t.unescape(s,yt(e,i)),escape:(s,i={})=>t.escape(s,yt(e,i)),filter:(s,i={})=>t.filter(s,yt(e,i)),defaults:s=>t.defaults(yt(e,s)),makeRe:(s,i={})=>t.makeRe(s,yt(e,i)),braceExpand:(s,i={})=>t.braceExpand(s,yt(e,i)),match:(s,i,n={})=>t.match(s,i,yt(e,n)),sep:t.sep,GLOBSTAR:at})};lt.defaults=Fo;var Hr=(e,t={})=>(Qs(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Hn(e,{max:t.braceExpandMax}));lt.braceExpand=Hr;var Po=(e,t={})=>new pe(e,t).makeRe();lt.makeRe=Po;var Do=(e,t,s={})=>{let i=new pe(t,s);return e=e.filter(n=>i.match(n)),i.options.nonull&&!e.length&&e.push(t),e};lt.match=Do;var Zi=/[?*]|[+@!]\(.*?\)|\[|\]/,Io=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),pe=class{constructor(e,t={}){c(this,"options");c(this,"set");c(this,"pattern");c(this,"windowsPathsNoEscape");c(this,"nonegate");c(this,"negate");c(this,"comment");c(this,"empty");c(this,"preserveMultipleSlashes");c(this,"partial");c(this,"globSet");c(this,"globParts");c(this,"nocase");c(this,"isWindows");c(this,"platform");c(this,"windowsNoMagicRoot");c(this,"regexp");Qs(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||Jr,this.isWindows=this.platform==="win32";let s="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[s]===false,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=false,this.nonegate=!!t.nonegate,this.comment=false,this.empty=false,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make();}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return true;for(let e of this.set)for(let t of e)if(typeof t!="string")return true;return false}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...n)=>console.error(...n)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((n,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=n[0]===""&&n[1]===""&&(n[2]==="?"||!Zi.test(n[2]))&&!Zi.test(n[3]),h=/^[a-z]:/i.test(n[0]);if(l)return [...n.slice(0,4),...n.slice(4).map(d=>this.parse(d))];if(h)return [n[0],...n.slice(1).map(d=>this.parse(d))]}return n.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(n=>n.indexOf(false)===-1),this.isWindows)for(let n=0;n<this.set.length;n++){let o=this.set[n];o[0]===""&&o[1]===""&&this.globParts[n][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?");}this.debug(this.pattern,this.set);}preprocess(e){if(this.options.noglobstar)for(let s=0;s<e.length;s++)for(let i=0;i<e[s].length;i++)e[s][i]==="**"&&(e[s][i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let s=-1;for(;(s=t.indexOf("**",s+1))!==-1;){let i=s;for(;t[i+1]==="**";)i++;i!==s&&t.splice(s,i-s);}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((s,i)=>{let n=s[s.length-1];return i==="**"&&n==="**"?s:i===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(s.pop(),s):(s.push(i),s)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=false;do{if(t=false,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let n=e[i];i===1&&n===""&&e[0]===""||(n==="."||n==="")&&(t=true,e.splice(i,1),i--);}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=true,e.pop());}let s=0;for(;(s=e.indexOf("..",s+1))!==-1;){let i=e[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=true,e.splice(s-1,2),s-=2);}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=false;do{t=false;for(let s of e){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let o=i;for(;s[o+1]==="**";)o++;o>i&&s.splice(i+1,o-i);let a=s[i+1],l=s[i+2],h=s[i+3];if(a!==".."||!l||l==="."||l===".."||!h||h==="."||h==="..")continue;t=true,s.splice(i,1);let d=s.slice(0);d[i]="**",e.push(d),i--;}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let a=s[o];o===1&&a===""&&s[0]===""||(a==="."||a==="")&&(t=true,s.splice(o,1),o--);}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(t=true,s.pop());}let n=0;for(;(n=s.indexOf("..",n+1))!==-1;){let o=s[n-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=true;let a=n===1&&s[n+1]==="**"?["."]:[];s.splice(n-1,2,...a),s.length===0&&s.push(""),n-=2;}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let s=t+1;s<e.length;s++){let i=this.partsMatch(e[t],e[s],!this.preserveMultipleSlashes);if(i){e[t]=[],e[s]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,s=false){let i=0,n=0,o=[],a="";for(;i<e.length&&n<t.length;)if(e[i]===t[n])o.push(a==="b"?t[n]:e[i]),i++,n++;else if(s&&e[i]==="**"&&t[n]===e[i+1])o.push(e[i]),i++;else if(s&&t[n]==="**"&&e[i]===t[n+1])o.push(t[n]),n++;else if(e[i]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(a==="b")return false;a="a",o.push(e[i]),i++,n++;}else if(t[n]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return false;a="b",o.push(t[n]),i++,n++;}else return false;return e.length===t.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=false,s=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,s++;s&&(this.pattern=e.slice(s)),this.negate=t;}matchOne(e,t,s=false){let i=this.options;if(this.isWindows){let S=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),v=!S&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),E=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),w=!E&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),O=v?3:S?0:void 0,T=w?3:E?0:void 0;if(typeof O=="number"&&typeof T=="number"){let[C,k]=[e[O],t[T]];C.toLowerCase()===k.toLowerCase()&&(t[T]=C,T>O?t=t.slice(T):O>T&&(e=e.slice(O)));}}let{optimizationLevel:n=1}=this.options;n>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var o=0,a=0,l=e.length,h=t.length;o<l&&a<h;o++,a++){this.debug("matchOne loop");var d=t[a],f=e[o];if(this.debug(t,d,f),d===false)return false;if(d===at){this.debug("GLOBSTAR",[t,d,f]);var p=o,y=a+1;if(y===h){for(this.debug("** at the end");o<l;o++)if(e[o]==="."||e[o]===".."||!i.dot&&e[o].charAt(0)===".")return false;return true}for(;p<l;){var b=e[p];if(this.debug(`
3
+ globstar while`,e,p,t,y,b),this.matchOne(e.slice(p),t.slice(y),s))return this.debug("globstar found match!",p,l,b),true;if(b==="."||b===".."||!i.dot&&b.charAt(0)==="."){this.debug("dot detected!",e,p,t,y);break}this.debug("globstar swallow a segment, and continue"),p++;}return !!(s&&(this.debug(`
4
+ >>> no match, partial?`,e,p,t,y),p===l))}let S;if(typeof d=="string"?(S=f===d,this.debug("string match",d,f,S)):(S=d.test(f),this.debug("pattern match",d,f,S)),!S)return false}if(o===l&&a===h)return true;if(o===l)return s;if(a===h)return o===l-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return Hr(this.pattern,this.options)}parse(e){Qs(e);let t=this.options;if(e==="**")return at;if(e==="")return "";let s,i=null;(s=e.match(bo))?i=t.dot?So:vo:(s=e.match(lo))?i=(t.nocase?t.dot?po:uo:t.dot?co:ho)(s[1]):(s=e.match(xo))?i=(t.nocase?t.dot?Co:Eo:t.dot?ko:Oo)(s):(s=e.match(fo))?i=t.dot?mo:go:(s=e.match(yo))&&(i=wo);let n=$r.fromGlob(e,this.options).toMMPattern();return i&&typeof n=="object"&&Reflect.defineProperty(n,"test",{value:i}),n}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;let e=this.set;if(!e.length)return this.regexp=false,this.regexp;let t=this.options,s=t.noglobstar?Mo:t.dot?Ao:Lo,i=new Set(t.nocase?["i"]:[]),n=e.map(l=>{let h=l.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))i.add(p);return typeof f=="string"?Io(f):f===at?at:f._src});h.forEach((f,p)=>{let y=h[p+1],b=h[p-1];f!==at||b===at||(b===void 0?y!==void 0&&y!==at?h[p+1]="(?:\\/|"+s+"\\/)?"+y:h[p]=s:y===void 0?h[p-1]=b+"(?:\\/|\\/"+s+")?":y!==at&&(h[p-1]=b+"(?:\\/|\\/"+s+"\\/)"+y,h[p+1]=at));});let d=h.filter(f=>f!==at);if(this.partial&&d.length>=1){let f=[];for(let p=1;p<=d.length;p++)f.push(d.slice(0,p).join("/"));return "(?:"+f.join("|")+")"}return d.join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];n="^"+o+n+a+"$",this.partial&&(n="^(?:\\/|"+o+n.slice(1,-1)+a+")$"),this.negate&&(n="^(?!"+n+").+$");try{this.regexp=new RegExp(n,[...i].join(""));}catch{this.regexp=false;}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return false;if(this.empty)return e==="";if(e==="/"&&t)return true;let s=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let n=this.set;this.debug(this.pattern,"set",n);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a=0;a<n.length;a++){let l=n[a],h=i;if(s.matchBase&&l.length===1&&(h=[o]),this.matchOne(h,l,t))return s.flipNegate?true:!this.negate}return s.flipNegate?false:this.negate}static defaults(e){return lt.defaults(e).Minimatch}};lt.AST=$r;lt.Minimatch=pe;lt.escape=Gr;lt.unescape=Fe;var jo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Zr=new Set,Ei=typeof process=="object"&&process?process:{},Kr=(e,t,s,i)=>{typeof Ei.emitWarning=="function"?Ei.emitWarning(e,t,s,i):console.error(`[${s}] ${t}: ${e}`);},Xs=globalThis.AbortController,Ki=globalThis.AbortSignal;if(typeof Xs>"u"){Ki=class{constructor(){c(this,"onabort");c(this,"_onabort",[]);c(this,"reason");c(this,"aborted",false);}addEventListener(s,i){this._onabort.push(i);}},Xs=class{constructor(){c(this,"signal",new Ki);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s);}}};let e=Ei.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=false,Kr("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",t));};}var Wo=e=>!Zr.has(e),ee=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Yr=e=>ee(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Vs:null:null,Vs=class extends Array{constructor(e){super(e),this.fill(0);}},$t,Pe,zo=($t=class{constructor(t,s){c(this,"heap");c(this,"length");if(!r($t,Pe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0;}static create(t){let s=Yr(t);if(!s)return [];u($t,Pe,true);let i=new $t(t,s);return u($t,Pe,false),i}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},Pe=new WeakMap,m($t,Pe,false),$t),ur,dr,bt,ut,kt,be,Ot,De,Ie,Rt,V,Tt,B,j,_,rt,dt,st,Y,Mt,Q,At,Lt,pt,ft,_t,ae,nt,Ne,x,Ci,ve,Vt,hs,gt,Qr,Se,je,cs,se,ie,ki,qs,Js,I,Oi,ss,re,Ri,We,si=(We=class{constructor(t){m(this,x);m(this,bt);m(this,ut);m(this,kt);m(this,be);m(this,Ot);m(this,De);m(this,Ie);m(this,Rt);c(this,"ttl");c(this,"ttlResolution");c(this,"ttlAutopurge");c(this,"updateAgeOnGet");c(this,"updateAgeOnHas");c(this,"allowStale");c(this,"noDisposeOnSet");c(this,"noUpdateTTL");c(this,"maxEntrySize");c(this,"sizeCalculation");c(this,"noDeleteOnFetchRejection");c(this,"noDeleteOnStaleGet");c(this,"allowStaleOnFetchAbort");c(this,"allowStaleOnFetchRejection");c(this,"ignoreFetchAbort");m(this,V);m(this,Tt);m(this,B);m(this,j);m(this,_);m(this,rt);m(this,dt);m(this,st);m(this,Y);m(this,Mt);m(this,Q);m(this,At);m(this,Lt);m(this,pt);m(this,ft);m(this,_t);m(this,ae);m(this,nt);m(this,Ne);m(this,ve,()=>{});m(this,Vt,()=>{});m(this,hs,()=>{});m(this,gt,()=>false);m(this,Se,t=>{});m(this,je,(t,s,i)=>{});m(this,cs,(t,s,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});c(this,ur,"LRUCache");let{max:s=0,ttl:i,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:h,dispose:d,onInsert:f,disposeAfter:p,noDisposeOnSet:y,noUpdateTTL:b,maxSize:S=0,maxEntrySize:v=0,sizeCalculation:E,fetchMethod:w,memoMethod:O,noDeleteOnFetchRejection:T,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:k,allowStaleOnFetchAbort:M,ignoreFetchAbort:F,perf:D}=t;if(D!==void 0&&typeof D?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,Rt,D??jo),s!==0&&!ee(s))throw new TypeError("max option must be a nonnegative integer");let A=s?Yr(s):Array;if(!A)throw new Error("invalid max value: "+s);if(u(this,bt,s),u(this,ut,S),this.maxEntrySize=v||r(this,ut),this.sizeCalculation=E,this.sizeCalculation){if(!r(this,ut)&&!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(O!==void 0&&typeof O!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,Ie,O),w!==void 0&&typeof w!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,De,w),u(this,ae,!!w),u(this,B,new Map),u(this,j,new Array(s).fill(void 0)),u(this,_,new Array(s).fill(void 0)),u(this,rt,new A(s)),u(this,dt,new A(s)),u(this,st,0),u(this,Y,0),u(this,Mt,zo.create(s)),u(this,V,0),u(this,Tt,0),typeof d=="function"&&u(this,kt,d),typeof f=="function"&&u(this,be,f),typeof p=="function"?(u(this,Ot,p),u(this,Q,[])):(u(this,Ot,void 0),u(this,Q,void 0)),u(this,_t,!!r(this,kt)),u(this,Ne,!!r(this,be)),u(this,nt,!!r(this,Ot)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!T,this.allowStaleOnFetchRejection=!!k,this.allowStaleOnFetchAbort=!!M,this.ignoreFetchAbort=!!F,this.maxEntrySize!==0){if(r(this,ut)!==0&&!ee(r(this,ut)))throw new TypeError("maxSize must be a positive integer if specified");if(!ee(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");g(this,x,Qr).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=ee(n)||n===0?n:1,this.ttlAutopurge=!!o,this.ttl=i||0,this.ttl){if(!ee(this.ttl))throw new TypeError("ttl must be a positive integer if specified");g(this,x,Ci).call(this);}if(r(this,bt)===0&&this.ttl===0&&r(this,ut)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,bt)&&!r(this,ut)){let P="LRU_CACHE_UNBOUNDED";Wo(P)&&(Zr.add(P),Kr("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",P,We));}}get perf(){return r(this,Rt)}static unsafeExposeInternals(t){return {starts:r(t,Lt),ttls:r(t,pt),autopurgeTimers:r(t,ft),sizes:r(t,At),keyMap:r(t,B),keyList:r(t,j),valList:r(t,_),next:r(t,rt),prev:r(t,dt),get head(){return r(t,st)},get tail(){return r(t,Y)},free:r(t,Mt),isBackgroundFetch:s=>{var i;return g(i=t,x,I).call(i,s)},backgroundFetch:(s,i,n,o)=>{var a;return g(a=t,x,Js).call(a,s,i,n,o)},moveToTail:s=>{var i;return g(i=t,x,ss).call(i,s)},indexes:s=>{var i;return g(i=t,x,se).call(i,s)},rindexes:s=>{var i;return g(i=t,x,ie).call(i,s)},isStale:s=>{var i;return r(i=t,gt).call(i,s)}}}get max(){return r(this,bt)}get maxSize(){return r(this,ut)}get calculatedSize(){return r(this,Tt)}get size(){return r(this,V)}get fetchMethod(){return r(this,De)}get memoMethod(){return r(this,Ie)}get dispose(){return r(this,kt)}get onInsert(){return r(this,be)}get disposeAfter(){return r(this,Ot)}getRemainingTTL(t){return r(this,B).has(t)?1/0:0}*entries(){for(let t of g(this,x,se).call(this))r(this,_)[t]!==void 0&&r(this,j)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield [r(this,j)[t],r(this,_)[t]]);}*rentries(){for(let t of g(this,x,ie).call(this))r(this,_)[t]!==void 0&&r(this,j)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield [r(this,j)[t],r(this,_)[t]]);}*keys(){for(let t of g(this,x,se).call(this)){let s=r(this,j)[t];s!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield s);}}*rkeys(){for(let t of g(this,x,ie).call(this)){let s=r(this,j)[t];s!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield s);}}*values(){for(let t of g(this,x,se).call(this))r(this,_)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield r(this,_)[t]);}*rvalues(){for(let t of g(this,x,ie).call(this))r(this,_)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield r(this,_)[t]);}[(dr=Symbol.iterator,ur=Symbol.toStringTag,dr)](){return this.entries()}find(t,s={}){for(let i of g(this,x,se).call(this)){let n=r(this,_)[i],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;if(o!==void 0&&t(o,r(this,j)[i],this))return this.get(r(this,j)[i],s)}}forEach(t,s=this){for(let i of g(this,x,se).call(this)){let n=r(this,_)[i],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(s,o,r(this,j)[i],this);}}rforEach(t,s=this){for(let i of g(this,x,ie).call(this)){let n=r(this,_)[i],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(s,o,r(this,j)[i],this);}}purgeStale(){let t=false;for(let s of g(this,x,ie).call(this,{allowStale:true}))r(this,gt).call(this,s)&&(g(this,x,re).call(this,r(this,j)[s],"expire"),t=true);return t}info(t){let s=r(this,B).get(t);if(s===void 0)return;let i=r(this,_)[s],n=g(this,x,I).call(this,i)?i.__staleWhileFetching:i;if(n===void 0)return;let o={value:n};if(r(this,pt)&&r(this,Lt)){let a=r(this,pt)[s],l=r(this,Lt)[s];if(a&&l){let h=a-(r(this,Rt).now()-l);o.ttl=h,o.start=Date.now();}}return r(this,At)&&(o.size=r(this,At)[s]),o}dump(){let t=[];for(let s of g(this,x,se).call(this,{allowStale:true})){let i=r(this,j)[s],n=r(this,_)[s],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;if(o===void 0||i===void 0)continue;let a={value:o};if(r(this,pt)&&r(this,Lt)){a.ttl=r(this,pt)[s];let l=r(this,Rt).now()-r(this,Lt)[s];a.start=Math.floor(Date.now()-l);}r(this,At)&&(a.size=r(this,At)[s]),t.unshift([i,a]);}return t}load(t){this.clear();for(let[s,i]of t){if(i.start){let n=Date.now()-i.start;i.start=r(this,Rt).now()-n;}this.set(s,i.value,i);}}set(t,s,i={}){var y,b,S,v;if(s===void 0)return this.delete(t),this;let{ttl:n=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:h}=i,{noUpdateTTL:d=this.noUpdateTTL}=i,f=r(this,cs).call(this,t,s,i.size||0,l);if(this.maxEntrySize&&f>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),g(this,x,re).call(this,t,"set"),this;let p=r(this,V)===0?void 0:r(this,B).get(t);if(p===void 0)p=r(this,V)===0?r(this,Y):r(this,Mt).length!==0?r(this,Mt).pop():r(this,V)===r(this,bt)?g(this,x,qs).call(this,false):r(this,V),r(this,j)[p]=t,r(this,_)[p]=s,r(this,B).set(t,p),r(this,rt)[r(this,Y)]=p,r(this,dt)[p]=r(this,Y),u(this,Y,p),Ps(this,V)._++,r(this,je).call(this,p,f,h),h&&(h.set="add"),d=false,r(this,Ne)&&((y=r(this,be))==null||y.call(this,s,t,"add"));else {g(this,x,ss).call(this,p);let E=r(this,_)[p];if(s!==E){if(r(this,ae)&&g(this,x,I).call(this,E)){E.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=E;w!==void 0&&!a&&(r(this,_t)&&((b=r(this,kt))==null||b.call(this,w,t,"set")),r(this,nt)&&r(this,Q)?.push([w,t,"set"]));}else a||(r(this,_t)&&((S=r(this,kt))==null||S.call(this,E,t,"set")),r(this,nt)&&r(this,Q)?.push([E,t,"set"]));if(r(this,Se).call(this,p),r(this,je).call(this,p,f,h),r(this,_)[p]=s,h){h.set="replace";let w=E&&g(this,x,I).call(this,E)?E.__staleWhileFetching:E;w!==void 0&&(h.oldValue=w);}}else h&&(h.set="update");r(this,Ne)&&this.onInsert?.(s,t,s===E?"update":"replace");}if(n!==0&&!r(this,pt)&&g(this,x,Ci).call(this),r(this,pt)&&(d||r(this,hs).call(this,p,n,o),h&&r(this,Vt).call(this,h,p)),!a&&r(this,nt)&&r(this,Q)){let E=r(this,Q),w;for(;w=E?.shift();)(v=r(this,Ot))==null||v.call(this,...w);}return this}pop(){var t;try{for(;r(this,V);){let s=r(this,_)[r(this,st)];if(g(this,x,qs).call(this,!0),g(this,x,I).call(this,s)){if(s.__staleWhileFetching)return s.__staleWhileFetching}else if(s!==void 0)return s}}finally{if(r(this,nt)&&r(this,Q)){let s=r(this,Q),i;for(;i=s?.shift();)(t=r(this,Ot))==null||t.call(this,...i);}}}has(t,s={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=s,o=r(this,B).get(t);if(o!==void 0){let a=r(this,_)[o];if(g(this,x,I).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(r(this,gt).call(this,o))n&&(n.has="stale",r(this,Vt).call(this,n,o));else return i&&r(this,ve).call(this,o),n&&(n.has="hit",r(this,Vt).call(this,n,o)),true}else n&&(n.has="miss");return false}peek(t,s={}){let{allowStale:i=this.allowStale}=s,n=r(this,B).get(t);if(n===void 0||!i&&r(this,gt).call(this,n))return;let o=r(this,_)[n];return g(this,x,I).call(this,o)?o.__staleWhileFetching:o}async fetch(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:h=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:b=this.ignoreFetchAbort,allowStaleOnFetchAbort:S=this.allowStaleOnFetchAbort,context:v,forceRefresh:E=false,status:w,signal:O}=s;if(!r(this,ae))return w&&(w.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,status:w});let T={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:l,size:h,sizeCalculation:d,noUpdateTTL:f,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:S,ignoreFetchAbort:b,status:w,signal:O},C=r(this,B).get(t);if(C===void 0){w&&(w.fetch="miss");let k=g(this,x,Js).call(this,t,C,T,v);return k.__returned=k}else {let k=r(this,_)[C];if(g(this,x,I).call(this,k)){let A=i&&k.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",A&&(w.returnedStale=true)),A?k.__staleWhileFetching:k.__returned=k}let M=r(this,gt).call(this,C);if(!E&&!M)return w&&(w.fetch="hit"),g(this,x,ss).call(this,C),n&&r(this,ve).call(this,C),w&&r(this,Vt).call(this,w,C),k;let F=g(this,x,Js).call(this,t,C,T,v),D=F.__staleWhileFetching!==void 0&&i;return w&&(w.fetch=M?"stale":"refresh",D&&M&&(w.returnedStale=true)),D?F.__staleWhileFetching:F.__returned=F}}async forceFetch(t,s={}){let i=await this.fetch(t,s);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,s={}){let i=r(this,Ie);if(!i)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:o,...a}=s,l=this.get(t,a);if(!o&&l!==void 0)return l;let h=i(t,l,{options:a,context:n});return this.set(t,h,a),h}get(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=s,l=r(this,B).get(t);if(l!==void 0){let h=r(this,_)[l],d=g(this,x,I).call(this,h);return a&&r(this,Vt).call(this,a,l),r(this,gt).call(this,l)?(a&&(a.get="stale"),d?(a&&i&&h.__staleWhileFetching!==void 0&&(a.returnedStale=true),i?h.__staleWhileFetching:void 0):(o||g(this,x,re).call(this,t,"expire"),a&&i&&(a.returnedStale=true),i?h:void 0)):(a&&(a.get="hit"),d?h.__staleWhileFetching:(g(this,x,ss).call(this,l),n&&r(this,ve).call(this,l),h))}else a&&(a.get="miss");}delete(t){return g(this,x,re).call(this,t,"delete")}clear(){return g(this,x,Ri).call(this,"delete")}},bt=new WeakMap,ut=new WeakMap,kt=new WeakMap,be=new WeakMap,Ot=new WeakMap,De=new WeakMap,Ie=new WeakMap,Rt=new WeakMap,V=new WeakMap,Tt=new WeakMap,B=new WeakMap,j=new WeakMap,_=new WeakMap,rt=new WeakMap,dt=new WeakMap,st=new WeakMap,Y=new WeakMap,Mt=new WeakMap,Q=new WeakMap,At=new WeakMap,Lt=new WeakMap,pt=new WeakMap,ft=new WeakMap,_t=new WeakMap,ae=new WeakMap,nt=new WeakMap,Ne=new WeakMap,x=new WeakSet,Ci=function(){let t=new Vs(r(this,bt)),s=new Vs(r(this,bt));u(this,pt,t),u(this,Lt,s);let i=this.ttlAutopurge?new Array(r(this,bt)):void 0;u(this,ft,i),u(this,hs,(a,l,h=r(this,Rt).now())=>{if(s[a]=l!==0?h:0,t[a]=l,i?.[a]&&(clearTimeout(i[a]),i[a]=void 0),l!==0&&i){let d=setTimeout(()=>{r(this,gt).call(this,a)&&g(this,x,re).call(this,r(this,j)[a],"expire");},l+1);d.unref&&d.unref(),i[a]=d;}}),u(this,ve,a=>{s[a]=t[a]!==0?r(this,Rt).now():0;}),u(this,Vt,(a,l)=>{if(t[l]){let h=t[l],d=s[l];if(!h||!d)return;a.ttl=h,a.start=d,a.now=n||o();let f=a.now-d;a.remainingTTL=h-f;}});let n=0,o=()=>{let a=r(this,Rt).now();if(this.ttlResolution>0){n=a;let l=setTimeout(()=>n=0,this.ttlResolution);l.unref&&l.unref();}return a};this.getRemainingTTL=a=>{let l=r(this,B).get(a);if(l===void 0)return 0;let h=t[l],d=s[l];if(!h||!d)return 1/0;let f=(n||o())-d;return h-f},u(this,gt,a=>{let l=s[a],h=t[a];return !!h&&!!l&&(n||o())-l>h});},ve=new WeakMap,Vt=new WeakMap,hs=new WeakMap,gt=new WeakMap,Qr=function(){let t=new Vs(r(this,bt));u(this,Tt,0),u(this,At,t),u(this,Se,s=>{u(this,Tt,r(this,Tt)-t[s]),t[s]=0;}),u(this,cs,(s,i,n,o)=>{if(g(this,x,I).call(this,i))return 0;if(!ee(n))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(n=o(i,s),!ee(n))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 n}),u(this,je,(s,i,n)=>{if(t[s]=i,r(this,ut)){let o=r(this,ut)-t[s];for(;r(this,Tt)>o;)g(this,x,qs).call(this,true);}u(this,Tt,r(this,Tt)+t[s]),n&&(n.entrySize=i,n.totalCalculatedSize=r(this,Tt));});},Se=new WeakMap,je=new WeakMap,cs=new WeakMap,se=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let s=r(this,Y);!(!g(this,x,ki).call(this,s)||((t||!r(this,gt).call(this,s))&&(yield s),s===r(this,st)));)s=r(this,dt)[s];},ie=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let s=r(this,st);!(!g(this,x,ki).call(this,s)||((t||!r(this,gt).call(this,s))&&(yield s),s===r(this,Y)));)s=r(this,rt)[s];},ki=function(t){return t!==void 0&&r(this,B).get(r(this,j)[t])===t},qs=function(t){var o;let s=r(this,st),i=r(this,j)[s],n=r(this,_)[s];return r(this,ae)&&g(this,x,I).call(this,n)?n.__abortController.abort(new Error("evicted")):(r(this,_t)||r(this,nt))&&(r(this,_t)&&((o=r(this,kt))==null||o.call(this,n,i,"evict")),r(this,nt)&&r(this,Q)?.push([n,i,"evict"])),r(this,Se).call(this,s),r(this,ft)?.[s]&&(clearTimeout(r(this,ft)[s]),r(this,ft)[s]=void 0),t&&(r(this,j)[s]=void 0,r(this,_)[s]=void 0,r(this,Mt).push(s)),r(this,V)===1?(u(this,st,u(this,Y,0)),r(this,Mt).length=0):u(this,st,r(this,rt)[s]),r(this,B).delete(i),Ps(this,V)._--,s},Js=function(t,s,i,n){let o=s===void 0?void 0:r(this,_)[s];if(g(this,x,I).call(this,o))return o;let a=new Xs,{signal:l}=i;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let h={signal:a.signal,options:i,context:n},d=(v,E=false)=>{let{aborted:w}=a.signal,O=i.ignoreFetchAbort&&v!==void 0,T=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&v!==void 0);if(i.status&&(w&&!E?(i.status.fetchAborted=true,i.status.fetchError=a.signal.reason,O&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),w&&!O&&!E)return p(a.signal.reason,T);let C=b,k=r(this,_)[s];return (k===b||O&&E&&k===void 0)&&(v===void 0?C.__staleWhileFetching!==void 0?r(this,_)[s]=C.__staleWhileFetching:g(this,x,re).call(this,t,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(t,v,h.options))),v},f=v=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=v),p(v,false)),p=(v,E)=>{let{aborted:w}=a.signal,O=w&&i.allowStaleOnFetchAbort,T=O||i.allowStaleOnFetchRejection,C=T||i.noDeleteOnFetchRejection,k=b;if(r(this,_)[s]===b&&(!C||!E&&k.__staleWhileFetching===void 0?g(this,x,re).call(this,t,"fetch"):O||(r(this,_)[s]=k.__staleWhileFetching)),T)return i.status&&k.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),k.__staleWhileFetching;if(k.__returned===k)throw v},y=(v,E)=>{var O;let w=(O=r(this,De))==null?void 0:O.call(this,t,o,h);w&&w instanceof Promise&&w.then(T=>v(T===void 0?void 0:T),E),a.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(v(void 0),i.allowStaleOnFetchAbort&&(v=T=>d(T,true)));});};i.status&&(i.status.fetchDispatched=true);let b=new Promise(y).then(d,f),S=Object.assign(b,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return s===void 0?(this.set(t,S,{...h.options,status:void 0}),s=r(this,B).get(t)):r(this,_)[s]=S,S},I=function(t){if(!r(this,ae))return false;let s=t;return !!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Xs},Oi=function(t,s){r(this,dt)[s]=t,r(this,rt)[t]=s;},ss=function(t){t!==r(this,Y)&&(t===r(this,st)?u(this,st,r(this,rt)[t]):g(this,x,Oi).call(this,r(this,dt)[t],r(this,rt)[t]),g(this,x,Oi).call(this,r(this,Y),t),u(this,Y,t));},re=function(t,s){var n,o;let i=false;if(r(this,V)!==0){let a=r(this,B).get(t);if(a!==void 0)if(r(this,ft)?.[a]&&(clearTimeout(r(this,ft)?.[a]),r(this,ft)[a]=void 0),i=true,r(this,V)===1)g(this,x,Ri).call(this,s);else {r(this,Se).call(this,a);let l=r(this,_)[a];if(g(this,x,I).call(this,l)?l.__abortController.abort(new Error("deleted")):(r(this,_t)||r(this,nt))&&(r(this,_t)&&((n=r(this,kt))==null||n.call(this,l,t,s)),r(this,nt)&&r(this,Q)?.push([l,t,s])),r(this,B).delete(t),r(this,j)[a]=void 0,r(this,_)[a]=void 0,a===r(this,Y))u(this,Y,r(this,dt)[a]);else if(a===r(this,st))u(this,st,r(this,rt)[a]);else {let h=r(this,dt)[a];r(this,rt)[h]=r(this,rt)[a];let d=r(this,rt)[a];r(this,dt)[d]=r(this,dt)[a];}Ps(this,V)._--,r(this,Mt).push(a);}}if(r(this,nt)&&r(this,Q)?.length){let a=r(this,Q),l;for(;l=a?.shift();)(o=r(this,Ot))==null||o.call(this,...l);}return i},Ri=function(t){var s,i;for(let n of g(this,x,ie).call(this,{allowStale:true})){let o=r(this,_)[n];if(g(this,x,I).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=r(this,j)[n];r(this,_t)&&((s=r(this,kt))==null||s.call(this,o,a,t)),r(this,nt)&&r(this,Q)?.push([o,a,t]);}}if(r(this,B).clear(),r(this,_).fill(void 0),r(this,j).fill(void 0),r(this,pt)&&r(this,Lt)){r(this,pt).fill(0),r(this,Lt).fill(0);for(let n of r(this,ft)??[])n!==void 0&&clearTimeout(n);r(this,ft)?.fill(void 0);}if(r(this,At)&&r(this,At).fill(0),u(this,st,0),u(this,Y,0),r(this,Mt).length=0,u(this,Tt,0),u(this,V,0),r(this,nt)&&r(this,Q)){let n=r(this,Q),o;for(;o=n?.shift();)(i=r(this,Ot))==null||i.call(this,...o);}},We),Yi=typeof process=="object"&&process?process:{stdout:null,stderr:null},ta=e=>!!e&&typeof e=="object"&&(e instanceof ti||e instanceof Xr||ea(e)||sa(e)),ea=e=>!!e&&typeof e=="object"&&e instanceof EventEmitter&&typeof e.pipe=="function"&&e.pipe!==Xr.Writable.prototype.pipe,sa=e=>!!e&&typeof e=="object"&&e instanceof EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",Ut=Symbol("EOF"),Bt=Symbol("maybeEmitEnd"),te=Symbol("emittedEnd"),Ns=Symbol("emittingEnd"),Ke=Symbol("emittedError"),js=Symbol("closed"),Qi=Symbol("read"),Ws=Symbol("flush"),Xi=Symbol("flushChunk"),Et=Symbol("encoding"),Le=Symbol("decoder"),J=Symbol("flowing"),Ye=Symbol("paused"),_e=Symbol("resume"),H=Symbol("buffer"),it=Symbol("pipes"),Z=Symbol("bufferLength"),gi=Symbol("bufferPush"),zs=Symbol("bufferShift"),et=Symbol("objectMode"),$=Symbol("destroyed"),mi=Symbol("error"),yi=Symbol("emitData"),tr=Symbol("emitEnd"),wi=Symbol("emitEnd2"),It=Symbol("async"),bi=Symbol("abort"),$s=Symbol("aborted"),Qe=Symbol("signal"),fe=Symbol("dataListeners"),ct=Symbol("discarded"),Xe=e=>Promise.resolve().then(e),ia=e=>e(),ra=e=>e==="end"||e==="finish"||e==="prefinish",na=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,oa=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),tn=class{constructor(e,t,s){c(this,"src");c(this,"dest");c(this,"opts");c(this,"ondrain");this.src=e,this.dest=t,this.opts=s,this.ondrain=()=>e[_e](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},aa=class extends tn{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(e,t,s){super(e,t,s),this.proxyErrors=i=>t.emit("error",i),e.on("error",this.proxyErrors);}},la=e=>!!e.objectMode,ha=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",pr,fr,gr,mr,yr,wr,br,vr,Sr,xr,Er,Cr,kr,Or,Rr,Tr,Mr,Ar,Lr,ti=class extends EventEmitter{constructor(...t){let s=t[0]||{};super();c(this,Lr,false);c(this,Ar,false);c(this,Mr,[]);c(this,Tr,[]);c(this,Rr);c(this,Or);c(this,kr);c(this,Cr);c(this,Er,false);c(this,xr,false);c(this,Sr,false);c(this,vr,false);c(this,br,null);c(this,wr,0);c(this,yr,false);c(this,mr);c(this,gr,false);c(this,fr,0);c(this,pr,false);c(this,"writable",true);c(this,"readable",true);if(s.objectMode&&typeof s.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");la(s)?(this[et]=true,this[Et]=null):ha(s)?(this[Et]=s.encoding,this[et]=false):(this[et]=false,this[Et]=null),this[It]=!!s.async,this[Le]=this[Et]?new StringDecoder(this[Et]):null,s&&s.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[H]}),s&&s.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[it]});let{signal:i}=s;i&&(this[Qe]=i,i.aborted?this[bi]():i.addEventListener("abort",()=>this[bi]()));}get bufferLength(){return this[Z]}get encoding(){return this[Et]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[et]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[It]}set async(t){this[It]=this[It]||!!t;}[(Lr=J,Ar=Ye,Mr=it,Tr=H,Rr=et,Or=Et,kr=It,Cr=Le,Er=Ut,xr=te,Sr=Ns,vr=js,br=Ke,wr=Z,yr=$,mr=Qe,gr=$s,fr=fe,pr=ct,bi)](){this[$s]=true,this.emit("abort",this[Qe]?.reason),this.destroy(this[Qe]?.reason);}get aborted(){return this[$s]}set aborted(t){}write(t,s,i){if(this[$s])return false;if(this[Ut])throw new Error("write after end");if(this[$])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;typeof s=="function"&&(i=s,s="utf8"),s||(s="utf8");let n=this[It]?Xe:ia;if(!this[et]&&!Buffer.isBuffer(t)){if(oa(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(na(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[et]?(this[J]&&this[Z]!==0&&this[Ws](true),this[J]?this.emit("data",t):this[gi](t),this[Z]!==0&&this.emit("readable"),i&&n(i),this[J]):t.length?(typeof t=="string"&&!(s===this[Et]&&!this[Le]?.lastNeed)&&(t=Buffer.from(t,s)),Buffer.isBuffer(t)&&this[Et]&&(t=this[Le].write(t)),this[J]&&this[Z]!==0&&this[Ws](true),this[J]?this.emit("data",t):this[gi](t),this[Z]!==0&&this.emit("readable"),i&&n(i),this[J]):(this[Z]!==0&&this.emit("readable"),i&&n(i),this[J])}read(t){if(this[$])return null;if(this[ct]=false,this[Z]===0||t===0||t&&t>this[Z])return this[Bt](),null;this[et]&&(t=null),this[H].length>1&&!this[et]&&(this[H]=[this[Et]?this[H].join(""):Buffer.concat(this[H],this[Z])]);let s=this[Qi](t||null,this[H][0]);return this[Bt](),s}[Qi](t,s){if(this[et])this[zs]();else {let i=s;t===i.length||t===null?this[zs]():typeof i=="string"?(this[H][0]=i.slice(t),s=i.slice(0,t),this[Z]-=t):(this[H][0]=i.subarray(t),s=i.subarray(0,t),this[Z]-=t);}return this.emit("data",s),!this[H].length&&!this[Ut]&&this.emit("drain"),s}end(t,s,i){return typeof t=="function"&&(i=t,t=void 0),typeof s=="function"&&(i=s,s="utf8"),t!==void 0&&this.write(t,s),i&&this.once("end",i),this[Ut]=true,this.writable=false,(this[J]||!this[Ye])&&this[Bt](),this}[_e](){this[$]||(!this[fe]&&!this[it].length&&(this[ct]=true),this[Ye]=false,this[J]=true,this.emit("resume"),this[H].length?this[Ws]():this[Ut]?this[Bt]():this.emit("drain"));}resume(){return this[_e]()}pause(){this[J]=false,this[Ye]=true,this[ct]=false;}get destroyed(){return this[$]}get flowing(){return this[J]}get paused(){return this[Ye]}[gi](t){this[et]?this[Z]+=1:this[Z]+=t.length,this[H].push(t);}[zs](){return this[et]?this[Z]-=1:this[Z]-=this[H][0].length,this[H].shift()}[Ws](t=false){do;while(this[Xi](this[zs]())&&this[H].length);!t&&!this[H].length&&!this[Ut]&&this.emit("drain");}[Xi](t){return this.emit("data",t),this[J]}pipe(t,s){if(this[$])return t;this[ct]=false;let i=this[te];return s=s||{},t===Yi.stdout||t===Yi.stderr?s.end=false:s.end=s.end!==false,s.proxyErrors=!!s.proxyErrors,i?s.end&&t.end():(this[it].push(s.proxyErrors?new aa(this,t,s):new tn(this,t,s)),this[It]?Xe(()=>this[_e]()):this[_e]()),t}unpipe(t){let s=this[it].find(i=>i.dest===t);s&&(this[it].length===1?(this[J]&&this[fe]===0&&(this[J]=false),this[it]=[]):this[it].splice(this[it].indexOf(s),1),s.unpipe());}addListener(t,s){return this.on(t,s)}on(t,s){let i=super.on(t,s);if(t==="data")this[ct]=false,this[fe]++,!this[it].length&&!this[J]&&this[_e]();else if(t==="readable"&&this[Z]!==0)super.emit("readable");else if(ra(t)&&this[te])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ke]){let n=s;this[It]?Xe(()=>n.call(this,this[Ke])):n.call(this,this[Ke]);}return i}removeListener(t,s){return this.off(t,s)}off(t,s){let i=super.off(t,s);return t==="data"&&(this[fe]=this.listeners("data").length,this[fe]===0&&!this[ct]&&!this[it].length&&(this[J]=false)),i}removeAllListeners(t){let s=super.removeAllListeners(t);return (t==="data"||t===void 0)&&(this[fe]=0,!this[ct]&&!this[it].length&&(this[J]=false)),s}get emittedEnd(){return this[te]}[Bt](){!this[Ns]&&!this[te]&&!this[$]&&this[H].length===0&&this[Ut]&&(this[Ns]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[js]&&this.emit("close"),this[Ns]=false);}emit(t,...s){let i=s[0];if(t!=="error"&&t!=="close"&&t!==$&&this[$])return false;if(t==="data")return !this[et]&&!i?false:this[It]?(Xe(()=>this[yi](i)),true):this[yi](i);if(t==="end")return this[tr]();if(t==="close"){if(this[js]=true,!this[te]&&!this[$])return false;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Ke]=i,super.emit(mi,i);let o=!this[Qe]||this.listeners("error").length?super.emit("error",i):false;return this[Bt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Bt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let n=super.emit(t,...s);return this[Bt](),n}[yi](t){for(let i of this[it])i.dest.write(t)===false&&this.pause();let s=this[ct]?false:super.emit("data",t);return this[Bt](),s}[tr](){return this[te]?false:(this[te]=true,this.readable=false,this[It]?(Xe(()=>this[wi]()),true):this[wi]())}[wi](){if(this[Le]){let s=this[Le].end();if(s){for(let i of this[it])i.dest.write(s);this[ct]||super.emit("data",s);}}for(let s of this[it])s.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[et]||(t.dataLength=0);let s=this.promise();return this.on("data",i=>{t.push(i),this[et]||(t.dataLength+=i.length);}),await s,t}async concat(){if(this[et])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Et]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,s)=>{this.on($,()=>s(new Error("stream destroyed"))),this.on("error",i=>s(i)),this.on("end",()=>t());})}[Symbol.asyncIterator](){this[ct]=false;let t=false,s=async()=>(this.pause(),t=true,{value:void 0,done:true});return {next:()=>{if(t)return s();let i=this.read();if(i!==null)return Promise.resolve({done:false,value:i});if(this[Ut])return s();let n,o,a=f=>{this.off("data",l),this.off("end",h),this.off($,d),s(),o(f);},l=f=>{this.off("error",a),this.off("end",h),this.off($,d),this.pause(),n({value:f,done:!!this[Ut]});},h=()=>{this.off("error",a),this.off("data",l),this.off($,d),s(),n({done:true,value:void 0});},d=()=>a(new Error("stream destroyed"));return new Promise((f,p)=>{o=p,n=f,this.once($,d),this.once("error",a),this.once("end",h),this.once("data",l);})},throw:s,return:s,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[ct]=false;let t=false,s=()=>(this.pause(),this.off(mi,s),this.off($,s),this.off("end",s),t=true,{done:true,value:void 0}),i=()=>{if(t)return s();let n=this.read();return n===null?s():{done:false,value:n}};return this.once("end",s),this.once(mi,s),this.once($,s),{next:i,throw:s,return:s,[Symbol.iterator](){return this}}}destroy(t){if(this[$])return t?this.emit("error",t):this.emit($),this;this[$]=true,this[ct]=true,this[H].length=0,this[Z]=0;let s=this;return typeof s.close=="function"&&!this[js]&&s.close(),t?this.emit("error",t):this.emit($),this}static get isStream(){return ta}},ca=realpathSync.native,is={lstatSync:lstatSync,readdir:readdir$1,readdirSync:readdirSync,readlinkSync:readlinkSync,realpathSync:ca,promises:{lstat:lstat,readdir:readdir,readlink:readlink,realpath:realpath}},en=e=>!e||e===is||e===Ho?is:{...is,...e,promises:{...is.promises,...e.promises||{}}},sn=/^\\\\\?\\([a-z]:)\\?$/i,ua=e=>e.replace(/\//g,"\\").replace(sn,"$1\\"),da=/[\\\/]/,vt=0,rn=1,nn=2,Nt=4,on=6,an=8,ge=10,ln=12,wt=15,ts=~wt,vi=16,er=32,rs=64,Ct=128,Us=256,Hs=512,sr=rs|Ct|Hs,pa=1023,Si=e=>e.isFile()?an:e.isDirectory()?Nt:e.isSymbolicLink()?ge:e.isCharacterDevice()?nn:e.isBlockDevice()?on:e.isSocket()?ln:e.isFIFO()?rn:vt,ir=new si({max:2**12}),ns=e=>{let t=ir.get(e);if(t)return t;let s=e.normalize("NFKD");return ir.set(e,s),s},rr=new si({max:2**12}),Bs=e=>{let t=rr.get(e);if(t)return t;let s=ns(e.toLowerCase());return rr.set(e,s),s},nr=class extends si{constructor(){super({max:256});}},fa=class extends si{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1});}},hn=Symbol("PathScurry setAsCwd"),ot,us,ds,ps,fs,gs,ms,ys,ws,bs,vs,Ss,xs,Es,Cs,ks,Os,Rs,Ts,le,xe,Wt,qt,Jt,Ht,L,Ee,Zt,zt,R,Mi,Zs,os,Ai,Li,as,Ks,_i,Fi,Ys,cn,un,dn,Pi,ze,$e,pn,Ce,_r,ht=(_r=class{constructor(e,t=vt,s,i,n,o,a){m(this,R);c(this,"name");c(this,"root");c(this,"roots");c(this,"parent");c(this,"nocase");c(this,"isCWD",false);m(this,ot);m(this,us);m(this,ds);m(this,ps);m(this,fs);m(this,gs);m(this,ms);m(this,ys);m(this,ws);m(this,bs);m(this,vs);m(this,Ss);m(this,xs);m(this,Es);m(this,Cs);m(this,ks);m(this,Os);m(this,Rs);m(this,Ts);m(this,le);m(this,xe);m(this,Wt);m(this,qt);m(this,Jt);m(this,Ht);m(this,L);m(this,Ee);m(this,Zt);m(this,zt);m(this,ze,[]);m(this,$e,false);m(this,Ce);this.name=e,u(this,le,n?Bs(e):ns(e)),u(this,L,t&pa),this.nocase=n,this.roots=i,this.root=s||this,u(this,Ee,o),u(this,Wt,a.fullpath),u(this,Jt,a.relative),u(this,Ht,a.relativePosix),this.parent=a.parent,this.parent?u(this,ot,r(this.parent,ot)):u(this,ot,en(a.fs));}get dev(){return r(this,us)}get mode(){return r(this,ds)}get nlink(){return r(this,ps)}get uid(){return r(this,fs)}get gid(){return r(this,gs)}get rdev(){return r(this,ms)}get blksize(){return r(this,ys)}get ino(){return r(this,ws)}get size(){return r(this,bs)}get blocks(){return r(this,vs)}get atimeMs(){return r(this,Ss)}get mtimeMs(){return r(this,xs)}get ctimeMs(){return r(this,Es)}get birthtimeMs(){return r(this,Cs)}get atime(){return r(this,ks)}get mtime(){return r(this,Os)}get ctime(){return r(this,Rs)}get birthtime(){return r(this,Ts)}get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return r(this,xe)!==void 0?r(this,xe):this.parent?u(this,xe,this.parent.depth()+1):u(this,xe,0)}childrenCache(){return r(this,Ee)}resolve(e){var i;if(!e)return this;let t=this.getRootString(e),s=e.substring(t.length).split(this.splitSep);return t?g(i=this.getRoot(t),R,Mi).call(i,s):g(this,R,Mi).call(this,s)}children(){let e=r(this,Ee).get(this);if(e)return e;let t=Object.assign([],{provisional:0});return r(this,Ee).set(this,t),u(this,L,r(this,L)&~vi),t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),i=this.nocase?Bs(e):ns(e);for(let l of s)if(r(l,le)===i)return l;let n=this.parent?this.sep:"",o=r(this,Wt)?r(this,Wt)+n+e:void 0,a=this.newChild(e,vt,{...t,parent:this,fullpath:o});return this.canReaddir()||u(a,L,r(a,L)|Ct),s.push(a),a}relative(){if(this.isCWD)return "";if(r(this,Jt)!==void 0)return r(this,Jt);let e=this.name,t=this.parent;if(!t)return u(this,Jt,this.name);let s=t.relative();return s+(!s||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return "";if(r(this,Ht)!==void 0)return r(this,Ht);let e=this.name,t=this.parent;if(!t)return u(this,Ht,this.fullpathPosix());let s=t.relativePosix();return s+(!s||!t.parent?"":"/")+e}fullpath(){if(r(this,Wt)!==void 0)return r(this,Wt);let e=this.name,t=this.parent;if(!t)return u(this,Wt,this.name);let s=t.fullpath()+(t.parent?this.sep:"")+e;return u(this,Wt,s)}fullpathPosix(){if(r(this,qt)!==void 0)return r(this,qt);if(this.sep==="/")return u(this,qt,this.fullpath());if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(i)?u(this,qt,`//?/${i}`):u(this,qt,i)}let e=this.parent,t=e.fullpathPosix(),s=t+(!t||!e.parent?"":"/")+this.name;return u(this,qt,s)}isUnknown(){return (r(this,L)&wt)===vt}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 (r(this,L)&wt)===an}isDirectory(){return (r(this,L)&wt)===Nt}isCharacterDevice(){return (r(this,L)&wt)===nn}isBlockDevice(){return (r(this,L)&wt)===on}isFIFO(){return (r(this,L)&wt)===rn}isSocket(){return (r(this,L)&wt)===ln}isSymbolicLink(){return (r(this,L)&ge)===ge}lstatCached(){return r(this,L)&er?this:void 0}readlinkCached(){return r(this,Zt)}realpathCached(){return r(this,zt)}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(r(this,Zt))return true;if(!this.parent)return false;let e=r(this,L)&wt;return !(e!==vt&&e!==ge||r(this,L)&Us||r(this,L)&Ct)}calledReaddir(){return !!(r(this,L)&vi)}isENOENT(){return !!(r(this,L)&Ct)}isNamed(e){return this.nocase?r(this,le)===Bs(e):r(this,le)===ns(e)}async readlink(){let e=r(this,Zt);if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await r(this,ot).promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(t);if(s)return u(this,Zt,s)}catch(t){g(this,R,Fi).call(this,t.code);return}}readlinkSync(){let e=r(this,Zt);if(e)return e;if(this.canReadlink()&&this.parent)try{let t=r(this,ot).readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(t);if(s)return u(this,Zt,s)}catch(t){g(this,R,Fi).call(this,t.code);return}}async lstat(){if((r(this,L)&Ct)===0)try{return g(this,R,Pi).call(this,await r(this,ot).promises.lstat(this.fullpath())),this}catch(e){g(this,R,_i).call(this,e.code);}}lstatSync(){if((r(this,L)&Ct)===0)try{return g(this,R,Pi).call(this,r(this,ot).lstatSync(this.fullpath())),this}catch(e){g(this,R,_i).call(this,e.code);}}readdirCB(e,t=false){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let s=this.children();if(this.calledReaddir()){let n=s.slice(0,s.provisional);t?e(null,n):queueMicrotask(()=>e(null,n));return}if(r(this,ze).push(e),r(this,$e))return;u(this,$e,true);let i=this.fullpath();r(this,ot).readdir(i,{withFileTypes:true},(n,o)=>{if(n)g(this,R,Ks).call(this,n.code),s.provisional=0;else {for(let a of o)g(this,R,Ys).call(this,a,s);g(this,R,Zs).call(this,s);}g(this,R,pn).call(this,s.slice(0,s.provisional));});}async readdir(){if(!this.canReaddir())return [];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(r(this,Ce))await r(this,Ce);else {let s=()=>{};u(this,Ce,new Promise(i=>s=i));try{for(let i of await r(this,ot).promises.readdir(t,{withFileTypes:!0}))g(this,R,Ys).call(this,i,e);g(this,R,Zs).call(this,e);}catch(i){g(this,R,Ks).call(this,i.code),e.provisional=0;}u(this,Ce,void 0),s();}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 t=this.fullpath();try{for(let s of r(this,ot).readdirSync(t,{withFileTypes:!0}))g(this,R,Ys).call(this,s,e);g(this,R,Zs).call(this,e);}catch(s){g(this,R,Ks).call(this,s.code),e.provisional=0;}return e.slice(0,e.provisional)}canReaddir(){if(r(this,L)&sr)return false;let e=wt&r(this,L);return e===vt||e===Nt||e===ge}shouldWalk(e,t){return (r(this,L)&Nt)===Nt&&!(r(this,L)&sr)&&!e.has(this)&&(!t||t(this))}async realpath(){if(r(this,zt))return r(this,zt);if(!((Hs|Us|Ct)&r(this,L)))try{let e=await r(this,ot).promises.realpath(this.fullpath());return u(this,zt,this.resolve(e))}catch{g(this,R,Li).call(this);}}realpathSync(){if(r(this,zt))return r(this,zt);if(!((Hs|Us|Ct)&r(this,L)))try{let e=r(this,ot).realpathSync(this.fullpath());return u(this,zt,this.resolve(e))}catch{g(this,R,Li).call(this);}}[hn](e){if(e===this)return;e.isCWD=false,this.isCWD=true;let t=new Set([]),s=[],i=this;for(;i&&i.parent;)t.add(i),u(i,Jt,s.join(this.sep)),u(i,Ht,s.join("/")),i=i.parent,s.push("..");for(i=e;i&&i.parent&&!t.has(i);)u(i,Jt,void 0),u(i,Ht,void 0),i=i.parent;}},ot=new WeakMap,us=new WeakMap,ds=new WeakMap,ps=new WeakMap,fs=new WeakMap,gs=new WeakMap,ms=new WeakMap,ys=new WeakMap,ws=new WeakMap,bs=new WeakMap,vs=new WeakMap,Ss=new WeakMap,xs=new WeakMap,Es=new WeakMap,Cs=new WeakMap,ks=new WeakMap,Os=new WeakMap,Rs=new WeakMap,Ts=new WeakMap,le=new WeakMap,xe=new WeakMap,Wt=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Ht=new WeakMap,L=new WeakMap,Ee=new WeakMap,Zt=new WeakMap,zt=new WeakMap,R=new WeakSet,Mi=function(e){let t=this;for(let s of e)t=t.child(s);return t},Zs=function(e){var t;u(this,L,r(this,L)|vi);for(let s=e.provisional;s<e.length;s++){let i=e[s];i&&g(t=i,R,os).call(t);}},os=function(){r(this,L)&Ct||(u(this,L,(r(this,L)|Ct)&ts),g(this,R,Ai).call(this));},Ai=function(){var t;let e=this.children();e.provisional=0;for(let s of e)g(t=s,R,os).call(t);},Li=function(){u(this,L,r(this,L)|Hs),g(this,R,as).call(this);},as=function(){if(r(this,L)&rs)return;let e=r(this,L);(e&wt)===Nt&&(e&=ts),u(this,L,e|rs),g(this,R,Ai).call(this);},Ks=function(e=""){e==="ENOTDIR"||e==="EPERM"?g(this,R,as).call(this):e==="ENOENT"?g(this,R,os).call(this):this.children().provisional=0;},_i=function(e=""){var t;e==="ENOTDIR"?g(t=this.parent,R,as).call(t):e==="ENOENT"&&g(this,R,os).call(this);},Fi=function(e=""){var s;let t=r(this,L);t|=Us,e==="ENOENT"&&(t|=Ct),(e==="EINVAL"||e==="UNKNOWN")&&(t&=ts),u(this,L,t),e==="ENOTDIR"&&this.parent&&g(s=this.parent,R,as).call(s);},Ys=function(e,t){return g(this,R,un).call(this,e,t)||g(this,R,cn).call(this,e,t)},cn=function(e,t){let s=Si(e),i=this.newChild(e.name,s,{parent:this}),n=r(i,L)&wt;return n!==Nt&&n!==ge&&n!==vt&&u(i,L,r(i,L)|rs),t.unshift(i),t.provisional++,i},un=function(e,t){for(let s=t.provisional;s<t.length;s++){let i=t[s];if((this.nocase?Bs(e.name):ns(e.name))===r(i,le))return g(this,R,dn).call(this,e,i,s,t)}},dn=function(e,t,s,i){let n=t.name;return u(t,L,r(t,L)&ts|Si(e)),n!==e.name&&(t.name=e.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(t)),i.provisional++,t},Pi=function(e){let{atime:t,atimeMs:s,birthtime:i,birthtimeMs:n,blksize:o,blocks:a,ctime:l,ctimeMs:h,dev:d,gid:f,ino:p,mode:y,mtime:b,mtimeMs:S,nlink:v,rdev:E,size:w,uid:O}=e;u(this,ks,t),u(this,Ss,s),u(this,Ts,i),u(this,Cs,n),u(this,ys,o),u(this,vs,a),u(this,Rs,l),u(this,Es,h),u(this,us,d),u(this,gs,f),u(this,ws,p),u(this,ds,y),u(this,Os,b),u(this,xs,S),u(this,ps,v),u(this,ms,E),u(this,bs,w),u(this,fs,O);let T=Si(e);u(this,L,r(this,L)&ts|T|er),T!==vt&&T!==Nt&&T!==ge&&u(this,L,r(this,L)|rs);},ze=new WeakMap,$e=new WeakMap,pn=function(e){u(this,$e,false);let t=r(this,ze).slice();r(this,ze).length=0,t.forEach(s=>s(null,e));},Ce=new WeakMap,_r),fn=class gn extends ht{constructor(s,i=vt,n,o,a,l,h){super(s,i,n,o,a,l,h);c(this,"sep","\\");c(this,"splitSep",da);}newChild(s,i=vt,n={}){return new gn(s,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(s){return win32.parse(s).root}getRoot(s){if(s=ua(s.toUpperCase()),s===this.root.name)return this.root;for(let[i,n]of Object.entries(this.roots))if(this.sameRoot(s,i))return this.roots[s]=n;return this.roots[s]=new Wi(s,this).root}sameRoot(s,i=this.root.name){return s=s.toUpperCase().replace(/\//g,"\\").replace(sn,"$1\\"),s===i}},mn=class yn extends ht{constructor(s,i=vt,n,o,a,l,h){super(s,i,n,o,a,l,h);c(this,"splitSep","/");c(this,"sep","/");}getRootString(s){return s.startsWith("/")?"/":""}getRoot(s){return this.root}newChild(s,i=vt,n={}){return new yn(s,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}},Ue,Be,Ms,As,Fr,wn=(Fr=class{constructor(e=process.cwd(),t,s,{nocase:i,childrenCacheSize:n=16*1024,fs:o=is}={}){c(this,"root");c(this,"rootPath");c(this,"roots");c(this,"cwd");m(this,Ue);m(this,Be);m(this,Ms);c(this,"nocase");m(this,As);u(this,As,en(o)),(e instanceof URL||e.startsWith("file://"))&&(e=fileURLToPath(e));let a=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),u(this,Ue,new nr),u(this,Be,new nr),u(this,Ms,new fa(n));let l=a.substring(this.rootPath.length).split(s);if(l.length===1&&!l[0]&&l.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(r(this,As)),this.roots[this.rootPath]=this.root;let h=this.root,d=l.length-1,f=t.sep,p=this.rootPath,y=false;for(let b of l){let S=d--;h=h.child(b,{relative:new Array(S).fill("..").join(f),relativePosix:new Array(S).fill("..").join("/"),fullpath:p+=(y?"":f)+b}),y=true;}this.cwd=h;}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return r(this,Ms)}resolve(...e){let t="";for(let n=e.length-1;n>=0;n--){let o=e[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=r(this,Ue).get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpath();return r(this,Ue).set(t,i),i}resolvePosix(...e){let t="";for(let n=e.length-1;n>=0;n--){let o=e[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=r(this,Be).get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpathPosix();return r(this,Be).set(t,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,t={withFileTypes:true}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s}=t;if(e.canReaddir()){let i=await e.readdir();return s?i:i.map(n=>n.name)}else return []}readdirSync(e=this.cwd,t={withFileTypes:true}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true}=t;return e.canReaddir()?s?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:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=await e.readlink();return t?s:s?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=e.readlinkSync();return t?s:s?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=await e.realpath();return t?s:s?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=e.realpathSync();return t?s:s?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(e))&&a.push(s?e:e.fullpath());let l=new Set,h=(f,p)=>{l.add(f),f.readdirCB((y,b)=>{if(y)return p(y);let S=b.length;if(!S)return p();let v=()=>{--S===0&&p();};for(let E of b)(!n||n(E))&&a.push(s?E:E.fullpath()),i&&E.isSymbolicLink()?E.realpath().then(w=>w?.isUnknown()?w.lstat():w).then(w=>w?.shouldWalk(l,o)?h(w,v):v()):E.shouldWalk(l,o)?h(E,v):v();},true);},d=e;return new Promise((f,p)=>{h(d,y=>{if(y)return p(y);f(a);});})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(e))&&a.push(s?e:e.fullpath());let l=new Set([e]);for(let h of l){let d=h.readdirSync();for(let f of d){(!n||n(f))&&a.push(s?f:f.fullpath());let p=f;if(f.isSymbolicLink()){if(!(i&&(p=f.realpathSync())))continue;p.isUnknown()&&p.lstatSync();}p.shouldWalk(l,o)&&l.add(p);}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t;(!n||n(e))&&(yield s?e:e.fullpath());let a=new Set([e]);for(let l of a){let h=l.readdirSync();for(let d of h){(!n||n(d))&&(yield s?d:d.fullpath());let f=d;if(d.isSymbolicLink()){if(!(i&&(f=d.realpathSync())))continue;f.isUnknown()&&f.lstatSync();}f.shouldWalk(a,o)&&a.add(f);}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=new ti({objectMode:true});(!n||n(e))&&a.write(s?e:e.fullpath());let l=new Set,h=[e],d=0,f=()=>{let p=false;for(;!p;){let y=h.shift();if(!y){d===0&&a.end();return}d++,l.add(y);let b=(v,E,w=false)=>{if(v)return a.emit("error",v);if(i&&!w){let O=[];for(let T of E)T.isSymbolicLink()&&O.push(T.realpath().then(C=>C?.isUnknown()?C.lstat():C));if(O.length){Promise.all(O).then(()=>b(null,E,true));return}}for(let O of E)O&&(!n||n(O))&&(a.write(s?O:O.fullpath())||(p=true));d--;for(let O of E){let T=O.realpathCached()||O;T.shouldWalk(l,o)&&h.push(T);}p&&!a.flowing?a.once("drain",f):S||f();},S=true;y.readdirCB(b,true),S=false;}};return f(),a}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=new ti({objectMode:true}),l=new Set;(!n||n(e))&&a.write(s?e:e.fullpath());let h=[e],d=0,f=()=>{let p=false;for(;!p;){let y=h.shift();if(!y){d===0&&a.end();return}d++,l.add(y);let b=y.readdirSync();for(let S of b)(!n||n(S))&&(a.write(s?S:S.fullpath())||(p=true));d--;for(let S of b){let v=S;if(S.isSymbolicLink()){if(!(i&&(v=S.realpathSync())))continue;v.isUnknown()&&v.lstatSync();}v.shouldWalk(l,o)&&h.push(v);}}p&&!a.flowing&&a.once("drain",f);};return f(),a}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[hn](t);}},Ue=new WeakMap,Be=new WeakMap,Ms=new WeakMap,As=new WeakMap,Fr),Wi=class extends wn{constructor(t=process.cwd(),s={}){let{nocase:i=true}=s;super(t,win32,"\\",{...s,nocase:i});c(this,"sep","\\");this.nocase=i;for(let n=this.cwd;n;n=n.parent)n.nocase=this.nocase;}parseRootPath(t){return win32.parse(t).root.toUpperCase()}newRoot(t){return new fn(this.rootPath,Nt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},zi=class extends wn{constructor(t=process.cwd(),s={}){let{nocase:i=false}=s;super(t,posix,"/",{...s,nocase:i});c(this,"sep","/");this.nocase=i;}parseRootPath(t){return "/"}newRoot(t){return new mn(this.rootPath,Nt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},bn=class extends zi{constructor(e=process.cwd(),t={}){let{nocase:s=true}=t;super(e,{...t,nocase:s});}};process.platform==="win32"?fn:mn;var ga=process.platform==="win32"?Wi:process.platform==="darwin"?bn:zi,ma=e=>e.length>=1,ya=e=>e.length>=1,q,mt,X,ke,Ft,Ls,he,ce,ue,Ge,Ve,vn=(Ve=class{constructor(t,s,i,n){m(this,q);m(this,mt);m(this,X);c(this,"length");m(this,ke);m(this,Ft);m(this,Ls);m(this,he);m(this,ce);m(this,ue);m(this,Ge,true);if(!ma(t))throw new TypeError("empty pattern list");if(!ya(s))throw new TypeError("empty glob list");if(s.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,i<0||i>=this.length)throw new TypeError("index out of range");if(u(this,q,t),u(this,mt,s),u(this,X,i),u(this,ke,n),r(this,X)===0){if(this.isUNC()){let[o,a,l,h,...d]=r(this,q),[f,p,y,b,...S]=r(this,mt);d[0]===""&&(d.shift(),S.shift());let v=[o,a,l,h,""].join("/"),E=[f,p,y,b,""].join("/");u(this,q,[v,...d]),u(this,mt,[E,...S]),this.length=r(this,q).length;}else if(this.isDrive()||this.isAbsolute()){let[o,...a]=r(this,q),[l,...h]=r(this,mt);a[0]===""&&(a.shift(),h.shift());let d=o+"/",f=l+"/";u(this,q,[d,...a]),u(this,mt,[f,...h]),this.length=r(this,q).length;}}}pattern(){return r(this,q)[r(this,X)]}isString(){return typeof r(this,q)[r(this,X)]=="string"}isGlobstar(){return r(this,q)[r(this,X)]===at}isRegExp(){return r(this,q)[r(this,X)]instanceof RegExp}globString(){return u(this,Ls,r(this,Ls)||(r(this,X)===0?this.isAbsolute()?r(this,mt)[0]+r(this,mt).slice(1).join("/"):r(this,mt).join("/"):r(this,mt).slice(r(this,X)).join("/")))}hasMore(){return this.length>r(this,X)+1}rest(){return r(this,Ft)!==void 0?r(this,Ft):this.hasMore()?(u(this,Ft,new Ve(r(this,q),r(this,mt),r(this,X)+1,r(this,ke))),u(r(this,Ft),ue,r(this,ue)),u(r(this,Ft),ce,r(this,ce)),u(r(this,Ft),he,r(this,he)),r(this,Ft)):u(this,Ft,null)}isUNC(){let t=r(this,q);return r(this,ce)!==void 0?r(this,ce):u(this,ce,r(this,ke)==="win32"&&r(this,X)===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3])}isDrive(){let t=r(this,q);return r(this,he)!==void 0?r(this,he):u(this,he,r(this,ke)==="win32"&&r(this,X)===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]))}isAbsolute(){let t=r(this,q);return r(this,ue)!==void 0?r(this,ue):u(this,ue,t[0]===""&&t.length>1||this.isDrive()||this.isUNC())}root(){let t=r(this,q)[0];return typeof t=="string"&&this.isAbsolute()&&r(this,X)===0?t:""}checkFollowGlobstar(){return !(r(this,X)===0||!this.isGlobstar()||!r(this,Ge))}markFollowGlobstar(){return r(this,X)===0||!this.isGlobstar()||!r(this,Ge)?false:(u(this,Ge,false),true)}},q=new WeakMap,mt=new WeakMap,X=new WeakMap,ke=new WeakMap,Ft=new WeakMap,Ls=new WeakMap,he=new WeakMap,ce=new WeakMap,ue=new WeakMap,Ge=new WeakMap,Ve),wa=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",or=class{constructor(e,{nobrace:t,nocase:s,noext:i,noglobstar:n,platform:o=wa}){c(this,"relative");c(this,"relativeChildren");c(this,"absolute");c(this,"absoluteChildren");c(this,"platform");c(this,"mmopts");this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:true,nobrace:t,nocase:s,noext:i,noglobstar:n,optimizationLevel:2,platform:o,nocomment:true,nonegate:true};for(let a of e)this.add(a);}add(e){let t=new pe(e,this.mmopts);for(let s=0;s<t.set.length;s++){let i=t.set[s],n=t.globParts[s];if(!i||!n)throw new Error("invalid pattern object");for(;i[0]==="."&&n[0]===".";)i.shift(),n.shift();let o=new vn(i,n,0,this.platform),a=new pe(o.globString(),this.mmopts),l=n[n.length-1]==="**",h=o.isAbsolute();h?this.absolute.push(a):this.relative.push(a),l&&(h?this.absoluteChildren.push(a):this.relativeChildren.push(a));}}ignored(e){let t=e.fullpath(),s=`${t}/`,i=e.relative()||".",n=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(n))return true;for(let o of this.absolute)if(o.match(t)||o.match(s))return true;return false}childrenIgnored(e){let t=e.fullpath()+"/",s=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return true;for(let i of this.absoluteChildren)if(i.match(t))return true;return false}},ba=class Sn{constructor(t=new Map){c(this,"store");this.store=t;}copy(){return new Sn(new Map(this.store))}hasWalked(t,s){return this.store.get(t.fullpath())?.has(s.globString())}storeWalked(t,s){let i=t.fullpath(),n=this.store.get(i);n?n.add(s.globString()):this.store.set(i,new Set([s.globString()]));}},va=class{constructor(){c(this,"store",new Map);}add(e,t,s){let i=(t?2:0)|(s?1:0),n=this.store.get(e);this.store.set(e,n===void 0?i:i&n);}entries(){return [...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},Sa=class{constructor(){c(this,"store",new Map);}add(e,t){if(!e.canReaddir())return;let s=this.store.get(e);s?s.find(i=>i.globString()===t.globString())||s.push(t):this.store.set(e,[t]);}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return [...this.store.keys()].filter(e=>e.canReaddir())}},ar=class xn{constructor(t,s){c(this,"hasWalkedCache");c(this,"matches",new va);c(this,"subwalks",new Sa);c(this,"patterns");c(this,"follow");c(this,"dot");c(this,"opts");this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=s?s.copy():new ba;}processPatterns(t,s){this.patterns=s;let i=s.map(n=>[t,n]);for(let[n,o]of i){this.hasWalkedCache.storeWalked(n,o);let a=o.root(),l=o.isAbsolute()&&this.opts.absolute!==false;if(a){n=n.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let p=o.rest();if(p)o=p;else {this.matches.add(n,true,false);continue}}if(n.isENOENT())continue;let h,d,f=false;for(;typeof(h=o.pattern())=="string"&&(d=o.rest());)n=n.resolve(h),o=d,f=true;if(h=o.pattern(),d=o.rest(),f){if(this.hasWalkedCache.hasWalked(n,o))continue;this.hasWalkedCache.storeWalked(n,o);}if(typeof h=="string"){let p=h===".."||h===""||h===".";this.matches.add(n.resolve(h),l,p);continue}else if(h===at){(!n.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(n,o);let p=d?.pattern(),y=d?.rest();if(!d||(p===""||p===".")&&!y)this.matches.add(n,l,p===""||p===".");else if(p===".."){let b=n.parent||n;y?this.hasWalkedCache.hasWalked(b,y)||this.subwalks.add(b,y):this.matches.add(b,l,true);}}else h instanceof RegExp&&this.subwalks.add(n,o);}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new xn(this.opts,this.hasWalkedCache)}filterEntries(t,s){let i=this.subwalks.get(t),n=this.child();for(let o of s)for(let a of i){let l=a.isAbsolute(),h=a.pattern(),d=a.rest();h===at?n.testGlobstar(o,a,d,l):h instanceof RegExp?n.testRegExp(o,h,d,l):n.testString(o,h,d,l);}return n}testGlobstar(t,s,i,n){if((this.dot||!t.name.startsWith("."))&&(s.hasMore()||this.matches.add(t,n,false),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,s):t.isSymbolicLink()&&(i&&s.checkFollowGlobstar()?this.subwalks.add(t,i):s.markFollowGlobstar()&&this.subwalks.add(t,s)))),i){let o=i.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,i.rest(),n);else if(o===".."){let a=t.parent||t;this.subwalks.add(a,i);}else o instanceof RegExp&&this.testRegExp(t,o,i.rest(),n);}}testRegExp(t,s,i,n){s.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}testString(t,s,i,n){t.isNamed(s)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}},xa=(e,t)=>typeof e=="string"?new or([e],t):Array.isArray(e)?new or(e,t):e,qe,Kt,Oe,St,me,Di,Pr,En=(Pr=class{constructor(e,t,s){m(this,St);c(this,"path");c(this,"patterns");c(this,"opts");c(this,"seen",new Set);c(this,"paused",false);c(this,"aborted",false);m(this,qe,[]);m(this,Kt);m(this,Oe);c(this,"signal");c(this,"maxDepth");c(this,"includeChildMatches");if(this.patterns=e,this.path=t,this.opts=s,u(this,Oe,!s.posix&&s.platform==="win32"?"\\":"/"),this.includeChildMatches=s.includeChildMatches!==false,(s.ignore||!this.includeChildMatches)&&(u(this,Kt,xa(s.ignore??[],s)),!this.includeChildMatches&&typeof r(this,Kt).add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{r(this,qe).length=0;}));}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let e;for(;!this.paused&&(e=r(this,qe).shift());)e();}onResume(e){this.signal?.aborted||(this.paused?r(this,qe).push(e):e());}async matchCheck(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||await e.realpath(),!s)return;e=s;}let i=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let n=await i.realpath();n&&(n.isUnknown()||this.opts.stat)&&await n.lstat();}return this.matchCheckTest(i,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!g(this,St,me).call(this,e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||e.realpathSync(),!s)return;e=s;}let i=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let n=i.realpathSync();n&&(n?.isUnknown()||this.opts.stat)&&n.lstatSync();}return this.matchCheckTest(i,t)}matchFinish(e,t){if(g(this,St,me).call(this,e))return;if(!this.includeChildMatches&&r(this,Kt)?.add){let n=`${e.relativePosix()}/**`;r(this,Kt).add(n);}let s=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?r(this,Oe):"";if(this.opts.withFileTypes)this.matchEmit(e);else if(s){let n=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(n+i);}else {let n=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!n.startsWith(".."+r(this,Oe))?"."+r(this,Oe):"";this.matchEmit(n?o+n+i:"."+i);}}async match(e,t,s){let i=await this.matchCheck(e,s);i&&this.matchFinish(i,t);}matchSync(e,t,s){let i=this.matchCheckSync(e,s);i&&this.matchFinish(i,t);}walkCB(e,t,s){this.signal?.aborted&&s(),this.walkCB2(e,t,new ar(this.opts),s);}walkCB2(e,t,s,i){if(g(this,St,Di).call(this,e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,s,i));return}s.processPatterns(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,me).call(this,a)||(n++,this.match(a,l,h).then(()=>o()));for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirCached();a.calledReaddir()?this.walkCB3(a,l,s,o):a.readdirCB((h,d)=>this.walkCB3(a,d,s,o),true);}o();}walkCB3(e,t,s,i){s=s.filterEntries(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,me).call(this,a)||(n++,this.match(a,l,h).then(()=>o()));for(let[a,l]of s.subwalks.entries())n++,this.walkCB2(a,l,s.child(),o);o();}walkCBSync(e,t,s){this.signal?.aborted&&s(),this.walkCB2Sync(e,t,new ar(this.opts),s);}walkCB2Sync(e,t,s,i){if(g(this,St,Di).call(this,e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,s,i));return}s.processPatterns(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,me).call(this,a)||this.matchSync(a,l,h);for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirSync();this.walkCB3Sync(a,l,s,o);}o();}walkCB3Sync(e,t,s,i){s=s.filterEntries(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,me).call(this,a)||this.matchSync(a,l,h);for(let[a,l]of s.subwalks.entries())n++,this.walkCB2Sync(a,l,s.child(),o);o();}},qe=new WeakMap,Kt=new WeakMap,Oe=new WeakMap,St=new WeakSet,me=function(e){return this.seen.has(e)||!!r(this,Kt)?.ignored?.(e)},Di=function(e){return !!r(this,Kt)?.childrenIgnored?.(e)},Pr),lr=class extends En{constructor(t,s,i){super(t,s,i);c(this,"matches",new Set);}matchEmit(t){this.matches.add(t);}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,s)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?s(this.signal.reason):t(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}},hr=class extends En{constructor(t,s,i){super(t,s,i);c(this,"results");this.results=new ti({signal:this.signal,objectMode:true}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume());}matchEmit(t){this.results.write(t),this.results.flowing||this.pause();}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end());}):this.walkCB(t,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}},Ea=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Te=class{constructor(e,t){c(this,"absolute");c(this,"cwd");c(this,"root");c(this,"dot");c(this,"dotRelative");c(this,"follow");c(this,"ignore");c(this,"magicalBraces");c(this,"mark");c(this,"matchBase");c(this,"maxDepth");c(this,"nobrace");c(this,"nocase");c(this,"nodir");c(this,"noext");c(this,"noglobstar");c(this,"pattern");c(this,"platform");c(this,"realpath");c(this,"scurry");c(this,"stat");c(this,"signal");c(this,"windowsPathsNoEscape");c(this,"withFileTypes");c(this,"includeChildMatches");c(this,"opts");c(this,"patterns");if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=fileURLToPath(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==false,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===false,this.windowsPathsNoEscape&&(e=e.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(l=>l.includes("/")?l:`./**/${l}`);}if(this.pattern=e,this.platform=t.platform||Ea,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else {let l=t.platform==="win32"?Wi:t.platform==="darwin"?bn:t.platform?zi:ga;this.scurry=new l(this.cwd,{nocase:t.nocase,fs:t.fs});}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:true,noext:this.noext,nonegate:true,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},n=this.pattern.map(l=>new pe(l,i)),[o,a]=n.reduce((l,h)=>(l[0].push(...h.set),l[1].push(...h.globParts),l),[[],[]]);this.patterns=o.map((l,h)=>{let d=a[h];if(!d)throw new Error("invalid pattern object");return new vn(l,d,0,this.platform)});}async walk(){return [...await new lr(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 lr(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 hr(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 hr(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()}},Ca=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let s of e)if(new pe(s,t).hasMagic())return true;return false};function ii(e,t={}){return new Te(e,t).streamSync()}function Cn(e,t={}){return new Te(e,t).stream()}function kn(e,t={}){return new Te(e,t).walkSync()}async function cr(e,t={}){return new Te(e,t).walk()}function ri(e,t={}){return new Te(e,t).iterateSync()}function On(e,t={}){return new Te(e,t).iterate()}var ka=ii,Oa=Object.assign(Cn,{sync:ii}),Ra=ri,Ta=Object.assign(On,{sync:ri}),Ma=Object.assign(kn,{stream:ii,iterate:ri}),ei=Object.assign(cr,{glob:cr,globSync:kn,sync:Ma,globStream:Cn,stream:Oa,globStreamSync:ii,streamSync:ka,globIterate:On,iterate:Ta,globIterateSync:ri,iterateSync:Ra,Glob:Te,hasMagic:Ca,escape:Gr,unescape:Fe});ei.glob=ei;var Yt;(C=>{C.Level=La.enum(["DEBUG","INFO","WARN","ERROR"]).meta({ref:"LogLevel",description:"Log level"});let t={DEBUG:0,INFO:1,WARN:2,ERROR:3},s="INFO";function i(k){return t[k]>=t[s]}function n(){return s}C.getLevel=n;let o=new Map;C.Default=T({service:"default"});let l="";function h(){return l}C.file=h;let d,f,p=false,y=()=>{},b=false;async function S(k){if(k.level&&(s=k.level),k.print){p=true;return}if(k.logPath)l=k.logPath;else {y=()=>{},p=true;return}try{d=await Rn.open(l,"a"),f=createWriteStream("",{fd:d.fd,autoClose:!1}),y=M=>{if(!(b||!f||f.destroyed))try{if(!f.writable)return;f.write(M,F=>{F&&!b&&(b=!0,setTimeout(()=>{b=!1;},1e3));});}catch{b||(b=!0,setTimeout(()=>{b=!1;},1e3));}},p=!0;}catch{y=M=>{try{process.stderr.write(M);}catch{}},p=true;}}C.init=S;async function v(){p&&(f&&!f.destroyed&&(await new Promise((k,M)=>{f.end(F=>{F?M(F):k();});}).catch(()=>{}),f=void 0),d&&(await d.close().catch(()=>{}),d=void 0),y=k=>{try{process.stderr.write(k);}catch{}},p=false);}C.close=v;function w(k,M=0){let F=k.message;return k.cause instanceof Error&&M<10?F+" Caused by: "+w(k.cause,M+1):F}let O=Date.now();function T(k){k=k||{};let M=k.service;if(M&&typeof M=="string"){let A=o.get(M);if(A)return A}function F(A,P){let W=Object.entries({...k,...P}).filter(([$i,Qt])=>Qt!=null).map(([$i,Qt])=>{let li=`${$i}=`;return Qt instanceof Error?li+w(Qt):typeof Qt=="object"?li+JSON.stringify(Qt):li+Qt}).join(" "),z=new Date,Fs=z.getTime()-O;return O=z.getTime(),[z.getFullYear()+"-"+String(z.getMonth()+1).padStart(2,"0")+"-"+String(z.getDate()).padStart(2,"0")+"T"+String(z.getHours()).padStart(2,"0")+":"+String(z.getMinutes()).padStart(2,"0")+":"+String(z.getSeconds()).padStart(2,"0"),"+"+Fs+"ms",W,A].filter(Boolean).join(" ")+`
5
+ `}let D={debug(A,P){i("DEBUG")&&y("DEBUG "+F(A,P));},info(A,P){i("INFO")&&y("INFO "+F(A,P));},error(A,P){i("ERROR")&&y("ERROR "+F(A,P));},warn(A,P){i("WARN")&&y("WARN "+F(A,P));},tag(A,P){return k&&(k[A]=P),D},clone(){return C.create({...k})},time(A,P){let W=Date.now();D.info(A,{status:"started",...P});function z(){D.info(A,{status:"completed",duration:Date.now()-W,...P});}return {stop:z,[Symbol.dispose](){z();}}}};return M&&typeof M=="string"&&o.set(M,D),D}C.create=T;})(Yt||(Yt={}));var xt=Yt.create({service:"ollama-sdk",module:"native-language-model"});function ni(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function oi(e){if(!e||e.trim().length===0)return false;try{return JSON.parse(e),!0}catch{return false}}function Tn(e){return typeof e=="string"?e:JSON.stringify(e)}function Mn(e){return !e.tools||e.tools.length===0?{}:{tools:e.tools.map(t=>{if(!t.name)throw new He(t.name||"unknown","name");let s=t.inputSchema||t.parameters;if(!s)throw new He(t.name,"inputSchema");return {type:"function",function:{name:t.name,description:t.description,parameters:s}}})}}function An(e){let t=[];for(let s of e)try{switch(s.role){case "system":t.push({role:"system",content:s.content});break;case "user":{let i=s.content.filter(n=>n.type==="text").map(n=>n.text).join(`
6
+ `);i&&t.push({role:"user",content:i});break}case "assistant":{let i="",n=[];for(let o of s.content)if(o.type==="text")i+=o.text;else if(o.type==="tool-call"){let a=o;n.push({id:a.toolCallId,type:"function",function:{name:a.toolName,arguments:JSON.stringify(a.input)}});}t.push({role:"assistant",content:i||null,tool_calls:n.length>0?n:void 0});break}case "tool":for(let i of s.content){let n=i.output,o;switch(n.type){case "text":case "error-text":o=n.value;break;case "content":case "json":case "error-json":o=JSON.stringify(n.value);break;default:o=String(n.value);break}t.push({role:"tool",tool_call_id:i.toolCallId,content:o});}break}}catch(i){xt.warn("Failed to convert message",{messageRole:s.role,error:i instanceof Error?i.message:String(i)});}return t}var ai=class{constructor(t,s={}){c(this,"specificationVersion","v2");c(this,"provider","ollama");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"client");this.modelId=t,this.client=new Ds(s.baseURL);}async doStream(t){let s=ni();xt.debug("Stream request started",{traceId:s,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let i=An(t.prompt),n=Mn({tools:t.tools}),o=JSON.stringify({model:this.modelId,messages:i,options:Ae,...n}),a=null,l=null,h=b=>{a&&a.enqueue(b),l&&l.enqueue(b);},d=async()=>{try{let b=!0,S=!1,v=!1,E="",w="",O=!1,T=[],C=[],k=()=>{if(C.length>0){for(let F of C)h(F);C.length=0;}},M=null;for await(let F of this.client.streamChat({model:this.modelId,messages:i,options:Ae,...n})){if(M&&M.chunkCount++,b){b=!1;let D={type:"response-metadata",id:ni(),modelId:this.modelId,timestamp:new Date(F.created_at)};h(D),M&&M.eventCount++;}if(F.message?.tool_calls){v&&(C.push({type:"reasoning-end",id:"reasoning-0"}),v=!1),S&&(C.push({type:"text-end",id:"txt-0"}),S=!1);for(let D of F.message.tool_calls){if(!D.id||!D.function?.name){let Je=D.id?"function.name":"id";xt.error("Invalid tool call: missing field",{traceId:s,missingField:Je,toolCall:void 0}),C.push({type:"error",error:`Invalid tool call: missing ${Je}`});continue}let A=D.id,P=D.function.name,W=Tn(D.function.arguments),z=T.find(Je=>Je.id===A);z?(z.function.arguments+=W,xt.debug("Tool call arguments accumulated",{traceId:s,toolCallId:A,toolName:P,deltaLength:W.length,totalLength:z.function.arguments.length,isComplete:oi(z.function.arguments)}),W&&C.push({type:"tool-input-delta",id:A,delta:W})):(z={id:A,type:"function",function:{name:P,arguments:W},hasFinished:!1},T.push(z),M&&M.toolCallCount++,xt.debug("Tool call received",{traceId:s,toolCallId:A,toolName:P,argumentsLength:W.length,isComplete:oi(W)}),C.push({type:"tool-input-start",id:A,toolName:P}),W&&C.push({type:"tool-input-delta",id:A,delta:W}));let Fs=oi(z.function.arguments);!z.hasFinished&&Fs&&(xt.debug("Tool call arguments complete",{traceId:s,toolCallId:A,toolName:P,isComplete:Fs,argumentsLength:z.function.arguments.length}),C.push({type:"tool-input-end",id:A}),C.push({type:"tool-call",toolCallId:A,toolName:P,input:z.function.arguments}),z.hasFinished=!0);}k(),M&&(M.eventCount+=C.length);}if(F.message?.content){let D=F.message.content;for(w+=D;w.length>0;)if(O){let A=w.indexOf("</think>");if(A===-1){w.length>0&&C.push({type:"reasoning-delta",id:"reasoning-0",delta:w}),w="";break}else {if(A>0){let P=w.substring(0,A);C.push({type:"reasoning-delta",id:"reasoning-0",delta:P});}C.push({type:"reasoning-end",id:"reasoning-0"}),v=!1,O=!1,w=w.substring(A+8);}}else {let A=w.indexOf("<think>");if(A===-1){w.length>0&&(S||(S=!0,C.push({type:"text-start",id:"txt-0"})),C.push({type:"text-delta",id:"txt-0",delta:w}),E+=w),w="";break}else {if(A>0){let P=w.substring(0,A);S||(S=!0,C.push({type:"text-start",id:"txt-0"})),C.push({type:"text-delta",id:"txt-0",delta:P}),E+=P,C.push({type:"text-end",id:"txt-0"}),S=!1;}O=!0,w=w.substring(A+7),v||(v=!0,C.push({type:"reasoning-start",id:"reasoning-0"}));}}}if(k(),M&&(M.eventCount+=C.length),F.done){let D=T.filter(W=>!W.hasFinished);for(let W of D)C.push({type:"tool-input-end",id:W.id}),C.push({type:"tool-call",toolCallId:W.id,toolName:W.function.name,input:W.function.arguments});w.length>0&&(O?(C.push({type:"reasoning-delta",id:"reasoning-0",delta:w}),C.push({type:"reasoning-end",id:"reasoning-0"})):(S||(S=!0,C.push({type:"text-start",id:"txt-0"})),C.push({type:"text-delta",id:"txt-0",delta:w}),E+=w)),S&&C.push({type:"text-end",id:"txt-0"});let P=T.length>0?"tool-calls":"stop";if(C.push({type:"finish",finishReason:P,usage:{inputTokens:F.prompt_eval_count||0,outputTokens:F.eval_count||0,totalTokens:(F.prompt_eval_count||0)+(F.eval_count||0)},providerMetadata:{ollama:{totalDuration:F.total_duration||0,loadDuration:F.load_duration||0,promptEvalDuration:F.prompt_eval_duration||0,evalDuration:F.eval_duration||0}}}),k(),M&&(M.eventCount+=C.length),M);T.length=0;}}}catch(b){xt.error("Stream processing error",{traceId:s,error:b instanceof Error?b.message:String(b),stack:void 0}),h({type:"error",error:b instanceof Error?b.message:String(b)}),h({type:"finish",finishReason:"error",usage:{inputTokens:0,outputTokens:0,totalTokens:0}});}finally{a&&a.close(),l&&l.close();}},f=new ReadableStream({start(b){a=b;}}),p=new ReadableStream({start(b){l=b;}});d();async function*y(b){let S=b.getReader();try{for(;;){let{done:v,value:E}=await S.read();if(v)break;yield E;}}finally{S.releaseLock();}}return {stream:f,fullStream:y(p),request:{body:o},response:{}}}async doGenerate(t){let s=ni();xt.debug("Generate request started",{traceId:s,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let i=An(t.prompt),n=Mn({tools:t.tools}),o=await this.client.chat({model:this.modelId,messages:i,options:Ae,...n}),a=[];if(o.message?.content&&a.push({type:"text",text:o.message.content}),o.message?.tool_calls){xt.debug("Tool calls received in generate",{traceId:s,toolCallCount:o.message.tool_calls.length});for(let d of o.message.tool_calls){let f=d.id||ni(),p=d.function.name,y=Tn(d.function.arguments);xt.debug("Processing tool call in generate",{traceId:s,toolCallId:f,toolName:p,argumentsLength:y.length,isComplete:oi(y)}),a.push({type:"tool-call",toolCallId:f,toolName:p,input:y});}}let l=o.message?.tool_calls&&o.message.tool_calls.length>0,h=l?"tool-calls":"stop";return xt.debug("Generate request completed",{traceId:s,finishReason:h,contentParts:a.length,hasToolCalls:l,inputTokens:o.prompt_eval_count||0,outputTokens:o.eval_count||0}),{content:a,finishReason:h,usage:{inputTokens:o.prompt_eval_count||0,outputTokens:o.eval_count||0,totalTokens:(o.prompt_eval_count||0)+(o.eval_count||0)},providerMetadata:{ollama:{totalDuration:o.total_duration||0,loadDuration:o.load_duration||0,promptEvalDuration:o.prompt_eval_duration||0,evalDuration:o.eval_duration||0}},request:{body:JSON.stringify({model:this.modelId,messages:i,options:Ae,...n})},response:{}}}};var Me=class{constructor(t,s={}){c(this,"specificationVersion","v2");c(this,"provider","ollama");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"nativeModel");this.modelId=t,this.nativeModel=new ai(t,{baseURL:s.baseURL||"http://localhost:11434"});}doGenerate(t){return this.nativeModel.doGenerate(t)}doStream(t){return this.nativeModel.doStream(t)}};var _s=class{constructor(t,s={}){c(this,"specificationVersion","v2");c(this,"provider","ollama");c(this,"modelId");c(this,"maxEmbeddingsPerCall");c(this,"supportsParallelCalls",true);c(this,"baseURL");this.modelId=t,this.baseURL=s.baseURL||"http://localhost:11434";}async doEmbed(t){let{values:s,abortSignal:i,headers:n}=t,o=Yt.create({service:"ollama-embedding"});if(!s||s.length===0)return o.warn("Empty values array provided",{modelId:this.modelId}),{embeddings:[],usage:{tokens:0}};o.debug("Generating text embeddings",{modelId:this.modelId,valuesCount:s.length,baseURL:this.baseURL});try{let a=await Promise.all(s.map(h=>this.generateSingleEmbedding(h,i,n))),l=s.reduce((h,d)=>h+this.estimateTokens(d),0);return o.debug("Text embeddings generated successfully",{modelId:this.modelId,embeddingsCount:a.length,totalTokens:l}),{embeddings:a,usage:{tokens:l}}}catch(a){throw o.error("Text embedding generation failed",{modelId:this.modelId,error:a instanceof Error?a.message:String(a),stack:void 0}),a}}async generateSingleEmbedding(t,s,i){let n=`${this.baseURL}/api/embeddings`;try{let o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify({model:this.modelId,prompt:t}),signal:s});if(!o.ok){let l=await o.text();throw new Error(`Ollama embedding API error (${o.status}): ${l}`)}let a=await o.json();if(!a.embedding||!Array.isArray(a.embedding))throw new Error("Invalid response format from Ollama embedding API");return a.embedding}catch(o){throw o instanceof TypeError&&o.message.includes("fetch")?new Error(`Failed to connect to Ollama server at ${this.baseURL}: ${o.message}`):o}}estimateTokens(t){let s=t.match(/[a-zA-Z]/g)?.length||0,i=t.match(/[\u4e00-\u9fa5]/g)?.length||0,n=t.length-s-i;return Math.ceil(s/4)+i+Math.ceil(n*.5)}};function Fa(e={}){if(e.logPath){let s=e.logLevel||"DEBUG",i=_a.join(e.logPath,"ollama-sdk.log");Yt.init({print:false,logPath:i,level:s}).then(()=>{Yt.create({service:"ollama-sdk",module:"provider"}).debug("Ollama provider created",{baseURL:e.baseURL||"http://localhost:11434",logFile:i,logLevel:s});});}return Object.assign(s=>new Me(s,e),{languageModel:s=>new Me(s,e),chat:s=>new Me(s,e),textEmbeddingModel:s=>new _s(s,e)})}var Pa="0.1.0";
7
+ export{ci as ConnectionError,ui as ModelNotFoundError,Ae as OLLAMA_DEFAULT_OPTIONS,Fn as OLLAMA_SPECIFIC_PARAMS,_s as OllamaEmbeddingModel,Xt as OllamaError,Me as OllamaLanguageModel,pi as TimeoutError,Pa as VERSION,di as ValidationError,Fa as createOllama};