securewithtrace 0.34.0 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1782 -969
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b2) => (typeof require !== "undefined" ? require : a)[b2]
9
+ get: (a2, b) => (typeof require !== "undefined" ? require : a2)[b]
10
10
  }) : x)(function(x) {
11
11
  if (typeof require !== "undefined") return require.apply(this, arguments);
12
12
  throw Error('Dynamic require of "' + x + '" is not supported');
@@ -236,8 +236,8 @@ var require_help = __commonJS({
236
236
  visibleCommands.push(helpCommand);
237
237
  }
238
238
  if (this.sortSubcommands) {
239
- visibleCommands.sort((a, b2) => {
240
- return a.name().localeCompare(b2.name());
239
+ visibleCommands.sort((a2, b) => {
240
+ return a2.name().localeCompare(b.name());
241
241
  });
242
242
  }
243
243
  return visibleCommands;
@@ -249,11 +249,11 @@ var require_help = __commonJS({
249
249
  * @param {Option} b
250
250
  * @returns {number}
251
251
  */
252
- compareOptions(a, b2) {
252
+ compareOptions(a2, b) {
253
253
  const getSortKey = (option) => {
254
254
  return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
255
255
  };
256
- return getSortKey(a).localeCompare(getSortKey(b2));
256
+ return getSortKey(a2).localeCompare(getSortKey(b));
257
257
  }
258
258
  /**
259
259
  * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
@@ -1076,38 +1076,38 @@ var require_suggestSimilar = __commonJS({
1076
1076
  "../../node_modules/.bun/commander@13.1.0/node_modules/commander/lib/suggestSimilar.js"(exports) {
1077
1077
  "use strict";
1078
1078
  var maxDistance = 3;
1079
- function editDistance(a, b2) {
1080
- if (Math.abs(a.length - b2.length) > maxDistance)
1081
- return Math.max(a.length, b2.length);
1082
- const d2 = [];
1083
- for (let i = 0; i <= a.length; i++) {
1084
- d2[i] = [i];
1085
- }
1086
- for (let j3 = 0; j3 <= b2.length; j3++) {
1087
- d2[0][j3] = j3;
1088
- }
1089
- for (let j3 = 1; j3 <= b2.length; j3++) {
1090
- for (let i = 1; i <= a.length; i++) {
1079
+ function editDistance(a2, b) {
1080
+ if (Math.abs(a2.length - b.length) > maxDistance)
1081
+ return Math.max(a2.length, b.length);
1082
+ const d = [];
1083
+ for (let i2 = 0; i2 <= a2.length; i2++) {
1084
+ d[i2] = [i2];
1085
+ }
1086
+ for (let j = 0; j <= b.length; j++) {
1087
+ d[0][j] = j;
1088
+ }
1089
+ for (let j = 1; j <= b.length; j++) {
1090
+ for (let i2 = 1; i2 <= a2.length; i2++) {
1091
1091
  let cost = 1;
1092
- if (a[i - 1] === b2[j3 - 1]) {
1092
+ if (a2[i2 - 1] === b[j - 1]) {
1093
1093
  cost = 0;
1094
1094
  } else {
1095
1095
  cost = 1;
1096
1096
  }
1097
- d2[i][j3] = Math.min(
1098
- d2[i - 1][j3] + 1,
1097
+ d[i2][j] = Math.min(
1098
+ d[i2 - 1][j] + 1,
1099
1099
  // deletion
1100
- d2[i][j3 - 1] + 1,
1100
+ d[i2][j - 1] + 1,
1101
1101
  // insertion
1102
- d2[i - 1][j3 - 1] + cost
1102
+ d[i2 - 1][j - 1] + cost
1103
1103
  // substitution
1104
1104
  );
1105
- if (i > 1 && j3 > 1 && a[i - 1] === b2[j3 - 2] && a[i - 2] === b2[j3 - 1]) {
1106
- d2[i][j3] = Math.min(d2[i][j3], d2[i - 2][j3 - 2] + 1);
1105
+ if (i2 > 1 && j > 1 && a2[i2 - 1] === b[j - 2] && a2[i2 - 2] === b[j - 1]) {
1106
+ d[i2][j] = Math.min(d[i2][j], d[i2 - 2][j - 2] + 1);
1107
1107
  }
1108
1108
  }
1109
1109
  }
1110
- return d2[a.length][b2.length];
1110
+ return d[a2.length][b.length];
1111
1111
  }
1112
1112
  function suggestSimilar(word, candidates) {
1113
1113
  if (!candidates || candidates.length === 0) return "";
@@ -1134,7 +1134,7 @@ var require_suggestSimilar = __commonJS({
1134
1134
  }
1135
1135
  }
1136
1136
  });
1137
- similar.sort((a, b2) => a.localeCompare(b2));
1137
+ similar.sort((a2, b) => a2.localeCompare(b));
1138
1138
  if (searchingOptions) {
1139
1139
  similar = similar.map((candidate) => `--${candidate}`);
1140
1140
  }
@@ -1773,8 +1773,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1773
1773
  } else if (fn instanceof RegExp) {
1774
1774
  const regex = fn;
1775
1775
  fn = (val, def) => {
1776
- const m = regex.exec(val);
1777
- return m ? m[0] : def;
1776
+ const m2 = regex.exec(val);
1777
+ return m2 ? m2[0] : def;
1778
1778
  };
1779
1779
  option.default(defaultValue).argParser(fn);
1780
1780
  } else {
@@ -2316,8 +2316,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2316
2316
  * @private
2317
2317
  */
2318
2318
  _checkNumberOfArguments() {
2319
- this.registeredArguments.forEach((arg, i) => {
2320
- if (arg.required && this.args[i] == null) {
2319
+ this.registeredArguments.forEach((arg, i2) => {
2320
+ if (arg.required && this.args[i2] == null) {
2321
2321
  this.missingArgument(arg.name());
2322
2322
  }
2323
2323
  });
@@ -2355,8 +2355,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2355
2355
  if (index < this.args.length) {
2356
2356
  value = this.args.slice(index);
2357
2357
  if (declaredArg.parseArg) {
2358
- value = value.reduce((processed, v2) => {
2359
- return myParseArg(declaredArg, v2, processed);
2358
+ value = value.reduce((processed, v) => {
2359
+ return myParseArg(declaredArg, v, processed);
2360
2360
  }, declaredArg.defaultValue);
2361
2361
  }
2362
2362
  } else if (value === void 0) {
@@ -2697,8 +2697,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2697
2697
  if (this._storeOptionsAsProperties) {
2698
2698
  const result = {};
2699
2699
  const len = this.options.length;
2700
- for (let i = 0; i < len; i++) {
2701
- const key = this.options[i].attributeName();
2700
+ for (let i2 = 0; i2 < len; i2++) {
2701
+ const key = this.options[i2].attributeName();
2702
2702
  result[key] = key === this._versionOptionName ? this._version : this[key];
2703
2703
  }
2704
2704
  return result;
@@ -3342,7 +3342,7 @@ var require_src = __commonJS({
3342
3342
  var ESC2 = "\x1B";
3343
3343
  var CSI2 = `${ESC2}[`;
3344
3344
  var beep = "\x07";
3345
- var cursor = {
3345
+ var cursor3 = {
3346
3346
  to(x, y) {
3347
3347
  if (!y) return `${CSI2}${x + 1}G`;
3348
3348
  return `${CSI2}${y + 1};${x + 1}H`;
@@ -3371,7 +3371,7 @@ var require_src = __commonJS({
3371
3371
  up: (count = 1) => `${CSI2}S`.repeat(count),
3372
3372
  down: (count = 1) => `${CSI2}T`.repeat(count)
3373
3373
  };
3374
- var erase = {
3374
+ var erase3 = {
3375
3375
  screen: `${CSI2}2J`,
3376
3376
  up: (count = 1) => `${CSI2}1J`.repeat(count),
3377
3377
  down: (count = 1) => `${CSI2}J`.repeat(count),
@@ -3380,14 +3380,14 @@ var require_src = __commonJS({
3380
3380
  lineStart: `${CSI2}1K`,
3381
3381
  lines(count) {
3382
3382
  let clear = "";
3383
- for (let i = 0; i < count; i++)
3384
- clear += this.line + (i < count - 1 ? cursor.up() : "");
3383
+ for (let i2 = 0; i2 < count; i2++)
3384
+ clear += this.line + (i2 < count - 1 ? cursor3.up() : "");
3385
3385
  if (count)
3386
- clear += cursor.left;
3386
+ clear += cursor3.left;
3387
3387
  return clear;
3388
3388
  }
3389
3389
  };
3390
- module.exports = { cursor, scroll, erase, beep };
3390
+ module.exports = { cursor: cursor3, scroll, erase: erase3, beep };
3391
3391
  }
3392
3392
  });
3393
3393
 
@@ -3427,16 +3427,16 @@ var util;
3427
3427
  return obj;
3428
3428
  };
3429
3429
  util2.getValidEnumValues = (obj) => {
3430
- const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number");
3430
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
3431
3431
  const filtered = {};
3432
- for (const k2 of validKeys) {
3433
- filtered[k2] = obj[k2];
3432
+ for (const k of validKeys) {
3433
+ filtered[k] = obj[k];
3434
3434
  }
3435
3435
  return util2.objectValues(filtered);
3436
3436
  };
3437
3437
  util2.objectValues = (obj) => {
3438
- return util2.objectKeys(obj).map(function(e2) {
3439
- return obj[e2];
3438
+ return util2.objectKeys(obj).map(function(e) {
3439
+ return obj[e];
3440
3440
  });
3441
3441
  };
3442
3442
  util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object2) => {
@@ -3500,8 +3500,8 @@ var ZodParsedType = util.arrayToEnum([
3500
3500
  "set"
3501
3501
  ]);
3502
3502
  var getParsedType = (data) => {
3503
- const t = typeof data;
3504
- switch (t) {
3503
+ const t2 = typeof data;
3504
+ switch (t2) {
3505
3505
  case "undefined":
3506
3506
  return ZodParsedType.undefined;
3507
3507
  case "string":
@@ -3601,10 +3601,10 @@ var ZodError = class extends Error {
3601
3601
  fieldErrors._errors.push(mapper(issue2));
3602
3602
  } else {
3603
3603
  let curr = fieldErrors;
3604
- let i = 0;
3605
- while (i < issue2.path.length) {
3606
- const el = issue2.path[i];
3607
- const terminal = i === issue2.path.length - 1;
3604
+ let i2 = 0;
3605
+ while (i2 < issue2.path.length) {
3606
+ const el = issue2.path[i2];
3607
+ const terminal = i2 === issue2.path.length - 1;
3608
3608
  if (!terminal) {
3609
3609
  curr[el] = curr[el] || { _errors: [] };
3610
3610
  } else {
@@ -3612,7 +3612,7 @@ var ZodError = class extends Error {
3612
3612
  curr[el]._errors.push(mapper(issue2));
3613
3613
  }
3614
3614
  curr = curr[el];
3615
- i++;
3615
+ i2++;
3616
3616
  }
3617
3617
  }
3618
3618
  }
@@ -3763,7 +3763,7 @@ var makeIssue = (params) => {
3763
3763
  path: fullPath
3764
3764
  };
3765
3765
  let errorMessage = "";
3766
- const maps = errorMaps.filter((m) => !!m).slice().reverse();
3766
+ const maps = errorMaps.filter((m2) => !!m2).slice().reverse();
3767
3767
  for (const map2 of maps) {
3768
3768
  errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message;
3769
3769
  }
@@ -5314,14 +5314,14 @@ var ZodArray = class _ZodArray extends ZodType {
5314
5314
  }
5315
5315
  }
5316
5316
  if (ctx.common.async) {
5317
- return Promise.all([...ctx.data].map((item, i) => {
5318
- return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
5317
+ return Promise.all([...ctx.data].map((item, i2) => {
5318
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2));
5319
5319
  })).then((result2) => {
5320
5320
  return ParseStatus.mergeArray(status, result2);
5321
5321
  });
5322
5322
  }
5323
- const result = [...ctx.data].map((item, i) => {
5324
- return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
5323
+ const result = [...ctx.data].map((item, i2) => {
5324
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2));
5325
5325
  });
5326
5326
  return ParseStatus.mergeArray(status, result);
5327
5327
  }
@@ -5911,17 +5911,17 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
5911
5911
  });
5912
5912
  }
5913
5913
  };
5914
- function mergeValues(a, b2) {
5915
- const aType = getParsedType(a);
5916
- const bType = getParsedType(b2);
5917
- if (a === b2) {
5918
- return { valid: true, data: a };
5914
+ function mergeValues(a2, b) {
5915
+ const aType = getParsedType(a2);
5916
+ const bType = getParsedType(b);
5917
+ if (a2 === b) {
5918
+ return { valid: true, data: a2 };
5919
5919
  } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
5920
- const bKeys = util.objectKeys(b2);
5921
- const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
5922
- const newObj = { ...a, ...b2 };
5920
+ const bKeys = util.objectKeys(b);
5921
+ const sharedKeys = util.objectKeys(a2).filter((key) => bKeys.indexOf(key) !== -1);
5922
+ const newObj = { ...a2, ...b };
5923
5923
  for (const key of sharedKeys) {
5924
- const sharedValue = mergeValues(a[key], b2[key]);
5924
+ const sharedValue = mergeValues(a2[key], b[key]);
5925
5925
  if (!sharedValue.valid) {
5926
5926
  return { valid: false };
5927
5927
  }
@@ -5929,13 +5929,13 @@ function mergeValues(a, b2) {
5929
5929
  }
5930
5930
  return { valid: true, data: newObj };
5931
5931
  } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
5932
- if (a.length !== b2.length) {
5932
+ if (a2.length !== b.length) {
5933
5933
  return { valid: false };
5934
5934
  }
5935
5935
  const newArray = [];
5936
- for (let index = 0; index < a.length; index++) {
5937
- const itemA = a[index];
5938
- const itemB = b2[index];
5936
+ for (let index = 0; index < a2.length; index++) {
5937
+ const itemA = a2[index];
5938
+ const itemB = b[index];
5939
5939
  const sharedValue = mergeValues(itemA, itemB);
5940
5940
  if (!sharedValue.valid) {
5941
5941
  return { valid: false };
@@ -5943,8 +5943,8 @@ function mergeValues(a, b2) {
5943
5943
  newArray.push(sharedValue.data);
5944
5944
  }
5945
5945
  return { valid: true, data: newArray };
5946
- } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b2) {
5947
- return { valid: true, data: a };
5946
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a2 === +b) {
5947
+ return { valid: true, data: a2 };
5948
5948
  } else {
5949
5949
  return { valid: false };
5950
5950
  }
@@ -6237,7 +6237,7 @@ var ZodSet = class _ZodSet extends ZodType {
6237
6237
  }
6238
6238
  return { status: status.value, value: parsedSet };
6239
6239
  }
6240
- const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
6240
+ const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2)));
6241
6241
  if (ctx.common.async) {
6242
6242
  return Promise.all(elements).then((elements2) => finalizeSet(elements2));
6243
6243
  } else {
@@ -6322,29 +6322,29 @@ var ZodFunction = class _ZodFunction extends ZodType {
6322
6322
  const params = { errorMap: ctx.common.contextualErrorMap };
6323
6323
  const fn = ctx.data;
6324
6324
  if (this._def.returns instanceof ZodPromise) {
6325
- const me2 = this;
6325
+ const me = this;
6326
6326
  return OK(async function(...args) {
6327
6327
  const error48 = new ZodError([]);
6328
- const parsedArgs = await me2._def.args.parseAsync(args, params).catch((e2) => {
6329
- error48.addIssue(makeArgsIssue(args, e2));
6328
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
6329
+ error48.addIssue(makeArgsIssue(args, e));
6330
6330
  throw error48;
6331
6331
  });
6332
6332
  const result = await Reflect.apply(fn, this, parsedArgs);
6333
- const parsedReturns = await me2._def.returns._def.type.parseAsync(result, params).catch((e2) => {
6334
- error48.addIssue(makeReturnsIssue(result, e2));
6333
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
6334
+ error48.addIssue(makeReturnsIssue(result, e));
6335
6335
  throw error48;
6336
6336
  });
6337
6337
  return parsedReturns;
6338
6338
  });
6339
6339
  } else {
6340
- const me2 = this;
6340
+ const me = this;
6341
6341
  return OK(function(...args) {
6342
- const parsedArgs = me2._def.args.safeParse(args, params);
6342
+ const parsedArgs = me._def.args.safeParse(args, params);
6343
6343
  if (!parsedArgs.success) {
6344
6344
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
6345
6345
  }
6346
6346
  const result = Reflect.apply(fn, this, parsedArgs.data);
6347
- const parsedReturns = me2._def.returns.safeParse(result, params);
6347
+ const parsedReturns = me._def.returns.safeParse(result, params);
6348
6348
  if (!parsedReturns.success) {
6349
6349
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
6350
6350
  }
@@ -6879,10 +6879,10 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
6879
6879
  }
6880
6880
  }
6881
6881
  }
6882
- static create(a, b2) {
6882
+ static create(a2, b) {
6883
6883
  return new _ZodPipeline({
6884
- in: a,
6885
- out: b2,
6884
+ in: a2,
6885
+ out: b,
6886
6886
  typeName: ZodFirstPartyTypeKind.ZodPipeline
6887
6887
  });
6888
6888
  }
@@ -6908,10 +6908,10 @@ var custom = (check2, params = {}, fatal) => {
6908
6908
  return ZodAny.create().superRefine((data, ctx) => {
6909
6909
  var _a2, _b;
6910
6910
  if (!check2(data)) {
6911
- const p2 = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
6912
- const _fatal = (_b = (_a2 = p2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true;
6913
- const p22 = typeof p2 === "string" ? { message: p2 } : p2;
6914
- ctx.addIssue({ code: "custom", ...p22, fatal: _fatal });
6911
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
6912
+ const _fatal = (_b = (_a2 = p.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true;
6913
+ const p2 = typeof p === "string" ? { message: p } : p;
6914
+ ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
6915
6915
  }
6916
6916
  });
6917
6917
  return ZodAny.create();
@@ -7316,7 +7316,7 @@ var initContract = () => {
7316
7316
  };
7317
7317
  var insertParamsIntoPath = ({ path, params }) => {
7318
7318
  const pathParams = params;
7319
- return path.replace(/\/?:([^/?]+)\??/g, (matched, p2) => pathParams[p2] ? `${matched.startsWith("/") ? "/" : ""}${pathParams[p2]}` : "");
7319
+ return path.replace(/\/?:([^/?]+)\??/g, (matched, p) => pathParams[p] ? `${matched.startsWith("/") ? "/" : ""}${pathParams[p]}` : "");
7320
7320
  };
7321
7321
  var convertQueryParamsToUrlString = (query, json2 = false) => {
7322
7322
  const queryString = json2 ? encodeQueryParamsJson(query) : encodeQueryParams(query);
@@ -7346,7 +7346,7 @@ var encodeQueryParams = (query) => {
7346
7346
  };
7347
7347
  var tokeniseValue = (key, value) => {
7348
7348
  if (Array.isArray(value)) {
7349
- return value.flatMap((v2, idx) => tokeniseValue(`${key}[${idx}]`, v2));
7349
+ return value.flatMap((v, idx) => tokeniseValue(`${key}[${idx}]`, v));
7350
7350
  }
7351
7351
  if (value instanceof Date) {
7352
7352
  return [[`${key}`, value.toISOString()]];
@@ -7358,10 +7358,10 @@ var tokeniseValue = (key, value) => {
7358
7358
  return [];
7359
7359
  }
7360
7360
  if (typeof value === "object") {
7361
- return Object.keys(value).flatMap((k2) => (
7361
+ return Object.keys(value).flatMap((k) => (
7362
7362
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7363
7363
  // @ts-ignore
7364
- tokeniseValue(`${key}[${k2}]`, value[k2])
7364
+ tokeniseValue(`${key}[${k}]`, value[k])
7365
7365
  ));
7366
7366
  }
7367
7367
  return [[`${key}`, `${value}`]];
@@ -7435,7 +7435,7 @@ var createFormData = (body) => {
7435
7435
  return formData;
7436
7436
  };
7437
7437
  var normalizeHeaders = (headers) => {
7438
- return Object.fromEntries(Object.entries(headers).map(([k2, v2]) => [k2.toLowerCase(), v2]));
7438
+ return Object.fromEntries(Object.entries(headers).map(([k, v]) => [k.toLowerCase(), v]));
7439
7439
  };
7440
7440
  var fetchApi = (options) => {
7441
7441
  const { path, clientArgs, route, body, query, extraInputArgs, headers, fetchOptions } = options;
@@ -8126,10 +8126,10 @@ function $constructor(name, initializer3, params) {
8126
8126
  initializer3(inst, def);
8127
8127
  const proto2 = _.prototype;
8128
8128
  const keys = Object.keys(proto2);
8129
- for (let i = 0; i < keys.length; i++) {
8130
- const k2 = keys[i];
8131
- if (!(k2 in inst)) {
8132
- inst[k2] = proto2[k2].bind(inst);
8129
+ for (let i2 = 0; i2 < keys.length; i2++) {
8130
+ const k = keys[i2];
8131
+ if (!(k in inst)) {
8132
+ inst[k] = proto2[k].bind(inst);
8133
8133
  }
8134
8134
  }
8135
8135
  }
@@ -8257,8 +8257,8 @@ function assertNever(_x) {
8257
8257
  function assert(_) {
8258
8258
  }
8259
8259
  function getEnumValues(entries) {
8260
- const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
8261
- const values = Object.entries(entries).filter(([k2, _]) => numericValues.indexOf(+k2) === -1).map(([_, v2]) => v2);
8260
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
8261
+ const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
8262
8262
  return values;
8263
8263
  }
8264
8264
  function joinValues(array2, separator = "|") {
@@ -8319,9 +8319,9 @@ function defineLazy(object2, key, getter) {
8319
8319
  }
8320
8320
  return value;
8321
8321
  },
8322
- set(v2) {
8322
+ set(v) {
8323
8323
  Object.defineProperty(object2, key, {
8324
- value: v2
8324
+ value: v
8325
8325
  // configurable: true,
8326
8326
  });
8327
8327
  },
@@ -8360,8 +8360,8 @@ function promiseAllObject(promisesObj) {
8360
8360
  const promises = keys.map((key) => promisesObj[key]);
8361
8361
  return Promise.all(promises).then((results) => {
8362
8362
  const resolvedObj = {};
8363
- for (let i = 0; i < keys.length; i++) {
8364
- resolvedObj[keys[i]] = results[i];
8363
+ for (let i2 = 0; i2 < keys.length; i2++) {
8364
+ resolvedObj[keys[i2]] = results[i2];
8365
8365
  }
8366
8366
  return resolvedObj;
8367
8367
  });
@@ -8369,7 +8369,7 @@ function promiseAllObject(promisesObj) {
8369
8369
  function randomString(length = 10) {
8370
8370
  const chars = "abcdefghijklmnopqrstuvwxyz";
8371
8371
  let str = "";
8372
- for (let i = 0; i < length; i++) {
8372
+ for (let i2 = 0; i2 < length; i2++) {
8373
8373
  str += chars[Math.floor(Math.random() * chars.length)];
8374
8374
  }
8375
8375
  return str;
@@ -8390,17 +8390,17 @@ var allowsEval = cached(() => {
8390
8390
  return false;
8391
8391
  }
8392
8392
  try {
8393
- const F2 = Function;
8394
- new F2("");
8393
+ const F = Function;
8394
+ new F("");
8395
8395
  return true;
8396
8396
  } catch (_) {
8397
8397
  return false;
8398
8398
  }
8399
8399
  });
8400
- function isPlainObject(o) {
8401
- if (isObject(o) === false)
8400
+ function isPlainObject(o2) {
8401
+ if (isObject(o2) === false)
8402
8402
  return false;
8403
- const ctor = o.constructor;
8403
+ const ctor = o2.constructor;
8404
8404
  if (ctor === void 0)
8405
8405
  return true;
8406
8406
  if (typeof ctor !== "function")
@@ -8413,12 +8413,12 @@ function isPlainObject(o) {
8413
8413
  }
8414
8414
  return true;
8415
8415
  }
8416
- function shallowClone(o) {
8417
- if (isPlainObject(o))
8418
- return { ...o };
8419
- if (Array.isArray(o))
8420
- return [...o];
8421
- return o;
8416
+ function shallowClone(o2) {
8417
+ if (isPlainObject(o2))
8418
+ return { ...o2 };
8419
+ if (Array.isArray(o2))
8420
+ return [...o2];
8421
+ return o2;
8422
8422
  }
8423
8423
  function numKeys(data) {
8424
8424
  let keyCount = 0;
@@ -8430,8 +8430,8 @@ function numKeys(data) {
8430
8430
  return keyCount;
8431
8431
  }
8432
8432
  var getParsedType2 = (data) => {
8433
- const t = typeof data;
8434
- switch (t) {
8433
+ const t2 = typeof data;
8434
+ switch (t2) {
8435
8435
  case "undefined":
8436
8436
  return "undefined";
8437
8437
  case "string":
@@ -8470,7 +8470,7 @@ var getParsedType2 = (data) => {
8470
8470
  }
8471
8471
  return "object";
8472
8472
  default:
8473
- throw new Error(`Unknown data type: ${t}`);
8473
+ throw new Error(`Unknown data type: ${t2}`);
8474
8474
  }
8475
8475
  };
8476
8476
  var propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
@@ -8541,8 +8541,8 @@ function stringifyPrimitive(value) {
8541
8541
  return `${value}`;
8542
8542
  }
8543
8543
  function optionalKeys(shape) {
8544
- return Object.keys(shape).filter((k2) => {
8545
- return shape[k2]._zod.optin === "optional" && shape[k2]._zod.optout === "optional";
8544
+ return Object.keys(shape).filter((k) => {
8545
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
8546
8546
  });
8547
8547
  }
8548
8548
  var NUMBER_FORMAT_RANGES = {
@@ -8642,20 +8642,20 @@ function safeExtend(schema, shape) {
8642
8642
  });
8643
8643
  return clone(schema, def);
8644
8644
  }
8645
- function merge(a, b2) {
8646
- const def = mergeDefs(a._zod.def, {
8645
+ function merge(a2, b) {
8646
+ const def = mergeDefs(a2._zod.def, {
8647
8647
  get shape() {
8648
- const _shape = { ...a._zod.def.shape, ...b2._zod.def.shape };
8648
+ const _shape = { ...a2._zod.def.shape, ...b._zod.def.shape };
8649
8649
  assignProp(this, "shape", _shape);
8650
8650
  return _shape;
8651
8651
  },
8652
8652
  get catchall() {
8653
- return b2._zod.def.catchall;
8653
+ return b._zod.def.catchall;
8654
8654
  },
8655
8655
  checks: []
8656
8656
  // delete existing checks
8657
8657
  });
8658
- return clone(a, def);
8658
+ return clone(a2, def);
8659
8659
  }
8660
8660
  function partial(Class2, schema, mask) {
8661
8661
  const currDef = schema._zod.def;
@@ -8729,8 +8729,8 @@ function required(Class2, schema, mask) {
8729
8729
  function aborted(x, startIndex = 0) {
8730
8730
  if (x.aborted === true)
8731
8731
  return true;
8732
- for (let i = startIndex; i < x.issues.length; i++) {
8733
- if (x.issues[i]?.continue !== true) {
8732
+ for (let i2 = startIndex; i2 < x.issues.length; i2++) {
8733
+ if (x.issues[i2]?.continue !== true) {
8734
8734
  return true;
8735
8735
  }
8736
8736
  }
@@ -8777,8 +8777,8 @@ function getLengthableOrigin(input) {
8777
8777
  return "unknown";
8778
8778
  }
8779
8779
  function parsedType(data) {
8780
- const t = typeof data;
8781
- switch (t) {
8780
+ const t2 = typeof data;
8781
+ switch (t2) {
8782
8782
  case "number": {
8783
8783
  return Number.isNaN(data) ? "nan" : "number";
8784
8784
  }
@@ -8795,7 +8795,7 @@ function parsedType(data) {
8795
8795
  }
8796
8796
  }
8797
8797
  }
8798
- return t;
8798
+ return t2;
8799
8799
  }
8800
8800
  function issue(...args) {
8801
8801
  const [iss, input, inst] = args;
@@ -8810,22 +8810,22 @@ function issue(...args) {
8810
8810
  return { ...iss };
8811
8811
  }
8812
8812
  function cleanEnum(obj) {
8813
- return Object.entries(obj).filter(([k2, _]) => {
8814
- return Number.isNaN(Number.parseInt(k2, 10));
8813
+ return Object.entries(obj).filter(([k, _]) => {
8814
+ return Number.isNaN(Number.parseInt(k, 10));
8815
8815
  }).map((el) => el[1]);
8816
8816
  }
8817
8817
  function base64ToUint8Array(base643) {
8818
8818
  const binaryString = atob(base643);
8819
8819
  const bytes = new Uint8Array(binaryString.length);
8820
- for (let i = 0; i < binaryString.length; i++) {
8821
- bytes[i] = binaryString.charCodeAt(i);
8820
+ for (let i2 = 0; i2 < binaryString.length; i2++) {
8821
+ bytes[i2] = binaryString.charCodeAt(i2);
8822
8822
  }
8823
8823
  return bytes;
8824
8824
  }
8825
8825
  function uint8ArrayToBase64(bytes) {
8826
8826
  let binaryString = "";
8827
- for (let i = 0; i < bytes.length; i++) {
8828
- binaryString += String.fromCharCode(bytes[i]);
8827
+ for (let i2 = 0; i2 < bytes.length; i2++) {
8828
+ binaryString += String.fromCharCode(bytes[i2]);
8829
8829
  }
8830
8830
  return btoa(binaryString);
8831
8831
  }
@@ -8843,13 +8843,13 @@ function hexToUint8Array(hex3) {
8843
8843
  throw new Error("Invalid hex string length");
8844
8844
  }
8845
8845
  const bytes = new Uint8Array(cleanHex.length / 2);
8846
- for (let i = 0; i < cleanHex.length; i += 2) {
8847
- bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
8846
+ for (let i2 = 0; i2 < cleanHex.length; i2 += 2) {
8847
+ bytes[i2 / 2] = Number.parseInt(cleanHex.slice(i2, i2 + 2), 16);
8848
8848
  }
8849
8849
  return bytes;
8850
8850
  }
8851
8851
  function uint8ArrayToHex(bytes) {
8852
- return Array.from(bytes).map((b2) => b2.toString(16).padStart(2, "0")).join("");
8852
+ return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
8853
8853
  }
8854
8854
  var Class = class {
8855
8855
  constructor(..._args) {
@@ -8902,10 +8902,10 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
8902
8902
  fieldErrors._errors.push(mapper(issue2));
8903
8903
  } else {
8904
8904
  let curr = fieldErrors;
8905
- let i = 0;
8906
- while (i < issue2.path.length) {
8907
- const el = issue2.path[i];
8908
- const terminal = i === issue2.path.length - 1;
8905
+ let i2 = 0;
8906
+ while (i2 < issue2.path.length) {
8907
+ const el = issue2.path[i2];
8908
+ const terminal = i2 === issue2.path.length - 1;
8909
8909
  if (!terminal) {
8910
8910
  curr[el] = curr[el] || { _errors: [] };
8911
8911
  } else {
@@ -8913,7 +8913,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
8913
8913
  curr[el]._errors.push(mapper(issue2));
8914
8914
  }
8915
8915
  curr = curr[el];
8916
- i++;
8916
+ i2++;
8917
8917
  }
8918
8918
  }
8919
8919
  }
@@ -8939,10 +8939,10 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
8939
8939
  continue;
8940
8940
  }
8941
8941
  let curr = result;
8942
- let i = 0;
8943
- while (i < fullpath.length) {
8944
- const el = fullpath[i];
8945
- const terminal = i === fullpath.length - 1;
8942
+ let i2 = 0;
8943
+ while (i2 < fullpath.length) {
8944
+ const el = fullpath[i2];
8945
+ const terminal = i2 === fullpath.length - 1;
8946
8946
  if (typeof el === "string") {
8947
8947
  curr.properties ?? (curr.properties = {});
8948
8948
  (_a2 = curr.properties)[el] ?? (_a2[el] = { errors: [] });
@@ -8955,7 +8955,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
8955
8955
  if (terminal) {
8956
8956
  curr.errors.push(mapper(issue2));
8957
8957
  }
8958
- i++;
8958
+ i2++;
8959
8959
  }
8960
8960
  }
8961
8961
  }
@@ -8983,7 +8983,7 @@ function toDotPath(_path) {
8983
8983
  }
8984
8984
  function prettifyError(error48) {
8985
8985
  const lines = [];
8986
- const issues = [...error48.issues].sort((a, b2) => (a.path ?? []).length - (b2.path ?? []).length);
8986
+ const issues = [...error48.issues].sort((a2, b) => (a2.path ?? []).length - (b.path ?? []).length);
8987
8987
  for (const issue2 of issues) {
8988
8988
  lines.push(`\u2716 ${issue2.message}`);
8989
8989
  if (issue2.path?.length)
@@ -9000,9 +9000,9 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
9000
9000
  throw new $ZodAsyncError();
9001
9001
  }
9002
9002
  if (result.issues.length) {
9003
- const e2 = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
9004
- captureStackTrace(e2, _params?.callee);
9005
- throw e2;
9003
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
9004
+ captureStackTrace(e, _params?.callee);
9005
+ throw e;
9006
9006
  }
9007
9007
  return result.value;
9008
9008
  };
@@ -9013,9 +9013,9 @@ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
9013
9013
  if (result instanceof Promise)
9014
9014
  result = await result;
9015
9015
  if (result.issues.length) {
9016
- const e2 = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
9017
- captureStackTrace(e2, params?.callee);
9018
- throw e2;
9016
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
9017
+ captureStackTrace(e, params?.callee);
9018
+ throw e;
9019
9019
  }
9020
9020
  return result.value;
9021
9021
  };
@@ -9813,11 +9813,11 @@ var Doc = class {
9813
9813
  }
9814
9814
  }
9815
9815
  compile() {
9816
- const F2 = Function;
9816
+ const F = Function;
9817
9817
  const args = this?.args;
9818
9818
  const content = this?.content ?? [``];
9819
9819
  const lines = [...content.map((x) => ` ${x}`)];
9820
- return new F2(...args, lines.join("\n"));
9820
+ return new F(...args, lines.join("\n"));
9821
9821
  }
9822
9822
  };
9823
9823
 
@@ -9928,10 +9928,10 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
9928
9928
  defineLazy(inst, "~standard", () => ({
9929
9929
  validate: (value) => {
9930
9930
  try {
9931
- const r = safeParse(inst, value);
9932
- return r.success ? { value: r.data } : { issues: r.error?.issues };
9931
+ const r2 = safeParse(inst, value);
9932
+ return r2.success ? { value: r2.data } : { issues: r2.error?.issues };
9933
9933
  } catch (_) {
9934
- return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
9934
+ return safeParseAsync(inst, value).then((r2) => r2.success ? { value: r2.data } : { issues: r2.error?.issues });
9935
9935
  }
9936
9936
  },
9937
9937
  vendor: "zod",
@@ -9978,10 +9978,10 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
9978
9978
  v7: 7,
9979
9979
  v8: 8
9980
9980
  };
9981
- const v2 = versionMap[def.version];
9982
- if (v2 === void 0)
9981
+ const v = versionMap[def.version];
9982
+ if (v === void 0)
9983
9983
  throw new Error(`Invalid UUID version: "${def.version}"`);
9984
- def.pattern ?? (def.pattern = uuid(v2));
9984
+ def.pattern ?? (def.pattern = uuid(v));
9985
9985
  } else
9986
9986
  def.pattern ?? (def.pattern = uuid());
9987
9987
  $ZodStringFormat.init(inst, def);
@@ -10452,16 +10452,16 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
10452
10452
  }
10453
10453
  payload.value = Array(input.length);
10454
10454
  const proms = [];
10455
- for (let i = 0; i < input.length; i++) {
10456
- const item = input[i];
10455
+ for (let i2 = 0; i2 < input.length; i2++) {
10456
+ const item = input[i2];
10457
10457
  const result = def.element._zod.run({
10458
10458
  value: item,
10459
10459
  issues: []
10460
10460
  }, ctx);
10461
10461
  if (result instanceof Promise) {
10462
- proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
10462
+ proms.push(result.then((result2) => handleArrayResult(result2, payload, i2)));
10463
10463
  } else {
10464
- handleArrayResult(result, payload, i);
10464
+ handleArrayResult(result, payload, i2);
10465
10465
  }
10466
10466
  }
10467
10467
  if (proms.length) {
@@ -10487,9 +10487,9 @@ function handlePropertyResult(result, final, key, input, isOptionalOut) {
10487
10487
  }
10488
10488
  function normalizeDef(def) {
10489
10489
  const keys = Object.keys(def.shape);
10490
- for (const k2 of keys) {
10491
- if (!def.shape?.[k2]?._zod?.traits?.has("$ZodType")) {
10492
- throw new Error(`Invalid element at key "${k2}": expected a Zod schema`);
10490
+ for (const k of keys) {
10491
+ if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
10492
+ throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
10493
10493
  }
10494
10494
  }
10495
10495
  const okeys = optionalKeys(def.shape);
@@ -10505,20 +10505,20 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
10505
10505
  const unrecognized = [];
10506
10506
  const keySet = def.keySet;
10507
10507
  const _catchall = def.catchall._zod;
10508
- const t = _catchall.def.type;
10508
+ const t2 = _catchall.def.type;
10509
10509
  const isOptionalOut = _catchall.optout === "optional";
10510
10510
  for (const key in input) {
10511
10511
  if (keySet.has(key))
10512
10512
  continue;
10513
- if (t === "never") {
10513
+ if (t2 === "never") {
10514
10514
  unrecognized.push(key);
10515
10515
  continue;
10516
10516
  }
10517
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
10518
- if (r instanceof Promise) {
10519
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
10517
+ const r2 = _catchall.run({ value: input[key], issues: [] }, ctx);
10518
+ if (r2 instanceof Promise) {
10519
+ proms.push(r2.then((r3) => handlePropertyResult(r3, payload, key, input, isOptionalOut)));
10520
10520
  } else {
10521
- handlePropertyResult(r, payload, key, input, isOptionalOut);
10521
+ handlePropertyResult(r2, payload, key, input, isOptionalOut);
10522
10522
  }
10523
10523
  }
10524
10524
  if (unrecognized.length) {
@@ -10558,8 +10558,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
10558
10558
  const field = shape[key]._zod;
10559
10559
  if (field.values) {
10560
10560
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
10561
- for (const v2 of field.values)
10562
- propValues[key].add(v2);
10561
+ for (const v of field.values)
10562
+ propValues[key].add(v);
10563
10563
  }
10564
10564
  }
10565
10565
  return propValues;
@@ -10585,11 +10585,11 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
10585
10585
  for (const key of value.keys) {
10586
10586
  const el = shape[key];
10587
10587
  const isOptionalOut = el._zod.optout === "optional";
10588
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
10589
- if (r instanceof Promise) {
10590
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
10588
+ const r2 = el._zod.run({ value: input[key], issues: [] }, ctx);
10589
+ if (r2 instanceof Promise) {
10590
+ proms.push(r2.then((r3) => handlePropertyResult(r3, payload, key, input, isOptionalOut)));
10591
10591
  } else {
10592
- handlePropertyResult(r, payload, key, input, isOptionalOut);
10592
+ handlePropertyResult(r2, payload, key, input, isOptionalOut);
10593
10593
  }
10594
10594
  }
10595
10595
  if (!catchall) {
@@ -10606,8 +10606,8 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
10606
10606
  const doc = new Doc(["shape", "payload", "ctx"]);
10607
10607
  const normalized = _normalized.value;
10608
10608
  const parseStr = (key) => {
10609
- const k2 = esc(key);
10610
- return `shape[${k2}]._zod.run({ value: input[${k2}], issues: [] }, ctx)`;
10609
+ const k = esc(key);
10610
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
10611
10611
  };
10612
10612
  doc.write(`const input = payload.value;`);
10613
10613
  const ids = /* @__PURE__ */ Object.create(null);
@@ -10618,27 +10618,27 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
10618
10618
  doc.write(`const newResult = {};`);
10619
10619
  for (const key of normalized.keys) {
10620
10620
  const id = ids[key];
10621
- const k2 = esc(key);
10621
+ const k = esc(key);
10622
10622
  const schema = shape[key];
10623
10623
  const isOptionalOut = schema?._zod?.optout === "optional";
10624
10624
  doc.write(`const ${id} = ${parseStr(key)};`);
10625
10625
  if (isOptionalOut) {
10626
10626
  doc.write(`
10627
10627
  if (${id}.issues.length) {
10628
- if (${k2} in input) {
10628
+ if (${k} in input) {
10629
10629
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
10630
10630
  ...iss,
10631
- path: iss.path ? [${k2}, ...iss.path] : [${k2}]
10631
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
10632
10632
  })));
10633
10633
  }
10634
10634
  }
10635
10635
 
10636
10636
  if (${id}.value === undefined) {
10637
- if (${k2} in input) {
10638
- newResult[${k2}] = undefined;
10637
+ if (${k} in input) {
10638
+ newResult[${k}] = undefined;
10639
10639
  }
10640
10640
  } else {
10641
- newResult[${k2}] = ${id}.value;
10641
+ newResult[${k}] = ${id}.value;
10642
10642
  }
10643
10643
 
10644
10644
  `);
@@ -10647,16 +10647,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
10647
10647
  if (${id}.issues.length) {
10648
10648
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
10649
10649
  ...iss,
10650
- path: iss.path ? [${k2}, ...iss.path] : [${k2}]
10650
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
10651
10651
  })));
10652
10652
  }
10653
10653
 
10654
10654
  if (${id}.value === undefined) {
10655
- if (${k2} in input) {
10656
- newResult[${k2}] = undefined;
10655
+ if (${k} in input) {
10656
+ newResult[${k}] = undefined;
10657
10657
  }
10658
10658
  } else {
10659
- newResult[${k2}] = ${id}.value;
10659
+ newResult[${k}] = ${id}.value;
10660
10660
  }
10661
10661
 
10662
10662
  `);
@@ -10704,7 +10704,7 @@ function handleUnionResults(results, final, inst, ctx) {
10704
10704
  return final;
10705
10705
  }
10706
10706
  }
10707
- const nonaborted = results.filter((r) => !aborted(r));
10707
+ const nonaborted = results.filter((r2) => !aborted(r2));
10708
10708
  if (nonaborted.length === 1) {
10709
10709
  final.value = nonaborted[0].value;
10710
10710
  return nonaborted[0];
@@ -10719,18 +10719,18 @@ function handleUnionResults(results, final, inst, ctx) {
10719
10719
  }
10720
10720
  var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
10721
10721
  $ZodType.init(inst, def);
10722
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
10723
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
10722
+ defineLazy(inst._zod, "optin", () => def.options.some((o2) => o2._zod.optin === "optional") ? "optional" : void 0);
10723
+ defineLazy(inst._zod, "optout", () => def.options.some((o2) => o2._zod.optout === "optional") ? "optional" : void 0);
10724
10724
  defineLazy(inst._zod, "values", () => {
10725
- if (def.options.every((o) => o._zod.values)) {
10725
+ if (def.options.every((o2) => o2._zod.values)) {
10726
10726
  return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
10727
10727
  }
10728
10728
  return void 0;
10729
10729
  });
10730
10730
  defineLazy(inst._zod, "pattern", () => {
10731
- if (def.options.every((o) => o._zod.pattern)) {
10732
- const patterns = def.options.map((o) => o._zod.pattern);
10733
- return new RegExp(`^(${patterns.map((p2) => cleanRegex(p2.source)).join("|")})$`);
10731
+ if (def.options.every((o2) => o2._zod.pattern)) {
10732
+ const patterns = def.options.map((o2) => o2._zod.pattern);
10733
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
10734
10734
  }
10735
10735
  return void 0;
10736
10736
  });
@@ -10764,7 +10764,7 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
10764
10764
  };
10765
10765
  });
10766
10766
  function handleExclusiveUnionResults(results, final, inst, ctx) {
10767
- const successes = results.filter((r) => r.issues.length === 0);
10767
+ const successes = results.filter((r2) => r2.issues.length === 0);
10768
10768
  if (successes.length === 1) {
10769
10769
  final.value = successes[0].value;
10770
10770
  return final;
@@ -10827,11 +10827,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
10827
10827
  const pv = option._zod.propValues;
10828
10828
  if (!pv || Object.keys(pv).length === 0)
10829
10829
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
10830
- for (const [k2, v2] of Object.entries(pv)) {
10831
- if (!propValues[k2])
10832
- propValues[k2] = /* @__PURE__ */ new Set();
10833
- for (const val of v2) {
10834
- propValues[k2].add(val);
10830
+ for (const [k, v] of Object.entries(pv)) {
10831
+ if (!propValues[k])
10832
+ propValues[k] = /* @__PURE__ */ new Set();
10833
+ for (const val of v) {
10834
+ propValues[k].add(val);
10835
10835
  }
10836
10836
  }
10837
10837
  }
@@ -10840,15 +10840,15 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
10840
10840
  const disc = cached(() => {
10841
10841
  const opts = def.options;
10842
10842
  const map2 = /* @__PURE__ */ new Map();
10843
- for (const o of opts) {
10844
- const values = o._zod.propValues?.[def.discriminator];
10843
+ for (const o2 of opts) {
10844
+ const values = o2._zod.propValues?.[def.discriminator];
10845
10845
  if (!values || values.size === 0)
10846
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
10847
- for (const v2 of values) {
10848
- if (map2.has(v2)) {
10849
- throw new Error(`Duplicate discriminator value "${String(v2)}"`);
10846
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o2)}"`);
10847
+ for (const v of values) {
10848
+ if (map2.has(v)) {
10849
+ throw new Error(`Duplicate discriminator value "${String(v)}"`);
10850
10850
  }
10851
- map2.set(v2, o);
10851
+ map2.set(v, o2);
10852
10852
  }
10853
10853
  }
10854
10854
  return map2;
@@ -10898,19 +10898,19 @@ var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, d
10898
10898
  return handleIntersectionResults(payload, left, right);
10899
10899
  };
10900
10900
  });
10901
- function mergeValues2(a, b2) {
10902
- if (a === b2) {
10903
- return { valid: true, data: a };
10901
+ function mergeValues2(a2, b) {
10902
+ if (a2 === b) {
10903
+ return { valid: true, data: a2 };
10904
10904
  }
10905
- if (a instanceof Date && b2 instanceof Date && +a === +b2) {
10906
- return { valid: true, data: a };
10905
+ if (a2 instanceof Date && b instanceof Date && +a2 === +b) {
10906
+ return { valid: true, data: a2 };
10907
10907
  }
10908
- if (isPlainObject(a) && isPlainObject(b2)) {
10909
- const bKeys = Object.keys(b2);
10910
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
10911
- const newObj = { ...a, ...b2 };
10908
+ if (isPlainObject(a2) && isPlainObject(b)) {
10909
+ const bKeys = Object.keys(b);
10910
+ const sharedKeys = Object.keys(a2).filter((key) => bKeys.indexOf(key) !== -1);
10911
+ const newObj = { ...a2, ...b };
10912
10912
  for (const key of sharedKeys) {
10913
- const sharedValue = mergeValues2(a[key], b2[key]);
10913
+ const sharedValue = mergeValues2(a2[key], b[key]);
10914
10914
  if (!sharedValue.valid) {
10915
10915
  return {
10916
10916
  valid: false,
@@ -10921,14 +10921,14 @@ function mergeValues2(a, b2) {
10921
10921
  }
10922
10922
  return { valid: true, data: newObj };
10923
10923
  }
10924
- if (Array.isArray(a) && Array.isArray(b2)) {
10925
- if (a.length !== b2.length) {
10924
+ if (Array.isArray(a2) && Array.isArray(b)) {
10925
+ if (a2.length !== b.length) {
10926
10926
  return { valid: false, mergeErrorPath: [] };
10927
10927
  }
10928
10928
  const newArray = [];
10929
- for (let index = 0; index < a.length; index++) {
10930
- const itemA = a[index];
10931
- const itemB = b2[index];
10929
+ for (let index = 0; index < a2.length; index++) {
10930
+ const itemA = a2[index];
10931
+ const itemB = b[index];
10932
10932
  const sharedValue = mergeValues2(itemA, itemB);
10933
10933
  if (!sharedValue.valid) {
10934
10934
  return {
@@ -10948,10 +10948,10 @@ function handleIntersectionResults(result, left, right) {
10948
10948
  for (const iss of left.issues) {
10949
10949
  if (iss.code === "unrecognized_keys") {
10950
10950
  unrecIssue ?? (unrecIssue = iss);
10951
- for (const k2 of iss.keys) {
10952
- if (!unrecKeys.has(k2))
10953
- unrecKeys.set(k2, {});
10954
- unrecKeys.get(k2).l = true;
10951
+ for (const k of iss.keys) {
10952
+ if (!unrecKeys.has(k))
10953
+ unrecKeys.set(k, {});
10954
+ unrecKeys.get(k).l = true;
10955
10955
  }
10956
10956
  } else {
10957
10957
  result.issues.push(iss);
@@ -10959,16 +10959,16 @@ function handleIntersectionResults(result, left, right) {
10959
10959
  }
10960
10960
  for (const iss of right.issues) {
10961
10961
  if (iss.code === "unrecognized_keys") {
10962
- for (const k2 of iss.keys) {
10963
- if (!unrecKeys.has(k2))
10964
- unrecKeys.set(k2, {});
10965
- unrecKeys.get(k2).r = true;
10962
+ for (const k of iss.keys) {
10963
+ if (!unrecKeys.has(k))
10964
+ unrecKeys.set(k, {});
10965
+ unrecKeys.get(k).r = true;
10966
10966
  }
10967
10967
  } else {
10968
10968
  result.issues.push(iss);
10969
10969
  }
10970
10970
  }
10971
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k2]) => k2);
10971
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
10972
10972
  if (bothKeys.length && unrecIssue) {
10973
10973
  result.issues.push({ ...unrecIssue, keys: bothKeys });
10974
10974
  }
@@ -11012,35 +11012,35 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
11012
11012
  return payload;
11013
11013
  }
11014
11014
  }
11015
- let i = -1;
11015
+ let i2 = -1;
11016
11016
  for (const item of items) {
11017
- i++;
11018
- if (i >= input.length) {
11019
- if (i >= optStart)
11017
+ i2++;
11018
+ if (i2 >= input.length) {
11019
+ if (i2 >= optStart)
11020
11020
  continue;
11021
11021
  }
11022
11022
  const result = item._zod.run({
11023
- value: input[i],
11023
+ value: input[i2],
11024
11024
  issues: []
11025
11025
  }, ctx);
11026
11026
  if (result instanceof Promise) {
11027
- proms.push(result.then((result2) => handleTupleResult(result2, payload, i)));
11027
+ proms.push(result.then((result2) => handleTupleResult(result2, payload, i2)));
11028
11028
  } else {
11029
- handleTupleResult(result, payload, i);
11029
+ handleTupleResult(result, payload, i2);
11030
11030
  }
11031
11031
  }
11032
11032
  if (def.rest) {
11033
11033
  const rest = input.slice(items.length);
11034
11034
  for (const el of rest) {
11035
- i++;
11035
+ i2++;
11036
11036
  const result = def.rest._zod.run({
11037
11037
  value: el,
11038
11038
  issues: []
11039
11039
  }, ctx);
11040
11040
  if (result instanceof Promise) {
11041
- proms.push(result.then((result2) => handleTupleResult(result2, payload, i)));
11041
+ proms.push(result.then((result2) => handleTupleResult(result2, payload, i2)));
11042
11042
  } else {
11043
- handleTupleResult(result, payload, i);
11043
+ handleTupleResult(result, payload, i2);
11044
11044
  }
11045
11045
  }
11046
11046
  }
@@ -11262,7 +11262,7 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
11262
11262
  const values = getEnumValues(def.entries);
11263
11263
  const valuesSet = new Set(values);
11264
11264
  inst._zod.values = valuesSet;
11265
- inst._zod.pattern = new RegExp(`^(${values.filter((k2) => propertyKeyTypes.has(typeof k2)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
11265
+ inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o2) => typeof o2 === "string" ? escapeRegex(o2) : o2.toString()).join("|")})$`);
11266
11266
  inst._zod.parse = (payload, _ctx) => {
11267
11267
  const input = payload.value;
11268
11268
  if (valuesSet.has(input)) {
@@ -11284,7 +11284,7 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
11284
11284
  }
11285
11285
  const values = new Set(def.values);
11286
11286
  inst._zod.values = values;
11287
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
11287
+ inst._zod.pattern = new RegExp(`^(${def.values.map((o2) => typeof o2 === "string" ? escapeRegex(o2) : o2 ? escapeRegex(o2.toString()) : String(o2)).join("|")})$`);
11288
11288
  inst._zod.parse = (payload, _ctx) => {
11289
11289
  const input = payload.value;
11290
11290
  if (values.has(input)) {
@@ -11356,7 +11356,7 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
11356
11356
  if (def.innerType._zod.optin === "optional") {
11357
11357
  const result = def.innerType._zod.run(payload, ctx);
11358
11358
  if (result instanceof Promise)
11359
- return result.then((r) => handleOptionalResult(r, payload.value));
11359
+ return result.then((r2) => handleOptionalResult(r2, payload.value));
11360
11360
  return handleOptionalResult(result, payload.value);
11361
11361
  }
11362
11362
  if (payload.value === void 0) {
@@ -11432,8 +11432,8 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
11432
11432
  var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
11433
11433
  $ZodType.init(inst, def);
11434
11434
  defineLazy(inst._zod, "values", () => {
11435
- const v2 = def.innerType._zod.values;
11436
- return v2 ? new Set([...v2].filter((x) => x !== void 0)) : void 0;
11435
+ const v = def.innerType._zod.values;
11436
+ return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
11437
11437
  });
11438
11438
  inst._zod.parse = (payload, ctx) => {
11439
11439
  const result = def.innerType._zod.run(payload, ctx);
@@ -11719,9 +11719,9 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
11719
11719
  return payload;
11720
11720
  };
11721
11721
  inst.input = (...args) => {
11722
- const F2 = inst.constructor;
11722
+ const F = inst.constructor;
11723
11723
  if (Array.isArray(args[0])) {
11724
- return new F2({
11724
+ return new F({
11725
11725
  type: "function",
11726
11726
  input: new $ZodTuple({
11727
11727
  type: "tuple",
@@ -11731,15 +11731,15 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
11731
11731
  output: inst._def.output
11732
11732
  });
11733
11733
  }
11734
- return new F2({
11734
+ return new F({
11735
11735
  type: "function",
11736
11736
  input: args[0],
11737
11737
  output: inst._def.output
11738
11738
  });
11739
11739
  };
11740
11740
  inst.output = (output) => {
11741
- const F2 = inst.constructor;
11742
- return new F2({
11741
+ const F = inst.constructor;
11742
+ return new F({
11743
11743
  type: "function",
11744
11744
  input: inst._def.input,
11745
11745
  output
@@ -11773,11 +11773,11 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
11773
11773
  };
11774
11774
  inst._zod.check = (payload) => {
11775
11775
  const input = payload.value;
11776
- const r = def.fn(input);
11777
- if (r instanceof Promise) {
11778
- return r.then((r2) => handleRefineResult(r2, payload, input, inst));
11776
+ const r2 = def.fn(input);
11777
+ if (r2 instanceof Promise) {
11778
+ return r2.then((r3) => handleRefineResult(r3, payload, input, inst));
11779
11779
  }
11780
- handleRefineResult(r, payload, input, inst);
11780
+ handleRefineResult(r2, payload, input, inst);
11781
11781
  return;
11782
11782
  };
11783
11783
  });
@@ -13617,17 +13617,17 @@ var error16 = () => {
13617
13617
  number: { unit: "", shortLabel: "\u05E7\u05D8\u05DF", longLabel: "\u05D2\u05D3\u05D5\u05DC" }
13618
13618
  // no unit
13619
13619
  };
13620
- const typeEntry = (t) => t ? TypeNames[t] : void 0;
13621
- const typeLabel = (t) => {
13622
- const e2 = typeEntry(t);
13623
- if (e2)
13624
- return e2.label;
13625
- return t ?? TypeNames.unknown.label;
13626
- };
13627
- const withDefinite = (t) => `\u05D4${typeLabel(t)}`;
13628
- const verbFor = (t) => {
13629
- const e2 = typeEntry(t);
13630
- const gender = e2?.gender ?? "m";
13620
+ const typeEntry = (t2) => t2 ? TypeNames[t2] : void 0;
13621
+ const typeLabel = (t2) => {
13622
+ const e = typeEntry(t2);
13623
+ if (e)
13624
+ return e.label;
13625
+ return t2 ?? TypeNames.unknown.label;
13626
+ };
13627
+ const withDefinite = (t2) => `\u05D4${typeLabel(t2)}`;
13628
+ const verbFor = (t2) => {
13629
+ const e = typeEntry(t2);
13630
+ const gender = e?.gender ?? "m";
13631
13631
  return gender === "f" ? "\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA" : "\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA";
13632
13632
  };
13633
13633
  const getSizing = (origin) => {
@@ -13686,7 +13686,7 @@ var error16 = () => {
13686
13686
  if (issue2.values.length === 1) {
13687
13687
  return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${stringifyPrimitive(issue2.values[0])}`;
13688
13688
  }
13689
- const stringified = issue2.values.map((v2) => stringifyPrimitive(v2));
13689
+ const stringified = issue2.values.map((v) => stringifyPrimitive(v));
13690
13690
  if (issue2.values.length === 2) {
13691
13691
  return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${stringified[0]} \u05D0\u05D5 ${stringified[1]}`;
13692
13692
  }
@@ -17407,9 +17407,9 @@ var $ZodRegistry = class {
17407
17407
  return this;
17408
17408
  }
17409
17409
  get(schema) {
17410
- const p2 = schema._zod.parent;
17411
- if (p2) {
17412
- const pm = { ...this.get(p2) ?? {} };
17410
+ const p = schema._zod.parent;
17411
+ if (p) {
17412
+ const pm = { ...this.get(p) ?? {} };
17413
17413
  delete pm.id;
17414
17414
  const f = { ...pm, ...this._map.get(schema) };
17415
17415
  return Object.keys(f).length ? f : void 0;
@@ -18197,7 +18197,7 @@ function _set(Class2, valueType, params) {
18197
18197
  }
18198
18198
  // @__NO_SIDE_EFFECTS__
18199
18199
  function _enum(Class2, values, params) {
18200
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
18200
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
18201
18201
  return new Class2({
18202
18202
  type: "enum",
18203
18203
  entries,
@@ -18402,8 +18402,8 @@ function _stringbool(Classes, _params) {
18402
18402
  let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
18403
18403
  let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
18404
18404
  if (params.case !== "sensitive") {
18405
- truthyArray = truthyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
18406
- falsyArray = falsyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
18405
+ truthyArray = truthyArray.map((v) => typeof v === "string" ? v.toLowerCase() : v);
18406
+ falsyArray = falsyArray.map((v) => typeof v === "string" ? v.toLowerCase() : v);
18407
18407
  }
18408
18408
  const truthySet = new Set(truthyArray);
18409
18409
  const falsySet = new Set(falsyArray);
@@ -18949,9 +18949,9 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
18949
18949
  var enumProcessor = (schema, _ctx, json2, _params) => {
18950
18950
  const def = schema._zod.def;
18951
18951
  const values = getEnumValues(def.entries);
18952
- if (values.every((v2) => typeof v2 === "number"))
18952
+ if (values.every((v) => typeof v === "number"))
18953
18953
  json2.type = "number";
18954
- if (values.every((v2) => typeof v2 === "string"))
18954
+ if (values.every((v) => typeof v === "string"))
18955
18955
  json2.type = "string";
18956
18956
  json2.enum = values;
18957
18957
  };
@@ -18984,13 +18984,13 @@ var literalProcessor = (schema, ctx, json2, _params) => {
18984
18984
  json2.const = val;
18985
18985
  }
18986
18986
  } else {
18987
- if (vals.every((v2) => typeof v2 === "number"))
18987
+ if (vals.every((v) => typeof v === "number"))
18988
18988
  json2.type = "number";
18989
- if (vals.every((v2) => typeof v2 === "string"))
18989
+ if (vals.every((v) => typeof v === "string"))
18990
18990
  json2.type = "string";
18991
- if (vals.every((v2) => typeof v2 === "boolean"))
18991
+ if (vals.every((v) => typeof v === "boolean"))
18992
18992
  json2.type = "boolean";
18993
- if (vals.every((v2) => v2 === null))
18993
+ if (vals.every((v) => v === null))
18994
18994
  json2.type = "null";
18995
18995
  json2.enum = vals;
18996
18996
  }
@@ -19026,7 +19026,7 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
19026
19026
  Object.assign(_json, file2);
19027
19027
  } else {
19028
19028
  Object.assign(_json, file2);
19029
- _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
19029
+ _json.anyOf = mime.map((m2) => ({ contentMediaType: m2 }));
19030
19030
  }
19031
19031
  } else {
19032
19032
  Object.assign(_json, file2);
@@ -19085,11 +19085,11 @@ var objectProcessor = (schema, ctx, _json, params) => {
19085
19085
  }
19086
19086
  const allKeys = new Set(Object.keys(shape));
19087
19087
  const requiredKeys = new Set([...allKeys].filter((key) => {
19088
- const v2 = def.shape[key]._zod;
19088
+ const v = def.shape[key]._zod;
19089
19089
  if (ctx.io === "input") {
19090
- return v2.optin === void 0;
19090
+ return v.optin === void 0;
19091
19091
  } else {
19092
- return v2.optout === void 0;
19092
+ return v.optout === void 0;
19093
19093
  }
19094
19094
  }));
19095
19095
  if (requiredKeys.size > 0) {
@@ -19110,9 +19110,9 @@ var objectProcessor = (schema, ctx, _json, params) => {
19110
19110
  var unionProcessor = (schema, ctx, json2, params) => {
19111
19111
  const def = schema._zod.def;
19112
19112
  const isExclusive = def.inclusive === false;
19113
- const options = def.options.map((x, i) => process2(x, ctx, {
19113
+ const options = def.options.map((x, i2) => process2(x, ctx, {
19114
19114
  ...params,
19115
- path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
19115
+ path: [...params.path, isExclusive ? "oneOf" : "anyOf", i2]
19116
19116
  }));
19117
19117
  if (isExclusive) {
19118
19118
  json2.oneOf = options;
@@ -19122,18 +19122,18 @@ var unionProcessor = (schema, ctx, json2, params) => {
19122
19122
  };
19123
19123
  var intersectionProcessor = (schema, ctx, json2, params) => {
19124
19124
  const def = schema._zod.def;
19125
- const a = process2(def.left, ctx, {
19125
+ const a2 = process2(def.left, ctx, {
19126
19126
  ...params,
19127
19127
  path: [...params.path, "allOf", 0]
19128
19128
  });
19129
- const b2 = process2(def.right, ctx, {
19129
+ const b = process2(def.right, ctx, {
19130
19130
  ...params,
19131
19131
  path: [...params.path, "allOf", 1]
19132
19132
  });
19133
19133
  const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
19134
19134
  const allOf = [
19135
- ...isSimpleIntersection(a) ? a.allOf : [a],
19136
- ...isSimpleIntersection(b2) ? b2.allOf : [b2]
19135
+ ...isSimpleIntersection(a2) ? a2.allOf : [a2],
19136
+ ...isSimpleIntersection(b) ? b.allOf : [b]
19137
19137
  ];
19138
19138
  json2.allOf = allOf;
19139
19139
  };
@@ -19143,9 +19143,9 @@ var tupleProcessor = (schema, ctx, _json, params) => {
19143
19143
  json2.type = "array";
19144
19144
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
19145
19145
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
19146
- const prefixItems = def.items.map((x, i) => process2(x, ctx, {
19146
+ const prefixItems = def.items.map((x, i2) => process2(x, ctx, {
19147
19147
  ...params,
19148
- path: [...params.path, prefixPath, i]
19148
+ path: [...params.path, prefixPath, i2]
19149
19149
  }));
19150
19150
  const rest = def.rest ? process2(def.rest, ctx, {
19151
19151
  ...params,
@@ -19209,7 +19209,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
19209
19209
  }
19210
19210
  const keyValues = keyType._zod.values;
19211
19211
  if (keyValues) {
19212
- const validKeyValues = [...keyValues].filter((v2) => typeof v2 === "string" || typeof v2 === "number");
19212
+ const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
19213
19213
  if (validKeyValues.length > 0) {
19214
19214
  json2.required = validKeyValues;
19215
19215
  }
@@ -20381,11 +20381,11 @@ function record(keyType, valueType, params) {
20381
20381
  });
20382
20382
  }
20383
20383
  function partialRecord(keyType, valueType, params) {
20384
- const k2 = clone(keyType);
20385
- k2._zod.values = void 0;
20384
+ const k = clone(keyType);
20385
+ k._zod.values = void 0;
20386
20386
  return new ZodRecord2({
20387
20387
  type: "record",
20388
- keyType: k2,
20388
+ keyType: k,
20389
20389
  valueType,
20390
20390
  ...util_exports.normalizeParams(params)
20391
20391
  });
@@ -20473,7 +20473,7 @@ var ZodEnum2 = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
20473
20473
  };
20474
20474
  });
20475
20475
  function _enum2(values, params) {
20476
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
20476
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
20477
20477
  return new ZodEnum2({
20478
20478
  type: "enum",
20479
20479
  entries,
@@ -21007,10 +21007,10 @@ function convertBaseSchema(schema, ctx) {
21007
21007
  if (enumValues.length === 1) {
21008
21008
  return z2.literal(enumValues[0]);
21009
21009
  }
21010
- if (enumValues.every((v2) => typeof v2 === "string")) {
21010
+ if (enumValues.every((v) => typeof v === "string")) {
21011
21011
  return z2.enum(enumValues);
21012
21012
  }
21013
- const literalSchemas = enumValues.map((v2) => z2.literal(v2));
21013
+ const literalSchemas = enumValues.map((v) => z2.literal(v));
21014
21014
  if (literalSchemas.length < 2) {
21015
21015
  return literalSchemas[0];
21016
21016
  }
@@ -21021,8 +21021,8 @@ function convertBaseSchema(schema, ctx) {
21021
21021
  }
21022
21022
  const type = schema.type;
21023
21023
  if (Array.isArray(type)) {
21024
- const typeSchemas = type.map((t) => {
21025
- const typeSchema = { ...schema, type: t };
21024
+ const typeSchemas = type.map((t2) => {
21025
+ const typeSchema = { ...schema, type: t2 };
21026
21026
  return convertBaseSchema(typeSchema, ctx);
21027
21027
  });
21028
21028
  if (typeSchemas.length === 0) {
@@ -21175,8 +21175,8 @@ function convertBaseSchema(schema, ctx) {
21175
21175
  zodSchema = schemasToIntersect[0];
21176
21176
  } else {
21177
21177
  let result = z2.intersection(schemasToIntersect[0], schemasToIntersect[1]);
21178
- for (let i = 2; i < schemasToIntersect.length; i++) {
21179
- result = z2.intersection(result, schemasToIntersect[i]);
21178
+ for (let i2 = 2; i2 < schemasToIntersect.length; i2++) {
21179
+ result = z2.intersection(result, schemasToIntersect[i2]);
21180
21180
  }
21181
21181
  zodSchema = result;
21182
21182
  }
@@ -21271,8 +21271,8 @@ function convertSchema(schema, ctx) {
21271
21271
  } else {
21272
21272
  let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
21273
21273
  const startIdx = hasExplicitType ? 0 : 1;
21274
- for (let i = startIdx; i < schema.allOf.length; i++) {
21275
- result = z2.intersection(result, convertSchema(schema.allOf[i], ctx));
21274
+ for (let i2 = startIdx; i2 < schema.allOf.length; i2++) {
21275
+ result = z2.intersection(result, convertSchema(schema.allOf[i2], ctx));
21276
21276
  }
21277
21277
  baseSchema = result;
21278
21278
  }
@@ -22215,6 +22215,180 @@ var ROLE_PERMISSIONS = {
22215
22215
  [Role.admin]: new Set(Object.values(Permission))
22216
22216
  };
22217
22217
 
22218
+ // ../../packages/core/src/auth/totp.ts
22219
+ var TOTP_ALGORITHMS = ["SHA1", "SHA256", "SHA512"];
22220
+ var TOTP_DIGITS = [6, 8];
22221
+ var TOTP_DEFAULT_ALGORITHM = "SHA1";
22222
+ var TOTP_DEFAULT_DIGITS = 6;
22223
+ var TOTP_DEFAULT_PERIOD_SECONDS = 30;
22224
+ var TOTP_MIN_PERIOD_SECONDS = 5;
22225
+ var TOTP_MAX_PERIOD_SECONDS = 300;
22226
+ var TOTP_MIN_SECRET_CHARS = 16;
22227
+ var TOTP_MAX_SECRET_CHARS = 512;
22228
+ var TOTP_MAX_LABEL_CHARS = 500;
22229
+ var BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
22230
+ var TotpSetupKeyError = class extends Error {
22231
+ constructor(message) {
22232
+ super(message);
22233
+ this.name = "TotpSetupKeyError";
22234
+ }
22235
+ };
22236
+ function normalizeSecret(raw) {
22237
+ return raw.replace(/[\s-]/g, "").replace(/=+$/, "").toUpperCase();
22238
+ }
22239
+ function parseSecret(raw) {
22240
+ const secret = normalizeSecret(raw);
22241
+ if (secret.length === 0) {
22242
+ throw new TotpSetupKeyError(
22243
+ 'Setup key has an empty secret. Expected the base32 key the app shows next to the QR code (e.g. "JBSWY3DPEHPK3PXP").'
22244
+ );
22245
+ }
22246
+ if (secret.length < TOTP_MIN_SECRET_CHARS) {
22247
+ throw new TotpSetupKeyError(
22248
+ `Setup key secret is ${secret.length} characters; expected at least ${TOTP_MIN_SECRET_CHARS}. This usually means the value was truncated when it was copied.`
22249
+ );
22250
+ }
22251
+ if (secret.length > TOTP_MAX_SECRET_CHARS) {
22252
+ throw new TotpSetupKeyError(
22253
+ `Setup key secret is ${secret.length} characters; the maximum is ${TOTP_MAX_SECRET_CHARS}. Paste only the base32 key, not the whole QR payload or a file.`
22254
+ );
22255
+ }
22256
+ for (const char of secret) {
22257
+ if (!BASE32_ALPHABET.includes(char)) {
22258
+ throw new TotpSetupKeyError(
22259
+ "Setup key secret contains characters outside the base32 alphabet (A\u2013Z and 2\u20137). Check for a mistyped 0/O or 1/I, and paste the key exactly as the app displays it."
22260
+ );
22261
+ }
22262
+ }
22263
+ return secret;
22264
+ }
22265
+ function parseAlgorithm(raw) {
22266
+ if (raw === null || raw === "") return TOTP_DEFAULT_ALGORITHM;
22267
+ const upper = raw.toUpperCase();
22268
+ const match = TOTP_ALGORITHMS.find((a2) => a2 === upper);
22269
+ if (!match) {
22270
+ throw new TotpSetupKeyError(
22271
+ `Setup key has algorithm "${raw}"; expected one of ${TOTP_ALGORITHMS.join(", ")}.`
22272
+ );
22273
+ }
22274
+ return match;
22275
+ }
22276
+ function parseDigits(raw) {
22277
+ if (raw === null || raw === "") return TOTP_DEFAULT_DIGITS;
22278
+ const parsed = Number(raw);
22279
+ const match = TOTP_DIGITS.find((d) => d === parsed);
22280
+ if (!match) {
22281
+ throw new TotpSetupKeyError(
22282
+ `Setup key has digits "${raw}"; expected ${TOTP_DIGITS.join(" or ")}.`
22283
+ );
22284
+ }
22285
+ return match;
22286
+ }
22287
+ function parsePeriod(raw) {
22288
+ if (raw === null || raw === "") return TOTP_DEFAULT_PERIOD_SECONDS;
22289
+ const parsed = Number(raw);
22290
+ if (!Number.isInteger(parsed)) {
22291
+ throw new TotpSetupKeyError(
22292
+ `Setup key has period "${raw}"; expected a whole number of seconds (usually 30).`
22293
+ );
22294
+ }
22295
+ if (parsed < TOTP_MIN_PERIOD_SECONDS || parsed > TOTP_MAX_PERIOD_SECONDS) {
22296
+ throw new TotpSetupKeyError(
22297
+ `Setup key has period ${parsed}s; expected between ${TOTP_MIN_PERIOD_SECONDS} and ${TOTP_MAX_PERIOD_SECONDS} seconds (usually 30).`
22298
+ );
22299
+ }
22300
+ return parsed;
22301
+ }
22302
+ function parseLabel(pathname) {
22303
+ let label = pathname.replace(/^\//, "");
22304
+ try {
22305
+ label = decodeURIComponent(label);
22306
+ } catch {
22307
+ }
22308
+ if (label.length === 0) return { issuer: null, accountName: null };
22309
+ const colon = label.indexOf(":");
22310
+ if (colon === -1) return { issuer: null, accountName: clampLabel(label) };
22311
+ return {
22312
+ issuer: clampLabel(label.slice(0, colon)),
22313
+ accountName: clampLabel(label.slice(colon + 1))
22314
+ };
22315
+ }
22316
+ function clampLabel(value) {
22317
+ const trimmed = value.trim();
22318
+ if (trimmed.length === 0) return null;
22319
+ return trimmed.slice(0, TOTP_MAX_LABEL_CHARS);
22320
+ }
22321
+ function parseTotpSetupKey(input) {
22322
+ const trimmed = input.trim();
22323
+ if (trimmed.length === 0) {
22324
+ throw new TotpSetupKeyError(
22325
+ "Setup key is empty. Provide an otpauth:// URI or the base32 key shown next to the QR code."
22326
+ );
22327
+ }
22328
+ if (!/^otpauth:/i.test(trimmed)) {
22329
+ if (/^otpauth-migration:/i.test(trimmed)) {
22330
+ throw new TotpSetupKeyError(
22331
+ "This is a Google Authenticator export URI (otpauth-migration://), which packs several accounts into one protobuf blob. Open the account in the authenticator and use its individual otpauth:// URI or base32 key instead."
22332
+ );
22333
+ }
22334
+ return {
22335
+ secret: parseSecret(trimmed),
22336
+ algorithm: TOTP_DEFAULT_ALGORITHM,
22337
+ digits: TOTP_DEFAULT_DIGITS,
22338
+ periodSeconds: TOTP_DEFAULT_PERIOD_SECONDS,
22339
+ issuer: null,
22340
+ accountName: null
22341
+ };
22342
+ }
22343
+ let url2;
22344
+ try {
22345
+ url2 = new URL(trimmed);
22346
+ } catch {
22347
+ throw new TotpSetupKeyError(
22348
+ "Setup key starts with otpauth: but is not a valid URI. Expected otpauth://totp/Label?secret=BASE32."
22349
+ );
22350
+ }
22351
+ const kind = url2.host.toLowerCase();
22352
+ if (kind === "hotp") {
22353
+ throw new TotpSetupKeyError(
22354
+ "This is a counter-based HOTP key (otpauth://hotp/). Only time-based TOTP keys are supported \u2014 re-enrol the account choosing an authenticator app / time-based code."
22355
+ );
22356
+ }
22357
+ if (kind !== "totp") {
22358
+ throw new TotpSetupKeyError(
22359
+ `Setup key type is "${kind || "(none)"}"; expected otpauth://totp/.`
22360
+ );
22361
+ }
22362
+ const secretParam = url2.searchParams.get("secret");
22363
+ if (secretParam === null) {
22364
+ throw new TotpSetupKeyError(
22365
+ "Setup key URI has no `secret` parameter. Expected otpauth://totp/Label?secret=BASE32."
22366
+ );
22367
+ }
22368
+ const label = parseLabel(url2.pathname);
22369
+ const issuerParam = url2.searchParams.get("issuer");
22370
+ return {
22371
+ secret: parseSecret(secretParam),
22372
+ algorithm: parseAlgorithm(url2.searchParams.get("algorithm")),
22373
+ digits: parseDigits(url2.searchParams.get("digits")),
22374
+ periodSeconds: parsePeriod(url2.searchParams.get("period")),
22375
+ // The `issuer` parameter wins over the label prefix: the spec calls the
22376
+ // parameter "strongly recommended" and the prefix a legacy duplicate, and
22377
+ // when they disagree the parameter is the one the issuer set deliberately.
22378
+ // Clamped on this path too — it does not go through parseLabel.
22379
+ issuer: (issuerParam === null ? null : clampLabel(issuerParam)) ?? label.issuer,
22380
+ accountName: label.accountName
22381
+ };
22382
+ }
22383
+ function totpSetupKeyError(input) {
22384
+ try {
22385
+ parseTotpSetupKey(input);
22386
+ return null;
22387
+ } catch (err) {
22388
+ return err instanceof TotpSetupKeyError ? err.message : "Setup key could not be parsed.";
22389
+ }
22390
+ }
22391
+
22218
22392
  // ../../packages/core/src/application/types.ts
22219
22393
  var URL_BEARING_APPLICATION_TYPES = /* @__PURE__ */ new Set(["WEB", "API_SERVICE"]);
22220
22394
  function isUrlBearingApplicationType(type) {
@@ -24014,15 +24188,15 @@ var MagicAuthConfigSchema = external_exports.object({
24014
24188
  }).strict();
24015
24189
  var canonicalOrigin = external_exports.string().max(2048).transform((s, ctx) => {
24016
24190
  try {
24017
- const u = new URL(s);
24018
- if (u.protocol !== "https:" && u.protocol !== "http:" || u.username !== "" || u.password !== "") {
24191
+ const u4 = new URL(s);
24192
+ if (u4.protocol !== "https:" && u4.protocol !== "http:" || u4.username !== "" || u4.password !== "") {
24019
24193
  ctx.addIssue({
24020
24194
  code: "custom",
24021
24195
  message: "origin must be scheme://host[:port] with no path/query/credentials"
24022
24196
  });
24023
24197
  return external_exports.NEVER;
24024
24198
  }
24025
- return u.origin;
24199
+ return u4.origin;
24026
24200
  } catch {
24027
24201
  ctx.addIssue({ code: "custom", message: "origin must be a valid absolute http(s) URL" });
24028
24202
  return external_exports.NEVER;
@@ -24068,17 +24242,42 @@ var StorageStateSchema = external_exports.object({
24068
24242
  } catch {
24069
24243
  return;
24070
24244
  }
24071
- s.cookies.forEach((c51, i) => {
24072
- const d2 = c51.domain.replace(/^\./, "").toLowerCase();
24073
- if (d2 !== host && !host.endsWith(`.${d2}`)) {
24245
+ s.cookies.forEach((c51, i2) => {
24246
+ const d = c51.domain.replace(/^\./, "").toLowerCase();
24247
+ if (d !== host && !host.endsWith(`.${d}`)) {
24074
24248
  ctx.addIssue({
24075
24249
  code: "custom",
24076
- path: ["cookies", i, "domain"],
24250
+ path: ["cookies", i2, "domain"],
24077
24251
  message: `cookie domain "${c51.domain}" is not the capture origin host "${host}" or a parent domain of it`
24078
24252
  });
24079
24253
  }
24080
24254
  });
24081
24255
  });
24256
+ var CredentialMfaKindValues = ["TOTP"];
24257
+ var CredentialMfaKind = external_exports.enum(CredentialMfaKindValues);
24258
+ var TotpSetupKeySchema = external_exports.string().min(1).max(TOTP_MAX_SECRET_CHARS * 4).superRefine((value, ctx) => {
24259
+ const message = totpSetupKeyError(value);
24260
+ if (message !== null) ctx.addIssue({ code: "custom", message });
24261
+ });
24262
+ var CredentialMfaConfigSchema = external_exports.object({
24263
+ kind: external_exports.literal("TOTP"),
24264
+ // Both bounds come from the SAME constant the parser clamps to. They used
24265
+ // to be an independent `.max(500)`, which let a long otpauth label parse
24266
+ // clean, persist, and then fail this schema on read — enrolment answered
24267
+ // 200 with `mfa: null` while the seed sat in the row, and every code
24268
+ // request 422'd. One constant, one bound.
24269
+ /** Service name from the setup key's `issuer` param or label prefix. */
24270
+ issuer: external_exports.string().max(TOTP_MAX_LABEL_CHARS).nullable(),
24271
+ /** Account identifier from the setup key's label. May be an email. */
24272
+ accountName: external_exports.string().max(TOTP_MAX_LABEL_CHARS).nullable(),
24273
+ digits: external_exports.union([external_exports.literal(TOTP_DIGITS[0]), external_exports.literal(TOTP_DIGITS[1])]),
24274
+ periodSeconds: external_exports.number().int().min(TOTP_MIN_PERIOD_SECONDS).max(TOTP_MAX_PERIOD_SECONDS),
24275
+ algorithm: external_exports.enum(TOTP_ALGORITHMS)
24276
+ }).strict();
24277
+ var CredentialMfaSummarySchema = CredentialMfaConfigSchema.extend({
24278
+ /** When the factor was last enrolled or replaced. */
24279
+ enrolledAt: external_exports.coerce.date()
24280
+ }).strict();
24082
24281
  var CredentialAuthConfigSchema = external_exports.discriminatedUnion("type", [
24083
24282
  BearerAuthConfigSchema,
24084
24283
  JwtAuthConfigSchema,
@@ -24241,7 +24440,13 @@ var CredentialResponseSchema = external_exports.object({
24241
24440
  * edits — so only this field can evidence a secret change. Not secret
24242
24441
  * material: a timestamp, safe on the read path.
24243
24442
  */
24244
- secretRotatedAt: external_exports.date().nullable()
24443
+ secretRotatedAt: external_exports.date().nullable(),
24444
+ /**
24445
+ * The account's second factor, or null when it has none. NON-secret
24446
+ * parameters only — the seed lives in its own KMS envelope on the row and
24447
+ * has no reveal endpoint at all (see the reveal union below).
24448
+ */
24449
+ mfa: CredentialMfaSummarySchema.nullable()
24245
24450
  }).strict();
24246
24451
  var ListCredentialsResponseSchema = external_exports.array(CredentialResponseSchema);
24247
24452
  var UpdateCredentialRequestSchema = external_exports.object({
@@ -24262,6 +24467,15 @@ var RotateCredentialSecretRequestSchema = external_exports.discriminatedUnion("c
24262
24467
  }).strict(),
24263
24468
  external_exports.object({ credentialType: external_exports.literal("SESSION_STATE"), ...SECRET_SHAPES.SESSION_STATE }).strict()
24264
24469
  ]);
24470
+ var SetCredentialMfaRequestSchema = external_exports.object({
24471
+ kind: external_exports.literal("TOTP"),
24472
+ /** otpauth:// URI or bare base32 key. Validated by the shared parser. */
24473
+ setupKey: TotpSetupKeySchema
24474
+ }).strict();
24475
+ var CredentialMfaCodeResponseSchema = external_exports.object({
24476
+ code: external_exports.string().min(6).max(8),
24477
+ expiresInSeconds: external_exports.number().int().positive()
24478
+ }).strict();
24265
24479
  var RevealCredentialSecretResponseSchema = external_exports.discriminatedUnion("credentialType", [
24266
24480
  external_exports.object({
24267
24481
  credentialType: external_exports.literal("USERNAME_PASSWORD"),
@@ -24387,6 +24601,73 @@ var credentialContract = c9.router({
24387
24601
  500: ErrorResponseSchema
24388
24602
  }
24389
24603
  },
24604
+ // Attach or replace the account's SECOND FACTOR. Its own sub-resource for
24605
+ // the same reason rotate has one: every route that touches KMS or plaintext
24606
+ // is greppable at its own URL. PUT because the body carries the complete
24607
+ // factor — re-sending it is idempotent.
24608
+ //
24609
+ // Like rotate, and unlike delete/env-move, this is NOT subject to the
24610
+ // CREDENTIAL_IN_USE guard: enrolling MFA preserves credentialId and the
24611
+ // engagement's credential set, and mid-engagement is exactly when a target
24612
+ // that has just started enforcing MFA needs a seed attached.
24613
+ setCredentialMfa: {
24614
+ method: "PUT",
24615
+ path: "/organizations/:organizationId/environments/:environmentId/credentials/:credentialId/mfa",
24616
+ pathParams: CredentialIdParamsSchema,
24617
+ body: SetCredentialMfaRequestSchema,
24618
+ responses: {
24619
+ // Never echoes the setup key back — the standard credential shape, whose
24620
+ // `mfa` field carries the derived non-secret parameters.
24621
+ 200: CredentialResponseSchema,
24622
+ 400: ErrorResponseSchema,
24623
+ 401: ErrorResponseSchema,
24624
+ 403: ErrorResponseSchema,
24625
+ 404: ErrorResponseSchema,
24626
+ // 422 — the credential's type cannot carry a second factor
24627
+ // (errorCode CREDENTIAL_MFA_UNSUPPORTED_TYPE). See
24628
+ // MFA_CAPABLE_CREDENTIAL_TYPES.
24629
+ 422: ErrorResponseSchema,
24630
+ 500: ErrorResponseSchema
24631
+ }
24632
+ },
24633
+ // Derive the CURRENT second-factor code. POST, not GET, for the same reason
24634
+ // as reveal: it must never sit in an access log, a browser history entry, or
24635
+ // a cacheable read. Requires a user principal — a leaked trace_sk_* cannot
24636
+ // mint codes against a customer's account.
24637
+ //
24638
+ // This is the STAFF/human route (it exists so an operator can confirm a seed
24639
+ // they just pasted is the right one). The pentest agent reaches the same
24640
+ // service method over the separate run-token internal channel, never this.
24641
+ generateCredentialMfaCode: {
24642
+ method: "POST",
24643
+ path: "/organizations/:organizationId/environments/:environmentId/credentials/:credentialId/mfa/code",
24644
+ pathParams: CredentialIdParamsSchema,
24645
+ body: c9.noBody(),
24646
+ responses: {
24647
+ 200: CredentialMfaCodeResponseSchema,
24648
+ 401: ErrorResponseSchema,
24649
+ 403: ErrorResponseSchema,
24650
+ 404: ErrorResponseSchema,
24651
+ // 422 — the credential has no second factor, or its stored parameters
24652
+ // are unreadable (errorCode CREDENTIAL_MFA_NOT_ENROLLED).
24653
+ 422: ErrorResponseSchema,
24654
+ 500: ErrorResponseSchema
24655
+ }
24656
+ },
24657
+ // Remove the second factor. Idempotent: clearing a credential that has none
24658
+ // succeeds, so a caller reconciling state doesn't have to check first.
24659
+ clearCredentialMfa: {
24660
+ method: "DELETE",
24661
+ path: "/organizations/:organizationId/environments/:environmentId/credentials/:credentialId/mfa",
24662
+ pathParams: CredentialIdParamsSchema,
24663
+ responses: {
24664
+ 200: CredentialResponseSchema,
24665
+ 401: ErrorResponseSchema,
24666
+ 403: ErrorResponseSchema,
24667
+ 404: ErrorResponseSchema,
24668
+ 500: ErrorResponseSchema
24669
+ }
24670
+ },
24390
24671
  deleteCredential: {
24391
24672
  method: "DELETE",
24392
24673
  path: "/organizations/:organizationId/environments/:environmentId/credentials/:credentialId",
@@ -24515,7 +24796,7 @@ var DependencyAutocompleteResponseSchema = external_exports.object({
24515
24796
  });
24516
24797
  var ListRepoDependenciesQuerySchema = external_exports.object({
24517
24798
  search: external_exports.string().max(200).optional(),
24518
- isDirect: external_exports.enum(["true", "false"]).transform((v2) => v2 === "true").optional(),
24799
+ isDirect: external_exports.enum(["true", "false"]).transform((v) => v === "true").optional(),
24519
24800
  scope: DependencyScope.optional(),
24520
24801
  ecosystem: external_exports.enum(PackageEcosystemValues).optional(),
24521
24802
  /** Exact version match, e.g. "1.2.3". */
@@ -27922,7 +28203,7 @@ var CreateAttestationRequestSchema = external_exports.object({
27922
28203
  classification: AttestationClassification,
27923
28204
  version: external_exports.string().min(1).max(50),
27924
28205
  scopeText: external_exports.string().max(4e3)
27925
- }).refine((d2) => d2.testingWindowStart <= d2.testingWindowEnd, {
28206
+ }).refine((d) => d.testingWindowStart <= d.testingWindowEnd, {
27926
28207
  message: "testingWindowStart must be on or before testingWindowEnd",
27927
28208
  path: ["testingWindowEnd"]
27928
28209
  });
@@ -28491,7 +28772,7 @@ var FindingRewritesJsonSchema = external_exports.object({
28491
28772
  // generated 1:1 against published PentestFinding rows; a payload over
28492
28773
  // this cap would indicate corruption.
28493
28774
  rewrites: external_exports.array(FindingRewriteJsonSchema).max(1e3)
28494
- }).refine((v2) => new Set(v2.rewrites.map((r) => r.displayId)).size === v2.rewrites.length, {
28775
+ }).refine((v) => new Set(v.rewrites.map((r2) => r2.displayId)).size === v.rewrites.length, {
28495
28776
  // The renderer's merge step (`mergeRewritesIntoFindings` in
28496
28777
  // pentest-report-pdf.service.ts) keys by displayId; a duplicate would
28497
28778
  // silently overwrite one finding's rewrite with another. Reject at
@@ -29180,7 +29461,7 @@ var CurateFindingEvidenceRequestSchema = external_exports.object({
29180
29461
  displayOrder: external_exports.number().int().min(0).optional(),
29181
29462
  // VIDEO only: staff edit the stepped PoC chapters (null clears them).
29182
29463
  videoSteps: VideoStepsSchema.nullable().optional()
29183
- }).strict().refine((v2) => Object.keys(v2).length > 0, {
29464
+ }).strict().refine((v) => Object.keys(v).length > 0, {
29184
29465
  message: "At least one curation field must be provided"
29185
29466
  });
29186
29467
  var MAX_STAFF_EVIDENCE_UPLOAD_BYTES = 256 * 1024 * 1024;
@@ -31378,7 +31659,7 @@ var CreateTestIntegrationRequestSchema = external_exports.object({
31378
31659
  notes: external_exports.string().max(NOTES_MAX).optional(),
31379
31660
  apiKey: external_exports.string().min(1).max(4096).optional(),
31380
31661
  login: TestIntegrationLoginSchema.optional()
31381
- }).strict().refine((v2) => v2.apiKey !== void 0 || v2.login !== void 0, {
31662
+ }).strict().refine((v) => v.apiKey !== void 0 || v.login !== void 0, {
31382
31663
  message: "At least one of apiKey or login is required."
31383
31664
  });
31384
31665
  var UpdateTestIntegrationRequestSchema = external_exports.object({
@@ -32224,14 +32505,14 @@ function isPrivateIpv4Literal(hostname3) {
32224
32505
  if (octets.length !== 4 || octets.some((octet) => Number.isNaN(octet))) {
32225
32506
  return false;
32226
32507
  }
32227
- const [a, b2] = octets;
32228
- if (a === void 0 || b2 === void 0) {
32508
+ const [a2, b] = octets;
32509
+ if (a2 === void 0 || b === void 0) {
32229
32510
  return false;
32230
32511
  }
32231
- if (a === 127 || a === 10 || a === 0 || a >= 224) return true;
32232
- if (a === 172 && b2 >= 16 && b2 <= 31) return true;
32233
- if (a === 192 && b2 === 168) return true;
32234
- if (a === 169 && b2 === 254) return true;
32512
+ if (a2 === 127 || a2 === 10 || a2 === 0 || a2 >= 224) return true;
32513
+ if (a2 === 172 && b >= 16 && b <= 31) return true;
32514
+ if (a2 === 192 && b === 168) return true;
32515
+ if (a2 === 169 && b === 254) return true;
32235
32516
  return false;
32236
32517
  }
32237
32518
  function isPrivateIpv6Literal(hostname3) {
@@ -33025,6 +33306,24 @@ var AgentSessionLoginCodeResponseSchema = external_exports.object({
33025
33306
  value: external_exports.string().optional(),
33026
33307
  receivedAt: external_exports.coerce.date().optional()
33027
33308
  });
33309
+ var AgentSessionTotpCodeRequestSchema = external_exports.object({
33310
+ runVersion: external_exports.number().int().nonnegative(),
33311
+ /** Which account (by `Credential.label`); omit if exactly one is enrolled. */
33312
+ credentialLabel: external_exports.string().min(1).max(200).optional()
33313
+ });
33314
+ var AgentSessionTotpCodeResponseSchema = external_exports.object({
33315
+ /** The account the code belongs to, echoed so the agent can name it. */
33316
+ credentialLabel: external_exports.string().max(200),
33317
+ /** The current code. 6 or 8 digits, zero-padded. */
33318
+ code: external_exports.string().min(6).max(8),
33319
+ /**
33320
+ * Whole seconds the code stays valid. Guaranteed to leave usable time: the
33321
+ * api waits for the next window rather than returning a code that is about to
33322
+ * expire, so an agent that submits promptly is never rejected as stale (which
33323
+ * it would otherwise misread as a wrong password).
33324
+ */
33325
+ expiresInSeconds: external_exports.number().int().positive()
33326
+ });
33028
33327
  var AgentSessionListInboxMessagesRequestSchema = external_exports.object({
33029
33328
  runVersion: external_exports.number().int().nonnegative(),
33030
33329
  /** Which account's inbox (by `Credential.label`); omit if exactly one is readable. */
@@ -33256,8 +33555,8 @@ var OperatorRecordFindingRetestRequestSchema = CreatePentestFindingRetestRequest
33256
33555
  pentestFindingId: external_exports.uuid(),
33257
33556
  outcome: RetestOutcome,
33258
33557
  verification: external_exports.string().min(1).max(8e3).optional()
33259
- }).superRefine((v2, ctx) => {
33260
- if (v2.outcome !== "FIXED" && v2.verification !== void 0) {
33558
+ }).superRefine((v, ctx) => {
33559
+ if (v.outcome !== "FIXED" && v.verification !== void 0) {
33261
33560
  ctx.addIssue({
33262
33561
  code: "custom",
33263
33562
  message: "verification report prose is only allowed when outcome is FIXED",
@@ -33275,15 +33574,15 @@ var OperatorEditFindingRetestRequestSchema = external_exports.object({
33275
33574
  outcome: RetestOutcome.optional(),
33276
33575
  notes: external_exports.string().trim().min(1).max(1e4).optional(),
33277
33576
  verification: external_exports.string().min(1).max(8e3).optional()
33278
- }).superRefine((v2, ctx) => {
33279
- if (v2.outcome === void 0 && v2.notes === void 0) {
33577
+ }).superRefine((v, ctx) => {
33578
+ if (v.outcome === void 0 && v.notes === void 0) {
33280
33579
  ctx.addIssue({
33281
33580
  code: "custom",
33282
33581
  message: "provide outcome, notes, or both \u2014 an edit must change something",
33283
33582
  path: ["notes"]
33284
33583
  });
33285
33584
  }
33286
- if (v2.verification !== void 0 && v2.outcome !== "FIXED") {
33585
+ if (v.verification !== void 0 && v.outcome !== "FIXED") {
33287
33586
  ctx.addIssue({
33288
33587
  code: "custom",
33289
33588
  message: "verification report prose is only allowed when outcome is FIXED",
@@ -33625,6 +33924,33 @@ var agentSessionInternalContract = c43.router({
33625
33924
  503: ErrorResponseSchema
33626
33925
  }
33627
33926
  },
33927
+ // get_totp_code: derive the CURRENT second-factor code for one of the run's
33928
+ // accounts. Same resolution + ownership gate as login-code (org + pentest
33929
+ // from the run token, never from agent input).
33930
+ //
33931
+ // The seed stays in the api: the launch resolver ships only a `mfa` marker on
33932
+ // the credential entry, never the key. What crosses this wire is a code that
33933
+ // is single-use and dead within a period — which is why this is a JIT call
33934
+ // rather than another value in the task env.
33935
+ totpCode: {
33936
+ method: "POST",
33937
+ path: "/internal/v1/agent-sessions/:agentSessionId/totp-code",
33938
+ pathParams: AgentSessionInternalParamsSchema,
33939
+ body: AgentSessionTotpCodeRequestSchema,
33940
+ responses: {
33941
+ 200: AgentSessionTotpCodeResponseSchema,
33942
+ // Ambiguous credentialLabel (several enrolled accounts, none named), or a
33943
+ // label that matches more than one environment's credential.
33944
+ 400: ErrorResponseSchema,
33945
+ 401: ErrorResponseSchema,
33946
+ 409: ErrorResponseSchema,
33947
+ // No enrolled account on the pentest's environments under this org.
33948
+ 404: ErrorResponseSchema,
33949
+ // The row claims a factor but its stored parameters are unusable.
33950
+ 422: ErrorResponseSchema,
33951
+ 500: ErrorResponseSchema
33952
+ }
33953
+ },
33628
33954
  // list_emails: newest-first metadata for the pentest's readable Trace-managed
33629
33955
  // inbox. Same resolution + ownership gate as login-code (org + pentest
33630
33956
  // environments + provider-side inbox tenancy); no bodies cross the wire here.
@@ -35886,21 +36212,21 @@ function filterRepositories(repositories, options) {
35886
36212
  });
35887
36213
  }
35888
36214
  function parseListLimit(value) {
35889
- const n = Number(value);
35890
- if (!Number.isInteger(n) || n < 1) {
36215
+ const n3 = Number(value);
36216
+ if (!Number.isInteger(n3) || n3 < 1) {
35891
36217
  throw new Error("--limit must be a positive integer");
35892
36218
  }
35893
- if (n > MAX_LIMIT) {
36219
+ if (n3 > MAX_LIMIT) {
35894
36220
  throw new Error(`--limit cannot exceed ${MAX_LIMIT}`);
35895
36221
  }
35896
- return n;
36222
+ return n3;
35897
36223
  }
35898
36224
  function parseListPage(value) {
35899
- const n = Number(value);
35900
- if (!Number.isInteger(n) || n < 1) {
36225
+ const n3 = Number(value);
36226
+ if (!Number.isInteger(n3) || n3 < 1) {
35901
36227
  throw new Error("--page must be a positive integer");
35902
36228
  }
35903
- return n;
36229
+ return n3;
35904
36230
  }
35905
36231
  function paginateResults(items, options) {
35906
36232
  if (options.all) {
@@ -35958,11 +36284,11 @@ function buildRepositoriesTable(repositories) {
35958
36284
  ]
35959
36285
  );
35960
36286
  const colWidths = headers.map(
35961
- (h2, i) => Math.max(h2.length, ...rows.map((r) => (r[i] ?? "").length))
36287
+ (h2, i2) => Math.max(h2.length, ...rows.map((r2) => (r2[i2] ?? "").length))
35962
36288
  );
35963
- const pad = (s, w3) => s.padEnd(w3);
35964
- const headerLine = headers.map((h2, i) => pad(h2, colWidths[i] ?? h2.length)).join(" ");
35965
- const rowLines = rows.map((row) => row.map((cell, i) => pad(cell, colWidths[i] ?? 0)).join(" "));
36289
+ const pad = (s, w) => s.padEnd(w);
36290
+ const headerLine = headers.map((h2, i2) => pad(h2, colWidths[i2] ?? h2.length)).join(" ");
36291
+ const rowLines = rows.map((row) => row.map((cell, i2) => pad(cell, colWidths[i2] ?? 0)).join(" "));
35966
36292
  return { headerLine, rowLines };
35967
36293
  }
35968
36294
  function collectFilterExpression(value, previous) {
@@ -36186,7 +36512,7 @@ async function runRepositoryListCommand(options) {
36186
36512
  await runInteractivePager({
36187
36513
  items: displayedRepositories,
36188
36514
  header: headerLine,
36189
- renderItem: (_repo, i) => [rowLines[i] ?? ""],
36515
+ renderItem: (_repo, i2) => [rowLines[i2] ?? ""],
36190
36516
  disabled: options.pager === false
36191
36517
  });
36192
36518
  printPaginationHint(
@@ -36226,11 +36552,11 @@ async function runDependencyFilter(organizationId, options) {
36226
36552
  }
36227
36553
  for (const repo of pkg.repositories) {
36228
36554
  const existing = repoMap.get(repo.repositoryId);
36229
- const versionStrings = repo.versions.map((v2) => v2.version);
36555
+ const versionStrings = repo.versions.map((v) => v.version);
36230
36556
  if (existing) {
36231
- for (const v2 of versionStrings) {
36232
- if (!existing.versions.includes(v2)) {
36233
- existing.versions.push(v2);
36557
+ for (const v of versionStrings) {
36558
+ if (!existing.versions.includes(v)) {
36559
+ existing.versions.push(v);
36234
36560
  }
36235
36561
  }
36236
36562
  } else {
@@ -36559,14 +36885,14 @@ async function runSetScanningBranchCommand(repoUrl, options) {
36559
36885
  console.error(`Failed to list repositories (status ${listResult2.status}).`);
36560
36886
  process.exit(1);
36561
36887
  }
36562
- const ids = listResult2.body.map((r) => r.repositoryId);
36888
+ const ids = listResult2.body.map((r2) => r2.repositoryId);
36563
36889
  if (ids.length === 0) {
36564
36890
  console.log("No repositories found.");
36565
36891
  return;
36566
36892
  }
36567
36893
  const chunks = [];
36568
- for (let i = 0; i < ids.length; i += 100) {
36569
- chunks.push(ids.slice(i, i + 100));
36894
+ for (let i2 = 0; i2 < ids.length; i2 += 100) {
36895
+ chunks.push(ids.slice(i2, i2 + 100));
36570
36896
  }
36571
36897
  const allResults = [];
36572
36898
  for (const chunk of chunks) {
@@ -36586,19 +36912,19 @@ async function runSetScanningBranchCommand(repoUrl, options) {
36586
36912
  }
36587
36913
  allResults.push(...result2.body.results);
36588
36914
  }
36589
- const urlById = new Map(listResult2.body.map((r) => [r.repositoryId, r.repositoryUrl]));
36915
+ const urlById = new Map(listResult2.body.map((r2) => [r2.repositoryId, r2.repositoryUrl]));
36590
36916
  if (options.output === "json") {
36591
36917
  console.log(JSON.stringify(allResults, null, 2));
36592
36918
  return;
36593
36919
  }
36594
36920
  console.log("repositoryUrl status relabeledCount error");
36595
- for (const r of allResults) {
36921
+ for (const r2 of allResults) {
36596
36922
  console.log(
36597
36923
  [
36598
- urlById.get(r.repositoryId) ?? r.repositoryId,
36599
- r.status,
36600
- r.relabeledVulnerabilityCount ?? "",
36601
- r.errorMessage ?? ""
36924
+ urlById.get(r2.repositoryId) ?? r2.repositoryId,
36925
+ r2.status,
36926
+ r2.relabeledVulnerabilityCount ?? "",
36927
+ r2.errorMessage ?? ""
36602
36928
  ].join(" ")
36603
36929
  );
36604
36930
  }
@@ -36618,7 +36944,7 @@ async function runSetScanningBranchCommand(repoUrl, options) {
36618
36944
  }
36619
36945
  const normalizedTarget = normalizeForMatching(targetUrl);
36620
36946
  const match = listResult.body.find(
36621
- (r) => normalizeForMatching(r.repositoryUrl) === normalizedTarget
36947
+ (r2) => normalizeForMatching(r2.repositoryUrl) === normalizedTarget
36622
36948
  );
36623
36949
  if (!match) {
36624
36950
  console.error(`Repository not found: ${targetUrl}`);
@@ -36922,12 +37248,12 @@ function printApplicationsTsv(apps) {
36922
37248
  }
36923
37249
  }
36924
37250
  function buildApplicationsTable(apps) {
36925
- const cells = apps.map((a) => ({
36926
- id: a.applicationId,
36927
- name: sanitizeDisplay(a.name),
36928
- type: a.type,
36929
- repos: String(a.repositories.length),
36930
- url: a.applicationUrl ? sanitizeDisplay(a.applicationUrl) : "\u2014"
37251
+ const cells = apps.map((a2) => ({
37252
+ id: a2.applicationId,
37253
+ name: sanitizeDisplay(a2.name),
37254
+ type: a2.type,
37255
+ repos: String(a2.repositories.length),
37256
+ url: a2.applicationUrl ? sanitizeDisplay(a2.applicationUrl) : "\u2014"
36931
37257
  }));
36932
37258
  const idWidth = Math.max(2, ...cells.map((c51) => c51.id.length));
36933
37259
  const nameWidth = Math.max(4, ...cells.map((c51) => c51.name.length));
@@ -36943,16 +37269,16 @@ function formatLinkRole(role, roleLabel) {
36943
37269
  }
36944
37270
  function sortApplicationRepositoryLinks(links) {
36945
37271
  return [...links].sort(
36946
- (a, b2) => a.repositoryName.localeCompare(b2.repositoryName) || a.repositoryId.localeCompare(b2.repositoryId)
37272
+ (a2, b) => a2.repositoryName.localeCompare(b.repositoryName) || a2.repositoryId.localeCompare(b.repositoryId)
36947
37273
  );
36948
37274
  }
36949
37275
  function buildApplicationRepositoriesTable(links) {
36950
- const cells = links.map((l) => ({
36951
- name: sanitizeDisplay(l.repositoryName),
36952
- scan: l.scanEnabled ? "yes" : "no",
36953
- role: sanitizeDisplay(formatLinkRole(l.role, l.roleLabel)),
36954
- path: l.repositoryPath ? sanitizeDisplay(l.repositoryPath) : "\u2014",
36955
- status: formatStatus(l.repositoryStatus)
37276
+ const cells = links.map((l2) => ({
37277
+ name: sanitizeDisplay(l2.repositoryName),
37278
+ scan: l2.scanEnabled ? "yes" : "no",
37279
+ role: sanitizeDisplay(formatLinkRole(l2.role, l2.roleLabel)),
37280
+ path: l2.repositoryPath ? sanitizeDisplay(l2.repositoryPath) : "\u2014",
37281
+ status: formatStatus(l2.repositoryStatus)
36956
37282
  }));
36957
37283
  const nameWidth = Math.max(10, ...cells.map((c51) => c51.name.length));
36958
37284
  const roleWidth = Math.max(4, ...cells.map((c51) => c51.role.length));
@@ -36964,7 +37290,7 @@ function buildApplicationRepositoriesTable(links) {
36964
37290
  return { header, rows };
36965
37291
  }
36966
37292
  function scanDisabledWarning(links) {
36967
- const disabled = links.filter((l) => !l.scanEnabled).length;
37293
+ const disabled = links.filter((l2) => !l2.scanEnabled).length;
36968
37294
  if (disabled === 0) {
36969
37295
  return null;
36970
37296
  }
@@ -37037,7 +37363,7 @@ async function runCreate(name, options) {
37037
37363
  if (!type) {
37038
37364
  console.error(
37039
37365
  colorError(
37040
- `Invalid --type '${options.type}'. Use one of: ${ApplicationTypeValues.map((t) => t.toLowerCase().replace(/_/g, "-")).join(", ")}.`
37366
+ `Invalid --type '${options.type}'. Use one of: ${ApplicationTypeValues.map((t2) => t2.toLowerCase().replace(/_/g, "-")).join(", ")}.`
37041
37367
  )
37042
37368
  );
37043
37369
  process.exit(1);
@@ -37098,7 +37424,7 @@ async function runList(options) {
37098
37424
  await runInteractivePager({
37099
37425
  items: apps,
37100
37426
  header,
37101
- renderItem: (_app, i) => [rows[i] ?? ""],
37427
+ renderItem: (_app, i2) => [rows[i2] ?? ""],
37102
37428
  disabled: options.pager === false
37103
37429
  });
37104
37430
  }
@@ -37147,7 +37473,7 @@ async function runRepos(applicationId, options) {
37147
37473
  await runInteractivePager({
37148
37474
  items: links,
37149
37475
  header,
37150
- renderItem: (_link, i) => [rows[i] ?? ""],
37476
+ renderItem: (_link, i2) => [rows[i2] ?? ""],
37151
37477
  disabled: options.pager === false
37152
37478
  });
37153
37479
  const warning = scanDisabledWarning(links);
@@ -37290,11 +37616,11 @@ function createApplicationCommand() {
37290
37616
  // src/auth/commands.ts
37291
37617
  import { createInterface as createInterface3 } from "readline/promises";
37292
37618
 
37293
- // ../../node_modules/.bun/@clack+core@1.3.0/node_modules/@clack/core/dist/index.mjs
37294
- import { styleText as v } from "util";
37295
- import { stdout as S, stdin as D } from "process";
37296
- import * as b from "readline";
37297
- import E from "readline";
37619
+ // ../../node_modules/.bun/@clack+core@1.4.3/node_modules/@clack/core/dist/index.mjs
37620
+ import { styleText } from "util";
37621
+ import { stdout, stdin } from "process";
37622
+ import * as l from "readline";
37623
+ import l__default from "readline";
37298
37624
 
37299
37625
  // ../../node_modules/.bun/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
37300
37626
  var getCodePointsLength = /* @__PURE__ */ (() => {
@@ -37382,8 +37708,8 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
37382
37708
  if (index >= length) {
37383
37709
  break outer;
37384
37710
  }
37385
- for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
37386
- const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
37711
+ for (let i2 = 0, l2 = PARSE_BLOCKS.length; i2 < l2; i2++) {
37712
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
37387
37713
  BLOCK_RE.lastIndex = index;
37388
37714
  if (BLOCK_RE.test(input)) {
37389
37715
  lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
@@ -37586,8 +37912,8 @@ var exec = (string4, columns, options = {}) => {
37586
37912
  }
37587
37913
  const preString = rows.join("\n");
37588
37914
  let inSurrogate = false;
37589
- for (let i = 0; i < preString.length; i++) {
37590
- const character = preString[i];
37915
+ for (let i2 = 0; i2 < preString.length; i2++) {
37916
+ const character = preString[i2];
37591
37917
  returnValue += character;
37592
37918
  if (!inSurrogate) {
37593
37919
  inSurrogate = character >= "\uD800" && character <= "\uDBFF";
@@ -37598,7 +37924,7 @@ var exec = (string4, columns, options = {}) => {
37598
37924
  inSurrogate = false;
37599
37925
  }
37600
37926
  if (character === ESC || character === CSI) {
37601
- GROUP_REGEX.lastIndex = i + 1;
37927
+ GROUP_REGEX.lastIndex = i2 + 1;
37602
37928
  const groupsResult = GROUP_REGEX.exec(preString);
37603
37929
  const groups = groupsResult?.groups;
37604
37930
  if (groups?.code !== void 0) {
@@ -37608,7 +37934,7 @@ var exec = (string4, columns, options = {}) => {
37608
37934
  escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
37609
37935
  }
37610
37936
  }
37611
- if (preString[i + 1] === "\n") {
37937
+ if (preString[i2 + 1] === "\n") {
37612
37938
  if (escapeUrl) {
37613
37939
  returnValue += wrapAnsiHyperlink("");
37614
37940
  }
@@ -37632,66 +37958,134 @@ function wrapAnsi(string4, columns, options) {
37632
37958
  return String(string4).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
37633
37959
  }
37634
37960
 
37635
- // ../../node_modules/.bun/@clack+core@1.3.0/node_modules/@clack/core/dist/index.mjs
37961
+ // ../../node_modules/.bun/@clack+core@1.4.3/node_modules/@clack/core/dist/index.mjs
37636
37962
  var import_sisteransi = __toESM(require_src(), 1);
37637
- import { ReadStream as O } from "tty";
37638
- function d(r, t, s) {
37639
- if (!s.some((o) => !o.disabled)) return r;
37640
- const e2 = r + t, i = Math.max(s.length - 1, 0), n = e2 < 0 ? i : e2 > i ? 0 : e2;
37641
- return s[n].disabled ? d(n, t < 0 ? -1 : 1, s) : n;
37642
- }
37643
- function I(r, t, s, e2) {
37644
- const i = e2.split(`
37963
+ import { ReadStream } from "tty";
37964
+ function findCursor(s, o2, l2) {
37965
+ if (!l2.some((r2) => !r2.disabled))
37966
+ return s;
37967
+ const t2 = s + o2, n3 = Math.max(l2.length - 1, 0), e = t2 < 0 ? n3 : t2 > n3 ? 0 : t2;
37968
+ return l2[e]?.disabled ? findCursor(e, o2 < 0 ? -1 : 1, l2) : e;
37969
+ }
37970
+ function findTextCursor(s, o2, l2, i2) {
37971
+ const t2 = i2.split(`
37645
37972
  `);
37646
- let n = 0, o = r;
37647
- for (const a of i) {
37648
- if (o <= a.length) break;
37649
- o -= a.length + 1, n++;
37650
- }
37651
- for (n = Math.max(0, Math.min(i.length - 1, n + s)), o = Math.min(o, i[n].length) + t; o < 0 && n > 0; ) n--, o += i[n].length + 1;
37652
- for (; o > i[n].length && n < i.length - 1; ) o -= i[n].length + 1, n++;
37653
- o = Math.max(0, Math.min(i[n].length, o));
37654
- let u = 0;
37655
- for (let a = 0; a < n; a++) u += i[a].length + 1;
37656
- return u + o;
37657
- }
37658
- var G = ["up", "down", "left", "right", "space", "enter", "cancel"];
37659
- var K = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
37660
- var h = { actions: new Set(G), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...K], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
37661
- function C(r, t) {
37662
- if (typeof r == "string") return h.aliases.get(r) === t;
37663
- for (const s of r) if (s !== void 0 && C(s, t)) return true;
37973
+ let n3 = 0, e = s;
37974
+ for (const r2 of t2) {
37975
+ if (e <= r2.length)
37976
+ break;
37977
+ e -= r2.length + 1, n3++;
37978
+ }
37979
+ for (n3 = Math.max(0, Math.min(t2.length - 1, n3 + l2)), e = Math.min(e, t2[n3].length) + o2; e < 0 && n3 > 0; )
37980
+ n3--, e += t2[n3].length + 1;
37981
+ for (; e > t2[n3].length && n3 < t2.length - 1; )
37982
+ e -= t2[n3].length + 1, n3++;
37983
+ e = Math.max(0, Math.min(t2[n3].length, e));
37984
+ let h2 = 0;
37985
+ for (let r2 = 0; r2 < n3; r2++)
37986
+ h2 += t2[r2].length + 1;
37987
+ return h2 + e;
37988
+ }
37989
+ var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
37990
+ var t = [
37991
+ "January",
37992
+ "February",
37993
+ "March",
37994
+ "April",
37995
+ "May",
37996
+ "June",
37997
+ "July",
37998
+ "August",
37999
+ "September",
38000
+ "October",
38001
+ "November",
38002
+ "December"
38003
+ ];
38004
+ var settings = {
38005
+ actions: new Set(a$1),
38006
+ aliases: /* @__PURE__ */ new Map([
38007
+ // vim support
38008
+ ["k", "up"],
38009
+ ["j", "down"],
38010
+ ["h", "left"],
38011
+ ["l", "right"],
38012
+ ["", "cancel"],
38013
+ // opinionated defaults!
38014
+ ["escape", "cancel"]
38015
+ ]),
38016
+ messages: {
38017
+ cancel: "Canceled",
38018
+ error: "Something went wrong"
38019
+ },
38020
+ withGuide: true,
38021
+ date: {
38022
+ monthNames: [...t],
38023
+ messages: {
38024
+ required: "Please enter a valid date",
38025
+ invalidMonth: "There are only 12 months in a year",
38026
+ invalidDay: (n3, e) => `There are only ${n3} days in ${e}`,
38027
+ afterMin: (n3) => `Date must be on or after ${n3.toISOString().slice(0, 10)}`,
38028
+ beforeMax: (n3) => `Date must be on or before ${n3.toISOString().slice(0, 10)}`
38029
+ }
38030
+ }
38031
+ };
38032
+ function isActionKey(n3, e) {
38033
+ if (typeof n3 == "string")
38034
+ return settings.aliases.get(n3) === e;
38035
+ for (const s of n3)
38036
+ if (s !== void 0 && isActionKey(s, e))
38037
+ return true;
37664
38038
  return false;
37665
38039
  }
37666
- function z3(r, t) {
37667
- if (r === t) return;
37668
- const s = r.split(`
37669
- `), e2 = t.split(`
37670
- `), i = Math.max(s.length, e2.length), n = [];
37671
- for (let o = 0; o < i; o++) s[o] !== e2[o] && n.push(o);
37672
- return { lines: n, numLinesBefore: s.length, numLinesAfter: e2.length, numLines: i };
37673
- }
37674
- var Y = globalThis.process.platform.startsWith("win");
37675
- var k = /* @__PURE__ */ Symbol("clack:cancel");
37676
- function q(r) {
37677
- return r === k;
37678
- }
37679
- function w(r, t) {
37680
- const s = r;
37681
- s.isTTY && s.setRawMode(t);
37682
- }
37683
- var A = (r) => "columns" in r && typeof r.columns == "number" ? r.columns : 80;
37684
- var L = (r) => "rows" in r && typeof r.rows == "number" ? r.rows : 20;
37685
- function W(r, t, s, e2 = s, i) {
37686
- const n = A(r ?? S);
37687
- return wrapAnsi(t, n - s.length, { hard: true, trim: false }).split(`
37688
- `).map((o, u) => {
37689
- const a = i ? i(o, u) : o;
37690
- return `${u === 0 ? e2 : s}${a}`;
38040
+ function diffLines(i2, s) {
38041
+ if (i2 === s) return;
38042
+ const e = i2.split(`
38043
+ `), t2 = s.split(`
38044
+ `), r2 = Math.max(e.length, t2.length), f = [];
38045
+ for (let n3 = 0; n3 < r2; n3++)
38046
+ e[n3] !== t2[n3] && f.push(n3);
38047
+ return {
38048
+ lines: f,
38049
+ numLinesBefore: e.length,
38050
+ numLinesAfter: t2.length,
38051
+ numLines: r2
38052
+ };
38053
+ }
38054
+ var R = globalThis.process.platform.startsWith("win");
38055
+ var CANCEL_SYMBOL = /* @__PURE__ */ Symbol("clack:cancel");
38056
+ function isCancel(e) {
38057
+ return e === CANCEL_SYMBOL;
38058
+ }
38059
+ function setRawMode(e, r2) {
38060
+ const o2 = e;
38061
+ o2.isTTY && o2.setRawMode(r2);
38062
+ }
38063
+ var getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
38064
+ var getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
38065
+ function wrapTextWithPrefix(e, r2, o2, t2 = o2, s = o2, n3) {
38066
+ const f = getColumns(e ?? stdout);
38067
+ return wrapAnsi(r2, f - o2.length, {
38068
+ hard: true,
38069
+ trim: false
38070
+ }).split(`
38071
+ `).map((c51, i2, m2) => {
38072
+ const d = n3 ? n3(c51, i2) : c51;
38073
+ return i2 === 0 ? `${t2}${d}` : i2 === m2.length - 1 ? `${s}${d}` : `${o2}${d}`;
37691
38074
  }).join(`
37692
38075
  `);
37693
38076
  }
37694
- var p = class {
38077
+ function runValidation(e, n3) {
38078
+ if ("~standard" in e) {
38079
+ const a2 = e["~standard"].validate(n3);
38080
+ if (a2 instanceof Promise)
38081
+ throw new TypeError(
38082
+ "Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic."
38083
+ );
38084
+ return a2.issues?.at(0)?.message;
38085
+ }
38086
+ return e(n3);
38087
+ }
38088
+ var V = class {
37695
38089
  input;
37696
38090
  output;
37697
38091
  _abortSignal;
@@ -37706,247 +38100,310 @@ var p = class {
37706
38100
  error = "";
37707
38101
  value;
37708
38102
  userInput = "";
37709
- constructor(t, s = true) {
37710
- const { input: e2 = D, output: i = S, render: n, signal: o, ...u } = t;
37711
- this.opts = u, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = o, this.input = e2, this.output = i;
38103
+ constructor(t2, e = true) {
38104
+ const { input: i2 = stdin, output: n3 = stdout, render: s, signal: r2, ...o2 } = t2;
38105
+ this.opts = o2, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r2, this.input = i2, this.output = n3;
37712
38106
  }
38107
+ /**
38108
+ * Unsubscribe all listeners
38109
+ */
37713
38110
  unsubscribe() {
37714
38111
  this._subscribers.clear();
37715
38112
  }
37716
- setSubscriber(t, s) {
37717
- const e2 = this._subscribers.get(t) ?? [];
37718
- e2.push(s), this._subscribers.set(t, e2);
38113
+ /**
38114
+ * Set a subscriber with opts
38115
+ * @param event - The event name
38116
+ */
38117
+ setSubscriber(t2, e) {
38118
+ const i2 = this._subscribers.get(t2) ?? [];
38119
+ i2.push(e), this._subscribers.set(t2, i2);
37719
38120
  }
37720
- on(t, s) {
37721
- this.setSubscriber(t, { cb: s });
38121
+ /**
38122
+ * Subscribe to an event
38123
+ * @param event - The event name
38124
+ * @param cb - The callback
38125
+ */
38126
+ on(t2, e) {
38127
+ this.setSubscriber(t2, { cb: e });
37722
38128
  }
37723
- once(t, s) {
37724
- this.setSubscriber(t, { cb: s, once: true });
38129
+ /**
38130
+ * Subscribe to an event once
38131
+ * @param event - The event name
38132
+ * @param cb - The callback
38133
+ */
38134
+ once(t2, e) {
38135
+ this.setSubscriber(t2, { cb: e, once: true });
37725
38136
  }
37726
- emit(t, ...s) {
37727
- const e2 = this._subscribers.get(t) ?? [], i = [];
37728
- for (const n of e2) n.cb(...s), n.once && i.push(() => e2.splice(e2.indexOf(n), 1));
37729
- for (const n of i) n();
38137
+ /**
38138
+ * Emit an event with data
38139
+ * @param event - The event name
38140
+ * @param data - The data to pass to the callback
38141
+ */
38142
+ emit(t2, ...e) {
38143
+ const i2 = this._subscribers.get(t2) ?? [], n3 = [];
38144
+ for (const s of i2)
38145
+ s.cb(...e), s.once && n3.push(() => i2.splice(i2.indexOf(s), 1));
38146
+ for (const s of n3)
38147
+ s();
37730
38148
  }
37731
38149
  prompt() {
37732
- return new Promise((t) => {
38150
+ return new Promise((t2) => {
37733
38151
  if (this._abortSignal) {
37734
- if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(k);
37735
- this._abortSignal.addEventListener("abort", () => {
37736
- this.state = "cancel", this.close();
37737
- }, { once: true });
38152
+ if (this._abortSignal.aborted)
38153
+ return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
38154
+ this._abortSignal.addEventListener(
38155
+ "abort",
38156
+ () => {
38157
+ this.state = "cancel", this.close();
38158
+ },
38159
+ { once: true }
38160
+ );
37738
38161
  }
37739
- this.rl = E.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), w(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
37740
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
38162
+ this.rl = l__default.createInterface({
38163
+ input: this.input,
38164
+ tabSize: 2,
38165
+ prompt: "",
38166
+ escapeCodeTimeout: 50,
38167
+ terminal: true
38168
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
38169
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
37741
38170
  }), this.once("cancel", () => {
37742
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(k);
38171
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
37743
38172
  });
37744
38173
  });
37745
38174
  }
37746
- _isActionKey(t, s) {
37747
- return t === " ";
38175
+ _isActionKey(t2, e) {
38176
+ return t2 === " ";
37748
38177
  }
37749
- _shouldSubmit(t, s) {
38178
+ _shouldSubmit(t2, e) {
37750
38179
  return true;
37751
38180
  }
37752
- _setValue(t) {
37753
- this.value = t, this.emit("value", this.value);
38181
+ _setValue(t2) {
38182
+ this.value = t2, this.emit("value", this.value);
37754
38183
  }
37755
- _setUserInput(t, s) {
37756
- this.userInput = t ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
38184
+ _setUserInput(t2, e) {
38185
+ this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
37757
38186
  }
37758
38187
  _clearUserInput() {
37759
38188
  this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
37760
38189
  }
37761
- onKeypress(t, s) {
37762
- if (this._track && s.name !== "return" && (s.name && this._isActionKey(t, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && h.aliases.has(s.name) && this.emit("cursor", h.aliases.get(s.name)), h.actions.has(s.name) && this.emit("cursor", s.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), s), s?.name === "return" && this._shouldSubmit(t, s)) {
38190
+ onKeypress(t2, e) {
38191
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
37763
38192
  if (this.opts.validate) {
37764
- const e2 = this.opts.validate(this.value);
37765
- e2 && (this.error = e2 instanceof Error ? e2.message : e2, this.state = "error", this.rl?.write(this.userInput));
38193
+ const i2 = runValidation(this.opts.validate, this.value);
38194
+ i2 && (this.error = i2 instanceof Error ? i2.message : i2, this.state = "error", this.rl?.write(this.userInput));
37766
38195
  }
37767
38196
  this.state !== "error" && (this.state = "submit");
37768
38197
  }
37769
- C([t, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
38198
+ isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
37770
38199
  }
37771
38200
  close() {
37772
38201
  this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
37773
- `), w(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
38202
+ `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
37774
38203
  }
37775
38204
  restoreCursor() {
37776
- const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
38205
+ const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
37777
38206
  `).length - 1;
37778
- this.output.write(import_sisteransi.cursor.move(-999, t * -1));
38207
+ this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
37779
38208
  }
37780
38209
  render() {
37781
- const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
37782
- if (t !== this._prevFrame) {
37783
- if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
38210
+ const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
38211
+ hard: true,
38212
+ trim: false
38213
+ });
38214
+ if (t2 !== this._prevFrame) {
38215
+ if (this.state === "initial")
38216
+ this.output.write(import_sisteransi.cursor.hide);
37784
38217
  else {
37785
- const s = z3(this._prevFrame, t), e2 = L(this.output);
37786
- if (this.restoreCursor(), s) {
37787
- const i = Math.max(0, s.numLinesAfter - e2), n = Math.max(0, s.numLinesBefore - e2);
37788
- let o = s.lines.find((u) => u >= i);
37789
- if (o === void 0) {
37790
- this._prevFrame = t;
38218
+ const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
38219
+ if (this.restoreCursor(), e) {
38220
+ const n3 = Math.max(0, e.numLinesAfter - i2), s = Math.max(0, e.numLinesBefore - i2);
38221
+ let r2 = e.lines.find((o2) => o2 >= n3);
38222
+ if (r2 === void 0) {
38223
+ this._prevFrame = t2;
37791
38224
  return;
37792
38225
  }
37793
- if (s.lines.length === 1) {
37794
- this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
37795
- const u = t.split(`
38226
+ if (e.lines.length === 1) {
38227
+ this.output.write(import_sisteransi.cursor.move(0, r2 - s)), this.output.write(import_sisteransi.erase.lines(1));
38228
+ const o2 = t2.split(`
37796
38229
  `);
37797
- this.output.write(u[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, u.length - o - 1));
38230
+ this.output.write(o2[r2]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o2.length - r2 - 1));
37798
38231
  return;
37799
- } else if (s.lines.length > 1) {
37800
- if (i < n) o = i;
38232
+ } else if (e.lines.length > 1) {
38233
+ if (n3 < s)
38234
+ r2 = n3;
37801
38235
  else {
37802
- const a = o - n;
37803
- a > 0 && this.output.write(import_sisteransi.cursor.move(0, a));
38236
+ const h2 = r2 - s;
38237
+ h2 > 0 && this.output.write(import_sisteransi.cursor.move(0, h2));
37804
38238
  }
37805
38239
  this.output.write(import_sisteransi.erase.down());
37806
- const u = t.split(`
37807
- `).slice(o);
37808
- this.output.write(u.join(`
37809
- `)), this._prevFrame = t;
38240
+ const f = t2.split(`
38241
+ `).slice(r2);
38242
+ this.output.write(f.join(`
38243
+ `)), this._prevFrame = t2;
37810
38244
  return;
37811
38245
  }
37812
38246
  }
37813
38247
  this.output.write(import_sisteransi.erase.down());
37814
38248
  }
37815
- this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
38249
+ this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
37816
38250
  }
37817
38251
  }
37818
38252
  };
37819
- var X = class extends p {
38253
+ var r = class extends V {
37820
38254
  get cursor() {
37821
38255
  return this.value ? 0 : 1;
37822
38256
  }
37823
38257
  get _value() {
37824
38258
  return this.cursor === 0;
37825
38259
  }
37826
- constructor(t) {
37827
- super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
38260
+ constructor(t2) {
38261
+ super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
37828
38262
  this.value = this._value;
37829
- }), this.on("confirm", (s) => {
37830
- this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
38263
+ }), this.on("confirm", (i2) => {
38264
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
37831
38265
  }), this.on("cursor", () => {
37832
38266
  this.value = !this.value;
37833
38267
  });
37834
38268
  }
37835
38269
  };
37836
- var rt = class extends p {
37837
- #s = false;
37838
- #r;
38270
+ var o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
38271
+ var h = class extends V {
38272
+ #t = false;
38273
+ #s;
37839
38274
  focused = "editor";
37840
38275
  get userInputWithCursor() {
37841
- if (this.state === "submit") return this.userInput;
37842
- const t = this.userInput;
37843
- if (this.cursor >= t.length) return `${t}\u2588`;
37844
- const s = t.slice(0, this.cursor), e2 = t[this.cursor], i = t.slice(this.cursor + 1);
37845
- return e2 === `
38276
+ if (this.state === "submit")
38277
+ return this.userInput;
38278
+ const t2 = this.userInput;
38279
+ if (this.cursor >= t2.length)
38280
+ return `${t2}\u2588`;
38281
+ const s = t2.slice(0, this.cursor), r2 = t2.slice(this.cursor, this.cursor + 1), i2 = t2.slice(this.cursor + 1);
38282
+ return r2 === `
37846
38283
  ` ? `${s}\u2588
37847
- ${i}` : `${s}${v("inverse", e2)}${i}`;
38284
+ ${i2}` : `${s}${styleText("inverse", r2)}${i2}`;
37848
38285
  }
37849
38286
  get cursor() {
37850
38287
  return this._cursor;
37851
38288
  }
37852
- #t(t) {
38289
+ #r(t2) {
37853
38290
  if (this.userInput.length === 0) {
37854
- this._setUserInput(t);
38291
+ this._setUserInput(t2);
37855
38292
  return;
37856
38293
  }
37857
- this._setUserInput(this.userInput.slice(0, this.cursor) + t + this.userInput.slice(this.cursor));
38294
+ this._setUserInput(
38295
+ this.userInput.slice(0, this.cursor) + t2 + this.userInput.slice(this.cursor)
38296
+ );
37858
38297
  }
37859
- #n(t) {
38298
+ #i(t2) {
37860
38299
  const s = this.value ?? "";
37861
- switch (t) {
38300
+ switch (t2) {
37862
38301
  case "up":
37863
- this._cursor = I(this._cursor, 0, -1, s);
38302
+ this._cursor = findTextCursor(this._cursor, 0, -1, s);
37864
38303
  return;
37865
38304
  case "down":
37866
- this._cursor = I(this._cursor, 0, 1, s);
38305
+ this._cursor = findTextCursor(this._cursor, 0, 1, s);
37867
38306
  return;
37868
38307
  case "left":
37869
- this._cursor = I(this._cursor, -1, 0, s);
38308
+ this._cursor = findTextCursor(this._cursor, -1, 0, s);
37870
38309
  return;
37871
38310
  case "right":
37872
- this._cursor = I(this._cursor, 1, 0, s);
38311
+ this._cursor = findTextCursor(this._cursor, 1, 0, s);
37873
38312
  return;
37874
38313
  }
37875
38314
  }
37876
- _shouldSubmit(t, s) {
37877
- if (this.#r) return this.focused === "submit" ? true : (this.#t(`
38315
+ _shouldSubmit(t2, s) {
38316
+ if (this.#s)
38317
+ return this.focused === "submit" ? true : (this.#r(`
37878
38318
  `), this._cursor++, false);
37879
- const e2 = this.#s;
37880
- return this.#s = true, e2 ? (this.userInput[this.cursor - 1] === `
37881
- ` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#t(`
38319
+ const r2 = this.#t;
38320
+ return this.#t = true, r2 && this.cursor === this.userInput.length ? (this.userInput[this.cursor - 1] === `
38321
+ ` && (this._setUserInput(
38322
+ this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)
38323
+ ), this._cursor--), true) : (this.#r(`
37882
38324
  `), this._cursor++, false);
37883
38325
  }
37884
- constructor(t) {
37885
- super(t, false), this.#r = t.showSubmit ?? false, this.on("key", (s, e2) => {
37886
- if (e2?.name && h.actions.has(e2.name)) {
37887
- this.#n(e2.name);
38326
+ constructor(t2) {
38327
+ const s = t2.initialUserInput ?? t2.initialValue;
38328
+ super(
38329
+ {
38330
+ ...t2,
38331
+ initialUserInput: s
38332
+ },
38333
+ false
38334
+ ), s !== void 0 && (this._cursor = s.length), this.#s = t2.showSubmit ?? false, this.on("key", (r2, i2) => {
38335
+ if (i2?.name && o.has(i2.name)) {
38336
+ this.#t = false, this.#i(i2.name);
37888
38337
  return;
37889
38338
  }
37890
- if (s === " " && this.#r) {
38339
+ if (r2 === " " && this.#s) {
37891
38340
  this.focused = this.focused === "editor" ? "submit" : "editor";
37892
38341
  return;
37893
38342
  }
37894
- if (e2?.name !== "return") {
37895
- if (this.#s = false, e2?.name === "backspace" && this.cursor > 0) {
37896
- this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
38343
+ if (i2?.name !== "return") {
38344
+ if (this.#t = false, i2?.name === "backspace" && this.cursor > 0) {
38345
+ this._setUserInput(
38346
+ this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)
38347
+ ), this._cursor--;
37897
38348
  return;
37898
38349
  }
37899
- if (e2?.name === "delete" && this.cursor < this.userInput.length) {
37900
- this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
38350
+ if (i2?.name === "delete" && this.cursor < this.userInput.length) {
38351
+ this._setUserInput(
38352
+ this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1)
38353
+ );
37901
38354
  return;
37902
38355
  }
37903
- s && (this.#r && this.focused === "submit" && (this.focused = "editor"), this.#t(s ?? ""), this._cursor++);
38356
+ r2 && (this.#s && this.focused === "submit" && (this.focused = "editor"), this.#r(r2 ?? ""), this._cursor++);
37904
38357
  }
37905
- }), this.on("userInput", (s) => {
37906
- this._setValue(s);
38358
+ }), this.on("userInput", (r2) => {
38359
+ this._setValue(r2);
37907
38360
  }), this.on("finalize", () => {
37908
- this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
38361
+ this.value || (this.value = t2.defaultValue), this.value === void 0 && (this.value = "");
37909
38362
  });
37910
38363
  }
37911
38364
  };
37912
- var nt = class extends p {
38365
+ var a = class extends V {
37913
38366
  options;
37914
38367
  cursor = 0;
37915
38368
  get _value() {
37916
- return this.options[this.cursor].value;
38369
+ return this.options[this.cursor]?.value;
37917
38370
  }
37918
38371
  get _enabledOptions() {
37919
- return this.options.filter((t) => t.disabled !== true);
38372
+ return this.options.filter((e) => e.disabled !== true);
37920
38373
  }
37921
38374
  toggleAll() {
37922
- const t = this._enabledOptions, s = this.value !== void 0 && this.value.length === t.length;
37923
- this.value = s ? [] : t.map((e2) => e2.value);
38375
+ const e = this._enabledOptions, i2 = this.value !== void 0 && this.value.length === e.length;
38376
+ this.value = i2 ? [] : e.map((t2) => t2.value);
37924
38377
  }
37925
38378
  toggleInvert() {
37926
- const t = this.value;
37927
- if (!t) return;
37928
- const s = this._enabledOptions.filter((e2) => !t.includes(e2.value));
37929
- this.value = s.map((e2) => e2.value);
38379
+ const e = this.value;
38380
+ if (!e)
38381
+ return;
38382
+ const i2 = this._enabledOptions.filter((t2) => !e.includes(t2.value));
38383
+ this.value = i2.map((t2) => t2.value);
37930
38384
  }
37931
38385
  toggleValue() {
37932
38386
  this.value === void 0 && (this.value = []);
37933
- const t = this.value.includes(this._value);
37934
- this.value = t ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
37935
- }
37936
- constructor(t) {
37937
- super(t, false), this.options = t.options, this.value = [...t.initialValues ?? []];
37938
- const s = Math.max(this.options.findIndex(({ value: e2 }) => e2 === t.cursorAt), 0);
37939
- this.cursor = this.options[s].disabled ? d(s, 1, this.options) : s, this.on("key", (e2) => {
37940
- e2 === "a" && this.toggleAll(), e2 === "i" && this.toggleInvert();
37941
- }), this.on("cursor", (e2) => {
37942
- switch (e2) {
38387
+ const e = this.value.includes(this._value);
38388
+ this.value = e ? this.value.filter((i2) => i2 !== this._value) : [...this.value, this._value];
38389
+ }
38390
+ constructor(e) {
38391
+ super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
38392
+ const i2 = Math.max(
38393
+ this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt),
38394
+ 0
38395
+ );
38396
+ this.cursor = this.options[i2]?.disabled ? findCursor(i2, 1, this.options) : i2, this.on("key", (t2, l2) => {
38397
+ l2.name === "a" && this.toggleAll(), l2.name === "i" && this.toggleInvert();
38398
+ }), this.on("cursor", (t2) => {
38399
+ switch (t2) {
37943
38400
  case "left":
37944
38401
  case "up":
37945
- this.cursor = d(this.cursor, -1, this.options);
38402
+ this.cursor = findCursor(this.cursor, -1, this.options);
37946
38403
  break;
37947
38404
  case "down":
37948
38405
  case "right":
37949
- this.cursor = d(this.cursor, 1, this.options);
38406
+ this.cursor = findCursor(this.cursor, 1, this.options);
37950
38407
  break;
37951
38408
  case "space":
37952
38409
  this.toggleValue();
@@ -37955,7 +38412,7 @@ var nt = class extends p {
37955
38412
  });
37956
38413
  }
37957
38414
  };
37958
- var ot = class extends p {
38415
+ var u$1 = class u extends V {
37959
38416
  _mask = "\u2022";
37960
38417
  get cursor() {
37961
38418
  return this._cursor;
@@ -37964,42 +38421,47 @@ var ot = class extends p {
37964
38421
  return this.userInput.replaceAll(/./g, this._mask);
37965
38422
  }
37966
38423
  get userInputWithCursor() {
37967
- if (this.state === "submit" || this.state === "cancel") return this.masked;
37968
- const t = this.userInput;
37969
- if (this.cursor >= t.length) return `${this.masked}${v(["inverse", "hidden"], "_")}`;
37970
- const s = this.masked, e2 = s.slice(0, this.cursor), i = s.slice(this.cursor);
37971
- return `${e2}${v("inverse", i[0])}${i.slice(1)}`;
38424
+ if (this.state === "submit" || this.state === "cancel")
38425
+ return this.masked;
38426
+ const t2 = this.userInput;
38427
+ if (this.cursor >= t2.length)
38428
+ return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
38429
+ const s = this.masked, r2 = s.slice(0, this.cursor), i2 = s.slice(this.cursor, this.cursor + 1), o2 = s.slice(this.cursor + 1);
38430
+ return `${r2}${styleText("inverse", i2)}${o2}`;
37972
38431
  }
37973
38432
  clear() {
37974
38433
  this._clearUserInput();
37975
38434
  }
37976
- constructor({ mask: t, ...s }) {
37977
- super(s), this._mask = t ?? "\u2022", this.on("userInput", (e2) => {
37978
- this._setValue(e2);
38435
+ constructor({ mask: t2, ...s }) {
38436
+ super(s), this._mask = t2 ?? "\u2022", this.on("userInput", (r2) => {
38437
+ this._setValue(r2);
38438
+ }), this.on("finalize", () => {
38439
+ this.value === void 0 && (this.value = "");
37979
38440
  });
37980
38441
  }
37981
38442
  };
37982
- var ut = class extends p {
38443
+ var n$1 = class n extends V {
37983
38444
  options;
37984
38445
  cursor = 0;
37985
38446
  get _selectedValue() {
37986
38447
  return this.options[this.cursor];
37987
38448
  }
37988
38449
  changeValue() {
37989
- this.value = this._selectedValue.value;
37990
- }
37991
- constructor(t) {
37992
- super(t, false), this.options = t.options;
37993
- const s = this.options.findIndex(({ value: i }) => i === t.initialValue), e2 = s === -1 ? 0 : s;
37994
- this.cursor = this.options[e2].disabled ? d(e2, 1, this.options) : e2, this.changeValue(), this.on("cursor", (i) => {
37995
- switch (i) {
38450
+ const e = this._selectedValue;
38451
+ this.value = e === void 0 ? void 0 : e.value;
38452
+ }
38453
+ constructor(e) {
38454
+ super(e, false), this.options = e.options;
38455
+ const o2 = this.options.findIndex(({ value: s }) => s === e.initialValue), t2 = o2 === -1 ? 0 : o2;
38456
+ this.cursor = this.options[t2]?.disabled ? findCursor(t2, 1, this.options) : t2, this.changeValue(), this.on("cursor", (s) => {
38457
+ switch (s) {
37996
38458
  case "left":
37997
38459
  case "up":
37998
- this.cursor = d(this.cursor, -1, this.options);
38460
+ this.cursor = findCursor(this.cursor, -1, this.options);
37999
38461
  break;
38000
38462
  case "down":
38001
38463
  case "right":
38002
- this.cursor = d(this.cursor, 1, this.options);
38464
+ this.cursor = findCursor(this.cursor, 1, this.options);
38003
38465
  break;
38004
38466
  }
38005
38467
  this.changeValue();
@@ -38007,290 +38469,476 @@ var ut = class extends p {
38007
38469
  }
38008
38470
  };
38009
38471
 
38010
- // ../../node_modules/.bun/@clack+prompts@1.3.0/node_modules/@clack/prompts/dist/index.mjs
38011
- import { styleText as e, stripVTControlCharacters as nt2 } from "util";
38012
- import j2 from "process";
38472
+ // ../../node_modules/.bun/@clack+prompts@1.7.0/node_modules/@clack/prompts/dist/index.mjs
38473
+ import { styleText as styleText2, stripVTControlCharacters } from "util";
38474
+ import process$1 from "process";
38013
38475
  var import_sisteransi2 = __toESM(require_src(), 1);
38014
- import { existsSync as zt, lstatSync as wt, readdirSync as Qt } from "fs";
38015
- import { dirname as bt, join as Zt } from "path";
38016
- function te() {
38017
- return j2.platform !== "win32" ? j2.env.TERM !== "linux" : !!j2.env.CI || !!j2.env.WT_SESSION || !!j2.env.TERMINUS_SUBLIME || j2.env.ConEmuTask === "{cmd::Cmder}" || j2.env.TERM_PROGRAM === "Terminus-Sublime" || j2.env.TERM_PROGRAM === "vscode" || j2.env.TERM === "xterm-256color" || j2.env.TERM === "alacritty" || j2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
38018
- }
38019
- var tt = te();
38020
- var w2 = (t, r) => tt ? t : r;
38021
- var _t = w2("\u25C6", "*");
38022
- var ot2 = w2("\u25A0", "x");
38023
- var ut2 = w2("\u25B2", "x");
38024
- var F = w2("\u25C7", "o");
38025
- var lt = w2("\u250C", "T");
38026
- var $ = w2("\u2502", "|");
38027
- var E2 = w2("\u2514", "\u2014");
38028
- var It = w2("\u2510", "T");
38029
- var Et = w2("\u2518", "\u2014");
38030
- var z4 = w2("\u25CF", ">");
38031
- var H = w2("\u25CB", " ");
38032
- var et2 = w2("\u25FB", "[\u2022]");
38033
- var U = w2("\u25FC", "[+]");
38034
- var J = w2("\u25FB", "[ ]");
38035
- var Gt = w2("\u25AA", "\u2022");
38036
- var st = w2("\u2500", "-");
38037
- var ct = w2("\u256E", "+");
38038
- var xt = w2("\u251C", "+");
38039
- var $t = w2("\u256F", "+");
38040
- var dt = w2("\u2570", "+");
38041
- var Ot = w2("\u256D", "+");
38042
- var ht2 = w2("\u25CF", "\u2022");
38043
- var pt = w2("\u25C6", "*");
38044
- var mt = w2("\u25B2", "!");
38045
- var gt = w2("\u25A0", "x");
38046
- var M = (t) => {
38047
- switch (t) {
38476
+ import { existsSync as existsSync2, lstatSync, readdirSync } from "fs";
38477
+ import { dirname, join as join3 } from "path";
38478
+ function isUnicodeSupported() {
38479
+ if (process$1.platform !== "win32") {
38480
+ return process$1.env.TERM !== "linux";
38481
+ }
38482
+ return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
38483
+ }
38484
+ var unicode = isUnicodeSupported();
38485
+ var unicodeOr = (o2, e) => unicode ? o2 : e;
38486
+ var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
38487
+ var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
38488
+ var S_STEP_ERROR = unicodeOr("\u25B2", "x");
38489
+ var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
38490
+ var S_BAR_START = unicodeOr("\u250C", "T");
38491
+ var S_BAR = unicodeOr("\u2502", "|");
38492
+ var S_BAR_END = unicodeOr("\u2514", "\u2014");
38493
+ var S_BAR_START_RIGHT = unicodeOr("\u2510", "T");
38494
+ var S_BAR_END_RIGHT = unicodeOr("\u2518", "\u2014");
38495
+ var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
38496
+ var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
38497
+ var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
38498
+ var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
38499
+ var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
38500
+ var S_PASSWORD_MASK = unicodeOr("\u25AA", "\u2022");
38501
+ var S_BAR_H = unicodeOr("\u2500", "-");
38502
+ var S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+");
38503
+ var S_CONNECT_LEFT = unicodeOr("\u251C", "+");
38504
+ var S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+");
38505
+ var S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+");
38506
+ var S_CORNER_TOP_LEFT = unicodeOr("\u256D", "+");
38507
+ var S_INFO = unicodeOr("\u25CF", "\u2022");
38508
+ var S_SUCCESS = unicodeOr("\u25C6", "*");
38509
+ var S_WARN = unicodeOr("\u25B2", "!");
38510
+ var S_ERROR = unicodeOr("\u25A0", "x");
38511
+ var symbol2 = (o2) => {
38512
+ switch (o2) {
38048
38513
  case "initial":
38049
38514
  case "active":
38050
- return e("cyan", _t);
38515
+ return styleText2("cyan", S_STEP_ACTIVE);
38051
38516
  case "cancel":
38052
- return e("red", ot2);
38517
+ return styleText2("red", S_STEP_CANCEL);
38053
38518
  case "error":
38054
- return e("yellow", ut2);
38519
+ return styleText2("yellow", S_STEP_ERROR);
38055
38520
  case "submit":
38056
- return e("green", F);
38521
+ return styleText2("green", S_STEP_SUBMIT);
38057
38522
  }
38058
38523
  };
38059
- var yt = (t) => {
38060
- switch (t) {
38524
+ var symbolBar = (o2) => {
38525
+ switch (o2) {
38061
38526
  case "initial":
38062
38527
  case "active":
38063
- return e("cyan", $);
38528
+ return styleText2("cyan", S_BAR);
38064
38529
  case "cancel":
38065
- return e("red", $);
38530
+ return styleText2("red", S_BAR);
38066
38531
  case "error":
38067
- return e("yellow", $);
38532
+ return styleText2("yellow", S_BAR);
38068
38533
  case "submit":
38069
- return e("green", $);
38534
+ return styleText2("green", S_BAR);
38070
38535
  }
38071
38536
  };
38072
- var ee = (t, r, s, i, u) => {
38073
- let n = r, o = 0;
38074
- for (let c51 = s; c51 < i; c51++) {
38075
- const a = t[c51];
38076
- if (n = n - a.length, o++, n <= u) break;
38077
- }
38078
- return { lineCount: n, removals: o };
38079
- };
38080
- var Y2 = ({ cursor: t, options: r, style: s, output: i = process.stdout, maxItems: u = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: o = 4 }) => {
38081
- const c51 = A(i) - n, a = L(i), l = e("dim", "..."), d2 = Math.max(a - o, 0), y = Math.max(Math.min(u, d2), 5);
38082
- let p2 = 0;
38083
- t >= y - 3 && (p2 = Math.max(Math.min(t - y + 3, r.length - y), 0));
38084
- let m = y < r.length && p2 > 0, g = y < r.length && p2 + y < r.length;
38085
- const S2 = Math.min(p2 + y, r.length), h2 = [];
38537
+ function formatInstructionFooter(o2, e) {
38538
+ const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o2.join(" \u2022 ")}`];
38539
+ return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
38540
+ }
38541
+ var I = (l2, e, w, p, b, C = false) => {
38542
+ let r2 = e, O = 0;
38543
+ if (C)
38544
+ for (let i2 = p - 1; i2 >= w; i2--) {
38545
+ const m2 = l2[i2];
38546
+ if (m2 && (r2 -= m2.length), O++, r2 <= b) break;
38547
+ }
38548
+ else
38549
+ for (let i2 = w; i2 < p; i2++) {
38550
+ const m2 = l2[i2];
38551
+ if (m2 && (r2 -= m2.length), O++, r2 <= b) break;
38552
+ }
38553
+ return { lineCount: r2, removals: O };
38554
+ };
38555
+ var limitOptions = ({
38556
+ cursor: l2,
38557
+ options: e,
38558
+ style: w,
38559
+ output: p = process.stdout,
38560
+ maxItems: b = Number.POSITIVE_INFINITY,
38561
+ columnPadding: C = 0,
38562
+ rowPadding: r2 = 4
38563
+ }) => {
38564
+ const i2 = getColumns(p) - C, m2 = getRows(p), M = styleText2("dim", "..."), v = Math.max(m2 - r2, 0), a2 = Math.max(Math.min(b, v), 5);
38086
38565
  let f = 0;
38087
- m && f++, g && f++;
38088
- const v2 = p2 + (m ? 1 : 0), T = S2 - (g ? 1 : 0);
38089
- for (let b2 = v2; b2 < T; b2++) {
38090
- const G2 = wrapAnsi(s(r[b2], b2 === t), c51, { hard: true, trim: false }).split(`
38566
+ l2 >= a2 - 3 && (f = Math.max(
38567
+ Math.min(l2 - a2 + 3, e.length - a2),
38568
+ 0
38569
+ ));
38570
+ let d = a2 < e.length && f > 0, c51 = a2 < e.length && f + a2 < e.length;
38571
+ const W = Math.min(
38572
+ f + a2,
38573
+ e.length
38574
+ ), s = [];
38575
+ let g = 0;
38576
+ d && g++, c51 && g++;
38577
+ const T = f + (d ? 1 : 0), y = W - (c51 ? 1 : 0);
38578
+ for (let t2 = T; t2 < y; t2++) {
38579
+ const n3 = e[t2], o2 = n3 ? w(n3, t2 === l2) : "", h2 = wrapAnsi(o2, i2, {
38580
+ hard: true,
38581
+ trim: false
38582
+ }).split(`
38091
38583
  `);
38092
- h2.push(G2), f += G2.length;
38093
- }
38094
- if (f > d2) {
38095
- let b2 = 0, G2 = 0, x = f;
38096
- const A2 = t - v2, P = (N, D2) => ee(h2, x, N, D2, d2);
38097
- m ? ({ lineCount: x, removals: b2 } = P(0, A2), x > d2 && ({ lineCount: x, removals: G2 } = P(A2 + 1, h2.length))) : ({ lineCount: x, removals: G2 } = P(A2 + 1, h2.length), x > d2 && ({ lineCount: x, removals: b2 } = P(0, A2))), b2 > 0 && (m = true, h2.splice(0, b2)), G2 > 0 && (g = true, h2.splice(h2.length - G2, G2));
38098
- }
38099
- const C2 = [];
38100
- m && C2.push(l);
38101
- for (const b2 of h2) for (const G2 of b2) C2.push(G2);
38102
- return g && C2.push(l), C2;
38103
- };
38104
- var ue = (t) => {
38105
- const r = t.active ?? "Yes", s = t.inactive ?? "No";
38106
- return new X({ active: r, inactive: s, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue ?? true, render() {
38107
- const i = t.withGuide ?? h.withGuide, u = `${M(this.state)} `, n = i ? `${e("gray", $)} ` : "", o = W(t.output, t.message, n, u), c51 = `${i ? `${e("gray", $)}
38108
- ` : ""}${o}
38109
- `, a = this.value ? r : s;
38110
- switch (this.state) {
38111
- case "submit": {
38112
- const l = i ? `${e("gray", $)} ` : "";
38113
- return `${c51}${l}${e("dim", a)}`;
38114
- }
38115
- case "cancel": {
38116
- const l = i ? `${e("gray", $)} ` : "";
38117
- return `${c51}${l}${e(["strikethrough", "dim"], a)}${i ? `
38118
- ${e("gray", $)}` : ""}`;
38119
- }
38120
- default: {
38121
- const l = i ? `${e("cyan", $)} ` : "", d2 = i ? e("cyan", E2) : "";
38122
- return `${c51}${l}${this.value ? `${e("green", z4)} ${r}` : `${e("dim", H)} ${e("dim", r)}`}${t.vertical ? i ? `
38123
- ${e("cyan", $)} ` : `
38124
- ` : ` ${e("dim", "/")} `}${this.value ? `${e("dim", H)} ${e("dim", s)}` : `${e("green", z4)} ${s}`}
38125
- ${d2}
38584
+ s.push(h2), g += h2.length;
38585
+ }
38586
+ if (g > v) {
38587
+ let t2 = 0, n3 = 0, o2 = g;
38588
+ const h2 = l2 - T;
38589
+ let u4 = v;
38590
+ const L = () => I(s, o2, 0, h2, u4), E = () => I(
38591
+ s,
38592
+ o2,
38593
+ h2 + 1,
38594
+ s.length,
38595
+ u4,
38596
+ true
38597
+ );
38598
+ d ? ({ lineCount: o2, removals: t2 } = L(), o2 > u4 && (c51 || (u4 -= 1), { lineCount: o2, removals: n3 } = E())) : (c51 || (u4 -= 1), { lineCount: o2, removals: n3 } = E(), o2 > u4 && (u4 -= 1, { lineCount: o2, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n3 > 0 && (c51 = true, s.splice(s.length - n3, n3));
38599
+ }
38600
+ const x = [];
38601
+ d && x.push(M);
38602
+ for (const t2 of s)
38603
+ for (const n3 of t2)
38604
+ x.push(n3);
38605
+ return c51 && x.push(M), x;
38606
+ };
38607
+ var confirm = (i2) => {
38608
+ const a2 = i2.active ?? "Yes", s = i2.inactive ?? "No";
38609
+ return new r({
38610
+ active: a2,
38611
+ inactive: s,
38612
+ signal: i2.signal,
38613
+ input: i2.input,
38614
+ output: i2.output,
38615
+ initialValue: i2.initialValue ?? true,
38616
+ render() {
38617
+ const e = i2.withGuide ?? settings.withGuide, u4 = `${symbol2(this.state)} `, l2 = e ? `${styleText2("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(
38618
+ i2.output,
38619
+ i2.message,
38620
+ l2,
38621
+ u4
38622
+ ), o2 = `${e ? `${styleText2("gray", S_BAR)}
38623
+ ` : ""}${f}
38624
+ `, c51 = this.value ? a2 : s;
38625
+ switch (this.state) {
38626
+ case "submit": {
38627
+ const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
38628
+ return `${o2}${r2}${styleText2("dim", c51)}`;
38629
+ }
38630
+ case "cancel": {
38631
+ const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
38632
+ return `${o2}${r2}${styleText2(["strikethrough", "dim"], c51)}${e ? `
38633
+ ${styleText2("gray", S_BAR)}` : ""}`;
38634
+ }
38635
+ default: {
38636
+ const r2 = e ? `${styleText2("cyan", S_BAR)} ` : "", g = e ? styleText2("cyan", S_BAR_END) : "";
38637
+ return `${o2}${r2}${this.value ? `${styleText2("green", S_RADIO_ACTIVE)} ${a2}` : `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a2)}`}${i2.vertical ? e ? `
38638
+ ${styleText2("cyan", S_BAR)} ` : `
38639
+ ` : ` ${styleText2("dim", "/")} `}${this.value ? `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", s)}` : `${styleText2("green", S_RADIO_ACTIVE)} ${s}`}
38640
+ ${g}
38126
38641
  `;
38642
+ }
38127
38643
  }
38128
38644
  }
38129
- } }).prompt();
38645
+ }).prompt();
38130
38646
  };
38131
- var me = (t = "", r) => {
38132
- const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${e("gray", E2)} ` : "";
38133
- s.write(`${i}${e("red", t)}
38134
-
38647
+ var MULTISELECT_INSTRUCTIONS = [
38648
+ `${styleText2("dim", "\u2191/\u2193")} to navigate`,
38649
+ `${styleText2("dim", "Space:")} select`,
38650
+ `${styleText2("dim", "Enter:")} confirm`
38651
+ ];
38652
+ var m = (i2, u4) => i2.split(`
38653
+ `).map((d) => u4(d)).join(`
38135
38654
  `);
38136
- };
38137
- var fe = (t) => new rt({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, showSubmit: t.showSubmit, output: t.output, signal: t.signal, input: t.input, render() {
38138
- const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${e("gray", $)}
38139
- ` : ""}${M(this.state)} `}${t.message}
38140
- `, i = t.placeholder ? e("inverse", t.placeholder[0]) + e("dim", t.placeholder.slice(1)) : e(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : i, n = this.value ?? "", o = t.showSubmit ? `
38141
- ${e(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
38142
- switch (this.state) {
38143
- case "error": {
38144
- const c51 = `${e("yellow", $)} `, a = r ? W(t.output, u, c51, void 0) : u, l = e("yellow", E2);
38145
- return `${s}${a}
38146
- ${l} ${e("yellow", this.error)}${o}
38655
+ var multiselect = (i2) => {
38656
+ const u4 = (t2, a2) => {
38657
+ const r2 = t2.label ?? String(t2.value);
38658
+ return a2 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${m(r2, (o2) => styleText2(["strikethrough", "gray"], o2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : a2 === "active" ? `${styleText2("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${m(r2, (o2) => styleText2("dim", o2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "cancelled" ? `${m(r2, (o2) => styleText2(["strikethrough", "dim"], o2))}` : a2 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "submitted" ? `${m(r2, (o2) => styleText2("dim", o2))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${m(r2, (o2) => styleText2("dim", o2))}`;
38659
+ }, d = i2.required ?? true, v = i2.showInstructions ?? true;
38660
+ return new a({
38661
+ options: i2.options,
38662
+ signal: i2.signal,
38663
+ input: i2.input,
38664
+ output: i2.output,
38665
+ initialValues: i2.initialValues,
38666
+ required: d,
38667
+ cursorAt: i2.cursorAt,
38668
+ validate(t2) {
38669
+ if (d && (t2 === void 0 || t2.length === 0))
38670
+ return `Please select at least one option.
38671
+ ${styleText2(
38672
+ "reset",
38673
+ styleText2(
38674
+ "dim",
38675
+ `Press ${styleText2(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText2(
38676
+ "gray",
38677
+ styleText2("bgWhite", styleText2("inverse", " enter "))
38678
+ )} to submit`
38679
+ )
38680
+ )}`;
38681
+ },
38682
+ render() {
38683
+ const t2 = i2.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(
38684
+ i2.output,
38685
+ i2.message,
38686
+ t2 ? `${symbolBar(this.state)} ` : "",
38687
+ `${symbol2(this.state)} `
38688
+ ), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
38689
+ ` : ""}${a2}
38690
+ `, o2 = this.value ?? [], p = (n3, l2) => {
38691
+ if (n3.disabled)
38692
+ return u4(n3, "disabled");
38693
+ const s = o2.includes(n3.value);
38694
+ return l2 && s ? u4(n3, "active-selected") : s ? u4(n3, "selected") : u4(n3, l2 ? "active" : "inactive");
38695
+ };
38696
+ switch (this.state) {
38697
+ case "submit": {
38698
+ const n3 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u4(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), l2 = wrapTextWithPrefix(
38699
+ i2.output,
38700
+ n3,
38701
+ t2 ? `${styleText2("gray", S_BAR)} ` : ""
38702
+ );
38703
+ return `${r2}${l2}`;
38704
+ }
38705
+ case "cancel": {
38706
+ const n3 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u4(s, "cancelled")).join(styleText2("dim", ", "));
38707
+ if (n3.trim() === "")
38708
+ return `${r2}${styleText2("gray", S_BAR)}`;
38709
+ const l2 = wrapTextWithPrefix(
38710
+ i2.output,
38711
+ n3,
38712
+ t2 ? `${styleText2("gray", S_BAR)} ` : ""
38713
+ );
38714
+ return `${r2}${l2}${t2 ? `
38715
+ ${styleText2("gray", S_BAR)}` : ""}`;
38716
+ }
38717
+ case "error": {
38718
+ const n3 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", l2 = this.error.split(`
38719
+ `).map(
38720
+ ($, C) => C === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", $)}` : ` ${$}`
38721
+ ).join(`
38722
+ `), s = r2.split(`
38723
+ `).length, h2 = l2.split(`
38724
+ `).length + 1;
38725
+ return `${r2}${n3}${limitOptions({
38726
+ output: i2.output,
38727
+ options: this.options,
38728
+ cursor: this.cursor,
38729
+ maxItems: i2.maxItems,
38730
+ columnPadding: n3.length,
38731
+ rowPadding: s + h2,
38732
+ style: p
38733
+ }).join(`
38734
+ ${n3}`)}
38735
+ ${l2}
38147
38736
  `;
38148
- }
38149
- case "submit": {
38150
- const c51 = `${e("gray", $)} `, a = r ? W(t.output, n, c51, void 0, (l) => e("dim", l)) : n ? e("dim", n) : "";
38151
- return `${s}${a}`;
38152
- }
38153
- case "cancel": {
38154
- const c51 = `${e("gray", $)} `, a = r ? W(t.output, n, c51, void 0, (l) => e(["strikethrough", "dim"], l)) : n ? e(["strikethrough", "dim"], n) : "";
38155
- return `${s}${a}`;
38156
- }
38157
- default: {
38158
- const c51 = r ? `${e("cyan", $)} ` : "", a = r ? e("cyan", E2) : "", l = r ? W(t.output, u, c51) : u;
38159
- return `${s}${l}
38160
- ${a}${o}
38737
+ }
38738
+ default: {
38739
+ const n3 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l2 = r2.split(`
38740
+ `).length, s = v ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText2("cyan", S_BAR_END)] : [], h2 = s.join(`
38741
+ `), $ = s.length + 1;
38742
+ return `${r2}${n3}${limitOptions({
38743
+ output: i2.output,
38744
+ options: this.options,
38745
+ cursor: this.cursor,
38746
+ maxItems: i2.maxItems,
38747
+ columnPadding: n3.length,
38748
+ rowPadding: l2 + $,
38749
+ style: p
38750
+ }).join(`
38751
+ ${n3}`)}
38752
+ ${h2}
38161
38753
  `;
38754
+ }
38755
+ }
38162
38756
  }
38163
- }
38164
- } }).prompt();
38165
- var Q2 = (t, r) => t.split(`
38166
- `).map((s) => r(s)).join(`
38757
+ }).prompt();
38758
+ };
38759
+ var cancel = (o2 = "", t2) => {
38760
+ const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_END)} ` : "";
38761
+ i2.write(`${e}${styleText2("red", o2)}
38762
+
38167
38763
  `);
38168
- var ve = (t) => {
38169
- const r = (i, u) => {
38170
- const n = i.label ?? String(i.value);
38171
- return u === "disabled" ? `${e("gray", J)} ${Q2(n, (o) => e(["strikethrough", "gray"], o))}${i.hint ? ` ${e("dim", `(${i.hint ?? "disabled"})`)}` : ""}` : u === "active" ? `${e("cyan", et2)} ${n}${i.hint ? ` ${e("dim", `(${i.hint})`)}` : ""}` : u === "selected" ? `${e("green", U)} ${Q2(n, (o) => e("dim", o))}${i.hint ? ` ${e("dim", `(${i.hint})`)}` : ""}` : u === "cancelled" ? `${Q2(n, (o) => e(["strikethrough", "dim"], o))}` : u === "active-selected" ? `${e("green", U)} ${n}${i.hint ? ` ${e("dim", `(${i.hint})`)}` : ""}` : u === "submitted" ? `${Q2(n, (o) => e("dim", o))}` : `${e("dim", J)} ${Q2(n, (o) => e("dim", o))}`;
38172
- }, s = t.required ?? true;
38173
- return new nt({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValues: t.initialValues, required: s, cursorAt: t.cursorAt, validate(i) {
38174
- if (s && (i === void 0 || i.length === 0)) return `Please select at least one option.
38175
- ${e("reset", e("dim", `Press ${e(["gray", "bgWhite", "inverse"], " space ")} to select, ${e("gray", e("bgWhite", e("inverse", " enter ")))} to submit`))}`;
38176
- }, render() {
38177
- const i = t.withGuide ?? h.withGuide, u = W(t.output, t.message, i ? `${yt(this.state)} ` : "", `${M(this.state)} `), n = `${i ? `${e("gray", $)}
38178
- ` : ""}${u}
38179
- `, o = this.value ?? [], c51 = (a, l) => {
38180
- if (a.disabled) return r(a, "disabled");
38181
- const d2 = o.includes(a.value);
38182
- return l && d2 ? r(a, "active-selected") : d2 ? r(a, "selected") : r(a, l ? "active" : "inactive");
38183
- };
38764
+ };
38765
+ var multiline = (e) => new h({
38766
+ validate: e.validate,
38767
+ placeholder: e.placeholder,
38768
+ defaultValue: e.defaultValue,
38769
+ initialValue: e.initialValue,
38770
+ showSubmit: e.showSubmit,
38771
+ output: e.output,
38772
+ signal: e.signal,
38773
+ input: e.input,
38774
+ render() {
38775
+ const i2 = e?.withGuide ?? settings.withGuide, o2 = `${`${i2 ? `${styleText2("gray", S_BAR)}
38776
+ ` : ""}${symbol2(this.state)} `}${e.message}
38777
+ `, m2 = e.placeholder && e.placeholder.length > 0 ? (
38778
+ // biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
38779
+ styleText2("inverse", e.placeholder[0]) + styleText2("dim", e.placeholder.slice(1))
38780
+ ) : styleText2(["inverse", "hidden"], "_"), a2 = this.userInput ? this.userInputWithCursor : m2, l2 = this.value ?? "", c51 = e.showSubmit ? `
38781
+ ${styleText2(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
38184
38782
  switch (this.state) {
38783
+ case "error": {
38784
+ const n3 = `${styleText2("yellow", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(e.output, a2, n3, void 0) : a2, u4 = styleText2("yellow", S_BAR_END);
38785
+ return `${o2}${r2}
38786
+ ${u4} ${styleText2("yellow", this.error)}${c51}
38787
+ `;
38788
+ }
38185
38789
  case "submit": {
38186
- const a = this.options.filter(({ value: d2 }) => o.includes(d2)).map((d2) => r(d2, "submitted")).join(e("dim", ", ")) || e("dim", "none"), l = W(t.output, a, i ? `${e("gray", $)} ` : "");
38187
- return `${n}${l}`;
38790
+ const n3 = `${styleText2("gray", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(
38791
+ e.output,
38792
+ l2,
38793
+ n3,
38794
+ void 0,
38795
+ void 0,
38796
+ (u4) => styleText2("dim", u4)
38797
+ ) : l2 ? styleText2("dim", l2) : "";
38798
+ return `${o2}${r2}`;
38188
38799
  }
38189
38800
  case "cancel": {
38190
- const a = this.options.filter(({ value: d2 }) => o.includes(d2)).map((d2) => r(d2, "cancelled")).join(e("dim", ", "));
38191
- if (a.trim() === "") return `${n}${e("gray", $)}`;
38192
- const l = W(t.output, a, i ? `${e("gray", $)} ` : "");
38193
- return `${n}${l}${i ? `
38194
- ${e("gray", $)}` : ""}`;
38195
- }
38196
- case "error": {
38197
- const a = i ? `${e("yellow", $)} ` : "", l = this.error.split(`
38198
- `).map((p2, m) => m === 0 ? `${i ? `${e("yellow", E2)} ` : ""}${e("yellow", p2)}` : ` ${p2}`).join(`
38199
- `), d2 = n.split(`
38200
- `).length, y = l.split(`
38201
- `).length + 1;
38202
- return `${n}${a}${Y2({ output: t.output, options: this.options, cursor: this.cursor, maxItems: t.maxItems, columnPadding: a.length, rowPadding: d2 + y, style: c51 }).join(`
38203
- ${a}`)}
38204
- ${l}
38205
- `;
38801
+ const n3 = `${styleText2("gray", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(
38802
+ e.output,
38803
+ l2,
38804
+ n3,
38805
+ void 0,
38806
+ void 0,
38807
+ (u4) => styleText2(["strikethrough", "dim"], u4)
38808
+ ) : l2 ? styleText2(["strikethrough", "dim"], l2) : "";
38809
+ return `${o2}${r2}`;
38206
38810
  }
38207
38811
  default: {
38208
- const a = i ? `${e("cyan", $)} ` : "", l = n.split(`
38209
- `).length, d2 = i ? 2 : 1;
38210
- return `${n}${a}${Y2({ output: t.output, options: this.options, cursor: this.cursor, maxItems: t.maxItems, columnPadding: a.length, rowPadding: l + d2, style: c51 }).join(`
38211
- ${a}`)}
38212
- ${i ? e("cyan", E2) : ""}
38812
+ const n3 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "", u4 = i2 ? wrapTextWithPrefix(e.output, a2, n3) : a2;
38813
+ return `${o2}${u4}
38814
+ ${r2}${c51}
38213
38815
  `;
38214
38816
  }
38215
38817
  }
38216
- } }).prompt();
38217
- };
38218
- var Ce = (t) => new ot({ validate: t.validate, mask: t.mask ?? Gt, signal: t.signal, input: t.input, output: t.output, render() {
38219
- const r = t.withGuide ?? h.withGuide, s = `${r ? `${e("gray", $)}
38220
- ` : ""}${M(this.state)} ${t.message}
38221
- `, i = this.userInputWithCursor, u = this.masked;
38222
- switch (this.state) {
38223
- case "error": {
38224
- const n = r ? `${e("yellow", $)} ` : "", o = r ? `${e("yellow", E2)} ` : "", c51 = u ?? "";
38225
- return t.clearOnError && this.clear(), `${s.trim()}
38226
- ${n}${c51}
38227
- ${o}${e("yellow", this.error)}
38818
+ }
38819
+ }).prompt();
38820
+ var password = (r2) => new u$1({
38821
+ validate: r2.validate,
38822
+ mask: r2.mask ?? S_PASSWORD_MASK,
38823
+ signal: r2.signal,
38824
+ input: r2.input,
38825
+ output: r2.output,
38826
+ render() {
38827
+ const e = r2.withGuide ?? settings.withGuide, o2 = `${e ? `${styleText2("gray", S_BAR)}
38828
+ ` : ""}${symbol2(this.state)} ${r2.message}
38829
+ `, c51 = this.userInputWithCursor, i2 = this.masked;
38830
+ switch (this.state) {
38831
+ case "error": {
38832
+ const s = e ? `${styleText2("yellow", S_BAR)} ` : "", n3 = e ? `${styleText2("yellow", S_BAR_END)} ` : "", l2 = i2 ?? "";
38833
+ return r2.clearOnError && this.clear(), `${o2.trim()}
38834
+ ${s}${l2}
38835
+ ${n3}${styleText2("yellow", this.error)}
38228
38836
  `;
38229
- }
38230
- case "submit": {
38231
- const n = r ? `${e("gray", $)} ` : "", o = u ? e("dim", u) : "";
38232
- return `${s}${n}${o}`;
38233
- }
38234
- case "cancel": {
38235
- const n = r ? `${e("gray", $)} ` : "", o = u ? e(["strikethrough", "dim"], u) : "";
38236
- return `${s}${n}${o}${u && r ? `
38237
- ${e("gray", $)}` : ""}`;
38238
- }
38239
- default: {
38240
- const n = r ? `${e("cyan", $)} ` : "", o = r ? e("cyan", E2) : "";
38241
- return `${s}${n}${i}
38242
- ${o}
38837
+ }
38838
+ case "submit": {
38839
+ const s = e ? `${styleText2("gray", S_BAR)} ` : "", n3 = i2 ? styleText2("dim", i2) : "";
38840
+ return `${o2}${s}${n3}`;
38841
+ }
38842
+ case "cancel": {
38843
+ const s = e ? `${styleText2("gray", S_BAR)} ` : "", n3 = i2 ? styleText2(["strikethrough", "dim"], i2) : "";
38844
+ return `${o2}${s}${n3}${i2 && e ? `
38845
+ ${styleText2("gray", S_BAR)}` : ""}`;
38846
+ }
38847
+ default: {
38848
+ const s = e ? `${styleText2("cyan", S_BAR)} ` : "", n3 = e ? styleText2("cyan", S_BAR_END) : "";
38849
+ return `${o2}${s}${c51}
38850
+ ${n3}
38243
38851
  `;
38852
+ }
38244
38853
  }
38245
38854
  }
38246
- } }).prompt();
38247
- var Vt = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
38248
- var it2 = (t, r) => t.includes(`
38249
- `) ? t.split(`
38250
- `).map((s) => r(s)).join(`
38251
- `) : r(t);
38252
- var Ee = (t) => {
38253
- const r = (s, i) => {
38254
- const u = s.label ?? String(s.value);
38255
- switch (i) {
38855
+ }).prompt();
38856
+ var u3 = {
38857
+ light: unicodeOr("\u2500", "-"),
38858
+ heavy: unicodeOr("\u2501", "="),
38859
+ block: unicodeOr("\u2588", "#")
38860
+ };
38861
+ var SELECT_INSTRUCTIONS = [
38862
+ `${styleText2("dim", "\u2191/\u2193")} to navigate`,
38863
+ `${styleText2("dim", "Enter:")} confirm`
38864
+ ];
38865
+ var c50 = (t2, o2) => t2.includes(`
38866
+ `) ? t2.split(`
38867
+ `).map((d) => o2(d)).join(`
38868
+ `) : o2(t2);
38869
+ var select = (t2) => {
38870
+ const o2 = (n3, m2) => {
38871
+ if (n3 === void 0)
38872
+ return "";
38873
+ const s = n3.label ?? String(n3.value);
38874
+ switch (m2) {
38256
38875
  case "disabled":
38257
- return `${e("gray", H)} ${it2(u, (n) => e("gray", n))}${s.hint ? ` ${e("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
38876
+ return `${styleText2("gray", S_RADIO_INACTIVE)} ${c50(s, (i2) => styleText2("gray", i2))}${n3.hint ? ` ${styleText2("dim", `(${n3.hint ?? "disabled"})`)}` : ""}`;
38258
38877
  case "selected":
38259
- return `${it2(u, (n) => e("dim", n))}`;
38878
+ return `${c50(s, (i2) => styleText2("dim", i2))}`;
38260
38879
  case "active":
38261
- return `${e("green", z4)} ${u}${s.hint ? ` ${e("dim", `(${s.hint})`)}` : ""}`;
38880
+ return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`;
38262
38881
  case "cancelled":
38263
- return `${it2(u, (n) => e(["strikethrough", "dim"], n))}`;
38882
+ return `${c50(s, (i2) => styleText2(["strikethrough", "dim"], i2))}`;
38264
38883
  default:
38265
- return `${e("dim", H)} ${it2(u, (n) => e("dim", n))}`;
38266
- }
38267
- };
38268
- return new ut({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
38269
- const s = t.withGuide ?? h.withGuide, i = `${M(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, i), o = `${s ? `${e("gray", $)}
38270
- ` : ""}${n}
38884
+ return `${styleText2("dim", S_RADIO_INACTIVE)} ${c50(s, (i2) => styleText2("dim", i2))}`;
38885
+ }
38886
+ }, d = t2.showInstructions ?? true;
38887
+ return new n$1({
38888
+ options: t2.options,
38889
+ signal: t2.signal,
38890
+ input: t2.input,
38891
+ output: t2.output,
38892
+ initialValue: t2.initialValue,
38893
+ render() {
38894
+ const n3 = t2.withGuide ?? settings.withGuide, m2 = `${symbol2(this.state)} `, s = `${symbolBar(this.state)} `, i2 = wrapTextWithPrefix(
38895
+ t2.output,
38896
+ t2.message,
38897
+ s,
38898
+ m2
38899
+ ), u4 = `${n3 ? `${styleText2("gray", S_BAR)}
38900
+ ` : ""}${i2}
38271
38901
  `;
38272
- switch (this.state) {
38273
- case "submit": {
38274
- const c51 = s ? `${e("gray", $)} ` : "", a = W(t.output, r(this.options[this.cursor], "selected"), c51);
38275
- return `${o}${a}`;
38276
- }
38277
- case "cancel": {
38278
- const c51 = s ? `${e("gray", $)} ` : "", a = W(t.output, r(this.options[this.cursor], "cancelled"), c51);
38279
- return `${o}${a}${s ? `
38280
- ${e("gray", $)}` : ""}`;
38281
- }
38282
- default: {
38283
- const c51 = s ? `${e("cyan", $)} ` : "", a = s ? e("cyan", E2) : "", l = o.split(`
38284
- `).length, d2 = s ? 2 : 1;
38285
- return `${o}${c51}${Y2({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: c51.length, rowPadding: l + d2, style: (y, p2) => r(y, y.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
38286
- ${c51}`)}
38287
- ${a}
38902
+ switch (this.state) {
38903
+ case "submit": {
38904
+ const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
38905
+ t2.output,
38906
+ o2(this.options[this.cursor], "selected"),
38907
+ r2
38908
+ );
38909
+ return `${u4}${a2}`;
38910
+ }
38911
+ case "cancel": {
38912
+ const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
38913
+ t2.output,
38914
+ o2(this.options[this.cursor], "cancelled"),
38915
+ r2
38916
+ );
38917
+ return `${u4}${a2}${n3 ? `
38918
+ ${styleText2("gray", S_BAR)}` : ""}`;
38919
+ }
38920
+ default: {
38921
+ const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 = u4.split(`
38922
+ `).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], b = p.join(`
38923
+ `), f = p.length + 1;
38924
+ return `${u4}${r2}${limitOptions({
38925
+ output: t2.output,
38926
+ cursor: this.cursor,
38927
+ options: this.options,
38928
+ maxItems: t2.maxItems,
38929
+ columnPadding: r2.length,
38930
+ rowPadding: a2 + f,
38931
+ style: (g, x) => o2(g, g.disabled ? "disabled" : x ? "active" : "inactive")
38932
+ }).join(`
38933
+ ${r2}`)}
38934
+ ${b}
38288
38935
  `;
38936
+ }
38289
38937
  }
38290
38938
  }
38291
- } }).prompt();
38939
+ }).prompt();
38292
38940
  };
38293
- var jt = `${e("gray", $)} `;
38941
+ var i = `${styleText2("gray", S_BAR)} `;
38294
38942
 
38295
38943
  // src/auth/commands.ts
38296
38944
  function getClientId() {
@@ -38526,12 +39174,12 @@ async function promptForOrganizationSelection(organizations, activeOrganizationI
38526
39174
  hint: organization.organizationId
38527
39175
  };
38528
39176
  });
38529
- const selected = await Ee({
39177
+ const selected = await select({
38530
39178
  message: "Switch organization",
38531
39179
  options: choices,
38532
39180
  initialValue: activeIndex >= 0 ? organizations[activeIndex]?.organizationId : void 0
38533
39181
  });
38534
- if (q(selected)) {
39182
+ if (isCancel(selected)) {
38535
39183
  return null;
38536
39184
  }
38537
39185
  const selectedOrganization = organizations.find(
@@ -38747,15 +39395,15 @@ function createOrgListCommand() {
38747
39395
  return new Command("list").description("List organizations available to your account").option("-o, --output <format>", "Output format: table, json, tsv (default: table)", "table").option(
38748
39396
  "-L, --limit <n>",
38749
39397
  `Max organizations to display, max ${ORG_LIST_MAX_LIMIT} (default: all)`,
38750
- (v2) => {
38751
- const n = Number.parseInt(v2, 10);
38752
- if (Number.isNaN(n) || n < 1) {
39398
+ (v) => {
39399
+ const n3 = Number.parseInt(v, 10);
39400
+ if (Number.isNaN(n3) || n3 < 1) {
38753
39401
  throw new Error("--limit must be a positive integer");
38754
39402
  }
38755
- if (n > ORG_LIST_MAX_LIMIT) {
39403
+ if (n3 > ORG_LIST_MAX_LIMIT) {
38756
39404
  throw new Error(`--limit cannot exceed ${ORG_LIST_MAX_LIMIT}`);
38757
39405
  }
38758
- return n;
39406
+ return n3;
38759
39407
  }
38760
39408
  ).option(
38761
39409
  "-f, --filter <expression>",
@@ -38839,17 +39487,17 @@ Examples:
38839
39487
  ];
38840
39488
  });
38841
39489
  const colWidths = headers.map(
38842
- (h2, i) => Math.max(h2.length, ...rows.map((r) => (r[i] ?? "").length))
39490
+ (h2, i2) => Math.max(h2.length, ...rows.map((r2) => (r2[i2] ?? "").length))
38843
39491
  );
38844
- const pad = (s, w3) => s.padEnd(w3);
38845
- const headerLine = headers.map((h2, i) => pad(h2, colWidths[i] ?? h2.length)).join(" ");
39492
+ const pad = (s, w) => s.padEnd(w);
39493
+ const headerLine = headers.map((h2, i2) => pad(h2, colWidths[i2] ?? h2.length)).join(" ");
38846
39494
  const rowLines = rows.map(
38847
- (row) => row.map((cell, i) => pad(cell, colWidths[i] ?? 0)).join(" ")
39495
+ (row) => row.map((cell, i2) => pad(cell, colWidths[i2] ?? 0)).join(" ")
38848
39496
  );
38849
39497
  await runInteractivePager({
38850
39498
  items,
38851
39499
  header: headerLine,
38852
- renderItem: (_item, i) => [rowLines[i] ?? ""],
39500
+ renderItem: (_item, i2) => [rowLines[i2] ?? ""],
38853
39501
  disabled: options.pager === false
38854
39502
  });
38855
39503
  if (organizationContext.staleSelectionDetected) {
@@ -39044,14 +39692,14 @@ function repoDisplayName(repositoryUrl) {
39044
39692
  }
39045
39693
  }
39046
39694
  function countedRows(totals) {
39047
- const b2 = totals.buckets;
39695
+ const b = totals.buckets;
39048
39696
  return [
39049
- { label: "Billable code", value: b2.code.code },
39050
- { label: "Blank & comment lines in billable files", value: b2.code.lines - b2.code.code },
39051
- { label: "Tests", value: b2.tests.lines },
39052
- { label: "Documentation", value: b2.docs.lines },
39053
- { label: "Configuration & data", value: b2.config_data.lines },
39054
- { label: "Vendored & generated", value: b2.vendored_generated.lines }
39697
+ { label: "Billable code", value: b.code.code },
39698
+ { label: "Blank & comment lines in billable files", value: b.code.lines - b.code.code },
39699
+ { label: "Tests", value: b.tests.lines },
39700
+ { label: "Documentation", value: b.docs.lines },
39701
+ { label: "Configuration & data", value: b.config_data.lines },
39702
+ { label: "Vendored & generated", value: b.vendored_generated.lines }
39055
39703
  ];
39056
39704
  }
39057
39705
  function countedTotal(totals) {
@@ -39062,7 +39710,7 @@ function padValues(rows) {
39062
39710
  const labelWidth = Math.max(...rows.map((row) => row.label.length));
39063
39711
  const valueWidth = Math.max(...formatted.map((value) => value.length));
39064
39712
  return rows.map(
39065
- (row, i) => ` ${row.label.padEnd(labelWidth)} ${(formatted[i] ?? "").padStart(valueWidth)}`
39713
+ (row, i2) => ` ${row.label.padEnd(labelWidth)} ${(formatted[i2] ?? "").padStart(valueWidth)}`
39066
39714
  );
39067
39715
  }
39068
39716
  function renderCodeSizeTable(codeSize, options) {
@@ -39222,12 +39870,12 @@ Examples:
39222
39870
  // src/completion/index.ts
39223
39871
  function extractCommandTree(cmd) {
39224
39872
  const BUILTIN_FLAGS = /* @__PURE__ */ new Set(["--help", "-h", "--version", "-V"]);
39225
- const options = cmd.options.filter((o) => !o.hidden).filter((o) => !BUILTIN_FLAGS.has(o.long ?? "") && !BUILTIN_FLAGS.has(o.short ?? "")).map((o) => ({
39226
- flags: o.flags,
39227
- long: o.long ?? "",
39228
- short: o.short ?? null,
39229
- description: o.description,
39230
- takesValue: o.required || o.optional
39873
+ const options = cmd.options.filter((o2) => !o2.hidden).filter((o2) => !BUILTIN_FLAGS.has(o2.long ?? "") && !BUILTIN_FLAGS.has(o2.short ?? "")).map((o2) => ({
39874
+ flags: o2.flags,
39875
+ long: o2.long ?? "",
39876
+ short: o2.short ?? null,
39877
+ description: o2.description,
39878
+ takesValue: o2.required || o2.optional
39231
39879
  }));
39232
39880
  const subcommands = cmd.commands.filter((c51) => !c51._hidden).map((c51) => extractCommandTree(c51));
39233
39881
  return {
@@ -39296,15 +39944,15 @@ function generateBashCompletion(tree, binName) {
39296
39944
  function collectBashCases(tree, prefix) {
39297
39945
  const cases = /* @__PURE__ */ new Map();
39298
39946
  const subcommandNames = tree.subcommands.map((c51) => c51.name);
39299
- const optionNames = tree.options.flatMap((o) => o.short ? [o.long, o.short] : [o.long]);
39947
+ const optionNames = tree.options.flatMap((o2) => o2.short ? [o2.long, o2.short] : [o2.long]);
39300
39948
  const extraOptions = prefix === "" ? ["--help", "--version"] : ["--help"];
39301
39949
  const allOptions = [.../* @__PURE__ */ new Set([...optionNames, ...extraOptions])];
39302
39950
  cases.set(prefix, { subcommands: subcommandNames, options: allOptions });
39303
39951
  for (const sub of tree.subcommands) {
39304
39952
  const subPath = prefix ? `${prefix} ${sub.name}` : sub.name;
39305
39953
  const subCases = collectBashCases(sub, subPath);
39306
- for (const [k2, v2] of subCases) {
39307
- cases.set(k2, v2);
39954
+ for (const [k, v] of subCases) {
39955
+ cases.set(k, v);
39308
39956
  }
39309
39957
  }
39310
39958
  return cases;
@@ -39464,7 +40112,7 @@ function buildFishCondition(binName, parentPath) {
39464
40112
  if (parentPath.length === 1) {
39465
40113
  return `-n '__fish_seen_subcommand_from ${parentPath[0]}'`;
39466
40114
  }
39467
- const conditions = parentPath.map((p2) => `__fish_seen_subcommand_from ${p2}`);
40115
+ const conditions = parentPath.map((p) => `__fish_seen_subcommand_from ${p}`);
39468
40116
  return `-n '${conditions.join("; and ")}'`;
39469
40117
  }
39470
40118
  function generateCompletion(program3, shell, binName) {
@@ -39481,9 +40129,9 @@ function generateCompletion(program3, shell, binName) {
39481
40129
  }
39482
40130
 
39483
40131
  // src/completion/install.ts
39484
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "fs";
40132
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "fs";
39485
40133
  import { homedir as homedir2 } from "os";
39486
- import { join as join3 } from "path";
40134
+ import { join as join4 } from "path";
39487
40135
  var TRACE_DIR = ".trace";
39488
40136
  function completionFileName(shell) {
39489
40137
  switch (shell) {
@@ -39496,14 +40144,14 @@ function completionFileName(shell) {
39496
40144
  }
39497
40145
  }
39498
40146
  function getTraceDir2() {
39499
- return join3(homedir2(), TRACE_DIR);
40147
+ return join4(homedir2(), TRACE_DIR);
39500
40148
  }
39501
40149
  function getCompletionFilePath(shell) {
39502
- return join3(getTraceDir2(), completionFileName(shell));
40150
+ return join4(getTraceDir2(), completionFileName(shell));
39503
40151
  }
39504
40152
  function writeCompletionFile(shell, script) {
39505
40153
  const dir = getTraceDir2();
39506
- if (!existsSync2(dir)) {
40154
+ if (!existsSync3(dir)) {
39507
40155
  mkdirSync2(dir, { recursive: true });
39508
40156
  }
39509
40157
  const filePath = getCompletionFilePath(shell);
@@ -39774,7 +40422,7 @@ async function runList2(options) {
39774
40422
  await runInteractivePager({
39775
40423
  items: inboxes,
39776
40424
  header,
39777
- renderItem: (_inbox, i) => [rows[i] ?? ""],
40425
+ renderItem: (_inbox, i2) => [rows[i2] ?? ""],
39778
40426
  disabled: options.pager === false
39779
40427
  });
39780
40428
  console.log(formatInboxQuota(quota));
@@ -39895,8 +40543,8 @@ async function resolveSecret(label, flagBase, opts, readStdin = defaultReadStdin
39895
40543
  `No source for ${label}. Use --${flagBase}-stdin, --${flagBase}-file, or --${flagBase}-env (or run interactively to be prompted).`
39896
40544
  );
39897
40545
  }
39898
- const entered = await Ce({ message: `Enter ${label}:` });
39899
- if (q(entered) || typeof entered !== "string" || entered.length === 0) {
40546
+ const entered = await password({ message: `Enter ${label}:` });
40547
+ if (isCancel(entered) || typeof entered !== "string" || entered.length === 0) {
39900
40548
  throw new SecretInputError(`${label} entry was cancelled or empty.`);
39901
40549
  }
39902
40550
  return entered;
@@ -40197,6 +40845,16 @@ function authConfigDisplay(authConfig) {
40197
40845
  }
40198
40846
  return sanitizeDisplay(JSON.stringify(authConfig));
40199
40847
  }
40848
+ function mfaDisplay(mfa) {
40849
+ if (!mfa) return "(none)";
40850
+ const parts = [mfa.kind];
40851
+ if (mfa.issuer) parts.push(`issuer=${sanitizeDisplay(mfa.issuer)}`);
40852
+ if (mfa.accountName) parts.push(`account=${sanitizeDisplay(mfa.accountName)}`);
40853
+ if (mfa.digits !== 6) parts.push(`${mfa.digits} digits`);
40854
+ if (mfa.periodSeconds !== 30) parts.push(`${mfa.periodSeconds}s`);
40855
+ if (mfa.algorithm !== "SHA1") parts.push(mfa.algorithm);
40856
+ return parts.join(" \xB7 ");
40857
+ }
40200
40858
  function renderCredentialDetail(cred) {
40201
40859
  const pad = 13;
40202
40860
  return [
@@ -40205,11 +40863,14 @@ function renderCredentialDetail(cred) {
40205
40863
  `${"Type:".padEnd(pad)} ${cred.credentialType}`,
40206
40864
  `${"Environment:".padEnd(pad)} ${cred.environmentId}`,
40207
40865
  `${"Auth config:".padEnd(pad)} ${authConfigDisplay(cred.authConfig)}`,
40866
+ `${"MFA:".padEnd(pad)} ${mfaDisplay(cred.mfa)}`,
40208
40867
  `${"Created:".padEnd(pad)} ${formatDate(cred.createdAt)}`
40209
40868
  ].join("\n");
40210
40869
  }
40211
40870
  function printCredentialsTsv(creds) {
40212
- console.log(["credentialId", "label", "credentialType", "authConfig", "createdAt"].join(" "));
40871
+ console.log(
40872
+ ["credentialId", "label", "credentialType", "authConfig", "mfa", "createdAt"].join(" ")
40873
+ );
40213
40874
  for (const cred of creds) {
40214
40875
  console.log(
40215
40876
  [
@@ -40217,6 +40878,9 @@ function printCredentialsTsv(creds) {
40217
40878
  tsvSafe(sanitizeDisplay(cred.label)),
40218
40879
  tsvSafe(cred.credentialType),
40219
40880
  tsvSafe(authConfigDisplay(cred.authConfig)),
40881
+ // Kind only in TSV — the column is for scripting "which accounts have a
40882
+ // second factor", and the parameters would make the row unreadable.
40883
+ tsvSafe(cred.mfa ? cred.mfa.kind : ""),
40220
40884
  tsvSafe(toIso(cred.createdAt))
40221
40885
  ].join(" ")
40222
40886
  );
@@ -40384,12 +41048,12 @@ async function buildCreateBody(type, label, options) {
40384
41048
  const ac = buildUsernamePasswordAuthConfig(options);
40385
41049
  if ("error" in ac) failAuthBuild(ac);
40386
41050
  const username = await resolveSecret("username", "username", usernameOpts(options));
40387
- const password = await resolveSecret("password", "password", passwordOpts(options));
41051
+ const password2 = await resolveSecret("password", "password", passwordOpts(options));
40388
41052
  return {
40389
41053
  credentialType: "USERNAME_PASSWORD",
40390
41054
  ...labelFields,
40391
41055
  username,
40392
- password,
41056
+ password: password2,
40393
41057
  ...ac.value ? { authConfig: ac.value } : {}
40394
41058
  };
40395
41059
  }
@@ -40422,7 +41086,7 @@ async function runList3(options) {
40422
41086
  await runInteractivePager({
40423
41087
  items: creds,
40424
41088
  header,
40425
- renderItem: (_c, i) => [rows[i] ?? ""],
41089
+ renderItem: (_c, i2) => [rows[i2] ?? ""],
40426
41090
  disabled: options.pager === false
40427
41091
  });
40428
41092
  }
@@ -40511,6 +41175,112 @@ async function runUpdate2(credentialId, options) {
40511
41175
  }
40512
41176
  outputCredential(result.body, output);
40513
41177
  }
41178
+ function failMfaOp(action, status, body, credentialId) {
41179
+ const { message, errorCode } = readErrorFields(body);
41180
+ if (status === UNAUTHORIZED_STATUS2) {
41181
+ exitAuthFailed();
41182
+ }
41183
+ if (status === 403) {
41184
+ console.error(colorError(`Only Trace staff can ${action} a credential's second factor.`));
41185
+ process.exit(1);
41186
+ }
41187
+ if (status === 404) {
41188
+ console.error(colorError(message ?? `Not found: ${credentialId}.`));
41189
+ process.exit(1);
41190
+ }
41191
+ if (status === 422 && errorCode === "CREDENTIAL_MFA_UNSUPPORTED_TYPE") {
41192
+ console.error(colorError(message ?? "This credential type cannot carry a second factor."));
41193
+ process.exit(1);
41194
+ }
41195
+ if (status === 422 && errorCode === "CREDENTIAL_MFA_NOT_ENROLLED") {
41196
+ console.error(colorError(message ?? "This credential has no second factor enrolled."));
41197
+ process.exit(1);
41198
+ }
41199
+ if (status === 400) {
41200
+ console.error(colorError(message ?? "Invalid setup key (status 400)."));
41201
+ process.exit(1);
41202
+ }
41203
+ console.error(
41204
+ colorError(
41205
+ `Failed to ${action} the second factor (status ${status})${message ? `: ${message}` : "."}`
41206
+ )
41207
+ );
41208
+ process.exit(1);
41209
+ }
41210
+ async function runSetMfa(credentialId, options) {
41211
+ const output = parseOutput(options.output);
41212
+ requireEnvId(options.env);
41213
+ requireCredId(credentialId);
41214
+ const sourceOpts = {
41215
+ stdin: options.setupKeyStdin,
41216
+ file: options.setupKeyFile,
41217
+ env: options.setupKeyEnv
41218
+ };
41219
+ let setupKey;
41220
+ try {
41221
+ setupKey = await resolveSecret("TOTP setup key", "setup-key", sourceOpts);
41222
+ } catch (error48) {
41223
+ if (error48 instanceof SecretInputError) {
41224
+ console.error(colorError(error48.message));
41225
+ process.exit(1);
41226
+ }
41227
+ throw error48;
41228
+ }
41229
+ const organizationId = await resolveOrganizationId();
41230
+ const result = await authenticatedRequest(
41231
+ (client) => client.credential.setCredentialMfa({
41232
+ params: { organizationId, environmentId: options.env, credentialId },
41233
+ body: { kind: "TOTP", setupKey }
41234
+ })
41235
+ );
41236
+ if (result.status !== SUCCESS_STATUS) {
41237
+ failMfaOp("enrol", result.status, result.body, credentialId);
41238
+ }
41239
+ if (output === "table") {
41240
+ console.log(
41241
+ colorSuccess(`Enrolled a TOTP second factor on ${sanitizeDisplay(result.body.label)}`)
41242
+ );
41243
+ console.log("Verify it with: tracecli credential mfa-code <id> --env <envId>");
41244
+ }
41245
+ outputCredential(result.body, output);
41246
+ }
41247
+ async function runClearMfa(credentialId, options) {
41248
+ requireEnvId(options.env);
41249
+ requireCredId(credentialId);
41250
+ const organizationId = await resolveOrganizationId();
41251
+ const result = await authenticatedRequest(
41252
+ (client) => client.credential.clearCredentialMfa({
41253
+ params: { organizationId, environmentId: options.env, credentialId }
41254
+ })
41255
+ );
41256
+ if (result.status !== SUCCESS_STATUS) {
41257
+ failMfaOp("clear", result.status, result.body, credentialId);
41258
+ }
41259
+ console.log(colorSuccess(`Removed the second factor from ${credentialId}`));
41260
+ }
41261
+ async function runMfaCode(credentialId, options) {
41262
+ const output = parseOutput(options.output);
41263
+ requireEnvId(options.env);
41264
+ requireCredId(credentialId);
41265
+ const organizationId = await resolveOrganizationId();
41266
+ const result = await authenticatedRequest(
41267
+ (client) => client.credential.generateCredentialMfaCode({
41268
+ params: { organizationId, environmentId: options.env, credentialId }
41269
+ })
41270
+ );
41271
+ if (result.status !== SUCCESS_STATUS) {
41272
+ failMfaOp("generate a code for", result.status, result.body, credentialId);
41273
+ }
41274
+ if (output === "json") {
41275
+ console.log(JSON.stringify(result.body, null, 2));
41276
+ return;
41277
+ }
41278
+ if (output === "tsv") {
41279
+ console.log(result.body.code);
41280
+ return;
41281
+ }
41282
+ console.log(`${result.body.code} (valid for ${result.body.expiresInSeconds}s)`);
41283
+ }
40514
41284
  async function runDelete3(credentialId, options) {
40515
41285
  requireEnvId(options.env);
40516
41286
  requireCredId(credentialId);
@@ -40595,6 +41365,46 @@ function createDeleteCommand3() {
40595
41365
  await runDelete3(credentialId, options);
40596
41366
  });
40597
41367
  }
41368
+ function createSetMfaCommand() {
41369
+ return new Command("set-mfa").description("Attach or replace an account credential's TOTP second factor").argument("<credentialId>", "Credential UUID (a username-password or magic-auth credential)").requiredOption("--env <environmentId>", "Parent environment UUID").option("--setup-key-stdin", "Read the TOTP setup key from stdin").option("--setup-key-file <path>", "Read the TOTP setup key from a file").option("--setup-key-env <name>", "Read the TOTP setup key from an env var").option("-o, --output <format>", "Output format: table, json, tsv (default: table)", "table").addHelpText(
41370
+ "after",
41371
+ `
41372
+ The setup key is either a full otpauth:// URI or the bare base32 key a setup
41373
+ page shows under "can't scan the QR code?" \u2014 NOT a 6-digit code. Like every
41374
+ secret here it is read from stdin/file/env (or a no-echo prompt), never an
41375
+ inline flag, so it stays out of shell history and CI logs.
41376
+
41377
+ Where to find it: whatever you saved when the account's MFA was first set up.
41378
+ In a password manager it is the one-time-password field's underlying secret
41379
+ (the app shows the live code; you want the key behind it). If you no longer
41380
+ have it, turn MFA off and back on in the target app and capture the key then.
41381
+
41382
+ Examples:
41383
+ tracecli credential set-mfa <id> --env <envId> --setup-key-stdin # paste, no echo
41384
+ tracecli credential set-mfa <id> --env <envId> --setup-key-env TOTP_SETUP_KEY
41385
+ tracecli credential set-mfa <id> --env <envId> --setup-key-file ./key.txt
41386
+ tracecli credential mfa-code <id> --env <envId> # confirm the paste took`
41387
+ ).action(async (credentialId, options) => {
41388
+ await runSetMfa(credentialId, options);
41389
+ });
41390
+ }
41391
+ function createClearMfaCommand() {
41392
+ return new Command("clear-mfa").description("Remove an account credential's second factor").argument("<credentialId>", "Credential UUID").requiredOption("--env <environmentId>", "Parent environment UUID").action(async (credentialId, options) => {
41393
+ await runClearMfa(credentialId, options);
41394
+ });
41395
+ }
41396
+ function createMfaCodeCommand() {
41397
+ return new Command("mfa-code").description("Print the account's current TOTP code (the seed is never shown)").argument("<credentialId>", "Credential UUID").requiredOption("--env <environmentId>", "Parent environment UUID").option("-o, --output <format>", "Output format: table, json, tsv (default: table)", "table").addHelpText(
41398
+ "after",
41399
+ `
41400
+ Use this to confirm an enrolment took. The code always has a few seconds of life
41401
+ left \u2014 if the current window is nearly over, the API waits for the next one.
41402
+
41403
+ -o tsv prints the bare code, for piping into a form filler.`
41404
+ ).action(async (credentialId, options) => {
41405
+ await runMfaCode(credentialId, options);
41406
+ });
41407
+ }
40598
41408
  function createCredentialCommand() {
40599
41409
  const credential = new Command("credential").alias("cred").description("Manage environment credentials");
40600
41410
  credential.addCommand(createCreateCommand3());
@@ -40602,6 +41412,9 @@ function createCredentialCommand() {
40602
41412
  credential.addCommand(createGetCommand2());
40603
41413
  credential.addCommand(createUpdateCommand2());
40604
41414
  credential.addCommand(createDeleteCommand3());
41415
+ credential.addCommand(createSetMfaCommand());
41416
+ credential.addCommand(createClearMfaCommand());
41417
+ credential.addCommand(createMfaCodeCommand());
40605
41418
  credential.addCommand(createInboxCommand());
40606
41419
  return credential;
40607
41420
  }
@@ -40750,7 +41563,7 @@ function printEnvironmentsTsv(envs) {
40750
41563
  }
40751
41564
  function sortOrgEnvironments(envs) {
40752
41565
  return [...envs].sort(
40753
- (a, b2) => a.applicationName.localeCompare(b2.applicationName) || a.name.localeCompare(b2.name) || a.applicationId.localeCompare(b2.applicationId) || a.environmentId.localeCompare(b2.environmentId)
41566
+ (a2, b) => a2.applicationName.localeCompare(b.applicationName) || a2.name.localeCompare(b.name) || a2.applicationId.localeCompare(b.applicationId) || a2.environmentId.localeCompare(b.environmentId)
40754
41567
  );
40755
41568
  }
40756
41569
  function printOrgEnvironmentsTsv(envs) {
@@ -40780,17 +41593,17 @@ function printOrgEnvironmentsTsv(envs) {
40780
41593
  }
40781
41594
  }
40782
41595
  function buildEnvironmentTable(envs, leading) {
40783
- const cells = envs.map((e2) => ({
40784
- leading: leading.map((column) => sanitizeDisplay(column.value(e2))),
40785
- name: sanitizeDisplay(e2.name),
40786
- prod: e2.isProduction ? "yes" : "no",
40787
- url: e2.primaryUrl != null ? sanitizeDisplay(e2.primaryUrl) : "\u2014"
41596
+ const cells = envs.map((e) => ({
41597
+ leading: leading.map((column) => sanitizeDisplay(column.value(e))),
41598
+ name: sanitizeDisplay(e.name),
41599
+ prod: e.isProduction ? "yes" : "no",
41600
+ url: e.primaryUrl != null ? sanitizeDisplay(e.primaryUrl) : "\u2014"
40788
41601
  }));
40789
41602
  const leadingWidths = leading.map(
40790
- (column, i) => Math.max(column.header.length, ...cells.map((c51) => c51.leading[i]?.length ?? 0))
41603
+ (column, i2) => Math.max(column.header.length, ...cells.map((c51) => c51.leading[i2]?.length ?? 0))
40791
41604
  );
40792
41605
  const nameWidth = Math.max(4, ...cells.map((c51) => c51.name.length));
40793
- const padLeading = (values) => values.map((v2, i) => v2.padEnd(leadingWidths[i] ?? 0)).join(" ");
41606
+ const padLeading = (values) => values.map((v, i2) => v.padEnd(leadingWidths[i2] ?? 0)).join(" ");
40794
41607
  return {
40795
41608
  header: `${padLeading(leading.map((c51) => c51.header))} ${"NAME".padEnd(nameWidth)} PROD URL`,
40796
41609
  rows: cells.map(
@@ -40800,12 +41613,12 @@ function buildEnvironmentTable(envs, leading) {
40800
41613
  }
40801
41614
  var ENVIRONMENT_ID_COLUMN = {
40802
41615
  header: "ID",
40803
- value: (e2) => e2.environmentId
41616
+ value: (e) => e.environmentId
40804
41617
  };
40805
41618
  function buildOrgEnvironmentsTable(envs) {
40806
41619
  return buildEnvironmentTable(envs, [
40807
41620
  ENVIRONMENT_ID_COLUMN,
40808
- { header: "APPLICATION", value: (e2) => e2.applicationName }
41621
+ { header: "APPLICATION", value: (e) => e.applicationName }
40809
41622
  ]);
40810
41623
  }
40811
41624
  function buildEnvironmentsTable(envs) {
@@ -40887,8 +41700,8 @@ async function collectOrgEnvironments(requests) {
40887
41700
  }
40888
41701
  const apps = appsResult.data;
40889
41702
  const environments = [];
40890
- for (let i = 0; i < apps.length; i += ORG_LIST_CONCURRENCY) {
40891
- const batch = apps.slice(i, i + ORG_LIST_CONCURRENCY);
41703
+ for (let i2 = 0; i2 < apps.length; i2 += ORG_LIST_CONCURRENCY) {
41704
+ const batch = apps.slice(i2, i2 + ORG_LIST_CONCURRENCY);
40892
41705
  const results = await Promise.all(
40893
41706
  // Catch per request, not around the batch: a rejected fetch (ECONNRESET,
40894
41707
  // DNS failure) would otherwise reject the whole `Promise.all` and crash
@@ -40951,7 +41764,7 @@ async function runListAcrossOrganization(output, pager) {
40951
41764
  await runInteractivePager({
40952
41765
  items: envs,
40953
41766
  header,
40954
- renderItem: (_env, i) => [rows[i] ?? ""],
41767
+ renderItem: (_env, i2) => [rows[i2] ?? ""],
40955
41768
  disabled: pager === false
40956
41769
  });
40957
41770
  }
@@ -40989,7 +41802,7 @@ async function runList4(options) {
40989
41802
  await runInteractivePager({
40990
41803
  items: envs,
40991
41804
  header,
40992
- renderItem: (_env, i) => [rows[i] ?? ""],
41805
+ renderItem: (_env, i2) => [rows[i2] ?? ""],
40993
41806
  disabled: options.pager === false
40994
41807
  });
40995
41808
  }
@@ -41131,13 +41944,13 @@ function createEnvironmentCommand() {
41131
41944
 
41132
41945
  // src/metadata.ts
41133
41946
  import { readFileSync as readFileSync3 } from "fs";
41134
- import { dirname, join as join4 } from "path";
41947
+ import { dirname as dirname2, join as join5 } from "path";
41135
41948
  import { fileURLToPath } from "url";
41136
41949
  var DEFAULT_PACKAGE_NAME = "securewithtrace";
41137
41950
  var DEFAULT_VERSION = "0.0.1";
41138
41951
  function readPackageMetadata() {
41139
41952
  const currentFilePath = fileURLToPath(import.meta.url);
41140
- const packageJsonPath = join4(dirname(currentFilePath), "..", "package.json");
41953
+ const packageJsonPath = join5(dirname2(currentFilePath), "..", "package.json");
41141
41954
  try {
41142
41955
  const rawPackageJson = readFileSync3(packageJsonPath, "utf-8");
41143
41956
  const parsed = JSON.parse(rawPackageJson);
@@ -41190,7 +42003,7 @@ async function resolvePentestId(organizationId, identifier) {
41190
42003
  console.error(`Failed to list pentests (status ${result.status}).`);
41191
42004
  process.exit(1);
41192
42005
  }
41193
- const pentest = result.body.find((p2) => p2.displayId === displayId);
42006
+ const pentest = result.body.find((p) => p.displayId === displayId);
41194
42007
  if (!pentest) {
41195
42008
  console.error(
41196
42009
  `Pentest with display ID ${displayId} not found.
@@ -41425,10 +42238,10 @@ function applyMultiSelectIntakeAnswer(current, key, selected) {
41425
42238
  };
41426
42239
  }
41427
42240
  function formatIssueClasses(values) {
41428
- return values.map((v2) => INTAKE_ISSUE_CLASS_LABELS[v2]).join(", ");
42241
+ return values.map((v) => INTAKE_ISSUE_CLASS_LABELS[v]).join(", ");
41429
42242
  }
41430
42243
  function formatSurfaces(values) {
41431
- return values.map((v2) => INTAKE_SURFACE_LABELS[v2]).join(", ");
42244
+ return values.map((v) => INTAKE_SURFACE_LABELS[v]).join(", ");
41432
42245
  }
41433
42246
  function formatAnswerValue(key, answers) {
41434
42247
  switch (key) {
@@ -41489,8 +42302,8 @@ function surfaceSelectOptions() {
41489
42302
  // src/pentest/commands.ts
41490
42303
  var DEFAULT_LIMIT2 = 30;
41491
42304
  var MAX_LIMIT2 = 100;
41492
- function displayPentestStatus(pt2) {
41493
- return pt2.status ?? pt2.customerStatus ?? "UNKNOWN";
42305
+ function displayPentestStatus(pt) {
42306
+ return pt.status ?? pt.customerStatus ?? "UNKNOWN";
41494
42307
  }
41495
42308
  function tsvSafe2(value) {
41496
42309
  return value.replace(/[\t\n\r]/g, " ");
@@ -41499,8 +42312,8 @@ function formatDate2(date5) {
41499
42312
  if (!date5) {
41500
42313
  return "\u2014";
41501
42314
  }
41502
- const d2 = typeof date5 === "string" ? new Date(date5) : date5;
41503
- return d2.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
42315
+ const d = typeof date5 === "string" ? new Date(date5) : date5;
42316
+ return d.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
41504
42317
  }
41505
42318
  function formatFindingSeverity(severity) {
41506
42319
  switch (severity) {
@@ -41526,12 +42339,12 @@ function createListCommand6() {
41526
42339
  ).option(
41527
42340
  "-L, --limit <n>",
41528
42341
  `Max results to return (default: ${DEFAULT_LIMIT2}, max: ${MAX_LIMIT2})`,
41529
- (v2) => {
41530
- const n = Number.parseInt(v2, 10);
41531
- if (Number.isNaN(n) || n < 1) {
42342
+ (v) => {
42343
+ const n3 = Number.parseInt(v, 10);
42344
+ if (Number.isNaN(n3) || n3 < 1) {
41532
42345
  throw new Error("--limit must be a positive integer");
41533
42346
  }
41534
- return Math.min(n, MAX_LIMIT2);
42347
+ return Math.min(n3, MAX_LIMIT2);
41535
42348
  }
41536
42349
  ).option("-o, --output <format>", "Output format: table, json, tsv (default: table)", "table").option("-w, --web", "Open the pentests dashboard in a browser").option("--no-pager", "Disable the interactive arrow-key pager for table output").addHelpText(
41537
42350
  "after",
@@ -41573,7 +42386,7 @@ Examples:
41573
42386
  let filteredPentests = allPentests;
41574
42387
  if (options.status) {
41575
42388
  filteredPentests = filteredPentests.filter(
41576
- (p2) => displayPentestStatus(p2) === options.status
42389
+ (p) => displayPentestStatus(p) === options.status
41577
42390
  );
41578
42391
  }
41579
42392
  const limit = options.limit ?? DEFAULT_LIMIT2;
@@ -41596,14 +42409,14 @@ Examples:
41596
42409
  }
41597
42410
  if (isTsv) {
41598
42411
  console.log("displayId title status startedAt endedAt findingsTotal");
41599
- for (const pt2 of pentests) {
42412
+ for (const pt of pentests) {
41600
42413
  const cols = [
41601
- `PT-${pt2.displayId}`,
41602
- tsvSafe2(pt2.title),
41603
- displayPentestStatus(pt2),
41604
- pt2.startedAt ? String(pt2.startedAt) : "",
41605
- pt2.endedAt ? String(pt2.endedAt) : "",
41606
- String(pt2.findingCounts.total)
42414
+ `PT-${pt.displayId}`,
42415
+ tsvSafe2(pt.title),
42416
+ displayPentestStatus(pt),
42417
+ pt.startedAt ? String(pt.startedAt) : "",
42418
+ pt.endedAt ? String(pt.endedAt) : "",
42419
+ String(pt.findingCounts.total)
41607
42420
  ];
41608
42421
  console.log(cols.join(" "));
41609
42422
  }
@@ -41613,24 +42426,24 @@ Examples:
41613
42426
  await runInteractivePager({
41614
42427
  items: pentests,
41615
42428
  header,
41616
- renderItem: (pt2) => renderPentestLines(pt2),
42429
+ renderItem: (pt) => renderPentestLines(pt),
41617
42430
  disabled: options.pager === false
41618
42431
  });
41619
42432
  }
41620
42433
  );
41621
42434
  }
41622
- function renderPentestLines(pt2) {
41623
- const status = formatStatus(displayPentestStatus(pt2));
41624
- const started = formatDate2(pt2.startedAt);
41625
- const ended = formatDate2(pt2.endedAt);
41626
- const dateRange = pt2.startedAt ? `${started} \u2013 ${ended}` : "Not started";
41627
- const findings = pt2.findingCounts.total;
42435
+ function renderPentestLines(pt) {
42436
+ const status = formatStatus(displayPentestStatus(pt));
42437
+ const started = formatDate2(pt.startedAt);
42438
+ const ended = formatDate2(pt.endedAt);
42439
+ const dateRange = pt.startedAt ? `${started} \u2013 ${ended}` : "Not started";
42440
+ const findings = pt.findingCounts.total;
41628
42441
  const lines = [
41629
- ` [PT-${pt2.displayId}] ${pt2.title}`,
42442
+ ` [PT-${pt.displayId}] ${pt.title}`,
41630
42443
  ` Status: ${status} | Findings: ${findings} | ${dateRange}`
41631
42444
  ];
41632
- if (pt2.description) {
41633
- lines.push(` ${pt2.description}`);
42445
+ if (pt.description) {
42446
+ lines.push(` ${pt.description}`);
41634
42447
  }
41635
42448
  lines.push("");
41636
42449
  return lines;
@@ -41647,12 +42460,12 @@ function createFindingsListCommand() {
41647
42460
  ).option(
41648
42461
  "-L, --limit <n>",
41649
42462
  `Max results to return (default: ${DEFAULT_LIMIT2}, max: ${MAX_LIMIT2})`,
41650
- (v2) => {
41651
- const n = Number.parseInt(v2, 10);
41652
- if (Number.isNaN(n) || n < 1) {
42463
+ (v) => {
42464
+ const n3 = Number.parseInt(v, 10);
42465
+ if (Number.isNaN(n3) || n3 < 1) {
41653
42466
  throw new Error("--limit must be a positive integer");
41654
42467
  }
41655
- return Math.min(n, MAX_LIMIT2);
42468
+ return Math.min(n3, MAX_LIMIT2);
41656
42469
  }
41657
42470
  ).option("-o, --output <format>", "Output format: table, json, tsv (default: table)", "table").option("-w, --web", "Open the pentest detail page in a browser").option("--no-pager", "Disable the interactive arrow-key pager for table output").addHelpText(
41658
42471
  "after",
@@ -41703,7 +42516,7 @@ Examples:
41703
42516
  (f) => (!options.severity || f.severity === options.severity) && (!options.status || f.status === options.status)
41704
42517
  );
41705
42518
  filteredFindings.sort(
41706
- (a, b2) => (SEVERITY_ORDER[a.severity] ?? 99) - (SEVERITY_ORDER[b2.severity] ?? 99)
42519
+ (a2, b) => (SEVERITY_ORDER[a2.severity] ?? 99) - (SEVERITY_ORDER[b.severity] ?? 99)
41707
42520
  );
41708
42521
  const limit = options.limit ?? DEFAULT_LIMIT2;
41709
42522
  const findings = filteredFindings.slice(0, limit);
@@ -41872,46 +42685,46 @@ function truncateForDisplay(value, max = 120) {
41872
42685
  }
41873
42686
  return `${value.slice(0, max - 1)}\u2026`;
41874
42687
  }
41875
- function printPentestUpdateDetail(pt2) {
42688
+ function printPentestUpdateDetail(pt) {
41876
42689
  const pad = 14;
41877
42690
  console.log(
41878
42691
  [
41879
- `${"ID:".padEnd(pad)} PT-${pt2.displayId}`,
41880
- `${"Title:".padEnd(pad)} ${sanitizeDisplay(pt2.title)}`,
41881
- `${"Status:".padEnd(pad)} ${sanitizeDisplay(pt2.status)}`,
41882
- `${"Stage:".padEnd(pad)} ${sanitizeDisplay(pt2.currentStage)}`,
41883
- `${"Description:".padEnd(pad)} ${pt2.description ? sanitizeDisplay(truncateForDisplay(pt2.description)) : "\u2014"}`,
41884
- `${"Priorities:".padEnd(pad)} ${sanitizeDisplay(formatPriorities(pt2.customerPriorityCategories))}`,
41885
- `${"Concerns:".padEnd(pad)} ${pt2.customerConcernsContext ? sanitizeDisplay(truncateForDisplay(pt2.customerConcernsContext)) : "\u2014"}`,
41886
- `${"Updated:".padEnd(pad)} ${toIso(pt2.updatedAt)}`
42692
+ `${"ID:".padEnd(pad)} PT-${pt.displayId}`,
42693
+ `${"Title:".padEnd(pad)} ${sanitizeDisplay(pt.title)}`,
42694
+ `${"Status:".padEnd(pad)} ${sanitizeDisplay(pt.status)}`,
42695
+ `${"Stage:".padEnd(pad)} ${sanitizeDisplay(pt.currentStage)}`,
42696
+ `${"Description:".padEnd(pad)} ${pt.description ? sanitizeDisplay(truncateForDisplay(pt.description)) : "\u2014"}`,
42697
+ `${"Priorities:".padEnd(pad)} ${sanitizeDisplay(formatPriorities(pt.customerPriorityCategories))}`,
42698
+ `${"Concerns:".padEnd(pad)} ${pt.customerConcernsContext ? sanitizeDisplay(truncateForDisplay(pt.customerConcernsContext)) : "\u2014"}`,
42699
+ `${"Updated:".padEnd(pad)} ${toIso(pt.updatedAt)}`
41887
42700
  ].join("\n")
41888
42701
  );
41889
42702
  }
41890
- function printPentestUpdateTsv(pt2) {
42703
+ function printPentestUpdateTsv(pt) {
41891
42704
  console.log("displayId title status stage description priorities concerns updatedAt");
41892
42705
  console.log(
41893
42706
  [
41894
- `PT-${pt2.displayId}`,
41895
- tsvSafe2(sanitizeDisplay(pt2.title)),
41896
- tsvSafe2(sanitizeDisplay(pt2.status)),
41897
- tsvSafe2(sanitizeDisplay(pt2.currentStage)),
41898
- tsvSafe2(sanitizeDisplay(pt2.description ?? "")),
41899
- tsvSafe2(sanitizeDisplay(pt2.customerPriorityCategories.join(","))),
41900
- tsvSafe2(sanitizeDisplay(pt2.customerConcernsContext ?? "")),
41901
- toIso(pt2.updatedAt)
42707
+ `PT-${pt.displayId}`,
42708
+ tsvSafe2(sanitizeDisplay(pt.title)),
42709
+ tsvSafe2(sanitizeDisplay(pt.status)),
42710
+ tsvSafe2(sanitizeDisplay(pt.currentStage)),
42711
+ tsvSafe2(sanitizeDisplay(pt.description ?? "")),
42712
+ tsvSafe2(sanitizeDisplay(pt.customerPriorityCategories.join(","))),
42713
+ tsvSafe2(sanitizeDisplay(pt.customerConcernsContext ?? "")),
42714
+ toIso(pt.updatedAt)
41902
42715
  ].join(" ")
41903
42716
  );
41904
42717
  }
41905
- function outputPentestUpdate(pt2, output) {
42718
+ function outputPentestUpdate(pt, output) {
41906
42719
  if (output === "json") {
41907
- console.log(JSON.stringify(pt2, null, 2));
42720
+ console.log(JSON.stringify(pt, null, 2));
41908
42721
  return;
41909
42722
  }
41910
42723
  if (output === "tsv") {
41911
- printPentestUpdateTsv(pt2);
42724
+ printPentestUpdateTsv(pt);
41912
42725
  return;
41913
42726
  }
41914
- printPentestUpdateDetail(pt2);
42727
+ printPentestUpdateDetail(pt);
41915
42728
  }
41916
42729
  async function runUpdate4(pentestIdentifier, options) {
41917
42730
  const output = parseOutput(options.output);
@@ -42083,19 +42896,19 @@ function questionnaireShowInput(body) {
42083
42896
  };
42084
42897
  }
42085
42898
  function exitCancelled() {
42086
- me("Cancelled.");
42899
+ cancel("Cancelled.");
42087
42900
  process.exit(1);
42088
42901
  }
42089
42902
  async function promptQuestionnaireAnswers(existing) {
42090
42903
  let working = { ...existing ?? {} };
42091
42904
  const textPrompt = async (key, question) => {
42092
42905
  const previous = existing?.[key];
42093
- const value = await fe({
42094
- message: `${question} (empty keeps previous)`,
42906
+ const value = await multiline({
42907
+ message: `${question} (Enter for a new line, Enter twice to continue \u2014 empty keeps previous)`,
42095
42908
  initialValue: previous ?? "",
42096
- ...previous ? {} : { placeholder: "Optional, press Enter to skip" }
42909
+ ...previous ? {} : { placeholder: "Optional, press Enter twice to skip" }
42097
42910
  });
42098
- if (q(value)) {
42911
+ if (isCancel(value)) {
42099
42912
  exitCancelled();
42100
42913
  }
42101
42914
  working = applyTextIntakeAnswer(working, key, value);
@@ -42107,35 +42920,35 @@ async function promptQuestionnaireAnswers(existing) {
42107
42920
  }
42108
42921
  const message = `${entry.question} (empty keeps previous)`;
42109
42922
  if (entry.key === "issueClasses") {
42110
- const selected = await ve({
42923
+ const selected = await multiselect({
42111
42924
  message,
42112
42925
  options: issueClassSelectOptions(),
42113
42926
  required: false,
42114
42927
  ...existing?.issueClasses !== void 0 ? { initialValues: existing.issueClasses } : {}
42115
42928
  });
42116
- if (q(selected)) {
42929
+ if (isCancel(selected)) {
42117
42930
  exitCancelled();
42118
42931
  }
42119
42932
  working = applyMultiSelectIntakeAnswer(working, "issueClasses", selected);
42120
42933
  } else {
42121
- const selected = await ve({
42934
+ const selected = await multiselect({
42122
42935
  message,
42123
42936
  options: surfaceSelectOptions(),
42124
42937
  required: false,
42125
42938
  ...existing?.surfaces !== void 0 ? { initialValues: existing.surfaces } : {}
42126
42939
  });
42127
- if (q(selected)) {
42940
+ if (isCancel(selected)) {
42128
42941
  exitCancelled();
42129
42942
  }
42130
42943
  working = applyMultiSelectIntakeAnswer(working, "surfaces", selected);
42131
42944
  }
42132
42945
  await textPrompt(entry.notesKey, entry.notesQuestion);
42133
42946
  }
42134
- const confirmed = await ue({
42947
+ const confirmed = await confirm({
42135
42948
  message: "Save questionnaire answers?",
42136
42949
  initialValue: true
42137
42950
  });
42138
- if (q(confirmed) || !confirmed) {
42951
+ if (isCancel(confirmed) || !confirmed) {
42139
42952
  exitCancelled();
42140
42953
  }
42141
42954
  if (Object.keys(working).length === 0) {
@@ -42258,8 +43071,8 @@ function createPentestCommand() {
42258
43071
  }
42259
43072
 
42260
43073
  // src/update/commands.ts
42261
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
42262
- import { dirname as dirname2, join as join5 } from "path";
43074
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
43075
+ import { dirname as dirname3, join as join6 } from "path";
42263
43076
  import { createInterface as createInterface4 } from "readline/promises";
42264
43077
  var UPDATE_CACHE_FILE = "update-check.json";
42265
43078
  var UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -42268,11 +43081,11 @@ var DISABLE_UPDATE_NOTIFIER_ENV = "TRACECLI_DISABLE_UPDATE_NOTIFIER";
42268
43081
  var REGISTRY_URL_ENV = "TRACECLI_NPM_REGISTRY_URL";
42269
43082
  var noticePrinted = false;
42270
43083
  function getUpdateCheckCachePath() {
42271
- return join5(getTraceDir(), UPDATE_CACHE_FILE);
43084
+ return join6(getTraceDir(), UPDATE_CACHE_FILE);
42272
43085
  }
42273
43086
  function readUpdateCheckCache() {
42274
43087
  const cachePath = getUpdateCheckCachePath();
42275
- if (!existsSync3(cachePath)) {
43088
+ if (!existsSync4(cachePath)) {
42276
43089
  return null;
42277
43090
  }
42278
43091
  try {
@@ -42295,7 +43108,7 @@ function readUpdateCheckCache() {
42295
43108
  }
42296
43109
  function writeUpdateCheckCache(cache) {
42297
43110
  const cachePath = getUpdateCheckCachePath();
42298
- mkdirSync3(dirname2(cachePath), { recursive: true, mode: 448 });
43111
+ mkdirSync3(dirname3(cachePath), { recursive: true, mode: 448 });
42299
43112
  writeFileSync4(cachePath, `${JSON.stringify(cache, null, 2)}
42300
43113
  `, {
42301
43114
  encoding: "utf-8",
@@ -42319,11 +43132,11 @@ function parseSemver(version2) {
42319
43132
  const prerelease = match[4] ? match[4].split(".") : [];
42320
43133
  return { major, minor, patch, prerelease };
42321
43134
  }
42322
- function comparePrerelease(a, b2) {
42323
- const maxLength = Math.max(a.length, b2.length);
43135
+ function comparePrerelease(a2, b) {
43136
+ const maxLength = Math.max(a2.length, b.length);
42324
43137
  for (let index = 0; index < maxLength; index += 1) {
42325
- const aPart = a[index];
42326
- const bPart = b2[index];
43138
+ const aPart = a2[index];
43139
+ const bPart = b[index];
42327
43140
  if (aPart === void 0 && bPart === void 0) {
42328
43141
  return 0;
42329
43142
  }
@@ -42355,9 +43168,9 @@ function comparePrerelease(a, b2) {
42355
43168
  }
42356
43169
  return 0;
42357
43170
  }
42358
- function compareSemver(a, b2) {
42359
- const aSemver = parseSemver(a);
42360
- const bSemver = parseSemver(b2);
43171
+ function compareSemver(a2, b) {
43172
+ const aSemver = parseSemver(a2);
43173
+ const bSemver = parseSemver(b);
42361
43174
  if (!aSemver || !bSemver) {
42362
43175
  return null;
42363
43176
  }
@@ -42541,11 +43354,11 @@ async function maybeNotifyUpdateAvailable(commandName) {
42541
43354
  `A new tracecli version is available: ${availability.currentVersion} -> ${availability.latestVersion}`,
42542
43355
  "Run `tracecli upgrade` to install the latest version."
42543
43356
  ];
42544
- const maxLen = Math.max(...lines.map((l) => l.length));
43357
+ const maxLen = Math.max(...lines.map((l2) => l2.length));
42545
43358
  const pad = (s) => s + " ".repeat(maxLen - s.length);
42546
43359
  const top = `\u256D${"\u2500".repeat(maxLen + 2)}\u256E`;
42547
43360
  const bottom = `\u2570${"\u2500".repeat(maxLen + 2)}\u256F`;
42548
- const boxed = [top, ...lines.map((l) => `\u2502 ${pad(l)} \u2502`), bottom].join("\n");
43361
+ const boxed = [top, ...lines.map((l2) => `\u2502 ${pad(l2)} \u2502`), bottom].join("\n");
42549
43362
  console.log("");
42550
43363
  console.log(colorMuted(boxed));
42551
43364
  console.log("");
@@ -42684,8 +43497,8 @@ async function resolveRepositoryIdAuthenticated(organizationId, repoIdentifier)
42684
43497
  const repos = result.body;
42685
43498
  const isBareNameOnly = !repoIdentifier.includes("/") && !repoIdentifier.startsWith("http");
42686
43499
  if (!isBareNameOnly) {
42687
- const match = repos.find((r) => {
42688
- const url2 = r.repositoryUrl;
43500
+ const match = repos.find((r2) => {
43501
+ const url2 = r2.repositoryUrl;
42689
43502
  if (url2.endsWith(`/${repoIdentifier}`)) return true;
42690
43503
  if (url2.endsWith(`/${repoIdentifier}.git`)) return true;
42691
43504
  if (url2 === repoIdentifier) return true;
@@ -42695,8 +43508,8 @@ async function resolveRepositoryIdAuthenticated(organizationId, repoIdentifier)
42695
43508
  return match.repositoryId;
42696
43509
  }
42697
43510
  }
42698
- const byName = repos.filter((r) => {
42699
- const segments = r.repositoryUrl.replace(/\.git$/, "").split("/");
43511
+ const byName = repos.filter((r2) => {
43512
+ const segments = r2.repositoryUrl.replace(/\.git$/, "").split("/");
42700
43513
  const name = segments[segments.length - 1];
42701
43514
  return name === repoIdentifier;
42702
43515
  });
@@ -42706,7 +43519,7 @@ async function resolveRepositoryIdAuthenticated(organizationId, repoIdentifier)
42706
43519
  if (byName.length > 1) {
42707
43520
  console.error(
42708
43521
  `Ambiguous repository name '${repoIdentifier}'. Multiple matches found:
42709
- ${byName.map((r) => ` - ${r.repositoryUrl}`).join("\n")}
43522
+ ${byName.map((r2) => ` - ${r2.repositoryUrl}`).join("\n")}
42710
43523
  Please use the full owner/repo format.`
42711
43524
  );
42712
43525
  process.exit(1);
@@ -42747,7 +43560,7 @@ function renderVulnerabilityLines(vuln) {
42747
43560
  }
42748
43561
  function sortVulnerabilitiesBySeverity(vulnerabilities) {
42749
43562
  return [...vulnerabilities].sort(
42750
- (a, b2) => (SEVERITY_ORDER[a.severity] ?? 99) - (SEVERITY_ORDER[b2.severity] ?? 99)
43563
+ (a2, b) => (SEVERITY_ORDER[a2.severity] ?? 99) - (SEVERITY_ORDER[b.severity] ?? 99)
42751
43564
  );
42752
43565
  }
42753
43566
  function sanitizeTsvField(value) {
@@ -42755,7 +43568,7 @@ function sanitizeTsvField(value) {
42755
43568
  }
42756
43569
  function printVulnerabilitiesTsv(vulnerabilities) {
42757
43570
  const sorted = [...vulnerabilities].sort(
42758
- (a, b2) => (SEVERITY_ORDER[a.severity] ?? 99) - (SEVERITY_ORDER[b2.severity] ?? 99)
43571
+ (a2, b) => (SEVERITY_ORDER[a2.severity] ?? 99) - (SEVERITY_ORDER[b.severity] ?? 99)
42759
43572
  );
42760
43573
  console.log("severity status repository file line traceId title");
42761
43574
  for (const vuln of sorted) {
@@ -42887,12 +43700,12 @@ function createListCommand7() {
42887
43700
  ).option(
42888
43701
  "-L, --limit <n>",
42889
43702
  `Max results to return (default: ${DEFAULT_LIMIT3}, max: ${MAX_LIMIT3})`,
42890
- (v2) => {
42891
- const n = Number.parseInt(v2, 10);
42892
- if (Number.isNaN(n) || n < 1) {
43703
+ (v) => {
43704
+ const n3 = Number.parseInt(v, 10);
43705
+ if (Number.isNaN(n3) || n3 < 1) {
42893
43706
  throw new Error("--limit must be a positive integer");
42894
43707
  }
42895
- return Math.min(n, MAX_LIMIT3);
43708
+ return Math.min(n3, MAX_LIMIT3);
42896
43709
  }
42897
43710
  ).option(
42898
43711
  "-f, --filter <expression>",