@optique/core 1.2.0-dev.2244 → 1.2.0-dev.2246

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.
@@ -1,6 +1,6 @@
1
- import { cloneMessage, lineBreak, message, metavar, text, valueSet } from "./message.js";
1
+ import { cloneMessage, lineBreak, message, metavar, text, value, valueSet } from "./message.js";
2
2
  import { isDerivedValueParser } from "./internal/dependency.js";
3
- import { appendValueHint, createSuggestionMessage, deduplicateSuggestions } from "./suggestion.js";
3
+ import { appendValueHint, deduplicateSuggestions } from "./suggestion.js";
4
4
  import { ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
5
5
 
6
6
  //#region src/valueparser.ts
@@ -112,8 +112,8 @@ function choice(choices, options = {}) {
112
112
  error: formatNumberChoiceError(input, numberChoices, numberChoices, numberInvalidChoice)
113
113
  };
114
114
  },
115
- format(value) {
116
- return Object.is(value, -0) ? "-0" : String(value);
115
+ format(value$1) {
116
+ return Object.is(value$1, -0) ? "-0" : String(value$1);
117
117
  },
118
118
  suggest(prefix) {
119
119
  return numberStrings.filter((valueStr, i) => !Number.isNaN(numberChoices[i]) && valueStr.startsWith(prefix)).map((valueStr) => ({
@@ -151,8 +151,8 @@ function choice(choices, options = {}) {
151
151
  }
152
152
  if (isValidObject) {
153
153
  const obj = stringSuggest;
154
- if (obj.maxDistance !== void 0 && (typeof obj.maxDistance !== "number" || !isFinite(obj.maxDistance))) throw new TypeError(`Expected suggest.maxDistance to be a finite number, but got ${typeof obj.maxDistance}: ${String(obj.maxDistance)}.`);
155
- if (obj.maxSuggestions !== void 0 && (typeof obj.maxSuggestions !== "number" || !isFinite(obj.maxSuggestions))) throw new TypeError(`Expected suggest.maxSuggestions to be a finite number, but got ${typeof obj.maxSuggestions}: ${String(obj.maxSuggestions)}.`);
154
+ if (obj.maxDistance !== void 0 && (typeof obj.maxDistance !== "number" || !Number.isInteger(obj.maxDistance) || obj.maxDistance < 0)) throw new TypeError(`Expected suggest.maxDistance to be a non-negative integer, but got ${typeof obj.maxDistance}: ${String(obj.maxDistance)}.`);
155
+ if (obj.maxSuggestions !== void 0 && (typeof obj.maxSuggestions !== "number" || !Number.isInteger(obj.maxSuggestions) || obj.maxSuggestions < 1)) throw new TypeError(`Expected suggest.maxSuggestions to be a positive integer, but got ${typeof obj.maxSuggestions}: ${String(obj.maxSuggestions)}.`);
156
156
  }
157
157
  }
158
158
  return {
@@ -172,17 +172,17 @@ function choice(choices, options = {}) {
172
172
  value: stringChoices[index]
173
173
  };
174
174
  },
175
- format(value) {
176
- return String(value);
175
+ format(value$1) {
176
+ return String(value$1);
177
177
  },
178
178
  suggest(prefix) {
179
179
  const normalizedPrefix = caseInsensitive ? prefix.toLowerCase() : prefix;
180
- return stringChoices.filter((value) => {
181
- const normalizedValue = caseInsensitive ? value.toLowerCase() : value;
180
+ return stringChoices.filter((value$1) => {
181
+ const normalizedValue = caseInsensitive ? value$1.toLowerCase() : value$1;
182
182
  return normalizedValue.startsWith(normalizedPrefix);
183
- }).map((value) => ({
183
+ }).map((value$1) => ({
184
184
  kind: "literal",
185
- text: value
185
+ text: value$1
186
186
  }));
187
187
  }
188
188
  };
@@ -198,8 +198,8 @@ function choice(choices, options = {}) {
198
198
  * @since 1.0.0
199
199
  */
200
200
  function checkBooleanOption(options, key) {
201
- const value = options?.[key];
202
- if (value !== void 0 && typeof value !== "boolean") throw new TypeError(`Expected ${String(key)} to be a boolean, but got ${typeof value}: ${String(value)}.`);
201
+ const value$1 = options?.[key];
202
+ if (value$1 !== void 0 && typeof value$1 !== "boolean") throw new TypeError(`Expected ${String(key)} to be a boolean, but got ${typeof value$1}: ${String(value$1)}.`);
203
203
  }
204
204
  /**
205
205
  * Validates that an option value, if present, is one of the allowed values.
@@ -215,10 +215,10 @@ function checkBooleanOption(options, key) {
215
215
  * @since 1.0.0
216
216
  */
217
217
  function checkEnumOption(options, key, allowed) {
218
- const value = options?.[key];
219
- if (value !== void 0 && (typeof value !== "string" || !allowed.includes(value))) {
220
- const rendered = typeof value === "string" ? JSON.stringify(value) : typeof value === "symbol" ? value.toString() : String(value);
221
- throw new TypeError(`Expected ${String(key)} to be one of ${allowed.map((v) => JSON.stringify(v)).join(", ")}, but got ${typeof value}: ${rendered}.`);
218
+ const value$1 = options?.[key];
219
+ if (value$1 !== void 0 && (typeof value$1 !== "string" || !allowed.includes(value$1))) {
220
+ const rendered = typeof value$1 === "string" ? JSON.stringify(value$1) : typeof value$1 === "symbol" ? value$1.toString() : String(value$1);
221
+ throw new TypeError(`Expected ${String(key)} to be one of ${allowed.map((v) => JSON.stringify(v)).join(", ")}, but got ${typeof value$1}: ${rendered}.`);
222
222
  }
223
223
  }
224
224
  /**
@@ -279,13 +279,19 @@ function formatStringChoiceError(input, choices, invalidChoice, suggest) {
279
279
  if (typeof suggest === "function") {
280
280
  const hints = suggest(input, choices);
281
281
  if (!Array.isArray(hints) || hints.length === 0) return base;
282
- const suggestionMsg = createSuggestionMessage(hints);
283
- return suggestionMsg.length > 0 ? [
282
+ let suggestionMsg;
283
+ if (hints.length === 1) suggestionMsg = message`Did you mean ${value(hints[0])}?`;
284
+ else {
285
+ const parts = [text("Did you mean one of these?")];
286
+ for (const hint of hints) parts.push(text("\n "), value(hint));
287
+ suggestionMsg = parts;
288
+ }
289
+ return [
284
290
  ...base,
285
291
  lineBreak(),
286
292
  lineBreak(),
287
293
  ...suggestionMsg
288
- ] : base;
294
+ ];
289
295
  }
290
296
  return appendValueHint(base, input, choices, suggest);
291
297
  }
@@ -351,8 +357,8 @@ function string(options = {}) {
351
357
  value: input
352
358
  };
353
359
  },
354
- format(value) {
355
- return value;
360
+ format(value$1) {
361
+ return value$1;
356
362
  }
357
363
  };
358
364
  }
@@ -404,12 +410,12 @@ function keyValue(options = {}) {
404
410
  if (custom != null) return typeof custom === "function" ? custom(error) : custom;
405
411
  return [text("Invalid value: "), ...cloneMessage(error)];
406
412
  }
407
- function validateParts(input, key, value) {
413
+ function validateParts(input, key, value$1) {
408
414
  if (!allowEmptyKey && key === "") return {
409
415
  success: false,
410
416
  error: emptyKeyError(input)
411
417
  };
412
- if (!allowEmptyValue && value === "") return {
418
+ if (!allowEmptyValue && value$1 === "") return {
413
419
  success: false,
414
420
  error: emptyValueError(input)
415
421
  };
@@ -418,7 +424,7 @@ function keyValue(options = {}) {
418
424
  success: false,
419
425
  error: invalidKeyError(keyResult.error)
420
426
  };
421
- const valueResult = valueParser.parse(value);
427
+ const valueResult = valueParser.parse(value$1);
422
428
  if (!valueResult.success) return {
423
429
  success: false,
424
430
  error: invalidValueError(valueResult.error)
@@ -440,14 +446,14 @@ function keyValue(options = {}) {
440
446
  if (!allowEmptyKey && key === "") return false;
441
447
  return partsRoundTrip(key, "");
442
448
  }
443
- function fallbackInput(key, value) {
444
- return `${typeof key === "string" ? key : ""}${separator}${typeof value === "string" ? value : ""}`;
449
+ function fallbackInput(key, value$1) {
450
+ return `${typeof key === "string" ? key : ""}${separator}${typeof value$1 === "string" ? value$1 : ""}`;
445
451
  }
446
- function partsRoundTrip(key, value) {
447
- const input = `${key}${separator}${value}`;
452
+ function partsRoundTrip(key, value$1) {
453
+ const input = `${key}${separator}${value$1}`;
448
454
  const index = findSeparator(input);
449
455
  if (index < 0) return false;
450
- return input.slice(0, index) === key && input.slice(index + separator.length) === value;
456
+ return input.slice(0, index) === key && input.slice(index + separator.length) === value$1;
451
457
  }
452
458
  function validateResultParts(input, keyResult, valueResult) {
453
459
  if (!allowEmptyKey && keyResult.value === "") return {
@@ -497,26 +503,26 @@ function keyValue(options = {}) {
497
503
  }
498
504
  return makeKeyValueSuccess(keyResult, valueResult);
499
505
  }
500
- function validateTuple(value) {
501
- if (!allowEmptyKey && value[0] === "") return {
506
+ function validateTuple(value$1) {
507
+ if (!allowEmptyKey && value$1[0] === "") return {
502
508
  success: false,
503
- error: emptyKeyError(fallbackInput(value[0], value[1]))
509
+ error: emptyKeyError(fallbackInput(value$1[0], value$1[1]))
504
510
  };
505
- if (!allowEmptyValue && value[1] === "") return {
511
+ if (!allowEmptyValue && value$1[1] === "") return {
506
512
  success: false,
507
- error: emptyValueError(fallbackInput(value[0], value[1]))
513
+ error: emptyValueError(fallbackInput(value$1[0], value$1[1]))
508
514
  };
509
- const keyResult = validateValueParserValue(keyParser, value[0]);
515
+ const keyResult = validateValueParserValue(keyParser, value$1[0]);
510
516
  if (!keyResult.success) return {
511
517
  success: false,
512
518
  error: invalidKeyError(keyResult.error)
513
519
  };
514
- const valueResult = validateValueParserValue(valueParser, value[1]);
520
+ const valueResult = validateValueParserValue(valueParser, value$1[1]);
515
521
  if (!valueResult.success) return {
516
522
  success: false,
517
523
  error: invalidValueError(valueResult.error)
518
524
  };
519
- return validateResultParts(fallbackInput(value[0], value[1]), keyResult, valueResult);
525
+ return validateResultParts(fallbackInput(value$1[0], value$1[1]), keyResult, valueResult);
520
526
  }
521
527
  return {
522
528
  mode: "sync",
@@ -529,23 +535,23 @@ function keyValue(options = {}) {
529
535
  error: missingSeparatorError(input)
530
536
  };
531
537
  const key = input.slice(0, index);
532
- const value = input.slice(index + separator.length);
533
- return validateParts(input, key, value);
538
+ const value$1 = input.slice(index + separator.length);
539
+ return validateParts(input, key, value$1);
534
540
  },
535
- format(value) {
536
- return `${keyParser.format(value[0])}${separator}${valueParser.format(value[1])}`;
541
+ format(value$1) {
542
+ return `${keyParser.format(value$1[0])}${separator}${valueParser.format(value$1[1])}`;
537
543
  },
538
- validate(value) {
539
- if (!isKeyValueTuple(value)) return {
544
+ validate(value$1) {
545
+ if (!isKeyValueTuple(value$1)) return {
540
546
  success: false,
541
547
  error: message`Expected a key-value tuple.`
542
548
  };
543
- return validateTuple(value);
549
+ return validateTuple(value$1);
544
550
  },
545
- ...hasNormalize ? { normalize(value) {
546
- if (!isKeyValueTuple(value)) return value;
547
- const normalized = [typeof keyParser.normalize === "function" ? keyParser.normalize(value[0]) : value[0], typeof valueParser.normalize === "function" ? valueParser.normalize(value[1]) : value[1]];
548
- return validateTuple(normalized).success ? normalized : value;
551
+ ...hasNormalize ? { normalize(value$1) {
552
+ if (!isKeyValueTuple(value$1)) return value$1;
553
+ const normalized = [typeof keyParser.normalize === "function" ? keyParser.normalize(value$1[0]) : value$1[0], typeof valueParser.normalize === "function" ? valueParser.normalize(value$1[1]) : value$1[1]];
554
+ return validateTuple(normalized).success ? normalized : value$1;
549
555
  } } : {},
550
556
  ...hasSuggest ? { *suggest(prefix) {
551
557
  const index = findSeparator(prefix);
@@ -569,9 +575,9 @@ function keyValue(options = {}) {
569
575
  }
570
576
  const valuePrefix = prefix.slice(index + separator.length);
571
577
  for (const suggestion of valueParser.suggest(valuePrefix)) {
572
- const value = suggestionTextValue(suggestion);
573
- if (!partsRoundTrip(key, value)) continue;
574
- if (suggestion.kind === "literal" && !validateParts(`${key}${separator}${value}`, key, value).success) continue;
578
+ const value$1 = suggestionTextValue(suggestion);
579
+ if (!partsRoundTrip(key, value$1)) continue;
580
+ if (suggestion.kind === "literal" && !validateParts(`${key}${separator}${value$1}`, key, value$1).success) continue;
575
581
  suggestions.push(prefixKeyValueSuggestion(suggestion, `${key}${separator}`));
576
582
  }
577
583
  }
@@ -584,15 +590,15 @@ function checkKeyValueChildParser(role, parser) {
584
590
  if (parser.mode !== "sync") throw new TypeError(`keyValue() only supports sync ${role} parsers, but an async one was given.`);
585
591
  if (isDerivedValueParser(parser)) throw new TypeError(`keyValue() does not support dependency-derived ${role} parsers (created via deriveFrom() or dependency().derive()); pass the derived parser directly to option() or argument() instead.`);
586
592
  }
587
- function validateValueParserValue(parser, value) {
588
- if (typeof parser.validate === "function") return parser.validate(value);
593
+ function validateValueParserValue(parser, value$1) {
594
+ if (typeof parser.validate === "function") return parser.validate(value$1);
589
595
  let formatted;
590
596
  try {
591
- formatted = parser.format(value);
597
+ formatted = parser.format(value$1);
592
598
  } catch {
593
599
  return {
594
600
  success: true,
595
- value
601
+ value: value$1
596
602
  };
597
603
  }
598
604
  if (typeof formatted !== "string") return {
@@ -601,10 +607,10 @@ function validateValueParserValue(parser, value) {
601
607
  };
602
608
  return parser.parse(formatted);
603
609
  }
604
- function formatValueParserValue(parser, value) {
610
+ function formatValueParserValue(parser, value$1) {
605
611
  let formatted;
606
612
  try {
607
- formatted = parser.format(value);
613
+ formatted = parser.format(value$1);
608
614
  } catch {
609
615
  return {
610
616
  success: true,
@@ -642,8 +648,8 @@ function prefixKeyValueSuggestion(suggestion, prefix, suffix = "") {
642
648
  description: suggestion.description
643
649
  };
644
650
  }
645
- function isKeyValueTuple(value) {
646
- return Array.isArray(value) && value.length === 2 && 0 in value && 1 in value;
651
+ function isKeyValueTuple(value$1) {
652
+ return Array.isArray(value$1) && value$1.length === 2 && 0 in value$1 && 1 in value$1;
647
653
  }
648
654
  function makeKeyValueSuccess(keyResult, valueResult) {
649
655
  const deferredKeys = /* @__PURE__ */ new Map();
@@ -729,22 +735,22 @@ function integer(options) {
729
735
  success: false,
730
736
  error: options.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : message`Expected a valid integer, but got ${input}.`
731
737
  };
732
- const value = BigInt(input);
733
- if (options.min != null && value < options.min) return {
738
+ const value$1 = BigInt(input);
739
+ if (options.min != null && value$1 < options.min) return {
734
740
  success: false,
735
- error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : message`Expected a value greater than or equal to ${text(options.min.toLocaleString("en"))}, but got ${input}.`
741
+ error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value$1, options.min) : options.errors.belowMinimum : message`Expected a value greater than or equal to ${text(options.min.toLocaleString("en"))}, but got ${input}.`
736
742
  };
737
- else if (options.max != null && value > options.max) return {
743
+ else if (options.max != null && value$1 > options.max) return {
738
744
  success: false,
739
- error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, options.max) : options.errors.aboveMaximum : message`Expected a value less than or equal to ${text(options.max.toLocaleString("en"))}, but got ${input}.`
745
+ error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value$1, options.max) : options.errors.aboveMaximum : message`Expected a value less than or equal to ${text(options.max.toLocaleString("en"))}, but got ${input}.`
740
746
  };
741
747
  return {
742
748
  success: true,
743
- value
749
+ value: value$1
744
750
  };
745
751
  },
746
- format(value) {
747
- return value.toString();
752
+ format(value$1) {
753
+ return value$1.toString();
748
754
  }
749
755
  };
750
756
  }
@@ -780,22 +786,22 @@ function integer(options) {
780
786
  return makeUnsafeIntegerError(input);
781
787
  }
782
788
  if (n > maxSafe || n < minSafe) return makeUnsafeIntegerError(input);
783
- const value = Number(input);
784
- if (options?.min != null && value < options.min) return {
789
+ const value$1 = Number(input);
790
+ if (options?.min != null && value$1 < options.min) return {
785
791
  success: false,
786
- error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : message`Expected a value greater than or equal to ${text(options.min.toLocaleString("en"))}, but got ${input}.`
792
+ error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value$1, options.min) : options.errors.belowMinimum : message`Expected a value greater than or equal to ${text(options.min.toLocaleString("en"))}, but got ${input}.`
787
793
  };
788
- else if (options?.max != null && value > options.max) return {
794
+ else if (options?.max != null && value$1 > options.max) return {
789
795
  success: false,
790
- error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, options.max) : options.errors.aboveMaximum : message`Expected a value less than or equal to ${text(options.max.toLocaleString("en"))}, but got ${input}.`
796
+ error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value$1, options.max) : options.errors.aboveMaximum : message`Expected a value less than or equal to ${text(options.max.toLocaleString("en"))}, but got ${input}.`
791
797
  };
792
798
  return {
793
799
  success: true,
794
- value
800
+ value: value$1
795
801
  };
796
802
  },
797
- format(value) {
798
- return value.toString();
803
+ format(value$1) {
804
+ return value$1.toString();
799
805
  }
800
806
  };
801
807
  }
@@ -824,31 +830,31 @@ function float(options = {}) {
824
830
  success: false,
825
831
  error: options.errors?.invalidNumber ? typeof options.errors.invalidNumber === "function" ? options.errors.invalidNumber(i) : options.errors.invalidNumber : message`Expected a valid number, but got ${i}.`
826
832
  });
827
- let value;
833
+ let value$1;
828
834
  const lowerInput = input.toLowerCase();
829
- if (lowerInput === "nan" && options.allowNaN) value = NaN;
830
- else if ((lowerInput === "infinity" || lowerInput === "+infinity") && options.allowInfinity) value = Infinity;
831
- else if (lowerInput === "-infinity" && options.allowInfinity) value = -Infinity;
835
+ if (lowerInput === "nan" && options.allowNaN) value$1 = NaN;
836
+ else if ((lowerInput === "infinity" || lowerInput === "+infinity") && options.allowInfinity) value$1 = Infinity;
837
+ else if (lowerInput === "-infinity" && options.allowInfinity) value$1 = -Infinity;
832
838
  else if (floatRegex.test(input)) {
833
- value = Number(input);
834
- if (!Number.isFinite(value) && !options.allowInfinity) return invalidNumber(input);
835
- if (Number.isNaN(value)) return invalidNumber(input);
839
+ value$1 = Number(input);
840
+ if (!Number.isFinite(value$1) && !options.allowInfinity) return invalidNumber(input);
841
+ if (Number.isNaN(value$1)) return invalidNumber(input);
836
842
  } else return invalidNumber(input);
837
- if (options.min != null && value < options.min) return {
843
+ if (options.min != null && value$1 < options.min) return {
838
844
  success: false,
839
- error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : message`Expected a value greater than or equal to ${text(options.min.toLocaleString("en"))}, but got ${input}.`
845
+ error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value$1, options.min) : options.errors.belowMinimum : message`Expected a value greater than or equal to ${text(options.min.toLocaleString("en"))}, but got ${input}.`
840
846
  };
841
- else if (options.max != null && value > options.max) return {
847
+ else if (options.max != null && value$1 > options.max) return {
842
848
  success: false,
843
- error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, options.max) : options.errors.aboveMaximum : message`Expected a value less than or equal to ${text(options.max.toLocaleString("en"))}, but got ${input}.`
849
+ error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value$1, options.max) : options.errors.aboveMaximum : message`Expected a value less than or equal to ${text(options.max.toLocaleString("en"))}, but got ${input}.`
844
850
  };
845
851
  return {
846
852
  success: true,
847
- value
853
+ value: value$1
848
854
  };
849
855
  },
