@mherod/get-cookie 4.0.4 → 4.2.0
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/dist/chunk-GVQTX3C5.js +2 -0
- package/dist/chunk-GVQTX3C5.js.map +1 -0
- package/dist/cli.cjs +1 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/getChromePassword-6XZINNNO.js +2 -0
- package/dist/{getChromePassword-GTIXL733.js.map → getChromePassword-6XZINNNO.js.map} +1 -1
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +228 -49
- package/dist/index.d.ts +228 -49
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/eslint.config.js +2 -17
- package/examples/README.md +37 -0
- package/examples/advanced-usage.ts +56 -0
- package/examples/basic-usage.ts +44 -0
- package/examples/cli-examples.sh +51 -0
- package/package.json +22 -26
- 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-56Z35D5R.js +0 -2
- package/dist/chunk-56Z35D5R.js.map +0 -1
- package/dist/chunk-5FUMK7M3.js +0 -4
- package/dist/chunk-5FUMK7M3.js.map +0 -1
- package/dist/chunk-A6MIB6FP.js +0 -2
- package/dist/chunk-A6MIB6FP.js.map +0 -1
- package/dist/chunk-CFMK2YSL.js +0 -2
- package/dist/chunk-CFMK2YSL.js.map +0 -1
- package/dist/chunk-IRERRCUF.js +0 -2
- package/dist/chunk-IRERRCUF.js.map +0 -1
- package/dist/chunk-UPNW543B.js +0 -2
- package/dist/chunk-UPNW543B.js.map +0 -1
- package/dist/chunk-VMBA4NVU.js +0 -2
- package/dist/chunk-VMBA4NVU.js.map +0 -1
- package/dist/getChromeCookie-CL3SRRWX.js +0 -2
- package/dist/getChromeCookie-CL3SRRWX.js.map +0 -1
- package/dist/getChromePassword-GTIXL733.js +0 -2
- package/dist/getCookie-WV5KDZN7.js +0 -2
- package/dist/getCookie-WV5KDZN7.js.map +0 -1
- package/dist/getFirefoxCookie-BXQ2GXAW.js +0 -2
- package/dist/getFirefoxCookie-BXQ2GXAW.js.map +0 -1
- package/dist/getGroupedRenderedCookies-FNJ6FQVQ.js +0 -2
- package/dist/getGroupedRenderedCookies-FNJ6FQVQ.js.map +0 -1
- package/dist/getMergedRenderedCookies-PNC2LHSD.js +0 -2
- package/dist/getMergedRenderedCookies-PNC2LHSD.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as i}from"./chunk-GVQTX3C5.js";import{memoize as l}from"lodash-es";import{exec as m}from"child_process";import{promisify as u}from"util";var f=u(m),o=class extends Error{constructor(n,e,s){super(n);this.command=e;this.originalError=s;this.name="CommandExecutionError"}};function d(t,r){if(t instanceof o)throw i("Command execution failed",t,{command:t.command,originalError:t.originalError}),t;if(t instanceof Error){let e=new o(t.message,r,t);throw i("Failed to execute command",t,{command:r,stack:t.stack}),e}let n=new o("Unknown error occurred during command execution",r);throw i("Failed to execute command",null,{error:t,command:r}),n}async function a(t,r={}){if(!t||typeof t!="string")throw new o("Command must be a non-empty string",t);let n={encoding:"utf8",maxBuffer:5*1024*1024,timeout:3e4};try{let{stdout:e,stderr:s}=await f(t,{...n,...r}),c=e.trim();if(!c)throw s?new o(`Command failed with stderr: ${s}`,t):new o("Command returned empty result",t);return c}catch(e){d(e,t)}}var g=async()=>a('security find-generic-password -w -s "Chrome Safe Storage"'),P=l(g);export{P as getChromePassword};
|
|
2
|
+
//# sourceMappingURL=getChromePassword-6XZINNNO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/browsers/chrome/macos/getChromePassword.ts","../src/utils/execSimple.ts"],"sourcesContent":["import { memoize } from \"lodash-es\";\n\nimport { execSimple } from \"@utils/execSimple\";\n\n/**\n * Retrieves the Chrome Safe Storage password from the macOS keychain\n * @returns A promise that resolves to the Chrome Safe Storage password\n * @throws {Error} If the password cannot be retrieved from the keychain\n */\nconst getChromeSafeStoragePassword = async (): Promise<string> => {\n const command = 'security find-generic-password -w -s \"Chrome Safe Storage\"';\n return execSimple(command);\n};\n\n/**\n * Memoized version of getChromeSafeStoragePassword that caches the result\n * to avoid repeated keychain queries\n * @returns A promise that resolves to the Chrome Safe Storage password\n * @throws {Error} If the password cannot be retrieved from the keychain\n * @example\n */\nexport const getChromePassword: () => Promise<string> = memoize(\n getChromeSafeStoragePassword,\n);\n","// External imports\nimport { exec, ExecOptions } from \"child_process\";\nimport { promisify } from \"util\";\n\n// Internal imports\nimport { logError } from \"@utils/logHelpers\";\n\nconst execPromise = promisify(exec);\n\n/**\n * Custom error class for command execution failures.\n * @property {string} command - The command that failed to execute\n * @property {Error} [originalError] - The underlying error that caused the failure\n * @throws CommandExecutionError Always throws with appropriate error context\n * @example\n * ```typescript\n * throw new CommandExecutionError(\n * 'Command timed out',\n * 'git status',\n * originalError\n * );\n * ```\n */\nclass CommandExecutionError extends Error {\n public constructor(\n message: string,\n public readonly command: string,\n public readonly originalError?: Error,\n ) {\n super(message);\n this.name = \"CommandExecutionError\";\n }\n}\n\n/**\n * Handles execution errors and throws appropriate CommandExecutionError.\n * @internal\n * @param error - The error that occurred during command execution\n * @param command - The command that was being executed when the error occurred\n * @throws CommandExecutionError Always throws with appropriate error context\n * @example\n * ```typescript\n * try {\n * await execPromise('invalid-command');\n * } catch (error) {\n * handleExecutionError(error, 'invalid-command');\n * }\n * ```\n */\nfunction handleExecutionError(error: unknown, command: string): never {\n if (error instanceof CommandExecutionError) {\n logError(\"Command execution failed\", error, {\n command: error.command,\n originalError: error.originalError,\n });\n throw error;\n }\n\n if (error instanceof Error) {\n const commandError = new CommandExecutionError(\n error.message,\n command,\n error,\n );\n logError(\"Failed to execute command\", error, {\n command,\n stack: error.stack,\n });\n throw commandError;\n }\n\n // Handle unknown error types\n const commandError = new CommandExecutionError(\n \"Unknown error occurred during command execution\",\n command,\n );\n logError(\"Failed to execute command\", null, {\n error,\n command,\n });\n throw commandError;\n}\n\n/**\n * Executes a shell command asynchronously and returns its output as a string.\n * @param command - The shell command to execute\n * @param options - Optional execution options that override the defaults\n * @returns A promise that resolves to the trimmed command output\n * @throws CommandExecutionError if the command returns an empty result, times out, or fails to execute\n * @example\n * ```typescript\n * // Basic usage\n * const gitStatus = await execSimple('git status');\n *\n * // With custom timeout\n * const output = await execSimple('long-running-command', { timeout: 60000 });\n *\n * // Error handling\n * try {\n * const result = await execSimple('git push');\n * } catch (error) {\n * if (error instanceof CommandExecutionError) {\n * console.error('Push failed:', error.message);\n * }\n * }\n * ```\n */\nexport async function execSimple(\n command: string,\n options: Partial<ExecOptions> = {},\n): Promise<string> {\n if (!command || typeof command !== \"string\") {\n throw new CommandExecutionError(\n \"Command must be a non-empty string\",\n command,\n );\n }\n\n const defaultOptions = {\n encoding: \"utf8\" as BufferEncoding,\n maxBuffer: 5 * 1024 * 1024, // 5MB buffer\n timeout: 30000, // 30 second timeout\n };\n\n try {\n const { stdout, stderr } = await execPromise(command, {\n ...defaultOptions,\n ...options,\n });\n const result = stdout.trim();\n\n if (!result) {\n if (stderr) {\n throw new CommandExecutionError(\n `Command failed with stderr: ${stderr}`,\n command,\n );\n }\n throw new CommandExecutionError(\"Command returned empty result\", command);\n }\n\n return result;\n } catch (error) {\n handleExecutionError(error, command);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/core/browsers/chrome/macos/getChromePassword.ts","../src/utils/execSimple.ts"],"sourcesContent":["import { memoize } from \"lodash-es\";\n\nimport { execSimple } from \"@utils/execSimple\";\n\n/**\n * Retrieves the Chrome Safe Storage password from the macOS keychain\n * @returns A promise that resolves to the Chrome Safe Storage password\n * @throws {Error} If the password cannot be retrieved from the keychain\n */\nconst getChromeSafeStoragePassword = async (): Promise<string> => {\n const command = 'security find-generic-password -w -s \"Chrome Safe Storage\"';\n return execSimple(command);\n};\n\n/**\n * Memoized version of getChromeSafeStoragePassword that caches the result\n * to avoid repeated keychain queries\n * @returns A promise that resolves to the Chrome Safe Storage password\n * @throws {Error} If the password cannot be retrieved from the keychain\n * @example\n */\nexport const getChromePassword: () => Promise<string> = memoize(\n getChromeSafeStoragePassword,\n);\n","// External imports\nimport { exec, ExecOptions } from \"child_process\";\nimport { promisify } from \"util\";\n\n// Internal imports\nimport { logError } from \"@utils/logHelpers\";\n\nconst execPromise = promisify(exec);\n\n/**\n * Custom error class for command execution failures.\n * @property {string} command - The command that failed to execute\n * @property {Error} [originalError] - The underlying error that caused the failure\n * @throws CommandExecutionError Always throws with appropriate error context\n * @example\n * ```typescript\n * throw new CommandExecutionError(\n * 'Command timed out',\n * 'git status',\n * originalError\n * );\n * ```\n */\nclass CommandExecutionError extends Error {\n public constructor(\n message: string,\n public readonly command: string,\n public readonly originalError?: Error,\n ) {\n super(message);\n this.name = \"CommandExecutionError\";\n }\n}\n\n/**\n * Handles execution errors and throws appropriate CommandExecutionError.\n * @internal\n * @param error - The error that occurred during command execution\n * @param command - The command that was being executed when the error occurred\n * @throws CommandExecutionError Always throws with appropriate error context\n * @example\n * ```typescript\n * try {\n * await execPromise('invalid-command');\n * } catch (error) {\n * handleExecutionError(error, 'invalid-command');\n * }\n * ```\n */\nfunction handleExecutionError(error: unknown, command: string): never {\n if (error instanceof CommandExecutionError) {\n logError(\"Command execution failed\", error, {\n command: error.command,\n originalError: error.originalError,\n });\n throw error;\n }\n\n if (error instanceof Error) {\n const commandError = new CommandExecutionError(\n error.message,\n command,\n error,\n );\n logError(\"Failed to execute command\", error, {\n command,\n stack: error.stack,\n });\n throw commandError;\n }\n\n // Handle unknown error types\n const commandError = new CommandExecutionError(\n \"Unknown error occurred during command execution\",\n command,\n );\n logError(\"Failed to execute command\", null, {\n error,\n command,\n });\n throw commandError;\n}\n\n/**\n * Executes a shell command asynchronously and returns its output as a string.\n * @param command - The shell command to execute\n * @param options - Optional execution options that override the defaults\n * @returns A promise that resolves to the trimmed command output\n * @throws CommandExecutionError if the command returns an empty result, times out, or fails to execute\n * @example\n * ```typescript\n * // Basic usage\n * const gitStatus = await execSimple('git status');\n *\n * // With custom timeout\n * const output = await execSimple('long-running-command', { timeout: 60000 });\n *\n * // Error handling\n * try {\n * const result = await execSimple('git push');\n * } catch (error) {\n * if (error instanceof CommandExecutionError) {\n * console.error('Push failed:', error.message);\n * }\n * }\n * ```\n */\nexport async function execSimple(\n command: string,\n options: Partial<ExecOptions> = {},\n): Promise<string> {\n if (!command || typeof command !== \"string\") {\n throw new CommandExecutionError(\n \"Command must be a non-empty string\",\n command,\n );\n }\n\n const defaultOptions = {\n encoding: \"utf8\" as BufferEncoding,\n maxBuffer: 5 * 1024 * 1024, // 5MB buffer\n timeout: 30000, // 30 second timeout\n };\n\n try {\n const { stdout, stderr } = await execPromise(command, {\n ...defaultOptions,\n ...options,\n });\n const result = stdout.trim();\n\n if (!result) {\n if (stderr) {\n throw new CommandExecutionError(\n `Command failed with stderr: ${stderr}`,\n command,\n );\n }\n throw new CommandExecutionError(\"Command returned empty result\", command);\n }\n\n return result;\n } catch (error) {\n handleExecutionError(error, command);\n }\n}\n"],"mappings":"wCAAA,OAAS,WAAAA,MAAe,YCCxB,OAAS,QAAAC,MAAyB,gBAClC,OAAS,aAAAC,MAAiB,OAK1B,IAAMC,EAAcC,EAAUC,CAAI,EAgB5BC,EAAN,cAAoC,KAAM,CACjC,YACLC,EACgBC,EACAC,EAChB,CACA,MAAMF,CAAO,EAHG,aAAAC,EACA,mBAAAC,EAGhB,KAAK,KAAO,uBACd,CACF,EAiBA,SAASC,EAAqBC,EAAgBH,EAAwB,CACpE,GAAIG,aAAiBL,EACnB,MAAAM,EAAS,2BAA4BD,EAAO,CAC1C,QAASA,EAAM,QACf,cAAeA,EAAM,aACvB,CAAC,EACKA,EAGR,GAAIA,aAAiB,MAAO,CAC1B,IAAME,EAAe,IAAIP,EACvBK,EAAM,QACNH,EACAG,CACF,EACA,MAAAC,EAAS,4BAA6BD,EAAO,CAC3C,QAAAH,EACA,MAAOG,EAAM,KACf,CAAC,EACKE,CACR,CAGA,IAAMA,EAAe,IAAIP,EACvB,kDACAE,CACF,EACA,MAAAI,EAAS,4BAA6B,KAAM,CAC1C,MAAAD,EACA,QAAAH,CACF,CAAC,EACKK,CACR,CA0BA,eAAsBC,EACpBN,EACAO,EAAgC,CAAC,EAChB,CACjB,GAAI,CAACP,GAAW,OAAOA,GAAY,SACjC,MAAM,IAAIF,EACR,qCACAE,CACF,EAGF,IAAMQ,EAAiB,CACrB,SAAU,OACV,UAAW,EAAI,KAAO,KACtB,QAAS,GACX,EAEA,GAAI,CACF,GAAM,CAAE,OAAAC,EAAQ,OAAAC,CAAO,EAAI,MAAMf,EAAYK,EAAS,CACpD,GAAGQ,EACH,GAAGD,CACL,CAAC,EACKI,EAASF,EAAO,KAAK,EAE3B,GAAI,CAACE,EACH,MAAID,EACI,IAAIZ,EACR,+BAA+BY,CAAM,GACrCV,CACF,EAEI,IAAIF,EAAsB,gCAAiCE,CAAO,EAG1E,OAAOW,CACT,OAASR,EAAO,CACdD,EAAqBC,EAAOH,CAAO,CACrC,CACF,CDxIA,IAAMY,EAA+B,SAE5BC,EADS,4DACS,EAUdC,EAA2CC,EACtDH,CACF","names":["memoize","exec","promisify","execPromise","promisify","exec","CommandExecutionError","message","command","originalError","handleExecutionError","error","logError","commandError","execSimple","options","defaultOptions","stdout","stderr","result","getChromeSafeStoragePassword","execSimple","getChromePassword","memoize"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
"use strict";var sn=Object.create;var ge=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var on=Object.getOwnPropertyNames;var nn=Object.getPrototypeOf,an=Object.prototype.hasOwnProperty;var Pi=r=>{throw TypeError(r)};var hn=(r,t,e)=>t in r?ge(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var E=(r,t)=>()=>(r&&(t=r(r=0)),t);var Di=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),_t=(r,t)=>{for(var e in t)ge(r,e,{get:t[e],enumerable:!0})},Mi=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of on(t))!an.call(r,i)&&i!==e&&ge(r,i,{get:()=>t[i],enumerable:!(s=rn(t,i))||s.enumerable});return r};var we=(r,t,e)=>(e=r!=null?sn(nn(r)):{},Mi(t||!r||!r.__esModule?ge(e,"default",{value:r,enumerable:!0}):e,r)),ln=r=>Mi(ge({},"__esModule",{value:!0}),r);var f=(r,t,e)=>hn(r,typeof t!="symbol"?t+"":t,e),Is=(r,t,e)=>t.has(r)||Pi("Cannot "+e);var a=(r,t,e)=>(Is(r,t,"read from private field"),e?e.call(r):t.get(r)),w=(r,t,e)=>t.has(r)?Pi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),p=(r,t,e,s)=>(Is(r,t,"write to private field"),s?s.call(r,e):t.set(r,e),e),b=(r,t,e)=>(Is(r,t,"access private method"),e);var Fi,cn,D,gt=E(()=>{"use strict";Fi=require("consola"),cn=(0,Fi.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}),D=cn});function Ni(r,t,e){let i=`${t?"\u2705":"\u274C"} ${r} ${t?"succeeded":"failed"}`;t?D.success(i,e):D.error(i,e)}function F(r,t,e){let s={...e!=null?e:{},error:t instanceof Error?{name:t.name,message:t.message,stack:t.stack}:t};D.error(r,s)}function lt(r,t,e){D.withTag(r).debug(t,e)}function Li(r){return D.withTag(r)}function os(r,t,e){D.withTag(r).warn(t,e)}var vt=E(()=>{"use strict";gt();gt()});var Ai,Bi,ns,Ii=E(()=>{"use strict";Ai=require("lodash-es"),Bi={};(0,Ai.merge)(Bi,process.env);ns=Bi.HOME;if(typeof ns!="string"||ns.length===0)throw new Error("HOME environment variable is not set or empty")});var _i,ji,Yt,js=E(()=>{"use strict";_i=require("path");Ii();Yt=(0,_i.join)((ji=ns)!=null?ji:"","Library","Application Support","Google","Chrome")});function un(r){try{return r.close(),Promise.resolve()}catch(t){return F("Database close failed",t),Promise.reject(t instanceof Error?t:new Error("Failed to close database: Unknown error"))}}async function as({file:r,sql:t,params:e,rowFilter:s,rowTransform:i}){let o;try{o=await fn(r);let h=o.prepare(t).all(e),l=s?h.filter(s):h;return i?l.map(i):l}catch(n){throw F("Database query failed",n,{file:r,sql:t}),n}finally{o&&await un(o)}}var $i,Wi,fn,_s=E(()=>{"use strict";$i=we(require("better-sqlite3"),1),Wi=require("lodash-es");vt();fn=(0,Wi.memoize)(r=>{try{return Promise.resolve(new $i.default(r,{readonly:!0}))}catch(t){throw F("Database open failed",t,{file:r}),t}})});function pn(r){if(typeof r!="string")return!1;let t=r.trim();return t.length===0?!1:(0,Ui.existsSync)(t)}async function dn(){let r=[(0,hs.join)(Yt,"Default/Cookies"),(0,hs.join)(Yt,"Profile */Cookies"),(0,hs.join)(Yt,"Profile Default/Cookies")],t=[];for(let e of r){let s=await(0,zi.default)(e);t.push(...s)}return lt("ChromeCookies","Found cookie files",{count:t.length,files:t}),t}function mn(r,t){let e=r==="%",s=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 ?",i=e?[`%${t}%`]:[r,`%${t}%`];return{sql:s,params:i}}async function gn(r,t,e){try{let{sql:s,params:i}=mn(t,e);lt("ChromeCookies","Executing query",{sql:s,params:i});let o=await as({file:r,sql:s,params:i,rowTransform:n=>({name:n.name,domain:n.host_key,value:n.encrypted_value,expiry:n.expires_utc})});return Ni("QueryCookies",!0,{file:r,count:o.length}),o}catch(s){return F("Failed to read cookie file",s,{file:r}),[]}}async function qi({name:r,domain:t,file:e}){let s=typeof e=="string"&&e.length>0?[e]:await dn();if(s.length===0)return lt("ChromeCookies","No cookie files found"),[];let i=[];for(let o of s){if(!pn(o)){lt("ChromeCookies","Cookie file missing or invalid",{file:o});continue}let n=await gn(o,r,t);i.push(...n)}return lt("ChromeCookies","Query complete",{totalCookies:i.length}),i}var Ui,hs,zi,Gi=E(()=>{"use strict";Ui=require("fs"),hs=require("path"),zi=we(require("fast-glob"),1);vt();js();_s()});var Ji=Di((kh,Vi)=>{"use strict";Vi.exports=Qi;function Qi(r,t,e){r instanceof RegExp&&(r=Hi(r,e)),t instanceof RegExp&&(t=Hi(t,e));var s=Ki(r,t,e);return s&&{start:s[0],end:s[1],pre:e.slice(0,s[0]),body:e.slice(s[0]+r.length,s[1]),post:e.slice(s[1]+t.length)}}function Hi(r,t){var e=t.match(r);return e?e[0]:null}Qi.range=Ki;function Ki(r,t,e){var s,i,o,n,h,l=e.indexOf(r),c=e.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(r===t)return[l,c];for(s=[],o=e.length;u>=0&&!h;)u==l?(s.push(u),l=e.indexOf(r,u+1)):s.length==1?h=[s.pop(),c]:(i=s.pop(),i<o&&(o=i,n=c),c=e.indexOf(t,u+1)),u=l<c&&l>=0?l:c;s.length&&(h=[o,n])}return h}});var rr=Di((Sh,ir)=>{"use strict";var Yi=Ji();ir.exports=bn;var Zi="\0SLASH"+Math.random()+"\0",Xi="\0OPEN"+Math.random()+"\0",Ws="\0CLOSE"+Math.random()+"\0",tr="\0COMMA"+Math.random()+"\0",er="\0PERIOD"+Math.random()+"\0";function $s(r){return parseInt(r,10)==r?parseInt(r,10):r.charCodeAt(0)}function wn(r){return r.split("\\\\").join(Zi).split("\\{").join(Xi).split("\\}").join(Ws).split("\\,").join(tr).split("\\.").join(er)}function yn(r){return r.split(Zi).join("\\").split(Xi).join("{").split(Ws).join("}").split(tr).join(",").split(er).join(".")}function sr(r){if(!r)return[""];var t=[],e=Yi("{","}",r);if(!e)return r.split(",");var s=e.pre,i=e.body,o=e.post,n=s.split(",");n[n.length-1]+="{"+i+"}";var h=sr(o);return o.length&&(n[n.length-1]+=h.shift(),n.push.apply(n,h)),t.push.apply(t,n),t}function bn(r){return r?(r.substr(0,2)==="{}"&&(r="\\{\\}"+r.substr(2)),ye(wn(r),!0).map(yn)):[]}function kn(r){return"{"+r+"}"}function Sn(r){return/^-?0\d/.test(r)}function Cn(r,t){return r<=t}function xn(r,t){return r>=t}function ye(r,t){var e=[],s=Yi("{","}",r);if(!s)return[r];var i=s.pre,o=s.post.length?ye(s.post,!1):[""];if(/\$$/.test(s.pre))for(var n=0;n<o.length;n++){var h=i+"{"+s.body+"}"+o[n];e.push(h)}else{var l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),u=l||c,m=s.body.indexOf(",")>=0;if(!u&&!m)return s.post.match(/,.*\}/)?(r=s.pre+"{"+s.body+Ws+s.post,ye(r)):[r];var d;if(u)d=s.body.split(/\.\./);else if(d=sr(s.body),d.length===1&&(d=ye(d[0],!1).map(kn),d.length===1))return o.map(function(en){return s.pre+d[0]+en});var y;if(u){var R=$s(d[0]),g=$s(d[1]),x=Math.max(d[0].length,d[1].length),C=d.length==3?Math.abs($s(d[2])):1,T=Cn,O=g<R;O&&(C*=-1,T=xn);var L=d.some(Sn);y=[];for(var V=R;T(V,g);V+=C){var X;if(c)X=String.fromCharCode(V),X==="\\"&&(X="");else if(X=String(V),L){var Ti=x-X.length;if(Ti>0){var Oi=new Array(Ti+1).join("0");V<0?X="-"+Oi+X.slice(1):X=Oi+X}}y.push(X)}}else{y=[];for(var jt=0;jt<d.length;jt++)y.push.apply(y,ye(d[jt],!1))}for(var jt=0;jt<y.length;jt++)for(var n=0;n<o.length;n++){var h=i+y[jt]+o[n];(!t||u||h)&&e.push(h)}}return e}});var be,or=E(()=>{"use strict";be=r=>{if(typeof r!="string")throw new TypeError("invalid pattern");if(r.length>65536)throw new TypeError("pattern is too long")}});var En,ke,vn,nr,ar,hr=E(()=>{"use strict";En={"[: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]},ke=r=>r.replace(/[[\]\\-]/g,"\\$&"),vn=r=>r.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),nr=r=>r.join(""),ar=(r,t)=>{let e=t;if(r.charAt(e)!=="[")throw new Error("not in a brace expression");let s=[],i=[],o=e+1,n=!1,h=!1,l=!1,c=!1,u=e,m="";t:for(;o<r.length;){let g=r.charAt(o);if((g==="!"||g==="^")&&o===e+1){c=!0,o++;continue}if(g==="]"&&n&&!l){u=o+1;break}if(n=!0,g==="\\"&&!l){l=!0,o++;continue}if(g==="["&&!l){for(let[x,[C,T,O]]of Object.entries(En))if(r.startsWith(x,o)){if(m)return["$.",!1,r.length-e,!0];o+=x.length,O?i.push(C):s.push(C),h=h||T;continue t}}if(l=!1,m){g>m?s.push(ke(m)+"-"+ke(g)):g===m&&s.push(ke(g)),m="",o++;continue}if(r.startsWith("-]",o+1)){s.push(ke(g+"-")),o+=2;continue}if(r.startsWith("-",o+1)){m=g,o+=2;continue}s.push(ke(g)),o++}if(u<o)return["",!1,0,!1];if(!s.length&&!i.length)return["$.",!1,r.length-e,!0];if(i.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!c){let g=s[0].length===2?s[0].slice(-1):s[0];return[vn(g),!1,u-e,!1]}let d="["+(c?"^":"")+nr(s)+"]",y="["+(c?"":"^")+nr(i)+"]";return[s.length&&i.length?"("+d+"|"+y+")":s.length?d:y,h,u-e,!0]}});var rt,ls=E(()=>{"use strict";rt=(r,{windowsPathsNoEscape:t=!1}={})=>t?r.replace(/\[([^\/\\])\]/g,"$1"):r.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")});var Rn,lr,Tn,cs,On,Pn,Dn,Mn,zs,cr,fr,A,I,wt,P,N,Rt,$t,Tt,ct,Wt,Se,Ut,ur,Ot,fs,Us,pr,G,Zt,qs=E(()=>{"use strict";hr();ls();Rn=new Set(["!","?","+","*","@"]),lr=r=>Rn.has(r),Tn="(?!(?:^|/)\\.\\.?(?:$|/))",cs="(?!\\.)",On=new Set(["[","."]),Pn=new Set(["..","."]),Dn=new Set("().*{}+?[]^$\\!"),Mn=r=>r.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),zs="[^/]",cr=zs+"*?",fr=zs+"+?",G=class G{constructor(t,e,s={}){w(this,Ut);f(this,"type");w(this,A);w(this,I);w(this,wt,!1);w(this,P,[]);w(this,N);w(this,Rt);w(this,$t);w(this,Tt,!1);w(this,ct);w(this,Wt);w(this,Se,!1);this.type=t,t&&p(this,I,!0),p(this,N,e),p(this,A,a(this,N)?a(a(this,N),A):this),p(this,ct,a(this,A)===this?s:a(a(this,A),ct)),p(this,$t,a(this,A)===this?[]:a(a(this,A),$t)),t==="!"&&!a(a(this,A),Tt)&&a(this,$t).push(this),p(this,Rt,a(this,N)?a(a(this,N),P).length:0)}get hasMagic(){if(a(this,I)!==void 0)return a(this,I);for(let t of a(this,P))if(typeof t!="string"&&(t.type||t.hasMagic))return p(this,I,!0);return a(this,I)}toString(){return a(this,Wt)!==void 0?a(this,Wt):this.type?p(this,Wt,this.type+"("+a(this,P).map(t=>String(t)).join("|")+")"):p(this,Wt,a(this,P).map(t=>String(t)).join(""))}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof G&&a(e,N)===this))throw new Error("invalid part: "+e);a(this,P).push(e)}}toJSON(){var e;let t=this.type===null?a(this,P).slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...a(this,P).map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===a(this,A)||a(a(this,A),Tt)&&((e=a(this,N))==null?void 0:e.type)==="!")&&t.push({}),t}isStart(){var e;if(a(this,A)===this)return!0;if(!((e=a(this,N))!=null&&e.isStart()))return!1;if(a(this,Rt)===0)return!0;let t=a(this,N);for(let s=0;s<a(this,Rt);s++){let i=a(t,P)[s];if(!(i instanceof G&&i.type==="!"))return!1}return!0}isEnd(){var e,s,i;if(a(this,A)===this||((e=a(this,N))==null?void 0:e.type)==="!")return!0;if(!((s=a(this,N))!=null&&s.isEnd()))return!1;if(!this.type)return(i=a(this,N))==null?void 0:i.isEnd();let t=a(this,N)?a(a(this,N),P).length:0;return a(this,Rt)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let e=new G(this.type,t);for(let s of a(this,P))e.copyIn(s);return e}static fromGlob(t,e={}){var i;let s=new G(null,void 0,e);return b(i=G,Ot,fs).call(i,t,s,0,e),s}toMMPattern(){if(this!==a(this,A))return a(this,A).toMMPattern();let t=this.toString(),[e,s,i,o]=this.toRegExpSource();if(!(i||a(this,I)||a(this,ct).nocase&&!a(this,ct).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;let h=(a(this,ct).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${e}$`,h),{_src:e,_glob:t})}get options(){return a(this,ct)}toRegExpSource(t){var l;let e=t!=null?t:!!a(this,ct).dot;if(a(this,A)===this&&b(this,Ut,ur).call(this),!this.type){let c=this.isStart()&&this.isEnd(),u=a(this,P).map(R=>{var O;let[g,x,C,T]=typeof R=="string"?b(O=G,Ot,pr).call(O,R,a(this,I),c):R.toRegExpSource(t);return p(this,I,a(this,I)||C),p(this,wt,a(this,wt)||T),g}).join(""),m="";if(this.isStart()&&typeof a(this,P)[0]=="string"&&!(a(this,P).length===1&&Pn.has(a(this,P)[0]))){let g=On,x=e&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),C=!e&&!t&&g.has(u.charAt(0));m=x?Tn:C?cs:""}let d="";return this.isEnd()&&a(a(this,A),Tt)&&((l=a(this,N))==null?void 0:l.type)==="!"&&(d="(?:$|\\/)"),[m+u+d,rt(u),p(this,I,!!a(this,I)),a(this,wt)]}let s=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=b(this,Ut,Us).call(this,e);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let c=this.toString();return p(this,P,[c]),this.type=null,p(this,I,void 0),[c,rt(this.toString()),!1,!1]}let n=!s||t||e||!cs?"":b(this,Ut,Us).call(this,!0);n===o&&(n=""),n&&(o=`(?:${o})(?:${n})*?`);let h="";if(this.type==="!"&&a(this,Se))h=(this.isStart()&&!e?cs:"")+fr;else{let c=this.type==="!"?"))"+(this.isStart()&&!e&&!t?cs:"")+cr+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&n?")":this.type==="*"&&n?")?":`)${this.type}`;h=i+o+c}return[h,rt(o),p(this,I,!!a(this,I)),a(this,wt)]}};A=new WeakMap,I=new WeakMap,wt=new WeakMap,P=new WeakMap,N=new WeakMap,Rt=new WeakMap,$t=new WeakMap,Tt=new WeakMap,ct=new WeakMap,Wt=new WeakMap,Se=new WeakMap,Ut=new WeakSet,ur=function(){if(this!==a(this,A))throw new Error("should only call on root");if(a(this,Tt))return this;this.toString(),p(this,Tt,!0);let t;for(;t=a(this,$t).pop();){if(t.type!=="!")continue;let e=t,s=a(e,N);for(;s;){for(let i=a(e,Rt)+1;!s.type&&i<a(s,P).length;i++)for(let o of a(t,P)){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(a(s,P)[i])}e=s,s=a(e,N)}}return this},Ot=new WeakSet,fs=function(t,e,s,i){var y,R;let o=!1,n=!1,h=-1,l=!1;if(e.type===null){let g=s,x="";for(;g<t.length;){let C=t.charAt(g++);if(o||C==="\\"){o=!o,x+=C;continue}if(n){g===h+1?(C==="^"||C==="!")&&(l=!0):C==="]"&&!(g===h+2&&l)&&(n=!1),x+=C;continue}else if(C==="["){n=!0,h=g,l=!1,x+=C;continue}if(!i.noext&&lr(C)&&t.charAt(g)==="("){e.push(x),x="";let T=new G(C,e);g=b(y=G,Ot,fs).call(y,t,T,g,i),e.push(T);continue}x+=C}return e.push(x),g}let c=s+1,u=new G(null,e),m=[],d="";for(;c<t.length;){let g=t.charAt(c++);if(o||g==="\\"){o=!o,d+=g;continue}if(n){c===h+1?(g==="^"||g==="!")&&(l=!0):g==="]"&&!(c===h+2&&l)&&(n=!1),d+=g;continue}else if(g==="["){n=!0,h=c,l=!1,d+=g;continue}if(lr(g)&&t.charAt(c)==="("){u.push(d),d="";let x=new G(g,u);u.push(x),c=b(R=G,Ot,fs).call(R,t,x,c,i);continue}if(g==="|"){u.push(d),d="",m.push(u),u=new G(null,e);continue}if(g===")")return d===""&&a(e,P).length===0&&p(e,Se,!0),u.push(d),d="",e.push(...m,u),c;d+=g}return e.type=null,p(e,I,void 0),p(e,P,[t.substring(s-1)]),c},Us=function(t){return a(this,P).map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[s,i,o,n]=e.toRegExpSource(t);return p(this,wt,a(this,wt)||n),s}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")},pr=function(t,e,s=!1){let i=!1,o="",n=!1;for(let h=0;h<t.length;h++){let l=t.charAt(h);if(i){i=!1,o+=(Dn.has(l)?"\\":"")+l;continue}if(l==="\\"){h===t.length-1?o+="\\\\":i=!0;continue}if(l==="["){let[c,u,m,d]=ar(t,h);if(m){o+=c,n=n||u,h+=m-1,e=e||d;continue}}if(l==="*"){s&&t==="*"?o+=fr:o+=cr,e=!0;continue}if(l==="?"){o+=zs,e=!0;continue}o+=Mn(l)}return[o,rt(t),!!e,n]},w(G,Ot);Zt=G});var Xt,Gs=E(()=>{"use strict";Xt=(r,{windowsPathsNoEscape:t=!1}={})=>t?r.replace(/[?*()[\]]/g,"[$&]"):r.replace(/[?*()[\]\\]/g,"\\$&")});var gr,H,Fn,Nn,Ln,An,Bn,In,jn,_n,$n,Wn,Un,zn,qn,Gn,Hn,Qn,Kn,Vn,wr,yr,br,dr,Jn,U,Yn,Zn,Xn,ta,ea,tt,sa,kr,ia,ra,mr,oa,J,Pt=E(()=>{"use strict";gr=we(rr(),1);or();qs();Gs();ls();qs();Gs();ls();H=(r,t,e={})=>(be(t),!e.nocomment&&t.charAt(0)==="#"?!1:new J(t,e).match(r)),Fn=/^\*+([^+@!?\*\[\(]*)$/,Nn=r=>t=>!t.startsWith(".")&&t.endsWith(r),Ln=r=>t=>t.endsWith(r),An=r=>(r=r.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(r)),Bn=r=>(r=r.toLowerCase(),t=>t.toLowerCase().endsWith(r)),In=/^\*+\.\*+$/,jn=r=>!r.startsWith(".")&&r.includes("."),_n=r=>r!=="."&&r!==".."&&r.includes("."),$n=/^\.\*+$/,Wn=r=>r!=="."&&r!==".."&&r.startsWith("."),Un=/^\*+$/,zn=r=>r.length!==0&&!r.startsWith("."),qn=r=>r.length!==0&&r!=="."&&r!=="..",Gn=/^\?+([^+@!?\*\[\(]*)?$/,Hn=([r,t=""])=>{let e=wr([r]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},Qn=([r,t=""])=>{let e=yr([r]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},Kn=([r,t=""])=>{let e=yr([r]);return t?s=>e(s)&&s.endsWith(t):e},Vn=([r,t=""])=>{let e=wr([r]);return t?s=>e(s)&&s.endsWith(t):e},wr=([r])=>{let t=r.length;return e=>e.length===t&&!e.startsWith(".")},yr=([r])=>{let t=r.length;return e=>e.length===t&&e!=="."&&e!==".."},br=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",dr={win32:{sep:"\\"},posix:{sep:"/"}},Jn=br==="win32"?dr.win32.sep:dr.posix.sep;H.sep=Jn;U=Symbol("globstar **");H.GLOBSTAR=U;Yn="[^/]",Zn=Yn+"*?",Xn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ta="(?:(?!(?:\\/|^)\\.).)*?",ea=(r,t={})=>e=>H(e,r,t);H.filter=ea;tt=(r,t={})=>Object.assign({},r,t),sa=r=>{if(!r||typeof r!="object"||!Object.keys(r).length)return H;let t=H;return Object.assign((s,i,o={})=>t(s,i,tt(r,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,tt(r,o))}static defaults(i){return t.defaults(tt(r,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,n={}){super(i,o,tt(r,n))}static fromGlob(i,o={}){return t.AST.fromGlob(i,tt(r,o))}},unescape:(s,i={})=>t.unescape(s,tt(r,i)),escape:(s,i={})=>t.escape(s,tt(r,i)),filter:(s,i={})=>t.filter(s,tt(r,i)),defaults:s=>t.defaults(tt(r,s)),makeRe:(s,i={})=>t.makeRe(s,tt(r,i)),braceExpand:(s,i={})=>t.braceExpand(s,tt(r,i)),match:(s,i,o={})=>t.match(s,i,tt(r,o)),sep:t.sep,GLOBSTAR:U})};H.defaults=sa;kr=(r,t={})=>(be(r),t.nobrace||!/\{(?:(?!\{).)*\}/.test(r)?[r]:(0,gr.default)(r));H.braceExpand=kr;ia=(r,t={})=>new J(r,t).makeRe();H.makeRe=ia;ra=(r,t,e={})=>{let s=new J(t,e);return r=r.filter(i=>s.match(i)),s.options.nonull&&!r.length&&r.push(t),r};H.match=ra;mr=/[?*]|[+@!]\(.*?\)|\[|\]/,oa=r=>r.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),J=class{constructor(t,e={}){f(this,"options");f(this,"set");f(this,"pattern");f(this,"windowsPathsNoEscape");f(this,"nonegate");f(this,"negate");f(this,"comment");f(this,"empty");f(this,"preserveMultipleSlashes");f(this,"partial");f(this,"globSet");f(this,"globParts");f(this,"nocase");f(this,"isWindows");f(this,"platform");f(this,"windowsNoMagicRoot");f(this,"regexp");be(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||br,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=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,n,h)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!mr.test(o[2]))&&!mr.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let n=this.set[o];n[0]===""&&n[1]===""&&this.globParts[o][2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3])&&(n[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let s=0;s<t.length;s++)for(let i=0;i<t[s].length;i++)t[s][i]==="**"&&(t[s][i]="*");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 s=-1;for(;(s=e.indexOf("**",s+1))!==-1;){let i=s;for(;e[i+1]==="**";)i++;i!==s&&e.splice(s,i-s)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((s,i)=>{let o=s[s.length-1];return i==="**"&&o==="**"?s:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(s.pop(),s):(s.push(i),s)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(e=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let s=0;for(;(s=t.indexOf("..",s+1))!==-1;){let i=t[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&(e=!0,t.splice(s-1,2),s-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let s of t){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let n=i;for(;s[n+1]==="**";)n++;n>i&&s.splice(i+1,n-i);let h=s[i+1],l=s[i+2],c=s[i+3];if(h!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;e=!0,s.splice(i,1);let u=s.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let n=1;n<s.length-1;n++){let h=s[n];n===1&&h===""&&s[0]===""||(h==="."||h==="")&&(e=!0,s.splice(n,1),n--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(e=!0,s.pop())}let o=0;for(;(o=s.indexOf("..",o+1))!==-1;){let n=s[o-1];if(n&&n!=="."&&n!==".."&&n!=="**"){e=!0;let l=o===1&&s[o+1]==="**"?["."]:[];s.splice(o-1,2,...l),s.length===0&&s.push(""),o-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let s=e+1;s<t.length;s++){let i=this.partsMatch(t[e],t[s],!this.preserveMultipleSlashes);if(i){t[e]=[],t[s]=i;break}}return t.filter(e=>e.length)}partsMatch(t,e,s=!1){let i=0,o=0,n=[],h="";for(;i<t.length&&o<e.length;)if(t[i]===e[o])n.push(h==="b"?e[o]:t[i]),i++,o++;else if(s&&t[i]==="**"&&e[o]===t[i+1])n.push(t[i]),i++;else if(s&&e[o]==="**"&&t[i]===e[o+1])n.push(e[o]),o++;else if(t[i]==="*"&&e[o]&&(this.options.dot||!e[o].startsWith("."))&&e[o]!=="**"){if(h==="b")return!1;h="a",n.push(t[i]),i++,o++}else if(e[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(h==="a")return!1;h="b",n.push(e[o]),i++,o++}else return!1;return t.length===e.length&&n}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,s=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)e=!e,s++;s&&(this.pattern=t.slice(s)),this.negate=e}matchOne(t,e,s=!1){let i=this.options;if(this.isWindows){let g=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),x=!g&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),C=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),T=!C&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),O=x?3:g?0:void 0,L=T?3:C?0:void 0;if(typeof O=="number"&&typeof L=="number"){let[V,X]=[t[O],e[L]];V.toLowerCase()===X.toLowerCase()&&(e[L]=V,L>O?e=e.slice(L):O>L&&(t=t.slice(O)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var n=0,h=0,l=t.length,c=e.length;n<l&&h<c;n++,h++){this.debug("matchOne loop");var u=e[h],m=t[n];if(this.debug(e,u,m),u===!1)return!1;if(u===U){this.debug("GLOBSTAR",[e,u,m]);var d=n,y=h+1;if(y===c){for(this.debug("** at the end");n<l;n++)if(t[n]==="."||t[n]===".."||!i.dot&&t[n].charAt(0)===".")return!1;return!0}for(;d<l;){var R=t[d];if(this.debug(`
|
|
2
|
-
globstar while`,t,d,e,y,R),this.matchOne(t.slice(d),e.slice(y),s))return this.debug("globstar found match!",d,l,R),!0;if(R==="."||R===".."||!i.dot&&R.charAt(0)==="."){this.debug("dot detected!",t,d,e,y);break}this.debug("globstar swallow a segment, and continue"),d++}return!!(s&&(this.debug(`
|
|
3
|
-
>>> no match, partial?`,t,d,e,y),d===l))}let g;if(typeof u=="string"?(g=m===u,this.debug("string match",u,m,g)):(g=u.test(m),this.debug("pattern match",u,m,g)),!g)return!1}if(n===l&&h===c)return!0;if(n===l)return s;if(h===c)return n===l-1&&t[n]==="";throw new Error("wtf?")}braceExpand(){return kr(this.pattern,this.options)}parse(t){be(t);let e=this.options;if(t==="**")return U;if(t==="")return"";let s,i=null;(s=t.match(Un))?i=e.dot?qn:zn:(s=t.match(Fn))?i=(e.nocase?e.dot?Bn:An:e.dot?Ln:Nn)(s[1]):(s=t.match(Gn))?i=(e.nocase?e.dot?Qn:Hn:e.dot?Kn:Vn)(s):(s=t.match(In))?i=e.dot?_n:jn:(s=t.match($n))&&(i=Wn);let o=Zt.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}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,s=e.noglobstar?Zn:e.dot?Xn:ta,i=new Set(e.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(u=>{if(u instanceof RegExp)for(let m of u.flags.split(""))i.add(m);return typeof u=="string"?oa(u):u===U?U:u._src});return c.forEach((u,m)=>{let d=c[m+1],y=c[m-1];u!==U||y===U||(y===void 0?d!==void 0&&d!==U?c[m+1]="(?:\\/|"+s+"\\/)?"+d:c[m]=s:d===void 0?c[m-1]=y+"(?:\\/|"+s+")?":d!==U&&(c[m-1]=y+"(?:\\/|\\/"+s+"\\/)"+d,c[m+1]=U))}),c.filter(u=>u!==U).join("/")}).join("|"),[n,h]=t.length>1?["(?:",")"]:["",""];o="^"+n+o+h+"$",this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch(l){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 s=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let n=i[i.length-1];if(!n)for(let h=i.length-2;!n&&h>=0;h--)n=i[h];for(let h=0;h<o.length;h++){let l=o[h],c=i;if(s.matchBase&&l.length===1&&(c=[n]),this.matchOne(c,l,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(t){return H.defaults(t).Minimatch}};H.AST=Zt;H.Minimatch=J;H.escape=Xt;H.unescape=rt});var ys,Zs,qr,Sr,na,aa,ha,yt,bt,Dt,us,Ce,ps,Cr,ds,xr,ot,te,j,xe,ee,_,Q,$,Hs,ms,z,M,Qs,Ks,Er,Vs,ft,Js,gs,Ee,zt,Y,ve,la,ca,fa,ua,ws,Ys,pa,da,vr,Rr,Tr,Or,Pr,Dr,Mr,Fr,Nr,Lr,Ar,Br,Ir,jr,_r,$r,Wr,Ur,zr,Mt,Xs=E(()=>{"use strict";ys=require("events"),Zs=we(require("stream"),1),qr=require("string_decoder"),Sr=typeof process=="object"&&process?process:{stdout:null,stderr:null},na=r=>!!r&&typeof r=="object"&&(r instanceof Mt||r instanceof Zs.default||aa(r)||ha(r)),aa=r=>!!r&&typeof r=="object"&&r instanceof ys.EventEmitter&&typeof r.pipe=="function"&&r.pipe!==Zs.default.Writable.prototype.pipe,ha=r=>!!r&&typeof r=="object"&&r instanceof ys.EventEmitter&&typeof r.write=="function"&&typeof r.end=="function",yt=Symbol("EOF"),bt=Symbol("maybeEmitEnd"),Dt=Symbol("emittedEnd"),us=Symbol("emittingEnd"),Ce=Symbol("emittedError"),ps=Symbol("closed"),Cr=Symbol("read"),ds=Symbol("flush"),xr=Symbol("flushChunk"),ot=Symbol("encoding"),te=Symbol("decoder"),j=Symbol("flowing"),xe=Symbol("paused"),ee=Symbol("resume"),_=Symbol("buffer"),Q=Symbol("pipes"),$=Symbol("bufferLength"),Hs=Symbol("bufferPush"),ms=Symbol("bufferShift"),z=Symbol("objectMode"),M=Symbol("destroyed"),Qs=Symbol("error"),Ks=Symbol("emitData"),Er=Symbol("emitEnd"),Vs=Symbol("emitEnd2"),ft=Symbol("async"),Js=Symbol("abort"),gs=Symbol("aborted"),Ee=Symbol("signal"),zt=Symbol("dataListeners"),Y=Symbol("discarded"),ve=r=>Promise.resolve().then(r),la=r=>r(),ca=r=>r==="end"||r==="finish"||r==="prefinish",fa=r=>r instanceof ArrayBuffer||!!r&&typeof r=="object"&&r.constructor&&r.constructor.name==="ArrayBuffer"&&r.byteLength>=0,ua=r=>!Buffer.isBuffer(r)&&ArrayBuffer.isView(r),ws=class{constructor(t,e,s){f(this,"src");f(this,"dest");f(this,"opts");f(this,"ondrain");this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[ee](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Ys=class extends ws{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,s){super(t,e,s),this.proxyErrors=i=>e.emit("error",i),t.on("error",this.proxyErrors)}},pa=r=>!!r.objectMode,da=r=>!r.objectMode&&!!r.encoding&&r.encoding!=="buffer",Mt=class extends ys.EventEmitter{constructor(...e){let s=e[0]||{};super();f(this,zr,!1);f(this,Ur,!1);f(this,Wr,[]);f(this,$r,[]);f(this,_r);f(this,jr);f(this,Ir);f(this,Br);f(this,Ar,!1);f(this,Lr,!1);f(this,Nr,!1);f(this,Fr,!1);f(this,Mr,null);f(this,Dr,0);f(this,Pr,!1);f(this,Or);f(this,Tr,!1);f(this,Rr,0);f(this,vr,!1);f(this,"writable",!0);f(this,"readable",!0);if(s.objectMode&&typeof s.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");pa(s)?(this[z]=!0,this[ot]=null):da(s)?(this[ot]=s.encoding,this[z]=!1):(this[z]=!1,this[ot]=null),this[ft]=!!s.async,this[te]=this[ot]?new qr.StringDecoder(this[ot]):null,s&&s.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[_]}),s&&s.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Q]});let{signal:i}=s;i&&(this[Ee]=i,i.aborted?this[Js]():i.addEventListener("abort",()=>this[Js]()))}get bufferLength(){return this[$]}get encoding(){return this[ot]}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[z]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[ft]}set async(e){this[ft]=this[ft]||!!e}[(zr=j,Ur=xe,Wr=Q,$r=_,_r=z,jr=ot,Ir=ft,Br=te,Ar=yt,Lr=Dt,Nr=us,Fr=ps,Mr=Ce,Dr=$,Pr=M,Or=Ee,Tr=gs,Rr=zt,vr=Y,Js)](){var e,s;this[gs]=!0,this.emit("abort",(e=this[Ee])==null?void 0:e.reason),this.destroy((s=this[Ee])==null?void 0:s.reason)}get aborted(){return this[gs]}set aborted(e){}write(e,s,i){var n;if(this[gs])return!1;if(this[yt])throw new Error("write after end");if(this[M])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof s=="function"&&(i=s,s="utf8"),s||(s="utf8");let o=this[ft]?ve:la;if(!this[z]&&!Buffer.isBuffer(e)){if(ua(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(fa(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[z]?(this[j]&&this[$]!==0&&this[ds](!0),this[j]?this.emit("data",e):this[Hs](e),this[$]!==0&&this.emit("readable"),i&&o(i),this[j]):e.length?(typeof e=="string"&&!(s===this[ot]&&!((n=this[te])!=null&&n.lastNeed))&&(e=Buffer.from(e,s)),Buffer.isBuffer(e)&&this[ot]&&(e=this[te].write(e)),this[j]&&this[$]!==0&&this[ds](!0),this[j]?this.emit("data",e):this[Hs](e),this[$]!==0&&this.emit("readable"),i&&o(i),this[j]):(this[$]!==0&&this.emit("readable"),i&&o(i),this[j])}read(e){if(this[M])return null;if(this[Y]=!1,this[$]===0||e===0||e&&e>this[$])return this[bt](),null;this[z]&&(e=null),this[_].length>1&&!this[z]&&(this[_]=[this[ot]?this[_].join(""):Buffer.concat(this[_],this[$])]);let s=this[Cr](e||null,this[_][0]);return this[bt](),s}[Cr](e,s){if(this[z])this[ms]();else{let i=s;e===i.length||e===null?this[ms]():typeof i=="string"?(this[_][0]=i.slice(e),s=i.slice(0,e),this[$]-=e):(this[_][0]=i.subarray(e),s=i.subarray(0,e),this[$]-=e)}return this.emit("data",s),!this[_].length&&!this[yt]&&this.emit("drain"),s}end(e,s,i){return typeof e=="function"&&(i=e,e=void 0),typeof s=="function"&&(i=s,s="utf8"),e!==void 0&&this.write(e,s),i&&this.once("end",i),this[yt]=!0,this.writable=!1,(this[j]||!this[xe])&&this[bt](),this}[ee](){this[M]||(!this[zt]&&!this[Q].length&&(this[Y]=!0),this[xe]=!1,this[j]=!0,this.emit("resume"),this[_].length?this[ds]():this[yt]?this[bt]():this.emit("drain"))}resume(){return this[ee]()}pause(){this[j]=!1,this[xe]=!0,this[Y]=!1}get destroyed(){return this[M]}get flowing(){return this[j]}get paused(){return this[xe]}[Hs](e){this[z]?this[$]+=1:this[$]+=e.length,this[_].push(e)}[ms](){return this[z]?this[$]-=1:this[$]-=this[_][0].length,this[_].shift()}[ds](e=!1){do;while(this[xr](this[ms]())&&this[_].length);!e&&!this[_].length&&!this[yt]&&this.emit("drain")}[xr](e){return this.emit("data",e),this[j]}pipe(e,s){if(this[M])return e;this[Y]=!1;let i=this[Dt];return s=s||{},e===Sr.stdout||e===Sr.stderr?s.end=!1:s.end=s.end!==!1,s.proxyErrors=!!s.proxyErrors,i?s.end&&e.end():(this[Q].push(s.proxyErrors?new Ys(this,e,s):new ws(this,e,s)),this[ft]?ve(()=>this[ee]()):this[ee]()),e}unpipe(e){let s=this[Q].find(i=>i.dest===e);s&&(this[Q].length===1?(this[j]&&this[zt]===0&&(this[j]=!1),this[Q]=[]):this[Q].splice(this[Q].indexOf(s),1),s.unpipe())}addListener(e,s){return this.on(e,s)}on(e,s){let i=super.on(e,s);if(e==="data")this[Y]=!1,this[zt]++,!this[Q].length&&!this[j]&&this[ee]();else if(e==="readable"&&this[$]!==0)super.emit("readable");else if(ca(e)&&this[Dt])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[Ce]){let o=s;this[ft]?ve(()=>o.call(this,this[Ce])):o.call(this,this[Ce])}return i}removeListener(e,s){return this.off(e,s)}off(e,s){let i=super.off(e,s);return e==="data"&&(this[zt]=this.listeners("data").length,this[zt]===0&&!this[Y]&&!this[Q].length&&(this[j]=!1)),i}removeAllListeners(e){let s=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[zt]=0,!this[Y]&&!this[Q].length&&(this[j]=!1)),s}get emittedEnd(){return this[Dt]}[bt](){!this[us]&&!this[Dt]&&!this[M]&&this[_].length===0&&this[yt]&&(this[us]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ps]&&this.emit("close"),this[us]=!1)}emit(e,...s){let i=s[0];if(e!=="error"&&e!=="close"&&e!==M&&this[M])return!1;if(e==="data")return!this[z]&&!i?!1:this[ft]?(ve(()=>this[Ks](i)),!0):this[Ks](i);if(e==="end")return this[Er]();if(e==="close"){if(this[ps]=!0,!this[Dt]&&!this[M])return!1;let n=super.emit("close");return this.removeAllListeners("close"),n}else if(e==="error"){this[Ce]=i,super.emit(Qs,i);let n=!this[Ee]||this.listeners("error").length?super.emit("error",i):!1;return this[bt](),n}else if(e==="resume"){let n=super.emit("resume");return this[bt](),n}else if(e==="finish"||e==="prefinish"){let n=super.emit(e);return this.removeAllListeners(e),n}let o=super.emit(e,...s);return this[bt](),o}[Ks](e){for(let i of this[Q])i.dest.write(e)===!1&&this.pause();let s=this[Y]?!1:super.emit("data",e);return this[bt](),s}[Er](){return this[Dt]?!1:(this[Dt]=!0,this.readable=!1,this[ft]?(ve(()=>this[Vs]()),!0):this[Vs]())}[Vs](){if(this[te]){let s=this[te].end();if(s){for(let i of this[Q])i.dest.write(s);this[Y]||super.emit("data",s)}}for(let s of this[Q])s.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[z]||(e.dataLength=0);let s=this.promise();return this.on("data",i=>{e.push(i),this[z]||(e.dataLength+=i.length)}),await s,e}async concat(){if(this[z])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[ot]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,s)=>{this.on(M,()=>s(new Error("stream destroyed"))),this.on("error",i=>s(i)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Y]=!1;let e=!1,s=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return s();let o=this.read();if(o!==null)return Promise.resolve({done:!1,value:o});if(this[yt])return s();let n,h,l=d=>{this.off("data",c),this.off("end",u),this.off(M,m),s(),h(d)},c=d=>{this.off("error",l),this.off("end",u),this.off(M,m),this.pause(),n({value:d,done:!!this[yt]})},u=()=>{this.off("error",l),this.off("data",c),this.off(M,m),s(),n({done:!0,value:void 0})},m=()=>l(new Error("stream destroyed"));return new Promise((d,y)=>{h=y,n=d,this.once(M,m),this.once("error",l),this.once("end",u),this.once("data",c)})},throw:s,return:s,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Y]=!1;let e=!1,s=()=>(this.pause(),this.off(Qs,s),this.off(M,s),this.off("end",s),e=!0,{done:!0,value:void 0}),i=()=>{if(e)return s();let o=this.read();return o===null?s():{done:!1,value:o}};return this.once("end",s),this.once(Qs,s),this.once(M,s),{next:i,throw:s,return:s,[Symbol.iterator](){return this}}}destroy(e){if(this[M])return e?this.emit("error",e):this.emit(M),this;this[M]=!0,this[Y]=!0,this[_].length=0,this[$]=0;let s=this;return typeof s.close=="function"&&!this[ps]&&s.close(),e?this.emit("error",e):this.emit(M),this}static get isStream(){return na}}});var li,ne,Vr,mt,ma,Nt,ga,Te,Jr,Yr,wa,ya,st,Zr,Xr,ut,to,eo,qt,so,et,Re,ti,Gr,Oe,nt,bs,Ss,Hr,ba,ei,Qr,Pe,Kr,ks,vs,si,io,K,Ne,Le,Ae,Be,Ie,je,_e,$e,We,Ue,ze,qe,Ge,He,Qe,Ke,Ve,Je,Ft,Gt,pt,kt,St,Ct,S,Ht,xt,dt,k,ii,Cs,De,ri,oi,Me,xs,ni,ai,Es,ro,oo,no,hi,se,ie,ao,Qt,q,Rs,Ts,re,oe,Ye,Ze,Os,ae,he,Fe,qh,ho,lo=E(()=>{"use strict";li=require("lru-cache"),ne=require("path"),Vr=require("url"),mt=require("fs"),ma=we(require("fs"),1),Nt=require("fs/promises");Xs();ga=mt.realpathSync.native,Te={lstatSync:mt.lstatSync,readdir:mt.readdir,readdirSync:mt.readdirSync,readlinkSync:mt.readlinkSync,realpathSync:ga,promises:{lstat:Nt.lstat,readdir:Nt.readdir,readlink:Nt.readlink,realpath:Nt.realpath}},Jr=r=>!r||r===Te||r===ma?Te:{...Te,...r,promises:{...Te.promises,...r.promises||{}}},Yr=/^\\\\\?\\([a-z]:)\\?$/i,wa=r=>r.replace(/\//g,"\\").replace(Yr,"$1\\"),ya=/[\\\/]/,st=0,Zr=1,Xr=2,ut=4,to=6,eo=8,qt=10,so=12,et=15,Re=~et,ti=16,Gr=32,Oe=64,nt=128,bs=256,Ss=512,Hr=Oe|nt|Ss,ba=1023,ei=r=>r.isFile()?eo:r.isDirectory()?ut:r.isSymbolicLink()?qt:r.isCharacterDevice()?Xr:r.isBlockDevice()?to:r.isSocket()?so:r.isFIFO()?Zr:st,Qr=new Map,Pe=r=>{let t=Qr.get(r);if(t)return t;let e=r.normalize("NFKD");return Qr.set(r,e),e},Kr=new Map,ks=r=>{let t=Kr.get(r);if(t)return t;let e=Pe(r.toLowerCase());return Kr.set(r,e),e},vs=class extends li.LRUCache{constructor(){super({max:256})}},si=class extends li.LRUCache{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},io=Symbol("PathScurry setAsCwd"),q=class{constructor(t,e=st,s,i,o,n,h){w(this,k);f(this,"name");f(this,"root");f(this,"roots");f(this,"parent");f(this,"nocase");f(this,"isCWD",!1);w(this,K);w(this,Ne);w(this,Le);w(this,Ae);w(this,Be);w(this,Ie);w(this,je);w(this,_e);w(this,$e);w(this,We);w(this,Ue);w(this,ze);w(this,qe);w(this,Ge);w(this,He);w(this,Qe);w(this,Ke);w(this,Ve);w(this,Je);w(this,Ft);w(this,Gt);w(this,pt);w(this,kt);w(this,St);w(this,Ct);w(this,S);w(this,Ht);w(this,xt);w(this,dt);w(this,se,[]);w(this,ie,!1);w(this,Qt);this.name=t,p(this,Ft,o?ks(t):Pe(t)),p(this,S,e&ba),this.nocase=o,this.roots=i,this.root=s||this,p(this,Ht,n),p(this,pt,h.fullpath),p(this,St,h.relative),p(this,Ct,h.relativePosix),this.parent=h.parent,this.parent?p(this,K,a(this.parent,K)):p(this,K,Jr(h.fs))}get dev(){return a(this,Ne)}get mode(){return a(this,Le)}get nlink(){return a(this,Ae)}get uid(){return a(this,Be)}get gid(){return a(this,Ie)}get rdev(){return a(this,je)}get blksize(){return a(this,_e)}get ino(){return a(this,$e)}get size(){return a(this,We)}get blocks(){return a(this,Ue)}get atimeMs(){return a(this,ze)}get mtimeMs(){return a(this,qe)}get ctimeMs(){return a(this,Ge)}get birthtimeMs(){return a(this,He)}get atime(){return a(this,Qe)}get mtime(){return a(this,Ke)}get ctime(){return a(this,Ve)}get birthtime(){return a(this,Je)}get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return a(this,Gt)!==void 0?a(this,Gt):this.parent?p(this,Gt,this.parent.depth()+1):p(this,Gt,0)}childrenCache(){return a(this,Ht)}resolve(t){var n;if(!t)return this;let e=this.getRootString(t),i=t.substring(e.length).split(this.splitSep);return e?b(n=this.getRoot(e),k,ii).call(n,i):b(this,k,ii).call(this,i)}children(){let t=a(this,Ht).get(this);if(t)return t;let e=Object.assign([],{provisional:0});return a(this,Ht).set(this,e),p(this,S,a(this,S)&~ti),e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let s=this.children(),i=this.nocase?ks(t):Pe(t);for(let l of s)if(a(l,Ft)===i)return l;let o=this.parent?this.sep:"",n=a(this,pt)?a(this,pt)+o+t:void 0,h=this.newChild(t,st,{...e,parent:this,fullpath:n});return this.canReaddir()||p(h,S,a(h,S)|nt),s.push(h),h}relative(){if(this.isCWD)return"";if(a(this,St)!==void 0)return a(this,St);let t=this.name,e=this.parent;if(!e)return p(this,St,this.name);let s=e.relative();return s+(!s||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(a(this,Ct)!==void 0)return a(this,Ct);let t=this.name,e=this.parent;if(!e)return p(this,Ct,this.fullpathPosix());let s=e.relativePosix();return s+(!s||!e.parent?"":"/")+t}fullpath(){if(a(this,pt)!==void 0)return a(this,pt);let t=this.name,e=this.parent;if(!e)return p(this,pt,this.name);let i=e.fullpath()+(e.parent?this.sep:"")+t;return p(this,pt,i)}fullpathPosix(){if(a(this,kt)!==void 0)return a(this,kt);if(this.sep==="/")return p(this,kt,this.fullpath());if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?p(this,kt,`//?/${i}`):p(this,kt,i)}let t=this.parent,e=t.fullpathPosix(),s=e+(!e||!t.parent?"":"/")+this.name;return p(this,kt,s)}isUnknown(){return(a(this,S)&et)===st}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(a(this,S)&et)===eo}isDirectory(){return(a(this,S)&et)===ut}isCharacterDevice(){return(a(this,S)&et)===Xr}isBlockDevice(){return(a(this,S)&et)===to}isFIFO(){return(a(this,S)&et)===Zr}isSocket(){return(a(this,S)&et)===so}isSymbolicLink(){return(a(this,S)&qt)===qt}lstatCached(){return a(this,S)&Gr?this:void 0}readlinkCached(){return a(this,xt)}realpathCached(){return a(this,dt)}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(a(this,xt))return!0;if(!this.parent)return!1;let t=a(this,S)&et;return!(t!==st&&t!==qt||a(this,S)&bs||a(this,S)&nt)}calledReaddir(){return!!(a(this,S)&ti)}isENOENT(){return!!(a(this,S)&nt)}isNamed(t){return this.nocase?a(this,Ft)===ks(t):a(this,Ft)===Pe(t)}async readlink(){var e;let t=a(this,xt);if(t)return t;if(this.canReadlink()&&this.parent)try{let s=await a(this,K).promises.readlink(this.fullpath()),i=(e=await this.parent.realpath())==null?void 0:e.resolve(s);if(i)return p(this,xt,i)}catch(s){b(this,k,ai).call(this,s.code);return}}readlinkSync(){var e;let t=a(this,xt);if(t)return t;if(this.canReadlink()&&this.parent)try{let s=a(this,K).readlinkSync(this.fullpath()),i=(e=this.parent.realpathSync())==null?void 0:e.resolve(s);if(i)return p(this,xt,i)}catch(s){b(this,k,ai).call(this,s.code);return}}async lstat(){if(!(a(this,S)&nt))try{return b(this,k,hi).call(this,await a(this,K).promises.lstat(this.fullpath())),this}catch(t){b(this,k,ni).call(this,t.code)}}lstatSync(){if(!(a(this,S)&nt))try{return b(this,k,hi).call(this,a(this,K).lstatSync(this.fullpath())),this}catch(t){b(this,k,ni).call(this,t.code)}}readdirCB(t,e=!1){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let s=this.children();if(this.calledReaddir()){let o=s.slice(0,s.provisional);e?t(null,o):queueMicrotask(()=>t(null,o));return}if(a(this,se).push(t),a(this,ie))return;p(this,ie,!0);let i=this.fullpath();a(this,K).readdir(i,{withFileTypes:!0},(o,n)=>{if(o)b(this,k,xs).call(this,o.code),s.provisional=0;else{for(let h of n)b(this,k,Es).call(this,h,s);b(this,k,Cs).call(this,s)}b(this,k,ao).call(this,s.slice(0,s.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(a(this,Qt))await a(this,Qt);else{let s=()=>{};p(this,Qt,new Promise(i=>s=i));try{for(let i of await a(this,K).promises.readdir(e,{withFileTypes:!0}))b(this,k,Es).call(this,i,t);b(this,k,Cs).call(this,t)}catch(i){b(this,k,xs).call(this,i.code),t.provisional=0}p(this,Qt,void 0),s()}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 s of a(this,K).readdirSync(e,{withFileTypes:!0}))b(this,k,Es).call(this,s,t);b(this,k,Cs).call(this,t)}catch(s){b(this,k,xs).call(this,s.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(a(this,S)&Hr)return!1;let t=et&a(this,S);return t===st||t===ut||t===qt}shouldWalk(t,e){return(a(this,S)&ut)===ut&&!(a(this,S)&Hr)&&!t.has(this)&&(!e||e(this))}async realpath(){if(a(this,dt))return a(this,dt);if(!((Ss|bs|nt)&a(this,S)))try{let t=await a(this,K).promises.realpath(this.fullpath());return p(this,dt,this.resolve(t))}catch(t){b(this,k,oi).call(this)}}realpathSync(){if(a(this,dt))return a(this,dt);if(!((Ss|bs|nt)&a(this,S)))try{let t=a(this,K).realpathSync(this.fullpath());return p(this,dt,this.resolve(t))}catch(t){b(this,k,oi).call(this)}}[io](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let e=new Set([]),s=[],i=this;for(;i&&i.parent;)e.add(i),p(i,St,s.join(this.sep)),p(i,Ct,s.join("/")),i=i.parent,s.push("..");for(i=t;i&&i.parent&&!e.has(i);)p(i,St,void 0),p(i,Ct,void 0),i=i.parent}};K=new WeakMap,Ne=new WeakMap,Le=new WeakMap,Ae=new WeakMap,Be=new WeakMap,Ie=new WeakMap,je=new WeakMap,_e=new WeakMap,$e=new WeakMap,We=new WeakMap,Ue=new WeakMap,ze=new WeakMap,qe=new WeakMap,Ge=new WeakMap,He=new WeakMap,Qe=new WeakMap,Ke=new WeakMap,Ve=new WeakMap,Je=new WeakMap,Ft=new WeakMap,Gt=new WeakMap,pt=new WeakMap,kt=new WeakMap,St=new WeakMap,Ct=new WeakMap,S=new WeakMap,Ht=new WeakMap,xt=new WeakMap,dt=new WeakMap,k=new WeakSet,ii=function(t){let e=this;for(let s of t)e=e.child(s);return e},Cs=function(t){var e;p(this,S,a(this,S)|ti);for(let s=t.provisional;s<t.length;s++){let i=t[s];i&&b(e=i,k,De).call(e)}},De=function(){a(this,S)&nt||(p(this,S,(a(this,S)|nt)&Re),b(this,k,ri).call(this))},ri=function(){var e;let t=this.children();t.provisional=0;for(let s of t)b(e=s,k,De).call(e)},oi=function(){p(this,S,a(this,S)|Ss),b(this,k,Me).call(this)},Me=function(){if(a(this,S)&Oe)return;let t=a(this,S);(t&et)===ut&&(t&=Re),p(this,S,t|Oe),b(this,k,ri).call(this)},xs=function(t=""){t==="ENOTDIR"||t==="EPERM"?b(this,k,Me).call(this):t==="ENOENT"?b(this,k,De).call(this):this.children().provisional=0},ni=function(t=""){var e;if(t==="ENOTDIR"){let s=this.parent;b(e=s,k,Me).call(e)}else t==="ENOENT"&&b(this,k,De).call(this)},ai=function(t=""){var s;let e=a(this,S);e|=bs,t==="ENOENT"&&(e|=nt),(t==="EINVAL"||t==="UNKNOWN")&&(e&=Re),p(this,S,e),t==="ENOTDIR"&&this.parent&&b(s=this.parent,k,Me).call(s)},Es=function(t,e){return b(this,k,oo).call(this,t,e)||b(this,k,ro).call(this,t,e)},ro=function(t,e){let s=ei(t),i=this.newChild(t.name,s,{parent:this}),o=a(i,S)&et;return o!==ut&&o!==qt&&o!==st&&p(i,S,a(i,S)|Oe),e.unshift(i),e.provisional++,i},oo=function(t,e){for(let s=e.provisional;s<e.length;s++){let i=e[s];if((this.nocase?ks(t.name):Pe(t.name))===a(i,Ft))return b(this,k,no).call(this,t,i,s,e)}},no=function(t,e,s,i){let o=e.name;return p(e,S,a(e,S)&Re|ei(t)),o!==t.name&&(e.name=t.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(e)),i.provisional++,e},hi=function(t){let{atime:e,atimeMs:s,birthtime:i,birthtimeMs:o,blksize:n,blocks:h,ctime:l,ctimeMs:c,dev:u,gid:m,ino:d,mode:y,mtime:R,mtimeMs:g,nlink:x,rdev:C,size:T,uid:O}=t;p(this,Qe,e),p(this,ze,s),p(this,Je,i),p(this,He,o),p(this,_e,n),p(this,Ue,h),p(this,Ve,l),p(this,Ge,c),p(this,Ne,u),p(this,Ie,m),p(this,$e,d),p(this,Le,y),p(this,Ke,R),p(this,qe,g),p(this,Ae,x),p(this,je,C),p(this,We,T),p(this,Be,O);let L=ei(t);p(this,S,a(this,S)&Re|L|Gr),L!==st&&L!==ut&&L!==qt&&p(this,S,a(this,S)|Oe)},se=new WeakMap,ie=new WeakMap,ao=function(t){p(this,ie,!1);let e=a(this,se).slice();a(this,se).length=0,e.forEach(s=>s(null,t))},Qt=new WeakMap;Rs=class r extends q{constructor(e,s=st,i,o,n,h,l){super(e,s,i,o,n,h,l);f(this,"sep","\\");f(this,"splitSep",ya)}newChild(e,s=st,i={}){return new r(e,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}getRootString(e){return ne.win32.parse(e).root}getRoot(e){if(e=wa(e.toUpperCase()),e===this.root.name)return this.root;for(let[s,i]of Object.entries(this.roots))if(this.sameRoot(e,s))return this.roots[e]=i;return this.roots[e]=new ae(e,this).root}sameRoot(e,s=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(Yr,"$1\\"),e===s}},Ts=class r extends q{constructor(e,s=st,i,o,n,h,l){super(e,s,i,o,n,h,l);f(this,"splitSep","/");f(this,"sep","/")}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,s=st,i={}){return new r(e,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}},Os=class{constructor(t=process.cwd(),e,s,{nocase:i,childrenCacheSize:o=16*1024,fs:n=Te}={}){f(this,"root");f(this,"rootPath");f(this,"roots");f(this,"cwd");w(this,re);w(this,oe);w(this,Ye);f(this,"nocase");w(this,Ze);p(this,Ze,Jr(n)),(t instanceof URL||t.startsWith("file://"))&&(t=(0,Vr.fileURLToPath)(t));let h=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(h),p(this,re,new vs),p(this,oe,new vs),p(this,Ye,new si(o));let l=h.substring(this.rootPath.length).split(s);if(l.length===1&&!l[0]&&l.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(a(this,Ze)),this.roots[this.rootPath]=this.root;let c=this.root,u=l.length-1,m=e.sep,d=this.rootPath,y=!1;for(let R of l){let g=u--;c=c.child(R,{relative:new Array(g).fill("..").join(m),relativePosix:new Array(g).fill("..").join("/"),fullpath:d+=(y?"":m)+R}),y=!0}this.cwd=c}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return a(this,Ye)}resolve(...t){let e="";for(let o=t.length-1;o>=0;o--){let n=t[o];if(!(!n||n===".")&&(e=e?`${n}/${e}`:n,this.isAbsolute(n)))break}let s=a(this,re).get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpath();return a(this,re).set(e,i),i}resolvePosix(...t){let e="";for(let o=t.length-1;o>=0;o--){let n=t[o];if(!(!n||n===".")&&(e=e?`${n}/${e}`:n,this.isAbsolute(n)))break}let s=a(this,oe).get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpathPosix();return a(this,oe).set(e,i),i}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 q||(e=t,t=this.cwd);let{withFileTypes:s}=e;if(t.canReaddir()){let i=await t.readdir();return s?i:i.map(o=>o.name)}else return[]}readdirSync(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof q||(e=t,t=this.cwd);let{withFileTypes:s=!0}=e;return t.canReaddir()?s?t.readdirSync():t.readdirSync().map(i=>i.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 q||(e=t.withFileTypes,t=this.cwd);let s=await t.readlink();return e?s:s==null?void 0:s.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof q||(e=t.withFileTypes,t=this.cwd);let s=t.readlinkSync();return e?s:s==null?void 0:s.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof q||(e=t.withFileTypes,t=this.cwd);let s=await t.realpath();return e?s:s==null?void 0:s.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof q||(e=t.withFileTypes,t=this.cwd);let s=t.realpathSync();return e?s:s==null?void 0:s.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof q||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:o,walkFilter:n}=e,h=[];(!o||o(t))&&h.push(s?t:t.fullpath());let l=new Set,c=(m,d)=>{l.add(m),m.readdirCB((y,R)=>{if(y)return d(y);let g=R.length;if(!g)return d();let x=()=>{--g===0&&d()};for(let C of R)(!o||o(C))&&h.push(s?C:C.fullpath()),i&&C.isSymbolicLink()?C.realpath().then(T=>T!=null&&T.isUnknown()?T.lstat():T).then(T=>T!=null&&T.shouldWalk(l,n)?c(T,x):x()):C.shouldWalk(l,n)?c(C,x):x()},!0)},u=t;return new Promise((m,d)=>{c(u,y=>{if(y)return d(y);m(h)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof q||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:o,walkFilter:n}=e,h=[];(!o||o(t))&&h.push(s?t:t.fullpath());let l=new Set([t]);for(let c of l){let u=c.readdirSync();for(let m of u){(!o||o(m))&&h.push(s?m:m.fullpath());let d=m;if(m.isSymbolicLink()){if(!(i&&(d=m.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(l,n)&&l.add(d)}}return h}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof q||(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 q||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:o,walkFilter:n}=e;(!o||o(t))&&(yield s?t:t.fullpath());let h=new Set([t]);for(let l of h){let c=l.readdirSync();for(let u of c){(!o||o(u))&&(yield s?u:u.fullpath());let m=u;if(u.isSymbolicLink()){if(!(i&&(m=u.realpathSync())))continue;m.isUnknown()&&m.lstatSync()}m.shouldWalk(h,n)&&h.add(m)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof q||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:o,walkFilter:n}=e,h=new Mt({objectMode:!0});(!o||o(t))&&h.write(s?t:t.fullpath());let l=new Set,c=[t],u=0,m=()=>{let d=!1;for(;!d;){let y=c.shift();if(!y){u===0&&h.end();return}u++,l.add(y);let R=(x,C,T=!1)=>{if(x)return h.emit("error",x);if(i&&!T){let O=[];for(let L of C)L.isSymbolicLink()&&O.push(L.realpath().then(V=>V!=null&&V.isUnknown()?V.lstat():V));if(O.length){Promise.all(O).then(()=>R(null,C,!0));return}}for(let O of C)O&&(!o||o(O))&&(h.write(s?O:O.fullpath())||(d=!0));u--;for(let O of C){let L=O.realpathCached()||O;L.shouldWalk(l,n)&&c.push(L)}d&&!h.flowing?h.once("drain",m):g||m()},g=!0;y.readdirCB(R,!0),g=!1}};return m(),h}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof q||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:o,walkFilter:n}=e,h=new Mt({objectMode:!0}),l=new Set;(!o||o(t))&&h.write(s?t:t.fullpath());let c=[t],u=0,m=()=>{let d=!1;for(;!d;){let y=c.shift();if(!y){u===0&&h.end();return}u++,l.add(y);let R=y.readdirSync();for(let g of R)(!o||o(g))&&(h.write(s?g:g.fullpath())||(d=!0));u--;for(let g of R){let x=g;if(g.isSymbolicLink()){if(!(i&&(x=g.realpathSync())))continue;x.isUnknown()&&x.lstatSync()}x.shouldWalk(l,n)&&c.push(x)}}d&&!h.flowing&&h.once("drain",m)};return m(),h}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[io](e)}};re=new WeakMap,oe=new WeakMap,Ye=new WeakMap,Ze=new WeakMap;ae=class extends Os{constructor(e=process.cwd(),s={}){let{nocase:i=!0}=s;super(e,ne.win32,"\\",{...s,nocase:i});f(this,"sep","\\");this.nocase=i;for(let o=this.cwd;o;o=o.parent)o.nocase=this.nocase}parseRootPath(e){return ne.win32.parse(e).root.toUpperCase()}newRoot(e){return new Rs(this.rootPath,ut,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},he=class extends Os{constructor(e=process.cwd(),s={}){let{nocase:i=!1}=s;super(e,ne.posix,"/",{...s,nocase:i});f(this,"sep","/");this.nocase=i}parseRootPath(e){return"/"}newRoot(e){return new Ts(this.rootPath,ut,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},Fe=class extends he{constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,{...e,nocase:s})}},qh=process.platform==="win32"?Rs:Ts,ho=process.platform==="win32"?ae:process.platform==="darwin"?Fe:he});var ka,Sa,B,Z,W,Kt,at,Xe,Lt,At,Bt,le,ci,ce,fi=E(()=>{"use strict";Pt();ka=r=>r.length>=1,Sa=r=>r.length>=1,ci=class ci{constructor(t,e,s,i){w(this,B);w(this,Z);w(this,W);f(this,"length");w(this,Kt);w(this,at);w(this,Xe);w(this,Lt);w(this,At);w(this,Bt);w(this,le,!0);if(!ka(t))throw new TypeError("empty pattern list");if(!Sa(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,s<0||s>=this.length)throw new TypeError("index out of range");if(p(this,B,t),p(this,Z,e),p(this,W,s),p(this,Kt,i),a(this,W)===0){if(this.isUNC()){let[o,n,h,l,...c]=a(this,B),[u,m,d,y,...R]=a(this,Z);c[0]===""&&(c.shift(),R.shift());let g=[o,n,h,l,""].join("/"),x=[u,m,d,y,""].join("/");p(this,B,[g,...c]),p(this,Z,[x,...R]),this.length=a(this,B).length}else if(this.isDrive()||this.isAbsolute()){let[o,...n]=a(this,B),[h,...l]=a(this,Z);n[0]===""&&(n.shift(),l.shift());let c=o+"/",u=h+"/";p(this,B,[c,...n]),p(this,Z,[u,...l]),this.length=a(this,B).length}}}pattern(){return a(this,B)[a(this,W)]}isString(){return typeof a(this,B)[a(this,W)]=="string"}isGlobstar(){return a(this,B)[a(this,W)]===U}isRegExp(){return a(this,B)[a(this,W)]instanceof RegExp}globString(){return p(this,Xe,a(this,Xe)||(a(this,W)===0?this.isAbsolute()?a(this,Z)[0]+a(this,Z).slice(1).join("/"):a(this,Z).join("/"):a(this,Z).slice(a(this,W)).join("/")))}hasMore(){return this.length>a(this,W)+1}rest(){return a(this,at)!==void 0?a(this,at):this.hasMore()?(p(this,at,new ci(a(this,B),a(this,Z),a(this,W)+1,a(this,Kt))),p(a(this,at),Bt,a(this,Bt)),p(a(this,at),At,a(this,At)),p(a(this,at),Lt,a(this,Lt)),a(this,at)):p(this,at,null)}isUNC(){let t=a(this,B);return a(this,At)!==void 0?a(this,At):p(this,At,a(this,Kt)==="win32"&&a(this,W)===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3])}isDrive(){let t=a(this,B);return a(this,Lt)!==void 0?a(this,Lt):p(this,Lt,a(this,Kt)==="win32"&&a(this,W)===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]))}isAbsolute(){let t=a(this,B);return a(this,Bt)!==void 0?a(this,Bt):p(this,Bt,t[0]===""&&t.length>1||this.isDrive()||this.isUNC())}root(){let t=a(this,B)[0];return typeof t=="string"&&this.isAbsolute()&&a(this,W)===0?t:""}checkFollowGlobstar(){return!(a(this,W)===0||!this.isGlobstar()||!a(this,le))}markFollowGlobstar(){return a(this,W)===0||!this.isGlobstar()||!a(this,le)?!1:(p(this,le,!1),!0)}};B=new WeakMap,Z=new WeakMap,W=new WeakMap,Kt=new WeakMap,at=new WeakMap,Xe=new WeakMap,Lt=new WeakMap,At=new WeakMap,Bt=new WeakMap,le=new WeakMap;ce=ci});var Ca,fe,ui=E(()=>{"use strict";Pt();fi();Ca=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",fe=class{constructor(t,{nobrace:e,nocase:s,noext:i,noglobstar:o,platform:n=Ca}){f(this,"relative");f(this,"relativeChildren");f(this,"absolute");f(this,"absoluteChildren");f(this,"platform");f(this,"mmopts");this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=n,this.mmopts={dot:!0,nobrace:e,nocase:s,noext:i,noglobstar:o,optimizationLevel:2,platform:n,nocomment:!0,nonegate:!0};for(let h of t)this.add(h)}add(t){let e=new J(t,this.mmopts);for(let s=0;s<e.set.length;s++){let i=e.set[s],o=e.globParts[s];if(!i||!o)throw new Error("invalid pattern object");for(;i[0]==="."&&o[0]===".";)i.shift(),o.shift();let n=new ce(i,o,0,this.platform),h=new J(n.globString(),this.mmopts),l=o[o.length-1]==="**",c=n.isAbsolute();c?this.absolute.push(h):this.relative.push(h),l&&(c?this.absoluteChildren.push(h):this.relativeChildren.push(h))}}ignored(t){let e=t.fullpath(),s=`${e}/`,i=t.relative()||".",o=`${i}/`;for(let n of this.relative)if(n.match(i)||n.match(o))return!0;for(let n of this.absolute)if(n.match(e)||n.match(s))return!0;return!1}childrenIgnored(t){let e=t.fullpath()+"/",s=(t.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return!0;for(let i of this.absoluteChildren)if(i.match(e))return!0;return!1}}});var pi,di,mi,ts,co=E(()=>{"use strict";Pt();pi=class r{constructor(t=new Map){f(this,"store");this.store=t}copy(){return new r(new Map(this.store))}hasWalked(t,e){var s;return(s=this.store.get(t.fullpath()))==null?void 0:s.has(e.globString())}storeWalked(t,e){let s=t.fullpath(),i=this.store.get(s);i?i.add(e.globString()):this.store.set(s,new Set([e.globString()]))}},di=class{constructor(){f(this,"store",new Map)}add(t,e,s){let i=(e?2:0)|(s?1:0),o=this.store.get(t);this.store.set(t,o===void 0?i:i&o)}entries(){return[...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},mi=class{constructor(){f(this,"store",new Map)}add(t,e){if(!t.canReaddir())return;let s=this.store.get(t);s?s.find(i=>i.globString()===e.globString())||s.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())}},ts=class r{constructor(t,e){f(this,"hasWalkedCache");f(this,"matches",new di);f(this,"subwalks",new mi);f(this,"patterns");f(this,"follow");f(this,"dot");f(this,"opts");this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=e?e.copy():new pi}processPatterns(t,e){this.patterns=e;let s=e.map(i=>[t,i]);for(let[i,o]of s){this.hasWalkedCache.storeWalked(i,o);let n=o.root(),h=o.isAbsolute()&&this.opts.absolute!==!1;if(n){i=i.resolve(n==="/"&&this.opts.root!==void 0?this.opts.root:n);let m=o.rest();if(m)o=m;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let l,c,u=!1;for(;typeof(l=o.pattern())=="string"&&(c=o.rest());)i=i.resolve(l),o=c,u=!0;if(l=o.pattern(),c=o.rest(),u){if(this.hasWalkedCache.hasWalked(i,o))continue;this.hasWalkedCache.storeWalked(i,o)}if(typeof l=="string"){let m=l===".."||l===""||l===".";this.matches.add(i.resolve(l),h,m);continue}else if(l===U){(!i.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(i,o);let m=c==null?void 0:c.pattern(),d=c==null?void 0:c.rest();if(!c||(m===""||m===".")&&!d)this.matches.add(i,h,m===""||m===".");else if(m===".."){let y=i.parent||i;d?this.hasWalkedCache.hasWalked(y,d)||this.subwalks.add(y,d):this.matches.add(y,h,!0)}}else l instanceof RegExp&&this.subwalks.add(i,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new r(this.opts,this.hasWalkedCache)}filterEntries(t,e){let s=this.subwalks.get(t),i=this.child();for(let o of e)for(let n of s){let h=n.isAbsolute(),l=n.pattern(),c=n.rest();l===U?i.testGlobstar(o,n,c,h):l instanceof RegExp?i.testRegExp(o,l,c,h):i.testString(o,l,c,h)}return i}testGlobstar(t,e,s,i){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,i,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(s&&e.checkFollowGlobstar()?this.subwalks.add(t,s):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),s){let o=s.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,s.rest(),i);else if(o===".."){let n=t.parent||t;this.subwalks.add(n,s)}else o instanceof RegExp&&this.testRegExp(t,o,s.rest(),i)}}testRegExp(t,e,s,i){e.test(t.name)&&(s?this.subwalks.add(t,s):this.matches.add(t,i,!1))}testString(t,e,s,i){t.isNamed(e)&&(s?this.subwalks.add(t,s):this.matches.add(t,i,!1))}}});var xa,ue,Et,Jt,it,Vt,gi,Ps,es,ss,fo=E(()=>{"use strict";Xs();ui();co();xa=(r,t)=>typeof r=="string"?new fe([r],t):Array.isArray(r)?new fe(r,t):r,Ps=class{constructor(t,e,s){w(this,it);f(this,"path");f(this,"patterns");f(this,"opts");f(this,"seen",new Set);f(this,"paused",!1);f(this,"aborted",!1);w(this,ue,[]);w(this,Et);w(this,Jt);f(this,"signal");f(this,"maxDepth");f(this,"includeChildMatches");var i;if(this.patterns=t,this.path=e,this.opts=s,p(this,Jt,!s.posix&&s.platform==="win32"?"\\":"/"),this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(p(this,Et,xa((i=s.ignore)!=null?i:[],s)),!this.includeChildMatches&&typeof a(this,Et).add!="function")){let o="cannot ignore child matches, ignore lacks add() method.";throw new Error(o)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{a(this,ue).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=a(this,ue).shift());)t()}onResume(t){var e;(e=this.signal)!=null&&e.aborted||(this.paused?a(this,ue).push(t):t())}async matchCheck(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||await t.realpath(),!s)return;t=s}let o=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&(o!=null&&o.isSymbolicLink())){let n=await o.realpath();n&&(n.isUnknown()||this.opts.stat)&&await n.lstat()}return this.matchCheckTest(o,e)}matchCheckTest(t,e){var s;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()||!((s=t.realpathCached())!=null&&s.isDirectory()))&&!b(this,it,Vt).call(this,t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||t.realpathSync(),!s)return;t=s}let o=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&(o!=null&&o.isSymbolicLink())){let n=o.realpathSync();n&&(n!=null&&n.isUnknown()||this.opts.stat)&&n.lstatSync()}return this.matchCheckTest(o,e)}matchFinish(t,e){var o;if(b(this,it,Vt).call(this,t))return;if(!this.includeChildMatches&&((o=a(this,Et))!=null&&o.add)){let n=`${t.relativePosix()}/**`;a(this,Et).add(n)}let s=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let i=this.opts.mark&&t.isDirectory()?a(this,Jt):"";if(this.opts.withFileTypes)this.matchEmit(t);else if(s){let n=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(n+i)}else{let n=this.opts.posix?t.relativePosix():t.relative(),h=this.opts.dotRelative&&!n.startsWith(".."+a(this,Jt))?"."+a(this,Jt):"";this.matchEmit(n?h+n+i:"."+i)}}async match(t,e,s){let i=await this.matchCheck(t,s);i&&this.matchFinish(i,e)}matchSync(t,e,s){let i=this.matchCheckSync(t,s);i&&this.matchFinish(i,e)}walkCB(t,e,s){var i;(i=this.signal)!=null&&i.aborted&&s(),this.walkCB2(t,e,new ts(this.opts),s)}walkCB2(t,e,s,i){var h;if(b(this,it,gi).call(this,t))return i();if((h=this.signal)!=null&&h.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(t,e,s,i));return}s.processPatterns(t,e);let o=1,n=()=>{--o===0&&i()};for(let[l,c,u]of s.matches.entries())b(this,it,Vt).call(this,l)||(o++,this.match(l,c,u).then(()=>n()));for(let l of s.subwalkTargets()){if(this.maxDepth!==1/0&&l.depth()>=this.maxDepth)continue;o++;let c=l.readdirCached();l.calledReaddir()?this.walkCB3(l,c,s,n):l.readdirCB((u,m)=>this.walkCB3(l,m,s,n),!0)}n()}walkCB3(t,e,s,i){s=s.filterEntries(t,e);let o=1,n=()=>{--o===0&&i()};for(let[h,l,c]of s.matches.entries())b(this,it,Vt).call(this,h)||(o++,this.match(h,l,c).then(()=>n()));for(let[h,l]of s.subwalks.entries())o++,this.walkCB2(h,l,s.child(),n);n()}walkCBSync(t,e,s){var i;(i=this.signal)!=null&&i.aborted&&s(),this.walkCB2Sync(t,e,new ts(this.opts),s)}walkCB2Sync(t,e,s,i){var h;if(b(this,it,gi).call(this,t))return i();if((h=this.signal)!=null&&h.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,s,i));return}s.processPatterns(t,e);let o=1,n=()=>{--o===0&&i()};for(let[l,c,u]of s.matches.entries())b(this,it,Vt).call(this,l)||this.matchSync(l,c,u);for(let l of s.subwalkTargets()){if(this.maxDepth!==1/0&&l.depth()>=this.maxDepth)continue;o++;let c=l.readdirSync();this.walkCB3Sync(l,c,s,n)}n()}walkCB3Sync(t,e,s,i){s=s.filterEntries(t,e);let o=1,n=()=>{--o===0&&i()};for(let[h,l,c]of s.matches.entries())b(this,it,Vt).call(this,h)||this.matchSync(h,l,c);for(let[h,l]of s.subwalks.entries())o++,this.walkCB2Sync(h,l,s.child(),n);n()}};ue=new WeakMap,Et=new WeakMap,Jt=new WeakMap,it=new WeakSet,Vt=function(t){var e,s;return this.seen.has(t)||!!((s=(e=a(this,Et))==null?void 0:e.ignored)!=null&&s.call(e,t))},gi=function(t){var e,s;return!!((s=(e=a(this,Et))==null?void 0:e.childrenIgnored)!=null&&s.call(e,t))};es=class extends Ps{constructor(e,s,i){super(e,s,i);f(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((s,i)=>{this.walkCB(this.path,this.patterns,()=>{var o;(o=this.signal)!=null&&o.aborted?i(this.signal.reason):s(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 s;if((s=this.signal)!=null&&s.aborted)throw this.signal.reason}),this.matches}},ss=class extends Ps{constructor(e,s,i){super(e,s,i);f(this,"results");this.results=new Mt({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 uo,Ea,ht,wi=E(()=>{"use strict";Pt();uo=require("url");lo();fi();fo();Ea=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",ht=class{constructor(t,e){f(this,"absolute");f(this,"cwd");f(this,"root");f(this,"dot");f(this,"dotRelative");f(this,"follow");f(this,"ignore");f(this,"magicalBraces");f(this,"mark");f(this,"matchBase");f(this,"maxDepth");f(this,"nobrace");f(this,"nocase");f(this,"nodir");f(this,"noext");f(this,"noglobstar");f(this,"pattern");f(this,"platform");f(this,"realpath");f(this,"scurry");f(this,"stat");f(this,"signal");f(this,"windowsPathsNoEscape");f(this,"withFileTypes");f(this,"includeChildMatches");f(this,"opts");f(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,uo.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(l=>l.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(l=>l.includes("/")?l:`./**/${l}`)}if(this.pattern=t,this.platform=e.platform||Ea,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 l=e.platform==="win32"?ae:e.platform==="darwin"?Fe:e.platform?he:ho;this.scurry=new l(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},o=this.pattern.map(l=>new J(l,i)),[n,h]=o.reduce((l,c)=>(l[0].push(...c.set),l[1].push(...c.globParts),l),[[],[]]);this.patterns=n.map((l,c)=>{let u=h[c];if(!u)throw new Error("invalid pattern object");return new ce(l,u,0,this.platform)})}async walk(){return[...await new es(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 es(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 ss(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 ss(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 yi,bi=E(()=>{"use strict";Pt();yi=(r,t={})=>{Array.isArray(r)||(r=[r]);for(let e of r)if(new J(e,t).hasMagic())return!0;return!1}});function Ds(r,t={}){return new ht(r,t).streamSync()}function go(r,t={}){return new ht(r,t).stream()}function wo(r,t={}){return new ht(r,t).walkSync()}async function po(r,t={}){return new ht(r,t).walk()}function Ms(r,t={}){return new ht(r,t).iterateSync()}function yo(r,t={}){return new ht(r,t).iterate()}var va,Ra,Ta,Oa,is,mo,ki=E(()=>{"use strict";Pt();wi();bi();Pt();wi();bi();ui();va=Ds,Ra=Object.assign(go,{sync:Ds}),Ta=Ms,Oa=Object.assign(yo,{sync:Ms}),is=Object.assign(wo,{stream:Ds,iterate:Ms}),mo=Object.assign(po,{glob:po,globSync:wo,sync:is,globStream:go,stream:Ra,globStreamSync:Ds,streamSync:va,globIterate:yo,iterate:Oa,globIterateSync:Ms,iterateSync:Ta,Glob:ht,hasMagic:yi,escape:Xt,unescape:rt});mo.glob=mo});function bo(){let r=is("./**/Cookies",{cwd:Yt,absolute:!0});return Ma.debug("Found cookie files:",r),r}var Pa,Da,Ma,ko=E(()=>{"use strict";Pa=require("fs"),Da=require("path");ki();gt();js();Ma=D.withTag("listChromeProfiles")});function La(r){var e;let t=[/.*?0t(.+)$/,/.*?1e`(.+)$/,/.*?[`'](.+)$/,/[^\x20-\x7E]*([\x20-\x7E].+)$/];for(let s of t){let i=r.match(s),o=(e=i==null?void 0:i[1])!=null?e:"";if(o.length>0)return o}return r}async function So(r,t){if(typeof t!="string")throw new Error("password must be a string");if(!Buffer.isBuffer(r))throw new Error("encryptedData must be a Buffer");return new Promise((e,s)=>{(0,Fs.pbkdf2)(t,"saltysalt",1003,16,"sha1",(i,o)=>{try{if(i){s(new Error("Failed to derive key: "+i.message));return}let n=Fa(r);if(n.length%16!==0){s(new Error("Encrypted data length is not a multiple of 16"));return}let h=Buffer.alloc(16," "),l=(0,Fs.createDecipheriv)("aes-128-cbc",o,h);l.setAutoPadding(!1);let c=l.update(n);try{l.final()}catch(m){s(new Error("Failed to finalize decryption: "+m.message));return}c=Na(c);let u=c.toString("utf8");e(La(u))}catch(n){s(new Error("Decryption failed: "+n.message))}})})}var Fs,Si,Fa,Na,Co=E(()=>{"use strict";Fs=require("crypto"),Si=require("lodash-es"),Fa=(0,Si.memoize)(r=>r.length>=3&&r[0]===118&&r[1]===49&&r[2]===48?r.slice(3):r,r=>r.toString("hex")),Na=(0,Si.memoize)(r=>{let t=r[r.length-1];return t&&t<=16?r.slice(0,-t):r},r=>r.toString("hex"))});function Ba(r,t){if(r instanceof It)throw F("Command execution failed",r,{command:r.command,originalError:r.originalError}),r;if(r instanceof Error){let s=new It(r.message,t,r);throw F("Failed to execute command",r,{command:t,stack:r.stack}),s}let e=new It("Unknown error occurred during command execution",t);throw F("Failed to execute command",null,{error:r,command:t}),e}async function vo(r,t={}){if(!r||typeof r!="string")throw new It("Command must be a non-empty string",r);let e={encoding:"utf8",maxBuffer:5*1024*1024,timeout:3e4};try{let{stdout:s,stderr:i}=await Aa(r,{...e,...t}),o=s.trim();if(!o)throw i?new It(`Command failed with stderr: ${i}`,r):new It("Command returned empty result",r);return o}catch(s){Ba(s,r)}}var xo,Eo,Aa,It,Ro=E(()=>{"use strict";xo=require("child_process"),Eo=require("util");vt();Aa=(0,Eo.promisify)(xo.exec),It=class extends Error{constructor(e,s,i){super(e);this.command=s;this.originalError=i;this.name="CommandExecutionError"}}});var Oo={};_t(Oo,{getChromePassword:()=>ja});var To,Ia,ja,Po=E(()=>{"use strict";To=require("lodash-es");Ro();Ia=async()=>vo('security find-generic-password -w -s "Chrome Safe Storage"'),ja=(0,To.memoize)(Ia)});var Do,Mo,Fo=E(()=>{"use strict";Do=require("lodash-es");vt();Mo=(0,Do.memoize)(async()=>{if(process.platform!=="darwin")throw F("Chrome password retrieval failed",new Error("This only works on macOS"),{platform:process.platform}),new Error("This only works on macOS");try{let{getChromePassword:r}=await Promise.resolve().then(()=>(Po(),Oo)),t=await r();return lt("ChromePassword","Retrieved password successfully",{platform:"macOS"}),t}catch(r){throw F("Chrome password retrieval failed",r,{platform:"macOS"}),r}})});function _a(r){return typeof r!="number"||r<=0?"Infinity":new Date(r)}function No(r,t,e,s,i,o){return{domain:r,name:t,value:e,expiry:_a(s),meta:{file:i,browser:"Chrome",decrypted:o}}}var pe,Ci=E(()=>{"use strict";vt();Gi();ko();Co();Fo();pe=class{constructor(){this.logger=Li("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 s=bo();if(s.length===0)return this.logger.warn("No Chrome cookie files found"),[];let i=await Mo();return(await Promise.all(s.map(n=>this.processFile(n,t,e,i)))).flat()}catch(s){return s instanceof Error?F("Failed to query cookies",s,{name:t,domain:e}):F("Failed to query cookies",new Error(String(s)),{name:t,domain:e}),[]}}async processFile(t,e,s,i){try{let o=await qi({name:e,domain:s,file:t}),n={file:t,password:i};return(await Promise.allSettled(o.map(l=>this.processCookie(l,n)))).map(l=>l.status==="fulfilled"?l.value:null).filter(l=>l!==null)}catch(o){return o instanceof Error?this.logger.error("Failed to process cookie file",{error:o,file:t}):this.logger.error("Failed to process cookie file",{error:String(o),file:t}),[]}}async processCookie(t,e){try{let s=Buffer.isBuffer(t.value)?t.value:Buffer.from(String(t.value)),i=await So(s,e.password);return No(t.domain,t.name,i,t.expiry,e.file,!0)}catch(s){return s instanceof Error?this.logger.warn("Failed to decrypt cookie",{error:s}):this.logger.warn("Failed to decrypt cookie",{error:String(s)}),No(t.domain,t.name,t.value.toString("utf-8"),t.expiry,e.file,!1)}}}});function $a(){let r=[],t=process.env.HOME;if(typeof t!="string"||t.length===0)return os("FirefoxCookieQuery","HOME environment variable not set"),r;let e=[(0,xi.join)(t,"Library/Application Support/Firefox/Profiles/*/cookies.sqlite"),(0,xi.join)(t,".mozilla/firefox/*/cookies.sqlite")];for(let s of e){let i=is(s);r.push(...i)}return lt("FirefoxCookieQuery","Found Firefox cookie files",{files:r}),r}var xi,de,Ei=E(()=>{"use strict";xi=require("path");ki();vt();_s();de=class{constructor(){this.browserName="Firefox"}async queryCookies(t,e){let s=$a(),i=[];for(let o of s)try{let n=await as({file:o,sql:"SELECT name, value, host as domain, expiry FROM moz_cookies WHERE name = ? AND host LIKE ?",params:[t,`%${e}%`],rowTransform:h=>({name:h.name,value:h.value,domain:h.domain,expiry:h.expiry>0?new Date(h.expiry*1e3):"Infinity",meta:{file:o,browser:"Firefox",decrypted:!1}})});i.push(...n)}catch(n){n instanceof Error?os("FirefoxCookieQuery",`Error reading Firefox cookie file ${o}`,{error:n.message}):os("FirefoxCookieQuery",`Error reading Firefox cookie file ${o}`)}return i}}});function Ns(r,t){let e=t;for(;e<r.length&&r[e]!==0;)e++;return[r.toString("utf8",t,e),e+1]}function qa(r,t){let e=r.readUInt32LE(t),s=t+43,o=r.readUInt32LE(s)-za,n=t+56,[h,l]=Ns(r,n);n=l;let[c,u]=Ns(r,n);n=u;let[m,d]=Ns(r,n);n=d;let[y,R]=Ns(r,n);return[{name:c,value:y,domain:h.startsWith(".")?h.slice(1):h,path:m||"/",expiry:o,creation:o},e]}function Ga(r,t,e){let s=t+5,i=r.readUInt32BE(s),o=t+i,n=[],h=t+e;for(;o<h-8;)try{let[l,c]=qa(r,o);n.push(l),o+=c}catch(l){console.warn(`Error decoding cookie at offset ${o}:`,l);break}return n}function Ao(r){let t=(0,Lo.readFileSync)(r),e=t.readUInt32BE(4),s=[];for(let n=0;n<e;n++)s.push(t.readUInt32BE(8+n*4));let i=8+e*4,o=[];for(let n=0;n<e;n++)try{let h=Ga(t,i,s[n]);o.push(...h),i+=s[n]}catch(h){console.warn(`Error decoding page ${n}:`,h),i+=s[n]}return o}var Lo,Wa,Ua,za,Bo=E(()=>{"use strict";Lo=require("fs"),Wa=require("os"),Ua=require("path"),za=1706047360});var Io,Ls,jo=E(()=>{"use strict";Io=require("path");vt();Bo();Ls=class{constructor(){this.browserName="Safari"}getHomeDir(){let t=process.env.HOME;return typeof t!="string"||t.trim().length===0?(F("SafariCookieQueryStrategy","HOME environment variable not set"),""):t}getCookieDbPath(t){return(0,Io.join)(t,"Library","Containers","com.apple.Safari","Data","Library","Cookies","Cookies.binarycookies")}decodeCookies(t,e,s){try{return Ao(t).filter(o=>o.name===e&&o.domain.includes(s)).map(o=>({domain:o.domain,name:o.name,value:o.value.toString(),expiry:typeof o.expiry=="number"&&o.expiry>0?new Date(o.expiry*1e3):"Infinity",meta:{file:t,browser:"Safari",decrypted:!1}}))}catch(i){return i instanceof Error?F("SafariCookieQueryStrategy",`Error decoding ${t}`,{error:i,name:e,domain:s}):F("SafariCookieQueryStrategy",`Error decoding ${t}`,{error:"Unknown error",name:e,domain:s}),[]}}async queryCookies(t,e){let s=this.getHomeDir();if(typeof s!="string"||s.length===0)return Promise.resolve([]);let i=this.getCookieDbPath(s);return Promise.resolve(this.decodeCookies(i,t,e))}}});async function _o(r){if(!r.name||!r.domain)return[];let{name:t,domain:e}=r;if(typeof t!="string"||typeof e!="string")return[];let s=[new pe,new de,new Ls];return(await Promise.allSettled(s.map(o=>o.queryCookies(t,e)))).filter(o=>o.status==="fulfilled").flatMap(o=>o.value)}var $o=E(()=>{"use strict";Ci();Ei();jo()});var Wo={};_t(Wo,{default:()=>Ha,getCookie:()=>me});async function me(r){try{return await _o(r)}catch(t){return D.warn("Error querying cookies:",t instanceof Error?t.message:String(t)),[]}}var Ha,As=E(()=>{"use strict";gt();$o();Ha=me});var zo={};_t(zo,{default:()=>Qa,getChromeCookie:()=>Uo});async function Uo(r){try{return await new pe().queryCookies(r.name,r.domain)}catch(t){return D.warn("Error querying Chrome cookies:",t),[]}}var Qa,qo=E(()=>{"use strict";gt();Ci();Qa=Uo});var Ho={};_t(Ho,{default:()=>Ka,getFirefoxCookie:()=>Go});async function Go(r){try{return await new de().queryCookies(r.name,r.domain)}catch(t){return D.warn("Error querying Firefox cookies:",t instanceof Error?t.message:String(t)),[]}}var Ka,Qo=E(()=>{"use strict";gt();Ei();Ka=Go});var v,oc,Va,rs,nc,ac,Ja,hc,vi=E(()=>{"use strict";v=require("zod"),oc=v.z.object({name:v.z.string().trim().min(1,"Cookie name cannot be empty"),domain:v.z.string().trim().min(1,"Domain cannot be empty")}).strict(),Va=v.z.object({file:v.z.string().trim().min(1,"File path cannot be empty").optional(),browser:v.z.string().trim().optional(),decrypted:v.z.boolean().optional(),secure:v.z.boolean().optional(),httpOnly:v.z.boolean().optional(),path:v.z.string().optional()}).catchall(v.z.unknown()).strict(),rs=v.z.object({domain:v.z.string().trim().min(1,"Domain cannot be empty"),name:v.z.string().trim().min(1,"Cookie name cannot be empty"),value:v.z.string(),expiry:v.z.union([v.z.literal("Infinity"),v.z.date(),v.z.number().int().positive("Expiry must be a positive number")]).optional(),meta:Va.optional()}).strict(),nc=v.z.object({expiry:v.z.number().int().optional(),domain:v.z.string().trim().min(1,"Domain cannot be empty"),name:v.z.string().trim().min(1,"Cookie name cannot be empty"),value:v.z.union([v.z.string(),v.z.instanceof(Buffer)])}).strict(),ac=v.z.object({format:v.z.enum(["merged","grouped"]).optional(),separator:v.z.string().optional(),showFilePaths:v.z.boolean().optional()}).strict(),Ja=v.z.enum(["Chrome","Firefox","Safari","internal","unknown"]),hc=v.z.object({browserName:Ja,queryCookies:v.z.function().args(v.z.string(),v.z.string()).returns(v.z.promise(v.z.array(rs)))}).strict()});function Bs(r,t={}){let{format:e="merged",showFilePaths:s=!0,separator:i="; "}=t;if(r.length===0)return e==="merged"?"":[];if(e==="merged")return r.map(n=>n.value).join(i);let o=(0,Ko.groupBy)(r,n=>{var h,l;return(l=(h=n.meta)==null?void 0:h.file)!=null?l:"unknown"});return Object.entries(o).map(([n,h])=>{let l=h.map(c=>c.value).join(i);return s?`${n}: ${l}`:l})}var Ko,Ri=E(()=>{"use strict";Ko=require("lodash-es")});var Jo={};_t(Jo,{default:()=>Ya,getGroupedRenderedCookies:()=>Vo});async function Vo(r,t={}){try{let e=await me(r);if(!Array.isArray(e))return[];let s=e.filter(i=>{let o=rs.safeParse(i);return o.success?!0:(D.warn("Invalid cookie format:",o.error.format()),!1)});return Bs(s,{...t,format:"grouped"})}catch(e){return D.warn("Error getting grouped rendered cookies:",e instanceof Error?e.message:String(e)),[]}}var Ya,Yo=E(()=>{"use strict";vi();gt();As();Ri();Ya=Vo});var Xo={};_t(Xo,{default:()=>Za,getMergedRenderedCookies:()=>Zo});async function Zo(r,t){try{let e=await me(r);if(!Array.isArray(e))return"";let s=e.filter(o=>{let n=rs.safeParse(o);return n.success?!0:(D.warn("Invalid cookie format:",n.error.format()),!1)}),i=Bs(s,{...t,format:"merged"});return typeof i=="string"?i:""}catch(e){return D.warn("Error getting merged rendered cookies:",e instanceof Error?e.message:String(e)),""}}var Za,tn=E(()=>{"use strict";vi();gt();As();Ri();Za=Zo});var rh={};_t(rh,{getChromeCookie:()=>th,getCookie:()=>Xa,getFirefoxCookie:()=>eh,getGroupedRenderedCookies:()=>sh,getMergedRenderedCookies:()=>ih});module.exports=ln(rh);var Xa=()=>Promise.resolve().then(()=>(As(),Wo)).then(r=>r.getCookie),th=()=>Promise.resolve().then(()=>(qo(),zo)).then(r=>r.getChromeCookie),eh=()=>Promise.resolve().then(()=>(Qo(),Ho)).then(r=>r.getFirefoxCookie),sh=()=>Promise.resolve().then(()=>(Yo(),Jo)).then(r=>r.getGroupedRenderedCookies),ih=()=>Promise.resolve().then(()=>(tn(),Xo)).then(r=>r.getMergedRenderedCookies);0&&(module.exports={getChromeCookie,getCookie,getFirefoxCookie,getGroupedRenderedCookies,getMergedRenderedCookies});
|
|
1
|
+
"use strict";var ze=Object.create;var T=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var B=(o,e)=>()=>(o&&(e=o(o=0)),e);var K=(o,e)=>{for(var r in e)T(o,r,{get:e[r],enumerable:!0})},X=(o,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $e(e))!Ne.call(o,i)&&i!==r&&T(o,i,{get:()=>e[i],enumerable:!(t=Ae(e,i))||t.enumerable});return o};var O=(o,e,r)=>(r=o!=null?ze(Qe(o)):{},X(e||!o||!o.__esModule?T(r,"default",{value:o,enumerable:!0}):r,o)),Me=o=>X(T({},"__esModule",{value:!0}),o);var Y,ee,P,je,M,oe=B(()=>{"use strict";Y=require("os"),ee=require("dotenv"),P=require("zod");(0,ee.config)();je=P.z.object({LOG_LEVEL:P.z.enum(["debug","info","warn","error"]).default("info"),HOME:P.z.string().optional().transform(o=>o??process.env.USERPROFILE??"").pipe(P.z.string().min(1))}),M=je.parse({LOG_LEVEL:process.env.LOG_LEVEL,HOME:(0,Y.homedir)()})});var re,Ve,ho,m,C=B(()=>{"use strict";re=require("consola");oe();Ve=(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}),ho=M.LOG_LEVEL==="debug",m=Ve});function te(o,e,r){let i=`${e?"\u2705":"\u274C"} ${o} ${e?"succeeded":"failed"}`;e?m.success(i,r):m.error(i,r)}function l(o,e,r){let t={...r??{},error:e instanceof Error?{name:e.name,message:e.message,stack:e.stack}:e};m.error(o,t)}function y(o,e,r){m.withTag(o).debug(e,r)}function ie(o){return m.withTag(o)}function d(o,e,r){m.withTag(o).warn(e,r)}var h=B(()=>{"use strict";C();C()});function so(o,e){if(o instanceof w)throw l("Command execution failed",o,{command:o.command,originalError:o.originalError}),o;if(o instanceof Error){let t=new w(o.message,e,o);throw l("Failed to execute command",o,{command:e,stack:o.stack}),t}let r=new w("Unknown error occurred during command execution",e);throw l("Failed to execute command",null,{error:o,command:e}),r}async function ye(o,e={}){if(!o||typeof o!="string")throw new w("Command must be a non-empty string",o);let r={encoding:"utf8",maxBuffer:5*1024*1024,timeout:3e4};try{let{stdout:t,stderr:i}=await io(o,{...r,...e}),s=t.trim();if(!s)throw i?new w(`Command failed with stderr: ${i}`,o):new w("Command returned empty result",o);return s}catch(t){so(t,o)}}var de,ge,io,w,he=B(()=>{"use strict";de=require("child_process"),ge=require("util");h();io=(0,ge.promisify)(de.exec),w=class extends Error{constructor(r,t,i){super(r);this.command=t;this.originalError=i;this.name="CommandExecutionError"}}});var Ce={};K(Ce,{getChromePassword:()=>ao});var ke,no,ao,we=B(()=>{"use strict";ke=require("lodash-es");he();no=async()=>ye('security find-generic-password -w -s "Chrome Safe Storage"'),ao=(0,ke.memoize)(no)});var lo={};K(lo,{getChromeCookie:()=>G,getCookie:()=>b,getFirefoxCookie:()=>W,getGroupedRenderedCookies:()=>Z,getMergedRenderedCookies:()=>J});module.exports=Me(lo);C();h();var fe=require("fs"),D=require("path"),ce=O(require("fast-glob"),1);h();var se=require("os"),ne=require("path"),E=(()=>{let o=(0,se.homedir)();if(!o)throw new Error("Unable to determine user home directory");return(0,ne.join)(o,"Library","Application Support","Google","Chrome")})();var ae=O(require("better-sqlite3"),1);h();function He(o){try{return new ae.default(o,{readonly:!0,fileMustExist:!0})}catch(e){throw l("Database open failed",e,{file:o}),e}}function Ge(o){try{return o.close(),Promise.resolve()}catch(e){return l("Database close failed",e),Promise.reject(e instanceof Error?e:new Error("Failed to close database: Unknown error"))}}async function I({file:o,sql:e,params:r,rowFilter:t,rowTransform:i}){let s;try{s=He(o);let c=s.prepare(e).all(r),f=t?c.filter(t):c;return i?f.map(i):f}catch(n){throw l("Database query failed",n,{file:o,sql:e}),n}finally{s&&await Ge(s)}}function We(o){if(typeof o!="string")return!1;let e=o.trim();return e.length===0?!1:(0,fe.existsSync)(e)}async function Ze(){let o=[(0,D.join)(E,"Default/Cookies"),(0,D.join)(E,"Profile */Cookies"),(0,D.join)(E,"Profile Default/Cookies")],e=[];for(let r of o){let t=await(0,ce.default)(r);e.push(...t)}return y("ChromeCookies","Found cookie files",{count:e.length,files:e}),e}function Je(o,e){let r=o==="%",t=r?"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=r?[`%${e}%`]:[o,`%${e}%`];return{sql:t,params:i}}async function Ke(o,e,r){try{let{sql:t,params:i}=Je(e,r);y("ChromeCookies","Executing query",{sql:t,params:i});let s=await I({file:o,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:o,count:s.length}),s}catch(t){return l("Failed to read cookie file",t,{file:o}),[]}}async function me({name:o,domain:e,file:r}){let t=typeof r=="string"&&r.length>0?[r]:await Ze();if(t.length===0)return y("ChromeCookies","No cookie files found"),[];let i=[];for(let s of t){if(!We(s)){y("ChromeCookies","Cookie file missing or invalid",{file:s});continue}let n=await Ke(s,o,e);i.push(...n)}return y("ChromeCookies","Query complete",{totalCookies:i.length}),i}var Xe=require("fs"),Ye=require("path"),pe=O(require("fast-glob"),1);C();var eo=m.withTag("listChromeProfiles");function le(){let o=pe.default.sync("./**/Cookies",{cwd:E,absolute:!0});return eo.debug("Found cookie files:",o),o}var _=require("crypto"),j=require("lodash-es"),oo=(0,j.memoize)(o=>o.length>=3&&o[0]===118&&o[1]===49&&o[2]===48?o.slice(3):o,o=>o.toString("hex")),ro=(0,j.memoize)(o=>{let e=o[o.length-1];return e&&e<=16?o.slice(0,-e):o},o=>o.toString("hex"));function to(o){let e=[/.*?0t(.+)$/,/.*?1e`(.+)$/,/.*?[`'](.+)$/,/[^\x20-\x7E]*([\x20-\x7E].+)$/];for(let r of e){let i=o.match(r)?.[1]??"";if(i.length>0)return i}return o}async function ue(o,e){if(typeof e!="string")throw new Error("password must be a string");if(!Buffer.isBuffer(o))throw new Error("encryptedData must be a Buffer");return new Promise((r,t)=>{(0,_.pbkdf2)(e,"saltysalt",1003,16,"sha1",(i,s)=>{try{if(i){t(new Error("Failed to derive key: "+i.message));return}let n=oo(o);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,_.createDecipheriv)("aes-128-cbc",s,c);f.setAutoPadding(!1);let p=f.update(n);try{f.final()}catch(g){t(new Error("Failed to finalize decryption: "+g.message));return}p=ro(p);let u=p.toString("utf8");r(to(u))}catch(n){t(new Error("Decryption failed: "+n.message))}})})}var xe=require("lodash-es");h();var be=(0,xe.memoize)(async()=>{if(process.platform!=="darwin")throw l("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(()=>(we(),Ce)),e=await o();return y("ChromePassword","Retrieved password successfully",{platform:"macOS"}),e}catch(o){throw l("Chrome password retrieval failed",o,{platform:"macOS"}),o}});function fo(o){return typeof o!="number"||o<=0?"Infinity":new Date(o)}function Ee(o,e,r,t,i,s){return{domain:o,name:e,value:r,expiry:fo(t),meta:{file:i,browser:"Chrome",decrypted:s}}}var S=class{constructor(){this.logger=ie("ChromeCookieQueryStrategy");this.browserName="Chrome"}async queryCookies(e,r){try{if(this.logger.info("Querying cookies",{name:e,domain:r}),process.platform!=="darwin")return this.logger.warn("Platform not supported",{platform:process.platform}),[];let t=le();if(t.length===0)return this.logger.warn("No Chrome cookie files found"),[];let i=await be();return(await Promise.all(t.map(n=>this.processFile(n,e,r,i)))).flat()}catch(t){return t instanceof Error?l("Failed to query cookies",t,{name:e,domain:r}):l("Failed to query cookies",new Error(String(t)),{name:e,domain:r}),[]}}async processFile(e,r,t,i){try{let s=await me({name:r,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,r){try{let t=Buffer.isBuffer(e.value)?e.value:Buffer.from(String(e.value)),i=await ue(t,r.password);return Ee(e.domain,e.name,i,e.expiry,r.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)}),Ee(e.domain,e.name,e.value.toString("utf-8"),e.expiry,r.file,!1)}}};var Se=require("os"),V=require("path"),ve=O(require("fast-glob"),1);h();function co(){let o=(0,Se.homedir)();if(!o)return d("FirefoxCookieQuery","Failed to get home directory"),[];let e=[(0,V.join)(o,"Library/Application Support/Firefox/Profiles/*/cookies.sqlite"),(0,V.join)(o,".mozilla/firefox/*/cookies.sqlite")],r=[];for(let t of e){let i=ve.default.sync(t);r.push(...i)}return y("FirefoxCookieQuery","Found Firefox cookie files",{files:r}),r}var v=class{constructor(){this.browserName="Firefox"}async queryCookies(e,r){let t=co(),i=[];for(let s of t)try{let n=await I({file:s,sql:"SELECT name, value, host as domain, expiry FROM moz_cookies WHERE name = ? AND host LIKE ?",params:[e,`%${r}%`],rowTransform:c=>({name:c.name,value:c.value,domain:c.domain,expiry:c.expiry>0?new Date(c.expiry*1e3):"Infinity",meta:{file:s,browser:"Firefox",decrypted:!1}})});i.push(...n)}catch(n){n instanceof Error?d("FirefoxCookieQuery",`Error reading Firefox cookie file ${s}`,{error:n.message}):d("FirefoxCookieQuery",`Error reading Firefox cookie file ${s}`)}return i}};var _e=require("os"),qe=require("path");h();var Fe=require("buffer"),Le=require("fs"),Te=require("os"),Ie=require("path");h();h();var z=require("buffer");var Re=O(require("destr"),1),a=require("zod"),q=a.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"),U=a.z.string().trim().min(1,"Cookie name cannot be empty").refine(o=>o==="%"||/^[!#$%&'()*+\-.:0-9A-Z \^_`a-z|~]+$/.test(o),"Invalid cookie name format - must contain only valid characters (letters, numbers, and certain symbols) or be '%' for wildcard"),Be=a.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("/"),Oe=a.z.string().trim().transform(o=>(0,Re.default)(o)).pipe(a.z.any()),Pe=a.z.object({name:U,value:Oe,domain:q,path:Be,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()}),Zo=a.z.object({name:U,domain:q}).strict(),mo=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:Be.optional()}).catchall(a.z.unknown()).strict(),F=a.z.object({domain:q,name:U,value:Oe,expiry:a.z.union([a.z.literal("Infinity"),a.z.date(),a.z.number().int().positive("Expiry must be a positive number")]).optional(),meta:mo.optional()}).strict(),Jo=a.z.object({expiry:a.z.number().int().optional(),domain:q,name:U,value:a.z.union([a.z.string(),a.z.instanceof(Buffer)])}).strict(),Ko=a.z.object({format:a.z.enum(["merged","grouped"]).optional(),separator:a.z.string().optional(),showFilePaths:a.z.boolean().optional()}).strict(),po=a.z.enum(["Chrome","Firefox","Safari","internal","unknown"]),Xo=a.z.object({browserName:po,queryCookies:a.z.function().args(a.z.string(),a.z.string()).returns(a.z.promise(a.z.array(F)))}).strict();var 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 r={offset:0,buffer:e};this.decode(r)}decodeUrlValue(e){let r=e,t;do{t=r;try{r=decodeURIComponent(r)}catch{return t}}while(r!==t&&r.includes("%"));return r}decodeJwtPayload(e){let r=e.split(".");if(r.length!==3)return null;try{let t=z.Buffer.from(r[1],"base64").toString("utf8"),i=JSON.parse(t);return JSON.stringify(i)}catch{return null}}parseJsonValue(e){try{let r=JSON.parse(e);return JSON.stringify(r)}catch{return null}}processValue(e){let r=this.decodeUrlValue(e);if(r.match(/^ey[A-Za-z0-9_-]+\.ey[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/)){let t=this.decodeJwtPayload(r);if(typeof t=="string"&&t.length>0)return t}if(r.startsWith("{")||r.startsWith("[")){let t=this.parseJsonValue(r);if(typeof t=="string"&&t.length>0)return t}return r}toCookieRow(){try{let e=this.convertFlags(),r=this.url.replace(/^https?:\/\//,"").replace(/\/.*$/,"")||"uk";return Pe.parse({name:this.name.replace(/^: /,""),value:this.processValue(this.value)||"",domain:r,path:this.path||"/",expiry:this.expiration,creation:this.creation,flags:e,version:this.version,port:this.port,comment:this.comment,commentURL:this.commentURL})}catch{return null}}readNullTerminatedString(e,r){let t=r;for(;t<e.buffer.length&&e.buffer[t]!==0;)t++;return e.buffer.toString("utf8",r,t)||""}readHeader(e){let r=e.buffer.readUInt32LE(e.offset);e.offset+=4,e.offset+=4;let t=e.buffer.readUInt32LE(e.offset);e.offset+=4,this.flags={isSecure:(t&1)!==0,isHTTPOnly:(t&4)!==0,unknown1:(t&8)!==0,unknown2:(t&16)!==0};let i=e.buffer.readUInt32LE(e.offset);e.offset+=4;let s={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{size:r,hasPort:i,offsets:s}}readTimestamps(e){let r=z.Buffer.alloc(8);for(let n=0;n<8;n++)r[n]=e.buffer[e.offset+n];let t=r.readDoubleLE(0);e.offset+=8;let i=z.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,r,t){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);for(let n=0;n<s.length;n++){let{field:c,offset:f}=s[n],u=(n<s.length-1?s[n+1].offset:r)-f,g=0+f;for(;g<0+f+u&&e.buffer[g]!==0;)g++;let x=e.buffer.toString("utf8",0+f,g);switch(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:r,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,r,i)}convertFlags(){return(this.flags.isSecure?1:0)|(this.flags.isHTTPOnly?4:0)|(this.flags.unknown1?8:0)|(this.flags.unknown2?16:0)}};var R=class R{constructor(e){this.cookies=[];let r={offset:0,buffer:e};this.decode(r)}toCookieRows(){let e=[];for(let r of this.cookies)try{let t=r.toCookieRow();t!==null&&e.push(t)}catch(t){let i=t instanceof Error?t.message:String(t);d("BinaryCookies","Error converting cookie",{error:i})}return e}decode(e){let r=e.buffer.readUInt32BE(e.offset);if(e.offset+=4,r!==R.HEADER)throw new Error("Invalid page header");let t=e.buffer.readUInt32LE(e.offset);e.offset+=4;let i=e.offset-8,s=[];for(let c=0;c<t;c++){let f=e.buffer.readUInt32LE(e.offset);s.push(f),e.offset+=4}let n=e.buffer.readUInt32BE(e.offset);if(e.offset+=4,n!==R.FOOTER)throw new Error("Invalid page footer");for(let c=0;c<t;c++)try{let f=s[c],p=i+f,u=e.buffer.readUInt32LE(p);if(u<48){d("BinaryCookies",`Invalid cookie size ${u} at index ${c}`);continue}if(p+u>e.buffer.length){d("BinaryCookies",`Cookie size ${u} at index ${c} would exceed buffer length`);continue}let g=e.buffer.subarray(p,p+u),x=new A(g);this.cookies.push(x)}catch(f){let p=f instanceof Error?f.message:String(f);d("BinaryCookies",`Error decoding cookie at index ${c}`,{error:p})}}};R.HEADER=256,R.FOOTER=0;var $=R;var k=class k{constructor(e){let r={offset:0,buffer:e};this.pages=[],this.metadata={},this.decode(r)}static fromFile(e){let r=(0,Le.readFileSync)(e);return new k(r)}static fromDefaultPath(){return k.fromFile(k.DEFAULT_COOKIE_PATH)}toCookieRows(){let e=[];for(let r of this.pages)try{let t=r.toCookieRows();Array.isArray(t)&&e.push(...t)}catch(t){let i=t instanceof Error?t.message:String(t);d("BinaryCookies","Error converting page cookies",{error:i})}return e}decode(e){try{let r=e.buffer.subarray(e.offset,e.offset+4);if(e.offset+=4,!r.equals(k.MAGIC))throw new Error("Missing magic value");let t=e.buffer.readUInt32BE(e.offset);e.offset+=4;let i=[];for(let p=0;p<t;p++)i.push(e.buffer.readUInt32BE(e.offset)),e.offset+=4;let s=e.offset;for(let p of i)try{let u=e.buffer.subarray(s,s+p),g=new $(u);this.pages.push(g),s+=p}catch(u){let g=u instanceof Error?u.message:String(u);d("BinaryCookies","Error decoding page",{error:g}),s+=p}e.offset=s;let n=e.buffer.readUInt32BE(e.offset);e.offset+=4;let c=e.buffer.readBigUInt64BE(e.offset);e.offset+=8,c!==k.FOOTER&&d("BinaryCookies","Invalid cookie file format: wrong footer");let f=e.buffer.subarray(e.offset);this.metadata={}}catch(r){let t=r instanceof Error?r.message:String(r);throw d("BinaryCookies","Error decoding binary cookies file",{error:t}),r}}};k.MAGIC=Fe.Buffer.from("cook","utf8"),k.FOOTER=BigInt("0x071720050000004b"),k.DEFAULT_COOKIE_PATH=(0,Ie.join)((0,Te.homedir)(),"Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies");var Q=k;function De(o){return Q.fromFile(o).toCookieRows()}var N=class{constructor(){this.browserName="Safari"}getCookieDbPath(e){return(0,qe.join)(e,"Library","Containers","com.apple.Safari","Data","Library","Cookies","Cookies.binarycookies")}decodeCookies(e,r,t){try{return De(e).filter(s=>(r==="%"||s.name===r)&&(t==="%"||s.domain.includes(t))).map(s=>({domain:s.domain,name:s.name,value:Buffer.isBuffer(s.value)?s.value.toString():String(s.value),expiry:typeof s.expiry=="number"&&s.expiry>0?new Date(s.expiry*1e3):"Infinity",meta:{file:e,browser:"Safari",decrypted:!1}}))}catch(i){return i instanceof Error?l("SafariCookieQueryStrategy",`Error decoding ${e}`,{error:i,name:r,domain:t}):l("SafariCookieQueryStrategy",`Error decoding ${e}`,{error:"Unknown error",name:r,domain:t}),[]}}async queryCookies(e,r){let t=(0,_e.homedir)();if(typeof t!="string"||t.length===0)return l("SafariCookieQueryStrategy","Failed to get home directory"),Promise.resolve([]);let i=this.getCookieDbPath(t);return Promise.resolve(this.decodeCookies(i,e||"%",r||"%"))}};async function H(o){if(!o.name||!o.domain)return[];let{name:e,domain:r}=o;if(typeof e!="string"||typeof r!="string")return[];let t=[new S,new v,new N];return(await Promise.allSettled(t.map(s=>s.queryCookies(e,r)))).filter(s=>s.status==="fulfilled").flatMap(s=>s.value)}async function b(o){try{return await H(o)}catch(e){return m.warn("Error querying cookies:",e instanceof Error?e.message:String(e)),[]}}C();async function G(o){try{return await new S().queryCookies(o.name,o.domain)}catch(e){return m.warn("Error querying Chrome cookies:",e),[]}}C();async function W(o){try{return await new v().queryCookies(o.name,o.domain)}catch(e){return m.warn("Error querying Firefox cookies:",e instanceof Error?e.message:String(e)),[]}}C();var Ue=require("lodash-es");function L(o,e={}){let{format:r="merged",showFilePaths:t=!0,separator:i="; "}=e;if(o.length===0)return r==="merged"?"":[];if(r==="merged")return o.map(n=>n.value).join(i);let s=(0,Ue.groupBy)(o,n=>n.meta?.file??"unknown");return Object.entries(s).map(([n,c])=>{let f=c.map(p=>p.value).join(i);return t?`${n}: ${f}`:f})}async function Z(o,e={}){try{let r=await b(o);if(!Array.isArray(r))return[];let t=r.filter(i=>{let s=F.safeParse(i);return s.success?!0:(m.warn("Invalid cookie format:",s.error.format()),!1)});return L(t,{...e,format:"grouped"})}catch(r){return m.warn("Error getting grouped rendered cookies:",r instanceof Error?r.message:String(r)),[]}}C();async function J(o,e){try{let r=await b(o);if(!Array.isArray(r))return"";let t=r.filter(s=>{let n=F.safeParse(s);return n.success?!0:(m.warn("Invalid cookie format:",n.error.format()),!1)}),i=L(t,{...e,format:"merged"});return typeof i=="string"?i:""}catch(r){return m.warn("Error getting merged rendered cookies:",r instanceof Error?r.message:String(r)),""}}0&&(module.exports={getChromeCookie,getCookie,getFirefoxCookie,getGroupedRenderedCookies,getMergedRenderedCookies});
|
|
4
2
|
//# sourceMappingURL=index.cjs.map
|