void 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/AGENTS_TEMPLATE.md +1 -1
  2. package/dist/{account-cmd-C84Ee8cO.mjs → account-cmd-vJhh5lrb.mjs} +5 -5
  3. package/dist/{auth-CSkdO2Bb.mjs → auth-CQkSDS50.mjs} +22 -49
  4. package/dist/auth-DX3JURcX.mjs +2 -0
  5. package/dist/{auth-link-CioEg6uY.mjs → auth-link-D75t9wO2.mjs} +5 -5
  6. package/dist/{auth-router-BsR981d4.mjs → auth-router-ClfhL1J7.mjs} +7 -7
  7. package/dist/{build-cmd-LzvNJORH.mjs → build-cmd-zMi1iFnS.mjs} +6 -6
  8. package/dist/{cache-C4MvnrMH.mjs → cache-ZtQmyxVV.mjs} +5 -5
  9. package/dist/{cancel-deploy-abUxpP2n.mjs → cancel-deploy-Box0kkEV.mjs} +5 -5
  10. package/dist/{cf-access-P0iZnu0q.mjs → cf-access-BGe5sWXF.mjs} +4 -48
  11. package/dist/{cf-access-DRsQRe6k.mjs → cf-access-TWNzXltp.mjs} +3 -11
  12. package/dist/cli/cli.mjs +47 -44
  13. package/dist/cli/cloudflare-operation-process.mjs +14 -5
  14. package/dist/cli/env-schema-probe.mjs +3 -3
  15. package/dist/client-B9UBI03V.mjs +2 -0
  16. package/dist/{client-RV8NVeB8.mjs → client-DKAsFA4X.mjs} +33 -15
  17. package/dist/{cloudflare-cmd-BcrVyTmJ.mjs → cloudflare-cmd-CmY8dGkd.mjs} +1 -1
  18. package/dist/{cloudflare-connect-B8uPZ4nx.mjs → cloudflare-connect-IiR3ZieC.mjs} +1 -1
  19. package/dist/{cloudflare-operations-AiWashgg.mjs → cloudflare-operations-BCdXSsmo.mjs} +1 -1
  20. package/dist/{cloudflare-operations-fxHb-byx.mjs → cloudflare-operations-DzH-A966.mjs} +1 -1
  21. package/dist/{connect-Bd4kJd9U.mjs → connect-B-usTnlF.mjs} +9 -9
  22. package/dist/{create-project-bMf6ffLZ.mjs → create-project-CYOOAYcn.mjs} +12 -12
  23. package/dist/{create-project-Boczwj5r.mjs → create-project-FWbf5Olo.mjs} +1 -1
  24. package/dist/{db-8uG64XLl.mjs → db-Ck2eZ2iB.mjs} +15 -15
  25. package/dist/{delete-NvbiyeJf.mjs → delete-sK56qtzZ.mjs} +5 -5
  26. package/dist/{deploy-DzAIwqNU.mjs → deploy-gCVaiJbS.mjs} +86 -44
  27. package/dist/{deploy-bjXdFCtn.mjs → deploy-irP5q0-x.mjs} +1 -1
  28. package/dist/{domain-y5Tvydvo.mjs → domain-DFfQE8jg.mjs} +6 -6
  29. package/dist/{email-B3umsW75.mjs → email-CdnhUHvJ.mjs} +7 -7
  30. package/dist/{env-BS6qYHDb.mjs → env-DmGdHi5i.mjs} +8 -8
  31. package/dist/{env-types-C2_bIk_b.mjs → env-types-D5kds_OZ.mjs} +1 -1
  32. package/dist/{env-validation-BPn7vk-V.mjs → env-validation-C_8tPdhs.mjs} +2 -2
  33. package/dist/{env-validation-DbTg7-ar.mjs → env-validation-zZOCcQVZ.mjs} +1 -1
  34. package/dist/{gen-B580--vC.mjs → gen-CshAkukR.mjs} +2 -2
  35. package/dist/gen-DvQTWzDU.mjs +2 -0
  36. package/dist/{github-cmd-v45BdfKX.mjs → github-cmd-DftuEvIt.mjs} +13 -13
  37. package/dist/{headers-DWi2IXWx.mjs → headers-2rKda9Y6.mjs} +1 -1
  38. package/dist/{help-daGKjXGk.mjs → help-Dotbf6iz.mjs} +8 -4
  39. package/dist/help-mabuIV98.mjs +2 -0
  40. package/dist/{inbound-aVHEUhKo.mjs → inbound-fRkqcXaC.mjs} +1 -1
  41. package/dist/index.mjs +16 -20
  42. package/dist/{init-Bvy7zrBo.mjs → init-BTQEZZGJ.mjs} +25 -22
  43. package/dist/{link-CDqqCjFl.mjs → link-B46sYH0K.mjs} +6 -6
  44. package/dist/{list-CZj0dzKY.mjs → list-BnPrIsU_.mjs} +6 -6
  45. package/dist/log-vqY3pqwI.mjs +29 -0
  46. package/dist/{login-UZKFM_u7.mjs → login-BuiMyUrx.mjs} +8 -8
  47. package/dist/login-DIy9Sb-U.mjs +2 -0
  48. package/dist/{logs-CUZ6t9t3.mjs → logs-CZG9d-ic.mjs} +10 -11
  49. package/dist/migrate-BCiJ8w0f.mjs +2 -0
  50. package/dist/{migrate-DHul7PRV.mjs → migrate-q4_njtaW.mjs} +2 -2
  51. package/dist/{operator-args-CLgKGlwU.mjs → operator-args-B3BTmSoi.mjs} +12 -5
  52. package/dist/{operator-auth-8KnOVXVd.mjs → operator-auth-7erYc6Lt.mjs} +2 -2
  53. package/dist/{operator-client-DUwumHpQ.mjs → operator-client-CpHjTd0t.mjs} +3 -3
  54. package/dist/{operator-cmd-DBA6dl0m.mjs → operator-cmd-DGqPJUD3.mjs} +6 -6
  55. package/dist/{output-Dm_A4Tbv.mjs → output-CbM85T4k.mjs} +18 -10
  56. package/dist/pages/index.mjs +1 -1
  57. package/dist/{platform-args-BJdRtlLq.mjs → platform-args-3k8X9-H_.mjs} +11 -3
  58. package/dist/platform-args-DdnM6WIf.mjs +2 -0
  59. package/dist/{platform-auth-config-B56E9YP1.mjs → platform-auth-config-DDrxUy4m.mjs} +6 -6
  60. package/dist/{platform-auth-protection-BDWO_aER.mjs → platform-auth-protection-BLadnnct.mjs} +8 -8
  61. package/dist/{platform-auth-recovery-1gg4CSRe.mjs → platform-auth-recovery-CmCzX2Fl.mjs} +6 -6
  62. package/dist/{platform-cmd-DMcQStSc.mjs → platform-cmd-DMDEc9uS.mjs} +10 -10
  63. package/dist/{platform-cmd-Bt-1w6pY.mjs → platform-cmd-pMTRhvYs.mjs} +1 -1
  64. package/dist/{platform-domain-BNkcz0OB.mjs → platform-domain-Di6EYrQl.mjs} +5 -5
  65. package/dist/{platform-lifecycle-9OyBALhH.mjs → platform-lifecycle-BBoNzojY.mjs} +1264 -407
  66. package/dist/{platform-lifecycle-BE6C_jxh.mjs → platform-lifecycle-BFdSi9Qt.mjs} +1 -1
  67. package/dist/{platform-management-CjwLVQwN.mjs → platform-management-CWOQOWXm.mjs} +5 -5
  68. package/dist/{platform-management-CnyTdcWX.mjs → platform-management-DG47jys8.mjs} +1 -1
  69. package/dist/{platform-plans-config-BNGKGr4P.mjs → platform-plans-config-Vl9BP3H4.mjs} +3 -3
  70. package/dist/{platform-recovery-D6KSpuFm.mjs → platform-recovery-BJnQJEtQ.mjs} +4 -4
  71. package/dist/{platform-registry-QBa4DK32.mjs → platform-registry-DkPPXfp_.mjs} +2 -2
  72. package/dist/{prepare-B5Mkic5u.mjs → prepare-CBLT3CHH.mjs} +3 -3
  73. package/dist/prepare-CnjcTV2s.mjs +2 -0
  74. package/dist/{prepare-DOsL0CC9.mjs → prepare-DnaKBi--.mjs} +1 -1
  75. package/dist/{project-C0Fqu05O.mjs → project-DKG5Ra8p.mjs} +15 -82
  76. package/dist/project-DsblYifa.mjs +2 -0
  77. package/dist/{project-cmd-CNzrqvBv.mjs → project-cmd-DxnXstAq.mjs} +19 -19
  78. package/dist/{project-team-DQOWPfQT.mjs → project-team-BmHcaALJ.mjs} +5 -5
  79. package/dist/{project-token-CTDYU0Cc.mjs → project-token-GionZlBI.mjs} +5 -5
  80. package/dist/{project-zero-trust-BNAkW-_0.mjs → project-zero-trust-JLCjVQA7.mjs} +5 -5
  81. package/dist/prompts-2TGE6oXx.mjs +2 -0
  82. package/dist/prompts-BNUoTiaf.mjs +2044 -0
  83. package/dist/{provision-C4ORE7G7.mjs → provision-CVku1JFU.mjs} +1 -1
  84. package/dist/{provision-CJFgTZY8.mjs → provision-CaoxO_U7.mjs} +1 -1
  85. package/dist/{requests-MhxYnau8.mjs → requests-BOjIVAeF.mjs} +5 -5
  86. package/dist/{rollback-CJ6iSDoU.mjs → rollback-CwR3pLj3.mjs} +6 -6
  87. package/dist/runtime/ai.mjs +3 -5
  88. package/dist/runtime/email/testing.mjs +1 -1
  89. package/dist/runtime/email.mjs +1 -1
  90. package/dist/runtime/remote/index.mjs +2 -2
  91. package/dist/{secret-Dli5fP0B.mjs → secret-ByWJWBUG.mjs} +7 -7
  92. package/dist/{skills-D1II1Juz.mjs → skills-C1PlclPt.mjs} +1 -1
  93. package/dist/{subcommand-prompt-CY1C4fvl.mjs → subcommand-prompt-klFCfcor.mjs} +40 -32
  94. package/package.json +8 -9
  95. package/skills/void/SKILL.md +6 -1
  96. package/skills/void/docs/guide/deployment.md +22 -0
  97. package/skills/void/docs/guide/edge/headers.md +1 -1
  98. package/skills/void/docs/guide/email/domains.md +5 -1
  99. package/skills/void/docs/guide/email/sending.md +1 -1
  100. package/skills/void/docs/guide/platform/administration/zero-trust.md +27 -9
  101. package/skills/void/docs/guide/platform/installation/ci.md +1 -1
  102. package/skills/void/docs/guide/platform/installation/credentials.md +10 -3
  103. package/skills/void/docs/guide/platform/installation/domains.md +8 -3
  104. package/skills/void/docs/guide/platform/installation/first-deployment.md +2 -2
  105. package/skills/void/docs/guide/platform/installation/maintenance.md +12 -0
  106. package/skills/void/docs/guide/platform/installation/prerequisites.md +8 -7
  107. package/skills/void/docs/guide/platform/installation/setup.md +80 -10
  108. package/skills/void/docs/guide/remote-dev.md +1 -1
  109. package/skills/void/docs/reference/cli/auth.md +4 -3
  110. package/skills/void/docs/reference/cli/database.md +1 -1
  111. package/skills/void/docs/reference/cli/deploy.md +20 -0
  112. package/skills/void/docs/reference/cli/platform-installation.md +42 -27
  113. package/skills/void/docs/reference/cli/platform-zero-trust.md +14 -0
  114. package/skills/void/docs/reference/config.md +1 -1
  115. package/dist/auth-CCjt0hcq.mjs +0 -2
  116. package/dist/client-Cu7jWiF1.mjs +0 -2
  117. package/dist/dist-BuDuKZJv.mjs +0 -2
  118. package/dist/dist-CTBk70IR.mjs +0 -1310
  119. package/dist/gen-BVaUUumi.mjs +0 -2
  120. package/dist/help-DofyZuY7.mjs +0 -2
  121. package/dist/log-ChfPKsVd.mjs +0 -26
  122. package/dist/login-DYt_An22.mjs +0 -2
  123. package/dist/migrate-8_2u55MD.mjs +0 -2
  124. package/dist/platform-args-D3RXyR6h.mjs +0 -2
  125. package/dist/prepare-cgvDMtSb.mjs +0 -2
  126. package/dist/project-BuUwfj6f.mjs +0 -2
