@maizzle/framework 6.0.0-rc.24 → 6.0.0-rc.25

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.
Files changed (122) hide show
  1. package/dist/build.js.map +1 -1
  2. package/dist/components/Body.vue +12 -0
  3. package/dist/components/Button.vue +16 -29
  4. package/dist/components/CodeBlock.vue +5 -4
  5. package/dist/components/CodeInline.vue +9 -8
  6. package/dist/components/Column.vue +17 -4
  7. package/dist/components/Container.vue +7 -11
  8. package/dist/components/Hr.vue +1 -1
  9. package/dist/components/Img.vue +39 -22
  10. package/dist/components/Layout.vue +1 -1
  11. package/dist/components/Markdown.vue +9 -14
  12. package/dist/components/QrCode.vue +2 -2
  13. package/dist/components/Section.vue +9 -6
  14. package/dist/components/Text.vue +2 -2
  15. package/dist/components/utils.d.ts +25 -1
  16. package/dist/components/utils.d.ts.map +1 -1
  17. package/dist/components/utils.js +29 -1
  18. package/dist/components/utils.js.map +1 -1
  19. package/dist/components/utils.ts +46 -0
  20. package/dist/composables/useConfig.d.ts.map +1 -1
  21. package/dist/composables/useCurrentTemplate.d.ts.map +1 -1
  22. package/dist/composables/useEvent.d.ts.map +1 -1
  23. package/dist/composables/useFont.js.map +1 -1
  24. package/dist/config/index.js.map +1 -1
  25. package/dist/events/index.d.ts.map +1 -1
  26. package/dist/events/index.js.map +1 -1
  27. package/dist/plaintext.js.map +1 -1
  28. package/dist/plugins/postcss/mergeMediaQueries.js.map +1 -1
  29. package/dist/plugins/postcss/pruneVars.js.map +1 -1
  30. package/dist/plugins/postcss/quoteFontFamilies.d.ts.map +1 -1
  31. package/dist/plugins/postcss/quoteFontFamilies.js.map +1 -1
  32. package/dist/plugins/postcss/removeDeclarations.js.map +1 -1
  33. package/dist/plugins/postcss/resolveProps.d.ts.map +1 -1
  34. package/dist/plugins/postcss/resolveProps.js +0 -3
  35. package/dist/plugins/postcss/resolveProps.js.map +1 -1
  36. package/dist/plugins/postcss/tailwindCleanup.js.map +1 -1
  37. package/dist/prepare.js +1 -1
  38. package/dist/prepare.js.map +1 -1
  39. package/dist/render/active.d.ts.map +1 -1
  40. package/dist/render/createRenderer.d.ts.map +1 -1
  41. package/dist/render/createRenderer.js +3 -7
  42. package/dist/render/createRenderer.js.map +1 -1
  43. package/dist/render/index.js.map +1 -1
  44. package/dist/render/injectFonts.js.map +1 -1
  45. package/dist/render/plugins/codeBlockExtract.d.ts.map +1 -1
  46. package/dist/render/plugins/codeBlockExtract.js.map +1 -1
  47. package/dist/render/plugins/markdownExtract.d.ts.map +1 -1
  48. package/dist/render/plugins/markdownExtract.js.map +1 -1
  49. package/dist/render/plugins/rawExtract.d.ts.map +1 -1
  50. package/dist/render/plugins/rawExtract.js.map +1 -1
  51. package/dist/render/plugins/rowSourceLocation.d.ts.map +1 -1
  52. package/dist/render/plugins/rowSourceLocation.js.map +1 -1
  53. package/dist/serve.js.map +1 -1
  54. package/dist/server/compatibility.d.ts.map +1 -1
  55. package/dist/server/compatibility.js.map +1 -1
  56. package/dist/server/linter.js.map +1 -1
  57. package/dist/server/sfc-utils.js.map +1 -1
  58. package/dist/tests/render/_helpers.d.ts.map +1 -1
  59. package/dist/tests/render/_helpers.js.map +1 -1
  60. package/dist/transformers/addAttributes.js +2 -3
  61. package/dist/transformers/addAttributes.js.map +1 -1
  62. package/dist/transformers/base.d.ts +1 -1
  63. package/dist/transformers/base.d.ts.map +1 -1
  64. package/dist/transformers/base.js +5 -10
  65. package/dist/transformers/base.js.map +1 -1
  66. package/dist/transformers/columnWidth.d.ts.map +1 -1
  67. package/dist/transformers/columnWidth.js +2 -7
  68. package/dist/transformers/columnWidth.js.map +1 -1
  69. package/dist/transformers/entities.js.map +1 -1
  70. package/dist/transformers/filters/defaults.js.map +1 -1
  71. package/dist/transformers/filters/index.js.map +1 -1
  72. package/dist/transformers/format.js.map +1 -1
  73. package/dist/transformers/imgWidth.d.ts +20 -0
  74. package/dist/transformers/imgWidth.d.ts.map +1 -0
  75. package/dist/transformers/imgWidth.js +76 -0
  76. package/dist/transformers/imgWidth.js.map +1 -0
  77. package/dist/transformers/index.d.ts.map +1 -1
  78. package/dist/transformers/index.js +2 -0
  79. package/dist/transformers/index.js.map +1 -1
  80. package/dist/transformers/inlineCss.d.ts +3 -2
  81. package/dist/transformers/inlineCss.d.ts.map +1 -1
  82. package/dist/transformers/inlineCss.js.map +1 -1
  83. package/dist/transformers/inlineLink.js +1 -1
  84. package/dist/transformers/inlineLink.js.map +1 -1
  85. package/dist/transformers/minify.js.map +1 -1
  86. package/dist/transformers/minifyCodeInline.js.map +1 -1
  87. package/dist/transformers/msoPlaceholders.d.ts.map +1 -1
  88. package/dist/transformers/msoPlaceholders.js +2 -7
  89. package/dist/transformers/msoPlaceholders.js.map +1 -1
  90. package/dist/transformers/purgeCss.js.map +1 -1
  91. package/dist/transformers/replaceStrings.js.map +1 -1
  92. package/dist/transformers/safeSelectors.js.map +1 -1
  93. package/dist/transformers/shorthandCss.js.map +1 -1
  94. package/dist/transformers/tailwindComponent.js.map +1 -1
  95. package/dist/transformers/tailwindcss.js +1 -1
  96. package/dist/transformers/tailwindcss.js.map +1 -1
  97. package/dist/transformers/urlQuery.js.map +1 -1
  98. package/dist/types/config.d.ts +5 -4
  99. package/dist/types/config.d.ts.map +1 -1
  100. package/dist/utils/ast/serializer.js.map +1 -1
  101. package/dist/utils/compileTailwindCss.js.map +1 -1
  102. package/dist/utils/componentSources.js.map +1 -1
  103. package/dist/utils/cssBox.d.ts.map +1 -1
  104. package/dist/utils/cssBox.js +2 -7
  105. package/dist/utils/cssBox.js.map +1 -1
  106. package/dist/utils/decodeStyleEntities.js.map +1 -1
  107. package/dist/utils/url.js.map +1 -1
  108. package/dist/utils/watchPaths.js.map +1 -1
  109. package/node_modules/@clack/core/CHANGELOG.md +30 -0
  110. package/node_modules/@clack/core/dist/index.d.mts +109 -3
  111. package/node_modules/@clack/core/dist/index.mjs +972 -17
  112. package/node_modules/@clack/core/package.json +2 -1
  113. package/node_modules/@clack/prompts/CHANGELOG.md +42 -0
  114. package/node_modules/@clack/prompts/README.md +30 -9
  115. package/node_modules/@clack/prompts/dist/index.d.mts +458 -27
  116. package/node_modules/@clack/prompts/dist/index.mjs +1378 -141
  117. package/node_modules/@clack/prompts/package.json +2 -2
  118. package/node_modules/tinyexec/package.json +4 -4
  119. package/package.json +8 -7
  120. package/dist/components/Overlap.vue +0 -156
  121. package/node_modules/@clack/core/dist/index.mjs.map +0 -1
  122. package/node_modules/@clack/prompts/dist/index.mjs.map +0 -1
