wp-studio 1.7.7-alpha1

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 (48) hide show
  1. package/LICENSE.md +257 -0
  2. package/README.md +87 -0
  3. package/dist/cli/_events-BeOo0LuG.js +116 -0
  4. package/dist/cli/appdata-07CF2rhg.js +21090 -0
  5. package/dist/cli/archive-xDmkN4wb.js +15942 -0
  6. package/dist/cli/browser-CgWK-yoe.js +44 -0
  7. package/dist/cli/certificate-manager-DdBumKZp.js +250 -0
  8. package/dist/cli/create-BHVhkvTx.js +80 -0
  9. package/dist/cli/create-ZS29BDDi.js +40999 -0
  10. package/dist/cli/delete-BgQn-elT.js +56 -0
  11. package/dist/cli/delete-g8pgaLna.js +132 -0
  12. package/dist/cli/get-wordpress-version-BwSCJujO.js +18 -0
  13. package/dist/cli/index-7pbG_s_U.js +434 -0
  14. package/dist/cli/index-BXRYeCYG.js +1393 -0
  15. package/dist/cli/index-T3F1GwxX.js +2668 -0
  16. package/dist/cli/is-errno-exception-t38xF2pB.js +6 -0
  17. package/dist/cli/list-BE_UBjL5.js +105 -0
  18. package/dist/cli/list-DKz0XxM7.js +1032 -0
  19. package/dist/cli/logger-actions-OaIvl-ai.js +45 -0
  20. package/dist/cli/login-B4PkfKOu.js +82 -0
  21. package/dist/cli/logout-BC9gKlTj.js +48 -0
  22. package/dist/cli/main.js +5 -0
  23. package/dist/cli/mu-plugins-GEfKsl5U.js +530 -0
  24. package/dist/cli/passwords-DyzWd9Xi.js +80 -0
  25. package/dist/cli/process-manager-daemon.js +327 -0
  26. package/dist/cli/process-manager-ipc-AUZeYYDT.js +454 -0
  27. package/dist/cli/proxy-daemon.js +197 -0
  28. package/dist/cli/run-wp-cli-command-BctnMDWG.js +88 -0
  29. package/dist/cli/sequential-BQFuixXz.js +46 -0
  30. package/dist/cli/server-files-C_oy-mnI.js +26 -0
  31. package/dist/cli/set-DknhAZpw.js +327 -0
  32. package/dist/cli/site-utils-CfsabjUn.js +243 -0
  33. package/dist/cli/snapshots-6XE53y_F.js +874 -0
  34. package/dist/cli/sqlite-integration-H4OwSlwR.js +83 -0
  35. package/dist/cli/start-CRJqm09_.js +90 -0
  36. package/dist/cli/status-CWNHIOaY.js +44 -0
  37. package/dist/cli/status-CWWx9jYF.js +110 -0
  38. package/dist/cli/stop-CQosmjqA.js +117 -0
  39. package/dist/cli/update-BgL2HKHW.js +101 -0
  40. package/dist/cli/validation-error-DqLxqQuA.js +40 -0
  41. package/dist/cli/wordpress-server-child.js +514 -0
  42. package/dist/cli/wordpress-server-ipc-Dwsg9jSb.js +140 -0
  43. package/dist/cli/wordpress-server-manager-CtiuJqEb.js +566 -0
  44. package/dist/cli/wordpress-version-utils-B6UVeTh_.js +51 -0
  45. package/dist/cli/wp-UGSnlkN0.js +103 -0
  46. package/package.json +73 -0
  47. package/patches/@wp-playground+wordpress+3.1.12.patch +28 -0
  48. package/scripts/postinstall-npm.mjs +38 -0
