@kitschpatrol/tldraw-cli 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- var Ot=(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="1.0.1";import hn from"express";import bi from"node:net";import wi from"node:os";var he=class extends Error{constructor(t){super(`${t} is locked`)}},Zt={old:new Set,young:new Set},yi=1e3*15;var ie,Oi=()=>{let s=wi.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=bi.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},_i=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},yi),ie.unref&&ie.unref());let n=Oi();for(let i of _i(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 he(i);r=await cn({...s,port:i},n)}return Zt.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 un from"node:fs/promises";import dn from"node:os";import Wt from"node:path";import{dirname as xi}from"node:path";import{fileURLToPath as Ei}from"node:url";import ji from"puppeteer";import Ci from"node:os";var fn=Ci.homedir();function ue(s){if(typeof s!="string")throw new TypeError(`Expected a string, got ${typeof s}`);return fn?s.replace(/^~(?=$|\/|\\)/,fn):s}async function Ai(s){let t=hn(),e=await $e();return t.use(hn.static(s)),new Promise((n,i)=>{let r=t.listen(e,()=>{n(r)});r.on("error",a=>{i(a)})})}async function Pi(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 pn(s,t="svg",e="./",n=!1){let i=xi(Ei(import.meta.url)),r=Wt.resolve(ue(s));n&&console.log(`Loading tldr file "${r}"`);let a=await un.readFile(r,"utf8");n&&console.log("Starting tldraw server..."),console.log(`scriptDirectory: ${i}`);let c=Wt.join(i,i.endsWith("/src/lib")?"../../dist/tldraw":i.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");n&&console.log(`tldraw served from "${c}"`);let g=await Ai(c),{port:w}=g.address();n&&console.log(`tldraw hosted at "http://localhost:${w}"`),n&&console.log("Starting Puppeteer...");let p=await ji.launch({headless:"new"}),u=await p.newPage();await u.setRequestInterception(!0),u.on("request",D=>{D.url().endsWith("favicon.ico")?D.respond({status:200}):D.continue()}),u.on("console",D=>{let z=D.type(),T=D.text();z==="error"?console.error(`[Browser] ${T}`):z==="warning"?console.warn(`[Browser] ${T}`):n&&console.log(`[Browser] ${T}`)});let m=await u.target().createCDPSession();await m.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:dn.tmpdir(),eventsEnabled:!0}),await u.goto(`http://localhost:${w}`),await u.waitForFunction(()=>window.tldrawExportFile!==void 0),n&&console.log("Requesting download"),await u.evaluate((D,z)=>{window.tldrawExportFile(D,z)},a,t);let y=await Pi(m);n&&console.log("Download complete"),await p.close(),n&&console.log("Stopped Puppeteer");let E=Wt.basename(s,Wt.extname(s)),_=Wt.join(dn.tmpdir(),y),d=ue(Wt.join(e,`${E}.${t}`));return await un.rename(_,d),n&&console.log(`Saved to "${d}"`),g.close(),n&&console.log("Stopped tldraw server"),Wt.resolve(d)}import{notStrictEqual as Xi,strictEqual as ki}from"assert";var Si={right:Fi,center:Ni},Ii=0,de=1,Mi=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(`
2
+ var Ot=(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 cn="1.1.1";import dn from"express";import yi from"node:net";import Oi from"node:os";var ue=class extends Error{constructor(t){super(`${t} is locked`)}},Zt={old:new Set,young:new Set},_i=1e3*15;var ie,Ci=()=>{let s=Oi.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},fn=s=>new Promise((t,e)=>{let n=yi.createServer();n.unref(),n.on("error",e),n.listen(s,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),hn=async(s,t)=>{if(s.host||s.port===0)return fn(s);for(let e of t)try{await fn({port:s.port,host:e})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return s.port},xi=function*(s){s&&(yield*s),yield 0};async function ve(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},_i),ie.unref&&ie.unref());let n=Ci();for(let i of xi(t))try{if(e.has(i))continue;let r=await hn({...s,port:i},n);for(;Zt.old.has(r)||Zt.young.has(r);){if(i!==0)throw new ue(i);r=await hn({...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 Fe from"node:fs/promises";import de from"node:os";import jt from"node:path";import{dirname as ji}from"node:path";import{fileURLToPath as Ai}from"node:url";import pn from"puppeteer";import Ei from"node:os";var un=Ei.homedir();function se(s){if(typeof s!="string")throw new TypeError(`Expected a string, got ${typeof s}`);return un?s.replace(/^~(?=$|\/|\\)/,un):s}async function mn(s,t="svg",e="./",n=!1){return s.startsWith("https://www.tldraw.com/")?(n&&console.log("tldraw URL detected"),Pi(s,t,e,n)):(n&&console.log("Local file detected"),Si(s,t,e,n))}async function Pi(s,t,e,n){n&&console.log("Starting Puppeteer...");let r=await(await pn.launch({headless:"new"})).newPage(),a=await r.target().createCDPSession();await a.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:de.tmpdir(),eventsEnabled:!0}),n&&console.log(`Navigating to: ${s}`),await r.goto(s,{waitUntil:"networkidle0"}),n&&console.log("Requesting download"),await $i(r,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${t}`]);let c=await gn(a);n&&console.log("Download complete");let m=jt.join(de.tmpdir(),c),w=se(jt.join(e,`${c}.${t}`));return await Fe.rename(m,w),n&&console.log(`Saved to "${w}"`),w}async function Si(s,t,e,n){let i=ji(Ai(import.meta.url)),r=jt.resolve(se(s));n&&console.log(`Loading tldr file "${r}"`);let a=await Fe.readFile(r,"utf8");n&&console.log("Starting tldraw server...");let c=jt.join(i,i.endsWith("/src/lib")?"../../dist/tldraw":i.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");n&&console.log(`tldraw served from "${c}"`);let m=await Mi(c),{port:w}=m.address();n&&console.log(`tldraw hosted at "http://localhost:${w}"`),n&&console.log("Starting Puppeteer...");let p=await pn.launch({headless:"new"}),u=await p.newPage();await u.setRequestInterception(!0),u.on("request",W=>{W.url().endsWith("favicon.ico")?W.respond({status:200}):W.continue()}),Ii(u,n);let g=await u.target().createCDPSession();await g.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:de.tmpdir(),eventsEnabled:!0}),await u.goto(`http://localhost:${w}`),await u.waitForFunction(()=>window.tldrawExportFile!==void 0),n&&console.log("Requesting download"),await u.evaluate((W,z)=>{window.tldrawExportFile(W,z)},a,t);let y=await gn(g);n&&console.log("Download complete"),await p.close(),n&&console.log("Stopped Puppeteer");let E=jt.basename(s,jt.extname(s)),_=jt.join(de.tmpdir(),y),d=se(jt.join(e,`${E}.${t}`));return await Fe.rename(_,d),n&&console.log(`Saved to "${d}"`),m.close(),n&&console.log("Stopped tldraw server"),jt.resolve(d)}function Ii(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=dn(),e=await ve();return t.use(dn.static(s)),new Promise((n,i)=>{let r=t.listen(e,()=>{n(r)});r.on("error",a=>{i(a)})})}async function gn(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}"]`)}import{notStrictEqual as ns,strictEqual as is}from"assert";var vi={right:Li,center:zi},Fi=0,pe=1,Ni=2,me=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(`
3
3
  `).map(i=>i.split(" ")),n=0;return e.forEach(i=>{i.length>1&&at.stringWidth(i[0])>n&&(n=Math.min(Math.floor(this.width*.5),at.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=at.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(`
4
- `)}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>at.stringWidth(a)&&(p+=" ".repeat(w-at.stringWidth(a))),t[c].align&&t[c].align!=="left"&&this.wrap){let m=Si[t[c].align];p=m(p,w),at.stringWidth(p)<w&&(p+=" ".repeat((g||0)-at.stringWidth(p)-1))}let u=t[c].padding||[0,0,0,0];u[pe]&&(r+=" ".repeat(u[pe])),r+=mn(t[c],p,"| "),r+=p,r+=mn(t[c],p," |"),u[de]&&(r+=" ".repeat(u[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=at.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=at.wrap(r.text,this.negatePadding(r),{hard:!0}).split(`
4
+ `)}rowToString(t,e){return this.rasterize(t).forEach((n,i)=>{let r="";n.forEach((a,c)=>{let{width:m}=t[c],w=this.negatePadding(t[c]),p=a;if(w>at.stringWidth(a)&&(p+=" ".repeat(w-at.stringWidth(a))),t[c].align&&t[c].align!=="left"&&this.wrap){let g=vi[t[c].align];p=g(p,w),at.stringWidth(p)<w&&(p+=" ".repeat((m||0)-at.stringWidth(p)-1))}let u=t[c].padding||[0,0,0,0];u[me]&&(r+=" ".repeat(u[me])),r+=bn(t[c],p,"| "),r+=p,r+=bn(t[c],p," |"),u[pe]&&(r+=" ".repeat(u[pe])),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=at.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=at.wrap(r.text,this.negatePadding(r),{hard:!0}).split(`
5
5
  `):i=r.text.split(`
6
- `),r.border&&(i.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(r)+2)+"'")),r.padding&&(i.unshift(...new Array(r.padding[Ii]||0).fill("")),i.push(...new Array(r.padding[Mi]||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||at.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,$i(t[c])):a)}};function mn(s,t,e){return s.border?/[.']-+[.']/.test(t)?"":t.trim().length!==0?e:" ":""}function $i(s){let t=s.padding||[],e=1+(t[pe]||0)+(t[de]||0);return s.border?e+4:e}function vi(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Fi(s,t){s=s.trim();let e=at.stringWidth(s);return e<t?" ".repeat(t-e)+s:s}function Ni(s,t){s=s.trim();let e=at.stringWidth(s);return e>=t?s:" ".repeat(t-e>>1)+s}var at;function gn(s,t){return at=t,new ve({width:s?.width||vi(),wrap:s?.wrap})}var bn=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function Fe(s){return s.replace(bn,"")}function wn(s,t){let[e,n]=s.match(bn)||["",""];s=Fe(s);let i="";for(let r=0;r<s.length;r++)r!==0&&r%t===0&&(i+=`
7
- `),i+=s.charAt(r);return e&&n&&(i=`${e}${i}${n}`),i}function Ne(s){return gn(s,{stringWidth:t=>[...t].length,stripAnsi:Fe,wrap:wn})}import{dirname as yn,resolve as On}from"path";import{readdirSync as Di,statSync as Wi}from"fs";function _n(s,t){let e=On(".",s),n;for(Wi(e).isDirectory()||(e=yn(e));;){if(n=t(e,Di(e)),n)return On(e,n);if(e=yn(n=e),n===e)break}}import{inspect as ts}from"util";import{readFileSync as es}from"fs";import{fileURLToPath as ns}from"url";import{format as Ri}from"util";import{normalize as Ui,resolve as Ti}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 Cn(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 jt,be=class{constructor(t){jt=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=Cn(t),r=typeof t=="string",a=Li(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,u=c["populate--"],m=u?"--":"_",y=Object.create(null),E=Object.create(null),_=n.__||jt.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:[]},D=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,z=new RegExp("^--"+c["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(l){let h=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][h]=!0),d.arrays[h]=!0,d.keys.push(h)}),[].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,h])=>{typeof h=="number"&&(d.nargs[l]=h,d.keys.push(l))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([l,h])=>{typeof h=="function"&&(d.coercions[l]=h,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,h])=>{(typeof h=="boolean"||typeof h=="function")&&(d.configs[l]=h)})),Dt(n.key,a,n.default,d.arrays),Object.keys(g).forEach(function(l){(d.aliases[l]||[]).forEach(function(h){g[h]=g[l]})});let T=null;fe();let U=[],B=Object.assign(Object.create(null),{_:[]}),At={};for(let l=0;l<i.length;l++){let h=i[l],O=h.replace(/^-{3,}/,"---"),b,f,S,x,$,it;if(h!=="--"&&/^-/.test(h)&&J(h))gt(h);else if(O.match(/^---+(=|$)/)){gt(h);continue}else if(h.match(/^--.+=/)||!c["short-option-groups"]&&h.match(/^-.+=/))x=h.match(/^--?([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&(F(x[1],d.arrays)?l=Ft(l,x[1],i,x[2]):F(x[1],d.nargs)!==!1?l=Jt(l,x[1],i,x[2]):G(x[1],x[2],!0));else if(h.match(z)&&c["boolean-negation"])x=h.match(z),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],G(f,F(f,d.arrays)?[!1]:!1));else if(h.match(/^--.+/)||!c["short-option-groups"]&&h.match(/^-[^-]+/))x=h.match(/^--?(.+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],F(f,d.arrays)?l=Ft(l,f,i):F(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!$.match(/^-/)||$.match(D))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))));else if(h.match(/^-.\..+=/))x=h.match(/^-([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&G(x[1],x[2]);else if(h.match(/^-.\..+/)&&!h.match(D))$=i[l+1],x=h.match(/^-(.\..+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],$!==void 0&&!$.match(/^-/)&&!F(f,d.bools)&&!F(f,d.counts)?(G(f,$),l++):G(f,Z(f)));else if(h.match(/^-[^-]+/)&&!h.match(D)){S=h.slice(1,-1).split(""),b=!1;for(let rt=0;rt<S.length;rt++){if($=h.slice(rt+2),S[rt+1]&&S[rt+1]==="="){it=h.slice(rt+3),f=S[rt],F(f,d.arrays)?l=Ft(l,f,i,it):F(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($)&&F($,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=h.slice(-1)[0],!b&&f!=="-"&&(F(f,d.arrays)?l=Ft(l,f,i):F(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(D))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))))}else if(h.match(/^-[0-9]$/)&&h.match(D)&&F(h.slice(1),d.bools))f=h.slice(1),G(f,Z(f));else if(h==="--"){U=i.slice(l+1);break}else if(c["halt-at-non-option"]){U=i.slice(l);break}else gt(h)}H(B,!0),H(B,!1),L(B),et(),Q(B,d.aliases,g,!0),nt(B),c["set-placeholder-key"]&&Nt(B),Object.keys(d.counts).forEach(function(l){xt(B,l.split("."))||G(l,0)}),u&&U.length&&(B[m]=[]),U.forEach(function(l){B[m].push(l)}),c["camel-case-expansion"]&&c["strip-dashed"]&&Object.keys(B).filter(l=>l!=="--"&&l.includes("-")).forEach(l=>{delete B[l]}),c["strip-aliased"]&&[].concat(...Object.keys(a).map(l=>a[l])).forEach(l=>{c["camel-case-expansion"]&&l.includes("-")&&delete B[l.split(".").map(h=>Lt(h)).join(".")],delete B[l]});function gt(l){let h=P("_",l);(typeof h=="string"||typeof h=="number")&&B._.push(h)}function Jt(l,h,O,b){let f,S=F(h,d.nargs);if(S=typeof S!="number"||isNaN(S)?1:S,S===0)return wt(b)||(T=Error(_("Argument unexpected for: %s",h))),G(h,Z(h)),l;let x=wt(b)?0:1;if(c["nargs-eats-options"])O.length-(l+1)+x<S&&(T=Error(_("Not enough arguments following: %s",h))),x=S;else{for(f=l+1;f<O.length&&(!O[f].match(/^-[^0-9]/)||O[f].match(D)||J(O[f]));f++)x++;x<S&&(T=Error(_("Not enough arguments following: %s",h)))}let $=Math.min(x,S);for(!wt(b)&&$>0&&(G(h,b),$--),f=l+1;f<$+l+1;f++)G(h,O[f]);return l+$}function Ft(l,h,O,b){let f=[],S=b||O[l+1],x=F(h,d.nargs);if(F(h,d.bools)&&!/^(true|false)$/.test(S))f.push(!0);else if(wt(S)||wt(b)&&/^-/.test(S)&&!D.test(S)&&!J(S)){if(g[h]!==void 0){let $=g[h];f=Array.isArray($)?$:[$]}}else{wt(b)||f.push(C(h,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)&&!D.test(S)&&!J(S)));$++)l=$,f.push(C(h,S,r))}return typeof x=="number"&&(x&&f.length<x||isNaN(x)&&f.length===0)&&(T=Error(_("Not enough arguments following: %s",h))),G(h,f),l}function G(l,h,O=r){if(/-/.test(l)&&c["camel-case-expansion"]){let S=l.split(".").map(function(x){return Lt(x)}).join(".");I(l,S)}let b=C(l,h,O),f=l.split(".");Et(B,f,b),d.aliases[l]&&d.aliases[l].forEach(function(S){let x=S.split(".");Et(B,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("."))||Et(B,x,b)}),F(l,d.normalize)&&!F(l,d.arrays)&&[l].concat(d.aliases[l]||[]).forEach(function(x){Object.defineProperty(At,x,{enumerable:!0,get(){return h},set($){h=typeof $=="string"?jt.normalize($):$}})})}function I(l,h){d.aliases[l]&&d.aliases[l].length||(d.aliases[l]=[h],y[h]=!0),d.aliases[h]&&d.aliases[h].length||I(h,l)}function C(l,h,O){O&&(h=zi(h)),(F(l,d.bools)||F(l,d.counts))&&typeof h=="string"&&(h=h==="true");let b=Array.isArray(h)?h.map(function(f){return P(l,f)}):P(l,h);return F(l,d.counts)&&(wt(b)||typeof b=="boolean")&&(b=De()),F(l,d.normalize)&&F(l,d.arrays)&&(Array.isArray(h)?b=h.map(f=>jt.normalize(f)):b=jt.normalize(h)),b}function P(l,h){return!c["parse-positional-numbers"]&&l==="_"||!F(l,d.strings)&&!F(l,d.bools)&&!Array.isArray(h)&&(ge(h)&&c["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${h}`)))||!wt(h)&&F(l,d.numbers))&&(h=Number(h)),h}function L(l){let h=Object.create(null);Q(h,d.aliases,g),Object.keys(d.configs).forEach(function(O){let b=l[O]||h[O];if(b)try{let f=null,S=jt.resolve(jt.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=jt.require(S);Y(f)}catch(f){f.name==="PermissionDenied"?T=f:l[O]&&(T=Error(_("Invalid JSON config file: %s",b)))}})}function Y(l,h){Object.keys(l).forEach(function(O){let b=l[O],f=h?h+"."+O:O;typeof b=="object"&&b!==null&&!Array.isArray(b)&&c["dot-notation"]?Y(b,f):(!xt(B,f.split("."))||F(f,d.arrays)&&c["combine-arrays"])&&G(f,b)})}function et(){typeof w<"u"&&w.forEach(function(l){Y(l)})}function H(l,h){if(typeof p>"u")return;let O=typeof p=="string"?p:"",b=jt.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)});(h&&d.configs[S.join(".")]||!h)&&!xt(l,S)&&G(S.join("."),b[f])}})}function nt(l){let h,O=new Set;Object.keys(l).forEach(function(b){if(!O.has(b)&&(h=F(b,d.coercions),typeof h=="function"))try{let f=P(b,h(l[b]));[].concat(d.aliases[b]||[],b).forEach(S=>{O.add(S),l[S]=f})}catch(f){T=f}})}function Nt(l){return d.keys.forEach(h=>{~h.indexOf(".")||typeof l[h]>"u"&&(l[h]=void 0)}),l}function Q(l,h,O,b=!1){Object.keys(O).forEach(function(f){xt(l,f.split("."))||(Et(l,f.split("."),O[f]),b&&(E[f]=!0),(h[f]||[]).forEach(function(S){xt(l,S.split("."))||Et(l,S.split("."),O[f])}))})}function xt(l,h){let O=l;c["dot-notation"]||(h=[h.join(".")]),h.slice(0,-1).forEach(function(f){O=O[f]||{}});let b=h[h.length-1];return typeof O!="object"?!1:b in O}function Et(l,h,O){let b=l;c["dot-notation"]||(h=[h.join(".")]),h.slice(0,-1).forEach(function(it){it=xn(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=xn(h[h.length-1]),S=F(h.join("."),d.arrays),x=Array.isArray(O),$=c["duplicate-arguments-array"];!$&&F(f,d.nargs)&&($=!0,(!wt(b[f])&&d.nargs[f]===1||Array.isArray(b[f])&&b[f].length===d.nargs[f])&&(b[f]=void 0)),O===De()?b[f]=De(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||F(f,d.counts)||F(f,d.bools))?b[f]=[b[f],O]:b[f]=O}function Dt(...l){l.forEach(function(h){Object.keys(h||{}).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 F(l,h){let O=[].concat(d.aliases[l]||[],l),b=Object.keys(h),f=O.find(S=>b.includes(S));return f?h[f]:!1}function Me(l){let h=Object.keys(d);return[].concat(h.map(b=>d[b])).some(function(b){return Array.isArray(b)?b.includes(l):b[l]})}function v(l,...h){return[].concat(...h).some(function(b){let f=l.match(b);return f&&Me(f[1])})}function K(l){if(l.match(D)||!l.match(/^-[^-]+/))return!1;let h=!0,O,b=l.slice(1).split("");for(let f=0;f<b.length;f++){if(O=l.slice(f+2),!Me(b[f])){h=!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 h}function J(l){return c["unknown-options-as-args"]&&R(l)}function R(l){return l=l.replace(/^-{3,}/,"--"),l.match(D)||K(l)?!1:!v(l,/^-+([^=]+?)=[\s\S]*$/,z,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Z(l){return!F(l,d.bools)&&!F(l,d.counts)&&`${l}`in g?g[l]:k(bt(l))}function k(l){return{[ht.BOOLEAN]:!0,[ht.STRING]:"",[ht.NUMBER]:void 0,[ht.ARRAY]:[]}[l]}function bt(l){let h=ht.BOOLEAN;return F(l,d.strings)?h=ht.STRING:F(l,d.numbers)?h=ht.NUMBER:F(l,d.bools)?h=ht.BOOLEAN:F(l,d.arrays)&&(h=ht.ARRAY),h}function wt(l){return l===void 0}function fe(){Object.keys(d.counts).find(l=>F(l,d.arrays)?(T=Error(_("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0):F(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,B),configuration:c,defaulted:Object.assign({},E),error:T,newAliases:Object.assign({},y)}}};function Li(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 De(s){return s!==void 0?s+1:1}function xn(s){return s==="__proto__"?"___proto___":s}function zi(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 Hi}from"fs";var We,Le,ze,En=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,jn=(Le=(We=process==null?void 0:process.versions)===null||We===void 0?void 0:We.node)!==null&&Le!==void 0?Le:(ze=process==null?void 0:process.version)===null||ze===void 0?void 0:ze.slice(1);if(jn&&Number(jn.match(/^([^.]+)/)[1])<En)throw Error(`yargs parser supports a minimum Node.js version of ${En}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var Yi=process?process.env:{},An=new be({cwd:process.cwd,env:()=>Yi,format:Ri,normalize:Ui,resolve:Ti,require:s=>{if(typeof Ot<"u")return Ot(s);if(s.match(/\.json$/))return JSON.parse(Hi(s,"utf8"));throw Error("only .json config files are supported in ESM")}}),se=function(t,e){return An.parse(t.slice(),e).argv};se.detailed=function(s,t){return An.parse(s.slice(),t)};se.camelCase=Lt;se.decamelize=me;se.looksLikeNumber=ge;var Re=se;import{basename as is,dirname as ss,extname as rs,relative as os,resolve as vn}from"path";function Pn(){return Bi()?0:1}function Bi(){return Gi()&&!process.defaultApp}function Gi(){return!!process.versions.electron}function Ue(s){return s.slice(Pn()+1)}function Sn(){return process.argv[Pn()]}var V=class s extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,s)}};import{readFileSync as Vi,statSync as qi,writeFile as Ki}from"fs";import{format as Qi}from"util";import{resolve as Ji}from"path";var In={fs:{readFileSync:Vi,writeFile:Ki},format:Qi,resolve:Ji,exists:s=>{try{return qi(s).isFile()}catch{return!1}}};var yt,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(),yt.format.apply(yt.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),yt.format.apply(yt.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);yt.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{yt.fs.readFileSync&&(t=JSON.parse(yt.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=yt.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){let i=yt.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(i)&&(n=i)}return n}_fileExistsSync(t){return yt.exists(t)}};function Mn(s,t){yt=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 Zi=s=>Mn(s,In),$n=Zi;var as="require is not supported by ESM",Fn="loading a directory of commands is not supported yet for ESM",re;try{re=ns(import.meta.url)}catch{re=process.cwd()}var ls=re.substring(0,re.lastIndexOf("node_modules")),He={assert:{notStrictEqual:Xi,strictEqual:ki},cliui:Ne,findUp:_n,getEnv:s=>process.env[s],inspect:ts,getCallerFile:()=>{throw new V(Fn)},getProcessArgvBin:Sn,mainFilename:ls||process.cwd(),Parser:Re,path:{basename:is,dirname:ss,extname:rs,relative:os,resolve:vn},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:es,require:()=>{throw new V(as)},requireDirectory:()=>{throw new V(Fn)},stringWidth:s=>[...s].length,y18n:$n({directory:vn(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 cs=["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(u=>{let m=g.shift(),y=Nn(m);u.cmd.filter(_=>_===y||_==="*").length===0&&Dn(y,u.cmd,i),i+=1}),r.optional.forEach(u=>{if(g.length===0)return;let m=g.shift(),y=Nn(m);u.cmd.filter(_=>_===y||_==="*").length===0&&Dn(y,u.cmd,i),i+=1})}catch(i){console.warn(i.stack)}}function Nn(s){return Array.isArray(s)?"array":s===null?"null":typeof s}function Dn(s,t,e){throw new V(`Invalid ${cs[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 Wn(s){return s?s.map(t=>(t.applyBeforeValidation=!1,t)):[]}function zt(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 Rt(s,t,e=n=>{throw n}){try{let n=fs(s)?s():s;return q(n)?n.then(i=>t(i)):t(n)}catch(n){return e(n)}}function fs(s){return typeof s=="function"}function Be(s){if(typeof Ot>"u")return null;for(let t=0,e=Object.keys(Ot.cache),n;t<e.length;t++)if(n=Ot.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=Wn(r);if(i=i||(()=>{}),Array.isArray(t))if(hs(t))[t,...c]=t;else for(let w of t)this.addHandler(w);else if(ds(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(Ln(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,u=[w.cmd].concat(c).filter(m=>kt.test(m)?(p=!0,!1):!0);u.length===0&&p&&u.push("$0"),p&&(w.cmd=u[0],c=u.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 u=this.applyBuilderUpdateUsageAndParse(p,c,e,n.aliases,w,i,r,a);return q(u)?u.then(m=>this.applyMiddlewareAndGetResult(p,c,m.innerArgv,g,r,m.aliases,e)):this.applyMiddlewareAndGetResult(p,c,u.innerArgv,g,r,u.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 u=w(n.getInternalMethods().reset(i),g);if(q(u))return u.then(m=>(p=Rn(m)?m:n,this.parseAndUpdateUsage(t,e,p,r,a,c)))}else us(w)&&(n.getInternalMethods().getUsageInstance().freeze(),p=n.getInternalMethods().reset(i),Object.keys(e.builder).forEach(u=>{p.option(u,w[u])}));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=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=zt(n,a,c,!1),n=Rt(n,p=>{let u=e.handler(p);return q(u)?u.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=zt(n,c,w,!0);return q(p)?p.then(u=>this.handleValidationAndGetResult(t,e,u,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);Ln(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 Ln(s){return typeof s=="object"&&!!s.builder&&typeof s.handler=="function"}function hs(s){return s.every(t=>typeof t=="string")}function ye(s){return typeof s=="function"}function us(s){return typeof s=="object"}function ds(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 It(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 ps(s){return typeof s=="boolean"}function Tn(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[L,Y]=typeof C=="string"?[!0,C]:[C,P];return s.getInternalMethods().isGlobalContext()&&(a=Y),r=Y,c=L,n};let g=!1;n.fail=function(C,P){let L=s.getInternalMethods().getLoggerInstance();if(i.length)for(let Y=i.length-1;Y>=0;--Y){let et=i[Y];if(ps(et)){if(P)throw P;if(C)throw Error(C)}else et(C,P,n)}else{if(s.getExitProcess()&&It(!0),!g){g=!0,c&&(s.showHelp("error"),L.error()),(C||P)&&L.error(C||P);let Y=r||a;Y&&((C||P)&&L.error(""),L.error(Y))}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=(I,C)=>I===null?(p=!0,w=[],n):(p=!1,w.push([I,C||""]),n),n.getUsage=()=>w,n.getUsageDisabled=()=>p,n.getPositionalGroupName=()=>e("Positionals:");let u=[];n.example=(I,C)=>{u.push([I,C||""])};let m=[];n.command=function(C,P,L,Y,et=!1){L&&(m=m.map(H=>(H[2]=!1,H))),m.push([C,P||"",L,Y,et])},n.getCommands=()=>m;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=I=>{E.push(I)};let _=!1,d;n.wrap=I=>{_=!0,d=I},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(_||(d=Jt(),_=!0),d);let D="__yargsString__:";n.deferY18nLookup=I=>D+I,n.help=function(){if(U)return U;T();let C=s.customScriptName?s.$0:t.path.basename(s.$0),P=s.getDemandedOptions(),L=s.getDemandedCommands(),Y=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(At),nt=Object.keys(nt.reduce((v,K)=>(K!=="_"&&(v[K]=!0),v),{}));let Nt=n.getWrap(),Q=t.cliui({width:Nt,wrap:!!Nt});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;L._?v=`${C} <${e("command")}>
6
+ `),r.border&&(i.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(r)+2)+"'")),r.padding&&(i.unshift(...new Array(r.padding[Fi]||0).fill("")),i.push(...new Array(r.padding[Ni]||0).fill(""))),i.forEach((c,m)=>{e[m]||e.push([]);let w=e[m];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[me]||0)+(t.padding[pe]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map(a=>a.width||at.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,Di(t[c])):a)}};function bn(s,t,e){return s.border?/[.']-+[.']/.test(t)?"":t.trim().length!==0?e:" ":""}function Di(s){let t=s.padding||[],e=1+(t[me]||0)+(t[pe]||0);return s.border?e+4:e}function Wi(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Li(s,t){s=s.trim();let e=at.stringWidth(s);return e<t?" ".repeat(t-e)+s:s}function zi(s,t){s=s.trim();let e=at.stringWidth(s);return e>=t?s:" ".repeat(t-e>>1)+s}var at;function wn(s,t){return at=t,new Ne({width:s?.width||Wi(),wrap:s?.wrap})}var yn=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(yn,"")}function On(s,t){let[e,n]=s.match(yn)||["",""];s=De(s);let i="";for(let r=0;r<s.length;r++)r!==0&&r%t===0&&(i+=`
7
+ `),i+=s.charAt(r);return e&&n&&(i=`${e}${i}${n}`),i}function We(s){return wn(s,{stringWidth:t=>[...t].length,stripAnsi:De,wrap:On})}import{dirname as _n,resolve as Cn}from"path";import{readdirSync as Ri,statSync as Ti}from"fs";function xn(s,t){let e=Cn(".",s),n;for(Ti(e).isDirectory()||(e=_n(e));;){if(n=t(e,Ri(e)),n)return Cn(e,n);if(e=_n(n=e),n===e)break}}import{inspect as ss}from"util";import{readFileSync as rs}from"fs";import{fileURLToPath as os}from"url";import{format as Yi}from"util";import{normalize as Bi,resolve as Gi}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 ge(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 be(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 En(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,we=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=En(t),r=typeof t=="string",a=Ui(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),m=Object.assign(Object.create(null),n.default),w=n.configObjects||[],p=n.envPrefix,u=c["populate--"],g=u?"--":"_",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]+)$/,z=new RegExp("^--"+c["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(l){let h=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][h]=!0),d.arrays[h]=!0,d.keys.push(h)}),[].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,h])=>{typeof h=="number"&&(d.nargs[l]=h,d.keys.push(l))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([l,h])=>{typeof h=="function"&&(d.coercions[l]=h,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,h])=>{(typeof h=="boolean"||typeof h=="function")&&(d.configs[l]=h)})),Wt(n.key,a,n.default,d.arrays),Object.keys(m).forEach(function(l){(d.aliases[l]||[]).forEach(function(h){m[h]=m[l]})});let Y=null;he();let T=[],B=Object.assign(Object.create(null),{_:[]}),Pt={};for(let l=0;l<i.length;l++){let h=i[l],O=h.replace(/^-{3,}/,"---"),b,f,S,x,$,it;if(h!=="--"&&/^-/.test(h)&&J(h))gt(h);else if(O.match(/^---+(=|$)/)){gt(h);continue}else if(h.match(/^--.+=/)||!c["short-option-groups"]&&h.match(/^-.+=/))x=h.match(/^--?([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&(F(x[1],d.arrays)?l=Nt(l,x[1],i,x[2]):F(x[1],d.nargs)!==!1?l=Jt(l,x[1],i,x[2]):G(x[1],x[2],!0));else if(h.match(z)&&c["boolean-negation"])x=h.match(z),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],G(f,F(f,d.arrays)?[!1]:!1));else if(h.match(/^--.+/)||!c["short-option-groups"]&&h.match(/^-[^-]+/))x=h.match(/^--?(.+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],F(f,d.arrays)?l=Nt(l,f,i):F(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!$.match(/^-/)||$.match(W))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))));else if(h.match(/^-.\..+=/))x=h.match(/^-([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&G(x[1],x[2]);else if(h.match(/^-.\..+/)&&!h.match(W))$=i[l+1],x=h.match(/^-(.\..+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],$!==void 0&&!$.match(/^-/)&&!F(f,d.bools)&&!F(f,d.counts)?(G(f,$),l++):G(f,Z(f)));else if(h.match(/^-[^-]+/)&&!h.match(W)){S=h.slice(1,-1).split(""),b=!1;for(let rt=0;rt<S.length;rt++){if($=h.slice(rt+2),S[rt+1]&&S[rt+1]==="="){it=h.slice(rt+3),f=S[rt],F(f,d.arrays)?l=Nt(l,f,i,it):F(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($)&&F($,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=h.slice(-1)[0],!b&&f!=="-"&&(F(f,d.arrays)?l=Nt(l,f,i):F(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(W))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))))}else if(h.match(/^-[0-9]$/)&&h.match(W)&&F(h.slice(1),d.bools))f=h.slice(1),G(f,Z(f));else if(h==="--"){T=i.slice(l+1);break}else if(c["halt-at-non-option"]){T=i.slice(l);break}else gt(h)}U(B,!0),U(B,!1),L(B),et(),Q(B,d.aliases,m,!0),nt(B),c["set-placeholder-key"]&&Dt(B),Object.keys(d.counts).forEach(function(l){xt(B,l.split("."))||G(l,0)}),u&&T.length&&(B[g]=[]),T.forEach(function(l){B[g].push(l)}),c["camel-case-expansion"]&&c["strip-dashed"]&&Object.keys(B).filter(l=>l!=="--"&&l.includes("-")).forEach(l=>{delete B[l]}),c["strip-aliased"]&&[].concat(...Object.keys(a).map(l=>a[l])).forEach(l=>{c["camel-case-expansion"]&&l.includes("-")&&delete B[l.split(".").map(h=>Lt(h)).join(".")],delete B[l]});function gt(l){let h=P("_",l);(typeof h=="string"||typeof h=="number")&&B._.push(h)}function Jt(l,h,O,b){let f,S=F(h,d.nargs);if(S=typeof S!="number"||isNaN(S)?1:S,S===0)return wt(b)||(Y=Error(_("Argument unexpected for: %s",h))),G(h,Z(h)),l;let x=wt(b)?0:1;if(c["nargs-eats-options"])O.length-(l+1)+x<S&&(Y=Error(_("Not enough arguments following: %s",h))),x=S;else{for(f=l+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",h)))}let $=Math.min(x,S);for(!wt(b)&&$>0&&(G(h,b),$--),f=l+1;f<$+l+1;f++)G(h,O[f]);return l+$}function Nt(l,h,O,b){let f=[],S=b||O[l+1],x=F(h,d.nargs);if(F(h,d.bools)&&!/^(true|false)$/.test(S))f.push(!0);else if(wt(S)||wt(b)&&/^-/.test(S)&&!W.test(S)&&!J(S)){if(m[h]!==void 0){let $=m[h];f=Array.isArray($)?$:[$]}}else{wt(b)||f.push(C(h,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)&&!W.test(S)&&!J(S)));$++)l=$,f.push(C(h,S,r))}return typeof x=="number"&&(x&&f.length<x||isNaN(x)&&f.length===0)&&(Y=Error(_("Not enough arguments following: %s",h))),G(h,f),l}function G(l,h,O=r){if(/-/.test(l)&&c["camel-case-expansion"]){let S=l.split(".").map(function(x){return Lt(x)}).join(".");I(l,S)}let b=C(l,h,O),f=l.split(".");Et(B,f,b),d.aliases[l]&&d.aliases[l].forEach(function(S){let x=S.split(".");Et(B,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("."))||Et(B,x,b)}),F(l,d.normalize)&&!F(l,d.arrays)&&[l].concat(d.aliases[l]||[]).forEach(function(x){Object.defineProperty(Pt,x,{enumerable:!0,get(){return h},set($){h=typeof $=="string"?At.normalize($):$}})})}function I(l,h){d.aliases[l]&&d.aliases[l].length||(d.aliases[l]=[h],y[h]=!0),d.aliases[h]&&d.aliases[h].length||I(h,l)}function C(l,h,O){O&&(h=Hi(h)),(F(l,d.bools)||F(l,d.counts))&&typeof h=="string"&&(h=h==="true");let b=Array.isArray(h)?h.map(function(f){return P(l,f)}):P(l,h);return F(l,d.counts)&&(wt(b)||typeof b=="boolean")&&(b=Le()),F(l,d.normalize)&&F(l,d.arrays)&&(Array.isArray(h)?b=h.map(f=>At.normalize(f)):b=At.normalize(h)),b}function P(l,h){return!c["parse-positional-numbers"]&&l==="_"||!F(l,d.strings)&&!F(l,d.bools)&&!Array.isArray(h)&&(be(h)&&c["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${h}`)))||!wt(h)&&F(l,d.numbers))&&(h=Number(h)),h}function L(l){let h=Object.create(null);Q(h,d.aliases,m),Object.keys(d.configs).forEach(function(O){let b=l[O]||h[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);H(f)}catch(f){f.name==="PermissionDenied"?Y=f:l[O]&&(Y=Error(_("Invalid JSON config file: %s",b)))}})}function H(l,h){Object.keys(l).forEach(function(O){let b=l[O],f=h?h+"."+O:O;typeof b=="object"&&b!==null&&!Array.isArray(b)&&c["dot-notation"]?H(b,f):(!xt(B,f.split("."))||F(f,d.arrays)&&c["combine-arrays"])&&G(f,b)})}function et(){typeof w<"u"&&w.forEach(function(l){H(l)})}function U(l,h){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)});(h&&d.configs[S.join(".")]||!h)&&!xt(l,S)&&G(S.join("."),b[f])}})}function nt(l){let h,O=new Set;Object.keys(l).forEach(function(b){if(!O.has(b)&&(h=F(b,d.coercions),typeof h=="function"))try{let f=P(b,h(l[b]));[].concat(d.aliases[b]||[],b).forEach(S=>{O.add(S),l[S]=f})}catch(f){Y=f}})}function Dt(l){return d.keys.forEach(h=>{~h.indexOf(".")||typeof l[h]>"u"&&(l[h]=void 0)}),l}function Q(l,h,O,b=!1){Object.keys(O).forEach(function(f){xt(l,f.split("."))||(Et(l,f.split("."),O[f]),b&&(E[f]=!0),(h[f]||[]).forEach(function(S){xt(l,S.split("."))||Et(l,S.split("."),O[f])}))})}function xt(l,h){let O=l;c["dot-notation"]||(h=[h.join(".")]),h.slice(0,-1).forEach(function(f){O=O[f]||{}});let b=h[h.length-1];return typeof O!="object"?!1:b in O}function Et(l,h,O){let b=l;c["dot-notation"]||(h=[h.join(".")]),h.slice(0,-1).forEach(function(it){it=jn(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=jn(h[h.length-1]),S=F(h.join("."),d.arrays),x=Array.isArray(O),$=c["duplicate-arguments-array"];!$&&F(f,d.nargs)&&($=!0,(!wt(b[f])&&d.nargs[f]===1||Array.isArray(b[f])&&b[f].length===d.nargs[f])&&(b[f]=void 0)),O===Le()?b[f]=Le(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||F(f,d.counts)||F(f,d.bools))?b[f]=[b[f],O]:b[f]=O}function Wt(...l){l.forEach(function(h){Object.keys(h||{}).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=ge(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(l,h){let O=[].concat(d.aliases[l]||[],l),b=Object.keys(h),f=O.find(S=>b.includes(S));return f?h[f]:!1}function $e(l){let h=Object.keys(d);return[].concat(h.map(b=>d[b])).some(function(b){return Array.isArray(b)?b.includes(l):b[l]})}function v(l,...h){return[].concat(...h).some(function(b){let f=l.match(b);return f&&$e(f[1])})}function K(l){if(l.match(W)||!l.match(/^-[^-]+/))return!1;let h=!0,O,b=l.slice(1).split("");for(let f=0;f<b.length;f++){if(O=l.slice(f+2),!$e(b[f])){h=!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 h}function J(l){return c["unknown-options-as-args"]&&R(l)}function R(l){return l=l.replace(/^-{3,}/,"--"),l.match(W)||K(l)?!1:!v(l,/^-+([^=]+?)=[\s\S]*$/,z,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Z(l){return!F(l,d.bools)&&!F(l,d.counts)&&`${l}`in m?m[l]:k(bt(l))}function k(l){return{[ht.BOOLEAN]:!0,[ht.STRING]:"",[ht.NUMBER]:void 0,[ht.ARRAY]:[]}[l]}function bt(l){let h=ht.BOOLEAN;return F(l,d.strings)?h=ht.STRING:F(l,d.numbers)?h=ht.NUMBER:F(l,d.bools)?h=ht.BOOLEAN:F(l,d.arrays)&&(h=ht.ARRAY),h}function wt(l){return l===void 0}function he(){Object.keys(d.counts).find(l=>F(l,d.arrays)?(Y=Error(_("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0):F(l,d.nargs)?(Y=Error(_("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0):!1)}return{aliases:Object.assign({},d.aliases),argv:Object.assign(Pt,B),configuration:c,defaulted:Object.assign({},E),error:Y,newAliases:Object.assign({},y)}}};function Ui(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,m){return m.indexOf(a)===c});let r=i.pop();r!==void 0&&typeof r=="string"&&(e[r]=i)}),e}function Le(s){return s!==void 0?s+1:1}function jn(s){return s==="__proto__"?"___proto___":s}function Hi(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 Vi}from"fs";var ze,Re,Te,An=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,Pn=(Re=(ze=process==null?void 0:process.versions)===null||ze===void 0?void 0:ze.node)!==null&&Re!==void 0?Re:(Te=process==null?void 0:process.version)===null||Te===void 0?void 0:Te.slice(1);if(Pn&&Number(Pn.match(/^([^.]+)/)[1])<An)throw Error(`yargs parser supports a minimum Node.js version of ${An}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var qi=process?process.env:{},Sn=new we({cwd:process.cwd,env:()=>qi,format:Yi,normalize:Bi,resolve:Gi,require:s=>{if(typeof Ot<"u")return Ot(s);if(s.match(/\.json$/))return JSON.parse(Vi(s,"utf8"));throw Error("only .json config files are supported in ESM")}}),re=function(t,e){return Sn.parse(t.slice(),e).argv};re.detailed=function(s,t){return Sn.parse(s.slice(),t)};re.camelCase=Lt;re.decamelize=ge;re.looksLikeNumber=be;var Ue=re;import{basename as as,dirname as ls,extname as cs,relative as fs,resolve as Nn}from"path";function In(){return Ki()?0:1}function Ki(){return Qi()&&!process.defaultApp}function Qi(){return!!process.versions.electron}function He(s){return s.slice(In()+1)}function Mn(){return process.argv[In()]}var V=class s extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,s)}};import{readFileSync as Ji,statSync as Zi,writeFile as Xi}from"fs";import{format as ki}from"util";import{resolve as ts}from"path";var $n={fs:{readFileSync:Ji,writeFile:Xi},format:ki,resolve:ts,exists:s=>{try{return Zi(s).isFile()}catch{return!1}}};var yt,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(),yt.format.apply(yt.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),yt.format.apply(yt.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);yt.fs.writeFile(a,c,"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{yt.fs.readFileSync&&(t=JSON.parse(yt.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=yt.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){let i=yt.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(i)&&(n=i)}return n}_fileExistsSync(t){return yt.exists(t)}};function vn(s,t){yt=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 es=s=>vn(s,$n),Fn=es;var hs="require is not supported by ESM",Dn="loading a directory of commands is not supported yet for ESM",oe;try{oe=os(import.meta.url)}catch{oe=process.cwd()}var us=oe.substring(0,oe.lastIndexOf("node_modules")),Be={assert:{notStrictEqual:ns,strictEqual:is},cliui:We,findUp:xn,getEnv:s=>process.env[s],inspect:ss,getCallerFile:()=>{throw new V(Dn)},getProcessArgvBin:Mn,mainFilename:us||process.cwd(),Parser:Ue,path:{basename:as,dirname:ls,extname:cs,relative:fs,resolve:Nn},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:rs,require:()=>{throw new V(hs)},requireDirectory:()=>{throw new V(Dn)},stringWidth:s=>[...s].length,y18n:Fn({directory:Nn(oe,"../../../locales"),updateFiles:!1})};function ot(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 q(s){return!!s&&!!s.then&&typeof s.then=="function"}function St(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 m=!1;a=a.replace(/\s/g,""),/\.+[\]>]/.test(a)&&c===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 ds=["first","second","third","fourth","fifth","sixth"];function j(s,t,e){function n(){return typeof s=="object"?[{demanded:[],optional:[]},s,t]:[St(`cmd ${s}`),t,e]}try{let i=0,[r,a,c]=n(),m=[].slice.call(a);for(;m.length&&m[m.length-1]===void 0;)m.pop();let w=c||m.length;if(w<r.demanded.length)throw new V(`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 V(`Too many arguments provided. Expected max ${p} but received ${w}.`);r.demanded.forEach(u=>{let g=m.shift(),y=Wn(g);u.cmd.filter(_=>_===y||_==="*").length===0&&Ln(y,u.cmd,i),i+=1}),r.optional.forEach(u=>{if(m.length===0)return;let g=m.shift(),y=Wn(g);u.cmd.filter(_=>_===y||_==="*").length===0&&Ln(y,u.cmd,i),i+=1})}catch(i){console.warn(i.stack)}}function Wn(s){return Array.isArray(s)?"array":s===null?"null":typeof s}function Ln(s,t,e){throw new V(`Invalid ${ds[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${s}.`)}var ye=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 zn(s){return s?s.map(t=>(t.applyBeforeValidation=!1,t)):[]}function zt(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 Rt(s,t,e=n=>{throw n}){try{let n=ps(s)?s():s;return q(n)?n.then(i=>t(i)):t(n)}catch(n){return e(n)}}function ps(s){return typeof s=="function"}function Ve(s){if(typeof Ot>"u")return null;for(let t=0,e=Object.keys(Ot.cache),n;t<e.length;t++)if(n=Ot.cache[e[t]],n.exports===s)return n;return null}var kt=/(^\*)|(^\$0)/,qe=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,m)=>{let w=r(a,c,m);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=[],m=zn(r);if(i=i||(()=>{}),Array.isArray(t))if(ms(t))[t,...c]=t;else for(let w of t)this.addHandler(w);else if(bs(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=St(t);c=c.map(g=>St(g).cmd);let p=!1,u=[w.cmd].concat(c).filter(g=>kt.test(g)?(p=!0,!1):!0);u.length===0&&p&&u.push("$0"),p&&(w.cmd=u[0],c=u.slice(1),t=t.replace(kt,w.cmd)),c.forEach(g=>{this.aliasMap[g]=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: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 c=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(c.original));let u=this.applyBuilderUpdateUsageAndParse(p,c,e,n.aliases,w,i,r,a);return q(u)?u.then(g=>this.applyMiddlewareAndGetResult(p,c,g.innerArgv,m,r,g.aliases,e)):this.applyMiddlewareAndGetResult(p,c,u.innerArgv,m,r,u.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,i,r,a,c,m){let w=e.builder,p=n;if(Oe(w)){n.getInternalMethods().getUsageInstance().freeze();let u=w(n.getInternalMethods().reset(i),m);if(q(u))return u.then(g=>(p=Un(g)?g:n,this.parseAndUpdateUsage(t,e,p,r,a,c)))}else gs(w)&&(n.getInternalMethods().getUsageInstance().freeze(),p=n.getInternalMethods().reset(i),Object.keys(e.builder).forEach(u=>{p.option(u,w[u])}));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(m=>({aliases:n.parsed.aliases,innerArgv:m})):{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,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=zt(n,a,c,!1),n=Rt(n,p=>{let u=e.handler(p);return q(u)?u.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 m={};if(r)return n;c.getInternalMethods().getHasOutput()||(m=this.populatePositionals(e,n,i,c));let w=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),p=zt(n,c,w,!0);return q(p)?p.then(u=>this.handleValidationAndGetResult(t,e,u,i,a,c,w,m)):this.handleValidationAndGetResult(t,e,p,i,a,c,w,m)}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 m=r.shift();this.populatePositional(m,e,c)}for(;a.length;){let m=a.shift();this.populatePositional(m,e,c)}return e._=n.commands.concat(e._.map(m=>""+m)),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=St(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}),m=this.shim.Parser.detailed(a,Object.assign({},r,{configuration:c}));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(Oe(e))return e(t,!0);Rn(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;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 Tn(s,t,e,n){return new qe(s,t,e,n)}function Rn(s){return typeof s=="object"&&!!s.builder&&typeof s.handler=="function"}function ms(s){return s.every(t=>typeof t=="string")}function Oe(s){return typeof s=="function"}function gs(s){return typeof s=="object"}function bs(s){return typeof s=="object"&&!Array.isArray(s)}function It(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 ws(s){return typeof s=="boolean"}function Yn(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[L,H]=typeof C=="string"?[!0,C]:[C,P];return s.getInternalMethods().isGlobalContext()&&(a=H),r=H,c=L,n};let m=!1;n.fail=function(C,P){let L=s.getInternalMethods().getLoggerInstance();if(i.length)for(let H=i.length-1;H>=0;--H){let et=i[H];if(ws(et)){if(P)throw P;if(C)throw Error(C)}else et(C,P,n)}else{if(s.getExitProcess()&&Mt(!0),!m){m=!0,c&&(s.showHelp("error"),L.error()),(C||P)&&L.error(C||P);let H=r||a;H&&((C||P)&&L.error(""),L.error(H))}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=(I,C)=>I===null?(p=!0,w=[],n):(p=!1,w.push([I,C||""]),n),n.getUsage=()=>w,n.getUsageDisabled=()=>p,n.getPositionalGroupName=()=>e("Positionals:");let u=[];n.example=(I,C)=>{u.push([I,C||""])};let g=[];n.command=function(C,P,L,H,et=!1){L&&(g=g.map(U=>(U[2]=!1,U))),g.push([C,P||"",L,H,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=I=>{E.push(I)};let _=!1,d;n.wrap=I=>{_=!0,d=I},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(_||(d=Jt(),_=!0),d);let W="__yargsString__:";n.deferY18nLookup=I=>W+I,n.help=function(){if(T)return T;Y();let C=s.customScriptName?s.$0:t.path.basename(s.$0),P=s.getDemandedOptions(),L=s.getDemandedCommands(),H=s.getDeprecatedOptions(),et=s.getGroups(),U=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(U.default)),nt=nt.filter(Pt),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")}>
8
8
  `:v=`${C} [${e("command")}]
9
- `,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((R,Z)=>R[0].localeCompare(Z[0])));let J=C?`${C} `:"";m.forEach(R=>{let Z=`${J}${K}${R[0].replace(/^\$0 ?/,"")}`;Q.span({text:Z,padding:[0,2,0,2],width:z(m,Nt,`${C}${K}`)+4},{text:R[1]});let k=[];R[2]&&k.push(`[${e("default")}]`),R[3]&&R[3].length&&k.push(`[${e("aliases:")} ${R[3].join(", ")}]`),R[4]&&(typeof R[4]=="string"?k.push(`[${e("deprecated: %s",R[4])}]`):k.push(`[${e("deprecated")}]`)),k.length?Q.div({text:k.join(" "),padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}let xt=(Object.keys(H.alias)||[]).concat(Object.keys(s.parsed.newAliases)||[]);nt=nt.filter(v=>!s.parsed.newAliases[v]&&xt.every(K=>(H.alias[K]||[]).indexOf(v)===-1));let Et=e("Options:");et[Et]||(et[Et]=[]),B(nt,H.alias,et,Et);let Dt=v=>/^--/.test(Oe(v)),F=Object.keys(et).filter(v=>et[v].length>0).map(v=>{let K=et[v].filter(At).map(J=>{if(xt.includes(J))return J;for(let R=0,Z;(Z=xt[R])!==void 0;R++)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((R,Z)=>(R[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,bt)=>Dt(k)===Dt(bt)?0:Dt(k)?1:-1).join(", "),R),{});return{groupName:v,normalizedKeys:K,switches:J}});if(F.filter(({groupName:v})=>v!==n.getPositionalGroupName()).some(({normalizedKeys:v,switches:K})=>!v.every(J=>Dt(K[J])))&&F.filter(({groupName:v})=>v!==n.getPositionalGroupName()).forEach(({normalizedKeys:v,switches:K})=>{v.forEach(J=>{Dt(K[J])&&(K[J]=ms(K[J],4))})}),F.forEach(({groupName:v,normalizedKeys:K,switches:J})=>{Q.div(v),K.forEach(R=>{let Z=J[R],k=y[R]||"",bt=null;k.includes(D)&&(k=e(k.substring(D.length))),H.boolean.includes(R)&&(bt=`[${e("boolean")}]`),H.count.includes(R)&&(bt=`[${e("count")}]`),H.string.includes(R)&&(bt=`[${e("string")}]`),H.normalize.includes(R)&&(bt=`[${e("string")}]`),H.array.includes(R)&&(bt=`[${e("array")}]`),H.number.includes(R)&&(bt=`[${e("number")}]`);let wt=h=>typeof h=="string"?`[${e("deprecated: %s",h)}]`:`[${e("deprecated")}]`,fe=[R in Y?wt(Y[R]):null,bt,R in P?`[${e("required")}]`:null,H.choices&&H.choices[R]?`[${e("choices:")} ${n.stringifiedValues(H.choices[R])}]`:null,gt(H.default[R],H.defaultDescription[R])].filter(Boolean).join(" ");Q.span({text:Oe(Z),padding:[0,2,0,2+Un(Z)],width:z(J,Nt)+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()}),u.length&&(Q.div(e("Examples:")),u.forEach(v=>{v[0]=v[0].replace(/\$0/g,C)}),u.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(u,Nt)+4},{text:v[1]})}),Q.div()),E.length>0){let v=E.map(K=>K.replace(/\$0/g,C)).join(`
9
+ `,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((R,Z)=>R[0].localeCompare(Z[0])));let J=C?`${C} `:"";g.forEach(R=>{let Z=`${J}${K}${R[0].replace(/^\$0 ?/,"")}`;Q.span({text:Z,padding:[0,2,0,2],width:z(g,Dt,`${C}${K}`)+4},{text:R[1]});let k=[];R[2]&&k.push(`[${e("default")}]`),R[3]&&R[3].length&&k.push(`[${e("aliases:")} ${R[3].join(", ")}]`),R[4]&&(typeof R[4]=="string"?k.push(`[${e("deprecated: %s",R[4])}]`):k.push(`[${e("deprecated")}]`)),k.length?Q.div({text:k.join(" "),padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}let xt=(Object.keys(U.alias)||[]).concat(Object.keys(s.parsed.newAliases)||[]);nt=nt.filter(v=>!s.parsed.newAliases[v]&&xt.every(K=>(U.alias[K]||[]).indexOf(v)===-1));let Et=e("Options:");et[Et]||(et[Et]=[]),B(nt,U.alias,et,Et);let Wt=v=>/^--/.test(_e(v)),F=Object.keys(et).filter(v=>et[v].length>0).map(v=>{let K=et[v].filter(Pt).map(J=>{if(xt.includes(J))return J;for(let R=0,Z;(Z=xt[R])!==void 0;R++)if((U.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((R,Z)=>(R[Z]=[Z].concat(U.alias[Z]||[]).map(k=>v===n.getPositionalGroupName()?k:(/^[0-9]$/.test(k)?U.boolean.includes(Z)?"-":"--":k.length>1?"--":"-")+k).sort((k,bt)=>Wt(k)===Wt(bt)?0:Wt(k)?1:-1).join(", "),R),{});return{groupName:v,normalizedKeys:K,switches:J}});if(F.filter(({groupName:v})=>v!==n.getPositionalGroupName()).some(({normalizedKeys:v,switches:K})=>!v.every(J=>Wt(K[J])))&&F.filter(({groupName:v})=>v!==n.getPositionalGroupName()).forEach(({normalizedKeys:v,switches:K})=>{v.forEach(J=>{Wt(K[J])&&(K[J]=ys(K[J],4))})}),F.forEach(({groupName:v,normalizedKeys:K,switches:J})=>{Q.div(v),K.forEach(R=>{let Z=J[R],k=y[R]||"",bt=null;k.includes(W)&&(k=e(k.substring(W.length))),U.boolean.includes(R)&&(bt=`[${e("boolean")}]`),U.count.includes(R)&&(bt=`[${e("count")}]`),U.string.includes(R)&&(bt=`[${e("string")}]`),U.normalize.includes(R)&&(bt=`[${e("string")}]`),U.array.includes(R)&&(bt=`[${e("array")}]`),U.number.includes(R)&&(bt=`[${e("number")}]`);let wt=h=>typeof h=="string"?`[${e("deprecated: %s",h)}]`:`[${e("deprecated")}]`,he=[R in H?wt(H[R]):null,bt,R in P?`[${e("required")}]`:null,U.choices&&U.choices[R]?`[${e("choices:")} ${n.stringifiedValues(U.choices[R])}]`:null,gt(U.default[R],U.defaultDescription[R])].filter(Boolean).join(" ");Q.span({text:_e(Z),padding:[0,2,0,2+Hn(Z)],width:z(J,Dt)+4},k);let l=s.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;he&&!l?Q.div({text:he,padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}),u.length&&(Q.div(e("Examples:")),u.forEach(v=>{v[0]=v[0].replace(/\$0/g,C)}),u.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(u,Dt)+4},{text:v[1]})}),Q.div()),E.length>0){let v=E.map(K=>K.replace(/\$0/g,C)).join(`
10
10
  `);Q.div(`${v}
11
- `)}return Q.toString().replace(/\s*$/,"")};function z(I,C,P){let L=0;return Array.isArray(I)||(I=Object.values(I).map(Y=>[Y])),I.forEach(Y=>{L=Math.max(t.stringWidth(P?`${P} ${Oe(Y[0])}`:Oe(Y[0]))+Un(Y[0]),L)}),C&&(L=Math.min(L,parseInt((C*.5).toString(),10))),L}function T(){let I=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 I&&s.demandOption(P,I[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 B(I,C,P,L){let Y=[],et=null;return Object.keys(P).forEach(H=>{Y=Y.concat(P[H])}),I.forEach(H=>{et=[H].concat(C[H]),et.some(nt=>Y.indexOf(nt)!==-1)||P[L].push(H)}),Y}function At(I){return s.getOptions().hiddenOptions.indexOf(I)<0||s.parsed.argv[s.getOptions().showHiddenOpt]}n.showHelp=I=>{let C=s.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:C[I])(n.help())},n.functionDescription=I=>["(",I.name?t.Parser.decamelize(I.name,"-"):e("generated-value"),")"].join(""),n.stringifiedValues=function(C,P){let L="",Y=P||", ",et=[].concat(C);return!C||!et.length||et.forEach(H=>{L.length&&(L+=Y),L+=JSON.stringify(H)}),L};function gt(I,C){let P=`[${e("default:")} `;if(I===void 0&&!C)return null;if(C)P+=C;else switch(typeof I){case"string":P+=`"${I}"`;break;case"object":P+=JSON.stringify(I);break;default:P+=I}return`${P}]`}function Jt(){return t.process.stdColumns?Math.min(80,t.process.stdColumns):80}let Ft=null;n.version=I=>{Ft=I},n.showVersion=I=>{let C=s.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:C[I])(Ft)},n.reset=function(C){return r=null,g=!1,w=[],p=!1,E=[],u=[],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:u,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],u=[...P.examples,...u],E=[...P.epilogs,...E]):{failMessage:r,failureOutput:g,usages:w,usageDisabled:p,epilogs:E,examples:u,commands:m,descriptions:y}=P)},n}function Ve(s){return typeof s=="object"}function ms(s,t){return Ve(s)?{text:s.text,indentation:s.indentation+t}:{text:s,indentation:t}}function Un(s){return Ve(s)?s.indentation:0}function Oe(s){return Ve(s)?s.text:s}var Hn=`###-begin-{{app_name}}-completions-###
11
+ `)}return Q.toString().replace(/\s*$/,"")};function z(I,C,P){let L=0;return Array.isArray(I)||(I=Object.values(I).map(H=>[H])),I.forEach(H=>{L=Math.max(t.stringWidth(P?`${P} ${_e(H[0])}`:_e(H[0]))+Hn(H[0]),L)}),C&&(L=Math.min(L,parseInt((C*.5).toString(),10))),L}function Y(){let I=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 I&&s.demandOption(P,I[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 T;n.cacheHelpMessage=function(){T=this.help()},n.clearCachedHelpMessage=function(){T=void 0},n.hasCachedHelpMessage=function(){return!!T};function B(I,C,P,L){let H=[],et=null;return Object.keys(P).forEach(U=>{H=H.concat(P[U])}),I.forEach(U=>{et=[U].concat(C[U]),et.some(nt=>H.indexOf(nt)!==-1)||P[L].push(U)}),H}function Pt(I){return s.getOptions().hiddenOptions.indexOf(I)<0||s.parsed.argv[s.getOptions().showHiddenOpt]}n.showHelp=I=>{let C=s.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:C[I])(n.help())},n.functionDescription=I=>["(",I.name?t.Parser.decamelize(I.name,"-"):e("generated-value"),")"].join(""),n.stringifiedValues=function(C,P){let L="",H=P||", ",et=[].concat(C);return!C||!et.length||et.forEach(U=>{L.length&&(L+=H),L+=JSON.stringify(U)}),L};function gt(I,C){let P=`[${e("default:")} `;if(I===void 0&&!C)return null;if(C)P+=C;else switch(typeof I){case"string":P+=`"${I}"`;break;case"object":P+=JSON.stringify(I);break;default:P+=I}return`${P}]`}function Jt(){return t.process.stdColumns?Math.min(80,t.process.stdColumns):80}let Nt=null;n.version=I=>{Nt=I},n.showVersion=I=>{let C=s.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:C[I])(Nt)},n.reset=function(C){return r=null,m=!1,w=[],p=!1,E=[],u=[],g=[],y=It(y,P=>!C[P]),n};let G=[];return n.freeze=function(){G.push({failMessage:r,failureOutput:m,usages:w,usageDisabled:p,epilogs:E,examples:u,commands:g,descriptions:y})},n.unfreeze=function(C=!1){let P=G.pop();P&&(C?(y={...P.descriptions,...y},g=[...P.commands,...g],w=[...P.usages,...w],u=[...P.examples,...u],E=[...P.epilogs,...E]):{failMessage:r,failureOutput:m,usages:w,usageDisabled:p,epilogs:E,examples:u,commands:g,descriptions:y}=P)},n}function Ke(s){return typeof s=="object"}function ys(s,t){return Ke(s)?{text:s.text,indentation:s.indentation+t}:{text:s,indentation:t}}function Hn(s){return Ke(s)?s.indentation:0}function _e(s){return Ke(s)?s.text:s}var Bn=`###-begin-{{app_name}}-completions-###
12
12
  #
13
13
  # yargs command completion script
14
14
  #
@@ -36,7 +36,7 @@ _{{app_name}}_yargs_completions()
36
36
  }
37
37
  complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
38
38
  ###-end-{{app_name}}-completions-###
39
- `,Yn=`#compdef {{app_name}}
39
+ `,Gn=`#compdef {{app_name}}
40
40
  ###-begin-{{app_name}}-completions-###
41
41
  #
42
42
  # yargs command completion script
@@ -55,14 +55,14 @@ _{{app_name}}_yargs_completions()
55
55
  }
56
56
  compdef _{{app_name}}_yargs_completions {{app_name}}
57
57
  ###-end-{{app_name}}-completions-###
58
- `;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(D=>{let z=y[D];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),u=y=>/^[^0-9]$/.test(y),m=!p(n)&&u(t)?"-":"--";e.push(m+w),i&&e.push(m+"no-"+w)}customCompletion(t,e,n,i){if(ot(this.customCompletionFunction,null,this.shim),bs(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 ws(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?Yn:Hn,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 Bn(s,t,e,n){return new qe(s,t,e,n)}function bs(s){return s.length<3}function ws(s){return s.length>3}function Gn(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 Vn=["$0","--","_"];function qn(s,t,e){let n=e.y18n.__,i=e.y18n.__n,r={};r.nonOptionCount=function(u){let m=s.getDemandedCommands(),E=u._.length+(u["--"]?u["--"].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(u,m){m<u&&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+"",u+""))},r.requiredArguments=function(u,m){let y=null;for(let E of Object.keys(m))(!Object.prototype.hasOwnProperty.call(u,E)||typeof u[E]>"u")&&(y=y||{},y[E]=m[E]);if(y){let E=[];for(let d of Object.keys(y)){let D=y[d];D&&E.indexOf(D)<0&&E.push(D)}let _=E.length?`
58
+ `;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,m=t.length;c<m;++c)if(r[t[c]]&&r[t[c]].builder){let w=r[t[c]].builder;if(Oe(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=St(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 m=!!r.configuration["boolean-negation"]&&r.boolean.includes(c);!a.includes(c)&&!r.hiddenOptions.includes(c)&&!this.argsContainKey(e,c,m)&&this.completeOptionKey(c,t,i,m&&!!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 m=this.yargs.getOptions().choices[c]||[];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]||[]],c;for(let m of a)if(Object.prototype.hasOwnProperty.call(r.key,m)&&Array.isArray(r.choices[m])){c=r.choices[m];break}if(c)return c.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,c,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 z=y[W];return typeof z=="string"&&z.length>0}),_=E?y[E]:void 0,d=(m=(c=y[t])!==null&&c!==void 0?c:_)!==null&&m!==void 0?m:"";w=`${t.replace(/:/g,"\\:")}:${d.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let p=y=>/^--/.test(y),u=y=>/^[^0-9]$/.test(y),g=!p(n)&&u(t)?"-":"--";e.push(g+w),i&&e.push(g+"no-"+w)}customCompletion(t,e,n,i){if(ot(this.customCompletionFunction,null,this.shim),_s(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 Cs(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?Gn:Bn,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 Vn(s,t,e,n){return new Qe(s,t,e,n)}function _s(s){return s.length<3}function Cs(s){return s.length>3}function qn(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 Kn=["$0","--","_"];function Qn(s,t,e){let n=e.y18n.__,i=e.y18n.__n,r={};r.nonOptionCount=function(u){let g=s.getDemandedCommands(),E=u._.length+(u["--"]?u["--"].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(u,g){g<u&&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+"",u+""))},r.requiredArguments=function(u,g){let y=null;for(let E of Object.keys(g))(!Object.prototype.hasOwnProperty.call(u,E)||typeof u[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?`
59
59
  ${E.join(`
60
- `)}`:"";t.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(y).length,Object.keys(y).join(", ")+_))}},r.unknownArguments=function(u,m,y,E,_=!0){var d;let D=s.getInternalMethods().getCommandInstance().getCommands(),z=[],T=s.getInternalMethods().getContext();if(Object.keys(u).forEach(U=>{!Vn.includes(U)&&!Object.prototype.hasOwnProperty.call(y,U)&&!Object.prototype.hasOwnProperty.call(s.getInternalMethods().getParseContext(),U)&&!r.isValidAndSomeAliasIsNotNew(U,m)&&z.push(U)}),_&&(T.commands.length>0||D.length>0||E)&&u._.slice(T.commands.length).forEach(U=>{D.includes(""+U)||z.push(""+U)}),_){let B=((d=s.getDemandedCommands()._)===null||d===void 0?void 0:d.max)||0,At=T.commands.length+B;At<u._.length&&u._.slice(At).forEach(gt=>{gt=String(gt),!T.commands.includes(gt)&&!z.includes(gt)&&z.push(gt)})}z.length&&t.fail(i("Unknown argument: %s","Unknown arguments: %s",z.length,z.map(U=>U.trim()?U:`"${U}"`).join(", ")))},r.unknownCommands=function(u){let m=s.getInternalMethods().getCommandInstance().getCommands(),y=[],E=s.getInternalMethods().getContext();return(E.commands.length>0||m.length>0)&&u._.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(u,m){if(!Object.prototype.hasOwnProperty.call(m,u))return!1;let y=s.parsed.newAliases;return[u,...m[u]].some(E=>!Object.prototype.hasOwnProperty.call(y,E)||!y[u])},r.limitedChoices=function(u){let m=s.getOptions(),y={};if(!Object.keys(m.choices).length)return;Object.keys(u).forEach(d=>{Vn.indexOf(d)===-1&&Object.prototype.hasOwnProperty.call(m.choices,d)&&[].concat(u[d]).forEach(D=>{m.choices[d].indexOf(D)===-1&&D!==void 0&&(y[d]=(y[d]||[]).concat(D))})});let E=Object.keys(y);if(!E.length)return;let _=n("Invalid values:");E.forEach(d=>{_+=`
61
- ${n("Argument: %s, Given: %s, Choices: %s",d,t.stringifiedValues(y[d]),t.stringifiedValues(m.choices[d]))}`}),t.fail(_)};let a={};r.implies=function(u,m){j("<string|object> [array|number|string]",[u,m],arguments.length),typeof u=="object"?Object.keys(u).forEach(y=>{r.implies(y,u[y])}):(s.global(u),a[u]||(a[u]=[]),Array.isArray(m)?m.forEach(y=>r.implies(u,y)):(ot(m,void 0,e),a[u].push(m)))},r.getImplied=function(){return a};function c(p,u){let m=Number(u);return u=isNaN(m)?u:m,typeof u=="number"?u=p._.length>=u:u.match(/^--no-.+/)?(u=u.match(/^--no-(.+)/)[1],u=!Object.prototype.hasOwnProperty.call(p,u)):u=Object.prototype.hasOwnProperty.call(p,u),u}r.implications=function(u){let m=[];if(Object.keys(a).forEach(y=>{let E=y;(a[y]||[]).forEach(_=>{let d=E,D=_;d=c(u,d),_=c(u,_),d&&!_&&m.push(` ${E} -> ${D}`)})}),m.length){let y=`${n("Implications failed:")}
62
- `;m.forEach(E=>{y+=E}),t.fail(y)}};let g={};r.conflicts=function(u,m){j("<string|object> [array|string]",[u,m],arguments.length),typeof u=="object"?Object.keys(u).forEach(y=>{r.conflicts(y,u[y])}):(s.global(u),g[u]||(g[u]=[]),Array.isArray(m)?m.forEach(y=>r.conflicts(u,y)):g[u].push(m))},r.getConflicting=()=>g,r.conflicting=function(u){Object.keys(u).forEach(m=>{g[m]&&g[m].forEach(y=>{y&&u[m]!==void 0&&u[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&&u[e.Parser.camelCase(m)]!==void 0&&u[e.Parser.camelCase(y)]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",m,y))})})},r.recommendCommands=function(u,m){m=m.sort((d,D)=>D.length-d.length);let E=null,_=1/0;for(let d=0,D;(D=m[d])!==void 0;d++){let z=Gn(u,D);z<=3&&z<_&&(_=z,E=D)}E&&t.fail(n("Did you mean %s?",E))},r.reset=function(u){return a=St(a,m=>!u[m]),g=St(g,m=>!u[m]),r};let w=[];return r.freeze=function(){w.push({implied:a,conflicting:g})},r.unfreeze=function(){let u=w.pop();ot(u,void 0,e),{implied:a,conflicting:g}=u},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=Os(t,s.extends);else try{a=Ot.resolve(s.extends)}catch{return s}ys(a),Ke.push(a),i=r?JSON.parse(oe.readFileSync(a,"utf8")):Ot(s.extends),delete s.extends,i=ae(i,oe.path.dirname(a),e,oe)}return Ke=[],e?Kn(i,s):Object.assign({},i,s)}function ys(s){if(Ke.indexOf(s)>-1)throw new V(`Circular extended configurations: '${s}'.`)}function Os(s,t){return oe.path.resolve(s,t)}function Kn(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]=Kn(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,ut,lt,_e,Mt,Tt,Ce,dt,xe,pt,_t,ct,mt,Ee,te,st,M,je,Ae,ft,Ht,ee,Yt,$t,Pe,N,Bt,Gt,Vt,W,Se,Ct,X;function pi(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 Qn=Symbol("copyDoubleDash"),Jn=Symbol("copyDoubleDash"),Qe=Symbol("deleteFromParserHintObject"),Zn=Symbol("emitWarning"),Xn=Symbol("freeze"),kn=Symbol("getDollarZero"),qt=Symbol("getParserConfiguration"),ti=Symbol("getUsageConfiguration"),Je=Symbol("guessLocale"),ei=Symbol("guessVersion"),ni=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"),ii=Symbol("validateAsync"),si=Symbol("getCommandInstance"),ri=Symbol("getContext"),oi=Symbol("getHasOutput"),ai=Symbol("getLoggerInstance"),li=Symbol("getParseContext"),ci=Symbol("getUsageInstance"),fi=Symbol("getValidationInstance"),Ie=Symbol("hasParseCallback"),hi=Symbol("isGlobalContext"),Kt=Symbol("postProcess"),ui=Symbol("rebase"),sn=Symbol("reset"),ce=Symbol("runYargsParserAndExecuteCommands"),rn=Symbol("runValidation"),di=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:[]}),ut.set(this,null),lt.set(this,null),_e.set(this,"show-hidden"),Mt.set(this,null),Tt.set(this,!0),Ce.set(this,{}),dt.set(this,!0),xe.set(this,[]),pt.set(this,void 0),_t.set(this,{}),ct.set(this,!1),mt.set(this,null),Ee.set(this,!0),te.set(this,void 0),st.set(this,""),M.set(this,void 0),je.set(this,void 0),Ae.set(this,{}),ft.set(this,null),Ht.set(this,null),ee.set(this,{}),Yt.set(this,{}),$t.set(this,void 0),Pe.set(this,!1),N.set(this,void 0),Bt.set(this,!1),Gt.set(this,!1),Vt.set(this,!1),W.set(this,void 0),Se.set(this,{}),Ct.set(this,null),X.set(this,void 0),A(this,N,i,"f"),A(this,$t,t,"f"),A(this,Ut,e,"f"),A(this,je,n,"f"),A(this,pt,new we(this),"f"),this.$0=this[kn](),this[sn](),A(this,tt,o(this,tt,"f"),"f"),A(this,W,o(this,W,"f"),"f"),A(this,X,o(this,X,"f"),"f"),A(this,M,o(this,M,"f"),"f"),o(this,M,"f").showHiddenOpt=o(this,_e,"f"),A(this,te,this[Jn](),"f")}addHelpOpt(t,e){let n="help";return j("[string|boolean] [string]",[t,e],arguments.length),o(this,mt,"f")&&(this[Qe](o(this,mt,"f")),A(this,mt,null,"f")),t===!1&&e===void 0?this:(A(this,mt,typeof t=="string"?t:n,"f"),this.boolean(o(this,mt,"f")),this.describe(o(this,mt,"f"),e||o(this,W,"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,W,"f").deferY18nLookup("Show hidden options")),o(this,M,"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)=>Rt(()=>t(n,i.getOptions()),r=>(r?(typeof r=="string"||r instanceof Error)&&o(this,W,"f").fail(r.toString(),r):o(this,W,"f").fail(o(this,N,"f").y18n.__("Argument check failed: %s",t.toString())),n),r=>(o(this,W,"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,M,"f").key[t]=!0,o(this,pt,"f").addCoerceMiddleware((n,i)=>{let r;return Object.prototype.hasOwnProperty.call(n,t)?Rt(()=>(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,N,"f")),o(this,M,"f").configObjects=(o(this,M,"f").configObjects||[]).concat(t),this):(typeof e=="function"&&(n=e,e=void 0),this.describe(t,e||o(this,W,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach(i=>{o(this,M,"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,lt,t||o(this,lt,"f")||"completion","f"),!e&&e!==!1&&(e="generate completion script"),this.command(o(this,lt,"f"),e),n&&o(this,ut,"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,N,"f").require;return o(this,tt,"f").addDirectory(t,n,o(this,N,"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,N,"f")),o(this,M,"f").defaultDescription[t]=n),typeof e=="function"&&(Ye(t,o(this,N,"f")),o(this,M,"f").defaultDescription[t]||(o(this,M,"f").defaultDescription[t]=o(this,W,"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,M,"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,N,"f")),this.demandOption(i,n)}),e=1/0):typeof e!="number"&&(n=e,e=1/0),typeof t=="number"?(ot(n,!0,o(this,N,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach(i=>{ot(n,!0,o(this,N,"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,M,"f").deprecatedOptions[t]=e,this}describe(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[en](t,!0),o(this,W,"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,M,"f").envPrefix:o(this,M,"f").envPrefix=t||"",this}epilogue(t){return j("<string>",[t],arguments.length),o(this,W,"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,W,"f").example(t,e),this}exit(t,e){A(this,ct,!0,"f"),A(this,Mt,e,"f"),o(this,dt,"f")&&o(this,N,"f").process.exit(t)}exitProcess(t=!0){return j("[boolean]",[t],arguments.length),A(this,dt,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,W,"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,ut,"f").getCompletion(t,e):new Promise((n,i)=>{o(this,ut,"f").getCompletion(t,(r,a)=>{r?i(r):n(a)})})}getDemandedOptions(){return j([],0),o(this,M,"f").demandedOptions}getDemandedCommands(){return j([],0),o(this,M,"f").demandedCommands}getDeprecatedOptions(){return j([],0),o(this,M,"f").deprecatedOptions}getDetectLocale(){return o(this,Tt,"f")}getExitProcess(){return o(this,dt,"f")}getGroups(){return Object.assign({},o(this,_t,"f"),o(this,Yt,"f"))}getHelp(){if(A(this,ct,!0,"f"),!o(this,W,"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,W,"f").help())}let t=o(this,tt,"f").runDefaultBuilderOn(this);if(q(t))return t.then(()=>o(this,W,"f").help())}return Promise.resolve(o(this,W,"f").help())}getOptions(){return o(this,M,"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,M,"f").local=o(this,M,"f").local.filter(n=>t.indexOf(n)===-1):t.forEach(n=>{o(this,M,"f").local.includes(n)||o(this,M,"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,_t,"f")[e];o(this,Yt,"f")[e]&&delete o(this,Yt,"f")[e];let i={};return o(this,_t,"f")[e]=(n||[]).concat(t).filter(r=>i[r]?!1:i[r]=!0),this}hide(t){return j("<string>",[t],arguments.length),o(this,M,"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,N,"f").y18n.getLocale()):(A(this,Tt,!1,"f"),o(this,N,"f").y18n.setLocale(t),this)}middleware(t,e,n){return o(this,pt,"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,Ct,"f")&&(t==="version"||e?.alias==="version")&&this[Zn](['"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(`
63
- `),void 0,"versionWarning"),o(this,M,"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,M,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);let r=e.describe||e.description||e.desc,a=o(this,W,"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[Xn](),typeof t>"u"&&(t=o(this,$t,"f")),typeof e=="object"&&(A(this,Ht,e,"f"),e=n),typeof e=="function"&&(A(this,ft,e,"f"),e=!1),e||A(this,$t,t,"f"),o(this,ft,"f")&&A(this,dt,!1,"f");let i=this[ce](t,!!e),r=this.parsed;return o(this,ut,"f").setParsed(this.parsed),q(i)?i.then(a=>(o(this,ft,"f")&&o(this,ft,"f").call(this,o(this,Mt,"f"),a,o(this,st,"f")),a)).catch(a=>{throw o(this,ft,"f")&&o(this,ft,"f")(a,this.parsed.argv,o(this,st,"f")),a}).finally(()=>{this[nn](),this.parsed=r}):(o(this,ft,"f")&&o(this,ft,"f").call(this,o(this,Mt,"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,N,"f")),o(this,M,"f").configObjects=(o(this,M,"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,W,"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,M,"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,ut,"f").generateCompletionScript(t,e||o(this,lt,"f")||"completion")),this}showHelp(t){if(j("[string|function]",[t],arguments.length),A(this,ct,!0,"f"),!o(this,W,"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,W,"f").showHelp(t)}),this}let e=o(this,tt,"f").runDefaultBuilderOn(this);if(q(e))return e.then(()=>{o(this,W,"f").showHelp(t)}),this}return o(this,W,"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,W,"f").showHelpOnFail(t,e),this}showVersion(t){return j("[string|function]",[t],arguments.length),o(this,W,"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,N,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return j("<object>",[t],arguments.length),A(this,Tt,!1,"f"),o(this,N,"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,N,"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,W,"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,Ct,"f")&&(this[Qe](o(this,Ct,"f")),o(this,W,"f").version(void 0),A(this,Ct,null,"f")),arguments.length===0)n=this[ei](),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,Ct,typeof t=="string"?t:i,"f"),e=e||o(this,W,"f").deferY18nLookup("Show version number"),o(this,W,"f").version(n||void 0),this.boolean(o(this,Ct,"f")),this.describe(o(this,Ct,"f"),e),this}wrap(t){return j("<number|null|undefined>",[t],arguments.length),o(this,W,"f").wrap(t),this}[(tt=new WeakMap,Ut=new WeakMap,le=new WeakMap,ut=new WeakMap,lt=new WeakMap,_e=new WeakMap,Mt=new WeakMap,Tt=new WeakMap,Ce=new WeakMap,dt=new WeakMap,xe=new WeakMap,pt=new WeakMap,_t=new WeakMap,ct=new WeakMap,mt=new WeakMap,Ee=new WeakMap,te=new WeakMap,st=new WeakMap,M=new WeakMap,je=new WeakMap,Ae=new WeakMap,ft=new WeakMap,Ht=new WeakMap,ee=new WeakMap,Yt=new WeakMap,$t=new WeakMap,Pe=new WeakMap,N=new WeakMap,Bt=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,W=new WeakMap,Se=new WeakMap,Ct=new WeakMap,X=new WeakMap,Qn)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch{}return t}[Jn](){return{log:(...t)=>{this[Ie]()||console.log(...t),A(this,ct,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
64
- `,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")},error:(...t)=>{this[Ie]()||console.error(...t),A(this,ct,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
65
- `,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")}}}[Qe](t){Xt(o(this,M,"f")).forEach(e=>{if((i=>i==="configObjects")(e))return;let n=o(this,M,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):typeof n=="object"&&delete n[t]}),delete o(this,W,"f").getDescriptions()[t]}[Zn](t,e,n){o(this,Ce,"f")[n]||(o(this,N,"f").process.emitWarning(t,e),o(this,Ce,"f")[n]=!0)}[Xn](){o(this,xe,"f").push({options:o(this,M,"f"),configObjects:o(this,M,"f").configObjects.slice(0),exitProcess:o(this,dt,"f"),groups:o(this,_t,"f"),strict:o(this,Bt,"f"),strictCommands:o(this,Gt,"f"),strictOptions:o(this,Vt,"f"),completionCommand:o(this,lt,"f"),output:o(this,st,"f"),exitError:o(this,Mt,"f"),hasOutput:o(this,ct,"f"),parsed:this.parsed,parseFn:o(this,ft,"f"),parseContext:o(this,Ht,"f")}),o(this,W,"f").freeze(),o(this,X,"f").freeze(),o(this,tt,"f").freeze(),o(this,pt,"f").freeze()}[kn](){let t="",e;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,N,"f").process.argv()[0])?e=o(this,N,"f").process.argv().slice(1,2):e=o(this,N,"f").process.argv().slice(0,1),t=e.map(n=>{let i=this[ui](o(this,Ut,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),o(this,N,"f").getEnv("_")&&o(this,N,"f").getProcessArgvBin()===o(this,N,"f").getEnv("_")&&(t=o(this,N,"f").getEnv("_").replace(`${o(this,N,"f").path.dirname(o(this,N,"f").process.execPath())}/`,"")),t}[qt](){return o(this,Ae,"f")}[ti](){return o(this,Se,"f")}[Je](){if(!o(this,Tt,"f"))return;let t=o(this,N,"f").getEnv("LC_ALL")||o(this,N,"f").getEnv("LC_MESSAGES")||o(this,N,"f").getEnv("LANG")||o(this,N,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[ei](){return this[Ze]().version||"unknown"}[ni](t){let e=t["--"]?t["--"]:t._;for(let n=0,i;(i=e[n])!==void 0;n++)o(this,N,"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,N,"f").mainFilename;!t&&o(this,N,"f").path.extname(i)&&(i=o(this,N,"f").path.dirname(i));let r=o(this,N,"f").findUp(i,(a,c)=>{if(c.includes("package.json"))return"package.json"});ot(r,void 0,o(this,N,"f")),n=JSON.parse(o(this,N,"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,M,"f")[t].push(n)})}[ne](t,e,n,i){this[ke](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=c})}[Xe](t,e,n,i){this[ke](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=(o(this,M,"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,u,m;let y=o(this,xe,"f").pop();ot(y,void 0,o(this,N,"f"));let E;t=this,e=this,n=this,i=this,r=this,a=this,c=this,g=this,w=this,p=this,u=this,m=this,{options:{set value(_){A(t,M,_,"f")}}.value,configObjects:E,exitProcess:{set value(_){A(e,dt,_,"f")}}.value,groups:{set value(_){A(n,_t,_,"f")}}.value,output:{set value(_){A(i,st,_,"f")}}.value,exitError:{set value(_){A(r,Mt,_,"f")}}.value,hasOutput:{set value(_){A(a,ct,_,"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,lt,_,"f")}}.value,parseFn:{set value(_){A(u,ft,_,"f")}}.value,parseContext:{set value(_){A(m,Ht,_,"f")}}.value}=y,o(this,M,"f").configObjects=E,o(this,W,"f").unfreeze(),o(this,X,"f").unfreeze(),o(this,tt,"f").unfreeze(),o(this,pt,"f").unfreeze()}[ii](t,e){return Rt(e,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[si].bind(this),getContext:this[ri].bind(this),getHasOutput:this[oi].bind(this),getLoggerInstance:this[ai].bind(this),getParseContext:this[li].bind(this),getParserConfiguration:this[qt].bind(this),getUsageConfiguration:this[ti].bind(this),getUsageInstance:this[ci].bind(this),getValidationInstance:this[fi].bind(this),hasParseCallback:this[Ie].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[di].bind(this)}}[si](){return o(this,tt,"f")}[ri](){return o(this,le,"f")}[oi](){return o(this,ct,"f")}[ai](){return o(this,te,"f")}[li](){return o(this,Ht,"f")||{}}[ci](){return o(this,W,"f")}[fi](){return o(this,X,"f")}[Ie](){return!!o(this,ft,"f")}[hi](){return o(this,Ee,"f")}[Kt](t,e,n,i){return n||q(t)||(e||(t=this[Qn](t)),(this[qt]()["parse-positional-numbers"]||this[qt]()["parse-positional-numbers"]===void 0)&&(t=this[ni](t)),i&&(t=zt(t,this,o(this,pt,"f").getMiddleware(),!1))),t}[sn](t={}){A(this,M,o(this,M,"f")||{},"f");let e={};e.local=o(this,M,"f").local||[],e.configObjects=o(this,M,"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,_t,"f")).reduce((a,c)=>{let g=o(this,_t,"f")[c].filter(w=>!(w in n));return g.length>0&&(a[c]=g),a},{})),A(this,_t,{},"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,M,"f")[a]||[]).filter(c=>!n[c])}),r.forEach(a=>{e[a]=St(o(this,M,"f")[a],c=>!n[c])}),e.envPrefix=o(this,M,"f").envPrefix,A(this,M,e,"f"),A(this,W,o(this,W,"f")?o(this,W,"f").reset(n):Tn(this,o(this,N,"f")),"f"),A(this,X,o(this,X,"f")?o(this,X,"f").reset(n):qn(this,o(this,W,"f"),o(this,N,"f")),"f"),A(this,tt,o(this,tt,"f")?o(this,tt,"f").reset():zn(o(this,W,"f"),o(this,X,"f"),o(this,pt,"f"),o(this,N,"f")),"f"),o(this,ut,"f")||A(this,ut,Bn(this,o(this,W,"f"),o(this,tt,"f"),o(this,N,"f")),"f"),o(this,pt,"f").reset(),A(this,lt,null,"f"),A(this,st,"","f"),A(this,Mt,null,"f"),A(this,ct,!1,"f"),this.parsed=!1,this}[ui](t,e){return o(this,N,"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,M,"f").__=o(this,N,"f").y18n.__,o(this,M,"f").configuration=this[qt]();let c=!!o(this,M,"f").configuration["populate--"],g=Object.assign({},o(this,M,"f").configuration,{"populate--":!0}),w=o(this,N,"f").Parser.detailed(t,Object.assign({},o(this,M,"f"),{configuration:{"parse-positional-numbers":!1,...g}})),p=Object.assign(w.argv,o(this,Ht,"f")),u,m=w.aliases,y=!1,E=!1;Object.keys(p).forEach(_=>{_===o(this,mt,"f")&&p[_]?y=!0:_===o(this,Ct,"f")&&p[_]&&(E=!0)}),p.$0=this.$0,this.parsed=w,i===0&&o(this,W,"f").clearCachedHelpMessage();try{if(this[Je](),e)return this[Kt](p,c,!!n,!1);o(this,mt,"f")&&[o(this,mt,"f")].concat(m[o(this,mt,"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,ut,"f").completionKey in p,D=y||d||r;if(p._.length){if(_.length){let z;for(let T=i||0,U;p._[T]!==void 0;T++)if(U=String(p._[T]),_.includes(U)&&U!==o(this,lt,"f")){let B=o(this,tt,"f").runCommand(U,this,w,T+1,r,y||E||r);return this[Kt](B,c,!!n,!1)}else if(!z&&U!==o(this,lt,"f")){z=U;break}!o(this,tt,"f").hasDefaultCommand()&&o(this,Pe,"f")&&z&&!D&&o(this,X,"f").recommendCommands(z,_)}o(this,lt,"f")&&p._.includes(o(this,lt,"f"))&&!d&&(o(this,dt,"f")&&It(!0),this.showCompletionScript(),this.exit(0))}if(o(this,tt,"f").hasDefaultCommand()&&!D){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,dt,"f")&&It(!0),t=[].concat(t);let z=t.slice(t.indexOf(`--${o(this,ut,"f").completionKey}`)+1);return o(this,ut,"f").getCompletion(z,(T,U)=>{if(T)throw new V(T.message);(U||[]).forEach(B=>{o(this,te,"f").log(B)}),this.exit(0)}),this[Kt](p,!c,!!n,!1)}if(o(this,ct,"f")||(y?(o(this,dt,"f")&&It(!0),a=!0,this.showHelp("log"),this.exit(0)):E&&(o(this,dt,"f")&&It(!0),a=!0,o(this,W,"f").showVersion("log"),this.exit(0))),!a&&o(this,M,"f").skipValidation.length>0&&(a=Object.keys(p).some(z=>o(this,M,"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||(u=zt(p,this,o(this,pt,"f").getMiddleware(),!0)),u=this[ii](z,u??p),q(u)&&!n&&(u=u.then(()=>zt(p,this,o(this,pt,"f").getMiddleware(),!1)))}}}catch(_){if(_ instanceof V)o(this,W,"f").fail(_.message,_);else throw _}return this[Kt](u??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)}}[di](){A(this,ct,!0,"f")}[Qt](t){if(typeof t=="string")o(this,M,"f").key[t]=!0;else for(let e of t)o(this,M,"f").key[e]=!0}};function Rn(s){return!!s&&typeof s.getInternalMethods=="function"}var _s=pi(He),mi=_s;await mi(Ue(process.argv)).command("$0 <file>",'Convert a tldraw ".tldr" file to an svg or png image',s=>s.positional("file",{demandOption:!0,describe:'The ".tldr" file to convert',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("verbose",{default:!1,describe:"Enable verbose output",type:"boolean"}),async s=>{let{file:t,format:e,output:n,verbose:i}=s;try{await pn(t,e,n,i)}catch(r){console.error("Error during conversion:",r),process.exit(1)}}).alias("h","help").version("version",an).alias("v","version").help().parse();
60
+ `)}`:"";t.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(y).length,Object.keys(y).join(", ")+_))}},r.unknownArguments=function(u,g,y,E,_=!0){var d;let W=s.getInternalMethods().getCommandInstance().getCommands(),z=[],Y=s.getInternalMethods().getContext();if(Object.keys(u).forEach(T=>{!Kn.includes(T)&&!Object.prototype.hasOwnProperty.call(y,T)&&!Object.prototype.hasOwnProperty.call(s.getInternalMethods().getParseContext(),T)&&!r.isValidAndSomeAliasIsNotNew(T,g)&&z.push(T)}),_&&(Y.commands.length>0||W.length>0||E)&&u._.slice(Y.commands.length).forEach(T=>{W.includes(""+T)||z.push(""+T)}),_){let B=((d=s.getDemandedCommands()._)===null||d===void 0?void 0:d.max)||0,Pt=Y.commands.length+B;Pt<u._.length&&u._.slice(Pt).forEach(gt=>{gt=String(gt),!Y.commands.includes(gt)&&!z.includes(gt)&&z.push(gt)})}z.length&&t.fail(i("Unknown argument: %s","Unknown arguments: %s",z.length,z.map(T=>T.trim()?T:`"${T}"`).join(", ")))},r.unknownCommands=function(u){let g=s.getInternalMethods().getCommandInstance().getCommands(),y=[],E=s.getInternalMethods().getContext();return(E.commands.length>0||g.length>0)&&u._.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(u,g){if(!Object.prototype.hasOwnProperty.call(g,u))return!1;let y=s.parsed.newAliases;return[u,...g[u]].some(E=>!Object.prototype.hasOwnProperty.call(y,E)||!y[u])},r.limitedChoices=function(u){let g=s.getOptions(),y={};if(!Object.keys(g.choices).length)return;Object.keys(u).forEach(d=>{Kn.indexOf(d)===-1&&Object.prototype.hasOwnProperty.call(g.choices,d)&&[].concat(u[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=>{_+=`
61
+ ${n("Argument: %s, Given: %s, Choices: %s",d,t.stringifiedValues(y[d]),t.stringifiedValues(g.choices[d]))}`}),t.fail(_)};let a={};r.implies=function(u,g){j("<string|object> [array|number|string]",[u,g],arguments.length),typeof u=="object"?Object.keys(u).forEach(y=>{r.implies(y,u[y])}):(s.global(u),a[u]||(a[u]=[]),Array.isArray(g)?g.forEach(y=>r.implies(u,y)):(ot(g,void 0,e),a[u].push(g)))},r.getImplied=function(){return a};function c(p,u){let g=Number(u);return u=isNaN(g)?u:g,typeof u=="number"?u=p._.length>=u:u.match(/^--no-.+/)?(u=u.match(/^--no-(.+)/)[1],u=!Object.prototype.hasOwnProperty.call(p,u)):u=Object.prototype.hasOwnProperty.call(p,u),u}r.implications=function(u){let g=[];if(Object.keys(a).forEach(y=>{let E=y;(a[y]||[]).forEach(_=>{let d=E,W=_;d=c(u,d),_=c(u,_),d&&!_&&g.push(` ${E} -> ${W}`)})}),g.length){let y=`${n("Implications failed:")}
62
+ `;g.forEach(E=>{y+=E}),t.fail(y)}};let m={};r.conflicts=function(u,g){j("<string|object> [array|string]",[u,g],arguments.length),typeof u=="object"?Object.keys(u).forEach(y=>{r.conflicts(y,u[y])}):(s.global(u),m[u]||(m[u]=[]),Array.isArray(g)?g.forEach(y=>r.conflicts(u,y)):m[u].push(g))},r.getConflicting=()=>m,r.conflicting=function(u){Object.keys(u).forEach(g=>{m[g]&&m[g].forEach(y=>{y&&u[g]!==void 0&&u[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&&u[e.Parser.camelCase(g)]!==void 0&&u[e.Parser.camelCase(y)]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",g,y))})})},r.recommendCommands=function(u,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 z=qn(u,W);z<=3&&z<_&&(_=z,E=W)}E&&t.fail(n("Did you mean %s?",E))},r.reset=function(u){return a=It(a,g=>!u[g]),m=It(m,g=>!u[g]),r};let w=[];return r.freeze=function(){w.push({implied:a,conflicting:m})},r.unfreeze=function(){let u=w.pop();ot(u,void 0,e),{implied:a,conflicting:m}=u},r}var Je=[],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=Es(t,s.extends);else try{a=Ot.resolve(s.extends)}catch{return s}xs(a),Je.push(a),i=r?JSON.parse(ae.readFileSync(a,"utf8")):Ot(s.extends),delete s.extends,i=le(i,ae.path.dirname(a),e,ae)}return Je=[],e?Jn(i,s):Object.assign({},i,s)}function xs(s){if(Je.indexOf(s)>-1)throw new V(`Circular extended configurations: '${s}'.`)}function Es(s,t){return ae.path.resolve(s,t)}function Jn(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]=Jn(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,Tt,ce,ut,lt,Ce,$t,Ut,xe,dt,Ee,pt,_t,ct,mt,je,te,st,M,Ae,Pe,ft,Ht,ee,Yt,vt,Se,N,Bt,Gt,Vt,D,Ie,Ct,X;function gi(s){return(t=[],e=s.process.cwd(),n)=>{let i=new ln(t,e,n,s);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var Zn=Symbol("copyDoubleDash"),Xn=Symbol("copyDoubleDash"),Ze=Symbol("deleteFromParserHintObject"),kn=Symbol("emitWarning"),ti=Symbol("freeze"),ei=Symbol("getDollarZero"),qt=Symbol("getParserConfiguration"),ni=Symbol("getUsageConfiguration"),Xe=Symbol("guessLocale"),ii=Symbol("guessVersion"),si=Symbol("parsePositionalNumbers"),ke=Symbol("pkgUp"),Ft=Symbol("populateParserHintArray"),ne=Symbol("populateParserHintSingleValueDictionary"),tn=Symbol("populateParserHintArrayDictionary"),en=Symbol("populateParserHintDictionary"),nn=Symbol("sanitizeKey"),sn=Symbol("setKey"),rn=Symbol("unfreeze"),ri=Symbol("validateAsync"),oi=Symbol("getCommandInstance"),ai=Symbol("getContext"),li=Symbol("getHasOutput"),ci=Symbol("getLoggerInstance"),fi=Symbol("getParseContext"),hi=Symbol("getUsageInstance"),ui=Symbol("getValidationInstance"),Me=Symbol("hasParseCallback"),di=Symbol("isGlobalContext"),Kt=Symbol("postProcess"),pi=Symbol("rebase"),on=Symbol("reset"),fe=Symbol("runYargsParserAndExecuteCommands"),an=Symbol("runValidation"),mi=Symbol("setHasOutput"),Qt=Symbol("kTrackManuallySetKeys"),ln=class{constructor(t=[],e,n,i){this.customScriptName=!1,this.parsed=!1,tt.set(this,void 0),Tt.set(this,void 0),ce.set(this,{commands:[],fullCommands:[]}),ut.set(this,null),lt.set(this,null),Ce.set(this,"show-hidden"),$t.set(this,null),Ut.set(this,!0),xe.set(this,{}),dt.set(this,!0),Ee.set(this,[]),pt.set(this,void 0),_t.set(this,{}),ct.set(this,!1),mt.set(this,null),je.set(this,!0),te.set(this,void 0),st.set(this,""),M.set(this,void 0),Ae.set(this,void 0),Pe.set(this,{}),ft.set(this,null),Ht.set(this,null),ee.set(this,{}),Yt.set(this,{}),vt.set(this,void 0),Se.set(this,!1),N.set(this,void 0),Bt.set(this,!1),Gt.set(this,!1),Vt.set(this,!1),D.set(this,void 0),Ie.set(this,{}),Ct.set(this,null),X.set(this,void 0),A(this,N,i,"f"),A(this,vt,t,"f"),A(this,Tt,e,"f"),A(this,Ae,n,"f"),A(this,pt,new ye(this),"f"),this.$0=this[ei](),this[on](),A(this,tt,o(this,tt,"f"),"f"),A(this,D,o(this,D,"f"),"f"),A(this,X,o(this,X,"f"),"f"),A(this,M,o(this,M,"f"),"f"),o(this,M,"f").showHiddenOpt=o(this,Ce,"f"),A(this,te,this[Xn](),"f")}addHelpOpt(t,e){let n="help";return j("[string|boolean] [string]",[t,e],arguments.length),o(this,mt,"f")&&(this[Ze](o(this,mt,"f")),A(this,mt,null,"f")),t===!1&&e===void 0?this:(A(this,mt,typeof t=="string"?t:n,"f"),this.boolean(o(this,mt,"f")),this.describe(o(this,mt,"f"),e||o(this,D,"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,Ce,"f");return this.boolean(n),this.describe(n,e||o(this,D,"f").deferY18nLookup("Show hidden options")),o(this,M,"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[tn](this.alias.bind(this),"alias",t,e),this}array(t){return j("<array|string>",[t],arguments.length),this[Ft]("array",t),this[Qt](t),this}boolean(t){return j("<array|string>",[t],arguments.length),this[Ft]("boolean",t),this[Qt](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,D,"f").fail(r.toString(),r):o(this,D,"f").fail(o(this,N,"f").y18n.__("Argument check failed: %s",t.toString())),n),r=>(o(this,D,"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[tn](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,M,"f").key[t]=!0,o(this,pt,"f").addCoerceMiddleware((n,i)=>{let r;return Object.prototype.hasOwnProperty.call(n,t)?Rt(()=>(r=i.getAliases(),e(n[t])),c=>{n[t]=c;let m=i.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[t]&&m!==!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=le(t,o(this,Tt,"f"),this[qt]()["deep-merge-config"]||!1,o(this,N,"f")),o(this,M,"f").configObjects=(o(this,M,"f").configObjects||[]).concat(t),this):(typeof e=="function"&&(n=e,e=void 0),this.describe(t,e||o(this,D,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach(i=>{o(this,M,"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,lt,t||o(this,lt,"f")||"completion","f"),!e&&e!==!1&&(e="generate completion script"),this.command(o(this,lt,"f"),e),n&&o(this,ut,"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,Ae,"f")||o(this,N,"f").require;return o(this,tt,"f").addDirectory(t,n,o(this,N,"f").getCallerFile(),e),this}count(t){return j("<array|string>",[t],arguments.length),this[Ft]("count",t),this[Qt](t),this}default(t,e,n){return j("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(Ge(t,o(this,N,"f")),o(this,M,"f").defaultDescription[t]=n),typeof e=="function"&&(Ge(t,o(this,N,"f")),o(this,M,"f").defaultDescription[t]||(o(this,M,"f").defaultDescription[t]=o(this,D,"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,M,"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,N,"f")),this.demandOption(i,n)}),e=1/0):typeof e!="number"&&(n=e,e=1/0),typeof t=="number"?(ot(n,!0,o(this,N,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach(i=>{ot(n,!0,o(this,N,"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,M,"f").deprecatedOptions[t]=e,this}describe(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[sn](t,!0),o(this,D,"f").describe(t,e),this}detectLocale(t){return j("<boolean>",[t],arguments.length),A(this,Ut,t,"f"),this}env(t){return j("[string|boolean]",[t],arguments.length),t===!1?delete o(this,M,"f").envPrefix:o(this,M,"f").envPrefix=t||"",this}epilogue(t){return j("<string>",[t],arguments.length),o(this,D,"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,D,"f").example(t,e),this}exit(t,e){A(this,ct,!0,"f"),A(this,$t,e,"f"),o(this,dt,"f")&&o(this,N,"f").process.exit(t)}exitProcess(t=!0){return j("[boolean]",[t],arguments.length),A(this,dt,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,D,"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,ut,"f").getCompletion(t,e):new Promise((n,i)=>{o(this,ut,"f").getCompletion(t,(r,a)=>{r?i(r):n(a)})})}getDemandedOptions(){return j([],0),o(this,M,"f").demandedOptions}getDemandedCommands(){return j([],0),o(this,M,"f").demandedCommands}getDeprecatedOptions(){return j([],0),o(this,M,"f").deprecatedOptions}getDetectLocale(){return o(this,Ut,"f")}getExitProcess(){return o(this,dt,"f")}getGroups(){return Object.assign({},o(this,_t,"f"),o(this,Yt,"f"))}getHelp(){if(A(this,ct,!0,"f"),!o(this,D,"f").hasCachedHelpMessage()){if(!this.parsed){let e=this[fe](o(this,vt,"f"),void 0,void 0,0,!0);if(q(e))return e.then(()=>o(this,D,"f").help())}let t=o(this,tt,"f").runDefaultBuilderOn(this);if(q(t))return t.then(()=>o(this,D,"f").help())}return Promise.resolve(o(this,D,"f").help())}getOptions(){return o(this,M,"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,M,"f").local=o(this,M,"f").local.filter(n=>t.indexOf(n)===-1):t.forEach(n=>{o(this,M,"f").local.includes(n)||o(this,M,"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,_t,"f")[e];o(this,Yt,"f")[e]&&delete o(this,Yt,"f")[e];let i={};return o(this,_t,"f")[e]=(n||[]).concat(t).filter(r=>i[r]?!1:i[r]=!0),this}hide(t){return j("<string>",[t],arguments.length),o(this,M,"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[Xe](),o(this,N,"f").y18n.getLocale()):(A(this,Ut,!1,"f"),o(this,N,"f").y18n.setLocale(t),this)}middleware(t,e,n){return o(this,pt,"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[Ft]("normalize",t),this}number(t){return j("<array|string>",[t],arguments.length),this[Ft]("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,Ct,"f")&&(t==="version"||e?.alias==="version")&&this[kn](['"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(`
63
+ `),void 0,"versionWarning"),o(this,M,"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,M,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);let r=e.describe||e.description||e.desc,a=o(this,D,"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[ti](),typeof t>"u"&&(t=o(this,vt,"f")),typeof e=="object"&&(A(this,Ht,e,"f"),e=n),typeof e=="function"&&(A(this,ft,e,"f"),e=!1),e||A(this,vt,t,"f"),o(this,ft,"f")&&A(this,dt,!1,"f");let i=this[fe](t,!!e),r=this.parsed;return o(this,ut,"f").setParsed(this.parsed),q(i)?i.then(a=>(o(this,ft,"f")&&o(this,ft,"f").call(this,o(this,$t,"f"),a,o(this,st,"f")),a)).catch(a=>{throw o(this,ft,"f")&&o(this,ft,"f")(a,this.parsed.argv,o(this,st,"f")),a}).finally(()=>{this[rn](),this.parsed=r}):(o(this,ft,"f")&&o(this,ft,"f").call(this,o(this,$t,"f"),i,o(this,st,"f")),this[rn](),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,Pe,t,"f"),this}pkgConf(t,e){j("<string> [string]",[t,e],arguments.length);let n=null,i=this[ke](e||o(this,Tt,"f"));return i[t]&&typeof i[t]=="object"&&(n=le(i[t],e||o(this,Tt,"f"),this[qt]()["deep-merge-config"]||!1,o(this,N,"f")),o(this,M,"f").configObjects=(o(this,M,"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=It(e,(a,c)=>a==="type"&&!["string","number","boolean"].includes(c)?!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 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,D,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return j("[boolean]",[t],arguments.length),A(this,Se,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,M,"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,ut,"f").generateCompletionScript(t,e||o(this,lt,"f")||"completion")),this}showHelp(t){if(j("[string|function]",[t],arguments.length),A(this,ct,!0,"f"),!o(this,D,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[fe](o(this,vt,"f"),void 0,void 0,0,!0);if(q(n))return n.then(()=>{o(this,D,"f").showHelp(t)}),this}let e=o(this,tt,"f").runDefaultBuilderOn(this);if(q(e))return e.then(()=>{o(this,D,"f").showHelp(t)}),this}return o(this,D,"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,D,"f").showHelpOnFail(t,e),this}showVersion(t){return j("[string|function]",[t],arguments.length),o(this,D,"f").showVersion(t),this}skipValidation(t){return j("<array|string>",[t],arguments.length),this[Ft]("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[Ft]("string",t),this[Qt](t),this}terminalWidth(){return j([],0),o(this,N,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return j("<object>",[t],arguments.length),A(this,Ut,!1,"f"),o(this,N,"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,N,"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,D,"f").usage(t),this}usageConfiguration(t){return j("<object>",[t],arguments.length),A(this,Ie,t,"f"),this}version(t,e,n){let i="version";if(j("[boolean|string] [string] [string]",[t,e,n],arguments.length),o(this,Ct,"f")&&(this[Ze](o(this,Ct,"f")),o(this,D,"f").version(void 0),A(this,Ct,null,"f")),arguments.length===0)n=this[ii](),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,Ct,typeof t=="string"?t:i,"f"),e=e||o(this,D,"f").deferY18nLookup("Show version number"),o(this,D,"f").version(n||void 0),this.boolean(o(this,Ct,"f")),this.describe(o(this,Ct,"f"),e),this}wrap(t){return j("<number|null|undefined>",[t],arguments.length),o(this,D,"f").wrap(t),this}[(tt=new WeakMap,Tt=new WeakMap,ce=new WeakMap,ut=new WeakMap,lt=new WeakMap,Ce=new WeakMap,$t=new WeakMap,Ut=new WeakMap,xe=new WeakMap,dt=new WeakMap,Ee=new WeakMap,pt=new WeakMap,_t=new WeakMap,ct=new WeakMap,mt=new WeakMap,je=new WeakMap,te=new WeakMap,st=new WeakMap,M=new WeakMap,Ae=new WeakMap,Pe=new WeakMap,ft=new WeakMap,Ht=new WeakMap,ee=new WeakMap,Yt=new WeakMap,vt=new WeakMap,Se=new WeakMap,N=new WeakMap,Bt=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,D=new WeakMap,Ie=new WeakMap,Ct=new WeakMap,X=new WeakMap,Zn)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch{}return t}[Xn](){return{log:(...t)=>{this[Me]()||console.log(...t),A(this,ct,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
64
+ `,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")},error:(...t)=>{this[Me]()||console.error(...t),A(this,ct,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
65
+ `,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")}}}[Ze](t){Xt(o(this,M,"f")).forEach(e=>{if((i=>i==="configObjects")(e))return;let n=o(this,M,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):typeof n=="object"&&delete n[t]}),delete o(this,D,"f").getDescriptions()[t]}[kn](t,e,n){o(this,xe,"f")[n]||(o(this,N,"f").process.emitWarning(t,e),o(this,xe,"f")[n]=!0)}[ti](){o(this,Ee,"f").push({options:o(this,M,"f"),configObjects:o(this,M,"f").configObjects.slice(0),exitProcess:o(this,dt,"f"),groups:o(this,_t,"f"),strict:o(this,Bt,"f"),strictCommands:o(this,Gt,"f"),strictOptions:o(this,Vt,"f"),completionCommand:o(this,lt,"f"),output:o(this,st,"f"),exitError:o(this,$t,"f"),hasOutput:o(this,ct,"f"),parsed:this.parsed,parseFn:o(this,ft,"f"),parseContext:o(this,Ht,"f")}),o(this,D,"f").freeze(),o(this,X,"f").freeze(),o(this,tt,"f").freeze(),o(this,pt,"f").freeze()}[ei](){let t="",e;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,N,"f").process.argv()[0])?e=o(this,N,"f").process.argv().slice(1,2):e=o(this,N,"f").process.argv().slice(0,1),t=e.map(n=>{let i=this[pi](o(this,Tt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),o(this,N,"f").getEnv("_")&&o(this,N,"f").getProcessArgvBin()===o(this,N,"f").getEnv("_")&&(t=o(this,N,"f").getEnv("_").replace(`${o(this,N,"f").path.dirname(o(this,N,"f").process.execPath())}/`,"")),t}[qt](){return o(this,Pe,"f")}[ni](){return o(this,Ie,"f")}[Xe](){if(!o(this,Ut,"f"))return;let t=o(this,N,"f").getEnv("LC_ALL")||o(this,N,"f").getEnv("LC_MESSAGES")||o(this,N,"f").getEnv("LANG")||o(this,N,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[ii](){return this[ke]().version||"unknown"}[si](t){let e=t["--"]?t["--"]:t._;for(let n=0,i;(i=e[n])!==void 0;n++)o(this,N,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`)))&&(e[n]=Number(i));return t}[ke](t){let e=t||"*";if(o(this,ee,"f")[e])return o(this,ee,"f")[e];let n={};try{let i=t||o(this,N,"f").mainFilename;!t&&o(this,N,"f").path.extname(i)&&(i=o(this,N,"f").path.dirname(i));let r=o(this,N,"f").findUp(i,(a,c)=>{if(c.includes("package.json"))return"package.json"});ot(r,void 0,o(this,N,"f")),n=JSON.parse(o(this,N,"f").readFileSync(r,"utf8"))}catch{}return o(this,ee,"f")[e]=n||{},o(this,ee,"f")[e]}[Ft](t,e){e=[].concat(e),e.forEach(n=>{n=this[nn](n),o(this,M,"f")[t].push(n)})}[ne](t,e,n,i){this[en](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=c})}[tn](t,e,n,i){this[en](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=(o(this,M,"f")[r][a]||[]).concat(c)})}[en](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[nn](n),i)}[nn](t){return t==="__proto__"?"___proto___":t}[sn](t,e){return this[ne](this[sn].bind(this),"key",t,e),this}[rn](){var t,e,n,i,r,a,c,m,w,p,u,g;let y=o(this,Ee,"f").pop();ot(y,void 0,o(this,N,"f"));let E;t=this,e=this,n=this,i=this,r=this,a=this,c=this,m=this,w=this,p=this,u=this,g=this,{options:{set value(_){A(t,M,_,"f")}}.value,configObjects:E,exitProcess:{set value(_){A(e,dt,_,"f")}}.value,groups:{set value(_){A(n,_t,_,"f")}}.value,output:{set value(_){A(i,st,_,"f")}}.value,exitError:{set value(_){A(r,$t,_,"f")}}.value,hasOutput:{set value(_){A(a,ct,_,"f")}}.value,parsed:this.parsed,strict:{set value(_){A(c,Bt,_,"f")}}.value,strictCommands:{set value(_){A(m,Gt,_,"f")}}.value,strictOptions:{set value(_){A(w,Vt,_,"f")}}.value,completionCommand:{set value(_){A(p,lt,_,"f")}}.value,parseFn:{set value(_){A(u,ft,_,"f")}}.value,parseContext:{set value(_){A(g,Ht,_,"f")}}.value}=y,o(this,M,"f").configObjects=E,o(this,D,"f").unfreeze(),o(this,X,"f").unfreeze(),o(this,tt,"f").unfreeze(),o(this,pt,"f").unfreeze()}[ri](t,e){return Rt(e,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[oi].bind(this),getContext:this[ai].bind(this),getHasOutput:this[li].bind(this),getLoggerInstance:this[ci].bind(this),getParseContext:this[fi].bind(this),getParserConfiguration:this[qt].bind(this),getUsageConfiguration:this[ni].bind(this),getUsageInstance:this[hi].bind(this),getValidationInstance:this[ui].bind(this),hasParseCallback:this[Me].bind(this),isGlobalContext:this[di].bind(this),postProcess:this[Kt].bind(this),reset:this[on].bind(this),runValidation:this[an].bind(this),runYargsParserAndExecuteCommands:this[fe].bind(this),setHasOutput:this[mi].bind(this)}}[oi](){return o(this,tt,"f")}[ai](){return o(this,ce,"f")}[li](){return o(this,ct,"f")}[ci](){return o(this,te,"f")}[fi](){return o(this,Ht,"f")||{}}[hi](){return o(this,D,"f")}[ui](){return o(this,X,"f")}[Me](){return!!o(this,ft,"f")}[di](){return o(this,je,"f")}[Kt](t,e,n,i){return n||q(t)||(e||(t=this[Zn](t)),(this[qt]()["parse-positional-numbers"]||this[qt]()["parse-positional-numbers"]===void 0)&&(t=this[si](t)),i&&(t=zt(t,this,o(this,pt,"f").getMiddleware(),!1))),t}[on](t={}){A(this,M,o(this,M,"f")||{},"f");let e={};e.local=o(this,M,"f").local||[],e.configObjects=o(this,M,"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,_t,"f")).reduce((a,c)=>{let m=o(this,_t,"f")[c].filter(w=>!(w in n));return m.length>0&&(a[c]=m),a},{})),A(this,_t,{},"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,M,"f")[a]||[]).filter(c=>!n[c])}),r.forEach(a=>{e[a]=It(o(this,M,"f")[a],c=>!n[c])}),e.envPrefix=o(this,M,"f").envPrefix,A(this,M,e,"f"),A(this,D,o(this,D,"f")?o(this,D,"f").reset(n):Yn(this,o(this,N,"f")),"f"),A(this,X,o(this,X,"f")?o(this,X,"f").reset(n):Qn(this,o(this,D,"f"),o(this,N,"f")),"f"),A(this,tt,o(this,tt,"f")?o(this,tt,"f").reset():Tn(o(this,D,"f"),o(this,X,"f"),o(this,pt,"f"),o(this,N,"f")),"f"),o(this,ut,"f")||A(this,ut,Vn(this,o(this,D,"f"),o(this,tt,"f"),o(this,N,"f")),"f"),o(this,pt,"f").reset(),A(this,lt,null,"f"),A(this,st,"","f"),A(this,$t,null,"f"),A(this,ct,!1,"f"),this.parsed=!1,this}[pi](t,e){return o(this,N,"f").path.relative(t,e)}[fe](t,e,n,i=0,r=!1){let a=!!n||r;t=t||o(this,vt,"f"),o(this,M,"f").__=o(this,N,"f").y18n.__,o(this,M,"f").configuration=this[qt]();let c=!!o(this,M,"f").configuration["populate--"],m=Object.assign({},o(this,M,"f").configuration,{"populate--":!0}),w=o(this,N,"f").Parser.detailed(t,Object.assign({},o(this,M,"f"),{configuration:{"parse-positional-numbers":!1,...m}})),p=Object.assign(w.argv,o(this,Ht,"f")),u,g=w.aliases,y=!1,E=!1;Object.keys(p).forEach(_=>{_===o(this,mt,"f")&&p[_]?y=!0:_===o(this,Ct,"f")&&p[_]&&(E=!0)}),p.$0=this.$0,this.parsed=w,i===0&&o(this,D,"f").clearCachedHelpMessage();try{if(this[Xe](),e)return this[Kt](p,c,!!n,!1);o(this,mt,"f")&&[o(this,mt,"f")].concat(g[o(this,mt,"f")]||[]).filter(Y=>Y.length>1).includes(""+p._[p._.length-1])&&(p._.pop(),y=!0),A(this,je,!1,"f");let _=o(this,tt,"f").getCommands(),d=o(this,ut,"f").completionKey in p,W=y||d||r;if(p._.length){if(_.length){let z;for(let Y=i||0,T;p._[Y]!==void 0;Y++)if(T=String(p._[Y]),_.includes(T)&&T!==o(this,lt,"f")){let B=o(this,tt,"f").runCommand(T,this,w,Y+1,r,y||E||r);return this[Kt](B,c,!!n,!1)}else if(!z&&T!==o(this,lt,"f")){z=T;break}!o(this,tt,"f").hasDefaultCommand()&&o(this,Se,"f")&&z&&!W&&o(this,X,"f").recommendCommands(z,_)}o(this,lt,"f")&&p._.includes(o(this,lt,"f"))&&!d&&(o(this,dt,"f")&&Mt(!0),this.showCompletionScript(),this.exit(0))}if(o(this,tt,"f").hasDefaultCommand()&&!W){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,dt,"f")&&Mt(!0),t=[].concat(t);let z=t.slice(t.indexOf(`--${o(this,ut,"f").completionKey}`)+1);return o(this,ut,"f").getCompletion(z,(Y,T)=>{if(Y)throw new V(Y.message);(T||[]).forEach(B=>{o(this,te,"f").log(B)}),this.exit(0)}),this[Kt](p,!c,!!n,!1)}if(o(this,ct,"f")||(y?(o(this,dt,"f")&&Mt(!0),a=!0,this.showHelp("log"),this.exit(0)):E&&(o(this,dt,"f")&&Mt(!0),a=!0,o(this,D,"f").showVersion("log"),this.exit(0))),!a&&o(this,M,"f").skipValidation.length>0&&(a=Object.keys(p).some(z=>o(this,M,"f").skipValidation.indexOf(z)>=0&&p[z]===!0)),!a){if(w.error)throw new V(w.error.message);if(!d){let z=this[an](g,{},w.error);n||(u=zt(p,this,o(this,pt,"f").getMiddleware(),!0)),u=this[ri](z,u??p),q(u)&&!n&&(u=u.then(()=>zt(p,this,o(this,pt,"f").getMiddleware(),!1)))}}}catch(_){if(_ instanceof V)o(this,D,"f").fail(_.message,_);else throw _}return this[Kt](u??p,c,!!n,!0)}[an](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)}}[mi](){A(this,ct,!0,"f")}[Qt](t){if(typeof t=="string")o(this,M,"f").key[t]=!0;else for(let e of t)o(this,M,"f").key[e]=!0}};function Un(s){return!!s&&typeof s.getInternalMethods=="function"}var js=gi(Be),bi=js;await bi(He(process.argv)).command("$0 <file>",'Convert a tldraw ".tldr" file to an svg or png image',s=>s.positional("fileOrUrl",{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("verbose",{default:!1,describe:"Enable verbose output",type:"boolean"}),async s=>{let{fileOrUrl:t,format:e,output:n,verbose:i}=s;try{await mn(t,e,n,i)}catch(r){console.error("Error during conversion:",r),process.exit(1)}}).alias("h","help").version("version",cn).alias("v","version").help().parse();
66
66
  /*! Bundled license information:
67
67
 
68
68
  yargs-parser/build/lib/string-utils.js:
@@ -1,2 +1,2 @@
1
1
  export type { ExportFormat } from '../types';
2
- export { tldrToImage } from './tldr-to-image';
2
+ export { tldrawToImage } from './tldraw-to-image';
package/dist/lib/index.js CHANGED
@@ -1 +1 @@
1
- import D from"express";import R from"node:net";import C from"node:os";var w=class extends Error{constructor(t){super(`${t} is locked`)}},c={old:new Set,young:new Set},B=1e3*15;var d,k=()=>{let e=C.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let s of Object.values(e))for(let o of s)t.add(o.address);return t},b=e=>new Promise((t,s)=>{let o=R.createServer();o.unref(),o.on("error",s),o.listen(e,()=>{let{port:n}=o.address();o.close(()=>{t(n)})})}),$=async(e,t)=>{if(e.host||e.port===0)return b(e);for(let s of t)try{await b({port:e.port,host:s})}catch(o){if(!["EADDRNOTAVAIL","EINVAL"].includes(o.code))throw o}return e.port},L=function*(e){e&&(yield*e),yield 0};async function h(e){let t,s=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 r of n){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`)}s=new Set(n)}d===void 0&&(d=setTimeout(()=>{d=void 0,c.old=c.young,c.young=new Set},B),d.unref&&d.unref());let o=k();for(let n of L(t))try{if(s.has(n))continue;let r=await $({...e,port:n},o);for(;c.old.has(r)||c.young.has(r);){if(n!==0)throw new w(n);r=await $({...e,port:n},o)}return c.young.add(r),r}catch(r){if(!["EADDRINUSE","EACCES"].includes(r.code)&&!(r instanceof w))throw r}throw new Error("No available ports found")}import I from"node:fs/promises";import A from"node:os";import l from"node:path";import{dirname as q}from"node:path";import{fileURLToPath as O}from"node:url";import U from"puppeteer";import j from"node:os";var v=j.homedir();function u(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return v?e.replace(/^~(?=$|\/|\\)/,v):e}async function V(e){let t=D(),s=await h();return t.use(D.static(e)),new Promise((o,n)=>{let r=t.listen(s,()=>{o(r)});r.on("error",p=>{n(p)})})}async function _(e){return new Promise((t,s)=>{e.on("Browser.downloadProgress",o=>{o.state==="completed"?t(o.guid):o.state==="canceled"&&s(new Error("Download was canceled"))})})}async function G(e,t="svg",s="./",o=!1){let n=q(O(import.meta.url)),r=l.resolve(u(e));o&&console.log(`Loading tldr file "${r}"`);let p=await I.readFile(r,"utf8");o&&console.log("Starting tldraw server..."),console.log(`scriptDirectory: ${n}`);let y=l.join(n,n.endsWith("/src/lib")?"../../dist/tldraw":n.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");o&&console.log(`tldraw served from "${y}"`);let x=await V(y),{port:P}=x.address();o&&console.log(`tldraw hosted at "http://localhost:${P}"`),o&&console.log("Starting Puppeteer...");let E=await U.launch({headless:"new"}),a=await E.newPage();await a.setRequestInterception(!0),a.on("request",i=>{i.url().endsWith("favicon.ico")?i.respond({status:200}):i.continue()}),a.on("console",i=>{let f=i.type(),g=i.text();f==="error"?console.error(`[Browser] ${g}`):f==="warning"?console.warn(`[Browser] ${g}`):o&&console.log(`[Browser] ${g}`)});let S=await a.target().createCDPSession();await S.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:A.tmpdir(),eventsEnabled:!0}),await a.goto(`http://localhost:${P}`),await a.waitForFunction(()=>window.tldrawExportFile!==void 0),o&&console.log("Requesting download"),await a.evaluate((i,f)=>{window.tldrawExportFile(i,f)},p,t);let F=await _(S);o&&console.log("Download complete"),await E.close(),o&&console.log("Stopped Puppeteer");let T=l.basename(e,l.extname(e)),N=l.join(A.tmpdir(),F),m=u(l.join(s,`${T}.${t}`));return await I.rename(N,m),o&&console.log(`Saved to "${m}"`),x.close(),o&&console.log("Stopped tldraw server"),l.resolve(m)}export{G as tldrToImage};
1
+ import D from"express";import B from"node:net";import C from"node:os";var g=class extends Error{constructor(o){super(`${o} is locked`)}},d={old:new Set,young:new Set},k=1e3*15;var u,L=()=>{let e=C.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},$=e=>new Promise((o,r)=>{let t=B.createServer();t.unref(),t.on("error",r),t.listen(e,()=>{let{port:a}=t.address();t.close(()=>{o(a)})})}),b=async(e,o)=>{if(e.host||e.port===0)return $(e);for(let r of o)try{await $({port:e.port,host:r})}catch(t){if(!["EADDRNOTAVAIL","EINVAL"].includes(t.code))throw t}return e.port},j=function*(e){e&&(yield*e),yield 0};async function P(e){let o,r=new Set;if(e&&(e.port&&(o=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let a=e.exclude;if(typeof a[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let n of a){if(typeof n!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(n))throw new TypeError(`Number ${n} in the exclude option is not a safe integer and can't be used`)}r=new Set(a)}u===void 0&&(u=setTimeout(()=>{u=void 0,d.old=d.young,d.young=new Set},k),u.unref&&u.unref());let t=L();for(let a of j(o))try{if(r.has(a))continue;let n=await b({...e,port:a},t);for(;d.old.has(n)||d.young.has(n);){if(a!==0)throw new g(a);n=await b({...e,port:a},t)}return d.young.add(n),n}catch(n){if(!["EADDRINUSE","EACCES"].includes(n.code)&&!(n instanceof g))throw n}throw new Error("No available ports found")}import x from"node:fs/promises";import h from"node:os";import i from"node:path";import{dirname as G}from"node:path";import{fileURLToPath as M}from"node:url";import F from"puppeteer";import q from"node:os";var I=q.homedir();function m(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return I?e.replace(/^~(?=$|\/|\\)/,I):e}async function U(e,o="svg",r="./",t=!1){return e.startsWith("https://www.tldraw.com/")?(t&&console.log("tldraw URL detected"),V(e,o,r,t)):(t&&console.log("Local file detected"),_(e,o,r,t))}async function V(e,o,r,t){t&&console.log("Starting Puppeteer...");let n=await(await F.launch({headless:"new"})).newPage(),l=await n.target().createCDPSession();await l.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:h.tmpdir(),eventsEnabled:!0}),t&&console.log(`Navigating to: ${e}`),await n.goto(e,{waitUntil:"networkidle0"}),t&&console.log("Requesting download"),await W(n,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${o}`]);let w=await v(l);t&&console.log("Download complete");let p=i.join(h.tmpdir(),w),c=m(i.join(r,`${w}.${o}`));return await x.rename(p,c),t&&console.log(`Saved to "${c}"`),c}async function _(e,o,r,t){let a=G(M(import.meta.url)),n=i.resolve(m(e));t&&console.log(`Loading tldr file "${n}"`);let l=await x.readFile(n,"utf8");t&&console.log("Starting tldraw server...");let w=i.join(a,a.endsWith("/src/lib")?"../../dist/tldraw":a.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");t&&console.log(`tldraw served from "${w}"`);let p=await O(w),{port:c}=p.address();t&&console.log(`tldraw hosted at "http://localhost:${c}"`),t&&console.log("Starting Puppeteer...");let E=await F.launch({headless:"new"}),s=await E.newPage();await s.setRequestInterception(!0),s.on("request",f=>{f.url().endsWith("favicon.ico")?f.respond({status:200}):f.continue()}),H(s,t);let S=await s.target().createCDPSession();await S.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:h.tmpdir(),eventsEnabled:!0}),await s.goto(`http://localhost:${c}`),await s.waitForFunction(()=>window.tldrawExportFile!==void 0),t&&console.log("Requesting download"),await s.evaluate((f,R)=>{window.tldrawExportFile(f,R)},l,o);let T=await v(S);t&&console.log("Download complete"),await E.close(),t&&console.log("Stopped Puppeteer");let A=i.basename(e,i.extname(e)),N=i.join(h.tmpdir(),T),y=m(i.join(r,`${A}.${o}`));return await x.rename(N,y),t&&console.log(`Saved to "${y}"`),p.close(),t&&console.log("Stopped tldraw server"),i.resolve(y)}function H(e,o){e.on("console",r=>{let t=r.type(),a=r.text();t==="error"?console.error(`[Browser] ${a}`):t==="warning"?console.warn(`[Browser] ${a}`):o&&console.log(`[Browser] ${a}`)})}async function O(e){let o=D(),r=await P();return o.use(D.static(e)),new Promise((t,a)=>{let n=o.listen(r,()=>{t(n)});n.on("error",l=>{a(l)})})}async function v(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 W(e,o){for(let r of o)await e.waitForSelector(`[data-testid="${r}"]`),await e.click(`[data-testid="${r}"]`)}export{U as tldrawToImage};
@@ -0,0 +1,2 @@
1
+ import type { ExportFormat } from '../types';
2
+ export declare function tldrawToImage(tldrPathOrUrl: string, format?: ExportFormat, destination?: string, verbose?: boolean): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitschpatrol/tldraw-cli",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "description": "A tiny little CLI tool for converting tldraw .tldr files into svg or png images.",
6
6
  "repository": {
@@ -25,12 +25,9 @@
25
25
  "bin": {
26
26
  "tldraw-cli": "bin/cli.js"
27
27
  },
28
- "exports": {
29
- ".": {
30
- "import": "./dist/lib/index.js",
31
- "types": "./dist/lib/index.d.ts"
32
- }
33
- },
28
+ "main": "./dist/lib/index.js",
29
+ "module": "./dist/lib/index.js",
30
+ "types": "./dist/lib/index.d.ts",
34
31
  "files": [
35
32
  "bin/*",
36
33
  "dist/*"
@@ -81,6 +78,7 @@
81
78
  "build:tldraw": "pnpm run tldraw-copy-assets && vite build",
82
79
  "dev": "pnpm run tldraw-copy-assets && vite",
83
80
  "dev-cli": "pnpm run build:tldraw && tsx ./src/cli/tldraw-cli.ts ./test-assets/box.tldr --verbose",
81
+ "dev-cli-url": "pnpm run build && tsx ./src/cli/tldraw-cli.ts https://www.tldraw.com/s/v2_c_cQCtLu41OH97xkTl2Mt-9 --format png --verbose",
84
82
  "fix": "shared-config --fix",
85
83
  "lint": "shared-config --lint",
86
84
  "preview": "vite preview",
package/readme.md CHANGED
@@ -35,10 +35,12 @@ npm --install --global @kitschpatrol/tldraw-cli
35
35
  ### Invocation
36
36
 
37
37
  ```sh
38
- tldraw-cli file {options}
38
+ tldraw-cli fileOrUrl {options}
39
39
  ```
40
40
 
41
- ### Option flags
41
+ | Argument | Description |
42
+ | ----------- | ------------------------------------------------------------------------------------------------------ |
43
+ | `fileOrUrl` | The sketch to convert to an image — either a path to a local ".tldr" file, or a tldraw\.com sketch URL |
42
44
 
43
45
  | Option | Description | Default |
44
46
  | ----------------- | ------------------------------------------- | ------- |
@@ -48,55 +50,65 @@ tldraw-cli file {options}
48
50
  | `-v`, `--version` | Show version number | |
49
51
  | `--verbose` | Enable verbose output | `false` |
50
52
 
51
- ## API usage
53
+ ## Examples
52
54
 
53
- The conversion tool's functionality is also exposed as a module for use in TypeScript or JavaScript Node projects.
55
+ ### Basic .tldr file conversion
54
56
 
55
- The library exports a single async function, `tldrToImage` with the following type signature, mirroring the arguments available via the command line. The same default values apply:
57
+ To convert the file `your-drawing.tldr` to an svg named `your-drawing.svg` saved in the current working directory, run the following command. Note that the default output format is svg, and the default export location is the current working directory.
56
58
 
57
- ```ts
58
- tldrToImage(tldrPath: string, format?: ExportFormat, destination?: string, verbose?: boolean): Promise<string>;
59
+ ```sh
60
+ npx @kitschpatrol/tldraw-cli your-drawing.tldr
59
61
  ```
60
62
 
61
- The function exports the image in the requested format returns the full path to the output image.
63
+ ### Basic tldraw\.com image download
62
64
 
63
- Assuming you've installed `@kitschpatrol/tldraw-cli` locally in your project, it may be used as follows:
65
+ ```sh
66
+ npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4
67
+ ```
64
68
 
65
- ```ts
66
- // tldr-cli-api-test.ts
69
+ ### Export to a specific format
67
70
 
68
- import { tldrToImage } from '@kitschpatrol/tldraw-cli'
71
+ ```sh
72
+ npx @kitschpatrol/tldraw-cli your-drawing.tldr --format png
73
+ ```
69
74
 
70
- const imagePath = await tldrToImage('./some-file.tldr', 'png', './', false)
75
+ ### Export to a specific destination
71
76
 
72
- // Image saved to: "[...]/some-file.png"
73
- console.log(`Image saved to: "${imagePath}"`)
77
+ ```sh
78
+ npx @kitschpatrol/tldraw-cli your-drawing.tldr --output ~/Desktop
74
79
  ```
75
80
 
76
- _Note that the library provided is ESM only, and requires a Node-compatible runtime. TypeScript types are included._
77
-
78
- ## Examples
81
+ ## API usage
79
82
 
80
- ### Basic conversion
83
+ The conversion tool's functionality is also exposed as a module for use in TypeScript or JavaScript Node projects.
81
84
 
82
- To convert the file `your-drawing.tldr` to an svg named `your-drawing.svg` saved in the current working directory, run the following command. Note that the default output format is svg, and the default export location is the current working directory.
85
+ The library exports a single async function, `tldrawToImage` with the following type signature, mirroring the arguments available via the command line. The same default values apply:
83
86
 
84
- ```sh
85
- npx @kitschpatrol/tldraw-cli your-drawing.tldr
87
+ ```ts
88
+ tldrawToImage(tldrPathOrUrl: string, format?: ExportFormat, destination?: string, verbose?: boolean): Promise<string>;
86
89
  ```
87
90
 
88
- ### Export to a specific format
91
+ The function exports the image in the requested format returns the full path to the output image.
89
92
 
90
- ```sh
91
- npx @kitschpatrol/tldraw-cli your-drawing.tldr --format png
92
- ```
93
+ Assuming you've installed `@kitschpatrol/tldraw-cli` locally in your project, it may be used as follows:
93
94
 
94
- ### Export to a specific destination
95
+ ```ts
96
+ // tldr-cli-api-test.ts
95
97
 
96
- ```sh
97
- npx @kitschpatrol/tldraw-cli your-drawing.tldr --output ~/Desktop
98
+ import { tldrawToImage } from '@kitschpatrol/tldraw-cli'
99
+
100
+ // converting a local file
101
+ const imagePathFromLocal = await tldrawToImage('./some-file.tldr', 'png', './', false)
102
+
103
+ // Image saved to: "[...]/some-file.png"
104
+ console.log(`Image saved to: "${imagePathFromLocal}"`)
105
+
106
+ // Saving a remote tldraw url
107
+ await tldrawToImage('https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4')
98
108
  ```
99
109
 
110
+ _Note that the library provided is ESM only, and requires a Node-compatible runtime. TypeScript type definitions are included._
111
+
100
112
  ## Background
101
113
 
102
114
  The potential utility of a tldraw CLI app has received mention a few times.
@@ -105,6 +117,8 @@ On GitHub:
105
117
 
106
118
  - [\[Feature\]: CLI export application #1491](https://github.com/tldraw/tldraw/issues/1491)
107
119
  - [AWS Lambda-based approach](https://gist.github.com/steveruizok/c30fc99b9b3d95a14c82c59bdcc69201)
120
+ - [Added exporting of shapes and pages as images](https://github.com/tldraw/tldraw/pull/468)
121
+ - [\[feature\] Copy/Share as PNG](https://github.com/tldraw/tldraw-v1/issues/361)
108
122
 
109
123
  On Discord:
110
124
 
@@ -122,8 +136,9 @@ The local instance of tldraw includes its assets dependencies, so the tool shoul
122
136
  This is a very minimal implementation. Current plans for future improvements include the following:
123
137
 
124
138
  - Add automated tests
125
- - Implement the ability to export frames or pages as separate image files
139
+ - Implement the ability to export specific frames or pages as separate image files
126
140
  - Add an option flag to set dpi when exporting to a bitmap format
141
+ - Add option flag for transparent background
127
142
 
128
143
  Any other suggestions are welcome.
129
144
 
@@ -1,2 +0,0 @@
1
- import type { ExportFormat } from '../types';
2
- export declare function tldrToImage(tldrPath: string, format?: ExportFormat, destination?: string, verbose?: boolean): Promise<string>;