@@ -0,0 +1,2044 @@
1
+ import { n as __toESM, t as __commonJSMin } from "./rolldown-runtime-DXIUcv95.mjs";
2
+ import { t as require_picocolors } from "./picocolors-BTps1_gs.mjs";
3
+ import "node:fs";
4
+ import { randomBytes } from "node:crypto";
5
+ import { stripVTControlCharacters, styleText } from "node:util";
6
+ import process$1, { stdin, stdout } from "node:process";
7
+ import * as l from "node:readline";
8
+ import l__default from "node:readline";
9
+ import { ReadStream } from "node:tty";
10
+ //#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
11
+ const getCodePointsLength$1 = (() => {
12
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
13
+ return (input) => {
14
+ let surrogatePairsNr = 0;
15
+ SURROGATE_PAIR_RE.lastIndex = 0;
16
+ while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
17
+ return input.length - surrogatePairsNr;
18
+ };
19
+ })();
20
+ const isFullWidth$2 = (x) => {
21
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
22
+ };
23
+ const isWideNotCJKTNotEmoji$1 = (x) => {
24
+ return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
25
+ };
26
+ //#endregion
27
+ //#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
28
+ const ANSI_RE$2 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
29
+ const CONTROL_RE$2 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
30
+ const CJKT_WIDE_RE$1 = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
31
+ const TAB_RE$2 = /\t{1,1000}/y;
32
+ const EMOJI_RE$2 = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
33
+ const LATIN_RE$2 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
34
+ const MODIFIER_RE$2 = /\p{M}+/gu;
35
+ const NO_TRUNCATION$5 = {
36
+ limit: Infinity,
37
+ ellipsis: ""
38
+ };
39
+ const getStringTruncatedWidth$2 = (input, truncationOptions = {}, widthOptions = {}) => {
40
+ const LIMIT = truncationOptions.limit ?? Infinity;
41
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
42
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth$2(ELLIPSIS, NO_TRUNCATION$5, widthOptions).width : 0);
43
+ const ANSI_WIDTH = 0;
44
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
45
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
46
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
47
+ const FULL_WIDTH_WIDTH = 2;
48
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
49
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
50
+ const PARSE_BLOCKS = [
51
+ [LATIN_RE$2, REGULAR_WIDTH],
52
+ [ANSI_RE$2, ANSI_WIDTH],
53
+ [CONTROL_RE$2, CONTROL_WIDTH],
54
+ [TAB_RE$2, TAB_WIDTH],
55
+ [EMOJI_RE$2, EMOJI_WIDTH],
56
+ [CJKT_WIDE_RE$1, WIDE_WIDTH]
57
+ ];
58
+ let indexPrev = 0;
59
+ let index = 0;
60
+ let length = input.length;
61
+ let lengthExtra = 0;
62
+ let truncationEnabled = false;
63
+ let truncationIndex = length;
64
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
65
+ let unmatchedStart = 0;
66
+ let unmatchedEnd = 0;
67
+ let width = 0;
68
+ let widthExtra = 0;
69
+ outer: while (true) {
70
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
71
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
72
+ lengthExtra = 0;
73
+ for (const char of unmatched.replaceAll(MODIFIER_RE$2, "")) {
74
+ const codePoint = char.codePointAt(0) || 0;
75
+ if (isFullWidth$2(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
76
+ else if (isWideNotCJKTNotEmoji$1(codePoint)) widthExtra = WIDE_WIDTH;
77
+ else widthExtra = REGULAR_WIDTH;
78
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
79
+ if (width + widthExtra > LIMIT) {
80
+ truncationEnabled = true;
81
+ break outer;
82
+ }
83
+ lengthExtra += char.length;
84
+ width += widthExtra;
85
+ }
86
+ unmatchedStart = unmatchedEnd = 0;
87
+ }
88
+ if (index >= length) break outer;
89
+ for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
90
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
91
+ BLOCK_RE.lastIndex = index;
92
+ if (BLOCK_RE.test(input)) {
93
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE$1 ? getCodePointsLength$1(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE$2 ? 1 : BLOCK_RE.lastIndex - index;
94
+ widthExtra = lengthExtra * BLOCK_WIDTH;
95
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
96
+ if (width + widthExtra > LIMIT) {
97
+ truncationEnabled = true;
98
+ break outer;
99
+ }
100
+ width += widthExtra;
101
+ unmatchedStart = indexPrev;
102
+ unmatchedEnd = index;
103
+ index = indexPrev = BLOCK_RE.lastIndex;
104
+ continue outer;
105
+ }
106
+ }
107
+ index += 1;
108
+ }
109
+ return {
110
+ width: truncationEnabled ? truncationLimit : width,
111
+ index: truncationEnabled ? truncationIndex : length,
112
+ truncated: truncationEnabled,
113
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
114
+ };
115
+ };
116
+ //#endregion
117
+ //#region ../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
118
+ const NO_TRUNCATION$4 = {
119
+ limit: Infinity,
120
+ ellipsis: "",
121
+ ellipsisWidth: 0
122
+ };
123
+ const fastStringWidth$2 = (input, options = {}) => {
124
+ return getStringTruncatedWidth$2(input, NO_TRUNCATION$4, options).width;
125
+ };
126
+ //#endregion
127
+ //#region ../../node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
128
+ const ESC$1 = "\x1B";
129
+ const CSI$1 = "›";
130
+ const END_CODE$1 = 39;
131
+ const ANSI_ESCAPE_BELL$1 = "\x07";
132
+ const ANSI_CSI$1 = "[";
133
+ const ANSI_OSC$1 = "]";
134
+ const ANSI_SGR_TERMINATOR$1 = "m";
135
+ const ANSI_ESCAPE_LINK$1 = `${ANSI_OSC$1}8;;`;
136
+ const GROUP_REGEX$1 = new RegExp(`(?:\\${ANSI_CSI$1}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK$1}(?<uri>.*)${ANSI_ESCAPE_BELL$1})`, "y");
137
+ const getClosingCode$1 = (openingCode) => {
138
+ if (openingCode >= 30 && openingCode <= 37) return 39;
139
+ if (openingCode >= 90 && openingCode <= 97) return 39;
140
+ if (openingCode >= 40 && openingCode <= 47) return 49;
141
+ if (openingCode >= 100 && openingCode <= 107) return 49;
142
+ if (openingCode === 1 || openingCode === 2) return 22;
143
+ if (openingCode === 3) return 23;
144
+ if (openingCode === 4) return 24;
145
+ if (openingCode === 7) return 27;
146
+ if (openingCode === 8) return 28;
147
+ if (openingCode === 9) return 29;
148
+ if (openingCode === 0) return 0;
149
+ };
150
+ const wrapAnsiCode$1 = (code) => `${ESC$1}${ANSI_CSI$1}${code}${ANSI_SGR_TERMINATOR$1}`;
151
+ const wrapAnsiHyperlink$1 = (url) => `${ESC$1}${ANSI_ESCAPE_LINK$1}${url}${ANSI_ESCAPE_BELL$1}`;
152
+ const wrapWord$1 = (rows, word, columns) => {
153
+ const characters = word[Symbol.iterator]();
154
+ let isInsideEscape = false;
155
+ let isInsideLinkEscape = false;
156
+ let lastRow = rows.at(-1);
157
+ let visible = lastRow === void 0 ? 0 : fastStringWidth$2(lastRow);
158
+ let currentCharacter = characters.next();
159
+ let nextCharacter = characters.next();
160
+ let rawCharacterIndex = 0;
161
+ while (!currentCharacter.done) {
162
+ const character = currentCharacter.value;
163
+ const characterLength = fastStringWidth$2(character);
164
+ if (visible + characterLength <= columns) rows[rows.length - 1] += character;
165
+ else {
166
+ rows.push(character);
167
+ visible = 0;
168
+ }
169
+ if (character === ESC$1 || character === CSI$1) {
170
+ isInsideEscape = true;
171
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK$1, rawCharacterIndex + 1);
172
+ }
173
+ if (isInsideEscape) {
174
+ if (isInsideLinkEscape) {
175
+ if (character === ANSI_ESCAPE_BELL$1) {
176
+ isInsideEscape = false;
177
+ isInsideLinkEscape = false;
178
+ }
179
+ } else if (character === ANSI_SGR_TERMINATOR$1) isInsideEscape = false;
180
+ } else {
181
+ visible += characterLength;
182
+ if (visible === columns && !nextCharacter.done) {
183
+ rows.push("");
184
+ visible = 0;
185
+ }
186
+ }
187
+ currentCharacter = nextCharacter;
188
+ nextCharacter = characters.next();
189
+ rawCharacterIndex += character.length;
190
+ }
191
+ lastRow = rows.at(-1);
192
+ if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
193
+ };
194
+ const stringVisibleTrimSpacesRight$1 = (string) => {
195
+ const words = string.split(" ");
196
+ let last = words.length;
197
+ while (last) {
198
+ if (fastStringWidth$2(words[last - 1])) break;
199
+ last--;
200
+ }
201
+ if (last === words.length) return string;
202
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
203
+ };
204
+ const exec$1 = (string, columns, options = {}) => {
205
+ if (options.trim !== false && string.trim() === "") return "";
206
+ let returnValue = "";
207
+ let escapeCode;
208
+ let escapeUrl;
209
+ const words = string.split(" ");
210
+ let rows = [""];
211
+ let rowLength = 0;
212
+ for (let index = 0; index < words.length; index++) {
213
+ const word = words[index];
214
+ if (options.trim !== false) {
215
+ const row = rows.at(-1) ?? "";
216
+ const trimmed = row.trimStart();
217
+ if (row.length !== trimmed.length) {
218
+ rows[rows.length - 1] = trimmed;
219
+ rowLength = fastStringWidth$2(trimmed);
220
+ }
221
+ }
222
+ if (index !== 0) {
223
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
224
+ rows.push("");
225
+ rowLength = 0;
226
+ }
227
+ if (rowLength || options.trim === false) {
228
+ rows[rows.length - 1] += " ";
229
+ rowLength++;
230
+ }
231
+ }
232
+ const wordLength = fastStringWidth$2(word);
233
+ if (options.hard && wordLength > columns) {
234
+ const remainingColumns = columns - rowLength;
235
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
236
+ if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
237
+ wrapWord$1(rows, word, columns);
238
+ rowLength = fastStringWidth$2(rows.at(-1) ?? "");
239
+ continue;
240
+ }
241
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
242
+ if (options.wordWrap === false && rowLength < columns) {
243
+ wrapWord$1(rows, word, columns);
244
+ rowLength = fastStringWidth$2(rows.at(-1) ?? "");
245
+ continue;
246
+ }
247
+ rows.push("");
248
+ rowLength = 0;
249
+ }
250
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
251
+ wrapWord$1(rows, word, columns);
252
+ rowLength = fastStringWidth$2(rows.at(-1) ?? "");
253
+ continue;
254
+ }
255
+ rows[rows.length - 1] += word;
256
+ rowLength += wordLength;
257
+ }
258
+ if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight$1(row));
259
+ const preString = rows.join("\n");
260
+ let inSurrogate = false;
261
+ for (let i = 0; i < preString.length; i++) {
262
+ const character = preString[i];
263
+ returnValue += character;
264
+ if (!inSurrogate) {
265
+ inSurrogate = character >= "\ud800" && character <= "\udbff";
266
+ if (inSurrogate) continue;
267
+ } else inSurrogate = false;
268
+ if (character === ESC$1 || character === CSI$1) {
269
+ GROUP_REGEX$1.lastIndex = i + 1;
270
+ const groups = GROUP_REGEX$1.exec(preString)?.groups;
271
+ if (groups?.code !== void 0) {
272
+ const code = Number.parseFloat(groups.code);
273
+ escapeCode = code === END_CODE$1 ? void 0 : code;
274
+ } else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
275
+ }
276
+ if (preString[i + 1] === "\n") {
277
+ if (escapeUrl) returnValue += wrapAnsiHyperlink$1("");
278
+ const closingCode = escapeCode ? getClosingCode$1(escapeCode) : void 0;
279
+ if (escapeCode && closingCode) returnValue += wrapAnsiCode$1(closingCode);
280
+ } else if (character === "\n") {
281
+ if (escapeCode && getClosingCode$1(escapeCode)) returnValue += wrapAnsiCode$1(escapeCode);
282
+ if (escapeUrl) returnValue += wrapAnsiHyperlink$1(escapeUrl);
283
+ }
284
+ }
285
+ return returnValue;
286
+ };
287
+ const CRLF_OR_LF$1 = /\r?\n/;
288
+ function wrapAnsi$1(string, columns, options) {
289
+ return String(string).normalize().split(CRLF_OR_LF$1).map((line) => exec$1(line, columns, options)).join("\n");
290
+ }
291
+ //#endregion
292
+ //#region ../../node_modules/.pnpm/@clack+core@1.5.1/node_modules/@clack/core/dist/index.mjs
293
+ var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
294
+ const ESC = "\x1B";
295
+ const CSI = `${ESC}[`;
296
+ const beep = "\x07";
297
+ const cursor = {
298
+ to(x, y) {
299
+ if (!y) return `${CSI}${x + 1}G`;
300
+ return `${CSI}${y + 1};${x + 1}H`;
301
+ },
302
+ move(x, y) {
303
+ let ret = "";
304
+ if (x < 0) ret += `${CSI}${-x}D`;
305
+ else if (x > 0) ret += `${CSI}${x}C`;
306
+ if (y < 0) ret += `${CSI}${-y}A`;
307
+ else if (y > 0) ret += `${CSI}${y}B`;
308
+ return ret;
309
+ },
310
+ up: (count = 1) => `${CSI}${count}A`,
311
+ down: (count = 1) => `${CSI}${count}B`,
312
+ forward: (count = 1) => `${CSI}${count}C`,
313
+ backward: (count = 1) => `${CSI}${count}D`,
314
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
315
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
316
+ left: `${CSI}G`,
317
+ hide: `${CSI}?25l`,
318
+ show: `${CSI}?25h`,
319
+ save: `${ESC}7`,
320
+ restore: `${ESC}8`
321
+ };
322
+ module.exports = {
323
+ cursor,
324
+ scroll: {
325
+ up: (count = 1) => `${CSI}S`.repeat(count),
326
+ down: (count = 1) => `${CSI}T`.repeat(count)
327
+ },
328
+ erase: {
329
+ screen: `${CSI}2J`,
330
+ up: (count = 1) => `${CSI}1J`.repeat(count),
331
+ down: (count = 1) => `${CSI}J`.repeat(count),
332
+ line: `${CSI}2K`,
333
+ lineEnd: `${CSI}K`,
334
+ lineStart: `${CSI}1K`,
335
+ lines(count) {
336
+ let clear = "";
337
+ for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
338
+ if (count) clear += cursor.left;
339
+ return clear;
340
+ }
341
+ },
342
+ beep
343
+ };
344
+ })))();
345
+ function findCursor(s, o, l) {
346
+ if (!l.some((r) => !r.disabled)) return s;
347
+ const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
348
+ return l[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
349
+ }
350
+ const settings = {
351
+ actions: /* @__PURE__ */ new Set([
352
+ "up",
353
+ "down",
354
+ "left",
355
+ "right",
356
+ "space",
357
+ "enter",
358
+ "cancel"
359
+ ]),
360
+ aliases: /* @__PURE__ */ new Map([
361
+ ["k", "up"],
362
+ ["j", "down"],
363
+ ["h", "left"],
364
+ ["l", "right"],
365
+ ["", "cancel"],
366
+ ["escape", "cancel"]
367
+ ]),
368
+ messages: {
369
+ cancel: "Canceled",
370
+ error: "Something went wrong"
371
+ },
372
+ withGuide: true,
373
+ accessible: void 0,
374
+ date: {
375
+ monthNames: [...[
376
+ "January",
377
+ "February",
378
+ "March",
379
+ "April",
380
+ "May",
381
+ "June",
382
+ "July",
383
+ "August",
384
+ "September",
385
+ "October",
386
+ "November",
387
+ "December"
388
+ ]],
389
+ messages: {
390
+ required: "Please enter a valid date",
391
+ invalidMonth: "There are only 12 months in a year",
392
+ invalidDay: (n, e) => `There are only ${n} days in ${e}`,
393
+ afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
394
+ beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
395
+ }
396
+ }
397
+ };
398
+ function updateSettings(n) {
399
+ if (n.aliases !== void 0) {
400
+ const e = n.aliases;
401
+ for (const s in e) {
402
+ if (!Object.hasOwn(e, s)) continue;
403
+ const i = e[s];
404
+ i === void 0 || !settings.actions.has(i) || settings.aliases.has(s) || settings.aliases.set(s, i);
405
+ }
406
+ }
407
+ if (n.messages !== void 0) {
408
+ const e = n.messages;
409
+ e.cancel !== void 0 && (settings.messages.cancel = e.cancel), e.error !== void 0 && (settings.messages.error = e.error);
410
+ }
411
+ if (n.withGuide !== void 0 && (settings.withGuide = n.withGuide !== false), n.accessible !== void 0 && (settings.accessible = n.accessible === true), n.date !== void 0) {
412
+ const e = n.date;
413
+ e.monthNames !== void 0 && (settings.date.monthNames = [...e.monthNames]), e.messages !== void 0 && (e.messages.required !== void 0 && (settings.date.messages.required = e.messages.required), e.messages.invalidMonth !== void 0 && (settings.date.messages.invalidMonth = e.messages.invalidMonth), e.messages.invalidDay !== void 0 && (settings.date.messages.invalidDay = e.messages.invalidDay), e.messages.afterMin !== void 0 && (settings.date.messages.afterMin = e.messages.afterMin), e.messages.beforeMax !== void 0 && (settings.date.messages.beforeMax = e.messages.beforeMax));
414
+ }
415
+ }
416
+ function isAccessible(n) {
417
+ if (n !== void 0) return n;
418
+ if (settings.accessible !== void 0) return settings.accessible;
419
+ const e = process.env.ACCESSIBLE;
420
+ return e !== void 0 && e !== "" && e !== "0" && e !== "false";
421
+ }
422
+ function isActionKey(n, e) {
423
+ if (typeof n == "string") return settings.aliases.get(n) === e;
424
+ for (const s of n) if (s !== void 0 && isActionKey(s, e)) return true;
425
+ return false;
426
+ }
427
+ function diffLines(i, s) {
428
+ if (i === s) return;
429
+ const e = i.split(`
430
+ `), t = s.split(`
431
+ `), r = Math.max(e.length, t.length), f = [];
432
+ for (let n = 0; n < r; n++) e[n] !== t[n] && f.push(n);
433
+ return {
434
+ lines: f,
435
+ numLinesBefore: e.length,
436
+ numLinesAfter: t.length,
437
+ numLines: r
438
+ };
439
+ }
440
+ const R = globalThis.process.platform.startsWith("win");
441
+ const CANCEL_SYMBOL = Symbol("clack:cancel");
442
+ function isCancel(e) {
443
+ return e === CANCEL_SYMBOL;
444
+ }
445
+ function setRawMode(e, r) {
446
+ const o = e;
447
+ o.isTTY && o.setRawMode(r);
448
+ }
449
+ function block({ input: e = stdin, output: r = stdout, overwrite: o = true, hideCursor: n = true } = {}) {
450
+ const s = l.createInterface({
451
+ input: e,
452
+ output: r,
453
+ prompt: "",
454
+ tabSize: 1
455
+ });
456
+ l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
457
+ const t = (f, { name: a, sequence: w }) => {
458
+ if (isActionKey([
459
+ String(f),
460
+ a,
461
+ w
462
+ ], "cancel")) {
463
+ n && r.write(import_src.cursor.show), process.exit(0);
464
+ return;
465
+ }
466
+ if (!o) return;
467
+ const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
468
+ l.moveCursor(r, i, m, () => {
469
+ l.clearLine(r, 1, () => {
470
+ e.once("keypress", t);
471
+ });
472
+ });
473
+ };
474
+ return n && r.write(import_src.cursor.hide), e.once("keypress", t), () => {
475
+ e.off("keypress", t), n && r.write(import_src.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
476
+ };
477
+ }
478
+ const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
479
+ const getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
480
+ function runValidation(e, a) {
481
+ if ("~standard" in e) {
482
+ const n = e["~standard"].validate(a);
483
+ return n instanceof Promise ? n.then((r) => r.issues?.at(0)?.message) : n.issues?.at(0)?.message;
484
+ }
485
+ return e(a);
486
+ }
487
+ var y = class {
488
+ input;
489
+ output;
490
+ _abortSignal;
491
+ rl;
492
+ opts;
493
+ _render;
494
+ _track = false;
495
+ _prevFrame = "";
496
+ _subscribers = /* @__PURE__ */ new Map();
497
+ _cursor = 0;
498
+ state = "initial";
499
+ error = "";
500
+ value;
501
+ userInput = "";
502
+ /**
503
+ * Whether accessible (static, screen-reader friendly) output is enabled for
504
+ * this prompt, resolved from the `accessible` option, the global setting,
505
+ * and the `ACCESSIBLE` env var.
506
+ */
507
+ get accessible() {
508
+ return isAccessible(this.opts.accessible);
509
+ }
510
+ constructor(t, e = true) {
511
+ const { input: i = stdin, output: s = stdout, render: r, signal: n, ...o } = t;
512
+ this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = r.bind(this), this._track = e, this._abortSignal = n, this.input = i, this.output = s;
513
+ }
514
+ /**
515
+ * Unsubscribe all listeners
516
+ */
517
+ unsubscribe() {
518
+ this._subscribers.clear();
519
+ }
520
+ /**
521
+ * Set a subscriber with opts
522
+ * @param event - The event name
523
+ */
524
+ setSubscriber(t, e) {
525
+ const i = this._subscribers.get(t) ?? [];
526
+ i.push(e), this._subscribers.set(t, i);
527
+ }
528
+ /**
529
+ * Subscribe to an event
530
+ * @param event - The event name
531
+ * @param cb - The callback
532
+ */
533
+ on(t, e) {
534
+ this.setSubscriber(t, { cb: e });
535
+ }
536
+ /**
537
+ * Subscribe to an event once
538
+ * @param event - The event name
539
+ * @param cb - The callback
540
+ */
541
+ once(t, e) {
542
+ this.setSubscriber(t, {
543
+ cb: e,
544
+ once: true
545
+ });
546
+ }
547
+ /**
548
+ * Emit an event with data
549
+ * @param event - The event name
550
+ * @param data - The data to pass to the callback
551
+ */
552
+ emit(t, ...e) {
553
+ const i = this._subscribers.get(t) ?? [], s = [];
554
+ for (const r of i) r.cb(...e), r.once && s.push(() => i.splice(i.indexOf(r), 1));
555
+ for (const r of s) r();
556
+ }
557
+ prompt() {
558
+ return new Promise((t) => {
559
+ if (this._abortSignal) {
560
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
561
+ this._abortSignal.addEventListener("abort", () => {
562
+ this.state = "cancel", this.close();
563
+ }, { once: true });
564
+ }
565
+ this.rl = l__default.createInterface({
566
+ input: this.input,
567
+ tabSize: 2,
568
+ prompt: "",
569
+ escapeCodeTimeout: 50,
570
+ terminal: true
571
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
572
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
573
+ }), this.once("cancel", () => {
574
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
575
+ });
576
+ });
577
+ }
578
+ _isActionKey(t, e) {
579
+ return t === " ";
580
+ }
581
+ _shouldSubmit(t, e) {
582
+ return true;
583
+ }
584
+ _setValue(t) {
585
+ this.value = t, this.emit("value", this.value);
586
+ }
587
+ _setUserInput(t, e) {
588
+ this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
589
+ }
590
+ _clearUserInput() {
591
+ this.rl?.write(null, {
592
+ ctrl: true,
593
+ name: "u"
594
+ }), this._setUserInput("");
595
+ }
596
+ async onKeypress(t, e) {
597
+ if (this.state !== "validating") {
598
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
599
+ ctrl: true,
600
+ name: "h"
601
+ }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
602
+ if (this.opts.validate) {
603
+ const i = runValidation(this.opts.validate, this.value);
604
+ let s;
605
+ i instanceof Promise ? (this.state = "validating", this.render(), s = await i) : s = i, s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
606
+ }
607
+ this.state !== "error" && (this.state = "submit");
608
+ }
609
+ isActionKey([
610
+ t,
611
+ e?.name,
612
+ e?.sequence
613
+ ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
614
+ }
615
+ }
616
+ close() {
617
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
618
+ `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
619
+ }
620
+ restoreCursor() {
621
+ const t = wrapAnsi$1(this._prevFrame, process.stdout.columns, {
622
+ hard: true,
623
+ trim: false
624
+ }).split(`
625
+ `).length - 1;
626
+ this.output.write(import_src.cursor.move(-999, t * -1));
627
+ }
628
+ render() {
629
+ const t = wrapAnsi$1(this._render(this) ?? "", process.stdout.columns, {
630
+ hard: true,
631
+ trim: false
632
+ });
633
+ if (t !== this._prevFrame) {
634
+ if (this.state === "initial") this.output.write(import_src.cursor.hide);
635
+ else {
636
+ const e = diffLines(this._prevFrame, t), i = getRows(this.output);
637
+ if (this.restoreCursor(), e) {
638
+ const s = Math.max(0, e.numLinesAfter - i), r = Math.max(0, e.numLinesBefore - i);
639
+ let n = e.lines.find((o) => o >= s);
640
+ if (n === void 0) {
641
+ this._prevFrame = t;
642
+ return;
643
+ }
644
+ if (e.lines.length === 1) {
645
+ this.output.write(import_src.cursor.move(0, n - r)), this.output.write(import_src.erase.lines(1));
646
+ const o = t.split(`
647
+ `);
648
+ this.output.write(o[n]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, o.length - n - 1));
649
+ return;
650
+ } else if (e.lines.length > 1) {
651
+ if (s < r) n = s;
652
+ else {
653
+ const h = n - r;
654
+ h > 0 && this.output.write(import_src.cursor.move(0, h));
655
+ }
656
+ this.output.write(import_src.erase.down());
657
+ const f = t.split(`
658
+ `).slice(n);
659
+ this.output.write(f.join(`
660
+ `)), this._prevFrame = t;
661
+ return;
662
+ }
663
+ }
664
+ this.output.write(import_src.erase.down());
665
+ }
666
+ this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
667
+ }
668
+ }
669
+ };
670
+ var r = class extends y {
671
+ get cursor() {
672
+ return this.value ? 0 : 1;
673
+ }
674
+ get _value() {
675
+ return this.cursor === 0;
676
+ }
677
+ constructor(t) {
678
+ super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
679
+ this.value = this._value;
680
+ }), this.on("confirm", (i) => {
681
+ this.output.write(import_src.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
682
+ }), this.on("cursor", () => {
683
+ this.value = !this.value;
684
+ });
685
+ }
686
+ };
687
+ var a = class extends y {
688
+ options;
689
+ cursor = 0;
690
+ get _value() {
691
+ return this.options[this.cursor]?.value;
692
+ }
693
+ get _enabledOptions() {
694
+ return this.options.filter((e) => e.disabled !== true);
695
+ }
696
+ toggleAll() {
697
+ const e = this._enabledOptions, i = this.value !== void 0 && this.value.length === e.length;
698
+ this.value = i ? [] : e.map((t) => t.value);
699
+ }
700
+ toggleInvert() {
701
+ const e = this.value;
702
+ if (!e) return;
703
+ const i = this._enabledOptions.filter((t) => !e.includes(t.value));
704
+ this.value = i.map((t) => t.value);
705
+ }
706
+ toggleValue() {
707
+ this.value === void 0 && (this.value = []);
708
+ const e = this.value.includes(this._value);
709
+ this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
710
+ }
711
+ constructor(e) {
712
+ super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
713
+ const i = Math.max(this.options.findIndex(({ value: t }) => t === e.cursorAt), 0);
714
+ this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, l) => {
715
+ l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
716
+ }), this.on("cursor", (t) => {
717
+ switch (t) {
718
+ case "left":
719
+ case "up":
720
+ this.cursor = findCursor(this.cursor, -1, this.options);
721
+ break;
722
+ case "down":
723
+ case "right":
724
+ this.cursor = findCursor(this.cursor, 1, this.options);
725
+ break;
726
+ case "space": this.toggleValue();
727
+ }
728
+ });
729
+ }
730
+ };
731
+ let u$1 = class u extends y {
732
+ _mask = "•";
733
+ get cursor() {
734
+ return this._cursor;
735
+ }
736
+ get masked() {
737
+ return this.userInput.replaceAll(/./g, this._mask);
738
+ }
739
+ get userInputWithCursor() {
740
+ if (this.state === "submit" || this.state === "cancel") return this.masked;
741
+ const t = this.userInput;
742
+ if (this.cursor >= t.length) return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
743
+ const s = this.masked, r = s.slice(0, this.cursor), i = s.slice(this.cursor, this.cursor + 1), o = s.slice(this.cursor + 1);
744
+ return `${r}${styleText("inverse", i)}${o}`;
745
+ }
746
+ clear() {
747
+ this._clearUserInput();
748
+ }
749
+ constructor({ mask: t, ...s }) {
750
+ super(s), this._mask = t ?? "•", this.on("userInput", (r) => {
751
+ this._setValue(r);
752
+ }), this.on("finalize", () => {
753
+ this.value === void 0 && (this.value = "");
754
+ });
755
+ }
756
+ };
757
+ let n$1 = class n extends y {
758
+ options;
759
+ cursor = 0;
760
+ get _selectedValue() {
761
+ return this.options[this.cursor];
762
+ }
763
+ changeValue() {
764
+ const e = this._selectedValue;
765
+ this.value = e === void 0 ? void 0 : e.value;
766
+ }
767
+ constructor(e) {
768
+ super(e, false), this.options = e.options;
769
+ const o = this.options.findIndex(({ value: s }) => s === e.initialValue), t = o === -1 ? 0 : o;
770
+ this.cursor = this.options[t]?.disabled ? findCursor(t, 1, this.options) : t, this.changeValue(), this.on("cursor", (s) => {
771
+ switch (s) {
772
+ case "left":
773
+ case "up":
774
+ this.cursor = findCursor(this.cursor, -1, this.options);
775
+ break;
776
+ case "down":
777
+ case "right": this.cursor = findCursor(this.cursor, 1, this.options);
778
+ }
779
+ this.changeValue();
780
+ });
781
+ }
782
+ };
783
+ var n = class extends y {
784
+ get userInputWithCursor() {
785
+ if (this.state === "submit") return this.userInput;
786
+ const t = this.userInput;
787
+ if (this.cursor >= t.length) return `${this.userInput}\u2588`;
788
+ const r = t.slice(0, this.cursor), s = t.slice(this.cursor, this.cursor + 1), e = t.slice(this.cursor + 1);
789
+ return `${r}${styleText("inverse", s)}${e}`;
790
+ }
791
+ get cursor() {
792
+ return this._cursor;
793
+ }
794
+ constructor(t) {
795
+ super({
796
+ ...t,
797
+ initialUserInput: t.initialUserInput ?? t.initialValue
798
+ }), this.on("userInput", (r) => {
799
+ this._setValue(r);
800
+ }), this.on("finalize", () => {
801
+ this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
802
+ });
803
+ }
804
+ };
805
+ //#endregion
806
+ //#region ../prompts/index.mjs
807
+ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
808
+ const isAmbiguous = (x) => {
809
+ return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
810
+ };
811
+ const isFullWidth$1 = (x) => {
812
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
813
+ };
814
+ const isWide = (x) => {
815
+ return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9800 && x <= 9811 || x === 9855 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 19968 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101632 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129672 || x >= 129680 && x <= 129725 || x >= 129727 && x <= 129733 || x >= 129742 && x <= 129755 || x >= 129760 && x <= 129768 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
816
+ };
817
+ const ANSI_RE$1 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
818
+ const CONTROL_RE$1 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
819
+ const TAB_RE$1 = /\t{1,1000}/y;
820
+ const EMOJI_RE$1 = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
821
+ const LATIN_RE$1 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
822
+ const MODIFIER_RE$1 = /\p{M}+/gu;
823
+ const NO_TRUNCATION$3 = {
824
+ limit: Infinity,
825
+ ellipsis: ""
826
+ };
827
+ const getStringTruncatedWidth$1 = (input, truncationOptions = {}, widthOptions = {}) => {
828
+ const LIMIT = truncationOptions.limit ?? Infinity;
829
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
830
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth$1(ELLIPSIS, NO_TRUNCATION$3, widthOptions).width : 0);
831
+ const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
832
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
833
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
834
+ const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
835
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
836
+ const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
837
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
838
+ const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
839
+ let indexPrev = 0;
840
+ let index = 0;
841
+ let length = input.length;
842
+ let lengthExtra = 0;
843
+ let truncationEnabled = false;
844
+ let truncationIndex = length;
845
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
846
+ let unmatchedStart = 0;
847
+ let unmatchedEnd = 0;
848
+ let width = 0;
849
+ let widthExtra = 0;
850
+ outer: while (true) {
851
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
852
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
853
+ lengthExtra = 0;
854
+ for (const char of unmatched.replaceAll(MODIFIER_RE$1, "")) {
855
+ const codePoint = char.codePointAt(0) || 0;
856
+ if (isFullWidth$1(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
857
+ else if (isWide(codePoint)) widthExtra = WIDE_WIDTH;
858
+ else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) widthExtra = AMBIGUOUS_WIDTH;
859
+ else widthExtra = REGULAR_WIDTH;
860
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
861
+ if (width + widthExtra > LIMIT) {
862
+ truncationEnabled = true;
863
+ break outer;
864
+ }
865
+ lengthExtra += char.length;
866
+ width += widthExtra;
867
+ }
868
+ unmatchedStart = unmatchedEnd = 0;
869
+ }
870
+ if (index >= length) break;
871
+ LATIN_RE$1.lastIndex = index;
872
+ if (LATIN_RE$1.test(input)) {
873
+ lengthExtra = LATIN_RE$1.lastIndex - index;
874
+ widthExtra = lengthExtra * REGULAR_WIDTH;
875
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
876
+ if (width + widthExtra > LIMIT) {
877
+ truncationEnabled = true;
878
+ break;
879
+ }
880
+ width += widthExtra;
881
+ unmatchedStart = indexPrev;
882
+ unmatchedEnd = index;
883
+ index = indexPrev = LATIN_RE$1.lastIndex;
884
+ continue;
885
+ }
886
+ ANSI_RE$1.lastIndex = index;
887
+ if (ANSI_RE$1.test(input)) {
888
+ if (width + ANSI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
889
+ if (width + ANSI_WIDTH > LIMIT) {
890
+ truncationEnabled = true;
891
+ break;
892
+ }
893
+ width += ANSI_WIDTH;
894
+ unmatchedStart = indexPrev;
895
+ unmatchedEnd = index;
896
+ index = indexPrev = ANSI_RE$1.lastIndex;
897
+ continue;
898
+ }
899
+ CONTROL_RE$1.lastIndex = index;
900
+ if (CONTROL_RE$1.test(input)) {
901
+ lengthExtra = CONTROL_RE$1.lastIndex - index;
902
+ widthExtra = lengthExtra * CONTROL_WIDTH;
903
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
904
+ if (width + widthExtra > LIMIT) {
905
+ truncationEnabled = true;
906
+ break;
907
+ }
908
+ width += widthExtra;
909
+ unmatchedStart = indexPrev;
910
+ unmatchedEnd = index;
911
+ index = indexPrev = CONTROL_RE$1.lastIndex;
912
+ continue;
913
+ }
914
+ TAB_RE$1.lastIndex = index;
915
+ if (TAB_RE$1.test(input)) {
916
+ lengthExtra = TAB_RE$1.lastIndex - index;
917
+ widthExtra = lengthExtra * TAB_WIDTH;
918
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
919
+ if (width + widthExtra > LIMIT) {
920
+ truncationEnabled = true;
921
+ break;
922
+ }
923
+ width += widthExtra;
924
+ unmatchedStart = indexPrev;
925
+ unmatchedEnd = index;
926
+ index = indexPrev = TAB_RE$1.lastIndex;
927
+ continue;
928
+ }
929
+ EMOJI_RE$1.lastIndex = index;
930
+ if (EMOJI_RE$1.test(input)) {
931
+ if (width + EMOJI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
932
+ if (width + EMOJI_WIDTH > LIMIT) {
933
+ truncationEnabled = true;
934
+ break;
935
+ }
936
+ width += EMOJI_WIDTH;
937
+ unmatchedStart = indexPrev;
938
+ unmatchedEnd = index;
939
+ index = indexPrev = EMOJI_RE$1.lastIndex;
940
+ continue;
941
+ }
942
+ index += 1;
943
+ }
944
+ return {
945
+ width: truncationEnabled ? truncationLimit : width,
946
+ index: truncationEnabled ? truncationIndex : length,
947
+ truncated: truncationEnabled,
948
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
949
+ };
950
+ };
951
+ const NO_TRUNCATION$2 = {
952
+ limit: Infinity,
953
+ ellipsis: "",
954
+ ellipsisWidth: 0
955
+ };
956
+ const fastStringWidth$1 = (input, options = {}) => {
957
+ return getStringTruncatedWidth$1(input, NO_TRUNCATION$2, options).width;
958
+ };
959
+ const getCodePointsLength = (() => {
960
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
961
+ return (input) => {
962
+ let surrogatePairsNr = 0;
963
+ SURROGATE_PAIR_RE.lastIndex = 0;
964
+ while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
965
+ return input.length - surrogatePairsNr;
966
+ };
967
+ })();
968
+ const isFullWidth = (x) => {
969
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
970
+ };
971
+ const isWideNotCJKTNotEmoji = (x) => {
972
+ return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
973
+ };
974
+ const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
975
+ const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
976
+ const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
977
+ const TAB_RE = /\t{1,1000}/y;
978
+ const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
979
+ const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
980
+ const MODIFIER_RE = /\p{M}+/gu;
981
+ const NO_TRUNCATION$1 = {
982
+ limit: Infinity,
983
+ ellipsis: ""
984
+ };
985
+ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
986
+ const LIMIT = truncationOptions.limit ?? Infinity;
987
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
988
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
989
+ const ANSI_WIDTH = 0;
990
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
991
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
992
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
993
+ const FULL_WIDTH_WIDTH = 2;
994
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
995
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
996
+ const PARSE_BLOCKS = [
997
+ [LATIN_RE, REGULAR_WIDTH],
998
+ [ANSI_RE, ANSI_WIDTH],
999
+ [CONTROL_RE, CONTROL_WIDTH],
1000
+ [TAB_RE, TAB_WIDTH],
1001
+ [EMOJI_RE, EMOJI_WIDTH],
1002
+ [CJKT_WIDE_RE, WIDE_WIDTH]
1003
+ ];
1004
+ let indexPrev = 0;
1005
+ let index = 0;
1006
+ let length = input.length;
1007
+ let lengthExtra = 0;
1008
+ let truncationEnabled = false;
1009
+ let truncationIndex = length;
1010
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
1011
+ let unmatchedStart = 0;
1012
+ let unmatchedEnd = 0;
1013
+ let width = 0;
1014
+ let widthExtra = 0;
1015
+ outer: while (true) {
1016
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
1017
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
1018
+ lengthExtra = 0;
1019
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
1020
+ const codePoint = char.codePointAt(0) || 0;
1021
+ if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
1022
+ else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
1023
+ else widthExtra = REGULAR_WIDTH;
1024
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
1025
+ if (width + widthExtra > LIMIT) {
1026
+ truncationEnabled = true;
1027
+ break outer;
1028
+ }
1029
+ lengthExtra += char.length;
1030
+ width += widthExtra;
1031
+ }
1032
+ unmatchedStart = unmatchedEnd = 0;
1033
+ }
1034
+ if (index >= length) break outer;
1035
+ for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
1036
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
1037
+ BLOCK_RE.lastIndex = index;
1038
+ if (BLOCK_RE.test(input)) {
1039
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
1040
+ widthExtra = lengthExtra * BLOCK_WIDTH;
1041
+ if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
1042
+ if (width + widthExtra > LIMIT) {
1043
+ truncationEnabled = true;
1044
+ break outer;
1045
+ }
1046
+ width += widthExtra;
1047
+ unmatchedStart = indexPrev;
1048
+ unmatchedEnd = index;
1049
+ index = indexPrev = BLOCK_RE.lastIndex;
1050
+ continue outer;
1051
+ }
1052
+ }
1053
+ index += 1;
1054
+ }
1055
+ return {
1056
+ width: truncationEnabled ? truncationLimit : width,
1057
+ index: truncationEnabled ? truncationIndex : length,
1058
+ truncated: truncationEnabled,
1059
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
1060
+ };
1061
+ };
1062
+ const NO_TRUNCATION = {
1063
+ limit: Infinity,
1064
+ ellipsis: "",
1065
+ ellipsisWidth: 0
1066
+ };
1067
+ const fastStringWidth = (input, options = {}) => {
1068
+ return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
1069
+ };
1070
+ const ESC = "\x1B";
1071
+ const CSI = "›";
1072
+ const END_CODE = 39;
1073
+ const ANSI_ESCAPE_BELL = "\x07";
1074
+ const ANSI_CSI = "[";
1075
+ const ANSI_OSC = "]";
1076
+ const ANSI_SGR_TERMINATOR = "m";
1077
+ const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
1078
+ const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
1079
+ const getClosingCode = (openingCode) => {
1080
+ if (openingCode >= 30 && openingCode <= 37) return 39;
1081
+ if (openingCode >= 90 && openingCode <= 97) return 39;
1082
+ if (openingCode >= 40 && openingCode <= 47) return 49;
1083
+ if (openingCode >= 100 && openingCode <= 107) return 49;
1084
+ if (openingCode === 1 || openingCode === 2) return 22;
1085
+ if (openingCode === 3) return 23;
1086
+ if (openingCode === 4) return 24;
1087
+ if (openingCode === 7) return 27;
1088
+ if (openingCode === 8) return 28;
1089
+ if (openingCode === 9) return 29;
1090
+ if (openingCode === 0) return 0;
1091
+ };
1092
+ const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
1093
+ const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
1094
+ const wrapWord = (rows, word, columns) => {
1095
+ const characters = word[Symbol.iterator]();
1096
+ let isInsideEscape = false;
1097
+ let isInsideLinkEscape = false;
1098
+ let lastRow = rows.at(-1);
1099
+ let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
1100
+ let currentCharacter = characters.next();
1101
+ let nextCharacter = characters.next();
1102
+ let rawCharacterIndex = 0;
1103
+ while (!currentCharacter.done) {
1104
+ const character = currentCharacter.value;
1105
+ const characterLength = fastStringWidth(character);
1106
+ if (visible + characterLength <= columns) rows[rows.length - 1] += character;
1107
+ else {
1108
+ rows.push(character);
1109
+ visible = 0;
1110
+ }
1111
+ if (character === ESC || character === CSI) {
1112
+ isInsideEscape = true;
1113
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
1114
+ }
1115
+ if (isInsideEscape) {
1116
+ if (isInsideLinkEscape) {
1117
+ if (character === ANSI_ESCAPE_BELL) {
1118
+ isInsideEscape = false;
1119
+ isInsideLinkEscape = false;
1120
+ }
1121
+ } else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
1122
+ } else {
1123
+ visible += characterLength;
1124
+ if (visible === columns && !nextCharacter.done) {
1125
+ rows.push("");
1126
+ visible = 0;
1127
+ }
1128
+ }
1129
+ currentCharacter = nextCharacter;
1130
+ nextCharacter = characters.next();
1131
+ rawCharacterIndex += character.length;
1132
+ }
1133
+ lastRow = rows.at(-1);
1134
+ if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
1135
+ };
1136
+ const stringVisibleTrimSpacesRight = (string) => {
1137
+ const words = string.split(" ");
1138
+ let last = words.length;
1139
+ while (last) {
1140
+ if (fastStringWidth(words[last - 1])) break;
1141
+ last--;
1142
+ }
1143
+ if (last === words.length) return string;
1144
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
1145
+ };
1146
+ const exec = (string, columns, options = {}) => {
1147
+ if (options.trim !== false && string.trim() === "") return "";
1148
+ let returnValue = "";
1149
+ let escapeCode;
1150
+ let escapeUrl;
1151
+ const words = string.split(" ");
1152
+ let rows = [""];
1153
+ let rowLength = 0;
1154
+ for (let index = 0; index < words.length; index++) {
1155
+ const word = words[index];
1156
+ if (options.trim !== false) {
1157
+ const row = rows.at(-1) ?? "";
1158
+ const trimmed = row.trimStart();
1159
+ if (row.length !== trimmed.length) {
1160
+ rows[rows.length - 1] = trimmed;
1161
+ rowLength = fastStringWidth(trimmed);
1162
+ }
1163
+ }
1164
+ if (index !== 0) {
1165
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
1166
+ rows.push("");
1167
+ rowLength = 0;
1168
+ }
1169
+ if (rowLength || options.trim === false) {
1170
+ rows[rows.length - 1] += " ";
1171
+ rowLength++;
1172
+ }
1173
+ }
1174
+ const wordLength = fastStringWidth(word);
1175
+ if (options.hard && wordLength > columns) {
1176
+ const remainingColumns = columns - rowLength;
1177
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
1178
+ if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
1179
+ wrapWord(rows, word, columns);
1180
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
1181
+ continue;
1182
+ }
1183
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
1184
+ if (options.wordWrap === false && rowLength < columns) {
1185
+ wrapWord(rows, word, columns);
1186
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
1187
+ continue;
1188
+ }
1189
+ rows.push("");
1190
+ rowLength = 0;
1191
+ }
1192
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
1193
+ wrapWord(rows, word, columns);
1194
+ rowLength = fastStringWidth(rows.at(-1) ?? "");
1195
+ continue;
1196
+ }
1197
+ rows[rows.length - 1] += word;
1198
+ rowLength += wordLength;
1199
+ }
1200
+ if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
1201
+ const preString = rows.join("\n");
1202
+ let inSurrogate = false;
1203
+ for (let i = 0; i < preString.length; i++) {
1204
+ const character = preString[i];
1205
+ returnValue += character;
1206
+ if (!inSurrogate) {
1207
+ inSurrogate = character >= "\ud800" && character <= "\udbff";
1208
+ if (inSurrogate) continue;
1209
+ } else inSurrogate = false;
1210
+ if (character === ESC || character === CSI) {
1211
+ GROUP_REGEX.lastIndex = i + 1;
1212
+ const groups = GROUP_REGEX.exec(preString)?.groups;
1213
+ if (groups?.code !== void 0) {
1214
+ const code = Number.parseFloat(groups.code);
1215
+ escapeCode = code === END_CODE ? void 0 : code;
1216
+ } else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
1217
+ }
1218
+ if (preString[i + 1] === "\n") {
1219
+ if (escapeUrl) returnValue += wrapAnsiHyperlink("");
1220
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
1221
+ if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
1222
+ } else if (character === "\n") {
1223
+ if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
1224
+ if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
1225
+ }
1226
+ }
1227
+ return returnValue;
1228
+ };
1229
+ const CRLF_OR_LF = /\r?\n/;
1230
+ function wrapAnsi(string, columns, options) {
1231
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
1232
+ }
1233
+ function isUnicodeSupported() {
1234
+ if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
1235
+ return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
1236
+ }
1237
+ updateSettings({ withGuide: false });
1238
+ /** Wrap using visible columns rather than the length of ANSI escape sequences. */
1239
+ const wrapTextWithPrefix = (output, text, prefix, startPrefix = prefix) => {
1240
+ return wrapAnsi(text, Math.max(1, getColumns(output ?? process.stdout) - Math.max(fastStringWidth$1(prefix), fastStringWidth$1(startPrefix))), {
1241
+ hard: true,
1242
+ trim: false
1243
+ }).split("\n").map((line, index) => `${index === 0 ? startPrefix : prefix}${line}`).join("\n");
1244
+ };
1245
+ const getGuide = (opts) => opts?.withGuide ?? settings.withGuide;
1246
+ const promptTitle = (message, state, opts) => {
1247
+ if (!message.trim()) return "";
1248
+ const hasGuide = getGuide(opts);
1249
+ return `${hasGuide ? `${import_picocolors.default.gray(S_BAR)}\n` : ""}${wrapTextWithPrefix(opts.output, message, hasGuide ? `${symbolBar(state)} ` : " ", `${symbol(state)} `)}\n`;
1250
+ };
1251
+ const optionText = (output, marker, label, format, suffix = "") => {
1252
+ const continuation = " ".repeat(fastStringWidth$1(marker));
1253
+ const width = Math.max(1, getColumns(output ?? process.stdout) - 2 - fastStringWidth$1(marker));
1254
+ const [first, ...rest] = label.split("\n");
1255
+ return wrapAnsi([format(first) + suffix, ...rest.map(format)].join("\n"), width, {
1256
+ hard: true,
1257
+ trim: false
1258
+ }).split("\n").map((line, index) => `${index === 0 ? marker : continuation}${line}`).join("\n");
1259
+ };
1260
+ const SELECT_INSTRUCTIONS = ["↑/↓ navigate", "Enter confirm"];
1261
+ const MULTISELECT_INSTRUCTIONS = [
1262
+ "↑/↓ navigate",
1263
+ "Space select",
1264
+ "Enter confirm"
1265
+ ];
1266
+ const formatInstructionFooter = (instructions, hasGuide, output) => wrapTextWithPrefix(output, import_picocolors.default.dim(instructions.join(" · ")), hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : " ").split("\n");
1267
+ const unicode = isUnicodeSupported();
1268
+ const isCI = () => process.env.CI === "true";
1269
+ const isTTY = (output) => {
1270
+ return output.isTTY === true;
1271
+ };
1272
+ const unicodeOr = (c, fallback) => unicode ? c : fallback;
1273
+ const S_POINTER_ACTIVE = unicodeOr("›", ">");
1274
+ const S_STEP_ACTIVE = S_POINTER_ACTIVE;
1275
+ const S_STEP_CANCEL = unicodeOr("■", "x");
1276
+ const S_STEP_ERROR = unicodeOr("▲", "x");
1277
+ const S_STEP_SUBMIT = unicodeOr("◇", "o");
1278
+ const S_BAR_START = unicodeOr("┌", "T");
1279
+ const S_BAR = unicodeOr("│", "|");
1280
+ const S_BAR_END = unicodeOr("└", "—");
1281
+ const S_BAR_START_RIGHT = unicodeOr("┐", "T");
1282
+ const S_BAR_END_RIGHT = unicodeOr("┘", "—");
1283
+ const S_RADIO_ACTIVE = S_POINTER_ACTIVE;
1284
+ const S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]");
1285
+ const S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]");
1286
+ const S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]");
1287
+ const S_PASSWORD_MASK = unicodeOr("▪", "•");
1288
+ const S_BAR_H = unicodeOr("─", "-");
1289
+ const S_CORNER_TOP_RIGHT = unicodeOr("╮", "+");
1290
+ const S_CORNER_BOTTOM_RIGHT = unicodeOr("╯", "+");
1291
+ const S_CORNER_BOTTOM_LEFT = unicodeOr("╰", "+");
1292
+ const S_CORNER_TOP_LEFT = unicodeOr("╭", "+");
1293
+ const S_INFO = unicodeOr("●", "•");
1294
+ const S_SUCCESS = unicodeOr("◆", "*");
1295
+ const S_WARN = unicodeOr("▲", "!");
1296
+ const S_ERROR = unicodeOr("■", "x");
1297
+ const completeColor = (value) => import_picocolors.default.gray(value);
1298
+ const symbol = (state) => {
1299
+ switch (state) {
1300
+ case "initial":
1301
+ case "active": return import_picocolors.default.blue(S_STEP_ACTIVE);
1302
+ case "cancel": return import_picocolors.default.red(S_STEP_CANCEL);
1303
+ case "error": return import_picocolors.default.yellow(S_STEP_ERROR);
1304
+ case "validating": return import_picocolors.default.dim(S_STEP_ACTIVE);
1305
+ case "submit": return completeColor(S_STEP_SUBMIT);
1306
+ default: return import_picocolors.default.blue(S_STEP_ACTIVE);
1307
+ }
1308
+ };
1309
+ const symbolBar = (state) => {
1310
+ switch (state) {
1311
+ case "initial":
1312
+ case "active": return import_picocolors.default.blue(S_BAR);
1313
+ case "cancel": return import_picocolors.default.red(S_BAR);
1314
+ case "error": return import_picocolors.default.yellow(S_BAR);
1315
+ case "validating": return import_picocolors.default.dim(S_BAR);
1316
+ case "submit": return completeColor(S_BAR);
1317
+ default: return import_picocolors.default.blue(S_BAR);
1318
+ }
1319
+ };
1320
+ const trimLines = (groups, initialLineCount, startIndex, endIndex, maxLines, fromEnd = false) => {
1321
+ let lineCount = initialLineCount;
1322
+ let removals = 0;
1323
+ if (fromEnd) for (let i = endIndex - 1; i >= startIndex; i--) {
1324
+ const group = groups[i];
1325
+ if (group) lineCount -= group.length;
1326
+ removals++;
1327
+ if (lineCount <= maxLines) break;
1328
+ }
1329
+ else for (let i = startIndex; i < endIndex; i++) {
1330
+ const group = groups[i];
1331
+ if (group) lineCount -= group.length;
1332
+ removals++;
1333
+ if (lineCount <= maxLines) break;
1334
+ }
1335
+ return {
1336
+ lineCount,
1337
+ removals
1338
+ };
1339
+ };
1340
+ /**
1341
+ * Trims an option list to what fits the terminal, while keeping the active
1342
+ * option (cursor) visible using a Clack style sliding window.
1343
+ *
1344
+ * @returns The lines to render.
1345
+ *
1346
+ * @see https://bomb.sh/docs/clack/packages/prompts/#limitoptions
1347
+ *
1348
+ * @example
1349
+ * ```ts
1350
+ * import { limitOptions } from '@voidzero-dev/vite-plus-prompts';
1351
+ * import color from 'picocolors';
1352
+ *
1353
+ * const options = ['apple', 'banana', 'cherry', 'date'];
1354
+ * const lines = limitOptions({
1355
+ * options,
1356
+ * cursor: 2,
1357
+ * maxItems: 8,
1358
+ * style: (opt, active) =>
1359
+ * active ? color.blue(opt) : color.dim(opt),
1360
+ * });
1361
+ * ```
1362
+ */
1363
+ const limitOptions = ({ cursor, options, style, output = process.stdout, maxItems = Number.POSITIVE_INFINITY, columnPadding = 0, rowPadding = 4 }) => {
1364
+ const columns = getColumns(output);
1365
+ const maxWidth = Math.max(1, columns - columnPadding);
1366
+ const rows = getRows(output);
1367
+ const overflowFormat = import_picocolors.default.dim("...");
1368
+ const outputMaxItems = Math.max(rows - rowPadding, 0);
1369
+ const computedMaxItems = Math.max(Math.min(maxItems, outputMaxItems), 5);
1370
+ let slidingWindowLocation = 0;
1371
+ if (cursor >= computedMaxItems - 3) slidingWindowLocation = Math.max(Math.min(cursor - computedMaxItems + 3, options.length - computedMaxItems), 0);
1372
+ let shouldRenderTopEllipsis = computedMaxItems < options.length && slidingWindowLocation > 0;
1373
+ let shouldRenderBottomEllipsis = computedMaxItems < options.length && slidingWindowLocation + computedMaxItems < options.length;
1374
+ const slidingWindowLocationEnd = Math.min(slidingWindowLocation + computedMaxItems, options.length);
1375
+ const lineGroups = [];
1376
+ let lineCount = 0;
1377
+ if (shouldRenderTopEllipsis) lineCount++;
1378
+ if (shouldRenderBottomEllipsis) lineCount++;
1379
+ const slidingWindowLocationWithEllipsis = slidingWindowLocation + (shouldRenderTopEllipsis ? 1 : 0);
1380
+ const slidingWindowLocationEndWithEllipsis = slidingWindowLocationEnd - (shouldRenderBottomEllipsis ? 1 : 0);
1381
+ for (let i = slidingWindowLocationWithEllipsis; i < slidingWindowLocationEndWithEllipsis; i++) {
1382
+ const option = options[i];
1383
+ const wrappedLines = wrapAnsi(option === void 0 ? "" : style(option, i === cursor), maxWidth, {
1384
+ hard: true,
1385
+ trim: false
1386
+ }).split("\n");
1387
+ lineGroups.push(wrappedLines);
1388
+ lineCount += wrappedLines.length;
1389
+ }
1390
+ if (lineCount > outputMaxItems) {
1391
+ let precedingRemovals = 0;
1392
+ let followingRemovals = 0;
1393
+ let newLineCount = lineCount;
1394
+ const cursorGroupIndex = cursor - slidingWindowLocationWithEllipsis;
1395
+ let adjustedMax = outputMaxItems;
1396
+ const trimPreceding = () => trimLines(lineGroups, newLineCount, 0, cursorGroupIndex, adjustedMax);
1397
+ const trimFollowing = () => trimLines(lineGroups, newLineCount, cursorGroupIndex + 1, lineGroups.length, adjustedMax, true);
1398
+ if (shouldRenderTopEllipsis) {
1399
+ ({lineCount: newLineCount, removals: precedingRemovals} = trimPreceding());
1400
+ if (newLineCount > adjustedMax) {
1401
+ if (!shouldRenderBottomEllipsis) adjustedMax -= 1;
1402
+ ({lineCount: newLineCount, removals: followingRemovals} = trimFollowing());
1403
+ }
1404
+ } else {
1405
+ if (!shouldRenderBottomEllipsis) adjustedMax -= 1;
1406
+ ({lineCount: newLineCount, removals: followingRemovals} = trimFollowing());
1407
+ if (newLineCount > adjustedMax) {
1408
+ adjustedMax -= 1;
1409
+ ({lineCount: newLineCount, removals: precedingRemovals} = trimPreceding());
1410
+ }
1411
+ }
1412
+ if (precedingRemovals > 0) {
1413
+ shouldRenderTopEllipsis = true;
1414
+ lineGroups.splice(0, precedingRemovals);
1415
+ }
1416
+ if (followingRemovals > 0) {
1417
+ shouldRenderBottomEllipsis = true;
1418
+ lineGroups.splice(lineGroups.length - followingRemovals, followingRemovals);
1419
+ }
1420
+ }
1421
+ const result = [];
1422
+ if (shouldRenderTopEllipsis) result.push(overflowFormat);
1423
+ for (const lineGroup of lineGroups) for (const line of lineGroup) result.push(line);
1424
+ if (shouldRenderBottomEllipsis) result.push(overflowFormat);
1425
+ return result;
1426
+ };
1427
+ const roundedSymbols = [
1428
+ S_CORNER_TOP_LEFT,
1429
+ S_CORNER_TOP_RIGHT,
1430
+ S_CORNER_BOTTOM_LEFT,
1431
+ S_CORNER_BOTTOM_RIGHT
1432
+ ];
1433
+ const squareSymbols = [
1434
+ S_BAR_START,
1435
+ S_BAR_START_RIGHT,
1436
+ S_BAR_END,
1437
+ S_BAR_END_RIGHT
1438
+ ];
1439
+ function getPaddingForLine(lineLength, innerWidth, padding, contentAlign) {
1440
+ let leftPadding = padding;
1441
+ let rightPadding = padding;
1442
+ if (contentAlign === "center") leftPadding = Math.floor((innerWidth - lineLength) / 2);
1443
+ else if (contentAlign === "right") leftPadding = innerWidth - lineLength - padding;
1444
+ rightPadding = innerWidth - leftPadding - lineLength;
1445
+ return [leftPadding, rightPadding];
1446
+ }
1447
+ const defaultFormatBorder = import_picocolors.default.gray;
1448
+ const box = (message = "", title = "", opts) => {
1449
+ const output = opts?.output ?? process.stdout;
1450
+ const columns = getColumns(output);
1451
+ const borderTotalWidth = 2;
1452
+ let titlePadding = Math.max(0, opts?.titlePadding ?? 1);
1453
+ let contentPadding = Math.max(0, opts?.contentPadding ?? 2);
1454
+ const width = opts?.width === void 0 || opts.width === "auto" ? 1 : Math.max(0, Math.min(1, opts.width));
1455
+ const linePrefix = !getGuide(opts) ? "" : `${import_picocolors.default.gray(S_BAR)} `;
1456
+ const formatBorder = opts?.formatBorder ?? defaultFormatBorder;
1457
+ const symbols = (opts?.rounded !== false ? roundedSymbols : squareSymbols).map(formatBorder);
1458
+ const hSymbol = formatBorder(S_BAR_H);
1459
+ const vSymbol = formatBorder(S_BAR);
1460
+ const linePrefixWidth = fastStringWidth$1(linePrefix);
1461
+ const titleWidth = fastStringWidth$1(title);
1462
+ const maxBoxWidth = columns - linePrefixWidth;
1463
+ let boxWidth = Math.max(Math.min(8, maxBoxWidth), Math.floor(columns * width) - linePrefixWidth);
1464
+ if (opts?.width === "auto") {
1465
+ const lines = message.split("\n");
1466
+ let longestLine = titleWidth + titlePadding * 2;
1467
+ for (const line of lines) {
1468
+ const lineWithPadding = fastStringWidth$1(line) + contentPadding * 2;
1469
+ if (lineWithPadding > longestLine) longestLine = lineWithPadding;
1470
+ }
1471
+ const longestLineWidth = longestLine + borderTotalWidth;
1472
+ if (longestLineWidth < boxWidth) boxWidth = longestLineWidth;
1473
+ }
1474
+ if (boxWidth % 2 !== 0) {
1475
+ if (boxWidth < maxBoxWidth) boxWidth++;
1476
+ else boxWidth--;
1477
+ }
1478
+ const innerWidth = Math.max(0, boxWidth - borderTotalWidth);
1479
+ titlePadding = Math.min(titlePadding, Math.floor(innerWidth / 2));
1480
+ contentPadding = Math.min(contentPadding, Math.max(0, Math.floor((innerWidth - 1) / 2)));
1481
+ const maxTitleLength = innerWidth - titlePadding * 2;
1482
+ let truncatedTitle = title;
1483
+ if (titleWidth > maxTitleLength) {
1484
+ truncatedTitle = "";
1485
+ const suffix = maxTitleLength > 0 ? "…" : "";
1486
+ for (const { segment } of new Intl.Segmenter().segment(stripVTControlCharacters(title))) {
1487
+ if (fastStringWidth$1(truncatedTitle + segment + suffix) > maxTitleLength) break;
1488
+ truncatedTitle += segment;
1489
+ }
1490
+ truncatedTitle += suffix;
1491
+ }
1492
+ const [titlePaddingLeft, titlePaddingRight] = getPaddingForLine(fastStringWidth$1(truncatedTitle), innerWidth, titlePadding, opts?.titleAlign);
1493
+ const wrappedMessage = wrapAnsi(message, Math.max(1, innerWidth - contentPadding * 2), {
1494
+ hard: true,
1495
+ trim: false
1496
+ });
1497
+ output.write(`${linePrefix}${symbols[0]}${hSymbol.repeat(titlePaddingLeft)}${truncatedTitle}${hSymbol.repeat(titlePaddingRight)}${symbols[1]}\n`);
1498
+ const wrappedLines = wrappedMessage.split("\n");
1499
+ for (const line of wrappedLines) {
1500
+ const [leftLinePadding, rightLinePadding] = getPaddingForLine(fastStringWidth$1(line), innerWidth, contentPadding, opts?.contentAlign);
1501
+ output.write(`${linePrefix}${vSymbol}${" ".repeat(leftLinePadding)}${line}${" ".repeat(rightLinePadding)}${vSymbol}\n`);
1502
+ }
1503
+ output.write(`${linePrefix}${symbols[2]}${hSymbol.repeat(innerWidth)}${symbols[3]}\n`);
1504
+ };
1505
+ /**
1506
+ * Render-milestone markers for the PTY snapshot suite
1507
+ * (crates/vp_cli_snapshots): invisible window-title updates the runner
1508
+ * synchronizes on via `expect-milestone` interactions. Emission is gated on
1509
+ * `VP_EMIT_MILESTONES=1`, which only the runner sets; real terminals and
1510
+ * piped output never see these markers as content (they only update the
1511
+ * window title, which the runner's PTY captures).
1512
+ *
1513
+ * Protocol (shared with vite-task's `pty_terminal_test_client` crate):
1514
+ * `OSC 2 ; pty-terminal-test:<32-hex-id>:<base64url(name)> ST`. The runner
1515
+ * decodes the title with `decode_milestone_title`, ignoring ordinary title
1516
+ * updates. A fresh random id per emission keeps repeated milestones with the
1517
+ * same name observable as distinct title changes through Windows ConPTY.
1518
+ */
1519
+ const MILESTONE_TITLE_MARKER = "pty-terminal-test:";
1520
+ const OSC2_OPEN = "\x1B]2;";
1521
+ const ST = "\x1B\\";
1522
+ const MILESTONES_ENABLED = process.env.VP_EMIT_MILESTONES === "1";
1523
+ /**
1524
+ * Returns the encoded milestone byte sequence for `name`, or an empty string
1525
+ * when emission is disabled. Append the result to a rendered prompt frame so
1526
+ * the marker arrives in the output stream together with the render it marks.
1527
+ */
1528
+ function milestone(name) {
1529
+ if (!MILESTONES_ENABLED) return "";
1530
+ const id = randomBytes(16).toString("hex");
1531
+ const encodedName = Buffer.from(name, "utf8").toString("base64url");
1532
+ return `${OSC2_OPEN}${MILESTONE_TITLE_MARKER}${id}:${encodedName}${ST}`;
1533
+ }
1534
+ /**
1535
+ * Milestone for a prompt render, following the runner naming convention
1536
+ * `<kind>:<id>:<state>` (e.g. `select:template:1`, `confirm:approve:yes`,
1537
+ * `text:project-name:my-app`). `id` defaults to the prompt kind; pass
1538
+ * `testId` at ambiguous call sites (multiple prompts of one kind in a flow).
1539
+ */
1540
+ function promptMilestone(kind, id, state) {
1541
+ return milestone(`${kind}:${id ?? kind}:${state}`);
1542
+ }
1543
+ const confirm = (opts) => {
1544
+ const active = opts.active ?? "Yes";
1545
+ const inactive = opts.inactive ?? "No";
1546
+ return new r({
1547
+ active,
1548
+ inactive,
1549
+ signal: opts.signal,
1550
+ input: opts.input,
1551
+ accessible: opts.accessible,
1552
+ output: opts.output,
1553
+ initialValue: opts.initialValue ?? true,
1554
+ render() {
1555
+ const hasGuide = getGuide(opts);
1556
+ const nestedPrefix = " ";
1557
+ const title = promptTitle(opts.message, this.state, opts);
1558
+ const value = this.value ? active : inactive;
1559
+ switch (this.state) {
1560
+ case "submit": return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${import_picocolors.default.dim(value)}\n${promptMilestone("confirm", opts.testId, "submit")}`;
1561
+ case "cancel": return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${import_picocolors.default.strikethrough(import_picocolors.default.dim(value))}${hasGuide ? `\n${import_picocolors.default.gray(S_BAR)}` : ""}\n${promptMilestone("confirm", opts.testId, "cancel")}`;
1562
+ default: {
1563
+ const defaultPrefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
1564
+ const defaultPrefixEnd = hasGuide ? import_picocolors.default.blue(S_BAR_END) : "";
1565
+ return `${title}${defaultPrefix}${this.value ? `${import_picocolors.default.blue(S_POINTER_ACTIVE)} ${import_picocolors.default.bold(active)}` : `${import_picocolors.default.dim(" ")} ${import_picocolors.default.dim(active)}`}${opts.vertical ? hasGuide ? `\n${import_picocolors.default.blue(S_BAR)} ` : `\n${nestedPrefix}` : ` ${import_picocolors.default.dim("/")} `}${!this.value ? `${import_picocolors.default.blue(S_POINTER_ACTIVE)} ${import_picocolors.default.bold(inactive)}` : `${import_picocolors.default.dim(" ")} ${import_picocolors.default.dim(inactive)}`}${hasGuide ? `\n${defaultPrefixEnd}` : ""}\n${promptMilestone("confirm", opts.testId, this.value ? "yes" : "no")}`;
1566
+ }
1567
+ }
1568
+ }
1569
+ }).prompt();
1570
+ };
1571
+ const log = {
1572
+ message: (message = [], { symbol, secondarySymbol = import_picocolors.default.gray(S_BAR), output = process.stdout, spacing = 0, withGuide } = {}) => {
1573
+ const parts = [];
1574
+ const hasGuide = getGuide({ withGuide });
1575
+ const spacingString = !hasGuide ? "" : secondarySymbol;
1576
+ const prefix = symbol ? `${symbol} ` : hasGuide ? `${secondarySymbol} ` : "";
1577
+ const marker = symbol ?? secondarySymbol;
1578
+ const secondaryPrefix = hasGuide ? `${secondarySymbol} ` : symbol ? " " : "";
1579
+ for (let i = 0; i < spacing; i++) parts.push(spacingString);
1580
+ const messageParts = Array.isArray(message) ? message : message.split("\n");
1581
+ if (messageParts.length > 0) {
1582
+ const [firstLine, ...lines] = messageParts;
1583
+ if (firstLine.length > 0) parts.push(wrapTextWithPrefix(output, firstLine, secondaryPrefix, prefix));
1584
+ else parts.push(hasGuide || symbol ? marker : "");
1585
+ for (const ln of lines) if (ln.length > 0) parts.push(wrapTextWithPrefix(output, ln, secondaryPrefix));
1586
+ else parts.push(hasGuide ? secondarySymbol : "");
1587
+ }
1588
+ output.write(`${parts.join("\n")}\n`);
1589
+ },
1590
+ info: (message, opts) => {
1591
+ log.message(message, {
1592
+ ...opts,
1593
+ symbol: import_picocolors.default.blue(S_INFO)
1594
+ });
1595
+ },
1596
+ success: (message, opts) => {
1597
+ log.message(message, {
1598
+ ...opts,
1599
+ symbol: completeColor(S_SUCCESS)
1600
+ });
1601
+ },
1602
+ step: (message, opts) => {
1603
+ log.message(message, {
1604
+ ...opts,
1605
+ symbol: completeColor(S_STEP_SUBMIT)
1606
+ });
1607
+ },
1608
+ warn: (message, opts) => {
1609
+ log.message(message, {
1610
+ ...opts,
1611
+ symbol: import_picocolors.default.yellow(S_WARN)
1612
+ });
1613
+ },
1614
+ /** alias for `log.warn()`. */
1615
+ warning: (message, opts) => {
1616
+ log.warn(message, opts);
1617
+ },
1618
+ error: (message, opts) => {
1619
+ log.message(message, {
1620
+ ...opts,
1621
+ symbol: import_picocolors.default.red(S_ERROR)
1622
+ });
1623
+ }
1624
+ };
1625
+ const cancel = (message = "", opts) => {
1626
+ const output = opts?.output ?? process.stdout;
1627
+ const prefix = getGuide(opts) ? `${import_picocolors.default.gray(S_BAR_END)} ` : "";
1628
+ output.write(`${prefix}${import_picocolors.default.red(message)}\n\n`);
1629
+ };
1630
+ const intro = (title = "", opts) => {
1631
+ const output = opts?.output ?? process.stdout;
1632
+ const prefix = getGuide(opts) ? `${import_picocolors.default.gray(S_BAR_START)} ` : "";
1633
+ output.write(`${prefix}${title}\n\n`);
1634
+ };
1635
+ const outro = (message = "", opts) => {
1636
+ const output = opts?.output ?? process.stdout;
1637
+ const prefix = getGuide(opts) ? `${import_picocolors.default.gray(S_BAR)}\n${import_picocolors.default.gray(S_BAR_END)} ` : "";
1638
+ output.write(`${prefix}${message}\n\n`);
1639
+ };
1640
+ const computeLabel$1 = (label, format) => {
1641
+ return label.split("\n").map((line) => format(line)).join("\n");
1642
+ };
1643
+ const multiselect = (opts) => {
1644
+ const withMarkerAndCheckbox = (marker, checkbox, _width, label, format, suffix = "") => optionText(opts.output, `${marker} ${checkbox} `, label, format, suffix);
1645
+ const opt = (option, state) => {
1646
+ const label = option.label ?? String(option.value);
1647
+ const hint = option.hint ? ` ${import_picocolors.default.gray(`(${option.hint})`)}` : "";
1648
+ if (state === "disabled") return withMarkerAndCheckbox(import_picocolors.default.gray(" "), import_picocolors.default.gray(S_CHECKBOX_INACTIVE), S_CHECKBOX_INACTIVE.length, label, (str) => import_picocolors.default.strikethrough(import_picocolors.default.gray(str)), option.hint ? ` ${import_picocolors.default.dim(`(${option.hint ?? "disabled"})`)}` : "");
1649
+ if (state === "active") return withMarkerAndCheckbox(import_picocolors.default.blue(S_POINTER_ACTIVE), import_picocolors.default.blue(S_CHECKBOX_ACTIVE), S_CHECKBOX_ACTIVE.length, label, (text) => import_picocolors.default.blue(import_picocolors.default.bold(text)), hint);
1650
+ if (state === "selected") return withMarkerAndCheckbox(import_picocolors.default.dim(" "), import_picocolors.default.blue(S_CHECKBOX_SELECTED), S_CHECKBOX_SELECTED.length, label, import_picocolors.default.dim);
1651
+ if (state === "cancelled") return computeLabel$1(label, (text) => import_picocolors.default.strikethrough(import_picocolors.default.dim(text)));
1652
+ if (state === "active-selected") return withMarkerAndCheckbox(import_picocolors.default.blue(S_POINTER_ACTIVE), import_picocolors.default.blue(S_CHECKBOX_SELECTED), S_CHECKBOX_SELECTED.length, label, (text) => import_picocolors.default.blue(import_picocolors.default.bold(text)), hint);
1653
+ if (state === "submitted") return computeLabel$1(label, import_picocolors.default.dim);
1654
+ return withMarkerAndCheckbox(import_picocolors.default.dim(" "), import_picocolors.default.dim(S_CHECKBOX_INACTIVE), S_CHECKBOX_INACTIVE.length, label, import_picocolors.default.dim);
1655
+ };
1656
+ const required = opts.required ?? true;
1657
+ return new a({
1658
+ options: opts.options,
1659
+ signal: opts.signal,
1660
+ input: opts.input,
1661
+ accessible: opts.accessible,
1662
+ output: opts.output,
1663
+ initialValues: opts.initialValues,
1664
+ required,
1665
+ cursorAt: opts.cursorAt,
1666
+ validate(selected) {
1667
+ if (required && (selected === void 0 || selected.length === 0)) return "Please select at least one option.";
1668
+ },
1669
+ render() {
1670
+ const hasGuide = getGuide(opts);
1671
+ const nestedPrefix = " ";
1672
+ const title = promptTitle(opts.message, this.state, opts);
1673
+ const value = this.value ?? [];
1674
+ const instructions = opts.showInstructions === false ? [] : formatInstructionFooter(MULTISELECT_INSTRUCTIONS, hasGuide, opts.output);
1675
+ const hint = instructions.join("\n");
1676
+ const styleOption = (option, active) => {
1677
+ if (option.disabled) return opt(option, "disabled");
1678
+ const selected = value.includes(option.value);
1679
+ if (active && selected) return opt(option, "active-selected");
1680
+ if (selected) return opt(option, "selected");
1681
+ return opt(option, active ? "active" : "inactive");
1682
+ };
1683
+ switch (this.state) {
1684
+ case "submit": {
1685
+ const submitText = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none");
1686
+ const submitPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
1687
+ return `${title}${wrapTextWithPrefix(opts.output, submitText, submitPrefix)}\n`;
1688
+ }
1689
+ case "cancel": {
1690
+ const label = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "cancelled")).join(import_picocolors.default.dim(", "));
1691
+ if (label.trim() === "") return hasGuide ? `${title}${import_picocolors.default.gray(S_BAR)}\n` : `${title.trimEnd()}\n`;
1692
+ const cancelPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
1693
+ const wrappedLabel = wrapTextWithPrefix(opts.output, label, cancelPrefix);
1694
+ return hasGuide ? `${title}${wrappedLabel}\n${import_picocolors.default.gray(S_BAR)}\n` : `${title}${wrappedLabel}\n`;
1695
+ }
1696
+ case "error": {
1697
+ const prefix = hasGuide ? `${import_picocolors.default.yellow(S_BAR)} ` : nestedPrefix;
1698
+ const footer = wrapTextWithPrefix(opts.output, import_picocolors.default.yellow(this.error), hasGuide ? `${import_picocolors.default.yellow(S_BAR_END)} ` : nestedPrefix);
1699
+ const titleLineCount = title.split("\n").length;
1700
+ const footerLineCount = footer.split("\n").length + instructions.length + 1;
1701
+ return `${title}${prefix}${limitOptions({
1702
+ output: opts.output,
1703
+ options: this.options,
1704
+ cursor: this.cursor,
1705
+ maxItems: opts.maxItems,
1706
+ columnPadding: 2,
1707
+ rowPadding: titleLineCount + footerLineCount,
1708
+ style: styleOption
1709
+ }).join(`\n${prefix}`)}\n${hint}\n${footer}\n`;
1710
+ }
1711
+ default: {
1712
+ const prefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
1713
+ const titleLineCount = title.split("\n").length;
1714
+ const footerLineCount = instructions.length + (hasGuide ? 2 : 1);
1715
+ return `${title}${prefix}${limitOptions({
1716
+ output: opts.output,
1717
+ options: this.options,
1718
+ cursor: this.cursor,
1719
+ maxItems: opts.maxItems,
1720
+ columnPadding: 2,
1721
+ rowPadding: titleLineCount + footerLineCount,
1722
+ style: styleOption
1723
+ }).join(`\n${prefix}`)}\n${hint}${hasGuide ? `\n${import_picocolors.default.blue(S_BAR_END)}` : ""}\n`;
1724
+ }
1725
+ }
1726
+ }
1727
+ }).prompt();
1728
+ };
1729
+ /** A compact, enclosed note. Guide bars never replace its side borders. */
1730
+ const note = (message = "", title = "", opts) => {
1731
+ const content = opts?.format ? message.split("\n").map(opts.format).join("\n") : message;
1732
+ box(`\n${content}\n`, title, {
1733
+ ...opts,
1734
+ width: "auto",
1735
+ rounded: true,
1736
+ formatBorder: import_picocolors.default.gray
1737
+ });
1738
+ };
1739
+ const password = (opts) => {
1740
+ return new u$1({
1741
+ validate: opts.validate,
1742
+ mask: opts.mask ?? S_PASSWORD_MASK,
1743
+ signal: opts.signal,
1744
+ input: opts.input,
1745
+ accessible: opts.accessible,
1746
+ output: opts.output,
1747
+ render() {
1748
+ const hasGuide = getGuide(opts);
1749
+ const nestedPrefix = " ";
1750
+ const title = promptTitle(opts.message, this.state, opts);
1751
+ const userInput = !this.userInput && opts.placeholder ? import_picocolors.default.dim(opts.placeholder) : this.userInputWithCursor;
1752
+ const masked = this.masked;
1753
+ switch (this.state) {
1754
+ case "validating": {
1755
+ const prefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
1756
+ return `${title}${prefix}${import_picocolors.default.dim(masked ?? "")}\n${prefix}${import_picocolors.default.dim("Validating…")}\n`;
1757
+ }
1758
+ case "error": {
1759
+ const errorPrefix = hasGuide ? `${import_picocolors.default.yellow(S_BAR)} ` : nestedPrefix;
1760
+ const errorPrefixEnd = hasGuide ? `${import_picocolors.default.yellow(S_BAR_END)} ` : "";
1761
+ const maskedText = masked ?? "";
1762
+ if (opts.clearOnError) this.clear();
1763
+ return `${title.trim()}\n${errorPrefix}${maskedText}\n${wrapTextWithPrefix(opts.output, import_picocolors.default.yellow(this.error), hasGuide ? errorPrefixEnd : nestedPrefix)}\n`;
1764
+ }
1765
+ case "submit": return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${masked ? import_picocolors.default.dim(masked) : ""}\n`;
1766
+ case "cancel": return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${masked ? import_picocolors.default.strikethrough(import_picocolors.default.dim(masked)) : ""}${masked && hasGuide ? `\n${import_picocolors.default.gray(S_BAR)}` : ""}\n`;
1767
+ default: {
1768
+ const defaultPrefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
1769
+ const defaultPrefixEnd = hasGuide ? import_picocolors.default.blue(S_BAR_END) : "";
1770
+ return `${title}${defaultPrefix}${userInput}${hasGuide ? `\n${defaultPrefixEnd}` : ""}\n`;
1771
+ }
1772
+ }
1773
+ }
1774
+ }).prompt();
1775
+ };
1776
+ const defaultStyleFn = import_picocolors.default.blue;
1777
+ const removeTrailingDots = (msg) => {
1778
+ return msg.replace(/\.+$/, "");
1779
+ };
1780
+ const formatTimer = (durationMs) => {
1781
+ const duration = durationMs / 1e3;
1782
+ const min = Math.floor(duration / 60);
1783
+ const secs = Math.floor(duration % 60);
1784
+ return import_picocolors.default.gray(min > 0 ? `(${min}m ${secs}s)` : `(${secs}s)`);
1785
+ };
1786
+ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancelMessage, errorMessage, frames = unicode ? [
1787
+ "◒",
1788
+ "◐",
1789
+ "◓",
1790
+ "◑"
1791
+ ] : [
1792
+ "•",
1793
+ "o",
1794
+ "O",
1795
+ "0"
1796
+ ], delay = unicode ? 80 : 120, signal, ...opts } = {}) => {
1797
+ const isCI$1 = isCI() || !isTTY(output) || isAccessible(opts.accessible);
1798
+ let unblock;
1799
+ let loop;
1800
+ let isSpinnerActive = false;
1801
+ let isCancelled = false;
1802
+ let _message = "";
1803
+ let _prevMessage;
1804
+ let _origin = performance.now();
1805
+ let _elapsedMs = 0;
1806
+ const columns = getColumns(output);
1807
+ const styleFn = opts?.styleFrame ?? defaultStyleFn;
1808
+ const getElapsedMs = () => {
1809
+ if (!isSpinnerActive) return _elapsedMs;
1810
+ return _elapsedMs + (performance.now() - _origin);
1811
+ };
1812
+ const handleExit = (code) => {
1813
+ const msg = code > 1 ? errorMessage ?? settings.messages.error : cancelMessage ?? settings.messages.cancel;
1814
+ isCancelled = code === 1;
1815
+ if (isSpinnerActive) {
1816
+ _stop(msg, code);
1817
+ if (isCancelled && typeof onCancel === "function") onCancel();
1818
+ }
1819
+ };
1820
+ const errorEventHandler = () => handleExit(2);
1821
+ const signalEventHandler = () => handleExit(1);
1822
+ const registerHooks = () => {
1823
+ process.on("uncaughtExceptionMonitor", errorEventHandler);
1824
+ process.on("unhandledRejection", errorEventHandler);
1825
+ process.on("SIGINT", signalEventHandler);
1826
+ process.on("SIGTERM", signalEventHandler);
1827
+ process.on("exit", handleExit);
1828
+ if (signal) signal.addEventListener("abort", signalEventHandler);
1829
+ };
1830
+ const clearHooks = () => {
1831
+ process.removeListener("uncaughtExceptionMonitor", errorEventHandler);
1832
+ process.removeListener("unhandledRejection", errorEventHandler);
1833
+ process.removeListener("SIGINT", signalEventHandler);
1834
+ process.removeListener("SIGTERM", signalEventHandler);
1835
+ process.removeListener("exit", handleExit);
1836
+ if (signal) signal.removeEventListener("abort", signalEventHandler);
1837
+ };
1838
+ const clearPrevMessage = () => {
1839
+ if (_prevMessage === void 0) return;
1840
+ if (isCI$1) return;
1841
+ const prevLines = wrapAnsi(_prevMessage, columns, {
1842
+ hard: true,
1843
+ trim: false
1844
+ }).split("\n");
1845
+ if (prevLines.length > 1) output.write(import_src.cursor.up(prevLines.length - 1));
1846
+ output.write(import_src.cursor.to(0));
1847
+ output.write(import_src.erase.down());
1848
+ };
1849
+ const hasGuide = getGuide(opts);
1850
+ const startLoop = () => {
1851
+ isSpinnerActive = true;
1852
+ unblock = isCI$1 ? () => {} : block({ output });
1853
+ _origin = performance.now();
1854
+ _prevMessage = void 0;
1855
+ if (hasGuide) output.write(`${import_picocolors.default.gray(S_BAR)}\n`);
1856
+ let frameIndex = 0;
1857
+ let indicatorTimer = 0;
1858
+ registerHooks();
1859
+ const renderFrame = () => {
1860
+ if (isCI$1 && _prevMessage !== void 0) return;
1861
+ clearPrevMessage();
1862
+ const frame = styleFn(frames[frameIndex] ?? (unicode ? "◒" : "o"));
1863
+ let outputMessage;
1864
+ if (isCI$1) outputMessage = `${frame} ${_message}...`;
1865
+ else if (indicator === "timer") outputMessage = `${frame} ${_message} ${formatTimer(getElapsedMs())}`;
1866
+ else {
1867
+ const loadingDots = ".".repeat(Math.floor(indicatorTimer)).slice(0, 3);
1868
+ outputMessage = `${frame} ${_message}${loadingDots}`;
1869
+ }
1870
+ const wrapped = wrapAnsi(outputMessage, columns, {
1871
+ hard: true,
1872
+ trim: false
1873
+ });
1874
+ output.write(isCI$1 ? `${wrapped}\n` : wrapped);
1875
+ _prevMessage = wrapped;
1876
+ frameIndex = frameIndex + 1 < frames.length ? frameIndex + 1 : 0;
1877
+ indicatorTimer = indicatorTimer < 4 ? indicatorTimer + .125 : 0;
1878
+ };
1879
+ renderFrame();
1880
+ if (!isCI$1) loop = setInterval(renderFrame, delay);
1881
+ if (signal?.aborted) signalEventHandler();
1882
+ };
1883
+ const start = (msg = "") => {
1884
+ if (isSpinnerActive) return;
1885
+ isCancelled = false;
1886
+ _elapsedMs = 0;
1887
+ _message = removeTrailingDots(msg);
1888
+ startLoop();
1889
+ };
1890
+ const _stop = (msg = "", code = 0, silent = false, preserveElapsed = false) => {
1891
+ if (!isSpinnerActive) return;
1892
+ const elapsedMs = getElapsedMs();
1893
+ isSpinnerActive = false;
1894
+ isCancelled = code === 1;
1895
+ clearInterval(loop);
1896
+ clearPrevMessage();
1897
+ const step = code === 0 ? completeColor(S_STEP_SUBMIT) : code === 1 ? import_picocolors.default.red(S_STEP_CANCEL) : import_picocolors.default.red(S_STEP_ERROR);
1898
+ _message = msg ?? _message;
1899
+ if (!silent) {
1900
+ if (indicator === "timer") output.write(`${step} ${_message} ${formatTimer(elapsedMs)}\n`);
1901
+ else output.write(`${step} ${_message}\n`);
1902
+ }
1903
+ if (!preserveElapsed) _elapsedMs = 0;
1904
+ _prevMessage = void 0;
1905
+ clearHooks();
1906
+ unblock?.();
1907
+ };
1908
+ const pause = () => {
1909
+ if (!isSpinnerActive) return;
1910
+ _elapsedMs = getElapsedMs();
1911
+ _stop(_message, 0, true, true);
1912
+ };
1913
+ const resume = (msg = _message) => {
1914
+ if (isSpinnerActive) return;
1915
+ _message = removeTrailingDots(msg);
1916
+ startLoop();
1917
+ };
1918
+ const stop = (msg = "") => _stop(msg, 0);
1919
+ const cancel = (msg = "") => _stop(msg, 1);
1920
+ const error = (msg = "") => _stop(msg, 2);
1921
+ const clear = () => _stop("", 0, true);
1922
+ const message = (msg = "") => {
1923
+ _message = removeTrailingDots(msg ?? _message);
1924
+ };
1925
+ return {
1926
+ start,
1927
+ pause,
1928
+ resume,
1929
+ stop,
1930
+ message,
1931
+ cancel,
1932
+ error,
1933
+ clear,
1934
+ get isCancelled() {
1935
+ return isCancelled;
1936
+ }
1937
+ };
1938
+ };
1939
+ const computeLabel = (label, format) => {
1940
+ if (!label.includes("\n")) return format(label);
1941
+ return label.split("\n").map((line) => format(line)).join("\n");
1942
+ };
1943
+ const select = (opts) => {
1944
+ const withMarker = (marker, label, format, suffix = "") => optionText(opts.output, `${marker} `, label, format, suffix);
1945
+ const opt = (option, state) => {
1946
+ if (!option) return "";
1947
+ const label = option.label ?? String(option.value);
1948
+ const hint = option.hint ? `: ${import_picocolors.default.gray(option.hint)}` : "";
1949
+ switch (state) {
1950
+ case "disabled": return withMarker(import_picocolors.default.gray(" "), label, (text) => import_picocolors.default.strikethrough(import_picocolors.default.gray(text)), option.hint ? `: ${import_picocolors.default.gray(option.hint ?? "disabled")}` : "");
1951
+ case "selected": return computeLabel(label, import_picocolors.default.dim);
1952
+ case "active": return withMarker(import_picocolors.default.blue(S_POINTER_ACTIVE), label, (text) => import_picocolors.default.blue(import_picocolors.default.bold(text)), hint);
1953
+ case "cancelled": return computeLabel(label, (str) => import_picocolors.default.strikethrough(import_picocolors.default.dim(str)));
1954
+ default: return withMarker(import_picocolors.default.dim(" "), label, import_picocolors.default.dim);
1955
+ }
1956
+ };
1957
+ return new n$1({
1958
+ options: opts.options,
1959
+ signal: opts.signal,
1960
+ input: opts.input,
1961
+ accessible: opts.accessible,
1962
+ output: opts.output,
1963
+ initialValue: opts.initialValue,
1964
+ render() {
1965
+ const hasGuide = getGuide(opts);
1966
+ const nestedPrefix = " ";
1967
+ const title = promptTitle(opts.message, this.state, opts);
1968
+ switch (this.state) {
1969
+ case "submit": {
1970
+ const submitPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
1971
+ return `${title}${wrapTextWithPrefix(opts.output, opt(this.options[this.cursor], "selected"), submitPrefix)}\n${promptMilestone("select", opts.testId, "submit")}`;
1972
+ }
1973
+ case "cancel": {
1974
+ const cancelPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
1975
+ return `${title}${wrapTextWithPrefix(opts.output, opt(this.options[this.cursor], "cancelled"), cancelPrefix)}${hasGuide ? `\n${import_picocolors.default.gray(S_BAR)}` : ""}\n${promptMilestone("select", opts.testId, "cancel")}`;
1976
+ }
1977
+ default: {
1978
+ const prefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
1979
+ const footer = opts.showInstructions === false ? [] : formatInstructionFooter(SELECT_INSTRUCTIONS, hasGuide, opts.output);
1980
+ if (hasGuide) footer.push(import_picocolors.default.blue(S_BAR_END));
1981
+ const prefixEnd = footer.join("\n");
1982
+ const titleLineCount = title ? title.split("\n").length : 0;
1983
+ const footerLineCount = footer.length + 1;
1984
+ return `${title}${prefix}${limitOptions({
1985
+ output: opts.output,
1986
+ cursor: this.cursor,
1987
+ options: this.options,
1988
+ maxItems: opts.maxItems,
1989
+ columnPadding: 2,
1990
+ rowPadding: titleLineCount + footerLineCount,
1991
+ style: (item, active) => opt(item, item.disabled ? "disabled" : active ? "active" : "inactive")
1992
+ }).join(`\n${prefix}`)}\n${prefixEnd}\n${promptMilestone("select", opts.testId, String(this.cursor))}`;
1993
+ }
1994
+ }
1995
+ }
1996
+ }).prompt();
1997
+ };
1998
+ const text = (opts) => {
1999
+ return new n({
2000
+ validate: opts.validate,
2001
+ placeholder: opts.placeholder,
2002
+ defaultValue: opts.defaultValue,
2003
+ initialValue: opts.initialValue,
2004
+ output: opts.output,
2005
+ signal: opts.signal,
2006
+ input: opts.input,
2007
+ accessible: opts.accessible,
2008
+ render() {
2009
+ const hasGuide = getGuide(opts);
2010
+ const nestedPrefix = " ";
2011
+ const title = promptTitle(opts.message, this.state, opts);
2012
+ const placeholder = opts.placeholder ? import_picocolors.default.inverse(opts.placeholder[0]) + import_picocolors.default.dim(opts.placeholder.slice(1)) : import_picocolors.default.inverse(import_picocolors.default.hidden("_"));
2013
+ const userInput = !this.userInput ? placeholder : this.userInputWithCursor;
2014
+ const value = this.value ?? "";
2015
+ switch (this.state) {
2016
+ case "validating": {
2017
+ const prefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
2018
+ return `${title}${prefix}${import_picocolors.default.dim(value)}\n${prefix}${import_picocolors.default.dim("Validating…")}\n`;
2019
+ }
2020
+ case "error": {
2021
+ const errorText = this.error ? wrapTextWithPrefix(opts.output, import_picocolors.default.yellow(this.error), hasGuide ? `${import_picocolors.default.yellow(S_BAR_END)} ` : nestedPrefix) : "";
2022
+ const errorPrefix = hasGuide ? `${import_picocolors.default.yellow(S_BAR)} ` : nestedPrefix;
2023
+ return `${title.trim()}\n${errorPrefix}${userInput}\n${errorText}\n${promptMilestone("text", opts.testId, "error")}`;
2024
+ }
2025
+ case "submit": {
2026
+ const valueText = value ? import_picocolors.default.dim(value) : "";
2027
+ return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${valueText}\n${promptMilestone("text", opts.testId, "submit")}`;
2028
+ }
2029
+ case "cancel": {
2030
+ const valueText = value ? import_picocolors.default.strikethrough(import_picocolors.default.dim(value)) : "";
2031
+ const cancelPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
2032
+ return `${title}${cancelPrefix}${valueText}${value.trim() ? `\n${cancelPrefix}` : ""}\n${promptMilestone("text", opts.testId, "cancel")}`;
2033
+ }
2034
+ default: {
2035
+ const defaultPrefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
2036
+ const defaultPrefixEnd = hasGuide ? import_picocolors.default.blue(S_BAR_END) : "";
2037
+ return `${title}${defaultPrefix}${userInput}${hasGuide ? `\n${defaultPrefixEnd}` : ""}\n${promptMilestone("text", opts.testId, this.value ?? "")}`;
2038
+ }
2039
+ }
2040
+ }
2041
+ }).prompt();
2042
+ };
2043
+ //#endregion
2044
+ export { wrapTextWithPrefix as $, confirm as A, note as B, S_STEP_ERROR as C, box as D, S_WARN as E, isTTY as F, promptTitle as G, outro as H, limitOptions as I, symbol as J, select as K, log as L, getGuide as M, intro as N, cancel as O, isCI as P, unicodeOr as Q, milestone as R, S_STEP_CANCEL as S, S_SUCCESS as T, password as U, optionText as V, promptMilestone as W, text as X, symbolBar as Y, unicode as Z, S_INFO as _, S_BAR_END_RIGHT as a, S_RADIO_ACTIVE as b, S_BAR_START_RIGHT as c, S_CHECKBOX_SELECTED as d, CANCEL_SYMBOL as et, S_CORNER_BOTTOM_LEFT as f, S_ERROR as g, S_CORNER_TOP_RIGHT as h, S_BAR_END as i, wrapAnsi$1 as it, formatInstructionFooter as j, completeColor as k, S_CHECKBOX_ACTIVE as l, S_CORNER_TOP_LEFT as m, SELECT_INSTRUCTIONS as n, settings as nt, S_BAR_H as o, S_CORNER_BOTTOM_RIGHT as p, spinner as q, S_BAR as r, updateSettings as rt, S_BAR_START as s, MULTISELECT_INSTRUCTIONS as t, isCancel as tt, S_CHECKBOX_INACTIVE as u, S_PASSWORD_MASK as v, S_STEP_SUBMIT as w, S_STEP_ACTIVE as x, S_POINTER_ACTIVE as y, multiselect as z };