@learncard/helpers 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,13 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
6
11
  var __export = (target, all) => {
7
12
  for (var name in all)
8
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -15,12 +20,3943 @@ var __copyProps = (to, from, except, desc) => {
15
20
  }
16
21
  return to;
17
22
  };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
18
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
28
 
29
+ // ../learn-card-types/dist/types.cjs.development.js
30
+ var require_types_cjs_development = __commonJS({
31
+ "../learn-card-types/dist/types.cjs.development.js"(exports, module2) {
32
+ "use strict";
33
+ var __defProp2 = Object.defineProperty;
34
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
35
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
36
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
37
+ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
38
+ var __export2 = /* @__PURE__ */ __name((target, all) => {
39
+ for (var name in all)
40
+ __defProp2(target, name, { get: all[name], enumerable: true });
41
+ }, "__export");
42
+ var __copyProps2 = /* @__PURE__ */ __name((to, from, except, desc) => {
43
+ if (from && typeof from === "object" || typeof from === "function") {
44
+ for (let key of __getOwnPropNames2(from))
45
+ if (!__hasOwnProp2.call(to, key) && key !== except)
46
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
47
+ }
48
+ return to;
49
+ }, "__copyProps");
50
+ var __toCommonJS2 = /* @__PURE__ */ __name((mod2) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod2), "__toCommonJS");
51
+ var src_exports2 = {};
52
+ __export2(src_exports2, {
53
+ AchievementCredentialValidator: () => AchievementCredentialValidator,
54
+ AchievementCriteriaValidator: () => AchievementCriteriaValidator,
55
+ AchievementSubjectValidator: () => AchievementSubjectValidator,
56
+ AchievementTypeValidator: () => AchievementTypeValidator,
57
+ AchievementValidator: () => AchievementValidator,
58
+ AddressValidator: () => AddressValidator,
59
+ AlignmentTargetTypeValidator: () => AlignmentTargetTypeValidator,
60
+ AlignmentValidator: () => AlignmentValidator,
61
+ BoostRecipientValidator: () => BoostRecipientValidator,
62
+ BoostValidator: () => BoostValidator,
63
+ ContextValidator: () => ContextValidator,
64
+ CredentialInfoValidator: () => CredentialInfoValidator,
65
+ CredentialRecordValidator: () => CredentialRecordValidator,
66
+ CredentialSchemaValidator: () => CredentialSchemaValidator,
67
+ CredentialStatusValidator: () => CredentialStatusValidator,
68
+ CredentialSubjectValidator: () => CredentialSubjectValidator,
69
+ CriteriaValidator: () => CriteriaValidator,
70
+ EncryptedCredentialRecordValidator: () => EncryptedCredentialRecordValidator,
71
+ EndorsementCredentialValidator: () => EndorsementCredentialValidator,
72
+ EndorsementSubjectValidator: () => EndorsementSubjectValidator,
73
+ EvidenceValidator: () => EvidenceValidator,
74
+ GeoCoordinatesValidator: () => GeoCoordinatesValidator,
75
+ IdentifierEntryValidator: () => IdentifierEntryValidator,
76
+ IdentifierTypeValidator: () => IdentifierTypeValidator,
77
+ IdentityObjectValidator: () => IdentityObjectValidator,
78
+ ImageValidator: () => ImageValidator,
79
+ JWERecipientHeaderValidator: () => JWERecipientHeaderValidator,
80
+ JWERecipientValidator: () => JWERecipientValidator,
81
+ JWEValidator: () => JWEValidator2,
82
+ JWKValidator: () => JWKValidator,
83
+ KnownAchievementTypeValidator: () => KnownAchievementTypeValidator,
84
+ LCNBoostClaimLinkOptionsValidator: () => LCNBoostClaimLinkOptionsValidator,
85
+ LCNBoostClaimLinkSigningAuthorityValidator: () => LCNBoostClaimLinkSigningAuthorityValidator,
86
+ LCNBoostStatus: () => LCNBoostStatus,
87
+ LCNNotificationDataValidator: () => LCNNotificationDataValidator,
88
+ LCNNotificationMessageValidator: () => LCNNotificationMessageValidator,
89
+ LCNNotificationTypeEnumValidator: () => LCNNotificationTypeEnumValidator,
90
+ LCNNotificationValidator: () => LCNNotificationValidator,
91
+ LCNProfileConnectionStatusEnum: () => LCNProfileConnectionStatusEnum,
92
+ LCNProfileValidator: () => LCNProfileValidator,
93
+ LCNSigningAuthorityForUserValidator: () => LCNSigningAuthorityForUserValidator,
94
+ LCNSigningAuthorityValidator: () => LCNSigningAuthorityValidator,
95
+ PaginatedEncryptedCredentialRecordsValidator: () => PaginatedEncryptedCredentialRecordsValidator,
96
+ PaginationOptionsValidator: () => PaginationOptionsValidator,
97
+ PaginationResponseValidator: () => PaginationResponseValidator,
98
+ ProfileValidator: () => ProfileValidator,
99
+ ProofValidator: () => ProofValidator,
100
+ RefreshServiceValidator: () => RefreshServiceValidator,
101
+ RelatedValidator: () => RelatedValidator,
102
+ ResultDescriptionValidator: () => ResultDescriptionValidator,
103
+ ResultStatusTypeValidator: () => ResultStatusTypeValidator,
104
+ ResultTypeValidator: () => ResultTypeValidator,
105
+ ResultValidator: () => ResultValidator,
106
+ RubricCriterionValidator: () => RubricCriterionValidator,
107
+ SentCredentialInfoValidator: () => SentCredentialInfoValidator,
108
+ UnsignedAchievementCredentialValidator: () => UnsignedAchievementCredentialValidator,
109
+ UnsignedVCValidator: () => UnsignedVCValidator,
110
+ UnsignedVPValidator: () => UnsignedVPValidator,
111
+ VCValidator: () => VCValidator,
112
+ VPValidator: () => VPValidator,
113
+ VerificationCheckValidator: () => VerificationCheckValidator,
114
+ VerificationItemValidator: () => VerificationItemValidator,
115
+ VerificationStatusEnum: () => VerificationStatusEnum,
116
+ VerificationStatusValidator: () => VerificationStatusValidator
117
+ });
118
+ module2.exports = __toCommonJS2(src_exports2);
119
+ var util;
120
+ (function(util2) {
121
+ util2.assertEqual = (val) => val;
122
+ function assertIs(_arg) {
123
+ }
124
+ __name(assertIs, "assertIs");
125
+ __name2(assertIs, "assertIs");
126
+ util2.assertIs = assertIs;
127
+ function assertNever(_x) {
128
+ throw new Error();
129
+ }
130
+ __name(assertNever, "assertNever");
131
+ __name2(assertNever, "assertNever");
132
+ util2.assertNever = assertNever;
133
+ util2.arrayToEnum = (items) => {
134
+ const obj = {};
135
+ for (const item of items) {
136
+ obj[item] = item;
137
+ }
138
+ return obj;
139
+ };
140
+ util2.getValidEnumValues = (obj) => {
141
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
142
+ const filtered = {};
143
+ for (const k of validKeys) {
144
+ filtered[k] = obj[k];
145
+ }
146
+ return util2.objectValues(filtered);
147
+ };
148
+ util2.objectValues = (obj) => {
149
+ return util2.objectKeys(obj).map(function(e) {
150
+ return obj[e];
151
+ });
152
+ };
153
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
154
+ const keys = [];
155
+ for (const key in object) {
156
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
157
+ keys.push(key);
158
+ }
159
+ }
160
+ return keys;
161
+ };
162
+ util2.find = (arr, checker) => {
163
+ for (const item of arr) {
164
+ if (checker(item))
165
+ return item;
166
+ }
167
+ return void 0;
168
+ };
169
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
170
+ function joinValues(array, separator = " | ") {
171
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
172
+ }
173
+ __name(joinValues, "joinValues");
174
+ __name2(joinValues, "joinValues");
175
+ util2.joinValues = joinValues;
176
+ util2.jsonStringifyReplacer = (_, value) => {
177
+ if (typeof value === "bigint") {
178
+ return value.toString();
179
+ }
180
+ return value;
181
+ };
182
+ })(util || (util = {}));
183
+ var ZodParsedType = util.arrayToEnum([
184
+ "string",
185
+ "nan",
186
+ "number",
187
+ "integer",
188
+ "float",
189
+ "boolean",
190
+ "date",
191
+ "bigint",
192
+ "symbol",
193
+ "function",
194
+ "undefined",
195
+ "null",
196
+ "array",
197
+ "object",
198
+ "unknown",
199
+ "promise",
200
+ "void",
201
+ "never",
202
+ "map",
203
+ "set"
204
+ ]);
205
+ var getParsedType = /* @__PURE__ */ __name2((data) => {
206
+ const t = typeof data;
207
+ switch (t) {
208
+ case "undefined":
209
+ return ZodParsedType.undefined;
210
+ case "string":
211
+ return ZodParsedType.string;
212
+ case "number":
213
+ return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
214
+ case "boolean":
215
+ return ZodParsedType.boolean;
216
+ case "function":
217
+ return ZodParsedType.function;
218
+ case "bigint":
219
+ return ZodParsedType.bigint;
220
+ case "symbol":
221
+ return ZodParsedType.symbol;
222
+ case "object":
223
+ if (Array.isArray(data)) {
224
+ return ZodParsedType.array;
225
+ }
226
+ if (data === null) {
227
+ return ZodParsedType.null;
228
+ }
229
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
230
+ return ZodParsedType.promise;
231
+ }
232
+ if (typeof Map !== "undefined" && data instanceof Map) {
233
+ return ZodParsedType.map;
234
+ }
235
+ if (typeof Set !== "undefined" && data instanceof Set) {
236
+ return ZodParsedType.set;
237
+ }
238
+ if (typeof Date !== "undefined" && data instanceof Date) {
239
+ return ZodParsedType.date;
240
+ }
241
+ return ZodParsedType.object;
242
+ default:
243
+ return ZodParsedType.unknown;
244
+ }
245
+ }, "getParsedType");
246
+ var ZodIssueCode = util.arrayToEnum([
247
+ "invalid_type",
248
+ "invalid_literal",
249
+ "custom",
250
+ "invalid_union",
251
+ "invalid_union_discriminator",
252
+ "invalid_enum_value",
253
+ "unrecognized_keys",
254
+ "invalid_arguments",
255
+ "invalid_return_type",
256
+ "invalid_date",
257
+ "invalid_string",
258
+ "too_small",
259
+ "too_big",
260
+ "invalid_intersection_types",
261
+ "not_multiple_of",
262
+ "not_finite"
263
+ ]);
264
+ var quotelessJson = /* @__PURE__ */ __name2((obj) => {
265
+ const json = JSON.stringify(obj, null, 2);
266
+ return json.replace(/"([^"]+)":/g, "$1:");
267
+ }, "quotelessJson");
268
+ var ZodError = /* @__PURE__ */ __name(class extends Error {
269
+ constructor(issues) {
270
+ super();
271
+ this.issues = [];
272
+ this.addIssue = (sub) => {
273
+ this.issues = [...this.issues, sub];
274
+ };
275
+ this.addIssues = (subs = []) => {
276
+ this.issues = [...this.issues, ...subs];
277
+ };
278
+ const actualProto = new.target.prototype;
279
+ if (Object.setPrototypeOf) {
280
+ Object.setPrototypeOf(this, actualProto);
281
+ } else {
282
+ this.__proto__ = actualProto;
283
+ }
284
+ this.name = "ZodError";
285
+ this.issues = issues;
286
+ }
287
+ get errors() {
288
+ return this.issues;
289
+ }
290
+ format(_mapper) {
291
+ const mapper = _mapper || function(issue) {
292
+ return issue.message;
293
+ };
294
+ const fieldErrors = { _errors: [] };
295
+ const processError = /* @__PURE__ */ __name2((error) => {
296
+ for (const issue of error.issues) {
297
+ if (issue.code === "invalid_union") {
298
+ issue.unionErrors.map(processError);
299
+ } else if (issue.code === "invalid_return_type") {
300
+ processError(issue.returnTypeError);
301
+ } else if (issue.code === "invalid_arguments") {
302
+ processError(issue.argumentsError);
303
+ } else if (issue.path.length === 0) {
304
+ fieldErrors._errors.push(mapper(issue));
305
+ } else {
306
+ let curr = fieldErrors;
307
+ let i = 0;
308
+ while (i < issue.path.length) {
309
+ const el = issue.path[i];
310
+ const terminal = i === issue.path.length - 1;
311
+ if (!terminal) {
312
+ curr[el] = curr[el] || { _errors: [] };
313
+ } else {
314
+ curr[el] = curr[el] || { _errors: [] };
315
+ curr[el]._errors.push(mapper(issue));
316
+ }
317
+ curr = curr[el];
318
+ i++;
319
+ }
320
+ }
321
+ }
322
+ }, "processError");
323
+ processError(this);
324
+ return fieldErrors;
325
+ }
326
+ toString() {
327
+ return this.message;
328
+ }
329
+ get message() {
330
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
331
+ }
332
+ get isEmpty() {
333
+ return this.issues.length === 0;
334
+ }
335
+ flatten(mapper = (issue) => issue.message) {
336
+ const fieldErrors = {};
337
+ const formErrors = [];
338
+ for (const sub of this.issues) {
339
+ if (sub.path.length > 0) {
340
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
341
+ fieldErrors[sub.path[0]].push(mapper(sub));
342
+ } else {
343
+ formErrors.push(mapper(sub));
344
+ }
345
+ }
346
+ return { formErrors, fieldErrors };
347
+ }
348
+ get formErrors() {
349
+ return this.flatten();
350
+ }
351
+ }, "ZodError");
352
+ __name2(ZodError, "ZodError");
353
+ ZodError.create = (issues) => {
354
+ const error = new ZodError(issues);
355
+ return error;
356
+ };
357
+ var errorMap = /* @__PURE__ */ __name2((issue, _ctx) => {
358
+ let message;
359
+ switch (issue.code) {
360
+ case ZodIssueCode.invalid_type:
361
+ if (issue.received === ZodParsedType.undefined) {
362
+ message = "Required";
363
+ } else {
364
+ message = `Expected ${issue.expected}, received ${issue.received}`;
365
+ }
366
+ break;
367
+ case ZodIssueCode.invalid_literal:
368
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
369
+ break;
370
+ case ZodIssueCode.unrecognized_keys:
371
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
372
+ break;
373
+ case ZodIssueCode.invalid_union:
374
+ message = `Invalid input`;
375
+ break;
376
+ case ZodIssueCode.invalid_union_discriminator:
377
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
378
+ break;
379
+ case ZodIssueCode.invalid_enum_value:
380
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
381
+ break;
382
+ case ZodIssueCode.invalid_arguments:
383
+ message = `Invalid function arguments`;
384
+ break;
385
+ case ZodIssueCode.invalid_return_type:
386
+ message = `Invalid function return type`;
387
+ break;
388
+ case ZodIssueCode.invalid_date:
389
+ message = `Invalid date`;
390
+ break;
391
+ case ZodIssueCode.invalid_string:
392
+ if (typeof issue.validation === "object") {
393
+ if ("startsWith" in issue.validation) {
394
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
395
+ } else if ("endsWith" in issue.validation) {
396
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
397
+ } else {
398
+ util.assertNever(issue.validation);
399
+ }
400
+ } else if (issue.validation !== "regex") {
401
+ message = `Invalid ${issue.validation}`;
402
+ } else {
403
+ message = "Invalid";
404
+ }
405
+ break;
406
+ case ZodIssueCode.too_small:
407
+ if (issue.type === "array")
408
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
409
+ else if (issue.type === "string")
410
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
411
+ else if (issue.type === "number")
412
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
413
+ else if (issue.type === "date")
414
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
415
+ else
416
+ message = "Invalid input";
417
+ break;
418
+ case ZodIssueCode.too_big:
419
+ if (issue.type === "array")
420
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
421
+ else if (issue.type === "string")
422
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
423
+ else if (issue.type === "number")
424
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
425
+ else if (issue.type === "date")
426
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
427
+ else
428
+ message = "Invalid input";
429
+ break;
430
+ case ZodIssueCode.custom:
431
+ message = `Invalid input`;
432
+ break;
433
+ case ZodIssueCode.invalid_intersection_types:
434
+ message = `Intersection results could not be merged`;
435
+ break;
436
+ case ZodIssueCode.not_multiple_of:
437
+ message = `Number must be a multiple of ${issue.multipleOf}`;
438
+ break;
439
+ case ZodIssueCode.not_finite:
440
+ message = "Number must be finite";
441
+ break;
442
+ default:
443
+ message = _ctx.defaultError;
444
+ util.assertNever(issue);
445
+ }
446
+ return { message };
447
+ }, "errorMap");
448
+ var overrideErrorMap = errorMap;
449
+ function setErrorMap(map) {
450
+ overrideErrorMap = map;
451
+ }
452
+ __name(setErrorMap, "setErrorMap");
453
+ __name2(setErrorMap, "setErrorMap");
454
+ function getErrorMap() {
455
+ return overrideErrorMap;
456
+ }
457
+ __name(getErrorMap, "getErrorMap");
458
+ __name2(getErrorMap, "getErrorMap");
459
+ var makeIssue = /* @__PURE__ */ __name2((params) => {
460
+ const { data, path, errorMaps, issueData } = params;
461
+ const fullPath = [...path, ...issueData.path || []];
462
+ const fullIssue = {
463
+ ...issueData,
464
+ path: fullPath
465
+ };
466
+ let errorMessage = "";
467
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
468
+ for (const map of maps) {
469
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
470
+ }
471
+ return {
472
+ ...issueData,
473
+ path: fullPath,
474
+ message: issueData.message || errorMessage
475
+ };
476
+ }, "makeIssue");
477
+ var EMPTY_PATH = [];
478
+ function addIssueToContext(ctx, issueData) {
479
+ const issue = makeIssue({
480
+ issueData,
481
+ data: ctx.data,
482
+ path: ctx.path,
483
+ errorMaps: [
484
+ ctx.common.contextualErrorMap,
485
+ ctx.schemaErrorMap,
486
+ getErrorMap(),
487
+ errorMap
488
+ ].filter((x) => !!x)
489
+ });
490
+ ctx.common.issues.push(issue);
491
+ }
492
+ __name(addIssueToContext, "addIssueToContext");
493
+ __name2(addIssueToContext, "addIssueToContext");
494
+ var ParseStatus = /* @__PURE__ */ __name(class {
495
+ constructor() {
496
+ this.value = "valid";
497
+ }
498
+ dirty() {
499
+ if (this.value === "valid")
500
+ this.value = "dirty";
501
+ }
502
+ abort() {
503
+ if (this.value !== "aborted")
504
+ this.value = "aborted";
505
+ }
506
+ static mergeArray(status, results) {
507
+ const arrayValue = [];
508
+ for (const s of results) {
509
+ if (s.status === "aborted")
510
+ return INVALID;
511
+ if (s.status === "dirty")
512
+ status.dirty();
513
+ arrayValue.push(s.value);
514
+ }
515
+ return { status: status.value, value: arrayValue };
516
+ }
517
+ static async mergeObjectAsync(status, pairs) {
518
+ const syncPairs = [];
519
+ for (const pair of pairs) {
520
+ syncPairs.push({
521
+ key: await pair.key,
522
+ value: await pair.value
523
+ });
524
+ }
525
+ return ParseStatus.mergeObjectSync(status, syncPairs);
526
+ }
527
+ static mergeObjectSync(status, pairs) {
528
+ const finalObject = {};
529
+ for (const pair of pairs) {
530
+ const { key, value } = pair;
531
+ if (key.status === "aborted")
532
+ return INVALID;
533
+ if (value.status === "aborted")
534
+ return INVALID;
535
+ if (key.status === "dirty")
536
+ status.dirty();
537
+ if (value.status === "dirty")
538
+ status.dirty();
539
+ if (typeof value.value !== "undefined" || pair.alwaysSet) {
540
+ finalObject[key.value] = value.value;
541
+ }
542
+ }
543
+ return { status: status.value, value: finalObject };
544
+ }
545
+ }, "ParseStatus");
546
+ __name2(ParseStatus, "ParseStatus");
547
+ var INVALID = Object.freeze({
548
+ status: "aborted"
549
+ });
550
+ var DIRTY = /* @__PURE__ */ __name2((value) => ({ status: "dirty", value }), "DIRTY");
551
+ var OK = /* @__PURE__ */ __name2((value) => ({ status: "valid", value }), "OK");
552
+ var isAborted = /* @__PURE__ */ __name2((x) => x.status === "aborted", "isAborted");
553
+ var isDirty = /* @__PURE__ */ __name2((x) => x.status === "dirty", "isDirty");
554
+ var isValid = /* @__PURE__ */ __name2((x) => x.status === "valid", "isValid");
555
+ var isAsync = /* @__PURE__ */ __name2((x) => typeof Promise !== "undefined" && x instanceof Promise, "isAsync");
556
+ var errorUtil;
557
+ (function(errorUtil2) {
558
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
559
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
560
+ })(errorUtil || (errorUtil = {}));
561
+ var ParseInputLazyPath = /* @__PURE__ */ __name(class {
562
+ constructor(parent, value, path, key) {
563
+ this.parent = parent;
564
+ this.data = value;
565
+ this._path = path;
566
+ this._key = key;
567
+ }
568
+ get path() {
569
+ return this._path.concat(this._key);
570
+ }
571
+ }, "ParseInputLazyPath");
572
+ __name2(ParseInputLazyPath, "ParseInputLazyPath");
573
+ var handleResult = /* @__PURE__ */ __name2((ctx, result) => {
574
+ if (isValid(result)) {
575
+ return { success: true, data: result.value };
576
+ } else {
577
+ if (!ctx.common.issues.length) {
578
+ throw new Error("Validation failed but no issues detected.");
579
+ }
580
+ const error = new ZodError(ctx.common.issues);
581
+ return { success: false, error };
582
+ }
583
+ }, "handleResult");
584
+ function processCreateParams(params) {
585
+ if (!params)
586
+ return {};
587
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
588
+ if (errorMap2 && (invalid_type_error || required_error)) {
589
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
590
+ }
591
+ if (errorMap2)
592
+ return { errorMap: errorMap2, description };
593
+ const customMap = /* @__PURE__ */ __name2((iss, ctx) => {
594
+ if (iss.code !== "invalid_type")
595
+ return { message: ctx.defaultError };
596
+ if (typeof ctx.data === "undefined") {
597
+ return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
598
+ }
599
+ return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
600
+ }, "customMap");
601
+ return { errorMap: customMap, description };
602
+ }
603
+ __name(processCreateParams, "processCreateParams");
604
+ __name2(processCreateParams, "processCreateParams");
605
+ var ZodType = /* @__PURE__ */ __name(class {
606
+ constructor(def) {
607
+ this.spa = this.safeParseAsync;
608
+ this._def = def;
609
+ this.parse = this.parse.bind(this);
610
+ this.safeParse = this.safeParse.bind(this);
611
+ this.parseAsync = this.parseAsync.bind(this);
612
+ this.safeParseAsync = this.safeParseAsync.bind(this);
613
+ this.spa = this.spa.bind(this);
614
+ this.refine = this.refine.bind(this);
615
+ this.refinement = this.refinement.bind(this);
616
+ this.superRefine = this.superRefine.bind(this);
617
+ this.optional = this.optional.bind(this);
618
+ this.nullable = this.nullable.bind(this);
619
+ this.nullish = this.nullish.bind(this);
620
+ this.array = this.array.bind(this);
621
+ this.promise = this.promise.bind(this);
622
+ this.or = this.or.bind(this);
623
+ this.and = this.and.bind(this);
624
+ this.transform = this.transform.bind(this);
625
+ this.brand = this.brand.bind(this);
626
+ this.default = this.default.bind(this);
627
+ this.catch = this.catch.bind(this);
628
+ this.describe = this.describe.bind(this);
629
+ this.pipe = this.pipe.bind(this);
630
+ this.isNullable = this.isNullable.bind(this);
631
+ this.isOptional = this.isOptional.bind(this);
632
+ }
633
+ get description() {
634
+ return this._def.description;
635
+ }
636
+ _getType(input) {
637
+ return getParsedType(input.data);
638
+ }
639
+ _getOrReturnCtx(input, ctx) {
640
+ return ctx || {
641
+ common: input.parent.common,
642
+ data: input.data,
643
+ parsedType: getParsedType(input.data),
644
+ schemaErrorMap: this._def.errorMap,
645
+ path: input.path,
646
+ parent: input.parent
647
+ };
648
+ }
649
+ _processInputParams(input) {
650
+ return {
651
+ status: new ParseStatus(),
652
+ ctx: {
653
+ common: input.parent.common,
654
+ data: input.data,
655
+ parsedType: getParsedType(input.data),
656
+ schemaErrorMap: this._def.errorMap,
657
+ path: input.path,
658
+ parent: input.parent
659
+ }
660
+ };
661
+ }
662
+ _parseSync(input) {
663
+ const result = this._parse(input);
664
+ if (isAsync(result)) {
665
+ throw new Error("Synchronous parse encountered promise.");
666
+ }
667
+ return result;
668
+ }
669
+ _parseAsync(input) {
670
+ const result = this._parse(input);
671
+ return Promise.resolve(result);
672
+ }
673
+ parse(data, params) {
674
+ const result = this.safeParse(data, params);
675
+ if (result.success)
676
+ return result.data;
677
+ throw result.error;
678
+ }
679
+ safeParse(data, params) {
680
+ var _a;
681
+ const ctx = {
682
+ common: {
683
+ issues: [],
684
+ async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
685
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
686
+ },
687
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
688
+ schemaErrorMap: this._def.errorMap,
689
+ parent: null,
690
+ data,
691
+ parsedType: getParsedType(data)
692
+ };
693
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
694
+ return handleResult(ctx, result);
695
+ }
696
+ async parseAsync(data, params) {
697
+ const result = await this.safeParseAsync(data, params);
698
+ if (result.success)
699
+ return result.data;
700
+ throw result.error;
701
+ }
702
+ async safeParseAsync(data, params) {
703
+ const ctx = {
704
+ common: {
705
+ issues: [],
706
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
707
+ async: true
708
+ },
709
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
710
+ schemaErrorMap: this._def.errorMap,
711
+ parent: null,
712
+ data,
713
+ parsedType: getParsedType(data)
714
+ };
715
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
716
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
717
+ return handleResult(ctx, result);
718
+ }
719
+ refine(check, message) {
720
+ const getIssueProperties = /* @__PURE__ */ __name2((val) => {
721
+ if (typeof message === "string" || typeof message === "undefined") {
722
+ return { message };
723
+ } else if (typeof message === "function") {
724
+ return message(val);
725
+ } else {
726
+ return message;
727
+ }
728
+ }, "getIssueProperties");
729
+ return this._refinement((val, ctx) => {
730
+ const result = check(val);
731
+ const setError = /* @__PURE__ */ __name2(() => ctx.addIssue({
732
+ code: ZodIssueCode.custom,
733
+ ...getIssueProperties(val)
734
+ }), "setError");
735
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
736
+ return result.then((data) => {
737
+ if (!data) {
738
+ setError();
739
+ return false;
740
+ } else {
741
+ return true;
742
+ }
743
+ });
744
+ }
745
+ if (!result) {
746
+ setError();
747
+ return false;
748
+ } else {
749
+ return true;
750
+ }
751
+ });
752
+ }
753
+ refinement(check, refinementData) {
754
+ return this._refinement((val, ctx) => {
755
+ if (!check(val)) {
756
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
757
+ return false;
758
+ } else {
759
+ return true;
760
+ }
761
+ });
762
+ }
763
+ _refinement(refinement) {
764
+ return new ZodEffects({
765
+ schema: this,
766
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
767
+ effect: { type: "refinement", refinement }
768
+ });
769
+ }
770
+ superRefine(refinement) {
771
+ return this._refinement(refinement);
772
+ }
773
+ optional() {
774
+ return ZodOptional.create(this, this._def);
775
+ }
776
+ nullable() {
777
+ return ZodNullable.create(this, this._def);
778
+ }
779
+ nullish() {
780
+ return this.nullable().optional();
781
+ }
782
+ array() {
783
+ return ZodArray.create(this, this._def);
784
+ }
785
+ promise() {
786
+ return ZodPromise.create(this, this._def);
787
+ }
788
+ or(option) {
789
+ return ZodUnion.create([this, option], this._def);
790
+ }
791
+ and(incoming) {
792
+ return ZodIntersection.create(this, incoming, this._def);
793
+ }
794
+ transform(transform) {
795
+ return new ZodEffects({
796
+ ...processCreateParams(this._def),
797
+ schema: this,
798
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
799
+ effect: { type: "transform", transform }
800
+ });
801
+ }
802
+ default(def) {
803
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
804
+ return new ZodDefault({
805
+ ...processCreateParams(this._def),
806
+ innerType: this,
807
+ defaultValue: defaultValueFunc,
808
+ typeName: ZodFirstPartyTypeKind.ZodDefault
809
+ });
810
+ }
811
+ brand() {
812
+ return new ZodBranded({
813
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
814
+ type: this,
815
+ ...processCreateParams(this._def)
816
+ });
817
+ }
818
+ catch(def) {
819
+ const catchValueFunc = typeof def === "function" ? def : () => def;
820
+ return new ZodCatch({
821
+ ...processCreateParams(this._def),
822
+ innerType: this,
823
+ catchValue: catchValueFunc,
824
+ typeName: ZodFirstPartyTypeKind.ZodCatch
825
+ });
826
+ }
827
+ describe(description) {
828
+ const This = this.constructor;
829
+ return new This({
830
+ ...this._def,
831
+ description
832
+ });
833
+ }
834
+ pipe(target) {
835
+ return ZodPipeline.create(this, target);
836
+ }
837
+ isOptional() {
838
+ return this.safeParse(void 0).success;
839
+ }
840
+ isNullable() {
841
+ return this.safeParse(null).success;
842
+ }
843
+ }, "ZodType");
844
+ __name2(ZodType, "ZodType");
845
+ var cuidRegex = /^c[^\s-]{8,}$/i;
846
+ var cuid2Regex = /^[a-z][a-z0-9]*$/;
847
+ var uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
848
+ var emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|([^-]([a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}))$/;
849
+ var datetimeRegex = /* @__PURE__ */ __name2((args) => {
850
+ if (args.precision) {
851
+ if (args.offset) {
852
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
853
+ } else {
854
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
855
+ }
856
+ } else if (args.precision === 0) {
857
+ if (args.offset) {
858
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
859
+ } else {
860
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
861
+ }
862
+ } else {
863
+ if (args.offset) {
864
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
865
+ } else {
866
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
867
+ }
868
+ }
869
+ }, "datetimeRegex");
870
+ var ZodString = /* @__PURE__ */ __name(class extends ZodType {
871
+ constructor() {
872
+ super(...arguments);
873
+ this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
874
+ validation,
875
+ code: ZodIssueCode.invalid_string,
876
+ ...errorUtil.errToObj(message)
877
+ });
878
+ this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
879
+ this.trim = () => new ZodString({
880
+ ...this._def,
881
+ checks: [...this._def.checks, { kind: "trim" }]
882
+ });
883
+ }
884
+ _parse(input) {
885
+ if (this._def.coerce) {
886
+ input.data = String(input.data);
887
+ }
888
+ const parsedType = this._getType(input);
889
+ if (parsedType !== ZodParsedType.string) {
890
+ const ctx2 = this._getOrReturnCtx(input);
891
+ addIssueToContext(
892
+ ctx2,
893
+ {
894
+ code: ZodIssueCode.invalid_type,
895
+ expected: ZodParsedType.string,
896
+ received: ctx2.parsedType
897
+ }
898
+ );
899
+ return INVALID;
900
+ }
901
+ const status = new ParseStatus();
902
+ let ctx = void 0;
903
+ for (const check of this._def.checks) {
904
+ if (check.kind === "min") {
905
+ if (input.data.length < check.value) {
906
+ ctx = this._getOrReturnCtx(input, ctx);
907
+ addIssueToContext(ctx, {
908
+ code: ZodIssueCode.too_small,
909
+ minimum: check.value,
910
+ type: "string",
911
+ inclusive: true,
912
+ exact: false,
913
+ message: check.message
914
+ });
915
+ status.dirty();
916
+ }
917
+ } else if (check.kind === "max") {
918
+ if (input.data.length > check.value) {
919
+ ctx = this._getOrReturnCtx(input, ctx);
920
+ addIssueToContext(ctx, {
921
+ code: ZodIssueCode.too_big,
922
+ maximum: check.value,
923
+ type: "string",
924
+ inclusive: true,
925
+ exact: false,
926
+ message: check.message
927
+ });
928
+ status.dirty();
929
+ }
930
+ } else if (check.kind === "length") {
931
+ const tooBig = input.data.length > check.value;
932
+ const tooSmall = input.data.length < check.value;
933
+ if (tooBig || tooSmall) {
934
+ ctx = this._getOrReturnCtx(input, ctx);
935
+ if (tooBig) {
936
+ addIssueToContext(ctx, {
937
+ code: ZodIssueCode.too_big,
938
+ maximum: check.value,
939
+ type: "string",
940
+ inclusive: true,
941
+ exact: true,
942
+ message: check.message
943
+ });
944
+ } else if (tooSmall) {
945
+ addIssueToContext(ctx, {
946
+ code: ZodIssueCode.too_small,
947
+ minimum: check.value,
948
+ type: "string",
949
+ inclusive: true,
950
+ exact: true,
951
+ message: check.message
952
+ });
953
+ }
954
+ status.dirty();
955
+ }
956
+ } else if (check.kind === "email") {
957
+ if (!emailRegex.test(input.data)) {
958
+ ctx = this._getOrReturnCtx(input, ctx);
959
+ addIssueToContext(ctx, {
960
+ validation: "email",
961
+ code: ZodIssueCode.invalid_string,
962
+ message: check.message
963
+ });
964
+ status.dirty();
965
+ }
966
+ } else if (check.kind === "uuid") {
967
+ if (!uuidRegex.test(input.data)) {
968
+ ctx = this._getOrReturnCtx(input, ctx);
969
+ addIssueToContext(ctx, {
970
+ validation: "uuid",
971
+ code: ZodIssueCode.invalid_string,
972
+ message: check.message
973
+ });
974
+ status.dirty();
975
+ }
976
+ } else if (check.kind === "cuid") {
977
+ if (!cuidRegex.test(input.data)) {
978
+ ctx = this._getOrReturnCtx(input, ctx);
979
+ addIssueToContext(ctx, {
980
+ validation: "cuid",
981
+ code: ZodIssueCode.invalid_string,
982
+ message: check.message
983
+ });
984
+ status.dirty();
985
+ }
986
+ } else if (check.kind === "cuid2") {
987
+ if (!cuid2Regex.test(input.data)) {
988
+ ctx = this._getOrReturnCtx(input, ctx);
989
+ addIssueToContext(ctx, {
990
+ validation: "cuid2",
991
+ code: ZodIssueCode.invalid_string,
992
+ message: check.message
993
+ });
994
+ status.dirty();
995
+ }
996
+ } else if (check.kind === "url") {
997
+ try {
998
+ new URL(input.data);
999
+ } catch (_a) {
1000
+ ctx = this._getOrReturnCtx(input, ctx);
1001
+ addIssueToContext(ctx, {
1002
+ validation: "url",
1003
+ code: ZodIssueCode.invalid_string,
1004
+ message: check.message
1005
+ });
1006
+ status.dirty();
1007
+ }
1008
+ } else if (check.kind === "regex") {
1009
+ check.regex.lastIndex = 0;
1010
+ const testResult = check.regex.test(input.data);
1011
+ if (!testResult) {
1012
+ ctx = this._getOrReturnCtx(input, ctx);
1013
+ addIssueToContext(ctx, {
1014
+ validation: "regex",
1015
+ code: ZodIssueCode.invalid_string,
1016
+ message: check.message
1017
+ });
1018
+ status.dirty();
1019
+ }
1020
+ } else if (check.kind === "trim") {
1021
+ input.data = input.data.trim();
1022
+ } else if (check.kind === "startsWith") {
1023
+ if (!input.data.startsWith(check.value)) {
1024
+ ctx = this._getOrReturnCtx(input, ctx);
1025
+ addIssueToContext(ctx, {
1026
+ code: ZodIssueCode.invalid_string,
1027
+ validation: { startsWith: check.value },
1028
+ message: check.message
1029
+ });
1030
+ status.dirty();
1031
+ }
1032
+ } else if (check.kind === "endsWith") {
1033
+ if (!input.data.endsWith(check.value)) {
1034
+ ctx = this._getOrReturnCtx(input, ctx);
1035
+ addIssueToContext(ctx, {
1036
+ code: ZodIssueCode.invalid_string,
1037
+ validation: { endsWith: check.value },
1038
+ message: check.message
1039
+ });
1040
+ status.dirty();
1041
+ }
1042
+ } else if (check.kind === "datetime") {
1043
+ const regex = datetimeRegex(check);
1044
+ if (!regex.test(input.data)) {
1045
+ ctx = this._getOrReturnCtx(input, ctx);
1046
+ addIssueToContext(ctx, {
1047
+ code: ZodIssueCode.invalid_string,
1048
+ validation: "datetime",
1049
+ message: check.message
1050
+ });
1051
+ status.dirty();
1052
+ }
1053
+ } else {
1054
+ util.assertNever(check);
1055
+ }
1056
+ }
1057
+ return { status: status.value, value: input.data };
1058
+ }
1059
+ _addCheck(check) {
1060
+ return new ZodString({
1061
+ ...this._def,
1062
+ checks: [...this._def.checks, check]
1063
+ });
1064
+ }
1065
+ email(message) {
1066
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
1067
+ }
1068
+ url(message) {
1069
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
1070
+ }
1071
+ uuid(message) {
1072
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1073
+ }
1074
+ cuid(message) {
1075
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1076
+ }
1077
+ cuid2(message) {
1078
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1079
+ }
1080
+ datetime(options) {
1081
+ var _a;
1082
+ if (typeof options === "string") {
1083
+ return this._addCheck({
1084
+ kind: "datetime",
1085
+ precision: null,
1086
+ offset: false,
1087
+ message: options
1088
+ });
1089
+ }
1090
+ return this._addCheck({
1091
+ kind: "datetime",
1092
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1093
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1094
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1095
+ });
1096
+ }
1097
+ regex(regex, message) {
1098
+ return this._addCheck({
1099
+ kind: "regex",
1100
+ regex,
1101
+ ...errorUtil.errToObj(message)
1102
+ });
1103
+ }
1104
+ startsWith(value, message) {
1105
+ return this._addCheck({
1106
+ kind: "startsWith",
1107
+ value,
1108
+ ...errorUtil.errToObj(message)
1109
+ });
1110
+ }
1111
+ endsWith(value, message) {
1112
+ return this._addCheck({
1113
+ kind: "endsWith",
1114
+ value,
1115
+ ...errorUtil.errToObj(message)
1116
+ });
1117
+ }
1118
+ min(minLength, message) {
1119
+ return this._addCheck({
1120
+ kind: "min",
1121
+ value: minLength,
1122
+ ...errorUtil.errToObj(message)
1123
+ });
1124
+ }
1125
+ max(maxLength, message) {
1126
+ return this._addCheck({
1127
+ kind: "max",
1128
+ value: maxLength,
1129
+ ...errorUtil.errToObj(message)
1130
+ });
1131
+ }
1132
+ length(len, message) {
1133
+ return this._addCheck({
1134
+ kind: "length",
1135
+ value: len,
1136
+ ...errorUtil.errToObj(message)
1137
+ });
1138
+ }
1139
+ get isDatetime() {
1140
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1141
+ }
1142
+ get isEmail() {
1143
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1144
+ }
1145
+ get isURL() {
1146
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1147
+ }
1148
+ get isUUID() {
1149
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1150
+ }
1151
+ get isCUID() {
1152
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1153
+ }
1154
+ get isCUID2() {
1155
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1156
+ }
1157
+ get minLength() {
1158
+ let min = null;
1159
+ for (const ch of this._def.checks) {
1160
+ if (ch.kind === "min") {
1161
+ if (min === null || ch.value > min)
1162
+ min = ch.value;
1163
+ }
1164
+ }
1165
+ return min;
1166
+ }
1167
+ get maxLength() {
1168
+ let max = null;
1169
+ for (const ch of this._def.checks) {
1170
+ if (ch.kind === "max") {
1171
+ if (max === null || ch.value < max)
1172
+ max = ch.value;
1173
+ }
1174
+ }
1175
+ return max;
1176
+ }
1177
+ }, "ZodString");
1178
+ __name2(ZodString, "ZodString");
1179
+ ZodString.create = (params) => {
1180
+ var _a;
1181
+ return new ZodString({
1182
+ checks: [],
1183
+ typeName: ZodFirstPartyTypeKind.ZodString,
1184
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1185
+ ...processCreateParams(params)
1186
+ });
1187
+ };
1188
+ function floatSafeRemainder(val, step) {
1189
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1190
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
1191
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1192
+ const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
1193
+ const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
1194
+ return valInt % stepInt / Math.pow(10, decCount);
1195
+ }
1196
+ __name(floatSafeRemainder, "floatSafeRemainder");
1197
+ __name2(floatSafeRemainder, "floatSafeRemainder");
1198
+ var ZodNumber = /* @__PURE__ */ __name(class extends ZodType {
1199
+ constructor() {
1200
+ super(...arguments);
1201
+ this.min = this.gte;
1202
+ this.max = this.lte;
1203
+ this.step = this.multipleOf;
1204
+ }
1205
+ _parse(input) {
1206
+ if (this._def.coerce) {
1207
+ input.data = Number(input.data);
1208
+ }
1209
+ const parsedType = this._getType(input);
1210
+ if (parsedType !== ZodParsedType.number) {
1211
+ const ctx2 = this._getOrReturnCtx(input);
1212
+ addIssueToContext(ctx2, {
1213
+ code: ZodIssueCode.invalid_type,
1214
+ expected: ZodParsedType.number,
1215
+ received: ctx2.parsedType
1216
+ });
1217
+ return INVALID;
1218
+ }
1219
+ let ctx = void 0;
1220
+ const status = new ParseStatus();
1221
+ for (const check of this._def.checks) {
1222
+ if (check.kind === "int") {
1223
+ if (!util.isInteger(input.data)) {
1224
+ ctx = this._getOrReturnCtx(input, ctx);
1225
+ addIssueToContext(ctx, {
1226
+ code: ZodIssueCode.invalid_type,
1227
+ expected: "integer",
1228
+ received: "float",
1229
+ message: check.message
1230
+ });
1231
+ status.dirty();
1232
+ }
1233
+ } else if (check.kind === "min") {
1234
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1235
+ if (tooSmall) {
1236
+ ctx = this._getOrReturnCtx(input, ctx);
1237
+ addIssueToContext(ctx, {
1238
+ code: ZodIssueCode.too_small,
1239
+ minimum: check.value,
1240
+ type: "number",
1241
+ inclusive: check.inclusive,
1242
+ exact: false,
1243
+ message: check.message
1244
+ });
1245
+ status.dirty();
1246
+ }
1247
+ } else if (check.kind === "max") {
1248
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1249
+ if (tooBig) {
1250
+ ctx = this._getOrReturnCtx(input, ctx);
1251
+ addIssueToContext(ctx, {
1252
+ code: ZodIssueCode.too_big,
1253
+ maximum: check.value,
1254
+ type: "number",
1255
+ inclusive: check.inclusive,
1256
+ exact: false,
1257
+ message: check.message
1258
+ });
1259
+ status.dirty();
1260
+ }
1261
+ } else if (check.kind === "multipleOf") {
1262
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
1263
+ ctx = this._getOrReturnCtx(input, ctx);
1264
+ addIssueToContext(ctx, {
1265
+ code: ZodIssueCode.not_multiple_of,
1266
+ multipleOf: check.value,
1267
+ message: check.message
1268
+ });
1269
+ status.dirty();
1270
+ }
1271
+ } else if (check.kind === "finite") {
1272
+ if (!Number.isFinite(input.data)) {
1273
+ ctx = this._getOrReturnCtx(input, ctx);
1274
+ addIssueToContext(ctx, {
1275
+ code: ZodIssueCode.not_finite,
1276
+ message: check.message
1277
+ });
1278
+ status.dirty();
1279
+ }
1280
+ } else {
1281
+ util.assertNever(check);
1282
+ }
1283
+ }
1284
+ return { status: status.value, value: input.data };
1285
+ }
1286
+ gte(value, message) {
1287
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1288
+ }
1289
+ gt(value, message) {
1290
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1291
+ }
1292
+ lte(value, message) {
1293
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1294
+ }
1295
+ lt(value, message) {
1296
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1297
+ }
1298
+ setLimit(kind, value, inclusive, message) {
1299
+ return new ZodNumber({
1300
+ ...this._def,
1301
+ checks: [
1302
+ ...this._def.checks,
1303
+ {
1304
+ kind,
1305
+ value,
1306
+ inclusive,
1307
+ message: errorUtil.toString(message)
1308
+ }
1309
+ ]
1310
+ });
1311
+ }
1312
+ _addCheck(check) {
1313
+ return new ZodNumber({
1314
+ ...this._def,
1315
+ checks: [...this._def.checks, check]
1316
+ });
1317
+ }
1318
+ int(message) {
1319
+ return this._addCheck({
1320
+ kind: "int",
1321
+ message: errorUtil.toString(message)
1322
+ });
1323
+ }
1324
+ positive(message) {
1325
+ return this._addCheck({
1326
+ kind: "min",
1327
+ value: 0,
1328
+ inclusive: false,
1329
+ message: errorUtil.toString(message)
1330
+ });
1331
+ }
1332
+ negative(message) {
1333
+ return this._addCheck({
1334
+ kind: "max",
1335
+ value: 0,
1336
+ inclusive: false,
1337
+ message: errorUtil.toString(message)
1338
+ });
1339
+ }
1340
+ nonpositive(message) {
1341
+ return this._addCheck({
1342
+ kind: "max",
1343
+ value: 0,
1344
+ inclusive: true,
1345
+ message: errorUtil.toString(message)
1346
+ });
1347
+ }
1348
+ nonnegative(message) {
1349
+ return this._addCheck({
1350
+ kind: "min",
1351
+ value: 0,
1352
+ inclusive: true,
1353
+ message: errorUtil.toString(message)
1354
+ });
1355
+ }
1356
+ multipleOf(value, message) {
1357
+ return this._addCheck({
1358
+ kind: "multipleOf",
1359
+ value,
1360
+ message: errorUtil.toString(message)
1361
+ });
1362
+ }
1363
+ finite(message) {
1364
+ return this._addCheck({
1365
+ kind: "finite",
1366
+ message: errorUtil.toString(message)
1367
+ });
1368
+ }
1369
+ get minValue() {
1370
+ let min = null;
1371
+ for (const ch of this._def.checks) {
1372
+ if (ch.kind === "min") {
1373
+ if (min === null || ch.value > min)
1374
+ min = ch.value;
1375
+ }
1376
+ }
1377
+ return min;
1378
+ }
1379
+ get maxValue() {
1380
+ let max = null;
1381
+ for (const ch of this._def.checks) {
1382
+ if (ch.kind === "max") {
1383
+ if (max === null || ch.value < max)
1384
+ max = ch.value;
1385
+ }
1386
+ }
1387
+ return max;
1388
+ }
1389
+ get isInt() {
1390
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1391
+ }
1392
+ get isFinite() {
1393
+ let max = null, min = null;
1394
+ for (const ch of this._def.checks) {
1395
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
1396
+ return true;
1397
+ } else if (ch.kind === "min") {
1398
+ if (min === null || ch.value > min)
1399
+ min = ch.value;
1400
+ } else if (ch.kind === "max") {
1401
+ if (max === null || ch.value < max)
1402
+ max = ch.value;
1403
+ }
1404
+ }
1405
+ return Number.isFinite(min) && Number.isFinite(max);
1406
+ }
1407
+ }, "ZodNumber");
1408
+ __name2(ZodNumber, "ZodNumber");
1409
+ ZodNumber.create = (params) => {
1410
+ return new ZodNumber({
1411
+ checks: [],
1412
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1413
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1414
+ ...processCreateParams(params)
1415
+ });
1416
+ };
1417
+ var ZodBigInt = /* @__PURE__ */ __name(class extends ZodType {
1418
+ _parse(input) {
1419
+ if (this._def.coerce) {
1420
+ input.data = BigInt(input.data);
1421
+ }
1422
+ const parsedType = this._getType(input);
1423
+ if (parsedType !== ZodParsedType.bigint) {
1424
+ const ctx = this._getOrReturnCtx(input);
1425
+ addIssueToContext(ctx, {
1426
+ code: ZodIssueCode.invalid_type,
1427
+ expected: ZodParsedType.bigint,
1428
+ received: ctx.parsedType
1429
+ });
1430
+ return INVALID;
1431
+ }
1432
+ return OK(input.data);
1433
+ }
1434
+ }, "ZodBigInt");
1435
+ __name2(ZodBigInt, "ZodBigInt");
1436
+ ZodBigInt.create = (params) => {
1437
+ var _a;
1438
+ return new ZodBigInt({
1439
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
1440
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1441
+ ...processCreateParams(params)
1442
+ });
1443
+ };
1444
+ var ZodBoolean = /* @__PURE__ */ __name(class extends ZodType {
1445
+ _parse(input) {
1446
+ if (this._def.coerce) {
1447
+ input.data = Boolean(input.data);
1448
+ }
1449
+ const parsedType = this._getType(input);
1450
+ if (parsedType !== ZodParsedType.boolean) {
1451
+ const ctx = this._getOrReturnCtx(input);
1452
+ addIssueToContext(ctx, {
1453
+ code: ZodIssueCode.invalid_type,
1454
+ expected: ZodParsedType.boolean,
1455
+ received: ctx.parsedType
1456
+ });
1457
+ return INVALID;
1458
+ }
1459
+ return OK(input.data);
1460
+ }
1461
+ }, "ZodBoolean");
1462
+ __name2(ZodBoolean, "ZodBoolean");
1463
+ ZodBoolean.create = (params) => {
1464
+ return new ZodBoolean({
1465
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
1466
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1467
+ ...processCreateParams(params)
1468
+ });
1469
+ };
1470
+ var ZodDate = /* @__PURE__ */ __name(class extends ZodType {
1471
+ _parse(input) {
1472
+ if (this._def.coerce) {
1473
+ input.data = new Date(input.data);
1474
+ }
1475
+ const parsedType = this._getType(input);
1476
+ if (parsedType !== ZodParsedType.date) {
1477
+ const ctx2 = this._getOrReturnCtx(input);
1478
+ addIssueToContext(ctx2, {
1479
+ code: ZodIssueCode.invalid_type,
1480
+ expected: ZodParsedType.date,
1481
+ received: ctx2.parsedType
1482
+ });
1483
+ return INVALID;
1484
+ }
1485
+ if (isNaN(input.data.getTime())) {
1486
+ const ctx2 = this._getOrReturnCtx(input);
1487
+ addIssueToContext(ctx2, {
1488
+ code: ZodIssueCode.invalid_date
1489
+ });
1490
+ return INVALID;
1491
+ }
1492
+ const status = new ParseStatus();
1493
+ let ctx = void 0;
1494
+ for (const check of this._def.checks) {
1495
+ if (check.kind === "min") {
1496
+ if (input.data.getTime() < check.value) {
1497
+ ctx = this._getOrReturnCtx(input, ctx);
1498
+ addIssueToContext(ctx, {
1499
+ code: ZodIssueCode.too_small,
1500
+ message: check.message,
1501
+ inclusive: true,
1502
+ exact: false,
1503
+ minimum: check.value,
1504
+ type: "date"
1505
+ });
1506
+ status.dirty();
1507
+ }
1508
+ } else if (check.kind === "max") {
1509
+ if (input.data.getTime() > check.value) {
1510
+ ctx = this._getOrReturnCtx(input, ctx);
1511
+ addIssueToContext(ctx, {
1512
+ code: ZodIssueCode.too_big,
1513
+ message: check.message,
1514
+ inclusive: true,
1515
+ exact: false,
1516
+ maximum: check.value,
1517
+ type: "date"
1518
+ });
1519
+ status.dirty();
1520
+ }
1521
+ } else {
1522
+ util.assertNever(check);
1523
+ }
1524
+ }
1525
+ return {
1526
+ status: status.value,
1527
+ value: new Date(input.data.getTime())
1528
+ };
1529
+ }
1530
+ _addCheck(check) {
1531
+ return new ZodDate({
1532
+ ...this._def,
1533
+ checks: [...this._def.checks, check]
1534
+ });
1535
+ }
1536
+ min(minDate, message) {
1537
+ return this._addCheck({
1538
+ kind: "min",
1539
+ value: minDate.getTime(),
1540
+ message: errorUtil.toString(message)
1541
+ });
1542
+ }
1543
+ max(maxDate, message) {
1544
+ return this._addCheck({
1545
+ kind: "max",
1546
+ value: maxDate.getTime(),
1547
+ message: errorUtil.toString(message)
1548
+ });
1549
+ }
1550
+ get minDate() {
1551
+ let min = null;
1552
+ for (const ch of this._def.checks) {
1553
+ if (ch.kind === "min") {
1554
+ if (min === null || ch.value > min)
1555
+ min = ch.value;
1556
+ }
1557
+ }
1558
+ return min != null ? new Date(min) : null;
1559
+ }
1560
+ get maxDate() {
1561
+ let max = null;
1562
+ for (const ch of this._def.checks) {
1563
+ if (ch.kind === "max") {
1564
+ if (max === null || ch.value < max)
1565
+ max = ch.value;
1566
+ }
1567
+ }
1568
+ return max != null ? new Date(max) : null;
1569
+ }
1570
+ }, "ZodDate");
1571
+ __name2(ZodDate, "ZodDate");
1572
+ ZodDate.create = (params) => {
1573
+ return new ZodDate({
1574
+ checks: [],
1575
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1576
+ typeName: ZodFirstPartyTypeKind.ZodDate,
1577
+ ...processCreateParams(params)
1578
+ });
1579
+ };
1580
+ var ZodSymbol = /* @__PURE__ */ __name(class extends ZodType {
1581
+ _parse(input) {
1582
+ const parsedType = this._getType(input);
1583
+ if (parsedType !== ZodParsedType.symbol) {
1584
+ const ctx = this._getOrReturnCtx(input);
1585
+ addIssueToContext(ctx, {
1586
+ code: ZodIssueCode.invalid_type,
1587
+ expected: ZodParsedType.symbol,
1588
+ received: ctx.parsedType
1589
+ });
1590
+ return INVALID;
1591
+ }
1592
+ return OK(input.data);
1593
+ }
1594
+ }, "ZodSymbol");
1595
+ __name2(ZodSymbol, "ZodSymbol");
1596
+ ZodSymbol.create = (params) => {
1597
+ return new ZodSymbol({
1598
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
1599
+ ...processCreateParams(params)
1600
+ });
1601
+ };
1602
+ var ZodUndefined = /* @__PURE__ */ __name(class extends ZodType {
1603
+ _parse(input) {
1604
+ const parsedType = this._getType(input);
1605
+ if (parsedType !== ZodParsedType.undefined) {
1606
+ const ctx = this._getOrReturnCtx(input);
1607
+ addIssueToContext(ctx, {
1608
+ code: ZodIssueCode.invalid_type,
1609
+ expected: ZodParsedType.undefined,
1610
+ received: ctx.parsedType
1611
+ });
1612
+ return INVALID;
1613
+ }
1614
+ return OK(input.data);
1615
+ }
1616
+ }, "ZodUndefined");
1617
+ __name2(ZodUndefined, "ZodUndefined");
1618
+ ZodUndefined.create = (params) => {
1619
+ return new ZodUndefined({
1620
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
1621
+ ...processCreateParams(params)
1622
+ });
1623
+ };
1624
+ var ZodNull = /* @__PURE__ */ __name(class extends ZodType {
1625
+ _parse(input) {
1626
+ const parsedType = this._getType(input);
1627
+ if (parsedType !== ZodParsedType.null) {
1628
+ const ctx = this._getOrReturnCtx(input);
1629
+ addIssueToContext(ctx, {
1630
+ code: ZodIssueCode.invalid_type,
1631
+ expected: ZodParsedType.null,
1632
+ received: ctx.parsedType
1633
+ });
1634
+ return INVALID;
1635
+ }
1636
+ return OK(input.data);
1637
+ }
1638
+ }, "ZodNull");
1639
+ __name2(ZodNull, "ZodNull");
1640
+ ZodNull.create = (params) => {
1641
+ return new ZodNull({
1642
+ typeName: ZodFirstPartyTypeKind.ZodNull,
1643
+ ...processCreateParams(params)
1644
+ });
1645
+ };
1646
+ var ZodAny = /* @__PURE__ */ __name(class extends ZodType {
1647
+ constructor() {
1648
+ super(...arguments);
1649
+ this._any = true;
1650
+ }
1651
+ _parse(input) {
1652
+ return OK(input.data);
1653
+ }
1654
+ }, "ZodAny");
1655
+ __name2(ZodAny, "ZodAny");
1656
+ ZodAny.create = (params) => {
1657
+ return new ZodAny({
1658
+ typeName: ZodFirstPartyTypeKind.ZodAny,
1659
+ ...processCreateParams(params)
1660
+ });
1661
+ };
1662
+ var ZodUnknown = /* @__PURE__ */ __name(class extends ZodType {
1663
+ constructor() {
1664
+ super(...arguments);
1665
+ this._unknown = true;
1666
+ }
1667
+ _parse(input) {
1668
+ return OK(input.data);
1669
+ }
1670
+ }, "ZodUnknown");
1671
+ __name2(ZodUnknown, "ZodUnknown");
1672
+ ZodUnknown.create = (params) => {
1673
+ return new ZodUnknown({
1674
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
1675
+ ...processCreateParams(params)
1676
+ });
1677
+ };
1678
+ var ZodNever = /* @__PURE__ */ __name(class extends ZodType {
1679
+ _parse(input) {
1680
+ const ctx = this._getOrReturnCtx(input);
1681
+ addIssueToContext(ctx, {
1682
+ code: ZodIssueCode.invalid_type,
1683
+ expected: ZodParsedType.never,
1684
+ received: ctx.parsedType
1685
+ });
1686
+ return INVALID;
1687
+ }
1688
+ }, "ZodNever");
1689
+ __name2(ZodNever, "ZodNever");
1690
+ ZodNever.create = (params) => {
1691
+ return new ZodNever({
1692
+ typeName: ZodFirstPartyTypeKind.ZodNever,
1693
+ ...processCreateParams(params)
1694
+ });
1695
+ };
1696
+ var ZodVoid = /* @__PURE__ */ __name(class extends ZodType {
1697
+ _parse(input) {
1698
+ const parsedType = this._getType(input);
1699
+ if (parsedType !== ZodParsedType.undefined) {
1700
+ const ctx = this._getOrReturnCtx(input);
1701
+ addIssueToContext(ctx, {
1702
+ code: ZodIssueCode.invalid_type,
1703
+ expected: ZodParsedType.void,
1704
+ received: ctx.parsedType
1705
+ });
1706
+ return INVALID;
1707
+ }
1708
+ return OK(input.data);
1709
+ }
1710
+ }, "ZodVoid");
1711
+ __name2(ZodVoid, "ZodVoid");
1712
+ ZodVoid.create = (params) => {
1713
+ return new ZodVoid({
1714
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
1715
+ ...processCreateParams(params)
1716
+ });
1717
+ };
1718
+ var ZodArray = /* @__PURE__ */ __name(class extends ZodType {
1719
+ _parse(input) {
1720
+ const { ctx, status } = this._processInputParams(input);
1721
+ const def = this._def;
1722
+ if (ctx.parsedType !== ZodParsedType.array) {
1723
+ addIssueToContext(ctx, {
1724
+ code: ZodIssueCode.invalid_type,
1725
+ expected: ZodParsedType.array,
1726
+ received: ctx.parsedType
1727
+ });
1728
+ return INVALID;
1729
+ }
1730
+ if (def.exactLength !== null) {
1731
+ const tooBig = ctx.data.length > def.exactLength.value;
1732
+ const tooSmall = ctx.data.length < def.exactLength.value;
1733
+ if (tooBig || tooSmall) {
1734
+ addIssueToContext(ctx, {
1735
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
1736
+ minimum: tooSmall ? def.exactLength.value : void 0,
1737
+ maximum: tooBig ? def.exactLength.value : void 0,
1738
+ type: "array",
1739
+ inclusive: true,
1740
+ exact: true,
1741
+ message: def.exactLength.message
1742
+ });
1743
+ status.dirty();
1744
+ }
1745
+ }
1746
+ if (def.minLength !== null) {
1747
+ if (ctx.data.length < def.minLength.value) {
1748
+ addIssueToContext(ctx, {
1749
+ code: ZodIssueCode.too_small,
1750
+ minimum: def.minLength.value,
1751
+ type: "array",
1752
+ inclusive: true,
1753
+ exact: false,
1754
+ message: def.minLength.message
1755
+ });
1756
+ status.dirty();
1757
+ }
1758
+ }
1759
+ if (def.maxLength !== null) {
1760
+ if (ctx.data.length > def.maxLength.value) {
1761
+ addIssueToContext(ctx, {
1762
+ code: ZodIssueCode.too_big,
1763
+ maximum: def.maxLength.value,
1764
+ type: "array",
1765
+ inclusive: true,
1766
+ exact: false,
1767
+ message: def.maxLength.message
1768
+ });
1769
+ status.dirty();
1770
+ }
1771
+ }
1772
+ if (ctx.common.async) {
1773
+ return Promise.all([...ctx.data].map((item, i) => {
1774
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1775
+ })).then((result2) => {
1776
+ return ParseStatus.mergeArray(status, result2);
1777
+ });
1778
+ }
1779
+ const result = [...ctx.data].map((item, i) => {
1780
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1781
+ });
1782
+ return ParseStatus.mergeArray(status, result);
1783
+ }
1784
+ get element() {
1785
+ return this._def.type;
1786
+ }
1787
+ min(minLength, message) {
1788
+ return new ZodArray({
1789
+ ...this._def,
1790
+ minLength: { value: minLength, message: errorUtil.toString(message) }
1791
+ });
1792
+ }
1793
+ max(maxLength, message) {
1794
+ return new ZodArray({
1795
+ ...this._def,
1796
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
1797
+ });
1798
+ }
1799
+ length(len, message) {
1800
+ return new ZodArray({
1801
+ ...this._def,
1802
+ exactLength: { value: len, message: errorUtil.toString(message) }
1803
+ });
1804
+ }
1805
+ nonempty(message) {
1806
+ return this.min(1, message);
1807
+ }
1808
+ }, "ZodArray");
1809
+ __name2(ZodArray, "ZodArray");
1810
+ ZodArray.create = (schema, params) => {
1811
+ return new ZodArray({
1812
+ type: schema,
1813
+ minLength: null,
1814
+ maxLength: null,
1815
+ exactLength: null,
1816
+ typeName: ZodFirstPartyTypeKind.ZodArray,
1817
+ ...processCreateParams(params)
1818
+ });
1819
+ };
1820
+ var objectUtil;
1821
+ (function(objectUtil2) {
1822
+ objectUtil2.mergeShapes = (first, second) => {
1823
+ return {
1824
+ ...first,
1825
+ ...second
1826
+ };
1827
+ };
1828
+ })(objectUtil || (objectUtil = {}));
1829
+ function deepPartialify(schema) {
1830
+ if (schema instanceof ZodObject) {
1831
+ const newShape = {};
1832
+ for (const key in schema.shape) {
1833
+ const fieldSchema = schema.shape[key];
1834
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
1835
+ }
1836
+ return new ZodObject({
1837
+ ...schema._def,
1838
+ shape: () => newShape
1839
+ });
1840
+ } else if (schema instanceof ZodArray) {
1841
+ return ZodArray.create(deepPartialify(schema.element));
1842
+ } else if (schema instanceof ZodOptional) {
1843
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
1844
+ } else if (schema instanceof ZodNullable) {
1845
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
1846
+ } else if (schema instanceof ZodTuple) {
1847
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
1848
+ } else {
1849
+ return schema;
1850
+ }
1851
+ }
1852
+ __name(deepPartialify, "deepPartialify");
1853
+ __name2(deepPartialify, "deepPartialify");
1854
+ var ZodObject = /* @__PURE__ */ __name(class extends ZodType {
1855
+ constructor() {
1856
+ super(...arguments);
1857
+ this._cached = null;
1858
+ this.nonstrict = this.passthrough;
1859
+ this.augment = this.extend;
1860
+ }
1861
+ _getCached() {
1862
+ if (this._cached !== null)
1863
+ return this._cached;
1864
+ const shape = this._def.shape();
1865
+ const keys = util.objectKeys(shape);
1866
+ return this._cached = { shape, keys };
1867
+ }
1868
+ _parse(input) {
1869
+ const parsedType = this._getType(input);
1870
+ if (parsedType !== ZodParsedType.object) {
1871
+ const ctx2 = this._getOrReturnCtx(input);
1872
+ addIssueToContext(ctx2, {
1873
+ code: ZodIssueCode.invalid_type,
1874
+ expected: ZodParsedType.object,
1875
+ received: ctx2.parsedType
1876
+ });
1877
+ return INVALID;
1878
+ }
1879
+ const { status, ctx } = this._processInputParams(input);
1880
+ const { shape, keys: shapeKeys } = this._getCached();
1881
+ const extraKeys = [];
1882
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
1883
+ for (const key in ctx.data) {
1884
+ if (!shapeKeys.includes(key)) {
1885
+ extraKeys.push(key);
1886
+ }
1887
+ }
1888
+ }
1889
+ const pairs = [];
1890
+ for (const key of shapeKeys) {
1891
+ const keyValidator = shape[key];
1892
+ const value = ctx.data[key];
1893
+ pairs.push({
1894
+ key: { status: "valid", value: key },
1895
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
1896
+ alwaysSet: key in ctx.data
1897
+ });
1898
+ }
1899
+ if (this._def.catchall instanceof ZodNever) {
1900
+ const unknownKeys = this._def.unknownKeys;
1901
+ if (unknownKeys === "passthrough") {
1902
+ for (const key of extraKeys) {
1903
+ pairs.push({
1904
+ key: { status: "valid", value: key },
1905
+ value: { status: "valid", value: ctx.data[key] }
1906
+ });
1907
+ }
1908
+ } else if (unknownKeys === "strict") {
1909
+ if (extraKeys.length > 0) {
1910
+ addIssueToContext(ctx, {
1911
+ code: ZodIssueCode.unrecognized_keys,
1912
+ keys: extraKeys
1913
+ });
1914
+ status.dirty();
1915
+ }
1916
+ } else if (unknownKeys === "strip")
1917
+ ;
1918
+ else {
1919
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
1920
+ }
1921
+ } else {
1922
+ const catchall = this._def.catchall;
1923
+ for (const key of extraKeys) {
1924
+ const value = ctx.data[key];
1925
+ pairs.push({
1926
+ key: { status: "valid", value: key },
1927
+ value: catchall._parse(
1928
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
1929
+ ),
1930
+ alwaysSet: key in ctx.data
1931
+ });
1932
+ }
1933
+ }
1934
+ if (ctx.common.async) {
1935
+ return Promise.resolve().then(async () => {
1936
+ const syncPairs = [];
1937
+ for (const pair of pairs) {
1938
+ const key = await pair.key;
1939
+ syncPairs.push({
1940
+ key,
1941
+ value: await pair.value,
1942
+ alwaysSet: pair.alwaysSet
1943
+ });
1944
+ }
1945
+ return syncPairs;
1946
+ }).then((syncPairs) => {
1947
+ return ParseStatus.mergeObjectSync(status, syncPairs);
1948
+ });
1949
+ } else {
1950
+ return ParseStatus.mergeObjectSync(status, pairs);
1951
+ }
1952
+ }
1953
+ get shape() {
1954
+ return this._def.shape();
1955
+ }
1956
+ strict(message) {
1957
+ errorUtil.errToObj;
1958
+ return new ZodObject({
1959
+ ...this._def,
1960
+ unknownKeys: "strict",
1961
+ ...message !== void 0 ? {
1962
+ errorMap: (issue, ctx) => {
1963
+ var _a, _b, _c, _d;
1964
+ const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
1965
+ if (issue.code === "unrecognized_keys")
1966
+ return {
1967
+ message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
1968
+ };
1969
+ return {
1970
+ message: defaultError
1971
+ };
1972
+ }
1973
+ } : {}
1974
+ });
1975
+ }
1976
+ strip() {
1977
+ return new ZodObject({
1978
+ ...this._def,
1979
+ unknownKeys: "strip"
1980
+ });
1981
+ }
1982
+ passthrough() {
1983
+ return new ZodObject({
1984
+ ...this._def,
1985
+ unknownKeys: "passthrough"
1986
+ });
1987
+ }
1988
+ extend(augmentation) {
1989
+ return new ZodObject({
1990
+ ...this._def,
1991
+ shape: () => ({
1992
+ ...this._def.shape(),
1993
+ ...augmentation
1994
+ })
1995
+ });
1996
+ }
1997
+ merge(merging) {
1998
+ const merged = new ZodObject({
1999
+ unknownKeys: merging._def.unknownKeys,
2000
+ catchall: merging._def.catchall,
2001
+ shape: () => objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2002
+ typeName: ZodFirstPartyTypeKind.ZodObject
2003
+ });
2004
+ return merged;
2005
+ }
2006
+ setKey(key, schema) {
2007
+ return this.augment({ [key]: schema });
2008
+ }
2009
+ catchall(index) {
2010
+ return new ZodObject({
2011
+ ...this._def,
2012
+ catchall: index
2013
+ });
2014
+ }
2015
+ pick(mask) {
2016
+ const shape = {};
2017
+ util.objectKeys(mask).forEach((key) => {
2018
+ if (mask[key] && this.shape[key]) {
2019
+ shape[key] = this.shape[key];
2020
+ }
2021
+ });
2022
+ return new ZodObject({
2023
+ ...this._def,
2024
+ shape: () => shape
2025
+ });
2026
+ }
2027
+ omit(mask) {
2028
+ const shape = {};
2029
+ util.objectKeys(this.shape).forEach((key) => {
2030
+ if (!mask[key]) {
2031
+ shape[key] = this.shape[key];
2032
+ }
2033
+ });
2034
+ return new ZodObject({
2035
+ ...this._def,
2036
+ shape: () => shape
2037
+ });
2038
+ }
2039
+ deepPartial() {
2040
+ return deepPartialify(this);
2041
+ }
2042
+ partial(mask) {
2043
+ const newShape = {};
2044
+ util.objectKeys(this.shape).forEach((key) => {
2045
+ const fieldSchema = this.shape[key];
2046
+ if (mask && !mask[key]) {
2047
+ newShape[key] = fieldSchema;
2048
+ } else {
2049
+ newShape[key] = fieldSchema.optional();
2050
+ }
2051
+ });
2052
+ return new ZodObject({
2053
+ ...this._def,
2054
+ shape: () => newShape
2055
+ });
2056
+ }
2057
+ required(mask) {
2058
+ const newShape = {};
2059
+ util.objectKeys(this.shape).forEach((key) => {
2060
+ if (mask && !mask[key]) {
2061
+ newShape[key] = this.shape[key];
2062
+ } else {
2063
+ const fieldSchema = this.shape[key];
2064
+ let newField = fieldSchema;
2065
+ while (newField instanceof ZodOptional) {
2066
+ newField = newField._def.innerType;
2067
+ }
2068
+ newShape[key] = newField;
2069
+ }
2070
+ });
2071
+ return new ZodObject({
2072
+ ...this._def,
2073
+ shape: () => newShape
2074
+ });
2075
+ }
2076
+ keyof() {
2077
+ return createZodEnum(util.objectKeys(this.shape));
2078
+ }
2079
+ }, "ZodObject");
2080
+ __name2(ZodObject, "ZodObject");
2081
+ ZodObject.create = (shape, params) => {
2082
+ return new ZodObject({
2083
+ shape: () => shape,
2084
+ unknownKeys: "strip",
2085
+ catchall: ZodNever.create(),
2086
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2087
+ ...processCreateParams(params)
2088
+ });
2089
+ };
2090
+ ZodObject.strictCreate = (shape, params) => {
2091
+ return new ZodObject({
2092
+ shape: () => shape,
2093
+ unknownKeys: "strict",
2094
+ catchall: ZodNever.create(),
2095
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2096
+ ...processCreateParams(params)
2097
+ });
2098
+ };
2099
+ ZodObject.lazycreate = (shape, params) => {
2100
+ return new ZodObject({
2101
+ shape,
2102
+ unknownKeys: "strip",
2103
+ catchall: ZodNever.create(),
2104
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2105
+ ...processCreateParams(params)
2106
+ });
2107
+ };
2108
+ var ZodUnion = /* @__PURE__ */ __name(class extends ZodType {
2109
+ _parse(input) {
2110
+ const { ctx } = this._processInputParams(input);
2111
+ const options = this._def.options;
2112
+ function handleResults(results) {
2113
+ for (const result of results) {
2114
+ if (result.result.status === "valid") {
2115
+ return result.result;
2116
+ }
2117
+ }
2118
+ for (const result of results) {
2119
+ if (result.result.status === "dirty") {
2120
+ ctx.common.issues.push(...result.ctx.common.issues);
2121
+ return result.result;
2122
+ }
2123
+ }
2124
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2125
+ addIssueToContext(ctx, {
2126
+ code: ZodIssueCode.invalid_union,
2127
+ unionErrors
2128
+ });
2129
+ return INVALID;
2130
+ }
2131
+ __name(handleResults, "handleResults");
2132
+ __name2(handleResults, "handleResults");
2133
+ if (ctx.common.async) {
2134
+ return Promise.all(options.map(async (option) => {
2135
+ const childCtx = {
2136
+ ...ctx,
2137
+ common: {
2138
+ ...ctx.common,
2139
+ issues: []
2140
+ },
2141
+ parent: null
2142
+ };
2143
+ return {
2144
+ result: await option._parseAsync({
2145
+ data: ctx.data,
2146
+ path: ctx.path,
2147
+ parent: childCtx
2148
+ }),
2149
+ ctx: childCtx
2150
+ };
2151
+ })).then(handleResults);
2152
+ } else {
2153
+ let dirty = void 0;
2154
+ const issues = [];
2155
+ for (const option of options) {
2156
+ const childCtx = {
2157
+ ...ctx,
2158
+ common: {
2159
+ ...ctx.common,
2160
+ issues: []
2161
+ },
2162
+ parent: null
2163
+ };
2164
+ const result = option._parseSync({
2165
+ data: ctx.data,
2166
+ path: ctx.path,
2167
+ parent: childCtx
2168
+ });
2169
+ if (result.status === "valid") {
2170
+ return result;
2171
+ } else if (result.status === "dirty" && !dirty) {
2172
+ dirty = { result, ctx: childCtx };
2173
+ }
2174
+ if (childCtx.common.issues.length) {
2175
+ issues.push(childCtx.common.issues);
2176
+ }
2177
+ }
2178
+ if (dirty) {
2179
+ ctx.common.issues.push(...dirty.ctx.common.issues);
2180
+ return dirty.result;
2181
+ }
2182
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
2183
+ addIssueToContext(ctx, {
2184
+ code: ZodIssueCode.invalid_union,
2185
+ unionErrors
2186
+ });
2187
+ return INVALID;
2188
+ }
2189
+ }
2190
+ get options() {
2191
+ return this._def.options;
2192
+ }
2193
+ }, "ZodUnion");
2194
+ __name2(ZodUnion, "ZodUnion");
2195
+ ZodUnion.create = (types, params) => {
2196
+ return new ZodUnion({
2197
+ options: types,
2198
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
2199
+ ...processCreateParams(params)
2200
+ });
2201
+ };
2202
+ var getDiscriminator = /* @__PURE__ */ __name2((type) => {
2203
+ if (type instanceof ZodLazy) {
2204
+ return getDiscriminator(type.schema);
2205
+ } else if (type instanceof ZodEffects) {
2206
+ return getDiscriminator(type.innerType());
2207
+ } else if (type instanceof ZodLiteral) {
2208
+ return [type.value];
2209
+ } else if (type instanceof ZodEnum) {
2210
+ return type.options;
2211
+ } else if (type instanceof ZodNativeEnum) {
2212
+ return Object.keys(type.enum);
2213
+ } else if (type instanceof ZodDefault) {
2214
+ return getDiscriminator(type._def.innerType);
2215
+ } else if (type instanceof ZodUndefined) {
2216
+ return [void 0];
2217
+ } else if (type instanceof ZodNull) {
2218
+ return [null];
2219
+ } else {
2220
+ return null;
2221
+ }
2222
+ }, "getDiscriminator");
2223
+ var ZodDiscriminatedUnion = /* @__PURE__ */ __name(class extends ZodType {
2224
+ _parse(input) {
2225
+ const { ctx } = this._processInputParams(input);
2226
+ if (ctx.parsedType !== ZodParsedType.object) {
2227
+ addIssueToContext(ctx, {
2228
+ code: ZodIssueCode.invalid_type,
2229
+ expected: ZodParsedType.object,
2230
+ received: ctx.parsedType
2231
+ });
2232
+ return INVALID;
2233
+ }
2234
+ const discriminator = this.discriminator;
2235
+ const discriminatorValue = ctx.data[discriminator];
2236
+ const option = this.optionsMap.get(discriminatorValue);
2237
+ if (!option) {
2238
+ addIssueToContext(ctx, {
2239
+ code: ZodIssueCode.invalid_union_discriminator,
2240
+ options: Array.from(this.optionsMap.keys()),
2241
+ path: [discriminator]
2242
+ });
2243
+ return INVALID;
2244
+ }
2245
+ if (ctx.common.async) {
2246
+ return option._parseAsync({
2247
+ data: ctx.data,
2248
+ path: ctx.path,
2249
+ parent: ctx
2250
+ });
2251
+ } else {
2252
+ return option._parseSync({
2253
+ data: ctx.data,
2254
+ path: ctx.path,
2255
+ parent: ctx
2256
+ });
2257
+ }
2258
+ }
2259
+ get discriminator() {
2260
+ return this._def.discriminator;
2261
+ }
2262
+ get options() {
2263
+ return this._def.options;
2264
+ }
2265
+ get optionsMap() {
2266
+ return this._def.optionsMap;
2267
+ }
2268
+ static create(discriminator, options, params) {
2269
+ const optionsMap = /* @__PURE__ */ new Map();
2270
+ for (const type of options) {
2271
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2272
+ if (!discriminatorValues) {
2273
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2274
+ }
2275
+ for (const value of discriminatorValues) {
2276
+ if (optionsMap.has(value)) {
2277
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2278
+ }
2279
+ optionsMap.set(value, type);
2280
+ }
2281
+ }
2282
+ return new ZodDiscriminatedUnion({
2283
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2284
+ discriminator,
2285
+ options,
2286
+ optionsMap,
2287
+ ...processCreateParams(params)
2288
+ });
2289
+ }
2290
+ }, "ZodDiscriminatedUnion");
2291
+ __name2(ZodDiscriminatedUnion, "ZodDiscriminatedUnion");
2292
+ function mergeValues(a, b) {
2293
+ const aType = getParsedType(a);
2294
+ const bType = getParsedType(b);
2295
+ if (a === b) {
2296
+ return { valid: true, data: a };
2297
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2298
+ const bKeys = util.objectKeys(b);
2299
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2300
+ const newObj = { ...a, ...b };
2301
+ for (const key of sharedKeys) {
2302
+ const sharedValue = mergeValues(a[key], b[key]);
2303
+ if (!sharedValue.valid) {
2304
+ return { valid: false };
2305
+ }
2306
+ newObj[key] = sharedValue.data;
2307
+ }
2308
+ return { valid: true, data: newObj };
2309
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2310
+ if (a.length !== b.length) {
2311
+ return { valid: false };
2312
+ }
2313
+ const newArray = [];
2314
+ for (let index = 0; index < a.length; index++) {
2315
+ const itemA = a[index];
2316
+ const itemB = b[index];
2317
+ const sharedValue = mergeValues(itemA, itemB);
2318
+ if (!sharedValue.valid) {
2319
+ return { valid: false };
2320
+ }
2321
+ newArray.push(sharedValue.data);
2322
+ }
2323
+ return { valid: true, data: newArray };
2324
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
2325
+ return { valid: true, data: a };
2326
+ } else {
2327
+ return { valid: false };
2328
+ }
2329
+ }
2330
+ __name(mergeValues, "mergeValues");
2331
+ __name2(mergeValues, "mergeValues");
2332
+ var ZodIntersection = /* @__PURE__ */ __name(class extends ZodType {
2333
+ _parse(input) {
2334
+ const { status, ctx } = this._processInputParams(input);
2335
+ const handleParsed = /* @__PURE__ */ __name2((parsedLeft, parsedRight) => {
2336
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
2337
+ return INVALID;
2338
+ }
2339
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
2340
+ if (!merged.valid) {
2341
+ addIssueToContext(ctx, {
2342
+ code: ZodIssueCode.invalid_intersection_types
2343
+ });
2344
+ return INVALID;
2345
+ }
2346
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
2347
+ status.dirty();
2348
+ }
2349
+ return { status: status.value, value: merged.data };
2350
+ }, "handleParsed");
2351
+ if (ctx.common.async) {
2352
+ return Promise.all([
2353
+ this._def.left._parseAsync({
2354
+ data: ctx.data,
2355
+ path: ctx.path,
2356
+ parent: ctx
2357
+ }),
2358
+ this._def.right._parseAsync({
2359
+ data: ctx.data,
2360
+ path: ctx.path,
2361
+ parent: ctx
2362
+ })
2363
+ ]).then(([left, right]) => handleParsed(left, right));
2364
+ } else {
2365
+ return handleParsed(this._def.left._parseSync({
2366
+ data: ctx.data,
2367
+ path: ctx.path,
2368
+ parent: ctx
2369
+ }), this._def.right._parseSync({
2370
+ data: ctx.data,
2371
+ path: ctx.path,
2372
+ parent: ctx
2373
+ }));
2374
+ }
2375
+ }
2376
+ }, "ZodIntersection");
2377
+ __name2(ZodIntersection, "ZodIntersection");
2378
+ ZodIntersection.create = (left, right, params) => {
2379
+ return new ZodIntersection({
2380
+ left,
2381
+ right,
2382
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
2383
+ ...processCreateParams(params)
2384
+ });
2385
+ };
2386
+ var ZodTuple = /* @__PURE__ */ __name(class extends ZodType {
2387
+ _parse(input) {
2388
+ const { status, ctx } = this._processInputParams(input);
2389
+ if (ctx.parsedType !== ZodParsedType.array) {
2390
+ addIssueToContext(ctx, {
2391
+ code: ZodIssueCode.invalid_type,
2392
+ expected: ZodParsedType.array,
2393
+ received: ctx.parsedType
2394
+ });
2395
+ return INVALID;
2396
+ }
2397
+ if (ctx.data.length < this._def.items.length) {
2398
+ addIssueToContext(ctx, {
2399
+ code: ZodIssueCode.too_small,
2400
+ minimum: this._def.items.length,
2401
+ inclusive: true,
2402
+ exact: false,
2403
+ type: "array"
2404
+ });
2405
+ return INVALID;
2406
+ }
2407
+ const rest = this._def.rest;
2408
+ if (!rest && ctx.data.length > this._def.items.length) {
2409
+ addIssueToContext(ctx, {
2410
+ code: ZodIssueCode.too_big,
2411
+ maximum: this._def.items.length,
2412
+ inclusive: true,
2413
+ exact: false,
2414
+ type: "array"
2415
+ });
2416
+ status.dirty();
2417
+ }
2418
+ const items = [...ctx.data].map((item, itemIndex) => {
2419
+ const schema = this._def.items[itemIndex] || this._def.rest;
2420
+ if (!schema)
2421
+ return null;
2422
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
2423
+ }).filter((x) => !!x);
2424
+ if (ctx.common.async) {
2425
+ return Promise.all(items).then((results) => {
2426
+ return ParseStatus.mergeArray(status, results);
2427
+ });
2428
+ } else {
2429
+ return ParseStatus.mergeArray(status, items);
2430
+ }
2431
+ }
2432
+ get items() {
2433
+ return this._def.items;
2434
+ }
2435
+ rest(rest) {
2436
+ return new ZodTuple({
2437
+ ...this._def,
2438
+ rest
2439
+ });
2440
+ }
2441
+ }, "ZodTuple");
2442
+ __name2(ZodTuple, "ZodTuple");
2443
+ ZodTuple.create = (schemas, params) => {
2444
+ if (!Array.isArray(schemas)) {
2445
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2446
+ }
2447
+ return new ZodTuple({
2448
+ items: schemas,
2449
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
2450
+ rest: null,
2451
+ ...processCreateParams(params)
2452
+ });
2453
+ };
2454
+ var ZodRecord = /* @__PURE__ */ __name(class extends ZodType {
2455
+ get keySchema() {
2456
+ return this._def.keyType;
2457
+ }
2458
+ get valueSchema() {
2459
+ return this._def.valueType;
2460
+ }
2461
+ _parse(input) {
2462
+ const { status, ctx } = this._processInputParams(input);
2463
+ if (ctx.parsedType !== ZodParsedType.object) {
2464
+ addIssueToContext(ctx, {
2465
+ code: ZodIssueCode.invalid_type,
2466
+ expected: ZodParsedType.object,
2467
+ received: ctx.parsedType
2468
+ });
2469
+ return INVALID;
2470
+ }
2471
+ const pairs = [];
2472
+ const keyType = this._def.keyType;
2473
+ const valueType = this._def.valueType;
2474
+ for (const key in ctx.data) {
2475
+ pairs.push({
2476
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2477
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
2478
+ });
2479
+ }
2480
+ if (ctx.common.async) {
2481
+ return ParseStatus.mergeObjectAsync(status, pairs);
2482
+ } else {
2483
+ return ParseStatus.mergeObjectSync(status, pairs);
2484
+ }
2485
+ }
2486
+ get element() {
2487
+ return this._def.valueType;
2488
+ }
2489
+ static create(first, second, third) {
2490
+ if (second instanceof ZodType) {
2491
+ return new ZodRecord({
2492
+ keyType: first,
2493
+ valueType: second,
2494
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
2495
+ ...processCreateParams(third)
2496
+ });
2497
+ }
2498
+ return new ZodRecord({
2499
+ keyType: ZodString.create(),
2500
+ valueType: first,
2501
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
2502
+ ...processCreateParams(second)
2503
+ });
2504
+ }
2505
+ }, "ZodRecord");
2506
+ __name2(ZodRecord, "ZodRecord");
2507
+ var ZodMap = /* @__PURE__ */ __name(class extends ZodType {
2508
+ _parse(input) {
2509
+ const { status, ctx } = this._processInputParams(input);
2510
+ if (ctx.parsedType !== ZodParsedType.map) {
2511
+ addIssueToContext(ctx, {
2512
+ code: ZodIssueCode.invalid_type,
2513
+ expected: ZodParsedType.map,
2514
+ received: ctx.parsedType
2515
+ });
2516
+ return INVALID;
2517
+ }
2518
+ const keyType = this._def.keyType;
2519
+ const valueType = this._def.valueType;
2520
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
2521
+ return {
2522
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
2523
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
2524
+ };
2525
+ });
2526
+ if (ctx.common.async) {
2527
+ const finalMap = /* @__PURE__ */ new Map();
2528
+ return Promise.resolve().then(async () => {
2529
+ for (const pair of pairs) {
2530
+ const key = await pair.key;
2531
+ const value = await pair.value;
2532
+ if (key.status === "aborted" || value.status === "aborted") {
2533
+ return INVALID;
2534
+ }
2535
+ if (key.status === "dirty" || value.status === "dirty") {
2536
+ status.dirty();
2537
+ }
2538
+ finalMap.set(key.value, value.value);
2539
+ }
2540
+ return { status: status.value, value: finalMap };
2541
+ });
2542
+ } else {
2543
+ const finalMap = /* @__PURE__ */ new Map();
2544
+ for (const pair of pairs) {
2545
+ const key = pair.key;
2546
+ const value = pair.value;
2547
+ if (key.status === "aborted" || value.status === "aborted") {
2548
+ return INVALID;
2549
+ }
2550
+ if (key.status === "dirty" || value.status === "dirty") {
2551
+ status.dirty();
2552
+ }
2553
+ finalMap.set(key.value, value.value);
2554
+ }
2555
+ return { status: status.value, value: finalMap };
2556
+ }
2557
+ }
2558
+ }, "ZodMap");
2559
+ __name2(ZodMap, "ZodMap");
2560
+ ZodMap.create = (keyType, valueType, params) => {
2561
+ return new ZodMap({
2562
+ valueType,
2563
+ keyType,
2564
+ typeName: ZodFirstPartyTypeKind.ZodMap,
2565
+ ...processCreateParams(params)
2566
+ });
2567
+ };
2568
+ var ZodSet = /* @__PURE__ */ __name(class extends ZodType {
2569
+ _parse(input) {
2570
+ const { status, ctx } = this._processInputParams(input);
2571
+ if (ctx.parsedType !== ZodParsedType.set) {
2572
+ addIssueToContext(ctx, {
2573
+ code: ZodIssueCode.invalid_type,
2574
+ expected: ZodParsedType.set,
2575
+ received: ctx.parsedType
2576
+ });
2577
+ return INVALID;
2578
+ }
2579
+ const def = this._def;
2580
+ if (def.minSize !== null) {
2581
+ if (ctx.data.size < def.minSize.value) {
2582
+ addIssueToContext(ctx, {
2583
+ code: ZodIssueCode.too_small,
2584
+ minimum: def.minSize.value,
2585
+ type: "set",
2586
+ inclusive: true,
2587
+ exact: false,
2588
+ message: def.minSize.message
2589
+ });
2590
+ status.dirty();
2591
+ }
2592
+ }
2593
+ if (def.maxSize !== null) {
2594
+ if (ctx.data.size > def.maxSize.value) {
2595
+ addIssueToContext(ctx, {
2596
+ code: ZodIssueCode.too_big,
2597
+ maximum: def.maxSize.value,
2598
+ type: "set",
2599
+ inclusive: true,
2600
+ exact: false,
2601
+ message: def.maxSize.message
2602
+ });
2603
+ status.dirty();
2604
+ }
2605
+ }
2606
+ const valueType = this._def.valueType;
2607
+ function finalizeSet(elements2) {
2608
+ const parsedSet = /* @__PURE__ */ new Set();
2609
+ for (const element of elements2) {
2610
+ if (element.status === "aborted")
2611
+ return INVALID;
2612
+ if (element.status === "dirty")
2613
+ status.dirty();
2614
+ parsedSet.add(element.value);
2615
+ }
2616
+ return { status: status.value, value: parsedSet };
2617
+ }
2618
+ __name(finalizeSet, "finalizeSet");
2619
+ __name2(finalizeSet, "finalizeSet");
2620
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
2621
+ if (ctx.common.async) {
2622
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
2623
+ } else {
2624
+ return finalizeSet(elements);
2625
+ }
2626
+ }
2627
+ min(minSize, message) {
2628
+ return new ZodSet({
2629
+ ...this._def,
2630
+ minSize: { value: minSize, message: errorUtil.toString(message) }
2631
+ });
2632
+ }
2633
+ max(maxSize, message) {
2634
+ return new ZodSet({
2635
+ ...this._def,
2636
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
2637
+ });
2638
+ }
2639
+ size(size, message) {
2640
+ return this.min(size, message).max(size, message);
2641
+ }
2642
+ nonempty(message) {
2643
+ return this.min(1, message);
2644
+ }
2645
+ }, "ZodSet");
2646
+ __name2(ZodSet, "ZodSet");
2647
+ ZodSet.create = (valueType, params) => {
2648
+ return new ZodSet({
2649
+ valueType,
2650
+ minSize: null,
2651
+ maxSize: null,
2652
+ typeName: ZodFirstPartyTypeKind.ZodSet,
2653
+ ...processCreateParams(params)
2654
+ });
2655
+ };
2656
+ var ZodFunction = /* @__PURE__ */ __name(class extends ZodType {
2657
+ constructor() {
2658
+ super(...arguments);
2659
+ this.validate = this.implement;
2660
+ }
2661
+ _parse(input) {
2662
+ const { ctx } = this._processInputParams(input);
2663
+ if (ctx.parsedType !== ZodParsedType.function) {
2664
+ addIssueToContext(ctx, {
2665
+ code: ZodIssueCode.invalid_type,
2666
+ expected: ZodParsedType.function,
2667
+ received: ctx.parsedType
2668
+ });
2669
+ return INVALID;
2670
+ }
2671
+ function makeArgsIssue(args, error) {
2672
+ return makeIssue({
2673
+ data: args,
2674
+ path: ctx.path,
2675
+ errorMaps: [
2676
+ ctx.common.contextualErrorMap,
2677
+ ctx.schemaErrorMap,
2678
+ getErrorMap(),
2679
+ errorMap
2680
+ ].filter((x) => !!x),
2681
+ issueData: {
2682
+ code: ZodIssueCode.invalid_arguments,
2683
+ argumentsError: error
2684
+ }
2685
+ });
2686
+ }
2687
+ __name(makeArgsIssue, "makeArgsIssue");
2688
+ __name2(makeArgsIssue, "makeArgsIssue");
2689
+ function makeReturnsIssue(returns, error) {
2690
+ return makeIssue({
2691
+ data: returns,
2692
+ path: ctx.path,
2693
+ errorMaps: [
2694
+ ctx.common.contextualErrorMap,
2695
+ ctx.schemaErrorMap,
2696
+ getErrorMap(),
2697
+ errorMap
2698
+ ].filter((x) => !!x),
2699
+ issueData: {
2700
+ code: ZodIssueCode.invalid_return_type,
2701
+ returnTypeError: error
2702
+ }
2703
+ });
2704
+ }
2705
+ __name(makeReturnsIssue, "makeReturnsIssue");
2706
+ __name2(makeReturnsIssue, "makeReturnsIssue");
2707
+ const params = { errorMap: ctx.common.contextualErrorMap };
2708
+ const fn = ctx.data;
2709
+ if (this._def.returns instanceof ZodPromise) {
2710
+ return OK(async (...args) => {
2711
+ const error = new ZodError([]);
2712
+ const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
2713
+ error.addIssue(makeArgsIssue(args, e));
2714
+ throw error;
2715
+ });
2716
+ const result = await fn(...parsedArgs);
2717
+ const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => {
2718
+ error.addIssue(makeReturnsIssue(result, e));
2719
+ throw error;
2720
+ });
2721
+ return parsedReturns;
2722
+ });
2723
+ } else {
2724
+ return OK((...args) => {
2725
+ const parsedArgs = this._def.args.safeParse(args, params);
2726
+ if (!parsedArgs.success) {
2727
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
2728
+ }
2729
+ const result = fn(...parsedArgs.data);
2730
+ const parsedReturns = this._def.returns.safeParse(result, params);
2731
+ if (!parsedReturns.success) {
2732
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
2733
+ }
2734
+ return parsedReturns.data;
2735
+ });
2736
+ }
2737
+ }
2738
+ parameters() {
2739
+ return this._def.args;
2740
+ }
2741
+ returnType() {
2742
+ return this._def.returns;
2743
+ }
2744
+ args(...items) {
2745
+ return new ZodFunction({
2746
+ ...this._def,
2747
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
2748
+ });
2749
+ }
2750
+ returns(returnType) {
2751
+ return new ZodFunction({
2752
+ ...this._def,
2753
+ returns: returnType
2754
+ });
2755
+ }
2756
+ implement(func) {
2757
+ const validatedFunc = this.parse(func);
2758
+ return validatedFunc;
2759
+ }
2760
+ strictImplement(func) {
2761
+ const validatedFunc = this.parse(func);
2762
+ return validatedFunc;
2763
+ }
2764
+ static create(args, returns, params) {
2765
+ return new ZodFunction({
2766
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
2767
+ returns: returns || ZodUnknown.create(),
2768
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
2769
+ ...processCreateParams(params)
2770
+ });
2771
+ }
2772
+ }, "ZodFunction");
2773
+ __name2(ZodFunction, "ZodFunction");
2774
+ var ZodLazy = /* @__PURE__ */ __name(class extends ZodType {
2775
+ get schema() {
2776
+ return this._def.getter();
2777
+ }
2778
+ _parse(input) {
2779
+ const { ctx } = this._processInputParams(input);
2780
+ const lazySchema = this._def.getter();
2781
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
2782
+ }
2783
+ }, "ZodLazy");
2784
+ __name2(ZodLazy, "ZodLazy");
2785
+ ZodLazy.create = (getter, params) => {
2786
+ return new ZodLazy({
2787
+ getter,
2788
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
2789
+ ...processCreateParams(params)
2790
+ });
2791
+ };
2792
+ var ZodLiteral = /* @__PURE__ */ __name(class extends ZodType {
2793
+ _parse(input) {
2794
+ if (input.data !== this._def.value) {
2795
+ const ctx = this._getOrReturnCtx(input);
2796
+ addIssueToContext(ctx, {
2797
+ received: ctx.data,
2798
+ code: ZodIssueCode.invalid_literal,
2799
+ expected: this._def.value
2800
+ });
2801
+ return INVALID;
2802
+ }
2803
+ return { status: "valid", value: input.data };
2804
+ }
2805
+ get value() {
2806
+ return this._def.value;
2807
+ }
2808
+ }, "ZodLiteral");
2809
+ __name2(ZodLiteral, "ZodLiteral");
2810
+ ZodLiteral.create = (value, params) => {
2811
+ return new ZodLiteral({
2812
+ value,
2813
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
2814
+ ...processCreateParams(params)
2815
+ });
2816
+ };
2817
+ function createZodEnum(values, params) {
2818
+ return new ZodEnum({
2819
+ values,
2820
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
2821
+ ...processCreateParams(params)
2822
+ });
2823
+ }
2824
+ __name(createZodEnum, "createZodEnum");
2825
+ __name2(createZodEnum, "createZodEnum");
2826
+ var ZodEnum = /* @__PURE__ */ __name(class extends ZodType {
2827
+ _parse(input) {
2828
+ if (typeof input.data !== "string") {
2829
+ const ctx = this._getOrReturnCtx(input);
2830
+ const expectedValues = this._def.values;
2831
+ addIssueToContext(ctx, {
2832
+ expected: util.joinValues(expectedValues),
2833
+ received: ctx.parsedType,
2834
+ code: ZodIssueCode.invalid_type
2835
+ });
2836
+ return INVALID;
2837
+ }
2838
+ if (this._def.values.indexOf(input.data) === -1) {
2839
+ const ctx = this._getOrReturnCtx(input);
2840
+ const expectedValues = this._def.values;
2841
+ addIssueToContext(ctx, {
2842
+ received: ctx.data,
2843
+ code: ZodIssueCode.invalid_enum_value,
2844
+ options: expectedValues
2845
+ });
2846
+ return INVALID;
2847
+ }
2848
+ return OK(input.data);
2849
+ }
2850
+ get options() {
2851
+ return this._def.values;
2852
+ }
2853
+ get enum() {
2854
+ const enumValues = {};
2855
+ for (const val of this._def.values) {
2856
+ enumValues[val] = val;
2857
+ }
2858
+ return enumValues;
2859
+ }
2860
+ get Values() {
2861
+ const enumValues = {};
2862
+ for (const val of this._def.values) {
2863
+ enumValues[val] = val;
2864
+ }
2865
+ return enumValues;
2866
+ }
2867
+ get Enum() {
2868
+ const enumValues = {};
2869
+ for (const val of this._def.values) {
2870
+ enumValues[val] = val;
2871
+ }
2872
+ return enumValues;
2873
+ }
2874
+ extract(values) {
2875
+ return ZodEnum.create(values);
2876
+ }
2877
+ exclude(values) {
2878
+ return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
2879
+ }
2880
+ }, "ZodEnum");
2881
+ __name2(ZodEnum, "ZodEnum");
2882
+ ZodEnum.create = createZodEnum;
2883
+ var ZodNativeEnum = /* @__PURE__ */ __name(class extends ZodType {
2884
+ _parse(input) {
2885
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
2886
+ const ctx = this._getOrReturnCtx(input);
2887
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
2888
+ const expectedValues = util.objectValues(nativeEnumValues);
2889
+ addIssueToContext(ctx, {
2890
+ expected: util.joinValues(expectedValues),
2891
+ received: ctx.parsedType,
2892
+ code: ZodIssueCode.invalid_type
2893
+ });
2894
+ return INVALID;
2895
+ }
2896
+ if (nativeEnumValues.indexOf(input.data) === -1) {
2897
+ const expectedValues = util.objectValues(nativeEnumValues);
2898
+ addIssueToContext(ctx, {
2899
+ received: ctx.data,
2900
+ code: ZodIssueCode.invalid_enum_value,
2901
+ options: expectedValues
2902
+ });
2903
+ return INVALID;
2904
+ }
2905
+ return OK(input.data);
2906
+ }
2907
+ get enum() {
2908
+ return this._def.values;
2909
+ }
2910
+ }, "ZodNativeEnum");
2911
+ __name2(ZodNativeEnum, "ZodNativeEnum");
2912
+ ZodNativeEnum.create = (values, params) => {
2913
+ return new ZodNativeEnum({
2914
+ values,
2915
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
2916
+ ...processCreateParams(params)
2917
+ });
2918
+ };
2919
+ var ZodPromise = /* @__PURE__ */ __name(class extends ZodType {
2920
+ unwrap() {
2921
+ return this._def.type;
2922
+ }
2923
+ _parse(input) {
2924
+ const { ctx } = this._processInputParams(input);
2925
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
2926
+ addIssueToContext(ctx, {
2927
+ code: ZodIssueCode.invalid_type,
2928
+ expected: ZodParsedType.promise,
2929
+ received: ctx.parsedType
2930
+ });
2931
+ return INVALID;
2932
+ }
2933
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
2934
+ return OK(promisified.then((data) => {
2935
+ return this._def.type.parseAsync(data, {
2936
+ path: ctx.path,
2937
+ errorMap: ctx.common.contextualErrorMap
2938
+ });
2939
+ }));
2940
+ }
2941
+ }, "ZodPromise");
2942
+ __name2(ZodPromise, "ZodPromise");
2943
+ ZodPromise.create = (schema, params) => {
2944
+ return new ZodPromise({
2945
+ type: schema,
2946
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
2947
+ ...processCreateParams(params)
2948
+ });
2949
+ };
2950
+ var ZodEffects = /* @__PURE__ */ __name(class extends ZodType {
2951
+ innerType() {
2952
+ return this._def.schema;
2953
+ }
2954
+ sourceType() {
2955
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2956
+ }
2957
+ _parse(input) {
2958
+ const { status, ctx } = this._processInputParams(input);
2959
+ const effect = this._def.effect || null;
2960
+ if (effect.type === "preprocess") {
2961
+ const processed = effect.transform(ctx.data);
2962
+ if (ctx.common.async) {
2963
+ return Promise.resolve(processed).then((processed2) => {
2964
+ return this._def.schema._parseAsync({
2965
+ data: processed2,
2966
+ path: ctx.path,
2967
+ parent: ctx
2968
+ });
2969
+ });
2970
+ } else {
2971
+ return this._def.schema._parseSync({
2972
+ data: processed,
2973
+ path: ctx.path,
2974
+ parent: ctx
2975
+ });
2976
+ }
2977
+ }
2978
+ const checkCtx = {
2979
+ addIssue: (arg) => {
2980
+ addIssueToContext(ctx, arg);
2981
+ if (arg.fatal) {
2982
+ status.abort();
2983
+ } else {
2984
+ status.dirty();
2985
+ }
2986
+ },
2987
+ get path() {
2988
+ return ctx.path;
2989
+ }
2990
+ };
2991
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
2992
+ if (effect.type === "refinement") {
2993
+ const executeRefinement = /* @__PURE__ */ __name2((acc) => {
2994
+ const result = effect.refinement(acc, checkCtx);
2995
+ if (ctx.common.async) {
2996
+ return Promise.resolve(result);
2997
+ }
2998
+ if (result instanceof Promise) {
2999
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3000
+ }
3001
+ return acc;
3002
+ }, "executeRefinement");
3003
+ if (ctx.common.async === false) {
3004
+ const inner = this._def.schema._parseSync({
3005
+ data: ctx.data,
3006
+ path: ctx.path,
3007
+ parent: ctx
3008
+ });
3009
+ if (inner.status === "aborted")
3010
+ return INVALID;
3011
+ if (inner.status === "dirty")
3012
+ status.dirty();
3013
+ executeRefinement(inner.value);
3014
+ return { status: status.value, value: inner.value };
3015
+ } else {
3016
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3017
+ if (inner.status === "aborted")
3018
+ return INVALID;
3019
+ if (inner.status === "dirty")
3020
+ status.dirty();
3021
+ return executeRefinement(inner.value).then(() => {
3022
+ return { status: status.value, value: inner.value };
3023
+ });
3024
+ });
3025
+ }
3026
+ }
3027
+ if (effect.type === "transform") {
3028
+ if (ctx.common.async === false) {
3029
+ const base = this._def.schema._parseSync({
3030
+ data: ctx.data,
3031
+ path: ctx.path,
3032
+ parent: ctx
3033
+ });
3034
+ if (!isValid(base))
3035
+ return base;
3036
+ const result = effect.transform(base.value, checkCtx);
3037
+ if (result instanceof Promise) {
3038
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3039
+ }
3040
+ return { status: status.value, value: result };
3041
+ } else {
3042
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3043
+ if (!isValid(base))
3044
+ return base;
3045
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
3046
+ });
3047
+ }
3048
+ }
3049
+ util.assertNever(effect);
3050
+ }
3051
+ }, "ZodEffects");
3052
+ __name2(ZodEffects, "ZodEffects");
3053
+ ZodEffects.create = (schema, effect, params) => {
3054
+ return new ZodEffects({
3055
+ schema,
3056
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3057
+ effect,
3058
+ ...processCreateParams(params)
3059
+ });
3060
+ };
3061
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3062
+ return new ZodEffects({
3063
+ schema,
3064
+ effect: { type: "preprocess", transform: preprocess },
3065
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3066
+ ...processCreateParams(params)
3067
+ });
3068
+ };
3069
+ var ZodOptional = /* @__PURE__ */ __name(class extends ZodType {
3070
+ _parse(input) {
3071
+ const parsedType = this._getType(input);
3072
+ if (parsedType === ZodParsedType.undefined) {
3073
+ return OK(void 0);
3074
+ }
3075
+ return this._def.innerType._parse(input);
3076
+ }
3077
+ unwrap() {
3078
+ return this._def.innerType;
3079
+ }
3080
+ }, "ZodOptional");
3081
+ __name2(ZodOptional, "ZodOptional");
3082
+ ZodOptional.create = (type, params) => {
3083
+ return new ZodOptional({
3084
+ innerType: type,
3085
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
3086
+ ...processCreateParams(params)
3087
+ });
3088
+ };
3089
+ var ZodNullable = /* @__PURE__ */ __name(class extends ZodType {
3090
+ _parse(input) {
3091
+ const parsedType = this._getType(input);
3092
+ if (parsedType === ZodParsedType.null) {
3093
+ return OK(null);
3094
+ }
3095
+ return this._def.innerType._parse(input);
3096
+ }
3097
+ unwrap() {
3098
+ return this._def.innerType;
3099
+ }
3100
+ }, "ZodNullable");
3101
+ __name2(ZodNullable, "ZodNullable");
3102
+ ZodNullable.create = (type, params) => {
3103
+ return new ZodNullable({
3104
+ innerType: type,
3105
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
3106
+ ...processCreateParams(params)
3107
+ });
3108
+ };
3109
+ var ZodDefault = /* @__PURE__ */ __name(class extends ZodType {
3110
+ _parse(input) {
3111
+ const { ctx } = this._processInputParams(input);
3112
+ let data = ctx.data;
3113
+ if (ctx.parsedType === ZodParsedType.undefined) {
3114
+ data = this._def.defaultValue();
3115
+ }
3116
+ return this._def.innerType._parse({
3117
+ data,
3118
+ path: ctx.path,
3119
+ parent: ctx
3120
+ });
3121
+ }
3122
+ removeDefault() {
3123
+ return this._def.innerType;
3124
+ }
3125
+ }, "ZodDefault");
3126
+ __name2(ZodDefault, "ZodDefault");
3127
+ ZodDefault.create = (type, params) => {
3128
+ return new ZodDefault({
3129
+ innerType: type,
3130
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3131
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3132
+ ...processCreateParams(params)
3133
+ });
3134
+ };
3135
+ var ZodCatch = /* @__PURE__ */ __name(class extends ZodType {
3136
+ _parse(input) {
3137
+ const { ctx } = this._processInputParams(input);
3138
+ const result = this._def.innerType._parse({
3139
+ data: ctx.data,
3140
+ path: ctx.path,
3141
+ parent: {
3142
+ ...ctx,
3143
+ common: {
3144
+ ...ctx.common,
3145
+ issues: []
3146
+ }
3147
+ }
3148
+ });
3149
+ if (isAsync(result)) {
3150
+ return result.then((result2) => {
3151
+ return {
3152
+ status: "valid",
3153
+ value: result2.status === "valid" ? result2.value : this._def.catchValue()
3154
+ };
3155
+ });
3156
+ } else {
3157
+ return {
3158
+ status: "valid",
3159
+ value: result.status === "valid" ? result.value : this._def.catchValue()
3160
+ };
3161
+ }
3162
+ }
3163
+ removeCatch() {
3164
+ return this._def.innerType;
3165
+ }
3166
+ }, "ZodCatch");
3167
+ __name2(ZodCatch, "ZodCatch");
3168
+ ZodCatch.create = (type, params) => {
3169
+ return new ZodCatch({
3170
+ innerType: type,
3171
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3172
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3173
+ ...processCreateParams(params)
3174
+ });
3175
+ };
3176
+ var ZodNaN = /* @__PURE__ */ __name(class extends ZodType {
3177
+ _parse(input) {
3178
+ const parsedType = this._getType(input);
3179
+ if (parsedType !== ZodParsedType.nan) {
3180
+ const ctx = this._getOrReturnCtx(input);
3181
+ addIssueToContext(ctx, {
3182
+ code: ZodIssueCode.invalid_type,
3183
+ expected: ZodParsedType.nan,
3184
+ received: ctx.parsedType
3185
+ });
3186
+ return INVALID;
3187
+ }
3188
+ return { status: "valid", value: input.data };
3189
+ }
3190
+ }, "ZodNaN");
3191
+ __name2(ZodNaN, "ZodNaN");
3192
+ ZodNaN.create = (params) => {
3193
+ return new ZodNaN({
3194
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
3195
+ ...processCreateParams(params)
3196
+ });
3197
+ };
3198
+ var BRAND = Symbol("zod_brand");
3199
+ var ZodBranded = /* @__PURE__ */ __name(class extends ZodType {
3200
+ _parse(input) {
3201
+ const { ctx } = this._processInputParams(input);
3202
+ const data = ctx.data;
3203
+ return this._def.type._parse({
3204
+ data,
3205
+ path: ctx.path,
3206
+ parent: ctx
3207
+ });
3208
+ }
3209
+ unwrap() {
3210
+ return this._def.type;
3211
+ }
3212
+ }, "ZodBranded");
3213
+ __name2(ZodBranded, "ZodBranded");
3214
+ var ZodPipeline = /* @__PURE__ */ __name(class extends ZodType {
3215
+ _parse(input) {
3216
+ const { status, ctx } = this._processInputParams(input);
3217
+ if (ctx.common.async) {
3218
+ const handleAsync = /* @__PURE__ */ __name2(async () => {
3219
+ const inResult = await this._def.in._parseAsync({
3220
+ data: ctx.data,
3221
+ path: ctx.path,
3222
+ parent: ctx
3223
+ });
3224
+ if (inResult.status === "aborted")
3225
+ return INVALID;
3226
+ if (inResult.status === "dirty") {
3227
+ status.dirty();
3228
+ return DIRTY(inResult.value);
3229
+ } else {
3230
+ return this._def.out._parseAsync({
3231
+ data: inResult.value,
3232
+ path: ctx.path,
3233
+ parent: ctx
3234
+ });
3235
+ }
3236
+ }, "handleAsync");
3237
+ return handleAsync();
3238
+ } else {
3239
+ const inResult = this._def.in._parseSync({
3240
+ data: ctx.data,
3241
+ path: ctx.path,
3242
+ parent: ctx
3243
+ });
3244
+ if (inResult.status === "aborted")
3245
+ return INVALID;
3246
+ if (inResult.status === "dirty") {
3247
+ status.dirty();
3248
+ return {
3249
+ status: "dirty",
3250
+ value: inResult.value
3251
+ };
3252
+ } else {
3253
+ return this._def.out._parseSync({
3254
+ data: inResult.value,
3255
+ path: ctx.path,
3256
+ parent: ctx
3257
+ });
3258
+ }
3259
+ }
3260
+ }
3261
+ static create(a, b) {
3262
+ return new ZodPipeline({
3263
+ in: a,
3264
+ out: b,
3265
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
3266
+ });
3267
+ }
3268
+ }, "ZodPipeline");
3269
+ __name2(ZodPipeline, "ZodPipeline");
3270
+ var custom = /* @__PURE__ */ __name2((check, params = {}, fatal) => {
3271
+ if (check)
3272
+ return ZodAny.create().superRefine((data, ctx) => {
3273
+ if (!check(data)) {
3274
+ const p = typeof params === "function" ? params(data) : params;
3275
+ const p2 = typeof p === "string" ? { message: p } : p;
3276
+ ctx.addIssue({ code: "custom", ...p2, fatal });
3277
+ }
3278
+ });
3279
+ return ZodAny.create();
3280
+ }, "custom");
3281
+ var late = {
3282
+ object: ZodObject.lazycreate
3283
+ };
3284
+ var ZodFirstPartyTypeKind;
3285
+ (function(ZodFirstPartyTypeKind2) {
3286
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
3287
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
3288
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
3289
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
3290
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
3291
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
3292
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
3293
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
3294
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
3295
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
3296
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
3297
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
3298
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
3299
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
3300
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
3301
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
3302
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
3303
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
3304
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
3305
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
3306
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
3307
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
3308
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
3309
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
3310
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
3311
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
3312
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
3313
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
3314
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
3315
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
3316
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
3317
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
3318
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
3319
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
3320
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
3321
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3322
+ var instanceOfType = /* @__PURE__ */ __name2((cls, params = {
3323
+ message: `Input not instance of ${cls.name}`
3324
+ }) => custom((data) => data instanceof cls, params, true), "instanceOfType");
3325
+ var stringType = ZodString.create;
3326
+ var numberType = ZodNumber.create;
3327
+ var nanType = ZodNaN.create;
3328
+ var bigIntType = ZodBigInt.create;
3329
+ var booleanType = ZodBoolean.create;
3330
+ var dateType = ZodDate.create;
3331
+ var symbolType = ZodSymbol.create;
3332
+ var undefinedType = ZodUndefined.create;
3333
+ var nullType = ZodNull.create;
3334
+ var anyType = ZodAny.create;
3335
+ var unknownType = ZodUnknown.create;
3336
+ var neverType = ZodNever.create;
3337
+ var voidType = ZodVoid.create;
3338
+ var arrayType = ZodArray.create;
3339
+ var objectType = ZodObject.create;
3340
+ var strictObjectType = ZodObject.strictCreate;
3341
+ var unionType = ZodUnion.create;
3342
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
3343
+ var intersectionType = ZodIntersection.create;
3344
+ var tupleType = ZodTuple.create;
3345
+ var recordType = ZodRecord.create;
3346
+ var mapType = ZodMap.create;
3347
+ var setType = ZodSet.create;
3348
+ var functionType = ZodFunction.create;
3349
+ var lazyType = ZodLazy.create;
3350
+ var literalType = ZodLiteral.create;
3351
+ var enumType = ZodEnum.create;
3352
+ var nativeEnumType = ZodNativeEnum.create;
3353
+ var promiseType = ZodPromise.create;
3354
+ var effectsType = ZodEffects.create;
3355
+ var optionalType = ZodOptional.create;
3356
+ var nullableType = ZodNullable.create;
3357
+ var preprocessType = ZodEffects.createWithPreprocess;
3358
+ var pipelineType = ZodPipeline.create;
3359
+ var ostring = /* @__PURE__ */ __name2(() => stringType().optional(), "ostring");
3360
+ var onumber = /* @__PURE__ */ __name2(() => numberType().optional(), "onumber");
3361
+ var oboolean = /* @__PURE__ */ __name2(() => booleanType().optional(), "oboolean");
3362
+ var coerce = {
3363
+ string: (arg) => ZodString.create({ ...arg, coerce: true }),
3364
+ number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
3365
+ boolean: (arg) => ZodBoolean.create({
3366
+ ...arg,
3367
+ coerce: true
3368
+ }),
3369
+ bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
3370
+ date: (arg) => ZodDate.create({ ...arg, coerce: true })
3371
+ };
3372
+ var NEVER = INVALID;
3373
+ var mod = /* @__PURE__ */ Object.freeze({
3374
+ __proto__: null,
3375
+ defaultErrorMap: errorMap,
3376
+ setErrorMap,
3377
+ getErrorMap,
3378
+ makeIssue,
3379
+ EMPTY_PATH,
3380
+ addIssueToContext,
3381
+ ParseStatus,
3382
+ INVALID,
3383
+ DIRTY,
3384
+ OK,
3385
+ isAborted,
3386
+ isDirty,
3387
+ isValid,
3388
+ isAsync,
3389
+ get util() {
3390
+ return util;
3391
+ },
3392
+ ZodParsedType,
3393
+ getParsedType,
3394
+ ZodType,
3395
+ ZodString,
3396
+ ZodNumber,
3397
+ ZodBigInt,
3398
+ ZodBoolean,
3399
+ ZodDate,
3400
+ ZodSymbol,
3401
+ ZodUndefined,
3402
+ ZodNull,
3403
+ ZodAny,
3404
+ ZodUnknown,
3405
+ ZodNever,
3406
+ ZodVoid,
3407
+ ZodArray,
3408
+ get objectUtil() {
3409
+ return objectUtil;
3410
+ },
3411
+ ZodObject,
3412
+ ZodUnion,
3413
+ ZodDiscriminatedUnion,
3414
+ ZodIntersection,
3415
+ ZodTuple,
3416
+ ZodRecord,
3417
+ ZodMap,
3418
+ ZodSet,
3419
+ ZodFunction,
3420
+ ZodLazy,
3421
+ ZodLiteral,
3422
+ ZodEnum,
3423
+ ZodNativeEnum,
3424
+ ZodPromise,
3425
+ ZodEffects,
3426
+ ZodTransformer: ZodEffects,
3427
+ ZodOptional,
3428
+ ZodNullable,
3429
+ ZodDefault,
3430
+ ZodCatch,
3431
+ ZodNaN,
3432
+ BRAND,
3433
+ ZodBranded,
3434
+ ZodPipeline,
3435
+ custom,
3436
+ Schema: ZodType,
3437
+ ZodSchema: ZodType,
3438
+ late,
3439
+ get ZodFirstPartyTypeKind() {
3440
+ return ZodFirstPartyTypeKind;
3441
+ },
3442
+ coerce,
3443
+ any: anyType,
3444
+ array: arrayType,
3445
+ bigint: bigIntType,
3446
+ boolean: booleanType,
3447
+ date: dateType,
3448
+ discriminatedUnion: discriminatedUnionType,
3449
+ effect: effectsType,
3450
+ "enum": enumType,
3451
+ "function": functionType,
3452
+ "instanceof": instanceOfType,
3453
+ intersection: intersectionType,
3454
+ lazy: lazyType,
3455
+ literal: literalType,
3456
+ map: mapType,
3457
+ nan: nanType,
3458
+ nativeEnum: nativeEnumType,
3459
+ never: neverType,
3460
+ "null": nullType,
3461
+ nullable: nullableType,
3462
+ number: numberType,
3463
+ object: objectType,
3464
+ oboolean,
3465
+ onumber,
3466
+ optional: optionalType,
3467
+ ostring,
3468
+ pipeline: pipelineType,
3469
+ preprocess: preprocessType,
3470
+ promise: promiseType,
3471
+ record: recordType,
3472
+ set: setType,
3473
+ strictObject: strictObjectType,
3474
+ string: stringType,
3475
+ symbol: symbolType,
3476
+ transformer: effectsType,
3477
+ tuple: tupleType,
3478
+ "undefined": undefinedType,
3479
+ union: unionType,
3480
+ unknown: unknownType,
3481
+ "void": voidType,
3482
+ NEVER,
3483
+ ZodIssueCode,
3484
+ quotelessJson,
3485
+ ZodError
3486
+ });
3487
+ var ContextValidator = mod.array(mod.string().or(mod.record(mod.any())));
3488
+ var AchievementCriteriaValidator = mod.object({
3489
+ type: mod.string().optional(),
3490
+ narrative: mod.string().optional()
3491
+ });
3492
+ var ImageValidator = mod.string().or(
3493
+ mod.object({
3494
+ id: mod.string(),
3495
+ type: mod.string(),
3496
+ caption: mod.string().optional()
3497
+ })
3498
+ );
3499
+ var GeoCoordinatesValidator = mod.object({
3500
+ type: mod.string().min(1).or(mod.string().array().nonempty()),
3501
+ latitude: mod.number(),
3502
+ longitude: mod.number()
3503
+ });
3504
+ var AddressValidator = mod.object({
3505
+ type: mod.string().min(1).or(mod.string().array().nonempty()),
3506
+ addressCountry: mod.string().optional(),
3507
+ addressCountryCode: mod.string().optional(),
3508
+ addressRegion: mod.string().optional(),
3509
+ addressLocality: mod.string().optional(),
3510
+ streetAddress: mod.string().optional(),
3511
+ postOfficeBoxNumber: mod.string().optional(),
3512
+ postalCode: mod.string().optional(),
3513
+ geo: GeoCoordinatesValidator.optional()
3514
+ });
3515
+ var IdentifierTypeValidator = mod.enum([
3516
+ "sourcedId",
3517
+ "systemId",
3518
+ "productId",
3519
+ "userName",
3520
+ "accountId",
3521
+ "emailAddress",
3522
+ "nationalIdentityNumber",
3523
+ "isbn",
3524
+ "issn",
3525
+ "lisSourcedId",
3526
+ "oneRosterSourcedId",
3527
+ "sisSourcedId",
3528
+ "ltiContextId",
3529
+ "ltiDeploymentId",
3530
+ "ltiToolId",
3531
+ "ltiPlatformId",
3532
+ "ltiUserId",
3533
+ "identifier"
3534
+ ]).or(mod.string());
3535
+ var IdentifierEntryValidator = mod.object({
3536
+ type: mod.string().min(1).or(mod.string().array().nonempty()),
3537
+ identifier: mod.string(),
3538
+ identifierType: IdentifierTypeValidator
3539
+ });
3540
+ var ProfileValidator = mod.string().or(
3541
+ mod.object({
3542
+ id: mod.string().optional(),
3543
+ type: mod.string().or(mod.string().array().nonempty().optional()),
3544
+ name: mod.string().optional(),
3545
+ url: mod.string().optional(),
3546
+ phone: mod.string().optional(),
3547
+ description: mod.string().optional(),
3548
+ endorsement: mod.any().array().optional(),
3549
+ image: ImageValidator.optional(),
3550
+ email: mod.string().email().optional(),
3551
+ address: AddressValidator.optional(),
3552
+ otherIdentifier: IdentifierEntryValidator.array().optional(),
3553
+ official: mod.string().optional(),
3554
+ parentOrg: mod.any().optional(),
3555
+ familyName: mod.string().optional(),
3556
+ givenName: mod.string().optional(),
3557
+ additionalName: mod.string().optional(),
3558
+ patronymicName: mod.string().optional(),
3559
+ honorificPrefix: mod.string().optional(),
3560
+ honorificSuffix: mod.string().optional(),
3561
+ familyNamePrefix: mod.string().optional(),
3562
+ dateOfBirth: mod.string().optional()
3563
+ }).catchall(mod.any())
3564
+ );
3565
+ var CredentialSubjectValidator = mod.object({ id: mod.string().optional() }).catchall(mod.any());
3566
+ var CredentialStatusValidator = mod.object({ type: mod.string(), id: mod.string() });
3567
+ var CredentialSchemaValidator = mod.object({ id: mod.string(), type: mod.string() });
3568
+ var RefreshServiceValidator = mod.object({ id: mod.string(), type: mod.string() }).catchall(mod.any());
3569
+ var UnsignedVCValidator = mod.object({
3570
+ "@context": ContextValidator,
3571
+ id: mod.string().optional(),
3572
+ type: mod.string().array().nonempty(),
3573
+ issuer: ProfileValidator,
3574
+ issuanceDate: mod.string(),
3575
+ expirationDate: mod.string().optional(),
3576
+ credentialSubject: CredentialSubjectValidator.or(CredentialSubjectValidator.array()),
3577
+ credentialStatus: CredentialStatusValidator.optional(),
3578
+ credentialSchema: CredentialSchemaValidator.array().optional(),
3579
+ refreshService: RefreshServiceValidator.optional()
3580
+ }).catchall(mod.any());
3581
+ var ProofValidator = mod.object({
3582
+ type: mod.string(),
3583
+ created: mod.string(),
3584
+ challenge: mod.string().optional(),
3585
+ domain: mod.string().optional(),
3586
+ nonce: mod.string().optional(),
3587
+ proofPurpose: mod.string(),
3588
+ verificationMethod: mod.string(),
3589
+ jws: mod.string().optional()
3590
+ }).catchall(mod.any());
3591
+ var VCValidator = UnsignedVCValidator.extend({
3592
+ proof: ProofValidator.or(ProofValidator.array())
3593
+ });
3594
+ var UnsignedVPValidator = mod.object({
3595
+ "@context": ContextValidator,
3596
+ id: mod.string().optional(),
3597
+ type: mod.string().array().nonempty(),
3598
+ verifiableCredential: VCValidator.or(VCValidator.array()).optional(),
3599
+ holder: mod.string().optional()
3600
+ }).catchall(mod.any());
3601
+ var VPValidator = UnsignedVPValidator.extend({
3602
+ proof: ProofValidator.or(ProofValidator.array())
3603
+ });
3604
+ var AlignmentTargetTypeValidator = mod.enum([
3605
+ "ceasn:Competency",
3606
+ "ceterms:Credential",
3607
+ "CFItem",
3608
+ "CFRubric",
3609
+ "CFRubricCriterion",
3610
+ "CFRubricCriterionLevel",
3611
+ "CTDL"
3612
+ ]).or(mod.string());
3613
+ var AlignmentValidator = mod.object({
3614
+ type: mod.string().array().nonempty(),
3615
+ targetCode: mod.string().optional(),
3616
+ targetDescription: mod.string().optional(),
3617
+ targetName: mod.string(),
3618
+ targetFramework: mod.string().optional(),
3619
+ targetType: AlignmentTargetTypeValidator.optional(),
3620
+ targetUrl: mod.string()
3621
+ });
3622
+ var KnownAchievementTypeValidator = mod.enum([
3623
+ "Achievement",
3624
+ "ApprenticeshipCertificate",
3625
+ "Assessment",
3626
+ "Assignment",
3627
+ "AssociateDegree",
3628
+ "Award",
3629
+ "Badge",
3630
+ "BachelorDegree",
3631
+ "Certificate",
3632
+ "CertificateOfCompletion",
3633
+ "Certification",
3634
+ "CommunityService",
3635
+ "Competency",
3636
+ "Course",
3637
+ "CoCurricular",
3638
+ "Degree",
3639
+ "Diploma",
3640
+ "DoctoralDegree",
3641
+ "Fieldwork",
3642
+ "GeneralEducationDevelopment",
3643
+ "JourneymanCertificate",
3644
+ "LearningProgram",
3645
+ "License",
3646
+ "Membership",
3647
+ "ProfessionalDoctorate",
3648
+ "QualityAssuranceCredential",
3649
+ "MasterCertificate",
3650
+ "MasterDegree",
3651
+ "MicroCredential",
3652
+ "ResearchDoctorate",
3653
+ "SecondarySchoolDiploma"
3654
+ ]);
3655
+ var AchievementTypeValidator = KnownAchievementTypeValidator.or(mod.string());
3656
+ var CriteriaValidator = mod.object({ id: mod.string().optional(), narrative: mod.string().optional() }).catchall(mod.any());
3657
+ var EndorsementSubjectValidator = mod.object({
3658
+ id: mod.string(),
3659
+ type: mod.string().array().nonempty(),
3660
+ endorsementComment: mod.string().optional()
3661
+ });
3662
+ var EndorsementCredentialValidator = UnsignedVCValidator.extend({
3663
+ credentialSubject: EndorsementSubjectValidator,
3664
+ proof: ProofValidator.or(ProofValidator.array()).optional()
3665
+ });
3666
+ var RelatedValidator = mod.object({
3667
+ id: mod.string(),
3668
+ "@language": mod.string().optional(),
3669
+ version: mod.string().optional()
3670
+ });
3671
+ var ResultTypeValidator = mod.enum([
3672
+ "GradePointAverage",
3673
+ "LetterGrade",
3674
+ "Percent",
3675
+ "PerformanceLevel",
3676
+ "PredictedScore",
3677
+ "RawScore",
3678
+ "Result",
3679
+ "RubricCriterion",
3680
+ "RubricCriterionLevel",
3681
+ "RubricScore",
3682
+ "ScaledScore",
3683
+ "Status"
3684
+ ]).or(mod.string());
3685
+ var RubricCriterionValidator = mod.object({
3686
+ id: mod.string(),
3687
+ type: mod.string().array().nonempty(),
3688
+ alignment: AlignmentValidator.array().optional(),
3689
+ description: mod.string().optional(),
3690
+ level: mod.string().optional(),
3691
+ name: mod.string(),
3692
+ points: mod.string().optional()
3693
+ }).catchall(mod.any());
3694
+ var ResultDescriptionValidator = mod.object({
3695
+ id: mod.string(),
3696
+ type: mod.string().array().nonempty(),
3697
+ alignment: AlignmentValidator.array().optional(),
3698
+ allowedValue: mod.string().array().optional(),
3699
+ name: mod.string(),
3700
+ requiredLevel: mod.string().optional(),
3701
+ requiredValue: mod.string().optional(),
3702
+ resultType: ResultTypeValidator,
3703
+ rubricCriterionLevel: RubricCriterionValidator.array().optional(),
3704
+ valueMax: mod.string().optional(),
3705
+ valueMin: mod.string().optional()
3706
+ }).catchall(mod.any());
3707
+ var AchievementValidator = mod.object({
3708
+ id: mod.string().optional(),
3709
+ type: mod.string().array().nonempty(),
3710
+ alignment: AlignmentValidator.array().optional(),
3711
+ achievementType: AchievementTypeValidator.optional(),
3712
+ creator: ProfileValidator.optional(),
3713
+ creditsAvailable: mod.number().optional(),
3714
+ criteria: CriteriaValidator,
3715
+ description: mod.string(),
3716
+ endorsement: EndorsementCredentialValidator.array().optional(),
3717
+ fieldOfStudy: mod.string().optional(),
3718
+ humanCode: mod.string().optional(),
3719
+ image: ImageValidator.optional(),
3720
+ "@language": mod.string().optional(),
3721
+ name: mod.string(),
3722
+ otherIdentifier: IdentifierEntryValidator.array().optional(),
3723
+ related: RelatedValidator.array().optional(),
3724
+ resultDescription: ResultDescriptionValidator.array().optional(),
3725
+ specialization: mod.string().optional(),
3726
+ tag: mod.string().array().optional(),
3727
+ version: mod.string().optional()
3728
+ }).catchall(mod.any());
3729
+ var IdentityObjectValidator = mod.object({
3730
+ type: mod.string(),
3731
+ hashed: mod.boolean(),
3732
+ identityHash: mod.string(),
3733
+ identityType: mod.string(),
3734
+ salt: mod.string().optional()
3735
+ });
3736
+ var ResultStatusTypeValidator = mod.enum([
3737
+ "Completed",
3738
+ "Enrolled",
3739
+ "Failed",
3740
+ "InProgress",
3741
+ "OnHold",
3742
+ "Withdrew"
3743
+ ]);
3744
+ var ResultValidator = mod.object({
3745
+ type: mod.string().array().nonempty(),
3746
+ achievedLevel: mod.string().optional(),
3747
+ alignment: AlignmentValidator.array().optional(),
3748
+ resultDescription: mod.string().optional(),
3749
+ status: ResultStatusTypeValidator.optional(),
3750
+ value: mod.string().optional()
3751
+ }).catchall(mod.any());
3752
+ var AchievementSubjectValidator = mod.object({
3753
+ id: mod.string().optional(),
3754
+ type: mod.string().array().nonempty(),
3755
+ activityEndDate: mod.string().optional(),
3756
+ activityStartDate: mod.string().optional(),
3757
+ creditsEarned: mod.number().optional(),
3758
+ achievement: AchievementValidator.optional(),
3759
+ identifier: IdentityObjectValidator.array().optional(),
3760
+ image: ImageValidator.optional(),
3761
+ licenseNumber: mod.string().optional(),
3762
+ narrative: mod.string().optional(),
3763
+ result: ResultValidator.array().optional(),
3764
+ role: mod.string().optional(),
3765
+ source: ProfileValidator.optional(),
3766
+ term: mod.string().optional()
3767
+ }).catchall(mod.any());
3768
+ var EvidenceValidator = mod.object({
3769
+ id: mod.string().optional(),
3770
+ type: mod.string().array().nonempty(),
3771
+ narrative: mod.string().optional(),
3772
+ name: mod.string().optional(),
3773
+ description: mod.string().optional(),
3774
+ genre: mod.string().optional(),
3775
+ audience: mod.string().optional()
3776
+ }).catchall(mod.any());
3777
+ var UnsignedAchievementCredentialValidator = UnsignedVCValidator.extend({
3778
+ name: mod.string().optional(),
3779
+ description: mod.string().optional(),
3780
+ image: ImageValidator.optional(),
3781
+ credentialSubject: AchievementSubjectValidator.or(AchievementSubjectValidator.array()),
3782
+ endorsement: UnsignedVCValidator.array().optional(),
3783
+ evidence: EvidenceValidator.array().optional()
3784
+ });
3785
+ var AchievementCredentialValidator = UnsignedAchievementCredentialValidator.extend({
3786
+ proof: ProofValidator.or(ProofValidator.array())
3787
+ });
3788
+ var VerificationCheckValidator = mod.object({
3789
+ checks: mod.string().array(),
3790
+ warnings: mod.string().array(),
3791
+ errors: mod.string().array()
3792
+ });
3793
+ var VerificationStatusValidator = mod.enum(["Success", "Failed", "Error"]);
3794
+ var VerificationStatusEnum = VerificationStatusValidator.enum;
3795
+ var VerificationItemValidator = mod.object({
3796
+ check: mod.string(),
3797
+ status: VerificationStatusValidator,
3798
+ message: mod.string().optional(),
3799
+ details: mod.string().optional()
3800
+ });
3801
+ var CredentialInfoValidator = mod.object({
3802
+ title: mod.string().optional(),
3803
+ createdAt: mod.string().optional(),
3804
+ issuer: ProfileValidator.optional(),
3805
+ issuee: ProfileValidator.optional(),
3806
+ credentialSubject: CredentialSubjectValidator.optional()
3807
+ });
3808
+ var CredentialRecordValidator = mod.object({ id: mod.string(), uri: mod.string() }).catchall(mod.any());
3809
+ var PaginationOptionsValidator = mod.object({
3810
+ limit: mod.number(),
3811
+ cursor: mod.string().optional()
3812
+ });
3813
+ var PaginationResponseValidator = mod.object({
3814
+ cursor: mod.string().optional(),
3815
+ hasMore: mod.boolean()
3816
+ });
3817
+ var JWKValidator = mod.object({
3818
+ kty: mod.string(),
3819
+ crv: mod.string(),
3820
+ x: mod.string(),
3821
+ y: mod.string().optional(),
3822
+ n: mod.string().optional(),
3823
+ d: mod.string()
3824
+ });
3825
+ var JWERecipientHeaderValidator = mod.object({
3826
+ alg: mod.string(),
3827
+ iv: mod.string(),
3828
+ tag: mod.string(),
3829
+ epk: JWKValidator.partial().optional(),
3830
+ kid: mod.string().optional(),
3831
+ apv: mod.string().optional(),
3832
+ apu: mod.string().optional()
3833
+ });
3834
+ var JWERecipientValidator = mod.object({
3835
+ header: JWERecipientHeaderValidator,
3836
+ encrypted_key: mod.string()
3837
+ });
3838
+ var JWEValidator2 = mod.object({
3839
+ protected: mod.string(),
3840
+ iv: mod.string(),
3841
+ ciphertext: mod.string(),
3842
+ tag: mod.string(),
3843
+ aad: mod.string().optional(),
3844
+ recipients: JWERecipientValidator.array().optional()
3845
+ });
3846
+ var EncryptedCredentialRecordValidator = mod.object({
3847
+ encryptedRecord: JWEValidator2,
3848
+ fields: mod.string().array(),
3849
+ id: mod.string()
3850
+ }).catchall(mod.any());
3851
+ var PaginatedEncryptedCredentialRecordsValidator = PaginationResponseValidator.extend({
3852
+ records: EncryptedCredentialRecordValidator.array()
3853
+ });
3854
+ var LCNProfileValidator = mod.object({
3855
+ profileId: mod.string().min(3).max(40),
3856
+ displayName: mod.string().default(""),
3857
+ did: mod.string(),
3858
+ email: mod.string().optional(),
3859
+ image: mod.string().optional(),
3860
+ isServiceProfile: mod.boolean().default(false).optional(),
3861
+ notificationsWebhook: mod.string().url().startsWith("https://").optional()
3862
+ });
3863
+ var LCNProfileConnectionStatusEnum = mod.enum([
3864
+ "CONNECTED",
3865
+ "PENDING_REQUEST_SENT",
3866
+ "PENDING_REQUEST_RECEIVED",
3867
+ "NOT_CONNECTED"
3868
+ ]);
3869
+ var SentCredentialInfoValidator = mod.object({
3870
+ uri: mod.string(),
3871
+ to: mod.string(),
3872
+ from: mod.string(),
3873
+ sent: mod.string().datetime(),
3874
+ received: mod.string().datetime().optional()
3875
+ });
3876
+ var LCNBoostStatus = mod.enum(["DRAFT", "LIVE"]);
3877
+ var BoostValidator = mod.object({
3878
+ uri: mod.string(),
3879
+ name: mod.string().optional(),
3880
+ type: mod.string().optional(),
3881
+ category: mod.string().optional(),
3882
+ status: LCNBoostStatus.optional()
3883
+ });
3884
+ var BoostRecipientValidator = mod.object({
3885
+ to: LCNProfileValidator,
3886
+ from: mod.string(),
3887
+ received: mod.string()
3888
+ });
3889
+ var LCNNotificationTypeEnumValidator = mod.enum([
3890
+ "CONNECTION_REQUEST",
3891
+ "CONNECTION_ACCEPTED",
3892
+ "CREDENTIAL_RECEIVED",
3893
+ "CREDENTIAL_ACCEPTED",
3894
+ "BOOST_RECEIVED",
3895
+ "BOOST_ACCEPTED",
3896
+ "PRESENTATION_REQUEST",
3897
+ "PRESENTATION_RECEIVED"
3898
+ ]);
3899
+ var LCNNotificationMessageValidator = mod.object({
3900
+ title: mod.string().optional(),
3901
+ body: mod.string().optional()
3902
+ });
3903
+ var LCNNotificationDataValidator = mod.object({
3904
+ vcUris: mod.array(mod.string()).optional(),
3905
+ vpUris: mod.array(mod.string()).optional()
3906
+ });
3907
+ var LCNNotificationValidator = mod.object({
3908
+ type: LCNNotificationTypeEnumValidator,
3909
+ to: LCNProfileValidator.partial().and(mod.object({ did: mod.string() })),
3910
+ from: LCNProfileValidator.partial().and(mod.object({ did: mod.string() })),
3911
+ message: LCNNotificationMessageValidator.optional(),
3912
+ data: LCNNotificationDataValidator.optional(),
3913
+ sent: mod.string().datetime().optional()
3914
+ });
3915
+ var LCNBoostClaimLinkSigningAuthorityValidator = mod.object({
3916
+ endpoint: mod.string(),
3917
+ name: mod.string(),
3918
+ did: mod.string().optional()
3919
+ });
3920
+ var LCNBoostClaimLinkOptionsValidator = mod.object({
3921
+ ttlSeconds: mod.number().optional(),
3922
+ totalUses: mod.number().optional()
3923
+ });
3924
+ var LCNSigningAuthorityValidator = mod.object({
3925
+ endpoint: mod.string()
3926
+ });
3927
+ var LCNSigningAuthorityForUserValidator = mod.object({
3928
+ signingAuthority: LCNSigningAuthorityValidator,
3929
+ relationship: mod.object({
3930
+ name: mod.string().max(15).regex(/^[a-z0-9-]+$/, {
3931
+ message: "The input string must contain only lowercase letters, numbers, and hyphens."
3932
+ }),
3933
+ did: mod.string()
3934
+ })
3935
+ });
3936
+ }
3937
+ });
3938
+
3939
+ // ../learn-card-types/dist/index.js
3940
+ var require_dist = __commonJS({
3941
+ "../learn-card-types/dist/index.js"(exports, module2) {
3942
+ "use strict";
3943
+ if (false) {
3944
+ module2.exports = null;
3945
+ } else {
3946
+ module2.exports = require_types_cjs_development();
3947
+ }
3948
+ }
3949
+ });
3950
+
20
3951
  // src/index.ts
21
3952
  var src_exports = {};
22
3953
  __export(src_exports, {
3954
+ isEncrypted: () => isEncrypted,
23
3955
  isHex: () => isHex
24
3956
  });
25
3957
  module.exports = __toCommonJS(src_exports);
3958
+ var import_types = __toESM(require_dist());
26
3959
  var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
3960
+ var isEncrypted = /* @__PURE__ */ __name((item) => {
3961
+ return import_types.JWEValidator.safeParse(item).success;
3962
+ }, "isEncrypted");