ccusage 15.9.1 → 15.9.3

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.
@@ -17,8 +17,7 @@ const LogLevels = {
17
17
  debug: 4,
18
18
  trace: 5,
19
19
  verbose: Number.POSITIVE_INFINITY
20
- };
21
- const LogTypes = {
20
+ }, LogTypes = {
22
21
  silent: { level: -1 },
23
22
  fatal: { level: LogLevels.fatal },
24
23
  error: { level: LogLevels.error },
@@ -37,10 +36,7 @@ const LogTypes = {
37
36
  function isPlainObject$1(value) {
38
37
  if (value === null || typeof value !== "object") return false;
39
38
  const prototype = Object.getPrototypeOf(value);
40
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
41
- if (Symbol.iterator in value) return false;
42
- if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
43
- return true;
39
+ return prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null || Symbol.iterator in value ? false : Symbol.toStringTag in value ? Object.prototype.toString.call(value) === "[object Module]" : true;
44
40
  }
45
41
  function _defu(baseObject, defaults, namespace = ".", merger) {
46
42
  if (!isPlainObject$1(defaults)) return _defu(baseObject, {}, namespace, merger);
@@ -48,8 +44,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
48
44
  for (const key in baseObject) {
49
45
  if (key === "__proto__" || key === "constructor") continue;
50
46
  const value = baseObject[key];
51
- if (value === null || value === void 0) continue;
52
- if (merger && merger(object, key, value, namespace)) continue;
47
+ if (value === null || value === void 0 || merger && merger(object, key, value, namespace)) continue;
53
48
  if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
54
49
  else if (isPlainObject$1(value) && isPlainObject$1(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
55
50
  else object[key] = value;
@@ -64,10 +59,7 @@ function isPlainObject(obj) {
64
59
  return Object.prototype.toString.call(obj) === "[object Object]";
65
60
  }
66
61
  function isLogObj(arg) {
67
- if (!isPlainObject(arg)) return false;
68
- if (!arg.message && !arg.args) return false;
69
- if (arg.stack) return false;
70
- return true;
62
+ return !(!isPlainObject(arg) || !arg.message && !arg.args || arg.stack);
71
63
  }
72
64
  let paused = false;
73
65
  const queue = [];
@@ -75,14 +67,9 @@ var Consola = class Consola {
75
67
  options;
76
68
  _lastLog;
77
69
  _mockFn;
78
- /**
79
- * Creates an instance of Consola with specified options or defaults.
80
- *
81
- * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
82
- */
83
70
  constructor(options = {}) {
84
71
  const types = options.types || LogTypes;
85
- this.options = defu({
72
+ for (const type in this.options = defu({
86
73
  ...options,
87
74
  defaults: { ...options.defaults },
88
75
  level: _normalizeLogLevel(options.level, types),
@@ -96,54 +83,27 @@ var Consola = class Consola {
96
83
  colors: false,
97
84
  compact: true
98
85
  }
99
- });
100
- for (const type in types) {
86
+ }), types) {
101
87
  const defaults = {
102
88
  type,
103
89
  ...this.options.defaults,
104
90
  ...types[type]
105
91
  };
106
- this[type] = this._wrapLogFn(defaults);
107
- this[type].raw = this._wrapLogFn(defaults, true);
92
+ this[type] = this._wrapLogFn(defaults), this[type].raw = this._wrapLogFn(defaults, true);
108
93
  }
109
94
  if (this.options.mockFn) this.mockTypes();
110
95
  this._lastLog = {};
111
96
  }
112
- /**
113
- * Gets the current log level of the Consola instance.
114
- *
115
- * @returns {number} The current log level.
116
- */
117
97
  get level() {
118
98
  return this.options.level;
119
99
  }
120
- /**
121
- * Sets the minimum log level that will be output by the instance.
122
- *
123
- * @param {number} level - The new log level to set.
124
- */
125
100
  set level(level) {
126
101
  this.options.level = _normalizeLogLevel(level, this.options.types, this.options.level);
127
102
  }
128
- /**
129
- * Displays a prompt to the user and returns the response.
130
- * Throw an error if `prompt` is not supported by the current configuration.
131
- *
132
- * @template T
133
- * @param {string} message - The message to display in the prompt.
134
- * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
135
- * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
136
- */
137
103
  prompt(message, opts) {
138
104
  if (!this.options.prompt) throw new Error("prompt is not supported!");
139
105
  return this.options.prompt(message, opts);
140
106
  }
141
- /**
142
- * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
143
- *
144
- * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
145
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
146
- */
147
107
  create(options) {
148
108
  const instance = new Consola({
149
109
  ...this.options,
@@ -152,12 +112,6 @@ var Consola = class Consola {
152
112
  if (this._mockFn) instance.mockTypes(this._mockFn);
153
113
  return instance;
154
114
  }
155
- /**
156
- * Creates a new Consola instance with the specified default log object properties.
157
- *
158
- * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
159
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
160
- */
161
115
  withDefaults(defaults) {
162
116
  return this.create({
163
117
  ...this.options,
@@ -167,33 +121,12 @@ var Consola = class Consola {
167
121
  }
168
122
  });
169
123
  }
170
- /**
171
- * Creates a new Consola instance with a specified tag, which will be included in every log.
172
- *
173
- * @param {string} tag - The tag to include in each log of the new instance.
174
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
175
- */
176
124
  withTag(tag) {
177
125
  return this.withDefaults({ tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag });
178
126
  }
179
- /**
180
- * Adds a custom reporter to the Consola instance.
181
- * Reporters will be called for each log message, depending on their implementation and log level.
182
- *
183
- * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
184
- * @returns {Consola} The current Consola instance.
185
- */
186
127
  addReporter(reporter) {
187
- this.options.reporters.push(reporter);
188
- return this;
128
+ return this.options.reporters.push(reporter), this;
189
129
  }
190
- /**
191
- * Removes a custom reporter from the Consola instance.
192
- * If no reporter is specified, all reporters will be removed.
193
- *
194
- * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
195
- * @returns {Consola} The current Consola instance.
196
- */
197
130
  removeReporter(reporter) {
198
131
  if (reporter) {
199
132
  const i$1 = this.options.reporters.indexOf(reporter);
@@ -201,97 +134,52 @@ var Consola = class Consola {
201
134
  } else this.options.reporters.splice(0);
202
135
  return this;
203
136
  }
204
- /**
205
- * Replaces all reporters of the Consola instance with the specified array of reporters.
206
- *
207
- * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
208
- * @returns {Consola} The current Consola instance.
209
- */
210
137
  setReporters(reporters) {
211
- this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
212
- return this;
138
+ return this.options.reporters = Array.isArray(reporters) ? reporters : [reporters], this;
213
139
  }
214
140
  wrapAll() {
215
- this.wrapConsole();
216
- this.wrapStd();
141
+ this.wrapConsole(), this.wrapStd();
217
142
  }
218
143
  restoreAll() {
219
- this.restoreConsole();
220
- this.restoreStd();
144
+ this.restoreConsole(), this.restoreStd();
221
145
  }
222
- /**
223
- * Overrides console methods with Consola logging methods for consistent logging.
224
- */
225
146
  wrapConsole() {
226
147
  for (const type in this.options.types) {
227
148
  if (!console["__" + type]) console["__" + type] = console[type];
228
149
  console[type] = this[type].raw;
229
150
  }
230
151
  }
231
- /**
232
- * Restores the original console methods, removing Consola overrides.
233
- */
234
152
  restoreConsole() {
235
- for (const type in this.options.types) if (console["__" + type]) {
236
- console[type] = console["__" + type];
237
- delete console["__" + type];
238
- }
153
+ for (const type in this.options.types) if (console["__" + type]) console[type] = console["__" + type], delete console["__" + type];
239
154
  }
240
- /**
241
- * Overrides standard output and error streams to redirect them through Consola.
242
- */
243
155
  wrapStd() {
244
- this._wrapStream(this.options.stdout, "log");
245
- this._wrapStream(this.options.stderr, "log");
156
+ this._wrapStream(this.options.stdout, "log"), this._wrapStream(this.options.stderr, "log");
246
157
  }
247
158
  _wrapStream(stream, type) {
248
- if (!stream) return;
249
- if (!stream.__write) stream.__write = stream.write;
250
- stream.write = (data) => {
251
- this[type].raw(String(data).trim());
252
- };
159
+ if (stream) {
160
+ if (!stream.__write) stream.__write = stream.write;
161
+ stream.write = (data) => {
162
+ this[type].raw(String(data).trim());
163
+ };
164
+ }
253
165
  }
254
- /**
255
- * Restores the original standard output and error streams, removing the Consola redirection.
256
- */
257
166
  restoreStd() {
258
- this._restoreStream(this.options.stdout);
259
- this._restoreStream(this.options.stderr);
167
+ this._restoreStream(this.options.stdout), this._restoreStream(this.options.stderr);
260
168
  }
261
169
  _restoreStream(stream) {
262
- if (!stream) return;
263
- if (stream.__write) {
264
- stream.write = stream.__write;
265
- delete stream.__write;
266
- }
170
+ if (stream && stream.__write) stream.write = stream.__write, delete stream.__write;
267
171
  }
268
- /**
269
- * Pauses logging, queues incoming logs until resumed.
270
- */
271
172
  pauseLogs() {
272
173
  paused = true;
273
174
  }
274
- /**
275
- * Resumes logging, processing any queued logs.
276
- */
277
175
  resumeLogs() {
278
176
  paused = false;
279
177
  const _queue = queue.splice(0);
280
178
  for (const item of _queue) item[0]._logFn(item[1], item[2]);
281
179
  }
282
- /**
283
- * Replaces logging methods with mocks if a mock function is provided.
284
- *
285
- * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
286
- */
287
180
  mockTypes(mockFn) {
288
181
  const _mockFn = mockFn || this.options.mockFn;
289
- this._mockFn = _mockFn;
290
- if (typeof _mockFn !== "function") return;
291
- for (const type in this.options.types) {
292
- this[type] = _mockFn(type, this.options.types[type]) || this[type];
293
- this[type].raw = this[type];
294
- }
182
+ if (this._mockFn = _mockFn, typeof _mockFn === "function") for (const type in this.options.types) this[type] = _mockFn(type, this.options.types[type]) || this[type], this[type].raw = this[type];
295
183
  }
296
184
  _wrapLogFn(defaults, isRaw) {
297
185
  return (...args) => {
@@ -317,17 +205,12 @@ var Consola = class Consola {
317
205
  };
318
206
  if (!isRaw && args.length === 1 && isLogObj(args[0])) Object.assign(logObj, args[0]);
319
207
  else logObj.args = [...args];
320
- if (logObj.message) {
321
- logObj.args.unshift(logObj.message);
322
- delete logObj.message;
323
- }
208
+ if (logObj.message) logObj.args.unshift(logObj.message), delete logObj.message;
324
209
  if (logObj.additional) {
325
210
  if (!Array.isArray(logObj.additional)) logObj.additional = logObj.additional.split("\n");
326
- logObj.args.push("\n" + logObj.additional.join("\n"));
327
- delete logObj.additional;
211
+ logObj.args.push("\n" + logObj.additional.join("\n")), delete logObj.additional;
328
212
  }
329
- logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
330
- logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
213
+ logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log", logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
331
214
  const resolveLog = (newLog = false) => {
332
215
  const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
333
216
  if (this._lastLog.object && repeated > 0) {
@@ -336,28 +219,20 @@ var Consola = class Consola {
336
219
  this._log({
337
220
  ...this._lastLog.object,
338
221
  args: args2
339
- });
340
- this._lastLog.count = 1;
341
- }
342
- if (newLog) {
343
- this._lastLog.object = logObj;
344
- this._log(logObj);
222
+ }), this._lastLog.count = 1;
345
223
  }
224
+ if (newLog) this._lastLog.object = logObj, this._log(logObj);
346
225
  };
347
226
  clearTimeout(this._lastLog.timeout);
348
227
  const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
349
- this._lastLog.time = logObj.date;
350
- if (diffTime < this.options.throttle) try {
228
+ if (this._lastLog.time = logObj.date, diffTime < this.options.throttle) try {
351
229
  const serializedLog = JSON.stringify([
352
230
  logObj.type,
353
231
  logObj.tag,
354
232
  logObj.args
355
- ]);
356
- const isSameLog = this._lastLog.serialized === serializedLog;
357
- this._lastLog.serialized = serializedLog;
358
- if (isSameLog) {
359
- this._lastLog.count = (this._lastLog.count || 0) + 1;
360
- if (this._lastLog.count > this.options.throttleMin) {
233
+ ]), isSameLog = this._lastLog.serialized === serializedLog;
234
+ if (this._lastLog.serialized = serializedLog, isSameLog) {
235
+ if (this._lastLog.count = (this._lastLog.count || 0) + 1, this._lastLog.count > this.options.throttleMin) {
361
236
  this._lastLog.timeout = setTimeout(resolveLog, this.options.throttle);
362
237
  return;
363
238
  }
@@ -370,24 +245,14 @@ var Consola = class Consola {
370
245
  }
371
246
  };
372
247
  function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
373
- if (input === void 0) return defaultLevel;
374
- if (typeof input === "number") return input;
375
- if (types[input] && types[input].level !== void 0) return types[input].level;
376
- return defaultLevel;
377
- }
378
- Consola.prototype.add = Consola.prototype.addReporter;
379
- Consola.prototype.remove = Consola.prototype.removeReporter;
380
- Consola.prototype.clear = Consola.prototype.removeReporter;
381
- Consola.prototype.withScope = Consola.prototype.withTag;
382
- Consola.prototype.mock = Consola.prototype.mockTypes;
383
- Consola.prototype.pause = Consola.prototype.pauseLogs;
384
- Consola.prototype.resume = Consola.prototype.resumeLogs;
385
- function createConsola$1(options = {}) {
248
+ return input === void 0 ? defaultLevel : typeof input === "number" ? input : types[input] && types[input].level !== void 0 ? types[input].level : defaultLevel;
249
+ }
250
+ Consola.prototype.add = Consola.prototype.addReporter, Consola.prototype.remove = Consola.prototype.removeReporter, Consola.prototype.clear = Consola.prototype.removeReporter, Consola.prototype.withScope = Consola.prototype.withTag, Consola.prototype.mock = Consola.prototype.mockTypes, Consola.prototype.pause = Consola.prototype.pauseLogs, Consola.prototype.resume = Consola.prototype.resumeLogs;
251
+ function createConsola(options = {}) {
386
252
  return new Consola(options);
387
253
  }
388
254
  function parseStack(stack, message) {
389
- const cwd = process.cwd() + sep;
390
- const lines = stack.split("\n").splice(message.split("\n").length).map((l$1) => l$1.trim().replace("file://", "").replace(cwd, ""));
255
+ const cwd = process.cwd() + sep, lines = stack.split("\n").splice(message.split("\n").length).map((l$1) => l$1.trim().replace("file://", "").replace(cwd, ""));
391
256
  return lines;
392
257
  }
393
258
  function writeStream(data, stream) {
@@ -402,11 +267,7 @@ var BasicReporter = class {
402
267
  ${indent}`);
403
268
  }
404
269
  formatError(err, opts) {
405
- const message = err.message ?? formatWithOptions(opts, err);
406
- const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
407
- const level = opts?.errorLevel || 0;
408
- const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
409
- const causedError = err.cause ? "\n\n" + this.formatError(err.cause, {
270
+ const message = err.message ?? formatWithOptions(opts, err), stack = err.stack ? this.formatStack(err.stack, message, opts) : "", level = opts?.errorLevel || 0, causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "", causedError = err.cause ? "\n\n" + this.formatError(err.cause, {
410
271
  ...opts,
411
272
  errorLevel: level + 1
412
273
  }) : "";
@@ -414,8 +275,7 @@ ${indent}`);
414
275
  }
415
276
  formatArgs(args, opts) {
416
277
  const _args = args.map((arg) => {
417
- if (arg && typeof arg.stack === "string") return this.formatError(arg, opts);
418
- return arg;
278
+ return arg && typeof arg.stack === "string" ? this.formatError(arg, opts) : arg;
419
279
  });
420
280
  return formatWithOptions(opts, ..._args);
421
281
  }
@@ -427,12 +287,11 @@ ${indent}`);
427
287
  }
428
288
  formatLogObj(logObj, opts) {
429
289
  const message = this.formatArgs(logObj.args, opts);
430
- if (logObj.type === "box") return "\n" + [
290
+ return logObj.type === "box" ? "\n" + [
431
291
  bracket(logObj.tag),
432
292
  logObj.title && logObj.title,
433
293
  ...message.split("\n")
434
- ].filter(Boolean).map((l$1) => " > " + l$1).join("\n") + "\n";
435
- return this.filterAndJoin([
294
+ ].filter(Boolean).map((l$1) => " > " + l$1).join("\n") + "\n" : this.filterAndJoin([
436
295
  bracket(logObj.type),
437
296
  bracket(logObj.tag),
438
297
  message
@@ -446,14 +305,7 @@ ${indent}`);
446
305
  return writeStream(line + "\n", logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
447
306
  }
448
307
  };
449
- const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
450
- const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
451
- const isForced = "FORCE_COLOR" in env || argv.includes("--color");
452
- const isWindows = platform === "win32";
453
- const isDumbTerminal = env.TERM === "dumb";
454
- const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
455
- const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
456
- const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
308
+ const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process, isDisabled = "NO_COLOR" in env || argv.includes("--no-color"), isForced = "FORCE_COLOR" in env || argv.includes("--color"), isWindows = platform === "win32", isDumbTerminal = env.TERM === "dumb", isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal, isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env), isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
457
309
  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)) {
458
310
  return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
459
311
  }
@@ -517,7 +369,7 @@ function getColor$1(color, fallback = "reset") {
517
369
  return colors[color] || colors[fallback];
518
370
  }
519
371
  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("|");
520
- function stripAnsi$1(text) {
372
+ function stripAnsi(text) {
521
373
  return text.replace(new RegExp(ansiRegex$1, "g"), "");
522
374
  }
523
375
  const boxStylePresets = {
@@ -585,8 +437,7 @@ const boxStylePresets = {
585
437
  h: "─",
586
438
  v: "│"
587
439
  }
588
- };
589
- const defaultStyle = {
440
+ }, defaultStyle = {
590
441
  borderColor: "white",
591
442
  borderStyle: "rounded",
592
443
  valign: "center",
@@ -602,34 +453,21 @@ function box(text, _opts = {}) {
602
453
  ...defaultStyle,
603
454
  ..._opts.style
604
455
  }
605
- };
606
- const textLines = text.split("\n");
607
- const boxLines = [];
608
- const _color = getColor$1(opts.style.borderColor);
609
- const borderStyle = { ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle };
456
+ }, textLines = text.split("\n"), boxLines = [], _color = getColor$1(opts.style.borderColor), borderStyle = { ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle };
610
457
  if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
611
- const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
612
- const height = textLines.length + paddingOffset;
613
- const width = Math.max(...textLines.map((line) => stripAnsi$1(line).length), opts.title ? stripAnsi$1(opts.title).length : 0) + paddingOffset;
614
- const widthOffset = width + paddingOffset;
615
- const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
458
+ const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1, height = textLines.length + paddingOffset, width = Math.max(...textLines.map((line) => stripAnsi(line).length), opts.title ? stripAnsi(opts.title).length : 0) + paddingOffset, widthOffset = width + paddingOffset, leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
616
459
  if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
617
460
  if (opts.title) {
618
- const title = _color ? _color(opts.title) : opts.title;
619
- const left = borderStyle.h.repeat(Math.floor((width - stripAnsi$1(opts.title).length) / 2));
620
- const right = borderStyle.h.repeat(width - stripAnsi$1(opts.title).length - stripAnsi$1(left).length + paddingOffset);
461
+ const title = _color ? _color(opts.title) : opts.title, left = borderStyle.h.repeat(Math.floor((width - stripAnsi(opts.title).length) / 2)), right = borderStyle.h.repeat(width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset);
621
462
  boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
622
463
  } else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
623
464
  const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
624
465
  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}`);
625
466
  else {
626
- const line = textLines[i$1 - valignOffset];
627
- const left = " ".repeat(paddingOffset);
628
- const right = " ".repeat(width - stripAnsi$1(line).length);
467
+ const line = textLines[i$1 - valignOffset], left = " ".repeat(paddingOffset), right = " ".repeat(width - stripAnsi(line).length);
629
468
  boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
630
469
  }
631
- boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
632
- if (opts.style.marginBottom > 0) boxLines.push("".repeat(opts.style.marginBottom));
470
+ if (boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`), opts.style.marginBottom > 0) boxLines.push("".repeat(opts.style.marginBottom));
633
471
  return boxLines.join("\n");
634
472
  }
635
473
  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, {
@@ -793,12 +631,11 @@ function G() {
793
631
  const P = G();
794
632
  P?.name;
795
633
  function ansiRegex({ onlyFirst = false } = {}) {
796
- const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
797
- 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("|");
634
+ const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)", 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("|");
798
635
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
799
636
  }
800
637
  const regex = ansiRegex();
801
- function stripAnsi(string) {
638
+ function stripAnsi$1(string) {
802
639
  if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
803
640
  return string.replace(regex, "");
804
641
  }
@@ -815,30 +652,21 @@ function validate(codePoint) {
815
652
  if (!Number.isSafeInteger(codePoint)) throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
816
653
  }
817
654
  function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
818
- validate(codePoint);
819
- if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
820
- return 1;
655
+ return validate(codePoint), isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint) ? 2 : 1;
821
656
  }
822
657
  const emojiRegex = () => {
823
658
  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-\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08(?:\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;
824
- };
825
- const segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
826
- const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
659
+ }, segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") }, defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
827
660
  function stringWidth$1(string, options = {}) {
828
661
  if (typeof string !== "string" || string.length === 0) return 0;
829
662
  const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
830
- if (!countAnsiEscapeCodes) string = stripAnsi(string);
663
+ if (!countAnsiEscapeCodes) string = stripAnsi$1(string);
831
664
  if (string.length === 0) return 0;
832
665
  let width = 0;
833
666
  const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
834
667
  for (const { segment: character } of segmenter.segment(string)) {
835
668
  const codePoint = character.codePointAt(0);
836
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) continue;
837
- if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) continue;
838
- if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) continue;
839
- if (codePoint >= 55296 && codePoint <= 57343) continue;
840
- if (codePoint >= 65024 && codePoint <= 65039) continue;
841
- if (defaultIgnorableCodePointRegex.test(character)) continue;
669
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159 || codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279 || codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071 || codePoint >= 55296 && codePoint <= 57343 || codePoint >= 65024 && codePoint <= 65039 || defaultIgnorableCodePointRegex.test(character)) continue;
842
670
  if (emojiRegex().test(character)) {
843
671
  width += 2;
844
672
  continue;
@@ -848,10 +676,8 @@ function stringWidth$1(string, options = {}) {
848
676
  return width;
849
677
  }
850
678
  function isUnicodeSupported() {
851
- const { env: env$1 } = process$1;
852
- const { TERM, TERM_PROGRAM } = env$1;
853
- if (process$1.platform !== "win32") return TERM !== "linux";
854
- 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";
679
+ const { env: env$1 } = process$1, { TERM, TERM_PROGRAM } = env$1;
680
+ return process$1.platform === "win32" ? 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" : TERM !== "linux";
855
681
  }
856
682
  const TYPE_COLOR_MAP = {
857
683
  info: "cyan",
@@ -859,14 +685,10 @@ const TYPE_COLOR_MAP = {
859
685
  success: "green",
860
686
  ready: "green",
861
687
  start: "magenta"
862
- };
863
- const LEVEL_COLOR_MAP = {
688
+ }, LEVEL_COLOR_MAP = {
864
689
  0: "red",
865
690
  1: "yellow"
866
- };
867
- const unicode = isUnicodeSupported();
868
- const s = (c$1, fallback) => unicode ? c$1 : fallback;
869
- const TYPE_ICONS = {
691
+ }, unicode = isUnicodeSupported(), s = (c$1, fallback) => unicode ? c$1 : fallback, TYPE_ICONS = {
870
692
  error: s("✖", "×"),
871
693
  fatal: s("✖", "×"),
872
694
  ready: s("✔", "√"),
@@ -881,8 +703,7 @@ const TYPE_ICONS = {
881
703
  };
882
704
  function stringWidth(str) {
883
705
  const hasICU = typeof Intl === "object";
884
- if (!hasICU || !Intl.Segmenter) return stripAnsi$1(str).length;
885
- return stringWidth$1(str);
706
+ return !hasICU || !Intl.Segmenter ? stripAnsi(str).length : stringWidth$1(str);
886
707
  }
887
708
  var FancyReporter = class extends BasicReporter {
888
709
  formatStack(stack, message, opts) {
@@ -903,19 +724,11 @@ ${indent}`);
903
724
  title: logObj.title ? characterFormat(logObj.title) : void 0,
904
725
  style: logObj.style
905
726
  });
906
- const date = this.formatDate(logObj.date, opts);
907
- const coloredDate = date && colors.gray(date);
908
- const isBadge = logObj.badge ?? logObj.level < 2;
909
- const type = this.formatType(logObj, isBadge, opts);
910
- const tag = logObj.tag ? colors.gray(logObj.tag) : "";
727
+ const date = this.formatDate(logObj.date, opts), coloredDate = date && colors.gray(date), isBadge = logObj.badge ?? logObj.level < 2, type = this.formatType(logObj, isBadge, opts), tag = logObj.tag ? colors.gray(logObj.tag) : "";
911
728
  let line;
912
- const left = this.filterAndJoin([type, characterFormat(message)]);
913
- const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
914
- const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
915
- line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
916
- line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : "");
917
- if (logObj.type === "trace") {
918
- const _err = new Error("Trace: " + logObj.message);
729
+ const left = this.filterAndJoin([type, characterFormat(message)]), right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]), space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
730
+ if (line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left, line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : ""), logObj.type === "trace") {
731
+ const _err = /* @__PURE__ */ new Error("Trace: " + logObj.message);
919
732
  line += this.formatStack(_err.stack || "", _err.message);
920
733
  }
921
734
  return isBadge ? "\n" + line + "\n" : line;
@@ -930,39 +743,29 @@ function getColor(color = "white") {
930
743
  function getBgColor(color = "bgWhite") {
931
744
  return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
932
745
  }
933
- function createConsola(options = {}) {
746
+ function createConsola$1(options = {}) {
934
747
  let level = _getDefaultLogLevel();
935
748
  if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
936
- const consola2 = createConsola$1({
749
+ const consola2 = createConsola({
937
750
  level,
938
751
  defaults: { level },
939
752
  stdout: process.stdout,
940
753
  stderr: process.stderr,
941
- prompt: (...args) => import("./prompt-lm8M58zJ.js").then((m) => m.prompt(...args)),
754
+ prompt: (...args) => import("./prompt-DsUFNEY7.js").then((m) => m.prompt(...args)),
942
755
  reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
943
756
  ...options
944
757
  });
945
758
  return consola2;
946
759
  }
947
760
  function _getDefaultLogLevel() {
948
- if (g) return LogLevels.debug;
949
- if (R) return LogLevels.warn;
950
- return LogLevels.info;
951
- }
952
- const consola = createConsola();
953
- var name = "ccusage";
954
- var version = "15.9.1";
955
- var description = "Usage analysis tool for Claude Code";
956
- /**
957
- * Application logger instance with package name tag
958
- */
761
+ return g ? LogLevels.debug : R ? LogLevels.warn : LogLevels.info;
762
+ }
763
+ const consola = createConsola$1();
764
+ var name = "ccusage", version = "15.9.3", description = "Usage analysis tool for Claude Code";
959
765
  const logger = consola.withTag(name);
960
766
  if (process$1.env.LOG_LEVEL != null) {
961
767
  const level = Number.parseInt(process$1.env.LOG_LEVEL, 10);
962
768
  if (!Number.isNaN(level)) logger.level = level;
963
769
  }
964
- /**
965
- * Direct console.log function for cases where logger formatting is not desired
966
- */
967
770
  const log = console.log;
968
771
  export { description, log, logger, name, version };
package/dist/logger.js CHANGED
@@ -1,2 +1,2 @@
1
- import { log, logger } from "./logger-BODy31tA.js";
1
+ import { log, logger } from "./logger-L_zzb0iT.js";
2
2
  export { log, logger };