@willbooster/wb 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import t,{resolve as e,dirname as n,normalize as s,basename as i,extname as r,relative as o}from"node:path";import{
|
|
1
|
+
import t,{resolve as e,dirname as n,normalize as s,basename as i,extname as r,relative as o}from"node:path";import{notStrictEqual as a,strictEqual as c}from"node:assert";import l,{statSync as h,readdirSync as d,readFileSync as u,writeFile as f}from"node:fs";import{format as p,inspect as g}from"node:util";import{fileURLToPath as m}from"node:url";import y,{spawn as b,spawnSync as w}from"node:child_process";import{createHash as v}from"node:crypto";import O from"node:fs/promises";import k from"chalk";import{PromisePool as E}from"minimal-promise-pool";import{killPortProcess as j}from"kill-port-process";import A from"tree-kill";import _ from"node:os";import{config as x}from"dotenv";function P(t){return new Promise((e=>{l.access(t,l.constants.F_OK,(t=>{e(!t)}))}))}async function $(t,e,n){return new Promise(((s,i)=>{try{const r=b(t,e??[],n??{});let o="",a="";n?.input&&(r.stdin?.write(n.input),r.stdin?.end()),r.stdout?.on("data",(t=>{o+=t})),r.stderr?.on("data",(t=>{n?.mergeOutAndError?o+=t:a+=t}));let c=!1;const l=()=>{!c&&r.pid&&(c=!0,n?.verbose&&console.info(`treeKill(${r.pid})`),A(r.pid))};n?.killOnExit&&(process.on("beforeExit",l),process.on("SIGINT",l)),r.on("error",(t=>{process.removeListener("exit",l),r.removeAllListeners("close"),i(t)})),r.on("close",((t,e)=>{process.removeListener("exit",l),void 0===r.pid?i(new Error("Process has no pid.")):s({pid:r.pid,stdout:o,stderr:a,status:t,signal:e})}))}catch(t){i(t)}}))}const C={right:function(t,e){t=t.trim();const n=N.stringWidth(t);if(n<e)return" ".repeat(e-n)+t;return t},center:function(t,e){t=t.trim();const n=N.stringWidth(t);if(n>=e)return t;return" ".repeat(e-n>>1)+t}};class S{constructor(t){var e;this.width=t.width,this.wrap=null===(e=t.wrap)||void 0===e||e,this.rows=[]}span(...t){this.div(...t).span=!0}resetOutput(){this.rows=[]}div(...t){if(0===t.length&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&"string"==typeof t[0])return this.applyLayoutDSL(t[0]);const e=t.map((t=>"string"==typeof t?this.colFromString(t):t));return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return 1===t.length&&"string"==typeof t[0]&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){const e=t.split("\n").map((t=>t.split("\t")));let n=0;return e.forEach((t=>{t.length>1&&N.stringWidth(t[0])>n&&(n=Math.min(Math.floor(.5*this.width),N.stringWidth(t[0])))})),e.forEach((t=>{this.div(...t.map(((e,s)=>({text:e.trim(),padding:this.measurePadding(e),width:0===s&&t.length>1?n:void 0}))))})),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){const e=N.stripAnsi(t);return[0,e.match(/\s*$/)[0].length,0,e.match(/^\s*/)[0].length]}toString(){const t=[];return this.rows.forEach((e=>{this.rowToString(e,t)})),t.filter((t=>!t.hidden)).map((t=>t.text)).join("\n")}rowToString(t,e){return this.rasterize(t).forEach(((n,s)=>{let i="";n.forEach(((n,r)=>{const{width:o}=t[r],a=this.negatePadding(t[r]);let c=n;if(a>N.stringWidth(n)&&(c+=" ".repeat(a-N.stringWidth(n))),t[r].align&&"left"!==t[r].align&&this.wrap){c=(0,C[t[r].align])(c,a),N.stringWidth(c)<a&&(c+=" ".repeat((o||0)-N.stringWidth(c)-1))}const l=t[r].padding||[0,0,0,0];l[3]&&(i+=" ".repeat(l[3])),i+=M(t[r],c,"| "),i+=c,i+=M(t[r],c," |"),l[1]&&(i+=" ".repeat(l[1])),0===s&&e.length>0&&(i=this.renderInline(i,e[e.length-1]))})),e.push({text:i.replace(/ +$/,""),span:t.span})})),e}renderInline(t,e){const n=t.match(/^ */),s=n?n[0].length:0,i=e.text,r=N.stringWidth(i.trimRight());return e.span?this.wrap?s<r?t:(e.hidden=!0,i.trimRight()+" ".repeat(s-r)+t.trimLeft()):(e.hidden=!0,i+t):t}rasterize(t){const e=[],n=this.columnWidths(t);let s;return t.forEach(((t,i)=>{t.width=n[i],s=this.wrap?N.wrap(t.text,this.negatePadding(t),{hard:!0}).split("\n"):t.text.split("\n"),t.border&&(s.unshift("."+"-".repeat(this.negatePadding(t)+2)+"."),s.push("'"+"-".repeat(this.negatePadding(t)+2)+"'")),t.padding&&(s.unshift(...new Array(t.padding[0]||0).fill("")),s.push(...new Array(t.padding[2]||0).fill(""))),s.forEach(((t,n)=>{e[n]||e.push([]);const s=e[n];for(let t=0;t<i;t++)void 0===s[t]&&s.push("");s.push(t)}))})),e}negatePadding(t){let e=t.width||0;return t.padding&&(e-=(t.padding[3]||0)+(t.padding[1]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map((t=>t.width||N.stringWidth(t.text)));let e=t.length,n=this.width;const s=t.map((t=>{if(t.width)return e--,n-=t.width,t.width})),i=e?Math.floor(n/e):0;return s.map(((e,n)=>void 0===e?Math.max(i,function(t){const e=t.padding||[],n=1+(e[3]||0)+(e[1]||0);if(t.border)return n+4;return n}(t[n])):e))}}function M(t,e,n){return t.border?/[.']-+[.']/.test(e)?"":0!==e.trim().length?n:" ":""}let N;const D=new RegExp("(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function I(t){return t.replace(D,"")}function R(t,e){const[n,s]=t.match(D)||["",""];t=I(t);let i="";for(let n=0;n<t.length;n++)0!==n&&n%e==0&&(i+="\n"),i+=t.charAt(n);return n&&s&&(i=`${n}${i}${s}`),i}
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright (c) 2016, Contributors
|
|
5
5
|
* SPDX-License-Identifier: ISC
|
|
6
6
|
*/
|
|
7
|
-
function
|
|
7
|
+
function W(t){if(t!==t.toLowerCase()&&t!==t.toUpperCase()||(t=t.toLowerCase()),-1===t.indexOf("-")&&-1===t.indexOf("_"))return t;{let e="",n=!1;const s=t.match(/^-+/);for(let i=s?s[0].length:0;i<t.length;i++){let s=t.charAt(i);n&&(n=!1,s=s.toUpperCase()),0===i||"-"!==s&&"_"!==s?"-"!==s&&"_"!==s&&(e+=s):n=!0}return e}}function F(t,e){const n=t.toLowerCase();e=e||"-";let s="";for(let i=0;i<t.length;i++){const r=n.charAt(i),o=t.charAt(i);s+=r!==o&&i>0?`${e}${n.charAt(i)}`:o}return s}function z(t){return null!=t&&("number"==typeof t||(!!/^0x[0-9a-f]+$/i.test(t)||!/^0[^.]/.test(t)&&/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(t)))}
|
|
8
8
|
/**
|
|
9
9
|
* @license
|
|
10
10
|
* Copyright (c) 2016, Contributors
|
|
@@ -15,13 +15,13 @@ function I(t){if(t!==t.toLowerCase()&&t!==t.toUpperCase()||(t=t.toLowerCase()),-
|
|
|
15
15
|
* Copyright (c) 2016, Contributors
|
|
16
16
|
* SPDX-License-Identifier: ISC
|
|
17
17
|
*/
|
|
18
|
-
var
|
|
18
|
+
var L;
|
|
19
19
|
/**
|
|
20
20
|
* @license
|
|
21
21
|
* Copyright (c) 2016, Contributors
|
|
22
22
|
* SPDX-License-Identifier: ISC
|
|
23
23
|
*/
|
|
24
|
-
let
|
|
24
|
+
let T;!function(t){t.BOOLEAN="boolean",t.STRING="string",t.NUMBER="number",t.ARRAY="array"}(L||(L={}));function U(t){return void 0!==t?t+1:1}function H(t){return"__proto__"===t?"___proto___":t}
|
|
25
25
|
/**
|
|
26
26
|
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
|
|
27
27
|
* CJS and ESM environments.
|
|
@@ -30,5 +30,5 @@ let z;!function(t){t.BOOLEAN="boolean",t.STRING="string",t.NUMBER="number",t.ARR
|
|
|
30
30
|
* Copyright (c) 2016, Contributors
|
|
31
31
|
* SPDX-License-Identifier: ISC
|
|
32
32
|
*/
|
|
33
|
-
var H,T,V;const B=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,q=null!==(T=null===(H=null===process||void 0===process?void 0:process.versions)||void 0===H?void 0:H.node)&&void 0!==T?T:null===(V=null===process||void 0===process?void 0:process.version)||void 0===V?void 0:V.slice(1);if(q){if(Number(q.match(/^([^.]+)/)[1])<B)throw Error(`yargs parser supports a minimum Node.js version of ${B}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const Y=process?process.env:{},J=new class{constructor(t){z=t}parse(t,e){const n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},e),s=function(t){if(Array.isArray(t))return t.map((t=>"string"!=typeof t?t+"":t));t=t.trim();let e=0,n=null,s=null,i=null;const r=[];for(let o=0;o<t.length;o++)n=s,s=t.charAt(o)," "!==s||i?(s===i?i=null:"'"!==s&&'"'!==s||i||(i=s),r[e]||(r[e]=""),r[e]+=s):" "!==n&&e++;return r}(t),i="string"==typeof t,r=function(t){const e=[],n=Object.create(null);let s=!0;Object.keys(t).forEach((function(n){e.push([].concat(t[n],n))}));for(;s;){s=!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){if(e[t].filter((function(t){return-1!==e[n].indexOf(t)})).length){e[t]=e[t].concat(e[n]),e.splice(n,1),s=!0;break}}}return e.forEach((function(t){const e=(t=t.filter((function(t,e,n){return n.indexOf(t)===e}))).pop();void 0!==e&&"string"==typeof e&&(n[e]=t)})),n}(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],l=n.envPrefix,h=o["populate--"],d=h?"--":"_",u=Object.create(null),f=Object.create(null),p=n.__||z.format,g={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},m=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,y=new RegExp("^--"+o["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach((function(t){const e="object"==typeof t?t.key:t,n=Object.keys(t).map((function(t){return{boolean:"bools",string:"strings",number:"numbers"}[t]})).filter(Boolean).pop();n&&(g[n][e]=!0),g.arrays[e]=!0,g.keys.push(e)})),[].concat(n.boolean||[]).filter(Boolean).forEach((function(t){g.bools[t]=!0,g.keys.push(t)})),[].concat(n.string||[]).filter(Boolean).forEach((function(t){g.strings[t]=!0,g.keys.push(t)})),[].concat(n.number||[]).filter(Boolean).forEach((function(t){g.numbers[t]=!0,g.keys.push(t)})),[].concat(n.count||[]).filter(Boolean).forEach((function(t){g.counts[t]=!0,g.keys.push(t)})),[].concat(n.normalize||[]).filter(Boolean).forEach((function(t){g.normalize[t]=!0,g.keys.push(t)})),"object"==typeof n.narg&&Object.entries(n.narg).forEach((([t,e])=>{"number"==typeof e&&(g.nargs[t]=e,g.keys.push(t))})),"object"==typeof n.coerce&&Object.entries(n.coerce).forEach((([t,e])=>{"function"==typeof e&&(g.coercions[t]=e,g.keys.push(t))})),void 0!==n.config&&(Array.isArray(n.config)||"string"==typeof n.config?[].concat(n.config).filter(Boolean).forEach((function(t){g.configs[t]=!0})):"object"==typeof n.config&&Object.entries(n.config).forEach((([t,e])=>{"boolean"!=typeof e&&"function"!=typeof e||(g.configs[t]=e)}))),function(...t){t.forEach((function(t){Object.keys(t||{}).forEach((function(t){g.aliases[t]||(g.aliases[t]=[].concat(r[t]||[]),g.aliases[t].concat(t).forEach((function(e){if(/-/.test(e)&&o["camel-case-expansion"]){const n=I(e);n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].concat(t).forEach((function(e){if(e.length>1&&/[A-Z]/.test(e)&&o["camel-case-expansion"]){const n=W(e,"-");n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].forEach((function(e){g.aliases[e]=[t].concat(g.aliases[t].filter((function(t){return e!==t})))})))}))}))}(n.key,r,n.default,g.arrays),Object.keys(a).forEach((function(t){(g.aliases[t]||[]).forEach((function(e){a[e]=a[t]}))}));let b=null;Object.keys(g.counts).find((t=>D(t,g.arrays)?(b=Error(p("Invalid configuration: %s, opts.count excludes opts.array.",t)),!0):!!D(t,g.nargs)&&(b=Error(p("Invalid configuration: %s, opts.count excludes opts.narg.",t)),!0)));let v=[];const w=Object.assign(Object.create(null),{_:[]}),O={};for(let t=0;t<s.length;t++){const e=s[t],n=e.replace(/^-{3,}/,"---");let i,r,a,c,l,h;if("--"!==e&&/^-/.test(e)&&T(e))k(e);else{if(n.match(/^---+(=|$)/)){k(e);continue}if(e.match(/^--.+=/)||!o["short-option-groups"]&&e.match(/^-.+=/))c=e.match(/^--?([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&(D(c[1],g.arrays)?t=j(t,c[1],s,c[2]):!1!==D(c[1],g.nargs)?t=E(t,c[1],s,c[2]):A(c[1],c[2],!0));else if(e.match(y)&&o["boolean-negation"])c=e.match(y),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],A(r,!!D(r,g.arrays)&&[!1]));else if(e.match(/^--.+/)||!o["short-option-groups"]&&e.match(/^-[^-]+/))c=e.match(/^--?(.+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],D(r,g.arrays)?t=j(t,r,s):!1!==D(r,g.nargs)?t=E(t,r,s):(l=s[t+1],void 0===l||l.match(/^-/)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(A(r,l),t++):A(r,V(r)):(A(r,l),t++)));else if(e.match(/^-.\..+=/))c=e.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&A(c[1],c[2]);else if(e.match(/^-.\..+/)&&!e.match(m))l=s[t+1],c=e.match(/^-(.\..+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],void 0===l||l.match(/^-/)||D(r,g.bools)||D(r,g.counts)?A(r,V(r)):(A(r,l),t++));else if(e.match(/^-[^-]+/)&&!e.match(m)){a=e.slice(1,-1).split(""),i=!1;for(let n=0;n<a.length;n++){if(l=e.slice(n+2),a[n+1]&&"="===a[n+1]){h=e.slice(n+3),r=a[n],D(r,g.arrays)?t=j(t,r,s,h):!1!==D(r,g.nargs)?t=E(t,r,s,h):A(r,h),i=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===D(l,g.bools)){A(a[n],l),i=!0;break}if(a[n+1]&&a[n+1].match(/\W/)){A(a[n],l),i=!0;break}A(a[n],V(a[n]))}else A(a[n],l)}r=e.slice(-1)[0],i||"-"===r||(D(r,g.arrays)?t=j(t,r,s):!1!==D(r,g.nargs)?t=E(t,r,s):(l=s[t+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(A(r,l),t++):A(r,V(r)):(A(r,l),t++)))}else if(e.match(/^-[0-9]$/)&&e.match(m)&&D(e.slice(1),g.bools))r=e.slice(1),A(r,V(r));else{if("--"===e){v=s.slice(t+1);break}if(o["halt-at-non-option"]){v=s.slice(t);break}k(e)}}}function k(t){const e=P("_",t);"string"!=typeof e&&"number"!=typeof e||w._.push(e)}function E(t,e,n,s){let i,r=D(e,g.nargs);if(r="number"!=typeof r||isNaN(r)?1:r,0===r)return B(s)||(b=Error(p("Argument unexpected for: %s",e))),A(e,V(e)),t;let a=B(s)?0:1;if(o["nargs-eats-options"])n.length-(t+1)+a<r&&(b=Error(p("Not enough arguments following: %s",e))),a=r;else{for(i=t+1;i<n.length&&(!n[i].match(/^-[^0-9]/)||n[i].match(m)||T(n[i]));i++)a++;a<r&&(b=Error(p("Not enough arguments following: %s",e)))}let c=Math.min(a,r);for(!B(s)&&c>0&&(A(e,s),c--),i=t+1;i<c+t+1;i++)A(e,n[i]);return t+c}function j(t,e,n,s){let r=[],c=s||n[t+1];const l=D(e,g.nargs);if(D(e,g.bools)&&!/^(true|false)$/.test(c))r.push(!0);else if(B(c)||B(s)&&/^-/.test(c)&&!m.test(c)&&!T(c)){if(void 0!==a[e]){const t=a[e];r=Array.isArray(t)?t:[t]}}else{B(s)||r.push(x(e,s,!0));for(let s=t+1;s<n.length&&!(!o["greedy-arrays"]&&r.length>0||l&&"number"==typeof l&&r.length>=l)&&(c=n[s],!/^-/.test(c)||m.test(c)||T(c));s++)t=s,r.push(x(e,c,i))}return"number"==typeof l&&(l&&r.length<l||isNaN(l)&&0===r.length)&&(b=Error(p("Not enough arguments following: %s",e))),A(e,r),t}function A(t,e,n=i){if(/-/.test(t)&&o["camel-case-expansion"]){const e=t.split(".").map((function(t){return I(t)})).join(".");_(t,e)}const s=x(t,e,n),r=t.split(".");if(N(w,r,s),g.aliases[t]&&g.aliases[t].forEach((function(t){const e=t.split(".");N(w,e,s)})),r.length>1&&o["dot-notation"]&&(g.aliases[r[0]]||[]).forEach((function(e){let n=e.split(".");const i=[].concat(r);i.shift(),n=n.concat(i),(g.aliases[t]||[]).includes(n.join("."))||N(w,n,s)})),D(t,g.normalize)&&!D(t,g.arrays)){[t].concat(g.aliases[t]||[]).forEach((function(t){Object.defineProperty(O,t,{enumerable:!0,get:()=>e,set(t){e="string"==typeof t?z.normalize(t):t}})}))}}function _(t,e){g.aliases[t]&&g.aliases[t].length||(g.aliases[t]=[e],u[e]=!0),g.aliases[e]&&g.aliases[e].length||_(e,t)}function x(t,e,n){n&&(e=function(t){return"string"!=typeof t||"'"!==t[0]&&'"'!==t[0]||t[t.length-1]!==t[0]?t:t.substring(1,t.length-1)}(e)),(D(t,g.bools)||D(t,g.counts))&&"string"==typeof e&&(e="true"===e);let s=Array.isArray(e)?e.map((function(e){return P(t,e)})):P(t,e);return D(t,g.counts)&&(B(s)||"boolean"==typeof s)&&(s=L()),D(t,g.normalize)&&D(t,g.arrays)&&(s=Array.isArray(e)?e.map((t=>z.normalize(t))):z.normalize(e)),s}function P(t,e){if(!o["parse-positional-numbers"]&&"_"===t)return e;if(!D(t,g.strings)&&!D(t,g.bools)&&!Array.isArray(e)){(R(e)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${e}`)))||!B(e)&&D(t,g.numbers))&&(e=Number(e))}return e}function $(t,e){Object.keys(t).forEach((function(n){const s=t[n],i=e?e+"."+n:n;"object"==typeof s&&null!==s&&!Array.isArray(s)&&o["dot-notation"]?$(s,i):(!M(w,i.split("."))||D(i,g.arrays)&&o["combine-arrays"])&&A(i,s)}))}function C(t,e){if(void 0===l)return;const n="string"==typeof l?l:"",s=z.env();Object.keys(s).forEach((function(i){if(""===n||0===i.lastIndexOf(n,0)){const r=i.split("__").map((function(t,e){return 0===e&&(t=t.substring(n.length)),I(t)}));(e&&g.configs[r.join(".")]||!e)&&!M(t,r)&&A(r.join("."),s[i])}}))}function S(t,e,n,s=!1){Object.keys(n).forEach((function(i){M(t,i.split("."))||(N(t,i.split("."),n[i]),s&&(f[i]=!0),(e[i]||[]).forEach((function(e){M(t,e.split("."))||N(t,e.split("."),n[i])})))}))}function M(t,e){let n=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){n=n[t]||{}}));const s=e[e.length-1];return"object"==typeof n&&s in n}function N(t,e,n){let s=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){t=U(t),"object"==typeof s&&void 0===s[t]&&(s[t]={}),"object"!=typeof s[t]||Array.isArray(s[t])?(Array.isArray(s[t])?s[t].push({}):s[t]=[s[t],{}],s=s[t][s[t].length-1]):s=s[t]}));const i=U(e[e.length-1]),r=D(e.join("."),g.arrays),a=Array.isArray(n);let c=o["duplicate-arguments-array"];!c&&D(i,g.nargs)&&(c=!0,(!B(s[i])&&1===g.nargs[i]||Array.isArray(s[i])&&s[i].length===g.nargs[i])&&(s[i]=void 0)),n===L()?s[i]=L(s[i]):Array.isArray(s[i])?c&&r&&a?s[i]=o["flatten-duplicate-arrays"]?s[i].concat(n):(Array.isArray(s[i][0])?s[i]:[s[i]]).concat([n]):c||Boolean(r)!==Boolean(a)?s[i]=s[i].concat([n]):s[i]=n:void 0===s[i]&&r?s[i]=a?n:[n]:!c||void 0===s[i]||D(i,g.counts)||D(i,g.bools)?s[i]=n:s[i]=[s[i],n]}function D(t,e){const n=[].concat(g.aliases[t]||[],t),s=Object.keys(e),i=n.find((t=>s.includes(t)));return!!i&&e[i]}function H(t){const e=Object.keys(g);return[].concat(e.map((t=>g[t]))).some((function(e){return Array.isArray(e)?e.includes(t):e[t]}))}function T(t){return o["unknown-options-as-args"]&&function(t){if(t=t.replace(/^-{3,}/,"--"),t.match(m))return!1;if(function(t){if(t.match(m)||!t.match(/^-[^-]+/))return!1;let e,n=!0;const s=t.slice(1).split("");for(let i=0;i<s.length;i++){if(e=t.slice(i+2),!H(s[i])){n=!1;break}if(s[i+1]&&"="===s[i+1]||"-"===e||/[A-Za-z]/.test(s[i])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(e)||s[i+1]&&s[i+1].match(/\W/))break}return n}(t))return!1;return!function(t,...e){return[].concat(...e).some((function(e){const n=t.match(e);return n&&H(n[1])}))}(t,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}(t)}function V(t){return D(t,g.bools)||D(t,g.counts)||!(`${t}`in a)?(e=function(t){let e=F.BOOLEAN;return D(t,g.strings)?e=F.STRING:D(t,g.numbers)?e=F.NUMBER:D(t,g.bools)?e=F.BOOLEAN:D(t,g.arrays)&&(e=F.ARRAY),e}(t),{[F.BOOLEAN]:!0,[F.STRING]:"",[F.NUMBER]:void 0,[F.ARRAY]:[]}[e]):a[t];var e}function B(t){return void 0===t}return C(w,!0),C(w,!1),function(t){const e=Object.create(null);S(e,g.aliases,a),Object.keys(g.configs).forEach((function(n){const s=t[n]||e[n];if(s)try{let t=null;const e=z.resolve(z.cwd(),s),i=g.configs[n];if("function"==typeof i){try{t=i(e)}catch(e){t=e}if(t instanceof Error)return void(b=t)}else t=z.require(e);$(t)}catch(e){"PermissionDenied"===e.name?b=e:t[n]&&(b=Error(p("Invalid JSON config file: %s",s)))}}))}(w),void 0!==c&&c.forEach((function(t){$(t)})),S(w,g.aliases,a,!0),function(t){let e;const n=new Set;Object.keys(t).forEach((function(s){if(!n.has(s)&&(e=D(s,g.coercions),"function"==typeof e))try{const i=P(s,e(t[s]));[].concat(g.aliases[s]||[],s).forEach((e=>{n.add(e),t[e]=i}))}catch(t){b=t}}))}(w),o["set-placeholder-key"]&&function(t){g.keys.forEach((e=>{~e.indexOf(".")||void 0===t[e]&&(t[e]=void 0)}))}(w),Object.keys(g.counts).forEach((function(t){M(w,t.split("."))||A(t,0)})),h&&v.length&&(w[d]=[]),v.forEach((function(t){w[d].push(t)})),o["camel-case-expansion"]&&o["strip-dashed"]&&Object.keys(w).filter((t=>"--"!==t&&t.includes("-"))).forEach((t=>{delete w[t]})),o["strip-aliased"]&&[].concat(...Object.keys(r).map((t=>r[t]))).forEach((t=>{o["camel-case-expansion"]&&t.includes("-")&&delete w[t.split(".").map((t=>I(t))).join(".")],delete w[t]})),{aliases:Object.assign({},g.aliases),argv:Object.assign(O,w),configuration:o,defaulted:Object.assign({},f),error:b,newAliases:Object.assign({},u)}}}({cwd:process.cwd,env:()=>Y,format:g,normalize:s,resolve:e,require:t=>{if("undefined"!=typeof require)return require(t);if(t.match(/\.json$/))return JSON.parse(f(t,"utf8"));throw Error("only .json config files are supported in ESM")}}),G=function(t,e){return J.parse(t.slice(),e).argv};function K(){return process.versions.electron&&!process.defaultApp?0:1}G.detailed=function(t,e){return J.parse(t.slice(),e)},G.camelCase=I,G.decamelize=W,G.looksLikeNumber=R;class Q extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,Q)}}var Z={fs:{readFileSync:f,writeFile:p},format:g,resolve:e,exists:t=>{try{return d(t).isFile()}catch(t){return!1}}};let X;class tt{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles="boolean"!=typeof t.updateFiles||t.updateFiles,this.locale=t.locale||"en",this.fallbackToLanguage="boolean"!=typeof t.fallbackToLanguage||t.fallbackToLanguage,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if("string"!=typeof arguments[0])return this._taggedLiteral(arguments[0],...arguments);const e=t.shift();let n=function(){};return"function"==typeof t[t.length-1]&&(n=t.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),X.format.apply(X.format,[this.cache[this.locale][e]||e].concat(t))}__n(){const t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),s=t.shift();let i=function(){};"function"==typeof t[t.length-1]&&(i=t.pop()),this.cache[this.locale]||this._readLocaleFile();let r=1===s?e:n;if(this.cache[this.locale][e]){r=this.cache[this.locale][e][1===s?"one":"other"]}!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();const o=[r];return~r.indexOf("%d")&&o.push(s),X.format.apply(X.format,o.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let n="";return t.forEach((function(t,s){const i=e[s+1];n+=t,void 0!==i&&(n+="%s")})),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),1===this.writeQueue.length&&this._processWriteQueue()}_processWriteQueue(){const t=this,e=this.writeQueue[0],n=e.directory,s=e.locale,i=e.cb,r=this._resolveLocaleFile(n,s),o=JSON.stringify(this.cache[s],null,2);X.fs.writeFile(r,o,"utf-8",(function(e){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),i(e)}))}_readLocaleFile(){let t={};const e=this._resolveLocaleFile(this.directory,this.locale);try{X.fs.readFileSync&&(t=JSON.parse(X.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),"ENOENT"!==n.code)throw n;t={}}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=X.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const s=X.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(t){return X.exists(t)}}const et="loading a directory of commands is not supported yet for ESM";let nt;try{nt=y(import.meta.url)}catch(t){nt=process.cwd()}var st,it={assert:{notStrictEqual:c,strictEqual:l},cliui:function(t){return function(t,e){return S=e,new $({width:(null==t?void 0:t.width)||("object"==typeof process&&process.stdout&&process.stdout.columns?process.stdout.columns:80),wrap:null==t?void 0:t.wrap})}(t,{stringWidth:t=>[...t].length,stripAnsi:N,wrap:D})},findUp:function(t,s){let i,r=e(".",t);for(d(r).isDirectory()||(r=n(r));;){if(i=s(r,u(r)),i)return e(r,i);if(r=n(i=r),i===r)break}},getEnv:t=>process.env[t],inspect:m,getCallerFile:()=>{throw new Q(et)},getProcessArgvBin:function(){return process.argv[K()]},mainFilename:nt.substring(0,nt.lastIndexOf("node_modules"))||process.cwd(),Parser:G,path:{basename:i,dirname:n,extname:r,relative:o,resolve:e},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(t,e)=>process.emitWarning(t,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:void 0!==process.stdout.columns?process.stdout.columns:null},readFileSync:f,require:()=>{throw new Q("require is not supported by ESM")},requireDirectory:()=>{throw new Q(et)},stringWidth:t=>[...t].length,y18n:(st={directory:e(nt,"../../../locales"),updateFiles:!1},function(t,e){X=e;const n=new tt(t);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}(st,Z))};function rt(t,e,n,s){n.assert.notStrictEqual(t,e,s)}function ot(t,e){e.assert.strictEqual(typeof t,"string")}function at(t){return Object.keys(t)}function ct(t){return!!t&&!!t.then&&"function"==typeof t.then}function lt(t){const e=t.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,s=e.shift();if(!s)throw new Error(`No command found in: ${t}`);const i={cmd:s.replace(n,""),demanded:[],optional:[]};return e.forEach(((t,s)=>{let r=!1;t=t.replace(/\s/g,""),/\.+[\]>]/.test(t)&&s===e.length-1&&(r=!0),/^\[/.test(t)?i.optional.push({cmd:t.replace(n,"").split("|"),variadic:r}):i.demanded.push({cmd:t.replace(n,"").split("|"),variadic:r})})),i}const ht=["first","second","third","fourth","fifth","sixth"];function dt(t,e,n){try{let s=0;const[i,r,o]="object"==typeof t?[{demanded:[],optional:[]},t,e]:[lt(`cmd ${t}`),e,n],a=[].slice.call(r);for(;a.length&&void 0===a[a.length-1];)a.pop();const c=o||a.length;if(c<i.demanded.length)throw new Q(`Not enough arguments provided. Expected ${i.demanded.length} but received ${a.length}.`);const l=i.demanded.length+i.optional.length;if(c>l)throw new Q(`Too many arguments provided. Expected max ${l} but received ${c}.`);i.demanded.forEach((t=>{const e=ut(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&ft(e,t.cmd,s),s+=1})),i.optional.forEach((t=>{if(0===a.length)return;const e=ut(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&ft(e,t.cmd,s),s+=1}))}catch(t){console.warn(t.stack)}}function ut(t){return Array.isArray(t)?"array":null===t?"null":typeof t}function ft(t,e,n){throw new Q(`Invalid ${ht[n]||"manyith"} argument. Expected ${e.join(" or ")} but received ${t}.`)}class pt{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,s=!1){if(dt("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let s=0;s<t.length;s++){if("function"!=typeof t[s])throw Error("middleware must be a function");const i=t[s];i.applyBeforeValidation=e,i.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if("function"==typeof t){const i=t;i.applyBeforeValidation=e,i.global=n,i.mutates=s,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){const n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((t=>{const s=[...n[e]||[],e];return!t.option||!s.includes(t.option)})),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const t=this.frozens.pop();void 0!==t&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter((t=>t.global))}}function gt(t,e,n,s){return n.reduce(((t,n)=>{if(n.applyBeforeValidation!==s)return t;if(n.mutates){if(n.applied)return t;n.applied=!0}if(ct(t))return t.then((t=>Promise.all([t,n(t,e)]))).then((([t,e])=>Object.assign(t,e)));{const s=n(t,e);return ct(s)?s.then((e=>Object.assign(t,e))):Object.assign(t,s)}}),t)}function mt(t,e,n=(t=>{throw t})){try{const n="function"==typeof t?t():t;return ct(n)?n.then((t=>e(t))):e(n)}catch(t){return n(t)}}const yt=/(^\*)|(^\$0)/;class bt{constructor(t,e,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,s){"boolean"!=typeof(s=s||{}).recurse&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);const i="function"==typeof s.visit?s.visit:t=>t;s.visit=(t,e,n)=>{const s=i(t,e,n);if(s){if(this.requireCache.has(e))return s;this.requireCache.add(e),this.addHandler(s)}return s},this.shim.requireDirectory({require:e,filename:n},t,s)}addHandler(t,e,n,s,i,r){let o=[];const a=function(t){return t?t.map((t=>(t.applyBeforeValidation=!1,t))):[]}(i);if(s=s||(()=>{}),Array.isArray(t))if(function(t){return t.every((t=>"string"==typeof t))}(t))[t,...o]=t;else for(const e of t)this.addHandler(e);else{if(function(t){return"object"==typeof t&&!Array.isArray(t)}(t)){let e=Array.isArray(t.command)||"string"==typeof t.command?t.command:this.moduleName(t);return t.aliases&&(e=[].concat(e).concat(t.aliases)),void this.addHandler(e,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated)}if(vt(n))return void this.addHandler([t].concat(o),e,n.builder,n.handler,n.middlewares,n.deprecated)}if("string"==typeof t){const i=lt(t);o=o.map((t=>lt(t).cmd));let c=!1;const l=[i.cmd].concat(o).filter((t=>!yt.test(t)||(c=!0,!1)));0===l.length&&c&&l.push("$0"),c&&(i.cmd=l[0],o=l.slice(1),t=t.replace(yt,i.cmd)),o.forEach((t=>{this.aliasMap[t]=i.cmd})),!1!==e&&this.usage.command(t,e,c,o,r),this.handlers[i.cmd]={original:t,description:e,handler:s,builder:n||{},middlewares:a,deprecated:r,demanded:i.demanded,optional:i.optional},c&&(this.defaultCommand=this.handlers[i.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,s,i,r){const o=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,a=e.getInternalMethods().getContext(),c=a.commands.slice(),l=!t;t&&(a.commands.push(t),a.fullCommands.push(o.original));const h=this.applyBuilderUpdateUsageAndParse(l,o,e,n.aliases,c,s,i,r);return ct(h)?h.then((t=>this.applyMiddlewareAndGetResult(l,o,t.innerArgv,a,i,t.aliases,e))):this.applyMiddlewareAndGetResult(l,o,h.innerArgv,a,i,h.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,s,i,r,o,a){const c=e.builder;let l=n;if(wt(c)){n.getInternalMethods().getUsageInstance().freeze();const h=c(n.getInternalMethods().reset(s),a);if(ct(h))return h.then((s=>{var a;return l=(a=s)&&"function"==typeof a.getInternalMethods?s:n,this.parseAndUpdateUsage(t,e,l,i,r,o)}))}else(function(t){return"object"==typeof t})(c)&&(n.getInternalMethods().getUsageInstance().freeze(),l=n.getInternalMethods().reset(s),Object.keys(e.builder).forEach((t=>{l.option(t,c[t])})));return this.parseAndUpdateUsage(t,e,l,i,r,o)}parseAndUpdateUsage(t,e,n,s,i,r){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(s,e),e.description);const o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,r);return ct(o)?o.then((t=>({aliases:n.parsed.aliases,innerArgv:t}))):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&0===t.getInternalMethods().getUsageInstance().getUsage().length}usageFromParentCommandsCommandHandler(t,e){const n=yt.test(e.original)?e.original.replace(yt,"").trim():e.original,s=t.filter((t=>!yt.test(t)));return s.push(n),`$0 ${s.join(" ")}`}handleValidationAndGetResult(t,e,n,s,i,r,o,a){if(!r.getInternalMethods().getHasOutput()){const e=r.getInternalMethods().runValidation(i,a,r.parsed.error,t);n=mt(n,(t=>(e(t),t)))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const s=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(n,s,!1,!1),n=mt(n=gt(n,r,o,!1),(t=>{const n=e.handler(t);return ct(n)?n.then((()=>t)):t})),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),ct(n)&&!r.getInternalMethods().hasParseCallback()&&n.catch((t=>{try{r.getInternalMethods().getUsageInstance().fail(null,t)}catch(t){}}))}return t||(s.commands.pop(),s.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,s,i,r,o){let a={};if(i)return n;o.getInternalMethods().getHasOutput()||(a=this.populatePositionals(e,n,s,o));const c=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),l=gt(n,o,c,!0);return ct(l)?l.then((n=>this.handleValidationAndGetResult(t,e,n,s,r,o,c,a))):this.handleValidationAndGetResult(t,e,l,s,r,o,c,a)}populatePositionals(t,e,n,s){e._=e._.slice(n.commands.length);const i=t.demanded.slice(0),r=t.optional.slice(0),o={};for(this.validation.positionalCount(i.length,e._.length);i.length;){const t=i.shift();this.populatePositional(t,e,o)}for(;r.length;){const t=r.shift();this.populatePositional(t,e,o)}return e._=n.commands.concat(e._.map((t=>""+t))),this.postProcessPositionals(e,o,this.cmdToParseOptions(t.original),s),o}populatePositional(t,e,n){const s=t.cmd[0];t.variadic?n[s]=e._.splice(0).map(String):e._.length&&(n[s]=[String(e._.shift())])}cmdToParseOptions(t){const e={array:[],default:{},alias:{},demand:{}},n=lt(t);return n.demanded.forEach((t=>{const[n,...s]=t.cmd;t.variadic&&(e.array.push(n),e.default[n]=[]),e.alias[n]=s,e.demand[n]=!0})),n.optional.forEach((t=>{const[n,...s]=t.cmd;t.variadic&&(e.array.push(n),e.default[n]=[]),e.alias[n]=s})),e}postProcessPositionals(t,e,n,s){const i=Object.assign({},s.getOptions());i.default=Object.assign(n.default,i.default);for(const t of Object.keys(n.alias))i.alias[t]=(i.alias[t]||[]).concat(n.alias[t]);i.array=i.array.concat(n.array),i.config={};const r=[];if(Object.keys(e).forEach((t=>{e[t].map((e=>{i.configuration["unknown-options-as-args"]&&(i.key[t]=!0),r.push(`--${t}`),r.push(e)}))})),!r.length)return;const o=Object.assign({},i.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},i,{configuration:o}));if(a.error)s.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{const n=Object.keys(e);Object.keys(e).forEach((t=>{n.push(...a.aliases[t])})),Object.keys(a.argv).forEach((i=>{n.includes(i)&&(e[i]||(e[i]=a.argv[i]),!this.isInConfigs(s,i)&&!this.isDefaulted(s,i)&&Object.prototype.hasOwnProperty.call(t,i)&&Object.prototype.hasOwnProperty.call(a.argv,i)&&(Array.isArray(t[i])||Array.isArray(a.argv[i]))?t[i]=[].concat(t[i],a.argv[i]):t[i]=a.argv[i])}))}}isDefaulted(t,e){const{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){const{configObjects:n}=t.getOptions();return n.some((t=>Object.prototype.hasOwnProperty.call(t,e)))||n.some((t=>Object.prototype.hasOwnProperty.call(t,this.shim.Parser.camelCase(e))))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){const e=yt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(e,this.defaultCommand.description)}const e=this.defaultCommand.builder;if(wt(e))return e(t,!0);vt(e)||Object.keys(e).forEach((n=>{t.option(n,e[n])}))}moduleName(t){const e=function(t){if("undefined"==typeof require)return null;for(let e,n=0,s=Object.keys(require.cache);n<s.length;n++)if(e=require.cache[s[n]],e.exports===t)return e;return null}(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(const s of[t,e,n]){if("string"==typeof s||!1===s)return s;rt(s,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const t=this.frozens.pop();rt(t,void 0,this.shim),({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t)}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function vt(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function wt(t){return"function"==typeof t}function Ot(t={},e=(()=>!0)){const n={};return at(t).forEach((s=>{e(s,t[s])&&(n[s]=t[s])})),n}function kt(t){"undefined"!=typeof process&&[process.stdout,process.stderr].forEach((e=>{const n=e;n._handle&&n.isTTY&&"function"==typeof n._handle.setBlocking&&n._handle.setBlocking(t)}))}function Et(t){return"boolean"==typeof t}function jt(t,e){const n=e.y18n.__,s={},i=[];s.failFn=function(t){i.push(t)};let r=null,o=null,a=!0;s.showHelpOnFail=function(e=!0,n){const[i,c]="string"==typeof e?[!0,e]:[e,n];return t.getInternalMethods().isGlobalContext()&&(o=c),r=c,a=i,s};let c=!1;s.fail=function(e,n){const l=t.getInternalMethods().getLoggerInstance();if(!i.length){if(t.getExitProcess()&&kt(!0),!c){c=!0,a&&(t.showHelp("error"),l.error()),(e||n)&&l.error(e||n);const s=r||o;s&&((e||n)&&l.error(""),l.error(s))}if(n=n||new Q(e),t.getExitProcess())return t.exit(1);if(t.getInternalMethods().hasParseCallback())return t.exit(1,n);throw n}for(let t=i.length-1;t>=0;--t){const r=i[t];if(Et(r)){if(n)throw n;if(e)throw Error(e)}else r(e,n,s)}};let l=[],h=!1;s.usage=(t,e)=>null===t?(h=!0,l=[],s):(h=!1,l.push([t,e||""]),s),s.getUsage=()=>l,s.getUsageDisabled=()=>h,s.getPositionalGroupName=()=>n("Positionals:");let d=[];s.example=(t,e)=>{d.push([t,e||""])};let u=[];s.command=function(t,e,n,s,i=!1){n&&(u=u.map((t=>(t[2]=!1,t)))),u.push([t,e||"",n,s,i])},s.getCommands=()=>u;let f={};s.describe=function(t,e){Array.isArray(t)?t.forEach((t=>{s.describe(t,e)})):"object"==typeof t?Object.keys(t).forEach((e=>{s.describe(e,t[e])})):f[t]=e},s.getDescriptions=()=>f;let p=[];s.epilog=t=>{p.push(t)};let g,m=!1;s.wrap=t=>{m=!0,g=t},s.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(m||(g=function(){const t=80;return e.process.stdColumns?Math.min(t,e.process.stdColumns):t}(),m=!0),g);const y="__yargsString__:";function b(t,n,s){let i=0;return Array.isArray(t)||(t=Object.values(t).map((t=>[t]))),t.forEach((t=>{i=Math.max(e.stringWidth(s?`${s} ${xt(t[0])}`:xt(t[0]))+_t(t[0]),i)})),n&&(i=Math.min(i,parseInt((.5*n).toString(),10))),i}let v;function w(e){return t.getOptions().hiddenOptions.indexOf(e)<0||t.parsed.argv[t.getOptions().showHiddenOpt]}function O(t,e){let s=`[${n("default:")} `;if(void 0===t&&!e)return null;if(e)s+=e;else switch(typeof t){case"string":s+=`"${t}"`;break;case"object":s+=JSON.stringify(t);break;default:s+=t}return`${s}]`}s.deferY18nLookup=t=>y+t,s.help=function(){if(v)return v;!function(){const e=t.getDemandedOptions(),n=t.getOptions();(Object.keys(n.alias)||[]).forEach((i=>{n.alias[i].forEach((r=>{f[r]&&s.describe(i,f[r]),r in e&&t.demandOption(i,e[r]),n.boolean.includes(r)&&t.boolean(i),n.count.includes(r)&&t.count(i),n.string.includes(r)&&t.string(i),n.normalize.includes(r)&&t.normalize(i),n.array.includes(r)&&t.array(i),n.number.includes(r)&&t.number(i)}))}))}();const i=t.customScriptName?t.$0:e.path.basename(t.$0),r=t.getDemandedOptions(),o=t.getDemandedCommands(),a=t.getDeprecatedOptions(),c=t.getGroups(),g=t.getOptions();let m=[];m=m.concat(Object.keys(f)),m=m.concat(Object.keys(r)),m=m.concat(Object.keys(o)),m=m.concat(Object.keys(g.default)),m=m.filter(w),m=Object.keys(m.reduce(((t,e)=>("_"!==e&&(t[e]=!0),t)),{}));const k=s.getWrap(),E=e.cliui({width:k,wrap:!!k});if(!h)if(l.length)l.forEach((t=>{E.div({text:`${t[0].replace(/\$0/g,i)}`}),t[1]&&E.div({text:`${t[1]}`,padding:[1,0,0,0]})})),E.div();else if(u.length){let t=null;t=o._?`${i} <${n("command")}>\n`:`${i} [${n("command")}]\n`,E.div(`${t}`)}if(u.length>1||1===u.length&&!u[0][2]){E.div(n("Commands:"));const e=t.getInternalMethods().getContext(),s=e.commands.length?`${e.commands.join(" ")} `:"";!0===t.getInternalMethods().getParserConfiguration()["sort-commands"]&&(u=u.sort(((t,e)=>t[0].localeCompare(e[0]))));const r=i?`${i} `:"";u.forEach((t=>{const e=`${r}${s}${t[0].replace(/^\$0 ?/,"")}`;E.span({text:e,padding:[0,2,0,2],width:b(u,k,`${i}${s}`)+4},{text:t[1]});const o=[];t[2]&&o.push(`[${n("default")}]`),t[3]&&t[3].length&&o.push(`[${n("aliases:")} ${t[3].join(", ")}]`),t[4]&&("string"==typeof t[4]?o.push(`[${n("deprecated: %s",t[4])}]`):o.push(`[${n("deprecated")}]`)),o.length?E.div({text:o.join(" "),padding:[0,0,0,2],align:"right"}):E.div()})),E.div()}const j=(Object.keys(g.alias)||[]).concat(Object.keys(t.parsed.newAliases)||[]);m=m.filter((e=>!t.parsed.newAliases[e]&&j.every((t=>-1===(g.alias[t]||[]).indexOf(e)))));const A=n("Options:");c[A]||(c[A]=[]),function(t,e,n,s){let i=[],r=null;Object.keys(n).forEach((t=>{i=i.concat(n[t])})),t.forEach((t=>{r=[t].concat(e[t]),r.some((t=>-1!==i.indexOf(t)))||n[s].push(t)}))}(m,g.alias,c,A);const _=t=>/^--/.test(xt(t)),x=Object.keys(c).filter((t=>c[t].length>0)).map((t=>({groupName:t,normalizedKeys:c[t].filter(w).map((t=>{if(j.includes(t))return t;for(let e,n=0;void 0!==(e=j[n]);n++)if((g.alias[e]||[]).includes(t))return e;return t}))}))).filter((({normalizedKeys:t})=>t.length>0)).map((({groupName:t,normalizedKeys:e})=>{const n=e.reduce(((e,n)=>(e[n]=[n].concat(g.alias[n]||[]).map((e=>t===s.getPositionalGroupName()?e:(/^[0-9]$/.test(e)?g.boolean.includes(n)?"-":"--":e.length>1?"--":"-")+e)).sort(((t,e)=>_(t)===_(e)?0:_(t)?1:-1)).join(", "),e)),{});return{groupName:t,normalizedKeys:e,switches:n}}));if(x.filter((({groupName:t})=>t!==s.getPositionalGroupName())).some((({normalizedKeys:t,switches:e})=>!t.every((t=>_(e[t])))))&&x.filter((({groupName:t})=>t!==s.getPositionalGroupName())).forEach((({normalizedKeys:t,switches:e})=>{t.forEach((t=>{var n,s;_(e[t])&&(e[t]=(n=e[t],s=4,At(n)?{text:n.text,indentation:n.indentation+s}:{text:n,indentation:s}))}))})),x.forEach((({groupName:e,normalizedKeys:i,switches:o})=>{E.div(e),i.forEach((e=>{const i=o[e];let c=f[e]||"",l=null;c.includes(y)&&(c=n(c.substring(16))),g.boolean.includes(e)&&(l=`[${n("boolean")}]`),g.count.includes(e)&&(l=`[${n("count")}]`),g.string.includes(e)&&(l=`[${n("string")}]`),g.normalize.includes(e)&&(l=`[${n("string")}]`),g.array.includes(e)&&(l=`[${n("array")}]`),g.number.includes(e)&&(l=`[${n("number")}]`);const h=[e in a?(d=a[e],"string"==typeof d?`[${n("deprecated: %s",d)}]`:`[${n("deprecated")}]`):null,l,e in r?`[${n("required")}]`:null,g.choices&&g.choices[e]?`[${n("choices:")} ${s.stringifiedValues(g.choices[e])}]`:null,O(g.default[e],g.defaultDescription[e])].filter(Boolean).join(" ");var d;E.span({text:xt(i),padding:[0,2,0,2+_t(i)],width:b(o,k)+4},c);const u=!0===t.getInternalMethods().getUsageConfiguration()["hide-types"];h&&!u?E.div({text:h,padding:[0,0,0,2],align:"right"}):E.div()})),E.div()})),d.length&&(E.div(n("Examples:")),d.forEach((t=>{t[0]=t[0].replace(/\$0/g,i)})),d.forEach((t=>{""===t[1]?E.div({text:t[0],padding:[0,2,0,2]}):E.div({text:t[0],padding:[0,2,0,2],width:b(d,k)+4},{text:t[1]})})),E.div()),p.length>0){const t=p.map((t=>t.replace(/\$0/g,i))).join("\n");E.div(`${t}\n`)}return E.toString().replace(/\s*$/,"")},s.cacheHelpMessage=function(){v=this.help()},s.clearCachedHelpMessage=function(){v=void 0},s.hasCachedHelpMessage=function(){return!!v},s.showHelp=e=>{const n=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:n[e])(s.help())},s.functionDescription=t=>["(",t.name?e.Parser.decamelize(t.name,"-"):n("generated-value"),")"].join(""),s.stringifiedValues=function(t,e){let n="";const s=e||", ",i=[].concat(t);return t&&i.length?(i.forEach((t=>{n.length&&(n+=s),n+=JSON.stringify(t)})),n):n};let k=null;s.version=t=>{k=t},s.showVersion=e=>{const n=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:n[e])(k)},s.reset=function(t){return r=null,c=!1,l=[],h=!1,p=[],d=[],u=[],f=Ot(f,(e=>!t[e])),s};const E=[];return s.freeze=function(){E.push({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f})},s.unfreeze=function(t=!1){const e=E.pop();e&&(t?(f={...e.descriptions,...f},u=[...e.commands,...u],l=[...e.usages,...l],d=[...e.examples,...d],p=[...e.epilogs,...p]):({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f}=e))},s}function At(t){return"object"==typeof t}function _t(t){return At(t)?t.indentation:0}function xt(t){return At(t)?t.text:t}class Pt{constructor(t,e,n,s){var i,r,o;this.yargs=t,this.usage=e,this.command=n,this.shim=s,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=null!==(o=(null===(i=this.shim.getEnv("SHELL"))||void 0===i?void 0:i.includes("zsh"))||(null===(r=this.shim.getEnv("ZSH_NAME"))||void 0===r?void 0:r.includes("zsh")))&&void 0!==o&&o}defaultCompletion(t,e,n,s){const i=this.command.getCommandHandlers();for(let e=0,n=t.length;e<n;++e)if(i[t[e]]&&i[t[e]].builder){const n=i[t[e]].builder;if(wt(n)){this.indexAfterLastReset=e+1;const t=this.yargs.getInternalMethods().reset();return n(t,!0),t.argv}}const r=[];this.commandCompletions(r,t,n),this.optionCompletions(r,t,e,n),this.choicesFromOptionsCompletions(r,t,e,n),this.choicesFromPositionalsCompletions(r,t,e,n),s(null,r)}commandCompletions(t,e,n){const s=this.yargs.getInternalMethods().getContext().commands;n.match(/^-/)||s[s.length-1]===n||this.previousArgHasChoices(e)||this.usage.getCommands().forEach((n=>{const s=lt(n[0]).cmd;if(-1===e.indexOf(s))if(this.zshShell){const e=n[1]||"";t.push(s.replace(/:/g,"\\:")+":"+e)}else t.push(s)}))}optionCompletions(t,e,n,s){if((s.match(/^-/)||""===s&&0===t.length)&&!this.previousArgHasChoices(e)){const n=this.yargs.getOptions(),i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(n.key).forEach((r=>{const o=!!n.configuration["boolean-negation"]&&n.boolean.includes(r);i.includes(r)||n.hiddenOptions.includes(r)||this.argsContainKey(e,r,o)||this.completeOptionKey(r,t,s,o&&!!n.default[r])}))}}choicesFromOptionsCompletions(t,e,n,s){if(this.previousArgHasChoices(e)){const n=this.getPreviousArgChoices(e);n&&n.length>0&&t.push(...n.map((t=>t.replace(/:/g,"\\:"))))}}choicesFromPositionalsCompletions(t,e,n,s){if(""===s&&t.length>0&&this.previousArgHasChoices(e))return;const i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=i[n._.length-r-1];if(!o)return;const a=this.yargs.getOptions().choices[o]||[];for(const e of a)e.startsWith(s)&&t.push(e.replace(/:/g,"\\:"))}getPreviousArgChoices(t){if(t.length<1)return;let e=t[t.length-1],n="";if(!e.startsWith("-")&&t.length>1&&(n=e,e=t[t.length-2]),!e.startsWith("-"))return;const s=e.replace(/^-+/,""),i=this.yargs.getOptions(),r=[s,...this.yargs.getAliases()[s]||[]];let o;for(const t of r)if(Object.prototype.hasOwnProperty.call(i.key,t)&&Array.isArray(i.choices[t])){o=i.choices[t];break}return o?o.filter((t=>!n||t.startsWith(n))):void 0}previousArgHasChoices(t){const e=this.getPreviousArgChoices(t);return void 0!==e&&e.length>0}argsContainKey(t,e,n){const s=e=>-1!==t.indexOf((/^[^0-9]$/.test(e)?"-":"--")+e);if(s(e))return!0;if(n&&s(`no-${e}`))return!0;if(this.aliases)for(const t of this.aliases[e])if(s(t))return!0;return!1}completeOptionKey(t,e,n,s){var i,r,o,a;let c=t;if(this.zshShell){const e=this.usage.getDescriptions(),n=null===(r=null===(i=null==this?void 0:this.aliases)||void 0===i?void 0:i[t])||void 0===r?void 0:r.find((t=>{const n=e[t];return"string"==typeof n&&n.length>0})),s=n?e[n]:void 0,l=null!==(a=null!==(o=e[t])&&void 0!==o?o:s)&&void 0!==a?a:"";c=`${t.replace(/:/g,"\\:")}:${l.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}const l=!/^--/.test(n)&&(t=>/^[^0-9]$/.test(t))(t)?"-":"--";e.push(l+c),s&&e.push(l+"no-"+c)}customCompletion(t,e,n,s){if(rt(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const t=this.customCompletionFunction(n,e);return ct(t)?t.then((t=>{this.shim.process.nextTick((()=>{s(null,t)}))})).catch((t=>{this.shim.process.nextTick((()=>{s(t,void 0)}))})):s(null,t)}return function(t){return t.length>3}(this.customCompletionFunction)?this.customCompletionFunction(n,e,((i=s)=>this.defaultCompletion(t,e,n,i)),(t=>{s(null,t)})):this.customCompletionFunction(n,e,(t=>{s(null,t)}))}getCompletion(t,e){const n=t.length?t[t.length-1]:"",s=this.yargs.parse(t,!0),i=this.customCompletionFunction?s=>this.customCompletion(t,s,n,e):s=>this.defaultCompletion(t,s,n,e);return ct(s)?s.then(i):i(s)}generateCompletionScript(t,e){let n=this.zshShell?'#compdef {{app_name}}\n###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc\n# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local reply\n local si=$IFS\n IFS=$\'\n\' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "${words[@]}"))\n IFS=$si\n _describe \'values\' reply\n}\ncompdef _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n':'###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc\n# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local cur_word args type_list\n\n cur_word="${COMP_WORDS[COMP_CWORD]}"\n args=("${COMP_WORDS[@]}")\n\n # ask yargs to generate completions.\n type_list=$({{app_path}} --get-yargs-completions "${args[@]}")\n\n COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )\n\n # if no match was found, fall back to filename completion\n if [ ${#COMPREPLY[@]} -eq 0 ]; then\n COMPREPLY=()\n fi\n\n return 0\n}\ncomplete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n';const s=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),n=n.replace(/{{app_name}}/g,s),n=n.replace(/{{completion_command}}/g,e),n.replace(/{{app_path}}/g,t)}registerFunction(t){this.customCompletionFunction=t}setParsed(t){this.aliases=t.aliases}}function $t(t,e){if(0===t.length)return e.length;if(0===e.length)return t.length;const n=[];let s,i;for(s=0;s<=e.length;s++)n[s]=[s];for(i=0;i<=t.length;i++)n[0][i]=i;for(s=1;s<=e.length;s++)for(i=1;i<=t.length;i++)e.charAt(s-1)===t.charAt(i-1)?n[s][i]=n[s-1][i-1]:s>1&&i>1&&e.charAt(s-2)===t.charAt(i-1)&&e.charAt(s-1)===t.charAt(i-2)?n[s][i]=n[s-2][i-2]+1:n[s][i]=Math.min(n[s-1][i-1]+1,Math.min(n[s][i-1]+1,n[s-1][i]+1));return n[e.length][t.length]}const Ct=["$0","--","_"];let St,Mt=[];function Nt(t,e,n,s){St=s;let i={};if(Object.prototype.hasOwnProperty.call(t,"extends")){if("string"!=typeof t.extends)return i;const s=/\.json|\..*rc$/.test(t.extends);let r=null;if(s)r=function(t,e){return St.path.resolve(t,e)}(e,t.extends);else try{r=require.resolve(t.extends)}catch(e){return t}!function(t){if(Mt.indexOf(t)>-1)throw new Q(`Circular extended configurations: '${t}'.`)}(r),Mt.push(r),i=s?JSON.parse(St.readFileSync(r,"utf8")):require(t.extends),delete t.extends,i=Nt(i,St.path.dirname(r),n,St)}return Mt=[],n?Dt(i,t):Object.assign({},i,t)}function Dt(t,e){const n={};function s(t){return t&&"object"==typeof t&&!Array.isArray(t)}Object.assign(n,t);for(const i of Object.keys(e))s(e[i])&&s(n[i])?n[i]=Dt(t[i],e[i]):n[i]=e[i];return n}var It,Wt,Rt,Ft,zt,Lt,Ut,Ht,Tt,Vt,Bt,qt,Yt,Jt,Gt,Kt,Qt,Zt,Xt,te,ee,ne,se,ie,re,oe,ae,ce,le,he,de,ue,fe,pe,ge,me=function(t,e,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(t,n):i?i.value=n:e.set(t,n),n},ye=function(t,e,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(t):s?s.value:e.get(t)};const be=Symbol("copyDoubleDash"),ve=Symbol("copyDoubleDash"),we=Symbol("deleteFromParserHintObject"),Oe=Symbol("emitWarning"),ke=Symbol("freeze"),Ee=Symbol("getDollarZero"),je=Symbol("getParserConfiguration"),Ae=Symbol("getUsageConfiguration"),_e=Symbol("guessLocale"),xe=Symbol("guessVersion"),Pe=Symbol("parsePositionalNumbers"),$e=Symbol("pkgUp"),Ce=Symbol("populateParserHintArray"),Se=Symbol("populateParserHintSingleValueDictionary"),Me=Symbol("populateParserHintArrayDictionary"),Ne=Symbol("populateParserHintDictionary"),De=Symbol("sanitizeKey"),Ie=Symbol("setKey"),We=Symbol("unfreeze"),Re=Symbol("validateAsync"),Fe=Symbol("getCommandInstance"),ze=Symbol("getContext"),Le=Symbol("getHasOutput"),Ue=Symbol("getLoggerInstance"),He=Symbol("getParseContext"),Te=Symbol("getUsageInstance"),Ve=Symbol("getValidationInstance"),Be=Symbol("hasParseCallback"),qe=Symbol("isGlobalContext"),Ye=Symbol("postProcess"),Je=Symbol("rebase"),Ge=Symbol("reset"),Ke=Symbol("runYargsParserAndExecuteCommands"),Qe=Symbol("runValidation"),Ze=Symbol("setHasOutput"),Xe=Symbol("kTrackManuallySetKeys");class tn{constructor(t=[],e,n,s){this.customScriptName=!1,this.parsed=!1,It.set(this,void 0),Wt.set(this,void 0),Rt.set(this,{commands:[],fullCommands:[]}),Ft.set(this,null),zt.set(this,null),Lt.set(this,"show-hidden"),Ut.set(this,null),Ht.set(this,!0),Tt.set(this,{}),Vt.set(this,!0),Bt.set(this,[]),qt.set(this,void 0),Yt.set(this,{}),Jt.set(this,!1),Gt.set(this,null),Kt.set(this,!0),Qt.set(this,void 0),Zt.set(this,""),Xt.set(this,void 0),te.set(this,void 0),ee.set(this,{}),ne.set(this,null),se.set(this,null),ie.set(this,{}),re.set(this,{}),oe.set(this,void 0),ae.set(this,!1),ce.set(this,void 0),le.set(this,!1),he.set(this,!1),de.set(this,!1),ue.set(this,void 0),fe.set(this,{}),pe.set(this,null),ge.set(this,void 0),me(this,ce,s,"f"),me(this,oe,t,"f"),me(this,Wt,e,"f"),me(this,te,n,"f"),me(this,qt,new pt(this),"f"),this.$0=this[Ee](),this[Ge](),me(this,It,ye(this,It,"f"),"f"),me(this,ue,ye(this,ue,"f"),"f"),me(this,ge,ye(this,ge,"f"),"f"),me(this,Xt,ye(this,Xt,"f"),"f"),ye(this,Xt,"f").showHiddenOpt=ye(this,Lt,"f"),me(this,Qt,this[ve](),"f")}addHelpOpt(t,e){return dt("[string|boolean] [string]",[t,e],arguments.length),ye(this,Gt,"f")&&(this[we](ye(this,Gt,"f")),me(this,Gt,null,"f")),!1===t&&void 0===e||(me(this,Gt,"string"==typeof t?t:"help","f"),this.boolean(ye(this,Gt,"f")),this.describe(ye(this,Gt,"f"),e||ye(this,ue,"f").deferY18nLookup("Show help"))),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(dt("[string|boolean] [string]",[t,e],arguments.length),!1===t&&void 0===e)return this;const n="string"==typeof t?t:ye(this,Lt,"f");return this.boolean(n),this.describe(n,e||ye(this,ue,"f").deferY18nLookup("Show hidden options")),ye(this,Xt,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return dt("<object|string|array> [string|array]",[t,e],arguments.length),this[Me](this.alias.bind(this),"alias",t,e),this}array(t){return dt("<array|string>",[t],arguments.length),this[Ce]("array",t),this[Xe](t),this}boolean(t){return dt("<array|string>",[t],arguments.length),this[Ce]("boolean",t),this[Xe](t),this}check(t,e){return dt("<function> [boolean]",[t,e],arguments.length),this.middleware(((e,n)=>mt((()=>t(e,n.getOptions())),(n=>(n?("string"==typeof n||n instanceof Error)&&ye(this,ue,"f").fail(n.toString(),n):ye(this,ue,"f").fail(ye(this,ce,"f").y18n.__("Argument check failed: %s",t.toString())),e)),(t=>(ye(this,ue,"f").fail(t.message?t.message:t.toString(),t),e)))),!1,e),this}choices(t,e){return dt("<object|string|array> [string|array]",[t,e],arguments.length),this[Me](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(dt("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new Q("coerce callback must be provided");for(const n of t)this.coerce(n,e);return this}if("object"==typeof t){for(const e of Object.keys(t))this.coerce(e,t[e]);return this}if(!e)throw new Q("coerce callback must be provided");return ye(this,Xt,"f").key[t]=!0,ye(this,qt,"f").addCoerceMiddleware(((n,s)=>{let i;return Object.prototype.hasOwnProperty.call(n,t)?mt((()=>(i=s.getAliases(),e(n[t]))),(e=>{n[t]=e;const r=s.getInternalMethods().getParserConfiguration()["strip-aliased"];if(i[t]&&!0!==r)for(const s of i[t])n[s]=e;return n}),(t=>{throw new Q(t.message)})):n}),t),this}conflicts(t,e){return dt("<string|object> [string|array]",[t,e],arguments.length),ye(this,ge,"f").conflicts(t,e),this}config(t="config",e,n){return dt("[object|string] [string|function] [function]",[t,e,n],arguments.length),"object"!=typeof t||Array.isArray(t)?("function"==typeof e&&(n=e,e=void 0),this.describe(t,e||ye(this,ue,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((t=>{ye(this,Xt,"f").config[t]=n||!0})),this):(t=Nt(t,ye(this,Wt,"f"),this[je]()["deep-merge-config"]||!1,ye(this,ce,"f")),ye(this,Xt,"f").configObjects=(ye(this,Xt,"f").configObjects||[]).concat(t),this)}completion(t,e,n){return dt("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),"function"==typeof e&&(n=e,e=void 0),me(this,zt,t||ye(this,zt,"f")||"completion","f"),e||!1===e||(e="generate completion script"),this.command(ye(this,zt,"f"),e),n&&ye(this,Ft,"f").registerFunction(n),this}command(t,e,n,s,i,r){return dt("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,s,i,r],arguments.length),ye(this,It,"f").addHandler(t,e,n,s,i,r),this}commands(t,e,n,s,i,r){return this.command(t,e,n,s,i,r)}commandDir(t,e){dt("<string> [object]",[t,e],arguments.length);const n=ye(this,te,"f")||ye(this,ce,"f").require;return ye(this,It,"f").addDirectory(t,n,ye(this,ce,"f").getCallerFile(),e),this}count(t){return dt("<array|string>",[t],arguments.length),this[Ce]("count",t),this[Xe](t),this}default(t,e,n){return dt("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(ot(t,ye(this,ce,"f")),ye(this,Xt,"f").defaultDescription[t]=n),"function"==typeof e&&(ot(t,ye(this,ce,"f")),ye(this,Xt,"f").defaultDescription[t]||(ye(this,Xt,"f").defaultDescription[t]=ye(this,ue,"f").functionDescription(e)),e=e.call()),this[Se](this.default.bind(this),"default",t,e),this}defaults(t,e,n){return this.default(t,e,n)}demandCommand(t=1,e,n,s){return dt("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,n,s],arguments.length),"number"!=typeof e&&(n=e,e=1/0),this.global("_",!1),ye(this,Xt,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:s},this}demand(t,e,n){return Array.isArray(e)?(e.forEach((t=>{rt(n,!0,ye(this,ce,"f")),this.demandOption(t,n)})),e=1/0):"number"!=typeof e&&(n=e,e=1/0),"number"==typeof t?(rt(n,!0,ye(this,ce,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach((t=>{rt(n,!0,ye(this,ce,"f")),this.demandOption(t,n)})):"string"==typeof n?this.demandOption(t,n):!0!==n&&void 0!==n||this.demandOption(t),this}demandOption(t,e){return dt("<object|string|array> [string]",[t,e],arguments.length),this[Se](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return dt("<string> [string|boolean]",[t,e],arguments.length),ye(this,Xt,"f").deprecatedOptions[t]=e,this}describe(t,e){return dt("<object|string|array> [string]",[t,e],arguments.length),this[Ie](t,!0),ye(this,ue,"f").describe(t,e),this}detectLocale(t){return dt("<boolean>",[t],arguments.length),me(this,Ht,t,"f"),this}env(t){return dt("[string|boolean]",[t],arguments.length),!1===t?delete ye(this,Xt,"f").envPrefix:ye(this,Xt,"f").envPrefix=t||"",this}epilogue(t){return dt("<string>",[t],arguments.length),ye(this,ue,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return dt("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach((t=>this.example(...t))):ye(this,ue,"f").example(t,e),this}exit(t,e){me(this,Jt,!0,"f"),me(this,Ut,e,"f"),ye(this,Vt,"f")&&ye(this,ce,"f").process.exit(t)}exitProcess(t=!0){return dt("[boolean]",[t],arguments.length),me(this,Vt,t,"f"),this}fail(t){if(dt("<function|boolean>",[t],arguments.length),"boolean"==typeof t&&!1!==t)throw new Q("Invalid first argument. Expected function or boolean 'false'");return ye(this,ue,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return dt("<array> [function]",[t,e],arguments.length),e?ye(this,Ft,"f").getCompletion(t,e):new Promise(((e,n)=>{ye(this,Ft,"f").getCompletion(t,((t,s)=>{t?n(t):e(s)}))}))}getDemandedOptions(){return dt([],0),ye(this,Xt,"f").demandedOptions}getDemandedCommands(){return dt([],0),ye(this,Xt,"f").demandedCommands}getDeprecatedOptions(){return dt([],0),ye(this,Xt,"f").deprecatedOptions}getDetectLocale(){return ye(this,Ht,"f")}getExitProcess(){return ye(this,Vt,"f")}getGroups(){return Object.assign({},ye(this,Yt,"f"),ye(this,re,"f"))}getHelp(){if(me(this,Jt,!0,"f"),!ye(this,ue,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[Ke](ye(this,oe,"f"),void 0,void 0,0,!0);if(ct(t))return t.then((()=>ye(this,ue,"f").help()))}const t=ye(this,It,"f").runDefaultBuilderOn(this);if(ct(t))return t.then((()=>ye(this,ue,"f").help()))}return Promise.resolve(ye(this,ue,"f").help())}getOptions(){return ye(this,Xt,"f")}getStrict(){return ye(this,le,"f")}getStrictCommands(){return ye(this,he,"f")}getStrictOptions(){return ye(this,de,"f")}global(t,e){return dt("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),!1!==e?ye(this,Xt,"f").local=ye(this,Xt,"f").local.filter((e=>-1===t.indexOf(e))):t.forEach((t=>{ye(this,Xt,"f").local.includes(t)||ye(this,Xt,"f").local.push(t)})),this}group(t,e){dt("<string|array> <string>",[t,e],arguments.length);const n=ye(this,re,"f")[e]||ye(this,Yt,"f")[e];ye(this,re,"f")[e]&&delete ye(this,re,"f")[e];const s={};return ye(this,Yt,"f")[e]=(n||[]).concat(t).filter((t=>!s[t]&&(s[t]=!0))),this}hide(t){return dt("<string>",[t],arguments.length),ye(this,Xt,"f").hiddenOptions.push(t),this}implies(t,e){return dt("<string|object> [number|string|array]",[t,e],arguments.length),ye(this,ge,"f").implies(t,e),this}locale(t){return dt("[string]",[t],arguments.length),void 0===t?(this[_e](),ye(this,ce,"f").y18n.getLocale()):(me(this,Ht,!1,"f"),ye(this,ce,"f").y18n.setLocale(t),this)}middleware(t,e,n){return ye(this,qt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return dt("<string|object|array> [number]",[t,e],arguments.length),this[Se](this.nargs.bind(this),"narg",t,e),this}normalize(t){return dt("<array|string>",[t],arguments.length),this[Ce]("normalize",t),this}number(t){return dt("<array|string>",[t],arguments.length),this[Ce]("number",t),this[Xe](t),this}option(t,e){if(dt("<string|object> [object]",[t,e],arguments.length),"object"==typeof t)Object.keys(t).forEach((e=>{this.options(e,t[e])}));else{"object"!=typeof e&&(e={}),this[Xe](t),!ye(this,pe,"f")||"version"!==t&&"version"!==(null==e?void 0:e.alias)||this[Oe](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join("\n"),void 0,"versionWarning"),ye(this,Xt,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);const n=e.deprecate||e.deprecated;n&&this.deprecateOption(t,n);const s=e.demand||e.required||e.require;s&&this.demand(t,s),e.demandOption&&this.demandOption(t,"string"==typeof e.demandOption?e.demandOption:void 0),e.conflicts&&this.conflicts(t,e.conflicts),"default"in e&&this.default(t,e.default),void 0!==e.implies&&this.implies(t,e.implies),void 0!==e.nargs&&this.nargs(t,e.nargs),e.config&&this.config(t,e.configParser),e.normalize&&this.normalize(t),e.choices&&this.choices(t,e.choices),e.coerce&&this.coerce(t,e.coerce),e.group&&this.group(t,e.group),(e.boolean||"boolean"===e.type)&&(this.boolean(t),e.alias&&this.boolean(e.alias)),(e.array||"array"===e.type)&&(this.array(t),e.alias&&this.array(e.alias)),(e.number||"number"===e.type)&&(this.number(t),e.alias&&this.number(e.alias)),(e.string||"string"===e.type)&&(this.string(t),e.alias&&this.string(e.alias)),(e.count||"count"===e.type)&&this.count(t),"boolean"==typeof e.global&&this.global(t,e.global),e.defaultDescription&&(ye(this,Xt,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);const i=e.describe||e.description||e.desc,r=ye(this,ue,"f").getDescriptions();Object.prototype.hasOwnProperty.call(r,t)&&"string"!=typeof i||this.describe(t,i),e.hidden&&this.hide(t),e.requiresArg&&this.requiresArg(t)}return this}options(t,e){return this.option(t,e)}parse(t,e,n){dt("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[ke](),void 0===t&&(t=ye(this,oe,"f")),"object"==typeof e&&(me(this,se,e,"f"),e=n),"function"==typeof e&&(me(this,ne,e,"f"),e=!1),e||me(this,oe,t,"f"),ye(this,ne,"f")&&me(this,Vt,!1,"f");const s=this[Ke](t,!!e),i=this.parsed;return ye(this,Ft,"f").setParsed(this.parsed),ct(s)?s.then((t=>(ye(this,ne,"f")&&ye(this,ne,"f").call(this,ye(this,Ut,"f"),t,ye(this,Zt,"f")),t))).catch((t=>{throw ye(this,ne,"f")&&ye(this,ne,"f")(t,this.parsed.argv,ye(this,Zt,"f")),t})).finally((()=>{this[We](),this.parsed=i})):(ye(this,ne,"f")&&ye(this,ne,"f").call(this,ye(this,Ut,"f"),s,ye(this,Zt,"f")),this[We](),this.parsed=i,s)}parseAsync(t,e,n){const s=this.parse(t,e,n);return ct(s)?s:Promise.resolve(s)}parseSync(t,e,n){const s=this.parse(t,e,n);if(ct(s))throw new Q(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(t){return dt("<object>",[t],arguments.length),me(this,ee,t,"f"),this}pkgConf(t,e){dt("<string> [string]",[t,e],arguments.length);let n=null;const s=this[$e](e||ye(this,Wt,"f"));return s[t]&&"object"==typeof s[t]&&(n=Nt(s[t],e||ye(this,Wt,"f"),this[je]()["deep-merge-config"]||!1,ye(this,ce,"f")),ye(this,Xt,"f").configObjects=(ye(this,Xt,"f").configObjects||[]).concat(n)),this}positional(t,e){dt("<string> <object>",[t,e],arguments.length);const n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=Ot(e,((t,e)=>!("type"===t&&!["string","number","boolean"].includes(e))&&n.includes(t)));const s=ye(this,Rt,"f").fullCommands[ye(this,Rt,"f").fullCommands.length-1],i=s?ye(this,It,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return at(i).forEach((n=>{const s=i[n];Array.isArray(s)?-1!==s.indexOf(t)&&(e[n]=!0):s[t]&&!(n in e)&&(e[n]=s[t])})),this.group(t,ye(this,ue,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return dt("[boolean]",[t],arguments.length),me(this,ae,t,"f"),this}required(t,e,n){return this.demand(t,e,n)}require(t,e,n){return this.demand(t,e,n)}requiresArg(t){return dt("<array|string|object> [number]",[t],arguments.length),"string"==typeof t&&ye(this,Xt,"f").narg[t]||this[Se](this.requiresArg.bind(this),"narg",t,NaN),this}showCompletionScript(t,e){return dt("[string] [string]",[t,e],arguments.length),t=t||this.$0,ye(this,Qt,"f").log(ye(this,Ft,"f").generateCompletionScript(t,e||ye(this,zt,"f")||"completion")),this}showHelp(t){if(dt("[string|function]",[t],arguments.length),me(this,Jt,!0,"f"),!ye(this,ue,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[Ke](ye(this,oe,"f"),void 0,void 0,0,!0);if(ct(e))return e.then((()=>{ye(this,ue,"f").showHelp(t)})),this}const e=ye(this,It,"f").runDefaultBuilderOn(this);if(ct(e))return e.then((()=>{ye(this,ue,"f").showHelp(t)})),this}return ye(this,ue,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return dt("[boolean|string] [string]",[t,e],arguments.length),ye(this,ue,"f").showHelpOnFail(t,e),this}showVersion(t){return dt("[string|function]",[t],arguments.length),ye(this,ue,"f").showVersion(t),this}skipValidation(t){return dt("<array|string>",[t],arguments.length),this[Ce]("skipValidation",t),this}strict(t){return dt("[boolean]",[t],arguments.length),me(this,le,!1!==t,"f"),this}strictCommands(t){return dt("[boolean]",[t],arguments.length),me(this,he,!1!==t,"f"),this}strictOptions(t){return dt("[boolean]",[t],arguments.length),me(this,de,!1!==t,"f"),this}string(t){return dt("<array|string>",[t],arguments.length),this[Ce]("string",t),this[Xe](t),this}terminalWidth(){return dt([],0),ye(this,ce,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return dt("<object>",[t],arguments.length),me(this,Ht,!1,"f"),ye(this,ce,"f").y18n.updateLocale(t),this}usage(t,e,n,s){if(dt("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,s],arguments.length),void 0!==e){if(rt(t,null,ye(this,ce,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,s);throw new Q(".usage() description must start with $0 if being used as alias for .command()")}return ye(this,ue,"f").usage(t),this}usageConfiguration(t){return dt("<object>",[t],arguments.length),me(this,fe,t,"f"),this}version(t,e,n){const s="version";if(dt("[boolean|string] [string] [string]",[t,e,n],arguments.length),ye(this,pe,"f")&&(this[we](ye(this,pe,"f")),ye(this,ue,"f").version(void 0),me(this,pe,null,"f")),0===arguments.length)n=this[xe](),t=s;else if(1===arguments.length){if(!1===t)return this;n=t,t=s}else 2===arguments.length&&(n=e,e=void 0);return me(this,pe,"string"==typeof t?t:s,"f"),e=e||ye(this,ue,"f").deferY18nLookup("Show version number"),ye(this,ue,"f").version(n||void 0),this.boolean(ye(this,pe,"f")),this.describe(ye(this,pe,"f"),e),this}wrap(t){return dt("<number|null|undefined>",[t],arguments.length),ye(this,ue,"f").wrap(t),this}[(It=new WeakMap,Wt=new WeakMap,Rt=new WeakMap,Ft=new WeakMap,zt=new WeakMap,Lt=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,Tt=new WeakMap,Vt=new WeakMap,Bt=new WeakMap,qt=new WeakMap,Yt=new WeakMap,Jt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,Qt=new WeakMap,Zt=new WeakMap,Xt=new WeakMap,te=new WeakMap,ee=new WeakMap,ne=new WeakMap,se=new WeakMap,ie=new WeakMap,re=new WeakMap,oe=new WeakMap,ae=new WeakMap,ce=new WeakMap,le=new WeakMap,he=new WeakMap,de=new WeakMap,ue=new WeakMap,fe=new WeakMap,pe=new WeakMap,ge=new WeakMap,be)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch(t){}return t}[ve](){return{log:(...t)=>{this[Be]()||console.log(...t),me(this,Jt,!0,"f"),ye(this,Zt,"f").length&&me(this,Zt,ye(this,Zt,"f")+"\n","f"),me(this,Zt,ye(this,Zt,"f")+t.join(" "),"f")},error:(...t)=>{this[Be]()||console.error(...t),me(this,Jt,!0,"f"),ye(this,Zt,"f").length&&me(this,Zt,ye(this,Zt,"f")+"\n","f"),me(this,Zt,ye(this,Zt,"f")+t.join(" "),"f")}}}[we](t){at(ye(this,Xt,"f")).forEach((e=>{if("configObjects"===e)return;const n=ye(this,Xt,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):"object"==typeof n&&delete n[t]})),delete ye(this,ue,"f").getDescriptions()[t]}[Oe](t,e,n){ye(this,Tt,"f")[n]||(ye(this,ce,"f").process.emitWarning(t,e),ye(this,Tt,"f")[n]=!0)}[ke](){ye(this,Bt,"f").push({options:ye(this,Xt,"f"),configObjects:ye(this,Xt,"f").configObjects.slice(0),exitProcess:ye(this,Vt,"f"),groups:ye(this,Yt,"f"),strict:ye(this,le,"f"),strictCommands:ye(this,he,"f"),strictOptions:ye(this,de,"f"),completionCommand:ye(this,zt,"f"),output:ye(this,Zt,"f"),exitError:ye(this,Ut,"f"),hasOutput:ye(this,Jt,"f"),parsed:this.parsed,parseFn:ye(this,ne,"f"),parseContext:ye(this,se,"f")}),ye(this,ue,"f").freeze(),ye(this,ge,"f").freeze(),ye(this,It,"f").freeze(),ye(this,qt,"f").freeze()}[Ee](){let t,e="";return t=/\b(node|iojs|electron)(\.exe)?$/.test(ye(this,ce,"f").process.argv()[0])?ye(this,ce,"f").process.argv().slice(1,2):ye(this,ce,"f").process.argv().slice(0,1),e=t.map((t=>{const e=this[Je](ye(this,Wt,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&e.length<t.length?e:t})).join(" ").trim(),ye(this,ce,"f").getEnv("_")&&ye(this,ce,"f").getProcessArgvBin()===ye(this,ce,"f").getEnv("_")&&(e=ye(this,ce,"f").getEnv("_").replace(`${ye(this,ce,"f").path.dirname(ye(this,ce,"f").process.execPath())}/`,"")),e}[je](){return ye(this,ee,"f")}[Ae](){return ye(this,fe,"f")}[_e](){if(!ye(this,Ht,"f"))return;const t=ye(this,ce,"f").getEnv("LC_ALL")||ye(this,ce,"f").getEnv("LC_MESSAGES")||ye(this,ce,"f").getEnv("LANG")||ye(this,ce,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[xe](){return this[$e]().version||"unknown"}[Pe](t){const e=t["--"]?t["--"]:t._;for(let t,n=0;void 0!==(t=e[n]);n++)ye(this,ce,"f").Parser.looksLikeNumber(t)&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))&&(e[n]=Number(t));return t}[$e](t){const e=t||"*";if(ye(this,ie,"f")[e])return ye(this,ie,"f")[e];let n={};try{let e=t||ye(this,ce,"f").mainFilename;!t&&ye(this,ce,"f").path.extname(e)&&(e=ye(this,ce,"f").path.dirname(e));const s=ye(this,ce,"f").findUp(e,((t,e)=>e.includes("package.json")?"package.json":void 0));rt(s,void 0,ye(this,ce,"f")),n=JSON.parse(ye(this,ce,"f").readFileSync(s,"utf8"))}catch(t){}return ye(this,ie,"f")[e]=n||{},ye(this,ie,"f")[e]}[Ce](t,e){(e=[].concat(e)).forEach((e=>{e=this[De](e),ye(this,Xt,"f")[t].push(e)}))}[Se](t,e,n,s){this[Ne](t,e,n,s,((t,e,n)=>{ye(this,Xt,"f")[t][e]=n}))}[Me](t,e,n,s){this[Ne](t,e,n,s,((t,e,n)=>{ye(this,Xt,"f")[t][e]=(ye(this,Xt,"f")[t][e]||[]).concat(n)}))}[Ne](t,e,n,s,i){if(Array.isArray(n))n.forEach((e=>{t(e,s)}));else if((t=>"object"==typeof t)(n))for(const e of at(n))t(e,n[e]);else i(e,this[De](n),s)}[De](t){return"__proto__"===t?"___proto___":t}[Ie](t,e){return this[Se](this[Ie].bind(this),"key",t,e),this}[We](){var t,e,n,s,i,r,o,a,c,l,h,d;const u=ye(this,Bt,"f").pop();let f;rt(u,void 0,ye(this,ce,"f")),t=this,e=this,n=this,s=this,i=this,r=this,o=this,a=this,c=this,l=this,h=this,d=this,({options:{set value(e){me(t,Xt,e,"f")}}.value,configObjects:f,exitProcess:{set value(t){me(e,Vt,t,"f")}}.value,groups:{set value(t){me(n,Yt,t,"f")}}.value,output:{set value(t){me(s,Zt,t,"f")}}.value,exitError:{set value(t){me(i,Ut,t,"f")}}.value,hasOutput:{set value(t){me(r,Jt,t,"f")}}.value,parsed:this.parsed,strict:{set value(t){me(o,le,t,"f")}}.value,strictCommands:{set value(t){me(a,he,t,"f")}}.value,strictOptions:{set value(t){me(c,de,t,"f")}}.value,completionCommand:{set value(t){me(l,zt,t,"f")}}.value,parseFn:{set value(t){me(h,ne,t,"f")}}.value,parseContext:{set value(t){me(d,se,t,"f")}}.value}=u),ye(this,Xt,"f").configObjects=f,ye(this,ue,"f").unfreeze(),ye(this,ge,"f").unfreeze(),ye(this,It,"f").unfreeze(),ye(this,qt,"f").unfreeze()}[Re](t,e){return mt(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[Fe].bind(this),getContext:this[ze].bind(this),getHasOutput:this[Le].bind(this),getLoggerInstance:this[Ue].bind(this),getParseContext:this[He].bind(this),getParserConfiguration:this[je].bind(this),getUsageConfiguration:this[Ae].bind(this),getUsageInstance:this[Te].bind(this),getValidationInstance:this[Ve].bind(this),hasParseCallback:this[Be].bind(this),isGlobalContext:this[qe].bind(this),postProcess:this[Ye].bind(this),reset:this[Ge].bind(this),runValidation:this[Qe].bind(this),runYargsParserAndExecuteCommands:this[Ke].bind(this),setHasOutput:this[Ze].bind(this)}}[Fe](){return ye(this,It,"f")}[ze](){return ye(this,Rt,"f")}[Le](){return ye(this,Jt,"f")}[Ue](){return ye(this,Qt,"f")}[He](){return ye(this,se,"f")||{}}[Te](){return ye(this,ue,"f")}[Ve](){return ye(this,ge,"f")}[Be](){return!!ye(this,ne,"f")}[qe](){return ye(this,Kt,"f")}[Ye](t,e,n,s){if(n)return t;if(ct(t))return t;e||(t=this[be](t));return(this[je]()["parse-positional-numbers"]||void 0===this[je]()["parse-positional-numbers"])&&(t=this[Pe](t)),s&&(t=gt(t,this,ye(this,qt,"f").getMiddleware(),!1)),t}[Ge](t={}){me(this,Xt,ye(this,Xt,"f")||{},"f");const e={};e.local=ye(this,Xt,"f").local||[],e.configObjects=ye(this,Xt,"f").configObjects||[];const n={};e.local.forEach((e=>{n[e]=!0,(t[e]||[]).forEach((t=>{n[t]=!0}))})),Object.assign(ye(this,re,"f"),Object.keys(ye(this,Yt,"f")).reduce(((t,e)=>{const s=ye(this,Yt,"f")[e].filter((t=>!(t in n)));return s.length>0&&(t[e]=s),t}),{})),me(this,Yt,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((t=>{e[t]=(ye(this,Xt,"f")[t]||[]).filter((t=>!n[t]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((t=>{e[t]=Ot(ye(this,Xt,"f")[t],(t=>!n[t]))})),e.envPrefix=ye(this,Xt,"f").envPrefix,me(this,Xt,e,"f"),me(this,ue,ye(this,ue,"f")?ye(this,ue,"f").reset(n):jt(this,ye(this,ce,"f")),"f"),me(this,ge,ye(this,ge,"f")?ye(this,ge,"f").reset(n):function(t,e,n){const s=n.y18n.__,i=n.y18n.__n,r={nonOptionCount:function(n){const s=t.getDemandedCommands(),r=n._.length+(n["--"]?n["--"].length:0)-t.getInternalMethods().getContext().commands.length;s._&&(r<s._.min||r>s._.max)&&(r<s._.min?void 0!==s._.minMsg?e.fail(s._.minMsg?s._.minMsg.replace(/\$0/g,r.toString()).replace(/\$1/,s._.min.toString()):null):e.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",r,r.toString(),s._.min.toString())):r>s._.max&&(void 0!==s._.maxMsg?e.fail(s._.maxMsg?s._.maxMsg.replace(/\$0/g,r.toString()).replace(/\$1/,s._.max.toString()):null):e.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",r,r.toString(),s._.max.toString()))))},positionalCount:function(t,n){n<t&&e.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",n,n+"",t+""))},requiredArguments:function(t,n){let s=null;for(const e of Object.keys(n))Object.prototype.hasOwnProperty.call(t,e)&&void 0!==t[e]||(s=s||{},s[e]=n[e]);if(s){const t=[];for(const e of Object.keys(s)){const n=s[e];n&&t.indexOf(n)<0&&t.push(n)}const n=t.length?`\n${t.join("\n")}`:"";e.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(s).length,Object.keys(s).join(", ")+n))}},unknownArguments:function(n,s,o,a,c=!0){var l;const h=t.getInternalMethods().getCommandInstance().getCommands(),d=[],u=t.getInternalMethods().getContext();if(Object.keys(n).forEach((e=>{Ct.includes(e)||Object.prototype.hasOwnProperty.call(o,e)||Object.prototype.hasOwnProperty.call(t.getInternalMethods().getParseContext(),e)||r.isValidAndSomeAliasIsNotNew(e,s)||d.push(e)})),c&&(u.commands.length>0||h.length>0||a)&&n._.slice(u.commands.length).forEach((t=>{h.includes(""+t)||d.push(""+t)})),c){const e=(null===(l=t.getDemandedCommands()._)||void 0===l?void 0:l.max)||0,s=u.commands.length+e;s<n._.length&&n._.slice(s).forEach((t=>{t=String(t),u.commands.includes(t)||d.includes(t)||d.push(t)}))}d.length&&e.fail(i("Unknown argument: %s","Unknown arguments: %s",d.length,d.map((t=>t.trim()?t:`"${t}"`)).join(", ")))},unknownCommands:function(n){const s=t.getInternalMethods().getCommandInstance().getCommands(),r=[],o=t.getInternalMethods().getContext();return(o.commands.length>0||s.length>0)&&n._.slice(o.commands.length).forEach((t=>{s.includes(""+t)||r.push(""+t)})),r.length>0&&(e.fail(i("Unknown command: %s","Unknown commands: %s",r.length,r.join(", "))),!0)},isValidAndSomeAliasIsNotNew:function(e,n){if(!Object.prototype.hasOwnProperty.call(n,e))return!1;const s=t.parsed.newAliases;return[e,...n[e]].some((t=>!Object.prototype.hasOwnProperty.call(s,t)||!s[e]))},limitedChoices:function(n){const i=t.getOptions(),r={};if(!Object.keys(i.choices).length)return;Object.keys(n).forEach((t=>{-1===Ct.indexOf(t)&&Object.prototype.hasOwnProperty.call(i.choices,t)&&[].concat(n[t]).forEach((e=>{-1===i.choices[t].indexOf(e)&&void 0!==e&&(r[t]=(r[t]||[]).concat(e))}))}));const o=Object.keys(r);if(!o.length)return;let a=s("Invalid values:");o.forEach((t=>{a+=`\n ${s("Argument: %s, Given: %s, Choices: %s",t,e.stringifiedValues(r[t]),e.stringifiedValues(i.choices[t]))}`})),e.fail(a)}};let o={};function a(t,e){const n=Number(e);return"number"==typeof(e=isNaN(n)?e:n)?e=t._.length>=e:e.match(/^--no-.+/)?(e=e.match(/^--no-(.+)/)[1],e=!Object.prototype.hasOwnProperty.call(t,e)):e=Object.prototype.hasOwnProperty.call(t,e),e}r.implies=function(e,s){dt("<string|object> [array|number|string]",[e,s],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.implies(t,e[t])})):(t.global(e),o[e]||(o[e]=[]),Array.isArray(s)?s.forEach((t=>r.implies(e,t))):(rt(s,void 0,n),o[e].push(s)))},r.getImplied=function(){return o},r.implications=function(t){const n=[];if(Object.keys(o).forEach((e=>{const s=e;(o[e]||[]).forEach((e=>{let i=s;const r=e;i=a(t,i),e=a(t,e),i&&!e&&n.push(` ${s} -> ${r}`)}))})),n.length){let t=`${s("Implications failed:")}\n`;n.forEach((e=>{t+=e})),e.fail(t)}};let c={};r.conflicts=function(e,n){dt("<string|object> [array|string]",[e,n],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.conflicts(t,e[t])})):(t.global(e),c[e]||(c[e]=[]),Array.isArray(n)?n.forEach((t=>r.conflicts(e,t))):c[e].push(n))},r.getConflicting=()=>c,r.conflicting=function(i){Object.keys(i).forEach((t=>{c[t]&&c[t].forEach((n=>{n&&void 0!==i[t]&&void 0!==i[n]&&e.fail(s("Arguments %s and %s are mutually exclusive",t,n))}))})),t.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(c).forEach((t=>{c[t].forEach((r=>{r&&void 0!==i[n.Parser.camelCase(t)]&&void 0!==i[n.Parser.camelCase(r)]&&e.fail(s("Arguments %s and %s are mutually exclusive",t,r))}))}))},r.recommendCommands=function(t,n){n=n.sort(((t,e)=>e.length-t.length));let i=null,r=1/0;for(let e,s=0;void 0!==(e=n[s]);s++){const n=$t(t,e);n<=3&&n<r&&(r=n,i=e)}i&&e.fail(s("Did you mean %s?",i))},r.reset=function(t){return o=Ot(o,(e=>!t[e])),c=Ot(c,(e=>!t[e])),r};const l=[];return r.freeze=function(){l.push({implied:o,conflicting:c})},r.unfreeze=function(){const t=l.pop();rt(t,void 0,n),({implied:o,conflicting:c}=t)},r}(this,ye(this,ue,"f"),ye(this,ce,"f")),"f"),me(this,It,ye(this,It,"f")?ye(this,It,"f").reset():function(t,e,n,s){return new bt(t,e,n,s)}(ye(this,ue,"f"),ye(this,ge,"f"),ye(this,qt,"f"),ye(this,ce,"f")),"f"),ye(this,Ft,"f")||me(this,Ft,function(t,e,n,s){return new Pt(t,e,n,s)}(this,ye(this,ue,"f"),ye(this,It,"f"),ye(this,ce,"f")),"f"),ye(this,qt,"f").reset(),me(this,zt,null,"f"),me(this,Zt,"","f"),me(this,Ut,null,"f"),me(this,Jt,!1,"f"),this.parsed=!1,this}[Je](t,e){return ye(this,ce,"f").path.relative(t,e)}[Ke](t,e,n,s=0,i=!1){let r=!!n||i;t=t||ye(this,oe,"f"),ye(this,Xt,"f").__=ye(this,ce,"f").y18n.__,ye(this,Xt,"f").configuration=this[je]();const o=!!ye(this,Xt,"f").configuration["populate--"],a=Object.assign({},ye(this,Xt,"f").configuration,{"populate--":!0}),c=ye(this,ce,"f").Parser.detailed(t,Object.assign({},ye(this,Xt,"f"),{configuration:{"parse-positional-numbers":!1,...a}})),l=Object.assign(c.argv,ye(this,se,"f"));let h;const d=c.aliases;let u=!1,f=!1;Object.keys(l).forEach((t=>{t===ye(this,Gt,"f")&&l[t]?u=!0:t===ye(this,pe,"f")&&l[t]&&(f=!0)})),l.$0=this.$0,this.parsed=c,0===s&&ye(this,ue,"f").clearCachedHelpMessage();try{if(this[_e](),e)return this[Ye](l,o,!!n,!1);if(ye(this,Gt,"f")){[ye(this,Gt,"f")].concat(d[ye(this,Gt,"f")]||[]).filter((t=>t.length>1)).includes(""+l._[l._.length-1])&&(l._.pop(),u=!0)}me(this,Kt,!1,"f");const a=ye(this,It,"f").getCommands(),p=ye(this,Ft,"f").completionKey in l,g=u||p||i;if(l._.length){if(a.length){let t;for(let e,r=s||0;void 0!==l._[r];r++){if(e=String(l._[r]),a.includes(e)&&e!==ye(this,zt,"f")){const t=ye(this,It,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Ye](t,o,!!n,!1)}if(!t&&e!==ye(this,zt,"f")){t=e;break}}!ye(this,It,"f").hasDefaultCommand()&&ye(this,ae,"f")&&t&&!g&&ye(this,ge,"f").recommendCommands(t,a)}ye(this,zt,"f")&&l._.includes(ye(this,zt,"f"))&&!p&&(ye(this,Vt,"f")&&kt(!0),this.showCompletionScript(),this.exit(0))}if(ye(this,It,"f").hasDefaultCommand()&&!g){const t=ye(this,It,"f").runCommand(null,this,c,0,i,u||f||i);return this[Ye](t,o,!!n,!1)}if(p){ye(this,Vt,"f")&&kt(!0);const e=(t=[].concat(t)).slice(t.indexOf(`--${ye(this,Ft,"f").completionKey}`)+1);return ye(this,Ft,"f").getCompletion(e,((t,e)=>{if(t)throw new Q(t.message);(e||[]).forEach((t=>{ye(this,Qt,"f").log(t)})),this.exit(0)})),this[Ye](l,!o,!!n,!1)}if(ye(this,Jt,"f")||(u?(ye(this,Vt,"f")&&kt(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(ye(this,Vt,"f")&&kt(!0),r=!0,ye(this,ue,"f").showVersion("log"),this.exit(0))),!r&&ye(this,Xt,"f").skipValidation.length>0&&(r=Object.keys(l).some((t=>ye(this,Xt,"f").skipValidation.indexOf(t)>=0&&!0===l[t]))),!r){if(c.error)throw new Q(c.error.message);if(!p){const t=this[Qe](d,{},c.error);n||(h=gt(l,this,ye(this,qt,"f").getMiddleware(),!0)),h=this[Re](t,null!=h?h:l),ct(h)&&!n&&(h=h.then((()=>gt(l,this,ye(this,qt,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof Q))throw t;ye(this,ue,"f").fail(t.message,t)}return this[Ye](null!=h?h:l,o,!!n,!0)}[Qe](t,e,n,s){const i={...this.getDemandedOptions()};return r=>{if(n)throw new Q(n.message);ye(this,ge,"f").nonOptionCount(r),ye(this,ge,"f").requiredArguments(r,i);let o=!1;ye(this,he,"f")&&(o=ye(this,ge,"f").unknownCommands(r)),ye(this,le,"f")&&!o?ye(this,ge,"f").unknownArguments(r,t,e,!!s):ye(this,de,"f")&&ye(this,ge,"f").unknownArguments(r,t,{},!1,!1),ye(this,ge,"f").limitedChoices(r),ye(this,ge,"f").implications(r),ye(this,ge,"f").conflicting(r)}}[Ze](){me(this,Jt,!0,"f")}[Xe](t){if("string"==typeof t)ye(this,Xt,"f").key[t]=!0;else for(const e of t)ye(this,Xt,"f").key[e]=!0}}const en=(nn=it,(t=[],e=nn.process.cwd(),n)=>{const s=new tn(t,e,n,nn);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s});var nn;function sn(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var s=n.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}const rn=new class{constructor(){sn(this,"_dirPath",void 0),sn(this,"_dockerfile",void 0),sn(this,"_dockerfilePath",void 0),sn(this,"_hasDockerfile",void 0),sn(this,"_name",void 0),sn(this,"_rootPackageJson",void 0),sn(this,"_dockerPackageJson",void 0),sn(this,"_packageJson",void 0),this._dirPath=process.cwd()}get dirPath(){return this._dirPath}set dirPath(e){this._dirPath=t.resolve(e)}get dockerfile(){return this._dockerfile??=h.readFileSync(this.dockerfilePath,"utf8")}get dockerfilePath(){if(this._dockerfilePath)return this._dockerfilePath;if(h.existsSync(t.join(this.dirPath,"Dockerfile")))this._dockerfilePath=t.join(this.dirPath,"Dockerfile");else{if(!h.existsSync(t.join(this.dirPath,"..","..","Dockerfile")))throw new Error("Dockerfile not found");this._dockerfilePath=t.join(this.dirPath,"..","..","Dockerfile")}return this._dockerfilePath}get hasDockerfile(){if(void 0!==this._hasDockerfile)return this._hasDockerfile;try{this._hasDockerfile=!!this.dockerfilePath}catch{this._hasDockerfile=!1}return this._hasDockerfile}get name(){return this._name??=rn.rootPackageJson.name||"unknown"}get packageJson(){return this._packageJson??=JSON.parse(h.readFileSync(t.join(this.dirPath,"package.json"),"utf8"))}get rootPackageJson(){return this._rootPackageJson??=h.existsSync(t.join(this.dirPath,"..","..","package.json"))?JSON.parse(h.readFileSync(t.join(this.dirPath,"..","..","package.json"),"utf8")):this.packageJson}get dockerPackageJson(){return this._dockerPackageJson??=t.dirname(this.dockerfilePath)===this.dirPath?this.packageJson:JSON.parse(h.readFileSync(t.join(t.dirname(this.dockerfilePath),"package.json"),"utf8"))}},on={env:{description:".env files to be loaded.",type:"array"},"cascade-env":{description:"environment to load cascading .env files (e.g., `.env`, `.env.<environment>`, `.env.local` and `.env.<environment>.local`)",type:"string"},"cascade-node-env":{description:"environment to load cascading .env files (e.g., `.env`, `.env.<NODE_ENV>`, `.env.local` and `.env.<NODE_ENV>.local`). Preferred over `cascade`.",type:"boolean"},"working-dir":{description:"A working directory",type:"string",alias:"w"}},an={"dry-run":{description:"Whether to skip actual command execution",type:"boolean",alias:"d"},verbose:{description:"Whether to show verbose information",type:"boolean",alias:"v"}},cn={command:"buildIfNeeded",describe:"Build code if changes are detected",builder:{...on,...an,command:{description:"A build command",type:"string",default:"yarn build",alias:"c"}},async handler(e){await async function(e){const[n,s,i]=await async function(){const e=t.resolve(rn.dirPath,"node_modules",".cache","build"),n=t.resolve(e,"last-build");await k.mkdir(e,{recursive:!0});const s=O("sha256"),i=b.execSync("git rev-parse HEAD",{cwd:rn.dirPath}).toString().trim();s.update(i);const r=JSON.stringify(Object.entries(process.env).sort((([t],[e])=>t.localeCompare(e))));s.update(r),await async function(t){return new Promise((e=>{const n=b.spawnSync("git",["diff","--name-only"],{cwd:rn.dirPath,stdio:"pipe",encoding:"utf8"}).stdout.trim().split("\n").map((t=>"test"===process.env.WB_ENV?t.replace(/packages\/scripts\/test-fixtures\/[^/]+\//,""):t)).filter((t=>(ln.some((e=>t.includes(e)))||hn.some((e=>t.endsWith(e))))&&!dn.some((e=>t.includes(e))))),s=b.spawn("git",["diff","--",...n],{cwd:rn.dirPath});s.stdout?.on("data",(e=>{t.update(e)})),s.on("close",(()=>{e()}))}))}(s);const o=s.digest("hex");try{if(await k.readFile(n,"utf8")===o)return console.info("Skip to build production code."),[!0,n,o]}catch{}return[!1,n,o]}();if(n)return!1;if(console.info("Start building production code."),!e.dryRun){const[t,...n]=(e.command??"").split(" "),s=b.spawnSync(t,n,{cwd:rn.dirPath,stdio:"inherit"});if(0!==s.status)return console.info("Failed to build production code."),process.exitCode=s.status??1,!1}console.info("Finished building production code."),e.dryRun||await k.writeFile(s,i,"utf8");return!0}(e)}};const ln=["src/","public/"],hn=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","yarn.lock"],dn=["test/","tests/","__tests__/","test-fixtures/","package.json"];const un={command:"optimizeForDockerBuild",describe:"Optimize configuration when building a Docker image",builder:{...on,...an,outside:{description:"Whether the optimization is executed outside a docker container or not",type:"boolean",alias:"o"}},async handler(e){const n={stdio:"inherit"},s=["package.json"];if(rn.packageJson.workspaces){const e=await h.promises.readdir("packages",{withFileTypes:!0});for(const n of e){if(!n.isDirectory())continue;const e=t.join("packages",n.name,"package.json");h.existsSync(e)&&s.push(e)}}for(const n of s){const s=JSON.parse(h.readFileSync(n,"utf8")),i=s.dependencies||{};if(i["@discord-bot/llm"]&&"workspace:*"!==i["@discord-bot/llm"]&&(i["@discord-bot/llm"]="./@discord-bot/llm"),i["@moti-components/go-e-mon"]&&(i["@moti-components/go-e-mon"]="./@moti-components/go-e-mon"),i["@online-judge/shared"]&&(i["@online-judge/shared"]="./@online-judge/shared"),i["program-executor"]&&(i["program-executor"]="./program-executor"),i["online-judge-shared"]&&(i["online-judge-shared"]="./online-judge-shared"),fn(e,s),pn(s),e.dryRun)continue;const r=e.outside?t.join(t.dirname(n),"dist"):t.dirname(n);await h.promises.mkdir(r,{recursive:!0}),await h.promises.writeFile(t.join(r,"package.json"),JSON.stringify(s),"utf8")}e.dryRun||e.outside||b.spawnSync("yarn",n)}};function fn(t,e){if(!t.outside)return void delete e.devDependencies;const n=e.devDependencies||{},s=["concurrently","conventional-changelog-conventionalcommits","eslint","husky","jest","kill-port","lint-staged","open-cli","playwright","prettier","pinst","sort-package-json","wait-on","semantic-release","vitest"];for(const e of Object.keys(n))(s.some((t=>e.includes(t)))||!t.outside&&e.includes("willbooster")&&e.includes("config"))&&delete n[e]}function pn(t){const e=["check","deploy","format","lint","start","test"],n=["pinst ","husky "],s=t.scripts||{};for(const[t,i]of Object.entries(s))(e.some((e=>t.includes(e)))||n.some((t=>i.includes(t))))&&delete s[t]}const gn=new class{litestream(){return'node -e \'\nconst { PrismaClient } = require("@prisma/client");\nnew PrismaClient().$queryRaw`PRAGMA journal_mode = WAL;`\n .catch((error) => { console.log("Failed due to:", error); process.exit(1); });\n\''}migrate(){return`PRISMA migrate deploy && PRISMA generate && ${this.seed()}`}migrateDev(){return"PRISMA migrate dev"}reset(){return`PRISMA migrate reset --force --skip-seed && ${this.seed()}`}seed(){return rn.packageJson.dependencies?.blitz?"YARN blitz db seed":'if [ -e "prisma/seeds.ts" ]; then YARN build-ts run prisma/seeds.ts; fi'}studio(){return"PRISMA studio"}};function mn(t){return new Promise((e=>{h.access(t,h.constants.F_OK,(t=>{e(!t)}))}))}async function yn(t,e,n){return new Promise(((s,i)=>{try{const r=v(t,e??[],n??{});let o="",a="";n?.input&&(r.stdin?.write(n.input),r.stdin?.end()),r.stdout?.on("data",(t=>{o+=t})),r.stderr?.on("data",(t=>{n?.mergeOutAndError?o+=t:a+=t}));let c=!1;const l=()=>{!c&&r.pid&&(c=!0,n?.verbose&&console.info(`treeKill(${r.pid})`),_(r.pid))};n?.killOnExit&&(process.on("beforeExit",l),process.on("SIGINT",l)),r.on("error",(t=>{process.removeListener("exit",l),r.removeAllListeners("close"),i(t)})),r.on("close",((t,e)=>{process.removeListener("exit",l),void 0===r.pid?i(new Error("Process has no pid.")):s({pid:r.pid,stdout:o,stderr:a,status:t,signal:e})}))}catch(t){i(t)}}))}const bn=new j,vn=new Set;const wn={exitIfFailed:!0};async function On(t,e,n=wn){const[s,i]=En(t);if(jn(s),e.verbose&&jn(s,"Start (detailed)",!0),e.dryRun)return An(s,0,n),0;const r=i.match(/http:\/\/127.0.0.1:(\d+)/)?.[1];i.includes("wait-on")&&r&&!i.includes("docker run")&&await async function(t){await A(t);const e=async()=>{vn.has(t)||(vn.add(t),await A(t))};process.on("beforeExit",e),process.on("SIGINT",e)}(Number(r));const o=await yn(i,void 0,{cwd:rn.dirPath,shell:!0,stdio:"inherit",timeout:n?.timeout,killOnExit:!0,verbose:e.verbose});return An(s,o.status,n),o.status??1}function kn(t,e,n=wn){return bn.run((async()=>{const[s,i]=En(t);if(jn(s,"Start (parallel)",!0),e.dryRun)return jn(s,"Start (log)"),void An(s,0,n);const r=await yn(i,void 0,{cwd:rn.dirPath,shell:!0,stdio:"pipe",timeout:n?.timeout,mergeOutAndError:!0,killOnExit:!0,verbose:e.verbose});jn(s,"Start (log)");const o=r.stdout.trim();o&&console.info(o),An(s,r.status,n)}))}function En(e){const n=function(){if(_n)return xn;_n=!0;let e=rn.dirPath;for(;;){const n=t.join(e,"node_modules",".bin");if(h.existsSync(n)&&(process.env.PATH=`${n}:${process.env.PATH}`,xn=!0),h.existsSync(t.join(e,".git")))break;const s=t.dirname(e);if(e===s)break;e=s}return xn}(),s=e.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",rn.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").trim();return[s.replaceAll("YARN ","yarn "),s.replaceAll("YARN ",n?"":"yarn ")]}function jn(t,e="Start",n=!1){console.info("\n"+(n?E.gray:E.cyan)(E.bold(`${e}:`),t)+E.gray(` (@ ${rn.dirPath})`))}function An(t,e,n){0===e?console.info(E.green(E.bold("Finished:"),t)):(console.info(E.red(E.bold(`Failed (exit code ${e}): `),t)),!1!==n.exitIfFailed&&process.exit(e??1))}let _n=!1,xn=!1;const Pn={...an},$n={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Cn).command(Sn).command(Mn).command(Nn).command(Dn).command(In).demandCommand(),handler(){}},Cn={command:"litestream",describe:"Setup DB for Litestream",builder:Pn,async handler(t){await On(gn.litestream(),t)}},Sn={command:"migrate",describe:"Apply migration files to DB",builder:Pn,async handler(t){await On(gn.migrate(),t)}},Mn={command:"migrate-dev",describe:"Create a migration file",builder:Pn,async handler(t){await On(gn.migrateDev(),t)}},Nn={command:"reset",describe:"Reset DB",builder:Pn,async handler(t){await On(gn.reset(),t)}},Dn={command:"seed",describe:"Populate DB with seed data",builder:Pn,async handler(t){await On(gn.seed(),t)}},In={command:"studio",describe:"Open Prisma Studio",builder:Pn,async handler(t){await On(gn.studio(),t)}},Wn={command:"retry",describe:"Retry the given command until it succeeds",builder:{retry:{description:"A maximum retry count",type:"number",alias:"r",default:3},...an},async handler(t){const e=t._.slice(1);let n=0;for(let s=0;s<t.retry;s++)if(s>0&&console.info(`\n${E.yellow(`#${s} Retrying: ${e.join(" ")}`)}`),n=await On(e.join(" "),t,{exitIfFailed:!1}),0===n)return;process.exit(n)}},Rn={command:"setup",describe:"Setup development environment",builder:{...on,...an},async handler(t){await async function(t){const e=await k.readdir(rn.dirPath,{withFileTypes:!0});e.some((t=>t.isFile()&&t.name.includes("-version")))&&await On("asdf install",t);if(e.some((t=>t.isFile()&&"pyproject.toml"===t.name))){await kn("poetry config virtualenvs.in-project true",t),await kn("poetry config virtualenvs.prefer-active-python true",t);const[,e]=b.execSync("asdf current python").toString().trim().split(/\s+/);await kn(`poetry env use ${e}`,t),await bn.promiseAll(),await On("poetry run pip install --upgrade pip",t),await On("poetry install --ansi",t)}if("darwin"===x.platform()){const e=["pstree"];rn.hasDockerfile&&e.push("expect"),await kn(`brew install ${e.join(" ")}`,t)}const n=rn.packageJson.dependencies??{},s=rn.packageJson.devDependencies||{},i=rn.packageJson.scripts??{},r=[],o=[];n.blitz?(r.push("pm2"),o.push("concurrently","dotenv-cli","open-cli","vitest","wait-on")):s["@remix-run/dev"]?(r.push("dotenv-cli","pm2"),o.push("concurrently","open-cli","vitest","wait-on")):(n.express||n.fastify)&&(r.push("pm2"),o.push("concurrently","vitest","wait-on"));r.length>0&&await On(`yarn add ${r.join(" ")}`,t);o.length>0&&await On(`yarn add -D ${o.join(" ")}`,t);i["gen-code"]&&await On("yarn gen-code",t)}(t)}};const Fn=new class{buildDevImage(e="local"){const n=rn.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${t.dirname(rn.dockerfilePath)}\n && ${n}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${rn.name}\n --build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64)\n --build-arg WB_ENV=${e}\n --build-arg WB_VERSION=dev .`}stopAndStart(t=!1,e="",n=""){return`${this.stop()} && ${t?"unbuffer ":""}${this.start(e,n)}`}start(t="",e=""){return function(t){const e=async()=>{vn.has(t)||(vn.add(t),w(t,{shell:!0,stdio:"inherit"}))};process.on("beforeExit",e),process.on("SIGINT",e)}(this.stop()),`docker run --rm -it -p 8080:8080 --name ${rn.name} ${t} ${rn.name} ${e}`}stop(){return`true $(docker rm -f $(docker container ls -q -f name=${rn.name}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};class zn{constructor(t=3e3){this.defaultPort=t}buildDocker(t="local"){return Fn.buildDevImage(t)}startDocker(t=""){return`${this.buildDocker()}\n && YARN concurrently --raw --kill-others-on-fail\n "${Fn.stopAndStart(!1,"",t)}"\n "${this.waitAndOpenApp(8080)}"`}testE2E({playwrightArgs:t,prismaDirectory:e,startCommand:n}){return`APP_ENV=production WB_ENV=test PORT=8080 YARN dotenv -c production -- concurrently --kill-others --raw --success first\n "rm -Rf ${e}/mount && ${n} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && yarn playwright ${t}"`}testE2EDev({playwrightArgs:t,startCommand:e}){return`APP_ENV=development WB_ENV=test NEXT_PUBLIC_WB_ENV=test PORT=8080 YARN dotenv -c development -- concurrently --kill-others --raw --success first\n "${e} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && yarn playwright ${t}"`}testUnit(){return"YARN vitest run tests/unit --color --passWithNoTests"}waitApp(t=this.defaultPort){return`wait-on -t 10000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 10000 -i 500 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 10000 -i 1000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 10000 -i 2000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 20000 -i 4000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 60000 -i 5000 http://127.0.0.1:${t}`}waitAndOpenApp(t=this.defaultPort){return`${this.waitApp(t)} && open-cli http://localhost:${t}`}}const Ln=new class extends zn{constructor(){super()}start(t,e=""){return`YARN concurrently --raw --kill-others-on-fail\n "blitz dev ${e}"\n "${this.waitAndOpenApp()}"`}startProduction(t=8080,e=""){return`NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${gn.reset()} && yarn build && PORT=${t} pm2-runtime start ecosystem.config.cjs ${e}"\n "${this.waitAndOpenApp(t)}"`}testE2E({playwrightArgs:t="test tests/e2e",startCommand:e=`${gn.reset()} && yarn build && pm2-runtime start ecosystem.config.cjs`}){return super.testE2E({playwrightArgs:t,prismaDirectory:"db",startCommand:e})}testE2EDev({playwrightArgs:t="test tests/e2e",startCommand:e="blitz dev -p 8080"}){return super.testE2EDev({playwrightArgs:t,startCommand:e})}testStart(){return`YARN concurrently --kill-others --raw --success first "blitz dev" "${this.waitApp()}"`}};const Un=new class extends zn{constructor(){super()}start(t,e=""){return`YARN build-ts run src/index.ts ${t?"--watch":""} ${e}`}startDocker(t=""){return`${this.buildDocker()} && ${Fn.stopAndStart(!1,"",t)}`}startProduction(t=8080,e=""){return`NODE_ENV=production yarn build && NODE_ENV=production PORT=\${PORT:-${t}} node dist/index.js ${e}`}testE2E({startCommand:t=`if [ -e "prisma" ]; then prisma migrate reset --force --skip-generate; fi && (${this.startProduction()})`}){return`NODE_ENV=production WB_ENV=test PORT=8080 YARN concurrently --kill-others --raw --success first\n "${t} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testE2EDev({startCommand:t=this.start()}){return`NODE_ENV=production WB_ENV=test PORT=8080 YARN concurrently --kill-others --raw --success first\n "${t} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testStart(){return`YARN concurrently --kill-others --raw --success first "${this.start()}" "${this.waitApp()}"`}};const Hn=new class extends zn{constructor(){super()}start(t,e=""){return`YARN build-ts run src/index.ts ${t?"--watch":""} ${e}`}startDocker(t=""){return`${this.buildDocker()} && ${Fn.stopAndStart(!1,"",t)}`}startProduction(t=8080,e=""){return`NODE_ENV=production yarn build && NODE_ENV=production node dist/index.js ${e}`}testE2E(){return"echo 'do nothing.'"}testE2EDev(){return"echo 'do nothing.'"}testStart(){return"echo 'do nothing.'"}};const Tn=new class extends zn{constructor(){super()}start(t,e=""){return`YARN concurrently --raw --kill-others-on-fail\n "dotenv -c development -- remix dev ${e}"\n "${this.waitAndOpenApp()}"`}startProduction(t=8080,e=""){return`NODE_ENV=production YARN dotenv -c production -- concurrently --raw --kill-others-on-fail\n "${gn.reset()} && yarn build && PORT=${t} pm2-runtime start ecosystem.config.cjs ${e}"\n "${this.waitAndOpenApp(t)}"`}testE2E({playwrightArgs:t="test tests/e2e",startCommand:e=`${gn.reset()} && yarn build && pm2-runtime start ecosystem.config.cjs`}){return super.testE2E({playwrightArgs:t,prismaDirectory:"prisma",startCommand:e})}testE2EDev({playwrightArgs:t="test tests/e2e",startCommand:e="remix dev"}){return super.testE2EDev({playwrightArgs:t,startCommand:e})}testStart(){return`YARN concurrently --kill-others --raw --success first "dotenv -c development -- remix dev" "${this.waitApp()}"`}},Vn={command:"start",describe:"Start app",builder:{...an,watch:{description:"Whether to watch files",type:"boolean"},mode:{description:"Start mode: dev[elopment] (default) | prod[uction] | docker",type:"string",alias:"m"},args:{description:"Arguments text for start command",type:"string",alias:"a"}},async handler(t){const e=rn.packageJson.dependencies||{},n=rn.packageJson.devDependencies||{};let s;s=e.blitz?Ln:n["@remix-run/dev"]?Tn:(e.express||e.fastify)&&!e["firebase-functions"]||/EXPOSE\s+8080/.test(rn.dockerfile)?Un:Hn;const i=t.args??"";switch(t.mode||"dev"){case"dev":case"development":await On(s.start(t.watch,i),t);break;case"prod":case"production":await On(s.startProduction(8080,i),t);break;case"docker":await On(s.startDocker(i),t);break;default:throw new Error(`Unknown start mode: ${t.mode}`)}}},Bn={command:"test",describe:"Test project",builder:{...an,ci:{description:"Whether to run tests on CI",type:"boolean"},e2e:{description:"Whether to run e2e tests. You may pass mode as argument: none | headless (default) | headless-dev | headed | headed-dev | docker | debug | generate | trace",type:"string"},start:{description:"Whether to run start tests",type:"boolean"},unit:{description:"Whether to run unit tests",type:"boolean"},"unit-timeout":{description:"Timeout for unit tests",type:"number"}},async handler(e){await async function(e){await async function(t){if(!rn.packageJson.workspaces)return;const e=process.argv.slice(2),n=e.findIndex((t=>["-w","--working-dir","--workingDir"].includes(t)));n>=0&&e.splice(n,2),process.env.CI="1",process.env.FORCE_COLOR="3",await On(["yarn","workspaces","foreach","--exclude",rn.name,"--verbose","run","wb",...e].join(" "),t),process.exit(0)}(e);const n=rn.packageJson.dependencies||{},s=rn.packageJson.devDependencies||{};let i;i=n.blitz?Ln:s["@remix-run/dev"]?Tn:!n.express&&!n.fastify||n["firebase-functions"]?Hn:Un;const r=[];if(e.ci){const n=mn(t.join(rn.dirPath,"tests","unit")),s=mn(t.join(rn.dirPath,"tests","e2e"));if(await kn(Fn.stopAll(),e),!1!==e.unit&&await n&&await kn(i.testUnit(),e,{timeout:e.unitTimeout}),!1!==e.start&&await kn(i.testStart(),e),await bn.promiseAll(),"none"!==e.e2e&&await s){rn.hasDockerfile&&await On(`${i.buildDocker("test")}`,e);const t=rn.hasDockerfile?{startCommand:Fn.stopAndStart(!0)}:{};process.exitCode=await On(i.testE2E(t),e,{exitIfFailed:!1}),await On(Fn.stop(),e)}return}(e.unit||!e.start&&void 0===e.e2e)&&r.push(On(i.testUnit(),e,{timeout:e.unitTimeout}));e.start&&r.push(On(i.testStart(),e));switch(await Promise.all(r),e.e2e){case void 0:case"none":return;case"":case"headless":return void await On(i.testE2E({}),e);case"headless-dev":return void await On(i.testE2EDev({}),e);case"docker":return await On(`${i.buildDocker("test")}`,e),process.exitCode=await On(i.testE2E({startCommand:Fn.stopAndStart(!0)}),e,{exitIfFailed:!1}),void await On(Fn.stop(),e)}if(n.blitz||s["@remix-run/dev"])switch(e.e2e){case"headed":return void await On(i.testE2E({playwrightArgs:"test tests/e2e --headed"}),e);case"headed-dev":return void await On(i.testE2EDev({playwrightArgs:"test tests/e2e --headed"}),e);case"debug":return void await On(`PWDEBUG=1 ${i.testE2E({})}`,e);case"generate":return void await On(i.testE2E({playwrightArgs:"codegen http://localhost:8080"}),e);case"trace":return void await On("playwright show-trace",e)}throw new Error(`Unknown e2e mode: ${e.e2e}`)}(e)}};const qn={command:"typecheck",describe:"Run type checking",builder:{...an},async handler(t){if(process.exitCode=await On("tsc --noEmit --Pretty",t),0!==process.exitCode){(JSON.parse(await k.readFile("package.json","utf8")).dependencies||{}).blitz&&console.info(E.yellow('Please try "yarn gen-code" if you face unknown type errors.'))}}},Yn={...qn,command:"tc"};var Jn;await en((Jn=process.argv,Jn.slice(K()+1))).scriptName("wb").options(on).middleware((e=>{const n=e["working-dir"];if(n){const e=t.resolve(n);process.chdir(e),rn.dirPath=e}for(const t of Object.keys(process.env)){const e=t.toLowerCase();(e.startsWith("npm_")||e.startsWith("yarn_")||e.startsWith("berry_"))&&delete process.env[t]}let s=(e.env??[]).map((t=>t.toString()));const i=e.nodeEnv?process.env.NODE_ENV:e.cascade;"string"==typeof i&&(0===s.length&&s.push(".env"),s=s.flatMap((t=>i?[`${t}.${i}.local`,`${t}.local`,`${t}.${i}`,t]:[`${t}.local`,t]))),e.verbose&&console.info("Loading env files:",s);for(const e of s)a({path:t.join(rn.dirPath,e)})})).command(cn).command(un).command($n).command(Wn).command(Rn).command(Vn).command(Bn).command(qn).command(Yn).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
|
|
33
|
+
var B,V,q;const Y=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,G=null!==(V=null===(B=null===process||void 0===process?void 0:process.versions)||void 0===B?void 0:B.node)&&void 0!==V?V:null===(q=null===process||void 0===process?void 0:process.version)||void 0===q?void 0:q.slice(1);if(G){if(Number(G.match(/^([^.]+)/)[1])<Y)throw Error(`yargs parser supports a minimum Node.js version of ${Y}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const J=process?process.env:{},K=new class{constructor(t){T=t}parse(t,e){const n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},e),s=function(t){if(Array.isArray(t))return t.map((t=>"string"!=typeof t?t+"":t));t=t.trim();let e=0,n=null,s=null,i=null;const r=[];for(let o=0;o<t.length;o++)n=s,s=t.charAt(o)," "!==s||i?(s===i?i=null:"'"!==s&&'"'!==s||i||(i=s),r[e]||(r[e]=""),r[e]+=s):" "!==n&&e++;return r}(t),i="string"==typeof t,r=function(t){const e=[],n=Object.create(null);let s=!0;Object.keys(t).forEach((function(n){e.push([].concat(t[n],n))}));for(;s;){s=!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){if(e[t].filter((function(t){return-1!==e[n].indexOf(t)})).length){e[t]=e[t].concat(e[n]),e.splice(n,1),s=!0;break}}}return e.forEach((function(t){const e=(t=t.filter((function(t,e,n){return n.indexOf(t)===e}))).pop();void 0!==e&&"string"==typeof e&&(n[e]=t)})),n}(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],l=n.envPrefix,h=o["populate--"],d=h?"--":"_",u=Object.create(null),f=Object.create(null),p=n.__||T.format,g={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},m=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,y=new RegExp("^--"+o["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach((function(t){const e="object"==typeof t?t.key:t,n=Object.keys(t).map((function(t){return{boolean:"bools",string:"strings",number:"numbers"}[t]})).filter(Boolean).pop();n&&(g[n][e]=!0),g.arrays[e]=!0,g.keys.push(e)})),[].concat(n.boolean||[]).filter(Boolean).forEach((function(t){g.bools[t]=!0,g.keys.push(t)})),[].concat(n.string||[]).filter(Boolean).forEach((function(t){g.strings[t]=!0,g.keys.push(t)})),[].concat(n.number||[]).filter(Boolean).forEach((function(t){g.numbers[t]=!0,g.keys.push(t)})),[].concat(n.count||[]).filter(Boolean).forEach((function(t){g.counts[t]=!0,g.keys.push(t)})),[].concat(n.normalize||[]).filter(Boolean).forEach((function(t){g.normalize[t]=!0,g.keys.push(t)})),"object"==typeof n.narg&&Object.entries(n.narg).forEach((([t,e])=>{"number"==typeof e&&(g.nargs[t]=e,g.keys.push(t))})),"object"==typeof n.coerce&&Object.entries(n.coerce).forEach((([t,e])=>{"function"==typeof e&&(g.coercions[t]=e,g.keys.push(t))})),void 0!==n.config&&(Array.isArray(n.config)||"string"==typeof n.config?[].concat(n.config).filter(Boolean).forEach((function(t){g.configs[t]=!0})):"object"==typeof n.config&&Object.entries(n.config).forEach((([t,e])=>{"boolean"!=typeof e&&"function"!=typeof e||(g.configs[t]=e)}))),function(...t){t.forEach((function(t){Object.keys(t||{}).forEach((function(t){g.aliases[t]||(g.aliases[t]=[].concat(r[t]||[]),g.aliases[t].concat(t).forEach((function(e){if(/-/.test(e)&&o["camel-case-expansion"]){const n=W(e);n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].concat(t).forEach((function(e){if(e.length>1&&/[A-Z]/.test(e)&&o["camel-case-expansion"]){const n=F(e,"-");n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].forEach((function(e){g.aliases[e]=[t].concat(g.aliases[t].filter((function(t){return e!==t})))})))}))}))}(n.key,r,n.default,g.arrays),Object.keys(a).forEach((function(t){(g.aliases[t]||[]).forEach((function(e){a[e]=a[t]}))}));let b=null;Object.keys(g.counts).find((t=>D(t,g.arrays)?(b=Error(p("Invalid configuration: %s, opts.count excludes opts.array.",t)),!0):!!D(t,g.nargs)&&(b=Error(p("Invalid configuration: %s, opts.count excludes opts.narg.",t)),!0)));let w=[];const v=Object.assign(Object.create(null),{_:[]}),O={};for(let t=0;t<s.length;t++){const e=s[t],n=e.replace(/^-{3,}/,"---");let i,r,a,c,l,h;if("--"!==e&&/^-/.test(e)&&R(e))k(e);else{if(n.match(/^---+(=|$)/)){k(e);continue}if(e.match(/^--.+=/)||!o["short-option-groups"]&&e.match(/^-.+=/))c=e.match(/^--?([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&(D(c[1],g.arrays)?t=j(t,c[1],s,c[2]):!1!==D(c[1],g.nargs)?t=E(t,c[1],s,c[2]):A(c[1],c[2],!0));else if(e.match(y)&&o["boolean-negation"])c=e.match(y),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],A(r,!!D(r,g.arrays)&&[!1]));else if(e.match(/^--.+/)||!o["short-option-groups"]&&e.match(/^-[^-]+/))c=e.match(/^--?(.+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],D(r,g.arrays)?t=j(t,r,s):!1!==D(r,g.nargs)?t=E(t,r,s):(l=s[t+1],void 0===l||l.match(/^-/)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(A(r,l),t++):A(r,B(r)):(A(r,l),t++)));else if(e.match(/^-.\..+=/))c=e.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&A(c[1],c[2]);else if(e.match(/^-.\..+/)&&!e.match(m))l=s[t+1],c=e.match(/^-(.\..+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],void 0===l||l.match(/^-/)||D(r,g.bools)||D(r,g.counts)?A(r,B(r)):(A(r,l),t++));else if(e.match(/^-[^-]+/)&&!e.match(m)){a=e.slice(1,-1).split(""),i=!1;for(let n=0;n<a.length;n++){if(l=e.slice(n+2),a[n+1]&&"="===a[n+1]){h=e.slice(n+3),r=a[n],D(r,g.arrays)?t=j(t,r,s,h):!1!==D(r,g.nargs)?t=E(t,r,s,h):A(r,h),i=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===D(l,g.bools)){A(a[n],l),i=!0;break}if(a[n+1]&&a[n+1].match(/\W/)){A(a[n],l),i=!0;break}A(a[n],B(a[n]))}else A(a[n],l)}r=e.slice(-1)[0],i||"-"===r||(D(r,g.arrays)?t=j(t,r,s):!1!==D(r,g.nargs)?t=E(t,r,s):(l=s[t+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(m)||D(r,g.bools)||D(r,g.counts)?/^(true|false)$/.test(l)?(A(r,l),t++):A(r,B(r)):(A(r,l),t++)))}else if(e.match(/^-[0-9]$/)&&e.match(m)&&D(e.slice(1),g.bools))r=e.slice(1),A(r,B(r));else{if("--"===e){w=s.slice(t+1);break}if(o["halt-at-non-option"]){w=s.slice(t);break}k(e)}}}function k(t){const e=P("_",t);"string"!=typeof e&&"number"!=typeof e||v._.push(e)}function E(t,e,n,s){let i,r=D(e,g.nargs);if(r="number"!=typeof r||isNaN(r)?1:r,0===r)return V(s)||(b=Error(p("Argument unexpected for: %s",e))),A(e,B(e)),t;let a=V(s)?0:1;if(o["nargs-eats-options"])n.length-(t+1)+a<r&&(b=Error(p("Not enough arguments following: %s",e))),a=r;else{for(i=t+1;i<n.length&&(!n[i].match(/^-[^0-9]/)||n[i].match(m)||R(n[i]));i++)a++;a<r&&(b=Error(p("Not enough arguments following: %s",e)))}let c=Math.min(a,r);for(!V(s)&&c>0&&(A(e,s),c--),i=t+1;i<c+t+1;i++)A(e,n[i]);return t+c}function j(t,e,n,s){let r=[],c=s||n[t+1];const l=D(e,g.nargs);if(D(e,g.bools)&&!/^(true|false)$/.test(c))r.push(!0);else if(V(c)||V(s)&&/^-/.test(c)&&!m.test(c)&&!R(c)){if(void 0!==a[e]){const t=a[e];r=Array.isArray(t)?t:[t]}}else{V(s)||r.push(x(e,s,!0));for(let s=t+1;s<n.length&&!(!o["greedy-arrays"]&&r.length>0||l&&"number"==typeof l&&r.length>=l)&&(c=n[s],!/^-/.test(c)||m.test(c)||R(c));s++)t=s,r.push(x(e,c,i))}return"number"==typeof l&&(l&&r.length<l||isNaN(l)&&0===r.length)&&(b=Error(p("Not enough arguments following: %s",e))),A(e,r),t}function A(t,e,n=i){if(/-/.test(t)&&o["camel-case-expansion"]){const e=t.split(".").map((function(t){return W(t)})).join(".");_(t,e)}const s=x(t,e,n),r=t.split(".");if(N(v,r,s),g.aliases[t]&&g.aliases[t].forEach((function(t){const e=t.split(".");N(v,e,s)})),r.length>1&&o["dot-notation"]&&(g.aliases[r[0]]||[]).forEach((function(e){let n=e.split(".");const i=[].concat(r);i.shift(),n=n.concat(i),(g.aliases[t]||[]).includes(n.join("."))||N(v,n,s)})),D(t,g.normalize)&&!D(t,g.arrays)){[t].concat(g.aliases[t]||[]).forEach((function(t){Object.defineProperty(O,t,{enumerable:!0,get:()=>e,set(t){e="string"==typeof t?T.normalize(t):t}})}))}}function _(t,e){g.aliases[t]&&g.aliases[t].length||(g.aliases[t]=[e],u[e]=!0),g.aliases[e]&&g.aliases[e].length||_(e,t)}function x(t,e,n){n&&(e=function(t){return"string"!=typeof t||"'"!==t[0]&&'"'!==t[0]||t[t.length-1]!==t[0]?t:t.substring(1,t.length-1)}(e)),(D(t,g.bools)||D(t,g.counts))&&"string"==typeof e&&(e="true"===e);let s=Array.isArray(e)?e.map((function(e){return P(t,e)})):P(t,e);return D(t,g.counts)&&(V(s)||"boolean"==typeof s)&&(s=U()),D(t,g.normalize)&&D(t,g.arrays)&&(s=Array.isArray(e)?e.map((t=>T.normalize(t))):T.normalize(e)),s}function P(t,e){if(!o["parse-positional-numbers"]&&"_"===t)return e;if(!D(t,g.strings)&&!D(t,g.bools)&&!Array.isArray(e)){(z(e)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${e}`)))||!V(e)&&D(t,g.numbers))&&(e=Number(e))}return e}function $(t,e){Object.keys(t).forEach((function(n){const s=t[n],i=e?e+"."+n:n;"object"==typeof s&&null!==s&&!Array.isArray(s)&&o["dot-notation"]?$(s,i):(!M(v,i.split("."))||D(i,g.arrays)&&o["combine-arrays"])&&A(i,s)}))}function C(t,e){if(void 0===l)return;const n="string"==typeof l?l:"",s=T.env();Object.keys(s).forEach((function(i){if(""===n||0===i.lastIndexOf(n,0)){const r=i.split("__").map((function(t,e){return 0===e&&(t=t.substring(n.length)),W(t)}));(e&&g.configs[r.join(".")]||!e)&&!M(t,r)&&A(r.join("."),s[i])}}))}function S(t,e,n,s=!1){Object.keys(n).forEach((function(i){M(t,i.split("."))||(N(t,i.split("."),n[i]),s&&(f[i]=!0),(e[i]||[]).forEach((function(e){M(t,e.split("."))||N(t,e.split("."),n[i])})))}))}function M(t,e){let n=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){n=n[t]||{}}));const s=e[e.length-1];return"object"==typeof n&&s in n}function N(t,e,n){let s=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){t=H(t),"object"==typeof s&&void 0===s[t]&&(s[t]={}),"object"!=typeof s[t]||Array.isArray(s[t])?(Array.isArray(s[t])?s[t].push({}):s[t]=[s[t],{}],s=s[t][s[t].length-1]):s=s[t]}));const i=H(e[e.length-1]),r=D(e.join("."),g.arrays),a=Array.isArray(n);let c=o["duplicate-arguments-array"];!c&&D(i,g.nargs)&&(c=!0,(!V(s[i])&&1===g.nargs[i]||Array.isArray(s[i])&&s[i].length===g.nargs[i])&&(s[i]=void 0)),n===U()?s[i]=U(s[i]):Array.isArray(s[i])?c&&r&&a?s[i]=o["flatten-duplicate-arrays"]?s[i].concat(n):(Array.isArray(s[i][0])?s[i]:[s[i]]).concat([n]):c||Boolean(r)!==Boolean(a)?s[i]=s[i].concat([n]):s[i]=n:void 0===s[i]&&r?s[i]=a?n:[n]:!c||void 0===s[i]||D(i,g.counts)||D(i,g.bools)?s[i]=n:s[i]=[s[i],n]}function D(t,e){const n=[].concat(g.aliases[t]||[],t),s=Object.keys(e),i=n.find((t=>s.includes(t)));return!!i&&e[i]}function I(t){const e=Object.keys(g);return[].concat(e.map((t=>g[t]))).some((function(e){return Array.isArray(e)?e.includes(t):e[t]}))}function R(t){return o["unknown-options-as-args"]&&function(t){if(t=t.replace(/^-{3,}/,"--"),t.match(m))return!1;if(function(t){if(t.match(m)||!t.match(/^-[^-]+/))return!1;let e,n=!0;const s=t.slice(1).split("");for(let i=0;i<s.length;i++){if(e=t.slice(i+2),!I(s[i])){n=!1;break}if(s[i+1]&&"="===s[i+1]||"-"===e||/[A-Za-z]/.test(s[i])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(e)||s[i+1]&&s[i+1].match(/\W/))break}return n}(t))return!1;return!function(t,...e){return[].concat(...e).some((function(e){const n=t.match(e);return n&&I(n[1])}))}(t,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}(t)}function B(t){return D(t,g.bools)||D(t,g.counts)||!(`${t}`in a)?(e=function(t){let e=L.BOOLEAN;return D(t,g.strings)?e=L.STRING:D(t,g.numbers)?e=L.NUMBER:D(t,g.bools)?e=L.BOOLEAN:D(t,g.arrays)&&(e=L.ARRAY),e}(t),{[L.BOOLEAN]:!0,[L.STRING]:"",[L.NUMBER]:void 0,[L.ARRAY]:[]}[e]):a[t];var e}function V(t){return void 0===t}return C(v,!0),C(v,!1),function(t){const e=Object.create(null);S(e,g.aliases,a),Object.keys(g.configs).forEach((function(n){const s=t[n]||e[n];if(s)try{let t=null;const e=T.resolve(T.cwd(),s),i=g.configs[n];if("function"==typeof i){try{t=i(e)}catch(e){t=e}if(t instanceof Error)return void(b=t)}else t=T.require(e);$(t)}catch(e){"PermissionDenied"===e.name?b=e:t[n]&&(b=Error(p("Invalid JSON config file: %s",s)))}}))}(v),void 0!==c&&c.forEach((function(t){$(t)})),S(v,g.aliases,a,!0),function(t){let e;const n=new Set;Object.keys(t).forEach((function(s){if(!n.has(s)&&(e=D(s,g.coercions),"function"==typeof e))try{const i=P(s,e(t[s]));[].concat(g.aliases[s]||[],s).forEach((e=>{n.add(e),t[e]=i}))}catch(t){b=t}}))}(v),o["set-placeholder-key"]&&function(t){g.keys.forEach((e=>{~e.indexOf(".")||void 0===t[e]&&(t[e]=void 0)}))}(v),Object.keys(g.counts).forEach((function(t){M(v,t.split("."))||A(t,0)})),h&&w.length&&(v[d]=[]),w.forEach((function(t){v[d].push(t)})),o["camel-case-expansion"]&&o["strip-dashed"]&&Object.keys(v).filter((t=>"--"!==t&&t.includes("-"))).forEach((t=>{delete v[t]})),o["strip-aliased"]&&[].concat(...Object.keys(r).map((t=>r[t]))).forEach((t=>{o["camel-case-expansion"]&&t.includes("-")&&delete v[t.split(".").map((t=>W(t))).join(".")],delete v[t]})),{aliases:Object.assign({},g.aliases),argv:Object.assign(O,v),configuration:o,defaulted:Object.assign({},f),error:b,newAliases:Object.assign({},u)}}}({cwd:process.cwd,env:()=>J,format:p,normalize:s,resolve:e,require:t=>{if("undefined"!=typeof require)return require(t);if(t.match(/\.json$/))return JSON.parse(u(t,"utf8"));throw Error("only .json config files are supported in ESM")}}),Q=function(t,e){return K.parse(t.slice(),e).argv};function Z(){return process.versions.electron&&!process.defaultApp?0:1}Q.detailed=function(t,e){return K.parse(t.slice(),e)},Q.camelCase=W,Q.decamelize=F,Q.looksLikeNumber=z;class X extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,X)}}var tt={fs:{readFileSync:u,writeFile:f},format:p,resolve:e,exists:t=>{try{return h(t).isFile()}catch(t){return!1}}};let et;class nt{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles="boolean"!=typeof t.updateFiles||t.updateFiles,this.locale=t.locale||"en",this.fallbackToLanguage="boolean"!=typeof t.fallbackToLanguage||t.fallbackToLanguage,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if("string"!=typeof arguments[0])return this._taggedLiteral(arguments[0],...arguments);const e=t.shift();let n=function(){};return"function"==typeof t[t.length-1]&&(n=t.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),et.format.apply(et.format,[this.cache[this.locale][e]||e].concat(t))}__n(){const t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),s=t.shift();let i=function(){};"function"==typeof t[t.length-1]&&(i=t.pop()),this.cache[this.locale]||this._readLocaleFile();let r=1===s?e:n;if(this.cache[this.locale][e]){r=this.cache[this.locale][e][1===s?"one":"other"]}!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();const o=[r];return~r.indexOf("%d")&&o.push(s),et.format.apply(et.format,o.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let n="";return t.forEach((function(t,s){const i=e[s+1];n+=t,void 0!==i&&(n+="%s")})),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),1===this.writeQueue.length&&this._processWriteQueue()}_processWriteQueue(){const t=this,e=this.writeQueue[0],n=e.directory,s=e.locale,i=e.cb,r=this._resolveLocaleFile(n,s),o=JSON.stringify(this.cache[s],null,2);et.fs.writeFile(r,o,"utf-8",(function(e){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),i(e)}))}_readLocaleFile(){let t={};const e=this._resolveLocaleFile(this.directory,this.locale);try{et.fs.readFileSync&&(t=JSON.parse(et.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),"ENOENT"!==n.code)throw n;t={}}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=et.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const s=et.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(t){return et.exists(t)}}const st="loading a directory of commands is not supported yet for ESM";let it;try{it=m(import.meta.url)}catch(t){it=process.cwd()}var rt,ot={assert:{notStrictEqual:a,strictEqual:c},cliui:function(t){return function(t,e){return N=e,new S({width:(null==t?void 0:t.width)||("object"==typeof process&&process.stdout&&process.stdout.columns?process.stdout.columns:80),wrap:null==t?void 0:t.wrap})}(t,{stringWidth:t=>[...t].length,stripAnsi:I,wrap:R})},findUp:function(t,s){let i,r=e(".",t);for(h(r).isDirectory()||(r=n(r));;){if(i=s(r,d(r)),i)return e(r,i);if(r=n(i=r),i===r)break}},getEnv:t=>process.env[t],inspect:g,getCallerFile:()=>{throw new X(st)},getProcessArgvBin:function(){return process.argv[Z()]},mainFilename:it.substring(0,it.lastIndexOf("node_modules"))||process.cwd(),Parser:Q,path:{basename:i,dirname:n,extname:r,relative:o,resolve:e},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(t,e)=>process.emitWarning(t,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:void 0!==process.stdout.columns?process.stdout.columns:null},readFileSync:u,require:()=>{throw new X("require is not supported by ESM")},requireDirectory:()=>{throw new X(st)},stringWidth:t=>[...t].length,y18n:(rt={directory:e(it,"../../../locales"),updateFiles:!1},function(t,e){et=e;const n=new nt(t);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}(rt,tt))};function at(t,e,n,s){n.assert.notStrictEqual(t,e,s)}function ct(t,e){e.assert.strictEqual(typeof t,"string")}function lt(t){return Object.keys(t)}function ht(t){return!!t&&!!t.then&&"function"==typeof t.then}function dt(t){const e=t.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,s=e.shift();if(!s)throw new Error(`No command found in: ${t}`);const i={cmd:s.replace(n,""),demanded:[],optional:[]};return e.forEach(((t,s)=>{let r=!1;t=t.replace(/\s/g,""),/\.+[\]>]/.test(t)&&s===e.length-1&&(r=!0),/^\[/.test(t)?i.optional.push({cmd:t.replace(n,"").split("|"),variadic:r}):i.demanded.push({cmd:t.replace(n,"").split("|"),variadic:r})})),i}const ut=["first","second","third","fourth","fifth","sixth"];function ft(t,e,n){try{let s=0;const[i,r,o]="object"==typeof t?[{demanded:[],optional:[]},t,e]:[dt(`cmd ${t}`),e,n],a=[].slice.call(r);for(;a.length&&void 0===a[a.length-1];)a.pop();const c=o||a.length;if(c<i.demanded.length)throw new X(`Not enough arguments provided. Expected ${i.demanded.length} but received ${a.length}.`);const l=i.demanded.length+i.optional.length;if(c>l)throw new X(`Too many arguments provided. Expected max ${l} but received ${c}.`);i.demanded.forEach((t=>{const e=pt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&>(e,t.cmd,s),s+=1})),i.optional.forEach((t=>{if(0===a.length)return;const e=pt(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&>(e,t.cmd,s),s+=1}))}catch(t){console.warn(t.stack)}}function pt(t){return Array.isArray(t)?"array":null===t?"null":typeof t}function gt(t,e,n){throw new X(`Invalid ${ut[n]||"manyith"} argument. Expected ${e.join(" or ")} but received ${t}.`)}class mt{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,s=!1){if(ft("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let s=0;s<t.length;s++){if("function"!=typeof t[s])throw Error("middleware must be a function");const i=t[s];i.applyBeforeValidation=e,i.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if("function"==typeof t){const i=t;i.applyBeforeValidation=e,i.global=n,i.mutates=s,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){const n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((t=>{const s=[...n[e]||[],e];return!t.option||!s.includes(t.option)})),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const t=this.frozens.pop();void 0!==t&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter((t=>t.global))}}function yt(t,e,n,s){return n.reduce(((t,n)=>{if(n.applyBeforeValidation!==s)return t;if(n.mutates){if(n.applied)return t;n.applied=!0}if(ht(t))return t.then((t=>Promise.all([t,n(t,e)]))).then((([t,e])=>Object.assign(t,e)));{const s=n(t,e);return ht(s)?s.then((e=>Object.assign(t,e))):Object.assign(t,s)}}),t)}function bt(t,e,n=(t=>{throw t})){try{const n="function"==typeof t?t():t;return ht(n)?n.then((t=>e(t))):e(n)}catch(t){return n(t)}}const wt=/(^\*)|(^\$0)/;class vt{constructor(t,e,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,s){"boolean"!=typeof(s=s||{}).recurse&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);const i="function"==typeof s.visit?s.visit:t=>t;s.visit=(t,e,n)=>{const s=i(t,e,n);if(s){if(this.requireCache.has(e))return s;this.requireCache.add(e),this.addHandler(s)}return s},this.shim.requireDirectory({require:e,filename:n},t,s)}addHandler(t,e,n,s,i,r){let o=[];const a=function(t){return t?t.map((t=>(t.applyBeforeValidation=!1,t))):[]}(i);if(s=s||(()=>{}),Array.isArray(t))if(function(t){return t.every((t=>"string"==typeof t))}(t))[t,...o]=t;else for(const e of t)this.addHandler(e);else{if(function(t){return"object"==typeof t&&!Array.isArray(t)}(t)){let e=Array.isArray(t.command)||"string"==typeof t.command?t.command:this.moduleName(t);return t.aliases&&(e=[].concat(e).concat(t.aliases)),void this.addHandler(e,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated)}if(Ot(n))return void this.addHandler([t].concat(o),e,n.builder,n.handler,n.middlewares,n.deprecated)}if("string"==typeof t){const i=dt(t);o=o.map((t=>dt(t).cmd));let c=!1;const l=[i.cmd].concat(o).filter((t=>!wt.test(t)||(c=!0,!1)));0===l.length&&c&&l.push("$0"),c&&(i.cmd=l[0],o=l.slice(1),t=t.replace(wt,i.cmd)),o.forEach((t=>{this.aliasMap[t]=i.cmd})),!1!==e&&this.usage.command(t,e,c,o,r),this.handlers[i.cmd]={original:t,description:e,handler:s,builder:n||{},middlewares:a,deprecated:r,demanded:i.demanded,optional:i.optional},c&&(this.defaultCommand=this.handlers[i.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,s,i,r){const o=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,a=e.getInternalMethods().getContext(),c=a.commands.slice(),l=!t;t&&(a.commands.push(t),a.fullCommands.push(o.original));const h=this.applyBuilderUpdateUsageAndParse(l,o,e,n.aliases,c,s,i,r);return ht(h)?h.then((t=>this.applyMiddlewareAndGetResult(l,o,t.innerArgv,a,i,t.aliases,e))):this.applyMiddlewareAndGetResult(l,o,h.innerArgv,a,i,h.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,s,i,r,o,a){const c=e.builder;let l=n;if(kt(c)){n.getInternalMethods().getUsageInstance().freeze();const h=c(n.getInternalMethods().reset(s),a);if(ht(h))return h.then((s=>{var a;return l=(a=s)&&"function"==typeof a.getInternalMethods?s:n,this.parseAndUpdateUsage(t,e,l,i,r,o)}))}else(function(t){return"object"==typeof t})(c)&&(n.getInternalMethods().getUsageInstance().freeze(),l=n.getInternalMethods().reset(s),Object.keys(e.builder).forEach((t=>{l.option(t,c[t])})));return this.parseAndUpdateUsage(t,e,l,i,r,o)}parseAndUpdateUsage(t,e,n,s,i,r){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(s,e),e.description);const o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,r);return ht(o)?o.then((t=>({aliases:n.parsed.aliases,innerArgv:t}))):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&0===t.getInternalMethods().getUsageInstance().getUsage().length}usageFromParentCommandsCommandHandler(t,e){const n=wt.test(e.original)?e.original.replace(wt,"").trim():e.original,s=t.filter((t=>!wt.test(t)));return s.push(n),`$0 ${s.join(" ")}`}handleValidationAndGetResult(t,e,n,s,i,r,o,a){if(!r.getInternalMethods().getHasOutput()){const e=r.getInternalMethods().runValidation(i,a,r.parsed.error,t);n=bt(n,(t=>(e(t),t)))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const s=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(n,s,!1,!1),n=bt(n=yt(n,r,o,!1),(t=>{const n=e.handler(t);return ht(n)?n.then((()=>t)):t})),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),ht(n)&&!r.getInternalMethods().hasParseCallback()&&n.catch((t=>{try{r.getInternalMethods().getUsageInstance().fail(null,t)}catch(t){}}))}return t||(s.commands.pop(),s.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,s,i,r,o){let a={};if(i)return n;o.getInternalMethods().getHasOutput()||(a=this.populatePositionals(e,n,s,o));const c=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),l=yt(n,o,c,!0);return ht(l)?l.then((n=>this.handleValidationAndGetResult(t,e,n,s,r,o,c,a))):this.handleValidationAndGetResult(t,e,l,s,r,o,c,a)}populatePositionals(t,e,n,s){e._=e._.slice(n.commands.length);const i=t.demanded.slice(0),r=t.optional.slice(0),o={};for(this.validation.positionalCount(i.length,e._.length);i.length;){const t=i.shift();this.populatePositional(t,e,o)}for(;r.length;){const t=r.shift();this.populatePositional(t,e,o)}return e._=n.commands.concat(e._.map((t=>""+t))),this.postProcessPositionals(e,o,this.cmdToParseOptions(t.original),s),o}populatePositional(t,e,n){const s=t.cmd[0];t.variadic?n[s]=e._.splice(0).map(String):e._.length&&(n[s]=[String(e._.shift())])}cmdToParseOptions(t){const e={array:[],default:{},alias:{},demand:{}},n=dt(t);return n.demanded.forEach((t=>{const[n,...s]=t.cmd;t.variadic&&(e.array.push(n),e.default[n]=[]),e.alias[n]=s,e.demand[n]=!0})),n.optional.forEach((t=>{const[n,...s]=t.cmd;t.variadic&&(e.array.push(n),e.default[n]=[]),e.alias[n]=s})),e}postProcessPositionals(t,e,n,s){const i=Object.assign({},s.getOptions());i.default=Object.assign(n.default,i.default);for(const t of Object.keys(n.alias))i.alias[t]=(i.alias[t]||[]).concat(n.alias[t]);i.array=i.array.concat(n.array),i.config={};const r=[];if(Object.keys(e).forEach((t=>{e[t].map((e=>{i.configuration["unknown-options-as-args"]&&(i.key[t]=!0),r.push(`--${t}`),r.push(e)}))})),!r.length)return;const o=Object.assign({},i.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},i,{configuration:o}));if(a.error)s.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{const n=Object.keys(e);Object.keys(e).forEach((t=>{n.push(...a.aliases[t])})),Object.keys(a.argv).forEach((i=>{n.includes(i)&&(e[i]||(e[i]=a.argv[i]),!this.isInConfigs(s,i)&&!this.isDefaulted(s,i)&&Object.prototype.hasOwnProperty.call(t,i)&&Object.prototype.hasOwnProperty.call(a.argv,i)&&(Array.isArray(t[i])||Array.isArray(a.argv[i]))?t[i]=[].concat(t[i],a.argv[i]):t[i]=a.argv[i])}))}}isDefaulted(t,e){const{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){const{configObjects:n}=t.getOptions();return n.some((t=>Object.prototype.hasOwnProperty.call(t,e)))||n.some((t=>Object.prototype.hasOwnProperty.call(t,this.shim.Parser.camelCase(e))))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){const e=wt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(e,this.defaultCommand.description)}const e=this.defaultCommand.builder;if(kt(e))return e(t,!0);Ot(e)||Object.keys(e).forEach((n=>{t.option(n,e[n])}))}moduleName(t){const e=function(t){if("undefined"==typeof require)return null;for(let e,n=0,s=Object.keys(require.cache);n<s.length;n++)if(e=require.cache[s[n]],e.exports===t)return e;return null}(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(const s of[t,e,n]){if("string"==typeof s||!1===s)return s;at(s,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const t=this.frozens.pop();at(t,void 0,this.shim),({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t)}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function Ot(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function kt(t){return"function"==typeof t}function Et(t={},e=(()=>!0)){const n={};return lt(t).forEach((s=>{e(s,t[s])&&(n[s]=t[s])})),n}function jt(t){"undefined"!=typeof process&&[process.stdout,process.stderr].forEach((e=>{const n=e;n._handle&&n.isTTY&&"function"==typeof n._handle.setBlocking&&n._handle.setBlocking(t)}))}function At(t){return"boolean"==typeof t}function _t(t,e){const n=e.y18n.__,s={},i=[];s.failFn=function(t){i.push(t)};let r=null,o=null,a=!0;s.showHelpOnFail=function(e=!0,n){const[i,c]="string"==typeof e?[!0,e]:[e,n];return t.getInternalMethods().isGlobalContext()&&(o=c),r=c,a=i,s};let c=!1;s.fail=function(e,n){const l=t.getInternalMethods().getLoggerInstance();if(!i.length){if(t.getExitProcess()&&jt(!0),!c){c=!0,a&&(t.showHelp("error"),l.error()),(e||n)&&l.error(e||n);const s=r||o;s&&((e||n)&&l.error(""),l.error(s))}if(n=n||new X(e),t.getExitProcess())return t.exit(1);if(t.getInternalMethods().hasParseCallback())return t.exit(1,n);throw n}for(let t=i.length-1;t>=0;--t){const r=i[t];if(At(r)){if(n)throw n;if(e)throw Error(e)}else r(e,n,s)}};let l=[],h=!1;s.usage=(t,e)=>null===t?(h=!0,l=[],s):(h=!1,l.push([t,e||""]),s),s.getUsage=()=>l,s.getUsageDisabled=()=>h,s.getPositionalGroupName=()=>n("Positionals:");let d=[];s.example=(t,e)=>{d.push([t,e||""])};let u=[];s.command=function(t,e,n,s,i=!1){n&&(u=u.map((t=>(t[2]=!1,t)))),u.push([t,e||"",n,s,i])},s.getCommands=()=>u;let f={};s.describe=function(t,e){Array.isArray(t)?t.forEach((t=>{s.describe(t,e)})):"object"==typeof t?Object.keys(t).forEach((e=>{s.describe(e,t[e])})):f[t]=e},s.getDescriptions=()=>f;let p=[];s.epilog=t=>{p.push(t)};let g,m=!1;s.wrap=t=>{m=!0,g=t},s.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(m||(g=function(){const t=80;return e.process.stdColumns?Math.min(t,e.process.stdColumns):t}(),m=!0),g);const y="__yargsString__:";function b(t,n,s){let i=0;return Array.isArray(t)||(t=Object.values(t).map((t=>[t]))),t.forEach((t=>{i=Math.max(e.stringWidth(s?`${s} ${$t(t[0])}`:$t(t[0]))+Pt(t[0]),i)})),n&&(i=Math.min(i,parseInt((.5*n).toString(),10))),i}let w;function v(e){return t.getOptions().hiddenOptions.indexOf(e)<0||t.parsed.argv[t.getOptions().showHiddenOpt]}function O(t,e){let s=`[${n("default:")} `;if(void 0===t&&!e)return null;if(e)s+=e;else switch(typeof t){case"string":s+=`"${t}"`;break;case"object":s+=JSON.stringify(t);break;default:s+=t}return`${s}]`}s.deferY18nLookup=t=>y+t,s.help=function(){if(w)return w;!function(){const e=t.getDemandedOptions(),n=t.getOptions();(Object.keys(n.alias)||[]).forEach((i=>{n.alias[i].forEach((r=>{f[r]&&s.describe(i,f[r]),r in e&&t.demandOption(i,e[r]),n.boolean.includes(r)&&t.boolean(i),n.count.includes(r)&&t.count(i),n.string.includes(r)&&t.string(i),n.normalize.includes(r)&&t.normalize(i),n.array.includes(r)&&t.array(i),n.number.includes(r)&&t.number(i)}))}))}();const i=t.customScriptName?t.$0:e.path.basename(t.$0),r=t.getDemandedOptions(),o=t.getDemandedCommands(),a=t.getDeprecatedOptions(),c=t.getGroups(),g=t.getOptions();let m=[];m=m.concat(Object.keys(f)),m=m.concat(Object.keys(r)),m=m.concat(Object.keys(o)),m=m.concat(Object.keys(g.default)),m=m.filter(v),m=Object.keys(m.reduce(((t,e)=>("_"!==e&&(t[e]=!0),t)),{}));const k=s.getWrap(),E=e.cliui({width:k,wrap:!!k});if(!h)if(l.length)l.forEach((t=>{E.div({text:`${t[0].replace(/\$0/g,i)}`}),t[1]&&E.div({text:`${t[1]}`,padding:[1,0,0,0]})})),E.div();else if(u.length){let t=null;t=o._?`${i} <${n("command")}>\n`:`${i} [${n("command")}]\n`,E.div(`${t}`)}if(u.length>1||1===u.length&&!u[0][2]){E.div(n("Commands:"));const e=t.getInternalMethods().getContext(),s=e.commands.length?`${e.commands.join(" ")} `:"";!0===t.getInternalMethods().getParserConfiguration()["sort-commands"]&&(u=u.sort(((t,e)=>t[0].localeCompare(e[0]))));const r=i?`${i} `:"";u.forEach((t=>{const e=`${r}${s}${t[0].replace(/^\$0 ?/,"")}`;E.span({text:e,padding:[0,2,0,2],width:b(u,k,`${i}${s}`)+4},{text:t[1]});const o=[];t[2]&&o.push(`[${n("default")}]`),t[3]&&t[3].length&&o.push(`[${n("aliases:")} ${t[3].join(", ")}]`),t[4]&&("string"==typeof t[4]?o.push(`[${n("deprecated: %s",t[4])}]`):o.push(`[${n("deprecated")}]`)),o.length?E.div({text:o.join(" "),padding:[0,0,0,2],align:"right"}):E.div()})),E.div()}const j=(Object.keys(g.alias)||[]).concat(Object.keys(t.parsed.newAliases)||[]);m=m.filter((e=>!t.parsed.newAliases[e]&&j.every((t=>-1===(g.alias[t]||[]).indexOf(e)))));const A=n("Options:");c[A]||(c[A]=[]),function(t,e,n,s){let i=[],r=null;Object.keys(n).forEach((t=>{i=i.concat(n[t])})),t.forEach((t=>{r=[t].concat(e[t]),r.some((t=>-1!==i.indexOf(t)))||n[s].push(t)}))}(m,g.alias,c,A);const _=t=>/^--/.test($t(t)),x=Object.keys(c).filter((t=>c[t].length>0)).map((t=>({groupName:t,normalizedKeys:c[t].filter(v).map((t=>{if(j.includes(t))return t;for(let e,n=0;void 0!==(e=j[n]);n++)if((g.alias[e]||[]).includes(t))return e;return t}))}))).filter((({normalizedKeys:t})=>t.length>0)).map((({groupName:t,normalizedKeys:e})=>{const n=e.reduce(((e,n)=>(e[n]=[n].concat(g.alias[n]||[]).map((e=>t===s.getPositionalGroupName()?e:(/^[0-9]$/.test(e)?g.boolean.includes(n)?"-":"--":e.length>1?"--":"-")+e)).sort(((t,e)=>_(t)===_(e)?0:_(t)?1:-1)).join(", "),e)),{});return{groupName:t,normalizedKeys:e,switches:n}}));if(x.filter((({groupName:t})=>t!==s.getPositionalGroupName())).some((({normalizedKeys:t,switches:e})=>!t.every((t=>_(e[t])))))&&x.filter((({groupName:t})=>t!==s.getPositionalGroupName())).forEach((({normalizedKeys:t,switches:e})=>{t.forEach((t=>{var n,s;_(e[t])&&(e[t]=(n=e[t],s=4,xt(n)?{text:n.text,indentation:n.indentation+s}:{text:n,indentation:s}))}))})),x.forEach((({groupName:e,normalizedKeys:i,switches:o})=>{E.div(e),i.forEach((e=>{const i=o[e];let c=f[e]||"",l=null;c.includes(y)&&(c=n(c.substring(16))),g.boolean.includes(e)&&(l=`[${n("boolean")}]`),g.count.includes(e)&&(l=`[${n("count")}]`),g.string.includes(e)&&(l=`[${n("string")}]`),g.normalize.includes(e)&&(l=`[${n("string")}]`),g.array.includes(e)&&(l=`[${n("array")}]`),g.number.includes(e)&&(l=`[${n("number")}]`);const h=[e in a?(d=a[e],"string"==typeof d?`[${n("deprecated: %s",d)}]`:`[${n("deprecated")}]`):null,l,e in r?`[${n("required")}]`:null,g.choices&&g.choices[e]?`[${n("choices:")} ${s.stringifiedValues(g.choices[e])}]`:null,O(g.default[e],g.defaultDescription[e])].filter(Boolean).join(" ");var d;E.span({text:$t(i),padding:[0,2,0,2+Pt(i)],width:b(o,k)+4},c);const u=!0===t.getInternalMethods().getUsageConfiguration()["hide-types"];h&&!u?E.div({text:h,padding:[0,0,0,2],align:"right"}):E.div()})),E.div()})),d.length&&(E.div(n("Examples:")),d.forEach((t=>{t[0]=t[0].replace(/\$0/g,i)})),d.forEach((t=>{""===t[1]?E.div({text:t[0],padding:[0,2,0,2]}):E.div({text:t[0],padding:[0,2,0,2],width:b(d,k)+4},{text:t[1]})})),E.div()),p.length>0){const t=p.map((t=>t.replace(/\$0/g,i))).join("\n");E.div(`${t}\n`)}return E.toString().replace(/\s*$/,"")},s.cacheHelpMessage=function(){w=this.help()},s.clearCachedHelpMessage=function(){w=void 0},s.hasCachedHelpMessage=function(){return!!w},s.showHelp=e=>{const n=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:n[e])(s.help())},s.functionDescription=t=>["(",t.name?e.Parser.decamelize(t.name,"-"):n("generated-value"),")"].join(""),s.stringifiedValues=function(t,e){let n="";const s=e||", ",i=[].concat(t);return t&&i.length?(i.forEach((t=>{n.length&&(n+=s),n+=JSON.stringify(t)})),n):n};let k=null;s.version=t=>{k=t},s.showVersion=e=>{const n=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:n[e])(k)},s.reset=function(t){return r=null,c=!1,l=[],h=!1,p=[],d=[],u=[],f=Et(f,(e=>!t[e])),s};const E=[];return s.freeze=function(){E.push({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f})},s.unfreeze=function(t=!1){const e=E.pop();e&&(t?(f={...e.descriptions,...f},u=[...e.commands,...u],l=[...e.usages,...l],d=[...e.examples,...d],p=[...e.epilogs,...p]):({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f}=e))},s}function xt(t){return"object"==typeof t}function Pt(t){return xt(t)?t.indentation:0}function $t(t){return xt(t)?t.text:t}class Ct{constructor(t,e,n,s){var i,r,o;this.yargs=t,this.usage=e,this.command=n,this.shim=s,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=null!==(o=(null===(i=this.shim.getEnv("SHELL"))||void 0===i?void 0:i.includes("zsh"))||(null===(r=this.shim.getEnv("ZSH_NAME"))||void 0===r?void 0:r.includes("zsh")))&&void 0!==o&&o}defaultCompletion(t,e,n,s){const i=this.command.getCommandHandlers();for(let e=0,n=t.length;e<n;++e)if(i[t[e]]&&i[t[e]].builder){const n=i[t[e]].builder;if(kt(n)){this.indexAfterLastReset=e+1;const t=this.yargs.getInternalMethods().reset();return n(t,!0),t.argv}}const r=[];this.commandCompletions(r,t,n),this.optionCompletions(r,t,e,n),this.choicesFromOptionsCompletions(r,t,e,n),this.choicesFromPositionalsCompletions(r,t,e,n),s(null,r)}commandCompletions(t,e,n){const s=this.yargs.getInternalMethods().getContext().commands;n.match(/^-/)||s[s.length-1]===n||this.previousArgHasChoices(e)||this.usage.getCommands().forEach((n=>{const s=dt(n[0]).cmd;if(-1===e.indexOf(s))if(this.zshShell){const e=n[1]||"";t.push(s.replace(/:/g,"\\:")+":"+e)}else t.push(s)}))}optionCompletions(t,e,n,s){if((s.match(/^-/)||""===s&&0===t.length)&&!this.previousArgHasChoices(e)){const n=this.yargs.getOptions(),i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(n.key).forEach((r=>{const o=!!n.configuration["boolean-negation"]&&n.boolean.includes(r);i.includes(r)||n.hiddenOptions.includes(r)||this.argsContainKey(e,r,o)||this.completeOptionKey(r,t,s,o&&!!n.default[r])}))}}choicesFromOptionsCompletions(t,e,n,s){if(this.previousArgHasChoices(e)){const n=this.getPreviousArgChoices(e);n&&n.length>0&&t.push(...n.map((t=>t.replace(/:/g,"\\:"))))}}choicesFromPositionalsCompletions(t,e,n,s){if(""===s&&t.length>0&&this.previousArgHasChoices(e))return;const i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=i[n._.length-r-1];if(!o)return;const a=this.yargs.getOptions().choices[o]||[];for(const e of a)e.startsWith(s)&&t.push(e.replace(/:/g,"\\:"))}getPreviousArgChoices(t){if(t.length<1)return;let e=t[t.length-1],n="";if(!e.startsWith("-")&&t.length>1&&(n=e,e=t[t.length-2]),!e.startsWith("-"))return;const s=e.replace(/^-+/,""),i=this.yargs.getOptions(),r=[s,...this.yargs.getAliases()[s]||[]];let o;for(const t of r)if(Object.prototype.hasOwnProperty.call(i.key,t)&&Array.isArray(i.choices[t])){o=i.choices[t];break}return o?o.filter((t=>!n||t.startsWith(n))):void 0}previousArgHasChoices(t){const e=this.getPreviousArgChoices(t);return void 0!==e&&e.length>0}argsContainKey(t,e,n){const s=e=>-1!==t.indexOf((/^[^0-9]$/.test(e)?"-":"--")+e);if(s(e))return!0;if(n&&s(`no-${e}`))return!0;if(this.aliases)for(const t of this.aliases[e])if(s(t))return!0;return!1}completeOptionKey(t,e,n,s){var i,r,o,a;let c=t;if(this.zshShell){const e=this.usage.getDescriptions(),n=null===(r=null===(i=null==this?void 0:this.aliases)||void 0===i?void 0:i[t])||void 0===r?void 0:r.find((t=>{const n=e[t];return"string"==typeof n&&n.length>0})),s=n?e[n]:void 0,l=null!==(a=null!==(o=e[t])&&void 0!==o?o:s)&&void 0!==a?a:"";c=`${t.replace(/:/g,"\\:")}:${l.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}const l=!/^--/.test(n)&&(t=>/^[^0-9]$/.test(t))(t)?"-":"--";e.push(l+c),s&&e.push(l+"no-"+c)}customCompletion(t,e,n,s){if(at(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const t=this.customCompletionFunction(n,e);return ht(t)?t.then((t=>{this.shim.process.nextTick((()=>{s(null,t)}))})).catch((t=>{this.shim.process.nextTick((()=>{s(t,void 0)}))})):s(null,t)}return function(t){return t.length>3}(this.customCompletionFunction)?this.customCompletionFunction(n,e,((i=s)=>this.defaultCompletion(t,e,n,i)),(t=>{s(null,t)})):this.customCompletionFunction(n,e,(t=>{s(null,t)}))}getCompletion(t,e){const n=t.length?t[t.length-1]:"",s=this.yargs.parse(t,!0),i=this.customCompletionFunction?s=>this.customCompletion(t,s,n,e):s=>this.defaultCompletion(t,s,n,e);return ht(s)?s.then(i):i(s)}generateCompletionScript(t,e){let n=this.zshShell?'#compdef {{app_name}}\n###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc\n# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local reply\n local si=$IFS\n IFS=$\'\n\' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "${words[@]}"))\n IFS=$si\n _describe \'values\' reply\n}\ncompdef _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n':'###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc\n# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local cur_word args type_list\n\n cur_word="${COMP_WORDS[COMP_CWORD]}"\n args=("${COMP_WORDS[@]}")\n\n # ask yargs to generate completions.\n type_list=$({{app_path}} --get-yargs-completions "${args[@]}")\n\n COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )\n\n # if no match was found, fall back to filename completion\n if [ ${#COMPREPLY[@]} -eq 0 ]; then\n COMPREPLY=()\n fi\n\n return 0\n}\ncomplete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n';const s=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),n=n.replace(/{{app_name}}/g,s),n=n.replace(/{{completion_command}}/g,e),n.replace(/{{app_path}}/g,t)}registerFunction(t){this.customCompletionFunction=t}setParsed(t){this.aliases=t.aliases}}function St(t,e){if(0===t.length)return e.length;if(0===e.length)return t.length;const n=[];let s,i;for(s=0;s<=e.length;s++)n[s]=[s];for(i=0;i<=t.length;i++)n[0][i]=i;for(s=1;s<=e.length;s++)for(i=1;i<=t.length;i++)e.charAt(s-1)===t.charAt(i-1)?n[s][i]=n[s-1][i-1]:s>1&&i>1&&e.charAt(s-2)===t.charAt(i-1)&&e.charAt(s-1)===t.charAt(i-2)?n[s][i]=n[s-2][i-2]+1:n[s][i]=Math.min(n[s-1][i-1]+1,Math.min(n[s][i-1]+1,n[s-1][i]+1));return n[e.length][t.length]}const Mt=["$0","--","_"];let Nt,Dt=[];function It(t,e,n,s){Nt=s;let i={};if(Object.prototype.hasOwnProperty.call(t,"extends")){if("string"!=typeof t.extends)return i;const s=/\.json|\..*rc$/.test(t.extends);let r=null;if(s)r=function(t,e){return Nt.path.resolve(t,e)}(e,t.extends);else try{r=require.resolve(t.extends)}catch(e){return t}!function(t){if(Dt.indexOf(t)>-1)throw new X(`Circular extended configurations: '${t}'.`)}(r),Dt.push(r),i=s?JSON.parse(Nt.readFileSync(r,"utf8")):require(t.extends),delete t.extends,i=It(i,Nt.path.dirname(r),n,Nt)}return Dt=[],n?Rt(i,t):Object.assign({},i,t)}function Rt(t,e){const n={};function s(t){return t&&"object"==typeof t&&!Array.isArray(t)}Object.assign(n,t);for(const i of Object.keys(e))s(e[i])&&s(n[i])?n[i]=Rt(t[i],e[i]):n[i]=e[i];return n}var Wt,Ft,zt,Lt,Tt,Ut,Ht,Bt,Vt,qt,Yt,Gt,Jt,Kt,Qt,Zt,Xt,te,ee,ne,se,ie,re,oe,ae,ce,le,he,de,ue,fe,pe,ge,me,ye,be=function(t,e,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(t,n):i?i.value=n:e.set(t,n),n},we=function(t,e,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(t):s?s.value:e.get(t)};const ve=Symbol("copyDoubleDash"),Oe=Symbol("copyDoubleDash"),ke=Symbol("deleteFromParserHintObject"),Ee=Symbol("emitWarning"),je=Symbol("freeze"),Ae=Symbol("getDollarZero"),_e=Symbol("getParserConfiguration"),xe=Symbol("getUsageConfiguration"),Pe=Symbol("guessLocale"),$e=Symbol("guessVersion"),Ce=Symbol("parsePositionalNumbers"),Se=Symbol("pkgUp"),Me=Symbol("populateParserHintArray"),Ne=Symbol("populateParserHintSingleValueDictionary"),De=Symbol("populateParserHintArrayDictionary"),Ie=Symbol("populateParserHintDictionary"),Re=Symbol("sanitizeKey"),We=Symbol("setKey"),Fe=Symbol("unfreeze"),ze=Symbol("validateAsync"),Le=Symbol("getCommandInstance"),Te=Symbol("getContext"),Ue=Symbol("getHasOutput"),He=Symbol("getLoggerInstance"),Be=Symbol("getParseContext"),Ve=Symbol("getUsageInstance"),qe=Symbol("getValidationInstance"),Ye=Symbol("hasParseCallback"),Ge=Symbol("isGlobalContext"),Je=Symbol("postProcess"),Ke=Symbol("rebase"),Qe=Symbol("reset"),Ze=Symbol("runYargsParserAndExecuteCommands"),Xe=Symbol("runValidation"),tn=Symbol("setHasOutput"),en=Symbol("kTrackManuallySetKeys");class nn{constructor(t=[],e,n,s){this.customScriptName=!1,this.parsed=!1,Wt.set(this,void 0),Ft.set(this,void 0),zt.set(this,{commands:[],fullCommands:[]}),Lt.set(this,null),Tt.set(this,null),Ut.set(this,"show-hidden"),Ht.set(this,null),Bt.set(this,!0),Vt.set(this,{}),qt.set(this,!0),Yt.set(this,[]),Gt.set(this,void 0),Jt.set(this,{}),Kt.set(this,!1),Qt.set(this,null),Zt.set(this,!0),Xt.set(this,void 0),te.set(this,""),ee.set(this,void 0),ne.set(this,void 0),se.set(this,{}),ie.set(this,null),re.set(this,null),oe.set(this,{}),ae.set(this,{}),ce.set(this,void 0),le.set(this,!1),he.set(this,void 0),de.set(this,!1),ue.set(this,!1),fe.set(this,!1),pe.set(this,void 0),ge.set(this,{}),me.set(this,null),ye.set(this,void 0),be(this,he,s,"f"),be(this,ce,t,"f"),be(this,Ft,e,"f"),be(this,ne,n,"f"),be(this,Gt,new mt(this),"f"),this.$0=this[Ae](),this[Qe](),be(this,Wt,we(this,Wt,"f"),"f"),be(this,pe,we(this,pe,"f"),"f"),be(this,ye,we(this,ye,"f"),"f"),be(this,ee,we(this,ee,"f"),"f"),we(this,ee,"f").showHiddenOpt=we(this,Ut,"f"),be(this,Xt,this[Oe](),"f")}addHelpOpt(t,e){return ft("[string|boolean] [string]",[t,e],arguments.length),we(this,Qt,"f")&&(this[ke](we(this,Qt,"f")),be(this,Qt,null,"f")),!1===t&&void 0===e||(be(this,Qt,"string"==typeof t?t:"help","f"),this.boolean(we(this,Qt,"f")),this.describe(we(this,Qt,"f"),e||we(this,pe,"f").deferY18nLookup("Show help"))),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(ft("[string|boolean] [string]",[t,e],arguments.length),!1===t&&void 0===e)return this;const n="string"==typeof t?t:we(this,Ut,"f");return this.boolean(n),this.describe(n,e||we(this,pe,"f").deferY18nLookup("Show hidden options")),we(this,ee,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return ft("<object|string|array> [string|array]",[t,e],arguments.length),this[De](this.alias.bind(this),"alias",t,e),this}array(t){return ft("<array|string>",[t],arguments.length),this[Me]("array",t),this[en](t),this}boolean(t){return ft("<array|string>",[t],arguments.length),this[Me]("boolean",t),this[en](t),this}check(t,e){return ft("<function> [boolean]",[t,e],arguments.length),this.middleware(((e,n)=>bt((()=>t(e,n.getOptions())),(n=>(n?("string"==typeof n||n instanceof Error)&&we(this,pe,"f").fail(n.toString(),n):we(this,pe,"f").fail(we(this,he,"f").y18n.__("Argument check failed: %s",t.toString())),e)),(t=>(we(this,pe,"f").fail(t.message?t.message:t.toString(),t),e)))),!1,e),this}choices(t,e){return ft("<object|string|array> [string|array]",[t,e],arguments.length),this[De](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(ft("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new X("coerce callback must be provided");for(const n of t)this.coerce(n,e);return this}if("object"==typeof t){for(const e of Object.keys(t))this.coerce(e,t[e]);return this}if(!e)throw new X("coerce callback must be provided");return we(this,ee,"f").key[t]=!0,we(this,Gt,"f").addCoerceMiddleware(((n,s)=>{let i;return Object.prototype.hasOwnProperty.call(n,t)?bt((()=>(i=s.getAliases(),e(n[t]))),(e=>{n[t]=e;const r=s.getInternalMethods().getParserConfiguration()["strip-aliased"];if(i[t]&&!0!==r)for(const s of i[t])n[s]=e;return n}),(t=>{throw new X(t.message)})):n}),t),this}conflicts(t,e){return ft("<string|object> [string|array]",[t,e],arguments.length),we(this,ye,"f").conflicts(t,e),this}config(t="config",e,n){return ft("[object|string] [string|function] [function]",[t,e,n],arguments.length),"object"!=typeof t||Array.isArray(t)?("function"==typeof e&&(n=e,e=void 0),this.describe(t,e||we(this,pe,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((t=>{we(this,ee,"f").config[t]=n||!0})),this):(t=It(t,we(this,Ft,"f"),this[_e]()["deep-merge-config"]||!1,we(this,he,"f")),we(this,ee,"f").configObjects=(we(this,ee,"f").configObjects||[]).concat(t),this)}completion(t,e,n){return ft("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),"function"==typeof e&&(n=e,e=void 0),be(this,Tt,t||we(this,Tt,"f")||"completion","f"),e||!1===e||(e="generate completion script"),this.command(we(this,Tt,"f"),e),n&&we(this,Lt,"f").registerFunction(n),this}command(t,e,n,s,i,r){return ft("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,s,i,r],arguments.length),we(this,Wt,"f").addHandler(t,e,n,s,i,r),this}commands(t,e,n,s,i,r){return this.command(t,e,n,s,i,r)}commandDir(t,e){ft("<string> [object]",[t,e],arguments.length);const n=we(this,ne,"f")||we(this,he,"f").require;return we(this,Wt,"f").addDirectory(t,n,we(this,he,"f").getCallerFile(),e),this}count(t){return ft("<array|string>",[t],arguments.length),this[Me]("count",t),this[en](t),this}default(t,e,n){return ft("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(ct(t,we(this,he,"f")),we(this,ee,"f").defaultDescription[t]=n),"function"==typeof e&&(ct(t,we(this,he,"f")),we(this,ee,"f").defaultDescription[t]||(we(this,ee,"f").defaultDescription[t]=we(this,pe,"f").functionDescription(e)),e=e.call()),this[Ne](this.default.bind(this),"default",t,e),this}defaults(t,e,n){return this.default(t,e,n)}demandCommand(t=1,e,n,s){return ft("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,n,s],arguments.length),"number"!=typeof e&&(n=e,e=1/0),this.global("_",!1),we(this,ee,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:s},this}demand(t,e,n){return Array.isArray(e)?(e.forEach((t=>{at(n,!0,we(this,he,"f")),this.demandOption(t,n)})),e=1/0):"number"!=typeof e&&(n=e,e=1/0),"number"==typeof t?(at(n,!0,we(this,he,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach((t=>{at(n,!0,we(this,he,"f")),this.demandOption(t,n)})):"string"==typeof n?this.demandOption(t,n):!0!==n&&void 0!==n||this.demandOption(t),this}demandOption(t,e){return ft("<object|string|array> [string]",[t,e],arguments.length),this[Ne](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return ft("<string> [string|boolean]",[t,e],arguments.length),we(this,ee,"f").deprecatedOptions[t]=e,this}describe(t,e){return ft("<object|string|array> [string]",[t,e],arguments.length),this[We](t,!0),we(this,pe,"f").describe(t,e),this}detectLocale(t){return ft("<boolean>",[t],arguments.length),be(this,Bt,t,"f"),this}env(t){return ft("[string|boolean]",[t],arguments.length),!1===t?delete we(this,ee,"f").envPrefix:we(this,ee,"f").envPrefix=t||"",this}epilogue(t){return ft("<string>",[t],arguments.length),we(this,pe,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return ft("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach((t=>this.example(...t))):we(this,pe,"f").example(t,e),this}exit(t,e){be(this,Kt,!0,"f"),be(this,Ht,e,"f"),we(this,qt,"f")&&we(this,he,"f").process.exit(t)}exitProcess(t=!0){return ft("[boolean]",[t],arguments.length),be(this,qt,t,"f"),this}fail(t){if(ft("<function|boolean>",[t],arguments.length),"boolean"==typeof t&&!1!==t)throw new X("Invalid first argument. Expected function or boolean 'false'");return we(this,pe,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return ft("<array> [function]",[t,e],arguments.length),e?we(this,Lt,"f").getCompletion(t,e):new Promise(((e,n)=>{we(this,Lt,"f").getCompletion(t,((t,s)=>{t?n(t):e(s)}))}))}getDemandedOptions(){return ft([],0),we(this,ee,"f").demandedOptions}getDemandedCommands(){return ft([],0),we(this,ee,"f").demandedCommands}getDeprecatedOptions(){return ft([],0),we(this,ee,"f").deprecatedOptions}getDetectLocale(){return we(this,Bt,"f")}getExitProcess(){return we(this,qt,"f")}getGroups(){return Object.assign({},we(this,Jt,"f"),we(this,ae,"f"))}getHelp(){if(be(this,Kt,!0,"f"),!we(this,pe,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[Ze](we(this,ce,"f"),void 0,void 0,0,!0);if(ht(t))return t.then((()=>we(this,pe,"f").help()))}const t=we(this,Wt,"f").runDefaultBuilderOn(this);if(ht(t))return t.then((()=>we(this,pe,"f").help()))}return Promise.resolve(we(this,pe,"f").help())}getOptions(){return we(this,ee,"f")}getStrict(){return we(this,de,"f")}getStrictCommands(){return we(this,ue,"f")}getStrictOptions(){return we(this,fe,"f")}global(t,e){return ft("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),!1!==e?we(this,ee,"f").local=we(this,ee,"f").local.filter((e=>-1===t.indexOf(e))):t.forEach((t=>{we(this,ee,"f").local.includes(t)||we(this,ee,"f").local.push(t)})),this}group(t,e){ft("<string|array> <string>",[t,e],arguments.length);const n=we(this,ae,"f")[e]||we(this,Jt,"f")[e];we(this,ae,"f")[e]&&delete we(this,ae,"f")[e];const s={};return we(this,Jt,"f")[e]=(n||[]).concat(t).filter((t=>!s[t]&&(s[t]=!0))),this}hide(t){return ft("<string>",[t],arguments.length),we(this,ee,"f").hiddenOptions.push(t),this}implies(t,e){return ft("<string|object> [number|string|array]",[t,e],arguments.length),we(this,ye,"f").implies(t,e),this}locale(t){return ft("[string]",[t],arguments.length),void 0===t?(this[Pe](),we(this,he,"f").y18n.getLocale()):(be(this,Bt,!1,"f"),we(this,he,"f").y18n.setLocale(t),this)}middleware(t,e,n){return we(this,Gt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return ft("<string|object|array> [number]",[t,e],arguments.length),this[Ne](this.nargs.bind(this),"narg",t,e),this}normalize(t){return ft("<array|string>",[t],arguments.length),this[Me]("normalize",t),this}number(t){return ft("<array|string>",[t],arguments.length),this[Me]("number",t),this[en](t),this}option(t,e){if(ft("<string|object> [object]",[t,e],arguments.length),"object"==typeof t)Object.keys(t).forEach((e=>{this.options(e,t[e])}));else{"object"!=typeof e&&(e={}),this[en](t),!we(this,me,"f")||"version"!==t&&"version"!==(null==e?void 0:e.alias)||this[Ee](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join("\n"),void 0,"versionWarning"),we(this,ee,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);const n=e.deprecate||e.deprecated;n&&this.deprecateOption(t,n);const s=e.demand||e.required||e.require;s&&this.demand(t,s),e.demandOption&&this.demandOption(t,"string"==typeof e.demandOption?e.demandOption:void 0),e.conflicts&&this.conflicts(t,e.conflicts),"default"in e&&this.default(t,e.default),void 0!==e.implies&&this.implies(t,e.implies),void 0!==e.nargs&&this.nargs(t,e.nargs),e.config&&this.config(t,e.configParser),e.normalize&&this.normalize(t),e.choices&&this.choices(t,e.choices),e.coerce&&this.coerce(t,e.coerce),e.group&&this.group(t,e.group),(e.boolean||"boolean"===e.type)&&(this.boolean(t),e.alias&&this.boolean(e.alias)),(e.array||"array"===e.type)&&(this.array(t),e.alias&&this.array(e.alias)),(e.number||"number"===e.type)&&(this.number(t),e.alias&&this.number(e.alias)),(e.string||"string"===e.type)&&(this.string(t),e.alias&&this.string(e.alias)),(e.count||"count"===e.type)&&this.count(t),"boolean"==typeof e.global&&this.global(t,e.global),e.defaultDescription&&(we(this,ee,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);const i=e.describe||e.description||e.desc,r=we(this,pe,"f").getDescriptions();Object.prototype.hasOwnProperty.call(r,t)&&"string"!=typeof i||this.describe(t,i),e.hidden&&this.hide(t),e.requiresArg&&this.requiresArg(t)}return this}options(t,e){return this.option(t,e)}parse(t,e,n){ft("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[je](),void 0===t&&(t=we(this,ce,"f")),"object"==typeof e&&(be(this,re,e,"f"),e=n),"function"==typeof e&&(be(this,ie,e,"f"),e=!1),e||be(this,ce,t,"f"),we(this,ie,"f")&&be(this,qt,!1,"f");const s=this[Ze](t,!!e),i=this.parsed;return we(this,Lt,"f").setParsed(this.parsed),ht(s)?s.then((t=>(we(this,ie,"f")&&we(this,ie,"f").call(this,we(this,Ht,"f"),t,we(this,te,"f")),t))).catch((t=>{throw we(this,ie,"f")&&we(this,ie,"f")(t,this.parsed.argv,we(this,te,"f")),t})).finally((()=>{this[Fe](),this.parsed=i})):(we(this,ie,"f")&&we(this,ie,"f").call(this,we(this,Ht,"f"),s,we(this,te,"f")),this[Fe](),this.parsed=i,s)}parseAsync(t,e,n){const s=this.parse(t,e,n);return ht(s)?s:Promise.resolve(s)}parseSync(t,e,n){const s=this.parse(t,e,n);if(ht(s))throw new X(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(t){return ft("<object>",[t],arguments.length),be(this,se,t,"f"),this}pkgConf(t,e){ft("<string> [string]",[t,e],arguments.length);let n=null;const s=this[Se](e||we(this,Ft,"f"));return s[t]&&"object"==typeof s[t]&&(n=It(s[t],e||we(this,Ft,"f"),this[_e]()["deep-merge-config"]||!1,we(this,he,"f")),we(this,ee,"f").configObjects=(we(this,ee,"f").configObjects||[]).concat(n)),this}positional(t,e){ft("<string> <object>",[t,e],arguments.length);const n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=Et(e,((t,e)=>!("type"===t&&!["string","number","boolean"].includes(e))&&n.includes(t)));const s=we(this,zt,"f").fullCommands[we(this,zt,"f").fullCommands.length-1],i=s?we(this,Wt,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return lt(i).forEach((n=>{const s=i[n];Array.isArray(s)?-1!==s.indexOf(t)&&(e[n]=!0):s[t]&&!(n in e)&&(e[n]=s[t])})),this.group(t,we(this,pe,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return ft("[boolean]",[t],arguments.length),be(this,le,t,"f"),this}required(t,e,n){return this.demand(t,e,n)}require(t,e,n){return this.demand(t,e,n)}requiresArg(t){return ft("<array|string|object> [number]",[t],arguments.length),"string"==typeof t&&we(this,ee,"f").narg[t]||this[Ne](this.requiresArg.bind(this),"narg",t,NaN),this}showCompletionScript(t,e){return ft("[string] [string]",[t,e],arguments.length),t=t||this.$0,we(this,Xt,"f").log(we(this,Lt,"f").generateCompletionScript(t,e||we(this,Tt,"f")||"completion")),this}showHelp(t){if(ft("[string|function]",[t],arguments.length),be(this,Kt,!0,"f"),!we(this,pe,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[Ze](we(this,ce,"f"),void 0,void 0,0,!0);if(ht(e))return e.then((()=>{we(this,pe,"f").showHelp(t)})),this}const e=we(this,Wt,"f").runDefaultBuilderOn(this);if(ht(e))return e.then((()=>{we(this,pe,"f").showHelp(t)})),this}return we(this,pe,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return ft("[boolean|string] [string]",[t,e],arguments.length),we(this,pe,"f").showHelpOnFail(t,e),this}showVersion(t){return ft("[string|function]",[t],arguments.length),we(this,pe,"f").showVersion(t),this}skipValidation(t){return ft("<array|string>",[t],arguments.length),this[Me]("skipValidation",t),this}strict(t){return ft("[boolean]",[t],arguments.length),be(this,de,!1!==t,"f"),this}strictCommands(t){return ft("[boolean]",[t],arguments.length),be(this,ue,!1!==t,"f"),this}strictOptions(t){return ft("[boolean]",[t],arguments.length),be(this,fe,!1!==t,"f"),this}string(t){return ft("<array|string>",[t],arguments.length),this[Me]("string",t),this[en](t),this}terminalWidth(){return ft([],0),we(this,he,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return ft("<object>",[t],arguments.length),be(this,Bt,!1,"f"),we(this,he,"f").y18n.updateLocale(t),this}usage(t,e,n,s){if(ft("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,s],arguments.length),void 0!==e){if(at(t,null,we(this,he,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,s);throw new X(".usage() description must start with $0 if being used as alias for .command()")}return we(this,pe,"f").usage(t),this}usageConfiguration(t){return ft("<object>",[t],arguments.length),be(this,ge,t,"f"),this}version(t,e,n){const s="version";if(ft("[boolean|string] [string] [string]",[t,e,n],arguments.length),we(this,me,"f")&&(this[ke](we(this,me,"f")),we(this,pe,"f").version(void 0),be(this,me,null,"f")),0===arguments.length)n=this[$e](),t=s;else if(1===arguments.length){if(!1===t)return this;n=t,t=s}else 2===arguments.length&&(n=e,e=void 0);return be(this,me,"string"==typeof t?t:s,"f"),e=e||we(this,pe,"f").deferY18nLookup("Show version number"),we(this,pe,"f").version(n||void 0),this.boolean(we(this,me,"f")),this.describe(we(this,me,"f"),e),this}wrap(t){return ft("<number|null|undefined>",[t],arguments.length),we(this,pe,"f").wrap(t),this}[(Wt=new WeakMap,Ft=new WeakMap,zt=new WeakMap,Lt=new WeakMap,Tt=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,Bt=new WeakMap,Vt=new WeakMap,qt=new WeakMap,Yt=new WeakMap,Gt=new WeakMap,Jt=new WeakMap,Kt=new WeakMap,Qt=new WeakMap,Zt=new WeakMap,Xt=new WeakMap,te=new WeakMap,ee=new WeakMap,ne=new WeakMap,se=new WeakMap,ie=new WeakMap,re=new WeakMap,oe=new WeakMap,ae=new WeakMap,ce=new WeakMap,le=new WeakMap,he=new WeakMap,de=new WeakMap,ue=new WeakMap,fe=new WeakMap,pe=new WeakMap,ge=new WeakMap,me=new WeakMap,ye=new WeakMap,ve)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch(t){}return t}[Oe](){return{log:(...t)=>{this[Ye]()||console.log(...t),be(this,Kt,!0,"f"),we(this,te,"f").length&&be(this,te,we(this,te,"f")+"\n","f"),be(this,te,we(this,te,"f")+t.join(" "),"f")},error:(...t)=>{this[Ye]()||console.error(...t),be(this,Kt,!0,"f"),we(this,te,"f").length&&be(this,te,we(this,te,"f")+"\n","f"),be(this,te,we(this,te,"f")+t.join(" "),"f")}}}[ke](t){lt(we(this,ee,"f")).forEach((e=>{if("configObjects"===e)return;const n=we(this,ee,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):"object"==typeof n&&delete n[t]})),delete we(this,pe,"f").getDescriptions()[t]}[Ee](t,e,n){we(this,Vt,"f")[n]||(we(this,he,"f").process.emitWarning(t,e),we(this,Vt,"f")[n]=!0)}[je](){we(this,Yt,"f").push({options:we(this,ee,"f"),configObjects:we(this,ee,"f").configObjects.slice(0),exitProcess:we(this,qt,"f"),groups:we(this,Jt,"f"),strict:we(this,de,"f"),strictCommands:we(this,ue,"f"),strictOptions:we(this,fe,"f"),completionCommand:we(this,Tt,"f"),output:we(this,te,"f"),exitError:we(this,Ht,"f"),hasOutput:we(this,Kt,"f"),parsed:this.parsed,parseFn:we(this,ie,"f"),parseContext:we(this,re,"f")}),we(this,pe,"f").freeze(),we(this,ye,"f").freeze(),we(this,Wt,"f").freeze(),we(this,Gt,"f").freeze()}[Ae](){let t,e="";return t=/\b(node|iojs|electron)(\.exe)?$/.test(we(this,he,"f").process.argv()[0])?we(this,he,"f").process.argv().slice(1,2):we(this,he,"f").process.argv().slice(0,1),e=t.map((t=>{const e=this[Ke](we(this,Ft,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&e.length<t.length?e:t})).join(" ").trim(),we(this,he,"f").getEnv("_")&&we(this,he,"f").getProcessArgvBin()===we(this,he,"f").getEnv("_")&&(e=we(this,he,"f").getEnv("_").replace(`${we(this,he,"f").path.dirname(we(this,he,"f").process.execPath())}/`,"")),e}[_e](){return we(this,se,"f")}[xe](){return we(this,ge,"f")}[Pe](){if(!we(this,Bt,"f"))return;const t=we(this,he,"f").getEnv("LC_ALL")||we(this,he,"f").getEnv("LC_MESSAGES")||we(this,he,"f").getEnv("LANG")||we(this,he,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[$e](){return this[Se]().version||"unknown"}[Ce](t){const e=t["--"]?t["--"]:t._;for(let t,n=0;void 0!==(t=e[n]);n++)we(this,he,"f").Parser.looksLikeNumber(t)&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))&&(e[n]=Number(t));return t}[Se](t){const e=t||"*";if(we(this,oe,"f")[e])return we(this,oe,"f")[e];let n={};try{let e=t||we(this,he,"f").mainFilename;!t&&we(this,he,"f").path.extname(e)&&(e=we(this,he,"f").path.dirname(e));const s=we(this,he,"f").findUp(e,((t,e)=>e.includes("package.json")?"package.json":void 0));at(s,void 0,we(this,he,"f")),n=JSON.parse(we(this,he,"f").readFileSync(s,"utf8"))}catch(t){}return we(this,oe,"f")[e]=n||{},we(this,oe,"f")[e]}[Me](t,e){(e=[].concat(e)).forEach((e=>{e=this[Re](e),we(this,ee,"f")[t].push(e)}))}[Ne](t,e,n,s){this[Ie](t,e,n,s,((t,e,n)=>{we(this,ee,"f")[t][e]=n}))}[De](t,e,n,s){this[Ie](t,e,n,s,((t,e,n)=>{we(this,ee,"f")[t][e]=(we(this,ee,"f")[t][e]||[]).concat(n)}))}[Ie](t,e,n,s,i){if(Array.isArray(n))n.forEach((e=>{t(e,s)}));else if((t=>"object"==typeof t)(n))for(const e of lt(n))t(e,n[e]);else i(e,this[Re](n),s)}[Re](t){return"__proto__"===t?"___proto___":t}[We](t,e){return this[Ne](this[We].bind(this),"key",t,e),this}[Fe](){var t,e,n,s,i,r,o,a,c,l,h,d;const u=we(this,Yt,"f").pop();let f;at(u,void 0,we(this,he,"f")),t=this,e=this,n=this,s=this,i=this,r=this,o=this,a=this,c=this,l=this,h=this,d=this,({options:{set value(e){be(t,ee,e,"f")}}.value,configObjects:f,exitProcess:{set value(t){be(e,qt,t,"f")}}.value,groups:{set value(t){be(n,Jt,t,"f")}}.value,output:{set value(t){be(s,te,t,"f")}}.value,exitError:{set value(t){be(i,Ht,t,"f")}}.value,hasOutput:{set value(t){be(r,Kt,t,"f")}}.value,parsed:this.parsed,strict:{set value(t){be(o,de,t,"f")}}.value,strictCommands:{set value(t){be(a,ue,t,"f")}}.value,strictOptions:{set value(t){be(c,fe,t,"f")}}.value,completionCommand:{set value(t){be(l,Tt,t,"f")}}.value,parseFn:{set value(t){be(h,ie,t,"f")}}.value,parseContext:{set value(t){be(d,re,t,"f")}}.value}=u),we(this,ee,"f").configObjects=f,we(this,pe,"f").unfreeze(),we(this,ye,"f").unfreeze(),we(this,Wt,"f").unfreeze(),we(this,Gt,"f").unfreeze()}[ze](t,e){return bt(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[Le].bind(this),getContext:this[Te].bind(this),getHasOutput:this[Ue].bind(this),getLoggerInstance:this[He].bind(this),getParseContext:this[Be].bind(this),getParserConfiguration:this[_e].bind(this),getUsageConfiguration:this[xe].bind(this),getUsageInstance:this[Ve].bind(this),getValidationInstance:this[qe].bind(this),hasParseCallback:this[Ye].bind(this),isGlobalContext:this[Ge].bind(this),postProcess:this[Je].bind(this),reset:this[Qe].bind(this),runValidation:this[Xe].bind(this),runYargsParserAndExecuteCommands:this[Ze].bind(this),setHasOutput:this[tn].bind(this)}}[Le](){return we(this,Wt,"f")}[Te](){return we(this,zt,"f")}[Ue](){return we(this,Kt,"f")}[He](){return we(this,Xt,"f")}[Be](){return we(this,re,"f")||{}}[Ve](){return we(this,pe,"f")}[qe](){return we(this,ye,"f")}[Ye](){return!!we(this,ie,"f")}[Ge](){return we(this,Zt,"f")}[Je](t,e,n,s){if(n)return t;if(ht(t))return t;e||(t=this[ve](t));return(this[_e]()["parse-positional-numbers"]||void 0===this[_e]()["parse-positional-numbers"])&&(t=this[Ce](t)),s&&(t=yt(t,this,we(this,Gt,"f").getMiddleware(),!1)),t}[Qe](t={}){be(this,ee,we(this,ee,"f")||{},"f");const e={};e.local=we(this,ee,"f").local||[],e.configObjects=we(this,ee,"f").configObjects||[];const n={};e.local.forEach((e=>{n[e]=!0,(t[e]||[]).forEach((t=>{n[t]=!0}))})),Object.assign(we(this,ae,"f"),Object.keys(we(this,Jt,"f")).reduce(((t,e)=>{const s=we(this,Jt,"f")[e].filter((t=>!(t in n)));return s.length>0&&(t[e]=s),t}),{})),be(this,Jt,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((t=>{e[t]=(we(this,ee,"f")[t]||[]).filter((t=>!n[t]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((t=>{e[t]=Et(we(this,ee,"f")[t],(t=>!n[t]))})),e.envPrefix=we(this,ee,"f").envPrefix,be(this,ee,e,"f"),be(this,pe,we(this,pe,"f")?we(this,pe,"f").reset(n):_t(this,we(this,he,"f")),"f"),be(this,ye,we(this,ye,"f")?we(this,ye,"f").reset(n):function(t,e,n){const s=n.y18n.__,i=n.y18n.__n,r={nonOptionCount:function(n){const s=t.getDemandedCommands(),r=n._.length+(n["--"]?n["--"].length:0)-t.getInternalMethods().getContext().commands.length;s._&&(r<s._.min||r>s._.max)&&(r<s._.min?void 0!==s._.minMsg?e.fail(s._.minMsg?s._.minMsg.replace(/\$0/g,r.toString()).replace(/\$1/,s._.min.toString()):null):e.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",r,r.toString(),s._.min.toString())):r>s._.max&&(void 0!==s._.maxMsg?e.fail(s._.maxMsg?s._.maxMsg.replace(/\$0/g,r.toString()).replace(/\$1/,s._.max.toString()):null):e.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",r,r.toString(),s._.max.toString()))))},positionalCount:function(t,n){n<t&&e.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",n,n+"",t+""))},requiredArguments:function(t,n){let s=null;for(const e of Object.keys(n))Object.prototype.hasOwnProperty.call(t,e)&&void 0!==t[e]||(s=s||{},s[e]=n[e]);if(s){const t=[];for(const e of Object.keys(s)){const n=s[e];n&&t.indexOf(n)<0&&t.push(n)}const n=t.length?`\n${t.join("\n")}`:"";e.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(s).length,Object.keys(s).join(", ")+n))}},unknownArguments:function(n,s,o,a,c=!0){var l;const h=t.getInternalMethods().getCommandInstance().getCommands(),d=[],u=t.getInternalMethods().getContext();if(Object.keys(n).forEach((e=>{Mt.includes(e)||Object.prototype.hasOwnProperty.call(o,e)||Object.prototype.hasOwnProperty.call(t.getInternalMethods().getParseContext(),e)||r.isValidAndSomeAliasIsNotNew(e,s)||d.push(e)})),c&&(u.commands.length>0||h.length>0||a)&&n._.slice(u.commands.length).forEach((t=>{h.includes(""+t)||d.push(""+t)})),c){const e=(null===(l=t.getDemandedCommands()._)||void 0===l?void 0:l.max)||0,s=u.commands.length+e;s<n._.length&&n._.slice(s).forEach((t=>{t=String(t),u.commands.includes(t)||d.includes(t)||d.push(t)}))}d.length&&e.fail(i("Unknown argument: %s","Unknown arguments: %s",d.length,d.map((t=>t.trim()?t:`"${t}"`)).join(", ")))},unknownCommands:function(n){const s=t.getInternalMethods().getCommandInstance().getCommands(),r=[],o=t.getInternalMethods().getContext();return(o.commands.length>0||s.length>0)&&n._.slice(o.commands.length).forEach((t=>{s.includes(""+t)||r.push(""+t)})),r.length>0&&(e.fail(i("Unknown command: %s","Unknown commands: %s",r.length,r.join(", "))),!0)},isValidAndSomeAliasIsNotNew:function(e,n){if(!Object.prototype.hasOwnProperty.call(n,e))return!1;const s=t.parsed.newAliases;return[e,...n[e]].some((t=>!Object.prototype.hasOwnProperty.call(s,t)||!s[e]))},limitedChoices:function(n){const i=t.getOptions(),r={};if(!Object.keys(i.choices).length)return;Object.keys(n).forEach((t=>{-1===Mt.indexOf(t)&&Object.prototype.hasOwnProperty.call(i.choices,t)&&[].concat(n[t]).forEach((e=>{-1===i.choices[t].indexOf(e)&&void 0!==e&&(r[t]=(r[t]||[]).concat(e))}))}));const o=Object.keys(r);if(!o.length)return;let a=s("Invalid values:");o.forEach((t=>{a+=`\n ${s("Argument: %s, Given: %s, Choices: %s",t,e.stringifiedValues(r[t]),e.stringifiedValues(i.choices[t]))}`})),e.fail(a)}};let o={};function a(t,e){const n=Number(e);return"number"==typeof(e=isNaN(n)?e:n)?e=t._.length>=e:e.match(/^--no-.+/)?(e=e.match(/^--no-(.+)/)[1],e=!Object.prototype.hasOwnProperty.call(t,e)):e=Object.prototype.hasOwnProperty.call(t,e),e}r.implies=function(e,s){ft("<string|object> [array|number|string]",[e,s],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.implies(t,e[t])})):(t.global(e),o[e]||(o[e]=[]),Array.isArray(s)?s.forEach((t=>r.implies(e,t))):(at(s,void 0,n),o[e].push(s)))},r.getImplied=function(){return o},r.implications=function(t){const n=[];if(Object.keys(o).forEach((e=>{const s=e;(o[e]||[]).forEach((e=>{let i=s;const r=e;i=a(t,i),e=a(t,e),i&&!e&&n.push(` ${s} -> ${r}`)}))})),n.length){let t=`${s("Implications failed:")}\n`;n.forEach((e=>{t+=e})),e.fail(t)}};let c={};r.conflicts=function(e,n){ft("<string|object> [array|string]",[e,n],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.conflicts(t,e[t])})):(t.global(e),c[e]||(c[e]=[]),Array.isArray(n)?n.forEach((t=>r.conflicts(e,t))):c[e].push(n))},r.getConflicting=()=>c,r.conflicting=function(i){Object.keys(i).forEach((t=>{c[t]&&c[t].forEach((n=>{n&&void 0!==i[t]&&void 0!==i[n]&&e.fail(s("Arguments %s and %s are mutually exclusive",t,n))}))})),t.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(c).forEach((t=>{c[t].forEach((r=>{r&&void 0!==i[n.Parser.camelCase(t)]&&void 0!==i[n.Parser.camelCase(r)]&&e.fail(s("Arguments %s and %s are mutually exclusive",t,r))}))}))},r.recommendCommands=function(t,n){n=n.sort(((t,e)=>e.length-t.length));let i=null,r=1/0;for(let e,s=0;void 0!==(e=n[s]);s++){const n=St(t,e);n<=3&&n<r&&(r=n,i=e)}i&&e.fail(s("Did you mean %s?",i))},r.reset=function(t){return o=Et(o,(e=>!t[e])),c=Et(c,(e=>!t[e])),r};const l=[];return r.freeze=function(){l.push({implied:o,conflicting:c})},r.unfreeze=function(){const t=l.pop();at(t,void 0,n),({implied:o,conflicting:c}=t)},r}(this,we(this,pe,"f"),we(this,he,"f")),"f"),be(this,Wt,we(this,Wt,"f")?we(this,Wt,"f").reset():function(t,e,n,s){return new vt(t,e,n,s)}(we(this,pe,"f"),we(this,ye,"f"),we(this,Gt,"f"),we(this,he,"f")),"f"),we(this,Lt,"f")||be(this,Lt,function(t,e,n,s){return new Ct(t,e,n,s)}(this,we(this,pe,"f"),we(this,Wt,"f"),we(this,he,"f")),"f"),we(this,Gt,"f").reset(),be(this,Tt,null,"f"),be(this,te,"","f"),be(this,Ht,null,"f"),be(this,Kt,!1,"f"),this.parsed=!1,this}[Ke](t,e){return we(this,he,"f").path.relative(t,e)}[Ze](t,e,n,s=0,i=!1){let r=!!n||i;t=t||we(this,ce,"f"),we(this,ee,"f").__=we(this,he,"f").y18n.__,we(this,ee,"f").configuration=this[_e]();const o=!!we(this,ee,"f").configuration["populate--"],a=Object.assign({},we(this,ee,"f").configuration,{"populate--":!0}),c=we(this,he,"f").Parser.detailed(t,Object.assign({},we(this,ee,"f"),{configuration:{"parse-positional-numbers":!1,...a}})),l=Object.assign(c.argv,we(this,re,"f"));let h;const d=c.aliases;let u=!1,f=!1;Object.keys(l).forEach((t=>{t===we(this,Qt,"f")&&l[t]?u=!0:t===we(this,me,"f")&&l[t]&&(f=!0)})),l.$0=this.$0,this.parsed=c,0===s&&we(this,pe,"f").clearCachedHelpMessage();try{if(this[Pe](),e)return this[Je](l,o,!!n,!1);if(we(this,Qt,"f")){[we(this,Qt,"f")].concat(d[we(this,Qt,"f")]||[]).filter((t=>t.length>1)).includes(""+l._[l._.length-1])&&(l._.pop(),u=!0)}be(this,Zt,!1,"f");const a=we(this,Wt,"f").getCommands(),p=we(this,Lt,"f").completionKey in l,g=u||p||i;if(l._.length){if(a.length){let t;for(let e,r=s||0;void 0!==l._[r];r++){if(e=String(l._[r]),a.includes(e)&&e!==we(this,Tt,"f")){const t=we(this,Wt,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Je](t,o,!!n,!1)}if(!t&&e!==we(this,Tt,"f")){t=e;break}}!we(this,Wt,"f").hasDefaultCommand()&&we(this,le,"f")&&t&&!g&&we(this,ye,"f").recommendCommands(t,a)}we(this,Tt,"f")&&l._.includes(we(this,Tt,"f"))&&!p&&(we(this,qt,"f")&&jt(!0),this.showCompletionScript(),this.exit(0))}if(we(this,Wt,"f").hasDefaultCommand()&&!g){const t=we(this,Wt,"f").runCommand(null,this,c,0,i,u||f||i);return this[Je](t,o,!!n,!1)}if(p){we(this,qt,"f")&&jt(!0);const e=(t=[].concat(t)).slice(t.indexOf(`--${we(this,Lt,"f").completionKey}`)+1);return we(this,Lt,"f").getCompletion(e,((t,e)=>{if(t)throw new X(t.message);(e||[]).forEach((t=>{we(this,Xt,"f").log(t)})),this.exit(0)})),this[Je](l,!o,!!n,!1)}if(we(this,Kt,"f")||(u?(we(this,qt,"f")&&jt(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(we(this,qt,"f")&&jt(!0),r=!0,we(this,pe,"f").showVersion("log"),this.exit(0))),!r&&we(this,ee,"f").skipValidation.length>0&&(r=Object.keys(l).some((t=>we(this,ee,"f").skipValidation.indexOf(t)>=0&&!0===l[t]))),!r){if(c.error)throw new X(c.error.message);if(!p){const t=this[Xe](d,{},c.error);n||(h=yt(l,this,we(this,Gt,"f").getMiddleware(),!0)),h=this[ze](t,null!=h?h:l),ht(h)&&!n&&(h=h.then((()=>yt(l,this,we(this,Gt,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof X))throw t;we(this,pe,"f").fail(t.message,t)}return this[Je](null!=h?h:l,o,!!n,!0)}[Xe](t,e,n,s){const i={...this.getDemandedOptions()};return r=>{if(n)throw new X(n.message);we(this,ye,"f").nonOptionCount(r),we(this,ye,"f").requiredArguments(r,i);let o=!1;we(this,ue,"f")&&(o=we(this,ye,"f").unknownCommands(r)),we(this,de,"f")&&!o?we(this,ye,"f").unknownArguments(r,t,e,!!s):we(this,fe,"f")&&we(this,ye,"f").unknownArguments(r,t,{},!1,!1),we(this,ye,"f").limitedChoices(r),we(this,ye,"f").implications(r),we(this,ye,"f").conflicting(r)}}[tn](){be(this,Kt,!0,"f")}[en](t){if("string"==typeof t)we(this,ee,"f").key[t]=!0;else for(const e of t)we(this,ee,"f").key[e]=!0}}const sn=(rn=ot,(t=[],e=rn.process.cwd(),n)=>{const s=new nn(t,e,n,rn);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s});var rn;function on(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var s=n.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}const an=new class{constructor(){on(this,"_dirPath",void 0),on(this,"_dockerfile",void 0),on(this,"_dockerfilePath",void 0),on(this,"_hasDockerfile",void 0),on(this,"_name",void 0),on(this,"_rootPackageJson",void 0),on(this,"_dockerPackageJson",void 0),on(this,"_packageJson",void 0),this._dirPath=process.cwd()}get dirPath(){return this._dirPath}set dirPath(e){this._dirPath=t.resolve(e)}get dockerfile(){return this._dockerfile??=l.readFileSync(this.dockerfilePath,"utf8")}get dockerfilePath(){if(this._dockerfilePath)return this._dockerfilePath;if(l.existsSync(t.join(this.dirPath,"Dockerfile")))this._dockerfilePath=t.join(this.dirPath,"Dockerfile");else{if(!l.existsSync(t.join(this.dirPath,"..","..","Dockerfile")))throw new Error("Dockerfile not found");this._dockerfilePath=t.join(this.dirPath,"..","..","Dockerfile")}return this._dockerfilePath}get hasDockerfile(){if(void 0!==this._hasDockerfile)return this._hasDockerfile;try{this._hasDockerfile=!!this.dockerfilePath}catch{this._hasDockerfile=!1}return this._hasDockerfile}get name(){return this._name??=an.rootPackageJson.name||"unknown"}get packageJson(){return this._packageJson??=JSON.parse(l.readFileSync(t.join(this.dirPath,"package.json"),"utf8"))}get rootPackageJson(){return this._rootPackageJson??=l.existsSync(t.join(this.dirPath,"..","..","package.json"))?JSON.parse(l.readFileSync(t.join(this.dirPath,"..","..","package.json"),"utf8")):this.packageJson}get dockerPackageJson(){return this._dockerPackageJson??=t.dirname(this.dockerfilePath)===this.dirPath?this.packageJson:JSON.parse(l.readFileSync(t.join(t.dirname(this.dockerfilePath),"package.json"),"utf8"))}},cn={env:{description:".env files to be loaded.",type:"array"},"cascade-env":{description:"environment to load cascading .env files (e.g., `.env`, `.env.<environment>`, `.env.local` and `.env.<environment>.local`)",type:"string"},"cascade-node-env":{description:"environment to load cascading .env files (e.g., `.env`, `.env.<NODE_ENV>`, `.env.local` and `.env.<NODE_ENV>.local`). Preferred over `cascade`.",type:"boolean"},"working-dir":{description:"A working directory",type:"string",alias:"w"}},ln={"dry-run":{description:"Whether to skip actual command execution",type:"boolean",alias:"d"},verbose:{description:"Whether to show verbose information",type:"boolean",alias:"v"}},hn={command:"buildIfNeeded",describe:"Build code if changes are detected",builder:{...cn,...ln,command:{description:"A build command",type:"string",default:"yarn build",alias:"c"}},async handler(e){await async function(e){const[n,s,i]=await async function(){const e=t.resolve(an.dirPath,"node_modules",".cache","build"),n=t.resolve(e,"last-build");await O.mkdir(e,{recursive:!0});const s=v("sha256"),i=y.execSync("git rev-parse HEAD",{cwd:an.dirPath}).toString().trim();s.update(i);const r=JSON.stringify(Object.entries(process.env).sort((([t],[e])=>t.localeCompare(e))));s.update(r),await async function(t){return new Promise((e=>{const n=y.spawnSync("git",["diff","--name-only"],{cwd:an.dirPath,stdio:"pipe",encoding:"utf8"}).stdout.trim().split("\n").map((t=>"test"===process.env.WB_ENV?t.replace(/packages\/scripts\/test-fixtures\/[^/]+\//,""):t)).filter((t=>(dn.some((e=>t.includes(e)))||un.some((e=>t.endsWith(e))))&&!fn.some((e=>t.includes(e))))),s=y.spawn("git",["diff","--",...n],{cwd:an.dirPath});s.stdout?.on("data",(e=>{t.update(e)})),s.on("close",(()=>{e()}))}))}(s);const o=s.digest("hex");try{if(await O.readFile(n,"utf8")===o)return console.info("Skip to build production code."),[!0,n,o]}catch{}return[!1,n,o]}();if(n)return!1;if(console.info("Start building production code."),!e.dryRun){const[t,...n]=(e.command??"").split(" "),s=y.spawnSync(t,n,{cwd:an.dirPath,stdio:"inherit"});if(0!==s.status)return console.info("Failed to build production code."),process.exitCode=s.status??1,!1}console.info("Finished building production code."),e.dryRun||await O.writeFile(s,i,"utf8");return!0}(e)}};const dn=["src/","public/"],un=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","yarn.lock"],fn=["test/","tests/","__tests__/","test-fixtures/","package.json"];const pn={command:"optimizeForDockerBuild",describe:"Optimize configuration when building a Docker image",builder:{...cn,...ln,outside:{description:"Whether the optimization is executed outside a docker container or not",type:"boolean",alias:"o"}},async handler(e){const n={stdio:"inherit"},s=["package.json"];if(an.packageJson.workspaces){const e=await l.promises.readdir("packages",{withFileTypes:!0});for(const n of e){if(!n.isDirectory())continue;const e=t.join("packages",n.name,"package.json");l.existsSync(e)&&s.push(e)}}for(const n of s){const s=JSON.parse(l.readFileSync(n,"utf8")),i=s.dependencies||{};if(i["@discord-bot/llm"]&&"workspace:*"!==i["@discord-bot/llm"]&&(i["@discord-bot/llm"]="./@discord-bot/llm"),i["@moti-components/go-e-mon"]&&(i["@moti-components/go-e-mon"]="./@moti-components/go-e-mon"),i["@online-judge/shared"]&&(i["@online-judge/shared"]="./@online-judge/shared"),i["program-executor"]&&(i["program-executor"]="./program-executor"),i["online-judge-shared"]&&(i["online-judge-shared"]="./online-judge-shared"),gn(e,s),mn(s),e.dryRun)continue;const r=e.outside?t.join(t.dirname(n),"dist"):t.dirname(n);await l.promises.mkdir(r,{recursive:!0}),await l.promises.writeFile(t.join(r,"package.json"),JSON.stringify(s),"utf8")}e.dryRun||e.outside||y.spawnSync("yarn",n)}};function gn(t,e){if(!t.outside)return void delete e.devDependencies;const n=e.devDependencies||{},s=["concurrently","conventional-changelog-conventionalcommits","eslint","husky","jest","kill-port","lint-staged","open-cli","playwright","prettier","pinst","sort-package-json","wait-on","semantic-release","vitest"];for(const e of Object.keys(n))(s.some((t=>e.includes(t)))||!t.outside&&e.includes("willbooster")&&e.includes("config"))&&delete n[e]}function mn(t){const e=["check","deploy","format","lint","start","test"],n=["pinst ","husky "],s=t.scripts||{};for(const[t,i]of Object.entries(s))(e.some((e=>t.includes(e)))||n.some((t=>i.includes(t))))&&delete s[t]}const yn=new class{deploy(){return"PRISMA migrate deploy"}deployForce(t){return`rm -Rf db/mount/prod.sqlite3*; PRISMA migrate reset --force && rm -Rf db/mount/prod.sqlite3* && litestream restore -o db/mount/prod.sqlite3 ${t} && PRISMA migrate deploy`}litestream(){return'node -e \'\nconst { PrismaClient } = require("@prisma/client");\nnew PrismaClient().$queryRaw`PRAGMA journal_mode = WAL;`\n .catch((error) => { console.log("Failed due to:", error); process.exit(1); });\n\''}migrate(){return`PRISMA migrate deploy && PRISMA generate && ${this.seed()}`}migrateDev(){return"PRISMA migrate dev"}reset(){return`PRISMA migrate reset --force --skip-seed && ${this.seed()}`}restore(t){return`rm -Rf db/restored.sqlite3; GOOGLE_APPLICATION_CREDENTIALS=gcp-sa-key.json litestream restore -o db/restored.sqlite3 ${t}`}seed(){return an.packageJson.dependencies?.blitz?"YARN blitz db seed":'if [ -e "prisma/seeds.ts" ]; then YARN build-ts run prisma/seeds.ts; fi'}studio(){return"PRISMA studio"}},bn=new E,wn=new Set;const vn={exitIfFailed:!0};async function On(t,e,n=vn){const[s,i]=En(t);if(jn(s),e.verbose&&jn(s,"Start (detailed)",!0),e.dryRun)return An(s,0,n),0;const r=i.match(/http:\/\/127.0.0.1:(\d+)/)?.[1];i.includes("wait-on")&&r&&!i.includes("docker run")&&await async function(t){await j(t);const e=async()=>{wn.has(t)||(wn.add(t),await j(t))};process.on("beforeExit",e),process.on("SIGINT",e)}(Number(r));const o=await $(i,void 0,{cwd:an.dirPath,shell:!0,stdio:"inherit",timeout:n?.timeout,killOnExit:!0,verbose:e.verbose});return An(s,o.status,n),o.status??1}function kn(t,e,n=vn){return bn.run((async()=>{const[s,i]=En(t);if(jn(s,"Start (parallel)",!0),e.dryRun)return jn(s,"Start (log)"),void An(s,0,n);const r=await $(i,void 0,{cwd:an.dirPath,shell:!0,stdio:"pipe",timeout:n?.timeout,mergeOutAndError:!0,killOnExit:!0,verbose:e.verbose});jn(s,"Start (log)");const o=r.stdout.trim();o&&console.info(o),An(s,r.status,n)}))}function En(e){const n=function(){if(_n)return xn;_n=!0;let e=an.dirPath;for(;;){const n=t.join(e,"node_modules",".bin");if(l.existsSync(n)&&(process.env.PATH=`${n}:${process.env.PATH}`,xn=!0),l.existsSync(t.join(e,".git")))break;const s=t.dirname(e);if(e===s)break;e=s}return xn}(),s=e.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",an.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").trim();return[s.replaceAll("YARN ","yarn "),s.replaceAll("YARN ",n?"":"yarn ")]}function jn(t,e="Start",n=!1){console.info("\n"+(n?k.gray:k.cyan)(k.bold(`${e}:`),t)+k.gray(` (@ ${an.dirPath})`))}function An(t,e,n){0===e?console.info(k.green(k.bold("Finished:"),t)):(console.info(k.red(k.bold(`Failed (exit code ${e}): `),t)),!1!==n.exitIfFailed&&process.exit(e??1))}let _n=!1,xn=!1;const Pn={...ln},$n={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Cn).command(Sn).command(Mn).command(Nn).command(Dn).command(In).command(Rn).command(Wn).command(Fn).demandCommand(),handler(){}},Cn={command:"deploy",describe:"Apply migration to DB without initializing it",builder:Pn,async handler(t){await On(yn.deploy(),t)}},Sn={command:"deploy-force",describe:"Force to apply migration to DB utilizing Litestream's backup without initializing it",builder:Pn,async handler(t){await On(yn.deployForce(t.backupPath),t)}},Mn={command:"litestream",describe:"Setup DB for Litestream",builder:Pn,async handler(t){await On(yn.litestream(),t)}},Nn={command:"migrate",describe:"Apply migration to DB with initializing it",builder:Pn,async handler(t){await On(yn.migrate(),t)}},Dn={command:"migrate-dev",describe:"Create a migration file",builder:Pn,async handler(t){await On(yn.migrateDev(),t)}},In={command:"reset",describe:"Reset DB",builder:Pn,async handler(t){await On(yn.reset(),t)}},Rn={command:"restore",describe:"Restore DB from Litestream's backup",builder:Pn,async handler(t){await On(yn.restore(t.backupPath),t)}},Wn={command:"seed",describe:"Populate DB with seed data",builder:Pn,async handler(t){await On(yn.seed(),t)}},Fn={command:"studio",describe:"Open Prisma Studio",builder:Pn,async handler(t){await On(yn.studio(),t)}},zn={command:"retry",describe:"Retry the given command until it succeeds",builder:{retry:{description:"A maximum retry count",type:"number",alias:"r",default:3},...ln},async handler(t){const e=t._.slice(1);let n=0;for(let s=0;s<t.retry;s++)if(s>0&&console.info(`\n${k.yellow(`#${s} Retrying: ${e.join(" ")}`)}`),n=await On(e.join(" "),t,{exitIfFailed:!1}),0===n)return;process.exit(n)}},Ln={command:"setup",describe:"Setup development environment",builder:{...cn,...ln},async handler(t){await async function(t){const e=await O.readdir(an.dirPath,{withFileTypes:!0});e.some((t=>t.isFile()&&t.name.includes("-version")))&&await On("asdf install",t);if(e.some((t=>t.isFile()&&"pyproject.toml"===t.name))){await kn("poetry config virtualenvs.in-project true",t),await kn("poetry config virtualenvs.prefer-active-python true",t);const[,e]=y.execSync("asdf current python").toString().trim().split(/\s+/);await kn(`poetry env use ${e}`,t),await bn.promiseAll(),await On("poetry run pip install --upgrade pip",t),await On("poetry install --ansi",t)}if("darwin"===_.platform()){const e=["pstree"];an.hasDockerfile&&e.push("expect"),await kn(`brew install ${e.join(" ")}`,t)}const n=an.packageJson.dependencies??{},s=an.packageJson.devDependencies||{},i=an.packageJson.scripts??{},r=[],o=[];n.blitz?(r.push("pm2"),o.push("concurrently","dotenv-cli","open-cli","vitest","wait-on")):s["@remix-run/dev"]?(r.push("dotenv-cli","pm2"),o.push("concurrently","open-cli","vitest","wait-on")):(n.express||n.fastify)&&(r.push("pm2"),o.push("concurrently","vitest","wait-on"));r.length>0&&await On(`yarn add ${r.join(" ")}`,t);o.length>0&&await On(`yarn add -D ${o.join(" ")}`,t);i["gen-code"]&&await On("yarn gen-code",t)}(t)}};const Tn=new class{buildDevImage(e="local"){const n=an.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${t.dirname(an.dockerfilePath)}\n && ${n}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${an.name}\n --build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64)\n --build-arg WB_ENV=${e}\n --build-arg WB_VERSION=dev .`}stopAndStart(t=!1,e="",n=""){return`${this.stop()} && ${t?"unbuffer ":""}${this.start(e,n)}`}start(t="",e=""){return function(t){const e=async()=>{wn.has(t)||(wn.add(t),w(t,{shell:!0,stdio:"inherit"}))};process.on("beforeExit",e),process.on("SIGINT",e)}(this.stop()),`docker run --rm -it -p 8080:8080 --name ${an.name} ${t} ${an.name} ${e}`}stop(){return`true $(docker rm -f $(docker container ls -q -f name=${an.name}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};class Un{constructor(t=3e3){this.defaultPort=t}buildDocker(t="local"){return Tn.buildDevImage(t)}startDocker(t=""){return`${this.buildDocker()}\n && YARN concurrently --raw --kill-others-on-fail\n "${Tn.stopAndStart(!1,"",t)}"\n "${this.waitAndOpenApp(8080)}"`}testE2E({playwrightArgs:t,prismaDirectory:e,startCommand:n}){return`APP_ENV=production WB_ENV=test PORT=8080 YARN dotenv -c production -- concurrently --kill-others --raw --success first\n "rm -Rf ${e}/mount && ${n} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && yarn playwright ${t}"`}testE2EDev({playwrightArgs:t,startCommand:e}){return`APP_ENV=development WB_ENV=test NEXT_PUBLIC_WB_ENV=test PORT=8080 YARN dotenv -c development -- concurrently --kill-others --raw --success first\n "${e} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && yarn playwright ${t}"`}testUnit(){return"YARN vitest run tests/unit --color --passWithNoTests"}waitApp(t=this.defaultPort){return`wait-on -t 10000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 10000 -i 500 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 10000 -i 1000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 10000 -i 2000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 20000 -i 4000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 60000 -i 5000 http://127.0.0.1:${t}`}waitAndOpenApp(t=this.defaultPort){return`${this.waitApp(t)} && open-cli http://localhost:${t}`}}const Hn=new class extends Un{constructor(){super()}start(t,e=""){return`YARN concurrently --raw --kill-others-on-fail\n "blitz dev ${e}"\n "${this.waitAndOpenApp()}"`}startProduction(t=8080,e=""){return`NODE_ENV=production YARN concurrently --raw --kill-others-on-fail\n "${yn.reset()} && yarn build && PORT=${t} pm2-runtime start ecosystem.config.cjs ${e}"\n "${this.waitAndOpenApp(t)}"`}testE2E({playwrightArgs:t="test tests/e2e",startCommand:e=`${yn.reset()} && yarn build && pm2-runtime start ecosystem.config.cjs`}){return super.testE2E({playwrightArgs:t,prismaDirectory:"db",startCommand:e})}testE2EDev({playwrightArgs:t="test tests/e2e",startCommand:e="blitz dev -p 8080"}){return super.testE2EDev({playwrightArgs:t,startCommand:e})}testStart(){return`YARN concurrently --kill-others --raw --success first "blitz dev" "${this.waitApp()}"`}};const Bn=new class extends Un{constructor(){super()}start(t,e=""){return`YARN build-ts run src/index.ts ${t?"--watch":""} ${e}`}startDocker(t=""){return`${this.buildDocker()} && ${Tn.stopAndStart(!1,"",t)}`}startProduction(t=8080,e=""){return`NODE_ENV=production yarn build && NODE_ENV=production PORT=\${PORT:-${t}} node dist/index.js ${e}`}testE2E({startCommand:t=`if [ -e "prisma" ]; then prisma migrate reset --force --skip-generate; fi && (${this.startProduction()})`}){return`NODE_ENV=production WB_ENV=test PORT=8080 YARN concurrently --kill-others --raw --success first\n "${t} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testE2EDev({startCommand:t=this.start()}){return`NODE_ENV=production WB_ENV=test PORT=8080 YARN concurrently --kill-others --raw --success first\n "${t} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testStart(){return`YARN concurrently --kill-others --raw --success first "${this.start()}" "${this.waitApp()}"`}};const Vn=new class extends Un{constructor(){super()}start(t,e=""){return`YARN build-ts run src/index.ts ${t?"--watch":""} ${e}`}startDocker(t=""){return`${this.buildDocker()} && ${Tn.stopAndStart(!1,"",t)}`}startProduction(t=8080,e=""){return`NODE_ENV=production yarn build && NODE_ENV=production node dist/index.js ${e}`}testE2E(){return"echo 'do nothing.'"}testE2EDev(){return"echo 'do nothing.'"}testStart(){return"echo 'do nothing.'"}};const qn=new class extends Un{constructor(){super()}start(t,e=""){return`YARN concurrently --raw --kill-others-on-fail\n "dotenv -c development -- remix dev ${e}"\n "${this.waitAndOpenApp()}"`}startProduction(t=8080,e=""){return`NODE_ENV=production YARN dotenv -c production -- concurrently --raw --kill-others-on-fail\n "${yn.reset()} && yarn build && PORT=${t} pm2-runtime start ecosystem.config.cjs ${e}"\n "${this.waitAndOpenApp(t)}"`}testE2E({playwrightArgs:t="test tests/e2e",startCommand:e=`${yn.reset()} && yarn build && pm2-runtime start ecosystem.config.cjs`}){return super.testE2E({playwrightArgs:t,prismaDirectory:"prisma",startCommand:e})}testE2EDev({playwrightArgs:t="test tests/e2e",startCommand:e="remix dev"}){return super.testE2EDev({playwrightArgs:t,startCommand:e})}testStart(){return`YARN concurrently --kill-others --raw --success first "dotenv -c development -- remix dev" "${this.waitApp()}"`}},Yn={command:"start",describe:"Start app",builder:{...ln,watch:{description:"Whether to watch files",type:"boolean"},mode:{description:"Start mode: dev[elopment] (default) | prod[uction] | docker",type:"string",alias:"m"},args:{description:"Arguments text for start command",type:"string",alias:"a"}},async handler(t){const e=an.packageJson.dependencies||{},n=an.packageJson.devDependencies||{};let s;s=e.blitz?Hn:n["@remix-run/dev"]?qn:(e.express||e.fastify)&&!e["firebase-functions"]||/EXPOSE\s+8080/.test(an.dockerfile)?Bn:Vn;const i=t.args??"";switch(t.mode||"dev"){case"dev":case"development":await On(s.start(t.watch,i),t);break;case"prod":case"production":await On(s.startProduction(8080,i),t);break;case"docker":await On(s.startDocker(i),t);break;default:throw new Error(`Unknown start mode: ${t.mode}`)}}},Gn={command:"test",describe:"Test project",builder:{...ln,ci:{description:"Whether to run tests on CI",type:"boolean"},e2e:{description:"Whether to run e2e tests. You may pass mode as argument: none | headless (default) | headless-dev | headed | headed-dev | docker | debug | generate | trace",type:"string"},start:{description:"Whether to run start tests",type:"boolean"},unit:{description:"Whether to run unit tests",type:"boolean"},"unit-timeout":{description:"Timeout for unit tests",type:"number"}},async handler(e){await async function(e){await async function(t){if(!an.packageJson.workspaces)return;const e=process.argv.slice(2),n=e.findIndex((t=>["-w","--working-dir","--workingDir"].includes(t)));n>=0&&e.splice(n,2),process.env.CI="1",process.env.FORCE_COLOR="3",await On(["yarn","workspaces","foreach","--exclude",an.name,"--verbose","run","wb",...e].join(" "),t),process.exit(0)}(e);const n=an.packageJson.dependencies||{},s=an.packageJson.devDependencies||{};let i;i=n.blitz?Hn:s["@remix-run/dev"]?qn:!n.express&&!n.fastify||n["firebase-functions"]?Vn:Bn;const r=[];if(e.ci){const n=P(t.join(an.dirPath,"tests","unit")),s=P(t.join(an.dirPath,"tests","e2e"));if(await kn(Tn.stopAll(),e),!1!==e.unit&&await n&&await kn(i.testUnit(),e,{timeout:e.unitTimeout}),!1!==e.start&&await kn(i.testStart(),e),await bn.promiseAll(),"none"!==e.e2e&&await s){an.hasDockerfile&&await On(`${i.buildDocker("test")}`,e);const t=an.hasDockerfile?{startCommand:Tn.stopAndStart(!0)}:{};process.exitCode=await On(i.testE2E(t),e,{exitIfFailed:!1}),await On(Tn.stop(),e)}return}(e.unit||!e.start&&void 0===e.e2e)&&r.push(On(i.testUnit(),e,{timeout:e.unitTimeout}));e.start&&r.push(On(i.testStart(),e));switch(await Promise.all(r),e.e2e){case void 0:case"none":return;case"":case"headless":return void await On(i.testE2E({}),e);case"headless-dev":return void await On(i.testE2EDev({}),e);case"docker":return await On(`${i.buildDocker("test")}`,e),process.exitCode=await On(i.testE2E({startCommand:Tn.stopAndStart(!0)}),e,{exitIfFailed:!1}),void await On(Tn.stop(),e)}if(n.blitz||s["@remix-run/dev"])switch(e.e2e){case"headed":return void await On(i.testE2E({playwrightArgs:"test tests/e2e --headed"}),e);case"headed-dev":return void await On(i.testE2EDev({playwrightArgs:"test tests/e2e --headed"}),e);case"debug":return void await On(`PWDEBUG=1 ${i.testE2E({})}`,e);case"generate":return void await On(i.testE2E({playwrightArgs:"codegen http://localhost:8080"}),e);case"trace":return void await On("playwright show-trace",e)}throw new Error(`Unknown e2e mode: ${e.e2e}`)}(e)}};const Jn={command:"typecheck",describe:"Run type checking",builder:{...ln},async handler(t){if(process.exitCode=await On("tsc --noEmit --Pretty",t),0!==process.exitCode){(JSON.parse(await O.readFile("package.json","utf8")).dependencies||{}).blitz&&console.info(k.yellow('Please try "yarn gen-code" if you face unknown type errors.'))}}},Kn={...Jn,command:"tc"};var Qn;await sn((Qn=process.argv,Qn.slice(Z()+1))).scriptName("wb").options(cn).middleware((e=>{const n=e["working-dir"];if(n){const e=t.resolve(n);process.chdir(e),an.dirPath=e}!function(t){for(const e of Object.keys(t)){const n=e.toLowerCase();(n.startsWith("npm_")||n.startsWith("yarn_")||n.startsWith("berry_"))&&delete t[e]}}(process.env),function(e,n){let s=(e.env??[]).map((t=>t.toString()));const i=e.cascadeNodeEnv?process.env.NODE_ENV??"":e.cascadeEnv;"string"==typeof i&&(0===s.length&&s.push(".env"),s=s.flatMap((t=>i?[`${t}.${i}.local`,`${t}.local`,`${t}.${i}`,t]:[`${t}.local`,t]))),e.verbose&&console.info("Loading env files:",s);let r={};for(const e of s)r={...x({path:t.join(n,e)}).parsed,...r}}(e,an.dirPath)})).command(hn).command(pn).command($n).command(zn).command(Ln).command(Yn).command(Gn).command(Jn).command(Kn).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
|
|
34
34
|
//# sourceMappingURL=index.js.map
|