UNPKG

directus-extension-schema-sync

Version:

Sync schema and data betwreen Directus instances

1 lines 99.3 kB
import{useBus as t}from"@directus/api/bus/index";import e,{readdir as s,readFile as i,writeFile as r,access as n,mkdir as o,rm as a}from"fs/promises";import h,{resolve as l}from"path";import{fileURLToPath as c,pathToFileURL as d}from"url";import{fileURLToPath as p}from"node:url";import{win32 as u,posix as f}from"node:path";import{realpathSync as g,readlinkSync as m,readdirSync as w,readdir as y,lstatSync as b}from"fs";import*as v from"node:fs";import{realpath as S,readlink as x,readdir as k,lstat as E}from"node:fs/promises";import{EventEmitter as C}from"node:events";import A from"node:stream";import{StringDecoder as F}from"node:string_decoder";import{createHash as T}from"crypto";function L(t){let e=!1,s=!1;return new Proxy(t,{async apply(t,i,r){if(e)s=!0;else do{e=!0,s=!1;try{return await Reflect.apply(t,i,r)}catch(t){console.error("Error in condensed action:",t)}finally{e=!1}}while(s)}})}function _(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var M,O,D,N;var P=function(){if(N)return D;N=1;var t=function(){if(O)return M;function t(t,i,r){t instanceof RegExp&&(t=e(t,r)),i instanceof RegExp&&(i=e(i,r));var n=s(t,i,r);return n&&{start:n[0],end:n[1],pre:r.slice(0,n[0]),body:r.slice(n[0]+t.length,n[1]),post:r.slice(n[1]+i.length)}}function e(t,e){var s=e.match(t);return s?s[0]:null}function s(t,e,s){var i,r,n,o,a,h=s.indexOf(t),l=s.indexOf(e,h+1),c=h;if(h>=0&&l>0){if(t===e)return[h,l];for(i=[],n=s.length;c>=0&&!a;)c==h?(i.push(c),h=s.indexOf(t,c+1)):1==i.length?a=[i.pop(),l]:((r=i.pop())<n&&(n=r,o=l),l=s.indexOf(e,c+1)),c=h<l&&h>=0?h:l;i.length&&(a=[n,o])}return a}return O=1,M=t,t.range=s,M}();D=function(t){if(!t)return[];"{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2));return u(function(t){return t.split("\\\\").join(e).split("\\{").join(s).split("\\}").join(i).split("\\,").join(r).split("\\.").join(n)}(t),!0).map(a)};var e="\0SLASH"+Math.random()+"\0",s="\0OPEN"+Math.random()+"\0",i="\0CLOSE"+Math.random()+"\0",r="\0COMMA"+Math.random()+"\0",n="\0PERIOD"+Math.random()+"\0";function o(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function a(t){return t.split(e).join("\\").split(s).join("{").split(i).join("}").split(r).join(",").split(n).join(".")}function h(e){if(!e)return[""];var s=[],i=t("{","}",e);if(!i)return e.split(",");var r=i.pre,n=i.body,o=i.post,a=r.split(",");a[a.length-1]+="{"+n+"}";var l=h(o);return o.length&&(a[a.length-1]+=l.shift(),a.push.apply(a,l)),s.push.apply(s,a),s}function l(t){return"{"+t+"}"}function c(t){return/^-?0\d/.test(t)}function d(t,e){return t<=e}function p(t,e){return t>=e}function u(e,s){var r=[],n=t("{","}",e);if(!n)return[e];var a=n.pre,f=n.post.length?u(n.post,!1):[""];if(/\$$/.test(n.pre))for(var g=0;g<f.length;g++){var m=a+"{"+n.body+"}"+f[g];r.push(m)}else{var w,y,b=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),v=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),S=b||v,x=n.body.indexOf(",")>=0;if(!S&&!x)return n.post.match(/,(?!,).*\}/)?u(e=n.pre+"{"+n.body+i+n.post):[e];if(S)w=n.body.split(/\.\./);else if(1===(w=h(n.body)).length&&1===(w=u(w[0],!1).map(l)).length)return f.map(function(t){return n.pre+w[0]+t});if(S){var k=o(w[0]),E=o(w[1]),C=Math.max(w[0].length,w[1].length),A=3==w.length?Math.abs(o(w[2])):1,F=d;E<k&&(A*=-1,F=p);var T=w.some(c);y=[];for(var L=k;F(L,E);L+=A){var _;if(v)"\\"===(_=String.fromCharCode(L))&&(_="");else if(_=String(L),T){var M=C-_.length;if(M>0){var O=new Array(M+1).join("0");_=L<0?"-"+O+_.slice(1):O+_}}y.push(_)}}else{y=[];for(var D=0;D<w.length;D++)y.push.apply(y,u(w[D],!1))}for(D=0;D<y.length;D++)for(g=0;g<f.length;g++){m=a+y[D]+f[g];(!s||S||m)&&r.push(m)}}return r}return D}(),R=_(P);const z=t=>{if("string"!=typeof t)throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")},j={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},I=t=>t.replace(/[[\]\\-]/g,"\\$&"),$=t=>t.join(""),B=(t,e)=>{const s=e;if("["!==t.charAt(s))throw new Error("not in a brace expression");const i=[],r=[];let n=s+1,o=!1,a=!1,h=!1,l=!1,c=s,d="";t:for(;n<t.length;){const e=t.charAt(n);if("!"!==e&&"^"!==e||n!==s+1){if("]"===e&&o&&!h){c=n+1;break}if(o=!0,"\\"!==e||h){if("["===e&&!h)for(const[e,[o,h,l]]of Object.entries(j))if(t.startsWith(e,n)){if(d)return["$.",!1,t.length-s,!0];n+=e.length,l?r.push(o):i.push(o),a=a||h;continue t}h=!1,d?(e>d?i.push(I(d)+"-"+I(e)):e===d&&i.push(I(e)),d="",n++):t.startsWith("-]",n+1)?(i.push(I(e+"-")),n+=2):t.startsWith("-",n+1)?(d=e,n+=2):(i.push(I(e)),n++)}else h=!0,n++}else l=!0,n++}if(c<n)return["",!1,0,!1];if(!i.length&&!r.length)return["$.",!1,t.length-s,!0];if(0===r.length&&1===i.length&&/^\\?.$/.test(i[0])&&!l){const t=2===i[0].length?i[0].slice(-1):i[0];return[(p=t,p.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")),!1,c-s,!1]}var p;const u="["+(l?"^":"")+$(i)+"]",f="["+(l?"":"^")+$(r)+"]";return[i.length&&r.length?"("+u+"|"+f+")":i.length?u:f,a,c-s,!0]},W=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),U=new Set(["!","?","+","*","@"]),G=t=>U.has(t),H="(?!\\.)",q=new Set(["[","."]),Y=new Set(["..","."]),J=new Set("().*{}+?[]^$\\!"),K=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),V="[^/]",Z=V+"*?",Q=V+"+?";class X{type;#t;#e;#s=!1;#i=[];#r;#n;#o;#a=!1;#h;#l;#c=!1;constructor(t,e,s={}){this.type=t,t&&(this.#e=!0),this.#r=e,this.#t=this.#r?this.#r.#t:this,this.#h=this.#t===this?s:this.#t.#h,this.#o=this.#t===this?[]:this.#t.#o,"!"!==t||this.#t.#a||this.#o.push(this),this.#n=this.#r?this.#r.#i.length:0}get hasMagic(){if(void 0!==this.#e)return this.#e;for(const t of this.#i)if("string"!=typeof t&&(t.type||t.hasMagic))return this.#e=!0;return this.#e}toString(){return void 0!==this.#l?this.#l:this.type?this.#l=this.type+"("+this.#i.map(t=>String(t)).join("|")+")":this.#l=this.#i.map(t=>String(t)).join("")}#d(){if(this!==this.#t)throw new Error("should only call on root");if(this.#a)return this;let t;for(this.toString(),this.#a=!0;t=this.#o.pop();){if("!"!==t.type)continue;let e=t,s=e.#r;for(;s;){for(let i=e.#n+1;!s.type&&i<s.#i.length;i++)for(const e of t.#i){if("string"==typeof e)throw new Error("string part in extglob AST??");e.copyIn(s.#i[i])}e=s,s=e.#r}}return this}push(...t){for(const e of t)if(""!==e){if("string"!=typeof e&&!(e instanceof X&&e.#r===this))throw new Error("invalid part: "+e);this.#i.push(e)}}toJSON(){const t=null===this.type?this.#i.slice().map(t=>"string"==typeof t?t:t.toJSON()):[this.type,...this.#i.map(t=>t.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#a&&"!"===this.#r?.type)&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#r?.isStart())return!1;if(0===this.#n)return!0;const t=this.#r;for(let e=0;e<this.#n;e++){const s=t.#i[e];if(!(s instanceof X&&"!"===s.type))return!1}return!0}isEnd(){if(this.#t===this)return!0;if("!"===this.#r?.type)return!0;if(!this.#r?.isEnd())return!1;if(!this.type)return this.#r?.isEnd();const t=this.#r?this.#r.#i.length:0;return this.#n===t-1}copyIn(t){"string"==typeof t?this.push(t):this.push(t.clone(this))}clone(t){const e=new X(this.type,t);for(const t of this.#i)e.copyIn(t);return e}static#p(t,e,s,i){let r=!1,n=!1,o=-1,a=!1;if(null===e.type){let h=s,l="";for(;h<t.length;){const s=t.charAt(h++);if(r||"\\"===s)r=!r,l+=s;else if(n)h===o+1?"^"!==s&&"!"!==s||(a=!0):"]"!==s||h===o+2&&a||(n=!1),l+=s;else if("["!==s){if(!i.noext&&G(s)&&"("===t.charAt(h)){e.push(l),l="";const r=new X(s,e);h=X.#p(t,r,h,i),e.push(r);continue}l+=s}else n=!0,o=h,a=!1,l+=s}return e.push(l),h}let h=s+1,l=new X(null,e);const c=[];let d="";for(;h<t.length;){const s=t.charAt(h++);if(r||"\\"===s)r=!r,d+=s;else if(n)h===o+1?"^"!==s&&"!"!==s||(a=!0):"]"!==s||h===o+2&&a||(n=!1),d+=s;else if("["!==s){if(G(s)&&"("===t.charAt(h)){l.push(d),d="";const e=new X(s,l);l.push(e),h=X.#p(t,e,h,i);continue}if("|"!==s){if(")"===s)return""===d&&0===e.#i.length&&(e.#c=!0),l.push(d),d="",e.push(...c,l),h;d+=s}else l.push(d),d="",c.push(l),l=new X(null,e)}else n=!0,o=h,a=!1,d+=s}return e.type=null,e.#e=void 0,e.#i=[t.substring(s-1)],h}static fromGlob(t,e={}){const s=new X(null,void 0,e);return X.#p(t,s,0,e),s}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();const t=this.toString(),[e,s,i,r]=this.toRegExpSource();if(!(i||this.#e||this.#h.nocase&&!this.#h.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;const n=(this.#h.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${e}$`,n),{_src:e,_glob:t})}get options(){return this.#h}toRegExpSource(t){const e=t??!!this.#h.dot;if(this.#t===this&&this.#d(),!this.type){const s=this.isStart()&&this.isEnd(),i=this.#i.map(e=>{const[i,r,n,o]="string"==typeof e?X.#u(e,this.#e,s):e.toRegExpSource(t);return this.#e=this.#e||n,this.#s=this.#s||o,i}).join("");let r="";if(this.isStart()&&"string"==typeof this.#i[0]){if(!(1===this.#i.length&&Y.has(this.#i[0]))){const s=q,n=e&&s.has(i.charAt(0))||i.startsWith("\\.")&&s.has(i.charAt(2))||i.startsWith("\\.\\.")&&s.has(i.charAt(4)),o=!e&&!t&&s.has(i.charAt(0));r=n?"(?!(?:^|/)\\.\\.?(?:$|/))":o?H:""}}let n="";this.isEnd()&&this.#t.#a&&"!"===this.#r?.type&&(n="(?:$|\\/)");return[r+i+n,W(i),this.#e=!!this.#e,this.#s]}const s="*"===this.type||"+"===this.type,i="!"===this.type?"(?:(?!(?:":"(?:";let r=this.#f(e);if(this.isStart()&&this.isEnd()&&!r&&"!"!==this.type){const t=this.toString();return this.#i=[t],this.type=null,this.#e=void 0,[t,W(this.toString()),!1,!1]}let n=!s||t||e?"":this.#f(!0);n===r&&(n=""),n&&(r=`(?:${r})(?:${n})*?`);let o="";if("!"===this.type&&this.#c)o=(this.isStart()&&!e?H:"")+Q;else{o=i+r+("!"===this.type?"))"+(!this.isStart()||e||t?"":H)+Z+")":"@"===this.type?")":"?"===this.type?")?":"+"===this.type&&n?")":"*"===this.type&&n?")?":`)${this.type}`)}return[o,W(r),this.#e=!!this.#e,this.#s]}#f(t){return this.#i.map(e=>{if("string"==typeof e)throw new Error("string type in extglob ast??");const[s,i,r,n]=e.toRegExpSource(t);return this.#s=this.#s||n,s}).filter(t=>!(this.isStart()&&this.isEnd()&&!t)).join("|")}static#u(t,e,s=!1){let i=!1,r="",n=!1;for(let o=0;o<t.length;o++){const a=t.charAt(o);if(i)i=!1,r+=(J.has(a)?"\\":"")+a;else if("\\"!==a){if("["===a){const[s,i,a,h]=B(t,o);if(a){r+=s,n=n||i,o+=a-1,e=e||h;continue}}"*"!==a?"?"!==a?r+=K(a):(r+=V,e=!0):(r+=s&&"*"===t?Q:Z,e=!0)}else o===t.length-1?r+="\\\\":i=!0}return[r,W(t),!!e,n]}}const tt=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&"),et=(t,e,s={})=>(z(e),!(!s.nocomment&&"#"===e.charAt(0))&&new Ft(e,s).match(t)),st=/^\*+([^+@!?\*\[\(]*)$/,it=t=>e=>!e.startsWith(".")&&e.endsWith(t),rt=t=>e=>e.endsWith(t),nt=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),ot=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),at=/^\*+\.\*+$/,ht=t=>!t.startsWith(".")&&t.includes("."),lt=t=>"."!==t&&".."!==t&&t.includes("."),ct=/^\.\*+$/,dt=t=>"."!==t&&".."!==t&&t.startsWith("."),pt=/^\*+$/,ut=t=>0!==t.length&&!t.startsWith("."),ft=t=>0!==t.length&&"."!==t&&".."!==t,gt=/^\?+([^+@!?\*\[\(]*)?$/,mt=([t,e=""])=>{const s=vt([t]);return e?(e=e.toLowerCase(),t=>s(t)&&t.toLowerCase().endsWith(e)):s},wt=([t,e=""])=>{const s=St([t]);return e?(e=e.toLowerCase(),t=>s(t)&&t.toLowerCase().endsWith(e)):s},yt=([t,e=""])=>{const s=St([t]);return e?t=>s(t)&&t.endsWith(e):s},bt=([t,e=""])=>{const s=vt([t]);return e?t=>s(t)&&t.endsWith(e):s},vt=([t])=>{const e=t.length;return t=>t.length===e&&!t.startsWith(".")},St=([t])=>{const e=t.length;return t=>t.length===e&&"."!==t&&".."!==t},xt="object"==typeof process&&process?"object"==typeof process.env&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix";et.sep="win32"===xt?{sep:"\\"}.sep:{sep:"/"}.sep;const kt=Symbol("globstar **");et.GLOBSTAR=kt;et.filter=(t,e={})=>s=>et(s,t,e);const Et=(t,e={})=>Object.assign({},t,e);et.defaults=t=>{if(!t||"object"!=typeof t||!Object.keys(t).length)return et;const e=et;return Object.assign((s,i,r={})=>e(s,i,Et(t,r)),{Minimatch:class extends e.Minimatch{constructor(e,s={}){super(e,Et(t,s))}static defaults(s){return e.defaults(Et(t,s)).Minimatch}},AST:class extends e.AST{constructor(e,s,i={}){super(e,s,Et(t,i))}static fromGlob(s,i={}){return e.AST.fromGlob(s,Et(t,i))}},unescape:(s,i={})=>e.unescape(s,Et(t,i)),escape:(s,i={})=>e.escape(s,Et(t,i)),filter:(s,i={})=>e.filter(s,Et(t,i)),defaults:s=>e.defaults(Et(t,s)),makeRe:(s,i={})=>e.makeRe(s,Et(t,i)),braceExpand:(s,i={})=>e.braceExpand(s,Et(t,i)),match:(s,i,r={})=>e.match(s,i,Et(t,r)),sep:e.sep,GLOBSTAR:kt})};const Ct=(t,e={})=>(z(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:R(t));et.braceExpand=Ct;et.makeRe=(t,e={})=>new Ft(t,e).makeRe();et.match=(t,e,s={})=>{const i=new Ft(e,s);return t=t.filter(t=>i.match(t)),i.options.nonull&&!t.length&&t.push(e),t};const At=/[?*]|[+@!]\(.*?\)|\[|\]/;class Ft{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){z(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||xt,this.isWindows="win32"===this.platform,this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||!1===e.allowWindowsEscape,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=void 0!==e.windowsNoMagicRoot?e.windowsNoMagicRoot:!(!this.isWindows||!this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(const t of this.set)for(const e of t)if("string"!=typeof e)return!0;return!1}debug(...t){}make(){const t=this.pattern,e=this.options;if(!e.nocomment&&"#"===t.charAt(0))return void(this.comment=!0);if(!t)return void(this.empty=!0);this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...t)=>console.error(...t)),this.debug(this.pattern,this.globSet);const s=this.globSet.map(t=>this.slashSplit(t));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((t,e,s)=>{if(this.isWindows&&this.windowsNoMagicRoot){const e=!(""!==t[0]||""!==t[1]||"?"!==t[2]&&At.test(t[2])||At.test(t[3])),s=/^[a-z]:/i.test(t[0]);if(e)return[...t.slice(0,4),...t.slice(4).map(t=>this.parse(t))];if(s)return[t[0],...t.slice(1).map(t=>this.parse(t))]}return t.map(t=>this.parse(t))});if(this.debug(this.pattern,i),this.set=i.filter(t=>-1===t.indexOf(!1)),this.isWindows)for(let t=0;t<this.set.length;t++){const e=this.set[t];""===e[0]&&""===e[1]&&"?"===this.globParts[t][2]&&"string"==typeof e[3]&&/^[a-z]:$/i.test(e[3])&&(e[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let e=0;e<t.length;e++)for(let s=0;s<t[e].length;s++)"**"===t[e][s]&&(t[e][s]="*");const{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):t=e>=1?this.levelOneOptimize(t):this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(t=>{let e=-1;for(;-1!==(e=t.indexOf("**",e+1));){let s=e;for(;"**"===t[s+1];)s++;s!==e&&t.splice(e,s-e)}return t})}levelOneOptimize(t){return t.map(t=>0===(t=t.reduce((t,e)=>{const s=t[t.length-1];return"**"===e&&"**"===s?t:".."===e&&s&&".."!==s&&"."!==s&&"**"!==s?(t.pop(),t):(t.push(e),t)},[])).length?[""]:t)}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let s=1;s<t.length-1;s++){const i=t[s];1===s&&""===i&&""===t[0]||("."!==i&&""!==i||(e=!0,t.splice(s,1),s--))}"."!==t[0]||2!==t.length||"."!==t[1]&&""!==t[1]||(e=!0,t.pop())}let s=0;for(;-1!==(s=t.indexOf("..",s+1));){const i=t[s-1];i&&"."!==i&&".."!==i&&"**"!==i&&(e=!0,t.splice(s-1,2),s-=2)}}while(e);return 0===t.length?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let s of t){let i=-1;for(;-1!==(i=s.indexOf("**",i+1));){let r=i;for(;"**"===s[r+1];)r++;r>i&&s.splice(i+1,r-i);let n=s[i+1];const o=s[i+2],a=s[i+3];if(".."!==n)continue;if(!o||"."===o||".."===o||!a||"."===a||".."===a)continue;e=!0,s.splice(i,1);const h=s.slice(0);h[i]="**",t.push(h),i--}if(!this.preserveMultipleSlashes){for(let t=1;t<s.length-1;t++){const i=s[t];1===t&&""===i&&""===s[0]||("."!==i&&""!==i||(e=!0,s.splice(t,1),t--))}"."!==s[0]||2!==s.length||"."!==s[1]&&""!==s[1]||(e=!0,s.pop())}let r=0;for(;-1!==(r=s.indexOf("..",r+1));){const t=s[r-1];if(t&&"."!==t&&".."!==t&&"**"!==t){e=!0;const t=1===r&&"**"===s[r+1]?["."]:[];s.splice(r-1,2,...t),0===s.length&&s.push(""),r-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let s=e+1;s<t.length;s++){const i=this.partsMatch(t[e],t[s],!this.preserveMultipleSlashes);if(i){t[e]=[],t[s]=i;break}}return t.filter(t=>t.length)}partsMatch(t,e,s=!1){let i=0,r=0,n=[],o="";for(;i<t.length&&r<e.length;)if(t[i]===e[r])n.push("b"===o?e[r]:t[i]),i++,r++;else if(s&&"**"===t[i]&&e[r]===t[i+1])n.push(t[i]),i++;else if(s&&"**"===e[r]&&t[i]===e[r+1])n.push(e[r]),r++;else if("*"!==t[i]||!e[r]||!this.options.dot&&e[r].startsWith(".")||"**"===e[r]){if("*"!==e[r]||!t[i]||!this.options.dot&&t[i].startsWith(".")||"**"===t[i])return!1;if("a"===o)return!1;o="b",n.push(e[r]),i++,r++}else{if("b"===o)return!1;o="a",n.push(t[i]),i++,r++}return t.length===e.length&&n}parseNegate(){if(this.nonegate)return;const t=this.pattern;let e=!1,s=0;for(let i=0;i<t.length&&"!"===t.charAt(i);i++)e=!e,s++;s&&(this.pattern=t.slice(s)),this.negate=e}matchOne(t,e,s=!1){const i=this.options;if(this.isWindows){const s="string"==typeof t[0]&&/^[a-z]:$/i.test(t[0]),i=!s&&""===t[0]&&""===t[1]&&"?"===t[2]&&/^[a-z]:$/i.test(t[3]),r="string"==typeof e[0]&&/^[a-z]:$/i.test(e[0]),n=i?3:s?0:void 0,o=!r&&""===e[0]&&""===e[1]&&"?"===e[2]&&"string"==typeof e[3]&&/^[a-z]:$/i.test(e[3])?3:r?0:void 0;if("number"==typeof n&&"number"==typeof o){const[s,i]=[t[n],e[o]];s.toLowerCase()===i.toLowerCase()&&(e[o]=s,o>n?e=e.slice(o):n>o&&(t=t.slice(n)))}}const{optimizationLevel:r=1}=this.options;r>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var n=0,o=0,a=t.length,h=e.length;n<a&&o<h;n++,o++){this.debug("matchOne loop");var l=e[o],c=t[n];if(this.debug(e,l,c),!1===l)return!1;if(l===kt){this.debug("GLOBSTAR",[e,l,c]);var d=n,p=o+1;if(p===h){for(this.debug("** at the end");n<a;n++)if("."===t[n]||".."===t[n]||!i.dot&&"."===t[n].charAt(0))return!1;return!0}for(;d<a;){var u=t[d];if(this.debug("\nglobstar while",t,d,e,p,u),this.matchOne(t.slice(d),e.slice(p),s))return this.debug("globstar found match!",d,a,u),!0;if("."===u||".."===u||!i.dot&&"."===u.charAt(0)){this.debug("dot detected!",t,d,e,p);break}this.debug("globstar swallow a segment, and continue"),d++}return!(!s||(this.debug("\n>>> no match, partial?",t,d,e,p),d!==a))}let r;if("string"==typeof l?(r=c===l,this.debug("string match",l,c,r)):(r=l.test(c),this.debug("pattern match",l,c,r)),!r)return!1}if(n===a&&o===h)return!0;if(n===a)return s;if(o===h)return n===a-1&&""===t[n];throw new Error("wtf?")}braceExpand(){return Ct(this.pattern,this.options)}parse(t){z(t);const e=this.options;if("**"===t)return kt;if(""===t)return"";let s,i=null;(s=t.match(pt))?i=e.dot?ft:ut:(s=t.match(st))?i=(e.nocase?e.dot?ot:nt:e.dot?rt:it)(s[1]):(s=t.match(gt))?i=(e.nocase?e.dot?wt:mt:e.dot?yt:bt)(s):(s=t.match(at))?i=e.dot?lt:ht:(s=t.match(ct))&&(i=dt);const r=X.fromGlob(t,this.options).toMMPattern();return i&&"object"==typeof r&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||!1===this.regexp)return this.regexp;const t=this.set;if(!t.length)return this.regexp=!1,this.regexp;const e=this.options,s=e.noglobstar?"[^/]*?":e.dot?"(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?":"(?:(?!(?:\\/|^)\\.).)*?",i=new Set(e.nocase?["i"]:[]);let r=t.map(t=>{const e=t.map(t=>{if(t instanceof RegExp)for(const e of t.flags.split(""))i.add(e);return"string"==typeof t?t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):t===kt?kt:t._src});return e.forEach((t,i)=>{const r=e[i+1],n=e[i-1];t===kt&&n!==kt&&(void 0===n?void 0!==r&&r!==kt?e[i+1]="(?:\\/|"+s+"\\/)?"+r:e[i]=s:void 0===r?e[i-1]=n+"(?:\\/|"+s+")?":r!==kt&&(e[i-1]=n+"(?:\\/|\\/"+s+"\\/)"+r,e[i+1]=kt))}),e.filter(t=>t!==kt).join("/")}).join("|");const[n,o]=t.length>1?["(?:",")"]:["",""];r="^"+n+r+o+"$",this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch(t){this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return""===t;if("/"===t&&e)return!0;const s=this.options;this.isWindows&&(t=t.split("\\").join("/"));const i=this.slashSplit(t);this.debug(this.pattern,"split",i);const r=this.set;this.debug(this.pattern,"set",r);let n=i[i.length-1];if(!n)for(let t=i.length-2;!n&&t>=0;t--)n=i[t];for(let t=0;t<r.length;t++){const o=r[t];let a=i;s.matchBase&&1===o.length&&(a=[n]);if(this.matchOne(a,o,e))return!!s.flipNegate||!this.negate}return!s.flipNegate&&this.negate}static defaults(t){return et.defaults(t).Minimatch}}et.AST=X,et.Minimatch=Ft,et.escape=tt,et.unescape=W;const Tt="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,Lt=new Set,_t="object"==typeof process&&process?process:{},Mt=(t,e,s,i)=>{"function"==typeof _t.emitWarning?_t.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)};let Ot=globalThis.AbortController,Dt=globalThis.AbortSignal;if(void 0===Ot){Dt=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},Ot=class{constructor(){e()}signal=new Dt;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==_t.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,Mt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const Nt=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Pt=t=>Nt(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Rt:null:null;class Rt extends Array{constructor(t){super(t),this.fill(0)}}class zt{heap;length;static#g=!1;static create(t){const e=Pt(t);if(!e)return[];zt.#g=!0;const s=new zt(t,e);return zt.#g=!1,s}constructor(t,e){if(!zt.#g)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class jt{#m;#w;#y;#b;#v;#S;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#x;#k;#E;#C;#A;#F;#T;#L;#_;#M;#O;#D;#N;#P;#R;#z;#j;static unsafeExposeInternals(t){return{starts:t.#N,ttls:t.#P,sizes:t.#D,keyMap:t.#E,keyList:t.#C,valList:t.#A,next:t.#F,prev:t.#T,get head(){return t.#L},get tail(){return t.#_},free:t.#M,isBackgroundFetch:e=>t.#I(e),backgroundFetch:(e,s,i,r)=>t.#$(e,s,i,r),moveToTail:e=>t.#B(e),indexes:e=>t.#W(e),rindexes:e=>t.#U(e),isStale:e=>t.#G(e)}}get max(){return this.#m}get maxSize(){return this.#w}get calculatedSize(){return this.#k}get size(){return this.#x}get fetchMethod(){return this.#v}get memoMethod(){return this.#S}get dispose(){return this.#y}get disposeAfter(){return this.#b}constructor(t){const{max:e=0,ttl:s,ttlResolution:i=1,ttlAutopurge:r,updateAgeOnGet:n,updateAgeOnHas:o,allowStale:a,dispose:h,disposeAfter:l,noDisposeOnSet:c,noUpdateTTL:d,maxSize:p=0,maxEntrySize:u=0,sizeCalculation:f,fetchMethod:g,memoMethod:m,noDeleteOnFetchRejection:w,noDeleteOnStaleGet:y,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:v,ignoreFetchAbort:S}=t;if(0!==e&&!Nt(e))throw new TypeError("max option must be a nonnegative integer");const x=e?Pt(e):Array;if(!x)throw new Error("invalid max value: "+e);if(this.#m=e,this.#w=p,this.maxEntrySize=u||this.#w,this.sizeCalculation=f,this.sizeCalculation){if(!this.#w&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==m&&"function"!=typeof m)throw new TypeError("memoMethod must be a function if defined");if(this.#S=m,void 0!==g&&"function"!=typeof g)throw new TypeError("fetchMethod must be a function if specified");if(this.#v=g,this.#z=!!g,this.#E=new Map,this.#C=new Array(e).fill(void 0),this.#A=new Array(e).fill(void 0),this.#F=new x(e),this.#T=new x(e),this.#L=0,this.#_=0,this.#M=zt.create(e),this.#x=0,this.#k=0,"function"==typeof h&&(this.#y=h),"function"==typeof l?(this.#b=l,this.#O=[]):(this.#b=void 0,this.#O=void 0),this.#R=!!this.#y,this.#j=!!this.#b,this.noDisposeOnSet=!!c,this.noUpdateTTL=!!d,this.noDeleteOnFetchRejection=!!w,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!v,this.ignoreFetchAbort=!!S,0!==this.maxEntrySize){if(0!==this.#w&&!Nt(this.#w))throw new TypeError("maxSize must be a positive integer if specified");if(!Nt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#H()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!y,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!o,this.ttlResolution=Nt(i)||0===i?i:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!Nt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#q()}if(0===this.#m&&0===this.ttl&&0===this.#w)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#m&&!this.#w){const t="LRU_CACHE_UNBOUNDED";if((t=>!Lt.has(t))(t)){Lt.add(t);Mt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,jt)}}}getRemainingTTL(t){return this.#E.has(t)?1/0:0}#q(){const t=new Rt(this.#m),e=new Rt(this.#m);this.#P=t,this.#N=e,this.#Y=(s,i,r=Tt.now())=>{if(e[s]=0!==i?r:0,t[s]=i,0!==i&&this.ttlAutopurge){const t=setTimeout(()=>{this.#G(s)&&this.#J(this.#C[s],"expire")},i+1);t.unref&&t.unref()}},this.#K=s=>{e[s]=0!==t[s]?Tt.now():0},this.#V=(r,n)=>{if(t[n]){const o=t[n],a=e[n];if(!o||!a)return;r.ttl=o,r.start=a,r.now=s||i();const h=r.now-a;r.remainingTTL=o-h}};let s=0;const i=()=>{const t=Tt.now();if(this.ttlResolution>0){s=t;const e=setTimeout(()=>s=0,this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=r=>{const n=this.#E.get(r);if(void 0===n)return 0;const o=t[n],a=e[n];if(!o||!a)return 1/0;return o-((s||i())-a)},this.#G=r=>{const n=e[r],o=t[r];return!!o&&!!n&&(s||i())-n>o}}#K=()=>{};#V=()=>{};#Y=()=>{};#G=()=>!1;#H(){const t=new Rt(this.#m);this.#k=0,this.#D=t,this.#Z=e=>{this.#k-=t[e],t[e]=0},this.#Q=(t,e,s,i)=>{if(this.#I(e))return 0;if(!Nt(s)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(s=i(e,t),!Nt(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return s},this.#X=(e,s,i)=>{if(t[e]=s,this.#w){const s=this.#w-t[e];for(;this.#k>s;)this.#tt(!0)}this.#k+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#k)}}#Z=t=>{};#X=(t,e,s)=>{};#Q=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#W({allowStale:t=this.allowStale}={}){if(this.#x)for(let e=this.#_;this.#et(e)&&(!t&&this.#G(e)||(yield e),e!==this.#L);)e=this.#T[e]}*#U({allowStale:t=this.allowStale}={}){if(this.#x)for(let e=this.#L;this.#et(e)&&(!t&&this.#G(e)||(yield e),e!==this.#_);)e=this.#F[e]}#et(t){return void 0!==t&&this.#E.get(this.#C[t])===t}*entries(){for(const t of this.#W())void 0===this.#A[t]||void 0===this.#C[t]||this.#I(this.#A[t])||(yield[this.#C[t],this.#A[t]])}*rentries(){for(const t of this.#U())void 0===this.#A[t]||void 0===this.#C[t]||this.#I(this.#A[t])||(yield[this.#C[t],this.#A[t]])}*keys(){for(const t of this.#W()){const e=this.#C[t];void 0===e||this.#I(this.#A[t])||(yield e)}}*rkeys(){for(const t of this.#U()){const e=this.#C[t];void 0===e||this.#I(this.#A[t])||(yield e)}}*values(){for(const t of this.#W()){void 0===this.#A[t]||this.#I(this.#A[t])||(yield this.#A[t])}}*rvalues(){for(const t of this.#U()){void 0===this.#A[t]||this.#I(this.#A[t])||(yield this.#A[t])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const s of this.#W()){const i=this.#A[s],r=this.#I(i)?i.__staleWhileFetching:i;if(void 0!==r&&t(r,this.#C[s],this))return this.get(this.#C[s],e)}}forEach(t,e=this){for(const s of this.#W()){const i=this.#A[s],r=this.#I(i)?i.__staleWhileFetching:i;void 0!==r&&t.call(e,r,this.#C[s],this)}}rforEach(t,e=this){for(const s of this.#U()){const i=this.#A[s],r=this.#I(i)?i.__staleWhileFetching:i;void 0!==r&&t.call(e,r,this.#C[s],this)}}purgeStale(){let t=!1;for(const e of this.#U({allowStale:!0}))this.#G(e)&&(this.#J(this.#C[e],"expire"),t=!0);return t}info(t){const e=this.#E.get(t);if(void 0===e)return;const s=this.#A[e],i=this.#I(s)?s.__staleWhileFetching:s;if(void 0===i)return;const r={value:i};if(this.#P&&this.#N){const t=this.#P[e],s=this.#N[e];if(t&&s){const e=t-(Tt.now()-s);r.ttl=e,r.start=Date.now()}}return this.#D&&(r.size=this.#D[e]),r}dump(){const t=[];for(const e of this.#W({allowStale:!0})){const s=this.#C[e],i=this.#A[e],r=this.#I(i)?i.__staleWhileFetching:i;if(void 0===r||void 0===s)continue;const n={value:r};if(this.#P&&this.#N){n.ttl=this.#P[e];const t=Tt.now()-this.#N[e];n.start=Math.floor(Date.now()-t)}this.#D&&(n.size=this.#D[e]),t.unshift([s,n])}return t}load(t){this.clear();for(const[e,s]of t){if(s.start){const t=Date.now()-s.start;s.start=Tt.now()-t}this.set(e,s.value,s)}}set(t,e,s={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:r,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=s;let{noUpdateTTL:h=this.noUpdateTTL}=s;const l=this.#Q(t,e,s.size||0,o);if(this.maxEntrySize&&l>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#J(t,"set"),this;let c=0===this.#x?void 0:this.#E.get(t);if(void 0===c)c=0===this.#x?this.#_:0!==this.#M.length?this.#M.pop():this.#x===this.#m?this.#tt(!1):this.#x,this.#C[c]=t,this.#A[c]=e,this.#E.set(t,c),this.#F[this.#_]=c,this.#T[c]=this.#_,this.#_=c,this.#x++,this.#X(c,l,a),a&&(a.set="add"),h=!1;else{this.#B(c);const s=this.#A[c];if(e!==s){if(this.#z&&this.#I(s)){s.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=s;void 0===e||n||(this.#R&&this.#y?.(e,t,"set"),this.#j&&this.#O?.push([e,t,"set"]))}else n||(this.#R&&this.#y?.(s,t,"set"),this.#j&&this.#O?.push([s,t,"set"]));if(this.#Z(c),this.#X(c,l,a),this.#A[c]=e,a){a.set="replace";const t=s&&this.#I(s)?s.__staleWhileFetching:s;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#P||this.#q(),this.#P&&(h||this.#Y(c,i,r),a&&this.#V(a,c)),!n&&this.#j&&this.#O){const t=this.#O;let e;for(;e=t?.shift();)this.#b?.(...e)}return this}pop(){try{for(;this.#x;){const t=this.#A[this.#L];if(this.#tt(!0),this.#I(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#j&&this.#O){const t=this.#O;let e;for(;e=t?.shift();)this.#b?.(...e)}}}#tt(t){const e=this.#L,s=this.#C[e],i=this.#A[e];return this.#z&&this.#I(i)?i.__abortController.abort(new Error("evicted")):(this.#R||this.#j)&&(this.#R&&this.#y?.(i,s,"evict"),this.#j&&this.#O?.push([i,s,"evict"])),this.#Z(e),t&&(this.#C[e]=void 0,this.#A[e]=void 0,this.#M.push(e)),1===this.#x?(this.#L=this.#_=0,this.#M.length=0):this.#L=this.#F[e],this.#E.delete(s),this.#x--,e}has(t,e={}){const{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,r=this.#E.get(t);if(void 0!==r){const t=this.#A[r];if(this.#I(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#G(r))return s&&this.#K(r),i&&(i.has="hit",this.#V(i,r)),!0;i&&(i.has="stale",this.#V(i,r))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:s=this.allowStale}=e,i=this.#E.get(t);if(void 0===i||!s&&this.#G(i))return;const r=this.#A[i];return this.#I(r)?r.__staleWhileFetching:r}#$(t,e,s,i){const r=void 0===e?void 0:this.#A[e];if(this.#I(r))return r;const n=new Ot,{signal:o}=s;o?.addEventListener("abort",()=>n.abort(o.reason),{signal:n.signal});const a={signal:n.signal,options:s,context:i},h=(i,r=!1)=>{const{aborted:o}=n.signal,h=s.ignoreFetchAbort&&void 0!==i;if(s.status&&(o&&!r?(s.status.fetchAborted=!0,s.status.fetchError=n.signal.reason,h&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),o&&!h&&!r)return l(n.signal.reason);const d=c;return this.#A[e]===c&&(void 0===i?d.__staleWhileFetching?this.#A[e]=d.__staleWhileFetching:this.#J(t,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(t,i,a.options))),i},l=i=>{const{aborted:r}=n.signal,o=r&&s.allowStaleOnFetchAbort,a=o||s.allowStaleOnFetchRejection,h=a||s.noDeleteOnFetchRejection,l=c;if(this.#A[e]===c){!h||void 0===l.__staleWhileFetching?this.#J(t,"fetch"):o||(this.#A[e]=l.__staleWhileFetching)}if(a)return s.status&&void 0!==l.__staleWhileFetching&&(s.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw i};s.status&&(s.status.fetchDispatched=!0);const c=new Promise((e,i)=>{const o=this.#v?.(t,r,a);o&&o instanceof Promise&&o.then(t=>e(void 0===t?void 0:t),i),n.signal.addEventListener("abort",()=>{s.ignoreFetchAbort&&!s.allowStaleOnFetchAbort||(e(void 0),s.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))})}).then(h,t=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=t),l(t))),d=Object.assign(c,{__abortController:n,__staleWhileFetching:r,__returned:void 0});return void 0===e?(this.set(t,d,{...a.options,status:void 0}),e=this.#E.get(t)):this.#A[e]=d,d}#I(t){if(!this.#z)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Ot}async fetch(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:u=this.allowStaleOnFetchAbort,context:f,forceRefresh:g=!1,status:m,signal:w}=e;if(!this.#z)return m&&(m.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:m});const y={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:n,noDisposeOnSet:o,size:a,sizeCalculation:h,noUpdateTTL:l,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:u,ignoreFetchAbort:p,status:m,signal:w};let b=this.#E.get(t);if(void 0===b){m&&(m.fetch="miss");const e=this.#$(t,b,y,f);return e.__returned=e}{const e=this.#A[b];if(this.#I(e)){const t=s&&void 0!==e.__staleWhileFetching;return m&&(m.fetch="inflight",t&&(m.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const r=this.#G(b);if(!g&&!r)return m&&(m.fetch="hit"),this.#B(b),i&&this.#K(b),m&&this.#V(m,b),e;const n=this.#$(t,b,y,f),o=void 0!==n.__staleWhileFetching&&s;return m&&(m.fetch=r?"stale":"refresh",o&&r&&(m.returnedStale=!0)),o?n.__staleWhileFetching:n.__returned=n}}async forceFetch(t,e={}){const s=await this.fetch(t,e);if(void 0===s)throw new Error("fetch() returned undefined");return s}memo(t,e={}){const s=this.#S;if(!s)throw new Error("no memoMethod provided to constructor");const{context:i,forceRefresh:r,...n}=e,o=this.get(t,n);if(!r&&void 0!==o)return o;const a=s(t,o,{options:n,context:i});return this.set(t,a,n),a}get(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:n}=e,o=this.#E.get(t);if(void 0!==o){const e=this.#A[o],a=this.#I(e);return n&&this.#V(n,o),this.#G(o)?(n&&(n.get="stale"),a?(n&&s&&void 0!==e.__staleWhileFetching&&(n.returnedStale=!0),s?e.__staleWhileFetching:void 0):(r||this.#J(t,"expire"),n&&s&&(n.returnedStale=!0),s?e:void 0)):(n&&(n.get="hit"),a?e.__staleWhileFetching:(this.#B(o),i&&this.#K(o),e))}n&&(n.get="miss")}#st(t,e){this.#T[e]=t,this.#F[t]=e}#B(t){t!==this.#_&&(t===this.#L?this.#L=this.#F[t]:this.#st(this.#T[t],this.#F[t]),this.#st(this.#_,t),this.#_=t)}delete(t){return this.#J(t,"delete")}#J(t,e){let s=!1;if(0!==this.#x){const i=this.#E.get(t);if(void 0!==i)if(s=!0,1===this.#x)this.#it(e);else{this.#Z(i);const s=this.#A[i];if(this.#I(s)?s.__abortController.abort(new Error("deleted")):(this.#R||this.#j)&&(this.#R&&this.#y?.(s,t,e),this.#j&&this.#O?.push([s,t,e])),this.#E.delete(t),this.#C[i]=void 0,this.#A[i]=void 0,i===this.#_)this.#_=this.#T[i];else if(i===this.#L)this.#L=this.#F[i];else{const t=this.#T[i];this.#F[t]=this.#F[i];const e=this.#F[i];this.#T[e]=this.#T[i]}this.#x--,this.#M.push(i)}}if(this.#j&&this.#O?.length){const t=this.#O;let e;for(;e=t?.shift();)this.#b?.(...e)}return s}clear(){return this.#it("delete")}#it(t){for(const e of this.#U({allowStale:!0})){const s=this.#A[e];if(this.#I(s))s.__abortController.abort(new Error("deleted"));else{const i=this.#C[e];this.#R&&this.#y?.(s,i,t),this.#j&&this.#O?.push([s,i,t])}}if(this.#E.clear(),this.#A.fill(void 0),this.#C.fill(void 0),this.#P&&this.#N&&(this.#P.fill(0),this.#N.fill(0)),this.#D&&this.#D.fill(0),this.#L=0,this.#_=0,this.#M.length=0,this.#k=0,this.#x=0,this.#j&&this.#O){const t=this.#O;let e;for(;e=t?.shift();)this.#b?.(...e)}}}const It="object"==typeof process&&process?process:{stdout:null,stderr:null},$t=t=>!!t&&"object"==typeof t&&(t instanceof Ee||t instanceof A||Bt(t)||Wt(t)),Bt=t=>!!t&&"object"==typeof t&&t instanceof C&&"function"==typeof t.pipe&&t.pipe!==A.Writable.prototype.pipe,Wt=t=>!!t&&"object"==typeof t&&t instanceof C&&"function"==typeof t.write&&"function"==typeof t.end,Ut=Symbol("EOF"),Gt=Symbol("maybeEmitEnd"),Ht=Symbol("emittedEnd"),qt=Symbol("emittingEnd"),Yt=Symbol("emittedError"),Jt=Symbol("closed"),Kt=Symbol("read"),Vt=Symbol("flush"),Zt=Symbol("flushChunk"),Qt=Symbol("encoding"),Xt=Symbol("decoder"),te=Symbol("flowing"),ee=Symbol("paused"),se=Symbol("resume"),ie=Symbol("buffer"),re=Symbol("pipes"),ne=Symbol("bufferLength"),oe=Symbol("bufferPush"),ae=Symbol("bufferShift"),he=Symbol("objectMode"),le=Symbol("destroyed"),ce=Symbol("error"),de=Symbol("emitData"),pe=Symbol("emitEnd"),ue=Symbol("emitEnd2"),fe=Symbol("async"),ge=Symbol("abort"),me=Symbol("aborted"),we=Symbol("signal"),ye=Symbol("dataListeners"),be=Symbol("discarded"),ve=t=>Promise.resolve().then(t),Se=t=>t();class xe{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[se](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}}class ke extends xe{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,s){super(t,e,s),this.proxyErrors=t=>e.emit("error",t),t.on("error",this.proxyErrors)}}class Ee extends C{[te]=!1;[ee]=!1;[re]=[];[ie]=[];[he];[Qt];[fe];[Xt];[Ut]=!1;[Ht]=!1;[qt]=!1;[Jt]=!1;[Yt]=null;[ne]=0;[le]=!1;[we];[me]=!1;[ye]=0;[be]=!1;writable=!0;readable=!0;constructor(...t){const e=t[0]||{};if(super(),e.objectMode&&"string"==typeof e.encoding)throw new TypeError("Encoding and objectMode may not be used together");e.objectMode?(this[he]=!0,this[Qt]=null):(t=>!t.objectMode&&!!t.encoding&&"buffer"!==t.encoding)(e)?(this[Qt]=e.encoding,this[he]=!1):(this[he]=!1,this[Qt]=null),this[fe]=!!e.async,this[Xt]=this[Qt]?new F(this[Qt]):null,e&&!0===e.debugExposeBuffer&&Object.defineProperty(this,"buffer",{get:()=>this[ie]}),e&&!0===e.debugExposePipes&&Object.defineProperty(this,"pipes",{get:()=>this[re]});const{signal:s}=e;s&&(this[we]=s,s.aborted?this[ge]():s.addEventListener("abort",()=>this[ge]()))}get bufferLength(){return this[ne]}get encoding(){return this[Qt]}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[he]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[fe]}set async(t){this[fe]=this[fe]||!!t}[ge](){this[me]=!0,this.emit("abort",this[we]?.reason),this.destroy(this[we]?.reason)}get aborted(){return this[me]}set aborted(t){}write(t,e,s){if(this[me])return!1;if(this[Ut])throw new Error("write after end");if(this[le])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;"function"==typeof e&&(s=e,e="utf8"),e||(e="utf8");const i=this[fe]?ve:Se;if(!this[he]&&!Buffer.isBuffer(t))if(r=t,!Buffer.isBuffer(r)&&ArrayBuffer.isView(r))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if((t=>t instanceof ArrayBuffer||!!t&&"object"==typeof t&&t.constructor&&"ArrayBuffer"===t.constructor.name&&t.byteLength>=0)(t))t=Buffer.from(t);else if("string"!=typeof t)throw new Error("Non-contiguous data written to non-objectMode stream");var r;return this[he]?(this[te]&&0!==this[ne]&&this[Vt](!0),this[te]?this.emit("data",t):this[oe](t),0!==this[ne]&&this.emit("readable"),s&&i(s),this[te]):t.length?("string"!=typeof t||e===this[Qt]&&!this[Xt]?.lastNeed||(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[Qt]&&(t=this[Xt].write(t)),this[te]&&0!==this[ne]&&this[Vt](!0),this[te]?this.emit("data",t):this[oe](t),0!==this[ne]&&this.emit("readable"),s&&i(s),this[te]):(0!==this[ne]&&this.emit("readable"),s&&i(s),this[te])}read(t){if(this[le])return null;if(this[be]=!1,0===this[ne]||0===t||t&&t>this[ne])return this[Gt](),null;this[he]&&(t=null),this[ie].length>1&&!this[he]&&(this[ie]=[this[Qt]?this[ie].join(""):Buffer.concat(this[ie],this[ne])]);const e=this[Kt](t||null,this[ie][0]);return this[Gt](),e}[Kt](t,e){if(this[he])this[ae]();else{const s=e;t===s.length||null===t?this[ae]():"string"==typeof s?(this[ie][0]=s.slice(t),e=s.slice(0,t),this[ne]-=t):(this[ie][0]=s.subarray(t),e=s.subarray(0,t),this[ne]-=t)}return this.emit("data",e),this[ie].length||this[Ut]||this.emit("drain"),e}end(t,e,s){return"function"==typeof t&&(s=t,t=void 0),"function"==typeof e&&(s=e,e="utf8"),void 0!==t&&this.write(t,e),s&&this.once("end",s),this[Ut]=!0,this.writable=!1,!this[te]&&this[ee]||this[Gt](),this}[se](){this[le]||(this[ye]||this[re].length||(this[be]=!0),this[ee]=!1,this[te]=!0,this.emit("resume"),this[ie].length?this[Vt]():this[Ut]?this[Gt]():this.emit("drain"))}resume(){return this[se]()}pause(){this[te]=!1,this[ee]=!0,this[be]=!1}get destroyed(){return this[le]}get flowing(){return this[te]}get paused(){return this[ee]}[oe](t){this[he]?this[ne]+=1:this[ne]+=t.length,this[ie].push(t)}[ae](){return this[he]?this[ne]-=1:this[ne]-=this[ie][0].length,this[ie].shift()}[Vt](t=!1){do{}while(this[Zt](this[ae]())&&this[ie].length);t||this[ie].length||this[Ut]||this.emit("drain")}[Zt](t){return this.emit("data",t),this[te]}pipe(t,e){if(this[le])return t;this[be]=!1;const s=this[Ht];return e=e||{},t===It.stdout||t===It.stderr?e.end=!1:e.end=!1!==e.end,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[re].push(e.proxyErrors?new ke(this,t,e):new xe(this,t,e)),this[fe]?ve(()=>this[se]()):this[se]()),t}unpipe(t){const e=this[re].find(e=>e.dest===t);e&&(1===this[re].length?(this[te]&&0===this[ye]&&(this[te]=!1),this[re]=[]):this[re].splice(this[re].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){const s=super.on(t,e);if("data"===t)this[be]=!1,this[ye]++,this[re].length||this[te]||this[se]();else if("readable"===t&&0!==this[ne])super.emit("readable");else if((t=>"end"===t||"finish"===t||"prefinish"===t)(t)&&this[Ht])super.emit(t),this.removeAllListeners(t);else if("error"===t&&this[Yt]){const t=e;this[fe]?ve(()=>t.call(this,this[Yt])):t.call(this,this[Yt])}return s}removeListener(t,e){return this.off(t,e)}off(t,e){const s=super.off(t,e);return"data"===t&&(this[ye]=this.listeners("data").length,0!==this[ye]||this[be]||this[re].length||(this[te]=!1)),s}removeAllListeners(t){const e=super.removeAllListeners(t);return"data"!==t&&void 0!==t||(this[ye]=0,this[be]||this[re].length||(this[te]=!1)),e}get emittedEnd(){return this[Ht]}[Gt](){this[qt]||this[Ht]||this[le]||0!==this[ie].length||!this[Ut]||(this[qt]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Jt]&&this.emit("close"),this[qt]=!1)}emit(t,...e){const s=e[0];if("error"!==t&&"close"!==t&&t!==le&&this[le])return!1;if("data"===t)return!(!this[he]&&!s)&&(this[fe]?(ve(()=>this[de](s)),!0):this[de](s));if("end"===t)return this[pe]();if("close"===t){if(this[Jt]=!0,!this[Ht]&&!this[le])return!1;const t=super.emit("close");return this.removeAllListeners("close"),t}if("error"===t){this[Yt]=s,super.emit(ce,s);const t=!(this[we]&&!this.listeners("error").length)&&super.emit("error",s);return this[Gt](),t}if("resume"===t){const t=super.emit("resume");return this[Gt](),t}if("finish"===t||"prefinish"===t){const e=super.emit(t);return this.removeAllListeners(t),e}const i=super.emit(t,...e);return this[Gt](),i}[de](t){for(const e of this[re])!1===e.dest.write(t)&&this.pause();const e=!this[be]&&super.emit("data",t);return this[Gt](),e}[pe](){return!this[Ht]&&(this[Ht]=!0,this.readable=!1,this[fe]?(ve(()=>this[ue]()),!0):this[ue]())}[ue](){if(this[Xt]){const t=this[Xt].end();if(t){for(const e of this[re])e.dest.write(t);this[be]||super.emit("data",t)}}for(const t of this[re])t.end();const t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){const t=Object.assign([],{dataLength:0});this[he]||(t.dataLength=0);const e=this.promise();return this.on("data",e=>{t.push(e),this[he]||(t.dataLength+=e.length)}),await e,t}async concat(){if(this[he])throw new Error("cannot concat in objectMode");const t=await this.collect();return this[Qt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(le,()=>e(new Error("stream destroyed"))),this.on("error",t=>e(t)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[be]=!1;let t=!1;const e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();const s=this.read();if(null!==s)return Promise.resolve({done:!1,value:s});if(this[Ut])return e();let i,r;const n=t=>{this.off("data",o),this.off("end",a),this.off(le,h),e(),r(t)},o=t=>{this.off("error",n),this.off("end",a),this.off(le,h),this.pause(),i({value:t,done:!!this[Ut]})},a=()=>{this.off("error",n),this.off("data",o),this.off(le,h),e(),i({done:!0,value:void 0})},h=()=>n(new Error("stream destroyed"));return new Promise((t,e)=>{r=e,i=t,this.once(le,h),this.once("error",n),this.once("end",a),this.once("data",o)})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[be]=!1;let t=!1;const e=()=>(this.pause(),this.off(ce,e),this.off(le,e),this.off("end",e),t=!0,{done:!0,value:void 0});return this.once("end",e),this.once(ce,e),this.once(le,e),{next:()=>{if(t)return e();const s=this.read();return null===s?e():{done:!1,value:s}},throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){if(this[le])return t?this.emit("error",t):this.emit(le),this;this[le]=!0,this[be]=!0,this[ie].length=0,this[ne]=0;return"function"!=typeof this.close||this[Jt]||this.close(),t?this.emit("error",t):this.emit(le),this}static get isStream(){return $t}}const Ce={lstatSync:b,readdir:y,readdirSync:w,readlinkSync:m,realpathSync:g.native,promises:{lstat:E,readdir:k,readlink:x,realpath:S}},Ae=t=>t&&t!==Ce&&t!==v?{...Ce,...t,promises:{...Ce.promises,...t.promises||{}}}:Ce,Fe=/^\\\\\?\\([a-z]:)\\?$/i,Te=/[\\\/]/,Le=10,_e=15,Me=-16,Oe=128,De=256,Ne=512,Pe=t=>t.isFile()?8:t.isDirectory()?4:t.isSymbolicLink()?Le:t.isCharacterDevice()?2:t.isBlockDevice()?6:t.isSocket()?12:t.isFIFO()?1:0,Re=new Map,ze=t=>{const e=Re.get(t);if(e)return e;const s=t.normalize("NFKD");return Re.set(t,s),s},je=new Map,Ie=t=>{const e=je.get(t);if(e)return e;const s=ze(t.toLowerCase());return je.set(t,s),s};class $e extends jt{constructor(){super({max:256})}}class Be extends jt{constructor(t=16384){super({maxSize:t,sizeCalculation:t=>t.length+1})}}const We=Symbol("PathScurry setAsCwd");class Ue{name;root;roots;parent;nocase;isCWD=!1;#rt;#nt;get dev(){return this.#nt}#ot;get mode(){return this.#ot}#at;get nlink(){return this.#at}#ht;get uid(){return this.#ht}#lt;get gid(){return this.#lt}#ct;get rdev(){return this.#ct}#dt;get blksize(){return this.#dt}#pt;get ino(){return this.#pt}#x;get size(){return this.#x}#ut;get blocks(){return this.#ut}#ft;get atimeMs(){return this.#ft}#gt;get mtimeMs(){return this.#gt}#mt;get ctimeMs(){return this.#mt}#wt;get birthtimeMs(){return this.#wt}#yt;get atime(){return this.#yt}#bt;get mtime(){return this.#bt}#vt;get ctime(){return this.#vt}#St;get birthtime(){return this.#St}#xt;#kt;#Et;#Ct;#At;#Ft;#Tt;#Lt;#_t;#Mt;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,e=0,s,i,r,n,