@easbot/ollama-sdk 0.1.2 → 0.1.7

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.cjs CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict';var On=require('path'),kn=require('fs/promises'),Ho=require('fs'),La=require('zod'),url=require('url'),events=require('events'),Kr=require('stream'),string_decoder=require('string_decoder');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var On__default=/*#__PURE__*/_interopDefault(On);var kn__default=/*#__PURE__*/_interopDefault(kn);var Ho__namespace=/*#__PURE__*/_interopNamespace(Ho);var La__default=/*#__PURE__*/_interopDefault(La);var Kr__default=/*#__PURE__*/_interopDefault(Kr);var Ln=Object.defineProperty;var Wi=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 u=(e,t,s)=>_n(e,typeof t!="symbol"?t+"":t,s),oi=(e,t,s)=>t.has(e)||Wi("Cannot "+s);var r=(e,t,s)=>(oi(e,t,"read from private field"),s?s.call(e):t.get(e)),y=(e,t,s)=>t.has(e)?Wi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),d=(e,t,s,i)=>(oi(e,t,"write to private field"),t.set(e,s),s),g=(e,t,s)=>(oi(e,t,"access private method"),s);var Ls=(e,t,s,i)=>({set _(n){d(e,t,n);},get _(){return r(e,t,i)}});var _s=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 Te={numCtx:32768,temperature:.7,topK:40,topP:.9,repeatPenalty:1.1,numPredict:32e3},Fn=["numCtx","repeatPenalty","numPredict"];var Yt=class extends Error{constructor(s,i){super(s);this.cause=i;this.name="OllamaError",Object.setPrototypeOf(this,new.target.prototype);}},ai=class extends Yt{constructor(s,i,n){super(s,n);this.url=i;this.name="ConnectionError";}},hi=class extends Yt{constructor(s,i){super(`Model not found: ${s}`,i);this.modelId=s;this.name="ModelNotFoundError";}},li=class extends Yt{constructor(s,i,n,o){super(s,o);this.field=i;this.value=n;this.name="ValidationError";}},ci=class extends Yt{constructor(s,i,n){super(s,n);this.timeoutMs=i;this.name="TimeoutError";}},qe=class extends Yt{constructor(s,i,n){super(`Invalid tool definition for "${s}": missing ${i}`,n);this.toolName=s;this.missingField=i;this.name="InvalidToolDefinitionError";}};var _r=(e,t,s)=>{let i=e instanceof RegExp?zi(e,s):e,n=t instanceof RegExp?zi(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)}},zi=(e,t)=>{let s=t.match(e);return s?s[0]:null},Pn=(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},Fr="\0SLASH"+Math.random()+"\0",Pr="\0OPEN"+Math.random()+"\0",Fi="\0CLOSE"+Math.random()+"\0",Dr="\0COMMA"+Math.random()+"\0",Nr="\0PERIOD"+Math.random()+"\0",Dn=new RegExp(Fr,"g"),Nn=new RegExp(Pr,"g"),In=new RegExp(Fi,"g"),jn=new RegExp(Dr,"g"),Wn=new RegExp(Nr,"g"),zn=/\\\\/g,$n=/\\{/g,Un=/\\}/g,Bn=/\\,/g,Gn=/\\./g,Vn=1e5;function ui(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function qn(e){return e.replace(zn,Fr).replace($n,Pr).replace(Un,Fi).replace(Bn,Dr).replace(Gn,Nr)}function Jn(e){return e.replace(Dn,"\\").replace(Nn,"{").replace(In,"}").replace(jn,",").replace(Wn,".")}function Ir(e){if(!e)return [""];let t=[],s=_r("{","}",e);if(!s)return e.split(",");let{pre:i,body:n,post:o}=s,a=i.split(",");a[a.length-1]+="{"+n+"}";let h=Ir(o);return o.length&&(a[a.length-1]+=h.shift(),a.push.apply(a,h)),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)),Xe(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 Xe(e,t,s){let i=[],n=_r("{","}",e);if(!n)return [e];let o=n.pre,a=n.post.length?Xe(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+Fi+n.post,Xe(e,t,true)):[e];let p;if(c)p=n.body.split(/\.\./);else if(p=Ir(n.body),p.length===1&&p[0]!==void 0&&(p=Xe(p[0],t,false).map(Zn),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=ui(p[0]),b=ui(p[1]),v=Math.max(p[0].length,p[1].length),E=p.length===3&&p[2]!==void 0?Math.abs(ui(p[2])):1,w=Yn;b<S&&(E*=-1,w=Qn);let M=p.some(Kn);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,Xe(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 Zs=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]},Je=e=>e.replace(/[[\]\\-]/g,"\\$&"),to=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),$i=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,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(Xn))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(Je(p)+"-"+Je(b)):b===p&&i.push(Je(b)),p="",o++;continue}if(e.startsWith("-]",o+1)){i.push(Je(b+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=b,o+=2;continue}i.push(Je(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 [to(b),false,f-s,false]}let m="["+(c?"^":"")+$i(i)+"]",S="["+(c?"":"^")+$i(n)+"]";return [i.length&&n.length?"("+m+"|"+S+")":i.length?m:S,h,f-s,true]},Le=(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(["!","?","+","*","@"]),Ui=e=>so.has(e),io="(?!(?:^|/)\\.\\.?(?:$|/))",Fs="(?!\\.)",ro=new Set(["[","."]),no=new Set(["..","."]),oo=new Set("().*{}+?[]^$\\!"),ao=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Pi="[^/]",Bi=Pi+"*?",Gi=Pi+"+?",U,H,Ut,N,z,ie,ge,re,Nt,me,os,Ce,Wr,ce,Q,$s,bi,zr,jr=(Q=class{constructor(t,s,i={}){y(this,Ce);u(this,"type");y(this,U);y(this,H);y(this,Ut,false);y(this,N,[]);y(this,z);y(this,ie);y(this,ge);y(this,re,false);y(this,Nt);y(this,me);y(this,os,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,Nt,r(this,U)===this?i:r(r(this,U),Nt)),d(this,ge,r(this,U)===this?[]:r(r(this,U),ge)),t==="!"&&!r(r(this,U),re)&&r(this,ge).push(this),d(this,ie,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,me)!==void 0?r(this,me):this.type?d(this,me,this.type+"("+r(this,N).map(t=>String(t)).join("|")+")"):d(this,me,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),re)&&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,ie)===0)return true;let t=r(this,z);for(let s=0;s<r(this,ie);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,ie)===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,ce,$s).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,Nt).nocase&&!r(this,Nt).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(r(this,Nt).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,a),{_src:s,_glob:t})}get options(){return r(this,Nt)}toRegExpSource(t){let s=t??!!r(this,Nt).dot;if(r(this,U)===this&&g(this,Ce,Wr).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,ce,zr).call(w,m,r(this,H),l):m.toRegExpSource(t);return d(this,H,r(this,H)||v),d(this,Ut,r(this,Ut)||E),S}).join(""),f="";if(this.isStart()&&typeof r(this,N)[0]=="string"&&!(r(this,N).length===1&&no.has(r(this,N)[0]))){let m=ro,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?io:b?Fs:"";}let p="";return this.isEnd()&&r(r(this,U),re)&&r(this,z)?.type==="!"&&(p="(?:$|\\/)"),[f+c+p,Le(c),d(this,H,!!r(this,H)),r(this,Ut)]}let i=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",o=g(this,Ce,bi).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,Le(this.toString()),false,false]}let a=!i||t||s||!Fs?"":g(this,Ce,bi).call(this,true);a===o&&(a=""),a&&(o=`(?:${o})(?:${a})*?`);let h="";if(this.type==="!"&&r(this,os))h=(this.isStart()&&!s?Fs:"")+Gi;else {let l=this.type==="!"?"))"+(this.isStart()&&!s&&!t?Fs:"")+Bi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;h=n+o+l;}return [h,Le(o),d(this,H,!!r(this,H)),r(this,Ut)]}},U=new WeakMap,H=new WeakMap,Ut=new WeakMap,N=new WeakMap,z=new WeakMap,ie=new WeakMap,ge=new WeakMap,re=new WeakMap,Nt=new WeakMap,me=new WeakMap,os=new WeakMap,Ce=new WeakSet,Wr=function(){if(this!==r(this,U))throw new Error("should only call on root");if(r(this,re))return this;this.toString(),d(this,re,true);let t;for(;t=r(this,ge).pop();){if(t.type!=="!")continue;let s=t,i=r(s,z);for(;i;){for(let n=r(s,ie)+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},ce=new WeakSet,$s=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&&Ui(w)&&t.charAt(v)==="("){s.push(E),E="";let M=new Q(w,s);v=g(S=Q,ce,$s).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(Ui(v)&&t.charAt(c)==="("){f.push(m),m="";let E=new Q(v,f);f.push(E),c=g(b=Q,ce,$s).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,os,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},bi=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,Ut,r(this,Ut)||a),i}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")},zr=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+=(oo.has(l)?"\\":"")+l;continue}if(l==="\\"){h===t.length-1?o+="\\\\":n=true;continue}if(l==="["){let[c,f,p,m]=eo(t,h);if(p){o+=c,a=a||f,h+=p-1,s=s||m;continue}}if(l==="*"){o+=i&&t==="*"?Gi:Bi,s=true;continue}if(l==="?"){o+=Pi,s=true;continue}o+=ao(l);}return [o,Le(t),!!s,a]},y(Q,ce),Q),$r=(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={})=>(Zs(t),!s.nocomment&&t.charAt(0)==="#"?false:new ue(t,s).match(e)),ho=/^\*+([^+@!?\*\[\(]*)$/,lo=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=Ur([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},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=Br([e]);return t?i=>s(i)&&i.endsWith(t):s},Oo=([e,t=""])=>{let s=Ur([e]);return t?i=>s(i)&&i.endsWith(t):s},Ur=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},Br=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Gr=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Vi={win32:{sep:"\\"},posix:{sep:"/"}},Ro=Gr==="win32"?Vi.win32.sep:Vi.posix.sep;ot.sep=Ro;var nt=Symbol("globstar **");ot.GLOBSTAR=nt;var To="[^/]",Mo=To+"*?",Ao="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Lo="(?:(?!(?:\\/|^)\\.).)*?",_o=(e,t={})=>s=>ot(s,e,t);ot.filter=_o;var gt=(e,t={})=>Object.assign({},e,t),Fo=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=Fo;var Vr=(e,t={})=>(Zs(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Hn(e,{max:t.braceExpandMax}));ot.braceExpand=Vr;var Po=(e,t={})=>new ue(e,t).makeRe();ot.makeRe=Po;var Do=(e,t,s={})=>{let i=new ue(t,s);return e=e.filter(n=>i.match(n)),i.options.nonull&&!e.length&&e.push(t),e};ot.match=Do;var qi=/[?*]|[+@!]\(.*?\)|\[|\]/,No=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ue=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");Zs(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||Gr,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]==="?"||!qi.test(n[2]))&&!qi.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 Vr(this.pattern,this.options)}parse(e){Zs(e);let t=this.options;if(e==="**")return nt;if(e==="")return "";let s,i=null;(s=e.match(bo))?i=t.dot?So:vo:(s=e.match(ho))?i=(t.nocase?t.dot?po:uo:t.dot?co:lo)(s[1]):(s=e.match(xo))?i=(t.nocase?t.dot?ko:Eo:t.dot?Co:Oo)(s):(s=e.match(fo))?i=t.dot?mo:go:(s=e.match(yo))&&(i=wo);let n=jr.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(h=>{let l=h.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))i.add(p);return typeof f=="string"?No(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=jr;ot.Minimatch=ue;ot.escape=$r;ot.unescape=Le;var jo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,qr=new Set,vi=typeof process=="object"&&process?process:{},Jr=(e,t,s,i)=>{typeof vi.emitWarning=="function"?vi.emitWarning(e,t,s,i):console.error(`[${s}] ${t}: ${e}`);},Ks=globalThis.AbortController,Ji=globalThis.AbortSignal;if(typeof Ks>"u"){Ji=class{constructor(){u(this,"onabort");u(this,"_onabort",[]);u(this,"reason");u(this,"aborted",false);}addEventListener(s,i){this._onabort.push(i);}},Ks=class{constructor(){u(this,"signal",new Ji);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=vi.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=false,Jr("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=>!qr.has(e),Xt=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Hr=e=>Xt(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Us:null:null,Us=class extends Array{constructor(e){super(e),this.fill(0);}},Wt,_e,zo=(Wt=class{constructor(t,s){u(this,"heap");u(this,"length");if(!r(Wt,_e))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0;}static create(t){let s=Hr(t);if(!s)return [];d(Wt,_e,true);let i=new Wt(t,s);return d(Wt,_e,false),i}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},_e=new WeakMap,y(Wt,_e,false),Wt),hr,lr,yt,lt,kt,ye,Ct,Fe,Pe,Ot,B,Rt,$,I,L,st,ct,tt,Z,Tt,K,Mt,At,ut,dt,Lt,ne,it,De,x,Si,we,Bt,as,pt,Zr,be,Ne,hs,te,ee,xi,Bs,Gs,D,Ei,ts,se,ki,Ie,Xs=(Ie=class{constructor(t){y(this,x);y(this,yt);y(this,lt);y(this,kt);y(this,ye);y(this,Ct);y(this,Fe);y(this,Pe);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,ne);y(this,it);y(this,De);y(this,we,()=>{});y(this,Bt,()=>{});y(this,as,()=>{});y(this,pt,()=>false);y(this,be,t=>{});y(this,Ne,(t,s,i)=>{});y(this,hs,(t,s,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});u(this,hr,"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??jo),s!==0&&!Xt(s))throw new TypeError("max option must be a nonnegative integer");let F=s?Hr(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,Pe,M),w!==void 0&&typeof w!="function")throw new TypeError("fetchMethod must be a function if specified");if(d(this,Fe,w),d(this,ne,!!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,zo.create(s)),d(this,B,0),d(this,Rt,0),typeof c=="function"&&d(this,kt,c),typeof f=="function"&&d(this,ye,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,De,!!r(this,ye)),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&&!Xt(r(this,lt)))throw new TypeError("maxSize must be a positive integer if specified");if(!Xt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");g(this,x,Zr).call(this);}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!O,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=Xt(n)||n===0?n:1,this.ttlAutopurge=!!o,this.ttl=i||0,this.ttl){if(!Xt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");g(this,x,Si).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";Wo(j)&&(qr.add(j),Jr("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",j,Ie));}}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,Gs).call(a,s,i,n,o)},moveToTail:s=>{var i;return g(i=t,x,ts).call(i,s)},indexes:s=>{var i;return g(i=t,x,te).call(i,s)},rindexes:s=>{var i;return g(i=t,x,ee).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,Fe)}get memoMethod(){return r(this,Pe)}get dispose(){return r(this,kt)}get onInsert(){return r(this,ye)}get disposeAfter(){return r(this,Ct)}getRemainingTTL(t){return r(this,$).has(t)?1/0:0}*entries(){for(let t of g(this,x,te).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,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]]);}*keys(){for(let t of g(this,x,te).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,ee).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,te).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,ee).call(this))r(this,L)[t]!==void 0&&!g(this,x,D).call(this,r(this,L)[t])&&(yield r(this,L)[t]);}[(lr=Symbol.iterator,hr=Symbol.toStringTag,lr)](){return this.entries()}find(t,s={}){for(let i of g(this,x,te).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,te).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,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);}}purgeStale(){let t=false;for(let s of g(this,x,ee).call(this,{allowStale:true}))r(this,pt).call(this,s)&&(g(this,x,se).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,te).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,hs).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,se).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,Bs).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),Ls(this,B)._++,r(this,Ne).call(this,p,f,l),l&&(l.set="add"),c=false,r(this,De)&&((m=r(this,ye))==null||m.call(this,s,t,"add"));else {g(this,x,ts).call(this,p);let E=r(this,L)[p];if(s!==E){if(r(this,ne)&&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,be).call(this,p),r(this,Ne).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,De)&&this.onInsert?.(s,t,s===E?"update":"replace");}if(n!==0&&!r(this,ut)&&g(this,x,Si).call(this),r(this,ut)&&(c||r(this,as).call(this,p,n,o),l&&r(this,Bt).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,Bs).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,Bt).call(this,n,o));else return i&&r(this,we).call(this,o),n&&(n.has="hit",r(this,Bt).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,ne))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,Gs).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,ts).call(this,O),n&&r(this,we).call(this,O),w&&r(this,Bt).call(this,w,O),k;let _=g(this,x,Gs).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,Pe);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,Bt).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,se).call(this,t,"expire"),a&&i&&(a.returnedStale=true),i?l:void 0)):(a&&(a.get="hit"),c?l.__staleWhileFetching:(g(this,x,ts).call(this,h),n&&r(this,we).call(this,h),l))}else a&&(a.get="miss");}delete(t){return g(this,x,se).call(this,t,"delete")}clear(){return g(this,x,ki).call(this,"delete")}},yt=new WeakMap,lt=new WeakMap,kt=new WeakMap,ye=new WeakMap,Ct=new WeakMap,Fe=new WeakMap,Pe=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,ne=new WeakMap,it=new WeakMap,De=new WeakMap,x=new WeakSet,Si=function(){let t=new Us(r(this,yt)),s=new Us(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,as,(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,se).call(this,r(this,I)[a],"expire");},h+1);c.unref&&c.unref(),i[a]=c;}}),d(this,we,a=>{s[a]=t[a]!==0?r(this,Ot).now():0;}),d(this,Bt,(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});},we=new WeakMap,Bt=new WeakMap,as=new WeakMap,pt=new WeakMap,Zr=function(){let t=new Us(r(this,yt));d(this,Rt,0),d(this,Mt,t),d(this,be,s=>{d(this,Rt,r(this,Rt)-t[s]),t[s]=0;}),d(this,hs,(s,i,n,o)=>{if(g(this,x,D).call(this,i))return 0;if(!Xt(n))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(n=o(i,s),!Xt(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,Ne,(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,Bs).call(this,true);}d(this,Rt,r(this,Rt)+t[s]),n&&(n.entrySize=i,n.totalCalculatedSize=r(this,Rt));});},be=new WeakMap,Ne=new WeakMap,hs=new WeakMap,te=function*({allowStale:t=this.allowStale}={}){if(r(this,B))for(let s=r(this,Z);!(!g(this,x,xi).call(this,s)||((t||!r(this,pt).call(this,s))&&(yield s),s===r(this,tt)));)s=r(this,ct)[s];},ee=function*({allowStale:t=this.allowStale}={}){if(r(this,B))for(let s=r(this,tt);!(!g(this,x,xi).call(this,s)||((t||!r(this,pt).call(this,s))&&(yield s),s===r(this,Z)));)s=r(this,st)[s];},xi=function(t){return t!==void 0&&r(this,$).get(r(this,I)[t])===t},Bs=function(t){var o;let s=r(this,tt),i=r(this,I)[s],n=r(this,L)[s];return r(this,ne)&&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,be).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),Ls(this,B)._--,s},Gs=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 Ks,{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,se).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,se).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,Fe))==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,ne))return false;let s=t;return !!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Ks},Ei=function(t,s){r(this,ct)[s]=t,r(this,st)[t]=s;},ts=function(t){t!==r(this,Z)&&(t===r(this,tt)?d(this,tt,r(this,st)[t]):g(this,x,Ei).call(this,r(this,ct)[t],r(this,st)[t]),g(this,x,Ei).call(this,r(this,Z),t),d(this,Z,t));},se=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,ki).call(this,s);else {r(this,be).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];}Ls(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},ki=function(t){var s,i;for(let n of g(this,x,ee).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);}},Ie),Hi=typeof process=="object"&&process?process:{stdout:null,stderr:null},ta=e=>!!e&&typeof e=="object"&&(e instanceof Ys||e instanceof Kr__default.default||ea(e)||sa(e)),ea=e=>!!e&&typeof e=="object"&&e instanceof events.EventEmitter&&typeof e.pipe=="function"&&e.pipe!==Kr__default.default.Writable.prototype.pipe,sa=e=>!!e&&typeof e=="object"&&e instanceof events.EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",zt=Symbol("EOF"),$t=Symbol("maybeEmitEnd"),Qt=Symbol("emittedEnd"),Ps=Symbol("emittingEnd"),He=Symbol("emittedError"),Ds=Symbol("closed"),Zi=Symbol("read"),Ns=Symbol("flush"),Ki=Symbol("flushChunk"),xt=Symbol("encoding"),Me=Symbol("decoder"),V=Symbol("flowing"),Ze=Symbol("paused"),Ae=Symbol("resume"),q=Symbol("buffer"),et=Symbol("pipes"),J=Symbol("bufferLength"),di=Symbol("bufferPush"),Is=Symbol("bufferShift"),X=Symbol("objectMode"),W=Symbol("destroyed"),pi=Symbol("error"),fi=Symbol("emitData"),Yi=Symbol("emitEnd"),gi=Symbol("emitEnd2"),Pt=Symbol("async"),mi=Symbol("abort"),js=Symbol("aborted"),Ke=Symbol("signal"),de=Symbol("dataListeners"),ht=Symbol("discarded"),Ye=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),Yr=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[Ae](),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 Yr{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);}},ha=e=>!!e.objectMode,la=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",cr,ur,dr,pr,fr,gr,mr,yr,wr,br,vr,Sr,xr,Er,kr,Cr,Or,Rr,Tr,Ys=class extends events.EventEmitter{constructor(...t){let s=t[0]||{};super();u(this,Tr,false);u(this,Rr,false);u(this,Or,[]);u(this,Cr,[]);u(this,kr);u(this,Er);u(this,xr);u(this,Sr);u(this,vr,false);u(this,br,false);u(this,wr,false);u(this,yr,false);u(this,mr,null);u(this,gr,0);u(this,fr,false);u(this,pr);u(this,dr,false);u(this,ur,0);u(this,cr,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");ha(s)?(this[X]=true,this[xt]=null):la(s)?(this[xt]=s.encoding,this[X]=false):(this[X]=false,this[xt]=null),this[Pt]=!!s.async,this[Me]=this[xt]?new string_decoder.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[Ke]=i,i.aborted?this[mi]():i.addEventListener("abort",()=>this[mi]()));}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[Pt]}set async(t){this[Pt]=this[Pt]||!!t;}[(Tr=V,Rr=Ze,Or=et,Cr=q,kr=X,Er=xt,xr=Pt,Sr=Me,vr=zt,br=Qt,wr=Ps,yr=Ds,mr=He,gr=J,fr=W,pr=Ke,dr=js,ur=de,cr=ht,mi)](){this[js]=true,this.emit("abort",this[Ke]?.reason),this.destroy(this[Ke]?.reason);}get aborted(){return this[js]}set aborted(t){}write(t,s,i){if(this[js])return false;if(this[zt])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[Pt]?Ye:ia;if(!this[X]&&!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[X]?(this[V]&&this[J]!==0&&this[Ns](true),this[V]?this.emit("data",t):this[di](t),this[J]!==0&&this.emit("readable"),i&&n(i),this[V]):t.length?(typeof t=="string"&&!(s===this[xt]&&!this[Me]?.lastNeed)&&(t=Buffer.from(t,s)),Buffer.isBuffer(t)&&this[xt]&&(t=this[Me].write(t)),this[V]&&this[J]!==0&&this[Ns](true),this[V]?this.emit("data",t):this[di](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[$t](),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[Zi](t||null,this[q][0]);return this[$t](),s}[Zi](t,s){if(this[X])this[Is]();else {let i=s;t===i.length||t===null?this[Is]():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[zt]&&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[zt]=true,this.writable=false,(this[V]||!this[Ze])&&this[$t](),this}[Ae](){this[W]||(!this[de]&&!this[et].length&&(this[ht]=true),this[Ze]=false,this[V]=true,this.emit("resume"),this[q].length?this[Ns]():this[zt]?this[$t]():this.emit("drain"));}resume(){return this[Ae]()}pause(){this[V]=false,this[Ze]=true,this[ht]=false;}get destroyed(){return this[W]}get flowing(){return this[V]}get paused(){return this[Ze]}[di](t){this[X]?this[J]+=1:this[J]+=t.length,this[q].push(t);}[Is](){return this[X]?this[J]-=1:this[J]-=this[q][0].length,this[q].shift()}[Ns](t=false){do;while(this[Ki](this[Is]())&&this[q].length);!t&&!this[q].length&&!this[zt]&&this.emit("drain");}[Ki](t){return this.emit("data",t),this[V]}pipe(t,s){if(this[W])return t;this[ht]=false;let i=this[Qt];return s=s||{},t===Hi.stdout||t===Hi.stderr?s.end=false:s.end=s.end!==false,s.proxyErrors=!!s.proxyErrors,i?s.end&&t.end():(this[et].push(s.proxyErrors?new aa(this,t,s):new Yr(this,t,s)),this[Pt]?Ye(()=>this[Ae]()):this[Ae]()),t}unpipe(t){let s=this[et].find(i=>i.dest===t);s&&(this[et].length===1?(this[V]&&this[de]===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[de]++,!this[et].length&&!this[V]&&this[Ae]();else if(t==="readable"&&this[J]!==0)super.emit("readable");else if(ra(t)&&this[Qt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[He]){let n=s;this[Pt]?Ye(()=>n.call(this,this[He])):n.call(this,this[He]);}return i}removeListener(t,s){return this.off(t,s)}off(t,s){let i=super.off(t,s);return t==="data"&&(this[de]=this.listeners("data").length,this[de]===0&&!this[ht]&&!this[et].length&&(this[V]=false)),i}removeAllListeners(t){let s=super.removeAllListeners(t);return (t==="data"||t===void 0)&&(this[de]=0,!this[ht]&&!this[et].length&&(this[V]=false)),s}get emittedEnd(){return this[Qt]}[$t](){!this[Ps]&&!this[Qt]&&!this[W]&&this[q].length===0&&this[zt]&&(this[Ps]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ds]&&this.emit("close"),this[Ps]=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[Pt]?(Ye(()=>this[fi](i)),true):this[fi](i);if(t==="end")return this[Yi]();if(t==="close"){if(this[Ds]=true,!this[Qt]&&!this[W])return false;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[He]=i,super.emit(pi,i);let o=!this[Ke]||this.listeners("error").length?super.emit("error",i):false;return this[$t](),o}else if(t==="resume"){let o=super.emit("resume");return this[$t](),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[$t](),n}[fi](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[$t](),s}[Yi](){return this[Qt]?false:(this[Qt]=true,this.readable=false,this[Pt]?(Ye(()=>this[gi]()),true):this[gi]())}[gi](){if(this[Me]){let s=this[Me].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[zt])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[zt]});},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(pi,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(pi,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[Ds]&&s.close(),t?this.emit("error",t):this.emit(W),this}static get isStream(){return ta}},ca=Ho.realpathSync.native,es={lstatSync:Ho.lstatSync,readdir:Ho.readdir,readdirSync:Ho.readdirSync,readlinkSync:Ho.readlinkSync,realpathSync:ca,promises:{lstat:kn.lstat,readdir:kn.readdir,readlink:kn.readlink,realpath:kn.realpath}},Qr=e=>!e||e===es||e===Ho__namespace?es:{...es,...e,promises:{...es.promises,...e.promises||{}}},Xr=/^\\\\\?\\([a-z]:)\\?$/i,ua=e=>e.replace(/\//g,"\\").replace(Xr,"$1\\"),da=/[\\\/]/,wt=0,tn=1,en=2,Dt=4,sn=6,rn=8,pe=10,nn=12,mt=15,Qe=~mt,yi=16,Qi=32,ss=64,Et=128,Ws=256,Vs=512,Xi=ss|Et|Vs,pa=1023,wi=e=>e.isFile()?rn:e.isDirectory()?Dt:e.isSymbolicLink()?pe:e.isCharacterDevice()?en:e.isBlockDevice()?sn:e.isSocket()?nn:e.isFIFO()?tn:wt,tr=new Xs({max:2**12}),is=e=>{let t=tr.get(e);if(t)return t;let s=e.normalize("NFKD");return tr.set(e,s),s},er=new Xs({max:2**12}),zs=e=>{let t=er.get(e);if(t)return t;let s=is(e.toLowerCase());return er.set(e,s),s},sr=class extends Xs{constructor(){super({max:256});}},fa=class extends Xs{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1});}},on=Symbol("PathScurry setAsCwd"),rt,ls,cs,us,ds,ps,fs,gs,ms,ys,ws,bs,vs,Ss,xs,Es,ks,Cs,Os,oe,ve,It,Gt,Vt,qt,A,Se,Jt,jt,R,Oi,qs,rs,Ri,Ti,ns,Js,Mi,Ai,Hs,an,hn,ln,Li,je,We,cn,xe,Mr,at=(Mr=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,ls);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,oe);y(this,ve);y(this,It);y(this,Gt);y(this,Vt);y(this,qt);y(this,A);y(this,Se);y(this,Jt);y(this,jt);y(this,je,[]);y(this,We,false);y(this,xe);this.name=e,d(this,oe,n?zs(e):is(e)),d(this,A,t&pa),this.nocase=n,this.roots=i,this.root=s||this,d(this,Se,o),d(this,It,a.fullpath),d(this,Vt,a.relative),d(this,qt,a.relativePosix),this.parent=a.parent,this.parent?d(this,rt,r(this.parent,rt)):d(this,rt,Qr(a.fs));}get dev(){return r(this,ls)}get mode(){return r(this,cs)}get nlink(){return r(this,us)}get uid(){return r(this,ds)}get gid(){return r(this,ps)}get rdev(){return r(this,fs)}get blksize(){return r(this,gs)}get ino(){return r(this,ms)}get size(){return r(this,ys)}get blocks(){return r(this,ws)}get atimeMs(){return r(this,bs)}get mtimeMs(){return r(this,vs)}get ctimeMs(){return r(this,Ss)}get birthtimeMs(){return r(this,xs)}get atime(){return r(this,Es)}get mtime(){return r(this,ks)}get ctime(){return r(this,Cs)}get birthtime(){return r(this,Os)}get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return r(this,ve)!==void 0?r(this,ve):this.parent?d(this,ve,this.parent.depth()+1):d(this,ve,0)}childrenCache(){return r(this,Se)}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,Oi).call(i,s):g(this,R,Oi).call(this,s)}children(){let e=r(this,Se).get(this);if(e)return e;let t=Object.assign([],{provisional:0});return r(this,Se).set(this,t),d(this,A,r(this,A)&~yi),t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),i=this.nocase?zs(e):is(e);for(let h of s)if(r(h,oe)===i)return h;let n=this.parent?this.sep:"",o=r(this,It)?r(this,It)+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,Vt)!==void 0)return r(this,Vt);let e=this.name,t=this.parent;if(!t)return d(this,Vt,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,qt)!==void 0)return r(this,qt);let e=this.name,t=this.parent;if(!t)return d(this,qt,this.fullpathPosix());let s=t.relativePosix();return s+(!s||!t.parent?"":"/")+e}fullpath(){if(r(this,It)!==void 0)return r(this,It);let e=this.name,t=this.parent;if(!t)return d(this,It,this.name);let s=t.fullpath()+(t.parent?this.sep:"")+e;return d(this,It,s)}fullpathPosix(){if(r(this,Gt)!==void 0)return r(this,Gt);if(this.sep==="/")return d(this,Gt,this.fullpath());if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(i)?d(this,Gt,`//?/${i}`):d(this,Gt,i)}let e=this.parent,t=e.fullpathPosix(),s=t+(!t||!e.parent?"":"/")+this.name;return d(this,Gt,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)===rn}isDirectory(){return (r(this,A)&mt)===Dt}isCharacterDevice(){return (r(this,A)&mt)===en}isBlockDevice(){return (r(this,A)&mt)===sn}isFIFO(){return (r(this,A)&mt)===tn}isSocket(){return (r(this,A)&mt)===nn}isSymbolicLink(){return (r(this,A)&pe)===pe}lstatCached(){return r(this,A)&Qi?this:void 0}readlinkCached(){return r(this,Jt)}realpathCached(){return r(this,jt)}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(r(this,Jt))return true;if(!this.parent)return false;let e=r(this,A)&mt;return !(e!==wt&&e!==pe||r(this,A)&Ws||r(this,A)&Et)}calledReaddir(){return !!(r(this,A)&yi)}isENOENT(){return !!(r(this,A)&Et)}isNamed(e){return this.nocase?r(this,oe)===zs(e):r(this,oe)===is(e)}async readlink(){let e=r(this,Jt);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,Jt,s)}catch(t){g(this,R,Ai).call(this,t.code);return}}readlinkSync(){let e=r(this,Jt);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,Jt,s)}catch(t){g(this,R,Ai).call(this,t.code);return}}async lstat(){if((r(this,A)&Et)===0)try{return g(this,R,Li).call(this,await r(this,rt).promises.lstat(this.fullpath())),this}catch(e){g(this,R,Mi).call(this,e.code);}}lstatSync(){if((r(this,A)&Et)===0)try{return g(this,R,Li).call(this,r(this,rt).lstatSync(this.fullpath())),this}catch(e){g(this,R,Mi).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,je).push(e),r(this,We))return;d(this,We,true);let i=this.fullpath();r(this,rt).readdir(i,{withFileTypes:true},(n,o)=>{if(n)g(this,R,Js).call(this,n.code),s.provisional=0;else {for(let a of o)g(this,R,Hs).call(this,a,s);g(this,R,qs).call(this,s);}g(this,R,cn).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,xe))await r(this,xe);else {let s=()=>{};d(this,xe,new Promise(i=>s=i));try{for(let i of await r(this,rt).promises.readdir(t,{withFileTypes:!0}))g(this,R,Hs).call(this,i,e);g(this,R,qs).call(this,e);}catch(i){g(this,R,Js).call(this,i.code),e.provisional=0;}d(this,xe,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,Hs).call(this,s,e);g(this,R,qs).call(this,e);}catch(s){g(this,R,Js).call(this,s.code),e.provisional=0;}return e.slice(0,e.provisional)}canReaddir(){if(r(this,A)&Xi)return false;let e=mt&r(this,A);return e===wt||e===Dt||e===pe}shouldWalk(e,t){return (r(this,A)&Dt)===Dt&&!(r(this,A)&Xi)&&!e.has(this)&&(!t||t(this))}async realpath(){if(r(this,jt))return r(this,jt);if(!((Vs|Ws|Et)&r(this,A)))try{let e=await r(this,rt).promises.realpath(this.fullpath());return d(this,jt,this.resolve(e))}catch{g(this,R,Ti).call(this);}}realpathSync(){if(r(this,jt))return r(this,jt);if(!((Vs|Ws|Et)&r(this,A)))try{let e=r(this,rt).realpathSync(this.fullpath());return d(this,jt,this.resolve(e))}catch{g(this,R,Ti).call(this);}}[on](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,Vt,s.join(this.sep)),d(i,qt,s.join("/")),i=i.parent,s.push("..");for(i=e;i&&i.parent&&!t.has(i);)d(i,Vt,void 0),d(i,qt,void 0),i=i.parent;}},rt=new WeakMap,ls=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,oe=new WeakMap,ve=new WeakMap,It=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,qt=new WeakMap,A=new WeakMap,Se=new WeakMap,Jt=new WeakMap,jt=new WeakMap,R=new WeakSet,Oi=function(e){let t=this;for(let s of e)t=t.child(s);return t},qs=function(e){var t;d(this,A,r(this,A)|yi);for(let s=e.provisional;s<e.length;s++){let i=e[s];i&&g(t=i,R,rs).call(t);}},rs=function(){r(this,A)&Et||(d(this,A,(r(this,A)|Et)&Qe),g(this,R,Ri).call(this));},Ri=function(){var t;let e=this.children();e.provisional=0;for(let s of e)g(t=s,R,rs).call(t);},Ti=function(){d(this,A,r(this,A)|Vs),g(this,R,ns).call(this);},ns=function(){if(r(this,A)&ss)return;let e=r(this,A);(e&mt)===Dt&&(e&=Qe),d(this,A,e|ss),g(this,R,Ri).call(this);},Js=function(e=""){e==="ENOTDIR"||e==="EPERM"?g(this,R,ns).call(this):e==="ENOENT"?g(this,R,rs).call(this):this.children().provisional=0;},Mi=function(e=""){var t;e==="ENOTDIR"?g(t=this.parent,R,ns).call(t):e==="ENOENT"&&g(this,R,rs).call(this);},Ai=function(e=""){var s;let t=r(this,A);t|=Ws,e==="ENOENT"&&(t|=Et),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Qe),d(this,A,t),e==="ENOTDIR"&&this.parent&&g(s=this.parent,R,ns).call(s);},Hs=function(e,t){return g(this,R,hn).call(this,e,t)||g(this,R,an).call(this,e,t)},an=function(e,t){let s=wi(e),i=this.newChild(e.name,s,{parent:this}),n=r(i,A)&mt;return n!==Dt&&n!==pe&&n!==wt&&d(i,A,r(i,A)|ss),t.unshift(i),t.provisional++,i},hn=function(e,t){for(let s=t.provisional;s<t.length;s++){let i=t[s];if((this.nocase?zs(e.name):is(e.name))===r(i,oe))return g(this,R,ln).call(this,e,i,s,t)}},ln=function(e,t,s,i){let n=t.name;return d(t,A,r(t,A)&Qe|wi(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},Li=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,Es,t),d(this,bs,s),d(this,Os,i),d(this,xs,n),d(this,gs,o),d(this,ws,a),d(this,Cs,h),d(this,Ss,l),d(this,ls,c),d(this,ps,f),d(this,ms,p),d(this,cs,m),d(this,ks,S),d(this,vs,b),d(this,us,v),d(this,fs,E),d(this,ys,w),d(this,ds,M);let C=wi(e);d(this,A,r(this,A)&Qe|C|Qi),C!==wt&&C!==Dt&&C!==pe&&d(this,A,r(this,A)|ss);},je=new WeakMap,We=new WeakMap,cn=function(e){d(this,We,false);let t=r(this,je).slice();r(this,je).length=0,t.forEach(s=>s(null,e));},xe=new WeakMap,Mr),un=class dn 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",da);}newChild(s,i=wt,n={}){return new dn(s,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(s){return On.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 Ni(s,this).root}sameRoot(s,i=this.root.name){return s=s.toUpperCase().replace(/\//g,"\\").replace(Xr,"$1\\"),s===i}},pn=class fn 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 fn(s,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}},ze,$e,Rs,Ts,Ar,gn=(Ar=class{constructor(e=process.cwd(),t,s,{nocase:i,childrenCacheSize:n=16*1024,fs:o=es}={}){u(this,"root");u(this,"rootPath");u(this,"roots");u(this,"cwd");y(this,ze);y(this,$e);y(this,Rs);u(this,"nocase");y(this,Ts);d(this,Ts,Qr(o)),(e instanceof URL||e.startsWith("file://"))&&(e=url.fileURLToPath(e));let a=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),d(this,ze,new sr),d(this,$e,new sr),d(this,Rs,new fa(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,Ts)),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,Rs)}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,ze).get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpath();return r(this,ze).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,$e).get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpathPosix();return r(this,$e).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 Ys({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 Ys({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[on](t);}},ze=new WeakMap,$e=new WeakMap,Rs=new WeakMap,Ts=new WeakMap,Ar),Ni=class extends gn{constructor(t=process.cwd(),s={}){let{nocase:i=true}=s;super(t,On.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 On.win32.parse(t).root.toUpperCase()}newRoot(t){return new un(this.rootPath,Dt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Ii=class extends gn{constructor(t=process.cwd(),s={}){let{nocase:i=false}=s;super(t,On.posix,"/",{...s,nocase:i});u(this,"sep","/");this.nocase=i;}parseRootPath(t){return "/"}newRoot(t){return new pn(this.rootPath,Dt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},mn=class extends Ii{constructor(e=process.cwd(),t={}){let{nocase:s=true}=t;super(e,{...t,nocase:s});}};process.platform==="win32"?un:pn;var ga=process.platform==="win32"?Ni:process.platform==="darwin"?mn:Ii,ma=e=>e.length>=1,ya=e=>e.length>=1,G,ft,Y,Ee,_t,Ms,ae,he,le,Ue,Be,yn=(Be=class{constructor(t,s,i,n){y(this,G);y(this,ft);y(this,Y);u(this,"length");y(this,Ee);y(this,_t);y(this,Ms);y(this,ae);y(this,he);y(this,le);y(this,Ue,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(d(this,G,t),d(this,ft,s),d(this,Y,i),d(this,Ee,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,Ms,r(this,Ms)||(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 Be(r(this,G),r(this,ft),r(this,Y)+1,r(this,Ee))),d(r(this,_t),le,r(this,le)),d(r(this,_t),he,r(this,he)),d(r(this,_t),ae,r(this,ae)),r(this,_t)):d(this,_t,null)}isUNC(){let t=r(this,G);return r(this,he)!==void 0?r(this,he):d(this,he,r(this,Ee)==="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,ae)!==void 0?r(this,ae):d(this,ae,r(this,Ee)==="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,le)!==void 0?r(this,le):d(this,le,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,Ue))}markFollowGlobstar(){return r(this,Y)===0||!this.isGlobstar()||!r(this,Ue)?false:(d(this,Ue,false),true)}},G=new WeakMap,ft=new WeakMap,Y=new WeakMap,Ee=new WeakMap,_t=new WeakMap,Ms=new WeakMap,ae=new WeakMap,he=new WeakMap,le=new WeakMap,Ue=new WeakMap,Be),wa=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",ir=class{constructor(e,{nobrace:t,nocase:s,noext:i,noglobstar:n,platform:o=wa}){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 ue(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 yn(i,n,0,this.platform),a=new ue(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}},ba=class wn{constructor(t=new Map){u(this,"store");this.store=t;}copy(){return new wn(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(){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)])}},Sa=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())}},rr=class bn{constructor(t,s){u(this,"hasWalkedCache");u(this,"matches",new va);u(this,"subwalks",new Sa);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 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(),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 bn(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));}},xa=(e,t)=>typeof e=="string"?new ir([e],t):Array.isArray(e)?new ir(e,t):e,Ge,Ht,ke,bt,fe,_i,Lr,vn=(Lr=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,Ge,[]);y(this,Ht);y(this,ke);u(this,"signal");u(this,"maxDepth");u(this,"includeChildMatches");if(this.patterns=e,this.path=t,this.opts=s,d(this,ke,!s.posix&&s.platform==="win32"?"\\":"/"),this.includeChildMatches=s.includeChildMatches!==false,(s.ignore||!this.includeChildMatches)&&(d(this,Ht,xa(s.ignore??[],s)),!this.includeChildMatches&&typeof r(this,Ht).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,Ge).length=0;}));}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let e;for(;!this.paused&&(e=r(this,Ge).shift());)e();}onResume(e){this.signal?.aborted||(this.paused?r(this,Ge).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,fe).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,fe).call(this,e))return;if(!this.includeChildMatches&&r(this,Ht)?.add){let n=`${e.relativePosix()}/**`;r(this,Ht).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,ke):"";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,ke))?"."+r(this,ke):"";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 rr(this.opts),s);}walkCB2(e,t,s,i){if(g(this,bt,_i).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,fe).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,fe).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 rr(this.opts),s);}walkCB2Sync(e,t,s,i){if(g(this,bt,_i).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,fe).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,fe).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();}},Ge=new WeakMap,Ht=new WeakMap,ke=new WeakMap,bt=new WeakSet,fe=function(e){return this.seen.has(e)||!!r(this,Ht)?.ignored?.(e)},_i=function(e){return !!r(this,Ht)?.childrenIgnored?.(e)},Lr),nr=class extends vn{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}},or=class extends vn{constructor(t,s,i){super(t,s,i);u(this,"results");this.results=new Ys({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",Oe=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=url.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||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 h=t.platform==="win32"?Ni:t.platform==="darwin"?mn:t.platform?Ii:ga;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 ue(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 yn(h,c,0,this.platform)});}async walk(){return [...await new nr(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 nr(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 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}).stream()}streamSync(){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}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}},ka=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let s of e)if(new ue(s,t).hasMagic())return true;return false};function ti(e,t={}){return new Oe(e,t).streamSync()}function Sn(e,t={}){return new Oe(e,t).stream()}function xn(e,t={}){return new Oe(e,t).walkSync()}async function ar(e,t={}){return new Oe(e,t).walk()}function ei(e,t={}){return new Oe(e,t).iterateSync()}function En(e,t={}){return new Oe(e,t).iterate()}var Ca=ti,Oa=Object.assign(Sn,{sync:ti}),Ra=ei,Ta=Object.assign(En,{sync:ei}),Ma=Object.assign(xn,{stream:ti,iterate:ei}),Qs=Object.assign(ar,{glob:ar,globSync:xn,sync:Ma,globStream:Sn,stream:Oa,globStreamSync:ti,streamSync:Ca,globIterate:En,iterate:Ta,globIterateSync:ei,iterateSync:Ra,Glob:Oe,hasMagic:ka,escape:$r,unescape:Le});Qs.glob=Qs;var Cn=On__default.default.join(process.cwd(),"log"),Ve;(O=>{O.Level=La__default.default.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(Cn).catch(T=>{}),k.print){p=true;return}h=On__default.default.join(Cn,k.dev?"dev.log":(new Date().toISOString().split(".")[0]??"").replace(/:/g,"")+".log");try{c=await kn__default.default.open(h,"w"),f=Ho.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 Qs("????-??-??T??????.log",{cwd:k,absolute:true});if(T.length<=5)return;let _=T.slice(0,-10);await Promise.all(_.map(P=>kn__default.default.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 Zt=Object.entries({...k,...j}).filter(([ji,Kt])=>Kt!=null).map(([ji,Kt])=>{let ni=`${ji}=`;return Kt instanceof Error?ni+w(Kt):typeof Kt=="object"?ni+JSON.stringify(Kt):ni+Kt}).join(" "),St=new Date,An=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"),"+"+An+"ms",Zt,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 Zt=Date.now();P.info(F,{status:"started",...j});function St(){P.info(F,{status:"completed",duration:Date.now()-Zt,...j});}return {stop:St,[Symbol.dispose](){St();}}}};return T&&typeof T=="string"&&o.set(T,P),P}O.create=C;})(Ve||(Ve={}));var vt=Ve.create({service:"ollama-sdk",module:"native-language-model"});function si(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function ii(e){if(!e||e.trim().length===0)return false;try{return JSON.parse(e),!0}catch{return false}}function Rn(e){return typeof e=="string"?e:JSON.stringify(e)}function Tn(e){return !e.tools||e.tools.length===0?{}:{tools:e.tools.map(t=>{if(!t.name)throw new qe(t.name||"unknown","name");let s=t.inputSchema||t.parameters;if(!s)throw new qe(t.name,"inputSchema");return {type:"function",function:{name:t.name,description:t.description,parameters:s}}})}}function Mn(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 ri=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 _s(s.baseURL);}async doStream(t){let s=si();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=Mn(t.prompt),n=Tn({tools:t.tools}),o=JSON.stringify({model:this.modelId,messages:i,options:Te,...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:Te,...n})){if(C&&C.chunkCount++,f){f=!1;let k={type:"response-metadata",id:si(),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 Zt=k.id?"function.name":"id";vt.error("Invalid tool call: missing field",{traceId:s,missingField:Zt,toolCall:void 0}),w.push({type:"error",error:`Invalid tool call: missing ${Zt}`});continue}let T=k.id,_=k.function.name,P=Rn(k.function.arguments),F=E.find(Zt=>Zt.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:ii(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:ii(P)}),w.push({type:"tool-input-start",id:T,toolName:_}),P&&w.push({type:"tool-input-delta",id:T,delta:P}));let j=ii(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=si();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=Mn(t.prompt),n=Tn({tools:t.tools}),o=await this.client.chat({model:this.modelId,messages:i,options:Te,...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||si(),p=c.function.name,m=Rn(c.function.arguments);vt.debug("Processing tool call in generate",{traceId:s,toolCallId:f,toolName:p,argumentsLength:m.length,isComplete:ii(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:Te,...n})},response:{}}}};var Re=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 ri(t,{baseURL:s.baseURL||"http://localhost:11434"});}doGenerate(t){return this.nativeModel.doGenerate(t)}doStream(t){return this.nativeModel.doStream(t)}};var As=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=Ve.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 _a(e={}){return Object.assign(s=>new Re(s,e),{languageModel:s=>new Re(s,e),chat:s=>new Re(s,e),textEmbeddingModel:s=>new As(s,e)})}var Fa="0.1.0";
7
- exports.ConnectionError=ai;exports.ModelNotFoundError=hi;exports.OLLAMA_DEFAULT_OPTIONS=Te;exports.OLLAMA_SPECIFIC_PARAMS=Fn;exports.OllamaEmbeddingModel=As;exports.OllamaError=Yt;exports.OllamaLanguageModel=Re;exports.TimeoutError=ci;exports.VERSION=Fa;exports.ValidationError=li;exports.createOllama=_a;
1
+ 'use strict';var zi=require('path'),Rn=require('fs/promises'),Zo=require('fs'),Fa=require('zod'),url=require('url'),events=require('events'),Xr=require('stream'),string_decoder=require('string_decoder');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var zi__default=/*#__PURE__*/_interopDefault(zi);var Rn__default=/*#__PURE__*/_interopDefault(Rn);var Zo__namespace=/*#__PURE__*/_interopNamespace(Zo);var Fa__default=/*#__PURE__*/_interopDefault(Fa);var Xr__default=/*#__PURE__*/_interopDefault(Xr);var _n=Object.defineProperty;var Ui=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),li=(e,t,s)=>t.has(e)||Ui("Cannot "+s);var r=(e,t,s)=>(li(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),d=(e,t,s,i)=>(li(e,t,"write to private field"),t.set(e,s),s),g=(e,t,s)=>(li(e,t,"access private method"),s);var Fs=(e,t,s,i)=>({set _(n){d(e,t,n);},get _(){return r(e,t,i)}});var Ps=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 c of h){let f=c.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 Le={numCtx:262144,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";}},ci=class extends Qt{constructor(s,i){super(`Model not found: ${s}`,i);this.modelId=s;this.name="ModelNotFoundError";}},ui=class extends Qt{constructor(s,i,n,o){super(s,o);this.field=i;this.value=n;this.name="ValidationError";}},di=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 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&&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)}},Bi=(e,t)=>{let s=t.match(e);return s?s[0]:null},Dn=(e,t,s)=>{let i,n,o,a,l,h=s.indexOf(e),c=s.indexOf(t,h+1),f=h;if(h>=0&&c>0){if(e===t)return [h,c];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,c]);}else n=i.pop(),n!==void 0&&n<o&&(o=n,a=c),c=s.indexOf(t,f+1);f=h<c&&h>=0?h:c;}i.length&&a!==void 0&&(l=[o,a]);}return l},Ir="\0SLASH"+Math.random()+"\0",Nr="\0OPEN"+Math.random()+"\0",Di="\0CLOSE"+Math.random()+"\0",jr="\0COMMA"+Math.random()+"\0",Wr="\0PERIOD"+Math.random()+"\0",In=new RegExp(Ir,"g"),Nn=new RegExp(Nr,"g"),jn=new RegExp(Di,"g"),Wn=new RegExp(jr,"g"),zn=new RegExp(Wr,"g"),$n=/\\\\/g,Un=/\\{/g,Bn=/\\}/g,Gn=/\\,/g,Vn=/\\./g,qn=1e5;function pi(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Jn(e){return e.replace($n,Ir).replace(Un,Nr).replace(Bn,Di).replace(Gn,jr).replace(Vn,Wr)}function Hn(e){return e.replace(In,"\\").replace(Nn,"{").replace(jn,"}").replace(Wn,",").replace(zn,".")}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 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=Dr("{","}",e);if(!n)return [e];let o=n.pre,a=n.post.length?ts(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),c=l||h,f=n.body.indexOf(",")>=0;if(!c&&!f)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+Di+n.post,ts(e,t,true)):[e];let p;if(c)p=n.body.split(/\.\./);else if(p=zr(n.body),p.length===1&&p[0]!==void 0&&(p=ts(p[0],t,false).map(Kn),p.length===1))return a.map(b=>n.pre+p[0]+b);let y;if(c&&p[0]!==void 0&&p[1]!==void 0){let b=pi(p[0]),S=pi(p[1]),v=Math.max(p[0].length,p[1].length),E=p.length===3&&p[2]!==void 0?Math.abs(pi(p[2])):1,w=Qn;S<b&&(E*=-1,w=Xn);let k=p.some(Yn);y=[];for(let M=b;w(M,S);M+=E){let C;if(h)C=String.fromCharCode(M),C==="\\"&&(C="");else if(C=String(M),k){let O=v-C.length;if(O>0){let T=new Array(O+1).join("0");M<0?C="-"+T+C.slice(1):C=T+C;}}y.push(C);}}else {y=[];for(let b=0;b<p.length;b++)y.push.apply(y,ts(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||c||v)&&i.push(v);}}return i}var Ys=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,"\\$&"),Gi=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,l=false,h=false,c=false,f=s,p="";t:for(;o<e.length;){let S=e.charAt(o);if((S==="!"||S==="^")&&o===s+1){c=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,k]]of Object.entries(to))if(e.startsWith(v,o)){if(p)return ["$.",false,e.length-s,true];o+=v.length,k?n.push(E):i.push(E),l=l||w;continue t}}if(h=false,p){S>p?i.push(He(p)+"-"+He(S)):S===p&&i.push(He(S)),p="",o++;continue}if(e.startsWith("-]",o+1)){i.push(He(S+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=S,o+=2;continue}i.push(He(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])&&!c){let S=i[0].length===2?i[0].slice(-1):i[0];return [eo(S),false,f-s,false]}let y="["+(c?"^":"")+Gi(i)+"]",b="["+(c?"":"^")+Gi(n)+"]";return [i.length&&n.length?"("+y+"|"+b+")":i.length?y:b,l,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(["!","?","+","*","@"]),Vi=e=>io.has(e),ro="(?!(?:^|/)\\.\\.?(?:$|/))",Ds="(?!\\.)",no=new Set(["[","."]),oo=new Set(["..","."]),ao=new Set("().*{}+?[]^$\\!"),lo=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ii="[^/]",qi=Ii+"*?",Ji=Ii+"+?",G,Y,Bt,N,U,re,me,ne,Nt,ye,as,ke,Ur,ue,tt,Bs,Si,Br,$r=(tt=class{constructor(t,s,i={}){m(this,ke);u(this,"type");m(this,G);m(this,Y);m(this,Bt,false);m(this,N,[]);m(this,U);m(this,re);m(this,me);m(this,ne,false);m(this,Nt);m(this,ye);m(this,as,false);this.type=t,t&&d(this,Y,true),d(this,U,s),d(this,G,r(this,U)?r(r(this,U),G):this),d(this,Nt,r(this,G)===this?i:r(r(this,G),Nt)),d(this,me,r(this,G)===this?[]:r(r(this,G),me)),t==="!"&&!r(r(this,G),ne)&&r(this,me).push(this),d(this,re,r(this,U)?r(r(this,U),N).length:0);}get hasMagic(){if(r(this,Y)!==void 0)return r(this,Y);for(let t of r(this,N))if(typeof t!="string"&&(t.type||t.hasMagic))return d(this,Y,true);return r(this,Y)}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 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),ne)&&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,re)===0)return true;let t=r(this,U);for(let s=0;s<r(this,re);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,re)===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,ue,Bs).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,Y)||r(this,Nt).nocase&&!r(this,Nt).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(r(this,Nt).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,a),{_src:s,_glob:t})}get options(){return r(this,Nt)}toRegExpSource(t){let s=t??!!r(this,Nt).dot;if(r(this,G)===this&&g(this,ke,Ur).call(this),!this.type){let h=this.isStart()&&this.isEnd()&&!r(this,N).some(y=>typeof y!="string"),c=r(this,N).map(y=>{var w;let[b,S,v,E]=typeof y=="string"?g(w=tt,ue,Br).call(w,y,r(this,Y),h):y.toRegExpSource(t);return d(this,Y,r(this,Y)||v),d(this,Bt,r(this,Bt)||E),b}).join(""),f="";if(this.isStart()&&typeof r(this,N)[0]=="string"&&!(r(this,N).length===1&&oo.has(r(this,N)[0]))){let y=no,b=s&&y.has(c.charAt(0))||c.startsWith("\\.")&&y.has(c.charAt(2))||c.startsWith("\\.\\.")&&y.has(c.charAt(4)),S=!s&&!t&&y.has(c.charAt(0));f=b?ro:S?Ds:"";}let p="";return this.isEnd()&&r(r(this,G),ne)&&r(this,U)?.type==="!"&&(p="(?:$|\\/)"),[f+c+p,_e(c),d(this,Y,!!r(this,Y)),r(this,Bt)]}let i=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",o=g(this,ke,Si).call(this,s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let h=this.toString();return d(this,N,[h]),this.type=null,d(this,Y,void 0),[h,_e(this.toString()),false,false]}let a=!i||t||s||!Ds?"":g(this,ke,Si).call(this,true);a===o&&(a=""),a&&(o=`(?:${o})(?:${a})*?`);let l="";if(this.type==="!"&&r(this,as))l=(this.isStart()&&!s?Ds:"")+Ji;else {let h=this.type==="!"?"))"+(this.isStart()&&!s&&!t?Ds:"")+qi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;l=n+o+h;}return [l,_e(o),d(this,Y,!!r(this,Y)),r(this,Bt)]}},G=new WeakMap,Y=new WeakMap,Bt=new WeakMap,N=new WeakMap,U=new WeakMap,re=new WeakMap,me=new WeakMap,ne=new WeakMap,Nt=new WeakMap,ye=new WeakMap,as=new WeakMap,ke=new WeakSet,Ur=function(){if(this!==r(this,G))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,U);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,U);}}return this},ue=new WeakSet,Bs=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 k=new tt(w,s);v=g(b=tt,ue,Bs).call(b,t,k,v,n),s.push(k);continue}E+=w;}return s.push(E),v}let c=i+1,f=new tt(null,s),p=[],y="";for(;c<t.length;){let v=t.charAt(c++);if(o||v==="\\"){o=!o,y+=v;continue}if(a){c===l+1?(v==="^"||v==="!")&&(h=true):v==="]"&&!(c===l+2&&h)&&(a=false),y+=v;continue}else if(v==="["){a=true,l=c,h=false,y+=v;continue}if(Vi(v)&&t.charAt(c)==="("){f.push(y),y="";let E=new tt(v,f);f.push(E),c=g(S=tt,ue,Bs).call(S,t,E,c,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&&d(s,as,true),f.push(y),y="",s.push(...p,f),c;y+=v;}return s.type=null,d(s,Y,void 0),d(s,N,[t.substring(i-1)]),c},Si=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("|")},Br=function(t,s,i=false){let n=false,o="",a=false,l=false;for(let h=0;h<t.length;h++){let c=t.charAt(h);if(n){n=false,o+=(ao.has(c)?"\\":"")+c;continue}if(c==="*"){if(l)continue;l=true,o+=i&&/^[*]+$/.test(t)?Ji:qi,s=true;continue}else l=false;if(c==="\\"){h===t.length-1?o+="\\\\":n=true;continue}if(c==="["){let[f,p,y,b]=so(t,h);if(y){o+=f,a=a||p,h+=y-1,s=s||b;continue}}if(c==="?"){o+=Ii,s=true;continue}o+=lo(c);}return [o,_e(t),!!s,a]},m(tt,ue),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={})=>(Ys(t),!s.nocomment&&t.charAt(0)==="#"?false:new de(t,s).match(e)),ho=/^\*+([^+@!?\*\[\(]*)$/,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=/^\?+([^+@!?\*\[\(]*)?$/,Co=([e,t=""])=>{let s=Vr([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},Oo=([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},Ro=([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:"/"}},Mo=Jr==="win32"?Hi.win32.sep:Hi.posix.sep;lt.sep=Mo;var at=Symbol("globstar **");lt.GLOBSTAR=at;var Lo="[^/]",To=Lo+"*?",Ao="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_o="(?:(?!(?:\\/|^)\\.).)*?",Fo=(e,t={})=>s=>lt(s,e,t);lt.filter=Fo;var yt=(e,t={})=>Object.assign({},e,t),Po=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=Po;var Hr=(e,t={})=>(Ys(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Zn(e,{max:t.braceExpandMax}));lt.braceExpand=Hr;var Do=(e,t={})=>new de(e,t).makeRe();lt.makeRe=Do;var Io=(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};lt.match=Io;var Zi=/[?*]|[+@!]\(.*?\)|\[|\]/,No=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");Ys(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(c=>this.parse(c))];if(h)return [n[0],...n.slice(1).map(c=>this.parse(c))]}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 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 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]),k=v?3:S?0:void 0,M=w?3:E?0:void 0;if(typeof k=="number"&&typeof M=="number"){let[C,O]=[e[k],t[M]];C.toLowerCase()===O.toLowerCase()&&(t[M]=C,M>k?t=t.slice(M):k>M&&(e=e.slice(k)));}}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 c=t[a],f=e[o];if(this.debug(t,c,f),c===false)return false;if(c===at){this.debug("GLOBSTAR",[t,c,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 c=="string"?(S=f===c,this.debug("string match",c,f,S)):(S=c.test(f),this.debug("pattern match",c,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){Ys(e);let t=this.options;if(e==="**")return at;if(e==="")return "";let s,i=null;(s=e.match(vo))?i=t.dot?xo:So:(s=e.match(ho))?i=(t.nocase?t.dot?fo:po:t.dot?uo:co)(s[1]):(s=e.match(Eo))?i=(t.nocase?t.dot?Oo:Co:t.dot?ko:Ro)(s):(s=e.match(go))?i=t.dot?yo:mo:(s=e.match(wo))&&(i=bo);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?To:t.dot?Ao:_o,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"?No(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 c=h.filter(f=>f!==at);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 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=de;lt.escape=Gr;lt.unescape=_e;var Wo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Zr=new Set,xi=typeof process=="object"&&process?process:{},Kr=(e,t,s,i)=>{typeof xi.emitWarning=="function"?xi.emitWarning(e,t,s,i):console.error(`[${s}] ${t}: ${e}`);},Qs=globalThis.AbortController,Ki=globalThis.AbortSignal;if(typeof Qs>"u"){Ki=class{constructor(){u(this,"onabort");u(this,"_onabort",[]);u(this,"reason");u(this,"aborted",false);}addEventListener(s,i){this._onabort.push(i);}},Qs=class{constructor(){u(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=xi.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 zo=e=>!Zr.has(e),te=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Yr=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?Gs:null:null,Gs=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=Yr(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,m(zt,Fe,false),zt),ur,dr,bt,dt,kt,we,Rt,Pe,De,Mt,V,Lt,B,j,_,rt,pt,st,Q,Tt,X,At,_t,ft,gt,Ft,oe,nt,Ie,x,Ei,be,Gt,ls,mt,Qr,ve,Ne,hs,ee,se,Ci,Vs,qs,I,Oi,es,ie,ki,je,ei=(je=class{constructor(t){m(this,x);m(this,bt);m(this,dt);m(this,kt);m(this,we);m(this,Rt);m(this,Pe);m(this,De);m(this,Mt);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");m(this,V);m(this,Lt);m(this,B);m(this,j);m(this,_);m(this,rt);m(this,pt);m(this,st);m(this,Q);m(this,Tt);m(this,X);m(this,At);m(this,_t);m(this,ft);m(this,gt);m(this,Ft);m(this,oe);m(this,nt);m(this,Ie);m(this,be,()=>{});m(this,Gt,()=>{});m(this,ls,()=>{});m(this,mt,()=>false);m(this,ve,t=>{});m(this,Ne,(t,s,i)=>{});m(this,hs,(t,s,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});u(this,ur,"LRUCache");let{max:s=0,ttl:i,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:h,dispose:c,onInsert:f,disposeAfter:p,noDisposeOnSet:y,noUpdateTTL:b,maxSize:S=0,maxEntrySize:v=0,sizeCalculation:E,fetchMethod:w,memoMethod:k,noDeleteOnFetchRejection:M,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:T,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(d(this,Mt,D??Wo),s!==0&&!te(s))throw new TypeError("max option must be a nonnegative integer");let L=s?Yr(s):Array;if(!L)throw new Error("invalid max value: "+s);if(d(this,bt,s),d(this,dt,S),this.maxEntrySize=v||r(this,dt),this.sizeCalculation=E,this.sizeCalculation){if(!r(this,dt)&&!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(k!==void 0&&typeof k!="function")throw new TypeError("memoMethod must be a function if defined");if(d(this,De,k),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,B,new Map),d(this,j,new Array(s).fill(void 0)),d(this,_,new Array(s).fill(void 0)),d(this,rt,new L(s)),d(this,pt,new L(s)),d(this,st,0),d(this,Q,0),d(this,Tt,$o.create(s)),d(this,V,0),d(this,Lt,0),typeof c=="function"&&d(this,kt,c),typeof f=="function"&&d(this,we,f),typeof p=="function"?(d(this,Rt,p),d(this,X,[])):(d(this,Rt,void 0),d(this,X,void 0)),d(this,Ft,!!r(this,kt)),d(this,Ie,!!r(this,we)),d(this,nt,!!r(this,Rt)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!M,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!T,this.ignoreFetchAbort=!!F,this.maxEntrySize!==0){if(r(this,dt)!==0&&!te(r(this,dt)))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,Qr).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,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,Ei).call(this);}if(r(this,bt)===0&&this.ttl===0&&r(this,dt)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,bt)&&!r(this,dt)){let P="LRU_CACHE_UNBOUNDED";zo(P)&&(Zr.add(P),Kr("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",P,je));}}get perf(){return r(this,Mt)}static unsafeExposeInternals(t){return {starts:r(t,_t),ttls:r(t,ft),autopurgeTimers:r(t,gt),sizes:r(t,At),keyMap:r(t,B),keyList:r(t,j),valList:r(t,_),next:r(t,rt),prev:r(t,pt),get head(){return r(t,st)},get tail(){return r(t,Q)},free:r(t,Tt),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,qs).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,mt).call(i,s)}}}get max(){return r(this,bt)}get maxSize(){return r(this,dt)}get calculatedSize(){return r(this,Lt)}get size(){return r(this,V)}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,Rt)}getRemainingTTL(t){return r(this,B).has(t)?1/0:0}*entries(){for(let t of g(this,x,ee).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,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]]);}*keys(){for(let t of g(this,x,ee).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,se).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,ee).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,se).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,ee).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,ee).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,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);}}purgeStale(){let t=false;for(let s of g(this,x,se).call(this,{allowStale:true}))r(this,mt).call(this,s)&&(g(this,x,ie).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,ft)&&r(this,_t)){let a=r(this,ft)[s],l=r(this,_t)[s];if(a&&l){let h=a-(r(this,Mt).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,ee).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,ft)&&r(this,_t)){a.ttl=r(this,ft)[s];let l=r(this,Mt).now()-r(this,_t)[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,Mt).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:c=this.noUpdateTTL}=i,f=r(this,hs).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,ie).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,Q):r(this,Tt).length!==0?r(this,Tt).pop():r(this,V)===r(this,bt)?g(this,x,Vs).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,Q)]=p,r(this,pt)[p]=r(this,Q),d(this,Q,p),Fs(this,V)._++,r(this,Ne).call(this,p,f,h),h&&(h.set="add"),c=false,r(this,Ie)&&((y=r(this,we))==null||y.call(this,s,t,"add"));else {g(this,x,es).call(this,p);let E=r(this,_)[p];if(s!==E){if(r(this,oe)&&g(this,x,I).call(this,E)){E.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=E;w!==void 0&&!a&&(r(this,Ft)&&((b=r(this,kt))==null||b.call(this,w,t,"set")),r(this,nt)&&r(this,X)?.push([w,t,"set"]));}else a||(r(this,Ft)&&((S=r(this,kt))==null||S.call(this,E,t,"set")),r(this,nt)&&r(this,X)?.push([E,t,"set"]));if(r(this,ve).call(this,p),r(this,Ne).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,Ie)&&this.onInsert?.(s,t,s===E?"update":"replace");}if(n!==0&&!r(this,ft)&&g(this,x,Ei).call(this),r(this,ft)&&(c||r(this,ls).call(this,p,n,o),h&&r(this,Gt).call(this,h,p)),!a&&r(this,nt)&&r(this,X)){let E=r(this,X),w;for(;w=E?.shift();)(v=r(this,Rt))==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,Vs).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,X)){let s=r(this,X),i;for(;i=s?.shift();)(t=r(this,Rt))==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,mt).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,B).get(t);if(n===void 0||!i&&r(this,mt).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:c=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:k}=s;if(!r(this,oe))return w&&(w.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,status:w});let M={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:l,size:h,sizeCalculation:c,noUpdateTTL:f,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:S,ignoreFetchAbort:b,status:w,signal:k},C=r(this,B).get(t);if(C===void 0){w&&(w.fetch="miss");let O=g(this,x,qs).call(this,t,C,M,v);return O.__returned=O}else {let O=r(this,_)[C];if(g(this,x,I).call(this,O)){let L=i&&O.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",L&&(w.returnedStale=true)),L?O.__staleWhileFetching:O.__returned=O}let T=r(this,mt).call(this,C);if(!E&&!T)return w&&(w.fetch="hit"),g(this,x,es).call(this,C),n&&r(this,be).call(this,C),w&&r(this,Gt).call(this,w,C),O;let F=g(this,x,qs).call(this,t,C,M,v),D=F.__staleWhileFetching!==void 0&&i;return w&&(w.fetch=T?"stale":"refresh",D&&T&&(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,De);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],c=g(this,x,I).call(this,h);return a&&r(this,Gt).call(this,a,l),r(this,mt).call(this,l)?(a&&(a.get="stale"),c?(a&&i&&h.__staleWhileFetching!==void 0&&(a.returnedStale=true),i?h.__staleWhileFetching:void 0):(o||g(this,x,ie).call(this,t,"expire"),a&&i&&(a.returnedStale=true),i?h:void 0)):(a&&(a.get="hit"),c?h.__staleWhileFetching:(g(this,x,es).call(this,l),n&&r(this,be).call(this,l),h))}else a&&(a.get="miss");}delete(t){return g(this,x,ie).call(this,t,"delete")}clear(){return g(this,x,ki).call(this,"delete")}},bt=new WeakMap,dt=new WeakMap,kt=new WeakMap,we=new WeakMap,Rt=new WeakMap,Pe=new WeakMap,De=new WeakMap,Mt=new WeakMap,V=new WeakMap,Lt=new WeakMap,B=new WeakMap,j=new WeakMap,_=new WeakMap,rt=new WeakMap,pt=new WeakMap,st=new WeakMap,Q=new WeakMap,Tt=new WeakMap,X=new WeakMap,At=new WeakMap,_t=new WeakMap,ft=new WeakMap,gt=new WeakMap,Ft=new WeakMap,oe=new WeakMap,nt=new WeakMap,Ie=new WeakMap,x=new WeakSet,Ei=function(){let t=new Gs(r(this,bt)),s=new Gs(r(this,bt));d(this,ft,t),d(this,_t,s);let i=this.ttlAutopurge?new Array(r(this,bt)):void 0;d(this,gt,i),d(this,ls,(a,l,h=r(this,Mt).now())=>{if(s[a]=l!==0?h:0,t[a]=l,i?.[a]&&(clearTimeout(i[a]),i[a]=void 0),l!==0&&i){let c=setTimeout(()=>{r(this,mt).call(this,a)&&g(this,x,ie).call(this,r(this,j)[a],"expire");},l+1);c.unref&&c.unref(),i[a]=c;}}),d(this,be,a=>{s[a]=t[a]!==0?r(this,Mt).now():0;}),d(this,Gt,(a,l)=>{if(t[l]){let h=t[l],c=s[l];if(!h||!c)return;a.ttl=h,a.start=c,a.now=n||o();let f=a.now-c;a.remainingTTL=h-f;}});let n=0,o=()=>{let a=r(this,Mt).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],c=s[l];if(!h||!c)return 1/0;let f=(n||o())-c;return h-f},d(this,mt,a=>{let l=s[a],h=t[a];return !!h&&!!l&&(n||o())-l>h});},be=new WeakMap,Gt=new WeakMap,ls=new WeakMap,mt=new WeakMap,Qr=function(){let t=new Gs(r(this,bt));d(this,Lt,0),d(this,At,t),d(this,ve,s=>{d(this,Lt,r(this,Lt)-t[s]),t[s]=0;}),d(this,hs,(s,i,n,o)=>{if(g(this,x,I).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,Ne,(s,i,n)=>{if(t[s]=i,r(this,dt)){let o=r(this,dt)-t[s];for(;r(this,Lt)>o;)g(this,x,Vs).call(this,true);}d(this,Lt,r(this,Lt)+t[s]),n&&(n.entrySize=i,n.totalCalculatedSize=r(this,Lt));});},ve=new WeakMap,Ne=new WeakMap,hs=new WeakMap,ee=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let s=r(this,Q);!(!g(this,x,Ci).call(this,s)||((t||!r(this,mt).call(this,s))&&(yield s),s===r(this,st)));)s=r(this,pt)[s];},se=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let s=r(this,st);!(!g(this,x,Ci).call(this,s)||((t||!r(this,mt).call(this,s))&&(yield s),s===r(this,Q)));)s=r(this,rt)[s];},Ci=function(t){return t!==void 0&&r(this,B).get(r(this,j)[t])===t},Vs=function(t){var o;let s=r(this,st),i=r(this,j)[s],n=r(this,_)[s];return r(this,oe)&&g(this,x,I).call(this,n)?n.__abortController.abort(new Error("evicted")):(r(this,Ft)||r(this,nt))&&(r(this,Ft)&&((o=r(this,kt))==null||o.call(this,n,i,"evict")),r(this,nt)&&r(this,X)?.push([n,i,"evict"])),r(this,ve).call(this,s),r(this,gt)?.[s]&&(clearTimeout(r(this,gt)[s]),r(this,gt)[s]=void 0),t&&(r(this,j)[s]=void 0,r(this,_)[s]=void 0,r(this,Tt).push(s)),r(this,V)===1?(d(this,st,d(this,Q,0)),r(this,Tt).length=0):d(this,st,r(this,rt)[s]),r(this,B).delete(i),Fs(this,V)._--,s},qs=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 Qs,{signal:l}=i;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let h={signal:a.signal,options:i,context:n},c=(v,E=false)=>{let{aborted:w}=a.signal,k=i.ignoreFetchAbort&&v!==void 0,M=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&v!==void 0);if(i.status&&(w&&!E?(i.status.fetchAborted=true,i.status.fetchError=a.signal.reason,k&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),w&&!k&&!E)return p(a.signal.reason,M);let C=b,O=r(this,_)[s];return (O===b||k&&E&&O===void 0)&&(v===void 0?C.__staleWhileFetching!==void 0?r(this,_)[s]=C.__staleWhileFetching:g(this,x,ie).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,k=w&&i.allowStaleOnFetchAbort,M=k||i.allowStaleOnFetchRejection,C=M||i.noDeleteOnFetchRejection,O=b;if(r(this,_)[s]===b&&(!C||!E&&O.__staleWhileFetching===void 0?g(this,x,ie).call(this,t,"fetch"):k||(r(this,_)[s]=O.__staleWhileFetching)),M)return i.status&&O.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw v},y=(v,E)=>{var k;let w=(k=r(this,Pe))==null?void 0:k.call(this,t,o,h);w&&w instanceof Promise&&w.then(M=>v(M===void 0?void 0:M),E),a.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(v(void 0),i.allowStaleOnFetchAbort&&(v=M=>c(M,true)));});};i.status&&(i.status.fetchDispatched=true);let b=new Promise(y).then(c,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,oe))return false;let s=t;return !!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Qs},Oi=function(t,s){r(this,pt)[s]=t,r(this,rt)[t]=s;},es=function(t){t!==r(this,Q)&&(t===r(this,st)?d(this,st,r(this,rt)[t]):g(this,x,Oi).call(this,r(this,pt)[t],r(this,rt)[t]),g(this,x,Oi).call(this,r(this,Q),t),d(this,Q,t));},ie=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,gt)?.[a]&&(clearTimeout(r(this,gt)?.[a]),r(this,gt)[a]=void 0),i=true,r(this,V)===1)g(this,x,ki).call(this,s);else {r(this,ve).call(this,a);let l=r(this,_)[a];if(g(this,x,I).call(this,l)?l.__abortController.abort(new Error("deleted")):(r(this,Ft)||r(this,nt))&&(r(this,Ft)&&((n=r(this,kt))==null||n.call(this,l,t,s)),r(this,nt)&&r(this,X)?.push([l,t,s])),r(this,B).delete(t),r(this,j)[a]=void 0,r(this,_)[a]=void 0,a===r(this,Q))d(this,Q,r(this,pt)[a]);else if(a===r(this,st))d(this,st,r(this,rt)[a]);else {let h=r(this,pt)[a];r(this,rt)[h]=r(this,rt)[a];let c=r(this,rt)[a];r(this,pt)[c]=r(this,pt)[a];}Fs(this,V)._--,r(this,Tt).push(a);}}if(r(this,nt)&&r(this,X)?.length){let a=r(this,X),l;for(;l=a?.shift();)(o=r(this,Rt))==null||o.call(this,...l);}return i},ki=function(t){var s,i;for(let n of g(this,x,se).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,Ft)&&((s=r(this,kt))==null||s.call(this,o,a,t)),r(this,nt)&&r(this,X)?.push([o,a,t]);}}if(r(this,B).clear(),r(this,_).fill(void 0),r(this,j).fill(void 0),r(this,ft)&&r(this,_t)){r(this,ft).fill(0),r(this,_t).fill(0);for(let n of r(this,gt)??[])n!==void 0&&clearTimeout(n);r(this,gt)?.fill(void 0);}if(r(this,At)&&r(this,At).fill(0),d(this,st,0),d(this,Q,0),r(this,Tt).length=0,d(this,Lt,0),d(this,V,0),r(this,nt)&&r(this,X)){let n=r(this,X),o;for(;o=n?.shift();)(i=r(this,Rt))==null||i.call(this,...o);}},je),Yi=typeof process=="object"&&process?process:{stdout:null,stderr:null},ea=e=>!!e&&typeof e=="object"&&(e instanceof Xs||e instanceof Xr__default.default||sa(e)||ia(e)),sa=e=>!!e&&typeof e=="object"&&e instanceof events.EventEmitter&&typeof e.pipe=="function"&&e.pipe!==Xr__default.default.Writable.prototype.pipe,ia=e=>!!e&&typeof e=="object"&&e instanceof events.EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",$t=Symbol("EOF"),Ut=Symbol("maybeEmitEnd"),Xt=Symbol("emittedEnd"),Is=Symbol("emittingEnd"),Ze=Symbol("emittedError"),Ns=Symbol("closed"),Qi=Symbol("read"),js=Symbol("flush"),Xi=Symbol("flushChunk"),Ct=Symbol("encoding"),Te=Symbol("decoder"),H=Symbol("flowing"),Ke=Symbol("paused"),Ae=Symbol("resume"),Z=Symbol("buffer"),it=Symbol("pipes"),K=Symbol("bufferLength"),fi=Symbol("bufferPush"),Ws=Symbol("bufferShift"),et=Symbol("objectMode"),$=Symbol("destroyed"),gi=Symbol("error"),mi=Symbol("emitData"),tr=Symbol("emitEnd"),yi=Symbol("emitEnd2"),Dt=Symbol("async"),wi=Symbol("abort"),zs=Symbol("aborted"),Ye=Symbol("signal"),pe=Symbol("dataListeners"),ut=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),tn=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[Ae](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},la=class extends tn{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(e,t,s){super(e,t,s),this.proxyErrors=i=>this.dest.emit("error",i),e.on("error",this.proxyErrors);}},ha=e=>!!e.objectMode,ca=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",pr,fr,gr,mr,yr,wr,br,vr,Sr,xr,Er,Cr,Or,kr,Rr,Mr,Lr,Tr,Ar,Xs=class extends events.EventEmitter{constructor(...t){let s=t[0]||{};super();u(this,Ar,false);u(this,Tr,false);u(this,Lr,[]);u(this,Mr,[]);u(this,Rr);u(this,kr);u(this,Or);u(this,Cr);u(this,Er,false);u(this,xr,false);u(this,Sr,false);u(this,vr,false);u(this,br,null);u(this,wr,0);u(this,yr,false);u(this,mr);u(this,gr,false);u(this,fr,0);u(this,pr,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");ha(s)?(this[et]=true,this[Ct]=null):ca(s)?(this[Ct]=s.encoding,this[et]=false):(this[et]=false,this[Ct]=null),this[Dt]=!!s.async,this[Te]=this[Ct]?new string_decoder.StringDecoder(this[Ct]):null,s&&s.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[Z]}),s&&s.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[it]});let{signal:i}=s;i&&(this[Ye]=i,i.aborted?this[wi]():i.addEventListener("abort",()=>this[wi]()));}get bufferLength(){return this[K]}get encoding(){return this[Ct]}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[Dt]}set async(t){this[Dt]=this[Dt]||!!t;}[(Ar=H,Tr=Ke,Lr=it,Mr=Z,Rr=et,kr=Ct,Or=Dt,Cr=Te,Er=$t,xr=Xt,Sr=Is,vr=Ns,br=Ze,wr=K,yr=$,mr=Ye,gr=zs,fr=pe,pr=ut,wi)](){this[zs]=true,this.emit("abort",this[Ye]?.reason),this.destroy(this[Ye]?.reason);}get aborted(){return this[zs]}set aborted(t){}write(t,s,i){if(this[zs])return false;if(this[$t])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[Dt]?Qe:ra;if(!this[et]&&!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[et]?(this[H]&&this[K]!==0&&this[js](true),this[H]?this.emit("data",t):this[fi](t),this[K]!==0&&this.emit("readable"),i&&n(i),this[H]):t.length?(typeof t=="string"&&!(s===this[Ct]&&!this[Te]?.lastNeed)&&(t=Buffer.from(t,s)),Buffer.isBuffer(t)&&this[Ct]&&(t=this[Te].write(t)),this[H]&&this[K]!==0&&this[js](true),this[H]?this.emit("data",t):this[fi](t),this[K]!==0&&this.emit("readable"),i&&n(i),this[H]):(this[K]!==0&&this.emit("readable"),i&&n(i),this[H])}read(t){if(this[$])return null;if(this[ut]=false,this[K]===0||t===0||t&&t>this[K])return this[Ut](),null;this[et]&&(t=null),this[Z].length>1&&!this[et]&&(this[Z]=[this[Ct]?this[Z].join(""):Buffer.concat(this[Z],this[K])]);let s=this[Qi](t||null,this[Z][0]);return this[Ut](),s}[Qi](t,s){if(this[et])this[Ws]();else {let i=s;t===i.length||t===null?this[Ws]():typeof i=="string"?(this[Z][0]=i.slice(t),s=i.slice(0,t),this[K]-=t):(this[Z][0]=i.subarray(t),s=i.subarray(0,t),this[K]-=t);}return this.emit("data",s),!this[Z].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[H]||!this[Ke])&&this[Ut](),this}[Ae](){this[$]||(!this[pe]&&!this[it].length&&(this[ut]=true),this[Ke]=false,this[H]=true,this.emit("resume"),this[Z].length?this[js]():this[$t]?this[Ut]():this.emit("drain"));}resume(){return this[Ae]()}pause(){this[H]=false,this[Ke]=true,this[ut]=false;}get destroyed(){return this[$]}get flowing(){return this[H]}get paused(){return this[Ke]}[fi](t){this[et]?this[K]+=1:this[K]+=t.length,this[Z].push(t);}[Ws](){return this[et]?this[K]-=1:this[K]-=this[Z][0].length,this[Z].shift()}[js](t=false){do;while(this[Xi](this[Ws]())&&this[Z].length);!t&&!this[Z].length&&!this[$t]&&this.emit("drain");}[Xi](t){return this.emit("data",t),this[H]}pipe(t,s){if(this[$])return t;this[ut]=false;let i=this[Xt];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 la(this,t,s):new tn(this,t,s)),this[Dt]?Qe(()=>this[Ae]()):this[Ae]()),t}unpipe(t){let s=this[it].find(i=>i.dest===t);s&&(this[it].length===1?(this[H]&&this[pe]===0&&(this[H]=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[ut]=false,this[pe]++,!this[it].length&&!this[H]&&this[Ae]();else if(t==="readable"&&this[K]!==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[ut]&&!this[it].length&&(this[H]=false)),i}removeAllListeners(t){let s=super.removeAllListeners(t);return (t==="data"||t===void 0)&&(this[pe]=0,!this[ut]&&!this[it].length&&(this[H]=false)),s}get emittedEnd(){return this[Xt]}[Ut](){!this[Is]&&!this[Xt]&&!this[$]&&this[Z].length===0&&this[$t]&&(this[Is]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ns]&&this.emit("close"),this[Is]=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[Dt]?(Qe(()=>this[mi](i)),true):this[mi](i);if(t==="end")return this[tr]();if(t==="close"){if(this[Ns]=true,!this[Xt]&&!this[$])return false;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Ze]=i,super.emit(gi,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}[mi](t){for(let i of this[it])i.dest.write(t)===false&&this.pause();let s=this[ut]?false:super.emit("data",t);return this[Ut](),s}[tr](){return this[Xt]?false:(this[Xt]=true,this.readable=false,this[Dt]?(Qe(()=>this[yi]()),true):this[yi]())}[yi](){if(this[Te]){let s=this[Te].end();if(s){for(let i of this[it])i.dest.write(s);this[ut]||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[Ct]?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[ut]=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",l),this.off("end",h),this.off($,c),s(),o(f);},l=f=>{this.off("error",a),this.off("end",h),this.off($,c),this.pause(),n({value:f,done:!!this[$t]});},h=()=>{this.off("error",a),this.off("data",l),this.off($,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($,c),this.once("error",a),this.once("end",h),this.once("data",l);})},throw:s,return:s,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[ut]=false;let t=false,s=()=>(this.pause(),this.off(gi,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(gi,s),this.once($,s),{next:i,throw:s,return:s,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[$])return t?this.emit("error",t):this.emit($),this;this[$]=true,this[ut]=true,this[Z].length=0,this[K]=0;let s=this;return typeof s.close=="function"&&!this[Ns]&&s.close(),t?this.emit("error",t):this.emit($),this}static get isStream(){return ea}},ua=Zo.realpathSync.native,ss={lstatSync:Zo.lstatSync,readdir:Zo.readdir,readdirSync:Zo.readdirSync,readlinkSync:Zo.readlinkSync,realpathSync:ua,promises:{lstat:Rn.lstat,readdir:Rn.readdir,readlink:Rn.readlink,realpath:Rn.realpath}},en=e=>!e||e===ss||e===Zo__namespace?ss:{...ss,...e,promises:{...ss.promises,...e.promises||{}}},sn=/^\\\\\?\\([a-z]:)\\?$/i,da=e=>e.replace(/\//g,"\\").replace(sn,"$1\\"),pa=/[\\\/]/,vt=0,rn=1,nn=2,It=4,on=6,an=8,fe=10,ln=12,wt=15,Xe=~wt,bi=16,er=32,is=64,Ot=128,$s=256,Js=512,sr=is|Ot|Js,fa=1023,vi=e=>e.isFile()?an:e.isDirectory()?It:e.isSymbolicLink()?fe:e.isCharacterDevice()?nn:e.isBlockDevice()?on:e.isSocket()?ln:e.isFIFO()?rn:vt,ir=new ei({max:2**12}),rs=e=>{let t=ir.get(e);if(t)return t;let s=e.normalize("NFKD");return ir.set(e,s),s},rr=new ei({max:2**12}),Us=e=>{let t=rr.get(e);if(t)return t;let s=rs(e.toLowerCase());return rr.set(e,s),s},nr=class extends ei{constructor(){super({max:256});}},ga=class extends ei{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1});}},hn=Symbol("PathScurry setAsCwd"),ot,cs,us,ds,ps,fs,gs,ms,ys,ws,bs,vs,Ss,xs,Es,Cs,Os,ks,Rs,ae,Se,jt,Vt,qt,Jt,A,xe,Ht,Wt,R,Mi,Hs,ns,Li,Ti,os,Zs,Ai,_i,Ks,cn,un,dn,Fi,We,ze,pn,Ee,_r,ht=(_r=class{constructor(e,t=vt,s,i,n,o,a){m(this,R);u(this,"name");u(this,"root");u(this,"roots");u(this,"parent");u(this,"nocase");u(this,"isCWD",false);m(this,ot);m(this,cs);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,Os);m(this,ks);m(this,Rs);m(this,ae);m(this,Se);m(this,jt);m(this,Vt);m(this,qt);m(this,Jt);m(this,A);m(this,xe);m(this,Ht);m(this,Wt);m(this,We,[]);m(this,ze,false);m(this,Ee);this.name=e,d(this,ae,n?Us(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,ot,r(this.parent,ot)):d(this,ot,en(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,Cs)}get mtime(){return r(this,Os)}get ctime(){return r(this,ks)}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,Mi).call(i,s):g(this,R,Mi).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)&~bi),t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),i=this.nocase?Us(e):rs(e);for(let l of s)if(r(l,ae)===i)return l;let n=this.parent?this.sep:"",o=r(this,jt)?r(this,jt)+n+e:void 0,a=this.newChild(e,vt,{...t,parent:this,fullpath:o});return this.canReaddir()||d(a,A,r(a,A)|Ot),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)&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,A)&wt)===an}isDirectory(){return (r(this,A)&wt)===It}isCharacterDevice(){return (r(this,A)&wt)===nn}isBlockDevice(){return (r(this,A)&wt)===on}isFIFO(){return (r(this,A)&wt)===rn}isSocket(){return (r(this,A)&wt)===ln}isSymbolicLink(){return (r(this,A)&fe)===fe}lstatCached(){return r(this,A)&er?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)&wt;return !(e!==vt&&e!==fe||r(this,A)&$s||r(this,A)&Ot)}calledReaddir(){return !!(r(this,A)&bi)}isENOENT(){return !!(r(this,A)&Ot)}isNamed(e){return this.nocase?r(this,ae)===Us(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,ot).promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(t);if(s)return d(this,Ht,s)}catch(t){g(this,R,_i).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,ot).readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(t);if(s)return d(this,Ht,s)}catch(t){g(this,R,_i).call(this,t.code);return}}async lstat(){if((r(this,A)&Ot)===0)try{return g(this,R,Fi).call(this,await r(this,ot).promises.lstat(this.fullpath())),this}catch(e){g(this,R,Ai).call(this,e.code);}}lstatSync(){if((r(this,A)&Ot)===0)try{return g(this,R,Fi).call(this,r(this,ot).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,ot).readdir(i,{withFileTypes:true},(n,o)=>{if(n)g(this,R,Zs).call(this,n.code),s.provisional=0;else {for(let a of o)g(this,R,Ks).call(this,a,s);g(this,R,Hs).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,Ee))await r(this,Ee);else {let s=()=>{};d(this,Ee,new Promise(i=>s=i));try{for(let i of await r(this,ot).promises.readdir(t,{withFileTypes:!0}))g(this,R,Ks).call(this,i,e);g(this,R,Hs).call(this,e);}catch(i){g(this,R,Zs).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,ot).readdirSync(t,{withFileTypes:!0}))g(this,R,Ks).call(this,s,e);g(this,R,Hs).call(this,e);}catch(s){g(this,R,Zs).call(this,s.code),e.provisional=0;}return e.slice(0,e.provisional)}canReaddir(){if(r(this,A)&sr)return false;let e=wt&r(this,A);return e===vt||e===It||e===fe}shouldWalk(e,t){return (r(this,A)&It)===It&&!(r(this,A)&sr)&&!e.has(this)&&(!t||t(this))}async realpath(){if(r(this,Wt))return r(this,Wt);if(!((Js|$s|Ot)&r(this,A)))try{let e=await r(this,ot).promises.realpath(this.fullpath());return d(this,Wt,this.resolve(e))}catch{g(this,R,Ti).call(this);}}realpathSync(){if(r(this,Wt))return r(this,Wt);if(!((Js|$s|Ot)&r(this,A)))try{let e=r(this,ot).realpathSync(this.fullpath());return d(this,Wt,this.resolve(e))}catch{g(this,R,Ti).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),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;}},ot=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,Cs=new WeakMap,Os=new WeakMap,ks=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,Mi=function(e){let t=this;for(let s of e)t=t.child(s);return t},Hs=function(e){var t;d(this,A,r(this,A)|bi);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)&Ot||(d(this,A,(r(this,A)|Ot)&Xe),g(this,R,Li).call(this));},Li=function(){var t;let e=this.children();e.provisional=0;for(let s of e)g(t=s,R,ns).call(t);},Ti=function(){d(this,A,r(this,A)|Js),g(this,R,os).call(this);},os=function(){if(r(this,A)&is)return;let e=r(this,A);(e&wt)===It&&(e&=Xe),d(this,A,e|is),g(this,R,Li).call(this);},Zs=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);},_i=function(e=""){var s;let t=r(this,A);t|=$s,e==="ENOENT"&&(t|=Ot),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Xe),d(this,A,t),e==="ENOTDIR"&&this.parent&&g(s=this.parent,R,os).call(s);},Ks=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=vi(e),i=this.newChild(e.name,s,{parent:this}),n=r(i,A)&wt;return n!==It&&n!==fe&&n!==vt&&d(i,A,r(i,A)|is),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?Us(e.name):rs(e.name))===r(i,ae))return g(this,R,dn).call(this,e,i,s,t)}},dn=function(e,t,s,i){let n=t.name;return d(t,A,r(t,A)&Xe|vi(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},Fi=function(e){let{atime:t,atimeMs:s,birthtime:i,birthtimeMs:n,blksize:o,blocks:a,ctime:l,ctimeMs:h,dev:c,gid:f,ino:p,mode:y,mtime:b,mtimeMs:S,nlink:v,rdev:E,size:w,uid:k}=e;d(this,Cs,t),d(this,vs,s),d(this,Rs,i),d(this,Es,n),d(this,ms,o),d(this,bs,a),d(this,ks,l),d(this,xs,h),d(this,cs,c),d(this,fs,f),d(this,ys,p),d(this,us,y),d(this,Os,b),d(this,Ss,S),d(this,ds,v),d(this,gs,E),d(this,ws,w),d(this,ps,k);let M=vi(e);d(this,A,r(this,A)&Xe|M|er),M!==vt&&M!==It&&M!==fe&&d(this,A,r(this,A)|is);},We=new WeakMap,ze=new WeakMap,pn=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,_r),fn=class gn extends ht{constructor(s,i=vt,n,o,a,l,h){super(s,i,n,o,a,l,h);u(this,"sep","\\");u(this,"splitSep",pa);}newChild(s,i=vt,n={}){return new gn(s,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(s){return zi.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 ji(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);u(this,"splitSep","/");u(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)}},$e,Ue,Ms,Ls,Fr,wn=(Fr=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");m(this,$e);m(this,Ue);m(this,Ms);u(this,"nocase");m(this,Ls);d(this,Ls,en(o)),(e instanceof URL||e.startsWith("file://"))&&(e=url.fileURLToPath(e));let a=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),d(this,$e,new nr),d(this,Ue,new nr),d(this,Ms,new ga(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,Ls)),this.roots[this.rootPath]=this.root;let h=this.root,c=l.length-1,f=t.sep,p=this.rootPath,y=false;for(let b of l){let S=c--;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,$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 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);},c=e;return new Promise((f,p)=>{h(c,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 c=h.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(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 c of h){(!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 ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=new Xs({objectMode:true});(!n||n(e))&&a.write(s?e:e.fullpath());let l=new Set,h=[e],c=0,f=()=>{let p=false;for(;!p;){let y=h.shift();if(!y){c===0&&a.end();return}c++,l.add(y);let b=(v,E,w=false)=>{if(v)return a.emit("error",v);if(i&&!w){let k=[];for(let M of E)M.isSymbolicLink()&&k.push(M.realpath().then(C=>C?.isUnknown()?C.lstat():C));if(k.length){Promise.all(k).then(()=>b(null,E,true));return}}for(let k of E)k&&(!n||n(k))&&(a.write(s?k:k.fullpath())||(p=true));c--;for(let k of E){let M=k.realpathCached()||k;M.shouldWalk(l,o)&&h.push(M);}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 Xs({objectMode:true}),l=new Set;(!n||n(e))&&a.write(s?e:e.fullpath());let h=[e],c=0,f=()=>{let p=false;for(;!p;){let y=h.shift();if(!y){c===0&&a.end();return}c++,l.add(y);let b=y.readdirSync();for(let S of b)(!n||n(S))&&(a.write(s?S:S.fullpath())||(p=true));c--;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);}},$e=new WeakMap,Ue=new WeakMap,Ms=new WeakMap,Ls=new WeakMap,Fr),ji=class extends wn{constructor(t=process.cwd(),s={}){let{nocase:i=true}=s;super(t,zi.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 zi.win32.parse(t).root.toUpperCase()}newRoot(t){return new fn(this.rootPath,It,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Wi=class extends wn{constructor(t=process.cwd(),s={}){let{nocase:i=false}=s;super(t,zi.posix,"/",{...s,nocase:i});u(this,"sep","/");this.nocase=i;}parseRootPath(t){return "/"}newRoot(t){return new mn(this.rootPath,It,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},bn=class extends Wi{constructor(e=process.cwd(),t={}){let{nocase:s=true}=t;super(e,{...t,nocase:s});}};process.platform==="win32"?fn:mn;var ma=process.platform==="win32"?ji:process.platform==="darwin"?bn:Wi,ya=e=>e.length>=1,wa=e=>e.length>=1,ba=Symbol.for("nodejs.util.inspect.custom"),q,ct,J,Ce,Pt,Ts,le,he,ce,Be,Ge,vn=(Ge=class{constructor(t,s,i,n){m(this,q);m(this,ct);m(this,J);u(this,"length");m(this,Ce);m(this,Pt);m(this,Ts);m(this,le);m(this,he);m(this,ce);m(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,q,t),d(this,ct,s),d(this,J,i),d(this,Ce,n),r(this,J)===0){if(this.isUNC()){let[o,a,l,h,...c]=r(this,q),[f,p,y,b,...S]=r(this,ct);c[0]===""&&(c.shift(),S.shift());let v=[o,a,l,h,""].join("/"),E=[f,p,y,b,""].join("/");d(this,q,[v,...c]),d(this,ct,[E,...S]),this.length=r(this,q).length;}else if(this.isDrive()||this.isAbsolute()){let[o,...a]=r(this,q),[l,...h]=r(this,ct);a[0]===""&&(a.shift(),h.shift());let c=o+"/",f=l+"/";d(this,q,[c,...a]),d(this,ct,[f,...h]),this.length=r(this,q).length;}}}[ba](){return "Pattern <"+r(this,ct).slice(r(this,J)).join("/")+">"}pattern(){return r(this,q)[r(this,J)]}isString(){return typeof r(this,q)[r(this,J)]=="string"}isGlobstar(){return r(this,q)[r(this,J)]===at}isRegExp(){return r(this,q)[r(this,J)]instanceof RegExp}globString(){return d(this,Ts,r(this,Ts)||(r(this,J)===0?this.isAbsolute()?r(this,ct)[0]+r(this,ct).slice(1).join("/"):r(this,ct).join("/"):r(this,ct).slice(r(this,J)).join("/")))}hasMore(){return this.length>r(this,J)+1}rest(){return r(this,Pt)!==void 0?r(this,Pt):this.hasMore()?(d(this,Pt,new Ge(r(this,q),r(this,ct),r(this,J)+1,r(this,Ce))),d(r(this,Pt),ce,r(this,ce)),d(r(this,Pt),he,r(this,he)),d(r(this,Pt),le,r(this,le)),r(this,Pt)):d(this,Pt,null)}isUNC(){let t=r(this,q);return r(this,he)!==void 0?r(this,he):d(this,he,r(this,Ce)==="win32"&&r(this,J)===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,le)!==void 0?r(this,le):d(this,le,r(this,Ce)==="win32"&&r(this,J)===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]))}isAbsolute(){let t=r(this,q);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,q)[0];return typeof t=="string"&&this.isAbsolute()&&r(this,J)===0?t:""}checkFollowGlobstar(){return !(r(this,J)===0||!this.isGlobstar()||!r(this,Be))}markFollowGlobstar(){return r(this,J)===0||!this.isGlobstar()||!r(this,Be)?false:(d(this,Be,false),true)}},q=new WeakMap,ct=new WeakMap,J=new WeakMap,Ce=new WeakMap,Pt=new WeakMap,Ts=new WeakMap,le=new WeakMap,he=new WeakMap,ce=new WeakMap,Be=new WeakMap,Ge),va=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=va}){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 vn(i,n,0,this.platform),a=new de(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}},Sa=class Sn{constructor(t=new Map){u(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()]));}},xa=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)])}},Ea=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())}},ar=class xn{constructor(t,s){u(this,"hasWalkedCache");u(this,"matches",new xa);u(this,"subwalks",new Ea);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 Sa;}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,c,f=false;for(;typeof(h=o.pattern())=="string"&&(c=o.rest());)n=n.resolve(h),o=c,f=true;if(h=o.pattern(),c=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=c?.pattern(),y=c?.rest();if(!c||(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(),c=a.rest();h===at?n.testGlobstar(o,a,c,l):h instanceof RegExp?n.testRegExp(o,h,c,l):n.testString(o,h,c,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));}},Ca=(e,t)=>typeof e=="string"?new or([e],t):Array.isArray(e)?new or(e,t):e,Ve,Zt,Oe,St,ge,Pi,Pr,En=(Pr=class{constructor(e,t,s){m(this,St);u(this,"path");u(this,"patterns");u(this,"opts");u(this,"seen",new Set);u(this,"paused",false);u(this,"aborted",false);m(this,Ve,[]);m(this,Zt);m(this,Oe);u(this,"signal");u(this,"maxDepth");u(this,"includeChildMatches");if(this.patterns=e,this.path=t,this.opts=s,d(this,Oe,!s.posix&&s.platform==="win32"?"\\":"/"),this.includeChildMatches=s.includeChildMatches!==false,(s.ignore||!this.includeChildMatches)&&(d(this,Zt,Ca(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,St,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,St,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,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,Pi).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,ge).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,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,l,h]of s.matches.entries())g(this,St,ge).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,Pi).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,ge).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,ge).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();}},Ve=new WeakMap,Zt=new WeakMap,Oe=new WeakMap,St=new WeakSet,ge=function(e){return this.seen.has(e)||!!r(this,Zt)?.ignored?.(e)},Pi=function(e){return !!r(this,Zt)?.childrenIgnored?.(e)},Pr),lr=class extends En{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}},hr=class extends En{constructor(t,s,i){super(t,s,i);u(this,"results");this.results=new Xs({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}},Oa=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=url.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||Oa,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"?ji:t.platform==="darwin"?bn:t.platform?Wi:ma;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={braceExpandMax:1e4,...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 de(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 c=a[h];if(!c)throw new Error("invalid pattern object");return new vn(l,c,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()}},ka=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let s of e)if(new de(s,t).hasMagic())return true;return false};function si(e,t={}){return new Re(e,t).streamSync()}function Cn(e,t={}){return new Re(e,t).stream()}function On(e,t={}){return new Re(e,t).walkSync()}async function cr(e,t={}){return new Re(e,t).walk()}function ii(e,t={}){return new Re(e,t).iterateSync()}function kn(e,t={}){return new Re(e,t).iterate()}var Ra=si,Ma=Object.assign(Cn,{sync:si}),La=ii,Ta=Object.assign(kn,{sync:ii}),Aa=Object.assign(On,{stream:si,iterate:ii}),ti=Object.assign(cr,{glob:cr,globSync:On,sync:Aa,globStream:Cn,stream:Ma,globStreamSync:si,streamSync:Ra,globIterate:kn,iterate:Ta,globIterateSync:ii,iterateSync:La,Glob:Re,hasMagic:ka,escape:Gr,unescape:_e});ti.glob=ti;var Kt;(C=>{C.Level=Fa__default.default.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(O){return t[O]>=t[s]}function n(){return s}C.getLevel=n;let o=new Map;C.Default=M({service:"default"});let l="";function h(){return l}C.file=h;let c,f,p=false,y=()=>{},b=false;async function S(O){if(p)return;if(O.print){p=true;return}O.level&&(s=O.level);let T=O.logDir||zi__default.default.join(process.cwd(),"logs");O.logFile?l=zi__default.default.join(T,O.logFile??"ollama-sdk.log"):l=zi__default.default.join(T,"ollama-sdk.log");try{c=await Rn__default.default.open(l,"a"),f=Zo.createWriteStream("",{fd:c.fd,autoClose:!1}),y=F=>{if(!(b||!f||f.destroyed))try{if(!f.writable)return;f.write(F,D=>{D&&!b&&(b=!0,setTimeout(()=>{b=!1;},1e3));});}catch{b||(b=!0,setTimeout(()=>{b=!1;},1e3));}},p=!0;}catch{y=F=>{try{process.stderr.write(F);}catch{}},p=true;}}C.init=S;async function v(){p&&(f&&!f.destroyed&&(await new Promise((O,T)=>{f.end(F=>{F?T(F):O();});}).catch(()=>{}),f=void 0),c&&(await c.close().catch(()=>{}),c=void 0),y=O=>{try{process.stderr.write(O);}catch{}},p=false);}C.close=v;function w(O,T=0){let F=O.message;return O.cause instanceof Error&&T<10?F+" Caused by: "+w(O.cause,T+1):F}let k=Date.now();function M(O){O=O||{};let T=O.service;if(T&&typeof T=="string"){let L=o.get(T);if(L)return L}function F(L,P){let W=Object.entries({...O,...P}).filter(([$i,Yt])=>Yt!=null).map(([$i,Yt])=>{let ai=`${$i}=`;return Yt instanceof Error?ai+w(Yt):typeof Yt=="object"?ai+JSON.stringify(Yt):ai+Yt}).join(" "),z=new Date,_s=z.getTime()-k;return k=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"),"+"+_s+"ms",W,L].filter(Boolean).join(" ")+`
5
+ `}let D={debug(L,P){i("DEBUG")&&y("DEBUG "+F(L,P));},info(L,P){i("INFO")&&y("INFO "+F(L,P));},error(L,P){i("ERROR")&&y("ERROR "+F(L,P));},warn(L,P){i("WARN")&&y("WARN "+F(L,P));},tag(L,P){return O&&(O[L]=P),D},clone(){return C.create({...O})},time(L,P){let W=Date.now();D.info(L,{status:"started",...P});function z(){D.info(L,{status:"completed",duration:Date.now()-W,...P});}return {stop:z,[Symbol.dispose](){z();}}}};return T&&typeof T=="string"&&o.set(T,D),D}C.create=M;})(Kt||(Kt={}));function Mn(e,t,s){let i;return t?i="tool-calls":e?i="stop":i="other",{unified:i,raw:s}}var xt=Kt.create({service:"ollama-sdk",module:"native-language-model"});function ri(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function ni(e){if(!e||e.trim().length===0)return false;try{return JSON.parse(e),!0}catch{return false}}function Ln(e){return typeof e=="string"?e:JSON.stringify(e)}function Tn(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){xt.warn("Failed to convert message",{messageRole:s.role,error:i instanceof Error?i.message:String(i)});}return t}var oi=class{constructor(t,s={}){u(this,"specificationVersion","v3");u(this,"provider","ollama");u(this,"modelId");u(this,"defaultObjectGenerationMode","json");u(this,"supportedUrls",{});u(this,"client");this.modelId=t,this.client=new Ps(s.baseURL);}async generate(t){return this.doGenerate(t)}async stream(t){return this.doStream(t)}async doStream(t){let s=ri();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=Tn({tools:t.tools}),o=JSON.stringify({model:this.modelId,messages:i,options:Le,...n}),a=null,l=null,h=b=>{a&&a.enqueue(b),l&&l.enqueue(b);},c=async()=>{try{let b=!0,S=!1,v=!1,E="",w="",k=!1,M=[],C=[],O=()=>{if(C.length>0){for(let F of C)h(F);C.length=0;}},T=null;for await(let F of this.client.streamChat({model:this.modelId,messages:i,options:Le,...n})){if(T&&T.chunkCount++,b){b=!1;let D={type:"response-metadata",id:ri(),modelId:this.modelId,timestamp:new Date(F.created_at)};h(D),T&&T.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 qe=D.id?"function.name":"id";xt.error("Invalid tool call: missing field",{traceId:s,missingField:qe,toolCall:void 0}),C.push({type:"error",error:`Invalid tool call: missing ${qe}`});continue}let L=D.id,P=D.function.name,W=Ln(D.function.arguments),z=M.find(qe=>qe.id===L);z?(z.function.arguments+=W,xt.debug("Tool call arguments accumulated",{traceId:s,toolCallId:L,toolName:P,deltaLength:W.length,totalLength:z.function.arguments.length,isComplete:ni(z.function.arguments)}),W&&C.push({type:"tool-input-delta",id:L,delta:W})):(z={id:L,type:"function",function:{name:P,arguments:W},hasFinished:!1},M.push(z),T&&T.toolCallCount++,xt.debug("Tool call received",{traceId:s,toolCallId:L,toolName:P,argumentsLength:W.length,isComplete:ni(W)}),C.push({type:"tool-input-start",id:L,toolName:P}),W&&C.push({type:"tool-input-delta",id:L,delta:W}));let _s=ni(z.function.arguments);!z.hasFinished&&_s&&(xt.debug("Tool call arguments complete",{traceId:s,toolCallId:L,toolName:P,isComplete:_s,argumentsLength:z.function.arguments.length}),C.push({type:"tool-input-end",id:L}),C.push({type:"tool-call",toolCallId:L,toolName:P,input:z.function.arguments}),z.hasFinished=!0);}O(),T&&(T.eventCount+=C.length);}if(F.message?.content){let D=F.message.content;for(w+=D;w.length>0;)if(k){let L=w.indexOf("</think>");if(L===-1){w.length>0&&C.push({type:"reasoning-delta",id:"reasoning-0",delta:w}),w="";break}else {if(L>0){let P=w.substring(0,L);C.push({type:"reasoning-delta",id:"reasoning-0",delta:P});}C.push({type:"reasoning-end",id:"reasoning-0"}),v=!1,k=!1,w=w.substring(L+8);}}else {let L=w.indexOf("<think>");if(L===-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(L>0){let P=w.substring(0,L);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;}k=!0,w=w.substring(L+7),v||(v=!0,C.push({type:"reasoning-start",id:"reasoning-0"}));}}}if(O(),T&&(T.eventCount+=C.length),F.done){let D=M.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&&(k?(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=M.length>0?"tool-calls":"stop";if(C.push({type:"finish",finishReason:P,usage:{inputTokens:{total:F.prompt_eval_count||0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:F.eval_count||0,text:void 0,reasoning:void 0}},providerMetadata:{ollama:{totalDuration:F.total_duration||0,loadDuration:F.load_duration||0,promptEvalDuration:F.prompt_eval_duration||0,evalDuration:F.eval_duration||0}}}),O(),T&&(T.eventCount+=C.length),T);M.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:{total:0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:0,text:void 0,reasoning:void 0}}});}finally{a&&a.close(),l&&l.close();}},f=new ReadableStream({start(b){a=b;}}),p=new ReadableStream({start(b){l=b;}});c();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=ri();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=Tn({tools:t.tools}),o=await this.client.chat({model:this.modelId,messages:i,options:Le,...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 c of o.message.tool_calls){let f=c.id||ri(),p=c.function.name,y=Ln(c.function.arguments);xt.debug("Processing tool call in generate",{traceId:s,toolCallId:f,toolName:p,argumentsLength:y.length,isComplete:ni(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=Mn(o.done??false,l,"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:{total:o.prompt_eval_count||0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:o.eval_count||0,text:void 0,reasoning:void 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:Le,...n})},response:{}}}};var Me=class{constructor(t,s={}){u(this,"specificationVersion","v3");u(this,"provider","ollama");u(this,"modelId");u(this,"defaultObjectGenerationMode","json");u(this,"supportedUrls",{});u(this,"nativeModel");this.modelId=t,this.nativeModel=new oi(t,{baseURL:s.baseURL||"http://localhost:11434"});}doGenerate(t){return this.nativeModel.doGenerate(t)}doStream(t){return this.nativeModel.doStream(t)}async generate(t){return this.nativeModel.generate(t)}async stream(t){return this.nativeModel.stream(t)}};var As=class{constructor(t,s={}){u(this,"specificationVersion","v3");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}=t,n=Kt.create({service:"ollama-embedding"});if(!s||s.length===0)return n.warn("Empty values array provided",{modelId:this.modelId}),{embeddings:[],usage:{tokens:0},warnings:[]};n.debug("Generating text embeddings",{modelId:this.modelId,valuesCount:s.length,baseURL:this.baseURL});try{let o=await Promise.all(s.map(l=>this.generateSingleEmbedding(l,i))),a=s.reduce((l,h)=>l+this.estimateTokens(h),0);return n.debug("Text embeddings generated successfully",{modelId:this.modelId,embeddingsCount:o.length,totalTokens:a}),{embeddings:o,usage:{tokens:a},warnings:[]}}catch(o){throw n.error("Text embedding generation failed",{modelId:this.modelId,error:o instanceof Error?o.message:String(o),stack:void 0}),o}}async generateSingleEmbedding(t,s){let i=`${this.baseURL}/api/embeddings`;try{let n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:this.modelId,prompt:t}),signal:s});if(!n.ok){let a=await n.text();throw new Error(`Ollama embedding API error (${n.status}): ${a}`)}let o=await n.json();if(!o.embedding||!Array.isArray(o.embedding))throw new Error("Invalid response format from Ollama embedding API");return o.embedding}catch(n){throw n instanceof TypeError&&n.message.includes("fetch")?new Error(`Failed to connect to Ollama server at ${this.baseURL}: ${n.message}`):n}}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 Da(e={}){if(e.logDir){let s=e.logLevel??"INFO",i=zi__default.default.join(e.logDir,"ollama-sdk.log");Kt.init({print:process.argv.includes("--print-logs"),logDir:e.logDir,level:s,logFile:"ollama-sdk.log"}).then(()=>{Kt.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 As(s,e)})}var Ia="0.1.0";
7
+ exports.ConnectionError=hi;exports.ModelNotFoundError=ci;exports.OLLAMA_DEFAULT_OPTIONS=Le;exports.OLLAMA_SPECIFIC_PARAMS=Pn;exports.OllamaEmbeddingModel=As;exports.OllamaError=Qt;exports.OllamaLanguageModel=Me;exports.TimeoutError=di;exports.VERSION=Ia;exports.ValidationError=ui;exports.createOllama=Da;