"use strict";const node_util=require("node:util"),core=require("@clack/core"),process$1=require("node:process"),e=require("picocolors"),sisteransi=require("sisteransi");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const process__default=_interopDefaultCompat(process$1),e__default=_interopDefaultCompat(e);function isUnicodeSupported(){return process__default.platform!=="win32"?process__default.env.TERM!=="linux":!!process__default.env.CI||!!process__default.env.WT_SESSION||!!process__default.env.TERMINUS_SUBLIME||process__default.env.ConEmuTask==="{cmd::Cmder}"||process__default.env.TERM_PROGRAM==="Terminus-Sublime"||process__default.env.TERM_PROGRAM==="vscode"||process__default.env.TERM==="xterm-256color"||process__default.env.TERM==="alacritty"||process__default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const P=isUnicodeSupported(),u=(t,n)=>P?t:n,z=u("\u25C6","*"),R=u("\u25A0","x"),A=u("\u25B2","x"),w=u("\u25C7","o"),Q=u("\u250C","T"),a=u("\u2502","|"),d=u("\u2514","\u2014"),O=u("\u25CF",">"),I=u("\u25CB"," "),_=u("\u25FB","[\u2022]"),x=u("\u25FC","[+]"),M=u("\u25FB","[ ]"),Z=u("\u25AA","\u2022"),k=u("\u2500","-"),ee=u("\u256E","+"),te=u("\u251C","+"),re=u("\u256F","+"),se=u("\u25CF","\u2022"),ne=u("\u25C6","*"),ie=u("\u25B2","!"),ae=u("\u25A0","x"),h=t=>{switch(t){case"initial":case"active":return e__default.cyan(z);case"cancel":return e__default.red(R);case"error":return e__default.yellow(A);case"submit":return e__default.green(w)}},C=t=>{const{cursor:n,options:s,style:i}=t,r=t.maxItems??Number.POSITIVE_INFINITY,c=Math.max(process.stdout.rows-4,0),o=Math.min(c,Math.max(r,5));let l=0;n>=l+o-3?l=Math.max(Math.min(n-o+3,s.length-o),0):n0,p=o{const S=f===0&&$,b=f===T.length-1&&p;return S||b?e__default.dim("..."):i(y,f+l===n)})},text=t=>new core.TextPrompt({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){const n=`${e__default.gray(a)} ${h(this.state)} ${t.message} `,s=t.placeholder?e__default.inverse(t.placeholder[0])+e__default.dim(t.placeholder.slice(1)):e__default.inverse(e__default.hidden("_")),i=this.value?this.valueWithCursor:s;switch(this.state){case"error":return`${n.trim()} ${e__default.yellow(a)} ${i} ${e__default.yellow(d)} ${e__default.yellow(this.error)} `;case"submit":return`${n}${e__default.gray(a)} ${e__default.dim(this.value||t.placeholder)}`;case"cancel":return`${n}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(this.value??""))}${this.value?.trim()?` ${e__default.gray(a)}`:""}`;default:return`${n}${e__default.cyan(a)} ${i} ${e__default.cyan(d)} `}}}).prompt(),password=t=>new core.PasswordPrompt({validate:t.validate,mask:t.mask??Z,render(){const n=`${e__default.gray(a)} ${h(this.state)} ${t.message} `,s=this.valueWithCursor,i=this.masked;switch(this.state){case"error":return`${n.trim()} ${e__default.yellow(a)} ${i} ${e__default.yellow(d)} ${e__default.yellow(this.error)} `;case"submit":return`${n}${e__default.gray(a)} ${e__default.dim(i)}`;case"cancel":return`${n}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(i??""))}${i?` ${e__default.gray(a)}`:""}`;default:return`${n}${e__default.cyan(a)} ${s} ${e__default.cyan(d)} `}}}).prompt(),confirm=t=>{const n=t.active??"Yes",s=t.inactive??"No";return new core.ConfirmPrompt({active:n,inactive:s,initialValue:t.initialValue??!0,render(){const i=`${e__default.gray(a)} ${h(this.state)} ${t.message} `,r=this.value?n:s;switch(this.state){case"submit":return`${i}${e__default.gray(a)} ${e__default.dim(r)}`;case"cancel":return`${i}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(r))} ${e__default.gray(a)}`;default:return`${i}${e__default.cyan(a)} ${this.value?`${e__default.green(O)} ${n}`:`${e__default.dim(I)} ${e__default.dim(n)}`} ${e__default.dim("/")} ${this.value?`${e__default.dim(I)} ${e__default.dim(s)}`:`${e__default.green(O)} ${s}`} ${e__default.cyan(d)} `}}}).prompt()},select=t=>{const n=(s,i)=>{const r=s.label??String(s.value);switch(i){case"selected":return`${e__default.dim(r)}`;case"active":return`${e__default.green(O)} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`;case"cancelled":return`${e__default.strikethrough(e__default.dim(r))}`;default:return`${e__default.dim(I)} ${e__default.dim(r)}`}};return new core.SelectPrompt({options:t.options,initialValue:t.initialValue,render(){const s=`${e__default.gray(a)} ${h(this.state)} ${t.message} `;switch(this.state){case"submit":return`${s}${e__default.gray(a)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${s}${e__default.gray(a)} ${n(this.options[this.cursor],"cancelled")} ${e__default.gray(a)}`;default:return`${s}${e__default.cyan(a)} ${C({cursor:this.cursor,options:this.options,maxItems:t.maxItems,style:(i,r)=>n(i,r?"active":"inactive")}).join(` ${e__default.cyan(a)} `)} ${e__default.cyan(d)} `}}}).prompt()},selectKey=t=>{const n=(s,i="inactive")=>{const r=s.label??String(s.value);return i==="selected"?`${e__default.dim(r)}`:i==="cancelled"?`${e__default.strikethrough(e__default.dim(r))}`:i==="active"?`${e__default.bgCyan(e__default.gray(` ${s.value} `))} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`:`${e__default.gray(e__default.bgWhite(e__default.inverse(` ${s.value} `)))} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`};return new core.SelectKeyPrompt({options:t.options,initialValue:t.initialValue,render(){const s=`${e__default.gray(a)} ${h(this.state)} ${t.message} `;switch(this.state){case"submit":return`${s}${e__default.gray(a)} ${n(this.options.find(i=>i.value===this.value)??t.options[0],"selected")}`;case"cancel":return`${s}${e__default.gray(a)} ${n(this.options[0],"cancelled")} ${e__default.gray(a)}`;default:return`${s}${e__default.cyan(a)} ${this.options.map((i,r)=>n(i,r===this.cursor?"active":"inactive")).join(` ${e__default.cyan(a)} `)} ${e__default.cyan(d)} `}}}).prompt()},multiselect=t=>{const n=(s,i)=>{const r=s.label??String(s.value);return i==="active"?`${e__default.cyan(_)} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`:i==="selected"?`${e__default.green(x)} ${e__default.dim(r)}`:i==="cancelled"?`${e__default.strikethrough(e__default.dim(r))}`:i==="active-selected"?`${e__default.green(x)} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`:i==="submitted"?`${e__default.dim(r)}`:`${e__default.dim(M)} ${e__default.dim(r)}`};return new core.MultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(s){if(this.required&&s.length===0)return`Please select at least one option. ${e__default.reset(e__default.dim(`Press ${e__default.gray(e__default.bgWhite(e__default.inverse(" space ")))} to select, ${e__default.gray(e__default.bgWhite(e__default.inverse(" enter ")))} to submit`))}`},render(){const s=`${e__default.gray(a)} ${h(this.state)} ${t.message} `,i=(r,c)=>{const o=this.value.includes(r.value);return c&&o?n(r,"active-selected"):o?n(r,"selected"):n(r,c?"active":"inactive")};switch(this.state){case"submit":return`${s}${e__default.gray(a)} ${this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"submitted")).join(e__default.dim(", "))||e__default.dim("none")}`;case"cancel":{const r=this.options.filter(({value:c})=>this.value.includes(c)).map(c=>n(c,"cancelled")).join(e__default.dim(", "));return`${s}${e__default.gray(a)} ${r.trim()?`${r} ${e__default.gray(a)}`:""}`}case"error":{const r=this.error.split(` `).map((c,o)=>o===0?`${e__default.yellow(d)} ${e__default.yellow(c)}`:` ${c}`).join(` `);return`${s+e__default.yellow(a)} ${C({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:i}).join(` ${e__default.yellow(a)} `)} ${r} `}default:return`${s}${e__default.cyan(a)} ${C({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:i}).join(` ${e__default.cyan(a)} `)} ${e__default.cyan(d)} `}}}).prompt()},groupMultiselect=t=>{const n=(s,i,r=[])=>{const c=s.label??String(s.value),o=typeof s.group=="string",l=o&&(r[r.indexOf(s)+1]??{group:!0}),$=o&&l.group===!0,p=o?`${$?d:a} `:"";return i==="active"?`${e__default.dim(p)}${e__default.cyan(_)} ${c} ${s.hint?e__default.dim(`(${s.hint})`):""}`:i==="group-active"?`${p}${e__default.cyan(_)} ${e__default.dim(c)}`:i==="group-active-selected"?`${p}${e__default.green(x)} ${e__default.dim(c)}`:i==="selected"?`${e__default.dim(p)}${e__default.green(x)} ${e__default.dim(c)}`:i==="cancelled"?`${e__default.strikethrough(e__default.dim(c))}`:i==="active-selected"?`${e__default.dim(p)}${e__default.green(x)} ${c} ${s.hint?e__default.dim(`(${s.hint})`):""}`:i==="submitted"?`${e__default.dim(c)}`:`${e__default.dim(p)}${e__default.dim(M)} ${e__default.dim(c)}`};return new core.GroupMultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(s){if(this.required&&s.length===0)return`Please select at least one option. ${e__default.reset(e__default.dim(`Press ${e__default.gray(e__default.bgWhite(e__default.inverse(" space ")))} to select, ${e__default.gray(e__default.bgWhite(e__default.inverse(" enter ")))} to submit`))}`},render(){const s=`${e__default.gray(a)} ${h(this.state)} ${t.message} `;switch(this.state){case"submit":return`${s}${e__default.gray(a)} ${this.options.filter(({value:i})=>this.value.includes(i)).map(i=>n(i,"submitted")).join(e__default.dim(", "))}`;case"cancel":{const i=this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"cancelled")).join(e__default.dim(", "));return`${s}${e__default.gray(a)} ${i.trim()?`${i} ${e__default.gray(a)}`:""}`}case"error":{const i=this.error.split(` `).map((r,c)=>c===0?`${e__default.yellow(d)} ${e__default.yellow(r)}`:` ${r}`).join(` `);return`${s}${e__default.yellow(a)} ${this.options.map((r,c,o)=>{const l=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),$=c===this.cursor;return!$&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?n(r,l?"group-active-selected":"group-active",o):$&&l?n(r,"active-selected",o):l?n(r,"selected",o):n(r,$?"active":"inactive",o)}).join(` ${e__default.yellow(a)} `)} ${i} `}default:return`${s}${e__default.cyan(a)} ${this.options.map((i,r,c)=>{const o=this.value.includes(i.value)||i.group===!0&&this.isGroupSelected(`${i.value}`),l=r===this.cursor;return!l&&typeof i.group=="string"&&this.options[this.cursor].value===i.group?n(i,o?"group-active-selected":"group-active",c):l&&o?n(i,"active-selected",c):o?n(i,"selected",c):n(i,l?"active":"inactive",c)}).join(` ${e__default.cyan(a)} `)} ${e__default.cyan(d)} `}}}).prompt()},note=(t="",n="")=>{const s=` ${t} `.split(` `),i=node_util.stripVTControlCharacters(n).length,r=Math.max(s.reduce((o,l)=>{const $=node_util.stripVTControlCharacters(l);return $.length>o?$.length:o},0),i)+2,c=s.map(o=>`${e__default.gray(a)} ${e__default.dim(o)}${" ".repeat(r-node_util.stripVTControlCharacters(o).length)}${e__default.gray(a)}`).join(` `);process.stdout.write(`${e__default.gray(a)} ${e__default.green(w)} ${e__default.reset(n)} ${e__default.gray(k.repeat(Math.max(r-i-1,1))+ee)} ${c} ${e__default.gray(te+k.repeat(r+2)+re)} `)},cancel=(t="")=>{process.stdout.write(`${e__default.gray(d)} ${e__default.red(t)} `)},intro=(t="")=>{process.stdout.write(`${e__default.gray(Q)} ${t} `)},outro=(t="")=>{process.stdout.write(`${e__default.gray(a)} ${e__default.gray(d)} ${t} `)},log={message:(t="",{symbol:n=e__default.gray(a)}={})=>{const s=[`${e__default.gray(a)}`];if(t){const[i,...r]=t.split(` `);s.push(`${n} ${i}`,...r.map(c=>`${e__default.gray(a)} ${c}`))}process.stdout.write(`${s.join(` `)} `)},info:t=>{log.message(t,{symbol:e__default.blue(se)})},success:t=>{log.message(t,{symbol:e__default.green(ne)})},step:t=>{log.message(t,{symbol:e__default.green(w)})},warn:t=>{log.message(t,{symbol:e__default.yellow(ie)})},warning:t=>{log.warn(t)},error:t=>{log.message(t,{symbol:e__default.red(ae)})}},spinner=()=>{const t=P?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=P?80:120,s=process.env.CI==="true";let i,r,c=!1,o="",l;const $=m=>{const g=m>1?"Something went wrong":"Canceled";c&&V(g,m)},p=()=>$(2),y=()=>$(1),f=()=>{process.on("uncaughtExceptionMonitor",p),process.on("unhandledRejection",p),process.on("SIGINT",y),process.on("SIGTERM",y),process.on("exit",$)},T=()=>{process.removeListener("uncaughtExceptionMonitor",p),process.removeListener("unhandledRejection",p),process.removeListener("SIGINT",y),process.removeListener("SIGTERM",y),process.removeListener("exit",$)},S=()=>{if(l===void 0)return;s&&process.stdout.write(` `);const m=l.split(` `);process.stdout.write(sisteransi.cursor.move(-999,m.length-1)),process.stdout.write(sisteransi.erase.down(m.length))},b=m=>m.replace(/\.+$/,""),j=(m="")=>{c=!0,i=core.block(),o=b(m),process.stdout.write(`${e__default.gray(a)} `);let g=0,v=0;f(),r=setInterval(()=>{if(s&&o===l)return;S(),l=o;const E=e__default.magenta(t[g]),q=s?"...":".".repeat(Math.floor(v)).slice(0,3);process.stdout.write(`${E} ${o}${q}`),g=g+1{c=!1,clearInterval(r),S();const v=g===0?e__default.green(w):g===1?e__default.red(R):e__default.red(A);o=b(m??o),process.stdout.write(`${v} ${o} `),T(),i()};return{start:j,stop:V,message:(m="")=>{o=b(m??o)}}},group=async(t,n)=>{const s={},i=Object.keys(t);for(const r of i){const c=t[r],o=await c({results:s})?.catch(l=>{throw l});if(typeof n?.onCancel=="function"&&core.isCancel(o)){s[r]="canceled",n.onCancel({results:s});continue}s[r]=o}return s},tasks=async t=>{for(const n of t){if(n.enabled===!1)continue;const s=spinner();s.start(n.title);const i=await n.task(s.message);s.stop(i||n.title)}};exports.isCancel=core.isCancel,exports.updateSettings=core.updateSettings,exports.cancel=cancel,exports.confirm=confirm,exports.group=group,exports.groupMultiselect=groupMultiselect,exports.intro=intro,exports.log=log,exports.multiselect=multiselect,exports.note=note,exports.outro=outro,exports.password=password,exports.select=select,exports.selectKey=selectKey,exports.spinner=spinner,exports.tasks=tasks,exports.text=text; //# sourceMappingURL=index.cjs.map