@willbooster/wb 2.6.1 → 2.7.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 CHANGED
@@ -1,4 +1,4 @@
1
- import t,{resolve as e,dirname as n,normalize as s,basename as i,extname as r,relative as o}from"node:path";import{config as a}from"dotenv";import{notStrictEqual as c,strictEqual as l}from"node:assert";import h,{statSync as d,readdirSync as u,readFileSync as f,writeFile as p}from"node:fs";import{format as g,inspect as m}from"node:util";import{fileURLToPath as y}from"node:url";import b,{spawn as w,execSync as v,spawnSync as O}from"node:child_process";import{createHash as k}from"node:crypto";import j from"node:fs/promises";import A from"chalk";import{PromisePool as E}from"minimal-promise-pool";import*as _ from"node:os";import x from"node:os";import{killPortProcess as $}from"kill-port-process";const P={right:function(t,e){t=t.trim();const n=M.stringWidth(t);if(n<e)return" ".repeat(e-n)+t;return t},center:function(t,e){t=t.trim();const n=M.stringWidth(t);if(n>=e)return t;return" ".repeat(e-n>>1)+t}};class C{constructor(t){var e;this.width=t.width,this.wrap=null===(e=t.wrap)||void 0===e||e,this.rows=[]}span(...t){this.div(...t).span=!0}resetOutput(){this.rows=[]}div(...t){if(0===t.length&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&"string"==typeof t[0])return this.applyLayoutDSL(t[0]);const e=t.map((t=>"string"==typeof t?this.colFromString(t):t));return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return 1===t.length&&"string"==typeof t[0]&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){const e=t.split("\n").map((t=>t.split("\t")));let n=0;return e.forEach((t=>{t.length>1&&M.stringWidth(t[0])>n&&(n=Math.min(Math.floor(.5*this.width),M.stringWidth(t[0])))})),e.forEach((t=>{this.div(...t.map(((e,s)=>({text:e.trim(),padding:this.measurePadding(e),width:0===s&&t.length>1?n:void 0}))))})),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){const e=M.stripAnsi(t);return[0,e.match(/\s*$/)[0].length,0,e.match(/^\s*/)[0].length]}toString(){const t=[];return this.rows.forEach((e=>{this.rowToString(e,t)})),t.filter((t=>!t.hidden)).map((t=>t.text)).join("\n")}rowToString(t,e){return this.rasterize(t).forEach(((n,s)=>{let i="";n.forEach(((n,r)=>{const{width:o}=t[r],a=this.negatePadding(t[r]);let c=n;if(a>M.stringWidth(n)&&(c+=" ".repeat(a-M.stringWidth(n))),t[r].align&&"left"!==t[r].align&&this.wrap){c=(0,P[t[r].align])(c,a),M.stringWidth(c)<a&&(c+=" ".repeat((o||0)-M.stringWidth(c)-1))}const l=t[r].padding||[0,0,0,0];l[3]&&(i+=" ".repeat(l[3])),i+=S(t[r],c,"| "),i+=c,i+=S(t[r],c," |"),l[1]&&(i+=" ".repeat(l[1])),0===s&&e.length>0&&(i=this.renderInline(i,e[e.length-1]))})),e.push({text:i.replace(/ +$/,""),span:t.span})})),e}renderInline(t,e){const n=t.match(/^ */),s=n?n[0].length:0,i=e.text,r=M.stringWidth(i.trimRight());return e.span?this.wrap?s<r?t:(e.hidden=!0,i.trimRight()+" ".repeat(s-r)+t.trimLeft()):(e.hidden=!0,i+t):t}rasterize(t){const e=[],n=this.columnWidths(t);let s;return t.forEach(((t,i)=>{t.width=n[i],s=this.wrap?M.wrap(t.text,this.negatePadding(t),{hard:!0}).split("\n"):t.text.split("\n"),t.border&&(s.unshift("."+"-".repeat(this.negatePadding(t)+2)+"."),s.push("'"+"-".repeat(this.negatePadding(t)+2)+"'")),t.padding&&(s.unshift(...new Array(t.padding[0]||0).fill("")),s.push(...new Array(t.padding[2]||0).fill(""))),s.forEach(((t,n)=>{e[n]||e.push([]);const s=e[n];for(let t=0;t<i;t++)void 0===s[t]&&s.push("");s.push(t)}))})),e}negatePadding(t){let e=t.width||0;return t.padding&&(e-=(t.padding[3]||0)+(t.padding[1]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map((t=>t.width||M.stringWidth(t.text)));let e=t.length,n=this.width;const s=t.map((t=>{if(t.width)return e--,n-=t.width,t.width})),i=e?Math.floor(n/e):0;return s.map(((e,n)=>void 0===e?Math.max(i,function(t){const e=t.padding||[],n=1+(e[3]||0)+(e[1]||0);if(t.border)return n+4;return n}(t[n])):e))}}function S(t,e,n){return t.border?/[.']-+[.']/.test(e)?"":0!==e.trim().length?n:" ":""}let M;const N=new RegExp("(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function I(t){return t.replace(N,"")}function D(t,e){const[n,s]=t.match(N)||["",""];t=I(t);let i="";for(let n=0;n<t.length;n++)0!==n&&n%e==0&&(i+="\n"),i+=t.charAt(n);return n&&s&&(i=`${n}${i}${s}`),i}
1
+ import t,{resolve as e,dirname as n,normalize as s,basename as i,extname as r,relative as o}from"node:path";import{config as a}from"dotenv";import{notStrictEqual as c,strictEqual as l}from"node:assert";import h,{statSync as d,readdirSync as u,readFileSync as f,writeFile as p}from"node:fs";import{format as g,inspect as m}from"node:util";import{fileURLToPath as y}from"node:url";import b,{spawn as w,execSync as v,spawnSync as O}from"node:child_process";import{createHash as k}from"node:crypto";import j from"node:fs/promises";import A from"chalk";import{PromisePool as E}from"minimal-promise-pool";import{killPortProcess as _}from"kill-port-process";import*as x from"node:os";import $ from"node:os";const P={right:function(t,e){t=t.trim();const n=M.stringWidth(t);if(n<e)return" ".repeat(e-n)+t;return t},center:function(t,e){t=t.trim();const n=M.stringWidth(t);if(n>=e)return t;return" ".repeat(e-n>>1)+t}};class C{constructor(t){var e;this.width=t.width,this.wrap=null===(e=t.wrap)||void 0===e||e,this.rows=[]}span(...t){this.div(...t).span=!0}resetOutput(){this.rows=[]}div(...t){if(0===t.length&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&"string"==typeof t[0])return this.applyLayoutDSL(t[0]);const e=t.map((t=>"string"==typeof t?this.colFromString(t):t));return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return 1===t.length&&"string"==typeof t[0]&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){const e=t.split("\n").map((t=>t.split("\t")));let n=0;return e.forEach((t=>{t.length>1&&M.stringWidth(t[0])>n&&(n=Math.min(Math.floor(.5*this.width),M.stringWidth(t[0])))})),e.forEach((t=>{this.div(...t.map(((e,s)=>({text:e.trim(),padding:this.measurePadding(e),width:0===s&&t.length>1?n:void 0}))))})),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){const e=M.stripAnsi(t);return[0,e.match(/\s*$/)[0].length,0,e.match(/^\s*/)[0].length]}toString(){const t=[];return this.rows.forEach((e=>{this.rowToString(e,t)})),t.filter((t=>!t.hidden)).map((t=>t.text)).join("\n")}rowToString(t,e){return this.rasterize(t).forEach(((n,s)=>{let i="";n.forEach(((n,r)=>{const{width:o}=t[r],a=this.negatePadding(t[r]);let c=n;if(a>M.stringWidth(n)&&(c+=" ".repeat(a-M.stringWidth(n))),t[r].align&&"left"!==t[r].align&&this.wrap){c=(0,P[t[r].align])(c,a),M.stringWidth(c)<a&&(c+=" ".repeat((o||0)-M.stringWidth(c)-1))}const l=t[r].padding||[0,0,0,0];l[3]&&(i+=" ".repeat(l[3])),i+=S(t[r],c,"| "),i+=c,i+=S(t[r],c," |"),l[1]&&(i+=" ".repeat(l[1])),0===s&&e.length>0&&(i=this.renderInline(i,e[e.length-1]))})),e.push({text:i.replace(/ +$/,""),span:t.span})})),e}renderInline(t,e){const n=t.match(/^ */),s=n?n[0].length:0,i=e.text,r=M.stringWidth(i.trimRight());return e.span?this.wrap?s<r?t:(e.hidden=!0,i.trimRight()+" ".repeat(s-r)+t.trimLeft()):(e.hidden=!0,i+t):t}rasterize(t){const e=[],n=this.columnWidths(t);let s;return t.forEach(((t,i)=>{t.width=n[i],s=this.wrap?M.wrap(t.text,this.negatePadding(t),{hard:!0}).split("\n"):t.text.split("\n"),t.border&&(s.unshift("."+"-".repeat(this.negatePadding(t)+2)+"."),s.push("'"+"-".repeat(this.negatePadding(t)+2)+"'")),t.padding&&(s.unshift(...new Array(t.padding[0]||0).fill("")),s.push(...new Array(t.padding[2]||0).fill(""))),s.forEach(((t,n)=>{e[n]||e.push([]);const s=e[n];for(let t=0;t<i;t++)void 0===s[t]&&s.push("");s.push(t)}))})),e}negatePadding(t){let e=t.width||0;return t.padding&&(e-=(t.padding[3]||0)+(t.padding[1]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map((t=>t.width||M.stringWidth(t.text)));let e=t.length,n=this.width;const s=t.map((t=>{if(t.width)return e--,n-=t.width,t.width})),i=e?Math.floor(n/e):0;return s.map(((e,n)=>void 0===e?Math.max(i,function(t){const e=t.padding||[],n=1+(e[3]||0)+(e[1]||0);if(t.border)return n+4;return n}(t[n])):e))}}function S(t,e,n){return t.border?/[.']-+[.']/.test(e)?"":0!==e.trim().length?n:" ":""}let M;const N=new RegExp("(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function I(t){return t.replace(N,"")}function D(t,e){const[n,s]=t.match(N)||["",""];t=I(t);let i="";for(let n=0;n<t.length;n++)0!==n&&n%e==0&&(i+="\n"),i+=t.charAt(n);return n&&s&&(i=`${n}${i}${s}`),i}
2
2
  /**
3
3
  * @license
4
4
  * Copyright (c) 2016, Contributors
@@ -30,5 +30,5 @@ let L;!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 T,B,q;const V=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,J=null!==(B=null===(T=null===process||void 0===process?void 0:process.versions)||void 0===T?void 0:T.node)&&void 0!==B?B:null===(q=null===process||void 0===process?void 0:process.version)||void 0===q?void 0:q.slice(1);if(J){if(Number(J.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 Y=process?process.env:{},G=new class{constructor(t){L=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.__||L.format,g={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},m=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,y=new RegExp("^--"+o["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach((function(t){const e="object"==typeof t?t.key:t,n=Object.keys(t).map((function(t){return{boolean:"bools",string:"strings",number:"numbers"}[t]})).filter(Boolean).pop();n&&(g[n][e]=!0),g.arrays[e]=!0,g.keys.push(e)})),[].concat(n.boolean||[]).filter(Boolean).forEach((function(t){g.bools[t]=!0,g.keys.push(t)})),[].concat(n.string||[]).filter(Boolean).forEach((function(t){g.strings[t]=!0,g.keys.push(t)})),[].concat(n.number||[]).filter(Boolean).forEach((function(t){g.numbers[t]=!0,g.keys.push(t)})),[].concat(n.count||[]).filter(Boolean).forEach((function(t){g.counts[t]=!0,g.keys.push(t)})),[].concat(n.normalize||[]).filter(Boolean).forEach((function(t){g.normalize[t]=!0,g.keys.push(t)})),"object"==typeof n.narg&&Object.entries(n.narg).forEach((([t,e])=>{"number"==typeof e&&(g.nargs[t]=e,g.keys.push(t))})),"object"==typeof n.coerce&&Object.entries(n.coerce).forEach((([t,e])=>{"function"==typeof e&&(g.coercions[t]=e,g.keys.push(t))})),void 0!==n.config&&(Array.isArray(n.config)||"string"==typeof n.config?[].concat(n.config).filter(Boolean).forEach((function(t){g.configs[t]=!0})):"object"==typeof n.config&&Object.entries(n.config).forEach((([t,e])=>{"boolean"!=typeof e&&"function"!=typeof e||(g.configs[t]=e)}))),function(...t){t.forEach((function(t){Object.keys(t||{}).forEach((function(t){g.aliases[t]||(g.aliases[t]=[].concat(r[t]||[]),g.aliases[t].concat(t).forEach((function(e){if(/-/.test(e)&&o["camel-case-expansion"]){const n=W(e);n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].concat(t).forEach((function(e){if(e.length>1&&/[A-Z]/.test(e)&&o["camel-case-expansion"]){const n=R(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 W(t)})).join(".");_(t,e)}const s=x(t,e,n),r=t.split(".");if(N(v,r,s),g.aliases[t]&&g.aliases[t].forEach((function(t){const e=t.split(".");N(v,e,s)})),r.length>1&&o["dot-notation"]&&(g.aliases[r[0]]||[]).forEach((function(e){let n=e.split(".");const i=[].concat(r);i.shift(),n=n.concat(i),(g.aliases[t]||[]).includes(n.join("."))||N(v,n,s)})),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?L.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=H()),I(t,g.normalize)&&I(t,g.arrays)&&(s=Array.isArray(e)?e.map((t=>L.normalize(t))):L.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}`)))||!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=L.env();Object.keys(s).forEach((function(i){if(""===n||0===i.lastIndexOf(n,0)){const r=i.split("__").map((function(t,e){return 0===e&&(t=t.substring(n.length)),W(t)}));(e&&g.configs[r.join(".")]||!e)&&!M(t,r)&&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=U(t),"object"==typeof s&&void 0===s[t]&&(s[t]={}),"object"!=typeof s[t]||Array.isArray(s[t])?(Array.isArray(s[t])?s[t].push({}):s[t]=[s[t],{}],s=s[t][s[t].length-1]):s=s[t]}));const i=U(e[e.length-1]),r=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===H()?s[i]=H(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 D(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),!D(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&&D(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=z.BOOLEAN;return I(t,g.strings)?e=z.STRING:I(t,g.numbers)?e=z.NUMBER:I(t,g.bools)?e=z.BOOLEAN:I(t,g.arrays)&&(e=z.ARRAY),e}(t),{[z.BOOLEAN]:!0,[z.STRING]:"",[z.NUMBER]:void 0,[z.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=L.resolve(L.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=L.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=>W(t))).join(".")],delete v[t]})),{aliases:Object.assign({},g.aliases),argv:Object.assign(O,v),configuration:o,defaulted:Object.assign({},f),error:b,newAliases:Object.assign({},u)}}}({cwd:process.cwd,env:()=>Y,format:g,normalize:s,resolve:e,require:t=>{if("undefined"!=typeof require)return require(t);if(t.match(/\.json$/))return JSON.parse(f(t,"utf8"));throw Error("only .json config files are supported in ESM")}}),K=function(t,e){return G.parse(t.slice(),e).argv};function Q(){return process.versions.electron&&!process.defaultApp?0:1}K.detailed=function(t,e){return G.parse(t.slice(),e)},K.camelCase=W,K.decamelize=R,K.looksLikeNumber=F;class Z extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,Z)}}var X={fs:{readFileSync:f,writeFile:p},format:g,resolve:e,exists:t=>{try{return d(t).isFile()}catch(t){return!1}}};let tt;class et{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(),tt.format.apply(tt.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),tt.format.apply(tt.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);tt.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{tt.fs.readFileSync&&(t=JSON.parse(tt.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=tt.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const s=tt.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(t){return tt.exists(t)}}const nt="loading a directory of commands is not supported yet for ESM";let st;try{st=y(import.meta.url)}catch(t){st=process.cwd()}var it,rt={assert:{notStrictEqual:c,strictEqual:l},cliui:function(t){return function(t,e){return M=e,new C({width:(null==t?void 0:t.width)||("object"==typeof process&&process.stdout&&process.stdout.columns?process.stdout.columns:80),wrap:null==t?void 0:t.wrap})}(t,{stringWidth:t=>[...t].length,stripAnsi:I,wrap:D})},findUp:function(t,s){let i,r=e(".",t);for(d(r).isDirectory()||(r=n(r));;){if(i=s(r,u(r)),i)return e(r,i);if(r=n(i=r),i===r)break}},getEnv:t=>process.env[t],inspect:m,getCallerFile:()=>{throw new Z(nt)},getProcessArgvBin:function(){return process.argv[Q()]},mainFilename:st.substring(0,st.lastIndexOf("node_modules"))||process.cwd(),Parser:K,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 Z("require is not supported by ESM")},requireDirectory:()=>{throw new Z(nt)},stringWidth:t=>[...t].length,y18n:(it={directory:e(st,"../../../locales"),updateFiles:!1},function(t,e){tt=e;const n=new et(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}}(it,X))};function ot(t,e,n,s){n.assert.notStrictEqual(t,e,s)}function at(t,e){e.assert.strictEqual(typeof t,"string")}function ct(t){return Object.keys(t)}function lt(t){return!!t&&!!t.then&&"function"==typeof t.then}function ht(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 dt=["first","second","third","fourth","fifth","sixth"];function ut(t,e,n){try{let s=0;const[i,r,o]="object"==typeof t?[{demanded:[],optional:[]},t,e]:[ht(`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 Z(`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 Z(`Too many arguments provided. Expected max ${l} but received ${c}.`);i.demanded.forEach((t=>{const e=ft(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&pt(e,t.cmd,s),s+=1})),i.optional.forEach((t=>{if(0===a.length)return;const e=ft(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&pt(e,t.cmd,s),s+=1}))}catch(t){console.warn(t.stack)}}function ft(t){return Array.isArray(t)?"array":null===t?"null":typeof t}function pt(t,e,n){throw new Z(`Invalid ${dt[n]||"manyith"} argument. Expected ${e.join(" or ")} but received ${t}.`)}class gt{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,s=!1){if(ut("<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 mt(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(lt(t))return t.then((t=>Promise.all([t,n(t,e)]))).then((([t,e])=>Object.assign(t,e)));{const s=n(t,e);return lt(s)?s.then((e=>Object.assign(t,e))):Object.assign(t,s)}}),t)}function yt(t,e,n=(t=>{throw t})){try{const n="function"==typeof t?t():t;return lt(n)?n.then((t=>e(t))):e(n)}catch(t){return n(t)}}const bt=/(^\*)|(^\$0)/;class wt{constructor(t,e,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,s){"boolean"!=typeof(s=s||{}).recurse&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);const i="function"==typeof s.visit?s.visit:t=>t;s.visit=(t,e,n)=>{const s=i(t,e,n);if(s){if(this.requireCache.has(e))return s;this.requireCache.add(e),this.addHandler(s)}return s},this.shim.requireDirectory({require:e,filename:n},t,s)}addHandler(t,e,n,s,i,r){let o=[];const a=function(t){return t?t.map((t=>(t.applyBeforeValidation=!1,t))):[]}(i);if(s=s||(()=>{}),Array.isArray(t))if(function(t){return t.every((t=>"string"==typeof t))}(t))[t,...o]=t;else for(const e of t)this.addHandler(e);else{if(function(t){return"object"==typeof t&&!Array.isArray(t)}(t)){let e=Array.isArray(t.command)||"string"==typeof t.command?t.command:this.moduleName(t);return t.aliases&&(e=[].concat(e).concat(t.aliases)),void this.addHandler(e,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated)}if(vt(n))return void this.addHandler([t].concat(o),e,n.builder,n.handler,n.middlewares,n.deprecated)}if("string"==typeof t){const i=ht(t);o=o.map((t=>ht(t).cmd));let c=!1;const l=[i.cmd].concat(o).filter((t=>!bt.test(t)||(c=!0,!1)));0===l.length&&c&&l.push("$0"),c&&(i.cmd=l[0],o=l.slice(1),t=t.replace(bt,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 lt(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(Ot(c)){n.getInternalMethods().getUsageInstance().freeze();const h=c(n.getInternalMethods().reset(s),a);if(lt(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 lt(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=bt.test(e.original)?e.original.replace(bt,"").trim():e.original,s=t.filter((t=>!bt.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=yt(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=yt(n=mt(n,r,o,!1),(t=>{const n=e.handler(t);return lt(n)?n.then((()=>t)):t})),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),lt(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=mt(n,o,c,!0);return lt(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=ht(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=bt.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(Ot(e))return e(t,!0);vt(e)||Object.keys(e).forEach((n=>{t.option(n,e[n])}))}moduleName(t){const e=function(t){if("undefined"==typeof require)return null;for(let e,n=0,s=Object.keys(require.cache);n<s.length;n++)if(e=require.cache[s[n]],e.exports===t)return e;return null}(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(const s of[t,e,n]){if("string"==typeof s||!1===s)return s;ot(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();ot(t,void 0,this.shim),({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t)}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function vt(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function Ot(t){return"function"==typeof t}function kt(t={},e=(()=>!0)){const n={};return ct(t).forEach((s=>{e(s,t[s])&&(n[s]=t[s])})),n}function jt(t){"undefined"!=typeof process&&[process.stdout,process.stderr].forEach((e=>{const n=e;n._handle&&n.isTTY&&"function"==typeof n._handle.setBlocking&&n._handle.setBlocking(t)}))}function At(t){return"boolean"==typeof t}function Et(t,e){const n=e.y18n.__,s={},i=[];s.failFn=function(t){i.push(t)};let r=null,o=null,a=!0;s.showHelpOnFail=function(e=!0,n){const[i,c]="string"==typeof e?[!0,e]:[e,n];return t.getInternalMethods().isGlobalContext()&&(o=c),r=c,a=i,s};let c=!1;s.fail=function(e,n){const l=t.getInternalMethods().getLoggerInstance();if(!i.length){if(t.getExitProcess()&&jt(!0),!c){c=!0,a&&(t.showHelp("error"),l.error()),(e||n)&&l.error(e||n);const s=r||o;s&&((e||n)&&l.error(""),l.error(s))}if(n=n||new Z(e),t.getExitProcess())return t.exit(1);if(t.getInternalMethods().hasParseCallback())return t.exit(1,n);throw n}for(let t=i.length-1;t>=0;--t){const r=i[t];if(At(r)){if(n)throw n;if(e)throw Error(e)}else r(e,n,s)}};let l=[],h=!1;s.usage=(t,e)=>null===t?(h=!0,l=[],s):(h=!1,l.push([t,e||""]),s),s.getUsage=()=>l,s.getUsageDisabled=()=>h,s.getPositionalGroupName=()=>n("Positionals:");let d=[];s.example=(t,e)=>{d.push([t,e||""])};let u=[];s.command=function(t,e,n,s,i=!1){n&&(u=u.map((t=>(t[2]=!1,t)))),u.push([t,e||"",n,s,i])},s.getCommands=()=>u;let f={};s.describe=function(t,e){Array.isArray(t)?t.forEach((t=>{s.describe(t,e)})):"object"==typeof t?Object.keys(t).forEach((e=>{s.describe(e,t[e])})):f[t]=e},s.getDescriptions=()=>f;let p=[];s.epilog=t=>{p.push(t)};let g,m=!1;s.wrap=t=>{m=!0,g=t},s.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(m||(g=function(){const t=80;return e.process.stdColumns?Math.min(t,e.process.stdColumns):t}(),m=!0),g);const y="__yargsString__:";function b(t,n,s){let i=0;return Array.isArray(t)||(t=Object.values(t).map((t=>[t]))),t.forEach((t=>{i=Math.max(e.stringWidth(s?`${s} ${$t(t[0])}`:$t(t[0]))+xt(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($t(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,_t(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:$t(i),padding:[0,2,0,2+xt(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=kt(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 _t(t){return"object"==typeof t}function xt(t){return _t(t)?t.indentation:0}function $t(t){return _t(t)?t.text:t}class Pt{constructor(t,e,n,s){var i,r,o;this.yargs=t,this.usage=e,this.command=n,this.shim=s,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=null!==(o=(null===(i=this.shim.getEnv("SHELL"))||void 0===i?void 0:i.includes("zsh"))||(null===(r=this.shim.getEnv("ZSH_NAME"))||void 0===r?void 0:r.includes("zsh")))&&void 0!==o&&o}defaultCompletion(t,e,n,s){const i=this.command.getCommandHandlers();for(let e=0,n=t.length;e<n;++e)if(i[t[e]]&&i[t[e]].builder){const n=i[t[e]].builder;if(Ot(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=ht(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(ot(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const t=this.customCompletionFunction(n,e);return lt(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 lt(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 Ct(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 St=["$0","--","_"];let Mt,Nt=[];function It(t,e,n,s){Mt=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 Mt.path.resolve(t,e)}(e,t.extends);else try{r=require.resolve(t.extends)}catch(e){return t}!function(t){if(Nt.indexOf(t)>-1)throw new Z(`Circular extended configurations: '${t}'.`)}(r),Nt.push(r),i=s?JSON.parse(Mt.readFileSync(r,"utf8")):require(t.extends),delete t.extends,i=It(i,Mt.path.dirname(r),n,Mt)}return Nt=[],n?Dt(i,t):Object.assign({},i,t)}function Dt(t,e){const n={};function s(t){return t&&"object"==typeof t&&!Array.isArray(t)}Object.assign(n,t);for(const i of Object.keys(e))s(e[i])&&s(n[i])?n[i]=Dt(t[i],e[i]):n[i]=e[i];return n}var 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,ye=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},be=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 we=Symbol("copyDoubleDash"),ve=Symbol("copyDoubleDash"),Oe=Symbol("deleteFromParserHintObject"),ke=Symbol("emitWarning"),je=Symbol("freeze"),Ae=Symbol("getDollarZero"),Ee=Symbol("getParserConfiguration"),_e=Symbol("getUsageConfiguration"),xe=Symbol("guessLocale"),$e=Symbol("guessVersion"),Pe=Symbol("parsePositionalNumbers"),Ce=Symbol("pkgUp"),Se=Symbol("populateParserHintArray"),Me=Symbol("populateParserHintSingleValueDictionary"),Ne=Symbol("populateParserHintArrayDictionary"),Ie=Symbol("populateParserHintDictionary"),De=Symbol("sanitizeKey"),We=Symbol("setKey"),Re=Symbol("unfreeze"),Fe=Symbol("validateAsync"),ze=Symbol("getCommandInstance"),Le=Symbol("getContext"),He=Symbol("getHasOutput"),Ue=Symbol("getLoggerInstance"),Te=Symbol("getParseContext"),Be=Symbol("getUsageInstance"),qe=Symbol("getValidationInstance"),Ve=Symbol("hasParseCallback"),Je=Symbol("isGlobalContext"),Ye=Symbol("postProcess"),Ge=Symbol("rebase"),Ke=Symbol("reset"),Qe=Symbol("runYargsParserAndExecuteCommands"),Ze=Symbol("runValidation"),Xe=Symbol("setHasOutput"),tn=Symbol("kTrackManuallySetKeys");class en{constructor(t=[],e,n,s){this.customScriptName=!1,this.parsed=!1,Wt.set(this,void 0),Rt.set(this,void 0),Ft.set(this,{commands:[],fullCommands:[]}),zt.set(this,null),Lt.set(this,null),Ht.set(this,"show-hidden"),Ut.set(this,null),Tt.set(this,!0),Bt.set(this,{}),qt.set(this,!0),Vt.set(this,[]),Jt.set(this,void 0),Yt.set(this,{}),Gt.set(this,!1),Kt.set(this,null),Qt.set(this,!0),Zt.set(this,void 0),Xt.set(this,""),te.set(this,void 0),ee.set(this,void 0),ne.set(this,{}),se.set(this,null),ie.set(this,null),re.set(this,{}),oe.set(this,{}),ae.set(this,void 0),ce.set(this,!1),le.set(this,void 0),he.set(this,!1),de.set(this,!1),ue.set(this,!1),fe.set(this,void 0),pe.set(this,{}),ge.set(this,null),me.set(this,void 0),ye(this,le,s,"f"),ye(this,ae,t,"f"),ye(this,Rt,e,"f"),ye(this,ee,n,"f"),ye(this,Jt,new gt(this),"f"),this.$0=this[Ae](),this[Ke](),ye(this,Wt,be(this,Wt,"f"),"f"),ye(this,fe,be(this,fe,"f"),"f"),ye(this,me,be(this,me,"f"),"f"),ye(this,te,be(this,te,"f"),"f"),be(this,te,"f").showHiddenOpt=be(this,Ht,"f"),ye(this,Zt,this[ve](),"f")}addHelpOpt(t,e){return ut("[string|boolean] [string]",[t,e],arguments.length),be(this,Kt,"f")&&(this[Oe](be(this,Kt,"f")),ye(this,Kt,null,"f")),!1===t&&void 0===e||(ye(this,Kt,"string"==typeof t?t:"help","f"),this.boolean(be(this,Kt,"f")),this.describe(be(this,Kt,"f"),e||be(this,fe,"f").deferY18nLookup("Show help"))),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(ut("[string|boolean] [string]",[t,e],arguments.length),!1===t&&void 0===e)return this;const n="string"==typeof t?t:be(this,Ht,"f");return this.boolean(n),this.describe(n,e||be(this,fe,"f").deferY18nLookup("Show hidden options")),be(this,te,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return ut("<object|string|array> [string|array]",[t,e],arguments.length),this[Ne](this.alias.bind(this),"alias",t,e),this}array(t){return ut("<array|string>",[t],arguments.length),this[Se]("array",t),this[tn](t),this}boolean(t){return ut("<array|string>",[t],arguments.length),this[Se]("boolean",t),this[tn](t),this}check(t,e){return ut("<function> [boolean]",[t,e],arguments.length),this.middleware(((e,n)=>yt((()=>t(e,n.getOptions())),(n=>(n?("string"==typeof n||n instanceof Error)&&be(this,fe,"f").fail(n.toString(),n):be(this,fe,"f").fail(be(this,le,"f").y18n.__("Argument check failed: %s",t.toString())),e)),(t=>(be(this,fe,"f").fail(t.message?t.message:t.toString(),t),e)))),!1,e),this}choices(t,e){return ut("<object|string|array> [string|array]",[t,e],arguments.length),this[Ne](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(ut("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new Z("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 Z("coerce callback must be provided");return be(this,te,"f").key[t]=!0,be(this,Jt,"f").addCoerceMiddleware(((n,s)=>{let i;return Object.prototype.hasOwnProperty.call(n,t)?yt((()=>(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 Z(t.message)})):n}),t),this}conflicts(t,e){return ut("<string|object> [string|array]",[t,e],arguments.length),be(this,me,"f").conflicts(t,e),this}config(t="config",e,n){return ut("[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||be(this,fe,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((t=>{be(this,te,"f").config[t]=n||!0})),this):(t=It(t,be(this,Rt,"f"),this[Ee]()["deep-merge-config"]||!1,be(this,le,"f")),be(this,te,"f").configObjects=(be(this,te,"f").configObjects||[]).concat(t),this)}completion(t,e,n){return ut("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),"function"==typeof e&&(n=e,e=void 0),ye(this,Lt,t||be(this,Lt,"f")||"completion","f"),e||!1===e||(e="generate completion script"),this.command(be(this,Lt,"f"),e),n&&be(this,zt,"f").registerFunction(n),this}command(t,e,n,s,i,r){return ut("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,s,i,r],arguments.length),be(this,Wt,"f").addHandler(t,e,n,s,i,r),this}commands(t,e,n,s,i,r){return this.command(t,e,n,s,i,r)}commandDir(t,e){ut("<string> [object]",[t,e],arguments.length);const n=be(this,ee,"f")||be(this,le,"f").require;return be(this,Wt,"f").addDirectory(t,n,be(this,le,"f").getCallerFile(),e),this}count(t){return ut("<array|string>",[t],arguments.length),this[Se]("count",t),this[tn](t),this}default(t,e,n){return ut("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(at(t,be(this,le,"f")),be(this,te,"f").defaultDescription[t]=n),"function"==typeof e&&(at(t,be(this,le,"f")),be(this,te,"f").defaultDescription[t]||(be(this,te,"f").defaultDescription[t]=be(this,fe,"f").functionDescription(e)),e=e.call()),this[Me](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 ut("[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),be(this,te,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:s},this}demand(t,e,n){return Array.isArray(e)?(e.forEach((t=>{ot(n,!0,be(this,le,"f")),this.demandOption(t,n)})),e=1/0):"number"!=typeof e&&(n=e,e=1/0),"number"==typeof t?(ot(n,!0,be(this,le,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach((t=>{ot(n,!0,be(this,le,"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 ut("<object|string|array> [string]",[t,e],arguments.length),this[Me](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return ut("<string> [string|boolean]",[t,e],arguments.length),be(this,te,"f").deprecatedOptions[t]=e,this}describe(t,e){return ut("<object|string|array> [string]",[t,e],arguments.length),this[We](t,!0),be(this,fe,"f").describe(t,e),this}detectLocale(t){return ut("<boolean>",[t],arguments.length),ye(this,Tt,t,"f"),this}env(t){return ut("[string|boolean]",[t],arguments.length),!1===t?delete be(this,te,"f").envPrefix:be(this,te,"f").envPrefix=t||"",this}epilogue(t){return ut("<string>",[t],arguments.length),be(this,fe,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return ut("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach((t=>this.example(...t))):be(this,fe,"f").example(t,e),this}exit(t,e){ye(this,Gt,!0,"f"),ye(this,Ut,e,"f"),be(this,qt,"f")&&be(this,le,"f").process.exit(t)}exitProcess(t=!0){return ut("[boolean]",[t],arguments.length),ye(this,qt,t,"f"),this}fail(t){if(ut("<function|boolean>",[t],arguments.length),"boolean"==typeof t&&!1!==t)throw new Z("Invalid first argument. Expected function or boolean 'false'");return be(this,fe,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return ut("<array> [function]",[t,e],arguments.length),e?be(this,zt,"f").getCompletion(t,e):new Promise(((e,n)=>{be(this,zt,"f").getCompletion(t,((t,s)=>{t?n(t):e(s)}))}))}getDemandedOptions(){return ut([],0),be(this,te,"f").demandedOptions}getDemandedCommands(){return ut([],0),be(this,te,"f").demandedCommands}getDeprecatedOptions(){return ut([],0),be(this,te,"f").deprecatedOptions}getDetectLocale(){return be(this,Tt,"f")}getExitProcess(){return be(this,qt,"f")}getGroups(){return Object.assign({},be(this,Yt,"f"),be(this,oe,"f"))}getHelp(){if(ye(this,Gt,!0,"f"),!be(this,fe,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[Qe](be(this,ae,"f"),void 0,void 0,0,!0);if(lt(t))return t.then((()=>be(this,fe,"f").help()))}const t=be(this,Wt,"f").runDefaultBuilderOn(this);if(lt(t))return t.then((()=>be(this,fe,"f").help()))}return Promise.resolve(be(this,fe,"f").help())}getOptions(){return be(this,te,"f")}getStrict(){return be(this,he,"f")}getStrictCommands(){return be(this,de,"f")}getStrictOptions(){return be(this,ue,"f")}global(t,e){return ut("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),!1!==e?be(this,te,"f").local=be(this,te,"f").local.filter((e=>-1===t.indexOf(e))):t.forEach((t=>{be(this,te,"f").local.includes(t)||be(this,te,"f").local.push(t)})),this}group(t,e){ut("<string|array> <string>",[t,e],arguments.length);const n=be(this,oe,"f")[e]||be(this,Yt,"f")[e];be(this,oe,"f")[e]&&delete be(this,oe,"f")[e];const s={};return be(this,Yt,"f")[e]=(n||[]).concat(t).filter((t=>!s[t]&&(s[t]=!0))),this}hide(t){return ut("<string>",[t],arguments.length),be(this,te,"f").hiddenOptions.push(t),this}implies(t,e){return ut("<string|object> [number|string|array]",[t,e],arguments.length),be(this,me,"f").implies(t,e),this}locale(t){return ut("[string]",[t],arguments.length),void 0===t?(this[xe](),be(this,le,"f").y18n.getLocale()):(ye(this,Tt,!1,"f"),be(this,le,"f").y18n.setLocale(t),this)}middleware(t,e,n){return be(this,Jt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return ut("<string|object|array> [number]",[t,e],arguments.length),this[Me](this.nargs.bind(this),"narg",t,e),this}normalize(t){return ut("<array|string>",[t],arguments.length),this[Se]("normalize",t),this}number(t){return ut("<array|string>",[t],arguments.length),this[Se]("number",t),this[tn](t),this}option(t,e){if(ut("<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[tn](t),!be(this,ge,"f")||"version"!==t&&"version"!==(null==e?void 0:e.alias)||this[ke](['"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"),be(this,te,"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&&(be(this,te,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);const i=e.describe||e.description||e.desc,r=be(this,fe,"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){ut("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[je](),void 0===t&&(t=be(this,ae,"f")),"object"==typeof e&&(ye(this,ie,e,"f"),e=n),"function"==typeof e&&(ye(this,se,e,"f"),e=!1),e||ye(this,ae,t,"f"),be(this,se,"f")&&ye(this,qt,!1,"f");const s=this[Qe](t,!!e),i=this.parsed;return be(this,zt,"f").setParsed(this.parsed),lt(s)?s.then((t=>(be(this,se,"f")&&be(this,se,"f").call(this,be(this,Ut,"f"),t,be(this,Xt,"f")),t))).catch((t=>{throw be(this,se,"f")&&be(this,se,"f")(t,this.parsed.argv,be(this,Xt,"f")),t})).finally((()=>{this[Re](),this.parsed=i})):(be(this,se,"f")&&be(this,se,"f").call(this,be(this,Ut,"f"),s,be(this,Xt,"f")),this[Re](),this.parsed=i,s)}parseAsync(t,e,n){const s=this.parse(t,e,n);return lt(s)?s:Promise.resolve(s)}parseSync(t,e,n){const s=this.parse(t,e,n);if(lt(s))throw new Z(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(t){return ut("<object>",[t],arguments.length),ye(this,ne,t,"f"),this}pkgConf(t,e){ut("<string> [string]",[t,e],arguments.length);let n=null;const s=this[Ce](e||be(this,Rt,"f"));return s[t]&&"object"==typeof s[t]&&(n=It(s[t],e||be(this,Rt,"f"),this[Ee]()["deep-merge-config"]||!1,be(this,le,"f")),be(this,te,"f").configObjects=(be(this,te,"f").configObjects||[]).concat(n)),this}positional(t,e){ut("<string> <object>",[t,e],arguments.length);const n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=kt(e,((t,e)=>!("type"===t&&!["string","number","boolean"].includes(e))&&n.includes(t)));const s=be(this,Ft,"f").fullCommands[be(this,Ft,"f").fullCommands.length-1],i=s?be(this,Wt,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return ct(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,be(this,fe,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return ut("[boolean]",[t],arguments.length),ye(this,ce,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 ut("<array|string|object> [number]",[t],arguments.length),"string"==typeof t&&be(this,te,"f").narg[t]||this[Me](this.requiresArg.bind(this),"narg",t,NaN),this}showCompletionScript(t,e){return ut("[string] [string]",[t,e],arguments.length),t=t||this.$0,be(this,Zt,"f").log(be(this,zt,"f").generateCompletionScript(t,e||be(this,Lt,"f")||"completion")),this}showHelp(t){if(ut("[string|function]",[t],arguments.length),ye(this,Gt,!0,"f"),!be(this,fe,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[Qe](be(this,ae,"f"),void 0,void 0,0,!0);if(lt(e))return e.then((()=>{be(this,fe,"f").showHelp(t)})),this}const e=be(this,Wt,"f").runDefaultBuilderOn(this);if(lt(e))return e.then((()=>{be(this,fe,"f").showHelp(t)})),this}return be(this,fe,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return ut("[boolean|string] [string]",[t,e],arguments.length),be(this,fe,"f").showHelpOnFail(t,e),this}showVersion(t){return ut("[string|function]",[t],arguments.length),be(this,fe,"f").showVersion(t),this}skipValidation(t){return ut("<array|string>",[t],arguments.length),this[Se]("skipValidation",t),this}strict(t){return ut("[boolean]",[t],arguments.length),ye(this,he,!1!==t,"f"),this}strictCommands(t){return ut("[boolean]",[t],arguments.length),ye(this,de,!1!==t,"f"),this}strictOptions(t){return ut("[boolean]",[t],arguments.length),ye(this,ue,!1!==t,"f"),this}string(t){return ut("<array|string>",[t],arguments.length),this[Se]("string",t),this[tn](t),this}terminalWidth(){return ut([],0),be(this,le,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return ut("<object>",[t],arguments.length),ye(this,Tt,!1,"f"),be(this,le,"f").y18n.updateLocale(t),this}usage(t,e,n,s){if(ut("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,s],arguments.length),void 0!==e){if(ot(t,null,be(this,le,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,s);throw new Z(".usage() description must start with $0 if being used as alias for .command()")}return be(this,fe,"f").usage(t),this}usageConfiguration(t){return ut("<object>",[t],arguments.length),ye(this,pe,t,"f"),this}version(t,e,n){const s="version";if(ut("[boolean|string] [string] [string]",[t,e,n],arguments.length),be(this,ge,"f")&&(this[Oe](be(this,ge,"f")),be(this,fe,"f").version(void 0),ye(this,ge,null,"f")),0===arguments.length)n=this[$e](),t=s;else if(1===arguments.length){if(!1===t)return this;n=t,t=s}else 2===arguments.length&&(n=e,e=void 0);return ye(this,ge,"string"==typeof t?t:s,"f"),e=e||be(this,fe,"f").deferY18nLookup("Show version number"),be(this,fe,"f").version(n||void 0),this.boolean(be(this,ge,"f")),this.describe(be(this,ge,"f"),e),this}wrap(t){return ut("<number|null|undefined>",[t],arguments.length),be(this,fe,"f").wrap(t),this}[(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,me=new WeakMap,we)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch(t){}return t}[ve](){return{log:(...t)=>{this[Ve]()||console.log(...t),ye(this,Gt,!0,"f"),be(this,Xt,"f").length&&ye(this,Xt,be(this,Xt,"f")+"\n","f"),ye(this,Xt,be(this,Xt,"f")+t.join(" "),"f")},error:(...t)=>{this[Ve]()||console.error(...t),ye(this,Gt,!0,"f"),be(this,Xt,"f").length&&ye(this,Xt,be(this,Xt,"f")+"\n","f"),ye(this,Xt,be(this,Xt,"f")+t.join(" "),"f")}}}[Oe](t){ct(be(this,te,"f")).forEach((e=>{if("configObjects"===e)return;const n=be(this,te,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):"object"==typeof n&&delete n[t]})),delete be(this,fe,"f").getDescriptions()[t]}[ke](t,e,n){be(this,Bt,"f")[n]||(be(this,le,"f").process.emitWarning(t,e),be(this,Bt,"f")[n]=!0)}[je](){be(this,Vt,"f").push({options:be(this,te,"f"),configObjects:be(this,te,"f").configObjects.slice(0),exitProcess:be(this,qt,"f"),groups:be(this,Yt,"f"),strict:be(this,he,"f"),strictCommands:be(this,de,"f"),strictOptions:be(this,ue,"f"),completionCommand:be(this,Lt,"f"),output:be(this,Xt,"f"),exitError:be(this,Ut,"f"),hasOutput:be(this,Gt,"f"),parsed:this.parsed,parseFn:be(this,se,"f"),parseContext:be(this,ie,"f")}),be(this,fe,"f").freeze(),be(this,me,"f").freeze(),be(this,Wt,"f").freeze(),be(this,Jt,"f").freeze()}[Ae](){let t,e="";return t=/\b(node|iojs|electron)(\.exe)?$/.test(be(this,le,"f").process.argv()[0])?be(this,le,"f").process.argv().slice(1,2):be(this,le,"f").process.argv().slice(0,1),e=t.map((t=>{const e=this[Ge](be(this,Rt,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&e.length<t.length?e:t})).join(" ").trim(),be(this,le,"f").getEnv("_")&&be(this,le,"f").getProcessArgvBin()===be(this,le,"f").getEnv("_")&&(e=be(this,le,"f").getEnv("_").replace(`${be(this,le,"f").path.dirname(be(this,le,"f").process.execPath())}/`,"")),e}[Ee](){return be(this,ne,"f")}[_e](){return be(this,pe,"f")}[xe](){if(!be(this,Tt,"f"))return;const t=be(this,le,"f").getEnv("LC_ALL")||be(this,le,"f").getEnv("LC_MESSAGES")||be(this,le,"f").getEnv("LANG")||be(this,le,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[$e](){return this[Ce]().version||"unknown"}[Pe](t){const e=t["--"]?t["--"]:t._;for(let t,n=0;void 0!==(t=e[n]);n++)be(this,le,"f").Parser.looksLikeNumber(t)&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))&&(e[n]=Number(t));return t}[Ce](t){const e=t||"*";if(be(this,re,"f")[e])return be(this,re,"f")[e];let n={};try{let e=t||be(this,le,"f").mainFilename;!t&&be(this,le,"f").path.extname(e)&&(e=be(this,le,"f").path.dirname(e));const s=be(this,le,"f").findUp(e,((t,e)=>e.includes("package.json")?"package.json":void 0));ot(s,void 0,be(this,le,"f")),n=JSON.parse(be(this,le,"f").readFileSync(s,"utf8"))}catch(t){}return be(this,re,"f")[e]=n||{},be(this,re,"f")[e]}[Se](t,e){(e=[].concat(e)).forEach((e=>{e=this[De](e),be(this,te,"f")[t].push(e)}))}[Me](t,e,n,s){this[Ie](t,e,n,s,((t,e,n)=>{be(this,te,"f")[t][e]=n}))}[Ne](t,e,n,s){this[Ie](t,e,n,s,((t,e,n)=>{be(this,te,"f")[t][e]=(be(this,te,"f")[t][e]||[]).concat(n)}))}[Ie](t,e,n,s,i){if(Array.isArray(n))n.forEach((e=>{t(e,s)}));else if((t=>"object"==typeof t)(n))for(const e of ct(n))t(e,n[e]);else i(e,this[De](n),s)}[De](t){return"__proto__"===t?"___proto___":t}[We](t,e){return this[Me](this[We].bind(this),"key",t,e),this}[Re](){var t,e,n,s,i,r,o,a,c,l,h,d;const u=be(this,Vt,"f").pop();let f;ot(u,void 0,be(this,le,"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){ye(t,te,e,"f")}}.value,configObjects:f,exitProcess:{set value(t){ye(e,qt,t,"f")}}.value,groups:{set value(t){ye(n,Yt,t,"f")}}.value,output:{set value(t){ye(s,Xt,t,"f")}}.value,exitError:{set value(t){ye(i,Ut,t,"f")}}.value,hasOutput:{set value(t){ye(r,Gt,t,"f")}}.value,parsed:this.parsed,strict:{set value(t){ye(o,he,t,"f")}}.value,strictCommands:{set value(t){ye(a,de,t,"f")}}.value,strictOptions:{set value(t){ye(c,ue,t,"f")}}.value,completionCommand:{set value(t){ye(l,Lt,t,"f")}}.value,parseFn:{set value(t){ye(h,se,t,"f")}}.value,parseContext:{set value(t){ye(d,ie,t,"f")}}.value}=u),be(this,te,"f").configObjects=f,be(this,fe,"f").unfreeze(),be(this,me,"f").unfreeze(),be(this,Wt,"f").unfreeze(),be(this,Jt,"f").unfreeze()}[Fe](t,e){return yt(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[ze].bind(this),getContext:this[Le].bind(this),getHasOutput:this[He].bind(this),getLoggerInstance:this[Ue].bind(this),getParseContext:this[Te].bind(this),getParserConfiguration:this[Ee].bind(this),getUsageConfiguration:this[_e].bind(this),getUsageInstance:this[Be].bind(this),getValidationInstance:this[qe].bind(this),hasParseCallback:this[Ve].bind(this),isGlobalContext:this[Je].bind(this),postProcess:this[Ye].bind(this),reset:this[Ke].bind(this),runValidation:this[Ze].bind(this),runYargsParserAndExecuteCommands:this[Qe].bind(this),setHasOutput:this[Xe].bind(this)}}[ze](){return be(this,Wt,"f")}[Le](){return be(this,Ft,"f")}[He](){return be(this,Gt,"f")}[Ue](){return be(this,Zt,"f")}[Te](){return be(this,ie,"f")||{}}[Be](){return be(this,fe,"f")}[qe](){return be(this,me,"f")}[Ve](){return!!be(this,se,"f")}[Je](){return be(this,Qt,"f")}[Ye](t,e,n,s){if(n)return t;if(lt(t))return t;e||(t=this[we](t));return(this[Ee]()["parse-positional-numbers"]||void 0===this[Ee]()["parse-positional-numbers"])&&(t=this[Pe](t)),s&&(t=mt(t,this,be(this,Jt,"f").getMiddleware(),!1)),t}[Ke](t={}){ye(this,te,be(this,te,"f")||{},"f");const e={};e.local=be(this,te,"f").local||[],e.configObjects=be(this,te,"f").configObjects||[];const n={};e.local.forEach((e=>{n[e]=!0,(t[e]||[]).forEach((t=>{n[t]=!0}))})),Object.assign(be(this,oe,"f"),Object.keys(be(this,Yt,"f")).reduce(((t,e)=>{const s=be(this,Yt,"f")[e].filter((t=>!(t in n)));return s.length>0&&(t[e]=s),t}),{})),ye(this,Yt,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((t=>{e[t]=(be(this,te,"f")[t]||[]).filter((t=>!n[t]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((t=>{e[t]=kt(be(this,te,"f")[t],(t=>!n[t]))})),e.envPrefix=be(this,te,"f").envPrefix,ye(this,te,e,"f"),ye(this,fe,be(this,fe,"f")?be(this,fe,"f").reset(n):Et(this,be(this,le,"f")),"f"),ye(this,me,be(this,me,"f")?be(this,me,"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=>{St.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===St.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){ut("<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))):(ot(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){ut("<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=Ct(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=kt(o,(e=>!t[e])),c=kt(c,(e=>!t[e])),r};const l=[];return r.freeze=function(){l.push({implied:o,conflicting:c})},r.unfreeze=function(){const t=l.pop();ot(t,void 0,n),({implied:o,conflicting:c}=t)},r}(this,be(this,fe,"f"),be(this,le,"f")),"f"),ye(this,Wt,be(this,Wt,"f")?be(this,Wt,"f").reset():function(t,e,n,s){return new wt(t,e,n,s)}(be(this,fe,"f"),be(this,me,"f"),be(this,Jt,"f"),be(this,le,"f")),"f"),be(this,zt,"f")||ye(this,zt,function(t,e,n,s){return new Pt(t,e,n,s)}(this,be(this,fe,"f"),be(this,Wt,"f"),be(this,le,"f")),"f"),be(this,Jt,"f").reset(),ye(this,Lt,null,"f"),ye(this,Xt,"","f"),ye(this,Ut,null,"f"),ye(this,Gt,!1,"f"),this.parsed=!1,this}[Ge](t,e){return be(this,le,"f").path.relative(t,e)}[Qe](t,e,n,s=0,i=!1){let r=!!n||i;t=t||be(this,ae,"f"),be(this,te,"f").__=be(this,le,"f").y18n.__,be(this,te,"f").configuration=this[Ee]();const o=!!be(this,te,"f").configuration["populate--"],a=Object.assign({},be(this,te,"f").configuration,{"populate--":!0}),c=be(this,le,"f").Parser.detailed(t,Object.assign({},be(this,te,"f"),{configuration:{"parse-positional-numbers":!1,...a}})),l=Object.assign(c.argv,be(this,ie,"f"));let h;const d=c.aliases;let u=!1,f=!1;Object.keys(l).forEach((t=>{t===be(this,Kt,"f")&&l[t]?u=!0:t===be(this,ge,"f")&&l[t]&&(f=!0)})),l.$0=this.$0,this.parsed=c,0===s&&be(this,fe,"f").clearCachedHelpMessage();try{if(this[xe](),e)return this[Ye](l,o,!!n,!1);if(be(this,Kt,"f")){[be(this,Kt,"f")].concat(d[be(this,Kt,"f")]||[]).filter((t=>t.length>1)).includes(""+l._[l._.length-1])&&(l._.pop(),u=!0)}ye(this,Qt,!1,"f");const a=be(this,Wt,"f").getCommands(),p=be(this,zt,"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!==be(this,Lt,"f")){const t=be(this,Wt,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Ye](t,o,!!n,!1)}if(!t&&e!==be(this,Lt,"f")){t=e;break}}!be(this,Wt,"f").hasDefaultCommand()&&be(this,ce,"f")&&t&&!g&&be(this,me,"f").recommendCommands(t,a)}be(this,Lt,"f")&&l._.includes(be(this,Lt,"f"))&&!p&&(be(this,qt,"f")&&jt(!0),this.showCompletionScript(),this.exit(0))}if(be(this,Wt,"f").hasDefaultCommand()&&!g){const t=be(this,Wt,"f").runCommand(null,this,c,0,i,u||f||i);return this[Ye](t,o,!!n,!1)}if(p){be(this,qt,"f")&&jt(!0);const e=(t=[].concat(t)).slice(t.indexOf(`--${be(this,zt,"f").completionKey}`)+1);return be(this,zt,"f").getCompletion(e,((t,e)=>{if(t)throw new Z(t.message);(e||[]).forEach((t=>{be(this,Zt,"f").log(t)})),this.exit(0)})),this[Ye](l,!o,!!n,!1)}if(be(this,Gt,"f")||(u?(be(this,qt,"f")&&jt(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(be(this,qt,"f")&&jt(!0),r=!0,be(this,fe,"f").showVersion("log"),this.exit(0))),!r&&be(this,te,"f").skipValidation.length>0&&(r=Object.keys(l).some((t=>be(this,te,"f").skipValidation.indexOf(t)>=0&&!0===l[t]))),!r){if(c.error)throw new Z(c.error.message);if(!p){const t=this[Ze](d,{},c.error);n||(h=mt(l,this,be(this,Jt,"f").getMiddleware(),!0)),h=this[Fe](t,null!=h?h:l),lt(h)&&!n&&(h=h.then((()=>mt(l,this,be(this,Jt,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof Z))throw t;be(this,fe,"f").fail(t.message,t)}return this[Ye](null!=h?h:l,o,!!n,!0)}[Ze](t,e,n,s){const i={...this.getDemandedOptions()};return r=>{if(n)throw new Z(n.message);be(this,me,"f").nonOptionCount(r),be(this,me,"f").requiredArguments(r,i);let o=!1;be(this,de,"f")&&(o=be(this,me,"f").unknownCommands(r)),be(this,he,"f")&&!o?be(this,me,"f").unknownArguments(r,t,e,!!s):be(this,ue,"f")&&be(this,me,"f").unknownArguments(r,t,{},!1,!1),be(this,me,"f").limitedChoices(r),be(this,me,"f").implications(r),be(this,me,"f").conflicting(r)}}[Xe](){ye(this,Gt,!0,"f")}[tn](t){if("string"==typeof t)be(this,te,"f").key[t]=!0;else for(const e of t)be(this,te,"f").key[e]=!0}}const nn=(sn=rt,(t=[],e=sn.process.cwd(),n)=>{const s=new en(t,e,n,sn);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s});var sn;function rn(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 on=new class{constructor(){rn(this,"_dirPath",void 0),rn(this,"_dockerfile",void 0),rn(this,"_dockerfilePath",void 0),rn(this,"_hasDockerfile",void 0),rn(this,"_name",void 0),rn(this,"_rootPackageJson",void 0),rn(this,"_dockerPackageJson",void 0),rn(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??=on.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"))}},an={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"}},cn={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"}},ln={command:"buildIfNeeded",describe:"Build code if changes are detected",builder:{...an,...cn,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(on.dirPath,"node_modules",".cache","build"),n=t.resolve(e,"last-build");await j.mkdir(e,{recursive:!0});const s=k("sha256"),i=b.execSync("git rev-parse HEAD",{cwd:on.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:on.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=>(hn.some((e=>t.includes(e)))||dn.some((e=>t.endsWith(e))))&&!un.some((e=>t.includes(e))))),s=b.spawn("git",["diff","--",...n],{cwd:on.dirPath});s.stdout?.on("data",(e=>{t.update(e)})),s.on("close",(()=>{e()}))}))}(s);const o=s.digest("hex");try{if(await j.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:on.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 j.writeFile(s,i,"utf8");return!0}(e)}};const hn=["src/","public/"],dn=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","yarn.lock"],un=["test/","tests/","__tests__/","test-fixtures/","package.json"];const fn={command:"optimizeForDockerBuild",describe:"Optimize configuration when building a Docker image",builder:{...an,...cn,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(on.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"),pn(e,s),gn(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 pn(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 gn(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 mn=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 on.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 yn(t){return new Promise((e=>{h.access(t,h.constants.F_OK,(t=>{e(!t)}))}))}async function bn(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}));const c=()=>{try{let t,e;"darwin"===_.platform()?(t=v(`pstree ${r.pid}`).toString(),e=/\d+/):(t=v(`pstree -p ${r.pid}`).toString(),e=/\d+/g);const s=t.split("\n").flatMap((t=>(t.match(e)??[]).map(Number))),i=[];for(const t of s)t>0&&(t===r.pid||i.length>0)&&i.push(t);const o=`kill ${i.join(" ")}`;n?.verbose&&(console.info(t),console.info(`$ ${o}`)),v(o)}catch{}};n?.killOnExit&&process.on("exit",c),r.on("error",(t=>{process.removeListener("exit",c),r.removeAllListeners("close"),i(t)})),r.on("close",((t,e)=>{process.removeListener("exit",c),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 wn=new E,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=await bn(i,void 0,{cwd:on.dirPath,shell:!0,stdio:"inherit",timeout:n?.timeout,killOnExit:!0,verbose:!0});return En(s,r.status,n),r.status??1}function kn(t,e,n=vn){return wn.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 bn(i,void 0,{cwd:on.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=on.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 ",on.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?A.gray:A.cyan)(A.bold(`${e}:`),t))}function En(t,e,n){0===e?console.info(A.green(A.bold("Finished:"),t)):(console.info(A.red(A.bold(`Failed (exit code ${e}): `),t)),!1!==n.exitIfFailed&&process.exit(e??1))}let _n=!1,xn=!1;const $n={...cn},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(mn.litestream(),t)}},Sn={command:"migrate",describe:"Apply migration files to DB",builder:$n,async handler(t){await On(mn.migrate(),t)}},Mn={command:"migrate-dev",describe:"Create a migration file",builder:$n,async handler(t){await On(mn.migrateDev(),t)}},Nn={command:"reset",describe:"Reset DB",builder:$n,async handler(t){await On(mn.reset(),t)}},In={command:"seed",describe:"Populate DB with seed data",builder:$n,async handler(t){await On(mn.seed(),t)}},Dn={command:"studio",describe:"Open Prisma Studio",builder:$n,async handler(t){await On(mn.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},...cn},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${A.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:{...an,...cn},async handler(t){await async function(t){const e=await j.readdir(on.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 wn.promiseAll(),await On("poetry run pip install --upgrade pip",t),await On("poetry install --ansi",t)}if("darwin"===x.platform()){const e=["pstree"];on.hasDockerfile&&e.push("expect"),await kn(`brew install ${e.join(" ")}`,t)}const n=on.packageJson.dependencies??{},s=on.packageJson.devDependencies||{},i=on.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=on.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${t.dirname(on.dockerfilePath)}\n && ${n}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${on.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 process.on("exit",(()=>O(this.stop(),{shell:!0,stdio:"inherit"}))),`docker run --rm -it -p 8080:8080 --name ${on.name} ${t} ${on.name} ${e}`}stop(){return`true $(docker rm -f $(docker container ls -q -f name=${on.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 "${mn.reset()} && yarn build && PORT=${t} pm2-runtime start ecosystem.config.cjs ${e}"\n "${this.waitAndOpenApp(t)}"`}testE2E({playwrightArgs:t="test tests/e2e",startCommand:e=`${mn.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 "${mn.reset()} && yarn build && PORT=${t} pm2-runtime start ecosystem.config.cjs ${e}"\n "${this.waitAndOpenApp(t)}"`}testE2E({playwrightArgs:t="test tests/e2e",startCommand:e=`${mn.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:{...cn,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=on.packageJson.dependencies||{},n=on.packageJson.devDependencies||{};let s;s=e.blitz?Ln:n["@remix-run/dev"]?Tn:(e.express||e.fastify)&&!e["firebase-functions"]||/EXPOSE\s+8080/.test(on.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}`)}}};async function qn(t=8080){await $(t),process.on("exit",(async()=>{await $(t)}))}const Vn={command:"test",describe:"Test project",builder:{...cn,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(!on.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",on.name,"--verbose","run","wb",...e].join(" "),t),process.exit(0)}(e);const n=on.packageJson.dependencies||{},s=on.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=yn(t.join(on.dirPath,"tests","unit")),s=yn(t.join(on.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 wn.promiseAll(),"none"!==e.e2e&&await s){await(on.hasDockerfile?On(`${i.buildDocker("test")}`,e):qn());const t=on.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 await qn(),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 await qn(),void await On(i.testE2E({playwrightArgs:"test tests/e2e --headed"}),e);case"debug":return await qn(),void await On(`PWDEBUG=1 ${i.testE2E({})}`,e);case"generate":return await qn(),void await On(i.testE2E({playwrightArgs:"codegen http://localhost:8080"}),e);case"trace":return void await On("playwright show-trace",e)}throw new Error(`Unknown e2e mode: ${e.e2e}`)}(e)}};const Jn={command:"typecheck",describe:"Run type checking",builder:{...cn},async handler(t){if(process.exitCode=await On("tsc --noEmit --Pretty",t),0!==process.exitCode){(JSON.parse(await j.readFile("package.json","utf8")).dependencies||{}).blitz&&console.info(A.yellow('Please try "yarn gen-code" if you face unknown type errors.'))}}},Yn={...Jn,command:"tc"};var Gn;await nn((Gn=process.argv,Gn.slice(Q()+1))).scriptName("wb").options(an).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),on.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(on.dirPath,e)})})).command(ln).command(fn).command(Pn).command(Wn).command(Rn).command(Bn).command(Vn).command(Jn).command(Yn).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
33
+ var T,B,q;const V=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,J=null!==(B=null===(T=null===process||void 0===process?void 0:process.versions)||void 0===T?void 0:T.node)&&void 0!==B?B:null===(q=null===process||void 0===process?void 0:process.version)||void 0===q?void 0:q.slice(1);if(J){if(Number(J.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 Y=process?process.env:{},G=new class{constructor(t){L=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.__||L.format,g={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},m=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,y=new RegExp("^--"+o["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach((function(t){const e="object"==typeof t?t.key:t,n=Object.keys(t).map((function(t){return{boolean:"bools",string:"strings",number:"numbers"}[t]})).filter(Boolean).pop();n&&(g[n][e]=!0),g.arrays[e]=!0,g.keys.push(e)})),[].concat(n.boolean||[]).filter(Boolean).forEach((function(t){g.bools[t]=!0,g.keys.push(t)})),[].concat(n.string||[]).filter(Boolean).forEach((function(t){g.strings[t]=!0,g.keys.push(t)})),[].concat(n.number||[]).filter(Boolean).forEach((function(t){g.numbers[t]=!0,g.keys.push(t)})),[].concat(n.count||[]).filter(Boolean).forEach((function(t){g.counts[t]=!0,g.keys.push(t)})),[].concat(n.normalize||[]).filter(Boolean).forEach((function(t){g.normalize[t]=!0,g.keys.push(t)})),"object"==typeof n.narg&&Object.entries(n.narg).forEach((([t,e])=>{"number"==typeof e&&(g.nargs[t]=e,g.keys.push(t))})),"object"==typeof n.coerce&&Object.entries(n.coerce).forEach((([t,e])=>{"function"==typeof e&&(g.coercions[t]=e,g.keys.push(t))})),void 0!==n.config&&(Array.isArray(n.config)||"string"==typeof n.config?[].concat(n.config).filter(Boolean).forEach((function(t){g.configs[t]=!0})):"object"==typeof n.config&&Object.entries(n.config).forEach((([t,e])=>{"boolean"!=typeof e&&"function"!=typeof e||(g.configs[t]=e)}))),function(...t){t.forEach((function(t){Object.keys(t||{}).forEach((function(t){g.aliases[t]||(g.aliases[t]=[].concat(r[t]||[]),g.aliases[t].concat(t).forEach((function(e){if(/-/.test(e)&&o["camel-case-expansion"]){const n=W(e);n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].concat(t).forEach((function(e){if(e.length>1&&/[A-Z]/.test(e)&&o["camel-case-expansion"]){const n=R(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 W(t)})).join(".");_(t,e)}const s=x(t,e,n),r=t.split(".");if(N(v,r,s),g.aliases[t]&&g.aliases[t].forEach((function(t){const e=t.split(".");N(v,e,s)})),r.length>1&&o["dot-notation"]&&(g.aliases[r[0]]||[]).forEach((function(e){let n=e.split(".");const i=[].concat(r);i.shift(),n=n.concat(i),(g.aliases[t]||[]).includes(n.join("."))||N(v,n,s)})),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?L.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=H()),I(t,g.normalize)&&I(t,g.arrays)&&(s=Array.isArray(e)?e.map((t=>L.normalize(t))):L.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}`)))||!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=L.env();Object.keys(s).forEach((function(i){if(""===n||0===i.lastIndexOf(n,0)){const r=i.split("__").map((function(t,e){return 0===e&&(t=t.substring(n.length)),W(t)}));(e&&g.configs[r.join(".")]||!e)&&!M(t,r)&&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=U(t),"object"==typeof s&&void 0===s[t]&&(s[t]={}),"object"!=typeof s[t]||Array.isArray(s[t])?(Array.isArray(s[t])?s[t].push({}):s[t]=[s[t],{}],s=s[t][s[t].length-1]):s=s[t]}));const i=U(e[e.length-1]),r=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===H()?s[i]=H(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 D(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),!D(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&&D(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=z.BOOLEAN;return I(t,g.strings)?e=z.STRING:I(t,g.numbers)?e=z.NUMBER:I(t,g.bools)?e=z.BOOLEAN:I(t,g.arrays)&&(e=z.ARRAY),e}(t),{[z.BOOLEAN]:!0,[z.STRING]:"",[z.NUMBER]:void 0,[z.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=L.resolve(L.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=L.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=>W(t))).join(".")],delete v[t]})),{aliases:Object.assign({},g.aliases),argv:Object.assign(O,v),configuration:o,defaulted:Object.assign({},f),error:b,newAliases:Object.assign({},u)}}}({cwd:process.cwd,env:()=>Y,format:g,normalize:s,resolve:e,require:t=>{if("undefined"!=typeof require)return require(t);if(t.match(/\.json$/))return JSON.parse(f(t,"utf8"));throw Error("only .json config files are supported in ESM")}}),K=function(t,e){return G.parse(t.slice(),e).argv};function Q(){return process.versions.electron&&!process.defaultApp?0:1}K.detailed=function(t,e){return G.parse(t.slice(),e)},K.camelCase=W,K.decamelize=R,K.looksLikeNumber=F;class Z extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,Z)}}var X={fs:{readFileSync:f,writeFile:p},format:g,resolve:e,exists:t=>{try{return d(t).isFile()}catch(t){return!1}}};let tt;class et{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(),tt.format.apply(tt.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),tt.format.apply(tt.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);tt.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{tt.fs.readFileSync&&(t=JSON.parse(tt.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=tt.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const s=tt.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(t){return tt.exists(t)}}const nt="loading a directory of commands is not supported yet for ESM";let st;try{st=y(import.meta.url)}catch(t){st=process.cwd()}var it,rt={assert:{notStrictEqual:c,strictEqual:l},cliui:function(t){return function(t,e){return M=e,new C({width:(null==t?void 0:t.width)||("object"==typeof process&&process.stdout&&process.stdout.columns?process.stdout.columns:80),wrap:null==t?void 0:t.wrap})}(t,{stringWidth:t=>[...t].length,stripAnsi:I,wrap:D})},findUp:function(t,s){let i,r=e(".",t);for(d(r).isDirectory()||(r=n(r));;){if(i=s(r,u(r)),i)return e(r,i);if(r=n(i=r),i===r)break}},getEnv:t=>process.env[t],inspect:m,getCallerFile:()=>{throw new Z(nt)},getProcessArgvBin:function(){return process.argv[Q()]},mainFilename:st.substring(0,st.lastIndexOf("node_modules"))||process.cwd(),Parser:K,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 Z("require is not supported by ESM")},requireDirectory:()=>{throw new Z(nt)},stringWidth:t=>[...t].length,y18n:(it={directory:e(st,"../../../locales"),updateFiles:!1},function(t,e){tt=e;const n=new et(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}}(it,X))};function ot(t,e,n,s){n.assert.notStrictEqual(t,e,s)}function at(t,e){e.assert.strictEqual(typeof t,"string")}function ct(t){return Object.keys(t)}function lt(t){return!!t&&!!t.then&&"function"==typeof t.then}function ht(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 dt=["first","second","third","fourth","fifth","sixth"];function ut(t,e,n){try{let s=0;const[i,r,o]="object"==typeof t?[{demanded:[],optional:[]},t,e]:[ht(`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 Z(`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 Z(`Too many arguments provided. Expected max ${l} but received ${c}.`);i.demanded.forEach((t=>{const e=ft(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&pt(e,t.cmd,s),s+=1})),i.optional.forEach((t=>{if(0===a.length)return;const e=ft(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&pt(e,t.cmd,s),s+=1}))}catch(t){console.warn(t.stack)}}function ft(t){return Array.isArray(t)?"array":null===t?"null":typeof t}function pt(t,e,n){throw new Z(`Invalid ${dt[n]||"manyith"} argument. Expected ${e.join(" or ")} but received ${t}.`)}class gt{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,s=!1){if(ut("<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 mt(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(lt(t))return t.then((t=>Promise.all([t,n(t,e)]))).then((([t,e])=>Object.assign(t,e)));{const s=n(t,e);return lt(s)?s.then((e=>Object.assign(t,e))):Object.assign(t,s)}}),t)}function yt(t,e,n=(t=>{throw t})){try{const n="function"==typeof t?t():t;return lt(n)?n.then((t=>e(t))):e(n)}catch(t){return n(t)}}const bt=/(^\*)|(^\$0)/;class wt{constructor(t,e,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,s){"boolean"!=typeof(s=s||{}).recurse&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);const i="function"==typeof s.visit?s.visit:t=>t;s.visit=(t,e,n)=>{const s=i(t,e,n);if(s){if(this.requireCache.has(e))return s;this.requireCache.add(e),this.addHandler(s)}return s},this.shim.requireDirectory({require:e,filename:n},t,s)}addHandler(t,e,n,s,i,r){let o=[];const a=function(t){return t?t.map((t=>(t.applyBeforeValidation=!1,t))):[]}(i);if(s=s||(()=>{}),Array.isArray(t))if(function(t){return t.every((t=>"string"==typeof t))}(t))[t,...o]=t;else for(const e of t)this.addHandler(e);else{if(function(t){return"object"==typeof t&&!Array.isArray(t)}(t)){let e=Array.isArray(t.command)||"string"==typeof t.command?t.command:this.moduleName(t);return t.aliases&&(e=[].concat(e).concat(t.aliases)),void this.addHandler(e,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated)}if(vt(n))return void this.addHandler([t].concat(o),e,n.builder,n.handler,n.middlewares,n.deprecated)}if("string"==typeof t){const i=ht(t);o=o.map((t=>ht(t).cmd));let c=!1;const l=[i.cmd].concat(o).filter((t=>!bt.test(t)||(c=!0,!1)));0===l.length&&c&&l.push("$0"),c&&(i.cmd=l[0],o=l.slice(1),t=t.replace(bt,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 lt(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(Ot(c)){n.getInternalMethods().getUsageInstance().freeze();const h=c(n.getInternalMethods().reset(s),a);if(lt(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 lt(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=bt.test(e.original)?e.original.replace(bt,"").trim():e.original,s=t.filter((t=>!bt.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=yt(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=yt(n=mt(n,r,o,!1),(t=>{const n=e.handler(t);return lt(n)?n.then((()=>t)):t})),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),lt(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=mt(n,o,c,!0);return lt(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=ht(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=bt.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(Ot(e))return e(t,!0);vt(e)||Object.keys(e).forEach((n=>{t.option(n,e[n])}))}moduleName(t){const e=function(t){if("undefined"==typeof require)return null;for(let e,n=0,s=Object.keys(require.cache);n<s.length;n++)if(e=require.cache[s[n]],e.exports===t)return e;return null}(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(const s of[t,e,n]){if("string"==typeof s||!1===s)return s;ot(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();ot(t,void 0,this.shim),({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t)}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function vt(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function Ot(t){return"function"==typeof t}function kt(t={},e=(()=>!0)){const n={};return ct(t).forEach((s=>{e(s,t[s])&&(n[s]=t[s])})),n}function jt(t){"undefined"!=typeof process&&[process.stdout,process.stderr].forEach((e=>{const n=e;n._handle&&n.isTTY&&"function"==typeof n._handle.setBlocking&&n._handle.setBlocking(t)}))}function At(t){return"boolean"==typeof t}function Et(t,e){const n=e.y18n.__,s={},i=[];s.failFn=function(t){i.push(t)};let r=null,o=null,a=!0;s.showHelpOnFail=function(e=!0,n){const[i,c]="string"==typeof e?[!0,e]:[e,n];return t.getInternalMethods().isGlobalContext()&&(o=c),r=c,a=i,s};let c=!1;s.fail=function(e,n){const l=t.getInternalMethods().getLoggerInstance();if(!i.length){if(t.getExitProcess()&&jt(!0),!c){c=!0,a&&(t.showHelp("error"),l.error()),(e||n)&&l.error(e||n);const s=r||o;s&&((e||n)&&l.error(""),l.error(s))}if(n=n||new Z(e),t.getExitProcess())return t.exit(1);if(t.getInternalMethods().hasParseCallback())return t.exit(1,n);throw n}for(let t=i.length-1;t>=0;--t){const r=i[t];if(At(r)){if(n)throw n;if(e)throw Error(e)}else r(e,n,s)}};let l=[],h=!1;s.usage=(t,e)=>null===t?(h=!0,l=[],s):(h=!1,l.push([t,e||""]),s),s.getUsage=()=>l,s.getUsageDisabled=()=>h,s.getPositionalGroupName=()=>n("Positionals:");let d=[];s.example=(t,e)=>{d.push([t,e||""])};let u=[];s.command=function(t,e,n,s,i=!1){n&&(u=u.map((t=>(t[2]=!1,t)))),u.push([t,e||"",n,s,i])},s.getCommands=()=>u;let f={};s.describe=function(t,e){Array.isArray(t)?t.forEach((t=>{s.describe(t,e)})):"object"==typeof t?Object.keys(t).forEach((e=>{s.describe(e,t[e])})):f[t]=e},s.getDescriptions=()=>f;let p=[];s.epilog=t=>{p.push(t)};let g,m=!1;s.wrap=t=>{m=!0,g=t},s.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(m||(g=function(){const t=80;return e.process.stdColumns?Math.min(t,e.process.stdColumns):t}(),m=!0),g);const y="__yargsString__:";function b(t,n,s){let i=0;return Array.isArray(t)||(t=Object.values(t).map((t=>[t]))),t.forEach((t=>{i=Math.max(e.stringWidth(s?`${s} ${$t(t[0])}`:$t(t[0]))+xt(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($t(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,_t(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:$t(i),padding:[0,2,0,2+xt(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=kt(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 _t(t){return"object"==typeof t}function xt(t){return _t(t)?t.indentation:0}function $t(t){return _t(t)?t.text:t}class Pt{constructor(t,e,n,s){var i,r,o;this.yargs=t,this.usage=e,this.command=n,this.shim=s,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=null!==(o=(null===(i=this.shim.getEnv("SHELL"))||void 0===i?void 0:i.includes("zsh"))||(null===(r=this.shim.getEnv("ZSH_NAME"))||void 0===r?void 0:r.includes("zsh")))&&void 0!==o&&o}defaultCompletion(t,e,n,s){const i=this.command.getCommandHandlers();for(let e=0,n=t.length;e<n;++e)if(i[t[e]]&&i[t[e]].builder){const n=i[t[e]].builder;if(Ot(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=ht(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(ot(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const t=this.customCompletionFunction(n,e);return lt(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 lt(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 Ct(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 St=["$0","--","_"];let Mt,Nt=[];function It(t,e,n,s){Mt=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 Mt.path.resolve(t,e)}(e,t.extends);else try{r=require.resolve(t.extends)}catch(e){return t}!function(t){if(Nt.indexOf(t)>-1)throw new Z(`Circular extended configurations: '${t}'.`)}(r),Nt.push(r),i=s?JSON.parse(Mt.readFileSync(r,"utf8")):require(t.extends),delete t.extends,i=It(i,Mt.path.dirname(r),n,Mt)}return Nt=[],n?Dt(i,t):Object.assign({},i,t)}function Dt(t,e){const n={};function s(t){return t&&"object"==typeof t&&!Array.isArray(t)}Object.assign(n,t);for(const i of Object.keys(e))s(e[i])&&s(n[i])?n[i]=Dt(t[i],e[i]):n[i]=e[i];return n}var 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,ye=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},be=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 we=Symbol("copyDoubleDash"),ve=Symbol("copyDoubleDash"),Oe=Symbol("deleteFromParserHintObject"),ke=Symbol("emitWarning"),je=Symbol("freeze"),Ae=Symbol("getDollarZero"),Ee=Symbol("getParserConfiguration"),_e=Symbol("getUsageConfiguration"),xe=Symbol("guessLocale"),$e=Symbol("guessVersion"),Pe=Symbol("parsePositionalNumbers"),Ce=Symbol("pkgUp"),Se=Symbol("populateParserHintArray"),Me=Symbol("populateParserHintSingleValueDictionary"),Ne=Symbol("populateParserHintArrayDictionary"),Ie=Symbol("populateParserHintDictionary"),De=Symbol("sanitizeKey"),We=Symbol("setKey"),Re=Symbol("unfreeze"),Fe=Symbol("validateAsync"),ze=Symbol("getCommandInstance"),Le=Symbol("getContext"),He=Symbol("getHasOutput"),Ue=Symbol("getLoggerInstance"),Te=Symbol("getParseContext"),Be=Symbol("getUsageInstance"),qe=Symbol("getValidationInstance"),Ve=Symbol("hasParseCallback"),Je=Symbol("isGlobalContext"),Ye=Symbol("postProcess"),Ge=Symbol("rebase"),Ke=Symbol("reset"),Qe=Symbol("runYargsParserAndExecuteCommands"),Ze=Symbol("runValidation"),Xe=Symbol("setHasOutput"),tn=Symbol("kTrackManuallySetKeys");class en{constructor(t=[],e,n,s){this.customScriptName=!1,this.parsed=!1,Wt.set(this,void 0),Rt.set(this,void 0),Ft.set(this,{commands:[],fullCommands:[]}),zt.set(this,null),Lt.set(this,null),Ht.set(this,"show-hidden"),Ut.set(this,null),Tt.set(this,!0),Bt.set(this,{}),qt.set(this,!0),Vt.set(this,[]),Jt.set(this,void 0),Yt.set(this,{}),Gt.set(this,!1),Kt.set(this,null),Qt.set(this,!0),Zt.set(this,void 0),Xt.set(this,""),te.set(this,void 0),ee.set(this,void 0),ne.set(this,{}),se.set(this,null),ie.set(this,null),re.set(this,{}),oe.set(this,{}),ae.set(this,void 0),ce.set(this,!1),le.set(this,void 0),he.set(this,!1),de.set(this,!1),ue.set(this,!1),fe.set(this,void 0),pe.set(this,{}),ge.set(this,null),me.set(this,void 0),ye(this,le,s,"f"),ye(this,ae,t,"f"),ye(this,Rt,e,"f"),ye(this,ee,n,"f"),ye(this,Jt,new gt(this),"f"),this.$0=this[Ae](),this[Ke](),ye(this,Wt,be(this,Wt,"f"),"f"),ye(this,fe,be(this,fe,"f"),"f"),ye(this,me,be(this,me,"f"),"f"),ye(this,te,be(this,te,"f"),"f"),be(this,te,"f").showHiddenOpt=be(this,Ht,"f"),ye(this,Zt,this[ve](),"f")}addHelpOpt(t,e){return ut("[string|boolean] [string]",[t,e],arguments.length),be(this,Kt,"f")&&(this[Oe](be(this,Kt,"f")),ye(this,Kt,null,"f")),!1===t&&void 0===e||(ye(this,Kt,"string"==typeof t?t:"help","f"),this.boolean(be(this,Kt,"f")),this.describe(be(this,Kt,"f"),e||be(this,fe,"f").deferY18nLookup("Show help"))),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(ut("[string|boolean] [string]",[t,e],arguments.length),!1===t&&void 0===e)return this;const n="string"==typeof t?t:be(this,Ht,"f");return this.boolean(n),this.describe(n,e||be(this,fe,"f").deferY18nLookup("Show hidden options")),be(this,te,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return ut("<object|string|array> [string|array]",[t,e],arguments.length),this[Ne](this.alias.bind(this),"alias",t,e),this}array(t){return ut("<array|string>",[t],arguments.length),this[Se]("array",t),this[tn](t),this}boolean(t){return ut("<array|string>",[t],arguments.length),this[Se]("boolean",t),this[tn](t),this}check(t,e){return ut("<function> [boolean]",[t,e],arguments.length),this.middleware(((e,n)=>yt((()=>t(e,n.getOptions())),(n=>(n?("string"==typeof n||n instanceof Error)&&be(this,fe,"f").fail(n.toString(),n):be(this,fe,"f").fail(be(this,le,"f").y18n.__("Argument check failed: %s",t.toString())),e)),(t=>(be(this,fe,"f").fail(t.message?t.message:t.toString(),t),e)))),!1,e),this}choices(t,e){return ut("<object|string|array> [string|array]",[t,e],arguments.length),this[Ne](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(ut("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new Z("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 Z("coerce callback must be provided");return be(this,te,"f").key[t]=!0,be(this,Jt,"f").addCoerceMiddleware(((n,s)=>{let i;return Object.prototype.hasOwnProperty.call(n,t)?yt((()=>(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 Z(t.message)})):n}),t),this}conflicts(t,e){return ut("<string|object> [string|array]",[t,e],arguments.length),be(this,me,"f").conflicts(t,e),this}config(t="config",e,n){return ut("[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||be(this,fe,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((t=>{be(this,te,"f").config[t]=n||!0})),this):(t=It(t,be(this,Rt,"f"),this[Ee]()["deep-merge-config"]||!1,be(this,le,"f")),be(this,te,"f").configObjects=(be(this,te,"f").configObjects||[]).concat(t),this)}completion(t,e,n){return ut("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),"function"==typeof e&&(n=e,e=void 0),ye(this,Lt,t||be(this,Lt,"f")||"completion","f"),e||!1===e||(e="generate completion script"),this.command(be(this,Lt,"f"),e),n&&be(this,zt,"f").registerFunction(n),this}command(t,e,n,s,i,r){return ut("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,s,i,r],arguments.length),be(this,Wt,"f").addHandler(t,e,n,s,i,r),this}commands(t,e,n,s,i,r){return this.command(t,e,n,s,i,r)}commandDir(t,e){ut("<string> [object]",[t,e],arguments.length);const n=be(this,ee,"f")||be(this,le,"f").require;return be(this,Wt,"f").addDirectory(t,n,be(this,le,"f").getCallerFile(),e),this}count(t){return ut("<array|string>",[t],arguments.length),this[Se]("count",t),this[tn](t),this}default(t,e,n){return ut("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(at(t,be(this,le,"f")),be(this,te,"f").defaultDescription[t]=n),"function"==typeof e&&(at(t,be(this,le,"f")),be(this,te,"f").defaultDescription[t]||(be(this,te,"f").defaultDescription[t]=be(this,fe,"f").functionDescription(e)),e=e.call()),this[Me](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 ut("[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),be(this,te,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:s},this}demand(t,e,n){return Array.isArray(e)?(e.forEach((t=>{ot(n,!0,be(this,le,"f")),this.demandOption(t,n)})),e=1/0):"number"!=typeof e&&(n=e,e=1/0),"number"==typeof t?(ot(n,!0,be(this,le,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach((t=>{ot(n,!0,be(this,le,"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 ut("<object|string|array> [string]",[t,e],arguments.length),this[Me](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return ut("<string> [string|boolean]",[t,e],arguments.length),be(this,te,"f").deprecatedOptions[t]=e,this}describe(t,e){return ut("<object|string|array> [string]",[t,e],arguments.length),this[We](t,!0),be(this,fe,"f").describe(t,e),this}detectLocale(t){return ut("<boolean>",[t],arguments.length),ye(this,Tt,t,"f"),this}env(t){return ut("[string|boolean]",[t],arguments.length),!1===t?delete be(this,te,"f").envPrefix:be(this,te,"f").envPrefix=t||"",this}epilogue(t){return ut("<string>",[t],arguments.length),be(this,fe,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return ut("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach((t=>this.example(...t))):be(this,fe,"f").example(t,e),this}exit(t,e){ye(this,Gt,!0,"f"),ye(this,Ut,e,"f"),be(this,qt,"f")&&be(this,le,"f").process.exit(t)}exitProcess(t=!0){return ut("[boolean]",[t],arguments.length),ye(this,qt,t,"f"),this}fail(t){if(ut("<function|boolean>",[t],arguments.length),"boolean"==typeof t&&!1!==t)throw new Z("Invalid first argument. Expected function or boolean 'false'");return be(this,fe,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return ut("<array> [function]",[t,e],arguments.length),e?be(this,zt,"f").getCompletion(t,e):new Promise(((e,n)=>{be(this,zt,"f").getCompletion(t,((t,s)=>{t?n(t):e(s)}))}))}getDemandedOptions(){return ut([],0),be(this,te,"f").demandedOptions}getDemandedCommands(){return ut([],0),be(this,te,"f").demandedCommands}getDeprecatedOptions(){return ut([],0),be(this,te,"f").deprecatedOptions}getDetectLocale(){return be(this,Tt,"f")}getExitProcess(){return be(this,qt,"f")}getGroups(){return Object.assign({},be(this,Yt,"f"),be(this,oe,"f"))}getHelp(){if(ye(this,Gt,!0,"f"),!be(this,fe,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[Qe](be(this,ae,"f"),void 0,void 0,0,!0);if(lt(t))return t.then((()=>be(this,fe,"f").help()))}const t=be(this,Wt,"f").runDefaultBuilderOn(this);if(lt(t))return t.then((()=>be(this,fe,"f").help()))}return Promise.resolve(be(this,fe,"f").help())}getOptions(){return be(this,te,"f")}getStrict(){return be(this,he,"f")}getStrictCommands(){return be(this,de,"f")}getStrictOptions(){return be(this,ue,"f")}global(t,e){return ut("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),!1!==e?be(this,te,"f").local=be(this,te,"f").local.filter((e=>-1===t.indexOf(e))):t.forEach((t=>{be(this,te,"f").local.includes(t)||be(this,te,"f").local.push(t)})),this}group(t,e){ut("<string|array> <string>",[t,e],arguments.length);const n=be(this,oe,"f")[e]||be(this,Yt,"f")[e];be(this,oe,"f")[e]&&delete be(this,oe,"f")[e];const s={};return be(this,Yt,"f")[e]=(n||[]).concat(t).filter((t=>!s[t]&&(s[t]=!0))),this}hide(t){return ut("<string>",[t],arguments.length),be(this,te,"f").hiddenOptions.push(t),this}implies(t,e){return ut("<string|object> [number|string|array]",[t,e],arguments.length),be(this,me,"f").implies(t,e),this}locale(t){return ut("[string]",[t],arguments.length),void 0===t?(this[xe](),be(this,le,"f").y18n.getLocale()):(ye(this,Tt,!1,"f"),be(this,le,"f").y18n.setLocale(t),this)}middleware(t,e,n){return be(this,Jt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return ut("<string|object|array> [number]",[t,e],arguments.length),this[Me](this.nargs.bind(this),"narg",t,e),this}normalize(t){return ut("<array|string>",[t],arguments.length),this[Se]("normalize",t),this}number(t){return ut("<array|string>",[t],arguments.length),this[Se]("number",t),this[tn](t),this}option(t,e){if(ut("<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[tn](t),!be(this,ge,"f")||"version"!==t&&"version"!==(null==e?void 0:e.alias)||this[ke](['"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"),be(this,te,"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&&(be(this,te,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);const i=e.describe||e.description||e.desc,r=be(this,fe,"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){ut("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[je](),void 0===t&&(t=be(this,ae,"f")),"object"==typeof e&&(ye(this,ie,e,"f"),e=n),"function"==typeof e&&(ye(this,se,e,"f"),e=!1),e||ye(this,ae,t,"f"),be(this,se,"f")&&ye(this,qt,!1,"f");const s=this[Qe](t,!!e),i=this.parsed;return be(this,zt,"f").setParsed(this.parsed),lt(s)?s.then((t=>(be(this,se,"f")&&be(this,se,"f").call(this,be(this,Ut,"f"),t,be(this,Xt,"f")),t))).catch((t=>{throw be(this,se,"f")&&be(this,se,"f")(t,this.parsed.argv,be(this,Xt,"f")),t})).finally((()=>{this[Re](),this.parsed=i})):(be(this,se,"f")&&be(this,se,"f").call(this,be(this,Ut,"f"),s,be(this,Xt,"f")),this[Re](),this.parsed=i,s)}parseAsync(t,e,n){const s=this.parse(t,e,n);return lt(s)?s:Promise.resolve(s)}parseSync(t,e,n){const s=this.parse(t,e,n);if(lt(s))throw new Z(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(t){return ut("<object>",[t],arguments.length),ye(this,ne,t,"f"),this}pkgConf(t,e){ut("<string> [string]",[t,e],arguments.length);let n=null;const s=this[Ce](e||be(this,Rt,"f"));return s[t]&&"object"==typeof s[t]&&(n=It(s[t],e||be(this,Rt,"f"),this[Ee]()["deep-merge-config"]||!1,be(this,le,"f")),be(this,te,"f").configObjects=(be(this,te,"f").configObjects||[]).concat(n)),this}positional(t,e){ut("<string> <object>",[t,e],arguments.length);const n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=kt(e,((t,e)=>!("type"===t&&!["string","number","boolean"].includes(e))&&n.includes(t)));const s=be(this,Ft,"f").fullCommands[be(this,Ft,"f").fullCommands.length-1],i=s?be(this,Wt,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return ct(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,be(this,fe,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return ut("[boolean]",[t],arguments.length),ye(this,ce,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 ut("<array|string|object> [number]",[t],arguments.length),"string"==typeof t&&be(this,te,"f").narg[t]||this[Me](this.requiresArg.bind(this),"narg",t,NaN),this}showCompletionScript(t,e){return ut("[string] [string]",[t,e],arguments.length),t=t||this.$0,be(this,Zt,"f").log(be(this,zt,"f").generateCompletionScript(t,e||be(this,Lt,"f")||"completion")),this}showHelp(t){if(ut("[string|function]",[t],arguments.length),ye(this,Gt,!0,"f"),!be(this,fe,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[Qe](be(this,ae,"f"),void 0,void 0,0,!0);if(lt(e))return e.then((()=>{be(this,fe,"f").showHelp(t)})),this}const e=be(this,Wt,"f").runDefaultBuilderOn(this);if(lt(e))return e.then((()=>{be(this,fe,"f").showHelp(t)})),this}return be(this,fe,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return ut("[boolean|string] [string]",[t,e],arguments.length),be(this,fe,"f").showHelpOnFail(t,e),this}showVersion(t){return ut("[string|function]",[t],arguments.length),be(this,fe,"f").showVersion(t),this}skipValidation(t){return ut("<array|string>",[t],arguments.length),this[Se]("skipValidation",t),this}strict(t){return ut("[boolean]",[t],arguments.length),ye(this,he,!1!==t,"f"),this}strictCommands(t){return ut("[boolean]",[t],arguments.length),ye(this,de,!1!==t,"f"),this}strictOptions(t){return ut("[boolean]",[t],arguments.length),ye(this,ue,!1!==t,"f"),this}string(t){return ut("<array|string>",[t],arguments.length),this[Se]("string",t),this[tn](t),this}terminalWidth(){return ut([],0),be(this,le,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return ut("<object>",[t],arguments.length),ye(this,Tt,!1,"f"),be(this,le,"f").y18n.updateLocale(t),this}usage(t,e,n,s){if(ut("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,s],arguments.length),void 0!==e){if(ot(t,null,be(this,le,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,s);throw new Z(".usage() description must start with $0 if being used as alias for .command()")}return be(this,fe,"f").usage(t),this}usageConfiguration(t){return ut("<object>",[t],arguments.length),ye(this,pe,t,"f"),this}version(t,e,n){const s="version";if(ut("[boolean|string] [string] [string]",[t,e,n],arguments.length),be(this,ge,"f")&&(this[Oe](be(this,ge,"f")),be(this,fe,"f").version(void 0),ye(this,ge,null,"f")),0===arguments.length)n=this[$e](),t=s;else if(1===arguments.length){if(!1===t)return this;n=t,t=s}else 2===arguments.length&&(n=e,e=void 0);return ye(this,ge,"string"==typeof t?t:s,"f"),e=e||be(this,fe,"f").deferY18nLookup("Show version number"),be(this,fe,"f").version(n||void 0),this.boolean(be(this,ge,"f")),this.describe(be(this,ge,"f"),e),this}wrap(t){return ut("<number|null|undefined>",[t],arguments.length),be(this,fe,"f").wrap(t),this}[(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,me=new WeakMap,we)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch(t){}return t}[ve](){return{log:(...t)=>{this[Ve]()||console.log(...t),ye(this,Gt,!0,"f"),be(this,Xt,"f").length&&ye(this,Xt,be(this,Xt,"f")+"\n","f"),ye(this,Xt,be(this,Xt,"f")+t.join(" "),"f")},error:(...t)=>{this[Ve]()||console.error(...t),ye(this,Gt,!0,"f"),be(this,Xt,"f").length&&ye(this,Xt,be(this,Xt,"f")+"\n","f"),ye(this,Xt,be(this,Xt,"f")+t.join(" "),"f")}}}[Oe](t){ct(be(this,te,"f")).forEach((e=>{if("configObjects"===e)return;const n=be(this,te,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):"object"==typeof n&&delete n[t]})),delete be(this,fe,"f").getDescriptions()[t]}[ke](t,e,n){be(this,Bt,"f")[n]||(be(this,le,"f").process.emitWarning(t,e),be(this,Bt,"f")[n]=!0)}[je](){be(this,Vt,"f").push({options:be(this,te,"f"),configObjects:be(this,te,"f").configObjects.slice(0),exitProcess:be(this,qt,"f"),groups:be(this,Yt,"f"),strict:be(this,he,"f"),strictCommands:be(this,de,"f"),strictOptions:be(this,ue,"f"),completionCommand:be(this,Lt,"f"),output:be(this,Xt,"f"),exitError:be(this,Ut,"f"),hasOutput:be(this,Gt,"f"),parsed:this.parsed,parseFn:be(this,se,"f"),parseContext:be(this,ie,"f")}),be(this,fe,"f").freeze(),be(this,me,"f").freeze(),be(this,Wt,"f").freeze(),be(this,Jt,"f").freeze()}[Ae](){let t,e="";return t=/\b(node|iojs|electron)(\.exe)?$/.test(be(this,le,"f").process.argv()[0])?be(this,le,"f").process.argv().slice(1,2):be(this,le,"f").process.argv().slice(0,1),e=t.map((t=>{const e=this[Ge](be(this,Rt,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&e.length<t.length?e:t})).join(" ").trim(),be(this,le,"f").getEnv("_")&&be(this,le,"f").getProcessArgvBin()===be(this,le,"f").getEnv("_")&&(e=be(this,le,"f").getEnv("_").replace(`${be(this,le,"f").path.dirname(be(this,le,"f").process.execPath())}/`,"")),e}[Ee](){return be(this,ne,"f")}[_e](){return be(this,pe,"f")}[xe](){if(!be(this,Tt,"f"))return;const t=be(this,le,"f").getEnv("LC_ALL")||be(this,le,"f").getEnv("LC_MESSAGES")||be(this,le,"f").getEnv("LANG")||be(this,le,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[$e](){return this[Ce]().version||"unknown"}[Pe](t){const e=t["--"]?t["--"]:t._;for(let t,n=0;void 0!==(t=e[n]);n++)be(this,le,"f").Parser.looksLikeNumber(t)&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))&&(e[n]=Number(t));return t}[Ce](t){const e=t||"*";if(be(this,re,"f")[e])return be(this,re,"f")[e];let n={};try{let e=t||be(this,le,"f").mainFilename;!t&&be(this,le,"f").path.extname(e)&&(e=be(this,le,"f").path.dirname(e));const s=be(this,le,"f").findUp(e,((t,e)=>e.includes("package.json")?"package.json":void 0));ot(s,void 0,be(this,le,"f")),n=JSON.parse(be(this,le,"f").readFileSync(s,"utf8"))}catch(t){}return be(this,re,"f")[e]=n||{},be(this,re,"f")[e]}[Se](t,e){(e=[].concat(e)).forEach((e=>{e=this[De](e),be(this,te,"f")[t].push(e)}))}[Me](t,e,n,s){this[Ie](t,e,n,s,((t,e,n)=>{be(this,te,"f")[t][e]=n}))}[Ne](t,e,n,s){this[Ie](t,e,n,s,((t,e,n)=>{be(this,te,"f")[t][e]=(be(this,te,"f")[t][e]||[]).concat(n)}))}[Ie](t,e,n,s,i){if(Array.isArray(n))n.forEach((e=>{t(e,s)}));else if((t=>"object"==typeof t)(n))for(const e of ct(n))t(e,n[e]);else i(e,this[De](n),s)}[De](t){return"__proto__"===t?"___proto___":t}[We](t,e){return this[Me](this[We].bind(this),"key",t,e),this}[Re](){var t,e,n,s,i,r,o,a,c,l,h,d;const u=be(this,Vt,"f").pop();let f;ot(u,void 0,be(this,le,"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){ye(t,te,e,"f")}}.value,configObjects:f,exitProcess:{set value(t){ye(e,qt,t,"f")}}.value,groups:{set value(t){ye(n,Yt,t,"f")}}.value,output:{set value(t){ye(s,Xt,t,"f")}}.value,exitError:{set value(t){ye(i,Ut,t,"f")}}.value,hasOutput:{set value(t){ye(r,Gt,t,"f")}}.value,parsed:this.parsed,strict:{set value(t){ye(o,he,t,"f")}}.value,strictCommands:{set value(t){ye(a,de,t,"f")}}.value,strictOptions:{set value(t){ye(c,ue,t,"f")}}.value,completionCommand:{set value(t){ye(l,Lt,t,"f")}}.value,parseFn:{set value(t){ye(h,se,t,"f")}}.value,parseContext:{set value(t){ye(d,ie,t,"f")}}.value}=u),be(this,te,"f").configObjects=f,be(this,fe,"f").unfreeze(),be(this,me,"f").unfreeze(),be(this,Wt,"f").unfreeze(),be(this,Jt,"f").unfreeze()}[Fe](t,e){return yt(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[ze].bind(this),getContext:this[Le].bind(this),getHasOutput:this[He].bind(this),getLoggerInstance:this[Ue].bind(this),getParseContext:this[Te].bind(this),getParserConfiguration:this[Ee].bind(this),getUsageConfiguration:this[_e].bind(this),getUsageInstance:this[Be].bind(this),getValidationInstance:this[qe].bind(this),hasParseCallback:this[Ve].bind(this),isGlobalContext:this[Je].bind(this),postProcess:this[Ye].bind(this),reset:this[Ke].bind(this),runValidation:this[Ze].bind(this),runYargsParserAndExecuteCommands:this[Qe].bind(this),setHasOutput:this[Xe].bind(this)}}[ze](){return be(this,Wt,"f")}[Le](){return be(this,Ft,"f")}[He](){return be(this,Gt,"f")}[Ue](){return be(this,Zt,"f")}[Te](){return be(this,ie,"f")||{}}[Be](){return be(this,fe,"f")}[qe](){return be(this,me,"f")}[Ve](){return!!be(this,se,"f")}[Je](){return be(this,Qt,"f")}[Ye](t,e,n,s){if(n)return t;if(lt(t))return t;e||(t=this[we](t));return(this[Ee]()["parse-positional-numbers"]||void 0===this[Ee]()["parse-positional-numbers"])&&(t=this[Pe](t)),s&&(t=mt(t,this,be(this,Jt,"f").getMiddleware(),!1)),t}[Ke](t={}){ye(this,te,be(this,te,"f")||{},"f");const e={};e.local=be(this,te,"f").local||[],e.configObjects=be(this,te,"f").configObjects||[];const n={};e.local.forEach((e=>{n[e]=!0,(t[e]||[]).forEach((t=>{n[t]=!0}))})),Object.assign(be(this,oe,"f"),Object.keys(be(this,Yt,"f")).reduce(((t,e)=>{const s=be(this,Yt,"f")[e].filter((t=>!(t in n)));return s.length>0&&(t[e]=s),t}),{})),ye(this,Yt,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((t=>{e[t]=(be(this,te,"f")[t]||[]).filter((t=>!n[t]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((t=>{e[t]=kt(be(this,te,"f")[t],(t=>!n[t]))})),e.envPrefix=be(this,te,"f").envPrefix,ye(this,te,e,"f"),ye(this,fe,be(this,fe,"f")?be(this,fe,"f").reset(n):Et(this,be(this,le,"f")),"f"),ye(this,me,be(this,me,"f")?be(this,me,"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=>{St.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===St.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){ut("<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))):(ot(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){ut("<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=Ct(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=kt(o,(e=>!t[e])),c=kt(c,(e=>!t[e])),r};const l=[];return r.freeze=function(){l.push({implied:o,conflicting:c})},r.unfreeze=function(){const t=l.pop();ot(t,void 0,n),({implied:o,conflicting:c}=t)},r}(this,be(this,fe,"f"),be(this,le,"f")),"f"),ye(this,Wt,be(this,Wt,"f")?be(this,Wt,"f").reset():function(t,e,n,s){return new wt(t,e,n,s)}(be(this,fe,"f"),be(this,me,"f"),be(this,Jt,"f"),be(this,le,"f")),"f"),be(this,zt,"f")||ye(this,zt,function(t,e,n,s){return new Pt(t,e,n,s)}(this,be(this,fe,"f"),be(this,Wt,"f"),be(this,le,"f")),"f"),be(this,Jt,"f").reset(),ye(this,Lt,null,"f"),ye(this,Xt,"","f"),ye(this,Ut,null,"f"),ye(this,Gt,!1,"f"),this.parsed=!1,this}[Ge](t,e){return be(this,le,"f").path.relative(t,e)}[Qe](t,e,n,s=0,i=!1){let r=!!n||i;t=t||be(this,ae,"f"),be(this,te,"f").__=be(this,le,"f").y18n.__,be(this,te,"f").configuration=this[Ee]();const o=!!be(this,te,"f").configuration["populate--"],a=Object.assign({},be(this,te,"f").configuration,{"populate--":!0}),c=be(this,le,"f").Parser.detailed(t,Object.assign({},be(this,te,"f"),{configuration:{"parse-positional-numbers":!1,...a}})),l=Object.assign(c.argv,be(this,ie,"f"));let h;const d=c.aliases;let u=!1,f=!1;Object.keys(l).forEach((t=>{t===be(this,Kt,"f")&&l[t]?u=!0:t===be(this,ge,"f")&&l[t]&&(f=!0)})),l.$0=this.$0,this.parsed=c,0===s&&be(this,fe,"f").clearCachedHelpMessage();try{if(this[xe](),e)return this[Ye](l,o,!!n,!1);if(be(this,Kt,"f")){[be(this,Kt,"f")].concat(d[be(this,Kt,"f")]||[]).filter((t=>t.length>1)).includes(""+l._[l._.length-1])&&(l._.pop(),u=!0)}ye(this,Qt,!1,"f");const a=be(this,Wt,"f").getCommands(),p=be(this,zt,"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!==be(this,Lt,"f")){const t=be(this,Wt,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Ye](t,o,!!n,!1)}if(!t&&e!==be(this,Lt,"f")){t=e;break}}!be(this,Wt,"f").hasDefaultCommand()&&be(this,ce,"f")&&t&&!g&&be(this,me,"f").recommendCommands(t,a)}be(this,Lt,"f")&&l._.includes(be(this,Lt,"f"))&&!p&&(be(this,qt,"f")&&jt(!0),this.showCompletionScript(),this.exit(0))}if(be(this,Wt,"f").hasDefaultCommand()&&!g){const t=be(this,Wt,"f").runCommand(null,this,c,0,i,u||f||i);return this[Ye](t,o,!!n,!1)}if(p){be(this,qt,"f")&&jt(!0);const e=(t=[].concat(t)).slice(t.indexOf(`--${be(this,zt,"f").completionKey}`)+1);return be(this,zt,"f").getCompletion(e,((t,e)=>{if(t)throw new Z(t.message);(e||[]).forEach((t=>{be(this,Zt,"f").log(t)})),this.exit(0)})),this[Ye](l,!o,!!n,!1)}if(be(this,Gt,"f")||(u?(be(this,qt,"f")&&jt(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(be(this,qt,"f")&&jt(!0),r=!0,be(this,fe,"f").showVersion("log"),this.exit(0))),!r&&be(this,te,"f").skipValidation.length>0&&(r=Object.keys(l).some((t=>be(this,te,"f").skipValidation.indexOf(t)>=0&&!0===l[t]))),!r){if(c.error)throw new Z(c.error.message);if(!p){const t=this[Ze](d,{},c.error);n||(h=mt(l,this,be(this,Jt,"f").getMiddleware(),!0)),h=this[Fe](t,null!=h?h:l),lt(h)&&!n&&(h=h.then((()=>mt(l,this,be(this,Jt,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof Z))throw t;be(this,fe,"f").fail(t.message,t)}return this[Ye](null!=h?h:l,o,!!n,!0)}[Ze](t,e,n,s){const i={...this.getDemandedOptions()};return r=>{if(n)throw new Z(n.message);be(this,me,"f").nonOptionCount(r),be(this,me,"f").requiredArguments(r,i);let o=!1;be(this,de,"f")&&(o=be(this,me,"f").unknownCommands(r)),be(this,he,"f")&&!o?be(this,me,"f").unknownArguments(r,t,e,!!s):be(this,ue,"f")&&be(this,me,"f").unknownArguments(r,t,{},!1,!1),be(this,me,"f").limitedChoices(r),be(this,me,"f").implications(r),be(this,me,"f").conflicting(r)}}[Xe](){ye(this,Gt,!0,"f")}[tn](t){if("string"==typeof t)be(this,te,"f").key[t]=!0;else for(const e of t)be(this,te,"f").key[e]=!0}}const nn=(sn=rt,(t=[],e=sn.process.cwd(),n)=>{const s=new en(t,e,n,sn);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s});var sn;function rn(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 on=new class{constructor(){rn(this,"_dirPath",void 0),rn(this,"_dockerfile",void 0),rn(this,"_dockerfilePath",void 0),rn(this,"_hasDockerfile",void 0),rn(this,"_name",void 0),rn(this,"_rootPackageJson",void 0),rn(this,"_dockerPackageJson",void 0),rn(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??=on.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"))}},an={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"}},cn={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"}},ln={command:"buildIfNeeded",describe:"Build code if changes are detected",builder:{...an,...cn,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(on.dirPath,"node_modules",".cache","build"),n=t.resolve(e,"last-build");await j.mkdir(e,{recursive:!0});const s=k("sha256"),i=b.execSync("git rev-parse HEAD",{cwd:on.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:on.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=>(hn.some((e=>t.includes(e)))||dn.some((e=>t.endsWith(e))))&&!un.some((e=>t.includes(e))))),s=b.spawn("git",["diff","--",...n],{cwd:on.dirPath});s.stdout?.on("data",(e=>{t.update(e)})),s.on("close",(()=>{e()}))}))}(s);const o=s.digest("hex");try{if(await j.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:on.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 j.writeFile(s,i,"utf8");return!0}(e)}};const hn=["src/","public/"],dn=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","yarn.lock"],un=["test/","tests/","__tests__/","test-fixtures/","package.json"];const fn={command:"optimizeForDockerBuild",describe:"Optimize configuration when building a Docker image",builder:{...an,...cn,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(on.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"),pn(e,s),gn(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 pn(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 gn(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 mn=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 on.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 yn(t){return new Promise((e=>{h.access(t,h.constants.F_OK,(t=>{e(!t)}))}))}async function bn(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}));const c=()=>{try{let t,e;"darwin"===x.platform()?(t=v(`pstree ${r.pid}`).toString(),e=/\d+/):(t=v(`pstree -p ${r.pid}`).toString(),e=/\d+/g);const s=t.split("\n").flatMap((t=>(t.match(e)??[]).map(Number))),i=[];for(const t of s)t>0&&(t===r.pid||i.length>0)&&i.push(t);const o=`kill ${i.join(" ")}`;n?.verbose&&(console.info(t),console.info(`$ ${o}`)),v(o)}catch{}};n?.killOnExit&&process.on("exit",c),r.on("error",(t=>{process.removeListener("exit",c),r.removeAllListeners("close"),i(t)})),r.on("close",((t,e)=>{process.removeListener("exit",c),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 wn=new E,vn=new Set;const On={exitIfFailed:!0};async function kn(t,e,n=On){const[s,i]=An(t);if(En(s),e.verbose&&En(s,"Start (detailed)",!0),e.dryRun)return _n(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 _(t),process.on("beforeExit",(async()=>{vn.has(t)||(vn.add(t),await _(t))}))}(Number(r));const o=await bn(i,void 0,{cwd:on.dirPath,shell:!0,stdio:"inherit",timeout:n?.timeout,killOnExit:!0,verbose:!0});return _n(s,o.status,n),o.status??1}function jn(t,e,n=On){return wn.run((async()=>{const[s,i]=An(t);if(En(s,"Start (parallel)",!0),e.dryRun)return En(s,"Start (log)"),void _n(s,0,n);const r=await bn(i,void 0,{cwd:on.dirPath,shell:!0,stdio:"pipe",timeout:n?.timeout,mergeOutAndError:!0,killOnExit:!0,verbose:!0});En(s,"Start (log)");const o=r.stdout.trim();o&&console.info(o),_n(s,r.status,n)}))}function An(e){const n=function(){if(xn)return $n;xn=!0;let e=on.dirPath;for(;;){const n=t.join(e,"node_modules",".bin");if(h.existsSync(n)&&(process.env.PATH=`${n}:${process.env.PATH}`,$n=!0),h.existsSync(t.join(e,".git")))break;const s=t.dirname(e);if(e===s)break;e=s}return $n}(),s=e.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",on.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").trim();return[s.replaceAll("YARN ","yarn "),s.replaceAll("YARN ",n?"":"yarn ")]}function En(t,e="Start",n=!1){console.info("\n"+(n?A.gray:A.cyan)(A.bold(`${e}:`),t))}function _n(t,e,n){0===e?console.info(A.green(A.bold("Finished:"),t)):(console.info(A.red(A.bold(`Failed (exit code ${e}): `),t)),!1!==n.exitIfFailed&&process.exit(e??1))}let xn=!1,$n=!1;const Pn={...cn},Cn={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(Sn).command(Mn).command(Nn).command(In).command(Dn).command(Wn).demandCommand(),handler(){}},Sn={command:"litestream",describe:"Setup DB for Litestream",builder:Pn,async handler(t){await kn(mn.litestream(),t)}},Mn={command:"migrate",describe:"Apply migration files to DB",builder:Pn,async handler(t){await kn(mn.migrate(),t)}},Nn={command:"migrate-dev",describe:"Create a migration file",builder:Pn,async handler(t){await kn(mn.migrateDev(),t)}},In={command:"reset",describe:"Reset DB",builder:Pn,async handler(t){await kn(mn.reset(),t)}},Dn={command:"seed",describe:"Populate DB with seed data",builder:Pn,async handler(t){await kn(mn.seed(),t)}},Wn={command:"studio",describe:"Open Prisma Studio",builder:Pn,async handler(t){await kn(mn.studio(),t)}},Rn={command:"retry",describe:"Retry the given command until it succeeds",builder:{retry:{description:"A maximum retry count",type:"number",alias:"r",default:3},...cn},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${A.yellow(`#${s} Retrying: ${e.join(" ")}`)}`),n=await kn(e.join(" "),t,{exitIfFailed:!1}),0===n)return;process.exit(n)}},Fn={command:"setup",describe:"Setup development environment",builder:{...an,...cn},async handler(t){await async function(t){const e=await j.readdir(on.dirPath,{withFileTypes:!0});e.some((t=>t.isFile()&&t.name.includes("-version")))&&await kn("asdf install",t);if(e.some((t=>t.isFile()&&"pyproject.toml"===t.name))){await jn("poetry config virtualenvs.in-project true",t),await jn("poetry config virtualenvs.prefer-active-python true",t);const[,e]=b.execSync("asdf current python").toString().trim().split(/\s+/);await jn(`poetry env use ${e}`,t),await wn.promiseAll(),await kn("poetry run pip install --upgrade pip",t),await kn("poetry install --ansi",t)}if("darwin"===$.platform()){const e=["pstree"];on.hasDockerfile&&e.push("expect"),await jn(`brew install ${e.join(" ")}`,t)}const n=on.packageJson.dependencies??{},s=on.packageJson.devDependencies||{},i=on.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 kn(`yarn add ${r.join(" ")}`,t);o.length>0&&await kn(`yarn add -D ${o.join(" ")}`,t);i["gen-code"]&&await kn("yarn gen-code",t)}(t)}};const zn=new class{buildDevImage(e="local"){const n=on.dockerPackageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":"";return`cd ${t.dirname(on.dockerfilePath)}\n && ${n}YARN wb optimizeForDockerBuild --outside\n && YARN wb retry -- docker build -t ${on.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){process.on("beforeExit",(()=>{vn.has(t)||(vn.add(t),O(t,{shell:!0,stdio:"inherit"}))}))}(this.stop()),`docker run --rm -it -p 8080:8080 --name ${on.name} ${t} ${on.name} ${e}`}stop(){return`true $(docker rm -f $(docker container ls -q -f name=${on.name}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};class Ln{constructor(t=3e3){this.defaultPort=t}buildDocker(t="local"){return zn.buildDevImage(t)}startDocker(t=""){return`${this.buildDocker()}\n && YARN concurrently --raw --kill-others-on-fail\n "${zn.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 Hn=new class extends Ln{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 "${mn.reset()} && yarn build && PORT=${t} pm2-runtime start ecosystem.config.cjs ${e}"\n "${this.waitAndOpenApp(t)}"`}testE2E({playwrightArgs:t="test tests/e2e",startCommand:e=`${mn.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 Un=new class extends Ln{constructor(){super()}start(t,e=""){return`YARN build-ts run src/index.ts ${t?"--watch":""} ${e}`}startDocker(t=""){return`${this.buildDocker()} && ${zn.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 Tn=new class extends Ln{constructor(){super()}start(t,e=""){return`YARN build-ts run src/index.ts ${t?"--watch":""} ${e}`}startDocker(t=""){return`${this.buildDocker()} && ${zn.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 Bn=new class extends Ln{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 "${mn.reset()} && yarn build && PORT=${t} pm2-runtime start ecosystem.config.cjs ${e}"\n "${this.waitAndOpenApp(t)}"`}testE2E({playwrightArgs:t="test tests/e2e",startCommand:e=`${mn.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()}"`}},qn={command:"start",describe:"Start app",builder:{...cn,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=on.packageJson.dependencies||{},n=on.packageJson.devDependencies||{};let s;s=e.blitz?Hn:n["@remix-run/dev"]?Bn:(e.express||e.fastify)&&!e["firebase-functions"]||/EXPOSE\s+8080/.test(on.dockerfile)?Un:Tn;const i=t.args??"";switch(t.mode||"dev"){case"dev":case"development":await kn(s.start(t.watch,i),t);break;case"prod":case"production":await kn(s.startProduction(8080,i),t);break;case"docker":await kn(s.startDocker(i),t);break;default:throw new Error(`Unknown start mode: ${t.mode}`)}}},Vn={command:"test",describe:"Test project",builder:{...cn,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(!on.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 kn(["yarn","workspaces","foreach","--exclude",on.name,"--verbose","run","wb",...e].join(" "),t),process.exit(0)}(e);const n=on.packageJson.dependencies||{},s=on.packageJson.devDependencies||{};let i;i=n.blitz?Hn:s["@remix-run/dev"]?Bn:!n.express&&!n.fastify||n["firebase-functions"]?Tn:Un;const r=[];if(e.ci){const n=yn(t.join(on.dirPath,"tests","unit")),s=yn(t.join(on.dirPath,"tests","e2e"));if(await jn(zn.stopAll(),e),!1!==e.unit&&await n&&await jn(i.testUnit(),e,{timeout:e.unitTimeout}),!1!==e.start&&await jn(i.testStart(),e),await wn.promiseAll(),"none"!==e.e2e&&await s){on.hasDockerfile&&await kn(`${i.buildDocker("test")}`,e);const t=on.hasDockerfile?{startCommand:zn.stopAndStart(!0)}:{};process.exitCode=await kn(i.testE2E(t),e,{exitIfFailed:!1}),await kn(zn.stop(),e)}return}(e.unit||!e.start&&void 0===e.e2e)&&r.push(kn(i.testUnit(),e,{timeout:e.unitTimeout}));e.start&&r.push(kn(i.testStart(),e));switch(await Promise.all(r),e.e2e){case void 0:case"none":return;case"":case"headless":return void await kn(i.testE2E({}),e);case"docker":return await kn(`${i.buildDocker("test")}`,e),process.exitCode=await kn(i.testE2E({startCommand:zn.stopAndStart(!0)}),e,{exitIfFailed:!1}),void await kn(zn.stop(),e)}if(n.blitz||s["@remix-run/dev"])switch(e.e2e){case"headed":return void await kn(i.testE2E({playwrightArgs:"test tests/e2e --headed"}),e);case"debug":return void await kn(`PWDEBUG=1 ${i.testE2E({})}`,e);case"generate":return void await kn(i.testE2E({playwrightArgs:"codegen http://localhost:8080"}),e);case"trace":return void await kn("playwright show-trace",e)}throw new Error(`Unknown e2e mode: ${e.e2e}`)}(e)}};const Jn={command:"typecheck",describe:"Run type checking",builder:{...cn},async handler(t){if(process.exitCode=await kn("tsc --noEmit --Pretty",t),0!==process.exitCode){(JSON.parse(await j.readFile("package.json","utf8")).dependencies||{}).blitz&&console.info(A.yellow('Please try "yarn gen-code" if you face unknown type errors.'))}}},Yn={...Jn,command:"tc"};var Gn;await nn((Gn=process.argv,Gn.slice(Q()+1))).scriptName("wb").options(an).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),on.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(on.dirPath,e)})})).command(ln).command(fn).command(Cn).command(Rn).command(Fn).command(qn).command(Vn).command(Jn).command(Yn).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
34
34
  //# sourceMappingURL=index.js.map