@rolldown/browser 1.0.0-beta.10

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 (56) hide show
  1. package/LICENSE +25 -0
  2. package/bin/cli.mjs +2 -0
  3. package/dist/cli.cjs +1748 -0
  4. package/dist/cli.d.cts +1 -0
  5. package/dist/cli.d.mts +1 -0
  6. package/dist/cli.mjs +1771 -0
  7. package/dist/config.cjs +12 -0
  8. package/dist/config.d.cts +11 -0
  9. package/dist/config.d.mts +11 -0
  10. package/dist/config.mjs +10 -0
  11. package/dist/experimental-index.browser.mjs +76 -0
  12. package/dist/experimental-index.cjs +129 -0
  13. package/dist/experimental-index.d.cts +96 -0
  14. package/dist/experimental-index.d.mts +96 -0
  15. package/dist/experimental-index.mjs +84 -0
  16. package/dist/filter-index.cjs +53 -0
  17. package/dist/filter-index.d.cts +3 -0
  18. package/dist/filter-index.d.mts +3 -0
  19. package/dist/filter-index.mjs +43 -0
  20. package/dist/index.browser.mjs +3 -0
  21. package/dist/index.cjs +9 -0
  22. package/dist/index.d.cts +3 -0
  23. package/dist/index.d.mts +3 -0
  24. package/dist/index.mjs +5 -0
  25. package/dist/parallel-plugin-worker.cjs +33 -0
  26. package/dist/parallel-plugin-worker.d.cts +1 -0
  27. package/dist/parallel-plugin-worker.d.mts +1 -0
  28. package/dist/parallel-plugin-worker.mjs +32 -0
  29. package/dist/parallel-plugin.cjs +8 -0
  30. package/dist/parallel-plugin.d.cts +14 -0
  31. package/dist/parallel-plugin.d.mts +14 -0
  32. package/dist/parallel-plugin.mjs +7 -0
  33. package/dist/parse-ast-index.cjs +4 -0
  34. package/dist/parse-ast-index.d.cts +9 -0
  35. package/dist/parse-ast-index.d.mts +9 -0
  36. package/dist/parse-ast-index.mjs +3 -0
  37. package/dist/rolldown-binding.wasi-browser.js +111 -0
  38. package/dist/rolldown-binding.wasi.cjs +135 -0
  39. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  40. package/dist/shared/chunk-DDkG_k5U.cjs +39 -0
  41. package/dist/shared/define-config.d-BBxr6_Bs.d.mts +1167 -0
  42. package/dist/shared/define-config.d-DII1FzpF.d.cts +1167 -0
  43. package/dist/shared/dist-BMVjvV-v.cjs +249 -0
  44. package/dist/shared/dist-JdACkHJM.mjs +147 -0
  45. package/dist/shared/load-config-CS9U8pRI.cjs +125 -0
  46. package/dist/shared/load-config-MCu-vRGz.mjs +119 -0
  47. package/dist/shared/parse-ast-index-BuelS_NF.cjs +314 -0
  48. package/dist/shared/parse-ast-index-C31FpvkE.mjs +260 -0
  49. package/dist/shared/prompt-8EeOGx1_.cjs +854 -0
  50. package/dist/shared/prompt-C3zHEaSG.mjs +852 -0
  51. package/dist/shared/src-AQQVsE86.mjs +4449 -0
  52. package/dist/shared/src-DKImwtxN.cjs +4647 -0
  53. package/dist/src-8Q9XjZLd.js +4329 -0
  54. package/dist/wasi-worker-browser.mjs +39 -0
  55. package/dist/wasi-worker.mjs +63 -0
  56. package/package.json +71 -0
