@mherod/get-cookie 4.1.0 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +5 -0
- package/.husky/commit-msg +6 -2
- package/.husky/pre-commit +6 -4
- package/.husky/pre-push +6 -4
- package/README.md +76 -117
- package/dist/cli.cjs +1 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +220 -41
- package/dist/index.d.ts +220 -41
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/eslint.config.js +8 -18
- package/examples/README.md +37 -0
- package/examples/advanced-usage.ts +56 -0
- package/examples/basic-usage.ts +43 -0
- package/examples/cli-examples.sh +51 -0
- package/package.json +13 -4
- package/tsconfig.build.json +2 -2
- package/tsconfig.cli.json +12 -0
- package/tsconfig.tsup.json +12 -0
- package/tsup.cli.ts +1 -0
- package/tsup.lib.ts +1 -0
- package/dist/chunk-3FVH4L25.js +0 -2
- package/dist/chunk-3FVH4L25.js.map +0 -1
- package/dist/chunk-56Z35D5R.js +0 -2
- package/dist/chunk-56Z35D5R.js.map +0 -1
- package/dist/chunk-7XZ7PCDJ.js +0 -2
- package/dist/chunk-7XZ7PCDJ.js.map +0 -1
- package/dist/chunk-DVWQBWUF.js +0 -4
- package/dist/chunk-DVWQBWUF.js.map +0 -1
- package/dist/chunk-I6AYGFSQ.js +0 -2
- package/dist/chunk-I6AYGFSQ.js.map +0 -1
- package/dist/chunk-U27I5BLR.js +0 -2
- package/dist/chunk-U27I5BLR.js.map +0 -1
- package/dist/chunk-YOZOS2YM.js +0 -2
- package/dist/chunk-YOZOS2YM.js.map +0 -1
- package/dist/getChromeCookie-2ROVM47V.js +0 -2
- package/dist/getChromeCookie-2ROVM47V.js.map +0 -1
- package/dist/getChromePassword-O452VQWI.js +0 -2
- package/dist/getChromePassword-O452VQWI.js.map +0 -1
- package/dist/getCookie-CRE6M3GI.js +0 -2
- package/dist/getCookie-CRE6M3GI.js.map +0 -1
- package/dist/getFirefoxCookie-5P74VDC7.js +0 -2
- package/dist/getFirefoxCookie-5P74VDC7.js.map +0 -1
- package/dist/getGroupedRenderedCookies-DFEJTTC6.js +0 -2
- package/dist/getGroupedRenderedCookies-DFEJTTC6.js.map +0 -1
- package/dist/getMergedRenderedCookies-W5GSSHQQ.js +0 -2
- package/dist/getMergedRenderedCookies-W5GSSHQQ.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
"use strict";var ga=Object.create;var si=Object.defineProperty;var wa=Object.getOwnPropertyDescriptor;var ya=Object.getOwnPropertyNames;var Sa=Object.getPrototypeOf,ba=Object.prototype.hasOwnProperty;var Fr=o=>{throw TypeError(o)};var Ea=(o,t,e)=>t in o?si(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var D=(o,t)=>()=>(o&&(t=o(o=0)),t);var Ar=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),ge=(o,t)=>{for(var e in t)si(o,e,{get:t[e],enumerable:!0})},Dr=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ya(t))!ba.call(o,s)&&s!==e&&si(o,s,{get:()=>t[s],enumerable:!(i=wa(t,s))||i.enumerable});return o};var De=(o,t,e)=>(e=o!=null?ga(Sa(o)):{},Dr(t||!o||!o.__esModule?si(e,"default",{value:o,enumerable:!0}):e,o)),Ca=o=>Dr(si({},"__esModule",{value:!0}),o);var u=(o,t,e)=>Ea(o,typeof t!="symbol"?t+"":t,e),Ls=(o,t,e)=>t.has(o)||Fr("Cannot "+e);var r=(o,t,e)=>(Ls(o,t,"read from private field"),e?e.call(o):t.get(o)),y=(o,t,e)=>t.has(o)?Fr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,e),f=(o,t,e,i)=>(Ls(o,t,"write to private field"),i?i.call(o,e):t.set(o,e),e),m=(o,t,e)=>(Ls(o,t,"access private method"),e);var Zi=(o,t,e,i)=>({set _(s){f(o,t,s,e)},get _(){return r(o,t,i)}});var _r,xa,N,jt=D(()=>{"use strict";_r=require("consola"),xa=(0,_r.createConsola)({fancy:!0,formatOptions:{showLogLevel:!1,colors:!0,date:!1,compact:!0,columns:typeof process.stdout.columns=="number"?process.stdout.columns:80},level:typeof process.env.LOG_LEVEL=="string"&&process.env.LOG_LEVEL==="debug"?5:2}),N=xa});function Pr(o,t,e){let s=`${t?"\u2705":"\u274C"} ${o} ${t?"succeeded":"failed"}`;t?N.success(s,e):N.error(s,e)}function z(o,t,e){let i={...e!=null?e:{},error:t instanceof Error?{name:t.name,message:t.message,stack:t.stack}:t};N.error(o,i)}function Lt(o,t,e){N.withTag(o).debug(t,e)}function Lr(o){return N.withTag(o)}function Yi(o,t,e){N.withTag(o).warn(t,e)}var Yt=D(()=>{"use strict";jt();jt()});var Mr,Nr,Ji,Br=D(()=>{"use strict";Mr=require("lodash-es"),Nr={};(0,Mr.merge)(Nr,process.env);Ji=Nr.HOME;if(typeof Ji!="string"||Ji.length===0)throw new Error("HOME environment variable is not set or empty")});var zr,Ir,_e,Ms=D(()=>{"use strict";zr=require("path");Br();_e=(0,zr.join)((Ir=Ji)!=null?Ir:"","Library","Application Support","Google","Chrome")});function va(o){try{return o.close(),Promise.resolve()}catch(t){return z("Database close failed",t),Promise.reject(t instanceof Error?t:new Error("Failed to close database: Unknown error"))}}async function Xi({file:o,sql:t,params:e,rowFilter:i,rowTransform:s}){let n;try{n=await ka(o);let l=n.prepare(t).all(e),h=i?l.filter(i):l;return s?h.map(s):h}catch(a){throw z("Database query failed",a,{file:o,sql:t}),a}finally{n&&await va(n)}}var Wr,jr,ka,Ns=D(()=>{"use strict";Wr=De(require("better-sqlite3"),1),jr=require("lodash-es");Yt();ka=(0,jr.memoize)(o=>{try{return Promise.resolve(new Wr.default(o,{readonly:!0}))}catch(t){throw z("Database open failed",t,{file:o}),t}})});function Ra(o){if(typeof o!="string")return!1;let t=o.trim();return t.length===0?!1:(0,Ur.existsSync)(t)}async function Ta(){let o=[(0,ts.join)(_e,"Default/Cookies"),(0,ts.join)(_e,"Profile */Cookies"),(0,ts.join)(_e,"Profile Default/Cookies")],t=[];for(let e of o){let i=await(0,$r.default)(e);t.push(...i)}return Lt("ChromeCookies","Found cookie files",{count:t.length,files:t}),t}function Oa(o,t){let e=o==="%",i=e?"SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE host_key LIKE ?":"SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE name = ? AND host_key LIKE ?",s=e?[`%${t}%`]:[o,`%${t}%`];return{sql:i,params:s}}async function Fa(o,t,e){try{let{sql:i,params:s}=Oa(t,e);Lt("ChromeCookies","Executing query",{sql:i,params:s});let n=await Xi({file:o,sql:i,params:s,rowTransform:a=>({name:a.name,domain:a.host_key,value:a.encrypted_value,expiry:a.expires_utc})});return Pr("QueryCookies",!0,{file:o,count:n.length}),n}catch(i){return z("Failed to read cookie file",i,{file:o}),[]}}async function Gr({name:o,domain:t,file:e}){let i=typeof e=="string"&&e.length>0?[e]:await Ta();if(i.length===0)return Lt("ChromeCookies","No cookie files found"),[];let s=[];for(let n of i){if(!Ra(n)){Lt("ChromeCookies","Cookie file missing or invalid",{file:n});continue}let a=await Fa(n,o,t);s.push(...a)}return Lt("ChromeCookies","Query complete",{totalCookies:s.length}),s}var Ur,ts,$r,qr=D(()=>{"use strict";Ur=require("fs"),ts=require("path"),$r=De(require("fast-glob"),1);Yt();Ms();Ns()});var Zr=Ar((Nl,Vr)=>{"use strict";Vr.exports=Qr;function Qr(o,t,e){o instanceof RegExp&&(o=Hr(o,e)),t instanceof RegExp&&(t=Hr(t,e));var i=Kr(o,t,e);return i&&{start:i[0],end:i[1],pre:e.slice(0,i[0]),body:e.slice(i[0]+o.length,i[1]),post:e.slice(i[1]+t.length)}}function Hr(o,t){var e=t.match(o);return e?e[0]:null}Qr.range=Kr;function Kr(o,t,e){var i,s,n,a,l,h=e.indexOf(o),c=e.indexOf(t,h+1),p=h;if(h>=0&&c>0){if(o===t)return[h,c];for(i=[],n=e.length;p>=0&&!l;)p==h?(i.push(p),h=e.indexOf(o,p+1)):i.length==1?l=[i.pop(),c]:(s=i.pop(),s<n&&(n=s,a=c),c=e.indexOf(t,p+1)),p=h<c&&h>=0?h:c;i.length&&(l=[n,a])}return l}});var ro=Ar((Bl,so)=>{"use strict";var Yr=Zr();so.exports=_a;var Jr="\0SLASH"+Math.random()+"\0",Xr="\0OPEN"+Math.random()+"\0",Is="\0CLOSE"+Math.random()+"\0",to="\0COMMA"+Math.random()+"\0",eo="\0PERIOD"+Math.random()+"\0";function Bs(o){return parseInt(o,10)==o?parseInt(o,10):o.charCodeAt(0)}function Aa(o){return o.split("\\\\").join(Jr).split("\\{").join(Xr).split("\\}").join(Is).split("\\,").join(to).split("\\.").join(eo)}function Da(o){return o.split(Jr).join("\\").split(Xr).join("{").split(Is).join("}").split(to).join(",").split(eo).join(".")}function io(o){if(!o)return[""];var t=[],e=Yr("{","}",o);if(!e)return o.split(",");var i=e.pre,s=e.body,n=e.post,a=i.split(",");a[a.length-1]+="{"+s+"}";var l=io(n);return n.length&&(a[a.length-1]+=l.shift(),a.push.apply(a,l)),t.push.apply(t,a),t}function _a(o){return o?(o.substr(0,2)==="{}"&&(o="\\{\\}"+o.substr(2)),ri(Aa(o),!0).map(Da)):[]}function Pa(o){return"{"+o+"}"}function La(o){return/^-?0\d/.test(o)}function Ma(o,t){return o<=t}function Na(o,t){return o>=t}function ri(o,t){var e=[],i=Yr("{","}",o);if(!i)return[o];var s=i.pre,n=i.post.length?ri(i.post,!1):[""];if(/\$$/.test(i.pre))for(var a=0;a<n.length;a++){var l=s+"{"+i.body+"}"+n[a];e.push(l)}else{var h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),p=h||c,d=i.body.indexOf(",")>=0;if(!p&&!d)return i.post.match(/,.*\}/)?(o=i.pre+"{"+i.body+Is+i.post,ri(o)):[o];var w;if(p)w=i.body.split(/\.\./);else if(w=io(i.body),w.length===1&&(w=ri(w[0],!1).map(Pa),w.length===1))return n.map(function(Vi){return i.pre+w[0]+Vi});var E;if(p){var x=Bs(w[0]),g=Bs(w[1]),C=Math.max(w[0].length,w[1].length),S=w.length==3?Math.abs(Bs(w[2])):1,k=Ma,R=g<x;R&&(S*=-1,k=Na);var A=w.some(La);E=[];for(var _=x;k(_,g);_+=S){var I;if(c)I=String.fromCharCode(_),I==="\\"&&(I="");else if(I=String(_),A){var St=C-I.length;if(St>0){var me=new Array(St+1).join("0");_<0?I="-"+me+I.slice(1):I=me+I}}E.push(I)}}else{E=[];for(var bt=0;bt<w.length;bt++)E.push.apply(E,ri(w[bt],!1))}for(var bt=0;bt<E.length;bt++)for(var a=0;a<n.length;a++){var l=s+E[bt]+n[a];(!t||p||l)&&e.push(l)}}return e}});var oi,oo=D(()=>{"use strict";oi=o=>{if(typeof o!="string")throw new TypeError("invalid pattern");if(o.length>65536)throw new TypeError("pattern is too long")}});var Ba,ni,Ia,no,ao,ho=D(()=>{"use strict";Ba={"[: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]},ni=o=>o.replace(/[[\]\\-]/g,"\\$&"),Ia=o=>o.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),no=o=>o.join(""),ao=(o,t)=>{let e=t;if(o.charAt(e)!=="[")throw new Error("not in a brace expression");let i=[],s=[],n=e+1,a=!1,l=!1,h=!1,c=!1,p=e,d="";t:for(;n<o.length;){let g=o.charAt(n);if((g==="!"||g==="^")&&n===e+1){c=!0,n++;continue}if(g==="]"&&a&&!h){p=n+1;break}if(a=!0,g==="\\"&&!h){h=!0,n++;continue}if(g==="["&&!h){for(let[C,[S,k,R]]of Object.entries(Ba))if(o.startsWith(C,n)){if(d)return["$.",!1,o.length-e,!0];n+=C.length,R?s.push(S):i.push(S),l=l||k;continue t}}if(h=!1,d){g>d?i.push(ni(d)+"-"+ni(g)):g===d&&i.push(ni(g)),d="",n++;continue}if(o.startsWith("-]",n+1)){i.push(ni(g+"-")),n+=2;continue}if(o.startsWith("-",n+1)){d=g,n+=2;continue}i.push(ni(g)),n++}if(p<n)return["",!1,0,!1];if(!i.length&&!s.length)return["$.",!1,o.length-e,!0];if(s.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!c){let g=i[0].length===2?i[0].slice(-1):i[0];return[Ia(g),!1,p-e,!1]}let w="["+(c?"^":"")+no(i)+"]",E="["+(c?"":"^")+no(s)+"]";return[i.length&&s.length?"("+w+"|"+E+")":i.length?w:E,l,p-e,!0]}});var Et,es=D(()=>{"use strict";Et=(o,{windowsPathsNoEscape:t=!1}={})=>t?o.replace(/\[([^\/\\])\]/g,"$1"):o.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")});var za,lo,Wa,is,ja,Ua,$a,Ga,Ws,co,fo,U,q,Ut,M,W,Jt,we,Xt,Mt,ye,ai,Se,uo,te,ss,zs,po,it,Pe,js=D(()=>{"use strict";ho();es();za=new Set(["!","?","+","*","@"]),lo=o=>za.has(o),Wa="(?!(?:^|/)\\.\\.?(?:$|/))",is="(?!\\.)",ja=new Set(["[","."]),Ua=new Set(["..","."]),$a=new Set("().*{}+?[]^$\\!"),Ga=o=>o.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ws="[^/]",co=Ws+"*?",fo=Ws+"+?",it=class it{constructor(t,e,i={}){y(this,Se);u(this,"type");y(this,U);y(this,q);y(this,Ut,!1);y(this,M,[]);y(this,W);y(this,Jt);y(this,we);y(this,Xt,!1);y(this,Mt);y(this,ye);y(this,ai,!1);this.type=t,t&&f(this,q,!0),f(this,W,e),f(this,U,r(this,W)?r(r(this,W),U):this),f(this,Mt,r(this,U)===this?i:r(r(this,U),Mt)),f(this,we,r(this,U)===this?[]:r(r(this,U),we)),t==="!"&&!r(r(this,U),Xt)&&r(this,we).push(this),f(this,Jt,r(this,W)?r(r(this,W),M).length:0)}get hasMagic(){if(r(this,q)!==void 0)return r(this,q);for(let t of r(this,M))if(typeof t!="string"&&(t.type||t.hasMagic))return f(this,q,!0);return r(this,q)}toString(){return r(this,ye)!==void 0?r(this,ye):this.type?f(this,ye,this.type+"("+r(this,M).map(t=>String(t)).join("|")+")"):f(this,ye,r(this,M).map(t=>String(t)).join(""))}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof it&&r(e,W)===this))throw new Error("invalid part: "+e);r(this,M).push(e)}}toJSON(){var e;let t=this.type===null?r(this,M).slice().map(i=>typeof i=="string"?i:i.toJSON()):[this.type,...r(this,M).map(i=>i.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===r(this,U)||r(r(this,U),Xt)&&((e=r(this,W))==null?void 0:e.type)==="!")&&t.push({}),t}isStart(){var e;if(r(this,U)===this)return!0;if(!((e=r(this,W))!=null&&e.isStart()))return!1;if(r(this,Jt)===0)return!0;let t=r(this,W);for(let i=0;i<r(this,Jt);i++){let s=r(t,M)[i];if(!(s instanceof it&&s.type==="!"))return!1}return!0}isEnd(){var e,i,s;if(r(this,U)===this||((e=r(this,W))==null?void 0:e.type)==="!")return!0;if(!((i=r(this,W))!=null&&i.isEnd()))return!1;if(!this.type)return(s=r(this,W))==null?void 0:s.isEnd();let t=r(this,W)?r(r(this,W),M).length:0;return r(this,Jt)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let e=new it(this.type,t);for(let i of r(this,M))e.copyIn(i);return e}static fromGlob(t,e={}){var s;let i=new it(null,void 0,e);return m(s=it,te,ss).call(s,t,i,0,e),i}toMMPattern(){if(this!==r(this,U))return r(this,U).toMMPattern();let t=this.toString(),[e,i,s,n]=this.toRegExpSource();if(!(s||r(this,q)||r(this,Mt).nocase&&!r(this,Mt).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let l=(r(this,Mt).nocase?"i":"")+(n?"u":"");return Object.assign(new RegExp(`^${e}$`,l),{_src:e,_glob:t})}get options(){return r(this,Mt)}toRegExpSource(t){var h;let e=t!=null?t:!!r(this,Mt).dot;if(r(this,U)===this&&m(this,Se,uo).call(this),!this.type){let c=this.isStart()&&this.isEnd(),p=r(this,M).map(x=>{var R;let[g,C,S,k]=typeof x=="string"?m(R=it,te,po).call(R,x,r(this,q),c):x.toRegExpSource(t);return f(this,q,r(this,q)||S),f(this,Ut,r(this,Ut)||k),g}).join(""),d="";if(this.isStart()&&typeof r(this,M)[0]=="string"&&!(r(this,M).length===1&&Ua.has(r(this,M)[0]))){let g=ja,C=e&&g.has(p.charAt(0))||p.startsWith("\\.")&&g.has(p.charAt(2))||p.startsWith("\\.\\.")&&g.has(p.charAt(4)),S=!e&&!t&&g.has(p.charAt(0));d=C?Wa:S?is:""}let w="";return this.isEnd()&&r(r(this,U),Xt)&&((h=r(this,W))==null?void 0:h.type)==="!"&&(w="(?:$|\\/)"),[d+p+w,Et(p),f(this,q,!!r(this,q)),r(this,Ut)]}let i=this.type==="*"||this.type==="+",s=this.type==="!"?"(?:(?!(?:":"(?:",n=m(this,Se,zs).call(this,e);if(this.isStart()&&this.isEnd()&&!n&&this.type!=="!"){let c=this.toString();return f(this,M,[c]),this.type=null,f(this,q,void 0),[c,Et(this.toString()),!1,!1]}let a=!i||t||e||!is?"":m(this,Se,zs).call(this,!0);a===n&&(a=""),a&&(n=`(?:${n})(?:${a})*?`);let l="";if(this.type==="!"&&r(this,ai))l=(this.isStart()&&!e?is:"")+fo;else{let c=this.type==="!"?"))"+(this.isStart()&&!e&&!t?is:"")+co+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;l=s+n+c}return[l,Et(n),f(this,q,!!r(this,q)),r(this,Ut)]}};U=new WeakMap,q=new WeakMap,Ut=new WeakMap,M=new WeakMap,W=new WeakMap,Jt=new WeakMap,we=new WeakMap,Xt=new WeakMap,Mt=new WeakMap,ye=new WeakMap,ai=new WeakMap,Se=new WeakSet,uo=function(){if(this!==r(this,U))throw new Error("should only call on root");if(r(this,Xt))return this;this.toString(),f(this,Xt,!0);let t;for(;t=r(this,we).pop();){if(t.type!=="!")continue;let e=t,i=r(e,W);for(;i;){for(let s=r(e,Jt)+1;!i.type&&s<r(i,M).length;s++)for(let n of r(t,M)){if(typeof n=="string")throw new Error("string part in extglob AST??");n.copyIn(r(i,M)[s])}e=i,i=r(e,W)}}return this},te=new WeakSet,ss=function(t,e,i,s){var E,x;let n=!1,a=!1,l=-1,h=!1;if(e.type===null){let g=i,C="";for(;g<t.length;){let S=t.charAt(g++);if(n||S==="\\"){n=!n,C+=S;continue}if(a){g===l+1?(S==="^"||S==="!")&&(h=!0):S==="]"&&!(g===l+2&&h)&&(a=!1),C+=S;continue}else if(S==="["){a=!0,l=g,h=!1,C+=S;continue}if(!s.noext&&lo(S)&&t.charAt(g)==="("){e.push(C),C="";let k=new it(S,e);g=m(E=it,te,ss).call(E,t,k,g,s),e.push(k);continue}C+=S}return e.push(C),g}let c=i+1,p=new it(null,e),d=[],w="";for(;c<t.length;){let g=t.charAt(c++);if(n||g==="\\"){n=!n,w+=g;continue}if(a){c===l+1?(g==="^"||g==="!")&&(h=!0):g==="]"&&!(c===l+2&&h)&&(a=!1),w+=g;continue}else if(g==="["){a=!0,l=c,h=!1,w+=g;continue}if(lo(g)&&t.charAt(c)==="("){p.push(w),w="";let C=new it(g,p);p.push(C),c=m(x=it,te,ss).call(x,t,C,c,s);continue}if(g==="|"){p.push(w),w="",d.push(p),p=new it(null,e);continue}if(g===")")return w===""&&r(e,M).length===0&&f(e,ai,!0),p.push(w),w="",e.push(...d,p),c;w+=g}return e.type=null,f(e,q,void 0),f(e,M,[t.substring(i-1)]),c},zs=function(t){return r(this,M).map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[i,s,n,a]=e.toRegExpSource(t);return f(this,Ut,r(this,Ut)||a),i}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")},po=function(t,e,i=!1){let s=!1,n="",a=!1;for(let l=0;l<t.length;l++){let h=t.charAt(l);if(s){s=!1,n+=($a.has(h)?"\\":"")+h;continue}if(h==="\\"){l===t.length-1?n+="\\\\":s=!0;continue}if(h==="["){let[c,p,d,w]=ao(t,l);if(d){n+=c,a=a||p,l+=d-1,e=e||w;continue}}if(h==="*"){i&&t==="*"?n+=fo:n+=co,e=!0;continue}if(h==="?"){n+=Ws,e=!0;continue}n+=Ga(h)}return[n,Et(t),!!e,a]},y(it,te);Pe=it});var Le,Us=D(()=>{"use strict";Le=(o,{windowsPathsNoEscape:t=!1}={})=>t?o.replace(/[?*()[\]]/g,"[$&]"):o.replace(/[?*()[\]\\]/g,"\\$&")});var wo,st,qa,Ha,Qa,Ka,Va,Za,Ya,Ja,Xa,th,eh,ih,sh,rh,oh,nh,ah,hh,yo,So,bo,mo,lh,J,ch,fh,uh,ph,dh,mt,mh,Eo,gh,wh,go,yh,ht,ee=D(()=>{"use strict";wo=De(ro(),1);oo();js();Us();es();js();Us();es();st=(o,t,e={})=>(oi(t),!e.nocomment&&t.charAt(0)==="#"?!1:new ht(t,e).match(o)),qa=/^\*+([^+@!?\*\[\(]*)$/,Ha=o=>t=>!t.startsWith(".")&&t.endsWith(o),Qa=o=>t=>t.endsWith(o),Ka=o=>(o=o.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(o)),Va=o=>(o=o.toLowerCase(),t=>t.toLowerCase().endsWith(o)),Za=/^\*+\.\*+$/,Ya=o=>!o.startsWith(".")&&o.includes("."),Ja=o=>o!=="."&&o!==".."&&o.includes("."),Xa=/^\.\*+$/,th=o=>o!=="."&&o!==".."&&o.startsWith("."),eh=/^\*+$/,ih=o=>o.length!==0&&!o.startsWith("."),sh=o=>o.length!==0&&o!=="."&&o!=="..",rh=/^\?+([^+@!?\*\[\(]*)?$/,oh=([o,t=""])=>{let e=yo([o]);return t?(t=t.toLowerCase(),i=>e(i)&&i.toLowerCase().endsWith(t)):e},nh=([o,t=""])=>{let e=So([o]);return t?(t=t.toLowerCase(),i=>e(i)&&i.toLowerCase().endsWith(t)):e},ah=([o,t=""])=>{let e=So([o]);return t?i=>e(i)&&i.endsWith(t):e},hh=([o,t=""])=>{let e=yo([o]);return t?i=>e(i)&&i.endsWith(t):e},yo=([o])=>{let t=o.length;return e=>e.length===t&&!e.startsWith(".")},So=([o])=>{let t=o.length;return e=>e.length===t&&e!=="."&&e!==".."},bo=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",mo={win32:{sep:"\\"},posix:{sep:"/"}},lh=bo==="win32"?mo.win32.sep:mo.posix.sep;st.sep=lh;J=Symbol("globstar **");st.GLOBSTAR=J;ch="[^/]",fh=ch+"*?",uh="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ph="(?:(?!(?:\\/|^)\\.).)*?",dh=(o,t={})=>e=>st(e,o,t);st.filter=dh;mt=(o,t={})=>Object.assign({},o,t),mh=o=>{if(!o||typeof o!="object"||!Object.keys(o).length)return st;let t=st;return Object.assign((i,s,n={})=>t(i,s,mt(o,n)),{Minimatch:class extends t.Minimatch{constructor(s,n={}){super(s,mt(o,n))}static defaults(s){return t.defaults(mt(o,s)).Minimatch}},AST:class extends t.AST{constructor(s,n,a={}){super(s,n,mt(o,a))}static fromGlob(s,n={}){return t.AST.fromGlob(s,mt(o,n))}},unescape:(i,s={})=>t.unescape(i,mt(o,s)),escape:(i,s={})=>t.escape(i,mt(o,s)),filter:(i,s={})=>t.filter(i,mt(o,s)),defaults:i=>t.defaults(mt(o,i)),makeRe:(i,s={})=>t.makeRe(i,mt(o,s)),braceExpand:(i,s={})=>t.braceExpand(i,mt(o,s)),match:(i,s,n={})=>t.match(i,s,mt(o,n)),sep:t.sep,GLOBSTAR:J})};st.defaults=mh;Eo=(o,t={})=>(oi(o),t.nobrace||!/\{(?:(?!\{).)*\}/.test(o)?[o]:(0,wo.default)(o));st.braceExpand=Eo;gh=(o,t={})=>new ht(o,t).makeRe();st.makeRe=gh;wh=(o,t,e={})=>{let i=new ht(t,e);return o=o.filter(s=>i.match(s)),i.options.nonull&&!o.length&&o.push(t),o};st.match=wh;go=/[?*]|[+@!]\(.*?\)|\[|\]/,yh=o=>o.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ht=class{constructor(t,e={}){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");oi(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||bo,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,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=e.windowsNoMagicRoot!==void 0?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(let t of this.set)for(let e of t)if(typeof e!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,e=this.options;if(!e.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...n)=>console.error(...n)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let s=this.globParts.map((n,a,l)=>{if(this.isWindows&&this.windowsNoMagicRoot){let h=n[0]===""&&n[1]===""&&(n[2]==="?"||!go.test(n[2]))&&!go.test(n[3]),c=/^[a-z]:/i.test(n[0]);if(h)return[...n.slice(0,4),...n.slice(4).map(p=>this.parse(p))];if(c)return[n[0],...n.slice(1).map(p=>this.parse(p))]}return n.map(h=>this.parse(h))});if(this.debug(this.pattern,s),this.set=s.filter(n=>n.indexOf(!1)===-1),this.isWindows)for(let n=0;n<this.set.length;n++){let a=this.set[n];a[0]===""&&a[1]===""&&this.globParts[n][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let i=0;i<t.length;i++)for(let s=0;s<t[i].length;s++)t[i][s]==="**"&&(t[i][s]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):e>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(e=>{let i=-1;for(;(i=e.indexOf("**",i+1))!==-1;){let s=i;for(;e[s+1]==="**";)s++;s!==i&&e.splice(i,s-i)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((i,s)=>{let n=i[i.length-1];return s==="**"&&n==="**"?i:s===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(i.pop(),i):(i.push(s),i)},[]),e.length===0?[""]:e))}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++){let n=t[s];s===1&&n===""&&t[0]===""||(n==="."||n==="")&&(e=!0,t.splice(s,1),s--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let i=0;for(;(i=t.indexOf("..",i+1))!==-1;){let s=t[i-1];s&&s!=="."&&s!==".."&&s!=="**"&&(e=!0,t.splice(i-1,2),i-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let i of t){let s=-1;for(;(s=i.indexOf("**",s+1))!==-1;){let a=s;for(;i[a+1]==="**";)a++;a>s&&i.splice(s+1,a-s);let l=i[s+1],h=i[s+2],c=i[s+3];if(l!==".."||!h||h==="."||h===".."||!c||c==="."||c==="..")continue;e=!0,i.splice(s,1);let p=i.slice(0);p[s]="**",t.push(p),s--}if(!this.preserveMultipleSlashes){for(let a=1;a<i.length-1;a++){let l=i[a];a===1&&l===""&&i[0]===""||(l==="."||l==="")&&(e=!0,i.splice(a,1),a--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(e=!0,i.pop())}let n=0;for(;(n=i.indexOf("..",n+1))!==-1;){let a=i[n-1];if(a&&a!=="."&&a!==".."&&a!=="**"){e=!0;let h=n===1&&i[n+1]==="**"?["."]:[];i.splice(n-1,2,...h),i.length===0&&i.push(""),n-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let i=e+1;i<t.length;i++){let s=this.partsMatch(t[e],t[i],!this.preserveMultipleSlashes);if(s){t[e]=[],t[i]=s;break}}return t.filter(e=>e.length)}partsMatch(t,e,i=!1){let s=0,n=0,a=[],l="";for(;s<t.length&&n<e.length;)if(t[s]===e[n])a.push(l==="b"?e[n]:t[s]),s++,n++;else if(i&&t[s]==="**"&&e[n]===t[s+1])a.push(t[s]),s++;else if(i&&e[n]==="**"&&t[s]===e[n+1])a.push(e[n]),n++;else if(t[s]==="*"&&e[n]&&(this.options.dot||!e[n].startsWith("."))&&e[n]!=="**"){if(l==="b")return!1;l="a",a.push(t[s]),s++,n++}else if(e[n]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(l==="a")return!1;l="b",a.push(e[n]),s++,n++}else return!1;return t.length===e.length&&a}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,i=0;for(let s=0;s<t.length&&t.charAt(s)==="!";s++)e=!e,i++;i&&(this.pattern=t.slice(i)),this.negate=e}matchOne(t,e,i=!1){let s=this.options;if(this.isWindows){let g=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),C=!g&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),S=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),k=!S&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),R=C?3:g?0:void 0,A=k?3:S?0:void 0;if(typeof R=="number"&&typeof A=="number"){let[_,I]=[t[R],e[A]];_.toLowerCase()===I.toLowerCase()&&(e[A]=_,A>R?e=e.slice(A):R>A&&(t=t.slice(R)))}}let{optimizationLevel:n=1}=this.options;n>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var a=0,l=0,h=t.length,c=e.length;a<h&&l<c;a++,l++){this.debug("matchOne loop");var p=e[l],d=t[a];if(this.debug(e,p,d),p===!1)return!1;if(p===J){this.debug("GLOBSTAR",[e,p,d]);var w=a,E=l+1;if(E===c){for(this.debug("** at the end");a<h;a++)if(t[a]==="."||t[a]===".."||!s.dot&&t[a].charAt(0)===".")return!1;return!0}for(;w<h;){var x=t[w];if(this.debug(`
|
|
2
|
-
globstar while`,t,w,e,E,x),this.matchOne(t.slice(w),e.slice(E),i))return this.debug("globstar found match!",w,h,x),!0;if(x==="."||x===".."||!s.dot&&x.charAt(0)==="."){this.debug("dot detected!",t,w,e,E);break}this.debug("globstar swallow a segment, and continue"),w++}return!!(i&&(this.debug(`
|
|
3
|
-
>>> no match, partial?`,t,w,e,E),w===h))}let g;if(typeof p=="string"?(g=d===p,this.debug("string match",p,d,g)):(g=p.test(d),this.debug("pattern match",p,d,g)),!g)return!1}if(a===h&&l===c)return!0;if(a===h)return i;if(l===c)return a===h-1&&t[a]==="";throw new Error("wtf?")}braceExpand(){return Eo(this.pattern,this.options)}parse(t){oi(t);let e=this.options;if(t==="**")return J;if(t==="")return"";let i,s=null;(i=t.match(eh))?s=e.dot?sh:ih:(i=t.match(qa))?s=(e.nocase?e.dot?Va:Ka:e.dot?Qa:Ha)(i[1]):(i=t.match(rh))?s=(e.nocase?e.dot?nh:oh:e.dot?ah:hh)(i):(i=t.match(Za))?s=e.dot?Ja:Ya:(i=t.match(Xa))&&(s=th);let n=Pe.fromGlob(t,this.options).toMMPattern();return s&&typeof n=="object"&&Reflect.defineProperty(n,"test",{value:s}),n}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,i=e.noglobstar?fh:e.dot?uh:ph,s=new Set(e.nocase?["i"]:[]),n=t.map(h=>{let c=h.map(p=>{if(p instanceof RegExp)for(let d of p.flags.split(""))s.add(d);return typeof p=="string"?yh(p):p===J?J:p._src});return c.forEach((p,d)=>{let w=c[d+1],E=c[d-1];p!==J||E===J||(E===void 0?w!==void 0&&w!==J?c[d+1]="(?:\\/|"+i+"\\/)?"+w:c[d]=i:w===void 0?c[d-1]=E+"(?:\\/|"+i+")?":w!==J&&(c[d-1]=E+"(?:\\/|\\/"+i+"\\/)"+w,c[d+1]=J))}),c.filter(p=>p!==J).join("/")}).join("|"),[a,l]=t.length>1?["(?:",")"]:["",""];n="^"+a+n+l+"$",this.negate&&(n="^(?!"+n+").+$");try{this.regexp=new RegExp(n,[...s].join(""))}catch(h){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;let i=this.options;this.isWindows&&(t=t.split("\\").join("/"));let s=this.slashSplit(t);this.debug(this.pattern,"split",s);let n=this.set;this.debug(this.pattern,"set",n);let a=s[s.length-1];if(!a)for(let l=s.length-2;!a&&l>=0;l--)a=s[l];for(let l=0;l<n.length;l++){let h=n[l],c=s;if(i.matchBase&&h.length===1&&(c=[a]),this.matchOne(c,h,e))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(t){return st.defaults(t).Minimatch}};st.AST=Pe;st.Minimatch=ht;st.escape=Le;st.unescape=Et});var Me,Ro,$s,To,ns,Co,xo,Sh,oc,ie,Oo,Ne,Be,be,Gs,ko,vo,Ct,lt,xt,kt,Ie,ze,$,vt,j,L,O,rt,ct,X,H,Rt,Q,Tt,Ot,ft,Ft,ne,ot,b,qs,Ee,$t,ci,ut,Fo,Ce,We,fi,se,re,Hs,rs,os,P,Qs,hi,oe,Ks,Vs,li,Ao=D(()=>{"use strict";Me=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ro=new Set,$s=typeof process=="object"&&process?process:{},To=(o,t,e,i)=>{typeof $s.emitWarning=="function"?$s.emitWarning(o,t,e,i):console.error(`[${e}] ${t}: ${o}`)},ns=globalThis.AbortController,Co=globalThis.AbortSignal;if(typeof ns=="undefined"){Co=class{constructor(){u(this,"onabort");u(this,"_onabort",[]);u(this,"reason");u(this,"aborted",!1)}addEventListener(i,s){this._onabort.push(s)}},ns=class{constructor(){u(this,"signal",new Co);t()}abort(i){var s,n;if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=!0;for(let a of this.signal._onabort)a(i);(n=(s=this.signal).onabort)==null||n.call(s,i)}}};let o=((xo=$s.env)==null?void 0:xo.LRU_CACHE_IGNORE_AC_WARNING)!=="1",t=()=>{o&&(o=!1,To("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))}}Sh=o=>!Ro.has(o),oc=Symbol("type"),ie=o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),Oo=o=>ie(o)?o<=Math.pow(2,8)?Uint8Array:o<=Math.pow(2,16)?Uint16Array:o<=Math.pow(2,32)?Uint32Array:o<=Number.MAX_SAFE_INTEGER?Ne:null:null,Ne=class extends Array{constructor(t){super(t),this.fill(0)}},be=class be{constructor(t,e){u(this,"heap");u(this,"length");if(!r(be,Be))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}static create(t){let e=Oo(t);if(!e)return[];f(be,Be,!0);let i=new be(t,e);return f(be,Be,!1),i}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}};Be=new WeakMap,y(be,Be,!1);Gs=be,Vs=class Vs{constructor(t){y(this,b);y(this,Ct);y(this,lt);y(this,xt);y(this,kt);y(this,Ie);y(this,ze);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,$);y(this,vt);y(this,j);y(this,L);y(this,O);y(this,rt);y(this,ct);y(this,X);y(this,H);y(this,Rt);y(this,Q);y(this,Tt);y(this,Ot);y(this,ft);y(this,Ft);y(this,ne);y(this,ot);y(this,Ee,()=>{});y(this,$t,()=>{});y(this,ci,()=>{});y(this,ut,()=>!1);y(this,Ce,t=>{});y(this,We,(t,e,i)=>{});y(this,fi,(t,e,i,s)=>{if(i||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});u(this,ko,"LRUCache");let{max:e=0,ttl:i,ttlResolution:s=1,ttlAutopurge:n,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:h,dispose:c,disposeAfter:p,noDisposeOnSet:d,noUpdateTTL:w,maxSize:E=0,maxEntrySize:x=0,sizeCalculation:g,fetchMethod:C,memoMethod:S,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:_,ignoreFetchAbort:I}=t;if(e!==0&&!ie(e))throw new TypeError("max option must be a nonnegative integer");let St=e?Oo(e):Array;if(!St)throw new Error("invalid max value: "+e);if(f(this,Ct,e),f(this,lt,E),this.maxEntrySize=x||r(this,lt),this.sizeCalculation=g,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(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,ze,S),C!==void 0&&typeof C!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,Ie,C),f(this,ne,!!C),f(this,j,new Map),f(this,L,new Array(e).fill(void 0)),f(this,O,new Array(e).fill(void 0)),f(this,rt,new St(e)),f(this,ct,new St(e)),f(this,X,0),f(this,H,0),f(this,Rt,Gs.create(e)),f(this,$,0),f(this,vt,0),typeof c=="function"&&f(this,xt,c),typeof p=="function"?(f(this,kt,p),f(this,Q,[])):(f(this,kt,void 0),f(this,Q,void 0)),f(this,Ft,!!r(this,xt)),f(this,ot,!!r(this,kt)),this.noDisposeOnSet=!!d,this.noUpdateTTL=!!w,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!_,this.ignoreFetchAbort=!!I,this.maxEntrySize!==0){if(r(this,lt)!==0&&!ie(r(this,lt)))throw new TypeError("maxSize must be a positive integer if specified");if(!ie(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");m(this,b,Fo).call(this)}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=ie(s)||s===0?s:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!ie(this.ttl))throw new TypeError("ttl must be a positive integer if specified");m(this,b,qs).call(this)}if(r(this,Ct)===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,Ct)&&!r(this,lt)){let me="LRU_CACHE_UNBOUNDED";Sh(me)&&(Ro.add(me),To("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",me,Vs))}}static unsafeExposeInternals(t){return{starts:r(t,Ot),ttls:r(t,ft),sizes:r(t,Tt),keyMap:r(t,j),keyList:r(t,L),valList:r(t,O),next:r(t,rt),prev:r(t,ct),get head(){return r(t,X)},get tail(){return r(t,H)},free:r(t,Rt),isBackgroundFetch:e=>{var i;return m(i=t,b,P).call(i,e)},backgroundFetch:(e,i,s,n)=>{var a;return m(a=t,b,os).call(a,e,i,s,n)},moveToTail:e=>{var i;return m(i=t,b,hi).call(i,e)},indexes:e=>{var i;return m(i=t,b,se).call(i,e)},rindexes:e=>{var i;return m(i=t,b,re).call(i,e)},isStale:e=>{var i;return r(i=t,ut).call(i,e)}}}get max(){return r(this,Ct)}get maxSize(){return r(this,lt)}get calculatedSize(){return r(this,vt)}get size(){return r(this,$)}get fetchMethod(){return r(this,Ie)}get memoMethod(){return r(this,ze)}get dispose(){return r(this,xt)}get disposeAfter(){return r(this,kt)}getRemainingTTL(t){return r(this,j).has(t)?1/0:0}*entries(){for(let t of m(this,b,se).call(this))r(this,O)[t]!==void 0&&r(this,L)[t]!==void 0&&!m(this,b,P).call(this,r(this,O)[t])&&(yield[r(this,L)[t],r(this,O)[t]])}*rentries(){for(let t of m(this,b,re).call(this))r(this,O)[t]!==void 0&&r(this,L)[t]!==void 0&&!m(this,b,P).call(this,r(this,O)[t])&&(yield[r(this,L)[t],r(this,O)[t]])}*keys(){for(let t of m(this,b,se).call(this)){let e=r(this,L)[t];e!==void 0&&!m(this,b,P).call(this,r(this,O)[t])&&(yield e)}}*rkeys(){for(let t of m(this,b,re).call(this)){let e=r(this,L)[t];e!==void 0&&!m(this,b,P).call(this,r(this,O)[t])&&(yield e)}}*values(){for(let t of m(this,b,se).call(this))r(this,O)[t]!==void 0&&!m(this,b,P).call(this,r(this,O)[t])&&(yield r(this,O)[t])}*rvalues(){for(let t of m(this,b,re).call(this))r(this,O)[t]!==void 0&&!m(this,b,P).call(this,r(this,O)[t])&&(yield r(this,O)[t])}[(vo=Symbol.iterator,ko=Symbol.toStringTag,vo)](){return this.entries()}find(t,e={}){for(let i of m(this,b,se).call(this)){let s=r(this,O)[i],n=m(this,b,P).call(this,s)?s.__staleWhileFetching:s;if(n!==void 0&&t(n,r(this,L)[i],this))return this.get(r(this,L)[i],e)}}forEach(t,e=this){for(let i of m(this,b,se).call(this)){let s=r(this,O)[i],n=m(this,b,P).call(this,s)?s.__staleWhileFetching:s;n!==void 0&&t.call(e,n,r(this,L)[i],this)}}rforEach(t,e=this){for(let i of m(this,b,re).call(this)){let s=r(this,O)[i],n=m(this,b,P).call(this,s)?s.__staleWhileFetching:s;n!==void 0&&t.call(e,n,r(this,L)[i],this)}}purgeStale(){let t=!1;for(let e of m(this,b,re).call(this,{allowStale:!0}))r(this,ut).call(this,e)&&(m(this,b,oe).call(this,r(this,L)[e],"expire"),t=!0);return t}info(t){let e=r(this,j).get(t);if(e===void 0)return;let i=r(this,O)[e],s=m(this,b,P).call(this,i)?i.__staleWhileFetching:i;if(s===void 0)return;let n={value:s};if(r(this,ft)&&r(this,Ot)){let a=r(this,ft)[e],l=r(this,Ot)[e];if(a&&l){let h=a-(Me.now()-l);n.ttl=h,n.start=Date.now()}}return r(this,Tt)&&(n.size=r(this,Tt)[e]),n}dump(){let t=[];for(let e of m(this,b,se).call(this,{allowStale:!0})){let i=r(this,L)[e],s=r(this,O)[e],n=m(this,b,P).call(this,s)?s.__staleWhileFetching:s;if(n===void 0||i===void 0)continue;let a={value:n};if(r(this,ft)&&r(this,Ot)){a.ttl=r(this,ft)[e];let l=Me.now()-r(this,Ot)[e];a.start=Math.floor(Date.now()-l)}r(this,Tt)&&(a.size=r(this,Tt)[e]),t.unshift([i,a])}return t}load(t){this.clear();for(let[e,i]of t){if(i.start){let s=Date.now()-i.start;i.start=Me.now()-s}this.set(e,i.value,i)}}set(t,e,i={}){var w,E,x,g,C;if(e===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:n,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:h}=i,{noUpdateTTL:c=this.noUpdateTTL}=i,p=r(this,fi).call(this,t,e,i.size||0,l);if(this.maxEntrySize&&p>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=!0),m(this,b,oe).call(this,t,"set"),this;let d=r(this,$)===0?void 0:r(this,j).get(t);if(d===void 0)d=r(this,$)===0?r(this,H):r(this,Rt).length!==0?r(this,Rt).pop():r(this,$)===r(this,Ct)?m(this,b,rs).call(this,!1):r(this,$),r(this,L)[d]=t,r(this,O)[d]=e,r(this,j).set(t,d),r(this,rt)[r(this,H)]=d,r(this,ct)[d]=r(this,H),f(this,H,d),Zi(this,$)._++,r(this,We).call(this,d,p,h),h&&(h.set="add"),c=!1;else{m(this,b,hi).call(this,d);let S=r(this,O)[d];if(e!==S){if(r(this,ne)&&m(this,b,P).call(this,S)){S.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:k}=S;k!==void 0&&!a&&(r(this,Ft)&&((w=r(this,xt))==null||w.call(this,k,t,"set")),r(this,ot)&&((E=r(this,Q))==null||E.push([k,t,"set"])))}else a||(r(this,Ft)&&((x=r(this,xt))==null||x.call(this,S,t,"set")),r(this,ot)&&((g=r(this,Q))==null||g.push([S,t,"set"])));if(r(this,Ce).call(this,d),r(this,We).call(this,d,p,h),r(this,O)[d]=e,h){h.set="replace";let k=S&&m(this,b,P).call(this,S)?S.__staleWhileFetching:S;k!==void 0&&(h.oldValue=k)}}else h&&(h.set="update")}if(s!==0&&!r(this,ft)&&m(this,b,qs).call(this),r(this,ft)&&(c||r(this,ci).call(this,d,s,n),h&&r(this,$t).call(this,h,d)),!a&&r(this,ot)&&r(this,Q)){let S=r(this,Q),k;for(;k=S==null?void 0:S.shift();)(C=r(this,kt))==null||C.call(this,...k)}return this}pop(){var t;try{for(;r(this,$);){let e=r(this,O)[r(this,X)];if(m(this,b,rs).call(this,!0),m(this,b,P).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(r(this,ot)&&r(this,Q)){let e=r(this,Q),i;for(;i=e==null?void 0:e.shift();)(t=r(this,kt))==null||t.call(this,...i)}}}has(t,e={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:s}=e,n=r(this,j).get(t);if(n!==void 0){let a=r(this,O)[n];if(m(this,b,P).call(this,a)&&a.__staleWhileFetching===void 0)return!1;if(r(this,ut).call(this,n))s&&(s.has="stale",r(this,$t).call(this,s,n));else return i&&r(this,Ee).call(this,n),s&&(s.has="hit",r(this,$t).call(this,s,n)),!0}else s&&(s.has="miss");return!1}peek(t,e={}){let{allowStale:i=this.allowStale}=e,s=r(this,j).get(t);if(s===void 0||!i&&r(this,ut).call(this,s))return;let n=r(this,O)[s];return m(this,b,P).call(this,n)?n.__staleWhileFetching:n}async fetch(t,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:h=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:p=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:w=this.allowStaleOnFetchRejection,ignoreFetchAbort:E=this.ignoreFetchAbort,allowStaleOnFetchAbort:x=this.allowStaleOnFetchAbort,context:g,forceRefresh:C=!1,status:S,signal:k}=e;if(!r(this,ne))return S&&(S.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,status:S});let R={allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,ttl:a,noDisposeOnSet:l,size:h,sizeCalculation:c,noUpdateTTL:p,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:x,ignoreFetchAbort:E,status:S,signal:k},A=r(this,j).get(t);if(A===void 0){S&&(S.fetch="miss");let _=m(this,b,os).call(this,t,A,R,g);return _.__returned=_}else{let _=r(this,O)[A];if(m(this,b,P).call(this,_)){let Vi=i&&_.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",Vi&&(S.returnedStale=!0)),Vi?_.__staleWhileFetching:_.__returned=_}let I=r(this,ut).call(this,A);if(!C&&!I)return S&&(S.fetch="hit"),m(this,b,hi).call(this,A),s&&r(this,Ee).call(this,A),S&&r(this,$t).call(this,S,A),_;let St=m(this,b,os).call(this,t,A,R,g),bt=St.__staleWhileFetching!==void 0&&i;return S&&(S.fetch=I?"stale":"refresh",bt&&I&&(S.returnedStale=!0)),bt?St.__staleWhileFetching:St.__returned=St}}async forceFetch(t,e={}){let i=await this.fetch(t,e);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,e={}){let i=r(this,ze);if(!i)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:n,...a}=e,l=this.get(t,a);if(!n&&l!==void 0)return l;let h=i(t,l,{options:a,context:s});return this.set(t,h,a),h}get(t,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:a}=e,l=r(this,j).get(t);if(l!==void 0){let h=r(this,O)[l],c=m(this,b,P).call(this,h);return a&&r(this,$t).call(this,a,l),r(this,ut).call(this,l)?(a&&(a.get="stale"),c?(a&&i&&h.__staleWhileFetching!==void 0&&(a.returnedStale=!0),i?h.__staleWhileFetching:void 0):(n||m(this,b,oe).call(this,t,"expire"),a&&i&&(a.returnedStale=!0),i?h:void 0)):(a&&(a.get="hit"),c?h.__staleWhileFetching:(m(this,b,hi).call(this,l),s&&r(this,Ee).call(this,l),h))}else a&&(a.get="miss")}delete(t){return m(this,b,oe).call(this,t,"delete")}clear(){return m(this,b,Ks).call(this,"delete")}};Ct=new WeakMap,lt=new WeakMap,xt=new WeakMap,kt=new WeakMap,Ie=new WeakMap,ze=new WeakMap,$=new WeakMap,vt=new WeakMap,j=new WeakMap,L=new WeakMap,O=new WeakMap,rt=new WeakMap,ct=new WeakMap,X=new WeakMap,H=new WeakMap,Rt=new WeakMap,Q=new WeakMap,Tt=new WeakMap,Ot=new WeakMap,ft=new WeakMap,Ft=new WeakMap,ne=new WeakMap,ot=new WeakMap,b=new WeakSet,qs=function(){let t=new Ne(r(this,Ct)),e=new Ne(r(this,Ct));f(this,ft,t),f(this,Ot,e),f(this,ci,(n,a,l=Me.now())=>{if(e[n]=a!==0?l:0,t[n]=a,a!==0&&this.ttlAutopurge){let h=setTimeout(()=>{r(this,ut).call(this,n)&&m(this,b,oe).call(this,r(this,L)[n],"expire")},a+1);h.unref&&h.unref()}}),f(this,Ee,n=>{e[n]=t[n]!==0?Me.now():0}),f(this,$t,(n,a)=>{if(t[a]){let l=t[a],h=e[a];if(!l||!h)return;n.ttl=l,n.start=h,n.now=i||s();let c=n.now-h;n.remainingTTL=l-c}});let i=0,s=()=>{let n=Me.now();if(this.ttlResolution>0){i=n;let a=setTimeout(()=>i=0,this.ttlResolution);a.unref&&a.unref()}return n};this.getRemainingTTL=n=>{let a=r(this,j).get(n);if(a===void 0)return 0;let l=t[a],h=e[a];if(!l||!h)return 1/0;let c=(i||s())-h;return l-c},f(this,ut,n=>{let a=e[n],l=t[n];return!!l&&!!a&&(i||s())-a>l})},Ee=new WeakMap,$t=new WeakMap,ci=new WeakMap,ut=new WeakMap,Fo=function(){let t=new Ne(r(this,Ct));f(this,vt,0),f(this,Tt,t),f(this,Ce,e=>{f(this,vt,r(this,vt)-t[e]),t[e]=0}),f(this,fi,(e,i,s,n)=>{if(m(this,b,P).call(this,i))return 0;if(!ie(s))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(s=n(i,e),!ie(s))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 s}),f(this,We,(e,i,s)=>{if(t[e]=i,r(this,lt)){let n=r(this,lt)-t[e];for(;r(this,vt)>n;)m(this,b,rs).call(this,!0)}f(this,vt,r(this,vt)+t[e]),s&&(s.entrySize=i,s.totalCalculatedSize=r(this,vt))})},Ce=new WeakMap,We=new WeakMap,fi=new WeakMap,se=function*({allowStale:t=this.allowStale}={}){if(r(this,$))for(let e=r(this,H);!(!m(this,b,Hs).call(this,e)||((t||!r(this,ut).call(this,e))&&(yield e),e===r(this,X)));)e=r(this,ct)[e]},re=function*({allowStale:t=this.allowStale}={}){if(r(this,$))for(let e=r(this,X);!(!m(this,b,Hs).call(this,e)||((t||!r(this,ut).call(this,e))&&(yield e),e===r(this,H)));)e=r(this,rt)[e]},Hs=function(t){return t!==void 0&&r(this,j).get(r(this,L)[t])===t},rs=function(t){var n,a;let e=r(this,X),i=r(this,L)[e],s=r(this,O)[e];return r(this,ne)&&m(this,b,P).call(this,s)?s.__abortController.abort(new Error("evicted")):(r(this,Ft)||r(this,ot))&&(r(this,Ft)&&((n=r(this,xt))==null||n.call(this,s,i,"evict")),r(this,ot)&&((a=r(this,Q))==null||a.push([s,i,"evict"]))),r(this,Ce).call(this,e),t&&(r(this,L)[e]=void 0,r(this,O)[e]=void 0,r(this,Rt).push(e)),r(this,$)===1?(f(this,X,f(this,H,0)),r(this,Rt).length=0):f(this,X,r(this,rt)[e]),r(this,j).delete(i),Zi(this,$)._--,e},os=function(t,e,i,s){let n=e===void 0?void 0:r(this,O)[e];if(m(this,b,P).call(this,n))return n;let a=new ns,{signal:l}=i;l==null||l.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let h={signal:a.signal,options:i,context:s},c=(g,C=!1)=>{let{aborted:S}=a.signal,k=i.ignoreFetchAbort&&g!==void 0;if(i.status&&(S&&!C?(i.status.fetchAborted=!0,i.status.fetchError=a.signal.reason,k&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),S&&!k&&!C)return d(a.signal.reason);let R=E;return r(this,O)[e]===E&&(g===void 0?R.__staleWhileFetching?r(this,O)[e]=R.__staleWhileFetching:m(this,b,oe).call(this,t,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(t,g,h.options))),g},p=g=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=g),d(g)),d=g=>{let{aborted:C}=a.signal,S=C&&i.allowStaleOnFetchAbort,k=S||i.allowStaleOnFetchRejection,R=k||i.noDeleteOnFetchRejection,A=E;if(r(this,O)[e]===E&&(!R||A.__staleWhileFetching===void 0?m(this,b,oe).call(this,t,"fetch"):S||(r(this,O)[e]=A.__staleWhileFetching)),k)return i.status&&A.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),A.__staleWhileFetching;if(A.__returned===A)throw g},w=(g,C)=>{var k;let S=(k=r(this,Ie))==null?void 0:k.call(this,t,n,h);S&&S instanceof Promise&&S.then(R=>g(R===void 0?void 0:R),C),a.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(g(void 0),i.allowStaleOnFetchAbort&&(g=R=>c(R,!0)))})};i.status&&(i.status.fetchDispatched=!0);let E=new Promise(w).then(c,p),x=Object.assign(E,{__abortController:a,__staleWhileFetching:n,__returned:void 0});return e===void 0?(this.set(t,x,{...h.options,status:void 0}),e=r(this,j).get(t)):r(this,O)[e]=x,x},P=function(t){if(!r(this,ne))return!1;let e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof ns},Qs=function(t,e){r(this,ct)[e]=t,r(this,rt)[t]=e},hi=function(t){t!==r(this,H)&&(t===r(this,X)?f(this,X,r(this,rt)[t]):m(this,b,Qs).call(this,r(this,ct)[t],r(this,rt)[t]),m(this,b,Qs).call(this,r(this,H),t),f(this,H,t))},oe=function(t,e){var s,n,a,l;let i=!1;if(r(this,$)!==0){let h=r(this,j).get(t);if(h!==void 0)if(i=!0,r(this,$)===1)m(this,b,Ks).call(this,e);else{r(this,Ce).call(this,h);let c=r(this,O)[h];if(m(this,b,P).call(this,c)?c.__abortController.abort(new Error("deleted")):(r(this,Ft)||r(this,ot))&&(r(this,Ft)&&((s=r(this,xt))==null||s.call(this,c,t,e)),r(this,ot)&&((n=r(this,Q))==null||n.push([c,t,e]))),r(this,j).delete(t),r(this,L)[h]=void 0,r(this,O)[h]=void 0,h===r(this,H))f(this,H,r(this,ct)[h]);else if(h===r(this,X))f(this,X,r(this,rt)[h]);else{let p=r(this,ct)[h];r(this,rt)[p]=r(this,rt)[h];let d=r(this,rt)[h];r(this,ct)[d]=r(this,ct)[h]}Zi(this,$)._--,r(this,Rt).push(h)}}if(r(this,ot)&&((a=r(this,Q))!=null&&a.length)){let h=r(this,Q),c;for(;c=h==null?void 0:h.shift();)(l=r(this,kt))==null||l.call(this,...c)}return i},Ks=function(t){var e,i,s;for(let n of m(this,b,re).call(this,{allowStale:!0})){let a=r(this,O)[n];if(m(this,b,P).call(this,a))a.__abortController.abort(new Error("deleted"));else{let l=r(this,L)[n];r(this,Ft)&&((e=r(this,xt))==null||e.call(this,a,l,t)),r(this,ot)&&((i=r(this,Q))==null||i.push([a,l,t]))}}if(r(this,j).clear(),r(this,O).fill(void 0),r(this,L).fill(void 0),r(this,ft)&&r(this,Ot)&&(r(this,ft).fill(0),r(this,Ot).fill(0)),r(this,Tt)&&r(this,Tt).fill(0),f(this,X,0),f(this,H,0),r(this,Rt).length=0,f(this,vt,0),f(this,$,0),r(this,ot)&&r(this,Q)){let n=r(this,Q),a;for(;a=n==null?void 0:n.shift();)(s=r(this,kt))==null||s.call(this,...a)}};li=Vs});var ps,ir,tn,Do,bh,Eh,Ch,Gt,qt,ae,as,ui,hs,_o,ls,Po,At,je,K,pi,Ue,V,nt,Z,Zs,cs,tt,B,Ys,Js,Lo,Xs,Nt,tr,fs,di,xe,pt,mi,xh,kh,vh,Rh,us,er,Th,Oh,Mo,No,Bo,Io,zo,Wo,jo,Uo,$o,Go,qo,Ho,Qo,Ko,Vo,Zo,Yo,Jo,Xo,he,sr=D(()=>{"use strict";ps=require("events"),ir=De(require("stream"),1),tn=require("string_decoder"),Do=typeof process=="object"&&process?process:{stdout:null,stderr:null},bh=o=>!!o&&typeof o=="object"&&(o instanceof he||o instanceof ir.default||Eh(o)||Ch(o)),Eh=o=>!!o&&typeof o=="object"&&o instanceof ps.EventEmitter&&typeof o.pipe=="function"&&o.pipe!==ir.default.Writable.prototype.pipe,Ch=o=>!!o&&typeof o=="object"&&o instanceof ps.EventEmitter&&typeof o.write=="function"&&typeof o.end=="function",Gt=Symbol("EOF"),qt=Symbol("maybeEmitEnd"),ae=Symbol("emittedEnd"),as=Symbol("emittingEnd"),ui=Symbol("emittedError"),hs=Symbol("closed"),_o=Symbol("read"),ls=Symbol("flush"),Po=Symbol("flushChunk"),At=Symbol("encoding"),je=Symbol("decoder"),K=Symbol("flowing"),pi=Symbol("paused"),Ue=Symbol("resume"),V=Symbol("buffer"),nt=Symbol("pipes"),Z=Symbol("bufferLength"),Zs=Symbol("bufferPush"),cs=Symbol("bufferShift"),tt=Symbol("objectMode"),B=Symbol("destroyed"),Ys=Symbol("error"),Js=Symbol("emitData"),Lo=Symbol("emitEnd"),Xs=Symbol("emitEnd2"),Nt=Symbol("async"),tr=Symbol("abort"),fs=Symbol("aborted"),di=Symbol("signal"),xe=Symbol("dataListeners"),pt=Symbol("discarded"),mi=o=>Promise.resolve().then(o),xh=o=>o(),kh=o=>o==="end"||o==="finish"||o==="prefinish",vh=o=>o instanceof ArrayBuffer||!!o&&typeof o=="object"&&o.constructor&&o.constructor.name==="ArrayBuffer"&&o.byteLength>=0,Rh=o=>!Buffer.isBuffer(o)&&ArrayBuffer.isView(o),us=class{constructor(t,e,i){u(this,"src");u(this,"dest");u(this,"opts");u(this,"ondrain");this.src=t,this.dest=e,this.opts=i,this.ondrain=()=>t[Ue](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},er=class extends us{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,i){super(t,e,i),this.proxyErrors=s=>e.emit("error",s),t.on("error",this.proxyErrors)}},Th=o=>!!o.objectMode,Oh=o=>!o.objectMode&&!!o.encoding&&o.encoding!=="buffer",he=class extends ps.EventEmitter{constructor(...e){let i=e[0]||{};super();u(this,Xo,!1);u(this,Jo,!1);u(this,Yo,[]);u(this,Zo,[]);u(this,Vo);u(this,Ko);u(this,Qo);u(this,Ho);u(this,qo,!1);u(this,Go,!1);u(this,$o,!1);u(this,Uo,!1);u(this,jo,null);u(this,Wo,0);u(this,zo,!1);u(this,Io);u(this,Bo,!1);u(this,No,0);u(this,Mo,!1);u(this,"writable",!0);u(this,"readable",!0);if(i.objectMode&&typeof i.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Th(i)?(this[tt]=!0,this[At]=null):Oh(i)?(this[At]=i.encoding,this[tt]=!1):(this[tt]=!1,this[At]=null),this[Nt]=!!i.async,this[je]=this[At]?new tn.StringDecoder(this[At]):null,i&&i.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[V]}),i&&i.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[nt]});let{signal:s}=i;s&&(this[di]=s,s.aborted?this[tr]():s.addEventListener("abort",()=>this[tr]()))}get bufferLength(){return this[Z]}get encoding(){return this[At]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[tt]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Nt]}set async(e){this[Nt]=this[Nt]||!!e}[(Xo=K,Jo=pi,Yo=nt,Zo=V,Vo=tt,Ko=At,Qo=Nt,Ho=je,qo=Gt,Go=ae,$o=as,Uo=hs,jo=ui,Wo=Z,zo=B,Io=di,Bo=fs,No=xe,Mo=pt,tr)](){var e,i;this[fs]=!0,this.emit("abort",(e=this[di])==null?void 0:e.reason),this.destroy((i=this[di])==null?void 0:i.reason)}get aborted(){return this[fs]}set aborted(e){}write(e,i,s){var a;if(this[fs])return!1;if(this[Gt])throw new Error("write after end");if(this[B])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof i=="function"&&(s=i,i="utf8"),i||(i="utf8");let n=this[Nt]?mi:xh;if(!this[tt]&&!Buffer.isBuffer(e)){if(Rh(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(vh(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[tt]?(this[K]&&this[Z]!==0&&this[ls](!0),this[K]?this.emit("data",e):this[Zs](e),this[Z]!==0&&this.emit("readable"),s&&n(s),this[K]):e.length?(typeof e=="string"&&!(i===this[At]&&!((a=this[je])!=null&&a.lastNeed))&&(e=Buffer.from(e,i)),Buffer.isBuffer(e)&&this[At]&&(e=this[je].write(e)),this[K]&&this[Z]!==0&&this[ls](!0),this[K]?this.emit("data",e):this[Zs](e),this[Z]!==0&&this.emit("readable"),s&&n(s),this[K]):(this[Z]!==0&&this.emit("readable"),s&&n(s),this[K])}read(e){if(this[B])return null;if(this[pt]=!1,this[Z]===0||e===0||e&&e>this[Z])return this[qt](),null;this[tt]&&(e=null),this[V].length>1&&!this[tt]&&(this[V]=[this[At]?this[V].join(""):Buffer.concat(this[V],this[Z])]);let i=this[_o](e||null,this[V][0]);return this[qt](),i}[_o](e,i){if(this[tt])this[cs]();else{let s=i;e===s.length||e===null?this[cs]():typeof s=="string"?(this[V][0]=s.slice(e),i=s.slice(0,e),this[Z]-=e):(this[V][0]=s.subarray(e),i=s.subarray(0,e),this[Z]-=e)}return this.emit("data",i),!this[V].length&&!this[Gt]&&this.emit("drain"),i}end(e,i,s){return typeof e=="function"&&(s=e,e=void 0),typeof i=="function"&&(s=i,i="utf8"),e!==void 0&&this.write(e,i),s&&this.once("end",s),this[Gt]=!0,this.writable=!1,(this[K]||!this[pi])&&this[qt](),this}[Ue](){this[B]||(!this[xe]&&!this[nt].length&&(this[pt]=!0),this[pi]=!1,this[K]=!0,this.emit("resume"),this[V].length?this[ls]():this[Gt]?this[qt]():this.emit("drain"))}resume(){return this[Ue]()}pause(){this[K]=!1,this[pi]=!0,this[pt]=!1}get destroyed(){return this[B]}get flowing(){return this[K]}get paused(){return this[pi]}[Zs](e){this[tt]?this[Z]+=1:this[Z]+=e.length,this[V].push(e)}[cs](){return this[tt]?this[Z]-=1:this[Z]-=this[V][0].length,this[V].shift()}[ls](e=!1){do;while(this[Po](this[cs]())&&this[V].length);!e&&!this[V].length&&!this[Gt]&&this.emit("drain")}[Po](e){return this.emit("data",e),this[K]}pipe(e,i){if(this[B])return e;this[pt]=!1;let s=this[ae];return i=i||{},e===Do.stdout||e===Do.stderr?i.end=!1:i.end=i.end!==!1,i.proxyErrors=!!i.proxyErrors,s?i.end&&e.end():(this[nt].push(i.proxyErrors?new er(this,e,i):new us(this,e,i)),this[Nt]?mi(()=>this[Ue]()):this[Ue]()),e}unpipe(e){let i=this[nt].find(s=>s.dest===e);i&&(this[nt].length===1?(this[K]&&this[xe]===0&&(this[K]=!1),this[nt]=[]):this[nt].splice(this[nt].indexOf(i),1),i.unpipe())}addListener(e,i){return this.on(e,i)}on(e,i){let s=super.on(e,i);if(e==="data")this[pt]=!1,this[xe]++,!this[nt].length&&!this[K]&&this[Ue]();else if(e==="readable"&&this[Z]!==0)super.emit("readable");else if(kh(e)&&this[ae])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[ui]){let n=i;this[Nt]?mi(()=>n.call(this,this[ui])):n.call(this,this[ui])}return s}removeListener(e,i){return this.off(e,i)}off(e,i){let s=super.off(e,i);return e==="data"&&(this[xe]=this.listeners("data").length,this[xe]===0&&!this[pt]&&!this[nt].length&&(this[K]=!1)),s}removeAllListeners(e){let i=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[xe]=0,!this[pt]&&!this[nt].length&&(this[K]=!1)),i}get emittedEnd(){return this[ae]}[qt](){!this[as]&&!this[ae]&&!this[B]&&this[V].length===0&&this[Gt]&&(this[as]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[hs]&&this.emit("close"),this[as]=!1)}emit(e,...i){let s=i[0];if(e!=="error"&&e!=="close"&&e!==B&&this[B])return!1;if(e==="data")return!this[tt]&&!s?!1:this[Nt]?(mi(()=>this[Js](s)),!0):this[Js](s);if(e==="end")return this[Lo]();if(e==="close"){if(this[hs]=!0,!this[ae]&&!this[B])return!1;let a=super.emit("close");return this.removeAllListeners("close"),a}else if(e==="error"){this[ui]=s,super.emit(Ys,s);let a=!this[di]||this.listeners("error").length?super.emit("error",s):!1;return this[qt](),a}else if(e==="resume"){let a=super.emit("resume");return this[qt](),a}else if(e==="finish"||e==="prefinish"){let a=super.emit(e);return this.removeAllListeners(e),a}let n=super.emit(e,...i);return this[qt](),n}[Js](e){for(let s of this[nt])s.dest.write(e)===!1&&this.pause();let i=this[pt]?!1:super.emit("data",e);return this[qt](),i}[Lo](){return this[ae]?!1:(this[ae]=!0,this.readable=!1,this[Nt]?(mi(()=>this[Xs]()),!0):this[Xs]())}[Xs](){if(this[je]){let i=this[je].end();if(i){for(let s of this[nt])s.dest.write(i);this[pt]||super.emit("data",i)}}for(let i of this[nt])i.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[tt]||(e.dataLength=0);let i=this.promise();return this.on("data",s=>{e.push(s),this[tt]||(e.dataLength+=s.length)}),await i,e}async concat(){if(this[tt])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[At]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,i)=>{this.on(B,()=>i(new Error("stream destroyed"))),this.on("error",s=>i(s)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[pt]=!1;let e=!1,i=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return i();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[Gt])return i();let a,l,h=w=>{this.off("data",c),this.off("end",p),this.off(B,d),i(),l(w)},c=w=>{this.off("error",h),this.off("end",p),this.off(B,d),this.pause(),a({value:w,done:!!this[Gt]})},p=()=>{this.off("error",h),this.off("data",c),this.off(B,d),i(),a({done:!0,value:void 0})},d=()=>h(new Error("stream destroyed"));return new Promise((w,E)=>{l=E,a=w,this.once(B,d),this.once("error",h),this.once("end",p),this.once("data",c)})},throw:i,return:i,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[pt]=!1;let e=!1,i=()=>(this.pause(),this.off(Ys,i),this.off(B,i),this.off("end",i),e=!0,{done:!0,value:void 0}),s=()=>{if(e)return i();let n=this.read();return n===null?i():{done:!1,value:n}};return this.once("end",i),this.once(Ys,i),this.once(B,i),{next:s,throw:i,return:i,[Symbol.iterator](){return this}}}destroy(e){if(this[B])return e?this.emit("error",e):this.emit(B),this;this[B]=!0,this[pt]=!0,this[V].length=0,this[Z]=0;let i=this;return typeof i.close=="function"&&!this[hs]&&i.close(),e?this.emit("error",e):this.emit(B),this}static get isStream(){return bh}}});var Qe,nn,Wt,Fh,ce,Ah,wi,an,hn,Dh,_h,wt,ln,cn,Bt,fn,un,ke,pn,gt,gi,rr,en,yi,Dt,ds,gs,sn,Ph,or,rn,Si,on,ms,bs,nr,dn,at,xi,ki,vi,Ri,Ti,Oi,Fi,Ai,Di,_i,Pi,Li,Mi,Ni,Bi,Ii,zi,Wi,le,ve,It,Ht,Qt,Kt,T,Re,Vt,zt,v,ar,ws,bi,hr,lr,Ei,ys,cr,fr,Ss,mn,gn,wn,ur,$e,Ge,yn,Te,et,Es,Cs,qe,He,ji,Ui,xs,Ke,Ve,Ci,uc,Sn,bn=D(()=>{"use strict";Ao();Qe=require("path"),nn=require("url"),Wt=require("fs"),Fh=De(require("fs"),1),ce=require("fs/promises");sr();Ah=Wt.realpathSync.native,wi={lstatSync:Wt.lstatSync,readdir:Wt.readdir,readdirSync:Wt.readdirSync,readlinkSync:Wt.readlinkSync,realpathSync:Ah,promises:{lstat:ce.lstat,readdir:ce.readdir,readlink:ce.readlink,realpath:ce.realpath}},an=o=>!o||o===wi||o===Fh?wi:{...wi,...o,promises:{...wi.promises,...o.promises||{}}},hn=/^\\\\\?\\([a-z]:)\\?$/i,Dh=o=>o.replace(/\//g,"\\").replace(hn,"$1\\"),_h=/[\\\/]/,wt=0,ln=1,cn=2,Bt=4,fn=6,un=8,ke=10,pn=12,gt=15,gi=~gt,rr=16,en=32,yi=64,Dt=128,ds=256,gs=512,sn=yi|Dt|gs,Ph=1023,or=o=>o.isFile()?un:o.isDirectory()?Bt:o.isSymbolicLink()?ke:o.isCharacterDevice()?cn:o.isBlockDevice()?fn:o.isSocket()?pn:o.isFIFO()?ln:wt,rn=new Map,Si=o=>{let t=rn.get(o);if(t)return t;let e=o.normalize("NFKD");return rn.set(o,e),e},on=new Map,ms=o=>{let t=on.get(o);if(t)return t;let e=Si(o.toLowerCase());return on.set(o,e),e},bs=class extends li{constructor(){super({max:256})}},nr=class extends li{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},dn=Symbol("PathScurry setAsCwd"),et=class{constructor(t,e=wt,i,s,n,a,l){y(this,v);u(this,"name");u(this,"root");u(this,"roots");u(this,"parent");u(this,"nocase");u(this,"isCWD",!1);y(this,at);y(this,xi);y(this,ki);y(this,vi);y(this,Ri);y(this,Ti);y(this,Oi);y(this,Fi);y(this,Ai);y(this,Di);y(this,_i);y(this,Pi);y(this,Li);y(this,Mi);y(this,Ni);y(this,Bi);y(this,Ii);y(this,zi);y(this,Wi);y(this,le);y(this,ve);y(this,It);y(this,Ht);y(this,Qt);y(this,Kt);y(this,T);y(this,Re);y(this,Vt);y(this,zt);y(this,$e,[]);y(this,Ge,!1);y(this,Te);this.name=t,f(this,le,n?ms(t):Si(t)),f(this,T,e&Ph),this.nocase=n,this.roots=s,this.root=i||this,f(this,Re,a),f(this,It,l.fullpath),f(this,Qt,l.relative),f(this,Kt,l.relativePosix),this.parent=l.parent,this.parent?f(this,at,r(this.parent,at)):f(this,at,an(l.fs))}get dev(){return r(this,xi)}get mode(){return r(this,ki)}get nlink(){return r(this,vi)}get uid(){return r(this,Ri)}get gid(){return r(this,Ti)}get rdev(){return r(this,Oi)}get blksize(){return r(this,Fi)}get ino(){return r(this,Ai)}get size(){return r(this,Di)}get blocks(){return r(this,_i)}get atimeMs(){return r(this,Pi)}get mtimeMs(){return r(this,Li)}get ctimeMs(){return r(this,Mi)}get birthtimeMs(){return r(this,Ni)}get atime(){return r(this,Bi)}get mtime(){return r(this,Ii)}get ctime(){return r(this,zi)}get birthtime(){return r(this,Wi)}get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return r(this,ve)!==void 0?r(this,ve):this.parent?f(this,ve,this.parent.depth()+1):f(this,ve,0)}childrenCache(){return r(this,Re)}resolve(t){var a;if(!t)return this;let e=this.getRootString(t),s=t.substring(e.length).split(this.splitSep);return e?m(a=this.getRoot(e),v,ar).call(a,s):m(this,v,ar).call(this,s)}children(){let t=r(this,Re).get(this);if(t)return t;let e=Object.assign([],{provisional:0});return r(this,Re).set(this,e),f(this,T,r(this,T)&~rr),e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let i=this.children(),s=this.nocase?ms(t):Si(t);for(let h of i)if(r(h,le)===s)return h;let n=this.parent?this.sep:"",a=r(this,It)?r(this,It)+n+t:void 0,l=this.newChild(t,wt,{...e,parent:this,fullpath:a});return this.canReaddir()||f(l,T,r(l,T)|Dt),i.push(l),l}relative(){if(this.isCWD)return"";if(r(this,Qt)!==void 0)return r(this,Qt);let t=this.name,e=this.parent;if(!e)return f(this,Qt,this.name);let i=e.relative();return i+(!i||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(r(this,Kt)!==void 0)return r(this,Kt);let t=this.name,e=this.parent;if(!e)return f(this,Kt,this.fullpathPosix());let i=e.relativePosix();return i+(!i||!e.parent?"":"/")+t}fullpath(){if(r(this,It)!==void 0)return r(this,It);let t=this.name,e=this.parent;if(!e)return f(this,It,this.name);let s=e.fullpath()+(e.parent?this.sep:"")+t;return f(this,It,s)}fullpathPosix(){if(r(this,Ht)!==void 0)return r(this,Ht);if(this.sep==="/")return f(this,Ht,this.fullpath());if(!this.parent){let s=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(s)?f(this,Ht,`//?/${s}`):f(this,Ht,s)}let t=this.parent,e=t.fullpathPosix(),i=e+(!e||!t.parent?"":"/")+this.name;return f(this,Ht,i)}isUnknown(){return(r(this,T)>)===wt}isType(t){return this[`is${t}`]()}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,T)>)===un}isDirectory(){return(r(this,T)>)===Bt}isCharacterDevice(){return(r(this,T)>)===cn}isBlockDevice(){return(r(this,T)>)===fn}isFIFO(){return(r(this,T)>)===ln}isSocket(){return(r(this,T)>)===pn}isSymbolicLink(){return(r(this,T)&ke)===ke}lstatCached(){return r(this,T)&en?this:void 0}readlinkCached(){return r(this,Vt)}realpathCached(){return r(this,zt)}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(r(this,Vt))return!0;if(!this.parent)return!1;let t=r(this,T)>return!(t!==wt&&t!==ke||r(this,T)&ds||r(this,T)&Dt)}calledReaddir(){return!!(r(this,T)&rr)}isENOENT(){return!!(r(this,T)&Dt)}isNamed(t){return this.nocase?r(this,le)===ms(t):r(this,le)===Si(t)}async readlink(){var e;let t=r(this,Vt);if(t)return t;if(this.canReadlink()&&this.parent)try{let i=await r(this,at).promises.readlink(this.fullpath()),s=(e=await this.parent.realpath())==null?void 0:e.resolve(i);if(s)return f(this,Vt,s)}catch(i){m(this,v,fr).call(this,i.code);return}}readlinkSync(){var e;let t=r(this,Vt);if(t)return t;if(this.canReadlink()&&this.parent)try{let i=r(this,at).readlinkSync(this.fullpath()),s=(e=this.parent.realpathSync())==null?void 0:e.resolve(i);if(s)return f(this,Vt,s)}catch(i){m(this,v,fr).call(this,i.code);return}}async lstat(){if(!(r(this,T)&Dt))try{return m(this,v,ur).call(this,await r(this,at).promises.lstat(this.fullpath())),this}catch(t){m(this,v,cr).call(this,t.code)}}lstatSync(){if(!(r(this,T)&Dt))try{return m(this,v,ur).call(this,r(this,at).lstatSync(this.fullpath())),this}catch(t){m(this,v,cr).call(this,t.code)}}readdirCB(t,e=!1){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let i=this.children();if(this.calledReaddir()){let n=i.slice(0,i.provisional);e?t(null,n):queueMicrotask(()=>t(null,n));return}if(r(this,$e).push(t),r(this,Ge))return;f(this,Ge,!0);let s=this.fullpath();r(this,at).readdir(s,{withFileTypes:!0},(n,a)=>{if(n)m(this,v,ys).call(this,n.code),i.provisional=0;else{for(let l of a)m(this,v,Ss).call(this,l,i);m(this,v,ws).call(this,i)}m(this,v,yn).call(this,i.slice(0,i.provisional))})}async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();if(r(this,Te))await r(this,Te);else{let i=()=>{};f(this,Te,new Promise(s=>i=s));try{for(let s of await r(this,at).promises.readdir(e,{withFileTypes:!0}))m(this,v,Ss).call(this,s,t);m(this,v,ws).call(this,t)}catch(s){m(this,v,ys).call(this,s.code),t.provisional=0}f(this,Te,void 0),i()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();try{for(let i of r(this,at).readdirSync(e,{withFileTypes:!0}))m(this,v,Ss).call(this,i,t);m(this,v,ws).call(this,t)}catch(i){m(this,v,ys).call(this,i.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(r(this,T)&sn)return!1;let t=gt&r(this,T);return t===wt||t===Bt||t===ke}shouldWalk(t,e){return(r(this,T)&Bt)===Bt&&!(r(this,T)&sn)&&!t.has(this)&&(!e||e(this))}async realpath(){if(r(this,zt))return r(this,zt);if(!((gs|ds|Dt)&r(this,T)))try{let t=await r(this,at).promises.realpath(this.fullpath());return f(this,zt,this.resolve(t))}catch(t){m(this,v,lr).call(this)}}realpathSync(){if(r(this,zt))return r(this,zt);if(!((gs|ds|Dt)&r(this,T)))try{let t=r(this,at).realpathSync(this.fullpath());return f(this,zt,this.resolve(t))}catch(t){m(this,v,lr).call(this)}}[dn](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let e=new Set([]),i=[],s=this;for(;s&&s.parent;)e.add(s),f(s,Qt,i.join(this.sep)),f(s,Kt,i.join("/")),s=s.parent,i.push("..");for(s=t;s&&s.parent&&!e.has(s);)f(s,Qt,void 0),f(s,Kt,void 0),s=s.parent}};at=new WeakMap,xi=new WeakMap,ki=new WeakMap,vi=new WeakMap,Ri=new WeakMap,Ti=new WeakMap,Oi=new WeakMap,Fi=new WeakMap,Ai=new WeakMap,Di=new WeakMap,_i=new WeakMap,Pi=new WeakMap,Li=new WeakMap,Mi=new WeakMap,Ni=new WeakMap,Bi=new WeakMap,Ii=new WeakMap,zi=new WeakMap,Wi=new WeakMap,le=new WeakMap,ve=new WeakMap,It=new WeakMap,Ht=new WeakMap,Qt=new WeakMap,Kt=new WeakMap,T=new WeakMap,Re=new WeakMap,Vt=new WeakMap,zt=new WeakMap,v=new WeakSet,ar=function(t){let e=this;for(let i of t)e=e.child(i);return e},ws=function(t){var e;f(this,T,r(this,T)|rr);for(let i=t.provisional;i<t.length;i++){let s=t[i];s&&m(e=s,v,bi).call(e)}},bi=function(){r(this,T)&Dt||(f(this,T,(r(this,T)|Dt)&gi),m(this,v,hr).call(this))},hr=function(){var e;let t=this.children();t.provisional=0;for(let i of t)m(e=i,v,bi).call(e)},lr=function(){f(this,T,r(this,T)|gs),m(this,v,Ei).call(this)},Ei=function(){if(r(this,T)&yi)return;let t=r(this,T);(t>)===Bt&&(t&=gi),f(this,T,t|yi),m(this,v,hr).call(this)},ys=function(t=""){t==="ENOTDIR"||t==="EPERM"?m(this,v,Ei).call(this):t==="ENOENT"?m(this,v,bi).call(this):this.children().provisional=0},cr=function(t=""){var e;if(t==="ENOTDIR"){let i=this.parent;m(e=i,v,Ei).call(e)}else t==="ENOENT"&&m(this,v,bi).call(this)},fr=function(t=""){var i;let e=r(this,T);e|=ds,t==="ENOENT"&&(e|=Dt),(t==="EINVAL"||t==="UNKNOWN")&&(e&=gi),f(this,T,e),t==="ENOTDIR"&&this.parent&&m(i=this.parent,v,Ei).call(i)},Ss=function(t,e){return m(this,v,gn).call(this,t,e)||m(this,v,mn).call(this,t,e)},mn=function(t,e){let i=or(t),s=this.newChild(t.name,i,{parent:this}),n=r(s,T)>return n!==Bt&&n!==ke&&n!==wt&&f(s,T,r(s,T)|yi),e.unshift(s),e.provisional++,s},gn=function(t,e){for(let i=e.provisional;i<e.length;i++){let s=e[i];if((this.nocase?ms(t.name):Si(t.name))===r(s,le))return m(this,v,wn).call(this,t,s,i,e)}},wn=function(t,e,i,s){let n=e.name;return f(e,T,r(e,T)&gi|or(t)),n!==t.name&&(e.name=t.name),i!==s.provisional&&(i===s.length-1?s.pop():s.splice(i,1),s.unshift(e)),s.provisional++,e},ur=function(t){let{atime:e,atimeMs:i,birthtime:s,birthtimeMs:n,blksize:a,blocks:l,ctime:h,ctimeMs:c,dev:p,gid:d,ino:w,mode:E,mtime:x,mtimeMs:g,nlink:C,rdev:S,size:k,uid:R}=t;f(this,Bi,e),f(this,Pi,i),f(this,Wi,s),f(this,Ni,n),f(this,Fi,a),f(this,_i,l),f(this,zi,h),f(this,Mi,c),f(this,xi,p),f(this,Ti,d),f(this,Ai,w),f(this,ki,E),f(this,Ii,x),f(this,Li,g),f(this,vi,C),f(this,Oi,S),f(this,Di,k),f(this,Ri,R);let A=or(t);f(this,T,r(this,T)&gi|A|en),A!==wt&&A!==Bt&&A!==ke&&f(this,T,r(this,T)|yi)},$e=new WeakMap,Ge=new WeakMap,yn=function(t){f(this,Ge,!1);let e=r(this,$e).slice();r(this,$e).length=0,e.forEach(i=>i(null,t))},Te=new WeakMap;Es=class o extends et{constructor(e,i=wt,s,n,a,l,h){super(e,i,s,n,a,l,h);u(this,"sep","\\");u(this,"splitSep",_h)}newChild(e,i=wt,s={}){return new o(e,i,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(e){return Qe.win32.parse(e).root}getRoot(e){if(e=Dh(e.toUpperCase()),e===this.root.name)return this.root;for(let[i,s]of Object.entries(this.roots))if(this.sameRoot(e,i))return this.roots[e]=s;return this.roots[e]=new Ke(e,this).root}sameRoot(e,i=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(hn,"$1\\"),e===i}},Cs=class o extends et{constructor(e,i=wt,s,n,a,l,h){super(e,i,s,n,a,l,h);u(this,"splitSep","/");u(this,"sep","/")}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,i=wt,s={}){return new o(e,i,this.root,this.roots,this.nocase,this.childrenCache(),s)}},xs=class{constructor(t=process.cwd(),e,i,{nocase:s,childrenCacheSize:n=16*1024,fs:a=wi}={}){u(this,"root");u(this,"rootPath");u(this,"roots");u(this,"cwd");y(this,qe);y(this,He);y(this,ji);u(this,"nocase");y(this,Ui);f(this,Ui,an(a)),(t instanceof URL||t.startsWith("file://"))&&(t=(0,nn.fileURLToPath)(t));let l=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(l),f(this,qe,new bs),f(this,He,new bs),f(this,ji,new nr(n));let h=l.substring(this.rootPath.length).split(i);if(h.length===1&&!h[0]&&h.pop(),s===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=s,this.root=this.newRoot(r(this,Ui)),this.roots[this.rootPath]=this.root;let c=this.root,p=h.length-1,d=e.sep,w=this.rootPath,E=!1;for(let x of h){let g=p--;c=c.child(x,{relative:new Array(g).fill("..").join(d),relativePosix:new Array(g).fill("..").join("/"),fullpath:w+=(E?"":d)+x}),E=!0}this.cwd=c}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return r(this,ji)}resolve(...t){let e="";for(let n=t.length-1;n>=0;n--){let a=t[n];if(!(!a||a===".")&&(e=e?`${a}/${e}`:a,this.isAbsolute(a)))break}let i=r(this,qe).get(e);if(i!==void 0)return i;let s=this.cwd.resolve(e).fullpath();return r(this,qe).set(e,s),s}resolvePosix(...t){let e="";for(let n=t.length-1;n>=0;n--){let a=t[n];if(!(!a||a===".")&&(e=e?`${a}/${e}`:a,this.isAbsolute(a)))break}let i=r(this,He).get(e);if(i!==void 0)return i;let s=this.cwd.resolve(e).fullpathPosix();return r(this,He).set(e,s),s}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t,t=this.cwd);let{withFileTypes:i}=e;if(t.canReaddir()){let s=await t.readdir();return i?s:s.map(n=>n.name)}else return[]}readdirSync(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t,t=this.cwd);let{withFileTypes:i=!0}=e;return t.canReaddir()?i?t.readdirSync():t.readdirSync().map(s=>s.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t.withFileTypes,t=this.cwd);let i=await t.readlink();return e?i:i==null?void 0:i.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t.withFileTypes,t=this.cwd);let i=t.readlinkSync();return e?i:i==null?void 0:i.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t.withFileTypes,t=this.cwd);let i=await t.realpath();return e?i:i==null?void 0:i.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t.withFileTypes,t=this.cwd);let i=t.realpathSync();return e?i:i==null?void 0:i.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:s=!1,filter:n,walkFilter:a}=e,l=[];(!n||n(t))&&l.push(i?t:t.fullpath());let h=new Set,c=(d,w)=>{h.add(d),d.readdirCB((E,x)=>{if(E)return w(E);let g=x.length;if(!g)return w();let C=()=>{--g===0&&w()};for(let S of x)(!n||n(S))&&l.push(i?S:S.fullpath()),s&&S.isSymbolicLink()?S.realpath().then(k=>k!=null&&k.isUnknown()?k.lstat():k).then(k=>k!=null&&k.shouldWalk(h,a)?c(k,C):C()):S.shouldWalk(h,a)?c(S,C):C()},!0)},p=t;return new Promise((d,w)=>{c(p,E=>{if(E)return w(E);d(l)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:s=!1,filter:n,walkFilter:a}=e,l=[];(!n||n(t))&&l.push(i?t:t.fullpath());let h=new Set([t]);for(let c of h){let p=c.readdirSync();for(let d of p){(!n||n(d))&&l.push(i?d:d.fullpath());let w=d;if(d.isSymbolicLink()){if(!(s&&(w=d.realpathSync())))continue;w.isUnknown()&&w.lstatSync()}w.shouldWalk(h,a)&&h.add(w)}}return l}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t,t=this.cwd),this.stream(t,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:s=!1,filter:n,walkFilter:a}=e;(!n||n(t))&&(yield i?t:t.fullpath());let l=new Set([t]);for(let h of l){let c=h.readdirSync();for(let p of c){(!n||n(p))&&(yield i?p:p.fullpath());let d=p;if(p.isSymbolicLink()){if(!(s&&(d=p.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(l,a)&&l.add(d)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:s=!1,filter:n,walkFilter:a}=e,l=new he({objectMode:!0});(!n||n(t))&&l.write(i?t:t.fullpath());let h=new Set,c=[t],p=0,d=()=>{let w=!1;for(;!w;){let E=c.shift();if(!E){p===0&&l.end();return}p++,h.add(E);let x=(C,S,k=!1)=>{if(C)return l.emit("error",C);if(s&&!k){let R=[];for(let A of S)A.isSymbolicLink()&&R.push(A.realpath().then(_=>_!=null&&_.isUnknown()?_.lstat():_));if(R.length){Promise.all(R).then(()=>x(null,S,!0));return}}for(let R of S)R&&(!n||n(R))&&(l.write(i?R:R.fullpath())||(w=!0));p--;for(let R of S){let A=R.realpathCached()||R;A.shouldWalk(h,a)&&c.push(A)}w&&!l.flowing?l.once("drain",d):g||d()},g=!0;E.readdirCB(x,!0),g=!1}};return d(),l}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof et||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:s=!1,filter:n,walkFilter:a}=e,l=new he({objectMode:!0}),h=new Set;(!n||n(t))&&l.write(i?t:t.fullpath());let c=[t],p=0,d=()=>{let w=!1;for(;!w;){let E=c.shift();if(!E){p===0&&l.end();return}p++,h.add(E);let x=E.readdirSync();for(let g of x)(!n||n(g))&&(l.write(i?g:g.fullpath())||(w=!0));p--;for(let g of x){let C=g;if(g.isSymbolicLink()){if(!(s&&(C=g.realpathSync())))continue;C.isUnknown()&&C.lstatSync()}C.shouldWalk(h,a)&&c.push(C)}}w&&!l.flowing&&l.once("drain",d)};return d(),l}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[dn](e)}};qe=new WeakMap,He=new WeakMap,ji=new WeakMap,Ui=new WeakMap;Ke=class extends xs{constructor(e=process.cwd(),i={}){let{nocase:s=!0}=i;super(e,Qe.win32,"\\",{...i,nocase:s});u(this,"sep","\\");this.nocase=s;for(let n=this.cwd;n;n=n.parent)n.nocase=this.nocase}parseRootPath(e){return Qe.win32.parse(e).root.toUpperCase()}newRoot(e){return new Es(this.rootPath,Bt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},Ve=class extends xs{constructor(e=process.cwd(),i={}){let{nocase:s=!1}=i;super(e,Qe.posix,"/",{...i,nocase:s});u(this,"sep","/");this.nocase=s}parseRootPath(e){return"/"}newRoot(e){return new Cs(this.rootPath,Bt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},Ci=class extends Ve{constructor(t=process.cwd(),e={}){let{nocase:i=!0}=e;super(t,{...e,nocase:i})}},uc=process.platform==="win32"?Es:Cs,Sn=process.platform==="win32"?Ke:process.platform==="darwin"?Ci:Ve});var Lh,Mh,G,dt,Y,Oe,_t,$i,fe,ue,pe,Ze,pr,Ye,dr=D(()=>{"use strict";ee();Lh=o=>o.length>=1,Mh=o=>o.length>=1,pr=class pr{constructor(t,e,i,s){y(this,G);y(this,dt);y(this,Y);u(this,"length");y(this,Oe);y(this,_t);y(this,$i);y(this,fe);y(this,ue);y(this,pe);y(this,Ze,!0);if(!Lh(t))throw new TypeError("empty pattern list");if(!Mh(e))throw new TypeError("empty glob list");if(e.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(f(this,G,t),f(this,dt,e),f(this,Y,i),f(this,Oe,s),r(this,Y)===0){if(this.isUNC()){let[n,a,l,h,...c]=r(this,G),[p,d,w,E,...x]=r(this,dt);c[0]===""&&(c.shift(),x.shift());let g=[n,a,l,h,""].join("/"),C=[p,d,w,E,""].join("/");f(this,G,[g,...c]),f(this,dt,[C,...x]),this.length=r(this,G).length}else if(this.isDrive()||this.isAbsolute()){let[n,...a]=r(this,G),[l,...h]=r(this,dt);a[0]===""&&(a.shift(),h.shift());let c=n+"/",p=l+"/";f(this,G,[c,...a]),f(this,dt,[p,...h]),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)]===J}isRegExp(){return r(this,G)[r(this,Y)]instanceof RegExp}globString(){return f(this,$i,r(this,$i)||(r(this,Y)===0?this.isAbsolute()?r(this,dt)[0]+r(this,dt).slice(1).join("/"):r(this,dt).join("/"):r(this,dt).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()?(f(this,_t,new pr(r(this,G),r(this,dt),r(this,Y)+1,r(this,Oe))),f(r(this,_t),pe,r(this,pe)),f(r(this,_t),ue,r(this,ue)),f(r(this,_t),fe,r(this,fe)),r(this,_t)):f(this,_t,null)}isUNC(){let t=r(this,G);return r(this,ue)!==void 0?r(this,ue):f(this,ue,r(this,Oe)==="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,fe)!==void 0?r(this,fe):f(this,fe,r(this,Oe)==="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,pe)!==void 0?r(this,pe):f(this,pe,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,Ze))}markFollowGlobstar(){return r(this,Y)===0||!this.isGlobstar()||!r(this,Ze)?!1:(f(this,Ze,!1),!0)}};G=new WeakMap,dt=new WeakMap,Y=new WeakMap,Oe=new WeakMap,_t=new WeakMap,$i=new WeakMap,fe=new WeakMap,ue=new WeakMap,pe=new WeakMap,Ze=new WeakMap;Ye=pr});var Nh,Je,mr=D(()=>{"use strict";ee();dr();Nh=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Je=class{constructor(t,{nobrace:e,nocase:i,noext:s,noglobstar:n,platform:a=Nh}){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=a,this.mmopts={dot:!0,nobrace:e,nocase:i,noext:s,noglobstar:n,optimizationLevel:2,platform:a,nocomment:!0,nonegate:!0};for(let l of t)this.add(l)}add(t){let e=new ht(t,this.mmopts);for(let i=0;i<e.set.length;i++){let s=e.set[i],n=e.globParts[i];if(!s||!n)throw new Error("invalid pattern object");for(;s[0]==="."&&n[0]===".";)s.shift(),n.shift();let a=new Ye(s,n,0,this.platform),l=new ht(a.globString(),this.mmopts),h=n[n.length-1]==="**",c=a.isAbsolute();c?this.absolute.push(l):this.relative.push(l),h&&(c?this.absoluteChildren.push(l):this.relativeChildren.push(l))}}ignored(t){let e=t.fullpath(),i=`${e}/`,s=t.relative()||".",n=`${s}/`;for(let a of this.relative)if(a.match(s)||a.match(n))return!0;for(let a of this.absolute)if(a.match(e)||a.match(i))return!0;return!1}childrenIgnored(t){let e=t.fullpath()+"/",i=(t.relative()||".")+"/";for(let s of this.relativeChildren)if(s.match(i))return!0;for(let s of this.absoluteChildren)if(s.match(e))return!0;return!1}}});var gr,wr,yr,Gi,En=D(()=>{"use strict";ee();gr=class o{constructor(t=new Map){u(this,"store");this.store=t}copy(){return new o(new Map(this.store))}hasWalked(t,e){var i;return(i=this.store.get(t.fullpath()))==null?void 0:i.has(e.globString())}storeWalked(t,e){let i=t.fullpath(),s=this.store.get(i);s?s.add(e.globString()):this.store.set(i,new Set([e.globString()]))}},wr=class{constructor(){u(this,"store",new Map)}add(t,e,i){let s=(e?2:0)|(i?1:0),n=this.store.get(t);this.store.set(t,n===void 0?s:s&n)}entries(){return[...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},yr=class{constructor(){u(this,"store",new Map)}add(t,e){if(!t.canReaddir())return;let i=this.store.get(t);i?i.find(s=>s.globString()===e.globString())||i.push(e):this.store.set(t,[e])}get(t){let e=this.store.get(t);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},Gi=class o{constructor(t,e){u(this,"hasWalkedCache");u(this,"matches",new wr);u(this,"subwalks",new yr);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=e?e.copy():new gr}processPatterns(t,e){this.patterns=e;let i=e.map(s=>[t,s]);for(let[s,n]of i){this.hasWalkedCache.storeWalked(s,n);let a=n.root(),l=n.isAbsolute()&&this.opts.absolute!==!1;if(a){s=s.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let d=n.rest();if(d)n=d;else{this.matches.add(s,!0,!1);continue}}if(s.isENOENT())continue;let h,c,p=!1;for(;typeof(h=n.pattern())=="string"&&(c=n.rest());)s=s.resolve(h),n=c,p=!0;if(h=n.pattern(),c=n.rest(),p){if(this.hasWalkedCache.hasWalked(s,n))continue;this.hasWalkedCache.storeWalked(s,n)}if(typeof h=="string"){let d=h===".."||h===""||h===".";this.matches.add(s.resolve(h),l,d);continue}else if(h===J){(!s.isSymbolicLink()||this.follow||n.checkFollowGlobstar())&&this.subwalks.add(s,n);let d=c==null?void 0:c.pattern(),w=c==null?void 0:c.rest();if(!c||(d===""||d===".")&&!w)this.matches.add(s,l,d===""||d===".");else if(d===".."){let E=s.parent||s;w?this.hasWalkedCache.hasWalked(E,w)||this.subwalks.add(E,w):this.matches.add(E,l,!0)}}else h instanceof RegExp&&this.subwalks.add(s,n)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new o(this.opts,this.hasWalkedCache)}filterEntries(t,e){let i=this.subwalks.get(t),s=this.child();for(let n of e)for(let a of i){let l=a.isAbsolute(),h=a.pattern(),c=a.rest();h===J?s.testGlobstar(n,a,c,l):h instanceof RegExp?s.testRegExp(n,h,c,l):s.testString(n,h,c,l)}return s}testGlobstar(t,e,i,s){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,s,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(i&&e.checkFollowGlobstar()?this.subwalks.add(t,i):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),i){let n=i.pattern();if(typeof n=="string"&&n!==".."&&n!==""&&n!==".")this.testString(t,n,i.rest(),s);else if(n===".."){let a=t.parent||t;this.subwalks.add(a,i)}else n instanceof RegExp&&this.testRegExp(t,n,i.rest(),s)}}testRegExp(t,e,i,s){e.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,s,!1))}testString(t,e,i,s){t.isNamed(e)&&(i?this.subwalks.add(t,i):this.matches.add(t,s,!1))}}});var Bh,Xe,Zt,Ae,yt,Fe,Sr,ks,qi,Hi,Cn=D(()=>{"use strict";sr();mr();En();Bh=(o,t)=>typeof o=="string"?new Je([o],t):Array.isArray(o)?new Je(o,t):o,ks=class{constructor(t,e,i){y(this,yt);u(this,"path");u(this,"patterns");u(this,"opts");u(this,"seen",new Set);u(this,"paused",!1);u(this,"aborted",!1);y(this,Xe,[]);y(this,Zt);y(this,Ae);u(this,"signal");u(this,"maxDepth");u(this,"includeChildMatches");var s;if(this.patterns=t,this.path=e,this.opts=i,f(this,Ae,!i.posix&&i.platform==="win32"?"\\":"/"),this.includeChildMatches=i.includeChildMatches!==!1,(i.ignore||!this.includeChildMatches)&&(f(this,Zt,Bh((s=i.ignore)!=null?s:[],i)),!this.includeChildMatches&&typeof r(this,Zt).add!="function")){let n="cannot ignore child matches, ignore lacks add() method.";throw new Error(n)}this.maxDepth=i.maxDepth||1/0,i.signal&&(this.signal=i.signal,this.signal.addEventListener("abort",()=>{r(this,Xe).length=0}))}pause(){this.paused=!0}resume(){var e;if((e=this.signal)!=null&&e.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=r(this,Xe).shift());)t()}onResume(t){var e;(e=this.signal)!=null&&e.aborted||(this.paused?r(this,Xe).push(t):t())}async matchCheck(t,e){if(e&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||await t.realpath(),!i)return;t=i}let n=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&(n!=null&&n.isSymbolicLink())){let a=await n.realpath();a&&(a.isUnknown()||this.opts.stat)&&await a.lstat()}return this.matchCheckTest(n,e)}matchCheckTest(t,e){var i;return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!e||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!((i=t.realpathCached())!=null&&i.isDirectory()))&&!m(this,yt,Fe).call(this,t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||t.realpathSync(),!i)return;t=i}let n=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&(n!=null&&n.isSymbolicLink())){let a=n.realpathSync();a&&(a!=null&&a.isUnknown()||this.opts.stat)&&a.lstatSync()}return this.matchCheckTest(n,e)}matchFinish(t,e){var n;if(m(this,yt,Fe).call(this,t))return;if(!this.includeChildMatches&&((n=r(this,Zt))!=null&&n.add)){let a=`${t.relativePosix()}/**`;r(this,Zt).add(a)}let i=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let s=this.opts.mark&&t.isDirectory()?r(this,Ae):"";if(this.opts.withFileTypes)this.matchEmit(t);else if(i){let a=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(a+s)}else{let a=this.opts.posix?t.relativePosix():t.relative(),l=this.opts.dotRelative&&!a.startsWith(".."+r(this,Ae))?"."+r(this,Ae):"";this.matchEmit(a?l+a+s:"."+s)}}async match(t,e,i){let s=await this.matchCheck(t,i);s&&this.matchFinish(s,e)}matchSync(t,e,i){let s=this.matchCheckSync(t,i);s&&this.matchFinish(s,e)}walkCB(t,e,i){var s;(s=this.signal)!=null&&s.aborted&&i(),this.walkCB2(t,e,new Gi(this.opts),i)}walkCB2(t,e,i,s){var l;if(m(this,yt,Sr).call(this,t))return s();if((l=this.signal)!=null&&l.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2(t,e,i,s));return}i.processPatterns(t,e);let n=1,a=()=>{--n===0&&s()};for(let[h,c,p]of i.matches.entries())m(this,yt,Fe).call(this,h)||(n++,this.match(h,c,p).then(()=>a()));for(let h of i.subwalkTargets()){if(this.maxDepth!==1/0&&h.depth()>=this.maxDepth)continue;n++;let c=h.readdirCached();h.calledReaddir()?this.walkCB3(h,c,i,a):h.readdirCB((p,d)=>this.walkCB3(h,d,i,a),!0)}a()}walkCB3(t,e,i,s){i=i.filterEntries(t,e);let n=1,a=()=>{--n===0&&s()};for(let[l,h,c]of i.matches.entries())m(this,yt,Fe).call(this,l)||(n++,this.match(l,h,c).then(()=>a()));for(let[l,h]of i.subwalks.entries())n++,this.walkCB2(l,h,i.child(),a);a()}walkCBSync(t,e,i){var s;(s=this.signal)!=null&&s.aborted&&i(),this.walkCB2Sync(t,e,new Gi(this.opts),i)}walkCB2Sync(t,e,i,s){var l;if(m(this,yt,Sr).call(this,t))return s();if((l=this.signal)!=null&&l.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,i,s));return}i.processPatterns(t,e);let n=1,a=()=>{--n===0&&s()};for(let[h,c,p]of i.matches.entries())m(this,yt,Fe).call(this,h)||this.matchSync(h,c,p);for(let h of i.subwalkTargets()){if(this.maxDepth!==1/0&&h.depth()>=this.maxDepth)continue;n++;let c=h.readdirSync();this.walkCB3Sync(h,c,i,a)}a()}walkCB3Sync(t,e,i,s){i=i.filterEntries(t,e);let n=1,a=()=>{--n===0&&s()};for(let[l,h,c]of i.matches.entries())m(this,yt,Fe).call(this,l)||this.matchSync(l,h,c);for(let[l,h]of i.subwalks.entries())n++,this.walkCB2Sync(l,h,i.child(),a);a()}};Xe=new WeakMap,Zt=new WeakMap,Ae=new WeakMap,yt=new WeakSet,Fe=function(t){var e,i;return this.seen.has(t)||!!((i=(e=r(this,Zt))==null?void 0:e.ignored)!=null&&i.call(e,t))},Sr=function(t){var e,i;return!!((i=(e=r(this,Zt))==null?void 0:e.childrenIgnored)!=null&&i.call(e,t))};qi=class extends ks{constructor(e,i,s){super(e,i,s);u(this,"matches",new Set)}matchEmit(e){this.matches.add(e)}async walk(){var e;if((e=this.signal)!=null&&e.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((i,s)=>{this.walkCB(this.path,this.patterns,()=>{var n;(n=this.signal)!=null&&n.aborted?s(this.signal.reason):i(this.matches)})}),this.matches}walkSync(){var e;if((e=this.signal)!=null&&e.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{var i;if((i=this.signal)!=null&&i.aborted)throw this.signal.reason}),this.matches}},Hi=class extends ks{constructor(e,i,s){super(e,i,s);u(this,"results");this.results=new he({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}});var xn,Ih,Pt,br=D(()=>{"use strict";ee();xn=require("url");bn();dr();Cn();Ih=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Pt=class{constructor(t,e){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(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=(0,xn.fileURLToPath)(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.includeChildMatches=e.includeChildMatches!==!1,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(h=>h.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(h=>h.includes("/")?h:`./**/${h}`)}if(this.pattern=t,this.platform=e.platform||Ih,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let h=e.platform==="win32"?Ke:e.platform==="darwin"?Ci:e.platform?Ve:Sn;this.scurry=new h(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let i=this.platform==="darwin"||this.platform==="win32",s={...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:i,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},n=this.pattern.map(h=>new ht(h,s)),[a,l]=n.reduce((h,c)=>(h[0].push(...c.set),h[1].push(...c.globParts),h),[[],[]]);this.patterns=a.map((h,c)=>{let p=l[c];if(!p)throw new Error("invalid pattern object");return new Ye(h,p,0,this.platform)})}async walk(){return[...await new qi(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 qi(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 Hi(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 Hi(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}});var Er,Cr=D(()=>{"use strict";ee();Er=(o,t={})=>{Array.isArray(o)||(o=[o]);for(let e of o)if(new ht(e,t).hasMagic())return!0;return!1}});function vs(o,t={}){return new Pt(o,t).streamSync()}function Rn(o,t={}){return new Pt(o,t).stream()}function Tn(o,t={}){return new Pt(o,t).walkSync()}async function kn(o,t={}){return new Pt(o,t).walk()}function Rs(o,t={}){return new Pt(o,t).iterateSync()}function On(o,t={}){return new Pt(o,t).iterate()}var zh,Wh,jh,Uh,Qi,vn,xr=D(()=>{"use strict";ee();br();Cr();ee();br();Cr();mr();zh=vs,Wh=Object.assign(Rn,{sync:vs}),jh=Rs,Uh=Object.assign(On,{sync:Rs}),Qi=Object.assign(Tn,{stream:vs,iterate:Rs}),vn=Object.assign(kn,{glob:kn,globSync:Tn,sync:Qi,globStream:Rn,stream:Wh,globStreamSync:vs,streamSync:zh,globIterate:On,iterate:Uh,globIterateSync:Rs,iterateSync:jh,Glob:Pt,hasMagic:Er,escape:Le,unescape:Et});vn.glob=vn});function Fn(){let o=Qi("./**/Cookies",{cwd:_e,absolute:!0});return qh.debug("Found cookie files:",o),o}var $h,Gh,qh,An=D(()=>{"use strict";$h=require("fs"),Gh=require("path");xr();jt();Ms();qh=N.withTag("listChromeProfiles")});function Kh(o){var e;let t=[/.*?0t(.+)$/,/.*?1e`(.+)$/,/.*?[`'](.+)$/,/[^\x20-\x7E]*([\x20-\x7E].+)$/];for(let i of t){let s=o.match(i),n=(e=s==null?void 0:s[1])!=null?e:"";if(n.length>0)return n}return o}async function Dn(o,t){if(typeof t!="string")throw new Error("password must be a string");if(!Buffer.isBuffer(o))throw new Error("encryptedData must be a Buffer");return new Promise((e,i)=>{(0,Ts.pbkdf2)(t,"saltysalt",1003,16,"sha1",(s,n)=>{try{if(s){i(new Error("Failed to derive key: "+s.message));return}let a=Hh(o);if(a.length%16!==0){i(new Error("Encrypted data length is not a multiple of 16"));return}let l=Buffer.alloc(16," "),h=(0,Ts.createDecipheriv)("aes-128-cbc",n,l);h.setAutoPadding(!1);let c=h.update(a);try{h.final()}catch(d){i(new Error("Failed to finalize decryption: "+d.message));return}c=Qh(c);let p=c.toString("utf8");e(Kh(p))}catch(a){i(new Error("Decryption failed: "+a.message))}})})}var Ts,kr,Hh,Qh,_n=D(()=>{"use strict";Ts=require("crypto"),kr=require("lodash-es"),Hh=(0,kr.memoize)(o=>o.length>=3&&o[0]===118&&o[1]===49&&o[2]===48?o.slice(3):o,o=>o.toString("hex")),Qh=(0,kr.memoize)(o=>{let t=o[o.length-1];return t&&t<=16?o.slice(0,-t):o},o=>o.toString("hex"))});function Zh(o,t){if(o instanceof de)throw z("Command execution failed",o,{command:o.command,originalError:o.originalError}),o;if(o instanceof Error){let i=new de(o.message,t,o);throw z("Failed to execute command",o,{command:t,stack:o.stack}),i}let e=new de("Unknown error occurred during command execution",t);throw z("Failed to execute command",null,{error:o,command:t}),e}async function Mn(o,t={}){if(!o||typeof o!="string")throw new de("Command must be a non-empty string",o);let e={encoding:"utf8",maxBuffer:5*1024*1024,timeout:3e4};try{let{stdout:i,stderr:s}=await Vh(o,{...e,...t}),n=i.trim();if(!n)throw s?new de(`Command failed with stderr: ${s}`,o):new de("Command returned empty result",o);return n}catch(i){Zh(i,o)}}var Pn,Ln,Vh,de,Nn=D(()=>{"use strict";Pn=require("child_process"),Ln=require("util");Yt();Vh=(0,Ln.promisify)(Pn.exec),de=class extends Error{constructor(e,i,s){super(e);this.command=i;this.originalError=s;this.name="CommandExecutionError"}}});var In={};ge(In,{getChromePassword:()=>Jh});var Bn,Yh,Jh,zn=D(()=>{"use strict";Bn=require("lodash-es");Nn();Yh=async()=>Mn('security find-generic-password -w -s "Chrome Safe Storage"'),Jh=(0,Bn.memoize)(Yh)});var Wn,jn,Un=D(()=>{"use strict";Wn=require("lodash-es");Yt();jn=(0,Wn.memoize)(async()=>{if(process.platform!=="darwin")throw z("Chrome password retrieval failed",new Error("This only works on macOS"),{platform:process.platform}),new Error("This only works on macOS");try{let{getChromePassword:o}=await Promise.resolve().then(()=>(zn(),In)),t=await o();return Lt("ChromePassword","Retrieved password successfully",{platform:"macOS"}),t}catch(o){throw z("Chrome password retrieval failed",o,{platform:"macOS"}),o}})});function Xh(o){return typeof o!="number"||o<=0?"Infinity":new Date(o)}function $n(o,t,e,i,s,n){return{domain:o,name:t,value:e,expiry:Xh(i),meta:{file:s,browser:"Chrome",decrypted:n}}}var ti,vr=D(()=>{"use strict";Yt();qr();An();_n();Un();ti=class{constructor(){this.logger=Lr("ChromeCookieQueryStrategy");this.browserName="Chrome"}async queryCookies(t,e){try{if(this.logger.info("Querying cookies",{name:t,domain:e}),process.platform!=="darwin")return this.logger.warn("Platform not supported",{platform:process.platform}),[];let i=Fn();if(i.length===0)return this.logger.warn("No Chrome cookie files found"),[];let s=await jn();return(await Promise.all(i.map(a=>this.processFile(a,t,e,s)))).flat()}catch(i){return i instanceof Error?z("Failed to query cookies",i,{name:t,domain:e}):z("Failed to query cookies",new Error(String(i)),{name:t,domain:e}),[]}}async processFile(t,e,i,s){try{let n=await Gr({name:e,domain:i,file:t}),a={file:t,password:s};return(await Promise.allSettled(n.map(h=>this.processCookie(h,a)))).map(h=>h.status==="fulfilled"?h.value:null).filter(h=>h!==null)}catch(n){return n instanceof Error?this.logger.error("Failed to process cookie file",{error:n,file:t}):this.logger.error("Failed to process cookie file",{error:String(n),file:t}),[]}}async processCookie(t,e){try{let i=Buffer.isBuffer(t.value)?t.value:Buffer.from(String(t.value)),s=await Dn(i,e.password);return $n(t.domain,t.name,s,t.expiry,e.file,!0)}catch(i){return i instanceof Error?this.logger.warn("Failed to decrypt cookie",{error:i}):this.logger.warn("Failed to decrypt cookie",{error:String(i)}),$n(t.domain,t.name,t.value.toString("utf-8"),t.expiry,e.file,!1)}}}});function tl(){let o=[],t=process.env.HOME;if(typeof t!="string"||t.length===0)return Yi("FirefoxCookieQuery","HOME environment variable not set"),o;let e=[(0,Rr.join)(t,"Library/Application Support/Firefox/Profiles/*/cookies.sqlite"),(0,Rr.join)(t,".mozilla/firefox/*/cookies.sqlite")];for(let i of e){let s=Qi(i);o.push(...s)}return Lt("FirefoxCookieQuery","Found Firefox cookie files",{files:o}),o}var Rr,ei,Tr=D(()=>{"use strict";Rr=require("path");xr();Yt();Ns();ei=class{constructor(){this.browserName="Firefox"}async queryCookies(t,e){let i=tl(),s=[];for(let n of i)try{let a=await Xi({file:n,sql:"SELECT name, value, host as domain, expiry FROM moz_cookies WHERE name = ? AND host LIKE ?",params:[t,`%${e}%`],rowTransform:l=>({name:l.name,value:l.value,domain:l.domain,expiry:l.expiry>0?new Date(l.expiry*1e3):"Infinity",meta:{file:n,browser:"Firefox",decrypted:!1}})});s.push(...a)}catch(a){a instanceof Error?Yi("FirefoxCookieQuery",`Error reading Firefox cookie file ${n}`,{error:a.message}):Yi("FirefoxCookieQuery",`Error reading Firefox cookie file ${n}`)}return s}}});var Gn,F,Os,Fs,qn,Hn,Qn,df,el,Ki,mf,gf,il,wf,As=D(()=>{"use strict";Gn=De(require("destr"),1),F=require("zod"),Os=F.z.string().trim().min(1,"Domain cannot be empty").refine(o=>/^\.?[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(o),"Invalid domain format"),Fs=F.z.string().trim().min(1,"Cookie name cannot be empty").refine(o=>/^[\x21\x23-\x27\x2A\x2B\x2D-\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+$/.test(o),"Invalid cookie name format - must contain only valid characters (letters, numbers, and certain symbols)"),qn=F.z.string().trim().min(1,"Path cannot be empty").refine(o=>o.startsWith("/"),"Path must start with /").refine(o=>/^\/[!#$%&'()*+,\-./:=@\w]*$/.test(o),"Invalid path format - must contain only valid URL path characters").default("/"),Hn=F.z.string().trim().transform(o=>(0,Gn.default)(o)).pipe(F.z.any()),Qn=F.z.object({name:Fs,value:Hn,domain:Os,path:qn,expiry:F.z.number().int(),creation:F.z.number().int(),flags:F.z.number().optional(),version:F.z.number().int().optional(),port:F.z.number().int().optional(),comment:F.z.string().optional(),commentURL:F.z.string().optional()}),df=F.z.object({name:Fs,domain:Os}).strict(),el=F.z.object({file:F.z.string().trim().min(1,"File path cannot be empty").optional(),browser:F.z.string().trim().optional(),decrypted:F.z.boolean().optional(),secure:F.z.boolean().optional(),httpOnly:F.z.boolean().optional(),path:qn.optional()}).catchall(F.z.unknown()).strict(),Ki=F.z.object({domain:Os,name:Fs,value:Hn,expiry:F.z.union([F.z.literal("Infinity"),F.z.date(),F.z.number().int().positive("Expiry must be a positive number")]).optional(),meta:el.optional()}).strict(),mf=F.z.object({expiry:F.z.number().int().optional(),domain:Os,name:Fs,value:F.z.union([F.z.string(),F.z.instanceof(Buffer)])}).strict(),gf=F.z.object({format:F.z.enum(["merged","grouped"]).optional(),separator:F.z.string().optional(),showFilePaths:F.z.boolean().optional()}).strict(),il=F.z.enum(["Chrome","Firefox","Safari","internal","unknown"]),wf=F.z.object({browserName:il,queryCookies:F.z.function().args(F.z.string(),F.z.string()).returns(F.z.promise(F.z.array(Ki)))}).strict()});function al(o,t){let e=t;for(;e<o.length&&o[e]!==0;)e++;return[o.toString("utf8",t,e),e+1]}function hl(o,t){let e=o.readUInt32LE(t),i=o.readUInt32LE(t+4),s=o.readUInt32LE(t+8),n=o.readUInt32LE(t+12),a=o.readUInt32LE(t+16),l=o.readUInt32LE(t+20),h=o.readUInt32LE(t+24),c=o.readUInt32LE(t+28),p=o.readUInt32LE(t+32),d=o.readUInt32LE(t+36),w=o.readDoubleLE(t+40)+Kn,E=o.readDoubleLE(t+48)+Kn,x=t+56,g;n&&(g=o.readUInt16LE(x),x+=2);let C=[{field:"url",offset:a},{field:"name",offset:l},{field:"path",offset:h},{field:"value",offset:c},{field:"comment",offset:p},{field:"commentURL",offset:d}].sort((R,A)=>R.offset-A.offset),S={};for(let{field:R,offset:A}of C)if(A>0){let[_,I]=al(o,t+A);S[R]=_,x=Math.max(x,I)}return[Qn.parse({name:S.name,value:S.value,domain:S.url.startsWith(".")?S.url.slice(1):S.url,path:S.path||"/",expiry:Math.floor(w),creation:Math.floor(E),flags:s,version:i,port:g,comment:S.comment,commentURL:S.commentURL}),e]}function ll(o,t,e){let i=t+5,s=o.readUInt32BE(i),n=t+s,a=[],l=t+e;for(;n<l-8;)try{let[h,c]=hl(o,n);a.push(h),n+=c}catch(h){console.warn(`Error decoding cookie at offset ${n}:`,h);break}return a}function Zn(o){let t=(0,Vn.readFileSync)(o);if(t.toString("utf8",0,4)!==ol)throw new Error("Invalid cookie file format: wrong magic header");let i=t.readUInt32BE(4),s=[];for(let h=0;h<i;h++)s.push(t.readUInt32BE(8+h*4));let n=8+i*4,a=[];for(let h=0;h<i;h++)try{let c=ll(t,n,s[h]);a.push(...c),n+=s[h]}catch(c){console.warn(`Error decoding page ${h}:`,c),n+=s[h]}return Number(t.readBigUInt64BE(t.length-8))!==nl&&console.warn("Invalid cookie file format: wrong footer"),a}var Vn,sl,rl,ol,nl,Kn,Yn=D(()=>{"use strict";Vn=require("fs"),sl=require("os"),rl=require("path");As();ol="cook",nl=510912288576766e3,Kn=978307200});var Jn,Ds,Xn=D(()=>{"use strict";Jn=require("path");Yt();Yn();Ds=class{constructor(){this.browserName="Safari"}getHomeDir(){let t=process.env.HOME;return typeof t!="string"||t.trim().length===0?(z("SafariCookieQueryStrategy","HOME environment variable not set"),""):t}getCookieDbPath(t){return(0,Jn.join)(t,"Library","Containers","com.apple.Safari","Data","Library","Cookies","Cookies.binarycookies")}decodeCookies(t,e,i){try{return Zn(t).filter(n=>n.name===e&&n.domain.includes(i)).map(n=>({domain:n.domain,name:n.name,value:Buffer.isBuffer(n.value)?n.value.toString():String(n.value),expiry:typeof n.expiry=="number"&&n.expiry>0?new Date(n.expiry*1e3):"Infinity",meta:{file:t,browser:"Safari",decrypted:!1}}))}catch(s){return s instanceof Error?z("SafariCookieQueryStrategy",`Error decoding ${t}`,{error:s,name:e,domain:i}):z("SafariCookieQueryStrategy",`Error decoding ${t}`,{error:"Unknown error",name:e,domain:i}),[]}}async queryCookies(t,e){let i=this.getHomeDir();if(typeof i!="string"||i.length===0)return Promise.resolve([]);let s=this.getCookieDbPath(i);return Promise.resolve(this.decodeCookies(s,t,e))}}});async function ta(o){if(!o.name||!o.domain)return[];let{name:t,domain:e}=o;if(typeof t!="string"||typeof e!="string")return[];let i=[new ti,new ei,new Ds];return(await Promise.allSettled(i.map(n=>n.queryCookies(t,e)))).filter(n=>n.status==="fulfilled").flatMap(n=>n.value)}var ea=D(()=>{"use strict";vr();Tr();Xn()});var ia={};ge(ia,{default:()=>cl,getCookie:()=>ii});async function ii(o){try{return await ta(o)}catch(t){return N.warn("Error querying cookies:",t instanceof Error?t.message:String(t)),[]}}var cl,_s=D(()=>{"use strict";jt();ea();cl=ii});var ra={};ge(ra,{default:()=>fl,getChromeCookie:()=>sa});async function sa(o){try{return await new ti().queryCookies(o.name,o.domain)}catch(t){return N.warn("Error querying Chrome cookies:",t),[]}}var fl,oa=D(()=>{"use strict";jt();vr();fl=sa});var aa={};ge(aa,{default:()=>ul,getFirefoxCookie:()=>na});async function na(o){try{return await new ei().queryCookies(o.name,o.domain)}catch(t){return N.warn("Error querying Firefox cookies:",t instanceof Error?t.message:String(t)),[]}}var ul,ha=D(()=>{"use strict";jt();Tr();ul=na});function Ps(o,t={}){let{format:e="merged",showFilePaths:i=!0,separator:s="; "}=t;if(o.length===0)return e==="merged"?"":[];if(e==="merged")return o.map(a=>a.value).join(s);let n=(0,la.groupBy)(o,a=>{var l,h;return(h=(l=a.meta)==null?void 0:l.file)!=null?h:"unknown"});return Object.entries(n).map(([a,l])=>{let h=l.map(c=>c.value).join(s);return i?`${a}: ${h}`:h})}var la,Or=D(()=>{"use strict";la=require("lodash-es")});var fa={};ge(fa,{default:()=>pl,getGroupedRenderedCookies:()=>ca});async function ca(o,t={}){try{let e=await ii(o);if(!Array.isArray(e))return[];let i=e.filter(s=>{let n=Ki.safeParse(s);return n.success?!0:(N.warn("Invalid cookie format:",n.error.format()),!1)});return Ps(i,{...t,format:"grouped"})}catch(e){return N.warn("Error getting grouped rendered cookies:",e instanceof Error?e.message:String(e)),[]}}var pl,ua=D(()=>{"use strict";As();jt();_s();Or();pl=ca});var da={};ge(da,{default:()=>dl,getMergedRenderedCookies:()=>pa});async function pa(o,t){try{let e=await ii(o);if(!Array.isArray(e))return"";let i=e.filter(n=>{let a=Ki.safeParse(n);return a.success?!0:(N.warn("Invalid cookie format:",a.error.format()),!1)}),s=Ps(i,{...t,format:"merged"});return typeof s=="string"?s:""}catch(e){return N.warn("Error getting merged rendered cookies:",e instanceof Error?e.message:String(e)),""}}var dl,ma=D(()=>{"use strict";As();jt();_s();Or();dl=pa});var bl={};ge(bl,{getChromeCookie:()=>gl,getCookie:()=>ml,getFirefoxCookie:()=>wl,getGroupedRenderedCookies:()=>yl,getMergedRenderedCookies:()=>Sl});module.exports=Ca(bl);var ml=()=>Promise.resolve().then(()=>(_s(),ia)).then(o=>o.getCookie),gl=()=>Promise.resolve().then(()=>(oa(),ra)).then(o=>o.getChromeCookie),wl=()=>Promise.resolve().then(()=>(ha(),aa)).then(o=>o.getFirefoxCookie),yl=()=>Promise.resolve().then(()=>(ua(),fa)).then(o=>o.getGroupedRenderedCookies),Sl=()=>Promise.resolve().then(()=>(ma(),da)).then(o=>o.getMergedRenderedCookies);0&&(module.exports={getChromeCookie,getCookie,getFirefoxCookie,getGroupedRenderedCookies,getMergedRenderedCookies});
|
|
1
|
+
"use strict";var Ie=Object.create;var T=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var _e=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var qe=(r,e)=>{for(var o in e)T(r,o,{get:e[o],enumerable:!0})},Y=(r,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ue(e))!ze.call(r,i)&&i!==o&&T(r,i,{get:()=>e[i],enumerable:!(t=De(e,i))||t.enumerable});return r};var B=(r,e,o)=>(o=r!=null?Ie(_e(r)):{},Y(e||!r||!r.__esModule?T(o,"default",{value:r,enumerable:!0}):o,r)),Ae=r=>Y(T({},"__esModule",{value:!0}),r);var ao={};qe(ao,{getChromeCookie:()=>Z,getCookie:()=>w,getFirefoxCookie:()=>J,getGroupedRenderedCookies:()=>K,getMergedRenderedCookies:()=>X});module.exports=Ae(ao);var re=require("consola");var ee=require("os"),oe=require("dotenv"),O=require("zod");(0,oe.config)();var $e=O.z.object({LOG_LEVEL:O.z.enum(["debug","info","warn","error"]).default("info"),HOME:O.z.string().optional().transform(r=>r??process.env.USERPROFILE??"").pipe(O.z.string().min(1))}),M=$e.parse({LOG_LEVEL:process.env.LOG_LEVEL,HOME:(0,ee.homedir)()});var Qe=(0,re.createConsola)({fancy:!0,formatOptions:{showLogLevel:!1,colors:!0,date:!1,compact:!0,columns:typeof process.stdout.columns=="number"?process.stdout.columns:80},level:M.LOG_LEVEL==="debug"?5:2}),uo=M.LOG_LEVEL==="debug",Ne=Qe,u=Ne;function te(r,e,o){e?u.success(`${r} succeeded`,o):u.error(`${r} failed`,o)}function p(r,e,o){let t=e instanceof Error?e.message:String(e);u.error(r,{...o,error:t})}function y(r,e,o){u.warn(`[${r}] ${e}`,o)}function g(r){return u.withTag(r)}var ae=require("fs"),D=require("path"),fe=B(require("fast-glob"),1);var ie=require("os"),se=require("path"),E=(()=>{let r=(0,ie.homedir)();if(!r)throw new Error("Unable to determine user home directory");return(0,se.join)(r,"Library","Application Support","Google","Chrome")})();var ne=B(require("better-sqlite3"),1);function Me(r){try{return new ne.default(r,{readonly:!0,fileMustExist:!0})}catch(e){throw p("Database open failed",e,{file:r}),e}}function je(r){try{return r.close(),Promise.resolve()}catch(e){return p("Database close failed",e),Promise.reject(e instanceof Error?e:new Error("Failed to close database: Unknown error"))}}async function I({file:r,sql:e,params:o,rowFilter:t,rowTransform:i}){let s;try{s=Me(r);let c=s.prepare(e).all(o),f=t?c.filter(t):c;return i?f.map(i):f}catch(n){throw p("Database query failed",n,{file:r,sql:e}),n}finally{s&&await je(s)}}var P=g("getEncryptedChromeCookie");function Ve(r){if(typeof r!="string")return!1;let e=r.trim();return e.length===0?!1:(0,ae.existsSync)(e)}async function He(){let r=[(0,D.join)(E,"Default/Cookies"),(0,D.join)(E,"Profile */Cookies"),(0,D.join)(E,"Profile Default/Cookies")],e=[];for(let o of r){let t=await(0,fe.default)(o);e.push(...t)}return P.debug("ChromeCookies","Found cookie files",{count:e.length,files:e}),e}function Ge(r,e){let o=r==="%",t=o?"SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE host_key LIKE ?":"SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE name = ? AND host_key LIKE ?",i=o?[`%${e}%`]:[r,`%${e}%`];return{sql:t,params:i}}async function We(r,e,o){try{let{sql:t,params:i}=Ge(e,o);P.debug("ChromeCookies","Executing query",{sql:t,params:i});let s=await I({file:r,sql:t,params:i,rowTransform:n=>({name:n.name,domain:n.host_key,value:n.encrypted_value,expiry:n.expires_utc})});return te("QueryCookies",!0,{file:r,count:s.length}),s}catch(t){return p("Failed to read cookie file",t,{file:r}),[]}}async function ce({name:r,domain:e,file:o}){let t=typeof o=="string"&&o.length>0?[o]:await He();if(t.length===0)return P.debug("ChromeCookies","No cookie files found"),[];let i=[];for(let s of t){if(!Ve(s)){P.debug("ChromeCookies","Cookie file missing or invalid",{file:s});continue}let n=await We(s,r,e);i.push(...n)}return P.debug("ChromeCookies","Query complete",{totalCookies:i.length}),i}var Ze=require("fs"),Je=require("path"),me=B(require("fast-glob"),1);var Ke=g("listChromeProfiles");function ue(){let r=me.default.sync("./**/Cookies",{cwd:E,absolute:!0});return Ke.debug("Found cookie files:",r),r}var U=require("crypto"),j=require("lodash-es"),Xe=(0,j.memoize)(r=>r.length>=3&&r[0]===118&&r[1]===49&&r[2]===48?r.slice(3):r,r=>r.toString("hex")),Ye=(0,j.memoize)(r=>{let e=r[r.length-1];return e&&e<=16?r.slice(0,-e):r},r=>r.toString("hex"));function eo(r){let e=[/.*?0t(.+)$/,/.*?1e`(.+)$/,/.*?[`'](.+)$/,/[^\x20-\x7E]*([\x20-\x7E].+)$/];for(let o of e){let i=r.match(o)?.[1]??"";if(i.length>0)return i}return r}async function pe(r,e){if(typeof e!="string")throw new Error("password must be a string");if(!Buffer.isBuffer(r))throw new Error("encryptedData must be a Buffer");return new Promise((o,t)=>{(0,U.pbkdf2)(e,"saltysalt",1003,16,"sha1",(i,s)=>{try{if(i){t(new Error("Failed to derive key: "+i.message));return}let n=Xe(r);if(n.length%16!==0){t(new Error("Encrypted data length is not a multiple of 16"));return}let c=Buffer.alloc(16," "),f=(0,U.createDecipheriv)("aes-128-cbc",s,c);f.setAutoPadding(!1);let m=f.update(n);try{f.final()}catch(d){t(new Error("Failed to finalize decryption: "+d.message));return}m=Ye(m);let l=m.toString("utf8");o(eo(l))}catch(n){t(new Error("Decryption failed: "+n.message))}})})}var H=require("os");var le=require("child_process"),ge=require("util");var oo=(0,ge.promisify)(le.exec),V=class extends Error{constructor(o,t,i){super(o);this.command=t;this.originalError=i;this.name="CommandExecutionError"}};async function de(r,e){try{let o=await oo(r,{...e,encoding:"utf8"});return{stdout:o.stdout.toString(),stderr:o.stderr.toString()}}catch(o){throw p("Command execution failed",o,{command:r}),new V(o instanceof Error?o.message:String(o),r,o instanceof Error?o:void 0)}}async function ye(){return(await de('security find-generic-password -w -s "Chrome Safe Storage"')).stdout.trim()}async function he(){switch((0,H.platform)()){case"darwin":return ye();default:throw new Error(`Platform ${(0,H.platform)()} is not supported`)}}function ro(r){return typeof r!="number"||r<=0?"Infinity":new Date(r)}function Ce(r,e,o,t,i,s){return{domain:r,name:e,value:o,expiry:ro(t),meta:{file:i,browser:"Chrome",decrypted:s}}}var S=class{constructor(){this.logger=g("ChromeCookieQueryStrategy");this.browserName="Chrome"}async queryCookies(e,o,t){try{if(this.logger.info("Querying cookies",{name:e,domain:o,store:t}),process.platform!=="darwin")return this.logger.warn("Platform not supported",{platform:process.platform}),[];let i=t??ue(),s=Array.isArray(i)?i:[i];if(s.length===0)return this.logger.warn("No Chrome cookie files found"),[];let n=await he();return(await Promise.all(s.map(f=>this.processFile(f,e,o,n)))).flat()}catch(i){return i instanceof Error?p("Failed to query cookies",i,{name:e,domain:o}):p("Failed to query cookies",new Error(String(i)),{name:e,domain:o}),[]}}async processFile(e,o,t,i){try{let s=await ce({name:o,domain:t,file:e}),n={file:e,password:i};return(await Promise.allSettled(s.map(f=>this.processCookie(f,n)))).map(f=>f.status==="fulfilled"?f.value:null).filter(f=>f!==null)}catch(s){return s instanceof Error?this.logger.error("Failed to process cookie file",{error:s,file:e}):this.logger.error("Failed to process cookie file",{error:String(s),file:e}),[]}}async processCookie(e,o){try{let t=Buffer.isBuffer(e.value)?e.value:Buffer.from(String(e.value)),i=await pe(t,o.password);return Ce(e.domain,e.name,i,e.expiry,o.file,!0)}catch(t){return t instanceof Error?this.logger.warn("Failed to decrypt cookie",{error:t}):this.logger.warn("Failed to decrypt cookie",{error:String(t)}),Ce(e.domain,e.name,e.value.toString("utf-8"),e.expiry,o.file,!1)}}};var ke=require("os"),G=require("path"),be=B(require("fast-glob"),1);var to=g("FirefoxCookieQueryStrategy");function io(){let r=(0,ke.homedir)();if(!r)return y("FirefoxCookieQuery","Failed to get home directory"),[];let e=[(0,G.join)(r,"Library/Application Support/Firefox/Profiles/*/cookies.sqlite"),(0,G.join)(r,".mozilla/firefox/*/cookies.sqlite")],o=[];for(let t of e){let i=be.default.sync(t);o.push(...i)}return to.debug("Found Firefox cookie files",{files:o}),o}var v=class{constructor(){this.browserName="Firefox"}async queryCookies(e,o,t){let i=t??io(),s=Array.isArray(i)?i:[i],n=[];for(let c of s)try{let f=await I({file:c,sql:"SELECT name, value, host as domain, expiry FROM moz_cookies WHERE name = ? AND host LIKE ?",params:[e,`%${o}%`],rowTransform:m=>({name:m.name,value:m.value,domain:m.domain,expiry:m.expiry>0?new Date(m.expiry*1e3):"Infinity",meta:{file:c,browser:"Firefox",decrypted:!1}})});n.push(...f)}catch(f){f instanceof Error?y("FirefoxCookieQuery",`Error reading Firefox cookie file ${c}`,{error:f.message}):y("FirefoxCookieQuery",`Error reading Firefox cookie file ${c}`)}return n}};var Fe=require("os"),Le=require("path");var ve=require("buffer"),Re=require("fs"),Be=require("os"),Oe=require("path");var q=require("buffer");var we=B(require("destr"),1),a=require("zod"),_=a.z.string().trim().min(1,"Domain cannot be empty").refine(r=>/^\.?[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(r),"Invalid domain format"),z=a.z.string().trim().min(1,"Cookie name cannot be empty").refine(r=>r==="%"||/^[!#$%&'()*+\-.:0-9A-Z \^_`a-z|~]+$/.test(r),"Invalid cookie name format - must contain only valid characters (letters, numbers, and certain symbols) or be '%' for wildcard"),xe=a.z.string().trim().min(1,"Path cannot be empty").refine(r=>r.startsWith("/"),"Path must start with /").refine(r=>/^\/[!#$%&'()*+,\-./:=@\w~]*$/.test(r),"Invalid path format - must contain only valid URL path characters").default("/"),Ee=a.z.string().trim().transform(r=>(0,we.default)(r)).pipe(a.z.any()),Se=a.z.object({name:z,value:Ee,domain:_,path:xe,expiry:a.z.number().int(),creation:a.z.number().int(),flags:a.z.number().optional(),version:a.z.number().int().optional(),port:a.z.number().int().optional(),comment:a.z.string().optional(),commentURL:a.z.string().optional()}),Vo=a.z.object({name:z,domain:_}).strict(),so=a.z.object({file:a.z.string().trim().min(1,"File path cannot be empty").optional(),browser:a.z.string().trim().optional(),decrypted:a.z.boolean().optional(),secure:a.z.boolean().optional(),httpOnly:a.z.boolean().optional(),path:xe.optional()}).catchall(a.z.unknown()).strict(),F=a.z.object({domain:_,name:z,value:Ee,expiry:a.z.union([a.z.literal("Infinity"),a.z.date(),a.z.number().int().positive("Expiry must be a positive number")]).optional(),meta:so.optional()}).strict(),Ho=a.z.object({expiry:a.z.number().int().optional(),domain:_,name:z,value:a.z.union([a.z.string(),a.z.instanceof(Buffer)])}).strict(),Go=a.z.object({format:a.z.enum(["merged","grouped"]).optional(),separator:a.z.string().optional(),showFilePaths:a.z.boolean().optional()}).strict(),no=a.z.enum(["Chrome","Firefox","Safari","internal","unknown"]),Wo=a.z.object({browserName:no,queryCookies:a.z.function().args(a.z.string(),a.z.string(),a.z.string().optional()).returns(a.z.promise(a.z.array(F)))}).strict();var k=g("BinaryCodableCookie"),A=class{constructor(e){this.version=0;this.url="";this.name="";this.path="";this.value="";this.flags={isSecure:!1,isHTTPOnly:!1,unknown1:!1,unknown2:!1};this.expiration=0;this.creation=0;let o={offset:0,buffer:e};this.decode(o)}decodeUrlValue(e){let o=e,t;do{t=o;try{o=decodeURIComponent(o)}catch{return t}}while(o!==t&&o.includes("%"));return o}decodeJwtPayload(e){let o=e.split(".");if(o.length!==3)return null;try{let t=q.Buffer.from(o[1],"base64").toString("utf8"),i=JSON.parse(t);return JSON.stringify(i)}catch{return null}}parseJsonValue(e){try{let o=JSON.parse(e);return JSON.stringify(o)}catch{return null}}processValue(e){let o=this.decodeUrlValue(e);if(o.match(/^ey[A-Za-z0-9_-]+\.ey[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/)){let t=this.decodeJwtPayload(o);if(typeof t=="string"&&t.length>0)return t}if(o.startsWith("{")||o.startsWith("[")){let t=this.parseJsonValue(o);if(typeof t=="string"&&t.length>0)return t}return o}toCookieRow(){try{let e=this.convertFlags(),o=this.url.replace(/^https?:\/\//,"").replace(/\/.*$/,"")||"uk",t=978307200,i=this.expiration>0?this.expiration+t:this.expiration,s=this.creation>0?this.creation+t:this.creation;return Se.parse({name:this.name.replace(/^: /,""),value:this.processValue(this.value)||"",domain:o,path:this.path||"/",expiry:i,creation:s,flags:e,version:this.version,port:this.port,comment:this.comment,commentURL:this.commentURL})}catch{return null}}readNullTerminatedString(e,o){let t=o;for(;t<e.buffer.length&&e.buffer[t]!==0;)t++;return e.buffer.toString("utf8",o,t)||""}readHeader(e){let o=e.buffer.readUInt32LE(e.offset);k.debug("Cookie size:",o),e.offset+=4;let t=e.buffer.readUInt32LE(e.offset);k.debug("Cookie version:",t),e.offset+=4;let i=e.buffer.readUInt32LE(e.offset);k.debug("Cookie flags:",i.toString(2).padStart(8,"0")),e.offset+=4,this.flags={isSecure:(i&1)!==0,isHTTPOnly:(i&4)!==0,unknown1:(i&8)!==0,unknown2:(i&16)!==0};let s=e.buffer.readUInt32LE(e.offset);k.debug("Has port:",s),e.offset+=4;let n={urlOffset:e.buffer.readUInt32LE(e.offset),nameOffset:e.buffer.readUInt32LE(e.offset+4),pathOffset:e.buffer.readUInt32LE(e.offset+8),valueOffset:e.buffer.readUInt32LE(e.offset+12),commentOffset:e.buffer.readUInt32LE(e.offset+16),commentURLOffset:e.buffer.readUInt32LE(e.offset+20)};return k.debug("String offsets:",n),{size:o,hasPort:s,offsets:n}}readTimestamps(e){let o=q.Buffer.alloc(8);for(let n=0;n<8;n++)o[n]=e.buffer[e.offset+n];let t=o.readDoubleLE(0);e.offset+=8;let i=q.Buffer.alloc(8);for(let n=0;n<8;n++)i[n]=e.buffer[e.offset+n];let s=i.readDoubleLE(0);e.offset+=8,this.expiration=t,this.creation=s}readStrings(e,o,t){k.debug("Reading strings from cookie buffer of size:",o);let s=[{field:"url",offset:t.urlOffset},{field:"name",offset:t.nameOffset},{field:"path",offset:t.pathOffset},{field:"value",offset:t.valueOffset},{field:"comment",offset:t.commentOffset}].filter(n=>n.offset>0).sort((n,c)=>n.offset-c.offset);k.debug("Reading strings in order:",s.map(n=>n.field));for(let n=0;n<s.length;n++){let{field:c,offset:f}=s[n],l=(n<s.length-1?s[n+1].offset:o)-f,d=0+f;for(;d<0+f+l&&e.buffer[d]!==0;)d++;let x=e.buffer.toString("utf8",0+f,d);switch(k.debug(`Read ${c}:`,x),c){case"url":this.url=x;break;case"name":this.name=x;break;case"path":this.path=x;break;case"value":this.value=x;break;case"comment":this.comment=x;break}}}decode(e){let{size:o,hasPort:t,offsets:i}=this.readHeader(e),s=e.offset;e.offset=s+24,this.readTimestamps(e),t>0&&(this.port=e.buffer.readUInt16LE(e.offset),e.offset+=2),e.offset=s,this.readStrings(e,o,i)}convertFlags(){return(this.flags.isSecure?1:0)|(this.flags.isHTTPOnly?4:0)|(this.flags.unknown1?8:0)|(this.flags.unknown2?16:0)}};var h=g("BinaryCodablePage"),R=class R{constructor(e){this.cookies=[];let o={offset:0,buffer:e};this.decode(o)}toCookieRows(){let e=[];for(let o of this.cookies)try{let t=o.toCookieRow();t!==null&&e.push(t)}catch(t){let i=t instanceof Error?t.message:String(t);y("BinaryCookies","Error converting cookie",{error:i})}return e}decode(e){let o=e.buffer.readUInt32BE(e.offset);if(h.debug("Page header:",o.toString(16)),e.offset+=4,o!==R.HEADER)throw new Error("Invalid page header");let t=e.buffer.readUInt32LE(e.offset);h.debug("Cookie count:",t),e.offset+=4;let i=e.offset-8;h.debug("Page start offset:",i);let s=[];for(let c=0;c<t;c++){let f=e.buffer.readUInt32LE(e.offset);s.push(f),h.debug(`Cookie ${c} offset:`,f),e.offset+=4}let n=e.buffer.readUInt32BE(e.offset);if(h.debug("Page footer:",n.toString(16)),e.offset+=4,n!==R.FOOTER)throw new Error("Invalid page footer");for(let c=0;c<t;c++)try{let f=s[c];h.debug(`Reading cookie ${c} at offset:`,f);let m=e.buffer.readUInt32LE(f);if(h.debug(`Cookie ${c} size:`,m),m<48){h.warn(`Invalid cookie size ${m} at index ${c}`);continue}if(f+m>e.buffer.length){h.warn(`Cookie size ${m} at index ${c} would exceed buffer length ${e.buffer.length}`);continue}let l=e.buffer.subarray(f,f+m),d=new A(l);this.cookies.push(d)}catch(f){h.warn("Invalid cookie data",{error:f instanceof Error?f.message:String(f)})}}};R.HEADER=256,R.FOOTER=0;var $=R;var b=g("BinaryCodableCookies"),C=class C{constructor(e){let o={offset:0,buffer:e};this.pages=[],this.metadata={},this.decode(o)}static fromFile(e){let o=(0,Re.readFileSync)(e);return new C(o)}static fromDefaultPath(){return C.fromFile(C.DEFAULT_COOKIE_PATH)}toCookieRows(){let e=[];for(let o of this.pages)try{let t=o.toCookieRows();Array.isArray(t)&&e.push(...t)}catch(t){let i=t instanceof Error?t.message:String(t);y("BinaryCookies","Error converting page cookies",{error:i})}return e}decode(e){try{let o=e.buffer.subarray(e.offset,e.offset+4);if(e.offset+=4,b.debug("Magic bytes:",o.toString()),!o.equals(C.MAGIC))throw new Error("Missing magic value");let t=e.buffer.readUInt32BE(e.offset);b.debug("Page count:",t),e.offset+=4;let i=[];for(let m=0;m<t;m++){let l=e.buffer.readUInt32BE(e.offset);i.push(l),b.debug(`Page ${m} size:`,l),e.offset+=4}let s=e.offset;b.debug("Starting page data at offset:",s);for(let m of i)try{b.debug("Reading page at offset:",s,"with size:",m);let l=e.buffer.subarray(s,s+m),d=new $(l);this.pages.push(d),s+=m}catch(l){let d=l instanceof Error?l.message:String(l);b.warn("Error decoding page:",{error:d}),s+=m}e.offset=s;let n=e.buffer.readUInt32BE(e.offset);b.debug("Checksum:",n.toString(16)),e.offset+=4;let c=e.buffer.readBigUInt64BE(e.offset);b.debug("Footer:",c.toString(16)),e.offset+=8,c!==C.FOOTER&&y("BinaryCookies","Invalid cookie file format: wrong footer");let f=e.buffer.subarray(e.offset);this.metadata={}}catch(o){let t=o instanceof Error?o.message:String(o);throw y("BinaryCookies","Error decoding binary cookies file",{error:t}),o}}};C.MAGIC=ve.Buffer.from("cook","utf8"),C.FOOTER=BigInt("0x071720050000004b"),C.DEFAULT_COOKIE_PATH=(0,Oe.join)((0,Be.homedir)(),"Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies");var Q=C;function Pe(r){return Q.fromFile(r).toCookieRows()}var N=class{constructor(){this.browserName="Safari"}getCookieDbPath(e){return(0,Le.join)(e,"Library","Containers","com.apple.Safari","Data","Library","Cookies","Cookies.binarycookies")}formatDomain(e){return e.startsWith(".")?e.slice(1):e}formatExpiry(e){return e<=0?"Infinity":new Date(e*1e3)}isFlagSet(e,o){return typeof e!="number"||isNaN(e)||e<=0?!1:(e&o)===o}formatCreation(e){if(!(typeof e!="number"||isNaN(e)||e<=0))return e*1e3}decodeCookies(e,o,t){try{return Pe(e).filter(s=>(o==="%"||s.name===o)&&(t==="%"||this.formatDomain(s.domain).includes(t))).map(s=>({domain:this.formatDomain(s.domain),name:s.name,value:Buffer.isBuffer(s.value)?s.value.toString():String(s.value),expiry:this.formatExpiry(s.expiry),meta:{file:e,browser:"Safari",decrypted:!1,secure:this.isFlagSet(s.flags,1),httpOnly:this.isFlagSet(s.flags,4),path:s.path,version:s.version,comment:s.comment,commentURL:s.commentURL,port:s.port,creation:this.formatCreation(s.creation)}}))}catch(i){return i instanceof Error?p("SafariCookieQueryStrategy",`Error decoding ${e}`,{error:i,name:o,domain:t}):p("SafariCookieQueryStrategy",`Error decoding ${e}`,{error:"Unknown error",name:o,domain:t}),[]}}async queryCookies(e,o,t){let i=(0,Fe.homedir)();if(typeof i!="string"||i.length===0)return p("SafariCookieQueryStrategy","Failed to get home directory"),Promise.resolve([]);let s=t??this.getCookieDbPath(i);return Promise.resolve(this.decodeCookies(s,e||"%",o||"%"))}};async function W(r){if(!r.name||!r.domain)return[];let{name:e,domain:o}=r;if(typeof e!="string"||typeof o!="string")return[];let t=[new S,new v,new N];return(await Promise.allSettled(t.map(s=>s.queryCookies(e,o)))).filter(s=>s.status==="fulfilled").flatMap(s=>s.value)}async function w(r){try{return await W(r)}catch(e){return u.warn("Error querying cookies:",e instanceof Error?e.message:String(e)),[]}}async function Z(r){try{return await new S().queryCookies(r.name,r.domain)}catch(e){return u.warn("Error querying Chrome cookies:",e),[]}}async function J(r){try{return await new v().queryCookies(r.name,r.domain)}catch(e){return u.warn("Error querying Firefox cookies:",e instanceof Error?e.message:String(e)),[]}}var Te=require("lodash-es");function L(r,e={}){let{format:o="merged",showFilePaths:t=!0,separator:i="; "}=e;if(r.length===0)return o==="merged"?"":[];if(o==="merged")return r.map(n=>n.value).join(i);let s=(0,Te.groupBy)(r,n=>n.meta?.file??"unknown");return Object.entries(s).map(([n,c])=>{let f=c.map(m=>m.value).join(i);return t?`${n}: ${f}`:f})}async function K(r,e={}){try{let o=await w(r);if(!Array.isArray(o))return[];let t=o.filter(i=>{let s=F.safeParse(i);return s.success?!0:(u.warn("Invalid cookie format:",s.error.format()),!1)});return L(t,{...e,format:"grouped"})}catch(o){return u.warn("Error getting grouped rendered cookies:",o instanceof Error?o.message:String(o)),[]}}async function X(r,e){try{let o=await w(r);if(!Array.isArray(o))return"";let t=o.filter(s=>{let n=F.safeParse(s);return n.success?!0:(u.warn("Invalid cookie format:",n.error.format()),!1)}),i=L(t,{...e,format:"merged"});return typeof i=="string"?i:""}catch(o){return u.warn("Error getting merged rendered cookies:",o instanceof Error?o.message:String(o)),""}}0&&(module.exports={getChromeCookie,getCookie,getFirefoxCookie,getGroupedRenderedCookies,getMergedRenderedCookies});
|
|
4
2
|
//# sourceMappingURL=index.cjs.map
|