@shipers-dev/multi 0.8.0 → 0.8.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 (3) hide show
  1. package/dist/index.js +338 -338
  2. package/package.json +1 -1
  3. package/src/index.ts +1 -1
package/dist/index.js CHANGED
@@ -604,20 +604,20 @@ var makeIssue = (params) => {
604
604
  };
605
605
  };
606
606
  var EMPTY_PATH = [];
607
- function addIssueToContext(ctx2, issueData) {
607
+ function addIssueToContext(ctx, issueData) {
608
608
  const overrideMap = getErrorMap();
609
609
  const issue = makeIssue({
610
610
  issueData,
611
- data: ctx2.data,
612
- path: ctx2.path,
611
+ data: ctx.data,
612
+ path: ctx.path,
613
613
  errorMaps: [
614
- ctx2.common.contextualErrorMap,
615
- ctx2.schemaErrorMap,
614
+ ctx.common.contextualErrorMap,
615
+ ctx.schemaErrorMap,
616
616
  overrideMap,
617
617
  overrideMap === en_default ? undefined : en_default
618
618
  ].filter((x) => !!x)
619
619
  });
620
- ctx2.common.issues.push(issue);
620
+ ctx.common.issues.push(issue);
621
621
  }
622
622
 
623
623
  class ParseStatus {
@@ -710,11 +710,11 @@ class ParseInputLazyPath {
710
710
  return this._cachedPath;
711
711
  }
712
712
  }
713
- var handleResult = (ctx2, result) => {
713
+ var handleResult = (ctx, result) => {
714
714
  if (isValid(result)) {
715
715
  return { success: true, data: result.value };
716
716
  } else {
717
- if (!ctx2.common.issues.length) {
717
+ if (!ctx.common.issues.length) {
718
718
  throw new Error("Validation failed but no issues detected.");
719
719
  }
720
720
  return {
@@ -722,7 +722,7 @@ var handleResult = (ctx2, result) => {
722
722
  get error() {
723
723
  if (this._error)
724
724
  return this._error;
725
- const error = new ZodError(ctx2.common.issues);
725
+ const error = new ZodError(ctx.common.issues);
726
726
  this._error = error;
727
727
  return this._error;
728
728
  }
@@ -738,17 +738,17 @@ function processCreateParams(params) {
738
738
  }
739
739
  if (errorMap2)
740
740
  return { errorMap: errorMap2, description };
741
- const customMap = (iss, ctx2) => {
741
+ const customMap = (iss, ctx) => {
742
742
  const { message } = params;
743
743
  if (iss.code === "invalid_enum_value") {
744
- return { message: message ?? ctx2.defaultError };
744
+ return { message: message ?? ctx.defaultError };
745
745
  }
746
- if (typeof ctx2.data === "undefined") {
747
- return { message: message ?? required_error ?? ctx2.defaultError };
746
+ if (typeof ctx.data === "undefined") {
747
+ return { message: message ?? required_error ?? ctx.defaultError };
748
748
  }
749
749
  if (iss.code !== "invalid_type")
750
- return { message: ctx2.defaultError };
751
- return { message: message ?? invalid_type_error ?? ctx2.defaultError };
750
+ return { message: ctx.defaultError };
751
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
752
752
  };
753
753
  return { errorMap: customMap, description };
754
754
  }
@@ -760,8 +760,8 @@ class ZodType {
760
760
  _getType(input) {
761
761
  return getParsedType(input.data);
762
762
  }
763
- _getOrReturnCtx(input, ctx2) {
764
- return ctx2 || {
763
+ _getOrReturnCtx(input, ctx) {
764
+ return ctx || {
765
765
  common: input.parent.common,
766
766
  data: input.data,
767
767
  parsedType: getParsedType(input.data),
@@ -801,7 +801,7 @@ class ZodType {
801
801
  throw result.error;
802
802
  }
803
803
  safeParse(data, params) {
804
- const ctx2 = {
804
+ const ctx = {
805
805
  common: {
806
806
  issues: [],
807
807
  async: params?.async ?? false,
@@ -813,11 +813,11 @@ class ZodType {
813
813
  data,
814
814
  parsedType: getParsedType(data)
815
815
  };
816
- const result = this._parseSync({ data, path: ctx2.path, parent: ctx2 });
817
- return handleResult(ctx2, result);
816
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
817
+ return handleResult(ctx, result);
818
818
  }
819
819
  "~validate"(data) {
820
- const ctx2 = {
820
+ const ctx = {
821
821
  common: {
822
822
  issues: [],
823
823
  async: !!this["~standard"].async
@@ -830,26 +830,26 @@ class ZodType {
830
830
  };
831
831
  if (!this["~standard"].async) {
832
832
  try {
833
- const result = this._parseSync({ data, path: [], parent: ctx2 });
833
+ const result = this._parseSync({ data, path: [], parent: ctx });
834
834
  return isValid(result) ? {
835
835
  value: result.value
836
836
  } : {
837
- issues: ctx2.common.issues
837
+ issues: ctx.common.issues
838
838
  };
839
839
  } catch (err) {
840
840
  if (err?.message?.toLowerCase()?.includes("encountered")) {
841
841
  this["~standard"].async = true;
842
842
  }
843
- ctx2.common = {
843
+ ctx.common = {
844
844
  issues: [],
845
845
  async: true
846
846
  };
847
847
  }
848
848
  }
849
- return this._parseAsync({ data, path: [], parent: ctx2 }).then((result) => isValid(result) ? {
849
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
850
850
  value: result.value
851
851
  } : {
852
- issues: ctx2.common.issues
852
+ issues: ctx.common.issues
853
853
  });
854
854
  }
855
855
  async parseAsync(data, params) {
@@ -859,7 +859,7 @@ class ZodType {
859
859
  throw result.error;
860
860
  }
861
861
  async safeParseAsync(data, params) {
862
- const ctx2 = {
862
+ const ctx = {
863
863
  common: {
864
864
  issues: [],
865
865
  contextualErrorMap: params?.errorMap,
@@ -871,9 +871,9 @@ class ZodType {
871
871
  data,
872
872
  parsedType: getParsedType(data)
873
873
  };
874
- const maybeAsyncResult = this._parse({ data, path: ctx2.path, parent: ctx2 });
874
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
875
875
  const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
876
- return handleResult(ctx2, result);
876
+ return handleResult(ctx, result);
877
877
  }
878
878
  refine(check, message) {
879
879
  const getIssueProperties = (val) => {
@@ -885,9 +885,9 @@ class ZodType {
885
885
  return message;
886
886
  }
887
887
  };
888
- return this._refinement((val, ctx2) => {
888
+ return this._refinement((val, ctx) => {
889
889
  const result = check(val);
890
- const setError = () => ctx2.addIssue({
890
+ const setError = () => ctx.addIssue({
891
891
  code: ZodIssueCode.custom,
892
892
  ...getIssueProperties(val)
893
893
  });
@@ -910,9 +910,9 @@ class ZodType {
910
910
  });
911
911
  }
912
912
  refinement(check, refinementData) {
913
- return this._refinement((val, ctx2) => {
913
+ return this._refinement((val, ctx) => {
914
914
  if (!check(val)) {
915
- ctx2.addIssue(typeof refinementData === "function" ? refinementData(val, ctx2) : refinementData);
915
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
916
916
  return false;
917
917
  } else {
918
918
  return true;
@@ -1124,21 +1124,21 @@ class ZodString extends ZodType {
1124
1124
  }
1125
1125
  const parsedType = this._getType(input);
1126
1126
  if (parsedType !== ZodParsedType.string) {
1127
- const ctx3 = this._getOrReturnCtx(input);
1128
- addIssueToContext(ctx3, {
1127
+ const ctx2 = this._getOrReturnCtx(input);
1128
+ addIssueToContext(ctx2, {
1129
1129
  code: ZodIssueCode.invalid_type,
1130
1130
  expected: ZodParsedType.string,
1131
- received: ctx3.parsedType
1131
+ received: ctx2.parsedType
1132
1132
  });
1133
1133
  return INVALID;
1134
1134
  }
1135
1135
  const status = new ParseStatus;
1136
- let ctx2 = undefined;
1136
+ let ctx = undefined;
1137
1137
  for (const check of this._def.checks) {
1138
1138
  if (check.kind === "min") {
1139
1139
  if (input.data.length < check.value) {
1140
- ctx2 = this._getOrReturnCtx(input, ctx2);
1141
- addIssueToContext(ctx2, {
1140
+ ctx = this._getOrReturnCtx(input, ctx);
1141
+ addIssueToContext(ctx, {
1142
1142
  code: ZodIssueCode.too_small,
1143
1143
  minimum: check.value,
1144
1144
  type: "string",
@@ -1150,8 +1150,8 @@ class ZodString extends ZodType {
1150
1150
  }
1151
1151
  } else if (check.kind === "max") {
1152
1152
  if (input.data.length > check.value) {
1153
- ctx2 = this._getOrReturnCtx(input, ctx2);
1154
- addIssueToContext(ctx2, {
1153
+ ctx = this._getOrReturnCtx(input, ctx);
1154
+ addIssueToContext(ctx, {
1155
1155
  code: ZodIssueCode.too_big,
1156
1156
  maximum: check.value,
1157
1157
  type: "string",
@@ -1165,9 +1165,9 @@ class ZodString extends ZodType {
1165
1165
  const tooBig = input.data.length > check.value;
1166
1166
  const tooSmall = input.data.length < check.value;
1167
1167
  if (tooBig || tooSmall) {
1168
- ctx2 = this._getOrReturnCtx(input, ctx2);
1168
+ ctx = this._getOrReturnCtx(input, ctx);
1169
1169
  if (tooBig) {
1170
- addIssueToContext(ctx2, {
1170
+ addIssueToContext(ctx, {
1171
1171
  code: ZodIssueCode.too_big,
1172
1172
  maximum: check.value,
1173
1173
  type: "string",
@@ -1176,7 +1176,7 @@ class ZodString extends ZodType {
1176
1176
  message: check.message
1177
1177
  });
1178
1178
  } else if (tooSmall) {
1179
- addIssueToContext(ctx2, {
1179
+ addIssueToContext(ctx, {
1180
1180
  code: ZodIssueCode.too_small,
1181
1181
  minimum: check.value,
1182
1182
  type: "string",
@@ -1189,8 +1189,8 @@ class ZodString extends ZodType {
1189
1189
  }
1190
1190
  } else if (check.kind === "email") {
1191
1191
  if (!emailRegex.test(input.data)) {
1192
- ctx2 = this._getOrReturnCtx(input, ctx2);
1193
- addIssueToContext(ctx2, {
1192
+ ctx = this._getOrReturnCtx(input, ctx);
1193
+ addIssueToContext(ctx, {
1194
1194
  validation: "email",
1195
1195
  code: ZodIssueCode.invalid_string,
1196
1196
  message: check.message
@@ -1202,8 +1202,8 @@ class ZodString extends ZodType {
1202
1202
  emojiRegex = new RegExp(_emojiRegex, "u");
1203
1203
  }
1204
1204
  if (!emojiRegex.test(input.data)) {
1205
- ctx2 = this._getOrReturnCtx(input, ctx2);
1206
- addIssueToContext(ctx2, {
1205
+ ctx = this._getOrReturnCtx(input, ctx);
1206
+ addIssueToContext(ctx, {
1207
1207
  validation: "emoji",
1208
1208
  code: ZodIssueCode.invalid_string,
1209
1209
  message: check.message
@@ -1212,8 +1212,8 @@ class ZodString extends ZodType {
1212
1212
  }
1213
1213
  } else if (check.kind === "uuid") {
1214
1214
  if (!uuidRegex.test(input.data)) {
1215
- ctx2 = this._getOrReturnCtx(input, ctx2);
1216
- addIssueToContext(ctx2, {
1215
+ ctx = this._getOrReturnCtx(input, ctx);
1216
+ addIssueToContext(ctx, {
1217
1217
  validation: "uuid",
1218
1218
  code: ZodIssueCode.invalid_string,
1219
1219
  message: check.message
@@ -1222,8 +1222,8 @@ class ZodString extends ZodType {
1222
1222
  }
1223
1223
  } else if (check.kind === "nanoid") {
1224
1224
  if (!nanoidRegex.test(input.data)) {
1225
- ctx2 = this._getOrReturnCtx(input, ctx2);
1226
- addIssueToContext(ctx2, {
1225
+ ctx = this._getOrReturnCtx(input, ctx);
1226
+ addIssueToContext(ctx, {
1227
1227
  validation: "nanoid",
1228
1228
  code: ZodIssueCode.invalid_string,
1229
1229
  message: check.message
@@ -1232,8 +1232,8 @@ class ZodString extends ZodType {
1232
1232
  }
1233
1233
  } else if (check.kind === "cuid") {
1234
1234
  if (!cuidRegex.test(input.data)) {
1235
- ctx2 = this._getOrReturnCtx(input, ctx2);
1236
- addIssueToContext(ctx2, {
1235
+ ctx = this._getOrReturnCtx(input, ctx);
1236
+ addIssueToContext(ctx, {
1237
1237
  validation: "cuid",
1238
1238
  code: ZodIssueCode.invalid_string,
1239
1239
  message: check.message
@@ -1242,8 +1242,8 @@ class ZodString extends ZodType {
1242
1242
  }
1243
1243
  } else if (check.kind === "cuid2") {
1244
1244
  if (!cuid2Regex.test(input.data)) {
1245
- ctx2 = this._getOrReturnCtx(input, ctx2);
1246
- addIssueToContext(ctx2, {
1245
+ ctx = this._getOrReturnCtx(input, ctx);
1246
+ addIssueToContext(ctx, {
1247
1247
  validation: "cuid2",
1248
1248
  code: ZodIssueCode.invalid_string,
1249
1249
  message: check.message
@@ -1252,8 +1252,8 @@ class ZodString extends ZodType {
1252
1252
  }
1253
1253
  } else if (check.kind === "ulid") {
1254
1254
  if (!ulidRegex.test(input.data)) {
1255
- ctx2 = this._getOrReturnCtx(input, ctx2);
1256
- addIssueToContext(ctx2, {
1255
+ ctx = this._getOrReturnCtx(input, ctx);
1256
+ addIssueToContext(ctx, {
1257
1257
  validation: "ulid",
1258
1258
  code: ZodIssueCode.invalid_string,
1259
1259
  message: check.message
@@ -1264,8 +1264,8 @@ class ZodString extends ZodType {
1264
1264
  try {
1265
1265
  new URL(input.data);
1266
1266
  } catch {
1267
- ctx2 = this._getOrReturnCtx(input, ctx2);
1268
- addIssueToContext(ctx2, {
1267
+ ctx = this._getOrReturnCtx(input, ctx);
1268
+ addIssueToContext(ctx, {
1269
1269
  validation: "url",
1270
1270
  code: ZodIssueCode.invalid_string,
1271
1271
  message: check.message
@@ -1276,8 +1276,8 @@ class ZodString extends ZodType {
1276
1276
  check.regex.lastIndex = 0;
1277
1277
  const testResult = check.regex.test(input.data);
1278
1278
  if (!testResult) {
1279
- ctx2 = this._getOrReturnCtx(input, ctx2);
1280
- addIssueToContext(ctx2, {
1279
+ ctx = this._getOrReturnCtx(input, ctx);
1280
+ addIssueToContext(ctx, {
1281
1281
  validation: "regex",
1282
1282
  code: ZodIssueCode.invalid_string,
1283
1283
  message: check.message
@@ -1288,8 +1288,8 @@ class ZodString extends ZodType {
1288
1288
  input.data = input.data.trim();
1289
1289
  } else if (check.kind === "includes") {
1290
1290
  if (!input.data.includes(check.value, check.position)) {
1291
- ctx2 = this._getOrReturnCtx(input, ctx2);
1292
- addIssueToContext(ctx2, {
1291
+ ctx = this._getOrReturnCtx(input, ctx);
1292
+ addIssueToContext(ctx, {
1293
1293
  code: ZodIssueCode.invalid_string,
1294
1294
  validation: { includes: check.value, position: check.position },
1295
1295
  message: check.message
@@ -1302,8 +1302,8 @@ class ZodString extends ZodType {
1302
1302
  input.data = input.data.toUpperCase();
1303
1303
  } else if (check.kind === "startsWith") {
1304
1304
  if (!input.data.startsWith(check.value)) {
1305
- ctx2 = this._getOrReturnCtx(input, ctx2);
1306
- addIssueToContext(ctx2, {
1305
+ ctx = this._getOrReturnCtx(input, ctx);
1306
+ addIssueToContext(ctx, {
1307
1307
  code: ZodIssueCode.invalid_string,
1308
1308
  validation: { startsWith: check.value },
1309
1309
  message: check.message
@@ -1312,8 +1312,8 @@ class ZodString extends ZodType {
1312
1312
  }
1313
1313
  } else if (check.kind === "endsWith") {
1314
1314
  if (!input.data.endsWith(check.value)) {
1315
- ctx2 = this._getOrReturnCtx(input, ctx2);
1316
- addIssueToContext(ctx2, {
1315
+ ctx = this._getOrReturnCtx(input, ctx);
1316
+ addIssueToContext(ctx, {
1317
1317
  code: ZodIssueCode.invalid_string,
1318
1318
  validation: { endsWith: check.value },
1319
1319
  message: check.message
@@ -1323,8 +1323,8 @@ class ZodString extends ZodType {
1323
1323
  } else if (check.kind === "datetime") {
1324
1324
  const regex = datetimeRegex(check);
1325
1325
  if (!regex.test(input.data)) {
1326
- ctx2 = this._getOrReturnCtx(input, ctx2);
1327
- addIssueToContext(ctx2, {
1326
+ ctx = this._getOrReturnCtx(input, ctx);
1327
+ addIssueToContext(ctx, {
1328
1328
  code: ZodIssueCode.invalid_string,
1329
1329
  validation: "datetime",
1330
1330
  message: check.message
@@ -1334,8 +1334,8 @@ class ZodString extends ZodType {
1334
1334
  } else if (check.kind === "date") {
1335
1335
  const regex = dateRegex;
1336
1336
  if (!regex.test(input.data)) {
1337
- ctx2 = this._getOrReturnCtx(input, ctx2);
1338
- addIssueToContext(ctx2, {
1337
+ ctx = this._getOrReturnCtx(input, ctx);
1338
+ addIssueToContext(ctx, {
1339
1339
  code: ZodIssueCode.invalid_string,
1340
1340
  validation: "date",
1341
1341
  message: check.message
@@ -1345,8 +1345,8 @@ class ZodString extends ZodType {
1345
1345
  } else if (check.kind === "time") {
1346
1346
  const regex = timeRegex(check);
1347
1347
  if (!regex.test(input.data)) {
1348
- ctx2 = this._getOrReturnCtx(input, ctx2);
1349
- addIssueToContext(ctx2, {
1348
+ ctx = this._getOrReturnCtx(input, ctx);
1349
+ addIssueToContext(ctx, {
1350
1350
  code: ZodIssueCode.invalid_string,
1351
1351
  validation: "time",
1352
1352
  message: check.message
@@ -1355,8 +1355,8 @@ class ZodString extends ZodType {
1355
1355
  }
1356
1356
  } else if (check.kind === "duration") {
1357
1357
  if (!durationRegex.test(input.data)) {
1358
- ctx2 = this._getOrReturnCtx(input, ctx2);
1359
- addIssueToContext(ctx2, {
1358
+ ctx = this._getOrReturnCtx(input, ctx);
1359
+ addIssueToContext(ctx, {
1360
1360
  validation: "duration",
1361
1361
  code: ZodIssueCode.invalid_string,
1362
1362
  message: check.message
@@ -1365,8 +1365,8 @@ class ZodString extends ZodType {
1365
1365
  }
1366
1366
  } else if (check.kind === "ip") {
1367
1367
  if (!isValidIP(input.data, check.version)) {
1368
- ctx2 = this._getOrReturnCtx(input, ctx2);
1369
- addIssueToContext(ctx2, {
1368
+ ctx = this._getOrReturnCtx(input, ctx);
1369
+ addIssueToContext(ctx, {
1370
1370
  validation: "ip",
1371
1371
  code: ZodIssueCode.invalid_string,
1372
1372
  message: check.message
@@ -1375,8 +1375,8 @@ class ZodString extends ZodType {
1375
1375
  }
1376
1376
  } else if (check.kind === "jwt") {
1377
1377
  if (!isValidJWT(input.data, check.alg)) {
1378
- ctx2 = this._getOrReturnCtx(input, ctx2);
1379
- addIssueToContext(ctx2, {
1378
+ ctx = this._getOrReturnCtx(input, ctx);
1379
+ addIssueToContext(ctx, {
1380
1380
  validation: "jwt",
1381
1381
  code: ZodIssueCode.invalid_string,
1382
1382
  message: check.message
@@ -1385,8 +1385,8 @@ class ZodString extends ZodType {
1385
1385
  }
1386
1386
  } else if (check.kind === "cidr") {
1387
1387
  if (!isValidCidr(input.data, check.version)) {
1388
- ctx2 = this._getOrReturnCtx(input, ctx2);
1389
- addIssueToContext(ctx2, {
1388
+ ctx = this._getOrReturnCtx(input, ctx);
1389
+ addIssueToContext(ctx, {
1390
1390
  validation: "cidr",
1391
1391
  code: ZodIssueCode.invalid_string,
1392
1392
  message: check.message
@@ -1395,8 +1395,8 @@ class ZodString extends ZodType {
1395
1395
  }
1396
1396
  } else if (check.kind === "base64") {
1397
1397
  if (!base64Regex.test(input.data)) {
1398
- ctx2 = this._getOrReturnCtx(input, ctx2);
1399
- addIssueToContext(ctx2, {
1398
+ ctx = this._getOrReturnCtx(input, ctx);
1399
+ addIssueToContext(ctx, {
1400
1400
  validation: "base64",
1401
1401
  code: ZodIssueCode.invalid_string,
1402
1402
  message: check.message
@@ -1405,8 +1405,8 @@ class ZodString extends ZodType {
1405
1405
  }
1406
1406
  } else if (check.kind === "base64url") {
1407
1407
  if (!base64urlRegex.test(input.data)) {
1408
- ctx2 = this._getOrReturnCtx(input, ctx2);
1409
- addIssueToContext(ctx2, {
1408
+ ctx = this._getOrReturnCtx(input, ctx);
1409
+ addIssueToContext(ctx, {
1410
1410
  validation: "base64url",
1411
1411
  code: ZodIssueCode.invalid_string,
1412
1412
  message: check.message
@@ -1682,21 +1682,21 @@ class ZodNumber extends ZodType {
1682
1682
  }
1683
1683
  const parsedType = this._getType(input);
1684
1684
  if (parsedType !== ZodParsedType.number) {
1685
- const ctx3 = this._getOrReturnCtx(input);
1686
- addIssueToContext(ctx3, {
1685
+ const ctx2 = this._getOrReturnCtx(input);
1686
+ addIssueToContext(ctx2, {
1687
1687
  code: ZodIssueCode.invalid_type,
1688
1688
  expected: ZodParsedType.number,
1689
- received: ctx3.parsedType
1689
+ received: ctx2.parsedType
1690
1690
  });
1691
1691
  return INVALID;
1692
1692
  }
1693
- let ctx2 = undefined;
1693
+ let ctx = undefined;
1694
1694
  const status = new ParseStatus;
1695
1695
  for (const check of this._def.checks) {
1696
1696
  if (check.kind === "int") {
1697
1697
  if (!util.isInteger(input.data)) {
1698
- ctx2 = this._getOrReturnCtx(input, ctx2);
1699
- addIssueToContext(ctx2, {
1698
+ ctx = this._getOrReturnCtx(input, ctx);
1699
+ addIssueToContext(ctx, {
1700
1700
  code: ZodIssueCode.invalid_type,
1701
1701
  expected: "integer",
1702
1702
  received: "float",
@@ -1707,8 +1707,8 @@ class ZodNumber extends ZodType {
1707
1707
  } else if (check.kind === "min") {
1708
1708
  const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1709
1709
  if (tooSmall) {
1710
- ctx2 = this._getOrReturnCtx(input, ctx2);
1711
- addIssueToContext(ctx2, {
1710
+ ctx = this._getOrReturnCtx(input, ctx);
1711
+ addIssueToContext(ctx, {
1712
1712
  code: ZodIssueCode.too_small,
1713
1713
  minimum: check.value,
1714
1714
  type: "number",
@@ -1721,8 +1721,8 @@ class ZodNumber extends ZodType {
1721
1721
  } else if (check.kind === "max") {
1722
1722
  const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1723
1723
  if (tooBig) {
1724
- ctx2 = this._getOrReturnCtx(input, ctx2);
1725
- addIssueToContext(ctx2, {
1724
+ ctx = this._getOrReturnCtx(input, ctx);
1725
+ addIssueToContext(ctx, {
1726
1726
  code: ZodIssueCode.too_big,
1727
1727
  maximum: check.value,
1728
1728
  type: "number",
@@ -1734,8 +1734,8 @@ class ZodNumber extends ZodType {
1734
1734
  }
1735
1735
  } else if (check.kind === "multipleOf") {
1736
1736
  if (floatSafeRemainder(input.data, check.value) !== 0) {
1737
- ctx2 = this._getOrReturnCtx(input, ctx2);
1738
- addIssueToContext(ctx2, {
1737
+ ctx = this._getOrReturnCtx(input, ctx);
1738
+ addIssueToContext(ctx, {
1739
1739
  code: ZodIssueCode.not_multiple_of,
1740
1740
  multipleOf: check.value,
1741
1741
  message: check.message
@@ -1744,8 +1744,8 @@ class ZodNumber extends ZodType {
1744
1744
  }
1745
1745
  } else if (check.kind === "finite") {
1746
1746
  if (!Number.isFinite(input.data)) {
1747
- ctx2 = this._getOrReturnCtx(input, ctx2);
1748
- addIssueToContext(ctx2, {
1747
+ ctx = this._getOrReturnCtx(input, ctx);
1748
+ addIssueToContext(ctx, {
1749
1749
  code: ZodIssueCode.not_finite,
1750
1750
  message: check.message
1751
1751
  });
@@ -1920,14 +1920,14 @@ class ZodBigInt extends ZodType {
1920
1920
  if (parsedType !== ZodParsedType.bigint) {
1921
1921
  return this._getInvalidInput(input);
1922
1922
  }
1923
- let ctx2 = undefined;
1923
+ let ctx = undefined;
1924
1924
  const status = new ParseStatus;
1925
1925
  for (const check of this._def.checks) {
1926
1926
  if (check.kind === "min") {
1927
1927
  const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1928
1928
  if (tooSmall) {
1929
- ctx2 = this._getOrReturnCtx(input, ctx2);
1930
- addIssueToContext(ctx2, {
1929
+ ctx = this._getOrReturnCtx(input, ctx);
1930
+ addIssueToContext(ctx, {
1931
1931
  code: ZodIssueCode.too_small,
1932
1932
  type: "bigint",
1933
1933
  minimum: check.value,
@@ -1939,8 +1939,8 @@ class ZodBigInt extends ZodType {
1939
1939
  } else if (check.kind === "max") {
1940
1940
  const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1941
1941
  if (tooBig) {
1942
- ctx2 = this._getOrReturnCtx(input, ctx2);
1943
- addIssueToContext(ctx2, {
1942
+ ctx = this._getOrReturnCtx(input, ctx);
1943
+ addIssueToContext(ctx, {
1944
1944
  code: ZodIssueCode.too_big,
1945
1945
  type: "bigint",
1946
1946
  maximum: check.value,
@@ -1951,8 +1951,8 @@ class ZodBigInt extends ZodType {
1951
1951
  }
1952
1952
  } else if (check.kind === "multipleOf") {
1953
1953
  if (input.data % check.value !== BigInt(0)) {
1954
- ctx2 = this._getOrReturnCtx(input, ctx2);
1955
- addIssueToContext(ctx2, {
1954
+ ctx = this._getOrReturnCtx(input, ctx);
1955
+ addIssueToContext(ctx, {
1956
1956
  code: ZodIssueCode.not_multiple_of,
1957
1957
  multipleOf: check.value,
1958
1958
  message: check.message
@@ -1966,11 +1966,11 @@ class ZodBigInt extends ZodType {
1966
1966
  return { status: status.value, value: input.data };
1967
1967
  }
1968
1968
  _getInvalidInput(input) {
1969
- const ctx2 = this._getOrReturnCtx(input);
1970
- addIssueToContext(ctx2, {
1969
+ const ctx = this._getOrReturnCtx(input);
1970
+ addIssueToContext(ctx, {
1971
1971
  code: ZodIssueCode.invalid_type,
1972
1972
  expected: ZodParsedType.bigint,
1973
- received: ctx2.parsedType
1973
+ received: ctx.parsedType
1974
1974
  });
1975
1975
  return INVALID;
1976
1976
  }
@@ -2082,11 +2082,11 @@ class ZodBoolean extends ZodType {
2082
2082
  }
2083
2083
  const parsedType = this._getType(input);
2084
2084
  if (parsedType !== ZodParsedType.boolean) {
2085
- const ctx2 = this._getOrReturnCtx(input);
2086
- addIssueToContext(ctx2, {
2085
+ const ctx = this._getOrReturnCtx(input);
2086
+ addIssueToContext(ctx, {
2087
2087
  code: ZodIssueCode.invalid_type,
2088
2088
  expected: ZodParsedType.boolean,
2089
- received: ctx2.parsedType
2089
+ received: ctx.parsedType
2090
2090
  });
2091
2091
  return INVALID;
2092
2092
  }
@@ -2108,28 +2108,28 @@ class ZodDate extends ZodType {
2108
2108
  }
2109
2109
  const parsedType = this._getType(input);
2110
2110
  if (parsedType !== ZodParsedType.date) {
2111
- const ctx3 = this._getOrReturnCtx(input);
2112
- addIssueToContext(ctx3, {
2111
+ const ctx2 = this._getOrReturnCtx(input);
2112
+ addIssueToContext(ctx2, {
2113
2113
  code: ZodIssueCode.invalid_type,
2114
2114
  expected: ZodParsedType.date,
2115
- received: ctx3.parsedType
2115
+ received: ctx2.parsedType
2116
2116
  });
2117
2117
  return INVALID;
2118
2118
  }
2119
2119
  if (Number.isNaN(input.data.getTime())) {
2120
- const ctx3 = this._getOrReturnCtx(input);
2121
- addIssueToContext(ctx3, {
2120
+ const ctx2 = this._getOrReturnCtx(input);
2121
+ addIssueToContext(ctx2, {
2122
2122
  code: ZodIssueCode.invalid_date
2123
2123
  });
2124
2124
  return INVALID;
2125
2125
  }
2126
2126
  const status = new ParseStatus;
2127
- let ctx2 = undefined;
2127
+ let ctx = undefined;
2128
2128
  for (const check of this._def.checks) {
2129
2129
  if (check.kind === "min") {
2130
2130
  if (input.data.getTime() < check.value) {
2131
- ctx2 = this._getOrReturnCtx(input, ctx2);
2132
- addIssueToContext(ctx2, {
2131
+ ctx = this._getOrReturnCtx(input, ctx);
2132
+ addIssueToContext(ctx, {
2133
2133
  code: ZodIssueCode.too_small,
2134
2134
  message: check.message,
2135
2135
  inclusive: true,
@@ -2141,8 +2141,8 @@ class ZodDate extends ZodType {
2141
2141
  }
2142
2142
  } else if (check.kind === "max") {
2143
2143
  if (input.data.getTime() > check.value) {
2144
- ctx2 = this._getOrReturnCtx(input, ctx2);
2145
- addIssueToContext(ctx2, {
2144
+ ctx = this._getOrReturnCtx(input, ctx);
2145
+ addIssueToContext(ctx, {
2146
2146
  code: ZodIssueCode.too_big,
2147
2147
  message: check.message,
2148
2148
  inclusive: true,
@@ -2215,11 +2215,11 @@ class ZodSymbol extends ZodType {
2215
2215
  _parse(input) {
2216
2216
  const parsedType = this._getType(input);
2217
2217
  if (parsedType !== ZodParsedType.symbol) {
2218
- const ctx2 = this._getOrReturnCtx(input);
2219
- addIssueToContext(ctx2, {
2218
+ const ctx = this._getOrReturnCtx(input);
2219
+ addIssueToContext(ctx, {
2220
2220
  code: ZodIssueCode.invalid_type,
2221
2221
  expected: ZodParsedType.symbol,
2222
- received: ctx2.parsedType
2222
+ received: ctx.parsedType
2223
2223
  });
2224
2224
  return INVALID;
2225
2225
  }
@@ -2237,11 +2237,11 @@ class ZodUndefined extends ZodType {
2237
2237
  _parse(input) {
2238
2238
  const parsedType = this._getType(input);
2239
2239
  if (parsedType !== ZodParsedType.undefined) {
2240
- const ctx2 = this._getOrReturnCtx(input);
2241
- addIssueToContext(ctx2, {
2240
+ const ctx = this._getOrReturnCtx(input);
2241
+ addIssueToContext(ctx, {
2242
2242
  code: ZodIssueCode.invalid_type,
2243
2243
  expected: ZodParsedType.undefined,
2244
- received: ctx2.parsedType
2244
+ received: ctx.parsedType
2245
2245
  });
2246
2246
  return INVALID;
2247
2247
  }
@@ -2259,11 +2259,11 @@ class ZodNull extends ZodType {
2259
2259
  _parse(input) {
2260
2260
  const parsedType = this._getType(input);
2261
2261
  if (parsedType !== ZodParsedType.null) {
2262
- const ctx2 = this._getOrReturnCtx(input);
2263
- addIssueToContext(ctx2, {
2262
+ const ctx = this._getOrReturnCtx(input);
2263
+ addIssueToContext(ctx, {
2264
2264
  code: ZodIssueCode.invalid_type,
2265
2265
  expected: ZodParsedType.null,
2266
- received: ctx2.parsedType
2266
+ received: ctx.parsedType
2267
2267
  });
2268
2268
  return INVALID;
2269
2269
  }
@@ -2311,11 +2311,11 @@ ZodUnknown.create = (params) => {
2311
2311
 
2312
2312
  class ZodNever extends ZodType {
2313
2313
  _parse(input) {
2314
- const ctx2 = this._getOrReturnCtx(input);
2315
- addIssueToContext(ctx2, {
2314
+ const ctx = this._getOrReturnCtx(input);
2315
+ addIssueToContext(ctx, {
2316
2316
  code: ZodIssueCode.invalid_type,
2317
2317
  expected: ZodParsedType.never,
2318
- received: ctx2.parsedType
2318
+ received: ctx.parsedType
2319
2319
  });
2320
2320
  return INVALID;
2321
2321
  }
@@ -2331,11 +2331,11 @@ class ZodVoid extends ZodType {
2331
2331
  _parse(input) {
2332
2332
  const parsedType = this._getType(input);
2333
2333
  if (parsedType !== ZodParsedType.undefined) {
2334
- const ctx2 = this._getOrReturnCtx(input);
2335
- addIssueToContext(ctx2, {
2334
+ const ctx = this._getOrReturnCtx(input);
2335
+ addIssueToContext(ctx, {
2336
2336
  code: ZodIssueCode.invalid_type,
2337
2337
  expected: ZodParsedType.void,
2338
- received: ctx2.parsedType
2338
+ received: ctx.parsedType
2339
2339
  });
2340
2340
  return INVALID;
2341
2341
  }
@@ -2351,21 +2351,21 @@ ZodVoid.create = (params) => {
2351
2351
 
2352
2352
  class ZodArray extends ZodType {
2353
2353
  _parse(input) {
2354
- const { ctx: ctx2, status } = this._processInputParams(input);
2354
+ const { ctx, status } = this._processInputParams(input);
2355
2355
  const def = this._def;
2356
- if (ctx2.parsedType !== ZodParsedType.array) {
2357
- addIssueToContext(ctx2, {
2356
+ if (ctx.parsedType !== ZodParsedType.array) {
2357
+ addIssueToContext(ctx, {
2358
2358
  code: ZodIssueCode.invalid_type,
2359
2359
  expected: ZodParsedType.array,
2360
- received: ctx2.parsedType
2360
+ received: ctx.parsedType
2361
2361
  });
2362
2362
  return INVALID;
2363
2363
  }
2364
2364
  if (def.exactLength !== null) {
2365
- const tooBig = ctx2.data.length > def.exactLength.value;
2366
- const tooSmall = ctx2.data.length < def.exactLength.value;
2365
+ const tooBig = ctx.data.length > def.exactLength.value;
2366
+ const tooSmall = ctx.data.length < def.exactLength.value;
2367
2367
  if (tooBig || tooSmall) {
2368
- addIssueToContext(ctx2, {
2368
+ addIssueToContext(ctx, {
2369
2369
  code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2370
2370
  minimum: tooSmall ? def.exactLength.value : undefined,
2371
2371
  maximum: tooBig ? def.exactLength.value : undefined,
@@ -2378,8 +2378,8 @@ class ZodArray extends ZodType {
2378
2378
  }
2379
2379
  }
2380
2380
  if (def.minLength !== null) {
2381
- if (ctx2.data.length < def.minLength.value) {
2382
- addIssueToContext(ctx2, {
2381
+ if (ctx.data.length < def.minLength.value) {
2382
+ addIssueToContext(ctx, {
2383
2383
  code: ZodIssueCode.too_small,
2384
2384
  minimum: def.minLength.value,
2385
2385
  type: "array",
@@ -2391,8 +2391,8 @@ class ZodArray extends ZodType {
2391
2391
  }
2392
2392
  }
2393
2393
  if (def.maxLength !== null) {
2394
- if (ctx2.data.length > def.maxLength.value) {
2395
- addIssueToContext(ctx2, {
2394
+ if (ctx.data.length > def.maxLength.value) {
2395
+ addIssueToContext(ctx, {
2396
2396
  code: ZodIssueCode.too_big,
2397
2397
  maximum: def.maxLength.value,
2398
2398
  type: "array",
@@ -2403,15 +2403,15 @@ class ZodArray extends ZodType {
2403
2403
  status.dirty();
2404
2404
  }
2405
2405
  }
2406
- if (ctx2.common.async) {
2407
- return Promise.all([...ctx2.data].map((item, i) => {
2408
- return def.type._parseAsync(new ParseInputLazyPath(ctx2, item, ctx2.path, i));
2406
+ if (ctx.common.async) {
2407
+ return Promise.all([...ctx.data].map((item, i) => {
2408
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2409
2409
  })).then((result2) => {
2410
2410
  return ParseStatus.mergeArray(status, result2);
2411
2411
  });
2412
2412
  }
2413
- const result = [...ctx2.data].map((item, i) => {
2414
- return def.type._parseSync(new ParseInputLazyPath(ctx2, item, ctx2.path, i));
2413
+ const result = [...ctx.data].map((item, i) => {
2414
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2415
2415
  });
2416
2416
  return ParseStatus.mergeArray(status, result);
2417
2417
  }
@@ -2495,19 +2495,19 @@ class ZodObject extends ZodType {
2495
2495
  _parse(input) {
2496
2496
  const parsedType = this._getType(input);
2497
2497
  if (parsedType !== ZodParsedType.object) {
2498
- const ctx3 = this._getOrReturnCtx(input);
2499
- addIssueToContext(ctx3, {
2498
+ const ctx2 = this._getOrReturnCtx(input);
2499
+ addIssueToContext(ctx2, {
2500
2500
  code: ZodIssueCode.invalid_type,
2501
2501
  expected: ZodParsedType.object,
2502
- received: ctx3.parsedType
2502
+ received: ctx2.parsedType
2503
2503
  });
2504
2504
  return INVALID;
2505
2505
  }
2506
- const { status, ctx: ctx2 } = this._processInputParams(input);
2506
+ const { status, ctx } = this._processInputParams(input);
2507
2507
  const { shape, keys: shapeKeys } = this._getCached();
2508
2508
  const extraKeys = [];
2509
2509
  if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2510
- for (const key in ctx2.data) {
2510
+ for (const key in ctx.data) {
2511
2511
  if (!shapeKeys.includes(key)) {
2512
2512
  extraKeys.push(key);
2513
2513
  }
@@ -2516,11 +2516,11 @@ class ZodObject extends ZodType {
2516
2516
  const pairs = [];
2517
2517
  for (const key of shapeKeys) {
2518
2518
  const keyValidator = shape[key];
2519
- const value = ctx2.data[key];
2519
+ const value = ctx.data[key];
2520
2520
  pairs.push({
2521
2521
  key: { status: "valid", value: key },
2522
- value: keyValidator._parse(new ParseInputLazyPath(ctx2, value, ctx2.path, key)),
2523
- alwaysSet: key in ctx2.data
2522
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2523
+ alwaysSet: key in ctx.data
2524
2524
  });
2525
2525
  }
2526
2526
  if (this._def.catchall instanceof ZodNever) {
@@ -2529,12 +2529,12 @@ class ZodObject extends ZodType {
2529
2529
  for (const key of extraKeys) {
2530
2530
  pairs.push({
2531
2531
  key: { status: "valid", value: key },
2532
- value: { status: "valid", value: ctx2.data[key] }
2532
+ value: { status: "valid", value: ctx.data[key] }
2533
2533
  });
2534
2534
  }
2535
2535
  } else if (unknownKeys === "strict") {
2536
2536
  if (extraKeys.length > 0) {
2537
- addIssueToContext(ctx2, {
2537
+ addIssueToContext(ctx, {
2538
2538
  code: ZodIssueCode.unrecognized_keys,
2539
2539
  keys: extraKeys
2540
2540
  });
@@ -2546,15 +2546,15 @@ class ZodObject extends ZodType {
2546
2546
  } else {
2547
2547
  const catchall = this._def.catchall;
2548
2548
  for (const key of extraKeys) {
2549
- const value = ctx2.data[key];
2549
+ const value = ctx.data[key];
2550
2550
  pairs.push({
2551
2551
  key: { status: "valid", value: key },
2552
- value: catchall._parse(new ParseInputLazyPath(ctx2, value, ctx2.path, key)),
2553
- alwaysSet: key in ctx2.data
2552
+ value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2553
+ alwaysSet: key in ctx.data
2554
2554
  });
2555
2555
  }
2556
2556
  }
2557
- if (ctx2.common.async) {
2557
+ if (ctx.common.async) {
2558
2558
  return Promise.resolve().then(async () => {
2559
2559
  const syncPairs = [];
2560
2560
  for (const pair of pairs) {
@@ -2583,8 +2583,8 @@ class ZodObject extends ZodType {
2583
2583
  ...this._def,
2584
2584
  unknownKeys: "strict",
2585
2585
  ...message !== undefined ? {
2586
- errorMap: (issue, ctx2) => {
2587
- const defaultError = this._def.errorMap?.(issue, ctx2).message ?? ctx2.defaultError;
2586
+ errorMap: (issue, ctx) => {
2587
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2588
2588
  if (issue.code === "unrecognized_keys")
2589
2589
  return {
2590
2590
  message: errorUtil.errToObj(message).message ?? defaultError
@@ -2733,7 +2733,7 @@ ZodObject.lazycreate = (shape, params) => {
2733
2733
 
2734
2734
  class ZodUnion extends ZodType {
2735
2735
  _parse(input) {
2736
- const { ctx: ctx2 } = this._processInputParams(input);
2736
+ const { ctx } = this._processInputParams(input);
2737
2737
  const options = this._def.options;
2738
2738
  function handleResults(results) {
2739
2739
  for (const result of results) {
@@ -2743,31 +2743,31 @@ class ZodUnion extends ZodType {
2743
2743
  }
2744
2744
  for (const result of results) {
2745
2745
  if (result.result.status === "dirty") {
2746
- ctx2.common.issues.push(...result.ctx.common.issues);
2746
+ ctx.common.issues.push(...result.ctx.common.issues);
2747
2747
  return result.result;
2748
2748
  }
2749
2749
  }
2750
2750
  const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2751
- addIssueToContext(ctx2, {
2751
+ addIssueToContext(ctx, {
2752
2752
  code: ZodIssueCode.invalid_union,
2753
2753
  unionErrors
2754
2754
  });
2755
2755
  return INVALID;
2756
2756
  }
2757
- if (ctx2.common.async) {
2757
+ if (ctx.common.async) {
2758
2758
  return Promise.all(options.map(async (option) => {
2759
2759
  const childCtx = {
2760
- ...ctx2,
2760
+ ...ctx,
2761
2761
  common: {
2762
- ...ctx2.common,
2762
+ ...ctx.common,
2763
2763
  issues: []
2764
2764
  },
2765
2765
  parent: null
2766
2766
  };
2767
2767
  return {
2768
2768
  result: await option._parseAsync({
2769
- data: ctx2.data,
2770
- path: ctx2.path,
2769
+ data: ctx.data,
2770
+ path: ctx.path,
2771
2771
  parent: childCtx
2772
2772
  }),
2773
2773
  ctx: childCtx
@@ -2778,16 +2778,16 @@ class ZodUnion extends ZodType {
2778
2778
  const issues = [];
2779
2779
  for (const option of options) {
2780
2780
  const childCtx = {
2781
- ...ctx2,
2781
+ ...ctx,
2782
2782
  common: {
2783
- ...ctx2.common,
2783
+ ...ctx.common,
2784
2784
  issues: []
2785
2785
  },
2786
2786
  parent: null
2787
2787
  };
2788
2788
  const result = option._parseSync({
2789
- data: ctx2.data,
2790
- path: ctx2.path,
2789
+ data: ctx.data,
2790
+ path: ctx.path,
2791
2791
  parent: childCtx
2792
2792
  });
2793
2793
  if (result.status === "valid") {
@@ -2800,11 +2800,11 @@ class ZodUnion extends ZodType {
2800
2800
  }
2801
2801
  }
2802
2802
  if (dirty) {
2803
- ctx2.common.issues.push(...dirty.ctx.common.issues);
2803
+ ctx.common.issues.push(...dirty.ctx.common.issues);
2804
2804
  return dirty.result;
2805
2805
  }
2806
2806
  const unionErrors = issues.map((issues2) => new ZodError(issues2));
2807
- addIssueToContext(ctx2, {
2807
+ addIssueToContext(ctx, {
2808
2808
  code: ZodIssueCode.invalid_union,
2809
2809
  unionErrors
2810
2810
  });
@@ -2856,37 +2856,37 @@ var getDiscriminator = (type) => {
2856
2856
 
2857
2857
  class ZodDiscriminatedUnion extends ZodType {
2858
2858
  _parse(input) {
2859
- const { ctx: ctx2 } = this._processInputParams(input);
2860
- if (ctx2.parsedType !== ZodParsedType.object) {
2861
- addIssueToContext(ctx2, {
2859
+ const { ctx } = this._processInputParams(input);
2860
+ if (ctx.parsedType !== ZodParsedType.object) {
2861
+ addIssueToContext(ctx, {
2862
2862
  code: ZodIssueCode.invalid_type,
2863
2863
  expected: ZodParsedType.object,
2864
- received: ctx2.parsedType
2864
+ received: ctx.parsedType
2865
2865
  });
2866
2866
  return INVALID;
2867
2867
  }
2868
2868
  const discriminator = this.discriminator;
2869
- const discriminatorValue = ctx2.data[discriminator];
2869
+ const discriminatorValue = ctx.data[discriminator];
2870
2870
  const option = this.optionsMap.get(discriminatorValue);
2871
2871
  if (!option) {
2872
- addIssueToContext(ctx2, {
2872
+ addIssueToContext(ctx, {
2873
2873
  code: ZodIssueCode.invalid_union_discriminator,
2874
2874
  options: Array.from(this.optionsMap.keys()),
2875
2875
  path: [discriminator]
2876
2876
  });
2877
2877
  return INVALID;
2878
2878
  }
2879
- if (ctx2.common.async) {
2879
+ if (ctx.common.async) {
2880
2880
  return option._parseAsync({
2881
- data: ctx2.data,
2882
- path: ctx2.path,
2883
- parent: ctx2
2881
+ data: ctx.data,
2882
+ path: ctx.path,
2883
+ parent: ctx
2884
2884
  });
2885
2885
  } else {
2886
2886
  return option._parseSync({
2887
- data: ctx2.data,
2888
- path: ctx2.path,
2889
- parent: ctx2
2887
+ data: ctx.data,
2888
+ path: ctx.path,
2889
+ parent: ctx
2890
2890
  });
2891
2891
  }
2892
2892
  }
@@ -2963,14 +2963,14 @@ function mergeValues(a, b) {
2963
2963
 
2964
2964
  class ZodIntersection extends ZodType {
2965
2965
  _parse(input) {
2966
- const { status, ctx: ctx2 } = this._processInputParams(input);
2966
+ const { status, ctx } = this._processInputParams(input);
2967
2967
  const handleParsed = (parsedLeft, parsedRight) => {
2968
2968
  if (isAborted(parsedLeft) || isAborted(parsedRight)) {
2969
2969
  return INVALID;
2970
2970
  }
2971
2971
  const merged = mergeValues(parsedLeft.value, parsedRight.value);
2972
2972
  if (!merged.valid) {
2973
- addIssueToContext(ctx2, {
2973
+ addIssueToContext(ctx, {
2974
2974
  code: ZodIssueCode.invalid_intersection_types
2975
2975
  });
2976
2976
  return INVALID;
@@ -2980,28 +2980,28 @@ class ZodIntersection extends ZodType {
2980
2980
  }
2981
2981
  return { status: status.value, value: merged.data };
2982
2982
  };
2983
- if (ctx2.common.async) {
2983
+ if (ctx.common.async) {
2984
2984
  return Promise.all([
2985
2985
  this._def.left._parseAsync({
2986
- data: ctx2.data,
2987
- path: ctx2.path,
2988
- parent: ctx2
2986
+ data: ctx.data,
2987
+ path: ctx.path,
2988
+ parent: ctx
2989
2989
  }),
2990
2990
  this._def.right._parseAsync({
2991
- data: ctx2.data,
2992
- path: ctx2.path,
2993
- parent: ctx2
2991
+ data: ctx.data,
2992
+ path: ctx.path,
2993
+ parent: ctx
2994
2994
  })
2995
2995
  ]).then(([left, right]) => handleParsed(left, right));
2996
2996
  } else {
2997
2997
  return handleParsed(this._def.left._parseSync({
2998
- data: ctx2.data,
2999
- path: ctx2.path,
3000
- parent: ctx2
2998
+ data: ctx.data,
2999
+ path: ctx.path,
3000
+ parent: ctx
3001
3001
  }), this._def.right._parseSync({
3002
- data: ctx2.data,
3003
- path: ctx2.path,
3004
- parent: ctx2
3002
+ data: ctx.data,
3003
+ path: ctx.path,
3004
+ parent: ctx
3005
3005
  }));
3006
3006
  }
3007
3007
  }
@@ -3017,17 +3017,17 @@ ZodIntersection.create = (left, right, params) => {
3017
3017
 
3018
3018
  class ZodTuple extends ZodType {
3019
3019
  _parse(input) {
3020
- const { status, ctx: ctx2 } = this._processInputParams(input);
3021
- if (ctx2.parsedType !== ZodParsedType.array) {
3022
- addIssueToContext(ctx2, {
3020
+ const { status, ctx } = this._processInputParams(input);
3021
+ if (ctx.parsedType !== ZodParsedType.array) {
3022
+ addIssueToContext(ctx, {
3023
3023
  code: ZodIssueCode.invalid_type,
3024
3024
  expected: ZodParsedType.array,
3025
- received: ctx2.parsedType
3025
+ received: ctx.parsedType
3026
3026
  });
3027
3027
  return INVALID;
3028
3028
  }
3029
- if (ctx2.data.length < this._def.items.length) {
3030
- addIssueToContext(ctx2, {
3029
+ if (ctx.data.length < this._def.items.length) {
3030
+ addIssueToContext(ctx, {
3031
3031
  code: ZodIssueCode.too_small,
3032
3032
  minimum: this._def.items.length,
3033
3033
  inclusive: true,
@@ -3037,8 +3037,8 @@ class ZodTuple extends ZodType {
3037
3037
  return INVALID;
3038
3038
  }
3039
3039
  const rest = this._def.rest;
3040
- if (!rest && ctx2.data.length > this._def.items.length) {
3041
- addIssueToContext(ctx2, {
3040
+ if (!rest && ctx.data.length > this._def.items.length) {
3041
+ addIssueToContext(ctx, {
3042
3042
  code: ZodIssueCode.too_big,
3043
3043
  maximum: this._def.items.length,
3044
3044
  inclusive: true,
@@ -3047,13 +3047,13 @@ class ZodTuple extends ZodType {
3047
3047
  });
3048
3048
  status.dirty();
3049
3049
  }
3050
- const items = [...ctx2.data].map((item, itemIndex) => {
3050
+ const items = [...ctx.data].map((item, itemIndex) => {
3051
3051
  const schema = this._def.items[itemIndex] || this._def.rest;
3052
3052
  if (!schema)
3053
3053
  return null;
3054
- return schema._parse(new ParseInputLazyPath(ctx2, item, ctx2.path, itemIndex));
3054
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3055
3055
  }).filter((x) => !!x);
3056
- if (ctx2.common.async) {
3056
+ if (ctx.common.async) {
3057
3057
  return Promise.all(items).then((results) => {
3058
3058
  return ParseStatus.mergeArray(status, results);
3059
3059
  });
@@ -3091,26 +3091,26 @@ class ZodRecord extends ZodType {
3091
3091
  return this._def.valueType;
3092
3092
  }
3093
3093
  _parse(input) {
3094
- const { status, ctx: ctx2 } = this._processInputParams(input);
3095
- if (ctx2.parsedType !== ZodParsedType.object) {
3096
- addIssueToContext(ctx2, {
3094
+ const { status, ctx } = this._processInputParams(input);
3095
+ if (ctx.parsedType !== ZodParsedType.object) {
3096
+ addIssueToContext(ctx, {
3097
3097
  code: ZodIssueCode.invalid_type,
3098
3098
  expected: ZodParsedType.object,
3099
- received: ctx2.parsedType
3099
+ received: ctx.parsedType
3100
3100
  });
3101
3101
  return INVALID;
3102
3102
  }
3103
3103
  const pairs = [];
3104
3104
  const keyType = this._def.keyType;
3105
3105
  const valueType = this._def.valueType;
3106
- for (const key in ctx2.data) {
3106
+ for (const key in ctx.data) {
3107
3107
  pairs.push({
3108
- key: keyType._parse(new ParseInputLazyPath(ctx2, key, ctx2.path, key)),
3109
- value: valueType._parse(new ParseInputLazyPath(ctx2, ctx2.data[key], ctx2.path, key)),
3110
- alwaysSet: key in ctx2.data
3108
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3109
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3110
+ alwaysSet: key in ctx.data
3111
3111
  });
3112
3112
  }
3113
- if (ctx2.common.async) {
3113
+ if (ctx.common.async) {
3114
3114
  return ParseStatus.mergeObjectAsync(status, pairs);
3115
3115
  } else {
3116
3116
  return ParseStatus.mergeObjectSync(status, pairs);
@@ -3145,24 +3145,24 @@ class ZodMap extends ZodType {
3145
3145
  return this._def.valueType;
3146
3146
  }
3147
3147
  _parse(input) {
3148
- const { status, ctx: ctx2 } = this._processInputParams(input);
3149
- if (ctx2.parsedType !== ZodParsedType.map) {
3150
- addIssueToContext(ctx2, {
3148
+ const { status, ctx } = this._processInputParams(input);
3149
+ if (ctx.parsedType !== ZodParsedType.map) {
3150
+ addIssueToContext(ctx, {
3151
3151
  code: ZodIssueCode.invalid_type,
3152
3152
  expected: ZodParsedType.map,
3153
- received: ctx2.parsedType
3153
+ received: ctx.parsedType
3154
3154
  });
3155
3155
  return INVALID;
3156
3156
  }
3157
3157
  const keyType = this._def.keyType;
3158
3158
  const valueType = this._def.valueType;
3159
- const pairs = [...ctx2.data.entries()].map(([key, value], index) => {
3159
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3160
3160
  return {
3161
- key: keyType._parse(new ParseInputLazyPath(ctx2, key, ctx2.path, [index, "key"])),
3162
- value: valueType._parse(new ParseInputLazyPath(ctx2, value, ctx2.path, [index, "value"]))
3161
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3162
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3163
3163
  };
3164
3164
  });
3165
- if (ctx2.common.async) {
3165
+ if (ctx.common.async) {
3166
3166
  const finalMap = new Map;
3167
3167
  return Promise.resolve().then(async () => {
3168
3168
  for (const pair of pairs) {
@@ -3206,19 +3206,19 @@ ZodMap.create = (keyType, valueType, params) => {
3206
3206
 
3207
3207
  class ZodSet extends ZodType {
3208
3208
  _parse(input) {
3209
- const { status, ctx: ctx2 } = this._processInputParams(input);
3210
- if (ctx2.parsedType !== ZodParsedType.set) {
3211
- addIssueToContext(ctx2, {
3209
+ const { status, ctx } = this._processInputParams(input);
3210
+ if (ctx.parsedType !== ZodParsedType.set) {
3211
+ addIssueToContext(ctx, {
3212
3212
  code: ZodIssueCode.invalid_type,
3213
3213
  expected: ZodParsedType.set,
3214
- received: ctx2.parsedType
3214
+ received: ctx.parsedType
3215
3215
  });
3216
3216
  return INVALID;
3217
3217
  }
3218
3218
  const def = this._def;
3219
3219
  if (def.minSize !== null) {
3220
- if (ctx2.data.size < def.minSize.value) {
3221
- addIssueToContext(ctx2, {
3220
+ if (ctx.data.size < def.minSize.value) {
3221
+ addIssueToContext(ctx, {
3222
3222
  code: ZodIssueCode.too_small,
3223
3223
  minimum: def.minSize.value,
3224
3224
  type: "set",
@@ -3230,8 +3230,8 @@ class ZodSet extends ZodType {
3230
3230
  }
3231
3231
  }
3232
3232
  if (def.maxSize !== null) {
3233
- if (ctx2.data.size > def.maxSize.value) {
3234
- addIssueToContext(ctx2, {
3233
+ if (ctx.data.size > def.maxSize.value) {
3234
+ addIssueToContext(ctx, {
3235
3235
  code: ZodIssueCode.too_big,
3236
3236
  maximum: def.maxSize.value,
3237
3237
  type: "set",
@@ -3254,8 +3254,8 @@ class ZodSet extends ZodType {
3254
3254
  }
3255
3255
  return { status: status.value, value: parsedSet };
3256
3256
  }
3257
- const elements = [...ctx2.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx2, item, ctx2.path, i)));
3258
- if (ctx2.common.async) {
3257
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3258
+ if (ctx.common.async) {
3259
3259
  return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3260
3260
  } else {
3261
3261
  return finalizeSet(elements);
@@ -3296,20 +3296,20 @@ class ZodFunction extends ZodType {
3296
3296
  this.validate = this.implement;
3297
3297
  }
3298
3298
  _parse(input) {
3299
- const { ctx: ctx2 } = this._processInputParams(input);
3300
- if (ctx2.parsedType !== ZodParsedType.function) {
3301
- addIssueToContext(ctx2, {
3299
+ const { ctx } = this._processInputParams(input);
3300
+ if (ctx.parsedType !== ZodParsedType.function) {
3301
+ addIssueToContext(ctx, {
3302
3302
  code: ZodIssueCode.invalid_type,
3303
3303
  expected: ZodParsedType.function,
3304
- received: ctx2.parsedType
3304
+ received: ctx.parsedType
3305
3305
  });
3306
3306
  return INVALID;
3307
3307
  }
3308
3308
  function makeArgsIssue(args, error) {
3309
3309
  return makeIssue({
3310
3310
  data: args,
3311
- path: ctx2.path,
3312
- errorMaps: [ctx2.common.contextualErrorMap, ctx2.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3311
+ path: ctx.path,
3312
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3313
3313
  issueData: {
3314
3314
  code: ZodIssueCode.invalid_arguments,
3315
3315
  argumentsError: error
@@ -3319,16 +3319,16 @@ class ZodFunction extends ZodType {
3319
3319
  function makeReturnsIssue(returns, error) {
3320
3320
  return makeIssue({
3321
3321
  data: returns,
3322
- path: ctx2.path,
3323
- errorMaps: [ctx2.common.contextualErrorMap, ctx2.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3322
+ path: ctx.path,
3323
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3324
3324
  issueData: {
3325
3325
  code: ZodIssueCode.invalid_return_type,
3326
3326
  returnTypeError: error
3327
3327
  }
3328
3328
  });
3329
3329
  }
3330
- const params = { errorMap: ctx2.common.contextualErrorMap };
3331
- const fn = ctx2.data;
3330
+ const params = { errorMap: ctx.common.contextualErrorMap };
3331
+ const fn = ctx.data;
3332
3332
  if (this._def.returns instanceof ZodPromise) {
3333
3333
  const me = this;
3334
3334
  return OK(async function(...args) {
@@ -3401,9 +3401,9 @@ class ZodLazy extends ZodType {
3401
3401
  return this._def.getter();
3402
3402
  }
3403
3403
  _parse(input) {
3404
- const { ctx: ctx2 } = this._processInputParams(input);
3404
+ const { ctx } = this._processInputParams(input);
3405
3405
  const lazySchema = this._def.getter();
3406
- return lazySchema._parse({ data: ctx2.data, path: ctx2.path, parent: ctx2 });
3406
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3407
3407
  }
3408
3408
  }
3409
3409
  ZodLazy.create = (getter, params) => {
@@ -3417,9 +3417,9 @@ ZodLazy.create = (getter, params) => {
3417
3417
  class ZodLiteral extends ZodType {
3418
3418
  _parse(input) {
3419
3419
  if (input.data !== this._def.value) {
3420
- const ctx2 = this._getOrReturnCtx(input);
3421
- addIssueToContext(ctx2, {
3422
- received: ctx2.data,
3420
+ const ctx = this._getOrReturnCtx(input);
3421
+ addIssueToContext(ctx, {
3422
+ received: ctx.data,
3423
3423
  code: ZodIssueCode.invalid_literal,
3424
3424
  expected: this._def.value
3425
3425
  });
@@ -3449,11 +3449,11 @@ function createZodEnum(values, params) {
3449
3449
  class ZodEnum extends ZodType {
3450
3450
  _parse(input) {
3451
3451
  if (typeof input.data !== "string") {
3452
- const ctx2 = this._getOrReturnCtx(input);
3452
+ const ctx = this._getOrReturnCtx(input);
3453
3453
  const expectedValues = this._def.values;
3454
- addIssueToContext(ctx2, {
3454
+ addIssueToContext(ctx, {
3455
3455
  expected: util.joinValues(expectedValues),
3456
- received: ctx2.parsedType,
3456
+ received: ctx.parsedType,
3457
3457
  code: ZodIssueCode.invalid_type
3458
3458
  });
3459
3459
  return INVALID;
@@ -3462,10 +3462,10 @@ class ZodEnum extends ZodType {
3462
3462
  this._cache = new Set(this._def.values);
3463
3463
  }
3464
3464
  if (!this._cache.has(input.data)) {
3465
- const ctx2 = this._getOrReturnCtx(input);
3465
+ const ctx = this._getOrReturnCtx(input);
3466
3466
  const expectedValues = this._def.values;
3467
- addIssueToContext(ctx2, {
3468
- received: ctx2.data,
3467
+ addIssueToContext(ctx, {
3468
+ received: ctx.data,
3469
3469
  code: ZodIssueCode.invalid_enum_value,
3470
3470
  options: expectedValues
3471
3471
  });
@@ -3515,12 +3515,12 @@ ZodEnum.create = createZodEnum;
3515
3515
  class ZodNativeEnum extends ZodType {
3516
3516
  _parse(input) {
3517
3517
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3518
- const ctx2 = this._getOrReturnCtx(input);
3519
- if (ctx2.parsedType !== ZodParsedType.string && ctx2.parsedType !== ZodParsedType.number) {
3518
+ const ctx = this._getOrReturnCtx(input);
3519
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3520
3520
  const expectedValues = util.objectValues(nativeEnumValues);
3521
- addIssueToContext(ctx2, {
3521
+ addIssueToContext(ctx, {
3522
3522
  expected: util.joinValues(expectedValues),
3523
- received: ctx2.parsedType,
3523
+ received: ctx.parsedType,
3524
3524
  code: ZodIssueCode.invalid_type
3525
3525
  });
3526
3526
  return INVALID;
@@ -3530,8 +3530,8 @@ class ZodNativeEnum extends ZodType {
3530
3530
  }
3531
3531
  if (!this._cache.has(input.data)) {
3532
3532
  const expectedValues = util.objectValues(nativeEnumValues);
3533
- addIssueToContext(ctx2, {
3534
- received: ctx2.data,
3533
+ addIssueToContext(ctx, {
3534
+ received: ctx.data,
3535
3535
  code: ZodIssueCode.invalid_enum_value,
3536
3536
  options: expectedValues
3537
3537
  });
@@ -3556,20 +3556,20 @@ class ZodPromise extends ZodType {
3556
3556
  return this._def.type;
3557
3557
  }
3558
3558
  _parse(input) {
3559
- const { ctx: ctx2 } = this._processInputParams(input);
3560
- if (ctx2.parsedType !== ZodParsedType.promise && ctx2.common.async === false) {
3561
- addIssueToContext(ctx2, {
3559
+ const { ctx } = this._processInputParams(input);
3560
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3561
+ addIssueToContext(ctx, {
3562
3562
  code: ZodIssueCode.invalid_type,
3563
3563
  expected: ZodParsedType.promise,
3564
- received: ctx2.parsedType
3564
+ received: ctx.parsedType
3565
3565
  });
3566
3566
  return INVALID;
3567
3567
  }
3568
- const promisified = ctx2.parsedType === ZodParsedType.promise ? ctx2.data : Promise.resolve(ctx2.data);
3568
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3569
3569
  return OK(promisified.then((data) => {
3570
3570
  return this._def.type.parseAsync(data, {
3571
- path: ctx2.path,
3572
- errorMap: ctx2.common.contextualErrorMap
3571
+ path: ctx.path,
3572
+ errorMap: ctx.common.contextualErrorMap
3573
3573
  });
3574
3574
  }));
3575
3575
  }
@@ -3590,11 +3590,11 @@ class ZodEffects extends ZodType {
3590
3590
  return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3591
3591
  }
3592
3592
  _parse(input) {
3593
- const { status, ctx: ctx2 } = this._processInputParams(input);
3593
+ const { status, ctx } = this._processInputParams(input);
3594
3594
  const effect = this._def.effect || null;
3595
3595
  const checkCtx = {
3596
3596
  addIssue: (arg) => {
3597
- addIssueToContext(ctx2, arg);
3597
+ addIssueToContext(ctx, arg);
3598
3598
  if (arg.fatal) {
3599
3599
  status.abort();
3600
3600
  } else {
@@ -3602,20 +3602,20 @@ class ZodEffects extends ZodType {
3602
3602
  }
3603
3603
  },
3604
3604
  get path() {
3605
- return ctx2.path;
3605
+ return ctx.path;
3606
3606
  }
3607
3607
  };
3608
3608
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3609
3609
  if (effect.type === "preprocess") {
3610
- const processed = effect.transform(ctx2.data, checkCtx);
3611
- if (ctx2.common.async) {
3610
+ const processed = effect.transform(ctx.data, checkCtx);
3611
+ if (ctx.common.async) {
3612
3612
  return Promise.resolve(processed).then(async (processed2) => {
3613
3613
  if (status.value === "aborted")
3614
3614
  return INVALID;
3615
3615
  const result = await this._def.schema._parseAsync({
3616
3616
  data: processed2,
3617
- path: ctx2.path,
3618
- parent: ctx2
3617
+ path: ctx.path,
3618
+ parent: ctx
3619
3619
  });
3620
3620
  if (result.status === "aborted")
3621
3621
  return INVALID;
@@ -3630,8 +3630,8 @@ class ZodEffects extends ZodType {
3630
3630
  return INVALID;
3631
3631
  const result = this._def.schema._parseSync({
3632
3632
  data: processed,
3633
- path: ctx2.path,
3634
- parent: ctx2
3633
+ path: ctx.path,
3634
+ parent: ctx
3635
3635
  });
3636
3636
  if (result.status === "aborted")
3637
3637
  return INVALID;
@@ -3645,7 +3645,7 @@ class ZodEffects extends ZodType {
3645
3645
  if (effect.type === "refinement") {
3646
3646
  const executeRefinement = (acc) => {
3647
3647
  const result = effect.refinement(acc, checkCtx);
3648
- if (ctx2.common.async) {
3648
+ if (ctx.common.async) {
3649
3649
  return Promise.resolve(result);
3650
3650
  }
3651
3651
  if (result instanceof Promise) {
@@ -3653,11 +3653,11 @@ class ZodEffects extends ZodType {
3653
3653
  }
3654
3654
  return acc;
3655
3655
  };
3656
- if (ctx2.common.async === false) {
3656
+ if (ctx.common.async === false) {
3657
3657
  const inner = this._def.schema._parseSync({
3658
- data: ctx2.data,
3659
- path: ctx2.path,
3660
- parent: ctx2
3658
+ data: ctx.data,
3659
+ path: ctx.path,
3660
+ parent: ctx
3661
3661
  });
3662
3662
  if (inner.status === "aborted")
3663
3663
  return INVALID;
@@ -3666,7 +3666,7 @@ class ZodEffects extends ZodType {
3666
3666
  executeRefinement(inner.value);
3667
3667
  return { status: status.value, value: inner.value };
3668
3668
  } else {
3669
- return this._def.schema._parseAsync({ data: ctx2.data, path: ctx2.path, parent: ctx2 }).then((inner) => {
3669
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3670
3670
  if (inner.status === "aborted")
3671
3671
  return INVALID;
3672
3672
  if (inner.status === "dirty")
@@ -3678,11 +3678,11 @@ class ZodEffects extends ZodType {
3678
3678
  }
3679
3679
  }
3680
3680
  if (effect.type === "transform") {
3681
- if (ctx2.common.async === false) {
3681
+ if (ctx.common.async === false) {
3682
3682
  const base = this._def.schema._parseSync({
3683
- data: ctx2.data,
3684
- path: ctx2.path,
3685
- parent: ctx2
3683
+ data: ctx.data,
3684
+ path: ctx.path,
3685
+ parent: ctx
3686
3686
  });
3687
3687
  if (!isValid(base))
3688
3688
  return INVALID;
@@ -3692,7 +3692,7 @@ class ZodEffects extends ZodType {
3692
3692
  }
3693
3693
  return { status: status.value, value: result };
3694
3694
  } else {
3695
- return this._def.schema._parseAsync({ data: ctx2.data, path: ctx2.path, parent: ctx2 }).then((base) => {
3695
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3696
3696
  if (!isValid(base))
3697
3697
  return INVALID;
3698
3698
  return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
@@ -3763,15 +3763,15 @@ ZodNullable.create = (type, params) => {
3763
3763
 
3764
3764
  class ZodDefault extends ZodType {
3765
3765
  _parse(input) {
3766
- const { ctx: ctx2 } = this._processInputParams(input);
3767
- let data = ctx2.data;
3768
- if (ctx2.parsedType === ZodParsedType.undefined) {
3766
+ const { ctx } = this._processInputParams(input);
3767
+ let data = ctx.data;
3768
+ if (ctx.parsedType === ZodParsedType.undefined) {
3769
3769
  data = this._def.defaultValue();
3770
3770
  }
3771
3771
  return this._def.innerType._parse({
3772
3772
  data,
3773
- path: ctx2.path,
3774
- parent: ctx2
3773
+ path: ctx.path,
3774
+ parent: ctx
3775
3775
  });
3776
3776
  }
3777
3777
  removeDefault() {
@@ -3789,11 +3789,11 @@ ZodDefault.create = (type, params) => {
3789
3789
 
3790
3790
  class ZodCatch extends ZodType {
3791
3791
  _parse(input) {
3792
- const { ctx: ctx2 } = this._processInputParams(input);
3792
+ const { ctx } = this._processInputParams(input);
3793
3793
  const newCtx = {
3794
- ...ctx2,
3794
+ ...ctx,
3795
3795
  common: {
3796
- ...ctx2.common,
3796
+ ...ctx.common,
3797
3797
  issues: []
3798
3798
  }
3799
3799
  };
@@ -3845,11 +3845,11 @@ class ZodNaN extends ZodType {
3845
3845
  _parse(input) {
3846
3846
  const parsedType = this._getType(input);
3847
3847
  if (parsedType !== ZodParsedType.nan) {
3848
- const ctx2 = this._getOrReturnCtx(input);
3849
- addIssueToContext(ctx2, {
3848
+ const ctx = this._getOrReturnCtx(input);
3849
+ addIssueToContext(ctx, {
3850
3850
  code: ZodIssueCode.invalid_type,
3851
3851
  expected: ZodParsedType.nan,
3852
- received: ctx2.parsedType
3852
+ received: ctx.parsedType
3853
3853
  });
3854
3854
  return INVALID;
3855
3855
  }
@@ -3866,12 +3866,12 @@ var BRAND = Symbol("zod_brand");
3866
3866
 
3867
3867
  class ZodBranded extends ZodType {
3868
3868
  _parse(input) {
3869
- const { ctx: ctx2 } = this._processInputParams(input);
3870
- const data = ctx2.data;
3869
+ const { ctx } = this._processInputParams(input);
3870
+ const data = ctx.data;
3871
3871
  return this._def.type._parse({
3872
3872
  data,
3873
- path: ctx2.path,
3874
- parent: ctx2
3873
+ path: ctx.path,
3874
+ parent: ctx
3875
3875
  });
3876
3876
  }
3877
3877
  unwrap() {
@@ -3881,13 +3881,13 @@ class ZodBranded extends ZodType {
3881
3881
 
3882
3882
  class ZodPipeline extends ZodType {
3883
3883
  _parse(input) {
3884
- const { status, ctx: ctx2 } = this._processInputParams(input);
3885
- if (ctx2.common.async) {
3884
+ const { status, ctx } = this._processInputParams(input);
3885
+ if (ctx.common.async) {
3886
3886
  const handleAsync = async () => {
3887
3887
  const inResult = await this._def.in._parseAsync({
3888
- data: ctx2.data,
3889
- path: ctx2.path,
3890
- parent: ctx2
3888
+ data: ctx.data,
3889
+ path: ctx.path,
3890
+ parent: ctx
3891
3891
  });
3892
3892
  if (inResult.status === "aborted")
3893
3893
  return INVALID;
@@ -3897,17 +3897,17 @@ class ZodPipeline extends ZodType {
3897
3897
  } else {
3898
3898
  return this._def.out._parseAsync({
3899
3899
  data: inResult.value,
3900
- path: ctx2.path,
3901
- parent: ctx2
3900
+ path: ctx.path,
3901
+ parent: ctx
3902
3902
  });
3903
3903
  }
3904
3904
  };
3905
3905
  return handleAsync();
3906
3906
  } else {
3907
3907
  const inResult = this._def.in._parseSync({
3908
- data: ctx2.data,
3909
- path: ctx2.path,
3910
- parent: ctx2
3908
+ data: ctx.data,
3909
+ path: ctx.path,
3910
+ parent: ctx
3911
3911
  });
3912
3912
  if (inResult.status === "aborted")
3913
3913
  return INVALID;
@@ -3920,8 +3920,8 @@ class ZodPipeline extends ZodType {
3920
3920
  } else {
3921
3921
  return this._def.out._parseSync({
3922
3922
  data: inResult.value,
3923
- path: ctx2.path,
3924
- parent: ctx2
3923
+ path: ctx.path,
3924
+ parent: ctx
3925
3925
  });
3926
3926
  }
3927
3927
  }
@@ -3964,21 +3964,21 @@ function cleanParams(params, data) {
3964
3964
  }
3965
3965
  function custom(check, _params = {}, fatal) {
3966
3966
  if (check)
3967
- return ZodAny.create().superRefine((data, ctx2) => {
3967
+ return ZodAny.create().superRefine((data, ctx) => {
3968
3968
  const r = check(data);
3969
3969
  if (r instanceof Promise) {
3970
3970
  return r.then((r2) => {
3971
3971
  if (!r2) {
3972
3972
  const params = cleanParams(_params, data);
3973
3973
  const _fatal = params.fatal ?? fatal ?? true;
3974
- ctx2.addIssue({ code: "custom", ...params, fatal: _fatal });
3974
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3975
3975
  }
3976
3976
  });
3977
3977
  }
3978
3978
  if (!r) {
3979
3979
  const params = cleanParams(_params, data);
3980
3980
  const _fatal = params.fatal ?? fatal ?? true;
3981
- ctx2.addIssue({ code: "custom", ...params, fatal: _fatal });
3981
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3982
3982
  }
3983
3983
  return;
3984
3984
  });
@@ -6002,7 +6002,7 @@ async function parseTunnelUrl(stream2) {
6002
6002
  }
6003
6003
  return null;
6004
6004
  }
6005
- async function handleRunTask(apiUrl, deviceId, task, detected, ctx2) {
6005
+ async function handleRunTask(apiUrl, deviceId, task, detected, ctx) {
6006
6006
  const issueId = task.issue_id;
6007
6007
  const isFollowup = !!task.followup;
6008
6008
  const workingDir = task.working_dir && existsSync2(task.working_dir) ? task.working_dir : undefined;
@@ -6424,12 +6424,12 @@ ${userPart}` : userPart;
6424
6424
  if (n > 0)
6425
6425
  log(` \uD83D\uDCCE uploaded ${n} output file(s)`);
6426
6426
  }
6427
- if (ctx2) {
6427
+ if (ctx) {
6428
6428
  const fullText = turn.blocks.filter((b) => b.kind === "text").map((b) => b.text).join(`
6429
6429
  `);
6430
6430
  const actions = extractPlanActions(fullText);
6431
6431
  if (actions.length) {
6432
- const summary = await executePlanActions(apiUrl, task, actions, ctx2);
6432
+ const summary = await executePlanActions(apiUrl, task, actions, ctx);
6433
6433
  if (summary) {
6434
6434
  try {
6435
6435
  await apiClient.post(`${apiUrl}/api/issues/${issueId}/comments`, { author_type: "agent", author_id: task.agent_id, author_name: "agent", body: summary });
@@ -6531,7 +6531,7 @@ function extractPlanActions(text) {
6531
6531
  return out;
6532
6532
  }
6533
6533
  var PLAN_ACTION_LIMIT = 10;
6534
- async function executePlanActions(apiUrl, parentTask, actions, _ctx) {
6534
+ async function executePlanActions(apiUrl, parentTask, actions, ctx) {
6535
6535
  const lines = [];
6536
6536
  let truncated = false;
6537
6537
  if (actions.length > PLAN_ACTION_LIMIT) {