@sr-connect/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +554 -0
- package/dist/chunk-7ZX4RISS.js +8 -0
- package/dist/chunk-HHBSYJ3E.js +2 -0
- package/dist/chunk-STBTNAXZ.js +21 -0
- package/dist/dist-A3XXQMMP.js +148 -0
- package/dist/dist-UQEAKLYF.js +2 -0
- package/dist/highlight-7NU3CBVT.js +2 -0
- package/dist/index.js +1398 -0
- package/package.json +74 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{__commonJS,__toESM}from"./chunk-HHBSYJ3E.js";var require_core=__commonJS({"node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/lib/core.js"(exports,module){"use strict";function deepFreeze(obj){return obj instanceof Map?obj.clear=obj.delete=obj.set=function(){throw new Error("map is read-only")}:obj instanceof Set&&(obj.add=obj.clear=obj.delete=function(){throw new Error("set is read-only")}),Object.freeze(obj),Object.getOwnPropertyNames(obj).forEach(name=>{let prop=obj[name],type=typeof prop;(type==="object"||type==="function")&&!Object.isFrozen(prop)&&deepFreeze(prop)}),obj}var Response=class{constructor(mode){mode.data===void 0&&(mode.data={}),this.data=mode.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function escapeHTML(value){return value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function inherit$1(original,...objects){let result=Object.create(null);for(let key in original)result[key]=original[key];return objects.forEach(function(obj){for(let key in obj)result[key]=obj[key]}),result}var SPAN_CLOSE="</span>",emitsWrappingTags=node=>!!node.scope,scopeToCSSClass=(name,{prefix})=>{if(name.startsWith("language:"))return name.replace("language:","language-");if(name.includes(".")){let pieces=name.split(".");return[`${prefix}${pieces.shift()}`,...pieces.map((x,i)=>`${x}${"_".repeat(i+1)}`)].join(" ")}return`${prefix}${name}`},HTMLRenderer=class{constructor(parseTree,options){this.buffer="",this.classPrefix=options.classPrefix,parseTree.walk(this)}addText(text){this.buffer+=escapeHTML(text)}openNode(node){if(!emitsWrappingTags(node))return;let className=scopeToCSSClass(node.scope,{prefix:this.classPrefix});this.span(className)}closeNode(node){emitsWrappingTags(node)&&(this.buffer+=SPAN_CLOSE)}value(){return this.buffer}span(className){this.buffer+=`<span class="${className}">`}},newNode=(opts={})=>{let result={children:[]};return Object.assign(result,opts),result},TokenTree=class _TokenTree{constructor(){this.rootNode=newNode(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(node){this.top.children.push(node)}openNode(scope){let node=newNode({scope});this.add(node),this.stack.push(node)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(builder){return this.constructor._walk(builder,this.rootNode)}static _walk(builder,node){return typeof node=="string"?builder.addText(node):node.children&&(builder.openNode(node),node.children.forEach(child=>this._walk(builder,child)),builder.closeNode(node)),builder}static _collapse(node){typeof node!="string"&&node.children&&(node.children.every(el=>typeof el=="string")?node.children=[node.children.join("")]:node.children.forEach(child=>{_TokenTree._collapse(child)}))}},TokenTreeEmitter=class extends TokenTree{constructor(options){super(),this.options=options}addText(text){text!==""&&this.add(text)}startScope(scope){this.openNode(scope)}endScope(){this.closeNode()}__addSublanguage(emitter,name){let node=emitter.root;name&&(node.scope=`language:${name}`),this.add(node)}toHTML(){return new HTMLRenderer(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function source(re){return re?typeof re=="string"?re:re.source:null}function lookahead(re){return concat("(?=",re,")")}function anyNumberOfTimes(re){return concat("(?:",re,")*")}function optional(re){return concat("(?:",re,")?")}function concat(...args){return args.map(x=>source(x)).join("")}function stripOptionsFromArgs(args){let opts=args[args.length-1];return typeof opts=="object"&&opts.constructor===Object?(args.splice(args.length-1,1),opts):{}}function either(...args){return"("+(stripOptionsFromArgs(args).capture?"":"?:")+args.map(x=>source(x)).join("|")+")"}function countMatchGroups(re){return new RegExp(re.toString()+"|").exec("").length-1}function startsWith(re,lexeme){let match=re&&re.exec(lexeme);return match&&match.index===0}var BACKREF_RE=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function _rewriteBackreferences(regexps,{joinWith}){let numCaptures=0;return regexps.map(regex=>{numCaptures+=1;let offset=numCaptures,re=source(regex),out="";for(;re.length>0;){let match=BACKREF_RE.exec(re);if(!match){out+=re;break}out+=re.substring(0,match.index),re=re.substring(match.index+match[0].length),match[0][0]==="\\"&&match[1]?out+="\\"+String(Number(match[1])+offset):(out+=match[0],match[0]==="("&&numCaptures++)}return out}).map(re=>`(${re})`).join(joinWith)}var MATCH_NOTHING_RE=/\b\B/,IDENT_RE2="[a-zA-Z]\\w*",UNDERSCORE_IDENT_RE="[a-zA-Z_]\\w*",NUMBER_RE="\\b\\d+(\\.\\d+)?",C_NUMBER_RE="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",BINARY_NUMBER_RE="\\b(0b[01]+)",RE_STARTERS_RE="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG=(opts={})=>{let beginShebang=/^#![ ]*\//;return opts.binary&&(opts.begin=concat(beginShebang,/.*\b/,opts.binary,/\b.*/)),inherit$1({scope:"meta",begin:beginShebang,end:/$/,relevance:0,"on:begin":(m,resp)=>{m.index!==0&&resp.ignoreMatch()}},opts)},BACKSLASH_ESCAPE={begin:"\\\\[\\s\\S]",relevance:0},APOS_STRING_MODE={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[BACKSLASH_ESCAPE]},QUOTE_STRING_MODE={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[BACKSLASH_ESCAPE]},PHRASAL_WORDS_MODE={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},COMMENT=function(begin,end,modeOptions={}){let mode=inherit$1({scope:"comment",begin,end,contains:[]},modeOptions);mode.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let ENGLISH_WORD=either("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return mode.contains.push({begin:concat(/[ ]+/,"(",ENGLISH_WORD,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),mode},C_LINE_COMMENT_MODE=COMMENT("//","$"),C_BLOCK_COMMENT_MODE=COMMENT("/\\*","\\*/"),HASH_COMMENT_MODE=COMMENT("#","$"),NUMBER_MODE={scope:"number",begin:NUMBER_RE,relevance:0},C_NUMBER_MODE={scope:"number",begin:C_NUMBER_RE,relevance:0},BINARY_NUMBER_MODE={scope:"number",begin:BINARY_NUMBER_RE,relevance:0},REGEXP_MODE={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[BACKSLASH_ESCAPE]}]},TITLE_MODE={scope:"title",begin:IDENT_RE2,relevance:0},UNDERSCORE_TITLE_MODE={scope:"title",begin:UNDERSCORE_IDENT_RE,relevance:0},METHOD_GUARD={begin:"\\.\\s*"+UNDERSCORE_IDENT_RE,relevance:0},END_SAME_AS_BEGIN=function(mode){return Object.assign(mode,{"on:begin":(m,resp)=>{resp.data._beginMatch=m[1]},"on:end":(m,resp)=>{resp.data._beginMatch!==m[1]&&resp.ignoreMatch()}})},MODES=Object.freeze({__proto__:null,APOS_STRING_MODE,BACKSLASH_ESCAPE,BINARY_NUMBER_MODE,BINARY_NUMBER_RE,COMMENT,C_BLOCK_COMMENT_MODE,C_LINE_COMMENT_MODE,C_NUMBER_MODE,C_NUMBER_RE,END_SAME_AS_BEGIN,HASH_COMMENT_MODE,IDENT_RE:IDENT_RE2,MATCH_NOTHING_RE,METHOD_GUARD,NUMBER_MODE,NUMBER_RE,PHRASAL_WORDS_MODE,QUOTE_STRING_MODE,REGEXP_MODE,RE_STARTERS_RE,SHEBANG,TITLE_MODE,UNDERSCORE_IDENT_RE,UNDERSCORE_TITLE_MODE});function skipIfHasPrecedingDot(match,response){match.input[match.index-1]==="."&&response.ignoreMatch()}function scopeClassName(mode,_parent){mode.className!==void 0&&(mode.scope=mode.className,delete mode.className)}function beginKeywords(mode,parent){parent&&mode.beginKeywords&&(mode.begin="\\b("+mode.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",mode.__beforeBegin=skipIfHasPrecedingDot,mode.keywords=mode.keywords||mode.beginKeywords,delete mode.beginKeywords,mode.relevance===void 0&&(mode.relevance=0))}function compileIllegal(mode,_parent){Array.isArray(mode.illegal)&&(mode.illegal=either(...mode.illegal))}function compileMatch(mode,_parent){if(mode.match){if(mode.begin||mode.end)throw new Error("begin & end are not supported with match");mode.begin=mode.match,delete mode.match}}function compileRelevance(mode,_parent){mode.relevance===void 0&&(mode.relevance=1)}var beforeMatchExt=(mode,parent)=>{if(!mode.beforeMatch)return;if(mode.starts)throw new Error("beforeMatch cannot be used with starts");let originalMode=Object.assign({},mode);Object.keys(mode).forEach(key=>{delete mode[key]}),mode.keywords=originalMode.keywords,mode.begin=concat(originalMode.beforeMatch,lookahead(originalMode.begin)),mode.starts={relevance:0,contains:[Object.assign(originalMode,{endsParent:!0})]},mode.relevance=0,delete originalMode.beforeMatch},COMMON_KEYWORDS=["of","and","for","in","not","or","if","then","parent","list","value"],DEFAULT_KEYWORD_SCOPE="keyword";function compileKeywords(rawKeywords,caseInsensitive,scopeName=DEFAULT_KEYWORD_SCOPE){let compiledKeywords=Object.create(null);return typeof rawKeywords=="string"?compileList(scopeName,rawKeywords.split(" ")):Array.isArray(rawKeywords)?compileList(scopeName,rawKeywords):Object.keys(rawKeywords).forEach(function(scopeName2){Object.assign(compiledKeywords,compileKeywords(rawKeywords[scopeName2],caseInsensitive,scopeName2))}),compiledKeywords;function compileList(scopeName2,keywordList){caseInsensitive&&(keywordList=keywordList.map(x=>x.toLowerCase())),keywordList.forEach(function(keyword){let pair=keyword.split("|");compiledKeywords[pair[0]]=[scopeName2,scoreForKeyword(pair[0],pair[1])]})}}function scoreForKeyword(keyword,providedScore){return providedScore?Number(providedScore):commonKeyword(keyword)?0:1}function commonKeyword(keyword){return COMMON_KEYWORDS.includes(keyword.toLowerCase())}var seenDeprecations={},error=message=>{console.error(message)},warn=(message,...args)=>{console.log(`WARN: ${message}`,...args)},deprecated=(version2,message)=>{seenDeprecations[`${version2}/${message}`]||(console.log(`Deprecated as of ${version2}. ${message}`),seenDeprecations[`${version2}/${message}`]=!0)},MultiClassError=new Error;function remapScopeNames(mode,regexes,{key}){let offset=0,scopeNames=mode[key],emit={},positions={};for(let i=1;i<=regexes.length;i++)positions[i+offset]=scopeNames[i],emit[i+offset]=!0,offset+=countMatchGroups(regexes[i-1]);mode[key]=positions,mode[key]._emit=emit,mode[key]._multi=!0}function beginMultiClass(mode){if(Array.isArray(mode.begin)){if(mode.skip||mode.excludeBegin||mode.returnBegin)throw error("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),MultiClassError;if(typeof mode.beginScope!="object"||mode.beginScope===null)throw error("beginScope must be object"),MultiClassError;remapScopeNames(mode,mode.begin,{key:"beginScope"}),mode.begin=_rewriteBackreferences(mode.begin,{joinWith:""})}}function endMultiClass(mode){if(Array.isArray(mode.end)){if(mode.skip||mode.excludeEnd||mode.returnEnd)throw error("skip, excludeEnd, returnEnd not compatible with endScope: {}"),MultiClassError;if(typeof mode.endScope!="object"||mode.endScope===null)throw error("endScope must be object"),MultiClassError;remapScopeNames(mode,mode.end,{key:"endScope"}),mode.end=_rewriteBackreferences(mode.end,{joinWith:""})}}function scopeSugar(mode){mode.scope&&typeof mode.scope=="object"&&mode.scope!==null&&(mode.beginScope=mode.scope,delete mode.scope)}function MultiClass(mode){scopeSugar(mode),typeof mode.beginScope=="string"&&(mode.beginScope={_wrap:mode.beginScope}),typeof mode.endScope=="string"&&(mode.endScope={_wrap:mode.endScope}),beginMultiClass(mode),endMultiClass(mode)}function compileLanguage(language){function langRe(value,global){return new RegExp(source(value),"m"+(language.case_insensitive?"i":"")+(language.unicodeRegex?"u":"")+(global?"g":""))}class MultiRegex{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(re,opts){opts.position=this.position++,this.matchIndexes[this.matchAt]=opts,this.regexes.push([opts,re]),this.matchAt+=countMatchGroups(re)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let terminators=this.regexes.map(el=>el[1]);this.matcherRe=langRe(_rewriteBackreferences(terminators,{joinWith:"|"}),!0),this.lastIndex=0}exec(s){this.matcherRe.lastIndex=this.lastIndex;let match=this.matcherRe.exec(s);if(!match)return null;let i=match.findIndex((el,i2)=>i2>0&&el!==void 0),matchData=this.matchIndexes[i];return match.splice(0,i),Object.assign(match,matchData)}}class ResumableMultiRegex{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(index){if(this.multiRegexes[index])return this.multiRegexes[index];let matcher=new MultiRegex;return this.rules.slice(index).forEach(([re,opts])=>matcher.addRule(re,opts)),matcher.compile(),this.multiRegexes[index]=matcher,matcher}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(re,opts){this.rules.push([re,opts]),opts.type==="begin"&&this.count++}exec(s){let m=this.getMatcher(this.regexIndex);m.lastIndex=this.lastIndex;let result=m.exec(s);if(this.resumingScanAtSamePosition()&&!(result&&result.index===this.lastIndex)){let m2=this.getMatcher(0);m2.lastIndex=this.lastIndex+1,result=m2.exec(s)}return result&&(this.regexIndex+=result.position+1,this.regexIndex===this.count&&this.considerAll()),result}}function buildModeRegex(mode){let mm=new ResumableMultiRegex;return mode.contains.forEach(term=>mm.addRule(term.begin,{rule:term,type:"begin"})),mode.terminatorEnd&&mm.addRule(mode.terminatorEnd,{type:"end"}),mode.illegal&&mm.addRule(mode.illegal,{type:"illegal"}),mm}function compileMode(mode,parent){let cmode=mode;if(mode.isCompiled)return cmode;[scopeClassName,compileMatch,MultiClass,beforeMatchExt].forEach(ext=>ext(mode,parent)),language.compilerExtensions.forEach(ext=>ext(mode,parent)),mode.__beforeBegin=null,[beginKeywords,compileIllegal,compileRelevance].forEach(ext=>ext(mode,parent)),mode.isCompiled=!0;let keywordPattern=null;return typeof mode.keywords=="object"&&mode.keywords.$pattern&&(mode.keywords=Object.assign({},mode.keywords),keywordPattern=mode.keywords.$pattern,delete mode.keywords.$pattern),keywordPattern=keywordPattern||/\w+/,mode.keywords&&(mode.keywords=compileKeywords(mode.keywords,language.case_insensitive)),cmode.keywordPatternRe=langRe(keywordPattern,!0),parent&&(mode.begin||(mode.begin=/\B|\b/),cmode.beginRe=langRe(cmode.begin),!mode.end&&!mode.endsWithParent&&(mode.end=/\B|\b/),mode.end&&(cmode.endRe=langRe(cmode.end)),cmode.terminatorEnd=source(cmode.end)||"",mode.endsWithParent&&parent.terminatorEnd&&(cmode.terminatorEnd+=(mode.end?"|":"")+parent.terminatorEnd)),mode.illegal&&(cmode.illegalRe=langRe(mode.illegal)),mode.contains||(mode.contains=[]),mode.contains=[].concat(...mode.contains.map(function(c){return expandOrCloneMode(c==="self"?mode:c)})),mode.contains.forEach(function(c){compileMode(c,cmode)}),mode.starts&&compileMode(mode.starts,parent),cmode.matcher=buildModeRegex(cmode),cmode}if(language.compilerExtensions||(language.compilerExtensions=[]),language.contains&&language.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return language.classNameAliases=inherit$1(language.classNameAliases||{}),compileMode(language)}function dependencyOnParent(mode){return mode?mode.endsWithParent||dependencyOnParent(mode.starts):!1}function expandOrCloneMode(mode){return mode.variants&&!mode.cachedVariants&&(mode.cachedVariants=mode.variants.map(function(variant){return inherit$1(mode,{variants:null},variant)})),mode.cachedVariants?mode.cachedVariants:dependencyOnParent(mode)?inherit$1(mode,{starts:mode.starts?inherit$1(mode.starts):null}):Object.isFrozen(mode)?inherit$1(mode):mode}var version="11.9.0",HTMLInjectionError=class extends Error{constructor(reason,html){super(reason),this.name="HTMLInjectionError",this.html=html}},escape=escapeHTML,inherit=inherit$1,NO_MATCH=Symbol("nomatch"),MAX_KEYWORD_HITS=7,HLJS=function(hljs){let languages=Object.create(null),aliases=Object.create(null),plugins=[],SAFE_MODE=!0,LANGUAGE_NOT_FOUND="Could not find the language '{}', did you forget to load/include a language module?",PLAINTEXT_LANGUAGE={disableAutodetect:!0,name:"Plain text",contains:[]},options={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:TokenTreeEmitter};function shouldNotHighlight(languageName){return options.noHighlightRe.test(languageName)}function blockLanguage(block){let classes=block.className+" ";classes+=block.parentNode?block.parentNode.className:"";let match=options.languageDetectRe.exec(classes);if(match){let language=getLanguage(match[1]);return language||(warn(LANGUAGE_NOT_FOUND.replace("{}",match[1])),warn("Falling back to no-highlight mode for this block.",block)),language?match[1]:"no-highlight"}return classes.split(/\s+/).find(_class=>shouldNotHighlight(_class)||getLanguage(_class))}function highlight2(codeOrLanguageName,optionsOrCode,ignoreIllegals){let code="",languageName="";typeof optionsOrCode=="object"?(code=codeOrLanguageName,ignoreIllegals=optionsOrCode.ignoreIllegals,languageName=optionsOrCode.language):(deprecated("10.7.0","highlight(lang, code, ...args) has been deprecated."),deprecated("10.7.0",`Please use highlight(code, options) instead.
|
|
3
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),languageName=codeOrLanguageName,code=optionsOrCode),ignoreIllegals===void 0&&(ignoreIllegals=!0);let context={code,language:languageName};fire("before:highlight",context);let result=context.result?context.result:_highlight(context.language,context.code,ignoreIllegals);return result.code=context.code,fire("after:highlight",result),result}function _highlight(languageName,codeToHighlight,ignoreIllegals,continuation){let keywordHits=Object.create(null);function keywordData(mode,matchText){return mode.keywords[matchText]}function processKeywords(){if(!top.keywords){emitter.addText(modeBuffer);return}let lastIndex=0;top.keywordPatternRe.lastIndex=0;let match=top.keywordPatternRe.exec(modeBuffer),buf="";for(;match;){buf+=modeBuffer.substring(lastIndex,match.index);let word=language.case_insensitive?match[0].toLowerCase():match[0],data=keywordData(top,word);if(data){let[kind,keywordRelevance]=data;if(emitter.addText(buf),buf="",keywordHits[word]=(keywordHits[word]||0)+1,keywordHits[word]<=MAX_KEYWORD_HITS&&(relevance+=keywordRelevance),kind.startsWith("_"))buf+=match[0];else{let cssClass=language.classNameAliases[kind]||kind;emitKeyword(match[0],cssClass)}}else buf+=match[0];lastIndex=top.keywordPatternRe.lastIndex,match=top.keywordPatternRe.exec(modeBuffer)}buf+=modeBuffer.substring(lastIndex),emitter.addText(buf)}function processSubLanguage(){if(modeBuffer==="")return;let result2=null;if(typeof top.subLanguage=="string"){if(!languages[top.subLanguage]){emitter.addText(modeBuffer);return}result2=_highlight(top.subLanguage,modeBuffer,!0,continuations[top.subLanguage]),continuations[top.subLanguage]=result2._top}else result2=highlightAuto(modeBuffer,top.subLanguage.length?top.subLanguage:null);top.relevance>0&&(relevance+=result2.relevance),emitter.__addSublanguage(result2._emitter,result2.language)}function processBuffer(){top.subLanguage!=null?processSubLanguage():processKeywords(),modeBuffer=""}function emitKeyword(keyword,scope){keyword!==""&&(emitter.startScope(scope),emitter.addText(keyword),emitter.endScope())}function emitMultiClass(scope,match){let i=1,max=match.length-1;for(;i<=max;){if(!scope._emit[i]){i++;continue}let klass=language.classNameAliases[scope[i]]||scope[i],text=match[i];klass?emitKeyword(text,klass):(modeBuffer=text,processKeywords(),modeBuffer=""),i++}}function startNewMode(mode,match){return mode.scope&&typeof mode.scope=="string"&&emitter.openNode(language.classNameAliases[mode.scope]||mode.scope),mode.beginScope&&(mode.beginScope._wrap?(emitKeyword(modeBuffer,language.classNameAliases[mode.beginScope._wrap]||mode.beginScope._wrap),modeBuffer=""):mode.beginScope._multi&&(emitMultiClass(mode.beginScope,match),modeBuffer="")),top=Object.create(mode,{parent:{value:top}}),top}function endOfMode(mode,match,matchPlusRemainder){let matched=startsWith(mode.endRe,matchPlusRemainder);if(matched){if(mode["on:end"]){let resp=new Response(mode);mode["on:end"](match,resp),resp.isMatchIgnored&&(matched=!1)}if(matched){for(;mode.endsParent&&mode.parent;)mode=mode.parent;return mode}}if(mode.endsWithParent)return endOfMode(mode.parent,match,matchPlusRemainder)}function doIgnore(lexeme){return top.matcher.regexIndex===0?(modeBuffer+=lexeme[0],1):(resumeScanAtSamePosition=!0,0)}function doBeginMatch(match){let lexeme=match[0],newMode=match.rule,resp=new Response(newMode),beforeCallbacks=[newMode.__beforeBegin,newMode["on:begin"]];for(let cb of beforeCallbacks)if(cb&&(cb(match,resp),resp.isMatchIgnored))return doIgnore(lexeme);return newMode.skip?modeBuffer+=lexeme:(newMode.excludeBegin&&(modeBuffer+=lexeme),processBuffer(),!newMode.returnBegin&&!newMode.excludeBegin&&(modeBuffer=lexeme)),startNewMode(newMode,match),newMode.returnBegin?0:lexeme.length}function doEndMatch(match){let lexeme=match[0],matchPlusRemainder=codeToHighlight.substring(match.index),endMode=endOfMode(top,match,matchPlusRemainder);if(!endMode)return NO_MATCH;let origin=top;top.endScope&&top.endScope._wrap?(processBuffer(),emitKeyword(lexeme,top.endScope._wrap)):top.endScope&&top.endScope._multi?(processBuffer(),emitMultiClass(top.endScope,match)):origin.skip?modeBuffer+=lexeme:(origin.returnEnd||origin.excludeEnd||(modeBuffer+=lexeme),processBuffer(),origin.excludeEnd&&(modeBuffer=lexeme));do top.scope&&emitter.closeNode(),!top.skip&&!top.subLanguage&&(relevance+=top.relevance),top=top.parent;while(top!==endMode.parent);return endMode.starts&&startNewMode(endMode.starts,match),origin.returnEnd?0:lexeme.length}function processContinuations(){let list=[];for(let current=top;current!==language;current=current.parent)current.scope&&list.unshift(current.scope);list.forEach(item=>emitter.openNode(item))}let lastMatch={};function processLexeme(textBeforeMatch,match){let lexeme=match&&match[0];if(modeBuffer+=textBeforeMatch,lexeme==null)return processBuffer(),0;if(lastMatch.type==="begin"&&match.type==="end"&&lastMatch.index===match.index&&lexeme===""){if(modeBuffer+=codeToHighlight.slice(match.index,match.index+1),!SAFE_MODE){let err=new Error(`0 width match regex (${languageName})`);throw err.languageName=languageName,err.badRule=lastMatch.rule,err}return 1}if(lastMatch=match,match.type==="begin")return doBeginMatch(match);if(match.type==="illegal"&&!ignoreIllegals){let err=new Error('Illegal lexeme "'+lexeme+'" for mode "'+(top.scope||"<unnamed>")+'"');throw err.mode=top,err}else if(match.type==="end"){let processed=doEndMatch(match);if(processed!==NO_MATCH)return processed}if(match.type==="illegal"&&lexeme==="")return 1;if(iterations>1e5&&iterations>match.index*3)throw new Error("potential infinite loop, way more iterations than matches");return modeBuffer+=lexeme,lexeme.length}let language=getLanguage(languageName);if(!language)throw error(LANGUAGE_NOT_FOUND.replace("{}",languageName)),new Error('Unknown language: "'+languageName+'"');let md=compileLanguage(language),result="",top=continuation||md,continuations={},emitter=new options.__emitter(options);processContinuations();let modeBuffer="",relevance=0,index=0,iterations=0,resumeScanAtSamePosition=!1;try{if(language.__emitTokens)language.__emitTokens(codeToHighlight,emitter);else{for(top.matcher.considerAll();;){iterations++,resumeScanAtSamePosition?resumeScanAtSamePosition=!1:top.matcher.considerAll(),top.matcher.lastIndex=index;let match=top.matcher.exec(codeToHighlight);if(!match)break;let beforeMatch=codeToHighlight.substring(index,match.index),processedCount=processLexeme(beforeMatch,match);index=match.index+processedCount}processLexeme(codeToHighlight.substring(index))}return emitter.finalize(),result=emitter.toHTML(),{language:languageName,value:result,relevance,illegal:!1,_emitter:emitter,_top:top}}catch(err){if(err.message&&err.message.includes("Illegal"))return{language:languageName,value:escape(codeToHighlight),illegal:!0,relevance:0,_illegalBy:{message:err.message,index,context:codeToHighlight.slice(index-100,index+100),mode:err.mode,resultSoFar:result},_emitter:emitter};if(SAFE_MODE)return{language:languageName,value:escape(codeToHighlight),illegal:!1,relevance:0,errorRaised:err,_emitter:emitter,_top:top};throw err}}function justTextHighlightResult(code){let result={value:escape(code),illegal:!1,relevance:0,_top:PLAINTEXT_LANGUAGE,_emitter:new options.__emitter(options)};return result._emitter.addText(code),result}function highlightAuto(code,languageSubset){languageSubset=languageSubset||options.languages||Object.keys(languages);let plaintext=justTextHighlightResult(code),results=languageSubset.filter(getLanguage).filter(autoDetection).map(name=>_highlight(name,code,!1));results.unshift(plaintext);let sorted=results.sort((a,b)=>{if(a.relevance!==b.relevance)return b.relevance-a.relevance;if(a.language&&b.language){if(getLanguage(a.language).supersetOf===b.language)return 1;if(getLanguage(b.language).supersetOf===a.language)return-1}return 0}),[best,secondBest]=sorted,result=best;return result.secondBest=secondBest,result}function updateClassName(element,currentLang,resultLang){let language=currentLang&&aliases[currentLang]||resultLang;element.classList.add("hljs"),element.classList.add(`language-${language}`)}function highlightElement(element){let node=null,language=blockLanguage(element);if(shouldNotHighlight(language))return;if(fire("before:highlightElement",{el:element,language}),element.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",element);return}if(element.children.length>0&&(options.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(element)),options.throwUnescapedHTML))throw new HTMLInjectionError("One of your code blocks includes unescaped HTML.",element.innerHTML);node=element;let text=node.textContent,result=language?highlight2(text,{language,ignoreIllegals:!0}):highlightAuto(text);element.innerHTML=result.value,element.dataset.highlighted="yes",updateClassName(element,language,result.language),element.result={language:result.language,re:result.relevance,relevance:result.relevance},result.secondBest&&(element.secondBest={language:result.secondBest.language,relevance:result.secondBest.relevance}),fire("after:highlightElement",{el:element,result,text})}function configure(userOptions){options=inherit(options,userOptions)}let initHighlighting=()=>{highlightAll(),deprecated("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function initHighlightingOnLoad(){highlightAll(),deprecated("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let wantsHighlight=!1;function highlightAll(){if(document.readyState==="loading"){wantsHighlight=!0;return}document.querySelectorAll(options.cssSelector).forEach(highlightElement)}function boot(){wantsHighlight&&highlightAll()}typeof window<"u"&&window.addEventListener&&window.addEventListener("DOMContentLoaded",boot,!1);function registerLanguage(languageName,languageDefinition){let lang=null;try{lang=languageDefinition(hljs)}catch(error$1){if(error("Language definition for '{}' could not be registered.".replace("{}",languageName)),SAFE_MODE)error(error$1);else throw error$1;lang=PLAINTEXT_LANGUAGE}lang.name||(lang.name=languageName),languages[languageName]=lang,lang.rawDefinition=languageDefinition.bind(null,hljs),lang.aliases&®isterAliases(lang.aliases,{languageName})}function unregisterLanguage(languageName){delete languages[languageName];for(let alias of Object.keys(aliases))aliases[alias]===languageName&&delete aliases[alias]}function listLanguages(){return Object.keys(languages)}function getLanguage(name){return name=(name||"").toLowerCase(),languages[name]||languages[aliases[name]]}function registerAliases(aliasList,{languageName}){typeof aliasList=="string"&&(aliasList=[aliasList]),aliasList.forEach(alias=>{aliases[alias.toLowerCase()]=languageName})}function autoDetection(name){let lang=getLanguage(name);return lang&&!lang.disableAutodetect}function upgradePluginAPI(plugin){plugin["before:highlightBlock"]&&!plugin["before:highlightElement"]&&(plugin["before:highlightElement"]=data=>{plugin["before:highlightBlock"](Object.assign({block:data.el},data))}),plugin["after:highlightBlock"]&&!plugin["after:highlightElement"]&&(plugin["after:highlightElement"]=data=>{plugin["after:highlightBlock"](Object.assign({block:data.el},data))})}function addPlugin(plugin){upgradePluginAPI(plugin),plugins.push(plugin)}function removePlugin(plugin){let index=plugins.indexOf(plugin);index!==-1&&plugins.splice(index,1)}function fire(event,args){let cb=event;plugins.forEach(function(plugin){plugin[cb]&&plugin[cb](args)})}function deprecateHighlightBlock(el){return deprecated("10.7.0","highlightBlock will be removed entirely in v12.0"),deprecated("10.7.0","Please use highlightElement now."),highlightElement(el)}Object.assign(hljs,{highlight:highlight2,highlightAuto,highlightAll,highlightElement,highlightBlock:deprecateHighlightBlock,configure,initHighlighting,initHighlightingOnLoad,registerLanguage,unregisterLanguage,listLanguages,getLanguage,registerAliases,autoDetection,inherit,addPlugin,removePlugin}),hljs.debugMode=function(){SAFE_MODE=!1},hljs.safeMode=function(){SAFE_MODE=!0},hljs.versionString=version,hljs.regex={concat,lookahead,either,optional,anyNumberOfTimes};for(let key in MODES)typeof MODES[key]=="object"&&deepFreeze(MODES[key]);return Object.assign(hljs,MODES),hljs},highlight=HLJS({});highlight.newInstance=()=>HLJS({});module.exports=highlight;highlight.HighlightJS=highlight;highlight.default=highlight}});function json(hljs){let ATTRIBUTE={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},PUNCTUATION={match:/[{}[\],:]/,className:"punctuation",relevance:0},LITERALS2=["true","false","null"],LITERALS_MODE={scope:"literal",beginKeywords:LITERALS2.join(" ")};return{name:"JSON",keywords:{literal:LITERALS2},contains:[ATTRIBUTE,PUNCTUATION,hljs.QUOTE_STRING_MODE,LITERALS_MODE,hljs.C_NUMBER_MODE,hljs.C_LINE_COMMENT_MODE,hljs.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function markdown(hljs){let regex=hljs.regex,INLINE_HTML={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},HORIZONTAL_RULE={begin:"^[-\\*]{3,}",end:"$"},CODE={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},LIST={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},LINK_REFERENCE={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},URL_SCHEME=/[A-Za-z][A-Za-z0-9+.-]*/,LINK={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:regex.concat(/\[.+?\]\(/,URL_SCHEME,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},BOLD={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},ITALIC={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},BOLD_WITHOUT_ITALIC=hljs.inherit(BOLD,{contains:[]}),ITALIC_WITHOUT_BOLD=hljs.inherit(ITALIC,{contains:[]});BOLD.contains.push(ITALIC_WITHOUT_BOLD),ITALIC.contains.push(BOLD_WITHOUT_ITALIC);let CONTAINABLE=[INLINE_HTML,LINK];return[BOLD,ITALIC,BOLD_WITHOUT_ITALIC,ITALIC_WITHOUT_BOLD].forEach(m=>{m.contains=m.contains.concat(CONTAINABLE)}),CONTAINABLE=CONTAINABLE.concat(BOLD,ITALIC),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:CONTAINABLE},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:CONTAINABLE}]}]},INLINE_HTML,LIST,BOLD,ITALIC,{className:"quote",begin:"^>\\s+",contains:CONTAINABLE,end:"$"},CODE,HORIZONTAL_RULE,LINK,LINK_REFERENCE]}}var IDENT_RE="[A-Za-z$_][0-9A-Za-z$_]*",KEYWORDS=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],LITERALS=["true","false","null","undefined","NaN","Infinity"],TYPES=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],ERROR_TYPES=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],BUILT_IN_GLOBALS=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],BUILT_IN_VARIABLES=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],BUILT_INS=[].concat(BUILT_IN_GLOBALS,TYPES,ERROR_TYPES);function javascript(hljs){let regex=hljs.regex,hasClosingTag=(match,{after})=>{let tag="</"+match[0].slice(1);return match.input.indexOf(tag,after)!==-1},IDENT_RE$1=IDENT_RE,FRAGMENT={begin:"<>",end:"</>"},XML_SELF_CLOSING=/<[A-Za-z0-9\\._:-]+\s*\/>/,XML_TAG={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(match,response)=>{let afterMatchIndex=match[0].length+match.index,nextChar=match.input[afterMatchIndex];if(nextChar==="<"||nextChar===","){response.ignoreMatch();return}nextChar===">"&&(hasClosingTag(match,{after:afterMatchIndex})||response.ignoreMatch());let m,afterMatch=match.input.substring(afterMatchIndex);if(m=afterMatch.match(/^\s*=/)){response.ignoreMatch();return}if((m=afterMatch.match(/^\s+extends\s+/))&&m.index===0){response.ignoreMatch();return}}},KEYWORDS$1={$pattern:IDENT_RE,keyword:KEYWORDS,literal:LITERALS,built_in:BUILT_INS,"variable.language":BUILT_IN_VARIABLES},decimalDigits="[0-9](_?[0-9])*",frac=`\\.(${decimalDigits})`,decimalInteger="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",NUMBER={className:"number",variants:[{begin:`(\\b(${decimalInteger})((${frac})|\\.)?|(${frac}))[eE][+-]?(${decimalDigits})\\b`},{begin:`\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},SUBST={className:"subst",begin:"\\$\\{",end:"\\}",keywords:KEYWORDS$1,contains:[]},HTML_TEMPLATE={begin:"html`",end:"",starts:{end:"`",returnEnd:!1,contains:[hljs.BACKSLASH_ESCAPE,SUBST],subLanguage:"xml"}},CSS_TEMPLATE={begin:"css`",end:"",starts:{end:"`",returnEnd:!1,contains:[hljs.BACKSLASH_ESCAPE,SUBST],subLanguage:"css"}},GRAPHQL_TEMPLATE={begin:"gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[hljs.BACKSLASH_ESCAPE,SUBST],subLanguage:"graphql"}},TEMPLATE_STRING={className:"string",begin:"`",end:"`",contains:[hljs.BACKSLASH_ESCAPE,SUBST]},COMMENT={className:"comment",variants:[hljs.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:IDENT_RE$1+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),hljs.C_BLOCK_COMMENT_MODE,hljs.C_LINE_COMMENT_MODE]},SUBST_INTERNALS=[hljs.APOS_STRING_MODE,hljs.QUOTE_STRING_MODE,HTML_TEMPLATE,CSS_TEMPLATE,GRAPHQL_TEMPLATE,TEMPLATE_STRING,{match:/\$\d+/},NUMBER];SUBST.contains=SUBST_INTERNALS.concat({begin:/\{/,end:/\}/,keywords:KEYWORDS$1,contains:["self"].concat(SUBST_INTERNALS)});let SUBST_AND_COMMENTS=[].concat(COMMENT,SUBST.contains),PARAMS_CONTAINS=SUBST_AND_COMMENTS.concat([{begin:/\(/,end:/\)/,keywords:KEYWORDS$1,contains:["self"].concat(SUBST_AND_COMMENTS)}]),PARAMS={className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:KEYWORDS$1,contains:PARAMS_CONTAINS},CLASS_OR_EXTENDS={variants:[{match:[/class/,/\s+/,IDENT_RE$1,/\s+/,/extends/,/\s+/,regex.concat(IDENT_RE$1,"(",regex.concat(/\./,IDENT_RE$1),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,IDENT_RE$1],scope:{1:"keyword",3:"title.class"}}]},CLASS_REFERENCE={relevance:0,match:regex.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...TYPES,...ERROR_TYPES]}},USE_STRICT={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},FUNCTION_DEFINITION={variants:[{match:[/function/,/\s+/,IDENT_RE$1,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[PARAMS],illegal:/%/},UPPER_CASE_CONSTANT={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function noneOf(list){return regex.concat("(?!",list.join("|"),")")}let FUNCTION_CALL={match:regex.concat(/\b/,noneOf([...BUILT_IN_GLOBALS,"super","import"]),IDENT_RE$1,regex.lookahead(/\(/)),className:"title.function",relevance:0},PROPERTY_ACCESS={begin:regex.concat(/\./,regex.lookahead(regex.concat(IDENT_RE$1,/(?![0-9A-Za-z$_(])/))),end:IDENT_RE$1,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},GETTER_OR_SETTER={match:[/get|set/,/\s+/,IDENT_RE$1,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},PARAMS]},FUNC_LEAD_IN_RE="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+hljs.UNDERSCORE_IDENT_RE+")\\s*=>",FUNCTION_VARIABLE={match:[/const|var|let/,/\s+/,IDENT_RE$1,/\s*/,/=\s*/,/(async\s*)?/,regex.lookahead(FUNC_LEAD_IN_RE)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[PARAMS]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:KEYWORDS$1,exports:{PARAMS_CONTAINS,CLASS_REFERENCE},illegal:/#(?![$_A-z])/,contains:[hljs.SHEBANG({label:"shebang",binary:"node",relevance:5}),USE_STRICT,hljs.APOS_STRING_MODE,hljs.QUOTE_STRING_MODE,HTML_TEMPLATE,CSS_TEMPLATE,GRAPHQL_TEMPLATE,TEMPLATE_STRING,COMMENT,{match:/\$\d+/},NUMBER,CLASS_REFERENCE,{className:"attr",begin:IDENT_RE$1+regex.lookahead(":"),relevance:0},FUNCTION_VARIABLE,{begin:"("+hljs.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[COMMENT,hljs.REGEXP_MODE,{className:"function",begin:FUNC_LEAD_IN_RE,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:hljs.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:KEYWORDS$1,contains:PARAMS_CONTAINS}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:FRAGMENT.begin,end:FRAGMENT.end},{match:XML_SELF_CLOSING},{begin:XML_TAG.begin,"on:begin":XML_TAG.isTrulyOpeningTag,end:XML_TAG.end}],subLanguage:"xml",contains:[{begin:XML_TAG.begin,end:XML_TAG.end,skip:!0,contains:["self"]}]}]},FUNCTION_DEFINITION,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+hljs.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[PARAMS,hljs.inherit(hljs.TITLE_MODE,{begin:IDENT_RE$1,className:"title.function"})]},{match:/\.\.\./,relevance:0},PROPERTY_ACCESS,{match:"\\$"+IDENT_RE$1,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[PARAMS]},FUNCTION_CALL,UPPER_CASE_CONSTANT,CLASS_OR_EXTENDS,GETTER_OR_SETTER,{match:/\$[(.]/}]}}function typescript(hljs){let tsLanguage=javascript(hljs),IDENT_RE$1=IDENT_RE,TYPES2=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],NAMESPACE={beginKeywords:"namespace",end:/\{/,excludeEnd:!0,contains:[tsLanguage.exports.CLASS_REFERENCE]},INTERFACE={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:TYPES2},contains:[tsLanguage.exports.CLASS_REFERENCE]},USE_STRICT={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},TS_SPECIFIC_KEYWORDS=["type","namespace","interface","public","private","protected","implements","declare","abstract","readonly","enum","override"],KEYWORDS$1={$pattern:IDENT_RE,keyword:KEYWORDS.concat(TS_SPECIFIC_KEYWORDS),literal:LITERALS,built_in:BUILT_INS.concat(TYPES2),"variable.language":BUILT_IN_VARIABLES},DECORATOR={className:"meta",begin:"@"+IDENT_RE$1},swapMode=(mode,label,replacement)=>{let indx=mode.contains.findIndex(m=>m.label===label);if(indx===-1)throw new Error("can not find mode to replace");mode.contains.splice(indx,1,replacement)};Object.assign(tsLanguage.keywords,KEYWORDS$1),tsLanguage.exports.PARAMS_CONTAINS.push(DECORATOR),tsLanguage.contains=tsLanguage.contains.concat([DECORATOR,NAMESPACE,INTERFACE]),swapMode(tsLanguage,"shebang",hljs.SHEBANG()),swapMode(tsLanguage,"use_strict",USE_STRICT);let functionDeclaration=tsLanguage.contains.find(m=>m.label==="func.def");return functionDeclaration.relevance=0,Object.assign(tsLanguage,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),tsLanguage}var import_core=__toESM(require_core(),1);var core_default=import_core.default;var emptyOptions={},defaultPrefix="hljs-";function createLowlight(grammars){let high=core_default.newInstance();return grammars&®ister(grammars),{highlight,highlightAuto,listLanguages,register,registerAlias,registered};function highlight(language,value,options){let settings=options||emptyOptions,prefix=typeof settings.prefix=="string"?settings.prefix:defaultPrefix;if(!high.getLanguage(language))throw new Error("Unknown language: `"+language+"` is not registered");high.configure({__emitter:HastEmitter,classPrefix:prefix});let result=high.highlight(value,{ignoreIllegals:!0,language});if(result.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:result.errorRaised});let root=result._emitter.root,data=root.data;return data.language=result.language,data.relevance=result.relevance,root}function highlightAuto(value,options){let subset=(options||emptyOptions).subset||listLanguages(),index=-1,relevance=0,result;for(;++index<subset.length;){let name=subset[index];if(!high.getLanguage(name))continue;let current=highlight(name,value,options);current.data&¤t.data.relevance!==void 0&¤t.data.relevance>relevance&&(relevance=current.data.relevance,result=current)}return result||{type:"root",children:[],data:{language:void 0,relevance}}}function listLanguages(){return high.listLanguages()}function register(grammarsOrName,grammar){if(typeof grammarsOrName=="string")high.registerLanguage(grammarsOrName,grammar);else{let name;for(name in grammarsOrName)Object.hasOwn(grammarsOrName,name)&&high.registerLanguage(name,grammarsOrName[name])}}function registerAlias(aliasesOrName,alias){if(typeof aliasesOrName=="string")high.registerAliases(typeof alias=="string"?alias:[...alias],{languageName:aliasesOrName});else{let key;for(key in aliasesOrName)if(Object.hasOwn(aliasesOrName,key)){let aliases=aliasesOrName[key];high.registerAliases(typeof aliases=="string"?aliases:[...aliases],{languageName:key})}}}function registered(aliasOrName){return!!high.getLanguage(aliasOrName)}}var HastEmitter=class{constructor(options){this.options=options,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(value){if(value==="")return;let current=this.stack[this.stack.length-1],tail=current.children[current.children.length-1];tail&&tail.type==="text"?tail.value+=value:current.children.push({type:"text",value})}startScope(rawName){this.openNode(String(rawName))}endScope(){this.closeNode()}__addSublanguage(other,name){let current=this.stack[this.stack.length-1],results=other.root.children;name?current.children.push({type:"element",tagName:"span",properties:{className:[name]},children:results}):current.children.push(...results)}openNode(name){let self=this,className=name.split(".").map(function(d,i){return i?d+"_".repeat(i):self.options.classPrefix+d}),current=this.stack[this.stack.length-1],child={type:"element",tagName:"span",properties:{className},children:[]};current.children.push(child),this.stack.push(child)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}};var wrapAnsi16=(offset=0)=>code=>`\x1B[${code+offset}m`,wrapAnsi256=(offset=0)=>code=>`\x1B[${38+offset};5;${code}m`,wrapAnsi16m=(offset=0)=>(red,green,blue)=>`\x1B[${38+offset};2;${red};${green};${blue}m`,styles={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]}},modifierNames=Object.keys(styles.modifier),foregroundColorNames=Object.keys(styles.color),backgroundColorNames=Object.keys(styles.bgColor),colorNames=[...foregroundColorNames,...backgroundColorNames];function assembleStyles(){let codes=new Map;for(let[groupName,group]of Object.entries(styles)){for(let[styleName,style]of Object.entries(group))styles[styleName]={open:`\x1B[${style[0]}m`,close:`\x1B[${style[1]}m`},group[styleName]=styles[styleName],codes.set(style[0],style[1]);Object.defineProperty(styles,groupName,{value:group,enumerable:!1})}return Object.defineProperty(styles,"codes",{value:codes,enumerable:!1}),styles.color.close="\x1B[39m",styles.bgColor.close="\x1B[49m",styles.color.ansi=wrapAnsi16(),styles.color.ansi256=wrapAnsi256(),styles.color.ansi16m=wrapAnsi16m(),styles.bgColor.ansi=wrapAnsi16(10),styles.bgColor.ansi256=wrapAnsi256(10),styles.bgColor.ansi16m=wrapAnsi16m(10),Object.defineProperties(styles,{rgbToAnsi256:{value(red,green,blue){return red===green&&green===blue?red<8?16:red>248?231:Math.round((red-8)/247*24)+232:16+36*Math.round(red/255*5)+6*Math.round(green/255*5)+Math.round(blue/255*5)},enumerable:!1},hexToRgb:{value(hex){let matches=/[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));if(!matches)return[0,0,0];let[colorString]=matches;colorString.length===3&&(colorString=[...colorString].map(character=>character+character).join(""));let integer=Number.parseInt(colorString,16);return[integer>>16&255,integer>>8&255,integer&255]},enumerable:!1},hexToAnsi256:{value:hex=>styles.rgbToAnsi256(...styles.hexToRgb(hex)),enumerable:!1},ansi256ToAnsi:{value(code){if(code<8)return 30+code;if(code<16)return 90+(code-8);let red,green,blue;if(code>=232)red=((code-232)*10+8)/255,green=red,blue=red;else{code-=16;let remainder=code%36;red=Math.floor(code/36)/5,green=Math.floor(remainder/6)/5,blue=remainder%6/5}let value=Math.max(red,green,blue)*2;if(value===0)return 30;let result=30+(Math.round(blue)<<2|Math.round(green)<<1|Math.round(red));return value===2&&(result+=60),result},enumerable:!1},rgbToAnsi:{value:(red,green,blue)=>styles.ansi256ToAnsi(styles.rgbToAnsi256(red,green,blue)),enumerable:!1},hexToAnsi:{value:hex=>styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),enumerable:!1}}),styles}var ansiStyles=assembleStyles(),ansi_styles_default=ansiStyles;import process2 from"process";import os from"os";import tty from"tty";function hasFlag(flag,argv=globalThis.Deno?globalThis.Deno.args:process2.argv){let prefix=flag.startsWith("-")?"":flag.length===1?"-":"--",position=argv.indexOf(prefix+flag),terminatorPosition=argv.indexOf("--");return position!==-1&&(terminatorPosition===-1||position<terminatorPosition)}var{env}=process2,flagForceColor;hasFlag("no-color")||hasFlag("no-colors")||hasFlag("color=false")||hasFlag("color=never")?flagForceColor=0:(hasFlag("color")||hasFlag("colors")||hasFlag("color=true")||hasFlag("color=always"))&&(flagForceColor=1);function envForceColor(){if("FORCE_COLOR"in env)return env.FORCE_COLOR==="true"?1:env.FORCE_COLOR==="false"?0:env.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(env.FORCE_COLOR,10),3)}function translateLevel(level){return level===0?!1:{level,hasBasic:!0,has256:level>=2,has16m:level>=3}}function _supportsColor(haveStream,{streamIsTTY,sniffFlags=!0}={}){let noFlagForceColor=envForceColor();noFlagForceColor!==void 0&&(flagForceColor=noFlagForceColor);let forceColor=sniffFlags?flagForceColor:noFlagForceColor;if(forceColor===0)return 0;if(sniffFlags){if(hasFlag("color=16m")||hasFlag("color=full")||hasFlag("color=truecolor"))return 3;if(hasFlag("color=256"))return 2}if("TF_BUILD"in env&&"AGENT_NAME"in env)return 1;if(haveStream&&!streamIsTTY&&forceColor===void 0)return 0;let min=forceColor||0;if(env.TERM==="dumb")return min;if(process2.platform==="win32"){let osRelease=os.release().split(".");return Number(osRelease[0])>=10&&Number(osRelease[2])>=10586?Number(osRelease[2])>=14931?3:2:1}if("CI"in env)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(key=>key in env)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(sign=>sign in env)||env.CI_NAME==="codeship"?1:min;if("TEAMCITY_VERSION"in env)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION)?1:0;if(env.COLORTERM==="truecolor"||env.TERM==="xterm-kitty"||env.TERM==="xterm-ghostty"||env.TERM==="wezterm")return 3;if("TERM_PROGRAM"in env){let version=Number.parseInt((env.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(env.TERM_PROGRAM){case"iTerm.app":return version>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(env.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)||"COLORTERM"in env?1:min}function createSupportsColor(stream,options={}){let level=_supportsColor(stream,{streamIsTTY:stream&&stream.isTTY,...options});return translateLevel(level)}var supportsColor={stdout:createSupportsColor({isTTY:tty.isatty(1)}),stderr:createSupportsColor({isTTY:tty.isatty(2)})},supports_color_default=supportsColor;function stringReplaceAll(string,substring,replacer){let index=string.indexOf(substring);if(index===-1)return string;let substringLength=substring.length,endIndex=0,returnValue="";do returnValue+=string.slice(endIndex,index)+substring+replacer,endIndex=index+substringLength,index=string.indexOf(substring,endIndex);while(index!==-1);return returnValue+=string.slice(endIndex),returnValue}function stringEncaseCRLFWithFirstIndex(string,prefix,postfix,index){let endIndex=0,returnValue="";do{let gotCR=string[index-1]==="\r";returnValue+=string.slice(endIndex,gotCR?index-1:index)+prefix+(gotCR?`\r
|
|
4
|
+
`:`
|
|
5
|
+
`)+postfix,endIndex=index+1,index=string.indexOf(`
|
|
6
|
+
`,endIndex)}while(index!==-1);return returnValue+=string.slice(endIndex),returnValue}var{stdout:stdoutColor,stderr:stderrColor}=supports_color_default,GENERATOR=Symbol("GENERATOR"),STYLER=Symbol("STYLER"),IS_EMPTY=Symbol("IS_EMPTY"),levelMapping=["ansi","ansi","ansi256","ansi16m"],styles2=Object.create(null),applyOptions=(object,options={})=>{if(options.level&&!(Number.isInteger(options.level)&&options.level>=0&&options.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let colorLevel=stdoutColor?stdoutColor.level:0;object.level=options.level===void 0?colorLevel:options.level},Chalk=class{constructor(options){return chalkFactory(options)}},chalkFactory=options=>{let chalk3=(...strings)=>strings.join(" ");return applyOptions(chalk3,options),Object.setPrototypeOf(chalk3,createChalk.prototype),chalk3};function createChalk(options){return chalkFactory(options)}Object.setPrototypeOf(createChalk.prototype,Function.prototype);for(let[styleName,style]of Object.entries(ansi_styles_default))styles2[styleName]={get(){let builder=createBuilder(this,createStyler(style.open,style.close,this[STYLER]),this[IS_EMPTY]);return Object.defineProperty(this,styleName,{value:builder}),builder}};styles2.visible={get(){let builder=createBuilder(this,this[STYLER],!0);return Object.defineProperty(this,"visible",{value:builder}),builder}};var getModelAnsi=(model,level,type,...arguments_)=>model==="rgb"?level==="ansi16m"?ansi_styles_default[type].ansi16m(...arguments_):level==="ansi256"?ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_)):ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_)):model==="hex"?getModelAnsi("rgb",level,type,...ansi_styles_default.hexToRgb(...arguments_)):ansi_styles_default[type][model](...arguments_),usedModels=["rgb","hex","ansi256"];for(let model of usedModels){styles2[model]={get(){let{level}=this;return function(...arguments_){let styler=createStyler(getModelAnsi(model,levelMapping[level],"color",...arguments_),ansi_styles_default.color.close,this[STYLER]);return createBuilder(this,styler,this[IS_EMPTY])}}};let bgModel="bg"+model[0].toUpperCase()+model.slice(1);styles2[bgModel]={get(){let{level}=this;return function(...arguments_){let styler=createStyler(getModelAnsi(model,levelMapping[level],"bgColor",...arguments_),ansi_styles_default.bgColor.close,this[STYLER]);return createBuilder(this,styler,this[IS_EMPTY])}}}}var proto=Object.defineProperties(()=>{},{...styles2,level:{enumerable:!0,get(){return this[GENERATOR].level},set(level){this[GENERATOR].level=level}}}),createStyler=(open,close,parent)=>{let openAll,closeAll;return parent===void 0?(openAll=open,closeAll=close):(openAll=parent.openAll+open,closeAll=close+parent.closeAll),{open,close,openAll,closeAll,parent}},createBuilder=(self,_styler,_isEmpty)=>{let builder=(...arguments_)=>applyStyle(builder,arguments_.length===1?""+arguments_[0]:arguments_.join(" "));return Object.setPrototypeOf(builder,proto),builder[GENERATOR]=self,builder[STYLER]=_styler,builder[IS_EMPTY]=_isEmpty,builder},applyStyle=(self,string)=>{if(self.level<=0||!string)return self[IS_EMPTY]?"":string;let styler=self[STYLER];if(styler===void 0)return string;let{openAll,closeAll}=styler;if(string.includes("\x1B"))for(;styler!==void 0;)string=stringReplaceAll(string,styler.close,styler.open),styler=styler.parent;let lfIndex=string.indexOf(`
|
|
7
|
+
`);return lfIndex!==-1&&(string=stringEncaseCRLFWithFirstIndex(string,closeAll,openAll,lfIndex)),openAll+string+closeAll};Object.defineProperties(createChalk.prototype,styles2);var chalk=createChalk(),chalkStderr=createChalk({level:stderrColor?stderrColor.level:0});var chalk2=new Chalk({level:2}),defaultSheet={comment:chalk2.gray,quote:chalk2.gray,keyword:chalk2.green,"selector-tag":chalk2.green,addition:chalk2.green,number:chalk2.cyan,string:chalk2.cyan,"meta meta-string":chalk2.cyan,literal:chalk2.cyan,doctag:chalk2.cyan,regexp:chalk2.cyan,title:chalk2.blue,section:chalk2.blue,name:chalk2.blue,"selector-id":chalk2.blue,"selector-class":chalk2.blue,attribute:chalk2.yellow,attr:chalk2.yellow,variable:chalk2.yellow,"template-variable":chalk2.yellow,"class title":chalk2.yellow,type:chalk2.yellow,symbol:chalk2.magenta,bullet:chalk2.magenta,subst:chalk2.magenta,meta:chalk2.magenta,"meta keyword":chalk2.magenta,"selector-attr":chalk2.magenta,"selector-pseudo":chalk2.magenta,link:chalk2.magenta,built_in:chalk2.red,deletion:chalk2.red,emphasis:chalk2.italic,strong:chalk2.bold,formula:chalk2.inverse};function createEmphasize(grammars){let lowlight=createLowlight(grammars);return{highlight,highlightAuto,listLanguages:lowlight.listLanguages,register:lowlight.register,registerAlias:lowlight.registerAlias,registered:lowlight.registered};function highlight(language,value,sheet){let result=lowlight.highlight(language,value),data=result.data;return{language:data.language,relevance:data.relevance,value:visit(sheet||defaultSheet,result)}}function highlightAuto(value,options){let sheet,config;if(options&&("subset"in options||"sheet"in options)){let settings=options;config={subset:settings.subset},sheet=settings.sheet}else sheet=options;let result=lowlight.highlightAuto(value,config),data=result.data;return{language:data.language,relevance:data.relevance,value:visit(sheet||defaultSheet,result)}}}function visit(sheet,node){let names=new Set(node.type==="element"&&Array.isArray(node.properties.className)?node.properties.className.map(function(d){return String(d).replace(/^hljs-/,"")}):[]),scoped={},style,content="",key;for(key in sheet)if(Object.hasOwn(sheet,key)){let parts=key.split(" "),color=sheet[key];names.has(parts[0])?parts.length===1?style=color:scoped[parts.slice(1).join(" ")]=color:scoped[key]=color}return"value"in node?content=node.value:"children"in node&&(content=all(scoped,node.children)),style&&(content=style(content)),content}function all(sheet,nodes){let result=[],index=-1;for(;++index<nodes.length;)result.push(visit(sheet,nodes[index]));return result.join("")}var emphasize=createEmphasize({typescript,json,markdown}),CURSOR_BLOCK="\u2588",INVERSE_ON="\x1B[7m",INVERSE_OFF="\x1B[27m";function highlightContent(code,language){if(process.env.NO_COLOR)return code;try{return emphasize.highlight(language,code).value}catch{return code}}function insertCursor(highlighted,plain,cursor){if(cursor>=plain.length)return`${highlighted}${CURSOR_BLOCK}`;let at=indexOfPlainChar(highlighted,cursor),ch=plain[cursor];if(ch===`
|
|
8
|
+
`||ch===" ")return`${highlighted.slice(0,at)}${CURSOR_BLOCK}${highlighted.slice(at)}`;let codePoint=highlighted.codePointAt(at),width=codePoint!==void 0&&codePoint>65535?2:1;return`${highlighted.slice(0,at)}${INVERSE_ON}${highlighted.slice(at,at+width)}${INVERSE_OFF}${highlighted.slice(at+width)}`}function highlightWithCursor(input,cursor,language){return insertCursor(highlightContent(input,language),input,cursor)}function indexOfPlainChar(text,target){let plainSeen=0,i=0;for(;i<text.length;){let sgr=sgrLength(text,i);if(sgr>0){i+=sgr;continue}if(plainSeen===target)return i;plainSeen++,i++}return text.length}function sgrLength(text,i){if(text.charCodeAt(i)!==27||text[i+1]!=="[")return 0;let j=i+2;for(;j<text.length&&/[\d;]/.test(text[j]);)j++;return text[j]==="m"?j+1-i:0}export{highlightContent,insertCursor,highlightWithCursor};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));export{__commonJS,__export,__toESM};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{__commonJS,__toESM}from"./chunk-HHBSYJ3E.js";var require_src=__commonJS({"node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports,module){"use strict";var cursor2={to(x,y){return y?`\x1B[${y+1};${x+1}H`:`\x1B[${x+1}G`},move(x,y){let ret="";return x<0?ret+=`\x1B[${-x}D`:x>0&&(ret+=`\x1B[${x}C`),y<0?ret+=`\x1B[${-y}A`:y>0&&(ret+=`\x1B[${y}B`),ret},up:(count=1)=>`\x1B[${count}A`,down:(count=1)=>`\x1B[${count}B`,forward:(count=1)=>`\x1B[${count}C`,backward:(count=1)=>`\x1B[${count}D`,nextLine:(count=1)=>"\x1B[E".repeat(count),prevLine:(count=1)=>"\x1B[F".repeat(count),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},scroll={up:(count=1)=>"\x1B[S".repeat(count),down:(count=1)=>"\x1B[T".repeat(count)},erase2={screen:"\x1B[2J",up:(count=1)=>"\x1B[1J".repeat(count),down:(count=1)=>"\x1B[J".repeat(count),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(count){let clear="";for(let i=0;i<count;i++)clear+=this.line+(i<count-1?cursor2.up():"");return count&&(clear+=cursor2.left),clear}};module.exports={cursor:cursor2,scroll,erase:erase2,beep:"\x07"}}});import{styleText}from"util";import{stdout,stdin}from"process";import*as l from"readline";import l__default from"readline";var getCodePointsLength=(()=>{let SURROGATE_PAIR_RE=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return input=>{let surrogatePairsNr=0;for(SURROGATE_PAIR_RE.lastIndex=0;SURROGATE_PAIR_RE.test(input);)surrogatePairsNr+=1;return input.length-surrogatePairsNr}})(),isFullWidth=x=>x===12288||x>=65281&&x<=65376||x>=65504&&x<=65510,isWideNotCJKTNotEmoji=x=>x===8987||x===9001||x>=12272&&x<=12287||x>=12289&&x<=12350||x>=12441&&x<=12543||x>=12549&&x<=12591||x>=12593&&x<=12686||x>=12688&&x<=12771||x>=12783&&x<=12830||x>=12832&&x<=12871||x>=12880&&x<=19903||x>=65040&&x<=65049||x>=65072&&x<=65106||x>=65108&&x<=65126||x>=65128&&x<=65131||x>=127488&&x<=127490||x>=127504&&x<=127547||x>=127552&&x<=127560||x>=131072&&x<=196605||x>=196608&&x<=262141;var ANSI_RE=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,CONTROL_RE=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,CJKT_WIDE_RE=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,TAB_RE=/\t{1,1000}/y,EMOJI_RE=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),LATIN_RE=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,MODIFIER_RE=new RegExp("\\p{M}+","gu"),NO_TRUNCATION={limit:1/0,ellipsis:""},getStringTruncatedWidth=(input,truncationOptions={},widthOptions={})=>{let LIMIT=truncationOptions.limit??1/0,ELLIPSIS=truncationOptions.ellipsis??"",ELLIPSIS_WIDTH=truncationOptions?.ellipsisWidth??(ELLIPSIS?getStringTruncatedWidth(ELLIPSIS,NO_TRUNCATION,widthOptions).width:0),ANSI_WIDTH=0,CONTROL_WIDTH=widthOptions.controlWidth??0,TAB_WIDTH=widthOptions.tabWidth??8,EMOJI_WIDTH=widthOptions.emojiWidth??2,FULL_WIDTH_WIDTH=2,REGULAR_WIDTH=widthOptions.regularWidth??1,WIDE_WIDTH=widthOptions.wideWidth??FULL_WIDTH_WIDTH,PARSE_BLOCKS=[[LATIN_RE,REGULAR_WIDTH],[ANSI_RE,ANSI_WIDTH],[CONTROL_RE,CONTROL_WIDTH],[TAB_RE,TAB_WIDTH],[EMOJI_RE,EMOJI_WIDTH],[CJKT_WIDE_RE,WIDE_WIDTH]],indexPrev=0,index=0,length=input.length,lengthExtra=0,truncationEnabled=!1,truncationIndex=length,truncationLimit=Math.max(0,LIMIT-ELLIPSIS_WIDTH),unmatchedStart=0,unmatchedEnd=0,width=0,widthExtra=0;outer:for(;;){if(unmatchedEnd>unmatchedStart||index>=length&&index>indexPrev){let unmatched=input.slice(unmatchedStart,unmatchedEnd)||input.slice(indexPrev,index);lengthExtra=0;for(let char of unmatched.replaceAll(MODIFIER_RE,"")){let codePoint=char.codePointAt(0)||0;if(isFullWidth(codePoint)?widthExtra=FULL_WIDTH_WIDTH:isWideNotCJKTNotEmoji(codePoint)?widthExtra=WIDE_WIDTH:widthExtra=REGULAR_WIDTH,width+widthExtra>truncationLimit&&(truncationIndex=Math.min(truncationIndex,Math.max(unmatchedStart,indexPrev)+lengthExtra)),width+widthExtra>LIMIT){truncationEnabled=!0;break outer}lengthExtra+=char.length,width+=widthExtra}unmatchedStart=unmatchedEnd=0}if(index>=length)break outer;for(let i=0,l2=PARSE_BLOCKS.length;i<l2;i++){let[BLOCK_RE,BLOCK_WIDTH]=PARSE_BLOCKS[i];if(BLOCK_RE.lastIndex=index,BLOCK_RE.test(input)){if(lengthExtra=BLOCK_RE===CJKT_WIDE_RE?getCodePointsLength(input.slice(index,BLOCK_RE.lastIndex)):BLOCK_RE===EMOJI_RE?1:BLOCK_RE.lastIndex-index,widthExtra=lengthExtra*BLOCK_WIDTH,width+widthExtra>truncationLimit&&(truncationIndex=Math.min(truncationIndex,index+Math.floor((truncationLimit-width)/BLOCK_WIDTH))),width+widthExtra>LIMIT){truncationEnabled=!0;break outer}width+=widthExtra,unmatchedStart=indexPrev,unmatchedEnd=index,index=indexPrev=BLOCK_RE.lastIndex;continue outer}}index+=1}return{width:truncationEnabled?truncationLimit:width,index:truncationEnabled?truncationIndex:length,truncated:truncationEnabled,ellipsed:truncationEnabled&&LIMIT>=ELLIPSIS_WIDTH}},dist_default=getStringTruncatedWidth;var NO_TRUNCATION2={limit:1/0,ellipsis:"",ellipsisWidth:0},fastStringWidth=(input,options={})=>dist_default(input,NO_TRUNCATION2,options).width,dist_default2=fastStringWidth;var ESC="\x1B",CSI="\x9B",END_CODE=39,ANSI_ESCAPE_BELL="\x07",ANSI_CSI="[",ANSI_OSC="]",ANSI_SGR_TERMINATOR="m",ANSI_ESCAPE_LINK=`${ANSI_OSC}8;;`,GROUP_REGEX=new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`,"y"),getClosingCode=openingCode=>{if(openingCode>=30&&openingCode<=37||openingCode>=90&&openingCode<=97)return 39;if(openingCode>=40&&openingCode<=47||openingCode>=100&&openingCode<=107)return 49;if(openingCode===1||openingCode===2)return 22;if(openingCode===3)return 23;if(openingCode===4)return 24;if(openingCode===7)return 27;if(openingCode===8)return 28;if(openingCode===9)return 29;if(openingCode===0)return 0},wrapAnsiCode=code=>`${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`,wrapAnsiHyperlink=url=>`${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`,wrapWord=(rows,word,columns)=>{let characters=word[Symbol.iterator](),isInsideEscape=!1,isInsideLinkEscape=!1,lastRow=rows.at(-1),visible=lastRow===void 0?0:dist_default2(lastRow),currentCharacter=characters.next(),nextCharacter=characters.next(),rawCharacterIndex=0;for(;!currentCharacter.done;){let character=currentCharacter.value,characterLength=dist_default2(character);visible+characterLength<=columns?rows[rows.length-1]+=character:(rows.push(character),visible=0),(character===ESC||character===CSI)&&(isInsideEscape=!0,isInsideLinkEscape=word.startsWith(ANSI_ESCAPE_LINK,rawCharacterIndex+1)),isInsideEscape?isInsideLinkEscape?character===ANSI_ESCAPE_BELL&&(isInsideEscape=!1,isInsideLinkEscape=!1):character===ANSI_SGR_TERMINATOR&&(isInsideEscape=!1):(visible+=characterLength,visible===columns&&!nextCharacter.done&&(rows.push(""),visible=0)),currentCharacter=nextCharacter,nextCharacter=characters.next(),rawCharacterIndex+=character.length}lastRow=rows.at(-1),!visible&&lastRow!==void 0&&lastRow.length&&rows.length>1&&(rows[rows.length-2]+=rows.pop())},stringVisibleTrimSpacesRight=string=>{let words=string.split(" "),last=words.length;for(;last&&!dist_default2(words[last-1]);)last--;return last===words.length?string:words.slice(0,last).join(" ")+words.slice(last).join("")},exec=(string,columns,options={})=>{if(options.trim!==!1&&string.trim()==="")return"";let returnValue="",escapeCode,escapeUrl,words=string.split(" "),rows=[""],rowLength=0;for(let index=0;index<words.length;index++){let word=words[index];if(options.trim!==!1){let row=rows.at(-1)??"",trimmed=row.trimStart();row.length!==trimmed.length&&(rows[rows.length-1]=trimmed,rowLength=dist_default2(trimmed))}index!==0&&(rowLength>=columns&&(options.wordWrap===!1||options.trim===!1)&&(rows.push(""),rowLength=0),(rowLength||options.trim===!1)&&(rows[rows.length-1]+=" ",rowLength++));let wordLength=dist_default2(word);if(options.hard&&wordLength>columns){let remainingColumns=columns-rowLength,breaksStartingThisLine=1+Math.floor((wordLength-remainingColumns-1)/columns);Math.floor((wordLength-1)/columns)<breaksStartingThisLine&&rows.push(""),wrapWord(rows,word,columns),rowLength=dist_default2(rows.at(-1)??"");continue}if(rowLength+wordLength>columns&&rowLength&&wordLength){if(options.wordWrap===!1&&rowLength<columns){wrapWord(rows,word,columns),rowLength=dist_default2(rows.at(-1)??"");continue}rows.push(""),rowLength=0}if(rowLength+wordLength>columns&&options.wordWrap===!1){wrapWord(rows,word,columns),rowLength=dist_default2(rows.at(-1)??"");continue}rows[rows.length-1]+=word,rowLength+=wordLength}options.trim!==!1&&(rows=rows.map(row=>stringVisibleTrimSpacesRight(row)));let preString=rows.join(`
|
|
3
|
+
`),inSurrogate=!1;for(let i=0;i<preString.length;i++){let character=preString[i];if(returnValue+=character,inSurrogate)inSurrogate=!1;else if(inSurrogate=character>="\uD800"&&character<="\uDBFF",inSurrogate)continue;if(character===ESC||character===CSI){GROUP_REGEX.lastIndex=i+1;let groups=GROUP_REGEX.exec(preString)?.groups;if(groups?.code!==void 0){let code=Number.parseFloat(groups.code);escapeCode=code===END_CODE?void 0:code}else groups?.uri!==void 0&&(escapeUrl=groups.uri.length===0?void 0:groups.uri)}if(preString[i+1]===`
|
|
4
|
+
`){escapeUrl&&(returnValue+=wrapAnsiHyperlink(""));let closingCode=escapeCode?getClosingCode(escapeCode):void 0;escapeCode&&closingCode&&(returnValue+=wrapAnsiCode(closingCode))}else character===`
|
|
5
|
+
`&&(escapeCode&&getClosingCode(escapeCode)&&(returnValue+=wrapAnsiCode(escapeCode)),escapeUrl&&(returnValue+=wrapAnsiHyperlink(escapeUrl)))}return returnValue},CRLF_OR_LF=/\r?\n/;function wrapAnsi(string,columns,options){return String(string).normalize().split(CRLF_OR_LF).map(line=>exec(line,columns,options)).join(`
|
|
6
|
+
`)}var import_sisteransi=__toESM(require_src(),1);import{ReadStream}from"tty";function findCursor(s,o2,l2){if(!l2.some(r2=>!r2.disabled))return s;let t2=s+o2,n3=Math.max(l2.length-1,0),e=t2<0?n3:t2>n3?0:t2;return l2[e]?.disabled?findCursor(e,o2<0?-1:1,l2):e}function findTextCursor(s,o2,l2,i){let t2=i.split(`
|
|
7
|
+
`),n3=0,e=s;for(let r2 of t2){if(e<=r2.length)break;e-=r2.length+1,n3++}for(n3=Math.max(0,Math.min(t2.length-1,n3+l2)),e=Math.min(e,t2[n3].length)+o2;e<0&&n3>0;)n3--,e+=t2[n3].length+1;for(;e>t2[n3].length&&n3<t2.length-1;)e-=t2[n3].length+1,n3++;e=Math.max(0,Math.min(t2[n3].length,e));let h2=0;for(let r2=0;r2<n3;r2++)h2+=t2[r2].length+1;return h2+e}var a$1=["up","down","left","right","space","enter","cancel"],t=["January","February","March","April","May","June","July","August","September","October","November","December"],settings={actions:new Set(a$1),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...t],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(n3,e)=>`There are only ${n3} days in ${e}`,afterMin:n3=>`Date must be on or after ${n3.toISOString().slice(0,10)}`,beforeMax:n3=>`Date must be on or before ${n3.toISOString().slice(0,10)}`}}};function updateSettings(n3){if(n3.aliases!==void 0){let e=n3.aliases;for(let s in e){if(!Object.hasOwn(e,s))continue;let i=e[s];i===void 0||!settings.actions.has(i)||settings.aliases.has(s)||settings.aliases.set(s,i)}}if(n3.messages!==void 0){let e=n3.messages;e.cancel!==void 0&&(settings.messages.cancel=e.cancel),e.error!==void 0&&(settings.messages.error=e.error)}if(n3.withGuide!==void 0&&(settings.withGuide=n3.withGuide!==!1),n3.date!==void 0){let e=n3.date;e.monthNames!==void 0&&(settings.date.monthNames=[...e.monthNames]),e.messages!==void 0&&(e.messages.required!==void 0&&(settings.date.messages.required=e.messages.required),e.messages.invalidMonth!==void 0&&(settings.date.messages.invalidMonth=e.messages.invalidMonth),e.messages.invalidDay!==void 0&&(settings.date.messages.invalidDay=e.messages.invalidDay),e.messages.afterMin!==void 0&&(settings.date.messages.afterMin=e.messages.afterMin),e.messages.beforeMax!==void 0&&(settings.date.messages.beforeMax=e.messages.beforeMax))}}function isActionKey(n3,e){if(typeof n3=="string")return settings.aliases.get(n3)===e;for(let s of n3)if(s!==void 0&&isActionKey(s,e))return!0;return!1}function diffLines(i,s){if(i===s)return;let e=i.split(`
|
|
8
|
+
`),t2=s.split(`
|
|
9
|
+
`),r2=Math.max(e.length,t2.length),f2=[];for(let n3=0;n3<r2;n3++)e[n3]!==t2[n3]&&f2.push(n3);return{lines:f2,numLinesBefore:e.length,numLinesAfter:t2.length,numLines:r2}}var R=globalThis.process.platform.startsWith("win"),CANCEL_SYMBOL=Symbol("clack:cancel");function isCancel(e){return e===CANCEL_SYMBOL}function setRawMode(e,r2){let o2=e;o2.isTTY&&o2.setRawMode(r2)}function block({input:e=stdin,output:r2=stdout,overwrite:o2=!0,hideCursor:t2=!0}={}){let s=l.createInterface({input:e,output:r2,prompt:"",tabSize:1});l.emitKeypressEvents(e,s),e instanceof ReadStream&&e.isTTY&&e.setRawMode(!0);let n3=(f2,{name:a2,sequence:p2})=>{let c2=String(f2);if(isActionKey([c2,a2,p2],"cancel")){t2&&r2.write(import_sisteransi.cursor.show),process.exit(0);return}if(!o2)return;l.moveCursor(r2,a2==="return"?0:-1,a2==="return"?-1:0,()=>{l.clearLine(r2,1,()=>{e.once("keypress",n3)})})};return t2&&r2.write(import_sisteransi.cursor.hide),e.once("keypress",n3),()=>{e.off("keypress",n3),t2&&r2.write(import_sisteransi.cursor.show),e instanceof ReadStream&&e.isTTY&&!R&&e.setRawMode(!1),s.terminal=!1,s.close()}}var getColumns=e=>"columns"in e&&typeof e.columns=="number"?e.columns:80,getRows=e=>"rows"in e&&typeof e.rows=="number"?e.rows:20;function wrapTextWithPrefix(e,r2,o2,t2=o2,s=o2,n3){let f2=getColumns(e??stdout);return wrapAnsi(r2,f2-o2.length,{hard:!0,trim:!1}).split(`
|
|
10
|
+
`).map((c2,i,m2)=>{let d=n3?n3(c2,i):c2;return i===0?`${t2}${d}`:i===m2.length-1?`${s}${d}`:`${o2}${d}`}).join(`
|
|
11
|
+
`)}function runValidation(e,n3){if("~standard"in e){let a2=e["~standard"].validate(n3);if(a2 instanceof Promise)throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return a2.issues?.at(0)?.message}return e(n3)}var V=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(t2,e=!0){let{input:i=stdin,output:n3=stdout,render:s,signal:r2,...o2}=t2;this.opts=o2,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=s.bind(this),this._track=e,this._abortSignal=r2,this.input=i,this.output=n3}unsubscribe(){this._subscribers.clear()}setSubscriber(t2,e){let i=this._subscribers.get(t2)??[];i.push(e),this._subscribers.set(t2,i)}on(t2,e){this.setSubscriber(t2,{cb:e})}once(t2,e){this.setSubscriber(t2,{cb:e,once:!0})}emit(t2,...e){let i=this._subscribers.get(t2)??[],n3=[];for(let s of i)s.cb(...e),s.once&&n3.push(()=>i.splice(i.indexOf(s),1));for(let s of n3)s()}prompt(){return new Promise(t2=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t2(CANCEL_SYMBOL);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=l__default.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),setRawMode(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(import_sisteransi.cursor.show),this.output.off("resize",this.render),setRawMode(this.input,!1),t2(this.value)}),this.once("cancel",()=>{this.output.write(import_sisteransi.cursor.show),this.output.off("resize",this.render),setRawMode(this.input,!1),t2(CANCEL_SYMBOL)})})}_isActionKey(t2,e){return t2===" "}_shouldSubmit(t2,e){return!0}_setValue(t2){this.value=t2,this.emit("value",this.value)}_setUserInput(t2,e){this.userInput=t2??"",this.emit("userInput",this.userInput),e&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(t2,e){if(this._track&&e.name!=="return"&&(e.name&&this._isActionKey(t2,e)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),e?.name&&(!this._track&&settings.aliases.has(e.name)&&this.emit("cursor",settings.aliases.get(e.name)),settings.actions.has(e.name)&&this.emit("cursor",e.name)),t2&&(t2.toLowerCase()==="y"||t2.toLowerCase()==="n")&&this.emit("confirm",t2.toLowerCase()==="y"),this.emit("key",t2,e),e?.name==="return"&&this._shouldSubmit(t2,e)){if(this.opts.validate){let i=runValidation(this.opts.validate,this.value);i&&(this.error=i instanceof Error?i.message:i,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}isActionKey([t2,e?.name,e?.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(`
|
|
12
|
+
`),setRawMode(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t2=wrapAnsi(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
13
|
+
`).length-1;this.output.write(import_sisteransi.cursor.move(-999,t2*-1))}render(){let t2=wrapAnsi(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t2!==this._prevFrame){if(this.state==="initial")this.output.write(import_sisteransi.cursor.hide);else{let e=diffLines(this._prevFrame,t2),i=getRows(this.output);if(this.restoreCursor(),e){let n3=Math.max(0,e.numLinesAfter-i),s=Math.max(0,e.numLinesBefore-i),r2=e.lines.find(o2=>o2>=n3);if(r2===void 0){this._prevFrame=t2;return}if(e.lines.length===1){this.output.write(import_sisteransi.cursor.move(0,r2-s)),this.output.write(import_sisteransi.erase.lines(1));let o2=t2.split(`
|
|
14
|
+
`);this.output.write(o2[r2]),this._prevFrame=t2,this.output.write(import_sisteransi.cursor.move(0,o2.length-r2-1));return}else if(e.lines.length>1){if(n3<s)r2=n3;else{let h2=r2-s;h2>0&&this.output.write(import_sisteransi.cursor.move(0,h2))}this.output.write(import_sisteransi.erase.down());let f2=t2.split(`
|
|
15
|
+
`).slice(r2);this.output.write(f2.join(`
|
|
16
|
+
`)),this._prevFrame=t2;return}}this.output.write(import_sisteransi.erase.down())}this.output.write(t2),this.state==="initial"&&(this.state="active"),this._prevFrame=t2}}};function p$1(l2,e){if(l2===void 0||e.length===0)return 0;let i=e.findIndex(s=>s.value===l2);return i!==-1?i:0}function g(l2,e){return(e.label??String(e.value)).toLowerCase().includes(l2.toLowerCase())}function m(l2,e){if(e)return l2?e:e[0]}var T$1=class extends V{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#e=0;#s="";#t;#i;#n;get cursor(){return this.#e}get userInputWithCursor(){if(!this.userInput)return styleText(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let e=this.userInput.slice(0,this.cursor),t2=this.userInput.slice(this.cursor,this.cursor+1),i=this.userInput.slice(this.cursor+1);return`${e}${styleText("inverse",t2)}${i}`}get options(){return typeof this.#i=="function"?this.#i():this.#i}constructor(e){super(e),this.#i=e.options,this.#n=e.placeholder;let t2=this.options;this.filteredOptions=[...t2],this.multiple=e.multiple===!0,this.#t=typeof e.options=="function"?e.filter:e.filter??g;let i;if(e.initialValue&&Array.isArray(e.initialValue)?this.multiple?i=e.initialValue:i=e.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(i=[this.options[0]?.value]),i)for(let s of i){let n3=t2.findIndex(o2=>o2.value===s);n3!==-1&&(this.toggleSelected(s),this.#e=n3)}this.focusedValue=this.options[this.#e]?.value,this.on("key",(s,n3)=>this.#l(s,n3)),this.on("userInput",s=>this.#u(s))}_isActionKey(e,t2){return e===" "||this.multiple&&this.isNavigating&&t2.name==="space"&&e!==void 0&&e!==""}#l(e,t2){let i=t2.name==="up",s=t2.name==="down",n3=t2.name==="return",o2=this.userInput===""||this.userInput===" ",u4=this.#n,a2=this.options,f2=u4!==void 0&&u4!==""&&a2.some(r2=>!r2.disabled&&(this.#t?this.#t(u4,r2):!0));if(t2.name==="tab"&&o2&&f2){this.userInput===" "&&this._clearUserInput(),this._setUserInput(u4,!0),this.isNavigating=!1;return}i||s?(this.#e=findCursor(this.#e,i?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#e]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):n3?this.value=m(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(t2.name==="tab"||this.isNavigating&&t2.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(e){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(e)?this.selectedValues=this.selectedValues.filter(t2=>t2!==e):this.selectedValues=[...this.selectedValues,e]:this.selectedValues=[e])}#u(e){if(e!==this.#s){this.#s=e;let t2=this.options;e&&this.#t?this.filteredOptions=t2.filter(n3=>this.#t?.(e,n3)):this.filteredOptions=[...t2];let i=p$1(this.focusedValue,this.filteredOptions);this.#e=findCursor(i,0,this.filteredOptions);let s=this.filteredOptions[this.#e];s&&!s.disabled?this.focusedValue=s.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}},r=class extends V{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t2){super(t2,!1),this.value=!!t2.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",i=>{this.output.write(import_sisteransi.cursor.move(0,-1)),this.value=i,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}},_={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function M(r2){return[...r2].map(t2=>_[t2])}function P(r2){let i=new Intl.DateTimeFormat(r2,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2e3,0,15)),s=[],n3="/";for(let e of i)e.type==="literal"?n3=e.value.trim()||e.value:(e.type==="year"||e.type==="month"||e.type==="day")&&s.push({type:e.type,len:e.type==="year"?4:2});return{segments:s,separator:n3}}function p(r2){return Number.parseInt((r2||"0").replace(/_/g,"0"),10)||0}function f(r2){return{year:p(r2.year),month:p(r2.month),day:p(r2.day)}}function c(r2,t2){return new Date(r2||2001,t2||1,0).getDate()}function b(r2){let{year:t2,month:i,day:s}=f(r2);if(!t2||t2<0||t2>9999||!i||i<1||i>12||!s||s<1)return;let n3=new Date(Date.UTC(t2,i-1,s));if(!(n3.getUTCFullYear()!==t2||n3.getUTCMonth()!==i-1||n3.getUTCDate()!==s))return{year:t2,month:i,day:s}}function C(r2){let t2=b(r2);return t2?new Date(Date.UTC(t2.year,t2.month-1,t2.day)):void 0}function T2(r2,t2,i,s){let n3=i?{year:i.getUTCFullYear(),month:i.getUTCMonth()+1,day:i.getUTCDate()}:null,e=s?{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate()}:null;return r2==="year"?{min:n3?.year??1,max:e?.year??9999}:r2==="month"?{min:n3&&t2.year===n3.year?n3.month:1,max:e&&t2.year===e.year?e.month:12}:{min:n3&&t2.year===n3.year&&t2.month===n3.month?n3.day:1,max:e&&t2.year===e.year&&t2.month===e.month?e.day:c(t2.year,t2.month)}}var U=class extends V{#i;#o;#t;#h;#u;#e={segmentIndex:0,positionInSegment:0};#n=!0;#s=null;inlineError="";get segmentCursor(){return{...this.#e}}get segmentValues(){return{...this.#t}}get segments(){return this.#i}get separator(){return this.#o}get formattedValue(){return this.#l(this.#t)}#l(t2){return this.#i.map(i=>t2[i.type]).join(this.#o)}#r(){this._setUserInput(this.#l(this.#t)),this._setValue(C(this.#t)??void 0)}constructor(t2){let i=t2.format?{segments:M(t2.format),separator:t2.separator??"/"}:P(t2.locale),s=t2.separator??i.separator,n3=t2.format?M(t2.format):i.segments,e=t2.initialValue??t2.defaultValue,m2=e?{year:String(e.getUTCFullYear()).padStart(4,"0"),month:String(e.getUTCMonth()+1).padStart(2,"0"),day:String(e.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},o2=n3.map(a2=>m2[a2.type]).join(s);super({...t2,initialUserInput:o2},!1),this.#i=n3,this.#o=s,this.#t=m2,this.#h=t2.minDate,this.#u=t2.maxDate,this.#r(),this.on("cursor",a2=>this.#f(a2)),this.on("key",(a2,u4)=>this.#y(a2,u4)),this.on("finalize",()=>this.#p(t2))}#a(){let t2=Math.max(0,Math.min(this.#e.segmentIndex,this.#i.length-1)),i=this.#i[t2];if(i)return this.#e.positionInSegment=Math.max(0,Math.min(this.#e.positionInSegment,i.len-1)),{segment:i,index:t2}}#m(t2){this.inlineError="",this.#s=null;let i=this.#a();i&&(this.#e.segmentIndex=Math.max(0,Math.min(this.#i.length-1,i.index+t2)),this.#e.positionInSegment=0,this.#n=!0)}#d(t2){let i=this.#a();if(!i)return;let{segment:s}=i,n3=this.#t[s.type],e=!n3||n3.replace(/_/g,"")==="",m2=Number.parseInt((n3||"0").replace(/_/g,"0"),10)||0,o2=T2(s.type,f(this.#t),this.#h,this.#u),a2;e?a2=t2===1?o2.min:o2.max:a2=Math.max(Math.min(o2.max,m2+t2),o2.min),this.#t={...this.#t,[s.type]:a2.toString().padStart(s.len,"0")},this.#n=!0,this.#s=null,this.#r()}#f(t2){if(t2)switch(t2){case"right":return this.#m(1);case"left":return this.#m(-1);case"up":return this.#d(1);case"down":return this.#d(-1)}}#y(t2,i){if(i?.name==="backspace"||i?.sequence==="\x7F"||i?.sequence==="\b"||t2==="\x7F"||t2==="\b"){this.inlineError="";let n3=this.#a();if(!n3)return;if(!this.#t[n3.segment.type].replace(/_/g,"")){this.#m(-1);return}this.#t[n3.segment.type]="_".repeat(n3.segment.len),this.#n=!0,this.#e.positionInSegment=0,this.#r();return}if(i?.name==="tab"){this.inlineError="";let n3=this.#a();if(!n3)return;let e=i.shift?-1:1,m2=n3.index+e;m2>=0&&m2<this.#i.length&&(this.#e.segmentIndex=m2,this.#e.positionInSegment=0,this.#n=!0);return}if(t2&&/^[0-9]$/.test(t2)){let n3=this.#a();if(!n3)return;let{segment:e}=n3,m2=!this.#t[e.type].replace(/_/g,"");if(this.#n&&this.#s!==null&&!m2){let h2=this.#s+t2,d={...this.#t,[e.type]:h2},g2=this.#g(d,e);if(g2){this.inlineError=g2,this.#s=null,this.#n=!1;return}this.inlineError="",this.#t[e.type]=h2,this.#s=null,this.#n=!1,this.#r(),n3.index<this.#i.length-1&&(this.#e.segmentIndex=n3.index+1,this.#e.positionInSegment=0,this.#n=!0);return}this.#n&&!m2&&(this.#t[e.type]="_".repeat(e.len),this.#e.positionInSegment=0),this.#n=!1,this.#s=null;let o2=this.#t[e.type],a2=o2.indexOf("_"),u4=a2>=0?a2:Math.min(this.#e.positionInSegment,e.len-1);if(u4<0||u4>=e.len)return;let l2=o2.slice(0,u4)+t2+o2.slice(u4+1),D=!1;if(u4===0&&o2==="__"&&(e.type==="month"||e.type==="day")){let h2=Number.parseInt(t2,10);l2=`0${t2}`,D=h2<=(e.type==="month"?1:2)}if(e.type==="year"&&(l2=(o2.replace(/_/g,"")+t2).padStart(e.len,"_")),!l2.includes("_")){let h2={...this.#t,[e.type]:l2},d=this.#g(h2,e);if(d){this.inlineError=d;return}}this.inlineError="",this.#t[e.type]=l2;let y=l2.includes("_")?void 0:b(this.#t);if(y){let{year:h2,month:d}=y,g2=c(h2,d);this.#t={year:String(Math.max(0,Math.min(9999,h2))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,d))).padStart(2,"0"),day:String(Math.max(1,Math.min(g2,y.day))).padStart(2,"0")}}this.#r();let S=l2.indexOf("_");D?(this.#n=!0,this.#s=t2):S>=0?this.#e.positionInSegment=S:a2>=0&&n3.index<this.#i.length-1?(this.#e.segmentIndex=n3.index+1,this.#e.positionInSegment=0,this.#n=!0):this.#e.positionInSegment=Math.min(u4+1,e.len-1)}}#g(t2,i){let{month:s,day:n3}=f(t2);if(i.type==="month"&&(s<0||s>12))return settings.date.messages.invalidMonth;if(i.type==="day"&&(n3<0||n3>31))return settings.date.messages.invalidDay(31,"any month")}#p(t2){let{year:i,month:s,day:n3}=f(this.#t);if(i&&s&&n3){let e=c(i,s);this.#t={...this.#t,day:String(Math.min(n3,e)).padStart(2,"0")}}this.value=C(this.#t)??t2.defaultValue??void 0}},u$2=class extends V{options;cursor=0;#t;getGroupItems(t2){return this.options.filter(r2=>r2.group===t2)}isGroupSelected(t2){let r2=this.getGroupItems(t2),e=this.value;return e===void 0?!1:r2.every(s=>e.includes(s.value))}toggleValue(){let t2=this.options[this.cursor];if(t2!==void 0)if(this.value===void 0&&(this.value=[]),t2.group===!0){let r2=t2.value,e=this.getGroupItems(r2);this.isGroupSelected(r2)?this.value=this.value.filter(s=>e.findIndex(i=>i.value===s)===-1):this.value=[...this.value,...e.map(s=>s.value)],this.value=Array.from(new Set(this.value))}else{let r2=this.value.includes(t2.value);this.value=r2?this.value.filter(e=>e!==t2.value):[...this.value,t2.value]}}constructor(t2){super(t2,!1);let{options:r2}=t2;this.#t=t2.selectableGroups!==!1,this.options=Object.entries(r2).flatMap(([e,s])=>[{value:e,group:!0,label:e},...s.map(i=>({...i,group:e}))]),this.value=[...t2.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===t2.cursorAt),this.#t?0:1),this.on("cursor",e=>{switch(e){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let s=this.options[this.cursor]?.group===!0;!this.#t&&s&&(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;let s=this.options[this.cursor]?.group===!0;!this.#t&&s&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},o=new Set(["up","down","left","right"]),h=class extends V{#t=!1;#s;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t2=this.userInput;if(this.cursor>=t2.length)return`${t2}\u2588`;let s=t2.slice(0,this.cursor),r2=t2.slice(this.cursor,this.cursor+1),i=t2.slice(this.cursor+1);return r2===`
|
|
17
|
+
`?`${s}\u2588
|
|
18
|
+
${i}`:`${s}${styleText("inverse",r2)}${i}`}get cursor(){return this._cursor}#r(t2){if(this.userInput.length===0){this._setUserInput(t2);return}this._setUserInput(this.userInput.slice(0,this.cursor)+t2+this.userInput.slice(this.cursor))}#i(t2){let s=this.value??"";switch(t2){case"up":this._cursor=findTextCursor(this._cursor,0,-1,s);return;case"down":this._cursor=findTextCursor(this._cursor,0,1,s);return;case"left":this._cursor=findTextCursor(this._cursor,-1,0,s);return;case"right":this._cursor=findTextCursor(this._cursor,1,0,s);return}}_shouldSubmit(t2,s){if(this.#s)return this.focused==="submit"?!0:(this.#r(`
|
|
19
|
+
`),this._cursor++,!1);let r2=this.#t;return this.#t=!0,r2&&this.cursor===this.userInput.length?(this.userInput[this.cursor-1]===`
|
|
20
|
+
`&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#r(`
|
|
21
|
+
`),this._cursor++,!1)}constructor(t2){let s=t2.initialUserInput??t2.initialValue;super({...t2,initialUserInput:s},!1),s!==void 0&&(this._cursor=s.length),this.#s=t2.showSubmit??!1,this.on("key",(r2,i)=>{if(i?.name&&o.has(i.name)){this.#t=!1,this.#i(i.name);return}if(r2===" "&&this.#s){this.focused=this.focused==="editor"?"submit":"editor";return}if(i?.name!=="return"){if(this.#t=!1,i?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(i?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}r2&&(this.#s&&this.focused==="submit"&&(this.focused="editor"),this.#r(r2??""),this._cursor++)}}),this.on("userInput",r2=>{this._setValue(r2)}),this.on("finalize",()=>{this.value||(this.value=t2.defaultValue),this.value===void 0&&(this.value="")})}},a=class extends V{options;cursor=0;get _value(){return this.options[this.cursor]?.value}get _enabledOptions(){return this.options.filter(e=>e.disabled!==!0)}toggleAll(){let e=this._enabledOptions,i=this.value!==void 0&&this.value.length===e.length;this.value=i?[]:e.map(t2=>t2.value)}toggleInvert(){let e=this.value;if(!e)return;let i=this._enabledOptions.filter(t2=>!e.includes(t2.value));this.value=i.map(t2=>t2.value)}toggleValue(){this.value===void 0&&(this.value=[]);let e=this.value.includes(this._value);this.value=e?this.value.filter(i=>i!==this._value):[...this.value,this._value]}constructor(e){super(e,!1),this.options=e.options,this.value=[...e.initialValues??[]];let i=Math.max(this.options.findIndex(({value:t2})=>t2===e.cursorAt),0);this.cursor=this.options[i]?.disabled?findCursor(i,1,this.options):i,this.on("key",(t2,l2)=>{l2.name==="a"&&this.toggleAll(),l2.name==="i"&&this.toggleInvert()}),this.on("cursor",t2=>{switch(t2){case"left":case"up":this.cursor=findCursor(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=findCursor(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}},u$1=class extends V{_mask="\u2022";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let t2=this.userInput;if(this.cursor>=t2.length)return`${this.masked}${styleText(["inverse","hidden"],"_")}`;let s=this.masked,r2=s.slice(0,this.cursor),i=s.slice(this.cursor,this.cursor+1),o2=s.slice(this.cursor+1);return`${r2}${styleText("inverse",i)}${o2}`}clear(){this._clearUserInput()}constructor({mask:t2,...s}){super(s),this._mask=t2??"\u2022",this.on("userInput",r2=>{this._setValue(r2)}),this.on("finalize",()=>{this.value===void 0&&(this.value="")})}},n$1=class extends V{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=e===void 0?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let o2=this.options.findIndex(({value:s})=>s===e.initialValue),t2=o2===-1?0:o2;this.cursor=this.options[t2]?.disabled?findCursor(t2,1,this.options):t2,this.changeValue(),this.on("cursor",s=>{switch(s){case"left":case"up":this.cursor=findCursor(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=findCursor(this.cursor,1,this.options);break}this.changeValue()})}},u3=class extends V{options;cursor=0;constructor(t2){super(t2,!1),this.options=t2.options;let s=t2.caseSensitive===!0,i=this.options.map(({value:[e]})=>s?e:e?.toLowerCase());this.cursor=Math.max(i.indexOf(t2.initialValue),0),this.on("key",e=>{if(!e)return;let o2=s?e:e.toLowerCase();if(!i.includes(o2))return;let n3=this.options.find(({value:[r2]})=>s?r2===o2:r2?.toLowerCase()===o2);n3&&(this.value=n3.value,this.state="submit",this.emit("submit"))})}},n2=class extends V{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t2=this.userInput;if(this.cursor>=t2.length)return`${this.userInput}\u2588`;let r2=t2.slice(0,this.cursor),s=t2.slice(this.cursor,this.cursor+1),e=t2.slice(this.cursor+1);return`${r2}${styleText("inverse",s)}${e}`}get cursor(){return this._cursor}constructor(t2){super({...t2,initialUserInput:t2.initialUserInput??t2.initialValue}),this.on("userInput",r2=>{this._setValue(r2)}),this.on("finalize",()=>{this.value||(this.value=t2.defaultValue),this.value===void 0&&(this.value="")})}};export{dist_default2 as dist_default,wrapAnsi,require_src,settings,updateSettings,isCancel,block,getColumns,getRows,wrapTextWithPrefix,runValidation,V,T$1,r,U,u$2,h,a,u$1,n$1,u3 as u,n2 as n};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{T$1,U,a,block,dist_default,getColumns,getRows,h,isCancel,n,n$1,r,require_src,runValidation,settings,u,u$1,u$2,updateSettings,wrapAnsi,wrapTextWithPrefix}from"./chunk-STBTNAXZ.js";import{__toESM}from"./chunk-HHBSYJ3E.js";import{styleText,stripVTControlCharacters}from"util";import process$1 from"process";var import_sisteransi=__toESM(require_src(),1);import{existsSync,lstatSync,readdirSync}from"fs";import{dirname,join}from"path";function isUnicodeSupported(){return process$1.platform!=="win32"?process$1.env.TERM!=="linux":!!process$1.env.CI||!!process$1.env.WT_SESSION||!!process$1.env.TERMINUS_SUBLIME||process$1.env.ConEmuTask==="{cmd::Cmder}"||process$1.env.TERM_PROGRAM==="Terminus-Sublime"||process$1.env.TERM_PROGRAM==="vscode"||process$1.env.TERM==="xterm-256color"||process$1.env.TERM==="alacritty"||process$1.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var unicode=isUnicodeSupported(),isCI=()=>process.env.CI==="true",isTTY=o=>o.isTTY===!0,unicodeOr=(o,e)=>unicode?o:e,S_STEP_ACTIVE=unicodeOr("\u25C6","*"),S_STEP_CANCEL=unicodeOr("\u25A0","x"),S_STEP_ERROR=unicodeOr("\u25B2","x"),S_STEP_SUBMIT=unicodeOr("\u25C7","o"),S_BAR_START=unicodeOr("\u250C","T"),S_BAR=unicodeOr("\u2502","|"),S_BAR_END=unicodeOr("\u2514","\u2014"),S_BAR_START_RIGHT=unicodeOr("\u2510","T"),S_BAR_END_RIGHT=unicodeOr("\u2518","\u2014"),S_RADIO_ACTIVE=unicodeOr("\u25CF",">"),S_RADIO_INACTIVE=unicodeOr("\u25CB"," "),S_CHECKBOX_ACTIVE=unicodeOr("\u25FB","[\u2022]"),S_CHECKBOX_SELECTED=unicodeOr("\u25FC","[+]"),S_CHECKBOX_INACTIVE=unicodeOr("\u25FB","[ ]"),S_PASSWORD_MASK=unicodeOr("\u25AA","\u2022"),S_BAR_H=unicodeOr("\u2500","-"),S_CORNER_TOP_RIGHT=unicodeOr("\u256E","+"),S_CONNECT_LEFT=unicodeOr("\u251C","+"),S_CORNER_BOTTOM_RIGHT=unicodeOr("\u256F","+"),S_CORNER_BOTTOM_LEFT=unicodeOr("\u2570","+"),S_CORNER_TOP_LEFT=unicodeOr("\u256D","+"),S_INFO=unicodeOr("\u25CF","\u2022"),S_SUCCESS=unicodeOr("\u25C6","*"),S_WARN=unicodeOr("\u25B2","!"),S_ERROR=unicodeOr("\u25A0","x"),symbol=o=>{switch(o){case"initial":case"active":return styleText("cyan",S_STEP_ACTIVE);case"cancel":return styleText("red",S_STEP_CANCEL);case"error":return styleText("yellow",S_STEP_ERROR);case"submit":return styleText("green",S_STEP_SUBMIT)}},symbolBar=o=>{switch(o){case"initial":case"active":return styleText("cyan",S_BAR);case"cancel":return styleText("red",S_BAR);case"error":return styleText("yellow",S_BAR);case"submit":return styleText("green",S_BAR)}};function formatInstructionFooter(o,e){let r2=[`${e?`${styleText("cyan",S_BAR)} `:""}${o.join(" \u2022 ")}`];return e&&r2.push(styleText("cyan",S_BAR_END)),r2}var I=(l,e,w,p2,b2,C2=!1)=>{let r2=e,O=0;if(C2)for(let i2=p2-1;i2>=w;i2--){let m2=l[i2];if(m2&&(r2-=m2.length),O++,r2<=b2)break}else for(let i2=w;i2<p2;i2++){let m2=l[i2];if(m2&&(r2-=m2.length),O++,r2<=b2)break}return{lineCount:r2,removals:O}},limitOptions=({cursor:l,options:e,style:w,output:p2=process.stdout,maxItems:b2=Number.POSITIVE_INFINITY,columnPadding:C2=0,rowPadding:r2=4})=>{let i2=getColumns(p2)-C2,m2=getRows(p2),M=styleText("dim","..."),v=Math.max(m2-r2,0),a2=Math.max(Math.min(b2,v),5),f=0;l>=a2-3&&(f=Math.max(Math.min(l-a2+3,e.length-a2),0));let d=a2<e.length&&f>0,c2=a2<e.length&&f+a2<e.length,W2=Math.min(f+a2,e.length),s=[],g=0;d&&g++,c2&&g++;let T=f+(d?1:0),y=W2-(c2?1:0);for(let t=T;t<y;t++){let n2=e[t],o=n2?w(n2,t===l):"",h2=wrapAnsi(o,i2,{hard:!0,trim:!1}).split(`
|
|
3
|
+
`);s.push(h2),g+=h2.length}if(g>v){let t=0,n2=0,o=g,h2=l-T,u3=v,L=()=>I(s,o,0,h2,u3),E2=()=>I(s,o,h2+1,s.length,u3,!0);d?({lineCount:o,removals:t}=L(),o>u3&&(c2||(u3-=1),{lineCount:o,removals:n2}=E2())):(c2||(u3-=1),{lineCount:o,removals:n2}=E2(),o>u3&&(u3-=1,{lineCount:o,removals:t}=L())),t>0&&(d=!0,s.splice(0,t)),n2>0&&(c2=!0,s.splice(s.length-n2,n2))}let x2=[];d&&x2.push(M);for(let t of s)for(let n2 of t)x2.push(n2);return c2&&x2.push(M),x2};function P(t){return t.label??String(t.value??"")}function E(t,c2){if(!t)return!0;let n2=(c2.label??String(c2.value??"")).toLowerCase(),i2=(c2.hint??"").toLowerCase(),l=String(c2.value).toLowerCase(),o=t.toLowerCase();return n2.includes(o)||i2.includes(o)||l.includes(o)}function N(t,c2){let n2=[];for(let i2 of c2)t.includes(i2.value)&&n2.push(i2);return n2}var autocomplete=t=>new T$1({options:t.options,initialValue:t.initialValue?[t.initialValue]:void 0,initialUserInput:t.initialUserInput,placeholder:t.placeholder,filter:t.filter??((n2,i2)=>E(n2,i2)),signal:t.signal,input:t.input,output:t.output,validate:t.validate,render(){let n2=t.withGuide??settings.withGuide,i2=n2?[`${styleText("gray",S_BAR)}`,`${symbol(this.state)} ${t.message}`]:[`${symbol(this.state)} ${t.message}`],l=this.userInput,o=this.options,m2=t.placeholder,p2=l===""&&m2!==void 0,$=(r2,s)=>{let a2=P(r2),u3=r2.hint&&r2.value===this.focusedValue?styleText("dim",` (${r2.hint})`):"";switch(s){case"active":return`${styleText("green",S_RADIO_ACTIVE)} ${a2}${u3}`;case"inactive":return`${styleText("dim",S_RADIO_INACTIVE)} ${styleText("dim",a2)}`;case"disabled":return`${styleText("gray",S_RADIO_INACTIVE)} ${styleText(["strikethrough","gray"],a2)}`}};switch(this.state){case"submit":{let r2=N(this.selectedValues,o),s=r2.length>0?` ${styleText("dim",r2.map(P).join(", "))}`:"",a2=n2?styleText("gray",S_BAR):"";return`${i2.join(`
|
|
4
|
+
`)}
|
|
5
|
+
${a2}${s}`}case"cancel":{let r2=l?` ${styleText(["strikethrough","dim"],l)}`:"",s=n2?styleText("gray",S_BAR):"";return`${i2.join(`
|
|
6
|
+
`)}
|
|
7
|
+
${s}${r2}`}default:{let r2=this.state==="error"?"yellow":"cyan",s=n2?`${styleText(r2,S_BAR)} `:"",a2=n2?styleText(r2,S_BAR_END):"",u3="";if(this.isNavigating||p2){let d=p2?m2:l;u3=d!==""?` ${styleText("dim",d)}`:""}else u3=` ${this.userInputWithCursor}`;let V=this.filteredOptions.length!==o.length?styleText("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",y=this.filteredOptions.length===0&&l?[`${s}${styleText("yellow","No matches found")}`]:[],b2=this.state==="error"?[`${s}${styleText("yellow",this.error)}`]:[];n2&&i2.push(`${s.trimEnd()}`),i2.push(`${s}${styleText("dim","Search:")}${u3}${V}`,...y,...b2);let v=[`${styleText("dim","\u2191/\u2193")} to select`,`${styleText("dim","Enter:")} confirm`,`${styleText("dim","Type:")} to search`],g=[`${s}${v.join(" \u2022 ")}`,a2],O=this.filteredOptions.length===0?[]:limitOptions({cursor:this.cursor,options:this.filteredOptions,columnPadding:n2?3:0,rowPadding:i2.length+g.length,style:(d,f)=>$(d,d.disabled?"disabled":f?"active":"inactive"),maxItems:t.maxItems,output:t.output});return[...i2,...O.map(d=>`${s}${d}`),...g].join(`
|
|
8
|
+
`)}}}}).prompt(),autocompleteMultiselect=t=>{let c2=(i2,l,o,m2)=>{let p2=o.includes(i2.value),$=i2.label??String(i2.value??""),r2=i2.hint&&m2!==void 0&&i2.value===m2?styleText("dim",` (${i2.hint})`):"",s=p2?styleText("green",S_CHECKBOX_SELECTED):styleText("dim",S_CHECKBOX_INACTIVE);return i2.disabled?`${styleText("gray",S_CHECKBOX_INACTIVE)} ${styleText(["strikethrough","gray"],$)}`:l?`${s} ${$}${r2}`:`${s} ${styleText("dim",$)}`},n2=new T$1({options:t.options,multiple:!0,placeholder:t.placeholder,filter:t.filter??((i2,l)=>E(i2,l)),validate:()=>{if(t.required&&n2.selectedValues.length===0)return"Please select at least one item"},initialValue:t.initialValues,signal:t.signal,input:t.input,output:t.output,render(){let i2=t.withGuide??settings.withGuide,l=`${i2?`${styleText("gray",S_BAR)}
|
|
9
|
+
`:""}${symbol(this.state)} ${t.message}
|
|
10
|
+
`,o=this.userInput,m2=t.placeholder,p2=o===""&&m2!==void 0,$=this.isNavigating||p2?styleText("dim",p2?m2:o):this.userInputWithCursor,r2=this.options,s=this.filteredOptions.length!==r2.length?styleText("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${l}${i2?`${styleText("gray",S_BAR)} `:""}${styleText("dim",`${this.selectedValues.length} items selected`)}`;case"cancel":return`${l}${i2?`${styleText("gray",S_BAR)} `:""}${styleText(["strikethrough","dim"],o)}`;default:{let a2=this.state==="error"?"yellow":"cyan",u3=i2?`${styleText(a2,S_BAR)} `:"",V=i2?styleText(a2,S_BAR_END):"",y=[`${styleText("dim","\u2191/\u2193")} to navigate`,`${styleText("dim",this.isNavigating?"Space/Tab:":"Tab:")} select`,`${styleText("dim","Enter:")} confirm`,`${styleText("dim","Type:")} to search`],b2=this.filteredOptions.length===0&&o?[`${u3}${styleText("yellow","No matches found")}`]:[],v=this.state==="error"?[`${u3}${styleText("yellow",this.error)}`]:[],g=[...`${l}${i2?styleText(a2,S_BAR):""}`.split(`
|
|
11
|
+
`),`${u3}${styleText("dim","Search:")} ${$}${s}`,...b2,...v],O=[`${u3}${y.join(" \u2022 ")}`,V],d=limitOptions({cursor:this.cursor,options:this.filteredOptions,style:(f,_)=>c2(f,_,this.selectedValues,this.focusedValue),maxItems:t.maxItems,output:t.output,rowPadding:g.length+O.length});return[...g,...d.map(f=>`${u3}${f}`),...O].join(`
|
|
12
|
+
`)}}}});return n2.prompt()},J=[S_CORNER_TOP_LEFT,S_CORNER_TOP_RIGHT,S_CORNER_BOTTOM_LEFT,S_CORNER_BOTTOM_RIGHT],K=[S_BAR_START,S_BAR_START_RIGHT,S_BAR_END,S_BAR_END_RIGHT];function A$1(n2,e,t,o){let i2=t,f=t;return o==="center"?i2=Math.floor((e-n2)/2):o==="right"&&(i2=e-n2-t),f=e-i2-n2,[i2,f]}var Q=n2=>n2,box=(n2="",e="",t)=>{let o=t?.output??process.stdout,i2=getColumns(o),R=2,u3=t?.titlePadding??1,h2=t?.contentPadding??2,w=t?.width===void 0||t.width==="auto"?1:Math.min(1,t.width),m2=t?.withGuide??settings.withGuide?`${S_BAR} `:"",b2=t?.formatBorder??Q,a2=(t?.rounded?J:K).map(b2),_=b2(S_BAR_H),B=b2(S_BAR),p2=dist_default(m2),x2=dist_default(e),O=i2-p2,r2=Math.floor(i2*w)-p2;if(t?.width==="auto"){let c2=n2.split(`
|
|
13
|
+
`),s=x2+u3*2;for(let G of c2){let P2=dist_default(G)+h2*2;P2>s&&(s=P2)}let g=s+R;g<r2&&(r2=g)}r2%2!==0&&(r2<O?r2++:r2--);let d=r2-R,S=d-u3*2,T=x2>S?`${e.slice(0,S-3)}...`:e,[y,W2]=A$1(dist_default(T),d,u3,t?.titleAlign),L=wrapAnsi(n2,d-h2*2,{hard:!0,trim:!1});o.write(`${m2}${a2[0]}${_.repeat(y)}${T}${_.repeat(W2)}${a2[1]}
|
|
14
|
+
`);let E2=L.split(`
|
|
15
|
+
`);for(let c2 of E2){let[s,g]=A$1(dist_default(c2),d,h2,t?.contentAlign);o.write(`${m2}${B}${" ".repeat(s)}${c2}${" ".repeat(g)}${B}
|
|
16
|
+
`)}o.write(`${m2}${a2[2]}${_.repeat(d)}${a2[3]}
|
|
17
|
+
`)},confirm=i2=>{let a2=i2.active??"Yes",s=i2.inactive??"No";return new r({active:a2,inactive:s,signal:i2.signal,input:i2.input,output:i2.output,initialValue:i2.initialValue??!0,render(){let e=i2.withGuide??settings.withGuide,u3=`${symbol(this.state)} `,l=e?`${styleText("gray",S_BAR)} `:"",f=wrapTextWithPrefix(i2.output,i2.message,l,u3),o=`${e?`${styleText("gray",S_BAR)}
|
|
18
|
+
`:""}${f}
|
|
19
|
+
`,c2=this.value?a2:s;switch(this.state){case"submit":{let r2=e?`${styleText("gray",S_BAR)} `:"";return`${o}${r2}${styleText("dim",c2)}`}case"cancel":{let r2=e?`${styleText("gray",S_BAR)} `:"";return`${o}${r2}${styleText(["strikethrough","dim"],c2)}${e?`
|
|
20
|
+
${styleText("gray",S_BAR)}`:""}`}default:{let r2=e?`${styleText("cyan",S_BAR)} `:"",g=e?styleText("cyan",S_BAR_END):"";return`${o}${r2}${this.value?`${styleText("green",S_RADIO_ACTIVE)} ${a2}`:`${styleText("dim",S_RADIO_INACTIVE)} ${styleText("dim",a2)}`}${i2.vertical?e?`
|
|
21
|
+
${styleText("cyan",S_BAR)} `:`
|
|
22
|
+
`:` ${styleText("dim","/")} `}${this.value?`${styleText("dim",S_RADIO_INACTIVE)} ${styleText("dim",s)}`:`${styleText("green",S_RADIO_ACTIVE)} ${s}`}
|
|
23
|
+
${g}
|
|
24
|
+
`}}}}).prompt()},date=e=>{let r2=e.validate;return new U({...e,validate(t){if(t===void 0)return e.defaultValue!==void 0?void 0:r2?runValidation(r2,t):settings.date.messages.required;let o=i2=>i2.toISOString().slice(0,10);if(e.minDate&&o(t)<o(e.minDate))return settings.date.messages.afterMin(e.minDate);if(e.maxDate&&o(t)>o(e.maxDate))return settings.date.messages.beforeMax(e.maxDate);if(r2)return runValidation(r2,t)},render(){let t=(e?.withGuide??settings.withGuide)!==!1,i2=`${`${t?`${styleText("gray",S_BAR)}
|
|
25
|
+
`:""}${symbol(this.state)} `}${e.message}
|
|
26
|
+
`,l=this.state!=="initial"?this.state:"active",d=b(this,l),c2=this.value instanceof Date?this.formattedValue:"";switch(this.state){case"error":{let a2=this.error?` ${styleText("yellow",this.error)}`:"",s=t?`${styleText("yellow",S_BAR)} `:"",f=t?styleText("yellow",S_BAR_END):"";return`${i2.trim()}
|
|
27
|
+
${s}${d}
|
|
28
|
+
${f}${a2}
|
|
29
|
+
`}case"submit":{let a2=c2?` ${styleText("dim",c2)}`:"",s=t?styleText("gray",S_BAR):"";return`${i2}${s}${a2}`}case"cancel":{let a2=c2?` ${styleText(["strikethrough","dim"],c2)}`:"",s=t?styleText("gray",S_BAR):"";return`${i2}${s}${a2}${c2.trim()?`
|
|
30
|
+
${s}`:""}`}default:{let a2=t?`${styleText("cyan",S_BAR)} `:"",s=t?styleText("cyan",S_BAR_END):"",f=t?`${styleText("cyan",S_BAR)} `:"",g=this.inlineError?`
|
|
31
|
+
${f}${styleText("yellow",this.inlineError)}`:"";return`${i2}${a2}${d}${g}
|
|
32
|
+
${s}
|
|
33
|
+
`}}}}).prompt()};function b(e,r2){let t=e.segmentValues,o=e.segmentCursor;if(r2==="submit"||r2==="cancel")return e.formattedValue;let i2=styleText("gray",e.separator);return e.segments.map((l,d)=>{let c2=d===o.segmentIndex&&!["submit","cancel"].includes(r2),a2=p[l.type];return x(t[l.type],{isActive:c2,label:a2})}).join(i2)}function x(e,r2){let t=!e||e.replace(/_/g,"")==="";return r2.isActive?styleText("inverse",t?r2.label:e.replace(/_/g," ")):t?styleText("dim",r2.label):e.replace(/_/g,styleText("dim"," "))}var p={year:"yyyy",month:"mm",day:"dd"},group=async(o,r2)=>{let t={},p2=Object.keys(o);for(let e of p2){let i2=o[e],n2=await i2({results:t})?.catch(a2=>{throw a2});if(typeof r2?.onCancel=="function"&&isCancel(n2)){t[e]="canceled",r2.onCancel({results:t});continue}t[e]=n2}return t},MULTISELECT_INSTRUCTIONS=[`${styleText("dim","\u2191/\u2193")} to navigate`,`${styleText("dim","Space:")} select`,`${styleText("dim","Enter:")} confirm`],m=(i2,u3)=>i2.split(`
|
|
34
|
+
`).map(d=>u3(d)).join(`
|
|
35
|
+
`),multiselect=i2=>{let u3=(t,a2)=>{let r2=t.label??String(t.value);return a2==="disabled"?`${styleText("gray",S_CHECKBOX_INACTIVE)} ${m(r2,o=>styleText(["strikethrough","gray"],o))}${t.hint?` ${styleText("dim",`(${t.hint??"disabled"})`)}`:""}`:a2==="active"?`${styleText("cyan",S_CHECKBOX_ACTIVE)} ${r2}${t.hint?` ${styleText("dim",`(${t.hint})`)}`:""}`:a2==="selected"?`${styleText("green",S_CHECKBOX_SELECTED)} ${m(r2,o=>styleText("dim",o))}${t.hint?` ${styleText("dim",`(${t.hint})`)}`:""}`:a2==="cancelled"?`${m(r2,o=>styleText(["strikethrough","dim"],o))}`:a2==="active-selected"?`${styleText("green",S_CHECKBOX_SELECTED)} ${r2}${t.hint?` ${styleText("dim",`(${t.hint})`)}`:""}`:a2==="submitted"?`${m(r2,o=>styleText("dim",o))}`:`${styleText("dim",S_CHECKBOX_INACTIVE)} ${m(r2,o=>styleText("dim",o))}`},d=i2.required??!0,v=i2.showInstructions??!0;return new a({options:i2.options,signal:i2.signal,input:i2.input,output:i2.output,initialValues:i2.initialValues,required:d,cursorAt:i2.cursorAt,validate(t){if(d&&(t===void 0||t.length===0))return`Please select at least one option.
|
|
36
|
+
${styleText("reset",styleText("dim",`Press ${styleText(["gray","bgWhite","inverse"]," space ")} to select, ${styleText("gray",styleText("bgWhite",styleText("inverse"," enter ")))} to submit`))}`},render(){let t=i2.withGuide??settings.withGuide,a2=wrapTextWithPrefix(i2.output,i2.message,t?`${symbolBar(this.state)} `:"",`${symbol(this.state)} `),r2=`${t?`${styleText("gray",S_BAR)}
|
|
37
|
+
`:""}${a2}
|
|
38
|
+
`,o=this.value??[],p2=(n2,l)=>{if(n2.disabled)return u3(n2,"disabled");let s=o.includes(n2.value);return l&&s?u3(n2,"active-selected"):s?u3(n2,"selected"):u3(n2,l?"active":"inactive")};switch(this.state){case"submit":{let n2=this.options.filter(({value:s})=>o.includes(s)).map(s=>u3(s,"submitted")).join(styleText("dim",", "))||styleText("dim","none"),l=wrapTextWithPrefix(i2.output,n2,t?`${styleText("gray",S_BAR)} `:"");return`${r2}${l}`}case"cancel":{let n2=this.options.filter(({value:s})=>o.includes(s)).map(s=>u3(s,"cancelled")).join(styleText("dim",", "));if(n2.trim()==="")return`${r2}${styleText("gray",S_BAR)}`;let l=wrapTextWithPrefix(i2.output,n2,t?`${styleText("gray",S_BAR)} `:"");return`${r2}${l}${t?`
|
|
39
|
+
${styleText("gray",S_BAR)}`:""}`}case"error":{let n2=t?`${styleText("yellow",S_BAR)} `:"",l=this.error.split(`
|
|
40
|
+
`).map(($,C2)=>C2===0?`${t?`${styleText("yellow",S_BAR_END)} `:""}${styleText("yellow",$)}`:` ${$}`).join(`
|
|
41
|
+
`),s=r2.split(`
|
|
42
|
+
`).length,h2=l.split(`
|
|
43
|
+
`).length+1;return`${r2}${n2}${limitOptions({output:i2.output,options:this.options,cursor:this.cursor,maxItems:i2.maxItems,columnPadding:n2.length,rowPadding:s+h2,style:p2}).join(`
|
|
44
|
+
${n2}`)}
|
|
45
|
+
${l}
|
|
46
|
+
`}default:{let n2=t?`${styleText("cyan",S_BAR)} `:"",l=r2.split(`
|
|
47
|
+
`).length,s=v?formatInstructionFooter(MULTISELECT_INSTRUCTIONS,t):t?[styleText("cyan",S_BAR_END)]:[],h2=s.join(`
|
|
48
|
+
`),$=s.length+1;return`${r2}${n2}${limitOptions({output:i2.output,options:this.options,cursor:this.cursor,maxItems:i2.maxItems,columnPadding:n2.length,rowPadding:l+$,style:p2}).join(`
|
|
49
|
+
${n2}`)}
|
|
50
|
+
${h2}
|
|
51
|
+
`}}}}).prompt()},groupMultiselect=o=>{let{selectableGroups:h2=!0,groupSpacing:x2=0}=o,m2=(n2,l,g=[])=>{let a2=n2.label??String(n2.value),t=typeof n2.group=="string",s=t&&(g[g.indexOf(n2)+1]??{group:!0}),u3=t&&s&&s.group===!0,r2="",c2="";t&&(h2?(r2=u3?`${S_BAR_END} `:`${S_BAR} `,c2=u3?" ":`${S_BAR} `):r2=" ");let i2="";if(x2>0&&!t&&(i2=`
|
|
52
|
+
`.repeat(x2)),l==="active")return wrapTextWithPrefix(o.output,`${a2}${n2.hint?` ${styleText("dim",`(${n2.hint})`)}`:""}`,`${i2}${styleText("dim",r2)} `,`${i2}${styleText("dim",r2)}${styleText("cyan",S_CHECKBOX_ACTIVE)} `,`${i2}${styleText("dim",c2)} `);if(l==="group-active")return wrapTextWithPrefix(o.output,a2,`${i2}${r2} `,`${i2}${r2}${styleText("cyan",S_CHECKBOX_ACTIVE)} `,`${i2}${c2} `,d=>styleText("dim",d));if(l==="group-active-selected")return wrapTextWithPrefix(o.output,a2,`${i2}${r2} `,`${i2}${r2}${styleText("green",S_CHECKBOX_SELECTED)} `,`${i2}${c2} `,d=>styleText("dim",d));if(l==="selected"){let d=t||h2?styleText("green",S_CHECKBOX_SELECTED):"";return wrapTextWithPrefix(o.output,`${a2}${n2.hint?` (${n2.hint})`:""}`,`${i2}${styleText("dim",r2)} `,`${i2}${styleText("dim",r2)}${d} `,`${i2}${styleText("dim",c2)} `,S=>styleText("dim",S))}if(l==="cancelled")return`${styleText(["strikethrough","dim"],a2)}`;if(l==="active-selected")return wrapTextWithPrefix(o.output,`${a2}${n2.hint?` ${styleText("dim",`(${n2.hint})`)}`:""}`,`${i2}${styleText("dim",r2)} `,`${i2}${styleText("dim",r2)}${styleText("green",S_CHECKBOX_SELECTED)} `,`${i2}${styleText("dim",c2)} `);if(l==="submitted")return`${styleText("dim",a2)}`;let f=t||h2?styleText("dim",S_CHECKBOX_INACTIVE):"";return wrapTextWithPrefix(o.output,a2,`${i2}${styleText("dim",r2)} `,`${i2}${styleText("dim",r2)}${f} `,`${i2}${styleText("dim",c2)} `,d=>styleText("dim",d))},y=o.required??!0,I2=o.showInstructions??!0;return new u$2({options:o.options,signal:o.signal,input:o.input,output:o.output,initialValues:o.initialValues,required:y,cursorAt:o.cursorAt,selectableGroups:h2,validate(n2){if(y&&(n2===void 0||n2.length===0))return`Please select at least one option.
|
|
53
|
+
${styleText("reset",styleText("dim",`Press ${styleText(["gray","bgWhite","inverse"]," space ")} to select, ${styleText("gray",styleText(["bgWhite","inverse"]," enter "))} to submit`))}`},render(){let n2=o.withGuide??settings.withGuide,l=`${n2?`${styleText("gray",S_BAR)}
|
|
54
|
+
`:""}${symbol(this.state)} ${o.message}
|
|
55
|
+
`,g=this.value??[],a2=(t,s)=>{let u3=this.options,r2=g.includes(t.value)||t.group===!0&&this.isGroupSelected(`${t.value}`);return!s&&typeof t.group=="string"&&this.options[this.cursor]?.value===t.group?m2(t,r2?"group-active-selected":"group-active",u3):s&&r2?m2(t,"active-selected",u3):r2?m2(t,"selected",u3):m2(t,s?"active":"inactive",u3)};switch(this.state){case"submit":{let t=this.options.filter(({value:u3})=>g.includes(u3)).map(u3=>m2(u3,"submitted")),s=t.length===0?"":` ${t.join(styleText("dim",", "))}`;return`${l}${n2?styleText("gray",S_BAR):""}${s}`}case"cancel":{let t=this.options.filter(({value:s})=>g.includes(s)).map(s=>m2(s,"cancelled")).join(styleText("dim",", "));return`${l}${n2?`${styleText("gray",S_BAR)} `:""}${t.trim()?`${t}${n2?`
|
|
56
|
+
${styleText("gray",S_BAR)}`:""}`:""}`}case"error":{let t=n2?`${styleText("yellow",S_BAR)} `:"",s=this.error.split(`
|
|
57
|
+
`).map((i2,f)=>f===0?`${n2?`${styleText("yellow",S_BAR_END)} `:""}${styleText("yellow",i2)}`:` ${i2}`).join(`
|
|
58
|
+
`),u3=l.split(`
|
|
59
|
+
`).length,r2=s.split(`
|
|
60
|
+
`).length+1,c2=limitOptions({output:o.output,options:this.options,cursor:this.cursor,maxItems:o.maxItems,columnPadding:t.length,rowPadding:u3+r2,style:a2}).join(`
|
|
61
|
+
${t}`);return`${l}${t}${c2}
|
|
62
|
+
${s}
|
|
63
|
+
`}default:{let t=n2?`${styleText("cyan",S_BAR)} `:"",s=l.split(`
|
|
64
|
+
`).length,u3=I2?formatInstructionFooter(MULTISELECT_INSTRUCTIONS,n2):n2?[styleText("cyan",S_BAR_END)]:[],r2=u3.join(`
|
|
65
|
+
`),c2=u3.length+1,i2=limitOptions({output:o.output,options:this.options,cursor:this.cursor,maxItems:o.maxItems,columnPadding:t.length,rowPadding:s+c2,style:a2}).join(`
|
|
66
|
+
${t}`);return`${l}${t}${i2}
|
|
67
|
+
${r2}
|
|
68
|
+
`}}}}).prompt()},log={message:(s=[],{symbol:e=styleText("gray",S_BAR),secondarySymbol:r2=styleText("gray",S_BAR),output:m2=process.stdout,spacing:l=1,withGuide:c2}={})=>{let t=[],o=c2??settings.withGuide,f=o?r2:"",O=o?`${e} `:"",u3=o?`${r2} `:"";for(let i2=0;i2<l;i2++)t.push(f);let g=Array.isArray(s)?s:s.split(`
|
|
69
|
+
`);if(g.length>0){let[i2,...y]=g;i2.length>0?t.push(`${O}${i2}`):t.push(o?e:"");for(let p2 of y)p2.length>0?t.push(`${u3}${p2}`):t.push(o?r2:"")}m2.write(`${t.join(`
|
|
70
|
+
`)}
|
|
71
|
+
`)},info:(s,e)=>{log.message(s,{...e,symbol:styleText("blue",S_INFO)})},success:(s,e)=>{log.message(s,{...e,symbol:styleText("green",S_SUCCESS)})},step:(s,e)=>{log.message(s,{...e,symbol:styleText("green",S_STEP_SUBMIT)})},warn:(s,e)=>{log.message(s,{...e,symbol:styleText("yellow",S_WARN)})},warning:(s,e)=>{log.warn(s,e)},error:(s,e)=>{log.message(s,{...e,symbol:styleText("red",S_ERROR)})}},cancel=(o="",t)=>{let i2=t?.output??process.stdout,e=t?.withGuide??settings.withGuide?`${styleText("gray",S_BAR_END)} `:"";i2.write(`${e}${styleText("red",o)}
|
|
72
|
+
|
|
73
|
+
`)},intro=(o="",t)=>{let i2=t?.output??process.stdout,e=t?.withGuide??settings.withGuide?`${styleText("gray",S_BAR_START)} `:"";i2.write(`${e}${o}
|
|
74
|
+
`)},outro=(o="",t)=>{let i2=t?.output??process.stdout,e=t?.withGuide??settings.withGuide?`${styleText("gray",S_BAR)}
|
|
75
|
+
${styleText("gray",S_BAR_END)} `:"";i2.write(`${e}${o}
|
|
76
|
+
|
|
77
|
+
`)},multiline=e=>new h({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,showSubmit:e.showSubmit,output:e.output,signal:e.signal,input:e.input,render(){let i2=e?.withGuide??settings.withGuide,o=`${`${i2?`${styleText("gray",S_BAR)}
|
|
78
|
+
`:""}${symbol(this.state)} `}${e.message}
|
|
79
|
+
`,m2=e.placeholder&&e.placeholder.length>0?styleText("inverse",e.placeholder[0])+styleText("dim",e.placeholder.slice(1)):styleText(["inverse","hidden"],"_"),a2=this.userInput?this.userInputWithCursor:m2,l=this.value??"",c2=e.showSubmit?`
|
|
80
|
+
${styleText(this.focused==="submit"?"cyan":"dim","[ submit ]")}`:"";switch(this.state){case"error":{let n2=`${styleText("yellow",S_BAR)} `,r2=i2?wrapTextWithPrefix(e.output,a2,n2,void 0):a2,u3=styleText("yellow",S_BAR_END);return`${o}${r2}
|
|
81
|
+
${u3} ${styleText("yellow",this.error)}${c2}
|
|
82
|
+
`}case"submit":{let n2=`${styleText("gray",S_BAR)} `,r2=i2?wrapTextWithPrefix(e.output,l,n2,void 0,void 0,u3=>styleText("dim",u3)):l?styleText("dim",l):"";return`${o}${r2}`}case"cancel":{let n2=`${styleText("gray",S_BAR)} `,r2=i2?wrapTextWithPrefix(e.output,l,n2,void 0,void 0,u3=>styleText(["strikethrough","dim"],u3)):l?styleText(["strikethrough","dim"],l):"";return`${o}${r2}`}default:{let n2=i2?`${styleText("cyan",S_BAR)} `:"",r2=i2?styleText("cyan",S_BAR_END):"",u3=i2?wrapTextWithPrefix(e.output,a2,n2):a2;return`${o}${u3}
|
|
83
|
+
${r2}${c2}
|
|
84
|
+
`}}}}).prompt(),W$1=o=>o,C=(o,e,s)=>{let a2={hard:!0,trim:!1},i2=wrapAnsi(o,e,a2).split(`
|
|
85
|
+
`),c2=i2.reduce((n2,t)=>Math.max(dist_default(t),n2),0),u3=i2.map(s).reduce((n2,t)=>Math.max(dist_default(t),n2),0),g=e-(u3-c2);return wrapAnsi(o,g,a2)},note=(o="",e="",s)=>{let a2=s?.output??process$1.stdout,i2=s?.withGuide??settings.withGuide,c2=s?.format??W$1,g=["",...C(o,getColumns(a2)-6,c2).split(`
|
|
86
|
+
`).map(c2),""],n2=dist_default(e),t=Math.max(g.reduce((m2,F)=>{let O=dist_default(F);return O>m2?O:m2},0),n2)+2,h2=g.map(m2=>`${styleText("gray",S_BAR)} ${m2}${" ".repeat(t-dist_default(m2))}${styleText("gray",S_BAR)}`).join(`
|
|
87
|
+
`),T=i2?`${styleText("gray",S_BAR)}
|
|
88
|
+
`:"",l$1=i2?S_CONNECT_LEFT:S_CORNER_BOTTOM_LEFT;a2.write(`${T}${styleText("green",S_STEP_SUBMIT)} ${styleText("reset",e)} ${styleText("gray",S_BAR_H.repeat(Math.max(t-n2-1,1))+S_CORNER_TOP_RIGHT)}
|
|
89
|
+
${h2}
|
|
90
|
+
${styleText("gray",l$1+S_BAR_H.repeat(t+2)+S_CORNER_BOTTOM_RIGHT)}
|
|
91
|
+
`)},password=r2=>new u$1({validate:r2.validate,mask:r2.mask??S_PASSWORD_MASK,signal:r2.signal,input:r2.input,output:r2.output,render(){let e=r2.withGuide??settings.withGuide,o=`${e?`${styleText("gray",S_BAR)}
|
|
92
|
+
`:""}${symbol(this.state)} ${r2.message}
|
|
93
|
+
`,c2=this.userInputWithCursor,i2=this.masked;switch(this.state){case"error":{let s=e?`${styleText("yellow",S_BAR)} `:"",n2=e?`${styleText("yellow",S_BAR_END)} `:"",l=i2??"";return r2.clearOnError&&this.clear(),`${o.trim()}
|
|
94
|
+
${s}${l}
|
|
95
|
+
${n2}${styleText("yellow",this.error)}
|
|
96
|
+
`}case"submit":{let s=e?`${styleText("gray",S_BAR)} `:"",n2=i2?styleText("dim",i2):"";return`${o}${s}${n2}`}case"cancel":{let s=e?`${styleText("gray",S_BAR)} `:"",n2=i2?styleText(["strikethrough","dim"],i2):"";return`${o}${s}${n2}${i2&&e?`
|
|
97
|
+
${styleText("gray",S_BAR)}`:""}`}default:{let s=e?`${styleText("cyan",S_BAR)} `:"",n2=e?styleText("cyan",S_BAR_END):"";return`${o}${s}${c2}
|
|
98
|
+
${n2}
|
|
99
|
+
`}}}}).prompt(),path=e=>{let a2=e.validate;return autocomplete({...e,initialUserInput:e.initialValue??e.root??process.cwd(),maxItems:5,validate(t){if(!Array.isArray(t)){if(!t)return"Please select a path";if(a2)return runValidation(a2,t)}},options(){let t=this.userInput;if(t==="")return[];try{let i2;existsSync(t)?lstatSync(t).isDirectory()&&(!e.directory||t.endsWith("/"))?i2=t:i2=dirname(t):i2=dirname(t);let c2=t.length>1&&t.endsWith("/")?t.slice(0,-1):t;return readdirSync(i2).map(r2=>{let n2=join(i2,r2),m2=lstatSync(n2);return{name:r2,path:n2,isDirectory:m2.isDirectory()}}).filter(({path:r2,isDirectory:n2})=>r2.startsWith(c2)&&(n2||!e.directory)).map(r2=>({value:r2.path}))}catch{return[]}}})},W=l=>styleText("magenta",l),spinner=({indicator:l="dots",onCancel:h2,output:n2=process.stdout,cancelMessage:G,errorMessage:O,frames:E2=unicode?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:F=unicode?80:120,signal:m2,...I2}={})=>{let u3=isCI(),M,T,d=!1,S=!1,s="",p2,w=performance.now(),x2=getColumns(n2),k=I2?.styleFrame??W,g=e=>{let r2=e>1?O??settings.messages.error:G??settings.messages.cancel;S=e===1,d&&(a2(r2,e),S&&typeof h2=="function"&&h2())},f=()=>g(2),i2=()=>g(1),A2=()=>{process.on("uncaughtExceptionMonitor",f),process.on("unhandledRejection",f),process.on("SIGINT",i2),process.on("SIGTERM",i2),process.on("exit",g),m2&&m2.addEventListener("abort",i2)},H=()=>{process.removeListener("uncaughtExceptionMonitor",f),process.removeListener("unhandledRejection",f),process.removeListener("SIGINT",i2),process.removeListener("SIGTERM",i2),process.removeListener("exit",g),m2&&m2.removeEventListener("abort",i2)},y=()=>{if(p2===void 0)return;u3&&n2.write(`
|
|
100
|
+
`);let r2=wrapAnsi(p2,x2,{hard:!0,trim:!1}).split(`
|
|
101
|
+
`);r2.length>1&&n2.write(import_sisteransi.cursor.up(r2.length-1)),n2.write(import_sisteransi.cursor.to(0)),n2.write(import_sisteransi.erase.down())},C2=e=>e.replace(/\.+$/,""),_=e=>{let r2=(performance.now()-e)/1e3,t=Math.floor(r2/60),o=Math.floor(r2%60);return t>0?`[${t}m ${o}s]`:`[${o}s]`},N2=I2.withGuide??settings.withGuide,P2=(e="")=>{d=!0,M=block({output:n2}),s=C2(e),w=performance.now(),N2&&n2.write(`${styleText("gray",S_BAR)}
|
|
102
|
+
`);let r2=0,t=0;A2(),T=setInterval(()=>{if(u3&&s===p2)return;y(),p2=s;let o=k(E2[r2]),v;if(u3)v=`${o} ${s}...`;else if(l==="timer")v=`${o} ${s} ${_(w)}`;else{let B=".".repeat(Math.floor(t)).slice(0,3);v=`${o} ${s}${B}`}let j=wrapAnsi(v,x2,{hard:!0,trim:!1});n2.write(j),r2=r2+1<E2.length?r2+1:0,t=t<4?t+.125:0},F)},a2=(e="",r2=0,t=!1)=>{if(!d)return;d=!1,clearInterval(T),y();let o=r2===0?styleText("green",S_STEP_SUBMIT):r2===1?styleText("red",S_STEP_CANCEL):styleText("red",S_STEP_ERROR);s=e??s,t||(l==="timer"?n2.write(`${o} ${s} ${_(w)}
|
|
103
|
+
`):n2.write(`${o} ${s}
|
|
104
|
+
`)),H(),M()};return{start:P2,stop:(e="")=>a2(e,0),message:(e="")=>{s=C2(e??s)},cancel:(e="")=>a2(e,1),error:(e="")=>a2(e,2),clear:()=>a2("",0,!0),get isCancelled(){return S}}},u2={light:unicodeOr("\u2500","-"),heavy:unicodeOr("\u2501","="),block:unicodeOr("\u2588","#")};function progress({style:o="heavy",max:d=100,size:v=40,...x2}={}){let r2=spinner(x2),a2=0,n2="",c2=Math.max(1,d),l=Math.max(1,v),S=t=>{switch(t){case"initial":case"active":return e=>styleText("magenta",e);case"error":case"cancel":return e=>styleText("red",e);case"submit":return e=>styleText("green",e);default:return e=>styleText("magenta",e)}},p2=(t,e)=>{let m2=Math.floor(a2/c2*l);return`${S(t)(u2[o].repeat(m2))}${styleText("dim",u2[o].repeat(l-m2))} ${e}`},h2=(t="")=>{n2=t,r2.start(p2("initial",t))},g=(t=1,e)=>{a2=Math.min(c2,t+a2),r2.message(p2("active",e??n2)),n2=e??n2};return{start:h2,stop:r2.stop,cancel:r2.cancel,error:r2.error,clear:r2.clear,advance:g,isCancelled:r2.isCancelled,message:t=>g(0,t)}}var SELECT_INSTRUCTIONS=[`${styleText("dim","\u2191/\u2193")} to navigate`,`${styleText("dim","Enter:")} confirm`],c=(t,o)=>t.includes(`
|
|
105
|
+
`)?t.split(`
|
|
106
|
+
`).map(d=>o(d)).join(`
|
|
107
|
+
`):o(t),select=t=>{let o=(n2,m2)=>{if(n2===void 0)return"";let s=n2.label??String(n2.value);switch(m2){case"disabled":return`${styleText("gray",S_RADIO_INACTIVE)} ${c(s,i2=>styleText("gray",i2))}${n2.hint?` ${styleText("dim",`(${n2.hint??"disabled"})`)}`:""}`;case"selected":return`${c(s,i2=>styleText("dim",i2))}`;case"active":return`${styleText("green",S_RADIO_ACTIVE)} ${s}${n2.hint?` ${styleText("dim",`(${n2.hint})`)}`:""}`;case"cancelled":return`${c(s,i2=>styleText(["strikethrough","dim"],i2))}`;default:return`${styleText("dim",S_RADIO_INACTIVE)} ${c(s,i2=>styleText("dim",i2))}`}},d=t.showInstructions??!0;return new n$1({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,render(){let n2=t.withGuide??settings.withGuide,m2=`${symbol(this.state)} `,s=`${symbolBar(this.state)} `,i2=wrapTextWithPrefix(t.output,t.message,s,m2),u3=`${n2?`${styleText("gray",S_BAR)}
|
|
108
|
+
`:""}${i2}
|
|
109
|
+
`;switch(this.state){case"submit":{let r2=n2?`${styleText("gray",S_BAR)} `:"",a2=wrapTextWithPrefix(t.output,o(this.options[this.cursor],"selected"),r2);return`${u3}${a2}`}case"cancel":{let r2=n2?`${styleText("gray",S_BAR)} `:"",a2=wrapTextWithPrefix(t.output,o(this.options[this.cursor],"cancelled"),r2);return`${u3}${a2}${n2?`
|
|
110
|
+
${styleText("gray",S_BAR)}`:""}`}default:{let r2=n2?`${styleText("cyan",S_BAR)} `:"",a2=u3.split(`
|
|
111
|
+
`).length,p2=d?formatInstructionFooter(SELECT_INSTRUCTIONS,n2):n2?[styleText("cyan",S_BAR_END)]:[],b2=p2.join(`
|
|
112
|
+
`),f=p2.length+1;return`${u3}${r2}${limitOptions({output:t.output,cursor:this.cursor,options:this.options,maxItems:t.maxItems,columnPadding:r2.length,rowPadding:a2+f,style:(g,x2)=>o(g,g.disabled?"disabled":x2?"active":"inactive")}).join(`
|
|
113
|
+
${r2}`)}
|
|
114
|
+
${b2}
|
|
115
|
+
`}}}}).prompt()},selectKey=t=>{let l=(e,a2="inactive")=>{if(e===void 0)return"";let n2=e.label??String(e.value);return a2==="selected"?`${styleText("dim",n2)}`:a2==="cancelled"?`${styleText(["strikethrough","dim"],n2)}`:a2==="active"?`${styleText(["bgCyan","gray"],` ${e.value} `)} ${n2}${e.hint?` ${styleText("dim",`(${e.hint})`)}`:""}`:`${styleText(["gray","bgWhite","inverse"],` ${e.value} `)} ${n2}${e.hint?` ${styleText("dim",`(${e.hint})`)}`:""}`};return new u({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,caseSensitive:t.caseSensitive,render(){let e=t.withGuide??settings.withGuide,a2=`${e?`${styleText("gray",S_BAR)}
|
|
116
|
+
`:""}${symbol(this.state)} ${t.message}
|
|
117
|
+
`;switch(this.state){case"submit":{let n2=e?`${styleText("gray",S_BAR)} `:"",s=this.options.find(u3=>u3.value===this.value)??t.options[0],c2=wrapTextWithPrefix(t.output,l(s,"selected"),n2);return`${a2}${c2}`}case"cancel":{let n2=e?`${styleText("gray",S_BAR)} `:"",s=wrapTextWithPrefix(t.output,l(this.options[0],"cancelled"),n2);return`${a2}${s}${e?`
|
|
118
|
+
${styleText("gray",S_BAR)}`:""}`}default:{let n2=e?`${styleText("cyan",S_BAR)} `:"",s=e?styleText("cyan",S_BAR_END):"",c2=this.options.map((u3,d)=>wrapTextWithPrefix(t.output,l(u3,d===this.cursor?"active":"inactive"),n2)).join(`
|
|
119
|
+
`);return`${a2}${c2}
|
|
120
|
+
${s}
|
|
121
|
+
`}}}}).prompt()},i=`${styleText("gray",S_BAR)} `,stream={message:async(e,{symbol:l=styleText("gray",S_BAR)}={})=>{process.stdout.write(`${styleText("gray",S_BAR)}
|
|
122
|
+
${l} `);let s=3;for await(let r2 of e){r2=r2.replace(/\n/g,`
|
|
123
|
+
${i}`),r2.includes(`
|
|
124
|
+
`)&&(s=3+stripVTControlCharacters(r2.slice(r2.lastIndexOf(`
|
|
125
|
+
`))).length);let o=stripVTControlCharacters(r2).length;s+o<process.stdout.columns?(s+=o,process.stdout.write(r2)):(process.stdout.write(`
|
|
126
|
+
${i}${r2.trimStart()}`),s=3+stripVTControlCharacters(r2.trimStart()).length)}process.stdout.write(`
|
|
127
|
+
`)},info:e=>stream.message(e,{symbol:styleText("blue",S_INFO)}),success:e=>stream.message(e,{symbol:styleText("green",S_SUCCESS)}),step:e=>stream.message(e,{symbol:styleText("green",S_STEP_SUBMIT)}),warn:e=>stream.message(e,{symbol:styleText("yellow",S_WARN)}),warning:e=>stream.warn(e),error:e=>stream.message(e,{symbol:styleText("red",S_ERROR)})},tasks=async(o,e)=>{for(let t of o){if(t.enabled===!1)continue;let s=spinner(e);s.start(t.title);let n2=await t.task(s.message);s.stop(n2||t.title)}},A=l=>l.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,""),taskLog=l=>{let r2=l.output??process.stdout,O=getColumns(r2),i2=styleText("gray",S_BAR),p2=l.spacing??1,k=3,m2=l.retainLog===!0,d=!isCI()&&isTTY(r2);r2.write(`${i2}
|
|
128
|
+
`),r2.write(`${styleText("green",S_STEP_SUBMIT)} ${l.title}
|
|
129
|
+
`);for(let e=0;e<p2;e++)r2.write(`${i2}
|
|
130
|
+
`);let n2=[{value:"",full:""}],v=!1,f=e=>{if(n2.length===0)return;let s=0;e&&(s+=p2+2);for(let t of n2){let{value:o,result:a2}=t,g=a2?.message??o;if(g.length===0)continue;a2===void 0&&t.header!==void 0&&t.header!==""&&(g+=`
|
|
131
|
+
${t.header}`);let E2=g.split(`
|
|
132
|
+
`).reduce((b2,w)=>w===""?b2+1:b2+Math.ceil((w.length+k)/O),0);s+=E2}s>0&&(s+=1,r2.write(import_sisteransi.erase.lines(s)))},h2=(e,s,t)=>{let o=t?`${e.full}
|
|
133
|
+
${e.value}`:e.value;e.header!==void 0&&e.header!==""&&log.message(e.header.split(`
|
|
134
|
+
`).map(a2=>styleText("bold",a2)),{output:r2,secondarySymbol:i2,symbol:i2,spacing:0}),log.message(o.split(`
|
|
135
|
+
`).map(a2=>styleText("dim",a2)),{output:r2,secondarySymbol:i2,symbol:i2,spacing:s??p2})},T=()=>{for(let e of n2){let{header:s,value:t,full:o}=e;(s===void 0||s.length===0)&&t.length===0||h2(e,void 0,m2===!0&&o.length>0)}},L=(e,s,t)=>{if(f(!1),(t?.raw!==!0||!v)&&e.value!==""&&(e.value+=`
|
|
136
|
+
`),e.value+=A(s),v=t?.raw===!0,l.limit!==void 0){let o=e.value.split(`
|
|
137
|
+
`),a2=o.length-l.limit;if(a2>0){let g=o.splice(0,a2);m2&&(e.full+=(e.full===""?"":`
|
|
138
|
+
`)+g.join(`
|
|
139
|
+
`))}e.value=o.join(`
|
|
140
|
+
`)}d&&y()},y=()=>{for(let e of n2)e.result?e.result.status==="error"?log.error(e.result.message,{output:r2,secondarySymbol:i2,spacing:0}):log.success(e.result.message,{output:r2,secondarySymbol:i2,spacing:0}):e.value!==""&&h2(e,0)},B=(e,s)=>{f(!1),e.result=s,d&&y()};return{message(e,s){L(n2[0],e,s)},group(e){let s={header:e,value:"",full:""};return n2.push(s),{message(t,o){L(s,t,o)},error(t){B(s,{status:"error",message:t})},success(t){B(s,{status:"success",message:t})}}},error(e,s){f(!0),log.error(e,{output:r2,secondarySymbol:i2,spacing:1}),s?.showLog!==!1&&T(),n2.splice(1,n2.length-1),n2[0].value="",n2[0].full=""},success(e,s){f(!0),log.success(e,{output:r2,secondarySymbol:i2,spacing:1}),s?.showLog===!0&&T(),n2.splice(1,n2.length-1),n2[0].value="",n2[0].full=""}}},text=e=>new n({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let i2=e?.withGuide??settings.withGuide,s=`${`${i2?`${styleText("gray",S_BAR)}
|
|
141
|
+
`:""}${symbol(this.state)} `}${e.message}
|
|
142
|
+
`,c2=e.placeholder&&e.placeholder.length>0?styleText("inverse",e.placeholder[0])+styleText("dim",e.placeholder.slice(1)):styleText(["inverse","hidden"],"_"),o=this.userInput?this.userInputWithCursor:c2,l=this.value??"";switch(this.state){case"error":{let n2=this.error?` ${styleText("yellow",this.error)}`:"",r2=i2?`${styleText("yellow",S_BAR)} `:"",d=i2?styleText("yellow",S_BAR_END):"";return`${s.trim()}
|
|
143
|
+
${r2}${o}
|
|
144
|
+
${d}${n2}
|
|
145
|
+
`}case"submit":{let n2=l?` ${styleText("dim",l)}`:"",r2=i2?styleText("gray",S_BAR):"";return`${s}${r2}${n2}`}case"cancel":{let n2=l?` ${styleText(["strikethrough","dim"],l)}`:"",r2=i2?styleText("gray",S_BAR):"";return`${s}${r2}${n2}${l.trim()?`
|
|
146
|
+
${r2}`:""}`}default:{let n2=i2?`${styleText("cyan",S_BAR)} `:"",r2=i2?styleText("cyan",S_BAR_END):"";return`${s}${n2}${o}
|
|
147
|
+
${r2}
|
|
148
|
+
`}}}}).prompt();export{MULTISELECT_INSTRUCTIONS,SELECT_INSTRUCTIONS,S_BAR,S_BAR_END,S_BAR_END_RIGHT,S_BAR_H,S_BAR_START,S_BAR_START_RIGHT,S_CHECKBOX_ACTIVE,S_CHECKBOX_INACTIVE,S_CHECKBOX_SELECTED,S_CONNECT_LEFT,S_CORNER_BOTTOM_LEFT,S_CORNER_BOTTOM_RIGHT,S_CORNER_TOP_LEFT,S_CORNER_TOP_RIGHT,S_ERROR,S_INFO,S_PASSWORD_MASK,S_RADIO_ACTIVE,S_RADIO_INACTIVE,S_STEP_ACTIVE,S_STEP_CANCEL,S_STEP_ERROR,S_STEP_SUBMIT,S_SUCCESS,S_WARN,autocomplete,autocompleteMultiselect,box,cancel,confirm,date,formatInstructionFooter,group,groupMultiselect,intro,isCI,isCancel,isTTY,limitOptions,log,multiline,multiselect,note,outro,password,path,progress,select,selectKey,settings,spinner,stream,symbol,symbolBar,taskLog,tasks,text,unicode,unicodeOr,updateSettings};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{T$1,U,V,a,block,getColumns,getRows,h,isCancel,n,n$1,r,runValidation,settings,u,u$1,u$2,updateSettings,wrapTextWithPrefix}from"./chunk-STBTNAXZ.js";import"./chunk-HHBSYJ3E.js";export{T$1 as AutocompletePrompt,r as ConfirmPrompt,U as DatePrompt,u$2 as GroupMultiSelectPrompt,h as MultiLinePrompt,a as MultiSelectPrompt,u$1 as PasswordPrompt,V as Prompt,u as SelectKeyPrompt,n$1 as SelectPrompt,n as TextPrompt,block,getColumns,getRows,isCancel,runValidation,settings,updateSettings,wrapTextWithPrefix};
|