@@ -1,145 +1,1382 @@
1
- import{getColumns as X,getRows as Lt,AutocompletePrompt as vt,settings as T,ConfirmPrompt as Dt,wrapTextWithPrefix as E,DatePrompt as Wt,isCancel as Ft,GroupMultiSelectPrompt as Ht,MultiLinePrompt as Ut,MultiSelectPrompt as Kt,PasswordPrompt as qt,block as Jt,SelectPrompt as Yt,SelectKeyPrompt as Xt,TextPrompt as zt}from"@clack/core";export{isCancel,settings,updateSettings}from"@clack/core";import{styleText as e,stripVTControlCharacters as nt}from"node:util";import V from"node:process";import{wrapAnsi as J}from"fast-wrap-ansi";import B from"fast-string-width";import{existsSync as Qt,lstatSync as wt,readdirSync as Zt}from"node:fs";import{dirname as bt,join as te}from"node:path";import{cursor as St,erase as Ct}from"sisteransi";function ee(){return V.platform!=="win32"?V.env.TERM!=="linux":!!V.env.CI||!!V.env.WT_SESSION||!!V.env.TERMINUS_SUBLIME||V.env.ConEmuTask==="{cmd::Cmder}"||V.env.TERM_PROGRAM==="Terminus-Sublime"||V.env.TERM_PROGRAM==="vscode"||V.env.TERM==="xterm-256color"||V.env.TERM==="alacritty"||V.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const tt=ee(),ot=()=>process.env.CI==="true",It=t=>t.isTTY===!0,w=(t,i)=>tt?t:i,Tt=w("\u25C6","*"),at=w("\u25A0","x"),ut=w("\u25B2","x"),H=w("\u25C7","o"),lt=w("\u250C","T"),$=w("\u2502","|"),x=w("\u2514","\u2014"),_t=w("\u2510","T"),xt=w("\u2518","\u2014"),z=w("\u25CF",">"),U=w("\u25CB"," "),et=w("\u25FB","[\u2022]"),K=w("\u25FC","[+]"),Y=w("\u25FB","[ ]"),Et=w("\u25AA","\u2022"),st=w("\u2500","-"),ct=w("\u256E","+"),Gt=w("\u251C","+"),$t=w("\u256F","+"),dt=w("\u2570","+"),Mt=w("\u256D","+"),ht=w("\u25CF","\u2022"),pt=w("\u25C6","*"),mt=w("\u25B2","!"),gt=w("\u25A0","x"),P=t=>{switch(t){case"initial":case"active":return e("cyan",Tt);case"cancel":return e("red",at);case"error":return e("yellow",ut);case"submit":return e("green",H)}},yt=t=>{switch(t){case"initial":case"active":return e("cyan",$);case"cancel":return e("red",$);case"error":return e("yellow",$);case"submit":return e("green",$)}},Ot=(t,i,s,r,u,n=!1)=>{let a=i,c=0;if(n)for(let o=r-1;o>=s&&(a-=t[o].length,c++,!(a<=u));o--);else for(let o=s;o<r&&(a-=t[o].length,c++,!(a<=u));o++);return{lineCount:a,removals:c}},F=({cursor:t,options:i,style:s,output:r=process.stdout,maxItems:u=Number.POSITIVE_INFINITY,columnPadding:n=0,rowPadding:a=4})=>{const c=X(r)-n,o=Lt(r),l=e("dim","..."),d=Math.max(o-a,0),g=Math.max(Math.min(u,d),5);let p=0;t>=g-3&&(p=Math.max(Math.min(t-g+3,i.length-g),0));let f=g<i.length&&p>0,h=g<i.length&&p+g<i.length;const I=Math.min(p+g,i.length),m=[];let y=0;f&&y++,h&&y++;const v=p+(f?1:0),C=I-(h?1:0);for(let b=v;b<C;b++){const G=J(s(i[b],b===t),c,{hard:!0,trim:!1}).split(`
2
- `);m.push(G),y+=G.length}if(y>d){let b=0,G=0,M=y;const N=t-v;let O=d;const j=()=>Ot(m,M,0,N,O),k=()=>Ot(m,M,N+1,m.length,O,!0);f?({lineCount:M,removals:b}=j(),M>O&&(h||(O-=1),{lineCount:M,removals:G}=k())):(h||(O-=1),{lineCount:M,removals:G}=k(),M>O&&(O-=1,{lineCount:M,removals:b}=j())),b>0&&(f=!0,m.splice(0,b)),G>0&&(h=!0,m.splice(m.length-G,G))}const S=[];f&&S.push(l);for(const b of m)for(const G of b)S.push(G);return h&&S.push(l),S};function Pt(t){return t.label??String(t.value??"")}function Rt(t,i){if(!t)return!0;const s=(i.label??String(i.value??"")).toLowerCase(),r=(i.hint??"").toLowerCase(),u=String(i.value).toLowerCase(),n=t.toLowerCase();return s.includes(n)||r.includes(n)||u.includes(n)}function se(t,i){const s=[];for(const r of i)t.includes(r.value)&&s.push(r);return s}const At=t=>new vt({options:t.options,initialValue:t.initialValue?[t.initialValue]:void 0,initialUserInput:t.initialUserInput,placeholder:t.placeholder,filter:t.filter??((i,s)=>Rt(i,s)),signal:t.signal,input:t.input,output:t.output,validate:t.validate,render(){const i=t.withGuide??T.withGuide,s=i?[`${e("gray",$)}`,`${P(this.state)} ${t.message}`]:[`${P(this.state)} ${t.message}`],r=this.userInput,u=this.options,n=t.placeholder,a=r===""&&n!==void 0,c=(o,l)=>{const d=Pt(o),g=o.hint&&o.value===this.focusedValue?e("dim",` (${o.hint})`):"";switch(l){case"active":return`${e("green",z)} ${d}${g}`;case"inactive":return`${e("dim",U)} ${e("dim",d)}`;case"disabled":return`${e("gray",U)} ${e(["strikethrough","gray"],d)}`}};switch(this.state){case"submit":{const o=se(this.selectedValues,u),l=o.length>0?` ${e("dim",o.map(Pt).join(", "))}`:"",d=i?e("gray",$):"";return`${s.join(`
1
+ import { getColumns, getRows, AutocompletePrompt, settings, ConfirmPrompt, wrapTextWithPrefix, DatePrompt, runValidation, isCancel, GroupMultiSelectPrompt, MultiLinePrompt, MultiSelectPrompt, PasswordPrompt, block, SelectPrompt, SelectKeyPrompt, TextPrompt } from '@clack/core';
2
+ export { isCancel, settings, updateSettings } from '@clack/core';
3
+ import { styleText, stripVTControlCharacters } from 'node:util';
4
+ import process$1 from 'node:process';
5
+ import { wrapAnsi } from 'fast-wrap-ansi';
6
+ import l from 'fast-string-width';
7
+ import { existsSync, lstatSync, readdirSync } from 'node:fs';
8
+ import { dirname, join } from 'node:path';
9
+ import { cursor, erase } from 'sisteransi';
10
+
11
+ function isUnicodeSupported() {
12
+ if (process$1.platform !== 'win32') {
13
+ return process$1.env.TERM !== 'linux'; // Linux console (kernel)
14
+ }
15
+
16
+ return Boolean(process$1.env.CI)
17
+ || Boolean(process$1.env.WT_SESSION) // Windows Terminal
18
+ || Boolean(process$1.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
19
+ || process$1.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
20
+ || process$1.env.TERM_PROGRAM === 'Terminus-Sublime'
21
+ || process$1.env.TERM_PROGRAM === 'vscode'
22
+ || process$1.env.TERM === 'xterm-256color'
23
+ || process$1.env.TERM === 'alacritty'
24
+ || process$1.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
25
+ }
26
+
27
+ const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", isTTY = (e) => e.isTTY === true, unicodeOr = (e, o) => unicode ? e : o, 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 = (e) => {
28
+ switch (e) {
29
+ case "initial":
30
+ case "active":
31
+ return styleText("cyan", S_STEP_ACTIVE);
32
+ case "cancel":
33
+ return styleText("red", S_STEP_CANCEL);
34
+ case "error":
35
+ return styleText("yellow", S_STEP_ERROR);
36
+ case "submit":
37
+ return styleText("green", S_STEP_SUBMIT);
38
+ }
39
+ }, symbolBar = (e) => {
40
+ switch (e) {
41
+ case "initial":
42
+ case "active":
43
+ return styleText("cyan", S_BAR);
44
+ case "cancel":
45
+ return styleText("red", S_BAR);
46
+ case "error":
47
+ return styleText("yellow", S_BAR);
48
+ case "submit":
49
+ return styleText("green", S_BAR);
50
+ }
51
+ };
52
+
53
+ const E$1 = (l, o, g, c, h, O = false) => {
54
+ let r = o, w = 0;
55
+ if (O)
56
+ for (let i = c - 1; i >= g && (r -= l[i].length, w++, !(r <= h)); i--)
57
+ ;
58
+ else
59
+ for (let i = g; i < c && (r -= l[i].length, w++, !(r <= h)); i++)
60
+ ;
61
+ return { lineCount: r, removals: w };
62
+ };
63
+ const limitOptions = ({
64
+ cursor: l,
65
+ options: o,
66
+ style: g,
67
+ output: c = process.stdout,
68
+ maxItems: h = Number.POSITIVE_INFINITY,
69
+ columnPadding: O = 0,
70
+ rowPadding: r = 4
71
+ }) => {
72
+ const i = getColumns(c) - O, I = getRows(c), C = styleText("dim", "..."), x = Math.max(I - r, 0), m = Math.max(Math.min(h, x), 5);
73
+ let p = 0;
74
+ l >= m - 3 && (p = Math.max(
75
+ Math.min(l - m + 3, o.length - m),
76
+ 0
77
+ ));
78
+ let f = m < o.length && p > 0, u = m < o.length && p + m < o.length;
79
+ const W = Math.min(
80
+ p + m,
81
+ o.length
82
+ ), e = [];
83
+ let d = 0;
84
+ f && d++, u && d++;
85
+ const v = p + (f ? 1 : 0), P = W - (u ? 1 : 0);
86
+ for (let t = v; t < P; t++) {
87
+ const n = wrapAnsi(g(o[t], t === l), i, {
88
+ hard: true,
89
+ trim: false
90
+ }).split(`
91
+ `);
92
+ e.push(n), d += n.length;
93
+ }
94
+ if (d > x) {
95
+ let t = 0, n = 0, s = d;
96
+ const M = l - v;
97
+ let a = x;
98
+ const T = () => E$1(e, s, 0, M, a), L = () => E$1(
99
+ e,
100
+ s,
101
+ M + 1,
102
+ e.length,
103
+ a,
104
+ true
105
+ );
106
+ f ? ({ lineCount: s, removals: t } = T(), s > a && (u || (a -= 1), { lineCount: s, removals: n } = L())) : (u || (a -= 1), { lineCount: s, removals: n } = L(), s > a && (a -= 1, { lineCount: s, removals: t } = T())), t > 0 && (f = true, e.splice(0, t)), n > 0 && (u = true, e.splice(e.length - n, n));
107
+ }
108
+ const b = [];
109
+ f && b.push(C);
110
+ for (const t of e)
111
+ for (const n of t)
112
+ b.push(n);
113
+ return u && b.push(C), b;
114
+ };
115
+
116
+ function P(t) {
117
+ return t.label ?? String(t.value ?? "");
118
+ }
119
+ function E(t, c) {
120
+ if (!t)
121
+ return true;
122
+ const n = (c.label ?? String(c.value ?? "")).toLowerCase(), i = (c.hint ?? "").toLowerCase(), l = String(c.value).toLowerCase(), o = t.toLowerCase();
123
+ return n.includes(o) || i.includes(o) || l.includes(o);
124
+ }
125
+ function N(t, c) {
126
+ const n = [];
127
+ for (const i of c)
128
+ t.includes(i.value) && n.push(i);
129
+ return n;
130
+ }
131
+ const autocomplete = (t) => new AutocompletePrompt({
132
+ options: t.options,
133
+ initialValue: t.initialValue ? [t.initialValue] : void 0,
134
+ initialUserInput: t.initialUserInput,
135
+ placeholder: t.placeholder,
136
+ filter: t.filter ?? ((n, i) => E(n, i)),
137
+ signal: t.signal,
138
+ input: t.input,
139
+ output: t.output,
140
+ validate: t.validate,
141
+ render() {
142
+ const n = t.withGuide ?? settings.withGuide, i = n ? [`${styleText("gray", S_BAR)}`, `${symbol(this.state)} ${t.message}`] : [`${symbol(this.state)} ${t.message}`], l = this.userInput, o = this.options, m = t.placeholder, p = l === "" && m !== void 0, $ = (r, s) => {
143
+ const a = P(r), u = r.hint && r.value === this.focusedValue ? styleText("dim", ` (${r.hint})`) : "";
144
+ switch (s) {
145
+ case "active":
146
+ return `${styleText("green", S_RADIO_ACTIVE)} ${a}${u}`;
147
+ case "inactive":
148
+ return `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`;
149
+ case "disabled":
150
+ return `${styleText("gray", S_RADIO_INACTIVE)} ${styleText(["strikethrough", "gray"], a)}`;
151
+ }
152
+ };
153
+ switch (this.state) {
154
+ case "submit": {
155
+ const r = N(this.selectedValues, o), s = r.length > 0 ? ` ${styleText("dim", r.map(P).join(", "))}` : "", a = n ? styleText("gray", S_BAR) : "";
156
+ return `${i.join(`
3
157
  `)}
4
- ${d}${l}`}case"cancel":{const o=r?` ${e(["strikethrough","dim"],r)}`:"",l=i?e("gray",$):"";return`${s.join(`
158
+ ${a}${s}`;
159
+ }
160
+ case "cancel": {
161
+ const r = l ? ` ${styleText(["strikethrough", "dim"], l)}` : "", s = n ? styleText("gray", S_BAR) : "";
162
+ return `${i.join(`
5
163
  `)}
6
- ${l}${o}`}default:{const o=this.state==="error"?"yellow":"cyan",l=i?`${e(o,$)} `:"",d=i?e(o,x):"";let g="";if(this.isNavigating||a){const v=a?n:r;g=v!==""?` ${e("dim",v)}`:""}else g=` ${this.userInputWithCursor}`;const p=this.filteredOptions.length!==u.length?e("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",f=this.filteredOptions.length===0&&r?[`${l}${e("yellow","No matches found")}`]:[],h=this.state==="error"?[`${l}${e("yellow",this.error)}`]:[];i&&s.push(`${l.trimEnd()}`),s.push(`${l}${e("dim","Search:")}${g}${p}`,...f,...h);const I=[`${e("dim","\u2191/\u2193")} to select`,`${e("dim","Enter:")} confirm`,`${e("dim","Type:")} to search`],m=[`${l}${I.join(" \u2022 ")}`,d],y=this.filteredOptions.length===0?[]:F({cursor:this.cursor,options:this.filteredOptions,columnPadding:i?3:0,rowPadding:s.length+m.length,style:(v,C)=>c(v,v.disabled?"disabled":C?"active":"inactive"),maxItems:t.maxItems,output:t.output});return[...s,...y.map(v=>`${l}${v}`),...m].join(`
7
- `)}}}}).prompt(),ie=t=>{const i=(r,u,n,a)=>{const c=n.includes(r.value),o=r.label??String(r.value??""),l=r.hint&&a!==void 0&&r.value===a?e("dim",` (${r.hint})`):"",d=c?e("green",K):e("dim",Y);return r.disabled?`${e("gray",Y)} ${e(["strikethrough","gray"],o)}`:u?`${d} ${o}${l}`:`${d} ${e("dim",o)}`},s=new vt({options:t.options,multiple:!0,placeholder:t.placeholder,filter:t.filter??((r,u)=>Rt(r,u)),validate:()=>{if(t.required&&s.selectedValues.length===0)return"Please select at least one item"},initialValue:t.initialValues,signal:t.signal,input:t.input,output:t.output,render(){const r=t.withGuide??T.withGuide,u=`${r?`${e("gray",$)}
8
- `:""}${P(this.state)} ${t.message}
9
- `,n=this.userInput,a=t.placeholder,c=n===""&&a!==void 0,o=this.isNavigating||c?e("dim",c?a:n):this.userInputWithCursor,l=this.options,d=this.filteredOptions.length!==l.length?e("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${u}${r?`${e("gray",$)} `:""}${e("dim",`${this.selectedValues.length} items selected`)}`;case"cancel":return`${u}${r?`${e("gray",$)} `:""}${e(["strikethrough","dim"],n)}`;default:{const g=this.state==="error"?"yellow":"cyan",p=r?`${e(g,$)} `:"",f=r?e(g,x):"",h=[`${e("dim","\u2191/\u2193")} to navigate`,`${e("dim",this.isNavigating?"Space/Tab:":"Tab:")} select`,`${e("dim","Enter:")} confirm`,`${e("dim","Type:")} to search`],I=this.filteredOptions.length===0&&n?[`${p}${e("yellow","No matches found")}`]:[],m=this.state==="error"?[`${p}${e("yellow",this.error)}`]:[],y=[...`${u}${r?e(g,$):""}`.split(`
10
- `),`${p}${e("dim","Search:")} ${o}${d}`,...I,...m],v=[`${p}${h.join(" \u2022 ")}`,f],C=F({cursor:this.cursor,options:this.filteredOptions,style:(S,b)=>i(S,b,this.selectedValues,this.focusedValue),maxItems:t.maxItems,output:t.output,rowPadding:y.length+v.length});return[...y,...C.map(S=>`${p}${S}`),...v].join(`
11
- `)}}}});return s.prompt()},re=[Mt,ct,dt,$t],ne=[lt,_t,x,xt];function Vt(t,i,s,r){let u=s,n=s;return r==="center"?u=Math.floor((i-t)/2):r==="right"&&(u=i-t-s),n=i-u-t,[u,n]}const oe=t=>t,ae=(t="",i="",s)=>{const r=s?.output??process.stdout,u=X(r),n=2,a=s?.titlePadding??1,c=s?.contentPadding??2,o=s?.width===void 0||s.width==="auto"?1:Math.min(1,s.width),l=s?.withGuide??T.withGuide?`${$} `:"",d=s?.formatBorder??oe,g=(s?.rounded?re:ne).map(d),p=d(st),f=d($),h=B(l),I=B(i),m=u-h;let y=Math.floor(u*o)-h;if(s?.width==="auto"){const O=t.split(`
12
- `);let j=I+a*2;for(const rt of O){const W=B(rt)+c*2;W>j&&(j=W)}const k=j+n;k<y&&(y=k)}y%2!==0&&(y<m?y++:y--);const v=y-n,C=v-a*2,S=I>C?`${i.slice(0,C-3)}...`:i,[b,G]=Vt(B(S),v,a,s?.titleAlign),M=J(t,v-c*2,{hard:!0,trim:!1});r.write(`${l}${g[0]}${p.repeat(b)}${S}${p.repeat(G)}${g[1]}
13
- `);const N=M.split(`
14
- `);for(const O of N){const[j,k]=Vt(B(O),v,c,s?.contentAlign);r.write(`${l}${f}${" ".repeat(j)}${O}${" ".repeat(k)}${f}
15
- `)}r.write(`${l}${g[2]}${p.repeat(v)}${g[3]}
16
- `)},ue=t=>{const i=t.active??"Yes",s=t.inactive??"No";return new Dt({active:i,inactive:s,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue??!0,render(){const r=t.withGuide??T.withGuide,u=`${P(this.state)} `,n=r?`${e("gray",$)} `:"",a=E(t.output,t.message,n,u),c=`${r?`${e("gray",$)}
17
- `:""}${a}
18
- `,o=this.value?i:s;switch(this.state){case"submit":{const l=r?`${e("gray",$)} `:"";return`${c}${l}${e("dim",o)}`}case"cancel":{const l=r?`${e("gray",$)} `:"";return`${c}${l}${e(["strikethrough","dim"],o)}${r?`
19
- ${e("gray",$)}`:""}`}default:{const l=r?`${e("cyan",$)} `:"",d=r?e("cyan",x):"";return`${c}${l}${this.value?`${e("green",z)} ${i}`:`${e("dim",U)} ${e("dim",i)}`}${t.vertical?r?`
20
- ${e("cyan",$)} `:`
21
- `:` ${e("dim","/")} `}${this.value?`${e("dim",U)} ${e("dim",s)}`:`${e("green",z)} ${s}`}
22
- ${d}
23
- `}}}}).prompt()},le=t=>{const i=t.validate;return new Wt({...t,validate(s){if(s===void 0)return t.defaultValue!==void 0?void 0:i?i(s):T.date.messages.required;const r=u=>u.toISOString().slice(0,10);if(t.minDate&&r(s)<r(t.minDate))return T.date.messages.afterMin(t.minDate);if(t.maxDate&&r(s)>r(t.maxDate))return T.date.messages.beforeMax(t.maxDate);if(i)return i(s)},render(){const s=(t?.withGuide??T.withGuide)!==!1,r=`${`${s?`${e("gray",$)}
24
- `:""}${P(this.state)} `}${t.message}
25
- `,u=this.state!=="initial"?this.state:"active",n=ce(this,u),a=this.value instanceof Date?this.formattedValue:"";switch(this.state){case"error":{const c=this.error?` ${e("yellow",this.error)}`:"",o=s?`${e("yellow",$)} `:"",l=s?e("yellow",x):"";return`${r.trim()}
26
- ${o}${n}
27
- ${l}${c}
28
- `}case"submit":{const c=a?` ${e("dim",a)}`:"",o=s?e("gray",$):"";return`${r}${o}${c}`}case"cancel":{const c=a?` ${e(["strikethrough","dim"],a)}`:"",o=s?e("gray",$):"";return`${r}${o}${c}${a.trim()?`
29
- ${o}`:""}`}default:{const c=s?`${e("cyan",$)} `:"",o=s?e("cyan",x):"",l=s?`${e("cyan",$)} `:"",d=this.inlineError?`
30
- ${l}${e("yellow",this.inlineError)}`:"";return`${r}${c}${n}${d}
31
- ${o}
32
- `}}}}).prompt()};function ce(t,i){const s=t.segmentValues,r=t.segmentCursor;if(i==="submit"||i==="cancel")return t.formattedValue;const u=e("gray",t.separator);return t.segments.map((n,a)=>{const c=a===r.segmentIndex&&!["submit","cancel"].includes(i),o=de[n.type];return $e(s[n.type],{isActive:c,label:o})}).join(u)}function $e(t,i){const s=!t||t.replace(/_/g,"")==="";return i.isActive?e("inverse",s?i.label:t.replace(/_/g," ")):s?e("dim",i.label):t.replace(/_/g,e("dim"," "))}const de={year:"yyyy",month:"mm",day:"dd"},he=async(t,i)=>{const s={},r=Object.keys(t);for(const u of r){const n=t[u],a=await n({results:s})?.catch(c=>{throw c});if(typeof i?.onCancel=="function"&&Ft(a)){s[u]="canceled",i.onCancel({results:s});continue}s[u]=a}return s},pe=t=>{const{selectableGroups:i=!0,groupSpacing:s=0}=t,r=(n,a,c=[])=>{const o=n.label??String(n.value),l=typeof n.group=="string",d=l&&(c[c.indexOf(n)+1]??{group:!0}),g=l&&d&&d.group===!0;let p="",f="";l&&(i?(p=g?`${x} `:`${$} `,f=g?" ":`${$} `):p=" ");let h="";if(s>0&&!l&&(h=`
33
- `.repeat(s)),a==="active")return E(t.output,`${o}${n.hint?` ${e("dim",`(${n.hint})`)}`:""}`,`${h}${e("dim",p)} `,`${h}${e("dim",p)}${e("cyan",et)} `,`${h}${e("dim",f)} `);if(a==="group-active")return E(t.output,o,`${h}${p} `,`${h}${p}${e("cyan",et)} `,`${h}${f} `,m=>e("dim",m));if(a==="group-active-selected")return E(t.output,o,`${h}${p} `,`${h}${p}${e("green",K)} `,`${h}${f} `,m=>e("dim",m));if(a==="selected"){const m=l||i?e("green",K):"";return E(t.output,`${o}${n.hint?` (${n.hint})`:""}`,`${h}${e("dim",p)} `,`${h}${e("dim",p)}${m} `,`${h}${e("dim",f)} `,y=>e("dim",y))}if(a==="cancelled")return`${e(["strikethrough","dim"],o)}`;if(a==="active-selected")return E(t.output,`${o}${n.hint?` ${e("dim",`(${n.hint})`)}`:""}`,`${h}${e("dim",p)} `,`${h}${e("dim",p)}${e("green",K)} `,`${h}${e("dim",f)} `);if(a==="submitted")return`${e("dim",o)}`;const I=l||i?e("dim",Y):"";return E(t.output,o,`${h}${e("dim",p)} `,`${h}${e("dim",p)}${I} `,`${h}${e("dim",f)} `,m=>e("dim",m))},u=t.required??!0;return new Ht({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValues:t.initialValues,required:u,cursorAt:t.cursorAt,selectableGroups:i,validate(n){if(u&&(n===void 0||n.length===0))return`Please select at least one option.
34
- ${e("reset",e("dim",`Press ${e(["gray","bgWhite","inverse"]," space ")} to select, ${e("gray",e(["bgWhite","inverse"]," enter "))} to submit`))}`},render(){const n=t.withGuide??T.withGuide,a=`${n?`${e("gray",$)}
35
- `:""}${P(this.state)} ${t.message}
36
- `,c=this.value??[],o=(l,d)=>{const g=this.options,p=c.includes(l.value)||l.group===!0&&this.isGroupSelected(`${l.value}`);return!d&&typeof l.group=="string"&&this.options[this.cursor].value===l.group?r(l,p?"group-active-selected":"group-active",g):d&&p?r(l,"active-selected",g):p?r(l,"selected",g):r(l,d?"active":"inactive",g)};switch(this.state){case"submit":{const l=this.options.filter(({value:g})=>c.includes(g)).map(g=>r(g,"submitted")),d=l.length===0?"":` ${l.join(e("dim",", "))}`;return`${a}${n?e("gray",$):""}${d}`}case"cancel":{const l=this.options.filter(({value:d})=>c.includes(d)).map(d=>r(d,"cancelled")).join(e("dim",", "));return`${a}${n?`${e("gray",$)} `:""}${l.trim()?`${l}${n?`
37
- ${e("gray",$)}`:""}`:""}`}case"error":{const l=n?`${e("yellow",$)} `:"",d=this.error.split(`
38
- `).map((h,I)=>I===0?`${n?`${e("yellow",x)} `:""}${e("yellow",h)}`:` ${h}`).join(`
39
- `),g=a.split(`
40
- `).length,p=d.split(`
41
- `).length+1,f=F({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:l.length,rowPadding:g+p,style:o}).join(`
42
- ${l}`);return`${a}${l}${f}
43
- ${d}
44
- `}default:{const l=n?`${e("cyan",$)} `:"",d=a.split(`
45
- `).length,g=(n?1:0)+1,p=F({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:l.length,rowPadding:d+g,style:o}).join(`
46
- ${l}`);return`${a}${l}${p}
47
- ${n?e("cyan",x):""}
48
- `}}}}).prompt()},R={message:(t=[],{symbol:i=e("gray",$),secondarySymbol:s=e("gray",$),output:r=process.stdout,spacing:u=1,withGuide:n}={})=>{const a=[],c=n??T.withGuide,o=c?s:"",l=c?`${i} `:"",d=c?`${s} `:"";for(let p=0;p<u;p++)a.push(o);const g=Array.isArray(t)?t:t.split(`
49
- `);if(g.length>0){const[p,...f]=g;p.length>0?a.push(`${l}${p}`):a.push(c?i:"");for(const h of f)h.length>0?a.push(`${d}${h}`):a.push(c?s:"")}r.write(`${a.join(`
164
+ ${s}${r}`;
165
+ }
166
+ default: {
167
+ const r = this.state === "error" ? "yellow" : "cyan", s = n ? `${styleText(r, S_BAR)} ` : "", a = n ? styleText(r, S_BAR_END) : "";
168
+ let u = "";
169
+ if (this.isNavigating || p) {
170
+ const d = p ? m : l;
171
+ u = d !== "" ? ` ${styleText("dim", d)}` : "";
172
+ } else
173
+ u = ` ${this.userInputWithCursor}`;
174
+ const V = this.filteredOptions.length !== o.length ? styleText(
175
+ "dim",
176
+ ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
177
+ ) : "", y = this.filteredOptions.length === 0 && l ? [`${s}${styleText("yellow", "No matches found")}`] : [], b = this.state === "error" ? [`${s}${styleText("yellow", this.error)}`] : [];
178
+ n && i.push(`${s.trimEnd()}`), i.push(
179
+ `${s}${styleText("dim", "Search:")}${u}${V}`,
180
+ ...y,
181
+ ...b
182
+ );
183
+ const v = [
184
+ `${styleText("dim", "\u2191/\u2193")} to select`,
185
+ `${styleText("dim", "Enter:")} confirm`,
186
+ `${styleText("dim", "Type:")} to search`
187
+ ], g = [`${s}${v.join(" \u2022 ")}`, a], O = this.filteredOptions.length === 0 ? [] : limitOptions({
188
+ cursor: this.cursor,
189
+ options: this.filteredOptions,
190
+ columnPadding: n ? 3 : 0,
191
+ // for `| ` when guide is shown
192
+ rowPadding: i.length + g.length,
193
+ style: (d, f) => $(
194
+ d,
195
+ d.disabled ? "disabled" : f ? "active" : "inactive"
196
+ ),
197
+ maxItems: t.maxItems,
198
+ output: t.output
199
+ });
200
+ return [
201
+ ...i,
202
+ ...O.map((d) => `${s}${d}`),
203
+ ...g
204
+ ].join(`
205
+ `);
206
+ }
207
+ }
208
+ }
209
+ }).prompt(), autocompleteMultiselect = (t) => {
210
+ const c = (i, l, o, m) => {
211
+ const p = o.includes(i.value), $ = i.label ?? String(i.value ?? ""), r = i.hint && m !== void 0 && i.value === m ? styleText("dim", ` (${i.hint})`) : "", s = p ? styleText("green", S_CHECKBOX_SELECTED) : styleText("dim", S_CHECKBOX_INACTIVE);
212
+ return i.disabled ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${styleText(["strikethrough", "gray"], $)}` : l ? `${s} ${$}${r}` : `${s} ${styleText("dim", $)}`;
213
+ }, n = new AutocompletePrompt({
214
+ options: t.options,
215
+ multiple: true,
216
+ placeholder: t.placeholder,
217
+ filter: t.filter ?? ((i, l) => E(i, l)),
218
+ validate: () => {
219
+ if (t.required && n.selectedValues.length === 0)
220
+ return "Please select at least one item";
221
+ },
222
+ initialValue: t.initialValues,
223
+ signal: t.signal,
224
+ input: t.input,
225
+ output: t.output,
226
+ render() {
227
+ const i = t.withGuide ?? settings.withGuide, l = `${i ? `${styleText("gray", S_BAR)}
228
+ ` : ""}${symbol(this.state)} ${t.message}
229
+ `, o = this.userInput, m = t.placeholder, p = o === "" && m !== void 0, $ = this.isNavigating || p ? styleText("dim", p ? m : o) : this.userInputWithCursor, r = this.options, s = this.filteredOptions.length !== r.length ? styleText(
230
+ "dim",
231
+ ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
232
+ ) : "";
233
+ switch (this.state) {
234
+ case "submit":
235
+ return `${l}${i ? `${styleText("gray", S_BAR)} ` : ""}${styleText(
236
+ "dim",
237
+ `${this.selectedValues.length} items selected`
238
+ )}`;
239
+ case "cancel":
240
+ return `${l}${i ? `${styleText("gray", S_BAR)} ` : ""}${styleText(
241
+ ["strikethrough", "dim"],
242
+ o
243
+ )}`;
244
+ default: {
245
+ const a = this.state === "error" ? "yellow" : "cyan", u = i ? `${styleText(a, S_BAR)} ` : "", V = i ? styleText(a, S_BAR_END) : "", y = [
246
+ `${styleText("dim", "\u2191/\u2193")} to navigate`,
247
+ `${styleText("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
248
+ `${styleText("dim", "Enter:")} confirm`,
249
+ `${styleText("dim", "Type:")} to search`
250
+ ], b = this.filteredOptions.length === 0 && o ? [`${u}${styleText("yellow", "No matches found")}`] : [], v = this.state === "error" ? [`${u}${styleText("yellow", this.error)}`] : [], g = [
251
+ ...`${l}${i ? styleText(a, S_BAR) : ""}`.split(`
252
+ `),
253
+ `${u}${styleText("dim", "Search:")} ${$}${s}`,
254
+ ...b,
255
+ ...v
256
+ ], O = [`${u}${y.join(" \u2022 ")}`, V], d = limitOptions({
257
+ cursor: this.cursor,
258
+ options: this.filteredOptions,
259
+ style: (f, _) => c(f, _, this.selectedValues, this.focusedValue),
260
+ maxItems: t.maxItems,
261
+ output: t.output,
262
+ rowPadding: g.length + O.length
263
+ });
264
+ return [
265
+ ...g,
266
+ ...d.map((f) => `${u}${f}`),
267
+ ...O
268
+ ].join(`
269
+ `);
270
+ }
271
+ }
272
+ }
273
+ });
274
+ return n.prompt();
275
+ };
276
+
277
+ const J = [
278
+ S_CORNER_TOP_LEFT,
279
+ S_CORNER_TOP_RIGHT,
280
+ S_CORNER_BOTTOM_LEFT,
281
+ S_CORNER_BOTTOM_RIGHT
282
+ ], K = [S_BAR_START, S_BAR_START_RIGHT, S_BAR_END, S_BAR_END_RIGHT];
283
+ function A$1(n, e, t, o) {
284
+ let i = t, f = t;
285
+ return o === "center" ? i = Math.floor((e - n) / 2) : o === "right" && (i = e - n - t), f = e - i - n, [i, f];
286
+ }
287
+ const Q = (n) => n;
288
+ const box = (n = "", e = "", t) => {
289
+ const o = t?.output ?? process.stdout, i = getColumns(o), R = 1 * 2, u = t?.titlePadding ?? 1, h = t?.contentPadding ?? 2, w = t?.width === void 0 || t.width === "auto" ? 1 : Math.min(1, t.width), m = t?.withGuide ?? settings.withGuide ? `${S_BAR} ` : "", b = t?.formatBorder ?? Q, a = (t?.rounded ? J : K).map(b), _ = b(S_BAR_H), B = b(S_BAR), p = l(m), x = l(e), O = i - p;
290
+ let r = Math.floor(i * w) - p;
291
+ if (t?.width === "auto") {
292
+ const c = n.split(`
293
+ `);
294
+ let s = x + u * 2;
295
+ for (const G of c) {
296
+ const P = l(G) + h * 2;
297
+ P > s && (s = P);
298
+ }
299
+ const g = s + R;
300
+ g < r && (r = g);
301
+ }
302
+ r % 2 !== 0 && (r < O ? r++ : r--);
303
+ const d = r - R, S = d - u * 2, T = x > S ? `${e.slice(0, S - 3)}...` : e, [y, W] = A$1(
304
+ l(T),
305
+ d,
306
+ u,
307
+ t?.titleAlign
308
+ ), L = wrapAnsi(n, d - h * 2, {
309
+ hard: true,
310
+ trim: false
311
+ });
312
+ o.write(
313
+ `${m}${a[0]}${_.repeat(y)}${T}${_.repeat(W)}${a[1]}
314
+ `
315
+ );
316
+ const E = L.split(`
317
+ `);
318
+ for (const c of E) {
319
+ const [s, g] = A$1(
320
+ l(c),
321
+ d,
322
+ h,
323
+ t?.contentAlign
324
+ );
325
+ o.write(
326
+ `${m}${B}${" ".repeat(s)}${c}${" ".repeat(g)}${B}
327
+ `
328
+ );
329
+ }
330
+ o.write(`${m}${a[2]}${_.repeat(d)}${a[3]}
331
+ `);
332
+ };
333
+
334
+ const confirm = (i) => {
335
+ const a = i.active ?? "Yes", s = i.inactive ?? "No";
336
+ return new ConfirmPrompt({
337
+ active: a,
338
+ inactive: s,
339
+ signal: i.signal,
340
+ input: i.input,
341
+ output: i.output,
342
+ initialValue: i.initialValue ?? true,
343
+ render() {
344
+ const e = i.withGuide ?? settings.withGuide, u = `${symbol(this.state)} `, l = e ? `${styleText("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(
345
+ i.output,
346
+ i.message,
347
+ l,
348
+ u
349
+ ), o = `${e ? `${styleText("gray", S_BAR)}
350
+ ` : ""}${f}
351
+ `, c = this.value ? a : s;
352
+ switch (this.state) {
353
+ case "submit": {
354
+ const r = e ? `${styleText("gray", S_BAR)} ` : "";
355
+ return `${o}${r}${styleText("dim", c)}`;
356
+ }
357
+ case "cancel": {
358
+ const r = e ? `${styleText("gray", S_BAR)} ` : "";
359
+ return `${o}${r}${styleText(["strikethrough", "dim"], c)}${e ? `
360
+ ${styleText("gray", S_BAR)}` : ""}`;
361
+ }
362
+ default: {
363
+ const r = e ? `${styleText("cyan", S_BAR)} ` : "", g = e ? styleText("cyan", S_BAR_END) : "";
364
+ return `${o}${r}${this.value ? `${styleText("green", S_RADIO_ACTIVE)} ${a}` : `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`}${i.vertical ? e ? `
365
+ ${styleText("cyan", S_BAR)} ` : `
366
+ ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", s)}` : `${styleText("green", S_RADIO_ACTIVE)} ${s}`}
367
+ ${g}
368
+ `;
369
+ }
370
+ }
371
+ }
372
+ }).prompt();
373
+ };
374
+
375
+ const date = (e) => {
376
+ const r = e.validate;
377
+ return new DatePrompt({
378
+ ...e,
379
+ validate(t) {
380
+ if (t === void 0)
381
+ return e.defaultValue !== void 0 ? void 0 : r ? runValidation(r, t) : settings.date.messages.required;
382
+ const o = (i) => i.toISOString().slice(0, 10);
383
+ if (e.minDate && o(t) < o(e.minDate))
384
+ return settings.date.messages.afterMin(e.minDate);
385
+ if (e.maxDate && o(t) > o(e.maxDate))
386
+ return settings.date.messages.beforeMax(e.maxDate);
387
+ if (r) return runValidation(r, t);
388
+ },
389
+ render() {
390
+ const t = (e?.withGuide ?? settings.withGuide) !== false, i = `${`${t ? `${styleText("gray", S_BAR)}
391
+ ` : ""}${symbol(this.state)} `}${e.message}
392
+ `, l = this.state !== "initial" ? this.state : "active", d = b(this, l), c = this.value instanceof Date ? this.formattedValue : "";
393
+ switch (this.state) {
394
+ case "error": {
395
+ const a = this.error ? ` ${styleText("yellow", this.error)}` : "", s = t ? `${styleText("yellow", S_BAR)} ` : "", f = t ? styleText("yellow", S_BAR_END) : "";
396
+ return `${i.trim()}
397
+ ${s}${d}
398
+ ${f}${a}
399
+ `;
400
+ }
401
+ case "submit": {
402
+ const a = c ? ` ${styleText("dim", c)}` : "", s = t ? styleText("gray", S_BAR) : "";
403
+ return `${i}${s}${a}`;
404
+ }
405
+ case "cancel": {
406
+ const a = c ? ` ${styleText(["strikethrough", "dim"], c)}` : "", s = t ? styleText("gray", S_BAR) : "";
407
+ return `${i}${s}${a}${c.trim() ? `
408
+ ${s}` : ""}`;
409
+ }
410
+ default: {
411
+ const a = t ? `${styleText("cyan", S_BAR)} ` : "", s = t ? styleText("cyan", S_BAR_END) : "", f = t ? `${styleText("cyan", S_BAR)} ` : "", g = this.inlineError ? `
412
+ ${f}${styleText("yellow", this.inlineError)}` : "";
413
+ return `${i}${a}${d}${g}
414
+ ${s}
415
+ `;
416
+ }
417
+ }
418
+ }
419
+ }).prompt();
420
+ };
421
+ function b(e, r) {
422
+ const t = e.segmentValues, o = e.segmentCursor;
423
+ if (r === "submit" || r === "cancel")
424
+ return e.formattedValue;
425
+ const i = styleText("gray", e.separator);
426
+ return e.segments.map((l, d) => {
427
+ const c = d === o.segmentIndex && !["submit", "cancel"].includes(r), a = p[l.type];
428
+ return x(t[l.type], { isActive: c, label: a });
429
+ }).join(i);
430
+ }
431
+ function x(e, r) {
432
+ const t = !e || e.replace(/_/g, "") === "";
433
+ return r.isActive ? styleText("inverse", t ? r.label : e.replace(/_/g, " ")) : t ? styleText("dim", r.label) : e.replace(/_/g, styleText("dim", " "));
434
+ }
435
+ const p = {
436
+ year: "yyyy",
437
+ month: "mm",
438
+ day: "dd"
439
+ };
440
+
441
+ const group = async (o, r) => {
442
+ const t = {}, p = Object.keys(o);
443
+ for (const e of p) {
444
+ const i = o[e], n = await i({ results: t })?.catch((a) => {
445
+ throw a;
446
+ });
447
+ if (typeof r?.onCancel == "function" && isCancel(n)) {
448
+ t[e] = "canceled", r.onCancel({ results: t });
449
+ continue;
450
+ }
451
+ t[e] = n;
452
+ }
453
+ return t;
454
+ };
455
+
456
+ const groupMultiselect = (u) => {
457
+ const { selectableGroups: h = true, groupSpacing: x = 0 } = u, m = (i, l, g = []) => {
458
+ const c = i.label ?? String(i.value), t = typeof i.group == "string", s = t && (g[g.indexOf(i) + 1] ?? { group: true }), o = t && s && s.group === true;
459
+ let n = "", a = "";
460
+ t && (h ? (n = o ? `${S_BAR_END} ` : `${S_BAR} `, a = o ? " " : `${S_BAR} `) : n = " ");
461
+ let r = "";
462
+ if (x > 0 && !t && (r = `
463
+ `.repeat(x)), l === "active")
464
+ return wrapTextWithPrefix(
465
+ u.output,
466
+ `${c}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}`,
467
+ `${r}${styleText("dim", n)} `,
468
+ `${r}${styleText("dim", n)}${styleText("cyan", S_CHECKBOX_ACTIVE)} `,
469
+ `${r}${styleText("dim", a)} `
470
+ );
471
+ if (l === "group-active")
472
+ return wrapTextWithPrefix(
473
+ u.output,
474
+ c,
475
+ `${r}${n} `,
476
+ `${r}${n}${styleText("cyan", S_CHECKBOX_ACTIVE)} `,
477
+ `${r}${a} `,
478
+ (d) => styleText("dim", d)
479
+ );
480
+ if (l === "group-active-selected")
481
+ return wrapTextWithPrefix(
482
+ u.output,
483
+ c,
484
+ `${r}${n} `,
485
+ `${r}${n}${styleText("green", S_CHECKBOX_SELECTED)} `,
486
+ `${r}${a} `,
487
+ (d) => styleText("dim", d)
488
+ );
489
+ if (l === "selected") {
490
+ const d = t || h ? styleText("green", S_CHECKBOX_SELECTED) : "";
491
+ return wrapTextWithPrefix(
492
+ u.output,
493
+ `${c}${i.hint ? ` (${i.hint})` : ""}`,
494
+ `${r}${styleText("dim", n)} `,
495
+ `${r}${styleText("dim", n)}${d} `,
496
+ `${r}${styleText("dim", a)} `,
497
+ (V) => styleText("dim", V)
498
+ );
499
+ }
500
+ if (l === "cancelled")
501
+ return `${styleText(["strikethrough", "dim"], c)}`;
502
+ if (l === "active-selected")
503
+ return wrapTextWithPrefix(
504
+ u.output,
505
+ `${c}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}`,
506
+ `${r}${styleText("dim", n)} `,
507
+ `${r}${styleText("dim", n)}${styleText("green", S_CHECKBOX_SELECTED)} `,
508
+ `${r}${styleText("dim", a)} `
509
+ );
510
+ if (l === "submitted")
511
+ return `${styleText("dim", c)}`;
512
+ const f = t || h ? styleText("dim", S_CHECKBOX_INACTIVE) : "";
513
+ return wrapTextWithPrefix(
514
+ u.output,
515
+ c,
516
+ `${r}${styleText("dim", n)} `,
517
+ `${r}${styleText("dim", n)}${f} `,
518
+ `${r}${styleText("dim", a)} `,
519
+ (d) => styleText("dim", d)
520
+ );
521
+ }, y = u.required ?? true;
522
+ return new GroupMultiSelectPrompt({
523
+ options: u.options,
524
+ signal: u.signal,
525
+ input: u.input,
526
+ output: u.output,
527
+ initialValues: u.initialValues,
528
+ required: y,
529
+ cursorAt: u.cursorAt,
530
+ selectableGroups: h,
531
+ validate(i) {
532
+ if (y && (i === void 0 || i.length === 0))
533
+ return `Please select at least one option.
534
+ ${styleText(
535
+ "reset",
536
+ styleText(
537
+ "dim",
538
+ `Press ${styleText(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText(
539
+ "gray",
540
+ styleText(["bgWhite", "inverse"], " enter ")
541
+ )} to submit`
542
+ )
543
+ )}`;
544
+ },
545
+ render() {
546
+ const i = u.withGuide ?? settings.withGuide, l = `${i ? `${styleText("gray", S_BAR)}
547
+ ` : ""}${symbol(this.state)} ${u.message}
548
+ `, g = this.value ?? [], c = (t, s) => {
549
+ const o = this.options, n = g.includes(t.value) || t.group === true && this.isGroupSelected(`${t.value}`);
550
+ return !s && typeof t.group == "string" && this.options[this.cursor].value === t.group ? m(t, n ? "group-active-selected" : "group-active", o) : s && n ? m(t, "active-selected", o) : n ? m(t, "selected", o) : m(t, s ? "active" : "inactive", o);
551
+ };
552
+ switch (this.state) {
553
+ case "submit": {
554
+ const t = this.options.filter(({ value: o }) => g.includes(o)).map((o) => m(o, "submitted")), s = t.length === 0 ? "" : ` ${t.join(styleText("dim", ", "))}`;
555
+ return `${l}${i ? styleText("gray", S_BAR) : ""}${s}`;
556
+ }
557
+ case "cancel": {
558
+ const t = this.options.filter(({ value: s }) => g.includes(s)).map((s) => m(s, "cancelled")).join(styleText("dim", ", "));
559
+ return `${l}${i ? `${styleText("gray", S_BAR)} ` : ""}${t.trim() ? `${t}${i ? `
560
+ ${styleText("gray", S_BAR)}` : ""}` : ""}`;
561
+ }
562
+ case "error": {
563
+ const t = i ? `${styleText("yellow", S_BAR)} ` : "", s = this.error.split(`
564
+ `).map(
565
+ (r, f) => f === 0 ? `${i ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", r)}` : ` ${r}`
566
+ ).join(`
567
+ `), o = l.split(`
568
+ `).length, n = s.split(`
569
+ `).length + 1, a = limitOptions({
570
+ output: u.output,
571
+ options: this.options,
572
+ cursor: this.cursor,
573
+ maxItems: u.maxItems,
574
+ columnPadding: t.length,
575
+ rowPadding: o + n,
576
+ style: c
577
+ }).join(`
578
+ ${t}`);
579
+ return `${l}${t}${a}
580
+ ${s}
581
+ `;
582
+ }
583
+ default: {
584
+ const t = i ? `${styleText("cyan", S_BAR)} ` : "", s = l.split(`
585
+ `).length, o = (i ? 1 : 0) + 1, n = limitOptions({
586
+ output: u.output,
587
+ options: this.options,
588
+ cursor: this.cursor,
589
+ maxItems: u.maxItems,
590
+ columnPadding: t.length,
591
+ rowPadding: s + o,
592
+ style: c
593
+ }).join(`
594
+ ${t}`);
595
+ return `${l}${t}${n}
596
+ ${i ? styleText("cyan", S_BAR_END) : ""}
597
+ `;
598
+ }
599
+ }
600
+ }
601
+ }).prompt();
602
+ };
603
+
604
+ const log = {
605
+ message: (s = [], {
606
+ symbol: e = styleText("gray", S_BAR),
607
+ secondarySymbol: r = styleText("gray", S_BAR),
608
+ output: m = process.stdout,
609
+ spacing: l = 1,
610
+ withGuide: c
611
+ } = {}) => {
612
+ const t = [], o = c ?? settings.withGuide, f = o ? r : "", O = o ? `${e} ` : "", u = o ? `${r} ` : "";
613
+ for (let i = 0; i < l; i++)
614
+ t.push(f);
615
+ const g = Array.isArray(s) ? s : s.split(`
616
+ `);
617
+ if (g.length > 0) {
618
+ const [i, ...y] = g;
619
+ i.length > 0 ? t.push(`${O}${i}`) : t.push(o ? e : "");
620
+ for (const p of y)
621
+ p.length > 0 ? t.push(`${u}${p}`) : t.push(o ? r : "");
622
+ }
623
+ m.write(`${t.join(`
50
624
  `)}
51
- `)},info:(t,i)=>{R.message(t,{...i,symbol:e("blue",ht)})},success:(t,i)=>{R.message(t,{...i,symbol:e("green",pt)})},step:(t,i)=>{R.message(t,{...i,symbol:e("green",H)})},warn:(t,i)=>{R.message(t,{...i,symbol:e("yellow",mt)})},warning:(t,i)=>{R.warn(t,i)},error:(t,i)=>{R.message(t,{...i,symbol:e("red",gt)})}},me=(t="",i)=>{const s=i?.output??process.stdout,r=i?.withGuide??T.withGuide?`${e("gray",x)} `:"";s.write(`${r}${e("red",t)}
52
-
53
- `)},ge=(t="",i)=>{const s=i?.output??process.stdout,r=i?.withGuide??T.withGuide?`${e("gray",lt)} `:"";s.write(`${r}${t}
54
- `)},ye=(t="",i)=>{const s=i?.output??process.stdout,r=i?.withGuide??T.withGuide?`${e("gray",$)}
55
- ${e("gray",x)} `:"";s.write(`${r}${t}
56
-
57
- `)},fe=t=>new Ut({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,showSubmit:t.showSubmit,output:t.output,signal:t.signal,input:t.input,render(){const i=t?.withGuide??T.withGuide,s=`${`${i?`${e("gray",$)}
58
- `:""}${P(this.state)} `}${t.message}
59
- `,r=t.placeholder?e("inverse",t.placeholder[0])+e("dim",t.placeholder.slice(1)):e(["inverse","hidden"],"_"),u=this.userInput?this.userInputWithCursor:r,n=this.value??"",a=t.showSubmit?`
60
- ${e(this.focused==="submit"?"cyan":"dim","[ submit ]")}`:"";switch(this.state){case"error":{const c=`${e("yellow",$)} `,o=i?E(t.output,u,c,void 0):u,l=e("yellow",x);return`${s}${o}
61
- ${l} ${e("yellow",this.error)}${a}
62
- `}case"submit":{const c=`${e("gray",$)} `,o=i?E(t.output,n,c,void 0,void 0,l=>e("dim",l)):n?e("dim",n):"";return`${s}${o}`}case"cancel":{const c=`${e("gray",$)} `,o=i?E(t.output,n,c,void 0,void 0,l=>e(["strikethrough","dim"],l)):n?e(["strikethrough","dim"],n):"";return`${s}${o}`}default:{const c=i?`${e("cyan",$)} `:"",o=i?e("cyan",x):"",l=i?E(t.output,u,c):u;return`${s}${l}
63
- ${o}${a}
64
- `}}}}).prompt(),Q=(t,i)=>t.split(`
65
- `).map(s=>i(s)).join(`
66
- `),ve=t=>{const i=(r,u)=>{const n=r.label??String(r.value);return u==="disabled"?`${e("gray",Y)} ${Q(n,a=>e(["strikethrough","gray"],a))}${r.hint?` ${e("dim",`(${r.hint??"disabled"})`)}`:""}`:u==="active"?`${e("cyan",et)} ${n}${r.hint?` ${e("dim",`(${r.hint})`)}`:""}`:u==="selected"?`${e("green",K)} ${Q(n,a=>e("dim",a))}${r.hint?` ${e("dim",`(${r.hint})`)}`:""}`:u==="cancelled"?`${Q(n,a=>e(["strikethrough","dim"],a))}`:u==="active-selected"?`${e("green",K)} ${n}${r.hint?` ${e("dim",`(${r.hint})`)}`:""}`:u==="submitted"?`${Q(n,a=>e("dim",a))}`:`${e("dim",Y)} ${Q(n,a=>e("dim",a))}`},s=t.required??!0;return new Kt({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValues:t.initialValues,required:s,cursorAt:t.cursorAt,validate(r){if(s&&(r===void 0||r.length===0))return`Please select at least one option.
67
- ${e("reset",e("dim",`Press ${e(["gray","bgWhite","inverse"]," space ")} to select, ${e("gray",e("bgWhite",e("inverse"," enter ")))} to submit`))}`},render(){const r=t.withGuide??T.withGuide,u=E(t.output,t.message,r?`${yt(this.state)} `:"",`${P(this.state)} `),n=`${r?`${e("gray",$)}
68
- `:""}${u}
69
- `,a=this.value??[],c=(o,l)=>{if(o.disabled)return i(o,"disabled");const d=a.includes(o.value);return l&&d?i(o,"active-selected"):d?i(o,"selected"):i(o,l?"active":"inactive")};switch(this.state){case"submit":{const o=this.options.filter(({value:d})=>a.includes(d)).map(d=>i(d,"submitted")).join(e("dim",", "))||e("dim","none"),l=E(t.output,o,r?`${e("gray",$)} `:"");return`${n}${l}`}case"cancel":{const o=this.options.filter(({value:d})=>a.includes(d)).map(d=>i(d,"cancelled")).join(e("dim",", "));if(o.trim()==="")return`${n}${e("gray",$)}`;const l=E(t.output,o,r?`${e("gray",$)} `:"");return`${n}${l}${r?`
70
- ${e("gray",$)}`:""}`}case"error":{const o=r?`${e("yellow",$)} `:"",l=this.error.split(`
71
- `).map((p,f)=>f===0?`${r?`${e("yellow",x)} `:""}${e("yellow",p)}`:` ${p}`).join(`
72
- `),d=n.split(`
73
- `).length,g=l.split(`
74
- `).length+1;return`${n}${o}${F({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:o.length,rowPadding:d+g,style:c}).join(`
75
- ${o}`)}
76
- ${l}
77
- `}default:{const o=r?`${e("cyan",$)} `:"",l=n.split(`
78
- `).length,d=r?2:1;return`${n}${o}${F({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:o.length,rowPadding:l+d,style:c}).join(`
79
- ${o}`)}
80
- ${r?e("cyan",x):""}
81
- `}}}}).prompt()},we=t=>e("dim",t),be=(t,i,s)=>{const r={hard:!0,trim:!1},u=J(t,i,r).split(`
82
- `),n=u.reduce((o,l)=>Math.max(B(l),o),0),a=u.map(s).reduce((o,l)=>Math.max(B(l),o),0),c=i-(a-n);return J(t,c,r)},Se=(t="",i="",s)=>{const r=s?.output??V.stdout,u=s?.withGuide??T.withGuide,n=s?.format??we,a=["",...be(t,X(r)-6,n).split(`
83
- `).map(n),""],c=B(i),o=Math.max(a.reduce((p,f)=>{const h=B(f);return h>p?h:p},0),c)+2,l=a.map(p=>`${e("gray",$)} ${p}${" ".repeat(o-B(p))}${e("gray",$)}`).join(`
84
- `),d=u?`${e("gray",$)}
85
- `:"",g=u?Gt:dt;r.write(`${d}${e("green",H)} ${e("reset",i)} ${e("gray",st.repeat(Math.max(o-c-1,1))+ct)}
86
- ${l}
87
- ${e("gray",g+st.repeat(o+2)+$t)}
88
- `)},Ce=t=>new qt({validate:t.validate,mask:t.mask??Et,signal:t.signal,input:t.input,output:t.output,render(){const i=t.withGuide??T.withGuide,s=`${i?`${e("gray",$)}
89
- `:""}${P(this.state)} ${t.message}
90
- `,r=this.userInputWithCursor,u=this.masked;switch(this.state){case"error":{const n=i?`${e("yellow",$)} `:"",a=i?`${e("yellow",x)} `:"",c=u??"";return t.clearOnError&&this.clear(),`${s.trim()}
91
- ${n}${c}
92
- ${a}${e("yellow",this.error)}
93
- `}case"submit":{const n=i?`${e("gray",$)} `:"",a=u?e("dim",u):"";return`${s}${n}${a}`}case"cancel":{const n=i?`${e("gray",$)} `:"",a=u?e(["strikethrough","dim"],u):"";return`${s}${n}${a}${u&&i?`
94
- ${e("gray",$)}`:""}`}default:{const n=i?`${e("cyan",$)} `:"",a=i?e("cyan",x):"";return`${s}${n}${r}
95
- ${a}
96
- `}}}}).prompt(),Ie=t=>{const i=t.validate;return At({...t,initialUserInput:t.initialValue??t.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;Qt(s)?wt(s).isDirectory()&&(!t.directory||s.endsWith("/"))?r=s:r=bt(s):r=bt(s);const u=s.length>1&&s.endsWith("/")?s.slice(0,-1):s;return Zt(r).map(n=>{const a=te(r,n),c=wt(a);return{name:n,path:a,isDirectory:c.isDirectory()}}).filter(({path:n,isDirectory:a})=>n.startsWith(u)&&(a||!t.directory)).map(n=>({value:n.path}))}catch{return[]}}})},Te=t=>e("magenta",t),ft=({indicator:t="dots",onCancel:i,output:s=process.stdout,cancelMessage:r,errorMessage:u,frames:n=tt?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:a=tt?80:120,signal:c,...o}={})=>{const l=ot();let d,g,p=!1,f=!1,h="",I,m=performance.now();const y=X(s),v=o?.styleFrame??Te,C=_=>{const A=_>1?u??T.messages.error:r??T.messages.cancel;f=_===1,p&&(W(A,_),f&&typeof i=="function"&&i())},S=()=>C(2),b=()=>C(1),G=()=>{process.on("uncaughtExceptionMonitor",S),process.on("unhandledRejection",S),process.on("SIGINT",b),process.on("SIGTERM",b),process.on("exit",C),c&&c.addEventListener("abort",b)},M=()=>{process.removeListener("uncaughtExceptionMonitor",S),process.removeListener("unhandledRejection",S),process.removeListener("SIGINT",b),process.removeListener("SIGTERM",b),process.removeListener("exit",C),c&&c.removeEventListener("abort",b)},N=()=>{if(I===void 0)return;l&&s.write(`
97
- `);const _=J(I,y,{hard:!0,trim:!1}).split(`
98
- `);_.length>1&&s.write(St.up(_.length-1)),s.write(St.to(0)),s.write(Ct.down())},O=_=>_.replace(/\.+$/,""),j=_=>{const A=(performance.now()-_)/1e3,L=Math.floor(A/60),D=Math.floor(A%60);return L>0?`[${L}m ${D}s]`:`[${D}s]`},k=o.withGuide??T.withGuide,rt=(_="")=>{p=!0,d=Jt({output:s}),h=O(_),m=performance.now(),k&&s.write(`${e("gray",$)}
99
- `);let A=0,L=0;G(),g=setInterval(()=>{if(l&&h===I)return;N(),I=h;const D=v(n[A]);let Z;if(l)Z=`${D} ${h}...`;else if(t==="timer")Z=`${D} ${h} ${j(m)}`;else{const kt=".".repeat(Math.floor(L)).slice(0,3);Z=`${D} ${h}${kt}`}const Bt=J(Z,y,{hard:!0,trim:!1});s.write(Bt),A=A+1<n.length?A+1:0,L=L<4?L+.125:0},a)},W=(_="",A=0,L=!1)=>{if(!p)return;p=!1,clearInterval(g),N();const D=A===0?e("green",H):A===1?e("red",at):e("red",ut);h=_??h,L||(t==="timer"?s.write(`${D} ${h} ${j(m)}
100
- `):s.write(`${D} ${h}
101
- `)),M(),d()};return{start:rt,stop:(_="")=>W(_,0),message:(_="")=>{h=O(_??h)},cancel:(_="")=>W(_,1),error:(_="")=>W(_,2),clear:()=>W("",0,!0),get isCancelled(){return f}}},jt={light:w("\u2500","-"),heavy:w("\u2501","="),block:w("\u2588","#")};function _e({style:t="heavy",max:i=100,size:s=40,...r}={}){const u=ft(r);let n=0,a="";const c=Math.max(1,i),o=Math.max(1,s),l=f=>{switch(f){case"initial":case"active":return h=>e("magenta",h);case"error":case"cancel":return h=>e("red",h);case"submit":return h=>e("green",h);default:return h=>e("magenta",h)}},d=(f,h)=>{const I=Math.floor(n/c*o);return`${l(f)(jt[t].repeat(I))}${e("dim",jt[t].repeat(o-I))} ${h}`},g=(f="")=>{a=f,u.start(d("initial",f))},p=(f=1,h)=>{n=Math.min(c,f+n),u.message(d("active",h??a)),a=h??a};return{start:g,stop:u.stop,cancel:u.cancel,error:u.error,clear:u.clear,advance:p,isCancelled:u.isCancelled,message:f=>p(0,f)}}const it=(t,i)=>t.includes(`
102
- `)?t.split(`
103
- `).map(s=>i(s)).join(`
104
- `):i(t),xe=t=>{const i=(s,r)=>{const u=s.label??String(s.value);switch(r){case"disabled":return`${e("gray",U)} ${it(u,n=>e("gray",n))}${s.hint?` ${e("dim",`(${s.hint??"disabled"})`)}`:""}`;case"selected":return`${it(u,n=>e("dim",n))}`;case"active":return`${e("green",z)} ${u}${s.hint?` ${e("dim",`(${s.hint})`)}`:""}`;case"cancelled":return`${it(u,n=>e(["strikethrough","dim"],n))}`;default:return`${e("dim",U)} ${it(u,n=>e("dim",n))}`}};return new Yt({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,render(){const s=t.withGuide??T.withGuide,r=`${P(this.state)} `,u=`${yt(this.state)} `,n=E(t.output,t.message,u,r),a=`${s?`${e("gray",$)}
105
- `:""}${n}
106
- `;switch(this.state){case"submit":{const c=s?`${e("gray",$)} `:"",o=E(t.output,i(this.options[this.cursor],"selected"),c);return`${a}${o}`}case"cancel":{const c=s?`${e("gray",$)} `:"",o=E(t.output,i(this.options[this.cursor],"cancelled"),c);return`${a}${o}${s?`
107
- ${e("gray",$)}`:""}`}default:{const c=s?`${e("cyan",$)} `:"",o=s?e("cyan",x):"",l=a.split(`
108
- `).length,d=s?2:1;return`${a}${c}${F({output:t.output,cursor:this.cursor,options:this.options,maxItems:t.maxItems,columnPadding:c.length,rowPadding:l+d,style:(g,p)=>i(g,g.disabled?"disabled":p?"active":"inactive")}).join(`
109
- ${c}`)}
110
- ${o}
111
- `}}}}).prompt()},Ee=t=>{const i=(s,r="inactive")=>{const u=s.label??String(s.value);return r==="selected"?`${e("dim",u)}`:r==="cancelled"?`${e(["strikethrough","dim"],u)}`:r==="active"?`${e(["bgCyan","gray"],` ${s.value} `)} ${u}${s.hint?` ${e("dim",`(${s.hint})`)}`:""}`:`${e(["gray","bgWhite","inverse"],` ${s.value} `)} ${u}${s.hint?` ${e("dim",`(${s.hint})`)}`:""}`};return new Xt({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,caseSensitive:t.caseSensitive,render(){const s=t.withGuide??T.withGuide,r=`${s?`${e("gray",$)}
112
- `:""}${P(this.state)} ${t.message}
113
- `;switch(this.state){case"submit":{const u=s?`${e("gray",$)} `:"",n=this.options.find(c=>c.value===this.value)??t.options[0],a=E(t.output,i(n,"selected"),u);return`${r}${a}`}case"cancel":{const u=s?`${e("gray",$)} `:"",n=E(t.output,i(this.options[0],"cancelled"),u);return`${r}${n}${s?`
114
- ${e("gray",$)}`:""}`}default:{const u=s?`${e("cyan",$)} `:"",n=s?e("cyan",x):"",a=this.options.map((c,o)=>E(t.output,i(c,o===this.cursor?"active":"inactive"),u)).join(`
115
- `);return`${r}${a}
625
+ `);
626
+ },
627
+ info: (s, e) => {
628
+ log.message(s, { ...e, symbol: styleText("blue", S_INFO) });
629
+ },
630
+ success: (s, e) => {
631
+ log.message(s, { ...e, symbol: styleText("green", S_SUCCESS) });
632
+ },
633
+ step: (s, e) => {
634
+ log.message(s, { ...e, symbol: styleText("green", S_STEP_SUBMIT) });
635
+ },
636
+ warn: (s, e) => {
637
+ log.message(s, { ...e, symbol: styleText("yellow", S_WARN) });
638
+ },
639
+ /** alias for `log.warn()`. */
640
+ warning: (s, e) => {
641
+ log.warn(s, e);
642
+ },
643
+ error: (s, e) => {
644
+ log.message(s, { ...e, symbol: styleText("red", S_ERROR) });
645
+ }
646
+ };
647
+
648
+ const cancel = (o = "", t) => {
649
+ const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_END)} ` : "";
650
+ i.write(`${e}${styleText("red", o)}
651
+
652
+ `);
653
+ }, intro = (o = "", t) => {
654
+ const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_START)} ` : "";
655
+ i.write(`${e}${o}
656
+ `);
657
+ }, outro = (o = "", t) => {
658
+ const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR)}
659
+ ${styleText("gray", S_BAR_END)} ` : "";
660
+ i.write(`${e}${o}
661
+
662
+ `);
663
+ };
664
+
665
+ const multiline = (e) => new MultiLinePrompt({
666
+ validate: e.validate,
667
+ placeholder: e.placeholder,
668
+ defaultValue: e.defaultValue,
669
+ initialValue: e.initialValue,
670
+ showSubmit: e.showSubmit,
671
+ output: e.output,
672
+ signal: e.signal,
673
+ input: e.input,
674
+ render() {
675
+ const i = e?.withGuide ?? settings.withGuide, o = `${`${i ? `${styleText("gray", S_BAR)}
676
+ ` : ""}${symbol(this.state)} `}${e.message}
677
+ `, h = e.placeholder ? styleText("inverse", e.placeholder[0]) + styleText("dim", e.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), a = this.userInput ? this.userInputWithCursor : h, s = this.value ?? "", c = e.showSubmit ? `
678
+ ${styleText(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
679
+ switch (this.state) {
680
+ case "error": {
681
+ const n = `${styleText("yellow", S_BAR)} `, r = i ? wrapTextWithPrefix(e.output, a, n, void 0) : a, u = styleText("yellow", S_BAR_END);
682
+ return `${o}${r}
683
+ ${u} ${styleText("yellow", this.error)}${c}
684
+ `;
685
+ }
686
+ case "submit": {
687
+ const n = `${styleText("gray", S_BAR)} `, r = i ? wrapTextWithPrefix(
688
+ e.output,
689
+ s,
690
+ n,
691
+ void 0,
692
+ void 0,
693
+ (u) => styleText("dim", u)
694
+ ) : s ? styleText("dim", s) : "";
695
+ return `${o}${r}`;
696
+ }
697
+ case "cancel": {
698
+ const n = `${styleText("gray", S_BAR)} `, r = i ? wrapTextWithPrefix(
699
+ e.output,
700
+ s,
701
+ n,
702
+ void 0,
703
+ void 0,
704
+ (u) => styleText(["strikethrough", "dim"], u)
705
+ ) : s ? styleText(["strikethrough", "dim"], s) : "";
706
+ return `${o}${r}`;
707
+ }
708
+ default: {
709
+ const n = i ? `${styleText("cyan", S_BAR)} ` : "", r = i ? styleText("cyan", S_BAR_END) : "", u = i ? wrapTextWithPrefix(e.output, a, n) : a;
710
+ return `${o}${u}
711
+ ${r}${c}
712
+ `;
713
+ }
714
+ }
715
+ }
716
+ }).prompt();
717
+
718
+ const d = (n, a) => n.split(`
719
+ `).map((m) => a(m)).join(`
720
+ `);
721
+ const multiselect = (n) => {
722
+ const a = (t, o) => {
723
+ const r = t.label ?? String(t.value);
724
+ return o === "disabled" ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText(["strikethrough", "gray"], l))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}` : o === "active" ? `${styleText("cyan", S_CHECKBOX_ACTIVE)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${d(r, (l) => styleText("dim", l))}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "cancelled" ? `${d(r, (l) => styleText(["strikethrough", "dim"], l))}` : o === "active-selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "submitted" ? `${d(r, (l) => styleText("dim", l))}` : `${styleText("dim", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText("dim", l))}`;
725
+ }, m = n.required ?? true;
726
+ return new MultiSelectPrompt({
727
+ options: n.options,
728
+ signal: n.signal,
729
+ input: n.input,
730
+ output: n.output,
731
+ initialValues: n.initialValues,
732
+ required: m,
733
+ cursorAt: n.cursorAt,
734
+ validate(t) {
735
+ if (m && (t === void 0 || t.length === 0))
736
+ return `Please select at least one option.
737
+ ${styleText(
738
+ "reset",
739
+ styleText(
740
+ "dim",
741
+ `Press ${styleText(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText(
742
+ "gray",
743
+ styleText("bgWhite", styleText("inverse", " enter "))
744
+ )} to submit`
745
+ )
746
+ )}`;
747
+ },
748
+ render() {
749
+ const t = n.withGuide ?? settings.withGuide, o = wrapTextWithPrefix(
750
+ n.output,
751
+ n.message,
752
+ t ? `${symbolBar(this.state)} ` : "",
753
+ `${symbol(this.state)} `
754
+ ), r = `${t ? `${styleText("gray", S_BAR)}
755
+ ` : ""}${o}
756
+ `, l = this.value ?? [], g = (i, u) => {
757
+ if (i.disabled)
758
+ return a(i, "disabled");
759
+ const s = l.includes(i.value);
760
+ return u && s ? a(i, "active-selected") : s ? a(i, "selected") : a(i, u ? "active" : "inactive");
761
+ };
762
+ switch (this.state) {
763
+ case "submit": {
764
+ const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), u = wrapTextWithPrefix(
765
+ n.output,
766
+ i,
767
+ t ? `${styleText("gray", S_BAR)} ` : ""
768
+ );
769
+ return `${r}${u}`;
770
+ }
771
+ case "cancel": {
772
+ const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "cancelled")).join(styleText("dim", ", "));
773
+ if (i.trim() === "")
774
+ return `${r}${styleText("gray", S_BAR)}`;
775
+ const u = wrapTextWithPrefix(
776
+ n.output,
777
+ i,
778
+ t ? `${styleText("gray", S_BAR)} ` : ""
779
+ );
780
+ return `${r}${u}${t ? `
781
+ ${styleText("gray", S_BAR)}` : ""}`;
782
+ }
783
+ case "error": {
784
+ const i = t ? `${styleText("yellow", S_BAR)} ` : "", u = this.error.split(`
785
+ `).map(
786
+ (h, x) => x === 0 ? `${t ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", h)}` : ` ${h}`
787
+ ).join(`
788
+ `), s = r.split(`
789
+ `).length, v = u.split(`
790
+ `).length + 1;
791
+ return `${r}${i}${limitOptions({
792
+ output: n.output,
793
+ options: this.options,
794
+ cursor: this.cursor,
795
+ maxItems: n.maxItems,
796
+ columnPadding: i.length,
797
+ rowPadding: s + v,
798
+ style: g
799
+ }).join(`
800
+ ${i}`)}
801
+ ${u}
802
+ `;
803
+ }
804
+ default: {
805
+ const i = t ? `${styleText("cyan", S_BAR)} ` : "", u = r.split(`
806
+ `).length, s = t ? 2 : 1;
807
+ return `${r}${i}${limitOptions({
808
+ output: n.output,
809
+ options: this.options,
810
+ cursor: this.cursor,
811
+ maxItems: n.maxItems,
812
+ columnPadding: i.length,
813
+ rowPadding: u + s,
814
+ style: g
815
+ }).join(`
816
+ ${i}`)}
817
+ ${t ? styleText("cyan", S_BAR_END) : ""}
818
+ `;
819
+ }
820
+ }
821
+ }
822
+ }).prompt();
823
+ };
824
+
825
+ const W$1 = (o) => styleText("dim", o), C = (o, e, s) => {
826
+ const a = {
827
+ hard: true,
828
+ trim: false
829
+ }, i = wrapAnsi(o, e, a).split(`
830
+ `), c = i.reduce((n, r) => Math.max(l(r), n), 0), u = i.map(s).reduce((n, r) => Math.max(l(r), n), 0), g = e - (u - c);
831
+ return wrapAnsi(o, g, a);
832
+ };
833
+ const note = (o = "", e = "", s) => {
834
+ const a = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c = s?.format ?? W$1, g = ["", ...C(o, getColumns(a) - 6, c).split(`
835
+ `).map(c), ""], n = l(e), r = Math.max(
836
+ g.reduce((m, F) => {
837
+ const O = l(F);
838
+ return O > m ? O : m;
839
+ }, 0),
840
+ n
841
+ ) + 2, h = g.map(
842
+ (m) => `${styleText("gray", S_BAR)} ${m}${" ".repeat(r - l(m))}${styleText("gray", S_BAR)}`
843
+ ).join(`
844
+ `), T = i ? `${styleText("gray", S_BAR)}
845
+ ` : "", l$1 = i ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
846
+ a.write(
847
+ `${T}${styleText("green", S_STEP_SUBMIT)} ${styleText("reset", e)} ${styleText(
848
+ "gray",
849
+ S_BAR_H.repeat(Math.max(r - n - 1, 1)) + S_CORNER_TOP_RIGHT
850
+ )}
851
+ ${h}
852
+ ${styleText("gray", l$1 + S_BAR_H.repeat(r + 2) + S_CORNER_BOTTOM_RIGHT)}
853
+ `
854
+ );
855
+ };
856
+
857
+ const password = (r) => new PasswordPrompt({
858
+ validate: r.validate,
859
+ mask: r.mask ?? S_PASSWORD_MASK,
860
+ signal: r.signal,
861
+ input: r.input,
862
+ output: r.output,
863
+ render() {
864
+ const e = r.withGuide ?? settings.withGuide, o = `${e ? `${styleText("gray", S_BAR)}
865
+ ` : ""}${symbol(this.state)} ${r.message}
866
+ `, c = this.userInputWithCursor, i = this.masked;
867
+ switch (this.state) {
868
+ case "error": {
869
+ const s = e ? `${styleText("yellow", S_BAR)} ` : "", n = e ? `${styleText("yellow", S_BAR_END)} ` : "", l = i ?? "";
870
+ return r.clearOnError && this.clear(), `${o.trim()}
871
+ ${s}${l}
872
+ ${n}${styleText("yellow", this.error)}
873
+ `;
874
+ }
875
+ case "submit": {
876
+ const s = e ? `${styleText("gray", S_BAR)} ` : "", n = i ? styleText("dim", i) : "";
877
+ return `${o}${s}${n}`;
878
+ }
879
+ case "cancel": {
880
+ const s = e ? `${styleText("gray", S_BAR)} ` : "", n = i ? styleText(["strikethrough", "dim"], i) : "";
881
+ return `${o}${s}${n}${i && e ? `
882
+ ${styleText("gray", S_BAR)}` : ""}`;
883
+ }
884
+ default: {
885
+ const s = e ? `${styleText("cyan", S_BAR)} ` : "", n = e ? styleText("cyan", S_BAR_END) : "";
886
+ return `${o}${s}${c}
116
887
  ${n}
117
- `}}}}).prompt()},Nt=`${e("gray",$)} `,q={message:async(t,{symbol:i=e("gray",$)}={})=>{process.stdout.write(`${e("gray",$)}
118
- ${i} `);let s=3;for await(let r of t){r=r.replace(/\n/g,`
119
- ${Nt}`),r.includes(`
120
- `)&&(s=3+nt(r.slice(r.lastIndexOf(`
121
- `))).length);const u=nt(r).length;s+u<process.stdout.columns?(s+=u,process.stdout.write(r)):(process.stdout.write(`
122
- ${Nt}${r.trimStart()}`),s=3+nt(r.trimStart()).length)}process.stdout.write(`
123
- `)},info:t=>q.message(t,{symbol:e("blue",ht)}),success:t=>q.message(t,{symbol:e("green",pt)}),step:t=>q.message(t,{symbol:e("green",H)}),warn:t=>q.message(t,{symbol:e("yellow",mt)}),warning:t=>q.warn(t),error:t=>q.message(t,{symbol:e("red",gt)})},Ge=async(t,i)=>{for(const s of t){if(s.enabled===!1)continue;const r=ft(i);r.start(s.title);const u=await s.task(r.message);r.stop(u||s.title)}},Me=t=>t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,""),Oe=t=>{const i=t.output??process.stdout,s=X(i),r=e("gray",$),u=t.spacing??1,n=3,a=t.retainLog===!0,c=!ot()&&It(i);i.write(`${r}
124
- `),i.write(`${e("green",H)} ${t.title}
125
- `);for(let m=0;m<u;m++)i.write(`${r}
126
- `);const o=[{value:"",full:""}];let l=!1;const d=m=>{if(o.length===0)return;let y=0;m&&(y+=u+2);for(const v of o){const{value:C,result:S}=v;let b=S?.message??C;if(b.length===0)continue;S===void 0&&v.header!==void 0&&v.header!==""&&(b+=`
127
- ${v.header}`);const G=b.split(`
128
- `).reduce((M,N)=>N===""?M+1:M+Math.ceil((N.length+n)/s),0);y+=G}y>0&&(y+=1,i.write(Ct.lines(y)))},g=(m,y,v)=>{const C=v?`${m.full}
129
- ${m.value}`:m.value;m.header!==void 0&&m.header!==""&&R.message(m.header.split(`
130
- `).map(S=>e("bold",S)),{output:i,secondarySymbol:r,symbol:r,spacing:0}),R.message(C.split(`
131
- `).map(S=>e("dim",S)),{output:i,secondarySymbol:r,symbol:r,spacing:y??u})},p=()=>{for(const m of o){const{header:y,value:v,full:C}=m;(y===void 0||y.length===0)&&v.length===0||g(m,void 0,a===!0&&C.length>0)}},f=(m,y,v)=>{if(d(!1),(v?.raw!==!0||!l)&&m.value!==""&&(m.value+=`
132
- `),m.value+=Me(y),l=v?.raw===!0,t.limit!==void 0){const C=m.value.split(`
133
- `),S=C.length-t.limit;if(S>0){const b=C.splice(0,S);a&&(m.full+=(m.full===""?"":`
134
- `)+b.join(`
135
- `))}m.value=C.join(`
136
- `)}c&&h()},h=()=>{for(const m of o)m.result?m.result.status==="error"?R.error(m.result.message,{output:i,secondarySymbol:r,spacing:0}):R.success(m.result.message,{output:i,secondarySymbol:r,spacing:0}):m.value!==""&&g(m,0)},I=(m,y)=>{d(!1),m.result=y,c&&h()};return{message(m,y){f(o[0],m,y)},group(m){const y={header:m,value:"",full:""};return o.push(y),{message(v,C){f(y,v,C)},error(v){I(y,{status:"error",message:v})},success(v){I(y,{status:"success",message:v})}}},error(m,y){d(!0),R.error(m,{output:i,secondarySymbol:r,spacing:1}),y?.showLog!==!1&&p(),o.splice(1,o.length-1),o[0].value="",o[0].full=""},success(m,y){d(!0),R.success(m,{output:i,secondarySymbol:r,spacing:1}),y?.showLog===!0&&p(),o.splice(1,o.length-1),o[0].value="",o[0].full=""}}},Pe=t=>new zt({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,output:t.output,signal:t.signal,input:t.input,render(){const i=t?.withGuide??T.withGuide,s=`${`${i?`${e("gray",$)}
137
- `:""}${P(this.state)} `}${t.message}
138
- `,r=t.placeholder?e("inverse",t.placeholder[0])+e("dim",t.placeholder.slice(1)):e(["inverse","hidden"],"_"),u=this.userInput?this.userInputWithCursor:r,n=this.value??"";switch(this.state){case"error":{const a=this.error?` ${e("yellow",this.error)}`:"",c=i?`${e("yellow",$)} `:"",o=i?e("yellow",x):"";return`${s.trim()}
139
- ${c}${u}
140
- ${o}${a}
141
- `}case"submit":{const a=n?` ${e("dim",n)}`:"",c=i?e("gray",$):"";return`${s}${c}${a}`}case"cancel":{const a=n?` ${e(["strikethrough","dim"],n)}`:"",c=i?e("gray",$):"";return`${s}${c}${a}${n.trim()?`
142
- ${c}`:""}`}default:{const a=i?`${e("cyan",$)} `:"",c=i?e("cyan",x):"";return`${s}${a}${u}
143
- ${c}
144
- `}}}}).prompt();export{$ as S_BAR,x as S_BAR_END,xt as S_BAR_END_RIGHT,st as S_BAR_H,lt as S_BAR_START,_t as S_BAR_START_RIGHT,et as S_CHECKBOX_ACTIVE,Y as S_CHECKBOX_INACTIVE,K as S_CHECKBOX_SELECTED,Gt as S_CONNECT_LEFT,dt as S_CORNER_BOTTOM_LEFT,$t as S_CORNER_BOTTOM_RIGHT,Mt as S_CORNER_TOP_LEFT,ct as S_CORNER_TOP_RIGHT,gt as S_ERROR,ht as S_INFO,Et as S_PASSWORD_MASK,z as S_RADIO_ACTIVE,U as S_RADIO_INACTIVE,Tt as S_STEP_ACTIVE,at as S_STEP_CANCEL,ut as S_STEP_ERROR,H as S_STEP_SUBMIT,pt as S_SUCCESS,mt as S_WARN,At as autocomplete,ie as autocompleteMultiselect,ae as box,me as cancel,ue as confirm,le as date,he as group,pe as groupMultiselect,ge as intro,ot as isCI,It as isTTY,F as limitOptions,R as log,fe as multiline,ve as multiselect,Se as note,ye as outro,Ce as password,Ie as path,_e as progress,xe as select,Ee as selectKey,ft as spinner,q as stream,P as symbol,yt as symbolBar,Oe as taskLog,Ge as tasks,Pe as text,tt as unicode,w as unicodeOr};
145
- //# sourceMappingURL=index.mjs.map
888
+ `;
889
+ }
890
+ }
891
+ }
892
+ }).prompt();
893
+
894
+ const path = (e) => {
895
+ const a = e.validate;
896
+ return autocomplete({
897
+ ...e,
898
+ initialUserInput: e.initialValue ?? e.root ?? process.cwd(),
899
+ maxItems: 5,
900
+ validate(t) {
901
+ if (!Array.isArray(t)) {
902
+ if (!t)
903
+ return "Please select a path";
904
+ if (a)
905
+ return runValidation(a, t);
906
+ }
907
+ },
908
+ options() {
909
+ const t = this.userInput;
910
+ if (t === "")
911
+ return [];
912
+ try {
913
+ let i;
914
+ existsSync(t) ? lstatSync(t).isDirectory() && (!e.directory || t.endsWith("/")) ? i = t : i = dirname(t) : i = dirname(t);
915
+ const c = t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t;
916
+ return readdirSync(i).map((r) => {
917
+ const n = join(i, r), m = lstatSync(n);
918
+ return {
919
+ name: r,
920
+ path: n,
921
+ isDirectory: m.isDirectory()
922
+ };
923
+ }).filter(
924
+ ({ path: r, isDirectory: n }) => r.startsWith(c) && (n || !e.directory)
925
+ ).map((r) => ({
926
+ value: r.path
927
+ }));
928
+ } catch {
929
+ return [];
930
+ }
931
+ }
932
+ });
933
+ };
934
+
935
+ const W = (l) => styleText("magenta", l);
936
+ const spinner = ({
937
+ indicator: l = "dots",
938
+ onCancel: h,
939
+ output: n = process.stdout,
940
+ cancelMessage: G,
941
+ errorMessage: O,
942
+ frames: E = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
943
+ delay: F = unicode ? 80 : 120,
944
+ signal: m,
945
+ ...I
946
+ } = {}) => {
947
+ const u = isCI();
948
+ let M, T, d = false, S = false, s = "", p, w = performance.now();
949
+ const x = getColumns(n), k = I?.styleFrame ?? W, g = (e) => {
950
+ const r = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
951
+ S = e === 1, d && (a(r, e), S && typeof h == "function" && h());
952
+ }, f = () => g(2), i = () => g(1), A = () => {
953
+ process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i), process.on("SIGTERM", i), process.on("exit", g), m && m.addEventListener("abort", i);
954
+ }, H = () => {
955
+ process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g), m && m.removeEventListener("abort", i);
956
+ }, y = () => {
957
+ if (p === void 0) return;
958
+ u && n.write(`
959
+ `);
960
+ const r = wrapAnsi(p, x, {
961
+ hard: true,
962
+ trim: false
963
+ }).split(`
964
+ `);
965
+ r.length > 1 && n.write(cursor.up(r.length - 1)), n.write(cursor.to(0)), n.write(erase.down());
966
+ }, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
967
+ const r = (performance.now() - e) / 1e3, t = Math.floor(r / 60), o = Math.floor(r % 60);
968
+ return t > 0 ? `[${t}m ${o}s]` : `[${o}s]`;
969
+ }, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
970
+ d = true, M = block({ output: n }), s = C(e), w = performance.now(), N && n.write(`${styleText("gray", S_BAR)}
971
+ `);
972
+ let r = 0, t = 0;
973
+ A(), T = setInterval(() => {
974
+ if (u && s === p)
975
+ return;
976
+ y(), p = s;
977
+ const o = k(E[r]);
978
+ let v;
979
+ if (u)
980
+ v = `${o} ${s}...`;
981
+ else if (l === "timer")
982
+ v = `${o} ${s} ${_(w)}`;
983
+ else {
984
+ const B = ".".repeat(Math.floor(t)).slice(0, 3);
985
+ v = `${o} ${s}${B}`;
986
+ }
987
+ const j = wrapAnsi(v, x, {
988
+ hard: true,
989
+ trim: false
990
+ });
991
+ n.write(j), r = r + 1 < E.length ? r + 1 : 0, t = t < 4 ? t + 0.125 : 0;
992
+ }, F);
993
+ }, a = (e = "", r = 0, t = false) => {
994
+ if (!d) return;
995
+ d = false, clearInterval(T), y();
996
+ const o = r === 0 ? styleText("green", S_STEP_SUBMIT) : r === 1 ? styleText("red", S_STEP_CANCEL) : styleText("red", S_STEP_ERROR);
997
+ s = e ?? s, t || (l === "timer" ? n.write(`${o} ${s} ${_(w)}
998
+ `) : n.write(`${o} ${s}
999
+ `)), H(), M();
1000
+ };
1001
+ return {
1002
+ start: P,
1003
+ stop: (e = "") => a(e, 0),
1004
+ message: (e = "") => {
1005
+ s = C(e ?? s);
1006
+ },
1007
+ cancel: (e = "") => a(e, 1),
1008
+ error: (e = "") => a(e, 2),
1009
+ clear: () => a("", 0, true),
1010
+ get isCancelled() {
1011
+ return S;
1012
+ }
1013
+ };
1014
+ };
1015
+
1016
+ const u = {
1017
+ light: unicodeOr("\u2500", "-"),
1018
+ heavy: unicodeOr("\u2501", "="),
1019
+ block: unicodeOr("\u2588", "#")
1020
+ };
1021
+ function progress({
1022
+ style: o = "heavy",
1023
+ max: d = 100,
1024
+ size: v = 40,
1025
+ ...x
1026
+ } = {}) {
1027
+ const r = spinner(x);
1028
+ let a = 0, n = "";
1029
+ const c = Math.max(1, d), l = Math.max(1, v), S = (t) => {
1030
+ switch (t) {
1031
+ case "initial":
1032
+ case "active":
1033
+ return (e) => styleText("magenta", e);
1034
+ case "error":
1035
+ case "cancel":
1036
+ return (e) => styleText("red", e);
1037
+ case "submit":
1038
+ return (e) => styleText("green", e);
1039
+ default:
1040
+ return (e) => styleText("magenta", e);
1041
+ }
1042
+ }, p = (t, e) => {
1043
+ const m = Math.floor(a / c * l);
1044
+ return `${S(t)(u[o].repeat(m))}${styleText("dim", u[o].repeat(l - m))} ${e}`;
1045
+ }, h = (t = "") => {
1046
+ n = t, r.start(p("initial", t));
1047
+ }, g = (t = 1, e) => {
1048
+ a = Math.min(c, t + a), r.message(p("active", e ?? n)), n = e ?? n;
1049
+ };
1050
+ return {
1051
+ start: h,
1052
+ stop: r.stop,
1053
+ cancel: r.cancel,
1054
+ error: r.error,
1055
+ clear: r.clear,
1056
+ advance: g,
1057
+ isCancelled: r.isCancelled,
1058
+ message: (t) => g(0, t)
1059
+ };
1060
+ }
1061
+
1062
+ const c = (e, a) => e.includes(`
1063
+ `) ? e.split(`
1064
+ `).map((t) => a(t)).join(`
1065
+ `) : a(e);
1066
+ const select = (e) => {
1067
+ const a = (t, d) => {
1068
+ const s = t.label ?? String(t.value);
1069
+ switch (d) {
1070
+ case "disabled":
1071
+ return `${styleText("gray", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("gray", n))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}`;
1072
+ case "selected":
1073
+ return `${c(s, (n) => styleText("dim", n))}`;
1074
+ case "active":
1075
+ return `${styleText("green", S_RADIO_ACTIVE)} ${s}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}`;
1076
+ case "cancelled":
1077
+ return `${c(s, (n) => styleText(["strikethrough", "dim"], n))}`;
1078
+ default:
1079
+ return `${styleText("dim", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("dim", n))}`;
1080
+ }
1081
+ };
1082
+ return new SelectPrompt({
1083
+ options: e.options,
1084
+ signal: e.signal,
1085
+ input: e.input,
1086
+ output: e.output,
1087
+ initialValue: e.initialValue,
1088
+ render() {
1089
+ const t = e.withGuide ?? settings.withGuide, d = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n = wrapTextWithPrefix(
1090
+ e.output,
1091
+ e.message,
1092
+ s,
1093
+ d
1094
+ ), u = `${t ? `${styleText("gray", S_BAR)}
1095
+ ` : ""}${n}
1096
+ `;
1097
+ switch (this.state) {
1098
+ case "submit": {
1099
+ const r = t ? `${styleText("gray", S_BAR)} ` : "", l = wrapTextWithPrefix(
1100
+ e.output,
1101
+ a(this.options[this.cursor], "selected"),
1102
+ r
1103
+ );
1104
+ return `${u}${l}`;
1105
+ }
1106
+ case "cancel": {
1107
+ const r = t ? `${styleText("gray", S_BAR)} ` : "", l = wrapTextWithPrefix(
1108
+ e.output,
1109
+ a(this.options[this.cursor], "cancelled"),
1110
+ r
1111
+ );
1112
+ return `${u}${l}${t ? `
1113
+ ${styleText("gray", S_BAR)}` : ""}`;
1114
+ }
1115
+ default: {
1116
+ const r = t ? `${styleText("cyan", S_BAR)} ` : "", l = t ? styleText("cyan", S_BAR_END) : "", g = u.split(`
1117
+ `).length, h = t ? 2 : 1;
1118
+ return `${u}${r}${limitOptions({
1119
+ output: e.output,
1120
+ cursor: this.cursor,
1121
+ options: this.options,
1122
+ maxItems: e.maxItems,
1123
+ columnPadding: r.length,
1124
+ rowPadding: g + h,
1125
+ style: (p, b) => a(p, p.disabled ? "disabled" : b ? "active" : "inactive")
1126
+ }).join(`
1127
+ ${r}`)}
1128
+ ${l}
1129
+ `;
1130
+ }
1131
+ }
1132
+ }
1133
+ }).prompt();
1134
+ };
1135
+
1136
+ const selectKey = (t) => {
1137
+ const l = (e, a = "inactive") => {
1138
+ const n = e.label ?? String(e.value);
1139
+ return a === "selected" ? `${styleText("dim", n)}` : a === "cancelled" ? `${styleText(["strikethrough", "dim"], n)}` : a === "active" ? `${styleText(["bgCyan", "gray"], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}` : `${styleText(["gray", "bgWhite", "inverse"], ` ${e.value} `)} ${n}${e.hint ? ` ${styleText("dim", `(${e.hint})`)}` : ""}`;
1140
+ };
1141
+ return new SelectKeyPrompt({
1142
+ options: t.options,
1143
+ signal: t.signal,
1144
+ input: t.input,
1145
+ output: t.output,
1146
+ initialValue: t.initialValue,
1147
+ caseSensitive: t.caseSensitive,
1148
+ render() {
1149
+ const e = t.withGuide ?? settings.withGuide, a = `${e ? `${styleText("gray", S_BAR)}
1150
+ ` : ""}${symbol(this.state)} ${t.message}
1151
+ `;
1152
+ switch (this.state) {
1153
+ case "submit": {
1154
+ const n = e ? `${styleText("gray", S_BAR)} ` : "", s = this.options.find((u) => u.value === this.value) ?? t.options[0], c = wrapTextWithPrefix(
1155
+ t.output,
1156
+ l(s, "selected"),
1157
+ n
1158
+ );
1159
+ return `${a}${c}`;
1160
+ }
1161
+ case "cancel": {
1162
+ const n = e ? `${styleText("gray", S_BAR)} ` : "", s = wrapTextWithPrefix(
1163
+ t.output,
1164
+ l(this.options[0], "cancelled"),
1165
+ n
1166
+ );
1167
+ return `${a}${s}${e ? `
1168
+ ${styleText("gray", S_BAR)}` : ""}`;
1169
+ }
1170
+ default: {
1171
+ const n = e ? `${styleText("cyan", S_BAR)} ` : "", s = e ? styleText("cyan", S_BAR_END) : "", c = this.options.map(
1172
+ (u, $) => wrapTextWithPrefix(
1173
+ t.output,
1174
+ l(u, $ === this.cursor ? "active" : "inactive"),
1175
+ n
1176
+ )
1177
+ ).join(`
1178
+ `);
1179
+ return `${a}${c}
1180
+ ${s}
1181
+ `;
1182
+ }
1183
+ }
1184
+ }
1185
+ }).prompt();
1186
+ };
1187
+
1188
+ const i = `${styleText("gray", S_BAR)} `;
1189
+ const stream = {
1190
+ message: async (e, { symbol: l = styleText("gray", S_BAR) } = {}) => {
1191
+ process.stdout.write(`${styleText("gray", S_BAR)}
1192
+ ${l} `);
1193
+ let s = 3;
1194
+ for await (let r of e) {
1195
+ r = r.replace(/\n/g, `
1196
+ ${i}`), r.includes(`
1197
+ `) && (s = 3 + stripVTControlCharacters(r.slice(r.lastIndexOf(`
1198
+ `))).length);
1199
+ const o = stripVTControlCharacters(r).length;
1200
+ s + o < process.stdout.columns ? (s += o, process.stdout.write(r)) : (process.stdout.write(`
1201
+ ${i}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length);
1202
+ }
1203
+ process.stdout.write(`
1204
+ `);
1205
+ },
1206
+ info: (e) => stream.message(e, { symbol: styleText("blue", S_INFO) }),
1207
+ success: (e) => stream.message(e, { symbol: styleText("green", S_SUCCESS) }),
1208
+ step: (e) => stream.message(e, { symbol: styleText("green", S_STEP_SUBMIT) }),
1209
+ warn: (e) => stream.message(e, { symbol: styleText("yellow", S_WARN) }),
1210
+ /** alias for `log.warn()`. */
1211
+ warning: (e) => stream.warn(e),
1212
+ error: (e) => stream.message(e, { symbol: styleText("red", S_ERROR) })
1213
+ };
1214
+
1215
+ const tasks = async (o, e) => {
1216
+ for (const t of o) {
1217
+ if (t.enabled === false) continue;
1218
+ const s = spinner(e);
1219
+ s.start(t.title);
1220
+ const n = await t.task(s.message);
1221
+ s.stop(n || t.title);
1222
+ }
1223
+ };
1224
+
1225
+ const A = (l) => l.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "");
1226
+ const taskLog = (l) => {
1227
+ const r = l.output ?? process.stdout, O = getColumns(r), i = styleText("gray", S_BAR), p = l.spacing ?? 1, k = 3, m = l.retainLog === true, d = !isCI() && isTTY(r);
1228
+ r.write(`${i}
1229
+ `), r.write(`${styleText("green", S_STEP_SUBMIT)} ${l.title}
1230
+ `);
1231
+ for (let e = 0; e < p; e++)
1232
+ r.write(`${i}
1233
+ `);
1234
+ const n = [
1235
+ {
1236
+ value: "",
1237
+ full: ""
1238
+ }
1239
+ ];
1240
+ let v = false;
1241
+ const f = (e) => {
1242
+ if (n.length === 0)
1243
+ return;
1244
+ let s = 0;
1245
+ e && (s += p + 2);
1246
+ for (const t of n) {
1247
+ const { value: o, result: a } = t;
1248
+ let g = a?.message ?? o;
1249
+ if (g.length === 0)
1250
+ continue;
1251
+ a === void 0 && t.header !== void 0 && t.header !== "" && (g += `
1252
+ ${t.header}`);
1253
+ const x = g.split(`
1254
+ `).reduce((b, w) => w === "" ? b + 1 : b + Math.ceil((w.length + k) / O), 0);
1255
+ s += x;
1256
+ }
1257
+ s > 0 && (s += 1, r.write(erase.lines(s)));
1258
+ }, h = (e, s, t) => {
1259
+ const o = t ? `${e.full}
1260
+ ${e.value}` : e.value;
1261
+ e.header !== void 0 && e.header !== "" && log.message(
1262
+ e.header.split(`
1263
+ `).map((a) => styleText("bold", a)),
1264
+ {
1265
+ output: r,
1266
+ secondarySymbol: i,
1267
+ symbol: i,
1268
+ spacing: 0
1269
+ }
1270
+ ), log.message(
1271
+ o.split(`
1272
+ `).map((a) => styleText("dim", a)),
1273
+ {
1274
+ output: r,
1275
+ secondarySymbol: i,
1276
+ symbol: i,
1277
+ spacing: s ?? p
1278
+ }
1279
+ );
1280
+ }, T = () => {
1281
+ for (const e of n) {
1282
+ const { header: s, value: t, full: o } = e;
1283
+ (s === void 0 || s.length === 0) && t.length === 0 || h(e, void 0, m === true && o.length > 0);
1284
+ }
1285
+ }, L = (e, s, t) => {
1286
+ if (f(false), (t?.raw !== true || !v) && e.value !== "" && (e.value += `
1287
+ `), e.value += A(s), v = t?.raw === true, l.limit !== void 0) {
1288
+ const o = e.value.split(`
1289
+ `), a = o.length - l.limit;
1290
+ if (a > 0) {
1291
+ const g = o.splice(0, a);
1292
+ m && (e.full += (e.full === "" ? "" : `
1293
+ `) + g.join(`
1294
+ `));
1295
+ }
1296
+ e.value = o.join(`
1297
+ `);
1298
+ }
1299
+ d && y();
1300
+ }, y = () => {
1301
+ for (const e of n)
1302
+ e.result ? e.result.status === "error" ? log.error(e.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : log.success(e.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : e.value !== "" && h(e, 0);
1303
+ }, B = (e, s) => {
1304
+ f(false), e.result = s, d && y();
1305
+ };
1306
+ return {
1307
+ message(e, s) {
1308
+ L(n[0], e, s);
1309
+ },
1310
+ group(e) {
1311
+ const s = {
1312
+ header: e,
1313
+ value: "",
1314
+ full: ""
1315
+ };
1316
+ return n.push(s), {
1317
+ message(t, o) {
1318
+ L(s, t, o);
1319
+ },
1320
+ error(t) {
1321
+ B(s, {
1322
+ status: "error",
1323
+ message: t
1324
+ });
1325
+ },
1326
+ success(t) {
1327
+ B(s, {
1328
+ status: "success",
1329
+ message: t
1330
+ });
1331
+ }
1332
+ };
1333
+ },
1334
+ error(e, s) {
1335
+ f(true), log.error(e, { output: r, secondarySymbol: i, spacing: 1 }), s?.showLog !== false && T(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
1336
+ },
1337
+ success(e, s) {
1338
+ f(true), log.success(e, { output: r, secondarySymbol: i, spacing: 1 }), s?.showLog === true && T(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
1339
+ }
1340
+ };
1341
+ };
1342
+
1343
+ const text = (t) => new TextPrompt({
1344
+ validate: t.validate,
1345
+ placeholder: t.placeholder,
1346
+ defaultValue: t.defaultValue,
1347
+ initialValue: t.initialValue,
1348
+ output: t.output,
1349
+ signal: t.signal,
1350
+ input: t.input,
1351
+ render() {
1352
+ const i = t?.withGuide ?? settings.withGuide, s = `${`${i ? `${styleText("gray", S_BAR)}
1353
+ ` : ""}${symbol(this.state)} `}${t.message}
1354
+ `, c = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : c, a = this.value ?? "";
1355
+ switch (this.state) {
1356
+ case "error": {
1357
+ const n = this.error ? ` ${styleText("yellow", this.error)}` : "", r = i ? `${styleText("yellow", S_BAR)} ` : "", d = i ? styleText("yellow", S_BAR_END) : "";
1358
+ return `${s.trim()}
1359
+ ${r}${o}
1360
+ ${d}${n}
1361
+ `;
1362
+ }
1363
+ case "submit": {
1364
+ const n = a ? ` ${styleText("dim", a)}` : "", r = i ? styleText("gray", S_BAR) : "";
1365
+ return `${s}${r}${n}`;
1366
+ }
1367
+ case "cancel": {
1368
+ const n = a ? ` ${styleText(["strikethrough", "dim"], a)}` : "", r = i ? styleText("gray", S_BAR) : "";
1369
+ return `${s}${r}${n}${a.trim() ? `
1370
+ ${r}` : ""}`;
1371
+ }
1372
+ default: {
1373
+ const n = i ? `${styleText("cyan", S_BAR)} ` : "", r = i ? styleText("cyan", S_BAR_END) : "";
1374
+ return `${s}${n}${o}
1375
+ ${r}
1376
+ `;
1377
+ }
1378
+ }
1379
+ }
1380
+ }).prompt();
1381
+
1382
+ 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, multiline, multiselect, note, outro, password, path, progress, select, selectKey, spinner, stream, symbol, symbolBar, taskLog, tasks, text, unicode, unicodeOr };