package/dist/cli.mjs ADDED
@@ -0,0 +1,1771 @@
1
+ import { description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "./shared/src-AQQVsE86.mjs";
2
+ import { arraify } from "./shared/dist-JdACkHJM.mjs";
3
+ import "./shared/parse-ast-index-C31FpvkE.mjs";
4
+ import { loadConfig } from "./shared/load-config-MCu-vRGz.mjs";
5
+ import path, { sep } from "node:path";
6
+ import colors from "ansis";
7
+ import process$1 from "node:process";
8
+ import { formatWithOptions, parseArgs } from "node:util";
9
+ import * as tty from "node:tty";
10
+ import { performance } from "node:perf_hooks";
11
+
12
+ //#region rolldown:runtime
13
+ var __create = Object.create;
14
+ var __defProp = Object.defineProperty;
15
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
16
+ var __getOwnPropNames = Object.getOwnPropertyNames;
17
+ var __getProtoOf = Object.getPrototypeOf;
18
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
19
+ var __commonJS = (cb, mod) => function() {
20
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
21
+ };
22
+ var __copyProps = (to, from, except, desc) => {
23
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i$1 = 0, n$1 = keys.length, key; i$1 < n$1; i$1++) {
24
+ key = keys[i$1];
25
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
26
+ get: ((k) => from[k]).bind(null, key),
27
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
28
+ });
29
+ }
30
+ return to;
31
+ };
32
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
33
+ value: mod,
34
+ enumerable: true
35
+ }) : target, mod));
36
+
37
+ //#endregion
38
+ //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
39
+ const LogLevels = {
40
+ silent: Number.NEGATIVE_INFINITY,
41
+ fatal: 0,
42
+ error: 0,
43
+ warn: 1,
44
+ log: 2,
45
+ info: 3,
46
+ success: 3,
47
+ fail: 3,
48
+ ready: 3,
49
+ start: 3,
50
+ box: 3,
51
+ debug: 4,
52
+ trace: 5,
53
+ verbose: Number.POSITIVE_INFINITY
54
+ };
55
+ const LogTypes = {
56
+ silent: { level: -1 },
57
+ fatal: { level: LogLevels.fatal },
58
+ error: { level: LogLevels.error },
59
+ warn: { level: LogLevels.warn },
60
+ log: { level: LogLevels.log },
61
+ info: { level: LogLevels.info },
62
+ success: { level: LogLevels.success },
63
+ fail: { level: LogLevels.fail },
64
+ ready: { level: LogLevels.info },
65
+ start: { level: LogLevels.info },
66
+ box: { level: LogLevels.info },
67
+ debug: { level: LogLevels.debug },
68
+ trace: { level: LogLevels.trace },
69
+ verbose: { level: LogLevels.verbose }
70
+ };
71
+ function isPlainObject$1(value) {
72
+ if (value === null || typeof value !== "object") return false;
73
+ const prototype = Object.getPrototypeOf(value);
74
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
75
+ if (Symbol.iterator in value) return false;
76
+ if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
77
+ return true;
78
+ }
79
+ function _defu(baseObject, defaults, namespace = ".", merger) {
80
+ if (!isPlainObject$1(defaults)) return _defu(baseObject, {}, namespace, merger);
81
+ const object = Object.assign({}, defaults);
82
+ for (const key in baseObject) {
83
+ if (key === "__proto__" || key === "constructor") continue;
84
+ const value = baseObject[key];
85
+ if (value === null || value === void 0) continue;
86
+ if (merger && merger(object, key, value, namespace)) continue;
87
+ if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
88
+ else if (isPlainObject$1(value) && isPlainObject$1(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
89
+ else object[key] = value;
90
+ }
91
+ return object;
92
+ }
93
+ function createDefu(merger) {
94
+ return (...arguments_) => arguments_.reduce((p, c$1) => _defu(p, c$1, "", merger), {});
95
+ }
96
+ const defu = createDefu();
97
+ function isPlainObject(obj) {
98
+ return Object.prototype.toString.call(obj) === "[object Object]";
99
+ }
100
+ function isLogObj(arg) {
101
+ if (!isPlainObject(arg)) return false;
102
+ if (!arg.message && !arg.args) return false;
103
+ if (arg.stack) return false;
104
+ return true;
105
+ }
106
+ let paused = false;
107
+ const queue = [];
108
+ var Consola = class Consola {
109
+ options;
110
+ _lastLog;
111
+ _mockFn;
112
+ /**
113
+ * Creates an instance of Consola with specified options or defaults.
114
+ *
115
+ * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
116
+ */
117
+ constructor(options$1 = {}) {
118
+ const types = options$1.types || LogTypes;
119
+ this.options = defu({
120
+ ...options$1,
121
+ defaults: { ...options$1.defaults },
122
+ level: _normalizeLogLevel(options$1.level, types),
123
+ reporters: [...options$1.reporters || []]
124
+ }, {
125
+ types: LogTypes,
126
+ throttle: 1e3,
127
+ throttleMin: 5,
128
+ formatOptions: {
129
+ date: true,
130
+ colors: false,
131
+ compact: true
132
+ }
133
+ });
134
+ for (const type in types) {
135
+ const defaults = {
136
+ type,
137
+ ...this.options.defaults,
138
+ ...types[type]
139
+ };
140
+ this[type] = this._wrapLogFn(defaults);
141
+ this[type].raw = this._wrapLogFn(defaults, true);
142
+ }
143
+ if (this.options.mockFn) this.mockTypes();
144
+ this._lastLog = {};
145
+ }
146
+ /**
147
+ * Gets the current log level of the Consola instance.
148
+ *
149
+ * @returns {number} The current log level.
150
+ */
151
+ get level() {
152
+ return this.options.level;
153
+ }
154
+ /**
155
+ * Sets the minimum log level that will be output by the instance.
156
+ *
157
+ * @param {number} level - The new log level to set.
158
+ */
159
+ set level(level) {
160
+ this.options.level = _normalizeLogLevel(level, this.options.types, this.options.level);
161
+ }
162
+ /**
163
+ * Displays a prompt to the user and returns the response.
164
+ * Throw an error if `prompt` is not supported by the current configuration.
165
+ *
166
+ * @template T
167
+ * @param {string} message - The message to display in the prompt.
168
+ * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
169
+ * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
170
+ */
171
+ prompt(message, opts) {
172
+ if (!this.options.prompt) throw new Error("prompt is not supported!");
173
+ return this.options.prompt(message, opts);
174
+ }
175
+ /**
176
+ * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
177
+ *
178
+ * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
179
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
180
+ */
181
+ create(options$1) {
182
+ const instance = new Consola({
183
+ ...this.options,
184
+ ...options$1
185
+ });
186
+ if (this._mockFn) instance.mockTypes(this._mockFn);
187
+ return instance;
188
+ }
189
+ /**
190
+ * Creates a new Consola instance with the specified default log object properties.
191
+ *
192
+ * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
193
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
194
+ */
195
+ withDefaults(defaults) {
196
+ return this.create({
197
+ ...this.options,
198
+ defaults: {
199
+ ...this.options.defaults,
200
+ ...defaults
201
+ }
202
+ });
203
+ }
204
+ /**
205
+ * Creates a new Consola instance with a specified tag, which will be included in every log.
206
+ *
207
+ * @param {string} tag - The tag to include in each log of the new instance.
208
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
209
+ */
210
+ withTag(tag) {
211
+ return this.withDefaults({ tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag });
212
+ }
213
+ /**
214
+ * Adds a custom reporter to the Consola instance.
215
+ * Reporters will be called for each log message, depending on their implementation and log level.
216
+ *
217
+ * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
218
+ * @returns {Consola} The current Consola instance.
219
+ */
220
+ addReporter(reporter) {
221
+ this.options.reporters.push(reporter);
222
+ return this;
223
+ }
224
+ /**
225
+ * Removes a custom reporter from the Consola instance.
226
+ * If no reporter is specified, all reporters will be removed.
227
+ *
228
+ * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
229
+ * @returns {Consola} The current Consola instance.
230
+ */
231
+ removeReporter(reporter) {
232
+ if (reporter) {
233
+ const i$1 = this.options.reporters.indexOf(reporter);
234
+ if (i$1 !== -1) return this.options.reporters.splice(i$1, 1);
235
+ } else this.options.reporters.splice(0);
236
+ return this;
237
+ }
238
+ /**
239
+ * Replaces all reporters of the Consola instance with the specified array of reporters.
240
+ *
241
+ * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
242
+ * @returns {Consola} The current Consola instance.
243
+ */
244
+ setReporters(reporters) {
245
+ this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
246
+ return this;
247
+ }
248
+ wrapAll() {
249
+ this.wrapConsole();
250
+ this.wrapStd();
251
+ }
252
+ restoreAll() {
253
+ this.restoreConsole();
254
+ this.restoreStd();
255
+ }
256
+ /**
257
+ * Overrides console methods with Consola logging methods for consistent logging.
258
+ */
259
+ wrapConsole() {
260
+ for (const type in this.options.types) {
261
+ if (!console["__" + type]) console["__" + type] = console[type];
262
+ console[type] = this[type].raw;
263
+ }
264
+ }
265
+ /**
266
+ * Restores the original console methods, removing Consola overrides.
267
+ */
268
+ restoreConsole() {
269
+ for (const type in this.options.types) if (console["__" + type]) {
270
+ console[type] = console["__" + type];
271
+ delete console["__" + type];
272
+ }
273
+ }
274
+ /**
275
+ * Overrides standard output and error streams to redirect them through Consola.
276
+ */
277
+ wrapStd() {
278
+ this._wrapStream(this.options.stdout, "log");
279
+ this._wrapStream(this.options.stderr, "log");
280
+ }
281
+ _wrapStream(stream, type) {
282
+ if (!stream) return;
283
+ if (!stream.__write) stream.__write = stream.write;
284
+ stream.write = (data) => {
285
+ this[type].raw(String(data).trim());
286
+ };
287
+ }
288
+ /**
289
+ * Restores the original standard output and error streams, removing the Consola redirection.
290
+ */
291
+ restoreStd() {
292
+ this._restoreStream(this.options.stdout);
293
+ this._restoreStream(this.options.stderr);
294
+ }
295
+ _restoreStream(stream) {
296
+ if (!stream) return;
297
+ if (stream.__write) {
298
+ stream.write = stream.__write;
299
+ delete stream.__write;
300
+ }
301
+ }
302
+ /**
303
+ * Pauses logging, queues incoming logs until resumed.
304
+ */
305
+ pauseLogs() {
306
+ paused = true;
307
+ }
308
+ /**
309
+ * Resumes logging, processing any queued logs.
310
+ */
311
+ resumeLogs() {
312
+ paused = false;
313
+ const _queue = queue.splice(0);
314
+ for (const item of _queue) item[0]._logFn(item[1], item[2]);
315
+ }
316
+ /**
317
+ * Replaces logging methods with mocks if a mock function is provided.
318
+ *
319
+ * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
320
+ */
321
+ mockTypes(mockFn) {
322
+ const _mockFn = mockFn || this.options.mockFn;
323
+ this._mockFn = _mockFn;
324
+ if (typeof _mockFn !== "function") return;
325
+ for (const type in this.options.types) {
326
+ this[type] = _mockFn(type, this.options.types[type]) || this[type];
327
+ this[type].raw = this[type];
328
+ }
329
+ }
330
+ _wrapLogFn(defaults, isRaw) {
331
+ return (...args) => {
332
+ if (paused) {
333
+ queue.push([
334
+ this,
335
+ defaults,
336
+ args,
337
+ isRaw
338
+ ]);
339
+ return;
340
+ }
341
+ return this._logFn(defaults, args, isRaw);
342
+ };
343
+ }
344
+ _logFn(defaults, args, isRaw) {
345
+ if ((defaults.level || 0) > this.level) return false;
346
+ const logObj = {
347
+ date: /* @__PURE__ */ new Date(),
348
+ args: [],
349
+ ...defaults,
350
+ level: _normalizeLogLevel(defaults.level, this.options.types)
351
+ };
352
+ if (!isRaw && args.length === 1 && isLogObj(args[0])) Object.assign(logObj, args[0]);
353
+ else logObj.args = [...args];
354
+ if (logObj.message) {
355
+ logObj.args.unshift(logObj.message);
356
+ delete logObj.message;
357
+ }
358
+ if (logObj.additional) {
359
+ if (!Array.isArray(logObj.additional)) logObj.additional = logObj.additional.split("\n");
360
+ logObj.args.push("\n" + logObj.additional.join("\n"));
361
+ delete logObj.additional;
362
+ }
363
+ logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
364
+ logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
365
+ const resolveLog = (newLog = false) => {
366
+ const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
367
+ if (this._lastLog.object && repeated > 0) {
368
+ const args2 = [...this._lastLog.object.args];
369
+ if (repeated > 1) args2.push(`(repeated ${repeated} times)`);
370
+ this._log({
371
+ ...this._lastLog.object,
372
+ args: args2
373
+ });
374
+ this._lastLog.count = 1;
375
+ }
376
+ if (newLog) {
377
+ this._lastLog.object = logObj;
378
+ this._log(logObj);
379
+ }
380
+ };
381
+ clearTimeout(this._lastLog.timeout);
382
+ const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
383
+ this._lastLog.time = logObj.date;
384
+ if (diffTime < this.options.throttle) try {
385
+ const serializedLog = JSON.stringify([
386
+ logObj.type,
387
+ logObj.tag,
388
+ logObj.args
389
+ ]);
390
+ const isSameLog = this._lastLog.serialized === serializedLog;
391
+ this._lastLog.serialized = serializedLog;
392
+ if (isSameLog) {
393
+ this._lastLog.count = (this._lastLog.count || 0) + 1;
394
+ if (this._lastLog.count > this.options.throttleMin) {
395
+ this._lastLog.timeout = setTimeout(resolveLog, this.options.throttle);
396
+ return;
397
+ }
398
+ }
399
+ } catch {}
400
+ resolveLog(true);
401
+ }
402
+ _log(logObj) {
403
+ for (const reporter of this.options.reporters) reporter.log(logObj, { options: this.options });
404
+ }
405
+ };
406
+ function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
407
+ if (input === void 0) return defaultLevel;
408
+ if (typeof input === "number") return input;
409
+ if (types[input] && types[input].level !== void 0) return types[input].level;
410
+ return defaultLevel;
411
+ }
412
+ Consola.prototype.add = Consola.prototype.addReporter;
413
+ Consola.prototype.remove = Consola.prototype.removeReporter;
414
+ Consola.prototype.clear = Consola.prototype.removeReporter;
415
+ Consola.prototype.withScope = Consola.prototype.withTag;
416
+ Consola.prototype.mock = Consola.prototype.mockTypes;
417
+ Consola.prototype.pause = Consola.prototype.pauseLogs;
418
+ Consola.prototype.resume = Consola.prototype.resumeLogs;
419
+ function createConsola$1(options$1 = {}) {
420
+ return new Consola(options$1);
421
+ }
422
+
423
+ //#endregion
424
+ //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
425
+ function parseStack(stack, message) {
426
+ const cwd$1 = process.cwd() + sep;
427
+ const lines = stack.split("\n").splice(message.split("\n").length).map((l$1) => l$1.trim().replace("file://", "").replace(cwd$1, ""));
428
+ return lines;
429
+ }
430
+ function writeStream(data, stream) {
431
+ const write = stream.__write || stream.write;
432
+ return write.call(stream, data);
433
+ }
434
+ const bracket = (x) => x ? `[${x}]` : "";
435
+ var BasicReporter = class {
436
+ formatStack(stack, message, opts) {
437
+ const indent = " ".repeat((opts?.errorLevel || 0) + 1);
438
+ return indent + parseStack(stack, message).join(`
439
+ ${indent}`);
440
+ }
441
+ formatError(err, opts) {
442
+ const message = err.message ?? formatWithOptions(opts, err);
443
+ const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
444
+ const level = opts?.errorLevel || 0;
445
+ const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
446
+ const causedError = err.cause ? "\n\n" + this.formatError(err.cause, {
447
+ ...opts,
448
+ errorLevel: level + 1
449
+ }) : "";
450
+ return causedPrefix + message + "\n" + stack + causedError;
451
+ }
452
+ formatArgs(args, opts) {
453
+ const _args = args.map((arg) => {
454
+ if (arg && typeof arg.stack === "string") return this.formatError(arg, opts);
455
+ return arg;
456
+ });
457
+ return formatWithOptions(opts, ..._args);
458
+ }
459
+ formatDate(date, opts) {
460
+ return opts.date ? date.toLocaleTimeString() : "";
461
+ }
462
+ filterAndJoin(arr) {
463
+ return arr.filter(Boolean).join(" ");
464
+ }
465
+ formatLogObj(logObj, opts) {
466
+ const message = this.formatArgs(logObj.args, opts);
467
+ if (logObj.type === "box") return "\n" + [
468
+ bracket(logObj.tag),
469
+ logObj.title && logObj.title,
470
+ ...message.split("\n")
471
+ ].filter(Boolean).map((l$1) => " > " + l$1).join("\n") + "\n";
472
+ return this.filterAndJoin([
473
+ bracket(logObj.type),
474
+ bracket(logObj.tag),
475
+ message
476
+ ]);
477
+ }
478
+ log(logObj, ctx) {
479
+ const line = this.formatLogObj(logObj, {
480
+ columns: ctx.options.stdout.columns || 0,
481
+ ...ctx.options.formatOptions
482
+ });
483
+ return writeStream(line + "\n", logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
484
+ }
485
+ };
486
+
487
+ //#endregion
488
+ //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
489
+ const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
490
+ const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
491
+ const isForced = "FORCE_COLOR" in env || argv.includes("--color");
492
+ const isWindows = platform === "win32";
493
+ const isDumbTerminal = env.TERM === "dumb";
494
+ const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
495
+ const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
496
+ const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
497
+ function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
498
+ return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
499
+ }
500
+ function clearBleed(index, string, open, close, replace) {
501
+ return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
502
+ }
503
+ function filterEmpty(open, close, replace = open, at = open.length + 1) {
504
+ return (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
505
+ }
506
+ function init(open, close, replace) {
507
+ return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
508
+ }
509
+ const colorDefs = {
510
+ reset: init(0, 0),
511
+ bold: init(1, 22, "\x1B[22m\x1B[1m"),
512
+ dim: init(2, 22, "\x1B[22m\x1B[2m"),
513
+ italic: init(3, 23),
514
+ underline: init(4, 24),
515
+ inverse: init(7, 27),
516
+ hidden: init(8, 28),
517
+ strikethrough: init(9, 29),
518
+ black: init(30, 39),
519
+ red: init(31, 39),
520
+ green: init(32, 39),
521
+ yellow: init(33, 39),
522
+ blue: init(34, 39),
523
+ magenta: init(35, 39),
524
+ cyan: init(36, 39),
525
+ white: init(37, 39),
526
+ gray: init(90, 39),
527
+ bgBlack: init(40, 49),
528
+ bgRed: init(41, 49),
529
+ bgGreen: init(42, 49),
530
+ bgYellow: init(43, 49),
531
+ bgBlue: init(44, 49),
532
+ bgMagenta: init(45, 49),
533
+ bgCyan: init(46, 49),
534
+ bgWhite: init(47, 49),
535
+ blackBright: init(90, 39),
536
+ redBright: init(91, 39),
537
+ greenBright: init(92, 39),
538
+ yellowBright: init(93, 39),
539
+ blueBright: init(94, 39),
540
+ magentaBright: init(95, 39),
541
+ cyanBright: init(96, 39),
542
+ whiteBright: init(97, 39),
543
+ bgBlackBright: init(100, 49),
544
+ bgRedBright: init(101, 49),
545
+ bgGreenBright: init(102, 49),
546
+ bgYellowBright: init(103, 49),
547
+ bgBlueBright: init(104, 49),
548
+ bgMagentaBright: init(105, 49),
549
+ bgCyanBright: init(106, 49),
550
+ bgWhiteBright: init(107, 49)
551
+ };
552
+ function createColors(useColor = isColorSupported) {
553
+ return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
554
+ }
555
+ const colors$1 = createColors();
556
+ function getColor$1(color, fallback = "reset") {
557
+ return colors$1[color] || colors$1[fallback];
558
+ }
559
+ const ansiRegex$1 = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
560
+ function stripAnsi(text) {
561
+ return text.replace(new RegExp(ansiRegex$1, "g"), "");
562
+ }
563
+ const boxStylePresets = {
564
+ solid: {
565
+ tl: "┌",
566
+ tr: "┐",
567
+ bl: "└",
568
+ br: "┘",
569
+ h: "─",
570
+ v: "│"
571
+ },
572
+ double: {
573
+ tl: "╔",
574
+ tr: "╗",
575
+ bl: "╚",
576
+ br: "╝",
577
+ h: "═",
578
+ v: "║"
579
+ },
580
+ doubleSingle: {
581
+ tl: "╓",
582
+ tr: "╖",
583
+ bl: "╙",
584
+ br: "╜",
585
+ h: "─",
586
+ v: "║"
587
+ },
588
+ doubleSingleRounded: {
589
+ tl: "╭",
590
+ tr: "╮",
591
+ bl: "╰",
592
+ br: "╯",
593
+ h: "─",
594
+ v: "║"
595
+ },
596
+ singleThick: {
597
+ tl: "┏",
598
+ tr: "┓",
599
+ bl: "┗",
600
+ br: "┛",
601
+ h: "━",
602
+ v: "┃"
603
+ },
604
+ singleDouble: {
605
+ tl: "╒",
606
+ tr: "╕",
607
+ bl: "╘",
608
+ br: "╛",
609
+ h: "═",
610
+ v: "│"
611
+ },
612
+ singleDoubleRounded: {
613
+ tl: "╭",
614
+ tr: "╮",
615
+ bl: "╰",
616
+ br: "╯",
617
+ h: "═",
618
+ v: "│"
619
+ },
620
+ rounded: {
621
+ tl: "╭",
622
+ tr: "╮",
623
+ bl: "╰",
624
+ br: "╯",
625
+ h: "─",
626
+ v: "│"
627
+ }
628
+ };
629
+ const defaultStyle = {
630
+ borderColor: "white",
631
+ borderStyle: "rounded",
632
+ valign: "center",
633
+ padding: 2,
634
+ marginLeft: 1,
635
+ marginTop: 1,
636
+ marginBottom: 1
637
+ };
638
+ function box(text, _opts = {}) {
639
+ const opts = {
640
+ ..._opts,
641
+ style: {
642
+ ...defaultStyle,
643
+ ..._opts.style
644
+ }
645
+ };
646
+ const textLines = text.split("\n");
647
+ const boxLines = [];
648
+ const _color = getColor$1(opts.style.borderColor);
649
+ const borderStyle = { ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle };
650
+ if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
651
+ const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
652
+ const height = textLines.length + paddingOffset;
653
+ const width = Math.max(...textLines.map((line) => stripAnsi(line).length), opts.title ? stripAnsi(opts.title).length : 0) + paddingOffset;
654
+ const widthOffset = width + paddingOffset;
655
+ const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
656
+ if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
657
+ if (opts.title) {
658
+ const title = _color ? _color(opts.title) : opts.title;
659
+ const left = borderStyle.h.repeat(Math.floor((width - stripAnsi(opts.title).length) / 2));
660
+ const right = borderStyle.h.repeat(width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset);
661
+ boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
662
+ } else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
663
+ const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
664
+ for (let i$1 = 0; i$1 < height; i$1++) if (i$1 < valignOffset || i$1 >= valignOffset + textLines.length) boxLines.push(`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`);
665
+ else {
666
+ const line = textLines[i$1 - valignOffset];
667
+ const left = " ".repeat(paddingOffset);
668
+ const right = " ".repeat(width - stripAnsi(line).length);
669
+ boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
670
+ }
671
+ boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
672
+ if (opts.style.marginBottom > 0) boxLines.push("".repeat(opts.style.marginBottom));
673
+ return boxLines.join("\n");
674
+ }
675
+
676
+ //#endregion
677
+ //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs
678
+ const r = Object.create(null), i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis), o = new Proxy(r, {
679
+ get(e, s$1) {
680
+ return i()[s$1] ?? r[s$1];
681
+ },
682
+ has(e, s$1) {
683
+ const E = i();
684
+ return s$1 in E || s$1 in r;
685
+ },
686
+ set(e, s$1, E) {
687
+ const B = i(true);
688
+ return B[s$1] = E, true;
689
+ },
690
+ deleteProperty(e, s$1) {
691
+ if (!s$1) return false;
692
+ const E = i(true);
693
+ return delete E[s$1], true;
694
+ },
695
+ ownKeys() {
696
+ const e = i(true);
697
+ return Object.keys(e);
698
+ }
699
+ }), t = typeof process < "u" && process.env && process.env.NODE_ENV || "", f = [
700
+ ["APPVEYOR"],
701
+ [
702
+ "AWS_AMPLIFY",
703
+ "AWS_APP_ID",
704
+ { ci: true }
705
+ ],
706
+ ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
707
+ ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
708
+ ["APPCIRCLE", "AC_APPCIRCLE"],
709
+ ["BAMBOO", "bamboo_planKey"],
710
+ ["BITBUCKET", "BITBUCKET_COMMIT"],
711
+ ["BITRISE", "BITRISE_IO"],
712
+ ["BUDDY", "BUDDY_WORKSPACE_ID"],
713
+ ["BUILDKITE"],
714
+ ["CIRCLE", "CIRCLECI"],
715
+ ["CIRRUS", "CIRRUS_CI"],
716
+ [
717
+ "CLOUDFLARE_PAGES",
718
+ "CF_PAGES",
719
+ { ci: true }
720
+ ],
721
+ ["CODEBUILD", "CODEBUILD_BUILD_ARN"],
722
+ ["CODEFRESH", "CF_BUILD_ID"],
723
+ ["DRONE"],
724
+ ["DRONE", "DRONE_BUILD_EVENT"],
725
+ ["DSARI"],
726
+ ["GITHUB_ACTIONS"],
727
+ ["GITLAB", "GITLAB_CI"],
728
+ ["GITLAB", "CI_MERGE_REQUEST_ID"],
729
+ ["GOCD", "GO_PIPELINE_LABEL"],
730
+ ["LAYERCI"],
731
+ ["HUDSON", "HUDSON_URL"],
732
+ ["JENKINS", "JENKINS_URL"],
733
+ ["MAGNUM"],
734
+ ["NETLIFY"],
735
+ [
736
+ "NETLIFY",
737
+ "NETLIFY_LOCAL",
738
+ { ci: false }
739
+ ],
740
+ ["NEVERCODE"],
741
+ ["RENDER"],
742
+ ["SAIL", "SAILCI"],
743
+ ["SEMAPHORE"],
744
+ ["SCREWDRIVER"],
745
+ ["SHIPPABLE"],
746
+ ["SOLANO", "TDDIUM"],
747
+ ["STRIDER"],
748
+ ["TEAMCITY", "TEAMCITY_VERSION"],
749
+ ["TRAVIS"],
750
+ ["VERCEL", "NOW_BUILDER"],
751
+ [
752
+ "VERCEL",
753
+ "VERCEL",
754
+ { ci: false }
755
+ ],
756
+ [
757
+ "VERCEL",
758
+ "VERCEL_ENV",
759
+ { ci: false }
760
+ ],
761
+ ["APPCENTER", "APPCENTER_BUILD_ID"],
762
+ [
763
+ "CODESANDBOX",
764
+ "CODESANDBOX_SSE",
765
+ { ci: false }
766
+ ],
767
+ [
768
+ "CODESANDBOX",
769
+ "CODESANDBOX_HOST",
770
+ { ci: false }
771
+ ],
772
+ ["STACKBLITZ"],
773
+ ["STORMKIT"],
774
+ ["CLEAVR"],
775
+ ["ZEABUR"],
776
+ [
777
+ "CODESPHERE",
778
+ "CODESPHERE_APP_ID",
779
+ { ci: true }
780
+ ],
781
+ ["RAILWAY", "RAILWAY_PROJECT_ID"],
782
+ ["RAILWAY", "RAILWAY_SERVICE_ID"],
783
+ ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"],
784
+ [
785
+ "FIREBASE_APP_HOSTING",
786
+ "FIREBASE_APP_HOSTING",
787
+ { ci: true }
788
+ ]
789
+ ];
790
+ function b() {
791
+ if (globalThis.process?.env) for (const e of f) {
792
+ const s$1 = e[1] || e[0];
793
+ if (globalThis.process?.env[s$1]) return {
794
+ name: e[0].toLowerCase(),
795
+ ...e[2]
796
+ };
797
+ }
798
+ return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? {
799
+ name: "stackblitz",
800
+ ci: false
801
+ } : {
802
+ name: "",
803
+ ci: false
804
+ };
805
+ }
806
+ const l = b();
807
+ l.name;
808
+ function n(e) {
809
+ return e ? e !== "false" : false;
810
+ }
811
+ const I = globalThis.process?.platform || "", T = n(o.CI) || l.ci !== false, a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), g = n(o.DEBUG), R = t === "test" || n(o.TEST);
812
+ n(o.MINIMAL);
813
+ const A = /^win/i.test(I);
814
+ !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM);
815
+ const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
816
+ Number(C?.split(".")[0]);
817
+ const y = globalThis.process || Object.create(null), _ = { versions: {} };
818
+ new Proxy(y, { get(e, s$1) {
819
+ if (s$1 === "env") return o;
820
+ if (s$1 in e) return e[s$1];
821
+ if (s$1 in _) return _[s$1];
822
+ } });
823
+ const c = globalThis.process?.release?.name === "node", O = !!globalThis.Bun || !!globalThis.process?.versions?.bun, D = !!globalThis.Deno, L = !!globalThis.fastly, S = !!globalThis.Netlify, u = !!globalThis.EdgeRuntime, N = globalThis.navigator?.userAgent === "Cloudflare-Workers", F = [
824
+ [S, "netlify"],
825
+ [u, "edge-light"],
826
+ [N, "workerd"],
827
+ [L, "fastly"],
828
+ [D, "deno"],
829
+ [O, "bun"],
830
+ [c, "node"]
831
+ ];
832
+ function G() {
833
+ const e = F.find((s$1) => s$1[0]);
834
+ if (e) return { name: e[1] };
835
+ }
836
+ const P = G();
837
+ P?.name;
838
+ function ansiRegex({ onlyFirst = false } = {}) {
839
+ const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
840
+ const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
841
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
842
+ }
843
+ const regex = ansiRegex();
844
+ function stripAnsi$1(string) {
845
+ if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
846
+ return string.replace(regex, "");
847
+ }
848
+ function isAmbiguous(x) {
849
+ return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
850
+ }
851
+ function isFullWidth(x) {
852
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
853
+ }
854
+ function isWide(x) {
855
+ return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
856
+ }
857
+ function validate(codePoint) {
858
+ if (!Number.isSafeInteger(codePoint)) throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
859
+ }
860
+ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
861
+ validate(codePoint);
862
+ if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
863
+ return 1;
864
+ }
865
+ const emojiRegex = () => {
866
+ return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
867
+ };
868
+ const segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
869
+ const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
870
+ function stringWidth$1(string, options$1 = {}) {
871
+ if (typeof string !== "string" || string.length === 0) return 0;
872
+ const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options$1;
873
+ if (!countAnsiEscapeCodes) string = stripAnsi$1(string);
874
+ if (string.length === 0) return 0;
875
+ let width = 0;
876
+ const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
877
+ for (const { segment: character } of segmenter.segment(string)) {
878
+ const codePoint = character.codePointAt(0);
879
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) continue;
880
+ if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) continue;
881
+ if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) continue;
882
+ if (codePoint >= 55296 && codePoint <= 57343) continue;
883
+ if (codePoint >= 65024 && codePoint <= 65039) continue;
884
+ if (defaultIgnorableCodePointRegex.test(character)) continue;
885
+ if (emojiRegex().test(character)) {
886
+ width += 2;
887
+ continue;
888
+ }
889
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
890
+ }
891
+ return width;
892
+ }
893
+ function isUnicodeSupported() {
894
+ const { env: env$1 } = process$1;
895
+ const { TERM, TERM_PROGRAM } = env$1;
896
+ if (process$1.platform !== "win32") return TERM !== "linux";
897
+ return Boolean(env$1.WT_SESSION) || Boolean(env$1.TERMINUS_SUBLIME) || env$1.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env$1.TERMINAL_EMULATOR === "JetBrains-JediTerm";
898
+ }
899
+ const TYPE_COLOR_MAP = {
900
+ info: "cyan",
901
+ fail: "red",
902
+ success: "green",
903
+ ready: "green",
904
+ start: "magenta"
905
+ };
906
+ const LEVEL_COLOR_MAP = {
907
+ 0: "red",
908
+ 1: "yellow"
909
+ };
910
+ const unicode = isUnicodeSupported();
911
+ const s = (c$1, fallback) => unicode ? c$1 : fallback;
912
+ const TYPE_ICONS = {
913
+ error: s("✖", "×"),
914
+ fatal: s("✖", "×"),
915
+ ready: s("✔", "√"),
916
+ warn: s("⚠", "‼"),
917
+ info: s("ℹ", "i"),
918
+ success: s("✔", "√"),
919
+ debug: s("⚙", "D"),
920
+ trace: s("→", "→"),
921
+ fail: s("✖", "×"),
922
+ start: s("◐", "o"),
923
+ log: ""
924
+ };
925
+ function stringWidth(str) {
926
+ const hasICU = typeof Intl === "object";
927
+ if (!hasICU || !Intl.Segmenter) return stripAnsi(str).length;
928
+ return stringWidth$1(str);
929
+ }
930
+ var FancyReporter = class extends BasicReporter {
931
+ formatStack(stack, message, opts) {
932
+ const indent = " ".repeat((opts?.errorLevel || 0) + 1);
933
+ return `
934
+ ${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m) => colors$1.gray(m)).replace(/\((.+)\)/, (_$1, m) => `(${colors$1.cyan(m)})`)).join(`
935
+ ${indent}`);
936
+ }
937
+ formatType(logObj, isBadge, opts) {
938
+ const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
939
+ if (isBadge) return getBgColor(typeColor)(colors$1.black(` ${logObj.type.toUpperCase()} `));
940
+ const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
941
+ return _type ? getColor(typeColor)(_type) : "";
942
+ }
943
+ formatLogObj(logObj, opts) {
944
+ const [message, ...additional] = this.formatArgs(logObj.args, opts).split("\n");
945
+ if (logObj.type === "box") return box(characterFormat(message + (additional.length > 0 ? "\n" + additional.join("\n") : "")), {
946
+ title: logObj.title ? characterFormat(logObj.title) : void 0,
947
+ style: logObj.style
948
+ });
949
+ const date = this.formatDate(logObj.date, opts);
950
+ const coloredDate = date && colors$1.gray(date);
951
+ const isBadge = logObj.badge ?? logObj.level < 2;
952
+ const type = this.formatType(logObj, isBadge, opts);
953
+ const tag = logObj.tag ? colors$1.gray(logObj.tag) : "";
954
+ let line;
955
+ const left = this.filterAndJoin([type, characterFormat(message)]);
956
+ const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
957
+ const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
958
+ line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors$1.gray(`[${right}]`)} ` : "") + left;
959
+ line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : "");
960
+ if (logObj.type === "trace") {
961
+ const _err = new Error("Trace: " + logObj.message);
962
+ line += this.formatStack(_err.stack || "", _err.message);
963
+ }
964
+ return isBadge ? "\n" + line + "\n" : line;
965
+ }
966
+ };
967
+ function characterFormat(str) {
968
+ return str.replace(/`([^`]+)`/gm, (_$1, m) => colors$1.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_$1, m) => ` ${colors$1.underline(m)} `);
969
+ }
970
+ function getColor(color = "white") {
971
+ return colors$1[color] || colors$1.white;
972
+ }
973
+ function getBgColor(color = "bgWhite") {
974
+ return colors$1[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors$1.bgWhite;
975
+ }
976
+ function createConsola(options$1 = {}) {
977
+ let level = _getDefaultLogLevel();
978
+ if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
979
+ const consola2 = createConsola$1({
980
+ level,
981
+ defaults: { level },
982
+ stdout: process.stdout,
983
+ stderr: process.stderr,
984
+ prompt: (...args) => import("./shared/prompt-C3zHEaSG.mjs").then((m) => m.prompt(...args)),
985
+ reporters: options$1.reporters || [options$1.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
986
+ ...options$1
987
+ });
988
+ return consola2;
989
+ }
990
+ function _getDefaultLogLevel() {
991
+ if (g) return LogLevels.debug;
992
+ if (R) return LogLevels.warn;
993
+ return LogLevels.info;
994
+ }
995
+ const consola = createConsola();
996
+
997
+ //#endregion
998
+ //#region src/cli/logger.ts
999
+ /**
1000
+ * Console logger
1001
+ */
1002
+ const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : createConsola({ formatOptions: { date: false } });
1003
+ function createTestingLogger() {
1004
+ const types = [
1005
+ "silent",
1006
+ "fatal",
1007
+ "error",
1008
+ "warn",
1009
+ "log",
1010
+ "info",
1011
+ "success",
1012
+ "fail",
1013
+ "ready",
1014
+ "start",
1015
+ "box",
1016
+ "debug",
1017
+ "trace",
1018
+ "verbose"
1019
+ ];
1020
+ const ret = Object.create(null);
1021
+ for (const type of types) ret[type] = console.log;
1022
+ return ret;
1023
+ }
1024
+
1025
+ //#endregion
1026
+ //#region src/cli/arguments/alias.ts
1027
+ const alias = {
1028
+ config: {
1029
+ abbreviation: "c",
1030
+ hint: "filename"
1031
+ },
1032
+ help: { abbreviation: "h" },
1033
+ version: { abbreviation: "v" },
1034
+ watch: { abbreviation: "w" },
1035
+ dir: { abbreviation: "d" },
1036
+ file: { abbreviation: "o" },
1037
+ external: { abbreviation: "e" },
1038
+ format: { abbreviation: "f" },
1039
+ name: { abbreviation: "n" },
1040
+ globals: { abbreviation: "g" },
1041
+ sourcemap: {
1042
+ abbreviation: "s",
1043
+ default: true
1044
+ },
1045
+ minify: { abbreviation: "m" },
1046
+ platform: { abbreviation: "p" },
1047
+ assetFileNames: { hint: "name" },
1048
+ chunkFileNames: { hint: "name" },
1049
+ entryFileNames: { hint: "name" },
1050
+ externalLiveBindings: {
1051
+ default: true,
1052
+ reverse: true
1053
+ },
1054
+ treeshake: {
1055
+ default: true,
1056
+ reverse: true
1057
+ },
1058
+ moduleTypes: { hint: "types" }
1059
+ };
1060
+
1061
+ //#endregion
1062
+ //#region src/cli/arguments/utils.ts
1063
+ const priority = [
1064
+ "object",
1065
+ "array",
1066
+ "string",
1067
+ "number",
1068
+ "boolean"
1069
+ ];
1070
+ function getSchemaType(schema) {
1071
+ if ("anyOf" in schema) {
1072
+ const types = schema.anyOf.map(getSchemaType);
1073
+ let result = priority.find((type) => types.includes(type));
1074
+ if (result) return result;
1075
+ }
1076
+ if ("type" in schema) return schema.type;
1077
+ if ("const" in schema) return typeof schema.const;
1078
+ return "never";
1079
+ }
1080
+ function flattenSchema(schema, base = {}, parent = "") {
1081
+ if (schema === void 0) return base;
1082
+ for (const [k, value] of Object.entries(schema)) {
1083
+ const key = parent ? `${parent}.${k}` : k;
1084
+ if (getSchemaType(value) === "object") if ("properties" in value) flattenSchema(value.properties, base, key);
1085
+ else base[key] = value;
1086
+ else base[key] = value;
1087
+ }
1088
+ return base;
1089
+ }
1090
+ function setNestedProperty(obj, path$1, value) {
1091
+ const keys = path$1.split(".");
1092
+ let current = obj;
1093
+ for (let i$1 = 0; i$1 < keys.length - 1; i$1++) {
1094
+ if (!current[keys[i$1]]) current[keys[i$1]] = {};
1095
+ current = current[keys[i$1]];
1096
+ }
1097
+ const finalKey = keys[keys.length - 1];
1098
+ Object.defineProperty(current, finalKey, {
1099
+ value,
1100
+ writable: true,
1101
+ enumerable: true,
1102
+ configurable: true
1103
+ });
1104
+ }
1105
+ function camelCaseToKebabCase(str) {
1106
+ return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
1107
+ }
1108
+ function kebabCaseToCamelCase(str) {
1109
+ return str.replace(/-./g, (match) => match[1].toUpperCase());
1110
+ }
1111
+
1112
+ //#endregion
1113
+ //#region src/cli/arguments/normalize.ts
1114
+ function normalizeCliOptions(cliOptions, positionals) {
1115
+ const [data, errors] = validateCliOptions(cliOptions);
1116
+ if (errors?.length) {
1117
+ errors.forEach((error) => {
1118
+ logger.error(`${error}. You can use \`rolldown -h\` to see the help.`);
1119
+ });
1120
+ process.exit(1);
1121
+ }
1122
+ const options$1 = data ?? {};
1123
+ const result = {
1124
+ input: {},
1125
+ output: {},
1126
+ help: options$1.help ?? false,
1127
+ version: options$1.version ?? false,
1128
+ watch: options$1.watch ?? false
1129
+ };
1130
+ if (typeof options$1.config === "string") result.config = options$1.config;
1131
+ const keysOfInput = getInputCliKeys();
1132
+ const keysOfOutput = getOutputCliKeys();
1133
+ const reservedKeys = [
1134
+ "help",
1135
+ "version",
1136
+ "config",
1137
+ "watch"
1138
+ ];
1139
+ for (let [key, value] of Object.entries(options$1)) {
1140
+ const keys = key.split(".");
1141
+ const [primary] = keys;
1142
+ if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
1143
+ else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
1144
+ else if (!reservedKeys.includes(key)) {
1145
+ logger.error(`Unknown option: ${key}`);
1146
+ process.exit(1);
1147
+ }
1148
+ }
1149
+ if (!result.config && positionals.length > 0) if (Array.isArray(result.input.input)) result.input.input.push(...positionals);
1150
+ else result.input.input = positionals;
1151
+ return result;
1152
+ }
1153
+
1154
+ //#endregion
1155
+ //#region src/cli/arguments/index.ts
1156
+ const objectSchema = getJsonSchema();
1157
+ const flattenedSchema = flattenSchema(objectSchema.properties);
1158
+ const options = Object.fromEntries(Object.entries(flattenedSchema).filter(([_key, schema]) => getSchemaType(schema) !== "never").map(([key, schema]) => {
1159
+ const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
1160
+ const type = getSchemaType(schema);
1161
+ const result = {
1162
+ type: type === "boolean" ? "boolean" : "string",
1163
+ description: schema?.description ?? config?.description ?? "",
1164
+ hint: config?.hint
1165
+ };
1166
+ if (config && config?.abbreviation) result.short = config?.abbreviation;
1167
+ if (config && config.reverse) if (result.description.startsWith("enable")) result.description = result.description.replace("enable", "disable");
1168
+ else result.description = `disable ${result.description}`;
1169
+ key = camelCaseToKebabCase(key);
1170
+ return [config?.reverse ? `no-${key}` : key, result];
1171
+ }));
1172
+ function parseCliArguments() {
1173
+ const { values, tokens, positionals } = parseArgs({
1174
+ options,
1175
+ tokens: true,
1176
+ allowPositionals: true,
1177
+ strict: false
1178
+ });
1179
+ tokens.filter((token) => token.kind === "option").forEach((option) => {
1180
+ let negative = false;
1181
+ if (option.name.startsWith("no-")) {
1182
+ const name = kebabCaseToCamelCase(option.name.substring(3));
1183
+ if (name in flattenedSchema) {
1184
+ delete values[option.name];
1185
+ option.name = name;
1186
+ negative = true;
1187
+ }
1188
+ }
1189
+ delete values[option.name];
1190
+ option.name = kebabCaseToCamelCase(option.name);
1191
+ let originalType = flattenedSchema[option.name];
1192
+ if (!originalType) {
1193
+ logger.error(`Invalid option: ${option.rawName}. We will ignore this option.`);
1194
+ process.exit(1);
1195
+ }
1196
+ let type = getSchemaType(originalType);
1197
+ if (type === "string" && typeof option.value !== "string") {
1198
+ let opt = option;
1199
+ let defaultValue = Object.getOwnPropertyDescriptor(alias, opt.name)?.value;
1200
+ Object.defineProperty(values, opt.name, {
1201
+ value: defaultValue.default ?? "",
1202
+ enumerable: true,
1203
+ configurable: true,
1204
+ writable: true
1205
+ });
1206
+ } else if (type === "object" && typeof option.value === "string") {
1207
+ const [key, value] = option.value.split(",").map((x) => x.split("="))[0];
1208
+ if (!values[option.name]) Object.defineProperty(values, option.name, {
1209
+ value: {},
1210
+ enumerable: true,
1211
+ configurable: true,
1212
+ writable: true
1213
+ });
1214
+ if (key && value) Object.defineProperty(values[option.name], key, {
1215
+ value,
1216
+ enumerable: true,
1217
+ configurable: true,
1218
+ writable: true
1219
+ });
1220
+ } else if (type === "array" && typeof option.value === "string") {
1221
+ if (!values[option.name]) Object.defineProperty(values, option.name, {
1222
+ value: [],
1223
+ enumerable: true,
1224
+ configurable: true,
1225
+ writable: true
1226
+ });
1227
+ values[option.name].push(option.value);
1228
+ } else if (type === "boolean") Object.defineProperty(values, option.name, {
1229
+ value: !negative,
1230
+ enumerable: true,
1231
+ configurable: true,
1232
+ writable: true
1233
+ });
1234
+ else Object.defineProperty(values, option.name, {
1235
+ value: option.value ?? "",
1236
+ enumerable: true,
1237
+ configurable: true,
1238
+ writable: true
1239
+ });
1240
+ });
1241
+ return normalizeCliOptions(values, positionals);
1242
+ }
1243
+
1244
+ //#endregion
1245
+ //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
1246
+ /**
1247
+ * This is not the set of all possible signals.
1248
+ *
1249
+ * It IS, however, the set of all signals that trigger
1250
+ * an exit on either Linux or BSD systems. Linux is a
1251
+ * superset of the signal names supported on BSD, and
1252
+ * the unknown signals just fail to register, so we can
1253
+ * catch that easily enough.
1254
+ *
1255
+ * Windows signals are a different set, since there are
1256
+ * signals that terminate Windows processes, but don't
1257
+ * terminate (or don't even exist) on Posix systems.
1258
+ *
1259
+ * Don't bother with SIGKILL. It's uncatchable, which
1260
+ * means that we can't fire any callbacks anyway.
1261
+ *
1262
+ * If a user does happen to register a handler on a non-
1263
+ * fatal signal like SIGWINCH or something, and then
1264
+ * exit, it'll end up firing `process.emit('exit')`, so
1265
+ * the handler will be fired anyway.
1266
+ *
1267
+ * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
1268
+ * artificially, inherently leave the process in a
1269
+ * state from which it is not safe to try and enter JS
1270
+ * listeners.
1271
+ */
1272
+ const signals = [];
1273
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
1274
+ if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
1275
+ if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
1276
+
1277
+ //#endregion
1278
+ //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
1279
+ const processOk = (process$3) => !!process$3 && typeof process$3 === "object" && typeof process$3.removeListener === "function" && typeof process$3.emit === "function" && typeof process$3.reallyExit === "function" && typeof process$3.listeners === "function" && typeof process$3.kill === "function" && typeof process$3.pid === "number" && typeof process$3.on === "function";
1280
+ const kExitEmitter = Symbol.for("signal-exit emitter");
1281
+ const global = globalThis;
1282
+ const ObjectDefineProperty = Object.defineProperty.bind(Object);
1283
+ var Emitter = class {
1284
+ emitted = {
1285
+ afterExit: false,
1286
+ exit: false
1287
+ };
1288
+ listeners = {
1289
+ afterExit: [],
1290
+ exit: []
1291
+ };
1292
+ count = 0;
1293
+ id = Math.random();
1294
+ constructor() {
1295
+ if (global[kExitEmitter]) return global[kExitEmitter];
1296
+ ObjectDefineProperty(global, kExitEmitter, {
1297
+ value: this,
1298
+ writable: false,
1299
+ enumerable: false,
1300
+ configurable: false
1301
+ });
1302
+ }
1303
+ on(ev, fn) {
1304
+ this.listeners[ev].push(fn);
1305
+ }
1306
+ removeListener(ev, fn) {
1307
+ const list = this.listeners[ev];
1308
+ const i$1 = list.indexOf(fn);
1309
+ /* c8 ignore start */
1310
+ if (i$1 === -1) return;
1311
+ /* c8 ignore stop */
1312
+ if (i$1 === 0 && list.length === 1) list.length = 0;
1313
+ else list.splice(i$1, 1);
1314
+ }
1315
+ emit(ev, code, signal) {
1316
+ if (this.emitted[ev]) return false;
1317
+ this.emitted[ev] = true;
1318
+ let ret = false;
1319
+ for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
1320
+ if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
1321
+ return ret;
1322
+ }
1323
+ };
1324
+ var SignalExitBase = class {};
1325
+ const signalExitWrap = (handler) => {
1326
+ return {
1327
+ onExit(cb, opts) {
1328
+ return handler.onExit(cb, opts);
1329
+ },
1330
+ load() {
1331
+ return handler.load();
1332
+ },
1333
+ unload() {
1334
+ return handler.unload();
1335
+ }
1336
+ };
1337
+ };
1338
+ var SignalExitFallback = class extends SignalExitBase {
1339
+ onExit() {
1340
+ return () => {};
1341
+ }
1342
+ load() {}
1343
+ unload() {}
1344
+ };
1345
+ var SignalExit = class extends SignalExitBase {
1346
+ /* c8 ignore start */
1347
+ #hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
1348
+ /* c8 ignore stop */
1349
+ #emitter = new Emitter();
1350
+ #process;
1351
+ #originalProcessEmit;
1352
+ #originalProcessReallyExit;
1353
+ #sigListeners = {};
1354
+ #loaded = false;
1355
+ constructor(process$3) {
1356
+ super();
1357
+ this.#process = process$3;
1358
+ this.#sigListeners = {};
1359
+ for (const sig of signals) this.#sigListeners[sig] = () => {
1360
+ const listeners = this.#process.listeners(sig);
1361
+ let { count } = this.#emitter;
1362
+ /* c8 ignore start */
1363
+ const p = process$3;
1364
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
1365
+ /* c8 ignore stop */
1366
+ if (listeners.length === count) {
1367
+ this.unload();
1368
+ const ret = this.#emitter.emit("exit", null, sig);
1369
+ /* c8 ignore start */
1370
+ const s$1 = sig === "SIGHUP" ? this.#hupSig : sig;
1371
+ if (!ret) process$3.kill(process$3.pid, s$1);
1372
+ }
1373
+ };
1374
+ this.#originalProcessReallyExit = process$3.reallyExit;
1375
+ this.#originalProcessEmit = process$3.emit;
1376
+ }
1377
+ onExit(cb, opts) {
1378
+ /* c8 ignore start */
1379
+ if (!processOk(this.#process)) return () => {};
1380
+ /* c8 ignore stop */
1381
+ if (this.#loaded === false) this.load();
1382
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
1383
+ this.#emitter.on(ev, cb);
1384
+ return () => {
1385
+ this.#emitter.removeListener(ev, cb);
1386
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
1387
+ };
1388
+ }
1389
+ load() {
1390
+ if (this.#loaded) return;
1391
+ this.#loaded = true;
1392
+ this.#emitter.count += 1;
1393
+ for (const sig of signals) try {
1394
+ const fn = this.#sigListeners[sig];
1395
+ if (fn) this.#process.on(sig, fn);
1396
+ } catch (_$1) {}
1397
+ this.#process.emit = (ev, ...a$1) => {
1398
+ return this.#processEmit(ev, ...a$1);
1399
+ };
1400
+ this.#process.reallyExit = (code) => {
1401
+ return this.#processReallyExit(code);
1402
+ };
1403
+ }
1404
+ unload() {
1405
+ if (!this.#loaded) return;
1406
+ this.#loaded = false;
1407
+ signals.forEach((sig) => {
1408
+ const listener = this.#sigListeners[sig];
1409
+ /* c8 ignore start */
1410
+ if (!listener) throw new Error("Listener not defined for signal: " + sig);
1411
+ /* c8 ignore stop */
1412
+ try {
1413
+ this.#process.removeListener(sig, listener);
1414
+ } catch (_$1) {}
1415
+ /* c8 ignore stop */
1416
+ });
1417
+ this.#process.emit = this.#originalProcessEmit;
1418
+ this.#process.reallyExit = this.#originalProcessReallyExit;
1419
+ this.#emitter.count -= 1;
1420
+ }
1421
+ #processReallyExit(code) {
1422
+ /* c8 ignore start */
1423
+ if (!processOk(this.#process)) return 0;
1424
+ this.#process.exitCode = code || 0;
1425
+ /* c8 ignore stop */
1426
+ this.#emitter.emit("exit", this.#process.exitCode, null);
1427
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
1428
+ }
1429
+ #processEmit(ev, ...args) {
1430
+ const og = this.#originalProcessEmit;
1431
+ if (ev === "exit" && processOk(this.#process)) {
1432
+ if (typeof args[0] === "number") this.#process.exitCode = args[0];
1433
+ /* c8 ignore start */
1434
+ const ret = og.call(this.#process, ev, ...args);
1435
+ /* c8 ignore start */
1436
+ this.#emitter.emit("exit", this.#process.exitCode, null);
1437
+ /* c8 ignore stop */
1438
+ return ret;
1439
+ } else return og.call(this.#process, ev, ...args);
1440
+ }
1441
+ };
1442
+ const process$2 = globalThis.process;
1443
+ const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
1444
+
1445
+ //#endregion
1446
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.1/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
1447
+ var require_usingCtx = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.1/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) {
1448
+ function _usingCtx() {
1449
+ var r$1 = "function" == typeof SuppressedError ? SuppressedError : function(r$2, e$1) {
1450
+ var n$2 = Error();
1451
+ return n$2.name = "SuppressedError", n$2.error = r$2, n$2.suppressed = e$1, n$2;
1452
+ }, e = {}, n$1 = [];
1453
+ function using(r$2, e$1) {
1454
+ if (null != e$1) {
1455
+ if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
1456
+ if (r$2) var o$1 = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
1457
+ if (void 0 === o$1 && (o$1 = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$2)) var t$1 = o$1;
1458
+ if ("function" != typeof o$1) throw new TypeError("Object is not disposable.");
1459
+ t$1 && (o$1 = function o$2() {
1460
+ try {
1461
+ t$1.call(e$1);
1462
+ } catch (r$3) {
1463
+ return Promise.reject(r$3);
1464
+ }
1465
+ }), n$1.push({
1466
+ v: e$1,
1467
+ d: o$1,
1468
+ a: r$2
1469
+ });
1470
+ } else r$2 && n$1.push({
1471
+ d: e$1,
1472
+ a: r$2
1473
+ });
1474
+ return e$1;
1475
+ }
1476
+ return {
1477
+ e,
1478
+ u: using.bind(null, !1),
1479
+ a: using.bind(null, !0),
1480
+ d: function d() {
1481
+ var o$1, t$1 = this.e, s$1 = 0;
1482
+ function next() {
1483
+ for (; o$1 = n$1.pop();) try {
1484
+ if (!o$1.a && 1 === s$1) return s$1 = 0, n$1.push(o$1), Promise.resolve().then(next);
1485
+ if (o$1.d) {
1486
+ var r$2 = o$1.d.call(o$1.v);
1487
+ if (o$1.a) return s$1 |= 2, Promise.resolve(r$2).then(next, err);
1488
+ } else s$1 |= 1;
1489
+ } catch (r$3) {
1490
+ return err(r$3);
1491
+ }
1492
+ if (1 === s$1) return t$1 !== e ? Promise.reject(t$1) : Promise.resolve();
1493
+ if (t$1 !== e) throw t$1;
1494
+ }
1495
+ function err(n$2) {
1496
+ return t$1 = t$1 !== e ? new r$1(n$2, t$1) : n$2, next();
1497
+ }
1498
+ return next();
1499
+ }
1500
+ };
1501
+ }
1502
+ module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
1503
+ } });
1504
+
1505
+ //#endregion
1506
+ //#region src/cli/commands/bundle.ts
1507
+ var import_usingCtx = __toESM(require_usingCtx());
1508
+ async function bundleWithConfig(configPath, cliOptions) {
1509
+ if (cliOptions.watch) {
1510
+ process.env.ROLLUP_WATCH = "true";
1511
+ process.env.ROLLDOWN_WATCH = "true";
1512
+ }
1513
+ const config = await loadConfig(configPath);
1514
+ if (!config) {
1515
+ logger.error(`No configuration found at ${config}`);
1516
+ process.exit(1);
1517
+ }
1518
+ if (cliOptions.watch) await watchInner(config, cliOptions);
1519
+ else await bundleInner(config, cliOptions);
1520
+ }
1521
+ async function bundleWithCliOptions(cliOptions) {
1522
+ try {
1523
+ var _usingCtx$1 = (0, import_usingCtx.default)();
1524
+ if (cliOptions.output.dir || cliOptions.output.file) {
1525
+ const operation = cliOptions.watch ? watchInner : bundleInner;
1526
+ await operation({}, cliOptions);
1527
+ return;
1528
+ }
1529
+ if (cliOptions.watch) {
1530
+ logger.error("You must specify `output.dir` to use watch mode");
1531
+ process.exit(1);
1532
+ }
1533
+ const build = _usingCtx$1.a(await rolldown(cliOptions.input));
1534
+ const { output: outputs } = await build.generate(cliOptions.output);
1535
+ if (outputs.length === 0) {
1536
+ logger.error("No output generated");
1537
+ process.exit(1);
1538
+ }
1539
+ for (const file of outputs) {
1540
+ if (outputs.length > 1) logger.log(`\n${colors.cyan(colors.bold(`|→ ${file.fileName}:`))}\n`);
1541
+ console.log(file.type === "asset" ? file.source : file.code);
1542
+ }
1543
+ } catch (_$1) {
1544
+ _usingCtx$1.e = _$1;
1545
+ } finally {
1546
+ await _usingCtx$1.d();
1547
+ }
1548
+ }
1549
+ async function watchInner(config, cliOptions) {
1550
+ let normalizedConfig = arraify(config).map((option) => {
1551
+ return {
1552
+ ...option,
1553
+ ...cliOptions.input,
1554
+ output: arraify(option.output || {}).map((output) => {
1555
+ return {
1556
+ ...output,
1557
+ ...cliOptions.output
1558
+ };
1559
+ })
1560
+ };
1561
+ });
1562
+ const watcher = await watch(normalizedConfig);
1563
+ onExit((code) => {
1564
+ Promise.resolve(watcher.close()).finally(() => {
1565
+ process.exit(typeof code === "number" ? code : 0);
1566
+ });
1567
+ return true;
1568
+ });
1569
+ const changedFile = [];
1570
+ watcher.on("change", (id, event) => {
1571
+ if (event.event === "update") changedFile.push(id);
1572
+ });
1573
+ watcher.on("event", async (event) => {
1574
+ switch (event.code) {
1575
+ case "BUNDLE_START":
1576
+ if (changedFile.length > 0) logger.log(`Found ${colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
1577
+ changedFile.length = 0;
1578
+ break;
1579
+ case "BUNDLE_END":
1580
+ await event.result.close();
1581
+ logger.success(`Rebuilt ${colors.bold(relativeId(event.output[0]))} in ${colors.bold(ms(event.duration))}.`);
1582
+ break;
1583
+ case "ERROR":
1584
+ await event.result.close();
1585
+ logger.error(event.error);
1586
+ break;
1587
+ default: break;
1588
+ }
1589
+ });
1590
+ logger.log(`Waiting for changes...`);
1591
+ }
1592
+ async function bundleInner(config, cliOptions) {
1593
+ const startTime = performance.now();
1594
+ const result = [];
1595
+ const configList = arraify(config);
1596
+ for (const config$1 of configList) {
1597
+ const outputList = arraify(config$1.output || {});
1598
+ const build = await rolldown({
1599
+ ...config$1,
1600
+ ...cliOptions.input
1601
+ });
1602
+ for (const output of outputList) try {
1603
+ result.push(await build.write({
1604
+ ...output,
1605
+ ...cliOptions.output
1606
+ }));
1607
+ } finally {
1608
+ await build.close();
1609
+ }
1610
+ }
1611
+ result.forEach(printBundleOutputPretty);
1612
+ logger.log(``);
1613
+ const endTime = performance.now();
1614
+ const duration = endTime - startTime;
1615
+ logger.success(`Finished in ${colors.bold(ms(duration))}`);
1616
+ }
1617
+ function printBundleOutputPretty(output) {
1618
+ const outputEntries = collectOutputEntries(output.output);
1619
+ const outputLayoutSizes = collectOutputLayoutAdjustmentSizes(outputEntries);
1620
+ printOutputEntries(outputEntries, outputLayoutSizes, "<DIR>");
1621
+ }
1622
+ function collectOutputEntries(output) {
1623
+ return output.map((chunk) => ({
1624
+ type: chunk.type,
1625
+ fileName: chunk.fileName,
1626
+ size: chunk.type === "chunk" ? Buffer.byteLength(chunk.code) : Buffer.byteLength(chunk.source)
1627
+ }));
1628
+ }
1629
+ function collectOutputLayoutAdjustmentSizes(entries) {
1630
+ let longest = 0;
1631
+ let biggestSize = 0;
1632
+ for (const entry of entries) {
1633
+ if (entry.fileName.length > longest) longest = entry.fileName.length;
1634
+ if (entry.size > biggestSize) biggestSize = entry.size;
1635
+ }
1636
+ const sizePad = displaySize(biggestSize).length;
1637
+ return {
1638
+ longest,
1639
+ biggestSize,
1640
+ sizePad
1641
+ };
1642
+ }
1643
+ const numberFormatter = new Intl.NumberFormat("en", {
1644
+ maximumFractionDigits: 2,
1645
+ minimumFractionDigits: 2
1646
+ });
1647
+ function displaySize(bytes) {
1648
+ return `${numberFormatter.format(bytes / 1e3)} kB`;
1649
+ }
1650
+ const CHUNK_GROUPS = [{
1651
+ type: "asset",
1652
+ color: "green"
1653
+ }, {
1654
+ type: "chunk",
1655
+ color: "cyan"
1656
+ }];
1657
+ function printOutputEntries(entries, sizeAdjustment, distPath) {
1658
+ for (const group of CHUNK_GROUPS) {
1659
+ const filtered = entries.filter((e) => e.type === group.type);
1660
+ if (!filtered.length) continue;
1661
+ for (const entry of filtered.sort((a$1, z) => a$1.size - z.size)) {
1662
+ let log = colors.dim(withTrailingSlash(distPath));
1663
+ log += colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
1664
+ log += colors.dim(entry.type);
1665
+ log += colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
1666
+ logger.log(log);
1667
+ }
1668
+ }
1669
+ }
1670
+ function withTrailingSlash(path$1) {
1671
+ if (path$1[path$1.length - 1] !== "/") return `${path$1}/`;
1672
+ return path$1;
1673
+ }
1674
+ function ms(duration) {
1675
+ return duration < 1e3 ? `${duration.toFixed(2)} ms` : `${(duration / 1e3).toFixed(2)} s`;
1676
+ }
1677
+ function relativeId(id) {
1678
+ if (!path.isAbsolute(id)) return id;
1679
+ return path.relative(path.resolve(), id);
1680
+ }
1681
+
1682
+ //#endregion
1683
+ //#region src/cli/commands/help.ts
1684
+ const introduction = `${colors.gray(`${description} (rolldown v${version})`)}
1685
+
1686
+ ${colors.bold(colors.underline("USAGE"))} ${colors.cyan("rolldown -c <config>")} or ${colors.cyan("rolldown <input> <options>")}`;
1687
+ const examples = [
1688
+ {
1689
+ title: "Bundle with a config file `rolldown.config.mjs`",
1690
+ command: "rolldown -c rolldown.config.mjs"
1691
+ },
1692
+ {
1693
+ title: "Bundle the `src/main.ts` to `dist` with `cjs` format",
1694
+ command: "rolldown src/main.ts -d dist -f cjs"
1695
+ },
1696
+ {
1697
+ title: "Bundle the `src/main.ts` and handle the `.png` assets to Data URL",
1698
+ command: "rolldown src/main.ts -d dist --moduleTypes .png=dataurl"
1699
+ },
1700
+ {
1701
+ title: "Bundle the `src/main.tsx` and minify the output with sourcemap",
1702
+ command: "rolldown src/main.tsx -d dist -m -s"
1703
+ },
1704
+ {
1705
+ title: "Create self-executing IIFE using external jQuery as `$` and `_`",
1706
+ command: "rolldown src/main.ts -d dist -n bundle -f iife -e jQuery,window._ -g jQuery=$"
1707
+ }
1708
+ ];
1709
+ const notes = [
1710
+ "Due to the API limitation, you need to pass `-s` for `.map` sourcemap file as the last argument.",
1711
+ "If you are using the configuration, please pass the `-c` as the last argument if you ignore the default configuration file.",
1712
+ "CLI options will override the configuration file.",
1713
+ "For more information, please visit https://rolldown.rs/."
1714
+ ];
1715
+ function showHelp() {
1716
+ logger.log(introduction);
1717
+ logger.log("");
1718
+ logger.log(`${colors.bold(colors.underline("OPTIONS"))}`);
1719
+ logger.log("");
1720
+ logger.log(Object.entries(options).sort(([a$1], [b$1]) => {
1721
+ if (options[a$1].short && !options[b$1].short) return -1;
1722
+ if (!options[a$1].short && options[b$1].short) return 1;
1723
+ if (options[a$1].short && options[b$1].short) return options[a$1].short.localeCompare(options[b$1].short);
1724
+ return a$1.localeCompare(b$1);
1725
+ }).map(([option, { type, short, hint, description: description$1 }]) => {
1726
+ let optionStr = ` --${option} `;
1727
+ option = camelCaseToKebabCase(option);
1728
+ if (short) optionStr += `-${short}, `;
1729
+ if (type === "string") optionStr += `<${hint ?? option}>`;
1730
+ if (description$1 && description$1.length > 0) description$1 = description$1[0].toUpperCase() + description$1.slice(1);
1731
+ return colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
1732
+ }).join("\n"));
1733
+ logger.log("");
1734
+ logger.log(`${colors.bold(colors.underline("EXAMPLES"))}`);
1735
+ logger.log("");
1736
+ examples.forEach(({ title, command }, ord) => {
1737
+ logger.log(` ${ord + 1}. ${title}:`);
1738
+ logger.log(` ${colors.cyan(command)}`);
1739
+ logger.log("");
1740
+ });
1741
+ logger.log(`${colors.bold(colors.underline("NOTES"))}`);
1742
+ logger.log("");
1743
+ notes.forEach((note) => {
1744
+ logger.log(` * ${colors.gray(note)}`);
1745
+ });
1746
+ }
1747
+
1748
+ //#endregion
1749
+ //#region src/cli/index.ts
1750
+ async function main() {
1751
+ const cliOptions = parseCliArguments();
1752
+ if (cliOptions.config || cliOptions.config === "") {
1753
+ await bundleWithConfig(cliOptions.config, cliOptions);
1754
+ return;
1755
+ }
1756
+ if ("input" in cliOptions.input) {
1757
+ await bundleWithCliOptions(cliOptions);
1758
+ return;
1759
+ }
1760
+ if (cliOptions.version) {
1761
+ logger.log(`rolldown v${version}`);
1762
+ return;
1763
+ }
1764
+ showHelp();
1765
+ }
1766
+ main().catch((err) => {
1767
+ logger.error(err);
1768
+ process$1.exit(1);
1769
+ });
1770
+
1771
+ //#endregion