🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@clack/prompts

Package Overview
Dependencies
Maintainers
5
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clack/prompts - npm Package Compare versions

Comparing version
1.1.0
to
1.2.0
+20
-0
CHANGELOG.md
# @clack/prompts
## 1.2.0
### Minor Changes
- 9786226: Externalize `fast-string-width` and `fast-wrap-ansi` to avoid double dependencies
- 090902c: Adds `date` prompt with `format` support (YMD, MDY, DMY)
### Patch Changes
- 134a1a1: Fix the `path` prompt so `directory: true` correctly enforces directory-only selection while still allowing directory navigation, and add regression tests for both directory and default file selection behavior.
- bdf89a5: Adds `placeholder` option to `autocomplete`. When the placeholder is set and the input is empty, pressing `tab` will set the value to `placeholder`.
- 336495a: Apply guide to wrapped multi-line messages in confirm prompt.
- 9fe8de6: Respect `withGuide: false` in autocomplete and multiselect prompts.
- 29a50cb: Fix `path` directory mode so pressing Enter with an existing directory `initialValue` submits that current directory instead of the first child option, and add regression coverage for immediate submit and child-directory navigation.
- Updated dependencies [9786226]
- Updated dependencies [bdf89a5]
- Updated dependencies [417b451]
- Updated dependencies [090902c]
- @clack/core@1.2.0
## 1.1.0

@@ -4,0 +24,0 @@

+16
-4

@@ -1,3 +0,3 @@

import { State, AutocompletePrompt } from '@clack/core';
export { ClackSettings, isCancel, settings, updateSettings } from '@clack/core';
import { State, AutocompletePrompt, DateFormat } from '@clack/core';
export { ClackSettings, DateFormat, isCancel, settings, updateSettings } from '@clack/core';
import { Readable, Writable } from 'node:stream';

@@ -175,2 +175,14 @@