@@ -0,0 +1,2668 @@
1
+ import * as readline$1 from "node:readline";
2
+ import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
3
+ import { y as getDefaultExportFromCjs } from "./appdata-07CF2rhg.js";
4
+ import require$$0$2 from "stream";
5
+ import { stripVTControlCharacters } from "node:util";
6
+ import require$$0$1 from "tty";
7
+ import require$$0 from "node:tty";
8
+ import process$2 from "node:process";
9
+ const isUpKey = (key, keybindings = []) => (
10
+ // The up key
11
+ key.name === "up" || // Vim keybinding: hjkl keys map to left/down/up/right
12
+ keybindings.includes("vim") && key.name === "k" || // Emacs keybinding: Ctrl+P means "previous" in Emacs navigation conventions
13
+ keybindings.includes("emacs") && key.ctrl && key.name === "p"
14
+ );
15
+ const isDownKey = (key, keybindings = []) => (
16
+ // The down key
17
+ key.name === "down" || // Vim keybinding: hjkl keys map to left/down/up/right
18
+ keybindings.includes("vim") && key.name === "j" || // Emacs keybinding: Ctrl+N means "next" in Emacs navigation conventions
19
+ keybindings.includes("emacs") && key.ctrl && key.name === "n"
20
+ );
21
+ const isBackspaceKey = (key) => key.name === "backspace";
22
+ const isTabKey = (key) => key.name === "tab";
23
+ const isNumberKey = (key) => "1234567890".includes(key.name);
24
+ const isEnterKey = (key) => key.name === "enter" || key.name === "return";
25
+ class AbortPromptError extends Error {
26
+ name = "AbortPromptError";
27
+ message = "Prompt was aborted";
28
+ constructor(options) {
29
+ super();
30
+ this.cause = options?.cause;
31
+ }
32
+ }
33
+ class CancelPromptError extends Error {
34
+ name = "CancelPromptError";
35
+ message = "Prompt was canceled";
36
+ }
37
+ class ExitPromptError extends Error {
38
+ name = "ExitPromptError";
39
+ }
40
+ class HookError extends Error {
41
+ name = "HookError";
42
+ }
43
+ class ValidationError extends Error {
44
+ name = "ValidationError";
45
+ }
46
+ const hookStorage = new AsyncLocalStorage();
47
+ function createStore(rl) {
48
+ const store = {
49
+ rl,
50
+ hooks: [],
51
+ hooksCleanup: [],
52
+ hooksEffect: [],
53
+ index: 0,
54
+ handleChange() {
55
+ }
56
+ };
57
+ return store;
58
+ }
59
+ function withHooks(rl, cb) {
60
+ const store = createStore(rl);
61
+ return hookStorage.run(store, () => {
62
+ function cycle(render) {
63
+ store.handleChange = () => {
64
+ store.index = 0;
65
+ render();
66
+ };
67
+ store.handleChange();
68
+ }
69
+ return cb(cycle);
70
+ });
71
+ }
72
+ function getStore() {
73
+ const store = hookStorage.getStore();
74
+ if (!store) {
75
+ throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
76
+ }
77
+ return store;
78
+ }
79
+ function readline() {
80
+ return getStore().rl;
81
+ }
82
+ function withUpdates(fn) {
83
+ const wrapped = (...args) => {
84
+ const store = getStore();
85
+ let shouldUpdate = false;
86
+ const oldHandleChange = store.handleChange;
87
+ store.handleChange = () => {
88
+ shouldUpdate = true;
89
+ };
90
+ const returnValue = fn(...args);
91
+ if (shouldUpdate) {
92
+ oldHandleChange();
93
+ }
94
+ store.handleChange = oldHandleChange;
95
+ return returnValue;
96
+ };
97
+ return AsyncResource.bind(wrapped);
98
+ }
99
+ function withPointer(cb) {
100
+ const store = getStore();
101
+ const { index } = store;
102
+ const pointer = {
103
+ get() {
104
+ return store.hooks[index];
105
+ },
106
+ set(value) {
107
+ store.hooks[index] = value;
108
+ },
109
+ initialized: index in store.hooks
110
+ };
111
+ const returnValue = cb(pointer);
112
+ store.index++;
113
+ return returnValue;
114
+ }
115
+ function handleChange() {
116
+ getStore().handleChange();
117
+ }
118
+ const effectScheduler = {
119
+ queue(cb) {
120
+ const store = getStore();
121
+ const { index } = store;
122
+ store.hooksEffect.push(() => {
123
+ store.hooksCleanup[index]?.();
124
+ const cleanFn = cb(readline());
125
+ if (cleanFn != null && typeof cleanFn !== "function") {
126
+ throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
127
+ }
128
+ store.hooksCleanup[index] = cleanFn;
129
+ });
130
+ },
131
+ run() {
132
+ const store = getStore();
133
+ withUpdates(() => {
134
+ store.hooksEffect.forEach((effect) => {
135
+ effect();
136
+ });
137
+ store.hooksEffect.length = 0;
138
+ })();
139
+ },
140
+ clearAll() {
141
+ const store = getStore();
142
+ store.hooksCleanup.forEach((cleanFn) => {
143
+ cleanFn?.();
144
+ });
145
+ store.hooksEffect.length = 0;
146
+ store.hooksCleanup.length = 0;
147
+ }
148
+ };
149
+ function useState(defaultValue) {
150
+ return withPointer((pointer) => {
151
+ const setState = AsyncResource.bind(function setState2(newValue) {
152
+ if (pointer.get() !== newValue) {
153
+ pointer.set(newValue);
154
+ handleChange();
155
+ }
156
+ });
157
+ if (pointer.initialized) {
158
+ return [pointer.get(), setState];
159
+ }
160
+ const value = typeof defaultValue === "function" ? defaultValue() : defaultValue;
161
+ pointer.set(value);
162
+ return [value, setState];
163
+ });
164
+ }
165
+ function useEffect(cb, depArray) {
166
+ withPointer((pointer) => {
167
+ const oldDeps = pointer.get();
168
+ const hasChanged = !Array.isArray(oldDeps) || depArray.some((dep, i) => !Object.is(dep, oldDeps[i]));
169
+ if (hasChanged) {
170
+ effectScheduler.queue(cb);
171
+ }
172
+ pointer.set(depArray);
173
+ });
174
+ }
175
+ var yoctocolorsCjs;
176
+ var hasRequiredYoctocolorsCjs;
177
+ function requireYoctocolorsCjs() {
178
+ if (hasRequiredYoctocolorsCjs) return yoctocolorsCjs;
179
+ hasRequiredYoctocolorsCjs = 1;
180
+ const tty = require$$0;
181
+ const hasColors = tty?.WriteStream?.prototype?.hasColors?.() ?? false;
182
+ const format = (open, close) => {
183
+ if (!hasColors) {
184
+ return (input2) => input2;
185
+ }
186
+ const openCode = `\x1B[${open}m`;
187
+ const closeCode = `\x1B[${close}m`;
188
+ return (input2) => {
189
+ const string = input2 + "";
190
+ let index = string.indexOf(closeCode);
191
+ if (index === -1) {
192
+ return openCode + string + closeCode;
193
+ }
194
+ let result = openCode;
195
+ let lastIndex = 0;
196
+ const reopenOnNestedClose = close === 22;
197
+ const replaceCode = (reopenOnNestedClose ? closeCode : "") + openCode;
198
+ while (index !== -1) {
199
+ result += string.slice(lastIndex, index) + replaceCode;
200
+ lastIndex = index + closeCode.length;
201
+ index = string.indexOf(closeCode, lastIndex);
202
+ }
203
+ result += string.slice(lastIndex) + closeCode;
204
+ return result;
205
+ };
206
+ };
207
+ const colors2 = {};
208
+ colors2.reset = format(0, 0);
209
+ colors2.bold = format(1, 22);
210
+ colors2.dim = format(2, 22);
211
+ colors2.italic = format(3, 23);
212
+ colors2.underline = format(4, 24);
213
+ colors2.overline = format(53, 55);
214
+ colors2.inverse = format(7, 27);
215
+ colors2.hidden = format(8, 28);
216
+ colors2.strikethrough = format(9, 29);
217
+ colors2.black = format(30, 39);
218
+ colors2.red = format(31, 39);
219
+ colors2.green = format(32, 39);
220
+ colors2.yellow = format(33, 39);
221
+ colors2.blue = format(34, 39);
222
+ colors2.magenta = format(35, 39);
223
+ colors2.cyan = format(36, 39);
224
+ colors2.white = format(37, 39);
225
+ colors2.gray = format(90, 39);
226
+ colors2.bgBlack = format(40, 49);
227
+ colors2.bgRed = format(41, 49);
228
+ colors2.bgGreen = format(42, 49);
229
+ colors2.bgYellow = format(43, 49);
230
+ colors2.bgBlue = format(44, 49);
231
+ colors2.bgMagenta = format(45, 49);
232
+ colors2.bgCyan = format(46, 49);
233
+ colors2.bgWhite = format(47, 49);
234
+ colors2.bgGray = format(100, 49);
235
+ colors2.redBright = format(91, 39);
236
+ colors2.greenBright = format(92, 39);
237
+ colors2.yellowBright = format(93, 39);
238
+ colors2.blueBright = format(94, 39);
239
+ colors2.magentaBright = format(95, 39);
240
+ colors2.cyanBright = format(96, 39);
241
+ colors2.whiteBright = format(97, 39);
242
+ colors2.bgRedBright = format(101, 49);
243
+ colors2.bgGreenBright = format(102, 49);
244
+ colors2.bgYellowBright = format(103, 49);
245
+ colors2.bgBlueBright = format(104, 49);
246
+ colors2.bgMagentaBright = format(105, 49);
247
+ colors2.bgCyanBright = format(106, 49);
248
+ colors2.bgWhiteBright = format(107, 49);
249
+ yoctocolorsCjs = colors2;
250
+ return yoctocolorsCjs;
251
+ }
252
+ var yoctocolorsCjsExports = /* @__PURE__ */ requireYoctocolorsCjs();
253
+ const colors = /* @__PURE__ */ getDefaultExportFromCjs(yoctocolorsCjsExports);
254
+ function isUnicodeSupported() {
255
+ if (process$2.platform !== "win32") {
256
+ return process$2.env["TERM"] !== "linux";
257
+ }
258
+ return Boolean(process$2.env["WT_SESSION"]) || // Windows Terminal
259
+ Boolean(process$2.env["TERMINUS_SUBLIME"]) || // Terminus (<0.2.27)
260
+ process$2.env["ConEmuTask"] === "{cmd::Cmder}" || // ConEmu and cmder
261
+ process$2.env["TERM_PROGRAM"] === "Terminus-Sublime" || process$2.env["TERM_PROGRAM"] === "vscode" || process$2.env["TERM"] === "xterm-256color" || process$2.env["TERM"] === "alacritty" || process$2.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
262
+ }
263
+ const common = {
264
+ circleQuestionMark: "(?)",
265
+ questionMarkPrefix: "(?)",
266
+ square: "█",
267
+ squareDarkShade: "▓",
268
+ squareMediumShade: "▒",
269
+ squareLightShade: "░",
270
+ squareTop: "▀",
271
+ squareBottom: "▄",
272
+ squareLeft: "▌",
273
+ squareRight: "▐",
274
+ squareCenter: "■",
275
+ bullet: "●",
276
+ dot: "․",
277
+ ellipsis: "…",
278
+ pointerSmall: "›",
279
+ triangleUp: "▲",
280
+ triangleUpSmall: "▴",
281
+ triangleDown: "▼",
282
+ triangleDownSmall: "▾",
283
+ triangleLeftSmall: "◂",
284
+ triangleRightSmall: "▸",
285
+ home: "⌂",
286
+ heart: "♥",
287
+ musicNote: "♪",
288
+ musicNoteBeamed: "♫",
289
+ arrowUp: "↑",
290
+ arrowDown: "↓",
291
+ arrowLeft: "←",
292
+ arrowRight: "→",
293
+ arrowLeftRight: "↔",
294
+ arrowUpDown: "↕",
295
+ almostEqual: "≈",
296
+ notEqual: "≠",
297
+ lessOrEqual: "≤",
298
+ greaterOrEqual: "≥",
299
+ identical: "≡",
300
+ infinity: "∞",
301
+ subscriptZero: "₀",
302
+ subscriptOne: "₁",
303
+ subscriptTwo: "₂",
304
+ subscriptThree: "₃",
305
+ subscriptFour: "₄",
306
+ subscriptFive: "₅",
307
+ subscriptSix: "₆",
308
+ subscriptSeven: "₇",
309
+ subscriptEight: "₈",
310
+ subscriptNine: "₉",
311
+ oneHalf: "½",
312
+ oneThird: "⅓",
313
+ oneQuarter: "¼",
314
+ oneFifth: "⅕",
315
+ oneSixth: "⅙",
316
+ oneEighth: "⅛",
317
+ twoThirds: "⅔",
318
+ twoFifths: "⅖",
319
+ threeQuarters: "¾",
320
+ threeFifths: "⅗",
321
+ threeEighths: "⅜",
322
+ fourFifths: "⅘",
323
+ fiveSixths: "⅚",
324
+ fiveEighths: "⅝",
325
+ sevenEighths: "⅞",
326
+ line: "─",
327
+ lineBold: "━",
328
+ lineDouble: "═",
329
+ lineDashed0: "┄",
330
+ lineDashed1: "┅",
331
+ lineDashed2: "┈",
332
+ lineDashed3: "┉",
333
+ lineDashed4: "╌",
334
+ lineDashed5: "╍",
335
+ lineDashed6: "╴",
336
+ lineDashed7: "╶",
337
+ lineDashed8: "╸",
338
+ lineDashed9: "╺",
339
+ lineDashed10: "╼",
340
+ lineDashed11: "╾",
341
+ lineDashed12: "−",
342
+ lineDashed13: "–",
343
+ lineDashed14: "‐",
344
+ lineDashed15: "⁃",
345
+ lineVertical: "│",
346
+ lineVerticalBold: "┃",
347
+ lineVerticalDouble: "║",
348
+ lineVerticalDashed0: "┆",
349
+ lineVerticalDashed1: "┇",
350
+ lineVerticalDashed2: "┊",
351
+ lineVerticalDashed3: "┋",
352
+ lineVerticalDashed4: "╎",
353
+ lineVerticalDashed5: "╏",
354
+ lineVerticalDashed6: "╵",
355
+ lineVerticalDashed7: "╷",
356
+ lineVerticalDashed8: "╹",
357
+ lineVerticalDashed9: "╻",
358
+ lineVerticalDashed10: "╽",
359
+ lineVerticalDashed11: "╿",
360
+ lineDownLeft: "┐",
361
+ lineDownLeftArc: "╮",
362
+ lineDownBoldLeftBold: "┓",
363
+ lineDownBoldLeft: "┒",
364
+ lineDownLeftBold: "┑",
365
+ lineDownDoubleLeftDouble: "╗",
366
+ lineDownDoubleLeft: "╖",
367
+ lineDownLeftDouble: "╕",
368
+ lineDownRight: "┌",
369
+ lineDownRightArc: "╭",
370
+ lineDownBoldRightBold: "┏",
371
+ lineDownBoldRight: "┎",
372
+ lineDownRightBold: "┍",
373
+ lineDownDoubleRightDouble: "╔",
374
+ lineDownDoubleRight: "╓",
375
+ lineDownRightDouble: "╒",
376
+ lineUpLeft: "┘",
377
+ lineUpLeftArc: "╯",
378
+ lineUpBoldLeftBold: "┛",
379
+ lineUpBoldLeft: "┚",
380
+ lineUpLeftBold: "┙",
381
+ lineUpDoubleLeftDouble: "╝",
382
+ lineUpDoubleLeft: "╜",
383
+ lineUpLeftDouble: "╛",
384
+ lineUpRight: "└",
385
+ lineUpRightArc: "╰",
386
+ lineUpBoldRightBold: "┗",
387
+ lineUpBoldRight: "┖",
388
+ lineUpRightBold: "┕",
389
+ lineUpDoubleRightDouble: "╚",
390
+ lineUpDoubleRight: "╙",
391
+ lineUpRightDouble: "╘",
392
+ lineUpDownLeft: "┤",
393
+ lineUpBoldDownBoldLeftBold: "┫",
394
+ lineUpBoldDownBoldLeft: "┨",
395
+ lineUpDownLeftBold: "┥",
396
+ lineUpBoldDownLeftBold: "┩",
397
+ lineUpDownBoldLeftBold: "┪",
398
+ lineUpDownBoldLeft: "┧",
399
+ lineUpBoldDownLeft: "┦",
400
+ lineUpDoubleDownDoubleLeftDouble: "╣",
401
+ lineUpDoubleDownDoubleLeft: "╢",
402
+ lineUpDownLeftDouble: "╡",
403
+ lineUpDownRight: "├",
404
+ lineUpBoldDownBoldRightBold: "┣",
405
+ lineUpBoldDownBoldRight: "┠",
406
+ lineUpDownRightBold: "┝",
407
+ lineUpBoldDownRightBold: "┡",
408
+ lineUpDownBoldRightBold: "┢",
409
+ lineUpDownBoldRight: "┟",
410
+ lineUpBoldDownRight: "┞",
411
+ lineUpDoubleDownDoubleRightDouble: "╠",
412
+ lineUpDoubleDownDoubleRight: "╟",
413
+ lineUpDownRightDouble: "╞",
414
+ lineDownLeftRight: "┬",
415
+ lineDownBoldLeftBoldRightBold: "┳",
416
+ lineDownLeftBoldRightBold: "┯",
417
+ lineDownBoldLeftRight: "┰",
418
+ lineDownBoldLeftBoldRight: "┱",
419
+ lineDownBoldLeftRightBold: "┲",
420
+ lineDownLeftRightBold: "┮",
421
+ lineDownLeftBoldRight: "┭",
422
+ lineDownDoubleLeftDoubleRightDouble: "╦",
423
+ lineDownDoubleLeftRight: "╥",
424
+ lineDownLeftDoubleRightDouble: "╤",
425
+ lineUpLeftRight: "┴",
426
+ lineUpBoldLeftBoldRightBold: "┻",
427
+ lineUpLeftBoldRightBold: "┷",
428
+ lineUpBoldLeftRight: "┸",
429
+ lineUpBoldLeftBoldRight: "┹",
430
+ lineUpBoldLeftRightBold: "┺",
431
+ lineUpLeftRightBold: "┶",
432
+ lineUpLeftBoldRight: "┵",
433
+ lineUpDoubleLeftDoubleRightDouble: "╩",
434
+ lineUpDoubleLeftRight: "╨",
435
+ lineUpLeftDoubleRightDouble: "╧",
436
+ lineUpDownLeftRight: "┼",
437
+ lineUpBoldDownBoldLeftBoldRightBold: "╋",
438
+ lineUpDownBoldLeftBoldRightBold: "╈",
439
+ lineUpBoldDownLeftBoldRightBold: "╇",
440
+ lineUpBoldDownBoldLeftRightBold: "╊",
441
+ lineUpBoldDownBoldLeftBoldRight: "╉",
442
+ lineUpBoldDownLeftRight: "╀",
443
+ lineUpDownBoldLeftRight: "╁",
444
+ lineUpDownLeftBoldRight: "┽",
445
+ lineUpDownLeftRightBold: "┾",
446
+ lineUpBoldDownBoldLeftRight: "╂",
447
+ lineUpDownLeftBoldRightBold: "┿",
448
+ lineUpBoldDownLeftBoldRight: "╃",
449
+ lineUpBoldDownLeftRightBold: "╄",
450
+ lineUpDownBoldLeftBoldRight: "╅",
451
+ lineUpDownBoldLeftRightBold: "╆",
452
+ lineUpDoubleDownDoubleLeftDoubleRightDouble: "╬",
453
+ lineUpDoubleDownDoubleLeftRight: "╫",
454
+ lineUpDownLeftDoubleRightDouble: "╪",
455
+ lineCross: "╳",
456
+ lineBackslash: "╲",
457
+ lineSlash: "╱"
458
+ };
459
+ const specialMainSymbols = {
460
+ tick: "✔",
461
+ info: "ℹ",
462
+ warning: "⚠",
463
+ cross: "✘",
464
+ squareSmall: "◻",
465
+ squareSmallFilled: "◼",
466
+ circle: "◯",
467
+ circleFilled: "◉",
468
+ circleDotted: "◌",
469
+ circleDouble: "◎",
470
+ circleCircle: "ⓞ",
471
+ circleCross: "ⓧ",
472
+ circlePipe: "Ⓘ",
473
+ radioOn: "◉",
474
+ radioOff: "◯",
475
+ checkboxOn: "☒",
476
+ checkboxOff: "☐",
477
+ checkboxCircleOn: "ⓧ",
478
+ checkboxCircleOff: "Ⓘ",
479
+ pointer: "❯",
480
+ triangleUpOutline: "△",
481
+ triangleLeft: "◀",
482
+ triangleRight: "▶",
483
+ lozenge: "◆",
484
+ lozengeOutline: "◇",
485
+ hamburger: "☰",
486
+ smiley: "㋡",
487
+ mustache: "෴",
488
+ star: "★",
489
+ play: "▶",
490
+ nodejs: "⬢",
491
+ oneSeventh: "⅐",
492
+ oneNinth: "⅑",
493
+ oneTenth: "⅒"
494
+ };
495
+ const specialFallbackSymbols = {
496
+ tick: "√",
497
+ info: "i",
498
+ warning: "‼",
499
+ cross: "×",
500
+ squareSmall: "□",
501
+ squareSmallFilled: "■",
502
+ circle: "( )",
503
+ circleFilled: "(*)",
504
+ circleDotted: "( )",
505
+ circleDouble: "( )",
506
+ circleCircle: "(○)",
507
+ circleCross: "(×)",
508
+ circlePipe: "(│)",
509
+ radioOn: "(*)",
510
+ radioOff: "( )",
511
+ checkboxOn: "[×]",
512
+ checkboxOff: "[ ]",
513
+ checkboxCircleOn: "(×)",
514
+ checkboxCircleOff: "( )",
515
+ pointer: ">",
516
+ triangleUpOutline: "∆",
517
+ triangleLeft: "◄",
518
+ triangleRight: "►",
519
+ lozenge: "♦",
520
+ lozengeOutline: "◊",
521
+ hamburger: "≡",
522
+ smiley: "☺",
523
+ mustache: "┌─┐",
524
+ star: "✶",
525
+ play: "►",
526
+ nodejs: "♦",
527
+ oneSeventh: "1/7",
528
+ oneNinth: "1/9",
529
+ oneTenth: "1/10"
530
+ };
531
+ const mainSymbols = {
532
+ ...common,
533
+ ...specialMainSymbols
534
+ };
535
+ const fallbackSymbols = {
536
+ ...common,
537
+ ...specialFallbackSymbols
538
+ };
539
+ const shouldUseMain = isUnicodeSupported();
540
+ const figures = shouldUseMain ? mainSymbols : fallbackSymbols;
541
+ const defaultTheme = {
542
+ prefix: {
543
+ idle: colors.blue("?"),
544
+ done: colors.green(figures.tick)
545
+ },
546
+ spinner: {
547
+ interval: 80,
548
+ frames: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"].map((frame) => colors.yellow(frame))
549
+ },
550
+ style: {
551
+ answer: colors.cyan,
552
+ message: colors.bold,
553
+ error: (text) => colors.red(`> ${text}`),
554
+ defaultAnswer: (text) => colors.dim(`(${text})`),
555
+ help: colors.dim,
556
+ highlight: colors.cyan,
557
+ key: (text) => colors.cyan(colors.bold(`<${text}>`))
558
+ }
559
+ };
560
+ function isPlainObject(value) {
561
+ if (typeof value !== "object" || value === null)
562
+ return false;
563
+ let proto = value;
564
+ while (Object.getPrototypeOf(proto) !== null) {
565
+ proto = Object.getPrototypeOf(proto);
566
+ }
567
+ return Object.getPrototypeOf(value) === proto;
568
+ }
569
+ function deepMerge(...objects) {
570
+ const output = {};
571
+ for (const obj of objects) {
572
+ for (const [key, value] of Object.entries(obj)) {
573
+ const prevValue = output[key];
574
+ output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge(prevValue, value) : value;
575
+ }
576
+ }
577
+ return output;
578
+ }
579
+ function makeTheme(...themes) {
580
+ const themesToMerge = [
581
+ defaultTheme,
582
+ ...themes.filter((theme) => theme != null)
583
+ ];
584
+ return deepMerge(...themesToMerge);
585
+ }
586
+ function usePrefix({ status = "idle", theme }) {
587
+ const [showLoader, setShowLoader] = useState(false);
588
+ const [tick, setTick] = useState(0);
589
+ const { prefix, spinner } = makeTheme(theme);
590
+ useEffect(() => {
591
+ if (status === "loading") {
592
+ let tickInterval;
593
+ let inc = -1;
594
+ const delayTimeout = setTimeout(() => {
595
+ setShowLoader(true);
596
+ tickInterval = setInterval(() => {
597
+ inc = inc + 1;
598
+ setTick(inc % spinner.frames.length);
599
+ }, spinner.interval);
600
+ }, 300);
601
+ return () => {
602
+ clearTimeout(delayTimeout);
603
+ clearInterval(tickInterval);
604
+ };
605
+ } else {
606
+ setShowLoader(false);
607
+ }
608
+ }, [status]);
609
+ if (showLoader) {
610
+ return spinner.frames[tick];
611
+ }
612
+ const iconName = status === "loading" ? "idle" : status;
613
+ return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
614
+ }
615
+ function useRef(val) {
616
+ return useState({ current: val })[0];
617
+ }
618
+ function useKeypress(userHandler) {
619
+ const signal = useRef(userHandler);
620
+ signal.current = userHandler;
621
+ useEffect((rl) => {
622
+ let ignore = false;
623
+ const handler = withUpdates((_input, event) => {
624
+ if (ignore)
625
+ return;
626
+ void signal.current(event, rl);
627
+ });
628
+ rl.input.on("keypress", handler);
629
+ return () => {
630
+ ignore = true;
631
+ rl.input.removeListener("keypress", handler);
632
+ };
633
+ }, []);
634
+ }
635
+ var cliWidth_1;
636
+ var hasRequiredCliWidth;
637
+ function requireCliWidth() {
638
+ if (hasRequiredCliWidth) return cliWidth_1;
639
+ hasRequiredCliWidth = 1;
640
+ cliWidth_1 = cliWidth2;
641
+ function normalizeOpts(options) {
642
+ const defaultOpts = {
643
+ defaultWidth: 0,
644
+ output: process.stdout,
645
+ tty: require$$0$1
646
+ };
647
+ if (!options) {
648
+ return defaultOpts;
649
+ }
650
+ Object.keys(defaultOpts).forEach(function(key) {
651
+ if (!options[key]) {
652
+ options[key] = defaultOpts[key];
653
+ }
654
+ });
655
+ return options;
656
+ }
657
+ function cliWidth2(options) {
658
+ const opts = normalizeOpts(options);
659
+ if (opts.output.getWindowSize) {
660
+ return opts.output.getWindowSize()[0] || opts.defaultWidth;
661
+ }
662
+ if (opts.tty.getWindowSize) {
663
+ return opts.tty.getWindowSize()[1] || opts.defaultWidth;
664
+ }
665
+ if (opts.output.columns) {
666
+ return opts.output.columns;
667
+ }
668
+ if (process.env.CLI_WIDTH) {
669
+ const width = parseInt(process.env.CLI_WIDTH, 10);
670
+ if (!isNaN(width) && width !== 0) {
671
+ return width;
672
+ }
673
+ }
674
+ return opts.defaultWidth;
675
+ }
676
+ return cliWidth_1;
677
+ }
678
+ var cliWidthExports = requireCliWidth();
679
+ const cliWidth = /* @__PURE__ */ getDefaultExportFromCjs(cliWidthExports);
680
+ var stringWidth = { exports: {} };
681
+ var ansiRegex;
682
+ var hasRequiredAnsiRegex;
683
+ function requireAnsiRegex() {
684
+ if (hasRequiredAnsiRegex) return ansiRegex;
685
+ hasRequiredAnsiRegex = 1;
686
+ ansiRegex = ({ onlyFirst = false } = {}) => {
687
+ const pattern = [
688
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
689
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
690
+ ].join("|");
691
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
692
+ };
693
+ return ansiRegex;
694
+ }
695
+ var stripAnsi$1;
696
+ var hasRequiredStripAnsi$1;
697
+ function requireStripAnsi$1() {
698
+ if (hasRequiredStripAnsi$1) return stripAnsi$1;
699
+ hasRequiredStripAnsi$1 = 1;
700
+ const ansiRegex2 = requireAnsiRegex();
701
+ stripAnsi$1 = (string) => typeof string === "string" ? string.replace(ansiRegex2(), "") : string;
702
+ return stripAnsi$1;
703
+ }
704
+ var isFullwidthCodePoint = { exports: {} };
705
+ var hasRequiredIsFullwidthCodePoint;
706
+ function requireIsFullwidthCodePoint() {
707
+ if (hasRequiredIsFullwidthCodePoint) return isFullwidthCodePoint.exports;
708
+ hasRequiredIsFullwidthCodePoint = 1;
709
+ const isFullwidthCodePoint$1 = (codePoint) => {
710
+ if (Number.isNaN(codePoint)) {
711
+ return false;
712
+ }
713
+ if (codePoint >= 4352 && (codePoint <= 4447 || // Hangul Jamo
714
+ codePoint === 9001 || // LEFT-POINTING ANGLE BRACKET
715
+ codePoint === 9002 || // RIGHT-POINTING ANGLE BRACKET
716
+ // CJK Radicals Supplement .. Enclosed CJK Letters and Months
717
+ 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
718
+ 12880 <= codePoint && codePoint <= 19903 || // CJK Unified Ideographs .. Yi Radicals
719
+ 19968 <= codePoint && codePoint <= 42182 || // Hangul Jamo Extended-A
720
+ 43360 <= codePoint && codePoint <= 43388 || // Hangul Syllables
721
+ 44032 <= codePoint && codePoint <= 55203 || // CJK Compatibility Ideographs
722
+ 63744 <= codePoint && codePoint <= 64255 || // Vertical Forms
723
+ 65040 <= codePoint && codePoint <= 65049 || // CJK Compatibility Forms .. Small Form Variants
724
+ 65072 <= codePoint && codePoint <= 65131 || // Halfwidth and Fullwidth Forms
725
+ 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || // Kana Supplement
726
+ 110592 <= codePoint && codePoint <= 110593 || // Enclosed Ideographic Supplement
727
+ 127488 <= codePoint && codePoint <= 127569 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
728
+ 131072 <= codePoint && codePoint <= 262141)) {
729
+ return true;
730
+ }
731
+ return false;
732
+ };
733
+ isFullwidthCodePoint.exports = isFullwidthCodePoint$1;
734
+ isFullwidthCodePoint.exports.default = isFullwidthCodePoint$1;
735
+ return isFullwidthCodePoint.exports;
736
+ }
737
+ var emojiRegex;
738
+ var hasRequiredEmojiRegex;
739
+ function requireEmojiRegex() {
740
+ if (hasRequiredEmojiRegex) return emojiRegex;
741
+ hasRequiredEmojiRegex = 1;
742
+ emojiRegex = function() {
743
+ return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
744
+ };
745
+ return emojiRegex;
746
+ }
747
+ var hasRequiredStringWidth;
748
+ function requireStringWidth() {
749
+ if (hasRequiredStringWidth) return stringWidth.exports;
750
+ hasRequiredStringWidth = 1;
751
+ const stripAnsi2 = requireStripAnsi$1();
752
+ const isFullwidthCodePoint2 = requireIsFullwidthCodePoint();
753
+ const emojiRegex2 = requireEmojiRegex();
754
+ const stringWidth$1 = (string) => {
755
+ if (typeof string !== "string" || string.length === 0) {
756
+ return 0;
757
+ }
758
+ string = stripAnsi2(string);
759
+ if (string.length === 0) {
760
+ return 0;
761
+ }
762
+ string = string.replace(emojiRegex2(), " ");
763
+ let width = 0;
764
+ for (let i = 0; i < string.length; i++) {
765
+ const code = string.codePointAt(i);
766
+ if (code <= 31 || code >= 127 && code <= 159) {
767
+ continue;
768
+ }
769
+ if (code >= 768 && code <= 879) {
770
+ continue;
771
+ }
772
+ if (code > 65535) {
773
+ i++;
774
+ }
775
+ width += isFullwidthCodePoint2(code) ? 2 : 1;
776
+ }
777
+ return width;
778
+ };
779
+ stringWidth.exports = stringWidth$1;
780
+ stringWidth.exports.default = stringWidth$1;
781
+ return stringWidth.exports;
782
+ }
783
+ var stripAnsi;
784
+ var hasRequiredStripAnsi;
785
+ function requireStripAnsi() {
786
+ if (hasRequiredStripAnsi) return stripAnsi;
787
+ hasRequiredStripAnsi = 1;
788
+ const ansiRegex2 = requireAnsiRegex();
789
+ stripAnsi = (string) => typeof string === "string" ? string.replace(ansiRegex2(), "") : string;
790
+ return stripAnsi;
791
+ }
792
+ var ansiStyles = { exports: {} };
793
+ var colorName;
794
+ var hasRequiredColorName;
795
+ function requireColorName() {
796
+ if (hasRequiredColorName) return colorName;
797
+ hasRequiredColorName = 1;
798
+ colorName = {
799
+ "aliceblue": [240, 248, 255],
800
+ "antiquewhite": [250, 235, 215],
801
+ "aqua": [0, 255, 255],
802
+ "aquamarine": [127, 255, 212],
803
+ "azure": [240, 255, 255],
804
+ "beige": [245, 245, 220],
805
+ "bisque": [255, 228, 196],
806
+ "black": [0, 0, 0],
807
+ "blanchedalmond": [255, 235, 205],
808
+ "blue": [0, 0, 255],
809
+ "blueviolet": [138, 43, 226],
810
+ "brown": [165, 42, 42],
811
+ "burlywood": [222, 184, 135],
812
+ "cadetblue": [95, 158, 160],
813
+ "chartreuse": [127, 255, 0],
814
+ "chocolate": [210, 105, 30],
815
+ "coral": [255, 127, 80],
816
+ "cornflowerblue": [100, 149, 237],
817
+ "cornsilk": [255, 248, 220],
818
+ "crimson": [220, 20, 60],
819
+ "cyan": [0, 255, 255],
820
+ "darkblue": [0, 0, 139],
821
+ "darkcyan": [0, 139, 139],
822
+ "darkgoldenrod": [184, 134, 11],
823
+ "darkgray": [169, 169, 169],
824
+ "darkgreen": [0, 100, 0],
825
+ "darkgrey": [169, 169, 169],
826
+ "darkkhaki": [189, 183, 107],
827
+ "darkmagenta": [139, 0, 139],
828
+ "darkolivegreen": [85, 107, 47],
829
+ "darkorange": [255, 140, 0],
830
+ "darkorchid": [153, 50, 204],
831
+ "darkred": [139, 0, 0],
832
+ "darksalmon": [233, 150, 122],
833
+ "darkseagreen": [143, 188, 143],
834
+ "darkslateblue": [72, 61, 139],
835
+ "darkslategray": [47, 79, 79],
836
+ "darkslategrey": [47, 79, 79],
837
+ "darkturquoise": [0, 206, 209],
838
+ "darkviolet": [148, 0, 211],
839
+ "deeppink": [255, 20, 147],
840
+ "deepskyblue": [0, 191, 255],
841
+ "dimgray": [105, 105, 105],
842
+ "dimgrey": [105, 105, 105],
843
+ "dodgerblue": [30, 144, 255],
844
+ "firebrick": [178, 34, 34],
845
+ "floralwhite": [255, 250, 240],
846
+ "forestgreen": [34, 139, 34],
847
+ "fuchsia": [255, 0, 255],
848
+ "gainsboro": [220, 220, 220],
849
+ "ghostwhite": [248, 248, 255],
850
+ "gold": [255, 215, 0],
851
+ "goldenrod": [218, 165, 32],
852
+ "gray": [128, 128, 128],
853
+ "green": [0, 128, 0],
854
+ "greenyellow": [173, 255, 47],
855
+ "grey": [128, 128, 128],
856
+ "honeydew": [240, 255, 240],
857
+ "hotpink": [255, 105, 180],
858
+ "indianred": [205, 92, 92],
859
+ "indigo": [75, 0, 130],
860
+ "ivory": [255, 255, 240],
861
+ "khaki": [240, 230, 140],
862
+ "lavender": [230, 230, 250],
863
+ "lavenderblush": [255, 240, 245],
864
+ "lawngreen": [124, 252, 0],
865
+ "lemonchiffon": [255, 250, 205],
866
+ "lightblue": [173, 216, 230],
867
+ "lightcoral": [240, 128, 128],
868
+ "lightcyan": [224, 255, 255],
869
+ "lightgoldenrodyellow": [250, 250, 210],
870
+ "lightgray": [211, 211, 211],
871
+ "lightgreen": [144, 238, 144],
872
+ "lightgrey": [211, 211, 211],
873
+ "lightpink": [255, 182, 193],
874
+ "lightsalmon": [255, 160, 122],
875
+ "lightseagreen": [32, 178, 170],
876
+ "lightskyblue": [135, 206, 250],
877
+ "lightslategray": [119, 136, 153],
878
+ "lightslategrey": [119, 136, 153],
879
+ "lightsteelblue": [176, 196, 222],
880
+ "lightyellow": [255, 255, 224],
881
+ "lime": [0, 255, 0],
882
+ "limegreen": [50, 205, 50],
883
+ "linen": [250, 240, 230],
884
+ "magenta": [255, 0, 255],
885
+ "maroon": [128, 0, 0],
886
+ "mediumaquamarine": [102, 205, 170],
887
+ "mediumblue": [0, 0, 205],
888
+ "mediumorchid": [186, 85, 211],
889
+ "mediumpurple": [147, 112, 219],
890
+ "mediumseagreen": [60, 179, 113],
891
+ "mediumslateblue": [123, 104, 238],
892
+ "mediumspringgreen": [0, 250, 154],
893
+ "mediumturquoise": [72, 209, 204],
894
+ "mediumvioletred": [199, 21, 133],
895
+ "midnightblue": [25, 25, 112],
896
+ "mintcream": [245, 255, 250],
897
+ "mistyrose": [255, 228, 225],
898
+ "moccasin": [255, 228, 181],
899
+ "navajowhite": [255, 222, 173],
900
+ "navy": [0, 0, 128],
901
+ "oldlace": [253, 245, 230],
902
+ "olive": [128, 128, 0],
903
+ "olivedrab": [107, 142, 35],
904
+ "orange": [255, 165, 0],
905
+ "orangered": [255, 69, 0],
906
+ "orchid": [218, 112, 214],
907
+ "palegoldenrod": [238, 232, 170],
908
+ "palegreen": [152, 251, 152],
909
+ "paleturquoise": [175, 238, 238],
910
+ "palevioletred": [219, 112, 147],
911
+ "papayawhip": [255, 239, 213],
912
+ "peachpuff": [255, 218, 185],
913
+ "peru": [205, 133, 63],
914
+ "pink": [255, 192, 203],
915
+ "plum": [221, 160, 221],
916
+ "powderblue": [176, 224, 230],
917
+ "purple": [128, 0, 128],
918
+ "rebeccapurple": [102, 51, 153],
919
+ "red": [255, 0, 0],
920
+ "rosybrown": [188, 143, 143],
921
+ "royalblue": [65, 105, 225],
922
+ "saddlebrown": [139, 69, 19],
923
+ "salmon": [250, 128, 114],
924
+ "sandybrown": [244, 164, 96],
925
+ "seagreen": [46, 139, 87],
926
+ "seashell": [255, 245, 238],
927
+ "sienna": [160, 82, 45],
928
+ "silver": [192, 192, 192],
929
+ "skyblue": [135, 206, 235],
930
+ "slateblue": [106, 90, 205],
931
+ "slategray": [112, 128, 144],
932
+ "slategrey": [112, 128, 144],
933
+ "snow": [255, 250, 250],
934
+ "springgreen": [0, 255, 127],
935
+ "steelblue": [70, 130, 180],
936
+ "tan": [210, 180, 140],
937
+ "teal": [0, 128, 128],
938
+ "thistle": [216, 191, 216],
939
+ "tomato": [255, 99, 71],
940
+ "turquoise": [64, 224, 208],
941
+ "violet": [238, 130, 238],
942
+ "wheat": [245, 222, 179],
943
+ "white": [255, 255, 255],
944
+ "whitesmoke": [245, 245, 245],
945
+ "yellow": [255, 255, 0],
946
+ "yellowgreen": [154, 205, 50]
947
+ };
948
+ return colorName;
949
+ }
950
+ var conversions;
951
+ var hasRequiredConversions;
952
+ function requireConversions() {
953
+ if (hasRequiredConversions) return conversions;
954
+ hasRequiredConversions = 1;
955
+ const cssKeywords = requireColorName();
956
+ const reverseKeywords = {};
957
+ for (const key of Object.keys(cssKeywords)) {
958
+ reverseKeywords[cssKeywords[key]] = key;
959
+ }
960
+ const convert = {
961
+ rgb: { channels: 3, labels: "rgb" },
962
+ hsl: { channels: 3, labels: "hsl" },
963
+ hsv: { channels: 3, labels: "hsv" },
964
+ hwb: { channels: 3, labels: "hwb" },
965
+ cmyk: { channels: 4, labels: "cmyk" },
966
+ xyz: { channels: 3, labels: "xyz" },
967
+ lab: { channels: 3, labels: "lab" },
968
+ lch: { channels: 3, labels: "lch" },
969
+ hex: { channels: 1, labels: ["hex"] },
970
+ keyword: { channels: 1, labels: ["keyword"] },
971
+ ansi16: { channels: 1, labels: ["ansi16"] },
972
+ ansi256: { channels: 1, labels: ["ansi256"] },
973
+ hcg: { channels: 3, labels: ["h", "c", "g"] },
974
+ apple: { channels: 3, labels: ["r16", "g16", "b16"] },
975
+ gray: { channels: 1, labels: ["gray"] }
976
+ };
977
+ conversions = convert;
978
+ for (const model of Object.keys(convert)) {
979
+ if (!("channels" in convert[model])) {
980
+ throw new Error("missing channels property: " + model);
981
+ }
982
+ if (!("labels" in convert[model])) {
983
+ throw new Error("missing channel labels property: " + model);
984
+ }
985
+ if (convert[model].labels.length !== convert[model].channels) {
986
+ throw new Error("channel and label counts mismatch: " + model);
987
+ }
988
+ const { channels, labels } = convert[model];
989
+ delete convert[model].channels;
990
+ delete convert[model].labels;
991
+ Object.defineProperty(convert[model], "channels", { value: channels });
992
+ Object.defineProperty(convert[model], "labels", { value: labels });
993
+ }
994
+ convert.rgb.hsl = function(rgb) {
995
+ const r = rgb[0] / 255;
996
+ const g = rgb[1] / 255;
997
+ const b = rgb[2] / 255;
998
+ const min = Math.min(r, g, b);
999
+ const max = Math.max(r, g, b);
1000
+ const delta = max - min;
1001
+ let h;
1002
+ let s;
1003
+ if (max === min) {
1004
+ h = 0;
1005
+ } else if (r === max) {
1006
+ h = (g - b) / delta;
1007
+ } else if (g === max) {
1008
+ h = 2 + (b - r) / delta;
1009
+ } else if (b === max) {
1010
+ h = 4 + (r - g) / delta;
1011
+ }
1012
+ h = Math.min(h * 60, 360);
1013
+ if (h < 0) {
1014
+ h += 360;
1015
+ }
1016
+ const l = (min + max) / 2;
1017
+ if (max === min) {
1018
+ s = 0;
1019
+ } else if (l <= 0.5) {
1020
+ s = delta / (max + min);
1021
+ } else {
1022
+ s = delta / (2 - max - min);
1023
+ }
1024
+ return [h, s * 100, l * 100];
1025
+ };
1026
+ convert.rgb.hsv = function(rgb) {
1027
+ let rdif;
1028
+ let gdif;
1029
+ let bdif;
1030
+ let h;
1031
+ let s;
1032
+ const r = rgb[0] / 255;
1033
+ const g = rgb[1] / 255;
1034
+ const b = rgb[2] / 255;
1035
+ const v = Math.max(r, g, b);
1036
+ const diff = v - Math.min(r, g, b);
1037
+ const diffc = function(c) {
1038
+ return (v - c) / 6 / diff + 1 / 2;
1039
+ };
1040
+ if (diff === 0) {
1041
+ h = 0;
1042
+ s = 0;
1043
+ } else {
1044
+ s = diff / v;
1045
+ rdif = diffc(r);
1046
+ gdif = diffc(g);
1047
+ bdif = diffc(b);
1048
+ if (r === v) {
1049
+ h = bdif - gdif;
1050
+ } else if (g === v) {
1051
+ h = 1 / 3 + rdif - bdif;
1052
+ } else if (b === v) {
1053
+ h = 2 / 3 + gdif - rdif;
1054
+ }
1055
+ if (h < 0) {
1056
+ h += 1;
1057
+ } else if (h > 1) {
1058
+ h -= 1;
1059
+ }
1060
+ }
1061
+ return [
1062
+ h * 360,
1063
+ s * 100,
1064
+ v * 100
1065
+ ];
1066
+ };
1067
+ convert.rgb.hwb = function(rgb) {
1068
+ const r = rgb[0];
1069
+ const g = rgb[1];
1070
+ let b = rgb[2];
1071
+ const h = convert.rgb.hsl(rgb)[0];
1072
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
1073
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
1074
+ return [h, w * 100, b * 100];
1075
+ };
1076
+ convert.rgb.cmyk = function(rgb) {
1077
+ const r = rgb[0] / 255;
1078
+ const g = rgb[1] / 255;
1079
+ const b = rgb[2] / 255;
1080
+ const k = Math.min(1 - r, 1 - g, 1 - b);
1081
+ const c = (1 - r - k) / (1 - k) || 0;
1082
+ const m = (1 - g - k) / (1 - k) || 0;
1083
+ const y = (1 - b - k) / (1 - k) || 0;
1084
+ return [c * 100, m * 100, y * 100, k * 100];
1085
+ };
1086
+ function comparativeDistance(x, y) {
1087
+ return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
1088
+ }
1089
+ convert.rgb.keyword = function(rgb) {
1090
+ const reversed = reverseKeywords[rgb];
1091
+ if (reversed) {
1092
+ return reversed;
1093
+ }
1094
+ let currentClosestDistance = Infinity;
1095
+ let currentClosestKeyword;
1096
+ for (const keyword of Object.keys(cssKeywords)) {
1097
+ const value = cssKeywords[keyword];
1098
+ const distance = comparativeDistance(rgb, value);
1099
+ if (distance < currentClosestDistance) {
1100
+ currentClosestDistance = distance;
1101
+ currentClosestKeyword = keyword;
1102
+ }
1103
+ }
1104
+ return currentClosestKeyword;
1105
+ };
1106
+ convert.keyword.rgb = function(keyword) {
1107
+ return cssKeywords[keyword];
1108
+ };
1109
+ convert.rgb.xyz = function(rgb) {
1110
+ let r = rgb[0] / 255;
1111
+ let g = rgb[1] / 255;
1112
+ let b = rgb[2] / 255;
1113
+ r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
1114
+ g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
1115
+ b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
1116
+ const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
1117
+ const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
1118
+ const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
1119
+ return [x * 100, y * 100, z * 100];
1120
+ };
1121
+ convert.rgb.lab = function(rgb) {
1122
+ const xyz = convert.rgb.xyz(rgb);
1123
+ let x = xyz[0];
1124
+ let y = xyz[1];
1125
+ let z = xyz[2];
1126
+ x /= 95.047;
1127
+ y /= 100;
1128
+ z /= 108.883;
1129
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
1130
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
1131
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
1132
+ const l = 116 * y - 16;
1133
+ const a = 500 * (x - y);
1134
+ const b = 200 * (y - z);
1135
+ return [l, a, b];
1136
+ };
1137
+ convert.hsl.rgb = function(hsl) {
1138
+ const h = hsl[0] / 360;
1139
+ const s = hsl[1] / 100;
1140
+ const l = hsl[2] / 100;
1141
+ let t2;
1142
+ let t3;
1143
+ let val;
1144
+ if (s === 0) {
1145
+ val = l * 255;
1146
+ return [val, val, val];
1147
+ }
1148
+ if (l < 0.5) {
1149
+ t2 = l * (1 + s);
1150
+ } else {
1151
+ t2 = l + s - l * s;
1152
+ }
1153
+ const t1 = 2 * l - t2;
1154
+ const rgb = [0, 0, 0];
1155
+ for (let i = 0; i < 3; i++) {
1156
+ t3 = h + 1 / 3 * -(i - 1);
1157
+ if (t3 < 0) {
1158
+ t3++;
1159
+ }
1160
+ if (t3 > 1) {
1161
+ t3--;
1162
+ }
1163
+ if (6 * t3 < 1) {
1164
+ val = t1 + (t2 - t1) * 6 * t3;
1165
+ } else if (2 * t3 < 1) {
1166
+ val = t2;
1167
+ } else if (3 * t3 < 2) {
1168
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
1169
+ } else {
1170
+ val = t1;
1171
+ }
1172
+ rgb[i] = val * 255;
1173
+ }
1174
+ return rgb;
1175
+ };
1176
+ convert.hsl.hsv = function(hsl) {
1177
+ const h = hsl[0];
1178
+ let s = hsl[1] / 100;
1179
+ let l = hsl[2] / 100;
1180
+ let smin = s;
1181
+ const lmin = Math.max(l, 0.01);
1182
+ l *= 2;
1183
+ s *= l <= 1 ? l : 2 - l;
1184
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
1185
+ const v = (l + s) / 2;
1186
+ const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
1187
+ return [h, sv * 100, v * 100];
1188
+ };
1189
+ convert.hsv.rgb = function(hsv) {
1190
+ const h = hsv[0] / 60;
1191
+ const s = hsv[1] / 100;
1192
+ let v = hsv[2] / 100;
1193
+ const hi = Math.floor(h) % 6;
1194
+ const f = h - Math.floor(h);
1195
+ const p = 255 * v * (1 - s);
1196
+ const q = 255 * v * (1 - s * f);
1197
+ const t = 255 * v * (1 - s * (1 - f));
1198
+ v *= 255;
1199
+ switch (hi) {
1200
+ case 0:
1201
+ return [v, t, p];
1202
+ case 1:
1203
+ return [q, v, p];
1204
+ case 2:
1205
+ return [p, v, t];
1206
+ case 3:
1207
+ return [p, q, v];
1208
+ case 4:
1209
+ return [t, p, v];
1210
+ case 5:
1211
+ return [v, p, q];
1212
+ }
1213
+ };
1214
+ convert.hsv.hsl = function(hsv) {
1215
+ const h = hsv[0];
1216
+ const s = hsv[1] / 100;
1217
+ const v = hsv[2] / 100;
1218
+ const vmin = Math.max(v, 0.01);
1219
+ let sl;
1220
+ let l;
1221
+ l = (2 - s) * v;
1222
+ const lmin = (2 - s) * vmin;
1223
+ sl = s * vmin;
1224
+ sl /= lmin <= 1 ? lmin : 2 - lmin;
1225
+ sl = sl || 0;
1226
+ l /= 2;
1227
+ return [h, sl * 100, l * 100];
1228
+ };
1229
+ convert.hwb.rgb = function(hwb) {
1230
+ const h = hwb[0] / 360;
1231
+ let wh = hwb[1] / 100;
1232
+ let bl = hwb[2] / 100;
1233
+ const ratio = wh + bl;
1234
+ let f;
1235
+ if (ratio > 1) {
1236
+ wh /= ratio;
1237
+ bl /= ratio;
1238
+ }
1239
+ const i = Math.floor(6 * h);
1240
+ const v = 1 - bl;
1241
+ f = 6 * h - i;
1242
+ if ((i & 1) !== 0) {
1243
+ f = 1 - f;
1244
+ }
1245
+ const n = wh + f * (v - wh);
1246
+ let r;
1247
+ let g;
1248
+ let b;
1249
+ switch (i) {
1250
+ default:
1251
+ case 6:
1252
+ case 0:
1253
+ r = v;
1254
+ g = n;
1255
+ b = wh;
1256
+ break;
1257
+ case 1:
1258
+ r = n;
1259
+ g = v;
1260
+ b = wh;
1261
+ break;
1262
+ case 2:
1263
+ r = wh;
1264
+ g = v;
1265
+ b = n;
1266
+ break;
1267
+ case 3:
1268
+ r = wh;
1269
+ g = n;
1270
+ b = v;
1271
+ break;
1272
+ case 4:
1273
+ r = n;
1274
+ g = wh;
1275
+ b = v;
1276
+ break;
1277
+ case 5:
1278
+ r = v;
1279
+ g = wh;
1280
+ b = n;
1281
+ break;
1282
+ }
1283
+ return [r * 255, g * 255, b * 255];
1284
+ };
1285
+ convert.cmyk.rgb = function(cmyk) {
1286
+ const c = cmyk[0] / 100;
1287
+ const m = cmyk[1] / 100;
1288
+ const y = cmyk[2] / 100;
1289
+ const k = cmyk[3] / 100;
1290
+ const r = 1 - Math.min(1, c * (1 - k) + k);
1291
+ const g = 1 - Math.min(1, m * (1 - k) + k);
1292
+ const b = 1 - Math.min(1, y * (1 - k) + k);
1293
+ return [r * 255, g * 255, b * 255];
1294
+ };
1295
+ convert.xyz.rgb = function(xyz) {
1296
+ const x = xyz[0] / 100;
1297
+ const y = xyz[1] / 100;
1298
+ const z = xyz[2] / 100;
1299
+ let r;
1300
+ let g;
1301
+ let b;
1302
+ r = x * 3.2406 + y * -1.5372 + z * -0.4986;
1303
+ g = x * -0.9689 + y * 1.8758 + z * 0.0415;
1304
+ b = x * 0.0557 + y * -0.204 + z * 1.057;
1305
+ r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
1306
+ g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
1307
+ b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
1308
+ r = Math.min(Math.max(0, r), 1);
1309
+ g = Math.min(Math.max(0, g), 1);
1310
+ b = Math.min(Math.max(0, b), 1);
1311
+ return [r * 255, g * 255, b * 255];
1312
+ };
1313
+ convert.xyz.lab = function(xyz) {
1314
+ let x = xyz[0];
1315
+ let y = xyz[1];
1316
+ let z = xyz[2];
1317
+ x /= 95.047;
1318
+ y /= 100;
1319
+ z /= 108.883;
1320
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
1321
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
1322
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
1323
+ const l = 116 * y - 16;
1324
+ const a = 500 * (x - y);
1325
+ const b = 200 * (y - z);
1326
+ return [l, a, b];
1327
+ };
1328
+ convert.lab.xyz = function(lab) {
1329
+ const l = lab[0];
1330
+ const a = lab[1];
1331
+ const b = lab[2];
1332
+ let x;
1333
+ let y;
1334
+ let z;
1335
+ y = (l + 16) / 116;
1336
+ x = a / 500 + y;
1337
+ z = y - b / 200;
1338
+ const y2 = y ** 3;
1339
+ const x2 = x ** 3;
1340
+ const z2 = z ** 3;
1341
+ y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
1342
+ x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
1343
+ z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
1344
+ x *= 95.047;
1345
+ y *= 100;
1346
+ z *= 108.883;
1347
+ return [x, y, z];
1348
+ };
1349
+ convert.lab.lch = function(lab) {
1350
+ const l = lab[0];
1351
+ const a = lab[1];
1352
+ const b = lab[2];
1353
+ let h;
1354
+ const hr = Math.atan2(b, a);
1355
+ h = hr * 360 / 2 / Math.PI;
1356
+ if (h < 0) {
1357
+ h += 360;
1358
+ }
1359
+ const c = Math.sqrt(a * a + b * b);
1360
+ return [l, c, h];
1361
+ };
1362
+ convert.lch.lab = function(lch) {
1363
+ const l = lch[0];
1364
+ const c = lch[1];
1365
+ const h = lch[2];
1366
+ const hr = h / 360 * 2 * Math.PI;
1367
+ const a = c * Math.cos(hr);
1368
+ const b = c * Math.sin(hr);
1369
+ return [l, a, b];
1370
+ };
1371
+ convert.rgb.ansi16 = function(args, saturation = null) {
1372
+ const [r, g, b] = args;
1373
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
1374
+ value = Math.round(value / 50);
1375
+ if (value === 0) {
1376
+ return 30;
1377
+ }
1378
+ let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
1379
+ if (value === 2) {
1380
+ ansi += 60;
1381
+ }
1382
+ return ansi;
1383
+ };
1384
+ convert.hsv.ansi16 = function(args) {
1385
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
1386
+ };
1387
+ convert.rgb.ansi256 = function(args) {
1388
+ const r = args[0];
1389
+ const g = args[1];
1390
+ const b = args[2];
1391
+ if (r === g && g === b) {
1392
+ if (r < 8) {
1393
+ return 16;
1394
+ }
1395
+ if (r > 248) {
1396
+ return 231;
1397
+ }
1398
+ return Math.round((r - 8) / 247 * 24) + 232;
1399
+ }
1400
+ const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
1401
+ return ansi;
1402
+ };
1403
+ convert.ansi16.rgb = function(args) {
1404
+ let color = args % 10;
1405
+ if (color === 0 || color === 7) {
1406
+ if (args > 50) {
1407
+ color += 3.5;
1408
+ }
1409
+ color = color / 10.5 * 255;
1410
+ return [color, color, color];
1411
+ }
1412
+ const mult = (~~(args > 50) + 1) * 0.5;
1413
+ const r = (color & 1) * mult * 255;
1414
+ const g = (color >> 1 & 1) * mult * 255;
1415
+ const b = (color >> 2 & 1) * mult * 255;
1416
+ return [r, g, b];
1417
+ };
1418
+ convert.ansi256.rgb = function(args) {
1419
+ if (args >= 232) {
1420
+ const c = (args - 232) * 10 + 8;
1421
+ return [c, c, c];
1422
+ }
1423
+ args -= 16;
1424
+ let rem;
1425
+ const r = Math.floor(args / 36) / 5 * 255;
1426
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
1427
+ const b = rem % 6 / 5 * 255;
1428
+ return [r, g, b];
1429
+ };
1430
+ convert.rgb.hex = function(args) {
1431
+ const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
1432
+ const string = integer.toString(16).toUpperCase();
1433
+ return "000000".substring(string.length) + string;
1434
+ };
1435
+ convert.hex.rgb = function(args) {
1436
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
1437
+ if (!match) {
1438
+ return [0, 0, 0];
1439
+ }
1440
+ let colorString = match[0];
1441
+ if (match[0].length === 3) {
1442
+ colorString = colorString.split("").map((char) => {
1443
+ return char + char;
1444
+ }).join("");
1445
+ }
1446
+ const integer = parseInt(colorString, 16);
1447
+ const r = integer >> 16 & 255;
1448
+ const g = integer >> 8 & 255;
1449
+ const b = integer & 255;
1450
+ return [r, g, b];
1451
+ };
1452
+ convert.rgb.hcg = function(rgb) {
1453
+ const r = rgb[0] / 255;
1454
+ const g = rgb[1] / 255;
1455
+ const b = rgb[2] / 255;
1456
+ const max = Math.max(Math.max(r, g), b);
1457
+ const min = Math.min(Math.min(r, g), b);
1458
+ const chroma = max - min;
1459
+ let grayscale;
1460
+ let hue;
1461
+ if (chroma < 1) {
1462
+ grayscale = min / (1 - chroma);
1463
+ } else {
1464
+ grayscale = 0;
1465
+ }
1466
+ if (chroma <= 0) {
1467
+ hue = 0;
1468
+ } else if (max === r) {
1469
+ hue = (g - b) / chroma % 6;
1470
+ } else if (max === g) {
1471
+ hue = 2 + (b - r) / chroma;
1472
+ } else {
1473
+ hue = 4 + (r - g) / chroma;
1474
+ }
1475
+ hue /= 6;
1476
+ hue %= 1;
1477
+ return [hue * 360, chroma * 100, grayscale * 100];
1478
+ };
1479
+ convert.hsl.hcg = function(hsl) {
1480
+ const s = hsl[1] / 100;
1481
+ const l = hsl[2] / 100;
1482
+ const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
1483
+ let f = 0;
1484
+ if (c < 1) {
1485
+ f = (l - 0.5 * c) / (1 - c);
1486
+ }
1487
+ return [hsl[0], c * 100, f * 100];
1488
+ };
1489
+ convert.hsv.hcg = function(hsv) {
1490
+ const s = hsv[1] / 100;
1491
+ const v = hsv[2] / 100;
1492
+ const c = s * v;
1493
+ let f = 0;
1494
+ if (c < 1) {
1495
+ f = (v - c) / (1 - c);
1496
+ }
1497
+ return [hsv[0], c * 100, f * 100];
1498
+ };
1499
+ convert.hcg.rgb = function(hcg) {
1500
+ const h = hcg[0] / 360;
1501
+ const c = hcg[1] / 100;
1502
+ const g = hcg[2] / 100;
1503
+ if (c === 0) {
1504
+ return [g * 255, g * 255, g * 255];
1505
+ }
1506
+ const pure = [0, 0, 0];
1507
+ const hi = h % 1 * 6;
1508
+ const v = hi % 1;
1509
+ const w = 1 - v;
1510
+ let mg = 0;
1511
+ switch (Math.floor(hi)) {
1512
+ case 0:
1513
+ pure[0] = 1;
1514
+ pure[1] = v;
1515
+ pure[2] = 0;
1516
+ break;
1517
+ case 1:
1518
+ pure[0] = w;
1519
+ pure[1] = 1;
1520
+ pure[2] = 0;
1521
+ break;
1522
+ case 2:
1523
+ pure[0] = 0;
1524
+ pure[1] = 1;
1525
+ pure[2] = v;
1526
+ break;
1527
+ case 3:
1528
+ pure[0] = 0;
1529
+ pure[1] = w;
1530
+ pure[2] = 1;
1531
+ break;
1532
+ case 4:
1533
+ pure[0] = v;
1534
+ pure[1] = 0;
1535
+ pure[2] = 1;
1536
+ break;
1537
+ default:
1538
+ pure[0] = 1;
1539
+ pure[1] = 0;
1540
+ pure[2] = w;
1541
+ }
1542
+ mg = (1 - c) * g;
1543
+ return [
1544
+ (c * pure[0] + mg) * 255,
1545
+ (c * pure[1] + mg) * 255,
1546
+ (c * pure[2] + mg) * 255
1547
+ ];
1548
+ };
1549
+ convert.hcg.hsv = function(hcg) {
1550
+ const c = hcg[1] / 100;
1551
+ const g = hcg[2] / 100;
1552
+ const v = c + g * (1 - c);
1553
+ let f = 0;
1554
+ if (v > 0) {
1555
+ f = c / v;
1556
+ }
1557
+ return [hcg[0], f * 100, v * 100];
1558
+ };
1559
+ convert.hcg.hsl = function(hcg) {
1560
+ const c = hcg[1] / 100;
1561
+ const g = hcg[2] / 100;
1562
+ const l = g * (1 - c) + 0.5 * c;
1563
+ let s = 0;
1564
+ if (l > 0 && l < 0.5) {
1565
+ s = c / (2 * l);
1566
+ } else if (l >= 0.5 && l < 1) {
1567
+ s = c / (2 * (1 - l));
1568
+ }
1569
+ return [hcg[0], s * 100, l * 100];
1570
+ };
1571
+ convert.hcg.hwb = function(hcg) {
1572
+ const c = hcg[1] / 100;
1573
+ const g = hcg[2] / 100;
1574
+ const v = c + g * (1 - c);
1575
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
1576
+ };
1577
+ convert.hwb.hcg = function(hwb) {
1578
+ const w = hwb[1] / 100;
1579
+ const b = hwb[2] / 100;
1580
+ const v = 1 - b;
1581
+ const c = v - w;
1582
+ let g = 0;
1583
+ if (c < 1) {
1584
+ g = (v - c) / (1 - c);
1585
+ }
1586
+ return [hwb[0], c * 100, g * 100];
1587
+ };
1588
+ convert.apple.rgb = function(apple) {
1589
+ return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
1590
+ };
1591
+ convert.rgb.apple = function(rgb) {
1592
+ return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
1593
+ };
1594
+ convert.gray.rgb = function(args) {
1595
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1596
+ };
1597
+ convert.gray.hsl = function(args) {
1598
+ return [0, 0, args[0]];
1599
+ };
1600
+ convert.gray.hsv = convert.gray.hsl;
1601
+ convert.gray.hwb = function(gray) {
1602
+ return [0, 100, gray[0]];
1603
+ };
1604
+ convert.gray.cmyk = function(gray) {
1605
+ return [0, 0, 0, gray[0]];
1606
+ };
1607
+ convert.gray.lab = function(gray) {
1608
+ return [gray[0], 0, 0];
1609
+ };
1610
+ convert.gray.hex = function(gray) {
1611
+ const val = Math.round(gray[0] / 100 * 255) & 255;
1612
+ const integer = (val << 16) + (val << 8) + val;
1613
+ const string = integer.toString(16).toUpperCase();
1614
+ return "000000".substring(string.length) + string;
1615
+ };
1616
+ convert.rgb.gray = function(rgb) {
1617
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1618
+ return [val / 255 * 100];
1619
+ };
1620
+ return conversions;
1621
+ }
1622
+ var route;
1623
+ var hasRequiredRoute;
1624
+ function requireRoute() {
1625
+ if (hasRequiredRoute) return route;
1626
+ hasRequiredRoute = 1;
1627
+ const conversions2 = requireConversions();
1628
+ function buildGraph() {
1629
+ const graph = {};
1630
+ const models = Object.keys(conversions2);
1631
+ for (let len = models.length, i = 0; i < len; i++) {
1632
+ graph[models[i]] = {
1633
+ // http://jsperf.com/1-vs-infinity
1634
+ // micro-opt, but this is simple.
1635
+ distance: -1,
1636
+ parent: null
1637
+ };
1638
+ }
1639
+ return graph;
1640
+ }
1641
+ function deriveBFS(fromModel) {
1642
+ const graph = buildGraph();
1643
+ const queue = [fromModel];
1644
+ graph[fromModel].distance = 0;
1645
+ while (queue.length) {
1646
+ const current = queue.pop();
1647
+ const adjacents = Object.keys(conversions2[current]);
1648
+ for (let len = adjacents.length, i = 0; i < len; i++) {
1649
+ const adjacent = adjacents[i];
1650
+ const node = graph[adjacent];
1651
+ if (node.distance === -1) {
1652
+ node.distance = graph[current].distance + 1;
1653
+ node.parent = current;
1654
+ queue.unshift(adjacent);
1655
+ }
1656
+ }
1657
+ }
1658
+ return graph;
1659
+ }
1660
+ function link(from, to) {
1661
+ return function(args) {
1662
+ return to(from(args));
1663
+ };
1664
+ }
1665
+ function wrapConversion(toModel, graph) {
1666
+ const path = [graph[toModel].parent, toModel];
1667
+ let fn = conversions2[graph[toModel].parent][toModel];
1668
+ let cur = graph[toModel].parent;
1669
+ while (graph[cur].parent) {
1670
+ path.unshift(graph[cur].parent);
1671
+ fn = link(conversions2[graph[cur].parent][cur], fn);
1672
+ cur = graph[cur].parent;
1673
+ }
1674
+ fn.conversion = path;
1675
+ return fn;
1676
+ }
1677
+ route = function(fromModel) {
1678
+ const graph = deriveBFS(fromModel);
1679
+ const conversion = {};
1680
+ const models = Object.keys(graph);
1681
+ for (let len = models.length, i = 0; i < len; i++) {
1682
+ const toModel = models[i];
1683
+ const node = graph[toModel];
1684
+ if (node.parent === null) {
1685
+ continue;
1686
+ }
1687
+ conversion[toModel] = wrapConversion(toModel, graph);
1688
+ }
1689
+ return conversion;
1690
+ };
1691
+ return route;
1692
+ }
1693
+ var colorConvert;
1694
+ var hasRequiredColorConvert;
1695
+ function requireColorConvert() {
1696
+ if (hasRequiredColorConvert) return colorConvert;
1697
+ hasRequiredColorConvert = 1;
1698
+ const conversions2 = requireConversions();
1699
+ const route2 = requireRoute();
1700
+ const convert = {};
1701
+ const models = Object.keys(conversions2);
1702
+ function wrapRaw(fn) {
1703
+ const wrappedFn = function(...args) {
1704
+ const arg0 = args[0];
1705
+ if (arg0 === void 0 || arg0 === null) {
1706
+ return arg0;
1707
+ }
1708
+ if (arg0.length > 1) {
1709
+ args = arg0;
1710
+ }
1711
+ return fn(args);
1712
+ };
1713
+ if ("conversion" in fn) {
1714
+ wrappedFn.conversion = fn.conversion;
1715
+ }
1716
+ return wrappedFn;
1717
+ }
1718
+ function wrapRounded(fn) {
1719
+ const wrappedFn = function(...args) {
1720
+ const arg0 = args[0];
1721
+ if (arg0 === void 0 || arg0 === null) {
1722
+ return arg0;
1723
+ }
1724
+ if (arg0.length > 1) {
1725
+ args = arg0;
1726
+ }
1727
+ const result = fn(args);
1728
+ if (typeof result === "object") {
1729
+ for (let len = result.length, i = 0; i < len; i++) {
1730
+ result[i] = Math.round(result[i]);
1731
+ }
1732
+ }
1733
+ return result;
1734
+ };
1735
+ if ("conversion" in fn) {
1736
+ wrappedFn.conversion = fn.conversion;
1737
+ }
1738
+ return wrappedFn;
1739
+ }
1740
+ models.forEach((fromModel) => {
1741
+ convert[fromModel] = {};
1742
+ Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
1743
+ Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
1744
+ const routes = route2(fromModel);
1745
+ const routeModels = Object.keys(routes);
1746
+ routeModels.forEach((toModel) => {
1747
+ const fn = routes[toModel];
1748
+ convert[fromModel][toModel] = wrapRounded(fn);
1749
+ convert[fromModel][toModel].raw = wrapRaw(fn);
1750
+ });
1751
+ });
1752
+ colorConvert = convert;
1753
+ return colorConvert;
1754
+ }
1755
+ ansiStyles.exports;
1756
+ var hasRequiredAnsiStyles;
1757
+ function requireAnsiStyles() {
1758
+ if (hasRequiredAnsiStyles) return ansiStyles.exports;
1759
+ hasRequiredAnsiStyles = 1;
1760
+ (function(module) {
1761
+ const wrapAnsi16 = (fn, offset) => (...args) => {
1762
+ const code = fn(...args);
1763
+ return `\x1B[${code + offset}m`;
1764
+ };
1765
+ const wrapAnsi256 = (fn, offset) => (...args) => {
1766
+ const code = fn(...args);
1767
+ return `\x1B[${38 + offset};5;${code}m`;
1768
+ };
1769
+ const wrapAnsi16m = (fn, offset) => (...args) => {
1770
+ const rgb = fn(...args);
1771
+ return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1772
+ };
1773
+ const ansi2ansi = (n) => n;
1774
+ const rgb2rgb = (r, g, b) => [r, g, b];
1775
+ const setLazyProperty = (object, property, get) => {
1776
+ Object.defineProperty(object, property, {
1777
+ get: () => {
1778
+ const value = get();
1779
+ Object.defineProperty(object, property, {
1780
+ value,
1781
+ enumerable: true,
1782
+ configurable: true
1783
+ });
1784
+ return value;
1785
+ },
1786
+ enumerable: true,
1787
+ configurable: true
1788
+ });
1789
+ };
1790
+ let colorConvert2;
1791
+ const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
1792
+ if (colorConvert2 === void 0) {
1793
+ colorConvert2 = requireColorConvert();
1794
+ }
1795
+ const offset = isBackground ? 10 : 0;
1796
+ const styles = {};
1797
+ for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
1798
+ const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
1799
+ if (sourceSpace === targetSpace) {
1800
+ styles[name] = wrap(identity, offset);
1801
+ } else if (typeof suite === "object") {
1802
+ styles[name] = wrap(suite[targetSpace], offset);
1803
+ }
1804
+ }
1805
+ return styles;
1806
+ };
1807
+ function assembleStyles() {
1808
+ const codes = /* @__PURE__ */ new Map();
1809
+ const styles = {
1810
+ modifier: {
1811
+ reset: [0, 0],
1812
+ // 21 isn't widely supported and 22 does the same thing
1813
+ bold: [1, 22],
1814
+ dim: [2, 22],
1815
+ italic: [3, 23],
1816
+ underline: [4, 24],
1817
+ inverse: [7, 27],
1818
+ hidden: [8, 28],
1819
+ strikethrough: [9, 29]
1820
+ },
1821
+ color: {
1822
+ black: [30, 39],
1823
+ red: [31, 39],
1824
+ green: [32, 39],
1825
+ yellow: [33, 39],
1826
+ blue: [34, 39],
1827
+ magenta: [35, 39],
1828
+ cyan: [36, 39],
1829
+ white: [37, 39],
1830
+ // Bright color
1831
+ blackBright: [90, 39],
1832
+ redBright: [91, 39],
1833
+ greenBright: [92, 39],
1834
+ yellowBright: [93, 39],
1835
+ blueBright: [94, 39],
1836
+ magentaBright: [95, 39],
1837
+ cyanBright: [96, 39],
1838
+ whiteBright: [97, 39]
1839
+ },
1840
+ bgColor: {
1841
+ bgBlack: [40, 49],
1842
+ bgRed: [41, 49],
1843
+ bgGreen: [42, 49],
1844
+ bgYellow: [43, 49],
1845
+ bgBlue: [44, 49],
1846
+ bgMagenta: [45, 49],
1847
+ bgCyan: [46, 49],
1848
+ bgWhite: [47, 49],
1849
+ // Bright color
1850
+ bgBlackBright: [100, 49],
1851
+ bgRedBright: [101, 49],
1852
+ bgGreenBright: [102, 49],
1853
+ bgYellowBright: [103, 49],
1854
+ bgBlueBright: [104, 49],
1855
+ bgMagentaBright: [105, 49],
1856
+ bgCyanBright: [106, 49],
1857
+ bgWhiteBright: [107, 49]
1858
+ }
1859
+ };
1860
+ styles.color.gray = styles.color.blackBright;
1861
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
1862
+ styles.color.grey = styles.color.blackBright;
1863
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
1864
+ for (const [groupName, group] of Object.entries(styles)) {
1865
+ for (const [styleName, style] of Object.entries(group)) {
1866
+ styles[styleName] = {
1867
+ open: `\x1B[${style[0]}m`,
1868
+ close: `\x1B[${style[1]}m`
1869
+ };
1870
+ group[styleName] = styles[styleName];
1871
+ codes.set(style[0], style[1]);
1872
+ }
1873
+ Object.defineProperty(styles, groupName, {
1874
+ value: group,
1875
+ enumerable: false
1876
+ });
1877
+ }
1878
+ Object.defineProperty(styles, "codes", {
1879
+ value: codes,
1880
+ enumerable: false
1881
+ });
1882
+ styles.color.close = "\x1B[39m";
1883
+ styles.bgColor.close = "\x1B[49m";
1884
+ setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
1885
+ setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
1886
+ setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
1887
+ setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
1888
+ setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
1889
+ setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
1890
+ return styles;
1891
+ }
1892
+ Object.defineProperty(module, "exports", {
1893
+ enumerable: true,
1894
+ get: assembleStyles
1895
+ });
1896
+ })(ansiStyles);
1897
+ return ansiStyles.exports;
1898
+ }
1899
+ var wrapAnsi_1;
1900
+ var hasRequiredWrapAnsi;
1901
+ function requireWrapAnsi() {
1902
+ if (hasRequiredWrapAnsi) return wrapAnsi_1;
1903
+ hasRequiredWrapAnsi = 1;
1904
+ const stringWidth2 = requireStringWidth();
1905
+ const stripAnsi2 = requireStripAnsi();
1906
+ const ansiStyles2 = requireAnsiStyles();
1907
+ const ESCAPES = /* @__PURE__ */ new Set([
1908
+ "\x1B",
1909
+ "›"
1910
+ ]);
1911
+ const END_CODE = 39;
1912
+ const wrapAnsi2 = (code) => `${ESCAPES.values().next().value}[${code}m`;
1913
+ const wordLengths = (string) => string.split(" ").map((character) => stringWidth2(character));
1914
+ const wrapWord = (rows, word, columns) => {
1915
+ const characters = [...word];
1916
+ let isInsideEscape = false;
1917
+ let visible = stringWidth2(stripAnsi2(rows[rows.length - 1]));
1918
+ for (const [index, character] of characters.entries()) {
1919
+ const characterLength = stringWidth2(character);
1920
+ if (visible + characterLength <= columns) {
1921
+ rows[rows.length - 1] += character;
1922
+ } else {
1923
+ rows.push(character);
1924
+ visible = 0;
1925
+ }
1926
+ if (ESCAPES.has(character)) {
1927
+ isInsideEscape = true;
1928
+ } else if (isInsideEscape && character === "m") {
1929
+ isInsideEscape = false;
1930
+ continue;
1931
+ }
1932
+ if (isInsideEscape) {
1933
+ continue;
1934
+ }
1935
+ visible += characterLength;
1936
+ if (visible === columns && index < characters.length - 1) {
1937
+ rows.push("");
1938
+ visible = 0;
1939
+ }
1940
+ }
1941
+ if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) {
1942
+ rows[rows.length - 2] += rows.pop();
1943
+ }
1944
+ };
1945
+ const stringVisibleTrimSpacesRight = (str) => {
1946
+ const words = str.split(" ");
1947
+ let last = words.length;
1948
+ while (last > 0) {
1949
+ if (stringWidth2(words[last - 1]) > 0) {
1950
+ break;
1951
+ }
1952
+ last--;
1953
+ }
1954
+ if (last === words.length) {
1955
+ return str;
1956
+ }
1957
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
1958
+ };
1959
+ const exec = (string, columns, options = {}) => {
1960
+ if (options.trim !== false && string.trim() === "") {
1961
+ return "";
1962
+ }
1963
+ let pre = "";
1964
+ let ret = "";
1965
+ let escapeCode;
1966
+ const lengths = wordLengths(string);
1967
+ let rows = [""];
1968
+ for (const [index, word] of string.split(" ").entries()) {
1969
+ if (options.trim !== false) {
1970
+ rows[rows.length - 1] = rows[rows.length - 1].trimLeft();
1971
+ }
1972
+ let rowLength = stringWidth2(rows[rows.length - 1]);
1973
+ if (index !== 0) {
1974
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
1975
+ rows.push("");
1976
+ rowLength = 0;
1977
+ }
1978
+ if (rowLength > 0 || options.trim === false) {
1979
+ rows[rows.length - 1] += " ";
1980
+ rowLength++;
1981
+ }
1982
+ }
1983
+ if (options.hard && lengths[index] > columns) {
1984
+ const remainingColumns = columns - rowLength;
1985
+ const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
1986
+ const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
1987
+ if (breaksStartingNextLine < breaksStartingThisLine) {
1988
+ rows.push("");
1989
+ }
1990
+ wrapWord(rows, word, columns);
1991
+ continue;
1992
+ }
1993
+ if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
1994
+ if (options.wordWrap === false && rowLength < columns) {
1995
+ wrapWord(rows, word, columns);
1996
+ continue;
1997
+ }
1998
+ rows.push("");
1999
+ }
2000
+ if (rowLength + lengths[index] > columns && options.wordWrap === false) {
2001
+ wrapWord(rows, word, columns);
2002
+ continue;
2003
+ }
2004
+ rows[rows.length - 1] += word;
2005
+ }
2006
+ if (options.trim !== false) {
2007
+ rows = rows.map(stringVisibleTrimSpacesRight);
2008
+ }
2009
+ pre = rows.join("\n");
2010
+ for (const [index, character] of [...pre].entries()) {
2011
+ ret += character;
2012
+ if (ESCAPES.has(character)) {
2013
+ const code2 = parseFloat(/\d[^m]*/.exec(pre.slice(index, index + 4)));
2014
+ escapeCode = code2 === END_CODE ? null : code2;
2015
+ }
2016
+ const code = ansiStyles2.codes.get(Number(escapeCode));
2017
+ if (escapeCode && code) {
2018
+ if (pre[index + 1] === "\n") {
2019
+ ret += wrapAnsi2(code);
2020
+ } else if (character === "\n") {
2021
+ ret += wrapAnsi2(escapeCode);
2022
+ }
2023
+ }
2024
+ }
2025
+ return ret;
2026
+ };
2027
+ wrapAnsi_1 = (string, columns, options) => {
2028
+ return String(string).normalize().replace(/\r\n/g, "\n").split("\n").map((line) => exec(line, columns, options)).join("\n");
2029
+ };
2030
+ return wrapAnsi_1;
2031
+ }
2032
+ var wrapAnsiExports = requireWrapAnsi();
2033
+ const wrapAnsi = /* @__PURE__ */ getDefaultExportFromCjs(wrapAnsiExports);
2034
+ function breakLines(content, width) {
2035
+ return content.split("\n").flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }).split("\n").map((str) => str.trimEnd())).join("\n");
2036
+ }
2037
+ function readlineWidth() {
2038
+ return cliWidth({ defaultWidth: 80, output: readline().output });
2039
+ }
2040
+ var lib;
2041
+ var hasRequiredLib;
2042
+ function requireLib() {
2043
+ if (hasRequiredLib) return lib;
2044
+ hasRequiredLib = 1;
2045
+ const Stream = require$$0$2;
2046
+ class MuteStream2 extends Stream {
2047
+ #isTTY = null;
2048
+ constructor(opts = {}) {
2049
+ super(opts);
2050
+ this.writable = this.readable = true;
2051
+ this.muted = false;
2052
+ this.on("pipe", this._onpipe);
2053
+ this.replace = opts.replace;
2054
+ this._prompt = opts.prompt || null;
2055
+ this._hadControl = false;
2056
+ }
2057
+ #destSrc(key, def) {
2058
+ if (this._dest) {
2059
+ return this._dest[key];
2060
+ }
2061
+ if (this._src) {
2062
+ return this._src[key];
2063
+ }
2064
+ return def;
2065
+ }
2066
+ #proxy(method, ...args) {
2067
+ if (typeof this._dest?.[method] === "function") {
2068
+ this._dest[method](...args);
2069
+ }
2070
+ if (typeof this._src?.[method] === "function") {
2071
+ this._src[method](...args);
2072
+ }
2073
+ }
2074
+ get isTTY() {
2075
+ if (this.#isTTY !== null) {
2076
+ return this.#isTTY;
2077
+ }
2078
+ return this.#destSrc("isTTY", false);
2079
+ }
2080
+ // basically just get replace the getter/setter with a regular value
2081
+ set isTTY(val) {
2082
+ this.#isTTY = val;
2083
+ }
2084
+ get rows() {
2085
+ return this.#destSrc("rows");
2086
+ }
2087
+ get columns() {
2088
+ return this.#destSrc("columns");
2089
+ }
2090
+ mute() {
2091
+ this.muted = true;
2092
+ }
2093
+ unmute() {
2094
+ this.muted = false;
2095
+ }
2096
+ _onpipe(src) {
2097
+ this._src = src;
2098
+ }
2099
+ pipe(dest, options) {
2100
+ this._dest = dest;
2101
+ return super.pipe(dest, options);
2102
+ }
2103
+ pause() {
2104
+ if (this._src) {
2105
+ return this._src.pause();
2106
+ }
2107
+ }
2108
+ resume() {
2109
+ if (this._src) {
2110
+ return this._src.resume();
2111
+ }
2112
+ }
2113
+ write(c) {
2114
+ if (this.muted) {
2115
+ if (!this.replace) {
2116
+ return true;
2117
+ }
2118
+ if (c.match(/^\u001b/)) {
2119
+ if (c.indexOf(this._prompt) === 0) {
2120
+ c = c.slice(this._prompt.length);
2121
+ c = c.replace(/./g, this.replace);
2122
+ c = this._prompt + c;
2123
+ }
2124
+ this._hadControl = true;
2125
+ return this.emit("data", c);
2126
+ } else {
2127
+ if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
2128
+ this._hadControl = false;
2129
+ this.emit("data", this._prompt);
2130
+ c = c.slice(this._prompt.length);
2131
+ }
2132
+ c = c.toString().replace(/./g, this.replace);
2133
+ }
2134
+ }
2135
+ this.emit("data", c);
2136
+ }
2137
+ end(c) {
2138
+ if (this.muted) {
2139
+ if (c && this.replace) {
2140
+ c = c.toString().replace(/./g, this.replace);
2141
+ } else {
2142
+ c = null;
2143
+ }
2144
+ }
2145
+ if (c) {
2146
+ this.emit("data", c);
2147
+ }
2148
+ this.emit("end");
2149
+ }
2150
+ destroy(...args) {
2151
+ return this.#proxy("destroy", ...args);
2152
+ }
2153
+ destroySoon(...args) {
2154
+ return this.#proxy("destroySoon", ...args);
2155
+ }
2156
+ close(...args) {
2157
+ return this.#proxy("close", ...args);
2158
+ }
2159
+ }
2160
+ lib = MuteStream2;
2161
+ return lib;
2162
+ }
2163
+ var libExports = requireLib();
2164
+ const MuteStream = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
2165
+ const signals = [];
2166
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
2167
+ if (process.platform !== "win32") {
2168
+ signals.push(
2169
+ "SIGALRM",
2170
+ "SIGABRT",
2171
+ "SIGVTALRM",
2172
+ "SIGXCPU",
2173
+ "SIGXFSZ",
2174
+ "SIGUSR2",
2175
+ "SIGTRAP",
2176
+ "SIGSYS",
2177
+ "SIGQUIT",
2178
+ "SIGIOT"
2179
+ // should detect profiler and enable/disable accordingly.
2180
+ // see #21
2181
+ // 'SIGPROF'
2182
+ );
2183
+ }
2184
+ if (process.platform === "linux") {
2185
+ signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
2186
+ }
2187
+ const processOk = (process2) => !!process2 && typeof process2 === "object" && typeof process2.removeListener === "function" && typeof process2.emit === "function" && typeof process2.reallyExit === "function" && typeof process2.listeners === "function" && typeof process2.kill === "function" && typeof process2.pid === "number" && typeof process2.on === "function";
2188
+ const kExitEmitter = /* @__PURE__ */ Symbol.for("signal-exit emitter");
2189
+ const global = globalThis;
2190
+ const ObjectDefineProperty = Object.defineProperty.bind(Object);
2191
+ class Emitter {
2192
+ emitted = {
2193
+ afterExit: false,
2194
+ exit: false
2195
+ };
2196
+ listeners = {
2197
+ afterExit: [],
2198
+ exit: []
2199
+ };
2200
+ count = 0;
2201
+ id = Math.random();
2202
+ constructor() {
2203
+ if (global[kExitEmitter]) {
2204
+ return global[kExitEmitter];
2205
+ }
2206
+ ObjectDefineProperty(global, kExitEmitter, {
2207
+ value: this,
2208
+ writable: false,
2209
+ enumerable: false,
2210
+ configurable: false
2211
+ });
2212
+ }
2213
+ on(ev, fn) {
2214
+ this.listeners[ev].push(fn);
2215
+ }
2216
+ removeListener(ev, fn) {
2217
+ const list = this.listeners[ev];
2218
+ const i = list.indexOf(fn);
2219
+ if (i === -1) {
2220
+ return;
2221
+ }
2222
+ if (i === 0 && list.length === 1) {
2223
+ list.length = 0;
2224
+ } else {
2225
+ list.splice(i, 1);
2226
+ }
2227
+ }
2228
+ emit(ev, code, signal) {
2229
+ if (this.emitted[ev]) {
2230
+ return false;
2231
+ }
2232
+ this.emitted[ev] = true;
2233
+ let ret = false;
2234
+ for (const fn of this.listeners[ev]) {
2235
+ ret = fn(code, signal) === true || ret;
2236
+ }
2237
+ if (ev === "exit") {
2238
+ ret = this.emit("afterExit", code, signal) || ret;
2239
+ }
2240
+ return ret;
2241
+ }
2242
+ }
2243
+ class SignalExitBase {
2244
+ }
2245
+ const signalExitWrap = (handler) => {
2246
+ return {
2247
+ onExit(cb, opts) {
2248
+ return handler.onExit(cb, opts);
2249
+ },
2250
+ load() {
2251
+ return handler.load();
2252
+ },
2253
+ unload() {
2254
+ return handler.unload();
2255
+ }
2256
+ };
2257
+ };
2258
+ class SignalExitFallback extends SignalExitBase {
2259
+ onExit() {
2260
+ return () => {
2261
+ };
2262
+ }
2263
+ load() {
2264
+ }
2265
+ unload() {
2266
+ }
2267
+ }
2268
+ class SignalExit extends SignalExitBase {
2269
+ // "SIGHUP" throws an `ENOSYS` error on Windows,
2270
+ // so use a supported signal instead
2271
+ /* c8 ignore start */
2272
+ #hupSig = process$1.platform === "win32" ? "SIGINT" : "SIGHUP";
2273
+ /* c8 ignore stop */
2274
+ #emitter = new Emitter();
2275
+ #process;
2276
+ #originalProcessEmit;
2277
+ #originalProcessReallyExit;
2278
+ #sigListeners = {};
2279
+ #loaded = false;
2280
+ constructor(process2) {
2281
+ super();
2282
+ this.#process = process2;
2283
+ this.#sigListeners = {};
2284
+ for (const sig of signals) {
2285
+ this.#sigListeners[sig] = () => {
2286
+ const listeners = this.#process.listeners(sig);
2287
+ let { count } = this.#emitter;
2288
+ const p = process2;
2289
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
2290
+ count += p.__signal_exit_emitter__.count;
2291
+ }
2292
+ if (listeners.length === count) {
2293
+ this.unload();
2294
+ const ret = this.#emitter.emit("exit", null, sig);
2295
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
2296
+ if (!ret)
2297
+ process2.kill(process2.pid, s);
2298
+ }
2299
+ };
2300
+ }
2301
+ this.#originalProcessReallyExit = process2.reallyExit;
2302
+ this.#originalProcessEmit = process2.emit;
2303
+ }
2304
+ onExit(cb, opts) {
2305
+ if (!processOk(this.#process)) {
2306
+ return () => {
2307
+ };
2308
+ }
2309
+ if (this.#loaded === false) {
2310
+ this.load();
2311
+ }
2312
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
2313
+ this.#emitter.on(ev, cb);
2314
+ return () => {
2315
+ this.#emitter.removeListener(ev, cb);
2316
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
2317
+ this.unload();
2318
+ }
2319
+ };
2320
+ }
2321
+ load() {
2322
+ if (this.#loaded) {
2323
+ return;
2324
+ }
2325
+ this.#loaded = true;
2326
+ this.#emitter.count += 1;
2327
+ for (const sig of signals) {
2328
+ try {
2329
+ const fn = this.#sigListeners[sig];
2330
+ if (fn)
2331
+ this.#process.on(sig, fn);
2332
+ } catch (_) {
2333
+ }
2334
+ }
2335
+ this.#process.emit = (ev, ...a) => {
2336
+ return this.#processEmit(ev, ...a);
2337
+ };
2338
+ this.#process.reallyExit = (code) => {
2339
+ return this.#processReallyExit(code);
2340
+ };
2341
+ }
2342
+ unload() {
2343
+ if (!this.#loaded) {
2344
+ return;
2345
+ }
2346
+ this.#loaded = false;
2347
+ signals.forEach((sig) => {
2348
+ const listener = this.#sigListeners[sig];
2349
+ if (!listener) {
2350
+ throw new Error("Listener not defined for signal: " + sig);
2351
+ }
2352
+ try {
2353
+ this.#process.removeListener(sig, listener);
2354
+ } catch (_) {
2355
+ }
2356
+ });
2357
+ this.#process.emit = this.#originalProcessEmit;
2358
+ this.#process.reallyExit = this.#originalProcessReallyExit;
2359
+ this.#emitter.count -= 1;
2360
+ }
2361
+ #processReallyExit(code) {
2362
+ if (!processOk(this.#process)) {
2363
+ return 0;
2364
+ }
2365
+ this.#process.exitCode = code || 0;
2366
+ this.#emitter.emit("exit", this.#process.exitCode, null);
2367
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
2368
+ }
2369
+ #processEmit(ev, ...args) {
2370
+ const og = this.#originalProcessEmit;
2371
+ if (ev === "exit" && processOk(this.#process)) {
2372
+ if (typeof args[0] === "number") {
2373
+ this.#process.exitCode = args[0];
2374
+ }
2375
+ const ret = og.call(this.#process, ev, ...args);
2376
+ this.#emitter.emit("exit", this.#process.exitCode, null);
2377
+ return ret;
2378
+ } else {
2379
+ return og.call(this.#process, ev, ...args);
2380
+ }
2381
+ }
2382
+ }
2383
+ const process$1 = globalThis.process;
2384
+ const {
2385
+ /**
2386
+ * Called when the process is exiting, whether via signal, explicit
2387
+ * exit, or running out of stuff to do.
2388
+ *
2389
+ * If the global process object is not suitable for instrumentation,
2390
+ * then this will be a no-op.
2391
+ *
2392
+ * Returns a function that may be used to unload signal-exit.
2393
+ */
2394
+ onExit
2395
+ } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
2396
+ const ESC = "\x1B[";
2397
+ const cursorLeft = ESC + "G";
2398
+ const cursorHide = ESC + "?25l";
2399
+ const cursorShow = ESC + "?25h";
2400
+ const cursorUp = (rows = 1) => rows > 0 ? `${ESC}${rows}A` : "";
2401
+ const cursorDown = (rows = 1) => rows > 0 ? `${ESC}${rows}B` : "";
2402
+ const cursorTo = (x, y) => {
2403
+ return `${ESC}${x + 1}G`;
2404
+ };
2405
+ const eraseLine = ESC + "2K";
2406
+ const eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
2407
+ const height = (content) => content.split("\n").length;
2408
+ const lastLine = (content) => content.split("\n").pop() ?? "";
2409
+ class ScreenManager {
2410
+ // These variables are keeping information to allow correct prompt re-rendering
2411
+ height = 0;
2412
+ extraLinesUnderPrompt = 0;
2413
+ cursorPos;
2414
+ rl;
2415
+ constructor(rl) {
2416
+ this.rl = rl;
2417
+ this.cursorPos = rl.getCursorPos();
2418
+ }
2419
+ write(content) {
2420
+ this.rl.output.unmute();
2421
+ this.rl.output.write(content);
2422
+ this.rl.output.mute();
2423
+ }
2424
+ render(content, bottomContent = "") {
2425
+ const promptLine = lastLine(content);
2426
+ const rawPromptLine = stripVTControlCharacters(promptLine);
2427
+ let prompt = rawPromptLine;
2428
+ if (this.rl.line.length > 0) {
2429
+ prompt = prompt.slice(0, -this.rl.line.length);
2430
+ }
2431
+ this.rl.setPrompt(prompt);
2432
+ this.cursorPos = this.rl.getCursorPos();
2433
+ const width = readlineWidth();
2434
+ content = breakLines(content, width);
2435
+ bottomContent = breakLines(bottomContent, width);
2436
+ if (rawPromptLine.length % width === 0) {
2437
+ content += "\n";
2438
+ }
2439
+ let output = content + (bottomContent ? "\n" + bottomContent : "");
2440
+ const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
2441
+ const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
2442
+ if (bottomContentHeight > 0)
2443
+ output += cursorUp(bottomContentHeight);
2444
+ output += cursorTo(this.cursorPos.cols);
2445
+ this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
2446
+ this.extraLinesUnderPrompt = bottomContentHeight;
2447
+ this.height = height(output);
2448
+ }
2449
+ checkCursorPos() {
2450
+ const cursorPos = this.rl.getCursorPos();
2451
+ if (cursorPos.cols !== this.cursorPos.cols) {
2452
+ this.write(cursorTo(cursorPos.cols));
2453
+ this.cursorPos = cursorPos;
2454
+ }
2455
+ }
2456
+ done({ clearContent }) {
2457
+ this.rl.setPrompt("");
2458
+ let output = cursorDown(this.extraLinesUnderPrompt);
2459
+ output += clearContent ? eraseLines(this.height) : "\n";
2460
+ output += cursorShow;
2461
+ this.write(output);
2462
+ this.rl.close();
2463
+ }
2464
+ }
2465
+ class PromisePolyfill extends Promise {
2466
+ // Available starting from Node 22
2467
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
2468
+ static withResolver() {
2469
+ let resolve;
2470
+ let reject;
2471
+ const promise = new Promise((res, rej) => {
2472
+ resolve = res;
2473
+ reject = rej;
2474
+ });
2475
+ return { promise, resolve, reject };
2476
+ }
2477
+ }
2478
+ function getCallSites() {
2479
+ const _prepareStackTrace = Error.prepareStackTrace;
2480
+ let result = [];
2481
+ try {
2482
+ Error.prepareStackTrace = (_, callSites) => {
2483
+ const callSitesWithoutCurrent = callSites.slice(1);
2484
+ result = callSitesWithoutCurrent;
2485
+ return callSitesWithoutCurrent;
2486
+ };
2487
+ new Error().stack;
2488
+ } catch {
2489
+ return result;
2490
+ }
2491
+ Error.prepareStackTrace = _prepareStackTrace;
2492
+ return result;
2493
+ }
2494
+ function createPrompt(view) {
2495
+ const callSites = getCallSites();
2496
+ const prompt = (config, context = {}) => {
2497
+ const { input: input2 = process.stdin, signal } = context;
2498
+ const cleanups = /* @__PURE__ */ new Set();
2499
+ const output = new MuteStream();
2500
+ output.pipe(context.output ?? process.stdout);
2501
+ const rl = readline$1.createInterface({
2502
+ terminal: true,
2503
+ input: input2,
2504
+ output
2505
+ });
2506
+ const screen = new ScreenManager(rl);
2507
+ const { promise, resolve, reject } = PromisePolyfill.withResolver();
2508
+ const cancel = () => reject(new CancelPromptError());
2509
+ if (signal) {
2510
+ const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
2511
+ if (signal.aborted) {
2512
+ abort();
2513
+ return Object.assign(promise, { cancel });
2514
+ }
2515
+ signal.addEventListener("abort", abort);
2516
+ cleanups.add(() => signal.removeEventListener("abort", abort));
2517
+ }
2518
+ cleanups.add(onExit((code, signal2) => {
2519
+ reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
2520
+ }));
2521
+ const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
2522
+ rl.on("SIGINT", sigint);
2523
+ cleanups.add(() => rl.removeListener("SIGINT", sigint));
2524
+ const checkCursorPos = () => screen.checkCursorPos();
2525
+ rl.input.on("keypress", checkCursorPos);
2526
+ cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
2527
+ return withHooks(rl, (cycle) => {
2528
+ const hooksCleanup = AsyncResource.bind(() => effectScheduler.clearAll());
2529
+ rl.on("close", hooksCleanup);
2530
+ cleanups.add(() => rl.removeListener("close", hooksCleanup));
2531
+ cycle(() => {
2532
+ try {
2533
+ const nextView = view(config, (value) => {
2534
+ setImmediate(() => resolve(value));
2535
+ });
2536
+ if (nextView === void 0) {
2537
+ const callerFilename = callSites[1]?.getFileName();
2538
+ throw new Error(`Prompt functions must return a string.
2539
+ at ${callerFilename}`);
2540
+ }
2541
+ const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
2542
+ screen.render(content, bottomContent);
2543
+ effectScheduler.run();
2544
+ } catch (error) {
2545
+ reject(error);
2546
+ }
2547
+ });
2548
+ return Object.assign(promise.then((answer) => {
2549
+ effectScheduler.clearAll();
2550
+ return answer;
2551
+ }, (error) => {
2552
+ effectScheduler.clearAll();
2553
+ throw error;
2554
+ }).finally(() => {
2555
+ cleanups.forEach((cleanup) => cleanup());
2556
+ screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
2557
+ output.end();
2558
+ }).then(() => promise), { cancel });
2559
+ });
2560
+ };
2561
+ return prompt;
2562
+ }
2563
+ const inputTheme = {
2564
+ validationFailureMode: "keep"
2565
+ };
2566
+ const input = createPrompt((config, done) => {
2567
+ const { prefill = "tab" } = config;
2568
+ const theme = makeTheme(inputTheme, config.theme);
2569
+ const [status, setStatus] = useState("idle");
2570
+ const [defaultValue = "", setDefaultValue] = useState(config.default);
2571
+ const [errorMsg, setError] = useState();
2572
+ const [value, setValue] = useState("");
2573
+ const prefix = usePrefix({ status, theme });
2574
+ async function validate(value2) {
2575
+ const { required, pattern, patternError = "Invalid input" } = config;
2576
+ if (required && !value2) {
2577
+ return "You must provide a value";
2578
+ }
2579
+ if (pattern && !pattern.test(value2)) {
2580
+ return patternError;
2581
+ }
2582
+ if (typeof config.validate === "function") {
2583
+ return await config.validate(value2) || "You must provide a valid value";
2584
+ }
2585
+ return true;
2586
+ }
2587
+ useKeypress(async (key, rl) => {
2588
+ if (status !== "idle") {
2589
+ return;
2590
+ }
2591
+ if (isEnterKey(key)) {
2592
+ const answer = value || defaultValue;
2593
+ setStatus("loading");
2594
+ const isValid = await validate(answer);
2595
+ if (isValid === true) {
2596
+ setValue(answer);
2597
+ setStatus("done");
2598
+ done(answer);
2599
+ } else {
2600
+ if (theme.validationFailureMode === "clear") {
2601
+ setValue("");
2602
+ } else {
2603
+ rl.write(value);
2604
+ }
2605
+ setError(isValid);
2606
+ setStatus("idle");
2607
+ }
2608
+ } else if (isBackspaceKey(key) && !value) {
2609
+ setDefaultValue(void 0);
2610
+ } else if (isTabKey(key) && !value) {
2611
+ setDefaultValue(void 0);
2612
+ rl.clearLine(0);
2613
+ rl.write(defaultValue);
2614
+ setValue(defaultValue);
2615
+ } else {
2616
+ setValue(rl.line);
2617
+ setError(void 0);
2618
+ }
2619
+ });
2620
+ useEffect((rl) => {
2621
+ if (prefill === "editable" && defaultValue) {
2622
+ rl.write(defaultValue);
2623
+ setValue(defaultValue);
2624
+ }
2625
+ }, []);
2626
+ const message = theme.style.message(config.message, status);
2627
+ let formattedValue = value;
2628
+ if (typeof config.transformer === "function") {
2629
+ formattedValue = config.transformer(value, { isFinal: status === "done" });
2630
+ } else if (status === "done") {
2631
+ formattedValue = theme.style.answer(value);
2632
+ }
2633
+ let defaultStr;
2634
+ if (defaultValue && status !== "done" && !value) {
2635
+ defaultStr = theme.style.defaultAnswer(defaultValue);
2636
+ }
2637
+ let error = "";
2638
+ if (errorMsg) {
2639
+ error = theme.style.error(errorMsg);
2640
+ }
2641
+ return [
2642
+ [prefix, message, defaultStr, formattedValue].filter((v) => v !== void 0).join(" "),
2643
+ error
2644
+ ];
2645
+ });
2646
+ export {
2647
+ ValidationError as V,
2648
+ createPrompt as a,
2649
+ breakLines as b,
2650
+ colors as c,
2651
+ useState as d,
2652
+ usePrefix as e,
2653
+ figures as f,
2654
+ useKeypress as g,
2655
+ isEnterKey as h,
2656
+ input as i,
2657
+ isTabKey as j,
2658
+ cursorHide as k,
2659
+ isUpKey as l,
2660
+ makeTheme as m,
2661
+ isDownKey as n,
2662
+ isNumberKey as o,
2663
+ isBackspaceKey as p,
2664
+ useEffect as q,
2665
+ readlineWidth as r,
2666
+ useRef as u,
2667
+ withPointer as w
2668
+ };