850
- format(value) {
851
- return value.toString();
856
+ format(value$1) {
857
+ return value$1.toString();
852
858
  }
853
859
  };
854
860
  }
@@ -985,17 +991,17 @@ const BIGINT_FORMAT_UNITS_SI_AS_BINARY = [
985
991
  * Formats a bigint byte count using the most readable unit. Falls back to
986
992
  * `"${value}B"`. Tries exact integers, then 1 and 2 decimal places.
987
993
  */
988
- function formatBigIntBytes(value, units) {
989
- if (value === 0n) return "0B";
990
- const absValue = value < 0n ? -value : value;
994
+ function formatBigIntBytes(value$1, units) {
995
+ if (value$1 === 0n) return "0B";
996
+ const absValue = value$1 < 0n ? -value$1 : value$1;
991
997
  for (const [unit, size] of units) {
992
998
  if (absValue < size) continue;
993
- if (value % size === 0n) {
994
- const v = value / size;
999
+ if (value$1 % size === 0n) {
1000
+ const v = value$1 / size;
995
1001
  const absV = v < 0n ? -v : v;
996
1002
  if (absV >= 1n && absV < 1000n) return `${v}${unit}`;
997
1003
  }
998
- const v100 = value * 100n;
1004
+ const v100 = value$1 * 100n;
999
1005
  if (v100 % size === 0n) {
1000
1006
  const q = v100 / size;
1001
1007
  const absQ = q < 0n ? -q : q;
@@ -1007,7 +1013,7 @@ function formatBigIntBytes(value, units) {
1007
1013
  }
1008
1014
  }
1009
1015
  }
1010
- return `${value}B`;
1016
+ return `${value$1}B`;
1011
1017
  }
1012
1018
  /**
1013
1019
  * Core computation: parses `numStr` as a decimal rational, multiplies by
@@ -1137,10 +1143,10 @@ function fileSize(options = {}) {
1137
1143
  value: bytes
1138
1144
  };
1139
1145
  },
1140
- format(value) {
1146
+ format(value$1) {
1141
1147
  const maxSafe = BigInt(Number.MAX_SAFE_INTEGER);
1142
- if (value >= -maxSafe && value <= maxSafe) return formatWithUnits(Number(value), numberFormatUnits);
1143
- return formatBigIntBytes(value, bigintFormatUnits);
1148
+ if (value$1 >= -maxSafe && value$1 <= maxSafe) return formatWithUnits(Number(value$1), numberFormatUnits);
1149
+ return formatBigIntBytes(value$1, bigintFormatUnits);
1144
1150
  }
1145
1151
  };
1146
1152
  }
@@ -1178,8 +1184,8 @@ function fileSize(options = {}) {
1178
1184
  value: bytes
1179
1185
  };
1180
1186
  },
1181
- format(value) {
1182
- return formatWithUnits(value, formatUnits);
1187
+ format(value$1) {
1188
+ return formatWithUnits(value$1, formatUnits);
1183
1189
  }
1184
1190
  };
1185
1191
  }
@@ -2271,8 +2277,8 @@ function color(options = {}) {
2271
2277
  }
2272
2278
  return invalidFormatError(input);
2273
2279
  },
2274
- format(value) {
2275
- const { r, g, b, a } = value;
2280
+ format(value$1) {
2281
+ const { r, g, b, a } = value$1;
2276
2282
  if (!Number.isInteger(r) || r < 0 || r > 255 || !Number.isInteger(g) || g < 0 || g > 255 || !Number.isInteger(b) || b < 0 || b > 255 || !Number.isFinite(a) || a < 0 || a > 1) throw new RangeError(`Color components out of range: r=${r}, g=${g}, b=${b}, a=${a}.`);
2277
2283
  const aStr = parseFloat(a.toFixed(4));
2278
2284
  if (allowHex) {
@@ -2294,11 +2300,11 @@ function color(options = {}) {
2294
2300
  for (const [name, c] of Object.entries(CSS_NAMED_COLORS)) if (c.r === r && c.g === g && c.b === b && c.a === a) return name;
2295
2301
  throw new RangeError(`No CSS named color matches { r: ${r}, g: ${g}, b: ${b}, a: ${a} }.`);
2296
2302
  },
2297
- normalize(value) {
2298
- if (!Number.isInteger(value.r) || value.r < 0 || value.r > 255 || !Number.isInteger(value.g) || value.g < 0 || value.g > 255 || !Number.isInteger(value.b) || value.b < 0 || value.b > 255 || !Number.isFinite(value.a) || value.a < 0 || value.a > 1) return value;
2299
- const a = Math.round(value.a * 255) / 255;
2300
- return a === value.a ? value : {
2301
- ...value,
2303
+ normalize(value$1) {
2304
+ if (!Number.isInteger(value$1.r) || value$1.r < 0 || value$1.r > 255 || !Number.isInteger(value$1.g) || value$1.g < 0 || value$1.g > 255 || !Number.isInteger(value$1.b) || value$1.b < 0 || value$1.b > 255 || !Number.isFinite(value$1.a) || value$1.a < 0 || value$1.a > 1) return value$1;
2305
+ const a = Math.round(value$1.a * 255) / 255;
2306
+ return a === value$1.a ? value$1 : {
2307
+ ...value$1,
2302
2308
  a
2303
2309
  };
2304
2310
  },
@@ -2403,8 +2409,8 @@ function url(options = {}) {
2403
2409
  value: url$1
2404
2410
  };
2405
2411
  },
2406
- format(value) {
2407
- return value.href;
2412
+ format(value$1) {
2413
+ return value$1.href;
2408
2414
  },
2409
2415
  *suggest(prefix) {
2410
2416
  if (allowedProtocols && prefix.length > 0 && !prefix.includes(":")) for (const protocol of allowedProtocols) {
@@ -2453,8 +2459,8 @@ function locale(options = {}) {
2453
2459
  value: locale$1
2454
2460
  };
2455
2461
  },
2456
- format(value) {
2457
- return value.toString();
2462
+ format(value$1) {
2463
+ return value$1.toString();
2458
2464
  },
2459
2465
  *suggest(prefix) {
2460
2466
  const commonLocales = [
@@ -2783,8 +2789,8 @@ function uuid(options = {}) {
2783
2789
  value: input
2784
2790
  };
2785
2791
  },
2786
- format(value) {
2787
- return value;
2792
+ format(value$1) {
2793
+ return value$1;
2788
2794
  }
2789
2795
  };
2790
2796
  }
@@ -2846,26 +2852,26 @@ function port(options) {
2846
2852
  success: false,
2847
2853
  error: options.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : message`Expected a valid port number, but got ${input}.`
2848
2854
  };
2849
- const value = BigInt(input);
2850
- if (value < min$1) return {
2855
+ const value$1 = BigInt(input);
2856
+ if (value$1 < min$1) return {
2851
2857
  success: false,
2852
- error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, min$1) : options.errors.belowMinimum : message`Expected a port number greater than or equal to ${text(min$1.toLocaleString("en"))}, but got ${input}.`
2858
+ error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value$1, min$1) : options.errors.belowMinimum : message`Expected a port number greater than or equal to ${text(min$1.toLocaleString("en"))}, but got ${input}.`
2853
2859
  };
2854
- if (value > max$1) return {
2860
+ if (value$1 > max$1) return {
2855
2861
  success: false,
2856
- error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, max$1) : options.errors.aboveMaximum : message`Expected a port number less than or equal to ${text(max$1.toLocaleString("en"))}, but got ${input}.`
2862
+ error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value$1, max$1) : options.errors.aboveMaximum : message`Expected a port number less than or equal to ${text(max$1.toLocaleString("en"))}, but got ${input}.`
2857
2863
  };
2858
- if (options.disallowWellKnown && value >= 1n && value <= 1023n) return {
2864
+ if (options.disallowWellKnown && value$1 >= 1n && value$1 <= 1023n) return {
2859
2865
  success: false,
2860
- error: options.errors?.wellKnownNotAllowed ? typeof options.errors.wellKnownNotAllowed === "function" ? options.errors.wellKnownNotAllowed(value) : options.errors.wellKnownNotAllowed : message`Port ${value.toLocaleString("en")} is a well-known port (1-1023) and may require elevated privileges.`
2866
+ error: options.errors?.wellKnownNotAllowed ? typeof options.errors.wellKnownNotAllowed === "function" ? options.errors.wellKnownNotAllowed(value$1) : options.errors.wellKnownNotAllowed : message`Port ${value$1.toLocaleString("en")} is a well-known port (1-1023) and may require elevated privileges.`
2861
2867
  };
2862
2868
  return {
2863
2869
  success: true,
2864
- value
2870
+ value: value$1
2865
2871
  };
2866
2872
  },
2867
- format(value) {
2868
- return value.toString();
2873
+ format(value$1) {
2874
+ return value$1.toString();
2869
2875
  }
2870
2876
  };
2871
2877
  }
@@ -2886,26 +2892,26 @@ function port(options) {
2886
2892
  success: false,
2887
2893
  error: options?.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : message`Expected a valid port number, but got ${input}.`
2888
2894
  };
2889
- const value = Number.parseInt(input);
2890
- if (value < min) return {
2895
+ const value$1 = Number.parseInt(input);
2896
+ if (value$1 < min) return {
2891
2897
  success: false,
2892
- error: options?.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, min) : options.errors.belowMinimum : message`Expected a port number greater than or equal to ${text(min.toLocaleString("en"))}, but got ${input}.`
2898
+ error: options?.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value$1, min) : options.errors.belowMinimum : message`Expected a port number greater than or equal to ${text(min.toLocaleString("en"))}, but got ${input}.`
2893
2899
  };
2894
- if (value > max) return {
2900
+ if (value$1 > max) return {
2895
2901
  success: false,
2896
- error: options?.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, max) : options.errors.aboveMaximum : message`Expected a port number less than or equal to ${text(max.toLocaleString("en"))}, but got ${input}.`
2902
+ error: options?.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value$1, max) : options.errors.aboveMaximum : message`Expected a port number less than or equal to ${text(max.toLocaleString("en"))}, but got ${input}.`
2897
2903
  };
2898
- if (options?.disallowWellKnown && value >= 1 && value <= 1023) return {
2904
+ if (options?.disallowWellKnown && value$1 >= 1 && value$1 <= 1023) return {
2899
2905
  success: false,
2900
- error: options.errors?.wellKnownNotAllowed ? typeof options.errors.wellKnownNotAllowed === "function" ? options.errors.wellKnownNotAllowed(value) : options.errors.wellKnownNotAllowed : message`Port ${value.toLocaleString("en")} is a well-known port (1-1023) and may require elevated privileges.`
2906
+ error: options.errors?.wellKnownNotAllowed ? typeof options.errors.wellKnownNotAllowed === "function" ? options.errors.wellKnownNotAllowed(value$1) : options.errors.wellKnownNotAllowed : message`Port ${value$1.toLocaleString("en")} is a well-known port (1-1023) and may require elevated privileges.`
2901
2907
  };
2902
2908
  return {
2903
2909
  success: true,
2904
- value
2910
+ value: value$1
2905
2911
  };
2906
2912
  },
2907
- format(value) {
2908
- return value.toString();
2913
+ format(value$1) {
2914
+ return value$1.toString();
2909
2915
  }
2910
2916
  };
2911
2917
  }
@@ -3039,8 +3045,8 @@ function ipv4(options) {
3039
3045
  value: ipAddress
3040
3046
  };
3041
3047
  },
3042
- format(value) {
3043
- return value;
3048
+ format(value$1) {
3049
+ return value$1;
3044
3050
  }
3045
3051
  };
3046
3052
  }
@@ -3202,8 +3208,8 @@ function hostname(options) {
3202
3208
  value: input
3203
3209
  };
3204
3210
  },
3205
- format(value) {
3206
- return value;
3211
+ format(value$1) {
3212
+ return value$1;
3207
3213
  }
3208
3214
  };
3209
3215
  }
@@ -3424,9 +3430,9 @@ function email(options) {
3424
3430
  };
3425
3431
  }
3426
3432
  },
3427
- format(value) {
3428
- if (Array.isArray(value)) return value.join(", ");
3429
- return value;
3433
+ format(value$1) {
3434
+ if (Array.isArray(value$1)) return value$1.join(", ");
3435
+ return value$1;
3430
3436
  }
3431
3437
  };
3432
3438
  }
@@ -3659,13 +3665,13 @@ function socketAddress(options) {
3659
3665
  };
3660
3666
  return makeInvalidFormatError(input);
3661
3667
  }
3662
- function isSocketAddressValue(value) {
3663
- return typeof value === "object" && value !== null && "host" in value && typeof value.host === "string" && "port" in value && typeof value.port === "number";
3668
+ function isSocketAddressValue(value$1) {
3669
+ return typeof value$1 === "object" && value$1 !== null && "host" in value$1 && typeof value$1.host === "string" && "port" in value$1 && typeof value$1.port === "number";
3664
3670
  }
3665
- function formatSocketAddressValue(value) {
3666
- const ipv6Host = parseAndNormalizeIpv6(value.host);
3667
- if (separator === ":" && ipv6Host !== null) return `[${ipv6Host}]${separator}${value.port}`;
3668
- return `${value.host}${separator}${value.port}`;
3671
+ function formatSocketAddressValue(value$1) {
3672
+ const ipv6Host = parseAndNormalizeIpv6(value$1.host);
3673
+ if (separator === ":" && ipv6Host !== null) return `[${ipv6Host}]${separator}${value$1.port}`;
3674
+ return `${value$1.host}${separator}${value$1.port}`;
3669
3675
  }
3670
3676
  const parser = {
3671
3677
  mode: "sync",
@@ -3898,16 +3904,16 @@ function socketAddress(options) {
3898
3904
  error: message`Expected a socket address in format ${text(formatExample)}, but got ${input}.`
3899
3905
  };
3900
3906
  },
3901
- format(value) {
3902
- return formatSocketAddressValue(value);
3907
+ format(value$1) {
3908
+ return formatSocketAddressValue(value$1);
3903
3909
  },
3904
- normalize(value) {
3905
- if (!isSocketAddressValue(value)) return value;
3910
+ normalize(value$1) {
3911
+ if (!isSocketAddressValue(value$1)) return value$1;
3906
3912
  try {
3907
- const result = parser.parse(formatSocketAddressValue(value));
3908
- return result.success ? result.value : value;
3913
+ const result = parser.parse(formatSocketAddressValue(value$1));
3914
+ return result.success ? result.value : value$1;
3909
3915
  } catch {
3910
- return value;
3916
+ return value$1;
3911
3917
  }
3912
3918
  }
3913
3919
  };
@@ -4038,8 +4044,8 @@ function portRange(options) {
4038
4044
  };
4039
4045
  }
4040
4046
  },
4041
- format(value) {
4042
- return `${value.start}${separator}${value.end}`;
4047
+ format(value$1) {
4048
+ return `${value$1.start}${separator}${value$1.end}`;
4043
4049
  }
4044
4050
  };
4045
4051
  }
@@ -4117,11 +4123,11 @@ function macAddress(options) {
4117
4123
  return formatted.join(sep);
4118
4124
  }
4119
4125
  let macParsing = false;
4120
- function normalizeMacValue(value, fallback) {
4121
- if (macParsing) return value;
4126
+ function normalizeMacValue(value$1, fallback) {
4127
+ if (macParsing) return value$1;
4122
4128
  macParsing = true;
4123
4129
  try {
4124
- const result = parserObj.parse(value);
4130
+ const result = parserObj.parse(value$1);
4125
4131
  return result.success ? result.value : fallback;
4126
4132
  } catch {
4127
4133
  return fallback;
@@ -4212,13 +4218,13 @@ function macAddress(options) {
4212
4218
  value: joinOctets(octets, finalSeparator)
4213
4219
  };
4214
4220
  },
4215
- format(value) {
4216
- if (typeof value !== "string") return metavar$1;
4217
- return normalizeMacValue(value, value);
4221
+ format(value$1) {
4222
+ if (typeof value$1 !== "string") return metavar$1;
4223
+ return normalizeMacValue(value$1, value$1);
4218
4224
  },
4219
- normalize(value) {
4220
- if (typeof value !== "string") return value;
4221
- return normalizeMacValue(value, value);
4225
+ normalize(value$1) {
4226
+ if (typeof value$1 !== "string") return value$1;
4227
+ return normalizeMacValue(value$1, value$1);
4222
4228
  }
4223
4229
  };
4224
4230
  return parserObj;
@@ -4500,10 +4506,10 @@ function domain(options) {
4500
4506
  value: result
4501
4507
  };
4502
4508
  },
4503
- format(value) {
4504
- if (typeof value !== "string") return metavar$1;
4505
- if (!lowercase) return value;
4506
- return value.split(".").length >= minLabels ? value.toLowerCase() : value;
4509
+ format(value$1) {
4510
+ if (typeof value$1 !== "string") return metavar$1;
4511
+ if (!lowercase) return value$1;
4512
+ return value$1.split(".").length >= minLabels ? value$1.toLowerCase() : value$1;
4507
4513
  }
4508
4514
  };
4509
4515
  if (lowercase) {
@@ -4730,9 +4736,9 @@ function ipv6(options) {
4730
4736
  value: normalized
4731
4737
  };
4732
4738
  },
4733
- format(value) {
4734
- if (typeof value !== "string") return metavar$1;
4735
- return parseAndNormalizeIpv6(value) ?? value;
4739
+ format(value$1) {
4740
+ if (typeof value$1 !== "string") return metavar$1;
4741
+ return parseAndNormalizeIpv6(value$1) ?? value$1;
4736
4742
  }
4737
4743
  };
4738
4744
  let ipv6Parsing = false;
@@ -5116,9 +5122,9 @@ function ip(options) {
5116
5122
  error: msg
5117
5123
  };
5118
5124
  },
5119
- format(value) {
5120
- if (typeof value !== "string") return metavar$1;
5121
- return parseAndNormalizeIpv6(value) ?? value;
5125
+ format(value$1) {
5126
+ if (typeof value$1 !== "string") return metavar$1;
5127
+ return parseAndNormalizeIpv6(value$1) ?? value$1;
5122
5128
  }
5123
5129
  };
5124
5130
  let ipParsing = false;
@@ -5610,16 +5616,16 @@ function cidr(options) {
5610
5616
  };
5611
5617
  let cidrParsing = false;
5612
5618
  Object.defineProperty(cidrParserObj, "format", {
5613
- value(value) {
5614
- if (typeof value !== "object" || value == null || !("address" in value) || !("prefix" in value) || !("version" in value)) return metavar$1;
5615
- if (cidrParsing) return `${value.address}/${value.prefix}`;
5619
+ value(value$1) {
5620
+ if (typeof value$1 !== "object" || value$1 == null || !("address" in value$1) || !("prefix" in value$1) || !("version" in value$1)) return metavar$1;
5621
+ if (cidrParsing) return `${value$1.address}/${value$1.prefix}`;
5616
5622
  cidrParsing = true;
5617
5623
  try {
5618
- const raw = `${value.address}/${value.prefix}`;
5624
+ const raw = `${value$1.address}/${value$1.prefix}`;
5619
5625
  const result = cidrParserObj.parse(raw);
5620
- return result.success && result.value.version === value.version ? `${result.value.address}/${result.value.prefix}` : raw;
5626
+ return result.success && result.value.version === value$1.version ? `${result.value.address}/${result.value.prefix}` : raw;
5621
5627
  } catch {
5622
- return `${value.address}/${value.prefix}`;
5628
+ return `${value$1.address}/${value$1.prefix}`;
5623
5629
  } finally {
5624
5630
  cidrParsing = false;
5625
5631
  }
@@ -5701,10 +5707,10 @@ function semVer(options = {}) {
5701
5707
  value: result
5702
5708
  };
5703
5709
  },
5704
- format(value) {
5705
- let s = `${value.major}.${value.minor}.${value.patch}`;
5706
- if (value.preRelease != null) s += `-${value.preRelease}`;
5707
- if (value.metadata != null) s += `+${value.metadata}`;
5710
+ format(value$1) {
5711
+ let s = `${value$1.major}.${value$1.minor}.${value$1.patch}`;
5712
+ if (value$1.preRelease != null) s += `-${value$1.preRelease}`;
5713
+ if (value$1.metadata != null) s += `+${value$1.metadata}`;
5708
5714
  return s;
5709
5715
  },
5710
5716
  *suggest(prefix) {
@@ -5728,8 +5734,8 @@ function semVer(options = {}) {
5728
5734
  value: canonical
5729
5735
  };
5730
5736
  },
5731
- format(value) {
5732
- return value;
5737
+ format(value$1) {
5738
+ return value$1;
5733
5739
  },
5734
5740
  *suggest(prefix) {
5735
5741
  for (const s of suggestions) if (s.startsWith(prefix)) yield {
@@ -5797,9 +5803,9 @@ function json(options) {
5797
5803
  metavar: metavar$1,
5798
5804
  placeholder,
5799
5805
  parse(input) {
5800
- let value;
5806
+ let value$1;
5801
5807
  try {
5802
- value = JSON.parse(input);
5808
+ value$1 = JSON.parse(input);
5803
5809
  } catch (e) {
5804
5810
  const err = e instanceof Error ? e : new Error(String(e));
5805
5811
  const error = invalidJsonError instanceof Function ? invalidJsonError(input) : invalidJsonError ?? [text(`Not a valid JSON: ${err.message}`)];
@@ -5808,7 +5814,7 @@ function json(options) {
5808
5814
  error
5809
5815
  };
5810
5816
  }
5811
- const nonFinite = findNonFiniteNumber(value);
5817
+ const nonFinite = findNonFiniteNumber(value$1);
5812
5818
  if (nonFinite !== void 0) {
5813
5819
  const error = invalidJsonError instanceof Function ? invalidJsonError(input) : invalidJsonError ?? [text(`Not a valid JSON: number out of range.`)];
5814
5820
  return {
@@ -5817,9 +5823,9 @@ function json(options) {
5817
5823
  };
5818
5824
  }
5819
5825
  if (rootType != null) {
5820
- const actual = jsonTypeOf(value);
5826
+ const actual = jsonTypeOf(value$1);
5821
5827
  if (actual !== rootType) {
5822
- const error = invalidRootTypeError instanceof Function ? invalidRootTypeError(value, rootType) : invalidRootTypeError ?? [text(`Expected JSON ${rootType}, but got ${actual}.`)];
5828
+ const error = invalidRootTypeError instanceof Function ? invalidRootTypeError(value$1, rootType) : invalidRootTypeError ?? [text(`Expected JSON ${rootType}, but got ${actual}.`)];
5823
5829
  return {
5824
5830
  success: false,
5825
5831
  error
@@ -5828,20 +5834,20 @@ function json(options) {
5828
5834
  }
5829
5835
  return {
5830
5836
  success: true,
5831
- value
5837
+ value: value$1
5832
5838
  };
5833
5839
  },
5834
- format(value) {
5835
- const nonFinite = findNonFiniteNumber(value);
5840
+ format(value$1) {
5841
+ const nonFinite = findNonFiniteNumber(value$1);
5836
5842
  if (nonFinite !== void 0) throw new TypeError(`Expected a finite JSON number, but got ${String(nonFinite)}.`);
5837
- return JSON.stringify(value);
5843
+ return JSON.stringify(value$1);
5838
5844
  }
5839
5845
  };
5840
5846
  }
5841
- function jsonTypeOf(value) {
5842
- if (value === null) return "null";
5843
- if (Array.isArray(value)) return "array";
5844
- return typeof value;
5847
+ function jsonTypeOf(value$1) {
5848
+ if (value$1 === null) return "null";
5849
+ if (Array.isArray(value$1)) return "array";
5850
+ return typeof value$1;
5845
5851
  }
5846
5852
  /**
5847
5853
  * Finds the first non-finite number (`NaN`, `Infinity`, or `-Infinity`)
@@ -5858,17 +5864,17 @@ function findNonFiniteNumber(root) {
5858
5864
  const stack = [root];
5859
5865
  const seen = /* @__PURE__ */ new Set();
5860
5866
  while (stack.length > 0) {
5861
- const value = stack.pop();
5862
- if (typeof value === "number") {
5863
- if (!Number.isFinite(value)) return value;
5864
- } else if (Array.isArray(value)) {
5865
- if (seen.has(value)) continue;
5866
- seen.add(value);
5867
- for (const item of value) stack.push(item);
5868
- } else if (value !== null && typeof value === "object") {
5869
- if (seen.has(value)) continue;
5870
- seen.add(value);
5871
- for (const item of Object.values(value)) stack.push(item);
5867
+ const value$1 = stack.pop();
5868
+ if (typeof value$1 === "number") {
5869
+ if (!Number.isFinite(value$1)) return value$1;
5870
+ } else if (Array.isArray(value$1)) {
5871
+ if (seen.has(value$1)) continue;
5872
+ seen.add(value$1);
5873
+ for (const item of value$1) stack.push(item);
5874
+ } else if (value$1 !== null && typeof value$1 === "object") {
5875
+ if (seen.has(value$1)) continue;
5876
+ seen.add(value$1);
5877
+ for (const item of Object.values(value$1)) stack.push(item);
5872
5878
  }
5873
5879
  }
5874
5880
  return void 0;
@@ -6001,21 +6007,21 @@ function cron(options = {}) {
6001
6007
  ...years ? { year: "1970" } : {}
6002
6008
  },
6003
6009
  parse: parseCron,
6004
- format(value) {
6010
+ format(value$1) {
6005
6011
  return [
6006
- ...seconds ? [value.second ?? "0"] : [],
6007
- value.minute,
6008
- value.hour,
6009
- value.dayOfMonth,
6010
- value.month,
6011
- value.dayOfWeek,
6012
- ...years ? [value.year ?? "1970"] : []
6012
+ ...seconds ? [value$1.second ?? "0"] : [],
6013
+ value$1.minute,
6014
+ value$1.hour,
6015
+ value$1.dayOfMonth,
6016
+ value$1.month,
6017
+ value$1.dayOfWeek,
6018
+ ...years ? [value$1.year ?? "1970"] : []
6013
6019
  ].join(" ");
6014
6020
  },
6015
- validate(value) {
6016
- if (seconds && value.second == null || years && value.year == null) return makeError(this.format(value));
6017
- if (!seconds && value.second != null || !years && value.year != null) return makeError(this.format(value));
6018
- const result = parseCron(this.format(value));
6021
+ validate(value$1) {
6022
+ if (seconds && value$1.second == null || years && value$1.year == null) return makeError(this.format(value$1));
6023
+ if (!seconds && value$1.second != null || !years && value$1.year != null) return makeError(this.format(value$1));
6024
+ const result = parseCron(this.format(value$1));
6019
6025
  return result.success ? {
6020
6026
  success: true,
6021
6027
  value: result.value
@@ -6047,10 +6053,10 @@ function isQuartzCronField(field, spec, quartz) {
6047
6053
  }
6048
6054
  return false;
6049
6055
  }
6050
- function parseQuartzDayOfWeekSuffixValue(value) {
6051
- if (/^[1-7]$/u.test(value)) return true;
6052
- if (!/^[A-Z]{3}$/u.test(value)) return false;
6053
- return CRON_DAY_NAMES.has(value);
6056
+ function parseQuartzDayOfWeekSuffixValue(value$1) {
6057
+ if (/^[1-7]$/u.test(value$1)) return true;
6058
+ if (!/^[A-Z]{3}$/u.test(value$1)) return false;
6059
+ return CRON_DAY_NAMES.has(value$1);
6054
6060
  }
6055
6061
  function isValidCronFieldPart(part, spec) {
6056
6062
  const stepParts = part.split("/");
@@ -6071,18 +6077,18 @@ function isValidCronFieldPart(part, spec) {
6071
6077
  function isPositiveCronStep(step) {
6072
6078
  return /^\d+$/u.test(step) && Number.parseInt(step, 10) > 0;
6073
6079
  }
6074
- function isCronValueInRange(value, spec) {
6075
- return parseCronValue(value, spec) !== void 0;
6080
+ function isCronValueInRange(value$1, spec) {
6081
+ return parseCronValue(value$1, spec) !== void 0;
6076
6082
  }
6077
6083
  function parseCronRangeEnd(start, end, spec) {
6078
6084
  if (spec.kind === "dayOfWeek" && start.toUpperCase() !== "SUN" && (end.toUpperCase() === "SUN" || end === "0")) return 7;
6079
6085
  return parseCronValue(end, spec);
6080
6086
  }
6081
- function parseCronValue(value, spec) {
6082
- const named = spec.names?.get(value.toUpperCase());
6087
+ function parseCronValue(value$1, spec) {
6088
+ const named = spec.names?.get(value$1.toUpperCase());
6083
6089
  if (named !== void 0) return named;
6084
- if (!/^\d+$/u.test(value)) return void 0;
6085
- const number = Number.parseInt(value, 10);
6090
+ if (!/^\d+$/u.test(value$1)) return void 0;
6091
+ const number = Number.parseInt(value$1, 10);
6086
6092
  return number >= spec.min && number <= spec.max ? number : void 0;
6087
6093
  }
6088
6094
  /**
@@ -6113,14 +6119,14 @@ function firstOf(...rawArgs) {
6113
6119
  }
6114
6120
  const metavar$1 = options.metavar ?? parsers.map((parser) => parser.metavar).join("|");
6115
6121
  ensureNonEmptyString(metavar$1);
6116
- const mergedChoices = parsers.every((parser) => parser.choices != null) ? Object.freeze(parsers.flatMap((parser) => [...parser.choices]).filter((value, index, all) => all.findIndex((other) => Object.is(other, value)) === index)) : void 0;
6117
- function findOwner(value) {
6122
+ const mergedChoices = parsers.every((parser) => parser.choices != null) ? Object.freeze(parsers.flatMap((parser) => [...parser.choices]).filter((value$1, index, all) => all.findIndex((other) => Object.is(other, value$1)) === index)) : void 0;
6123
+ function findOwner(value$1) {
6118
6124
  let canonicalizing;
6119
6125
  for (const parser of parsers) {
6120
6126
  if (typeof parser.validate === "function") {
6121
6127
  let result$1;
6122
6128
  try {
6123
- result$1 = parser.validate(value);
6129
+ result$1 = parser.validate(value$1);
6124
6130
  } catch {
6125
6131
  continue;
6126
6132
  }
@@ -6132,18 +6138,18 @@ function firstOf(...rawArgs) {
6132
6138
  }
6133
6139
  let formatted;
6134
6140
  try {
6135
- formatted = parser.format(value);
6141
+ formatted = parser.format(value$1);
6136
6142
  } catch {
6137
6143
  continue;
6138
6144
  }
6139
6145
  if (typeof formatted !== "string") continue;
6140
6146
  const result = parser.parse(formatted);
6141
6147
  if (!result.success) continue;
6142
- if (ownsRoundTrippedValue(parser, result.value, value)) return {
6148
+ if (ownsRoundTrippedValue(parser, result.value, value$1)) return {
6143
6149
  parser,
6144
6150
  result
6145
6151
  };
6146
- if (canonicalizing == null && value !== null && typeof value !== "object" && typeof result.value === typeof value) canonicalizing = {
6152
+ if (canonicalizing == null && value$1 !== null && typeof value$1 !== "object" && typeof result.value === typeof value$1) canonicalizing = {
6147
6153
  parser,
6148
6154
  result
6149
6155
  };
@@ -6170,7 +6176,7 @@ function firstOf(...rawArgs) {
6170
6176
  error: noMatch == null ? firstOfNoMatchError(errors) : typeof noMatch === "function" ? noMatch(input, errors) : noMatch
6171
6177
  };
6172
6178
  },
6173
- format(value) {
6179
+ format(value$1) {
6174
6180
  let canonicalizing;
6175
6181
  let fallback;
6176
6182
  let firstError;
@@ -6178,7 +6184,7 @@ function firstOf(...rawArgs) {
6178
6184
  for (const parser of parsers) {
6179
6185
  let formatted;
6180
6186
  try {
6181
- formatted = parser.format(value);
6187
+ formatted = parser.format(value$1);
6182
6188
  } catch (e) {
6183
6189
  if (!hasError) {
6184
6190
  firstError = e;
@@ -6190,14 +6196,14 @@ function firstOf(...rawArgs) {
6190
6196
  if (typeof parser.validate === "function") {
6191
6197
  let owned = false;
6192
6198
  try {
6193
- owned = parser.validate(value).success;
6199
+ owned = parser.validate(value$1).success;
6194
6200
  } catch {}
6195
6201
  if (owned) return formatted;
6196
6202
  } else {
6197
6203
  const result = parser.parse(formatted);
6198
6204
  if (result.success) {
6199
- if (ownsRoundTrippedValue(parser, result.value, value)) return formatted;
6200
- if (canonicalizing == null && value !== null && typeof value !== "object" && typeof result.value === typeof value) canonicalizing = formatted;
6205
+ if (ownsRoundTrippedValue(parser, result.value, value$1)) return formatted;
6206
+ if (canonicalizing == null && value$1 !== null && typeof value$1 !== "object" && typeof result.value === typeof value$1) canonicalizing = formatted;
6201
6207
  }
6202
6208
  }
6203
6209
  fallback ??= formatted;
@@ -6207,18 +6213,18 @@ function firstOf(...rawArgs) {
6207
6213
  if (hasError) throw firstError;
6208
6214
  throw new TypeError("No constituent parser could format the given value.");
6209
6215
  },
6210
- validate(value) {
6211
- const owner = findOwner(value);
6216
+ validate(value$1) {
6217
+ const owner = findOwner(value$1);
6212
6218
  if (owner == null) return {
6213
6219
  success: false,
6214
6220
  error: message`Expected a value matching ${metavar(metavar$1)}.`
6215
6221
  };
6216
6222
  return owner.result;
6217
6223
  },
6218
- ...hasNormalize ? { normalize(value) {
6219
- const owner = findOwner(value);
6220
- if (owner == null || typeof owner.parser.normalize !== "function") return value;
6221
- return owner.parser.normalize(value);
6224
+ ...hasNormalize ? { normalize(value$1) {
6225
+ const owner = findOwner(value$1);
6226
+ if (owner == null || typeof owner.parser.normalize !== "function") return value$1;
6227
+ return owner.parser.normalize(value$1);
6222
6228
  } } : {},
6223
6229
  ...hasSuggest ? { *suggest(prefix) {
6224
6230
  const collected = [];
@@ -6261,19 +6267,19 @@ function firstOfNoMatchError(errors) {
6261
6267
  * canonicalization from data loss (e.g. a lossy `color()` `format()`
6262
6268
  * dropping fields that belong to a later, more faithful constituent).
6263
6269
  */
6264
- function ownsRoundTrippedValue(parser, roundTripped, value) {
6265
- if (valuesEqual(roundTripped, value)) return true;
6270
+ function ownsRoundTrippedValue(parser, roundTripped, value$1) {
6271
+ if (valuesEqual(roundTripped, value$1)) return true;
6266
6272
  if (typeof parser.normalize === "function") {
6267
6273
  let normalized;
6268
6274
  try {
6269
- normalized = parser.normalize(value);
6275
+ normalized = parser.normalize(value$1);
6270
6276
  } catch {
6271
6277
  return false;
6272
6278
  }
6273
6279
  if (valuesEqual(roundTripped, normalized)) return true;
6274
6280
  }
6275
- if (typeof value === "string" && typeof roundTripped === "string") return value.toLowerCase() === roundTripped.toLowerCase();
6276
- if (typeof value === "number" && typeof roundTripped === "number") return value === roundTripped;
6281
+ if (typeof value$1 === "string" && typeof roundTripped === "string") return value$1.toLowerCase() === roundTripped.toLowerCase();
6282
+ if (typeof value$1 === "number" && typeof roundTripped === "number") return value$1 === roundTripped;
6277
6283
  return false;
6278
6284
  }
6279
6285
  /**
@@ -6317,9 +6323,9 @@ function valuesEqual(a, b) {
6317
6323
  * Checks whether an object provides a `toString()` implementation other
6318
6324
  * than the generic `Object.prototype.toString`.
6319
6325
  */
6320
- function hasCustomToString(value) {
6326
+ function hasCustomToString(value$1) {
6321
6327
  try {
6322
- const toString = value.toString;
6328
+ const toString = value$1.toString;
6323
6329
  return typeof toString === "function" && toString !== Object.prototype.toString;
6324
6330
  } catch {
6325
6331
  return false;