figlet-ts
Version:
Figlet command-line application, authored in Typescript
2 lines • 249 kB
JavaScript
#!/usr/bin/env node
import t from"events";import e from"child_process";import i,{win32 as s,posix as r}from"path";import*as n from"fs";import o,{lstatSync as a,readdir as h,readdirSync as u,readlinkSync as l,realpathSync as c}from"fs";import d from"process";import p from"tty";import D from"util";import g from"os";import f from"node:process";import m from"node:os";import C from"node:tty";import*as _ from"readline";import{fileURLToPath as F,pathToFileURL as E}from"url";import{lstat as b,readdir as S,readlink as w,realpath as y}from"fs/promises";import A from"stream";import v from"string_decoder";var L={},T={get exports(){return L},set exports(t){L=t}},O={},I={};let R=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}};I.CommanderError=R,I.InvalidArgumentError=class extends R{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:x}=I;O.Argument=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t}this._name.length>3&&"..."===this._name.slice(-3)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new x(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},O.humanReadableArgName=function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"};var k={},B={};const{humanReadableArgName:H}=O;B.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(t){const e=t.commands.filter((t=>!t._hidden));if(t._hasImplicitHelpCommand()){const[,i,s]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),r=t.createCommand(i).helpOption(!1);r.description(t._helpCommandDescription),s&&r.arguments(s),e.push(r)}return this.sortSubcommands&&e.sort(((t,e)=>t.name().localeCompare(e.name()))),e}compareOptions(t,e){const i=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){const e=t.options.filter((t=>!t.hidden)),i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag),s=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||s){let r;r=i?s?t.createOption(t._helpFlags,t._helpDescription):t.createOption(t._helpShortFlag,t._helpDescription):t.createOption(t._helpLongFlag,t._helpDescription),e.push(r)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const e=[];for(let i=t.parent;i;i=i.parent){const t=i.options.filter((t=>!t.hidden));e.push(...t)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t._args.forEach((e=>{e.description=e.description||t._argsDescription[e.name()]||""})),t._args.find((t=>t.description))?t._args:[]}subcommandTerm(t){const e=t._args.map((t=>H(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce(((t,i)=>Math.max(t,e.subcommandTerm(i).length)),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce(((t,i)=>Math.max(t,e.optionTerm(i).length)),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce(((t,i)=>Math.max(t,e.optionTerm(i).length)),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce(((t,i)=>Math.max(t,e.argumentTerm(i).length)),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let e=t.parent;e;e=e.parent)i=e.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`),void 0!==t.defaultValue){(t.required||t.optional||t.isBoolean()&&"boolean"==typeof t.defaultValue)&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}return void 0!==t.presetArg&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),void 0!==t.envVar&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`),void 0!==t.defaultValue&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){const i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,e){const i=e.padWidth(t,e),s=e.helpWidth||80,r=2,n=2;function o(t,o){if(o){const a=`${t.padEnd(i+n)}${o}`;return e.wrap(a,s-r,i+n)}return t}function a(t){return t.join("\n").replace(/^/gm," ".repeat(r))}let h=[`Usage: ${e.commandUsage(t)}`,""];const u=e.commandDescription(t);u.length>0&&(h=h.concat([e.wrap(u,s,0),""]));const l=e.visibleArguments(t).map((t=>o(e.argumentTerm(t),e.argumentDescription(t))));l.length>0&&(h=h.concat(["Arguments:",a(l),""]));const c=e.visibleOptions(t).map((t=>o(e.optionTerm(t),e.optionDescription(t))));if(c.length>0&&(h=h.concat(["Options:",a(c),""])),this.showGlobalOptions){const i=e.visibleGlobalOptions(t).map((t=>o(e.optionTerm(t),e.optionDescription(t))));i.length>0&&(h=h.concat(["Global Options:",a(i),""]))}const d=e.visibleCommands(t).map((t=>o(e.subcommandTerm(t),e.subcommandDescription(t))));return d.length>0&&(h=h.concat(["Commands:",a(d),""])),h.join("\n")}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,i,s=40){const r=new RegExp("[\\n][ \\f\\t\\v - \ufeff]+");if(t.match(r))return t;const n=e-i;if(n<s)return t;const o=t.slice(0,i),a=t.slice(i).replace("\r\n","\n"),h=" ".repeat(i),u="\\s",l=new RegExp(`\n|.{1,${n-1}}([${u}]|$)|[^${u}]+?([${u}]|$)`,"g");return o+(a.match(l)||[]).map(((t,e)=>"\n"===t?"":(e>0?h:"")+t.trimEnd())).join("\n")}};var M={};const{InvalidArgumentError:N}=I;function P(t){let e,i;const s=t.split(/[ |,]+/);return s.length>1&&!/^[[<]/.test(s[1])&&(e=s.shift()),i=s.shift(),!e&&/^-[^-]$/.test(i)&&(e=i,i=void 0),{shortFlag:e,longFlag:i}}M.Option=class{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;const i=P(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){return this.implied=Object.assign(this.implied||{},t),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new N(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce(((t,e)=>t+e[0].toUpperCase()+e.slice(1)))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},M.splitOptionFlags=P,M.DualOptions=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach((t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)})),this.negativeOptions.forEach(((t,e)=>{this.positiveOptions.has(e)&&this.dualOptions.add(e)}))}valueFromOption(t,e){const i=e.attributeName();if(!this.dualOptions.has(i))return!0;const s=this.negativeOptions.get(i).presetArg,r=void 0!==s&&s;return e.negate===(r===t)}};var z={};const G=3;z.suggestSimilar=function(t,e){if(!e||0===e.length)return"";e=Array.from(new Set(e));const i=t.startsWith("--");i&&(t=t.slice(2),e=e.map((t=>t.slice(2))));let s=[],r=G;return e.forEach((e=>{if(e.length<=1)return;const i=function(t,e){if(Math.abs(t.length-e.length)>G)return Math.max(t.length,e.length);const i=[];for(let e=0;e<=t.length;e++)i[e]=[e];for(let t=0;t<=e.length;t++)i[0][t]=t;for(let s=1;s<=e.length;s++)for(let r=1;r<=t.length;r++){let n=1;n=t[r-1]===e[s-1]?0:1,i[r][s]=Math.min(i[r-1][s]+1,i[r][s-1]+1,i[r-1][s-1]+n),r>1&&s>1&&t[r-1]===e[s-2]&&t[r-2]===e[s-1]&&(i[r][s]=Math.min(i[r][s],i[r-2][s-2]+1))}return i[t.length][e.length]}(t,e),n=Math.max(t.length,e.length);(n-i)/n>.4&&(i<r?(r=i,s=[e]):i===r&&s.push(e))})),s.sort(((t,e)=>t.localeCompare(e))),i&&(s=s.map((t=>`--${t}`))),s.length>1?`\n(Did you mean one of ${s.join(", ")}?)`:1===s.length?`\n(Did you mean ${s[0]}?)`:""};const $=t.EventEmitter,W=e,V=i,U=o,j=d,{Argument:q,humanReadableArgName:K}=O,{CommanderError:Y}=I,{Help:Z}=B,{Option:X,splitOptionFlags:J,DualOptions:Q}=M,{suggestSimilar:tt}=z;function et(t,e){t._hasHelpOption&&e.find((e=>e===t._helpLongFlag||e===t._helpShortFlag))&&(t.outputHelp(),t._exit(0,"commander.helpDisplayed","(outputHelp)"))}function it(t){return t.map((t=>{if(!t.startsWith("--inspect"))return t;let e,i,s="127.0.0.1",r="9229";return null!==(i=t.match(/^(--inspect(-brk)?)$/))?e=i[1]:null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(e=i[1],/^\d+$/.test(i[3])?r=i[3]:s=i[3]):null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=i[1],s=i[3],r=i[4]),e&&"0"!==r?`${e}=${s}:${parseInt(r)+1}`:t}))}function st(t){const e=[];for(let i=t;i;i=i.parent)e.push(i);return e}k.Command=class t extends ${constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this._args=[],this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>j.stdout.write(t),writeErr:t=>j.stderr.write(t),getOutHelpWidth:()=>j.stdout.isTTY?j.stdout.columns:void 0,getErrHelpWidth:()=>j.stderr.isTTY?j.stderr.columns:void 0,outputError:(t,e)=>e(t)},this._hidden=!1,this._hasHelpOption=!0,this._helpFlags="-h, --help",this._helpDescription="display help for command",this._helpShortFlag="-h",this._helpLongFlag="--help",this._addImplicitHelpCommand=void 0,this._helpCommandName="help",this._helpCommandnameAndArgs="help [command]",this._helpCommandDescription="display help for command",this._helpConfiguration={}}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._hasHelpOption=t._hasHelpOption,this._helpFlags=t._helpFlags,this._helpDescription=t._helpDescription,this._helpShortFlag=t._helpShortFlag,this._helpLongFlag=t._helpLongFlag,this._helpCommandName=t._helpCommandName,this._helpCommandnameAndArgs=t._helpCommandnameAndArgs,this._helpCommandDescription=t._helpCommandDescription,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}command(t,e,i){let s=e,r=i;"object"==typeof s&&null!==s&&(r=s,s=null),r=r||{};const[,n,o]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(n);return s&&(a.description(s),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!r.noHelp&&!r.hidden),a._executableFile=r.executableFile||null,o&&a.arguments(o),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),s?this:a}createCommand(e){return new t(e)}createHelp(){return Object.assign(new Z,this.configureHelp())}configureHelp(t){return void 0===t?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return void 0===t?this._outputConfiguration:(Object.assign(this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return"string"!=typeof t&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this.commands.push(t),t.parent=this,this}createArgument(t,e){return new q(t,e)}argument(t,e,i,s){const r=this.createArgument(t,e);return"function"==typeof i?r.default(s).argParser(i):r.default(i),this.addArgument(r),this}arguments(t){return t.split(/ +/).forEach((t=>{this.argument(t)})),this}addArgument(t){const e=this._args.slice(-1)[0];if(e&&e.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&void 0!==t.defaultValue&&void 0===t.parseArg)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this._args.push(t),this}addHelpCommand(t,e){return!1===t?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,"string"==typeof t&&(this._helpCommandName=t.split(" ")[0],this._helpCommandnameAndArgs=t),this._helpCommandDescription=e||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return void 0===this._addImplicitHelpCommand?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(t,e){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return this._exitCallback=t||(t=>{if("commander.executeSubCommandAsync"!==t.code)throw t}),this}_exit(t,e,i){this._exitCallback&&this._exitCallback(new Y(t,e,i)),j.exit(t)}action(t){return this._actionHandler=e=>{const i=this._args.length,s=e.slice(0,i);return this._storeOptionsAsProperties?s[i]=this:s[i]=this.opts(),s.push(this),t.apply(this,s)},this}createOption(t,e){return new X(t,e)}addOption(t){const e=t.name(),i=t.attributeName();if(t.negate){const e=t.long.replace(/^--no-/,"--");this._findOption(e)||this.setOptionValueWithSource(i,void 0===t.defaultValue||t.defaultValue,"default")}else void 0!==t.defaultValue&&this.setOptionValueWithSource(i,t.defaultValue,"default");this.options.push(t);const s=(e,s,r)=>{null==e&&void 0!==t.presetArg&&(e=t.presetArg);const n=this.getOptionValue(i);if(null!==e&&t.parseArg)try{e=t.parseArg(e,n)}catch(t){if("commander.invalidArgument"===t.code){const e=`${s} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}else null!==e&&t.variadic&&(e=t._concatValue(e,n));null==e&&(e=!t.negate&&(!(!t.isBoolean()&&!t.optional)||"")),this.setOptionValueWithSource(i,e,r)};return this.on("option:"+e,(e=>{const i=`error: option '${t.flags}' argument '${e}' is invalid.`;s(e,i,"cli")})),t.envVar&&this.on("optionEnv:"+e,(e=>{const i=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;s(e,i,"env")})),this}_optionEx(t,e,i,s,r){if("object"==typeof e&&e instanceof X)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const n=this.createOption(e,i);if(n.makeOptionMandatory(!!t.mandatory),"function"==typeof s)n.default(r).argParser(s);else if(s instanceof RegExp){const t=s;s=(e,i)=>{const s=t.exec(e);return s?s[0]:i},n.default(r).argParser(s)}else n.default(s);return this.addOption(n)}option(t,e,i,s){return this._optionEx({},t,e,i,s)}requiredOption(t,e,i,s){return this._optionEx({mandatory:!0},t,e,i,s)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){if(this._passThroughOptions=!!t,this.parent&&t&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(t=!0){if(this._storeOptionsAsProperties=!!t,this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,i){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return st(this).forEach((i=>{void 0!==i.getOptionValueSource(t)&&(e=i.getOptionValueSource(t))})),e}_prepareUserArgs(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");let i;switch(e=e||{},void 0===t&&(t=j.argv,j.versions&&j.versions.electron&&(e.from="electron")),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":j.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,e){const i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){const i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),this}_executeSubCommand(t,e){e=e.slice();let i=!1;const s=[".js",".ts",".tsx",".mjs",".cjs"];function r(t,e){const i=V.resolve(t,e);if(U.existsSync(i))return i;if(s.includes(V.extname(e)))return;const r=s.find((t=>U.existsSync(`${i}${t}`)));return r?`${i}${r}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n,o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let t;try{t=U.realpathSync(this._scriptPath)}catch(e){t=this._scriptPath}a=V.resolve(V.dirname(t),a)}if(a){let e=r(a,o);if(!e&&!t._executableFile&&this._scriptPath){const i=V.basename(this._scriptPath,V.extname(this._scriptPath));i!==this._name&&(e=r(a,`${i}-${t._name}`))}o=e||o}if(i=s.includes(V.extname(o)),"win32"!==j.platform?i?(e.unshift(o),e=it(j.execArgv).concat(e),n=W.spawn(j.argv[0],e,{stdio:"inherit"})):n=W.spawn(o,e,{stdio:"inherit"}):(e.unshift(o),e=it(j.execArgv).concat(e),n=W.spawn(j.execPath,e,{stdio:"inherit"})),!n.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((t=>{j.on(t,(()=>{!1===n.killed&&null===n.exitCode&&n.kill(t)}))}))}const h=this._exitCallback;h?n.on("close",(()=>{h(new Y(j.exitCode||0,"commander.executeSubCommandAsync","(close)"))})):n.on("close",j.exit.bind(j)),n.on("error",(e=>{if("ENOENT"===e.code){const e=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${o}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${e}`;throw new Error(i)}if("EACCES"===e.code)throw new Error(`'${o}' not executable`);if(h){const t=new Y(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,h(t)}else j.exit(1)})),this.runningCommand=n}_dispatchSubcommand(t,e,i){const s=this._findCommand(t);let r;return s||this.help({error:!0}),r=this._chainOrCallSubCommandHook(r,s,"preSubcommand"),r=this._chainOrCall(r,(()=>{if(!s._executableHandler)return s._parseCommand(e,i);this._executeSubCommand(s,e.concat(i))})),r}_checkNumberOfArguments(){this._args.forEach(((t,e)=>{t.required&&null==this.args[e]&&this.missingArgument(t.name())})),this._args.length>0&&this._args[this._args.length-1].variadic||this.args.length>this._args.length&&this._excessArguments(this.args)}_processArguments(){const t=(t,e,i)=>{let s=e;if(null!==e&&t.parseArg)try{s=t.parseArg(e,i)}catch(i){if("commander.invalidArgument"===i.code){const s=`error: command-argument value '${e}' is invalid for argument '${t.name()}'. ${i.message}`;this.error(s,{exitCode:i.exitCode,code:i.code})}throw i}return s};this._checkNumberOfArguments();const e=[];this._args.forEach(((i,s)=>{let r=i.defaultValue;i.variadic?s<this.args.length?(r=this.args.slice(s),i.parseArg&&(r=r.reduce(((e,s)=>t(i,s,e)),i.defaultValue))):void 0===r&&(r=[]):s<this.args.length&&(r=this.args[s],i.parseArg&&(r=t(i,r,i.defaultValue))),e[s]=r})),this.processedArgs=e}_chainOrCall(t,e){return t&&t.then&&"function"==typeof t.then?t.then((()=>e())):e()}_chainOrCallHooks(t,e){let i=t;const s=[];return st(this).reverse().filter((t=>void 0!==t._lifeCycleHooks[e])).forEach((t=>{t._lifeCycleHooks[e].forEach((e=>{s.push({hookedCommand:t,callback:e})}))})),"postAction"===e&&s.reverse(),s.forEach((t=>{i=this._chainOrCall(i,(()=>t.callback(t.hookedCommand,this)))})),i}_chainOrCallSubCommandHook(t,e,i){let s=t;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach((t=>{s=this._chainOrCall(s,(()=>t(this,e)))})),s}_parseCommand(t,e){const i=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),e=i.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName)return 1===t.length&&this.help(),this._dispatchSubcommand(t[1],[],[this._helpLongFlag]);if(this._defaultCommandName)return et(this,e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),et(this,i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const s=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){let i;return s(),this._processArguments(),i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs))),this.parent&&(i=this._chainOrCall(i,(()=>{this.parent.emit(r,t,e)}))),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(r))s(),this._processArguments(),this.parent.emit(r,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(s(),this._processArguments())}else this.commands.length?(s(),this.help({error:!0})):(s(),this._processArguments())}_findCommand(t){if(t)return this.commands.find((e=>e._name===t||e._aliases.includes(t)))}_findOption(t){return this.options.find((e=>e.is(t)))}_checkForMissingMandatoryOptions(){for(let t=this;t;t=t.parent)t.options.forEach((e=>{e.mandatory&&void 0===t.getOptionValue(e.attributeName())&&t.missingMandatoryOptionValue(e)}))}_checkForConflictingLocalOptions(){const t=this.options.filter((t=>{const e=t.attributeName();return void 0!==this.getOptionValue(e)&&"default"!==this.getOptionValueSource(e)})),e=t.filter((t=>t.conflictsWith.length>0));e.forEach((e=>{const i=t.find((t=>e.conflictsWith.includes(t.attributeName())));i&&this._conflictingOption(e,i)}))}_checkForConflictingOptions(){for(let t=this;t;t=t.parent)t._checkForConflictingLocalOptions()}parseOptions(t){const e=[],i=[];let s=e;const r=t.slice();function n(t){return t.length>1&&"-"===t[0]}let o=null;for(;r.length;){const t=r.shift();if("--"===t){s===i&&s.push(t),s.push(...r);break}if(!o||n(t)){if(o=null,n(t)){const e=this._findOption(t);if(e){if(e.required){const t=r.shift();void 0===t&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;r.length>0&&!n(r[0])&&(t=r.shift()),this.emit(`option:${e.name()}`,t)}else this.emit(`option:${e.name()}`);o=e.variadic?e:null;continue}}if(t.length>2&&"-"===t[0]&&"-"!==t[1]){const e=this._findOption(`-${t[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,t.slice(2)):(this.emit(`option:${e.name()}`),r.unshift(`-${t.slice(2)}`));continue}}if(/^--[^=]+=/.test(t)){const e=t.indexOf("="),i=this._findOption(t.slice(0,e));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(e+1));continue}}if(n(t)&&(s=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===i.length){if(this._findCommand(t)){e.push(t),r.length>0&&i.push(...r);break}if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){e.push(t),r.length>0&&e.push(...r);break}if(this._defaultCommandName){i.push(t),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){s.push(t),r.length>0&&s.push(...r);break}s.push(t)}else this.emit(`option:${o.name()}`,t)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={},e=this.options.length;for(let i=0;i<e;i++){const e=this.options[i].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}optsWithGlobals(){return st(this).reduce(((t,e)=>Object.assign(t,e.opts())),{})}error(t,e){this._outputConfiguration.outputError(`${t}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0}));const i=e||{},s=i.exitCode||1,r=i.code||"commander.error";this._exit(s,r,t)}_parseOptionsEnv(){this.options.forEach((t=>{if(t.envVar&&t.envVar in j.env){const e=t.attributeName();(void 0===this.getOptionValue(e)||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,j.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}}))}_parseOptionsImplied(){const t=new Q(this.options),e=t=>void 0!==this.getOptionValue(t)&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter((i=>void 0!==i.implied&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i))).forEach((t=>{Object.keys(t.implied).filter((t=>!e(t))).forEach((e=>{this.setOptionValueWithSource(e,t.implied[e],"implied")}))}))}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const i=t=>{const e=t.attributeName(),i=this.getOptionValue(e),s=this.options.find((t=>t.negate&&e===t.attributeName())),r=this.options.find((t=>!t.negate&&e===t.attributeName()));return s&&(void 0===s.presetArg&&!1===i||void 0!==s.presetArg&&i===s.presetArg)?s:r||t},s=t=>{const e=i(t),s=e.attributeName();return"env"===this.getOptionValueSource(s)?`environment variable '${e.envVar}'`:`option '${e.flags}'`},r=`error: ${s(t)} cannot be used with ${s(e)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[],s=this;do{const t=s.createHelp().visibleOptions(s).filter((t=>t.long)).map((t=>t.long));i=i.concat(t),s=s.parent}while(s&&!s._enablePositionalOptions);e=tt(t,i)}const i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this._args.length,i=1===e?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${i} but got ${t.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((t=>{i.push(t.name()),t.alias()&&i.push(t.alias())})),e=tt(t,i)}const i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(void 0===t)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";const s=this.createOption(e,i);return this._versionOptionName=s.attributeName(),this.options.push(s),this.on("option:"+s.name(),(()=>{this._outputConfiguration.writeOut(`${t}\n`),this._exit(0,"commander.version",t)})),this}description(t,e){return void 0===t&&void 0===e?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return void 0===t?this._summary:(this._summary=t,this)}alias(t){if(void 0===t)return this._aliases[0];let e=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");return e._aliases.push(t),this}aliases(t){return void 0===t?this._aliases:(t.forEach((t=>this.alias(t))),this)}usage(t){if(void 0===t){if(this._usage)return this._usage;const t=this._args.map((t=>K(t)));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?t:[]).join(" ")}return this._usage=t,this}name(t){return void 0===t?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=V.basename(t,V.extname(t)),this}executableDir(t){return void 0===t?this._executableDir:(this._executableDir=t,this)}helpInformation(t){const e=this.createHelp();return void 0===e.helpWidth&&(e.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),e.formatHelp(this,e)}_getHelpContext(t){const e={error:!!(t=t||{}).error};let i;return i=e.error?t=>this._outputConfiguration.writeErr(t):t=>this._outputConfiguration.writeOut(t),e.write=t.write||i,e.command=this,e}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const i=this._getHelpContext(t);st(this).reverse().forEach((t=>t.emit("beforeAllHelp",i))),this.emit("beforeHelp",i);let s=this.helpInformation(i);if(e&&(s=e(s),"string"!=typeof s&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(s),this.emit(this._helpLongFlag),this.emit("afterHelp",i),st(this).forEach((t=>t.emit("afterAllHelp",i)))}helpOption(t,e){if("boolean"==typeof t)return this._hasHelpOption=t,this;this._helpFlags=t||this._helpFlags,this._helpDescription=e||this._helpDescription;const i=J(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(t){this.outputHelp(t);let e=j.exitCode||0;0===e&&t&&"function"!=typeof t&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const s=`${t}Help`;return this.on(s,(t=>{let i;i="function"==typeof e?e({error:t.error,command:t.command}):e,i&&t.write(`${i}\n`)})),this}},function(t,e){const{Argument:i}=O,{Command:s}=k,{CommanderError:r,InvalidArgumentError:n}=I,{Help:o}=B,{Option:a}=M;(e=t.exports=new s).program=e,e.Argument=i,e.Command=s,e.CommanderError=r,e.Help=o,e.InvalidArgumentError=n,e.InvalidOptionArgumentError=n,e.Option=a}(T,L);var rt=L;const{program:nt,createCommand:ot,createArgument:at,createOption:ht,CommanderError:ut,InvalidArgumentError:lt,InvalidOptionArgumentError:ct,Command:dt,Argument:pt,Option:Dt,Help:gt}=rt;var ft,mt,Ct,_t,Ft;!function(t){t[t.HORIZONTAL_EQUAL_CHARACTER_SMUSHING=1]="HORIZONTAL_EQUAL_CHARACTER_SMUSHING",t[t.HORIZONTAL_UNDERSCORE_SMUSHING=2]="HORIZONTAL_UNDERSCORE_SMUSHING",t[t.HORIZONTAL_HIERARCHY_SMUSHING=4]="HORIZONTAL_HIERARCHY_SMUSHING",t[t.HORIZONTAL_OPPOSITE_PAIR_SMUSHING=8]="HORIZONTAL_OPPOSITE_PAIR_SMUSHING",t[t.HORIZONTAL_BIG_X_SMUSHING=16]="HORIZONTAL_BIG_X_SMUSHING",t[t.HORIZONTAL_HARDBLANK_SMUSHING=32]="HORIZONTAL_HARDBLANK_SMUSHING",t[t.HORIZONTAL_KERNING=64]="HORIZONTAL_KERNING",t[t.HORIZONTAL_SMUSHING=128]="HORIZONTAL_SMUSHING",t[t.VERTICAL_EQUAL_CHARACTER_SMUSHING=256]="VERTICAL_EQUAL_CHARACTER_SMUSHING",t[t.VERTICAL_UNDERSCORE_SMUSHING=512]="VERTICAL_UNDERSCORE_SMUSHING",t[t.VERTICAL_HIERARCHY_SMUSHING=1024]="VERTICAL_HIERARCHY_SMUSHING",t[t.VERTICAL_HORIZONTAL_LINE_SMUSHING=2048]="VERTICAL_HORIZONTAL_LINE_SMUSHING",t[t.VERTICAL_VERTICAL_LINE_SUPERSMUSHING=4096]="VERTICAL_VERTICAL_LINE_SUPERSMUSHING",t[t.VERTICAL_KERNING=8192]="VERTICAL_KERNING",t[t.VERTICAL_SMUSHING=16384]="VERTICAL_SMUSHING"}(ft||(ft={})),function(t){t[t.LEFT_TO_RIGHT=0]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=1]="RIGHT_TO_LEFT"}(mt||(mt={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.FLF_MANDATORY=1]="FLF_MANDATORY",t[t.FLF_CODE_TAGGED=2]="FLF_CODE_TAGGED",t[t.GENERATED_BLANK=3]="GENERATED_BLANK"}(Ct||(Ct={}));class Et extends Error{message;constructor(t){super(t),this.message=t}}class bt extends Et{constructor(t){super(`${t} is not allowed as the hardblank character in a font`)}}class St{static FIGLET_TS_LEFT_PADDING_MARKER=-20171228;static FIGLET_TS_RIGHT_PADDING_MARKER=-20221119;static FIGLET_TS_SINGLE_WIDTH_WHITESPACE=-19760908;static ASCII_NULL=0;static ASCII_LINE_FEED=10;static ASCII_CARRIAGE_RETURN=13;static ASCII_SPACE=32;static ASCII_OPEN_PARENTHESIS=40;static ASCII_CLOSED_PARENTHESIS=41;static ASCII_FORWARD_SLASH=47;static ASCII_LESS_THAN=60;static ASCII_GREATER_THAN=62;static ASCII_OPEN_BRACKET=91;static ASCII_BACKWARD_SLASH=92;static ASCII_CLOSED_BRACKET=93;static ASCII_UNDERSCORE=95;static ASCII_OPEN_BRACE=123;static ASCII_PIPE=124;static ASCII_CLOSED_BRACE=125}class wt{_topDownDistances;_bottomUpDistances;_leftToRightDistances;_rightToLeftDistances;_topDownCharacters;_bottomUpCharacters;_leftToRightCharacters;_rightToLeftCharacters;constructor(t){const e=t[0].length,i=t.length;this._topDownDistances=Array(e).fill(1/0),this._bottomUpDistances=Array(e).fill(1/0),this._leftToRightDistances=Array(i).fill(1/0),this._rightToLeftDistances=Array(i).fill(1/0),this._topDownCharacters=Array(e).fill(St.ASCII_SPACE),this._bottomUpCharacters=Array(e).fill(St.ASCII_SPACE),this._leftToRightCharacters=Array(i).fill(St.ASCII_SPACE),this._rightToLeftCharacters=Array(i).fill(St.ASCII_SPACE);for(let s=0;s<e;s++)for(let r=0;r<i;r++){const n=t[r][s];n!==St.ASCII_SPACE&&this._topDownDistances[s]==1/0&&(this._topDownDistances[s]=r,this._topDownCharacters[s]=n),n!==St.ASCII_SPACE&&(this._bottomUpDistances[s]=i-r-1,this._bottomUpCharacters[s]=n),n!==St.ASCII_SPACE&&this._leftToRightDistances[r]==1/0&&(this._leftToRightDistances[r]=s,this._leftToRightCharacters[r]=n),n!==St.ASCII_SPACE&&(this._rightToLeftDistances[r]=e-s-1,this._rightToLeftCharacters[r]=n)}}get topDownDistances(){return this._topDownDistances}get bottomUpDistances(){return this._bottomUpDistances}get leftToRightDistances(){return this._leftToRightDistances}get rightToLeftDistances(){return this._rightToLeftDistances}get topDownCharacters(){return this._topDownCharacters}get bottomUpCharacters(){return this._bottomUpCharacters}get leftToRightCharacters(){return this._leftToRightCharacters}get rightToLeftCharacters(){return this._rightToLeftCharacters}}class yt{_hardblankCharacter=0;_width=0;_height=0;_characterCode;_comment;_glyph=[];_isEmptyGlyph=!1;_glyphType=Ct.UNKNOWN;_paddingInfo;static fromRequiredFIGCharacterString(t,e,i){return i=i.replaceAll("\r",""),new yt(t,`Required ASCII character code ${t} / "${String.fromCharCode(t)}"`,e,i,Ct.FLF_MANDATORY)}static fromCodeTaggedFIGCharacterString(t,e,i=Ct.FLF_CODE_TAGGED){const s=(e=e.replaceAll("\r","")).split("\n");if(s.length<2)throw new Et("Code tagged character has insufficient glyph lines");const r=s[0];s.shift();const n=yt.parseCodeTagLine(r);return new yt(n[0],n[1],t,s.join("\n"),i)}static parseCodeTagLine(t){const e=t.split(" "),i=e[0].toLowerCase();e.shift();const s=e?.join(" ").trim()||"";let r;if(r=i.startsWith("0x")||i.startsWith("-0x")?parseInt(i,16):i.startsWith("0")||i.startsWith("-0")?parseInt(i,8):parseInt(i),isNaN(r))throw new Et(`Cannot parse code tag line "${t}" as hexadecimal, octal nor decimal value`);return[r,s]}constructor(t,e,i,s,r){this._characterCode=t,this._comment=e,this._hardblankCharacter=i,this.parseFIGCharacterString(s),this._glyphType=r}parseFIGCharacterString(t){const e=(t=t.replaceAll("\r","")).split("\n");if(0===e.length||0===e[0].length)throw new Et("Character glyph has zero content");this._height=e.length,this._width=-1;const i=e[0][e[0].length-1];if(e.every((t=>t==i||t==i+i))){this._width=0;for(let t=0;t<e.length;t++)this._glyph[t]=[];this._isEmptyGlyph=!0}else{let t=0;for(const s of e){const e=s.indexOf(i);if(-1===e)throw new Et(`Character line was not terminated with character ${i}`);const r=s.substring(0,e).split("").map((t=>t.charCodeAt(0)));this._glyph.push(r),t=Math.max(t,r.length)}this._width=t;for(let e=0;e<this._glyph.length;e++)this._glyph[e].length<t&&(this._glyph[e]=Object.assign(new Array(t).fill(St.ASCII_SPACE),this._glyph[e]))}this._paddingInfo=new wt(this._glyph)}get hardblankCharacter(){return this._hardblankCharacter}get characterCode(){return this._characterCode}get character(){return String.fromCharCode(this._characterCode)}get height(){return this._height}get width(){return this._width}get comment(){return this._comment}getGlyph(){return this._glyph}getGlyphLine(t){return this._glyph[t]}get paddingInfo(){return this._paddingInfo}get isEmptyGlyph(){return this._isEmptyGlyph}get glyphType(){return this._glyphType}getTotalMaxHorizontalSmushDistance(t){return t===mt.RIGHT_TO_LEFT?Math.min(...this._paddingInfo.rightToLeftDistances):Math.min(...this._paddingInfo.leftToRightDistances)}}!function(t){t[t.FONT_DEFAULT=0]="FONT_DEFAULT",t[t.LEFT_ALIGN=1]="LEFT_ALIGN",t[t.RIGHT_ALIGN=2]="RIGHT_ALIGN",t[t.CENTRE_ALIGN=3]="CENTRE_ALIGN"}(_t||(_t={})),function(t){t[t.DEFAULT=0]="DEFAULT",t[t.FULL_PADDING=1]="FULL_PADDING",t[t.NO_PADDING=2]="NO_PADDING",t[t.NO_LEFT_PADDING=3]="NO_LEFT_PADDING",t[t.NO_RIGHT_PADDING=4]="NO_RIGHT_PADDING"}(Ft||(Ft={}));class At{_driverOptions;constructor(t){this._driverOptions=t}useFontDefaultAlignment(){this._driverOptions._renderingAlignment=_t.FONT_DEFAULT}left(){this._driverOptions._renderingAlignment=_t.LEFT_ALIGN}centre(){this._driverOptions._renderingAlignment=_t.CENTRE_ALIGN}right(){this._driverOptions._renderingAlignment=_t.RIGHT_ALIGN}}function vt(t){if("string"!=typeof t)throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(function({onlyFirst:t=!1}={}){const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}(),"")}function Lt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Tt={},Ot={get exports(){return Tt},set exports(t){Tt=t}};!function(t){var e={};function i(t){return t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}Ot.exports=e,e.eastAsianWidth=function(t){var e=t.charCodeAt(0),i=2==t.length?t.charCodeAt(1):0,s=e;return 55296<=e&&e<=56319&&56320<=i&&i<=57343&&(s=(e&=1023)<<10|(i&=1023),s+=65536),12288==s||65281<=s&&s<=65376||65504<=s&&s<=65510?"F":8361==s||65377<=s&&s<=65470||65474<=s&&s<=65479||65482<=s&&s<=65487||65490<=s&&s<=65495||65498<=s&&s<=65500||65512<=s&&s<=65518?"H":4352<=s&&s<=4447||4515<=s&&s<=4519||4602<=s&&s<=4607||9001<=s&&s<=9002||11904<=s&&s<=11929||11931<=s&&s<=12019||12032<=s&&s<=12245||12272<=s&&s<=12283||12289<=s&&s<=12350||12353<=s&&s<=12438||12441<=s&&s<=12543||12549<=s&&s<=12589||12593<=s&&s<=12686||12688<=s&&s<=12730||12736<=s&&s<=12771||12784<=s&&s<=12830||12832<=s&&s<=12871||12880<=s&&s<=13054||13056<=s&&s<=19903||19968<=s&&s<=42124||42128<=s&&s<=42182||43360<=s&&s<=43388||44032<=s&&s<=55203||55216<=s&&s<=55238||55243<=s&&s<=55291||63744<=s&&s<=64255||65040<=s&&s<=65049||65072<=s&&s<=65106||65108<=s&&s<=65126||65128<=s&&s<=65131||110592<=s&&s<=110593||127488<=s&&s<=127490||127504<=s&&s<=127546||127552<=s&&s<=127560||127568<=s&&s<=127569||131072<=s&&s<=194367||177984<=s&&s<=196605||196608<=s&&s<=262141?"W":32<=s&&s<=126||162<=s&&s<=163||165<=s&&s<=166||172==s||175==s||10214<=s&&s<=10221||10629<=s&&s<=10630?"Na":161==s||164==s||167<=s&&s<=168||170==s||173<=s&&s<=174||176<=s&&s<=180||182<=s&&s<=186||188<=s&&s<=191||198==s||208==s||215<=s&&s<=216||222<=s&&s<=225||230==s||232<=s&&s<=234||236<=s&&s<=237||240==s||242<=s&&s<=243||247<=s&&s<=250||252==s||254==s||257==s||273==s||275==s||283==s||294<=s&&s<=295||299==s||305<=s&&s<=307||312==s||319<=s&&s<=322||324==s||328<=s&&s<=331||333==s||338<=s&&s<=339||358<=s&&s<=359||363==s||462==s||464==s||466==s||468==s||470==s||472==s||474==s||476==s||593==s||609==s||708==s||711==s||713<=s&&s<=715||717==s||720==s||728<=s&&s<=731||733==s||735==s||768<=s&&s<=879||913<=s&&s<=929||931<=s&&s<=937||945<=s&&s<=961||963<=s&&s<=969||1025==s||1040<=s&&s<=1103||1105==s||8208==s||8211<=s&&s<=8214||8216<=s&&s<=8217||8220<=s&&s<=8221||8224<=s&&s<=8226||8228<=s&&s<=8231||8240==s||8242<=s&&s<=8243||8245==s||8251==s||8254==s||8308==s||8319==s||8321<=s&&s<=8324||8364==s||8451==s||8453==s||8457==s||8467==s||8470==s||8481<=s&&s<=8482||8486==s||8491==s||8531<=s&&s<=8532||8539<=s&&s<=8542||8544<=s&&s<=8555||8560<=s&&s<=8569||8585==s||8592<=s&&s<=8601||8632<=s&&s<=8633||8658==s||8660==s||8679==s||8704==s||8706<=s&&s<=8707||8711<=s&&s<=8712||8715==s||8719==s||8721==s||8725==s||8730==s||8733<=s&&s<=8736||8739==s||8741==s||8743<=s&&s<=8748||8750==s||8756<=s&&s<=8759||8764<=s&&s<=8765||8776==s||8780==s||8786==s||8800<=s&&s<=8801||8804<=s&&s<=8807||8810<=s&&s<=8811||8814<=s&&s<=8815||8834<=s&&s<=8835||8838<=s&&s<=8839||8853==s||8857==s||8869==s||8895==s||8978==s||9312<=s&&s<=9449||9451<=s&&s<=9547||9552<=s&&s<=9587||9600<=s&&s<=9615||9618<=s&&s<=9621||9632<=s&&s<=9633||9635<=s&&s<=9641||9650<=s&&s<=9651||9654<=s&&s<=9655||9660<=s&&s<=9661||9664<=s&&s<=9665||9670<=s&&s<=9672||9675==s||9678<=s&&s<=9681||9698<=s&&s<=9701||9711==s||9733<=s&&s<=9734||9737==s||9742<=s&&s<=9743||9748<=s&&s<=9749||9756==s||9758==s||9792==s||9794==s||9824<=s&&s<=9825||9827<=s&&s<=9829||9831<=s&&s<=9834||9836<=s&&s<=9837||9839==s||9886<=s&&s<=9887||9918<=s&&s<=9919||9924<=s&&s<=9933||9935<=s&&s<=9953||9955==s||9960<=s&&s<=9983||10045==s||10071==s||10102<=s&&s<=10111||11093<=s&&s<=11097||12872<=s&&s<=12879||57344<=s&&s<=63743||65024<=s&&s<=65039||65533==s||127232<=s&&s<=127242||127248<=s&&s<=127277||127280<=s&&s<=127337||127344<=s&&s<=127386||917760<=s&&s<=917999||983040<=s&&s<=1048573||1048576<=s&&s<=1114109?"A":"N"},e.characterLength=function(t){var e=this.eastAsianWidth(t);return"F"==e||"W"==e||"A"==e?2:1},e.length=function(t){for(var e=i(t),s=0,r=0;r<e.length;r++)s+=this.characterLength(e[r]);return s},e.slice=function(t,s,r){textLen=e.length(t),r=r||1,(s=s||0)<0&&(s=textLen+s),r<0&&(r=textLen+r);for(var n="",o=0,a=i(t),h=0;h<a.length;h++){var u=a[h],l=e.length(u);if(o>=s-(2==l?1:0)){if(!(o+l<=r))break;n+=u}o+=l}return n}}();var It=Tt,Rt=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD8