@wallabyjs/cli 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +15 -15
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import t,{basename as n,dirname as r,join as i,parse as a,posix as o,resolve as s}from"node:path";import c,{homedir as l,tmpdir as u}from"node:os";import d,{createWriteStream as f,existsSync as p,mkdirSync as m,readFileSync as h,readdirSync as g}from"node:fs";import{fileURLToPath as _}from"node:url";import v,{constants as y,mkdir as b,readdir as x,rename as S,rm as C,stat as w,unlink as T,writeFile as E}from"node:fs/promises";import{Writable as D}from"node:stream";import O,{
|
|
2
|
-
GFS4: `),console.error(e)}),n[s]||(u(n,global[s]||[]),n.close=(function(e){function t(t,r){return e.call(n,t,function(e){e||h(),typeof r==`function`&&r.apply(this,arguments)})}return Object.defineProperty(t,c,{value:e}),t})(n.close),n.closeSync=(function(e){function t(t){e.apply(n,arguments),h()}return Object.defineProperty(t,c,{value:e}),t})(n.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&process.on(`exit`,function(){d(n[s]),B(`assert`).equal(n[s].length,0)})),global[s]||u(global,n[s]),t.exports=f(a(n)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!n.__patched&&(t.exports=f(n),n.__patched=!0);function f(e){r(e),e.gracefulify=f,e.createReadStream=T,e.createWriteStream=E;var t=e.readFile;e.readFile=n;function n(e,n,r){return typeof n==`function`&&(r=n,n=null),i(e,n,r);function i(e,n,r,a){return t(e,n,function(t){t&&(t.code===`EMFILE`||t.code===`ENFILE`)?p([i,[e,n,r],t,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var a=e.writeFile;e.writeFile=o;function o(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,o){return a(e,t,n,function(a){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?p([i,[e,t,n,r],a,o||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var s=e.appendFile;s&&(e.appendFile=c);function c(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return s(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?p([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var l=e.copyFile;l&&(e.copyFile=u);function u(e,t,n,r){return typeof n==`function`&&(r=n,n=0),i(e,t,n,r);function i(e,t,n,r,a){return l(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?p([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var d=e.readdir;e.readdir=h;var m=/^v[0-5]\./;function h(e,t,n){typeof t==`function`&&(n=t,t=null);var r=m.test(process.version)?function(e,t,n,r){return d(e,i(e,t,n,r))}:function(e,t,n,r){return d(e,t,i(e,t,n,r))};return r(e,t,n);function i(e,t,n,i){return function(a,o){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?p([r,[e,t,n],a,i||Date.now(),Date.now()]):(o&&o.sort&&o.sort(),typeof n==`function`&&n.call(this,a,o))}}}if(process.version.substr(0,4)===`v0.8`){var g=i(e);x=g.ReadStream,C=g.WriteStream}var _=e.ReadStream;_&&(x.prototype=Object.create(_.prototype),x.prototype.open=S);var v=e.WriteStream;v&&(C.prototype=Object.create(v.prototype),C.prototype.open=w),Object.defineProperty(e,`ReadStream`,{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,`WriteStream`,{get:function(){return C},set:function(e){C=e},enumerable:!0,configurable:!0});var y=x;Object.defineProperty(e,`FileReadStream`,{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var b=C;Object.defineProperty(e,`FileWriteStream`,{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0});function x(e,t){return this instanceof x?(_.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function S(){var e=this;O(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function C(e,t){return this instanceof C?(v.apply(this,arguments),this):C.apply(Object.create(C.prototype),arguments)}function w(){var e=this;O(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function T(t,n){return new e.ReadStream(t,n)}function E(t,n){return new e.WriteStream(t,n)}var D=e.open;e.open=O;function O(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return D(e,t,n,function(o,s){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?p([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}return e}function p(e){d(`ENQUEUE`,e[0].name,e[1]),n[s].push(e),g()}var m;function h(){for(var e=Date.now(),t=0;t<n[s].length;++t)n[s][t].length>2&&(n[s][t][3]=e,n[s][t][4]=e);g()}function g(){if(clearTimeout(m),m=void 0,n[s].length!==0){var e=n[s].shift(),t=e[0],r=e[1],i=e[2],a=e[3],o=e[4];if(a===void 0)d(`RETRY`,t.name,r),t.apply(null,r);else if(Date.now()-a>=6e4){d(`TIMEOUT`,t.name,r);var c=r.pop();typeof c==`function`&&c.call(null,i)}else{var l=Date.now()-o,u=Math.max(o-a,1);l>=Math.min(u*1.2,100)?(d(`RETRY`,t.name,r),t.apply(null,r.concat([a]))):n[s].push(e)}m===void 0&&(m=setTimeout(g,0))}}})),H=z((e=>{let t=V().fromCallback,n=pe(),r=`access.appendFile.chmod.chown.close.copyFile.cp.fchmod.fchown.fdatasync.fstat.fsync.ftruncate.futimes.glob.lchmod.lchown.lutimes.link.lstat.mkdir.mkdtemp.open.opendir.readdir.readFile.readlink.realpath.rename.rm.rmdir.stat.statfs.symlink.truncate.unlink.utimes.writeFile`.split(`.`).filter(e=>typeof n[e]==`function`);Object.assign(e,n),r.forEach(r=>{e[r]=t(n[r])}),e.exists=function(e,t){return typeof t==`function`?n.exists(e,t):new Promise(t=>n.exists(e,t))},e.read=function(e,t,r,i,a,o){return typeof o==`function`?n.read(e,t,r,i,a,o):new Promise((o,s)=>{n.read(e,t,r,i,a,(e,t,n)=>{if(e)return s(e);o({bytesRead:t,buffer:n})})})},e.write=function(e,t,...r){return typeof r[r.length-1]==`function`?n.write(e,t,...r):new Promise((i,a)=>{n.write(e,t,...r,(e,t,n)=>{if(e)return a(e);i({bytesWritten:t,buffer:n})})})},e.readv=function(e,t,...r){return typeof r[r.length-1]==`function`?n.readv(e,t,...r):new Promise((i,a)=>{n.readv(e,t,...r,(e,t,n)=>{if(e)return a(e);i({bytesRead:t,buffers:n})})})},e.writev=function(e,t,...r){return typeof r[r.length-1]==`function`?n.writev(e,t,...r):new Promise((i,a)=>{n.writev(e,t,...r,(e,t,n)=>{if(e)return a(e);i({bytesWritten:t,buffers:n})})})},typeof n.realpath.native==`function`?e.realpath.native=t(n.realpath.native):process.emitWarning(`fs.realpath.native is not a function. Is fs being monkey-patched?`,`Warning`,`fs-extra-WARN0003`)})),me=z(((e,t)=>{let n=B(`path`);t.exports.checkPath=function(e){if(process.platform===`win32`&&/[<>:"|?*]/.test(e.replace(n.parse(e).root,``))){let t=Error(`Path contains invalid characters: ${e}`);throw t.code=`EINVAL`,t}}})),he=z(((e,t)=>{let n=H(),{checkPath:r}=me(),i=e=>typeof e==`number`?e:{mode:511,...e}.mode;t.exports.makeDir=async(e,t)=>(r(e),n.mkdir(e,{mode:i(t),recursive:!0})),t.exports.makeDirSync=(e,t)=>(r(e),n.mkdirSync(e,{mode:i(t),recursive:!0}))})),U=z(((e,t)=>{let n=V().fromPromise,{makeDir:r,makeDirSync:i}=he(),a=n(r);t.exports={mkdirs:a,mkdirsSync:i,mkdirp:a,mkdirpSync:i,ensureDir:a,ensureDirSync:i}})),ge=z(((e,t)=>{let n=V().fromPromise,r=H();function i(e){return r.access(e).then(()=>!0).catch(()=>!1)}t.exports={pathExists:n(i),pathExistsSync:r.existsSync}})),_e=z(((e,t)=>{let n=H(),r=V().fromPromise;async function i(e,t,r){let i=await n.open(e,`r+`),a=null;try{await n.futimes(i,t,r)}finally{try{await n.close(i)}catch(e){a=e}}if(a)throw a}function a(e,t,r){let i=n.openSync(e,`r+`);return n.futimesSync(i,t,r),n.closeSync(i)}t.exports={utimesMillis:r(i),utimesMillisSync:a}})),ve=z(((e,t)=>{let n=H(),r=B(`path`),i=V().fromPromise;function a(e,t,r){let i=r.dereference?e=>n.stat(e,{bigint:!0}):e=>n.lstat(e,{bigint:!0});return Promise.all([i(e),i(t).catch(e=>{if(e.code===`ENOENT`)return null;throw e})]).then(([e,t])=>({srcStat:e,destStat:t}))}function o(e,t,r){let i,a=r.dereference?e=>n.statSync(e,{bigint:!0}):e=>n.lstatSync(e,{bigint:!0}),o=a(e);try{i=a(t)}catch(e){if(e.code===`ENOENT`)return{srcStat:o,destStat:null};throw e}return{srcStat:o,destStat:i}}async function s(e,t,n,i){let{srcStat:o,destStat:s}=await a(e,t,i);if(s){if(d(o,s)){let i=r.basename(e),a=r.basename(t);if(n===`move`&&i!==a&&i.toLowerCase()===a.toLowerCase())return{srcStat:o,destStat:s,isChangingCase:!0};throw Error(`Source and destination must not be the same.`)}if(o.isDirectory()&&!s.isDirectory())throw Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!o.isDirectory()&&s.isDirectory())throw Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(o.isDirectory()&&f(e,t))throw Error(p(e,t,n));return{srcStat:o,destStat:s}}function c(e,t,n,i){let{srcStat:a,destStat:s}=o(e,t,i);if(s){if(d(a,s)){let i=r.basename(e),o=r.basename(t);if(n===`move`&&i!==o&&i.toLowerCase()===o.toLowerCase())return{srcStat:a,destStat:s,isChangingCase:!0};throw Error(`Source and destination must not be the same.`)}if(a.isDirectory()&&!s.isDirectory())throw Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!a.isDirectory()&&s.isDirectory())throw Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(a.isDirectory()&&f(e,t))throw Error(p(e,t,n));return{srcStat:a,destStat:s}}async function l(e,t,i,a){let o=r.resolve(r.dirname(e)),s=r.resolve(r.dirname(i));if(s===o||s===r.parse(s).root)return;let c;try{c=await n.stat(s,{bigint:!0})}catch(e){if(e.code===`ENOENT`)return;throw e}if(d(t,c))throw Error(p(e,i,a));return l(e,t,s,a)}function u(e,t,i,a){let o=r.resolve(r.dirname(e)),s=r.resolve(r.dirname(i));if(s===o||s===r.parse(s).root)return;let c;try{c=n.statSync(s,{bigint:!0})}catch(e){if(e.code===`ENOENT`)return;throw e}if(d(t,c))throw Error(p(e,i,a));return u(e,t,s,a)}function d(e,t){return t.ino!==void 0&&t.dev!==void 0&&t.ino===e.ino&&t.dev===e.dev}function f(e,t){let n=r.resolve(e).split(r.sep).filter(e=>e),i=r.resolve(t).split(r.sep).filter(e=>e);return n.every((e,t)=>i[t]===e)}function p(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}t.exports={checkPaths:i(s),checkPathsSync:c,checkParentPaths:i(l),checkParentPathsSync:u,isSrcSubdir:f,areIdentical:d}})),ye=z(((e,t)=>{async function n(e,t){let n=[];for await(let r of e)n.push(t(r).then(()=>null,e=>e??Error(`unknown error`)));await Promise.all(n.map(e=>e.then(e=>{if(e!==null)throw e})))}t.exports={asyncIteratorConcurrentProcess:n}})),be=z(((e,t)=>{let n=H(),r=B(`path`),{mkdirs:i}=U(),{pathExists:a}=ge(),{utimesMillis:o}=_e(),s=ve(),{asyncIteratorConcurrentProcess:c}=ye();async function l(e,t,n={}){typeof n==`function`&&(n={filter:n}),n.clobber=`clobber`in n?!!n.clobber:!0,n.overwrite=`overwrite`in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&process.arch===`ia32`&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
1
|
+
import{createRequire as e}from"node:module";import t,{basename as n,dirname as r,join as i,parse as a,posix as o,resolve as s}from"node:path";import c,{homedir as l,tmpdir as u}from"node:os";import d,{createWriteStream as f,existsSync as p,mkdirSync as m,readFileSync as h,readdirSync as g}from"node:fs";import{fileURLToPath as _}from"node:url";import v,{constants as y,mkdir as b,readdir as x,rename as S,rm as C,stat as w,unlink as T,writeFile as E}from"node:fs/promises";import{Writable as D}from"node:stream";import O,{randomUUID as k}from"node:crypto";import A,{cwd as j}from"node:process";import{Agent as M}from"node:https";import N,{exec as P,execFile as ee,spawn as F}from"node:child_process";import{format as te,promisify as ne}from"node:util";import{Buffer as I}from"node:buffer";var re=Object.create,ie=Object.defineProperty,ae=Object.getOwnPropertyDescriptor,oe=Object.getOwnPropertyNames,se=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty,L=(e,t)=>()=>(e&&(t=e(e=0)),t),R=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),le=(e,t)=>{let n={};for(var r in e)ie(n,r,{get:e[r],enumerable:!0});return t||ie(n,Symbol.toStringTag,{value:`Module`}),n},ue=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=oe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!ce.call(e,s)&&s!==n&&ie(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ae(t,s))||r.enumerable});return e},z=(e,t,n)=>(n=e==null?{}:re(se(e)),ue(t||!e||!e.__esModule?ie(n,`default`,{value:e,enumerable:!0}):n,e)),B=e(import.meta.url),V=R((e=>{e.fromCallback=function(e){return Object.defineProperty(function(...t){if(typeof t[t.length-1]==`function`)e.apply(this,t);else return new Promise((n,r)=>{t.push((e,t)=>e==null?n(t):r(e)),e.apply(this,t)})},`name`,{value:e.name})},e.fromPromise=function(e){return Object.defineProperty(function(...t){let n=t[t.length-1];if(typeof n!=`function`)return e.apply(this,t);t.pop(),e.apply(this,t).then(e=>n(null,e),n)},`name`,{value:e.name})}})),de=R(((e,t)=>{var n=B(`constants`),r=process.cwd,i=null,a=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return i||=r.call(process),i};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var o=process.chdir;process.chdir=function(e){i=null,o.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,o)}t.exports=s;function s(e){n.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=o(e.chmodSync),e.fchmodSync=o(e.fchmodSync),e.lchmodSync=o(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),a===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,r,i){e.open(t,n.O_WRONLY|n.O_SYMLINK,r,function(t,n){if(t){i&&i(t);return}e.fchmod(n,r,function(t){e.close(n,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,r){var i=e.openSync(t,n.O_WRONLY|n.O_SYMLINK,r),a=!0,o;try{o=e.fchmodSync(i,r),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function r(e){n.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,r,i,a){e.open(t,n.O_SYMLINK,function(t,n){if(t){a&&a(t);return}e.futimes(n,r,i,function(t){e.close(n,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,r,i){var a=e.openSync(t,n.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,r,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function o(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),fe=R(((e,t)=>{var n=B(`stream`).Stream;t.exports=r;function r(e){return{ReadStream:t,WriteStream:r};function t(r,i){if(!(this instanceof t))return new t(r,i);n.call(this);var a=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=64*1024,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function r(t,i){if(!(this instanceof r))return new r(t,i);n.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),pe=R(((e,t)=>{t.exports=r;var n=Object.getPrototypeOf||function(e){return e.__proto__};function r(e){if(typeof e!=`object`||!e)return e;if(e instanceof Object)var t={__proto__:n(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}})),H=R(((e,t)=>{var n=B(`fs`),r=de(),i=fe(),a=pe(),o=B(`util`),s,c;typeof Symbol==`function`&&typeof Symbol.for==`function`?(s=Symbol.for(`graceful-fs.queue`),c=Symbol.for(`graceful-fs.previous`)):(s=`___graceful-fs.queue`,c=`___graceful-fs.previous`);function l(){}function u(e,t){Object.defineProperty(e,s,{get:function(){return t}})}var d=l;o.debuglog?d=o.debuglog(`gfs4`):/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&(d=function(){var e=o.format.apply(o,arguments);e=`GFS4: `+e.split(/\n/).join(`
|
|
2
|
+
GFS4: `),console.error(e)}),n[s]||(u(n,global[s]||[]),n.close=(function(e){function t(t,r){return e.call(n,t,function(e){e||h(),typeof r==`function`&&r.apply(this,arguments)})}return Object.defineProperty(t,c,{value:e}),t})(n.close),n.closeSync=(function(e){function t(t){e.apply(n,arguments),h()}return Object.defineProperty(t,c,{value:e}),t})(n.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&process.on(`exit`,function(){d(n[s]),B(`assert`).equal(n[s].length,0)})),global[s]||u(global,n[s]),t.exports=f(a(n)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!n.__patched&&(t.exports=f(n),n.__patched=!0);function f(e){r(e),e.gracefulify=f,e.createReadStream=T,e.createWriteStream=E;var t=e.readFile;e.readFile=n;function n(e,n,r){return typeof n==`function`&&(r=n,n=null),i(e,n,r);function i(e,n,r,a){return t(e,n,function(t){t&&(t.code===`EMFILE`||t.code===`ENFILE`)?p([i,[e,n,r],t,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var a=e.writeFile;e.writeFile=o;function o(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,o){return a(e,t,n,function(a){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?p([i,[e,t,n,r],a,o||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var s=e.appendFile;s&&(e.appendFile=c);function c(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return s(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?p([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var l=e.copyFile;l&&(e.copyFile=u);function u(e,t,n,r){return typeof n==`function`&&(r=n,n=0),i(e,t,n,r);function i(e,t,n,r,a){return l(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?p([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var d=e.readdir;e.readdir=h;var m=/^v[0-5]\./;function h(e,t,n){typeof t==`function`&&(n=t,t=null);var r=m.test(process.version)?function(e,t,n,r){return d(e,i(e,t,n,r))}:function(e,t,n,r){return d(e,t,i(e,t,n,r))};return r(e,t,n);function i(e,t,n,i){return function(a,o){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?p([r,[e,t,n],a,i||Date.now(),Date.now()]):(o&&o.sort&&o.sort(),typeof n==`function`&&n.call(this,a,o))}}}if(process.version.substr(0,4)===`v0.8`){var g=i(e);x=g.ReadStream,C=g.WriteStream}var _=e.ReadStream;_&&(x.prototype=Object.create(_.prototype),x.prototype.open=S);var v=e.WriteStream;v&&(C.prototype=Object.create(v.prototype),C.prototype.open=w),Object.defineProperty(e,`ReadStream`,{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,`WriteStream`,{get:function(){return C},set:function(e){C=e},enumerable:!0,configurable:!0});var y=x;Object.defineProperty(e,`FileReadStream`,{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var b=C;Object.defineProperty(e,`FileWriteStream`,{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0});function x(e,t){return this instanceof x?(_.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function S(){var e=this;O(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function C(e,t){return this instanceof C?(v.apply(this,arguments),this):C.apply(Object.create(C.prototype),arguments)}function w(){var e=this;O(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function T(t,n){return new e.ReadStream(t,n)}function E(t,n){return new e.WriteStream(t,n)}var D=e.open;e.open=O;function O(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return D(e,t,n,function(o,s){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?p([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}return e}function p(e){d(`ENQUEUE`,e[0].name,e[1]),n[s].push(e),g()}var m;function h(){for(var e=Date.now(),t=0;t<n[s].length;++t)n[s][t].length>2&&(n[s][t][3]=e,n[s][t][4]=e);g()}function g(){if(clearTimeout(m),m=void 0,n[s].length!==0){var e=n[s].shift(),t=e[0],r=e[1],i=e[2],a=e[3],o=e[4];if(a===void 0)d(`RETRY`,t.name,r),t.apply(null,r);else if(Date.now()-a>=6e4){d(`TIMEOUT`,t.name,r);var c=r.pop();typeof c==`function`&&c.call(null,i)}else{var l=Date.now()-o,u=Math.max(o-a,1);l>=Math.min(u*1.2,100)?(d(`RETRY`,t.name,r),t.apply(null,r.concat([a]))):n[s].push(e)}m===void 0&&(m=setTimeout(g,0))}}})),U=R((e=>{let t=V().fromCallback,n=H(),r=`access.appendFile.chmod.chown.close.copyFile.cp.fchmod.fchown.fdatasync.fstat.fsync.ftruncate.futimes.glob.lchmod.lchown.lutimes.link.lstat.mkdir.mkdtemp.open.opendir.readdir.readFile.readlink.realpath.rename.rm.rmdir.stat.statfs.symlink.truncate.unlink.utimes.writeFile`.split(`.`).filter(e=>typeof n[e]==`function`);Object.assign(e,n),r.forEach(r=>{e[r]=t(n[r])}),e.exists=function(e,t){return typeof t==`function`?n.exists(e,t):new Promise(t=>n.exists(e,t))},e.read=function(e,t,r,i,a,o){return typeof o==`function`?n.read(e,t,r,i,a,o):new Promise((o,s)=>{n.read(e,t,r,i,a,(e,t,n)=>{if(e)return s(e);o({bytesRead:t,buffer:n})})})},e.write=function(e,t,...r){return typeof r[r.length-1]==`function`?n.write(e,t,...r):new Promise((i,a)=>{n.write(e,t,...r,(e,t,n)=>{if(e)return a(e);i({bytesWritten:t,buffer:n})})})},e.readv=function(e,t,...r){return typeof r[r.length-1]==`function`?n.readv(e,t,...r):new Promise((i,a)=>{n.readv(e,t,...r,(e,t,n)=>{if(e)return a(e);i({bytesRead:t,buffers:n})})})},e.writev=function(e,t,...r){return typeof r[r.length-1]==`function`?n.writev(e,t,...r):new Promise((i,a)=>{n.writev(e,t,...r,(e,t,n)=>{if(e)return a(e);i({bytesWritten:t,buffers:n})})})},typeof n.realpath.native==`function`?e.realpath.native=t(n.realpath.native):process.emitWarning(`fs.realpath.native is not a function. Is fs being monkey-patched?`,`Warning`,`fs-extra-WARN0003`)})),me=R(((e,t)=>{let n=B(`path`);t.exports.checkPath=function(e){if(process.platform===`win32`&&/[<>:"|?*]/.test(e.replace(n.parse(e).root,``))){let t=Error(`Path contains invalid characters: ${e}`);throw t.code=`EINVAL`,t}}})),he=R(((e,t)=>{let n=U(),{checkPath:r}=me(),i=e=>typeof e==`number`?e:{mode:511,...e}.mode;t.exports.makeDir=async(e,t)=>(r(e),n.mkdir(e,{mode:i(t),recursive:!0})),t.exports.makeDirSync=(e,t)=>(r(e),n.mkdirSync(e,{mode:i(t),recursive:!0}))})),W=R(((e,t)=>{let n=V().fromPromise,{makeDir:r,makeDirSync:i}=he(),a=n(r);t.exports={mkdirs:a,mkdirsSync:i,mkdirp:a,mkdirpSync:i,ensureDir:a,ensureDirSync:i}})),ge=R(((e,t)=>{let n=V().fromPromise,r=U();function i(e){return r.access(e).then(()=>!0).catch(()=>!1)}t.exports={pathExists:n(i),pathExistsSync:r.existsSync}})),_e=R(((e,t)=>{let n=U(),r=V().fromPromise;async function i(e,t,r){let i=await n.open(e,`r+`),a=null;try{await n.futimes(i,t,r)}finally{try{await n.close(i)}catch(e){a=e}}if(a)throw a}function a(e,t,r){let i=n.openSync(e,`r+`);return n.futimesSync(i,t,r),n.closeSync(i)}t.exports={utimesMillis:r(i),utimesMillisSync:a}})),ve=R(((e,t)=>{let n=U(),r=B(`path`),i=V().fromPromise;function a(e,t,r){let i=r.dereference?e=>n.stat(e,{bigint:!0}):e=>n.lstat(e,{bigint:!0});return Promise.all([i(e),i(t).catch(e=>{if(e.code===`ENOENT`)return null;throw e})]).then(([e,t])=>({srcStat:e,destStat:t}))}function o(e,t,r){let i,a=r.dereference?e=>n.statSync(e,{bigint:!0}):e=>n.lstatSync(e,{bigint:!0}),o=a(e);try{i=a(t)}catch(e){if(e.code===`ENOENT`)return{srcStat:o,destStat:null};throw e}return{srcStat:o,destStat:i}}async function s(e,t,n,i){let{srcStat:o,destStat:s}=await a(e,t,i);if(s){if(d(o,s)){let i=r.basename(e),a=r.basename(t);if(n===`move`&&i!==a&&i.toLowerCase()===a.toLowerCase())return{srcStat:o,destStat:s,isChangingCase:!0};throw Error(`Source and destination must not be the same.`)}if(o.isDirectory()&&!s.isDirectory())throw Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!o.isDirectory()&&s.isDirectory())throw Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(o.isDirectory()&&f(e,t))throw Error(p(e,t,n));return{srcStat:o,destStat:s}}function c(e,t,n,i){let{srcStat:a,destStat:s}=o(e,t,i);if(s){if(d(a,s)){let i=r.basename(e),o=r.basename(t);if(n===`move`&&i!==o&&i.toLowerCase()===o.toLowerCase())return{srcStat:a,destStat:s,isChangingCase:!0};throw Error(`Source and destination must not be the same.`)}if(a.isDirectory()&&!s.isDirectory())throw Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!a.isDirectory()&&s.isDirectory())throw Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(a.isDirectory()&&f(e,t))throw Error(p(e,t,n));return{srcStat:a,destStat:s}}async function l(e,t,i,a){let o=r.resolve(r.dirname(e)),s=r.resolve(r.dirname(i));if(s===o||s===r.parse(s).root)return;let c;try{c=await n.stat(s,{bigint:!0})}catch(e){if(e.code===`ENOENT`)return;throw e}if(d(t,c))throw Error(p(e,i,a));return l(e,t,s,a)}function u(e,t,i,a){let o=r.resolve(r.dirname(e)),s=r.resolve(r.dirname(i));if(s===o||s===r.parse(s).root)return;let c;try{c=n.statSync(s,{bigint:!0})}catch(e){if(e.code===`ENOENT`)return;throw e}if(d(t,c))throw Error(p(e,i,a));return u(e,t,s,a)}function d(e,t){return t.ino!==void 0&&t.dev!==void 0&&t.ino===e.ino&&t.dev===e.dev}function f(e,t){let n=r.resolve(e).split(r.sep).filter(e=>e),i=r.resolve(t).split(r.sep).filter(e=>e);return n.every((e,t)=>i[t]===e)}function p(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}t.exports={checkPaths:i(s),checkPathsSync:c,checkParentPaths:i(l),checkParentPathsSync:u,isSrcSubdir:f,areIdentical:d}})),ye=R(((e,t)=>{async function n(e,t){let n=[];for await(let r of e)n.push(t(r).then(()=>null,e=>e??Error(`unknown error`)));await Promise.all(n.map(e=>e.then(e=>{if(e!==null)throw e})))}t.exports={asyncIteratorConcurrentProcess:n}})),be=R(((e,t)=>{let n=U(),r=B(`path`),{mkdirs:i}=W(),{pathExists:a}=ge(),{utimesMillis:o}=_e(),s=ve(),{asyncIteratorConcurrentProcess:c}=ye();async function l(e,t,n={}){typeof n==`function`&&(n={filter:n}),n.clobber=`clobber`in n?!!n.clobber:!0,n.overwrite=`overwrite`in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&process.arch===`ia32`&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
3
3
|
|
|
4
|
-
see https://github.com/jprichardson/node-fs-extra/issues/269`,`Warning`,`fs-extra-WARN0001`);let{srcStat:o,destStat:c}=await s.checkPaths(e,t,`copy`,n);if(await s.checkParentPaths(e,o,t,`copy`),!await u(e,t,n))return;let l=r.dirname(t);await a(l)||await i(l),await d(c,e,t,n)}async function u(e,t,n){return n.filter?n.filter(e,t):!0}async function d(e,t,r,i){let a=await(i.dereference?n.stat:n.lstat)(t);if(a.isDirectory())return g(a,e,t,r,i);if(a.isFile()||a.isCharacterDevice()||a.isBlockDevice())return f(a,e,t,r,i);if(a.isSymbolicLink())return _(e,t,r,i);throw a.isSocket()?Error(`Cannot copy a socket file: ${t}`):a.isFIFO()?Error(`Cannot copy a FIFO pipe: ${t}`):Error(`Unknown file: ${t}`)}async function f(e,t,r,i,a){if(!t)return p(e,r,i,a);if(a.overwrite)return await n.unlink(i),p(e,r,i,a);if(a.errorOnExist)throw Error(`'${i}' already exists`)}async function p(e,t,r,i){if(await n.copyFile(t,r),i.preserveTimestamps){m(e.mode)&&await h(r,e.mode);let i=await n.stat(t);await o(r,i.atime,i.mtime)}return n.chmod(r,e.mode)}function m(e){return(e&128)==0}function h(e,t){return n.chmod(e,t|128)}async function g(e,t,i,a,o){t||await n.mkdir(a),await c(await n.opendir(i),async e=>{let t=r.join(i,e.name),n=r.join(a,e.name);if(await u(t,n,o)){let{destStat:e}=await s.checkPaths(t,n,`copy`,o);await d(e,t,n,o)}}),t||await n.chmod(a,e.mode)}async function _(e,t,i,a){let o=await n.readlink(t);if(a.dereference&&(o=r.resolve(process.cwd(),o)),!e)return n.symlink(o,i);let c=null;try{c=await n.readlink(i)}catch(e){if(e.code===`EINVAL`||e.code===`UNKNOWN`)return n.symlink(o,i);throw e}if(a.dereference&&(c=r.resolve(process.cwd(),c)),o!==c){if(s.isSrcSubdir(o,c))throw Error(`Cannot copy '${o}' to a subdirectory of itself, '${c}'.`);if(s.isSrcSubdir(c,o))throw Error(`Cannot overwrite '${c}' with '${o}'.`)}return await n.unlink(i),n.symlink(o,i)}t.exports=l})),xe=
|
|
4
|
+
see https://github.com/jprichardson/node-fs-extra/issues/269`,`Warning`,`fs-extra-WARN0001`);let{srcStat:o,destStat:c}=await s.checkPaths(e,t,`copy`,n);if(await s.checkParentPaths(e,o,t,`copy`),!await u(e,t,n))return;let l=r.dirname(t);await a(l)||await i(l),await d(c,e,t,n)}async function u(e,t,n){return n.filter?n.filter(e,t):!0}async function d(e,t,r,i){let a=await(i.dereference?n.stat:n.lstat)(t);if(a.isDirectory())return g(a,e,t,r,i);if(a.isFile()||a.isCharacterDevice()||a.isBlockDevice())return f(a,e,t,r,i);if(a.isSymbolicLink())return _(e,t,r,i);throw a.isSocket()?Error(`Cannot copy a socket file: ${t}`):a.isFIFO()?Error(`Cannot copy a FIFO pipe: ${t}`):Error(`Unknown file: ${t}`)}async function f(e,t,r,i,a){if(!t)return p(e,r,i,a);if(a.overwrite)return await n.unlink(i),p(e,r,i,a);if(a.errorOnExist)throw Error(`'${i}' already exists`)}async function p(e,t,r,i){if(await n.copyFile(t,r),i.preserveTimestamps){m(e.mode)&&await h(r,e.mode);let i=await n.stat(t);await o(r,i.atime,i.mtime)}return n.chmod(r,e.mode)}function m(e){return(e&128)==0}function h(e,t){return n.chmod(e,t|128)}async function g(e,t,i,a,o){t||await n.mkdir(a),await c(await n.opendir(i),async e=>{let t=r.join(i,e.name),n=r.join(a,e.name);if(await u(t,n,o)){let{destStat:e}=await s.checkPaths(t,n,`copy`,o);await d(e,t,n,o)}}),t||await n.chmod(a,e.mode)}async function _(e,t,i,a){let o=await n.readlink(t);if(a.dereference&&(o=r.resolve(process.cwd(),o)),!e)return n.symlink(o,i);let c=null;try{c=await n.readlink(i)}catch(e){if(e.code===`EINVAL`||e.code===`UNKNOWN`)return n.symlink(o,i);throw e}if(a.dereference&&(c=r.resolve(process.cwd(),c)),o!==c){if(s.isSrcSubdir(o,c))throw Error(`Cannot copy '${o}' to a subdirectory of itself, '${c}'.`);if(s.isSrcSubdir(c,o))throw Error(`Cannot overwrite '${c}' with '${o}'.`)}return await n.unlink(i),n.symlink(o,i)}t.exports=l})),xe=R(((e,t)=>{let n=H(),r=B(`path`),i=W().mkdirsSync,a=_e().utimesMillisSync,o=ve();function s(e,t,a){typeof a==`function`&&(a={filter:a}),a||={},a.clobber=`clobber`in a?!!a.clobber:!0,a.overwrite=`overwrite`in a?!!a.overwrite:a.clobber,a.preserveTimestamps&&process.arch===`ia32`&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
5
5
|
|
|
6
|
-
see https://github.com/jprichardson/node-fs-extra/issues/269`,`Warning`,`fs-extra-WARN0002`);let{srcStat:s,destStat:l}=o.checkPathsSync(e,t,`copy`,a);if(o.checkParentPathsSync(e,s,t,`copy`),a.filter&&!a.filter(e,t))return;let u=r.dirname(t);return n.existsSync(u)||i(u),c(l,e,t,a)}function c(e,t,r,i){let a=(i.dereference?n.statSync:n.lstatSync)(t);if(a.isDirectory())return _(a,e,t,r,i);if(a.isFile()||a.isCharacterDevice()||a.isBlockDevice())return l(a,e,t,r,i);if(a.isSymbolicLink())return x(e,t,r,i);throw a.isSocket()?Error(`Cannot copy a socket file: ${t}`):a.isFIFO()?Error(`Cannot copy a FIFO pipe: ${t}`):Error(`Unknown file: ${t}`)}function l(e,t,n,r,i){return t?u(e,n,r,i):d(e,n,r,i)}function u(e,t,r,i){if(i.overwrite)return n.unlinkSync(r),d(e,t,r,i);if(i.errorOnExist)throw Error(`'${r}' already exists`)}function d(e,t,r,i){return n.copyFileSync(t,r),i.preserveTimestamps&&f(e.mode,t,r),h(r,e.mode)}function f(e,t,n){return p(e)&&m(n,e),g(t,n)}function p(e){return(e&128)==0}function m(e,t){return h(e,t|128)}function h(e,t){return n.chmodSync(e,t)}function g(e,t){let r=n.statSync(e);return a(t,r.atime,r.mtime)}function _(e,t,n,r,i){return t?y(n,r,i):v(e.mode,n,r,i)}function v(e,t,r,i){return n.mkdirSync(r),y(t,r,i),h(r,e)}function y(e,t,r){let i=n.opendirSync(e);try{let n;for(;(n=i.readSync())!==null;)b(n.name,e,t,r)}finally{i.closeSync()}}function b(e,t,n,i){let a=r.join(t,e),s=r.join(n,e);if(i.filter&&!i.filter(a,s))return;let{destStat:l}=o.checkPathsSync(a,s,`copy`,i);return c(l,a,s,i)}function x(e,t,i,a){let s=n.readlinkSync(t);if(a.dereference&&(s=r.resolve(process.cwd(),s)),e){let e;try{e=n.readlinkSync(i)}catch(e){if(e.code===`EINVAL`||e.code===`UNKNOWN`)return n.symlinkSync(s,i);throw e}if(a.dereference&&(e=r.resolve(process.cwd(),e)),s!==e){if(o.isSrcSubdir(s,e))throw Error(`Cannot copy '${s}' to a subdirectory of itself, '${e}'.`);if(o.isSrcSubdir(e,s))throw Error(`Cannot overwrite '${e}' with '${s}'.`)}return S(s,i)}else return n.symlinkSync(s,i)}function S(e,t){return n.unlinkSync(t),n.symlinkSync(e,t)}t.exports=s})),Se=
|
|
7
|
-
`,finalEOL:n=!0,replacer:r=null,spaces:i}={}){let a=n?t:``,o=JSON.stringify(e,r,i);if(o===void 0)throw TypeError(`Converting ${typeof e} value to JSON is not supported`);return o.replace(/\n/g,t)+a}function r(e){return Buffer.isBuffer(e)&&(e=e.toString(`utf8`)),e.replace(/^\uFEFF/,``)}t.exports={stringify:n,stripBom:r}})),Me=z(((e,t)=>{let n;try{n=pe()}catch{n=B(`fs`)}let r=V(),{stringify:i,stripBom:a}=je();async function o(e,t={}){typeof t==`string`&&(t={encoding:t});let i=t.fs||n,o=`throws`in t?t.throws:!0,s=await r.fromCallback(i.readFile)(e,t);s=a(s);let c;try{c=JSON.parse(s,t?t.reviver:null)}catch(t){if(o)throw t.message=`${e}: ${t.message}`,t;return null}return c}let s=r.fromPromise(o);function c(e,t={}){typeof t==`string`&&(t={encoding:t});let r=t.fs||n,i=`throws`in t?t.throws:!0;try{let n=r.readFileSync(e,t);return n=a(n),JSON.parse(n,t.reviver)}catch(t){if(i)throw t.message=`${e}: ${t.message}`,t;return null}}async function l(e,t,a={}){let o=a.fs||n,s=i(t,a);await r.fromCallback(o.writeFile)(e,s,a)}let u=r.fromPromise(l);function d(e,t,r={}){let a=r.fs||n,o=i(t,r);return a.writeFileSync(e,o,r)}t.exports={readFile:s,readFileSync:c,writeFile:u,writeFileSync:d}})),Ne=z(((e,t)=>{let n=Me();t.exports={readJson:n.readFile,readJsonSync:n.readFileSync,writeJson:n.writeFile,writeJsonSync:n.writeFileSync}})),Pe=z(((e,t)=>{let n=V().fromPromise,r=H(),i=B(`path`),a=U(),o=ge().pathExists;async function s(e,t,n=`utf-8`){let s=i.dirname(e);return await o(s)||await a.mkdirs(s),r.writeFile(e,t,n)}function c(e,...t){let n=i.dirname(e);r.existsSync(n)||a.mkdirsSync(n),r.writeFileSync(e,...t)}t.exports={outputFile:n(s),outputFileSync:c}})),Fe=z(((e,t)=>{let{stringify:n}=je(),{outputFile:r}=Pe();async function i(e,t,i={}){await r(e,n(t,i),i)}t.exports=i})),Ie=z(((e,t)=>{let{stringify:n}=je(),{outputFileSync:r}=Pe();function i(e,t,i){r(e,n(t,i),i)}t.exports=i})),Le=z(((e,t)=>{let n=V().fromPromise,r=Ne();r.outputJson=n(Fe()),r.outputJsonSync=Ie(),r.outputJSON=r.outputJson,r.outputJSONSync=r.outputJsonSync,r.writeJSON=r.writeJson,r.writeJSONSync=r.writeJsonSync,r.readJSON=r.readJson,r.readJSONSync=r.readJsonSync,t.exports=r})),Re=z(((e,t)=>{let n=H(),r=B(`path`),{copy:i}=Se(),{remove:a}=Ce(),{mkdirp:o}=U(),{pathExists:s}=ge(),c=ve();async function l(e,t,n={}){let i=n.overwrite||n.clobber||!1,{srcStat:a,isChangingCase:s=!1}=await c.checkPaths(e,t,`move`,n);await c.checkParentPaths(e,a,t,`move`);let l=r.dirname(t);return r.parse(l).root!==l&&await o(l),u(e,t,i,s)}async function u(e,t,r,i){if(!i){if(r)await a(t);else if(await s(t))throw Error(`dest already exists.`)}try{await n.rename(e,t)}catch(n){if(n.code!==`EXDEV`)throw n;await d(e,t,r)}}async function d(e,t,n){return await i(e,t,{overwrite:n,errorOnExist:!0,preserveTimestamps:!0}),a(e)}t.exports=l})),ze=z(((e,t)=>{let n=pe(),r=B(`path`),i=Se().copySync,a=Ce().removeSync,o=U().mkdirpSync,s=ve();function c(e,t,n){n||={};let i=n.overwrite||n.clobber||!1,{srcStat:a,isChangingCase:c=!1}=s.checkPathsSync(e,t,`move`,n);return s.checkParentPathsSync(e,a,t,`move`),l(t)||o(r.dirname(t)),u(e,t,i,c)}function l(e){let t=r.dirname(e);return r.parse(t).root===t}function u(e,t,r,i){if(i)return d(e,t,r);if(r)return a(t),d(e,t,r);if(n.existsSync(t))throw Error(`dest already exists.`);return d(e,t,r)}function d(e,t,r){try{n.renameSync(e,t)}catch(n){if(n.code!==`EXDEV`)throw n;return f(e,t,r)}}function f(e,t,n){return i(e,t,{overwrite:n,errorOnExist:!0,preserveTimestamps:!0}),a(e)}t.exports=c})),Be=z(((e,t)=>{let n=V().fromPromise;t.exports={move:n(Re()),moveSync:ze()}})),Ve=z(((e,t)=>{t.exports={...H(),...Se(),...we(),...Ae(),...Le(),...U(),...Be(),...Pe(),...ge(),...Ce()}})),He=z(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),W=le(Ve(),1),G=le(He(),1);function Ue(e){return e==null?[]:Array.isArray(e)?e:[e]}function We(e,t,n,r){var i,a=e[t],o=~r.string.indexOf(t)?n==null||n===!0?``:String(n):typeof n==`boolean`?n:~r.boolean.indexOf(t)?n===`false`?!1:n===`true`||(e._.push((i=+n,i*0==0?i:n)),!!n):(i=+n,i*0==0?i:n);e[t]=a==null?o:Array.isArray(a)?a.concat(o):[a,o]}function Ge(e,t){e||=[],t||={};var n,r,i,a,o,s={_:[]},c=0,l=0,u=0,d=e.length;let f=t.alias!==void 0,p=t.unknown!==void 0,m=t.default!==void 0;if(t.alias=t.alias||{},t.string=Ue(t.string),t.boolean=Ue(t.boolean),f)for(n in t.alias)for(r=t.alias[n]=Ue(t.alias[n]),c=0;c<r.length;c++)(t.alias[r[c]]=r.concat(n)).splice(c,1);for(c=t.boolean.length;c-- >0;)for(r=t.alias[t.boolean[c]]||[],l=r.length;l-- >0;)t.boolean.push(r[l]);for(c=t.string.length;c-- >0;)for(r=t.alias[t.string[c]]||[],l=r.length;l-- >0;)t.string.push(r[l]);if(m){for(n in t.default)if(a=typeof t.default[n],r=t.alias[n]=t.alias[n]||[],t[a]!==void 0)for(t[a].push(n),c=0;c<r.length;c++)t[a].push(r[c])}let h=p?Object.keys(t.alias):[];for(c=0;c<d;c++){if(i=e[c],i===`--`){s._=s._.concat(e.slice(++c));break}for(l=0;l<i.length&&i.charCodeAt(l)===45;l++);if(l===0)s._.push(i);else if(i.substring(l,l+3)===`no-`){if(a=i.substring(l+3),p&&!~h.indexOf(a))return t.unknown(i);s[a]=!1}else{for(u=l+1;u<i.length&&i.charCodeAt(u)!==61;u++);for(a=i.substring(l,u),o=i.substring(++u)||c+1===d||(``+e[c+1]).charCodeAt(0)===45||e[++c],r=l===2?[a]:a,u=0;u<r.length;u++){if(a=r[u],p&&!~h.indexOf(a))return t.unknown(`-`.repeat(l)+a);We(s,a,u+1<r.length||o,t)}}}if(m)for(n in t.default)s[n]===void 0&&(s[n]=t.default[n]);if(f)for(n in s)for(r=t.alias[n]||[];r.length>0;)s[r.shift()]=s[n];return s}function Ke(e){return e.replace(/[<[].+/,``).trim()}function qe(e){let t=/<([^>]+)>/g,n=/\[([^\]]+)\]/g,r=[],i=e=>{let t=!1,n=e[1];return n.startsWith(`...`)&&(n=n.slice(3),t=!0),{required:e[0].startsWith(`<`),value:n,variadic:t}},a;for(;a=t.exec(e);)r.push(i(a));let o;for(;o=n.exec(e);)r.push(i(o));return r}function Je(e){let t={alias:{},boolean:[]};for(let[n,r]of e.entries())r.names.length>1&&(t.alias[r.names[0]]=r.names.slice(1)),r.isBoolean&&(r.negated&&e.some((e,t)=>t!==n&&e.names.some(e=>r.names.includes(e))&&typeof e.required==`boolean`)||t.boolean.push(r.names[0]));return t}function Ye(e){return e.sort((e,t)=>e.length>t.length?-1:1)[0]}function Xe(e,t){return e.length>=t?e:`${e}${` `.repeat(t-e.length)}`}function Ze(e){return e.replaceAll(/([a-z])-([a-z])/g,(e,t,n)=>t+n.toUpperCase())}function Qe(e,t,n){let r=e;for(let e=0;e<t.length;e++){let i=t[e];if(e===t.length-1){r[i]=n;return}if(r[i]==null){let n=+t[e+1]>-1;r[i]=n?[]:{}}r=r[i]}}function $e(e,t){for(let n of Object.keys(t)){let r=t[n];r.shouldTransform&&(e[n]=[e[n]].flat(),typeof r.transformFunction==`function`&&(e[n]=e[n].map(r.transformFunction)))}}function et(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:``}function tt(e){return e.split(`.`).map((e,t)=>t===0?Ze(e):e).join(`.`)}var nt=class extends Error{constructor(e){super(e),this.name=`CACError`,typeof Error.captureStackTrace!=`function`&&(this.stack=Error(e).stack)}},rt=class{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,t,n){this.rawName=e,this.description=t,this.config=Object.assign({},n),e=e.replaceAll(`.*`,``),this.negated=!1,this.names=Ke(e).split(`,`).map(e=>{let t=e.trim().replace(/^-{1,2}/,``);return t.startsWith(`no-`)&&(this.negated=!0,t=t.replace(/^no-/,``)),tt(t)}).sort((e,t)=>e.length>t.length?1:-1),this.name=this.names.at(-1),this.negated&&this.config.default==null&&(this.config.default=!0),e.includes(`<`)?this.required=!0:e.includes(`[`)?this.required=!1:this.isBoolean=!0}};let it,at;if(typeof process<`u`){let e;e=typeof Deno<`u`&&typeof Deno.version?.deno==`string`?`deno`:typeof Bun<`u`&&typeof Bun.version==`string`?`bun`:`node`,at=`${process.platform}-${process.arch} ${e}-${process.version}`,it=process.argv}else at=typeof navigator>`u`?`unknown`:`${navigator.platform} ${navigator.userAgent}`;var ot=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor(e,t,n={},r){this.rawName=e,this.description=t,this.config=n,this.cli=r,this.options=[],this.aliasNames=[],this.name=Ke(e),this.args=qe(e),this.examples=[]}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t=`-v, --version`){return this.versionNumber=e,this.option(t,`Display version number`),this}example(e){return this.examples.push(e),this}option(e,t,n){let r=new rt(e,t,n);return this.options.push(r),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}isMatched(e){return this.name===e||this.aliasNames.includes(e)}get isDefaultCommand(){return this.name===``||this.aliasNames.includes(`!`)}get isGlobalCommand(){return this instanceof st}hasOption(e){return e=e.split(`.`)[0],this.options.find(t=>t.names.includes(e))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:n,options:r,helpCallback:i}=this.cli.globalCommand,a=[{body:`${e}${n?`/${n}`:``}`}];if(a.push({title:`Usage`,body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let n=Ye(t.map(e=>e.rawName));a.push({title:`Commands`,body:t.map(e=>` ${Xe(e.rawName,n.length)} ${e.description}`).join(`
|
|
6
|
+
see https://github.com/jprichardson/node-fs-extra/issues/269`,`Warning`,`fs-extra-WARN0002`);let{srcStat:s,destStat:l}=o.checkPathsSync(e,t,`copy`,a);if(o.checkParentPathsSync(e,s,t,`copy`),a.filter&&!a.filter(e,t))return;let u=r.dirname(t);return n.existsSync(u)||i(u),c(l,e,t,a)}function c(e,t,r,i){let a=(i.dereference?n.statSync:n.lstatSync)(t);if(a.isDirectory())return _(a,e,t,r,i);if(a.isFile()||a.isCharacterDevice()||a.isBlockDevice())return l(a,e,t,r,i);if(a.isSymbolicLink())return x(e,t,r,i);throw a.isSocket()?Error(`Cannot copy a socket file: ${t}`):a.isFIFO()?Error(`Cannot copy a FIFO pipe: ${t}`):Error(`Unknown file: ${t}`)}function l(e,t,n,r,i){return t?u(e,n,r,i):d(e,n,r,i)}function u(e,t,r,i){if(i.overwrite)return n.unlinkSync(r),d(e,t,r,i);if(i.errorOnExist)throw Error(`'${r}' already exists`)}function d(e,t,r,i){return n.copyFileSync(t,r),i.preserveTimestamps&&f(e.mode,t,r),h(r,e.mode)}function f(e,t,n){return p(e)&&m(n,e),g(t,n)}function p(e){return(e&128)==0}function m(e,t){return h(e,t|128)}function h(e,t){return n.chmodSync(e,t)}function g(e,t){let r=n.statSync(e);return a(t,r.atime,r.mtime)}function _(e,t,n,r,i){return t?y(n,r,i):v(e.mode,n,r,i)}function v(e,t,r,i){return n.mkdirSync(r),y(t,r,i),h(r,e)}function y(e,t,r){let i=n.opendirSync(e);try{let n;for(;(n=i.readSync())!==null;)b(n.name,e,t,r)}finally{i.closeSync()}}function b(e,t,n,i){let a=r.join(t,e),s=r.join(n,e);if(i.filter&&!i.filter(a,s))return;let{destStat:l}=o.checkPathsSync(a,s,`copy`,i);return c(l,a,s,i)}function x(e,t,i,a){let s=n.readlinkSync(t);if(a.dereference&&(s=r.resolve(process.cwd(),s)),e){let e;try{e=n.readlinkSync(i)}catch(e){if(e.code===`EINVAL`||e.code===`UNKNOWN`)return n.symlinkSync(s,i);throw e}if(a.dereference&&(e=r.resolve(process.cwd(),e)),s!==e){if(o.isSrcSubdir(s,e))throw Error(`Cannot copy '${s}' to a subdirectory of itself, '${e}'.`);if(o.isSrcSubdir(e,s))throw Error(`Cannot overwrite '${e}' with '${s}'.`)}return S(s,i)}else return n.symlinkSync(s,i)}function S(e,t){return n.unlinkSync(t),n.symlinkSync(e,t)}t.exports=s})),Se=R(((e,t)=>{let n=V().fromPromise;t.exports={copy:n(be()),copySync:xe()}})),Ce=R(((e,t)=>{let n=H(),r=V().fromCallback;function i(e,t){n.rm(e,{recursive:!0,force:!0},t)}function a(e){n.rmSync(e,{recursive:!0,force:!0})}t.exports={remove:r(i),removeSync:a}})),we=R(((e,t)=>{let n=V().fromPromise,r=U(),i=B(`path`),a=W(),o=Ce(),s=n(async function(e){let t;try{t=await r.readdir(e)}catch{return a.mkdirs(e)}return Promise.all(t.map(t=>o.remove(i.join(e,t))))});function c(e){let t;try{t=r.readdirSync(e)}catch{return a.mkdirsSync(e)}t.forEach(t=>{t=i.join(e,t),o.removeSync(t)})}t.exports={emptyDirSync:c,emptydirSync:c,emptyDir:s,emptydir:s}})),Te=R(((e,t)=>{let n=V().fromPromise,r=B(`path`),i=U(),a=W();async function o(e){let t;try{t=await i.stat(e)}catch{}if(t&&t.isFile())return;let n=r.dirname(e),o=null;try{o=await i.stat(n)}catch(t){if(t.code===`ENOENT`){await a.mkdirs(n),await i.writeFile(e,``);return}else throw t}o.isDirectory()?await i.writeFile(e,``):await i.readdir(n)}function s(e){let t;try{t=i.statSync(e)}catch{}if(t&&t.isFile())return;let n=r.dirname(e);try{i.statSync(n).isDirectory()||i.readdirSync(n)}catch(e){if(e&&e.code===`ENOENT`)a.mkdirsSync(n);else throw e}i.writeFileSync(e,``)}t.exports={createFile:n(o),createFileSync:s}})),Ee=R(((e,t)=>{let n=V().fromPromise,r=B(`path`),i=U(),a=W(),{pathExists:o}=ge(),{areIdentical:s}=ve();async function c(e,t){let n;try{n=await i.lstat(t)}catch{}let c;try{c=await i.lstat(e)}catch(e){throw e.message=e.message.replace(`lstat`,`ensureLink`),e}if(n&&s(c,n))return;let l=r.dirname(t);await o(l)||await a.mkdirs(l),await i.link(e,t)}function l(e,t){let n;try{n=i.lstatSync(t)}catch{}try{let t=i.lstatSync(e);if(n&&s(t,n))return}catch(e){throw e.message=e.message.replace(`lstat`,`ensureLink`),e}let o=r.dirname(t);return i.existsSync(o)||a.mkdirsSync(o),i.linkSync(e,t)}t.exports={createLink:n(c),createLinkSync:l}})),De=R(((e,t)=>{let n=B(`path`),r=U(),{pathExists:i}=ge(),a=V().fromPromise;async function o(e,t){if(n.isAbsolute(e)){try{await r.lstat(e)}catch(e){throw e.message=e.message.replace(`lstat`,`ensureSymlink`),e}return{toCwd:e,toDst:e}}let a=n.dirname(t),o=n.join(a,e);if(await i(o))return{toCwd:o,toDst:e};try{await r.lstat(e)}catch(e){throw e.message=e.message.replace(`lstat`,`ensureSymlink`),e}return{toCwd:e,toDst:n.relative(a,e)}}function s(e,t){if(n.isAbsolute(e)){if(!r.existsSync(e))throw Error(`absolute srcpath does not exist`);return{toCwd:e,toDst:e}}let i=n.dirname(t),a=n.join(i,e);if(r.existsSync(a))return{toCwd:a,toDst:e};if(!r.existsSync(e))throw Error(`relative srcpath does not exist`);return{toCwd:e,toDst:n.relative(i,e)}}t.exports={symlinkPaths:a(o),symlinkPathsSync:s}})),Oe=R(((e,t)=>{let n=U(),r=V().fromPromise;async function i(e,t){if(t)return t;let r;try{r=await n.lstat(e)}catch{return`file`}return r&&r.isDirectory()?`dir`:`file`}function a(e,t){if(t)return t;let r;try{r=n.lstatSync(e)}catch{return`file`}return r&&r.isDirectory()?`dir`:`file`}t.exports={symlinkType:r(i),symlinkTypeSync:a}})),ke=R(((e,t)=>{let n=V().fromPromise,r=B(`path`),i=U(),{mkdirs:a,mkdirsSync:o}=W(),{symlinkPaths:s,symlinkPathsSync:c}=De(),{symlinkType:l,symlinkTypeSync:u}=Oe(),{pathExists:d}=ge(),{areIdentical:f}=ve();async function p(e,t,n){let o;try{o=await i.lstat(t)}catch{}if(o&&o.isSymbolicLink()){let n;if(r.isAbsolute(e))n=await i.stat(e);else{let a=r.dirname(t),o=r.join(a,e);try{n=await i.stat(o)}catch{n=await i.stat(e)}}let a=await i.stat(t);if(f(n,a))return}let c=await s(e,t);e=c.toDst;let u=await l(c.toCwd,n),p=r.dirname(t);return await d(p)||await a(p),i.symlink(e,t,u)}function m(e,t,n){let a;try{a=i.lstatSync(t)}catch{}if(a&&a.isSymbolicLink()){let n;if(r.isAbsolute(e))n=i.statSync(e);else{let a=r.dirname(t),o=r.join(a,e);try{n=i.statSync(o)}catch{n=i.statSync(e)}}let a=i.statSync(t);if(f(n,a))return}let s=c(e,t);e=s.toDst,n=u(s.toCwd,n);let l=r.dirname(t);return i.existsSync(l)||o(l),i.symlinkSync(e,t,n)}t.exports={createSymlink:n(p),createSymlinkSync:m}})),Ae=R(((e,t)=>{let{createFile:n,createFileSync:r}=Te(),{createLink:i,createLinkSync:a}=Ee(),{createSymlink:o,createSymlinkSync:s}=ke();t.exports={createFile:n,createFileSync:r,ensureFile:n,ensureFileSync:r,createLink:i,createLinkSync:a,ensureLink:i,ensureLinkSync:a,createSymlink:o,createSymlinkSync:s,ensureSymlink:o,ensureSymlinkSync:s}})),je=R(((e,t)=>{function n(e,{EOL:t=`
|
|
7
|
+
`,finalEOL:n=!0,replacer:r=null,spaces:i}={}){let a=n?t:``,o=JSON.stringify(e,r,i);if(o===void 0)throw TypeError(`Converting ${typeof e} value to JSON is not supported`);return o.replace(/\n/g,t)+a}function r(e){return Buffer.isBuffer(e)&&(e=e.toString(`utf8`)),e.replace(/^\uFEFF/,``)}t.exports={stringify:n,stripBom:r}})),Me=R(((e,t)=>{let n;try{n=H()}catch{n=B(`fs`)}let r=V(),{stringify:i,stripBom:a}=je();async function o(e,t={}){typeof t==`string`&&(t={encoding:t});let i=t.fs||n,o=`throws`in t?t.throws:!0,s=await r.fromCallback(i.readFile)(e,t);s=a(s);let c;try{c=JSON.parse(s,t?t.reviver:null)}catch(t){if(o)throw t.message=`${e}: ${t.message}`,t;return null}return c}let s=r.fromPromise(o);function c(e,t={}){typeof t==`string`&&(t={encoding:t});let r=t.fs||n,i=`throws`in t?t.throws:!0;try{let n=r.readFileSync(e,t);return n=a(n),JSON.parse(n,t.reviver)}catch(t){if(i)throw t.message=`${e}: ${t.message}`,t;return null}}async function l(e,t,a={}){let o=a.fs||n,s=i(t,a);await r.fromCallback(o.writeFile)(e,s,a)}let u=r.fromPromise(l);function d(e,t,r={}){let a=r.fs||n,o=i(t,r);return a.writeFileSync(e,o,r)}t.exports={readFile:s,readFileSync:c,writeFile:u,writeFileSync:d}})),Ne=R(((e,t)=>{let n=Me();t.exports={readJson:n.readFile,readJsonSync:n.readFileSync,writeJson:n.writeFile,writeJsonSync:n.writeFileSync}})),Pe=R(((e,t)=>{let n=V().fromPromise,r=U(),i=B(`path`),a=W(),o=ge().pathExists;async function s(e,t,n=`utf-8`){let s=i.dirname(e);return await o(s)||await a.mkdirs(s),r.writeFile(e,t,n)}function c(e,...t){let n=i.dirname(e);r.existsSync(n)||a.mkdirsSync(n),r.writeFileSync(e,...t)}t.exports={outputFile:n(s),outputFileSync:c}})),Fe=R(((e,t)=>{let{stringify:n}=je(),{outputFile:r}=Pe();async function i(e,t,i={}){await r(e,n(t,i),i)}t.exports=i})),Ie=R(((e,t)=>{let{stringify:n}=je(),{outputFileSync:r}=Pe();function i(e,t,i){r(e,n(t,i),i)}t.exports=i})),Le=R(((e,t)=>{let n=V().fromPromise,r=Ne();r.outputJson=n(Fe()),r.outputJsonSync=Ie(),r.outputJSON=r.outputJson,r.outputJSONSync=r.outputJsonSync,r.writeJSON=r.writeJson,r.writeJSONSync=r.writeJsonSync,r.readJSON=r.readJson,r.readJSONSync=r.readJsonSync,t.exports=r})),Re=R(((e,t)=>{let n=U(),r=B(`path`),{copy:i}=Se(),{remove:a}=Ce(),{mkdirp:o}=W(),{pathExists:s}=ge(),c=ve();async function l(e,t,n={}){let i=n.overwrite||n.clobber||!1,{srcStat:a,isChangingCase:s=!1}=await c.checkPaths(e,t,`move`,n);await c.checkParentPaths(e,a,t,`move`);let l=r.dirname(t);return r.parse(l).root!==l&&await o(l),u(e,t,i,s)}async function u(e,t,r,i){if(!i){if(r)await a(t);else if(await s(t))throw Error(`dest already exists.`)}try{await n.rename(e,t)}catch(n){if(n.code!==`EXDEV`)throw n;await d(e,t,r)}}async function d(e,t,n){return await i(e,t,{overwrite:n,errorOnExist:!0,preserveTimestamps:!0}),a(e)}t.exports=l})),ze=R(((e,t)=>{let n=H(),r=B(`path`),i=Se().copySync,a=Ce().removeSync,o=W().mkdirpSync,s=ve();function c(e,t,n){n||={};let i=n.overwrite||n.clobber||!1,{srcStat:a,isChangingCase:c=!1}=s.checkPathsSync(e,t,`move`,n);return s.checkParentPathsSync(e,a,t,`move`),l(t)||o(r.dirname(t)),u(e,t,i,c)}function l(e){let t=r.dirname(e);return r.parse(t).root===t}function u(e,t,r,i){if(i)return d(e,t,r);if(r)return a(t),d(e,t,r);if(n.existsSync(t))throw Error(`dest already exists.`);return d(e,t,r)}function d(e,t,r){try{n.renameSync(e,t)}catch(n){if(n.code!==`EXDEV`)throw n;return f(e,t,r)}}function f(e,t,n){return i(e,t,{overwrite:n,errorOnExist:!0,preserveTimestamps:!0}),a(e)}t.exports=c})),Be=R(((e,t)=>{let n=V().fromPromise;t.exports={move:n(Re()),moveSync:ze()}})),Ve=R(((e,t)=>{t.exports={...U(),...Se(),...we(),...Ae(),...Le(),...W(),...Be(),...Pe(),...ge(),...Ce()}})),He=R(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),G=z(Ve(),1),K=z(He(),1);function Ue(e){return e==null?[]:Array.isArray(e)?e:[e]}function We(e,t,n,r){var i,a=e[t],o=~r.string.indexOf(t)?n==null||n===!0?``:String(n):typeof n==`boolean`?n:~r.boolean.indexOf(t)?n===`false`?!1:n===`true`||(e._.push((i=+n,i*0==0?i:n)),!!n):(i=+n,i*0==0?i:n);e[t]=a==null?o:Array.isArray(a)?a.concat(o):[a,o]}function Ge(e,t){e||=[],t||={};var n,r,i,a,o,s={_:[]},c=0,l=0,u=0,d=e.length;let f=t.alias!==void 0,p=t.unknown!==void 0,m=t.default!==void 0;if(t.alias=t.alias||{},t.string=Ue(t.string),t.boolean=Ue(t.boolean),f)for(n in t.alias)for(r=t.alias[n]=Ue(t.alias[n]),c=0;c<r.length;c++)(t.alias[r[c]]=r.concat(n)).splice(c,1);for(c=t.boolean.length;c-- >0;)for(r=t.alias[t.boolean[c]]||[],l=r.length;l-- >0;)t.boolean.push(r[l]);for(c=t.string.length;c-- >0;)for(r=t.alias[t.string[c]]||[],l=r.length;l-- >0;)t.string.push(r[l]);if(m){for(n in t.default)if(a=typeof t.default[n],r=t.alias[n]=t.alias[n]||[],t[a]!==void 0)for(t[a].push(n),c=0;c<r.length;c++)t[a].push(r[c])}let h=p?Object.keys(t.alias):[];for(c=0;c<d;c++){if(i=e[c],i===`--`){s._=s._.concat(e.slice(++c));break}for(l=0;l<i.length&&i.charCodeAt(l)===45;l++);if(l===0)s._.push(i);else if(i.substring(l,l+3)===`no-`){if(a=i.substring(l+3),p&&!~h.indexOf(a))return t.unknown(i);s[a]=!1}else{for(u=l+1;u<i.length&&i.charCodeAt(u)!==61;u++);for(a=i.substring(l,u),o=i.substring(++u)||c+1===d||(``+e[c+1]).charCodeAt(0)===45||e[++c],r=l===2?[a]:a,u=0;u<r.length;u++){if(a=r[u],p&&!~h.indexOf(a))return t.unknown(`-`.repeat(l)+a);We(s,a,u+1<r.length||o,t)}}}if(m)for(n in t.default)s[n]===void 0&&(s[n]=t.default[n]);if(f)for(n in s)for(r=t.alias[n]||[];r.length>0;)s[r.shift()]=s[n];return s}function Ke(e){return e.replace(/[<[].+/,``).trim()}function qe(e){let t=/<([^>]+)>/g,n=/\[([^\]]+)\]/g,r=[],i=e=>{let t=!1,n=e[1];return n.startsWith(`...`)&&(n=n.slice(3),t=!0),{required:e[0].startsWith(`<`),value:n,variadic:t}},a;for(;a=t.exec(e);)r.push(i(a));let o;for(;o=n.exec(e);)r.push(i(o));return r}function Je(e){let t={alias:{},boolean:[]};for(let[n,r]of e.entries())r.names.length>1&&(t.alias[r.names[0]]=r.names.slice(1)),r.isBoolean&&(r.negated&&e.some((e,t)=>t!==n&&e.names.some(e=>r.names.includes(e))&&typeof e.required==`boolean`)||t.boolean.push(r.names[0]));return t}function Ye(e){return e.sort((e,t)=>e.length>t.length?-1:1)[0]}function Xe(e,t){return e.length>=t?e:`${e}${` `.repeat(t-e.length)}`}function Ze(e){return e.replaceAll(/([a-z])-([a-z])/g,(e,t,n)=>t+n.toUpperCase())}function Qe(e,t,n){let r=e;for(let e=0;e<t.length;e++){let i=t[e];if(e===t.length-1){r[i]=n;return}if(r[i]==null){let n=+t[e+1]>-1;r[i]=n?[]:{}}r=r[i]}}function $e(e,t){for(let n of Object.keys(t)){let r=t[n];r.shouldTransform&&(e[n]=[e[n]].flat(),typeof r.transformFunction==`function`&&(e[n]=e[n].map(r.transformFunction)))}}function et(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:``}function tt(e){return e.split(`.`).map((e,t)=>t===0?Ze(e):e).join(`.`)}var nt=class extends Error{constructor(e){super(e),this.name=`CACError`,typeof Error.captureStackTrace!=`function`&&(this.stack=Error(e).stack)}},rt=class{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,t,n){this.rawName=e,this.description=t,this.config=Object.assign({},n),e=e.replaceAll(`.*`,``),this.negated=!1,this.names=Ke(e).split(`,`).map(e=>{let t=e.trim().replace(/^-{1,2}/,``);return t.startsWith(`no-`)&&(this.negated=!0,t=t.replace(/^no-/,``)),tt(t)}).sort((e,t)=>e.length>t.length?1:-1),this.name=this.names.at(-1),this.negated&&this.config.default==null&&(this.config.default=!0),e.includes(`<`)?this.required=!0:e.includes(`[`)?this.required=!1:this.isBoolean=!0}};let it,at;if(typeof process<`u`){let e;e=typeof Deno<`u`&&typeof Deno.version?.deno==`string`?`deno`:typeof Bun<`u`&&typeof Bun.version==`string`?`bun`:`node`,at=`${process.platform}-${process.arch} ${e}-${process.version}`,it=process.argv}else at=typeof navigator>`u`?`unknown`:`${navigator.platform} ${navigator.userAgent}`;var ot=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor(e,t,n={},r){this.rawName=e,this.description=t,this.config=n,this.cli=r,this.options=[],this.aliasNames=[],this.name=Ke(e),this.args=qe(e),this.examples=[]}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t=`-v, --version`){return this.versionNumber=e,this.option(t,`Display version number`),this}example(e){return this.examples.push(e),this}option(e,t,n){let r=new rt(e,t,n);return this.options.push(r),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}isMatched(e){return this.name===e||this.aliasNames.includes(e)}get isDefaultCommand(){return this.name===``||this.aliasNames.includes(`!`)}get isGlobalCommand(){return this instanceof st}hasOption(e){return e=e.split(`.`)[0],this.options.find(t=>t.names.includes(e))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:n,options:r,helpCallback:i}=this.cli.globalCommand,a=[{body:`${e}${n?`/${n}`:``}`}];if(a.push({title:`Usage`,body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let n=Ye(t.map(e=>e.rawName));a.push({title:`Commands`,body:t.map(e=>` ${Xe(e.rawName,n.length)} ${e.description}`).join(`
|
|
8
8
|
`)},{title:"For more info, run any command with the `--help` flag",body:t.map(t=>` $ ${e}${t.name===``?``:` ${t.name}`} --help`).join(`
|
|
9
9
|
`)})}let o=this.isGlobalCommand?r:[...this.options,...r||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand&&(o=o.filter(e=>e.name!==`version`)),o.length>0){let e=Ye(o.map(e=>e.rawName));a.push({title:`Options`,body:o.map(t=>` ${Xe(t.rawName,e.length)} ${t.description} ${t.config.default===void 0?``:`(default: ${t.config.default})`}`).join(`
|
|
10
10
|
`)})}this.examples.length>0&&a.push({title:`Examples`,body:this.examples.map(t=>typeof t==`function`?t(e):t).join(`
|
|
11
11
|
`)}),i&&(a=i(a)||a),console.info(a.map(e=>e.title?`${e.title}:\n${e.body}`:e.body).join(`
|
|
12
12
|
|
|
13
|
-
`))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;t&&console.info(`${e}/${t} ${at}`)}checkRequiredArgs(){let e=this.args.filter(e=>e.required).length;if(this.cli.args.length<e)throw new nt(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!==`--`&&!this.hasOption(n)&&!t.hasOption(n))throw new nt(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,n=[...t.options,...this.options];for(let t of n){let r=e[t.name.split(`.`)[0]];if(t.required){let e=n.some(e=>e.negated&&e.names.includes(t.name));if(r===!0||r===!1&&!e)throw new nt(`option \`${t.rawName}\` value is missing`)}}}checkUnusedArgs(){let e=this.args.some(e=>e.variadic)?1/0:this.args.length;if(e<this.cli.args.length)throw new nt(`Unused args: ${this.cli.args.slice(e).map(e=>`\`${e}\``).join(`, `)}`)}},st=class extends ot{constructor(e){super(`@@global@@`,``,{},e)}},ct=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor(e=``){super(),this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new st(this),this.globalCommand.usage(`<command> [options]`)}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){let r=new ot(e,t||``,n,this);return r.globalCommand=this.globalCommand,this.commands.push(r),r}option(e,t,n){return this.globalCommand.option(e,t,n),this}help(e){return this.globalCommand.option(`-h, --help`,`Display this message`),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t=`-v, --version`){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){this.matchedCommand?this.matchedCommand.outputHelp():this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},n,r){return this.args=e,this.options=t,n&&(this.matchedCommand=n),r&&(this.matchedCommandName=r),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e,{run:t=!0}={}){if(!e){if(!it)throw Error(`No argv provided and runtime process argv is not available.`);e=it}this.rawArgs=e,this.name||=e[1]?et(e[1]):`cli`;let n=!0;for(let t of this.commands){let r=this.mri(e.slice(2),t),i=r.args[0];if(t.isMatched(i)){n=!1;let e={...r,args:r.args.slice(1)};this.setParsedInfo(e,t,i),this.dispatchEvent(new CustomEvent(`command:${i}`,{detail:t}))}}if(n){for(let t of this.commands)if(t.isDefaultCommand){n=!1;let r=this.mri(e.slice(2),t);this.setParsedInfo(r,t),this.dispatchEvent(new CustomEvent(`command:!`,{detail:t}))}}if(n){let t=this.mri(e.slice(2));this.setParsedInfo(t)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),t=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),t=!1,this.unsetMatchedCommand());let r={args:this.args,options:this.options};return t&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.dispatchEvent(new CustomEvent(`command:*`,{detail:this.args[0]})),r}mri(e,t){let n=[...this.globalCommand.options,...t?t.options:[]],r=Je(n),i=[],a=e.indexOf(`--`);a!==-1&&(i=e.slice(a+1),e=e.slice(0,a));let o=Ge(e,r);o=Object.keys(o).reduce((e,t)=>({...e,[tt(t)]:o[t]}),{_:[]});let s=o._,c={"--":i},l=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,u=Object.create(null);for(let e of n){if(!l&&e.config.default!==void 0)for(let t of e.names)c[t]=e.config.default;Array.isArray(e.config.type)&&u[e.name]===void 0&&(u[e.name]=Object.create(null),u[e.name].shouldTransform=!0,u[e.name].transformFunction=e.config.type[0])}for(let e of Object.keys(o))e!==`_`&&(Qe(c,e.split(`.`),o[e]),$e(c,u));return{args:s,options:c}}runMatchedCommand(){let{args:e,options:t,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs(),n.checkUnusedArgs();let r=[];return n.args.forEach((t,n)=>{t.variadic?r.push(e.slice(n)):r.push(e[n])}),r.push(t),n.commandAction.apply(this,r)}};const lt=(e=``)=>new ct(e);function ut(e){switch(e){case`strict`:return`strict`;case`relaxed`:return`relaxed`;case`off`:return`off`;default:throw Error(`Invalid value for --ssl: ${e}. Expected one of: strict, relaxed, off.`)}}function
|
|
13
|
+
`))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;t&&console.info(`${e}/${t} ${at}`)}checkRequiredArgs(){let e=this.args.filter(e=>e.required).length;if(this.cli.args.length<e)throw new nt(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!==`--`&&!this.hasOption(n)&&!t.hasOption(n))throw new nt(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,n=[...t.options,...this.options];for(let t of n){let r=e[t.name.split(`.`)[0]];if(t.required){let e=n.some(e=>e.negated&&e.names.includes(t.name));if(r===!0||r===!1&&!e)throw new nt(`option \`${t.rawName}\` value is missing`)}}}checkUnusedArgs(){let e=this.args.some(e=>e.variadic)?1/0:this.args.length;if(e<this.cli.args.length)throw new nt(`Unused args: ${this.cli.args.slice(e).map(e=>`\`${e}\``).join(`, `)}`)}},st=class extends ot{constructor(e){super(`@@global@@`,``,{},e)}},ct=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor(e=``){super(),this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new st(this),this.globalCommand.usage(`<command> [options]`)}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){let r=new ot(e,t||``,n,this);return r.globalCommand=this.globalCommand,this.commands.push(r),r}option(e,t,n){return this.globalCommand.option(e,t,n),this}help(e){return this.globalCommand.option(`-h, --help`,`Display this message`),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t=`-v, --version`){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){this.matchedCommand?this.matchedCommand.outputHelp():this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},n,r){return this.args=e,this.options=t,n&&(this.matchedCommand=n),r&&(this.matchedCommandName=r),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e,{run:t=!0}={}){if(!e){if(!it)throw Error(`No argv provided and runtime process argv is not available.`);e=it}this.rawArgs=e,this.name||=e[1]?et(e[1]):`cli`;let n=!0;for(let t of this.commands){let r=this.mri(e.slice(2),t),i=r.args[0];if(t.isMatched(i)){n=!1;let e={...r,args:r.args.slice(1)};this.setParsedInfo(e,t,i),this.dispatchEvent(new CustomEvent(`command:${i}`,{detail:t}))}}if(n){for(let t of this.commands)if(t.isDefaultCommand){n=!1;let r=this.mri(e.slice(2),t);this.setParsedInfo(r,t),this.dispatchEvent(new CustomEvent(`command:!`,{detail:t}))}}if(n){let t=this.mri(e.slice(2));this.setParsedInfo(t)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),t=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),t=!1,this.unsetMatchedCommand());let r={args:this.args,options:this.options};return t&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.dispatchEvent(new CustomEvent(`command:*`,{detail:this.args[0]})),r}mri(e,t){let n=[...this.globalCommand.options,...t?t.options:[]],r=Je(n),i=[],a=e.indexOf(`--`);a!==-1&&(i=e.slice(a+1),e=e.slice(0,a));let o=Ge(e,r);o=Object.keys(o).reduce((e,t)=>({...e,[tt(t)]:o[t]}),{_:[]});let s=o._,c={"--":i},l=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,u=Object.create(null);for(let e of n){if(!l&&e.config.default!==void 0)for(let t of e.names)c[t]=e.config.default;Array.isArray(e.config.type)&&u[e.name]===void 0&&(u[e.name]=Object.create(null),u[e.name].shouldTransform=!0,u[e.name].transformFunction=e.config.type[0])}for(let e of Object.keys(o))e!==`_`&&(Qe(c,e.split(`.`),o[e]),$e(c,u));return{args:s,options:c}}runMatchedCommand(){let{args:e,options:t,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs(),n.checkUnusedArgs();let r=[];return n.args.forEach((t,n)=>{t.variadic?r.push(e.slice(n)):r.push(e[n])}),r.push(t),n.commandAction.apply(this,r)}};const lt=(e=``)=>new ct(e);function ut(e){switch(e){case`strict`:return`strict`;case`relaxed`:return`relaxed`;case`off`:return`off`;default:throw Error(`Invalid value for --ssl: ${e}. Expected one of: strict, relaxed, off.`)}}function q(e){return Array.isArray(e)?e[e.length-1]:e}function dt(e){if(e===`true`)return`latest`;if(e!==`undefined`)return e}function ft(e,t){let n=ht(t);return{config:q(e.config),force:q(e.force)??!1,ui:q(e.ui),smart:n.length>0?!0:q(e.smart),update:dt(q(e.update)),ssl:ut(q(e.ssl)),notifications:q(e.notifications),paths:n}}function pt(e,t){let n=ht(t);return{config:q(e.config),force:q(e.force)??!1,skill:q(e.skill)??!1,smart:q(e.smart),update:dt(q(e.update)),ssl:ut(q(e.ssl)),paths:n}}function mt(e){return{all:q(e?.all)??!1,config:q(e?.config)}}function ht(e){return(Array.isArray(e)?e:[]).filter(e=>e!==``&&!e.startsWith(`--`))}function gt(e,t){let n=lt(`wallaby`),r,i=n.command(`[start] [...paths]`,`Start Wallaby`).usage(`[start] [...paths]`).alias(`start`).option(`--config <path>`,`Use config file: https://wallabyjs.com/docs/config/overview.html`).option(`--ui`,`Open browser on startup`,{default:!0}).option(`--smart`,`Use smart (lazy) start to run tests of modified test files only: https://wallabyjs.com/docs/intro/smart-start.html`).option(`--force`,`Start a new Wallaby instance even if one is already running`,{default:!1}).option(`--update [version]`,`Update Wallaby to the latest version before starting, or install and pin the specified version`,{type:[String]}).option(`--ssl <mode>`,`Set SSL mode for downloads: strict, relaxed, or off`,{default:`strict`,type:[String]}).option(`--notifications`,`Notify about license expiration`,{default:!0}).action((e,t,n)=>{r={action:`start`,options:ft(n,e?[e,...t??[]]:t)}});return i.rawName=`[start] [...paths]`,n.command(`run [...paths]`,`Run Wallaby for coding agents`).option(`--config <path>`,`Use config file: https://wallabyjs.com/docs/config/overview.html`).option(`--force`,`Force a new Wallaby instance launch`,{default:!1}).option(`--skill`,`Launch Wallaby in skill mode and keep it running after the run finishes`,{default:!1}).option(`--smart`,`Use smart (lazy) start to run tests of modified test files only: https://wallabyjs.com/docs/intro/smart-start.html`).option(`--update [version]`,`Update Wallaby to the latest version before starting, or install and pin the specified version`,{type:[String]}).option(`--ssl <mode>`,`Set SSL mode for downloads: strict, relaxed, or off`,{default:`strict`,type:[String]}).action((e,t)=>{r={action:`run`,options:pt(t,e)}}),n.command(`stop`,`Stop Wallaby`).option(`--config <path>`,`Stop Wallaby instances using config file`).option(`--all`,`Stop all Wallaby instances`,{default:!1}).action(e=>{r={action:`stop`,options:mt(e)}}),n.help(),n.version(t),n.parse(e),r}var _t=R(((e,t)=>{let n=e=>e&&typeof e.message==`string`,r=e=>{if(!e)return;let t=e.cause;if(typeof t==`function`){let t=e.cause();return n(t)?t:void 0}else return n(t)?t:void 0},i=(e,t)=>{if(!n(e))return``;let a=e.stack||``;if(t.has(e))return a+`
|
|
14
14
|
causes have become circular...`;let o=r(e);return o?(t.add(e),a+`
|
|
15
|
-
caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?``:e.message||``;if(t.has(e))return a+`: ...`;let s=r(e);if(s){t.add(e);let n=typeof e.cause==`function`;return a+(n?``:`: `)+o(s,t,n)}else return a};t.exports={isErrorLike:n,getErrorCause:r,stackWithCauses:a,messageWithCauses:e=>o(e,new Set)}})),_t=z(((e,t)=>{let n=Symbol(`circular-ref-tag`),r=Symbol(`pino-raw-err-ref`),i=Object.create({},{type:{enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,value:void 0},aggregateErrors:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[r]},set:function(e){this[r]=e}}});Object.defineProperty(i,r,{writable:!0,value:{}}),t.exports={pinoErrProto:i,pinoErrorSymbols:{seen:n,rawSymbol:r}}})),vt=z(((e,t)=>{t.exports=l;let{messageWithCauses:n,stackWithCauses:r,isErrorLike:i}=gt(),{pinoErrProto:a,pinoErrorSymbols:o}=_t(),{seen:s}=o,{toString:c}=Object.prototype;function l(e){if(!i(e))return e;e[s]=void 0;let t=Object.create(a);t.type=c.call(e.constructor)===`[object Function]`?e.constructor.name:e.name,t.message=n(e),t.stack=r(e),Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(e=>l(e)));for(let n in e)if(t[n]===void 0){let r=e[n];i(r)?n!==`cause`&&!Object.prototype.hasOwnProperty.call(r,s)&&(t[n]=l(r)):t[n]=r}return delete e[s],t.raw=e,t}})),yt=z(((e,t)=>{t.exports=s;let{isErrorLike:n}=gt(),{pinoErrProto:r,pinoErrorSymbols:i}=_t(),{seen:a}=i,{toString:o}=Object.prototype;function s(e){if(!n(e))return e;e[a]=void 0;let t=Object.create(r);t.type=o.call(e.constructor)===`[object Function]`?e.constructor.name:e.name,t.message=e.message,t.stack=e.stack,Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(e=>s(e))),n(e.cause)&&!Object.prototype.hasOwnProperty.call(e.cause,a)&&(t.cause=s(e.cause));for(let r in e)if(t[r]===void 0){let i=e[r];n(i)?Object.prototype.hasOwnProperty.call(i,a)||(t[r]=s(i)):t[r]=i}return delete e[a],t.raw=e,t}})),bt=z(((e,t)=>{t.exports={mapHttpRequest:a,reqSerializer:i};let n=Symbol(`pino-raw-req-ref`),r=Object.create({},{id:{enumerable:!0,writable:!0,value:``},method:{enumerable:!0,writable:!0,value:``},url:{enumerable:!0,writable:!0,value:``},query:{enumerable:!0,writable:!0,value:``},params:{enumerable:!0,writable:!0,value:``},headers:{enumerable:!0,writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:``},remotePort:{enumerable:!0,writable:!0,value:``},raw:{enumerable:!1,get:function(){return this[n]},set:function(e){this[n]=e}}});Object.defineProperty(r,n,{writable:!0,value:{}});function i(e){let t=e.info||e.socket,n=Object.create(r);if(n.id=typeof e.id==`function`?e.id():e.id||(e.info?e.info.id:void 0),n.method=e.method,e.originalUrl)n.url=e.originalUrl;else{let t=e.path;n.url=typeof t==`string`?t:e.url?e.url.path||e.url:void 0}return e.query&&(n.query=e.query),e.params&&(n.params=e.params),n.headers=e.headers,n.remoteAddress=t&&t.remoteAddress,n.remotePort=t&&t.remotePort,n.raw=e.raw||e,n}function a(e){return{req:i(e)}}})),xt=z(((e,t)=>{t.exports={mapHttpResponse:a,resSerializer:i};let n=Symbol(`pino-raw-res-ref`),r=Object.create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:``},raw:{enumerable:!1,get:function(){return this[n]},set:function(e){this[n]=e}}});Object.defineProperty(r,n,{writable:!0,value:{}});function i(e){let t=Object.create(r);return t.statusCode=e.headersSent?e.statusCode:null,t.headers=e.getHeaders?e.getHeaders():e._headers,t.raw=e,t}function a(e){return{res:i(e)}}})),St=z(((e,t)=>{let n=vt(),r=yt(),i=bt(),a=xt();t.exports={err:n,errWithCause:r,mapHttpRequest:i.mapHttpRequest,mapHttpResponse:a.mapHttpResponse,req:i.reqSerializer,res:a.resSerializer,wrapErrorSerializer:function(e){return e===n?e:function(t){return e(n(t))}},wrapRequestSerializer:function(e){return e===i.reqSerializer?e:function(t){return e(i.reqSerializer(t))}},wrapResponseSerializer:function(e){return e===a.resSerializer?e:function(t){return e(a.resSerializer(t))}}}})),Ct=z(((e,t)=>{function n(e,t){return t}t.exports=function(){let e=Error.prepareStackTrace;Error.prepareStackTrace=n;let t=Error().stack;if(Error.prepareStackTrace=e,!Array.isArray(t))return;let r=t.slice(2),i=[];for(let e of r)e&&i.push(e.getFileName());return i}})),wt=z(((e,t)=>{function n(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Array){let t=[];for(let r=0;r<e.length;r++)t[r]=n(e[r]);return t}if(typeof e==`object`){let t=Object.create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=n(e[r]));return t}return e}function r(e){let t=[],n=``,r=!1,i=!1,a=``;for(let o=0;o<e.length;o++){let s=e[o];!r&&s===`.`?n&&=(t.push(n),``):s===`[`?(n&&=(t.push(n),``),r=!0):s===`]`&&r?(t.push(n),n=``,r=!1,i=!1):(s===`"`||s===`'`)&&r?i?s===a?(i=!1,a=``):n+=s:(i=!0,a=s):n+=s}return n&&t.push(n),t}function i(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];if(typeof r!=`object`||!r||!(n in r)||typeof r[n]!=`object`||r[n]===null)return!1;r=r[n]}let i=t[t.length-1];if(i===`*`){if(Array.isArray(r))for(let e=0;e<r.length;e++)r[e]=n;else if(typeof r==`object`&&r)for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&(r[e]=n)}else typeof r==`object`&&r&&i in r&&Object.prototype.hasOwnProperty.call(r,i)&&(r[i]=n);return!0}function a(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(typeof n!=`object`||!n||!(r in n)||typeof n[r]!=`object`||n[r]===null)return!1;n=n[r]}let r=t[t.length-1];if(r===`*`){if(Array.isArray(n))for(let e=0;e<n.length;e++)n[e]=void 0;else if(typeof n==`object`&&n)for(let e in n)Object.prototype.hasOwnProperty.call(n,e)&&delete n[e]}else typeof n==`object`&&n&&r in n&&Object.prototype.hasOwnProperty.call(n,r)&&delete n[r];return!0}let o=Symbol(`PATH_NOT_FOUND`);function s(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||!n||!(e in n))return o;n=n[e]}return n}function c(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||!n)return;n=n[e]}return n}function l(e,t,n,c=!1){for(let l of t){let t=r(l);if(t.includes(`*`))u(e,t,n,l,c);else if(c)a(e,t);else{let r=s(e,t);if(r===o)continue;i(e,t,typeof n==`function`?n(r,t):n)}}}function u(e,t,n,r,i=!1){let a=t.indexOf(`*`);if(a===t.length-1){let r=t.slice(0,-1),a=e;for(let e of r){if(typeof a!=`object`||!a||!a)return;a=a[e]}if(Array.isArray(a))if(i)for(let e=0;e<a.length;e++)a[e]=void 0;else for(let e=0;e<a.length;e++){let t=[...r,e.toString()],i=typeof n==`function`?n(a[e],t):n;a[e]=i}else if(typeof a==`object`&&a)if(i){let e=[];for(let t in a)Object.prototype.hasOwnProperty.call(a,t)&&e.push(t);for(let t of e)delete a[t]}else for(let e in a){let t=[...r,e],i=typeof n==`function`?n(a[e],t):n;a[e]=i}}else d(e,t,n,a,r,i)}function d(e,t,n,r,o,s=!1){let l=t.slice(0,r),d=t.slice(r+1),f=[];function p(e,t){if(t===l.length){if(Array.isArray(e))for(let n=0;n<e.length;n++)f[t]=n.toString(),p(e[n],t+1);else if(typeof e==`object`&&e)for(let n in e)f[t]=n,p(e[n],t+1)}else if(t<l.length){let n=l[t];e&&typeof e==`object`&&e&&n in e&&(f[t]=n,p(e[n],t+1))}else d.includes(`*`)?u(e,d,typeof n==`function`?(e,r)=>n(e,[...f.slice(0,t),...r]):n,o,s):s?a(e,d):i(e,d,typeof n==`function`?n(c(e,d),[...f.slice(0,t),...d]):n)}if(l.length===0)p(e,0);else{let t=e;for(let e=0;e<l.length;e++){let n=l[e];if(typeof t!=`object`||!t||!t)return;t=t[n],f[e]=n}t!=null&&p(t,l.length)}}function f(e){if(e.length===0)return null;let t=new Map;for(let n of e){let e=r(n),i=t;for(let t=0;t<e.length;t++){let n=e[t];i.has(n)||i.set(n,new Map),i=i.get(n)}}return t}function p(e,t){if(!t)return e;function n(e,t,r=0){if(!t||t.size===0||typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let r=[];for(let i=0;i<e.length;i++){let a=i.toString();t.has(a)||t.has(`*`)?r[i]=n(e[i],t.get(a)||t.get(`*`)):r[i]=e[i]}return r}let i=Object.create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t.has(r)||t.has(`*`)?i[r]=n(e[r],t.get(r)||t.get(`*`)):i[r]=e[r]);return i}return n(e,t)}function m(e){if(typeof e!=`string`)throw Error(`Paths must be (non-empty) strings`);if(e===``)throw Error(`Invalid redaction path ()`);if(e.includes(`..`)||e.includes(`,`))throw Error(`Invalid redaction path (${e})`);let t=0,n=!1,r=``;for(let i=0;i<e.length;i++){let a=e[i];if((a===`"`||a===`'`)&&t>0)n?a===r&&(n=!1,r=``):(n=!0,r=a);else if(a===`[`&&!n)t++;else if(a===`]`&&!n&&(t--,t<0))throw Error(`Invalid redaction path (${e})`)}if(t!==0)throw Error(`Invalid redaction path (${e})`)}function h(e){if(!Array.isArray(e))throw TypeError(`paths must be an array`);for(let t of e)m(t)}function g(e={}){let{paths:t=[],censor:r=`[REDACTED]`,serialize:i=JSON.stringify,strict:a=!0,remove:o=!1}=e;h(t);let s=f(t);return function(e){if(a&&(typeof e!=`object`||!e)&&(typeof e!=`object`||!e))return i?i(e):e;let c=p(e,s),u=e,d=r;return typeof r==`function`&&(d=r),l(c,t,d,o),i===!1?(c.restore=function(){return n(u)},c):typeof i==`function`?i(c):JSON.stringify(c)}}t.exports=g})),Tt=z(((e,t)=>{let n=Symbol(`pino.setLevel`),r=Symbol(`pino.getLevel`),i=Symbol(`pino.levelVal`),a=Symbol(`pino.levelComp`),o=Symbol(`pino.useLevelLabels`),s=Symbol(`pino.useOnlyCustomLevels`),c=Symbol(`pino.mixin`),l=Symbol(`pino.lsCache`),u=Symbol(`pino.chindings`),d=Symbol(`pino.asJson`),f=Symbol(`pino.write`),p=Symbol(`pino.redactFmt`),m=Symbol(`pino.time`),h=Symbol(`pino.timeSliceIndex`),g=Symbol(`pino.stream`),_=Symbol(`pino.stringify`),v=Symbol(`pino.stringifySafe`),y=Symbol(`pino.stringifiers`),b=Symbol(`pino.end`),x=Symbol(`pino.formatOpts`),S=Symbol(`pino.messageKey`),C=Symbol(`pino.errorKey`),w=Symbol(`pino.nestedKey`),T=Symbol(`pino.nestedKeyStr`),E=Symbol(`pino.mixinMergeStrategy`),D=Symbol(`pino.msgPrefix`),O=Symbol(`pino.wildcardFirst`),k=Symbol.for(`pino.serializers`),A=Symbol.for(`pino.formatters`),j=Symbol.for(`pino.hooks`);t.exports={setLevelSym:n,getLevelSym:r,levelValSym:i,levelCompSym:a,useLevelLabelsSym:o,mixinSym:c,lsCacheSym:l,chindingsSym:u,asJsonSym:d,writeSym:f,serializersSym:k,redactFmtSym:p,timeSym:m,timeSliceIndexSym:h,streamSym:g,stringifySym:_,stringifySafeSym:v,stringifiersSym:y,endSym:b,formatOptsSym:x,messageKeySym:S,errorKeySym:C,nestedKeySym:w,wildcardFirstSym:O,needsMetadataGsym:Symbol.for(`pino.metadata`),useOnlyCustomLevelsSym:s,formattersSym:A,hooksSym:j,nestedKeyStrSym:T,mixinMergeStrategySym:E,msgPrefixSym:D}})),Et=z(((e,t)=>{let n=wt(),{redactFmtSym:r,wildcardFirstSym:i}=Tt(),a=/[^.[\]]+|\[([^[\]]*?)\]/g,o=`[Redacted]`;function s(e,t){let{paths:o,censor:s,remove:l}=c(e),u=o.reduce((e,t)=>{a.lastIndex=0;let n=a.exec(t),r=a.exec(t),o=n[1]===void 0?n[0]:n[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,`$1`);if(o===`*`&&(o=i),r===null)return e[o]=null,e;if(e[o]===null)return e;let{index:s}=r,c=`${t.substr(s,t.length-1)}`;return e[o]=e[o]||[],o!==i&&e[o].length===0&&e[o].push(...e[i]||[]),o===i&&Object.keys(e).forEach(function(t){e[t]&&e[t].push(c)}),e[o].push(c),e},{}),d={[r]:n({paths:o,censor:s,serialize:t,strict:!1,remove:l})},f=(...e)=>t(typeof s==`function`?s(...e):s);return[...Object.keys(u),...Object.getOwnPropertySymbols(u)].reduce((e,r)=>{if(u[r]===null)e[r]=e=>f(e,[r]);else{let i=typeof s==`function`?(e,t)=>s(e,[r,...t]):s;e[r]=n({paths:u[r],censor:i,serialize:t,strict:!1,remove:l})}return e},d)}function c(e){if(Array.isArray(e))return e={paths:e,censor:o},e;let{paths:t,censor:n=o,remove:r}=e;if(Array.isArray(t)===!1)throw Error(`pino – redact must contain an array of strings`);return r===!0&&(n=void 0),{paths:t,censor:n,remove:r}}t.exports=s})),Dt=z(((e,t)=>{let n=()=>``,r=()=>`,"time":${Date.now()}`,i=()=>`,"time":${Math.round(Date.now()/1e3)}`,a=()=>`,"time":"${new Date(Date.now()).toISOString()}"`,o=1000000000n,s=BigInt(Date.now())*1000000n,c=process.hrtime.bigint();t.exports={nullTime:n,epochTime:r,unixTime:i,isoTime:a,isoTimeNano:()=>{let e=s+(process.hrtime.bigint()-c),t=e/o,n=e%o,r=Number(t*1000n+n/1000000n),i=new Date(r);return`,"time":"${i.getUTCFullYear()}-${(i.getUTCMonth()+1).toString().padStart(2,`0`)}-${i.getUTCDate().toString().padStart(2,`0`)}T${i.getUTCHours().toString().padStart(2,`0`)}:${i.getUTCMinutes().toString().padStart(2,`0`)}:${i.getUTCSeconds().toString().padStart(2,`0`)}.${n.toString().padStart(9,`0`)}Z"`}}})),Ot=z(((e,t)=>{function n(e){try{return JSON.stringify(e)}catch{return`"[Circular]"`}}t.exports=r;function r(e,t,r){var i=r&&r.stringify||n,a=1;if(typeof e==`object`&&e){var o=t.length+a;if(o===1)return e;var s=Array(o);s[0]=i(e);for(var c=1;c<o;c++)s[c]=i(t[c]);return s.join(` `)}if(typeof e!=`string`)return e;var l=t.length;if(l===0)return e;for(var u=``,d=1-a,f=-1,p=e&&e.length||0,m=0;m<p;){if(e.charCodeAt(m)===37&&m+1<p){switch(f=f>-1?f:0,e.charCodeAt(m+1)){case 100:case 102:if(d>=l||t[d]==null)break;f<m&&(u+=e.slice(f,m)),u+=Number(t[d]),f=m+2,m++;break;case 105:if(d>=l||t[d]==null)break;f<m&&(u+=e.slice(f,m)),u+=Math.floor(Number(t[d])),f=m+2,m++;break;case 79:case 111:case 106:if(d>=l||t[d]===void 0)break;f<m&&(u+=e.slice(f,m));var h=typeof t[d];if(h===`string`){u+=`'`+t[d]+`'`,f=m+2,m++;break}if(h===`function`){u+=t[d].name||`<anonymous>`,f=m+2,m++;break}u+=i(t[d]),f=m+2,m++;break;case 115:if(d>=l)break;f<m&&(u+=e.slice(f,m)),u+=String(t[d]),f=m+2,m++;break;case 37:f<m&&(u+=e.slice(f,m)),u+=`%`,f=m+2,m++,d--;break}++d}++m}return f===-1?e:(f<p&&(u+=e.slice(f)),u)}})),kt=z(((e,t)=>{if(typeof SharedArrayBuffer<`u`&&typeof Atomics<`u`){let e=new Int32Array(new SharedArrayBuffer(4));function n(t){if(!(t>0&&t<1/0))throw typeof t!=`number`&&typeof t!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);Atomics.wait(e,0,0,Number(t))}t.exports=n}else{function e(e){if(!(e>0&&e<1/0))throw typeof e!=`number`&&typeof e!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);let t=Date.now()+Number(e);for(;t>Date.now(););}t.exports=e}})),At=z(((e,t)=>{let n=B(`fs`),r=B(`events`),i=B(`util`).inherits,a=B(`path`),o=kt(),s=B(`assert`),c=Buffer.allocUnsafe(0),l=`buffer`,u=`utf8`,[d,f]=(process.versions.node||`0.0`).split(`.`).map(Number),p=d>=22&&f>=7;function m(e,t){t._opening=!0,t._writing=!0,t._asyncDrainScheduled=!1;function r(n,r){if(n){t._reopening=!1,t._writing=!1,t._opening=!1,t.sync?process.nextTick(()=>{t.listenerCount(`error`)>0&&t.emit(`error`,n)}):t.emit(`error`,n);return}let i=t._reopening;t.fd=r,t.file=e,t._reopening=!1,t._opening=!1,t._writing=!1,t.sync?process.nextTick(()=>t.emit(`ready`)):t.emit(`ready`),!t.destroyed&&(!t._writing&&t._len>t.minLength||t._flushPending?t._actualWrite():i&&process.nextTick(()=>t.emit(`drain`)))}let i=t.append?`a`:`w`,o=t.mode;if(t.sync)try{t.mkdir&&n.mkdirSync(a.dirname(e),{recursive:!0}),r(null,n.openSync(e,i,o))}catch(e){throw r(e),e}else t.mkdir?n.mkdir(a.dirname(e),{recursive:!0},t=>{if(t)return r(t);n.open(e,i,o,r)}):n.open(e,i,o,r)}function h(e){if(!(this instanceof h))return new h(e);let{fd:t,dest:r,minLength:i,maxLength:a,maxWrite:s,periodicFlush:d,sync:f,append:p=!0,mkdir:v,retryEAGAIN:x,fsync:k,contentMode:A,mode:j}=e||{};t||=r,this._len=0,this.fd=-1,this._bufs=[],this._lens=[],this._writing=!1,this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._flushPending=!1,this._hwm=Math.max(i||0,16387),this.file=null,this.destroyed=!1,this.minLength=i||0,this.maxLength=a||0,this.maxWrite=s||16384,this._periodicFlush=d||0,this._periodicFlushTimer=void 0,this.sync=f||!1,this.writable=!0,this._fsync=k||!1,this.append=p||!1,this.mode=j,this.retryEAGAIN=x||(()=>!0),this.mkdir=v||!1;let M,N;if(A===l)this._writingBuf=c,this.write=b,this.flush=C,this.flushSync=T,this._actualWrite=D,M=()=>n.writeSync(this.fd,this._writingBuf),N=()=>n.write(this.fd,this._writingBuf,this.release);else if(A===void 0||A===u)this._writingBuf=``,this.write=y,this.flush=S,this.flushSync=w,this._actualWrite=E,M=()=>Buffer.isBuffer(this._writingBuf)?n.writeSync(this.fd,this._writingBuf):n.writeSync(this.fd,this._writingBuf,`utf8`),N=()=>Buffer.isBuffer(this._writingBuf)?n.write(this.fd,this._writingBuf,this.release):n.write(this.fd,this._writingBuf,`utf8`,this.release);else throw Error(`SonicBoom supports "${u}" and "${l}", but passed ${A}`);if(typeof t==`number`)this.fd=t,process.nextTick(()=>this.emit(`ready`));else if(typeof t==`string`)m(t,this);else throw Error(`SonicBoom supports only file descriptors and files`);if(this.minLength>=this.maxWrite)throw Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);this.release=(e,t)=>{if(e){if((e.code===`EAGAIN`||e.code===`EBUSY`)&&this.retryEAGAIN(e,this._writingBuf.length,this._len-this._writingBuf.length))if(this.sync)try{o(100),this.release(void 0,0)}catch(e){this.release(e)}else setTimeout(N,100);else this._writing=!1,this.emit(`error`,e);return}this.emit(`write`,t);let r=g(this._writingBuf,this._len,t);if(this._len=r.len,this._writingBuf=r.writingBuf,this._writingBuf.length){if(!this.sync){N();return}try{do{let e=M(),t=g(this._writingBuf,this._len,e);this._len=t.len,this._writingBuf=t.writingBuf}while(this._writingBuf.length)}catch(e){this.release(e);return}}this._fsync&&n.fsyncSync(this.fd);let i=this._len;this._reopening?(this._writing=!1,this._reopening=!1,this.reopen()):i>this.minLength?this._actualWrite():this._ending?i>0?this._actualWrite():(this._writing=!1,O(this)):(this._writing=!1,this.sync?this._asyncDrainScheduled||(this._asyncDrainScheduled=!0,process.nextTick(_,this)):this.emit(`drain`))},this.on(`newListener`,function(e){e===`drain`&&(this._asyncDrainScheduled=!1)}),this._periodicFlush!==0&&(this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush),this._periodicFlushTimer.unref())}function g(e,t,n){return typeof e==`string`&&(e=Buffer.from(e)),t=Math.max(t-n,0),e=e.subarray(n),{writingBuf:e,len:t}}function _(e){e.listenerCount(`drain`)>0&&(e._asyncDrainScheduled=!1,e.emit(`drain`))}i(h,r);function v(e,t){return e.length===0?c:e.length===1?e[0]:Buffer.concat(e,t)}function y(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);e=``+e;let t=Buffer.byteLength(e),n=this._len+t,r=this._bufs;return this.maxLength&&n>this.maxLength?(this.emit(`drop`,e),this._len<this._hwm):(r.length===0||Buffer.byteLength(r[r.length-1])+t>this.maxWrite?r.push(e):r[r.length-1]+=e,this._len=n,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function b(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);let t=this._len+e.length,n=this._bufs,r=this._lens;return this.maxLength&&t>this.maxLength?(this.emit(`drop`,e),this._len<this._hwm):(n.length===0||r[r.length-1]+e.length>this.maxWrite?(n.push([e]),r.push(e.length)):(n[n.length-1].push(e),r[r.length-1]+=e.length),this._len=t,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function x(e){this._flushPending=!0;let t=()=>{if(this._fsync)this._flushPending=!1,e();else try{n.fsync(this.fd,t=>{this._flushPending=!1,e(t)})}catch(t){e(t)}this.off(`error`,r)},r=n=>{this._flushPending=!1,e(n),this.off(`drain`,t)};this.once(`drain`,t),this.once(`error`,r)}function S(e){if(e!=null&&typeof e!=`function`)throw Error(`flush cb must be a function`);if(this.destroyed){let t=Error(`SonicBoom destroyed`);if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&x.call(this,e),!this._writing&&(this._bufs.length===0&&this._bufs.push(``),this._actualWrite())}function C(e){if(e!=null&&typeof e!=`function`)throw Error(`flush cb must be a function`);if(this.destroyed){let t=Error(`SonicBoom destroyed`);if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&x.call(this,e),!this._writing&&(this._bufs.length===0&&(this._bufs.push([]),this._lens.push(0)),this._actualWrite())}h.prototype.reopen=function(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this._opening){this.once(`ready`,()=>{this.reopen(e)});return}if(this._ending)return;if(!this.file)throw Error(`Unable to reopen a file descriptor, you must pass a file to SonicBoom`);if(e&&(this.file=e),this._reopening=!0,this._writing)return;let t=this.fd;this.once(`ready`,()=>{t!==this.fd&&n.close(t,e=>{if(e)return this.emit(`error`,e)})}),m(this.file,this)},h.prototype.end=function(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this._opening){this.once(`ready`,()=>{this.end()});return}this._ending||(this._ending=!0,!this._writing&&(this._len>0&&this.fd>=0?this._actualWrite():O(this)))};function w(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this.fd<0)throw Error(`sonic boom is not ready yet`);!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift(this._writingBuf),this._writingBuf=``);let e=``;for(;this._bufs.length||e.length;){e.length<=0&&(e=this._bufs[0]);try{let t=Buffer.isBuffer(e)?n.writeSync(this.fd,e):n.writeSync(this.fd,e,`utf8`),r=g(e,this._len,t);e=r.writingBuf,this._len=r.len,e.length<=0&&this._bufs.shift()}catch(t){if((t.code===`EAGAIN`||t.code===`EBUSY`)&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;o(100)}}try{n.fsyncSync(this.fd)}catch{}}function T(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this.fd<0)throw Error(`sonic boom is not ready yet`);!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift([this._writingBuf]),this._writingBuf=c);let e=c;for(;this._bufs.length||e.length;){e.length<=0&&(e=v(this._bufs[0],this._lens[0]));try{let t=n.writeSync(this.fd,e);e=e.subarray(t),this._len=Math.max(this._len-t,0),e.length<=0&&(this._bufs.shift(),this._lens.shift())}catch(t){if((t.code===`EAGAIN`||t.code===`EBUSY`)&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;o(100)}}}h.prototype.destroy=function(){this.destroyed||O(this)};function E(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:this._bufs.shift()||``,this.sync)try{e(null,Buffer.isBuffer(this._writingBuf)?n.writeSync(this.fd,this._writingBuf):n.writeSync(this.fd,this._writingBuf,`utf8`))}catch(t){e(t)}else n.write(this.fd,this._writingBuf,e)}function D(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:v(this._bufs.shift(),this._lens.shift()),this.sync)try{e(null,n.writeSync(this.fd,this._writingBuf))}catch(t){e(t)}else p&&(this._writingBuf=Buffer.from(this._writingBuf)),n.write(this.fd,this._writingBuf,e)}function O(e){if(e.fd===-1){e.once(`ready`,O.bind(null,e));return}e._periodicFlushTimer!==void 0&&clearInterval(e._periodicFlushTimer),e.destroyed=!0,e._bufs=[],e._lens=[],s(typeof e.fd==`number`,`sonic.fd must be a number, got ${typeof e.fd}`);try{n.fsync(e.fd,t)}catch{}function t(){e.fd!==1&&e.fd!==2?n.close(e.fd,r):r()}function r(t){if(t){e.emit(`error`,t);return}e._ending&&!e._writing&&e.emit(`finish`),e.emit(`close`)}}h.SonicBoom=h,h.default=h,t.exports=h})),jt=z(((e,t)=>{let n={exit:[],beforeExit:[]},r={exit:c,beforeExit:l},i;function a(){i===void 0&&(i=new FinalizationRegistry(d))}function o(e){n[e].length>0||process.on(e,r[e])}function s(e){n[e].length>0||(process.removeListener(e,r[e]),n.exit.length===0&&n.beforeExit.length===0&&(i=void 0))}function c(){u(`exit`)}function l(){u(`beforeExit`)}function u(e){for(let t of n[e]){let n=t.deref(),r=t.fn;n!==void 0&&r(n,e)}n[e]=[]}function d(e){for(let t of[`exit`,`beforeExit`]){let r=n[t].indexOf(e);n[t].splice(r,r+1),s(t)}}function f(e,t,r){if(t===void 0)throw Error(`the object can't be undefined`);o(e);let s=new WeakRef(t);s.fn=r,a(),i.register(t,s),n[e].push(s)}function p(e,t){f(`exit`,e,t)}function m(e,t){f(`beforeExit`,e,t)}function h(e){if(i!==void 0){i.unregister(e);for(let t of[`exit`,`beforeExit`])n[t]=n[t].filter(t=>{let n=t.deref();return n&&n!==e}),s(t)}}t.exports={register:p,registerBeforeExit:m,unregister:h}})),Mt=z(((e,t)=>{t.exports={name:`thread-stream`,version:`4.0.0`,description:`A streaming way to send data to a Node.js Worker Thread`,main:`index.js`,types:`index.d.ts`,engines:{node:`>=20`},dependencies:{"real-require":`^0.2.0`},devDependencies:{"@types/node":`^22.0.0`,"@yao-pkg/pkg":`^6.0.0`,borp:`^0.21.0`,desm:`^1.3.0`,eslint:`^9.39.1`,fastbench:`^1.0.1`,husky:`^9.0.6`,neostandard:`^0.12.2`,"pino-elasticsearch":`^8.0.0`,"sonic-boom":`^4.0.1`,"ts-node":`^10.8.0`,typescript:`~5.7.3`},scripts:{build:`tsc --noEmit`,lint:`eslint`,test:`npm run lint && npm run build && npm run transpile && borp --pattern 'test/*.test.{js,mjs}'`,"test:ci":`npm run lint && npm run transpile && borp --pattern 'test/*.test.{js,mjs}'`,"test:yarn":`npm run transpile && borp --pattern 'test/*.test.js'`,transpile:`sh ./test/ts/transpile.sh`,prepare:`husky install`},repository:{type:`git`,url:`git+https://github.com/mcollina/thread-stream.git`},keywords:[`worker`,`thread`,`threads`,`stream`],author:`Matteo Collina <hello@matteocollina.com>`,license:`MIT`,bugs:{url:`https://github.com/mcollina/thread-stream/issues`},homepage:`https://github.com/mcollina/thread-stream#readme`}})),Nt=z(((e,t)=>{let n=1e4;function r(e,t,r,i,a){let o=i===1/0?1/0:Date.now()+i,s=()=>{let i=Atomics.load(e,t);if(i===r){a(null,`ok`);return}if(o!==1/0&&Date.now()>o){a(null,`timed-out`);return}let c=o===1/0?n:Math.min(n,Math.max(1,o-Date.now())),l=Atomics.waitAsync(e,t,i,c);l.async?l.value.then(s):setImmediate(s)};s()}function i(e,t,r,i,a){let o=i===1/0?1/0:Date.now()+i,s=()=>{if(Atomics.load(e,t)!==r){a(null,`ok`);return}if(o!==1/0&&Date.now()>o){a(null,`timed-out`);return}let i=o===1/0?n:Math.min(n,Math.max(1,o-Date.now())),c=Atomics.waitAsync(e,t,r,i);c.async?c.value.then(s):setImmediate(s)};s()}t.exports={wait:r,waitDiff:i}})),Pt=z(((e,t)=>{t.exports={WRITE_INDEX:4,READ_INDEX:8}})),Ft=z(((e,t)=>{let{version:n}=Mt(),{EventEmitter:r}=B(`events`),{Worker:i}=B(`worker_threads`),{join:a}=B(`path`),{pathToFileURL:o}=B(`url`),{wait:s}=Nt(),{WRITE_INDEX:c,READ_INDEX:l}=Pt(),u=B(`buffer`),d=B(`assert`),f=Symbol(`kImpl`),p=u.constants.MAX_STRING_LENGTH;var m=class{constructor(e){this._value=e}deref(){return this._value}},h=class{register(){}unregister(){}};let g=process.env.NODE_V8_COVERAGE?h:global.FinalizationRegistry||h,_=process.env.NODE_V8_COVERAGE?m:global.WeakRef||m,v=new g(e=>{e.exited||e.terminate()});function y(e,t){let{filename:r,workerData:s}=t,c=new i((`__bundlerPathsOverrides`in globalThis?globalThis.__bundlerPathsOverrides:{})[`thread-stream-worker`]||a(__dirname,`lib`,`worker.js`),{...t.workerOpts,trackUnmanagedFds:!1,workerData:{filename:r.indexOf(`file://`)===0?r:o(r).href,dataBuf:e[f].dataBuf,stateBuf:e[f].stateBuf,workerData:{$context:{threadStreamVersion:n},...s}}});return c.stream=new m(e),c.on(`message`,S),c.on(`exit`,C),v.register(e,c),c}function b(e){d(!e[f].sync),e[f].needDrain&&(e[f].needDrain=!1,e.emit(`drain`))}function x(e){let t=Atomics.load(e[f].state,c),n=e[f].data.length-t;if(n>0){if(e[f].buf.length===0){e[f].flushing=!1,e[f].ending?O(e):e[f].needDrain&&process.nextTick(b,e);return}let t=e[f].buf.slice(0,n),r=Buffer.byteLength(t);r<=n?(e[f].buf=e[f].buf.slice(n),D(e,t,x.bind(null,e))):e.flush(()=>{if(!e.destroyed){for(Atomics.store(e[f].state,l,0),Atomics.store(e[f].state,c,0),Atomics.notify(e[f].state,l);r>e[f].data.length;)n/=2,t=e[f].buf.slice(0,n),r=Buffer.byteLength(t);e[f].buf=e[f].buf.slice(n),D(e,t,x.bind(null,e))}})}else if(n===0){if(t===0&&e[f].buf.length===0)return;e.flush(()=>{Atomics.store(e[f].state,l,0),Atomics.store(e[f].state,c,0),Atomics.notify(e[f].state,l),x(e)})}else E(e,Error(`overwritten`))}function S(e){let t=this.stream.deref();if(t===void 0){this.exited=!0,this.terminate();return}switch(e.code){case`READY`:this.stream=new _(t),t.flush(()=>{t[f].ready=!0,t.emit(`ready`)});break;case`ERROR`:E(t,e.err);break;case`EVENT`:Array.isArray(e.args)?t.emit(e.name,...e.args):t.emit(e.name,e.args);break;case`WARNING`:process.emitWarning(e.err);break;default:E(t,Error(`this should not happen: `+e.code))}}function C(e){let t=this.stream.deref();t!==void 0&&(v.unregister(t),t.worker.exited=!0,t.worker.off(`exit`,C),E(t,e===0?null:Error(`the worker thread exited`)))}var w=class extends r{constructor(e={}){if(super(),e.bufferSize<4)throw Error(`bufferSize must at least fit a 4-byte utf-8 char`);this[f]={},this[f].stateBuf=new SharedArrayBuffer(128),this[f].state=new Int32Array(this[f].stateBuf),this[f].dataBuf=new SharedArrayBuffer(e.bufferSize||4*1024*1024),this[f].data=Buffer.from(this[f].dataBuf),this[f].sync=e.sync||!1,this[f].ending=!1,this[f].ended=!1,this[f].needDrain=!1,this[f].destroyed=!1,this[f].flushing=!1,this[f].ready=!1,this[f].finished=!1,this[f].errored=null,this[f].closed=!1,this[f].buf=``,this.worker=y(this,e),this.on(`message`,(e,t)=>{this.worker.postMessage(e,t)})}write(e){if(this[f].destroyed)return T(this,Error(`the worker has exited`)),!1;if(this[f].ending)return T(this,Error(`the worker is ending`)),!1;if(this[f].flushing&&this[f].buf.length+e.length>=p)try{k(this),this[f].flushing=!0}catch(e){return E(this,e),!1}if(this[f].buf+=e,this[f].sync)try{return k(this),!0}catch(e){return E(this,e),!1}return this[f].flushing||(this[f].flushing=!0,setImmediate(x,this)),this[f].needDrain=this[f].data.length-this[f].buf.length-Atomics.load(this[f].state,c)<=0,!this[f].needDrain}end(){this[f].destroyed||(this[f].ending=!0,O(this))}flush(e){if(this[f].destroyed){typeof e==`function`&&process.nextTick(e,Error(`the worker has exited`));return}let t=Atomics.load(this[f].state,c);s(this[f].state,l,t,1/0,(t,n)=>{if(t){E(this,t),process.nextTick(e,t);return}if(n===`not-equal`){this.flush(e);return}process.nextTick(e)})}flushSync(){this[f].destroyed||(k(this),A(this))}unref(){this.worker.unref()}ref(){this.worker.ref()}get ready(){return this[f].ready}get destroyed(){return this[f].destroyed}get closed(){return this[f].closed}get writable(){return!this[f].destroyed&&!this[f].ending}get writableEnded(){return this[f].ending}get writableFinished(){return this[f].finished}get writableNeedDrain(){return this[f].needDrain}get writableObjectMode(){return!1}get writableErrored(){return this[f].errored}};function T(e,t){setImmediate(()=>{e.emit(`error`,t)})}function E(e,t){e[f].destroyed||(e[f].destroyed=!0,t&&(e[f].errored=t,T(e,t)),e.worker.exited?setImmediate(()=>{e[f].closed=!0,e.emit(`close`)}):e.worker.terminate().catch(()=>{}).then(()=>{e[f].closed=!0,e.emit(`close`)}))}function D(e,t,n){let r=Atomics.load(e[f].state,c),i=Buffer.byteLength(t);return e[f].data.write(t,r),Atomics.store(e[f].state,c,r+i),Atomics.notify(e[f].state,c),n(),!0}function O(e){if(!(e[f].ended||!e[f].ending||e[f].flushing)){e[f].ended=!0;try{e.flushSync();let t=Atomics.load(e[f].state,l);Atomics.store(e[f].state,c,-1),Atomics.notify(e[f].state,c);let n=0;for(;t!==-1;){if(Atomics.wait(e[f].state,l,t,1e3),t=Atomics.load(e[f].state,l),t===-2){E(e,Error(`end() failed`));return}if(++n===10){E(e,Error(`end() took too long (10s)`));return}}process.nextTick(()=>{e[f].finished=!0,e.emit(`finish`)})}catch(t){E(e,t)}}}function k(e){let t=()=>{e[f].ending?O(e):e[f].needDrain&&process.nextTick(b,e)};for(e[f].flushing=!1;e[f].buf.length!==0;){let n=Atomics.load(e[f].state,c),r=e[f].data.length-n;if(r===0){A(e),Atomics.store(e[f].state,l,0),Atomics.store(e[f].state,c,0),Atomics.notify(e[f].state,l);continue}else if(r<0)throw Error(`overwritten`);let i=e[f].buf.slice(0,r),a=Buffer.byteLength(i);if(a<=r)e[f].buf=e[f].buf.slice(r),D(e,i,t);else{for(A(e),Atomics.store(e[f].state,l,0),Atomics.store(e[f].state,c,0),Atomics.notify(e[f].state,l);a>e[f].buf.length;)r/=2,i=e[f].buf.slice(0,r),a=Buffer.byteLength(i);e[f].buf=e[f].buf.slice(r),D(e,i,t)}}}function A(e){if(e[f].flushing)throw Error(`unable to flush while flushing`);let t=Atomics.load(e[f].state,c),n=0;for(;;){let r=Atomics.load(e[f].state,l);if(r===-2)throw Error(`_flushSync failed`);if(r!==t)Atomics.wait(e[f].state,l,r,1e3);else break;if(++n===10)throw Error(`_flushSync took too long (10s)`)}}t.exports=w})),It=z(((e,t)=>{let{createRequire:n}=B(`module`),{existsSync:r}=B(`node:fs`),i=Ct(),{join:a,isAbsolute:o,sep:s}=B(`node:path`),{fileURLToPath:c}=B(`node:url`),l=kt(),u=jt(),d=Ft();function f(e){u.register(e,v),u.registerBeforeExit(e,y),e.on(`close`,function(){u.unregister(e)})}function p(){let e=process.execArgv;for(let t=0;t<e.length;t++){let n=e[t];if(n===`--import`||n===`--require`||n===`-r`||n.startsWith(`--import=`)||n.startsWith(`--require=`)||n.startsWith(`-r=`))return!0}return!1}function m(e){let t=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);if(!t)return e;let n=[],r=!1;for(let e=0;e<t.length;e++){let i=t[e];if(i===`--require`||i===`-r`||i===`--import`){let a=t[e+1];if(a&&h(a)){r=!0,e++;continue}n.push(i),a&&(n.push(a),e++);continue}if((i.startsWith(`--require=`)||i.startsWith(`-r=`)||i.startsWith(`--import=`))&&h(i.slice(i.indexOf(`=`)+1))){r=!0;continue}n.push(i)}return r?n.join(` `):e}function h(e){let t=g(e);if(!t)return!1;let n=t;if(n.startsWith(`file://`))try{n=c(n)}catch{return!1}return o(n)&&!r(n)}function g(e){let t=e[0],n=e[e.length-1];return t===`"`&&n===`"`||t===`'`&&n===`'`?e.slice(1,-1):e}function _(e,t,n,r,i){if(!n.execArgv&&p()&&B.main===void 0&&(n={...n,execArgv:[]}),!n.env&&process.env.NODE_OPTIONS){let e=m(process.env.NODE_OPTIONS);e!==process.env.NODE_OPTIONS&&(n={...n,env:{...process.env,NODE_OPTIONS:e}})}n={...n,name:i};let a=new d({filename:e,workerData:t,workerOpts:n,sync:r});a.on(`ready`,o),a.on(`close`,function(){process.removeListener(`exit`,s)}),process.on(`exit`,s);function o(){process.removeListener(`exit`,s),a.unref(),n.autoEnd!==!1&&f(a)}function s(){a.closed||(a.flushSync(),l(100),a.end())}return a}function v(e){e.ref(),e.flushSync(),e.end(),e.once(`close`,function(){e.unref()})}function y(e){e.flushSync()}function b(e){let{pipeline:t,targets:r,levels:c,dedupe:l,worker:u={},caller:d=i(),sync:f=!1}=e,p={...e.options},m=typeof d==`string`?[d]:d,h=typeof globalThis==`object`&&Object.prototype.hasOwnProperty.call(globalThis,`__bundlerPathsOverrides`)&&globalThis.__bundlerPathsOverrides&&typeof globalThis.__bundlerPathsOverrides==`object`?globalThis.__bundlerPathsOverrides:Object.create(null),g=e.target;if(g&&r)throw Error(`only one of target or targets can be specified`);r?(g=h[`pino-worker`]||a(__dirname,`worker.js`),p.targets=r.filter(e=>e.target).map(e=>({...e,target:y(e.target)})),p.pipelines=r.filter(e=>e.pipeline).map(e=>e.pipeline.map(t=>({...t,level:e.level,target:y(t.target)})))):t&&(g=h[`pino-worker`]||a(__dirname,`worker.js`),p.pipelines=[t.map(e=>({...e,target:y(e.target)}))]),c&&(p.levels=c),l&&(p.dedupe=l),p.pinoWillSendConfig=!0;let v=r||t?`pino.transport`:g;return _(y(g),p,u,f,v);function y(e){if(e=h[e]||e,o(e)||e.indexOf(`file://`)===0)return e;if(e===`pino/file`)return a(__dirname,`..`,`file.js`);let t;for(let r of m)try{t=n(r===`node:repl`?process.cwd()+s:r).resolve(e);break}catch{continue}if(!t)throw Error(`unable to determine transport target for "${e}"`);return t}}t.exports=b})),Lt=z(((e,t)=>{let n=B(`node:diagnostics_channel`),r=Ot(),{mapHttpRequest:i,mapHttpResponse:a}=St(),o=At(),s=jt(),{lsCacheSym:c,chindingsSym:l,writeSym:u,serializersSym:d,formatOptsSym:f,endSym:p,stringifiersSym:m,stringifySym:h,stringifySafeSym:g,wildcardFirstSym:_,nestedKeySym:v,formattersSym:y,messageKeySym:b,errorKeySym:x,nestedKeyStrSym:S,msgPrefixSym:C}=Tt(),{isMainThread:w}=B(`worker_threads`),T=It(),[E]=process.versions.node.split(`.`).map(e=>Number(e)),D=n.tracingChannel(`pino_asJson`),O=E>=25?e=>JSON.stringify(e):j;function k(){}function A(e,t){if(!t)return n;return function(...r){t.call(this,r,n,e)};function n(t,...n){if(typeof t==`object`){let o=t;t!==null&&(t.method&&t.headers&&t.socket?t=i(t):typeof t.setHeader==`function`&&(t=a(t)));let s;o===null&&n.length===0?s=[null]:(o=n.shift(),s=n),typeof this[C]==`string`&&o!=null&&(o=this[C]+o),this[u](t,r(o,s,this[f]),e)}else{let i=t===void 0?n.shift():t;typeof this[C]==`string`&&i!=null&&(i=this[C]+i),this[u](null,r(i,n,this[f]),e)}}}function j(e){let t=``,n=0,r=!1,i=255,a=e.length;if(a>100)return JSON.stringify(e);for(var o=0;o<a&&i>=32;o++)i=e.charCodeAt(o),(i===34||i===92)&&(t+=e.slice(n,o)+`\\`,n=o,r=!0);return r?t+=e.slice(n):t=e,i<32?JSON.stringify(e):`"`+t+`"`}function M(e,t,n,r){if(D.hasSubscribers===!1)return N.call(this,e,t,n,r);let i={instance:this,arguments};return D.traceSync(N,i,this,e,t,n,r)}function N(e,t,n,r){let i=this[h],a=this[g],o=this[m],s=this[p],u=this[l],f=this[d],C=this[y],w=this[b],T=this[x],E=this[c][n]+r;E+=u;let D;C.log&&(e=C.log(e));let k=o[_],A=``;for(let t in e)if(D=e[t],Object.prototype.hasOwnProperty.call(e,t)&&D!==void 0){f[t]?D=f[t](D):t===T&&f.err&&(D=f.err(D));let e=o[t]||k;switch(typeof D){case`undefined`:case`function`:continue;case`number`:Number.isFinite(D)===!1&&(D=null);case`boolean`:e&&(D=e(D));break;case`string`:D=(e||O)(D);break;default:D=(e||i)(D,a)}if(D===void 0)continue;let n=O(t);A+=`,`+n+`:`+D}let j=``;if(t!==void 0){D=f[w]?f[w](t):t;let e=o[w]||k;switch(typeof D){case`function`:break;case`number`:Number.isFinite(D)===!1&&(D=null);case`boolean`:e&&(D=e(D)),j=`,"`+w+`":`+D;break;case`string`:D=(e||O)(D),j=`,"`+w+`":`+D;break;default:D=(e||i)(D,a),j=`,"`+w+`":`+D}}return this[v]&&A?E+this[S]+A.slice(1)+`}`+j+s:E+A+j+s}function P(e,t){let n,r=e[l],i=e[h],a=e[g],o=e[m],s=o[_],c=e[d],u=e[y].bindings;t=u(t);for(let e in t)if(n=t[e],((e.length<5||e!==`level`&&e!==`serializers`&&e!==`formatters`&&e!==`customLevels`)&&t.hasOwnProperty(e)&&n!==void 0)===!0){if(n=c[e]?c[e](n):n,n=(o[e]||s||i)(n,a),n===void 0)continue;r+=`,"`+e+`":`+n}return r}function ee(e){return e.write!==e.constructor.prototype.write}function F(e){let t=new o(e);return t.on(`error`,n),!e.sync&&w&&(s.register(t,I),t.on(`close`,function(){s.unregister(t)})),t;function n(e){if(e.code===`EPIPE`){t.write=k,t.end=k,t.flushSync=k,t.destroy=k;return}t.removeListener(`error`,n),t.emit(`error`,e)}}function I(e,t){e.destroyed||(t===`beforeExit`?(e.flush(),e.on(`drain`,function(){e.end()})):e.flushSync())}function te(e){return function(t,n,r={},i){if(typeof r==`string`)i=F({dest:r}),r={};else if(typeof i==`string`){if(r&&r.transport)throw Error(`only one of option.transport or stream can be specified`);i=F({dest:i})}else if(r instanceof o||r.writable||r._writableState)i=r,r={};else if(r.transport){if(r.transport instanceof o||r.transport.writable||r.transport._writableState)throw Error(`option.transport do not allow stream, please pass to option directly. e.g. pino(transport)`);if(r.transport.targets&&r.transport.targets.length&&r.formatters&&typeof r.formatters.level==`function`)throw Error(`option.transport.targets do not allow custom level formatters`);let e;r.customLevels&&(e=r.useOnlyCustomLevels?r.customLevels:Object.assign({},r.levels,r.customLevels)),i=T({caller:n,...r.transport,levels:e})}if(r=Object.assign({},e,r),r.serializers=Object.assign({},e.serializers,r.serializers),r.formatters=Object.assign({},e.formatters,r.formatters),r.prettyPrint)throw Error(`prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)`);let{enabled:a,onChild:s}=r;return a===!1&&(r.level=`silent`),s||(r.onChild=k),i||=ee(process.stdout)?process.stdout:F({fd:process.stdout.fd||1}),{opts:r,stream:i}}}function L(e,t){try{return JSON.stringify(e)}catch{try{return(t||this[g])(e)}catch{return`"[unable to serialize, circular reference is too complex to analyze]"`}}}function ne(e,t,n){return{level:e,bindings:t,log:n}}function re(e){let t=Number(e);return typeof e==`string`&&Number.isFinite(t)?t:e===void 0?1:e}t.exports={noop:k,buildSafeSonicBoom:F,asChindings:P,asJson:M,genLog:A,createArgsNormalizer:te,stringify:L,buildFormatters:ne,normalizeDestFileDescriptor:re}})),Rt=z(((e,t)=>{t.exports={DEFAULT_LEVELS:{trace:10,debug:20,info:30,warn:40,error:50,fatal:60},SORTING_ORDER:{ASC:`ASC`,DESC:`DESC`}}})),zt=z(((e,t)=>{let{lsCacheSym:n,levelValSym:r,useOnlyCustomLevelsSym:i,streamSym:a,formattersSym:o,hooksSym:s,levelCompSym:c}=Tt(),{noop:l,genLog:u}=Lt(),{DEFAULT_LEVELS:d,SORTING_ORDER:f}=Rt(),p={fatal:e=>{let t=u(d.fatal,e);return function(...e){let n=this[a];if(t.call(this,...e),typeof n.flushSync==`function`)try{n.flushSync()}catch{}}},error:e=>u(d.error,e),warn:e=>u(d.warn,e),info:e=>u(d.info,e),debug:e=>u(d.debug,e),trace:e=>u(d.trace,e)},m=Object.keys(d).reduce((e,t)=>(e[d[t]]=t,e),{}),h=Object.keys(m).reduce((e,t)=>(e[t]=`{"level":`+Number(t),e),{});function g(e){let t=e[o].level,{labels:r}=e.levels,i={};for(let e in r){let n=t(r[e],Number(e));i[e]=JSON.stringify(n).slice(0,-1)}return e[n]=i,e}function _(e,t){if(t)return!1;switch(e){case`fatal`:case`error`:case`warn`:case`info`:case`debug`:case`trace`:return!0;default:return!1}}function v(e){let{labels:t,values:n}=this.levels;if(typeof e==`number`){if(t[e]===void 0)throw Error(`unknown level value`+e);e=t[e]}if(n[e]===void 0)throw Error(`unknown level `+e);let a=this[r],o=this[r]=n[e],d=this[i],f=this[c],m=this[s].logMethod;for(let e in n){if(f(n[e],o)===!1){this[e]=l;continue}this[e]=_(e,d)?p[e](m):u(n[e],m)}this.emit(`level-change`,e,o,t[a],a,this)}function y(e){let{levels:t,levelVal:n}=this;return t&&t.labels?t.labels[n]:``}function b(e){let{values:t}=this.levels,n=t[e];return n!==void 0&&this[c](n,this[r])}function x(e,t,n){return e===f.DESC?t<=n:t>=n}function S(e){return typeof e==`string`?x.bind(null,e):e}function C(e=null,t=!1){let n=e?Object.keys(e).reduce((t,n)=>(t[e[n]]=n,t),{}):null;return{labels:Object.assign(Object.create(Object.prototype,{Infinity:{value:`silent`}}),t?null:m,n),values:Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),t?null:d,e)}}function w(e,t,n){if(typeof e==`number`){if(![].concat(Object.keys(t||{}).map(e=>t[e]),n?[]:Object.keys(m).map(e=>+e),1/0).includes(e))throw Error(`default level:${e} must be included in custom levels`);return}if(!(e in Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),n?null:d,t)))throw Error(`default level:${e} must be included in custom levels`)}function T(e,t){let{labels:n,values:r}=e;for(let e in t){if(e in r)throw Error(`levels cannot be overridden`);if(t[e]in n)throw Error(`pre-existing level values cannot be used for new levels`)}}function E(e){if(typeof e!=`function`&&!(typeof e==`string`&&Object.values(f).includes(e)))throw Error(`Levels comparison should be one of "ASC", "DESC" or "function" type`)}t.exports={initialLsCache:h,genLsCache:g,levelMethods:p,getLevel:y,setLevel:v,isLevelEnabled:b,mappings:C,assertNoLevelCollisions:T,assertDefaultLevelFound:w,genLevelComparison:S,assertLevelComparison:E}})),Bt=z(((e,t)=>{t.exports={version:`10.3.1`}})),Vt=z(((e,t)=>{let{EventEmitter:n}=B(`node:events`),{lsCacheSym:r,levelValSym:i,setLevelSym:a,getLevelSym:o,chindingsSym:s,mixinSym:c,asJsonSym:l,writeSym:u,mixinMergeStrategySym:d,timeSym:f,timeSliceIndexSym:p,streamSym:m,serializersSym:h,formattersSym:g,errorKeySym:_,messageKeySym:v,useOnlyCustomLevelsSym:y,needsMetadataGsym:b,redactFmtSym:x,stringifySym:S,formatOptsSym:C,stringifiersSym:w,msgPrefixSym:T,hooksSym:E}=Tt(),{getLevel:D,setLevel:O,isLevelEnabled:k,mappings:A,initialLsCache:j,genLsCache:M,assertNoLevelCollisions:N}=zt(),{asChindings:P,asJson:ee,buildFormatters:F,stringify:I,noop:te}=Lt(),{version:L}=Bt(),ne=Et(),re={constructor:class{},child:ae,bindings:oe,setBindings:R,flush:ce,isLevelEnabled:k,version:L,get level(){return this[o]()},set level(e){this[a](e)},get levelVal(){return this[i]},set levelVal(e){throw Error(`levelVal is read-only`)},get msgPrefix(){return this[T]},get[Symbol.toStringTag](){return`Pino`},[r]:j,[u]:se,[l]:ee,[o]:D,[a]:O};Object.setPrototypeOf(re,n.prototype),t.exports=function(){return Object.create(re)};let ie=e=>e;function ae(e,t){if(!e)throw Error(`missing bindings for child Pino`);let n=this[h],r=this[g],i=Object.create(this);if(t==null)return i[g].bindings!==ie&&(i[g]=F(r.level,ie,r.log)),i[s]=P(i,e),this.onChild!==te&&this.onChild(i),i;if(t.hasOwnProperty(`serializers`)===!0){i[h]=Object.create(null);for(let e in n)i[h][e]=n[e];let e=Object.getOwnPropertySymbols(n);for(var o=0;o<e.length;o++){let t=e[o];i[h][t]=n[t]}for(let e in t.serializers)i[h][e]=t.serializers[e];let r=Object.getOwnPropertySymbols(t.serializers);for(var c=0;c<r.length;c++){let e=r[c];i[h][e]=t.serializers[e]}}else i[h]=n;if(t.hasOwnProperty(`formatters`)){let{level:e,bindings:n,log:a}=t.formatters;i[g]=F(e||r.level,n||ie,a||r.log)}else i[g]=F(r.level,ie,r.log);if(t.hasOwnProperty(`customLevels`)===!0&&(N(this.levels,t.customLevels),i.levels=A(t.customLevels,i[y]),M(i)),typeof t.redact==`object`&&t.redact!==null||Array.isArray(t.redact)){i.redact=t.redact;let e=ne(i.redact,I),n={stringify:e[x]};i[S]=I,i[w]=e,i[C]=n}if(typeof t.msgPrefix==`string`&&(i[T]=(this[T]||``)+t.msgPrefix),i[s]=P(i,e),t.level!==void 0&&t.level!==this.level||t.hasOwnProperty(`customLevels`)){let e=t.level||this.level;i[a](e)}return this.onChild(i),i}function oe(){let e=`{${this[s].substr(1)}}`,t=JSON.parse(e);return delete t.pid,delete t.hostname,t}function R(e){let t=P(this,e);this[s]=t}function z(e,t){return Object.assign(t,e)}function se(e,t,n){let r=this[f](),i=this[c],a=this[_],o=this[v],s=this[d]||z,u,h=this[E].streamWrite;e==null?u={}:e instanceof Error?(u={[a]:e},t===void 0&&(t=e.message)):(u=e,t===void 0&&e[o]===void 0&&e[a]&&(t=e[a].message)),i&&(u=s(u,i(u,n,this)));let g=this[l](u,t,n,r),y=this[m];y[b]===!0&&(y.lastLevel=n,y.lastObj=u,y.lastMsg=t,y.lastTime=r.slice(this[p]),y.lastLogger=this),y.write(h?h(g):g)}function ce(e){if(e!=null&&typeof e!=`function`)throw Error(`callback must be a function`);let t=this[m];typeof t.flush==`function`?t.flush(e||te):e&&e()}})),Ht=z(((e,t)=>{let{hasOwnProperty:n}=Object.prototype,r=_();r.configure=_,r.stringify=r,r.default=r,e.stringify=r,e.configure=_,t.exports=r;let i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function a(e){return e.length<5e3&&!i.test(e)?`"${e}"`:JSON.stringify(e)}function o(e,t){if(e.length>200||t)return e.sort(t);for(let t=1;t<e.length;t++){let n=e[t],r=t;for(;r!==0&&e[r-1]>n;)e[r]=e[r-1],r--;e[r]=n}return e}let s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(e){return s.call(e)!==void 0&&e.length!==0}function l(e,t,n){e.length<n&&(n=e.length);let r=t===`,`?``:` `,i=`"0":${r}${e[0]}`;for(let a=1;a<n;a++)i+=`${t}"${a}":${r}${e[a]}`;return i}function u(e){if(n.call(e,`circularValue`)){let t=e.circularValue;if(typeof t==`string`)return`"${t}"`;if(t==null)return t;if(t===Error||t===TypeError)return{toString(){throw TypeError(`Converting circular structure to JSON`)}};throw TypeError(`The "circularValue" argument must be of type string or the value null or undefined`)}return`"[Circular]"`}function d(e){let t;if(n.call(e,`deterministic`)&&(t=e.deterministic,typeof t!=`boolean`&&typeof t!=`function`))throw TypeError(`The "deterministic" argument must be of type boolean or comparator function`);return t===void 0?!0:t}function f(e,t){let r;if(n.call(e,t)&&(r=e[t],typeof r!=`boolean`))throw TypeError(`The "${t}" argument must be of type boolean`);return r===void 0?!0:r}function p(e,t){let r;if(n.call(e,t)){if(r=e[t],typeof r!=`number`)throw TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(r))throw TypeError(`The "${t}" argument must be an integer`);if(r<1)throw RangeError(`The "${t}" argument must be >= 1`)}return r===void 0?1/0:r}function m(e){return e===1?`1 item`:`${e} items`}function h(e){let t=new Set;for(let n of e)(typeof n==`string`||typeof n==`number`)&&t.add(String(n));return t}function g(e){if(n.call(e,`strict`)){let t=e.strict;if(typeof t!=`boolean`)throw TypeError(`The "strict" argument must be of type boolean`);if(t)return e=>{let t=`Object can not safely be stringified. Received type ${typeof e}`;throw typeof e!=`function`&&(t+=` (${e.toString()})`),Error(t)}}}function _(e){e={...e};let t=g(e);t&&(e.bigint===void 0&&(e.bigint=!1),`circularValue`in e||(e.circularValue=Error));let n=u(e),r=f(e,`bigint`),i=d(e),s=typeof i==`function`?i:void 0,_=p(e,`maximumDepth`),v=p(e,`maximumBreadth`);function y(e,l,u,d,f,p){let h=l[e];switch(typeof h==`object`&&h&&typeof h.toJSON==`function`&&(h=h.toJSON(e)),h=d.call(l,e,h),typeof h){case`string`:return a(h);case`object`:{if(h===null)return`null`;if(u.indexOf(h)!==-1)return n;let e=``,t=`,`,r=p;if(Array.isArray(h)){if(h.length===0)return`[]`;if(_<u.length+1)return`"[Array]"`;u.push(h),f!==``&&(p+=f,e+=`\n${p}`,t=`,\n${p}`);let n=Math.min(h.length,v),i=0;for(;i<n-1;i++){let n=y(String(i),h,u,d,f,p);e+=n===void 0?`null`:n,e+=t}let a=y(String(i),h,u,d,f,p);if(e+=a===void 0?`null`:a,h.length-1>v){let n=h.length-v-1;e+=`${t}"... ${m(n)} not stringified"`}return f!==``&&(e+=`\n${r}`),u.pop(),`[${e}]`}let l=Object.keys(h),g=l.length;if(g===0)return`{}`;if(_<u.length+1)return`"[Object]"`;let b=``,x=``;f!==``&&(p+=f,t=`,\n${p}`,b=` `);let S=Math.min(g,v);i&&!c(h)&&(l=o(l,s)),u.push(h);for(let n=0;n<S;n++){let r=l[n],i=y(r,h,u,d,f,p);i!==void 0&&(e+=`${x}${a(r)}:${b}${i}`,x=t)}if(g>v){let n=g-v;e+=`${x}"...":${b}"${m(n)} not stringified"`,x=t}return f!==``&&x.length>1&&(e=`\n${p}${e}\n${r}`),u.pop(),`{${e}}`}case`number`:return isFinite(h)?String(h):t?t(h):`null`;case`boolean`:return h===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(h);default:return t?t(h):void 0}}function b(e,i,o,s,c,l){switch(typeof i==`object`&&i&&typeof i.toJSON==`function`&&(i=i.toJSON(e)),typeof i){case`string`:return a(i);case`object`:{if(i===null)return`null`;if(o.indexOf(i)!==-1)return n;let e=l,t=``,r=`,`;if(Array.isArray(i)){if(i.length===0)return`[]`;if(_<o.length+1)return`"[Array]"`;o.push(i),c!==``&&(l+=c,t+=`\n${l}`,r=`,\n${l}`);let n=Math.min(i.length,v),a=0;for(;a<n-1;a++){let e=b(String(a),i[a],o,s,c,l);t+=e===void 0?`null`:e,t+=r}let u=b(String(a),i[a],o,s,c,l);if(t+=u===void 0?`null`:u,i.length-1>v){let e=i.length-v-1;t+=`${r}"... ${m(e)} not stringified"`}return c!==``&&(t+=`\n${e}`),o.pop(),`[${t}]`}o.push(i);let u=``;c!==``&&(l+=c,r=`,\n${l}`,u=` `);let d=``;for(let e of s){let n=b(e,i[e],o,s,c,l);n!==void 0&&(t+=`${d}${a(e)}:${u}${n}`,d=r)}return c!==``&&d.length>1&&(t=`\n${l}${t}\n${e}`),o.pop(),`{${t}}`}case`number`:return isFinite(i)?String(i):t?t(i):`null`;case`boolean`:return i===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(i);default:return t?t(i):void 0}}function x(e,u,d,f,p){switch(typeof u){case`string`:return a(u);case`object`:{if(u===null)return`null`;if(typeof u.toJSON==`function`){if(u=u.toJSON(e),typeof u!=`object`)return x(e,u,d,f,p);if(u===null)return`null`}if(d.indexOf(u)!==-1)return n;let t=p;if(Array.isArray(u)){if(u.length===0)return`[]`;if(_<d.length+1)return`"[Array]"`;d.push(u),p+=f;let e=`\n${p}`,n=`,\n${p}`,r=Math.min(u.length,v),i=0;for(;i<r-1;i++){let t=x(String(i),u[i],d,f,p);e+=t===void 0?`null`:t,e+=n}let a=x(String(i),u[i],d,f,p);if(e+=a===void 0?`null`:a,u.length-1>v){let t=u.length-v-1;e+=`${n}"... ${m(t)} not stringified"`}return e+=`\n${t}`,d.pop(),`[${e}]`}let r=Object.keys(u),h=r.length;if(h===0)return`{}`;if(_<d.length+1)return`"[Object]"`;p+=f;let g=`,\n${p}`,y=``,b=``,S=Math.min(h,v);c(u)&&(y+=l(u,g,v),r=r.slice(u.length),S-=u.length,b=g),i&&(r=o(r,s)),d.push(u);for(let e=0;e<S;e++){let t=r[e],n=x(t,u[t],d,f,p);n!==void 0&&(y+=`${b}${a(t)}: ${n}`,b=g)}if(h>v){let e=h-v;y+=`${b}"...": "${m(e)} not stringified"`,b=g}return b!==``&&(y=`\n${p}${y}\n${t}`),d.pop(),`{${y}}`}case`number`:return isFinite(u)?String(u):t?t(u):`null`;case`boolean`:return u===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(u);default:return t?t(u):void 0}}function S(e,u,d){switch(typeof u){case`string`:return a(u);case`object`:{if(u===null)return`null`;if(typeof u.toJSON==`function`){if(u=u.toJSON(e),typeof u!=`object`)return S(e,u,d);if(u===null)return`null`}if(d.indexOf(u)!==-1)return n;let t=``,r=u.length!==void 0;if(r&&Array.isArray(u)){if(u.length===0)return`[]`;if(_<d.length+1)return`"[Array]"`;d.push(u);let e=Math.min(u.length,v),n=0;for(;n<e-1;n++){let e=S(String(n),u[n],d);t+=e===void 0?`null`:e,t+=`,`}let r=S(String(n),u[n],d);if(t+=r===void 0?`null`:r,u.length-1>v){let e=u.length-v-1;t+=`,"... ${m(e)} not stringified"`}return d.pop(),`[${t}]`}let f=Object.keys(u),p=f.length;if(p===0)return`{}`;if(_<d.length+1)return`"[Object]"`;let h=``,g=Math.min(p,v);r&&c(u)&&(t+=l(u,`,`,v),f=f.slice(u.length),g-=u.length,h=`,`),i&&(f=o(f,s)),d.push(u);for(let e=0;e<g;e++){let n=f[e],r=S(n,u[n],d);r!==void 0&&(t+=`${h}${a(n)}:${r}`,h=`,`)}if(p>v){let e=p-v;t+=`${h}"...":"${m(e)} not stringified"`}return d.pop(),`{${t}}`}case`number`:return isFinite(u)?String(u):t?t(u):`null`;case`boolean`:return u===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(u);default:return t?t(u):void 0}}function C(e,t,n){if(arguments.length>1){let r=``;if(typeof n==`number`?r=` `.repeat(Math.min(n,10)):typeof n==`string`&&(r=n.slice(0,10)),t!=null){if(typeof t==`function`)return y(``,{"":e},[],t,r,``);if(Array.isArray(t))return b(``,e,[],h(t),r,``)}if(r.length!==0)return x(``,e,[],r,``)}return S(``,e,[])}return C}})),Ut=z(((e,t)=>{let n=Symbol.for(`pino.metadata`),{DEFAULT_LEVELS:r}=Rt(),i=r.info;function a(e,t){e||=[],t||={dedupe:!1};let a=Object.create(r);a.silent=1/0,t.levels&&typeof t.levels==`object`&&Object.keys(t.levels).forEach(e=>{a[e]=t.levels[e]});let u={write:d,add:m,remove:h,emit:f,flushSync:p,end:g,minLevel:0,lastId:0,streams:[],clone:_,[n]:!0,streamLevels:a};return Array.isArray(e)?e.forEach(m,u):m.call(u,e),e=null,u;function d(e){let r,i=this.lastLevel,{streams:a}=this,o=0,u;for(let d=s(a.length,t.dedupe);l(d,a.length,t.dedupe);d=c(d,t.dedupe))if(r=a[d],r.level<=i){if(o!==0&&o!==r.level)break;if(u=r.stream,u[n]){let{lastTime:e,lastMsg:t,lastObj:n,lastLogger:r}=this;u.lastLevel=i,u.lastTime=e,u.lastMsg=t,u.lastObj=n,u.lastLogger=r}u.write(e),t.dedupe&&(o=r.level)}else if(!t.dedupe)break}function f(...e){for(let{stream:t}of this.streams)typeof t.emit==`function`&&t.emit(...e)}function p(){for(let{stream:e}of this.streams)typeof e.flushSync==`function`&&e.flushSync()}function m(e){if(!e)return u;let t=typeof e.write==`function`||e.stream,n=e.write?e:e.stream;if(!t)throw Error(`stream object needs to implement either StreamEntry or DestinationStream interface`);let{streams:r,streamLevels:a}=this,s;s=typeof e.levelVal==`number`?e.levelVal:typeof e.level==`string`?a[e.level]:typeof e.level==`number`?e.level:i;let c={stream:n,level:s,levelVal:void 0,id:++u.lastId};return r.unshift(c),r.sort(o),this.minLevel=r[0].level,u}function h(e){let{streams:t}=this,n=t.findIndex(t=>t.id===e);return n>=0&&(t.splice(n,1),t.sort(o),this.minLevel=t.length>0?t[0].level:-1),u}function g(){for(let{stream:e}of this.streams)typeof e.flushSync==`function`&&e.flushSync(),e.end()}function _(e){let t=Array(this.streams.length);for(let n=0;n<t.length;n++)t[n]={level:e,stream:this.streams[n].stream};return{write:d,add:m,remove:h,minLevel:e,streams:t,clone:_,emit:f,flushSync:p,[n]:!0}}}function o(e,t){return e.level-t.level}function s(e,t){return t?e-1:0}function c(e,t){return t?e-1:e+1}function l(e,t,n){return n?e>=0:e<t}t.exports=a})),Wt=le(z(((e,t)=>{let n=B(`node:os`),r=St(),i=Ct(),a=Et(),o=Dt(),s=Vt(),c=Tt(),{configure:l}=Ht(),{assertDefaultLevelFound:u,mappings:d,genLsCache:f,genLevelComparison:p,assertLevelComparison:m}=zt(),{DEFAULT_LEVELS:h,SORTING_ORDER:g}=Rt(),{createArgsNormalizer:_,asChindings:v,buildSafeSonicBoom:y,buildFormatters:b,stringify:x,normalizeDestFileDescriptor:S,noop:C}=Lt(),{version:w}=Bt(),{chindingsSym:T,redactFmtSym:E,serializersSym:D,timeSym:O,timeSliceIndexSym:k,streamSym:A,stringifySym:j,stringifySafeSym:M,stringifiersSym:N,setLevelSym:P,endSym:ee,formatOptsSym:F,messageKeySym:I,errorKeySym:te,nestedKeySym:L,mixinSym:ne,levelCompSym:re,useOnlyCustomLevelsSym:ie,formattersSym:ae,hooksSym:oe,nestedKeyStrSym:R,mixinMergeStrategySym:z,msgPrefixSym:se}=c,{epochTime:ce,nullTime:le}=o,{pid:V}=process,ue=n.hostname(),de=r.err,fe=_({level:`info`,levelComparison:g.ASC,levels:h,messageKey:`msg`,errorKey:`err`,nestedKey:null,enabled:!0,base:{pid:V,hostname:ue},serializers:Object.assign(Object.create(null),{err:de}),formatters:Object.assign(Object.create(null),{bindings(e){return e},level(e,t){return{level:t}}}),hooks:{logMethod:void 0,streamWrite:void 0},timestamp:ce,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,depthLimit:5,edgeLimit:100}),pe=Object.assign(Object.create(null),r);function H(...e){let t={},{opts:n,stream:r}=fe(t,i(),...e);n.level&&typeof n.level==`string`&&h[n.level.toLowerCase()]!==void 0&&(n.level=n.level.toLowerCase());let{redact:o,crlf:c,serializers:g,timestamp:_,messageKey:y,errorKey:S,nestedKey:w,base:B,name:V,level:ue,customLevels:de,levelComparison:pe,mixin:H,mixinMergeStrategy:me,useOnlyCustomLevels:he,formatters:U,hooks:ge,depthLimit:_e,edgeLimit:ve,onChild:ye,msgPrefix:be}=n,xe=l({maximumDepth:_e,maximumBreadth:ve}),Se=b(U.level,U.bindings,U.log),Ce=x.bind({[M]:xe}),we=o?a(o,Ce):{},Te=o?{stringify:we[E]}:{stringify:Ce},Ee=`}`+(c?`\r
|
|
15
|
+
caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?``:e.message||``;if(t.has(e))return a+`: ...`;let s=r(e);if(s){t.add(e);let n=typeof e.cause==`function`;return a+(n?``:`: `)+o(s,t,n)}else return a};t.exports={isErrorLike:n,getErrorCause:r,stackWithCauses:a,messageWithCauses:e=>o(e,new Set)}})),vt=R(((e,t)=>{let n=Symbol(`circular-ref-tag`),r=Symbol(`pino-raw-err-ref`),i=Object.create({},{type:{enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,value:void 0},aggregateErrors:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[r]},set:function(e){this[r]=e}}});Object.defineProperty(i,r,{writable:!0,value:{}}),t.exports={pinoErrProto:i,pinoErrorSymbols:{seen:n,rawSymbol:r}}})),yt=R(((e,t)=>{t.exports=l;let{messageWithCauses:n,stackWithCauses:r,isErrorLike:i}=_t(),{pinoErrProto:a,pinoErrorSymbols:o}=vt(),{seen:s}=o,{toString:c}=Object.prototype;function l(e){if(!i(e))return e;e[s]=void 0;let t=Object.create(a);t.type=c.call(e.constructor)===`[object Function]`?e.constructor.name:e.name,t.message=n(e),t.stack=r(e),Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(e=>l(e)));for(let n in e)if(t[n]===void 0){let r=e[n];i(r)?n!==`cause`&&!Object.prototype.hasOwnProperty.call(r,s)&&(t[n]=l(r)):t[n]=r}return delete e[s],t.raw=e,t}})),bt=R(((e,t)=>{t.exports=s;let{isErrorLike:n}=_t(),{pinoErrProto:r,pinoErrorSymbols:i}=vt(),{seen:a}=i,{toString:o}=Object.prototype;function s(e){if(!n(e))return e;e[a]=void 0;let t=Object.create(r);t.type=o.call(e.constructor)===`[object Function]`?e.constructor.name:e.name,t.message=e.message,t.stack=e.stack,Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(e=>s(e))),n(e.cause)&&!Object.prototype.hasOwnProperty.call(e.cause,a)&&(t.cause=s(e.cause));for(let r in e)if(t[r]===void 0){let i=e[r];n(i)?Object.prototype.hasOwnProperty.call(i,a)||(t[r]=s(i)):t[r]=i}return delete e[a],t.raw=e,t}})),xt=R(((e,t)=>{t.exports={mapHttpRequest:a,reqSerializer:i};let n=Symbol(`pino-raw-req-ref`),r=Object.create({},{id:{enumerable:!0,writable:!0,value:``},method:{enumerable:!0,writable:!0,value:``},url:{enumerable:!0,writable:!0,value:``},query:{enumerable:!0,writable:!0,value:``},params:{enumerable:!0,writable:!0,value:``},headers:{enumerable:!0,writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:``},remotePort:{enumerable:!0,writable:!0,value:``},raw:{enumerable:!1,get:function(){return this[n]},set:function(e){this[n]=e}}});Object.defineProperty(r,n,{writable:!0,value:{}});function i(e){let t=e.info||e.socket,n=Object.create(r);if(n.id=typeof e.id==`function`?e.id():e.id||(e.info?e.info.id:void 0),n.method=e.method,e.originalUrl)n.url=e.originalUrl;else{let t=e.path;n.url=typeof t==`string`?t:e.url?e.url.path||e.url:void 0}return e.query&&(n.query=e.query),e.params&&(n.params=e.params),n.headers=e.headers,n.remoteAddress=t&&t.remoteAddress,n.remotePort=t&&t.remotePort,n.raw=e.raw||e,n}function a(e){return{req:i(e)}}})),St=R(((e,t)=>{t.exports={mapHttpResponse:a,resSerializer:i};let n=Symbol(`pino-raw-res-ref`),r=Object.create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:``},raw:{enumerable:!1,get:function(){return this[n]},set:function(e){this[n]=e}}});Object.defineProperty(r,n,{writable:!0,value:{}});function i(e){let t=Object.create(r);return t.statusCode=e.headersSent?e.statusCode:null,t.headers=e.getHeaders?e.getHeaders():e._headers,t.raw=e,t}function a(e){return{res:i(e)}}})),Ct=R(((e,t)=>{let n=yt(),r=bt(),i=xt(),a=St();t.exports={err:n,errWithCause:r,mapHttpRequest:i.mapHttpRequest,mapHttpResponse:a.mapHttpResponse,req:i.reqSerializer,res:a.resSerializer,wrapErrorSerializer:function(e){return e===n?e:function(t){return e(n(t))}},wrapRequestSerializer:function(e){return e===i.reqSerializer?e:function(t){return e(i.reqSerializer(t))}},wrapResponseSerializer:function(e){return e===a.resSerializer?e:function(t){return e(a.resSerializer(t))}}}})),wt=R(((e,t)=>{function n(e,t){return t}t.exports=function(){let e=Error.prepareStackTrace;Error.prepareStackTrace=n;let t=Error().stack;if(Error.prepareStackTrace=e,!Array.isArray(t))return;let r=t.slice(2),i=[];for(let e of r)e&&i.push(e.getFileName());return i}})),Tt=R(((e,t)=>{function n(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Array){let t=[];for(let r=0;r<e.length;r++)t[r]=n(e[r]);return t}if(typeof e==`object`){let t=Object.create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=n(e[r]));return t}return e}function r(e){let t=[],n=``,r=!1,i=!1,a=``;for(let o=0;o<e.length;o++){let s=e[o];!r&&s===`.`?n&&=(t.push(n),``):s===`[`?(n&&=(t.push(n),``),r=!0):s===`]`&&r?(t.push(n),n=``,r=!1,i=!1):(s===`"`||s===`'`)&&r?i?s===a?(i=!1,a=``):n+=s:(i=!0,a=s):n+=s}return n&&t.push(n),t}function i(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];if(typeof r!=`object`||!r||!(n in r)||typeof r[n]!=`object`||r[n]===null)return!1;r=r[n]}let i=t[t.length-1];if(i===`*`){if(Array.isArray(r))for(let e=0;e<r.length;e++)r[e]=n;else if(typeof r==`object`&&r)for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&(r[e]=n)}else typeof r==`object`&&r&&i in r&&Object.prototype.hasOwnProperty.call(r,i)&&(r[i]=n);return!0}function a(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(typeof n!=`object`||!n||!(r in n)||typeof n[r]!=`object`||n[r]===null)return!1;n=n[r]}let r=t[t.length-1];if(r===`*`){if(Array.isArray(n))for(let e=0;e<n.length;e++)n[e]=void 0;else if(typeof n==`object`&&n)for(let e in n)Object.prototype.hasOwnProperty.call(n,e)&&delete n[e]}else typeof n==`object`&&n&&r in n&&Object.prototype.hasOwnProperty.call(n,r)&&delete n[r];return!0}let o=Symbol(`PATH_NOT_FOUND`);function s(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||!n||!(e in n))return o;n=n[e]}return n}function c(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||!n)return;n=n[e]}return n}function l(e,t,n,c=!1){for(let l of t){let t=r(l);if(t.includes(`*`))u(e,t,n,l,c);else if(c)a(e,t);else{let r=s(e,t);if(r===o)continue;i(e,t,typeof n==`function`?n(r,t):n)}}}function u(e,t,n,r,i=!1){let a=t.indexOf(`*`);if(a===t.length-1){let r=t.slice(0,-1),a=e;for(let e of r){if(typeof a!=`object`||!a||!a)return;a=a[e]}if(Array.isArray(a))if(i)for(let e=0;e<a.length;e++)a[e]=void 0;else for(let e=0;e<a.length;e++){let t=[...r,e.toString()],i=typeof n==`function`?n(a[e],t):n;a[e]=i}else if(typeof a==`object`&&a)if(i){let e=[];for(let t in a)Object.prototype.hasOwnProperty.call(a,t)&&e.push(t);for(let t of e)delete a[t]}else for(let e in a){let t=[...r,e],i=typeof n==`function`?n(a[e],t):n;a[e]=i}}else d(e,t,n,a,r,i)}function d(e,t,n,r,o,s=!1){let l=t.slice(0,r),d=t.slice(r+1),f=[];function p(e,t){if(t===l.length){if(Array.isArray(e))for(let n=0;n<e.length;n++)f[t]=n.toString(),p(e[n],t+1);else if(typeof e==`object`&&e)for(let n in e)f[t]=n,p(e[n],t+1)}else if(t<l.length){let n=l[t];e&&typeof e==`object`&&e&&n in e&&(f[t]=n,p(e[n],t+1))}else d.includes(`*`)?u(e,d,typeof n==`function`?(e,r)=>n(e,[...f.slice(0,t),...r]):n,o,s):s?a(e,d):i(e,d,typeof n==`function`?n(c(e,d),[...f.slice(0,t),...d]):n)}if(l.length===0)p(e,0);else{let t=e;for(let e=0;e<l.length;e++){let n=l[e];if(typeof t!=`object`||!t||!t)return;t=t[n],f[e]=n}t!=null&&p(t,l.length)}}function f(e){if(e.length===0)return null;let t=new Map;for(let n of e){let e=r(n),i=t;for(let t=0;t<e.length;t++){let n=e[t];i.has(n)||i.set(n,new Map),i=i.get(n)}}return t}function p(e,t){if(!t)return e;function n(e,t,r=0){if(!t||t.size===0||typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let r=[];for(let i=0;i<e.length;i++){let a=i.toString();t.has(a)||t.has(`*`)?r[i]=n(e[i],t.get(a)||t.get(`*`)):r[i]=e[i]}return r}let i=Object.create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t.has(r)||t.has(`*`)?i[r]=n(e[r],t.get(r)||t.get(`*`)):i[r]=e[r]);return i}return n(e,t)}function m(e){if(typeof e!=`string`)throw Error(`Paths must be (non-empty) strings`);if(e===``)throw Error(`Invalid redaction path ()`);if(e.includes(`..`)||e.includes(`,`))throw Error(`Invalid redaction path (${e})`);let t=0,n=!1,r=``;for(let i=0;i<e.length;i++){let a=e[i];if((a===`"`||a===`'`)&&t>0)n?a===r&&(n=!1,r=``):(n=!0,r=a);else if(a===`[`&&!n)t++;else if(a===`]`&&!n&&(t--,t<0))throw Error(`Invalid redaction path (${e})`)}if(t!==0)throw Error(`Invalid redaction path (${e})`)}function h(e){if(!Array.isArray(e))throw TypeError(`paths must be an array`);for(let t of e)m(t)}function g(e={}){let{paths:t=[],censor:r=`[REDACTED]`,serialize:i=JSON.stringify,strict:a=!0,remove:o=!1}=e;h(t);let s=f(t);return function(e){if(a&&(typeof e!=`object`||!e)&&(typeof e!=`object`||!e))return i?i(e):e;let c=p(e,s),u=e,d=r;return typeof r==`function`&&(d=r),l(c,t,d,o),i===!1?(c.restore=function(){return n(u)},c):typeof i==`function`?i(c):JSON.stringify(c)}}t.exports=g})),Et=R(((e,t)=>{let n=Symbol(`pino.setLevel`),r=Symbol(`pino.getLevel`),i=Symbol(`pino.levelVal`),a=Symbol(`pino.levelComp`),o=Symbol(`pino.useLevelLabels`),s=Symbol(`pino.useOnlyCustomLevels`),c=Symbol(`pino.mixin`),l=Symbol(`pino.lsCache`),u=Symbol(`pino.chindings`),d=Symbol(`pino.asJson`),f=Symbol(`pino.write`),p=Symbol(`pino.redactFmt`),m=Symbol(`pino.time`),h=Symbol(`pino.timeSliceIndex`),g=Symbol(`pino.stream`),_=Symbol(`pino.stringify`),v=Symbol(`pino.stringifySafe`),y=Symbol(`pino.stringifiers`),b=Symbol(`pino.end`),x=Symbol(`pino.formatOpts`),S=Symbol(`pino.messageKey`),C=Symbol(`pino.errorKey`),w=Symbol(`pino.nestedKey`),T=Symbol(`pino.nestedKeyStr`),E=Symbol(`pino.mixinMergeStrategy`),D=Symbol(`pino.msgPrefix`),O=Symbol(`pino.wildcardFirst`),k=Symbol.for(`pino.serializers`),A=Symbol.for(`pino.formatters`),j=Symbol.for(`pino.hooks`);t.exports={setLevelSym:n,getLevelSym:r,levelValSym:i,levelCompSym:a,useLevelLabelsSym:o,mixinSym:c,lsCacheSym:l,chindingsSym:u,asJsonSym:d,writeSym:f,serializersSym:k,redactFmtSym:p,timeSym:m,timeSliceIndexSym:h,streamSym:g,stringifySym:_,stringifySafeSym:v,stringifiersSym:y,endSym:b,formatOptsSym:x,messageKeySym:S,errorKeySym:C,nestedKeySym:w,wildcardFirstSym:O,needsMetadataGsym:Symbol.for(`pino.metadata`),useOnlyCustomLevelsSym:s,formattersSym:A,hooksSym:j,nestedKeyStrSym:T,mixinMergeStrategySym:E,msgPrefixSym:D}})),Dt=R(((e,t)=>{let n=Tt(),{redactFmtSym:r,wildcardFirstSym:i}=Et(),a=/[^.[\]]+|\[([^[\]]*?)\]/g,o=`[Redacted]`;function s(e,t){let{paths:o,censor:s,remove:l}=c(e),u=o.reduce((e,t)=>{a.lastIndex=0;let n=a.exec(t),r=a.exec(t),o=n[1]===void 0?n[0]:n[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,`$1`);if(o===`*`&&(o=i),r===null)return e[o]=null,e;if(e[o]===null)return e;let{index:s}=r,c=`${t.substr(s,t.length-1)}`;return e[o]=e[o]||[],o!==i&&e[o].length===0&&e[o].push(...e[i]||[]),o===i&&Object.keys(e).forEach(function(t){e[t]&&e[t].push(c)}),e[o].push(c),e},{}),d={[r]:n({paths:o,censor:s,serialize:t,strict:!1,remove:l})},f=(...e)=>t(typeof s==`function`?s(...e):s);return[...Object.keys(u),...Object.getOwnPropertySymbols(u)].reduce((e,r)=>{if(u[r]===null)e[r]=e=>f(e,[r]);else{let i=typeof s==`function`?(e,t)=>s(e,[r,...t]):s;e[r]=n({paths:u[r],censor:i,serialize:t,strict:!1,remove:l})}return e},d)}function c(e){if(Array.isArray(e))return e={paths:e,censor:o},e;let{paths:t,censor:n=o,remove:r}=e;if(Array.isArray(t)===!1)throw Error(`pino – redact must contain an array of strings`);return r===!0&&(n=void 0),{paths:t,censor:n,remove:r}}t.exports=s})),Ot=R(((e,t)=>{let n=()=>``,r=()=>`,"time":${Date.now()}`,i=()=>`,"time":${Math.round(Date.now()/1e3)}`,a=()=>`,"time":"${new Date(Date.now()).toISOString()}"`,o=1000000000n,s=BigInt(Date.now())*1000000n,c=process.hrtime.bigint();t.exports={nullTime:n,epochTime:r,unixTime:i,isoTime:a,isoTimeNano:()=>{let e=s+(process.hrtime.bigint()-c),t=e/o,n=e%o,r=Number(t*1000n+n/1000000n),i=new Date(r);return`,"time":"${i.getUTCFullYear()}-${(i.getUTCMonth()+1).toString().padStart(2,`0`)}-${i.getUTCDate().toString().padStart(2,`0`)}T${i.getUTCHours().toString().padStart(2,`0`)}:${i.getUTCMinutes().toString().padStart(2,`0`)}:${i.getUTCSeconds().toString().padStart(2,`0`)}.${n.toString().padStart(9,`0`)}Z"`}}})),kt=R(((e,t)=>{function n(e){try{return JSON.stringify(e)}catch{return`"[Circular]"`}}t.exports=r;function r(e,t,r){var i=r&&r.stringify||n,a=1;if(typeof e==`object`&&e){var o=t.length+a;if(o===1)return e;var s=Array(o);s[0]=i(e);for(var c=1;c<o;c++)s[c]=i(t[c]);return s.join(` `)}if(typeof e!=`string`)return e;var l=t.length;if(l===0)return e;for(var u=``,d=1-a,f=-1,p=e&&e.length||0,m=0;m<p;){if(e.charCodeAt(m)===37&&m+1<p){switch(f=f>-1?f:0,e.charCodeAt(m+1)){case 100:case 102:if(d>=l||t[d]==null)break;f<m&&(u+=e.slice(f,m)),u+=Number(t[d]),f=m+2,m++;break;case 105:if(d>=l||t[d]==null)break;f<m&&(u+=e.slice(f,m)),u+=Math.floor(Number(t[d])),f=m+2,m++;break;case 79:case 111:case 106:if(d>=l||t[d]===void 0)break;f<m&&(u+=e.slice(f,m));var h=typeof t[d];if(h===`string`){u+=`'`+t[d]+`'`,f=m+2,m++;break}if(h===`function`){u+=t[d].name||`<anonymous>`,f=m+2,m++;break}u+=i(t[d]),f=m+2,m++;break;case 115:if(d>=l)break;f<m&&(u+=e.slice(f,m)),u+=String(t[d]),f=m+2,m++;break;case 37:f<m&&(u+=e.slice(f,m)),u+=`%`,f=m+2,m++,d--;break}++d}++m}return f===-1?e:(f<p&&(u+=e.slice(f)),u)}})),At=R(((e,t)=>{if(typeof SharedArrayBuffer<`u`&&typeof Atomics<`u`){let e=new Int32Array(new SharedArrayBuffer(4));function n(t){if(!(t>0&&t<1/0))throw typeof t!=`number`&&typeof t!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);Atomics.wait(e,0,0,Number(t))}t.exports=n}else{function e(e){if(!(e>0&&e<1/0))throw typeof e!=`number`&&typeof e!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);let t=Date.now()+Number(e);for(;t>Date.now(););}t.exports=e}})),jt=R(((e,t)=>{let n=B(`fs`),r=B(`events`),i=B(`util`).inherits,a=B(`path`),o=At(),s=B(`assert`),c=Buffer.allocUnsafe(0),l=`buffer`,u=`utf8`,[d,f]=(process.versions.node||`0.0`).split(`.`).map(Number),p=d>=22&&f>=7;function m(e,t){t._opening=!0,t._writing=!0,t._asyncDrainScheduled=!1;function r(n,r){if(n){t._reopening=!1,t._writing=!1,t._opening=!1,t.sync?process.nextTick(()=>{t.listenerCount(`error`)>0&&t.emit(`error`,n)}):t.emit(`error`,n);return}let i=t._reopening;t.fd=r,t.file=e,t._reopening=!1,t._opening=!1,t._writing=!1,t.sync?process.nextTick(()=>t.emit(`ready`)):t.emit(`ready`),!t.destroyed&&(!t._writing&&t._len>t.minLength||t._flushPending?t._actualWrite():i&&process.nextTick(()=>t.emit(`drain`)))}let i=t.append?`a`:`w`,o=t.mode;if(t.sync)try{t.mkdir&&n.mkdirSync(a.dirname(e),{recursive:!0}),r(null,n.openSync(e,i,o))}catch(e){throw r(e),e}else t.mkdir?n.mkdir(a.dirname(e),{recursive:!0},t=>{if(t)return r(t);n.open(e,i,o,r)}):n.open(e,i,o,r)}function h(e){if(!(this instanceof h))return new h(e);let{fd:t,dest:r,minLength:i,maxLength:a,maxWrite:s,periodicFlush:d,sync:f,append:p=!0,mkdir:v,retryEAGAIN:x,fsync:k,contentMode:A,mode:j}=e||{};t||=r,this._len=0,this.fd=-1,this._bufs=[],this._lens=[],this._writing=!1,this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._flushPending=!1,this._hwm=Math.max(i||0,16387),this.file=null,this.destroyed=!1,this.minLength=i||0,this.maxLength=a||0,this.maxWrite=s||16384,this._periodicFlush=d||0,this._periodicFlushTimer=void 0,this.sync=f||!1,this.writable=!0,this._fsync=k||!1,this.append=p||!1,this.mode=j,this.retryEAGAIN=x||(()=>!0),this.mkdir=v||!1;let M,N;if(A===l)this._writingBuf=c,this.write=b,this.flush=C,this.flushSync=T,this._actualWrite=D,M=()=>n.writeSync(this.fd,this._writingBuf),N=()=>n.write(this.fd,this._writingBuf,this.release);else if(A===void 0||A===u)this._writingBuf=``,this.write=y,this.flush=S,this.flushSync=w,this._actualWrite=E,M=()=>Buffer.isBuffer(this._writingBuf)?n.writeSync(this.fd,this._writingBuf):n.writeSync(this.fd,this._writingBuf,`utf8`),N=()=>Buffer.isBuffer(this._writingBuf)?n.write(this.fd,this._writingBuf,this.release):n.write(this.fd,this._writingBuf,`utf8`,this.release);else throw Error(`SonicBoom supports "${u}" and "${l}", but passed ${A}`);if(typeof t==`number`)this.fd=t,process.nextTick(()=>this.emit(`ready`));else if(typeof t==`string`)m(t,this);else throw Error(`SonicBoom supports only file descriptors and files`);if(this.minLength>=this.maxWrite)throw Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);this.release=(e,t)=>{if(e){if((e.code===`EAGAIN`||e.code===`EBUSY`)&&this.retryEAGAIN(e,this._writingBuf.length,this._len-this._writingBuf.length))if(this.sync)try{o(100),this.release(void 0,0)}catch(e){this.release(e)}else setTimeout(N,100);else this._writing=!1,this.emit(`error`,e);return}this.emit(`write`,t);let r=g(this._writingBuf,this._len,t);if(this._len=r.len,this._writingBuf=r.writingBuf,this._writingBuf.length){if(!this.sync){N();return}try{do{let e=M(),t=g(this._writingBuf,this._len,e);this._len=t.len,this._writingBuf=t.writingBuf}while(this._writingBuf.length)}catch(e){this.release(e);return}}this._fsync&&n.fsyncSync(this.fd);let i=this._len;this._reopening?(this._writing=!1,this._reopening=!1,this.reopen()):i>this.minLength?this._actualWrite():this._ending?i>0?this._actualWrite():(this._writing=!1,O(this)):(this._writing=!1,this.sync?this._asyncDrainScheduled||(this._asyncDrainScheduled=!0,process.nextTick(_,this)):this.emit(`drain`))},this.on(`newListener`,function(e){e===`drain`&&(this._asyncDrainScheduled=!1)}),this._periodicFlush!==0&&(this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush),this._periodicFlushTimer.unref())}function g(e,t,n){return typeof e==`string`&&(e=Buffer.from(e)),t=Math.max(t-n,0),e=e.subarray(n),{writingBuf:e,len:t}}function _(e){e.listenerCount(`drain`)>0&&(e._asyncDrainScheduled=!1,e.emit(`drain`))}i(h,r);function v(e,t){return e.length===0?c:e.length===1?e[0]:Buffer.concat(e,t)}function y(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);e=``+e;let t=Buffer.byteLength(e),n=this._len+t,r=this._bufs;return this.maxLength&&n>this.maxLength?(this.emit(`drop`,e),this._len<this._hwm):(r.length===0||Buffer.byteLength(r[r.length-1])+t>this.maxWrite?r.push(e):r[r.length-1]+=e,this._len=n,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function b(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);let t=this._len+e.length,n=this._bufs,r=this._lens;return this.maxLength&&t>this.maxLength?(this.emit(`drop`,e),this._len<this._hwm):(n.length===0||r[r.length-1]+e.length>this.maxWrite?(n.push([e]),r.push(e.length)):(n[n.length-1].push(e),r[r.length-1]+=e.length),this._len=t,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function x(e){this._flushPending=!0;let t=()=>{if(this._fsync)this._flushPending=!1,e();else try{n.fsync(this.fd,t=>{this._flushPending=!1,e(t)})}catch(t){e(t)}this.off(`error`,r)},r=n=>{this._flushPending=!1,e(n),this.off(`drain`,t)};this.once(`drain`,t),this.once(`error`,r)}function S(e){if(e!=null&&typeof e!=`function`)throw Error(`flush cb must be a function`);if(this.destroyed){let t=Error(`SonicBoom destroyed`);if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&x.call(this,e),!this._writing&&(this._bufs.length===0&&this._bufs.push(``),this._actualWrite())}function C(e){if(e!=null&&typeof e!=`function`)throw Error(`flush cb must be a function`);if(this.destroyed){let t=Error(`SonicBoom destroyed`);if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&x.call(this,e),!this._writing&&(this._bufs.length===0&&(this._bufs.push([]),this._lens.push(0)),this._actualWrite())}h.prototype.reopen=function(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this._opening){this.once(`ready`,()=>{this.reopen(e)});return}if(this._ending)return;if(!this.file)throw Error(`Unable to reopen a file descriptor, you must pass a file to SonicBoom`);if(e&&(this.file=e),this._reopening=!0,this._writing)return;let t=this.fd;this.once(`ready`,()=>{t!==this.fd&&n.close(t,e=>{if(e)return this.emit(`error`,e)})}),m(this.file,this)},h.prototype.end=function(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this._opening){this.once(`ready`,()=>{this.end()});return}this._ending||(this._ending=!0,!this._writing&&(this._len>0&&this.fd>=0?this._actualWrite():O(this)))};function w(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this.fd<0)throw Error(`sonic boom is not ready yet`);!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift(this._writingBuf),this._writingBuf=``);let e=``;for(;this._bufs.length||e.length;){e.length<=0&&(e=this._bufs[0]);try{let t=Buffer.isBuffer(e)?n.writeSync(this.fd,e):n.writeSync(this.fd,e,`utf8`),r=g(e,this._len,t);e=r.writingBuf,this._len=r.len,e.length<=0&&this._bufs.shift()}catch(t){if((t.code===`EAGAIN`||t.code===`EBUSY`)&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;o(100)}}try{n.fsyncSync(this.fd)}catch{}}function T(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this.fd<0)throw Error(`sonic boom is not ready yet`);!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift([this._writingBuf]),this._writingBuf=c);let e=c;for(;this._bufs.length||e.length;){e.length<=0&&(e=v(this._bufs[0],this._lens[0]));try{let t=n.writeSync(this.fd,e);e=e.subarray(t),this._len=Math.max(this._len-t,0),e.length<=0&&(this._bufs.shift(),this._lens.shift())}catch(t){if((t.code===`EAGAIN`||t.code===`EBUSY`)&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;o(100)}}}h.prototype.destroy=function(){this.destroyed||O(this)};function E(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:this._bufs.shift()||``,this.sync)try{e(null,Buffer.isBuffer(this._writingBuf)?n.writeSync(this.fd,this._writingBuf):n.writeSync(this.fd,this._writingBuf,`utf8`))}catch(t){e(t)}else n.write(this.fd,this._writingBuf,e)}function D(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:v(this._bufs.shift(),this._lens.shift()),this.sync)try{e(null,n.writeSync(this.fd,this._writingBuf))}catch(t){e(t)}else p&&(this._writingBuf=Buffer.from(this._writingBuf)),n.write(this.fd,this._writingBuf,e)}function O(e){if(e.fd===-1){e.once(`ready`,O.bind(null,e));return}e._periodicFlushTimer!==void 0&&clearInterval(e._periodicFlushTimer),e.destroyed=!0,e._bufs=[],e._lens=[],s(typeof e.fd==`number`,`sonic.fd must be a number, got ${typeof e.fd}`);try{n.fsync(e.fd,t)}catch{}function t(){e.fd!==1&&e.fd!==2?n.close(e.fd,r):r()}function r(t){if(t){e.emit(`error`,t);return}e._ending&&!e._writing&&e.emit(`finish`),e.emit(`close`)}}h.SonicBoom=h,h.default=h,t.exports=h})),Mt=R(((e,t)=>{let n={exit:[],beforeExit:[]},r={exit:c,beforeExit:l},i;function a(){i===void 0&&(i=new FinalizationRegistry(d))}function o(e){n[e].length>0||process.on(e,r[e])}function s(e){n[e].length>0||(process.removeListener(e,r[e]),n.exit.length===0&&n.beforeExit.length===0&&(i=void 0))}function c(){u(`exit`)}function l(){u(`beforeExit`)}function u(e){for(let t of n[e]){let n=t.deref(),r=t.fn;n!==void 0&&r(n,e)}n[e]=[]}function d(e){for(let t of[`exit`,`beforeExit`]){let r=n[t].indexOf(e);n[t].splice(r,r+1),s(t)}}function f(e,t,r){if(t===void 0)throw Error(`the object can't be undefined`);o(e);let s=new WeakRef(t);s.fn=r,a(),i.register(t,s),n[e].push(s)}function p(e,t){f(`exit`,e,t)}function m(e,t){f(`beforeExit`,e,t)}function h(e){if(i!==void 0){i.unregister(e);for(let t of[`exit`,`beforeExit`])n[t]=n[t].filter(t=>{let n=t.deref();return n&&n!==e}),s(t)}}t.exports={register:p,registerBeforeExit:m,unregister:h}})),Nt=R(((e,t)=>{t.exports={name:`thread-stream`,version:`4.0.0`,description:`A streaming way to send data to a Node.js Worker Thread`,main:`index.js`,types:`index.d.ts`,engines:{node:`>=20`},dependencies:{"real-require":`^0.2.0`},devDependencies:{"@types/node":`^22.0.0`,"@yao-pkg/pkg":`^6.0.0`,borp:`^0.21.0`,desm:`^1.3.0`,eslint:`^9.39.1`,fastbench:`^1.0.1`,husky:`^9.0.6`,neostandard:`^0.12.2`,"pino-elasticsearch":`^8.0.0`,"sonic-boom":`^4.0.1`,"ts-node":`^10.8.0`,typescript:`~5.7.3`},scripts:{build:`tsc --noEmit`,lint:`eslint`,test:`npm run lint && npm run build && npm run transpile && borp --pattern 'test/*.test.{js,mjs}'`,"test:ci":`npm run lint && npm run transpile && borp --pattern 'test/*.test.{js,mjs}'`,"test:yarn":`npm run transpile && borp --pattern 'test/*.test.js'`,transpile:`sh ./test/ts/transpile.sh`,prepare:`husky install`},repository:{type:`git`,url:`git+https://github.com/mcollina/thread-stream.git`},keywords:[`worker`,`thread`,`threads`,`stream`],author:`Matteo Collina <hello@matteocollina.com>`,license:`MIT`,bugs:{url:`https://github.com/mcollina/thread-stream/issues`},homepage:`https://github.com/mcollina/thread-stream#readme`}})),Pt=R(((e,t)=>{let n=1e4;function r(e,t,r,i,a){let o=i===1/0?1/0:Date.now()+i,s=()=>{let i=Atomics.load(e,t);if(i===r){a(null,`ok`);return}if(o!==1/0&&Date.now()>o){a(null,`timed-out`);return}let c=o===1/0?n:Math.min(n,Math.max(1,o-Date.now())),l=Atomics.waitAsync(e,t,i,c);l.async?l.value.then(s):setImmediate(s)};s()}function i(e,t,r,i,a){let o=i===1/0?1/0:Date.now()+i,s=()=>{if(Atomics.load(e,t)!==r){a(null,`ok`);return}if(o!==1/0&&Date.now()>o){a(null,`timed-out`);return}let i=o===1/0?n:Math.min(n,Math.max(1,o-Date.now())),c=Atomics.waitAsync(e,t,r,i);c.async?c.value.then(s):setImmediate(s)};s()}t.exports={wait:r,waitDiff:i}})),Ft=R(((e,t)=>{t.exports={WRITE_INDEX:4,READ_INDEX:8}})),It=R(((e,t)=>{let{version:n}=Nt(),{EventEmitter:r}=B(`events`),{Worker:i}=B(`worker_threads`),{join:a}=B(`path`),{pathToFileURL:o}=B(`url`),{wait:s}=Pt(),{WRITE_INDEX:c,READ_INDEX:l}=Ft(),u=B(`buffer`),d=B(`assert`),f=Symbol(`kImpl`),p=u.constants.MAX_STRING_LENGTH;var m=class{constructor(e){this._value=e}deref(){return this._value}},h=class{register(){}unregister(){}};let g=process.env.NODE_V8_COVERAGE?h:global.FinalizationRegistry||h,_=process.env.NODE_V8_COVERAGE?m:global.WeakRef||m,v=new g(e=>{e.exited||e.terminate()});function y(e,t){let{filename:r,workerData:s}=t,c=new i((`__bundlerPathsOverrides`in globalThis?globalThis.__bundlerPathsOverrides:{})[`thread-stream-worker`]||a(__dirname,`lib`,`worker.js`),{...t.workerOpts,trackUnmanagedFds:!1,workerData:{filename:r.indexOf(`file://`)===0?r:o(r).href,dataBuf:e[f].dataBuf,stateBuf:e[f].stateBuf,workerData:{$context:{threadStreamVersion:n},...s}}});return c.stream=new m(e),c.on(`message`,S),c.on(`exit`,C),v.register(e,c),c}function b(e){d(!e[f].sync),e[f].needDrain&&(e[f].needDrain=!1,e.emit(`drain`))}function x(e){let t=Atomics.load(e[f].state,c),n=e[f].data.length-t;if(n>0){if(e[f].buf.length===0){e[f].flushing=!1,e[f].ending?O(e):e[f].needDrain&&process.nextTick(b,e);return}let t=e[f].buf.slice(0,n),r=Buffer.byteLength(t);r<=n?(e[f].buf=e[f].buf.slice(n),D(e,t,x.bind(null,e))):e.flush(()=>{if(!e.destroyed){for(Atomics.store(e[f].state,l,0),Atomics.store(e[f].state,c,0),Atomics.notify(e[f].state,l);r>e[f].data.length;)n/=2,t=e[f].buf.slice(0,n),r=Buffer.byteLength(t);e[f].buf=e[f].buf.slice(n),D(e,t,x.bind(null,e))}})}else if(n===0){if(t===0&&e[f].buf.length===0)return;e.flush(()=>{Atomics.store(e[f].state,l,0),Atomics.store(e[f].state,c,0),Atomics.notify(e[f].state,l),x(e)})}else E(e,Error(`overwritten`))}function S(e){let t=this.stream.deref();if(t===void 0){this.exited=!0,this.terminate();return}switch(e.code){case`READY`:this.stream=new _(t),t.flush(()=>{t[f].ready=!0,t.emit(`ready`)});break;case`ERROR`:E(t,e.err);break;case`EVENT`:Array.isArray(e.args)?t.emit(e.name,...e.args):t.emit(e.name,e.args);break;case`WARNING`:process.emitWarning(e.err);break;default:E(t,Error(`this should not happen: `+e.code))}}function C(e){let t=this.stream.deref();t!==void 0&&(v.unregister(t),t.worker.exited=!0,t.worker.off(`exit`,C),E(t,e===0?null:Error(`the worker thread exited`)))}var w=class extends r{constructor(e={}){if(super(),e.bufferSize<4)throw Error(`bufferSize must at least fit a 4-byte utf-8 char`);this[f]={},this[f].stateBuf=new SharedArrayBuffer(128),this[f].state=new Int32Array(this[f].stateBuf),this[f].dataBuf=new SharedArrayBuffer(e.bufferSize||4*1024*1024),this[f].data=Buffer.from(this[f].dataBuf),this[f].sync=e.sync||!1,this[f].ending=!1,this[f].ended=!1,this[f].needDrain=!1,this[f].destroyed=!1,this[f].flushing=!1,this[f].ready=!1,this[f].finished=!1,this[f].errored=null,this[f].closed=!1,this[f].buf=``,this.worker=y(this,e),this.on(`message`,(e,t)=>{this.worker.postMessage(e,t)})}write(e){if(this[f].destroyed)return T(this,Error(`the worker has exited`)),!1;if(this[f].ending)return T(this,Error(`the worker is ending`)),!1;if(this[f].flushing&&this[f].buf.length+e.length>=p)try{k(this),this[f].flushing=!0}catch(e){return E(this,e),!1}if(this[f].buf+=e,this[f].sync)try{return k(this),!0}catch(e){return E(this,e),!1}return this[f].flushing||(this[f].flushing=!0,setImmediate(x,this)),this[f].needDrain=this[f].data.length-this[f].buf.length-Atomics.load(this[f].state,c)<=0,!this[f].needDrain}end(){this[f].destroyed||(this[f].ending=!0,O(this))}flush(e){if(this[f].destroyed){typeof e==`function`&&process.nextTick(e,Error(`the worker has exited`));return}let t=Atomics.load(this[f].state,c);s(this[f].state,l,t,1/0,(t,n)=>{if(t){E(this,t),process.nextTick(e,t);return}if(n===`not-equal`){this.flush(e);return}process.nextTick(e)})}flushSync(){this[f].destroyed||(k(this),A(this))}unref(){this.worker.unref()}ref(){this.worker.ref()}get ready(){return this[f].ready}get destroyed(){return this[f].destroyed}get closed(){return this[f].closed}get writable(){return!this[f].destroyed&&!this[f].ending}get writableEnded(){return this[f].ending}get writableFinished(){return this[f].finished}get writableNeedDrain(){return this[f].needDrain}get writableObjectMode(){return!1}get writableErrored(){return this[f].errored}};function T(e,t){setImmediate(()=>{e.emit(`error`,t)})}function E(e,t){e[f].destroyed||(e[f].destroyed=!0,t&&(e[f].errored=t,T(e,t)),e.worker.exited?setImmediate(()=>{e[f].closed=!0,e.emit(`close`)}):e.worker.terminate().catch(()=>{}).then(()=>{e[f].closed=!0,e.emit(`close`)}))}function D(e,t,n){let r=Atomics.load(e[f].state,c),i=Buffer.byteLength(t);return e[f].data.write(t,r),Atomics.store(e[f].state,c,r+i),Atomics.notify(e[f].state,c),n(),!0}function O(e){if(!(e[f].ended||!e[f].ending||e[f].flushing)){e[f].ended=!0;try{e.flushSync();let t=Atomics.load(e[f].state,l);Atomics.store(e[f].state,c,-1),Atomics.notify(e[f].state,c);let n=0;for(;t!==-1;){if(Atomics.wait(e[f].state,l,t,1e3),t=Atomics.load(e[f].state,l),t===-2){E(e,Error(`end() failed`));return}if(++n===10){E(e,Error(`end() took too long (10s)`));return}}process.nextTick(()=>{e[f].finished=!0,e.emit(`finish`)})}catch(t){E(e,t)}}}function k(e){let t=()=>{e[f].ending?O(e):e[f].needDrain&&process.nextTick(b,e)};for(e[f].flushing=!1;e[f].buf.length!==0;){let n=Atomics.load(e[f].state,c),r=e[f].data.length-n;if(r===0){A(e),Atomics.store(e[f].state,l,0),Atomics.store(e[f].state,c,0),Atomics.notify(e[f].state,l);continue}else if(r<0)throw Error(`overwritten`);let i=e[f].buf.slice(0,r),a=Buffer.byteLength(i);if(a<=r)e[f].buf=e[f].buf.slice(r),D(e,i,t);else{for(A(e),Atomics.store(e[f].state,l,0),Atomics.store(e[f].state,c,0),Atomics.notify(e[f].state,l);a>e[f].buf.length;)r/=2,i=e[f].buf.slice(0,r),a=Buffer.byteLength(i);e[f].buf=e[f].buf.slice(r),D(e,i,t)}}}function A(e){if(e[f].flushing)throw Error(`unable to flush while flushing`);let t=Atomics.load(e[f].state,c),n=0;for(;;){let r=Atomics.load(e[f].state,l);if(r===-2)throw Error(`_flushSync failed`);if(r!==t)Atomics.wait(e[f].state,l,r,1e3);else break;if(++n===10)throw Error(`_flushSync took too long (10s)`)}}t.exports=w})),Lt=R(((e,t)=>{let{createRequire:n}=B(`module`),{existsSync:r}=B(`node:fs`),i=wt(),{join:a,isAbsolute:o,sep:s}=B(`node:path`),{fileURLToPath:c}=B(`node:url`),l=At(),u=Mt(),d=It();function f(e){u.register(e,v),u.registerBeforeExit(e,y),e.on(`close`,function(){u.unregister(e)})}function p(){let e=process.execArgv;for(let t=0;t<e.length;t++){let n=e[t];if(n===`--import`||n===`--require`||n===`-r`||n.startsWith(`--import=`)||n.startsWith(`--require=`)||n.startsWith(`-r=`))return!0}return!1}function m(e){let t=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);if(!t)return e;let n=[],r=!1;for(let e=0;e<t.length;e++){let i=t[e];if(i===`--require`||i===`-r`||i===`--import`){let a=t[e+1];if(a&&h(a)){r=!0,e++;continue}n.push(i),a&&(n.push(a),e++);continue}if((i.startsWith(`--require=`)||i.startsWith(`-r=`)||i.startsWith(`--import=`))&&h(i.slice(i.indexOf(`=`)+1))){r=!0;continue}n.push(i)}return r?n.join(` `):e}function h(e){let t=g(e);if(!t)return!1;let n=t;if(n.startsWith(`file://`))try{n=c(n)}catch{return!1}return o(n)&&!r(n)}function g(e){let t=e[0],n=e[e.length-1];return t===`"`&&n===`"`||t===`'`&&n===`'`?e.slice(1,-1):e}function _(e,t,n,r,i){if(!n.execArgv&&p()&&B.main===void 0&&(n={...n,execArgv:[]}),!n.env&&process.env.NODE_OPTIONS){let e=m(process.env.NODE_OPTIONS);e!==process.env.NODE_OPTIONS&&(n={...n,env:{...process.env,NODE_OPTIONS:e}})}n={...n,name:i};let a=new d({filename:e,workerData:t,workerOpts:n,sync:r});a.on(`ready`,o),a.on(`close`,function(){process.removeListener(`exit`,s)}),process.on(`exit`,s);function o(){process.removeListener(`exit`,s),a.unref(),n.autoEnd!==!1&&f(a)}function s(){a.closed||(a.flushSync(),l(100),a.end())}return a}function v(e){e.ref(),e.flushSync(),e.end(),e.once(`close`,function(){e.unref()})}function y(e){e.flushSync()}function b(e){let{pipeline:t,targets:r,levels:c,dedupe:l,worker:u={},caller:d=i(),sync:f=!1}=e,p={...e.options},m=typeof d==`string`?[d]:d,h=typeof globalThis==`object`&&Object.prototype.hasOwnProperty.call(globalThis,`__bundlerPathsOverrides`)&&globalThis.__bundlerPathsOverrides&&typeof globalThis.__bundlerPathsOverrides==`object`?globalThis.__bundlerPathsOverrides:Object.create(null),g=e.target;if(g&&r)throw Error(`only one of target or targets can be specified`);r?(g=h[`pino-worker`]||a(__dirname,`worker.js`),p.targets=r.filter(e=>e.target).map(e=>({...e,target:y(e.target)})),p.pipelines=r.filter(e=>e.pipeline).map(e=>e.pipeline.map(t=>({...t,level:e.level,target:y(t.target)})))):t&&(g=h[`pino-worker`]||a(__dirname,`worker.js`),p.pipelines=[t.map(e=>({...e,target:y(e.target)}))]),c&&(p.levels=c),l&&(p.dedupe=l),p.pinoWillSendConfig=!0;let v=r||t?`pino.transport`:g;return _(y(g),p,u,f,v);function y(e){if(e=h[e]||e,o(e)||e.indexOf(`file://`)===0)return e;if(e===`pino/file`)return a(__dirname,`..`,`file.js`);let t;for(let r of m)try{t=n(r===`node:repl`?process.cwd()+s:r).resolve(e);break}catch{continue}if(!t)throw Error(`unable to determine transport target for "${e}"`);return t}}t.exports=b})),Rt=R(((e,t)=>{let n=B(`node:diagnostics_channel`),r=kt(),{mapHttpRequest:i,mapHttpResponse:a}=Ct(),o=jt(),s=Mt(),{lsCacheSym:c,chindingsSym:l,writeSym:u,serializersSym:d,formatOptsSym:f,endSym:p,stringifiersSym:m,stringifySym:h,stringifySafeSym:g,wildcardFirstSym:_,nestedKeySym:v,formattersSym:y,messageKeySym:b,errorKeySym:x,nestedKeyStrSym:S,msgPrefixSym:C}=Et(),{isMainThread:w}=B(`worker_threads`),T=Lt(),[E]=process.versions.node.split(`.`).map(e=>Number(e)),D=n.tracingChannel(`pino_asJson`),O=E>=25?e=>JSON.stringify(e):j;function k(){}function A(e,t){if(!t)return n;return function(...r){t.call(this,r,n,e)};function n(t,...n){if(typeof t==`object`){let o=t;t!==null&&(t.method&&t.headers&&t.socket?t=i(t):typeof t.setHeader==`function`&&(t=a(t)));let s;o===null&&n.length===0?s=[null]:(o=n.shift(),s=n),typeof this[C]==`string`&&o!=null&&(o=this[C]+o),this[u](t,r(o,s,this[f]),e)}else{let i=t===void 0?n.shift():t;typeof this[C]==`string`&&i!=null&&(i=this[C]+i),this[u](null,r(i,n,this[f]),e)}}}function j(e){let t=``,n=0,r=!1,i=255,a=e.length;if(a>100)return JSON.stringify(e);for(var o=0;o<a&&i>=32;o++)i=e.charCodeAt(o),(i===34||i===92)&&(t+=e.slice(n,o)+`\\`,n=o,r=!0);return r?t+=e.slice(n):t=e,i<32?JSON.stringify(e):`"`+t+`"`}function M(e,t,n,r){if(D.hasSubscribers===!1)return N.call(this,e,t,n,r);let i={instance:this,arguments};return D.traceSync(N,i,this,e,t,n,r)}function N(e,t,n,r){let i=this[h],a=this[g],o=this[m],s=this[p],u=this[l],f=this[d],C=this[y],w=this[b],T=this[x],E=this[c][n]+r;E+=u;let D;C.log&&(e=C.log(e));let k=o[_],A=``;for(let t in e)if(D=e[t],Object.prototype.hasOwnProperty.call(e,t)&&D!==void 0){f[t]?D=f[t](D):t===T&&f.err&&(D=f.err(D));let e=o[t]||k;switch(typeof D){case`undefined`:case`function`:continue;case`number`:Number.isFinite(D)===!1&&(D=null);case`boolean`:e&&(D=e(D));break;case`string`:D=(e||O)(D);break;default:D=(e||i)(D,a)}if(D===void 0)continue;let n=O(t);A+=`,`+n+`:`+D}let j=``;if(t!==void 0){D=f[w]?f[w](t):t;let e=o[w]||k;switch(typeof D){case`function`:break;case`number`:Number.isFinite(D)===!1&&(D=null);case`boolean`:e&&(D=e(D)),j=`,"`+w+`":`+D;break;case`string`:D=(e||O)(D),j=`,"`+w+`":`+D;break;default:D=(e||i)(D,a),j=`,"`+w+`":`+D}}return this[v]&&A?E+this[S]+A.slice(1)+`}`+j+s:E+A+j+s}function P(e,t){let n,r=e[l],i=e[h],a=e[g],o=e[m],s=o[_],c=e[d],u=e[y].bindings;t=u(t);for(let e in t)if(n=t[e],((e.length<5||e!==`level`&&e!==`serializers`&&e!==`formatters`&&e!==`customLevels`)&&t.hasOwnProperty(e)&&n!==void 0)===!0){if(n=c[e]?c[e](n):n,n=(o[e]||s||i)(n,a),n===void 0)continue;r+=`,"`+e+`":`+n}return r}function ee(e){return e.write!==e.constructor.prototype.write}function F(e){let t=new o(e);return t.on(`error`,n),!e.sync&&w&&(s.register(t,te),t.on(`close`,function(){s.unregister(t)})),t;function n(e){if(e.code===`EPIPE`){t.write=k,t.end=k,t.flushSync=k,t.destroy=k;return}t.removeListener(`error`,n),t.emit(`error`,e)}}function te(e,t){e.destroyed||(t===`beforeExit`?(e.flush(),e.on(`drain`,function(){e.end()})):e.flushSync())}function ne(e){return function(t,n,r={},i){if(typeof r==`string`)i=F({dest:r}),r={};else if(typeof i==`string`){if(r&&r.transport)throw Error(`only one of option.transport or stream can be specified`);i=F({dest:i})}else if(r instanceof o||r.writable||r._writableState)i=r,r={};else if(r.transport){if(r.transport instanceof o||r.transport.writable||r.transport._writableState)throw Error(`option.transport do not allow stream, please pass to option directly. e.g. pino(transport)`);if(r.transport.targets&&r.transport.targets.length&&r.formatters&&typeof r.formatters.level==`function`)throw Error(`option.transport.targets do not allow custom level formatters`);let e;r.customLevels&&(e=r.useOnlyCustomLevels?r.customLevels:Object.assign({},r.levels,r.customLevels)),i=T({caller:n,...r.transport,levels:e})}if(r=Object.assign({},e,r),r.serializers=Object.assign({},e.serializers,r.serializers),r.formatters=Object.assign({},e.formatters,r.formatters),r.prettyPrint)throw Error(`prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)`);let{enabled:a,onChild:s}=r;return a===!1&&(r.level=`silent`),s||(r.onChild=k),i||=ee(process.stdout)?process.stdout:F({fd:process.stdout.fd||1}),{opts:r,stream:i}}}function I(e,t){try{return JSON.stringify(e)}catch{try{return(t||this[g])(e)}catch{return`"[unable to serialize, circular reference is too complex to analyze]"`}}}function re(e,t,n){return{level:e,bindings:t,log:n}}function ie(e){let t=Number(e);return typeof e==`string`&&Number.isFinite(t)?t:e===void 0?1:e}t.exports={noop:k,buildSafeSonicBoom:F,asChindings:P,asJson:M,genLog:A,createArgsNormalizer:ne,stringify:I,buildFormatters:re,normalizeDestFileDescriptor:ie}})),zt=R(((e,t)=>{t.exports={DEFAULT_LEVELS:{trace:10,debug:20,info:30,warn:40,error:50,fatal:60},SORTING_ORDER:{ASC:`ASC`,DESC:`DESC`}}})),Bt=R(((e,t)=>{let{lsCacheSym:n,levelValSym:r,useOnlyCustomLevelsSym:i,streamSym:a,formattersSym:o,hooksSym:s,levelCompSym:c}=Et(),{noop:l,genLog:u}=Rt(),{DEFAULT_LEVELS:d,SORTING_ORDER:f}=zt(),p={fatal:e=>{let t=u(d.fatal,e);return function(...e){let n=this[a];if(t.call(this,...e),typeof n.flushSync==`function`)try{n.flushSync()}catch{}}},error:e=>u(d.error,e),warn:e=>u(d.warn,e),info:e=>u(d.info,e),debug:e=>u(d.debug,e),trace:e=>u(d.trace,e)},m=Object.keys(d).reduce((e,t)=>(e[d[t]]=t,e),{}),h=Object.keys(m).reduce((e,t)=>(e[t]=`{"level":`+Number(t),e),{});function g(e){let t=e[o].level,{labels:r}=e.levels,i={};for(let e in r){let n=t(r[e],Number(e));i[e]=JSON.stringify(n).slice(0,-1)}return e[n]=i,e}function _(e,t){if(t)return!1;switch(e){case`fatal`:case`error`:case`warn`:case`info`:case`debug`:case`trace`:return!0;default:return!1}}function v(e){let{labels:t,values:n}=this.levels;if(typeof e==`number`){if(t[e]===void 0)throw Error(`unknown level value`+e);e=t[e]}if(n[e]===void 0)throw Error(`unknown level `+e);let a=this[r],o=this[r]=n[e],d=this[i],f=this[c],m=this[s].logMethod;for(let e in n){if(f(n[e],o)===!1){this[e]=l;continue}this[e]=_(e,d)?p[e](m):u(n[e],m)}this.emit(`level-change`,e,o,t[a],a,this)}function y(e){let{levels:t,levelVal:n}=this;return t&&t.labels?t.labels[n]:``}function b(e){let{values:t}=this.levels,n=t[e];return n!==void 0&&this[c](n,this[r])}function x(e,t,n){return e===f.DESC?t<=n:t>=n}function S(e){return typeof e==`string`?x.bind(null,e):e}function C(e=null,t=!1){let n=e?Object.keys(e).reduce((t,n)=>(t[e[n]]=n,t),{}):null;return{labels:Object.assign(Object.create(Object.prototype,{Infinity:{value:`silent`}}),t?null:m,n),values:Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),t?null:d,e)}}function w(e,t,n){if(typeof e==`number`){if(![].concat(Object.keys(t||{}).map(e=>t[e]),n?[]:Object.keys(m).map(e=>+e),1/0).includes(e))throw Error(`default level:${e} must be included in custom levels`);return}if(!(e in Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),n?null:d,t)))throw Error(`default level:${e} must be included in custom levels`)}function T(e,t){let{labels:n,values:r}=e;for(let e in t){if(e in r)throw Error(`levels cannot be overridden`);if(t[e]in n)throw Error(`pre-existing level values cannot be used for new levels`)}}function E(e){if(typeof e!=`function`&&!(typeof e==`string`&&Object.values(f).includes(e)))throw Error(`Levels comparison should be one of "ASC", "DESC" or "function" type`)}t.exports={initialLsCache:h,genLsCache:g,levelMethods:p,getLevel:y,setLevel:v,isLevelEnabled:b,mappings:C,assertNoLevelCollisions:T,assertDefaultLevelFound:w,genLevelComparison:S,assertLevelComparison:E}})),Vt=R(((e,t)=>{t.exports={version:`10.3.1`}})),Ht=R(((e,t)=>{let{EventEmitter:n}=B(`node:events`),{lsCacheSym:r,levelValSym:i,setLevelSym:a,getLevelSym:o,chindingsSym:s,mixinSym:c,asJsonSym:l,writeSym:u,mixinMergeStrategySym:d,timeSym:f,timeSliceIndexSym:p,streamSym:m,serializersSym:h,formattersSym:g,errorKeySym:_,messageKeySym:v,useOnlyCustomLevelsSym:y,needsMetadataGsym:b,redactFmtSym:x,stringifySym:S,formatOptsSym:C,stringifiersSym:w,msgPrefixSym:T,hooksSym:E}=Et(),{getLevel:D,setLevel:O,isLevelEnabled:k,mappings:A,initialLsCache:j,genLsCache:M,assertNoLevelCollisions:N}=Bt(),{asChindings:P,asJson:ee,buildFormatters:F,stringify:te,noop:ne}=Rt(),{version:I}=Vt(),re=Dt(),ie={constructor:class{},child:oe,bindings:se,setBindings:ce,flush:le,isLevelEnabled:k,version:I,get level(){return this[o]()},set level(e){this[a](e)},get levelVal(){return this[i]},set levelVal(e){throw Error(`levelVal is read-only`)},get msgPrefix(){return this[T]},get[Symbol.toStringTag](){return`Pino`},[r]:j,[u]:R,[l]:ee,[o]:D,[a]:O};Object.setPrototypeOf(ie,n.prototype),t.exports=function(){return Object.create(ie)};let ae=e=>e;function oe(e,t){if(!e)throw Error(`missing bindings for child Pino`);let n=this[h],r=this[g],i=Object.create(this);if(t==null)return i[g].bindings!==ae&&(i[g]=F(r.level,ae,r.log)),i[s]=P(i,e),this.onChild!==ne&&this.onChild(i),i;if(t.hasOwnProperty(`serializers`)===!0){i[h]=Object.create(null);for(let e in n)i[h][e]=n[e];let e=Object.getOwnPropertySymbols(n);for(var o=0;o<e.length;o++){let t=e[o];i[h][t]=n[t]}for(let e in t.serializers)i[h][e]=t.serializers[e];let r=Object.getOwnPropertySymbols(t.serializers);for(var c=0;c<r.length;c++){let e=r[c];i[h][e]=t.serializers[e]}}else i[h]=n;if(t.hasOwnProperty(`formatters`)){let{level:e,bindings:n,log:a}=t.formatters;i[g]=F(e||r.level,n||ae,a||r.log)}else i[g]=F(r.level,ae,r.log);if(t.hasOwnProperty(`customLevels`)===!0&&(N(this.levels,t.customLevels),i.levels=A(t.customLevels,i[y]),M(i)),typeof t.redact==`object`&&t.redact!==null||Array.isArray(t.redact)){i.redact=t.redact;let e=re(i.redact,te),n={stringify:e[x]};i[S]=te,i[w]=e,i[C]=n}if(typeof t.msgPrefix==`string`&&(i[T]=(this[T]||``)+t.msgPrefix),i[s]=P(i,e),t.level!==void 0&&t.level!==this.level||t.hasOwnProperty(`customLevels`)){let e=t.level||this.level;i[a](e)}return this.onChild(i),i}function se(){let e=`{${this[s].substr(1)}}`,t=JSON.parse(e);return delete t.pid,delete t.hostname,t}function ce(e){let t=P(this,e);this[s]=t}function L(e,t){return Object.assign(t,e)}function R(e,t,n){let r=this[f](),i=this[c],a=this[_],o=this[v],s=this[d]||L,u,h=this[E].streamWrite;e==null?u={}:e instanceof Error?(u={[a]:e},t===void 0&&(t=e.message)):(u=e,t===void 0&&e[o]===void 0&&e[a]&&(t=e[a].message)),i&&(u=s(u,i(u,n,this)));let g=this[l](u,t,n,r),y=this[m];y[b]===!0&&(y.lastLevel=n,y.lastObj=u,y.lastMsg=t,y.lastTime=r.slice(this[p]),y.lastLogger=this),y.write(h?h(g):g)}function le(e){if(e!=null&&typeof e!=`function`)throw Error(`callback must be a function`);let t=this[m];typeof t.flush==`function`?t.flush(e||ne):e&&e()}})),Ut=R(((e,t)=>{let{hasOwnProperty:n}=Object.prototype,r=_();r.configure=_,r.stringify=r,r.default=r,e.stringify=r,e.configure=_,t.exports=r;let i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function a(e){return e.length<5e3&&!i.test(e)?`"${e}"`:JSON.stringify(e)}function o(e,t){if(e.length>200||t)return e.sort(t);for(let t=1;t<e.length;t++){let n=e[t],r=t;for(;r!==0&&e[r-1]>n;)e[r]=e[r-1],r--;e[r]=n}return e}let s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(e){return s.call(e)!==void 0&&e.length!==0}function l(e,t,n){e.length<n&&(n=e.length);let r=t===`,`?``:` `,i=`"0":${r}${e[0]}`;for(let a=1;a<n;a++)i+=`${t}"${a}":${r}${e[a]}`;return i}function u(e){if(n.call(e,`circularValue`)){let t=e.circularValue;if(typeof t==`string`)return`"${t}"`;if(t==null)return t;if(t===Error||t===TypeError)return{toString(){throw TypeError(`Converting circular structure to JSON`)}};throw TypeError(`The "circularValue" argument must be of type string or the value null or undefined`)}return`"[Circular]"`}function d(e){let t;if(n.call(e,`deterministic`)&&(t=e.deterministic,typeof t!=`boolean`&&typeof t!=`function`))throw TypeError(`The "deterministic" argument must be of type boolean or comparator function`);return t===void 0?!0:t}function f(e,t){let r;if(n.call(e,t)&&(r=e[t],typeof r!=`boolean`))throw TypeError(`The "${t}" argument must be of type boolean`);return r===void 0?!0:r}function p(e,t){let r;if(n.call(e,t)){if(r=e[t],typeof r!=`number`)throw TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(r))throw TypeError(`The "${t}" argument must be an integer`);if(r<1)throw RangeError(`The "${t}" argument must be >= 1`)}return r===void 0?1/0:r}function m(e){return e===1?`1 item`:`${e} items`}function h(e){let t=new Set;for(let n of e)(typeof n==`string`||typeof n==`number`)&&t.add(String(n));return t}function g(e){if(n.call(e,`strict`)){let t=e.strict;if(typeof t!=`boolean`)throw TypeError(`The "strict" argument must be of type boolean`);if(t)return e=>{let t=`Object can not safely be stringified. Received type ${typeof e}`;throw typeof e!=`function`&&(t+=` (${e.toString()})`),Error(t)}}}function _(e){e={...e};let t=g(e);t&&(e.bigint===void 0&&(e.bigint=!1),`circularValue`in e||(e.circularValue=Error));let n=u(e),r=f(e,`bigint`),i=d(e),s=typeof i==`function`?i:void 0,_=p(e,`maximumDepth`),v=p(e,`maximumBreadth`);function y(e,l,u,d,f,p){let h=l[e];switch(typeof h==`object`&&h&&typeof h.toJSON==`function`&&(h=h.toJSON(e)),h=d.call(l,e,h),typeof h){case`string`:return a(h);case`object`:{if(h===null)return`null`;if(u.indexOf(h)!==-1)return n;let e=``,t=`,`,r=p;if(Array.isArray(h)){if(h.length===0)return`[]`;if(_<u.length+1)return`"[Array]"`;u.push(h),f!==``&&(p+=f,e+=`\n${p}`,t=`,\n${p}`);let n=Math.min(h.length,v),i=0;for(;i<n-1;i++){let n=y(String(i),h,u,d,f,p);e+=n===void 0?`null`:n,e+=t}let a=y(String(i),h,u,d,f,p);if(e+=a===void 0?`null`:a,h.length-1>v){let n=h.length-v-1;e+=`${t}"... ${m(n)} not stringified"`}return f!==``&&(e+=`\n${r}`),u.pop(),`[${e}]`}let l=Object.keys(h),g=l.length;if(g===0)return`{}`;if(_<u.length+1)return`"[Object]"`;let b=``,x=``;f!==``&&(p+=f,t=`,\n${p}`,b=` `);let S=Math.min(g,v);i&&!c(h)&&(l=o(l,s)),u.push(h);for(let n=0;n<S;n++){let r=l[n],i=y(r,h,u,d,f,p);i!==void 0&&(e+=`${x}${a(r)}:${b}${i}`,x=t)}if(g>v){let n=g-v;e+=`${x}"...":${b}"${m(n)} not stringified"`,x=t}return f!==``&&x.length>1&&(e=`\n${p}${e}\n${r}`),u.pop(),`{${e}}`}case`number`:return isFinite(h)?String(h):t?t(h):`null`;case`boolean`:return h===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(h);default:return t?t(h):void 0}}function b(e,i,o,s,c,l){switch(typeof i==`object`&&i&&typeof i.toJSON==`function`&&(i=i.toJSON(e)),typeof i){case`string`:return a(i);case`object`:{if(i===null)return`null`;if(o.indexOf(i)!==-1)return n;let e=l,t=``,r=`,`;if(Array.isArray(i)){if(i.length===0)return`[]`;if(_<o.length+1)return`"[Array]"`;o.push(i),c!==``&&(l+=c,t+=`\n${l}`,r=`,\n${l}`);let n=Math.min(i.length,v),a=0;for(;a<n-1;a++){let e=b(String(a),i[a],o,s,c,l);t+=e===void 0?`null`:e,t+=r}let u=b(String(a),i[a],o,s,c,l);if(t+=u===void 0?`null`:u,i.length-1>v){let e=i.length-v-1;t+=`${r}"... ${m(e)} not stringified"`}return c!==``&&(t+=`\n${e}`),o.pop(),`[${t}]`}o.push(i);let u=``;c!==``&&(l+=c,r=`,\n${l}`,u=` `);let d=``;for(let e of s){let n=b(e,i[e],o,s,c,l);n!==void 0&&(t+=`${d}${a(e)}:${u}${n}`,d=r)}return c!==``&&d.length>1&&(t=`\n${l}${t}\n${e}`),o.pop(),`{${t}}`}case`number`:return isFinite(i)?String(i):t?t(i):`null`;case`boolean`:return i===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(i);default:return t?t(i):void 0}}function x(e,u,d,f,p){switch(typeof u){case`string`:return a(u);case`object`:{if(u===null)return`null`;if(typeof u.toJSON==`function`){if(u=u.toJSON(e),typeof u!=`object`)return x(e,u,d,f,p);if(u===null)return`null`}if(d.indexOf(u)!==-1)return n;let t=p;if(Array.isArray(u)){if(u.length===0)return`[]`;if(_<d.length+1)return`"[Array]"`;d.push(u),p+=f;let e=`\n${p}`,n=`,\n${p}`,r=Math.min(u.length,v),i=0;for(;i<r-1;i++){let t=x(String(i),u[i],d,f,p);e+=t===void 0?`null`:t,e+=n}let a=x(String(i),u[i],d,f,p);if(e+=a===void 0?`null`:a,u.length-1>v){let t=u.length-v-1;e+=`${n}"... ${m(t)} not stringified"`}return e+=`\n${t}`,d.pop(),`[${e}]`}let r=Object.keys(u),h=r.length;if(h===0)return`{}`;if(_<d.length+1)return`"[Object]"`;p+=f;let g=`,\n${p}`,y=``,b=``,S=Math.min(h,v);c(u)&&(y+=l(u,g,v),r=r.slice(u.length),S-=u.length,b=g),i&&(r=o(r,s)),d.push(u);for(let e=0;e<S;e++){let t=r[e],n=x(t,u[t],d,f,p);n!==void 0&&(y+=`${b}${a(t)}: ${n}`,b=g)}if(h>v){let e=h-v;y+=`${b}"...": "${m(e)} not stringified"`,b=g}return b!==``&&(y=`\n${p}${y}\n${t}`),d.pop(),`{${y}}`}case`number`:return isFinite(u)?String(u):t?t(u):`null`;case`boolean`:return u===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(u);default:return t?t(u):void 0}}function S(e,u,d){switch(typeof u){case`string`:return a(u);case`object`:{if(u===null)return`null`;if(typeof u.toJSON==`function`){if(u=u.toJSON(e),typeof u!=`object`)return S(e,u,d);if(u===null)return`null`}if(d.indexOf(u)!==-1)return n;let t=``,r=u.length!==void 0;if(r&&Array.isArray(u)){if(u.length===0)return`[]`;if(_<d.length+1)return`"[Array]"`;d.push(u);let e=Math.min(u.length,v),n=0;for(;n<e-1;n++){let e=S(String(n),u[n],d);t+=e===void 0?`null`:e,t+=`,`}let r=S(String(n),u[n],d);if(t+=r===void 0?`null`:r,u.length-1>v){let e=u.length-v-1;t+=`,"... ${m(e)} not stringified"`}return d.pop(),`[${t}]`}let f=Object.keys(u),p=f.length;if(p===0)return`{}`;if(_<d.length+1)return`"[Object]"`;let h=``,g=Math.min(p,v);r&&c(u)&&(t+=l(u,`,`,v),f=f.slice(u.length),g-=u.length,h=`,`),i&&(f=o(f,s)),d.push(u);for(let e=0;e<g;e++){let n=f[e],r=S(n,u[n],d);r!==void 0&&(t+=`${h}${a(n)}:${r}`,h=`,`)}if(p>v){let e=p-v;t+=`${h}"...":"${m(e)} not stringified"`}return d.pop(),`{${t}}`}case`number`:return isFinite(u)?String(u):t?t(u):`null`;case`boolean`:return u===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(u);default:return t?t(u):void 0}}function C(e,t,n){if(arguments.length>1){let r=``;if(typeof n==`number`?r=` `.repeat(Math.min(n,10)):typeof n==`string`&&(r=n.slice(0,10)),t!=null){if(typeof t==`function`)return y(``,{"":e},[],t,r,``);if(Array.isArray(t))return b(``,e,[],h(t),r,``)}if(r.length!==0)return x(``,e,[],r,``)}return S(``,e,[])}return C}})),Wt=R(((e,t)=>{let n=Symbol.for(`pino.metadata`),{DEFAULT_LEVELS:r}=zt(),i=r.info;function a(e,t){e||=[],t||={dedupe:!1};let a=Object.create(r);a.silent=1/0,t.levels&&typeof t.levels==`object`&&Object.keys(t.levels).forEach(e=>{a[e]=t.levels[e]});let u={write:d,add:m,remove:h,emit:f,flushSync:p,end:g,minLevel:0,lastId:0,streams:[],clone:_,[n]:!0,streamLevels:a};return Array.isArray(e)?e.forEach(m,u):m.call(u,e),e=null,u;function d(e){let r,i=this.lastLevel,{streams:a}=this,o=0,u;for(let d=s(a.length,t.dedupe);l(d,a.length,t.dedupe);d=c(d,t.dedupe))if(r=a[d],r.level<=i){if(o!==0&&o!==r.level)break;if(u=r.stream,u[n]){let{lastTime:e,lastMsg:t,lastObj:n,lastLogger:r}=this;u.lastLevel=i,u.lastTime=e,u.lastMsg=t,u.lastObj=n,u.lastLogger=r}u.write(e),t.dedupe&&(o=r.level)}else if(!t.dedupe)break}function f(...e){for(let{stream:t}of this.streams)typeof t.emit==`function`&&t.emit(...e)}function p(){for(let{stream:e}of this.streams)typeof e.flushSync==`function`&&e.flushSync()}function m(e){if(!e)return u;let t=typeof e.write==`function`||e.stream,n=e.write?e:e.stream;if(!t)throw Error(`stream object needs to implement either StreamEntry or DestinationStream interface`);let{streams:r,streamLevels:a}=this,s;s=typeof e.levelVal==`number`?e.levelVal:typeof e.level==`string`?a[e.level]:typeof e.level==`number`?e.level:i;let c={stream:n,level:s,levelVal:void 0,id:++u.lastId};return r.unshift(c),r.sort(o),this.minLevel=r[0].level,u}function h(e){let{streams:t}=this,n=t.findIndex(t=>t.id===e);return n>=0&&(t.splice(n,1),t.sort(o),this.minLevel=t.length>0?t[0].level:-1),u}function g(){for(let{stream:e}of this.streams)typeof e.flushSync==`function`&&e.flushSync(),e.end()}function _(e){let t=Array(this.streams.length);for(let n=0;n<t.length;n++)t[n]={level:e,stream:this.streams[n].stream};return{write:d,add:m,remove:h,minLevel:e,streams:t,clone:_,emit:f,flushSync:p,[n]:!0}}}function o(e,t){return e.level-t.level}function s(e,t){return t?e-1:0}function c(e,t){return t?e-1:e+1}function l(e,t,n){return n?e>=0:e<t}t.exports=a})),Gt=z(R(((e,t)=>{let n=B(`node:os`),r=Ct(),i=wt(),a=Dt(),o=Ot(),s=Ht(),c=Et(),{configure:l}=Ut(),{assertDefaultLevelFound:u,mappings:d,genLsCache:f,genLevelComparison:p,assertLevelComparison:m}=Bt(),{DEFAULT_LEVELS:h,SORTING_ORDER:g}=zt(),{createArgsNormalizer:_,asChindings:v,buildSafeSonicBoom:y,buildFormatters:b,stringify:x,normalizeDestFileDescriptor:S,noop:C}=Rt(),{version:w}=Vt(),{chindingsSym:T,redactFmtSym:E,serializersSym:D,timeSym:O,timeSliceIndexSym:k,streamSym:A,stringifySym:j,stringifySafeSym:M,stringifiersSym:N,setLevelSym:P,endSym:ee,formatOptsSym:F,messageKeySym:te,errorKeySym:ne,nestedKeySym:I,mixinSym:re,levelCompSym:ie,useOnlyCustomLevelsSym:ae,formattersSym:oe,hooksSym:se,nestedKeyStrSym:ce,mixinMergeStrategySym:L,msgPrefixSym:R}=c,{epochTime:le,nullTime:ue}=o,{pid:z}=process,V=n.hostname(),de=r.err,fe=_({level:`info`,levelComparison:g.ASC,levels:h,messageKey:`msg`,errorKey:`err`,nestedKey:null,enabled:!0,base:{pid:z,hostname:V},serializers:Object.assign(Object.create(null),{err:de}),formatters:Object.assign(Object.create(null),{bindings(e){return e},level(e,t){return{level:t}}}),hooks:{logMethod:void 0,streamWrite:void 0},timestamp:le,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,depthLimit:5,edgeLimit:100}),pe=Object.assign(Object.create(null),r);function H(...e){let t={},{opts:n,stream:r}=fe(t,i(),...e);n.level&&typeof n.level==`string`&&h[n.level.toLowerCase()]!==void 0&&(n.level=n.level.toLowerCase());let{redact:o,crlf:c,serializers:g,timestamp:_,messageKey:y,errorKey:S,nestedKey:w,base:z,name:B,level:V,customLevels:de,levelComparison:pe,mixin:H,mixinMergeStrategy:U,useOnlyCustomLevels:me,formatters:he,hooks:W,depthLimit:ge,edgeLimit:_e,onChild:ve,msgPrefix:ye}=n,be=l({maximumDepth:ge,maximumBreadth:_e}),xe=b(he.level,he.bindings,he.log),Se=x.bind({[M]:be}),Ce=o?a(o,Se):{},we=o?{stringify:Ce[E]}:{stringify:Se},Te=`}`+(c?`\r
|
|
16
16
|
`:`
|
|
17
|
-
`),De=v.bind(null,{[T]:``,[D]:g,[N]:we,[j]:x,[M]:xe,[ae]:Se}),Oe=``;B!==null&&(Oe=De(V===void 0?B:Object.assign({},B,{name:V})));let ke=_ instanceof Function?_:_?ce:le,Ae=ke().indexOf(`:`)+1;if(he&&!de)throw Error(`customLevels is required if useOnlyCustomLevels is set true`);if(H&&typeof H!=`function`)throw Error(`Unknown mixin type "${typeof H}" - expected "function"`);if(be&&typeof be!=`string`)throw Error(`Unknown msgPrefix type "${typeof be}" - expected "string"`);u(ue,de,he);let je=d(de,he);typeof r.emit==`function`&&r.emit(`message`,{code:`PINO_CONFIG`,config:{levels:je,messageKey:y,errorKey:S}}),m(pe);let Me=p(pe);return Object.assign(t,{levels:je,[re]:Me,[ie]:he,[A]:r,[O]:ke,[k]:Ae,[j]:x,[M]:xe,[N]:we,[ee]:Ee,[F]:Te,[I]:y,[te]:S,[L]:w,[R]:w?`,${JSON.stringify(w)}:{`:``,[D]:g,[ne]:H,[z]:me,[T]:Oe,[ae]:Se,[oe]:ge,silent:C,onChild:ye,[se]:be}),Object.setPrototypeOf(t,s()),f(t),t[P](ue),t}t.exports=H,t.exports.destination=(e=process.stdout.fd)=>typeof e==`object`?(e.dest=S(e.dest||process.stdout.fd),y(e)):y({dest:S(e),minLength:0}),t.exports.transport=It(),t.exports.multistream=Ut(),t.exports.levels=d(),t.exports.stdSerializers=pe,t.exports.stdTimeFunctions=Object.assign({},o),t.exports.symbols=c,t.exports.version=w,t.exports.default=H,t.exports.pino=H}))(),1),Gt=class extends D{_filePath;_fileDir;_fileExt;_fileStem;_fileBaseName;_options;_label;_size=0;_stream;_init;constructor(e,t={}){if(super(),!e)throw Error(`A log filename is required`);let r=a(e);this._filePath=e,this._fileDir=r.dir,this._fileExt=r.ext,this._fileStem=r.name,this._fileBaseName=n(e),this._options={size:t.size??0,backups:t.backups??1,flags:t.flags??`a`,mode:t.mode??384,encoding:t.encoding??`utf8`},this._label=this._format(new Date),this._init=this._initialize()}_write(e,t,n){this._writeChunk(e,t).then(()=>n(),n)}_final(e){this._close().then(()=>e(),e)}async _initialize(){await b(this._fileDir,{recursive:!0});let e=await Jt(this._filePath);if(e){let t=this._format(e.mtime),n=t!==this._label,r=this._options.size>0&&e.size>=this._options.size;n||r?await this._rotateHotFile(t):this._size=e.size}this._stream=this._open()}async _writeChunk(e,t){await this._init;let n=Buffer.isBuffer(e)?e.byteLength:Buffer.byteLength(e,t);await this._rotateIfNeeded(),await new Promise((n,r)=>{this._stream.write(e,t,e=>{e?r(e):n()})}),this._size+=n}_open(){let e=f(this._filePath,{flags:this._options.flags,mode:this._options.mode,encoding:this._options.encoding});return e.on(`error`,e=>{this.destroy(e)}),e}async _close(){if(await this._init.catch(()=>void 0),!this._stream)return;let e=this._stream;this._stream=void 0,await new Promise((t,n)=>{let r=()=>{e.off(`error`,i),t()},i=t=>{e.off(`close`,r),n(t)};e.once(`close`,r),e.once(`error`,i),e.end()})}async _rotateIfNeeded(){let e=this._format(new Date),t=e!==this._label,n=this._options.size>0&&this._size>=this._options.size;if(!t&&!n)return;await this._close();let r=await Jt(this._filePath);r&&r.size>0&&await this._rotateHotFile(this._label),this._label=e,this._size=0,this._stream=this._open()}async _rotateHotFile(e){if(!await Jt(this._filePath))return;let t=await this._getNextRotatedPath(e);await S(this._filePath,t),await this._pruneBackups()}async _getNextRotatedPath(e){let t=(await this._listRotatedFiles()).filter(t=>t.label===e).reduce((e,t)=>Math.max(e,t.index),0)+1;return i(this._fileDir,this._buildRotatedFileName(e,t))}_buildRotatedFileName(e,t){return this._fileExt?`${this._fileStem}.${e}.${t}${this._fileExt}`:`${this._fileBaseName}.${e}.${t}`}async _pruneBackups(){let e=(await this._listRotatedFiles()).sort((e,t)=>e.label===t.label?t.index-e.index:t.label.localeCompare(e.label)).slice(this._options.backups);await Promise.all(e.map(e=>C(e.path,{force:!0})))}async _listRotatedFiles(){let e=await x(this._fileDir),t=[],n=this._getRotatedFilePattern();for(let r of e){let e=n.exec(r);e?.groups&&t.push({label:e.groups.label,index:Number.parseInt(e.groups.index,10),path:i(this._fileDir,r)})}return t}_getRotatedFilePattern(){return this._fileExt?RegExp(`^${qt(this._fileStem)}\\.(?<label>.+)\\.(?<index>\\d+)${qt(this._fileExt)}$`,`u`):RegExp(`^${qt(this._fileBaseName)}\\.(?<label>.+)\\.(?<index>\\d+)$`,`u`)}_format(e){return`${Kt(e.getFullYear(),4)}-${Kt(e.getMonth()+1)}-${Kt(e.getDate())}`}};function Kt(e,t=2){return e.toString().padStart(t,`0`)}function qt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}async function Jt(e){try{return await w(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}}let Yt;var Xt=class{_category;_factory;_logger;constructor(e){this._category=e}trace(...e){this._log?.trace(...e)}debug(...e){this._log?.debug(...e)}info(...e){this._log?.info(...e)}warn(...e){this._log?.warn(...e)}error(...e){this._log?.error(...e)}fatal(...e){this._log?.fatal(...e)}get _log(){if(!Yt){this._factory=void 0,this._logger=void 0;return}return(this._factory!==Yt||!this._logger)&&(this._factory=Yt,this._logger=Yt.create(this._category)),this._logger}};function Zt(e){switch(e=e?.toLowerCase(),e){case`trace`:case`debug`:case`info`:case`warn`:case`error`:case`fatal`:case`silent`:return e;default:return`info`}}function Qt(e){let t=process.env.WALLABY_CLI_LOG_PATH;function n(){let e=process.env.WALLABY_CLI_LOG_LEVEL;return e?Zt(e):`info`}function r(e,t){let n=Number.parseInt(e??``,10);return Number.isInteger(n)&&n>0?n:t}return{path:e?.path??t??i(u(),`wallaby-cli.log`),level:e?.level??n(),size:e?.size??r(process.env.WALLABY_CLI_LOG_MAX_SIZE,10*1024*1024),backups:e?.backups??r(process.env.WALLABY_CLI_LOG_MAX_BACKUPS,7)}}function $t(e){if(Yt)throw Error(`Logger is already initialized`);e=Qt(e),W.default.ensureDirSync(r(e.path));let t=new Gt(e.path,{size:e.size,backups:e.backups,flags:`a`,mode:384,encoding:`utf8`});function n(e){process.stderr.write(`[logger] ${e.stack||e.message}\n`)}t.on(`error`,n);function i(e){let t=(t,n)=>{e.fatal({err:t,origin:n},`Uncaught exception`)},n=t=>{e.error({reason:t},`Unhandled promise rejection`)};return process.on(`uncaughtExceptionMonitor`,t),process.on(`unhandledRejection`,n),()=>{process.off(`uncaughtExceptionMonitor`,t),process.off(`unhandledRejection`,n)}}let a=(0,Wt.default)({level:e.level,timestamp:Wt.default.stdTimeFunctions.isoTime,base:{pid:process.pid},errorKey:`error`,formatters:{level(e){return{level:e}}}},t),o=i(a);Yt={create(e){return a.child({category:e})},async close(){o(),t.off(`error`,n),await new Promise((e,n)=>{t.end(t=>{t?n(t):e()})})}},a.debug(`Initialized CLI logger`)}function en(e){return new Xt(e)}async function tn(){let e=Yt;e&&(Yt=void 0,await e.close())}var K={initialize:$t,create:en,shutdown:tn};const nn=_(import.meta.url),rn=process.platform===`win32`,an=ln(),on=rn?e=>e.replace(/\\/g,o.sep):e=>e,sn=an?e=>e:e=>e.toLowerCase(),cn=e=>o.normalize(sn(on(e)));function ln(){return rn?!1:!p(un(nn))}function un(e){return e.replace(/\w/g,e=>{let t=e.toUpperCase();return e===t?e.toLowerCase():t})}var dn=z(((e,t)=>{t.exports=[`|/-\\`,`⠂-–—–-`,`◐◓◑◒`,`◴◷◶◵`,`◰◳◲◱`,`▖▘▝▗`,`■□▪▫`,`▌▀▐▄`,`▉▊▋▌▍▎▏▎▍▌▋▊▉`,`▁▃▄▅▆▇█▇▆▅▄▃`,`←↖↑↗→↘↓↙`,`┤┘┴└├┌┬┐`,`◢◣◤◥`,`.oO°Oo.`,`.oO@*`,[`🌍`,`🌎`,`🌏`],`◡◡ ⊙⊙ ◠◠`,`☱☲☴`,`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,`⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓`,`⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆`,`⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋`,`⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁`,`⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈`,`⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈`,`⢄⢂⢁⡁⡈⡐⡠`,`⢹⢺⢼⣸⣇⡧⡗⡏`,`⣾⣽⣻⢿⡿⣟⣯⣷`,`⠁⠂⠄⡀⢀⠠⠐⠈`,[`🌑`,`🌒`,`🌓`,`🌔`,`🌕`,`🌝`,`🌖`,`🌗`,`🌘`,`🌚`],[`🕛`,`🕐`,`🕑`,`🕒`,`🕓`,`🕔`,`🕕`,`🕖`,`🕗`,`🕘`,`🕙`,`🕚`]]})),fn=z((e=>{var t=B(`readline`),n=0,r=60;function i(e){this.clearLine(this.stream),this.stream.write(e)}var a=function(e){if(!(this instanceof a))return new a(e);typeof e==`string`?e={text:e}:e||={},this.text=e.text||``,this.setSpinnerString(n),this.setSpinnerDelay(r),this.onTick=e.onTick||i,this.stream=e.stream||process.stdout};a.spinners=dn(),a.setDefaultSpinnerString=function(e){return n=e,this},a.setDefaultSpinnerDelay=function(e){return r=e,this},a.prototype.start=function(){if(this.stream===process.stdout&&this.stream.isTTY!==!0)return this;var e=0,t=this,n=function(){var n=t.text.indexOf(`%s`)>-1?t.text.replace(`%s`,t.chars[e]):t.chars[e]+` `+t.text;t.onTick(n),e=++e%t.chars.length};return n(),this.id=setInterval(n,this.delay),this},a.prototype.isSpinning=function(){return this.id!==void 0},a.prototype.setSpinnerDelay=function(e){return this.delay=e,this},a.prototype.setSpinnerString=function(e){let t=s(e,this.spinners);return this.chars=Array.isArray(t)?t:t.split(``),this},a.prototype.setSpinnerTitle=function(e){return this.text=e,this},a.prototype.stop=function(e){return this.isSpinning===!1?this:(clearInterval(this.id),this.id=void 0,e&&this.clearLine(this.stream),this)},a.prototype.clearLine=function(e){return t.clearLine(e,0),t.cursorTo(e,0),this};function o(e){return typeof e==`number`&&e%1==0}function s(e,t){if(!o(e))return e+``;var n=a.spinners.length;return e=e>=n?0:e,e=e<0?n+e:e,a.spinners[e]}e.Spinner=a})),pn=z(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),mn=z(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),hn=z(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=pn(),a=mn();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),gn=z(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),_n=z(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),q=z(((e,t)=>{let n=mn(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=pn(),{safeRe:a,t:o}=hn(),s=gn(),{compareIdentifiers:c}=_n();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),vn=z(((e,t)=>{let n=q();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),yn=z(((e,t)=>{let n=vn();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),bn=z(((e,t)=>{let n=vn();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),xn=z(((e,t)=>{let n=q();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),Sn=z(((e,t)=>{let n=vn();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),Cn=z(((e,t)=>{let n=q();t.exports=(e,t)=>new n(e,t).major})),wn=z(((e,t)=>{let n=q();t.exports=(e,t)=>new n(e,t).minor})),Tn=z(((e,t)=>{let n=q();t.exports=(e,t)=>new n(e,t).patch})),En=z(((e,t)=>{let n=vn();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),J=z(((e,t)=>{let n=q();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),Dn=z(((e,t)=>{let n=J();t.exports=(e,t,r)=>n(t,e,r)})),On=z(((e,t)=>{let n=J();t.exports=(e,t)=>n(e,t,!0)})),kn=z(((e,t)=>{let n=q();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),An=z(((e,t)=>{let n=kn();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),jn=z(((e,t)=>{let n=kn();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),Mn=z(((e,t)=>{let n=J();t.exports=(e,t,r)=>n(e,t,r)>0})),Nn=z(((e,t)=>{let n=J();t.exports=(e,t,r)=>n(e,t,r)<0})),Pn=z(((e,t)=>{let n=J();t.exports=(e,t,r)=>n(e,t,r)===0})),Fn=z(((e,t)=>{let n=J();t.exports=(e,t,r)=>n(e,t,r)!==0})),In=z(((e,t)=>{let n=J();t.exports=(e,t,r)=>n(e,t,r)>=0})),Ln=z(((e,t)=>{let n=J();t.exports=(e,t,r)=>n(e,t,r)<=0})),Rn=z(((e,t)=>{let n=Pn(),r=Fn(),i=Mn(),a=In(),o=Nn(),s=Ln();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),zn=z(((e,t)=>{let n=q(),r=vn(),{safeRe:i,t:a}=hn();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)}})),Bn=z(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),Y=z(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,O(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>D(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let b=[..._.values()];return r.set(t,b),b}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(k(this.set[t],e,this.options))return!0;return!1}};let r=new(Bn()),i=gn(),a=Vn(),o=mn(),s=q(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=hn(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=pn(),h=e=>e.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=S(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=w(e,t),o(`xrange`,e),e=E(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>x(e,t)).join(` `),x=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},S=(e,t)=>e.trim().split(/\s+/).map(e=>C(e,t)).join(` `),C=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},w=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>T(e,t)).join(` `)),T=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},E=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),D=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),O=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),k=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(o(e[n].semver),e[n].semver!==a.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),Vn=z(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new l(t.value,n).test(this.value):t.operator===``?t.value===``?!0:new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=gn(),{safeRe:i,t:a}=hn(),o=Rn(),s=mn(),c=q(),l=Y()})),Hn=z(((e,t)=>{let n=Y();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),Un=z(((e,t)=>{let n=Y();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),Wn=z(((e,t)=>{let n=q(),r=Y();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),Gn=z(((e,t)=>{let n=q(),r=Y();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),Kn=z(((e,t)=>{let n=q(),r=Y(),i=Mn();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),qn=z(((e,t)=>{let n=Y();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),Jn=z(((e,t)=>{let n=q(),r=Vn(),{ANY:i}=r,a=Y(),o=Hn(),s=Mn(),c=Nn(),l=Ln(),u=In();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),Yn=z(((e,t)=>{let n=Jn();t.exports=(e,t,r)=>n(e,t,`>`,r)})),Xn=z(((e,t)=>{let n=Jn();t.exports=(e,t,r)=>n(e,t,`<`,r)})),Zn=z(((e,t)=>{let n=Y();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),Qn=z(((e,t)=>{let n=Hn(),r=J();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),$n=z(((e,t)=>{let n=Y(),r=Vn(),{ANY:i}=r,a=Hn(),o=J(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),er=z(((e,t)=>{let n=hn(),r=pn(),i=q(),a=_n();t.exports={parse:vn(),valid:yn(),clean:bn(),inc:xn(),diff:Sn(),major:Cn(),minor:wn(),patch:Tn(),prerelease:En(),compare:J(),rcompare:Dn(),compareLoose:On(),compareBuild:kn(),sort:An(),rsort:jn(),gt:Mn(),lt:Nn(),eq:Pn(),neq:Fn(),gte:In(),lte:Ln(),cmp:Rn(),coerce:zn(),Comparator:Vn(),Range:Y(),satisfies:Hn(),toComparators:Un(),maxSatisfying:Wn(),minSatisfying:Gn(),minVersion:Kn(),validRange:qn(),outside:Jn(),gtr:Yn(),ltr:Xn(),intersects:Zn(),simplifyRange:Qn(),subset:$n(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}})),tr=fn(),nr=er();const rr=K.create(`downloader`);async function ir(e,t,n,r,i){let a=`This may occur when you are behind proxy.`,o={headers:{"User-Agent":`node `+process.version}};rr.debug({name:e,from:t,to:n,size:r,strict:i},`Downloading file`),t.startsWith(`https:`)&&i===!1&&(o.agent=new j({rejectUnauthorized:!1}));let s=await fetch(t,o);if(rr.debug({name:e,from:t,to:n,size:r,strict:i,status:s.status},`Received download response`),!s.ok||s.status!==200)throw rr.debug({from:t,name:e,status:s.status},`Download failed`),Error(`Error while downloading ${e}, status code: ${s.status}. ${a}`);let c=s.headers.get(`content-length`);if(r&&c&&Number.parseInt(c,10)<r)throw rr.debug({name:e,from:t,to:n,size:r,strict:i,length:c},`Download failed size validation`),Error(`Error while downloading ${e}, file is corrupt. ${a}`);let l=await s.arrayBuffer();return await E(n,new Uint8Array(l)),rr.debug({name:e,from:t,to:n,size:r,strict:i,bytes:l.byteLength},`Downloaded file`),n}var ar=z((e=>{e.require=function(){var e=B(`fs`);if(process.versions.electron)try{e=B(`original-fs`)}catch{}return e}})),or=z(((e,t)=>{t.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,FLG_ENC:0,FLG_COMP1:1,FLG_COMP2:2,FLG_DESC:4,FLG_ENH:8,FLG_STR:16,FLG_LNG:1024,FLG_MSK:4096,FILE:0,BUFFER:1,NONE:2,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}})),sr=z(((e,t)=>{t.exports={INVALID_LOC:`Invalid LOC header (bad signature)`,INVALID_CEN:`Invalid CEN header (bad signature)`,INVALID_END:`Invalid END header (bad signature)`,NO_DATA:`Nothing to decompress`,BAD_CRC:`CRC32 checksum failed`,FILE_IN_THE_WAY:`There is a file in the way: %s`,UNKNOWN_METHOD:`Invalid/unsupported compression method`,AVAIL_DATA:`inflate::Available inflate data did not terminate`,INVALID_DISTANCE:`inflate::Invalid literal/length or distance code in fixed or dynamic block`,TO_MANY_CODES:`inflate::Dynamic block code description: too many length or distance codes`,INVALID_REPEAT_LEN:`inflate::Dynamic block code description: repeat more than specified lengths`,INVALID_REPEAT_FIRST:`inflate::Dynamic block code description: repeat lengths with no first length`,INCOMPLETE_CODES:`inflate::Dynamic block code description: code lengths codes incomplete`,INVALID_DYN_DISTANCE:`inflate::Dynamic block code description: invalid distance code lengths`,INVALID_CODES_LEN:`inflate::Dynamic block code description: invalid literal/length code lengths`,INVALID_STORE_BLOCK:`inflate::Stored block length did not match one's complement`,INVALID_BLOCK_TYPE:`inflate::Invalid block type (type == 3)`,CANT_EXTRACT_FILE:`Could not extract the file`,CANT_OVERRIDE:`Target file already exists`,NO_ZIP:`No zip file was loaded`,NO_ENTRY:`Entry doesn't exist`,DIRECTORY_CONTENT_ERROR:`A directory cannot have content`,FILE_NOT_FOUND:`File not found: %s`,NOT_IMPLEMENTED:`Not implemented`,INVALID_FILENAME:`Invalid filename`,INVALID_FORMAT:`Invalid or unsupported zip format. No END header found`}})),cr=z(((e,t)=>{var n=ar().require(),r=B(`path`);n.existsSync=n.existsSync||r.existsSync,t.exports=(function(){var e=[],t=or(),i=sr(),a=r.sep;function o(e){var t=e.split(a)[0];e.split(a).forEach(function(e){if(!(!e||e.substr(-1,1)===`:`)){t+=a+e;var r;try{r=n.statSync(t)}catch{n.mkdirSync(t)}if(r&&r.isFile())throw i.FILE_IN_THE_WAY.replace(`%s`,t)}})}function s(e,t,i){typeof t==`boolean`&&(i=t,t=void 0);var o=[];return n.readdirSync(e).forEach(function(c){var l=r.join(e,c);n.statSync(l).isDirectory()&&i&&(o=o.concat(s(l,t,i))),(!t||t.test(l))&&o.push(r.normalize(l)+(n.statSync(l).isDirectory()?a:``))}),o}return{makeDir:function(e){o(e)},crc32:function(t){typeof t==`string`&&(t=Buffer.alloc(t.length,t));var n=Buffer.alloc(4);if(!e.length)for(var r=0;r<256;r++){for(var i=r,a=8;--a>=0;)i&1?i=3988292384^i>>>1:i>>>=1;i<0&&(n.writeInt32LE(i,0),i=n.readUInt32LE(0)),e[r]=i}for(var o=0,s=0,c=t.length,l=~o;--c>=0;)l=e[(l^t[s++])&255]^l>>>8;return o=~l,n.writeInt32LE(o&4294967295,0),n.readUInt32LE(0)},methodToString:function(e){switch(e){case t.STORED:return`STORED (`+e+`)`;case t.DEFLATED:return`DEFLATED (`+e+`)`;default:return`UNSUPPORTED (`+e+`)`}},writeFileTo:function(e,t,i,a){if(n.existsSync(e)&&(!i||n.statSync(e).isDirectory()))return!1;var s=r.dirname(e);n.existsSync(s)||o(s);var c;try{c=n.openSync(e,`w`,438)}catch{n.chmodSync(e,438),c=n.openSync(e,`w`,438)}if(c)try{n.writeSync(c,t,0,t.length,0)}catch(e){throw e}finally{n.closeSync(c)}return n.chmodSync(e,a||438),!0},writeFileToAsync:function(e,t,i,a,s){typeof a==`function`&&(s=a,a=void 0),n.exists(e,function(c){if(c&&!i)return s(!1);n.stat(e,function(i,l){if(c&&l.isDirectory())return s(!1);var u=r.dirname(e);n.exists(u,function(r){r||o(u),n.open(e,`w`,438,function(r,i){r?n.chmod(e,438,function(){n.open(e,`w`,438,function(r,i){n.write(i,t,0,t.length,0,function(){n.close(i,function(){n.chmod(e,a||438,function(){s(!0)})})})})}):i?n.write(i,t,0,t.length,0,function(){n.close(i,function(){n.chmod(e,a||438,function(){s(!0)})})}):n.chmod(e,a||438,function(){s(!0)})})})})})},findFiles:function(e){return s(e,!0)},getAttributes:function(e){},setAttributes:function(e){},toBuffer:function(e){return Buffer.isBuffer(e)?e:e.length===0?Buffer.alloc(0):Buffer.alloc(e.length,e,`utf8`)},Constants:t,Errors:i}})()})),lr=z(((e,t)=>{var n=ar().require(),r=B(`path`);n.existsSync=n.existsSync||r.existsSync,t.exports=function(e){var t=e||``,i=o(),a=null;function o(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return t&&n.existsSync(t)?(a=n.statSync(t),i.directory=a.isDirectory(),i.mtime=a.mtime,i.atime=a.atime,i.executable=!!(1&parseInt((a.mode&511).toString(8)[0])),i.readonly=!!(2&parseInt((a.mode&511).toString(8)[0])),i.hidden=r.basename(t)[0]===`.`):console.warn(`Invalid path: `+t),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(e){},encodeAttributes:function(e){},toString:function(){return`{
|
|
17
|
+
`),Ee=v.bind(null,{[T]:``,[D]:g,[N]:Ce,[j]:x,[M]:be,[oe]:xe}),De=``;z!==null&&(De=Ee(B===void 0?z:Object.assign({},z,{name:B})));let Oe=_ instanceof Function?_:_?le:ue,ke=Oe().indexOf(`:`)+1;if(me&&!de)throw Error(`customLevels is required if useOnlyCustomLevels is set true`);if(H&&typeof H!=`function`)throw Error(`Unknown mixin type "${typeof H}" - expected "function"`);if(ye&&typeof ye!=`string`)throw Error(`Unknown msgPrefix type "${typeof ye}" - expected "string"`);u(V,de,me);let Ae=d(de,me);typeof r.emit==`function`&&r.emit(`message`,{code:`PINO_CONFIG`,config:{levels:Ae,messageKey:y,errorKey:S}}),m(pe);let je=p(pe);return Object.assign(t,{levels:Ae,[ie]:je,[ae]:me,[A]:r,[O]:Oe,[k]:ke,[j]:x,[M]:be,[N]:Ce,[ee]:Te,[F]:we,[te]:y,[ne]:S,[I]:w,[ce]:w?`,${JSON.stringify(w)}:{`:``,[D]:g,[re]:H,[L]:U,[T]:De,[oe]:xe,[se]:W,silent:C,onChild:ve,[R]:ye}),Object.setPrototypeOf(t,s()),f(t),t[P](V),t}t.exports=H,t.exports.destination=(e=process.stdout.fd)=>typeof e==`object`?(e.dest=S(e.dest||process.stdout.fd),y(e)):y({dest:S(e),minLength:0}),t.exports.transport=Lt(),t.exports.multistream=Wt(),t.exports.levels=d(),t.exports.stdSerializers=pe,t.exports.stdTimeFunctions=Object.assign({},o),t.exports.symbols=c,t.exports.version=w,t.exports.default=H,t.exports.pino=H}))(),1),Kt=class extends D{_filePath;_fileDir;_fileExt;_fileStem;_fileBaseName;_options;_label;_size=0;_stream;_init;constructor(e,t={}){if(super(),!e)throw Error(`A log filename is required`);let r=a(e);this._filePath=e,this._fileDir=r.dir,this._fileExt=r.ext,this._fileStem=r.name,this._fileBaseName=n(e),this._options={size:t.size??0,backups:t.backups??1,flags:t.flags??`a`,mode:t.mode??384,encoding:t.encoding??`utf8`},this._label=this._format(new Date),this._init=this._initialize()}_write(e,t,n){this._writeChunk(e,t).then(()=>n(),n)}_final(e){this._close().then(()=>e(),e)}async _initialize(){await b(this._fileDir,{recursive:!0});let e=await Yt(this._filePath);if(e){let t=this._format(e.mtime),n=t!==this._label,r=this._options.size>0&&e.size>=this._options.size;n||r?await this._rotateHotFile(t):this._size=e.size}this._stream=this._open()}async _writeChunk(e,t){await this._init;let n=Buffer.isBuffer(e)?e.byteLength:Buffer.byteLength(e,t);await this._rotateIfNeeded(),await new Promise((n,r)=>{this._stream.write(e,t,e=>{e?r(e):n()})}),this._size+=n}_open(){let e=f(this._filePath,{flags:this._options.flags,mode:this._options.mode,encoding:this._options.encoding});return e.on(`error`,e=>{this.destroy(e)}),e}async _close(){if(await this._init.catch(()=>void 0),!this._stream)return;let e=this._stream;this._stream=void 0,await new Promise((t,n)=>{let r=()=>{e.off(`error`,i),t()},i=t=>{e.off(`close`,r),n(t)};e.once(`close`,r),e.once(`error`,i),e.end()})}async _rotateIfNeeded(){let e=this._format(new Date),t=e!==this._label,n=this._options.size>0&&this._size>=this._options.size;if(!t&&!n)return;await this._close();let r=await Yt(this._filePath);r&&r.size>0&&await this._rotateHotFile(this._label),this._label=e,this._size=0,this._stream=this._open()}async _rotateHotFile(e){if(!await Yt(this._filePath))return;let t=await this._getNextRotatedPath(e);await S(this._filePath,t),await this._pruneBackups()}async _getNextRotatedPath(e){let t=(await this._listRotatedFiles()).filter(t=>t.label===e).reduce((e,t)=>Math.max(e,t.index),0)+1;return i(this._fileDir,this._buildRotatedFileName(e,t))}_buildRotatedFileName(e,t){return this._fileExt?`${this._fileStem}.${e}.${t}${this._fileExt}`:`${this._fileBaseName}.${e}.${t}`}async _pruneBackups(){let e=(await this._listRotatedFiles()).sort((e,t)=>e.label===t.label?t.index-e.index:t.label.localeCompare(e.label)).slice(this._options.backups);await Promise.all(e.map(e=>C(e.path,{force:!0})))}async _listRotatedFiles(){let e=await x(this._fileDir),t=[],n=this._getRotatedFilePattern();for(let r of e){let e=n.exec(r);e?.groups&&t.push({label:e.groups.label,index:Number.parseInt(e.groups.index,10),path:i(this._fileDir,r)})}return t}_getRotatedFilePattern(){return this._fileExt?RegExp(`^${Jt(this._fileStem)}\\.(?<label>.+)\\.(?<index>\\d+)${Jt(this._fileExt)}$`,`u`):RegExp(`^${Jt(this._fileBaseName)}\\.(?<label>.+)\\.(?<index>\\d+)$`,`u`)}_format(e){return`${qt(e.getFullYear(),4)}-${qt(e.getMonth()+1)}-${qt(e.getDate())}`}};function qt(e,t=2){return e.toString().padStart(t,`0`)}function Jt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}async function Yt(e){try{return await w(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}}let Xt;var Zt=class{_category;_factory;_logger;constructor(e){this._category=e}trace(...e){this._log?.trace(...e)}debug(...e){this._log?.debug(...e)}info(...e){this._log?.info(...e)}warn(...e){this._log?.warn(...e)}error(...e){this._log?.error(...e)}fatal(...e){this._log?.fatal(...e)}get _log(){if(!Xt){this._factory=void 0,this._logger=void 0;return}return(this._factory!==Xt||!this._logger)&&(this._factory=Xt,this._logger=Xt.create(this._category)),this._logger}};function Qt(e){switch(e=e?.toLowerCase(),e){case`trace`:case`debug`:case`info`:case`warn`:case`error`:case`fatal`:case`silent`:return e;default:return`info`}}function $t(e){let t=process.env.WALLABY_CLI_LOG_PATH;function n(){let e=process.env.WALLABY_CLI_LOG_LEVEL;return e?Qt(e):`info`}function r(e,t){let n=Number.parseInt(e??``,10);return Number.isInteger(n)&&n>0?n:t}return{path:e?.path??t??i(u(),`wallaby-cli.log`),level:e?.level??n(),size:e?.size??r(process.env.WALLABY_CLI_LOG_MAX_SIZE,10*1024*1024),backups:e?.backups??r(process.env.WALLABY_CLI_LOG_MAX_BACKUPS,7)}}function en(e){if(Xt)throw Error(`Logger is already initialized`);e=$t(e),G.default.ensureDirSync(r(e.path));let t=new Kt(e.path,{size:e.size,backups:e.backups,flags:`a`,mode:384,encoding:`utf8`});function n(e){process.stderr.write(`[logger] ${e.stack||e.message}\n`)}t.on(`error`,n);function i(e){let t=(t,n)=>{e.fatal({err:t,origin:n},`Uncaught exception`)},n=t=>{e.error({reason:t},`Unhandled promise rejection`)};return process.on(`uncaughtExceptionMonitor`,t),process.on(`unhandledRejection`,n),()=>{process.off(`uncaughtExceptionMonitor`,t),process.off(`unhandledRejection`,n)}}let a=(0,Gt.default)({level:e.level,timestamp:Gt.default.stdTimeFunctions.isoTime,base:{pid:process.pid},errorKey:`error`,formatters:{level(e){return{level:e}}}},t),o=i(a);Xt={create(e){return a.child({category:e})},async close(){o(),t.off(`error`,n),await new Promise((e,n)=>{t.end(t=>{t?n(t):e()})})}},a.debug(`Initialized CLI logger`)}function tn(e){return new Zt(e)}async function nn(){let e=Xt;e&&(Xt=void 0,await e.close())}var J={initialize:en,create:tn,shutdown:nn};const rn=_(import.meta.url),an=process.platform===`win32`,on=un(),sn=an?e=>e.replace(/\\/g,o.sep):e=>e,cn=on?e=>e:e=>e.toLowerCase(),ln=e=>o.normalize(cn(sn(e)));function un(){return an?!1:!p(dn(rn))}function dn(e){return e.replace(/\w/g,e=>{let t=e.toUpperCase();return e===t?e.toLowerCase():t})}const fn=_(new URL(`..`,import.meta.url));var Y={version:JSON.parse(h(i(fn,`package.json`),`utf-8`)).version,paths:{dirs:{package:{bin:i(fn,`bin`)},home:i(l(),`.wallaby`),current:i(l(),`.wallaby`,`cli`)}}},pn=R(((e,t)=>{t.exports=[`|/-\\`,`⠂-–—–-`,`◐◓◑◒`,`◴◷◶◵`,`◰◳◲◱`,`▖▘▝▗`,`■□▪▫`,`▌▀▐▄`,`▉▊▋▌▍▎▏▎▍▌▋▊▉`,`▁▃▄▅▆▇█▇▆▅▄▃`,`←↖↑↗→↘↓↙`,`┤┘┴└├┌┬┐`,`◢◣◤◥`,`.oO°Oo.`,`.oO@*`,[`🌍`,`🌎`,`🌏`],`◡◡ ⊙⊙ ◠◠`,`☱☲☴`,`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,`⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓`,`⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆`,`⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋`,`⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁`,`⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈`,`⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈`,`⢄⢂⢁⡁⡈⡐⡠`,`⢹⢺⢼⣸⣇⡧⡗⡏`,`⣾⣽⣻⢿⡿⣟⣯⣷`,`⠁⠂⠄⡀⢀⠠⠐⠈`,[`🌑`,`🌒`,`🌓`,`🌔`,`🌕`,`🌝`,`🌖`,`🌗`,`🌘`,`🌚`],[`🕛`,`🕐`,`🕑`,`🕒`,`🕓`,`🕔`,`🕕`,`🕖`,`🕗`,`🕘`,`🕙`,`🕚`]]})),mn=R((e=>{var t=B(`readline`),n=0,r=60;function i(e){this.clearLine(this.stream),this.stream.write(e)}var a=function(e){if(!(this instanceof a))return new a(e);typeof e==`string`?e={text:e}:e||={},this.text=e.text||``,this.setSpinnerString(n),this.setSpinnerDelay(r),this.onTick=e.onTick||i,this.stream=e.stream||process.stdout};a.spinners=pn(),a.setDefaultSpinnerString=function(e){return n=e,this},a.setDefaultSpinnerDelay=function(e){return r=e,this},a.prototype.start=function(){if(this.stream===process.stdout&&this.stream.isTTY!==!0)return this;var e=0,t=this,n=function(){var n=t.text.indexOf(`%s`)>-1?t.text.replace(`%s`,t.chars[e]):t.chars[e]+` `+t.text;t.onTick(n),e=++e%t.chars.length};return n(),this.id=setInterval(n,this.delay),this},a.prototype.isSpinning=function(){return this.id!==void 0},a.prototype.setSpinnerDelay=function(e){return this.delay=e,this},a.prototype.setSpinnerString=function(e){let t=s(e,this.spinners);return this.chars=Array.isArray(t)?t:t.split(``),this},a.prototype.setSpinnerTitle=function(e){return this.text=e,this},a.prototype.stop=function(e){return this.isSpinning===!1?this:(clearInterval(this.id),this.id=void 0,e&&this.clearLine(this.stream),this)},a.prototype.clearLine=function(e){return t.clearLine(e,0),t.cursorTo(e,0),this};function o(e){return typeof e==`number`&&e%1==0}function s(e,t){if(!o(e))return e+``;var n=a.spinners.length;return e=e>=n?0:e,e=e<0?n+e:e,a.spinners[e]}e.Spinner=a})),hn=R(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),gn=R(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),_n=R(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=hn(),a=gn();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),vn=R(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),yn=R(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),X=R(((e,t)=>{let n=gn(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=hn(),{safeRe:a,t:o}=_n(),s=vn(),{compareIdentifiers:c}=yn();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),bn=R(((e,t)=>{let n=X();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),xn=R(((e,t)=>{let n=bn();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),Sn=R(((e,t)=>{let n=bn();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),Cn=R(((e,t)=>{let n=X();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),wn=R(((e,t)=>{let n=bn();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),Tn=R(((e,t)=>{let n=X();t.exports=(e,t)=>new n(e,t).major})),En=R(((e,t)=>{let n=X();t.exports=(e,t)=>new n(e,t).minor})),Dn=R(((e,t)=>{let n=X();t.exports=(e,t)=>new n(e,t).patch})),On=R(((e,t)=>{let n=bn();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),Z=R(((e,t)=>{let n=X();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),kn=R(((e,t)=>{let n=Z();t.exports=(e,t,r)=>n(t,e,r)})),An=R(((e,t)=>{let n=Z();t.exports=(e,t)=>n(e,t,!0)})),jn=R(((e,t)=>{let n=X();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),Mn=R(((e,t)=>{let n=jn();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),Nn=R(((e,t)=>{let n=jn();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),Pn=R(((e,t)=>{let n=Z();t.exports=(e,t,r)=>n(e,t,r)>0})),Fn=R(((e,t)=>{let n=Z();t.exports=(e,t,r)=>n(e,t,r)<0})),In=R(((e,t)=>{let n=Z();t.exports=(e,t,r)=>n(e,t,r)===0})),Ln=R(((e,t)=>{let n=Z();t.exports=(e,t,r)=>n(e,t,r)!==0})),Rn=R(((e,t)=>{let n=Z();t.exports=(e,t,r)=>n(e,t,r)>=0})),zn=R(((e,t)=>{let n=Z();t.exports=(e,t,r)=>n(e,t,r)<=0})),Bn=R(((e,t)=>{let n=In(),r=Ln(),i=Pn(),a=Rn(),o=Fn(),s=zn();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),Vn=R(((e,t)=>{let n=X(),r=bn(),{safeRe:i,t:a}=_n();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)}})),Hn=R(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),Un=R(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,O(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>D(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let b=[..._.values()];return r.set(t,b),b}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(k(this.set[t],e,this.options))return!0;return!1}};let r=new(Hn()),i=vn(),a=Wn(),o=gn(),s=X(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=_n(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=hn(),h=e=>e.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=S(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=w(e,t),o(`xrange`,e),e=E(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>x(e,t)).join(` `),x=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},S=(e,t)=>e.trim().split(/\s+/).map(e=>C(e,t)).join(` `),C=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},w=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>T(e,t)).join(` `)),T=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},E=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),D=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),O=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),k=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(o(e[n].semver),e[n].semver!==a.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),Wn=R(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new l(t.value,n).test(this.value):t.operator===``?t.value===``?!0:new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=vn(),{safeRe:i,t:a}=_n(),o=Bn(),s=gn(),c=X(),l=Un()})),Gn=R(((e,t)=>{let n=Un();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),Kn=R(((e,t)=>{let n=Un();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),qn=R(((e,t)=>{let n=X(),r=Un();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),Jn=R(((e,t)=>{let n=X(),r=Un();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),Yn=R(((e,t)=>{let n=X(),r=Un(),i=Pn();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),Xn=R(((e,t)=>{let n=Un();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),Zn=R(((e,t)=>{let n=X(),r=Wn(),{ANY:i}=r,a=Un(),o=Gn(),s=Pn(),c=Fn(),l=zn(),u=Rn();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),Qn=R(((e,t)=>{let n=Zn();t.exports=(e,t,r)=>n(e,t,`>`,r)})),$n=R(((e,t)=>{let n=Zn();t.exports=(e,t,r)=>n(e,t,`<`,r)})),er=R(((e,t)=>{let n=Un();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),tr=R(((e,t)=>{let n=Gn(),r=Z();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),nr=R(((e,t)=>{let n=Un(),r=Wn(),{ANY:i}=r,a=Gn(),o=Z(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),rr=R(((e,t)=>{let n=_n(),r=hn(),i=X(),a=yn();t.exports={parse:bn(),valid:xn(),clean:Sn(),inc:Cn(),diff:wn(),major:Tn(),minor:En(),patch:Dn(),prerelease:On(),compare:Z(),rcompare:kn(),compareLoose:An(),compareBuild:jn(),sort:Mn(),rsort:Nn(),gt:Pn(),lt:Fn(),eq:In(),neq:Ln(),gte:Rn(),lte:zn(),cmp:Bn(),coerce:Vn(),Comparator:Wn(),Range:Un(),satisfies:Gn(),toComparators:Kn(),maxSatisfying:qn(),minSatisfying:Jn(),minVersion:Yn(),validRange:Xn(),outside:Zn(),gtr:Qn(),ltr:$n(),intersects:er(),simplifyRange:tr(),subset:nr(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}})),ir=mn(),ar=rr();const or=J.create(`downloader`);async function sr(e,t,n,r,i){let a=`This may occur when you are behind proxy.`,o={headers:{"User-Agent":`node `+process.version}};or.debug({name:e,from:t,to:n,size:r,strict:i},`Downloading file`),t.startsWith(`https:`)&&i===!1&&(o.agent=new M({rejectUnauthorized:!1}));let s=await fetch(t,o);if(or.debug({name:e,from:t,to:n,size:r,strict:i,status:s.status},`Received download response`),!s.ok||s.status!==200)throw or.debug({from:t,name:e,status:s.status},`Download failed`),Error(`Error while downloading ${e}, status code: ${s.status}. ${a}`);let c=s.headers.get(`content-length`);if(r&&c&&Number.parseInt(c,10)<r)throw or.debug({name:e,from:t,to:n,size:r,strict:i,length:c},`Download failed size validation`),Error(`Error while downloading ${e}, file is corrupt. ${a}`);let l=await s.arrayBuffer();return await E(n,new Uint8Array(l)),or.debug({name:e,from:t,to:n,size:r,strict:i,bytes:l.byteLength},`Downloaded file`),n}var cr=R((e=>{e.require=function(){var e=B(`fs`);if(process.versions.electron)try{e=B(`original-fs`)}catch{}return e}})),lr=R(((e,t)=>{t.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,FLG_ENC:0,FLG_COMP1:1,FLG_COMP2:2,FLG_DESC:4,FLG_ENH:8,FLG_STR:16,FLG_LNG:1024,FLG_MSK:4096,FILE:0,BUFFER:1,NONE:2,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}})),ur=R(((e,t)=>{t.exports={INVALID_LOC:`Invalid LOC header (bad signature)`,INVALID_CEN:`Invalid CEN header (bad signature)`,INVALID_END:`Invalid END header (bad signature)`,NO_DATA:`Nothing to decompress`,BAD_CRC:`CRC32 checksum failed`,FILE_IN_THE_WAY:`There is a file in the way: %s`,UNKNOWN_METHOD:`Invalid/unsupported compression method`,AVAIL_DATA:`inflate::Available inflate data did not terminate`,INVALID_DISTANCE:`inflate::Invalid literal/length or distance code in fixed or dynamic block`,TO_MANY_CODES:`inflate::Dynamic block code description: too many length or distance codes`,INVALID_REPEAT_LEN:`inflate::Dynamic block code description: repeat more than specified lengths`,INVALID_REPEAT_FIRST:`inflate::Dynamic block code description: repeat lengths with no first length`,INCOMPLETE_CODES:`inflate::Dynamic block code description: code lengths codes incomplete`,INVALID_DYN_DISTANCE:`inflate::Dynamic block code description: invalid distance code lengths`,INVALID_CODES_LEN:`inflate::Dynamic block code description: invalid literal/length code lengths`,INVALID_STORE_BLOCK:`inflate::Stored block length did not match one's complement`,INVALID_BLOCK_TYPE:`inflate::Invalid block type (type == 3)`,CANT_EXTRACT_FILE:`Could not extract the file`,CANT_OVERRIDE:`Target file already exists`,NO_ZIP:`No zip file was loaded`,NO_ENTRY:`Entry doesn't exist`,DIRECTORY_CONTENT_ERROR:`A directory cannot have content`,FILE_NOT_FOUND:`File not found: %s`,NOT_IMPLEMENTED:`Not implemented`,INVALID_FILENAME:`Invalid filename`,INVALID_FORMAT:`Invalid or unsupported zip format. No END header found`}})),dr=R(((e,t)=>{var n=cr().require(),r=B(`path`);n.existsSync=n.existsSync||r.existsSync,t.exports=(function(){var e=[],t=lr(),i=ur(),a=r.sep;function o(e){var t=e.split(a)[0];e.split(a).forEach(function(e){if(!(!e||e.substr(-1,1)===`:`)){t+=a+e;var r;try{r=n.statSync(t)}catch{n.mkdirSync(t)}if(r&&r.isFile())throw i.FILE_IN_THE_WAY.replace(`%s`,t)}})}function s(e,t,i){typeof t==`boolean`&&(i=t,t=void 0);var o=[];return n.readdirSync(e).forEach(function(c){var l=r.join(e,c);n.statSync(l).isDirectory()&&i&&(o=o.concat(s(l,t,i))),(!t||t.test(l))&&o.push(r.normalize(l)+(n.statSync(l).isDirectory()?a:``))}),o}return{makeDir:function(e){o(e)},crc32:function(t){typeof t==`string`&&(t=Buffer.alloc(t.length,t));var n=Buffer.alloc(4);if(!e.length)for(var r=0;r<256;r++){for(var i=r,a=8;--a>=0;)i&1?i=3988292384^i>>>1:i>>>=1;i<0&&(n.writeInt32LE(i,0),i=n.readUInt32LE(0)),e[r]=i}for(var o=0,s=0,c=t.length,l=~o;--c>=0;)l=e[(l^t[s++])&255]^l>>>8;return o=~l,n.writeInt32LE(o&4294967295,0),n.readUInt32LE(0)},methodToString:function(e){switch(e){case t.STORED:return`STORED (`+e+`)`;case t.DEFLATED:return`DEFLATED (`+e+`)`;default:return`UNSUPPORTED (`+e+`)`}},writeFileTo:function(e,t,i,a){if(n.existsSync(e)&&(!i||n.statSync(e).isDirectory()))return!1;var s=r.dirname(e);n.existsSync(s)||o(s);var c;try{c=n.openSync(e,`w`,438)}catch{n.chmodSync(e,438),c=n.openSync(e,`w`,438)}if(c)try{n.writeSync(c,t,0,t.length,0)}catch(e){throw e}finally{n.closeSync(c)}return n.chmodSync(e,a||438),!0},writeFileToAsync:function(e,t,i,a,s){typeof a==`function`&&(s=a,a=void 0),n.exists(e,function(c){if(c&&!i)return s(!1);n.stat(e,function(i,l){if(c&&l.isDirectory())return s(!1);var u=r.dirname(e);n.exists(u,function(r){r||o(u),n.open(e,`w`,438,function(r,i){r?n.chmod(e,438,function(){n.open(e,`w`,438,function(r,i){n.write(i,t,0,t.length,0,function(){n.close(i,function(){n.chmod(e,a||438,function(){s(!0)})})})})}):i?n.write(i,t,0,t.length,0,function(){n.close(i,function(){n.chmod(e,a||438,function(){s(!0)})})}):n.chmod(e,a||438,function(){s(!0)})})})})})},findFiles:function(e){return s(e,!0)},getAttributes:function(e){},setAttributes:function(e){},toBuffer:function(e){return Buffer.isBuffer(e)?e:e.length===0?Buffer.alloc(0):Buffer.alloc(e.length,e,`utf8`)},Constants:t,Errors:i}})()})),fr=R(((e,t)=>{var n=cr().require(),r=B(`path`);n.existsSync=n.existsSync||r.existsSync,t.exports=function(e){var t=e||``,i=o(),a=null;function o(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return t&&n.existsSync(t)?(a=n.statSync(t),i.directory=a.isDirectory(),i.mtime=a.mtime,i.atime=a.atime,i.executable=!!(1&parseInt((a.mode&511).toString(8)[0])),i.readonly=!!(2&parseInt((a.mode&511).toString(8)[0])),i.hidden=r.basename(t)[0]===`.`):console.warn(`Invalid path: `+t),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(e){},encodeAttributes:function(e){},toString:function(){return`{
|
|
18
18
|
"path" : "`+t+`,
|
|
19
19
|
"isDirectory" : `+i.directory+`,
|
|
20
20
|
"isReadOnly" : `+i.readonly+`,
|
|
@@ -22,7 +22,7 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
|
|
|
22
22
|
"isExecutable" : `+i.executable+`,
|
|
23
23
|
"mTime" : `+i.mtime+`
|
|
24
24
|
"aTime" : `+i.atime+`
|
|
25
|
-
}`}}}})),
|
|
25
|
+
}`}}}})),pr=R(((e,t)=>{t.exports=dr(),t.exports.FileSystem=cr(),t.exports.Constants=lr(),t.exports.Errors=ur(),t.exports.FileAttr=fr()})),mr=R(((e,t)=>{var n=pr(),r=n.Constants;t.exports=function(){var e=10,t=10,i=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_={};function v(e){e=new Date(e),o=(e.getFullYear()-1980&127)<<25|e.getMonth()+1<<21|e.getDate()<<16|e.getHours()<<11|e.getMinutes()<<5|e.getSeconds()>>1}return v(+new Date),{get made(){return e},set made(t){e=t},get version(){return t},set version(e){t=e},get flags(){return i},set flags(e){i=e},get method(){return a},set method(e){a=e},get time(){return new Date((o>>25&127)+1980,(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(o&31)<<1)},set time(e){v(e)},get crc(){return s},set crc(e){s=e},get compressedSize(){return c},set compressedSize(e){c=e},get size(){return l},set size(e){l=e},get fileNameLength(){return u},set fileNameLength(e){u=e},get extraLength(){return d},set extraLength(e){d=e},get commentLength(){return f},set commentLength(e){f=e},get diskNumStart(){return p},set diskNumStart(e){p=e},get inAttr(){return m},set inAttr(e){m=e},get attr(){return h},set attr(e){h=e},get offset(){return g},set offset(e){g=e},get encripted(){return(i&1)==1},get entryHeaderSize(){return r.CENHDR+u+d+f},get realDataOffset(){return g+r.LOCHDR+_.fnameLen+_.extraLen},get dataHeader(){return _},loadDataHeaderFromBinary:function(e){var t=e.slice(g,g+r.LOCHDR);if(t.readUInt32LE(0)!==r.LOCSIG)throw n.Errors.INVALID_LOC;_={version:t.readUInt16LE(r.LOCVER),flags:t.readUInt16LE(r.LOCFLG),method:t.readUInt16LE(r.LOCHOW),time:t.readUInt32LE(r.LOCTIM),crc:t.readUInt32LE(r.LOCCRC),compressedSize:t.readUInt32LE(r.LOCSIZ),size:t.readUInt32LE(r.LOCLEN),fnameLen:t.readUInt16LE(r.LOCNAM),extraLen:t.readUInt16LE(r.LOCEXT)}},loadFromBinary:function(_){if(_.length!==r.CENHDR||_.readUInt32LE(0)!==r.CENSIG)throw n.Errors.INVALID_CEN;e=_.readUInt16LE(r.CENVEM),t=_.readUInt16LE(r.CENVER),i=_.readUInt16LE(r.CENFLG),a=_.readUInt16LE(r.CENHOW),o=_.readUInt32LE(r.CENTIM),s=_.readUInt32LE(r.CENCRC),c=_.readUInt32LE(r.CENSIZ),l=_.readUInt32LE(r.CENLEN),u=_.readUInt16LE(r.CENNAM),d=_.readUInt16LE(r.CENEXT),f=_.readUInt16LE(r.CENCOM),p=_.readUInt16LE(r.CENDSK),m=_.readUInt16LE(r.CENATT),h=_.readUInt32LE(r.CENATX),g=_.readUInt32LE(r.CENOFF)},dataHeaderToBinary:function(){var e=Buffer.alloc(r.LOCHDR);return e.writeUInt32LE(r.LOCSIG,0),e.writeUInt16LE(t,r.LOCVER),e.writeUInt16LE(i,r.LOCFLG),e.writeUInt16LE(a,r.LOCHOW),e.writeUInt32LE(o,r.LOCTIM),e.writeUInt32LE(s,r.LOCCRC),e.writeUInt32LE(c,r.LOCSIZ),e.writeUInt32LE(l,r.LOCLEN),e.writeUInt16LE(u,r.LOCNAM),e.writeUInt16LE(d,r.LOCEXT),e},entryHeaderToBinary:function(){var n=Buffer.alloc(r.CENHDR+u+d+f);return n.writeUInt32LE(r.CENSIG,0),n.writeUInt16LE(e,r.CENVEM),n.writeUInt16LE(t,r.CENVER),n.writeUInt16LE(i,r.CENFLG),n.writeUInt16LE(a,r.CENHOW),n.writeUInt32LE(o,r.CENTIM),n.writeUInt32LE(s,r.CENCRC),n.writeUInt32LE(c,r.CENSIZ),n.writeUInt32LE(l,r.CENLEN),n.writeUInt16LE(u,r.CENNAM),n.writeUInt16LE(d,r.CENEXT),n.writeUInt16LE(f,r.CENCOM),n.writeUInt16LE(p,r.CENDSK),n.writeUInt16LE(m,r.CENATT),n.writeUInt32LE(h,r.CENATX),n.writeUInt32LE(g,r.CENOFF),n.fill(0,r.CENHDR),n},toString:function(){return`{
|
|
26
26
|
"made" : `+e+`,
|
|
27
27
|
"version" : `+t+`,
|
|
28
28
|
"flags" : `+i+`,
|
|
@@ -39,13 +39,13 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
|
|
|
39
39
|
"attr" : `+h+`,
|
|
40
40
|
"offset" : `+g+`,
|
|
41
41
|
"entryHeaderSize" : `+(r.CENHDR+u+d+f)+` bytes
|
|
42
|
-
}`}}}})),
|
|
42
|
+
}`}}}})),hr=R(((e,t)=>{var n=pr(),r=n.Constants;t.exports=function(){var e=0,t=0,i=0,a=0,o=0;return{get diskEntries(){return e},set diskEntries(n){e=t=n},get totalEntries(){return t},set totalEntries(n){t=e=n},get size(){return i},set size(e){i=e},get offset(){return a},set offset(e){a=e},get commentLength(){return o},set commentLength(e){o=e},get mainHeaderSize(){return r.ENDHDR+o},loadFromBinary:function(s){if(s.length!==r.ENDHDR||s.readUInt32LE(0)!==r.ENDSIG)throw n.Errors.INVALID_END;e=s.readUInt16LE(r.ENDSUB),t=s.readUInt16LE(r.ENDTOT),i=s.readUInt32LE(r.ENDSIZ),a=s.readUInt32LE(r.ENDOFF),o=s.readUInt16LE(r.ENDCOM)},toBinary:function(){var n=Buffer.alloc(r.ENDHDR+o);return n.writeUInt32LE(r.ENDSIG,0),n.writeUInt32LE(0,4),n.writeUInt16LE(e,r.ENDSUB),n.writeUInt16LE(t,r.ENDTOT),n.writeUInt32LE(i,r.ENDSIZ),n.writeUInt32LE(a,r.ENDOFF),n.writeUInt16LE(o,r.ENDCOM),n.fill(` `,r.ENDHDR),n},toString:function(){return`{
|
|
43
43
|
"diskEntries" : `+e+`,
|
|
44
44
|
"totalEntries" : `+t+`,
|
|
45
45
|
"size" : `+i+` bytes,
|
|
46
46
|
"offset" : 0x`+a.toString(16).toUpperCase()+`,
|
|
47
47
|
"commentLength" : 0x`+o+`
|
|
48
|
-
}`}}}})),
|
|
48
|
+
}`}}}})),gr=R((e=>{e.EntryHeader=mr(),e.MainHeader=hr()})),_r=R((()=>{})),vr=R(((e,t)=>{var n=B(`buffer`).Buffer;function r(e){var t=32768,r=n.alloc(65536),i=0,a=null,o,s,c=0,l=0,u=-1,d=!1,f=0,p=0,m,h,g,_,v=0,y=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],b=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],x=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],S=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],C=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function T(e,t,n,r,i,a){this.status=0,this.r=null,this.maxbit=0;var o,s,c,l=[],u=[],d=[],f=[],p={extra:0,bitcnt:0,lbase:0,next:null};c=this.r=null;for(var m=0;m<17;m++)u[m]=0,d[m]=0,l[m]=0;for(m=0;m<288;m++)f[m]=0;o=t>256?e[256]:16;for(var h=-1;++h<t;)u[e[h]]++;if(u[0]!==t){for(var g=1;g<=16&&u[g]===0;g++);var _=g;for(m=16;m!==0&&u[m]===0;m--);var v=m;a<g&&(a=g);for(var y=1<<g;g<m;g++,y<<=1)if((y-=u[g])<0){this.status=2,this.maxbit=a;return}if((y-=u[m])<0){this.status=2,this.maxbit=a;return}u[m]+=y,l[1]=g=0,h=1;for(var b=2;--m>0;)l[b++]=g+=u[h++];h=0,m=0;do(g=e[h++])&&(f[l[g]++]=m);while(++m<t);t=l[v],l[0]=m=0,h=0;for(var x=-1,S=d[0]=0,C=null,w=0,T=[];_<=v;_++)for(var E=u[_];E-- >0;){for(;_>S+d[1+x];){if(S+=d[1+x],x++,w=(w=v-S)>a?a:w,(s=1<<(g=_-S))>E+1)for(s-=E+1,b=_;++g<w&&!((s<<=1)<=u[++b]);)s-=u[b];for(S+g>o&&S<o&&(g=o-S),w=1<<g,d[1+x]=g,C=[];C.length<w;)C.push({extra:0,bitcnt:0,lbase:0,next:null});c=c==null?this.r={next:null,list:null}:c.next={next:null,list:null},c.next=null,c.list=C,T[x]=C,x>0&&(l[x]=m,p.bitcnt=d[x],p.extra=16+g,p.next=C,g=(m&(1<<S)-1)>>S-d[x],T[x-1][g].extra=p.extra,T[x-1][g].bitcnt=p.bitcnt,T[x-1][g].lbase=p.lbase,T[x-1][g].next=p.next)}for(p.bitcnt=_-S,h>=t?p.extra=99:f[h]<n?(p.extra=f[h]<256?16:15,p.lbase=f[h++]):(p.extra=i[f[h]-n],p.lbase=r[f[h++]-n]),s=1<<_-S,g=m>>S;g<w;g+=s)C[g].extra=p.extra,C[g].bitcnt=p.bitcnt,C[g].lbase=p.lbase,C[g].next=p.next;for(g=1<<_-1;(m&g)!==0;g>>=1)m^=g;for(m^=g;(m&(1<<S)-1)!==l[x];)S-=d[x],x--}this.maxbit=d[1],this.status=+(y!==0&&v!==1)}}function E(t){for(;l<t;)c|=e[v++]<<l,l+=8;return c}function D(e){return l-=e,c>>=e}function O(t){for(;l<t;)c|=e[v++]<<l,l+=8;var n=c&y[t];return c>>=t,l-=t,n}function k(e,n,a){var o,s;if(a===0)return 0;for(var c=0;;){for(s=m.list[E(g)&y[g]],o=s.extra;o>16;){if(o===99)return-1;D(s.bitcnt),o-=16,s=s.next[E(o)&y[o]],o=s.extra}if(D(s.bitcnt),o===16){if(i&=t-1,e[n+ c++]=r[i++]=s.lbase,c===a)return a;continue}if(o===15)break;for(f=s.lbase+O(o),s=h.list[E(_)&y[_]],o=s.extra;o>16;){if(o===99)return-1;D(s.bitcnt),o-=16,s=s.next[E(o)&y[o]],o=s.extra}for(D(s.bitcnt),p=i-s.lbase-O(o);f>0&&c<a;)f--,p&=t-1,i&=t-1,e[n+ c++]=r[i++]=r[p++];if(c===a)return a}return u=-1,c}function A(e,n,a){D(l&7);var o=O(16);if(o!==(~O(16)&65535))return-1;for(f=o,o=0;f>0&&o<a;)f--,i&=t-1,e[n+ o++]=r[i++]=O(8);return f===0&&(u=-1),o}function j(e,t,n){var r=0;if(a==null){for(var i=[],c=0;c<144;c++)i[c]=8;for(;c<256;c++)i[c]=9;for(;c<280;c++)i[c]=7;for(;c<288;c++)i[c]=8;s=7;var l=new T(i,288,257,b,x,s);if(l.status!==0)return-1;for(a=l.r,s=l.maxbit,c=0;c<30;c++)i[c]=5;if(r=5,l=new T(i,30,0,S,C,r),l.status>1)return a=null,-1;o=l.r,r=l.maxbit}return m=a,h=o,g=s,_=r,k(e,t,n)}function M(e,t,n){for(var r=Array(572),i=0;i<572;i++)r[i]=0;var a=257+O(5),o=1+O(5),s=4+O(4);if(a>286||o>30)return-1;for(var c=0;c<s;c++)r[w[c]]=O(3);for(;c<19;c++)r[w[c]]=0;g=7;var l=new T(r,19,19,null,null,g);if(l.status!==0)return-1;m=l.r,g=l.maxbit;for(var u=a+o,d=0,f=0;d<u;){var p=m.list[E(g)&y[g]];if(c=p.bitcnt,D(c),c=p.lbase,c<16)r[d++]=f=c;else if(c===16){if(c=3+O(2),d+c>u)return-1;for(;c-- >0;)r[d++]=f}else if(c===17){if(c=3+O(3),d+c>u)return-1;for(;c-- >0;)r[d++]=0;f=0}else{if(c=11+O(7),d+c>u)return-1;for(;c-- >0;)r[d++]=0;f=0}}if(g=9,l=new T(r,a,257,b,x,g),g===0&&(l.status=1),l.status!==0)return-1;for(m=l.r,g=l.maxbit,d=0;d<o;d++)r[d]=r[d+a];return _=6,l=new T(r,o,0,S,C,_),h=l.r,_=l.maxbit,_===0&&a>257||l.status!==0?-1:k(e,t,n)}return{inflate:function(e){m=null;for(var n=e.length,a=0,o;a<n;){if(d&&u===-1)return;if(f>0){if(u!==0)for(;f>0&&a<n;)f--,p&=t-1,i&=t-1,e[a++]=r[i++]=r[p++];else{for(;f>0&&a<n;)f--,i&=t-1,e[a++]=r[i++]=O(8);f===0&&(u=-1)}if(a===n)return}if(u===-1){if(d)break;d=O(1)!==0,u=O(2),m=null,f=0}switch(u){case 0:o=A(e,a,n-a);break;case 1:o=m==null?j(e,a,n-a):k(e,a,n-a);break;case 2:o=m==null?M(e,a,n-a):k(e,a,n-a);break;default:o=-1;break}if(o===-1)return;a+=o}}}}t.exports=function(e){var t=B(`zlib`);return{inflateAsync:function(r){var i=t.createInflateRaw(),a=[],o=0;i.on(`data`,function(e){a.push(e),o+=e.length}),i.on(`end`,function(){var e=n.alloc(o),t=0;e.fill(0);for(var i=0;i<a.length;i++){var s=a[i];s.copy(e,t),t+=s.length}r&&r(e)}),i.end(e)},inflate:function(t){var n={x:new r(e)};n.x.inflate(t),delete n.x}}}})),yr=R((e=>{e.Deflater=_r(),e.Inflater=vr()})),br=R(((e,t)=>{var n=pr(),r=gr(),i=n.Constants,a=yr();t.exports=function(e){var t=new r.EntryHeader,o=Buffer.alloc(0),s=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0);function d(){return!e||!Buffer.isBuffer(e)?Buffer.alloc(0):(t.loadDataHeaderFromBinary(e),e.slice(t.realDataOffset,t.realDataOffset+t.compressedSize))}function f(e){return!((t.flags&8)!=8&&n.crc32(e)!==t.crc)}function p(e,r,i){if(r===void 0&&typeof e==`string`&&(i=e,e=void 0),c)return e&&r&&r(Buffer.alloc(0),n.Errors.DIRECTORY_CONTENT_ERROR),Buffer.alloc(0);var s=d();if(s.length===0)return e&&r&&r(s,n.Errors.NO_DATA),s;var l=Buffer.alloc(t.size);switch(t.method){case n.Constants.STORED:return s.copy(l),f(l)?(e&&r&&r(l),l):(e&&r&&r(l,n.Errors.BAD_CRC),n.Errors.BAD_CRC);case n.Constants.DEFLATED:var u=new a.Inflater(s);if(e)u.inflateAsync(function(e){e.copy(l,0),f(l)?r&&r(l):r&&r(l,n.Errors.BAD_CRC)});else return u.inflate(l),f(l)||console.warn(n.Errors.BAD_CRC+` `+o.toString()),l;break;default:return e&&r&&r(Buffer.alloc(0),n.Errors.UNKNOWN_METHOD),n.Errors.UNKNOWN_METHOD}}function m(r,i){if((!l||!l.length)&&Buffer.isBuffer(e))return r&&i&&i(d()),d();if(l.length&&!c){var o;switch(t.method){case n.Constants.STORED:return t.compressedSize=t.size,o=Buffer.alloc(l.length),l.copy(o),r&&i&&i(o),o;default:case n.Constants.DEFLATED:var s=new a.Deflater(l);if(r)s.deflateAsync(function(e){o=Buffer.alloc(e.length),t.compressedSize=e.length,e.copy(o),i&&i(o)});else{var u=s.deflate();return t.compressedSize=u.length,u}s=null;break}}else if(r&&i)i(Buffer.alloc(0));else return Buffer.alloc(0)}function h(e,t){return(e.readUInt32LE(t+4)<<4)+e.readUInt32LE(t)}function g(e){for(var t=0,n,r,a;t<e.length;)n=e.readUInt16LE(t),t+=2,r=e.readUInt16LE(t),t+=2,a=e.slice(t,t+r),t+=r,i.ID_ZIP64===n&&_(a)}function _(e){var n,r,a,o;e.length>=i.EF_ZIP64_SCOMP&&(n=h(e,i.EF_ZIP64_SUNCOMP),t.size===i.EF_ZIP64_OR_32&&(t.size=n)),e.length>=i.EF_ZIP64_RHO&&(r=h(e,i.EF_ZIP64_SCOMP),t.compressedSize===i.EF_ZIP64_OR_32&&(t.compressedSize=r)),e.length>=i.EF_ZIP64_DSN&&(a=h(e,i.EF_ZIP64_RHO),t.offset===i.EF_ZIP64_OR_32&&(t.offset=a)),e.length>=i.EF_ZIP64_DSN+4&&(o=e.readUInt32LE(i.EF_ZIP64_DSN),t.diskNumStart===i.EF_ZIP64_OR_16&&(t.diskNumStart=o))}return{get entryName(){return o.toString()},get rawEntryName(){return o},set entryName(e){o=n.toBuffer(e);var r=o[o.length-1];c=r===47||r===92,t.fileNameLength=o.length},get extra(){return u},set extra(e){u=e,t.extraLength=e.length,g(e)},get comment(){return s.toString()},set comment(e){s=n.toBuffer(e),t.commentLength=s.length},get name(){var e=o.toString();return c?e.substr(e.length-1).split(`/`).pop():e.split(`/`).pop()},get isDirectory(){return c},getCompressedData:function(){return m(!1,null)},getCompressedDataAsync:function(e){m(!0,e)},setData:function(e){l=n.toBuffer(e),!c&&l.length?(t.size=l.length,t.method=n.Constants.STORED,t.crc=n.crc32(e),t.changed=!0):t.method=n.Constants.STORED},getData:function(e){return t.changed?l:p(!1,null,e)},getDataAsync:function(e,n){t.changed?e(l):p(!0,e,n)},set attr(e){t.attr=e},get attr(){return t.attr},set header(e){t.loadFromBinary(e)},get header(){return t},packHeader:function(){var e=t.entryHeaderToBinary();return o.copy(e,n.Constants.CENHDR),t.extraLength&&u.copy(e,n.Constants.CENHDR+o.length),t.commentLength&&s.copy(e,n.Constants.CENHDR+o.length+t.extraLength,s.length),e},toString:function(){return`{
|
|
49
49
|
"entryName" : "`+o.toString()+`",
|
|
50
50
|
"name" : "`+(c?o.toString().replace(/\/$/,``).split(`/`).pop():o.toString().split(`/`).pop())+`",
|
|
51
51
|
"comment" : "`+s.toString()+`",
|
|
@@ -53,17 +53,17 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
|
|
|
53
53
|
"header" : `+t.toString().replace(/\t/gm,` `).replace(/}/gm,` }`)+`,
|
|
54
54
|
"compressedData" : <`+(e&&e.length+` bytes buffer`||`null`)+`>
|
|
55
55
|
"data" : <`+(l&&l.length+` bytes buffer`||`null`)+`>
|
|
56
|
-
}`}}}})),
|
|
57
|
-
`)[2]}catch{}}var
|
|
56
|
+
}`}}}})),xr=R(((e,t)=>{var n=br(),r=gr(),i=pr();t.exports=function(e,t){var a=[],o={},s=Buffer.alloc(0),c=``,l=i.FileSystem.require(),u=null,d=new r.MainHeader;t===i.Constants.FILE?(c=e,u=l.readFileSync(c),p()):t===i.Constants.BUFFER&&(u=e,p());function f(){o={},a=Array(d.diskEntries);for(var e=d.offset,t=0;t<a.length;t++){var r=e,s=new n(u);s.header=u.slice(r,r+=i.Constants.CENHDR),s.entryName=u.slice(r,r+=s.header.fileNameLength),s.header.extraLength&&(s.extra=u.slice(r,r+=s.header.extraLength)),s.header.commentLength&&(s.comment=u.slice(r,r+s.header.commentLength)),e+=s.header.entryHeaderSize,a[t]=s,o[s.entryName]=s}}function p(){for(var e=u.length-i.Constants.ENDHDR,t=Math.max(0,e-65535),n=-1;e>=t;e--)if(u[e]===80&&u.readUInt32LE(e)===i.Constants.ENDSIG){n=e;break}if(!~n)throw i.Errors.INVALID_FORMAT;d.loadFromBinary(u.slice(n,n+i.Constants.ENDHDR)),d.commentLength&&(s=u.slice(n+i.Constants.ENDHDR)),f()}return{get entries(){return a},get comment(){return s.toString()},set comment(e){d.commentLength=e.length,s=e},getEntry:function(e){return o[e]||null},setEntry:function(e){a.push(e),o[e.entryName]=e,d.totalEntries=a.length},deleteEntry:function(e){var t=o[e];if(t&&t.isDirectory){var n=this;this.getEntryChildren(t).forEach(function(t){t.entryName!==e&&n.deleteEntry(t.entryName)})}a.splice(a.indexOf(t),1),delete o[e],d.totalEntries=a.length},getEntryChildren:function(e){if(e.isDirectory){var t=[],n=e.entryName,r=n.length;return a.forEach(function(e){e.entryName.substr(0,r)===n&&t.push(e)}),t}return[]},compressToBuffer:function(){a.length>1&&a.sort(function(e,t){var n=e.entryName.toLowerCase(),r=t.entryName.toLowerCase();return n<r?-1:+(n>r)});var e=0,t=[],n=[],r=0;d.size=0,d.offset=0,a.forEach(function(i){var a=i.getCompressedData();i.header.offset=r;var o=i.header.dataHeaderToBinary(),s=i.entryName+i.extra.toString(),c=Buffer.alloc(s.length,s),l=o.length+c.length+a.length;r+=l,t.push(o),t.push(c),t.push(a);var u=i.packHeader();n.push(u),d.size+=u.length,e+=l+u.length}),e+=d.mainHeaderSize,d.offset=r,r=0;var o=Buffer.alloc(e);t.forEach(function(e){e.copy(o,r),r+=e.length}),n.forEach(function(e){e.copy(o,r),r+=e.length});var c=d.toBinary();return s&&s.copy(c,i.Constants.ENDHDR),c.copy(o,r),o},toAsyncBuffer:function(e,t,n,r){a.length>1&&a.sort(function(e,t){var n=e.entryName.toLowerCase(),r=t.entryName.toLowerCase();return n>r?-1:+(n<r)});var o=0,c=[],l=[],u=0;d.size=0,d.offset=0,function(t){var a=arguments.callee;if(t.length){var f=t.pop(),p=f.entryName+f.extra.toString();n&&n(p),f.getCompressedDataAsync(function(n){r&&r(p),f.header.offset=u;var m=f.header.dataHeaderToBinary(),h=Buffer.alloc(p),g=m.length+h.length+n.length;u+=g,c.push(m),c.push(h),c.push(n);var _=f.packHeader();if(l.push(_),d.size+=_.length,o+=g+_.length,t.length)a(t);else{o+=d.mainHeaderSize,d.offset=u,u=0;var v=Buffer.alloc(o);c.forEach(function(e){e.copy(v,u),u+=e.length}),l.forEach(function(e){e.copy(v,u),u+=e.length});var y=d.toBinary();s&&s.copy(y,i.Constants.ENDHDR),y.copy(v,u),e(v)}})}}(a)}}}})),Sr=z(R(((e,t)=>{var n=pr(),r=n.FileSystem.require(),i=B(`path`);r.existsSync=r.existsSync||i.existsSync;var a=br(),o=xr();/^win/.test(process.platform),t.exports=function(e){var t=void 0,s=``;if(e&&typeof e==`string`)if(r.existsSync(e))s=e,t=new o(e,n.Constants.FILE);else throw n.Errors.INVALID_FILENAME;else t=e&&Buffer.isBuffer(e)?new o(e,n.Constants.BUFFER):new o(null,n.Constants.NONE);function c(e,t){e=i.resolve(i.normalize(e));for(var n=t.split(`/`),r=0,a=n.length;r<a;r++){var o=i.normalize(i.join(e,n.slice(r,a).join(i.sep)));if(o.indexOf(e)===0)return o}return i.normalize(i.join(e,i.basename(t)))}function l(e){if(e&&t){var n;if(typeof e==`string`&&(n=t.getEntry(e)),typeof e==`object`&&e.entryName!==void 0&&e.header!==void 0&&(n=t.getEntry(e.entryName)),n)return n}return null}return{readFile:function(e){var t=l(e);return t&&t.getData()||null},readFileAsync:function(e,t){var n=l(e);n?n.getDataAsync(t):t(null,`getEntry failed for:`+e)},readAsText:function(e,t){var n=l(e);if(n){var r=n.getData();if(r&&r.length)return r.toString(t||`utf8`)}return``},readAsTextAsync:function(e,t,n){var r=l(e);r?r.getDataAsync(function(e){e&&e.length?t(e.toString(n||`utf8`)):t(``)}):t(``)},deleteFile:function(e){var n=l(e);n&&t.deleteEntry(n.entryName)},addZipComment:function(e){t.comment=e},getZipComment:function(){return t.comment||``},addZipEntryComment:function(e,t){var n=l(e);n&&(n.comment=t)},getZipEntryComment:function(e){var t=l(e);return t&&t.comment||``},updateFile:function(e,t){var n=l(e);n&&n.setData(t)},addLocalFile:function(e,t,i){if(r.existsSync(e)){t?(t=t.split(`\\`).join(`/`),t.charAt(t.length-1)!==`/`&&(t+=`/`)):t=``;var a=e.split(`\\`).join(`/`).split(`/`).pop();i?this.addFile(t+i,r.readFileSync(e),``,0):this.addFile(t+a,r.readFileSync(e),``,0)}else throw n.Errors.FILE_NOT_FOUND.replace(`%s`,e)},addLocalFolder:function(e,t,a){if(a===void 0?a=function(){return!0}:a instanceof RegExp&&(a=function(e){return function(t){return e.test(t)}}(a)),t?(t=t.split(`\\`).join(`/`),t.charAt(t.length-1)!==`/`&&(t+=`/`)):t=``,e=i.normalize(e),e=e.split(`\\`).join(`/`),e.charAt(e.length-1)!==`/`&&(e+=`/`),r.existsSync(e)){var o=n.findFiles(e),s=this;o.length&&o.forEach(function(n){var i=n.split(`\\`).join(`/`).replace(new RegExp(e.replace(/(\(|\))/g,`\\$1`),`i`),``);a(i)&&(i.charAt(i.length-1)===`/`?s.addFile(t+i,Buffer.alloc(0),``,0):s.addFile(t+i,r.readFileSync(n),``,0))})}else throw n.Errors.FILE_NOT_FOUND.replace(`%s`,e)},addFile:function(e,n,r,i){var o=new a;o.entryName=e,o.comment=r||``,i||=o.isDirectory?1106051088:420<<16,o.attr=i,o.setData(n),t.setEntry(o)},getEntries:function(){return t?t.entries:[]},getEntry:function(e){return l(e)},extractEntryTo:function(e,a,o,s){s||=!1,o=o===void 0?!0:o;var u=l(e);if(!u)throw n.Errors.NO_ENTRY;var d=u.entryName,f=c(a,o?d:i.basename(d));if(u.isDirectory)return f=i.resolve(f,`..`),t.getEntryChildren(u).forEach(function(e){if(!e.isDirectory){var t=e.getData();if(!t)throw n.Errors.CANT_EXTRACT_FILE;var r=c(a,o?e.entryName:i.basename(e.entryName));n.writeFileTo(r,t,s)}}),!0;var p=u.getData();if(!p)throw n.Errors.CANT_EXTRACT_FILE;if(r.existsSync(f)&&!s)throw n.Errors.CANT_OVERRIDE;return n.writeFileTo(f,p,s),!0},test:function(){if(!t)return!1;for(var e in t.entries)try{if(e.isDirectory)continue;if(!t.entries[e].getData())return!1}catch{return!1}return!0},extractAllTo:function(e,i){if(i||=!1,!t)throw n.Errors.NO_ZIP;t.entries.forEach(function(t){var a=c(e,t.entryName.toString());if(t.isDirectory){n.makeDir(a);return}var o=t.getData();if(!o)throw n.Errors.CANT_EXTRACT_FILE;n.writeFileTo(a,o,i),r.utimesSync(a,t.header.time,t.header.time)})},extractAllToAsync:function(e,a,o){if(o||=function(){},a||=!1,!t){o(Error(n.Errors.NO_ZIP));return}var s=t.entries,l=s.length;s.forEach(function(t){if(!(l<=0)){var s=i.normalize(t.entryName.toString());if(t.isDirectory){n.makeDir(c(e,s)),--l===0&&o(void 0);return}t.getDataAsync(function(u){if(!(l<=0)){if(!u){l=0,o(Error(n.Errors.CANT_EXTRACT_FILE));return}n.writeFileToAsync(c(e,s),u,a,function(n){if(r.utimesSync(i.resolve(e,s),t.header.time,t.header.time),!(l<=0)){if(!n){l=0,o(Error(`Unable to write`));return}--l===0&&o(void 0)}})}})}})},writeZip:function(e,r){if(arguments.length===1&&typeof e==`function`&&(r=e,e=``),!e&&s&&(e=s),e){var i=t.compressToBuffer();if(i){var a=n.writeFileTo(e,i,!0);typeof r==`function`&&r(a?null:Error(`failed`),``)}}},toBuffer:function(e,n,r,i){return this.valueOf=2,typeof e==`function`?(t.toAsyncBuffer(e,n,r,i),null):t.compressToBuffer()}}}}))(),1);const Cr=J.create(`zip`);var wr=class{},Tr=class extends wr{signature;constructor(e){super(),this.signature=e}verify(e){let t=this.signature.path,n=e.getEntries();n.sort((e,t)=>e.entryName.localeCompare(t.entryName));let r=e.readAsText(t),i=O.createVerify(`RSA-SHA512`);return n.forEach(e=>{e.entryName!==t&&i.update(new Uint8Array(e.getData()))}),i.verify(this.signature.key,r,`base64`)}};async function Er(e){let t=new Sr.default(e.from);if(Cr.debug({from:e.from,to:e.to},`Extracting zip archive`),await Dr(e.to),e.verifier&&!await e.verifier.verify(t))throw Cr.error({from:e.from},`Archive signature verification failed`),Error(`Could not verify archive signature`);return e.verifier&&Cr.debug({from:e.from},`Verified archive signature`),await new Promise((n,r)=>{t.extractAllToAsync(e.to,!0,e=>{e?r(e):n()})}),Cr.debug({from:e.from,to:e.to},`Extracted zip archive`),{extractTo:e.to}}async function Dr(e){try{if(!(await w(e)).isDirectory())throw Error(`Extraction target must be a directory: ${e}`)}catch(e){if(!(e instanceof Error)||!(`code`in e)||e.code!==`ENOENT`)throw e}}const Or=i(Y.paths.dirs.home,`key.lic`),Q=J.create(`core/installer`),kr={downloads:i(Y.paths.dirs.current,`downloads`),versions:i(Y.paths.dirs.current,`wallaby.json`),manifest:i(Y.paths.dirs.current,`core.json`),pinned:i(Y.paths.dirs.current,`pinned.version`)};function Ar(){try{let e=e=>e&&e.replace(/^\s+|\s+$/gm,``),t=G.default.readFileSync(Or).toString();if(t){let n=t.split(`:`);n.length===2&&(t=e(n[1]))}return Buffer.from(t,`base64`).toString().split(`
|
|
57
|
+
`)[2]}catch{}}var jr=class extends Tr{version=``;date=new Date(NaN);constructor(){super({path:`signature.txt`,key:`-----BEGIN RSA PUBLIC KEY-----
|
|
58
58
|
MIIBCgKCAQEAngwMnSkF1zlHJggr7kXXO02ytYIlzMdvQxHu6hli+TFIeO72HNfK
|
|
59
59
|
P27g+f8EtlPRB0UwnpAHtkJHNCdwpo04eU8hS8g9vbmNf00luUJGuUHnf62Pp0EI
|
|
60
60
|
KbGKJvzkdPgfs62MItfi4uf+XiHa8rN0Bk7hRbddI1zA4Wupf/E0wZ7UorgCE9XB
|
|
61
61
|
EM6VULphGdHorpmHBW5deeCHIledtMOpOfDSM5lvjiqgVqmjNYT+WXCwjN8yCcyU
|
|
62
62
|
oedY3afSHTyqiuInKcpXd+VJQb2+d7y583Pb3+kDGraBMGFJaWGewm7+IYIlgk5C
|
|
63
63
|
uk54FsjCvwvaa0SKr2rkIBKuyFX3ZGymyQIDAQAB
|
|
64
|
-
-----END RSA PUBLIC KEY-----`})}verify(e){this.version=JSON.parse(e.readAsText(`package.json`)).version,this.date=new Date(e.getEntry(`package.json`).header.time),this.date.setMinutes(this.date.getMinutes()-this.date.getTimezoneOffset());let[t,n,r]=this.version.split(`.`).map(e=>Number.parseInt(e,10));return t>1||n>0||r>1091?super.verify(e):!0}};async function Ar(e,t,n,r){let a=!1;Z.debug({path:t,latest:n,reuse:r,ssl:e},`Resolving distribution with update policy`);let o=new Nr,s=Or(),c=e===`off`?`http`:`https`,l=`${c}://update.wallabyjs.com/`,u=l,d=t=>ir(`version`,`${t}wallaby.json?${s?`expiry=`+s.replace(/\//g,`-`):``}`,Dr.versions,void 0,e!==`relaxed`),f=o.pinned,p=n?!1:!!t&&W.default.existsSync(t),m=i(Dr.downloads,`wallaby.zip`);if(!p&&!n&&W.default.existsSync(m))try{t=await Mr(m),p=!!t&&W.default.existsSync(t),a=!0,Z.debug({path:t},`Recovered from cached archive`)}catch(e){Z.info({error:e,distFilePath:m},`Failed to recover from cached archive`)}let h;if(r&&p)h=o.read(t),Z.debug({path:t,latestVersion:h},`Using installed version`);else{let e=Fr(`Downloading version file`);try{try{await d(l)}catch{u=`${c}://s3.amazonaws.com/wallaby-downloads/`,Z.debug({downloadUrl:u},`Falling back to S3 metadata endpoint`),await d(`http://update.wallabyjs.com/`)}}finally{e()}h=o.latest,Z.debug({latestVersion:h},`Fetched latest version`)}if(f&&(h&&(0,nr.gt)(f,h)?await o.unpin():h=f,Z.debug({pinnedVersion:f,latestVersion:h},`Applied pinned version policy`)),!(p&&o.read(t)===h))try{t=await jr(`core`,`${u}wallaby-v${h}.zip`,e),a=!0}catch{Z.info({latestVersion:h},`Primary download failed, falling back to S3 archive`),t=await jr(`core`,`${c}://s3.amazonaws.com/wallaby-downloads/wallaby-v${h}.zip`,e),a=!0}return Z.debug({path:t,updated:a,latestVersion:h},`Resolved dist`),{path:t,updated:a,type:`dist`}}async function jr(e,t,n){Z.debug({name:e,from:t,ssl:n},`Downloading and extracting dist`);let r=Fr(`Downloading core`),a=i(Dr.downloads,`wallaby.zip`);try{W.default.ensureDirSync(Dr.downloads),await ir(e,t,a,2e6,n!==`relaxed`)}finally{r()}let o=Fr(`Extracting core`);try{return await Mr(a)}catch(t){throw Z.error({error:t,downloadedArchiveFilePath:a},`Failed to extract archive`),Error(`Error while unzipping wallaby.js ${e} file: ${t instanceof Error?t.message:String(t)}`,{cause:t})}finally{o()}}async function Mr(e){let t=A.randomBytes(3).toString(`hex`),n=i(X.paths.dirs.current,`wallaby`+t);for(;W.default.existsSync(n);)t=A.randomBytes(3).toString(`hex`),n=i(X.paths.dirs.current,`wallaby`+t);let r=new kr;await Cr({from:e,to:n,verifier:r});let a=new Nr().register(t,r.date.getTime());return Z.debug({from:e,to:{extracted:n,registered:a}},`Extracted dist`),a}var Nr=class{_logger=K.create(`core/installer/vm`);_paths;constructor(e){this._paths={pinned:e?.pinned??Dr.pinned,manifest:e?.manifest??Dr.manifest,versions:e?.versions??Dr.versions}}get pinned(){if(W.default.existsSync(this._paths.pinned)){let e=W.default.readFileSync(this._paths.pinned,`utf-8`);return this._logger.debug({version:e},`Read pinned version`),e}}get latest(){let e=JSON.parse(W.default.readFileSync(this._paths.versions).toString()),t;return e.latestServer.forEach(e=>{e.substring(0,e.lastIndexOf(`.`))===X.version.substring(0,e.lastIndexOf(`.`))&&(t=e)}),this._logger.debug({latest:t},`Resolved latest known version`),t}async pin(e){this._logger.info({version:e},`Pinning version`),await E(this._paths.pinned,e)}async unpin(){if(W.default.existsSync(this._paths.pinned))return this._logger.debug(`Removing pinned version`),await T(this._paths.pinned)}refresh(e,t=!1){let n;if(!e)try{e=JSON.parse(W.default.readFileSync(this._paths.manifest).toString())}catch{}e||={},this._logger.debug({manifestEntries:Object.keys(e).length},`Resolving installed core from manifest`);let a;try{let[e,t,n]=Or().split(`/`);a=new Date(Date.UTC(Number.parseInt(n,10),Number.parseInt(t,10)-1,Number.parseInt(e,10))).getTime()}catch{}let o=this.pinned,s=Object.keys(e).map(t=>{let n=i(i(X.paths.dirs.current,`wallaby`+t),`package.json`),r=o&&W.default.existsSync(n)?JSON.parse(W.default.readFileSync(n,`utf-8`)).version:void 0;return{id:t,pinned:o?r===o:!1,package:n,...e[t]}}).sort((e,t)=>t.releaseDate-e.releaseDate),c=new Date().getTime()-1e3*60*60*24*5;s.forEach(n=>{W.default.existsSync(n.package)?!n.pinned&&n.invalidated&&Object.keys(n.expiry).length===0&&n.invalidated<c&&(t=!0,delete e[n.id],W.default.remove(r(n.package)).catch(e=>{this._logger.warn({error:e,path:n.package},`Failed to remove invalidated core directory`)})):(t=!0,delete e[n.id])});let l=s.filter(t=>(!a||t.releaseDate<a)&&e[t.id]);if(l.length){if(a&&a<new Date().getTime()&&!e[l[0].id].expiry[a]){e[l[0].id].expiry[a]=!0;for(let t=1;t<l.length;t++)delete e[l[t].id].expiry[a];t=!0}let r=o?(l.find(e=>e.pinned)||l.find(e=>!e.invalidated)||l[0]).id:(l.find(e=>!e.invalidated)||l[0]).id;n=i(X.paths.dirs.current,`wallaby`+r),this._logger.debug({coreFolder:n,pinnedVersion:o},`Selected installed core folder`)}return t&&(W.default.writeFileSync(this._paths.manifest,JSON.stringify(e)),this._logger.debug({coreVersionManifest:this._paths.manifest},`Saved updated core manifest`)),n}register(e,t){let n;try{n=JSON.parse(W.default.readFileSync(this._paths.manifest).toString());let e=new Date().getTime();Object.keys(n).forEach(r=>{!n[r].invalidated&&n[r].releaseDate<=t&&(n[r].invalidated=e)})}catch{n={}}return n[e]={releaseDate:t,invalidated:!1,expiry:{}},this._logger.debug({id:e,releaseDate:t},`Added new core version to manifest`),this.refresh(n,!0)}read(e){let t=JSON.parse(W.default.readFileSync(i(e,`package.json`)).toString()).version;return this._logger.debug({path:e,version:t},`Read version`),t}async handle(e){return e=e?.trim(),e?e===`0`?{update:!1,fresh:!0}:e===`latest`?(await this.unpin(),{update:!0,fresh:!0}):(await this.pin(e.startsWith(`v`)?e.slice(1):e),{update:!1,fresh:!0}):{update:!1,fresh:!1}}},Pr=class{_timeout;_retry=0;_dist;_restarter;get dist(){return this._dist}clear(){this._dist=void 0}set restarter(e){this._restarter=e}stop(){clearTimeout(this._timeout),this._timeout=void 0}async check(e,t){try{Z.debug({path:e},`Performing update check`);let n=await Ar(t,e);if(n.updated){this._dist=n;let e=new Nr().read(n.path);Z.debug({path:n.path,version:e},`Core update downloaded`),this._restarter?.restart(e),this._retry=0}}catch(t){this._retry++,Z.info({error:t,path:e,retry:this._retry},`Scheduled update check failed`)}finally{this._retry<=3?this.schedule(this._dist?.path||e,t):Z.warn({path:e,retry:this._retry},`Stopped scheduling update checks after repeated failures`)}}schedule(e,t){this.stop(),Z.debug({path:e},`Scheduled update check`),this._timeout=setTimeout(async()=>await this.check(e,t),600*1e3)}};function Fr(e){let t=new tr.Spinner;return t.setSpinnerString(4),t.setSpinnerDelay(250),t.setSpinnerTitle(` ${G.default.green(`%s`)} ${e}`),t.start(),()=>t.stop(!0)}const Ir=K.create(`core/locator`),Lr=e(import.meta.url);r(_(import.meta.url));async function Rr(e){try{let e=Lr.resolve(`@wallabyjs/core`);if(await W.default.pathExists(e))return Ir.info({path:e},`Using installed @wallabyjs/core package`),{path:e,type:`npm`}}catch(e){Ir.debug({error:e},`No installed @wallabyjs/core package found`)}let t=await e();if(!t)throw Error(`Could not locate installed Wallaby Core`);return t}const Q=K.create(`core/launcher`);var zr=class e{location;version;_process;_ready=e._createDeferred();_exited=e._createDeferred();_stopping=e._createDeferred();_interrupted=!1;_cleaned=!1;_tail=``;constructor(e,t,n){this._process=e,this.location=t,this.version=n,this._attach(),e.pid||this._fail(Error(`Failed to start Wallaby process: no PID`))}async exited(){let e=this._exited.promise,{promise:t,cleanup:n}=this._waitShutdown();try{await Promise.race([this.ready,t,e]),await e}finally{n()}}get ready(){return this._ready.promise}get stopping(){return this._stopping.promise}release(){Q.debug({pid:this._process.pid},`Releasing process handle`),this._cleanup(),this._process.stdout.destroy(),this._process.stderr.destroy(),this._process.unref()}async stop(){if(!this._interrupted&&(this._interrupted=!0,this._stopping.resolve(),Q.debug({pid:this._process.pid},`Stopping process`),!(this._process.exitCode!==null||this._process.signalCode!==null)&&!this._process.kill(`SIGINT`)))throw Error(`Failed to terminate Wallaby process`)}_attach(){this._process.stdout.on(`data`,this._onStdOut),this._process.stderr.on(`data`,this._onStdError),this._process.on(`error`,this._onError),this._process.on(`exit`,this._onExit)}_waitShutdown(){let e=new Map,t=!1,n=[`SIGINT`,`SIGTERM`];return{promise:new Promise((r,i)=>{for(let a of n){let n=()=>{t||(t=!0,this._handleShutdown(a).then(r,i))};e.set(a,n),process.on(a,n)}}),cleanup:()=>{for(let[t,n]of e)process.off(t,n)}}}async _handleShutdown(e){Q.debug({signal:e},`Received shutdown signal`),await this.stop()}_onStdOut=e=>{if(this._tail===void 0)return;let t=this._tail+e.toString(`utf8`),n=t.match(/wallaby\.js started, port=(\d+)/);if(n){delete this._tail,this._process.stdout.off(`data`,this._onStdOut),this._ready.resolve(Number.parseInt(n[1],10));return}this._tail=t};_onStdError=e=>{let t=e.toString(`utf8`);Q.warn({stderr:t}),this._tail!==void 0&&process.stdout.write(t)};_onError=e=>{Q.error({error:e},`Process emitted an error`),this._fail(e,this._tail===void 0?`Wallaby process crashed`:`Wallaby process failed to start`),this._cleanup()};_onExit=(t,n)=>{Q.info({code:t,signal:n},`Process exited`),this._tail!==void 0&&this._ready.reject(e._createExitError(`Wallaby exited unexpectedly before startup completed`,t,n)),this._interrupted?this._exited.resolve():this._exited.reject(e._createExitError(`Wallaby exited unexpectedly`,t,n)),this._cleanup()};_cleanup(){this._cleaned||(this._cleaned=!0,this._process.stdout.off(`data`,this._onStdOut),this._process.stderr.off(`data`,this._onStdError),this._process.off(`error`,this._onError),this._process.off(`exit`,this._onExit))}_fail(e,t){let n=t?Error(`${t}: ${e.message}`):e;this._ready.reject(n),this._interrupted?this._exited.resolve():this._exited.reject(n)}static _createDeferred(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}static _createExitError(e,t,n){let r=``;return n&&(r=` (signal: ${n})`),t!==null&&(r=` (code: ${t})`),Error(`${e}${r}.`)}};async function Br(e,t,n){n?.stop();let r=await t.handle(e.update);r.fresh&&n?.clear();let a=async()=>await Ar(e.ssl,t.refresh(),r.update,!0),o=r.fresh?await Rr(a):n?.dist||await Rr(a);Q.debug({...o},`Located target to launch`);let s=Vr(e,t.pinned),c=t.read(o.path),[,,l]=c.split(`.`);if(Number.parseInt(l,10)<2033)throw Q.debug({revision:l},`Refusing to start unsupported version`),Error(`Wallaby Core v${c} is not supported by Wallaby CLI v ${X.version}.\nRun with --update flag to get the latest version of Wallaby Core.`);Q.info({args:s,revision:l},`Launching process`);let u=ee(process.execPath,[i(o.path,`server.js`),`extended-core-ws`,...s],{stdio:[`ignore`,`pipe`,`pipe`]});return Q.info({pid:u.pid},`Launched process`),new zr(u,o,c)}function Vr(e,t){let n=[`--port=0`,`--lkp=${Er}`,`--cli=${X.version}`,`--customNodeVersion=0`,`--capabilities=js`];return e.config&&n.push(`--configPath=${s(e.config)}`),e.smart&&n.push(`--smartStart=true`),t&&n.push(`--pinned=`+t),e.ignoreRunResultCache&&n.push(`--ignoreRunResultCache`),e.skill&&n.push(`--skill`),n}const Hr=K.create(`core/registry`);var Ur=class{constructor(e=i(X.paths.dirs.home,`registry`)){this._storeDirPath=e,p(this._storeDirPath)||m(this._storeDirPath,{recursive:!0})}get manifests(){let e=[];try{for(let t of g(this._storeDirPath))if(t.endsWith(`.json`))try{let n=JSON.parse(h(i(this._storeDirPath,t),`utf8`));e.push(n)}catch(e){Hr.trace({error:e},`Failed to read manifest`)}}catch(e){Hr.error({error:e},`Failed to read registry directory`)}return e}},Wr=z(((e,t)=>{let n=[`nodebuffer`,`arraybuffer`,`fragments`],r=typeof Blob<`u`;r&&n.push(`blob`),t.exports={BINARY_TYPES:n,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,hasBlob:r,kForOnEventAttribute:Symbol(`kIsForOnEventAttribute`),kListener:Symbol(`kListener`),kStatusCode:Symbol(`status-code`),kWebSocket:Symbol(`websocket`),NOOP:()=>{}}})),Gr=z(((e,t)=>{let{EMPTY_BUFFER:n}=Wr(),r=Buffer[Symbol.species];function i(e,t){if(e.length===0)return n;if(e.length===1)return e[0];let i=Buffer.allocUnsafe(t),a=0;for(let t=0;t<e.length;t++){let n=e[t];i.set(n,a),a+=n.length}return a<t?new r(i.buffer,i.byteOffset,a):i}function a(e,t,n,r,i){for(let a=0;a<i;a++)n[r+a]=e[a]^t[a&3]}function o(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function s(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function c(e){if(c.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new r(e):ArrayBuffer.isView(e)?t=new r(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),c.readOnly=!1),t}if(t.exports={concat:i,mask:a,toArrayBuffer:s,toBuffer:c,unmask:o},!process.env.WS_NO_BUFFER_UTIL)try{let e=B(`bufferutil`);t.exports.mask=function(t,n,r,i,o){o<48?a(t,n,r,i,o):e.mask(t,n,r,i,o)},t.exports.unmask=function(t,n){t.length<32?o(t,n):e.unmask(t,n)}}catch{}})),Kr=z(((e,t)=>{let n=Symbol(`kDone`),r=Symbol(`kRun`);t.exports=class{constructor(e){this[n]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[n])}}}})),qr=z(((e,t)=>{let n=B(`zlib`),r=Gr(),i=Kr(),{kStatusCode:a}=Wr(),o=Buffer[Symbol.species],s=Buffer.from([0,0,255,255]),c=Symbol(`permessage-deflate`),l=Symbol(`total-length`),u=Symbol(`callback`),d=Symbol(`buffers`),f=Symbol(`error`),p;t.exports=class{constructor(e){this._options=e||{},this._threshold=this._options.threshold===void 0?1024:this._options.threshold,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,p||=new i(this._options.concurrencyLimit===void 0?10:this._options.concurrencyLimit)}static get extensionName(){return`permessage-deflate`}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits??(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&=(this._inflate.close(),null),this._deflate){let e=this._deflate[u];this._deflate.close(),this._deflate=null,e&&e(Error(`The deflate stream was closed while data was being processed`))}}acceptAsServer(e){let t=this._options,n=e.find(e=>!(t.serverNoContextTakeover===!1&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits==`number`&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==`number`&&!e.client_max_window_bits));if(!n)throw Error(`None of the extension offers can be accepted`);return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits==`number`&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits==`number`?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw Error(`Unexpected parameter "client_no_context_takeover"`);if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits==`number`&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==`number`&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error(`Unexpected or invalid parameter "client_max_window_bits"`);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let n=e[t];if(n.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(n=n[0],t===`client_max_window_bits`){if(n!==!0){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else if(t===`server_max_window_bits`){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(t===`client_no_context_takeover`||t===`server_no_context_takeover`){if(n!==!0)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=n})}),e}decompress(e,t,n){p.add(r=>{this._decompress(e,t,(e,t)=>{r(),n(e,t)})})}compress(e,t,n){p.add(r=>{this._compress(e,t,(e,t)=>{r(),n(e,t)})})}_decompress(e,t,i){let a=this._isServer?`client`:`server`;if(!this._inflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:n.Z_DEFAULT_WINDOWBITS;this._inflate=n.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[c]=this,this._inflate[l]=0,this._inflate[d]=[],this._inflate.on(`error`,g),this._inflate.on(`data`,h)}this._inflate[u]=i,this._inflate.write(e),t&&this._inflate.write(s),this._inflate.flush(()=>{let e=this._inflate[f];if(e){this._inflate.close(),this._inflate=null,i(e);return}let n=r.concat(this._inflate[d],this._inflate[l]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[d]=[],t&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),i(null,n)})}_compress(e,t,i){let a=this._isServer?`server`:`client`;if(!this._deflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:n.Z_DEFAULT_WINDOWBITS;this._deflate=n.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[l]=0,this._deflate[d]=[],this._deflate.on(`data`,m)}this._deflate[u]=i,this._deflate.write(e),this._deflate.flush(n.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=r.concat(this._deflate[d],this._deflate[l]);t&&(e=new o(e.buffer,e.byteOffset,e.length-4)),this._deflate[u]=null,this._deflate[l]=0,this._deflate[d]=[],t&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),i(null,e)})}};function m(e){this[d].push(e),this[l]+=e.length}function h(e){if(this[l]+=e.length,this[c]._maxPayload<1||this[l]<=this[c]._maxPayload){this[d].push(e);return}this[f]=RangeError(`Max payload size exceeded`),this[f].code=`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`,this[f][a]=1009,this.removeListener(`data`,h),this.reset()}function g(e){if(this[c]._inflate=null,this[f]){this[u](this[f]);return}e[a]=1007,this[u](e)}})),Jr=z(((e,t)=>{let{isUtf8:n}=B(`buffer`),{hasBlob:r}=Wr(),i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function a(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function o(e){let t=e.length,n=0;for(;n<t;)if(!(e[n]&128))n++;else if((e[n]&224)==192){if(n+1===t||(e[n+1]&192)!=128||(e[n]&254)==192)return!1;n+=2}else if((e[n]&240)==224){if(n+2>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||e[n]===224&&(e[n+1]&224)==128||e[n]===237&&(e[n+1]&224)==160)return!1;n+=3}else if((e[n]&248)==240){if(n+3>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||(e[n+3]&192)!=128||e[n]===240&&(e[n+1]&240)==128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function s(e){return r&&typeof e==`object`&&typeof e.arrayBuffer==`function`&&typeof e.type==`string`&&typeof e.stream==`function`&&(e[Symbol.toStringTag]===`Blob`||e[Symbol.toStringTag]===`File`)}if(t.exports={isBlob:s,isValidStatusCode:a,isValidUTF8:o,tokenChars:i},n)t.exports.isValidUTF8=function(e){return e.length<24?o(e):n(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=B(`utf-8-validate`);t.exports.isValidUTF8=function(t){return t.length<32?o(t):e(t)}}catch{}})),Yr=z(((e,t)=>{let{Writable:n}=B(`stream`),r=qr(),{BINARY_TYPES:i,EMPTY_BUFFER:a,kStatusCode:o,kWebSocket:s}=Wr(),{concat:c,toArrayBuffer:l,unmask:u}=Gr(),{isValidStatusCode:d,isValidUTF8:f}=Jr(),p=Buffer[Symbol.species];t.exports=class extends n{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents===void 0?!0:e.allowSynchronousEvents,this._binaryType=e.binaryType||i[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[s]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(this._opcode===8&&this._state==0)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new p(t.buffer,t.byteOffset+e,t.length-e),new p(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],r=t.length-e;e>=n.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),r),this._buffers[0]=new p(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){e(this.createError(RangeError,`RSV2 and RSV3 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_2_3`));return}let n=(t[0]&64)==64;if(n&&!this._extensions[r.extensionName]){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._fin=(t[0]&128)==128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(!this._fragmented){e(this.createError(RangeError,`invalid opcode 0`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){e(this.createError(RangeError,`FIN must be set`,!0,1002,`WS_ERR_EXPECTED_FIN`));return}if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,`WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH`));return}}else{e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)==128,this._isServer){if(!this._masked){e(this.createError(RangeError,`MASK must be set`,!0,1002,`WS_ERR_EXPECTED_MASK`));return}}else if(this._masked){e(this.createError(RangeError,`MASK must be clear`,!0,1002,`WS_ERR_UNEXPECTED_MASK`));return}this._payloadLength===126?this._state=1:this._payloadLength===127?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),n=t.readUInt32BE(0);if(n>2**21-1){e(this.createError(RangeError,`Unsupported WebSocket frame: payload length > 2^53 - 1`,!1,1009,`WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH`));return}this._payloadLength=n*2**32+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=a;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&u(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=5,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[r.extensionName].decompress(e,this._fin,(e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){t(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._fragments.push(n)}this.dataMessage(t),this._state===0&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;r=this._binaryType===`nodebuffer`?c(n,t):this._binaryType===`arraybuffer`?l(c(n,t)):this._binaryType===`blob`?new Blob(n):n,this._allowSynchronousEvents?(this.emit(`message`,r,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!0),this._state=0,this.startLoop(e)}))}else{let r=c(n,t);if(!this._skipUTF8Validation&&!f(r)){e(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._state===5||this._allowSynchronousEvents?(this.emit(`message`,r,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit(`conclude`,1005,a),this.end();else{let n=e.readUInt16BE(0);if(!d(n)){t(this.createError(RangeError,`invalid status code ${n}`,!0,1002,`WS_ERR_INVALID_CLOSE_CODE`));return}let r=new p(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!f(r)){t(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._loop=!1,this.emit(`conclude`,n,r),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0,this.startLoop(t)}))}createError(e,t,n,r,i){this._loop=!1,this._errored=!0;let a=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,this.createError),a.code=i,a[o]=r,a}}})),Xr=z(((e,t)=>{let{Duplex:n}=B(`stream`),{randomFillSync:r}=B(`crypto`),i=qr(),{EMPTY_BUFFER:a,kWebSocket:o,NOOP:s}=Wr(),{isBlob:c,isValidStatusCode:l}=Jr(),{mask:u,toBuffer:d}=Gr(),f=Symbol(`kByteLength`),p=Buffer.alloc(4),m=8*1024,h,g=m;t.exports=class e{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=s,this[o]=void 0}static frame(e,t){let n,i=!1,a=2,o=!1;t.mask&&(n=t.maskBuffer||p,t.generateMask?t.generateMask(n):(g===m&&(h===void 0&&(h=Buffer.alloc(m)),r(h,0,m),g=0),n[0]=h[g++],n[1]=h[g++],n[2]=h[g++],n[3]=h[g++]),o=(n[0]|n[1]|n[2]|n[3])===0,a=6);let s;typeof e==`string`?(!t.mask||o)&&t[f]!==void 0?s=t[f]:(e=Buffer.from(e),s=e.length):(s=e.length,i=t.mask&&t.readOnly&&!o);let c=s;s>=65536?(a+=8,c=127):s>125&&(a+=2,c=126);let l=Buffer.allocUnsafe(i?s+a:a);return l[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(s,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),!t.mask||(l[1]|=128,l[a-4]=n[0],l[a-3]=n[1],l[a-2]=n[2],l[a-1]=n[3],o)?[l,e]:i?(u(e,n,l,a,s),[l]):(u(e,n,e,0,s),[l,e])}close(t,n,r,i){let o;if(t===void 0)o=a;else if(typeof t!=`number`||!l(t))throw TypeError(`First argument must be a valid error code number`);else if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let e=Buffer.byteLength(n);if(e>123)throw RangeError(`The message must not be greater than 123 bytes`);o=Buffer.allocUnsafe(2+e),o.writeUInt16BE(t,0),typeof n==`string`?o.write(n,2):o.set(n,2)}let s={[f]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state===0?this.sendFrame(e.frame(o,s),i):this.enqueue([this.dispatch,o,!1,s,i])}ping(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):c(t)?(i=t.size,a=!1):(t=d(t),i=t.length,a=d.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[f]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};c(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}pong(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):c(t)?(i=t.size,a=!1):(t=d(t),i=t.length,a=d.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[f]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};c(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}send(e,t,n){let r=this._extensions[i.extensionName],a=t.binary?2:1,o=t.compress,s,l;typeof e==`string`?(s=Buffer.byteLength(e),l=!1):c(e)?(s=e.size,l=!1):(e=d(e),s=e.length,l=d.readOnly),this._firstFragment?(this._firstFragment=!1,o&&r&&r.params[r._isServer?`server_no_context_takeover`:`client_no_context_takeover`]&&(o=s>=r._threshold),this._compress=o):(o=!1,a=0),t.fin&&(this._firstFragment=!0);let u={[f]:s,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:l,rsv1:o};c(e)?this._state===0?this.getBlobData(e,this._compress,u,n):this.enqueue([this.getBlobData,e,this._compress,u,n]):this._state===0?this.dispatch(e,this._compress,u,n):this.enqueue([this.dispatch,e,this._compress,u,n])}getBlobData(t,n,r,i){this._bufferedBytes+=r[f],this._state=2,t.arrayBuffer().then(t=>{if(this._socket.destroyed){let e=Error(`The socket was closed while the blob was being read`);process.nextTick(_,this,e,i);return}this._bufferedBytes-=r[f];let a=d(t);n?this.dispatch(a,n,r,i):(this._state=0,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(e=>{process.nextTick(v,this,e,i)})}dispatch(t,n,r,a){if(!n){this.sendFrame(e.frame(t,r),a);return}let o=this._extensions[i.extensionName];this._bufferedBytes+=r[f],this._state=1,o.compress(t,r.fin,(t,n)=>{if(this._socket.destroyed){let e=Error(`The socket was closed while data was being compressed`);_(this,e,a);return}this._bufferedBytes-=r[f],this._state=0,r.readOnly=!1,this.sendFrame(e.frame(n,r),a),this.dequeue()})}dequeue(){for(;this._state===0&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][f],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][f],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};function _(e,t,n){typeof n==`function`&&n(t);for(let n=0;n<e._queue.length;n++){let r=e._queue[n],i=r[r.length-1];typeof i==`function`&&i(t)}}function v(e,t,n){_(e,t,n),e.onerror(t)}})),Zr=z(((e,t)=>{let{kForOnEventAttribute:n,kListener:r}=Wr(),i=Symbol(`kCode`),a=Symbol(`kData`),o=Symbol(`kError`),s=Symbol(`kMessage`),c=Symbol(`kReason`),l=Symbol(`kTarget`),u=Symbol(`kType`),d=Symbol(`kWasClean`);var f=class{constructor(e){this[l]=null,this[u]=e}get target(){return this[l]}get type(){return this[u]}};Object.defineProperty(f.prototype,`target`,{enumerable:!0}),Object.defineProperty(f.prototype,`type`,{enumerable:!0});var p=class extends f{constructor(e,t={}){super(e),this[i]=t.code===void 0?0:t.code,this[c]=t.reason===void 0?``:t.reason,this[d]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[i]}get reason(){return this[c]}get wasClean(){return this[d]}};Object.defineProperty(p.prototype,`code`,{enumerable:!0}),Object.defineProperty(p.prototype,`reason`,{enumerable:!0}),Object.defineProperty(p.prototype,`wasClean`,{enumerable:!0});var m=class extends f{constructor(e,t={}){super(e),this[o]=t.error===void 0?null:t.error,this[s]=t.message===void 0?``:t.message}get error(){return this[o]}get message(){return this[s]}};Object.defineProperty(m.prototype,`error`,{enumerable:!0}),Object.defineProperty(m.prototype,`message`,{enumerable:!0});var h=class extends f{constructor(e,t={}){super(e),this[a]=t.data===void 0?null:t.data}get data(){return this[a]}};Object.defineProperty(h.prototype,`data`,{enumerable:!0}),t.exports={CloseEvent:p,ErrorEvent:m,Event:f,EventTarget:{addEventListener(e,t,i={}){for(let a of this.listeners(e))if(!i[n]&&a[r]===t&&!a[n])return;let a;if(e===`message`)a=function(e,n){let r=new h(`message`,{data:n?e:e.toString()});r[l]=this,g(t,this,r)};else if(e===`close`)a=function(e,n){let r=new p(`close`,{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[l]=this,g(t,this,r)};else if(e===`error`)a=function(e){let n=new m(`error`,{error:e,message:e.message});n[l]=this,g(t,this,n)};else if(e===`open`)a=function(){let e=new f(`open`);e[l]=this,g(t,this,e)};else return;a[n]=!!i[n],a[r]=t,i.once?this.once(e,a):this.on(e,a)},removeEventListener(e,t){for(let i of this.listeners(e))if(i[r]===t&&!i[n]){this.removeListener(e,i);break}}},MessageEvent:h};function g(e,t,n){typeof e==`object`&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}})),Qr=z(((e,t)=>{let{tokenChars:n}=Jr();function r(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function i(e){let t=Object.create(null),i=Object.create(null),a=!1,o=!1,s=!1,c,l,u=-1,d=-1,f=-1,p=0;for(;p<e.length;p++)if(d=e.charCodeAt(p),c===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(p!==0&&(d===32||d===9))f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);d===44?(r(t,n,i),i=Object.create(null)):c=n,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);else if(l===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(d===32||d===9)f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p),r(i,e.slice(u,f),!0),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),u=f=-1}else if(d===61&&u!==-1&&f===-1)l=e.slice(u,p),u=f=-1;else throw SyntaxError(`Unexpected character at index ${p}`);else if(o){if(n[d]!==1)throw SyntaxError(`Unexpected character at index ${p}`);u===-1?u=p:a||=!0,o=!1}else if(s)if(n[d]===1)u===-1&&(u=p);else if(d===34&&u!==-1)s=!1,f=p;else if(d===92)o=!0;else throw SyntaxError(`Unexpected character at index ${p}`);else if(d===34&&e.charCodeAt(p-1)===61)s=!0;else if(f===-1&&n[d]===1)u===-1&&(u=p);else if(u!==-1&&(d===32||d===9))f===-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);a&&=(n=n.replace(/\\/g,``),!1),r(i,l,n),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),l=void 0,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);if(u===-1||s||d===32||d===9)throw SyntaxError(`Unexpected end of input`);f===-1&&(f=p);let m=e.slice(u,f);return c===void 0?r(t,m,i):(l===void 0?r(i,m,!0):a?r(i,l,m.replace(/\\/g,``)):r(i,l,m),r(t,c,i)),t}function a(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>[t].concat(Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>e===!0?t:`${t}=${e}`).join(`; `)})).join(`; `)).join(`, `)}).join(`, `)}t.exports={format:a,parse:i}})),$r=z(((e,t)=>{let n=B(`events`),r=B(`https`),i=B(`http`),a=B(`net`),o=B(`tls`),{randomBytes:s,createHash:c}=B(`crypto`),{Duplex:l,Readable:u}=B(`stream`),{URL:d}=B(`url`),f=qr(),p=Yr(),m=Xr(),{isBlob:h}=Jr(),{BINARY_TYPES:g,CLOSE_TIMEOUT:_,EMPTY_BUFFER:v,GUID:y,kForOnEventAttribute:b,kListener:x,kStatusCode:S,kWebSocket:C,NOOP:w}=Wr(),{EventTarget:{addEventListener:T,removeEventListener:E}}=Zr(),{format:D,parse:O}=Qr(),{toBuffer:k}=Gr(),A=Symbol(`kAborted`),j=[8,13],M=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],N=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;var P=class e extends n{constructor(t,n,r){super(),this._binaryType=g[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=v,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol=``,this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t===null?(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0):(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n==`object`&&n?(r=n,n=[]):n=[n]),ee(this,t,n,r))}get binaryType(){return this._binaryType}set binaryType(e){g.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,r){let i=new p({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),a=new m(t,this._extensions,r.generateMask);this._receiver=i,this._sender=a,this._socket=t,i[C]=this,a[C]=this,t[C]=this,i.on(`conclude`,re),i.on(`drain`,ie),i.on(`error`,ae),i.on(`message`,R),i.on(`ping`,z),i.on(`pong`,se),a.onerror=le,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on(`close`,ue),t.on(`data`,de),t.on(`end`,fe),t.on(`error`,pe),this._readyState=e.OPEN,this.emit(`open`)}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage);return}this._extensions[f.extensionName]&&this._extensions[f.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){L(this,this._req,`WebSocket was closed before the connection was established`);return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),V(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ne(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||v,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ne(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||v,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof n==`function`&&(r=n,n={}),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ne(this,t,r);return}let i={binary:typeof t!=`string`,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[f.extensionName]||(i.compress=!1),this._sender.send(t||v,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){L(this,this._req,`WebSocket was closed before the connection was established`);return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(P,`CONNECTING`,{enumerable:!0,value:M.indexOf(`CONNECTING`)}),Object.defineProperty(P.prototype,`CONNECTING`,{enumerable:!0,value:M.indexOf(`CONNECTING`)}),Object.defineProperty(P,`OPEN`,{enumerable:!0,value:M.indexOf(`OPEN`)}),Object.defineProperty(P.prototype,`OPEN`,{enumerable:!0,value:M.indexOf(`OPEN`)}),Object.defineProperty(P,`CLOSING`,{enumerable:!0,value:M.indexOf(`CLOSING`)}),Object.defineProperty(P.prototype,`CLOSING`,{enumerable:!0,value:M.indexOf(`CLOSING`)}),Object.defineProperty(P,`CLOSED`,{enumerable:!0,value:M.indexOf(`CLOSED`)}),Object.defineProperty(P.prototype,`CLOSED`,{enumerable:!0,value:M.indexOf(`CLOSED`)}),[`binaryType`,`bufferedAmount`,`extensions`,`isPaused`,`protocol`,`readyState`,`url`].forEach(e=>{Object.defineProperty(P.prototype,e,{enumerable:!0})}),[`open`,`error`,`close`,`message`].forEach(e=>{Object.defineProperty(P.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[b])return t[x];return null},set(t){for(let t of this.listeners(e))if(t[b]){this.removeListener(e,t);break}typeof t==`function`&&this.addEventListener(e,t,{[b]:!0})}})}),P.prototype.addEventListener=T,P.prototype.removeEventListener=E,t.exports=P;function ee(e,t,n,a){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:_,protocolVersion:j[1],maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...a,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:`GET`,host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!j.includes(o.protocolVersion))throw RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${j.join(`, `)})`);let l;if(t instanceof d)l=t;else try{l=new d(t)}catch{throw SyntaxError(`Invalid URL: ${t}`)}l.protocol===`http:`?l.protocol=`ws:`:l.protocol===`https:`&&(l.protocol=`wss:`),e._url=l.href;let u=l.protocol===`wss:`,p=l.protocol===`ws+unix:`,m;if(l.protocol!==`ws:`&&!u&&!p?m=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:p&&!l.pathname?m=`The URL's pathname is empty`:l.hash&&(m=`The URL contains a fragment identifier`),m){let t=SyntaxError(m);if(e._redirects===0)throw t;F(e,t);return}let h=u?443:80,g=s(16).toString(`base64`),v=u?r.request:i.request,b=new Set,x;if(o.createConnection=o.createConnection||(u?te:I),o.defaultPort=o.defaultPort||h,o.port=l.port||h,o.host=l.hostname.startsWith(`[`)?l.hostname.slice(1,-1):l.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":g,Connection:`Upgrade`,Upgrade:`websocket`},o.path=l.pathname+l.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(x=new f({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers[`Sec-WebSocket-Extensions`]=D({[f.extensionName]:x.offer()})),n.length){for(let e of n){if(typeof e!=`string`||!N.test(e)||b.has(e))throw SyntaxError(`An invalid or duplicated subprotocol was specified`);b.add(e)}o.headers[`Sec-WebSocket-Protocol`]=n.join(`,`)}if(o.origin&&(o.protocolVersion<13?o.headers[`Sec-WebSocket-Origin`]=o.origin:o.headers.Origin=o.origin),(l.username||l.password)&&(o.auth=`${l.username}:${l.password}`),p){let e=o.path.split(`:`);o.socketPath=e[0],o.path=e[1]}let S;if(o.followRedirects){if(e._redirects===0){e._originalIpc=p,e._originalSecure=u,e._originalHostOrSocketPath=p?o.socketPath:l.host;let t=a&&a.headers;if(a={...a,headers:{}},t)for(let[e,n]of Object.entries(t))a.headers[e.toLowerCase()]=n}else if(e.listenerCount(`redirect`)===0){let t=p?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:l.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!u)&&(delete o.headers.authorization,delete o.headers.cookie,t||delete o.headers.host,o.auth=void 0)}o.auth&&!a.headers.authorization&&(a.headers.authorization=`Basic `+Buffer.from(o.auth).toString(`base64`)),S=e._req=v(o),e._redirects&&e.emit(`redirect`,e.url,S)}else S=e._req=v(o);o.timeout&&S.on(`timeout`,()=>{L(e,S,`Opening handshake has timed out`)}),S.on(`error`,t=>{S===null||S[A]||(S=e._req=null,F(e,t))}),S.on(`response`,r=>{let i=r.headers.location,s=r.statusCode;if(i&&o.followRedirects&&s>=300&&s<400){if(++e._redirects>o.maxRedirects){L(e,S,`Maximum redirects exceeded`);return}S.abort();let r;try{r=new d(i,t)}catch{F(e,SyntaxError(`Invalid URL: ${i}`));return}ee(e,r,n,a)}else e.emit(`unexpected-response`,S,r)||L(e,S,`Unexpected server response: ${r.statusCode}`)}),S.on(`upgrade`,(t,n,r)=>{if(e.emit(`upgrade`,t),e.readyState!==P.CONNECTING)return;S=e._req=null;let i=t.headers.upgrade;if(i===void 0||i.toLowerCase()!==`websocket`){L(e,n,`Invalid Upgrade header`);return}let a=c(`sha1`).update(g+y).digest(`base64`);if(t.headers[`sec-websocket-accept`]!==a){L(e,n,`Invalid Sec-WebSocket-Accept header`);return}let s=t.headers[`sec-websocket-protocol`],l;if(s===void 0?b.size&&(l=`Server sent no subprotocol`):b.size?b.has(s)||(l=`Server sent an invalid subprotocol`):l=`Server sent a subprotocol but none was requested`,l){L(e,n,l);return}s&&(e._protocol=s);let u=t.headers[`sec-websocket-extensions`];if(u!==void 0){if(!x){L(e,n,`Server sent a Sec-WebSocket-Extensions header but no extension was requested`);return}let t;try{t=O(u)}catch{L(e,n,`Invalid Sec-WebSocket-Extensions header`);return}let r=Object.keys(t);if(r.length!==1||r[0]!==f.extensionName){L(e,n,`Server indicated an extension that was not requested`);return}try{x.accept(t[f.extensionName])}catch{L(e,n,`Invalid Sec-WebSocket-Extensions header`);return}e._extensions[f.extensionName]=x}e.setSocket(n,r,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,e):S.end()}function F(e,t){e._readyState=P.CLOSING,e._errorEmitted=!0,e.emit(`error`,t),e.emitClose()}function I(e){return e.path=e.socketPath,a.connect(e)}function te(e){return e.path=void 0,!e.servername&&e.servername!==``&&(e.servername=a.isIP(e.host)?``:e.host),o.connect(e)}function L(e,t,n){e._readyState=P.CLOSING;let r=Error(n);Error.captureStackTrace(r,L),t.setHeader?(t[A]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(F,e,r)):(t.destroy(r),t.once(`error`,e.emit.bind(e,`error`)),t.once(`close`,e.emitClose.bind(e)))}function ne(e,t,n){if(t){let n=h(t)?t.size:k(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${M[e.readyState]})`);process.nextTick(n,t)}}function re(e,t){let n=this[C];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[C]!==void 0&&(n._socket.removeListener(`data`,de),process.nextTick(ce,n._socket),e===1005?n.close():n.close(e,t))}function ie(){let e=this[C];e.isPaused||e._socket.resume()}function ae(e){let t=this[C];t._socket[C]!==void 0&&(t._socket.removeListener(`data`,de),process.nextTick(ce,t._socket),t.close(e[S])),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e))}function oe(){this[C].emitClose()}function R(e,t){this[C].emit(`message`,e,t)}function z(e){let t=this[C];t._autoPong&&t.pong(e,!this._isServer,w),t.emit(`ping`,e)}function se(e){this[C].emit(`pong`,e)}function ce(e){e.resume()}function le(e){let t=this[C];t.readyState!==P.CLOSED&&(t.readyState===P.OPEN&&(t._readyState=P.CLOSING,V(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e)))}function V(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function ue(){let e=this[C];if(this.removeListener(`close`,ue),this.removeListener(`data`,de),this.removeListener(`end`,fe),e._readyState=P.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[C]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on(`error`,oe),e._receiver.on(`finish`,oe))}function de(e){this[C]._receiver.write(e)||this.pause()}function fe(){let e=this[C];e._readyState=P.CLOSING,e._receiver.end(),this.end()}function pe(){let e=this[C];this.removeListener(`error`,pe),this.on(`error`,w),e&&(e._readyState=P.CLOSING,this.destroy())}})),ei=z(((e,t)=>{$r();let{Duplex:n}=B(`stream`);function r(e){e.emit(`close`)}function i(){!this.destroyed&&this._writableState.finished&&this.destroy()}function a(e){this.removeListener(`error`,a),this.destroy(),this.listenerCount(`error`)===0&&this.emit(`error`,e)}function o(e,t){let o=!0,s=new n({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on(`message`,function(t,n){let r=!n&&s._readableState.objectMode?t.toString():t;s.push(r)||e.pause()}),e.once(`error`,function(e){s.destroyed||(o=!1,s.destroy(e))}),e.once(`close`,function(){s.destroyed||s.push(null)}),s._destroy=function(t,n){if(e.readyState===e.CLOSED){n(t),process.nextTick(r,s);return}let i=!1;e.once(`error`,function(e){i=!0,n(e)}),e.once(`close`,function(){i||n(t),process.nextTick(r,s)}),o&&e.terminate()},s._final=function(t){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._final(t)});return}e._socket!==null&&(e._socket._writableState.finished?(t(),s._readableState.endEmitted&&s.destroy()):(e._socket.once(`finish`,function(){t()}),e.close()))},s._read=function(){e.isPaused&&e.resume()},s._write=function(t,n,r){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._write(t,n,r)});return}e.send(t,r)},s.on(`end`,i),s.on(`error`,a),s}t.exports=o})),ti=z(((e,t)=>{let{tokenChars:n}=Jr();function r(e){let t=new Set,r=-1,i=-1,a=0;for(;a<e.length;a++){let o=e.charCodeAt(a);if(i===-1&&n[o]===1)r===-1&&(r=a);else if(a!==0&&(o===32||o===9))i===-1&&r!==-1&&(i=a);else if(o===44){if(r===-1)throw SyntaxError(`Unexpected character at index ${a}`);i===-1&&(i=a);let n=e.slice(r,i);if(t.has(n))throw SyntaxError(`The "${n}" subprotocol is duplicated`);t.add(n),r=i=-1}else throw SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||i!==-1)throw SyntaxError(`Unexpected end of input`);let o=e.slice(r,a);if(t.has(o))throw SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}t.exports={parse:r}})),ni=z(((e,t)=>{let n=B(`events`),r=B(`http`),{Duplex:i}=B(`stream`),{createHash:a}=B(`crypto`),o=Qr(),s=qr(),c=ti(),l=$r(),{CLOSE_TIMEOUT:u,GUID:d,kWebSocket:f}=Wr(),p=/^[+/0-9A-Za-z]{22}==$/;t.exports=class extends n{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:u,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:l,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError(`One and only one of the "port", "server", or "noServer" options must be specified`);if(e.port==null?e.server&&(this._server=e.server):(this._server=r.createServer((e,t)=>{let n=r.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":`text/plain`}),t.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)),this._server){let e=this.emit.bind(this,`connection`);this._removeListeners=m(this._server,{listening:this.emit.bind(this,`listening`),error:this.emit.bind(this,`error`),upgrade:(t,n,r)=>{this.handleUpgrade(t,n,r,e)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error(`The server is operating in "noServer" mode`);return this._server?this._server.address():null}close(e){if(this._state===2){e&&this.once(`close`,()=>{e(Error(`The server is not running`))}),process.nextTick(h,this);return}if(e&&this.once(`close`,e),this._state!==1)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(h,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{h(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf(`?`);if((t===-1?e.url:e.url.slice(0,t))!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,r){t.on(`error`,g);let i=e.headers[`sec-websocket-key`],a=e.headers.upgrade,l=+e.headers[`sec-websocket-version`];if(e.method!==`GET`){v(this,e,t,405,`Invalid HTTP method`);return}if(a===void 0||a.toLowerCase()!==`websocket`){v(this,e,t,400,`Invalid Upgrade header`);return}if(i===void 0||!p.test(i)){v(this,e,t,400,`Missing or invalid Sec-WebSocket-Key header`);return}if(l!==13&&l!==8){v(this,e,t,400,`Missing or invalid Sec-WebSocket-Version header`,{"Sec-WebSocket-Version":`13, 8`});return}if(!this.shouldHandle(e)){_(t,400);return}let u=e.headers[`sec-websocket-protocol`],d=new Set;if(u!==void 0)try{d=c.parse(u)}catch{v(this,e,t,400,`Invalid Sec-WebSocket-Protocol header`);return}let f=e.headers[`sec-websocket-extensions`],m={};if(this.options.perMessageDeflate&&f!==void 0){let n=new s({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let e=o.parse(f);e[s.extensionName]&&(n.accept(e[s.extensionName]),m[s.extensionName]=n)}catch{v(this,e,t,400,`Invalid or unacceptable Sec-WebSocket-Extensions header`);return}}if(this.options.verifyClient){let a={origin:e.headers[`${l===8?`sec-websocket-origin`:`origin`}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(a,(a,o,s,c)=>{if(!a)return _(t,o||401,s,c);this.completeUpgrade(m,i,d,e,t,n,r)});return}if(!this.options.verifyClient(a))return _(t,401)}this.completeUpgrade(m,i,d,e,t,n,r)}completeUpgrade(e,t,n,r,i,c,l){if(!i.readable||!i.writable)return i.destroy();if(i[f])throw Error(`server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration`);if(this._state>0)return _(i,503);let u=[`HTTP/1.1 101 Switching Protocols`,`Upgrade: websocket`,`Connection: Upgrade`,`Sec-WebSocket-Accept: ${a(`sha1`).update(t+d).digest(`base64`)}`],p=new this.options.WebSocket(null,void 0,this.options);if(n.size){let e=this.options.handleProtocols?this.options.handleProtocols(n,r):n.values().next().value;e&&(u.push(`Sec-WebSocket-Protocol: ${e}`),p._protocol=e)}if(e[s.extensionName]){let t=e[s.extensionName].params,n=o.format({[s.extensionName]:[t]});u.push(`Sec-WebSocket-Extensions: ${n}`),p._extensions=e}this.emit(`headers`,u,r),i.write(u.concat(`\r
|
|
64
|
+
-----END RSA PUBLIC KEY-----`})}verify(e){this.version=JSON.parse(e.readAsText(`package.json`)).version,this.date=new Date(e.getEntry(`package.json`).header.time),this.date.setMinutes(this.date.getMinutes()-this.date.getTimezoneOffset());let[t,n,r]=this.version.split(`.`).map(e=>Number.parseInt(e,10));return t>1||n>0||r>1091?super.verify(e):!0}};async function Mr(e,t,n,r){let a=!1;Q.debug({path:t,latest:n,reuse:r,ssl:e},`Resolving distribution with update policy`);let o=new Fr,s=Ar(),c=e===`off`?`http`:`https`,l=`${c}://update.wallabyjs.com/`,u=l,d=t=>sr(`version`,`${t}wallaby.json?${s?`expiry=`+s.replace(/\//g,`-`):``}`,kr.versions,void 0,e!==`relaxed`),f=o.pinned,p=n?!1:!!t&&G.default.existsSync(t),m=i(kr.downloads,`wallaby.zip`);if(!p&&!n&&G.default.existsSync(m))try{t=await Pr(m),p=!!t&&G.default.existsSync(t),a=!0,Q.debug({path:t},`Recovered from cached archive`)}catch(e){Q.info({error:e,distFilePath:m},`Failed to recover from cached archive`)}let h;if(r&&p)h=o.read(t),Q.debug({path:t,latestVersion:h},`Using installed version`);else{let e=Lr(`Downloading version file`);try{try{await d(l)}catch{u=`${c}://s3.amazonaws.com/wallaby-downloads/`,Q.debug({downloadUrl:u},`Falling back to S3 metadata endpoint`),await d(`http://update.wallabyjs.com/`)}}finally{e()}h=o.latest,Q.debug({latestVersion:h},`Fetched latest version`)}if(f&&(h&&(0,ar.gt)(f,h)?await o.unpin():h=f,Q.debug({pinnedVersion:f,latestVersion:h},`Applied pinned version policy`)),!(p&&o.read(t)===h))try{t=await Nr(`core`,`${u}wallaby-v${h}.zip`,e),a=!0}catch{Q.info({latestVersion:h},`Primary download failed, falling back to S3 archive`),t=await Nr(`core`,`${c}://s3.amazonaws.com/wallaby-downloads/wallaby-v${h}.zip`,e),a=!0}return Q.debug({path:t,updated:a,latestVersion:h},`Resolved dist`),{path:t,updated:a,type:`dist`}}async function Nr(e,t,n){Q.debug({name:e,from:t,ssl:n},`Downloading and extracting dist`);let r=Lr(`Downloading core`),a=i(kr.downloads,`wallaby.zip`);try{G.default.ensureDirSync(kr.downloads),await sr(e,t,a,2e6,n!==`relaxed`)}finally{r()}let o=Lr(`Extracting core`);try{return await Pr(a)}catch(t){throw Q.error({error:t,downloadedArchiveFilePath:a},`Failed to extract archive`),Error(`Error while unzipping wallaby.js ${e} file: ${t instanceof Error?t.message:String(t)}`,{cause:t})}finally{o()}}async function Pr(e){let t=O.randomBytes(3).toString(`hex`),n=i(Y.paths.dirs.current,`wallaby`+t);for(;G.default.existsSync(n);)t=O.randomBytes(3).toString(`hex`),n=i(Y.paths.dirs.current,`wallaby`+t);let r=new jr;await Er({from:e,to:n,verifier:r});let a=new Fr().register(t,r.date.getTime());return Q.debug({from:e,to:{extracted:n,registered:a}},`Extracted dist`),a}var Fr=class{_logger=J.create(`core/installer/vm`);_paths;constructor(e){this._paths={pinned:e?.pinned??kr.pinned,manifest:e?.manifest??kr.manifest,versions:e?.versions??kr.versions}}get pinned(){if(G.default.existsSync(this._paths.pinned)){let e=G.default.readFileSync(this._paths.pinned,`utf-8`);return this._logger.debug({version:e},`Read pinned version`),e}}get latest(){let e=JSON.parse(G.default.readFileSync(this._paths.versions).toString()),t;return e.latestServer.forEach(e=>{e.substring(0,e.lastIndexOf(`.`))===Y.version.substring(0,e.lastIndexOf(`.`))&&(t=e)}),this._logger.debug({latest:t},`Resolved latest known version`),t}async pin(e){this._logger.info({version:e},`Pinning version`),await E(this._paths.pinned,e)}async unpin(){if(G.default.existsSync(this._paths.pinned))return this._logger.debug(`Removing pinned version`),await T(this._paths.pinned)}refresh(e,t=!1){let n;if(!e)try{e=JSON.parse(G.default.readFileSync(this._paths.manifest).toString())}catch{}e||={},this._logger.debug({manifestEntries:Object.keys(e).length},`Resolving installed core from manifest`);let a;try{let[e,t,n]=Ar().split(`/`);a=new Date(Date.UTC(Number.parseInt(n,10),Number.parseInt(t,10)-1,Number.parseInt(e,10))).getTime()}catch{}let o=this.pinned,s=Object.keys(e).map(t=>{let n=i(i(Y.paths.dirs.current,`wallaby`+t),`package.json`),r=o&&G.default.existsSync(n)?JSON.parse(G.default.readFileSync(n,`utf-8`)).version:void 0;return{id:t,pinned:o?r===o:!1,package:n,...e[t]}}).sort((e,t)=>t.releaseDate-e.releaseDate),c=new Date().getTime()-1e3*60*60*24*5;s.forEach(n=>{G.default.existsSync(n.package)?!n.pinned&&n.invalidated&&Object.keys(n.expiry).length===0&&n.invalidated<c&&(t=!0,delete e[n.id],G.default.remove(r(n.package)).catch(e=>{this._logger.warn({error:e,path:n.package},`Failed to remove invalidated core directory`)})):(t=!0,delete e[n.id])});let l=s.filter(t=>(!a||t.releaseDate<a)&&e[t.id]);if(l.length){if(a&&a<new Date().getTime()&&!e[l[0].id].expiry[a]){e[l[0].id].expiry[a]=!0;for(let t=1;t<l.length;t++)delete e[l[t].id].expiry[a];t=!0}let r=o?(l.find(e=>e.pinned)||l.find(e=>!e.invalidated)||l[0]).id:(l.find(e=>!e.invalidated)||l[0]).id;n=i(Y.paths.dirs.current,`wallaby`+r),this._logger.debug({coreFolder:n,pinnedVersion:o},`Selected installed core folder`)}return t&&(G.default.writeFileSync(this._paths.manifest,JSON.stringify(e)),this._logger.debug({coreVersionManifest:this._paths.manifest},`Saved updated core manifest`)),n}register(e,t){let n;try{n=JSON.parse(G.default.readFileSync(this._paths.manifest).toString());let e=new Date().getTime();Object.keys(n).forEach(r=>{!n[r].invalidated&&n[r].releaseDate<=t&&(n[r].invalidated=e)})}catch{n={}}return n[e]={releaseDate:t,invalidated:!1,expiry:{}},this._logger.debug({id:e,releaseDate:t},`Added new core version to manifest`),this.refresh(n,!0)}read(e){let t=JSON.parse(G.default.readFileSync(i(e,`package.json`)).toString()).version;return this._logger.debug({path:e,version:t},`Read version`),t}async handle(e){return e=e?.trim(),e?e===`0`?{update:!1,fresh:!0}:e===`latest`?(await this.unpin(),{update:!0,fresh:!0}):(await this.pin(e.startsWith(`v`)?e.slice(1):e),{update:!1,fresh:!0}):{update:!1,fresh:!1}}},Ir=class{_timeout;_retry=0;_dist;_restarter;get dist(){return this._dist}clear(){this._dist=void 0}set restarter(e){this._restarter=e}stop(){clearTimeout(this._timeout),this._timeout=void 0}async check(e,t){try{Q.debug({path:e},`Performing update check`);let n=await Mr(t,e);if(n.updated){this._dist=n;let e=new Fr().read(n.path);Q.debug({path:n.path,version:e},`Core update downloaded`),this._restarter?.restart(e),this._retry=0}}catch(t){this._retry++,Q.info({error:t,path:e,retry:this._retry},`Scheduled update check failed`)}finally{this._retry<=3?this.schedule(this._dist?.path||e,t):Q.warn({path:e,retry:this._retry},`Stopped scheduling update checks after repeated failures`)}}schedule(e,t){this.stop(),Q.debug({path:e},`Scheduled update check`),this._timeout=setTimeout(async()=>await this.check(e,t),600*1e3),this._timeout.unref()}};function Lr(e){let t=new ir.Spinner;return t.setSpinnerString(4),t.setSpinnerDelay(250),t.setSpinnerTitle(` ${K.default.green(`%s`)} ${e}`),t.start(),()=>t.stop(!0)}const Rr=J.create(`core/locator`),zr=e(import.meta.url);r(_(import.meta.url));async function Br(e){try{let e=zr.resolve(`@wallabyjs/core`);if(await G.default.pathExists(e))return Rr.info({path:e},`Using installed @wallabyjs/core package`),{path:e,type:`npm`}}catch(e){Rr.debug({error:e},`No installed @wallabyjs/core package found`)}let t=await e();if(!t)throw Error(`Could not locate installed Wallaby Core`);return t}const Vr=J.create(`core/launcher`);var Hr=class e{location;version;_process;_ready=e._createDeferred();_exited=e._createDeferred();_stopping=e._createDeferred();_interrupted=!1;_cleaned=!1;_tail=``;constructor(e,t,n){this._process=e,this.location=t,this.version=n,this._attach(),e.pid||this._fail(Error(`Failed to start Wallaby process: no PID`))}async exited(e){let t=this._exited.promise,{promise:n,cleanup:r}=this._waitShutdown(e);try{await Promise.race([this.ready,n,t]),await t}finally{r()}}get ready(){return this._ready.promise}get stopping(){return this._stopping.promise}release(){Vr.debug({pid:this._process.pid},`Releasing process handle`),this._cleanup(),this._process.stdout.destroy(),this._process.stderr.destroy(),this._process.unref()}async stop(e){if(!this._interrupted&&(this._interrupted=!0,this._stopping.resolve(),Vr.debug({pid:this._process.pid},`Stopping process`),!(this._process.exitCode!==null||this._process.signalCode!==null))){if(process.platform===`win32`&&e)Vr.debug(`Stopping process through RPC`),e();else if(!this._process.kill(`SIGTERM`))throw Error(`Failed to terminate Wallaby process`)}}_attach(){this._process.stdout.on(`data`,this._onStdOut),this._process.stderr.on(`data`,this._onStdError),this._process.on(`error`,this._onError),this._process.on(`exit`,this._onExit)}_waitShutdown(e){let t=new Map,n=!1,r=[`SIGINT`,`SIGTERM`];return{promise:new Promise((i,a)=>{for(let o of r){let r=()=>{n||(n=!0,this._handleShutdown(o,e).then(i,a))};t.set(o,r),process.on(o,r)}}),cleanup:()=>{for(let[e,n]of t)process.off(e,n)}}}async _handleShutdown(e,t){Vr.debug({signal:e},`Received shutdown signal`),await this.stop(t)}_onStdOut=e=>{if(this._tail===void 0)return;let t=this._tail+e.toString(`utf8`),n=t.match(/wallaby\.js started, port=(\d+)/);if(n){delete this._tail,this._process.stdout.off(`data`,this._onStdOut),this._ready.resolve(Number.parseInt(n[1],10));return}this._tail=t};_onStdError=e=>{let t=e.toString(`utf8`);Vr.warn({stderr:t}),this._tail!==void 0&&process.stdout.write(t)};_onError=e=>{Vr.error({error:e},`Process emitted an error`),this._fail(e,this._tail===void 0?`Wallaby process crashed`:`Wallaby process failed to start`),this._cleanup()};_onExit=(t,n)=>{Vr.info({code:t,signal:n},`Process exited`),this._tail!==void 0&&this._ready.reject(e._createExitError(`Wallaby exited unexpectedly before startup completed`,t,n)),this._interrupted?this._exited.resolve():this._exited.reject(e._createExitError(`Wallaby exited unexpectedly`,t,n)),this._cleanup()};_cleanup(){this._cleaned||(this._cleaned=!0,this._process.stdout.off(`data`,this._onStdOut),this._process.stderr.off(`data`,this._onStdError),this._process.off(`error`,this._onError),this._process.off(`exit`,this._onExit))}_fail(e,t){let n=t?Error(`${t}: ${e.message}`):e;this._ready.reject(n),this._interrupted?this._exited.resolve():this._exited.reject(n)}static _createDeferred(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}static _createExitError(e,t,n){let r=``;return n&&(r=` (signal: ${n})`),t!==null&&(r=` (code: ${t})`),Error(`${e}${r}.`)}};async function Ur(e,t,n){n?.stop();let r=await t.handle(e.update);r.fresh&&n?.clear();let a=async()=>await Mr(e.ssl,t.refresh(),r.update,!0),o=r.fresh?await Br(a):n?.dist||await Br(a);Vr.debug({...o},`Located target to launch`);let s=Wr(e,t.pinned),c=t.read(o.path),[,,l]=c.split(`.`);if(Number.parseInt(l,10)<2035)throw Vr.debug({revision:l},`Refusing to start unsupported version`),Error(`Wallaby Core v${c} is not supported by Wallaby CLI v ${Y.version}.\nRun with --update flag to get the latest version of Wallaby Core.`);Vr.info({args:s,revision:l},`Launching process`);let u=F(process.execPath,[i(o.path,`server.js`),`extended-core-ws`,...s],{detached:e.skill||process.platform===`win32`,stdio:[`ignore`,`pipe`,`pipe`]});return Vr.info({pid:u.pid},`Launched process`),new Hr(u,o,c)}function Wr(e,t){let n=[`--port=0`,`--lkp=${Or}`,`--cli=${Y.version}`];return e.config&&n.push(`--configPath=${s(e.config)}`),e.smart&&n.push(`--smartStart=true`),t&&n.push(`--pinned=`+t),e.cache===!1&&n.push(`--cache=no-run-result`),e.skill&&n.push(`--skill`),n}const Gr=J.create(`core/registry`);var Kr=class{_storeDirPath;constructor(e=i(Y.paths.dirs.home,`registry`)){this._storeDirPath=e,p(this._storeDirPath)||m(this._storeDirPath,{recursive:!0})}get manifests(){let e=[];try{for(let t of g(this._storeDirPath))if(t.endsWith(`.json`))try{let n=JSON.parse(h(i(this._storeDirPath,t),`utf8`));e.push(n)}catch(e){Gr.trace({error:e},`Failed to read manifest`)}}catch(e){Gr.error({error:e},`Failed to read registry directory`)}return e}},qr=R(((e,t)=>{let n=[`nodebuffer`,`arraybuffer`,`fragments`],r=typeof Blob<`u`;r&&n.push(`blob`),t.exports={BINARY_TYPES:n,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,hasBlob:r,kForOnEventAttribute:Symbol(`kIsForOnEventAttribute`),kListener:Symbol(`kListener`),kStatusCode:Symbol(`status-code`),kWebSocket:Symbol(`websocket`),NOOP:()=>{}}})),Jr=R(((e,t)=>{let{EMPTY_BUFFER:n}=qr(),r=Buffer[Symbol.species];function i(e,t){if(e.length===0)return n;if(e.length===1)return e[0];let i=Buffer.allocUnsafe(t),a=0;for(let t=0;t<e.length;t++){let n=e[t];i.set(n,a),a+=n.length}return a<t?new r(i.buffer,i.byteOffset,a):i}function a(e,t,n,r,i){for(let a=0;a<i;a++)n[r+a]=e[a]^t[a&3]}function o(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function s(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function c(e){if(c.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new r(e):ArrayBuffer.isView(e)?t=new r(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),c.readOnly=!1),t}if(t.exports={concat:i,mask:a,toArrayBuffer:s,toBuffer:c,unmask:o},!process.env.WS_NO_BUFFER_UTIL)try{let e=B(`bufferutil`);t.exports.mask=function(t,n,r,i,o){o<48?a(t,n,r,i,o):e.mask(t,n,r,i,o)},t.exports.unmask=function(t,n){t.length<32?o(t,n):e.unmask(t,n)}}catch{}})),Yr=R(((e,t)=>{let n=Symbol(`kDone`),r=Symbol(`kRun`);t.exports=class{constructor(e){this[n]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[n])}}}})),Xr=R(((e,t)=>{let n=B(`zlib`),r=Jr(),i=Yr(),{kStatusCode:a}=qr(),o=Buffer[Symbol.species],s=Buffer.from([0,0,255,255]),c=Symbol(`permessage-deflate`),l=Symbol(`total-length`),u=Symbol(`callback`),d=Symbol(`buffers`),f=Symbol(`error`),p;t.exports=class{constructor(e){this._options=e||{},this._threshold=this._options.threshold===void 0?1024:this._options.threshold,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,p||=new i(this._options.concurrencyLimit===void 0?10:this._options.concurrencyLimit)}static get extensionName(){return`permessage-deflate`}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits??(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&=(this._inflate.close(),null),this._deflate){let e=this._deflate[u];this._deflate.close(),this._deflate=null,e&&e(Error(`The deflate stream was closed while data was being processed`))}}acceptAsServer(e){let t=this._options,n=e.find(e=>!(t.serverNoContextTakeover===!1&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits==`number`&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==`number`&&!e.client_max_window_bits));if(!n)throw Error(`None of the extension offers can be accepted`);return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits==`number`&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits==`number`?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw Error(`Unexpected parameter "client_no_context_takeover"`);if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits==`number`&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==`number`&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error(`Unexpected or invalid parameter "client_max_window_bits"`);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let n=e[t];if(n.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(n=n[0],t===`client_max_window_bits`){if(n!==!0){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else if(t===`server_max_window_bits`){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(t===`client_no_context_takeover`||t===`server_no_context_takeover`){if(n!==!0)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=n})}),e}decompress(e,t,n){p.add(r=>{this._decompress(e,t,(e,t)=>{r(),n(e,t)})})}compress(e,t,n){p.add(r=>{this._compress(e,t,(e,t)=>{r(),n(e,t)})})}_decompress(e,t,i){let a=this._isServer?`client`:`server`;if(!this._inflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:n.Z_DEFAULT_WINDOWBITS;this._inflate=n.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[c]=this,this._inflate[l]=0,this._inflate[d]=[],this._inflate.on(`error`,g),this._inflate.on(`data`,h)}this._inflate[u]=i,this._inflate.write(e),t&&this._inflate.write(s),this._inflate.flush(()=>{let e=this._inflate[f];if(e){this._inflate.close(),this._inflate=null,i(e);return}let n=r.concat(this._inflate[d],this._inflate[l]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[d]=[],t&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),i(null,n)})}_compress(e,t,i){let a=this._isServer?`server`:`client`;if(!this._deflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:n.Z_DEFAULT_WINDOWBITS;this._deflate=n.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[l]=0,this._deflate[d]=[],this._deflate.on(`data`,m)}this._deflate[u]=i,this._deflate.write(e),this._deflate.flush(n.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=r.concat(this._deflate[d],this._deflate[l]);t&&(e=new o(e.buffer,e.byteOffset,e.length-4)),this._deflate[u]=null,this._deflate[l]=0,this._deflate[d]=[],t&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),i(null,e)})}};function m(e){this[d].push(e),this[l]+=e.length}function h(e){if(this[l]+=e.length,this[c]._maxPayload<1||this[l]<=this[c]._maxPayload){this[d].push(e);return}this[f]=RangeError(`Max payload size exceeded`),this[f].code=`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`,this[f][a]=1009,this.removeListener(`data`,h),this.reset()}function g(e){if(this[c]._inflate=null,this[f]){this[u](this[f]);return}e[a]=1007,this[u](e)}})),Zr=R(((e,t)=>{let{isUtf8:n}=B(`buffer`),{hasBlob:r}=qr(),i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function a(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function o(e){let t=e.length,n=0;for(;n<t;)if(!(e[n]&128))n++;else if((e[n]&224)==192){if(n+1===t||(e[n+1]&192)!=128||(e[n]&254)==192)return!1;n+=2}else if((e[n]&240)==224){if(n+2>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||e[n]===224&&(e[n+1]&224)==128||e[n]===237&&(e[n+1]&224)==160)return!1;n+=3}else if((e[n]&248)==240){if(n+3>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||(e[n+3]&192)!=128||e[n]===240&&(e[n+1]&240)==128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function s(e){return r&&typeof e==`object`&&typeof e.arrayBuffer==`function`&&typeof e.type==`string`&&typeof e.stream==`function`&&(e[Symbol.toStringTag]===`Blob`||e[Symbol.toStringTag]===`File`)}if(t.exports={isBlob:s,isValidStatusCode:a,isValidUTF8:o,tokenChars:i},n)t.exports.isValidUTF8=function(e){return e.length<24?o(e):n(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=B(`utf-8-validate`);t.exports.isValidUTF8=function(t){return t.length<32?o(t):e(t)}}catch{}})),Qr=R(((e,t)=>{let{Writable:n}=B(`stream`),r=Xr(),{BINARY_TYPES:i,EMPTY_BUFFER:a,kStatusCode:o,kWebSocket:s}=qr(),{concat:c,toArrayBuffer:l,unmask:u}=Jr(),{isValidStatusCode:d,isValidUTF8:f}=Zr(),p=Buffer[Symbol.species];t.exports=class extends n{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents===void 0?!0:e.allowSynchronousEvents,this._binaryType=e.binaryType||i[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[s]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(this._opcode===8&&this._state==0)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new p(t.buffer,t.byteOffset+e,t.length-e),new p(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],r=t.length-e;e>=n.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),r),this._buffers[0]=new p(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){e(this.createError(RangeError,`RSV2 and RSV3 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_2_3`));return}let n=(t[0]&64)==64;if(n&&!this._extensions[r.extensionName]){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._fin=(t[0]&128)==128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(!this._fragmented){e(this.createError(RangeError,`invalid opcode 0`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){e(this.createError(RangeError,`FIN must be set`,!0,1002,`WS_ERR_EXPECTED_FIN`));return}if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,`WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH`));return}}else{e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)==128,this._isServer){if(!this._masked){e(this.createError(RangeError,`MASK must be set`,!0,1002,`WS_ERR_EXPECTED_MASK`));return}}else if(this._masked){e(this.createError(RangeError,`MASK must be clear`,!0,1002,`WS_ERR_UNEXPECTED_MASK`));return}this._payloadLength===126?this._state=1:this._payloadLength===127?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),n=t.readUInt32BE(0);if(n>2**21-1){e(this.createError(RangeError,`Unsupported WebSocket frame: payload length > 2^53 - 1`,!1,1009,`WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH`));return}this._payloadLength=n*2**32+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=a;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&u(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=5,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[r.extensionName].decompress(e,this._fin,(e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){t(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._fragments.push(n)}this.dataMessage(t),this._state===0&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;r=this._binaryType===`nodebuffer`?c(n,t):this._binaryType===`arraybuffer`?l(c(n,t)):this._binaryType===`blob`?new Blob(n):n,this._allowSynchronousEvents?(this.emit(`message`,r,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!0),this._state=0,this.startLoop(e)}))}else{let r=c(n,t);if(!this._skipUTF8Validation&&!f(r)){e(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._state===5||this._allowSynchronousEvents?(this.emit(`message`,r,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit(`conclude`,1005,a),this.end();else{let n=e.readUInt16BE(0);if(!d(n)){t(this.createError(RangeError,`invalid status code ${n}`,!0,1002,`WS_ERR_INVALID_CLOSE_CODE`));return}let r=new p(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!f(r)){t(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._loop=!1,this.emit(`conclude`,n,r),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0,this.startLoop(t)}))}createError(e,t,n,r,i){this._loop=!1,this._errored=!0;let a=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,this.createError),a.code=i,a[o]=r,a}}})),$r=R(((e,t)=>{let{Duplex:n}=B(`stream`),{randomFillSync:r}=B(`crypto`),i=Xr(),{EMPTY_BUFFER:a,kWebSocket:o,NOOP:s}=qr(),{isBlob:c,isValidStatusCode:l}=Zr(),{mask:u,toBuffer:d}=Jr(),f=Symbol(`kByteLength`),p=Buffer.alloc(4),m=8*1024,h,g=m;t.exports=class e{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=s,this[o]=void 0}static frame(e,t){let n,i=!1,a=2,o=!1;t.mask&&(n=t.maskBuffer||p,t.generateMask?t.generateMask(n):(g===m&&(h===void 0&&(h=Buffer.alloc(m)),r(h,0,m),g=0),n[0]=h[g++],n[1]=h[g++],n[2]=h[g++],n[3]=h[g++]),o=(n[0]|n[1]|n[2]|n[3])===0,a=6);let s;typeof e==`string`?(!t.mask||o)&&t[f]!==void 0?s=t[f]:(e=Buffer.from(e),s=e.length):(s=e.length,i=t.mask&&t.readOnly&&!o);let c=s;s>=65536?(a+=8,c=127):s>125&&(a+=2,c=126);let l=Buffer.allocUnsafe(i?s+a:a);return l[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(s,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),!t.mask||(l[1]|=128,l[a-4]=n[0],l[a-3]=n[1],l[a-2]=n[2],l[a-1]=n[3],o)?[l,e]:i?(u(e,n,l,a,s),[l]):(u(e,n,e,0,s),[l,e])}close(t,n,r,i){let o;if(t===void 0)o=a;else if(typeof t!=`number`||!l(t))throw TypeError(`First argument must be a valid error code number`);else if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let e=Buffer.byteLength(n);if(e>123)throw RangeError(`The message must not be greater than 123 bytes`);o=Buffer.allocUnsafe(2+e),o.writeUInt16BE(t,0),typeof n==`string`?o.write(n,2):o.set(n,2)}let s={[f]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state===0?this.sendFrame(e.frame(o,s),i):this.enqueue([this.dispatch,o,!1,s,i])}ping(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):c(t)?(i=t.size,a=!1):(t=d(t),i=t.length,a=d.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[f]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};c(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}pong(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):c(t)?(i=t.size,a=!1):(t=d(t),i=t.length,a=d.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[f]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};c(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}send(e,t,n){let r=this._extensions[i.extensionName],a=t.binary?2:1,o=t.compress,s,l;typeof e==`string`?(s=Buffer.byteLength(e),l=!1):c(e)?(s=e.size,l=!1):(e=d(e),s=e.length,l=d.readOnly),this._firstFragment?(this._firstFragment=!1,o&&r&&r.params[r._isServer?`server_no_context_takeover`:`client_no_context_takeover`]&&(o=s>=r._threshold),this._compress=o):(o=!1,a=0),t.fin&&(this._firstFragment=!0);let u={[f]:s,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:l,rsv1:o};c(e)?this._state===0?this.getBlobData(e,this._compress,u,n):this.enqueue([this.getBlobData,e,this._compress,u,n]):this._state===0?this.dispatch(e,this._compress,u,n):this.enqueue([this.dispatch,e,this._compress,u,n])}getBlobData(t,n,r,i){this._bufferedBytes+=r[f],this._state=2,t.arrayBuffer().then(t=>{if(this._socket.destroyed){let e=Error(`The socket was closed while the blob was being read`);process.nextTick(_,this,e,i);return}this._bufferedBytes-=r[f];let a=d(t);n?this.dispatch(a,n,r,i):(this._state=0,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(e=>{process.nextTick(v,this,e,i)})}dispatch(t,n,r,a){if(!n){this.sendFrame(e.frame(t,r),a);return}let o=this._extensions[i.extensionName];this._bufferedBytes+=r[f],this._state=1,o.compress(t,r.fin,(t,n)=>{if(this._socket.destroyed){let e=Error(`The socket was closed while data was being compressed`);_(this,e,a);return}this._bufferedBytes-=r[f],this._state=0,r.readOnly=!1,this.sendFrame(e.frame(n,r),a),this.dequeue()})}dequeue(){for(;this._state===0&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][f],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][f],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};function _(e,t,n){typeof n==`function`&&n(t);for(let n=0;n<e._queue.length;n++){let r=e._queue[n],i=r[r.length-1];typeof i==`function`&&i(t)}}function v(e,t,n){_(e,t,n),e.onerror(t)}})),ei=R(((e,t)=>{let{kForOnEventAttribute:n,kListener:r}=qr(),i=Symbol(`kCode`),a=Symbol(`kData`),o=Symbol(`kError`),s=Symbol(`kMessage`),c=Symbol(`kReason`),l=Symbol(`kTarget`),u=Symbol(`kType`),d=Symbol(`kWasClean`);var f=class{constructor(e){this[l]=null,this[u]=e}get target(){return this[l]}get type(){return this[u]}};Object.defineProperty(f.prototype,`target`,{enumerable:!0}),Object.defineProperty(f.prototype,`type`,{enumerable:!0});var p=class extends f{constructor(e,t={}){super(e),this[i]=t.code===void 0?0:t.code,this[c]=t.reason===void 0?``:t.reason,this[d]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[i]}get reason(){return this[c]}get wasClean(){return this[d]}};Object.defineProperty(p.prototype,`code`,{enumerable:!0}),Object.defineProperty(p.prototype,`reason`,{enumerable:!0}),Object.defineProperty(p.prototype,`wasClean`,{enumerable:!0});var m=class extends f{constructor(e,t={}){super(e),this[o]=t.error===void 0?null:t.error,this[s]=t.message===void 0?``:t.message}get error(){return this[o]}get message(){return this[s]}};Object.defineProperty(m.prototype,`error`,{enumerable:!0}),Object.defineProperty(m.prototype,`message`,{enumerable:!0});var h=class extends f{constructor(e,t={}){super(e),this[a]=t.data===void 0?null:t.data}get data(){return this[a]}};Object.defineProperty(h.prototype,`data`,{enumerable:!0}),t.exports={CloseEvent:p,ErrorEvent:m,Event:f,EventTarget:{addEventListener(e,t,i={}){for(let a of this.listeners(e))if(!i[n]&&a[r]===t&&!a[n])return;let a;if(e===`message`)a=function(e,n){let r=new h(`message`,{data:n?e:e.toString()});r[l]=this,g(t,this,r)};else if(e===`close`)a=function(e,n){let r=new p(`close`,{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[l]=this,g(t,this,r)};else if(e===`error`)a=function(e){let n=new m(`error`,{error:e,message:e.message});n[l]=this,g(t,this,n)};else if(e===`open`)a=function(){let e=new f(`open`);e[l]=this,g(t,this,e)};else return;a[n]=!!i[n],a[r]=t,i.once?this.once(e,a):this.on(e,a)},removeEventListener(e,t){for(let i of this.listeners(e))if(i[r]===t&&!i[n]){this.removeListener(e,i);break}}},MessageEvent:h};function g(e,t,n){typeof e==`object`&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}})),ti=R(((e,t)=>{let{tokenChars:n}=Zr();function r(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function i(e){let t=Object.create(null),i=Object.create(null),a=!1,o=!1,s=!1,c,l,u=-1,d=-1,f=-1,p=0;for(;p<e.length;p++)if(d=e.charCodeAt(p),c===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(p!==0&&(d===32||d===9))f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);d===44?(r(t,n,i),i=Object.create(null)):c=n,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);else if(l===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(d===32||d===9)f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p),r(i,e.slice(u,f),!0),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),u=f=-1}else if(d===61&&u!==-1&&f===-1)l=e.slice(u,p),u=f=-1;else throw SyntaxError(`Unexpected character at index ${p}`);else if(o){if(n[d]!==1)throw SyntaxError(`Unexpected character at index ${p}`);u===-1?u=p:a||=!0,o=!1}else if(s)if(n[d]===1)u===-1&&(u=p);else if(d===34&&u!==-1)s=!1,f=p;else if(d===92)o=!0;else throw SyntaxError(`Unexpected character at index ${p}`);else if(d===34&&e.charCodeAt(p-1)===61)s=!0;else if(f===-1&&n[d]===1)u===-1&&(u=p);else if(u!==-1&&(d===32||d===9))f===-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);a&&=(n=n.replace(/\\/g,``),!1),r(i,l,n),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),l=void 0,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);if(u===-1||s||d===32||d===9)throw SyntaxError(`Unexpected end of input`);f===-1&&(f=p);let m=e.slice(u,f);return c===void 0?r(t,m,i):(l===void 0?r(i,m,!0):a?r(i,l,m.replace(/\\/g,``)):r(i,l,m),r(t,c,i)),t}function a(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>[t].concat(Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>e===!0?t:`${t}=${e}`).join(`; `)})).join(`; `)).join(`, `)}).join(`, `)}t.exports={format:a,parse:i}})),ni=R(((e,t)=>{let n=B(`events`),r=B(`https`),i=B(`http`),a=B(`net`),o=B(`tls`),{randomBytes:s,createHash:c}=B(`crypto`),{Duplex:l,Readable:u}=B(`stream`),{URL:d}=B(`url`),f=Xr(),p=Qr(),m=$r(),{isBlob:h}=Zr(),{BINARY_TYPES:g,CLOSE_TIMEOUT:_,EMPTY_BUFFER:v,GUID:y,kForOnEventAttribute:b,kListener:x,kStatusCode:S,kWebSocket:C,NOOP:w}=qr(),{EventTarget:{addEventListener:T,removeEventListener:E}}=ei(),{format:D,parse:O}=ti(),{toBuffer:k}=Jr(),A=Symbol(`kAborted`),j=[8,13],M=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],N=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;var P=class e extends n{constructor(t,n,r){super(),this._binaryType=g[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=v,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol=``,this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t===null?(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0):(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n==`object`&&n?(r=n,n=[]):n=[n]),ee(this,t,n,r))}get binaryType(){return this._binaryType}set binaryType(e){g.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,r){let i=new p({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),a=new m(t,this._extensions,r.generateMask);this._receiver=i,this._sender=a,this._socket=t,i[C]=this,a[C]=this,t[C]=this,i.on(`conclude`,ie),i.on(`drain`,ae),i.on(`error`,oe),i.on(`message`,ce),i.on(`ping`,L),i.on(`pong`,R),a.onerror=ue,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on(`close`,V),t.on(`data`,de),t.on(`end`,fe),t.on(`error`,pe),this._readyState=e.OPEN,this.emit(`open`)}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage);return}this._extensions[f.extensionName]&&this._extensions[f.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){I(this,this._req,`WebSocket was closed before the connection was established`);return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),z(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){re(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||v,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){re(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||v,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof n==`function`&&(r=n,n={}),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){re(this,t,r);return}let i={binary:typeof t!=`string`,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[f.extensionName]||(i.compress=!1),this._sender.send(t||v,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){I(this,this._req,`WebSocket was closed before the connection was established`);return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(P,`CONNECTING`,{enumerable:!0,value:M.indexOf(`CONNECTING`)}),Object.defineProperty(P.prototype,`CONNECTING`,{enumerable:!0,value:M.indexOf(`CONNECTING`)}),Object.defineProperty(P,`OPEN`,{enumerable:!0,value:M.indexOf(`OPEN`)}),Object.defineProperty(P.prototype,`OPEN`,{enumerable:!0,value:M.indexOf(`OPEN`)}),Object.defineProperty(P,`CLOSING`,{enumerable:!0,value:M.indexOf(`CLOSING`)}),Object.defineProperty(P.prototype,`CLOSING`,{enumerable:!0,value:M.indexOf(`CLOSING`)}),Object.defineProperty(P,`CLOSED`,{enumerable:!0,value:M.indexOf(`CLOSED`)}),Object.defineProperty(P.prototype,`CLOSED`,{enumerable:!0,value:M.indexOf(`CLOSED`)}),[`binaryType`,`bufferedAmount`,`extensions`,`isPaused`,`protocol`,`readyState`,`url`].forEach(e=>{Object.defineProperty(P.prototype,e,{enumerable:!0})}),[`open`,`error`,`close`,`message`].forEach(e=>{Object.defineProperty(P.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[b])return t[x];return null},set(t){for(let t of this.listeners(e))if(t[b]){this.removeListener(e,t);break}typeof t==`function`&&this.addEventListener(e,t,{[b]:!0})}})}),P.prototype.addEventListener=T,P.prototype.removeEventListener=E,t.exports=P;function ee(e,t,n,a){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:_,protocolVersion:j[1],maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...a,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:`GET`,host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!j.includes(o.protocolVersion))throw RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${j.join(`, `)})`);let l;if(t instanceof d)l=t;else try{l=new d(t)}catch{throw SyntaxError(`Invalid URL: ${t}`)}l.protocol===`http:`?l.protocol=`ws:`:l.protocol===`https:`&&(l.protocol=`wss:`),e._url=l.href;let u=l.protocol===`wss:`,p=l.protocol===`ws+unix:`,m;if(l.protocol!==`ws:`&&!u&&!p?m=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:p&&!l.pathname?m=`The URL's pathname is empty`:l.hash&&(m=`The URL contains a fragment identifier`),m){let t=SyntaxError(m);if(e._redirects===0)throw t;F(e,t);return}let h=u?443:80,g=s(16).toString(`base64`),v=u?r.request:i.request,b=new Set,x;if(o.createConnection=o.createConnection||(u?ne:te),o.defaultPort=o.defaultPort||h,o.port=l.port||h,o.host=l.hostname.startsWith(`[`)?l.hostname.slice(1,-1):l.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":g,Connection:`Upgrade`,Upgrade:`websocket`},o.path=l.pathname+l.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(x=new f({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers[`Sec-WebSocket-Extensions`]=D({[f.extensionName]:x.offer()})),n.length){for(let e of n){if(typeof e!=`string`||!N.test(e)||b.has(e))throw SyntaxError(`An invalid or duplicated subprotocol was specified`);b.add(e)}o.headers[`Sec-WebSocket-Protocol`]=n.join(`,`)}if(o.origin&&(o.protocolVersion<13?o.headers[`Sec-WebSocket-Origin`]=o.origin:o.headers.Origin=o.origin),(l.username||l.password)&&(o.auth=`${l.username}:${l.password}`),p){let e=o.path.split(`:`);o.socketPath=e[0],o.path=e[1]}let S;if(o.followRedirects){if(e._redirects===0){e._originalIpc=p,e._originalSecure=u,e._originalHostOrSocketPath=p?o.socketPath:l.host;let t=a&&a.headers;if(a={...a,headers:{}},t)for(let[e,n]of Object.entries(t))a.headers[e.toLowerCase()]=n}else if(e.listenerCount(`redirect`)===0){let t=p?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:l.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!u)&&(delete o.headers.authorization,delete o.headers.cookie,t||delete o.headers.host,o.auth=void 0)}o.auth&&!a.headers.authorization&&(a.headers.authorization=`Basic `+Buffer.from(o.auth).toString(`base64`)),S=e._req=v(o),e._redirects&&e.emit(`redirect`,e.url,S)}else S=e._req=v(o);o.timeout&&S.on(`timeout`,()=>{I(e,S,`Opening handshake has timed out`)}),S.on(`error`,t=>{S===null||S[A]||(S=e._req=null,F(e,t))}),S.on(`response`,r=>{let i=r.headers.location,s=r.statusCode;if(i&&o.followRedirects&&s>=300&&s<400){if(++e._redirects>o.maxRedirects){I(e,S,`Maximum redirects exceeded`);return}S.abort();let r;try{r=new d(i,t)}catch{F(e,SyntaxError(`Invalid URL: ${i}`));return}ee(e,r,n,a)}else e.emit(`unexpected-response`,S,r)||I(e,S,`Unexpected server response: ${r.statusCode}`)}),S.on(`upgrade`,(t,n,r)=>{if(e.emit(`upgrade`,t),e.readyState!==P.CONNECTING)return;S=e._req=null;let i=t.headers.upgrade;if(i===void 0||i.toLowerCase()!==`websocket`){I(e,n,`Invalid Upgrade header`);return}let a=c(`sha1`).update(g+y).digest(`base64`);if(t.headers[`sec-websocket-accept`]!==a){I(e,n,`Invalid Sec-WebSocket-Accept header`);return}let s=t.headers[`sec-websocket-protocol`],l;if(s===void 0?b.size&&(l=`Server sent no subprotocol`):b.size?b.has(s)||(l=`Server sent an invalid subprotocol`):l=`Server sent a subprotocol but none was requested`,l){I(e,n,l);return}s&&(e._protocol=s);let u=t.headers[`sec-websocket-extensions`];if(u!==void 0){if(!x){I(e,n,`Server sent a Sec-WebSocket-Extensions header but no extension was requested`);return}let t;try{t=O(u)}catch{I(e,n,`Invalid Sec-WebSocket-Extensions header`);return}let r=Object.keys(t);if(r.length!==1||r[0]!==f.extensionName){I(e,n,`Server indicated an extension that was not requested`);return}try{x.accept(t[f.extensionName])}catch{I(e,n,`Invalid Sec-WebSocket-Extensions header`);return}e._extensions[f.extensionName]=x}e.setSocket(n,r,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,e):S.end()}function F(e,t){e._readyState=P.CLOSING,e._errorEmitted=!0,e.emit(`error`,t),e.emitClose()}function te(e){return e.path=e.socketPath,a.connect(e)}function ne(e){return e.path=void 0,!e.servername&&e.servername!==``&&(e.servername=a.isIP(e.host)?``:e.host),o.connect(e)}function I(e,t,n){e._readyState=P.CLOSING;let r=Error(n);Error.captureStackTrace(r,I),t.setHeader?(t[A]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(F,e,r)):(t.destroy(r),t.once(`error`,e.emit.bind(e,`error`)),t.once(`close`,e.emitClose.bind(e)))}function re(e,t,n){if(t){let n=h(t)?t.size:k(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${M[e.readyState]})`);process.nextTick(n,t)}}function ie(e,t){let n=this[C];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[C]!==void 0&&(n._socket.removeListener(`data`,de),process.nextTick(le,n._socket),e===1005?n.close():n.close(e,t))}function ae(){let e=this[C];e.isPaused||e._socket.resume()}function oe(e){let t=this[C];t._socket[C]!==void 0&&(t._socket.removeListener(`data`,de),process.nextTick(le,t._socket),t.close(e[S])),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e))}function se(){this[C].emitClose()}function ce(e,t){this[C].emit(`message`,e,t)}function L(e){let t=this[C];t._autoPong&&t.pong(e,!this._isServer,w),t.emit(`ping`,e)}function R(e){this[C].emit(`pong`,e)}function le(e){e.resume()}function ue(e){let t=this[C];t.readyState!==P.CLOSED&&(t.readyState===P.OPEN&&(t._readyState=P.CLOSING,z(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e)))}function z(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function V(){let e=this[C];if(this.removeListener(`close`,V),this.removeListener(`data`,de),this.removeListener(`end`,fe),e._readyState=P.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[C]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on(`error`,se),e._receiver.on(`finish`,se))}function de(e){this[C]._receiver.write(e)||this.pause()}function fe(){let e=this[C];e._readyState=P.CLOSING,e._receiver.end(),this.end()}function pe(){let e=this[C];this.removeListener(`error`,pe),this.on(`error`,w),e&&(e._readyState=P.CLOSING,this.destroy())}})),ri=R(((e,t)=>{ni();let{Duplex:n}=B(`stream`);function r(e){e.emit(`close`)}function i(){!this.destroyed&&this._writableState.finished&&this.destroy()}function a(e){this.removeListener(`error`,a),this.destroy(),this.listenerCount(`error`)===0&&this.emit(`error`,e)}function o(e,t){let o=!0,s=new n({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on(`message`,function(t,n){let r=!n&&s._readableState.objectMode?t.toString():t;s.push(r)||e.pause()}),e.once(`error`,function(e){s.destroyed||(o=!1,s.destroy(e))}),e.once(`close`,function(){s.destroyed||s.push(null)}),s._destroy=function(t,n){if(e.readyState===e.CLOSED){n(t),process.nextTick(r,s);return}let i=!1;e.once(`error`,function(e){i=!0,n(e)}),e.once(`close`,function(){i||n(t),process.nextTick(r,s)}),o&&e.terminate()},s._final=function(t){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._final(t)});return}e._socket!==null&&(e._socket._writableState.finished?(t(),s._readableState.endEmitted&&s.destroy()):(e._socket.once(`finish`,function(){t()}),e.close()))},s._read=function(){e.isPaused&&e.resume()},s._write=function(t,n,r){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._write(t,n,r)});return}e.send(t,r)},s.on(`end`,i),s.on(`error`,a),s}t.exports=o})),ii=R(((e,t)=>{let{tokenChars:n}=Zr();function r(e){let t=new Set,r=-1,i=-1,a=0;for(;a<e.length;a++){let o=e.charCodeAt(a);if(i===-1&&n[o]===1)r===-1&&(r=a);else if(a!==0&&(o===32||o===9))i===-1&&r!==-1&&(i=a);else if(o===44){if(r===-1)throw SyntaxError(`Unexpected character at index ${a}`);i===-1&&(i=a);let n=e.slice(r,i);if(t.has(n))throw SyntaxError(`The "${n}" subprotocol is duplicated`);t.add(n),r=i=-1}else throw SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||i!==-1)throw SyntaxError(`Unexpected end of input`);let o=e.slice(r,a);if(t.has(o))throw SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}t.exports={parse:r}})),ai=R(((e,t)=>{let n=B(`events`),r=B(`http`),{Duplex:i}=B(`stream`),{createHash:a}=B(`crypto`),o=ti(),s=Xr(),c=ii(),l=ni(),{CLOSE_TIMEOUT:u,GUID:d,kWebSocket:f}=qr(),p=/^[+/0-9A-Za-z]{22}==$/;t.exports=class extends n{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:u,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:l,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError(`One and only one of the "port", "server", or "noServer" options must be specified`);if(e.port==null?e.server&&(this._server=e.server):(this._server=r.createServer((e,t)=>{let n=r.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":`text/plain`}),t.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)),this._server){let e=this.emit.bind(this,`connection`);this._removeListeners=m(this._server,{listening:this.emit.bind(this,`listening`),error:this.emit.bind(this,`error`),upgrade:(t,n,r)=>{this.handleUpgrade(t,n,r,e)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error(`The server is operating in "noServer" mode`);return this._server?this._server.address():null}close(e){if(this._state===2){e&&this.once(`close`,()=>{e(Error(`The server is not running`))}),process.nextTick(h,this);return}if(e&&this.once(`close`,e),this._state!==1)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(h,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{h(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf(`?`);if((t===-1?e.url:e.url.slice(0,t))!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,r){t.on(`error`,g);let i=e.headers[`sec-websocket-key`],a=e.headers.upgrade,l=+e.headers[`sec-websocket-version`];if(e.method!==`GET`){v(this,e,t,405,`Invalid HTTP method`);return}if(a===void 0||a.toLowerCase()!==`websocket`){v(this,e,t,400,`Invalid Upgrade header`);return}if(i===void 0||!p.test(i)){v(this,e,t,400,`Missing or invalid Sec-WebSocket-Key header`);return}if(l!==13&&l!==8){v(this,e,t,400,`Missing or invalid Sec-WebSocket-Version header`,{"Sec-WebSocket-Version":`13, 8`});return}if(!this.shouldHandle(e)){_(t,400);return}let u=e.headers[`sec-websocket-protocol`],d=new Set;if(u!==void 0)try{d=c.parse(u)}catch{v(this,e,t,400,`Invalid Sec-WebSocket-Protocol header`);return}let f=e.headers[`sec-websocket-extensions`],m={};if(this.options.perMessageDeflate&&f!==void 0){let n=new s({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let e=o.parse(f);e[s.extensionName]&&(n.accept(e[s.extensionName]),m[s.extensionName]=n)}catch{v(this,e,t,400,`Invalid or unacceptable Sec-WebSocket-Extensions header`);return}}if(this.options.verifyClient){let a={origin:e.headers[`${l===8?`sec-websocket-origin`:`origin`}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(a,(a,o,s,c)=>{if(!a)return _(t,o||401,s,c);this.completeUpgrade(m,i,d,e,t,n,r)});return}if(!this.options.verifyClient(a))return _(t,401)}this.completeUpgrade(m,i,d,e,t,n,r)}completeUpgrade(e,t,n,r,i,c,l){if(!i.readable||!i.writable)return i.destroy();if(i[f])throw Error(`server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration`);if(this._state>0)return _(i,503);let u=[`HTTP/1.1 101 Switching Protocols`,`Upgrade: websocket`,`Connection: Upgrade`,`Sec-WebSocket-Accept: ${a(`sha1`).update(t+d).digest(`base64`)}`],p=new this.options.WebSocket(null,void 0,this.options);if(n.size){let e=this.options.handleProtocols?this.options.handleProtocols(n,r):n.values().next().value;e&&(u.push(`Sec-WebSocket-Protocol: ${e}`),p._protocol=e)}if(e[s.extensionName]){let t=e[s.extensionName].params,n=o.format({[s.extensionName]:[t]});u.push(`Sec-WebSocket-Extensions: ${n}`),p._extensions=e}this.emit(`headers`,u,r),i.write(u.concat(`\r
|
|
65
65
|
`).join(`\r
|
|
66
66
|
`)),i.removeListener(`error`,g),p.setSocket(i,c,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(p),p.on(`close`,()=>{this.clients.delete(p),this._shouldEmitClose&&!this.clients.size&&process.nextTick(h,this)})),l(p,r)}};function m(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let n of Object.keys(t))e.removeListener(n,t[n])}}function h(e){e._state=2,e.emit(`close`)}function g(){this.destroy()}function _(e,t,n,i){n||=r.STATUS_CODES[t],i={Connection:`close`,"Content-Type":`text/html`,"Content-Length":Buffer.byteLength(n),...i},e.once(`finish`,e.destroy),e.end(`HTTP/1.1 ${t} ${r.STATUS_CODES[t]}\r\n`+Object.keys(i).map(e=>`${e}: ${i[e]}`).join(`\r
|
|
67
67
|
`)+`\r
|
|
68
68
|
\r
|
|
69
|
-
`+n)}function v(e,t,n,r,i,a){if(e.listenerCount(`wsClientError`)){let r=Error(i);Error.captureStackTrace(r,v),e.emit(`wsClientError`,r,n,t)}else _(n,r,i,a)}}));ei(),Qr(),qr(),Yr(),Xr(),ti();var ri=le($r(),1);ni();function ii(e){if(!(e instanceof Error))return e;let t=e;return{...Object.keys(e).reduce((e,n)=>(e[n]=t[n],e),{}),name:e.name,message:e.message,stack:e.stack}}function ai(e){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e,n=Error(typeof t.message==`string`?t.message:String(e));return typeof t.name==`string`&&t.name&&(n.name=t.name),typeof t.stack==`string`&&t.stack&&(n.stack=t.stack),Object.assign(n,e),n}return Error(String(e))}var oi=class e{static nextId=0;id;sequenceNumber=1;awaitingPromises={};sendAcknowledgement=!0;remoteApiAcknowledgement=!0;inboundApi;_api;_originalProcessMessageReceived;constructor(t,n){this.properties=n;let r=this;this.id=e.nextId++,this._api=new Proxy({},{get:function(e,t){return async(...e)=>await r.sendInternal({method:t,args:e})}}),this.inboundApi=t(this)}get api(){return this._api}async processMethod(e,t,n){n?this.sendAcknowledgement&&e.sequenceNumber&&this.sendMessage({sequenceNumber:e.sequenceNumber,error:ii(n)}):this.sendAcknowledgement&&e.sequenceNumber&&this.sendMessage({sequenceNumber:e.sequenceNumber,result:{value:t}})}async processResult(e,t,n,r){t(r)}async processError(e,t,n,r){n(ai(r))}async processMessageReceived(e){if(e.method)try{let t=await this.inboundApi[e.method].apply(this.inboundApi,e.args);await this.processMethod(e,t,void 0)}catch(t){t||=Error(`An unknown error occurred`),await this.processMethod(e,void 0,t)}else if(e.result){let{sequenceNumber:t,result:n}=e;if(this.awaitingPromises[t]){let{resolve:r,reject:i}=this.awaitingPromises[t];delete this.awaitingPromises[t],r&&n&&await this.processResult(e,r,i,n.value)}}else if(e.error){let{sequenceNumber:t,error:n}=e;if(this.awaitingPromises[t]){let{resolve:r,reject:i}=this.awaitingPromises[t];delete this.awaitingPromises[t],r&&i&&await this.processError(e,r,i,n)}}}rejectAwaitingPromises(e){Object.values(this.awaitingPromises).forEach(({reject:t})=>t(e))}async onMessageReceived(e){this.processMessageReceived(e)}async sendInternal(e){if(this.remoteApiAcknowledgement&&(this.remoteApiAcknowledgement===!0||this.remoteApiAcknowledgement(e)))return e.sequenceNumber=this.sequenceNumber++,await new Promise(async(t,n)=>{this.awaitingPromises[e.sequenceNumber]={resolve:t,reject:n};try{await this.sendMessage(e)}catch(t){delete this.awaitingPromises[e.sequenceNumber],n(t)}});try{await this.sendMessage(e)}catch{}}dispose(){this.onDisposeListeners.map(e=>e()),this.onDisposeListeners=[],this.onConnectedListeners=[],this.onVersionMismatchListeners=[],this.rejectAwaitingPromises(Error(`Channel disposed`))}onConnectedListeners=[];subscribeOnConnected(e){this.onConnectedListeners.push(e)}unsubscribeOnConnected(e){this.onConnectedListeners=this.onConnectedListeners.filter(t=>t!==e)}connected(){this.onConnectedListeners.map(e=>e()),this.onConnectedListeners=[]}onVersionMismatchListeners=[];subscribeOnVersionMismatch(e){this.onVersionMismatchListeners.push(e)}unsubscribeOnVersionMismatch(e){this.onVersionMismatchListeners=this.onVersionMismatchListeners.filter(t=>t!==e)}versionMismatch(e,t){this.onVersionMismatchListeners.map(n=>n(e,t))}onDisposeListeners=[];subscribeOnDispose(e){this.onDisposeListeners.push(e)}unsubscribeOnDispose(e){this.onDisposeListeners=this.onDisposeListeners.filter(t=>t!==e)}replaceReceiver(e){this._originalProcessMessageReceived||=this.processMessageReceived;let t=e.allowedCalls;this.processMessageReceived=n=>{if(e.filter(n)){if(t<=0)return e.replacement(n);t--}return this._originalProcessMessageReceived.bind(this)(n)}}restoreReceiver(){this.processMessageReceived=(this._originalProcessMessageReceived||this.processMessageReceived).bind(this),delete this._originalProcessMessageReceived}},si=class{_channels=[];get channels(){return[...this._channels]}constructor(e,t){this.inboundApiFactory=e,this.channelBaseConstructor=t}createChannel(e){let t=new this.channelBaseConstructor(this.inboundApiFactory,e);return this._channels.push(t),t.connected(),t}destroyChannel(e){let t=this._channels.indexOf(e);t!==-1&&this._channels.splice(t,1)[0].dispose()}dispose(){this.channels.map(e=>this.destroyChannel(e))}};function ci(e){return e instanceof Error?e.message:String(e)}function li(e){return e instanceof Error?e.toString():String(e)}function ui(e){return e instanceof Error?e:Error(String(e))}var di=class extends oi{remoteApiAcknowledgement;_disposed=!1;_version=``;_onChannelError=()=>{};setOptions(e,t){this._onChannelError=e,this._version=t}constructor(e,t){super(e,t),this.properties=t,this.remoteApiAcknowledgement=t.remoteApiAcknowledgement}async sendMessage(e){if(this._disposed){this._onChannelError(Error(`Channel has been disposed`));return}try{this._version&&typeof e==`object`&&e&&(e.version=this._version);let t=JSON.stringify(e);if(t===void 0)throw TypeError(`Failed to serialize RPC message`);this.properties.socket.send(t,e=>{e&&this.properties.logger.trace(`send callback error:%s`,ci(e))})}catch(e){throw this.properties.logger.trace(`failed to send message: %s`,ci(e)),e}}async processMethod(e,t,n){await super.processMethod(e,t,n)}async processError(e,t,n,r){r&&this.properties.logger.trace(`error processing message: %s, %s`,e,li(r)),await super.processError(e,t,n,r)}async processMessageReceived(e){e.method&&this.properties.logger.trace(`received method call: %s`,e.method),await super.processMessageReceived(e)}dispose(){if(this._disposed=!0,super.dispose(),!this.properties.socket.CLOSED)try{this.properties.socket.close()}catch{}}};function fi(e,t,n){e.on(`message`,e=>{try{t(JSON.parse(e.toString()))}catch(e){n(ui(e))}})}function pi(e,t,n,r){let{secure:i,host:a,port:o,secret:s,onError:c,onClose:l}=e,u={};e.from&&(u.headers={from:e.from});let d=i?`wss://`:`ws://`,f=o?`:${o}`:``,p=s?`?secret=${s}`:``,m=new ri.default(d+(a||`localhost`)+f+p,u);return n&&fi(m,n,e=>{r.trace(`incoming message processing error: %s`,e?.message)}),m.onclose=({code:e,reason:t})=>{r.trace(`client disconnected: %s %s`,e,t);try{l&&l(m,e,t?.toString())}catch(e){r.trace(`error when closing connection: %s`,ci(e))}},m.onerror=e=>{try{r.trace(`connection error: %s`,e.error),c&&c(e.error)}catch(e){r.trace(`error when processing connection error: %s`,ci(e))}},m.onopen=()=>{t()},m}var mi=class extends si{_socket;constructor(e,t){super(t,di),e.onChannelError||=e=>{this.channels.forEach(t=>{t.rejectAwaitingPromises(e),this.destroyChannel(t)})},e.onError||=e=>{this.channels.forEach(t=>{t.rejectAwaitingPromises(e),this.destroyChannel(t)})},e.onClose||=(e,t,n)=>{this.channels.forEach(e=>{e.rejectAwaitingPromises(Error(`WebSocket closed with code ${t} and reason ${n}`)),this.destroyChannel(e)})},this._socket=pi(e,()=>{this.createChannel({socket:this._socket,remoteApiAcknowledgement:!0,logger:e.logger}).setOptions(e.onChannelError,e.version)},e=>{this.channels.forEach(t=>{t.onMessageReceived(e)})},e.logger)}dispose(){this._socket?.close(),super.dispose()}};const hi=K.create(`core/session`);var gi=class{_client;_alive=vi();_api;_disposed=!1;_deactivated=!1;_interrupted=!1;constructor(e,t){this._client=e,this._api=t(()=>this._client.channels)}get alive(){return this._alive.promise}get api(){return this._api}deactivate(){this._deactivated=!0}interrupt(e){if(!this._interrupted){if(this._interrupted=!0,this._deactivated||this._disposed){this._alive.resolve();return}this._alive.reject(e)}}dispose(){this._disposed||(this._disposed=!0,this._interrupted||(this._interrupted=!0,this._alive.resolve()),this._client.dispose())}};async function _i(e,t,n){let r=!1,i=!1,a,o=vi(),s=e=>{if(!r){r=!0,o.reject(e);return}i&&a.interrupt(e)};a=new gi(new mi({port:e,from:`cli`,logger:{trace:(...e)=>{let[t,n,...r]=e;if(typeof t==`string`){hi.trace(F(t,n,...r));return}if(typeof n==`string`||n===void 0){hi.trace(t,n,...r);return}hi.trace({args:e},`Websocket`)}},version:`1.0.0`,onError:e=>{hi.debug({error:e},`Socket error`),s(e)},onChannelError:e=>{hi.debug({error:e},`Channel error`),s(e)},onClose:(e,t,n)=>{hi.debug({code:t,reason:n},`Socket closed`),s(Error(`Socket closed with code ${t} and reason: ${n}`))}},n=>(n.subscribeOnConnected(async()=>{r||(i=!0,r=!0,hi.debug({port:e},`Connected`),o.resolve())}),t)),n);try{return await o.promise,a}catch(e){throw a.dispose(),e}}function vi(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const yi=new Pr;var bi=class{_logger=K.create(`commands/run/incoming`);constructor(e,t,n){this._options=e,this._path=t,this._restart=n}ping(){}notify(e){}restart(){this._logger.info(`Restart requested`),this._restart()}launched(e){this._logger.info({port:e},`UI launched`)}relicensed(){this._logger.info(`Relicensed`),this._path&&(yi.stop(),yi.check(this._path,this._options.ssl))}stopped(e){}},xi=class{constructor(e){this._channels=e}get _channel(){let[e]=this._channels();if(!e)throw Error(`Core RPC channel is not available`);return e}handshake(e){return this._channel.api.handshake(e)}signal(e){this._channel.api.signal(e)}run(e){return this._channel.api.run(e)}export(e){return this._channel.api.export(e)}},Si=class{_logger=K.create(`commands/run`);async execute(e){this._logger.info({cwd:k(),options:e},`Executing run command`);let t=await this._execute(e);return this._logger.info({result:t},`Executed run command`),t}async _execute(e){let t=await this._cycle(e);return t?`restarted`in t?(this._logger.info(`Restarting process`),await this._execute(e)):(console.info(t.message),t.success):!1}async _cycle(e){let t=!1,n=!1,r,i,a,o=()=>{t=!0},s=await this._attach(e,()=>new bi(e,void 0,()=>{n||r!==void 0||(n=!0,o())}),e=>new xi(e));if(!s)return await this._launch(e);let{manifest:c,session:l}=s;this._logger.info({id:c.id,pid:c.pids.primary,port:c.ports.primary},`Connected to active process from registry`),o=()=>{t||(t=!0,l.deactivate())};let u=this._run(l,e).then(async()=>await l.api.export({format:`llm`})).then(e=>{n||r!==void 0||(r=e,o())}).catch(e=>{n||t||(i=e,o())}),d=l.alive.catch(e=>{t||(a=e,o())});try{await u}finally{o(),l.dispose(),await d}if(n)return{restarted:!0};if(a)throw a;if(i)throw i;return r}async _launch(e){let t=await Br({...e,skill:!0,smart:e.smart||e.paths.length>0},new Nr,yi),n=t.exited(),r=await Promise.race([t.ready,n.then(()=>void 0)]);if(r===void 0)return;let i,a,o,s,c,l=!1,u=!1,d=!1,f,p,m,h,g=()=>(h?.(),p||(p=t.stop(),p.catch(()=>{})),p);try{m=await _i(r,new bi(e,t.location.path,()=>{u||c!==void 0||(u=!0,g())}),e=>new xi(e)),yi.restarter={restart(e){m.api.signal({type:`update`,version:e})}},h=()=>{l||(l=!0,m.deactivate())}}catch(e){try{await t.stop(),await n}catch(e){this._logger.warn({error:e},`Failed to stop process after connection failure`)}throw e}t.stopping.then(()=>{h?.()}),f=this._run(m,e).then(async()=>await m.api.export({format:`llm`})).then(t=>{if(!(u||c!==void 0)){if(c=t,e.exit)return g();d=!0,h?.()}}).catch(async e=>{if(!(u||l)){o=e;try{await g()}catch(e){this._logger.warn({error:e},`Failed to stop process after run/export failure`)}}});let _=m.alive.catch(async e=>{if(!l){a=e;try{await g()}catch(e){this._logger.warn({error:e},`Failed to stop process after connection loss`)}}});try{if(f&&await f,d&&t.release(),!d)try{await n}catch(e){i=e}}finally{if(yi.restarter=void 0,m.dispose(),await _,p)try{await p}catch(e){s=e}}if(s)throw s;if(u)return{restarted:!0};if(i)throw i;if(a)throw a;if(o)throw o;if(c)return c}async _attach(e,t,n){if(e.new)return;let r=this._find(e);if(r.length===0)return;let i=await this._connect(r,t,n);if(i)return i;throw Error(`Failed to attach to active Wallaby instance for the specified config.`)}async _connect([e,...t],n,r){if(e){this._logger.info({id:e.id,pid:e.pids.primary,port:e.ports.primary},`Trying to connect to active process from registry`);try{return{manifest:e,session:await _i(e.ports.primary,n(e),r)}}catch(i){return this._logger.warn({error:i,id:e.id,pid:e.pids.primary,port:e.ports.primary},`Failed to connect to active process from registry`),await this._connect(t,n,r)}}}async _run(e,t){await e.api.run({paths:t.paths})}_find(e){let t=cn(s(e.config?e.config:i(k(),`auto.detect`)));return new Ur().manifests.filter(e=>e.paths.config===t).sort((e,t)=>t.timestamps.refreshed-e.timestamps.refreshed).filter(e=>{try{return process.kill(e.pids.primary,0),!0}catch(e){return(typeof e==`object`&&e&&`code`in e?e.code:void 0)===`EPERM`}})}},Ci=z(((e,t)=>{t.exports=a,a.sync=o;var n=B(`fs`);function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}})),wi=z(((e,t)=>{t.exports=r,r.sync=i;var n=B(`fs`);function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),Ti=z(((e,t)=>{B(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?Ci():wi();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),Ei=z(((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=B(`path`),i=n?`;`:`:`,a=Ti(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}})),Di=z(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),Oi=z(((e,t)=>{let n=B(`path`),r=Ei(),i=Di();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o})),ki=z(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),Ai=z(((e,t)=>{t.exports=/^#!(.*)/})),ji=z(((e,t)=>{let n=Ai();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),Mi=z(((e,t)=>{let n=B(`fs`),r=ji();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i})),Ni=z(((e,t)=>{let n=B(`path`),r=Oi(),i=ki(),a=Mi(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d})),Pi=z(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),Fi=z(((e,t)=>{let n=B(`child_process`),r=Ni(),i=Pi();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i}));function Ii(){try{return d.statSync(`/.dockerenv`),!0}catch{return!1}}function Li(){try{return d.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`docker`)}catch{return!1}}function Ri(){return zi===void 0&&(zi=Ii()||Li()),zi}var zi,Bi=R((()=>{}));function Vi(){return Hi===void 0&&(Hi=Ui()||Ri()),Hi}var Hi,Ui,Wi=R((()=>{Bi(),Ui=()=>{try{return d.statSync(`/run/.containerenv`),!0}catch{return!1}}})),Gi,Ki,qi=R((()=>{Wi(),Gi=()=>{if(O.platform!==`linux`)return!1;if(c.release().toLowerCase().includes(`microsoft`))return!Vi();try{if(d.readFileSync(`/proc/version`,`utf8`).toLowerCase().includes(`microsoft`))return!Vi()}catch{}return d.existsSync(`/proc/sys/fs/binfmt_misc/WSLInterop`)||d.existsSync(`/run/WSL`)?!Vi():!1},Ki=O.env.__IS_WSL_TEST__?Gi:Gi()})),Ji,Yi,Xi,Zi=R((()=>{qi(),Ji=(()=>{let e=`/mnt/`,t;return async function(){if(t)return t;let n=`/etc/wsl.conf`,r=!1;try{await v.access(n,y.F_OK),r=!0}catch{}if(!r)return e;let i=await v.readFile(n,{encoding:`utf8`}),a=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(i);return a?(t=a.groups.mountPoint.trim(),t=t.endsWith(`/`)?t:`${t}/`,t):e}})(),Yi=async()=>`${await Ji()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,Xi=async()=>Ki?Yi():`${O.env.SYSTEMROOT||O.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`}));function Qi(e,t,n){let r=n=>Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let e=n();return r(e),e},set(e){r(e)}}),e}var $i=R((()=>{}));async function ea(){if(O.platform!==`darwin`)throw Error(`macOS only`);let{stdout:e}=await ta(`defaults`,[`read`,`com.apple.LaunchServices/com.apple.launchservices.secure`,`LSHandlers`]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??`com.apple.Safari`;return t===`com.apple.safari`?`com.apple.Safari`:t}var ta,na=R((()=>{ta=I(P)}));async function ra(e,{humanReadableOutput:t=!0,signal:n}={}){if(O.platform!==`darwin`)throw Error(`macOS only`);let r=t?[]:[`-ss`],i={};n&&(i.signal=n);let{stdout:a}=await ia(`osascript`,[`-e`,e,r],i);return a.trim()}var ia,aa=R((()=>{ia=I(P)}));async function oa(e){return ra(`tell application "Finder" to set app_path to application file id "${e}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var sa=R((()=>{aa()}));async function ca(e=la){let{stdout:t}=await e(`reg`,[`QUERY`,` HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice`,`/v`,`ProgId`]),n=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!n)throw new da(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:r}=n.groups,i=r.lastIndexOf(`.`),a=r.lastIndexOf(`-`),o=i===-1?void 0:r.slice(0,i),s=a===-1?void 0:r.slice(0,a);return ua[r]??ua[o]??ua[s]??{name:r,id:r}}var la,ua,da,fa=R((()=>{la=I(P),ua={MSEdgeHTM:{name:`Edge`,id:`com.microsoft.edge`},MSEdgeBHTML:{name:`Edge Beta`,id:`com.microsoft.edge.beta`},MSEdgeDHTML:{name:`Edge Dev`,id:`com.microsoft.edge.dev`},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:`Edge`,id:`com.microsoft.edge.old`},ChromeHTML:{name:`Chrome`,id:`com.google.chrome`},ChromeBHTML:{name:`Chrome Beta`,id:`com.google.chrome.beta`},ChromeDHTML:{name:`Chrome Dev`,id:`com.google.chrome.dev`},ChromiumHTM:{name:`Chromium`,id:`org.chromium.Chromium`},BraveHTML:{name:`Brave`,id:`com.brave.Browser`},BraveBHTML:{name:`Brave Beta`,id:`com.brave.Browser.beta`},BraveDHTML:{name:`Brave Dev`,id:`com.brave.Browser.dev`},BraveSSHTM:{name:`Brave Nightly`,id:`com.brave.Browser.nightly`},FirefoxURL:{name:`Firefox`,id:`org.mozilla.firefox`},OperaStable:{name:`Opera`,id:`com.operasoftware.Opera`},VivaldiHTM:{name:`Vivaldi`,id:`com.vivaldi.Vivaldi`},"IE.HTTP":{name:`Internet Explorer`,id:`com.microsoft.ie`}},new Map(Object.entries(ua)),da=class extends Error{}}));async function pa(){if(O.platform===`darwin`){let e=await ea();return{name:await oa(e),id:e}}if(O.platform===`linux`){let{stdout:e}=await ma(`xdg-mime`,[`query`,`default`,`x-scheme-handler/http`]),t=e.trim();return{name:ha(t.replace(/.desktop$/,``).replace(`-`,` `)),id:t}}if(O.platform===`win32`)return ca();throw Error(`Only macOS, Linux, and Windows are supported`)}var ma,ha,ga=R((()=>{na(),sa(),fa(),ma=I(P),ha=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase())})),_a=se({apps:()=>Aa,default:()=>Oa,openApp:()=>ka});async function va(){let e=await Xi(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:n}=await xa(e,[`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`,te.from(t,`utf16le`).toString(`base64`)],{encoding:`utf8`}),r=n.trim(),i={ChromeHTML:`com.google.chrome`,BraveHTML:`com.brave.Browser`,MSEdgeHTM:`com.microsoft.edge`,FirefoxURL:`org.mozilla.firefox`};return i[r]?{id:i[r]}:{}}function ya(e){if(typeof e==`string`||Array.isArray(e))return e;let{[Ta]:t}=e;if(!t)throw Error(`${Ta} is not supported`);return t}function ba({[wa]:e},{wsl:t}){if(t&&Ki)return ya(t);if(!e)throw Error(`${wa} is not supported`);return ya(e)}var xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja=R((()=>{Zi(),$i(),ga(),Wi(),xa=I(M.execFile),Sa=t.dirname(_(import.meta.url)),Ca=t.join(Sa,`xdg-open`),{platform:wa,arch:Ta}=O,Ea=async(e,t)=>{let n;for(let r of e)try{return await t(r)}catch(e){n=e}throw n},Da=async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return Ea(e.app,t=>Da({...e,app:t}));let{name:t,arguments:n=[]}=e.app??{};if(n=[...n],Array.isArray(t))return Ea(t,t=>Da({...e,app:{name:t,arguments:n}}));if(t===`browser`||t===`browserPrivate`){let r={"com.google.chrome":`chrome`,"google-chrome.desktop":`chrome`,"com.brave.Browser":`brave`,"org.mozilla.firefox":`firefox`,"firefox.desktop":`firefox`,"com.microsoft.msedge":`edge`,"com.microsoft.edge":`edge`,"com.microsoft.edgemac":`edge`,"microsoft-edge.desktop":`edge`},i={chrome:`--incognito`,brave:`--incognito`,firefox:`--private-window`,edge:`--inPrivate`},a=Ki?await va():await pa();if(a.id in r){let o=r[a.id];return t===`browserPrivate`&&n.push(i[o]),Da({...e,app:{name:Aa[o],arguments:n}})}throw Error(`${a.name} is not supported as a default browser`)}let r,i=[],a={};if(wa===`darwin`)r=`open`,e.wait&&i.push(`--wait-apps`),e.background&&i.push(`--background`),e.newInstance&&i.push(`--new`),t&&i.push(`-a`,t);else if(wa===`win32`||Ki&&!Vi()&&!t){r=await Xi(),i.push(`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`),Ki||(a.windowsVerbatimArguments=!0);let o=[`Start`];e.wait&&o.push(`-Wait`),t?(o.push(`"\`"${t}\`""`),e.target&&n.push(e.target)):e.target&&o.push(`"${e.target}"`),n.length>0&&(n=n.map(e=>`"\`"${e}\`""`),o.push(`-ArgumentList`,n.join(`,`))),e.target=te.from(o.join(` `),`utf16le`).toString(`base64`)}else{if(t)r=t;else{let e=!Sa||Sa===`/`,t=!1;try{await v.access(Ca,y.X_OK),t=!0}catch{}r=O.versions.electron??(wa===`android`||e||!t)?`xdg-open`:Ca}n.length>0&&i.push(...n),e.wait||(a.stdio=`ignore`,a.detached=!0)}wa===`darwin`&&n.length>0&&i.push(`--args`,...n),e.target&&i.push(e.target);let o=M.spawn(r,i,a);return e.wait?new Promise((t,n)=>{o.once(`error`,n),o.once(`close`,r=>{if(!e.allowNonzeroExitCode&&r>0){n(Error(`Exited with code ${r}`));return}t(o)})}):(o.unref(),o)},Oa=(e,t)=>{if(typeof e!=`string`)throw TypeError("Expected a `target`");return Da({...t,target:e})},ka=(e,t)=>{if(typeof e!=`string`&&!Array.isArray(e))throw TypeError("Expected a valid `name`");let{arguments:n=[]}=t??{};if(n!=null&&!Array.isArray(n))throw TypeError("Expected `appArguments` as Array type");return Da({...t,app:{name:e,arguments:n}})},Aa={},Qi(Aa,`chrome`,()=>ba({darwin:`google chrome`,win32:`chrome`,linux:[`google-chrome`,`google-chrome-stable`,`chromium`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`,x64:[`/mnt/c/Program Files/Google/Chrome/Application/chrome.exe`,`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`]}})),Qi(Aa,`brave`,()=>ba({darwin:`brave browser`,win32:`brave`,linux:[`brave-browser`,`brave`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`,x64:[`/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe`,`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`]}})),Qi(Aa,`firefox`,()=>ba({darwin:`firefox`,win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:`firefox`},{wsl:`/mnt/c/Program Files/Mozilla Firefox/firefox.exe`})),Qi(Aa,`edge`,()=>ba({darwin:`microsoft edge`,win32:`msedge`,linux:[`microsoft-edge`,`microsoft-edge-dev`]},{wsl:`/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`})),Qi(Aa,`browser`,()=>`browser`),Qi(Aa,`browserPrivate`,()=>`browserPrivate`)})),Ma=le(Fi(),1);const $=K.create(`browser`);function Na(e){let t=process.env.BROWSER||``;$.info({url:e,browser:t||`default`},`Opening browser`),t.toLowerCase().endsWith(`.js`)?Fa(t,e):t.toLowerCase()===`none`?$.debug({url:e},`Browser auto-open disabled by environment`):La(t,process.env.BROWSER_ARGS?process.env.BROWSER_ARGS.split(` `):[],e)}function Pa(e,t){return new Promise((n,r)=>{$.debug({command:e,cwd:t?.cwd},`Executing shell command`),N(e,t,(i,a)=>{i?($.error({err:i,command:e,cwd:t?.cwd},`Shell command failed`),r(i)):($.debug({command:e,cwd:t?.cwd},`Shell command completed`),n(a.toString()))})})}function Fa(e,t){let n=process.argv.slice(2);$.debug({scriptPath:e,url:t,extraArgs:n},`Launching browser script`);let r=(0,Ma.default)(process.execPath,[e,...n,t],{stdio:`inherit`});r.on(`error`,n=>{$.error({err:n,scriptPath:e,url:t},`Browser script process failed to start`)}),r.on(`close`,n=>{n===0?$.debug({scriptPath:e,url:t},`Browser script completed successfully`):($.warn({code:n,scriptPath:e,url:t},`Browser script exited with a non-zero status`),process.stdout.write(G.default.red(`\nThe script specified as BROWSER environment variable failed.\n\n${G.default.cyan(e)} exited with code ${n}.`)))})}const Ia=[`Google Chrome Canary`,`Google Chrome Dev`,`Google Chrome Beta`,`Google Chrome`,`Microsoft Edge`,`Brave Browser`,`Vivaldi`,`Chromium`];async function La(e,t,n){let r=e===`google chrome`?`Google Chrome`:e,i=process.platform===`darwin`&&(!r||Ia.includes(r));if($.debug({browser:r,browserArgs:t,url:n},`Starting browser process`),i)try{let e=await Pa(`ps cax`),t=r&&e.includes(r)?r:Ia.find(t=>e.includes(t));if(t)return await Pa(`osascript openChrome.applescript "${encodeURI(n)}" "${t}"`,{cwd:X.paths.dirs.package.bin}),$.debug({openedBrowser:t,url:n},`Opened browser via AppleScript`),!0}catch(e){$.debug({err:e,url:n},`AppleScript browser reuse attempt failed`)}process.platform===`darwin`&&e===`open`&&(e=void 0);try{let r=e?{app:{name:e,arguments:t}}:{},i;try{i=(await Promise.resolve().then(()=>(ja(),_a))).default}catch(e){$.error({err:e},`Failed to import browser opener`)}if(i)try{let t=await i(n,r);$.debug({url:n,browser:e||`default`},`Opened browser with open package`),t.on(`error`,e=>{$.error({err:e,url:n},`Browser subprocess reported an error`),process.stderr.write(e.stack||e.message)})}catch(e){$.error({err:e,url:n},`Failed to open browser`),process.stderr.write(e instanceof Error?e.stack||e.message:String(e))}else $.warn({url:n},`Browser opener module was unavailable`);return!0}catch(t){return $.warn({err:t,url:n,browser:e||`default`},`Browser launch failed`),!1}}const Ra=K.create(`core/notifications`);function za(e,t){if(!t.text){Ra.trace({type:t.type},`Skipping empty notification`);return}Ra.debug({type:t.type,button:!!t.button},`Received notification from core`);let n=[];if(~t.text.indexOf(`expire`)&&t.type===`warning`&&e.notifications===!1){Ra.trace({type:t.type},`Suppressed expiration notification`);return}let r=`http://localhost:${e.port}`;~t.text.indexOf(`activate-link`)&&e.port&&n.push({title:`Enter License`,url:r}),~t.text.indexOf(`continue-trial-link`)&&e.port&&n.push({title:`Continue Trial`,url:r}),t.button&&n.push({title:t.button.label,url:t.button.link}),t.text=t.text.replace(/<br\/><br\/>/g,` `).replace(/<br\/>/g,` `).replace(/<a\s+(?:[^>]*?\s+)?href=['"]([^'"]*)['"]/g,(e,t)=>(t.startsWith(`http`)&&n.push({url:t}),e)).replace(/<[^>]*>/g,``);let i=t.type===`error`?G.default.red:t.type===`warning`?G.default.yellow:G.default.green;if(process.stdout.write(i(`\n ⚑ ${t.text}\n\n`)),n.length)for(let e of n)process.stdout.write(`${G.default.green(` ➜ `)}${G.default.bold(G.default.yellow(e.title?e.title+`: `:``))}${G.default.cyan(e.url)}\n`);Ra.trace({links:n},`Rendered notification links`)}const Ba=new Pr;var Va=class{_logger=K.create(`commands/start/incoming`);_port;constructor(e,t,n,r){this._options=e,this._path=t,this._version=n,this._restart=r}ping(){}notify(e){za({notifications:this._options.notifications,port:this._port,ui:this._options.ui},e)}restart(){this._logger.info(`Restart requested`),this._restart()}launched(e){this._logger.info({port:e},`UI launched`),this._port=e;let t=`http://localhost:${e}`;process.stdout.write(G.default.green(` ${G.default.bold(`WALLABY CORE`)}${this._version?` v${this._version}`:``}\n`)),process.stdout.write(`${G.default.green(` ➜ `)}${G.default.bold(G.default.yellow(`UI:`))} ${G.default.cyan(t)}\n`),process.stdout.write(`${G.default.green(` ➜ `)}${G.default.bold(G.default.dim(`Docs:`))} ${G.default.cyan(`https://wallabyjs.com/docs`)}\n`),this._options.ui!==!1&&Na(t)}relicensed(){this._logger.info(`Relicensed`),this._path&&(Ba.stop(),Ba.check(this._path,this._options.ssl))}stopped(e){}},Ha=class{constructor(e){this._channels=e}get _channel(){let[e]=this._channels();if(!e)throw Error(`Core RPC channel is not available`);return e}handshake(e){return this._channel.api.handshake(e)}signal(e){this._channel.api.signal(e)}run(e){return this._channel.api.run(e)}export(e){return this._channel.api.export(e)}},Ua=class{_logger=K.create(`commands/start`);async execute(e){this._logger.info({cwd:k(),options:e},`Executing start command`);let t=await this._execute(e);return this._logger.info({result:t},`Executed start command`),t}async _execute(e){return await this._cycle(e)?(this._logger.info(`Restarting process`),await this._execute(e)):!0}async _cycle(e){if(!e.force){let t=this._find(e)[0];if(t)return this._logger.info({id:t.id,pid:t.pids.primary,port:t.ports.primary},`Active process is already running for the specified config`),console.warn(`Wallaby Core is already started.`),!1}let t=await Br({...e,smart:e.smart||e.paths.length>0},new Nr,Ba),n=t.exited(),r=await Promise.race([t.ready,n.then(()=>void 0)]);if(r===void 0)return!1;let i,a,o,s,c=!1,l,u,d=()=>(l||(l=t.stop(),l.catch(()=>{})),l);try{u=await _i(r,new Va(e,t.location.path,t.version,()=>{c||(c=!0,d())}),e=>new Ha(e)),Ba.restarter={restart(e){u.api.signal({type:`update`,version:e})}}}catch(e){try{await t.stop(),await n}catch(e){this._logger.warn({error:e},`Failed to stop process after connection failure`)}throw e}t.stopping.then(()=>u.deactivate());let f=u.alive.catch(async e=>{a=e;try{await d()}catch(e){this._logger.warn({error:e},`Failed to stop process after connection loss`)}});try{await this._handshake(u),t.location.type===`dist`&&Ba.schedule(t.location.path,e.ssl),await this._run(u,e).catch(async e=>{if(!c){o=e;try{await d()}catch(e){this._logger.warn({error:e},`Failed to stop process after run failure`)}}}),await n}catch(e){if(i=e,!c)try{await d(),await n.catch(()=>{})}catch(e){this._logger.warn({error:e},`Failed to stop process after startup failure`)}}finally{if(Ba.restarter=void 0,u.dispose(),await f,l)try{await l}catch(e){s=e}}if(s)throw s;if(i)throw i;if(o)throw o;if(a&&!(a instanceof Error&&a.message.startsWith(`Socket closed with code 1006 and reason:`)))throw a;return c}async _run(e,t){t.paths.length!==0&&await e.api.run({paths:t.paths})}async _handshake(e){let t=await e.api.handshake(X.version);if(!t.compatible)throw Error(t.message||`Wallaby CLI v${X.version} is not compatible with the running Wallaby Core.`)}_find(e){let t=cn(s(e.config?e.config:i(k(),`auto.detect`)));return new Ur().manifests.filter(e=>e.paths.config===t).sort((e,t)=>t.timestamps.refreshed-e.timestamps.refreshed).filter(e=>{try{return process.kill(e.pids.primary,0),!0}catch(e){return(typeof e==`object`&&e&&`code`in e?e.code:void 0)===`EPERM`}})}},Wa=class{_logger=K.create(`commands/stop`);async execute(e){this._logger.info({cwd:k(),options:e},`Executing stop command`);let t=cn(s(e.config?e.config:i(k(),`auto.detect`)));this._logger.info({config:t},`Determined config path and config directory`);let n=new Ur().manifests.filter(n=>e.all?!0:e.config?n.paths.config===t:r(n.paths.config)===r(t));if(n.length!==0)for(let e of n)this._stop(e);else this._logger.info(`No running processes matched stop criteria`);this._logger.info({count:n.length},`Executed stop command`)}_stop(e){this._logger.info({id:e.id,pid:e.pids.primary,config:e.paths.config},`Stopping process from registry`);try{process.kill(e.pids.primary,`SIGTERM`)}catch(e){this._logger.info({error:e},`Failed to send SIGTERM to process, it may have already stopped`)}this._logger.info({id:e.id,pid:e.pids.primary},`Stopped process from registry`)}};K.initialize({path:i(X.paths.dirs.current,`logs`,`wallaby-cli.log`)});const Ga=K.create(`cli`);async function Ka(){Ga.trace({argv:process.argv.slice(2),version:X.version},`Parsing CLI arguments`);let e=ht(process.argv,X.version);if(e){if(await W.default.ensureDir(X.paths.dirs.current),e.action===`stop`){await new Wa().execute(e.options);return}if(e.action===`run`){let t=await new Si().execute(e.options);process.exitCode=+!t;return}await new Ua().execute(e.options)}}async function qa(){try{await Ka()}catch(e){Ga.error({error:e},`Wallaby CLI failed`),console.error(G.default.red(e instanceof Error?e.message:String(e))),process.exitCode=1}finally{try{await K.shutdown()}catch(e){process.stderr.write(`[logger] ${e instanceof Error?e.stack||e.message:String(e)}\n`),process.exitCode=1}}}qa();export{};
|
|
69
|
+
`+n)}function v(e,t,n,r,i,a){if(e.listenerCount(`wsClientError`)){let r=Error(i);Error.captureStackTrace(r,v),e.emit(`wsClientError`,r,n,t)}else _(n,r,i,a)}}));ri(),ti(),Xr(),Qr(),$r(),ii();var oi=z(ni(),1);ai();function si(e){if(!(e instanceof Error))return e;let t=e;return{...Object.keys(e).reduce((e,n)=>(e[n]=t[n],e),{}),name:e.name,message:e.message,stack:e.stack}}function ci(e){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e,n=Error(typeof t.message==`string`?t.message:String(e));return typeof t.name==`string`&&t.name&&(n.name=t.name),typeof t.stack==`string`&&t.stack&&(n.stack=t.stack),Object.assign(n,e),n}return Error(String(e))}var li=class e{properties;static nextId=0;id;sequenceNumber=1;awaitingPromises={};sendAcknowledgement=!0;remoteApiAcknowledgement=!0;inboundApi;_api;_originalProcessMessageReceived;constructor(t,n){this.properties=n;let r=this;this.id=e.nextId++,this._api=new Proxy({},{get:function(e,t){return async(...e)=>await r.sendInternal({method:t,args:e})}}),this.inboundApi=t(this)}get api(){return this._api}async processMethod(e,t,n){n?this.sendAcknowledgement&&e.sequenceNumber&&this.sendMessage({sequenceNumber:e.sequenceNumber,error:si(n)}):this.sendAcknowledgement&&e.sequenceNumber&&this.sendMessage({sequenceNumber:e.sequenceNumber,result:{value:t}})}async processResult(e,t,n,r){t(r)}async processError(e,t,n,r){n(ci(r))}async processMessageReceived(e){if(e.method)try{let t=await this.inboundApi[e.method].apply(this.inboundApi,e.args);await this.processMethod(e,t,void 0)}catch(t){t||=Error(`An unknown error occurred`),await this.processMethod(e,void 0,t)}else if(e.result){let{sequenceNumber:t,result:n}=e;if(this.awaitingPromises[t]){let{resolve:r,reject:i}=this.awaitingPromises[t];delete this.awaitingPromises[t],r&&n&&await this.processResult(e,r,i,n.value)}}else if(e.error){let{sequenceNumber:t,error:n}=e;if(this.awaitingPromises[t]){let{resolve:r,reject:i}=this.awaitingPromises[t];delete this.awaitingPromises[t],r&&i&&await this.processError(e,r,i,n)}}}rejectAwaitingPromises(e){Object.values(this.awaitingPromises).forEach(({reject:t})=>t(e))}async onMessageReceived(e){this.processMessageReceived(e)}async sendInternal(e){if(this.remoteApiAcknowledgement&&(this.remoteApiAcknowledgement===!0||this.remoteApiAcknowledgement(e)))return e.sequenceNumber=this.sequenceNumber++,await new Promise(async(t,n)=>{this.awaitingPromises[e.sequenceNumber]={resolve:t,reject:n};try{await this.sendMessage(e)}catch(t){delete this.awaitingPromises[e.sequenceNumber],n(t)}});try{await this.sendMessage(e)}catch{}}dispose(){this.onDisposeListeners.map(e=>e()),this.onDisposeListeners=[],this.onConnectedListeners=[],this.onVersionMismatchListeners=[],this.rejectAwaitingPromises(Error(`Channel disposed`))}onConnectedListeners=[];subscribeOnConnected(e){this.onConnectedListeners.push(e)}unsubscribeOnConnected(e){this.onConnectedListeners=this.onConnectedListeners.filter(t=>t!==e)}connected(){this.onConnectedListeners.map(e=>e()),this.onConnectedListeners=[]}onVersionMismatchListeners=[];subscribeOnVersionMismatch(e){this.onVersionMismatchListeners.push(e)}unsubscribeOnVersionMismatch(e){this.onVersionMismatchListeners=this.onVersionMismatchListeners.filter(t=>t!==e)}versionMismatch(e,t){this.onVersionMismatchListeners.map(n=>n(e,t))}onDisposeListeners=[];subscribeOnDispose(e){this.onDisposeListeners.push(e)}unsubscribeOnDispose(e){this.onDisposeListeners=this.onDisposeListeners.filter(t=>t!==e)}replaceReceiver(e){this._originalProcessMessageReceived||=this.processMessageReceived;let t=e.allowedCalls;this.processMessageReceived=n=>{if(e.filter(n)){if(t<=0)return e.replacement(n);t--}return this._originalProcessMessageReceived.bind(this)(n)}}restoreReceiver(){this.processMessageReceived=(this._originalProcessMessageReceived||this.processMessageReceived).bind(this),delete this._originalProcessMessageReceived}},ui=class{inboundApiFactory;channelBaseConstructor;_channels=[];get channels(){return[...this._channels]}constructor(e,t){this.inboundApiFactory=e,this.channelBaseConstructor=t}createChannel(e){let t=new this.channelBaseConstructor(this.inboundApiFactory,e);return this._channels.push(t),t.connected(),t}destroyChannel(e){let t=this._channels.indexOf(e);t!==-1&&this._channels.splice(t,1)[0].dispose()}dispose(){this.channels.map(e=>this.destroyChannel(e))}};function di(e){return e instanceof Error?e.message:String(e)}function fi(e){return e instanceof Error?e.toString():String(e)}function pi(e){return e instanceof Error?e:Error(String(e))}var mi=class extends li{_disposed=!1;_version=``;_onChannelError=()=>{};setOptions(e,t){this._onChannelError=e,this._version=t}async sendMessage(e){if(this._disposed){this._onChannelError(Error(`Channel has been disposed`));return}try{this._version&&typeof e==`object`&&e&&(e.version=this._version);let t=JSON.stringify(e);if(t===void 0)throw TypeError(`Failed to serialize RPC message`);this.properties.socket.send(t,e=>{e&&this.properties.logger.trace(`send callback error:%s`,di(e))})}catch(e){throw this.properties.logger.trace(`failed to send message: %s`,di(e)),e}}async processError(e,t,n,r){r&&this.properties.logger.trace(`error processing message: %s, %s`,e,fi(r)),await super.processError(e,t,n,r)}async processMessageReceived(e){e.method&&this.properties.logger.trace(`received method call: %s`,e.method),await super.processMessageReceived(e)}rejectAwaitingPromises(e){this._disposed||super.rejectAwaitingPromises(e)}dispose(){if(this._disposed=!0,super.dispose(),!this.properties.socket.CLOSED)try{this.properties.socket.close()}catch{}}};function hi(e,t,n){e.on(`message`,e=>{try{t(JSON.parse(e.toString()))}catch(e){n(pi(e))}})}function gi(e,t,n,r){let{secure:i,host:a,port:o,secret:s,onError:c,onClose:l}=e,u={};e.from&&(u.headers={from:e.from});let d=i?`wss://`:`ws://`,f=o?`:${o}`:``,p=s?`?secret=${s}`:``,m=new oi.default(d+(a||`localhost`)+f+p,u);return n&&hi(m,n,e=>{r.trace(`incoming message processing error: %s`,e?.message)}),m.onclose=({code:e,reason:t})=>{r.trace(`client disconnected: %s %s`,e,t);try{l&&l(m,e,t?.toString())}catch(e){r.trace(`error when closing connection: %s`,di(e))}},m.onerror=e=>{try{r.trace(`connection error: %s`,e.error),c&&c(e.error)}catch(e){r.trace(`error when processing connection error: %s`,di(e))}},m.onopen=()=>{t()},m}var _i=class extends ui{_socket;constructor(e,t){super(t,mi),e.onChannelError||=e=>{this.channels.forEach(t=>{t.rejectAwaitingPromises(e),this.destroyChannel(t)})},e.onError||=e=>{this.channels.forEach(t=>{t.rejectAwaitingPromises(e),this.destroyChannel(t)})},e.onClose||=(e,t,n)=>{this.channels.forEach(e=>{e.rejectAwaitingPromises(Error(`WebSocket closed with code ${t} and reason ${n}`)),this.destroyChannel(e)})},this._socket=gi(e,()=>{this.createChannel({socket:this._socket,logger:e.logger}).setOptions(e.onChannelError,e.version)},e=>{this.channels.forEach(t=>{t.onMessageReceived(e)})},e.logger)}dispose(){this._socket?.close(),super.dispose()}};const vi=J.create(`core/session`);var yi=class{_channels;constructor(e){this._channels=e}get _channel(){let[e]=this._channels();if(!e)throw Error(`Core RPC channel is not available`);return e}handshake(e){return this._channel.api.handshake(e)}signal(e){this._channel.api.signal(e)}run(e){return this._channel.api.run(e)}export(e){return this._channel.api.export(e)}stop(){this._channel.api.stop()}},bi=class{ping(){}notify(e){}restart(){}launched(e){}relicensed(){}stopped(e){}},xi=class{_client;_alive=Ci();_api;_disposed=!1;_deactivated=!1;_interrupted=!1;constructor(e,t){this._client=e,this._api=t(()=>this._client.channels)}get alive(){return this._alive.promise}get api(){return this._api}deactivate(){this._deactivated=!0}interrupt(e){if(!this._interrupted){if(this._interrupted=!0,this._deactivated||this._disposed){this._alive.resolve();return}this._alive.reject(e)}}dispose(){this._disposed||(this._disposed=!0,this._interrupted||(this._interrupted=!0,this._alive.resolve()),this._client.dispose())}};async function Si(e,t,n){let r=!1,i=!1,a,o=Ci(),s=e=>{if(!r){r=!0,o.reject(e);return}i&&a.interrupt(e)};a=new xi(new _i({port:e,from:`cli`,logger:{trace:(...e)=>{let[t,n,...r]=e;if(typeof t==`string`){vi.trace(te(t,n,...r));return}if(typeof n==`string`||n===void 0){vi.trace(t,n,...r);return}vi.trace({args:e},`Websocket`)}},version:`1.0.0`,onError:e=>{vi.debug({error:e},`Socket error`),s(e)},onChannelError:e=>{vi.debug({error:e},`Channel error`),s(e)},onClose:(e,t,n)=>{vi.debug({code:t,reason:n},`Socket closed`),s(Error(`Socket closed with code ${t} and reason: ${n}`))}},n=>(n.subscribeOnConnected(async()=>{r||(i=!0,r=!0,vi.debug({port:e},`Connected`),o.resolve())}),t)),n);try{return await o.promise,a}catch(e){throw a.dispose(),e}}function Ci(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const wi=new Ir;var Ti=class extends bi{_options;_path;_restart;constructor(e,t,n){super(),this._options=e,this._path=t,this._restart=n}ping(){}notify(e){}restart(){this._restart()}launched(e){}relicensed(){this._path&&(wi.stop(),wi.check(this._path,this._options.ssl))}stopped(e){}},Ei=class{_logger=J.create(`commands/run`);async execute(e){this._logger.info({cwd:j(),options:e},`Executing run command`);let t=await this._execute(e);return this._logger.info({result:t},`Executed run command`),t}async _execute(e){let t=await this._cycle(e);return t?`restarted`in t?(this._logger.info(`Restarting process`),await this._execute(e)):(console.info(t.message),t.success):!1}async _cycle(e){let t=!1,n=!1,r,i,a,o=()=>{t=!0},s=await this._attach(e,()=>new Ti(e,void 0,()=>{n||r!==void 0||(n=!0,o())}),e=>new yi(e));if(!s)return await this._launch(e);let{manifest:c,session:l}=s;this._logger.info({id:c.id,pid:c.pids.primary,port:c.ports.primary},`Connected to active process from registry`),o=()=>{t||(t=!0,l.deactivate())};let u=k(),d=this._handshake(l).then(async()=>(await this._run(u,l,e),await l.api.export({id:u}))).then(e=>{n||r!==void 0||(r=e,o())}).catch(e=>{n||t||(i=e,o())}),f=l.alive.catch(e=>{t||(a=e,o())});try{await d}finally{o(),l.dispose(),await f}if(n)return{restarted:!0};if(a)throw a;if(i)throw i;return r}async _launch(e){let t=await Ur({...e,cache:!1,skill:e.skill,smart:e.smart||e.paths.length>0},new Fr,wi),n,r=()=>n?(n(),!0):!1,i=t.exited(r),a=await Promise.race([t.ready,i.then(()=>void 0)]);if(a===void 0)return;let o,s,c,l,u,d=!1,f=!1,p=!1,m,h,g,_,v=()=>(_?.(),h||(h=t.stop(r),h.catch(()=>{})),h);try{g=await Si(a,new Ti(e,t.location.path,()=>{p||u!==void 0||(p=!0,v())}),e=>new yi(e)),n=()=>g.api.stop(),wi.restarter={restart(e){g.api.signal({type:`update`,version:e})}},_=()=>{f||(f=!0,g.deactivate())}}catch(e){try{await t.stop(),await i}catch(e){this._logger.warn({error:e},`Failed to stop process after connection failure`)}throw e}t.stopping.then(()=>{_?.()}),m=this._handshake(g).then(async()=>{t.location.type===`dist`&&wi.schedule(t.location.path,e.ssl);let n=k();return await this._run(n,g,e),await g.api.export({id:n})}).then(t=>{if(!(p||u!==void 0)){if(u=t,e.skill){d=!0,_?.();return}return v()}}).catch(async e=>{if(!(p||f)){c=e;try{await v()}catch(e){this._logger.warn({error:e},`Failed to stop process after run/export failure`)}}});let y=g.alive.catch(async e=>{if(!f){s=e;try{await v()}catch(e){this._logger.warn({error:e},`Failed to stop process after connection loss`)}}});try{if(m&&await m,d&&t.release(),!d)try{await i}catch(e){o=e}}finally{if(wi.stop(),wi.restarter=void 0,g.dispose(),await y,h)try{await h}catch(e){l=e}}if(l)throw l;if(p)return{restarted:!0};if(o)throw o;if(s)throw s;if(c)throw c;if(u)return u}async _attach(e,t,n){if(e.force)return;let r=this._find(e);if(r.length===0)return;let i=await this._connect(r,t,n);if(i)return i;throw Error(`Failed to attach to active Wallaby instance for the specified config.`)}async _connect([e,...t],n,r){if(e){this._logger.info({id:e.id,pid:e.pids.primary,port:e.ports.primary},`Trying to connect to active process from registry`);try{return{manifest:e,session:await Si(e.ports.primary,n(e),r)}}catch(i){return this._logger.warn({error:i,id:e.id,pid:e.pids.primary,port:e.ports.primary},`Failed to connect to active process from registry`),await this._connect(t,n,r)}}}async _run(e,t,n){await t.api.run({id:e,paths:n.paths})}async _handshake(e){let t=await e.api.handshake(Y.version);if(!t.compatible)throw Error(t.message||`Wallaby CLI v${Y.version} is not compatible with the running Wallaby Core.`)}_find(e){let t=ln(s(e.config?e.config:i(j(),`auto.detect`)));return new Kr().manifests.filter(e=>e.paths.config===t).sort((e,t)=>t.timestamps.refreshed-e.timestamps.refreshed).filter(e=>{try{return process.kill(e.pids.primary,0),!0}catch(e){return(typeof e==`object`&&e&&`code`in e?e.code:void 0)===`EPERM`}})}},Di=R(((e,t)=>{t.exports=a,a.sync=o;var n=B(`fs`);function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}})),Oi=R(((e,t)=>{t.exports=r,r.sync=i;var n=B(`fs`);function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),ki=R(((e,t)=>{B(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?Di():Oi();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),Ai=R(((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=B(`path`),i=n?`;`:`:`,a=ki(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}})),ji=R(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),Mi=R(((e,t)=>{let n=B(`path`),r=Ai(),i=ji();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o})),Ni=R(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),Pi=R(((e,t)=>{t.exports=/^#!(.*)/})),Fi=R(((e,t)=>{let n=Pi();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),Ii=R(((e,t)=>{let n=B(`fs`),r=Fi();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i})),Li=R(((e,t)=>{let n=B(`path`),r=Mi(),i=Ni(),a=Ii(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d})),Ri=R(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),zi=R(((e,t)=>{let n=B(`child_process`),r=Li(),i=Ri();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i}));function Bi(){try{return d.statSync(`/.dockerenv`),!0}catch{return!1}}function Vi(){try{return d.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`docker`)}catch{return!1}}function Hi(){return Ui===void 0&&(Ui=Bi()||Vi()),Ui}var Ui,Wi=L((()=>{}));function Gi(){return Ki===void 0&&(Ki=qi()||Hi()),Ki}var Ki,qi,Ji=L((()=>{Wi(),qi=()=>{try{return d.statSync(`/run/.containerenv`),!0}catch{return!1}}})),Yi,Xi,Zi=L((()=>{Ji(),Yi=()=>{if(A.platform!==`linux`)return!1;if(c.release().toLowerCase().includes(`microsoft`))return!Gi();try{if(d.readFileSync(`/proc/version`,`utf8`).toLowerCase().includes(`microsoft`))return!Gi()}catch{}return d.existsSync(`/proc/sys/fs/binfmt_misc/WSLInterop`)||d.existsSync(`/run/WSL`)?!Gi():!1},Xi=A.env.__IS_WSL_TEST__?Yi:Yi()})),Qi,$i,ea,ta=L((()=>{Zi(),Qi=(()=>{let e=`/mnt/`,t;return async function(){if(t)return t;let n=`/etc/wsl.conf`,r=!1;try{await v.access(n,y.F_OK),r=!0}catch{}if(!r)return e;let i=await v.readFile(n,{encoding:`utf8`}),a=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(i);return a?(t=a.groups.mountPoint.trim(),t=t.endsWith(`/`)?t:`${t}/`,t):e}})(),$i=async()=>`${await Qi()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,ea=async()=>Xi?$i():`${A.env.SYSTEMROOT||A.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`}));function na(e,t,n){let r=n=>Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let e=n();return r(e),e},set(e){r(e)}}),e}var ra=L((()=>{}));async function ia(){if(A.platform!==`darwin`)throw Error(`macOS only`);let{stdout:e}=await aa(`defaults`,[`read`,`com.apple.LaunchServices/com.apple.launchservices.secure`,`LSHandlers`]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??`com.apple.Safari`;return t===`com.apple.safari`?`com.apple.Safari`:t}var aa,oa=L((()=>{aa=ne(ee)}));async function sa(e,{humanReadableOutput:t=!0,signal:n}={}){if(A.platform!==`darwin`)throw Error(`macOS only`);let r=t?[]:[`-ss`],i={};n&&(i.signal=n);let{stdout:a}=await ca(`osascript`,[`-e`,e,r],i);return a.trim()}var ca,la=L((()=>{ca=ne(ee)}));async function ua(e){return sa(`tell application "Finder" to set app_path to application file id "${e}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var da=L((()=>{la()}));async function fa(e=pa){let{stdout:t}=await e(`reg`,[`QUERY`,` HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice`,`/v`,`ProgId`]),n=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!n)throw new ha(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:r}=n.groups,i=r.lastIndexOf(`.`),a=r.lastIndexOf(`-`),o=i===-1?void 0:r.slice(0,i),s=a===-1?void 0:r.slice(0,a);return ma[r]??ma[o]??ma[s]??{name:r,id:r}}var pa,ma,ha,ga=L((()=>{pa=ne(ee),ma={MSEdgeHTM:{name:`Edge`,id:`com.microsoft.edge`},MSEdgeBHTML:{name:`Edge Beta`,id:`com.microsoft.edge.beta`},MSEdgeDHTML:{name:`Edge Dev`,id:`com.microsoft.edge.dev`},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:`Edge`,id:`com.microsoft.edge.old`},ChromeHTML:{name:`Chrome`,id:`com.google.chrome`},ChromeBHTML:{name:`Chrome Beta`,id:`com.google.chrome.beta`},ChromeDHTML:{name:`Chrome Dev`,id:`com.google.chrome.dev`},ChromiumHTM:{name:`Chromium`,id:`org.chromium.Chromium`},BraveHTML:{name:`Brave`,id:`com.brave.Browser`},BraveBHTML:{name:`Brave Beta`,id:`com.brave.Browser.beta`},BraveDHTML:{name:`Brave Dev`,id:`com.brave.Browser.dev`},BraveSSHTM:{name:`Brave Nightly`,id:`com.brave.Browser.nightly`},FirefoxURL:{name:`Firefox`,id:`org.mozilla.firefox`},OperaStable:{name:`Opera`,id:`com.operasoftware.Opera`},VivaldiHTM:{name:`Vivaldi`,id:`com.vivaldi.Vivaldi`},"IE.HTTP":{name:`Internet Explorer`,id:`com.microsoft.ie`}},new Map(Object.entries(ma)),ha=class extends Error{}}));async function _a(){if(A.platform===`darwin`){let e=await ia();return{name:await ua(e),id:e}}if(A.platform===`linux`){let{stdout:e}=await va(`xdg-mime`,[`query`,`default`,`x-scheme-handler/http`]),t=e.trim();return{name:ya(t.replace(/.desktop$/,``).replace(`-`,` `)),id:t}}if(A.platform===`win32`)return fa();throw Error(`Only macOS, Linux, and Windows are supported`)}var va,ya,ba=L((()=>{oa(),da(),ga(),va=ne(ee),ya=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase())})),xa=le({apps:()=>Pa,default:()=>Ma,openApp:()=>Na});async function Sa(){let e=await ea(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:n}=await Ta(e,[`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`,I.from(t,`utf16le`).toString(`base64`)],{encoding:`utf8`}),r=n.trim(),i={ChromeHTML:`com.google.chrome`,BraveHTML:`com.brave.Browser`,MSEdgeHTM:`com.microsoft.edge`,FirefoxURL:`org.mozilla.firefox`};return i[r]?{id:i[r]}:{}}function Ca(e){if(typeof e==`string`||Array.isArray(e))return e;let{[ka]:t}=e;if(!t)throw Error(`${ka} is not supported`);return t}function wa({[Oa]:e},{wsl:t}){if(t&&Xi)return Ca(t);if(!e)throw Error(`${Oa} is not supported`);return Ca(e)}var Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa=L((()=>{ta(),ra(),ba(),Ji(),Ta=ne(N.execFile),Ea=t.dirname(_(import.meta.url)),Da=t.join(Ea,`xdg-open`),{platform:Oa,arch:ka}=A,Aa=async(e,t)=>{let n;for(let r of e)try{return await t(r)}catch(e){n=e}throw n},ja=async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return Aa(e.app,t=>ja({...e,app:t}));let{name:t,arguments:n=[]}=e.app??{};if(n=[...n],Array.isArray(t))return Aa(t,t=>ja({...e,app:{name:t,arguments:n}}));if(t===`browser`||t===`browserPrivate`){let r={"com.google.chrome":`chrome`,"google-chrome.desktop":`chrome`,"com.brave.Browser":`brave`,"org.mozilla.firefox":`firefox`,"firefox.desktop":`firefox`,"com.microsoft.msedge":`edge`,"com.microsoft.edge":`edge`,"com.microsoft.edgemac":`edge`,"microsoft-edge.desktop":`edge`},i={chrome:`--incognito`,brave:`--incognito`,firefox:`--private-window`,edge:`--inPrivate`},a=Xi?await Sa():await _a();if(a.id in r){let o=r[a.id];return t===`browserPrivate`&&n.push(i[o]),ja({...e,app:{name:Pa[o],arguments:n}})}throw Error(`${a.name} is not supported as a default browser`)}let r,i=[],a={};if(Oa===`darwin`)r=`open`,e.wait&&i.push(`--wait-apps`),e.background&&i.push(`--background`),e.newInstance&&i.push(`--new`),t&&i.push(`-a`,t);else if(Oa===`win32`||Xi&&!Gi()&&!t){r=await ea(),i.push(`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`),Xi||(a.windowsVerbatimArguments=!0);let o=[`Start`];e.wait&&o.push(`-Wait`),t?(o.push(`"\`"${t}\`""`),e.target&&n.push(e.target)):e.target&&o.push(`"${e.target}"`),n.length>0&&(n=n.map(e=>`"\`"${e}\`""`),o.push(`-ArgumentList`,n.join(`,`))),e.target=I.from(o.join(` `),`utf16le`).toString(`base64`)}else{if(t)r=t;else{let e=!Ea||Ea===`/`,t=!1;try{await v.access(Da,y.X_OK),t=!0}catch{}r=A.versions.electron??(Oa===`android`||e||!t)?`xdg-open`:Da}n.length>0&&i.push(...n),e.wait||(a.stdio=`ignore`,a.detached=!0)}Oa===`darwin`&&n.length>0&&i.push(`--args`,...n),e.target&&i.push(e.target);let o=N.spawn(r,i,a);return e.wait?new Promise((t,n)=>{o.once(`error`,n),o.once(`close`,r=>{if(!e.allowNonzeroExitCode&&r>0){n(Error(`Exited with code ${r}`));return}t(o)})}):(o.unref(),o)},Ma=(e,t)=>{if(typeof e!=`string`)throw TypeError("Expected a `target`");return ja({...t,target:e})},Na=(e,t)=>{if(typeof e!=`string`&&!Array.isArray(e))throw TypeError("Expected a valid `name`");let{arguments:n=[]}=t??{};if(n!=null&&!Array.isArray(n))throw TypeError("Expected `appArguments` as Array type");return ja({...t,app:{name:e,arguments:n}})},Pa={},na(Pa,`chrome`,()=>wa({darwin:`google chrome`,win32:`chrome`,linux:[`google-chrome`,`google-chrome-stable`,`chromium`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`,x64:[`/mnt/c/Program Files/Google/Chrome/Application/chrome.exe`,`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`]}})),na(Pa,`brave`,()=>wa({darwin:`brave browser`,win32:`brave`,linux:[`brave-browser`,`brave`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`,x64:[`/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe`,`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`]}})),na(Pa,`firefox`,()=>wa({darwin:`firefox`,win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:`firefox`},{wsl:`/mnt/c/Program Files/Mozilla Firefox/firefox.exe`})),na(Pa,`edge`,()=>wa({darwin:`microsoft edge`,win32:`msedge`,linux:[`microsoft-edge`,`microsoft-edge-dev`]},{wsl:`/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`})),na(Pa,`browser`,()=>`browser`),na(Pa,`browserPrivate`,()=>`browserPrivate`)})),Ia=z(zi(),1);const $=J.create(`browser`);function La(e){let t=process.env.BROWSER||``;$.info({url:e,browser:t||`default`},`Opening browser`),t.toLowerCase().endsWith(`.js`)?za(t,e):t.toLowerCase()===`none`?$.debug({url:e},`Browser auto-open disabled by environment`):Va(t,process.env.BROWSER_ARGS?process.env.BROWSER_ARGS.split(` `):[],e)}function Ra(e,t){return new Promise((n,r)=>{$.debug({command:e,cwd:t?.cwd},`Executing shell command`),P(e,t,(i,a)=>{i?($.error({err:i,command:e,cwd:t?.cwd},`Shell command failed`),r(i)):($.debug({command:e,cwd:t?.cwd},`Shell command completed`),n(a.toString()))})})}function za(e,t){let n=process.argv.slice(2);$.debug({scriptPath:e,url:t,extraArgs:n},`Launching browser script`);let r=(0,Ia.default)(process.execPath,[e,...n,t],{stdio:`inherit`});r.on(`error`,n=>{$.error({err:n,scriptPath:e,url:t},`Browser script process failed to start`)}),r.on(`close`,n=>{n===0?$.debug({scriptPath:e,url:t},`Browser script completed successfully`):($.warn({code:n,scriptPath:e,url:t},`Browser script exited with a non-zero status`),process.stdout.write(K.default.red(`\nThe script specified as BROWSER environment variable failed.\n\n${K.default.cyan(e)} exited with code ${n}.`)))})}const Ba=[`Google Chrome Canary`,`Google Chrome Dev`,`Google Chrome Beta`,`Google Chrome`,`Microsoft Edge`,`Brave Browser`,`Vivaldi`,`Chromium`];async function Va(e,t,n){let r=e===`google chrome`?`Google Chrome`:e,i=process.platform===`darwin`&&(!r||Ba.includes(r));if($.debug({browser:r,browserArgs:t,url:n},`Starting browser process`),i)try{let e=await Ra(`ps cax`),t=r&&e.includes(r)?r:Ba.find(t=>e.includes(t));if(t)return await Ra(`osascript openChrome.applescript "${encodeURI(n)}" "${t}"`,{cwd:Y.paths.dirs.package.bin}),$.debug({openedBrowser:t,url:n},`Opened browser via AppleScript`),!0}catch(e){$.debug({err:e,url:n},`AppleScript browser reuse attempt failed`)}process.platform===`darwin`&&e===`open`&&(e=void 0);try{let r=e?{app:{name:e,arguments:t}}:{},i;try{i=(await Promise.resolve().then(()=>(Fa(),xa))).default}catch(e){$.error({err:e},`Failed to import browser opener`)}if(i)try{let t=await i(n,r);$.debug({url:n,browser:e||`default`},`Opened browser with open package`),t.on(`error`,e=>{$.error({err:e,url:n},`Browser subprocess reported an error`),process.stderr.write(e.stack||e.message)})}catch(e){$.error({err:e,url:n},`Failed to open browser`),process.stderr.write(e instanceof Error?e.stack||e.message:String(e))}else $.warn({url:n},`Browser opener module was unavailable`);return!0}catch(t){return $.warn({err:t,url:n,browser:e||`default`},`Browser launch failed`),!1}}const Ha=J.create(`core/notifications`);function Ua(e,t){if(!t.text){Ha.trace({type:t.type},`Skipping empty notification`);return}Ha.debug({type:t.type,button:!!t.button},`Received notification from core`);let n=[];if(~t.text.indexOf(`expire`)&&t.type===`warning`&&e.notifications===!1){Ha.trace({type:t.type},`Suppressed expiration notification`);return}let r=`http://localhost:${e.port}`;~t.text.indexOf(`activate-link`)&&e.port&&n.push({title:`Enter License`,url:r}),~t.text.indexOf(`continue-trial-link`)&&e.port&&n.push({title:`Continue Trial`,url:r}),t.button&&n.push({title:t.button.label,url:t.button.link}),t.text=t.text.replace(/<br\/><br\/>/g,` `).replace(/<br\/>/g,` `).replace(/<a\s+(?:[^>]*?\s+)?href=['"]([^'"]*)['"]/g,(e,t)=>(t.startsWith(`http`)&&n.push({url:t}),e)).replace(/<[^>]*>/g,``);let i=t.type===`error`?K.default.red:t.type===`warning`?K.default.yellow:K.default.green;if(process.stdout.write(i(`\n ⚑ ${t.text}\n\n`)),n.length)for(let e of n)process.stdout.write(`${K.default.green(` ➜ `)}${K.default.bold(K.default.yellow(e.title?e.title+`: `:``))}${K.default.cyan(e.url)}\n`);Ha.trace({links:n},`Rendered notification links`)}const Wa=new Ir;var Ga=class extends bi{_options;_path;_version;_restart;_port;constructor(e,t,n,r){super(),this._options=e,this._path=t,this._version=n,this._restart=r}ping(){}notify(e){Ua({notifications:this._options.notifications,port:this._port,ui:this._options.ui},e)}restart(){this._restart()}launched(e){this._port=e;let t=`http://localhost:${e}`;process.stdout.write(K.default.green(` ${K.default.bold(`WALLABY CORE`)}${this._version?` v${this._version}`:``}\n`)),process.stdout.write(`${K.default.green(` ➜ `)}${K.default.bold(K.default.yellow(`UI:`))} ${K.default.cyan(t)}\n`),process.stdout.write(`${K.default.green(` ➜ `)}${K.default.bold(K.default.dim(`Docs:`))} ${K.default.cyan(`https://wallabyjs.com/docs`)}\n`),this._options.ui!==!1&&La(t)}relicensed(){this._path&&(Wa.stop(),Wa.check(this._path,this._options.ssl))}stopped(e){}},Ka=class{_logger=J.create(`commands/start`);async execute(e){this._logger.info({cwd:j(),options:e},`Executing start command`);let t=await this._execute(e);return this._logger.info({result:t},`Executed start command`),t}async _execute(e){return await this._cycle(e)?(this._logger.info(`Restarting process`),await this._execute(e)):!0}async _cycle(e){if(!e.force){let t=this._find(e)[0];if(t)return this._logger.info({id:t.id,pid:t.pids.primary,port:t.ports.primary},`Active process is already running for the specified config`),console.warn(`Wallaby Core is already started.`),!1}let t=await Ur({...e,smart:e.smart||e.paths.length>0},new Fr,Wa),n,r=()=>n?(n(),!0):!1,i=t.exited(r),a=await Promise.race([t.ready,i.then(()=>void 0)]);if(a===void 0)return!1;let o,s,c,l,u=!1,d,f,p=()=>(d||(d=t.stop(r),d.catch(()=>{})),d);try{f=await Si(a,new Ga(e,t.location.path,t.version,()=>{u||(u=!0,p())}),e=>new yi(e)),n=()=>f.api.stop(),Wa.restarter={restart(e){f.api.signal({type:`update`,version:e})}}}catch(e){try{await t.stop(),await i}catch(e){this._logger.warn({error:e},`Failed to stop process after connection failure`)}throw e}t.stopping.then(()=>f.deactivate());let m=f.alive.catch(async e=>{s=e;try{await p()}catch(e){this._logger.warn({error:e},`Failed to stop process after connection loss`)}});try{await this._handshake(f),t.location.type===`dist`&&Wa.schedule(t.location.path,e.ssl),await this._run(f,e).catch(async e=>{if(!u){c=e;try{await p()}catch(e){this._logger.warn({error:e},`Failed to stop process after run failure`)}}}),await i}catch(e){if(o=e,!u)try{await p(),await i.catch(()=>{})}catch(e){this._logger.warn({error:e},`Failed to stop process after startup failure`)}}finally{if(Wa.stop(),Wa.restarter=void 0,f.dispose(),await m,d)try{await d}catch(e){l=e}}if(l)throw l;if(o)throw o;if(c)throw c;if(s&&!(s instanceof Error&&s.message.startsWith(`Socket closed with code 1006 and reason:`)))throw s;return u}async _run(e,t){t.paths.length!==0&&await e.api.run({id:k(),paths:t.paths})}async _handshake(e){let t=await e.api.handshake(Y.version);if(!t.compatible)throw Error(t.message||`Wallaby CLI v${Y.version} is not compatible with the running Wallaby Core.`)}_find(e){let t=ln(s(e.config?e.config:i(j(),`auto.detect`)));return new Kr().manifests.filter(e=>e.paths.config===t).sort((e,t)=>t.timestamps.refreshed-e.timestamps.refreshed).filter(e=>{try{return process.kill(e.pids.primary,0),!0}catch(e){return(typeof e==`object`&&e&&`code`in e?e.code:void 0)===`EPERM`}})}},qa=class{_logger=J.create(`commands/stop`);async execute(e){this._logger.info({cwd:j(),options:e},`Executing stop command`);let t=ln(s(e.config?e.config:i(j(),`auto.detect`)));this._logger.info({config:t},`Determined config path and config directory`);let n=new Kr().manifests.filter(n=>e.all?!0:e.config?n.paths.config===t:r(n.paths.config)===r(t));if(n.length!==0)for(let e of n)this._stop(e);else this._logger.info(`No running processes matched stop criteria`);this._logger.info({count:n.length},`Executed stop command`)}_stop(e){this._logger.info({id:e.id,pid:e.pids.primary,config:e.paths.config},`Stopping process from registry`);try{process.kill(e.pids.primary,`SIGTERM`)}catch(e){this._logger.info({error:e},`Failed to send SIGTERM to process, it may have already stopped`)}this._logger.info({id:e.id,pid:e.pids.primary},`Stopped process from registry`)}};J.initialize({path:i(Y.paths.dirs.current,`logs`,`trace.log`)});const Ja=J.create(`cli`);async function Ya(){Ja.trace({argv:process.argv.slice(2),version:Y.version},`Parsing CLI arguments`);let e=gt(process.argv,Y.version);if(e){if(await G.default.ensureDir(Y.paths.dirs.current),e.action===`stop`){await new qa().execute(e.options);return}if(e.action===`run`){let t=await new Ei().execute(e.options);process.exitCode=+!t;return}await new Ka().execute(e.options)}}async function Xa(){try{await Ya()}catch(e){Ja.error({error:e},`Wallaby CLI failed`),console.error(K.default.red(e instanceof Error?e.message:String(e))),process.exitCode=1}finally{try{await J.shutdown()}catch(e){process.stderr.write(`[logger] ${e instanceof Error?e.stack||e.message:String(e)}\n`),process.exitCode=1}}}Xa();export{};
|