derived-cli 0.0.67 → 0.0.71

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.
Files changed (2) hide show
  1. package/dist/bundle.js +168 -129
  2. package/package.json +2 -2
package/dist/bundle.js CHANGED
@@ -1,162 +1,201 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var os=Object.create;var le=Object.defineProperty;var as=Object.getOwnPropertyDescriptor;var ls=Object.getOwnPropertyNames;var Ds=Object.getPrototypeOf,cs=Object.prototype.hasOwnProperty;var hs=(s,e)=>()=>(s&&(e=s(s=0)),e);var I=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),St=(s,e)=>{for(var t in e)le(s,t,{get:e[t],enumerable:!0})},Tt=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ls(e))!cs.call(s,n)&&n!==t&&le(s,n,{get:()=>e[n],enumerable:!(i=as(e,n))||i.enumerable});return s};var C=(s,e,t)=>(t=s!=null?os(Ds(s)):{},Tt(e||!s||!s.__esModule?le(t,"default",{value:s,enumerable:!0}):t,s)),ps=s=>Tt(le({},"__esModule",{value:!0}),s);var ne=I(Me=>{var De=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Ne=class extends De{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Me.CommanderError=De;Me.InvalidArgumentError=Ne});var ce=I(He=>{var{InvalidArgumentError:ds}=ne(),Ve=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new ds(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function ms(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}He.Argument=Ve;He.humanReadableArgName=ms});var Re=I(We=>{var{humanReadableArgName:fs}=ce(),Ge=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(n=>!n._hidden),i=e._getHelpCommand();return i&&!i._hidden&&t.push(i),this.sortSubcommands&&t.sort((n,u)=>n.name().localeCompare(u.name())),t}compareOptions(e,t){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){let t=e.options.filter(n=>!n.hidden),i=e._getHelpOption();if(i&&!i.hidden){let n=i.short&&e._findOption(i.short),u=i.long&&e._findOption(i.long);!n&&!u?t.push(i):i.long&&!u?t.push(e.createOption(i.long,i.description)):i.short&&!n&&t.push(e.createOption(i.short,i.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let i=e.parent;i;i=i.parent){let n=i.options.filter(u=>!u.hidden);t.push(...n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(i=>fs(i)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((i,n)=>Math.max(i,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,n)=>Math.max(i,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((i,n)=>Math.max(i,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,n)=>Math.max(i,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let n=e.parent;n;n=n.parent)i=n.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatItemList(e,t,i){return t.length===0?[]:[i.styleTitle(e),...t,""]}groupItems(e,t,i){let n=new Map;return e.forEach(u=>{let r=i(u);n.has(r)||n.set(r,[])}),t.forEach(u=>{let r=i(u);n.has(r)||n.set(r,[]),n.get(r).push(u)}),n}formatHelp(e,t){let i=t.padWidth(e,t),n=t.helpWidth??80;function u(D,p){return t.formatItem(D,i,p,t)}let r=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],o=t.commandDescription(e);o.length>0&&(r=r.concat([t.boxWrap(t.styleCommandDescription(o),n),""]));let a=t.visibleArguments(e).map(D=>u(t.styleArgumentTerm(t.argumentTerm(D)),t.styleArgumentDescription(t.argumentDescription(D))));if(r=r.concat(this.formatItemList("Arguments:",a,t)),this.groupItems(e.options,t.visibleOptions(e),D=>D.helpGroupHeading??"Options:").forEach((D,p)=>{let E=D.map($=>u(t.styleOptionTerm(t.optionTerm($)),t.styleOptionDescription(t.optionDescription($))));r=r.concat(this.formatItemList(p,E,t))}),t.showGlobalOptions){let D=t.visibleGlobalOptions(e).map(p=>u(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));r=r.concat(this.formatItemList("Global Options:",D,t))}return this.groupItems(e.commands,t.visibleCommands(e),D=>D.helpGroup()||"Commands:").forEach((D,p)=>{let E=D.map($=>u(t.styleSubcommandTerm(t.subcommandTerm($)),t.styleSubcommandDescription(t.subcommandDescription($))));r=r.concat(this.formatItemList(p,E,t))}),r.join(`
3
- `)}displayWidth(e){return Pt(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,i,n){let r=" ".repeat(2);if(!i)return r+e;let o=e.padEnd(t+e.length-n.displayWidth(e)),a=2,l=(this.helpWidth??80)-t-a-2,D;return l<this.minWidthToWrap||n.preformatted(i)?D=i:D=n.boxWrap(i,l).replace(/\n/g,`
4
- `+" ".repeat(t+a)),r+o+" ".repeat(a)+D.replace(/\n/g,`
5
- ${r}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let i=e.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,u=[];return i.forEach(r=>{let o=r.match(n);if(o===null){u.push("");return}let a=[o.shift()],c=this.displayWidth(a[0]);o.forEach(l=>{let D=this.displayWidth(l);if(c+D<=t){a.push(l),c+=D;return}u.push(a.join(""));let p=l.trimStart();a=[p],c=this.displayWidth(p)}),u.push(a.join(""))}),u.join(`
6
- `)}};function Pt(s){let e=/\x1b\[\d*(;\d*)*m/g;return s.replace(e,"")}We.Help=Ge;We.stripColor=Pt});var Je=I(Ue=>{var{InvalidArgumentError:gs}=ne(),qe=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let i=Cs(e);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,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new gs(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,i):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?It(this.name().replace(/^no-/,"")):It(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Le=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(e,t){let i=t.attributeName();if(!this.dualOptions.has(i))return!0;let n=this.negativeOptions.get(i).presetArg,u=n!==void 0?n:!1;return t.negate===(u===e)}};function It(s){return s.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Cs(s){let e,t,i=/^-[^-]$/,n=/^--[^-]/,u=s.split(/[ |,]+/).concat("guard");if(i.test(u[0])&&(e=u.shift()),n.test(u[0])&&(t=u.shift()),!e&&i.test(u[0])&&(e=u.shift()),!e&&n.test(u[0])&&(e=t,t=u.shift()),u[0].startsWith("-")){let r=u[0],o=`option creation failed due to '${r}' in option flags '${s}'`;throw/^-[^-][^-]/.test(r)?new Error(`${o}
2
+ "use strict";var qn=Object.create;var be=Object.defineProperty;var Jn=Object.getOwnPropertyDescriptor;var Un=Object.getOwnPropertyNames;var Kn=Object.getPrototypeOf,zn=Object.prototype.hasOwnProperty;var Yn=(r,e)=>()=>(r&&(e=r(r=0)),e);var q=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),sr=(r,e)=>{for(var t in e)be(r,t,{get:e[t],enumerable:!0})},or=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Un(e))!zn.call(r,s)&&s!==t&&be(r,s,{get:()=>e[s],enumerable:!(i=Jn(e,s))||i.enumerable});return r};var b=(r,e,t)=>(t=r!=null?qn(Kn(r)):{},or(e||!r||!r.__esModule?be(t,"default",{value:r,enumerable:!0}):t,r)),Qn=r=>or(be({},"__esModule",{value:!0}),r);var fe=q(et=>{var ve=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Xe=class extends ve{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};et.CommanderError=ve;et.InvalidArgumentError=Xe});var $e=q(rt=>{var{InvalidArgumentError:Zn}=fe(),tt=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new Zn(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Xn(r){let e=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+e+">":"["+e+"]"}rt.Argument=tt;rt.humanReadableArgName=Xn});var st=q(it=>{var{humanReadableArgName:ei}=$e(),nt=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(s=>!s._hidden),i=e._getHelpCommand();return i&&!i._hidden&&t.push(i),this.sortSubcommands&&t.sort((s,o)=>s.name().localeCompare(o.name())),t}compareOptions(e,t){let i=s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){let t=e.options.filter(s=>!s.hidden),i=e._getHelpOption();if(i&&!i.hidden){let s=i.short&&e._findOption(i.short),o=i.long&&e._findOption(i.long);!s&&!o?t.push(i):i.long&&!o?t.push(e.createOption(i.long,i.description)):i.short&&!s&&t.push(e.createOption(i.short,i.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let i=e.parent;i;i=i.parent){let s=i.options.filter(o=>!o.hidden);t.push(...s)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(i=>ei(i)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((i,s)=>Math.max(i,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(s)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,s)=>Math.max(i,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((i,s)=>Math.max(i,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,s)=>Math.max(i,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(s)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let s=e.parent;s;s=s.parent)i=s.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatItemList(e,t,i){return t.length===0?[]:[i.styleTitle(e),...t,""]}groupItems(e,t,i){let s=new Map;return e.forEach(o=>{let n=i(o);s.has(n)||s.set(n,[])}),t.forEach(o=>{let n=i(o);s.has(n)||s.set(n,[]),s.get(n).push(o)}),s}formatHelp(e,t){let i=t.padWidth(e,t),s=t.helpWidth??80;function o(D,h){return t.formatItem(D,i,h,t)}let n=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],u=t.commandDescription(e);u.length>0&&(n=n.concat([t.boxWrap(t.styleCommandDescription(u),s),""]));let a=t.visibleArguments(e).map(D=>o(t.styleArgumentTerm(t.argumentTerm(D)),t.styleArgumentDescription(t.argumentDescription(D))));if(n=n.concat(this.formatItemList("Arguments:",a,t)),this.groupItems(e.options,t.visibleOptions(e),D=>D.helpGroupHeading??"Options:").forEach((D,h)=>{let E=D.map(B=>o(t.styleOptionTerm(t.optionTerm(B)),t.styleOptionDescription(t.optionDescription(B))));n=n.concat(this.formatItemList(h,E,t))}),t.showGlobalOptions){let D=t.visibleGlobalOptions(e).map(h=>o(t.styleOptionTerm(t.optionTerm(h)),t.styleOptionDescription(t.optionDescription(h))));n=n.concat(this.formatItemList("Global Options:",D,t))}return this.groupItems(e.commands,t.visibleCommands(e),D=>D.helpGroup()||"Commands:").forEach((D,h)=>{let E=D.map(B=>o(t.styleSubcommandTerm(t.subcommandTerm(B)),t.styleSubcommandDescription(t.subcommandDescription(B))));n=n.concat(this.formatItemList(h,E,t))}),n.join(`
3
+ `)}displayWidth(e){return ur(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,i,s){let n=" ".repeat(2);if(!i)return n+e;let u=e.padEnd(t+e.length-s.displayWidth(e)),a=2,l=(this.helpWidth??80)-t-a-2,D;return l<this.minWidthToWrap||s.preformatted(i)?D=i:D=s.boxWrap(i,l).replace(/\n/g,`
4
+ `+" ".repeat(t+a)),n+u+" ".repeat(a)+D.replace(/\n/g,`
5
+ ${n}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let i=e.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,o=[];return i.forEach(n=>{let u=n.match(s);if(u===null){o.push("");return}let a=[u.shift()],c=this.displayWidth(a[0]);u.forEach(l=>{let D=this.displayWidth(l);if(c+D<=t){a.push(l),c+=D;return}o.push(a.join(""));let h=l.trimStart();a=[h],c=this.displayWidth(h)}),o.push(a.join(""))}),o.join(`
6
+ `)}};function ur(r){let e=/\x1b\[\d*(;\d*)*m/g;return r.replace(e,"")}it.Help=nt;it.stripColor=ur});var ct=q(at=>{var{InvalidArgumentError:ti}=fe(),ot=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let i=ri(e);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,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new ti(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,i):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?ar(this.name().replace(/^no-/,"")):ar(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},ut=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(e,t){let i=t.attributeName();if(!this.dualOptions.has(i))return!0;let s=this.negativeOptions.get(i).presetArg,o=s!==void 0?s:!1;return t.negate===(o===e)}};function ar(r){return r.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ri(r){let e,t,i=/^-[^-]$/,s=/^--[^-]/,o=r.split(/[ |,]+/).concat("guard");if(i.test(o[0])&&(e=o.shift()),s.test(o[0])&&(t=o.shift()),!e&&i.test(o[0])&&(e=o.shift()),!e&&s.test(o[0])&&(e=t,t=o.shift()),o[0].startsWith("-")){let n=o[0],u=`option creation failed due to '${n}' in option flags '${r}'`;throw/^-[^-][^-]/.test(n)?new Error(`${u}
7
7
  - a short flag is a single dash and a single character
8
8
  - either use a single dash and a single character (for a short flag)
9
- - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(r)?new Error(`${o}
10
- - too many short flags`):n.test(r)?new Error(`${o}
11
- - too many long flags`):new Error(`${o}
12
- - unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${s}'.`);return{shortFlag:e,longFlag:t}}Ue.Option=qe;Ue.DualOptions=Le});var Nt=I(jt=>{function Fs(s,e){if(Math.abs(s.length-e.length)>3)return Math.max(s.length,e.length);let t=[];for(let i=0;i<=s.length;i++)t[i]=[i];for(let i=0;i<=e.length;i++)t[0][i]=i;for(let i=1;i<=e.length;i++)for(let n=1;n<=s.length;n++){let u=1;s[n-1]===e[i-1]?u=0:u=1,t[n][i]=Math.min(t[n-1][i]+1,t[n][i-1]+1,t[n-1][i-1]+u),n>1&&i>1&&s[n-1]===e[i-2]&&s[n-2]===e[i-1]&&(t[n][i]=Math.min(t[n][i],t[n-2][i-2]+1))}return t[s.length][e.length]}function Es(s,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=s.startsWith("--");t&&(s=s.slice(2),e=e.map(r=>r.slice(2)));let i=[],n=3,u=.4;return e.forEach(r=>{if(r.length<=1)return;let o=Fs(s,r),a=Math.max(s.length,r.length);(a-o)/a>u&&(o<n?(n=o,i=[r]):o===n&&i.push(r))}),i.sort((r,o)=>r.localeCompare(o)),t&&(i=i.map(r=>`--${r}`)),i.length>1?`
9
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(n)?new Error(`${u}
10
+ - too many short flags`):s.test(n)?new Error(`${u}
11
+ - too many long flags`):new Error(`${u}
12
+ - unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${r}'.`);return{shortFlag:e,longFlag:t}}at.Option=ot;at.DualOptions=ut});var lr=q(cr=>{function ni(r,e){if(Math.abs(r.length-e.length)>3)return Math.max(r.length,e.length);let t=[];for(let i=0;i<=r.length;i++)t[i]=[i];for(let i=0;i<=e.length;i++)t[0][i]=i;for(let i=1;i<=e.length;i++)for(let s=1;s<=r.length;s++){let o=1;r[s-1]===e[i-1]?o=0:o=1,t[s][i]=Math.min(t[s-1][i]+1,t[s][i-1]+1,t[s-1][i-1]+o),s>1&&i>1&&r[s-1]===e[i-2]&&r[s-2]===e[i-1]&&(t[s][i]=Math.min(t[s][i],t[s-2][i-2]+1))}return t[r.length][e.length]}function ii(r,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=r.startsWith("--");t&&(r=r.slice(2),e=e.map(n=>n.slice(2)));let i=[],s=3,o=.4;return e.forEach(n=>{if(n.length<=1)return;let u=ni(r,n),a=Math.max(r.length,n.length);(a-u)/a>o&&(u<s?(s=u,i=[n]):u===s&&i.push(n))}),i.sort((n,u)=>n.localeCompare(u)),t&&(i=i.map(n=>`--${n}`)),i.length>1?`
13
13
  (Did you mean one of ${i.join(", ")}?)`:i.length===1?`
14
- (Did you mean ${i[0]}?)`:""}jt.suggestSimilar=Es});var Gt=I(Ze=>{var ys=require("node:events").EventEmitter,Ke=require("node:child_process"),M=require("node:path"),he=require("node:fs"),f=require("node:process"),{Argument:bs,humanReadableArgName:vs}=ce(),{CommanderError:ze}=ne(),{Help:$s,stripColor:ws}=Re(),{Option:Mt,DualOptions:As}=Je(),{suggestSimilar:Vt}=Nt(),Ye=class s extends ys{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",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._savedState=null,this._outputConfiguration={writeOut:t=>f.stdout.write(t),writeErr:t=>f.stderr.write(t),outputError:(t,i)=>i(t),getOutHelpWidth:()=>f.stdout.isTTY?f.stdout.columns:void 0,getErrHelpWidth:()=>f.stderr.isTTY?f.stderr.columns:void 0,getOutHasColors:()=>Qe()??(f.stdout.isTTY&&f.stdout.hasColors?.()),getErrHasColors:()=>Qe()??(f.stderr.isTTY&&f.stderr.hasColors?.()),stripColor:t=>ws(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let n=t,u=i;typeof n=="object"&&n!==null&&(u=n,n=null),u=u||{};let[,r,o]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(r);return n&&(a.description(n),a._executableHandler=!0),u.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(u.noHelp||u.hidden),a._executableFile=u.executableFile||null,o&&a.arguments(o),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(e){return new s(e)}createHelp(){return Object.assign(new $s,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
15
- - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new bs(e,t)}argument(e,t,i,n){let u=this.createArgument(e,t);return typeof i=="function"?u.default(n).argParser(i):u.default(i),this.addArgument(u),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let i=e??"help [command]",[,n,u]=i.match(/([^ ]+) *(.*)/),r=t??"display help for command",o=this.createCommand(n);return o.helpOption(!1),u&&o.arguments(u),r&&o.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=o,(e||t)&&this._initCommandGroup(o),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
16
- Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new ze(e,t,i)),f.exit(e)}action(e){let t=i=>{let n=this.registeredArguments.length,u=i.slice(0,n);return this._storeOptionsAsProperties?u[n]=this:u[n]=this.opts(),u.push(this),e.apply(this,u)};return this._actionHandler=t,this}createOption(e,t){return new Mt(e,t)}_callParseArg(e,t,i,n){try{return e.parseArg(t,i)}catch(u){if(u.code==="commander.invalidArgument"){let r=`${n} ${u.message}`;this.error(r,{exitCode:u.exitCode,code:u.code})}throw u}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let i=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
17
- - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=n=>[n.name()].concat(n.aliases()),i=t(e).find(n=>this._findCommand(n));if(i){let n=t(this._findCommand(i)).join("|"),u=t(e).join("|");throw new Error(`cannot add command '${u}' as already have command '${n}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let u=e.long.replace(/^--no-/,"--");this._findOption(u)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let n=(u,r,o)=>{u==null&&e.presetArg!==void 0&&(u=e.presetArg);let a=this.getOptionValue(i);u!==null&&e.parseArg?u=this._callParseArg(e,u,a,r):u!==null&&e.variadic&&(u=e._collectValue(u,a)),u==null&&(e.negate?u=!1:e.isBoolean()||e.optional?u=!0:u=""),this.setOptionValueWithSource(i,u,o)};return this.on("option:"+t,u=>{let r=`error: option '${e.flags}' argument '${u}' is invalid.`;n(u,r,"cli")}),e.envVar&&this.on("optionEnv:"+t,u=>{let r=`error: option '${e.flags}' value '${u}' from env '${e.envVar}' is invalid.`;n(u,r,"env")}),this}_optionEx(e,t,i,n,u){if(typeof t=="object"&&t instanceof Mt)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let r=this.createOption(t,i);if(r.makeOptionMandatory(!!e.mandatory),typeof n=="function")r.default(u).argParser(n);else if(n instanceof RegExp){let o=n;n=(a,c)=>{let l=o.exec(a);return l?l[0]:c},r.default(u).argParser(n)}else r.default(n);return this.addOption(r)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:!0},e,t,i,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(e)!==void 0&&(t=i.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){f.versions?.electron&&(t.from="electron");let n=f.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(t.from="eval")}e===void 0&&(e=f.argv),this.rawArgs=e.slice();let i;switch(t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":f.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=e.slice(0);break;case"eval":i=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(e,t){this._prepareForParse();let i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){this._prepareForParse();let i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
18
- - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,i){if(he.existsSync(e))return;let n=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",u=`'${e}' does not exist
14
+ (Did you mean ${i[0]}?)`:""}cr.suggestSimilar=ii});var hr=q(ht=>{var si=require("node:events").EventEmitter,lt=require("node:child_process"),Q=require("node:path"),we=require("node:fs"),g=require("node:process"),{Argument:oi,humanReadableArgName:ui}=$e(),{CommanderError:Dt}=fe(),{Help:ai,stripColor:ci}=st(),{Option:Dr,DualOptions:li}=ct(),{suggestSimilar:dr}=lr(),dt=class r extends si{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",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._savedState=null,this._outputConfiguration={writeOut:t=>g.stdout.write(t),writeErr:t=>g.stderr.write(t),outputError:(t,i)=>i(t),getOutHelpWidth:()=>g.stdout.isTTY?g.stdout.columns:void 0,getErrHelpWidth:()=>g.stderr.isTTY?g.stderr.columns:void 0,getOutHasColors:()=>pt()??(g.stdout.isTTY&&g.stdout.hasColors?.()),getErrHasColors:()=>pt()??(g.stderr.isTTY&&g.stderr.hasColors?.()),stripColor:t=>ci(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let s=t,o=i;typeof s=="object"&&s!==null&&(o=s,s=null),o=o||{};let[,n,u]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(n);return s&&(a.description(s),a._executableHandler=!0),o.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(o.noHelp||o.hidden),a._executableFile=o.executableFile||null,u&&a.arguments(u),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),s?this:a}createCommand(e){return new r(e)}createHelp(){return Object.assign(new ai,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
15
+ - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new oi(e,t)}argument(e,t,i,s){let o=this.createArgument(e,t);return typeof i=="function"?o.default(s).argParser(i):o.default(i),this.addArgument(o),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let i=e??"help [command]",[,s,o]=i.match(/([^ ]+) *(.*)/),n=t??"display help for command",u=this.createCommand(s);return u.helpOption(!1),o&&u.arguments(o),n&&u.description(n),this._addImplicitHelpCommand=!0,this._helpCommand=u,(e||t)&&this._initCommandGroup(u),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
16
+ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new Dt(e,t,i)),g.exit(e)}action(e){let t=i=>{let s=this.registeredArguments.length,o=i.slice(0,s);return this._storeOptionsAsProperties?o[s]=this:o[s]=this.opts(),o.push(this),e.apply(this,o)};return this._actionHandler=t,this}createOption(e,t){return new Dr(e,t)}_callParseArg(e,t,i,s){try{return e.parseArg(t,i)}catch(o){if(o.code==="commander.invalidArgument"){let n=`${s} ${o.message}`;this.error(n,{exitCode:o.exitCode,code:o.code})}throw o}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let i=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
17
+ - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=s=>[s.name()].concat(s.aliases()),i=t(e).find(s=>this._findCommand(s));if(i){let s=t(this._findCommand(i)).join("|"),o=t(e).join("|");throw new Error(`cannot add command '${o}' as already have command '${s}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let o=e.long.replace(/^--no-/,"--");this._findOption(o)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let s=(o,n,u)=>{o==null&&e.presetArg!==void 0&&(o=e.presetArg);let a=this.getOptionValue(i);o!==null&&e.parseArg?o=this._callParseArg(e,o,a,n):o!==null&&e.variadic&&(o=e._collectValue(o,a)),o==null&&(e.negate?o=!1:e.isBoolean()||e.optional?o=!0:o=""),this.setOptionValueWithSource(i,o,u)};return this.on("option:"+t,o=>{let n=`error: option '${e.flags}' argument '${o}' is invalid.`;s(o,n,"cli")}),e.envVar&&this.on("optionEnv:"+t,o=>{let n=`error: option '${e.flags}' value '${o}' from env '${e.envVar}' is invalid.`;s(o,n,"env")}),this}_optionEx(e,t,i,s,o){if(typeof t=="object"&&t instanceof Dr)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let n=this.createOption(t,i);if(n.makeOptionMandatory(!!e.mandatory),typeof s=="function")n.default(o).argParser(s);else if(s instanceof RegExp){let u=s;s=(a,c)=>{let l=u.exec(a);return l?l[0]:c},n.default(o).argParser(s)}else n.default(s);return this.addOption(n)}option(e,t,i,s){return this._optionEx({},e,t,i,s)}requiredOption(e,t,i,s){return this._optionEx({mandatory:!0},e,t,i,s)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(e)!==void 0&&(t=i.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){g.versions?.electron&&(t.from="electron");let s=g.execArgv??[];(s.includes("-e")||s.includes("--eval")||s.includes("-p")||s.includes("--print"))&&(t.from="eval")}e===void 0&&(e=g.argv),this.rawArgs=e.slice();let i;switch(t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":g.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=e.slice(0);break;case"eval":i=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(e,t){this._prepareForParse();let i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){this._prepareForParse();let i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
18
+ - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,i){if(we.existsSync(e))return;let s=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",o=`'${e}' does not exist
19
19
  - if '${i}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
20
20
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
21
- - ${n}`;throw new Error(u)}_executeSubCommand(e,t){t=t.slice();let i=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function u(l,D){let p=M.resolve(l,D);if(he.existsSync(p))return p;if(n.includes(M.extname(D)))return;let E=n.find($=>he.existsSync(`${p}${$}`));if(E)return`${p}${E}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=e._executableFile||`${this._name}-${e._name}`,o=this._executableDir||"";if(this._scriptPath){let l;try{l=he.realpathSync(this._scriptPath)}catch{l=this._scriptPath}o=M.resolve(M.dirname(l),o)}if(o){let l=u(o,r);if(!l&&!e._executableFile&&this._scriptPath){let D=M.basename(this._scriptPath,M.extname(this._scriptPath));D!==this._name&&(l=u(o,`${D}-${e._name}`))}r=l||r}i=n.includes(M.extname(r));let a;f.platform!=="win32"?i?(t.unshift(r),t=Ht(f.execArgv).concat(t),a=Ke.spawn(f.argv[0],t,{stdio:"inherit"})):a=Ke.spawn(r,t,{stdio:"inherit"}):(this._checkForMissingExecutable(r,o,e._name),t.unshift(r),t=Ht(f.execArgv).concat(t),a=Ke.spawn(f.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(D=>{f.on(D,()=>{a.killed===!1&&a.exitCode===null&&a.kill(D)})});let c=this._exitCallback;a.on("close",l=>{l=l??1,c?c(new ze(l,"commander.executeSubCommandAsync","(close)")):f.exit(l)}),a.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(r,o,e._name);else if(l.code==="EACCES")throw new Error(`'${r}' not executable`);if(!c)f.exit(1);else{let D=new ze(1,"commander.executeSubCommandAsync","(error)");D.nestedError=l,c(D)}}),this.runningCommand=a}_dispatchSubcommand(e,t,i){let n=this._findCommand(e);n||this.help({error:!0}),n._prepareForParse();let u;return u=this._chainOrCallSubCommandHook(u,n,"preSubcommand"),u=this._chainOrCall(u,()=>{if(n._executableHandler)this._executeSubCommand(n,t.concat(i));else return n._parseCommand(t,i)}),u}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(i,n,u)=>{let r=n;if(n!==null&&i.parseArg){let o=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;r=this._callParseArg(i,n,u,o)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((i,n)=>{let u=i.defaultValue;i.variadic?n<this.args.length?(u=this.args.slice(n),i.parseArg&&(u=u.reduce((r,o)=>e(i,o,r),i.defaultValue))):u===void 0&&(u=[]):n<this.args.length&&(u=this.args[n],i.parseArg&&(u=e(i,u,i.defaultValue))),t[n]=u}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let i=e,n=[];return this._getCommandAndAncestors().reverse().filter(u=>u._lifeCycleHooks[t]!==void 0).forEach(u=>{u._lifeCycleHooks[t].forEach(r=>{n.push({hookedCommand:u,callback:r})})}),t==="postAction"&&n.reverse(),n.forEach(u=>{i=this._chainOrCall(i,()=>u.callback(u.hookedCommand,this))}),i}_chainOrCallSubCommandHook(e,t,i){let n=e;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(u=>{n=this._chainOrCall(n,()=>u(this,t))}),n}_parseCommand(e,t){let i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},u=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let r;return r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent&&(r=this._chainOrCall(r,()=>{this.parent.emit(u,e,t)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent?.listenerCount(u))n(),this._processArguments(),this.parent.emit(u,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});e.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=e.find(u=>i.conflictsWith.includes(u.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],i=[],n=t;function u(l){return l.length>1&&l[0]==="-"}let r=l=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(l)?!this._getCommandAndAncestors().some(D=>D.options.map(p=>p.short).some(p=>/^-\d$/.test(p))):!1,o=null,a=null,c=0;for(;c<e.length||a;){let l=a??e[c++];if(a=null,l==="--"){n===i&&n.push(l),n.push(...e.slice(c));break}if(o&&(!u(l)||r(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,u(l)){let D=this._findOption(l);if(D){if(D.required){let p=e[c++];p===void 0&&this.optionMissingArgument(D),this.emit(`option:${D.name()}`,p)}else if(D.optional){let p=null;c<e.length&&(!u(e[c])||r(e[c]))&&(p=e[c++]),this.emit(`option:${D.name()}`,p)}else this.emit(`option:${D.name()}`);o=D.variadic?D:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let D=this._findOption(`-${l[1]}`);if(D){D.required||D.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${D.name()}`,l.slice(2)):(this.emit(`option:${D.name()}`),a=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let D=l.indexOf("="),p=this._findOption(l.slice(0,D));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,l.slice(D+1));continue}}if(n===t&&u(l)&&!(this.commands.length===0&&r(l))&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(l)){t.push(l),i.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){i.push(l,...e.slice(c));break}}if(this._passThroughOptions){n.push(l,...e.slice(c));break}n.push(l)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let i=0;i<t;i++){let n=this.options[i].attributeName();e[n]=n===this._versionOptionName?this._version:this[n]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
21
+ - ${s}`;throw new Error(o)}_executeSubCommand(e,t){t=t.slice();let i=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function o(l,D){let h=Q.resolve(l,D);if(we.existsSync(h))return h;if(s.includes(Q.extname(D)))return;let E=s.find(B=>we.existsSync(`${h}${B}`));if(E)return`${h}${E}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=e._executableFile||`${this._name}-${e._name}`,u=this._executableDir||"";if(this._scriptPath){let l;try{l=we.realpathSync(this._scriptPath)}catch{l=this._scriptPath}u=Q.resolve(Q.dirname(l),u)}if(u){let l=o(u,n);if(!l&&!e._executableFile&&this._scriptPath){let D=Q.basename(this._scriptPath,Q.extname(this._scriptPath));D!==this._name&&(l=o(u,`${D}-${e._name}`))}n=l||n}i=s.includes(Q.extname(n));let a;g.platform!=="win32"?i?(t.unshift(n),t=pr(g.execArgv).concat(t),a=lt.spawn(g.argv[0],t,{stdio:"inherit"})):a=lt.spawn(n,t,{stdio:"inherit"}):(this._checkForMissingExecutable(n,u,e._name),t.unshift(n),t=pr(g.execArgv).concat(t),a=lt.spawn(g.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(D=>{g.on(D,()=>{a.killed===!1&&a.exitCode===null&&a.kill(D)})});let c=this._exitCallback;a.on("close",l=>{l=l??1,c?c(new Dt(l,"commander.executeSubCommandAsync","(close)")):g.exit(l)}),a.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(n,u,e._name);else if(l.code==="EACCES")throw new Error(`'${n}' not executable`);if(!c)g.exit(1);else{let D=new Dt(1,"commander.executeSubCommandAsync","(error)");D.nestedError=l,c(D)}}),this.runningCommand=a}_dispatchSubcommand(e,t,i){let s=this._findCommand(e);s||this.help({error:!0}),s._prepareForParse();let o;return o=this._chainOrCallSubCommandHook(o,s,"preSubcommand"),o=this._chainOrCall(o,()=>{if(s._executableHandler)this._executeSubCommand(s,t.concat(i));else return s._parseCommand(t,i)}),o}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(i,s,o)=>{let n=s;if(s!==null&&i.parseArg){let u=`error: command-argument value '${s}' is invalid for argument '${i.name()}'.`;n=this._callParseArg(i,s,o,u)}return n};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((i,s)=>{let o=i.defaultValue;i.variadic?s<this.args.length?(o=this.args.slice(s),i.parseArg&&(o=o.reduce((n,u)=>e(i,u,n),i.defaultValue))):o===void 0&&(o=[]):s<this.args.length&&(o=this.args[s],i.parseArg&&(o=e(i,o,i.defaultValue))),t[s]=o}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let i=e,s=[];return this._getCommandAndAncestors().reverse().filter(o=>o._lifeCycleHooks[t]!==void 0).forEach(o=>{o._lifeCycleHooks[t].forEach(n=>{s.push({hookedCommand:o,callback:n})})}),t==="postAction"&&s.reverse(),s.forEach(o=>{i=this._chainOrCall(i,()=>o.callback(o.hookedCommand,this))}),i}_chainOrCallSubCommandHook(e,t,i){let s=e;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(o=>{s=this._chainOrCall(s,()=>o(this,t))}),s}_parseCommand(e,t){let i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},o=`command:${this.name()}`;if(this._actionHandler){s(),this._processArguments();let n;return n=this._chainOrCallHooks(n,"preAction"),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(o,e,t)})),n=this._chainOrCallHooks(n,"postAction"),n}if(this.parent?.listenerCount(o))s(),this._processArguments(),this.parent.emit(o,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(s(),this._processArguments())}else this.commands.length?(s(),this.help({error:!0})):(s(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(i=>{let s=i.attributeName();return this.getOptionValue(s)===void 0?!1:this.getOptionValueSource(s)!=="default"});e.filter(i=>i.conflictsWith.length>0).forEach(i=>{let s=e.find(o=>i.conflictsWith.includes(o.attributeName()));s&&this._conflictingOption(i,s)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],i=[],s=t;function o(l){return l.length>1&&l[0]==="-"}let n=l=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(l)?!this._getCommandAndAncestors().some(D=>D.options.map(h=>h.short).some(h=>/^-\d$/.test(h))):!1,u=null,a=null,c=0;for(;c<e.length||a;){let l=a??e[c++];if(a=null,l==="--"){s===i&&s.push(l),s.push(...e.slice(c));break}if(u&&(!o(l)||n(l))){this.emit(`option:${u.name()}`,l);continue}if(u=null,o(l)){let D=this._findOption(l);if(D){if(D.required){let h=e[c++];h===void 0&&this.optionMissingArgument(D),this.emit(`option:${D.name()}`,h)}else if(D.optional){let h=null;c<e.length&&(!o(e[c])||n(e[c]))&&(h=e[c++]),this.emit(`option:${D.name()}`,h)}else this.emit(`option:${D.name()}`);u=D.variadic?D:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let D=this._findOption(`-${l[1]}`);if(D){D.required||D.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${D.name()}`,l.slice(2)):(this.emit(`option:${D.name()}`),a=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let D=l.indexOf("="),h=this._findOption(l.slice(0,D));if(h&&(h.required||h.optional)){this.emit(`option:${h.name()}`,l.slice(D+1));continue}}if(s===t&&o(l)&&!(this.commands.length===0&&n(l))&&(s=i),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(l)){t.push(l),i.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){i.push(l,...e.slice(c));break}}if(this._passThroughOptions){s.push(l,...e.slice(c));break}s.push(l)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let i=0;i<t;i++){let s=this.options[i].attributeName();e[s]=s===this._versionOptionName?this._version:this[s]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
22
22
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
23
23
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
24
- `),this.outputHelp({error:!0}));let i=t||{},n=i.exitCode||1,u=i.code||"commander.error";this._exit(n,u,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in f.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,f.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new As(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!t(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=r=>{let o=r.attributeName(),a=this.getOptionValue(o),c=this.options.find(D=>D.negate&&o===D.attributeName()),l=this.options.find(D=>!D.negate&&o===D.attributeName());return c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg)?c:l||r},n=r=>{let o=i(r),a=o.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${o.envVar}'`:`option '${o.flags}'`},u=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(u,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],u=this;do{let r=u.createHelp().visibleOptions(u).filter(o=>o.long).map(o=>o.long);n=n.concat(r),u=u.parent}while(u&&!u._enablePositionalOptions);t=Vt(e,n)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,i=t===1?"":"s",u=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(u,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(u=>{n.push(u.name()),u.alias()&&n.push(u.alias())}),t=Vt(e,n)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e}
25
- `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(e);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${n}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>vs(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=M.basename(e,M.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),i=this._getOutputContext(e);t.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let n=t.formatHelp(this,t);return i.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(e){e=e||{};let t=!!e.error,i,n,u;return t?(i=o=>this._outputConfiguration.writeErr(o),n=this._outputConfiguration.getErrHasColors(),u=this._outputConfiguration.getErrHelpWidth()):(i=o=>this._outputConfiguration.writeOut(o),n=this._outputConfiguration.getOutHasColors(),u=this._outputConfiguration.getOutHelpWidth()),{error:t,write:o=>(n||(o=this._outputConfiguration.stripColor(o)),i(o)),hasColors:n,helpWidth:u}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getOutputContext(e),n={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let u=this.helpInformation({error:i.error});if(t&&(u=t(u),typeof u!="string"&&!Buffer.isBuffer(u)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(u),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",n))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(f.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.
26
- Expecting one of '${i.join("', '")}'`);let n=`${e}Help`;return this.on(n,u=>{let r;typeof t=="function"?r=t({error:u.error,command:u.command}):r=t,r&&u.write(`${r}
27
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(n=>t.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Ht(s){return s.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",n="9229",u;return(u=e.match(/^(--inspect(-brk)?)$/))!==null?t=u[1]:(u=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=u[1],/^\d+$/.test(u[3])?n=u[3]:i=u[3]):(u=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=u[1],i=u[3],n=u[4]),t&&n!=="0"?`${t}=${i}:${parseInt(n)+1}`:e})}function Qe(){if(f.env.NO_COLOR||f.env.FORCE_COLOR==="0"||f.env.FORCE_COLOR==="false")return!1;if(f.env.FORCE_COLOR||f.env.CLICOLOR_FORCE!==void 0)return!0}Ze.Command=Ye;Ze.useColor=Qe});var Lt=I(k=>{var{Argument:Wt}=ce(),{Command:Xe}=Gt(),{CommanderError:Bs,InvalidArgumentError:Rt}=ne(),{Help:_s}=Re(),{Option:qt}=Je();k.program=new Xe;k.createCommand=s=>new Xe(s);k.createOption=(s,e)=>new qt(s,e);k.createArgument=(s,e)=>new Wt(s,e);k.Command=Xe;k.Option=qt;k.Argument=Wt;k.Help=_s;k.CommanderError=Bs;k.InvalidArgumentError=Rt;k.InvalidOptionArgumentError=Rt});var rt=I((yn,Kt)=>{"use strict";var et="\x1B",F=`${et}[`,xs="\x07",tt={to(s,e){return e?`${F}${e+1};${s+1}H`:`${F}${s+1}G`},move(s,e){let t="";return s<0?t+=`${F}${-s}D`:s>0&&(t+=`${F}${s}C`),e<0?t+=`${F}${-e}A`:e>0&&(t+=`${F}${e}B`),t},up:(s=1)=>`${F}${s}A`,down:(s=1)=>`${F}${s}B`,forward:(s=1)=>`${F}${s}C`,backward:(s=1)=>`${F}${s}D`,nextLine:(s=1)=>`${F}E`.repeat(s),prevLine:(s=1)=>`${F}F`.repeat(s),left:`${F}G`,hide:`${F}?25l`,show:`${F}?25h`,save:`${et}7`,restore:`${et}8`},Os={up:(s=1)=>`${F}S`.repeat(s),down:(s=1)=>`${F}T`.repeat(s)},ks={screen:`${F}2J`,up:(s=1)=>`${F}1J`.repeat(s),down:(s=1)=>`${F}J`.repeat(s),line:`${F}2K`,lineEnd:`${F}K`,lineStart:`${F}1K`,lines(s){let e="";for(let t=0;t<s;t++)e+=this.line+(t<s-1?tt.up():"");return s&&(e+=tt.left),e}};Kt.exports={cursor:tt,scroll:Os,erase:ks,beep:xs}});var me=I((bn,st)=>{var de=process||{},zt=de.argv||[],pe=de.env||{},Ss=!(pe.NO_COLOR||zt.includes("--no-color"))&&(!!pe.FORCE_COLOR||zt.includes("--color")||de.platform==="win32"||(de.stdout||{}).isTTY&&pe.TERM!=="dumb"||!!pe.CI),Ts=(s,e,t=s)=>i=>{let n=""+i,u=n.indexOf(e,s.length);return~u?s+Ps(n,e,t,u)+e:s+n+e},Ps=(s,e,t,i)=>{let n="",u=0;do n+=s.substring(u,i)+t,u=i+e.length,i=s.indexOf(e,u);while(~i);return n+s.substring(u)},Yt=(s=Ss)=>{let e=s?Ts:()=>String;return{isColorSupported:s,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};st.exports=Yt();st.exports.createColors=Yt});var $r=I((Pn,vr)=>{"use strict";var ft=Object.defineProperty,Fi=Object.getOwnPropertyDescriptor,Ei=Object.getOwnPropertyNames,yi=Object.prototype.hasOwnProperty,bi=(s,e)=>{for(var t in e)ft(s,t,{get:e[t],enumerable:!0})},vi=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ei(e))!yi.call(s,n)&&n!==t&&ft(s,n,{get:()=>e[n],enumerable:!(i=Fi(e,n))||i.enumerable});return s},$i=s=>vi(ft({},"__esModule",{value:!0}),s),br={};bi(br,{default:()=>Bi});vr.exports=$i(br);var wi=class{baseUrl;defaultHeaders;constructor(s,e={}){this.baseUrl=s,this.defaultHeaders=e}buildUrl(s){return`${this.baseUrl.replace(/\/$/,"")}/${s.replace(/^\//,"")}`}async request(s,e,t,i={}){let n=this.buildUrl(e),u=await fetch(n,{method:s,headers:{"Content-Type":"application/json",...this.defaultHeaders,...i},body:t?JSON.stringify(t):void 0});if(!u.ok){let o=await u.text().catch(()=>"");throw new Error(`HTTP ${u.status} ${u.statusText}: ${o||"Request failed"}`)}let r=await u.text();try{return JSON.parse(r)}catch{return r}}get(s,e){return this.request("GET",s,void 0,e)}post(s,e,t){return this.request("POST",s,e,t)}put(s,e,t){return this.request("PUT",s,e,t)}delete(s,e){return this.request("DELETE",s,void 0,e)}},Ai=class{api;apiToken;constructor(s){this.apiToken=s?.apiToken,this.api=new wi("https://api.derived.dev/api",{...this.apiToken?{Authorization:this.apiToken}:{}})}fetchBlock=async s=>this.api.get(`/public/v1/template-group/code/${s}`);getBlockInputFromUserQuery=(s,e)=>this.api.post("/public/v1/template-group/get-block-input-from-user-query",{blockInput:s,query:e});resolveMultipleTemplates=(s,e)=>this.api.post("/public/v1/template-group/resolve-multiple-templates-by-block-code",{blockCode:s,data:e});searchBlocksByName=s=>this.api.get(`/public/v1/template-group/semantic-search?q=${s}&limit=5&threshold=0.5`);fetchProjectBySlug=async s=>this.api.get(`/public/v1/project/detail-by-slug/${s}`);createMultipleTemplates=async s=>this.api.post("/v1/template/create-multiple",s);createTemplateGroup=async s=>this.api.post("/v1/template-group/create",s);getProjectCategories=async(s,e=20,t=1)=>{let i=encodeURIComponent(JSON.stringify({projectID:s})),n=encodeURIComponent(JSON.stringify({Desc:"id"}));return this.api.get(`/v1/block-category/list?filters=${i}&sort=${n}&limit=${e}&page=${t}`)};createCategory=async s=>this.api.post("/v1/block-category/create",s);updateTemplateGroup=async(s,e)=>this.api.put(`/v1/template-group/update/${s}`,e)},Bi=Ai});var zr={};St(zr,{isDirectoryEmpty:()=>Ki,removeGitDirectory:()=>zi});function Ki(s){return(0,Q.existsSync)(s)?(0,Q.readdirSync)(s).filter(i=>!i.startsWith(".")).length===0:!0}function zi(s){let e=(0,Kr.join)(s,".git");(0,Q.existsSync)(e)&&(0,Q.rmSync)(e,{recursive:!0,force:!0})}var Q,Kr,Yr=hs(()=>{"use strict";Q=require("fs"),Kr=require("path")});var en={};St(en,{displayFileTree:()=>rs});module.exports=ps(en);var Ut=C(Lt(),1),{program:Dn,createCommand:cn,createArgument:hn,createOption:pn,CommanderError:dn,InvalidArgumentError:mn,InvalidOptionArgumentError:fn,Command:Jt,Argument:gn,Option:Cn,Help:Fn}=Ut.default;var be=require("node:util");var v=C(rt(),1),re=require("node:process"),H=C(require("node:readline"),1),ut=C(require("node:readline"),1),nr=require("node:stream"),ur=C(me(),1);function Is({onlyFirst:s=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,s?void 0:"g")}var js=Is();function or(s){if(typeof s!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof s}\``);return s.replace(js,"")}function ar(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var lr={exports:{}};(function(s){var e={};s.exports=e,e.eastAsianWidth=function(i){var n=i.charCodeAt(0),u=i.length==2?i.charCodeAt(1):0,r=n;return 55296<=n&&n<=56319&&56320<=u&&u<=57343&&(n&=1023,u&=1023,r=n<<10|u,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?"F":r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?"H":4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?"W":32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?"Na":r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?"A":"N"},e.characterLength=function(i){var n=this.eastAsianWidth(i);return n=="F"||n=="W"||n=="A"?2:1};function t(i){return i.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}e.length=function(i){for(var n=t(i),u=0,r=0;r<n.length;r++)u=u+this.characterLength(n[r]);return u},e.slice=function(i,n,u){textLen=e.length(i),n=n||0,u=u||1,n<0&&(n=textLen+n),u<0&&(u=textLen+u);for(var r="",o=0,a=t(i),c=0;c<a.length;c++){var l=a[c],D=e.length(l);if(o>=n-(D==2?1:0))if(o+D<=u)r+=l;else break;o+=D}return r}})(lr);var Ns=lr.exports,Ms=ar(Ns),Vs=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(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},Hs=ar(Vs);function ue(s,e={}){if(typeof s!="string"||s.length===0||(e={ambiguousIsNarrow:!0,...e},s=or(s),s.length===0))return 0;s=s.replace(Hs()," ");let t=e.ambiguousIsNarrow?1:2,i=0;for(let n of s){let u=n.codePointAt(0);if(!(u<=31||u>=127&&u<=159||u>=768&&u<=879))switch(Ms.eastAsianWidth(n)){case"F":case"W":i+=2;break;case"A":i+=t;break;default:i+=1}}return i}var it=10,Qt=(s=0)=>e=>`\x1B[${e+s}m`,Zt=(s=0)=>e=>`\x1B[${38+s};5;${e}m`,Xt=(s=0)=>(e,t,i)=>`\x1B[${38+s};2;${e};${t};${i}m`,g={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(g.modifier);var Gs=Object.keys(g.color),Ws=Object.keys(g.bgColor);[...Gs,...Ws];function Rs(){let s=new Map;for(let[e,t]of Object.entries(g)){for(let[i,n]of Object.entries(t))g[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},t[i]=g[i],s.set(n[0],n[1]);Object.defineProperty(g,e,{value:t,enumerable:!1})}return Object.defineProperty(g,"codes",{value:s,enumerable:!1}),g.color.close="\x1B[39m",g.bgColor.close="\x1B[49m",g.color.ansi=Qt(),g.color.ansi256=Zt(),g.color.ansi16m=Xt(),g.bgColor.ansi=Qt(it),g.bgColor.ansi256=Zt(it),g.bgColor.ansi16m=Xt(it),Object.defineProperties(g,{rgbToAnsi256:{value:(e,t,i)=>e===t&&t===i?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[i]=t;i.length===3&&(i=[...i].map(u=>u+u).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:e=>g.rgbToAnsi256(...g.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,i,n;if(e>=232)t=((e-232)*10+8)/255,i=t,n=t;else{e-=16;let o=e%36;t=Math.floor(e/36)/5,i=Math.floor(o/6)/5,n=o%6/5}let u=Math.max(t,i,n)*2;if(u===0)return 30;let r=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(t));return u===2&&(r+=60),r},enumerable:!1},rgbToAnsi:{value:(e,t,i)=>g.ansi256ToAnsi(g.rgbToAnsi256(e,t,i)),enumerable:!1},hexToAnsi:{value:e=>g.ansi256ToAnsi(g.hexToAnsi256(e)),enumerable:!1}}),g}var qs=Rs(),ye=new Set(["\x1B","\x9B"]),Ls=39,at="\x07",Dr="[",Us="]",cr="m",lt=`${Us}8;;`,er=s=>`${ye.values().next().value}${Dr}${s}${cr}`,tr=s=>`${ye.values().next().value}${lt}${s}${at}`,Js=s=>s.split(" ").map(e=>ue(e)),nt=(s,e,t)=>{let i=[...e],n=!1,u=!1,r=ue(or(s[s.length-1]));for(let[o,a]of i.entries()){let c=ue(a);if(r+c<=t?s[s.length-1]+=a:(s.push(a),r=0),ye.has(a)&&(n=!0,u=i.slice(o+1).join("").startsWith(lt)),n){u?a===at&&(n=!1,u=!1):a===cr&&(n=!1);continue}r+=c,r===t&&o<i.length-1&&(s.push(""),r=0)}!r&&s[s.length-1].length>0&&s.length>1&&(s[s.length-2]+=s.pop())},Ks=s=>{let e=s.split(" "),t=e.length;for(;t>0&&!(ue(e[t-1])>0);)t--;return t===e.length?s:e.slice(0,t).join(" ")+e.slice(t).join("")},zs=(s,e,t={})=>{if(t.trim!==!1&&s.trim()==="")return"";let i="",n,u,r=Js(s),o=[""];for(let[c,l]of s.split(" ").entries()){t.trim!==!1&&(o[o.length-1]=o[o.length-1].trimStart());let D=ue(o[o.length-1]);if(c!==0&&(D>=e&&(t.wordWrap===!1||t.trim===!1)&&(o.push(""),D=0),(D>0||t.trim===!1)&&(o[o.length-1]+=" ",D++)),t.hard&&r[c]>e){let p=e-D,E=1+Math.floor((r[c]-p-1)/e);Math.floor((r[c]-1)/e)<E&&o.push(""),nt(o,l,e);continue}if(D+r[c]>e&&D>0&&r[c]>0){if(t.wordWrap===!1&&D<e){nt(o,l,e);continue}o.push("")}if(D+r[c]>e&&t.wordWrap===!1){nt(o,l,e);continue}o[o.length-1]+=l}t.trim!==!1&&(o=o.map(c=>Ks(c)));let a=[...o.join(`
28
- `)];for(let[c,l]of a.entries()){if(i+=l,ye.has(l)){let{groups:p}=new RegExp(`(?:\\${Dr}(?<code>\\d+)m|\\${lt}(?<uri>.*)${at})`).exec(a.slice(c).join(""))||{groups:{}};if(p.code!==void 0){let E=Number.parseFloat(p.code);n=E===Ls?void 0:E}else p.uri!==void 0&&(u=p.uri.length===0?void 0:p.uri)}let D=qs.codes.get(Number(n));a[c+1]===`
29
- `?(u&&(i+=tr("")),n&&D&&(i+=er(D))):l===`
30
- `&&(n&&D&&(i+=er(n)),u&&(i+=tr(u)))}return i};function rr(s,e,t){return String(s).normalize().replace(/\r\n/g,`
24
+ `),this.outputHelp({error:!0}));let i=t||{},s=i.exitCode||1,o=i.code||"commander.error";this._exit(s,o,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in g.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,g.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new li(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(s=>!t(s)).forEach(s=>{this.setOptionValueWithSource(s,i.implied[s],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=n=>{let u=n.attributeName(),a=this.getOptionValue(u),c=this.options.find(D=>D.negate&&u===D.attributeName()),l=this.options.find(D=>!D.negate&&u===D.attributeName());return c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg)?c:l||n},s=n=>{let u=i(n),a=u.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},o=`error: ${s(e)} cannot be used with ${s(t)}`;this.error(o,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let s=[],o=this;do{let n=o.createHelp().visibleOptions(o).filter(u=>u.long).map(u=>u.long);s=s.concat(n),o=o.parent}while(o&&!o._enablePositionalOptions);t=dr(e,s)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,i=t===1?"":"s",o=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(o,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let s=[];this.createHelp().visibleCommands(this).forEach(o=>{s.push(o.name()),o.alias()&&s.push(o.alias())}),t=dr(e,s)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let s=this.createOption(t,i);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.name(),()=>{this._outputConfiguration.writeOut(`${e}
25
+ `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(e);if(i){let s=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${s}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>ui(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=Q.basename(e,Q.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),i=this._getOutputContext(e);t.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let s=t.formatHelp(this,t);return i.hasColors?s:this._outputConfiguration.stripColor(s)}_getOutputContext(e){e=e||{};let t=!!e.error,i,s,o;return t?(i=u=>this._outputConfiguration.writeErr(u),s=this._outputConfiguration.getErrHasColors(),o=this._outputConfiguration.getErrHelpWidth()):(i=u=>this._outputConfiguration.writeOut(u),s=this._outputConfiguration.getOutHasColors(),o=this._outputConfiguration.getOutHelpWidth()),{error:t,write:u=>(s||(u=this._outputConfiguration.stripColor(u)),i(u)),hasColors:s,helpWidth:o}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getOutputContext(e),s={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(n=>n.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let o=this.helpInformation({error:i.error});if(t&&(o=t(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(o),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(n=>n.emit("afterAllHelp",s))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(g.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.
26
+ Expecting one of '${i.join("', '")}'`);let s=`${e}Help`;return this.on(s,o=>{let n;typeof t=="function"?n=t({error:o.error,command:o.command}):n=t,n&&o.write(`${n}
27
+ `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function pr(r){return r.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",s="9229",o;return(o=e.match(/^(--inspect(-brk)?)$/))!==null?t=o[1]:(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=o[1],/^\d+$/.test(o[3])?s=o[3]:i=o[3]):(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=o[1],i=o[3],s=o[4]),t&&s!=="0"?`${t}=${i}:${parseInt(s)+1}`:e})}function pt(){if(g.env.NO_COLOR||g.env.FORCE_COLOR==="0"||g.env.FORCE_COLOR==="false")return!1;if(g.env.FORCE_COLOR||g.env.CLICOLOR_FORCE!==void 0)return!0}ht.Command=dt;ht.useColor=pt});var Cr=q(R=>{var{Argument:mr}=$e(),{Command:mt}=hr(),{CommanderError:Di,InvalidArgumentError:fr}=fe(),{Help:di}=st(),{Option:gr}=ct();R.program=new mt;R.createCommand=r=>new mt(r);R.createOption=(r,e)=>new gr(r,e);R.createArgument=(r,e)=>new mr(r,e);R.Command=mt;R.Option=gr;R.Argument=mr;R.Help=di;R.CommanderError=Di;R.InvalidArgumentError=fr;R.InvalidOptionArgumentError=fr});var Ct=q((Co,Er)=>{"use strict";var ft="\x1B",w=`${ft}[`,pi="\x07",gt={to(r,e){return e?`${w}${e+1};${r+1}H`:`${w}${r+1}G`},move(r,e){let t="";return r<0?t+=`${w}${-r}D`:r>0&&(t+=`${w}${r}C`),e<0?t+=`${w}${-e}A`:e>0&&(t+=`${w}${e}B`),t},up:(r=1)=>`${w}${r}A`,down:(r=1)=>`${w}${r}B`,forward:(r=1)=>`${w}${r}C`,backward:(r=1)=>`${w}${r}D`,nextLine:(r=1)=>`${w}E`.repeat(r),prevLine:(r=1)=>`${w}F`.repeat(r),left:`${w}G`,hide:`${w}?25l`,show:`${w}?25h`,save:`${ft}7`,restore:`${ft}8`},hi={up:(r=1)=>`${w}S`.repeat(r),down:(r=1)=>`${w}T`.repeat(r)},mi={screen:`${w}2J`,up:(r=1)=>`${w}1J`.repeat(r),down:(r=1)=>`${w}J`.repeat(r),line:`${w}2K`,lineEnd:`${w}K`,lineStart:`${w}1K`,lines(r){let e="";for(let t=0;t<r;t++)e+=this.line+(t<r-1?gt.up():"");return r&&(e+=gt.left),e}};Er.exports={cursor:gt,scroll:hi,erase:mi,beep:pi}});var Be=q((Fo,Ft)=>{var xe=process||{},br=xe.argv||[],Ae=xe.env||{},fi=!(Ae.NO_COLOR||br.includes("--no-color"))&&(!!Ae.FORCE_COLOR||br.includes("--color")||xe.platform==="win32"||(xe.stdout||{}).isTTY&&Ae.TERM!=="dumb"||!!Ae.CI),gi=(r,e,t=r)=>i=>{let s=""+i,o=s.indexOf(e,r.length);return~o?r+Ci(s,e,t,o)+e:r+s+e},Ci=(r,e,t,i)=>{let s="",o=0;do s+=r.substring(o,i)+t,o=i+e.length,i=r.indexOf(e,o);while(~i);return s+r.substring(o)},vr=(r=fi)=>{let e=r?gi:()=>String;return{isColorSupported:r,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};Ft.exports=vr();Ft.exports.createColors=vr});var It=q((So,Xr)=>{"use strict";var Pt=Object.defineProperty,rs=Object.getOwnPropertyDescriptor,ns=Object.getOwnPropertyNames,is=Object.prototype.hasOwnProperty,ss=(r,e)=>{for(var t in e)Pt(r,t,{get:e[t],enumerable:!0})},os=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ns(e))!is.call(r,s)&&s!==t&&Pt(r,s,{get:()=>e[s],enumerable:!(i=rs(e,s))||i.enumerable});return r},us=r=>os(Pt({},"__esModule",{value:!0}),r),Zr={};ss(Zr,{default:()=>ls});Xr.exports=us(Zr);var as=class{baseUrl;defaultHeaders;constructor(r,e={}){this.baseUrl=r,this.defaultHeaders=e}buildUrl(r){return`${this.baseUrl.replace(/\/$/,"")}/${r.replace(/^\//,"")}`}async request(r,e,t,i={}){let s=this.buildUrl(e),o=await fetch(s,{method:r,headers:{"Content-Type":"application/json",...this.defaultHeaders,...i},body:t?JSON.stringify(t):void 0});if(!o.ok){let u=await o.text().catch(()=>"");throw new Error(`HTTP ${o.status} ${o.statusText}: ${u||"Request failed"}`)}let n=await o.text();try{return JSON.parse(n)}catch{return n}}get(r,e){return this.request("GET",r,void 0,e)}post(r,e,t){return this.request("POST",r,e,t)}put(r,e,t){return this.request("PUT",r,e,t)}delete(r,e){return this.request("DELETE",r,void 0,e)}},cs=class{api;apiToken;constructor(r){this.apiToken=r?.apiToken,this.api=new as("https://api.derived.dev/api",{...this.apiToken?{Authorization:this.apiToken}:{}})}fetchBlock=async r=>this.api.get(`/public/v1/template-group/code/${r}`);getBlockInputFromUserQuery=(r,e)=>this.api.post("/public/v1/template-group/get-block-input-from-user-query",{blockInput:r,query:e});resolveMultipleTemplates=(r,e)=>this.api.post("/public/v1/template-group/resolve-multiple-templates-by-block-code",{blockCode:r,data:e});searchBlocksByName=(r,e)=>this.api.get(`/public/v1/template-group/semantic-search?q=${r}&limit=5&threshold=0.5&project_id=${e}`);fetchProjectBySlug=async r=>this.api.get(`/public/v1/project/detail-by-slug/${r}`);createMultipleTemplates=async r=>this.api.post("/v1/template/create-multiple",r);createTemplateGroup=async r=>this.api.post("/v1/template-group/create",r);getProjectCategories=async(r,e=20,t=1)=>{let i=encodeURIComponent(JSON.stringify({projectID:r})),s=encodeURIComponent(JSON.stringify({Desc:"id"}));return this.api.get(`/v1/block-category/list?filters=${i}&sort=${s}&limit=${e}&page=${t}`)};createCategory=async r=>this.api.post("/v1/block-category/create",r);updateTemplateGroup=async(r,e)=>this.api.put(`/v1/template-group/update/${r}`,e)},ls=cs});var In={};sr(In,{isDirectoryEmpty:()=>Ws,removeGitDirectory:()=>Ls});function Ws(r){return(0,le.existsSync)(r)?(0,le.readdirSync)(r).filter(i=>!i.startsWith(".")).length===0:!0}function Ls(r){let e=(0,Pn.join)(r,".git");(0,le.existsSync)(e)&&(0,le.rmSync)(e,{recursive:!0,force:!0})}var le,Pn,Nn=Yn(()=>{"use strict";le=require("fs"),Pn=require("path")});var Qs={};sr(Qs,{displayFileTree:()=>Hn});module.exports=Qn(Qs);var Fr=b(Cr(),1),{program:oo,createCommand:uo,createArgument:ao,createOption:co,CommanderError:lo,InvalidArgumentError:Do,InvalidOptionArgumentError:po,Command:yr,Argument:ho,Option:mo,Help:fo}=Fr.default;var Pe=require("node:util");var S=b(Ct(),1),pe=require("node:process"),te=b(require("node:readline"),1),bt=b(require("node:readline"),1),kr=require("node:stream"),jr=b(Be(),1);function Fi({onlyFirst:r=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,r?void 0:"g")}var yi=Fi();function Tr(r){if(typeof r!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof r}\``);return r.replace(yi,"")}function Pr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ir={exports:{}};(function(r){var e={};r.exports=e,e.eastAsianWidth=function(i){var s=i.charCodeAt(0),o=i.length==2?i.charCodeAt(1):0,n=s;return 55296<=s&&s<=56319&&56320<=o&&o<=57343&&(s&=1023,o&=1023,n=s<<10|o,n+=65536),n==12288||65281<=n&&n<=65376||65504<=n&&n<=65510?"F":n==8361||65377<=n&&n<=65470||65474<=n&&n<=65479||65482<=n&&n<=65487||65490<=n&&n<=65495||65498<=n&&n<=65500||65512<=n&&n<=65518?"H":4352<=n&&n<=4447||4515<=n&&n<=4519||4602<=n&&n<=4607||9001<=n&&n<=9002||11904<=n&&n<=11929||11931<=n&&n<=12019||12032<=n&&n<=12245||12272<=n&&n<=12283||12289<=n&&n<=12350||12353<=n&&n<=12438||12441<=n&&n<=12543||12549<=n&&n<=12589||12593<=n&&n<=12686||12688<=n&&n<=12730||12736<=n&&n<=12771||12784<=n&&n<=12830||12832<=n&&n<=12871||12880<=n&&n<=13054||13056<=n&&n<=19903||19968<=n&&n<=42124||42128<=n&&n<=42182||43360<=n&&n<=43388||44032<=n&&n<=55203||55216<=n&&n<=55238||55243<=n&&n<=55291||63744<=n&&n<=64255||65040<=n&&n<=65049||65072<=n&&n<=65106||65108<=n&&n<=65126||65128<=n&&n<=65131||110592<=n&&n<=110593||127488<=n&&n<=127490||127504<=n&&n<=127546||127552<=n&&n<=127560||127568<=n&&n<=127569||131072<=n&&n<=194367||177984<=n&&n<=196605||196608<=n&&n<=262141?"W":32<=n&&n<=126||162<=n&&n<=163||165<=n&&n<=166||n==172||n==175||10214<=n&&n<=10221||10629<=n&&n<=10630?"Na":n==161||n==164||167<=n&&n<=168||n==170||173<=n&&n<=174||176<=n&&n<=180||182<=n&&n<=186||188<=n&&n<=191||n==198||n==208||215<=n&&n<=216||222<=n&&n<=225||n==230||232<=n&&n<=234||236<=n&&n<=237||n==240||242<=n&&n<=243||247<=n&&n<=250||n==252||n==254||n==257||n==273||n==275||n==283||294<=n&&n<=295||n==299||305<=n&&n<=307||n==312||319<=n&&n<=322||n==324||328<=n&&n<=331||n==333||338<=n&&n<=339||358<=n&&n<=359||n==363||n==462||n==464||n==466||n==468||n==470||n==472||n==474||n==476||n==593||n==609||n==708||n==711||713<=n&&n<=715||n==717||n==720||728<=n&&n<=731||n==733||n==735||768<=n&&n<=879||913<=n&&n<=929||931<=n&&n<=937||945<=n&&n<=961||963<=n&&n<=969||n==1025||1040<=n&&n<=1103||n==1105||n==8208||8211<=n&&n<=8214||8216<=n&&n<=8217||8220<=n&&n<=8221||8224<=n&&n<=8226||8228<=n&&n<=8231||n==8240||8242<=n&&n<=8243||n==8245||n==8251||n==8254||n==8308||n==8319||8321<=n&&n<=8324||n==8364||n==8451||n==8453||n==8457||n==8467||n==8470||8481<=n&&n<=8482||n==8486||n==8491||8531<=n&&n<=8532||8539<=n&&n<=8542||8544<=n&&n<=8555||8560<=n&&n<=8569||n==8585||8592<=n&&n<=8601||8632<=n&&n<=8633||n==8658||n==8660||n==8679||n==8704||8706<=n&&n<=8707||8711<=n&&n<=8712||n==8715||n==8719||n==8721||n==8725||n==8730||8733<=n&&n<=8736||n==8739||n==8741||8743<=n&&n<=8748||n==8750||8756<=n&&n<=8759||8764<=n&&n<=8765||n==8776||n==8780||n==8786||8800<=n&&n<=8801||8804<=n&&n<=8807||8810<=n&&n<=8811||8814<=n&&n<=8815||8834<=n&&n<=8835||8838<=n&&n<=8839||n==8853||n==8857||n==8869||n==8895||n==8978||9312<=n&&n<=9449||9451<=n&&n<=9547||9552<=n&&n<=9587||9600<=n&&n<=9615||9618<=n&&n<=9621||9632<=n&&n<=9633||9635<=n&&n<=9641||9650<=n&&n<=9651||9654<=n&&n<=9655||9660<=n&&n<=9661||9664<=n&&n<=9665||9670<=n&&n<=9672||n==9675||9678<=n&&n<=9681||9698<=n&&n<=9701||n==9711||9733<=n&&n<=9734||n==9737||9742<=n&&n<=9743||9748<=n&&n<=9749||n==9756||n==9758||n==9792||n==9794||9824<=n&&n<=9825||9827<=n&&n<=9829||9831<=n&&n<=9834||9836<=n&&n<=9837||n==9839||9886<=n&&n<=9887||9918<=n&&n<=9919||9924<=n&&n<=9933||9935<=n&&n<=9953||n==9955||9960<=n&&n<=9983||n==10045||n==10071||10102<=n&&n<=10111||11093<=n&&n<=11097||12872<=n&&n<=12879||57344<=n&&n<=63743||65024<=n&&n<=65039||n==65533||127232<=n&&n<=127242||127248<=n&&n<=127277||127280<=n&&n<=127337||127344<=n&&n<=127386||917760<=n&&n<=917999||983040<=n&&n<=1048573||1048576<=n&&n<=1114109?"A":"N"},e.characterLength=function(i){var s=this.eastAsianWidth(i);return s=="F"||s=="W"||s=="A"?2:1};function t(i){return i.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}e.length=function(i){for(var s=t(i),o=0,n=0;n<s.length;n++)o=o+this.characterLength(s[n]);return o},e.slice=function(i,s,o){textLen=e.length(i),s=s||0,o=o||1,s<0&&(s=textLen+s),o<0&&(o=textLen+o);for(var n="",u=0,a=t(i),c=0;c<a.length;c++){var l=a[c],D=e.length(l);if(u>=s-(D==2?1:0))if(u+D<=o)n+=l;else break;u+=D}return n}})(Ir);var Ei=Ir.exports,bi=Pr(Ei),vi=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(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},$i=Pr(vi);function ge(r,e={}){if(typeof r!="string"||r.length===0||(e={ambiguousIsNarrow:!0,...e},r=Tr(r),r.length===0))return 0;r=r.replace($i()," ");let t=e.ambiguousIsNarrow?1:2,i=0;for(let s of r){let o=s.codePointAt(0);if(!(o<=31||o>=127&&o<=159||o>=768&&o<=879))switch(bi.eastAsianWidth(s)){case"F":case"W":i+=2;break;case"A":i+=t;break;default:i+=1}}return i}var yt=10,$r=(r=0)=>e=>`\x1B[${e+r}m`,wr=(r=0)=>e=>`\x1B[${38+r};5;${e}m`,Ar=(r=0)=>(e,t,i)=>`\x1B[${38+r};2;${e};${t};${i}m`,v={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(v.modifier);var wi=Object.keys(v.color),Ai=Object.keys(v.bgColor);[...wi,...Ai];function xi(){let r=new Map;for(let[e,t]of Object.entries(v)){for(let[i,s]of Object.entries(t))v[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},t[i]=v[i],r.set(s[0],s[1]);Object.defineProperty(v,e,{value:t,enumerable:!1})}return Object.defineProperty(v,"codes",{value:r,enumerable:!1}),v.color.close="\x1B[39m",v.bgColor.close="\x1B[49m",v.color.ansi=$r(),v.color.ansi256=wr(),v.color.ansi16m=Ar(),v.bgColor.ansi=$r(yt),v.bgColor.ansi256=wr(yt),v.bgColor.ansi16m=Ar(yt),Object.defineProperties(v,{rgbToAnsi256:{value:(e,t,i)=>e===t&&t===i?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[i]=t;i.length===3&&(i=[...i].map(o=>o+o).join(""));let s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:e=>v.rgbToAnsi256(...v.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,i,s;if(e>=232)t=((e-232)*10+8)/255,i=t,s=t;else{e-=16;let u=e%36;t=Math.floor(e/36)/5,i=Math.floor(u/6)/5,s=u%6/5}let o=Math.max(t,i,s)*2;if(o===0)return 30;let n=30+(Math.round(s)<<2|Math.round(i)<<1|Math.round(t));return o===2&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(e,t,i)=>v.ansi256ToAnsi(v.rgbToAnsi256(e,t,i)),enumerable:!1},hexToAnsi:{value:e=>v.ansi256ToAnsi(v.hexToAnsi256(e)),enumerable:!1}}),v}var Bi=xi(),Te=new Set(["\x1B","\x9B"]),_i=39,$t="\x07",Nr="[",Oi="]",Rr="m",wt=`${Oi}8;;`,xr=r=>`${Te.values().next().value}${Nr}${r}${Rr}`,Br=r=>`${Te.values().next().value}${wt}${r}${$t}`,Si=r=>r.split(" ").map(e=>ge(e)),Et=(r,e,t)=>{let i=[...e],s=!1,o=!1,n=ge(Tr(r[r.length-1]));for(let[u,a]of i.entries()){let c=ge(a);if(n+c<=t?r[r.length-1]+=a:(r.push(a),n=0),Te.has(a)&&(s=!0,o=i.slice(u+1).join("").startsWith(wt)),s){o?a===$t&&(s=!1,o=!1):a===Rr&&(s=!1);continue}n+=c,n===t&&u<i.length-1&&(r.push(""),n=0)}!n&&r[r.length-1].length>0&&r.length>1&&(r[r.length-2]+=r.pop())},ki=r=>{let e=r.split(" "),t=e.length;for(;t>0&&!(ge(e[t-1])>0);)t--;return t===e.length?r:e.slice(0,t).join(" ")+e.slice(t).join("")},ji=(r,e,t={})=>{if(t.trim!==!1&&r.trim()==="")return"";let i="",s,o,n=Si(r),u=[""];for(let[c,l]of r.split(" ").entries()){t.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let D=ge(u[u.length-1]);if(c!==0&&(D>=e&&(t.wordWrap===!1||t.trim===!1)&&(u.push(""),D=0),(D>0||t.trim===!1)&&(u[u.length-1]+=" ",D++)),t.hard&&n[c]>e){let h=e-D,E=1+Math.floor((n[c]-h-1)/e);Math.floor((n[c]-1)/e)<E&&u.push(""),Et(u,l,e);continue}if(D+n[c]>e&&D>0&&n[c]>0){if(t.wordWrap===!1&&D<e){Et(u,l,e);continue}u.push("")}if(D+n[c]>e&&t.wordWrap===!1){Et(u,l,e);continue}u[u.length-1]+=l}t.trim!==!1&&(u=u.map(c=>ki(c)));let a=[...u.join(`
28
+ `)];for(let[c,l]of a.entries()){if(i+=l,Te.has(l)){let{groups:h}=new RegExp(`(?:\\${Nr}(?<code>\\d+)m|\\${wt}(?<uri>.*)${$t})`).exec(a.slice(c).join(""))||{groups:{}};if(h.code!==void 0){let E=Number.parseFloat(h.code);s=E===_i?void 0:E}else h.uri!==void 0&&(o=h.uri.length===0?void 0:h.uri)}let D=Bi.codes.get(Number(s));a[c+1]===`
29
+ `?(o&&(i+=Br("")),s&&D&&(i+=xr(D))):l===`
30
+ `&&(s&&D&&(i+=xr(s)),o&&(i+=Br(o)))}return i};function _r(r,e,t){return String(r).normalize().replace(/\r\n/g,`
31
31
  `).split(`
32
- `).map(i=>zs(i,e,t)).join(`
33
- `)}var Ys=["up","down","left","right","space","enter","cancel"],ge={actions:new Set(Ys),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]])};function Dt(s,e){if(typeof s=="string")return ge.aliases.get(s)===e;for(let t of s)if(t!==void 0&&Dt(t,e))return!0;return!1}function Qs(s,e){if(s===e)return;let t=s.split(`
32
+ `).map(i=>ji(i,e,t)).join(`
33
+ `)}var Ti=["up","down","left","right","space","enter","cancel"],Oe={actions:new Set(Ti),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]])};function At(r,e){if(typeof r=="string")return Oe.aliases.get(r)===e;for(let t of r)if(t!==void 0&&At(t,e))return!0;return!1}function Pi(r,e){if(r===e)return;let t=r.split(`
34
34
  `),i=e.split(`
35
- `),n=[];for(let u=0;u<Math.max(t.length,i.length);u++)t[u]!==i[u]&&n.push(u);return n}var Zs=globalThis.process.platform.startsWith("win"),ot=Symbol("clack:cancel");function G(s){return s===ot}function fe(s,e){let t=s;t.isTTY&&t.setRawMode(e)}function hr({input:s=re.stdin,output:e=re.stdout,overwrite:t=!0,hideCursor:i=!0}={}){let n=H.createInterface({input:s,output:e,prompt:"",tabSize:1});H.emitKeypressEvents(s,n),s.isTTY&&s.setRawMode(!0);let u=(r,{name:o,sequence:a})=>{let c=String(r);if(Dt([c,o,a],"cancel")){i&&e.write(v.cursor.show),process.exit(0);return}if(!t)return;H.moveCursor(e,o==="return"?0:-1,o==="return"?-1:0,()=>{H.clearLine(e,1,()=>{s.once("keypress",u)})})};return i&&e.write(v.cursor.hide),s.once("keypress",u),()=>{s.off("keypress",u),i&&e.write(v.cursor.show),s.isTTY&&!Zs&&s.setRawMode(!1),n.terminal=!1,n.close()}}var Xs=Object.defineProperty,ei=(s,e,t)=>e in s?Xs(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,x=(s,e,t)=>(ei(s,typeof e!="symbol"?e+"":e,t),t),te=class{constructor(e,t=!0){x(this,"input"),x(this,"output"),x(this,"_abortSignal"),x(this,"rl"),x(this,"opts"),x(this,"_render"),x(this,"_track",!1),x(this,"_prevFrame",""),x(this,"_subscribers",new Map),x(this,"_cursor",0),x(this,"state","initial"),x(this,"error",""),x(this,"value");let{input:i=re.stdin,output:n=re.stdout,render:u,signal:r,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=u.bind(this),this._track=t,this._abortSignal=r,this.input=i,this.output=n}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let i=this._subscribers.get(e)??[];i.push(t),this._subscribers.set(e,i)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let i=this._subscribers.get(e)??[],n=[];for(let u of i)u.cb(...t),u.once&&n.push(()=>i.splice(i.indexOf(u),1));for(let u of n)u()}prompt(){return new Promise((e,t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(ot);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let i=new nr.Writable;i._write=(n,u,r)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),r()},this.input.pipe(i),this.rl=ut.default.createInterface({input:this.input,output:i,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),ut.default.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),fe(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(v.cursor.show),this.output.off("resize",this.render),fe(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(v.cursor.show),this.output.off("resize",this.render),fe(this.input,!1),e(ot)})})}onKeypress(e,t){if(this.state==="error"&&(this.state="active"),t?.name&&(!this._track&&ge.aliases.has(t.name)&&this.emit("cursor",ge.aliases.get(t.name)),ge.actions.has(t.name)&&this.emit("cursor",t.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),e===" "&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),e&&this.emit("key",e.toLowerCase()),t?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i instanceof Error?i.message:i,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}Dt([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
36
- `),fe(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=rr(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
37
- `).length-1;this.output.write(v.cursor.move(-999,e*-1))}render(){let e=rr(this._render(this)??"",process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(v.cursor.hide);else{let t=Qs(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let i=t[0];this.output.write(v.cursor.move(0,i)),this.output.write(v.erase.lines(1));let n=e.split(`
38
- `);this.output.write(n[i]),this._prevFrame=e,this.output.write(v.cursor.move(0,n.length-i-1));return}if(t&&t?.length>1){let i=t[0];this.output.write(v.cursor.move(0,i)),this.output.write(v.erase.down());let n=e.split(`
39
- `).slice(i);this.output.write(n.join(`
40
- `)),this._prevFrame=e;return}this.output.write(v.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}},Ce=class extends te{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",t=>{this.output.write(v.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var ti;ti=new WeakMap;var ri=Object.defineProperty,si=(s,e,t)=>e in s?ri(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,sr=(s,e,t)=>(si(s,typeof e!="symbol"?e+"":e,t),t),pr=class extends te{constructor(s){super(s,!1),sr(this,"options"),sr(this,"cursor",0),this.options=s.options,this.value=[...s.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===s.cursorAt),0),this.on("key",e=>{e==="a"&&this.toggleAll()}),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let s=this.value.length===this.options.length;this.value=s?[]:this.options.map(e=>e.value)}toggleValue(){let s=this.value.includes(this._value);this.value=s?this.value.filter(e=>e!==this._value):[...this.value,this._value]}};var ii=Object.defineProperty,ni=(s,e,t)=>e in s?ii(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ir=(s,e,t)=>(ni(s,typeof e!="symbol"?e+"":e,t),t),Fe=class extends te{constructor(e){super(e,!1),ir(this,"options"),ir(this,"cursor",0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",t=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};var Ee=class extends te{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let e=this.value.slice(0,this.cursor),[t,...i]=this.value.slice(this.cursor);return`${e}${ur.default.inverse(t)}${i.join("")}`}get cursor(){return this._cursor}constructor(e){super(e),this.on("finalize",()=>{this.value||(this.value=e.defaultValue)})}};var S=C(require("node:process"),1),h=C(me(),1),ve=C(rt(),1);function ui(){return S.default.platform!=="win32"?S.default.env.TERM!=="linux":!!S.default.env.CI||!!S.default.env.WT_SESSION||!!S.default.env.TERMINUS_SUBLIME||S.default.env.ConEmuTask==="{cmd::Cmder}"||S.default.env.TERM_PROGRAM==="Terminus-Sublime"||S.default.env.TERM_PROGRAM==="vscode"||S.default.env.TERM==="xterm-256color"||S.default.env.TERM==="alacritty"||S.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var ct=ui(),b=(s,e)=>ct?s:e,oi=b("\u25C6","*"),fr=b("\u25A0","x"),gr=b("\u25B2","x"),$e=b("\u25C7","o"),ai=b("\u250C","T"),m=b("\u2502","|"),W=b("\u2514","\u2014"),ht=b("\u25CF",">"),pt=b("\u25CB"," "),li=b("\u25FB","[\u2022]"),dr=b("\u25FC","[+]"),Di=b("\u25FB","[ ]"),On=b("\u25AA","\u2022"),mr=b("\u2500","-"),ci=b("\u256E","+"),hi=b("\u251C","+"),pi=b("\u256F","+"),di=b("\u25CF","\u2022"),mi=b("\u25C6","*"),fi=b("\u25B2","!"),gi=b("\u25A0","x"),we=s=>{switch(s){case"initial":case"active":return h.default.cyan(oi);case"cancel":return h.default.red(fr);case"error":return h.default.yellow(gr);case"submit":return h.default.green($e)}},dt=s=>{let{cursor:e,options:t,style:i}=s,n=s.maxItems??Number.POSITIVE_INFINITY,u=Math.max(process.stdout.rows-4,0),r=Math.min(u,Math.max(n,5)),o=0;e>=o+r-3?o=Math.max(Math.min(e-r+3,t.length-r),0):e<o+2&&(o=Math.max(e-2,0));let a=r<t.length&&o>0,c=r<t.length&&o+r<t.length;return t.slice(o,o+r).map((l,D,p)=>{let E=D===0&&a,$=D===p.length-1&&c;return E||$?h.default.dim("..."):i(l,D+o===e)})},Cr=s=>new Ee({validate:s.validate,placeholder:s.placeholder,defaultValue:s.defaultValue,initialValue:s.initialValue,render(){let e=`${h.default.gray(m)}
41
- ${we(this.state)} ${s.message}
42
- `,t=s.placeholder?h.default.inverse(s.placeholder[0])+h.default.dim(s.placeholder.slice(1)):h.default.inverse(h.default.hidden("_")),i=this.value?this.valueWithCursor:t;switch(this.state){case"error":return`${e.trim()}
43
- ${h.default.yellow(m)} ${i}
44
- ${h.default.yellow(W)} ${h.default.yellow(this.error)}
45
- `;case"submit":return`${e}${h.default.gray(m)} ${h.default.dim(this.value||s.placeholder)}`;case"cancel":return`${e}${h.default.gray(m)} ${h.default.strikethrough(h.default.dim(this.value??""))}${this.value?.trim()?`
46
- ${h.default.gray(m)}`:""}`;default:return`${e}${h.default.cyan(m)} ${i}
47
- ${h.default.cyan(W)}
48
- `}}}).prompt();var Fr=s=>{let e=s.active??"Yes",t=s.inactive??"No";return new Ce({active:e,inactive:t,initialValue:s.initialValue??!0,render(){let i=`${h.default.gray(m)}
49
- ${we(this.state)} ${s.message}
50
- `,n=this.value?e:t;switch(this.state){case"submit":return`${i}${h.default.gray(m)} ${h.default.dim(n)}`;case"cancel":return`${i}${h.default.gray(m)} ${h.default.strikethrough(h.default.dim(n))}
51
- ${h.default.gray(m)}`;default:return`${i}${h.default.cyan(m)} ${this.value?`${h.default.green(ht)} ${e}`:`${h.default.dim(pt)} ${h.default.dim(e)}`} ${h.default.dim("/")} ${this.value?`${h.default.dim(pt)} ${h.default.dim(t)}`:`${h.default.green(ht)} ${t}`}
52
- ${h.default.cyan(W)}
53
- `}}}).prompt()},Ae=s=>{let e=(t,i)=>{let n=t.label??String(t.value);switch(i){case"selected":return`${h.default.dim(n)}`;case"active":return`${h.default.green(ht)} ${n} ${t.hint?h.default.dim(`(${t.hint})`):""}`;case"cancelled":return`${h.default.strikethrough(h.default.dim(n))}`;default:return`${h.default.dim(pt)} ${h.default.dim(n)}`}};return new Fe({options:s.options,initialValue:s.initialValue,render(){let t=`${h.default.gray(m)}
54
- ${we(this.state)} ${s.message}
55
- `;switch(this.state){case"submit":return`${t}${h.default.gray(m)} ${e(this.options[this.cursor],"selected")}`;case"cancel":return`${t}${h.default.gray(m)} ${e(this.options[this.cursor],"cancelled")}
56
- ${h.default.gray(m)}`;default:return`${t}${h.default.cyan(m)} ${dt({cursor:this.cursor,options:this.options,maxItems:s.maxItems,style:(i,n)=>e(i,n?"active":"inactive")}).join(`
57
- ${h.default.cyan(m)} `)}
58
- ${h.default.cyan(W)}
59
- `}}}).prompt()};var Er=s=>{let e=(t,i)=>{let n=t.label??String(t.value);return i==="active"?`${h.default.cyan(li)} ${n} ${t.hint?h.default.dim(`(${t.hint})`):""}`:i==="selected"?`${h.default.green(dr)} ${h.default.dim(n)} ${t.hint?h.default.dim(`(${t.hint})`):""}`:i==="cancelled"?`${h.default.strikethrough(h.default.dim(n))}`:i==="active-selected"?`${h.default.green(dr)} ${n} ${t.hint?h.default.dim(`(${t.hint})`):""}`:i==="submitted"?`${h.default.dim(n)}`:`${h.default.dim(Di)} ${h.default.dim(n)}`};return new pr({options:s.options,initialValues:s.initialValues,required:s.required??!0,cursorAt:s.cursorAt,validate(t){if(this.required&&t.length===0)return`Please select at least one option.
60
- ${h.default.reset(h.default.dim(`Press ${h.default.gray(h.default.bgWhite(h.default.inverse(" space ")))} to select, ${h.default.gray(h.default.bgWhite(h.default.inverse(" enter ")))} to submit`))}`},render(){let t=`${h.default.gray(m)}
61
- ${we(this.state)} ${s.message}
62
- `,i=(n,u)=>{let r=this.value.includes(n.value);return u&&r?e(n,"active-selected"):r?e(n,"selected"):e(n,u?"active":"inactive")};switch(this.state){case"submit":return`${t}${h.default.gray(m)} ${this.options.filter(({value:n})=>this.value.includes(n)).map(n=>e(n,"submitted")).join(h.default.dim(", "))||h.default.dim("none")}`;case"cancel":{let n=this.options.filter(({value:u})=>this.value.includes(u)).map(u=>e(u,"cancelled")).join(h.default.dim(", "));return`${t}${h.default.gray(m)} ${n.trim()?`${n}
63
- ${h.default.gray(m)}`:""}`}case"error":{let n=this.error.split(`
64
- `).map((u,r)=>r===0?`${h.default.yellow(W)} ${h.default.yellow(u)}`:` ${u}`).join(`
65
- `);return`${t+h.default.yellow(m)} ${dt({options:this.options,cursor:this.cursor,maxItems:s.maxItems,style:i}).join(`
66
- ${h.default.yellow(m)} `)}
67
- ${n}
68
- `}default:return`${t}${h.default.cyan(m)} ${dt({options:this.options,cursor:this.cursor,maxItems:s.maxItems,style:i}).join(`
69
- ${h.default.cyan(m)} `)}
70
- ${h.default.cyan(W)}
71
- `}}}).prompt()};var R=(s="",e="")=>{let t=`
35
+ `),s=[];for(let o=0;o<Math.max(t.length,i.length);o++)t[o]!==i[o]&&s.push(o);return s}var Ii=globalThis.process.platform.startsWith("win"),vt=Symbol("clack:cancel");function J(r){return r===vt}function _e(r,e){let t=r;t.isTTY&&t.setRawMode(e)}function Mr({input:r=pe.stdin,output:e=pe.stdout,overwrite:t=!0,hideCursor:i=!0}={}){let s=te.createInterface({input:r,output:e,prompt:"",tabSize:1});te.emitKeypressEvents(r,s),r.isTTY&&r.setRawMode(!0);let o=(n,{name:u,sequence:a})=>{let c=String(n);if(At([c,u,a],"cancel")){i&&e.write(S.cursor.show),process.exit(0);return}if(!t)return;te.moveCursor(e,u==="return"?0:-1,u==="return"?-1:0,()=>{te.clearLine(e,1,()=>{r.once("keypress",o)})})};return i&&e.write(S.cursor.hide),r.once("keypress",o),()=>{r.off("keypress",o),i&&e.write(S.cursor.show),r.isTTY&&!Ii&&r.setRawMode(!1),s.terminal=!1,s.close()}}var Ni=Object.defineProperty,Ri=(r,e,t)=>e in r?Ni(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,P=(r,e,t)=>(Ri(r,typeof e!="symbol"?e+"":e,t),t),de=class{constructor(e,t=!0){P(this,"input"),P(this,"output"),P(this,"_abortSignal"),P(this,"rl"),P(this,"opts"),P(this,"_render"),P(this,"_track",!1),P(this,"_prevFrame",""),P(this,"_subscribers",new Map),P(this,"_cursor",0),P(this,"state","initial"),P(this,"error",""),P(this,"value");let{input:i=pe.stdin,output:s=pe.stdout,render:o,signal:n,...u}=e;this.opts=u,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=o.bind(this),this._track=t,this._abortSignal=n,this.input=i,this.output=s}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let i=this._subscribers.get(e)??[];i.push(t),this._subscribers.set(e,i)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let i=this._subscribers.get(e)??[],s=[];for(let o of i)o.cb(...t),o.once&&s.push(()=>i.splice(i.indexOf(o),1));for(let o of s)o()}prompt(){return new Promise((e,t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(vt);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let i=new kr.Writable;i._write=(s,o,n)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),n()},this.input.pipe(i),this.rl=bt.default.createInterface({input:this.input,output:i,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),bt.default.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),_e(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(S.cursor.show),this.output.off("resize",this.render),_e(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(S.cursor.show),this.output.off("resize",this.render),_e(this.input,!1),e(vt)})})}onKeypress(e,t){if(this.state==="error"&&(this.state="active"),t?.name&&(!this._track&&Oe.aliases.has(t.name)&&this.emit("cursor",Oe.aliases.get(t.name)),Oe.actions.has(t.name)&&this.emit("cursor",t.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),e===" "&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),e&&this.emit("key",e.toLowerCase()),t?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i instanceof Error?i.message:i,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}At([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
36
+ `),_e(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=_r(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
37
+ `).length-1;this.output.write(S.cursor.move(-999,e*-1))}render(){let e=_r(this._render(this)??"",process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(S.cursor.hide);else{let t=Pi(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let i=t[0];this.output.write(S.cursor.move(0,i)),this.output.write(S.erase.lines(1));let s=e.split(`
38
+ `);this.output.write(s[i]),this._prevFrame=e,this.output.write(S.cursor.move(0,s.length-i-1));return}if(t&&t?.length>1){let i=t[0];this.output.write(S.cursor.move(0,i)),this.output.write(S.erase.down());let s=e.split(`
39
+ `).slice(i);this.output.write(s.join(`
40
+ `)),this._prevFrame=e;return}this.output.write(S.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}},Se=class extends de{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",t=>{this.output.write(S.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var Mi;Mi=new WeakMap;var Vi=Object.defineProperty,Gi=(r,e,t)=>e in r?Vi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Or=(r,e,t)=>(Gi(r,typeof e!="symbol"?e+"":e,t),t),Vr=class extends de{constructor(r){super(r,!1),Or(this,"options"),Or(this,"cursor",0),this.options=r.options,this.value=[...r.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===r.cursorAt),0),this.on("key",e=>{e==="a"&&this.toggleAll()}),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let r=this.value.length===this.options.length;this.value=r?[]:this.options.map(e=>e.value)}toggleValue(){let r=this.value.includes(this._value);this.value=r?this.value.filter(e=>e!==this._value):[...this.value,this._value]}};var Hi=Object.defineProperty,Wi=(r,e,t)=>e in r?Hi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Sr=(r,e,t)=>(Wi(r,typeof e!="symbol"?e+"":e,t),t),ke=class extends de{constructor(e){super(e,!1),Sr(this,"options"),Sr(this,"cursor",0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",t=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};var je=class extends de{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let e=this.value.slice(0,this.cursor),[t,...i]=this.value.slice(this.cursor);return`${e}${jr.default.inverse(t)}${i.join("")}`}get cursor(){return this._cursor}constructor(e){super(e),this.on("finalize",()=>{this.value||(this.value=e.defaultValue)})}};var M=b(require("node:process"),1),p=b(Be(),1),Ie=b(Ct(),1);function Li(){return M.default.platform!=="win32"?M.default.env.TERM!=="linux":!!M.default.env.CI||!!M.default.env.WT_SESSION||!!M.default.env.TERMINUS_SUBLIME||M.default.env.ConEmuTask==="{cmd::Cmder}"||M.default.env.TERM_PROGRAM==="Terminus-Sublime"||M.default.env.TERM_PROGRAM==="vscode"||M.default.env.TERM==="xterm-256color"||M.default.env.TERM==="alacritty"||M.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var xt=Li(),x=(r,e)=>xt?r:e,qi=x("\u25C6","*"),Wr=x("\u25A0","x"),Lr=x("\u25B2","x"),Ne=x("\u25C7","o"),Ji=x("\u250C","T"),f=x("\u2502","|"),re=x("\u2514","\u2014"),Bt=x("\u25CF",">"),_t=x("\u25CB"," "),Ui=x("\u25FB","[\u2022]"),Gr=x("\u25FC","[+]"),Ki=x("\u25FB","[ ]"),xo=x("\u25AA","\u2022"),Hr=x("\u2500","-"),zi=x("\u256E","+"),Yi=x("\u251C","+"),Qi=x("\u256F","+"),Zi=x("\u25CF","\u2022"),Xi=x("\u25C6","*"),es=x("\u25B2","!"),ts=x("\u25A0","x"),Re=r=>{switch(r){case"initial":case"active":return p.default.cyan(qi);case"cancel":return p.default.red(Wr);case"error":return p.default.yellow(Lr);case"submit":return p.default.green(Ne)}},Ot=r=>{let{cursor:e,options:t,style:i}=r,s=r.maxItems??Number.POSITIVE_INFINITY,o=Math.max(process.stdout.rows-4,0),n=Math.min(o,Math.max(s,5)),u=0;e>=u+n-3?u=Math.max(Math.min(e-n+3,t.length-n),0):e<u+2&&(u=Math.max(e-2,0));let a=n<t.length&&u>0,c=n<t.length&&u+n<t.length;return t.slice(u,u+n).map((l,D,h)=>{let E=D===0&&a,B=D===h.length-1&&c;return E||B?p.default.dim("..."):i(l,D+u===e)})},St=r=>new je({validate:r.validate,placeholder:r.placeholder,defaultValue:r.defaultValue,initialValue:r.initialValue,render(){let e=`${p.default.gray(f)}
41
+ ${Re(this.state)} ${r.message}
42
+ `,t=r.placeholder?p.default.inverse(r.placeholder[0])+p.default.dim(r.placeholder.slice(1)):p.default.inverse(p.default.hidden("_")),i=this.value?this.valueWithCursor:t;switch(this.state){case"error":return`${e.trim()}
43
+ ${p.default.yellow(f)} ${i}
44
+ ${p.default.yellow(re)} ${p.default.yellow(this.error)}
45
+ `;case"submit":return`${e}${p.default.gray(f)} ${p.default.dim(this.value||r.placeholder)}`;case"cancel":return`${e}${p.default.gray(f)} ${p.default.strikethrough(p.default.dim(this.value??""))}${this.value?.trim()?`
46
+ ${p.default.gray(f)}`:""}`;default:return`${e}${p.default.cyan(f)} ${i}
47
+ ${p.default.cyan(re)}
48
+ `}}}).prompt();var qr=r=>{let e=r.active??"Yes",t=r.inactive??"No";return new Se({active:e,inactive:t,initialValue:r.initialValue??!0,render(){let i=`${p.default.gray(f)}
49
+ ${Re(this.state)} ${r.message}
50
+ `,s=this.value?e:t;switch(this.state){case"submit":return`${i}${p.default.gray(f)} ${p.default.dim(s)}`;case"cancel":return`${i}${p.default.gray(f)} ${p.default.strikethrough(p.default.dim(s))}
51
+ ${p.default.gray(f)}`;default:return`${i}${p.default.cyan(f)} ${this.value?`${p.default.green(Bt)} ${e}`:`${p.default.dim(_t)} ${p.default.dim(e)}`} ${p.default.dim("/")} ${this.value?`${p.default.dim(_t)} ${p.default.dim(t)}`:`${p.default.green(Bt)} ${t}`}
52
+ ${p.default.cyan(re)}
53
+ `}}}).prompt()},Ce=r=>{let e=(t,i)=>{let s=t.label??String(t.value);switch(i){case"selected":return`${p.default.dim(s)}`;case"active":return`${p.default.green(Bt)} ${s} ${t.hint?p.default.dim(`(${t.hint})`):""}`;case"cancelled":return`${p.default.strikethrough(p.default.dim(s))}`;default:return`${p.default.dim(_t)} ${p.default.dim(s)}`}};return new ke({options:r.options,initialValue:r.initialValue,render(){let t=`${p.default.gray(f)}
54
+ ${Re(this.state)} ${r.message}
55
+ `;switch(this.state){case"submit":return`${t}${p.default.gray(f)} ${e(this.options[this.cursor],"selected")}`;case"cancel":return`${t}${p.default.gray(f)} ${e(this.options[this.cursor],"cancelled")}
56
+ ${p.default.gray(f)}`;default:return`${t}${p.default.cyan(f)} ${Ot({cursor:this.cursor,options:this.options,maxItems:r.maxItems,style:(i,s)=>e(i,s?"active":"inactive")}).join(`
57
+ ${p.default.cyan(f)} `)}
58
+ ${p.default.cyan(re)}
59
+ `}}}).prompt()};var Jr=r=>{let e=(t,i)=>{let s=t.label??String(t.value);return i==="active"?`${p.default.cyan(Ui)} ${s} ${t.hint?p.default.dim(`(${t.hint})`):""}`:i==="selected"?`${p.default.green(Gr)} ${p.default.dim(s)} ${t.hint?p.default.dim(`(${t.hint})`):""}`:i==="cancelled"?`${p.default.strikethrough(p.default.dim(s))}`:i==="active-selected"?`${p.default.green(Gr)} ${s} ${t.hint?p.default.dim(`(${t.hint})`):""}`:i==="submitted"?`${p.default.dim(s)}`:`${p.default.dim(Ki)} ${p.default.dim(s)}`};return new Vr({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(t){if(this.required&&t.length===0)return`Please select at least one option.
60
+ ${p.default.reset(p.default.dim(`Press ${p.default.gray(p.default.bgWhite(p.default.inverse(" space ")))} to select, ${p.default.gray(p.default.bgWhite(p.default.inverse(" enter ")))} to submit`))}`},render(){let t=`${p.default.gray(f)}
61
+ ${Re(this.state)} ${r.message}
62
+ `,i=(s,o)=>{let n=this.value.includes(s.value);return o&&n?e(s,"active-selected"):n?e(s,"selected"):e(s,o?"active":"inactive")};switch(this.state){case"submit":return`${t}${p.default.gray(f)} ${this.options.filter(({value:s})=>this.value.includes(s)).map(s=>e(s,"submitted")).join(p.default.dim(", "))||p.default.dim("none")}`;case"cancel":{let s=this.options.filter(({value:o})=>this.value.includes(o)).map(o=>e(o,"cancelled")).join(p.default.dim(", "));return`${t}${p.default.gray(f)} ${s.trim()?`${s}
63
+ ${p.default.gray(f)}`:""}`}case"error":{let s=this.error.split(`
64
+ `).map((o,n)=>n===0?`${p.default.yellow(re)} ${p.default.yellow(o)}`:` ${o}`).join(`
65
+ `);return`${t+p.default.yellow(f)} ${Ot({options:this.options,cursor:this.cursor,maxItems:r.maxItems,style:i}).join(`
66
+ ${p.default.yellow(f)} `)}
72
67
  ${s}
68
+ `}default:return`${t}${p.default.cyan(f)} ${Ot({options:this.options,cursor:this.cursor,maxItems:r.maxItems,style:i}).join(`
69
+ ${p.default.cyan(f)} `)}
70
+ ${p.default.cyan(re)}
71
+ `}}}).prompt()};var kt=(r="",e="")=>{let t=`
72
+ ${r}
73
73
  `.split(`
74
- `),i=(0,be.stripVTControlCharacters)(e).length,n=Math.max(t.reduce((r,o)=>{let a=(0,be.stripVTControlCharacters)(o);return a.length>r?a.length:r},0),i)+2,u=t.map(r=>`${h.default.gray(m)} ${h.default.dim(r)}${" ".repeat(n-(0,be.stripVTControlCharacters)(r).length)}${h.default.gray(m)}`).join(`
75
- `);process.stdout.write(`${h.default.gray(m)}
76
- ${h.default.green($e)} ${h.default.reset(e)} ${h.default.gray(mr.repeat(Math.max(n-i-1,1))+ci)}
77
- ${u}
78
- ${h.default.gray(hi+mr.repeat(n+2)+pi)}
79
- `)},d=(s="")=>{process.stdout.write(`${h.default.gray(W)} ${h.default.red(s)}
80
-
81
- `)},oe=(s="")=>{process.stdout.write(`${h.default.gray(ai)} ${s}
82
- `)},q=(s="")=>{process.stdout.write(`${h.default.gray(m)}
83
- ${h.default.gray(W)} ${s}
84
-
85
- `)},A={message:(s="",{symbol:e=h.default.gray(m)}={})=>{let t=[`${h.default.gray(m)}`];if(s){let[i,...n]=s.split(`
86
- `);t.push(`${e} ${i}`,...n.map(u=>`${h.default.gray(m)} ${u}`))}process.stdout.write(`${t.join(`
74
+ `),i=(0,Pe.stripVTControlCharacters)(e).length,s=Math.max(t.reduce((n,u)=>{let a=(0,Pe.stripVTControlCharacters)(u);return a.length>n?a.length:n},0),i)+2,o=t.map(n=>`${p.default.gray(f)} ${p.default.dim(n)}${" ".repeat(s-(0,Pe.stripVTControlCharacters)(n).length)}${p.default.gray(f)}`).join(`
75
+ `);process.stdout.write(`${p.default.gray(f)}
76
+ ${p.default.green(Ne)} ${p.default.reset(e)} ${p.default.gray(Hr.repeat(Math.max(s-i-1,1))+zi)}
77
+ ${o}
78
+ ${p.default.gray(Yi+Hr.repeat(s+2)+Qi)}
79
+ `)},jt=(r="")=>{process.stdout.write(`${p.default.gray(re)} ${p.default.red(r)}
80
+
81
+ `)},Ur=(r="")=>{process.stdout.write(`${p.default.gray(Ji)} ${r}
82
+ `)},Kr=(r="")=>{process.stdout.write(`${p.default.gray(f)}
83
+ ${p.default.gray(re)} ${r}
84
+
85
+ `)},U={message:(r="",{symbol:e=p.default.gray(f)}={})=>{let t=[`${p.default.gray(f)}`];if(r){let[i,...s]=r.split(`
86
+ `);t.push(`${e} ${i}`,...s.map(o=>`${p.default.gray(f)} ${o}`))}process.stdout.write(`${t.join(`
87
87
  `)}
88
- `)},info:s=>{A.message(s,{symbol:h.default.blue(di)})},success:s=>{A.message(s,{symbol:h.default.green(mi)})},step:s=>{A.message(s,{symbol:h.default.green($e)})},warn:s=>{A.message(s,{symbol:h.default.yellow(fi)})},warning:s=>{A.warn(s)},error:s=>{A.message(s,{symbol:h.default.red(gi)})}},kn=`${h.default.gray(m)} `;var B=({indicator:s="dots"}={})=>{let e=ct?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],t=ct?80:120,i=process.env.CI==="true",n,u,r=!1,o="",a,c=performance.now(),l=w=>{let O=w>1?"Something went wrong":"Canceled";r&&kt(O,w)},D=()=>l(2),p=()=>l(1),E=()=>{process.on("uncaughtExceptionMonitor",D),process.on("unhandledRejection",D),process.on("SIGINT",p),process.on("SIGTERM",p),process.on("exit",l)},$=()=>{process.removeListener("uncaughtExceptionMonitor",D),process.removeListener("unhandledRejection",D),process.removeListener("SIGINT",p),process.removeListener("SIGTERM",p),process.removeListener("exit",l)},X=()=>{if(a===void 0)return;i&&process.stdout.write(`
89
- `);let w=a.split(`
90
- `);process.stdout.write(ve.cursor.move(-999,w.length-1)),process.stdout.write(ve.erase.down(w.length))},J=w=>w.replace(/\.+$/,""),y=w=>{let O=(performance.now()-w)/1e3,P=Math.floor(O/60),ee=Math.floor(O%60);return P>0?`[${P}m ${ee}s]`:`[${ee}s]`},ns=(w="")=>{r=!0,n=hr(),o=J(w),c=performance.now(),process.stdout.write(`${h.default.gray(m)}
91
- `);let O=0,P=0;E(),u=setInterval(()=>{if(i&&o===a)return;X(),a=o;let ee=h.default.magenta(e[O]);if(i)process.stdout.write(`${ee} ${o}...`);else if(s==="timer")process.stdout.write(`${ee} ${o} ${y(c)}`);else{let us=".".repeat(Math.floor(P)).slice(0,3);process.stdout.write(`${ee} ${o}${us}`)}O=O+1<e.length?O+1:0,P=P<e.length?P+.125:0},t)},kt=(w="",O=0)=>{r=!1,clearInterval(u),X();let P=O===0?h.default.green($e):O===1?h.default.red(fr):h.default.red(gr);o=J(w??o),s==="timer"?process.stdout.write(`${P} ${o} ${y(c)}
92
- `):process.stdout.write(`${P} ${o}
93
- `),$(),n()};return{start:ns,stop:kt,message:(w="")=>{o=J(w??o)}}};var Xr=require("child_process"),T=require("fs"),es=require("os"),xt=require("path");var se=C(require("fs")),mt=C(require("path")),yr=(s,e=[],t=!1)=>{let i=[],n=[],u=[];for(let r of s){let o=mt.default.join(process.cwd(),r.resolvedPath);if(!r.isNotEnabled)try{if(se.default.mkdirSync(mt.default.dirname(o),{recursive:!0}),r.templateType==="add"){let a=se.default.existsSync(o)&&se.default.lstatSync(o).isFile(),c=t||e.includes(r.resolvedPath);if(a&&!c){u.push(`File already exists: ${o}`);continue}else{if(r.pathError||r.templateError){u.push(`Failed to create file: ${o} because of error: ${r.templateError}`);continue}se.default.writeFileSync(o,r.resolvedTemplate),i.push(o)}}else r.templateType==="modify"&&(r.modifiedFileContent?(se.default.writeFileSync(o,r.modifiedFileContent),n.push(o)):u.push(`Failed to modify file: ${o} because of error: ${r.templateError}`))}catch(a){u.push(a instanceof Error?a.message:String(a))}}return{addResults:i,modifyResults:n,errors:u}};var ie=C($r());var gt=C(me());function wr(s){let e={name:"root",type:"directory",children:[],path:""},t=s.map(i=>i.replace(/^\//,"").replace(/\\/g,"/")).sort();for(let i of t){let n=i.split("/").filter(Boolean),u=e;n.forEach((r,o)=>{let a=o===n.length-1,c=u.children?.find(l=>l.name===r);if(c)u=c;else{let l={name:r,type:a?"file":"directory",children:a?void 0:[],path:n.slice(0,o+1).join("/")};u.children||(u.children=[]),u.children.push(l),u=l}})}return e}function Be(s,e="",t=!0,i=!0){if(i&&s.children)return s.children.map((a,c)=>Be(a,"",c===s.children.length-1,!1)).join(`
94
- `);let n=t?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",u=s.type==="directory"?"\u{1F4C1} ":"\u{1F4C4} ",r=s.type==="directory"?gt.default.cyan(s.name+"/"):gt.default.green(s.name),o=e+n+u+r+`
95
- `;if(s.children&&s.children.length>0){let a=e+(t?" ":"\u2502 ");s.children.forEach((c,l)=>{o+=Be(c,a,l===s.children.length-1,!1)})}return o}var V=require("fs"),Ct=require("path"),_i=".derived",xi="blocks.json";function Ar(){return(0,Ct.join)(process.cwd(),_i)}function Br(){return(0,Ct.join)(Ar(),xi)}function Ft(s,e){if(s===e)return!0;if(s==null||e==null)return s===e;if(typeof s!=typeof e)return!1;if(typeof s!="object")return s===e;let t=Object.keys(s),i=Object.keys(e);if(t.length!==i.length)return!1;for(let n of t)if(!i.includes(n)||!Ft(s[n],e[n]))return!1;return!0}function _e(){let s=Br();if(!(0,V.existsSync)(s))return{addedBlocks:[]};try{let e=(0,V.readFileSync)(s,"utf-8"),t=JSON.parse(e);return Array.isArray(t.addedBlocks)?t.addedBlocks.length>0&&typeof t.addedBlocks[0]=="string"?{addedBlocks:t.addedBlocks.map(i=>({code:i,input:{}}))}:t:{addedBlocks:[]}}catch{return{addedBlocks:[]}}}function Oi(s){let e=Ar(),t=Br();(0,V.existsSync)(e)||(0,V.mkdirSync)(e,{recursive:!0}),(0,V.writeFileSync)(t,JSON.stringify(s,null,2))}function _r(s){return _e().addedBlocks.some(t=>t.code===s)}function Et(s,e){return _e().addedBlocks.find(n=>n.code===s&&Ft(n.input,e))||null}function xr(s,e){return _e().addedBlocks.filter(i=>i.code===s&&!Ft(i.input,e))}function Or(s,e={}){let t=_e();Et(s,e)||(t.addedBlocks.push({code:s,input:e}),Oi(t))}var z=require("child_process");function Sr(s){return e=>e.length>1?[s,"run",e[0],"--",...e.slice(1)]:[s,"run",e[0]]}function ki(){return s=>["deno","run",`npm:${s[0]}`,...s.slice(1)]}var Si={agent:["npm",0],run:Sr("npm"),install:["npm","i",0],frozen:["npm","ci",0],global:["npm","i","-g",0],add:["npm","i",0],upgrade:["npm","update",0],"upgrade-interactive":null,execute:["npx",0],"execute-local":["npx",0],uninstall:["npm","uninstall",0],global_uninstall:["npm","uninstall","-g",0]},Tr={agent:["yarn",0],run:["yarn","run",0],install:["yarn","install",0],frozen:["yarn","install","--frozen-lockfile",0],global:["yarn","global","add",0],add:["yarn","add",0],upgrade:["yarn","upgrade",0],"upgrade-interactive":["yarn","upgrade-interactive",0],execute:["npx",0],"execute-local":["yarn","exec",0],uninstall:["yarn","remove",0],global_uninstall:["yarn","global","remove",0]},Ti={...Tr,frozen:["yarn","install","--immutable",0],upgrade:["yarn","up",0],"upgrade-interactive":["yarn","up","-i",0],execute:["yarn","dlx",0],"execute-local":["yarn","exec",0],global:["npm","i","-g",0],global_uninstall:["npm","uninstall","-g",0]},kr={agent:["pnpm",0],run:["pnpm","run",0],install:["pnpm","i",0],frozen:["pnpm","i","--frozen-lockfile",0],global:["pnpm","add","-g",0],add:["pnpm","add",0],upgrade:["pnpm","update",0],"upgrade-interactive":["pnpm","update","-i",0],execute:["pnpm","dlx",0],"execute-local":["pnpm","exec",0],uninstall:["pnpm","remove",0],global_uninstall:["pnpm","remove","--global",0]},Pi={agent:["bun",0],run:["bun","run",0],install:["bun","install",0],frozen:["bun","install","--frozen-lockfile",0],global:["bun","add","-g",0],add:["bun","add",0],upgrade:["bun","update",0],"upgrade-interactive":["bun","update",0],execute:["bun","x",0],"execute-local":["bun","x",0],uninstall:["bun","remove",0],global_uninstall:["bun","remove","-g",0]},Ii={agent:["deno",0],run:["deno","task",0],install:["deno","install",0],frozen:["deno","install","--frozen",0],global:["deno","install","-g",0],add:["deno","add",0],upgrade:["deno","outdated","--update",0],"upgrade-interactive":["deno","outdated","--update",0],execute:ki(),"execute-local":["deno","task","--eval",0],uninstall:["deno","remove",0],global_uninstall:["deno","uninstall","-g",0]},Pr={npm:Si,yarn:Tr,"yarn@berry":Ti,pnpm:kr,"pnpm@6":{...kr,run:Sr("pnpm")},bun:Pi,deno:Ii};function yt(s,e,t){let i=Pr[s][e];return Ir(i,t)}function Ir(s,e){if(s==null)return null;let t=typeof s=="function"?s(e):s.flatMap(i=>typeof i=="number"?e:[i]);return{command:t[0],args:t.slice(1)}}var jr=["npm","yarn","yarn@berry","pnpm","pnpm@6","bun","deno"],bt={"bun.lock":"bun","bun.lockb":"bun","deno.lock":"deno","pnpm-lock.yaml":"pnpm","yarn.lock":"yarn","package-lock.json":"npm","npm-shrinkwrap.json":"npm"};var ke=C(require("node:fs"),1),K=C(require("node:path"),1),Wr=C(require("node:process"),1);var Nr=Symbol.for("quansync.getIsAsync"),xe=class extends Error{constructor(e="Unexpected promise in sync context"){super(e),this.name="QuansyncError"}};function $t(s){return s&&typeof s=="object"&&typeof s.then=="function"}function ji(s){return s&&typeof s=="object"&&typeof s[Symbol.iterator]=="function"&&"__quansync"in s}function wt(s){let e=function*(...i){return(yield Nr)?yield s.async.apply(this,i):s.sync.apply(this,i)};function t(...i){let n=e.apply(this,i);return n.then=(...u)=>s.async.apply(this,i).then(...u),n.__quansync=!0,n}return t.sync=s.sync,t.async=s.async,t}function Ni(s){return wt({async:()=>Promise.resolve(s),sync:()=>{if($t(s))throw new xe;return s}})}function vt(s,e){if(s===Nr)return e;if(ji(s))return e?Hr(s):Vr(s);if(!e&&$t(s))throw new xe;return s}var Mr=s=>s;function Vr(s,e=Mr){let t=s.next();for(;!t.done;)try{t=s.next(vt(e(t.value,!1)))}catch(i){t=s.throw(i)}return vt(t.value)}async function Hr(s,e=Mr){let t=s.next();for(;!t.done;)try{t=s.next(await vt(e(t.value,!0),!0))}catch(i){t=s.throw(i)}return t.value}function Mi(s,e){return wt({name:s.name,async(...t){return Hr(s.apply(this,t),e?.onYield)},sync(...t){return Vr(s.apply(this,t),e?.onYield)}})}function At(s,e){return $t(s)?Ni(s):typeof s=="function"?Mi(s,e):wt(s)}var Gn=At({async:()=>Promise.resolve(!0),sync:()=>!1});var Oe=At;var Rr=Oe({sync:s=>{try{return ke.default.statSync(s).isFile()}catch{return!1}},async:async s=>{try{return(await ke.default.promises.stat(s)).isFile()}catch{return!1}}});function*Vi(s=Wr.default.cwd()){let e=K.default.resolve(s),{root:t}=K.default.parse(e);for(;e&&e!==t;)yield e,e=K.default.dirname(e)}var Gr=Oe(function*(s,e){return!s||!(yield Rr(s))?null:Gi(s,e)}),Se=Oe(function*(s={}){let{cwd:e,onUnknown:t}=s;for(let i of Vi(e)){for(let u of Object.keys(bt))if(yield Rr(K.default.join(i,u))){let r=bt[u],o=yield Gr(K.default.join(i,"package.json"),t);return o||{name:r,agent:r}}let n=yield Gr(K.default.join(i,"package.json"),t);if(n)return n}return null}),Hi=Se.sync;function Gi(s,e){try{let t=JSON.parse(ke.default.readFileSync(s,"utf8")),i;if(typeof t.packageManager=="string"){let[n,u]=t.packageManager.replace(/^\^/,"").split("@"),r=u;return n==="yarn"&&Number.parseInt(u)>1?(i="yarn@berry",r="berry",{name:n,agent:i,version:r}):n==="pnpm"&&Number.parseInt(u)<7?(i="pnpm@6",{name:n,agent:i,version:r}):jr.includes(n)?(i=n,{name:n,agent:i,version:r}):e?.(t.packageManager)??null}}catch{}return null}function Bt(s){try{return process.platform==="win32"?(0,z.execSync)(`where ${s}`,{stdio:"ignore"}):(0,z.execSync)(`command -v ${s}`,{stdio:"ignore"}),!0}catch{return!1}}function Wi(s,e){if(s==="npx"||s==="pnpx"||s==="bunx")return{intent:"execute",args:e};if(s==="yarn"&&e[0]==="dlx")return{intent:"execute",args:e.slice(1)};if(["npm","pnpm","yarn","bun"].includes(s)){let i=e[0]||"",n=e.slice(1);if(!i||["install","i"].includes(i))return{intent:"install",args:n};if(i==="add")return{intent:"add",args:n};if(i==="run")return{intent:"run",args:n};if(["uninstall","remove","rm","un"].includes(i))return{intent:"uninstall",args:n};if(i==="install"&&n.length>0)return{intent:"add",args:n};if(i&&!i.startsWith("-"))return{intent:"run",args:e}}return null}async function Te(s,e={}){let t=s.trim().split(/\s+/),i=t[0]||"",n=t.slice(1),u=Wi(i,n);if(u){let o=(await Se({cwd:process.cwd()}))?.agent||"npm",a=yt(o,u.intent,u.args);if(a){let c=`${a.command} ${a.args.join(" ")}`;if(u.intent==="execute"){if(Bt("bunx")){let l=`bunx ${u.args.join(" ")}`;return(0,z.execSync)(l,{stdio:"inherit",cwd:process.cwd(),...e})}if(Bt("npx")){let l=`npx ${u.args.join(" ")}`;return(0,z.execSync)(l,{stdio:"inherit",cwd:process.cwd(),...e})}}if(Bt(a.command))return(0,z.execSync)(c,{stdio:"inherit",cwd:process.cwd(),...e});throw new Error(`Command not found: ${a.command}. Please install the required package manager.`)}}return(0,z.execSync)(s,{stdio:"inherit",cwd:process.cwd(),...e})}var Y=C(require("crypto")),_=C(require("fs")),ae=C(require("path")),_t=C(require("os")),Lr="ts-cli-derived",Ri="jwt-token",Pe=()=>{let s=_t.homedir();return ae.join(s,`.${Lr}`,`${Ri}.enc`)},qi=()=>{let s=Pe(),e=ae.dirname(s);_.existsSync(e)||_.mkdirSync(e,{recursive:!0})},qr=()=>{let s=ae.join(_t.homedir(),`.${Lr}`,"key");if(!_.existsSync(s)){let e=Y.randomBytes(32);return _.writeFileSync(s,e),e}return _.readFileSync(s)},L=class{static async saveToken(e){qi();let t=qr(),i=Y.randomBytes(16),n=Y.createCipheriv("aes-256-gcm",t,i),u=Buffer.concat([n.update(e,"utf8"),n.final()]),r=n.getAuthTag(),o={iv:i.toString("hex"),encrypted:u.toString("hex"),authTag:r.toString("hex")};_.writeFileSync(Pe(),JSON.stringify(o))}static async getToken(){try{let e=Pe();if(!_.existsSync(e))return null;let t=JSON.parse(_.readFileSync(e,"utf8")),i=qr(),n=Buffer.from(t.iv,"hex"),u=Buffer.from(t.encrypted,"hex"),r=Buffer.from(t.authTag,"hex"),o=Y.createDecipheriv("aes-256-gcm",i,n);return o.setAuthTag(r),o.update(u)+o.final("utf8")}catch{return null}}static async deleteToken(){try{let e=Pe();return _.existsSync(e)?(_.unlinkSync(e),!0):!1}catch{return!1}}};var j=require("fs"),U=require("path"),Li=new Set([".git","node_modules"]);function Ui(s){if((0,j.existsSync)(s))return(0,U.resolve)(s);if(s.startsWith("/")){let e=(0,U.resolve)(process.cwd(),s.replace(/^\/+/,""));if((0,j.existsSync)(e))return e}return(0,U.resolve)(process.cwd(),s)}function Ur(s){let e=(0,j.readdirSync)(s,{withFileTypes:!0}),t=[];for(let i of e){let n=(0,U.join)(s,i.name);if(i.isDirectory()){if(Li.has(i.name))continue;t.push(...Ur(n));continue}i.isFile()&&t.push(n)}return t}function Ji(s){let e=(0,U.relative)(process.cwd(),s);return!e||e.startsWith("..")?null:`/${e.replace(/\\/g,"/")}`}function Jr(s){let e=[],t=new Set;for(let r of s){let o=Ui(r);if(!(0,j.existsSync)(o)){e.push(`Path does not exist: ${r}`);continue}try{let a=(0,j.lstatSync)(o);if(a.isFile()){t.add(o);continue}if(a.isDirectory()){try{let c=Ur(o);for(let l of c)t.add(l)}catch(c){e.push(`Failed to read directory "${o}": ${c.message}`)}continue}e.push(`Unsupported path type: ${r}`)}catch(a){e.push(`Failed to inspect path "${o}": ${a.message}`)}}let i=[],n=new Set,u=Array.from(t).sort((r,o)=>r.localeCompare(o));for(let r of u){let o=Ji(r);if(!o){e.push(`Path is outside the current project: ${r}`);continue}if(!n.has(o)){n.add(o);try{let a=(0,j.readFileSync)(r,"utf-8");i.push({templatePath:o,template:a})}catch(a){e.push(`Failed to read file "${r}": ${a.message}`)}}}return{files:i,errors:e}}var N=new Jt,Z=new ie.default;function je(){return!process.stdin.isTTY||process.env.CI==="true"||process.env.TERM==="dumb"||process.env.NON_INTERACTIVE==="true"}async function Yi(s){let e=(0,xt.join)((0,es.tmpdir)(),`cli-edit-${Date.now()}.json`);(0,T.writeFileSync)(e,JSON.stringify(s,null,2));let t=process.env.VISUAL||process.env.EDITOR||"nano";return new Promise((i,n)=>{(0,Xr.spawn)(t,[e],{stdio:"inherit"}).on("exit",r=>{if(r===0)try{let o=(0,T.readFileSync)(e,"utf-8"),a=JSON.parse(o);(0,T.unlinkSync)(e),i(a)}catch{(0,T.unlinkSync)(e),n(new Error("Invalid JSON format"))}else(0,T.unlinkSync)(e),n(new Error("Editor closed without saving"))})})}async function Qr(s,e){let t=B();t.start("Modifying block input...");let i=await Z.getBlockInputFromUserQuery(JSON.stringify(s),e);return t.stop("Block input modified"),Ot(i.result,"Refined Block Input"),i.result}function Ot(s,e="Block Input"){R(JSON.stringify(s,null,2),e)}function ts(s,e){return Z.resolveMultipleTemplates(s,e)}async function rs(s,e){let t=await ts(s,e),i=t.result.files.map(r=>r.resolvedPath),n=wr(i),u=Be(n);R(u,`Files to be created (${t.result.files.length}):`)}async function Ie(s,e,t=!1,i){let n=B();n.start("Resolving Files...");let u=await ts(s,e),r=u.result.files.filter(l=>{let D=(0,xt.join)(process.cwd(),l.resolvedPath);return(0,T.existsSync)(D)&&(0,T.lstatSync)(D).isFile()&&l.templateType==="add"}),o=[],a=t;if(r.length>0&&!t){if(n.stop(`${r.length} conflicting files detected`),je()){let D=`
96
- Non-Interactive Mode Error:
88
+ `)},info:r=>{U.message(r,{symbol:p.default.blue(Zi)})},success:r=>{U.message(r,{symbol:p.default.green(Xi)})},step:r=>{U.message(r,{symbol:p.default.green(Ne)})},warn:r=>{U.message(r,{symbol:p.default.yellow(es)})},warning:r=>{U.warn(r)},error:r=>{U.message(r,{symbol:p.default.red(ts)})}},Bo=`${p.default.gray(f)} `;var zr=({indicator:r="dots"}={})=>{let e=xt?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],t=xt?80:120,i=process.env.CI==="true",s,o,n=!1,u="",a,c=performance.now(),l=F=>{let N=F>1?"Something went wrong":"Canceled";n&&C(N,F)},D=()=>l(2),h=()=>l(1),E=()=>{process.on("uncaughtExceptionMonitor",D),process.on("unhandledRejection",D),process.on("SIGINT",h),process.on("SIGTERM",h),process.on("exit",l)},B=()=>{process.removeListener("uncaughtExceptionMonitor",D),process.removeListener("unhandledRejection",D),process.removeListener("SIGINT",h),process.removeListener("SIGTERM",h),process.removeListener("exit",l)},G=()=>{if(a===void 0)return;i&&process.stdout.write(`
89
+ `);let F=a.split(`
90
+ `);process.stdout.write(Ie.cursor.move(-999,F.length-1)),process.stdout.write(Ie.erase.down(F.length))},m=F=>F.replace(/\.+$/,""),y=F=>{let N=(performance.now()-F)/1e3,L=Math.floor(N/60),De=Math.floor(N%60);return L>0?`[${L}m ${De}s]`:`[${De}s]`},W=(F="")=>{n=!0,s=Mr(),u=m(F),c=performance.now(),process.stdout.write(`${p.default.gray(f)}
91
+ `);let N=0,L=0;E(),o=setInterval(()=>{if(i&&u===a)return;G(),a=u;let De=p.default.magenta(e[N]);if(i)process.stdout.write(`${De} ${u}...`);else if(r==="timer")process.stdout.write(`${De} ${u} ${y(c)}`);else{let Ln=".".repeat(Math.floor(L)).slice(0,3);process.stdout.write(`${De} ${u}${Ln}`)}N=N+1<e.length?N+1:0,L=L<e.length?L+.125:0},t)},C=(F="",N=0)=>{n=!1,clearInterval(o),G();let L=N===0?p.default.green(Ne):N===1?p.default.red(Wr):p.default.red(Lr);u=m(F??u),r==="timer"?process.stdout.write(`${L} ${u} ${y(c)}
92
+ `):process.stdout.write(`${L} ${u}
93
+ `),B(),s()};return{start:W,stop:C,message:(F="")=>{u=m(F??u)}}};var Mn=require("node:child_process"),T=require("node:fs"),Vn=require("node:os"),Qe=require("node:path");var he=b(require("fs")),Tt=b(require("path")),Qr=(r,e=[],t=!1)=>{let i=[],s=[],o=[];for(let n of r){let u=Tt.default.join(process.cwd(),n.resolvedPath);if(!n.isNotEnabled)try{if(he.default.mkdirSync(Tt.default.dirname(u),{recursive:!0}),n.templateType==="add"){let a=he.default.existsSync(u)&&he.default.lstatSync(u).isFile(),c=t||e.includes(n.resolvedPath);if(a&&!c){o.push(`File already exists: ${u}`);continue}else{if(n.pathError||n.templateError){o.push(`Failed to create file: ${u} because of error: ${n.templateError}`);continue}he.default.writeFileSync(u,n.resolvedTemplate),i.push(u)}}else n.templateType==="modify"&&(n.modifiedFileContent?(he.default.writeFileSync(u,n.modifiedFileContent),s.push(u)):o.push(`Failed to modify file: ${u} because of error: ${n.templateError}`))}catch(a){o.push(a instanceof Error?a.message:String(a))}}return{addResults:i,modifyResults:s,errors:o}};var Ze=b(It());var Nt=b(Be());function en(r){let e={name:"root",type:"directory",children:[],path:""},t=r.map(i=>i.replace(/^\//,"").replace(/\\/g,"/")).sort();for(let i of t){let s=i.split("/").filter(Boolean),o=e;s.forEach((n,u)=>{let a=u===s.length-1,c=o.children?.find(l=>l.name===n);if(c)o=c;else{let l={name:n,type:a?"file":"directory",children:a?void 0:[],path:s.slice(0,u+1).join("/")};o.children||(o.children=[]),o.children.push(l),o=l}})}return e}function Me(r,e="",t=!0,i=!0){if(i&&r.children)return r.children.map((a,c)=>Me(a,"",c===r.children.length-1,!1)).join(`
94
+ `);let s=t?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",o=r.type==="directory"?"\u{1F4C1} ":"\u{1F4C4} ",n=r.type==="directory"?Nt.default.cyan(r.name+"/"):Nt.default.green(r.name),u=e+s+o+n+`
95
+ `;if(r.children&&r.children.length>0){let a=e+(t?" ":"\u2502 ");r.children.forEach((c,l)=>{u+=Me(c,a,l===r.children.length-1,!1)})}return u}var Z=require("fs"),Rt=require("path"),Ds=".derived",ds="blocks.json";function tn(){return(0,Rt.join)(process.cwd(),Ds)}function rn(){return(0,Rt.join)(tn(),ds)}function Mt(r,e){if(r===e)return!0;if(r==null||e==null)return r===e;if(typeof r!=typeof e)return!1;if(typeof r!="object")return r===e;let t=Object.keys(r),i=Object.keys(e);if(t.length!==i.length)return!1;for(let s of t)if(!i.includes(s)||!Mt(r[s],e[s]))return!1;return!0}function oe(){let r=rn();if(!(0,Z.existsSync)(r))return{addedBlocks:[]};try{let e=(0,Z.readFileSync)(r,"utf-8"),t=JSON.parse(e);return Array.isArray(t.addedBlocks)?t.addedBlocks.length>0&&typeof t.addedBlocks[0]=="string"?{addedBlocks:t.addedBlocks.map(i=>({code:i,input:{}}))}:t:{addedBlocks:[]}}catch{return{addedBlocks:[]}}}function ps(r){let e=tn(),t=rn();(0,Z.existsSync)(e)||(0,Z.mkdirSync)(e,{recursive:!0}),(0,Z.writeFileSync)(t,JSON.stringify(r,null,2))}function nn(r){return oe().addedBlocks.some(t=>t.code===r)}function Vt(r,e){return oe().addedBlocks.find(s=>s.code===r&&Mt(s.input,e))||null}function sn(r,e){return oe().addedBlocks.filter(i=>i.code===r&&!Mt(i.input,e))}function Gt(r,e={}){let t=oe();Vt(r,e)||(t.addedBlocks.push({code:r,input:e}),ps(t))}var X=require("node:fs"),Ht=require("node:path"),hs=".derived",ms="staging.json";function on(){return(0,Ht.join)(process.cwd(),hs)}function un(){return(0,Ht.join)(on(),ms)}function Ve(){let r=un();if(!(0,X.existsSync)(r))return{stagedFiles:[]};try{let e=(0,X.readFileSync)(r,"utf-8"),t=JSON.parse(e);return t&&Array.isArray(t.stagedFiles)?t:{stagedFiles:[]}}catch{return{stagedFiles:[]}}}function Wt(r){let e=on(),t=un();(0,X.existsSync)(e)||(0,X.mkdirSync)(e,{recursive:!0}),(0,X.writeFileSync)(t,JSON.stringify(r,null,2))}function Lt(r){return Ve().stagedFiles.some(t=>t.path===r)}function an(r){let e=Ve();Lt(r)||(e.stagedFiles.push({path:r,addedAt:new Date().toISOString()}),Wt(e))}function cn(r){let e=Ve();e.stagedFiles=e.stagedFiles.filter(t=>t.path!==r),Wt(e)}function qt(){Wt({stagedFiles:[]})}function Fe(){return Ve().stagedFiles}var ne=class extends Error{code;constructor(e,t){super(t),this.name="CliError",this.code=e}};var ae=require("child_process");function Dn(r){return e=>e.length>1?[r,"run",e[0],"--",...e.slice(1)]:[r,"run",e[0]]}function fs(){return r=>["deno","run",`npm:${r[0]}`,...r.slice(1)]}var gs={agent:["npm",0],run:Dn("npm"),install:["npm","i",0],frozen:["npm","ci",0],global:["npm","i","-g",0],add:["npm","i",0],upgrade:["npm","update",0],"upgrade-interactive":null,execute:["npx",0],"execute-local":["npx",0],uninstall:["npm","uninstall",0],global_uninstall:["npm","uninstall","-g",0]},dn={agent:["yarn",0],run:["yarn","run",0],install:["yarn","install",0],frozen:["yarn","install","--frozen-lockfile",0],global:["yarn","global","add",0],add:["yarn","add",0],upgrade:["yarn","upgrade",0],"upgrade-interactive":["yarn","upgrade-interactive",0],execute:["npx",0],"execute-local":["yarn","exec",0],uninstall:["yarn","remove",0],global_uninstall:["yarn","global","remove",0]},Cs={...dn,frozen:["yarn","install","--immutable",0],upgrade:["yarn","up",0],"upgrade-interactive":["yarn","up","-i",0],execute:["yarn","dlx",0],"execute-local":["yarn","exec",0],global:["npm","i","-g",0],global_uninstall:["npm","uninstall","-g",0]},ln={agent:["pnpm",0],run:["pnpm","run",0],install:["pnpm","i",0],frozen:["pnpm","i","--frozen-lockfile",0],global:["pnpm","add","-g",0],add:["pnpm","add",0],upgrade:["pnpm","update",0],"upgrade-interactive":["pnpm","update","-i",0],execute:["pnpm","dlx",0],"execute-local":["pnpm","exec",0],uninstall:["pnpm","remove",0],global_uninstall:["pnpm","remove","--global",0]},Fs={agent:["bun",0],run:["bun","run",0],install:["bun","install",0],frozen:["bun","install","--frozen-lockfile",0],global:["bun","add","-g",0],add:["bun","add",0],upgrade:["bun","update",0],"upgrade-interactive":["bun","update",0],execute:["bun","x",0],"execute-local":["bun","x",0],uninstall:["bun","remove",0],global_uninstall:["bun","remove","-g",0]},ys={agent:["deno",0],run:["deno","task",0],install:["deno","install",0],frozen:["deno","install","--frozen",0],global:["deno","install","-g",0],add:["deno","add",0],upgrade:["deno","outdated","--update",0],"upgrade-interactive":["deno","outdated","--update",0],execute:fs(),"execute-local":["deno","task","--eval",0],uninstall:["deno","remove",0],global_uninstall:["deno","uninstall","-g",0]},pn={npm:gs,yarn:dn,"yarn@berry":Cs,pnpm:ln,"pnpm@6":{...ln,run:Dn("pnpm")},bun:Fs,deno:ys};function Jt(r,e,t){let i=pn[r][e];return hn(i,t)}function hn(r,e){if(r==null)return null;let t=typeof r=="function"?r(e):r.flatMap(i=>typeof i=="number"?e:[i]);return{command:t[0],args:t.slice(1)}}var mn=["npm","yarn","yarn@berry","pnpm","pnpm@6","bun","deno"],Ut={"bun.lock":"bun","bun.lockb":"bun","deno.lock":"deno","pnpm-lock.yaml":"pnpm","yarn.lock":"yarn","package-lock.json":"npm","npm-shrinkwrap.json":"npm"};var We=b(require("node:fs"),1),ue=b(require("node:path"),1),En=b(require("node:process"),1);var fn=Symbol.for("quansync.getIsAsync"),Ge=class extends Error{constructor(e="Unexpected promise in sync context"){super(e),this.name="QuansyncError"}};function zt(r){return r&&typeof r=="object"&&typeof r.then=="function"}function Es(r){return r&&typeof r=="object"&&typeof r[Symbol.iterator]=="function"&&"__quansync"in r}function Yt(r){let e=function*(...i){return(yield fn)?yield r.async.apply(this,i):r.sync.apply(this,i)};function t(...i){let s=e.apply(this,i);return s.then=(...o)=>r.async.apply(this,i).then(...o),s.__quansync=!0,s}return t.sync=r.sync,t.async=r.async,t}function bs(r){return Yt({async:()=>Promise.resolve(r),sync:()=>{if(zt(r))throw new Ge;return r}})}function Kt(r,e){if(r===fn)return e;if(Es(r))return e?Fn(r):Cn(r);if(!e&&zt(r))throw new Ge;return r}var gn=r=>r;function Cn(r,e=gn){let t=r.next();for(;!t.done;)try{t=r.next(Kt(e(t.value,!1)))}catch(i){t=r.throw(i)}return Kt(t.value)}async function Fn(r,e=gn){let t=r.next();for(;!t.done;)try{t=r.next(await Kt(e(t.value,!0),!0))}catch(i){t=r.throw(i)}return t.value}function vs(r,e){return Yt({name:r.name,async(...t){return Fn(r.apply(this,t),e?.onYield)},sync(...t){return Cn(r.apply(this,t),e?.onYield)}})}function Qt(r,e){return zt(r)?bs(r):typeof r=="function"?vs(r,e):Yt(r)}var Vo=Qt({async:()=>Promise.resolve(!0),sync:()=>!1});var He=Qt;var bn=He({sync:r=>{try{return We.default.statSync(r).isFile()}catch{return!1}},async:async r=>{try{return(await We.default.promises.stat(r)).isFile()}catch{return!1}}});function*$s(r=En.default.cwd()){let e=ue.default.resolve(r),{root:t}=ue.default.parse(e);for(;e&&e!==t;)yield e,e=ue.default.dirname(e)}var yn=He(function*(r,e){return!r||!(yield bn(r))?null:As(r,e)}),Le=He(function*(r={}){let{cwd:e,onUnknown:t}=r;for(let i of $s(e)){for(let o of Object.keys(Ut))if(yield bn(ue.default.join(i,o))){let n=Ut[o],u=yield yn(ue.default.join(i,"package.json"),t);return u||{name:n,agent:n}}let s=yield yn(ue.default.join(i,"package.json"),t);if(s)return s}return null}),ws=Le.sync;function As(r,e){try{let t=JSON.parse(We.default.readFileSync(r,"utf8")),i;if(typeof t.packageManager=="string"){let[s,o]=t.packageManager.replace(/^\^/,"").split("@"),n=o;return s==="yarn"&&Number.parseInt(o)>1?(i="yarn@berry",n="berry",{name:s,agent:i,version:n}):s==="pnpm"&&Number.parseInt(o)<7?(i="pnpm@6",{name:s,agent:i,version:n}):mn.includes(s)?(i=s,{name:s,agent:i,version:n}):e?.(t.packageManager)??null}}catch{}return null}function Zt(r){try{return process.platform==="win32"?(0,ae.execSync)(`where ${r}`,{stdio:"ignore"}):(0,ae.execSync)(`command -v ${r}`,{stdio:"ignore"}),!0}catch{return!1}}function xs(r,e){if(r==="npx"||r==="pnpx"||r==="bunx")return{intent:"execute",args:e};if(r==="yarn"&&e[0]==="dlx")return{intent:"execute",args:e.slice(1)};if(["npm","pnpm","yarn","bun"].includes(r)){let i=e[0]||"",s=e.slice(1);if(!i||["install","i"].includes(i))return{intent:"install",args:s};if(i==="add")return{intent:"add",args:s};if(i==="run")return{intent:"run",args:s};if(["uninstall","remove","rm","un"].includes(i))return{intent:"uninstall",args:s};if(i==="install"&&s.length>0)return{intent:"add",args:s};if(i&&!i.startsWith("-"))return{intent:"run",args:e}}return null}async function qe(r,e={}){let t=r.trim().split(/\s+/),i=t[0]||"",s=t.slice(1),o=xs(i,s);if(o){let u=(await Le({cwd:process.cwd()}))?.agent||"npm",a=Jt(u,o.intent,o.args);if(a){let c=`${a.command} ${a.args.join(" ")}`;if(o.intent==="execute"){if(Zt("bunx")){let l=`bunx ${o.args.join(" ")}`;return(0,ae.execSync)(l,{stdio:"inherit",cwd:process.cwd(),...e})}if(Zt("npx")){let l=`npx ${o.args.join(" ")}`;return(0,ae.execSync)(l,{stdio:"inherit",cwd:process.cwd(),...e})}}if(Zt(a.command))return(0,ae.execSync)(c,{stdio:"inherit",cwd:process.cwd(),...e});throw new Error(`Command not found: ${a.command}. Please install the required package manager.`)}}return(0,ae.execSync)(r,{stdio:"inherit",cwd:process.cwd(),...e})}var ce=b(require("crypto")),k=b(require("fs")),ye=b(require("path")),Xt=b(require("os")),$n="ts-cli-derived",Bs="jwt-token",Je=()=>{let r=Xt.homedir();return ye.join(r,`.${$n}`,`${Bs}.enc`)},_s=()=>{let r=Je(),e=ye.dirname(r);k.existsSync(e)||k.mkdirSync(e,{recursive:!0})},vn=()=>{let r=ye.join(Xt.homedir(),`.${$n}`,"key");if(!k.existsSync(r)){let e=ce.randomBytes(32);return k.writeFileSync(r,e),e}return k.readFileSync(r)},V=class{static async saveToken(e){_s();let t=vn(),i=ce.randomBytes(16),s=ce.createCipheriv("aes-256-gcm",t,i),o=Buffer.concat([s.update(e,"utf8"),s.final()]),n=s.getAuthTag(),u={iv:i.toString("hex"),encrypted:o.toString("hex"),authTag:n.toString("hex")};k.writeFileSync(Je(),JSON.stringify(u))}static async getToken(){try{let e=Je();if(!k.existsSync(e))return null;let t=JSON.parse(k.readFileSync(e,"utf8")),i=vn(),s=Buffer.from(t.iv,"hex"),o=Buffer.from(t.encrypted,"hex"),n=Buffer.from(t.authTag,"hex"),u=ce.createDecipheriv("aes-256-gcm",i,s);return u.setAuthTag(n),u.update(o)+u.final("utf8")}catch{return null}}static async deleteToken(){try{let e=Je();return k.existsSync(e)?(k.unlinkSync(e),!0):!1}catch{return!1}}};var K=require("fs"),ie=require("path"),Os=new Set([".git","node_modules"]);function Ss(r){if((0,K.existsSync)(r))return(0,ie.resolve)(r);if(r.startsWith("/")){let e=(0,ie.resolve)(process.cwd(),r.replace(/^\/+/,""));if((0,K.existsSync)(e))return e}return(0,ie.resolve)(process.cwd(),r)}function wn(r){let e=(0,K.readdirSync)(r,{withFileTypes:!0}),t=[];for(let i of e){let s=(0,ie.join)(r,i.name);if(i.isDirectory()){if(Os.has(i.name))continue;t.push(...wn(s));continue}i.isFile()&&t.push(s)}return t}function ks(r){let e=(0,ie.relative)(process.cwd(),r);return!e||e.startsWith("..")?null:`/${e.replace(/\\/g,"/")}`}function er(r){let e=[],t=new Set;for(let n of r){let u=Ss(n);if(!(0,K.existsSync)(u)){e.push(`Path does not exist: ${n}`);continue}try{let a=(0,K.lstatSync)(u);if(a.isFile()){t.add(u);continue}if(a.isDirectory()){try{let c=wn(u);for(let l of c)t.add(l)}catch(c){e.push(`Failed to read directory "${u}": ${c.message}`)}continue}e.push(`Unsupported path type: ${n}`)}catch(a){e.push(`Failed to inspect path "${u}": ${a.message}`)}}let i=[],s=new Set,o=Array.from(t).sort((n,u)=>n.localeCompare(u));for(let n of o){let u=ks(n);if(!u){e.push(`Path is outside the current project: ${n}`);continue}if(!s.has(u)){s.add(u);try{let a=(0,K.readFileSync)(n,"utf-8");i.push({templatePath:u,template:a})}catch(a){e.push(`Failed to read file "${n}": ${a.message}`)}}}return{files:i,errors:e}}function js(){return!process.stdin.isTTY||process.env.CI==="true"||process.env.TERM==="dumb"||process.env.NON_INTERACTIVE==="true"}var _=js(),I=!1;function An(r){I=r}function A(){return I||_}function Ee(r,e){(I||_)&&console.error(`[${r}] ${e}`)}function $(){return _||I?{start:r=>console.error(`[start] ${r}`),stop:r=>console.error(`[done] ${r}`)}:zr()}var d={intro(r){_||I?Ee("intro",r):Ur(r)},outro(r){_||I?Ee("outro",r):Kr(r)},note(r,e){_||I?(e&&console.error(`[note:${e}]`),console.error(r)):kt(r,e)},data(r,e){_||I?(e&&console.error(`[data:${e}]`),console.error(JSON.stringify(r))):kt(JSON.stringify(r,null,2),e??"Data")},success(r){_||I?Ee("ok",r):U.success(r)},info(r){_||I?Ee("info",r):U.info(r)},warn(r){_||I?Ee("warn",r):U.warning(r)},fatal(r){throw _||I?console.error(`[error] ${r}`):jt(r),new ne("FATAL",r)},cancel(r){throw _||I?console.log(`[cancel] ${r}`):jt(r),new ne("CANCELLED",r)}};function Ts(r,e){let t=Is(r,e);process.stdout.write(JSON.stringify(t)+`
96
+ `)}function Ps(r,e,t,i){let s=Ns(r,e,t,i);process.stdout.write(JSON.stringify(s)+`
97
+ `)}function Is(r,e){return{type:"success",command:r,...e!==void 0?{data:e}:{}}}function Ns(r,e,t,i){return{type:"error",command:r,code:e,message:t,...i!==void 0?{detail:i}:{}}}function z(r,e){Ts(r,e),process.exit(0)}function j(r,e,t,i){Ps(r,e,t,i),process.exit(1)}var Ue=require("node:fs"),xn=require("node:path");function H(){let r=(0,xn.join)(process.cwd(),".derived","project.json");if(!(0,Ue.existsSync)(r))return null;try{let e=(0,Ue.readFileSync)(r,"utf-8");return JSON.parse(e)}catch{return null}}var me=b(It());var Y=require("node:fs"),tr=require("node:path"),Bn=".derived",Rs="categories.json";function _n(){return(0,tr.join)(process.cwd(),Bn,Rs)}function Ms(){return(0,tr.join)(process.cwd(),Bn)}function On(){let r=Ms();(0,Y.existsSync)(r)||(0,Y.mkdirSync)(r,{recursive:!0})}function Sn(){let r=_n();if(!(0,Y.existsSync)(r))return null;try{let e=(0,Y.readFileSync)(r,"utf-8"),t=JSON.parse(e);return t&&typeof t.projectId=="number"&&Array.isArray(t.categories)?t:null}catch{return null}}function ee(r,e){On();let t={projectId:r,lastRefreshed:new Date().toISOString(),categories:e.map(i=>({id:i.id,name:i.name,active:i.active,createdAt:i.createdAt}))};(0,Y.writeFileSync)(_n(),JSON.stringify(t,null,2))}function kn(r,e){let t=Sn();if(!t||t.projectId!==e)return null;let i=r.toLowerCase().trim();return t.categories.find(o=>o.name.toLowerCase().trim()===i)??null}function Ke(r,e){On();let t=Sn(),i={id:e.id,name:e.name,active:e.active,createdAt:e.createdAt};if(!t||t.projectId!==r){ee(r,[e]);return}let s=t.categories.filter(o=>o.id!==e.id);s.push(i),ee(r,s)}async function ze(r,e,t){let i=kn(r,e);if(i)return{id:i.id,name:i.name,projectId:e,active:i.active,createdAt:i.createdAt};let s=$();s.start(`Looking up category "${r}"...`);try{let o=await jn(e,t);s.stop(`Found ${o.length} categories`),ee(e,o);let n=r.toLowerCase().trim();return o.find(a=>a.name.toLowerCase().trim()===n)??null}catch(o){throw s.stop("Failed to fetch categories"),o}}async function rr(r,e,t){let i=await ze(r,e,t).catch(()=>null);if(i)return d.info(`Using existing category "${r}" (ID: ${i.id})`),i;let s=$();s.start(`Creating category "${r}"...`);try{let o=await t.createCategory({name:r,projectId:e,active:!0});s.stop(`Category created: "${r}"`);let n=o.result;return Ke(e,n),n}catch(o){throw s.stop(`Failed to create category "${r}"`),o}}async function jn(r,e,t=1,i=[]){let n=(await e.getProjectCategories(r,50,t))?.result??[];return n.length<50?[...i,...n]:jn(r,e,t+1,[...i,...n])}async function nr(r,e,t,i={}){let s=Number(r);if(!Number.isNaN(s)&&s>0)return s;if(i.findOrCreate)return(await rr(r,e,t)).id;let o=await ze(r,e,t);if(!o)throw new Error(`Category "${r}" not found. Use 'derived-cli category ensure "${r}"' to create it, or pass --find-or-create-category.`);return o.id}function Tn(r){Vs(r),Gs(r),Hs(r)}function Vs(r){r.command("create-category <categoryName>").description("Create a new category in a project (reads projectID from .derived/project.json)").action(async e=>{let t="create-category",i=await V.getToken();i||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let s=await H();s||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let o=s.projectID;d.info(`Using project ID from .derived/project.json: ${o}`);let n=new me.default({apiToken:i}),u=$();u.start("Creating category...");try{let a=await n.createCategory({name:e,projectId:o,active:!0});u.stop("Category created"),a?.result?.id&&Ke(o,a.result),A()&&z(t,a?.result),console.log(JSON.stringify(a?.result?.id??a))}catch(a){u.stop("Failed to create category");let c=a.response?.data?JSON.stringify(a.response.data):a.message;A()&&j(t,"API_ERROR",c),d.fatal(`API Error: ${c}`)}})}function Gs(r){r.command("list-categories").description("List all categories in a project (reads projectID from .derived/project.json)").action(async()=>{let e="list-categories",t=await V.getToken();t||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let i=await H();i||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let s=i.projectID;d.info(`Using project ID from .derived/project.json: ${s}`);let o=new me.default({apiToken:t}),n=$();n.start("Fetching categories...");try{let u=await o.getProjectCategories(s);n.stop("Categories fetched");let a=u?.result??[];Array.isArray(a)&&a.length>0&&ee(s,a),A()&&z(e,a),console.log(JSON.stringify(a))}catch(u){n.stop("Failed to fetch categories");let a=u.response?.data?JSON.stringify(u.response.data):u.message;A()&&j(e,"API_ERROR",a),d.fatal(`API Error: ${a}`)}})}function Hs(r){let e=r.command("category").description("Manage categories in the current project");e.command("find <name>").description("Find a category by name and output its ID").action(async t=>{let i="category.find",s=await V.getToken();s||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let o=await H();o||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let n=o.projectID,u=new me.default({apiToken:s});try{let a=await ze(t,n,u);a?(A()&&z(i,a),console.log(JSON.stringify(a))):(A()&&z(i,null),console.log(JSON.stringify(null)))}catch(a){let c=a.response?.data?JSON.stringify(a.response.data):a.message;A()&&j(i,"API_ERROR",c),d.fatal(`API Error: ${c}`)}}),e.command("ensure <name>").description("Find or create a category (idempotent)").action(async t=>{let i="category.ensure",s=await V.getToken();s||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let o=await H();o||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let n=o.projectID,u=new me.default({apiToken:s});try{let a=await rr(t,n,u);A()&&z(i,a),console.log(JSON.stringify(a))}catch(a){let c=a.response?.data?JSON.stringify(a.response.data):a.message;A()&&j(i,"API_ERROR",c),d.fatal(`API Error: ${c}`)}}),e.command("list").description("List all categories (same as list-categories)").action(async()=>{let t="category.list",i=await V.getToken();i||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let s=await H();s||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let o=s.projectID;d.info(`Using project ID from .derived/project.json: ${o}`);let n=new me.default({apiToken:i}),u=$();u.start("Fetching categories...");try{let a=await n.getProjectCategories(o);u.stop("Categories fetched");let c=a?.result??[];Array.isArray(c)&&c.length>0&&ee(o,c),A()&&z(t,c),console.log(JSON.stringify(c))}catch(a){u.stop("Failed to fetch categories");let c=a.response?.data?JSON.stringify(a.response.data):a.message;A()&&j(t,"API_ERROR",c),d.fatal(`API Error: ${c}`)}})}var O=new yr,se=new Ze.default;O.option("--json","Output structured JSON (agent-friendly)");O.hook("preAction",()=>{(O.opts().json||_)&&An(!0)});Tn(O);async function qs(r){let e=(0,Qe.join)((0,Vn.tmpdir)(),`cli-edit-${Date.now()}.json`);(0,T.writeFileSync)(e,JSON.stringify(r,null,2));let t=process.env.VISUAL||process.env.EDITOR||"nano";return new Promise((i,s)=>{(0,Mn.spawn)(t,[e],{stdio:"inherit"}).on("exit",n=>{if(n===0)try{let u=(0,T.readFileSync)(e,"utf-8"),a=JSON.parse(u);(0,T.unlinkSync)(e),i(a)}catch{(0,T.unlinkSync)(e),s(new Error("Invalid JSON format"))}else(0,T.unlinkSync)(e),s(new Error("Editor closed without saving"))})})}async function Rn(r,e){let t=$();t.start("Modifying block input...");let i=await se.getBlockInputFromUserQuery(JSON.stringify(r),e);return t.stop("Block input modified"),d.data(i.result,"Refined Block Input"),i.result}function Js(r,e="Block Input"){d.data(r,e)}function Gn(r,e){return se.resolveMultipleTemplates(r,e)}async function Hn(r,e){let t=await Gn(r,e),i=t.result.files.map(n=>n.resolvedPath),s=en(i),o=Me(s);d.note(o,`Files to be created (${t.result.files.length}):`)}async function Ye(r,e,t=!1,i){let s=$();s.start("Resolving Files...");let o=await Gn(r,e),n=o.result.files.filter(l=>{let D=(0,Qe.join)(process.cwd(),l.resolvedPath);return(0,T.existsSync)(D)&&(0,T.lstatSync)(D).isFile()&&l.templateType==="add"}),u=[],a=t;if(n.length>0&&!t){s.stop(`${n.length} conflicting files detected`),_&&d.fatal(`${n.length} file(s) already exist. Re-run with --overwrite to overwrite all.
98
+ Example: derived-cli add ${r} --overwrite`);let l=await Ce({message:"Some files already exist. How would you like to proceed?",options:[{value:"overwrite-all",label:"Overwrite all"},{value:"select",label:"Select files to overwrite"},{value:"skip-all",label:"Skip all"}]});if(J(l)&&d.cancel("Operation cancelled."),l==="overwrite-all")a=!0;else if(l==="select"){let D=await Jr({message:"Select files to overwrite",options:n.map(h=>({value:h.resolvedPath,label:h.resolvedPath}))});J(D)&&d.cancel("Operation cancelled."),u=D}s.start("Generating files...")}let c=Qr(o.result.files,u,a);if(c.errors?.length&&d.warn(`${c.errors.length} error(s) during file generation`),s.stop(`${c.addResults.length} files added, ${c.modifyResults.length} files modified, ${c.errors.length} errors`),c.addResults.length>0||c.modifyResults.length>0){if(Gt(r,e),i?.setupCommands&&i.setupCommands.trim()){let l=i.setupCommands.split(",").map(h=>h.trim()),D=$();for(let h of l)if(h){D.start(`Running setup command: ${h}`);try{await qe(h,{stdio:"inherit",cwd:process.cwd()}),D.stop(`Completed: ${h}`)}catch(E){D.stop(`Warning: Setup command failed: ${h}`),d.warn(E.message)}}}if(i?.aiInstruction&&i.aiInstruction.trim())return i.aiInstruction}return null}async function Us(r){let e=[],t=new Set;async function i(s){if(t.has(s))return;t.add(s);let o=await se.fetchBlock(s);if(o?.result?.id){if(o.result.dependsOn?.length)for(let n of o.result.dependsOn)await i(n.code);s!==r&&e.push(s)}}return await i(r),e}async function Ks(r,e,t,i=!1,s=!0){s&&d.intro(`Add block: ${r}`);let o=!1,n=$();n.start("Fetching block...");let u=await se.fetchBlock(r);if(u?.result?.id)n.stop(`Block found: ${u.result.name}${u.result.input?" (input required)":""}`);else return n.stop("Block not found"),null;let a=t||u.result.input;if(t){let c=await Ye(r,t,i,u.result);return o=!0,c}if(!a&&!o){let c=await Ye(r,{},i,u.result);return o=!0,c}if(a&&e&&!t){a=await Rn(a,e);let c=await Ye(r,a,i,u.result);return o=!0,c}for(;!o&&a&&!e;){Js(a),_&&d.fatal(`Block requires input. Re-run with --block-input <base64-json>.
99
+ Schema: ${JSON.stringify(a)}`);let l=await Ce({message:"What would you like to do?",options:[{value:"refine",label:"Edit (AI)"},{value:"edit",label:"Edit (Editor)"},{value:"showFiles",label:"Show files to be created"},{value:"done",label:"Insert Files"}]});if(J(l)&&d.cancel("Operation cancelled."),l==="refine"){let D=await St({message:"Describe what to refine:"});a=await Rn(a,D)}if(l==="edit"&&(a=await qs(a)),l==="done"){let D=await Ye(r,a,i,u.result);return o=!0,D}l==="showFiles"&&await Hn(r,a)}return null}async function Wn(r,e,t,i=!1){let n=[...await Us(r),r].filter(a=>a===r?!0:!nn(a));if(n.length===0){d.note(`Block "${r}" and all its dependencies are already added.`,"Nothing to do");return}if(n.length>1){let a=n.map((c,l)=>{let D=c===r;return` ${l+1}. ${c}${D?" (main)":" (dependency)"}`}).join(`
100
+ `);d.note(`${n.length} blocks will be processed:
101
+
102
+ ${a}`,"Processing Queue")}let u=[];for(let a=0;a<n.length;a++){let c=n[a];if(!c)continue;let l=c===r,D=a===n.length-1;n.length>1&&d.intro(`[${a+1}/${n.length}] Processing: ${c}${l?" (main)":""}`);let h=await Ks(c,l?e:void 0,l?t:null,i,n.length===1);h&&u.push({blockCode:c,instruction:h,isMain:l}),D||d.outro(`\u2713 ${c} completed`)}if(n.length>1&&d.outro(`All ${n.length} blocks processed`),u.length>0){let a="";u.length===1?a=u[0]?.instruction||"":a=u.map((c,l)=>{let D=c.isMain?`${c.blockCode} (main)`:c.blockCode;return`${l+1}. [${D}]
103
+ ${c.instruction}`}).join(`
97
104
 
98
- ${r.length} file(s) already exist and require user selection.
105
+ `),d.note(a,"Next Steps")}}async function zs(r,e={}){d.intro(`Searching: "${r}"`);let t=await H();t||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let i=t.projectID,s=$();s.start("Finding relevant blocks...");try{let o=await se.searchBlocksByName(r,i);if(s.stop("Search complete"),!o.result||o.result.length===0){d.outro("No blocks found.");return}let n;if(e.autoSelect||_){let c=o.result[0];if(!c){d.fatal("No blocks found in search results.");return}n=c.code,o.result.length>1?d.info(`Auto-selected: ${c.name} (${c.code}) \u2014 ${o.result.length-1} other match(es) skipped`):d.success(`Found: ${c.name} (${c.code})`)}else{let c=await Ce({message:`Found ${o.result.length} block(s). Select a block to add:`,options:o.result.map(D=>({value:D.code,label:D.name,hint:`Code: ${D.code} | Input: ${D.input?"Required":"Not required"}`}))});J(c)&&d.cancel("Operation cancelled."),n=c;let l=o.result.find(D=>D.code===n);l&&d.success(`Selected: ${l.name} (${l.code})`)}let u=o.result.find(c=>c.code===n);if(!u){d.fatal("Selected block not found.");return}let a=null;if(u.input&&Object.keys(u.input).length>0){let c=$();c.start("Resolving block input from query...");try{a=(await se.getBlockInputFromUserQuery(JSON.stringify(u.input),r)).result,c.stop("Block input resolved"),d.data(a,"Resolved Block Input")}catch(l){c.stop("Could not resolve input automatically"),d.warn(`Input resolution failed: ${l.message}`),d.info("Proceeding with default input schema.")}}await Wn(u.code,a?void 0:r,a||null,e.overwrite||!1)}catch(o){s.stop("Search failed"),d.fatal(`Error: ${o.message}`)}}O.command("help").description("List all commands and usage").action(()=>{console.log(`
106
+ Available commands:
99
107
 
100
- To resolve this, please restart the command with one of these flags:
108
+ GIT-LIKE WORKFLOW:
109
+ stage [paths...]
110
+ Stage files/directories for creating a block.
111
+ Paths can point to files or directories (directories are scanned recursively).
112
+ Example: derived-cli stage src/components/Button.tsx src/utils/
113
+ Example: derived-cli stage ./src/
101
114
 
102
- --overwrite : Automatically overwrite all existing files
115
+ status
116
+ Show staged files and added blocks (git-like format).
117
+ Example: derived-cli status
103
118
 
104
- Example:
105
- derived-cli add ${s} --overwrite
106
- `;d(D),process.exit(1)}let l=await Ae({message:"Some files already exist. How would you like to proceed?",options:[{value:"overwrite-all",label:"Overwrite all"},{value:"select",label:"Select files to overwrite"},{value:"skip-all",label:"Skip all"}]});if(G(l)&&(d("Operation cancelled."),process.exit(0)),l==="overwrite-all")a=!0;else if(l==="select"){let D=await Er({message:"Select files to overwrite",options:r.map(p=>({value:p.resolvedPath,label:p.resolvedPath}))});G(D)&&(d("Operation cancelled."),process.exit(0)),o=D}n.start("Generating files...")}let c=yr(u.result.files,o,a);if(c.errors?.length&&console.log(c.errors,"errors"),n.stop(`${c.addResults.length} files added, ${c.modifyResults.length} files modified, ${c.errors.length} errors`),c.addResults.length>0||c.modifyResults.length>0){if(Or(s,e),i?.setupCommands&&i.setupCommands.trim()){let l=i.setupCommands.split(",").map(p=>p.trim()),D=B();for(let p of l)if(p){D.start(`Running setup command: ${p}`);try{await Te(p,{stdio:"inherit",cwd:process.cwd()}),D.stop(`Completed: ${p}`)}catch(E){D.stop(`Warning: Setup command failed: ${p}`),console.warn(` ${E.message}`)}}}if(i?.aiInstruction&&i.aiInstruction.trim())return i.aiInstruction}return null}async function Qi(s){let e=[],t=new Set;async function i(n){if(t.has(n))return;t.add(n);let u=await Z.fetchBlock(n);if(u?.result?.id){if(u.result.dependsOn?.length)for(let r of u.result.dependsOn)await i(r.code);n!==s&&e.push(n)}}return await i(s),e}async function Zi(s,e,t,i=!1,n=!0){n&&oe(`Add block: ${s}`);let u=!1,r=B();r.start("Fetching block...");let o=await Z.fetchBlock(s);if(o?.result?.id)r.stop(`Block Found '${o.result.name}' ${o.result.input?"with input":""}`);else return r.stop("Block Not Found"),null;let a=t||o.result.input;if(t){let c=await Ie(s,t,i,o.result);return u=!0,c}if(!a&&!u){let c=await Ie(s,{},i,o.result);return u=!0,c}if(a&&e&&!t){a=await Qr(a,e);let c=await Ie(s,a,i,o.result);return u=!0,c}for(;!u&&a&&!e;){if(Ot(a),je()){let D=`This block requires input configuration, but user selection is not available.
119
+ unstage [paths...]
120
+ Remove files from the staging area.
121
+ Example: derived-cli unstage /src/components/Button.tsx
107
122
 
108
- To resolve this, please restart the command with below flag:
123
+ push
124
+ Push staged files to create a block in Derived.
125
+ Flags:
126
+ -c, --category <ref> : Category ID or name
127
+ -n, --name <name> : Block name
128
+ --find-or-create-category : Auto-create category if name not found
129
+ Example: derived-cli push -c 28 -n "my-component"
130
+ Example: derived-cli push -c "UI Components" -n "my-component" --find-or-create-category
109
131
 
110
- -i, --block-input <value> : Provide block input JSON schema (base64 encoded)
132
+ BLOCK MANAGEMENT:
133
+ add <block-id>
134
+ Add a block from Derived to your project.
135
+ Flags:
136
+ -q, --query <value> : Refine block input with AI
137
+ -i, --block-input <b64>: Block input as base64 JSON
138
+ -o, --overwrite : Overwrite existing files
139
+ -f, --force : Force re-add even if exists
140
+ Example: derived-cli add hero-section --overwrite
111
141
 
112
- Example: derived-cli add ${s} --block-input <base64-encoded-json>
142
+ search <query>
143
+ Search for blocks using natural language and add them.
144
+ Flags:
145
+ -a, --auto-select : Auto-select best match
146
+ -o, --overwrite : Overwrite existing files
147
+ Example: derived-cli search "add contact page"
113
148
 
149
+ create <category> <templateGroupName> [paths...]
150
+ Create templates from files (non-interactive).
151
+ <category> can be a category ID or name.
152
+ Flags:
153
+ --find-or-create-category : Auto-create category if name not found
154
+ Example: derived-cli create 28 "auth-jwt" /src/auth
155
+ Example: derived-cli create "UI Components" "hero-section" /src/components --find-or-create-category
114
156
 
115
- Follow this JSON structure for block input:
157
+ CATEGORY MANAGEMENT:
158
+ category find <name>
159
+ Find a category by name. Outputs the category JSON or null.
160
+ Example: derived-cli category find "UI Components"
116
161
 
117
- ${JSON.stringify(a,null,2)}
118
- `;d(D),process.exit(1)}let l=await Ae({message:"What would you like to do?",options:[{value:"refine",label:"Edit (AI)"},{value:"edit",label:"Edit (Editor)"},{value:"showFiles",label:"Show files to be created"},{value:"done",label:"Insert Files"}]});if(G(l)&&(d("Operation cancelled."),process.exit(0)),l==="refine"){let D=await Cr({message:"Describe what to refine:"});a=await Qr(a,D)}if(l==="edit"&&(a=await Yi(a)),l==="done"){let D=await Ie(s,a,i,o.result);return u=!0,D}l==="showFiles"&&await rs(s,a)}return null}async function ss(s,e,t,i=!1){let r=[...await Qi(s),s].filter(a=>a===s?!0:!_r(a));if(r.length===0){R(`Block "${s}" and all its dependencies are already added.`,"Nothing to do");return}if(r.length>1){let a=r.map((c,l)=>{let D=c===s;return` ${l+1}. ${c}${D?" (main)":" (dependency)"}`}).join(`
119
- `);R(`${r.length} blocks will be processed in order:
162
+ category ensure <name>
163
+ Find or create a category (idempotent). Always returns a category.
164
+ Example: derived-cli category ensure "UI Components"
120
165
 
121
- ${a}`,"Processing Queue")}let o=[];for(let a=0;a<r.length;a++){let c=r[a];if(!c)continue;let l=c===s,D=a===r.length-1;r.length>1&&oe(`[${a+1}/${r.length}] Processing: ${c}${l?" (main)":""}`);let p=await Zi(c,l?e:void 0,l?t:null,i,r.length===1);p&&o.push({blockCode:c,instruction:p,isMain:l}),D||q(`\u2713 ${c} completed`)}if(r.length>1){let a=`\u2713 All ${r.length} blocks processed successfully`;q(a)}if(o.length>0){let a="";o.length===1?a=o[0]?.instruction||"":a=o.map((c,l)=>{let D=c.isMain?`${c.blockCode} (main)`:c.blockCode;return`${l+1}. [${D}]
122
- ${c.instruction}`}).join(`
166
+ category list
167
+ List all categories in the project (same as list-categories).
168
+ Example: derived-cli category list
123
169
 
124
- `),R(a,"Next Steps")}}async function Xi(s,e={}){oe(`\u{1F50D} Searching for: "${s}"`);let t=B();t.start("Finding relevant blocks...");try{let i=await Z.searchBlocksByName(s);if(t.stop("Search complete"),!i.result||i.result.length===0){q("No blocks found matching your query.");return}let n;if(e.autoSelect||je()){let o=i.result[0];if(!o){d("No blocks found in search results.");return}n=o.code,i.result.length>1?(A.info(`Auto-selected best match: ${o.name} (${o.code})`),A.info(`${i.result.length-1} other match(es) available but not selected.`)):A.success(`Found exact match: ${o.name} (${o.code})`)}else{let o=await Ae({message:`Found ${i.result.length} block(s). Select a block to add:`,options:i.result.map((a,c)=>({value:a.code,label:`${a.name}`,hint:`Code: ${a.code} | Input: ${a.input?"Required":"Not required"}`}))});G(o)&&(d("Operation cancelled."),process.exit(0)),n=o}let u=i.result.find(o=>o.code===n);if(!u){d("Selected block not found.");return}!e.autoSelect&&!je()&&A.success(`Selected: ${u.name} (${u.code})`);let r=null;if(u.input&&Object.keys(u.input).length>0){let o=B();o.start("Resolving block input from your query...");try{r=(await Z.getBlockInputFromUserQuery(JSON.stringify(u.input),s)).result,o.stop("Block input resolved"),Ot(r,"Resolved Block Input")}catch(a){o.stop("Could not resolve input automatically"),A.warning(`Input resolution failed: ${a.message}`),A.info("Proceeding with default input schema \u2014 you can refine it in the next step.")}}await ss(u.code,r?void 0:s,r||null,e.overwrite||!1)}catch(i){t.stop("Search failed"),d(`Error: ${i.message}`)}}N.command("help").description("List all commands and usage").action(()=>{console.log(`
125
- Available commands:
170
+ create-category <categoryName>
171
+ Create a new category (legacy).
172
+ Example: derived-cli create-category "My Category"
126
173
 
127
- search <query>
128
- Search for blocks using natural language and add them to your project.
129
- Flags:
130
- -a, --auto-select : Automatically select the best match (agent-friendly mode)
131
- -o, --overwrite : Automatically overwrite existing files
132
- Example: derived-cli search "add contact page with name, contact number, city"
133
- Example (agent mode): derived-cli search "login page" --auto-select --overwrite
134
-
135
- add <block-id>
136
- Runs the interactive JSON builder with clack prompts.
137
- Use --overwrite to automatically overwrite existing files.
138
- Use --force to insert even if the block already exists.
139
- Example: derived-cli add hero-section --overwrite --force
140
-
141
- create <project-id> <category-id> <template-group-name> <paths...>
142
- Create a template group and templates from project files/folders.
143
- Paths can point to files or directories (directories are scanned recursively).
144
- Example: derived-cli create 28 2 go-auth-jwt /src/auth /src/middleware/auth.go
174
+ list-categories
175
+ List all categories in the project (legacy).
176
+ Example: derived-cli list-categories
145
177
 
178
+ PROJECT MANAGEMENT:
146
179
  init <project-slug>
147
- Initialize a project from a template in the current directory.
148
- The directory must be empty. Clones the project repository,
149
- removes git metadata, and runs setup commands.
180
+ Initialize a project from a template.
150
181
  Example: derived-cli init react-ts
151
182
 
152
- create-category <projectId> <categoryName>
153
- Create a new category in a project.
154
- Example: derived-cli create-category 123 "My Category"
183
+ project
184
+ Fetch current project details.
185
+ Example: derived-cli project
155
186
 
156
- help
157
- Show this help text.
158
- `)});var is=s=>{let e=B();try{e.start("Decoding base64...");let t=Buffer.from(s,"base64").toString("utf8"),i=JSON.parse(t);for(;typeof i!="object";)i=JSON.parse(i);return e.stop("Decoded input successfully"),i}catch{return e.stop("Failed to decode input"),null}};N.command("add <blockCode>").description("Generate and refine a JSON block interactively").option("-q, --query <value>","Optional user input").option("-i, --block-input <value>","Optional block input json schema in base 64").option("-o, --overwrite","Automatically overwrite existing files").option("-f, --force","Force insert even if block already exists").action(async(s,e)=>{let t=e.blockInput?is(e.blockInput):null;if(Et(s,t||{})&&!e.force){R(`Block "${s}" with the same input configuration is already added to this project.
187
+ GLOBAL FLAGS:
188
+ --json
189
+ Output structured JSON (agent-friendly). Auto-enabled in non-TTY environments.
159
190
 
160
- Use -f to force re-add.`,"Already Added");return}let n=xr(s,t||{});if(n.length>0&&!e.force){let u=n.length;R(`Block "${s}" has already been added ${u} time${u>1?"s":""} with different input configuration${u>1?"s":""}.
191
+ AUTH:
192
+ register <token>
193
+ Register with your account token.
194
+ Example: derived-cli register abc123
161
195
 
162
- Proceeding to add with new input configuration...`,"Different Input Detected")}await ss(s,e.query,t,e.overwrite)});N.command("search <query>").description("Search and add blocks using natural language").option("-a, --auto-select","Automatically select the best match (agent-friendly mode)").option("-o, --overwrite","Automatically overwrite existing files").action(async(s,e)=>{await Xi(s,{autoSelect:e.autoSelect,overwrite:e.overwrite})});N.command("create <projectId> <categoryId> <templateGroupName> [paths...]").description("Create templates from provided files/folders and group them into a template group").action(async(s,e,t,i=[])=>{let n=await L.getToken();n||(d("You must be logged in to create templates. Please run 'derived-cli register <token>' first."),process.exit(1));let u=Number.parseInt(s,10);Number.isNaN(u)&&(d("Invalid project ID. Please provide a numeric value."),process.exit(1));let r=Number.parseInt(e,10);Number.isNaN(r)&&(d("Invalid category ID. Please provide a numeric value."),process.exit(1));let o=i.filter(y=>y.trim().length>0);o.length===0&&(d("At least one file or directory path is required."),process.exit(1));let a=B();a.start("Collecting files from provided paths...");let{files:c,errors:l}=Jr(o);a.stop(`Collected ${c.length} file(s) from ${o.length} path(s)`);for(let y of l)A.warning(y);c.length===0&&(d("No valid files found to create templates from."),process.exit(1));let D=new ie.default({apiToken:n}),p=B();p.start("Creating template group...");let E=null,$=null;try{$=await D.createTemplateGroup({name:t,projectID:u,blockCategoryId:r});let y=Number($?.result?.id);if(!Number.isInteger(y)||y<=0)throw new Error("Template group created but no valid group ID was returned.");E=y,p.stop(`Template group created ${E}`)}catch(y){p.stop("Failed to create template group"),y.response?.data?d(`API Error: ${JSON.stringify(y.response.data)}`):d(`Error: ${y.message}`),process.exit(1)}E===null&&(d("Template group could not be created."),process.exit(1));let X=c.map(y=>({type:"add",templateGroupId:E,path:y.templatePath,template:y.template})),J=B();J.start(`Creating ${X.length} template(s)...`);try{await D.createMultipleTemplates(X),J.stop(`Created ${X.length} template(s) successfully`),q(`Template group "${t}" created successfully.`),console.log($?.result)}catch(y){J.stop("Failed to create templates"),y.response?.data?d(`API Error: ${JSON.stringify(y.response.data)}`):d(`Error: ${y.message}`),process.exit(1)}});N.command("create-template-group").description("Create a new template group").option("-p, --payload <value>","Base64 encoded JSON payload").action(async s=>{let e=await L.getToken();e||(d("You must be logged in to create a template group. Please run 'derived-cli register <token>' first."),process.exit(1)),s.payload||(d("Payload is required (--payload <base64-json>)"),process.exit(1));let t=is(s.payload);t||(d("Invalid base64 payload"),process.exit(1));let i=new ie.default({apiToken:e}),n=B();n.start("Creating template group...");try{let u=await i.createTemplateGroup(t);n.stop("Template group created successfully"),u?.result?.id?console.log(u.result.id):console.log(JSON.stringify(u))}catch(u){n.stop("Failed to create template group"),u.response?.data?d(`API Error: ${JSON.stringify(u.response.data)}`):d(`Error: ${u.message}`),process.exit(1)}});N.command("create-category <projectId> <categoryName>").description("Create a new category in a project").action(async(s,e)=>{let t=await L.getToken();t||(d("You must be logged in to create a category. Please run 'derived-cli register <token>' first."),process.exit(1));let i=Number.parseInt(s,10);Number.isNaN(i)&&(d("Invalid project ID. Please provide a numeric value."),process.exit(1));let n=new ie.default({apiToken:t}),u=B();u.start("Creating category...");try{let r=await n.createCategory({name:e,projectId:i,active:!0});u.stop("Category created successfully"),r?.result?.id?console.log(r.result.id):console.log(JSON.stringify(r))}catch(r){u.stop("Failed to create category"),r.response?.data?d(`API Error: ${JSON.stringify(r.response.data)}`):d(`Error: ${r.message}`),process.exit(1)}});N.command("list-categories <projectId>").description("List all categories in a project").action(async s=>{let e=await L.getToken();e||(d("You must be logged in to list categories. Please run 'derived-cli register <token>' first."),process.exit(1)),s||(d("Project ID is required"),process.exit(1));let t=new ie.default({apiToken:e}),i=B();i.start("Fetching categories...");try{let n=await t.getProjectCategories(parseInt(s));i.stop("Categories fetched successfully"),n?.result?console.log(JSON.stringify(n.result,null,2)):console.log("No categories found or invalid response structure")}catch(n){i.stop("Failed to fetch categories"),n.response?.data?d(`API Error: ${JSON.stringify(n.response.data)}`):d(`Error: ${n.message}`),process.exit(1)}});async function Zr(s,e){let{existsSync:t,mkdirSync:i,writeFileSync:n}=await import("fs"),{join:u}=await import("path"),r=u(s,".derived");t(r)||i(r,{recursive:!0});let o={projectID:e.id,projectSlug:e.slug,projectName:e.name,ownerUsername:e.ownerUsername,gitUrl:e.gitUrl,description:e.description},a=u(r,"project.json");n(a,JSON.stringify(o,null,2))}N.command("init <project-slug>").description("Initialize a project from a template").action(async s=>{oe(`\u{1F680} Initializing project: ${s}`);try{let e=process.cwd(),{isDirectoryEmpty:t,removeGitDirectory:i}=await Promise.resolve().then(()=>(Yr(),zr)),{existsSync:n}=await import("fs"),{join:u}=await import("path"),r=t(e),o=B();o.start("Fetching project details...");let a=await Z.fetchProjectBySlug(s);a?.result||(o.stop("\u274C Project not found"),d(`Project with slug '${s}' does not exist.`),process.exit(1));let c=a.result;if(o.stop(`\u2705 Found project: ${c.name}`),!r){let l=u(e,".derived","project.json");if(n(l)){let D=await Fr({message:"project.json already exists. Do you want to overwrite it?"});G(D)&&(d("Operation cancelled."),process.exit(0)),D||(q("Skipped updating project.json"),process.exit(0))}await Zr(e,c),q("Updated project.json in .derived folder"),process.exit(0)}o.start(`Cloning repository from ${c.gitUrl}...`);try{await Te(`git clone ${c.gitUrl} .`,{stdio:"pipe",cwd:e}),o.stop("\u2705 Repository cloned successfully")}catch(l){o.stop("\u274C Failed to clone repository"),d(`Git clone failed: ${l.message}`),process.exit(1)}if(i(e),c.setupCommand&&c.setupCommand.trim()){let l=c.setupCommand.split(",").map(D=>D.trim());for(let D of l)if(D){o.start(`Running: ${D}`);try{await Te(D,{stdio:"inherit",cwd:e}),o.stop(`\u2705 Completed: ${D}`)}catch(p){o.stop(`\u26A0\uFE0F Warning: Command failed: ${D}`),console.warn(` ${p.message}`)}}}await Zr(e,c),q(`\u{1F389} Project '${c.name}' setup successfully!`)}catch(e){d(`\u274C An error occurred: ${e.message}`),process.exit(1)}});N.command("register <token>").description("Register with your account token").action(async s=>{try{await L.saveToken(s),A.success("Token saved successfully!")}catch(e){d(`Failed to save token: ${e.message}`)}});N.parse();0&&(module.exports={displayFileTree});
196
+ help
197
+ Show this help text.
198
+ `)});var Ys=r=>{let e=$();try{e.start("Decoding base64...");let t=Buffer.from(r,"base64").toString("utf8"),i=JSON.parse(t);for(;typeof i!="object";)i=JSON.parse(i);return e.stop("Decoded input"),i}catch{return e.stop("Failed to decode input"),null}};O.command("add <blockCode>").description("Generate and refine a JSON block interactively").option("-q, --query <value>","Optional user input").option("-i, --block-input <value>","Optional block input json schema in base 64").option("-o, --overwrite","Automatically overwrite existing files").option("-f, --force","Force insert even if block already exists").action(async(r,e)=>{let t=e.blockInput?Ys(e.blockInput):null;if(Vt(r,t||{})&&!e.force){d.note(`Block "${r}" with the same input is already added. Use -f to force re-add.`,"Already Added");return}let s=sn(r,t||{});if(s.length>0&&!e.force){let o=s.length;d.note(`Block "${r}" was added ${o} time${o>1?"s":""} with different input. Proceeding with new input...`,"Different Input Detected")}await Wn(r,e.query,t,e.overwrite)});O.command("search <query>").description("Search and add blocks using natural language").option("-a, --auto-select","Automatically select the best match (agent-friendly mode)").option("-o, --overwrite","Automatically overwrite existing files").action(async(r,e)=>{await zs(r,{autoSelect:e.autoSelect,overwrite:e.overwrite})});O.command("create <category> <templateGroupName> [paths...]").description("Create templates from provided files/folders. <category> can be a category ID or name.").option("--find-or-create-category","If category name is given, create it if it does not exist").action(async(r,e,t=[],i)=>{let s="create",o=await V.getToken();o||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let n=await H();n||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let u=n.projectID;d.info(`Using project ID from .derived/project.json: ${u}`);let a=new Ze.default({apiToken:o}),c=0;try{c=await nr(r,u,a,{findOrCreate:i.findOrCreateCategory})}catch(C){A()&&j(s,"CATEGORY_NOT_FOUND",C.message),d.fatal(C.message);return}let l=t.filter(C=>C.trim().length>0);l.length===0&&d.fatal("At least one file or directory path is required.");let D=$();D.start("Collecting files...");let{files:h,errors:E}=er(l);D.stop(`Collected ${h.length} file(s) from ${l.length} path(s)`);for(let C of E)d.warn(C);h.length===0&&d.fatal("No valid files found.");let B=$();B.start("Creating template group...");let G=null,m=null;try{m=await a.createTemplateGroup({name:e,projectID:u,blockCategoryId:c});let C=Number(m?.result?.id);if(!Number.isInteger(C)||C<=0)throw new Error("Template group created but no valid group ID was returned.");G=C,B.stop(`Template group created: ${G}`)}catch(C){B.stop("Failed to create template group");let F=C.response?.data?JSON.stringify(C.response.data):C.message;A()&&j(s,"API_ERROR",F),d.fatal(`API Error: ${F}`)}G===null&&d.fatal("Template group could not be created.");let y=h.map(C=>({type:"add",templateGroupId:G,path:C.templatePath,template:C.template})),W=$();W.start(`Creating ${y.length} template(s)...`);try{await a.createMultipleTemplates(y),W.stop(`Created ${y.length} template(s)`);let C={templateGroup:m?.result,categoryId:c,templateCount:h.length};A()&&z(s,C),d.outro(`Template group "${e}" created`),console.log(JSON.stringify(m?.result))}catch(C){W.stop("Failed to create templates");let F=C.response?.data?JSON.stringify(C.response.data):C.message;A()&&j(s,"API_ERROR",F),d.fatal(`API Error: ${F}`)}});async function ir(r,e){let{existsSync:t,mkdirSync:i,writeFileSync:s}=await import("fs"),{join:o}=await import("path"),n=o(r,".derived");t(n)||i(n,{recursive:!0});let u={projectID:e.id,projectSlug:e.slug,projectName:e.name,ownerUsername:e.ownerUsername,gitUrl:e.gitUrl,description:e.description},a=o(n,"project.json");s(a,JSON.stringify(u,null,2))}O.command("project").description("Fetch current project details using slug from .derived/project.json").action(async()=>{let r=await H();if(!r){d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");return}let e=r.projectSlug,t=$();t.start(`Fetching project details for '${e}'...`);try{let i=await se.fetchProjectBySlug(e);i?.result||(t.stop("Project not found"),d.fatal(`Project '${e}' not found. Run 'derived-cli init <project-slug>' to initialize this directory with a valid project.`)),t.stop("Project details fetched"),console.log(JSON.stringify(i.result))}catch(i){i?.response?.status===404&&(t.stop("Project not found"),d.fatal(`Project '${e}' not found. Run 'derived-cli init <project-slug>' to initialize this directory with a valid project.`)),t.stop("Failed to fetch project details");let s=i.response?.data?JSON.stringify(i.response.data):i.message;d.fatal(`API Error: ${s}`)}});O.command("init <project-slug>").description("Initialize a project from a template").action(async r=>{d.intro(`Initializing project: ${r}`);try{let e=process.cwd(),{isDirectoryEmpty:t,removeGitDirectory:i}=await Promise.resolve().then(()=>(Nn(),In)),{existsSync:s}=await import("fs"),{join:o}=await import("path"),n=t(e),u=$();u.start("Fetching project details...");let a=await se.fetchProjectBySlug(r);a?.result||(u.stop("Project not found"),d.fatal(`Project '${r}' does not exist.`));let c=a.result;if(u.stop(`Found project: ${c.name}`),!n){let l=o(e,".derived","project.json");if(s(l)){_&&(await ir(e,c),d.outro("project.json updated"),process.exit(0));let D=await qr({message:"project.json already exists. Overwrite?"});J(D)&&d.cancel("Operation cancelled."),D||(d.outro("Skipped updating project.json"),process.exit(0))}await ir(e,c),d.outro("project.json updated in .derived folder"),process.exit(0)}u.start("Cloning repository...");try{await qe(`git clone ${c.gitUrl} .`,{stdio:"pipe",cwd:e}),u.stop("Repository cloned")}catch(l){u.stop("Failed to clone repository"),d.fatal(`Git clone failed: ${l.message}`)}if(i(e),c.setupCommand&&c.setupCommand.trim()){let l=c.setupCommand.split(",").map(D=>D.trim());for(let D of l)if(D){u.start(`Running: ${D}`);try{await qe(D,{stdio:"inherit",cwd:e}),u.stop(`Completed: ${D}`)}catch(h){u.stop(`Warning: Command failed: ${D}`),d.warn(h.message)}}}await ir(e,c),d.outro(`Project '${c.name}' initialized`)}catch(e){d.fatal(`An error occurred: ${e.message}`)}});O.command("status").description("Show staged files and added blocks").action(async()=>{try{let r=Fe(),e=oe(),t=r.length>0,i=e.addedBlocks.length>0;if(!t&&!i){d.note("Nothing to show. Use 'derived-cli stage <path>' to stage files.","Status");return}if(t){console.log(`
199
+ \x1B[32mChanges to be pushed:\x1B[0m`),console.log(` \x1B[32m(use "derived-cli unstage <path>" to unstage)\x1B[0m
200
+ `);for(let s of r)console.log(`\x1B[32m new file: ${s.path}\x1B[0m`)}if(i){t&&console.log(""),console.log("\x1B[36mBlocks added to this project:\x1B[0m"),console.log(` \x1B[36m(${e.addedBlocks.length} block(s))\x1B[0m
201
+ `);for(let s of e.addedBlocks){let o=Object.keys(s.input||{}).length>0?` ${JSON.stringify(s.input)}`:"";console.log(`\x1B[36m ${s.code}${o}\x1B[0m`)}}console.log("")}catch(r){d.fatal(`Failed to get status: ${r instanceof Error?r.message:String(r)}`)}});O.command("blocks-status").description("Show all blocks that have been added to the project").action(async()=>{try{let e=oe().addedBlocks;if(e.length===0){d.note("No blocks have been added yet.","Blocks Status");return}d.note(`${e.length} block(s) added to this project:`,"Blocks Status"),e.forEach((t,i)=>{let s=JSON.stringify(t.input),o=s==="{}"?"(no input)":s;d.note(` ${i+1}. ${t.code} ${o}`,"")})}catch(r){d.fatal(`Failed to get blocks status: ${r.message}`)}});O.command("stage [paths...]").description("Stage files/directories for creating a block (git-like)").action(async(r=[])=>{try{if(r.length===0){d.note("No paths provided. Usage: derived-cli stage <path1> [path2] ...");return}let{files:e,errors:t}=er(r);for(let o of t)d.warn(o);if(e.length===0){d.fatal("No valid files found to stage.");return}let i=0,s=0;for(let o of e){if(Lt(o.templatePath)){s++;continue}an(o.templatePath),i++}i>0&&d.success(`Staged ${i} file(s)`),s>0&&d.note(`${s} file(s) already staged (skipped)`)}catch(e){d.fatal(`Failed to stage files: ${e instanceof Error?e.message:String(e)}`)}});O.command("unstage [paths...]").description("Remove files from the staging area").action(async(r=[])=>{try{if(r.length===0){d.note("No paths provided. Usage: derived-cli unstage <path1> [path2] ...");return}let e=Fe(),t=new Set(e.map(o=>o.path)),i=0,s=0;for(let o of r)t.has(o)?(cn(o),i++):(s++,d.warn(`Not staged: ${o}`));i>0&&d.success(`Unstaged ${i} file(s)`),s>0&&i===0&&d.note("No matching staged files found.")}catch(e){d.fatal(`Failed to unstage: ${e.message}`)}});O.command("clear-staging").description("Clear all files from the staging area").action(async()=>{try{let r=Fe();if(r.length===0){d.note("No files are currently staged.");return}qt(),d.success(`Cleared ${r.length} file(s) from staging area`)}catch(r){d.fatal(`Failed to clear staging: ${r.message}`)}});O.command("push").description("Push staged files to create a block in Derived").option("-c, --category <ref>","Category ID or name").option("-n, --name <name>","Block name").option("--find-or-create-category","If category name is given, create it if it does not exist").action(async r=>{let e="push";try{let t=await V.getToken();t||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let i=await H();i||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let s=Fe();if(s.length===0){d.note("No files are currently staged. Use 'derived-cli stage <path>' to stage files.");return}d.intro(`Pushing ${s.length} staged file(s)`);let o=new Ze.default({apiToken:t}),n=i.projectID,u=0,a;if(r.category&&r.name){let m=String(r.category);try{u=await nr(m,n,o,{findOrCreate:r.findOrCreateCategory})}catch(y){A()&&j(e,"CATEGORY_NOT_FOUND",y.message),d.fatal(y.message);return}a=r.name}else{if(_){d.fatal("Category and name required in agent mode. Use: derived-cli push -c <categoryId|name> -n <blockName>");return}let m=$();m.start("Fetching categories...");let y=[];try{y=(await o.getProjectCategories(n))?.result||[],Array.isArray(y)&&y.length>0&&ee(n,y),m.stop(`Found ${y.length} categories`)}catch(F){m.stop("Failed to fetch categories"),d.fatal(`Error: ${F.message}`);return}if(y.length===0){d.fatal("No categories found. Create one first with 'derived-cli create-category <name>'");return}let W=await Ce({message:"Select a category for the block:",options:y.map(F=>({value:F.id,label:F.name,hint:`ID: ${F.id}`}))});if(J(W)){d.cancel("Operation cancelled.");return}u=W;let C=await St({message:"Enter a name for the block:",placeholder:"e.g., my-component"});if(J(C)){d.cancel("Operation cancelled.");return}if(a=C,!a||a.trim()===""){d.fatal("Block name is required.");return}}let c=$();c.start("Collecting file contents...");let l=s.map(m=>{let y=(0,Qe.join)(process.cwd(),m.path.replace(/^\//,"")),W=(0,T.existsSync)(y)?(0,T.readFileSync)(y,"utf-8"):"";return{templatePath:m.path,template:W}});c.stop(`Collected ${l.length} file(s)`);let D=$();D.start("Creating template group...");let h=null,E=null;try{E=await o.createTemplateGroup({name:a,projectID:n,blockCategoryId:u});let m=Number(E?.result?.id);if(!Number.isInteger(m)||m<=0)throw new Error("Template group created but no valid group ID was returned.");h=m,D.stop(`Template group created: ${h}`)}catch(m){D.stop("Failed to create template group");let y=m.response?.data?JSON.stringify(m.response.data):m.message;A()&&j(e,"API_ERROR",y),d.fatal(`API Error: ${y}`);return}if(h===null){d.fatal("Template group could not be created.");return}let B=l.map(m=>({type:"add",templateGroupId:h,path:m.templatePath,template:m.template})),G=$();G.start(`Creating ${B.length} template(s)...`);try{await o.createMultipleTemplates(B),G.stop(`Created ${B.length} template(s)`),qt(),Gt(a,{categoryId:u,fileCount:l.length});let m={templateGroup:E?.result,categoryId:u,fileCount:l.length};A()&&z(e,m),d.outro(`Block "${a}" created with ${l.length} file(s)`),console.log(JSON.stringify(E?.result))}catch(m){G.stop("Failed to create templates");let y=m.response?.data?JSON.stringify(m.response.data):m.message;A()&&j(e,"API_ERROR",y),d.fatal(`API Error: ${y}`)}}catch(t){d.fatal(`Failed to push: ${t.message}`)}});O.command("register <token>").description("Register with your account token").action(async r=>{try{await V.saveToken(r),d.success("Token saved")}catch(e){d.fatal(`Failed to save token: ${e.message}`)}});(async()=>{try{await O.parseAsync()}catch(r){throw r instanceof ne&&(A()&&j("cli",r.code,r.message),process.exit(r.code==="CANCELLED"?0:1)),r}})();0&&(module.exports={displayFileTree});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "derived-cli",
3
- "version": "0.0.67",
3
+ "version": "0.0.71",
4
4
  "description": "CLI for Derived",
5
5
  "author": "Derived",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "@clack/prompts": "^0.11.0",
26
26
  "clipboardy": "^5.1.0",
27
27
  "commander": "^14.0.2",
28
- "derived-sdk": "^0.0.16",
28
+ "derived-sdk": "^0.0.17",
29
29
  "dotenv": "16.4.5",
30
30
  "inquirer": "^12.6.0",
31
31
  "keytar": "^7.9.0",