derived-cli 0.0.71 → 0.0.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +96 -123
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`)}displayWidth(e){return
|
|
4
|
-
`+" ".repeat(t+a)),
|
|
5
|
-
${
|
|
6
|
-
`)}};function
|
|
2
|
+
"use strict";var Or=Object.create;var fe=Object.defineProperty;var Sr=Object.getOwnPropertyDescriptor;var kr=Object.getOwnPropertyNames;var Tr=Object.getPrototypeOf,Pr=Object.prototype.hasOwnProperty;var jr=(n,e)=>()=>(n&&(e=n(n=0)),e);var R=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Yt=(n,e)=>{for(var t in e)fe(n,t,{get:e[t],enumerable:!0})},Qt=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of kr(e))!Pr.call(n,s)&&s!==t&&fe(n,s,{get:()=>e[s],enumerable:!(i=Sr(e,s))||i.enumerable});return n};var y=(n,e,t)=>(t=n!=null?Or(Tr(n)):{},Qt(e||!n||!n.__esModule?fe(t,"default",{value:n,enumerable:!0}):t,n)),Ir=n=>Qt(fe({},"__esModule",{value:!0}),n);var ce=R(Ue=>{var ge=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}},Je=class extends ge{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Ue.CommanderError=ge;Ue.InvalidArgumentError=Je});var Ce=R(Ke=>{var{InvalidArgumentError:Nr}=ce(),ze=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 Nr(`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 Mr(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}Ke.Argument=ze;Ke.humanReadableArgName=Mr});var Ze=R(Qe=>{var{humanReadableArgName:Rr}=Ce(),Ye=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,u)=>s.name().localeCompare(u.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),u=i.long&&e._findOption(i.long);!s&&!u?t.push(i):i.long&&!u?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(u=>!u.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=>Rr(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(u=>{let r=i(u);s.has(r)||s.set(r,[])}),t.forEach(u=>{let r=i(u);s.has(r)||s.set(r,[]),s.get(r).push(u)}),s}formatHelp(e,t){let i=t.padWidth(e,t),s=t.helpWidth??80;function u(D,d){return t.formatItem(D,i,d,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),s),""]));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,d)=>{let C=D.map($=>u(t.styleOptionTerm(t.optionTerm($)),t.styleOptionDescription(t.optionDescription($))));r=r.concat(this.formatItemList(d,C,t))}),t.showGlobalOptions){let D=t.visibleGlobalOptions(e).map(d=>u(t.styleOptionTerm(t.optionTerm(d)),t.styleOptionDescription(t.optionDescription(d))));r=r.concat(this.formatItemList("Global Options:",D,t))}return this.groupItems(e.commands,t.visibleCommands(e),D=>D.helpGroup()||"Commands:").forEach((D,d)=>{let C=D.map($=>u(t.styleSubcommandTerm(t.subcommandTerm($)),t.styleSubcommandDescription(t.subcommandDescription($))));r=r.concat(this.formatItemList(d,C,t))}),r.join(`
|
|
3
|
+
`)}displayWidth(e){return Zt(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 r=" ".repeat(2);if(!i)return r+e;let o=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)),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/),s=/[\s]*[^\s]+/g,u=[];return i.forEach(r=>{let o=r.match(s);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 d=l.trimStart();a=[d],c=this.displayWidth(d)}),u.push(a.join(""))}),u.join(`
|
|
6
|
+
`)}};function Zt(n){let e=/\x1b\[\d*(;\d*)*m/g;return n.replace(e,"")}Qe.Help=Ye;Qe.stripColor=Zt});var nt=R(tt=>{var{InvalidArgumentError:Vr}=ce(),Xe=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=Gr(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 Vr(`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?Xt(this.name().replace(/^no-/,"")):Xt(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}},et=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,u=s!==void 0?s:!1;return t.negate===(u===e)}};function Xt(n){return n.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Gr(n){let e,t,i=/^-[^-]$/,s=/^--[^-]/,u=n.split(/[ |,]+/).concat("guard");if(i.test(u[0])&&(e=u.shift()),s.test(u[0])&&(t=u.shift()),!e&&i.test(u[0])&&(e=u.shift()),!e&&s.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 '${n}'`;throw/^-[^-][^-]/.test(r)?new Error(`${o}
|
|
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(
|
|
10
|
-
- too many short flags`):s.test(
|
|
11
|
-
- too many long flags`):new Error(`${
|
|
12
|
-
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${
|
|
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`):s.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 '${n}'.`);return{shortFlag:e,longFlag:t}}tt.Option=Xe;tt.DualOptions=et});var tn=R(en=>{function Hr(n,e){if(Math.abs(n.length-e.length)>3)return Math.max(n.length,e.length);let t=[];for(let i=0;i<=n.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<=n.length;s++){let u=1;n[s-1]===e[i-1]?u=0:u=1,t[s][i]=Math.min(t[s-1][i]+1,t[s][i-1]+1,t[s-1][i-1]+u),s>1&&i>1&&n[s-1]===e[i-2]&&n[s-2]===e[i-1]&&(t[s][i]=Math.min(t[s][i],t[s-2][i-2]+1))}return t[n.length][e.length]}function Wr(n,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=n.startsWith("--");t&&(n=n.slice(2),e=e.map(r=>r.slice(2)));let i=[],s=3,u=.4;return e.forEach(r=>{if(r.length<=1)return;let o=Hr(n,r),a=Math.max(n.length,r.length);(a-o)/a>u&&(o<s?(s=o,i=[r]):o===s&&i.push(r))}),i.sort((r,o)=>r.localeCompare(o)),t&&(i=i.map(r=>`--${r}`)),i.length>1?`
|
|
13
13
|
(Did you mean one of ${i.join(", ")}?)`:i.length===1?`
|
|
14
|
-
(Did you mean ${i[0]}?)`:""}
|
|
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
|
|
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
|
|
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("|"),
|
|
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(
|
|
14
|
+
(Did you mean ${i[0]}?)`:""}en.suggestSimilar=Wr});var un=R(ot=>{var qr=require("node:events").EventEmitter,rt=require("node:child_process"),H=require("node:path"),Fe=require("node:fs"),f=require("node:process"),{Argument:Lr,humanReadableArgName:Jr}=Ce(),{CommanderError:it}=ce(),{Help:Ur,stripColor:zr}=Ze(),{Option:nn,DualOptions:Kr}=nt(),{suggestSimilar:rn}=tn(),st=class n extends qr{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:()=>ut()??(f.stdout.isTTY&&f.stdout.hasColors?.()),getErrHasColors:()=>ut()??(f.stderr.isTTY&&f.stderr.hasColors?.()),stripColor:t=>zr(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,u=i;typeof s=="object"&&s!==null&&(u=s,s=null),u=u||{};let[,r,o]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(r);return s&&(a.description(s),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),s?this:a}createCommand(e){return new n(e)}createHelp(){return Object.assign(new Ur,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 Lr(e,t)}argument(e,t,i,s){let u=this.createArgument(e,t);return typeof i=="function"?u.default(s).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]",[,s,u]=i.match(/([^ ]+) *(.*)/),r=t??"display help for command",o=this.createCommand(s);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 it(e,t,i)),f.exit(e)}action(e){let t=i=>{let s=this.registeredArguments.length,u=i.slice(0,s);return this._storeOptionsAsProperties?u[s]=this:u[s]=this.opts(),u.push(this),e.apply(this,u)};return this._actionHandler=t,this}createOption(e,t){return new nn(e,t)}_callParseArg(e,t,i,s){try{return e.parseArg(t,i)}catch(u){if(u.code==="commander.invalidArgument"){let r=`${s} ${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=s=>[s.name()].concat(s.aliases()),i=t(e).find(s=>this._findCommand(s));if(i){let s=t(this._findCommand(i)).join("|"),u=t(e).join("|");throw new Error(`cannot add command '${u}' 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 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 s=(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.`;s(u,r,"cli")}),e.envVar&&this.on("optionEnv:"+t,u=>{let r=`error: option '${e.flags}' value '${u}' from env '${e.envVar}' is invalid.`;s(u,r,"env")}),this}_optionEx(e,t,i,s,u){if(typeof t=="object"&&t instanceof nn)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 s=="function")r.default(u).argParser(s);else if(s instanceof RegExp){let o=s;s=(a,c)=>{let l=o.exec(a);return l?l[0]:c},r.default(u).argParser(s)}else r.default(s);return this.addOption(r)}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){f.versions?.electron&&(t.from="electron");let s=f.execArgv??[];(s.includes("-e")||s.includes("--eval")||s.includes("-p")||s.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(Fe.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",u=`'${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
|
-
- ${s}`;throw new Error(
|
|
21
|
+
- ${s}`;throw new Error(u)}_executeSubCommand(e,t){t=t.slice();let i=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function u(l,D){let d=H.resolve(l,D);if(Fe.existsSync(d))return d;if(s.includes(H.extname(D)))return;let C=s.find($=>Fe.existsSync(`${d}${$}`));if(C)return`${d}${C}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=e._executableFile||`${this._name}-${e._name}`,o=this._executableDir||"";if(this._scriptPath){let l;try{l=Fe.realpathSync(this._scriptPath)}catch{l=this._scriptPath}o=H.resolve(H.dirname(l),o)}if(o){let l=u(o,r);if(!l&&!e._executableFile&&this._scriptPath){let D=H.basename(this._scriptPath,H.extname(this._scriptPath));D!==this._name&&(l=u(o,`${D}-${e._name}`))}r=l||r}i=s.includes(H.extname(r));let a;f.platform!=="win32"?i?(t.unshift(r),t=sn(f.execArgv).concat(t),a=rt.spawn(f.argv[0],t,{stdio:"inherit"})):a=rt.spawn(r,t,{stdio:"inherit"}):(this._checkForMissingExecutable(r,o,e._name),t.unshift(r),t=sn(f.execArgv).concat(t),a=rt.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 it(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 it(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 u;return u=this._chainOrCallSubCommandHook(u,s,"preSubcommand"),u=this._chainOrCall(u,()=>{if(s._executableHandler)this._executeSubCommand(s,t.concat(i));else return s._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,s,u)=>{let r=s;if(s!==null&&i.parseArg){let o=`error: command-argument value '${s}' is invalid for argument '${i.name()}'.`;r=this._callParseArg(i,s,u,o)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((i,s)=>{let u=i.defaultValue;i.variadic?s<this.args.length?(u=this.args.slice(s),i.parseArg&&(u=u.reduce((r,o)=>e(i,o,r),i.defaultValue))):u===void 0&&(u=[]):s<this.args.length&&(u=this.args[s],i.parseArg&&(u=e(i,u,i.defaultValue))),t[s]=u}),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(u=>u._lifeCycleHooks[t]!==void 0).forEach(u=>{u._lifeCycleHooks[t].forEach(r=>{s.push({hookedCommand:u,callback:r})})}),t==="postAction"&&s.reverse(),s.forEach(u=>{i=this._chainOrCall(i,()=>u.callback(u.hookedCommand,this))}),i}_chainOrCallSubCommandHook(e,t,i){let s=e;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(u=>{s=this._chainOrCall(s,()=>u(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])},u=`command:${this.name()}`;if(this._actionHandler){s(),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))s(),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():(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(u=>i.conflictsWith.includes(u.attributeName()));s&&this._conflictingOption(i,s)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],i=[],s=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(d=>d.short).some(d=>/^-\d$/.test(d))):!1,o=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(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 d=e[c++];d===void 0&&this.optionMissingArgument(D),this.emit(`option:${D.name()}`,d)}else if(D.optional){let d=null;c<e.length&&(!u(e[c])||r(e[c]))&&(d=e[c++]),this.emit(`option:${D.name()}`,d)}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("="),d=this._findOption(l.slice(0,D));if(d&&(d.required||d.optional)){this.emit(`option:${d.name()}`,l.slice(D+1));continue}}if(s===t&&u(l)&&!(this.commands.length===0&&r(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||{},s=i.exitCode||1,
|
|
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=>
|
|
26
|
-
Expecting one of '${i.join("', '")}'`);let s=`${e}Help`;return this.on(s,
|
|
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,
|
|
29
|
-
`?(
|
|
30
|
-
`&&(s&&D&&(i+=
|
|
24
|
+
`),this.outputHelp({error:!0}));let i=t||{},s=i.exitCode||1,u=i.code||"commander.error";this._exit(s,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 Kr(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=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},s=r=>{let o=i(r),a=o.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${o.envVar}'`:`option '${o.flags}'`},u=`error: ${s(e)} cannot be used with ${s(t)}`;this.error(u,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let s=[],u=this;do{let r=u.createHelp().visibleOptions(u).filter(o=>o.long).map(o=>o.long);s=s.concat(r),u=u.parent}while(u&&!u._enablePositionalOptions);t=rn(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",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 s=[];this.createHelp().visibleCommands(this).forEach(u=>{s.push(u.name()),u.alias()&&s.push(u.alias())}),t=rn(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=>Jr(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=H.basename(e,H.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,u;return t?(i=o=>this._outputConfiguration.writeErr(o),s=this._outputConfiguration.getErrHasColors(),u=this._outputConfiguration.getErrHelpWidth()):(i=o=>this._outputConfiguration.writeOut(o),s=this._outputConfiguration.getOutHasColors(),u=this._outputConfiguration.getOutHelpWidth()),{error:t,write:o=>(s||(o=this._outputConfiguration.stripColor(o)),i(o)),hasColors:s,helpWidth:u}}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(r=>r.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);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",s),this._getCommandAndAncestors().forEach(r=>r.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(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 s=`${e}Help`;return this.on(s,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(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function sn(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",s="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])?s=u[3]:i=u[3]):(u=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=u[1],i=u[3],s=u[4]),t&&s!=="0"?`${t}=${i}:${parseInt(s)+1}`:e})}function ut(){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}ot.Command=st;ot.useColor=ut});var cn=R(I=>{var{Argument:on}=Ce(),{Command:at}=un(),{CommanderError:Yr,InvalidArgumentError:an}=ce(),{Help:Qr}=Ze(),{Option:ln}=nt();I.program=new at;I.createCommand=n=>new at(n);I.createOption=(n,e)=>new ln(n,e);I.createArgument=(n,e)=>new on(n,e);I.Command=at;I.Option=ln;I.Argument=on;I.Help=Qr;I.CommanderError=Yr;I.InvalidArgumentError=an;I.InvalidOptionArgumentError=an});var Dt=R((Qs,pn)=>{"use strict";var lt="\x1B",b=`${lt}[`,Zr="\x07",ct={to(n,e){return e?`${b}${e+1};${n+1}H`:`${b}${n+1}G`},move(n,e){let t="";return n<0?t+=`${b}${-n}D`:n>0&&(t+=`${b}${n}C`),e<0?t+=`${b}${-e}A`:e>0&&(t+=`${b}${e}B`),t},up:(n=1)=>`${b}${n}A`,down:(n=1)=>`${b}${n}B`,forward:(n=1)=>`${b}${n}C`,backward:(n=1)=>`${b}${n}D`,nextLine:(n=1)=>`${b}E`.repeat(n),prevLine:(n=1)=>`${b}F`.repeat(n),left:`${b}G`,hide:`${b}?25l`,show:`${b}?25h`,save:`${lt}7`,restore:`${lt}8`},Xr={up:(n=1)=>`${b}S`.repeat(n),down:(n=1)=>`${b}T`.repeat(n)},ei={screen:`${b}2J`,up:(n=1)=>`${b}1J`.repeat(n),down:(n=1)=>`${b}J`.repeat(n),line:`${b}2K`,lineEnd:`${b}K`,lineStart:`${b}1K`,lines(n){let e="";for(let t=0;t<n;t++)e+=this.line+(t<n-1?ct.up():"");return n&&(e+=ct.left),e}};pn.exports={cursor:ct,scroll:Xr,erase:ei,beep:Zr}});var be=R((Zs,ht)=>{var ye=process||{},dn=ye.argv||[],Ee=ye.env||{},ti=!(Ee.NO_COLOR||dn.includes("--no-color"))&&(!!Ee.FORCE_COLOR||dn.includes("--color")||ye.platform==="win32"||(ye.stdout||{}).isTTY&&Ee.TERM!=="dumb"||!!Ee.CI),ni=(n,e,t=n)=>i=>{let s=""+i,u=s.indexOf(e,n.length);return~u?n+ri(s,e,t,u)+e:n+s+e},ri=(n,e,t,i)=>{let s="",u=0;do s+=n.substring(u,i)+t,u=i+e.length,i=n.indexOf(e,u);while(~i);return s+n.substring(u)},mn=(n=ti)=>{let e=n?ni:()=>String;return{isColorSupported:n,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")}};ht.exports=mn();ht.exports.createColors=mn});var Jn=R((cu,Ln)=>{"use strict";var xt=Object.defineProperty,Gi=Object.getOwnPropertyDescriptor,Hi=Object.getOwnPropertyNames,Wi=Object.prototype.hasOwnProperty,qi=(n,e)=>{for(var t in e)xt(n,t,{get:e[t],enumerable:!0})},Li=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Hi(e))!Wi.call(n,s)&&s!==t&&xt(n,s,{get:()=>e[s],enumerable:!(i=Gi(e,s))||i.enumerable});return n},Ji=n=>Li(xt({},"__esModule",{value:!0}),n),qn={};qi(qn,{default:()=>Ki});Ln.exports=Ji(qn);var Ui=class{baseUrl;defaultHeaders;constructor(n,e={}){this.baseUrl=n,this.defaultHeaders=e}buildUrl(n){return`${this.baseUrl.replace(/\/$/,"")}/${n.replace(/^\//,"")}`}async request(n,e,t,i={}){let s=this.buildUrl(e),u=await fetch(s,{method:n,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(n,e){return this.request("GET",n,void 0,e)}post(n,e,t){return this.request("POST",n,e,t)}put(n,e,t){return this.request("PUT",n,e,t)}delete(n,e){return this.request("DELETE",n,void 0,e)}},zi=class{api;apiToken;constructor(n){this.apiToken=n?.apiToken,this.api=new Ui("https://api.derived.dev/api",{...this.apiToken?{Authorization:this.apiToken}:{}})}fetchBlock=async n=>this.api.get(`/public/v1/template-group/code/${n}`);getBlockInputFromUserQuery=(n,e)=>this.api.post("/public/v1/template-group/get-block-input-from-user-query",{blockInput:n,query:e});resolveMultipleTemplates=(n,e)=>this.api.post("/public/v1/template-group/resolve-multiple-templates-by-block-code",{blockCode:n,data:e});searchBlocksByName=(n,e)=>this.api.get(`/public/v1/template-group/semantic-search?q=${n}&limit=5&threshold=0.5&project_id=${e}`);fetchProjectBySlug=async n=>this.api.get(`/public/v1/project/detail-by-slug/${n}`);createMultipleTemplates=async n=>this.api.post("/v1/template/create-multiple",n);createTemplateGroup=async n=>this.api.post("/v1/template-group/create",n);getProjectCategories=async(n,e=20,t=1)=>{let i=encodeURIComponent(JSON.stringify({projectID:n})),s=encodeURIComponent(JSON.stringify({Desc:"id"}));return this.api.get(`/v1/block-category/list?filters=${i}&sort=${s}&limit=${e}&page=${t}`)};createCategory=async n=>this.api.post("/v1/block-category/create",n);updateTemplateGroup=async(n,e)=>this.api.put(`/v1/template-group/update/${n}`,e)},Ki=zi});var yr={};Yt(yr,{isDirectoryEmpty:()=>vs,removeGitDirectory:()=>$s});function vs(n){return(0,re.existsSync)(n)?(0,re.readdirSync)(n).filter(i=>!i.startsWith(".")).length===0:!0}function $s(n){let e=(0,Er.join)(n,".git");(0,re.existsSync)(e)&&(0,re.rmSync)(e,{recursive:!0,force:!0})}var re,Er,br=jr(()=>{"use strict";re=require("fs"),Er=require("path")});var Ss={};Yt(Ss,{displayFileTree:()=>Br});module.exports=Ir(Ss);var Dn=y(cn(),1),{program:Vs,createCommand:Gs,createArgument:Hs,createOption:Ws,CommanderError:qs,InvalidArgumentError:Ls,InvalidOptionArgumentError:Js,Command:hn,Argument:Us,Option:zs,Help:Ks}=Dn.default;var _e=require("node:util");var x=y(Dt(),1),ue=require("node:process"),U=y(require("node:readline"),1),mt=y(require("node:readline"),1),$n=require("node:stream"),wn=y(be(),1);function ii({onlyFirst:n=!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,n?void 0:"g")}var si=ii();function An(n){if(typeof n!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof n}\``);return n.replace(si,"")}function Bn(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var xn={exports:{}};(function(n){var e={};n.exports=e,e.eastAsianWidth=function(i){var s=i.charCodeAt(0),u=i.length==2?i.charCodeAt(1):0,r=s;return 55296<=s&&s<=56319&&56320<=u&&u<=57343&&(s&=1023,u&=1023,r=s<<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 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),u=0,r=0;r<s.length;r++)u=u+this.characterLength(s[r]);return u},e.slice=function(i,s,u){textLen=e.length(i),s=s||0,u=u||1,s<0&&(s=textLen+s),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>=s-(D==2?1:0))if(o+D<=u)r+=l;else break;o+=D}return r}})(xn);var ui=xn.exports,oi=Bn(ui),ai=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},li=Bn(ai);function De(n,e={}){if(typeof n!="string"||n.length===0||(e={ambiguousIsNarrow:!0,...e},n=An(n),n.length===0))return 0;n=n.replace(li()," ");let t=e.ambiguousIsNarrow?1:2,i=0;for(let s of n){let u=s.codePointAt(0);if(!(u<=31||u>=127&&u<=159||u>=768&&u<=879))switch(oi.eastAsianWidth(s)){case"F":case"W":i+=2;break;case"A":i+=t;break;default:i+=1}}return i}var pt=10,fn=(n=0)=>e=>`\x1B[${e+n}m`,gn=(n=0)=>e=>`\x1B[${38+n};5;${e}m`,Cn=(n=0)=>(e,t,i)=>`\x1B[${38+n};2;${e};${t};${i}m`,E={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(E.modifier);var ci=Object.keys(E.color),Di=Object.keys(E.bgColor);[...ci,...Di];function hi(){let n=new Map;for(let[e,t]of Object.entries(E)){for(let[i,s]of Object.entries(t))E[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},t[i]=E[i],n.set(s[0],s[1]);Object.defineProperty(E,e,{value:t,enumerable:!1})}return Object.defineProperty(E,"codes",{value:n,enumerable:!1}),E.color.close="\x1B[39m",E.bgColor.close="\x1B[49m",E.color.ansi=fn(),E.color.ansi256=gn(),E.color.ansi16m=Cn(),E.bgColor.ansi=fn(pt),E.bgColor.ansi256=gn(pt),E.bgColor.ansi16m=Cn(pt),Object.defineProperties(E,{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 s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:e=>E.rgbToAnsi256(...E.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 o=e%36;t=Math.floor(e/36)/5,i=Math.floor(o/6)/5,s=o%6/5}let u=Math.max(t,i,s)*2;if(u===0)return 30;let r=30+(Math.round(s)<<2|Math.round(i)<<1|Math.round(t));return u===2&&(r+=60),r},enumerable:!1},rgbToAnsi:{value:(e,t,i)=>E.ansi256ToAnsi(E.rgbToAnsi256(e,t,i)),enumerable:!1},hexToAnsi:{value:e=>E.ansi256ToAnsi(E.hexToAnsi256(e)),enumerable:!1}}),E}var pi=hi(),xe=new Set(["\x1B","\x9B"]),di=39,gt="\x07",_n="[",mi="]",On="m",Ct=`${mi}8;;`,Fn=n=>`${xe.values().next().value}${_n}${n}${On}`,En=n=>`${xe.values().next().value}${Ct}${n}${gt}`,fi=n=>n.split(" ").map(e=>De(e)),dt=(n,e,t)=>{let i=[...e],s=!1,u=!1,r=De(An(n[n.length-1]));for(let[o,a]of i.entries()){let c=De(a);if(r+c<=t?n[n.length-1]+=a:(n.push(a),r=0),xe.has(a)&&(s=!0,u=i.slice(o+1).join("").startsWith(Ct)),s){u?a===gt&&(s=!1,u=!1):a===On&&(s=!1);continue}r+=c,r===t&&o<i.length-1&&(n.push(""),r=0)}!r&&n[n.length-1].length>0&&n.length>1&&(n[n.length-2]+=n.pop())},gi=n=>{let e=n.split(" "),t=e.length;for(;t>0&&!(De(e[t-1])>0);)t--;return t===e.length?n:e.slice(0,t).join(" ")+e.slice(t).join("")},Ci=(n,e,t={})=>{if(t.trim!==!1&&n.trim()==="")return"";let i="",s,u,r=fi(n),o=[""];for(let[c,l]of n.split(" ").entries()){t.trim!==!1&&(o[o.length-1]=o[o.length-1].trimStart());let D=De(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 d=e-D,C=1+Math.floor((r[c]-d-1)/e);Math.floor((r[c]-1)/e)<C&&o.push(""),dt(o,l,e);continue}if(D+r[c]>e&&D>0&&r[c]>0){if(t.wordWrap===!1&&D<e){dt(o,l,e);continue}o.push("")}if(D+r[c]>e&&t.wordWrap===!1){dt(o,l,e);continue}o[o.length-1]+=l}t.trim!==!1&&(o=o.map(c=>gi(c)));let a=[...o.join(`
|
|
28
|
+
`)];for(let[c,l]of a.entries()){if(i+=l,xe.has(l)){let{groups:d}=new RegExp(`(?:\\${_n}(?<code>\\d+)m|\\${Ct}(?<uri>.*)${gt})`).exec(a.slice(c).join(""))||{groups:{}};if(d.code!==void 0){let C=Number.parseFloat(d.code);s=C===di?void 0:C}else d.uri!==void 0&&(u=d.uri.length===0?void 0:d.uri)}let D=pi.codes.get(Number(s));a[c+1]===`
|
|
29
|
+
`?(u&&(i+=En("")),s&&D&&(i+=Fn(D))):l===`
|
|
30
|
+
`&&(s&&D&&(i+=Fn(s)),u&&(i+=En(u)))}return i};function yn(n,e,t){return String(n).normalize().replace(/\r\n/g,`
|
|
31
31
|
`).split(`
|
|
32
|
-
`).map(i=>
|
|
33
|
-
`)}var
|
|
32
|
+
`).map(i=>Ci(i,e,t)).join(`
|
|
33
|
+
`)}var Fi=["up","down","left","right","space","enter","cancel"],$e={actions:new Set(Fi),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]])};function Ft(n,e){if(typeof n=="string")return $e.aliases.get(n)===e;for(let t of n)if(t!==void 0&&Ft(t,e))return!0;return!1}function Ei(n,e){if(n===e)return;let t=n.split(`
|
|
34
34
|
`),i=e.split(`
|
|
35
|
-
`),s=[];for(let
|
|
36
|
-
`),
|
|
37
|
-
`).length-1;this.output.write(
|
|
38
|
-
`);this.output.write(s[i]),this._prevFrame=e,this.output.write(
|
|
35
|
+
`),s=[];for(let u=0;u<Math.max(t.length,i.length);u++)t[u]!==i[u]&&s.push(u);return s}var yi=globalThis.process.platform.startsWith("win"),ft=Symbol("clack:cancel");function W(n){return n===ft}function ve(n,e){let t=n;t.isTTY&&t.setRawMode(e)}function Sn({input:n=ue.stdin,output:e=ue.stdout,overwrite:t=!0,hideCursor:i=!0}={}){let s=U.createInterface({input:n,output:e,prompt:"",tabSize:1});U.emitKeypressEvents(n,s),n.isTTY&&n.setRawMode(!0);let u=(r,{name:o,sequence:a})=>{let c=String(r);if(Ft([c,o,a],"cancel")){i&&e.write(x.cursor.show),process.exit(0);return}if(!t)return;U.moveCursor(e,o==="return"?0:-1,o==="return"?-1:0,()=>{U.clearLine(e,1,()=>{n.once("keypress",u)})})};return i&&e.write(x.cursor.hide),n.once("keypress",u),()=>{n.off("keypress",u),i&&e.write(x.cursor.show),n.isTTY&&!yi&&n.setRawMode(!1),s.terminal=!1,s.close()}}var bi=Object.defineProperty,vi=(n,e,t)=>e in n?bi(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,T=(n,e,t)=>(vi(n,typeof e!="symbol"?e+"":e,t),t),se=class{constructor(e,t=!0){T(this,"input"),T(this,"output"),T(this,"_abortSignal"),T(this,"rl"),T(this,"opts"),T(this,"_render"),T(this,"_track",!1),T(this,"_prevFrame",""),T(this,"_subscribers",new Map),T(this,"_cursor",0),T(this,"state","initial"),T(this,"error",""),T(this,"value");let{input:i=ue.stdin,output:s=ue.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=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 u of i)u.cb(...t),u.once&&s.push(()=>i.splice(i.indexOf(u),1));for(let u of s)u()}prompt(){return new Promise((e,t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(ft);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let i=new $n.Writable;i._write=(s,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=mt.default.createInterface({input:this.input,output:i,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),mt.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),ve(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(x.cursor.show),this.output.off("resize",this.render),ve(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(x.cursor.show),this.output.off("resize",this.render),ve(this.input,!1),e(ft)})})}onKeypress(e,t){if(this.state==="error"&&(this.state="active"),t?.name&&(!this._track&&$e.aliases.has(t.name)&&this.emit("cursor",$e.aliases.get(t.name)),$e.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")}Ft([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
|
+
`),ve(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=yn(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
37
|
+
`).length-1;this.output.write(x.cursor.move(-999,e*-1))}render(){let e=yn(this._render(this)??"",process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(x.cursor.hide);else{let t=Ei(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let i=t[0];this.output.write(x.cursor.move(0,i)),this.output.write(x.erase.lines(1));let s=e.split(`
|
|
38
|
+
`);this.output.write(s[i]),this._prevFrame=e,this.output.write(x.cursor.move(0,s.length-i-1));return}if(t&&t?.length>1){let i=t[0];this.output.write(x.cursor.move(0,i)),this.output.write(x.erase.down());let s=e.split(`
|
|
39
39
|
`).slice(i);this.output.write(s.join(`
|
|
40
|
-
`)),this._prevFrame=e;return}this.output.write(
|
|
41
|
-
${
|
|
42
|
-
`,t=
|
|
43
|
-
${
|
|
44
|
-
${
|
|
45
|
-
`;case"submit":return`${e}${
|
|
46
|
-
${
|
|
47
|
-
${
|
|
48
|
-
`}}}).prompt();var
|
|
49
|
-
${
|
|
50
|
-
`,s=this.value?e:t;switch(this.state){case"submit":return`${i}${
|
|
51
|
-
${
|
|
52
|
-
${
|
|
53
|
-
`}}}).prompt()},
|
|
54
|
-
${
|
|
55
|
-
`;switch(this.state){case"submit":return`${t}${
|
|
56
|
-
${
|
|
57
|
-
${
|
|
58
|
-
${
|
|
59
|
-
`}}}).prompt()};var
|
|
60
|
-
${
|
|
61
|
-
${
|
|
62
|
-
`,i=(s,
|
|
63
|
-
${
|
|
64
|
-
`).map((
|
|
65
|
-
`);return`${t+
|
|
66
|
-
${
|
|
40
|
+
`)),this._prevFrame=e;return}this.output.write(x.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}},we=class extends se{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(x.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var $i;$i=new WeakMap;var wi=Object.defineProperty,Ai=(n,e,t)=>e in n?wi(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,bn=(n,e,t)=>(Ai(n,typeof e!="symbol"?e+"":e,t),t),kn=class extends se{constructor(n){super(n,!1),bn(this,"options"),bn(this,"cursor",0),this.options=n.options,this.value=[...n.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===n.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 n=this.value.length===this.options.length;this.value=n?[]:this.options.map(e=>e.value)}toggleValue(){let n=this.value.includes(this._value);this.value=n?this.value.filter(e=>e!==this._value):[...this.value,this._value]}};var Bi=Object.defineProperty,xi=(n,e,t)=>e in n?Bi(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,vn=(n,e,t)=>(xi(n,typeof e!="symbol"?e+"":e,t),t),Ae=class extends se{constructor(e){super(e,!1),vn(this,"options"),vn(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 Be=class extends se{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}${wn.default.inverse(t)}${i.join("")}`}get cursor(){return this._cursor}constructor(e){super(e),this.on("finalize",()=>{this.value||(this.value=e.defaultValue)})}};var N=y(require("node:process"),1),h=y(be(),1),Oe=y(Dt(),1);function _i(){return N.default.platform!=="win32"?N.default.env.TERM!=="linux":!!N.default.env.CI||!!N.default.env.WT_SESSION||!!N.default.env.TERMINUS_SUBLIME||N.default.env.ConEmuTask==="{cmd::Cmder}"||N.default.env.TERM_PROGRAM==="Terminus-Sublime"||N.default.env.TERM_PROGRAM==="vscode"||N.default.env.TERM==="xterm-256color"||N.default.env.TERM==="alacritty"||N.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Et=_i(),v=(n,e)=>Et?n:e,Oi=v("\u25C6","*"),jn=v("\u25A0","x"),In=v("\u25B2","x"),Se=v("\u25C7","o"),Si=v("\u250C","T"),m=v("\u2502","|"),z=v("\u2514","\u2014"),yt=v("\u25CF",">"),bt=v("\u25CB"," "),ki=v("\u25FB","[\u2022]"),Tn=v("\u25FC","[+]"),Ti=v("\u25FB","[ ]"),uu=v("\u25AA","\u2022"),Pn=v("\u2500","-"),Pi=v("\u256E","+"),ji=v("\u251C","+"),Ii=v("\u256F","+"),Ni=v("\u25CF","\u2022"),Mi=v("\u25C6","*"),Ri=v("\u25B2","!"),Vi=v("\u25A0","x"),ke=n=>{switch(n){case"initial":case"active":return h.default.cyan(Oi);case"cancel":return h.default.red(jn);case"error":return h.default.yellow(In);case"submit":return h.default.green(Se)}},vt=n=>{let{cursor:e,options:t,style:i}=n,s=n.maxItems??Number.POSITIVE_INFINITY,u=Math.max(process.stdout.rows-4,0),r=Math.min(u,Math.max(s,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,d)=>{let C=D===0&&a,$=D===d.length-1&&c;return C||$?h.default.dim("..."):i(l,D+o===e)})},$t=n=>new Be({validate:n.validate,placeholder:n.placeholder,defaultValue:n.defaultValue,initialValue:n.initialValue,render(){let e=`${h.default.gray(m)}
|
|
41
|
+
${ke(this.state)} ${n.message}
|
|
42
|
+
`,t=n.placeholder?h.default.inverse(n.placeholder[0])+h.default.dim(n.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(z)} ${h.default.yellow(this.error)}
|
|
45
|
+
`;case"submit":return`${e}${h.default.gray(m)} ${h.default.dim(this.value||n.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(z)}
|
|
48
|
+
`}}}).prompt();var Nn=n=>{let e=n.active??"Yes",t=n.inactive??"No";return new we({active:e,inactive:t,initialValue:n.initialValue??!0,render(){let i=`${h.default.gray(m)}
|
|
49
|
+
${ke(this.state)} ${n.message}
|
|
50
|
+
`,s=this.value?e:t;switch(this.state){case"submit":return`${i}${h.default.gray(m)} ${h.default.dim(s)}`;case"cancel":return`${i}${h.default.gray(m)} ${h.default.strikethrough(h.default.dim(s))}
|
|
51
|
+
${h.default.gray(m)}`;default:return`${i}${h.default.cyan(m)} ${this.value?`${h.default.green(yt)} ${e}`:`${h.default.dim(bt)} ${h.default.dim(e)}`} ${h.default.dim("/")} ${this.value?`${h.default.dim(bt)} ${h.default.dim(t)}`:`${h.default.green(yt)} ${t}`}
|
|
52
|
+
${h.default.cyan(z)}
|
|
53
|
+
`}}}).prompt()},Te=n=>{let e=(t,i)=>{let s=t.label??String(t.value);switch(i){case"selected":return`${h.default.dim(s)}`;case"active":return`${h.default.green(yt)} ${s} ${t.hint?h.default.dim(`(${t.hint})`):""}`;case"cancelled":return`${h.default.strikethrough(h.default.dim(s))}`;default:return`${h.default.dim(bt)} ${h.default.dim(s)}`}};return new Ae({options:n.options,initialValue:n.initialValue,render(){let t=`${h.default.gray(m)}
|
|
54
|
+
${ke(this.state)} ${n.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)} ${vt({cursor:this.cursor,options:this.options,maxItems:n.maxItems,style:(i,s)=>e(i,s?"active":"inactive")}).join(`
|
|
57
|
+
${h.default.cyan(m)} `)}
|
|
58
|
+
${h.default.cyan(z)}
|
|
59
|
+
`}}}).prompt()};var Mn=n=>{let e=(t,i)=>{let s=t.label??String(t.value);return i==="active"?`${h.default.cyan(ki)} ${s} ${t.hint?h.default.dim(`(${t.hint})`):""}`:i==="selected"?`${h.default.green(Tn)} ${h.default.dim(s)} ${t.hint?h.default.dim(`(${t.hint})`):""}`:i==="cancelled"?`${h.default.strikethrough(h.default.dim(s))}`:i==="active-selected"?`${h.default.green(Tn)} ${s} ${t.hint?h.default.dim(`(${t.hint})`):""}`:i==="submitted"?`${h.default.dim(s)}`:`${h.default.dim(Ti)} ${h.default.dim(s)}`};return new kn({options:n.options,initialValues:n.initialValues,required:n.required??!0,cursorAt:n.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
|
+
${ke(this.state)} ${n.message}
|
|
62
|
+
`,i=(s,u)=>{let r=this.value.includes(s.value);return u&&r?e(s,"active-selected"):r?e(s,"selected"):e(s,u?"active":"inactive")};switch(this.state){case"submit":return`${t}${h.default.gray(m)} ${this.options.filter(({value:s})=>this.value.includes(s)).map(s=>e(s,"submitted")).join(h.default.dim(", "))||h.default.dim("none")}`;case"cancel":{let s=this.options.filter(({value:u})=>this.value.includes(u)).map(u=>e(u,"cancelled")).join(h.default.dim(", "));return`${t}${h.default.gray(m)} ${s.trim()?`${s}
|
|
63
|
+
${h.default.gray(m)}`:""}`}case"error":{let s=this.error.split(`
|
|
64
|
+
`).map((u,r)=>r===0?`${h.default.yellow(z)} ${h.default.yellow(u)}`:` ${u}`).join(`
|
|
65
|
+
`);return`${t+h.default.yellow(m)} ${vt({options:this.options,cursor:this.cursor,maxItems:n.maxItems,style:i}).join(`
|
|
66
|
+
${h.default.yellow(m)} `)}
|
|
67
67
|
${s}
|
|
68
|
-
`}default:return`${t}${
|
|
69
|
-
${
|
|
70
|
-
${
|
|
71
|
-
`}}}).prompt()};var
|
|
72
|
-
${
|
|
68
|
+
`}default:return`${t}${h.default.cyan(m)} ${vt({options:this.options,cursor:this.cursor,maxItems:n.maxItems,style:i}).join(`
|
|
69
|
+
${h.default.cyan(m)} `)}
|
|
70
|
+
${h.default.cyan(z)}
|
|
71
|
+
`}}}).prompt()};var wt=(n="",e="")=>{let t=`
|
|
72
|
+
${n}
|
|
73
73
|
`.split(`
|
|
74
|
-
`),i=(0,
|
|
75
|
-
`);process.stdout.write(`${
|
|
76
|
-
${
|
|
77
|
-
${
|
|
78
|
-
${
|
|
79
|
-
`)},
|
|
80
|
-
|
|
81
|
-
`)},
|
|
82
|
-
`)},
|
|
83
|
-
${
|
|
84
|
-
|
|
85
|
-
`)},
|
|
86
|
-
`);t.push(`${e} ${i}`,...s.map(
|
|
74
|
+
`),i=(0,_e.stripVTControlCharacters)(e).length,s=Math.max(t.reduce((r,o)=>{let a=(0,_e.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(s-(0,_e.stripVTControlCharacters)(r).length)}${h.default.gray(m)}`).join(`
|
|
75
|
+
`);process.stdout.write(`${h.default.gray(m)}
|
|
76
|
+
${h.default.green(Se)} ${h.default.reset(e)} ${h.default.gray(Pn.repeat(Math.max(s-i-1,1))+Pi)}
|
|
77
|
+
${u}
|
|
78
|
+
${h.default.gray(ji+Pn.repeat(s+2)+Ii)}
|
|
79
|
+
`)},At=(n="")=>{process.stdout.write(`${h.default.gray(z)} ${h.default.red(n)}
|
|
80
|
+
|
|
81
|
+
`)},Rn=(n="")=>{process.stdout.write(`${h.default.gray(Si)} ${n}
|
|
82
|
+
`)},Vn=(n="")=>{process.stdout.write(`${h.default.gray(m)}
|
|
83
|
+
${h.default.gray(z)} ${n}
|
|
84
|
+
|
|
85
|
+
`)},V={message:(n="",{symbol:e=h.default.gray(m)}={})=>{let t=[`${h.default.gray(m)}`];if(n){let[i,...s]=n.split(`
|
|
86
|
+
`);t.push(`${e} ${i}`,...s.map(u=>`${h.default.gray(m)} ${u}`))}process.stdout.write(`${t.join(`
|
|
87
87
|
`)}
|
|
88
|
-
`)},info:
|
|
89
|
-
`);let
|
|
90
|
-
`);process.stdout.write(
|
|
91
|
-
`);let
|
|
92
|
-
`):process.stdout.write(`${
|
|
93
|
-
`)
|
|
94
|
-
`);let s=t?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",
|
|
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
|
|
97
|
-
`)}function
|
|
98
|
-
Example: derived-cli add ${
|
|
99
|
-
Schema: ${JSON.stringify(a)}`);let l=await
|
|
100
|
-
`);
|
|
101
|
-
|
|
102
|
-
${a}`,"Processing Queue")}let
|
|
88
|
+
`)},info:n=>{V.message(n,{symbol:h.default.blue(Ni)})},success:n=>{V.message(n,{symbol:h.default.green(Mi)})},step:n=>{V.message(n,{symbol:h.default.green(Se)})},warn:n=>{V.message(n,{symbol:h.default.yellow(Ri)})},warning:n=>{V.warn(n)},error:n=>{V.message(n,{symbol:h.default.red(Vi)})}},ou=`${h.default.gray(m)} `;var Gn=({indicator:n="dots"}={})=>{let e=Et?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],t=Et?80:120,i=process.env.CI==="true",s,u,r=!1,o="",a,c=performance.now(),l=O=>{let j=O>1?"Something went wrong":"Canceled";r&&Kt(j,O)},D=()=>l(2),d=()=>l(1),C=()=>{process.on("uncaughtExceptionMonitor",D),process.on("unhandledRejection",D),process.on("SIGINT",d),process.on("SIGTERM",d),process.on("exit",l)},$=()=>{process.removeListener("uncaughtExceptionMonitor",D),process.removeListener("unhandledRejection",D),process.removeListener("SIGINT",d),process.removeListener("SIGTERM",d),process.removeListener("exit",l)},g=()=>{if(a===void 0)return;i&&process.stdout.write(`
|
|
89
|
+
`);let O=a.split(`
|
|
90
|
+
`);process.stdout.write(Oe.cursor.move(-999,O.length-1)),process.stdout.write(Oe.erase.down(O.length))},B=O=>O.replace(/\.+$/,""),F=O=>{let j=(performance.now()-O)/1e3,M=Math.floor(j/60),ie=Math.floor(j%60);return M>0?`[${M}m ${ie}s]`:`[${ie}s]`},Z=(O="")=>{r=!0,s=Sn(),o=B(O),c=performance.now(),process.stdout.write(`${h.default.gray(m)}
|
|
91
|
+
`);let j=0,M=0;C(),u=setInterval(()=>{if(i&&o===a)return;g(),a=o;let ie=h.default.magenta(e[j]);if(i)process.stdout.write(`${ie} ${o}...`);else if(n==="timer")process.stdout.write(`${ie} ${o} ${F(c)}`);else{let _r=".".repeat(Math.floor(M)).slice(0,3);process.stdout.write(`${ie} ${o}${_r}`)}j=j+1<e.length?j+1:0,M=M<e.length?M+.125:0},t)},Kt=(O="",j=0)=>{r=!1,clearInterval(u),g();let M=j===0?h.default.green(Se):j===1?h.default.red(jn):h.default.red(In);o=B(O??o),n==="timer"?process.stdout.write(`${M} ${o} ${F(c)}
|
|
92
|
+
`):process.stdout.write(`${M} ${o}
|
|
93
|
+
`),$(),s()};return{start:Z,stop:Kt,message:(O="")=>{o=B(O??o)}}};var $r=require("node:child_process"),k=require("node:fs"),wr=require("node:os"),qe=require("node:path");var oe=y(require("fs")),Bt=y(require("path")),Wn=(n,e=[],t=!1)=>{let i=[],s=[],u=[];for(let r of n){let o=Bt.default.join(process.cwd(),r.resolvedPath);if(!r.isNotEnabled)try{if(oe.default.mkdirSync(Bt.default.dirname(o),{recursive:!0}),r.templateType==="add"){let a=oe.default.existsSync(o)&&oe.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}oe.default.writeFileSync(o,r.resolvedTemplate),i.push(o)}}else r.templateType==="modify"&&(r.modifiedFileContent?(oe.default.writeFileSync(o,r.modifiedFileContent),s.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:s,errors:u}};var Le=y(Jn());var _t=y(be());function Un(n){let e={name:"root",type:"directory",children:[],path:""},t=n.map(i=>i.replace(/^\//,"").replace(/\\/g,"/")).sort();for(let i of t){let s=i.split("/").filter(Boolean),u=e;s.forEach((r,o)=>{let a=o===s.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:s.slice(0,o+1).join("/")};u.children||(u.children=[]),u.children.push(l),u=l}})}return e}function Pe(n,e="",t=!0,i=!0){if(i&&n.children)return n.children.map((a,c)=>Pe(a,"",c===n.children.length-1,!1)).join(`
|
|
94
|
+
`);let s=t?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",u=n.type==="directory"?"\u{1F4C1} ":"\u{1F4C4} ",r=n.type==="directory"?_t.default.cyan(n.name+"/"):_t.default.green(n.name),o=e+s+u+r+`
|
|
95
|
+
`;if(n.children&&n.children.length>0){let a=e+(t?" ":"\u2502 ");n.children.forEach((c,l)=>{o+=Pe(c,a,l===n.children.length-1,!1)})}return o}var q=require("fs"),Ot=require("path"),Yi=".derived",Qi="blocks.json";function zn(){return(0,Ot.join)(process.cwd(),Yi)}function Kn(){return(0,Ot.join)(zn(),Qi)}function St(n,e){if(n===e)return!0;if(n==null||e==null)return n===e;if(typeof n!=typeof e)return!1;if(typeof n!="object")return n===e;let t=Object.keys(n),i=Object.keys(e);if(t.length!==i.length)return!1;for(let s of t)if(!i.includes(s)||!St(n[s],e[s]))return!1;return!0}function X(){let n=Kn();if(!(0,q.existsSync)(n))return{addedBlocks:[]};try{let e=(0,q.readFileSync)(n,"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 Zi(n){let e=zn(),t=Kn();(0,q.existsSync)(e)||(0,q.mkdirSync)(e,{recursive:!0}),(0,q.writeFileSync)(t,JSON.stringify(n,null,2))}function Yn(n){return X().addedBlocks.some(t=>t.code===n)}function kt(n,e){return X().addedBlocks.find(s=>s.code===n&&St(s.input,e))||null}function Qn(n,e){return X().addedBlocks.filter(i=>i.code===n&&!St(i.input,e))}function Tt(n,e={}){let t=X();kt(n,e)||(t.addedBlocks.push({code:n,input:e}),Zi(t))}var L=require("node:fs"),Pt=require("node:path"),Xi=".derived",es="staging.json";function Zn(){return(0,Pt.join)(process.cwd(),Xi)}function Xn(){return(0,Pt.join)(Zn(),es)}function je(){let n=Xn();if(!(0,L.existsSync)(n))return{stagedFiles:[]};try{let e=(0,L.readFileSync)(n,"utf-8"),t=JSON.parse(e);return t&&Array.isArray(t.stagedFiles)?t:{stagedFiles:[]}}catch{return{stagedFiles:[]}}}function jt(n){let e=Zn(),t=Xn();(0,L.existsSync)(e)||(0,L.mkdirSync)(e,{recursive:!0}),(0,L.writeFileSync)(t,JSON.stringify(n,null,2))}function It(n){return je().stagedFiles.some(t=>t.path===n)}function er(n){let e=je();It(n)||(e.stagedFiles.push({path:n,addedAt:new Date().toISOString()}),jt(e))}function tr(n){let e=je();e.stagedFiles=e.stagedFiles.filter(t=>t.path!==n),jt(e)}function Nt(){jt({stagedFiles:[]})}function he(){return je().stagedFiles}var K=class extends Error{code;constructor(e,t){super(t),this.name="CliError",this.code=e}};var te=require("child_process");function rr(n){return e=>e.length>1?[n,"run",e[0],"--",...e.slice(1)]:[n,"run",e[0]]}function ts(){return n=>["deno","run",`npm:${n[0]}`,...n.slice(1)]}var ns={agent:["npm",0],run:rr("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]},ir={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]},rs={...ir,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]},nr={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]},is={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]},ss={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:ts(),"execute-local":["deno","task","--eval",0],uninstall:["deno","remove",0],global_uninstall:["deno","uninstall","-g",0]},sr={npm:ns,yarn:ir,"yarn@berry":rs,pnpm:nr,"pnpm@6":{...nr,run:rr("pnpm")},bun:is,deno:ss};function Mt(n,e,t){let i=sr[n][e];return ur(i,t)}function ur(n,e){if(n==null)return null;let t=typeof n=="function"?n(e):n.flatMap(i=>typeof i=="number"?e:[i]);return{command:t[0],args:t.slice(1)}}var or=["npm","yarn","yarn@berry","pnpm","pnpm@6","bun","deno"],Rt={"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 Me=y(require("node:fs"),1),ee=y(require("node:path"),1),pr=y(require("node:process"),1);var ar=Symbol.for("quansync.getIsAsync"),Ie=class extends Error{constructor(e="Unexpected promise in sync context"){super(e),this.name="QuansyncError"}};function Gt(n){return n&&typeof n=="object"&&typeof n.then=="function"}function us(n){return n&&typeof n=="object"&&typeof n[Symbol.iterator]=="function"&&"__quansync"in n}function Ht(n){let e=function*(...i){return(yield ar)?yield n.async.apply(this,i):n.sync.apply(this,i)};function t(...i){let s=e.apply(this,i);return s.then=(...u)=>n.async.apply(this,i).then(...u),s.__quansync=!0,s}return t.sync=n.sync,t.async=n.async,t}function os(n){return Ht({async:()=>Promise.resolve(n),sync:()=>{if(Gt(n))throw new Ie;return n}})}function Vt(n,e){if(n===ar)return e;if(us(n))return e?Dr(n):cr(n);if(!e&&Gt(n))throw new Ie;return n}var lr=n=>n;function cr(n,e=lr){let t=n.next();for(;!t.done;)try{t=n.next(Vt(e(t.value,!1)))}catch(i){t=n.throw(i)}return Vt(t.value)}async function Dr(n,e=lr){let t=n.next();for(;!t.done;)try{t=n.next(await Vt(e(t.value,!0),!0))}catch(i){t=n.throw(i)}return t.value}function as(n,e){return Ht({name:n.name,async(...t){return Dr(n.apply(this,t),e?.onYield)},sync(...t){return cr(n.apply(this,t),e?.onYield)}})}function Wt(n,e){return Gt(n)?os(n):typeof n=="function"?as(n,e):Ht(n)}var Fu=Wt({async:()=>Promise.resolve(!0),sync:()=>!1});var Ne=Wt;var dr=Ne({sync:n=>{try{return Me.default.statSync(n).isFile()}catch{return!1}},async:async n=>{try{return(await Me.default.promises.stat(n)).isFile()}catch{return!1}}});function*ls(n=pr.default.cwd()){let e=ee.default.resolve(n),{root:t}=ee.default.parse(e);for(;e&&e!==t;)yield e,e=ee.default.dirname(e)}var hr=Ne(function*(n,e){return!n||!(yield dr(n))?null:Ds(n,e)}),Re=Ne(function*(n={}){let{cwd:e,onUnknown:t}=n;for(let i of ls(e)){for(let u of Object.keys(Rt))if(yield dr(ee.default.join(i,u))){let r=Rt[u],o=yield hr(ee.default.join(i,"package.json"),t);return o||{name:r,agent:r}}let s=yield hr(ee.default.join(i,"package.json"),t);if(s)return s}return null}),cs=Re.sync;function Ds(n,e){try{let t=JSON.parse(Me.default.readFileSync(n,"utf8")),i;if(typeof t.packageManager=="string"){let[s,u]=t.packageManager.replace(/^\^/,"").split("@"),r=u;return s==="yarn"&&Number.parseInt(u)>1?(i="yarn@berry",r="berry",{name:s,agent:i,version:r}):s==="pnpm"&&Number.parseInt(u)<7?(i="pnpm@6",{name:s,agent:i,version:r}):or.includes(s)?(i=s,{name:s,agent:i,version:r}):e?.(t.packageManager)??null}}catch{}return null}function qt(n){try{return process.platform==="win32"?(0,te.execSync)(`where ${n}`,{stdio:"ignore"}):(0,te.execSync)(`command -v ${n}`,{stdio:"ignore"}),!0}catch{return!1}}function hs(n,e){if(n==="npx"||n==="pnpx"||n==="bunx")return{intent:"execute",args:e};if(n==="yarn"&&e[0]==="dlx")return{intent:"execute",args:e.slice(1)};if(["npm","pnpm","yarn","bun"].includes(n)){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 Ve(n,e={}){let t=n.trim().split(/\s+/),i=t[0]||"",s=t.slice(1),u=hs(i,s);if(u){let o=(await Re({cwd:process.cwd()}))?.agent||"npm",a=Mt(o,u.intent,u.args);if(a){let c=`${a.command} ${a.args.join(" ")}`;if(u.intent==="execute"){if(qt("bunx")){let l=`bunx ${u.args.join(" ")}`;return(0,te.execSync)(l,{stdio:"inherit",cwd:process.cwd(),...e})}if(qt("npx")){let l=`npx ${u.args.join(" ")}`;return(0,te.execSync)(l,{stdio:"inherit",cwd:process.cwd(),...e})}}if(qt(a.command))return(0,te.execSync)(c,{stdio:"inherit",cwd:process.cwd(),...e});throw new Error(`Command not found: ${a.command}. Please install the required package manager.`)}}return(0,te.execSync)(n,{stdio:"inherit",cwd:process.cwd(),...e})}var ne=y(require("crypto")),S=y(require("fs")),pe=y(require("path")),Lt=y(require("os")),fr="ts-cli-derived",ps="jwt-token",Ge=()=>{let n=Lt.homedir();return pe.join(n,`.${fr}`,`${ps}.enc`)},ds=()=>{let n=Ge(),e=pe.dirname(n);S.existsSync(e)||S.mkdirSync(e,{recursive:!0})},mr=()=>{let n=pe.join(Lt.homedir(),`.${fr}`,"key");if(!S.existsSync(n)){let e=ne.randomBytes(32);return S.writeFileSync(n,e),e}return S.readFileSync(n)},ae=class{static async saveToken(e){ds();let t=mr(),i=ne.randomBytes(16),s=ne.createCipheriv("aes-256-gcm",t,i),u=Buffer.concat([s.update(e,"utf8"),s.final()]),r=s.getAuthTag(),o={iv:i.toString("hex"),encrypted:u.toString("hex"),authTag:r.toString("hex")};S.writeFileSync(Ge(),JSON.stringify(o))}static async getToken(){try{let e=Ge();if(!S.existsSync(e))return null;let t=JSON.parse(S.readFileSync(e,"utf8")),i=mr(),s=Buffer.from(t.iv,"hex"),u=Buffer.from(t.encrypted,"hex"),r=Buffer.from(t.authTag,"hex"),o=ne.createDecipheriv("aes-256-gcm",i,s);return o.setAuthTag(r),o.update(u)+o.final("utf8")}catch{return null}}static async deleteToken(){try{let e=Ge();return S.existsSync(e)?(S.unlinkSync(e),!0):!1}catch{return!1}}};var G=require("fs"),Y=require("path"),ms=new Set([".git","node_modules"]);function fs(n){if((0,G.existsSync)(n))return(0,Y.resolve)(n);if(n.startsWith("/")){let e=(0,Y.resolve)(process.cwd(),n.replace(/^\/+/,""));if((0,G.existsSync)(e))return e}return(0,Y.resolve)(process.cwd(),n)}function gr(n){let e=(0,G.readdirSync)(n,{withFileTypes:!0}),t=[];for(let i of e){let s=(0,Y.join)(n,i.name);if(i.isDirectory()){if(ms.has(i.name))continue;t.push(...gr(s));continue}i.isFile()&&t.push(s)}return t}function gs(n){let e=(0,Y.relative)(process.cwd(),n);return!e||e.startsWith("..")?null:`/${e.replace(/\\/g,"/")}`}function Jt(n){let e=[],t=new Set;for(let r of n){let o=fs(r);if(!(0,G.existsSync)(o)){e.push(`Path does not exist: ${r}`);continue}try{let a=(0,G.lstatSync)(o);if(a.isFile()){t.add(o);continue}if(a.isDirectory()){try{let c=gr(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=[],s=new Set,u=Array.from(t).sort((r,o)=>r.localeCompare(o));for(let r of u){let o=gs(r);if(!o){e.push(`Path is outside the current project: ${r}`);continue}if(!s.has(o)){s.add(o);try{let a=(0,G.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}}function Cs(){return!process.stdin.isTTY||process.env.CI==="true"||process.env.TERM==="dumb"||process.env.NON_INTERACTIVE==="true"}var w=Cs(),P=!1;function Cr(n){P=n}function J(){return P||w}function de(n,e){(P||w)&&console.error(`[${n}] ${e}`)}function _(){return w||P?{start:n=>console.error(`[start] ${n}`),stop:n=>console.error(`[done] ${n}`)}:Gn()}var p={intro(n){w||P?de("intro",n):Rn(n)},outro(n){w||P?de("outro",n):Vn(n)},note(n,e){w||P?(e&&console.error(`[note:${e}]`),console.error(n)):wt(n,e)},data(n,e){w||P?(e&&console.error(`[data:${e}]`),console.error(JSON.stringify(n))):wt(JSON.stringify(n,null,2),e??"Data")},success(n){w||P?de("ok",n):V.success(n)},info(n){w||P?de("info",n):V.info(n)},warn(n){w||P?de("warn",n):V.warning(n)},fatal(n){throw w||P?console.error(`[error] ${n}`):At(n),new K("FATAL",n)},cancel(n){throw w||P?console.log(`[cancel] ${n}`):At(n),new K("CANCELLED",n)}};function Fs(n,e){let t=ys(n,e);process.stdout.write(JSON.stringify(t)+`
|
|
96
|
+
`)}function Es(n,e,t,i){let s=bs(n,e,t,i);process.stdout.write(JSON.stringify(s)+`
|
|
97
|
+
`)}function ys(n,e){return{type:"success",command:n,...e!==void 0?{data:e}:{}}}function bs(n,e,t,i){return{type:"error",command:n,code:e,message:t,...i!==void 0?{detail:i}:{}}}function Ut(n,e){Fs(n,e),process.exit(0)}function le(n,e,t,i){Es(n,e,t,i),process.exit(1)}var He=require("node:fs"),Fr=require("node:path");function me(){let n=(0,Fr.join)(process.cwd(),".derived","project.json");if(!(0,He.existsSync)(n))return null;try{let e=(0,He.readFileSync)(n,"utf-8");return JSON.parse(e)}catch{return null}}var A=new hn,Q=new Le.default;A.option("--json","Output structured JSON (agent-friendly)");A.hook("preAction",()=>{(A.opts().json||w)&&Cr(!0)});async function ws(n){let e=(0,qe.join)((0,wr.tmpdir)(),`cli-edit-${Date.now()}.json`);(0,k.writeFileSync)(e,JSON.stringify(n,null,2));let t=process.env.VISUAL||process.env.EDITOR||"nano";return new Promise((i,s)=>{(0,$r.spawn)(t,[e],{stdio:"inherit"}).on("exit",r=>{if(r===0)try{let o=(0,k.readFileSync)(e,"utf-8"),a=JSON.parse(o);(0,k.unlinkSync)(e),i(a)}catch{(0,k.unlinkSync)(e),s(new Error("Invalid JSON format"))}else(0,k.unlinkSync)(e),s(new Error("Editor closed without saving"))})})}async function vr(n,e){let t=_();t.start("Modifying block input...");let i=await Q.getBlockInputFromUserQuery(JSON.stringify(n),e);return t.stop("Block input modified"),p.data(i.result,"Refined Block Input"),i.result}function As(n,e="Block Input"){p.data(n,e)}function Ar(n,e){return Q.resolveMultipleTemplates(n,e)}async function Br(n,e){let t=await Ar(n,e),i=t.result.files.map(r=>r.resolvedPath),s=Un(i),u=Pe(s);p.note(u,`Files to be created (${t.result.files.length}):`)}async function We(n,e,t=!1,i){let s=_();s.start("Resolving Files...");let u=await Ar(n,e),r=u.result.files.filter(l=>{let D=(0,qe.join)(process.cwd(),l.resolvedPath);return(0,k.existsSync)(D)&&(0,k.lstatSync)(D).isFile()&&l.templateType==="add"}),o=[],a=t;if(r.length>0&&!t){s.stop(`${r.length} conflicting files detected`),w&&p.fatal(`${r.length} file(s) already exist. Re-run with --overwrite to overwrite all.
|
|
98
|
+
Example: derived-cli add ${n} --overwrite`);let l=await Te({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(W(l)&&p.cancel("Operation cancelled."),l==="overwrite-all")a=!0;else if(l==="select"){let D=await Mn({message:"Select files to overwrite",options:r.map(d=>({value:d.resolvedPath,label:d.resolvedPath}))});W(D)&&p.cancel("Operation cancelled."),o=D}s.start("Generating files...")}let c=Wn(u.result.files,o,a);if(c.errors?.length&&p.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(Tt(n,e),i?.setupCommands&&i.setupCommands.trim()){let l=i.setupCommands.split(",").map(d=>d.trim()),D=_();for(let d of l)if(d){D.start(`Running setup command: ${d}`);try{await Ve(d,{stdio:"inherit",cwd:process.cwd()}),D.stop(`Completed: ${d}`)}catch(C){D.stop(`Warning: Setup command failed: ${d}`),p.warn(C.message)}}}if(i?.aiInstruction&&i.aiInstruction.trim())return i.aiInstruction}return null}async function Bs(n){let e=[],t=new Set;async function i(s){if(t.has(s))return;t.add(s);let u=await Q.fetchBlock(s);if(u?.result?.id){if(u.result.dependsOn?.length)for(let r of u.result.dependsOn)await i(r.code);s!==n&&e.push(s)}}return await i(n),e}async function xs(n,e,t,i=!1,s=!0){s&&p.intro(`Add block: ${n}`);let u=!1,r=_();r.start("Fetching block...");let o=await Q.fetchBlock(n);if(o?.result?.id)r.stop(`Block found: ${o.result.name}${o.result.input?" (input required)":""}`);else return r.stop("Block not found"),null;let a=t||o.result.input;if(t){let c=await We(n,t,i,o.result);return u=!0,c}if(!a&&!u){let c=await We(n,{},i,o.result);return u=!0,c}if(a&&e&&!t){a=await vr(a,e);let c=await We(n,a,i,o.result);return u=!0,c}for(;!u&&a&&!e;){As(a),w&&p.fatal(`Block requires input. Re-run with --block-input <base64-json>.
|
|
99
|
+
Schema: ${JSON.stringify(a)}`);let l=await Te({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(W(l)&&p.cancel("Operation cancelled."),l==="refine"){let D=await $t({message:"Describe what to refine:"});a=await vr(a,D)}if(l==="edit"&&(a=await ws(a)),l==="done"){let D=await We(n,a,i,o.result);return u=!0,D}l==="showFiles"&&await Br(n,a)}return null}async function xr(n,e,t,i=!1){let r=[...await Bs(n),n].filter(a=>a===n?!0:!Yn(a));if(r.length===0){p.note(`Block "${n}" and all its dependencies are already added.`,"Nothing to do");return}if(r.length>1){let a=r.map((c,l)=>{let D=c===n;return` ${l+1}. ${c}${D?" (main)":" (dependency)"}`}).join(`
|
|
100
|
+
`);p.note(`${r.length} blocks will be processed:
|
|
101
|
+
|
|
102
|
+
${a}`,"Processing Queue")}let o=[];for(let a=0;a<r.length;a++){let c=r[a];if(!c)continue;let l=c===n,D=a===r.length-1;r.length>1&&p.intro(`[${a+1}/${r.length}] Processing: ${c}${l?" (main)":""}`);let d=await xs(c,l?e:void 0,l?t:null,i,r.length===1);d&&o.push({blockCode:c,instruction:d,isMain:l}),D||p.outro(`\u2713 ${c} completed`)}if(r.length>1&&p.outro(`All ${r.length} blocks processed`),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}]
|
|
103
103
|
${c.instruction}`}).join(`
|
|
104
104
|
|
|
105
|
-
`),
|
|
105
|
+
`),p.note(a,"Next Steps")}}async function _s(n,e={}){p.intro(`Searching: "${n}"`);let t=await me();t||p.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 u=await Q.searchBlocksByName(n,i);if(s.stop("Search complete"),!u.result||u.result.length===0){p.outro("No blocks found.");return}let r;if(e.autoSelect||w){let c=u.result[0];if(!c){p.fatal("No blocks found in search results.");return}r=c.code,u.result.length>1?p.info(`Auto-selected: ${c.name} (${c.code}) \u2014 ${u.result.length-1} other match(es) skipped`):p.success(`Found: ${c.name} (${c.code})`)}else{let c=await Te({message:`Found ${u.result.length} block(s). Select a block to add:`,options:u.result.map(D=>({value:D.code,label:D.name,hint:`Code: ${D.code} | Input: ${D.input?"Required":"Not required"}`}))});W(c)&&p.cancel("Operation cancelled."),r=c;let l=u.result.find(D=>D.code===r);l&&p.success(`Selected: ${l.name} (${l.code})`)}let o=u.result.find(c=>c.code===r);if(!o){p.fatal("Selected block not found.");return}let a=null;if(o.input&&Object.keys(o.input).length>0){let c=_();c.start("Resolving block input from query...");try{a=(await Q.getBlockInputFromUserQuery(JSON.stringify(o.input),n)).result,c.stop("Block input resolved"),p.data(a,"Resolved Block Input")}catch(l){c.stop("Could not resolve input automatically"),p.warn(`Input resolution failed: ${l.message}`),p.info("Proceeding with default input schema.")}}await xr(o.code,a?void 0:n,a||null,e.overwrite||!1)}catch(u){s.stop("Search failed"),p.fatal(`Error: ${u.message}`)}}A.command("help").description("List all commands and usage").action(()=>{console.log(`
|
|
106
106
|
Available commands:
|
|
107
107
|
|
|
108
108
|
GIT-LIKE WORKFLOW:
|
|
@@ -123,11 +123,8 @@ Available commands:
|
|
|
123
123
|
push
|
|
124
124
|
Push staged files to create a block in Derived.
|
|
125
125
|
Flags:
|
|
126
|
-
-c, --category <ref> : Category ID or name
|
|
127
126
|
-n, --name <name> : Block name
|
|
128
|
-
|
|
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
|
|
127
|
+
Example: derived-cli push -n "my-component"
|
|
131
128
|
|
|
132
129
|
BLOCK MANAGEMENT:
|
|
133
130
|
add <block-id>
|
|
@@ -146,34 +143,10 @@ Available commands:
|
|
|
146
143
|
-o, --overwrite : Overwrite existing files
|
|
147
144
|
Example: derived-cli search "add contact page"
|
|
148
145
|
|
|
149
|
-
create <
|
|
146
|
+
create <templateGroupName> [paths...]
|
|
150
147
|
Create templates from files (non-interactive).
|
|
151
|
-
|
|
152
|
-
|
|
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
|
|
156
|
-
|
|
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"
|
|
161
|
-
|
|
162
|
-
category ensure <name>
|
|
163
|
-
Find or create a category (idempotent). Always returns a category.
|
|
164
|
-
Example: derived-cli category ensure "UI Components"
|
|
165
|
-
|
|
166
|
-
category list
|
|
167
|
-
List all categories in the project (same as list-categories).
|
|
168
|
-
Example: derived-cli category list
|
|
169
|
-
|
|
170
|
-
create-category <categoryName>
|
|
171
|
-
Create a new category (legacy).
|
|
172
|
-
Example: derived-cli create-category "My Category"
|
|
173
|
-
|
|
174
|
-
list-categories
|
|
175
|
-
List all categories in the project (legacy).
|
|
176
|
-
Example: derived-cli list-categories
|
|
148
|
+
Example: derived-cli create "auth-jwt" /src/auth
|
|
149
|
+
Example: derived-cli create "hero-section" /src/components
|
|
177
150
|
|
|
178
151
|
PROJECT MANAGEMENT:
|
|
179
152
|
init <project-slug>
|
|
@@ -195,7 +168,7 @@ Available commands:
|
|
|
195
168
|
|
|
196
169
|
help
|
|
197
170
|
Show this help text.
|
|
198
|
-
`)});var
|
|
171
|
+
`)});var Os=n=>{let e=_();try{e.start("Decoding base64...");let t=Buffer.from(n,"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}};A.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(n,e)=>{let t=e.blockInput?Os(e.blockInput):null;if(kt(n,t||{})&&!e.force){p.note(`Block "${n}" with the same input is already added. Use -f to force re-add.`,"Already Added");return}let s=Qn(n,t||{});if(s.length>0&&!e.force){let u=s.length;p.note(`Block "${n}" was added ${u} time${u>1?"s":""} with different input. Proceeding with new input...`,"Different Input Detected")}await xr(n,e.query,t,e.overwrite)});A.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(n,e)=>{await _s(n,{autoSelect:e.autoSelect,overwrite:e.overwrite})});A.command("create <templateGroupName> [paths...]").description("Create templates from provided files/folders.").action(async(n,e=[],t)=>{let i="create",s=await ae.getToken();s||p.fatal("Not logged in. Run 'derived-cli register <token>' first.");let u=await me();u||p.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let r=u.projectID;p.info(`Using project ID from .derived/project.json: ${r}`);let o=new Le.default({apiToken:s}),a=e.filter(F=>F.trim().length>0);a.length===0&&p.fatal("At least one file or directory path is required.");let c=_();c.start("Collecting files...");let{files:l,errors:D}=Jt(a);c.stop(`Collected ${l.length} file(s) from ${a.length} path(s)`);for(let F of D)p.warn(F);l.length===0&&p.fatal("No valid files found.");let d=_();d.start("Creating template group...");let C=null,$=null;try{$=await o.createTemplateGroup({name:n,projectID:r});let F=Number($?.result?.id);if(!Number.isInteger(F)||F<=0)throw new Error("Template group created but no valid group ID was returned.");C=F,d.stop(`Template group created: ${C}`)}catch(F){d.stop("Failed to create template group");let Z=F.response?.data?JSON.stringify(F.response.data):F.message;J()&&le(i,"API_ERROR",Z),p.fatal(`API Error: ${Z}`)}C===null&&p.fatal("Template group could not be created.");let g=l.map(F=>({type:"add",templateGroupId:C,path:F.templatePath,template:F.template})),B=_();B.start(`Creating ${g.length} template(s)...`);try{await o.createMultipleTemplates(g),B.stop(`Created ${g.length} template(s)`);let F={templateGroup:$?.result,templateCount:l.length};J()&&Ut(i,F),p.outro(`Template group "${n}" created`),console.log(JSON.stringify($?.result))}catch(F){B.stop("Failed to create templates");let Z=F.response?.data?JSON.stringify(F.response.data):F.message;J()&&le(i,"API_ERROR",Z),p.fatal(`API Error: ${Z}`)}});async function zt(n,e){let{existsSync:t,mkdirSync:i,writeFileSync:s}=await import("fs"),{join:u}=await import("path"),r=u(n,".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");s(a,JSON.stringify(o,null,2))}A.command("project").description("Fetch current project details using slug from .derived/project.json").action(async()=>{let n=await me();if(!n){p.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");return}let e=n.projectSlug,t=_();t.start(`Fetching project details for '${e}'...`);try{let i=await Q.fetchProjectBySlug(e);i?.result||(t.stop("Project not found"),p.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"),p.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;p.fatal(`API Error: ${s}`)}});A.command("init <project-slug>").description("Initialize a project from a template").action(async n=>{p.intro(`Initializing project: ${n}`);try{let e=process.cwd(),{isDirectoryEmpty:t,removeGitDirectory:i}=await Promise.resolve().then(()=>(br(),yr)),{existsSync:s}=await import("fs"),{join:u}=await import("path"),r=t(e),o=_();o.start("Fetching project details...");let a=await Q.fetchProjectBySlug(n);a?.result||(o.stop("Project not found"),p.fatal(`Project '${n}' does not exist.`));let c=a.result;if(o.stop(`Found project: ${c.name}`),!r){let l=u(e,".derived","project.json");if(s(l)){w&&(await zt(e,c),p.outro("project.json updated"),process.exit(0));let D=await Nn({message:"project.json already exists. Overwrite?"});W(D)&&p.cancel("Operation cancelled."),D||(p.outro("Skipped updating project.json"),process.exit(0))}await zt(e,c),p.outro("project.json updated in .derived folder"),process.exit(0)}o.start("Cloning repository...");try{await Ve(`git clone ${c.gitUrl} .`,{stdio:"pipe",cwd:e}),o.stop("Repository cloned")}catch(l){o.stop("Failed to clone repository"),p.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){o.start(`Running: ${D}`);try{await Ve(D,{stdio:"inherit",cwd:e}),o.stop(`Completed: ${D}`)}catch(d){o.stop(`Warning: Command failed: ${D}`),p.warn(d.message)}}}await zt(e,c),p.outro(`Project '${c.name}' initialized`)}catch(e){p.fatal(`An error occurred: ${e.message}`)}});A.command("status").description("Show staged files and added blocks").action(async()=>{try{let n=he(),e=X(),t=n.length>0,i=e.addedBlocks.length>0;if(!t&&!i){p.note("Nothing to show. Use 'derived-cli stage <path>' to stage files.","Status");return}if(t){console.log(`
|
|
199
172
|
\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
|
|
201
|
-
`);for(let s of e.addedBlocks){let
|
|
173
|
+
`);for(let s of n)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
|
|
174
|
+
`);for(let s of e.addedBlocks){let u=Object.keys(s.input||{}).length>0?` ${JSON.stringify(s.input)}`:"";console.log(`\x1B[36m ${s.code}${u}\x1B[0m`)}}console.log("")}catch(n){p.fatal(`Failed to get status: ${n instanceof Error?n.message:String(n)}`)}});A.command("blocks-status").description("Show all blocks that have been added to the project").action(async()=>{try{let e=X().addedBlocks;if(e.length===0){p.note("No blocks have been added yet.","Blocks Status");return}p.note(`${e.length} block(s) added to this project:`,"Blocks Status"),e.forEach((t,i)=>{let s=JSON.stringify(t.input),u=s==="{}"?"(no input)":s;p.note(` ${i+1}. ${t.code} ${u}`,"")})}catch(n){p.fatal(`Failed to get blocks status: ${n.message}`)}});A.command("stage [paths...]").description("Stage files/directories for creating a block (git-like)").action(async(n=[])=>{try{if(n.length===0){p.note("No paths provided. Usage: derived-cli stage <path1> [path2] ...");return}let{files:e,errors:t}=Jt(n);for(let u of t)p.warn(u);if(e.length===0){p.fatal("No valid files found to stage.");return}let i=0,s=0;for(let u of e){if(It(u.templatePath)){s++;continue}er(u.templatePath),i++}i>0&&p.success(`Staged ${i} file(s)`),s>0&&p.note(`${s} file(s) already staged (skipped)`)}catch(e){p.fatal(`Failed to stage files: ${e instanceof Error?e.message:String(e)}`)}});A.command("unstage [paths...]").description("Remove files from the staging area").action(async(n=[])=>{try{if(n.length===0){p.note("No paths provided. Usage: derived-cli unstage <path1> [path2] ...");return}let e=he(),t=new Set(e.map(u=>u.path)),i=0,s=0;for(let u of n)t.has(u)?(tr(u),i++):(s++,p.warn(`Not staged: ${u}`));i>0&&p.success(`Unstaged ${i} file(s)`),s>0&&i===0&&p.note("No matching staged files found.")}catch(e){p.fatal(`Failed to unstage: ${e.message}`)}});A.command("clear-staging").description("Clear all files from the staging area").action(async()=>{try{let n=he();if(n.length===0){p.note("No files are currently staged.");return}Nt(),p.success(`Cleared ${n.length} file(s) from staging area`)}catch(n){p.fatal(`Failed to clear staging: ${n.message}`)}});A.command("push").description("Push staged files to create a block in Derived").option("-n, --name <name>","Block name").action(async n=>{let e="push";try{let t=await ae.getToken();t||p.fatal("Not logged in. Run 'derived-cli register <token>' first.");let i=await me();i||p.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let s=he();if(s.length===0){p.note("No files are currently staged. Use 'derived-cli stage <path>' to stage files.");return}p.intro(`Pushing ${s.length} staged file(s)`);let u=new Le.default({apiToken:t}),r=i.projectID,o;if(n.name)o=n.name;else{if(w){p.fatal("Block name required in agent mode. Use: derived-cli push -n <blockName>");return}let g=await $t({message:"Enter a name for the block:",placeholder:"e.g., my-component"});if(W(g)){p.cancel("Operation cancelled.");return}if(o=g,!o||o.trim()===""){p.fatal("Block name is required.");return}}let a=_();a.start("Collecting file contents...");let c=s.map(g=>{let B=(0,qe.join)(process.cwd(),g.path.replace(/^\//,"")),F=(0,k.existsSync)(B)?(0,k.readFileSync)(B,"utf-8"):"";return{templatePath:g.path,template:F}});a.stop(`Collected ${c.length} file(s)`);let l=_();l.start("Creating template group...");let D=null,d=null;try{d=await u.createTemplateGroup({name:o,projectID:r});let g=Number(d?.result?.id);if(!Number.isInteger(g)||g<=0)throw new Error("Template group created but no valid group ID was returned.");D=g,l.stop(`Template group created: ${D}`)}catch(g){l.stop("Failed to create template group");let B=g.response?.data?JSON.stringify(g.response.data):g.message;J()&&le(e,"API_ERROR",B),p.fatal(`API Error: ${B}`);return}if(D===null){p.fatal("Template group could not be created.");return}let C=c.map(g=>({type:"add",templateGroupId:D,path:g.templatePath,template:g.template})),$=_();$.start(`Creating ${C.length} template(s)...`);try{await u.createMultipleTemplates(C),$.stop(`Created ${C.length} template(s)`),Nt(),Tt(o,{fileCount:c.length});let g={templateGroup:d?.result,fileCount:c.length};J()&&Ut(e,g),p.outro(`Block "${o}" created with ${c.length} file(s)`),console.log(JSON.stringify(d?.result))}catch(g){$.stop("Failed to create templates");let B=g.response?.data?JSON.stringify(g.response.data):g.message;J()&&le(e,"API_ERROR",B),p.fatal(`API Error: ${B}`)}}catch(t){p.fatal(`Failed to push: ${t.message}`)}});A.command("register <token>").description("Register with your account token").action(async n=>{try{await ae.saveToken(n),p.success("Token saved")}catch(e){p.fatal(`Failed to save token: ${e.message}`)}});(async()=>{try{await A.parseAsync()}catch(n){throw n instanceof K&&(J()&&le("cli",n.code,n.message),process.exit(n.code==="CANCELLED"?0:1)),n}})();0&&(module.exports={displayFileTree});
|