interface DateOptions extends CommonOptions {
message: string;
format?: DateFormat;
locale?: string;
defaultValue?: Date;
initialValue?: Date;
minDate?: Date;
maxDate?: Date;
validate?: (value: Date | undefined) => string | Error | undefined;
}
declare const date: (opts: DateOptions) => Promise<Date | symbol>;
type Prettify<T> = {

@@ -379,3 +391,3 @@ [P in keyof T]: T[P];

export { 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, group, groupMultiselect, intro, isCI, isTTY, limitOptions, log, multiselect, note, outro, password, path, progress, select, selectKey, spinner, stream, symbol, symbolBar, taskLog, tasks, text, unicode, unicodeOr };
export type { AutocompleteMultiSelectOptions, AutocompleteOptions, BoxAlignment, BoxOptions, CommonOptions, ConfirmOptions, GroupMultiSelectOptions, LimitOptionsParams, LogMessageOptions, MultiSelectOptions, NoteOptions, Option, PasswordOptions, PathOptions, ProgressOptions, ProgressResult, PromptGroup, PromptGroupAwaitedReturn, PromptGroupOptions, SelectKeyOptions, SelectOptions, SpinnerOptions, SpinnerResult, Task, TaskLogCompletionOptions, TaskLogMessageOptions, TaskLogOptions, TextOptions };
export { 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, group, groupMultiselect, intro, isCI, isTTY, limitOptions, log, multiselect, note, outro, password, path, progress, select, selectKey, spinner, stream, symbol, symbolBar, taskLog, tasks, text, unicode, unicodeOr };
export type { AutocompleteMultiSelectOptions, AutocompleteOptions, BoxAlignment, BoxOptions, CommonOptions, ConfirmOptions, DateOptions, GroupMultiSelectOptions, LimitOptionsParams, LogMessageOptions, MultiSelectOptions, NoteOptions, Option, PasswordOptions, PathOptions, ProgressOptions, ProgressResult, PromptGroup, PromptGroupAwaitedReturn, PromptGroupOptions, SelectKeyOptions, SelectOptions, SpinnerOptions, SpinnerResult, Task, TaskLogCompletionOptions, TaskLogMessageOptions, TaskLogOptions, TextOptions };
+128
-126

@@ -1,135 +0,137 @@

import{getColumns as Y,getRows as tt,AutocompletePrompt as Be,settings as _,ConfirmPrompt as st,isCancel as rt,GroupMultiSelectPrompt as it,MultiSelectPrompt as nt,wrapTextWithPrefix as j,PasswordPrompt as at,block as ot,SelectPrompt as lt,SelectKeyPrompt as ut,TextPrompt as ct}from"@clack/core";export{isCancel,settings,updateSettings}from"@clack/core";import{styleText as t,stripVTControlCharacters as ue}from"node:util";import N from"node:process";import{readdirSync as $t,existsSync as dt,lstatSync as xe}from"node:fs";import{dirname as _e,join as ht}from"node:path";import{cursor as De,erase as Te}from"sisteransi";function pt(){return N.platform!=="win32"?N.env.TERM!=="linux":!!N.env.CI||!!N.env.WT_SESSION||!!N.env.TERMINUS_SUBLIME||N.env.ConEmuTask==="{cmd::Cmder}"||N.env.TERM_PROGRAM==="Terminus-Sublime"||N.env.TERM_PROGRAM==="vscode"||N.env.TERM==="xterm-256color"||N.env.TERM==="alacritty"||N.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const ee=pt(),ce=()=>process.env.CI==="true",Me=e=>e.isTTY===!0,I=(e,r)=>ee?e:r,Re=I("\u25C6","*"),$e=I("\u25A0","x"),de=I("\u25B2","x"),V=I("\u25C7","o"),he=I("\u250C","T"),h=I("\u2502","|"),x=I("\u2514","\u2014"),Oe=I("\u2510","T"),Pe=I("\u2518","\u2014"),z=I("\u25CF",">"),H=I("\u25CB"," "),te=I("\u25FB","[\u2022]"),U=I("\u25FC","[+]"),q=I("\u25FB","[ ]"),Ne=I("\u25AA","\u2022"),se=I("\u2500","-"),pe=I("\u256E","+"),We=I("\u251C","+"),me=I("\u256F","+"),ge=I("\u2570","+"),Ge=I("\u256D","+"),fe=I("\u25CF","\u2022"),Fe=I("\u25C6","*"),ye=I("\u25B2","!"),Ee=I("\u25A0","x"),W=e=>{switch(e){case"initial":case"active":return t("cyan",Re);case"cancel":return t("red",$e);case"error":return t("yellow",de);case"submit":return t("green",V)}},ve=e=>{switch(e){case"initial":case"active":return t("cyan",h);case"cancel":return t("red",h);case"error":return t("yellow",h);case"submit":return t("green",h)}},mt=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,gt=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,ft=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,we=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,re=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,ie=/\t{1,1000}/y,Ae=/[\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,ne=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Ft=/\p{M}+/gu,yt={limit:1/0,ellipsis:""},Le=(e,r={},s={})=>{const i=r.limit??1/0,a=r.ellipsis??"",o=r?.ellipsisWidth??(a?Le(a,yt,s).width:0),u=s.ansiWidth??0,l=s.controlWidth??0,n=s.tabWidth??8,c=s.ambiguousWidth??1,p=s.emojiWidth??2,f=s.fullWidthWidth??2,g=s.regularWidth??1,E=s.wideWidth??2;let $=0,m=0,d=e.length,F=0,y=!1,v=d,C=Math.max(0,i-o),A=0,b=0,w=0,S=0;e:for(;;){if(b>A||m>=d&&m>$){const T=e.slice(A,b)||e.slice($,m);F=0;for(const M of T.replaceAll(Ft,"")){const O=M.codePointAt(0)||0;if(gt(O)?S=f:ft(O)?S=E:c!==g&&mt(O)?S=c:S=g,w+S>C&&(v=Math.min(v,Math.max(A,$)+F)),w+S>i){y=!0;break e}F+=M.length,w+=S}A=b=0}if(m>=d)break;if(ne.lastIndex=m,ne.test(e)){if(F=ne.lastIndex-m,S=F*g,w+S>C&&(v=Math.min(v,m+Math.floor((C-w)/g))),w+S>i){y=!0;break}w+=S,A=$,b=m,m=$=ne.lastIndex;continue}if(we.lastIndex=m,we.test(e)){if(w+u>C&&(v=Math.min(v,m)),w+u>i){y=!0;break}w+=u,A=$,b=m,m=$=we.lastIndex;continue}if(re.lastIndex=m,re.test(e)){if(F=re.lastIndex-m,S=F*l,w+S>C&&(v=Math.min(v,m+Math.floor((C-w)/l))),w+S>i){y=!0;break}w+=S,A=$,b=m,m=$=re.lastIndex;continue}if(ie.lastIndex=m,ie.test(e)){if(F=ie.lastIndex-m,S=F*n,w+S>C&&(v=Math.min(v,m+Math.floor((C-w)/n))),w+S>i){y=!0;break}w+=S,A=$,b=m,m=$=ie.lastIndex;continue}if(Ae.lastIndex=m,Ae.test(e)){if(w+p>C&&(v=Math.min(v,m)),w+p>i){y=!0;break}w+=p,A=$,b=m,m=$=Ae.lastIndex;continue}m+=1}return{width:y?C:w,index:y?v:d,truncated:y,ellipsed:y&&i>=o}},Et={limit:1/0,ellipsis:"",ellipsisWidth:0},D=(e,r={})=>Le(e,Et,r).width,ae="\x1B",je="\x9B",vt=39,Ce="\x07",ke="[",wt="]",Ve="m",Se=`${wt}8;;`,He=new RegExp(`(?:\\${ke}(?<code>\\d+)m|\\${Se}(?<uri>.*)${Ce})`,"y"),At=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Ue=e=>`${ae}${ke}${e}${Ve}`,Ke=e=>`${ae}${Se}${e}${Ce}`,Ct=e=>e.map(r=>D(r)),Ie=(e,r,s)=>{const i=r[Symbol.iterator]();let a=!1,o=!1,u=e.at(-1),l=u===void 0?0:D(u),n=i.next(),c=i.next(),p=0;for(;!n.done;){const f=n.value,g=D(f);l+g<=s?e[e.length-1]+=f:(e.push(f),l=0),(f===ae||f===je)&&(a=!0,o=r.startsWith(Se,p+1)),a?o?f===Ce&&(a=!1,o=!1):f===Ve&&(a=!1):(l+=g,l===s&&!c.done&&(e.push(""),l=0)),n=c,c=i.next(),p+=f.length}u=e.at(-1),!l&&u!==void 0&&u.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},St=e=>{const r=e.split(" ");let s=r.length;for(;s>0&&!(D(r[s-1])>0);)s--;return s===r.length?e:r.slice(0,s).join(" ")+r.slice(s).join("")},It=(e,r,s={})=>{if(s.trim!==!1&&e.trim()==="")return"";let i="",a,o;const u=e.split(" "),l=Ct(u);let n=[""];for(const[$,m]of u.entries()){s.trim!==!1&&(n[n.length-1]=(n.at(-1)??"").trimStart());let d=D(n.at(-1)??"");if($!==0&&(d>=r&&(s.wordWrap===!1||s.trim===!1)&&(n.push(""),d=0),(d>0||s.trim===!1)&&(n[n.length-1]+=" ",d++)),s.hard&&l[$]>r){const F=r-d,y=1+Math.floor((l[$]-F-1)/r);Math.floor((l[$]-1)/r)<y&&n.push(""),Ie(n,m,r);continue}if(d+l[$]>r&&d>0&&l[$]>0){if(s.wordWrap===!1&&d<r){Ie(n,m,r);continue}n.push("")}if(d+l[$]>r&&s.wordWrap===!1){Ie(n,m,r);continue}n[n.length-1]+=m}s.trim!==!1&&(n=n.map($=>St($)));const c=n.join(`
`),p=c[Symbol.iterator]();let f=p.next(),g=p.next(),E=0;for(;!f.done;){const $=f.value,m=g.value;if(i+=$,$===ae||$===je){He.lastIndex=E+1;const y=He.exec(c)?.groups;if(y?.code!==void 0){const v=Number.parseFloat(y.code);a=v===vt?void 0:v}else y?.uri!==void 0&&(o=y.uri.length===0?void 0:y.uri)}const d=a?At(a):void 0;m===`
`?(o&&(i+=Ke("")),a&&d&&(i+=Ue(d))):$===`
`&&(a&&d&&(i+=Ue(a)),o&&(i+=Ke(o))),E+=$.length,f=g,g=p.next()}return i};function J(e,r,s){return String(e).normalize().replaceAll(`\r
`,`
`).split(`
`).map(i=>It(i,r,s)).join(`
`)}const bt=(e,r,s,i,a)=>{let o=r,u=0;for(let l=s;l<i;l++){const n=e[l];if(o=o-n.length,u++,o<=a)break}return{lineCount:o,removals:u}},X=({cursor:e,options:r,style:s,output:i=process.stdout,maxItems:a=Number.POSITIVE_INFINITY,columnPadding:o=0,rowPadding:u=4})=>{const l=Y(i)-o,n=tt(i),c=t("dim","..."),p=Math.max(n-u,0),f=Math.max(Math.min(a,p),5);let g=0;e>=f-3&&(g=Math.max(Math.min(e-f+3,r.length-f),0));let E=f<r.length&&g>0,$=f<r.length&&g+f<r.length;const m=Math.min(g+f,r.length),d=[];let F=0;E&&F++,$&&F++;const y=g+(E?1:0),v=m-($?1:0);for(let A=y;A<v;A++){const b=J(s(r[A],A===e),l,{hard:!0,trim:!1}).split(`
`);d.push(b),F+=b.length}if(F>p){let A=0,b=0,w=F;const S=e-y,T=(M,O)=>bt(d,w,M,O,p);E?({lineCount:w,removals:A}=T(0,S),w>p&&({lineCount:w,removals:b}=T(S+1,d.length))):({lineCount:w,removals:b}=T(S+1,d.length),w>p&&({lineCount:w,removals:A}=T(0,S))),A>0&&(E=!0,d.splice(0,A)),b>0&&($=!0,d.splice(d.length-b,b))}const C=[];E&&C.push(c);for(const A of d)for(const b of A)C.push(b);return $&&C.push(c),C};function qe(e){return e.label??String(e.value??"")}function Je(e,r){if(!e)return!0;const s=(r.label??String(r.value??"")).toLowerCase(),i=(r.hint??"").toLowerCase(),a=String(r.value).toLowerCase(),o=e.toLowerCase();return s.includes(o)||i.includes(o)||a.includes(o)}function Bt(e,r){const s=[];for(const i of r)e.includes(i.value)&&s.push(i);return s}const Xe=e=>new Be({options:e.options,initialValue:e.initialValue?[e.initialValue]:void 0,initialUserInput:e.initialUserInput,filter:e.filter??((r,s)=>Je(r,s)),signal:e.signal,input:e.input,output:e.output,validate:e.validate,render(){const r=e.withGuide??_.withGuide,s=r?[`${t("gray",h)}`,`${W(this.state)} ${e.message}`]:[`${W(this.state)} ${e.message}`],i=this.userInput,a=this.options,o=e.placeholder,u=i===""&&o!==void 0,l=(n,c)=>{const p=qe(n),f=n.hint&&n.value===this.focusedValue?t("dim",` (${n.hint})`):"";switch(c){case"active":return`${t("green",z)} ${p}${f}`;case"inactive":return`${t("dim",H)} ${t("dim",p)}`;case"disabled":return`${t("gray",H)} ${t(["strikethrough","gray"],p)}`}};switch(this.state){case"submit":{const n=Bt(this.selectedValues,a),c=n.length>0?` ${t("dim",n.map(qe).join(", "))}`:"",p=r?t("gray",h):"";return`${s.join(`
import{getColumns as X,getRows as ke,AutocompletePrompt as ve,settings as I,ConfirmPrompt as Le,wrapTextWithPrefix as N,DatePrompt as De,isCancel as We,GroupMultiSelectPrompt as Fe,MultiSelectPrompt as He,PasswordPrompt as Ue,block as Ke,SelectPrompt as qe,SelectKeyPrompt as Je,TextPrompt as Ye}from"@clack/core";export{isCancel,settings,updateSettings}from"@clack/core";import{styleText as t,stripVTControlCharacters as ne}from"node:util";import P from"node:process";import{wrapAnsi as q}from"fast-wrap-ansi";import B from"fast-string-width";import{existsSync as Xe,lstatSync as we,readdirSync as ze}from"node:fs";import{dirname as be,join as Qe}from"node:path";import{cursor as Se,erase as Ce}from"sisteransi";function Ze(){return P.platform!=="win32"?P.env.TERM!=="linux":!!P.env.CI||!!P.env.WT_SESSION||!!P.env.TERMINUS_SUBLIME||P.env.ConEmuTask==="{cmd::Cmder}"||P.env.TERM_PROGRAM==="Terminus-Sublime"||P.env.TERM_PROGRAM==="vscode"||P.env.TERM==="xterm-256color"||P.env.TERM==="alacritty"||P.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const ee=Ze(),ae=()=>process.env.CI==="true",Te=e=>e.isTTY===!0,w=(e,i)=>ee?e:i,_e=w("\u25C6","*"),oe=w("\u25A0","x"),ue=w("\u25B2","x"),F=w("\u25C7","o"),le=w("\u250C","T"),d=w("\u2502","|"),E=w("\u2514","\u2014"),Ie=w("\u2510","T"),Ee=w("\u2518","\u2014"),z=w("\u25CF",">"),H=w("\u25CB"," "),te=w("\u25FB","[\u2022]"),U=w("\u25FC","[+]"),J=w("\u25FB","[ ]"),xe=w("\u25AA","\u2022"),se=w("\u2500","-"),ce=w("\u256E","+"),Ge=w("\u251C","+"),$e=w("\u256F","+"),de=w("\u2570","+"),Oe=w("\u256D","+"),he=w("\u25CF","\u2022"),pe=w("\u25C6","*"),me=w("\u25B2","!"),ge=w("\u25A0","x"),V=e=>{switch(e){case"initial":case"active":return t("cyan",_e);case"cancel":return t("red",oe);case"error":return t("yellow",ue);case"submit":return t("green",F)}},ye=e=>{switch(e){case"initial":case"active":return t("cyan",d);case"cancel":return t("red",d);case"error":return t("yellow",d);case"submit":return t("green",d)}},et=(e,i,s,r,u)=>{let n=i,o=0;for(let c=s;c<r;c++){const a=e[c];if(n=n-a.length,o++,n<=u)break}return{lineCount:n,removals:o}},Y=({cursor:e,options:i,style:s,output:r=process.stdout,maxItems:u=Number.POSITIVE_INFINITY,columnPadding:n=0,rowPadding:o=4})=>{const c=X(r)-n,a=ke(r),l=t("dim","..."),$=Math.max(a-o,0),y=Math.max(Math.min(u,$),5);let p=0;e>=y-3&&(p=Math.max(Math.min(e-y+3,i.length-y),0));let m=y<i.length&&p>0,g=y<i.length&&p+y<i.length;const S=Math.min(p+y,i.length),h=[];let f=0;m&&f++,g&&f++;const v=p+(m?1:0),T=S-(g?1:0);for(let b=v;b<T;b++){const x=q(s(i[b],b===e),c,{hard:!0,trim:!1}).split(`
`);h.push(x),f+=x.length}if(f>$){let b=0,x=0,G=f;const M=e-v,R=(j,D)=>et(h,G,j,D,$);m?({lineCount:G,removals:b}=R(0,M),G>$&&({lineCount:G,removals:x}=R(M+1,h.length))):({lineCount:G,removals:x}=R(M+1,h.length),G>$&&({lineCount:G,removals:b}=R(0,M))),b>0&&(m=!0,h.splice(0,b)),x>0&&(g=!0,h.splice(h.length-x,x))}const C=[];m&&C.push(l);for(const b of h)for(const x of b)C.push(x);return g&&C.push(l),C};function Me(e){return e.label??String(e.value??"")}function Re(e,i){if(!e)return!0;const s=(i.label??String(i.value??"")).toLowerCase(),r=(i.hint??"").toLowerCase(),u=String(i.value).toLowerCase(),n=e.toLowerCase();return s.includes(n)||r.includes(n)||u.includes(n)}function tt(e,i){const s=[];for(const r of i)e.includes(r.value)&&s.push(r);return s}const Ae=e=>new ve({options:e.options,initialValue:e.initialValue?[e.initialValue]:void 0,initialUserInput:e.initialUserInput,placeholder:e.placeholder,filter:e.filter??((i,s)=>Re(i,s)),signal:e.signal,input:e.input,output:e.output,validate:e.validate,render(){const i=e.withGuide??I.withGuide,s=i?[`${t("gray",d)}`,`${V(this.state)} ${e.message}`]:[`${V(this.state)} ${e.message}`],r=this.userInput,u=this.options,n=e.placeholder,o=r===""&&n!==void 0,c=(a,l)=>{const $=Me(a),y=a.hint&&a.value===this.focusedValue?t("dim",` (${a.hint})`):"";switch(l){case"active":return`${t("green",z)} ${$}${y}`;case"inactive":return`${t("dim",H)} ${t("dim",$)}`;case"disabled":return`${t("gray",H)} ${t(["strikethrough","gray"],$)}`}};switch(this.state){case"submit":{const a=tt(this.selectedValues,u),l=a.length>0?` ${t("dim",a.map(Me).join(", "))}`:"",$=i?t("gray",d):"";return`${s.join(`
`)}
${p}${c}`}case"cancel":{const n=i?` ${t(["strikethrough","dim"],i)}`:"",c=r?t("gray",h):"";return`${s.join(`
${$}${l}`}case"cancel":{const a=r?` ${t(["strikethrough","dim"],r)}`:"",l=i?t("gray",d):"";return`${s.join(`
`)}
${c}${n}`}default:{const n=this.state==="error"?"yellow":"cyan",c=r?`${t(n,h)} `:"",p=r?t(n,x):"";let f="";if(this.isNavigating||u){const y=u?o:i;f=y!==""?` ${t("dim",y)}`:""}else f=` ${this.userInputWithCursor}`;const g=this.filteredOptions.length!==a.length?t("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",E=this.filteredOptions.length===0&&i?[`${c}${t("yellow","No matches found")}`]:[],$=this.state==="error"?[`${c}${t("yellow",this.error)}`]:[];r&&s.push(`${c.trimEnd()}`),s.push(`${c}${t("dim","Search:")}${f}${g}`,...E,...$);const m=[`${t("dim","\u2191/\u2193")} to select`,`${t("dim","Enter:")} confirm`,`${t("dim","Type:")} to search`],d=[`${c}${m.join(" \u2022 ")}`,p],F=this.filteredOptions.length===0?[]:X({cursor:this.cursor,options:this.filteredOptions,columnPadding:r?3:0,rowPadding:s.length+d.length,style:(y,v)=>l(y,y.disabled?"disabled":v?"active":"inactive"),maxItems:e.maxItems,output:e.output});return[...s,...F.map(y=>`${c}${y}`),...d].join(`
`)}}}}).prompt(),xt=e=>{const r=(i,a,o,u)=>{const l=o.includes(i.value),n=i.label??String(i.value??""),c=i.hint&&u!==void 0&&i.value===u?t("dim",` (${i.hint})`):"",p=l?t("green",U):t("dim",q);return i.disabled?`${t("gray",q)} ${t(["strikethrough","gray"],n)}`:a?`${p} ${n}${c}`:`${p} ${t("dim",n)}`},s=new Be({options:e.options,multiple:!0,filter:e.filter??((i,a)=>Je(i,a)),validate:()=>{if(e.required&&s.selectedValues.length===0)return"Please select at least one item"},initialValue:e.initialValues,signal:e.signal,input:e.input,output:e.output,render(){const i=`${t("gray",h)}
${W(this.state)} ${e.message}
`,a=this.userInput,o=e.placeholder,u=a===""&&o!==void 0,l=this.isNavigating||u?t("dim",u?o:a):this.userInputWithCursor,n=this.options,c=this.filteredOptions.length!==n.length?t("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${i}${t("gray",h)} ${t("dim",`${this.selectedValues.length} items selected`)}`;case"cancel":return`${i}${t("gray",h)} ${t(["strikethrough","dim"],a)}`;default:{const p=this.state==="error"?"yellow":"cyan",f=[`${t("dim","\u2191/\u2193")} to navigate`,`${t("dim",this.isNavigating?"Space/Tab:":"Tab:")} select`,`${t("dim","Enter:")} confirm`,`${t("dim","Type:")} to search`],g=this.filteredOptions.length===0&&a?[`${t(p,h)} ${t("yellow","No matches found")}`]:[],E=this.state==="error"?[`${t(p,h)} ${t("yellow",this.error)}`]:[],$=[...`${i}${t(p,h)}`.split(`
`),`${t(p,h)} ${t("dim","Search:")} ${l}${c}`,...g,...E],m=[`${t(p,h)} ${f.join(" \u2022 ")}`,t(p,x)],d=X({cursor:this.cursor,options:this.filteredOptions,style:(F,y)=>r(F,y,this.selectedValues,this.focusedValue),maxItems:e.maxItems,output:e.output,rowPadding:$.length+m.length});return[...$,...d.map(F=>`${t(p,h)} ${F}`),...m].join(`
`)}}}});return s.prompt()},_t=[Ge,pe,ge,me],Dt=[he,Oe,x,Pe];function Ye(e,r,s,i){let a=s,o=s;return i==="center"?a=Math.floor((r-e)/2):i==="right"&&(a=r-e-s),o=r-a-e,[a,o]}const Tt=e=>e,Mt=(e="",r="",s)=>{const i=s?.output??process.stdout,a=Y(i),o=2,u=s?.titlePadding??1,l=s?.contentPadding??2,n=s?.width===void 0||s.width==="auto"?1:Math.min(1,s.width),c=s?.withGuide??_.withGuide?`${h} `:"",p=s?.formatBorder??Tt,f=(s?.rounded?_t:Dt).map(p),g=p(se),E=p(h),$=D(c),m=D(r),d=a-$;let F=Math.floor(a*n)-$;if(s?.width==="auto"){const T=e.split(`
`);let M=m+u*2;for(const le of T){const k=D(le)+l*2;k>M&&(M=k)}const O=M+o;O<F&&(F=O)}F%2!==0&&(F<d?F++:F--);const y=F-o,v=y-u*2,C=m>v?`${r.slice(0,v-3)}...`:r,[A,b]=Ye(D(C),y,u,s?.titleAlign),w=J(e,y-l*2,{hard:!0,trim:!1});i.write(`${c}${f[0]}${g.repeat(A)}${C}${g.repeat(b)}${f[1]}
`);const S=w.split(`
`);for(const T of S){const[M,O]=Ye(D(T),y,l,s?.contentAlign);i.write(`${c}${E}${" ".repeat(M)}${T}${" ".repeat(O)}${E}
`)}i.write(`${c}${f[2]}${g.repeat(y)}${f[3]}
`)},Rt=e=>{const r=e.active??"Yes",s=e.inactive??"No";return new st({active:r,inactive:s,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){const i=e.withGuide??_.withGuide,a=`${i?`${t("gray",h)}
`:""}${W(this.state)} ${e.message}
`,o=this.value?r:s;switch(this.state){case"submit":{const u=i?`${t("gray",h)} `:"";return`${a}${u}${t("dim",o)}`}case"cancel":{const u=i?`${t("gray",h)} `:"";return`${a}${u}${t(["strikethrough","dim"],o)}${i?`
${t("gray",h)}`:""}`}default:{const u=i?`${t("cyan",h)} `:"",l=i?t("cyan",x):"";return`${a}${u}${this.value?`${t("green",z)} ${r}`:`${t("dim",H)} ${t("dim",r)}`}${e.vertical?i?`
${t("cyan",h)} `:`
${l}${a}`}default:{const a=this.state==="error"?"yellow":"cyan",l=i?`${t(a,d)} `:"",$=i?t(a,E):"";let y="";if(this.isNavigating||o){const v=o?n:r;y=v!==""?` ${t("dim",v)}`:""}else y=` ${this.userInputWithCursor}`;const p=this.filteredOptions.length!==u.length?t("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",m=this.filteredOptions.length===0&&r?[`${l}${t("yellow","No matches found")}`]:[],g=this.state==="error"?[`${l}${t("yellow",this.error)}`]:[];i&&s.push(`${l.trimEnd()}`),s.push(`${l}${t("dim","Search:")}${y}${p}`,...m,...g);const S=[`${t("dim","\u2191/\u2193")} to select`,`${t("dim","Enter:")} confirm`,`${t("dim","Type:")} to search`],h=[`${l}${S.join(" \u2022 ")}`,$],f=this.filteredOptions.length===0?[]:Y({cursor:this.cursor,options:this.filteredOptions,columnPadding:i?3:0,rowPadding:s.length+h.length,style:(v,T)=>c(v,v.disabled?"disabled":T?"active":"inactive"),maxItems:e.maxItems,output:e.output});return[...s,...f.map(v=>`${l}${v}`),...h].join(`
`)}}}}).prompt(),st=e=>{const i=(r,u,n,o)=>{const c=n.includes(r.value),a=r.label??String(r.value??""),l=r.hint&&o!==void 0&&r.value===o?t("dim",` (${r.hint})`):"",$=c?t("green",U):t("dim",J);return r.disabled?`${t("gray",J)} ${t(["strikethrough","gray"],a)}`:u?`${$} ${a}${l}`:`${$} ${t("dim",a)}`},s=new ve({options:e.options,multiple:!0,placeholder:e.placeholder,filter:e.filter??((r,u)=>Re(r,u)),validate:()=>{if(e.required&&s.selectedValues.length===0)return"Please select at least one item"},initialValue:e.initialValues,signal:e.signal,input:e.input,output:e.output,render(){const r=e.withGuide??I.withGuide,u=`${r?`${t("gray",d)}
`:""}${V(this.state)} ${e.message}
`,n=this.userInput,o=e.placeholder,c=n===""&&o!==void 0,a=this.isNavigating||c?t("dim",c?o:n):this.userInputWithCursor,l=this.options,$=this.filteredOptions.length!==l.length?t("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${u}${r?`${t("gray",d)} `:""}${t("dim",`${this.selectedValues.length} items selected`)}`;case"cancel":return`${u}${r?`${t("gray",d)} `:""}${t(["strikethrough","dim"],n)}`;default:{const y=this.state==="error"?"yellow":"cyan",p=r?`${t(y,d)} `:"",m=r?t(y,E):"",g=[`${t("dim","\u2191/\u2193")} to navigate`,`${t("dim",this.isNavigating?"Space/Tab:":"Tab:")} select`,`${t("dim","Enter:")} confirm`,`${t("dim","Type:")} to search`],S=this.filteredOptions.length===0&&n?[`${p}${t("yellow","No matches found")}`]:[],h=this.state==="error"?[`${p}${t("yellow",this.error)}`]:[],f=[...`${u}${r?t(y,d):""}`.split(`
`),`${p}${t("dim","Search:")} ${a}${$}`,...S,...h],v=[`${p}${g.join(" \u2022 ")}`,m],T=Y({cursor:this.cursor,options:this.filteredOptions,style:(C,b)=>i(C,b,this.selectedValues,this.focusedValue),maxItems:e.maxItems,output:e.output,rowPadding:f.length+v.length});return[...f,...T.map(C=>`${p}${C}`),...v].join(`
`)}}}});return s.prompt()},rt=[Oe,ce,de,$e],it=[le,Ie,E,Ee];function Pe(e,i,s,r){let u=s,n=s;return r==="center"?u=Math.floor((i-e)/2):r==="right"&&(u=i-e-s),n=i-u-e,[u,n]}const nt=e=>e,at=(e="",i="",s)=>{const r=s?.output??process.stdout,u=X(r),n=2,o=s?.titlePadding??1,c=s?.contentPadding??2,a=s?.width===void 0||s.width==="auto"?1:Math.min(1,s.width),l=s?.withGuide??I.withGuide?`${d} `:"",$=s?.formatBorder??nt,y=(s?.rounded?rt:it).map($),p=$(se),m=$(d),g=B(l),S=B(i),h=u-g;let f=Math.floor(u*a)-g;if(s?.width==="auto"){const R=e.split(`
`);let j=S+o*2;for(const ie of R){const W=B(ie)+c*2;W>j&&(j=W)}const D=j+n;D<f&&(f=D)}f%2!==0&&(f<h?f++:f--);const v=f-n,T=v-o*2,C=S>T?`${i.slice(0,T-3)}...`:i,[b,x]=Pe(B(C),v,o,s?.titleAlign),G=q(e,v-c*2,{hard:!0,trim:!1});r.write(`${l}${y[0]}${p.repeat(b)}${C}${p.repeat(x)}${y[1]}
`);const M=G.split(`
`);for(const R of M){const[j,D]=Pe(B(R),v,c,s?.contentAlign);r.write(`${l}${m}${" ".repeat(j)}${R}${" ".repeat(D)}${m}
`)}r.write(`${l}${y[2]}${p.repeat(v)}${y[3]}
`)},ot=e=>{const i=e.active??"Yes",s=e.inactive??"No";return new Le({active:i,inactive:s,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){const r=e.withGuide??I.withGuide,u=`${V(this.state)} `,n=r?`${t("gray",d)} `:"",o=N(e.output,e.message,n,u),c=`${r?`${t("gray",d)}
`:""}${o}
`,a=this.value?i:s;switch(this.state){case"submit":{const l=r?`${t("gray",d)} `:"";return`${c}${l}${t("dim",a)}`}case"cancel":{const l=r?`${t("gray",d)} `:"";return`${c}${l}${t(["strikethrough","dim"],a)}${r?`
${t("gray",d)}`:""}`}default:{const l=r?`${t("cyan",d)} `:"",$=r?t("cyan",E):"";return`${c}${l}${this.value?`${t("green",z)} ${i}`:`${t("dim",H)} ${t("dim",i)}`}${e.vertical?r?`
${t("cyan",d)} `:`
`:` ${t("dim","/")} `}${this.value?`${t("dim",H)} ${t("dim",s)}`:`${t("green",z)} ${s}`}
${l}
`}}}}).prompt()},Ot=async(e,r)=>{const s={},i=Object.keys(e);for(const a of i){const o=e[a],u=await o({results:s})?.catch(l=>{throw l});if(typeof r?.onCancel=="function"&&rt(u)){s[a]="canceled",r.onCancel({results:s});continue}s[a]=u}return s},Pt=e=>{const{selectableGroups:r=!0,groupSpacing:s=0}=e,i=(o,u,l=[])=>{const n=o.label??String(o.value),c=typeof o.group=="string",p=c&&(l[l.indexOf(o)+1]??{group:!0}),f=c&&p&&p.group===!0,g=c?r?`${f?x:h} `:" ":"";let E="";if(s>0&&!c){const m=`
${t("cyan",h)}`;E=`${m.repeat(s-1)}${m} `}if(u==="active")return`${E}${t("dim",g)}${t("cyan",te)} ${n}${o.hint?` ${t("dim",`(${o.hint})`)}`:""}`;if(u==="group-active")return`${E}${g}${t("cyan",te)} ${t("dim",n)}`;if(u==="group-active-selected")return`${E}${g}${t("green",U)} ${t("dim",n)}`;if(u==="selected"){const m=c||r?t("green",U):"";return`${E}${t("dim",g)}${m} ${t("dim",n)}${o.hint?` ${t("dim",`(${o.hint})`)}`:""}`}if(u==="cancelled")return`${t(["strikethrough","dim"],n)}`;if(u==="active-selected")return`${E}${t("dim",g)}${t("green",U)} ${n}${o.hint?` ${t("dim",`(${o.hint})`)}`:""}`;if(u==="submitted")return`${t("dim",n)}`;const $=c||r?t("dim",q):"";return`${E}${t("dim",g)}${$} ${t("dim",n)}`},a=e.required??!0;return new it({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:a,cursorAt:e.cursorAt,selectableGroups:r,validate(o){if(a&&(o===void 0||o.length===0))return`Please select at least one option.
${t("reset",t("dim",`Press ${t(["gray","bgWhite","inverse"]," space ")} to select, ${t("gray",t(["bgWhite","inverse"]," enter "))} to submit`))}`},render(){const o=`${t("gray",h)}
${W(this.state)} ${e.message}
`,u=this.value??[];switch(this.state){case"submit":{const l=this.options.filter(({value:c})=>u.includes(c)).map(c=>i(c,"submitted")),n=l.length===0?"":` ${l.join(t("dim",", "))}`;return`${o}${t("gray",h)}${n}`}case"cancel":{const l=this.options.filter(({value:n})=>u.includes(n)).map(n=>i(n,"cancelled")).join(t("dim",", "));return`${o}${t("gray",h)} ${l.trim()?`${l}
${t("gray",h)}`:""}`}case"error":{const l=this.error.split(`
`).map((n,c)=>c===0?`${t("yellow",x)} ${t("yellow",n)}`:` ${n}`).join(`
`);return`${o}${t("yellow",h)} ${this.options.map((n,c,p)=>{const f=u.includes(n.value)||n.group===!0&&this.isGroupSelected(`${n.value}`),g=c===this.cursor;return!g&&typeof n.group=="string"&&this.options[this.cursor].value===n.group?i(n,f?"group-active-selected":"group-active",p):g&&f?i(n,"active-selected",p):f?i(n,"selected",p):i(n,g?"active":"inactive",p)}).join(`
${t("yellow",h)} `)}
${l}
`}default:{const l=this.options.map((c,p,f)=>{const g=u.includes(c.value)||c.group===!0&&this.isGroupSelected(`${c.value}`),E=p===this.cursor,$=!E&&typeof c.group=="string"&&this.options[this.cursor].value===c.group;let m="";return $?m=i(c,g?"group-active-selected":"group-active",f):E&&g?m=i(c,"active-selected",f):g?m=i(c,"selected",f):m=i(c,E?"active":"inactive",f),`${p!==0&&!m.startsWith(`
`)?" ":""}${m}`}).join(`
${t("cyan",h)}`),n=l.startsWith(`
`)?"":" ";return`${o}${t("cyan",h)}${n}${l}
${t("cyan",x)}
`}}}}).prompt()},R={message:(e=[],{symbol:r=t("gray",h),secondarySymbol:s=t("gray",h),output:i=process.stdout,spacing:a=1,withGuide:o}={})=>{const u=[],l=o??_.withGuide,n=l?s:"",c=l?`${r} `:"",p=l?`${s} `:"";for(let g=0;g<a;g++)u.push(n);const f=Array.isArray(e)?e:e.split(`
`);if(f.length>0){const[g,...E]=f;g.length>0?u.push(`${c}${g}`):u.push(l?r:"");for(const $ of E)$.length>0?u.push(`${p}${$}`):u.push(l?s:"")}i.write(`${u.join(`
${$}
`}}}}).prompt()},ut=e=>{const i=e.validate;return new De({...e,validate(s){if(s===void 0)return e.defaultValue!==void 0?void 0:i?i(s):I.date.messages.required;const r=u=>u.toISOString().slice(0,10);if(e.minDate&&r(s)<r(e.minDate))return I.date.messages.afterMin(e.minDate);if(e.maxDate&&r(s)>r(e.maxDate))return I.date.messages.beforeMax(e.maxDate);if(i)return i(s)},render(){const s=(e?.withGuide??I.withGuide)!==!1,r=`${`${s?`${t("gray",d)}
`:""}${V(this.state)} `}${e.message}
`,u=this.state!=="initial"?this.state:"active",n=lt(this,u),o=this.value instanceof Date?this.formattedValue:"";switch(this.state){case"error":{const c=this.error?` ${t("yellow",this.error)}`:"",a=s?`${t("yellow",d)} `:"",l=s?t("yellow",E):"";return`${r.trim()}
${a}${n}
${l}${c}
`}case"submit":{const c=o?` ${t("dim",o)}`:"",a=s?t("gray",d):"";return`${r}${a}${c}`}case"cancel":{const c=o?` ${t(["strikethrough","dim"],o)}`:"",a=s?t("gray",d):"";return`${r}${a}${c}${o.trim()?`
${a}`:""}`}default:{const c=s?`${t("cyan",d)} `:"",a=s?t("cyan",E):"",l=s?`${t("cyan",d)} `:"",$=this.inlineError?`
${l}${t("yellow",this.inlineError)}`:"";return`${r}${c}${n}${$}
${a}
`}}}}).prompt()};function lt(e,i){const s=e.segmentValues,r=e.segmentCursor;if(i==="submit"||i==="cancel")return e.formattedValue;const u=t("gray",e.separator);return e.segments.map((n,o)=>{const c=o===r.segmentIndex&&!["submit","cancel"].includes(i),a=$t[n.type];return ct(s[n.type],{isActive:c,label:a})}).join(u)}function ct(e,i){const s=!e||e.replace(/_/g,"")==="";return i.isActive?t("inverse",s?i.label:e.replace(/_/g," ")):s?t("dim",i.label):e.replace(/_/g,t("dim"," "))}const $t={year:"yyyy",month:"mm",day:"dd"},dt=async(e,i)=>{const s={},r=Object.keys(e);for(const u of r){const n=e[u],o=await n({results:s})?.catch(c=>{throw c});if(typeof i?.onCancel=="function"&&We(o)){s[u]="canceled",i.onCancel({results:s});continue}s[u]=o}return s},ht=e=>{const{selectableGroups:i=!0,groupSpacing:s=0}=e,r=(n,o,c=[])=>{const a=n.label??String(n.value),l=typeof n.group=="string",$=l&&(c[c.indexOf(n)+1]??{group:!0}),y=l&&$&&$.group===!0,p=l?i?`${y?E:d} `:" ":"";let m="";if(s>0&&!l){const S=`
${t("cyan",d)}`;m=`${S.repeat(s-1)}${S} `}if(o==="active")return`${m}${t("dim",p)}${t("cyan",te)} ${a}${n.hint?` ${t("dim",`(${n.hint})`)}`:""}`;if(o==="group-active")return`${m}${p}${t("cyan",te)} ${t("dim",a)}`;if(o==="group-active-selected")return`${m}${p}${t("green",U)} ${t("dim",a)}`;if(o==="selected"){const S=l||i?t("green",U):"";return`${m}${t("dim",p)}${S} ${t("dim",a)}${n.hint?` ${t("dim",`(${n.hint})`)}`:""}`}if(o==="cancelled")return`${t(["strikethrough","dim"],a)}`;if(o==="active-selected")return`${m}${t("dim",p)}${t("green",U)} ${a}${n.hint?` ${t("dim",`(${n.hint})`)}`:""}`;if(o==="submitted")return`${t("dim",a)}`;const g=l||i?t("dim",J):"";return`${m}${t("dim",p)}${g} ${t("dim",a)}`},u=e.required??!0;return new Fe({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:u,cursorAt:e.cursorAt,selectableGroups:i,validate(n){if(u&&(n===void 0||n.length===0))return`Please select at least one option.
${t("reset",t("dim",`Press ${t(["gray","bgWhite","inverse"]," space ")} to select, ${t("gray",t(["bgWhite","inverse"]," enter "))} to submit`))}`},render(){const n=e.withGuide??I.withGuide,o=`${n?`${t("gray",d)}
`:""}${V(this.state)} ${e.message}
`,c=this.value??[];switch(this.state){case"submit":{const a=this.options.filter(({value:$})=>c.includes($)).map($=>r($,"submitted")),l=a.length===0?"":` ${a.join(t("dim",", "))}`;return`${o}${n?t("gray",d):""}${l}`}case"cancel":{const a=this.options.filter(({value:l})=>c.includes(l)).map(l=>r(l,"cancelled")).join(t("dim",", "));return`${o}${n?`${t("gray",d)} `:""}${a.trim()?`${a}${n?`
${t("gray",d)}`:""}`:""}`}case"error":{const a=this.error.split(`
`).map((l,$)=>$===0?`${n?`${t("yellow",E)} `:""}${t("yellow",l)}`:` ${l}`).join(`
`);return`${o}${n?`${t("yellow",d)} `:""}${this.options.map((l,$,y)=>{const p=c.includes(l.value)||l.group===!0&&this.isGroupSelected(`${l.value}`),m=$===this.cursor;return!m&&typeof l.group=="string"&&this.options[this.cursor].value===l.group?r(l,p?"group-active-selected":"group-active",y):m&&p?r(l,"active-selected",y):p?r(l,"selected",y):r(l,m?"active":"inactive",y)}).join(`
${n?`${t("yellow",d)} `:""}`)}
${a}
`}default:{const a=this.options.map(($,y,p)=>{const m=c.includes($.value)||$.group===!0&&this.isGroupSelected(`${$.value}`),g=y===this.cursor,S=!g&&typeof $.group=="string"&&this.options[this.cursor].value===$.group;let h="";return S?h=r($,m?"group-active-selected":"group-active",p):g&&m?h=r($,"active-selected",p):m?h=r($,"selected",p):h=r($,g?"active":"inactive",p),`${y!==0&&!h.startsWith(`
`)?" ":""}${h}`}).join(`
${n?t("cyan",d):""}`),l=a.startsWith(`
`)?"":" ";return`${o}${n?t("cyan",d):""}${l}${a}
${n?t("cyan",E):""}
`}}}}).prompt()},O={message:(e=[],{symbol:i=t("gray",d),secondarySymbol:s=t("gray",d),output:r=process.stdout,spacing:u=1,withGuide:n}={})=>{const o=[],c=n??I.withGuide,a=c?s:"",l=c?`${i} `:"",$=c?`${s} `:"";for(let p=0;p<u;p++)o.push(a);const y=Array.isArray(e)?e:e.split(`
`);if(y.length>0){const[p,...m]=y;p.length>0?o.push(`${l}${p}`):o.push(c?i:"");for(const g of m)g.length>0?o.push(`${$}${g}`):o.push(c?s:"")}r.write(`${o.join(`
`)}
`)},info:(e,r)=>{R.message(e,{...r,symbol:t("blue",fe)})},success:(e,r)=>{R.message(e,{...r,symbol:t("green",Fe)})},step:(e,r)=>{R.message(e,{...r,symbol:t("green",V)})},warn:(e,r)=>{R.message(e,{...r,symbol:t("yellow",ye)})},warning:(e,r)=>{R.warn(e,r)},error:(e,r)=>{R.message(e,{...r,symbol:t("red",Ee)})}},Nt=(e="",r)=>{const s=r?.output??process.stdout,i=r?.withGuide??_.withGuide?`${t("gray",x)} `:"";s.write(`${i}${t("red",e)}
`)},info:(e,i)=>{O.message(e,{...i,symbol:t("blue",he)})},success:(e,i)=>{O.message(e,{...i,symbol:t("green",pe)})},step:(e,i)=>{O.message(e,{...i,symbol:t("green",F)})},warn:(e,i)=>{O.message(e,{...i,symbol:t("yellow",me)})},warning:(e,i)=>{O.warn(e,i)},error:(e,i)=>{O.message(e,{...i,symbol:t("red",ge)})}},pt=(e="",i)=>{const s=i?.output??process.stdout,r=i?.withGuide??I.withGuide?`${t("gray",E)} `:"";s.write(`${r}${t("red",e)}
`)},Wt=(e="",r)=>{const s=r?.output??process.stdout,i=r?.withGuide??_.withGuide?`${t("gray",he)} `:"";s.write(`${i}${e}
`)},Gt=(e="",r)=>{const s=r?.output??process.stdout,i=r?.withGuide??_.withGuide?`${t("gray",h)}
${t("gray",x)} `:"";s.write(`${i}${e}
`)},mt=(e="",i)=>{const s=i?.output??process.stdout,r=i?.withGuide??I.withGuide?`${t("gray",le)} `:"";s.write(`${r}${e}
`)},gt=(e="",i)=>{const s=i?.output??process.stdout,r=i?.withGuide??I.withGuide?`${t("gray",d)}
${t("gray",E)} `:"";s.write(`${r}${e}
`)},Q=(e,r)=>e.split(`
`).map(s=>r(s)).join(`
`),Lt=e=>{const r=(i,a)=>{const o=i.label??String(i.value);return a==="disabled"?`${t("gray",q)} ${Q(o,u=>t(["strikethrough","gray"],u))}${i.hint?` ${t("dim",`(${i.hint??"disabled"})`)}`:""}`:a==="active"?`${t("cyan",te)} ${o}${i.hint?` ${t("dim",`(${i.hint})`)}`:""}`:a==="selected"?`${t("green",U)} ${Q(o,u=>t("dim",u))}${i.hint?` ${t("dim",`(${i.hint})`)}`:""}`:a==="cancelled"?`${Q(o,u=>t(["strikethrough","dim"],u))}`:a==="active-selected"?`${t("green",U)} ${o}${i.hint?` ${t("dim",`(${i.hint})`)}`:""}`:a==="submitted"?`${Q(o,u=>t("dim",u))}`:`${t("dim",q)} ${Q(o,u=>t("dim",u))}`},s=e.required??!0;return new nt({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:s,cursorAt:e.cursorAt,validate(i){if(s&&(i===void 0||i.length===0))return`Please select at least one option.
${t("reset",t("dim",`Press ${t(["gray","bgWhite","inverse"]," space ")} to select, ${t("gray",t("bgWhite",t("inverse"," enter ")))} to submit`))}`},render(){const i=j(e.output,e.message,`${ve(this.state)} `,`${W(this.state)} `),a=`${t("gray",h)}
${i}
`,o=this.value??[],u=(l,n)=>{if(l.disabled)return r(l,"disabled");const c=o.includes(l.value);return n&&c?r(l,"active-selected"):c?r(l,"selected"):r(l,n?"active":"inactive")};switch(this.state){case"submit":{const l=this.options.filter(({value:c})=>o.includes(c)).map(c=>r(c,"submitted")).join(t("dim",", "))||t("dim","none"),n=j(e.output,l,`${t("gray",h)} `);return`${a}${n}`}case"cancel":{const l=this.options.filter(({value:c})=>o.includes(c)).map(c=>r(c,"cancelled")).join(t("dim",", "));if(l.trim()==="")return`${a}${t("gray",h)}`;const n=j(e.output,l,`${t("gray",h)} `);return`${a}${n}
${t("gray",h)}`}case"error":{const l=`${t("yellow",h)} `,n=this.error.split(`
`).map((f,g)=>g===0?`${t("yellow",x)} ${t("yellow",f)}`:` ${f}`).join(`
`),c=a.split(`
`).length,p=n.split(`
`).length+1;return`${a}${l}${X({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:l.length,rowPadding:c+p,style:u}).join(`
${l}`)}
`)},Q=(e,i)=>e.split(`
`).map(s=>i(s)).join(`
`),yt=e=>{const i=(r,u)=>{const n=r.label??String(r.value);return u==="disabled"?`${t("gray",J)} ${Q(n,o=>t(["strikethrough","gray"],o))}${r.hint?` ${t("dim",`(${r.hint??"disabled"})`)}`:""}`:u==="active"?`${t("cyan",te)} ${n}${r.hint?` ${t("dim",`(${r.hint})`)}`:""}`:u==="selected"?`${t("green",U)} ${Q(n,o=>t("dim",o))}${r.hint?` ${t("dim",`(${r.hint})`)}`:""}`:u==="cancelled"?`${Q(n,o=>t(["strikethrough","dim"],o))}`:u==="active-selected"?`${t("green",U)} ${n}${r.hint?` ${t("dim",`(${r.hint})`)}`:""}`:u==="submitted"?`${Q(n,o=>t("dim",o))}`:`${t("dim",J)} ${Q(n,o=>t("dim",o))}`},s=e.required??!0;return new He({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:s,cursorAt:e.cursorAt,validate(r){if(s&&(r===void 0||r.length===0))return`Please select at least one option.
${t("reset",t("dim",`Press ${t(["gray","bgWhite","inverse"]," space ")} to select, ${t("gray",t("bgWhite",t("inverse"," enter ")))} to submit`))}`},render(){const r=e.withGuide??I.withGuide,u=N(e.output,e.message,r?`${ye(this.state)} `:"",`${V(this.state)} `),n=`${r?`${t("gray",d)}
`:""}${u}
`,o=this.value??[],c=(a,l)=>{if(a.disabled)return i(a,"disabled");const $=o.includes(a.value);return l&&$?i(a,"active-selected"):$?i(a,"selected"):i(a,l?"active":"inactive")};switch(this.state){case"submit":{const a=this.options.filter(({value:$})=>o.includes($)).map($=>i($,"submitted")).join(t("dim",", "))||t("dim","none"),l=N(e.output,a,r?`${t("gray",d)} `:"");return`${n}${l}`}case"cancel":{const a=this.options.filter(({value:$})=>o.includes($)).map($=>i($,"cancelled")).join(t("dim",", "));if(a.trim()==="")return`${n}${t("gray",d)}`;const l=N(e.output,a,r?`${t("gray",d)} `:"");return`${n}${l}${r?`
${t("gray",d)}`:""}`}case"error":{const a=r?`${t("yellow",d)} `:"",l=this.error.split(`
`).map((p,m)=>m===0?`${r?`${t("yellow",E)} `:""}${t("yellow",p)}`:` ${p}`).join(`
`),$=n.split(`
`).length,y=l.split(`
`).length+1;return`${n}${a}${Y({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:a.length,rowPadding:$+y,style:c}).join(`
${a}`)}
${l}
`}default:{const a=r?`${t("cyan",d)} `:"",l=n.split(`
`).length,$=r?2:1;return`${n}${a}${Y({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:a.length,rowPadding:l+$,style:c}).join(`
${a}`)}
${r?t("cyan",E):""}
`}}}}).prompt()},ft=e=>t("dim",e),vt=(e,i,s)=>{const r={hard:!0,trim:!1},u=q(e,i,r).split(`
`),n=u.reduce((a,l)=>Math.max(B(l),a),0),o=u.map(s).reduce((a,l)=>Math.max(B(l),a),0),c=i-(o-n);return q(e,c,r)},wt=(e="",i="",s)=>{const r=s?.output??P.stdout,u=s?.withGuide??I.withGuide,n=s?.format??ft,o=["",...vt(e,X(r)-6,n).split(`
`).map(n),""],c=B(i),a=Math.max(o.reduce((p,m)=>{const g=B(m);return g>p?g:p},0),c)+2,l=o.map(p=>`${t("gray",d)} ${p}${" ".repeat(a-B(p))}${t("gray",d)}`).join(`
`),$=u?`${t("gray",d)}
`:"",y=u?Ge:de;r.write(`${$}${t("green",F)} ${t("reset",i)} ${t("gray",se.repeat(Math.max(a-c-1,1))+ce)}
${l}
${t("gray",y+se.repeat(a+2)+$e)}
`)},bt=e=>new Ue({validate:e.validate,mask:e.mask??xe,signal:e.signal,input:e.input,output:e.output,render(){const i=e.withGuide??I.withGuide,s=`${i?`${t("gray",d)}
`:""}${V(this.state)} ${e.message}
`,r=this.userInputWithCursor,u=this.masked;switch(this.state){case"error":{const n=i?`${t("yellow",d)} `:"",o=i?`${t("yellow",E)} `:"",c=u??"";return e.clearOnError&&this.clear(),`${s.trim()}
${n}${c}
${o}${t("yellow",this.error)}
`}case"submit":{const n=i?`${t("gray",d)} `:"",o=u?t("dim",u):"";return`${s}${n}${o}`}case"cancel":{const n=i?`${t("gray",d)} `:"",o=u?t(["strikethrough","dim"],u):"";return`${s}${n}${o}${u&&i?`
${t("gray",d)}`:""}`}default:{const n=i?`${t("cyan",d)} `:"",o=i?t("cyan",E):"";return`${s}${n}${r}
${o}
`}}}}).prompt(),St=e=>{const i=e.validate;return Ae({...e,initialUserInput:e.initialValue??e.root??process.cwd(),maxItems:5,validate(s){if(!Array.isArray(s)){if(!s)return"Please select a path";if(i)return i(s)}},options(){const s=this.userInput;if(s==="")return[];try{let r;Xe(s)?we(s).isDirectory()&&(!e.directory||s.endsWith("/"))?r=s:r=be(s):r=be(s);const u=s.length>1&&s.endsWith("/")?s.slice(0,-1):s;return ze(r).map(n=>{const o=Qe(r,n),c=we(o);return{name:n,path:o,isDirectory:c.isDirectory()}}).filter(({path:n,isDirectory:o})=>n.startsWith(u)&&(o||!e.directory)).map(n=>({value:n.path}))}catch{return[]}}})},Ct=e=>t("magenta",e),fe=({indicator:e="dots",onCancel:i,output:s=process.stdout,cancelMessage:r,errorMessage:u,frames:n=ee?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=ee?80:120,signal:c,...a}={})=>{const l=ae();let $,y,p=!1,m=!1,g="",S,h=performance.now();const f=X(s),v=a?.styleFrame??Ct,T=_=>{const A=_>1?u??I.messages.error:r??I.messages.cancel;m=_===1,p&&(W(A,_),m&&typeof i=="function"&&i())},C=()=>T(2),b=()=>T(1),x=()=>{process.on("uncaughtExceptionMonitor",C),process.on("unhandledRejection",C),process.on("SIGINT",b),process.on("SIGTERM",b),process.on("exit",T),c&&c.addEventListener("abort",b)},G=()=>{process.removeListener("uncaughtExceptionMonitor",C),process.removeListener("unhandledRejection",C),process.removeListener("SIGINT",b),process.removeListener("SIGTERM",b),process.removeListener("exit",T),c&&c.removeEventListener("abort",b)},M=()=>{if(S===void 0)return;l&&s.write(`
`);const _=q(S,f,{hard:!0,trim:!1}).split(`
`);_.length>1&&s.write(Se.up(_.length-1)),s.write(Se.to(0)),s.write(Ce.down())},R=_=>_.replace(/\.+$/,""),j=_=>{const A=(performance.now()-_)/1e3,k=Math.floor(A/60),L=Math.floor(A%60);return k>0?`[${k}m ${L}s]`:`[${L}s]`},D=a.withGuide??I.withGuide,ie=(_="")=>{p=!0,$=Ke({output:s}),g=R(_),h=performance.now(),D&&s.write(`${t("gray",d)}
`);let A=0,k=0;x(),y=setInterval(()=>{if(l&&g===S)return;M(),S=g;const L=v(n[A]);let Z;if(l)Z=`${L} ${g}...`;else if(e==="timer")Z=`${L} ${g} ${j(h)}`;else{const Be=".".repeat(Math.floor(k)).slice(0,3);Z=`${L} ${g}${Be}`}const Ne=q(Z,f,{hard:!0,trim:!1});s.write(Ne),A=A+1<n.length?A+1:0,k=k<4?k+.125:0},o)},W=(_="",A=0,k=!1)=>{if(!p)return;p=!1,clearInterval(y),M();const L=A===0?t("green",F):A===1?t("red",oe):t("red",ue);g=_??g,k||(e==="timer"?s.write(`${L} ${g} ${j(h)}
`):s.write(`${L} ${g}
`)),G(),$()};return{start:ie,stop:(_="")=>W(_,0),message:(_="")=>{g=R(_??g)},cancel:(_="")=>W(_,1),error:(_="")=>W(_,2),clear:()=>W("",0,!0),get isCancelled(){return m}}},Ve={light:w("\u2500","-"),heavy:w("\u2501","="),block:w("\u2588","#")};function Tt({style:e="heavy",max:i=100,size:s=40,...r}={}){const u=fe(r);let n=0,o="";const c=Math.max(1,i),a=Math.max(1,s),l=m=>{switch(m){case"initial":case"active":return g=>t("magenta",g);case"error":case"cancel":return g=>t("red",g);case"submit":return g=>t("green",g);default:return g=>t("magenta",g)}},$=(m,g)=>{const S=Math.floor(n/c*a);return`${l(m)(Ve[e].repeat(S))}${t("dim",Ve[e].repeat(a-S))} ${g}`},y=(m="")=>{o=m,u.start($("initial",m))},p=(m=1,g)=>{n=Math.min(c,m+n),u.message($("active",g??o)),o=g??o};return{start:y,stop:u.stop,cancel:u.cancel,error:u.error,clear:u.clear,advance:p,isCancelled:u.isCancelled,message:m=>p(0,m)}}const re=(e,i)=>e.includes(`
`)?e.split(`
`).map(s=>i(s)).join(`
`):i(e),_t=e=>{const i=(s,r)=>{const u=s.label??String(s.value);switch(r){case"disabled":return`${t("gray",H)} ${re(u,n=>t("gray",n))}${s.hint?` ${t("dim",`(${s.hint??"disabled"})`)}`:""}`;case"selected":return`${re(u,n=>t("dim",n))}`;case"active":return`${t("green",z)} ${u}${s.hint?` ${t("dim",`(${s.hint})`)}`:""}`;case"cancelled":return`${re(u,n=>t(["strikethrough","dim"],n))}`;default:return`${t("dim",H)} ${re(u,n=>t("dim",n))}`}};return new qe({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const s=e.withGuide??I.withGuide,r=`${V(this.state)} `,u=`${ye(this.state)} `,n=N(e.output,e.message,u,r),o=`${s?`${t("gray",d)}
`:""}${n}
`;switch(this.state){case"submit":{const c=s?`${t("gray",d)} `:"",a=N(e.output,i(this.options[this.cursor],"selected"),c);return`${o}${a}`}case"cancel":{const c=s?`${t("gray",d)} `:"",a=N(e.output,i(this.options[this.cursor],"cancelled"),c);return`${o}${a}${s?`
${t("gray",d)}`:""}`}default:{const c=s?`${t("cyan",d)} `:"",a=s?t("cyan",E):"",l=o.split(`
`).length,$=s?2:1;return`${o}${c}${Y({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:c.length,rowPadding:l+$,style:(y,p)=>i(y,y.disabled?"disabled":p?"active":"inactive")}).join(`
${c}`)}
${a}
`}}}}).prompt()},It=e=>{const i=(s,r="inactive")=>{const u=s.label??String(s.value);return r==="selected"?`${t("dim",u)}`:r==="cancelled"?`${t(["strikethrough","dim"],u)}`:r==="active"?`${t(["bgCyan","gray"],` ${s.value} `)} ${u}${s.hint?` ${t("dim",`(${s.hint})`)}`:""}`:`${t(["gray","bgWhite","inverse"],` ${s.value} `)} ${u}${s.hint?` ${t("dim",`(${s.hint})`)}`:""}`};return new Je({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,caseSensitive:e.caseSensitive,render(){const s=e.withGuide??I.withGuide,r=`${s?`${t("gray",d)}
`:""}${V(this.state)} ${e.message}
`;switch(this.state){case"submit":{const u=s?`${t("gray",d)} `:"",n=this.options.find(c=>c.value===this.value)??e.options[0],o=N(e.output,i(n,"selected"),u);return`${r}${o}`}case"cancel":{const u=s?`${t("gray",d)} `:"",n=N(e.output,i(this.options[0],"cancelled"),u);return`${r}${n}${s?`
${t("gray",d)}`:""}`}default:{const u=s?`${t("cyan",d)} `:"",n=s?t("cyan",E):"",o=this.options.map((c,a)=>N(e.output,i(c,a===this.cursor?"active":"inactive"),u)).join(`
`);return`${r}${o}
${n}
`}default:{const l=`${t("cyan",h)} `,n=a.split(`
`).length;return`${a}${l}${X({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:l.length,rowPadding:n+2,style:u}).join(`
${l}`)}
${t("cyan",x)}
`}}}}).prompt()},jt=e=>t("dim",e),kt=(e,r,s)=>{const i={hard:!0,trim:!1},a=J(e,r,i).split(`
`),o=a.reduce((n,c)=>Math.max(D(c),n),0),u=a.map(s).reduce((n,c)=>Math.max(D(c),n),0),l=r-(u-o);return J(e,l,i)},Vt=(e="",r="",s)=>{const i=s?.output??N.stdout,a=s?.withGuide??_.withGuide,o=s?.format??jt,u=["",...kt(e,Y(i)-6,o).split(`
`).map(o),""],l=D(r),n=Math.max(u.reduce((g,E)=>{const $=D(E);return $>g?$:g},0),l)+2,c=u.map(g=>`${t("gray",h)} ${g}${" ".repeat(n-D(g))}${t("gray",h)}`).join(`
`),p=a?`${t("gray",h)}
`:"",f=a?We:ge;i.write(`${p}${t("green",V)} ${t("reset",r)} ${t("gray",se.repeat(Math.max(n-l-1,1))+pe)}
`}}}}).prompt()},je=`${t("gray",d)} `,K={message:async(e,{symbol:i=t("gray",d)}={})=>{process.stdout.write(`${t("gray",d)}
${i} `);let s=3;for await(let r of e){r=r.replace(/\n/g,`
${je}`),r.includes(`
`)&&(s=3+ne(r.slice(r.lastIndexOf(`
`))).length);const u=ne(r).length;s+u<process.stdout.columns?(s+=u,process.stdout.write(r)):(process.stdout.write(`
${je}${r.trimStart()}`),s=3+ne(r.trimStart()).length)}process.stdout.write(`
`)},info:e=>K.message(e,{symbol:t("blue",he)}),success:e=>K.message(e,{symbol:t("green",pe)}),step:e=>K.message(e,{symbol:t("green",F)}),warn:e=>K.message(e,{symbol:t("yellow",me)}),warning:e=>K.warn(e),error:e=>K.message(e,{symbol:t("red",ge)})},Et=async(e,i)=>{for(const s of e){if(s.enabled===!1)continue;const r=fe(i);r.start(s.title);const u=await s.task(r.message);r.stop(u||s.title)}},xt=e=>e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,""),Gt=e=>{const i=e.output??process.stdout,s=X(i),r=t("gray",d),u=e.spacing??1,n=3,o=e.retainLog===!0,c=!ae()&&Te(i);i.write(`${r}
`),i.write(`${t("green",F)} ${e.title}
`);for(let h=0;h<u;h++)i.write(`${r}
`);const a=[{value:"",full:""}];let l=!1;const $=h=>{if(a.length===0)return;let f=0;h&&(f+=u+2);for(const v of a){const{value:T,result:C}=v;let b=C?.message??T;if(b.length===0)continue;C===void 0&&v.header!==void 0&&v.header!==""&&(b+=`
${v.header}`);const x=b.split(`
`).reduce((G,M)=>M===""?G+1:G+Math.ceil((M.length+n)/s),0);f+=x}f>0&&(f+=1,i.write(Ce.lines(f)))},y=(h,f,v)=>{const T=v?`${h.full}
${h.value}`:h.value;h.header!==void 0&&h.header!==""&&O.message(h.header.split(`
`).map(C=>t("bold",C)),{output:i,secondarySymbol:r,symbol:r,spacing:0}),O.message(T.split(`
`).map(C=>t("dim",C)),{output:i,secondarySymbol:r,symbol:r,spacing:f??u})},p=()=>{for(const h of a){const{header:f,value:v,full:T}=h;(f===void 0||f.length===0)&&v.length===0||y(h,void 0,o===!0&&T.length>0)}},m=(h,f,v)=>{if($(!1),(v?.raw!==!0||!l)&&h.value!==""&&(h.value+=`
`),h.value+=xt(f),l=v?.raw===!0,e.limit!==void 0){const T=h.value.split(`
`),C=T.length-e.limit;if(C>0){const b=T.splice(0,C);o&&(h.full+=(h.full===""?"":`
`)+b.join(`
`))}h.value=T.join(`
`)}c&&g()},g=()=>{for(const h of a)h.result?h.result.status==="error"?O.error(h.result.message,{output:i,secondarySymbol:r,spacing:0}):O.success(h.result.message,{output:i,secondarySymbol:r,spacing:0}):h.value!==""&&y(h,0)},S=(h,f)=>{$(!1),h.result=f,c&&g()};return{message(h,f){m(a[0],h,f)},group(h){const f={header:h,value:"",full:""};return a.push(f),{message(v,T){m(f,v,T)},error(v){S(f,{status:"error",message:v})},success(v){S(f,{status:"success",message:v})}}},error(h,f){$(!0),O.error(h,{output:i,secondarySymbol:r,spacing:1}),f?.showLog!==!1&&p(),a.splice(1,a.length-1),a[0].value="",a[0].full=""},success(h,f){$(!0),O.success(h,{output:i,secondarySymbol:r,spacing:1}),f?.showLog===!0&&p(),a.splice(1,a.length-1),a[0].value="",a[0].full=""}}},Ot=e=>new Ye({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){const i=e?.withGuide??I.withGuide,s=`${`${i?`${t("gray",d)}
`:""}${V(this.state)} `}${e.message}
`,r=e.placeholder?t("inverse",e.placeholder[0])+t("dim",e.placeholder.slice(1)):t(["inverse","hidden"],"_"),u=this.userInput?this.userInputWithCursor:r,n=this.value??"";switch(this.state){case"error":{const o=this.error?` ${t("yellow",this.error)}`:"",c=i?`${t("yellow",d)} `:"",a=i?t("yellow",E):"";return`${s.trim()}
${c}${u}
${a}${o}
`}case"submit":{const o=n?` ${t("dim",n)}`:"",c=i?t("gray",d):"";return`${s}${c}${o}`}case"cancel":{const o=n?` ${t(["strikethrough","dim"],n)}`:"",c=i?t("gray",d):"";return`${s}${c}${o}${n.trim()?`
${c}`:""}`}default:{const o=i?`${t("cyan",d)} `:"",c=i?t("cyan",E):"";return`${s}${o}${u}
${c}
${t("gray",f+se.repeat(n+2)+me)}
`)},Ht=e=>new at({validate:e.validate,mask:e.mask??Ne,signal:e.signal,input:e.input,output:e.output,render(){const r=e.withGuide??_.withGuide,s=`${r?`${t("gray",h)}
`:""}${W(this.state)} ${e.message}
`,i=this.userInputWithCursor,a=this.masked;switch(this.state){case"error":{const o=r?`${t("yellow",h)} `:"",u=r?`${t("yellow",x)} `:"",l=a??"";return e.clearOnError&&this.clear(),`${s.trim()}
${o}${l}
${u}${t("yellow",this.error)}
`}case"submit":{const o=r?`${t("gray",h)} `:"",u=a?t("dim",a):"";return`${s}${o}${u}`}case"cancel":{const o=r?`${t("gray",h)} `:"",u=a?t(["strikethrough","dim"],a):"";return`${s}${o}${u}${a&&r?`
${t("gray",h)}`:""}`}default:{const o=r?`${t("cyan",h)} `:"",u=r?t("cyan",x):"";return`${s}${o}${i}
${u}
`}}}}).prompt(),Ut=e=>{const r=e.validate;return Xe({...e,initialUserInput:e.initialValue??e.root??process.cwd(),maxItems:5,validate(s){if(!Array.isArray(s)){if(!s)return"Please select a path";if(r)return r(s)}},options(){const s=this.userInput;if(s==="")return[];try{let i;return dt(s)?xe(s).isDirectory()?i=s:i=_e(s):i=_e(s),$t(i).map(a=>{const o=ht(i,a),u=xe(o);return{name:a,path:o,isDirectory:u.isDirectory()}}).filter(({path:a,isDirectory:o})=>a.startsWith(s)&&(e.directory||!o)).map(a=>({value:a.path}))}catch{return[]}}})},Kt=e=>t("magenta",e),be=({indicator:e="dots",onCancel:r,output:s=process.stdout,cancelMessage:i,errorMessage:a,frames:o=ee?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:u=ee?80:120,signal:l,...n}={})=>{const c=ce();let p,f,g=!1,E=!1,$="",m,d=performance.now();const F=Y(s),y=n?.styleFrame??Kt,v=B=>{const P=B>1?a??_.messages.error:i??_.messages.cancel;E=B===1,g&&(k(P,B),E&&typeof r=="function"&&r())},C=()=>v(2),A=()=>v(1),b=()=>{process.on("uncaughtExceptionMonitor",C),process.on("unhandledRejection",C),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",v),l&&l.addEventListener("abort",A)},w=()=>{process.removeListener("uncaughtExceptionMonitor",C),process.removeListener("unhandledRejection",C),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",v),l&&l.removeEventListener("abort",A)},S=()=>{if(m===void 0)return;c&&s.write(`
`);const B=J(m,F,{hard:!0,trim:!1}).split(`
`);B.length>1&&s.write(De.up(B.length-1)),s.write(De.to(0)),s.write(Te.down())},T=B=>B.replace(/\.+$/,""),M=B=>{const P=(performance.now()-B)/1e3,G=Math.floor(P/60),L=Math.floor(P%60);return G>0?`[${G}m ${L}s]`:`[${L}s]`},O=n.withGuide??_.withGuide,le=(B="")=>{g=!0,p=ot({output:s}),$=T(B),d=performance.now(),O&&s.write(`${t("gray",h)}
`);let P=0,G=0;b(),f=setInterval(()=>{if(c&&$===m)return;S(),m=$;const L=y(o[P]);let Z;if(c)Z=`${L} ${$}...`;else if(e==="timer")Z=`${L} ${$} ${M(d)}`;else{const et=".".repeat(Math.floor(G)).slice(0,3);Z=`${L} ${$}${et}`}const Ze=J(Z,F,{hard:!0,trim:!1});s.write(Ze),P=P+1<o.length?P+1:0,G=G<4?G+.125:0},u)},k=(B="",P=0,G=!1)=>{if(!g)return;g=!1,clearInterval(f),S();const L=P===0?t("green",V):P===1?t("red",$e):t("red",de);$=B??$,G||(e==="timer"?s.write(`${L} ${$} ${M(d)}
`):s.write(`${L} ${$}
`)),w(),p()};return{start:le,stop:(B="")=>k(B,0),message:(B="")=>{$=T(B??$)},cancel:(B="")=>k(B,1),error:(B="")=>k(B,2),clear:()=>k("",0,!0),get isCancelled(){return E}}},ze={light:I("\u2500","-"),heavy:I("\u2501","="),block:I("\u2588","#")};function qt({style:e="heavy",max:r=100,size:s=40,...i}={}){const a=be(i);let o=0,u="";const l=Math.max(1,r),n=Math.max(1,s),c=E=>{switch(E){case"initial":case"active":return $=>t("magenta",$);case"error":case"cancel":return $=>t("red",$);case"submit":return $=>t("green",$);default:return $=>t("magenta",$)}},p=(E,$)=>{const m=Math.floor(o/l*n);return`${c(E)(ze[e].repeat(m))}${t("dim",ze[e].repeat(n-m))} ${$}`},f=(E="")=>{u=E,a.start(p("initial",E))},g=(E=1,$)=>{o=Math.min(l,E+o),a.message(p("active",$??u)),u=$??u};return{start:f,stop:a.stop,cancel:a.cancel,error:a.error,clear:a.clear,advance:g,isCancelled:a.isCancelled,message:E=>g(0,E)}}const oe=(e,r)=>e.includes(`
`)?e.split(`
`).map(s=>r(s)).join(`
`):r(e),Jt=e=>{const r=(s,i)=>{const a=s.label??String(s.value);switch(i){case"disabled":return`${t("gray",H)} ${oe(a,o=>t("gray",o))}${s.hint?` ${t("dim",`(${s.hint??"disabled"})`)}`:""}`;case"selected":return`${oe(a,o=>t("dim",o))}`;case"active":return`${t("green",z)} ${a}${s.hint?` ${t("dim",`(${s.hint})`)}`:""}`;case"cancelled":return`${oe(a,o=>t(["strikethrough","dim"],o))}`;default:return`${t("dim",H)} ${oe(a,o=>t("dim",o))}`}};return new lt({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const s=e.withGuide??_.withGuide,i=`${W(this.state)} `,a=`${ve(this.state)} `,o=j(e.output,e.message,a,i),u=`${s?`${t("gray",h)}
`:""}${o}
`;switch(this.state){case"submit":{const l=s?`${t("gray",h)} `:"",n=j(e.output,r(this.options[this.cursor],"selected"),l);return`${u}${n}`}case"cancel":{const l=s?`${t("gray",h)} `:"",n=j(e.output,r(this.options[this.cursor],"cancelled"),l);return`${u}${n}${s?`
${t("gray",h)}`:""}`}default:{const l=s?`${t("cyan",h)} `:"",n=s?t("cyan",x):"",c=u.split(`
`).length,p=s?2:1;return`${u}${l}${X({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:l.length,rowPadding:c+p,style:(f,g)=>r(f,f.disabled?"disabled":g?"active":"inactive")}).join(`
${l}`)}
${n}
`}}}}).prompt()},Xt=e=>{const r=(s,i="inactive")=>{const a=s.label??String(s.value);return i==="selected"?`${t("dim",a)}`:i==="cancelled"?`${t(["strikethrough","dim"],a)}`:i==="active"?`${t(["bgCyan","gray"],` ${s.value} `)} ${a}${s.hint?` ${t("dim",`(${s.hint})`)}`:""}`:`${t(["gray","bgWhite","inverse"],` ${s.value} `)} ${a}${s.hint?` ${t("dim",`(${s.hint})`)}`:""}`};return new ut({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,caseSensitive:e.caseSensitive,render(){const s=e.withGuide??_.withGuide,i=`${s?`${t("gray",h)}
`:""}${W(this.state)} ${e.message}
`;switch(this.state){case"submit":{const a=s?`${t("gray",h)} `:"",o=this.options.find(l=>l.value===this.value)??e.options[0],u=j(e.output,r(o,"selected"),a);return`${i}${u}`}case"cancel":{const a=s?`${t("gray",h)} `:"",o=j(e.output,r(this.options[0],"cancelled"),a);return`${i}${o}${s?`
${t("gray",h)}`:""}`}default:{const a=s?`${t("cyan",h)} `:"",o=s?t("cyan",x):"",u=this.options.map((l,n)=>j(e.output,r(l,n===this.cursor?"active":"inactive"),a)).join(`
`);return`${i}${u}
${o}
`}}}}).prompt()},Qe=`${t("gray",h)} `,K={message:async(e,{symbol:r=t("gray",h)}={})=>{process.stdout.write(`${t("gray",h)}
${r} `);let s=3;for await(let i of e){i=i.replace(/\n/g,`
${Qe}`),i.includes(`
`)&&(s=3+ue(i.slice(i.lastIndexOf(`
`))).length);const a=ue(i).length;s+a<process.stdout.columns?(s+=a,process.stdout.write(i)):(process.stdout.write(`
${Qe}${i.trimStart()}`),s=3+ue(i.trimStart()).length)}process.stdout.write(`
`)},info:e=>K.message(e,{symbol:t("blue",fe)}),success:e=>K.message(e,{symbol:t("green",Fe)}),step:e=>K.message(e,{symbol:t("green",V)}),warn:e=>K.message(e,{symbol:t("yellow",ye)}),warning:e=>K.warn(e),error:e=>K.message(e,{symbol:t("red",Ee)})},Yt=async(e,r)=>{for(const s of e){if(s.enabled===!1)continue;const i=be(r);i.start(s.title);const a=await s.task(i.message);i.stop(a||s.title)}},zt=e=>e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,""),Qt=e=>{const r=e.output??process.stdout,s=Y(r),i=t("gray",h),a=e.spacing??1,o=3,u=e.retainLog===!0,l=!ce()&&Me(r);r.write(`${i}
`),r.write(`${t("green",V)} ${e.title}
`);for(let d=0;d<a;d++)r.write(`${i}
`);const n=[{value:"",full:""}];let c=!1;const p=d=>{if(n.length===0)return;let F=0;d&&(F+=a+2);for(const y of n){const{value:v,result:C}=y;let A=C?.message??v;if(A.length===0)continue;C===void 0&&y.header!==void 0&&y.header!==""&&(A+=`
${y.header}`);const b=A.split(`
`).reduce((w,S)=>S===""?w+1:w+Math.ceil((S.length+o)/s),0);F+=b}F>0&&(F+=1,r.write(Te.lines(F)))},f=(d,F,y)=>{const v=y?`${d.full}
${d.value}`:d.value;d.header!==void 0&&d.header!==""&&R.message(d.header.split(`
`).map(C=>t("bold",C)),{output:r,secondarySymbol:i,symbol:i,spacing:0}),R.message(v.split(`
`).map(C=>t("dim",C)),{output:r,secondarySymbol:i,symbol:i,spacing:F??a})},g=()=>{for(const d of n){const{header:F,value:y,full:v}=d;(F===void 0||F.length===0)&&y.length===0||f(d,void 0,u===!0&&v.length>0)}},E=(d,F,y)=>{if(p(!1),(y?.raw!==!0||!c)&&d.value!==""&&(d.value+=`
`),d.value+=zt(F),c=y?.raw===!0,e.limit!==void 0){const v=d.value.split(`
`),C=v.length-e.limit;if(C>0){const A=v.splice(0,C);u&&(d.full+=(d.full===""?"":`
`)+A.join(`
`))}d.value=v.join(`
`)}l&&$()},$=()=>{for(const d of n)d.result?d.result.status==="error"?R.error(d.result.message,{output:r,secondarySymbol:i,spacing:0}):R.success(d.result.message,{output:r,secondarySymbol:i,spacing:0}):d.value!==""&&f(d,0)},m=(d,F)=>{p(!1),d.result=F,l&&$()};return{message(d,F){E(n[0],d,F)},group(d){const F={header:d,value:"",full:""};return n.push(F),{message(y,v){E(F,y,v)},error(y){m(F,{status:"error",message:y})},success(y){m(F,{status:"success",message:y})}}},error(d,F){p(!0),R.error(d,{output:r,secondarySymbol:i,spacing:1}),F?.showLog!==!1&&g(),n.splice(1,n.length-1),n[0].value="",n[0].full=""},success(d,F){p(!0),R.success(d,{output:r,secondarySymbol:i,spacing:1}),F?.showLog===!0&&g(),n.splice(1,n.length-1),n[0].value="",n[0].full=""}}},Zt=e=>new ct({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){const r=e?.withGuide??_.withGuide,s=`${`${r?`${t("gray",h)}
`:""}${W(this.state)} `}${e.message}
`,i=e.placeholder?t("inverse",e.placeholder[0])+t("dim",e.placeholder.slice(1)):t(["inverse","hidden"],"_"),a=this.userInput?this.userInputWithCursor:i,o=this.value??"";switch(this.state){case"error":{const u=this.error?` ${t("yellow",this.error)}`:"",l=r?`${t("yellow",h)} `:"",n=r?t("yellow",x):"";return`${s.trim()}
${l}${a}
${n}${u}
`}case"submit":{const u=o?` ${t("dim",o)}`:"",l=r?t("gray",h):"";return`${s}${l}${u}`}case"cancel":{const u=o?` ${t(["strikethrough","dim"],o)}`:"",l=r?t("gray",h):"";return`${s}${l}${u}${o.trim()?`
${l}`:""}`}default:{const u=r?`${t("cyan",h)} `:"",l=r?t("cyan",x):"";return`${s}${u}${a}
${l}
`}}}}).prompt();export{h as S_BAR,x as S_BAR_END,Pe as S_BAR_END_RIGHT,se as S_BAR_H,he as S_BAR_START,Oe as S_BAR_START_RIGHT,te as S_CHECKBOX_ACTIVE,q as S_CHECKBOX_INACTIVE,U as S_CHECKBOX_SELECTED,We as S_CONNECT_LEFT,ge as S_CORNER_BOTTOM_LEFT,me as S_CORNER_BOTTOM_RIGHT,Ge as S_CORNER_TOP_LEFT,pe as S_CORNER_TOP_RIGHT,Ee as S_ERROR,fe as S_INFO,Ne as S_PASSWORD_MASK,z as S_RADIO_ACTIVE,H as S_RADIO_INACTIVE,Re as S_STEP_ACTIVE,$e as S_STEP_CANCEL,de as S_STEP_ERROR,V as S_STEP_SUBMIT,Fe as S_SUCCESS,ye as S_WARN,Xe as autocomplete,xt as autocompleteMultiselect,Mt as box,Nt as cancel,Rt as confirm,Ot as group,Pt as groupMultiselect,Wt as intro,ce as isCI,Me as isTTY,X as limitOptions,R as log,Lt as multiselect,Vt as note,Gt as outro,Ht as password,Ut as path,qt as progress,Jt as select,Xt as selectKey,be as spinner,K as stream,W as symbol,ve as symbolBar,Qt as taskLog,Yt as tasks,Zt as text,ee as unicode,I as unicodeOr};
`}}}}).prompt();export{d as S_BAR,E as S_BAR_END,Ee as S_BAR_END_RIGHT,se as S_BAR_H,le as S_BAR_START,Ie as S_BAR_START_RIGHT,te as S_CHECKBOX_ACTIVE,J as S_CHECKBOX_INACTIVE,U as S_CHECKBOX_SELECTED,Ge as S_CONNECT_LEFT,de as S_CORNER_BOTTOM_LEFT,$e as S_CORNER_BOTTOM_RIGHT,Oe as S_CORNER_TOP_LEFT,ce as S_CORNER_TOP_RIGHT,ge as S_ERROR,he as S_INFO,xe as S_PASSWORD_MASK,z as S_RADIO_ACTIVE,H as S_RADIO_INACTIVE,_e as S_STEP_ACTIVE,oe as S_STEP_CANCEL,ue as S_STEP_ERROR,F as S_STEP_SUBMIT,pe as S_SUCCESS,me as S_WARN,Ae as autocomplete,st as autocompleteMultiselect,at as box,pt as cancel,ot as confirm,ut as date,dt as group,ht as groupMultiselect,mt as intro,ae as isCI,Te as isTTY,Y as limitOptions,O as log,yt as multiselect,wt as note,gt as outro,bt as password,St as path,Tt as progress,_t as select,It as selectKey,fe as spinner,K as stream,V as symbol,ye as symbolBar,Gt as taskLog,Et as tasks,Ot as text,ee as unicode,w as unicodeOr};
//# sourceMappingURL=index.mjs.map
{
"name": "@clack/prompts",
"version": "1.1.0",
"version": "1.2.0",
"type": "module",

@@ -50,8 +50,8 @@ "main": "./dist/index.mjs",

"dependencies": {
"fast-string-width": "^1.1.0",
"fast-wrap-ansi": "^0.1.3",
"sisteransi": "^1.0.5",
"@clack/core": "1.1.0"
"@clack/core": "1.2.0"
},
"devDependencies": {
"fast-string-width": "^1.1.0",
"fast-wrap-ansi": "^0.1.3",
"is-unicode-supported": "^1.3.0",

@@ -58,0 +58,0 @@ "memfs": "^4.17.2",

Sorry, the diff of this file is too big to display