derived-cli 0.0.68 → 0.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +178 -114
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -1,137 +1,201 @@
|
|
|
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 qn=Object.create;var be=Object.defineProperty;var Jn=Object.getOwnPropertyDescriptor;var Un=Object.getOwnPropertyNames;var Kn=Object.getPrototypeOf,zn=Object.prototype.hasOwnProperty;var Yn=(r,e)=>()=>(r&&(e=r(r=0)),e);var q=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),sr=(r,e)=>{for(var t in e)be(r,t,{get:e[t],enumerable:!0})},or=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Un(e))!zn.call(r,s)&&s!==t&&be(r,s,{get:()=>e[s],enumerable:!(i=Jn(e,s))||i.enumerable});return r};var b=(r,e,t)=>(t=r!=null?qn(Kn(r)):{},or(e||!r||!r.__esModule?be(t,"default",{value:r,enumerable:!0}):t,r)),Qn=r=>or(be({},"__esModule",{value:!0}),r);var fe=q(et=>{var ve=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Xe=class extends ve{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};et.CommanderError=ve;et.InvalidArgumentError=Xe});var $e=q(rt=>{var{InvalidArgumentError:Zn}=fe(),tt=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new Zn(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Xn(r){let e=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+e+">":"["+e+"]"}rt.Argument=tt;rt.humanReadableArgName=Xn});var st=q(it=>{var{humanReadableArgName:ei}=$e(),nt=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(s=>!s._hidden),i=e._getHelpCommand();return i&&!i._hidden&&t.push(i),this.sortSubcommands&&t.sort((s,o)=>s.name().localeCompare(o.name())),t}compareOptions(e,t){let i=s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){let t=e.options.filter(s=>!s.hidden),i=e._getHelpOption();if(i&&!i.hidden){let s=i.short&&e._findOption(i.short),o=i.long&&e._findOption(i.long);!s&&!o?t.push(i):i.long&&!o?t.push(e.createOption(i.long,i.description)):i.short&&!s&&t.push(e.createOption(i.short,i.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let i=e.parent;i;i=i.parent){let s=i.options.filter(o=>!o.hidden);t.push(...s)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(i=>ei(i)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((i,s)=>Math.max(i,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(s)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,s)=>Math.max(i,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((i,s)=>Math.max(i,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,s)=>Math.max(i,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(s)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let s=e.parent;s;s=s.parent)i=s.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatItemList(e,t,i){return t.length===0?[]:[i.styleTitle(e),...t,""]}groupItems(e,t,i){let s=new Map;return e.forEach(o=>{let n=i(o);s.has(n)||s.set(n,[])}),t.forEach(o=>{let n=i(o);s.has(n)||s.set(n,[]),s.get(n).push(o)}),s}formatHelp(e,t){let i=t.padWidth(e,t),s=t.helpWidth??80;function o(D,h){return t.formatItem(D,i,h,t)}let n=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],u=t.commandDescription(e);u.length>0&&(n=n.concat([t.boxWrap(t.styleCommandDescription(u),s),""]));let a=t.visibleArguments(e).map(D=>o(t.styleArgumentTerm(t.argumentTerm(D)),t.styleArgumentDescription(t.argumentDescription(D))));if(n=n.concat(this.formatItemList("Arguments:",a,t)),this.groupItems(e.options,t.visibleOptions(e),D=>D.helpGroupHeading??"Options:").forEach((D,h)=>{let E=D.map(B=>o(t.styleOptionTerm(t.optionTerm(B)),t.styleOptionDescription(t.optionDescription(B))));n=n.concat(this.formatItemList(h,E,t))}),t.showGlobalOptions){let D=t.visibleGlobalOptions(e).map(h=>o(t.styleOptionTerm(t.optionTerm(h)),t.styleOptionDescription(t.optionDescription(h))));n=n.concat(this.formatItemList("Global Options:",D,t))}return this.groupItems(e.commands,t.visibleCommands(e),D=>D.helpGroup()||"Commands:").forEach((D,h)=>{let E=D.map(B=>o(t.styleSubcommandTerm(t.subcommandTerm(B)),t.styleSubcommandDescription(t.subcommandDescription(B))));n=n.concat(this.formatItemList(h,E,t))}),n.join(`
|
|
3
|
+
`)}displayWidth(e){return ur(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,i,s){let n=" ".repeat(2);if(!i)return n+e;let u=e.padEnd(t+e.length-s.displayWidth(e)),a=2,l=(this.helpWidth??80)-t-a-2,D;return l<this.minWidthToWrap||s.preformatted(i)?D=i:D=s.boxWrap(i,l).replace(/\n/g,`
|
|
4
|
+
`+" ".repeat(t+a)),n+u+" ".repeat(a)+D.replace(/\n/g,`
|
|
5
|
+
${n}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let i=e.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,o=[];return i.forEach(n=>{let u=n.match(s);if(u===null){o.push("");return}let a=[u.shift()],c=this.displayWidth(a[0]);u.forEach(l=>{let D=this.displayWidth(l);if(c+D<=t){a.push(l),c+=D;return}o.push(a.join(""));let h=l.trimStart();a=[h],c=this.displayWidth(h)}),o.push(a.join(""))}),o.join(`
|
|
6
|
+
`)}};function ur(r){let e=/\x1b\[\d*(;\d*)*m/g;return r.replace(e,"")}it.Help=nt;it.stripColor=ur});var ct=q(at=>{var{InvalidArgumentError:ti}=fe(),ot=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let i=ri(e);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new ti(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,i):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?ar(this.name().replace(/^no-/,"")):ar(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},ut=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(e,t){let i=t.attributeName();if(!this.dualOptions.has(i))return!0;let s=this.negativeOptions.get(i).presetArg,o=s!==void 0?s:!1;return t.negate===(o===e)}};function ar(r){return r.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ri(r){let e,t,i=/^-[^-]$/,s=/^--[^-]/,o=r.split(/[ |,]+/).concat("guard");if(i.test(o[0])&&(e=o.shift()),s.test(o[0])&&(t=o.shift()),!e&&i.test(o[0])&&(e=o.shift()),!e&&s.test(o[0])&&(e=t,t=o.shift()),o[0].startsWith("-")){let n=o[0],u=`option creation failed due to '${n}' in option flags '${r}'`;throw/^-[^-][^-]/.test(n)?new Error(`${u}
|
|
7
7
|
- a short flag is a single dash and a single character
|
|
8
8
|
- either use a single dash and a single character (for a short flag)
|
|
9
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):
|
|
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 '${
|
|
13
|
-
(Did you mean one of ${
|
|
14
|
-
(Did you mean ${
|
|
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 '${
|
|
17
|
-
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=s=>[s.name()].concat(s.aliases()),
|
|
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,
|
|
19
|
-
- if '${
|
|
9
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(n)?new Error(`${u}
|
|
10
|
+
- too many short flags`):s.test(n)?new Error(`${u}
|
|
11
|
+
- too many long flags`):new Error(`${u}
|
|
12
|
+
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${r}'.`);return{shortFlag:e,longFlag:t}}at.Option=ot;at.DualOptions=ut});var lr=q(cr=>{function ni(r,e){if(Math.abs(r.length-e.length)>3)return Math.max(r.length,e.length);let t=[];for(let i=0;i<=r.length;i++)t[i]=[i];for(let i=0;i<=e.length;i++)t[0][i]=i;for(let i=1;i<=e.length;i++)for(let s=1;s<=r.length;s++){let o=1;r[s-1]===e[i-1]?o=0:o=1,t[s][i]=Math.min(t[s-1][i]+1,t[s][i-1]+1,t[s-1][i-1]+o),s>1&&i>1&&r[s-1]===e[i-2]&&r[s-2]===e[i-1]&&(t[s][i]=Math.min(t[s][i],t[s-2][i-2]+1))}return t[r.length][e.length]}function ii(r,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=r.startsWith("--");t&&(r=r.slice(2),e=e.map(n=>n.slice(2)));let i=[],s=3,o=.4;return e.forEach(n=>{if(n.length<=1)return;let u=ni(r,n),a=Math.max(r.length,n.length);(a-u)/a>o&&(u<s?(s=u,i=[n]):u===s&&i.push(n))}),i.sort((n,u)=>n.localeCompare(u)),t&&(i=i.map(n=>`--${n}`)),i.length>1?`
|
|
13
|
+
(Did you mean one of ${i.join(", ")}?)`:i.length===1?`
|
|
14
|
+
(Did you mean ${i[0]}?)`:""}cr.suggestSimilar=ii});var hr=q(ht=>{var si=require("node:events").EventEmitter,lt=require("node:child_process"),Q=require("node:path"),we=require("node:fs"),g=require("node:process"),{Argument:oi,humanReadableArgName:ui}=$e(),{CommanderError:Dt}=fe(),{Help:ai,stripColor:ci}=st(),{Option:Dr,DualOptions:li}=ct(),{suggestSimilar:dr}=lr(),dt=class r extends si{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>g.stdout.write(t),writeErr:t=>g.stderr.write(t),outputError:(t,i)=>i(t),getOutHelpWidth:()=>g.stdout.isTTY?g.stdout.columns:void 0,getErrHelpWidth:()=>g.stderr.isTTY?g.stderr.columns:void 0,getOutHasColors:()=>pt()??(g.stdout.isTTY&&g.stdout.hasColors?.()),getErrHasColors:()=>pt()??(g.stderr.isTTY&&g.stderr.hasColors?.()),stripColor:t=>ci(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let s=t,o=i;typeof s=="object"&&s!==null&&(o=s,s=null),o=o||{};let[,n,u]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(n);return s&&(a.description(s),a._executableHandler=!0),o.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(o.noHelp||o.hidden),a._executableFile=o.executableFile||null,u&&a.arguments(u),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),s?this:a}createCommand(e){return new r(e)}createHelp(){return Object.assign(new ai,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
15
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new oi(e,t)}argument(e,t,i,s){let o=this.createArgument(e,t);return typeof i=="function"?o.default(s).argParser(i):o.default(i),this.addArgument(o),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let i=e??"help [command]",[,s,o]=i.match(/([^ ]+) *(.*)/),n=t??"display help for command",u=this.createCommand(s);return u.helpOption(!1),o&&u.arguments(o),n&&u.description(n),this._addImplicitHelpCommand=!0,this._helpCommand=u,(e||t)&&this._initCommandGroup(u),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
16
|
+
Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new Dt(e,t,i)),g.exit(e)}action(e){let t=i=>{let s=this.registeredArguments.length,o=i.slice(0,s);return this._storeOptionsAsProperties?o[s]=this:o[s]=this.opts(),o.push(this),e.apply(this,o)};return this._actionHandler=t,this}createOption(e,t){return new Dr(e,t)}_callParseArg(e,t,i,s){try{return e.parseArg(t,i)}catch(o){if(o.code==="commander.invalidArgument"){let n=`${s} ${o.message}`;this.error(n,{exitCode:o.exitCode,code:o.code})}throw o}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let i=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
|
|
17
|
+
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=s=>[s.name()].concat(s.aliases()),i=t(e).find(s=>this._findCommand(s));if(i){let s=t(this._findCommand(i)).join("|"),o=t(e).join("|");throw new Error(`cannot add command '${o}' as already have command '${s}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let o=e.long.replace(/^--no-/,"--");this._findOption(o)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let s=(o,n,u)=>{o==null&&e.presetArg!==void 0&&(o=e.presetArg);let a=this.getOptionValue(i);o!==null&&e.parseArg?o=this._callParseArg(e,o,a,n):o!==null&&e.variadic&&(o=e._collectValue(o,a)),o==null&&(e.negate?o=!1:e.isBoolean()||e.optional?o=!0:o=""),this.setOptionValueWithSource(i,o,u)};return this.on("option:"+t,o=>{let n=`error: option '${e.flags}' argument '${o}' is invalid.`;s(o,n,"cli")}),e.envVar&&this.on("optionEnv:"+t,o=>{let n=`error: option '${e.flags}' value '${o}' from env '${e.envVar}' is invalid.`;s(o,n,"env")}),this}_optionEx(e,t,i,s,o){if(typeof t=="object"&&t instanceof Dr)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let n=this.createOption(t,i);if(n.makeOptionMandatory(!!e.mandatory),typeof s=="function")n.default(o).argParser(s);else if(s instanceof RegExp){let u=s;s=(a,c)=>{let l=u.exec(a);return l?l[0]:c},n.default(o).argParser(s)}else n.default(s);return this.addOption(n)}option(e,t,i,s){return this._optionEx({},e,t,i,s)}requiredOption(e,t,i,s){return this._optionEx({mandatory:!0},e,t,i,s)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(e)!==void 0&&(t=i.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){g.versions?.electron&&(t.from="electron");let s=g.execArgv??[];(s.includes("-e")||s.includes("--eval")||s.includes("-p")||s.includes("--print"))&&(t.from="eval")}e===void 0&&(e=g.argv),this.rawArgs=e.slice();let i;switch(t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":g.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=e.slice(0);break;case"eval":i=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(e,t){this._prepareForParse();let i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){this._prepareForParse();let i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
18
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,i){if(we.existsSync(e))return;let s=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",o=`'${e}' does not exist
|
|
19
|
+
- 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(o)}_executeSubCommand(e,t){t=t.slice();let i=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function o(l,D){let h=Q.resolve(l,D);if(we.existsSync(h))return h;if(s.includes(Q.extname(D)))return;let E=s.find(B=>we.existsSync(`${h}${B}`));if(E)return`${h}${E}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=e._executableFile||`${this._name}-${e._name}`,u=this._executableDir||"";if(this._scriptPath){let l;try{l=we.realpathSync(this._scriptPath)}catch{l=this._scriptPath}u=Q.resolve(Q.dirname(l),u)}if(u){let l=o(u,n);if(!l&&!e._executableFile&&this._scriptPath){let D=Q.basename(this._scriptPath,Q.extname(this._scriptPath));D!==this._name&&(l=o(u,`${D}-${e._name}`))}n=l||n}i=s.includes(Q.extname(n));let a;g.platform!=="win32"?i?(t.unshift(n),t=pr(g.execArgv).concat(t),a=lt.spawn(g.argv[0],t,{stdio:"inherit"})):a=lt.spawn(n,t,{stdio:"inherit"}):(this._checkForMissingExecutable(n,u,e._name),t.unshift(n),t=pr(g.execArgv).concat(t),a=lt.spawn(g.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(D=>{g.on(D,()=>{a.killed===!1&&a.exitCode===null&&a.kill(D)})});let c=this._exitCallback;a.on("close",l=>{l=l??1,c?c(new Dt(l,"commander.executeSubCommandAsync","(close)")):g.exit(l)}),a.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(n,u,e._name);else if(l.code==="EACCES")throw new Error(`'${n}' not executable`);if(!c)g.exit(1);else{let D=new Dt(1,"commander.executeSubCommandAsync","(error)");D.nestedError=l,c(D)}}),this.runningCommand=a}_dispatchSubcommand(e,t,i){let s=this._findCommand(e);s||this.help({error:!0}),s._prepareForParse();let o;return o=this._chainOrCallSubCommandHook(o,s,"preSubcommand"),o=this._chainOrCall(o,()=>{if(s._executableHandler)this._executeSubCommand(s,t.concat(i));else return s._parseCommand(t,i)}),o}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(i,s,o)=>{let n=s;if(s!==null&&i.parseArg){let u=`error: command-argument value '${s}' is invalid for argument '${i.name()}'.`;n=this._callParseArg(i,s,o,u)}return n};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((i,s)=>{let o=i.defaultValue;i.variadic?s<this.args.length?(o=this.args.slice(s),i.parseArg&&(o=o.reduce((n,u)=>e(i,u,n),i.defaultValue))):o===void 0&&(o=[]):s<this.args.length&&(o=this.args[s],i.parseArg&&(o=e(i,o,i.defaultValue))),t[s]=o}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let i=e,s=[];return this._getCommandAndAncestors().reverse().filter(o=>o._lifeCycleHooks[t]!==void 0).forEach(o=>{o._lifeCycleHooks[t].forEach(n=>{s.push({hookedCommand:o,callback:n})})}),t==="postAction"&&s.reverse(),s.forEach(o=>{i=this._chainOrCall(i,()=>o.callback(o.hookedCommand,this))}),i}_chainOrCallSubCommandHook(e,t,i){let s=e;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(o=>{s=this._chainOrCall(s,()=>o(this,t))}),s}_parseCommand(e,t){let i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},o=`command:${this.name()}`;if(this._actionHandler){s(),this._processArguments();let n;return n=this._chainOrCallHooks(n,"preAction"),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(o,e,t)})),n=this._chainOrCallHooks(n,"postAction"),n}if(this.parent?.listenerCount(o))s(),this._processArguments(),this.parent.emit(o,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(s(),this._processArguments())}else this.commands.length?(s(),this.help({error:!0})):(s(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(i=>{let s=i.attributeName();return this.getOptionValue(s)===void 0?!1:this.getOptionValueSource(s)!=="default"});e.filter(i=>i.conflictsWith.length>0).forEach(i=>{let s=e.find(o=>i.conflictsWith.includes(o.attributeName()));s&&this._conflictingOption(i,s)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],i=[],s=t;function o(l){return l.length>1&&l[0]==="-"}let n=l=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(l)?!this._getCommandAndAncestors().some(D=>D.options.map(h=>h.short).some(h=>/^-\d$/.test(h))):!1,u=null,a=null,c=0;for(;c<e.length||a;){let l=a??e[c++];if(a=null,l==="--"){s===i&&s.push(l),s.push(...e.slice(c));break}if(u&&(!o(l)||n(l))){this.emit(`option:${u.name()}`,l);continue}if(u=null,o(l)){let D=this._findOption(l);if(D){if(D.required){let h=e[c++];h===void 0&&this.optionMissingArgument(D),this.emit(`option:${D.name()}`,h)}else if(D.optional){let h=null;c<e.length&&(!o(e[c])||n(e[c]))&&(h=e[c++]),this.emit(`option:${D.name()}`,h)}else this.emit(`option:${D.name()}`);u=D.variadic?D:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let D=this._findOption(`-${l[1]}`);if(D){D.required||D.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${D.name()}`,l.slice(2)):(this.emit(`option:${D.name()}`),a=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let D=l.indexOf("="),h=this._findOption(l.slice(0,D));if(h&&(h.required||h.optional)){this.emit(`option:${h.name()}`,l.slice(D+1));continue}}if(s===t&&o(l)&&!(this.commands.length===0&&n(l))&&(s=i),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(l)){t.push(l),i.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){i.push(l,...e.slice(c));break}}if(this._passThroughOptions){s.push(l,...e.slice(c));break}s.push(l)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let i=0;i<t;i++){let s=this.options[i].attributeName();e[s]=s===this._versionOptionName?this._version:this[s]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
22
22
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
23
23
|
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
24
|
-
`),this.outputHelp({error:!0}));let
|
|
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
|
|
26
|
-
Expecting one of '${
|
|
27
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Rt(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="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]:n=u[3]):(u=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=u[1],n=u[3],s=u[4]),t&&s!=="0"?`${t}=${n}:${parseInt(s)+1}`:e})}function Ye(){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}Qe.Command=Ke;Qe.useColor=Ye});var Ut=P(S=>{var{Argument:Wt}=le(),{Command:Ze}=Gt(),{CommanderError:xi,InvalidArgumentError:qt}=ne(),{Help:Oi}=Ge(),{Option:Lt}=Ue();S.program=new Ze;S.createCommand=i=>new Ze(i);S.createOption=(i,e)=>new Lt(i,e);S.createArgument=(i,e)=>new Wt(i,e);S.Command=Ze;S.Option=Lt;S.Argument=Wt;S.Help=Oi;S.CommanderError=xi;S.InvalidArgumentError=qt;S.InvalidOptionArgumentError=qt});var tt=P((ws,Kt)=>{"use strict";var Xe="\x1B",F=`${Xe}[`,Si="\x07",et={to(i,e){return e?`${F}${e+1};${i+1}H`:`${F}${i+1}G`},move(i,e){let t="";return i<0?t+=`${F}${-i}D`:i>0&&(t+=`${F}${i}C`),e<0?t+=`${F}${-e}A`:e>0&&(t+=`${F}${e}B`),t},up:(i=1)=>`${F}${i}A`,down:(i=1)=>`${F}${i}B`,forward:(i=1)=>`${F}${i}C`,backward:(i=1)=>`${F}${i}D`,nextLine:(i=1)=>`${F}E`.repeat(i),prevLine:(i=1)=>`${F}F`.repeat(i),left:`${F}G`,hide:`${F}?25l`,show:`${F}?25h`,save:`${Xe}7`,restore:`${Xe}8`},ki={up:(i=1)=>`${F}S`.repeat(i),down:(i=1)=>`${F}T`.repeat(i)},Ti={screen:`${F}2J`,up:(i=1)=>`${F}1J`.repeat(i),down:(i=1)=>`${F}J`.repeat(i),line:`${F}2K`,lineEnd:`${F}K`,lineStart:`${F}1K`,lines(i){let e="";for(let t=0;t<i;t++)e+=this.line+(t<i-1?et.up():"");return i&&(e+=et.left),e}};Kt.exports={cursor:et,scroll:ki,erase:Ti,beep:Si}});var de=P((As,rt)=>{var pe=process||{},Yt=pe.argv||[],he=pe.env||{},ji=!(he.NO_COLOR||Yt.includes("--no-color"))&&(!!he.FORCE_COLOR||Yt.includes("--color")||pe.platform==="win32"||(pe.stdout||{}).isTTY&&he.TERM!=="dumb"||!!he.CI),Pi=(i,e,t=i)=>n=>{let s=""+n,u=s.indexOf(e,i.length);return~u?i+Ii(s,e,t,u)+e:i+s+e},Ii=(i,e,t,n)=>{let s="",u=0;do s+=i.substring(u,n)+t,u=n+e.length,n=i.indexOf(e,u);while(~n);return s+i.substring(u)},Qt=(i=ji)=>{let e=i?Pi:()=>String;return{isColorSupported:i,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")}};rt.exports=Qt();rt.exports.createColors=Qt});var xr=P((Ms,_r)=>{"use strict";var gt=Object.defineProperty,yn=Object.getOwnPropertyDescriptor,bn=Object.getOwnPropertyNames,vn=Object.prototype.hasOwnProperty,$n=(i,e)=>{for(var t in e)gt(i,t,{get:e[t],enumerable:!0})},wn=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of bn(e))!vn.call(i,s)&&s!==t&>(i,s,{get:()=>e[s],enumerable:!(n=yn(e,s))||n.enumerable});return i},An=i=>wn(gt({},"__esModule",{value:!0}),i),Br={};$n(Br,{default:()=>xn});_r.exports=An(Br);var Bn=class{baseUrl;defaultHeaders;constructor(i,e={}){this.baseUrl=i,this.defaultHeaders=e}buildUrl(i){return`${this.baseUrl.replace(/\/$/,"")}/${i.replace(/^\//,"")}`}async request(i,e,t,n={}){let s=this.buildUrl(e),u=await fetch(s,{method:i,headers:{"Content-Type":"application/json",...this.defaultHeaders,...n},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(i,e){return this.request("GET",i,void 0,e)}post(i,e,t){return this.request("POST",i,e,t)}put(i,e,t){return this.request("PUT",i,e,t)}delete(i,e){return this.request("DELETE",i,void 0,e)}},_n=class{api;apiToken;constructor(i){this.apiToken=i?.apiToken,this.api=new Bn("https://api.derived.dev/api",{...this.apiToken?{Authorization:this.apiToken}:{}})}fetchBlock=async i=>this.api.get(`/public/v1/template-group/code/${i}`);getBlockInputFromUserQuery=(i,e)=>this.api.post("/public/v1/template-group/get-block-input-from-user-query",{blockInput:i,query:e});resolveMultipleTemplates=(i,e)=>this.api.post("/public/v1/template-group/resolve-multiple-templates-by-block-code",{blockCode:i,data:e});searchBlocksByName=(i,e)=>this.api.get(`/public/v1/template-group/semantic-search?q=${i}&limit=5&threshold=0.5&project_id=${e}`);fetchProjectBySlug=async i=>this.api.get(`/public/v1/project/detail-by-slug/${i}`);createMultipleTemplates=async i=>this.api.post("/v1/template/create-multiple",i);createTemplateGroup=async i=>this.api.post("/v1/template-group/create",i);getProjectCategories=async(i,e=20,t=1)=>{let n=encodeURIComponent(JSON.stringify({projectID:i})),s=encodeURIComponent(JSON.stringify({Desc:"id"}));return this.api.get(`/v1/block-category/list?filters=${n}&sort=${s}&limit=${e}&page=${t}`)};createCategory=async i=>this.api.post("/v1/block-category/create",i);updateTemplateGroup=async(i,e)=>this.api.put(`/v1/template-group/update/${i}`,e)},xn=_n});var ei={};Tt(ei,{isDirectoryEmpty:()=>Qn,removeGitDirectory:()=>Zn});function Qn(i){return(0,Y.existsSync)(i)?(0,Y.readdirSync)(i).filter(n=>!n.startsWith(".")).length===0:!0}function Zn(i){let e=(0,Xr.join)(i,".git");(0,Y.existsSync)(e)&&(0,Y.rmSync)(e,{recursive:!0,force:!0})}var Y,Xr,ti=di(()=>{"use strict";Y=require("fs"),Xr=require("path")});var ss={};Tt(ss,{displayFileTree:()=>ui});module.exports=mi(ss);var Jt=g(Ut(),1),{program:ds,createCommand:ms,createArgument:fs,createOption:gs,CommanderError:Cs,InvalidArgumentError:Fs,InvalidOptionArgumentError:Es,Command:zt,Argument:ys,Option:bs,Help:vs}=Jt.default;var ye=require("node:util");var v=g(tt(),1),te=require("node:process"),R=g(require("node:readline"),1),st=g(require("node:readline"),1),ur=require("node:stream"),or=g(de(),1);function Ni({onlyFirst:i=!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,i?void 0:"g")}var Mi=Ni();function ar(i){if(typeof i!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof i}\``);return i.replace(Mi,"")}function Dr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var lr={exports:{}};(function(i){var e={};i.exports=e,e.eastAsianWidth=function(n){var s=n.charCodeAt(0),u=n.length==2?n.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(n){var s=this.eastAsianWidth(n);return s=="F"||s=="W"||s=="A"?2:1};function t(n){return n.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}e.length=function(n){for(var s=t(n),u=0,r=0;r<s.length;r++)u=u+this.characterLength(s[r]);return u},e.slice=function(n,s,u){textLen=e.length(n),s=s||0,u=u||1,s<0&&(s=textLen+s),u<0&&(u=textLen+u);for(var r="",o=0,a=t(n),D=0;D<a.length;D++){var l=a[D],c=e.length(l);if(o>=s-(c==2?1:0))if(o+c<=u)r+=l;else break;o+=c}return r}})(lr);var Vi=lr.exports,Hi=Dr(Vi),Ri=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},Gi=Dr(Ri);function se(i,e={}){if(typeof i!="string"||i.length===0||(e={ambiguousIsNarrow:!0,...e},i=ar(i),i.length===0))return 0;i=i.replace(Gi()," ");let t=e.ambiguousIsNarrow?1:2,n=0;for(let s of i){let u=s.codePointAt(0);if(!(u<=31||u>=127&&u<=159||u>=768&&u<=879))switch(Hi.eastAsianWidth(s)){case"F":case"W":n+=2;break;case"A":n+=t;break;default:n+=1}}return n}var it=10,Zt=(i=0)=>e=>`\x1B[${e+i}m`,Xt=(i=0)=>e=>`\x1B[${38+i};5;${e}m`,er=(i=0)=>(e,t,n)=>`\x1B[${38+i};2;${e};${t};${n}m`,C={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(C.modifier);var Wi=Object.keys(C.color),qi=Object.keys(C.bgColor);[...Wi,...qi];function Li(){let i=new Map;for(let[e,t]of Object.entries(C)){for(let[n,s]of Object.entries(t))C[n]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},t[n]=C[n],i.set(s[0],s[1]);Object.defineProperty(C,e,{value:t,enumerable:!1})}return Object.defineProperty(C,"codes",{value:i,enumerable:!1}),C.color.close="\x1B[39m",C.bgColor.close="\x1B[49m",C.color.ansi=Zt(),C.color.ansi256=Xt(),C.color.ansi16m=er(),C.bgColor.ansi=Zt(it),C.bgColor.ansi256=Xt(it),C.bgColor.ansi16m=er(it),Object.defineProperties(C,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?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(n/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[n]=t;n.length===3&&(n=[...n].map(u=>u+u).join(""));let s=Number.parseInt(n,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:e=>C.rgbToAnsi256(...C.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,s;if(e>=232)t=((e-232)*10+8)/255,n=t,s=t;else{e-=16;let o=e%36;t=Math.floor(e/36)/5,n=Math.floor(o/6)/5,s=o%6/5}let u=Math.max(t,n,s)*2;if(u===0)return 30;let r=30+(Math.round(s)<<2|Math.round(n)<<1|Math.round(t));return u===2&&(r+=60),r},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>C.ansi256ToAnsi(C.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>C.ansi256ToAnsi(C.hexToAnsi256(e)),enumerable:!1}}),C}var Ui=Li(),Ee=new Set(["\x1B","\x9B"]),Ji=39,ot="\x07",cr="[",zi="]",hr="m",at=`${zi}8;;`,tr=i=>`${Ee.values().next().value}${cr}${i}${hr}`,rr=i=>`${Ee.values().next().value}${at}${i}${ot}`,Ki=i=>i.split(" ").map(e=>se(e)),nt=(i,e,t)=>{let n=[...e],s=!1,u=!1,r=se(ar(i[i.length-1]));for(let[o,a]of n.entries()){let D=se(a);if(r+D<=t?i[i.length-1]+=a:(i.push(a),r=0),Ee.has(a)&&(s=!0,u=n.slice(o+1).join("").startsWith(at)),s){u?a===ot&&(s=!1,u=!1):a===hr&&(s=!1);continue}r+=D,r===t&&o<n.length-1&&(i.push(""),r=0)}!r&&i[i.length-1].length>0&&i.length>1&&(i[i.length-2]+=i.pop())},Yi=i=>{let e=i.split(" "),t=e.length;for(;t>0&&!(se(e[t-1])>0);)t--;return t===e.length?i:e.slice(0,t).join(" ")+e.slice(t).join("")},Qi=(i,e,t={})=>{if(t.trim!==!1&&i.trim()==="")return"";let n="",s,u,r=Ki(i),o=[""];for(let[D,l]of i.split(" ").entries()){t.trim!==!1&&(o[o.length-1]=o[o.length-1].trimStart());let c=se(o[o.length-1]);if(D!==0&&(c>=e&&(t.wordWrap===!1||t.trim===!1)&&(o.push(""),c=0),(c>0||t.trim===!1)&&(o[o.length-1]+=" ",c++)),t.hard&&r[D]>e){let p=e-c,E=1+Math.floor((r[D]-p-1)/e);Math.floor((r[D]-1)/e)<E&&o.push(""),nt(o,l,e);continue}if(c+r[D]>e&&c>0&&r[D]>0){if(t.wordWrap===!1&&c<e){nt(o,l,e);continue}o.push("")}if(c+r[D]>e&&t.wordWrap===!1){nt(o,l,e);continue}o[o.length-1]+=l}t.trim!==!1&&(o=o.map(D=>Yi(D)));let a=[...o.join(`
|
|
28
|
-
`)];for(let[
|
|
29
|
-
`?(
|
|
30
|
-
`&&(s&&
|
|
24
|
+
`),this.outputHelp({error:!0}));let i=t||{},s=i.exitCode||1,o=i.code||"commander.error";this._exit(s,o,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in g.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,g.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new li(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(s=>!t(s)).forEach(s=>{this.setOptionValueWithSource(s,i.implied[s],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=n=>{let u=n.attributeName(),a=this.getOptionValue(u),c=this.options.find(D=>D.negate&&u===D.attributeName()),l=this.options.find(D=>!D.negate&&u===D.attributeName());return c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg)?c:l||n},s=n=>{let u=i(n),a=u.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},o=`error: ${s(e)} cannot be used with ${s(t)}`;this.error(o,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let s=[],o=this;do{let n=o.createHelp().visibleOptions(o).filter(u=>u.long).map(u=>u.long);s=s.concat(n),o=o.parent}while(o&&!o._enablePositionalOptions);t=dr(e,s)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,i=t===1?"":"s",o=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(o,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let s=[];this.createHelp().visibleCommands(this).forEach(o=>{s.push(o.name()),o.alias()&&s.push(o.alias())}),t=dr(e,s)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let s=this.createOption(t,i);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
25
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(e);if(i){let s=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${s}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>ui(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=Q.basename(e,Q.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),i=this._getOutputContext(e);t.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let s=t.formatHelp(this,t);return i.hasColors?s:this._outputConfiguration.stripColor(s)}_getOutputContext(e){e=e||{};let t=!!e.error,i,s,o;return t?(i=u=>this._outputConfiguration.writeErr(u),s=this._outputConfiguration.getErrHasColors(),o=this._outputConfiguration.getErrHelpWidth()):(i=u=>this._outputConfiguration.writeOut(u),s=this._outputConfiguration.getOutHasColors(),o=this._outputConfiguration.getOutHelpWidth()),{error:t,write:u=>(s||(u=this._outputConfiguration.stripColor(u)),i(u)),hasColors:s,helpWidth:o}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getOutputContext(e),s={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(n=>n.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let o=this.helpInformation({error:i.error});if(t&&(o=t(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(o),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(n=>n.emit("afterAllHelp",s))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(g.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
26
|
+
Expecting one of '${i.join("', '")}'`);let s=`${e}Help`;return this.on(s,o=>{let n;typeof t=="function"?n=t({error:o.error,command:o.command}):n=t,n&&o.write(`${n}
|
|
27
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function pr(r){return r.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",s="9229",o;return(o=e.match(/^(--inspect(-brk)?)$/))!==null?t=o[1]:(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=o[1],/^\d+$/.test(o[3])?s=o[3]:i=o[3]):(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=o[1],i=o[3],s=o[4]),t&&s!=="0"?`${t}=${i}:${parseInt(s)+1}`:e})}function pt(){if(g.env.NO_COLOR||g.env.FORCE_COLOR==="0"||g.env.FORCE_COLOR==="false")return!1;if(g.env.FORCE_COLOR||g.env.CLICOLOR_FORCE!==void 0)return!0}ht.Command=dt;ht.useColor=pt});var Cr=q(R=>{var{Argument:mr}=$e(),{Command:mt}=hr(),{CommanderError:Di,InvalidArgumentError:fr}=fe(),{Help:di}=st(),{Option:gr}=ct();R.program=new mt;R.createCommand=r=>new mt(r);R.createOption=(r,e)=>new gr(r,e);R.createArgument=(r,e)=>new mr(r,e);R.Command=mt;R.Option=gr;R.Argument=mr;R.Help=di;R.CommanderError=Di;R.InvalidArgumentError=fr;R.InvalidOptionArgumentError=fr});var Ct=q((Co,Er)=>{"use strict";var ft="\x1B",w=`${ft}[`,pi="\x07",gt={to(r,e){return e?`${w}${e+1};${r+1}H`:`${w}${r+1}G`},move(r,e){let t="";return r<0?t+=`${w}${-r}D`:r>0&&(t+=`${w}${r}C`),e<0?t+=`${w}${-e}A`:e>0&&(t+=`${w}${e}B`),t},up:(r=1)=>`${w}${r}A`,down:(r=1)=>`${w}${r}B`,forward:(r=1)=>`${w}${r}C`,backward:(r=1)=>`${w}${r}D`,nextLine:(r=1)=>`${w}E`.repeat(r),prevLine:(r=1)=>`${w}F`.repeat(r),left:`${w}G`,hide:`${w}?25l`,show:`${w}?25h`,save:`${ft}7`,restore:`${ft}8`},hi={up:(r=1)=>`${w}S`.repeat(r),down:(r=1)=>`${w}T`.repeat(r)},mi={screen:`${w}2J`,up:(r=1)=>`${w}1J`.repeat(r),down:(r=1)=>`${w}J`.repeat(r),line:`${w}2K`,lineEnd:`${w}K`,lineStart:`${w}1K`,lines(r){let e="";for(let t=0;t<r;t++)e+=this.line+(t<r-1?gt.up():"");return r&&(e+=gt.left),e}};Er.exports={cursor:gt,scroll:hi,erase:mi,beep:pi}});var Be=q((Fo,Ft)=>{var xe=process||{},br=xe.argv||[],Ae=xe.env||{},fi=!(Ae.NO_COLOR||br.includes("--no-color"))&&(!!Ae.FORCE_COLOR||br.includes("--color")||xe.platform==="win32"||(xe.stdout||{}).isTTY&&Ae.TERM!=="dumb"||!!Ae.CI),gi=(r,e,t=r)=>i=>{let s=""+i,o=s.indexOf(e,r.length);return~o?r+Ci(s,e,t,o)+e:r+s+e},Ci=(r,e,t,i)=>{let s="",o=0;do s+=r.substring(o,i)+t,o=i+e.length,i=r.indexOf(e,o);while(~i);return s+r.substring(o)},vr=(r=fi)=>{let e=r?gi:()=>String;return{isColorSupported:r,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};Ft.exports=vr();Ft.exports.createColors=vr});var It=q((So,Xr)=>{"use strict";var Pt=Object.defineProperty,rs=Object.getOwnPropertyDescriptor,ns=Object.getOwnPropertyNames,is=Object.prototype.hasOwnProperty,ss=(r,e)=>{for(var t in e)Pt(r,t,{get:e[t],enumerable:!0})},os=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ns(e))!is.call(r,s)&&s!==t&&Pt(r,s,{get:()=>e[s],enumerable:!(i=rs(e,s))||i.enumerable});return r},us=r=>os(Pt({},"__esModule",{value:!0}),r),Zr={};ss(Zr,{default:()=>ls});Xr.exports=us(Zr);var as=class{baseUrl;defaultHeaders;constructor(r,e={}){this.baseUrl=r,this.defaultHeaders=e}buildUrl(r){return`${this.baseUrl.replace(/\/$/,"")}/${r.replace(/^\//,"")}`}async request(r,e,t,i={}){let s=this.buildUrl(e),o=await fetch(s,{method:r,headers:{"Content-Type":"application/json",...this.defaultHeaders,...i},body:t?JSON.stringify(t):void 0});if(!o.ok){let u=await o.text().catch(()=>"");throw new Error(`HTTP ${o.status} ${o.statusText}: ${u||"Request failed"}`)}let n=await o.text();try{return JSON.parse(n)}catch{return n}}get(r,e){return this.request("GET",r,void 0,e)}post(r,e,t){return this.request("POST",r,e,t)}put(r,e,t){return this.request("PUT",r,e,t)}delete(r,e){return this.request("DELETE",r,void 0,e)}},cs=class{api;apiToken;constructor(r){this.apiToken=r?.apiToken,this.api=new as("https://api.derived.dev/api",{...this.apiToken?{Authorization:this.apiToken}:{}})}fetchBlock=async r=>this.api.get(`/public/v1/template-group/code/${r}`);getBlockInputFromUserQuery=(r,e)=>this.api.post("/public/v1/template-group/get-block-input-from-user-query",{blockInput:r,query:e});resolveMultipleTemplates=(r,e)=>this.api.post("/public/v1/template-group/resolve-multiple-templates-by-block-code",{blockCode:r,data:e});searchBlocksByName=(r,e)=>this.api.get(`/public/v1/template-group/semantic-search?q=${r}&limit=5&threshold=0.5&project_id=${e}`);fetchProjectBySlug=async r=>this.api.get(`/public/v1/project/detail-by-slug/${r}`);createMultipleTemplates=async r=>this.api.post("/v1/template/create-multiple",r);createTemplateGroup=async r=>this.api.post("/v1/template-group/create",r);getProjectCategories=async(r,e=20,t=1)=>{let i=encodeURIComponent(JSON.stringify({projectID:r})),s=encodeURIComponent(JSON.stringify({Desc:"id"}));return this.api.get(`/v1/block-category/list?filters=${i}&sort=${s}&limit=${e}&page=${t}`)};createCategory=async r=>this.api.post("/v1/block-category/create",r);updateTemplateGroup=async(r,e)=>this.api.put(`/v1/template-group/update/${r}`,e)},ls=cs});var In={};sr(In,{isDirectoryEmpty:()=>Ws,removeGitDirectory:()=>Ls});function Ws(r){return(0,le.existsSync)(r)?(0,le.readdirSync)(r).filter(i=>!i.startsWith(".")).length===0:!0}function Ls(r){let e=(0,Pn.join)(r,".git");(0,le.existsSync)(e)&&(0,le.rmSync)(e,{recursive:!0,force:!0})}var le,Pn,Nn=Yn(()=>{"use strict";le=require("fs"),Pn=require("path")});var Qs={};sr(Qs,{displayFileTree:()=>Hn});module.exports=Qn(Qs);var Fr=b(Cr(),1),{program:oo,createCommand:uo,createArgument:ao,createOption:co,CommanderError:lo,InvalidArgumentError:Do,InvalidOptionArgumentError:po,Command:yr,Argument:ho,Option:mo,Help:fo}=Fr.default;var Pe=require("node:util");var S=b(Ct(),1),pe=require("node:process"),te=b(require("node:readline"),1),bt=b(require("node:readline"),1),kr=require("node:stream"),jr=b(Be(),1);function Fi({onlyFirst:r=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,r?void 0:"g")}var yi=Fi();function Tr(r){if(typeof r!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof r}\``);return r.replace(yi,"")}function Pr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ir={exports:{}};(function(r){var e={};r.exports=e,e.eastAsianWidth=function(i){var s=i.charCodeAt(0),o=i.length==2?i.charCodeAt(1):0,n=s;return 55296<=s&&s<=56319&&56320<=o&&o<=57343&&(s&=1023,o&=1023,n=s<<10|o,n+=65536),n==12288||65281<=n&&n<=65376||65504<=n&&n<=65510?"F":n==8361||65377<=n&&n<=65470||65474<=n&&n<=65479||65482<=n&&n<=65487||65490<=n&&n<=65495||65498<=n&&n<=65500||65512<=n&&n<=65518?"H":4352<=n&&n<=4447||4515<=n&&n<=4519||4602<=n&&n<=4607||9001<=n&&n<=9002||11904<=n&&n<=11929||11931<=n&&n<=12019||12032<=n&&n<=12245||12272<=n&&n<=12283||12289<=n&&n<=12350||12353<=n&&n<=12438||12441<=n&&n<=12543||12549<=n&&n<=12589||12593<=n&&n<=12686||12688<=n&&n<=12730||12736<=n&&n<=12771||12784<=n&&n<=12830||12832<=n&&n<=12871||12880<=n&&n<=13054||13056<=n&&n<=19903||19968<=n&&n<=42124||42128<=n&&n<=42182||43360<=n&&n<=43388||44032<=n&&n<=55203||55216<=n&&n<=55238||55243<=n&&n<=55291||63744<=n&&n<=64255||65040<=n&&n<=65049||65072<=n&&n<=65106||65108<=n&&n<=65126||65128<=n&&n<=65131||110592<=n&&n<=110593||127488<=n&&n<=127490||127504<=n&&n<=127546||127552<=n&&n<=127560||127568<=n&&n<=127569||131072<=n&&n<=194367||177984<=n&&n<=196605||196608<=n&&n<=262141?"W":32<=n&&n<=126||162<=n&&n<=163||165<=n&&n<=166||n==172||n==175||10214<=n&&n<=10221||10629<=n&&n<=10630?"Na":n==161||n==164||167<=n&&n<=168||n==170||173<=n&&n<=174||176<=n&&n<=180||182<=n&&n<=186||188<=n&&n<=191||n==198||n==208||215<=n&&n<=216||222<=n&&n<=225||n==230||232<=n&&n<=234||236<=n&&n<=237||n==240||242<=n&&n<=243||247<=n&&n<=250||n==252||n==254||n==257||n==273||n==275||n==283||294<=n&&n<=295||n==299||305<=n&&n<=307||n==312||319<=n&&n<=322||n==324||328<=n&&n<=331||n==333||338<=n&&n<=339||358<=n&&n<=359||n==363||n==462||n==464||n==466||n==468||n==470||n==472||n==474||n==476||n==593||n==609||n==708||n==711||713<=n&&n<=715||n==717||n==720||728<=n&&n<=731||n==733||n==735||768<=n&&n<=879||913<=n&&n<=929||931<=n&&n<=937||945<=n&&n<=961||963<=n&&n<=969||n==1025||1040<=n&&n<=1103||n==1105||n==8208||8211<=n&&n<=8214||8216<=n&&n<=8217||8220<=n&&n<=8221||8224<=n&&n<=8226||8228<=n&&n<=8231||n==8240||8242<=n&&n<=8243||n==8245||n==8251||n==8254||n==8308||n==8319||8321<=n&&n<=8324||n==8364||n==8451||n==8453||n==8457||n==8467||n==8470||8481<=n&&n<=8482||n==8486||n==8491||8531<=n&&n<=8532||8539<=n&&n<=8542||8544<=n&&n<=8555||8560<=n&&n<=8569||n==8585||8592<=n&&n<=8601||8632<=n&&n<=8633||n==8658||n==8660||n==8679||n==8704||8706<=n&&n<=8707||8711<=n&&n<=8712||n==8715||n==8719||n==8721||n==8725||n==8730||8733<=n&&n<=8736||n==8739||n==8741||8743<=n&&n<=8748||n==8750||8756<=n&&n<=8759||8764<=n&&n<=8765||n==8776||n==8780||n==8786||8800<=n&&n<=8801||8804<=n&&n<=8807||8810<=n&&n<=8811||8814<=n&&n<=8815||8834<=n&&n<=8835||8838<=n&&n<=8839||n==8853||n==8857||n==8869||n==8895||n==8978||9312<=n&&n<=9449||9451<=n&&n<=9547||9552<=n&&n<=9587||9600<=n&&n<=9615||9618<=n&&n<=9621||9632<=n&&n<=9633||9635<=n&&n<=9641||9650<=n&&n<=9651||9654<=n&&n<=9655||9660<=n&&n<=9661||9664<=n&&n<=9665||9670<=n&&n<=9672||n==9675||9678<=n&&n<=9681||9698<=n&&n<=9701||n==9711||9733<=n&&n<=9734||n==9737||9742<=n&&n<=9743||9748<=n&&n<=9749||n==9756||n==9758||n==9792||n==9794||9824<=n&&n<=9825||9827<=n&&n<=9829||9831<=n&&n<=9834||9836<=n&&n<=9837||n==9839||9886<=n&&n<=9887||9918<=n&&n<=9919||9924<=n&&n<=9933||9935<=n&&n<=9953||n==9955||9960<=n&&n<=9983||n==10045||n==10071||10102<=n&&n<=10111||11093<=n&&n<=11097||12872<=n&&n<=12879||57344<=n&&n<=63743||65024<=n&&n<=65039||n==65533||127232<=n&&n<=127242||127248<=n&&n<=127277||127280<=n&&n<=127337||127344<=n&&n<=127386||917760<=n&&n<=917999||983040<=n&&n<=1048573||1048576<=n&&n<=1114109?"A":"N"},e.characterLength=function(i){var s=this.eastAsianWidth(i);return s=="F"||s=="W"||s=="A"?2:1};function t(i){return i.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}e.length=function(i){for(var s=t(i),o=0,n=0;n<s.length;n++)o=o+this.characterLength(s[n]);return o},e.slice=function(i,s,o){textLen=e.length(i),s=s||0,o=o||1,s<0&&(s=textLen+s),o<0&&(o=textLen+o);for(var n="",u=0,a=t(i),c=0;c<a.length;c++){var l=a[c],D=e.length(l);if(u>=s-(D==2?1:0))if(u+D<=o)n+=l;else break;u+=D}return n}})(Ir);var Ei=Ir.exports,bi=Pr(Ei),vi=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},$i=Pr(vi);function ge(r,e={}){if(typeof r!="string"||r.length===0||(e={ambiguousIsNarrow:!0,...e},r=Tr(r),r.length===0))return 0;r=r.replace($i()," ");let t=e.ambiguousIsNarrow?1:2,i=0;for(let s of r){let o=s.codePointAt(0);if(!(o<=31||o>=127&&o<=159||o>=768&&o<=879))switch(bi.eastAsianWidth(s)){case"F":case"W":i+=2;break;case"A":i+=t;break;default:i+=1}}return i}var yt=10,$r=(r=0)=>e=>`\x1B[${e+r}m`,wr=(r=0)=>e=>`\x1B[${38+r};5;${e}m`,Ar=(r=0)=>(e,t,i)=>`\x1B[${38+r};2;${e};${t};${i}m`,v={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(v.modifier);var wi=Object.keys(v.color),Ai=Object.keys(v.bgColor);[...wi,...Ai];function xi(){let r=new Map;for(let[e,t]of Object.entries(v)){for(let[i,s]of Object.entries(t))v[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},t[i]=v[i],r.set(s[0],s[1]);Object.defineProperty(v,e,{value:t,enumerable:!1})}return Object.defineProperty(v,"codes",{value:r,enumerable:!1}),v.color.close="\x1B[39m",v.bgColor.close="\x1B[49m",v.color.ansi=$r(),v.color.ansi256=wr(),v.color.ansi16m=Ar(),v.bgColor.ansi=$r(yt),v.bgColor.ansi256=wr(yt),v.bgColor.ansi16m=Ar(yt),Object.defineProperties(v,{rgbToAnsi256:{value:(e,t,i)=>e===t&&t===i?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[i]=t;i.length===3&&(i=[...i].map(o=>o+o).join(""));let s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:e=>v.rgbToAnsi256(...v.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,i,s;if(e>=232)t=((e-232)*10+8)/255,i=t,s=t;else{e-=16;let u=e%36;t=Math.floor(e/36)/5,i=Math.floor(u/6)/5,s=u%6/5}let o=Math.max(t,i,s)*2;if(o===0)return 30;let n=30+(Math.round(s)<<2|Math.round(i)<<1|Math.round(t));return o===2&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(e,t,i)=>v.ansi256ToAnsi(v.rgbToAnsi256(e,t,i)),enumerable:!1},hexToAnsi:{value:e=>v.ansi256ToAnsi(v.hexToAnsi256(e)),enumerable:!1}}),v}var Bi=xi(),Te=new Set(["\x1B","\x9B"]),_i=39,$t="\x07",Nr="[",Oi="]",Rr="m",wt=`${Oi}8;;`,xr=r=>`${Te.values().next().value}${Nr}${r}${Rr}`,Br=r=>`${Te.values().next().value}${wt}${r}${$t}`,Si=r=>r.split(" ").map(e=>ge(e)),Et=(r,e,t)=>{let i=[...e],s=!1,o=!1,n=ge(Tr(r[r.length-1]));for(let[u,a]of i.entries()){let c=ge(a);if(n+c<=t?r[r.length-1]+=a:(r.push(a),n=0),Te.has(a)&&(s=!0,o=i.slice(u+1).join("").startsWith(wt)),s){o?a===$t&&(s=!1,o=!1):a===Rr&&(s=!1);continue}n+=c,n===t&&u<i.length-1&&(r.push(""),n=0)}!n&&r[r.length-1].length>0&&r.length>1&&(r[r.length-2]+=r.pop())},ki=r=>{let e=r.split(" "),t=e.length;for(;t>0&&!(ge(e[t-1])>0);)t--;return t===e.length?r:e.slice(0,t).join(" ")+e.slice(t).join("")},ji=(r,e,t={})=>{if(t.trim!==!1&&r.trim()==="")return"";let i="",s,o,n=Si(r),u=[""];for(let[c,l]of r.split(" ").entries()){t.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let D=ge(u[u.length-1]);if(c!==0&&(D>=e&&(t.wordWrap===!1||t.trim===!1)&&(u.push(""),D=0),(D>0||t.trim===!1)&&(u[u.length-1]+=" ",D++)),t.hard&&n[c]>e){let h=e-D,E=1+Math.floor((n[c]-h-1)/e);Math.floor((n[c]-1)/e)<E&&u.push(""),Et(u,l,e);continue}if(D+n[c]>e&&D>0&&n[c]>0){if(t.wordWrap===!1&&D<e){Et(u,l,e);continue}u.push("")}if(D+n[c]>e&&t.wordWrap===!1){Et(u,l,e);continue}u[u.length-1]+=l}t.trim!==!1&&(u=u.map(c=>ki(c)));let a=[...u.join(`
|
|
28
|
+
`)];for(let[c,l]of a.entries()){if(i+=l,Te.has(l)){let{groups:h}=new RegExp(`(?:\\${Nr}(?<code>\\d+)m|\\${wt}(?<uri>.*)${$t})`).exec(a.slice(c).join(""))||{groups:{}};if(h.code!==void 0){let E=Number.parseFloat(h.code);s=E===_i?void 0:E}else h.uri!==void 0&&(o=h.uri.length===0?void 0:h.uri)}let D=Bi.codes.get(Number(s));a[c+1]===`
|
|
29
|
+
`?(o&&(i+=Br("")),s&&D&&(i+=xr(D))):l===`
|
|
30
|
+
`&&(s&&D&&(i+=xr(s)),o&&(i+=Br(o)))}return i};function _r(r,e,t){return String(r).normalize().replace(/\r\n/g,`
|
|
31
31
|
`).split(`
|
|
32
|
-
`).map(
|
|
33
|
-
`)}var
|
|
34
|
-
`),
|
|
35
|
-
`),s=[];for(let
|
|
36
|
-
`),
|
|
37
|
-
`).length-1;this.output.write(
|
|
38
|
-
`);this.output.write(s[
|
|
39
|
-
`).slice(
|
|
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`${
|
|
51
|
-
${
|
|
52
|
-
${
|
|
53
|
-
`}}}).prompt()},
|
|
54
|
-
${
|
|
55
|
-
`;switch(this.state){case"submit":return`${t}${
|
|
56
|
-
${
|
|
57
|
-
${
|
|
58
|
-
${
|
|
59
|
-
`}}}).prompt()};var
|
|
60
|
-
${
|
|
61
|
-
${
|
|
62
|
-
`,
|
|
63
|
-
${
|
|
64
|
-
`).map((
|
|
65
|
-
`);return`${t+
|
|
66
|
-
${
|
|
32
|
+
`).map(i=>ji(i,e,t)).join(`
|
|
33
|
+
`)}var Ti=["up","down","left","right","space","enter","cancel"],Oe={actions:new Set(Ti),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]])};function At(r,e){if(typeof r=="string")return Oe.aliases.get(r)===e;for(let t of r)if(t!==void 0&&At(t,e))return!0;return!1}function Pi(r,e){if(r===e)return;let t=r.split(`
|
|
34
|
+
`),i=e.split(`
|
|
35
|
+
`),s=[];for(let o=0;o<Math.max(t.length,i.length);o++)t[o]!==i[o]&&s.push(o);return s}var Ii=globalThis.process.platform.startsWith("win"),vt=Symbol("clack:cancel");function J(r){return r===vt}function _e(r,e){let t=r;t.isTTY&&t.setRawMode(e)}function Mr({input:r=pe.stdin,output:e=pe.stdout,overwrite:t=!0,hideCursor:i=!0}={}){let s=te.createInterface({input:r,output:e,prompt:"",tabSize:1});te.emitKeypressEvents(r,s),r.isTTY&&r.setRawMode(!0);let o=(n,{name:u,sequence:a})=>{let c=String(n);if(At([c,u,a],"cancel")){i&&e.write(S.cursor.show),process.exit(0);return}if(!t)return;te.moveCursor(e,u==="return"?0:-1,u==="return"?-1:0,()=>{te.clearLine(e,1,()=>{r.once("keypress",o)})})};return i&&e.write(S.cursor.hide),r.once("keypress",o),()=>{r.off("keypress",o),i&&e.write(S.cursor.show),r.isTTY&&!Ii&&r.setRawMode(!1),s.terminal=!1,s.close()}}var Ni=Object.defineProperty,Ri=(r,e,t)=>e in r?Ni(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,P=(r,e,t)=>(Ri(r,typeof e!="symbol"?e+"":e,t),t),de=class{constructor(e,t=!0){P(this,"input"),P(this,"output"),P(this,"_abortSignal"),P(this,"rl"),P(this,"opts"),P(this,"_render"),P(this,"_track",!1),P(this,"_prevFrame",""),P(this,"_subscribers",new Map),P(this,"_cursor",0),P(this,"state","initial"),P(this,"error",""),P(this,"value");let{input:i=pe.stdin,output:s=pe.stdout,render:o,signal:n,...u}=e;this.opts=u,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=o.bind(this),this._track=t,this._abortSignal=n,this.input=i,this.output=s}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let i=this._subscribers.get(e)??[];i.push(t),this._subscribers.set(e,i)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let i=this._subscribers.get(e)??[],s=[];for(let o of i)o.cb(...t),o.once&&s.push(()=>i.splice(i.indexOf(o),1));for(let o of s)o()}prompt(){return new Promise((e,t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(vt);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let i=new kr.Writable;i._write=(s,o,n)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),n()},this.input.pipe(i),this.rl=bt.default.createInterface({input:this.input,output:i,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),bt.default.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),_e(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(S.cursor.show),this.output.off("resize",this.render),_e(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(S.cursor.show),this.output.off("resize",this.render),_e(this.input,!1),e(vt)})})}onKeypress(e,t){if(this.state==="error"&&(this.state="active"),t?.name&&(!this._track&&Oe.aliases.has(t.name)&&this.emit("cursor",Oe.aliases.get(t.name)),Oe.actions.has(t.name)&&this.emit("cursor",t.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),e===" "&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),e&&this.emit("key",e.toLowerCase()),t?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i instanceof Error?i.message:i,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}At([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
36
|
+
`),_e(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=_r(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
37
|
+
`).length-1;this.output.write(S.cursor.move(-999,e*-1))}render(){let e=_r(this._render(this)??"",process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(S.cursor.hide);else{let t=Pi(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let i=t[0];this.output.write(S.cursor.move(0,i)),this.output.write(S.erase.lines(1));let s=e.split(`
|
|
38
|
+
`);this.output.write(s[i]),this._prevFrame=e,this.output.write(S.cursor.move(0,s.length-i-1));return}if(t&&t?.length>1){let i=t[0];this.output.write(S.cursor.move(0,i)),this.output.write(S.erase.down());let s=e.split(`
|
|
39
|
+
`).slice(i);this.output.write(s.join(`
|
|
40
|
+
`)),this._prevFrame=e;return}this.output.write(S.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}},Se=class extends de{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",t=>{this.output.write(S.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var Mi;Mi=new WeakMap;var Vi=Object.defineProperty,Gi=(r,e,t)=>e in r?Vi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Or=(r,e,t)=>(Gi(r,typeof e!="symbol"?e+"":e,t),t),Vr=class extends de{constructor(r){super(r,!1),Or(this,"options"),Or(this,"cursor",0),this.options=r.options,this.value=[...r.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===r.cursorAt),0),this.on("key",e=>{e==="a"&&this.toggleAll()}),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let r=this.value.length===this.options.length;this.value=r?[]:this.options.map(e=>e.value)}toggleValue(){let r=this.value.includes(this._value);this.value=r?this.value.filter(e=>e!==this._value):[...this.value,this._value]}};var Hi=Object.defineProperty,Wi=(r,e,t)=>e in r?Hi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Sr=(r,e,t)=>(Wi(r,typeof e!="symbol"?e+"":e,t),t),ke=class extends de{constructor(e){super(e,!1),Sr(this,"options"),Sr(this,"cursor",0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",t=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};var je=class extends de{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let e=this.value.slice(0,this.cursor),[t,...i]=this.value.slice(this.cursor);return`${e}${jr.default.inverse(t)}${i.join("")}`}get cursor(){return this._cursor}constructor(e){super(e),this.on("finalize",()=>{this.value||(this.value=e.defaultValue)})}};var M=b(require("node:process"),1),p=b(Be(),1),Ie=b(Ct(),1);function Li(){return M.default.platform!=="win32"?M.default.env.TERM!=="linux":!!M.default.env.CI||!!M.default.env.WT_SESSION||!!M.default.env.TERMINUS_SUBLIME||M.default.env.ConEmuTask==="{cmd::Cmder}"||M.default.env.TERM_PROGRAM==="Terminus-Sublime"||M.default.env.TERM_PROGRAM==="vscode"||M.default.env.TERM==="xterm-256color"||M.default.env.TERM==="alacritty"||M.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var xt=Li(),x=(r,e)=>xt?r:e,qi=x("\u25C6","*"),Wr=x("\u25A0","x"),Lr=x("\u25B2","x"),Ne=x("\u25C7","o"),Ji=x("\u250C","T"),f=x("\u2502","|"),re=x("\u2514","\u2014"),Bt=x("\u25CF",">"),_t=x("\u25CB"," "),Ui=x("\u25FB","[\u2022]"),Gr=x("\u25FC","[+]"),Ki=x("\u25FB","[ ]"),xo=x("\u25AA","\u2022"),Hr=x("\u2500","-"),zi=x("\u256E","+"),Yi=x("\u251C","+"),Qi=x("\u256F","+"),Zi=x("\u25CF","\u2022"),Xi=x("\u25C6","*"),es=x("\u25B2","!"),ts=x("\u25A0","x"),Re=r=>{switch(r){case"initial":case"active":return p.default.cyan(qi);case"cancel":return p.default.red(Wr);case"error":return p.default.yellow(Lr);case"submit":return p.default.green(Ne)}},Ot=r=>{let{cursor:e,options:t,style:i}=r,s=r.maxItems??Number.POSITIVE_INFINITY,o=Math.max(process.stdout.rows-4,0),n=Math.min(o,Math.max(s,5)),u=0;e>=u+n-3?u=Math.max(Math.min(e-n+3,t.length-n),0):e<u+2&&(u=Math.max(e-2,0));let a=n<t.length&&u>0,c=n<t.length&&u+n<t.length;return t.slice(u,u+n).map((l,D,h)=>{let E=D===0&&a,B=D===h.length-1&&c;return E||B?p.default.dim("..."):i(l,D+u===e)})},St=r=>new je({validate:r.validate,placeholder:r.placeholder,defaultValue:r.defaultValue,initialValue:r.initialValue,render(){let e=`${p.default.gray(f)}
|
|
41
|
+
${Re(this.state)} ${r.message}
|
|
42
|
+
`,t=r.placeholder?p.default.inverse(r.placeholder[0])+p.default.dim(r.placeholder.slice(1)):p.default.inverse(p.default.hidden("_")),i=this.value?this.valueWithCursor:t;switch(this.state){case"error":return`${e.trim()}
|
|
43
|
+
${p.default.yellow(f)} ${i}
|
|
44
|
+
${p.default.yellow(re)} ${p.default.yellow(this.error)}
|
|
45
|
+
`;case"submit":return`${e}${p.default.gray(f)} ${p.default.dim(this.value||r.placeholder)}`;case"cancel":return`${e}${p.default.gray(f)} ${p.default.strikethrough(p.default.dim(this.value??""))}${this.value?.trim()?`
|
|
46
|
+
${p.default.gray(f)}`:""}`;default:return`${e}${p.default.cyan(f)} ${i}
|
|
47
|
+
${p.default.cyan(re)}
|
|
48
|
+
`}}}).prompt();var qr=r=>{let e=r.active??"Yes",t=r.inactive??"No";return new Se({active:e,inactive:t,initialValue:r.initialValue??!0,render(){let i=`${p.default.gray(f)}
|
|
49
|
+
${Re(this.state)} ${r.message}
|
|
50
|
+
`,s=this.value?e:t;switch(this.state){case"submit":return`${i}${p.default.gray(f)} ${p.default.dim(s)}`;case"cancel":return`${i}${p.default.gray(f)} ${p.default.strikethrough(p.default.dim(s))}
|
|
51
|
+
${p.default.gray(f)}`;default:return`${i}${p.default.cyan(f)} ${this.value?`${p.default.green(Bt)} ${e}`:`${p.default.dim(_t)} ${p.default.dim(e)}`} ${p.default.dim("/")} ${this.value?`${p.default.dim(_t)} ${p.default.dim(t)}`:`${p.default.green(Bt)} ${t}`}
|
|
52
|
+
${p.default.cyan(re)}
|
|
53
|
+
`}}}).prompt()},Ce=r=>{let e=(t,i)=>{let s=t.label??String(t.value);switch(i){case"selected":return`${p.default.dim(s)}`;case"active":return`${p.default.green(Bt)} ${s} ${t.hint?p.default.dim(`(${t.hint})`):""}`;case"cancelled":return`${p.default.strikethrough(p.default.dim(s))}`;default:return`${p.default.dim(_t)} ${p.default.dim(s)}`}};return new ke({options:r.options,initialValue:r.initialValue,render(){let t=`${p.default.gray(f)}
|
|
54
|
+
${Re(this.state)} ${r.message}
|
|
55
|
+
`;switch(this.state){case"submit":return`${t}${p.default.gray(f)} ${e(this.options[this.cursor],"selected")}`;case"cancel":return`${t}${p.default.gray(f)} ${e(this.options[this.cursor],"cancelled")}
|
|
56
|
+
${p.default.gray(f)}`;default:return`${t}${p.default.cyan(f)} ${Ot({cursor:this.cursor,options:this.options,maxItems:r.maxItems,style:(i,s)=>e(i,s?"active":"inactive")}).join(`
|
|
57
|
+
${p.default.cyan(f)} `)}
|
|
58
|
+
${p.default.cyan(re)}
|
|
59
|
+
`}}}).prompt()};var Jr=r=>{let e=(t,i)=>{let s=t.label??String(t.value);return i==="active"?`${p.default.cyan(Ui)} ${s} ${t.hint?p.default.dim(`(${t.hint})`):""}`:i==="selected"?`${p.default.green(Gr)} ${p.default.dim(s)} ${t.hint?p.default.dim(`(${t.hint})`):""}`:i==="cancelled"?`${p.default.strikethrough(p.default.dim(s))}`:i==="active-selected"?`${p.default.green(Gr)} ${s} ${t.hint?p.default.dim(`(${t.hint})`):""}`:i==="submitted"?`${p.default.dim(s)}`:`${p.default.dim(Ki)} ${p.default.dim(s)}`};return new Vr({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(t){if(this.required&&t.length===0)return`Please select at least one option.
|
|
60
|
+
${p.default.reset(p.default.dim(`Press ${p.default.gray(p.default.bgWhite(p.default.inverse(" space ")))} to select, ${p.default.gray(p.default.bgWhite(p.default.inverse(" enter ")))} to submit`))}`},render(){let t=`${p.default.gray(f)}
|
|
61
|
+
${Re(this.state)} ${r.message}
|
|
62
|
+
`,i=(s,o)=>{let n=this.value.includes(s.value);return o&&n?e(s,"active-selected"):n?e(s,"selected"):e(s,o?"active":"inactive")};switch(this.state){case"submit":return`${t}${p.default.gray(f)} ${this.options.filter(({value:s})=>this.value.includes(s)).map(s=>e(s,"submitted")).join(p.default.dim(", "))||p.default.dim("none")}`;case"cancel":{let s=this.options.filter(({value:o})=>this.value.includes(o)).map(o=>e(o,"cancelled")).join(p.default.dim(", "));return`${t}${p.default.gray(f)} ${s.trim()?`${s}
|
|
63
|
+
${p.default.gray(f)}`:""}`}case"error":{let s=this.error.split(`
|
|
64
|
+
`).map((o,n)=>n===0?`${p.default.yellow(re)} ${p.default.yellow(o)}`:` ${o}`).join(`
|
|
65
|
+
`);return`${t+p.default.yellow(f)} ${Ot({options:this.options,cursor:this.cursor,maxItems:r.maxItems,style:i}).join(`
|
|
66
|
+
${p.default.yellow(f)} `)}
|
|
67
67
|
${s}
|
|
68
|
-
`}default:return`${t}${
|
|
69
|
-
${
|
|
70
|
-
${
|
|
71
|
-
`}}}).prompt()};var
|
|
72
|
-
${
|
|
68
|
+
`}default:return`${t}${p.default.cyan(f)} ${Ot({options:this.options,cursor:this.cursor,maxItems:r.maxItems,style:i}).join(`
|
|
69
|
+
${p.default.cyan(f)} `)}
|
|
70
|
+
${p.default.cyan(re)}
|
|
71
|
+
`}}}).prompt()};var kt=(r="",e="")=>{let t=`
|
|
72
|
+
${r}
|
|
73
73
|
`.split(`
|
|
74
|
-
`),
|
|
75
|
-
`);process.stdout.write(`${
|
|
76
|
-
${
|
|
77
|
-
${
|
|
78
|
-
${
|
|
79
|
-
`)},
|
|
80
|
-
|
|
81
|
-
`)},
|
|
82
|
-
`)},
|
|
83
|
-
${
|
|
84
|
-
|
|
85
|
-
`)},
|
|
86
|
-
`);t.push(`${e} ${
|
|
74
|
+
`),i=(0,Pe.stripVTControlCharacters)(e).length,s=Math.max(t.reduce((n,u)=>{let a=(0,Pe.stripVTControlCharacters)(u);return a.length>n?a.length:n},0),i)+2,o=t.map(n=>`${p.default.gray(f)} ${p.default.dim(n)}${" ".repeat(s-(0,Pe.stripVTControlCharacters)(n).length)}${p.default.gray(f)}`).join(`
|
|
75
|
+
`);process.stdout.write(`${p.default.gray(f)}
|
|
76
|
+
${p.default.green(Ne)} ${p.default.reset(e)} ${p.default.gray(Hr.repeat(Math.max(s-i-1,1))+zi)}
|
|
77
|
+
${o}
|
|
78
|
+
${p.default.gray(Yi+Hr.repeat(s+2)+Qi)}
|
|
79
|
+
`)},jt=(r="")=>{process.stdout.write(`${p.default.gray(re)} ${p.default.red(r)}
|
|
80
|
+
|
|
81
|
+
`)},Ur=(r="")=>{process.stdout.write(`${p.default.gray(Ji)} ${r}
|
|
82
|
+
`)},Kr=(r="")=>{process.stdout.write(`${p.default.gray(f)}
|
|
83
|
+
${p.default.gray(re)} ${r}
|
|
84
|
+
|
|
85
|
+
`)},U={message:(r="",{symbol:e=p.default.gray(f)}={})=>{let t=[`${p.default.gray(f)}`];if(r){let[i,...s]=r.split(`
|
|
86
|
+
`);t.push(`${e} ${i}`,...s.map(o=>`${p.default.gray(f)} ${o}`))}process.stdout.write(`${t.join(`
|
|
87
87
|
`)}
|
|
88
|
-
`)},info:
|
|
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(i.children&&i.children.length>0){let a=e+(t?" ":"\u2502 ");i.children.forEach((D,l)=>{o+=Ae(D,a,l===i.children.length-1,!1)})}return o}var V=require("fs"),Ft=require("path"),On=".derived",Sn="blocks.json";function Sr(){return(0,Ft.join)(process.cwd(),On)}function kr(){return(0,Ft.join)(Sr(),Sn)}function Et(i,e){if(i===e)return!0;if(i==null||e==null)return i===e;if(typeof i!=typeof e)return!1;if(typeof i!="object")return i===e;let t=Object.keys(i),n=Object.keys(e);if(t.length!==n.length)return!1;for(let s of t)if(!n.includes(s)||!Et(i[s],e[s]))return!1;return!0}function Be(){let i=kr();if(!(0,V.existsSync)(i))return{addedBlocks:[]};try{let e=(0,V.readFileSync)(i,"utf-8"),t=JSON.parse(e);return Array.isArray(t.addedBlocks)?t.addedBlocks.length>0&&typeof t.addedBlocks[0]=="string"?{addedBlocks:t.addedBlocks.map(n=>({code:n,input:{}}))}:t:{addedBlocks:[]}}catch{return{addedBlocks:[]}}}function kn(i){let e=Sr(),t=kr();(0,V.existsSync)(e)||(0,V.mkdirSync)(e,{recursive:!0}),(0,V.writeFileSync)(t,JSON.stringify(i,null,2))}function Tr(i){return Be().addedBlocks.some(t=>t.code===i)}function yt(i,e){return Be().addedBlocks.find(s=>s.code===i&&Et(s.input,e))||null}function jr(i,e){return Be().addedBlocks.filter(n=>n.code===i&&!Et(n.input,e))}function Pr(i,e={}){let t=Be();yt(i,e)||(t.addedBlocks.push({code:i,input:e}),kn(t))}var J=require("child_process");function Nr(i){return e=>e.length>1?[i,"run",e[0],"--",...e.slice(1)]:[i,"run",e[0]]}function Tn(){return i=>["deno","run",`npm:${i[0]}`,...i.slice(1)]}var jn={agent:["npm",0],run:Nr("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]},Mr={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]},Pn={...Mr,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]},Ir={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]},In={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]},Nn={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:Tn(),"execute-local":["deno","task","--eval",0],uninstall:["deno","remove",0],global_uninstall:["deno","uninstall","-g",0]},Vr={npm:jn,yarn:Mr,"yarn@berry":Pn,pnpm:Ir,"pnpm@6":{...Ir,run:Nr("pnpm")},bun:In,deno:Nn};function bt(i,e,t){let n=Vr[i][e];return Hr(n,t)}function Hr(i,e){if(i==null)return null;let t=typeof i=="function"?i(e):i.flatMap(n=>typeof n=="number"?e:[n]);return{command:t[0],args:t.slice(1)}}var Rr=["npm","yarn","yarn@berry","pnpm","pnpm@6","bun","deno"],vt={"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 Oe=g(require("node:fs"),1),U=g(require("node:path"),1),Jr=g(require("node:process"),1);var Gr=Symbol.for("quansync.getIsAsync"),_e=class extends Error{constructor(e="Unexpected promise in sync context"){super(e),this.name="QuansyncError"}};function wt(i){return i&&typeof i=="object"&&typeof i.then=="function"}function Mn(i){return i&&typeof i=="object"&&typeof i[Symbol.iterator]=="function"&&"__quansync"in i}function At(i){let e=function*(...n){return(yield Gr)?yield i.async.apply(this,n):i.sync.apply(this,n)};function t(...n){let s=e.apply(this,n);return s.then=(...u)=>i.async.apply(this,n).then(...u),s.__quansync=!0,s}return t.sync=i.sync,t.async=i.async,t}function Vn(i){return At({async:()=>Promise.resolve(i),sync:()=>{if(wt(i))throw new _e;return i}})}function $t(i,e){if(i===Gr)return e;if(Mn(i))return e?Lr(i):qr(i);if(!e&&wt(i))throw new _e;return i}var Wr=i=>i;function qr(i,e=Wr){let t=i.next();for(;!t.done;)try{t=i.next($t(e(t.value,!1)))}catch(n){t=i.throw(n)}return $t(t.value)}async function Lr(i,e=Wr){let t=i.next();for(;!t.done;)try{t=i.next(await $t(e(t.value,!0),!0))}catch(n){t=i.throw(n)}return t.value}function Hn(i,e){return At({name:i.name,async(...t){return Lr(i.apply(this,t),e?.onYield)},sync(...t){return qr(i.apply(this,t),e?.onYield)}})}function Bt(i,e){return wt(i)?Vn(i):typeof i=="function"?Hn(i,e):At(i)}var Ls=Bt({async:()=>Promise.resolve(!0),sync:()=>!1});var xe=Bt;var zr=xe({sync:i=>{try{return Oe.default.statSync(i).isFile()}catch{return!1}},async:async i=>{try{return(await Oe.default.promises.stat(i)).isFile()}catch{return!1}}});function*Rn(i=Jr.default.cwd()){let e=U.default.resolve(i),{root:t}=U.default.parse(e);for(;e&&e!==t;)yield e,e=U.default.dirname(e)}var Ur=xe(function*(i,e){return!i||!(yield zr(i))?null:Wn(i,e)}),Se=xe(function*(i={}){let{cwd:e,onUnknown:t}=i;for(let n of Rn(e)){for(let u of Object.keys(vt))if(yield zr(U.default.join(n,u))){let r=vt[u],o=yield Ur(U.default.join(n,"package.json"),t);return o||{name:r,agent:r}}let s=yield Ur(U.default.join(n,"package.json"),t);if(s)return s}return null}),Gn=Se.sync;function Wn(i,e){try{let t=JSON.parse(Oe.default.readFileSync(i,"utf8")),n;if(typeof t.packageManager=="string"){let[s,u]=t.packageManager.replace(/^\^/,"").split("@"),r=u;return s==="yarn"&&Number.parseInt(u)>1?(n="yarn@berry",r="berry",{name:s,agent:n,version:r}):s==="pnpm"&&Number.parseInt(u)<7?(n="pnpm@6",{name:s,agent:n,version:r}):Rr.includes(s)?(n=s,{name:s,agent:n,version:r}):e?.(t.packageManager)??null}}catch{}return null}function _t(i){try{return process.platform==="win32"?(0,J.execSync)(`where ${i}`,{stdio:"ignore"}):(0,J.execSync)(`command -v ${i}`,{stdio:"ignore"}),!0}catch{return!1}}function qn(i,e){if(i==="npx"||i==="pnpx"||i==="bunx")return{intent:"execute",args:e};if(i==="yarn"&&e[0]==="dlx")return{intent:"execute",args:e.slice(1)};if(["npm","pnpm","yarn","bun"].includes(i)){let n=e[0]||"",s=e.slice(1);if(!n||["install","i"].includes(n))return{intent:"install",args:s};if(n==="add")return{intent:"add",args:s};if(n==="run")return{intent:"run",args:s};if(["uninstall","remove","rm","un"].includes(n))return{intent:"uninstall",args:s};if(n==="install"&&s.length>0)return{intent:"add",args:s};if(n&&!n.startsWith("-"))return{intent:"run",args:e}}return null}async function ke(i,e={}){let t=i.trim().split(/\s+/),n=t[0]||"",s=t.slice(1),u=qn(n,s);if(u){let o=(await Se({cwd:process.cwd()}))?.agent||"npm",a=bt(o,u.intent,u.args);if(a){let D=`${a.command} ${a.args.join(" ")}`;if(u.intent==="execute"){if(_t("bunx")){let l=`bunx ${u.args.join(" ")}`;return(0,J.execSync)(l,{stdio:"inherit",cwd:process.cwd(),...e})}if(_t("npx")){let l=`npx ${u.args.join(" ")}`;return(0,J.execSync)(l,{stdio:"inherit",cwd:process.cwd(),...e})}}if(_t(a.command))return(0,J.execSync)(D,{stdio:"inherit",cwd:process.cwd(),...e});throw new Error(`Command not found: ${a.command}. Please install the required package manager.`)}}return(0,J.execSync)(i,{stdio:"inherit",cwd:process.cwd(),...e})}var K=g(require("crypto")),A=g(require("fs")),ue=g(require("path")),xt=g(require("os")),Yr="ts-cli-derived",Ln="jwt-token",Te=()=>{let i=xt.homedir();return ue.join(i,`.${Yr}`,`${Ln}.enc`)},Un=()=>{let i=Te(),e=ue.dirname(i);A.existsSync(e)||A.mkdirSync(e,{recursive:!0})},Kr=()=>{let i=ue.join(xt.homedir(),`.${Yr}`,"key");if(!A.existsSync(i)){let e=K.randomBytes(32);return A.writeFileSync(i,e),e}return A.readFileSync(i)},z=class{static async saveToken(e){Un();let t=Kr(),n=K.randomBytes(16),s=K.createCipheriv("aes-256-gcm",t,n),u=Buffer.concat([s.update(e,"utf8"),s.final()]),r=s.getAuthTag(),o={iv:n.toString("hex"),encrypted:u.toString("hex"),authTag:r.toString("hex")};A.writeFileSync(Te(),JSON.stringify(o))}static async getToken(){try{let e=Te();if(!A.existsSync(e))return null;let t=JSON.parse(A.readFileSync(e,"utf8")),n=Kr(),s=Buffer.from(t.iv,"hex"),u=Buffer.from(t.encrypted,"hex"),r=Buffer.from(t.authTag,"hex"),o=K.createDecipheriv("aes-256-gcm",n,s);return o.setAuthTag(r),o.update(u)+o.final("utf8")}catch{return null}}static async deleteToken(){try{let e=Te();return A.existsSync(e)?(A.unlinkSync(e),!0):!1}catch{return!1}}};var N=require("fs"),q=require("path"),Jn=new Set([".git","node_modules"]);function zn(i){if((0,N.existsSync)(i))return(0,q.resolve)(i);if(i.startsWith("/")){let e=(0,q.resolve)(process.cwd(),i.replace(/^\/+/,""));if((0,N.existsSync)(e))return e}return(0,q.resolve)(process.cwd(),i)}function Qr(i){let e=(0,N.readdirSync)(i,{withFileTypes:!0}),t=[];for(let n of e){let s=(0,q.join)(i,n.name);if(n.isDirectory()){if(Jn.has(n.name))continue;t.push(...Qr(s));continue}n.isFile()&&t.push(s)}return t}function Kn(i){let e=(0,q.relative)(process.cwd(),i);return!e||e.startsWith("..")?null:`/${e.replace(/\\/g,"/")}`}function Zr(i){let e=[],t=new Set;for(let r of i){let o=zn(r);if(!(0,N.existsSync)(o)){e.push(`Path does not exist: ${r}`);continue}try{let a=(0,N.lstatSync)(o);if(a.isFile()){t.add(o);continue}if(a.isDirectory()){try{let D=Qr(o);for(let l of D)t.add(l)}catch(D){e.push(`Failed to read directory "${o}": ${D.message}`)}continue}e.push(`Unsupported path type: ${r}`)}catch(a){e.push(`Failed to inspect path "${o}": ${a.message}`)}}let n=[],s=new Set,u=Array.from(t).sort((r,o)=>r.localeCompare(o));for(let r of u){let o=Kn(r);if(!o){e.push(`Path is outside the current project: ${r}`);continue}if(!s.has(o)){s.add(o);try{let a=(0,N.readFileSync)(r,"utf-8");n.push({templatePath:o,template:a})}catch(a){e.push(`Failed to read file "${r}": ${a.message}`)}}}return{files:n,errors:e}}function Yn(){return!process.stdin.isTTY||process.env.CI==="true"||process.env.TERM==="dumb"||process.env.NON_INTERACTIVE==="true"}var B=Yn();function _(){return B?{start:i=>console.log(`[start] ${i}`),stop:i=>console.log(`[done] ${i}`)}:$r()}var d={intro(i){B?console.log(`[intro] ${i}`):br(i)},outro(i){B?console.log(`[outro] ${i}`):vr(i)},note(i,e){B?(e&&console.log(`[note:${e}]`),console.log(i)):dt(i,e)},data(i,e){B?(e&&console.log(`[data:${e}]`),console.log(JSON.stringify(i))):dt(JSON.stringify(i,null,2),e??"Data")},success(i){B?console.log(`[ok] ${i}`):I.success(i)},info(i){B?console.log(`[info] ${i}`):I.info(i)},warn(i){B?console.warn(`[warn] ${i}`):I.warning(i)},fatal(i){B?console.error(`[error] ${i}`):mt(i),process.exit(1)},cancel(i){B?console.log(`[cancel] ${i}`):mt(i),process.exit(0)}};var H=new zt,Q=new oe.default;async function Xn(i){let e=(0,St.join)((0,ni.tmpdir)(),`cli-edit-${Date.now()}.json`);(0,T.writeFileSync)(e,JSON.stringify(i,null,2));let t=process.env.VISUAL||process.env.EDITOR||"nano";return new Promise((n,s)=>{(0,ii.spawn)(t,[e],{stdio:"inherit"}).on("exit",r=>{if(r===0)try{let o=(0,T.readFileSync)(e,"utf-8"),a=JSON.parse(o);(0,T.unlinkSync)(e),n(a)}catch{(0,T.unlinkSync)(e),s(new Error("Invalid JSON format"))}else(0,T.unlinkSync)(e),s(new Error("Editor closed without saving"))})})}async function ri(i,e){let t=_();t.start("Modifying block input...");let n=await Q.getBlockInputFromUserQuery(JSON.stringify(i),e);return t.stop("Block input modified"),d.data(n.result,"Refined Block Input"),n.result}function es(i,e="Block Input"){d.data(i,e)}function si(i,e){return Q.resolveMultipleTemplates(i,e)}async function ui(i,e){let t=await si(i,e),n=t.result.files.map(r=>r.resolvedPath),s=Or(n),u=Ae(s);d.note(u,`Files to be created (${t.result.files.length}):`)}async function je(i,e,t=!1,n){let s=_();s.start("Resolving Files...");let u=await si(i,e),r=u.result.files.filter(l=>{let c=(0,St.join)(process.cwd(),l.resolvedPath);return(0,T.existsSync)(c)&&(0,T.lstatSync)(c).isFile()&&l.templateType==="add"}),o=[],a=t;if(r.length>0&&!t){s.stop(`${r.length} conflicting files detected`),B&&d.fatal(`${r.length} file(s) already exist. Re-run with --overwrite to overwrite all.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
`);d.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
88
|
+
`)},info:r=>{U.message(r,{symbol:p.default.blue(Zi)})},success:r=>{U.message(r,{symbol:p.default.green(Xi)})},step:r=>{U.message(r,{symbol:p.default.green(Ne)})},warn:r=>{U.message(r,{symbol:p.default.yellow(es)})},warning:r=>{U.warn(r)},error:r=>{U.message(r,{symbol:p.default.red(ts)})}},Bo=`${p.default.gray(f)} `;var zr=({indicator:r="dots"}={})=>{let e=xt?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],t=xt?80:120,i=process.env.CI==="true",s,o,n=!1,u="",a,c=performance.now(),l=F=>{let N=F>1?"Something went wrong":"Canceled";n&&C(N,F)},D=()=>l(2),h=()=>l(1),E=()=>{process.on("uncaughtExceptionMonitor",D),process.on("unhandledRejection",D),process.on("SIGINT",h),process.on("SIGTERM",h),process.on("exit",l)},B=()=>{process.removeListener("uncaughtExceptionMonitor",D),process.removeListener("unhandledRejection",D),process.removeListener("SIGINT",h),process.removeListener("SIGTERM",h),process.removeListener("exit",l)},G=()=>{if(a===void 0)return;i&&process.stdout.write(`
|
|
89
|
+
`);let F=a.split(`
|
|
90
|
+
`);process.stdout.write(Ie.cursor.move(-999,F.length-1)),process.stdout.write(Ie.erase.down(F.length))},m=F=>F.replace(/\.+$/,""),y=F=>{let N=(performance.now()-F)/1e3,L=Math.floor(N/60),De=Math.floor(N%60);return L>0?`[${L}m ${De}s]`:`[${De}s]`},W=(F="")=>{n=!0,s=Mr(),u=m(F),c=performance.now(),process.stdout.write(`${p.default.gray(f)}
|
|
91
|
+
`);let N=0,L=0;E(),o=setInterval(()=>{if(i&&u===a)return;G(),a=u;let De=p.default.magenta(e[N]);if(i)process.stdout.write(`${De} ${u}...`);else if(r==="timer")process.stdout.write(`${De} ${u} ${y(c)}`);else{let Ln=".".repeat(Math.floor(L)).slice(0,3);process.stdout.write(`${De} ${u}${Ln}`)}N=N+1<e.length?N+1:0,L=L<e.length?L+.125:0},t)},C=(F="",N=0)=>{n=!1,clearInterval(o),G();let L=N===0?p.default.green(Ne):N===1?p.default.red(Wr):p.default.red(Lr);u=m(F??u),r==="timer"?process.stdout.write(`${L} ${u} ${y(c)}
|
|
92
|
+
`):process.stdout.write(`${L} ${u}
|
|
93
|
+
`),B(),s()};return{start:W,stop:C,message:(F="")=>{u=m(F??u)}}};var Mn=require("node:child_process"),T=require("node:fs"),Vn=require("node:os"),Qe=require("node:path");var he=b(require("fs")),Tt=b(require("path")),Qr=(r,e=[],t=!1)=>{let i=[],s=[],o=[];for(let n of r){let u=Tt.default.join(process.cwd(),n.resolvedPath);if(!n.isNotEnabled)try{if(he.default.mkdirSync(Tt.default.dirname(u),{recursive:!0}),n.templateType==="add"){let a=he.default.existsSync(u)&&he.default.lstatSync(u).isFile(),c=t||e.includes(n.resolvedPath);if(a&&!c){o.push(`File already exists: ${u}`);continue}else{if(n.pathError||n.templateError){o.push(`Failed to create file: ${u} because of error: ${n.templateError}`);continue}he.default.writeFileSync(u,n.resolvedTemplate),i.push(u)}}else n.templateType==="modify"&&(n.modifiedFileContent?(he.default.writeFileSync(u,n.modifiedFileContent),s.push(u)):o.push(`Failed to modify file: ${u} because of error: ${n.templateError}`))}catch(a){o.push(a instanceof Error?a.message:String(a))}}return{addResults:i,modifyResults:s,errors:o}};var Ze=b(It());var Nt=b(Be());function en(r){let e={name:"root",type:"directory",children:[],path:""},t=r.map(i=>i.replace(/^\//,"").replace(/\\/g,"/")).sort();for(let i of t){let s=i.split("/").filter(Boolean),o=e;s.forEach((n,u)=>{let a=u===s.length-1,c=o.children?.find(l=>l.name===n);if(c)o=c;else{let l={name:n,type:a?"file":"directory",children:a?void 0:[],path:s.slice(0,u+1).join("/")};o.children||(o.children=[]),o.children.push(l),o=l}})}return e}function Me(r,e="",t=!0,i=!0){if(i&&r.children)return r.children.map((a,c)=>Me(a,"",c===r.children.length-1,!1)).join(`
|
|
94
|
+
`);let s=t?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",o=r.type==="directory"?"\u{1F4C1} ":"\u{1F4C4} ",n=r.type==="directory"?Nt.default.cyan(r.name+"/"):Nt.default.green(r.name),u=e+s+o+n+`
|
|
95
|
+
`;if(r.children&&r.children.length>0){let a=e+(t?" ":"\u2502 ");r.children.forEach((c,l)=>{u+=Me(c,a,l===r.children.length-1,!1)})}return u}var Z=require("fs"),Rt=require("path"),Ds=".derived",ds="blocks.json";function tn(){return(0,Rt.join)(process.cwd(),Ds)}function rn(){return(0,Rt.join)(tn(),ds)}function Mt(r,e){if(r===e)return!0;if(r==null||e==null)return r===e;if(typeof r!=typeof e)return!1;if(typeof r!="object")return r===e;let t=Object.keys(r),i=Object.keys(e);if(t.length!==i.length)return!1;for(let s of t)if(!i.includes(s)||!Mt(r[s],e[s]))return!1;return!0}function oe(){let r=rn();if(!(0,Z.existsSync)(r))return{addedBlocks:[]};try{let e=(0,Z.readFileSync)(r,"utf-8"),t=JSON.parse(e);return Array.isArray(t.addedBlocks)?t.addedBlocks.length>0&&typeof t.addedBlocks[0]=="string"?{addedBlocks:t.addedBlocks.map(i=>({code:i,input:{}}))}:t:{addedBlocks:[]}}catch{return{addedBlocks:[]}}}function ps(r){let e=tn(),t=rn();(0,Z.existsSync)(e)||(0,Z.mkdirSync)(e,{recursive:!0}),(0,Z.writeFileSync)(t,JSON.stringify(r,null,2))}function nn(r){return oe().addedBlocks.some(t=>t.code===r)}function Vt(r,e){return oe().addedBlocks.find(s=>s.code===r&&Mt(s.input,e))||null}function sn(r,e){return oe().addedBlocks.filter(i=>i.code===r&&!Mt(i.input,e))}function Gt(r,e={}){let t=oe();Vt(r,e)||(t.addedBlocks.push({code:r,input:e}),ps(t))}var X=require("node:fs"),Ht=require("node:path"),hs=".derived",ms="staging.json";function on(){return(0,Ht.join)(process.cwd(),hs)}function un(){return(0,Ht.join)(on(),ms)}function Ve(){let r=un();if(!(0,X.existsSync)(r))return{stagedFiles:[]};try{let e=(0,X.readFileSync)(r,"utf-8"),t=JSON.parse(e);return t&&Array.isArray(t.stagedFiles)?t:{stagedFiles:[]}}catch{return{stagedFiles:[]}}}function Wt(r){let e=on(),t=un();(0,X.existsSync)(e)||(0,X.mkdirSync)(e,{recursive:!0}),(0,X.writeFileSync)(t,JSON.stringify(r,null,2))}function Lt(r){return Ve().stagedFiles.some(t=>t.path===r)}function an(r){let e=Ve();Lt(r)||(e.stagedFiles.push({path:r,addedAt:new Date().toISOString()}),Wt(e))}function cn(r){let e=Ve();e.stagedFiles=e.stagedFiles.filter(t=>t.path!==r),Wt(e)}function qt(){Wt({stagedFiles:[]})}function Fe(){return Ve().stagedFiles}var ne=class extends Error{code;constructor(e,t){super(t),this.name="CliError",this.code=e}};var ae=require("child_process");function Dn(r){return e=>e.length>1?[r,"run",e[0],"--",...e.slice(1)]:[r,"run",e[0]]}function fs(){return r=>["deno","run",`npm:${r[0]}`,...r.slice(1)]}var gs={agent:["npm",0],run:Dn("npm"),install:["npm","i",0],frozen:["npm","ci",0],global:["npm","i","-g",0],add:["npm","i",0],upgrade:["npm","update",0],"upgrade-interactive":null,execute:["npx",0],"execute-local":["npx",0],uninstall:["npm","uninstall",0],global_uninstall:["npm","uninstall","-g",0]},dn={agent:["yarn",0],run:["yarn","run",0],install:["yarn","install",0],frozen:["yarn","install","--frozen-lockfile",0],global:["yarn","global","add",0],add:["yarn","add",0],upgrade:["yarn","upgrade",0],"upgrade-interactive":["yarn","upgrade-interactive",0],execute:["npx",0],"execute-local":["yarn","exec",0],uninstall:["yarn","remove",0],global_uninstall:["yarn","global","remove",0]},Cs={...dn,frozen:["yarn","install","--immutable",0],upgrade:["yarn","up",0],"upgrade-interactive":["yarn","up","-i",0],execute:["yarn","dlx",0],"execute-local":["yarn","exec",0],global:["npm","i","-g",0],global_uninstall:["npm","uninstall","-g",0]},ln={agent:["pnpm",0],run:["pnpm","run",0],install:["pnpm","i",0],frozen:["pnpm","i","--frozen-lockfile",0],global:["pnpm","add","-g",0],add:["pnpm","add",0],upgrade:["pnpm","update",0],"upgrade-interactive":["pnpm","update","-i",0],execute:["pnpm","dlx",0],"execute-local":["pnpm","exec",0],uninstall:["pnpm","remove",0],global_uninstall:["pnpm","remove","--global",0]},Fs={agent:["bun",0],run:["bun","run",0],install:["bun","install",0],frozen:["bun","install","--frozen-lockfile",0],global:["bun","add","-g",0],add:["bun","add",0],upgrade:["bun","update",0],"upgrade-interactive":["bun","update",0],execute:["bun","x",0],"execute-local":["bun","x",0],uninstall:["bun","remove",0],global_uninstall:["bun","remove","-g",0]},ys={agent:["deno",0],run:["deno","task",0],install:["deno","install",0],frozen:["deno","install","--frozen",0],global:["deno","install","-g",0],add:["deno","add",0],upgrade:["deno","outdated","--update",0],"upgrade-interactive":["deno","outdated","--update",0],execute:fs(),"execute-local":["deno","task","--eval",0],uninstall:["deno","remove",0],global_uninstall:["deno","uninstall","-g",0]},pn={npm:gs,yarn:dn,"yarn@berry":Cs,pnpm:ln,"pnpm@6":{...ln,run:Dn("pnpm")},bun:Fs,deno:ys};function Jt(r,e,t){let i=pn[r][e];return hn(i,t)}function hn(r,e){if(r==null)return null;let t=typeof r=="function"?r(e):r.flatMap(i=>typeof i=="number"?e:[i]);return{command:t[0],args:t.slice(1)}}var mn=["npm","yarn","yarn@berry","pnpm","pnpm@6","bun","deno"],Ut={"bun.lock":"bun","bun.lockb":"bun","deno.lock":"deno","pnpm-lock.yaml":"pnpm","yarn.lock":"yarn","package-lock.json":"npm","npm-shrinkwrap.json":"npm"};var We=b(require("node:fs"),1),ue=b(require("node:path"),1),En=b(require("node:process"),1);var fn=Symbol.for("quansync.getIsAsync"),Ge=class extends Error{constructor(e="Unexpected promise in sync context"){super(e),this.name="QuansyncError"}};function zt(r){return r&&typeof r=="object"&&typeof r.then=="function"}function Es(r){return r&&typeof r=="object"&&typeof r[Symbol.iterator]=="function"&&"__quansync"in r}function Yt(r){let e=function*(...i){return(yield fn)?yield r.async.apply(this,i):r.sync.apply(this,i)};function t(...i){let s=e.apply(this,i);return s.then=(...o)=>r.async.apply(this,i).then(...o),s.__quansync=!0,s}return t.sync=r.sync,t.async=r.async,t}function bs(r){return Yt({async:()=>Promise.resolve(r),sync:()=>{if(zt(r))throw new Ge;return r}})}function Kt(r,e){if(r===fn)return e;if(Es(r))return e?Fn(r):Cn(r);if(!e&&zt(r))throw new Ge;return r}var gn=r=>r;function Cn(r,e=gn){let t=r.next();for(;!t.done;)try{t=r.next(Kt(e(t.value,!1)))}catch(i){t=r.throw(i)}return Kt(t.value)}async function Fn(r,e=gn){let t=r.next();for(;!t.done;)try{t=r.next(await Kt(e(t.value,!0),!0))}catch(i){t=r.throw(i)}return t.value}function vs(r,e){return Yt({name:r.name,async(...t){return Fn(r.apply(this,t),e?.onYield)},sync(...t){return Cn(r.apply(this,t),e?.onYield)}})}function Qt(r,e){return zt(r)?bs(r):typeof r=="function"?vs(r,e):Yt(r)}var Vo=Qt({async:()=>Promise.resolve(!0),sync:()=>!1});var He=Qt;var bn=He({sync:r=>{try{return We.default.statSync(r).isFile()}catch{return!1}},async:async r=>{try{return(await We.default.promises.stat(r)).isFile()}catch{return!1}}});function*$s(r=En.default.cwd()){let e=ue.default.resolve(r),{root:t}=ue.default.parse(e);for(;e&&e!==t;)yield e,e=ue.default.dirname(e)}var yn=He(function*(r,e){return!r||!(yield bn(r))?null:As(r,e)}),Le=He(function*(r={}){let{cwd:e,onUnknown:t}=r;for(let i of $s(e)){for(let o of Object.keys(Ut))if(yield bn(ue.default.join(i,o))){let n=Ut[o],u=yield yn(ue.default.join(i,"package.json"),t);return u||{name:n,agent:n}}let s=yield yn(ue.default.join(i,"package.json"),t);if(s)return s}return null}),ws=Le.sync;function As(r,e){try{let t=JSON.parse(We.default.readFileSync(r,"utf8")),i;if(typeof t.packageManager=="string"){let[s,o]=t.packageManager.replace(/^\^/,"").split("@"),n=o;return s==="yarn"&&Number.parseInt(o)>1?(i="yarn@berry",n="berry",{name:s,agent:i,version:n}):s==="pnpm"&&Number.parseInt(o)<7?(i="pnpm@6",{name:s,agent:i,version:n}):mn.includes(s)?(i=s,{name:s,agent:i,version:n}):e?.(t.packageManager)??null}}catch{}return null}function Zt(r){try{return process.platform==="win32"?(0,ae.execSync)(`where ${r}`,{stdio:"ignore"}):(0,ae.execSync)(`command -v ${r}`,{stdio:"ignore"}),!0}catch{return!1}}function xs(r,e){if(r==="npx"||r==="pnpx"||r==="bunx")return{intent:"execute",args:e};if(r==="yarn"&&e[0]==="dlx")return{intent:"execute",args:e.slice(1)};if(["npm","pnpm","yarn","bun"].includes(r)){let i=e[0]||"",s=e.slice(1);if(!i||["install","i"].includes(i))return{intent:"install",args:s};if(i==="add")return{intent:"add",args:s};if(i==="run")return{intent:"run",args:s};if(["uninstall","remove","rm","un"].includes(i))return{intent:"uninstall",args:s};if(i==="install"&&s.length>0)return{intent:"add",args:s};if(i&&!i.startsWith("-"))return{intent:"run",args:e}}return null}async function qe(r,e={}){let t=r.trim().split(/\s+/),i=t[0]||"",s=t.slice(1),o=xs(i,s);if(o){let u=(await Le({cwd:process.cwd()}))?.agent||"npm",a=Jt(u,o.intent,o.args);if(a){let c=`${a.command} ${a.args.join(" ")}`;if(o.intent==="execute"){if(Zt("bunx")){let l=`bunx ${o.args.join(" ")}`;return(0,ae.execSync)(l,{stdio:"inherit",cwd:process.cwd(),...e})}if(Zt("npx")){let l=`npx ${o.args.join(" ")}`;return(0,ae.execSync)(l,{stdio:"inherit",cwd:process.cwd(),...e})}}if(Zt(a.command))return(0,ae.execSync)(c,{stdio:"inherit",cwd:process.cwd(),...e});throw new Error(`Command not found: ${a.command}. Please install the required package manager.`)}}return(0,ae.execSync)(r,{stdio:"inherit",cwd:process.cwd(),...e})}var ce=b(require("crypto")),k=b(require("fs")),ye=b(require("path")),Xt=b(require("os")),$n="ts-cli-derived",Bs="jwt-token",Je=()=>{let r=Xt.homedir();return ye.join(r,`.${$n}`,`${Bs}.enc`)},_s=()=>{let r=Je(),e=ye.dirname(r);k.existsSync(e)||k.mkdirSync(e,{recursive:!0})},vn=()=>{let r=ye.join(Xt.homedir(),`.${$n}`,"key");if(!k.existsSync(r)){let e=ce.randomBytes(32);return k.writeFileSync(r,e),e}return k.readFileSync(r)},V=class{static async saveToken(e){_s();let t=vn(),i=ce.randomBytes(16),s=ce.createCipheriv("aes-256-gcm",t,i),o=Buffer.concat([s.update(e,"utf8"),s.final()]),n=s.getAuthTag(),u={iv:i.toString("hex"),encrypted:o.toString("hex"),authTag:n.toString("hex")};k.writeFileSync(Je(),JSON.stringify(u))}static async getToken(){try{let e=Je();if(!k.existsSync(e))return null;let t=JSON.parse(k.readFileSync(e,"utf8")),i=vn(),s=Buffer.from(t.iv,"hex"),o=Buffer.from(t.encrypted,"hex"),n=Buffer.from(t.authTag,"hex"),u=ce.createDecipheriv("aes-256-gcm",i,s);return u.setAuthTag(n),u.update(o)+u.final("utf8")}catch{return null}}static async deleteToken(){try{let e=Je();return k.existsSync(e)?(k.unlinkSync(e),!0):!1}catch{return!1}}};var K=require("fs"),ie=require("path"),Os=new Set([".git","node_modules"]);function Ss(r){if((0,K.existsSync)(r))return(0,ie.resolve)(r);if(r.startsWith("/")){let e=(0,ie.resolve)(process.cwd(),r.replace(/^\/+/,""));if((0,K.existsSync)(e))return e}return(0,ie.resolve)(process.cwd(),r)}function wn(r){let e=(0,K.readdirSync)(r,{withFileTypes:!0}),t=[];for(let i of e){let s=(0,ie.join)(r,i.name);if(i.isDirectory()){if(Os.has(i.name))continue;t.push(...wn(s));continue}i.isFile()&&t.push(s)}return t}function ks(r){let e=(0,ie.relative)(process.cwd(),r);return!e||e.startsWith("..")?null:`/${e.replace(/\\/g,"/")}`}function er(r){let e=[],t=new Set;for(let n of r){let u=Ss(n);if(!(0,K.existsSync)(u)){e.push(`Path does not exist: ${n}`);continue}try{let a=(0,K.lstatSync)(u);if(a.isFile()){t.add(u);continue}if(a.isDirectory()){try{let c=wn(u);for(let l of c)t.add(l)}catch(c){e.push(`Failed to read directory "${u}": ${c.message}`)}continue}e.push(`Unsupported path type: ${n}`)}catch(a){e.push(`Failed to inspect path "${u}": ${a.message}`)}}let i=[],s=new Set,o=Array.from(t).sort((n,u)=>n.localeCompare(u));for(let n of o){let u=ks(n);if(!u){e.push(`Path is outside the current project: ${n}`);continue}if(!s.has(u)){s.add(u);try{let a=(0,K.readFileSync)(n,"utf-8");i.push({templatePath:u,template:a})}catch(a){e.push(`Failed to read file "${n}": ${a.message}`)}}}return{files:i,errors:e}}function js(){return!process.stdin.isTTY||process.env.CI==="true"||process.env.TERM==="dumb"||process.env.NON_INTERACTIVE==="true"}var _=js(),I=!1;function An(r){I=r}function A(){return I||_}function Ee(r,e){(I||_)&&console.error(`[${r}] ${e}`)}function $(){return _||I?{start:r=>console.error(`[start] ${r}`),stop:r=>console.error(`[done] ${r}`)}:zr()}var d={intro(r){_||I?Ee("intro",r):Ur(r)},outro(r){_||I?Ee("outro",r):Kr(r)},note(r,e){_||I?(e&&console.error(`[note:${e}]`),console.error(r)):kt(r,e)},data(r,e){_||I?(e&&console.error(`[data:${e}]`),console.error(JSON.stringify(r))):kt(JSON.stringify(r,null,2),e??"Data")},success(r){_||I?Ee("ok",r):U.success(r)},info(r){_||I?Ee("info",r):U.info(r)},warn(r){_||I?Ee("warn",r):U.warning(r)},fatal(r){throw _||I?console.error(`[error] ${r}`):jt(r),new ne("FATAL",r)},cancel(r){throw _||I?console.log(`[cancel] ${r}`):jt(r),new ne("CANCELLED",r)}};function Ts(r,e){let t=Is(r,e);process.stdout.write(JSON.stringify(t)+`
|
|
96
|
+
`)}function Ps(r,e,t,i){let s=Ns(r,e,t,i);process.stdout.write(JSON.stringify(s)+`
|
|
97
|
+
`)}function Is(r,e){return{type:"success",command:r,...e!==void 0?{data:e}:{}}}function Ns(r,e,t,i){return{type:"error",command:r,code:e,message:t,...i!==void 0?{detail:i}:{}}}function z(r,e){Ts(r,e),process.exit(0)}function j(r,e,t,i){Ps(r,e,t,i),process.exit(1)}var Ue=require("node:fs"),xn=require("node:path");function H(){let r=(0,xn.join)(process.cwd(),".derived","project.json");if(!(0,Ue.existsSync)(r))return null;try{let e=(0,Ue.readFileSync)(r,"utf-8");return JSON.parse(e)}catch{return null}}var me=b(It());var Y=require("node:fs"),tr=require("node:path"),Bn=".derived",Rs="categories.json";function _n(){return(0,tr.join)(process.cwd(),Bn,Rs)}function Ms(){return(0,tr.join)(process.cwd(),Bn)}function On(){let r=Ms();(0,Y.existsSync)(r)||(0,Y.mkdirSync)(r,{recursive:!0})}function Sn(){let r=_n();if(!(0,Y.existsSync)(r))return null;try{let e=(0,Y.readFileSync)(r,"utf-8"),t=JSON.parse(e);return t&&typeof t.projectId=="number"&&Array.isArray(t.categories)?t:null}catch{return null}}function ee(r,e){On();let t={projectId:r,lastRefreshed:new Date().toISOString(),categories:e.map(i=>({id:i.id,name:i.name,active:i.active,createdAt:i.createdAt}))};(0,Y.writeFileSync)(_n(),JSON.stringify(t,null,2))}function kn(r,e){let t=Sn();if(!t||t.projectId!==e)return null;let i=r.toLowerCase().trim();return t.categories.find(o=>o.name.toLowerCase().trim()===i)??null}function Ke(r,e){On();let t=Sn(),i={id:e.id,name:e.name,active:e.active,createdAt:e.createdAt};if(!t||t.projectId!==r){ee(r,[e]);return}let s=t.categories.filter(o=>o.id!==e.id);s.push(i),ee(r,s)}async function ze(r,e,t){let i=kn(r,e);if(i)return{id:i.id,name:i.name,projectId:e,active:i.active,createdAt:i.createdAt};let s=$();s.start(`Looking up category "${r}"...`);try{let o=await jn(e,t);s.stop(`Found ${o.length} categories`),ee(e,o);let n=r.toLowerCase().trim();return o.find(a=>a.name.toLowerCase().trim()===n)??null}catch(o){throw s.stop("Failed to fetch categories"),o}}async function rr(r,e,t){let i=await ze(r,e,t).catch(()=>null);if(i)return d.info(`Using existing category "${r}" (ID: ${i.id})`),i;let s=$();s.start(`Creating category "${r}"...`);try{let o=await t.createCategory({name:r,projectId:e,active:!0});s.stop(`Category created: "${r}"`);let n=o.result;return Ke(e,n),n}catch(o){throw s.stop(`Failed to create category "${r}"`),o}}async function jn(r,e,t=1,i=[]){let n=(await e.getProjectCategories(r,50,t))?.result??[];return n.length<50?[...i,...n]:jn(r,e,t+1,[...i,...n])}async function nr(r,e,t,i={}){let s=Number(r);if(!Number.isNaN(s)&&s>0)return s;if(i.findOrCreate)return(await rr(r,e,t)).id;let o=await ze(r,e,t);if(!o)throw new Error(`Category "${r}" not found. Use 'derived-cli category ensure "${r}"' to create it, or pass --find-or-create-category.`);return o.id}function Tn(r){Vs(r),Gs(r),Hs(r)}function Vs(r){r.command("create-category <categoryName>").description("Create a new category in a project (reads projectID from .derived/project.json)").action(async e=>{let t="create-category",i=await V.getToken();i||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let s=await H();s||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let o=s.projectID;d.info(`Using project ID from .derived/project.json: ${o}`);let n=new me.default({apiToken:i}),u=$();u.start("Creating category...");try{let a=await n.createCategory({name:e,projectId:o,active:!0});u.stop("Category created"),a?.result?.id&&Ke(o,a.result),A()&&z(t,a?.result),console.log(JSON.stringify(a?.result?.id??a))}catch(a){u.stop("Failed to create category");let c=a.response?.data?JSON.stringify(a.response.data):a.message;A()&&j(t,"API_ERROR",c),d.fatal(`API Error: ${c}`)}})}function Gs(r){r.command("list-categories").description("List all categories in a project (reads projectID from .derived/project.json)").action(async()=>{let e="list-categories",t=await V.getToken();t||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let i=await H();i||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let s=i.projectID;d.info(`Using project ID from .derived/project.json: ${s}`);let o=new me.default({apiToken:t}),n=$();n.start("Fetching categories...");try{let u=await o.getProjectCategories(s);n.stop("Categories fetched");let a=u?.result??[];Array.isArray(a)&&a.length>0&&ee(s,a),A()&&z(e,a),console.log(JSON.stringify(a))}catch(u){n.stop("Failed to fetch categories");let a=u.response?.data?JSON.stringify(u.response.data):u.message;A()&&j(e,"API_ERROR",a),d.fatal(`API Error: ${a}`)}})}function Hs(r){let e=r.command("category").description("Manage categories in the current project");e.command("find <name>").description("Find a category by name and output its ID").action(async t=>{let i="category.find",s=await V.getToken();s||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let o=await H();o||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let n=o.projectID,u=new me.default({apiToken:s});try{let a=await ze(t,n,u);a?(A()&&z(i,a),console.log(JSON.stringify(a))):(A()&&z(i,null),console.log(JSON.stringify(null)))}catch(a){let c=a.response?.data?JSON.stringify(a.response.data):a.message;A()&&j(i,"API_ERROR",c),d.fatal(`API Error: ${c}`)}}),e.command("ensure <name>").description("Find or create a category (idempotent)").action(async t=>{let i="category.ensure",s=await V.getToken();s||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let o=await H();o||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let n=o.projectID,u=new me.default({apiToken:s});try{let a=await rr(t,n,u);A()&&z(i,a),console.log(JSON.stringify(a))}catch(a){let c=a.response?.data?JSON.stringify(a.response.data):a.message;A()&&j(i,"API_ERROR",c),d.fatal(`API Error: ${c}`)}}),e.command("list").description("List all categories (same as list-categories)").action(async()=>{let t="category.list",i=await V.getToken();i||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let s=await H();s||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let o=s.projectID;d.info(`Using project ID from .derived/project.json: ${o}`);let n=new me.default({apiToken:i}),u=$();u.start("Fetching categories...");try{let a=await n.getProjectCategories(o);u.stop("Categories fetched");let c=a?.result??[];Array.isArray(c)&&c.length>0&&ee(o,c),A()&&z(t,c),console.log(JSON.stringify(c))}catch(a){u.stop("Failed to fetch categories");let c=a.response?.data?JSON.stringify(a.response.data):a.message;A()&&j(t,"API_ERROR",c),d.fatal(`API Error: ${c}`)}})}var O=new yr,se=new Ze.default;O.option("--json","Output structured JSON (agent-friendly)");O.hook("preAction",()=>{(O.opts().json||_)&&An(!0)});Tn(O);async function qs(r){let e=(0,Qe.join)((0,Vn.tmpdir)(),`cli-edit-${Date.now()}.json`);(0,T.writeFileSync)(e,JSON.stringify(r,null,2));let t=process.env.VISUAL||process.env.EDITOR||"nano";return new Promise((i,s)=>{(0,Mn.spawn)(t,[e],{stdio:"inherit"}).on("exit",n=>{if(n===0)try{let u=(0,T.readFileSync)(e,"utf-8"),a=JSON.parse(u);(0,T.unlinkSync)(e),i(a)}catch{(0,T.unlinkSync)(e),s(new Error("Invalid JSON format"))}else(0,T.unlinkSync)(e),s(new Error("Editor closed without saving"))})})}async function Rn(r,e){let t=$();t.start("Modifying block input...");let i=await se.getBlockInputFromUserQuery(JSON.stringify(r),e);return t.stop("Block input modified"),d.data(i.result,"Refined Block Input"),i.result}function Js(r,e="Block Input"){d.data(r,e)}function Gn(r,e){return se.resolveMultipleTemplates(r,e)}async function Hn(r,e){let t=await Gn(r,e),i=t.result.files.map(n=>n.resolvedPath),s=en(i),o=Me(s);d.note(o,`Files to be created (${t.result.files.length}):`)}async function Ye(r,e,t=!1,i){let s=$();s.start("Resolving Files...");let o=await Gn(r,e),n=o.result.files.filter(l=>{let D=(0,Qe.join)(process.cwd(),l.resolvedPath);return(0,T.existsSync)(D)&&(0,T.lstatSync)(D).isFile()&&l.templateType==="add"}),u=[],a=t;if(n.length>0&&!t){s.stop(`${n.length} conflicting files detected`),_&&d.fatal(`${n.length} file(s) already exist. Re-run with --overwrite to overwrite all.
|
|
98
|
+
Example: derived-cli add ${r} --overwrite`);let l=await Ce({message:"Some files already exist. How would you like to proceed?",options:[{value:"overwrite-all",label:"Overwrite all"},{value:"select",label:"Select files to overwrite"},{value:"skip-all",label:"Skip all"}]});if(J(l)&&d.cancel("Operation cancelled."),l==="overwrite-all")a=!0;else if(l==="select"){let D=await Jr({message:"Select files to overwrite",options:n.map(h=>({value:h.resolvedPath,label:h.resolvedPath}))});J(D)&&d.cancel("Operation cancelled."),u=D}s.start("Generating files...")}let c=Qr(o.result.files,u,a);if(c.errors?.length&&d.warn(`${c.errors.length} error(s) during file generation`),s.stop(`${c.addResults.length} files added, ${c.modifyResults.length} files modified, ${c.errors.length} errors`),c.addResults.length>0||c.modifyResults.length>0){if(Gt(r,e),i?.setupCommands&&i.setupCommands.trim()){let l=i.setupCommands.split(",").map(h=>h.trim()),D=$();for(let h of l)if(h){D.start(`Running setup command: ${h}`);try{await qe(h,{stdio:"inherit",cwd:process.cwd()}),D.stop(`Completed: ${h}`)}catch(E){D.stop(`Warning: Setup command failed: ${h}`),d.warn(E.message)}}}if(i?.aiInstruction&&i.aiInstruction.trim())return i.aiInstruction}return null}async function Us(r){let e=[],t=new Set;async function i(s){if(t.has(s))return;t.add(s);let o=await se.fetchBlock(s);if(o?.result?.id){if(o.result.dependsOn?.length)for(let n of o.result.dependsOn)await i(n.code);s!==r&&e.push(s)}}return await i(r),e}async function Ks(r,e,t,i=!1,s=!0){s&&d.intro(`Add block: ${r}`);let o=!1,n=$();n.start("Fetching block...");let u=await se.fetchBlock(r);if(u?.result?.id)n.stop(`Block found: ${u.result.name}${u.result.input?" (input required)":""}`);else return n.stop("Block not found"),null;let a=t||u.result.input;if(t){let c=await Ye(r,t,i,u.result);return o=!0,c}if(!a&&!o){let c=await Ye(r,{},i,u.result);return o=!0,c}if(a&&e&&!t){a=await Rn(a,e);let c=await Ye(r,a,i,u.result);return o=!0,c}for(;!o&&a&&!e;){Js(a),_&&d.fatal(`Block requires input. Re-run with --block-input <base64-json>.
|
|
99
|
+
Schema: ${JSON.stringify(a)}`);let l=await Ce({message:"What would you like to do?",options:[{value:"refine",label:"Edit (AI)"},{value:"edit",label:"Edit (Editor)"},{value:"showFiles",label:"Show files to be created"},{value:"done",label:"Insert Files"}]});if(J(l)&&d.cancel("Operation cancelled."),l==="refine"){let D=await St({message:"Describe what to refine:"});a=await Rn(a,D)}if(l==="edit"&&(a=await qs(a)),l==="done"){let D=await Ye(r,a,i,u.result);return o=!0,D}l==="showFiles"&&await Hn(r,a)}return null}async function Wn(r,e,t,i=!1){let n=[...await Us(r),r].filter(a=>a===r?!0:!nn(a));if(n.length===0){d.note(`Block "${r}" and all its dependencies are already added.`,"Nothing to do");return}if(n.length>1){let a=n.map((c,l)=>{let D=c===r;return` ${l+1}. ${c}${D?" (main)":" (dependency)"}`}).join(`
|
|
100
|
+
`);d.note(`${n.length} blocks will be processed:
|
|
101
|
+
|
|
102
|
+
${a}`,"Processing Queue")}let u=[];for(let a=0;a<n.length;a++){let c=n[a];if(!c)continue;let l=c===r,D=a===n.length-1;n.length>1&&d.intro(`[${a+1}/${n.length}] Processing: ${c}${l?" (main)":""}`);let h=await Ks(c,l?e:void 0,l?t:null,i,n.length===1);h&&u.push({blockCode:c,instruction:h,isMain:l}),D||d.outro(`\u2713 ${c} completed`)}if(n.length>1&&d.outro(`All ${n.length} blocks processed`),u.length>0){let a="";u.length===1?a=u[0]?.instruction||"":a=u.map((c,l)=>{let D=c.isMain?`${c.blockCode} (main)`:c.blockCode;return`${l+1}. [${D}]
|
|
103
|
+
${c.instruction}`}).join(`
|
|
104
|
+
|
|
105
|
+
`),d.note(a,"Next Steps")}}async function zs(r,e={}){d.intro(`Searching: "${r}"`);let t=await H();t||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let i=t.projectID,s=$();s.start("Finding relevant blocks...");try{let o=await se.searchBlocksByName(r,i);if(s.stop("Search complete"),!o.result||o.result.length===0){d.outro("No blocks found.");return}let n;if(e.autoSelect||_){let c=o.result[0];if(!c){d.fatal("No blocks found in search results.");return}n=c.code,o.result.length>1?d.info(`Auto-selected: ${c.name} (${c.code}) \u2014 ${o.result.length-1} other match(es) skipped`):d.success(`Found: ${c.name} (${c.code})`)}else{let c=await Ce({message:`Found ${o.result.length} block(s). Select a block to add:`,options:o.result.map(D=>({value:D.code,label:D.name,hint:`Code: ${D.code} | Input: ${D.input?"Required":"Not required"}`}))});J(c)&&d.cancel("Operation cancelled."),n=c;let l=o.result.find(D=>D.code===n);l&&d.success(`Selected: ${l.name} (${l.code})`)}let u=o.result.find(c=>c.code===n);if(!u){d.fatal("Selected block not found.");return}let a=null;if(u.input&&Object.keys(u.input).length>0){let c=$();c.start("Resolving block input from query...");try{a=(await se.getBlockInputFromUserQuery(JSON.stringify(u.input),r)).result,c.stop("Block input resolved"),d.data(a,"Resolved Block Input")}catch(l){c.stop("Could not resolve input automatically"),d.warn(`Input resolution failed: ${l.message}`),d.info("Proceeding with default input schema.")}}await Wn(u.code,a?void 0:r,a||null,e.overwrite||!1)}catch(o){s.stop("Search failed"),d.fatal(`Error: ${o.message}`)}}O.command("help").description("List all commands and usage").action(()=>{console.log(`
|
|
104
106
|
Available commands:
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
GIT-LIKE WORKFLOW:
|
|
109
|
+
stage [paths...]
|
|
110
|
+
Stage files/directories for creating a block.
|
|
111
|
+
Paths can point to files or directories (directories are scanned recursively).
|
|
112
|
+
Example: derived-cli stage src/components/Button.tsx src/utils/
|
|
113
|
+
Example: derived-cli stage ./src/
|
|
114
|
+
|
|
115
|
+
status
|
|
116
|
+
Show staged files and added blocks (git-like format).
|
|
117
|
+
Example: derived-cli status
|
|
118
|
+
|
|
119
|
+
unstage [paths...]
|
|
120
|
+
Remove files from the staging area.
|
|
121
|
+
Example: derived-cli unstage /src/components/Button.tsx
|
|
122
|
+
|
|
123
|
+
push
|
|
124
|
+
Push staged files to create a block in Derived.
|
|
108
125
|
Flags:
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
|
|
112
|
-
Example
|
|
126
|
+
-c, --category <ref> : Category ID or name
|
|
127
|
+
-n, --name <name> : Block name
|
|
128
|
+
--find-or-create-category : Auto-create category if name not found
|
|
129
|
+
Example: derived-cli push -c 28 -n "my-component"
|
|
130
|
+
Example: derived-cli push -c "UI Components" -n "my-component" --find-or-create-category
|
|
113
131
|
|
|
132
|
+
BLOCK MANAGEMENT:
|
|
114
133
|
add <block-id>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
134
|
+
Add a block from Derived to your project.
|
|
135
|
+
Flags:
|
|
136
|
+
-q, --query <value> : Refine block input with AI
|
|
137
|
+
-i, --block-input <b64>: Block input as base64 JSON
|
|
138
|
+
-o, --overwrite : Overwrite existing files
|
|
139
|
+
-f, --force : Force re-add even if exists
|
|
140
|
+
Example: derived-cli add hero-section --overwrite
|
|
119
141
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
142
|
+
search <query>
|
|
143
|
+
Search for blocks using natural language and add them.
|
|
144
|
+
Flags:
|
|
145
|
+
-a, --auto-select : Auto-select best match
|
|
146
|
+
-o, --overwrite : Overwrite existing files
|
|
147
|
+
Example: derived-cli search "add contact page"
|
|
148
|
+
|
|
149
|
+
create <category> <templateGroupName> [paths...]
|
|
150
|
+
Create templates from files (non-interactive).
|
|
151
|
+
<category> can be a category ID or name.
|
|
152
|
+
Flags:
|
|
153
|
+
--find-or-create-category : Auto-create category if name not found
|
|
154
|
+
Example: derived-cli create 28 "auth-jwt" /src/auth
|
|
155
|
+
Example: derived-cli create "UI Components" "hero-section" /src/components --find-or-create-category
|
|
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"
|
|
124
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
|
|
177
|
+
|
|
178
|
+
PROJECT MANAGEMENT:
|
|
125
179
|
init <project-slug>
|
|
126
|
-
Initialize a project from a template
|
|
127
|
-
The directory must be empty. Clones the project repository,
|
|
128
|
-
removes git metadata, and runs setup commands.
|
|
180
|
+
Initialize a project from a template.
|
|
129
181
|
Example: derived-cli init react-ts
|
|
130
182
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
Example: derived-cli
|
|
183
|
+
project
|
|
184
|
+
Fetch current project details.
|
|
185
|
+
Example: derived-cli project
|
|
186
|
+
|
|
187
|
+
GLOBAL FLAGS:
|
|
188
|
+
--json
|
|
189
|
+
Output structured JSON (agent-friendly). Auto-enabled in non-TTY environments.
|
|
190
|
+
|
|
191
|
+
AUTH:
|
|
192
|
+
register <token>
|
|
193
|
+
Register with your account token.
|
|
194
|
+
Example: derived-cli register abc123
|
|
134
195
|
|
|
135
196
|
help
|
|
136
197
|
Show this help text.
|
|
137
|
-
`)});var
|
|
198
|
+
`)});var Ys=r=>{let e=$();try{e.start("Decoding base64...");let t=Buffer.from(r,"base64").toString("utf8"),i=JSON.parse(t);for(;typeof i!="object";)i=JSON.parse(i);return e.stop("Decoded input"),i}catch{return e.stop("Failed to decode input"),null}};O.command("add <blockCode>").description("Generate and refine a JSON block interactively").option("-q, --query <value>","Optional user input").option("-i, --block-input <value>","Optional block input json schema in base 64").option("-o, --overwrite","Automatically overwrite existing files").option("-f, --force","Force insert even if block already exists").action(async(r,e)=>{let t=e.blockInput?Ys(e.blockInput):null;if(Vt(r,t||{})&&!e.force){d.note(`Block "${r}" with the same input is already added. Use -f to force re-add.`,"Already Added");return}let s=sn(r,t||{});if(s.length>0&&!e.force){let o=s.length;d.note(`Block "${r}" was added ${o} time${o>1?"s":""} with different input. Proceeding with new input...`,"Different Input Detected")}await Wn(r,e.query,t,e.overwrite)});O.command("search <query>").description("Search and add blocks using natural language").option("-a, --auto-select","Automatically select the best match (agent-friendly mode)").option("-o, --overwrite","Automatically overwrite existing files").action(async(r,e)=>{await zs(r,{autoSelect:e.autoSelect,overwrite:e.overwrite})});O.command("create <category> <templateGroupName> [paths...]").description("Create templates from provided files/folders. <category> can be a category ID or name.").option("--find-or-create-category","If category name is given, create it if it does not exist").action(async(r,e,t=[],i)=>{let s="create",o=await V.getToken();o||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let n=await H();n||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let u=n.projectID;d.info(`Using project ID from .derived/project.json: ${u}`);let a=new Ze.default({apiToken:o}),c=0;try{c=await nr(r,u,a,{findOrCreate:i.findOrCreateCategory})}catch(C){A()&&j(s,"CATEGORY_NOT_FOUND",C.message),d.fatal(C.message);return}let l=t.filter(C=>C.trim().length>0);l.length===0&&d.fatal("At least one file or directory path is required.");let D=$();D.start("Collecting files...");let{files:h,errors:E}=er(l);D.stop(`Collected ${h.length} file(s) from ${l.length} path(s)`);for(let C of E)d.warn(C);h.length===0&&d.fatal("No valid files found.");let B=$();B.start("Creating template group...");let G=null,m=null;try{m=await a.createTemplateGroup({name:e,projectID:u,blockCategoryId:c});let C=Number(m?.result?.id);if(!Number.isInteger(C)||C<=0)throw new Error("Template group created but no valid group ID was returned.");G=C,B.stop(`Template group created: ${G}`)}catch(C){B.stop("Failed to create template group");let F=C.response?.data?JSON.stringify(C.response.data):C.message;A()&&j(s,"API_ERROR",F),d.fatal(`API Error: ${F}`)}G===null&&d.fatal("Template group could not be created.");let y=h.map(C=>({type:"add",templateGroupId:G,path:C.templatePath,template:C.template})),W=$();W.start(`Creating ${y.length} template(s)...`);try{await a.createMultipleTemplates(y),W.stop(`Created ${y.length} template(s)`);let C={templateGroup:m?.result,categoryId:c,templateCount:h.length};A()&&z(s,C),d.outro(`Template group "${e}" created`),console.log(JSON.stringify(m?.result))}catch(C){W.stop("Failed to create templates");let F=C.response?.data?JSON.stringify(C.response.data):C.message;A()&&j(s,"API_ERROR",F),d.fatal(`API Error: ${F}`)}});async function ir(r,e){let{existsSync:t,mkdirSync:i,writeFileSync:s}=await import("fs"),{join:o}=await import("path"),n=o(r,".derived");t(n)||i(n,{recursive:!0});let u={projectID:e.id,projectSlug:e.slug,projectName:e.name,ownerUsername:e.ownerUsername,gitUrl:e.gitUrl,description:e.description},a=o(n,"project.json");s(a,JSON.stringify(u,null,2))}O.command("project").description("Fetch current project details using slug from .derived/project.json").action(async()=>{let r=await H();if(!r){d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");return}let e=r.projectSlug,t=$();t.start(`Fetching project details for '${e}'...`);try{let i=await se.fetchProjectBySlug(e);i?.result||(t.stop("Project not found"),d.fatal(`Project '${e}' not found. Run 'derived-cli init <project-slug>' to initialize this directory with a valid project.`)),t.stop("Project details fetched"),console.log(JSON.stringify(i.result))}catch(i){i?.response?.status===404&&(t.stop("Project not found"),d.fatal(`Project '${e}' not found. Run 'derived-cli init <project-slug>' to initialize this directory with a valid project.`)),t.stop("Failed to fetch project details");let s=i.response?.data?JSON.stringify(i.response.data):i.message;d.fatal(`API Error: ${s}`)}});O.command("init <project-slug>").description("Initialize a project from a template").action(async r=>{d.intro(`Initializing project: ${r}`);try{let e=process.cwd(),{isDirectoryEmpty:t,removeGitDirectory:i}=await Promise.resolve().then(()=>(Nn(),In)),{existsSync:s}=await import("fs"),{join:o}=await import("path"),n=t(e),u=$();u.start("Fetching project details...");let a=await se.fetchProjectBySlug(r);a?.result||(u.stop("Project not found"),d.fatal(`Project '${r}' does not exist.`));let c=a.result;if(u.stop(`Found project: ${c.name}`),!n){let l=o(e,".derived","project.json");if(s(l)){_&&(await ir(e,c),d.outro("project.json updated"),process.exit(0));let D=await qr({message:"project.json already exists. Overwrite?"});J(D)&&d.cancel("Operation cancelled."),D||(d.outro("Skipped updating project.json"),process.exit(0))}await ir(e,c),d.outro("project.json updated in .derived folder"),process.exit(0)}u.start("Cloning repository...");try{await qe(`git clone ${c.gitUrl} .`,{stdio:"pipe",cwd:e}),u.stop("Repository cloned")}catch(l){u.stop("Failed to clone repository"),d.fatal(`Git clone failed: ${l.message}`)}if(i(e),c.setupCommand&&c.setupCommand.trim()){let l=c.setupCommand.split(",").map(D=>D.trim());for(let D of l)if(D){u.start(`Running: ${D}`);try{await qe(D,{stdio:"inherit",cwd:e}),u.stop(`Completed: ${D}`)}catch(h){u.stop(`Warning: Command failed: ${D}`),d.warn(h.message)}}}await ir(e,c),d.outro(`Project '${c.name}' initialized`)}catch(e){d.fatal(`An error occurred: ${e.message}`)}});O.command("status").description("Show staged files and added blocks").action(async()=>{try{let r=Fe(),e=oe(),t=r.length>0,i=e.addedBlocks.length>0;if(!t&&!i){d.note("Nothing to show. Use 'derived-cli stage <path>' to stage files.","Status");return}if(t){console.log(`
|
|
199
|
+
\x1B[32mChanges to be pushed:\x1B[0m`),console.log(` \x1B[32m(use "derived-cli unstage <path>" to unstage)\x1B[0m
|
|
200
|
+
`);for(let s of r)console.log(`\x1B[32m new file: ${s.path}\x1B[0m`)}if(i){t&&console.log(""),console.log("\x1B[36mBlocks added to this project:\x1B[0m"),console.log(` \x1B[36m(${e.addedBlocks.length} block(s))\x1B[0m
|
|
201
|
+
`);for(let s of e.addedBlocks){let o=Object.keys(s.input||{}).length>0?` ${JSON.stringify(s.input)}`:"";console.log(`\x1B[36m ${s.code}${o}\x1B[0m`)}}console.log("")}catch(r){d.fatal(`Failed to get status: ${r instanceof Error?r.message:String(r)}`)}});O.command("blocks-status").description("Show all blocks that have been added to the project").action(async()=>{try{let e=oe().addedBlocks;if(e.length===0){d.note("No blocks have been added yet.","Blocks Status");return}d.note(`${e.length} block(s) added to this project:`,"Blocks Status"),e.forEach((t,i)=>{let s=JSON.stringify(t.input),o=s==="{}"?"(no input)":s;d.note(` ${i+1}. ${t.code} ${o}`,"")})}catch(r){d.fatal(`Failed to get blocks status: ${r.message}`)}});O.command("stage [paths...]").description("Stage files/directories for creating a block (git-like)").action(async(r=[])=>{try{if(r.length===0){d.note("No paths provided. Usage: derived-cli stage <path1> [path2] ...");return}let{files:e,errors:t}=er(r);for(let o of t)d.warn(o);if(e.length===0){d.fatal("No valid files found to stage.");return}let i=0,s=0;for(let o of e){if(Lt(o.templatePath)){s++;continue}an(o.templatePath),i++}i>0&&d.success(`Staged ${i} file(s)`),s>0&&d.note(`${s} file(s) already staged (skipped)`)}catch(e){d.fatal(`Failed to stage files: ${e instanceof Error?e.message:String(e)}`)}});O.command("unstage [paths...]").description("Remove files from the staging area").action(async(r=[])=>{try{if(r.length===0){d.note("No paths provided. Usage: derived-cli unstage <path1> [path2] ...");return}let e=Fe(),t=new Set(e.map(o=>o.path)),i=0,s=0;for(let o of r)t.has(o)?(cn(o),i++):(s++,d.warn(`Not staged: ${o}`));i>0&&d.success(`Unstaged ${i} file(s)`),s>0&&i===0&&d.note("No matching staged files found.")}catch(e){d.fatal(`Failed to unstage: ${e.message}`)}});O.command("clear-staging").description("Clear all files from the staging area").action(async()=>{try{let r=Fe();if(r.length===0){d.note("No files are currently staged.");return}qt(),d.success(`Cleared ${r.length} file(s) from staging area`)}catch(r){d.fatal(`Failed to clear staging: ${r.message}`)}});O.command("push").description("Push staged files to create a block in Derived").option("-c, --category <ref>","Category ID or name").option("-n, --name <name>","Block name").option("--find-or-create-category","If category name is given, create it if it does not exist").action(async r=>{let e="push";try{let t=await V.getToken();t||d.fatal("Not logged in. Run 'derived-cli register <token>' first.");let i=await H();i||d.fatal("No .derived/project.json found. Run 'derived-cli init <project-slug>' first.");let s=Fe();if(s.length===0){d.note("No files are currently staged. Use 'derived-cli stage <path>' to stage files.");return}d.intro(`Pushing ${s.length} staged file(s)`);let o=new Ze.default({apiToken:t}),n=i.projectID,u=0,a;if(r.category&&r.name){let m=String(r.category);try{u=await nr(m,n,o,{findOrCreate:r.findOrCreateCategory})}catch(y){A()&&j(e,"CATEGORY_NOT_FOUND",y.message),d.fatal(y.message);return}a=r.name}else{if(_){d.fatal("Category and name required in agent mode. Use: derived-cli push -c <categoryId|name> -n <blockName>");return}let m=$();m.start("Fetching categories...");let y=[];try{y=(await o.getProjectCategories(n))?.result||[],Array.isArray(y)&&y.length>0&&ee(n,y),m.stop(`Found ${y.length} categories`)}catch(F){m.stop("Failed to fetch categories"),d.fatal(`Error: ${F.message}`);return}if(y.length===0){d.fatal("No categories found. Create one first with 'derived-cli create-category <name>'");return}let W=await Ce({message:"Select a category for the block:",options:y.map(F=>({value:F.id,label:F.name,hint:`ID: ${F.id}`}))});if(J(W)){d.cancel("Operation cancelled.");return}u=W;let C=await St({message:"Enter a name for the block:",placeholder:"e.g., my-component"});if(J(C)){d.cancel("Operation cancelled.");return}if(a=C,!a||a.trim()===""){d.fatal("Block name is required.");return}}let c=$();c.start("Collecting file contents...");let l=s.map(m=>{let y=(0,Qe.join)(process.cwd(),m.path.replace(/^\//,"")),W=(0,T.existsSync)(y)?(0,T.readFileSync)(y,"utf-8"):"";return{templatePath:m.path,template:W}});c.stop(`Collected ${l.length} file(s)`);let D=$();D.start("Creating template group...");let h=null,E=null;try{E=await o.createTemplateGroup({name:a,projectID:n,blockCategoryId:u});let m=Number(E?.result?.id);if(!Number.isInteger(m)||m<=0)throw new Error("Template group created but no valid group ID was returned.");h=m,D.stop(`Template group created: ${h}`)}catch(m){D.stop("Failed to create template group");let y=m.response?.data?JSON.stringify(m.response.data):m.message;A()&&j(e,"API_ERROR",y),d.fatal(`API Error: ${y}`);return}if(h===null){d.fatal("Template group could not be created.");return}let B=l.map(m=>({type:"add",templateGroupId:h,path:m.templatePath,template:m.template})),G=$();G.start(`Creating ${B.length} template(s)...`);try{await o.createMultipleTemplates(B),G.stop(`Created ${B.length} template(s)`),qt(),Gt(a,{categoryId:u,fileCount:l.length});let m={templateGroup:E?.result,categoryId:u,fileCount:l.length};A()&&z(e,m),d.outro(`Block "${a}" created with ${l.length} file(s)`),console.log(JSON.stringify(E?.result))}catch(m){G.stop("Failed to create templates");let y=m.response?.data?JSON.stringify(m.response.data):m.message;A()&&j(e,"API_ERROR",y),d.fatal(`API Error: ${y}`)}}catch(t){d.fatal(`Failed to push: ${t.message}`)}});O.command("register <token>").description("Register with your account token").action(async r=>{try{await V.saveToken(r),d.success("Token saved")}catch(e){d.fatal(`Failed to save token: ${e.message}`)}});(async()=>{try{await O.parseAsync()}catch(r){throw r instanceof ne&&(A()&&j("cli",r.code,r.message),process.exit(r.code==="CANCELLED"?0:1)),r}})();0&&(module.exports={displayFileTree});
|