@willbooster/wb 2.8.4 → 3.0.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 +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +10 -11
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import t,{resolve as e,dirname as n,normalize as s,basename as i,extname as r,re
|
|
|
4
4
|
* Copyright (c) 2016, Contributors
|
|
5
5
|
* SPDX-License-Identifier: ISC
|
|
6
6
|
*/
|
|
7
|
-
function D(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 W(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
|
|
7
|
+
function D(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 W(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 F(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 D(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 R;
|
|
19
19
|
/**
|
|
20
20
|
* @license
|
|
21
21
|
* Copyright (c) 2016, Contributors
|
|
22
22
|
* SPDX-License-Identifier: ISC
|
|
23
23
|
*/
|
|
24
|
-
let z;!function(t){t.BOOLEAN="boolean",t.STRING="string",t.NUMBER="number",t.ARRAY="array"}(
|
|
24
|
+
let z;!function(t){t.BOOLEAN="boolean",t.STRING="string",t.NUMBER="number",t.ARRAY="array"}(R||(R={}));function L(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 U,T,B;const q=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,V=null!==(T=null===(U=null===process||void 0===process?void 0:process.versions)||void 0===U?void 0:U.node)&&void 0!==T?T:null===(B=null===process||void 0===process?void 0:process.version)||void 0===B?void 0:B.slice(1);if(V){if(Number(V.match(/^([^.]+)/)[1])<q)throw Error(`yargs parser supports a minimum Node.js version of ${q}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const J=process?process.env:{},Y=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=D(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=>I(t,g.arrays)?(b=Error(p("Invalid configuration: %s, opts.count excludes opts.array.",t)),!0):!!I(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)&&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&&(I(c[1],g.arrays)?t=A(t,c[1],s,c[2]):!1!==I(c[1],g.nargs)?t=j(t,c[1],s,c[2]):E(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],E(r,!!I(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],I(r,g.arrays)?t=A(t,r,s):!1!==I(r,g.nargs)?t=j(t,r,s):(l=s[t+1],void 0===l||l.match(/^-/)&&!l.match(m)||I(r,g.bools)||I(r,g.counts)?/^(true|false)$/.test(l)?(E(r,l),t++):E(r,B(r)):(E(r,l),t++)));else if(e.match(/^-.\..+=/))c=e.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&E(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(/^-/)||I(r,g.bools)||I(r,g.counts)?E(r,B(r)):(E(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],I(r,g.arrays)?t=A(t,r,s,h):!1!==I(r,g.nargs)?t=j(t,r,s,h):E(r,h),i=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===I(l,g.bools)){E(a[n],l),i=!0;break}if(a[n+1]&&a[n+1].match(/\W/)){E(a[n],l),i=!0;break}E(a[n],B(a[n]))}else E(a[n],l)}r=e.slice(-1)[0],i||"-"===r||(I(r,g.arrays)?t=A(t,r,s):!1!==I(r,g.nargs)?t=j(t,r,s):(l=s[t+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(m)||I(r,g.bools)||I(r,g.counts)?/^(true|false)$/.test(l)?(E(r,l),t++):E(r,B(r)):(E(r,l),t++)))}else if(e.match(/^-[0-9]$/)&&e.match(m)&&I(e.slice(1),g.bools))r=e.slice(1),E(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=$("_",t);"string"!=typeof e&&"number"!=typeof e||v._.push(e)}function j(t,e,n,s){let i,r=I(e,g.nargs);if(r="number"!=typeof r||isNaN(r)?1:r,0===r)return q(s)||(b=Error(p("Argument unexpected for: %s",e))),E(e,B(e)),t;let a=q(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(!q(s)&&c>0&&(E(e,s),c--),i=t+1;i<c+t+1;i++)E(e,n[i]);return t+c}function A(t,e,n,s){let r=[],c=s||n[t+1];const l=I(e,g.nargs);if(I(e,g.bools)&&!/^(true|false)$/.test(c))r.push(!0);else if(q(c)||q(s)&&/^-/.test(c)&&!m.test(c)&&!T(c)){if(void 0!==a[e]){const t=a[e];r=Array.isArray(t)?t:[t]}}else{q(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))),E(e,r),t}function E(t,e,n=i){if(/-/.test(t)&&o["camel-case-expansion"]){const e=t.split(".").map((function(t){return D(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)})),I(t,g.normalize)&&!I(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)),(I(t,g.bools)||I(t,g.counts))&&"string"==typeof e&&(e="true"===e);let s=Array.isArray(e)?e.map((function(e){return $(t,e)})):$(t,e);return I(t,g.counts)&&(q(s)||"boolean"==typeof s)&&(s=L()),I(t,g.normalize)&&I(t,g.arrays)&&(s=Array.isArray(e)?e.map((t=>z.normalize(t))):z.normalize(e)),s}function $(t,e){if(!o["parse-positional-numbers"]&&"_"===t)return e;if(!I(t,g.strings)&&!I(t,g.bools)&&!Array.isArray(e)){(R(e)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${e}`)))||!q(e)&&I(t,g.numbers))&&(e=Number(e))}return e}function P(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"]?P(s,i):(!M(v,i.split("."))||I(i,g.arrays)&&o["combine-arrays"])&&E(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)),D(t)}));(e&&g.configs[r.join(".")]||!e)&&!M(t,r)&&E(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=I(e.join("."),g.arrays),a=Array.isArray(n);let c=o["duplicate-arguments-array"];!c&&I(i,g.nargs)&&(c=!0,(!q(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]||I(i,g.counts)||I(i,g.bools)?s[i]=n:s[i]=[s[i],n]}function I(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 U(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),!U(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&&U(n[1])}))}(t,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}(t)}function B(t){return I(t,g.bools)||I(t,g.counts)||!(`${t}`in a)?(e=function(t){let e=F.BOOLEAN;return I(t,g.strings)?e=F.STRING:I(t,g.numbers)?e=F.NUMBER:I(t,g.bools)?e=F.BOOLEAN:I(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 q(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=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);P(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){P(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=I(s,g.coercions),"function"==typeof e))try{const i=$(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("."))||E(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=>D(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: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 Y.parse(t.slice(),e).argv};function K(){return process.versions.electron&&!process.defaultApp?0:1}G.detailed=function(t,e){return Y.parse(t.slice(),e)},G.camelCase=D,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 P({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:I})},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(wt(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(vt(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(vt(e))return e(t,!0);wt(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 wt(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function vt(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 jt(t){return"boolean"==typeof t}function At(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(jt(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 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(),j=e.cliui({width:k,wrap:!!k});if(!h)if(l.length)l.forEach((t=>{j.div({text:`${t[0].replace(/\$0/g,i)}`}),t[1]&&j.div({text:`${t[1]}`,padding:[1,0,0,0]})})),j.div();else if(u.length){let t=null;t=o._?`${i} <${n("command")}>\n`:`${i} [${n("command")}]\n`,j.div(`${t}`)}if(u.length>1||1===u.length&&!u[0][2]){j.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 ?/,"")}`;j.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?j.div({text:o.join(" "),padding:[0,0,0,2],align:"right"}):j.div()})),j.div()}const A=(Object.keys(g.alias)||[]).concat(Object.keys(t.parsed.newAliases)||[]);m=m.filter((e=>!t.parsed.newAliases[e]&&A.every((t=>-1===(g.alias[t]||[]).indexOf(e)))));const E=n("Options:");c[E]||(c[E]=[]),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,E);const _=t=>/^--/.test(xt(t)),x=Object.keys(c).filter((t=>c[t].length>0)).map((t=>({groupName:t,normalizedKeys:c[t].filter(v).map((t=>{if(A.includes(t))return t;for(let e,n=0;void 0!==(e=A[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,Et(n)?{text:n.text,indentation:n.indentation+s}:{text:n,indentation:s}))}))})),x.forEach((({groupName:e,normalizedKeys:i,switches:o})=>{j.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;j.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?j.div({text:h,padding:[0,0,0,2],align:"right"}):j.div()})),j.div()})),d.length&&(j.div(n("Examples:")),d.forEach((t=>{t[0]=t[0].replace(/\$0/g,i)})),d.forEach((t=>{""===t[1]?j.div({text:t[0],padding:[0,2,0,2]}):j.div({text:t[0],padding:[0,2,0,2],width:b(d,k)+4},{text:t[1]})})),j.div()),p.length>0){const t=p.map((t=>t.replace(/\$0/g,i))).join("\n");j.div(`${t}\n`)}return j.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=Ot(f,(e=>!t[e])),s};const j=[];return s.freeze=function(){j.push({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f})},s.unfreeze=function(t=!1){const e=j.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 Et(t){return"object"==typeof t}function _t(t){return Et(t)?t.indentation:0}function xt(t){return Et(t)?t.text:t}class $t{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(vt(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 Pt(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?It(i,t):Object.assign({},i,t)}function It(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]=It(t[i],e[i]):n[i]=e[i];return n}var Dt,Wt,Rt,Ft,zt,Lt,Ht,Ut,Tt,Bt,qt,Vt,Jt,Yt,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"),we=Symbol("copyDoubleDash"),ve=Symbol("deleteFromParserHintObject"),Oe=Symbol("emitWarning"),ke=Symbol("freeze"),je=Symbol("getDollarZero"),Ae=Symbol("getParserConfiguration"),Ee=Symbol("getUsageConfiguration"),_e=Symbol("guessLocale"),xe=Symbol("guessVersion"),$e=Symbol("parsePositionalNumbers"),Pe=Symbol("pkgUp"),Ce=Symbol("populateParserHintArray"),Se=Symbol("populateParserHintSingleValueDictionary"),Me=Symbol("populateParserHintArrayDictionary"),Ne=Symbol("populateParserHintDictionary"),Ie=Symbol("sanitizeKey"),De=Symbol("setKey"),We=Symbol("unfreeze"),Re=Symbol("validateAsync"),Fe=Symbol("getCommandInstance"),ze=Symbol("getContext"),Le=Symbol("getHasOutput"),He=Symbol("getLoggerInstance"),Ue=Symbol("getParseContext"),Te=Symbol("getUsageInstance"),Be=Symbol("getValidationInstance"),qe=Symbol("hasParseCallback"),Ve=Symbol("isGlobalContext"),Je=Symbol("postProcess"),Ye=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,Dt.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"),Ht.set(this,null),Ut.set(this,!0),Tt.set(this,{}),Bt.set(this,!0),qt.set(this,[]),Vt.set(this,void 0),Jt.set(this,{}),Yt.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,Vt,new pt(this),"f"),this.$0=this[je](),this[Ge](),me(this,Dt,ye(this,Dt,"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[we](),"f")}addHelpOpt(t,e){return dt("[string|boolean] [string]",[t,e],arguments.length),ye(this,Gt,"f")&&(this[ve](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,Vt,"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[Ae]()["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,Dt,"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,Dt,"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[De](t,!0),ye(this,ue,"f").describe(t,e),this}detectLocale(t){return dt("<boolean>",[t],arguments.length),me(this,Ut,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,Yt,!0,"f"),me(this,Ht,e,"f"),ye(this,Bt,"f")&&ye(this,ce,"f").process.exit(t)}exitProcess(t=!0){return dt("[boolean]",[t],arguments.length),me(this,Bt,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,Ut,"f")}getExitProcess(){return ye(this,Bt,"f")}getGroups(){return Object.assign({},ye(this,Jt,"f"),ye(this,re,"f"))}getHelp(){if(me(this,Yt,!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,Dt,"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,Jt,"f")[e];ye(this,re,"f")[e]&&delete ye(this,re,"f")[e];const s={};return ye(this,Jt,"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,Ut,!1,"f"),ye(this,ce,"f").y18n.setLocale(t),this)}middleware(t,e,n){return ye(this,Vt,"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,Bt,!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,Ht,"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,Ht,"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[Pe](e||ye(this,Wt,"f"));return s[t]&&"object"==typeof s[t]&&(n=Nt(s[t],e||ye(this,Wt,"f"),this[Ae]()["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,Dt,"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,Yt,!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,Dt,"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,Ut,!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[ve](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}[(Dt=new WeakMap,Wt=new WeakMap,Rt=new WeakMap,Ft=new WeakMap,zt=new WeakMap,Lt=new WeakMap,Ht=new WeakMap,Ut=new WeakMap,Tt=new WeakMap,Bt=new WeakMap,qt=new WeakMap,Vt=new WeakMap,Jt=new WeakMap,Yt=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}[we](){return{log:(...t)=>{this[qe]()||console.log(...t),me(this,Yt,!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[qe]()||console.error(...t),me(this,Yt,!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")}}}[ve](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,qt,"f").push({options:ye(this,Xt,"f"),configObjects:ye(this,Xt,"f").configObjects.slice(0),exitProcess:ye(this,Bt,"f"),groups:ye(this,Jt,"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,Ht,"f"),hasOutput:ye(this,Yt,"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,Dt,"f").freeze(),ye(this,Vt,"f").freeze()}[je](){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[Ye](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}[Ae](){return ye(this,ee,"f")}[Ee](){return ye(this,fe,"f")}[_e](){if(!ye(this,Ut,"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[Pe]().version||"unknown"}[$e](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}[Pe](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[Ie](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[Ie](n),s)}[Ie](t){return"__proto__"===t?"___proto___":t}[De](t,e){return this[Se](this[De].bind(this),"key",t,e),this}[We](){var t,e,n,s,i,r,o,a,c,l,h,d;const u=ye(this,qt,"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,Bt,t,"f")}}.value,groups:{set value(t){me(n,Jt,t,"f")}}.value,output:{set value(t){me(s,Zt,t,"f")}}.value,exitError:{set value(t){me(i,Ht,t,"f")}}.value,hasOutput:{set value(t){me(r,Yt,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,Dt,"f").unfreeze(),ye(this,Vt,"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[He].bind(this),getParseContext:this[Ue].bind(this),getParserConfiguration:this[Ae].bind(this),getUsageConfiguration:this[Ee].bind(this),getUsageInstance:this[Te].bind(this),getValidationInstance:this[Be].bind(this),hasParseCallback:this[qe].bind(this),isGlobalContext:this[Ve].bind(this),postProcess:this[Je].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,Dt,"f")}[ze](){return ye(this,Rt,"f")}[Le](){return ye(this,Yt,"f")}[He](){return ye(this,Qt,"f")}[Ue](){return ye(this,se,"f")||{}}[Te](){return ye(this,ue,"f")}[Be](){return ye(this,ge,"f")}[qe](){return!!ye(this,ne,"f")}[Ve](){return ye(this,Kt,"f")}[Je](t,e,n,s){if(n)return t;if(ct(t))return t;e||(t=this[be](t));return(this[Ae]()["parse-positional-numbers"]||void 0===this[Ae]()["parse-positional-numbers"])&&(t=this[$e](t)),s&&(t=gt(t,this,ye(this,Vt,"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,Jt,"f")).reduce(((t,e)=>{const s=ye(this,Jt,"f")[e].filter((t=>!(t in n)));return s.length>0&&(t[e]=s),t}),{})),me(this,Jt,{},"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):At(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=Pt(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,Dt,ye(this,Dt,"f")?ye(this,Dt,"f").reset():function(t,e,n,s){return new bt(t,e,n,s)}(ye(this,ue,"f"),ye(this,ge,"f"),ye(this,Vt,"f"),ye(this,ce,"f")),"f"),ye(this,Ft,"f")||me(this,Ft,function(t,e,n,s){return new $t(t,e,n,s)}(this,ye(this,ue,"f"),ye(this,Dt,"f"),ye(this,ce,"f")),"f"),ye(this,Vt,"f").reset(),me(this,zt,null,"f"),me(this,Zt,"","f"),me(this,Ht,null,"f"),me(this,Yt,!1,"f"),this.parsed=!1,this}[Ye](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[Ae]();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[Je](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,Dt,"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,Dt,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Je](t,o,!!n,!1)}if(!t&&e!==ye(this,zt,"f")){t=e;break}}!ye(this,Dt,"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,Bt,"f")&&kt(!0),this.showCompletionScript(),this.exit(0))}if(ye(this,Dt,"f").hasDefaultCommand()&&!g){const t=ye(this,Dt,"f").runCommand(null,this,c,0,i,u||f||i);return this[Je](t,o,!!n,!1)}if(p){ye(this,Bt,"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[Je](l,!o,!!n,!1)}if(ye(this,Yt,"f")||(u?(ye(this,Bt,"f")&&kt(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(ye(this,Bt,"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,Vt,"f").getMiddleware(),!0)),h=this[Re](t,null!=h?h:l),ct(h)&&!n&&(h=h.then((()=>gt(l,this,ye(this,Vt,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof Q))throw t;ye(this,ue,"f").fail(t.message,t)}return this[Je](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,Yt,!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:{description:"environment to load cascading .env files (e.g., `.env`, `.env.<environment>`, `.env.local` and `.env.<environment>.local`)",type:"string"},"working-dir":{description:"A working directory",type:"string",alias:"w"}},an={dry:{description:"Indicates if dry-run mode is enabled or not.",type:"boolean",alias:"d"},verbose:{description:"Indicates if verbose mode is enabled or not.",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.dry){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.dry||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.dry)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.dry||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`true $(rm -Rf db/**/*.sqlite* 2> /dev/null) && true $(rm -Rf prisma/**/*.sqlite* 2> /dev/null) && 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=w(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 A,wn=new Set;const vn={exitIfFailed:!0};async function On(t,e,n=vn){const[s,i]=jn(t);if(An(s),e.verbose&&An(s,"Start (detailed)",!0),e.dryRun)return En(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 E(t);const e=async()=>{wn.has(t)||(wn.add(t),await E(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:!0});return En(s,o.status,n),o.status??1}function kn(t,e,n=vn){return bn.run((async()=>{const[s,i]=jn(t);if(An(s,"Start (parallel)",!0),e.dryRun)return An(s,"Start (log)"),void En(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:!0});An(s,"Start (log)");const o=r.stdout.trim();o&&console.info(o),En(s,r.status,n)}))}function jn(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 An(t,e="Start",n=!1){console.info("\n"+(n?j.gray:j.cyan)(j.bold(`${e}:`),t))}function En(t,e,n){0===e?console.info(j.green(j.bold("Finished:"),t)):(console.info(j.red(j.bold(`Failed (exit code ${e}): `),t)),!1!==n.exitIfFailed&&process.exit(e??1))}let _n=!1,xn=!1;const $n={...an},Pn={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Cn).command(Sn).command(Mn).command(Nn).command(In).command(Dn).demandCommand(),handler(){}},Cn={command:"litestream",describe:"Setup DB for Litestream",builder:$n,async handler(t){await On(gn.litestream(),t)}},Sn={command:"migrate",describe:"Apply migration files to DB",builder:$n,async handler(t){await On(gn.migrate(),t)}},Mn={command:"migrate-dev",describe:"Create a migration file",builder:$n,async handler(t){await On(gn.migrateDev(),t)}},Nn={command:"reset",describe:"Reset DB",builder:$n,async handler(t){await On(gn.reset(),t)}},In={command:"seed",describe:"Populate DB with seed data",builder:$n,async handler(t){await On(gn.seed(),t)}},Dn={command:"studio",describe:"Open Prisma Studio",builder:$n,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${j.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()=>{wn.has(t)||(wn.add(t),v(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 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}"`}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 && PORT=8080 pm2-runtime start ecosystem.config.cjs`}){return super.testE2E({playwrightArgs:t,prismaDirectory:"db",startCommand:e})}testStart(){return`YARN concurrently --kill-others --raw --success first "blitz dev" "${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 && 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 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 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 dist/index.js ${e}`}testE2E(){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 && PORT=8080 pm2-runtime start ecosystem.config.cjs`}){return super.testE2E({playwrightArgs:t,prismaDirectory:"prisma",startCommand:e})}testStart(){return`YARN concurrently --kill-others --raw --success first "dotenv -c development -- remix dev" "${this.waitApp()}"`}},Bn={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)?Hn:Un;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}`)}}},qn={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) | docker | headed | 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"]?Un:Hn;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"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"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 Vn={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(j.yellow('Please try "yarn gen-code" if you face unknown type errors.'))}}},Jn={...Vn,command:"tc"};var Yn;await en((Yn=process.argv,Yn.slice(K()+1))).scriptName("wb").options(on).middleware((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]}const n=e["working-dir"];if(n){const e=t.resolve(n);process.chdir(e),rn.dirPath=e}let s=(e.env??[]).map((t=>t.toString()));if("string"==typeof e.cascade){0===s.length&&s.push(".env");const t=[];for(const n of s)t.push(...e.cascade?[`${n}.${e.cascade}.local`,`${n}.local`,`${n}.${e.cascade}`,n]:[`${n}.local`,n]);s=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(Pn).command(Wn).command(Rn).command(Bn).command(qn).command(Vn).command(Jn).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
|
|
33
|
+
var U,T,B;const V=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,q=null!==(T=null===(U=null===process||void 0===process?void 0:process.versions)||void 0===U?void 0:U.node)&&void 0!==T?T:null===(B=null===process||void 0===process?void 0:process.version)||void 0===B?void 0:B.slice(1);if(q){if(Number(q.match(/^([^.]+)/)[1])<V)throw Error(`yargs parser supports a minimum Node.js version of ${V}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const J=process?process.env:{},Y=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=D(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=>I(t,g.arrays)?(b=Error(p("Invalid configuration: %s, opts.count excludes opts.array.",t)),!0):!!I(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)&&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&&(I(c[1],g.arrays)?t=A(t,c[1],s,c[2]):!1!==I(c[1],g.nargs)?t=j(t,c[1],s,c[2]):E(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],E(r,!!I(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],I(r,g.arrays)?t=A(t,r,s):!1!==I(r,g.nargs)?t=j(t,r,s):(l=s[t+1],void 0===l||l.match(/^-/)&&!l.match(m)||I(r,g.bools)||I(r,g.counts)?/^(true|false)$/.test(l)?(E(r,l),t++):E(r,B(r)):(E(r,l),t++)));else if(e.match(/^-.\..+=/))c=e.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&E(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(/^-/)||I(r,g.bools)||I(r,g.counts)?E(r,B(r)):(E(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],I(r,g.arrays)?t=A(t,r,s,h):!1!==I(r,g.nargs)?t=j(t,r,s,h):E(r,h),i=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===I(l,g.bools)){E(a[n],l),i=!0;break}if(a[n+1]&&a[n+1].match(/\W/)){E(a[n],l),i=!0;break}E(a[n],B(a[n]))}else E(a[n],l)}r=e.slice(-1)[0],i||"-"===r||(I(r,g.arrays)?t=A(t,r,s):!1!==I(r,g.nargs)?t=j(t,r,s):(l=s[t+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(m)||I(r,g.bools)||I(r,g.counts)?/^(true|false)$/.test(l)?(E(r,l),t++):E(r,B(r)):(E(r,l),t++)))}else if(e.match(/^-[0-9]$/)&&e.match(m)&&I(e.slice(1),g.bools))r=e.slice(1),E(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=$("_",t);"string"!=typeof e&&"number"!=typeof e||v._.push(e)}function j(t,e,n,s){let i,r=I(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))),E(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)||T(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&&(E(e,s),c--),i=t+1;i<c+t+1;i++)E(e,n[i]);return t+c}function A(t,e,n,s){let r=[],c=s||n[t+1];const l=I(e,g.nargs);if(I(e,g.bools)&&!/^(true|false)$/.test(c))r.push(!0);else if(V(c)||V(s)&&/^-/.test(c)&&!m.test(c)&&!T(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)||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))),E(e,r),t}function E(t,e,n=i){if(/-/.test(t)&&o["camel-case-expansion"]){const e=t.split(".").map((function(t){return D(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)})),I(t,g.normalize)&&!I(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)),(I(t,g.bools)||I(t,g.counts))&&"string"==typeof e&&(e="true"===e);let s=Array.isArray(e)?e.map((function(e){return $(t,e)})):$(t,e);return I(t,g.counts)&&(V(s)||"boolean"==typeof s)&&(s=L()),I(t,g.normalize)&&I(t,g.arrays)&&(s=Array.isArray(e)?e.map((t=>z.normalize(t))):z.normalize(e)),s}function $(t,e){if(!o["parse-positional-numbers"]&&"_"===t)return e;if(!I(t,g.strings)&&!I(t,g.bools)&&!Array.isArray(e)){(F(e)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${e}`)))||!V(e)&&I(t,g.numbers))&&(e=Number(e))}return e}function P(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"]?P(s,i):(!M(v,i.split("."))||I(i,g.arrays)&&o["combine-arrays"])&&E(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)),D(t)}));(e&&g.configs[r.join(".")]||!e)&&!M(t,r)&&E(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=I(e.join("."),g.arrays),a=Array.isArray(n);let c=o["duplicate-arguments-array"];!c&&I(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===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]||I(i,g.counts)||I(i,g.bools)?s[i]=n:s[i]=[s[i],n]}function I(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 U(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),!U(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&&U(n[1])}))}(t,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}(t)}function B(t){return I(t,g.bools)||I(t,g.counts)||!(`${t}`in a)?(e=function(t){let e=R.BOOLEAN;return I(t,g.strings)?e=R.STRING:I(t,g.numbers)?e=R.NUMBER:I(t,g.bools)?e=R.BOOLEAN:I(t,g.arrays)&&(e=R.ARRAY),e}(t),{[R.BOOLEAN]:!0,[R.STRING]:"",[R.NUMBER]:void 0,[R.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=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);P(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){P(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=I(s,g.coercions),"function"==typeof e))try{const i=$(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("."))||E(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=>D(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: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 Y.parse(t.slice(),e).argv};function K(){return process.versions.electron&&!process.defaultApp?0:1}G.detailed=function(t,e){return Y.parse(t.slice(),e)},G.camelCase=D,G.decamelize=W,G.looksLikeNumber=F;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 P({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:I})},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(wt(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(vt(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(vt(e))return e(t,!0);wt(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 wt(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function vt(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 jt(t){return"boolean"==typeof t}function At(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(jt(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 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(),j=e.cliui({width:k,wrap:!!k});if(!h)if(l.length)l.forEach((t=>{j.div({text:`${t[0].replace(/\$0/g,i)}`}),t[1]&&j.div({text:`${t[1]}`,padding:[1,0,0,0]})})),j.div();else if(u.length){let t=null;t=o._?`${i} <${n("command")}>\n`:`${i} [${n("command")}]\n`,j.div(`${t}`)}if(u.length>1||1===u.length&&!u[0][2]){j.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 ?/,"")}`;j.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?j.div({text:o.join(" "),padding:[0,0,0,2],align:"right"}):j.div()})),j.div()}const A=(Object.keys(g.alias)||[]).concat(Object.keys(t.parsed.newAliases)||[]);m=m.filter((e=>!t.parsed.newAliases[e]&&A.every((t=>-1===(g.alias[t]||[]).indexOf(e)))));const E=n("Options:");c[E]||(c[E]=[]),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,E);const _=t=>/^--/.test(xt(t)),x=Object.keys(c).filter((t=>c[t].length>0)).map((t=>({groupName:t,normalizedKeys:c[t].filter(v).map((t=>{if(A.includes(t))return t;for(let e,n=0;void 0!==(e=A[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,Et(n)?{text:n.text,indentation:n.indentation+s}:{text:n,indentation:s}))}))})),x.forEach((({groupName:e,normalizedKeys:i,switches:o})=>{j.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;j.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?j.div({text:h,padding:[0,0,0,2],align:"right"}):j.div()})),j.div()})),d.length&&(j.div(n("Examples:")),d.forEach((t=>{t[0]=t[0].replace(/\$0/g,i)})),d.forEach((t=>{""===t[1]?j.div({text:t[0],padding:[0,2,0,2]}):j.div({text:t[0],padding:[0,2,0,2],width:b(d,k)+4},{text:t[1]})})),j.div()),p.length>0){const t=p.map((t=>t.replace(/\$0/g,i))).join("\n");j.div(`${t}\n`)}return j.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=Ot(f,(e=>!t[e])),s};const j=[];return s.freeze=function(){j.push({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f})},s.unfreeze=function(t=!1){const e=j.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 Et(t){return"object"==typeof t}function _t(t){return Et(t)?t.indentation:0}function xt(t){return Et(t)?t.text:t}class $t{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(vt(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 Pt(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?It(i,t):Object.assign({},i,t)}function It(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]=It(t[i],e[i]):n[i]=e[i];return n}var Dt,Wt,Ft,Rt,zt,Lt,Ht,Ut,Tt,Bt,Vt,qt,Jt,Yt,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"),we=Symbol("copyDoubleDash"),ve=Symbol("deleteFromParserHintObject"),Oe=Symbol("emitWarning"),ke=Symbol("freeze"),je=Symbol("getDollarZero"),Ae=Symbol("getParserConfiguration"),Ee=Symbol("getUsageConfiguration"),_e=Symbol("guessLocale"),xe=Symbol("guessVersion"),$e=Symbol("parsePositionalNumbers"),Pe=Symbol("pkgUp"),Ce=Symbol("populateParserHintArray"),Se=Symbol("populateParserHintSingleValueDictionary"),Me=Symbol("populateParserHintArrayDictionary"),Ne=Symbol("populateParserHintDictionary"),Ie=Symbol("sanitizeKey"),De=Symbol("setKey"),We=Symbol("unfreeze"),Fe=Symbol("validateAsync"),Re=Symbol("getCommandInstance"),ze=Symbol("getContext"),Le=Symbol("getHasOutput"),He=Symbol("getLoggerInstance"),Ue=Symbol("getParseContext"),Te=Symbol("getUsageInstance"),Be=Symbol("getValidationInstance"),Ve=Symbol("hasParseCallback"),qe=Symbol("isGlobalContext"),Je=Symbol("postProcess"),Ye=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,Dt.set(this,void 0),Wt.set(this,void 0),Ft.set(this,{commands:[],fullCommands:[]}),Rt.set(this,null),zt.set(this,null),Lt.set(this,"show-hidden"),Ht.set(this,null),Ut.set(this,!0),Tt.set(this,{}),Bt.set(this,!0),Vt.set(this,[]),qt.set(this,void 0),Jt.set(this,{}),Yt.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[je](),this[Ge](),me(this,Dt,ye(this,Dt,"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[we](),"f")}addHelpOpt(t,e){return dt("[string|boolean] [string]",[t,e],arguments.length),ye(this,Gt,"f")&&(this[ve](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[Ae]()["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,Rt,"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,Dt,"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,Dt,"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[De](t,!0),ye(this,ue,"f").describe(t,e),this}detectLocale(t){return dt("<boolean>",[t],arguments.length),me(this,Ut,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,Yt,!0,"f"),me(this,Ht,e,"f"),ye(this,Bt,"f")&&ye(this,ce,"f").process.exit(t)}exitProcess(t=!0){return dt("[boolean]",[t],arguments.length),me(this,Bt,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,Rt,"f").getCompletion(t,e):new Promise(((e,n)=>{ye(this,Rt,"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,Ut,"f")}getExitProcess(){return ye(this,Bt,"f")}getGroups(){return Object.assign({},ye(this,Jt,"f"),ye(this,re,"f"))}getHelp(){if(me(this,Yt,!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,Dt,"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,Jt,"f")[e];ye(this,re,"f")[e]&&delete ye(this,re,"f")[e];const s={};return ye(this,Jt,"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,Ut,!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,Bt,!1,"f");const s=this[Ke](t,!!e),i=this.parsed;return ye(this,Rt,"f").setParsed(this.parsed),ct(s)?s.then((t=>(ye(this,ne,"f")&&ye(this,ne,"f").call(this,ye(this,Ht,"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,Ht,"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[Pe](e||ye(this,Wt,"f"));return s[t]&&"object"==typeof s[t]&&(n=Nt(s[t],e||ye(this,Wt,"f"),this[Ae]()["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,Ft,"f").fullCommands[ye(this,Ft,"f").fullCommands.length-1],i=s?ye(this,Dt,"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,Rt,"f").generateCompletionScript(t,e||ye(this,zt,"f")||"completion")),this}showHelp(t){if(dt("[string|function]",[t],arguments.length),me(this,Yt,!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,Dt,"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,Ut,!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[ve](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}[(Dt=new WeakMap,Wt=new WeakMap,Ft=new WeakMap,Rt=new WeakMap,zt=new WeakMap,Lt=new WeakMap,Ht=new WeakMap,Ut=new WeakMap,Tt=new WeakMap,Bt=new WeakMap,Vt=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Yt=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}[we](){return{log:(...t)=>{this[Ve]()||console.log(...t),me(this,Yt,!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[Ve]()||console.error(...t),me(this,Yt,!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")}}}[ve](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,Vt,"f").push({options:ye(this,Xt,"f"),configObjects:ye(this,Xt,"f").configObjects.slice(0),exitProcess:ye(this,Bt,"f"),groups:ye(this,Jt,"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,Ht,"f"),hasOutput:ye(this,Yt,"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,Dt,"f").freeze(),ye(this,qt,"f").freeze()}[je](){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[Ye](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}[Ae](){return ye(this,ee,"f")}[Ee](){return ye(this,fe,"f")}[_e](){if(!ye(this,Ut,"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[Pe]().version||"unknown"}[$e](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}[Pe](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[Ie](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[Ie](n),s)}[Ie](t){return"__proto__"===t?"___proto___":t}[De](t,e){return this[Se](this[De].bind(this),"key",t,e),this}[We](){var t,e,n,s,i,r,o,a,c,l,h,d;const u=ye(this,Vt,"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,Bt,t,"f")}}.value,groups:{set value(t){me(n,Jt,t,"f")}}.value,output:{set value(t){me(s,Zt,t,"f")}}.value,exitError:{set value(t){me(i,Ht,t,"f")}}.value,hasOutput:{set value(t){me(r,Yt,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,Dt,"f").unfreeze(),ye(this,qt,"f").unfreeze()}[Fe](t,e){return mt(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[Re].bind(this),getContext:this[ze].bind(this),getHasOutput:this[Le].bind(this),getLoggerInstance:this[He].bind(this),getParseContext:this[Ue].bind(this),getParserConfiguration:this[Ae].bind(this),getUsageConfiguration:this[Ee].bind(this),getUsageInstance:this[Te].bind(this),getValidationInstance:this[Be].bind(this),hasParseCallback:this[Ve].bind(this),isGlobalContext:this[qe].bind(this),postProcess:this[Je].bind(this),reset:this[Ge].bind(this),runValidation:this[Qe].bind(this),runYargsParserAndExecuteCommands:this[Ke].bind(this),setHasOutput:this[Ze].bind(this)}}[Re](){return ye(this,Dt,"f")}[ze](){return ye(this,Ft,"f")}[Le](){return ye(this,Yt,"f")}[He](){return ye(this,Qt,"f")}[Ue](){return ye(this,se,"f")||{}}[Te](){return ye(this,ue,"f")}[Be](){return ye(this,ge,"f")}[Ve](){return!!ye(this,ne,"f")}[qe](){return ye(this,Kt,"f")}[Je](t,e,n,s){if(n)return t;if(ct(t))return t;e||(t=this[be](t));return(this[Ae]()["parse-positional-numbers"]||void 0===this[Ae]()["parse-positional-numbers"])&&(t=this[$e](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,Jt,"f")).reduce(((t,e)=>{const s=ye(this,Jt,"f")[e].filter((t=>!(t in n)));return s.length>0&&(t[e]=s),t}),{})),me(this,Jt,{},"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):At(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=Pt(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,Dt,ye(this,Dt,"f")?ye(this,Dt,"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,Rt,"f")||me(this,Rt,function(t,e,n,s){return new $t(t,e,n,s)}(this,ye(this,ue,"f"),ye(this,Dt,"f"),ye(this,ce,"f")),"f"),ye(this,qt,"f").reset(),me(this,zt,null,"f"),me(this,Zt,"","f"),me(this,Ht,null,"f"),me(this,Yt,!1,"f"),this.parsed=!1,this}[Ye](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[Ae]();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[Je](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,Dt,"f").getCommands(),p=ye(this,Rt,"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,Dt,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Je](t,o,!!n,!1)}if(!t&&e!==ye(this,zt,"f")){t=e;break}}!ye(this,Dt,"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,Bt,"f")&&kt(!0),this.showCompletionScript(),this.exit(0))}if(ye(this,Dt,"f").hasDefaultCommand()&&!g){const t=ye(this,Dt,"f").runCommand(null,this,c,0,i,u||f||i);return this[Je](t,o,!!n,!1)}if(p){ye(this,Bt,"f")&&kt(!0);const e=(t=[].concat(t)).slice(t.indexOf(`--${ye(this,Rt,"f").completionKey}`)+1);return ye(this,Rt,"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[Je](l,!o,!!n,!1)}if(ye(this,Yt,"f")||(u?(ye(this,Bt,"f")&&kt(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(ye(this,Bt,"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[Fe](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[Je](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,Yt,!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:{description:"environment to load cascading .env files (e.g., `.env`, `.env.<environment>`, `.env.local` and `.env.<environment>.local`)",type:"string"},"working-dir":{description:"A working directory",type:"string",alias:"w"}},an={dry:{description:"Indicates if dry-run mode is enabled or not.",type:"boolean",alias:"d"},verbose:{description:"Indicates if verbose mode is enabled or not.",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.dry){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.dry||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.dry)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.dry||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=w(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 A,wn=new Set;const vn={exitIfFailed:!0};async function On(t,e,n=vn){const[s,i]=jn(t);if(An(s),e.verbose&&An(s,"Start (detailed)",!0),e.dryRun)return En(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 E(t);const e=async()=>{wn.has(t)||(wn.add(t),await E(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:!0});return En(s,o.status,n),o.status??1}function kn(t,e,n=vn){return bn.run((async()=>{const[s,i]=jn(t);if(An(s,"Start (parallel)",!0),e.dryRun)return An(s,"Start (log)"),void En(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:!0});An(s,"Start (log)");const o=r.stdout.trim();o&&console.info(o),En(s,r.status,n)}))}function jn(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 An(t,e="Start",n=!1){console.info("\n"+(n?j.gray:j.cyan)(j.bold(`${e}:`),t))}function En(t,e,n){0===e?console.info(j.green(j.bold("Finished:"),t)):(console.info(j.red(j.bold(`Failed (exit code ${e}): `),t)),!1!==n.exitIfFailed&&process.exit(e??1))}let _n=!1,xn=!1;const $n={...an},Pn={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Cn).command(Sn).command(Mn).command(Nn).command(In).command(Dn).demandCommand(),handler(){}},Cn={command:"litestream",describe:"Setup DB for Litestream",builder:$n,async handler(t){await On(gn.litestream(),t)}},Sn={command:"migrate",describe:"Apply migration files to DB",builder:$n,async handler(t){await On(gn.migrate(),t)}},Mn={command:"migrate-dev",describe:"Create a migration file",builder:$n,async handler(t){await On(gn.migrateDev(),t)}},Nn={command:"reset",describe:"Reset DB",builder:$n,async handler(t){await On(gn.reset(),t)}},In={command:"seed",describe:"Populate DB with seed data",builder:$n,async handler(t){await On(gn.seed(),t)}},Dn={command:"studio",describe:"Open Prisma Studio",builder:$n,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${j.yellow(`#${s} Retrying: ${e.join(" ")}`)}`),n=await On(e.join(" "),t,{exitIfFailed:!1}),0===n)return;process.exit(n)}},Fn={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 Rn=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()=>{wn.has(t)||(wn.add(t),v(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 Rn.buildDevImage(t)}startDocker(t=""){return`${this.buildDocker()}\n && YARN concurrently --raw --kill-others-on-fail\n "${Rn.stopAndStart(!1,"",t)}"\n "${this.waitAndOpenApp(8080)}"`}testE2E({playwrightArgs:t,prismaDirectory:e,startCommand:n}){return`APP_ENV=production WB_ENV=test 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}"`}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 && PORT=8080 pm2-runtime start ecosystem.config.cjs`}){return super.testE2E({playwrightArgs:t,prismaDirectory:"db",startCommand:e})}testStart(){return`YARN concurrently --kill-others --raw --success first "blitz dev" "${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()} && ${Rn.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 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 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()} && ${Rn.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.'"}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 && PORT=8080 pm2-runtime start ecosystem.config.cjs`}){return super.testE2E({playwrightArgs:t,prismaDirectory:"prisma",startCommand:e})}testStart(){return`YARN concurrently --kill-others --raw --success first "dotenv -c development -- remix dev" "${this.waitApp()}"`}},Bn={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)?Hn:Un;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}`)}}},Vn={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) | docker | headed | 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"]?Un:Hn;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(Rn.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:Rn.stopAndStart(!0)}:{};process.exitCode=await On(i.testE2E(t),e,{exitIfFailed:!1}),await On(Rn.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"docker":return await On(`${i.buildDocker("test")}`,e),process.exitCode=await On(i.testE2E({startCommand:Rn.stopAndStart(!0)}),e,{exitIfFailed:!1}),void await On(Rn.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"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(j.yellow('Please try "yarn gen-code" if you face unknown type errors.'))}}},Jn={...qn,command:"tc"};var Yn;await en((Yn=process.argv,Yn.slice(K()+1))).scriptName("wb").options(on).middleware((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]}const n=e["working-dir"];if(n){const e=t.resolve(n);process.chdir(e),rn.dirPath=e}let s=(e.env??[]).map((t=>t.toString()));if("string"==typeof e.cascade){0===s.length&&s.push(".env");const t=[];for(const n of s)t.push(...e.cascade?[`${n}.${e.cascade}.local`,`${n}.local`,`${n}.${e.cascade}`,n]:[`${n}.local`,n]);s=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(Pn).command(Wn).command(Fn).command(Bn).command(Vn).command(qn).command(Jn).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
|
|
34
34
|
//# sourceMappingURL=index.js.map
|