@kitschpatrol/tldraw-cli 2.0.2 → 2.0.3

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/bin/cli.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- var _t=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var an="2.0.1";import un from"express";import wi from"node:net";import yi from"node:os";var ue=class extends Error{constructor(t){super(`${t} is locked`)}},Zt={old:new Set,young:new Set},Oi=1e3*15;var ie,_i=()=>{let s=yi.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let e of Object.values(s))for(let n of e)t.add(n.address);return t},ln=s=>new Promise((t,e)=>{let n=wi.createServer();n.unref(),n.on("error",e),n.listen(s,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),cn=async(s,t)=>{if(s.host||s.port===0)return ln(s);for(let e of t)try{await ln({port:s.port,host:e})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return s.port},Ci=function*(s){s&&(yield*s),yield 0};async function $e(s){let t,e=new Set;if(s&&(s.port&&(t=typeof s.port=="number"?[s.port]:s.port),s.exclude)){let i=s.exclude;if(typeof i[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let r of i){if(typeof r!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(r))throw new TypeError(`Number ${r} in the exclude option is not a safe integer and can't be used`)}e=new Set(i)}ie===void 0&&(ie=setTimeout(()=>{ie=void 0,Zt.old=Zt.young,Zt.young=new Set},Oi),ie.unref&&ie.unref());let n=_i();for(let i of Ci(t))try{if(e.has(i))continue;let r=await cn({...s,port:i},n);for(;Zt.old.has(r)||Zt.young.has(r);){if(i!==0)throw new ue(i);r=await cn({...s,port:i},n)}return Zt.young.add(r),r}catch(r){if(!["EADDRINUSE","EACCES"].includes(r.code)&&!(r instanceof ue))throw r}throw new Error("No available ports found")}import hn from"node:fs/promises";import dn from"node:os";import Wt from"node:path";import{dirname as Ei}from"node:path";import{fileURLToPath as ji}from"node:url";import Ai from"puppeteer";import xi from"node:os";var fn=xi.homedir();function he(s){if(typeof s!="string")throw new TypeError(`Expected a string, got ${typeof s}`);return fn?s.replace(/^~(?=$|\/|\\)/,fn):s}var Pi={darkMode:!1,format:"svg",output:"./",transparent:!1,verbose:!0};async function mn(s,t={}){let e={...Pi,...vi(t)},{darkMode:n,format:i,output:r,transparent:a,verbose:c}=e,g=!s.startsWith("https://www.tldraw.com/");c&&console.log(g?"Local file detected":"tldraw URL detected");let w=0,p;if(g){c&&console.log("Starting tldraw server...");let R=Ei(ji(import.meta.url)),H=Wt.join(R,R.endsWith("/src/lib")?"../../dist/tldraw":R.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");c&&console.log(`tldraw served from "${H}"`),p=await Mi(H),w=p.address().port,c&&console.log(`tldraw hosted at "http://localhost:${w}"`)}c&&console.log("Starting Puppeteer...");let h=await Ai.launch({args:g?["--no-sandbox","--disable-web-security"]:[],headless:"new"}),m=await h.newPage();Si(m,c);let y=await m.target().createCDPSession();if(await y.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:dn.tmpdir(),eventsEnabled:!0}),g){await m.setRequestInterception(!0),m.on("request",at=>{at.url().endsWith("favicon.ico")?at.respond({status:200}):at.continue()});let R=Wt.resolve(he(s));c&&console.log(`Loading tldr file "${R}"`);let H=await hn.readFile(R,"utf8");await m.evaluateOnNewDocument(at=>{localStorage.clear(),localStorage.setItem("tldrData",at)},H)}let E=g?`http://localhost:${w}`:s;c&&console.log(`Navigating to: ${E}`),await m.goto(E,{waitUntil:"networkidle0"}),c&&console.log(`Setting background transparency: ${a}`),await Ni(m,a),c&&console.log(`Setting dark mode: ${n}`);let _=await Fi(m);await pn(m,n),c&&console.log("Requesting download"),await Di(m),await $i(m,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${i}`]);let d=await Ii(y);c&&console.log("Download complete"),c&&console.log(`Restoring dark mode: ${_}`),await pn(m,_),await h.close(),c&&console.log("Stopped Puppeteer"),g&&p&&(p.close(),c&&console.log("Stopped tldraw server"));let L=g?Wt.basename(s,Wt.extname(s)):d,z=Wt.join(dn.tmpdir(),d),T=he(Wt.join(r,`${L}.${i}`));return await hn.rename(z,T),c&&console.log(`Saved to "${T}"`),Wt.resolve(T)}function Si(s,t){s.on("console",e=>{let n=e.type(),i=e.text();n==="error"?console.error(`[Browser] ${i}`):n==="warning"?console.warn(`[Browser] ${i}`):t&&console.log(`[Browser] ${i}`)})}async function Mi(s){let t=un(),e=await $e();return t.use(un.static(s)),new Promise((n,i)=>{let r=t.listen(e,()=>{n(r)});r.on("error",a=>{i(a)})})}async function Ii(s){return new Promise((t,e)=>{s.on("Browser.downloadProgress",n=>{n.state==="completed"?t(n.guid):n.state==="canceled"&&e(new Error("Download was canceled"))})})}async function $i(s,t){for(let e of t)await s.waitForSelector(`[data-testid="${e}"]`),await s.click(`[data-testid="${e}"]`)}function vi(s){return Object.fromEntries(Object.entries(s).filter(([,t])=>t!==void 0))}async function Di(s){await s.evaluate("app.clearOpenMenus()")}async function Fi(s){return!!await s.evaluate("editor.user.getUserPreferences().isDarkMode")}async function pn(s,t){await s.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${t}})`)}async function Ni(s,t){await s.evaluate(`editor.updateInstanceState(
2
+ var _t=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var fn="2.0.2";import dn from"node:path";import{fileURLToPath as Ai}from"node:url";import xi,{promises as Ei}from"fs";async function $e(s,t,e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);try{return(await Ei[s](e))[t]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function ve(s,t,e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);try{return xi[s](e)[t]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var Ts=$e.bind(null,"stat","isFile"),Hs=$e.bind(null,"stat","isDirectory"),Bs=$e.bind(null,"lstat","isSymbolicLink"),un=ve.bind(null,"statSync","isFile"),Ys=ve.bind(null,"statSync","isDirectory"),qs=ve.bind(null,"lstatSync","isSymbolicLink");import ji from"node:os";var hn=ji.homedir();function ie(s){if(typeof s!="string")throw new TypeError(`Expected a string, got ${typeof s}`);return hn?s.replace(/^~(?=$|\/|\\)/,hn):s}function Fe(s,t={}){let{requireFileExistence:e,validFileExtensions:n,validHostnames:i}=t;if(URL.canParse(s)){let m=new URL(s);if(m.protocol==="file:")return Fe(Ai(m),t);if(i&&!i.includes(m.hostname))throw new Error(`Bad input URL. Only ${i.join(", ")} URLs are supported.`);return m}let r=ie(s),a=dn.normalize(r);if(e&&!un(a))throw new Error("Input is not a file.");let l=dn.extname(a);if(n&&!n.includes(l))throw new Error(`Bad input file name. Only ${n.join(", ")} files are supported.`);return a}import gn from"express";import Pi from"node:net";import Si from"node:os";var he=class extends Error{constructor(t){super(`${t} is locked`)}},Jt={old:new Set,young:new Set},Mi=1e3*15;var se,Ii=()=>{let s=Si.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let e of Object.values(s))for(let n of e)t.add(n.address);return t},pn=s=>new Promise((t,e)=>{let n=Pi.createServer();n.unref(),n.on("error",e),n.listen(s,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),mn=async(s,t)=>{if(s.host||s.port===0)return pn(s);for(let e of t)try{await pn({port:s.port,host:e})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return s.port},$i=function*(s){s&&(yield*s),yield 0};async function De(s){let t,e=new Set;if(s&&(s.port&&(t=typeof s.port=="number"?[s.port]:s.port),s.exclude)){let i=s.exclude;if(typeof i[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let r of i){if(typeof r!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(r))throw new TypeError(`Number ${r} in the exclude option is not a safe integer and can't be used`)}e=new Set(i)}se===void 0&&(se=setTimeout(()=>{se=void 0,Jt.old=Jt.young,Jt.young=new Set},Mi),se.unref&&se.unref());let n=Ii();for(let i of $i(t))try{if(e.has(i))continue;let r=await mn({...s,port:i},n);for(;Jt.old.has(r)||Jt.young.has(r);){if(i!==0)throw new he(i);r=await mn({...s,port:i},n)}return Jt.young.add(r),r}catch(r){if(!["EADDRINUSE","EACCES"].includes(r.code)&&!(r instanceof he))throw r}throw new Error("No available ports found")}import bn from"node:fs/promises";import wn from"node:os";import Zt from"node:path";import{dirname as vi}from"node:path";import{fileURLToPath as Fi}from"node:url";import Di from"puppeteer";var Ni={darkMode:!1,format:"svg",output:"./",transparent:!1,verbose:!1};async function On(s,t={}){let e={...Ni,...zi(t)},{darkMode:n,format:i,output:r,transparent:a,verbose:l}=e,m=Fe(s,{requireFileExistence:!0,validFileExtensions:[".tldr"],validHostnames:["www.tldraw.com"]}),w=typeof m=="string";l&&console.log(w?"Local file detected":"tldraw URL detected");let p=0,h;if(w){l&&console.log("Starting tldraw server...");let T=vi(Fi(import.meta.url)),rt=Zt.join(T,T.endsWith("/src/lib")?"../../dist/tldraw":T.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");l&&console.log(`tldraw served from "${rt}"`),h=await Wi(rt),p=h.address().port,l&&console.log(`tldraw hosted at "http://localhost:${p}"`)}l&&console.log("Starting Puppeteer...");let g=await Di.launch({args:w?["--no-sandbox","--disable-web-security"]:[],headless:"new"}),y=await g.newPage();Li(y,l);let E=await y.target().createCDPSession();if(await E.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:wn.tmpdir(),eventsEnabled:!0}),w){await y.setRequestInterception(!0),y.on("request",rt=>{rt.url().endsWith("favicon.ico")?rt.respond({status:200}):rt.continue()}),l&&console.log(`Loading tldr file "${m}"`);let T=await bn.readFile(m,"utf8");await y.evaluateOnNewDocument(rt=>{localStorage.clear(),localStorage.setItem("tldrData",rt)},T)}let _=w?`http://localhost:${p}`:m.href;l&&console.log(`Navigating to: ${_}`),await y.goto(_,{waitUntil:"networkidle0"}),l&&console.log(`Setting background transparency: ${a}`),await Bi(y,a),l&&console.log(`Setting dark mode: ${n}`);let d=await Hi(y);await yn(y,n),l&&console.log("Requesting download"),await Ti(y),await Ui(y,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${i}`]);let W=await Ri(E);l&&console.log("Download complete"),l&&console.log(`Restoring dark mode: ${d}`),await yn(y,d),await g.close(),l&&console.log("Stopped Puppeteer"),w&&h&&(h.close(),l&&console.log("Stopped tldraw server"));let R=w?Zt.basename(m,Zt.extname(m)):W,Y=Zt.join(wn.tmpdir(),W),U=ie(Zt.join(r,`${R}.${i}`));return await bn.rename(Y,U),l&&console.log(`Saved to "${U}"`),Zt.resolve(U)}function Li(s,t){s.on("console",e=>{let n=e.type(),i=e.text();n==="error"?console.error(`[Browser] ${i}`):n==="warning"?console.warn(`[Browser] ${i}`):t&&console.log(`[Browser] ${i}`)})}async function Wi(s){let t=gn(),e=await De();return t.use(gn.static(s)),new Promise((n,i)=>{let r=t.listen(e,()=>{n(r)});r.on("error",a=>{i(a)})})}async function Ri(s){return new Promise((t,e)=>{s.on("Browser.downloadProgress",n=>{n.state==="completed"?t(n.guid):n.state==="canceled"&&e(new Error("Download was canceled"))})})}async function Ui(s,t){for(let e of t)await s.waitForSelector(`[data-testid="${e}"]`),await s.click(`[data-testid="${e}"]`)}function zi(s){return Object.fromEntries(Object.entries(s).filter(([,t])=>t!==void 0))}async function Ti(s){await s.evaluate("app.clearOpenMenus()")}async function Hi(s){return!!await s.evaluate("editor.user.getUserPreferences().isDarkMode")}async function yn(s,t){await s.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${t}})`)}async function Bi(s,t){await s.evaluate(`editor.updateInstanceState(
3
3
  { exportBackground: ${!t} },
4
4
  { ephemeral: true },
5
- )`)}import{notStrictEqual as os,strictEqual as as}from"assert";var Wi={right:Ti,center:Hi},Li=0,de=1,Ri=2,pe=3,ve=class{constructor(t){var e;this.width=t.width,this.wrap=(e=t.wrap)!==null&&e!==void 0?e:!0,this.rows=[]}span(...t){let e=this.div(...t);e.span=!0}resetOutput(){this.rows=[]}div(...t){if(t.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&typeof t[0]=="string")return this.applyLayoutDSL(t[0]);let e=t.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return t.length===1&&typeof t[0]=="string"&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){let e=t.split(`
5
+ )`)}import{notStrictEqual as ps,strictEqual as ms}from"assert";var Yi={right:Qi,center:Ji},qi=0,de=1,Gi=2,pe=3,Ne=class{constructor(t){var e;this.width=t.width,this.wrap=(e=t.wrap)!==null&&e!==void 0?e:!0,this.rows=[]}span(...t){let e=this.div(...t);e.span=!0}resetOutput(){this.rows=[]}div(...t){if(t.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&typeof t[0]=="string")return this.applyLayoutDSL(t[0]);let e=t.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return t.length===1&&typeof t[0]=="string"&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){let e=t.split(`
6
6
  `).map(i=>i.split(" ")),n=0;return e.forEach(i=>{i.length>1&&lt.stringWidth(i[0])>n&&(n=Math.min(Math.floor(this.width*.5),lt.stringWidth(i[0])))}),e.forEach(i=>{this.div(...i.map((r,a)=>({text:r.trim(),padding:this.measurePadding(r),width:a===0&&i.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){let e=lt.stripAnsi(t);return[0,e.match(/\s*$/)[0].length,0,e.match(/^\s*/)[0].length]}toString(){let t=[];return this.rows.forEach(e=>{this.rowToString(e,t)}),t.filter(e=>!e.hidden).map(e=>e.text).join(`
7
- `)}rowToString(t,e){return this.rasterize(t).forEach((n,i)=>{let r="";n.forEach((a,c)=>{let{width:g}=t[c],w=this.negatePadding(t[c]),p=a;if(w>lt.stringWidth(a)&&(p+=" ".repeat(w-lt.stringWidth(a))),t[c].align&&t[c].align!=="left"&&this.wrap){let m=Wi[t[c].align];p=m(p,w),lt.stringWidth(p)<w&&(p+=" ".repeat((g||0)-lt.stringWidth(p)-1))}let h=t[c].padding||[0,0,0,0];h[pe]&&(r+=" ".repeat(h[pe])),r+=gn(t[c],p,"| "),r+=p,r+=gn(t[c],p," |"),h[de]&&(r+=" ".repeat(h[de])),i===0&&e.length>0&&(r=this.renderInline(r,e[e.length-1]))}),e.push({text:r.replace(/ +$/,""),span:t.span})}),e}renderInline(t,e){let n=t.match(/^ */),i=n?n[0].length:0,r=e.text,a=lt.stringWidth(r.trimRight());return e.span?this.wrap?i<a?t:(e.hidden=!0,r.trimRight()+" ".repeat(i-a)+t.trimLeft()):(e.hidden=!0,r+t):t}rasterize(t){let e=[],n=this.columnWidths(t),i;return t.forEach((r,a)=>{r.width=n[a],this.wrap?i=lt.wrap(r.text,this.negatePadding(r),{hard:!0}).split(`
7
+ `)}rowToString(t,e){return this.rasterize(t).forEach((n,i)=>{let r="";n.forEach((a,l)=>{let{width:m}=t[l],w=this.negatePadding(t[l]),p=a;if(w>lt.stringWidth(a)&&(p+=" ".repeat(w-lt.stringWidth(a))),t[l].align&&t[l].align!=="left"&&this.wrap){let g=Yi[t[l].align];p=g(p,w),lt.stringWidth(p)<w&&(p+=" ".repeat((m||0)-lt.stringWidth(p)-1))}let h=t[l].padding||[0,0,0,0];h[pe]&&(r+=" ".repeat(h[pe])),r+=_n(t[l],p,"| "),r+=p,r+=_n(t[l],p," |"),h[de]&&(r+=" ".repeat(h[de])),i===0&&e.length>0&&(r=this.renderInline(r,e[e.length-1]))}),e.push({text:r.replace(/ +$/,""),span:t.span})}),e}renderInline(t,e){let n=t.match(/^ */),i=n?n[0].length:0,r=e.text,a=lt.stringWidth(r.trimRight());return e.span?this.wrap?i<a?t:(e.hidden=!0,r.trimRight()+" ".repeat(i-a)+t.trimLeft()):(e.hidden=!0,r+t):t}rasterize(t){let e=[],n=this.columnWidths(t),i;return t.forEach((r,a)=>{r.width=n[a],this.wrap?i=lt.wrap(r.text,this.negatePadding(r),{hard:!0}).split(`
8
8
  `):i=r.text.split(`
9
- `),r.border&&(i.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(r)+2)+"'")),r.padding&&(i.unshift(...new Array(r.padding[Li]||0).fill("")),i.push(...new Array(r.padding[Ri]||0).fill(""))),i.forEach((c,g)=>{e[g]||e.push([]);let w=e[g];for(let p=0;p<a;p++)w[p]===void 0&&w.push("");w.push(c)})}),e}negatePadding(t){let e=t.width||0;return t.padding&&(e-=(t.padding[pe]||0)+(t.padding[de]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map(a=>a.width||lt.stringWidth(a.text));let e=t.length,n=this.width,i=t.map(a=>{if(a.width)return e--,n-=a.width,a.width}),r=e?Math.floor(n/e):0;return i.map((a,c)=>a===void 0?Math.max(r,zi(t[c])):a)}};function gn(s,t,e){return s.border?/[.']-+[.']/.test(t)?"":t.trim().length!==0?e:" ":""}function zi(s){let t=s.padding||[],e=1+(t[pe]||0)+(t[de]||0);return s.border?e+4:e}function Ui(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Ti(s,t){s=s.trim();let e=lt.stringWidth(s);return e<t?" ".repeat(t-e)+s:s}function Hi(s,t){s=s.trim();let e=lt.stringWidth(s);return e>=t?s:" ".repeat(t-e>>1)+s}var lt;function bn(s,t){return lt=t,new ve({width:s?.width||Ui(),wrap:s?.wrap})}var wn=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function De(s){return s.replace(wn,"")}function yn(s,t){let[e,n]=s.match(wn)||["",""];s=De(s);let i="";for(let r=0;r<s.length;r++)r!==0&&r%t===0&&(i+=`
10
- `),i+=s.charAt(r);return e&&n&&(i=`${e}${i}${n}`),i}function Fe(s){return bn(s,{stringWidth:t=>[...t].length,stripAnsi:De,wrap:yn})}import{dirname as On,resolve as _n}from"path";import{readdirSync as Yi,statSync as Bi}from"fs";function Cn(s,t){let e=_n(".",s),n;for(Bi(e).isDirectory()||(e=On(e));;){if(n=t(e,Yi(e)),n)return _n(e,n);if(e=On(n=e),n===e)break}}import{inspect as ls}from"util";import{readFileSync as cs}from"fs";import{fileURLToPath as fs}from"url";import{format as qi}from"util";import{normalize as Ki,resolve as Qi}from"path";function Lt(s){if(s!==s.toLowerCase()&&s!==s.toUpperCase()||(s=s.toLowerCase()),s.indexOf("-")===-1&&s.indexOf("_")===-1)return s;{let e="",n=!1,i=s.match(/^-+/);for(let r=i?i[0].length:0;r<s.length;r++){let a=s.charAt(r);n&&(n=!1,a=a.toUpperCase()),r!==0&&(a==="-"||a==="_")?n=!0:a!=="-"&&a!=="_"&&(e+=a)}return e}}function me(s,t){let e=s.toLowerCase();t=t||"-";let n="";for(let i=0;i<s.length;i++){let r=e.charAt(i),a=s.charAt(i);r!==a&&i>0?n+=`${t}${e.charAt(i)}`:n+=a}return n}function ge(s){return s==null?!1:typeof s=="number"||/^0x[0-9a-f]+$/i.test(s)?!0:/^0[^.]/.test(s)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(s)}function xn(s){if(Array.isArray(s))return s.map(a=>typeof a!="string"?a+"":a);s=s.trim();let t=0,e=null,n=null,i=null,r=[];for(let a=0;a<s.length;a++){if(e=n,n=s.charAt(a),n===" "&&!i){e!==" "&&t++;continue}n===i?i=null:(n==="'"||n==='"')&&!i&&(i=n),r[t]||(r[t]=""),r[t]+=n}return r}var ht;(function(s){s.BOOLEAN="boolean",s.STRING="string",s.NUMBER="number",s.ARRAY="array"})(ht||(ht={}));var At,be=class{constructor(t){At=t}parse(t,e){let 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),i=xn(t),r=typeof t=="string",a=Gi(Object.assign(Object.create(null),n.alias)),c=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),g=Object.assign(Object.create(null),n.default),w=n.configObjects||[],p=n.envPrefix,h=c["populate--"],m=h?"--":"_",y=Object.create(null),E=Object.create(null),_=n.__||At.format,d={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:[]},L=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,z=new RegExp("^--"+c["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(l){let u=typeof l=="object"?l.key:l,O=Object.keys(l).map(function(b){return{boolean:"bools",string:"strings",number:"numbers"}[b]}).filter(Boolean).pop();O&&(d[O][u]=!0),d.arrays[u]=!0,d.keys.push(u)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){d.bools[l]=!0,d.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){d.strings[l]=!0,d.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){d.numbers[l]=!0,d.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){d.counts[l]=!0,d.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){d.normalize[l]=!0,d.keys.push(l)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([l,u])=>{typeof u=="number"&&(d.nargs[l]=u,d.keys.push(l))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([l,u])=>{typeof u=="function"&&(d.coercions[l]=u,d.keys.push(l))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(l){d.configs[l]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([l,u])=>{(typeof u=="boolean"||typeof u=="function")&&(d.configs[l]=u)})),Nt(n.key,a,n.default,d.arrays),Object.keys(g).forEach(function(l){(d.aliases[l]||[]).forEach(function(u){g[u]=g[l]})});let T=null;fe();let R=[],H=Object.assign(Object.create(null),{_:[]}),at={};for(let l=0;l<i.length;l++){let u=i[l],O=u.replace(/^-{3,}/,"---"),b,f,S,x,$,it;if(u!=="--"&&/^-/.test(u)&&J(u))bt(u);else if(O.match(/^---+(=|$)/)){bt(u);continue}else if(u.match(/^--.+=/)||!c["short-option-groups"]&&u.match(/^-.+=/))x=u.match(/^--?([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&(D(x[1],d.arrays)?l=Dt(l,x[1],i,x[2]):D(x[1],d.nargs)!==!1?l=Jt(l,x[1],i,x[2]):G(x[1],x[2],!0));else if(u.match(z)&&c["boolean-negation"])x=u.match(z),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],G(f,D(f,d.arrays)?[!1]:!1));else if(u.match(/^--.+/)||!c["short-option-groups"]&&u.match(/^-[^-]+/))x=u.match(/^--?(.+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],D(f,d.arrays)?l=Dt(l,f,i):D(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!$.match(/^-/)||$.match(L))&&!D(f,d.bools)&&!D(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))));else if(u.match(/^-.\..+=/))x=u.match(/^-([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&G(x[1],x[2]);else if(u.match(/^-.\..+/)&&!u.match(L))$=i[l+1],x=u.match(/^-(.\..+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],$!==void 0&&!$.match(/^-/)&&!D(f,d.bools)&&!D(f,d.counts)?(G(f,$),l++):G(f,Z(f)));else if(u.match(/^-[^-]+/)&&!u.match(L)){S=u.slice(1,-1).split(""),b=!1;for(let rt=0;rt<S.length;rt++){if($=u.slice(rt+2),S[rt+1]&&S[rt+1]==="="){it=u.slice(rt+3),f=S[rt],D(f,d.arrays)?l=Dt(l,f,i,it):D(f,d.nargs)!==!1?l=Jt(l,f,i,it):G(f,it),b=!0;break}if($==="-"){G(S[rt],$);continue}if(/[A-Za-z]/.test(S[rt])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test($)&&D($,d.bools)===!1){G(S[rt],$),b=!0;break}if(S[rt+1]&&S[rt+1].match(/\W/)){G(S[rt],$),b=!0;break}else G(S[rt],Z(S[rt]))}f=u.slice(-1)[0],!b&&f!=="-"&&(D(f,d.arrays)?l=Dt(l,f,i):D(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(L))&&!D(f,d.bools)&&!D(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))))}else if(u.match(/^-[0-9]$/)&&u.match(L)&&D(u.slice(1),d.bools))f=u.slice(1),G(f,Z(f));else if(u==="--"){R=i.slice(l+1);break}else if(c["halt-at-non-option"]){R=i.slice(l);break}else bt(u)}Y(H,!0),Y(H,!1),W(H),et(),Q(H,d.aliases,g,!0),nt(H),c["set-placeholder-key"]&&Ft(H),Object.keys(d.counts).forEach(function(l){Et(H,l.split("."))||G(l,0)}),h&&R.length&&(H[m]=[]),R.forEach(function(l){H[m].push(l)}),c["camel-case-expansion"]&&c["strip-dashed"]&&Object.keys(H).filter(l=>l!=="--"&&l.includes("-")).forEach(l=>{delete H[l]}),c["strip-aliased"]&&[].concat(...Object.keys(a).map(l=>a[l])).forEach(l=>{c["camel-case-expansion"]&&l.includes("-")&&delete H[l.split(".").map(u=>Lt(u)).join(".")],delete H[l]});function bt(l){let u=P("_",l);(typeof u=="string"||typeof u=="number")&&H._.push(u)}function Jt(l,u,O,b){let f,S=D(u,d.nargs);if(S=typeof S!="number"||isNaN(S)?1:S,S===0)return yt(b)||(T=Error(_("Argument unexpected for: %s",u))),G(u,Z(u)),l;let x=yt(b)?0:1;if(c["nargs-eats-options"])O.length-(l+1)+x<S&&(T=Error(_("Not enough arguments following: %s",u))),x=S;else{for(f=l+1;f<O.length&&(!O[f].match(/^-[^0-9]/)||O[f].match(L)||J(O[f]));f++)x++;x<S&&(T=Error(_("Not enough arguments following: %s",u)))}let $=Math.min(x,S);for(!yt(b)&&$>0&&(G(u,b),$--),f=l+1;f<$+l+1;f++)G(u,O[f]);return l+$}function Dt(l,u,O,b){let f=[],S=b||O[l+1],x=D(u,d.nargs);if(D(u,d.bools)&&!/^(true|false)$/.test(S))f.push(!0);else if(yt(S)||yt(b)&&/^-/.test(S)&&!L.test(S)&&!J(S)){if(g[u]!==void 0){let $=g[u];f=Array.isArray($)?$:[$]}}else{yt(b)||f.push(C(u,b,!0));for(let $=l+1;$<O.length&&!(!c["greedy-arrays"]&&f.length>0||x&&typeof x=="number"&&f.length>=x||(S=O[$],/^-/.test(S)&&!L.test(S)&&!J(S)));$++)l=$,f.push(C(u,S,r))}return typeof x=="number"&&(x&&f.length<x||isNaN(x)&&f.length===0)&&(T=Error(_("Not enough arguments following: %s",u))),G(u,f),l}function G(l,u,O=r){if(/-/.test(l)&&c["camel-case-expansion"]){let S=l.split(".").map(function(x){return Lt(x)}).join(".");M(l,S)}let b=C(l,u,O),f=l.split(".");jt(H,f,b),d.aliases[l]&&d.aliases[l].forEach(function(S){let x=S.split(".");jt(H,x,b)}),f.length>1&&c["dot-notation"]&&(d.aliases[f[0]]||[]).forEach(function(S){let x=S.split("."),$=[].concat(f);$.shift(),x=x.concat($),(d.aliases[l]||[]).includes(x.join("."))||jt(H,x,b)}),D(l,d.normalize)&&!D(l,d.arrays)&&[l].concat(d.aliases[l]||[]).forEach(function(x){Object.defineProperty(at,x,{enumerable:!0,get(){return u},set($){u=typeof $=="string"?At.normalize($):$}})})}function M(l,u){d.aliases[l]&&d.aliases[l].length||(d.aliases[l]=[u],y[u]=!0),d.aliases[u]&&d.aliases[u].length||M(u,l)}function C(l,u,O){O&&(u=Vi(u)),(D(l,d.bools)||D(l,d.counts))&&typeof u=="string"&&(u=u==="true");let b=Array.isArray(u)?u.map(function(f){return P(l,f)}):P(l,u);return D(l,d.counts)&&(yt(b)||typeof b=="boolean")&&(b=Ne()),D(l,d.normalize)&&D(l,d.arrays)&&(Array.isArray(u)?b=u.map(f=>At.normalize(f)):b=At.normalize(u)),b}function P(l,u){return!c["parse-positional-numbers"]&&l==="_"||!D(l,d.strings)&&!D(l,d.bools)&&!Array.isArray(u)&&(ge(u)&&c["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${u}`)))||!yt(u)&&D(l,d.numbers))&&(u=Number(u)),u}function W(l){let u=Object.create(null);Q(u,d.aliases,g),Object.keys(d.configs).forEach(function(O){let b=l[O]||u[O];if(b)try{let f=null,S=At.resolve(At.cwd(),b),x=d.configs[O];if(typeof x=="function"){try{f=x(S)}catch($){f=$}if(f instanceof Error){T=f;return}}else f=At.require(S);B(f)}catch(f){f.name==="PermissionDenied"?T=f:l[O]&&(T=Error(_("Invalid JSON config file: %s",b)))}})}function B(l,u){Object.keys(l).forEach(function(O){let b=l[O],f=u?u+"."+O:O;typeof b=="object"&&b!==null&&!Array.isArray(b)&&c["dot-notation"]?B(b,f):(!Et(H,f.split("."))||D(f,d.arrays)&&c["combine-arrays"])&&G(f,b)})}function et(){typeof w<"u"&&w.forEach(function(l){B(l)})}function Y(l,u){if(typeof p>"u")return;let O=typeof p=="string"?p:"",b=At.env();Object.keys(b).forEach(function(f){if(O===""||f.lastIndexOf(O,0)===0){let S=f.split("__").map(function(x,$){return $===0&&(x=x.substring(O.length)),Lt(x)});(u&&d.configs[S.join(".")]||!u)&&!Et(l,S)&&G(S.join("."),b[f])}})}function nt(l){let u,O=new Set;Object.keys(l).forEach(function(b){if(!O.has(b)&&(u=D(b,d.coercions),typeof u=="function"))try{let f=P(b,u(l[b]));[].concat(d.aliases[b]||[],b).forEach(S=>{O.add(S),l[S]=f})}catch(f){T=f}})}function Ft(l){return d.keys.forEach(u=>{~u.indexOf(".")||typeof l[u]>"u"&&(l[u]=void 0)}),l}function Q(l,u,O,b=!1){Object.keys(O).forEach(function(f){Et(l,f.split("."))||(jt(l,f.split("."),O[f]),b&&(E[f]=!0),(u[f]||[]).forEach(function(S){Et(l,S.split("."))||jt(l,S.split("."),O[f])}))})}function Et(l,u){let O=l;c["dot-notation"]||(u=[u.join(".")]),u.slice(0,-1).forEach(function(f){O=O[f]||{}});let b=u[u.length-1];return typeof O!="object"?!1:b in O}function jt(l,u,O){let b=l;c["dot-notation"]||(u=[u.join(".")]),u.slice(0,-1).forEach(function(it){it=En(it),typeof b=="object"&&b[it]===void 0&&(b[it]={}),typeof b[it]!="object"||Array.isArray(b[it])?(Array.isArray(b[it])?b[it].push({}):b[it]=[b[it],{}],b=b[it][b[it].length-1]):b=b[it]});let f=En(u[u.length-1]),S=D(u.join("."),d.arrays),x=Array.isArray(O),$=c["duplicate-arguments-array"];!$&&D(f,d.nargs)&&($=!0,(!yt(b[f])&&d.nargs[f]===1||Array.isArray(b[f])&&b[f].length===d.nargs[f])&&(b[f]=void 0)),O===Ne()?b[f]=Ne(b[f]):Array.isArray(b[f])?$&&S&&x?b[f]=c["flatten-duplicate-arrays"]?b[f].concat(O):(Array.isArray(b[f][0])?b[f]:[b[f]]).concat([O]):!$&&!!S==!!x?b[f]=O:b[f]=b[f].concat([O]):b[f]===void 0&&S?b[f]=x?O:[O]:$&&!(b[f]===void 0||D(f,d.counts)||D(f,d.bools))?b[f]=[b[f],O]:b[f]=O}function Nt(...l){l.forEach(function(u){Object.keys(u||{}).forEach(function(O){d.aliases[O]||(d.aliases[O]=[].concat(a[O]||[]),d.aliases[O].concat(O).forEach(function(b){if(/-/.test(b)&&c["camel-case-expansion"]){let f=Lt(b);f!==O&&d.aliases[O].indexOf(f)===-1&&(d.aliases[O].push(f),y[f]=!0)}}),d.aliases[O].concat(O).forEach(function(b){if(b.length>1&&/[A-Z]/.test(b)&&c["camel-case-expansion"]){let f=me(b,"-");f!==O&&d.aliases[O].indexOf(f)===-1&&(d.aliases[O].push(f),y[f]=!0)}}),d.aliases[O].forEach(function(b){d.aliases[b]=[O].concat(d.aliases[O].filter(function(f){return b!==f}))}))})})}function D(l,u){let O=[].concat(d.aliases[l]||[],l),b=Object.keys(u),f=O.find(S=>b.includes(S));return f?u[f]:!1}function Ie(l){let u=Object.keys(d);return[].concat(u.map(b=>d[b])).some(function(b){return Array.isArray(b)?b.includes(l):b[l]})}function v(l,...u){return[].concat(...u).some(function(b){let f=l.match(b);return f&&Ie(f[1])})}function K(l){if(l.match(L)||!l.match(/^-[^-]+/))return!1;let u=!0,O,b=l.slice(1).split("");for(let f=0;f<b.length;f++){if(O=l.slice(f+2),!Ie(b[f])){u=!1;break}if(b[f+1]&&b[f+1]==="="||O==="-"||/[A-Za-z]/.test(b[f])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(O)||b[f+1]&&b[f+1].match(/\W/))break}return u}function J(l){return c["unknown-options-as-args"]&&U(l)}function U(l){return l=l.replace(/^-{3,}/,"--"),l.match(L)||K(l)?!1:!v(l,/^-+([^=]+?)=[\s\S]*$/,z,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Z(l){return!D(l,d.bools)&&!D(l,d.counts)&&`${l}`in g?g[l]:k(wt(l))}function k(l){return{[ht.BOOLEAN]:!0,[ht.STRING]:"",[ht.NUMBER]:void 0,[ht.ARRAY]:[]}[l]}function wt(l){let u=ht.BOOLEAN;return D(l,d.strings)?u=ht.STRING:D(l,d.numbers)?u=ht.NUMBER:D(l,d.bools)?u=ht.BOOLEAN:D(l,d.arrays)&&(u=ht.ARRAY),u}function yt(l){return l===void 0}function fe(){Object.keys(d.counts).find(l=>D(l,d.arrays)?(T=Error(_("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0):D(l,d.nargs)?(T=Error(_("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0):!1)}return{aliases:Object.assign({},d.aliases),argv:Object.assign(at,H),configuration:c,defaulted:Object.assign({},E),error:T,newAliases:Object.assign({},y)}}};function Gi(s){let t=[],e=Object.create(null),n=!0;for(Object.keys(s).forEach(function(i){t.push([].concat(s[i],i))});n;){n=!1;for(let i=0;i<t.length;i++)for(let r=i+1;r<t.length;r++)if(t[i].filter(function(c){return t[r].indexOf(c)!==-1}).length){t[i]=t[i].concat(t[r]),t.splice(r,1),n=!0;break}}return t.forEach(function(i){i=i.filter(function(a,c,g){return g.indexOf(a)===c});let r=i.pop();r!==void 0&&typeof r=="string"&&(e[r]=i)}),e}function Ne(s){return s!==void 0?s+1:1}function En(s){return s==="__proto__"?"___proto___":s}function Vi(s){return typeof s=="string"&&(s[0]==="'"||s[0]==='"')&&s[s.length-1]===s[0]?s.substring(1,s.length-1):s}import{readFileSync as Ji}from"fs";var We,Le,Re,jn=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,An=(Le=(We=process==null?void 0:process.versions)===null||We===void 0?void 0:We.node)!==null&&Le!==void 0?Le:(Re=process==null?void 0:process.version)===null||Re===void 0?void 0:Re.slice(1);if(An&&Number(An.match(/^([^.]+)/)[1])<jn)throw Error(`yargs parser supports a minimum Node.js version of ${jn}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var Zi=process?process.env:{},Pn=new be({cwd:process.cwd,env:()=>Zi,format:qi,normalize:Ki,resolve:Qi,require:s=>{if(typeof _t<"u")return _t(s);if(s.match(/\.json$/))return JSON.parse(Ji(s,"utf8"));throw Error("only .json config files are supported in ESM")}}),se=function(t,e){return Pn.parse(t.slice(),e).argv};se.detailed=function(s,t){return Pn.parse(s.slice(),t)};se.camelCase=Lt;se.decamelize=me;se.looksLikeNumber=ge;var ze=se;import{basename as us,dirname as hs,extname as ds,relative as ps,resolve as Dn}from"path";function Sn(){return Xi()?0:1}function Xi(){return ki()&&!process.defaultApp}function ki(){return!!process.versions.electron}function Ue(s){return s.slice(Sn()+1)}function Mn(){return process.argv[Sn()]}var V=class s extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,s)}};import{readFileSync as ts,statSync as es,writeFile as ns}from"fs";import{format as is}from"util";import{resolve as ss}from"path";var In={fs:{readFileSync:ts,writeFile:ns},format:is,resolve:ss,exists:s=>{try{return es(s).isFile()}catch{return!1}}};var Ot,Te=class{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles=typeof t.updateFiles=="boolean"?t.updateFiles:!0,this.locale=t.locale||"en",this.fallbackToLanguage=typeof t.fallbackToLanguage=="boolean"?t.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let e=t.shift(),n=function(){};return typeof t[t.length-1]=="function"&&(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(),Ot.format.apply(Ot.format,[this.cache[this.locale][e]||e].concat(t))}__n(){let t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),i=t.shift(),r=function(){};typeof t[t.length-1]=="function"&&(r=t.pop()),this.cache[this.locale]||this._readLocaleFile();let a=i===1?e:n;this.cache[this.locale][e]&&(a=this.cache[this.locale][e][i===1?"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:r})):r();let c=[a];return~a.indexOf("%d")&&c.push(i),Ot.format.apply(Ot.format,c.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(let 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(i,r){let a=e[r+1];n+=i,typeof a<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let t=this,e=this.writeQueue[0],n=e.directory,i=e.locale,r=e.cb,a=this._resolveLocaleFile(n,i),c=JSON.stringify(this.cache[i],null,2);Ot.fs.writeFile(a,c,"utf-8",function(g){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),r(g)})}_readLocaleFile(){let t={},e=this._resolveLocaleFile(this.directory,this.locale);try{Ot.fs.readFileSync&&(t=JSON.parse(Ot.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),n.code==="ENOENT")t={};else throw n}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=Ot.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){let i=Ot.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(i)&&(n=i)}return n}_fileExistsSync(t){return Ot.exists(t)}};function $n(s,t){Ot=t;let e=new Te(s);return{__:e.__.bind(e),__n:e.__n.bind(e),setLocale:e.setLocale.bind(e),getLocale:e.getLocale.bind(e),updateLocale:e.updateLocale.bind(e),locale:e.locale}}var rs=s=>$n(s,In),vn=rs;var ms="require is not supported by ESM",Fn="loading a directory of commands is not supported yet for ESM",re;try{re=fs(import.meta.url)}catch{re=process.cwd()}var gs=re.substring(0,re.lastIndexOf("node_modules")),He={assert:{notStrictEqual:os,strictEqual:as},cliui:Fe,findUp:Cn,getEnv:s=>process.env[s],inspect:ls,getCallerFile:()=>{throw new V(Fn)},getProcessArgvBin:Mn,mainFilename:gs||process.cwd(),Parser:ze,path:{basename:us,dirname:hs,extname:ds,relative:ps,resolve:Dn},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(s,t)=>process.emitWarning(s,t),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:cs,require:()=>{throw new V(ms)},requireDirectory:()=>{throw new V(Fn)},stringWidth:s=>[...s].length,y18n:vn({directory:Dn(re,"../../../locales"),updateFiles:!1})};function ot(s,t,e,n){e.assert.notStrictEqual(s,t,n)}function Ye(s,t){t.assert.strictEqual(typeof s,"string")}function Xt(s){return Object.keys(s)}function q(s){return!!s&&!!s.then&&typeof s.then=="function"}function Pt(s){let e=s.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,i=e.shift();if(!i)throw new Error(`No command found in: ${s}`);let r={cmd:i.replace(n,""),demanded:[],optional:[]};return e.forEach((a,c)=>{let g=!1;a=a.replace(/\s/g,""),/\.+[\]>]/.test(a)&&c===e.length-1&&(g=!0),/^\[/.test(a)?r.optional.push({cmd:a.replace(n,"").split("|"),variadic:g}):r.demanded.push({cmd:a.replace(n,"").split("|"),variadic:g})}),r}var bs=["first","second","third","fourth","fifth","sixth"];function j(s,t,e){function n(){return typeof s=="object"?[{demanded:[],optional:[]},s,t]:[Pt(`cmd ${s}`),t,e]}try{let i=0,[r,a,c]=n(),g=[].slice.call(a);for(;g.length&&g[g.length-1]===void 0;)g.pop();let w=c||g.length;if(w<r.demanded.length)throw new V(`Not enough arguments provided. Expected ${r.demanded.length} but received ${g.length}.`);let p=r.demanded.length+r.optional.length;if(w>p)throw new V(`Too many arguments provided. Expected max ${p} but received ${w}.`);r.demanded.forEach(h=>{let m=g.shift(),y=Nn(m);h.cmd.filter(_=>_===y||_==="*").length===0&&Wn(y,h.cmd,i),i+=1}),r.optional.forEach(h=>{if(g.length===0)return;let m=g.shift(),y=Nn(m);h.cmd.filter(_=>_===y||_==="*").length===0&&Wn(y,h.cmd,i),i+=1})}catch(i){console.warn(i.stack)}}function Nn(s){return Array.isArray(s)?"array":s===null?"null":typeof s}function Wn(s,t,e){throw new V(`Invalid ${bs[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${s}.`)}var we=class{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,i=!1){if(j("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let r=0;r<t.length;r++){if(typeof t[r]!="function")throw Error("middleware must be a function");let a=t[r];a.applyBeforeValidation=e,a.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t=="function"){let r=t;r.applyBeforeValidation=e,r.global=n,r.mutates=i,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(i=>{let r=[...n[e]||[],e];return i.option?!r.includes(i.option):!0}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let t=this.frozens.pop();t!==void 0&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter(t=>t.global)}};function Ln(s){return s?s.map(t=>(t.applyBeforeValidation=!1,t)):[]}function Rt(s,t,e,n){return e.reduce((i,r)=>{if(r.applyBeforeValidation!==n)return i;if(r.mutates){if(r.applied)return i;r.applied=!0}if(q(i))return i.then(a=>Promise.all([a,r(a,t)])).then(([a,c])=>Object.assign(a,c));{let a=r(i,t);return q(a)?a.then(c=>Object.assign(i,c)):Object.assign(i,a)}},s)}function zt(s,t,e=n=>{throw n}){try{let n=ws(s)?s():s;return q(n)?n.then(i=>t(i)):t(n)}catch(n){return e(n)}}function ws(s){return typeof s=="function"}function Be(s){if(typeof _t>"u")return null;for(let t=0,e=Object.keys(_t.cache),n;t<e.length;t++)if(n=_t.cache[e[t]],n.exports===s)return n;return null}var kt=/(^\*)|(^\$0)/,Ge=class{constructor(t,e,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,i){i=i||{},typeof i.recurse!="boolean"&&(i.recurse=!1),Array.isArray(i.extensions)||(i.extensions=["js"]);let r=typeof i.visit=="function"?i.visit:a=>a;i.visit=(a,c,g)=>{let w=r(a,c,g);if(w){if(this.requireCache.has(c))return w;this.requireCache.add(c),this.addHandler(w)}return w},this.shim.requireDirectory({require:e,filename:n},t,i)}addHandler(t,e,n,i,r,a){let c=[],g=Ln(r);if(i=i||(()=>{}),Array.isArray(t))if(ys(t))[t,...c]=t;else for(let w of t)this.addHandler(w);else if(_s(t)){let w=Array.isArray(t.command)||typeof t.command=="string"?t.command:this.moduleName(t);t.aliases&&(w=[].concat(w).concat(t.aliases)),this.addHandler(w,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(Rn(n)){this.addHandler([t].concat(c),e,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof t=="string"){let w=Pt(t);c=c.map(m=>Pt(m).cmd);let p=!1,h=[w.cmd].concat(c).filter(m=>kt.test(m)?(p=!0,!1):!0);h.length===0&&p&&h.push("$0"),p&&(w.cmd=h[0],c=h.slice(1),t=t.replace(kt,w.cmd)),c.forEach(m=>{this.aliasMap[m]=w.cmd}),e!==!1&&this.usage.command(t,e,p,c,a),this.handlers[w.cmd]={original:t,description:e,handler:i,builder:n||{},middlewares:g,deprecated:a,demanded:w.demanded,optional:w.optional},p&&(this.defaultCommand=this.handlers[w.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,i,r,a){let c=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,g=e.getInternalMethods().getContext(),w=g.commands.slice(),p=!t;t&&(g.commands.push(t),g.fullCommands.push(c.original));let h=this.applyBuilderUpdateUsageAndParse(p,c,e,n.aliases,w,i,r,a);return q(h)?h.then(m=>this.applyMiddlewareAndGetResult(p,c,m.innerArgv,g,r,m.aliases,e)):this.applyMiddlewareAndGetResult(p,c,h.innerArgv,g,r,h.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,i,r,a,c,g){let w=e.builder,p=n;if(ye(w)){n.getInternalMethods().getUsageInstance().freeze();let h=w(n.getInternalMethods().reset(i),g);if(q(h))return h.then(m=>(p=Un(m)?m:n,this.parseAndUpdateUsage(t,e,p,r,a,c)))}else Os(w)&&(n.getInternalMethods().getUsageInstance().freeze(),p=n.getInternalMethods().reset(i),Object.keys(e.builder).forEach(h=>{p.option(h,w[h])}));return this.parseAndUpdateUsage(t,e,p,r,a,c)}parseAndUpdateUsage(t,e,n,i,r,a){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,e),e.description);let c=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,a);return q(c)?c.then(g=>({aliases:n.parsed.aliases,innerArgv:g})):{aliases:n.parsed.aliases,innerArgv:c}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){let n=kt.test(e.original)?e.original.replace(kt,"").trim():e.original,i=t.filter(r=>!kt.test(r));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(t,e,n,i,r,a,c,g){if(!a.getInternalMethods().getHasOutput()){let w=a.getInternalMethods().runValidation(r,g,a.parsed.error,t);n=zt(n,p=>(w(p),p))}if(e.handler&&!a.getInternalMethods().getHasOutput()){a.getInternalMethods().setHasOutput();let w=!!a.getOptions().configuration["populate--"];a.getInternalMethods().postProcess(n,w,!1,!1),n=Rt(n,a,c,!1),n=zt(n,p=>{let h=e.handler(p);return q(h)?h.then(()=>p):p}),t||a.getInternalMethods().getUsageInstance().cacheHelpMessage(),q(n)&&!a.getInternalMethods().hasParseCallback()&&n.catch(p=>{try{a.getInternalMethods().getUsageInstance().fail(null,p)}catch{}})}return t||(i.commands.pop(),i.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,i,r,a,c){let g={};if(r)return n;c.getInternalMethods().getHasOutput()||(g=this.populatePositionals(e,n,i,c));let w=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),p=Rt(n,c,w,!0);return q(p)?p.then(h=>this.handleValidationAndGetResult(t,e,h,i,a,c,w,g)):this.handleValidationAndGetResult(t,e,p,i,a,c,w,g)}populatePositionals(t,e,n,i){e._=e._.slice(n.commands.length);let r=t.demanded.slice(0),a=t.optional.slice(0),c={};for(this.validation.positionalCount(r.length,e._.length);r.length;){let g=r.shift();this.populatePositional(g,e,c)}for(;a.length;){let g=a.shift();this.populatePositional(g,e,c)}return e._=n.commands.concat(e._.map(g=>""+g)),this.postProcessPositionals(e,c,this.cmdToParseOptions(t.original),i),c}populatePositional(t,e,n){let i=t.cmd[0];t.variadic?n[i]=e._.splice(0).map(String):e._.length&&(n[i]=[String(e._.shift())])}cmdToParseOptions(t){let e={array:[],default:{},alias:{},demand:{}},n=Pt(t);return n.demanded.forEach(i=>{let[r,...a]=i.cmd;i.variadic&&(e.array.push(r),e.default[r]=[]),e.alias[r]=a,e.demand[r]=!0}),n.optional.forEach(i=>{let[r,...a]=i.cmd;i.variadic&&(e.array.push(r),e.default[r]=[]),e.alias[r]=a}),e}postProcessPositionals(t,e,n,i){let r=Object.assign({},i.getOptions());r.default=Object.assign(n.default,r.default);for(let w of Object.keys(n.alias))r.alias[w]=(r.alias[w]||[]).concat(n.alias[w]);r.array=r.array.concat(n.array),r.config={};let a=[];if(Object.keys(e).forEach(w=>{e[w].map(p=>{r.configuration["unknown-options-as-args"]&&(r.key[w]=!0),a.push(`--${w}`),a.push(p)})}),!a.length)return;let c=Object.assign({},r.configuration,{"populate--":!1}),g=this.shim.Parser.detailed(a,Object.assign({},r,{configuration:c}));if(g.error)i.getInternalMethods().getUsageInstance().fail(g.error.message,g.error);else{let w=Object.keys(e);Object.keys(e).forEach(p=>{w.push(...g.aliases[p])}),Object.keys(g.argv).forEach(p=>{w.includes(p)&&(e[p]||(e[p]=g.argv[p]),!this.isInConfigs(i,p)&&!this.isDefaulted(i,p)&&Object.prototype.hasOwnProperty.call(t,p)&&Object.prototype.hasOwnProperty.call(g.argv,p)&&(Array.isArray(t[p])||Array.isArray(g.argv[p]))?t[p]=[].concat(t[p],g.argv[p]):t[p]=g.argv[p])})}}isDefaulted(t,e){let{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){let{configObjects:n}=t.getOptions();return n.some(i=>Object.prototype.hasOwnProperty.call(i,e))||n.some(i=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){let n=kt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let e=this.defaultCommand.builder;if(ye(e))return e(t,!0);Rn(e)||Object.keys(e).forEach(n=>{t.option(n,e[n])})}moduleName(t){let e=Be(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(let i of[t,e,n]){if(typeof i=="string"||i===!1)return i;ot(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let 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 zn(s,t,e,n){return new Ge(s,t,e,n)}function Rn(s){return typeof s=="object"&&!!s.builder&&typeof s.handler=="function"}function ys(s){return s.every(t=>typeof t=="string")}function ye(s){return typeof s=="function"}function Os(s){return typeof s=="object"}function _s(s){return typeof s=="object"&&!Array.isArray(s)}function St(s={},t=()=>!0){let e={};return Xt(s).forEach(n=>{t(n,s[n])&&(e[n]=s[n])}),e}function Mt(s){typeof process>"u"||[process.stdout,process.stderr].forEach(t=>{let e=t;e._handle&&e.isTTY&&typeof e._handle.setBlocking=="function"&&e._handle.setBlocking(s)})}function Cs(s){return typeof s=="boolean"}function Hn(s,t){let e=t.y18n.__,n={},i=[];n.failFn=function(C){i.push(C)};let r=null,a=null,c=!0;n.showHelpOnFail=function(C=!0,P){let[W,B]=typeof C=="string"?[!0,C]:[C,P];return s.getInternalMethods().isGlobalContext()&&(a=B),r=B,c=W,n};let g=!1;n.fail=function(C,P){let W=s.getInternalMethods().getLoggerInstance();if(i.length)for(let B=i.length-1;B>=0;--B){let et=i[B];if(Cs(et)){if(P)throw P;if(C)throw Error(C)}else et(C,P,n)}else{if(s.getExitProcess()&&Mt(!0),!g){g=!0,c&&(s.showHelp("error"),W.error()),(C||P)&&W.error(C||P);let B=r||a;B&&((C||P)&&W.error(""),W.error(B))}if(P=P||new V(C),s.getExitProcess())return s.exit(1);if(s.getInternalMethods().hasParseCallback())return s.exit(1,P);throw P}};let w=[],p=!1;n.usage=(M,C)=>M===null?(p=!0,w=[],n):(p=!1,w.push([M,C||""]),n),n.getUsage=()=>w,n.getUsageDisabled=()=>p,n.getPositionalGroupName=()=>e("Positionals:");let h=[];n.example=(M,C)=>{h.push([M,C||""])};let m=[];n.command=function(C,P,W,B,et=!1){W&&(m=m.map(Y=>(Y[2]=!1,Y))),m.push([C,P||"",W,B,et])},n.getCommands=()=>m;let y={};n.describe=function(C,P){Array.isArray(C)?C.forEach(W=>{n.describe(W,P)}):typeof C=="object"?Object.keys(C).forEach(W=>{n.describe(W,C[W])}):y[C]=P},n.getDescriptions=()=>y;let E=[];n.epilog=M=>{E.push(M)};let _=!1,d;n.wrap=M=>{_=!0,d=M},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(_||(d=Jt(),_=!0),d);let L="__yargsString__:";n.deferY18nLookup=M=>L+M,n.help=function(){if(R)return R;T();let C=s.customScriptName?s.$0:t.path.basename(s.$0),P=s.getDemandedOptions(),W=s.getDemandedCommands(),B=s.getDeprecatedOptions(),et=s.getGroups(),Y=s.getOptions(),nt=[];nt=nt.concat(Object.keys(y)),nt=nt.concat(Object.keys(P)),nt=nt.concat(Object.keys(W)),nt=nt.concat(Object.keys(Y.default)),nt=nt.filter(at),nt=Object.keys(nt.reduce((v,K)=>(K!=="_"&&(v[K]=!0),v),{}));let Ft=n.getWrap(),Q=t.cliui({width:Ft,wrap:!!Ft});if(!p){if(w.length)w.forEach(v=>{Q.div({text:`${v[0].replace(/\$0/g,C)}`}),v[1]&&Q.div({text:`${v[1]}`,padding:[1,0,0,0]})}),Q.div();else if(m.length){let v=null;W._?v=`${C} <${e("command")}>
9
+ `),r.border&&(i.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(r)+2)+"'")),r.padding&&(i.unshift(...new Array(r.padding[qi]||0).fill("")),i.push(...new Array(r.padding[Gi]||0).fill(""))),i.forEach((l,m)=>{e[m]||e.push([]);let w=e[m];for(let p=0;p<a;p++)w[p]===void 0&&w.push("");w.push(l)})}),e}negatePadding(t){let e=t.width||0;return t.padding&&(e-=(t.padding[pe]||0)+(t.padding[de]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map(a=>a.width||lt.stringWidth(a.text));let e=t.length,n=this.width,i=t.map(a=>{if(a.width)return e--,n-=a.width,a.width}),r=e?Math.floor(n/e):0;return i.map((a,l)=>a===void 0?Math.max(r,Vi(t[l])):a)}};function _n(s,t,e){return s.border?/[.']-+[.']/.test(t)?"":t.trim().length!==0?e:" ":""}function Vi(s){let t=s.padding||[],e=1+(t[pe]||0)+(t[de]||0);return s.border?e+4:e}function Ki(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Qi(s,t){s=s.trim();let e=lt.stringWidth(s);return e<t?" ".repeat(t-e)+s:s}function Ji(s,t){s=s.trim();let e=lt.stringWidth(s);return e>=t?s:" ".repeat(t-e>>1)+s}var lt;function Cn(s,t){return lt=t,new Ne({width:s?.width||Ki(),wrap:s?.wrap})}var xn=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function Le(s){return s.replace(xn,"")}function En(s,t){let[e,n]=s.match(xn)||["",""];s=Le(s);let i="";for(let r=0;r<s.length;r++)r!==0&&r%t===0&&(i+=`
10
+ `),i+=s.charAt(r);return e&&n&&(i=`${e}${i}${n}`),i}function We(s){return Cn(s,{stringWidth:t=>[...t].length,stripAnsi:Le,wrap:En})}import{dirname as jn,resolve as An}from"path";import{readdirSync as Zi,statSync as Xi}from"fs";function Pn(s,t){let e=An(".",s),n;for(Xi(e).isDirectory()||(e=jn(e));;){if(n=t(e,Zi(e)),n)return An(e,n);if(e=jn(n=e),n===e)break}}import{inspect as gs}from"util";import{readFileSync as bs}from"fs";import{fileURLToPath as ws}from"url";import{format as es}from"util";import{normalize as ns,resolve as is}from"path";function Lt(s){if(s!==s.toLowerCase()&&s!==s.toUpperCase()||(s=s.toLowerCase()),s.indexOf("-")===-1&&s.indexOf("_")===-1)return s;{let e="",n=!1,i=s.match(/^-+/);for(let r=i?i[0].length:0;r<s.length;r++){let a=s.charAt(r);n&&(n=!1,a=a.toUpperCase()),r!==0&&(a==="-"||a==="_")?n=!0:a!=="-"&&a!=="_"&&(e+=a)}return e}}function me(s,t){let e=s.toLowerCase();t=t||"-";let n="";for(let i=0;i<s.length;i++){let r=e.charAt(i),a=s.charAt(i);r!==a&&i>0?n+=`${t}${e.charAt(i)}`:n+=a}return n}function ge(s){return s==null?!1:typeof s=="number"||/^0x[0-9a-f]+$/i.test(s)?!0:/^0[^.]/.test(s)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(s)}function Sn(s){if(Array.isArray(s))return s.map(a=>typeof a!="string"?a+"":a);s=s.trim();let t=0,e=null,n=null,i=null,r=[];for(let a=0;a<s.length;a++){if(e=n,n=s.charAt(a),n===" "&&!i){e!==" "&&t++;continue}n===i?i=null:(n==="'"||n==='"')&&!i&&(i=n),r[t]||(r[t]=""),r[t]+=n}return r}var ht;(function(s){s.BOOLEAN="boolean",s.STRING="string",s.NUMBER="number",s.ARRAY="array"})(ht||(ht={}));var At,be=class{constructor(t){At=t}parse(t,e){let 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),i=Sn(t),r=typeof t=="string",a=ki(Object.assign(Object.create(null),n.alias)),l=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),m=Object.assign(Object.create(null),n.default),w=n.configObjects||[],p=n.envPrefix,h=l["populate--"],g=h?"--":"_",y=Object.create(null),E=Object.create(null),_=n.__||At.format,d={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:[]},W=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,R=new RegExp("^--"+l["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(c){let u=typeof c=="object"?c.key:c,O=Object.keys(c).map(function(b){return{boolean:"bools",string:"strings",number:"numbers"}[b]}).filter(Boolean).pop();O&&(d[O][u]=!0),d.arrays[u]=!0,d.keys.push(u)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(c){d.bools[c]=!0,d.keys.push(c)}),[].concat(n.string||[]).filter(Boolean).forEach(function(c){d.strings[c]=!0,d.keys.push(c)}),[].concat(n.number||[]).filter(Boolean).forEach(function(c){d.numbers[c]=!0,d.keys.push(c)}),[].concat(n.count||[]).filter(Boolean).forEach(function(c){d.counts[c]=!0,d.keys.push(c)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(c){d.normalize[c]=!0,d.keys.push(c)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([c,u])=>{typeof u=="number"&&(d.nargs[c]=u,d.keys.push(c))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([c,u])=>{typeof u=="function"&&(d.coercions[c]=u,d.keys.push(c))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(c){d.configs[c]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([c,u])=>{(typeof u=="boolean"||typeof u=="function")&&(d.configs[c]=u)})),Nt(n.key,a,n.default,d.arrays),Object.keys(m).forEach(function(c){(d.aliases[c]||[]).forEach(function(u){m[u]=m[c]})});let Y=null;ue();let U=[],T=Object.assign(Object.create(null),{_:[]}),rt={};for(let c=0;c<i.length;c++){let u=i[c],O=u.replace(/^-{3,}/,"---"),b,f,S,x,$,it;if(u!=="--"&&/^-/.test(u)&&J(u))bt(u);else if(O.match(/^---+(=|$)/)){bt(u);continue}else if(u.match(/^--.+=/)||!l["short-option-groups"]&&u.match(/^-.+=/))x=u.match(/^--?([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&(F(x[1],d.arrays)?c=Ft(c,x[1],i,x[2]):F(x[1],d.nargs)!==!1?c=Qt(c,x[1],i,x[2]):q(x[1],x[2],!0));else if(u.match(R)&&l["boolean-negation"])x=u.match(R),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],q(f,F(f,d.arrays)?[!1]:!1));else if(u.match(/^--.+/)||!l["short-option-groups"]&&u.match(/^-[^-]+/))x=u.match(/^--?(.+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],F(f,d.arrays)?c=Ft(c,f,i):F(f,d.nargs)!==!1?c=Qt(c,f,i):($=i[c+1],$!==void 0&&(!$.match(/^-/)||$.match(W))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(q(f,$),c++):q(f,Z(f))));else if(u.match(/^-.\..+=/))x=u.match(/^-([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&q(x[1],x[2]);else if(u.match(/^-.\..+/)&&!u.match(W))$=i[c+1],x=u.match(/^-(.\..+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],$!==void 0&&!$.match(/^-/)&&!F(f,d.bools)&&!F(f,d.counts)?(q(f,$),c++):q(f,Z(f)));else if(u.match(/^-[^-]+/)&&!u.match(W)){S=u.slice(1,-1).split(""),b=!1;for(let ot=0;ot<S.length;ot++){if($=u.slice(ot+2),S[ot+1]&&S[ot+1]==="="){it=u.slice(ot+3),f=S[ot],F(f,d.arrays)?c=Ft(c,f,i,it):F(f,d.nargs)!==!1?c=Qt(c,f,i,it):q(f,it),b=!0;break}if($==="-"){q(S[ot],$);continue}if(/[A-Za-z]/.test(S[ot])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test($)&&F($,d.bools)===!1){q(S[ot],$),b=!0;break}if(S[ot+1]&&S[ot+1].match(/\W/)){q(S[ot],$),b=!0;break}else q(S[ot],Z(S[ot]))}f=u.slice(-1)[0],!b&&f!=="-"&&(F(f,d.arrays)?c=Ft(c,f,i):F(f,d.nargs)!==!1?c=Qt(c,f,i):($=i[c+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(W))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(q(f,$),c++):q(f,Z(f))))}else if(u.match(/^-[0-9]$/)&&u.match(W)&&F(u.slice(1),d.bools))f=u.slice(1),q(f,Z(f));else if(u==="--"){U=i.slice(c+1);break}else if(l["halt-at-non-option"]){U=i.slice(c);break}else bt(u)}H(T,!0),H(T,!1),L(T),et(),Q(T,d.aliases,m,!0),nt(T),l["set-placeholder-key"]&&Dt(T),Object.keys(d.counts).forEach(function(c){Et(T,c.split("."))||q(c,0)}),h&&U.length&&(T[g]=[]),U.forEach(function(c){T[g].push(c)}),l["camel-case-expansion"]&&l["strip-dashed"]&&Object.keys(T).filter(c=>c!=="--"&&c.includes("-")).forEach(c=>{delete T[c]}),l["strip-aliased"]&&[].concat(...Object.keys(a).map(c=>a[c])).forEach(c=>{l["camel-case-expansion"]&&c.includes("-")&&delete T[c.split(".").map(u=>Lt(u)).join(".")],delete T[c]});function bt(c){let u=P("_",c);(typeof u=="string"||typeof u=="number")&&T._.push(u)}function Qt(c,u,O,b){let f,S=F(u,d.nargs);if(S=typeof S!="number"||isNaN(S)?1:S,S===0)return yt(b)||(Y=Error(_("Argument unexpected for: %s",u))),q(u,Z(u)),c;let x=yt(b)?0:1;if(l["nargs-eats-options"])O.length-(c+1)+x<S&&(Y=Error(_("Not enough arguments following: %s",u))),x=S;else{for(f=c+1;f<O.length&&(!O[f].match(/^-[^0-9]/)||O[f].match(W)||J(O[f]));f++)x++;x<S&&(Y=Error(_("Not enough arguments following: %s",u)))}let $=Math.min(x,S);for(!yt(b)&&$>0&&(q(u,b),$--),f=c+1;f<$+c+1;f++)q(u,O[f]);return c+$}function Ft(c,u,O,b){let f=[],S=b||O[c+1],x=F(u,d.nargs);if(F(u,d.bools)&&!/^(true|false)$/.test(S))f.push(!0);else if(yt(S)||yt(b)&&/^-/.test(S)&&!W.test(S)&&!J(S)){if(m[u]!==void 0){let $=m[u];f=Array.isArray($)?$:[$]}}else{yt(b)||f.push(C(u,b,!0));for(let $=c+1;$<O.length&&!(!l["greedy-arrays"]&&f.length>0||x&&typeof x=="number"&&f.length>=x||(S=O[$],/^-/.test(S)&&!W.test(S)&&!J(S)));$++)c=$,f.push(C(u,S,r))}return typeof x=="number"&&(x&&f.length<x||isNaN(x)&&f.length===0)&&(Y=Error(_("Not enough arguments following: %s",u))),q(u,f),c}function q(c,u,O=r){if(/-/.test(c)&&l["camel-case-expansion"]){let S=c.split(".").map(function(x){return Lt(x)}).join(".");M(c,S)}let b=C(c,u,O),f=c.split(".");jt(T,f,b),d.aliases[c]&&d.aliases[c].forEach(function(S){let x=S.split(".");jt(T,x,b)}),f.length>1&&l["dot-notation"]&&(d.aliases[f[0]]||[]).forEach(function(S){let x=S.split("."),$=[].concat(f);$.shift(),x=x.concat($),(d.aliases[c]||[]).includes(x.join("."))||jt(T,x,b)}),F(c,d.normalize)&&!F(c,d.arrays)&&[c].concat(d.aliases[c]||[]).forEach(function(x){Object.defineProperty(rt,x,{enumerable:!0,get(){return u},set($){u=typeof $=="string"?At.normalize($):$}})})}function M(c,u){d.aliases[c]&&d.aliases[c].length||(d.aliases[c]=[u],y[u]=!0),d.aliases[u]&&d.aliases[u].length||M(u,c)}function C(c,u,O){O&&(u=ts(u)),(F(c,d.bools)||F(c,d.counts))&&typeof u=="string"&&(u=u==="true");let b=Array.isArray(u)?u.map(function(f){return P(c,f)}):P(c,u);return F(c,d.counts)&&(yt(b)||typeof b=="boolean")&&(b=Re()),F(c,d.normalize)&&F(c,d.arrays)&&(Array.isArray(u)?b=u.map(f=>At.normalize(f)):b=At.normalize(u)),b}function P(c,u){return!l["parse-positional-numbers"]&&c==="_"||!F(c,d.strings)&&!F(c,d.bools)&&!Array.isArray(u)&&(ge(u)&&l["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${u}`)))||!yt(u)&&F(c,d.numbers))&&(u=Number(u)),u}function L(c){let u=Object.create(null);Q(u,d.aliases,m),Object.keys(d.configs).forEach(function(O){let b=c[O]||u[O];if(b)try{let f=null,S=At.resolve(At.cwd(),b),x=d.configs[O];if(typeof x=="function"){try{f=x(S)}catch($){f=$}if(f instanceof Error){Y=f;return}}else f=At.require(S);B(f)}catch(f){f.name==="PermissionDenied"?Y=f:c[O]&&(Y=Error(_("Invalid JSON config file: %s",b)))}})}function B(c,u){Object.keys(c).forEach(function(O){let b=c[O],f=u?u+"."+O:O;typeof b=="object"&&b!==null&&!Array.isArray(b)&&l["dot-notation"]?B(b,f):(!Et(T,f.split("."))||F(f,d.arrays)&&l["combine-arrays"])&&q(f,b)})}function et(){typeof w<"u"&&w.forEach(function(c){B(c)})}function H(c,u){if(typeof p>"u")return;let O=typeof p=="string"?p:"",b=At.env();Object.keys(b).forEach(function(f){if(O===""||f.lastIndexOf(O,0)===0){let S=f.split("__").map(function(x,$){return $===0&&(x=x.substring(O.length)),Lt(x)});(u&&d.configs[S.join(".")]||!u)&&!Et(c,S)&&q(S.join("."),b[f])}})}function nt(c){let u,O=new Set;Object.keys(c).forEach(function(b){if(!O.has(b)&&(u=F(b,d.coercions),typeof u=="function"))try{let f=P(b,u(c[b]));[].concat(d.aliases[b]||[],b).forEach(S=>{O.add(S),c[S]=f})}catch(f){Y=f}})}function Dt(c){return d.keys.forEach(u=>{~u.indexOf(".")||typeof c[u]>"u"&&(c[u]=void 0)}),c}function Q(c,u,O,b=!1){Object.keys(O).forEach(function(f){Et(c,f.split("."))||(jt(c,f.split("."),O[f]),b&&(E[f]=!0),(u[f]||[]).forEach(function(S){Et(c,S.split("."))||jt(c,S.split("."),O[f])}))})}function Et(c,u){let O=c;l["dot-notation"]||(u=[u.join(".")]),u.slice(0,-1).forEach(function(f){O=O[f]||{}});let b=u[u.length-1];return typeof O!="object"?!1:b in O}function jt(c,u,O){let b=c;l["dot-notation"]||(u=[u.join(".")]),u.slice(0,-1).forEach(function(it){it=Mn(it),typeof b=="object"&&b[it]===void 0&&(b[it]={}),typeof b[it]!="object"||Array.isArray(b[it])?(Array.isArray(b[it])?b[it].push({}):b[it]=[b[it],{}],b=b[it][b[it].length-1]):b=b[it]});let f=Mn(u[u.length-1]),S=F(u.join("."),d.arrays),x=Array.isArray(O),$=l["duplicate-arguments-array"];!$&&F(f,d.nargs)&&($=!0,(!yt(b[f])&&d.nargs[f]===1||Array.isArray(b[f])&&b[f].length===d.nargs[f])&&(b[f]=void 0)),O===Re()?b[f]=Re(b[f]):Array.isArray(b[f])?$&&S&&x?b[f]=l["flatten-duplicate-arrays"]?b[f].concat(O):(Array.isArray(b[f][0])?b[f]:[b[f]]).concat([O]):!$&&!!S==!!x?b[f]=O:b[f]=b[f].concat([O]):b[f]===void 0&&S?b[f]=x?O:[O]:$&&!(b[f]===void 0||F(f,d.counts)||F(f,d.bools))?b[f]=[b[f],O]:b[f]=O}function Nt(...c){c.forEach(function(u){Object.keys(u||{}).forEach(function(O){d.aliases[O]||(d.aliases[O]=[].concat(a[O]||[]),d.aliases[O].concat(O).forEach(function(b){if(/-/.test(b)&&l["camel-case-expansion"]){let f=Lt(b);f!==O&&d.aliases[O].indexOf(f)===-1&&(d.aliases[O].push(f),y[f]=!0)}}),d.aliases[O].concat(O).forEach(function(b){if(b.length>1&&/[A-Z]/.test(b)&&l["camel-case-expansion"]){let f=me(b,"-");f!==O&&d.aliases[O].indexOf(f)===-1&&(d.aliases[O].push(f),y[f]=!0)}}),d.aliases[O].forEach(function(b){d.aliases[b]=[O].concat(d.aliases[O].filter(function(f){return b!==f}))}))})})}function F(c,u){let O=[].concat(d.aliases[c]||[],c),b=Object.keys(u),f=O.find(S=>b.includes(S));return f?u[f]:!1}function Ie(c){let u=Object.keys(d);return[].concat(u.map(b=>d[b])).some(function(b){return Array.isArray(b)?b.includes(c):b[c]})}function v(c,...u){return[].concat(...u).some(function(b){let f=c.match(b);return f&&Ie(f[1])})}function K(c){if(c.match(W)||!c.match(/^-[^-]+/))return!1;let u=!0,O,b=c.slice(1).split("");for(let f=0;f<b.length;f++){if(O=c.slice(f+2),!Ie(b[f])){u=!1;break}if(b[f+1]&&b[f+1]==="="||O==="-"||/[A-Za-z]/.test(b[f])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(O)||b[f+1]&&b[f+1].match(/\W/))break}return u}function J(c){return l["unknown-options-as-args"]&&z(c)}function z(c){return c=c.replace(/^-{3,}/,"--"),c.match(W)||K(c)?!1:!v(c,/^-+([^=]+?)=[\s\S]*$/,R,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Z(c){return!F(c,d.bools)&&!F(c,d.counts)&&`${c}`in m?m[c]:k(wt(c))}function k(c){return{[ht.BOOLEAN]:!0,[ht.STRING]:"",[ht.NUMBER]:void 0,[ht.ARRAY]:[]}[c]}function wt(c){let u=ht.BOOLEAN;return F(c,d.strings)?u=ht.STRING:F(c,d.numbers)?u=ht.NUMBER:F(c,d.bools)?u=ht.BOOLEAN:F(c,d.arrays)&&(u=ht.ARRAY),u}function yt(c){return c===void 0}function ue(){Object.keys(d.counts).find(c=>F(c,d.arrays)?(Y=Error(_("Invalid configuration: %s, opts.count excludes opts.array.",c)),!0):F(c,d.nargs)?(Y=Error(_("Invalid configuration: %s, opts.count excludes opts.narg.",c)),!0):!1)}return{aliases:Object.assign({},d.aliases),argv:Object.assign(rt,T),configuration:l,defaulted:Object.assign({},E),error:Y,newAliases:Object.assign({},y)}}};function ki(s){let t=[],e=Object.create(null),n=!0;for(Object.keys(s).forEach(function(i){t.push([].concat(s[i],i))});n;){n=!1;for(let i=0;i<t.length;i++)for(let r=i+1;r<t.length;r++)if(t[i].filter(function(l){return t[r].indexOf(l)!==-1}).length){t[i]=t[i].concat(t[r]),t.splice(r,1),n=!0;break}}return t.forEach(function(i){i=i.filter(function(a,l,m){return m.indexOf(a)===l});let r=i.pop();r!==void 0&&typeof r=="string"&&(e[r]=i)}),e}function Re(s){return s!==void 0?s+1:1}function Mn(s){return s==="__proto__"?"___proto___":s}function ts(s){return typeof s=="string"&&(s[0]==="'"||s[0]==='"')&&s[s.length-1]===s[0]?s.substring(1,s.length-1):s}import{readFileSync as ss}from"fs";var Ue,ze,Te,In=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,$n=(ze=(Ue=process==null?void 0:process.versions)===null||Ue===void 0?void 0:Ue.node)!==null&&ze!==void 0?ze:(Te=process==null?void 0:process.version)===null||Te===void 0?void 0:Te.slice(1);if($n&&Number($n.match(/^([^.]+)/)[1])<In)throw Error(`yargs parser supports a minimum Node.js version of ${In}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var rs=process?process.env:{},vn=new be({cwd:process.cwd,env:()=>rs,format:es,normalize:ns,resolve:is,require:s=>{if(typeof _t<"u")return _t(s);if(s.match(/\.json$/))return JSON.parse(ss(s,"utf8"));throw Error("only .json config files are supported in ESM")}}),re=function(t,e){return vn.parse(t.slice(),e).argv};re.detailed=function(s,t){return vn.parse(s.slice(),t)};re.camelCase=Lt;re.decamelize=me;re.looksLikeNumber=ge;var He=re;import{basename as ys,dirname as Os,extname as _s,relative as Cs,resolve as Rn}from"path";function Fn(){return os()?0:1}function os(){return as()&&!process.defaultApp}function as(){return!!process.versions.electron}function Be(s){return s.slice(Fn()+1)}function Dn(){return process.argv[Fn()]}var G=class s extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,s)}};import{readFileSync as ls,statSync as cs,writeFile as fs}from"fs";import{format as us}from"util";import{resolve as hs}from"path";var Nn={fs:{readFileSync:ls,writeFile:fs},format:us,resolve:hs,exists:s=>{try{return cs(s).isFile()}catch{return!1}}};var Ot,Ye=class{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles=typeof t.updateFiles=="boolean"?t.updateFiles:!0,this.locale=t.locale||"en",this.fallbackToLanguage=typeof t.fallbackToLanguage=="boolean"?t.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let e=t.shift(),n=function(){};return typeof t[t.length-1]=="function"&&(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(),Ot.format.apply(Ot.format,[this.cache[this.locale][e]||e].concat(t))}__n(){let t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),i=t.shift(),r=function(){};typeof t[t.length-1]=="function"&&(r=t.pop()),this.cache[this.locale]||this._readLocaleFile();let a=i===1?e:n;this.cache[this.locale][e]&&(a=this.cache[this.locale][e][i===1?"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:r})):r();let l=[a];return~a.indexOf("%d")&&l.push(i),Ot.format.apply(Ot.format,l.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(let 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(i,r){let a=e[r+1];n+=i,typeof a<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let t=this,e=this.writeQueue[0],n=e.directory,i=e.locale,r=e.cb,a=this._resolveLocaleFile(n,i),l=JSON.stringify(this.cache[i],null,2);Ot.fs.writeFile(a,l,"utf-8",function(m){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),r(m)})}_readLocaleFile(){let t={},e=this._resolveLocaleFile(this.directory,this.locale);try{Ot.fs.readFileSync&&(t=JSON.parse(Ot.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),n.code==="ENOENT")t={};else throw n}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=Ot.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){let i=Ot.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(i)&&(n=i)}return n}_fileExistsSync(t){return Ot.exists(t)}};function Ln(s,t){Ot=t;let e=new Ye(s);return{__:e.__.bind(e),__n:e.__n.bind(e),setLocale:e.setLocale.bind(e),getLocale:e.getLocale.bind(e),updateLocale:e.updateLocale.bind(e),locale:e.locale}}var ds=s=>Ln(s,Nn),Wn=ds;var xs="require is not supported by ESM",Un="loading a directory of commands is not supported yet for ESM",oe;try{oe=ws(import.meta.url)}catch{oe=process.cwd()}var Es=oe.substring(0,oe.lastIndexOf("node_modules")),qe={assert:{notStrictEqual:ps,strictEqual:ms},cliui:We,findUp:Pn,getEnv:s=>process.env[s],inspect:gs,getCallerFile:()=>{throw new G(Un)},getProcessArgvBin:Dn,mainFilename:Es||process.cwd(),Parser:He,path:{basename:ys,dirname:Os,extname:_s,relative:Cs,resolve:Rn},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(s,t)=>process.emitWarning(s,t),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:bs,require:()=>{throw new G(xs)},requireDirectory:()=>{throw new G(Un)},stringWidth:s=>[...s].length,y18n:Wn({directory:Rn(oe,"../../../locales"),updateFiles:!1})};function at(s,t,e,n){e.assert.notStrictEqual(s,t,n)}function Ge(s,t){t.assert.strictEqual(typeof s,"string")}function Xt(s){return Object.keys(s)}function V(s){return!!s&&!!s.then&&typeof s.then=="function"}function Pt(s){let e=s.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,i=e.shift();if(!i)throw new Error(`No command found in: ${s}`);let r={cmd:i.replace(n,""),demanded:[],optional:[]};return e.forEach((a,l)=>{let m=!1;a=a.replace(/\s/g,""),/\.+[\]>]/.test(a)&&l===e.length-1&&(m=!0),/^\[/.test(a)?r.optional.push({cmd:a.replace(n,"").split("|"),variadic:m}):r.demanded.push({cmd:a.replace(n,"").split("|"),variadic:m})}),r}var js=["first","second","third","fourth","fifth","sixth"];function j(s,t,e){function n(){return typeof s=="object"?[{demanded:[],optional:[]},s,t]:[Pt(`cmd ${s}`),t,e]}try{let i=0,[r,a,l]=n(),m=[].slice.call(a);for(;m.length&&m[m.length-1]===void 0;)m.pop();let w=l||m.length;if(w<r.demanded.length)throw new G(`Not enough arguments provided. Expected ${r.demanded.length} but received ${m.length}.`);let p=r.demanded.length+r.optional.length;if(w>p)throw new G(`Too many arguments provided. Expected max ${p} but received ${w}.`);r.demanded.forEach(h=>{let g=m.shift(),y=zn(g);h.cmd.filter(_=>_===y||_==="*").length===0&&Tn(y,h.cmd,i),i+=1}),r.optional.forEach(h=>{if(m.length===0)return;let g=m.shift(),y=zn(g);h.cmd.filter(_=>_===y||_==="*").length===0&&Tn(y,h.cmd,i),i+=1})}catch(i){console.warn(i.stack)}}function zn(s){return Array.isArray(s)?"array":s===null?"null":typeof s}function Tn(s,t,e){throw new G(`Invalid ${js[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${s}.`)}var we=class{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,i=!1){if(j("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let r=0;r<t.length;r++){if(typeof t[r]!="function")throw Error("middleware must be a function");let a=t[r];a.applyBeforeValidation=e,a.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t=="function"){let r=t;r.applyBeforeValidation=e,r.global=n,r.mutates=i,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(i=>{let r=[...n[e]||[],e];return i.option?!r.includes(i.option):!0}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let t=this.frozens.pop();t!==void 0&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter(t=>t.global)}};function Hn(s){return s?s.map(t=>(t.applyBeforeValidation=!1,t)):[]}function Wt(s,t,e,n){return e.reduce((i,r)=>{if(r.applyBeforeValidation!==n)return i;if(r.mutates){if(r.applied)return i;r.applied=!0}if(V(i))return i.then(a=>Promise.all([a,r(a,t)])).then(([a,l])=>Object.assign(a,l));{let a=r(i,t);return V(a)?a.then(l=>Object.assign(i,l)):Object.assign(i,a)}},s)}function Rt(s,t,e=n=>{throw n}){try{let n=As(s)?s():s;return V(n)?n.then(i=>t(i)):t(n)}catch(n){return e(n)}}function As(s){return typeof s=="function"}function Ve(s){if(typeof _t>"u")return null;for(let t=0,e=Object.keys(_t.cache),n;t<e.length;t++)if(n=_t.cache[e[t]],n.exports===s)return n;return null}var kt=/(^\*)|(^\$0)/,Ke=class{constructor(t,e,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,i){i=i||{},typeof i.recurse!="boolean"&&(i.recurse=!1),Array.isArray(i.extensions)||(i.extensions=["js"]);let r=typeof i.visit=="function"?i.visit:a=>a;i.visit=(a,l,m)=>{let w=r(a,l,m);if(w){if(this.requireCache.has(l))return w;this.requireCache.add(l),this.addHandler(w)}return w},this.shim.requireDirectory({require:e,filename:n},t,i)}addHandler(t,e,n,i,r,a){let l=[],m=Hn(r);if(i=i||(()=>{}),Array.isArray(t))if(Ps(t))[t,...l]=t;else for(let w of t)this.addHandler(w);else if(Ms(t)){let w=Array.isArray(t.command)||typeof t.command=="string"?t.command:this.moduleName(t);t.aliases&&(w=[].concat(w).concat(t.aliases)),this.addHandler(w,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(Bn(n)){this.addHandler([t].concat(l),e,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof t=="string"){let w=Pt(t);l=l.map(g=>Pt(g).cmd);let p=!1,h=[w.cmd].concat(l).filter(g=>kt.test(g)?(p=!0,!1):!0);h.length===0&&p&&h.push("$0"),p&&(w.cmd=h[0],l=h.slice(1),t=t.replace(kt,w.cmd)),l.forEach(g=>{this.aliasMap[g]=w.cmd}),e!==!1&&this.usage.command(t,e,p,l,a),this.handlers[w.cmd]={original:t,description:e,handler:i,builder:n||{},middlewares:m,deprecated:a,demanded:w.demanded,optional:w.optional},p&&(this.defaultCommand=this.handlers[w.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,i,r,a){let l=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,m=e.getInternalMethods().getContext(),w=m.commands.slice(),p=!t;t&&(m.commands.push(t),m.fullCommands.push(l.original));let h=this.applyBuilderUpdateUsageAndParse(p,l,e,n.aliases,w,i,r,a);return V(h)?h.then(g=>this.applyMiddlewareAndGetResult(p,l,g.innerArgv,m,r,g.aliases,e)):this.applyMiddlewareAndGetResult(p,l,h.innerArgv,m,r,h.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,i,r,a,l,m){let w=e.builder,p=n;if(ye(w)){n.getInternalMethods().getUsageInstance().freeze();let h=w(n.getInternalMethods().reset(i),m);if(V(h))return h.then(g=>(p=qn(g)?g:n,this.parseAndUpdateUsage(t,e,p,r,a,l)))}else Ss(w)&&(n.getInternalMethods().getUsageInstance().freeze(),p=n.getInternalMethods().reset(i),Object.keys(e.builder).forEach(h=>{p.option(h,w[h])}));return this.parseAndUpdateUsage(t,e,p,r,a,l)}parseAndUpdateUsage(t,e,n,i,r,a){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,e),e.description);let l=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,a);return V(l)?l.then(m=>({aliases:n.parsed.aliases,innerArgv:m})):{aliases:n.parsed.aliases,innerArgv:l}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){let n=kt.test(e.original)?e.original.replace(kt,"").trim():e.original,i=t.filter(r=>!kt.test(r));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(t,e,n,i,r,a,l,m){if(!a.getInternalMethods().getHasOutput()){let w=a.getInternalMethods().runValidation(r,m,a.parsed.error,t);n=Rt(n,p=>(w(p),p))}if(e.handler&&!a.getInternalMethods().getHasOutput()){a.getInternalMethods().setHasOutput();let w=!!a.getOptions().configuration["populate--"];a.getInternalMethods().postProcess(n,w,!1,!1),n=Wt(n,a,l,!1),n=Rt(n,p=>{let h=e.handler(p);return V(h)?h.then(()=>p):p}),t||a.getInternalMethods().getUsageInstance().cacheHelpMessage(),V(n)&&!a.getInternalMethods().hasParseCallback()&&n.catch(p=>{try{a.getInternalMethods().getUsageInstance().fail(null,p)}catch{}})}return t||(i.commands.pop(),i.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,i,r,a,l){let m={};if(r)return n;l.getInternalMethods().getHasOutput()||(m=this.populatePositionals(e,n,i,l));let w=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),p=Wt(n,l,w,!0);return V(p)?p.then(h=>this.handleValidationAndGetResult(t,e,h,i,a,l,w,m)):this.handleValidationAndGetResult(t,e,p,i,a,l,w,m)}populatePositionals(t,e,n,i){e._=e._.slice(n.commands.length);let r=t.demanded.slice(0),a=t.optional.slice(0),l={};for(this.validation.positionalCount(r.length,e._.length);r.length;){let m=r.shift();this.populatePositional(m,e,l)}for(;a.length;){let m=a.shift();this.populatePositional(m,e,l)}return e._=n.commands.concat(e._.map(m=>""+m)),this.postProcessPositionals(e,l,this.cmdToParseOptions(t.original),i),l}populatePositional(t,e,n){let i=t.cmd[0];t.variadic?n[i]=e._.splice(0).map(String):e._.length&&(n[i]=[String(e._.shift())])}cmdToParseOptions(t){let e={array:[],default:{},alias:{},demand:{}},n=Pt(t);return n.demanded.forEach(i=>{let[r,...a]=i.cmd;i.variadic&&(e.array.push(r),e.default[r]=[]),e.alias[r]=a,e.demand[r]=!0}),n.optional.forEach(i=>{let[r,...a]=i.cmd;i.variadic&&(e.array.push(r),e.default[r]=[]),e.alias[r]=a}),e}postProcessPositionals(t,e,n,i){let r=Object.assign({},i.getOptions());r.default=Object.assign(n.default,r.default);for(let w of Object.keys(n.alias))r.alias[w]=(r.alias[w]||[]).concat(n.alias[w]);r.array=r.array.concat(n.array),r.config={};let a=[];if(Object.keys(e).forEach(w=>{e[w].map(p=>{r.configuration["unknown-options-as-args"]&&(r.key[w]=!0),a.push(`--${w}`),a.push(p)})}),!a.length)return;let l=Object.assign({},r.configuration,{"populate--":!1}),m=this.shim.Parser.detailed(a,Object.assign({},r,{configuration:l}));if(m.error)i.getInternalMethods().getUsageInstance().fail(m.error.message,m.error);else{let w=Object.keys(e);Object.keys(e).forEach(p=>{w.push(...m.aliases[p])}),Object.keys(m.argv).forEach(p=>{w.includes(p)&&(e[p]||(e[p]=m.argv[p]),!this.isInConfigs(i,p)&&!this.isDefaulted(i,p)&&Object.prototype.hasOwnProperty.call(t,p)&&Object.prototype.hasOwnProperty.call(m.argv,p)&&(Array.isArray(t[p])||Array.isArray(m.argv[p]))?t[p]=[].concat(t[p],m.argv[p]):t[p]=m.argv[p])})}}isDefaulted(t,e){let{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){let{configObjects:n}=t.getOptions();return n.some(i=>Object.prototype.hasOwnProperty.call(i,e))||n.some(i=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){let n=kt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let e=this.defaultCommand.builder;if(ye(e))return e(t,!0);Bn(e)||Object.keys(e).forEach(n=>{t.option(n,e[n])})}moduleName(t){let e=Ve(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(let i of[t,e,n]){if(typeof i=="string"||i===!1)return i;at(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let t=this.frozens.pop();at(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function Yn(s,t,e,n){return new Ke(s,t,e,n)}function Bn(s){return typeof s=="object"&&!!s.builder&&typeof s.handler=="function"}function Ps(s){return s.every(t=>typeof t=="string")}function ye(s){return typeof s=="function"}function Ss(s){return typeof s=="object"}function Ms(s){return typeof s=="object"&&!Array.isArray(s)}function St(s={},t=()=>!0){let e={};return Xt(s).forEach(n=>{t(n,s[n])&&(e[n]=s[n])}),e}function Mt(s){typeof process>"u"||[process.stdout,process.stderr].forEach(t=>{let e=t;e._handle&&e.isTTY&&typeof e._handle.setBlocking=="function"&&e._handle.setBlocking(s)})}function Is(s){return typeof s=="boolean"}function Vn(s,t){let e=t.y18n.__,n={},i=[];n.failFn=function(C){i.push(C)};let r=null,a=null,l=!0;n.showHelpOnFail=function(C=!0,P){let[L,B]=typeof C=="string"?[!0,C]:[C,P];return s.getInternalMethods().isGlobalContext()&&(a=B),r=B,l=L,n};let m=!1;n.fail=function(C,P){let L=s.getInternalMethods().getLoggerInstance();if(i.length)for(let B=i.length-1;B>=0;--B){let et=i[B];if(Is(et)){if(P)throw P;if(C)throw Error(C)}else et(C,P,n)}else{if(s.getExitProcess()&&Mt(!0),!m){m=!0,l&&(s.showHelp("error"),L.error()),(C||P)&&L.error(C||P);let B=r||a;B&&((C||P)&&L.error(""),L.error(B))}if(P=P||new G(C),s.getExitProcess())return s.exit(1);if(s.getInternalMethods().hasParseCallback())return s.exit(1,P);throw P}};let w=[],p=!1;n.usage=(M,C)=>M===null?(p=!0,w=[],n):(p=!1,w.push([M,C||""]),n),n.getUsage=()=>w,n.getUsageDisabled=()=>p,n.getPositionalGroupName=()=>e("Positionals:");let h=[];n.example=(M,C)=>{h.push([M,C||""])};let g=[];n.command=function(C,P,L,B,et=!1){L&&(g=g.map(H=>(H[2]=!1,H))),g.push([C,P||"",L,B,et])},n.getCommands=()=>g;let y={};n.describe=function(C,P){Array.isArray(C)?C.forEach(L=>{n.describe(L,P)}):typeof C=="object"?Object.keys(C).forEach(L=>{n.describe(L,C[L])}):y[C]=P},n.getDescriptions=()=>y;let E=[];n.epilog=M=>{E.push(M)};let _=!1,d;n.wrap=M=>{_=!0,d=M},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(_||(d=Qt(),_=!0),d);let W="__yargsString__:";n.deferY18nLookup=M=>W+M,n.help=function(){if(U)return U;Y();let C=s.customScriptName?s.$0:t.path.basename(s.$0),P=s.getDemandedOptions(),L=s.getDemandedCommands(),B=s.getDeprecatedOptions(),et=s.getGroups(),H=s.getOptions(),nt=[];nt=nt.concat(Object.keys(y)),nt=nt.concat(Object.keys(P)),nt=nt.concat(Object.keys(L)),nt=nt.concat(Object.keys(H.default)),nt=nt.filter(rt),nt=Object.keys(nt.reduce((v,K)=>(K!=="_"&&(v[K]=!0),v),{}));let Dt=n.getWrap(),Q=t.cliui({width:Dt,wrap:!!Dt});if(!p){if(w.length)w.forEach(v=>{Q.div({text:`${v[0].replace(/\$0/g,C)}`}),v[1]&&Q.div({text:`${v[1]}`,padding:[1,0,0,0]})}),Q.div();else if(g.length){let v=null;L._?v=`${C} <${e("command")}>
11
11
  `:v=`${C} [${e("command")}]
12
- `,Q.div(`${v}`)}}if(m.length>1||m.length===1&&!m[0][2]){Q.div(e("Commands:"));let v=s.getInternalMethods().getContext(),K=v.commands.length?`${v.commands.join(" ")} `:"";s.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(m=m.sort((U,Z)=>U[0].localeCompare(Z[0])));let J=C?`${C} `:"";m.forEach(U=>{let Z=`${J}${K}${U[0].replace(/^\$0 ?/,"")}`;Q.span({text:Z,padding:[0,2,0,2],width:z(m,Ft,`${C}${K}`)+4},{text:U[1]});let k=[];U[2]&&k.push(`[${e("default")}]`),U[3]&&U[3].length&&k.push(`[${e("aliases:")} ${U[3].join(", ")}]`),U[4]&&(typeof U[4]=="string"?k.push(`[${e("deprecated: %s",U[4])}]`):k.push(`[${e("deprecated")}]`)),k.length?Q.div({text:k.join(" "),padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}let Et=(Object.keys(Y.alias)||[]).concat(Object.keys(s.parsed.newAliases)||[]);nt=nt.filter(v=>!s.parsed.newAliases[v]&&Et.every(K=>(Y.alias[K]||[]).indexOf(v)===-1));let jt=e("Options:");et[jt]||(et[jt]=[]),H(nt,Y.alias,et,jt);let Nt=v=>/^--/.test(Oe(v)),D=Object.keys(et).filter(v=>et[v].length>0).map(v=>{let K=et[v].filter(at).map(J=>{if(Et.includes(J))return J;for(let U=0,Z;(Z=Et[U])!==void 0;U++)if((Y.alias[Z]||[]).includes(J))return Z;return J});return{groupName:v,normalizedKeys:K}}).filter(({normalizedKeys:v})=>v.length>0).map(({groupName:v,normalizedKeys:K})=>{let J=K.reduce((U,Z)=>(U[Z]=[Z].concat(Y.alias[Z]||[]).map(k=>v===n.getPositionalGroupName()?k:(/^[0-9]$/.test(k)?Y.boolean.includes(Z)?"-":"--":k.length>1?"--":"-")+k).sort((k,wt)=>Nt(k)===Nt(wt)?0:Nt(k)?1:-1).join(", "),U),{});return{groupName:v,normalizedKeys:K,switches:J}});if(D.filter(({groupName:v})=>v!==n.getPositionalGroupName()).some(({normalizedKeys:v,switches:K})=>!v.every(J=>Nt(K[J])))&&D.filter(({groupName:v})=>v!==n.getPositionalGroupName()).forEach(({normalizedKeys:v,switches:K})=>{v.forEach(J=>{Nt(K[J])&&(K[J]=xs(K[J],4))})}),D.forEach(({groupName:v,normalizedKeys:K,switches:J})=>{Q.div(v),K.forEach(U=>{let Z=J[U],k=y[U]||"",wt=null;k.includes(L)&&(k=e(k.substring(L.length))),Y.boolean.includes(U)&&(wt=`[${e("boolean")}]`),Y.count.includes(U)&&(wt=`[${e("count")}]`),Y.string.includes(U)&&(wt=`[${e("string")}]`),Y.normalize.includes(U)&&(wt=`[${e("string")}]`),Y.array.includes(U)&&(wt=`[${e("array")}]`),Y.number.includes(U)&&(wt=`[${e("number")}]`);let yt=u=>typeof u=="string"?`[${e("deprecated: %s",u)}]`:`[${e("deprecated")}]`,fe=[U in B?yt(B[U]):null,wt,U in P?`[${e("required")}]`:null,Y.choices&&Y.choices[U]?`[${e("choices:")} ${n.stringifiedValues(Y.choices[U])}]`:null,bt(Y.default[U],Y.defaultDescription[U])].filter(Boolean).join(" ");Q.span({text:Oe(Z),padding:[0,2,0,2+Tn(Z)],width:z(J,Ft)+4},k);let l=s.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;fe&&!l?Q.div({text:fe,padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}),h.length&&(Q.div(e("Examples:")),h.forEach(v=>{v[0]=v[0].replace(/\$0/g,C)}),h.forEach(v=>{v[1]===""?Q.div({text:v[0],padding:[0,2,0,2]}):Q.div({text:v[0],padding:[0,2,0,2],width:z(h,Ft)+4},{text:v[1]})}),Q.div()),E.length>0){let v=E.map(K=>K.replace(/\$0/g,C)).join(`
12
+ `,Q.div(`${v}`)}}if(g.length>1||g.length===1&&!g[0][2]){Q.div(e("Commands:"));let v=s.getInternalMethods().getContext(),K=v.commands.length?`${v.commands.join(" ")} `:"";s.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(g=g.sort((z,Z)=>z[0].localeCompare(Z[0])));let J=C?`${C} `:"";g.forEach(z=>{let Z=`${J}${K}${z[0].replace(/^\$0 ?/,"")}`;Q.span({text:Z,padding:[0,2,0,2],width:R(g,Dt,`${C}${K}`)+4},{text:z[1]});let k=[];z[2]&&k.push(`[${e("default")}]`),z[3]&&z[3].length&&k.push(`[${e("aliases:")} ${z[3].join(", ")}]`),z[4]&&(typeof z[4]=="string"?k.push(`[${e("deprecated: %s",z[4])}]`):k.push(`[${e("deprecated")}]`)),k.length?Q.div({text:k.join(" "),padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}let Et=(Object.keys(H.alias)||[]).concat(Object.keys(s.parsed.newAliases)||[]);nt=nt.filter(v=>!s.parsed.newAliases[v]&&Et.every(K=>(H.alias[K]||[]).indexOf(v)===-1));let jt=e("Options:");et[jt]||(et[jt]=[]),T(nt,H.alias,et,jt);let Nt=v=>/^--/.test(Oe(v)),F=Object.keys(et).filter(v=>et[v].length>0).map(v=>{let K=et[v].filter(rt).map(J=>{if(Et.includes(J))return J;for(let z=0,Z;(Z=Et[z])!==void 0;z++)if((H.alias[Z]||[]).includes(J))return Z;return J});return{groupName:v,normalizedKeys:K}}).filter(({normalizedKeys:v})=>v.length>0).map(({groupName:v,normalizedKeys:K})=>{let J=K.reduce((z,Z)=>(z[Z]=[Z].concat(H.alias[Z]||[]).map(k=>v===n.getPositionalGroupName()?k:(/^[0-9]$/.test(k)?H.boolean.includes(Z)?"-":"--":k.length>1?"--":"-")+k).sort((k,wt)=>Nt(k)===Nt(wt)?0:Nt(k)?1:-1).join(", "),z),{});return{groupName:v,normalizedKeys:K,switches:J}});if(F.filter(({groupName:v})=>v!==n.getPositionalGroupName()).some(({normalizedKeys:v,switches:K})=>!v.every(J=>Nt(K[J])))&&F.filter(({groupName:v})=>v!==n.getPositionalGroupName()).forEach(({normalizedKeys:v,switches:K})=>{v.forEach(J=>{Nt(K[J])&&(K[J]=$s(K[J],4))})}),F.forEach(({groupName:v,normalizedKeys:K,switches:J})=>{Q.div(v),K.forEach(z=>{let Z=J[z],k=y[z]||"",wt=null;k.includes(W)&&(k=e(k.substring(W.length))),H.boolean.includes(z)&&(wt=`[${e("boolean")}]`),H.count.includes(z)&&(wt=`[${e("count")}]`),H.string.includes(z)&&(wt=`[${e("string")}]`),H.normalize.includes(z)&&(wt=`[${e("string")}]`),H.array.includes(z)&&(wt=`[${e("array")}]`),H.number.includes(z)&&(wt=`[${e("number")}]`);let yt=u=>typeof u=="string"?`[${e("deprecated: %s",u)}]`:`[${e("deprecated")}]`,ue=[z in B?yt(B[z]):null,wt,z in P?`[${e("required")}]`:null,H.choices&&H.choices[z]?`[${e("choices:")} ${n.stringifiedValues(H.choices[z])}]`:null,bt(H.default[z],H.defaultDescription[z])].filter(Boolean).join(" ");Q.span({text:Oe(Z),padding:[0,2,0,2+Gn(Z)],width:R(J,Dt)+4},k);let c=s.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;ue&&!c?Q.div({text:ue,padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}),h.length&&(Q.div(e("Examples:")),h.forEach(v=>{v[0]=v[0].replace(/\$0/g,C)}),h.forEach(v=>{v[1]===""?Q.div({text:v[0],padding:[0,2,0,2]}):Q.div({text:v[0],padding:[0,2,0,2],width:R(h,Dt)+4},{text:v[1]})}),Q.div()),E.length>0){let v=E.map(K=>K.replace(/\$0/g,C)).join(`
13
13
  `);Q.div(`${v}
14
- `)}return Q.toString().replace(/\s*$/,"")};function z(M,C,P){let W=0;return Array.isArray(M)||(M=Object.values(M).map(B=>[B])),M.forEach(B=>{W=Math.max(t.stringWidth(P?`${P} ${Oe(B[0])}`:Oe(B[0]))+Tn(B[0]),W)}),C&&(W=Math.min(W,parseInt((C*.5).toString(),10))),W}function T(){let M=s.getDemandedOptions(),C=s.getOptions();(Object.keys(C.alias)||[]).forEach(P=>{C.alias[P].forEach(W=>{y[W]&&n.describe(P,y[W]),W in M&&s.demandOption(P,M[W]),C.boolean.includes(W)&&s.boolean(P),C.count.includes(W)&&s.count(P),C.string.includes(W)&&s.string(P),C.normalize.includes(W)&&s.normalize(P),C.array.includes(W)&&s.array(P),C.number.includes(W)&&s.number(P)})})}let R;n.cacheHelpMessage=function(){R=this.help()},n.clearCachedHelpMessage=function(){R=void 0},n.hasCachedHelpMessage=function(){return!!R};function H(M,C,P,W){let B=[],et=null;return Object.keys(P).forEach(Y=>{B=B.concat(P[Y])}),M.forEach(Y=>{et=[Y].concat(C[Y]),et.some(nt=>B.indexOf(nt)!==-1)||P[W].push(Y)}),B}function at(M){return s.getOptions().hiddenOptions.indexOf(M)<0||s.parsed.argv[s.getOptions().showHiddenOpt]}n.showHelp=M=>{let C=s.getInternalMethods().getLoggerInstance();M||(M="error"),(typeof M=="function"?M:C[M])(n.help())},n.functionDescription=M=>["(",M.name?t.Parser.decamelize(M.name,"-"):e("generated-value"),")"].join(""),n.stringifiedValues=function(C,P){let W="",B=P||", ",et=[].concat(C);return!C||!et.length||et.forEach(Y=>{W.length&&(W+=B),W+=JSON.stringify(Y)}),W};function bt(M,C){let P=`[${e("default:")} `;if(M===void 0&&!C)return null;if(C)P+=C;else switch(typeof M){case"string":P+=`"${M}"`;break;case"object":P+=JSON.stringify(M);break;default:P+=M}return`${P}]`}function Jt(){return t.process.stdColumns?Math.min(80,t.process.stdColumns):80}let Dt=null;n.version=M=>{Dt=M},n.showVersion=M=>{let C=s.getInternalMethods().getLoggerInstance();M||(M="error"),(typeof M=="function"?M:C[M])(Dt)},n.reset=function(C){return r=null,g=!1,w=[],p=!1,E=[],h=[],m=[],y=St(y,P=>!C[P]),n};let G=[];return n.freeze=function(){G.push({failMessage:r,failureOutput:g,usages:w,usageDisabled:p,epilogs:E,examples:h,commands:m,descriptions:y})},n.unfreeze=function(C=!1){let P=G.pop();P&&(C?(y={...P.descriptions,...y},m=[...P.commands,...m],w=[...P.usages,...w],h=[...P.examples,...h],E=[...P.epilogs,...E]):{failMessage:r,failureOutput:g,usages:w,usageDisabled:p,epilogs:E,examples:h,commands:m,descriptions:y}=P)},n}function Ve(s){return typeof s=="object"}function xs(s,t){return Ve(s)?{text:s.text,indentation:s.indentation+t}:{text:s,indentation:t}}function Tn(s){return Ve(s)?s.indentation:0}function Oe(s){return Ve(s)?s.text:s}var Yn=`###-begin-{{app_name}}-completions-###
14
+ `)}return Q.toString().replace(/\s*$/,"")};function R(M,C,P){let L=0;return Array.isArray(M)||(M=Object.values(M).map(B=>[B])),M.forEach(B=>{L=Math.max(t.stringWidth(P?`${P} ${Oe(B[0])}`:Oe(B[0]))+Gn(B[0]),L)}),C&&(L=Math.min(L,parseInt((C*.5).toString(),10))),L}function Y(){let M=s.getDemandedOptions(),C=s.getOptions();(Object.keys(C.alias)||[]).forEach(P=>{C.alias[P].forEach(L=>{y[L]&&n.describe(P,y[L]),L in M&&s.demandOption(P,M[L]),C.boolean.includes(L)&&s.boolean(P),C.count.includes(L)&&s.count(P),C.string.includes(L)&&s.string(P),C.normalize.includes(L)&&s.normalize(P),C.array.includes(L)&&s.array(P),C.number.includes(L)&&s.number(P)})})}let U;n.cacheHelpMessage=function(){U=this.help()},n.clearCachedHelpMessage=function(){U=void 0},n.hasCachedHelpMessage=function(){return!!U};function T(M,C,P,L){let B=[],et=null;return Object.keys(P).forEach(H=>{B=B.concat(P[H])}),M.forEach(H=>{et=[H].concat(C[H]),et.some(nt=>B.indexOf(nt)!==-1)||P[L].push(H)}),B}function rt(M){return s.getOptions().hiddenOptions.indexOf(M)<0||s.parsed.argv[s.getOptions().showHiddenOpt]}n.showHelp=M=>{let C=s.getInternalMethods().getLoggerInstance();M||(M="error"),(typeof M=="function"?M:C[M])(n.help())},n.functionDescription=M=>["(",M.name?t.Parser.decamelize(M.name,"-"):e("generated-value"),")"].join(""),n.stringifiedValues=function(C,P){let L="",B=P||", ",et=[].concat(C);return!C||!et.length||et.forEach(H=>{L.length&&(L+=B),L+=JSON.stringify(H)}),L};function bt(M,C){let P=`[${e("default:")} `;if(M===void 0&&!C)return null;if(C)P+=C;else switch(typeof M){case"string":P+=`"${M}"`;break;case"object":P+=JSON.stringify(M);break;default:P+=M}return`${P}]`}function Qt(){return t.process.stdColumns?Math.min(80,t.process.stdColumns):80}let Ft=null;n.version=M=>{Ft=M},n.showVersion=M=>{let C=s.getInternalMethods().getLoggerInstance();M||(M="error"),(typeof M=="function"?M:C[M])(Ft)},n.reset=function(C){return r=null,m=!1,w=[],p=!1,E=[],h=[],g=[],y=St(y,P=>!C[P]),n};let q=[];return n.freeze=function(){q.push({failMessage:r,failureOutput:m,usages:w,usageDisabled:p,epilogs:E,examples:h,commands:g,descriptions:y})},n.unfreeze=function(C=!1){let P=q.pop();P&&(C?(y={...P.descriptions,...y},g=[...P.commands,...g],w=[...P.usages,...w],h=[...P.examples,...h],E=[...P.epilogs,...E]):{failMessage:r,failureOutput:m,usages:w,usageDisabled:p,epilogs:E,examples:h,commands:g,descriptions:y}=P)},n}function Qe(s){return typeof s=="object"}function $s(s,t){return Qe(s)?{text:s.text,indentation:s.indentation+t}:{text:s,indentation:t}}function Gn(s){return Qe(s)?s.indentation:0}function Oe(s){return Qe(s)?s.text:s}var Kn=`###-begin-{{app_name}}-completions-###
15
15
  #
16
16
  # yargs command completion script
17
17
  #
@@ -39,7 +39,7 @@ _{{app_name}}_yargs_completions()
39
39
  }
40
40
  complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
41
41
  ###-end-{{app_name}}-completions-###
42
- `,Bn=`#compdef {{app_name}}
42
+ `,Qn=`#compdef {{app_name}}
43
43
  ###-begin-{{app_name}}-completions-###
44
44
  #
45
45
  # yargs command completion script
@@ -58,14 +58,14 @@ _{{app_name}}_yargs_completions()
58
58
  }
59
59
  compdef _{{app_name}}_yargs_completions {{app_name}}
60
60
  ###-end-{{app_name}}-completions-###
61
- `;var qe=class{constructor(t,e,n,i){var r,a,c;this.yargs=t,this.usage=e,this.command=n,this.shim=i,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(c=((r=this.shim.getEnv("SHELL"))===null||r===void 0?void 0:r.includes("zsh"))||((a=this.shim.getEnv("ZSH_NAME"))===null||a===void 0?void 0:a.includes("zsh")))!==null&&c!==void 0?c:!1}defaultCompletion(t,e,n,i){let r=this.command.getCommandHandlers();for(let c=0,g=t.length;c<g;++c)if(r[t[c]]&&r[t[c]].builder){let w=r[t[c]].builder;if(ye(w)){this.indexAfterLastReset=c+1;let p=this.yargs.getInternalMethods().reset();return w(p,!0),p.argv}}let a=[];this.commandCompletions(a,t,n),this.optionCompletions(a,t,e,n),this.choicesFromOptionsCompletions(a,t,e,n),this.choicesFromPositionalsCompletions(a,t,e,n),i(null,a)}commandCompletions(t,e,n){let i=this.yargs.getInternalMethods().getContext().commands;!n.match(/^-/)&&i[i.length-1]!==n&&!this.previousArgHasChoices(e)&&this.usage.getCommands().forEach(r=>{let a=Pt(r[0]).cmd;if(e.indexOf(a)===-1)if(!this.zshShell)t.push(a);else{let c=r[1]||"";t.push(a.replace(/:/g,"\\:")+":"+c)}})}optionCompletions(t,e,n,i){if((i.match(/^-/)||i===""&&t.length===0)&&!this.previousArgHasChoices(e)){let r=this.yargs.getOptions(),a=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(r.key).forEach(c=>{let g=!!r.configuration["boolean-negation"]&&r.boolean.includes(c);!a.includes(c)&&!r.hiddenOptions.includes(c)&&!this.argsContainKey(e,c,g)&&this.completeOptionKey(c,t,i,g&&!!r.default[c])})}}choicesFromOptionsCompletions(t,e,n,i){if(this.previousArgHasChoices(e)){let r=this.getPreviousArgChoices(e);r&&r.length>0&&t.push(...r.map(a=>a.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(t,e,n,i){if(i===""&&t.length>0&&this.previousArgHasChoices(e))return;let r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],a=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),c=r[n._.length-a-1];if(!c)return;let g=this.yargs.getOptions().choices[c]||[];for(let w of g)w.startsWith(i)&&t.push(w.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;let i=e.replace(/^-+/,""),r=this.yargs.getOptions(),a=[i,...this.yargs.getAliases()[i]||[]],c;for(let g of a)if(Object.prototype.hasOwnProperty.call(r.key,g)&&Array.isArray(r.choices[g])){c=r.choices[g];break}if(c)return c.filter(g=>!n||g.startsWith(n))}previousArgHasChoices(t){let e=this.getPreviousArgChoices(t);return e!==void 0&&e.length>0}argsContainKey(t,e,n){let i=r=>t.indexOf((/^[^0-9]$/.test(r)?"-":"--")+r)!==-1;if(i(e)||n&&i(`no-${e}`))return!0;if(this.aliases){for(let r of this.aliases[e])if(i(r))return!0}return!1}completeOptionKey(t,e,n,i){var r,a,c,g;let w=t;if(this.zshShell){let y=this.usage.getDescriptions(),E=(a=(r=this===null||this===void 0?void 0:this.aliases)===null||r===void 0?void 0:r[t])===null||a===void 0?void 0:a.find(L=>{let z=y[L];return typeof z=="string"&&z.length>0}),_=E?y[E]:void 0,d=(g=(c=y[t])!==null&&c!==void 0?c:_)!==null&&g!==void 0?g:"";w=`${t.replace(/:/g,"\\:")}:${d.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let p=y=>/^--/.test(y),h=y=>/^[^0-9]$/.test(y),m=!p(n)&&h(t)?"-":"--";e.push(m+w),i&&e.push(m+"no-"+w)}customCompletion(t,e,n,i){if(ot(this.customCompletionFunction,null,this.shim),js(this.customCompletionFunction)){let r=this.customCompletionFunction(n,e);return q(r)?r.then(a=>{this.shim.process.nextTick(()=>{i(null,a)})}).catch(a=>{this.shim.process.nextTick(()=>{i(a,void 0)})}):i(null,r)}else return As(this.customCompletionFunction)?this.customCompletionFunction(n,e,(r=i)=>this.defaultCompletion(t,e,n,r),r=>{i(null,r)}):this.customCompletionFunction(n,e,r=>{i(null,r)})}getCompletion(t,e){let n=t.length?t[t.length-1]:"",i=this.yargs.parse(t,!0),r=this.customCompletionFunction?a=>this.customCompletion(t,a,n,e):a=>this.defaultCompletion(t,a,n,e);return q(i)?i.then(r):r(i)}generateCompletionScript(t,e){let n=this.zshShell?Bn:Yn,i=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),n=n.replace(/{{app_name}}/g,i),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 Gn(s,t,e,n){return new qe(s,t,e,n)}function js(s){return s.length<3}function As(s){return s.length>3}function Vn(s,t){if(s.length===0)return t.length;if(t.length===0)return s.length;let e=[],n;for(n=0;n<=t.length;n++)e[n]=[n];let i;for(i=0;i<=s.length;i++)e[0][i]=i;for(n=1;n<=t.length;n++)for(i=1;i<=s.length;i++)t.charAt(n-1)===s.charAt(i-1)?e[n][i]=e[n-1][i-1]:n>1&&i>1&&t.charAt(n-2)===s.charAt(i-1)&&t.charAt(n-1)===s.charAt(i-2)?e[n][i]=e[n-2][i-2]+1:e[n][i]=Math.min(e[n-1][i-1]+1,Math.min(e[n][i-1]+1,e[n-1][i]+1));return e[t.length][s.length]}var qn=["$0","--","_"];function Kn(s,t,e){let n=e.y18n.__,i=e.y18n.__n,r={};r.nonOptionCount=function(h){let m=s.getDemandedCommands(),E=h._.length+(h["--"]?h["--"].length:0)-s.getInternalMethods().getContext().commands.length;m._&&(E<m._.min||E>m._.max)&&(E<m._.min?m._.minMsg!==void 0?t.fail(m._.minMsg?m._.minMsg.replace(/\$0/g,E.toString()).replace(/\$1/,m._.min.toString()):null):t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",E,E.toString(),m._.min.toString())):E>m._.max&&(m._.maxMsg!==void 0?t.fail(m._.maxMsg?m._.maxMsg.replace(/\$0/g,E.toString()).replace(/\$1/,m._.max.toString()):null):t.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",E,E.toString(),m._.max.toString()))))},r.positionalCount=function(h,m){m<h&&t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",m,m+"",h+""))},r.requiredArguments=function(h,m){let y=null;for(let E of Object.keys(m))(!Object.prototype.hasOwnProperty.call(h,E)||typeof h[E]>"u")&&(y=y||{},y[E]=m[E]);if(y){let E=[];for(let d of Object.keys(y)){let L=y[d];L&&E.indexOf(L)<0&&E.push(L)}let _=E.length?`
61
+ `;var Je=class{constructor(t,e,n,i){var r,a,l;this.yargs=t,this.usage=e,this.command=n,this.shim=i,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(l=((r=this.shim.getEnv("SHELL"))===null||r===void 0?void 0:r.includes("zsh"))||((a=this.shim.getEnv("ZSH_NAME"))===null||a===void 0?void 0:a.includes("zsh")))!==null&&l!==void 0?l:!1}defaultCompletion(t,e,n,i){let r=this.command.getCommandHandlers();for(let l=0,m=t.length;l<m;++l)if(r[t[l]]&&r[t[l]].builder){let w=r[t[l]].builder;if(ye(w)){this.indexAfterLastReset=l+1;let p=this.yargs.getInternalMethods().reset();return w(p,!0),p.argv}}let a=[];this.commandCompletions(a,t,n),this.optionCompletions(a,t,e,n),this.choicesFromOptionsCompletions(a,t,e,n),this.choicesFromPositionalsCompletions(a,t,e,n),i(null,a)}commandCompletions(t,e,n){let i=this.yargs.getInternalMethods().getContext().commands;!n.match(/^-/)&&i[i.length-1]!==n&&!this.previousArgHasChoices(e)&&this.usage.getCommands().forEach(r=>{let a=Pt(r[0]).cmd;if(e.indexOf(a)===-1)if(!this.zshShell)t.push(a);else{let l=r[1]||"";t.push(a.replace(/:/g,"\\:")+":"+l)}})}optionCompletions(t,e,n,i){if((i.match(/^-/)||i===""&&t.length===0)&&!this.previousArgHasChoices(e)){let r=this.yargs.getOptions(),a=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(r.key).forEach(l=>{let m=!!r.configuration["boolean-negation"]&&r.boolean.includes(l);!a.includes(l)&&!r.hiddenOptions.includes(l)&&!this.argsContainKey(e,l,m)&&this.completeOptionKey(l,t,i,m&&!!r.default[l])})}}choicesFromOptionsCompletions(t,e,n,i){if(this.previousArgHasChoices(e)){let r=this.getPreviousArgChoices(e);r&&r.length>0&&t.push(...r.map(a=>a.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(t,e,n,i){if(i===""&&t.length>0&&this.previousArgHasChoices(e))return;let r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],a=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),l=r[n._.length-a-1];if(!l)return;let m=this.yargs.getOptions().choices[l]||[];for(let w of m)w.startsWith(i)&&t.push(w.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;let i=e.replace(/^-+/,""),r=this.yargs.getOptions(),a=[i,...this.yargs.getAliases()[i]||[]],l;for(let m of a)if(Object.prototype.hasOwnProperty.call(r.key,m)&&Array.isArray(r.choices[m])){l=r.choices[m];break}if(l)return l.filter(m=>!n||m.startsWith(n))}previousArgHasChoices(t){let e=this.getPreviousArgChoices(t);return e!==void 0&&e.length>0}argsContainKey(t,e,n){let i=r=>t.indexOf((/^[^0-9]$/.test(r)?"-":"--")+r)!==-1;if(i(e)||n&&i(`no-${e}`))return!0;if(this.aliases){for(let r of this.aliases[e])if(i(r))return!0}return!1}completeOptionKey(t,e,n,i){var r,a,l,m;let w=t;if(this.zshShell){let y=this.usage.getDescriptions(),E=(a=(r=this===null||this===void 0?void 0:this.aliases)===null||r===void 0?void 0:r[t])===null||a===void 0?void 0:a.find(W=>{let R=y[W];return typeof R=="string"&&R.length>0}),_=E?y[E]:void 0,d=(m=(l=y[t])!==null&&l!==void 0?l:_)!==null&&m!==void 0?m:"";w=`${t.replace(/:/g,"\\:")}:${d.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let p=y=>/^--/.test(y),h=y=>/^[^0-9]$/.test(y),g=!p(n)&&h(t)?"-":"--";e.push(g+w),i&&e.push(g+"no-"+w)}customCompletion(t,e,n,i){if(at(this.customCompletionFunction,null,this.shim),Fs(this.customCompletionFunction)){let r=this.customCompletionFunction(n,e);return V(r)?r.then(a=>{this.shim.process.nextTick(()=>{i(null,a)})}).catch(a=>{this.shim.process.nextTick(()=>{i(a,void 0)})}):i(null,r)}else return Ds(this.customCompletionFunction)?this.customCompletionFunction(n,e,(r=i)=>this.defaultCompletion(t,e,n,r),r=>{i(null,r)}):this.customCompletionFunction(n,e,r=>{i(null,r)})}getCompletion(t,e){let n=t.length?t[t.length-1]:"",i=this.yargs.parse(t,!0),r=this.customCompletionFunction?a=>this.customCompletion(t,a,n,e):a=>this.defaultCompletion(t,a,n,e);return V(i)?i.then(r):r(i)}generateCompletionScript(t,e){let n=this.zshShell?Qn:Kn,i=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),n=n.replace(/{{app_name}}/g,i),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 Jn(s,t,e,n){return new Je(s,t,e,n)}function Fs(s){return s.length<3}function Ds(s){return s.length>3}function Zn(s,t){if(s.length===0)return t.length;if(t.length===0)return s.length;let e=[],n;for(n=0;n<=t.length;n++)e[n]=[n];let i;for(i=0;i<=s.length;i++)e[0][i]=i;for(n=1;n<=t.length;n++)for(i=1;i<=s.length;i++)t.charAt(n-1)===s.charAt(i-1)?e[n][i]=e[n-1][i-1]:n>1&&i>1&&t.charAt(n-2)===s.charAt(i-1)&&t.charAt(n-1)===s.charAt(i-2)?e[n][i]=e[n-2][i-2]+1:e[n][i]=Math.min(e[n-1][i-1]+1,Math.min(e[n][i-1]+1,e[n-1][i]+1));return e[t.length][s.length]}var Xn=["$0","--","_"];function kn(s,t,e){let n=e.y18n.__,i=e.y18n.__n,r={};r.nonOptionCount=function(h){let g=s.getDemandedCommands(),E=h._.length+(h["--"]?h["--"].length:0)-s.getInternalMethods().getContext().commands.length;g._&&(E<g._.min||E>g._.max)&&(E<g._.min?g._.minMsg!==void 0?t.fail(g._.minMsg?g._.minMsg.replace(/\$0/g,E.toString()).replace(/\$1/,g._.min.toString()):null):t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",E,E.toString(),g._.min.toString())):E>g._.max&&(g._.maxMsg!==void 0?t.fail(g._.maxMsg?g._.maxMsg.replace(/\$0/g,E.toString()).replace(/\$1/,g._.max.toString()):null):t.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",E,E.toString(),g._.max.toString()))))},r.positionalCount=function(h,g){g<h&&t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",g,g+"",h+""))},r.requiredArguments=function(h,g){let y=null;for(let E of Object.keys(g))(!Object.prototype.hasOwnProperty.call(h,E)||typeof h[E]>"u")&&(y=y||{},y[E]=g[E]);if(y){let E=[];for(let d of Object.keys(y)){let W=y[d];W&&E.indexOf(W)<0&&E.push(W)}let _=E.length?`
62
62
  ${E.join(`
63
- `)}`:"";t.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(y).length,Object.keys(y).join(", ")+_))}},r.unknownArguments=function(h,m,y,E,_=!0){var d;let L=s.getInternalMethods().getCommandInstance().getCommands(),z=[],T=s.getInternalMethods().getContext();if(Object.keys(h).forEach(R=>{!qn.includes(R)&&!Object.prototype.hasOwnProperty.call(y,R)&&!Object.prototype.hasOwnProperty.call(s.getInternalMethods().getParseContext(),R)&&!r.isValidAndSomeAliasIsNotNew(R,m)&&z.push(R)}),_&&(T.commands.length>0||L.length>0||E)&&h._.slice(T.commands.length).forEach(R=>{L.includes(""+R)||z.push(""+R)}),_){let H=((d=s.getDemandedCommands()._)===null||d===void 0?void 0:d.max)||0,at=T.commands.length+H;at<h._.length&&h._.slice(at).forEach(bt=>{bt=String(bt),!T.commands.includes(bt)&&!z.includes(bt)&&z.push(bt)})}z.length&&t.fail(i("Unknown argument: %s","Unknown arguments: %s",z.length,z.map(R=>R.trim()?R:`"${R}"`).join(", ")))},r.unknownCommands=function(h){let m=s.getInternalMethods().getCommandInstance().getCommands(),y=[],E=s.getInternalMethods().getContext();return(E.commands.length>0||m.length>0)&&h._.slice(E.commands.length).forEach(_=>{m.includes(""+_)||y.push(""+_)}),y.length>0?(t.fail(i("Unknown command: %s","Unknown commands: %s",y.length,y.join(", "))),!0):!1},r.isValidAndSomeAliasIsNotNew=function(h,m){if(!Object.prototype.hasOwnProperty.call(m,h))return!1;let y=s.parsed.newAliases;return[h,...m[h]].some(E=>!Object.prototype.hasOwnProperty.call(y,E)||!y[h])},r.limitedChoices=function(h){let m=s.getOptions(),y={};if(!Object.keys(m.choices).length)return;Object.keys(h).forEach(d=>{qn.indexOf(d)===-1&&Object.prototype.hasOwnProperty.call(m.choices,d)&&[].concat(h[d]).forEach(L=>{m.choices[d].indexOf(L)===-1&&L!==void 0&&(y[d]=(y[d]||[]).concat(L))})});let E=Object.keys(y);if(!E.length)return;let _=n("Invalid values:");E.forEach(d=>{_+=`
64
- ${n("Argument: %s, Given: %s, Choices: %s",d,t.stringifiedValues(y[d]),t.stringifiedValues(m.choices[d]))}`}),t.fail(_)};let a={};r.implies=function(h,m){j("<string|object> [array|number|string]",[h,m],arguments.length),typeof h=="object"?Object.keys(h).forEach(y=>{r.implies(y,h[y])}):(s.global(h),a[h]||(a[h]=[]),Array.isArray(m)?m.forEach(y=>r.implies(h,y)):(ot(m,void 0,e),a[h].push(m)))},r.getImplied=function(){return a};function c(p,h){let m=Number(h);return h=isNaN(m)?h:m,typeof h=="number"?h=p._.length>=h:h.match(/^--no-.+/)?(h=h.match(/^--no-(.+)/)[1],h=!Object.prototype.hasOwnProperty.call(p,h)):h=Object.prototype.hasOwnProperty.call(p,h),h}r.implications=function(h){let m=[];if(Object.keys(a).forEach(y=>{let E=y;(a[y]||[]).forEach(_=>{let d=E,L=_;d=c(h,d),_=c(h,_),d&&!_&&m.push(` ${E} -> ${L}`)})}),m.length){let y=`${n("Implications failed:")}
65
- `;m.forEach(E=>{y+=E}),t.fail(y)}};let g={};r.conflicts=function(h,m){j("<string|object> [array|string]",[h,m],arguments.length),typeof h=="object"?Object.keys(h).forEach(y=>{r.conflicts(y,h[y])}):(s.global(h),g[h]||(g[h]=[]),Array.isArray(m)?m.forEach(y=>r.conflicts(h,y)):g[h].push(m))},r.getConflicting=()=>g,r.conflicting=function(h){Object.keys(h).forEach(m=>{g[m]&&g[m].forEach(y=>{y&&h[m]!==void 0&&h[y]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",m,y))})}),s.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(g).forEach(m=>{g[m].forEach(y=>{y&&h[e.Parser.camelCase(m)]!==void 0&&h[e.Parser.camelCase(y)]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",m,y))})})},r.recommendCommands=function(h,m){m=m.sort((d,L)=>L.length-d.length);let E=null,_=1/0;for(let d=0,L;(L=m[d])!==void 0;d++){let z=Vn(h,L);z<=3&&z<_&&(_=z,E=L)}E&&t.fail(n("Did you mean %s?",E))},r.reset=function(h){return a=St(a,m=>!h[m]),g=St(g,m=>!h[m]),r};let w=[];return r.freeze=function(){w.push({implied:a,conflicting:g})},r.unfreeze=function(){let h=w.pop();ot(h,void 0,e),{implied:a,conflicting:g}=h},r}var Ke=[],oe;function ae(s,t,e,n){oe=n;let i={};if(Object.prototype.hasOwnProperty.call(s,"extends")){if(typeof s.extends!="string")return i;let r=/\.json|\..*rc$/.test(s.extends),a=null;if(r)a=Ss(t,s.extends);else try{a=_t.resolve(s.extends)}catch{return s}Ps(a),Ke.push(a),i=r?JSON.parse(oe.readFileSync(a,"utf8")):_t(s.extends),delete s.extends,i=ae(i,oe.path.dirname(a),e,oe)}return Ke=[],e?Qn(i,s):Object.assign({},i,s)}function Ps(s){if(Ke.indexOf(s)>-1)throw new V(`Circular extended configurations: '${s}'.`)}function Ss(s,t){return oe.path.resolve(s,t)}function Qn(s,t){let e={};function n(i){return i&&typeof i=="object"&&!Array.isArray(i)}Object.assign(e,s);for(let i of Object.keys(t))n(t[i])&&n(e[i])?e[i]=Qn(s[i],t[i]):e[i]=t[i];return e}var A=function(s,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?s!==t||!i:!t.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(s,e):i?i.value=e:t.set(s,e),e},o=function(s,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?s!==t||!n:!t.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(s):n?n.value:t.get(s)},tt,Ut,le,dt,ct,_e,It,Tt,Ce,pt,xe,mt,Ct,ft,gt,Ee,te,st,I,je,Ae,ut,Ht,ee,Yt,$t,Pe,F,Bt,Gt,Vt,N,Se,xt,X;function mi(s){return(t=[],e=s.process.cwd(),n)=>{let i=new on(t,e,n,s);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var Jn=Symbol("copyDoubleDash"),Zn=Symbol("copyDoubleDash"),Qe=Symbol("deleteFromParserHintObject"),Xn=Symbol("emitWarning"),kn=Symbol("freeze"),ti=Symbol("getDollarZero"),qt=Symbol("getParserConfiguration"),ei=Symbol("getUsageConfiguration"),Je=Symbol("guessLocale"),ni=Symbol("guessVersion"),ii=Symbol("parsePositionalNumbers"),Ze=Symbol("pkgUp"),vt=Symbol("populateParserHintArray"),ne=Symbol("populateParserHintSingleValueDictionary"),Xe=Symbol("populateParserHintArrayDictionary"),ke=Symbol("populateParserHintDictionary"),tn=Symbol("sanitizeKey"),en=Symbol("setKey"),nn=Symbol("unfreeze"),si=Symbol("validateAsync"),ri=Symbol("getCommandInstance"),oi=Symbol("getContext"),ai=Symbol("getHasOutput"),li=Symbol("getLoggerInstance"),ci=Symbol("getParseContext"),fi=Symbol("getUsageInstance"),ui=Symbol("getValidationInstance"),Me=Symbol("hasParseCallback"),hi=Symbol("isGlobalContext"),Kt=Symbol("postProcess"),di=Symbol("rebase"),sn=Symbol("reset"),ce=Symbol("runYargsParserAndExecuteCommands"),rn=Symbol("runValidation"),pi=Symbol("setHasOutput"),Qt=Symbol("kTrackManuallySetKeys"),on=class{constructor(t=[],e,n,i){this.customScriptName=!1,this.parsed=!1,tt.set(this,void 0),Ut.set(this,void 0),le.set(this,{commands:[],fullCommands:[]}),dt.set(this,null),ct.set(this,null),_e.set(this,"show-hidden"),It.set(this,null),Tt.set(this,!0),Ce.set(this,{}),pt.set(this,!0),xe.set(this,[]),mt.set(this,void 0),Ct.set(this,{}),ft.set(this,!1),gt.set(this,null),Ee.set(this,!0),te.set(this,void 0),st.set(this,""),I.set(this,void 0),je.set(this,void 0),Ae.set(this,{}),ut.set(this,null),Ht.set(this,null),ee.set(this,{}),Yt.set(this,{}),$t.set(this,void 0),Pe.set(this,!1),F.set(this,void 0),Bt.set(this,!1),Gt.set(this,!1),Vt.set(this,!1),N.set(this,void 0),Se.set(this,{}),xt.set(this,null),X.set(this,void 0),A(this,F,i,"f"),A(this,$t,t,"f"),A(this,Ut,e,"f"),A(this,je,n,"f"),A(this,mt,new we(this),"f"),this.$0=this[ti](),this[sn](),A(this,tt,o(this,tt,"f"),"f"),A(this,N,o(this,N,"f"),"f"),A(this,X,o(this,X,"f"),"f"),A(this,I,o(this,I,"f"),"f"),o(this,I,"f").showHiddenOpt=o(this,_e,"f"),A(this,te,this[Zn](),"f")}addHelpOpt(t,e){let n="help";return j("[string|boolean] [string]",[t,e],arguments.length),o(this,gt,"f")&&(this[Qe](o(this,gt,"f")),A(this,gt,null,"f")),t===!1&&e===void 0?this:(A(this,gt,typeof t=="string"?t:n,"f"),this.boolean(o(this,gt,"f")),this.describe(o(this,gt,"f"),e||o(this,N,"f").deferY18nLookup("Show help")),this)}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(j("[string|boolean] [string]",[t,e],arguments.length),t===!1&&e===void 0)return this;let n=typeof t=="string"?t:o(this,_e,"f");return this.boolean(n),this.describe(n,e||o(this,N,"f").deferY18nLookup("Show hidden options")),o(this,I,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return j("<object|string|array> [string|array]",[t,e],arguments.length),this[Xe](this.alias.bind(this),"alias",t,e),this}array(t){return j("<array|string>",[t],arguments.length),this[vt]("array",t),this[Qt](t),this}boolean(t){return j("<array|string>",[t],arguments.length),this[vt]("boolean",t),this[Qt](t),this}check(t,e){return j("<function> [boolean]",[t,e],arguments.length),this.middleware((n,i)=>zt(()=>t(n,i.getOptions()),r=>(r?(typeof r=="string"||r instanceof Error)&&o(this,N,"f").fail(r.toString(),r):o(this,N,"f").fail(o(this,F,"f").y18n.__("Argument check failed: %s",t.toString())),n),r=>(o(this,N,"f").fail(r.message?r.message:r.toString(),r),n)),!1,e),this}choices(t,e){return j("<object|string|array> [string|array]",[t,e],arguments.length),this[Xe](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(j("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new V("coerce callback must be provided");for(let n of t)this.coerce(n,e);return this}else if(typeof t=="object"){for(let n of Object.keys(t))this.coerce(n,t[n]);return this}if(!e)throw new V("coerce callback must be provided");return o(this,I,"f").key[t]=!0,o(this,mt,"f").addCoerceMiddleware((n,i)=>{let r;return Object.prototype.hasOwnProperty.call(n,t)?zt(()=>(r=i.getAliases(),e(n[t])),c=>{n[t]=c;let g=i.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[t]&&g!==!0)for(let w of r[t])n[w]=c;return n},c=>{throw new V(c.message)}):n},t),this}conflicts(t,e){return j("<string|object> [string|array]",[t,e],arguments.length),o(this,X,"f").conflicts(t,e),this}config(t="config",e,n){return j("[object|string] [string|function] [function]",[t,e,n],arguments.length),typeof t=="object"&&!Array.isArray(t)?(t=ae(t,o(this,Ut,"f"),this[qt]()["deep-merge-config"]||!1,o(this,F,"f")),o(this,I,"f").configObjects=(o(this,I,"f").configObjects||[]).concat(t),this):(typeof e=="function"&&(n=e,e=void 0),this.describe(t,e||o(this,N,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach(i=>{o(this,I,"f").config[i]=n||!0}),this)}completion(t,e,n){return j("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),typeof e=="function"&&(n=e,e=void 0),A(this,ct,t||o(this,ct,"f")||"completion","f"),!e&&e!==!1&&(e="generate completion script"),this.command(o(this,ct,"f"),e),n&&o(this,dt,"f").registerFunction(n),this}command(t,e,n,i,r,a){return j("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,i,r,a],arguments.length),o(this,tt,"f").addHandler(t,e,n,i,r,a),this}commands(t,e,n,i,r,a){return this.command(t,e,n,i,r,a)}commandDir(t,e){j("<string> [object]",[t,e],arguments.length);let n=o(this,je,"f")||o(this,F,"f").require;return o(this,tt,"f").addDirectory(t,n,o(this,F,"f").getCallerFile(),e),this}count(t){return j("<array|string>",[t],arguments.length),this[vt]("count",t),this[Qt](t),this}default(t,e,n){return j("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(Ye(t,o(this,F,"f")),o(this,I,"f").defaultDescription[t]=n),typeof e=="function"&&(Ye(t,o(this,F,"f")),o(this,I,"f").defaultDescription[t]||(o(this,I,"f").defaultDescription[t]=o(this,N,"f").functionDescription(e)),e=e.call()),this[ne](this.default.bind(this),"default",t,e),this}defaults(t,e,n){return this.default(t,e,n)}demandCommand(t=1,e,n,i){return j("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,n,i],arguments.length),typeof e!="number"&&(n=e,e=1/0),this.global("_",!1),o(this,I,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:i},this}demand(t,e,n){return Array.isArray(e)?(e.forEach(i=>{ot(n,!0,o(this,F,"f")),this.demandOption(i,n)}),e=1/0):typeof e!="number"&&(n=e,e=1/0),typeof t=="number"?(ot(n,!0,o(this,F,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach(i=>{ot(n,!0,o(this,F,"f")),this.demandOption(i,n)}):typeof n=="string"?this.demandOption(t,n):(n===!0||typeof n>"u")&&this.demandOption(t),this}demandOption(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[ne](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return j("<string> [string|boolean]",[t,e],arguments.length),o(this,I,"f").deprecatedOptions[t]=e,this}describe(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[en](t,!0),o(this,N,"f").describe(t,e),this}detectLocale(t){return j("<boolean>",[t],arguments.length),A(this,Tt,t,"f"),this}env(t){return j("[string|boolean]",[t],arguments.length),t===!1?delete o(this,I,"f").envPrefix:o(this,I,"f").envPrefix=t||"",this}epilogue(t){return j("<string>",[t],arguments.length),o(this,N,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return j("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach(n=>this.example(...n)):o(this,N,"f").example(t,e),this}exit(t,e){A(this,ft,!0,"f"),A(this,It,e,"f"),o(this,pt,"f")&&o(this,F,"f").process.exit(t)}exitProcess(t=!0){return j("[boolean]",[t],arguments.length),A(this,pt,t,"f"),this}fail(t){if(j("<function|boolean>",[t],arguments.length),typeof t=="boolean"&&t!==!1)throw new V("Invalid first argument. Expected function or boolean 'false'");return o(this,N,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return j("<array> [function]",[t,e],arguments.length),e?o(this,dt,"f").getCompletion(t,e):new Promise((n,i)=>{o(this,dt,"f").getCompletion(t,(r,a)=>{r?i(r):n(a)})})}getDemandedOptions(){return j([],0),o(this,I,"f").demandedOptions}getDemandedCommands(){return j([],0),o(this,I,"f").demandedCommands}getDeprecatedOptions(){return j([],0),o(this,I,"f").deprecatedOptions}getDetectLocale(){return o(this,Tt,"f")}getExitProcess(){return o(this,pt,"f")}getGroups(){return Object.assign({},o(this,Ct,"f"),o(this,Yt,"f"))}getHelp(){if(A(this,ft,!0,"f"),!o(this,N,"f").hasCachedHelpMessage()){if(!this.parsed){let e=this[ce](o(this,$t,"f"),void 0,void 0,0,!0);if(q(e))return e.then(()=>o(this,N,"f").help())}let t=o(this,tt,"f").runDefaultBuilderOn(this);if(q(t))return t.then(()=>o(this,N,"f").help())}return Promise.resolve(o(this,N,"f").help())}getOptions(){return o(this,I,"f")}getStrict(){return o(this,Bt,"f")}getStrictCommands(){return o(this,Gt,"f")}getStrictOptions(){return o(this,Vt,"f")}global(t,e){return j("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),e!==!1?o(this,I,"f").local=o(this,I,"f").local.filter(n=>t.indexOf(n)===-1):t.forEach(n=>{o(this,I,"f").local.includes(n)||o(this,I,"f").local.push(n)}),this}group(t,e){j("<string|array> <string>",[t,e],arguments.length);let n=o(this,Yt,"f")[e]||o(this,Ct,"f")[e];o(this,Yt,"f")[e]&&delete o(this,Yt,"f")[e];let i={};return o(this,Ct,"f")[e]=(n||[]).concat(t).filter(r=>i[r]?!1:i[r]=!0),this}hide(t){return j("<string>",[t],arguments.length),o(this,I,"f").hiddenOptions.push(t),this}implies(t,e){return j("<string|object> [number|string|array]",[t,e],arguments.length),o(this,X,"f").implies(t,e),this}locale(t){return j("[string]",[t],arguments.length),t===void 0?(this[Je](),o(this,F,"f").y18n.getLocale()):(A(this,Tt,!1,"f"),o(this,F,"f").y18n.setLocale(t),this)}middleware(t,e,n){return o(this,mt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return j("<string|object|array> [number]",[t,e],arguments.length),this[ne](this.nargs.bind(this),"narg",t,e),this}normalize(t){return j("<array|string>",[t],arguments.length),this[vt]("normalize",t),this}number(t){return j("<array|string>",[t],arguments.length),this[vt]("number",t),this[Qt](t),this}option(t,e){if(j("<string|object> [object]",[t,e],arguments.length),typeof t=="object")Object.keys(t).forEach(n=>{this.options(n,t[n])});else{typeof e!="object"&&(e={}),this[Qt](t),o(this,xt,"f")&&(t==="version"||e?.alias==="version")&&this[Xn](['"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(`
66
- `),void 0,"versionWarning"),o(this,I,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);let n=e.deprecate||e.deprecated;n&&this.deprecateOption(t,n);let i=e.demand||e.required||e.require;i&&this.demand(t,i),e.demandOption&&this.demandOption(t,typeof e.demandOption=="string"?e.demandOption:void 0),e.conflicts&&this.conflicts(t,e.conflicts),"default"in e&&this.default(t,e.default),e.implies!==void 0&&this.implies(t,e.implies),e.nargs!==void 0&&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||e.type==="boolean")&&(this.boolean(t),e.alias&&this.boolean(e.alias)),(e.array||e.type==="array")&&(this.array(t),e.alias&&this.array(e.alias)),(e.number||e.type==="number")&&(this.number(t),e.alias&&this.number(e.alias)),(e.string||e.type==="string")&&(this.string(t),e.alias&&this.string(e.alias)),(e.count||e.type==="count")&&this.count(t),typeof e.global=="boolean"&&this.global(t,e.global),e.defaultDescription&&(o(this,I,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);let r=e.describe||e.description||e.desc,a=o(this,N,"f").getDescriptions();(!Object.prototype.hasOwnProperty.call(a,t)||typeof r=="string")&&this.describe(t,r),e.hidden&&this.hide(t),e.requiresArg&&this.requiresArg(t)}return this}options(t,e){return this.option(t,e)}parse(t,e,n){j("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[kn](),typeof t>"u"&&(t=o(this,$t,"f")),typeof e=="object"&&(A(this,Ht,e,"f"),e=n),typeof e=="function"&&(A(this,ut,e,"f"),e=!1),e||A(this,$t,t,"f"),o(this,ut,"f")&&A(this,pt,!1,"f");let i=this[ce](t,!!e),r=this.parsed;return o(this,dt,"f").setParsed(this.parsed),q(i)?i.then(a=>(o(this,ut,"f")&&o(this,ut,"f").call(this,o(this,It,"f"),a,o(this,st,"f")),a)).catch(a=>{throw o(this,ut,"f")&&o(this,ut,"f")(a,this.parsed.argv,o(this,st,"f")),a}).finally(()=>{this[nn](),this.parsed=r}):(o(this,ut,"f")&&o(this,ut,"f").call(this,o(this,It,"f"),i,o(this,st,"f")),this[nn](),this.parsed=r,i)}parseAsync(t,e,n){let i=this.parse(t,e,n);return q(i)?i:Promise.resolve(i)}parseSync(t,e,n){let i=this.parse(t,e,n);if(q(i))throw new V(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return i}parserConfiguration(t){return j("<object>",[t],arguments.length),A(this,Ae,t,"f"),this}pkgConf(t,e){j("<string> [string]",[t,e],arguments.length);let n=null,i=this[Ze](e||o(this,Ut,"f"));return i[t]&&typeof i[t]=="object"&&(n=ae(i[t],e||o(this,Ut,"f"),this[qt]()["deep-merge-config"]||!1,o(this,F,"f")),o(this,I,"f").configObjects=(o(this,I,"f").configObjects||[]).concat(n)),this}positional(t,e){j("<string> <object>",[t,e],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=St(e,(a,c)=>a==="type"&&!["string","number","boolean"].includes(c)?!1:n.includes(a));let i=o(this,le,"f").fullCommands[o(this,le,"f").fullCommands.length-1],r=i?o(this,tt,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return Xt(r).forEach(a=>{let c=r[a];Array.isArray(c)?c.indexOf(t)!==-1&&(e[a]=!0):c[t]&&!(a in e)&&(e[a]=c[t])}),this.group(t,o(this,N,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return j("[boolean]",[t],arguments.length),A(this,Pe,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 j("<array|string|object> [number]",[t],arguments.length),typeof t=="string"&&o(this,I,"f").narg[t]?this:(this[ne](this.requiresArg.bind(this),"narg",t,NaN),this)}showCompletionScript(t,e){return j("[string] [string]",[t,e],arguments.length),t=t||this.$0,o(this,te,"f").log(o(this,dt,"f").generateCompletionScript(t,e||o(this,ct,"f")||"completion")),this}showHelp(t){if(j("[string|function]",[t],arguments.length),A(this,ft,!0,"f"),!o(this,N,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[ce](o(this,$t,"f"),void 0,void 0,0,!0);if(q(n))return n.then(()=>{o(this,N,"f").showHelp(t)}),this}let e=o(this,tt,"f").runDefaultBuilderOn(this);if(q(e))return e.then(()=>{o(this,N,"f").showHelp(t)}),this}return o(this,N,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return j("[boolean|string] [string]",[t,e],arguments.length),o(this,N,"f").showHelpOnFail(t,e),this}showVersion(t){return j("[string|function]",[t],arguments.length),o(this,N,"f").showVersion(t),this}skipValidation(t){return j("<array|string>",[t],arguments.length),this[vt]("skipValidation",t),this}strict(t){return j("[boolean]",[t],arguments.length),A(this,Bt,t!==!1,"f"),this}strictCommands(t){return j("[boolean]",[t],arguments.length),A(this,Gt,t!==!1,"f"),this}strictOptions(t){return j("[boolean]",[t],arguments.length),A(this,Vt,t!==!1,"f"),this}string(t){return j("<array|string>",[t],arguments.length),this[vt]("string",t),this[Qt](t),this}terminalWidth(){return j([],0),o(this,F,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return j("<object>",[t],arguments.length),A(this,Tt,!1,"f"),o(this,F,"f").y18n.updateLocale(t),this}usage(t,e,n,i){if(j("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,i],arguments.length),e!==void 0){if(ot(t,null,o(this,F,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,i);throw new V(".usage() description must start with $0 if being used as alias for .command()")}else return o(this,N,"f").usage(t),this}usageConfiguration(t){return j("<object>",[t],arguments.length),A(this,Se,t,"f"),this}version(t,e,n){let i="version";if(j("[boolean|string] [string] [string]",[t,e,n],arguments.length),o(this,xt,"f")&&(this[Qe](o(this,xt,"f")),o(this,N,"f").version(void 0),A(this,xt,null,"f")),arguments.length===0)n=this[ni](),t=i;else if(arguments.length===1){if(t===!1)return this;n=t,t=i}else arguments.length===2&&(n=e,e=void 0);return A(this,xt,typeof t=="string"?t:i,"f"),e=e||o(this,N,"f").deferY18nLookup("Show version number"),o(this,N,"f").version(n||void 0),this.boolean(o(this,xt,"f")),this.describe(o(this,xt,"f"),e),this}wrap(t){return j("<number|null|undefined>",[t],arguments.length),o(this,N,"f").wrap(t),this}[(tt=new WeakMap,Ut=new WeakMap,le=new WeakMap,dt=new WeakMap,ct=new WeakMap,_e=new WeakMap,It=new WeakMap,Tt=new WeakMap,Ce=new WeakMap,pt=new WeakMap,xe=new WeakMap,mt=new WeakMap,Ct=new WeakMap,ft=new WeakMap,gt=new WeakMap,Ee=new WeakMap,te=new WeakMap,st=new WeakMap,I=new WeakMap,je=new WeakMap,Ae=new WeakMap,ut=new WeakMap,Ht=new WeakMap,ee=new WeakMap,Yt=new WeakMap,$t=new WeakMap,Pe=new WeakMap,F=new WeakMap,Bt=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,N=new WeakMap,Se=new WeakMap,xt=new WeakMap,X=new WeakMap,Jn)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch{}return t}[Zn](){return{log:(...t)=>{this[Me]()||console.log(...t),A(this,ft,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
63
+ `)}`:"";t.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(y).length,Object.keys(y).join(", ")+_))}},r.unknownArguments=function(h,g,y,E,_=!0){var d;let W=s.getInternalMethods().getCommandInstance().getCommands(),R=[],Y=s.getInternalMethods().getContext();if(Object.keys(h).forEach(U=>{!Xn.includes(U)&&!Object.prototype.hasOwnProperty.call(y,U)&&!Object.prototype.hasOwnProperty.call(s.getInternalMethods().getParseContext(),U)&&!r.isValidAndSomeAliasIsNotNew(U,g)&&R.push(U)}),_&&(Y.commands.length>0||W.length>0||E)&&h._.slice(Y.commands.length).forEach(U=>{W.includes(""+U)||R.push(""+U)}),_){let T=((d=s.getDemandedCommands()._)===null||d===void 0?void 0:d.max)||0,rt=Y.commands.length+T;rt<h._.length&&h._.slice(rt).forEach(bt=>{bt=String(bt),!Y.commands.includes(bt)&&!R.includes(bt)&&R.push(bt)})}R.length&&t.fail(i("Unknown argument: %s","Unknown arguments: %s",R.length,R.map(U=>U.trim()?U:`"${U}"`).join(", ")))},r.unknownCommands=function(h){let g=s.getInternalMethods().getCommandInstance().getCommands(),y=[],E=s.getInternalMethods().getContext();return(E.commands.length>0||g.length>0)&&h._.slice(E.commands.length).forEach(_=>{g.includes(""+_)||y.push(""+_)}),y.length>0?(t.fail(i("Unknown command: %s","Unknown commands: %s",y.length,y.join(", "))),!0):!1},r.isValidAndSomeAliasIsNotNew=function(h,g){if(!Object.prototype.hasOwnProperty.call(g,h))return!1;let y=s.parsed.newAliases;return[h,...g[h]].some(E=>!Object.prototype.hasOwnProperty.call(y,E)||!y[h])},r.limitedChoices=function(h){let g=s.getOptions(),y={};if(!Object.keys(g.choices).length)return;Object.keys(h).forEach(d=>{Xn.indexOf(d)===-1&&Object.prototype.hasOwnProperty.call(g.choices,d)&&[].concat(h[d]).forEach(W=>{g.choices[d].indexOf(W)===-1&&W!==void 0&&(y[d]=(y[d]||[]).concat(W))})});let E=Object.keys(y);if(!E.length)return;let _=n("Invalid values:");E.forEach(d=>{_+=`
64
+ ${n("Argument: %s, Given: %s, Choices: %s",d,t.stringifiedValues(y[d]),t.stringifiedValues(g.choices[d]))}`}),t.fail(_)};let a={};r.implies=function(h,g){j("<string|object> [array|number|string]",[h,g],arguments.length),typeof h=="object"?Object.keys(h).forEach(y=>{r.implies(y,h[y])}):(s.global(h),a[h]||(a[h]=[]),Array.isArray(g)?g.forEach(y=>r.implies(h,y)):(at(g,void 0,e),a[h].push(g)))},r.getImplied=function(){return a};function l(p,h){let g=Number(h);return h=isNaN(g)?h:g,typeof h=="number"?h=p._.length>=h:h.match(/^--no-.+/)?(h=h.match(/^--no-(.+)/)[1],h=!Object.prototype.hasOwnProperty.call(p,h)):h=Object.prototype.hasOwnProperty.call(p,h),h}r.implications=function(h){let g=[];if(Object.keys(a).forEach(y=>{let E=y;(a[y]||[]).forEach(_=>{let d=E,W=_;d=l(h,d),_=l(h,_),d&&!_&&g.push(` ${E} -> ${W}`)})}),g.length){let y=`${n("Implications failed:")}
65
+ `;g.forEach(E=>{y+=E}),t.fail(y)}};let m={};r.conflicts=function(h,g){j("<string|object> [array|string]",[h,g],arguments.length),typeof h=="object"?Object.keys(h).forEach(y=>{r.conflicts(y,h[y])}):(s.global(h),m[h]||(m[h]=[]),Array.isArray(g)?g.forEach(y=>r.conflicts(h,y)):m[h].push(g))},r.getConflicting=()=>m,r.conflicting=function(h){Object.keys(h).forEach(g=>{m[g]&&m[g].forEach(y=>{y&&h[g]!==void 0&&h[y]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",g,y))})}),s.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(m).forEach(g=>{m[g].forEach(y=>{y&&h[e.Parser.camelCase(g)]!==void 0&&h[e.Parser.camelCase(y)]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",g,y))})})},r.recommendCommands=function(h,g){g=g.sort((d,W)=>W.length-d.length);let E=null,_=1/0;for(let d=0,W;(W=g[d])!==void 0;d++){let R=Zn(h,W);R<=3&&R<_&&(_=R,E=W)}E&&t.fail(n("Did you mean %s?",E))},r.reset=function(h){return a=St(a,g=>!h[g]),m=St(m,g=>!h[g]),r};let w=[];return r.freeze=function(){w.push({implied:a,conflicting:m})},r.unfreeze=function(){let h=w.pop();at(h,void 0,e),{implied:a,conflicting:m}=h},r}var Ze=[],ae;function le(s,t,e,n){ae=n;let i={};if(Object.prototype.hasOwnProperty.call(s,"extends")){if(typeof s.extends!="string")return i;let r=/\.json|\..*rc$/.test(s.extends),a=null;if(r)a=Ls(t,s.extends);else try{a=_t.resolve(s.extends)}catch{return s}Ns(a),Ze.push(a),i=r?JSON.parse(ae.readFileSync(a,"utf8")):_t(s.extends),delete s.extends,i=le(i,ae.path.dirname(a),e,ae)}return Ze=[],e?ti(i,s):Object.assign({},i,s)}function Ns(s){if(Ze.indexOf(s)>-1)throw new G(`Circular extended configurations: '${s}'.`)}function Ls(s,t){return ae.path.resolve(s,t)}function ti(s,t){let e={};function n(i){return i&&typeof i=="object"&&!Array.isArray(i)}Object.assign(e,s);for(let i of Object.keys(t))n(t[i])&&n(e[i])?e[i]=ti(s[i],t[i]):e[i]=t[i];return e}var A=function(s,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?s!==t||!i:!t.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(s,e):i?i.value=e:t.set(s,e),e},o=function(s,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?s!==t||!n:!t.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(s):n?n.value:t.get(s)},tt,Ut,ce,dt,ct,_e,It,zt,Ce,pt,xe,mt,Ct,ft,gt,Ee,te,st,I,je,Ae,ut,Tt,ee,Ht,$t,Pe,D,Bt,Yt,qt,N,Se,xt,X;function Oi(s){return(t=[],e=s.process.cwd(),n)=>{let i=new cn(t,e,n,s);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var ei=Symbol("copyDoubleDash"),ni=Symbol("copyDoubleDash"),Xe=Symbol("deleteFromParserHintObject"),ii=Symbol("emitWarning"),si=Symbol("freeze"),ri=Symbol("getDollarZero"),Gt=Symbol("getParserConfiguration"),oi=Symbol("getUsageConfiguration"),ke=Symbol("guessLocale"),ai=Symbol("guessVersion"),li=Symbol("parsePositionalNumbers"),tn=Symbol("pkgUp"),vt=Symbol("populateParserHintArray"),ne=Symbol("populateParserHintSingleValueDictionary"),en=Symbol("populateParserHintArrayDictionary"),nn=Symbol("populateParserHintDictionary"),sn=Symbol("sanitizeKey"),rn=Symbol("setKey"),on=Symbol("unfreeze"),ci=Symbol("validateAsync"),fi=Symbol("getCommandInstance"),ui=Symbol("getContext"),hi=Symbol("getHasOutput"),di=Symbol("getLoggerInstance"),pi=Symbol("getParseContext"),mi=Symbol("getUsageInstance"),gi=Symbol("getValidationInstance"),Me=Symbol("hasParseCallback"),bi=Symbol("isGlobalContext"),Vt=Symbol("postProcess"),wi=Symbol("rebase"),an=Symbol("reset"),fe=Symbol("runYargsParserAndExecuteCommands"),ln=Symbol("runValidation"),yi=Symbol("setHasOutput"),Kt=Symbol("kTrackManuallySetKeys"),cn=class{constructor(t=[],e,n,i){this.customScriptName=!1,this.parsed=!1,tt.set(this,void 0),Ut.set(this,void 0),ce.set(this,{commands:[],fullCommands:[]}),dt.set(this,null),ct.set(this,null),_e.set(this,"show-hidden"),It.set(this,null),zt.set(this,!0),Ce.set(this,{}),pt.set(this,!0),xe.set(this,[]),mt.set(this,void 0),Ct.set(this,{}),ft.set(this,!1),gt.set(this,null),Ee.set(this,!0),te.set(this,void 0),st.set(this,""),I.set(this,void 0),je.set(this,void 0),Ae.set(this,{}),ut.set(this,null),Tt.set(this,null),ee.set(this,{}),Ht.set(this,{}),$t.set(this,void 0),Pe.set(this,!1),D.set(this,void 0),Bt.set(this,!1),Yt.set(this,!1),qt.set(this,!1),N.set(this,void 0),Se.set(this,{}),xt.set(this,null),X.set(this,void 0),A(this,D,i,"f"),A(this,$t,t,"f"),A(this,Ut,e,"f"),A(this,je,n,"f"),A(this,mt,new we(this),"f"),this.$0=this[ri](),this[an](),A(this,tt,o(this,tt,"f"),"f"),A(this,N,o(this,N,"f"),"f"),A(this,X,o(this,X,"f"),"f"),A(this,I,o(this,I,"f"),"f"),o(this,I,"f").showHiddenOpt=o(this,_e,"f"),A(this,te,this[ni](),"f")}addHelpOpt(t,e){let n="help";return j("[string|boolean] [string]",[t,e],arguments.length),o(this,gt,"f")&&(this[Xe](o(this,gt,"f")),A(this,gt,null,"f")),t===!1&&e===void 0?this:(A(this,gt,typeof t=="string"?t:n,"f"),this.boolean(o(this,gt,"f")),this.describe(o(this,gt,"f"),e||o(this,N,"f").deferY18nLookup("Show help")),this)}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(j("[string|boolean] [string]",[t,e],arguments.length),t===!1&&e===void 0)return this;let n=typeof t=="string"?t:o(this,_e,"f");return this.boolean(n),this.describe(n,e||o(this,N,"f").deferY18nLookup("Show hidden options")),o(this,I,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return j("<object|string|array> [string|array]",[t,e],arguments.length),this[en](this.alias.bind(this),"alias",t,e),this}array(t){return j("<array|string>",[t],arguments.length),this[vt]("array",t),this[Kt](t),this}boolean(t){return j("<array|string>",[t],arguments.length),this[vt]("boolean",t),this[Kt](t),this}check(t,e){return j("<function> [boolean]",[t,e],arguments.length),this.middleware((n,i)=>Rt(()=>t(n,i.getOptions()),r=>(r?(typeof r=="string"||r instanceof Error)&&o(this,N,"f").fail(r.toString(),r):o(this,N,"f").fail(o(this,D,"f").y18n.__("Argument check failed: %s",t.toString())),n),r=>(o(this,N,"f").fail(r.message?r.message:r.toString(),r),n)),!1,e),this}choices(t,e){return j("<object|string|array> [string|array]",[t,e],arguments.length),this[en](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(j("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new G("coerce callback must be provided");for(let n of t)this.coerce(n,e);return this}else if(typeof t=="object"){for(let n of Object.keys(t))this.coerce(n,t[n]);return this}if(!e)throw new G("coerce callback must be provided");return o(this,I,"f").key[t]=!0,o(this,mt,"f").addCoerceMiddleware((n,i)=>{let r;return Object.prototype.hasOwnProperty.call(n,t)?Rt(()=>(r=i.getAliases(),e(n[t])),l=>{n[t]=l;let m=i.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[t]&&m!==!0)for(let w of r[t])n[w]=l;return n},l=>{throw new G(l.message)}):n},t),this}conflicts(t,e){return j("<string|object> [string|array]",[t,e],arguments.length),o(this,X,"f").conflicts(t,e),this}config(t="config",e,n){return j("[object|string] [string|function] [function]",[t,e,n],arguments.length),typeof t=="object"&&!Array.isArray(t)?(t=le(t,o(this,Ut,"f"),this[Gt]()["deep-merge-config"]||!1,o(this,D,"f")),o(this,I,"f").configObjects=(o(this,I,"f").configObjects||[]).concat(t),this):(typeof e=="function"&&(n=e,e=void 0),this.describe(t,e||o(this,N,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach(i=>{o(this,I,"f").config[i]=n||!0}),this)}completion(t,e,n){return j("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),typeof e=="function"&&(n=e,e=void 0),A(this,ct,t||o(this,ct,"f")||"completion","f"),!e&&e!==!1&&(e="generate completion script"),this.command(o(this,ct,"f"),e),n&&o(this,dt,"f").registerFunction(n),this}command(t,e,n,i,r,a){return j("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,i,r,a],arguments.length),o(this,tt,"f").addHandler(t,e,n,i,r,a),this}commands(t,e,n,i,r,a){return this.command(t,e,n,i,r,a)}commandDir(t,e){j("<string> [object]",[t,e],arguments.length);let n=o(this,je,"f")||o(this,D,"f").require;return o(this,tt,"f").addDirectory(t,n,o(this,D,"f").getCallerFile(),e),this}count(t){return j("<array|string>",[t],arguments.length),this[vt]("count",t),this[Kt](t),this}default(t,e,n){return j("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(Ge(t,o(this,D,"f")),o(this,I,"f").defaultDescription[t]=n),typeof e=="function"&&(Ge(t,o(this,D,"f")),o(this,I,"f").defaultDescription[t]||(o(this,I,"f").defaultDescription[t]=o(this,N,"f").functionDescription(e)),e=e.call()),this[ne](this.default.bind(this),"default",t,e),this}defaults(t,e,n){return this.default(t,e,n)}demandCommand(t=1,e,n,i){return j("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,n,i],arguments.length),typeof e!="number"&&(n=e,e=1/0),this.global("_",!1),o(this,I,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:i},this}demand(t,e,n){return Array.isArray(e)?(e.forEach(i=>{at(n,!0,o(this,D,"f")),this.demandOption(i,n)}),e=1/0):typeof e!="number"&&(n=e,e=1/0),typeof t=="number"?(at(n,!0,o(this,D,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach(i=>{at(n,!0,o(this,D,"f")),this.demandOption(i,n)}):typeof n=="string"?this.demandOption(t,n):(n===!0||typeof n>"u")&&this.demandOption(t),this}demandOption(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[ne](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return j("<string> [string|boolean]",[t,e],arguments.length),o(this,I,"f").deprecatedOptions[t]=e,this}describe(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[rn](t,!0),o(this,N,"f").describe(t,e),this}detectLocale(t){return j("<boolean>",[t],arguments.length),A(this,zt,t,"f"),this}env(t){return j("[string|boolean]",[t],arguments.length),t===!1?delete o(this,I,"f").envPrefix:o(this,I,"f").envPrefix=t||"",this}epilogue(t){return j("<string>",[t],arguments.length),o(this,N,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return j("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach(n=>this.example(...n)):o(this,N,"f").example(t,e),this}exit(t,e){A(this,ft,!0,"f"),A(this,It,e,"f"),o(this,pt,"f")&&o(this,D,"f").process.exit(t)}exitProcess(t=!0){return j("[boolean]",[t],arguments.length),A(this,pt,t,"f"),this}fail(t){if(j("<function|boolean>",[t],arguments.length),typeof t=="boolean"&&t!==!1)throw new G("Invalid first argument. Expected function or boolean 'false'");return o(this,N,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return j("<array> [function]",[t,e],arguments.length),e?o(this,dt,"f").getCompletion(t,e):new Promise((n,i)=>{o(this,dt,"f").getCompletion(t,(r,a)=>{r?i(r):n(a)})})}getDemandedOptions(){return j([],0),o(this,I,"f").demandedOptions}getDemandedCommands(){return j([],0),o(this,I,"f").demandedCommands}getDeprecatedOptions(){return j([],0),o(this,I,"f").deprecatedOptions}getDetectLocale(){return o(this,zt,"f")}getExitProcess(){return o(this,pt,"f")}getGroups(){return Object.assign({},o(this,Ct,"f"),o(this,Ht,"f"))}getHelp(){if(A(this,ft,!0,"f"),!o(this,N,"f").hasCachedHelpMessage()){if(!this.parsed){let e=this[fe](o(this,$t,"f"),void 0,void 0,0,!0);if(V(e))return e.then(()=>o(this,N,"f").help())}let t=o(this,tt,"f").runDefaultBuilderOn(this);if(V(t))return t.then(()=>o(this,N,"f").help())}return Promise.resolve(o(this,N,"f").help())}getOptions(){return o(this,I,"f")}getStrict(){return o(this,Bt,"f")}getStrictCommands(){return o(this,Yt,"f")}getStrictOptions(){return o(this,qt,"f")}global(t,e){return j("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),e!==!1?o(this,I,"f").local=o(this,I,"f").local.filter(n=>t.indexOf(n)===-1):t.forEach(n=>{o(this,I,"f").local.includes(n)||o(this,I,"f").local.push(n)}),this}group(t,e){j("<string|array> <string>",[t,e],arguments.length);let n=o(this,Ht,"f")[e]||o(this,Ct,"f")[e];o(this,Ht,"f")[e]&&delete o(this,Ht,"f")[e];let i={};return o(this,Ct,"f")[e]=(n||[]).concat(t).filter(r=>i[r]?!1:i[r]=!0),this}hide(t){return j("<string>",[t],arguments.length),o(this,I,"f").hiddenOptions.push(t),this}implies(t,e){return j("<string|object> [number|string|array]",[t,e],arguments.length),o(this,X,"f").implies(t,e),this}locale(t){return j("[string]",[t],arguments.length),t===void 0?(this[ke](),o(this,D,"f").y18n.getLocale()):(A(this,zt,!1,"f"),o(this,D,"f").y18n.setLocale(t),this)}middleware(t,e,n){return o(this,mt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return j("<string|object|array> [number]",[t,e],arguments.length),this[ne](this.nargs.bind(this),"narg",t,e),this}normalize(t){return j("<array|string>",[t],arguments.length),this[vt]("normalize",t),this}number(t){return j("<array|string>",[t],arguments.length),this[vt]("number",t),this[Kt](t),this}option(t,e){if(j("<string|object> [object]",[t,e],arguments.length),typeof t=="object")Object.keys(t).forEach(n=>{this.options(n,t[n])});else{typeof e!="object"&&(e={}),this[Kt](t),o(this,xt,"f")&&(t==="version"||e?.alias==="version")&&this[ii](['"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(`
66
+ `),void 0,"versionWarning"),o(this,I,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);let n=e.deprecate||e.deprecated;n&&this.deprecateOption(t,n);let i=e.demand||e.required||e.require;i&&this.demand(t,i),e.demandOption&&this.demandOption(t,typeof e.demandOption=="string"?e.demandOption:void 0),e.conflicts&&this.conflicts(t,e.conflicts),"default"in e&&this.default(t,e.default),e.implies!==void 0&&this.implies(t,e.implies),e.nargs!==void 0&&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||e.type==="boolean")&&(this.boolean(t),e.alias&&this.boolean(e.alias)),(e.array||e.type==="array")&&(this.array(t),e.alias&&this.array(e.alias)),(e.number||e.type==="number")&&(this.number(t),e.alias&&this.number(e.alias)),(e.string||e.type==="string")&&(this.string(t),e.alias&&this.string(e.alias)),(e.count||e.type==="count")&&this.count(t),typeof e.global=="boolean"&&this.global(t,e.global),e.defaultDescription&&(o(this,I,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);let r=e.describe||e.description||e.desc,a=o(this,N,"f").getDescriptions();(!Object.prototype.hasOwnProperty.call(a,t)||typeof r=="string")&&this.describe(t,r),e.hidden&&this.hide(t),e.requiresArg&&this.requiresArg(t)}return this}options(t,e){return this.option(t,e)}parse(t,e,n){j("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[si](),typeof t>"u"&&(t=o(this,$t,"f")),typeof e=="object"&&(A(this,Tt,e,"f"),e=n),typeof e=="function"&&(A(this,ut,e,"f"),e=!1),e||A(this,$t,t,"f"),o(this,ut,"f")&&A(this,pt,!1,"f");let i=this[fe](t,!!e),r=this.parsed;return o(this,dt,"f").setParsed(this.parsed),V(i)?i.then(a=>(o(this,ut,"f")&&o(this,ut,"f").call(this,o(this,It,"f"),a,o(this,st,"f")),a)).catch(a=>{throw o(this,ut,"f")&&o(this,ut,"f")(a,this.parsed.argv,o(this,st,"f")),a}).finally(()=>{this[on](),this.parsed=r}):(o(this,ut,"f")&&o(this,ut,"f").call(this,o(this,It,"f"),i,o(this,st,"f")),this[on](),this.parsed=r,i)}parseAsync(t,e,n){let i=this.parse(t,e,n);return V(i)?i:Promise.resolve(i)}parseSync(t,e,n){let i=this.parse(t,e,n);if(V(i))throw new G(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return i}parserConfiguration(t){return j("<object>",[t],arguments.length),A(this,Ae,t,"f"),this}pkgConf(t,e){j("<string> [string]",[t,e],arguments.length);let n=null,i=this[tn](e||o(this,Ut,"f"));return i[t]&&typeof i[t]=="object"&&(n=le(i[t],e||o(this,Ut,"f"),this[Gt]()["deep-merge-config"]||!1,o(this,D,"f")),o(this,I,"f").configObjects=(o(this,I,"f").configObjects||[]).concat(n)),this}positional(t,e){j("<string> <object>",[t,e],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=St(e,(a,l)=>a==="type"&&!["string","number","boolean"].includes(l)?!1:n.includes(a));let i=o(this,ce,"f").fullCommands[o(this,ce,"f").fullCommands.length-1],r=i?o(this,tt,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return Xt(r).forEach(a=>{let l=r[a];Array.isArray(l)?l.indexOf(t)!==-1&&(e[a]=!0):l[t]&&!(a in e)&&(e[a]=l[t])}),this.group(t,o(this,N,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return j("[boolean]",[t],arguments.length),A(this,Pe,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 j("<array|string|object> [number]",[t],arguments.length),typeof t=="string"&&o(this,I,"f").narg[t]?this:(this[ne](this.requiresArg.bind(this),"narg",t,NaN),this)}showCompletionScript(t,e){return j("[string] [string]",[t,e],arguments.length),t=t||this.$0,o(this,te,"f").log(o(this,dt,"f").generateCompletionScript(t,e||o(this,ct,"f")||"completion")),this}showHelp(t){if(j("[string|function]",[t],arguments.length),A(this,ft,!0,"f"),!o(this,N,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[fe](o(this,$t,"f"),void 0,void 0,0,!0);if(V(n))return n.then(()=>{o(this,N,"f").showHelp(t)}),this}let e=o(this,tt,"f").runDefaultBuilderOn(this);if(V(e))return e.then(()=>{o(this,N,"f").showHelp(t)}),this}return o(this,N,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return j("[boolean|string] [string]",[t,e],arguments.length),o(this,N,"f").showHelpOnFail(t,e),this}showVersion(t){return j("[string|function]",[t],arguments.length),o(this,N,"f").showVersion(t),this}skipValidation(t){return j("<array|string>",[t],arguments.length),this[vt]("skipValidation",t),this}strict(t){return j("[boolean]",[t],arguments.length),A(this,Bt,t!==!1,"f"),this}strictCommands(t){return j("[boolean]",[t],arguments.length),A(this,Yt,t!==!1,"f"),this}strictOptions(t){return j("[boolean]",[t],arguments.length),A(this,qt,t!==!1,"f"),this}string(t){return j("<array|string>",[t],arguments.length),this[vt]("string",t),this[Kt](t),this}terminalWidth(){return j([],0),o(this,D,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return j("<object>",[t],arguments.length),A(this,zt,!1,"f"),o(this,D,"f").y18n.updateLocale(t),this}usage(t,e,n,i){if(j("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,i],arguments.length),e!==void 0){if(at(t,null,o(this,D,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,i);throw new G(".usage() description must start with $0 if being used as alias for .command()")}else return o(this,N,"f").usage(t),this}usageConfiguration(t){return j("<object>",[t],arguments.length),A(this,Se,t,"f"),this}version(t,e,n){let i="version";if(j("[boolean|string] [string] [string]",[t,e,n],arguments.length),o(this,xt,"f")&&(this[Xe](o(this,xt,"f")),o(this,N,"f").version(void 0),A(this,xt,null,"f")),arguments.length===0)n=this[ai](),t=i;else if(arguments.length===1){if(t===!1)return this;n=t,t=i}else arguments.length===2&&(n=e,e=void 0);return A(this,xt,typeof t=="string"?t:i,"f"),e=e||o(this,N,"f").deferY18nLookup("Show version number"),o(this,N,"f").version(n||void 0),this.boolean(o(this,xt,"f")),this.describe(o(this,xt,"f"),e),this}wrap(t){return j("<number|null|undefined>",[t],arguments.length),o(this,N,"f").wrap(t),this}[(tt=new WeakMap,Ut=new WeakMap,ce=new WeakMap,dt=new WeakMap,ct=new WeakMap,_e=new WeakMap,It=new WeakMap,zt=new WeakMap,Ce=new WeakMap,pt=new WeakMap,xe=new WeakMap,mt=new WeakMap,Ct=new WeakMap,ft=new WeakMap,gt=new WeakMap,Ee=new WeakMap,te=new WeakMap,st=new WeakMap,I=new WeakMap,je=new WeakMap,Ae=new WeakMap,ut=new WeakMap,Tt=new WeakMap,ee=new WeakMap,Ht=new WeakMap,$t=new WeakMap,Pe=new WeakMap,D=new WeakMap,Bt=new WeakMap,Yt=new WeakMap,qt=new WeakMap,N=new WeakMap,Se=new WeakMap,xt=new WeakMap,X=new WeakMap,ei)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch{}return t}[ni](){return{log:(...t)=>{this[Me]()||console.log(...t),A(this,ft,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
67
67
  `,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")},error:(...t)=>{this[Me]()||console.error(...t),A(this,ft,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
68
- `,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")}}}[Qe](t){Xt(o(this,I,"f")).forEach(e=>{if((i=>i==="configObjects")(e))return;let n=o(this,I,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):typeof n=="object"&&delete n[t]}),delete o(this,N,"f").getDescriptions()[t]}[Xn](t,e,n){o(this,Ce,"f")[n]||(o(this,F,"f").process.emitWarning(t,e),o(this,Ce,"f")[n]=!0)}[kn](){o(this,xe,"f").push({options:o(this,I,"f"),configObjects:o(this,I,"f").configObjects.slice(0),exitProcess:o(this,pt,"f"),groups:o(this,Ct,"f"),strict:o(this,Bt,"f"),strictCommands:o(this,Gt,"f"),strictOptions:o(this,Vt,"f"),completionCommand:o(this,ct,"f"),output:o(this,st,"f"),exitError:o(this,It,"f"),hasOutput:o(this,ft,"f"),parsed:this.parsed,parseFn:o(this,ut,"f"),parseContext:o(this,Ht,"f")}),o(this,N,"f").freeze(),o(this,X,"f").freeze(),o(this,tt,"f").freeze(),o(this,mt,"f").freeze()}[ti](){let t="",e;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,F,"f").process.argv()[0])?e=o(this,F,"f").process.argv().slice(1,2):e=o(this,F,"f").process.argv().slice(0,1),t=e.map(n=>{let i=this[di](o(this,Ut,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),o(this,F,"f").getEnv("_")&&o(this,F,"f").getProcessArgvBin()===o(this,F,"f").getEnv("_")&&(t=o(this,F,"f").getEnv("_").replace(`${o(this,F,"f").path.dirname(o(this,F,"f").process.execPath())}/`,"")),t}[qt](){return o(this,Ae,"f")}[ei](){return o(this,Se,"f")}[Je](){if(!o(this,Tt,"f"))return;let t=o(this,F,"f").getEnv("LC_ALL")||o(this,F,"f").getEnv("LC_MESSAGES")||o(this,F,"f").getEnv("LANG")||o(this,F,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[ni](){return this[Ze]().version||"unknown"}[ii](t){let e=t["--"]?t["--"]:t._;for(let n=0,i;(i=e[n])!==void 0;n++)o(this,F,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`)))&&(e[n]=Number(i));return t}[Ze](t){let e=t||"*";if(o(this,ee,"f")[e])return o(this,ee,"f")[e];let n={};try{let i=t||o(this,F,"f").mainFilename;!t&&o(this,F,"f").path.extname(i)&&(i=o(this,F,"f").path.dirname(i));let r=o(this,F,"f").findUp(i,(a,c)=>{if(c.includes("package.json"))return"package.json"});ot(r,void 0,o(this,F,"f")),n=JSON.parse(o(this,F,"f").readFileSync(r,"utf8"))}catch{}return o(this,ee,"f")[e]=n||{},o(this,ee,"f")[e]}[vt](t,e){e=[].concat(e),e.forEach(n=>{n=this[tn](n),o(this,I,"f")[t].push(n)})}[ne](t,e,n,i){this[ke](t,e,n,i,(r,a,c)=>{o(this,I,"f")[r][a]=c})}[Xe](t,e,n,i){this[ke](t,e,n,i,(r,a,c)=>{o(this,I,"f")[r][a]=(o(this,I,"f")[r][a]||[]).concat(c)})}[ke](t,e,n,i,r){if(Array.isArray(n))n.forEach(a=>{t(a,i)});else if((a=>typeof a=="object")(n))for(let a of Xt(n))t(a,n[a]);else r(e,this[tn](n),i)}[tn](t){return t==="__proto__"?"___proto___":t}[en](t,e){return this[ne](this[en].bind(this),"key",t,e),this}[nn](){var t,e,n,i,r,a,c,g,w,p,h,m;let y=o(this,xe,"f").pop();ot(y,void 0,o(this,F,"f"));let E;t=this,e=this,n=this,i=this,r=this,a=this,c=this,g=this,w=this,p=this,h=this,m=this,{options:{set value(_){A(t,I,_,"f")}}.value,configObjects:E,exitProcess:{set value(_){A(e,pt,_,"f")}}.value,groups:{set value(_){A(n,Ct,_,"f")}}.value,output:{set value(_){A(i,st,_,"f")}}.value,exitError:{set value(_){A(r,It,_,"f")}}.value,hasOutput:{set value(_){A(a,ft,_,"f")}}.value,parsed:this.parsed,strict:{set value(_){A(c,Bt,_,"f")}}.value,strictCommands:{set value(_){A(g,Gt,_,"f")}}.value,strictOptions:{set value(_){A(w,Vt,_,"f")}}.value,completionCommand:{set value(_){A(p,ct,_,"f")}}.value,parseFn:{set value(_){A(h,ut,_,"f")}}.value,parseContext:{set value(_){A(m,Ht,_,"f")}}.value}=y,o(this,I,"f").configObjects=E,o(this,N,"f").unfreeze(),o(this,X,"f").unfreeze(),o(this,tt,"f").unfreeze(),o(this,mt,"f").unfreeze()}[si](t,e){return zt(e,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[ri].bind(this),getContext:this[oi].bind(this),getHasOutput:this[ai].bind(this),getLoggerInstance:this[li].bind(this),getParseContext:this[ci].bind(this),getParserConfiguration:this[qt].bind(this),getUsageConfiguration:this[ei].bind(this),getUsageInstance:this[fi].bind(this),getValidationInstance:this[ui].bind(this),hasParseCallback:this[Me].bind(this),isGlobalContext:this[hi].bind(this),postProcess:this[Kt].bind(this),reset:this[sn].bind(this),runValidation:this[rn].bind(this),runYargsParserAndExecuteCommands:this[ce].bind(this),setHasOutput:this[pi].bind(this)}}[ri](){return o(this,tt,"f")}[oi](){return o(this,le,"f")}[ai](){return o(this,ft,"f")}[li](){return o(this,te,"f")}[ci](){return o(this,Ht,"f")||{}}[fi](){return o(this,N,"f")}[ui](){return o(this,X,"f")}[Me](){return!!o(this,ut,"f")}[hi](){return o(this,Ee,"f")}[Kt](t,e,n,i){return n||q(t)||(e||(t=this[Jn](t)),(this[qt]()["parse-positional-numbers"]||this[qt]()["parse-positional-numbers"]===void 0)&&(t=this[ii](t)),i&&(t=Rt(t,this,o(this,mt,"f").getMiddleware(),!1))),t}[sn](t={}){A(this,I,o(this,I,"f")||{},"f");let e={};e.local=o(this,I,"f").local||[],e.configObjects=o(this,I,"f").configObjects||[];let n={};e.local.forEach(a=>{n[a]=!0,(t[a]||[]).forEach(c=>{n[c]=!0})}),Object.assign(o(this,Yt,"f"),Object.keys(o(this,Ct,"f")).reduce((a,c)=>{let g=o(this,Ct,"f")[c].filter(w=>!(w in n));return g.length>0&&(a[c]=g),a},{})),A(this,Ct,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return i.forEach(a=>{e[a]=(o(this,I,"f")[a]||[]).filter(c=>!n[c])}),r.forEach(a=>{e[a]=St(o(this,I,"f")[a],c=>!n[c])}),e.envPrefix=o(this,I,"f").envPrefix,A(this,I,e,"f"),A(this,N,o(this,N,"f")?o(this,N,"f").reset(n):Hn(this,o(this,F,"f")),"f"),A(this,X,o(this,X,"f")?o(this,X,"f").reset(n):Kn(this,o(this,N,"f"),o(this,F,"f")),"f"),A(this,tt,o(this,tt,"f")?o(this,tt,"f").reset():zn(o(this,N,"f"),o(this,X,"f"),o(this,mt,"f"),o(this,F,"f")),"f"),o(this,dt,"f")||A(this,dt,Gn(this,o(this,N,"f"),o(this,tt,"f"),o(this,F,"f")),"f"),o(this,mt,"f").reset(),A(this,ct,null,"f"),A(this,st,"","f"),A(this,It,null,"f"),A(this,ft,!1,"f"),this.parsed=!1,this}[di](t,e){return o(this,F,"f").path.relative(t,e)}[ce](t,e,n,i=0,r=!1){let a=!!n||r;t=t||o(this,$t,"f"),o(this,I,"f").__=o(this,F,"f").y18n.__,o(this,I,"f").configuration=this[qt]();let c=!!o(this,I,"f").configuration["populate--"],g=Object.assign({},o(this,I,"f").configuration,{"populate--":!0}),w=o(this,F,"f").Parser.detailed(t,Object.assign({},o(this,I,"f"),{configuration:{"parse-positional-numbers":!1,...g}})),p=Object.assign(w.argv,o(this,Ht,"f")),h,m=w.aliases,y=!1,E=!1;Object.keys(p).forEach(_=>{_===o(this,gt,"f")&&p[_]?y=!0:_===o(this,xt,"f")&&p[_]&&(E=!0)}),p.$0=this.$0,this.parsed=w,i===0&&o(this,N,"f").clearCachedHelpMessage();try{if(this[Je](),e)return this[Kt](p,c,!!n,!1);o(this,gt,"f")&&[o(this,gt,"f")].concat(m[o(this,gt,"f")]||[]).filter(T=>T.length>1).includes(""+p._[p._.length-1])&&(p._.pop(),y=!0),A(this,Ee,!1,"f");let _=o(this,tt,"f").getCommands(),d=o(this,dt,"f").completionKey in p,L=y||d||r;if(p._.length){if(_.length){let z;for(let T=i||0,R;p._[T]!==void 0;T++)if(R=String(p._[T]),_.includes(R)&&R!==o(this,ct,"f")){let H=o(this,tt,"f").runCommand(R,this,w,T+1,r,y||E||r);return this[Kt](H,c,!!n,!1)}else if(!z&&R!==o(this,ct,"f")){z=R;break}!o(this,tt,"f").hasDefaultCommand()&&o(this,Pe,"f")&&z&&!L&&o(this,X,"f").recommendCommands(z,_)}o(this,ct,"f")&&p._.includes(o(this,ct,"f"))&&!d&&(o(this,pt,"f")&&Mt(!0),this.showCompletionScript(),this.exit(0))}if(o(this,tt,"f").hasDefaultCommand()&&!L){let z=o(this,tt,"f").runCommand(null,this,w,0,r,y||E||r);return this[Kt](z,c,!!n,!1)}if(d){o(this,pt,"f")&&Mt(!0),t=[].concat(t);let z=t.slice(t.indexOf(`--${o(this,dt,"f").completionKey}`)+1);return o(this,dt,"f").getCompletion(z,(T,R)=>{if(T)throw new V(T.message);(R||[]).forEach(H=>{o(this,te,"f").log(H)}),this.exit(0)}),this[Kt](p,!c,!!n,!1)}if(o(this,ft,"f")||(y?(o(this,pt,"f")&&Mt(!0),a=!0,this.showHelp("log"),this.exit(0)):E&&(o(this,pt,"f")&&Mt(!0),a=!0,o(this,N,"f").showVersion("log"),this.exit(0))),!a&&o(this,I,"f").skipValidation.length>0&&(a=Object.keys(p).some(z=>o(this,I,"f").skipValidation.indexOf(z)>=0&&p[z]===!0)),!a){if(w.error)throw new V(w.error.message);if(!d){let z=this[rn](m,{},w.error);n||(h=Rt(p,this,o(this,mt,"f").getMiddleware(),!0)),h=this[si](z,h??p),q(h)&&!n&&(h=h.then(()=>Rt(p,this,o(this,mt,"f").getMiddleware(),!1)))}}}catch(_){if(_ instanceof V)o(this,N,"f").fail(_.message,_);else throw _}return this[Kt](h??p,c,!!n,!0)}[rn](t,e,n,i){let r={...this.getDemandedOptions()};return a=>{if(n)throw new V(n.message);o(this,X,"f").nonOptionCount(a),o(this,X,"f").requiredArguments(a,r);let c=!1;o(this,Gt,"f")&&(c=o(this,X,"f").unknownCommands(a)),o(this,Bt,"f")&&!c?o(this,X,"f").unknownArguments(a,t,e,!!i):o(this,Vt,"f")&&o(this,X,"f").unknownArguments(a,t,{},!1,!1),o(this,X,"f").limitedChoices(a),o(this,X,"f").implications(a),o(this,X,"f").conflicting(a)}}[pi](){A(this,ft,!0,"f")}[Qt](t){if(typeof t=="string")o(this,I,"f").key[t]=!0;else for(let e of t)o(this,I,"f").key[e]=!0}};function Un(s){return!!s&&typeof s.getInternalMethods=="function"}var Ms=mi(He),gi=Ms;await gi(Ue(process.argv)).command("$0 <file-or-url>",'Convert a tldraw ".tldr" file or tldraw.com URL to an svg or png image',s=>s.positional("file-or-url",{demandOption:!0,describe:'The sketch to convert to an image \u2014 either a path to a local ".tldr" file, or a tldraw.com sketch URL',type:"string"}).option("format",{alias:"f",choices:["png","svg"],default:"svg",describe:"Output image format",type:"string"}).option("output",{alias:"o",default:"./",describe:"Output image directory",type:"string"}).option("transparent",{alias:"t",default:!1,describe:"Output an image with a transparent background",type:"boolean"}).option("dark-mode",{alias:"d",default:!1,describe:"Output a dark theme version of the image",type:"boolean"}).option("verbose",{default:!1,describe:"Enable verbose output",type:"boolean"}),async s=>{let{darkMode:t,fileOrUrl:e,format:n,output:i,transparent:r,verbose:a}=s;try{await mn(e,{darkMode:t,format:n,output:i,transparent:r,verbose:a}),process.exit(0)}catch(c){console.error("Error during conversion:",c),process.exit(1)}}).alias("h","help").version("version",an).alias("v","version").help().parse();
68
+ `,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")}}}[Xe](t){Xt(o(this,I,"f")).forEach(e=>{if((i=>i==="configObjects")(e))return;let n=o(this,I,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):typeof n=="object"&&delete n[t]}),delete o(this,N,"f").getDescriptions()[t]}[ii](t,e,n){o(this,Ce,"f")[n]||(o(this,D,"f").process.emitWarning(t,e),o(this,Ce,"f")[n]=!0)}[si](){o(this,xe,"f").push({options:o(this,I,"f"),configObjects:o(this,I,"f").configObjects.slice(0),exitProcess:o(this,pt,"f"),groups:o(this,Ct,"f"),strict:o(this,Bt,"f"),strictCommands:o(this,Yt,"f"),strictOptions:o(this,qt,"f"),completionCommand:o(this,ct,"f"),output:o(this,st,"f"),exitError:o(this,It,"f"),hasOutput:o(this,ft,"f"),parsed:this.parsed,parseFn:o(this,ut,"f"),parseContext:o(this,Tt,"f")}),o(this,N,"f").freeze(),o(this,X,"f").freeze(),o(this,tt,"f").freeze(),o(this,mt,"f").freeze()}[ri](){let t="",e;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,D,"f").process.argv()[0])?e=o(this,D,"f").process.argv().slice(1,2):e=o(this,D,"f").process.argv().slice(0,1),t=e.map(n=>{let i=this[wi](o(this,Ut,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),o(this,D,"f").getEnv("_")&&o(this,D,"f").getProcessArgvBin()===o(this,D,"f").getEnv("_")&&(t=o(this,D,"f").getEnv("_").replace(`${o(this,D,"f").path.dirname(o(this,D,"f").process.execPath())}/`,"")),t}[Gt](){return o(this,Ae,"f")}[oi](){return o(this,Se,"f")}[ke](){if(!o(this,zt,"f"))return;let t=o(this,D,"f").getEnv("LC_ALL")||o(this,D,"f").getEnv("LC_MESSAGES")||o(this,D,"f").getEnv("LANG")||o(this,D,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[ai](){return this[tn]().version||"unknown"}[li](t){let e=t["--"]?t["--"]:t._;for(let n=0,i;(i=e[n])!==void 0;n++)o(this,D,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`)))&&(e[n]=Number(i));return t}[tn](t){let e=t||"*";if(o(this,ee,"f")[e])return o(this,ee,"f")[e];let n={};try{let i=t||o(this,D,"f").mainFilename;!t&&o(this,D,"f").path.extname(i)&&(i=o(this,D,"f").path.dirname(i));let r=o(this,D,"f").findUp(i,(a,l)=>{if(l.includes("package.json"))return"package.json"});at(r,void 0,o(this,D,"f")),n=JSON.parse(o(this,D,"f").readFileSync(r,"utf8"))}catch{}return o(this,ee,"f")[e]=n||{},o(this,ee,"f")[e]}[vt](t,e){e=[].concat(e),e.forEach(n=>{n=this[sn](n),o(this,I,"f")[t].push(n)})}[ne](t,e,n,i){this[nn](t,e,n,i,(r,a,l)=>{o(this,I,"f")[r][a]=l})}[en](t,e,n,i){this[nn](t,e,n,i,(r,a,l)=>{o(this,I,"f")[r][a]=(o(this,I,"f")[r][a]||[]).concat(l)})}[nn](t,e,n,i,r){if(Array.isArray(n))n.forEach(a=>{t(a,i)});else if((a=>typeof a=="object")(n))for(let a of Xt(n))t(a,n[a]);else r(e,this[sn](n),i)}[sn](t){return t==="__proto__"?"___proto___":t}[rn](t,e){return this[ne](this[rn].bind(this),"key",t,e),this}[on](){var t,e,n,i,r,a,l,m,w,p,h,g;let y=o(this,xe,"f").pop();at(y,void 0,o(this,D,"f"));let E;t=this,e=this,n=this,i=this,r=this,a=this,l=this,m=this,w=this,p=this,h=this,g=this,{options:{set value(_){A(t,I,_,"f")}}.value,configObjects:E,exitProcess:{set value(_){A(e,pt,_,"f")}}.value,groups:{set value(_){A(n,Ct,_,"f")}}.value,output:{set value(_){A(i,st,_,"f")}}.value,exitError:{set value(_){A(r,It,_,"f")}}.value,hasOutput:{set value(_){A(a,ft,_,"f")}}.value,parsed:this.parsed,strict:{set value(_){A(l,Bt,_,"f")}}.value,strictCommands:{set value(_){A(m,Yt,_,"f")}}.value,strictOptions:{set value(_){A(w,qt,_,"f")}}.value,completionCommand:{set value(_){A(p,ct,_,"f")}}.value,parseFn:{set value(_){A(h,ut,_,"f")}}.value,parseContext:{set value(_){A(g,Tt,_,"f")}}.value}=y,o(this,I,"f").configObjects=E,o(this,N,"f").unfreeze(),o(this,X,"f").unfreeze(),o(this,tt,"f").unfreeze(),o(this,mt,"f").unfreeze()}[ci](t,e){return Rt(e,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[fi].bind(this),getContext:this[ui].bind(this),getHasOutput:this[hi].bind(this),getLoggerInstance:this[di].bind(this),getParseContext:this[pi].bind(this),getParserConfiguration:this[Gt].bind(this),getUsageConfiguration:this[oi].bind(this),getUsageInstance:this[mi].bind(this),getValidationInstance:this[gi].bind(this),hasParseCallback:this[Me].bind(this),isGlobalContext:this[bi].bind(this),postProcess:this[Vt].bind(this),reset:this[an].bind(this),runValidation:this[ln].bind(this),runYargsParserAndExecuteCommands:this[fe].bind(this),setHasOutput:this[yi].bind(this)}}[fi](){return o(this,tt,"f")}[ui](){return o(this,ce,"f")}[hi](){return o(this,ft,"f")}[di](){return o(this,te,"f")}[pi](){return o(this,Tt,"f")||{}}[mi](){return o(this,N,"f")}[gi](){return o(this,X,"f")}[Me](){return!!o(this,ut,"f")}[bi](){return o(this,Ee,"f")}[Vt](t,e,n,i){return n||V(t)||(e||(t=this[ei](t)),(this[Gt]()["parse-positional-numbers"]||this[Gt]()["parse-positional-numbers"]===void 0)&&(t=this[li](t)),i&&(t=Wt(t,this,o(this,mt,"f").getMiddleware(),!1))),t}[an](t={}){A(this,I,o(this,I,"f")||{},"f");let e={};e.local=o(this,I,"f").local||[],e.configObjects=o(this,I,"f").configObjects||[];let n={};e.local.forEach(a=>{n[a]=!0,(t[a]||[]).forEach(l=>{n[l]=!0})}),Object.assign(o(this,Ht,"f"),Object.keys(o(this,Ct,"f")).reduce((a,l)=>{let m=o(this,Ct,"f")[l].filter(w=>!(w in n));return m.length>0&&(a[l]=m),a},{})),A(this,Ct,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return i.forEach(a=>{e[a]=(o(this,I,"f")[a]||[]).filter(l=>!n[l])}),r.forEach(a=>{e[a]=St(o(this,I,"f")[a],l=>!n[l])}),e.envPrefix=o(this,I,"f").envPrefix,A(this,I,e,"f"),A(this,N,o(this,N,"f")?o(this,N,"f").reset(n):Vn(this,o(this,D,"f")),"f"),A(this,X,o(this,X,"f")?o(this,X,"f").reset(n):kn(this,o(this,N,"f"),o(this,D,"f")),"f"),A(this,tt,o(this,tt,"f")?o(this,tt,"f").reset():Yn(o(this,N,"f"),o(this,X,"f"),o(this,mt,"f"),o(this,D,"f")),"f"),o(this,dt,"f")||A(this,dt,Jn(this,o(this,N,"f"),o(this,tt,"f"),o(this,D,"f")),"f"),o(this,mt,"f").reset(),A(this,ct,null,"f"),A(this,st,"","f"),A(this,It,null,"f"),A(this,ft,!1,"f"),this.parsed=!1,this}[wi](t,e){return o(this,D,"f").path.relative(t,e)}[fe](t,e,n,i=0,r=!1){let a=!!n||r;t=t||o(this,$t,"f"),o(this,I,"f").__=o(this,D,"f").y18n.__,o(this,I,"f").configuration=this[Gt]();let l=!!o(this,I,"f").configuration["populate--"],m=Object.assign({},o(this,I,"f").configuration,{"populate--":!0}),w=o(this,D,"f").Parser.detailed(t,Object.assign({},o(this,I,"f"),{configuration:{"parse-positional-numbers":!1,...m}})),p=Object.assign(w.argv,o(this,Tt,"f")),h,g=w.aliases,y=!1,E=!1;Object.keys(p).forEach(_=>{_===o(this,gt,"f")&&p[_]?y=!0:_===o(this,xt,"f")&&p[_]&&(E=!0)}),p.$0=this.$0,this.parsed=w,i===0&&o(this,N,"f").clearCachedHelpMessage();try{if(this[ke](),e)return this[Vt](p,l,!!n,!1);o(this,gt,"f")&&[o(this,gt,"f")].concat(g[o(this,gt,"f")]||[]).filter(Y=>Y.length>1).includes(""+p._[p._.length-1])&&(p._.pop(),y=!0),A(this,Ee,!1,"f");let _=o(this,tt,"f").getCommands(),d=o(this,dt,"f").completionKey in p,W=y||d||r;if(p._.length){if(_.length){let R;for(let Y=i||0,U;p._[Y]!==void 0;Y++)if(U=String(p._[Y]),_.includes(U)&&U!==o(this,ct,"f")){let T=o(this,tt,"f").runCommand(U,this,w,Y+1,r,y||E||r);return this[Vt](T,l,!!n,!1)}else if(!R&&U!==o(this,ct,"f")){R=U;break}!o(this,tt,"f").hasDefaultCommand()&&o(this,Pe,"f")&&R&&!W&&o(this,X,"f").recommendCommands(R,_)}o(this,ct,"f")&&p._.includes(o(this,ct,"f"))&&!d&&(o(this,pt,"f")&&Mt(!0),this.showCompletionScript(),this.exit(0))}if(o(this,tt,"f").hasDefaultCommand()&&!W){let R=o(this,tt,"f").runCommand(null,this,w,0,r,y||E||r);return this[Vt](R,l,!!n,!1)}if(d){o(this,pt,"f")&&Mt(!0),t=[].concat(t);let R=t.slice(t.indexOf(`--${o(this,dt,"f").completionKey}`)+1);return o(this,dt,"f").getCompletion(R,(Y,U)=>{if(Y)throw new G(Y.message);(U||[]).forEach(T=>{o(this,te,"f").log(T)}),this.exit(0)}),this[Vt](p,!l,!!n,!1)}if(o(this,ft,"f")||(y?(o(this,pt,"f")&&Mt(!0),a=!0,this.showHelp("log"),this.exit(0)):E&&(o(this,pt,"f")&&Mt(!0),a=!0,o(this,N,"f").showVersion("log"),this.exit(0))),!a&&o(this,I,"f").skipValidation.length>0&&(a=Object.keys(p).some(R=>o(this,I,"f").skipValidation.indexOf(R)>=0&&p[R]===!0)),!a){if(w.error)throw new G(w.error.message);if(!d){let R=this[ln](g,{},w.error);n||(h=Wt(p,this,o(this,mt,"f").getMiddleware(),!0)),h=this[ci](R,h??p),V(h)&&!n&&(h=h.then(()=>Wt(p,this,o(this,mt,"f").getMiddleware(),!1)))}}}catch(_){if(_ instanceof G)o(this,N,"f").fail(_.message,_);else throw _}return this[Vt](h??p,l,!!n,!0)}[ln](t,e,n,i){let r={...this.getDemandedOptions()};return a=>{if(n)throw new G(n.message);o(this,X,"f").nonOptionCount(a),o(this,X,"f").requiredArguments(a,r);let l=!1;o(this,Yt,"f")&&(l=o(this,X,"f").unknownCommands(a)),o(this,Bt,"f")&&!l?o(this,X,"f").unknownArguments(a,t,e,!!i):o(this,qt,"f")&&o(this,X,"f").unknownArguments(a,t,{},!1,!1),o(this,X,"f").limitedChoices(a),o(this,X,"f").implications(a),o(this,X,"f").conflicting(a)}}[yi](){A(this,ft,!0,"f")}[Kt](t){if(typeof t=="string")o(this,I,"f").key[t]=!0;else for(let e of t)o(this,I,"f").key[e]=!0}};function qn(s){return!!s&&typeof s.getInternalMethods=="function"}var Ws=Oi(qe),_i=Ws;await _i(Be(process.argv)).command("$0 <file-or-url>",'Convert a tldraw ".tldr" file or tldraw.com URL to an svg or png image',s=>s.positional("file-or-url",{demandOption:!0,describe:'The sketch to convert to an image \u2014 either a path to a local ".tldr" file, or a tldraw.com sketch URL',type:"string"}).option("format",{alias:"f",choices:["png","svg"],default:"svg",describe:"Output image format",type:"string"}).option("output",{alias:"o",default:"./",describe:"Output image directory",type:"string"}).option("transparent",{alias:"t",default:!1,describe:"Output an image with a transparent background",type:"boolean"}).option("dark-mode",{alias:"d",default:!1,describe:"Output a dark theme version of the image",type:"boolean"}).option("verbose",{default:!1,describe:"Enable verbose output",type:"boolean"}),async s=>{let{darkMode:t,fileOrUrl:e,format:n,output:i,transparent:r,verbose:a}=s;try{await On(e,{darkMode:t,format:n,output:i,transparent:r,verbose:a}),process.exit(0)}catch(l){console.error("Error during conversion:",l),process.exit(1)}}).alias("h","help").version("version",fn).alias("v","version").help().parse();
69
69
  /*! Bundled license information:
70
70
 
71
71
  yargs-parser/build/lib/string-utils.js:
package/dist/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import R from"express";import L from"node:net";import O from"node:os";var b=class extends Error{constructor(t){super(`${t} is locked`)}},u={old:new Set,young:new Set},j=1e3*15;var w,F=()=>{let e=O.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(e))for(let o of r)t.add(o.address);return t},I=e=>new Promise((t,r)=>{let o=L.createServer();o.unref(),o.on("error",r),o.listen(e,()=>{let{port:n}=o.address();o.close(()=>{t(n)})})}),D=async(e,t)=>{if(e.host||e.port===0)return I(e);for(let r of t)try{await I({port:e.port,host:r})}catch(o){if(!["EADDRNOTAVAIL","EINVAL"].includes(o.code))throw o}return e.port},q=function*(e){e&&(yield*e),yield 0};async function P(e){let t,r=new Set;if(e&&(e.port&&(t=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let n=e.exclude;if(typeof n[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let a of n){if(typeof a!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(a))throw new TypeError(`Number ${a} in the exclude option is not a safe integer and can't be used`)}r=new Set(n)}w===void 0&&(w=setTimeout(()=>{w=void 0,u.old=u.young,u.young=new Set},j),w.unref&&w.unref());let o=F();for(let n of q(t))try{if(r.has(n))continue;let a=await D({...e,port:n},o);for(;u.old.has(a)||u.young.has(a);){if(n!==0)throw new b(n);a=await D({...e,port:n},o)}return u.young.add(a),a}catch(a){if(!["EADDRINUSE","EACCES"].includes(a.code)&&!(a instanceof b))throw a}throw new Error("No available ports found")}import M from"node:fs/promises";import N from"node:os";import l from"node:path";import{dirname as V}from"node:path";import{fileURLToPath as _}from"node:url";import G from"puppeteer";import U from"node:os";var T=U.homedir();function y(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return T?e.replace(/^~(?=$|\/|\\)/,T):e}var H={darkMode:!1,format:"svg",output:"./",transparent:!1,verbose:!0};async function W(e,t={}){let r={...H,...X(t)},{darkMode:o,format:n,output:a,transparent:p,verbose:s}=r,c=!e.startsWith("https://www.tldraw.com/");s&&console.log(c?"Local file detected":"tldraw URL detected");let h=0,m;if(c){s&&console.log("Starting tldraw server...");let d=V(_(import.meta.url)),g=l.join(d,d.endsWith("/src/lib")?"../../dist/tldraw":d.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");s&&console.log(`tldraw served from "${g}"`),m=await J(g),h=m.address().port,s&&console.log(`tldraw hosted at "http://localhost:${h}"`)}s&&console.log("Starting Puppeteer...");let S=await G.launch({args:c?["--no-sandbox","--disable-web-security"]:[],headless:"new"}),i=await S.newPage();z(i,s);let $=await i.target().createCDPSession();if(await $.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:N.tmpdir(),eventsEnabled:!0}),c){await i.setRequestInterception(!0),i.on("request",f=>{f.url().endsWith("favicon.ico")?f.respond({status:200}):f.continue()});let d=l.resolve(y(e));s&&console.log(`Loading tldr file "${d}"`);let g=await M.readFile(d,"utf8");await i.evaluateOnNewDocument(f=>{localStorage.clear(),localStorage.setItem("tldrData",f)},g)}let x=c?`http://localhost:${h}`:e;s&&console.log(`Navigating to: ${x}`),await i.goto(x,{waitUntil:"networkidle0"}),s&&console.log(`Setting background transparency: ${p}`),await ee(i,p),s&&console.log(`Setting dark mode: ${o}`);let k=await Z(i);await A(i,o),s&&console.log("Requesting download"),await Y(i),await Q(i,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${n}`]);let E=await K($);s&&console.log("Download complete"),s&&console.log(`Restoring dark mode: ${k}`),await A(i,k),await S.close(),s&&console.log("Stopped Puppeteer"),c&&m&&(m.close(),s&&console.log("Stopped tldraw server"));let B=c?l.basename(e,l.extname(e)):E,C=l.join(N.tmpdir(),E),v=y(l.join(a,`${B}.${n}`));return await M.rename(C,v),s&&console.log(`Saved to "${v}"`),l.resolve(v)}function z(e,t){e.on("console",r=>{let o=r.type(),n=r.text();o==="error"?console.error(`[Browser] ${n}`):o==="warning"?console.warn(`[Browser] ${n}`):t&&console.log(`[Browser] ${n}`)})}async function J(e){let t=R(),r=await P();return t.use(R.static(e)),new Promise((o,n)=>{let a=t.listen(r,()=>{o(a)});a.on("error",p=>{n(p)})})}async function K(e){return new Promise((t,r)=>{e.on("Browser.downloadProgress",o=>{o.state==="completed"?t(o.guid):o.state==="canceled"&&r(new Error("Download was canceled"))})})}async function Q(e,t){for(let r of t)await e.waitForSelector(`[data-testid="${r}"]`),await e.click(`[data-testid="${r}"]`)}function X(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}async function Y(e){await e.evaluate("app.clearOpenMenus()")}async function Z(e){return!!await e.evaluate("editor.user.getUserPreferences().isDarkMode")}async function A(e,t){await e.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${t}})`)}async function ee(e,t){await e.evaluate(`editor.updateInstanceState(
2
- { exportBackground: ${!t} },
1
+ import F from"node:path";import{fileURLToPath as V}from"node:url";import q,{promises as H}from"fs";async function P(e,o,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await H[e](r))[o]()}catch(t){if(t.code==="ENOENT")return!1;throw t}}function x(e,o,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return q[e](r)[o]()}catch(t){if(t.code==="ENOENT")return!1;throw t}}var de=P.bind(null,"stat","isFile"),fe=P.bind(null,"stat","isDirectory"),ue=P.bind(null,"lstat","isSymbolicLink"),R=x.bind(null,"statSync","isFile"),pe=x.bind(null,"statSync","isDirectory"),me=x.bind(null,"lstatSync","isSymbolicLink");import z from"node:os";var O=z.homedir();function w(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return O?e.replace(/^~(?=$|\/|\\)/,O):e}function S(e,o={}){let{requireFileExistence:r,validFileExtensions:t,validHostnames:n}=o;if(URL.canParse(e)){let l=new URL(e);if(l.protocol==="file:")return S(V(l),o);if(n&&!n.includes(l.hostname))throw new Error(`Bad input URL. Only ${n.join(", ")} URLs are supported.`);return l}let i=w(e),c=F.normalize(i);if(r&&!R(c))throw new Error("Input is not a file.");let s=F.extname(c);if(t&&!t.includes(s))throw new Error(`Bad input file name. Only ${t.join(", ")} files are supported.`);return c}import U from"express";import _ from"node:net";import G from"node:os";var b=class extends Error{constructor(o){super(`${o} is locked`)}},u={old:new Set,young:new Set},J=1e3*15;var g,K=()=>{let e=G.networkInterfaces(),o=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(e))for(let t of r)o.add(t.address);return o},L=e=>new Promise((o,r)=>{let t=_.createServer();t.unref(),t.on("error",r),t.listen(e,()=>{let{port:n}=t.address();t.close(()=>{o(n)})})}),N=async(e,o)=>{if(e.host||e.port===0)return L(e);for(let r of o)try{await L({port:e.port,host:r})}catch(t){if(!["EADDRNOTAVAIL","EINVAL"].includes(t.code))throw t}return e.port},Q=function*(e){e&&(yield*e),yield 0};async function E(e){let o,r=new Set;if(e&&(e.port&&(o=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let n=e.exclude;if(typeof n[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let i of n){if(typeof i!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(i))throw new TypeError(`Number ${i} in the exclude option is not a safe integer and can't be used`)}r=new Set(n)}g===void 0&&(g=setTimeout(()=>{g=void 0,u.old=u.young,u.young=new Set},J),g.unref&&g.unref());let t=K();for(let n of Q(o))try{if(r.has(n))continue;let i=await N({...e,port:n},t);for(;u.old.has(i)||u.young.has(i);){if(n!==0)throw new b(n);i=await N({...e,port:n},t)}return u.young.add(i),i}catch(i){if(!["EADDRINUSE","EACCES"].includes(i.code)&&!(i instanceof b))throw i}throw new Error("No available ports found")}import M from"node:fs/promises";import A from"node:os";import p from"node:path";import{dirname as W}from"node:path";import{fileURLToPath as X}from"node:url";import Y from"puppeteer";var Z={darkMode:!1,format:"svg",output:"./",transparent:!1,verbose:!1};async function ee(e,o={}){let r={...Z,...ie(o)},{darkMode:t,format:n,output:i,transparent:c,verbose:s}=r,l=S(e,{requireFileExistence:!0,validFileExtensions:[".tldr"],validHostnames:["www.tldraw.com"]}),f=typeof l=="string";s&&console.log(f?"Local file detected":"tldraw URL detected");let h=0,y;if(f){s&&console.log("Starting tldraw server...");let m=W(X(import.meta.url)),d=p.join(m,m.endsWith("/src/lib")?"../../dist/tldraw":m.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");s&&console.log(`tldraw served from "${d}"`),y=await oe(d),h=y.address().port,s&&console.log(`tldraw hosted at "http://localhost:${h}"`)}s&&console.log("Starting Puppeteer...");let $=await Y.launch({args:f?["--no-sandbox","--disable-web-security"]:[],headless:"new"}),a=await $.newPage();te(a,s);let k=await a.target().createCDPSession();if(await k.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:A.tmpdir(),eventsEnabled:!0}),f){await a.setRequestInterception(!0),a.on("request",d=>{d.url().endsWith("favicon.ico")?d.respond({status:200}):d.continue()}),s&&console.log(`Loading tldr file "${l}"`);let m=await M.readFile(l,"utf8");await a.evaluateOnNewDocument(d=>{localStorage.clear(),localStorage.setItem("tldrData",d)},m)}let D=f?`http://localhost:${h}`:l.href;s&&console.log(`Navigating to: ${D}`),await a.goto(D,{waitUntil:"networkidle0"}),s&&console.log(`Setting background transparency: ${c}`),await le(a,c),s&&console.log(`Setting dark mode: ${t}`);let I=await ae(a);await B(a,t),s&&console.log("Requesting download"),await se(a),await ne(a,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${n}`]);let T=await re(k);s&&console.log("Download complete"),s&&console.log(`Restoring dark mode: ${I}`),await B(a,I),await $.close(),s&&console.log("Stopped Puppeteer"),f&&y&&(y.close(),s&&console.log("Stopped tldraw server"));let j=f?p.basename(l,p.extname(l)):T,C=p.join(A.tmpdir(),T),v=w(p.join(i,`${j}.${n}`));return await M.rename(C,v),s&&console.log(`Saved to "${v}"`),p.resolve(v)}function te(e,o){e.on("console",r=>{let t=r.type(),n=r.text();t==="error"?console.error(`[Browser] ${n}`):t==="warning"?console.warn(`[Browser] ${n}`):o&&console.log(`[Browser] ${n}`)})}async function oe(e){let o=U(),r=await E();return o.use(U.static(e)),new Promise((t,n)=>{let i=o.listen(r,()=>{t(i)});i.on("error",c=>{n(c)})})}async function re(e){return new Promise((o,r)=>{e.on("Browser.downloadProgress",t=>{t.state==="completed"?o(t.guid):t.state==="canceled"&&r(new Error("Download was canceled"))})})}async function ne(e,o){for(let r of o)await e.waitForSelector(`[data-testid="${r}"]`),await e.click(`[data-testid="${r}"]`)}function ie(e){return Object.fromEntries(Object.entries(e).filter(([,o])=>o!==void 0))}async function se(e){await e.evaluate("app.clearOpenMenus()")}async function ae(e){return!!await e.evaluate("editor.user.getUserPreferences().isDarkMode")}async function B(e,o){await e.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${o}})`)}async function le(e,o){await e.evaluate(`editor.updateInstanceState(
2
+ { exportBackground: ${!o} },
3
3
  { ephemeral: true },
4
- )`)}export{W as tldrawToImage};
4
+ )`)}export{ee as tldrawToImage};
@@ -0,0 +1,5 @@
1
+ export declare function validatePathOrUrl(pathOrUrl: string, options?: {
2
+ requireFileExistence?: boolean;
3
+ validFileExtensions?: string[];
4
+ validHostnames?: string[];
5
+ }): URL | string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitschpatrol/tldraw-cli",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "type": "module",
5
5
  "description": "A tiny little CLI tool for rendering tldraw URLs and .tldr files into svg or png images.",
6
6
  "repository": {
@@ -59,6 +59,7 @@
59
59
  "eslint-plugin-react-hooks": "^4.6.0",
60
60
  "eslint-plugin-react-refresh": "^0.4.5",
61
61
  "get-port": "^7.0.0",
62
+ "path-type": "^5.0.0",
62
63
  "react": "^18.2.0",
63
64
  "react-dom": "^18.2.0",
64
65
  "tsx": "^4.7.0",